@markgrafhq/markgraf-embed 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/markgraf-embed.js +16 -16
- package/package.json +1 -1
package/dist/markgraf-embed.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
`:return"\\n";case"\r":return"\\r";case" ":return"\\t";case"\v":return"\\v"}var i=r+1,o=i<e&&t[i]>="0"&&t[i]<="9"?"\\&":"";return"\\"+n.charCodeAt(0).toString(10)+o})+'"'},xu=t=>t,ye=xu("LT"),xe=xu("GT"),Ge=xu("EQ"),w=(t,e)=>({tag:t,_1:e}),T=w("Nothing"),Yt=t=>w("Just",t),Sa=t=>{if(t.tag==="Nothing")return!0;if(t.tag==="Just")return!1;g()},Ga=t=>{if(t.tag==="Nothing")return!1;if(t.tag==="Just")return!0;g()},Gt=(t,e)=>({tag:t,_1:e}),k1=t=>Gt("Right",t),E1={map:t=>e=>{if(e.tag==="Left")return Gt("Left",e._1);if(e.tag==="Right")return Gt("Right",t(e._1));g()}},Pa={apply:t=>e=>{if(t.tag==="Left")return Gt("Left",t._1);if(t.tag==="Right"){if(e.tag==="Left")return Gt("Left",e._1);if(e.tag==="Right")return Gt("Right",t._1(e._1))}g()},Functor0:()=>E1},C1={bind:t=>{if(t.tag==="Left"){const e=t._1;return n=>Gt("Left",e)}if(t.tag==="Right"){const e=t._1;return n=>n(e)}g()},Apply0:()=>Pa},S1={pure:k1,Apply0:()=>Pa},Ia={Applicative0:()=>S1,Bind1:()=>C1},G1=t=>t,P1={map:t=>e=>t(e)},Da={apply:t=>e=>t(e),Functor0:()=>P1},I1={bind:t=>e=>e(t),Apply0:()=>Da},D1={pure:G1,Apply0:()=>Da},Mn={Applicative0:()=>D1,Bind1:()=>I1},A1=function(t){return function(){return t}},B1={apply:t=>e=>()=>{const n=t(),r=e();return Nu.pure(n(r))()},Functor0:()=>F1},Nu={pure:A1,Apply0:()=>B1},F1={map:t=>e=>()=>{const n=e();return t(n)}},Zr=(t,e)=>({tag:t,_1:e}),Aa=t=>Zr("Loop",t),R1={tailRecM:t=>{const e=n=>{let r=n,i=!0,o;for(;i;){const u=r;if(u.tag==="Loop"){r=t(u._1);continue}if(u.tag==="Done"){i=!1,o=u._1;continue}g()}return o};return n=>e(t(n))},Monad0:()=>Mn},Q1=function(t){return function(e){return function(){return t(e())}}},z1=function(t){return function(){return t}},W1={map:Q1},M1={apply:t=>e=>()=>{const n=t(),r=e();return Ba.pure(n(r))()},Functor0:()=>W1},Ba={pure:z1,Apply0:()=>M1},H1=(function(t){return function(e){return function(n){return function(){return t(e,n)}}}})(function(t,e){return e.push(t)}),O1=(t,e)=>({tag:"Iterator",_1:t,_2:e}),q1=t=>e=>n=>()=>{let r=!1;const i=e._2;for(;!r;){const o=i.value,u=e._1(o);if(u.tag==="Just"&&t(u._1)){n.push(u._1),e._2.value;const s=e._2.value;e._2.value=s+1|0;continue}r=!0}},$1=t=>e=>()=>{let n=!1;const r=t._2;for(;!n;){const i=r.value,o=r.value;r.value=o+1|0;const u=t._1(i);if(u.tag==="Just"){e(u._1)();continue}if(u.tag==="Nothing"){n=!0;continue}g()}},Kr=function(t){return function(e){return function(n){for(var r=e,i=n.length,o=i-1;o>=0;o--)r=t(n[o])(r);return r}}},J=function(t){return function(e){return function(n){for(var r=e,i=n.length,o=0;o<i;o++)r=t(r)(n[o]);return r}}},Ju=t=>{const e=t.Apply0();return n=>r=>n.foldr(i=>{const o=r(i);return u=>e.apply(e.Functor0().map(s=>Ea)(o))(u)})(t.pure())},Y1=t=>{const e=Ju(t);return n=>{const r=e(n);return i=>o=>r(o)(i)}},zt={foldr:Kr,foldl:J,foldMap:t=>{const e=t.mempty;return n=>zt.foldr(r=>i=>t.Semigroup0().append(n(r))(i))(e)}},b=(t,e)=>({tag:"Tuple",_1:t,_2:e}),Hn=t=>e=>b(t,e),$i=t=>t._2,Yi=t=>t._1,At=function(t){return function(e){for(var n=e.length,r=Array(n),i=0;i<n;i++)r[i]=t(i)(e[i]);return r}};var Tu=function(t){return function(e){return t===e}};const X1=Tu,V1=Tu,ti=Tu,vu=function(t){return function(e){return function(n){if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(!t(e[r])(n[r]))return!1;return!0}}},gn={eq:ti},U1={eq:V1},xr={eq:X1};var wu=function(t){return function(e){return function(n){return function(r){return function(i){return r<i?t:r===i?e:n}}}}};const j1=wu,Z1=wu,P={compare:wu(ye)(Ge)(xe),Eq0:()=>gn},st={compare:Z1(ye)(Ge)(xe),Eq0:()=>U1},it={compare:j1(ye)(Ge)(xe),Eq0:()=>xr},K1=function(t){return t},td=(function(){function t(i){return[i]}function e(i){return function(o){return[i,o]}}function n(i){return function(o){return function(u){return[i,o,u]}}}function r(i){return function(o){return i.concat(o)}}return function(i){return function(o){return function(u){return function(s){return function(a){function c(f,d){switch(d-f){case 0:return u([]);case 1:return o(t)(s(a[f]));case 2:return i(o(e)(s(a[f])))(s(a[f+1]));case 3:return i(i(o(n)(s(a[f])))(s(a[f+1])))(s(a[f+2]));default:var l=f+Math.floor((d-f)/4)*2;return i(o(r)(c(f,l)))(c(l,d))}}return c(0,a.length)}}}}}})(),ed=t=>t,ir={traverse:t=>{const e=t.Apply0();return td(e.apply)(e.Functor0().map)(t.pure)},sequence:t=>ir.traverse(t)(ed),Functor0:()=>b1,Foldable1:()=>zt},Dt=function(t,e){for(var n=t>e?-1:1,r=new Array(n*(e-t)+1),i=t,o=0;i!==e;)r[o++]=i,i+=n;return r[o]=i,r};var nd=function(t,e){if(t<1)return[];var n=new Array(t);return n.fill(e)},rd=function(t,e){for(var n=[],r=0,i=0;i<t;i++)n[r++]=e;return n};const id=typeof Array.prototype.fill=="function"?nd:rd,kt=(function(){function t(i,o){this.head=i,this.tail=o}var e={};function n(i){return function(o){return new t(i,o)}}function r(i){for(var o=[],u=0,s=i;s!==e;)o[u++]=s.head,s=s.tail;return o}return function(i,o){return r(i(n)(e)(o))}})(),Bt=function(t,e,n){return n.length===0?t({}):e(n[0])(n.slice(1))},Fa=function(t,e,n,r){for(var i=0;i<r.length;i++){var o=n(r[i]);if(e(o))return o}return t},On=function(t,e,n,r){for(var i=0,o=r.length;i<o;i++)if(n(r[i]))return t(i);return e},Ra=function(t,e,n,r){for(var i=r.length-1;i>=0;i--)if(n(r[i]))return t(i);return e},Qa=function(t,e,n,r,i){if(n<0||n>i.length)return e;var o=i.slice();return o.splice(n,0,r),t(o)},za=function(t,e,n,r){if(n<0||n>=r.length)return e;var i=r.slice();return i.splice(n,1),t(i)},qn=function(t,e,n,r,i){if(n<0||n>=i.length)return e;var o=i.slice();return o[n]=r,t(o)},ke=function(t){return t.slice().reverse()},Fe=function(t){if(t.length<=1e4)return Array.prototype.concat.apply([],t);for(var e=[],n=0,r=t.length;n<r;n++)for(var i=t[n],o=0,u=i.length;o<u;o++)e.push(i[o]);return e},at=function(t,e){return e.filter(t)},od=function(t,e,n){for(var r=n.length,i=e,o=new Array(r),u=0;u<r;u++)i=t(i)(n[u]),o[u]=i;return o},ud=(function(){function t(e,n,r,i,o,u){var s,a,c,f,d,l,_;for(s=o+(u-o>>1),s-o>1&&t(e,n,i,r,o,s),u-s>1&&t(e,n,i,r,s,u),a=o,c=s,f=o;a<s&&c<u;)d=i[a],l=i[c],_=n(e(d)(l)),_>0?(r[f++]=l,++c):(r[f++]=d,++a);for(;a<s;)r[f++]=i[a++];for(;c<u;)r[f++]=i[c++]}return function(e,n,r){var i;return r.length<2?r:(i=r.slice(0),t(e,n,i,r.slice(0),0,r.length),i)}})(),bt=function(t,e,n){return n.slice(t,e)},Je=function(t,e,n){for(var r=e.length<n.length?e.length:n.length,i=new Array(r),o=0;o<r;o++)i[o]=t(e[o])(n[o]);return i},Re=function(t,e){for(var n=e.length,r=0;r<n;r++)if(t(e[r]))return!0;return!1},Wa=function(t,e){for(var n=e.length,r=0;r<n;r++)if(!t(e[r]))return!1;return!0},Lt=t=>e=>ud(t,n=>{if(n==="GT")return 1;if(n==="EQ")return 0;if(n==="LT")return-1;g()},e),sd=t=>e=>Lt(n=>r=>t.compare(e(n))(e(r))),Ft=t=>e=>(()=>{const n=H1(e);return()=>{const r=[...t];return n(r)(),r}})()(),Xi=t=>{if(t.length===0)return t.length-1|0,T;const e=t.length-1|0;return e>=0&&e<t.length?w("Just",{init:bt(0,t.length-1|0,t),last:t[e]}):T},Ma=t=>e=>n=>t>=0&&t<n.length?qn(Yt,T,t,e(n[t]),n):T,or=t=>e=>{const n=(r=>{let i=r,o=!0,u;for(;o;){const s=i;if(s>=0&&s<e.length){if(t(e[s])){i=s+1|0;continue}o=!1,u=w("Just",s);continue}o=!1,u=T}return u})(0);if(n.tag==="Just")return n._1===0?{init:[],rest:e}:{init:bt(0,n._1,e),rest:bt(n._1,e.length,e)};if(n.tag==="Nothing")return{init:e,rest:[]};g()},Nr=t=>e=>{const n=Lt(r=>i=>t(r._2)(i._2))(At(Hn)(e));return 0<n.length?O($i)(sd(it)(Yi)((()=>{const r=[n[0]];for(const i of n){const o=t((()=>{const u=r.length-1|0;if(u>=0&&u<r.length)return r[u]._2;g()})())(i._2);(o==="LT"||o==="GT"||o!=="EQ")&&r.push(i)}return r})())):[]},ad=t=>e=>{const n=[],r=O1(i=>i>=0&&i<e.length?w("Just",e[i]):T,{value:0});return $1(r)(i=>()=>{const o=[];o.push(i),q1(t(i))(r)(o)(),n.push(o)})(),n},Xt=t=>e=>{const n=On(Yt,T,t,e);return n.tag==="Just"?w("Just",e[n._1]):T},Ha=t=>e=>at(t,e),Qe=t=>e=>n=>{const r=On(Yt,T,i=>t.eq(i)(e),n);if(r.tag==="Nothing")return!1;if(r.tag==="Just")return!0;g()},Oa=t=>e=>Tt(e)(t),xt=t=>Oa(e=>{const n=t(e);if(n.tag==="Nothing")return[];if(n.tag==="Just")return[n._1];g()}),qa=isFinite;function cd(t,e,n,r){var i=parseFloat(t);return e(i)?n(i):r}const $n=Math.abs,gd=Math.acos,ur=function(t){return function(e){return Math.atan2(t,e)}},Vi=Math.ceil,Ke=Math.cos,Ui=Math.exp,dn=Math.floor,$a=Math.log,fd=function(t){return function(e){return Math.min(t,e)}},bu=function(t){return function(e){return Math.pow(t,e)}},Yn=Math.round,Oe=Math.sin,Ee=Math.sqrt,_d=Math.tan,dd=function(t){return function(e){return function(n){return(n|0)===n?t(n):e}}},rt=function(t){return t},ld=(function(t){return function(e){return function(n){var r;n<11?r="[0-"+(n-1).toString()+"]":n===11?r="[0-9a]":r="[0-9a-"+String.fromCharCode(86+n)+"]";var i=new RegExp("^[\\+\\-]?"+r+"+$","i");return function(o){if(i.test(o)){var u=parseInt(o,n);return(u|0)===u?t(u):e}else return e}}}})(Yt)(T)(10),Ya=dd(Yt)(T),de=t=>{if(!qa(t))return 0;if(t>=rt(2147483647))return 2147483647;if(t<=rt(-2147483648))return-2147483648;const e=Ya(t);if(e.tag==="Nothing")return 0;if(e.tag==="Just")return e._1;g()},Ot=(t,e,n)=>({tag:t,_1:e,_2:n}),qt=Ot("Nil"),$t={foldr:t=>e=>{const n=$t.foldl(i=>o=>t(o)(i))(e),r=(i=>o=>{let u=i,s=o,a=!0,c;for(;a;){const f=u,d=s;if(d.tag==="Nil"){a=!1,c=f;continue}if(d.tag==="Cons"){u=Ot("Cons",d._1,f),s=d._2;continue}g()}return c})(qt);return i=>n(r(i))},foldl:t=>e=>n=>{let r=e,i=n,o=!0,u;for(;o;){const s=r,a=i;if(a.tag==="Nil"){o=!1,u=s;continue}if(a.tag==="Cons"){r=t(s)(a._1),i=a._2;continue}g()}return u},foldMap:t=>{const e=t.mempty;return n=>$t.foldl(r=>{const i=t.Semigroup0().append(r);return o=>i(n(o))})(e)}},hd=function(t){return function(e){return function(n){return function(r){return function(i){return function(o){for(var u=[],s=o;;){var a=i(s);u.push(n(a));var c=r(a);if(t(c))return u;s=e(c)}}}}}}},pd=t=>{if(t.tag==="Just")return t._1;g()},md={unfoldr1:hd(Sa)(pd)(Yi)($i)},yd=function(t){return function(e){return function(n){return function(r){return function(i){return function(o){for(var u=[],s=o;;){var a=i(s);if(t(a))return u;var c=e(a);u.push(n(c)),s=r(c)}}}}}}},xd=t=>{if(t.tag==="Just")return t._1;g()},qe={unfoldr:yd(Sa)(xd)(Yi)($i),Unfoldable10:()=>md},Mt=(t,e,n,r,i,o,u)=>({tag:t,_1:e,_2:n,_3:r,_4:i,_5:o,_6:u}),$e=(t,e,n,r)=>({tag:t,_1:e,_2:n,_3:r}),ji=(t,e,n)=>({tag:"Split",_1:t,_2:e,_3:n}),Xa=(t,e,n)=>({tag:"SplitLast",_1:t,_2:e,_3:n}),A=Mt("Leaf"),ln=$e("IterLeaf"),se=(t,e,n,r)=>{if(n.tag==="Leaf"){if(r.tag==="Leaf")return Mt("Node",1,1,t,e,n,r);if(r.tag==="Node")return Mt("Node",1+r._1|0,1+r._2|0,t,e,n,r);g()}if(n.tag==="Node"){if(r.tag==="Leaf")return Mt("Node",1+n._1|0,1+n._2|0,t,e,n,r);if(r.tag==="Node")return Mt("Node",n._1>r._1?1+n._1|0:1+r._1|0,(1+n._2|0)+r._2|0,t,e,n,r)}g()},ze=(t,e,n,r)=>{if(n.tag==="Leaf")return r.tag==="Leaf"?Mt("Node",1,1,t,e,A,A):r.tag==="Node"&&r._1>1?r._5.tag==="Node"&&(()=>{if(r._6.tag==="Leaf")return r._5._1>0;if(r._6.tag==="Node")return r._5._1>r._6._1;g()})()?se(r._5._3,r._5._4,se(t,e,n,r._5._5),se(r._3,r._4,r._5._6,r._6)):se(r._3,r._4,se(t,e,n,r._5),r._6):se(t,e,n,r);if(n.tag==="Node")return r.tag==="Node"?r._1>(n._1+1|0)?r._5.tag==="Node"&&(()=>{if(r._6.tag==="Leaf")return r._5._1>0;if(r._6.tag==="Node")return r._5._1>r._6._1;g()})()?se(r._5._3,r._5._4,se(t,e,n,r._5._5),se(r._3,r._4,r._5._6,r._6)):se(r._3,r._4,se(t,e,n,r._5),r._6):n._1>(r._1+1|0)?n._6.tag==="Node"&&(()=>{if(n._5.tag==="Leaf")return 0<=n._6._1;if(n._5.tag==="Node")return n._5._1<=n._6._1;g()})()?se(n._6._3,n._6._4,se(n._3,n._4,n._5,n._6._5),se(t,e,n._6._6,r)):se(n._3,n._4,n._5,se(t,e,n._6,r)):se(t,e,n,r):r.tag==="Leaf"&&n._1>1?n._6.tag==="Node"&&(()=>{if(n._5.tag==="Leaf")return 0<=n._6._1;if(n._5.tag==="Node")return n._5._1<=n._6._1;g()})()?se(n._6._3,n._6._4,se(n._3,n._4,n._5,n._6._5),se(t,e,n._6._6,r)):se(n._3,n._4,n._5,se(t,e,n._6,r)):se(t,e,n,r);g()},Jr=(t,e,n)=>{if(n.tag==="Leaf")return ji(T,A,A);if(n.tag==="Node"){const r=t(e)(n._3);if(r==="LT"){const i=Jr(t,e,n._5);return ji(i._1,i._2,ze(n._3,n._4,i._3,n._6))}if(r==="GT"){const i=Jr(t,e,n._6);return ji(i._1,ze(n._3,n._4,n._5,i._2),i._3)}if(r==="EQ")return ji(w("Just",n._4),n._5,n._6)}g()},Va=(t,e,n,r)=>{if(r.tag==="Leaf")return Xa(t,e,n);if(r.tag==="Node"){const i=Va(r._3,r._4,r._5,r._6);return Xa(i._1,i._2,ze(t,e,n,i._3))}g()},ei=(t,e)=>{if(t.tag==="Leaf")return e;if(t.tag==="Node"){const n=Va(t._3,t._4,t._5,t._6);return ze(n._1,n._2,n._3,e)}g()},Cn=(t,e,n)=>{if(e.tag==="Leaf")return A;if(n.tag==="Leaf")return e;if(n.tag==="Node"){const r=Jr(t,n._3,e);return ei(Cn(t,r._2,n._5),Cn(t,r._3,n._6))}g()},Zi=(t,e,n,r)=>{if(n.tag==="Leaf"||r.tag==="Leaf")return A;if(r.tag==="Node"){const i=Jr(t,r._3,n),o=Zi(t,e,i._2,r._5),u=Zi(t,e,i._3,r._6);if(i._1.tag==="Just")return ze(r._3,e(i._1._1)(r._4),o,u);if(i._1.tag==="Nothing")return ei(o,u)}g()},Ce=(t,e,n,r)=>{if(n.tag==="Leaf")return r;if(r.tag==="Leaf")return n;if(r.tag==="Node"){const i=Jr(t,r._3,n),o=Ce(t,e,i._2,r._5),u=Ce(t,e,i._3,r._6);if(i._1.tag==="Just")return ze(r._3,e(i._1._1)(r._4),o,u);if(i._1.tag==="Nothing")return ze(r._3,r._4,o,u)}g()},Nd=t=>e=>{const n=r=>{if(r.tag==="Leaf")return A;if(r.tag==="Node"){const i=e(r._3)(r._4);if(i.tag==="Just")return ze(r._3,i._1,n(r._5),n(r._6));if(i.tag==="Nothing")return ei(n(r._5),n(r._6))}g()};return n},hn=(t=>e=>n=>{let r=n,i=!0,o;for(;i;){const u=r;if(u.tag==="IterLeaf"){i=!1,o=e();continue}if(u.tag==="IterEmit"){i=!1,o=t(u._1,u._2,u._3);continue}if(u.tag==="IterNode"){r=(s=>a=>{let c=s,f=a,d=!0,l;for(;d;){const _=c,h=f;if(h.tag==="Leaf"){d=!1,l=_;continue}if(h.tag==="Node"){if(h._6.tag==="Leaf"){c=$e("IterEmit",h._3,h._4,_),f=h._5;continue}c=$e("IterEmit",h._3,h._4,$e("IterNode",h._6,_)),f=h._5;continue}g()}return l})(u._2)(u._1);continue}g()}return o})((t,e,n)=>w("Just",b(b(t,e),n)))(t=>T),vt=t=>e=>n=>r=>{const i=o=>{if(o.tag==="Leaf")return Mt("Node",1,1,n,r,A,A);if(o.tag==="Node"){const u=t.compare(n)(o._3);if(u==="LT")return ze(o._3,o._4,i(o._5),o._6);if(u==="GT")return ze(o._3,o._4,o._5,i(o._6));if(u==="EQ")return Mt("Node",o._1,o._2,n,e(o._4)(r),o._5,o._6)}g()};return i},K=t=>e=>n=>{const r=i=>{if(i.tag==="Leaf")return Mt("Node",1,1,e,n,A,A);if(i.tag==="Node"){const o=t.compare(e)(i._3);if(o==="LT")return ze(i._3,i._4,r(i._5),i._6);if(o==="GT")return ze(i._3,i._4,i._5,r(i._6));if(o==="EQ")return Mt("Node",i._1,i._2,e,n,i._5,i._6)}g()};return r},Kt=t=>e=>e.foldl(n=>r=>K(t)(r._1)(r._2)(n))(A),ni=t=>e=>{const n=r=>{if(r.tag==="Leaf")return A;if(r.tag==="Node"){const i=t.compare(e)(r._3);if(i==="LT")return ze(r._3,r._4,n(r._5),r._6);if(i==="GT")return ze(r._3,r._4,r._5,n(r._6));if(i==="EQ")return ei(r._5,r._6)}g()};return n},Ua=t=>{const e=t.compare;return n=>r=>i=>{const o=Jr(e,r,i),u=n(o._1);if(u.tag==="Nothing")return ei(o._2,o._3);if(u.tag==="Just")return ze(r,u._1,o._2,o._3);g()}},oe=function(t){return function(e){return t+e|0}},Tr=function(t){return function(e){return t+e}},Xn=function(t){return function(e){if(e===0)return 0;var n=Math.abs(e);return(t%n+n)%n}},Jd=function(t){return function(e){return t+e}},te=function(t){return function(e){return t.length===0?e:e.length===0?t:t.concat(e)}},Td={append:Jd},vd={append:te},wd={mempty:"",Semigroup0:()=>Td},bd={mempty:[],Semigroup0:()=>vd},Ld=null;function ja(t,e,n){return t==null?e:n(t)}function Tw(t){return t}function Lu(t){return function(e){return function(n){return t.apply(n,[e])}}}const kd=Lu(Number.prototype.toPrecision),Ed=Lu(Number.prototype.toFixed),Cd=Lu(Number.prototype.toExponential),ri=(t,e)=>({tag:t,_1:e}),ii=t=>e=>n=>{const r=it.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=it.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},oi=t=>{if(t.tag==="Precision")return kd(t._1);if(t.tag==="Fixed")return Ed(t._1);if(t.tag==="Exponential")return Cd(t._1);g()},Za=function(t){return function(){console.log(t)}};function Sd(){return Date.now()}function Gd(t){return function(){return t.getContext("2d")}}function Pd(t){return function(){return t.width}}function Id(t){return function(){return t.height}}function Dd(t){return function(e){return function(){t.width=e}}}function Ad(t){return function(e){return function(){t.height=e}}}function ku(t){return function(e){return function(){t.lineWidth=e}}}function Bd(t){return function(e){return function(){t.fillStyle=e}}}function Fd(t){return function(e){return function(){t.strokeStyle=e}}}function Eu(t){return function(e){return function(){t.lineCap=e}}}function Cu(t){return function(e){return function(){t.lineJoin=e}}}function Rd(t){return function(e){return function(){t.globalCompositeOperation=e}}}function Qd(t){return function(e){return function(){t.globalAlpha=e}}}function Ka(t){return function(){t.beginPath()}}function Su(t){return function(){t.stroke()}}function Gu(t){return function(){t.fill()}}function zd(t){return function(){t.clip()}}function ui(t){return function(e){return function(n){return function(){t.lineTo(e,n)}}}}function tc(t){return function(e){return function(n){return function(){t.moveTo(e,n)}}}}function ec(t){return function(){t.closePath()}}function Wd(t){return function(e){return function(){t.fillRect(e.x,e.y,e.width,e.height)}}}function Md(t){return function(e){return function(){t.clearRect(e.x,e.y,e.width,e.height)}}}function Ki(t){return function(e){return function(){t.scale(e.scaleX,e.scaleY)}}}function Pu(t){return function(e){return function(){t.translate(e.translateX,e.translateY)}}}function Hd(t){return function(e){return function(){t.transform(e.a,e.b,e.c,e.d,e.e,e.f)}}}function Od(t){return function(e){return function(){t.textAlign=e}}}function qd(t){return function(e){return function(){t.textBaseline=e}}}function $d(t){return function(e){return function(){t.font=e}}}function Yd(t){return function(e){return function(n){return function(r){return function(){t.fillText(e,n,r)}}}}}function sr(t){return function(){t.save()}}function ar(t){return function(){t.restore()}}function si(t){return function(e){return function(){t.quadraticCurveTo(e.cpx,e.cpy,e.x,e.y)}}}function Xd(t){return function(e){return function(){t.bezierCurveTo(e.cp1x,e.cp1y,e.cp2x,e.cp2y,e.x,e.y)}}}const nc=t=>t,Iu=t=>t,Du=t=>t,Au=t=>t,to=t=>t,Vd=to("BaselineTop"),Ud=to("BaselineMiddle"),jd=to("BaselineAlphabetic"),Zd=to("BaselineBottom"),Kd=Au("AlignLeft"),tl=Au("AlignRight"),el=Au("AlignCenter"),Bu=Du("BevelJoin"),eo=Du("RoundJoin"),Fu=Du("MiterJoin"),Ru=Iu("Round"),Qu=Iu("Square"),zu=Iu("Butt"),nl=nc("SourceOver"),rl=nc("Difference"),il=t=>e=>qd(t)((()=>{if(e==="BaselineTop")return"top";if(e==="BaselineHanging")return"hanging";if(e==="BaselineMiddle")return"middle";if(e==="BaselineAlphabetic")return"alphabetic";if(e==="BaselineIdeographic")return"ideographic";if(e==="BaselineBottom")return"bottom";g()})()),ol=t=>e=>Od(t)((()=>{if(e==="AlignLeft")return"left";if(e==="AlignRight")return"right";if(e==="AlignCenter")return"center";if(e==="AlignStart")return"start";if(e==="AlignEnd")return"end";g()})()),no=t=>e=>{if(e==="BevelJoin")return Cu(t)("bevel");if(e==="RoundJoin")return Cu(t)("round");if(e==="MiterJoin")return Cu(t)("miter");g()},Wu=t=>e=>{if(e==="Round")return Eu(t)("round");if(e==="Square")return Eu(t)("square");if(e==="Butt")return Eu(t)("butt");g()},rc=t=>e=>Rd(t)((()=>{if(e==="SourceOver")return"source-over";if(e==="SourceIn")return"source-in";if(e==="SourceOut")return"source-out";if(e==="SourceAtop")return"source-atop";if(e==="DestinationOver")return"destination-over";if(e==="DestinationIn")return"destination-in";if(e==="DestinationOut")return"destination-out";if(e==="DestinationAtop")return"destination-atop";if(e==="Lighter")return"lighter";if(e==="Copy")return"copy";if(e==="Xor")return"xor";if(e==="Multiply")return"multiply";if(e==="Screen")return"screen";if(e==="Overlay")return"overlay";if(e==="Darken")return"darken";if(e==="Lighten")return"lighten";if(e==="ColorDodge")return"color-dodge";if(e==="ColorBurn")return"color-burn";if(e==="HardLight")return"hard-light";if(e==="SoftLight")return"soft-light";if(e==="Difference")return"difference";if(e==="Exclusion")return"exclusion";if(e==="Hue")return"hue";if(e==="Saturation")return"saturation";if(e==="Color")return"color";if(e==="Luminosity")return"luminosity";g()})()),We={foldr:t=>e=>{const n=$t.foldr(t)(e);return r=>n((()=>{const i=(o,u)=>{if(o.tag==="Leaf")return u;if(o.tag==="Node")return i(o._5,Ot("Cons",o._3,i(o._6,u)));g()};return i(r,qt)})())}},ul=t=>{const e={append:(()=>{const n=t.compare;return r=>i=>Ce(n,Le,r,i)})()};return{mempty:A,Semigroup0:()=>e}},ai=function(t){return function(e){if(t>=0&&t<e.length)return e.charAt(t);throw new Error("Data.String.Unsafe.charAt: Invalid index.")}},cr=function(t){return t.join("")},Vn=function(t){return t.split("")},ro=function(t){return t},Un=function(t){return t.length},ic=function(t){return function(e){return e.substr(0,t)}},ci=function(t){return function(e){return e.substring(t)}},sl=function(t){return function(e){return{before:e.substring(0,t),after:e.substring(t)}}},al=t=>e=>{const n=sl(Un(t))(e);return n.before===t?w("Just",n.after):T},cl=function(t){var e=null;return function(){return t===void 0||(e=t(),t=void 0),e}},gl=function(t){return t()},fl=t=>e=>n=>{try{var r=BigInt(n);return t(r)}catch{return e}},_l=t=>e=>n=>{try{var r=BigInt(n);return t(r)}catch{return e}},gr=t=>BigInt(t),dl=t=>Number(t),io=t=>e=>t+e,oo=t=>e=>t*e,Mu=t=>e=>t-e,oc=0n,uo=1n,uc=t=>e=>t^e,gi=t=>e=>t&e,Hu=t=>e=>t<<e,Ou=t=>e=>t>>e,ll=t=>e=>t==e,hl=t=>e=>t===e?0:t>e?1:-1,pl={eq:ll},sc={compare:t=>e=>{const n=hl(t)(e);return n===1?xe:n===0?Ge:ye},Eq0:()=>pl},ml=fl(Yt)(T),yl=_l(Yt)(T),ac=(()=>{const t={eq:e=>n=>e._1===n._1&&e._2===n._2};return{compare:e=>n=>{const r=st.compare(e._1)(n._1);return r==="LT"?ye:r==="GT"?xe:st.compare(e._2)(n._2)},Eq0:()=>t}})(),xl=t=>e=>$n(t._1-e._1)+$n(t._2-e._2),fr=t=>t,so=t=>t,le=so("North"),he=so("South"),pn=so("East"),_r=so("West"),jn=fr("Rectangle"),Nl=fr("Cylinder"),Jl=fr("Parallelogram"),Tl=fr("Diamond"),vl=fr("Ellipse"),wl=fr("Document"),bl=fr("Cloud"),cc=t=>t,gc=J(Tr)(0),Ll=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},mn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},fi=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},fc=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},vr=t=>e=>{const n=Je(u=>s=>({a:u,b:s,len:(()=>{const a=s.y-u.y,c=s.x-u.x;return Ee(c*c+a*a)})()}),t,bt(1,t.length,t)),r=gc(O(u=>u.len)(n)),i=Ll(0)(r)(e*r),o=u=>s=>a=>{let c=u,f=s,d=a,l=!0,_;for(;l;){const h=c,m=f,p=d,y=Bt(x=>T,x=>N=>w("Just",{head:x,tail:N}),h);if(y.tag==="Nothing"){const x=t.length-1|0;if(x>=0&&x<t.length){l=!1,_=t[x];continue}l=!1,_=p;continue}if(y.tag==="Just"){if(m<=y._1.head.len){const x=y._1.head.len<=0?0:m/y._1.head.len;l=!1,_={x:y._1.head.a.x+(y._1.head.b.x-y._1.head.a.x)*x,y:y._1.head.a.y+(y._1.head.b.y-y._1.head.a.y)*x};continue}c=y._1.tail,f=m-y._1.head.len,d=p;continue}g()}return _};return 0<t.length?w("Just",o(n)(i)(t[0])):T},kl=t=>e=>{const n=mn(1)(t.w),r=mn(1)(t.h),i=mn(1)(e.w-8),o=mn(1)(e.h-8),u=fi(i/n)(o/r);return{scale:u,tx:e.x+4+(i-n*u)/2-t.x*u,ty:e.y+4+(o-r*u)/2-t.y*u}},_i=t=>gc(Je(e=>n=>{const r=n.y-e.y,i=n.x-e.x;return Ee(i*i+r*r)},t,bt(1,t.length,t))),El=t=>e=>n=>r=>i=>{const o=0<t.length?w("Just",t[0]):T,u=(()=>{if(o.tag==="Nothing")return e;if(o.tag==="Just")return o._1;g()})(),s=t.length-1|0,a=s>=0&&s<t.length?w("Just",t[s]):T,c=(()=>{if(a.tag==="Nothing")return n;if(a.tag==="Just")return a._1;g()})(),f=mn(.05)(1-i.pre-i.post),d=r<i.pre?0:r>1-i.post?1:(r-i.pre)/f,l=c.x-n.x,_=2*(()=>{const v=c.y-n.y;return(l<0?-l:l)+(v<0?-v:v)})(),h=u.x-e.x,m=2*(()=>{const v=u.y-e.y;return(h<0?-h:h)+(v<0?-v:v)})(),p=m+_i(t)+_,y=p<=1e-4?1:1-_/p,x=p<=1e-4?0:m/p;if(d<=x){const v=x<=1e-4?1:d/x;return{x:e.x+(u.x-e.x)*v,y:e.y+(u.y-e.y)*v}}if(d>=y){const v=y>=1?0:(d-y)/(1-y);return{x:c.x+(n.x-c.x)*v,y:c.y+(n.y-c.y)*v}}const N=vr(t)((d-x)/mn(1e-4)(y-x));if(N.tag==="Nothing")return u;if(N.tag==="Just")return N._1;g()},Cl=t=>{const e=Bt(n=>T,n=>r=>w("Just",{head:n,tail:r}),(()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return Tt(kt($t.foldr,n(t.nodes,qt)))(r=>[{x:r.x,y:r.y},{x:r.x+r.w,y:r.y+r.h}])})());if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=J(r=>i=>({minX:fi(r.minX)(i.x),minY:fi(r.minY)(i.y),maxX:mn(r.maxX)(i.x),maxY:mn(r.maxY)(i.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},qu={scale:1,tx:0,ty:0},Ye=t=>{const e=Bt(n=>T,n=>r=>w("Just",{head:n,tail:r}),[...(()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return Tt(kt($t.foldr,n(t.nodes,qt)))(r=>[{x:r.x,y:r.y},{x:r.x+r.w,y:r.y+r.h}])})(),...Fe((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return kt($t.foldr,n(t.edges,qt))})()),...Fe((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return kt($t.foldr,n(t.chipExtras,qt))})())]);if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=J(r=>i=>({minX:fi(r.minX)(i.x),minY:fi(r.minY)(i.y),maxX:mn(r.maxX)(i.x),maxY:mn(r.maxY)(i.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},Sl=t=>e=>(n=>r=>i=>{let o=n,u=r,s=i,a=!0,c;for(;a;){const f=o,d=u,l=s,_=Bt(h=>T,h=>m=>w("Just",{head:h,tail:m}),d);if(_.tag==="Nothing"){a=!1,c=l;continue}if(_.tag==="Just"){const h=fc(_._1.head)(f.interiors);if(h.tag==="Nothing"){a=!1,c=l;continue}if(h.tag==="Just"){o=h._1,u=_._1.tail,s=(()=>{const m=kl(Ye(h._1.layout))((()=>{const p=fc(_._1.head)(f.layout.nodes);if(p.tag==="Nothing")return{x:0,y:0,w:1,h:1,label:"",shape:jn};if(p.tag==="Just")return p._1;g()})());return{scale:l.scale*m.scale,tx:l.scale*m.tx+l.tx,ty:l.scale*m.ty+l.ty}})();continue}}g()}return c})(t)(e)(qu),_c=t=>t,dc=(t,e)=>({tag:t,_1:e}),ao=(t,e)=>({tag:t,_1:e}),$u=(t,e)=>({tag:t,_1:e}),Gl=$u("First"),Pl=_c("Forward"),Il=_c("Backward"),Dl=ao("ExitNode"),lc=Kt(P)(zt),Al=t=>Kr(e=>n=>({nodes:Ce(P.compare,Le,e.nodes,n.nodes),edges:Ce(P.compare,Le,e.edges,n.edges)}))({nodes:A,edges:A})(t.keyframes),Bl=t=>e=>({entering:{nodes:Cn(P.compare,e.nodes,t.nodes),edges:Cn(P.compare,e.edges,t.edges)},leaving:{nodes:Cn(P.compare,t.nodes,e.nodes),edges:Cn(P.compare,t.edges,e.edges)},surviving:{nodes:Zi(P.compare,Le,t.nodes,e.nodes),edges:Zi(P.compare,Le,t.edges,e.edges)}}),co=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},wr=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},di=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Yu=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Fl=J(t=>e=>K(P)(e)()(t))(A),Rl=J(t=>e=>K(P)(e)()(t))(A),Ql=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),hc=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},pc=Kt(P)(zt),li=t=>{const e=Bt(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=J(r=>i=>({minX:co(r.minX)(i.x),minY:co(r.minY)(i.y),maxX:wr(r.maxX)(i.x),maxY:wr(r.maxY)(i.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},zl=t=>{const e=Bt(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return T;if(e.tag==="Just")return w("Just",li(t));g()},Wl=t=>e=>n=>Fl(Tt(kt(We.foldr,n))(r=>{const i=di(r)(t);if(i.tag==="Just")return at(o=>!Yu(o)(e),[i._1.source,i._1.target]);if(i.tag==="Nothing")return[];g()})),Ml=t=>t.kind.tag==="SendToken"?w("Just",b(t.kind._1.edge,{source:t.kind._1.from,target:t.kind._1.to})):T,Hl=t=>t.tag==="DataFlow"?xt(Ml)(t._1.events):[],Ol=t=>e=>Rl(xt(n=>Yu(n._2.source)(e)||Yu(n._2.target)(e)?w("Just",n._1):T)(Ql(t))),ql=t=>{const e=t.length-1|0;return e>=0&&e<t.length?0<t.length?t[0].x===t[e].x&&t[0].y===t[e].y?w("Just",li([t[0]])):w("Just",li([t[0],t[e]])):T:0<t.length?w("Just",li([t[0]])):T},go=t=>{const e=Bt(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=J(r=>i=>({minX:co(r.minX)(i.x),minY:co(r.minY)(i.y),maxX:wr(r.maxX)(i.x+i.w),maxY:wr(r.maxY)(i.y+i.h)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x+e._1.head.w,maxY:e._1.head.y+e._1.head.h})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},mc=t=>e=>n=>{if(n.tag==="Leaf")return Ye(t);const r=Ol(e)(n),i=[...xt(o=>{const u=hc(o)(t.nodes);return u.tag==="Just"?w("Just",{x:u._1.x,y:u._1.y,w:u._1.w,h:u._1.h}):T})(kt(We.foldr,Ce(P.compare,Le,n,Wl(e)(n)(r)))),...xt(o=>{const u=di(o)(t.edges);return u.tag==="Just"?w("Just",li(u._1)):T})(kt(We.foldr,r)),...xt(o=>{const u=di(o)(t.chipExtras);if(u.tag==="Just")return zl(u._1);if(u.tag==="Nothing")return T;g()})(kt(We.foldr,r))];return i.length===0?Ye(t):go(i)},hi=t=>e=>n=>{const r=[...xt(i=>i)([(()=>{const i=di(n)(t.chipExtras);if(i.tag==="Just")return ql(i._1);if(i.tag==="Nothing")return T;g()})()]),...(()=>{const i=di(n)(e);if(i.tag==="Just")return xt(o=>{const u=hc(o)(t.nodes);return u.tag==="Just"?w("Just",{x:u._1.x,y:u._1.y,w:u._1.w,h:u._1.h}):T})([i._1.source,i._1.target]);if(i.tag==="Nothing")return[];g()})()];return r.length===0?mc(t)(e)(A):go(r)},Xu=t=>e=>{const n=Ye(t),r=n.w/wr(1e-4)(e.zoom),i=n.h/wr(1e-4)(e.zoom);return{x:e.center.x-r/2,y:e.center.y-i/2,w:r,h:i}},$l=t=>Ce(P.compare,Le,pc(O(e=>b(e.id,{source:e.from.node,target:e.to.node}))(t.graph.edges)),pc(Tt(t.scenes)(Hl))),Vu=t=>t,Yl=t=>t,dr=Vu("Linear"),Xl=Vu("EaseInOutQuad"),Vl=Vu("SpringBouncy"),pi=t=>e=>n=>{const r=Ee(1-e*e),i=t*r;return 1-Ui(-e*t*n)*(Ke(i*n)+e/r*Oe(i*n))},Ul=t=>{const e=st.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=st.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},Uu=t=>e=>(()=>{if(t==="Linear")return Yl;if(t==="EaseInQuad")return n=>n*n;if(t==="EaseOutQuad")return n=>1-(1-n)*(1-n);if(t==="EaseInOutQuad")return n=>n<.5?2*n*n:1-2*(1-n)*(1-n);if(t==="EaseInCubic")return n=>n*n*n;if(t==="EaseOutCubic")return n=>1-(1-n)*(1-n)*(1-n);if(t==="EaseInOutCubic")return n=>n<.5?4*n*n*n:1-(-2*n+2)*(-2*n+2)*(-2*n+2)/2;if(t==="EaseOutExpo")return n=>n>=1?1:1-bu(2)(-10*n);if(t==="Spring")return n=>1-(1+6*n)*Ui(-6*n);if(t==="SpringBouncy")return pi(6)(.7);g()})()(Ul(e)),yc=t=>t,ju=t=>t,fo=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},mi=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},xc=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},jl=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Zl=ju("Hold"),Kl=ju("Gap"),th=ju("Move"),yi=yc("LinearLerp"),Nc=yc("LogLerp"),eh=t=>e=>n=>{const r=n.center.y-e.center.y,i=n.center.x-e.center.x,o=Ee(i*i+r*r),u=n.zoom-e.zoom,s=u<0?-u:u;return fo(t.minTransition)(t.maxTransition)(mi(t.panSpeed<=0?t.minTransition:o/t.panSpeed)(t.zoomSpeed<=0?t.minTransition:s/t.zoomSpeed))},nh=J(t=>e=>{const n=t.length-1|0;return n>=0&&n<t.length&&t[n]===e?t:Ft(t)(e)})([]),Jc=t=>e=>{const n={x:0,y:0},r=0<t.length?t[0].pos:n,i=Ra(Yt,T,o=>o.t<=e,t);if(i.tag==="Nothing")return r;if(i.tag==="Just"){const o=i._1+1|0;if(o>=0&&o<t.length){if(i._1>=0&&i._1<t.length){const u=fo(0)(1)(t[o].t<=t[i._1].t?0:(e-t[i._1].t)/(t[o].t-t[i._1].t));return{x:t[i._1].pos.x+(t[o].pos.x-t[i._1].pos.x)*u,y:t[i._1].pos.y+(t[o].pos.y-t[i._1].pos.y)*u}}return n}return i._1>=0&&i._1<t.length?t[i._1].pos:n}g()},Zu=t=>e=>({center:{x:e.center.x*t.scale+t.tx,y:e.center.y*t.scale+t.ty},zoom:e.zoom/mi(1e-6)(t.scale)}),rh=t=>e=>n=>({center:{x:t.center.x+(e.center.x-t.center.x)*n,y:t.center.y+(e.center.y-t.center.y)*n},zoom:Ui((()=>{const r=$a(mi(1e-6)(t.zoom));return r+($a(mi(1e-6)(e.zoom))-r)*n})())}),ih=t=>e=>n=>{const r=Uu(n.easing)(fo(0)(1)(n.endT<=n.startT?1:(e-n.startT)/(n.endT-n.startT)));if(n.interp==="LinearLerp")return{center:{x:n.fromCam.center.x+(n.toCam.center.x-n.fromCam.center.x)*r,y:n.fromCam.center.y+(n.toCam.center.y-n.fromCam.center.y)*r},zoom:n.fromCam.zoom+(n.toCam.zoom-n.fromCam.zoom)*r};if(n.interp==="LogLerp")return rh(n.fromCam)(n.toCam)(r);g()},oh=t=>e=>n=>r=>{const i=(u,s)=>xc(eh(t)(u.toCam)(s.toCam))(u.endT-u.startT),o=J(u=>s=>{if(u.pending.tag==="Nothing")return{acc:u.acc,pending:w("Just",s)};if(u.pending.tag==="Just")return!(s.fromCam.zoom===s.toCam.zoom&&s.fromCam.center.x===s.toCam.center.x&&s.fromCam.center.y===s.toCam.center.y)||(()=>{const a=u.pending._1.toCam.center.x-s.toCam.center.x;return(a<0?-a<8:a<8)&&(()=>{const c=u.pending._1.toCam.center.y-s.toCam.center.y;return(c<0?-c<8:c<8)&&(()=>{const f=u.pending._1.toCam.zoom-s.toCam.zoom;return f<0?-f<.08:f<.08})()})()})()||i(u.pending._1,s)<=0?{acc:Ft(u.acc)(u.pending._1),pending:w("Just",s)}:{acc:Ft(Ft(u.acc)({...u.pending._1,endT:s.startT-i(u.pending._1,s)}))({startT:s.startT-i(u.pending._1,s),endT:s.startT,fromCam:u.pending._1.toCam,toCam:s.toCam,easing:s.easing,interp:yi}),pending:w("Just",s)};g()})({acc:[],pending:T})(r);if(o.pending.tag==="Nothing")return o.acc;if(o.pending.tag==="Just")return Ft(o.acc)(o.pending._1);g()},uh=t=>e=>{const n=r=>{const i=Ra(Yt,T,o=>o.kind==="Hold"||o.kind==="Move",r<1?[]:bt(0,r,e));if(i.tag==="Just")return i._1>=0&&i._1<e.length?w("Just",e[i._1].toCam):T;if(i.tag==="Nothing")return T;g()};return At(r=>i=>{if(i.kind==="Hold")return{startT:i.startT,endT:i.endT,fromCam:i.fromCam,toCam:i.toCam,easing:i.easing,interp:yi};if(i.kind==="Move")return{startT:i.startT,endT:i.endT,fromCam:i.fromCam,toCam:i.toCam,easing:dr,interp:yi};if(i.kind==="Gap")return{startT:i.startT,endT:i.endT,fromCam:(()=>{const o=n(r);if(o.tag==="Nothing")return t;if(o.tag==="Just")return o._1;g()})(),toCam:(()=>{const o=n(r),u=(()=>{if(o.tag==="Nothing")return t;if(o.tag==="Just")return o._1;g()})(),s=r+1|0,a=On(Yt,T,c=>c.kind==="Hold"||c.kind==="Move",s<1?e:bt(s,e.length,e));if(a.tag==="Just"){const c=(r+1|0)+a._1|0;return c>=0&&c<e.length?e[c].fromCam:u}if(a.tag==="Nothing")return u;g()})(),easing:i.easing,interp:yi};g()})(e)},sh={padding:24,easing:dr,minZoom:.9,maxZoom:2.5,tokenZoomFloor:0,panSpeed:1500,zoomSpeed:4,minTransition:.15,maxTransition:.6,cameraDecay:16},Ku=t=>e=>n=>{const r=e.w+n*2,i=e.h+n*2,o=Ye(t);return r<=0||i<=0||o.w<=0||o.h<=0?1:xc(o.w/r)(o.h/i)},ah=J(t=>e=>{const n=t.length-1|0,r=n>=0&&n<t.length?w("Just",t[n]):T;return r.tag==="Just"&&r._1.fromCam.zoom===r._1.toCam.zoom&&r._1.fromCam.center.x===r._1.toCam.center.x&&r._1.fromCam.center.y===r._1.toCam.center.y&&e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y&&(()=>{const i=r._1.toCam.center.x-e.toCam.center.x;return(i<0?-i<8:i<8)&&(()=>{const o=r._1.toCam.center.y-e.toCam.center.y;return(o<0?-o<8:o<8)&&(()=>{const u=r._1.toCam.zoom-e.toCam.zoom;return u<0?-u<.08:u<.08})()})()})()?Ft((()=>{const i=t.length-1|0;return i<1?[]:bt(0,i,t)})())({...r._1,endT:e.endT}):Ft(t)(e)})([]),xi=t=>e=>n=>r=>({center:{x:n.x+n.w/2,y:n.y+n.h/2},zoom:mi(r)(fo(t.minZoom)(t.maxZoom)(Ku(e)(n)(t.padding)))}),ch=t=>e=>n=>r=>{const i=Lt(s=>a=>it.compare(a.priority)(s.priority)),o=xi(t)(e)(Ye(e))(0),u=at(s=>s>=0&&s<=n,nh(Lt(st.compare)([0,n,...Tt(r)(s=>[s.startT,s.endT]),...Tt(r)(s=>{if(s.pathFollow.tag==="Nothing")return[];if(s.pathFollow.tag==="Just")return O(a=>a.t)(s.pathFollow._1.samples);g()})])));return oh(t)(e)(o)(ah(uh(o)(xt(s=>{const a=(s._1+s._2)/2;if(s._2<=s._1)return T;const c=xt(d=>d.pathFollow)(i(at(d=>d.startT<=a&&a<d.endT,r)));if(0<c.length)return w("Just",{kind:th,startT:s._1,endT:s._2,fromCam:{center:Jc(c[0].samples)(s._1),zoom:c[0].zoom},toCam:{center:Jc(c[0].samples)(s._2),zoom:c[0].zoom},easing:dr});const f=O(d=>d.bbox)(at(d=>d.priority===J(jl)(0)(O(l=>l.priority)(at(l=>l.startT<=a&&a<l.endT,r))),at(d=>d.startT<=a&&a<d.endT,r)));return f.length===0?w("Just",{kind:Kl,startT:s._1,endT:s._2,fromCam:o,toCam:o,easing:t.easing}):w("Just",{kind:Zl,startT:s._1,endT:s._2,fromCam:xi(t)(e)(go(f))(Re(d=>d.priority>=1,at(d=>d.startT<=a&&a<d.endT,r))?t.tokenZoomFloor:0),toCam:xi(t)(e)(go(f))(Re(d=>d.priority>=1,at(d=>d.startT<=a&&a<d.endT,r))?t.tokenZoomFloor:0),easing:t.easing})})(Je(Hn,u,bt(1,u.length,u))))))},Tc=t=>e=>n=>r=>{const i=Xt(o=>r>=o.startT&&r<o.endT)(n);if(i.tag==="Just")return ih()(r)(i._1);if(i.tag==="Nothing"){const o=n.length-1|0;if(o>=0&&o<n.length&&r>=n[o].endT)return n[o].toCam;const u=xi(t)(e)(Ye(e))(0);return 0<n.length?n[0].fromCam:u}g()},_o=t=>e=>{const n=Xt(r=>r.startT<=e&&e<r.endT)(t.spans);if(n.tag==="Just"){if(n._1.scene.tag==="Structural")return n._1.scene._1.to;if(n._1.scene.tag==="DataFlow")return n._1.scene._1.keyframe;if(n._1.scene.tag==="EnterNode"||n._1.scene.tag==="ExitNode")return"";g()}if(n.tag==="Nothing"){const r=t.spans.length-1|0;if(r>=0&&r<t.spans.length){if(t.spans[r].scene.tag==="Structural")return t.spans[r].scene._1.to;if(t.spans[r].scene.tag==="DataFlow")return t.spans[r].scene._1.keyframe;if(t.spans[r].scene.tag==="EnterNode"||t.spans[r].scene.tag==="ExitNode")return"";g()}return""}g()},gh=t=>e=>{if(e==="")return T;const n=Xt(r=>{if(r.scene.tag==="Structural")return r.scene._1.to===e;if(r.scene.tag==="DataFlow")return r.scene._1.keyframe===e;if(r.scene.tag==="EnterNode"||r.scene.tag==="ExitNode")return e==="";g()})(t.spans);if(n.tag==="Just")return w("Just",n._1.startT);if(n.tag==="Nothing")return T;g()};function Sn(t){return t.charCodeAt(0)}function vc(t){return String.fromCharCode(t)}const Zn=function(t){return function(e){return function(n){return n.replace(new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),e)}}},lo=function(t){return function(e){return e.split(t)}},fh=function(t){return t.trim()},ho=function(t){return function(e){return e.join(t)}};var _h=typeof Array.from=="function",dh=typeof Symbol<"u"&&Symbol!=null&&typeof Symbol.iterator<"u"&&typeof String.prototype[Symbol.iterator]=="function",lh=typeof String.prototype.fromCodePoint=="function",hh=typeof String.prototype.codePointAt=="function";const ph=function(t){return hh?function(e){return e.codePointAt(0)}:t},mh=function(t){return lh?String.fromCodePoint:t},yh=function(t){return function(e){return dh?function(n){for(var r="",i=n[Symbol.iterator](),o=0;o<e;++o){var u=i.next();if(u.done)return r;r+=u.value}return r}:t(e)}},xh=function(t){return function(e){return _h?function(n){return Array.from(n,e)}:t}},po=t=>{const e=Un(t);if(e===0)return T;if(e===1)return w("Just",{head:Sn(ai(0)(t)),tail:""});const n=Sn(ai(1)(t)),r=Sn(ai(0)(t));return 55296<=r&&r<=56319&&56320<=n&&n<=57343?w("Just",{head:(((r-55296|0)*1024|0)+(n-56320|0)|0)+65536|0,tail:ci(2)(t)}):w("Just",{head:r,tail:ci(1)(t)})},Nh=t=>{const e=po(t);return e.tag==="Just"?w("Just",b(e._1.head,e._1.tail)):T},Jh=t=>qe.unfoldr(Nh)(t),wc=ph(t=>{const e=Sn(ai(0)(t));if(55296<=e&&e<=56319&&Un(t)>1){const n=Sn(ai(1)(t));if(56320<=n&&n<=57343)return(((e-55296|0)*1024|0)+(n-56320|0)|0)+65536|0}return e}),mo=xh(Jh)(wc),ts=t=>ro(t>=0&&t<=65535?vc(t):t<0?"\0":"\uFFFF"),Th=mh(t=>t<=65535?ts(t):ts(En(t-65536|0,1024)+55296|0)+ts(Xn(t-65536|0)(1024)+56320|0)),bc=t=>e=>{if(t<1)return"";const n=po(e);return n.tag==="Just"?Th(n._1.head)+bc(t-1|0)(n._1.tail):e},me=yh(bc),vh=t=>e=>e===""?T:w("Just",wc(e)),br=(t,e,n)=>({tag:t,_1:e,_2:n}),wh=()=>({tag:"ExtendFromSource"}),Lr=(t,e)=>({tag:t,_1:e}),es=t=>t,yo=(t,e)=>({tag:t,_1:e}),ns=yo("NotYet"),Lc=yo("Consumed"),bh=es("FromSource"),kc=es("FromTarget"),Ec=es("FromBoth"),xo=Lr("Hidden"),Lh=Lr("Visible"),rs=wh(),No=br("Retracted"),kh=br("Extended"),Cc=t=>t,is=(t,e)=>({tag:t,_1:e}),kr=(t,e,n)=>({tag:t,_1:e,_2:n}),Sc=t=>t,lr=(t,e)=>({tag:t,_1:e}),Er=(t,e,n,r,i,o,u,s,a)=>({tag:t,_1:e,_2:n,_3:r,_4:i,_5:o,_6:u,_7:s,_8:a}),Ni=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},yn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Gc=Kt(P)(zt),os=vu(ti),Ji=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Jo=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Ti=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Pc=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Ic=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Cr=(()=>{const t=qe.unfoldr(e=>{if(e.tag==="Nil")return T;if(e.tag==="Cons")return w("Just",b(e._1,e._2));g()});return e=>t((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._3,n(r._6,i)));g()};return n(e,qt)})())})(),Eh=J(t=>e=>K(P)(e)()(t))(A),us=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},ss=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Ch=lr("NoKeyframes"),Sh=t=>lr("DuplicateEventId",t),Gh=t=>lr("UnknownEvent",t),Dc=Sc("PlopIn"),Ph=Sc("PlopOut"),Ih=Cc("DiveIn"),Dh=Cc("DiveOut"),Ah=t=>e=>n=>r=>{const i=Ni(r.edge)(e.edges),o=(()=>{if(i.tag==="Nothing")return 0;if(i.tag==="Just")return _i(i._1);g()})(),u=yn(t.minTokenDuration)(yn(rt(J(s=>a=>s+mo(a).length|0)(0)(r.labels))*t.tokenReadSecPerChar)(t.tokenSpeed<=0?0:o/t.tokenSpeed))+n.pre+n.post;return{duration:u,holdPre:u<=0?0:n.pre/u,holdPost:u<=0?0:n.post/u}},Bh=t=>e=>Gc(xt(n=>{if(n.kind.tag==="SendToken")return w("Just",b(n.id,{pre:(()=>{const r=n.when;return(()=>{const i=n.kind._1.from;return Re(o=>{if(o.kind.tag==="SendToken")return(r.tag==="First"?!1:r.tag==="After"&&r._1===o.id)&&o.kind._1.to===i;if(o.kind.tag==="FillNodeWithoutTransition")return!1;g()},e)})()?0:t.tokenHold})(),post:(()=>{const r=n.id;return(()=>{const i=n.kind._1.to;return Re(o=>{if(o.kind.tag==="SendToken")return(o.when.tag==="First"?!1:o.when.tag==="After"&&o.when._1===r)&&o.kind._1.from===i;if(o.kind.tag==="FillNodeWithoutTransition")return!1;g()},e)})()?0:t.tokenHold})()}));if(n.kind.tag==="FillNodeWithoutTransition")return T;g()})(e)),Fh=t=>{if(t.event.kind.tag==="SendToken")return w("Just",{startT:t.startT,endT:t.endT,target:Er("TokenWindow",t.event.id,t.event.kind._1.edge,t.event.kind._1.direction,t.event.kind._1.from,t.event.kind._1.to,t.event.kind._1.labels,t.holdPre,t.holdPost)});if(t.event.kind.tag==="FillNodeWithoutTransition")return w("Just",{startT:t.startT,endT:t.endT,target:Er("FillWindow",t.event.id,t.event.kind._1.node,t.event.kind._1.labels)});g()},Rh=t=>e=>n=>r=>{const i=Xt(o=>os(o.path)(e)&&($n(o.endT-n)<1e-4||$n(o.startT-r)<1e-4))(t.segments);if(i.tag==="Just")return w("Just",i._1);if(i.tag==="Nothing")return Xt(o=>os(o.path)(e))(t.segments);g()},Qh=t=>e=>n=>xt(r=>{const i=xt(o=>Ti(o)(t.nodes))(kt(We.foldr,(()=>{if(r.scene.tag==="Structural")return Ce(P.compare,Le,(()=>{const o=Ji(r.scene._1.from)(n);if(o.tag==="Nothing")return A;if(o.tag==="Just")return o._1.nodes;g()})(),(()=>{const o=Ji(r.scene._1.to)(n);if(o.tag==="Nothing")return A;if(o.tag==="Just")return o._1.nodes;g()})());if(r.scene.tag==="DataFlow"){const o=Ji(r.scene._1.keyframe)(n);if(o.tag==="Nothing")return A;if(o.tag==="Just")return o._1.nodes;g()}if(r.scene.tag==="EnterNode"||r.scene.tag==="ExitNode")return A;g()})()));return i.length===0?T:w("Just",{startT:r.startT,endT:r.endT,bbox:(()=>{const o=J(u=>s=>({minX:Jo(u.minX)(s.x),minY:Jo(u.minY)(s.y),maxX:yn(u.maxX)(s.x+s.w),maxY:yn(u.maxY)(s.y+s.h)}))(0<i.length?{minX:i[0].x,minY:i[0].y,maxX:i[0].x+i[0].w,maxY:i[0].y+i[0].h}:{minX:0,minY:0,maxX:0,maxY:0})(bt(1,i.length,i));return{x:o.minX,y:o.minY,w:o.maxX-o.minX,h:o.maxY-o.minY}})(),priority:0,pathFollow:T})}),zh=t=>e=>n=>{const r=Ni(n)(t);if(r.tag==="Nothing")return kc;if(r.tag==="Just"){const i=Pc(r._1.target)(e);return Pc(r._1.source)(e)?i?Ec:bh:kc}g()},Wh={pre:0,post:0},Mh=t=>e=>n=>r=>i=>{const o=Ic(i.event.id)(n),u=(()=>{if(o.tag==="Nothing")return Wh;if(o.tag==="Just")return o._1;g()})(),s=(()=>{if(i.event.when.tag==="First")return 0;if(i.event.when.tag==="At")return i.event.when._1;if(i.event.when.tag==="After"){const c=i.event.when._1,f=Xt(d=>d.event.id===c)(r);if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1.endT;g()}if(i.event.when.tag==="With"){const c=i.event.when._1,f=Xt(d=>d.event.id===c)(r);if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1.startT}g()})(),a=(()=>{if(i.event.kind.tag==="SendToken")return Ah(t)(e)(u)(i.event.kind._1);if(i.event.kind.tag==="FillNodeWithoutTransition")return{duration:t.plop,holdPre:0,holdPost:0};g()})();return Ft(r)({startT:s,endT:s+a.duration,event:i.event,holdPre:a.holdPre,holdPost:a.holdPost})},Ac=t=>e=>n=>J(Mh(t)(e)(Bh(t)(n)))([])(At(r=>i=>({event:i}))(n)),Hh=t=>e=>{const n=Ti(e)(t.interiors);if(n.tag==="Nothing")return t;if(n.tag==="Just")return n._1;g()},Oh=t=>e=>({...e,fromCam:Zu(t)(e.fromCam),toCam:Zu(t)(e.toCam)}),qh=t=>{if(t.when.tag==="First")return[];if(t.when.tag==="At")return[];if(t.when.tag==="After")return[t.when._1];if(t.when.tag==="With")return[t.when._1];g()},Bc={id:"",nodes:A,edges:A},$h=t=>e=>Bl((()=>{const n=Ji(e.from)(t);if(n.tag==="Nothing")return Bc;if(n.tag==="Just")return n._1;g()})())((()=>{const n=Ji(e.to)(t);if(n.tag==="Nothing")return Bc;if(n.tag==="Just")return n._1;g()})()),Yh=t=>e=>{const n=Ti(e)(t.interiors);if(n.tag==="Nothing")return{layout:t.layout,interiors:A};if(n.tag==="Just")return n._1;g()},as=t=>e=>n=>r=>{const i=Ni(r)(n.edges);if(i.tag==="Just")return t<=0?e:yn(e)(_i(i._1)/t);if(i.tag==="Nothing")return e;g()},Fc=t=>e=>n=>r=>i=>{const o=t.plop,u=$h(n)(i),s=O(_=>({startT:0,endT:0+as(t.edgeSpeed)(t.minEdgeDuration)(e)(_),target:Er("EdgeWindow",_,is("Extend",rs))}))(Cr(u.entering.edges)),a=O(_=>({startT:0,endT:o,target:Er("NodeWindow",_,Dc)}))(Cr(u.entering.nodes)),c=J(yn)(0)(O(_=>as(t.edgeSpeed)(t.minEdgeDuration)(e)(_))(Cr(u.leaving.edges))),f=_=>Re(h=>{const m=Ni(h)(r);if(m.tag==="Just")return m._1.source===_||m._1.target===_;if(m.tag==="Nothing")return!1;g()},Cr(u.leaving.edges))?c:0,d=O(_=>({startT:f(_),endT:f(_)+t.plop,target:Er("NodeWindow",_,Ph)}))(Cr(u.leaving.nodes)),l=O(_=>({startT:0,endT:as(t.edgeSpeed)(t.minEdgeDuration)(e)(_),target:Er("EdgeWindow",_,is("Retract",zh(r)(u.leaving.nodes)(_)))}))(Cr(u.leaving.edges));return{duration:(()=>{const _=Lt(st.compare)([...O(m=>m.endT)(l),...O(m=>m.endT)(d),...O(m=>m.endT)(a),...O(m=>m.endT)(s)]),h=_.length-1|0;return h>=0&&h<_.length?_[h]+t.gap:t.gap})(),windows:[...l,...d,...a,...s]}},Xh=t=>e=>n=>r=>i=>o=>O((()=>{const u=i.startT;return s=>({...s,startT:s.startT+u,endT:s.endT+u})})())(Fc(t)(e)(n)(r)(o).windows),Vh=t=>xt(e=>kt(Kr,e).length>1?w("Just",(()=>{const n=Bt(r=>T,r=>i=>w("Just",{head:r,tail:i}),kt(Kr,e));if(n.tag==="Just")return n._1.head;if(n.tag==="Nothing")return"";g()})()):T)(ad(ti)(Lt(P.compare)(t))),Uh=t=>{const e=O(r=>r.id)(t),n=Eh(e);return[...O(Sh)(Vh(e)),...O(Gh)(at(r=>!us(r)(n),Tt(t)(qh)))]},jh=t=>e=>n=>{const r=yn(t.minZoom)(t.tokenZoomFloor);return xt(i=>{if(i.target.tag==="NodeWindow"||i.target.tag==="EdgeWindow")return T;if(i.target.tag==="TokenWindow")return w("Just",(()=>{const o={pre:i.target._7,post:i.target._8};if(t.tokenZoomFloor<=0)return{startT:i.startT,endT:i.endT,bbox:hi(e)(n)(i.target._2),priority:1,pathFollow:T};const u=Ni(i.target._2)(e.edges);if(u.tag==="Just"){const s=Ti(i.target._4)(e.nodes);if(s.tag==="Just"){const a=Ti(i.target._5)(e.nodes);if(a.tag==="Just"){const c=a._1;return{startT:i.startT,endT:i.endT,bbox:hi(e)(n)(i.target._2),priority:1,pathFollow:w("Just",{samples:(()=>{const f=i.startT+o.pre*(i.endT-i.startT),d=yn(1e-4)(i.endT-o.post*(i.endT-i.startT)-f),l=i.endT-i.startT;return O(_=>{const h=f+rt(_)/rt(32)*d;return{t:h,pos:El(u._1)({x:s._1.x+s._1.w/2,y:s._1.y+s._1.h/2})({x:c.x+c.w/2,y:c.y+c.h/2})(l<=0?0:(h-i.startT)/l)(o)}})(Dt(0,32))})(),zoom:r})}}if(a.tag==="Nothing")return{startT:i.startT,endT:i.endT,bbox:hi(e)(n)(i.target._2),priority:1,pathFollow:T};g()}if(s.tag==="Nothing")return{startT:i.startT,endT:i.endT,bbox:hi(e)(n)(i.target._2),priority:1,pathFollow:T};g()}if(u.tag==="Nothing")return{startT:i.startT,endT:i.endT,bbox:hi(e)(n)(i.target._2),priority:1,pathFollow:T};g()})());if(i.target.tag==="FillWindow")return w("Just",{startT:i.startT,endT:i.endT,bbox:mc(e)(n)(Mt("Node",1,1,i.target._2,void 0,A,A)),priority:1,pathFollow:T});g()})},Zh=t=>e=>n=>r=>i=>ch(t)(i.layout)(r.endT)([...Qh(i.layout)(n)(e)(at(o=>o.startT>=i.startT&&o.endT<=i.endT,r.spans)),...jh(t)(i.layout)(n)(i.windows)]),Kh=t=>{const e=Gc(O(r=>b(r.id,(()=>{if(r.when.tag==="First")return[];if(r.when.tag==="At")return[];if(r.when.tag==="After")return[r.when._1];if(r.when.tag==="With")return[r.when._1];g()})()))(t)),n=r=>i=>o=>{if(us(o)(i))return[lr("ScheduleCycle",[...kt(We.foldr,i),o])];if(us(o)(r))return[];const u=Ic(o)(e);if(u.tag==="Nothing")return[];if(u.tag==="Just")return Tt(u._1)(n(K(P)(o)()(r))(K(P)(o)()(i)));g()};return Tt(t)(r=>n(A)(A)(r.id))},t0={plop:.5,gap:.5,edgeSpeed:350,minEdgeDuration:.3,tokenSpeed:250,minTokenDuration:1.8,tokenHold:.5,hatchHold:.4,tokenReadSecPerChar:.06,nodeEasing:Vl,edgeEasing:Xl,tokenEasing:dr,diveDur:1.2,retreatDur:1.2},e0=t=>e=>n=>r=>O((()=>{const i=n.startT;return o=>({...o,startT:o.startT+i,endT:o.endT+i})})())(xt(Fh)(Ac(t)(e)(r.events))),n0=t=>e=>n=>r=>i=>{if(i.scene.tag==="Structural")return Xh(t)(e)(n)(r)(i)(i.scene._1);if(i.scene.tag==="DataFlow")return e0(t)(e)(i)(i.scene._1);if(i.scene.tag==="EnterNode")return[];if(i.scene.tag==="ExitNode")return[];g()},r0=t=>e=>n=>{const r=Ac(t)(e)(n.events);return r.length===0?t.gap:J(yn)(0)(O(i=>i.endT)(r))+t.gap},i0=t=>e=>n=>r=>i=>{if(i.tag==="Structural")return Fc(t)(e)(n)(r)(i._1).duration;if(i.tag==="DataFlow")return r0(t)(e)(i._1);if(i.tag==="EnterNode"||i.tag==="ExitNode")return 0;g()},Rc=t=>e=>n=>r=>i=>o=>{const u=Sl(e)(r),s=n.layout,a=lc(O(m=>b(m.id,m))(i.keyframes)),c=0<i.keyframes.length?w("Just",i.keyframes[0]):T,f=(()=>{if(c.tag==="Just")return c._1.id;if(c.tag==="Nothing")return"";g()})(),d=$l(i),l=m=>({segments:m.runSpans.length===0?m.segments:Ft(m.segments)({startT:m.runStart,endT:m.t,path:r,layout:s,placement:u,windows:m.runWindows,spans:m.runSpans,keyframes:a,initialKeyframe:f,edgeEndpoints:d}),spans:m.spans,windows:m.windows,dives:m.dives}),_=J(m=>p=>{if(p.tag==="EnterNode"){const v=l(m),L=m.t+t.diveDur,k=Ft(r)(p._1),E=Rc(t)(e)(Yh(n)(p._1))(k)(Hh(i)(p._1))(L),Q=E.endT+t.retreatDur;return{...m,t:Q,runStart:Q,runSpans:[],runWindows:[],segments:[...v.segments,...E.segments],spans:[...v.spans,...E.spans],windows:[...v.windows,...E.windows],dives:[...v.dives,{startT:m.t,endT:L,node:p._1,parentPath:r,childPath:k,direction:Ih},...E.dives,{startT:E.endT,endT:Q,node:p._1,parentPath:r,childPath:k,direction:Dh}]}}if(p.tag==="ExitNode")return m;const y=m.t+i0(t)(s)(a)(d)(p),x={startT:m.t,endT:y,scene:p},N=n0(t)(s)(a)(d)(x);return{...m,t:y,runSpans:Ft(m.runSpans)(x),runWindows:[...m.runWindows,...N],spans:Ft(m.spans)(x),windows:[...m.windows,...N]}})({t:o,runStart:o,runSpans:[],runWindows:[],segments:[],spans:[],windows:[],dives:[]})(i.scenes),h=l(_);return{endT:_.t,spans:h.spans,windows:Lt(m=>p=>st.compare(m.startT)(p.startT))(h.windows),segments:h.segments,dives:h.dives}},o0=t=>e=>n=>n.endT<=t||n.startT>=e?T:w("Just",{...n,startT:yn(t)(n.startT),endT:Jo(e)(n.endT)}),cs=t=>e=>n=>{const r=Ye(n.layout),i={x:r.x*n.placement.scale+n.placement.tx,y:r.y*n.placement.scale+n.placement.ty,w:r.w*n.placement.scale,h:r.h*n.placement.scale};return{center:{x:i.x+i.w/2,y:i.y+i.h/2},zoom:Jo(Ku(e)(i)(t.padding*n.placement.scale))(40/(11*n.placement.scale))}},u0=t=>e=>n=>n.placement.scale===1&&n.placement.tx===0&&n.placement.ty===0?Zu(n.placement)(xi(t)(n.layout)(Ye(n.layout))(0)):cs(t)(e)(n),s0=t=>e=>n=>r=>xt(i=>{const o=Rh(r)(i.parentPath)(i.startT)(i.endT);if(o.tag==="Just"){const u=i.childPath,s=Xt(a=>os(a.path)(u))(r.segments);if(s.tag==="Just"){const a=u0(t)(e)(o._1),c=cs(t)(e)(s._1);if(i.direction==="DiveIn")return w("Just",{startT:i.startT,endT:i.endT,fromCam:a,toCam:c,easing:dr,interp:Nc});if(i.direction==="DiveOut")return w("Just",{startT:i.startT,endT:i.endT,fromCam:c,toCam:a,easing:dr,interp:Nc});g()}if(s.tag==="Nothing")return T;g()}if(o.tag==="Nothing")return T;g()})(r.dives),a0=t=>e=>{if(e.tag==="Structural")return xt(n=>n)([ss(e._1.from)(t)?T:w("Just",lr("UnknownKeyframe",e._1.from)),ss(e._1.to)(t)?T:w("Just",lr("UnknownKeyframe",e._1.to))]);if(e.tag==="DataFlow")return[...xt(n=>n)([ss(e._1.keyframe)(t)?T:w("Just",lr("UnknownKeyframe",e._1.keyframe))]),...Uh(e._1.events),...Kh(e._1.events)];if(e.tag==="EnterNode")return[];if(e.tag==="ExitNode")return[];g()},c0=t=>e=>{const n=Tt(e)(a0(t));return n.length===0?Gt("Right",void 0):Gt("Left",n)},g0=t=>e=>n=>r=>Lt(i=>o=>st.compare(i.startT)(o.startT))(Tt(r.segments)(i=>i.placement.scale===1&&i.placement.tx===0&&i.placement.ty===0?xt(o0(i.startT)(i.endT))(O(Oh(i.placement))(Zh(t)(n)(i.edgeEndpoints)(r)(i))):[(()=>{const o=cs(t)(e)(i);return{startT:i.startT,endT:i.endT,fromCam:o,toCam:o,easing:dr,interp:yi}})()])),f0=t=>e=>n=>r=>{if(0<n.keyframes.length){const i=n.keyframes[0],o=lc(O(s=>b(s.id,s))(n.keyframes)),u=c0(o)(n.scenes);return(()=>{if(u.tag==="Left"){const s=u._1;return a=>Gt("Left",s)}if(u.tag==="Right"){const s=u._1;return a=>a(s)}g()})()(()=>{const s=Rc(e)(r)(r)([])(n)(0);return Gt("Right",{totalDuration:s.endT,windows:s.windows,spans:s.spans,keyframes:o,initialKeyframe:i.id,timing:e,layout:r.layout,cameraSpans:[...g0(t)(r.layout)(o)(s),...s0(t)(r.layout)(o)(s)],cameraConfig:t,levelTree:r,segments:s.segments,dives:s.dives,seed:n.seed})})}return Gt("Left",[Ch])},gs=t=>e=>Math.imul(t,e),Sr=t=>{const e=t+1831565813|0,n=gs(e^e>>>15)(e|1),r=n^(n+gs(n^n>>>7)(n|61)|0),i=r^r>>>14;return{prng:i,value:i<0?(rt(i)+4294967296)/4294967296:rt(i)/4294967296}},ae=t=>e=>n=>{const r=Sr(n);return{prng:r.prng,value:t+r.value*(e-t)}},fs=t=>e=>J(n=>r=>gs(n^r)(-2048144789))(e)(O(Sn)(Vn(t))),_s=t=>t,tn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},To=vu(ti),_0=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),Qc=Kt(P)(zt),zc=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Wc=zt.foldMap(ul(P)),Mc=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},d0=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Gr=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},l0=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},h0=Kt(P)(zt),p0=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},m0=Kt(P)(zt),y0=_s("Backdrop"),Hc=_s("FlyThrough"),vo=_s("Active"),Oc=t=>e=>n=>{const r=(t+e)/2,i=n-r,o=i<0?-1:1,u=(e-t)/2,s=u*.15,a=u-s,c=i<0?-i:i;return e<=t?(t+e)/2:c<=a?n:r+o*(u-s*Ui(-(c-a)/s))},x0=t=>e=>n=>r=>{const i=Ye(t),o=i.w/tn(1e-4)(e.zoom)/2,u=i.h/tn(1e-4)(e.zoom)/2,s=n.y-e.center.y,a=n.x-e.center.x;return{...e,center:{x:o<=1e-4?e.center.x+0*r*.35:a<0?e.center.x+a/(1+-a/o)*r*.35:e.center.x+a/(1+a/o)*r*.35,y:u<=1e-4?e.center.y+0*r*.35:s<0?e.center.y+s/(1+-s/u)*r*.35:e.center.y+s/(1+s/u)*r*.35}}},ds=t=>e=>n=>{const r=Xt(i=>To(i.path)(e)&&n>=i.startT&&n<i.endT)(t.segments);if(r.tag==="Just")return w("Just",r._1);if(r.tag==="Nothing")return Xt(i=>To(i.path)(e))(t.segments);g()},N0=t=>({startT:0,endT:t.totalDuration,path:[],layout:t.layout,placement:qu,windows:t.windows,spans:t.spans,keyframes:t.keyframes,initialKeyframe:t.initialKeyframe,edgeEndpoints:A}),J0=t=>O(e=>e<1?[]:bt(0,e,t))(Dt(0,t.length-1|0)),T0=t=>J(e=>n=>(e*31|0)+Sn(n)|0)(7)(Vn(t)),qc=t=>e=>n=>({...n,state:{...n.state,nodes:Qc(O(r=>b(r._1,t(r._1)(r._2)))(_0(n.state.nodes))),edges:(()=>{const r=i=>{if(i.tag==="Leaf")return A;if(i.tag==="Node")return Mt("Node",i._1,i._2,i._3,e(i._4),r(i._5),r(i._6));g()};return r(n.state.edges)})()}}),ls=t=>e=>{const n=zc(e)(t.keyframes);if(n.tag==="Nothing")return A;if(n.tag==="Just")return n._1.nodes;g()},hs=t=>e=>{const n=zc(e)(t.keyframes);if(n.tag==="Nothing")return A;if(n.tag==="Just")return n._1.edges;g()},ps=t=>e=>{if(e<t.startT)return kr("AtKeyframe",t.initialKeyframe);const n=Xt(r=>e>=r.startT&&e<r.endT)(t.spans);if(n.tag==="Just"){if(n._1.scene.tag==="Structural")return kr("InTransition",n._1.scene._1.from,n._1.scene._1.to);if(n._1.scene.tag==="DataFlow")return kr("AtKeyframe",n._1.scene._1.keyframe);if(n._1.scene.tag==="EnterNode"||n._1.scene.tag==="ExitNode")return kr("AtKeyframe",t.initialKeyframe);g()}if(n.tag==="Nothing"){const r=t.spans.length-1|0;return r>=0&&r<t.spans.length?kr("AtKeyframe",(()=>{if(t.spans[r].scene.tag==="Structural")return t.spans[r].scene._1.to;if(t.spans[r].scene.tag==="DataFlow")return t.spans[r].scene._1.keyframe;if(t.spans[r].scene.tag==="EnterNode"||t.spans[r].scene.tag==="ExitNode")return t.initialKeyframe;g()})()):kr("AtKeyframe",t.initialKeyframe)}g()},v0=J(t=>e=>{const n=Xi(t);return n.tag==="Just"&&e.startT<=n._1.last.endT+1e-6?Ft(n._1.init)({...n._1.last,endT:tn(n._1.last.endT)(e.endT),windows:Ft(n._1.last.windows)(e)}):Ft(t)({endT:e.endT,windows:[e]})})([]),w0=t=>e=>n=>Wc(r=>Wc(i=>i.target.tag==="FillWindow"?i.startT<=n?Mt("Node",1,1,i.target._2,void 0,A,A):A:i.target.tag==="TokenWindow"&&i.startT+(i.endT-i.startT)*.25<=n?Mt("Node",1,1,i.target._4,void 0,A,A):A)(r.windows))(at(r=>n<=r.endT+t,v0(Lt(r=>i=>st.compare(r.startT)(i.startT))(at(r=>r.target.tag==="FillWindow"||r.target.tag==="TokenWindow",e))))),b0=t=>e=>n=>Re(r=>r.endT<=e&&r.target.tag==="EdgeWindow"&&r.target._2.tag==="Retract"&&r.target._1===n,t),L0=t=>e=>n=>Re(r=>r.endT<=e&&r.target.tag==="NodeWindow"&&r.target._2==="PlopOut"&&r.target._1===n,t),k0=t=>e=>n=>Re(r=>r.startT>e&&r.target.tag==="NodeWindow"&&r.target._2==="PlopIn"&&r.target._1===n,t),E0=t=>e=>n=>Re(r=>r.startT>e&&r.target.tag==="EdgeWindow"&&r.target._2.tag==="Extend"&&r.target._1===n,t),C0=t=>e=>{const n=ps(t)(e);if(n.tag==="AtKeyframe")return me(3)(n._1)==="kf-"?"":n._1;if(n.tag==="InTransition")return me(3)(n._2)==="kf-"?"":n._2;g()},$c=t=>e=>n=>Xt(r=>n(r)&&e>=r.startT&&e<r.endT)(t),S0=t=>{const e=Mc(0)(1)(t/.2),n=Mc(0)(1)((1-t)/.2);return e*e*(3-2*e)*n*n*(3-2*n)},G0=t=>e=>{if(e.tag==="Travelling"){const n=d0(e._1.edge)(t.edges);if(n.tag==="Just"){const r=vr(n._1)(e._1.progress);return r.tag==="Just"?w("Just",{dot:r._1,weight:S0(e._1.progress)}):T}if(n.tag==="Nothing")return T;g()}return T},P0={segment:{startT:0,endT:0,path:[],layout:{nodes:A,edges:A,chipExtras:A},placement:qu,windows:[],spans:[],keyframes:A,initialKeyframe:"",edgeEndpoints:A},state:{nodes:A,edges:A,tokens:A,camera:{center:{x:0,y:0},zoom:1},frameTitle:"",visited:A,nodeFadeAlpha:A,nodeInvert:A},bgAlpha:1,role:vo},wo=t=>{const e=t.levels.length-1|0;return e>=0&&e<t.levels.length?t.levels[e]:P0},I0=t=>e=>{const n=ps(t)(e);if(n.tag==="AtKeyframe")return ls(t)(n._1);if(n.tag==="InTransition")return Ce(P.compare,Le,ls(t)(n._1),ls(t)(n._2));g()},D0=t=>e=>{const n=ps(t)(e);if(n.tag==="AtKeyframe")return hs(t)(n._1);if(n.tag==="InTransition")return Ce(P.compare,Le,hs(t)(n._1),hs(t)(n._2));g()},A0=t=>e=>{const n=t.w/tn(1e-4)(e.zoom),r=t.h/tn(1e-4)(e.zoom);return{...e,center:{x:n>=t.w?t.x+t.w/2:Oc(t.x+n/2)(t.x+t.w-n/2)(e.center.x),y:r>=t.h?t.y+t.h/2:Oc(t.y+r/2)(t.y+t.h-r/2)(e.center.y)}}},B0=t=>A0((()=>{const e=Ye(t.layout),n=e.x*t.placement.scale+t.placement.tx,r=e.y*t.placement.scale+t.placement.ty;return{x:n,y:r,w:(e.x+e.w)*t.placement.scale+t.placement.tx-n,h:(e.y+e.h)*t.placement.scale+t.placement.ty-r}})()),F0=t=>e=>{const n=t.endT-t.startT;return n<=0?1:tn(0)(Gr(1)((e-t.startT)/n))},Yc=t=>e=>n=>tn(0)(Gr(1)((n-ae(0)(.3)(t+T0(e)|0).value)/tn(1e-4)(.7))),Xc=t=>e=>n=>qc(r=>i=>i.tag==="Hidden"?xo:Lr("PloppingOut",r===e?tn(0)(Gr(1)((n-.45)/tn(1e-4)(.55))):Yc(t)(r)(n)))(r=>r.tag==="Retracted"?No:br("Retracting",Ec,n)),Vc=t=>e=>qc(n=>r=>r.tag==="Hidden"?xo:Lr("PloppingIn",Yc(t)(n)(e)))(n=>n.tag==="Retracted"?No:br("Extending",rs,e)),bo=t=>e=>{const n=t.endT-t.startT;return n<=0?1:tn(0)(Gr(1)((e-t.startT)/n))},R0=t=>e=>n=>r=>i=>{const o=$c(e)(n)(u=>u.target.tag==="EdgeWindow"&&u.target._1===i);if(o.tag==="Just"){const u=Uu(t.timing.edgeEasing)(bo(o._1)(n)),s=o._1.target.tag==="EdgeWindow"?o._1.target._2:is("Extend",rs);if(s.tag==="Retract")return br("Retracting",s._1,u);if(s.tag==="Extend")return br("Extending",s._1,u);g()}if(o.tag==="Nothing")return E0(e)(n)(i)||b0(e)(n)(i)?No:l0(i)(r)?kh:No;g()},Q0=t=>e=>n=>{const r=D0(e)(n);return h0(O(i=>b(i,R0(t)(e.windows)(n)(r)(i)))((()=>{const i=o=>{if(o.tag==="Leaf")return A;if(o.tag==="Node")return Mt("Node",o._1,o._2,o._3,void 0,i(o._5),i(o._6));g()};return kt(We.foldr,i(e.layout.edges))})()))},z0=t=>e=>n=>r=>{const i=$c(t)(e)(o=>o.target.tag==="NodeWindow"&&o.target._1===r);if(i.tag==="Just"){const o=bo(i._1)(e),u=i._1.target.tag==="NodeWindow"?i._1.target._2:Dc;if(u==="PlopIn")return Lr("PloppingIn",o);if(u==="PlopOut")return Lr("PloppingOut",o);g()}if(i.tag==="Nothing")return k0(t)(e)(r)||L0(t)(e)(r)?xo:p0(r)(n)?Lh:xo;g()},W0=t=>e=>n=>{const r=I0(e)(n);return Qc(O(i=>b(i,z0(e.windows)(n)(r)(i)))((()=>{const i=o=>{if(o.tag==="Leaf")return A;if(o.tag==="Node")return Mt("Node",o._1,o._2,o._3,void 0,i(o._5),i(o._6));g()};return kt(We.foldr,i(e.layout.nodes))})()))},M0=t=>e=>n=>e.target.tag==="TokenWindow"?b(e.target._1,n<e.startT?ns:n>=e.endT?Lc:yo("Travelling",{edge:e.target._2,direction:e.target._3,progress:Uu(t.timing.tokenEasing)(bo(e)(n)),labels:e.target._6,source:e.target._4,target:e.target._5,holdPre:e.target._7,holdPost:e.target._8})):e.target.tag==="FillWindow"?b(e.target._1,n<e.startT?ns:n>=e.endT?Lc:yo("Filling",{node:e.target._2,progress:bo(e)(n),labels:e.target._3})):b("",ns),H0=t=>e=>n=>m0(O(r=>M0(t)(r)(n))(at(r=>r.target.tag==="TokenWindow"||r.target.tag==="FillWindow",e))),Pr=t=>e=>n=>({nodes:W0()(e)(n),edges:Q0(t)(e)(n),tokens:H0(t)(e.windows)(n),camera:Tc(t.cameraConfig)(e.layout)(t.cameraSpans)(n),frameTitle:C0(e)(n),visited:w0(t.timing.hatchHold)(e.windows)(n),nodeFadeAlpha:A,nodeInvert:A}),O0=t=>e=>n=>Fa(T,Ga,r=>r.direction==="DiveIn"&&To(r.parentPath)(e.path)&&n>=r.startT-.7&&n<r.startT?w("Just",{node:r.node,phase:(n-(r.startT-.7))/.7}):T,t.dives),q0=t=>e=>n=>r=>{const i=O0(t)(e)(n);if(i.tag==="Just"){const o=Oe(3.141592653589793*i._1.phase*3);return{...r,state:{...r.state,nodeInvert:Mt("Node",1,1,i._1.node,1*o*o,A,A)}}}if(i.tag==="Nothing")return r;g()},Uc=t=>e=>xt(n=>{const r=Xt(i=>i.direction==="DiveIn"&&To(i.childPath)((()=>{const o=n.length+1|0;return o<1?[]:bt(0,o,e)})()))(t.dives);if(r.tag==="Just"){const i=ds(t)(n)(r._1.startT-1e-4);if(i.tag==="Just")return w("Just",{bgAlpha:1,role:y0,segment:i._1,state:{...Pr(t)(i._1)(r._1.startT-1e-4),nodeFadeAlpha:Mt("Node",1,1,r._1.node,0,A,A)}});if(i.tag==="Nothing")return T;g()}if(r.tag==="Nothing")return T;g()})(J0(e)),jc=t=>e=>{const n=at(i=>e>=i.startT&&e<i.endT,t.segments),r=n.length-1|0;return r>=0&&r<n.length?n[r]:N0(t)},$0=t=>e=>n=>{const r=F0(n)(e),i=ds(t)(n.parentPath)((()=>{if(n.direction==="DiveIn")return n.startT-1e-4;if(n.direction==="DiveOut")return n.endT-1e-4;g()})()),o=ds(t)(n.childPath)((()=>{if(n.direction==="DiveIn")return n.endT;if(n.direction==="DiveOut")return n.startT-1e-4;g()})()),u=tn(0)(Gr(1)(r/.6)),s=tn(0)(Gr(1)((r-.4)/.6)),a=(()=>{if(n.direction==="DiveIn")return Xc(t.seed)(n.node)(u);if(n.direction==="DiveOut")return Vc(t.seed)(s);g()})(),c=(()=>{if(n.direction==="DiveIn")return Vc(t.seed)(s);if(n.direction==="DiveOut")return Xc(t.seed)(n.node)(u);g()})();return[...Uc(t)(n.parentPath),...(()=>{if(i.tag==="Just"){if(o.tag==="Just")return[a({segment:i._1,state:Pr(t)(i._1)((()=>{if(n.direction==="DiveIn")return n.startT-1e-4;if(n.direction==="DiveOut")return n.endT-1e-4;g()})()),bgAlpha:1,role:Hc}),c({segment:o._1,state:Pr(t)(o._1)((()=>{if(n.direction==="DiveIn")return n.endT;if(n.direction==="DiveOut")return n.startT-1e-4;g()})()),bgAlpha:1,role:vo})];if(o.tag==="Nothing")return[a({segment:i._1,state:Pr(t)(i._1)((()=>{if(n.direction==="DiveIn")return n.startT-1e-4;if(n.direction==="DiveOut")return n.endT-1e-4;g()})()),bgAlpha:1,role:Hc})];g()}if(i.tag==="Nothing")return[(()=>{const f=jc(t)(e);return{segment:f,state:Pr(t)(f)(e),bgAlpha:1,role:vo}})()];g()})()]},Y0=t=>e=>{const n=xt(G0(t))((()=>{const r=(i,o)=>{if(i.tag==="Leaf")return o;if(i.tag==="Node")return r(i._5,Ot("Cons",i._4,r(i._6,o)));g()};return kt($t.foldr,r(e.tokens,qt))})());return 0<n.length?w("Just",n[0]):T},X0=t=>e=>{const n=Y0(t)(e);if(n.tag==="Nothing")return e.camera;if(n.tag==="Just")return x0(t)(e.camera)(n._1.dot)(n._1.weight);g()},V0=t=>e=>t.placement.scale===1&&t.placement.tx===0&&t.placement.ty===0?X0(t.layout)(e):e.camera,U0=t=>e=>Xt(n=>e>=n.startT&&e<n.endT)(t.dives),j0=t=>e=>{const n=jc(t)(e),r=Pr(t)(n)(e),i=t.dives.length!==0,o=Tc(t.cameraConfig)(t.layout)(t.cameraSpans)(e),u=B0(n)(V0(n)({...r,camera:o})),s=q0(t)(n)(e)({bgAlpha:1,role:vo,segment:n,state:{...r,camera:u}}),a=Uc(t)(n.path),c=U0(t)(e);if(c.tag==="Just")return{levels:$0(t)(e)(c._1),camera:o,rootLayout:t.layout,hasDives:i,diving:!0};if(c.tag==="Nothing")return{levels:Ft(a)(s),camera:u,rootLayout:t.layout,hasDives:i,diving:!1};g()},Zc=t=>t,Kc=Zc("RunText"),Z0=Zc("RunCode"),tg=t=>e=>n=>e.length===0?n:Ft(n)({style:t,text:cr(e)}),K0=t=>({style:(()=>{if(t.style==="RunText")return Z0;if(t.style==="RunCode")return Kc;g()})(),buf:[],runs:tg(t.style)(t.buf)(t.runs)}),tp=t=>e=>0<e.length?{...t,buf:Ft(t.buf)(e[0])}:{...t,buf:Ft(t.buf)("\\")},ep=t=>e=>{let n=t,r=e,i=!0,o;for(;i;){const u=n,s=Bt(a=>T,a=>c=>w("Just",{head:a,tail:c}),r);if(s.tag==="Nothing"){i=!1,o=u;continue}if(s.tag==="Just"){if(s._1.head==="\\"){n=tp(u)(s._1.tail),r=bt(1,s._1.tail.length,s._1.tail);continue}if(s._1.head==="`"){n=K0(u),r=s._1.tail;continue}n={...u,buf:Ft(u.buf)(s._1.head)},r=s._1.tail;continue}g()}return o},eg=t=>{const e=ep({style:Kc,buf:[],runs:[]})(Vn(t));return tg(e.style)(e.buf)(e.runs)};let ms=null;function np(){return ms||(typeof document>"u"?null:(ms=document.createElement("canvas").getContext("2d"),ms))}const ng=new Map,rp=t=>e=>n=>r=>()=>{const i=`${n} ${e}px ${t}|${r}`,o=ng.get(i);if(o!==void 0)return o;const u=np();if(!u)return r.length*e*.62;u.font=`${n} ${e}px ${t}`;const s=u.measureText(r).width;return ng.set(i,s),s},ip=ir.traverse(Nu),op=J(Tr)(0),Ir=(()=>{const t=Zn(`\r
|
|
3
|
-
`)(" "),e=
|
|
4
|
-
`)(" "),n=(()=>{const r=
|
|
5
|
-
`)(o._1))(ys(i)),s=J(c=>f=>Dr(c)(Un(f)))(0)(u),a=o._2.shape==="Cylinder"?Dr(1)(En((s+2|0)+t.cellW|0,t.cellW)):r;return{...o._2,size:b(rt(s>i?En((s+2|0)+t.cellW|0,t.cellW):a),rt(Dr(1)(En(u.length+t.cellH|0,t.cellH))+(o._2.shape==="Cylinder"?1:0)|0))}})(n)}},dp=t=>e=>n=>({...n,nodes:O(r=>{const i=cp(r.id)(e);if(i.tag==="Nothing")return r;if(i.tag==="Just")return{...r,size:b(ap(r.size._1)(rt(Dr(1)(de(Vi(r.shape==="Cylinder"?(i._1+0)/t:(i._1+32)/t))))),r.size._2)};g()})(n.nodes)}),lp=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},hp=t=>{const e=t.length;return(n=>r=>{let i=n,o=r,u=!0,s;for(;u;){const a=i,c=o;if(a>=e){u=!1,s=c;continue}const f=d=>l=>{let _=d,h=l,m=!0,p;for(;m;){const y=_,x=h;if(y>=e){m=!1,p=x;continue}if(a>=0&&a<t.length){if(y>=0&&y<t.length){_=y+1|0,h=(()=>{const N=t[a].position,v=t[a].size,L=t[y].position,k=t[y].size;return N._1<L._1+k._1&&L._1<N._1+v._1&&N._2<L._2+k._2&&L._2<N._2+v._2})()?x+1|0:x;continue}_=y+1|0,h=x;continue}m=!1,p=x}return p};i=a+1|0,o=f(a+1|0)(c)}return s})(0)(0)},ug=t=>J(e=>n=>e+xl(n.start)(n.end))(0)(t.segments),pp=t=>e=>n=>({crossingCount:J(r=>i=>r+i.jumps.length|0)(0)(e),bendCount:J(r=>i=>r+i.bends.length|0)(0)(e),totalEdgeLength:J(r=>i=>r+ug(i))(0)(e),maxEdgeLength:J(r=>i=>lp(r)(ug(i)))(0)(e),nodeOverlapCount:hp(t),constraintViolations:n,jumpCount:J(r=>i=>r+i.jumps.length|0)(0)(e)}),xs=t=>t,jt=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Ns=xs("LEFT"),mp=xs("RIGHT"),sg=xs("UNDEFINED"),yp={eq:t=>e=>t==="LEFT"?e==="LEFT":t==="RIGHT"?e==="RIGHT":t==="UP"?e==="UP":t==="DOWN"?e==="DOWN":t==="UNDEFINED"&&e==="UNDEFINED"},xp={compare:t=>e=>{if(t==="LEFT")return e==="LEFT"?Ge:ye;if(e==="LEFT")return xe;if(t==="RIGHT")return e==="RIGHT"?Ge:ye;if(e==="RIGHT")return xe;if(t==="UP")return e==="UP"?Ge:ye;if(e==="UP")return xe;if(t==="DOWN")return e==="DOWN"?Ge:ye;if(e==="DOWN")return xe;if(t==="UNDEFINED"&&e==="UNDEFINED")return Ge;g()},Eq0:()=>yp},Np=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){if(t==="LEFT"){if(o._3==="LEFT"){r=!1,i=!0;continue}n=o._5;continue}if(o._3==="LEFT"){n=o._6;continue}if(t==="RIGHT"){if(o._3==="RIGHT"){r=!1,i=!0;continue}n=o._5;continue}if(o._3==="RIGHT"){n=o._6;continue}if(t==="UP"){if(o._3==="UP"){r=!1,i=!0;continue}n=o._5;continue}if(o._3==="UP"){n=o._6;continue}if(t==="DOWN"){if(o._3==="DOWN"){r=!1,i=!0;continue}n=o._5;continue}if(o._3==="DOWN"){n=o._6;continue}if(t==="UNDEFINED"&&o._3==="UNDEFINED"){r=!1,i=!0;continue}}g()}return i},Jp={x:0,y:0},Xe=t=>e=>n=>{const r=jt(t)(n.cNodes);if(r.tag==="Nothing")return n;if(r.tag==="Just")return{...n,cNodes:K(it)(t)(e(r._1))(n.cNodes)};g()},vi=t=>e=>n=>{const r=jt(t)(n.cGroups);if(r.tag==="Nothing")return n;if(r.tag==="Just")return{...n,cGroups:K(it)(t)(e(r._1))(n.cGroups)};g()},Tp=t=>J(e=>n=>Xe(n)(r=>({...r,hitboxPreCompaction:r.hitbox}))(e))(t)(t.cNodeOrder),vp=t=>{const e=J(n=>r=>{const i=jt(r)(t.cNodes);if(i.tag==="Nothing")return n;if(i.tag==="Just")return J(o=>u=>vt(it)(te)(u)([r])(o))(n)(i._1.constraints);g()})(A)(t.cNodeOrder);return J(n=>r=>Xe(r)(i=>({...i,constraints:(()=>{const o=jt(r)(e);if(o.tag==="Nothing")return[];if(o.tag==="Just")return o._1;g()})()}))(n))(t)(t.cNodeOrder)},wp=t=>e=>Xe(t)(n=>({...n,ignoreSpacing:{left:n.ignoreSpacing.left||e.left,right:n.ignoreSpacing.right||e.right,up:n.ignoreSpacing.up||e.up,down:n.ignoreSpacing.down||e.down}})),bp=t=>{const e=J(n=>r=>vi(r)(i=>({...i,outDegree:i.outDegreeReal}))(n))(t)(t.cGroupOrder);return J(n=>r=>Xe(r)(i=>({...i,startPos:-1e308}))(n))(e)(e.cNodeOrder)},sn={left:!1,right:!1,up:!1,down:!1},Lp={horizontalSpacing:t=>e=>0,verticalSpacing:t=>e=>0},Js=t=>J(e=>n=>{const r=jt(n)(e.cGroups);if(r.tag==="Nothing")return e;if(r.tag==="Just"){const i=J(u=>s=>{const a=jt(s)(e.cNodes);if(a.tag==="Nothing")return u;if(a.tag==="Just"){if(u.tag==="Nothing")return w("Just",s);if(u.tag==="Just"){const c=jt(u._1)(e.cNodes);if(c.tag==="Nothing")return w("Just",s);if(c.tag==="Just")return a._1.hitbox.x<c._1.hitbox.x?w("Just",s):w("Just",u._1)}}g()})(T)(r._1.cNodes),o=vi(n)(u=>({...u,reference:i}))(e);if(i.tag==="Nothing")return o;if(i.tag==="Just"){const u=jt(i._1)(o.cNodes);if(u.tag==="Nothing")return o;if(u.tag==="Just"){const s=u._1;return J(a=>c=>Xe(c)(f=>({...f,cGroupOffset:{x:f.hitbox.x-s.hitbox.x,y:f.hitbox.y-s.hitbox.y}}))(a))(o)(r._1.cNodes)}}}g()})(t)(t.cGroupOrder),Ve=t=>Js({...t,cNodes:(()=>{const e=n=>{if(n.tag==="Leaf")return A;if(n.tag==="Node")return Mt("Node",n._1,n._2,n._3,{...n._4,hitbox:{...n._4.hitbox,x:-n._4.hitbox.x-n._4.hitbox.width}},e(n._5),e(n._6));g()};return e(t.cNodes)})()}),xn=t=>Js({...t,cNodes:(()=>{const e=n=>{if(n.tag==="Leaf")return A;if(n.tag==="Node")return Mt("Node",n._1,n._2,n._3,{...n._4,hitbox:{x:n._4.hitbox.y,y:n._4.hitbox.x,width:n._4.hitbox.height,height:n._4.hitbox.width},cGroupOffset:{x:n._4.cGroupOffset.y,y:n._4.cGroupOffset.x}},e(n._5),e(n._6));g()};return e(t.cNodes)})()}),ag=t=>{const e=J(n=>r=>vi(r)(i=>({...i,outDegree:0,outDegreeReal:0,incomingConstraints:[]}))(n))(t)(t.cGroupOrder);return J(n=>r=>{const i=jt(r)(n.cNodes);if(i.tag==="Nothing")return n;if(i.tag==="Just"){if(i._1.cGroup.tag==="Nothing")return n;if(i._1.cGroup.tag==="Just"){const o=i._1.cGroup._1;return J(u=>s=>{const a=jt(s)(u.cNodes);if(a.tag==="Nothing")return u;if(a.tag==="Just")return a._1.cGroup.tag==="Just"&&a._1.cGroup._1!==o?vi(a._1.cGroup._1)(c=>({...c,outDegree:c.outDegree+1|0,outDegreeReal:c.outDegreeReal+1|0}))(vi(o)(c=>Qe(xr)(s)(c.incomingConstraints)?c:{...c,incomingConstraints:[...c.incomingConstraints,s]})(u)):u;g()})(n)(i._1.constraints)}}g()})(e)(e.cNodeOrder)},Lo=t=>{const e=vp(t.cGraph);return{...t,cGraph:ag(J(n=>r=>Xe(r)(i=>({...i,startPos:-1e308}))(n))(e)(e.cNodeOrder))}},kp=t=>e=>J(n=>r=>{if(t==="LEFT"||t==="UP"){const o=r._2;return Xe(r._1)(u=>({...u,constraints:[...u.constraints,o]}))(n)}const i=r._1;return Xe(r._2)(o=>({...o,constraints:[...o.constraints,i]}))(n)})(e)(t==="LEFT"||t==="RIGHT"?e.predefinedHorizontalConstraints:e.predefinedVerticalConstraints),an=t=>{const e={...t,cGraph:kp(t.direction)({...t.cGraph,cNodes:(()=>{const n=r=>{if(r.tag==="Leaf")return A;if(r.tag==="Node")return Mt("Node",r._1,r._2,r._3,{...r._4,constraints:[]},n(r._5),n(r._6));g()};return n(t.cGraph.cNodes)})()})};return{...e,cGraph:ag((()=>{if(e.constraintAlgorithm.tag==="Nothing")return e.cGraph;if(e.constraintAlgorithm.tag==="Just")return e.constraintAlgorithm._1(e);g()})())}},Ep=t=>e=>n=>{const r={...n,direction:e};if(t==="UNDEFINED")return e==="LEFT"?an(r):e==="RIGHT"?an({...r,cGraph:Ve(r.cGraph)}):e==="UP"?an({...r,cGraph:xn(r.cGraph)}):e==="DOWN"?an({...r,cGraph:Ve(xn(r.cGraph))}):r;if(t==="LEFT")return e==="RIGHT"?Lo({...r,cGraph:Ve(r.cGraph)}):e==="UP"?an({...r,cGraph:xn(r.cGraph)}):e==="DOWN"?an({...r,cGraph:Ve(xn(r.cGraph))}):r;if(t==="RIGHT")return e==="LEFT"?Lo({...r,cGraph:Ve(r.cGraph)}):e==="UP"?an({...r,cGraph:xn(Ve(r.cGraph))}):e==="DOWN"?an({...r,cGraph:Ve(xn(Ve(r.cGraph)))}):r;if(t==="UP")return e==="LEFT"?an({...r,cGraph:xn(r.cGraph)}):e==="RIGHT"?an({...r,cGraph:Ve(xn(r.cGraph))}):e==="DOWN"?Lo({...r,cGraph:Ve(r.cGraph)}):r;if(t==="DOWN")return e==="LEFT"?an({...r,cGraph:xn(Ve(r.cGraph))}):e==="RIGHT"?an({...r,cGraph:Ve(xn(Ve(r.cGraph)))}):e==="UP"?Lo({...r,cGraph:Ve(r.cGraph)}):r;g()},cg=t=>e=>e.finished||!Np(t)(e.cGraph.supportedDirections)||(t==="LEFT"?e.direction==="LEFT":t==="RIGHT"?e.direction==="RIGHT":t==="UP"?e.direction==="UP":t==="DOWN"?e.direction==="DOWN":t==="UNDEFINED"&&e.direction==="UNDEFINED")?e:Ep(e.direction)(t)(e),Cp=t=>{if(t.finished)return t;const e=t.direction==="UNDEFINED"?cg(Ns)(t):t,n={...e,cGraph:bp(e.cGraph)};if(n.compactionAlgorithm.tag==="Nothing")return n;if(n.compactionAlgorithm.tag==="Just")return n.compactionAlgorithm._1(n);g()},gg=t=>e=>n=>{const r=jt(t)(n.cNodes),i=jt(e)(n.cGroups);return r.tag==="Just"&&i.tag==="Just"?(()=>{if(r._1.cGroup.tag==="Nothing")return!1;if(r._1.cGroup.tag==="Just")return!0;g()})()&&(r._1.cGroup.tag==="Nothing"||!(r._1.cGroup.tag==="Just"&&r._1.cGroup._1===e))?n:{...n,cNodes:K(it)(t)({...r._1,cGroup:w("Just",e)})(n.cNodes),cGroups:K(it)(e)({...i._1,cNodes:Qe(xr)(t)(i._1.cNodes)?i._1.cNodes:[...i._1.cNodes,t],reference:(()=>{if(i._1.reference.tag==="Nothing")return w("Just",t);if(i._1.reference.tag==="Just")return w("Just",i._1.reference._1);g()})()})(n.cGroups)}:n},fg=t=>e=>({id:e.nextCNodeId,graph:{...e,cNodes:K(it)(e.nextCNodeId)({id:e.nextCNodeId,origin:t.origin,kind:t.kind,cGroup:T,cGroupOffset:Jp,hitbox:t.hitbox,hitboxPreCompaction:t.hitbox,constraints:[],startPos:-1e308,ignoreSpacing:sn})(e.cNodes),cNodeOrder:[...e.cNodeOrder,e.nextCNodeId],nextCNodeId:e.nextCNodeId+1|0}}),Ts=t=>e=>{const n=e.nextCGroupId;return{id:n,graph:J(r=>i=>gg(i)(n)(r))({...e,cGroups:K(it)(n)({id:n,master:t.master,cNodes:[],startPos:-1e308,incomingConstraints:[],outDegree:0,outDegreeReal:0,reference:T,delta:0,deltaNormalized:0})(e.cGroups),cGroupOrder:[...e.cGroupOrder,n],nextCGroupId:n+1|0})(t.nodes)}},Sp=t=>J(e=>n=>{const r=jt(n)(e.cNodes);return r.tag==="Just"&&r._1.cGroup.tag==="Nothing"?Ts({master:T,nodes:[n]})(e).graph:e})(t)(t.cNodeOrder),Gp=t=>({cGraph:Tp(Sp(Js(t))),direction:sg,compactionAlgorithm:T,constraintAlgorithm:T,spacingsHandler:Lp,lockFun:T,finished:!1}),_g=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Pp=t=>e=>{const n=st.compare(t._1)(e._1);return n==="LT"?ye:n==="GT"?xe:it.compare(t._2)(e._2)},Ip=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),dg=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},lg=t=>t.kind.tag==="Nothing"?!1:t.kind.tag==="Just"&&t.kind._1==="vs",hg=t=>t.kind.tag==="Nothing"||!(t.kind.tag==="Just"&&t.kind._1==="vs"),pg=rt(4),mg=_g(0)(pg/2-.5),Dp=_g(0)(pg/2-.5),ko=t=>e=>Pp(b(t.hitbox.x+t.hitbox.width/2,t.id))(b(e.hitbox.x+e.hitbox.width/2,e.id)),Ap=t=>e=>{const n=On(Yt,T,r=>ko(t)(r)==="LT",e);if(n.tag==="Just"){const r=Qa(Yt,T,n._1,t,e);if(r.tag==="Nothing")return e;if(r.tag==="Just")return r._1;g()}if(n.tag==="Nothing")return Ft(e)(t);g()},yg=t=>e=>{const n=at(i=>ko(i)(t)==="LT",e),r=n.length-1|0;return r>=0&&r<n.length?w("Just",n[r]):T},Bp=t=>e=>{const n=Ap(e)(t.intervals),r=Xt(o=>ko(e)(o)==="LT")(n),i=K(it)(e.id)((()=>{const o=yg(e)(n);return o.tag==="Just"?w("Just",o._1.id):T})())(t.cand);return{...t,intervals:n,cand:(()=>{if(r.tag==="Just")return K(it)(r._1.id)(w("Just",e.id))(i);if(r.tag==="Nothing")return i;g()})()}},Fp=t=>e=>{const n=st.compare(t.low?t.node.hitbox.y:t.node.hitbox.y+t.node.hitbox.height)(e.low?e.node.hitbox.y:e.node.hitbox.y+e.node.hitbox.height);return n==="EQ"?t.low?t.low&&!e.low?xe:Ge:e.low?ye:Ge:n},Rp=t=>J(e=>n=>Xe(n.id)(r=>({...r,constraints:[]}))(e))(t)(xt(e=>jt(e)(t.cNodes))(t.cNodeOrder)),Qp=t=>e=>J(n=>r=>{const i=jt(r._1)(n.cNodes);if(i.tag==="Just")return Xe(r._1)(o=>({...o,constraints:[...o.constraints,...r._2]}))(n);if(i.tag==="Nothing")return n;g()})(e)(Ip(t)),xg=t=>e=>e.kind.tag!=="Nothing"&&e.kind.tag==="Just"&&e.kind._1==="vs"?e.ignoreSpacing.up?e.ignoreSpacing.down?e:{...e,hitbox:{...e.hitbox,height:e.hitbox.height+t+.01}}:{...e,hitbox:{...e.hitbox,y:e.hitbox.y-t-.01,height:e.hitbox.height+t+.01}}:{...e,hitbox:{...e.hitbox,y:e.hitbox.y-t,height:e.hitbox.height+2*t}},Ng=t=>e=>n=>J(r=>i=>n(i)?Xe(i.id)(xg(t))(r):r)(e)(xt(r=>jt(r)(e.cNodes))(e.cNodeOrder)),zp=t=>e=>{const n=(r,i,o)=>{const u=Xe(o)(xg(t))(r);return i.length<=1?u:J(s=>a=>a===o?s:Xe(a)(c=>c.ignoreSpacing.up?{...c,hitbox:{...c.hitbox,y:c.hitbox.y+t+.01,height:c.hitbox.height-t-.01}}:c.ignoreSpacing.down?{...c,hitbox:{...c.hitbox,height:c.hitbox.height-t-.01}}:c)(s))(u)(i)};return J(r=>i=>{if(i.master.tag==="Nothing")return 0<i.cNodes.length?n(r,i.cNodes,i.cNodes[0]):r;if(i.master.tag==="Just")return n(r,i.cNodes,i.master._1);g()})(e)(xt(r=>jt(r)(e.cGroups))(e.cGroupOrder))},Wp=t=>e=>{const n=yg(e)(t.intervals),r=Xt(o=>ko(e)(o)==="LT")(t.intervals),i=n.tag==="Just"&&(()=>{const o=dg(e.id)(t.cand);return(o.tag==="Nothing"?!1:o.tag==="Just"&&(o._1.tag==="Nothing"?!1:o._1.tag==="Just"&&o._1._1===n._1.id))&&n._1.cGroup.tag==="Just"&&e.cGroup.tag==="Just"&&n._1.cGroup._1!==e.cGroup._1})()?vt(it)(te)(n._1.id)([e.id])(t.constraints):t.constraints;return{...t,constraints:r.tag==="Just"&&(()=>{const o=dg(r._1.id)(t.cand);return(o.tag==="Nothing"?!1:o.tag==="Just"&&(o._1.tag==="Nothing"?!1:o._1.tag==="Just"&&o._1._1===e.id))&&e.cGroup.tag==="Just"&&r._1.cGroup.tag==="Just"&&e.cGroup._1!==r._1.cGroup._1})()?vt(it)(te)(e.id)([r._1.id])(i):i,intervals:at(o=>o.id!==e.id,t.intervals)}},Mp=t=>e=>e.low?Bp(t)(e.node):Wp(t)(e.node),vs=t=>e=>Qp(J(Mp)({intervals:[],cand:A,constraints:A})(Lt(Fp)(Tt(at(t,xt(n=>jt(n)(e.cNodes))(e.cNodeOrder)))(n=>[{node:n,low:!0},{node:n,low:!1}]))).constraints)(e),Hp=t=>vs(e=>!0)(zp(mg)(vs(hg)(Ng(mg)(vs(lg)(Ng(Dp)(t)(lg)))(hg)))),Op=t=>Hp(Rp(t.cGraph)),Eo=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Jg=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},ws=t=>e=>n=>r=>i=>({id:t,representedEdges:[i],affectedBends:[e,n],hitbox:{x:Eo(e._1)(n._1),y:Eo(e._2)(n._2),width:$n(e._1-n._1),height:$n(e._2-n._2)},ignoreSpacing:sn,potentialGroupParents:(()=>{if(r.tag==="Nothing")return[];if(r.tag==="Just")return[r._1];g()})(),aPort:T}),qp=t=>e=>{const n=Eo(t.hitbox.x)(e.hitbox.x),r=Eo(t.hitbox.y)(e.hitbox.y);return{...t,representedEdges:[...t.representedEdges,...e.representedEdges],affectedBends:[...t.affectedBends,...e.affectedBends],potentialGroupParents:[...t.potentialGroupParents,...e.potentialGroupParents],hitbox:{x:n,y:r,width:Jg(t.hitbox.x+t.hitbox.width)(e.hitbox.x+e.hitbox.width)-n,height:Jg(t.hitbox.y+t.hitbox.height)(e.hitbox.y+e.hitbox.height)-r},ignoreSpacing:{left:t.ignoreSpacing.left||e.ignoreSpacing.left,right:t.ignoreSpacing.right||e.ignoreSpacing.right,up:t.ignoreSpacing.up||e.ignoreSpacing.up,down:t.ignoreSpacing.down||e.ignoreSpacing.down},aPort:(()=>{if(t.aPort.tag==="Just")return t.aPort;if(t.aPort.tag==="Nothing")return e.aPort;g()})()}},$p=t=>e=>$n(t.hitbox.x-e.hitbox.x)<=1e-4&&e.hitbox.y-(t.hitbox.y+t.hitbox.height)<=1e-4&&t.hitbox.y-(e.hitbox.y+e.hitbox.height)<=1e-4,Yp=t=>e=>$n(t.hitbox.x-e.hitbox.x)<=1e-4?st.compare(t.hitbox.y)(e.hitbox.y):t.hitbox.x<e.hitbox.x?ye:xe,Tg=(t,e)=>({tag:t,_1:e}),bs=Kt(P)(zt),Co=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},vg=(()=>{const t={eq:n=>r=>n._1===r._1&&(n._2.tag==="Nothing"?r._2.tag==="Nothing":n._2.tag==="Just"&&r._2.tag==="Just"&&n._2._1===r._2._1)},e={compare:n=>r=>{const i=P.compare(n._1)(r._1);if(i==="LT")return ye;if(i==="GT")return xe;if(n._2.tag==="Nothing")return r._2.tag==="Nothing"?Ge:ye;if(r._2.tag==="Nothing")return xe;if(n._2.tag==="Just"&&r._2.tag==="Just")return P.compare(n._2._1)(r._2._1);g()},Eq0:()=>t};return J(n=>r=>K(e)(r)()(n))(A)})(),Gn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Xp=J(t=>e=>K(xp)(e)()(t))(A),Ls=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=ac.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Vp=t=>e=>{const n=bs(O(o=>b(o.id,o))(t)),r=xt(o=>Co(o)(n))(e),i=it.compare((()=>{const o=vg(O(u=>b(u.from.node,u.from.port))(r));if(o.tag==="Leaf")return 0;if(o.tag==="Node")return o._2;g()})())((()=>{const o=vg(O(u=>b(u.to.node,u.to.port))(r));if(o.tag==="Leaf")return 0;if(o.tag==="Node")return o._2;g()})());if(i==="LT")return{...sn,left:!0,right:!1};if(i==="GT")return{...sn,left:!1,right:!0};if(i==="EQ")return sn;g()},Up=t=>xt(e=>{if(e.direction==="V")return w("Just",{start:e.start,end:e.end});if(e.direction==="H")return T;g()})(t.segments),So=t=>e=>n=>{if(n.tag==="Just"){const r=Gn(e)(t);if(r.tag==="Just"){const i=Xt(o=>o.id===n._1)(r._1);if(i.tag==="Just")return i._1.side;if(i.tag==="Nothing")return pn;g()}if(r.tag==="Nothing")return pn;g()}if(n.tag==="Nothing")return pn;g()},jp=t=>e=>n=>{const r=fg({origin:w("Just",Tg("SegmentOrigin",n)),kind:w("Just","vs"),hitbox:n.hitbox})(e.cGraph),i=wp(r.id)(n.ignoreSpacing)(r.graph);return{...e,cGraph:(()=>{if(0<n.potentialGroupParents.length){const o=jt(n.potentialGroupParents[0])(i.cNodes);if(o.tag==="Just"){if(o._1.cGroup.tag==="Just")return gg(r.id)(o._1.cGroup._1)(i);if(o._1.cGroup.tag==="Nothing")return i;g()}if(o.tag==="Nothing")return i;g()}return Ts({master:w("Just",r.id),nodes:[r.id]})(i).graph})(),edgeToCs:J(o=>u=>vt(P)(te)(u)([r.id])(o))(e.edgeToCs)(n.representedEdges),lockMap:K(it)(r.id)(Vp(t)(n.representedEdges))(e.lockMap)}},Zp=t=>e=>n=>{const r=Bt(i=>T,i=>o=>w("Just",{head:i,tail:o}),Lt(Yp)(e));if(r.tag==="Nothing")return n;if(r.tag==="Just"){const i=J(o=>u=>$p(o.survivor)(u)?{...o,survivor:qp(o.survivor)(u)}:{survivor:u,merged:[...o.merged,o.survivor]})({survivor:r._1.head,merged:[]})(r._1.tail);return J(jp(t))(n)([...i.merged,i.survivor])}g()},Kp=t=>({cGraph:{cNodes:A,cNodeOrder:[],cGroups:A,cGroupOrder:[],supportedDirections:Xp([sg,Ns,mp]),predefinedHorizontalConstraints:[],predefinedVerticalConstraints:[],nextCNodeId:0,nextCGroupId:0},nodeToC:A,edgeToCs:A,lockMap:A}),tm=t=>{const e=rt(4);return{x:t.position._1*e,y:t.position._2*e,width:t.size._1*e,height:t.size._2*e}},em=t=>e=>n=>J(r=>i=>{const o=fg({origin:w("Just",Tg("NodeOrigin",i.node)),kind:T,hitbox:tm(i)})(r.cGraph),u=Gn(i.node)(t),s=(()=>{if(u.tag==="Nothing")return b(0,0);if(u.tag==="Just")return u._1;g()})();return{...r,cGraph:Ts({master:w("Just",o.id),nodes:[o.id]})(o.graph).graph,nodeToC:K(P)(i.node)(o.id)(r.nodeToC),lockMap:K(it)(o.id)((()=>{const a=s._1-s._2|0;return a<0?{...sn,left:!0}:a>0?{...sn,right:!0}:sn})())(r.lockMap)}})(n)(e),nm=t=>J(e=>n=>vt(P)(r=>i=>b(r._1+i._1|0,r._2+i._2|0))(n.to.node)(b(1,0))(vt(P)(r=>i=>b(r._1+i._1|0,r._2+i._2|0))(n.from.node)(b(0,1))(e)))(A)(t),rm=t=>J(e=>n=>n.origin.tag==="Just"&&n.origin._1.tag==="NodeOrigin"?K(P)(n.origin._1._1)(n.hitbox.x)(e):e)(A)(xt(e=>jt(e)(t.cNodes))(t.cNodeOrder)),im=t=>J(e=>n=>n.origin.tag==="Just"&&n.origin._1.tag==="NodeOrigin"?K(P)(n.origin._1._1)(n.hitbox.x-n.hitboxPreCompaction.x)(e):e)(A)(xt(e=>jt(e)(t.cNodes))(t.cNodeOrder)),om=t=>J(e=>n=>{if(n.origin.tag==="Just"&&n.origin._1.tag==="SegmentOrigin"){const r=n.hitbox.x-n.hitboxPreCompaction.x;return J(i=>o=>K(ac)(o)(r)(i))(e)(n.origin._1._1.affectedBends)}return e})(A)(xt(e=>jt(e)(t.cNodes))(t.cNodeOrder)),wg=t=>{const e=bs(O(n=>b(n.id,n))(t.edges));return xt(n=>{const r=Co(n.edge)(e);if(r.tag==="Just")return n.reversed?w("Just",{edgeId:n.edge,src:r._1.to.node,tgt:r._1.from.node,srcSide:So(t.ports)(r._1.to.node)(r._1.to.port),tgtSide:So(t.ports)(r._1.from.node)(r._1.from.port),path:n}):w("Just",{edgeId:n.edge,src:r._1.from.node,tgt:r._1.to.node,srcSide:So(t.ports)(r._1.from.node)(r._1.from.port),tgtSide:So(t.ports)(r._1.to.node)(r._1.to.port),path:n});if(r.tag==="Nothing")return T;g()})(t.paths)},um=t=>e=>{const n=Tt(e)(r=>{if(r.src===r.tgt)return[];if((r.srcSide==="North"||r.srcSide==="South")&&(r.tgtSide==="North"||r.tgtSide==="South"))return[];const i=Gn(r.tgt)(t.nodeToC),o=(()=>{if(i.tag==="Just")return jt(i._1)(t.cGraph.cNodes);if(i.tag==="Nothing")return T;g()})(),u=Gn(r.src)(t.nodeToC),s=(()=>{if(u.tag==="Just")return jt(u._1)(t.cGraph.cNodes);if(u.tag==="Nothing")return T;g()})(),a=(()=>{if(s.tag==="Just"){if(o.tag==="Just"){if(s._1.cGroup.tag==="Just"){if(o._1.cGroup.tag==="Just")return w("Just",{srcGroup:s._1.cGroup._1,tgtGroup:o._1.cGroup._1,delta:0,weight:100});if(o._1.cGroup.tag==="Nothing")return T;g()}if(s._1.cGroup.tag==="Nothing")return T;g()}if(o.tag==="Nothing")return T;g()}if(s.tag==="Nothing")return T;g()})(),c=_=>h=>m=>{if(s.tag==="Just"){if(s._1.cGroup.tag==="Just"){if(m.cGroup.tag==="Just")return _(m.hitbox.x)&&m.cGroup._1!==s._1.cGroup._1?w("Just",h(m.cGroup._1)(s._1.cGroup._1)):T;if(m.cGroup.tag==="Nothing")return T;g()}if(s._1.cGroup.tag==="Nothing")return T;g()}if(s.tag==="Nothing")return T;g()},f=xt(_=>jt(_)(t.cGraph.cNodes))((()=>{const _=Co(r.edgeId)(t.edgeToCs);if(_.tag==="Nothing")return[];if(_.tag==="Just")return _._1;g()})()),d=(()=>{if(s.tag==="Just"&&r.srcSide==="West"){const _=s._1;return xt(c(h=>h<_.hitbox.x)(h=>m=>({srcGroup:h,tgtGroup:m,delta:1,weight:100})))(f)}return[]})(),l=(()=>{if(s.tag==="Just"&&r.tgtSide==="East"){const _=s._1;return xt(c(h=>h>_.hitbox.x)(h=>m=>({srcGroup:m,tgtGroup:h,delta:1,weight:100})))(f)}return[]})();if(a.tag==="Nothing")return[];if(a.tag==="Just")return[a._1,...d,...l];g()});return{sameEdgeVerticalSegments:r=>i=>r.origin.tag==="Just"&&r.origin._1.tag==="SegmentOrigin"&&i.origin.tag==="Just"&&i.origin._1.tag==="SegmentOrigin"&&(()=>{const o=i.origin._1._1;return Re(u=>Qe(gn)(u)(o.representedEdges),r.origin._1._1.representedEdges)})(),vsLNodePair:r=>i=>r.origin.tag==="Just"&&i.origin.tag==="Just"&&(r.origin._1.tag==="SegmentOrigin"?i.origin._1.tag==="NodeOrigin":r.origin._1.tag==="NodeOrigin"&&i.origin._1.tag==="SegmentOrigin"),edgeLengthEdges:r=>n}},sm=t=>e=>{const n=rt(4),r=rm(t),i=im(t),o=bs(O(s=>b(s.id,b(s.from.node,s.to.node)))(e.edges)),u=om(t);return{nodes:O(s=>{const a=Gn(s.node)(r);if(a.tag==="Just")return{...s,position:b(a._1/n,s.position._2)};if(a.tag==="Nothing")return s;g()})(e.nodes),edges:O(s=>{const a=Co(s.edge)(o),c=(()=>{if(a.tag==="Nothing")return s.segments;if(a.tag==="Just"){const f=Gn(a._1._1)(i),d=(()=>{if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1;g()})(),l=Gn(a._1._2)(i),_=(()=>{if(l.tag==="Nothing")return 0;if(l.tag==="Just")return l._1;g()})();return At((()=>{const h=s.reversed?_:d,m=s.reversed?d:_,p=s.segments.length;return y=>x=>{if(x.direction==="V"){const N=(()=>{if(y===0)return h;if(y===(p-1|0))return m;const v=Ls(x.start)(u);if(v.tag==="Nothing")return 0;if(v.tag==="Just")return v._1;g()})();return{...x,start:b(x.start._1+N,x.start._2),end:b(x.end._1+N,x.end._2)}}if(x.direction==="H")return{...x,start:b((()=>{if(y===0)return x.start._1+h;const N=Ls(x.start)(u);if(N.tag==="Nothing")return x.start._1+0;if(N.tag==="Just")return x.start._1+N._1;g()})(),x.start._2),end:b((()=>{if(y===(p-1|0))return x.end._1+m;const N=Ls(x.end)(u);if(N.tag==="Nothing")return x.end._1+0;if(N.tag==="Just")return x.end._1+N._1;g()})(),x.end._2)};g()}})())(s.segments)}g()})();return{...s,segments:c,bends:Je(f=>d=>f.end,c,bt(1,c.length,c))}})(e.paths)}},am=t=>e=>n=>r=>i=>o=>{const u=ws(i.nextId)(o._2.start)(o._2.end)(T)(t.edgeId),s=(()=>{if(o._1===0){if(e.tag==="Nothing")return u;if(e.tag==="Just")return{...u,ignoreSpacing:o._2.end._2<e._1.y?{...u.ignoreSpacing,down:!0}:o._2.end._2>e._1.y+e._1.height?{...u.ignoreSpacing,up:!0}:{...u.ignoreSpacing,up:!0,down:!0}};g()}return u})();return{nextId:i.nextId+1|0,segments:[...i.segments,(()=>{if(o._1===r){if(n.tag==="Nothing")return s;if(n.tag==="Just")return{...s,ignoreSpacing:o._2.start._2<n._1.y?{...s.ignoreSpacing,down:!0}:o._2.start._2>n._1.y+n._1.height?{...s.ignoreSpacing,up:!0}:{...s.ignoreSpacing,up:!0,down:!0}};g()}return s})()]}},bg=t=>e=>n=>r=>i=>o=>({nextId:o.nextId+1|0,segments:[...o.segments,{...ws(o.nextId)(r.start)(b(r.start._1,i.down?n.y:n.y+n.height))(w("Just",e))(t.edgeId),aPort:w("Just",{node:t.src,side:i.side}),ignoreSpacing:i.down?{...sn,down:!0}:{...sn,up:!0}}]}),Go=t=>e=>n=>r=>i=>o=>({nextId:o.nextId+1|0,segments:[...o.segments,{...ws(o.nextId)(r.end)(b(r.end._1,i.down?n.y:n.y+n.height))(w("Just",e))(t.edgeId),aPort:w("Just",{node:t.tgt,side:i.side}),ignoreSpacing:i.down?{...sn,down:!0}:{...sn,up:!0}}]}),cm=t=>e=>n=>{const r=Gn(n.src)(t.nodeToC),i=Gn(n.tgt)(t.nodeToC),o=(()=>{if(r.tag==="Just"){const f=jt(r._1)(t.cGraph.cNodes);return f.tag==="Just"?w("Just",f._1.hitbox):T}if(r.tag==="Nothing")return T;g()})(),u=(()=>{if(i.tag==="Just"){const f=jt(i._1)(t.cGraph.cNodes);return f.tag==="Just"?w("Just",f._1.hitbox):T}if(i.tag==="Nothing")return T;g()})(),s=Up(n.path),a=J(am(n)(o)(u)(s.length-1|0))(e)(At(f=>d=>b(f,d))(s));if(0<s.length){const f=(()=>{if(r.tag==="Just"&&o.tag==="Just"){if(n.srcSide==="North")return bg(n)(r._1)(o._1)(s[0])({side:le,down:!0})(a);if(n.srcSide==="South")return bg(n)(r._1)(o._1)(s[0])({side:he,down:!1})(a)}return a})(),d=s.length-1|0;if(d>=0&&d<s.length&&i.tag==="Just"&&u.tag==="Just"){if(n.tgtSide==="North")return Go(n)(i._1)(u._1)(s[d])({side:le,down:!0})(f);if(n.tgtSide==="South")return Go(n)(i._1)(u._1)(s[d])({side:he,down:!1})(f)}return f}const c=s.length-1|0;if(c>=0&&c<s.length&&i.tag==="Just"&&u.tag==="Just"){if(n.tgtSide==="North")return Go(n)(i._1)(u._1)(s[c])({side:le,down:!0})(a);if(n.tgtSide==="South")return Go(n)(i._1)(u._1)(s[c])({side:he,down:!1})(a)}return a},gm=t=>e=>n=>Zp(t)(J(cm(n))({nextId:0,segments:[]})(e).segments)(n),fm=t=>gm(t.edges)(wg(t))(em(nm(t.edges))(t.nodes)(Kp())),Pn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},ks=t=>e=>{const n=it.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Es=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},_m=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},dm=t=>{const e=t.Eq0();return n=>r=>{const i=s=>{let a=s,c=!0,f;for(;c;){const d=a,l=Bt(_=>T,_=>h=>w("Just",{head:_,tail:h}),d.queue);if(l.tag==="Nothing"){c=!1,f=d;continue}if(l.tag==="Just"){const _=l._1.head;if((m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=!1;continue}if(N.tag==="Node"){const v=t.compare(_)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=!0;continue}}g()}return x})(d.removedNodes)){a={...d,queue:l._1.tail};continue}const h=Xt(m=>!Pn(m.eid)(d.removedEdges)&&(e.eq(m.src)(_)||e.eq(m.tgt)(_)))(r);if(h.tag==="Nothing"){a={...d,queue:l._1.tail};continue}if(h.tag==="Just"){const m=e.eq(h._1.src)(_)?h._1.tgt:h._1.src,p={...d,degree:K(t)(m)((()=>{const y=(x=>{let N=x,v=!0,L;for(;v;){const k=N;if(k.tag==="Leaf"){v=!1,L=T;continue}if(k.tag==="Node"){const E=t.compare(m)(k._3);if(E==="LT"){N=k._5;continue}if(E==="GT"){N=k._6;continue}if(E==="EQ"){v=!1,L=w("Just",k._4);continue}}g()}return L})(d.degree);if(y.tag==="Nothing")return-1;if(y.tag==="Just")return y._1-1|0;g()})())(d.degree),removedNodes:K(t)(_)()(d.removedNodes),removedEdges:K(it)(h._1.eid)()(d.removedEdges),record:[...d.record,{node:_,neighbour:m,viaSrc:e.eq(h._1.src)(_)}],queue:l._1.tail};if((()=>{const y=(N=>{let v=N,L=!0,k;for(;L;){const E=v;if(E.tag==="Leaf"){L=!1,k=T;continue}if(E.tag==="Node"){const Q=t.compare(m)(E._3);if(Q==="LT"){v=E._5;continue}if(Q==="GT"){v=E._6;continue}if(Q==="EQ"){L=!1,k=w("Just",E._4);continue}}g()}return k})(p.degree),x=N=>{let v=N,L=!0,k;for(;L;){const E=v;if(E.tag==="Leaf"){L=!1,k=!1;continue}if(E.tag==="Node"){const Q=t.compare(m)(E._3);if(Q==="LT"){v=E._5;continue}if(Q==="GT"){v=E._6;continue}if(Q==="EQ"){L=!1,k=!0;continue}}g()}return k};return(()=>{if(y.tag==="Nothing")return!1;if(y.tag==="Just")return y._1===1;g()})()&&!x(p.removedNodes)})()){a={...p,queue:[...p.queue,m]};continue}a=p;continue}}g()}return f},o=J(s=>a=>vt(t)(oe)(a.src)(1)(vt(t)(oe)(a.tgt)(1)(s)))(A)(r),u=i({degree:o,removedNodes:A,removedEdges:A,record:[],queue:at(s=>{const a=(c=>{let f=c,d=!0,l;for(;d;){const _=f;if(_.tag==="Leaf"){d=!1,l=T;continue}if(_.tag==="Node"){const h=t.compare(s)(_._3);if(h==="LT"){f=_._5;continue}if(h==="GT"){f=_._6;continue}if(h==="EQ"){d=!1,l=w("Just",_._4);continue}}g()}return l})(o);if(a.tag==="Nothing")return!1;if(a.tag==="Just")return a._1===1;g()},n)});return{coreNodes:at(s=>!(a=>{let c=a,f=!0,d;for(;f;){const l=c;if(l.tag==="Leaf"){f=!1,d=!1;continue}if(l.tag==="Node"){const _=t.compare(s)(l._3);if(_==="LT"){c=l._5;continue}if(_==="GT"){c=l._6;continue}if(_==="EQ"){f=!1,d=!0;continue}}g()}return d})(u.removedNodes),n),coreEdges:at(s=>!Pn(s.eid)(u.removedEdges),r),removed:u.record}}},lm=t=>e=>n=>J(r=>i=>{const o=i.neighbour,u=(()=>{const s=(a=>{let c=a,f=!0,d;for(;f;){const l=c;if(l.tag==="Leaf"){f=!1,d=T;continue}if(l.tag==="Node"){const _=t.compare(o)(l._3);if(_==="LT"){c=l._5;continue}if(_==="GT"){c=l._6;continue}if(_==="EQ"){f=!1,d=w("Just",l._4);continue}}g()}return d})(r);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})();return K(t)(i.node)(i.viaSrc?u-1|0:u+1|0)(r)})(n)(ke(e)),Cs=t=>{const e=t.Eq0();return n=>r=>i=>{const o={...i,treeNode:K(t)(r)()(i.treeNode)};return J(u=>s=>{if(Pn(s.eid)(u.st.edgeVisited))return u;const a={...u.st,edgeVisited:K(it)(s.eid)()(u.st.edgeVisited)},c=e.eq(s.src)((()=>{const f=s.src,d=_=>{let h=_,m=!0,p;for(;m;){const y=h;if(y.tag==="Leaf"){m=!1,p=!1;continue}if(y.tag==="Node"){const x=t.compare(f)(y._3);if(x==="LT"){h=y._5;continue}if(x==="GT"){h=y._6;continue}if(x==="EQ"){m=!1,p=!0;continue}}g()}return p},l=s.tgt;return d(a.treeNode)&&!(_=>{let h=_,m=!0,p;for(;m;){const y=h;if(y.tag==="Leaf"){m=!1,p=!1;continue}if(y.tag==="Node"){const x=t.compare(l)(y._3);if(x==="LT"){h=y._5;continue}if(x==="GT"){h=y._6;continue}if(x==="EQ"){m=!1,p=!0;continue}}g()}return p})(a.treeNode)})()?s.src:(()=>{const f=s.tgt,d=_=>{let h=_,m=!0,p;for(;m;){const y=h;if(y.tag==="Leaf"){m=!1,p=!1;continue}if(y.tag==="Node"){const x=t.compare(f)(y._3);if(x==="LT"){h=y._5;continue}if(x==="GT"){h=y._6;continue}if(x==="EQ"){m=!1,p=!0;continue}}g()}return p},l=s.src;return d(a.treeNode)&&!(_=>{let h=_,m=!0,p;for(;m;){const y=h;if(y.tag==="Leaf"){m=!1,p=!1;continue}if(y.tag==="Node"){const x=t.compare(l)(y._3);if(x==="LT"){h=y._5;continue}if(x==="GT"){h=y._6;continue}if(x==="EQ"){m=!1,p=!0;continue}}g()}return p})(a.treeNode)})()?s.tgt:s.src)?s.tgt:s.src;if(Pn(s.eid)(a.treeEdge)){if((d=>{let l=d,_=!0,h;for(;_;){const m=l;if(m.tag==="Leaf"){_=!1,h=!1;continue}if(m.tag==="Node"){const p=t.compare(c)(m._3);if(p==="LT"){l=m._5;continue}if(p==="GT"){l=m._6;continue}if(p==="EQ"){_=!1,h=!0;continue}}g()}return h})(a.treeNode))return{...u,st:a};const f=Cs(t)(n)(c)(a);return{count:u.count+f.count|0,st:f.st}}if((()=>{const f=l=>{let _=l,h=!0,m;for(;h;){const p=_;if(p.tag==="Leaf"){h=!1,m=!1;continue}if(p.tag==="Node"){const y=t.compare(c)(p._3);if(y==="LT"){_=p._5;continue}if(y==="GT"){_=p._6;continue}if(y==="EQ"){h=!1,m=!0;continue}}g()}return m},d=s.tgt;return!f(a.treeNode)&&(()=>{const l=(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=T;continue}if(N.tag==="Node"){const v=t.compare(d)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=w("Just",N._4);continue}}g()}return x})(a.layer),_=s.src,h=(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=T;continue}if(N.tag==="Node"){const v=t.compare(_)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=w("Just",N._4);continue}}g()}return x})(a.layer);if(l.tag==="Nothing"){if(h.tag==="Nothing")return s.delta===0;if(h.tag==="Just")return s.delta===-h._1;g()}if(l.tag==="Just"){if(h.tag==="Nothing")return s.delta===(l._1-0|0);if(h.tag==="Just")return s.delta===(l._1-h._1|0)}g()})()})()){const f=Cs(t)(n)(c)({...a,treeEdge:K(it)(s.eid)()(a.treeEdge)});return{count:u.count+f.count|0,st:f.st}}return{...u,st:a}})({count:1,st:o})(at(u=>(e.eq(u.src)(r)||e.eq(u.tgt)(r))&&!Pn(u.eid)(o.edgeVisited),n))}},Po=t=>e=>n=>r=>{const i=r.src,o=(l=>{let _=l,h=!0,m;for(;h;){const p=_;if(p.tag==="Leaf"){h=!1,m=T;continue}if(p.tag==="Node"){const y=t.compare(i)(p._3);if(y==="LT"){_=p._5;continue}if(y==="GT"){_=p._6;continue}if(y==="EQ"){h=!1,m=w("Just",p._4);continue}}g()}return m})(e.poID),u=(()=>{if(o.tag==="Nothing")return 0;if(o.tag==="Just")return o._1;g()})(),s=r.tgt,a=(l=>{let _=l,h=!0,m;for(;h;){const p=_;if(p.tag==="Leaf"){h=!1,m=T;continue}if(p.tag==="Node"){const y=t.compare(s)(p._3);if(y==="LT"){_=p._5;continue}if(y==="GT"){_=p._6;continue}if(y==="EQ"){h=!1,m=w("Just",p._4);continue}}g()}return m})(e.poID),c=(()=>{if(a.tag==="Nothing")return 0;if(a.tag==="Just")return a._1;g()})(),f=(l=>{let _=l,h=!0,m;for(;h;){const p=_;if(p.tag==="Leaf"){h=!1,m=T;continue}if(p.tag==="Node"){const y=t.compare(n)(p._3);if(y==="LT"){_=p._5;continue}if(y==="GT"){_=p._6;continue}if(y==="EQ"){h=!1,m=w("Just",p._4);continue}}g()}return m})(e.poID),d=(()=>{if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1;g()})();return(()=>{const l=r.src,_=(h=>{let m=h,p=!0,y;for(;p;){const x=m;if(x.tag==="Leaf"){p=!1,y=T;continue}if(x.tag==="Node"){const N=t.compare(l)(x._3);if(N==="LT"){m=x._5;continue}if(N==="GT"){m=x._6;continue}if(N==="EQ"){p=!1,y=w("Just",x._4);continue}}g()}return y})(e.lowestPoID);return(()=>{if(_.tag==="Nothing")return 0<=d;if(_.tag==="Just")return _._1<=d;g()})()&&(()=>{const h=r.tgt;return d<=u&&(()=>{const m=(p=>{let y=p,x=!0,N;for(;x;){const v=y;if(v.tag==="Leaf"){x=!1,N=T;continue}if(v.tag==="Node"){const L=t.compare(h)(v._3);if(L==="LT"){y=v._5;continue}if(L==="GT"){y=v._6;continue}if(L==="EQ"){x=!1,N=w("Just",v._4);continue}}g()}return N})(e.lowestPoID);return(()=>{if(m.tag==="Nothing")return 0<=d;if(m.tag==="Just")return m._1<=d;g()})()&&d<=c})()})()})()?u>=c:u<c},hm=t=>{const e=Kt(t)(zt);return n=>({layer:e(O(r=>b(r,0))(n)),treeNode:A,treeEdge:A,poID:A,lowestPoID:A,cutvalue:A,postOrder:1,edgeVisited:A})},pm=t=>e=>n=>J(r=>i=>{if((()=>{const f=i.src,d=h=>{let m=h,p=!0,y;for(;p;){const x=m;if(x.tag==="Leaf"){p=!1,y=!1;continue}if(x.tag==="Node"){const N=t.compare(f)(x._3);if(N==="LT"){m=x._5;continue}if(N==="GT"){m=x._6;continue}if(N==="EQ"){p=!1,y=!0;continue}}g()}return y},l=i.tgt,_=h=>{let m=h,p=!0,y;for(;p;){const x=m;if(x.tag==="Leaf"){p=!1,y=!1;continue}if(x.tag==="Node"){const N=t.compare(l)(x._3);if(N==="LT"){m=x._5;continue}if(N==="GT"){m=x._6;continue}if(N==="EQ"){p=!1,y=!0;continue}}g()}return y};return d(n.treeNode)===_(n.treeNode)})())return r;const o=i.tgt,u=(f=>{let d=f,l=!0,_;for(;l;){const h=d;if(h.tag==="Leaf"){l=!1,_=T;continue}if(h.tag==="Node"){const m=t.compare(o)(h._3);if(m==="LT"){d=h._5;continue}if(m==="GT"){d=h._6;continue}if(m==="EQ"){l=!1,_=w("Just",h._4);continue}}g()}return _})(n.layer),s=i.src,a=(f=>{let d=f,l=!0,_;for(;l;){const h=d;if(h.tag==="Leaf"){l=!1,_=T;continue}if(h.tag==="Node"){const m=t.compare(s)(h._3);if(m==="LT"){d=h._5;continue}if(m==="GT"){d=h._6;continue}if(m==="EQ"){l=!1,_=w("Just",h._4);continue}}g()}return _})(n.layer),c=(()=>{if(u.tag==="Nothing"){if(a.tag==="Nothing")return-i.delta;if(a.tag==="Just")return-a._1-i.delta|0;g()}if(u.tag==="Just"){if(a.tag==="Nothing")return(u._1-0|0)-i.delta|0;if(a.tag==="Just")return(u._1-a._1|0)-i.delta|0}g()})();return c<r.slack?{edge:w("Just",i),slack:c}:r})({edge:T,slack:1e9})(e).edge,mm=t=>{const e=Kt(t)(zt);return n=>r=>{const i=J(o=>u=>ks(o)((()=>{const s=(a=>{let c=a,f=!0,d;for(;f;){const l=c;if(l.tag==="Leaf"){f=!1,d=T;continue}if(l.tag==="Node"){const _=t.compare(u)(l._3);if(_==="LT"){c=l._5;continue}if(_==="GT"){c=l._6;continue}if(_==="EQ"){f=!1,d=w("Just",l._4);continue}}g()}return d})(r);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(1e9)(n);return e(O(o=>b(o,(()=>{const u=(s=>{let a=s,c=!0,f;for(;c;){const d=a;if(d.tag==="Leaf"){c=!1,f=T;continue}if(d.tag==="Node"){const l=t.compare(o)(d._3);if(l==="LT"){a=d._5;continue}if(l==="GT"){a=d._6;continue}if(l==="EQ"){c=!1,f=w("Just",d._4);continue}}g()}return f})(r);if(u.tag==="Nothing")return-i;if(u.tag==="Just")return u._1-i|0;g()})()))(n))}},Lg=t=>{const e=t.Eq0();return n=>r=>i=>{const o=J(s=>a=>{const c=Lg(t)(n)(e.eq(a.src)(r)?a.tgt:a.src)({...s.st,edgeVisited:K(it)(a.eid)()(s.st.edgeVisited)});return{lowest:ks(s.lowest)(c.lowest),st:c.st}})({lowest:1e9,st:i})(at(s=>Pn(s.eid)(i.treeEdge)&&(e.eq(s.src)(r)||e.eq(s.tgt)(r))&&!Pn(s.eid)(i.edgeVisited),n)),u=ks(o.lowest)(o.st.postOrder);return{lowest:u,st:{...o.st,poID:K(t)(r)(o.st.postOrder)(o.st.poID),lowestPoID:K(t)(r)(u)(o.st.lowestPoID),postOrder:o.st.postOrder+1|0}}}},kg=t=>{const e=Lg(t);return n=>r=>i=>0<n.length?e(r)(n[0])({...i,edgeVisited:A,postOrder:1,poID:A,lowestPoID:A}).st:i},ym=t=>{const e=t.Eq0();return n=>r=>i=>at(o=>Pn(o.eid)(r.treeEdge)&&(e.eq(o.src)(i)||e.eq(o.tgt)(i)),n)},xm=t=>e=>Xt(n=>{const r=Es(n.eid)(e.cutvalue);return Pn(n.eid)(e.treeEdge)&&(()=>{if(r.tag==="Nothing")return!1;if(r.tag==="Just")return r._1<-1e-10;g()})()})(t),Eg=t=>{const e=Cs(t);return n=>r=>i=>{const o=0<n.length?w("Just",n[0]):T;if(o.tag==="Nothing")return i;if(o.tag==="Just"){const u=e(r)(o._1)({...i,edgeVisited:A,treeNode:A,treeEdge:A});if(u.count>=n.length)return u.st;const s=pm(t)(r)(u.st);if(s.tag==="Nothing")return u.st;if(s.tag==="Just"){const a=s._1.tgt,c=(h=>{let m=h,p=!0,y;for(;p;){const x=m;if(x.tag==="Leaf"){p=!1,y=T;continue}if(x.tag==="Node"){const N=t.compare(a)(x._3);if(N==="LT"){m=x._5;continue}if(N==="GT"){m=x._6;continue}if(N==="EQ"){p=!1,y=w("Just",x._4);continue}}g()}return y})(u.st.layer),f=s._1.src,d=(h=>{let m=h,p=!0,y;for(;p;){const x=m;if(x.tag==="Leaf"){p=!1,y=T;continue}if(x.tag==="Node"){const N=t.compare(f)(x._3);if(N==="LT"){m=x._5;continue}if(N==="GT"){m=x._6;continue}if(N==="EQ"){p=!1,y=w("Just",x._4);continue}}g()}return y})(u.st.layer),l=(()=>{if(c.tag==="Nothing"){if(d.tag==="Nothing")return-s._1.delta;if(d.tag==="Just")return-d._1-s._1.delta|0;g()}if(c.tag==="Just"){if(d.tag==="Nothing")return(c._1-0|0)-s._1.delta|0;if(d.tag==="Just")return(c._1-d._1|0)-s._1.delta|0}g()})(),_=(()=>{const h=s._1.tgt;return(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=!1;continue}if(N.tag==="Node"){const v=t.compare(h)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=!0;continue}}g()}return x})(u.st.treeNode)})()?-l:l;return Eg(t)(n)(r)({...u.st,layer:J(h=>m=>(p=>{let y=p,x=!0,N;for(;x;){const v=y;if(v.tag==="Leaf"){x=!1,N=!1;continue}if(v.tag==="Node"){const L=t.compare(m)(v._3);if(L==="LT"){y=v._5;continue}if(L==="GT"){y=v._6;continue}if(L==="EQ"){x=!1,N=!0;continue}}g()}return N})(u.st.treeNode)?K(t)(m)((()=>{const p=(y=>{let x=y,N=!0,v;for(;N;){const L=x;if(L.tag==="Leaf"){N=!1,v=T;continue}if(L.tag==="Node"){const k=t.compare(m)(L._3);if(k==="LT"){x=L._5;continue}if(k==="GT"){x=L._6;continue}if(k==="EQ"){N=!1,v=w("Just",L._4);continue}}g()}return v})(u.st.layer);if(p.tag==="Nothing")return 0+_|0;if(p.tag==="Just")return p._1+_|0;g()})())(h):h)(u.st.layer)(n)})}}g()}},Nm=t=>e=>n=>r=>J(i=>o=>{if(Po(t)(r)(o.src)(n)&&!Po(t)(r)(o.tgt)(n)){const u=o.tgt,s=(d=>{let l=d,_=!0,h;for(;_;){const m=l;if(m.tag==="Leaf"){_=!1,h=T;continue}if(m.tag==="Node"){const p=t.compare(u)(m._3);if(p==="LT"){l=m._5;continue}if(p==="GT"){l=m._6;continue}if(p==="EQ"){_=!1,h=w("Just",m._4);continue}}g()}return h})(r.layer),a=o.src,c=(d=>{let l=d,_=!0,h;for(;_;){const m=l;if(m.tag==="Leaf"){_=!1,h=T;continue}if(m.tag==="Node"){const p=t.compare(a)(m._3);if(p==="LT"){l=m._5;continue}if(p==="GT"){l=m._6;continue}if(p==="EQ"){_=!1,h=w("Just",m._4);continue}}g()}return h})(r.layer),f=(()=>{if(s.tag==="Nothing"){if(c.tag==="Nothing")return-o.delta;if(c.tag==="Just")return-c._1-o.delta|0;g()}if(s.tag==="Just"){if(c.tag==="Nothing")return(s._1-0|0)-o.delta|0;if(c.tag==="Just")return(s._1-c._1|0)-o.delta|0}g()})();if(f<i.slack)return{edge:w("Just",o),slack:f}}return i})({edge:T,slack:1e9})(e).edge,Jm=t=>{const e=t.Eq0();return n=>r=>i=>o=>{const u=o.tgt,s=o.src;return J(a=>c=>{if((()=>{const f=Es(c.eid)(r.cutvalue);if(f.tag==="Just")return!0;if(f.tag==="Nothing")return!1;g()})()){const f=Es(c.eid)(r.cutvalue),d=(()=>{if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1;g()})();return e.eq(s)(c.src)||e.eq(u)(c.tgt)?a-(d-c.weight):a+(d-c.weight)}return e.eq(i)(s)?e.eq(c.src)(i)?a+c.weight:a-c.weight:e.eq(c.src)(i)?a-c.weight:a+c.weight})(o.weight)(at(a=>a.eid!==o.eid&&(e.eq(a.src)(i)||e.eq(a.tgt)(i)),n))}},Tm=t=>{const e=Jm(t);return n=>r=>i=>{const o=(u,s,a)=>{const c=(f=>{let d=f,l=!0,_;for(;l;){const h=d;if(h.tag==="Leaf"){l=!1,_=T;continue}if(h.tag==="Node"){const m=t.compare(u)(h._3);if(m==="LT"){d=h._5;continue}if(m==="GT"){d=h._6;continue}if(m==="EQ"){l=!1,_=w("Just",h._4);continue}}g()}return _})(a);if(c.tag==="Just")return K(t)(u)(at(f=>f.eid!==s.eid,c._1))(a);if(c.tag==="Nothing")return a;g()};return(u=>s=>{let a=u,c=s,f=!0,d;for(;f;){const l=a,_=c,h=(p=>{let y=p,x=!0,N;for(;x;){const v=y;if(v.tag==="Leaf"){x=!1,N=T;continue}if(v.tag==="Node"){const L=t.compare(_)(v._3);if(L==="LT"){y=v._5;continue}if(L==="GT"){y=v._6;continue}if(L==="EQ"){x=!1,N=w("Just",v._4);continue}}g()}return N})(l.unknown),m=(()=>{if(h.tag==="Nothing")return[];if(h.tag==="Just")return h._1;g()})();if(m.length===1){const p=t.Eq0().eq(m[0].src)(_)?m[0].tgt:m[0].src;a={unknown:o(_,m[0],o(p,m[0],l.unknown)),cutvalue:K(it)(m[0].eid)(e(n)(l)(_)(m[0]))(l.cutvalue)},c=p;continue}f=!1,d=l}return d})(r)(i)}},Cg=t=>{const e=t.Eq0(),n=t.Eq0(),r={eq:c=>f=>c.delta===f.delta&&c.eid===f.eid&&n.eq(c.src)(f.src)&&e.eq(c.tgt)(f.tgt)&&c.weight===f.weight},i={compare:c=>f=>{const d=it.compare(c.delta)(f.delta);if(d==="LT"||d==="GT"||d!=="EQ")return d;const l=it.compare(c.eid)(f.eid);if(l==="LT"||l==="GT"||l!=="EQ")return l;const _=t.compare(c.src)(f.src);if(_==="LT"||_==="GT"||_!=="EQ")return _;const h=t.compare(c.tgt)(f.tgt);if(h==="LT"||h==="GT"||h!=="EQ")return h;const m=st.compare(c.weight)(f.weight);return m==="LT"||m==="GT"||m!=="EQ"?m:Ge},Eq0:()=>r},o=J(c=>f=>K(i)(f)()(c))(A),u=ym(t),s=Kt(t)(zt),a=Tm(t);return c=>f=>d=>{const l={unknown:s(O(_=>b(_,kt(We.foldr,o(u(f)(d)(_)))))(c)),cutvalue:A};return{...d,cutvalue:J(a(f))(l)(at(_=>{const h=(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=T;continue}if(N.tag==="Node"){const v=t.compare(_)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=w("Just",N._4);continue}}g()}return x})(l.unknown);if(h.tag==="Nothing")return!1;if(h.tag==="Just")return h._1.length===1;g()},c)).cutvalue}}},vm=t=>{const e=kg(t),n=Cg(t);return r=>i=>o=>u=>s=>{const a={...s,treeEdge:K(it)(u.eid)()(ni(it)(o.eid)(s.treeEdge))},c=u.tgt,f=(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=T;continue}if(N.tag==="Node"){const v=t.compare(c)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=w("Just",N._4);continue}}g()}return x})(a.layer),d=u.src,l=(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=T;continue}if(N.tag==="Node"){const v=t.compare(d)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=w("Just",N._4);continue}}g()}return x})(a.layer),_=(()=>{if(f.tag==="Nothing"){if(l.tag==="Nothing")return-u.delta;if(l.tag==="Just")return-l._1-u.delta|0;g()}if(f.tag==="Just"){if(l.tag==="Nothing")return(f._1-0|0)-u.delta|0;if(l.tag==="Just")return(f._1-l._1|0)-u.delta|0}g()})(),h=Po(t)(a)(u.tgt)(o)?_:-_;return n(r)(i)(e(r)(i)({...a,layer:J(m=>p=>Po(t)(a)(p)(o)?m:K(t)(p)((()=>{const y=(x=>{let N=x,v=!0,L;for(;v;){const k=N;if(k.tag==="Leaf"){v=!1,L=T;continue}if(k.tag==="Node"){const E=t.compare(p)(k._3);if(E==="LT"){N=k._5;continue}if(E==="GT"){N=k._6;continue}if(E==="EQ"){v=!1,L=w("Just",k._4);continue}}g()}return L})(a.layer);if(y.tag==="Nothing")return 0+h|0;if(y.tag==="Just")return y._1+h|0;g()})())(m))(a.layer)(r)}))}},wm=t=>{const e=vm(t);return n=>r=>i=>o=>(u=>s=>{let a=u,c=s,f=!0,d;for(;f;){const l=a,_=c;if(l===0){f=!1,d=_;continue}const h=xm(i)(_);if(h.tag==="Nothing"){f=!1,d=_;continue}if(h.tag==="Just"){const m=Nm(t)(i)(h._1)(_);if(m.tag==="Nothing"){f=!1,d=_;continue}if(m.tag==="Just"){a=l-1|0,c=e(r)(i)(h._1)(m._1)(_);continue}}g()}return d})(n)(o)},bm=t=>{const e=Cg(t),n=kg(t),r=Eg(t);return i=>o=>u=>e(i)(o)(n(i)(o)(r(i)(o)(u)))},Sg=t=>e=>J(n=>r=>vt(t)(te)(e(r))([r])(n))(A),Lm=t=>{const e=Kt(t)(zt);return n=>r=>i=>{const o=a=>c=>f=>d=>{let l=a,_=c,h=f,m=d,p=!0,y;for(;p;){const x=l,N=_,v=h,L=m,k=Bt(E=>T,E=>Q=>w("Just",{head:E,tail:Q}),v);if(k.tag==="Nothing"){p=!1,y=L;continue}if(k.tag==="Just"){const E=k._1.head,Q=(S=>{let C=S,U=!0,Y;for(;U;){const W=C;if(W.tag==="Leaf"){U=!1,Y=T;continue}if(W.tag==="Node"){const z=t.compare(E)(W._3);if(z==="LT"){C=W._5;continue}if(z==="GT"){C=W._6;continue}if(z==="EQ"){U=!1,Y=w("Just",W._4);continue}}g()}return Y})(L.layer),H=(()=>{if(Q.tag==="Nothing")return 0;if(Q.tag==="Just")return Q._1;g()})(),j=J(S=>C=>{const U=C.tgt,Y=(z=>{let R=z,G=!0,I;for(;G;){const D=R;if(D.tag==="Leaf"){G=!1,I=T;continue}if(D.tag==="Node"){const B=t.compare(U)(D._3);if(B==="LT"){R=D._5;continue}if(B==="GT"){R=D._6;continue}if(B==="EQ"){G=!1,I=w("Just",D._4);continue}}g()}return I})(S.incident),W=(()=>{if(Y.tag==="Nothing")return-1;if(Y.tag==="Just")return Y._1-1|0;g()})();return{st:{...S.st,layer:K(t)(C.tgt)(_m((()=>{const z=C.tgt,R=(G=>{let I=G,D=!0,B;for(;D;){const q=I;if(q.tag==="Leaf"){D=!1,B=T;continue}if(q.tag==="Node"){const V=t.compare(z)(q._3);if(V==="LT"){I=q._5;continue}if(V==="GT"){I=q._6;continue}if(V==="EQ"){D=!1,B=w("Just",q._4);continue}}g()}return B})(S.st.layer);if(R.tag==="Nothing")return 0;if(R.tag==="Just")return R._1;g()})())(H+C.delta|0))(S.st.layer)},incident:K(t)(C.tgt)(W)(S.incident),queue:W===0?[...S.queue,C.tgt]:S.queue}})({st:L,incident:N,queue:k._1.tail})((()=>{const S=(C=>{let U=C,Y=!0,W;for(;Y;){const z=U;if(z.tag==="Leaf"){Y=!1,W=T;continue}if(z.tag==="Node"){const R=t.compare(E)(z._3);if(R==="LT"){U=z._5;continue}if(R==="GT"){U=z._6;continue}if(R==="EQ"){Y=!1,W=w("Just",z._4);continue}}g()}return W})(x);if(S.tag==="Nothing")return[];if(S.tag==="Just")return S._1;g()})());l=x,_=j.incident,h=j.queue,m=j.st;continue}g()}return y},u=Sg(t)(a=>a.tgt)(r),s=e(O(a=>b(a,(()=>{const c=(f=>{let d=f,l=!0,_;for(;l;){const h=d;if(h.tag==="Leaf"){l=!1,_=T;continue}if(h.tag==="Node"){const m=t.compare(a)(h._3);if(m==="LT"){d=h._5;continue}if(m==="GT"){d=h._6;continue}if(m==="EQ"){l=!1,_=w("Just",h._4);continue}}g()}return _})(u);if(c.tag==="Nothing")return 0;if(c.tag==="Just")return c._1.length;g()})()))(n));return o(Sg(t)(a=>a.src)(r))(s)(at(a=>{const c=(f=>{let d=f,l=!0,_;for(;l;){const h=d;if(h.tag==="Leaf"){l=!1,_=T;continue}if(h.tag==="Node"){const m=t.compare(a)(h._3);if(m==="LT"){d=h._5;continue}if(m==="GT"){d=h._6;continue}if(m==="EQ"){l=!1,_=w("Just",h._4);continue}}g()}return _})(s);if(c.tag==="Nothing")return!0;if(c.tag==="Just")return c._1===0;g()},n))(i)}},km=t=>{const e=hm(t),n=Lm(t),r=bm(t),i=wm(t);return o=>u=>{const s=n(o)(u)(e(o));return u.length===0?s.layer:i(4*o.length|0)(o)(u)(r(o)(u)(s)).layer}},Gg=t=>{const e=mm(t),n=km(t),r=dm(t);return i=>o=>{if(i.length===0)return A;if(i.length<40)return e(i)(n(i)(o));const u=r(i)(o);return e(i)(lm(t)(u.removed)(n(u.coreNodes)(u.coreEdges)))}},Pg=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Ss=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Em=Gg(it),wi=t=>e=>({...e,edges:[...e.edges,{src:t.src,tgt:t.tgt,delta:t.delta,weight:t.weight,eid:e.nextEid}],nextEid:e.nextEid+1|0}),Cm=t=>e=>n=>{if(n.cGroup.tag==="Nothing")return e;if(n.cGroup.tag==="Just"){const r=rt((()=>{const i=Pg(n.cGroup._1)(t);if(i.tag==="Nothing")return 0;if(i.tag==="Just")return i._1;g()})());return Xe(n.id)(i=>({...i,hitbox:{...i.hitbox,x:r+i.cGroupOffset.x}}))(e)}g()},Sm=t=>e=>({...e,cGraph:J(Cm(t))(e.cGraph)((()=>{const n=e.cGraph;return xt(r=>jt(r)(n.cNodes))(n.cNodeOrder)})())}),Gm=t=>e=>n=>r=>i=>{const o=de(Vi(e.cGroupOffset.x-t.cGroupOffset.x));return wi({src:i.nextNodeId,tgt:r,delta:Ss(0)(-o),weight:1})(wi({src:i.nextNodeId,tgt:n,delta:Ss(0)(o),weight:1})({...i,nodes:[...i.nodes,i.nextNodeId],nextNodeId:i.nextNodeId+1|0}))},Pm=t=>e=>n=>r=>i=>o=>u=>{const s=Ss(0)(de(Vi(n.cGroupOffset.x+n.hitbox.width+(e.direction==="LEFT"||e.direction==="RIGHT"?e.spacingsHandler.horizontalSpacing(n)(r):e.spacingsHandler.verticalSpacing(n)(r))-r.cGroupOffset.x)));return t.sameEdgeVerticalSegments(n)(r)?Gm(n)(r)(i)(o)(u):wi({src:i,tgt:o,delta:s,weight:t.vsLNodePair(n)(r)?2:1})(u)},Im=t=>e=>n=>r=>i=>{const o=jt(i)(e.cGraph.cNodes);if(o.tag==="Nothing")return r;if(o.tag==="Just")return(n.cGroup.tag==="Nothing"?o._1.cGroup.tag==="Nothing":n.cGroup.tag==="Just"&&o._1.cGroup.tag==="Just"&&n.cGroup._1===o._1.cGroup._1)?r:n.cGroup.tag==="Just"&&o._1.cGroup.tag==="Just"?Pm(t)(e)(n)(o._1)(n.cGroup._1)(o._1.cGroup._1)(r):r;g()},Dm=t=>e=>n=>r=>J(Im(t)(e)(r))(n)(r.constraints),Am=t=>e=>wi({src:e.srcGroup,tgt:e.tgtGroup,delta:e.delta,weight:e.weight})(t),Bm=t=>{const e=J(i=>o=>vt(it)(oe)(o.tgt)(1)(i))(A)(t.edges),n=at(i=>{const o=Pg(i)(e);if(o.tag==="Nothing")return!0;if(o.tag==="Just")return o._1===0;g()},t.nodes);if(n.length<=1)return t;const r=t.nextNodeId;return J(i=>o=>wi({src:r,tgt:o,delta:1,weight:0})(i))({...t,nodes:[...t.nodes,r],nextNodeId:r+1|0})(n)},Fm=t=>e=>{const n=Bm(J(Am)(J(Dm(t)(e))({nodes:e.cGraph.cGroupOrder,edges:[],nextNodeId:e.cGraph.nextCGroupId,nextEid:0})((()=>{const r=e.cGraph;return xt(i=>jt(i)(r.cNodes))(r.cNodeOrder)})()))(t.edgeLengthEdges(e.cGraph)));return{nodes:n.nodes,edges:n.edges}},Rm=t=>e=>{const n=Fm(t)(e);return Sm(Em(n.nodes)(n.edges))(e)},Ig=t=>t,ee=Ig("H"),ne=Ig("V"),Qm=t=>b(t._2,t._1),Dg=t=>({...t,position:b(t.position._2,t.position._1),size:b(t.size._2,t.size._1)}),zm=t=>({start:b(t.start._2,t.start._1),end:b(t.end._2,t.end._1),direction:(()=>{if(t.direction==="H")return ne;if(t.direction==="V")return ee;g()})()}),Ag=t=>({...t,segments:O(zm)(t.segments),bends:O(Qm)(t.bends)}),Wm=t=>({nodes:O(Dg)(t.nodes),edges:t.edges,paths:O(Ag)(t.paths),ports:t.ports}),Mm=t=>({horizontalSpacing:e=>n=>{if(t.sameEdgeVerticalSegments(e)(n)||e.ignoreSpacing.right||n.ignoreSpacing.left)return 0;const r=n.kind.tag==="Nothing"?!1:n.kind.tag==="Just"&&n.kind._1==="vs";return e.kind.tag!=="Nothing"&&e.kind.tag==="Just"&&e.kind._1==="vs"?r?10:4:r?4:8},verticalSpacing:e=>n=>{if(t.sameEdgeVerticalSegments(e)(n))return 1;if(e.hitbox.y<=n.hitbox.y?e.ignoreSpacing.down||n.ignoreSpacing.up:e.ignoreSpacing.up||n.ignoreSpacing.down)return 0;const r=n.kind.tag==="Nothing"?!1:n.kind.tag==="Just"&&n.kind._1==="vs";return e.kind.tag!=="Nothing"&&e.kind.tag==="Just"&&e.kind._1==="vs"?r?10:4:r?4:8}}),Hm=t=>e=>Rm(e),Om=t=>e=>{const n=Wm(e),r=fm(n),i=um(r)(wg(n)),o=sm(cg(Ns)(Cp({...Gp(r.cGraph),compactionAlgorithm:w("Just",Hm()(i)),constraintAlgorithm:w("Just",Op),spacingsHandler:Mm(i)})).cGraph)({nodes:n.nodes,edges:n.edges,paths:n.paths});return{nodes:O(Dg)(o.nodes),edges:O(Ag)(o.edges)}},Bg=t=>t,Ar=Kt(it)(zt),Pt=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Fg=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},dt=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},ht=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Br=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},qm=t=>e=>{const n=it.compare(t._1)(e._1);return n==="LT"?ye:n==="GT"?xe:it.compare(t._2)(e._2)},Fr=t=>e=>{const n=it.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},$m=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),Ym=t=>t,Rg=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Xm=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Io=Bg("Regular"),Do=Bg("Critical"),Qg=t=>e=>{const n=J(u=>s=>K(P)(s.node)(s)(u))(A)(e),r=1.25*rt(4),i=(u,s,a)=>(c=>f=>d=>{let l=c,_=f,h=d,m=!0,p;for(;m;){const y=l,x=_,N=h;if(N.critical){m=!1,p=N;continue}const v=Bt(k=>T,k=>E=>w("Just",{head:k,tail:E}),y),L=Bt(k=>T,k=>E=>w("Just",{head:k,tail:E}),x);if(v.tag==="Just"&&L.tag==="Just"){const k=v._1.head>L._1.head-u&&v._1.head<L._1.head+u?{...N,critical:!0}:v._1.head>L._1.head-r&&v._1.head<L._1.head+r?{...N,conflicts:N.conflicts+1|0}:N;if(k.critical){m=!1,p=k;continue}if(v._1.head<=L._1.head){l=v._1.tail,_=x,h=k;continue}l=y,_=L._1.tail,h=k;continue}m=!1,p=N}return p})(s)(a)({conflicts:0,critical:!1}),o=(u,s,a)=>{if(ht(J(ht)(-1e18)(s.incoming))(J(ht)(-1e18)(s.outgoing))-dt(J(dt)(1e18)(s.incoming))(J(dt)(1e18)(s.outgoing))<.001||ht(J(ht)(-1e18)(a.incoming))(J(ht)(-1e18)(a.outgoing))-dt(J(dt)(1e18)(a.incoming))(J(dt)(1e18)(a.outgoing))<.001)return[];const c=i(u,s.outgoing,a.incoming),f=i(u,a.outgoing,s.incoming);if(c.critical||f.critical)return[...c.critical?[{src:a.id,tgt:s.id,weight:1,kind:Do}]:[],...f.critical?[{src:s.id,tgt:a.id,weight:1,kind:Do}]:[]];const d=dt(J(dt)(1e18)(s.incoming))(J(dt)(1e18)(s.outgoing)),l=ht(J(ht)(-1e18)(s.incoming))(J(ht)(-1e18)(s.outgoing)),_=dt(J(dt)(1e18)(a.incoming))(J(dt)(1e18)(a.outgoing)),h=ht(J(ht)(-1e18)(a.incoming))(J(ht)(-1e18)(a.outgoing)),m=(1*c.conflicts|0)+(16*(J(y=>x=>x>h?y:x>=_?y+1|0:y)(0)(s.outgoing)+J(y=>x=>x>l?y:x>=d?y+1|0:y)(0)(a.incoming)|0)|0)|0,p=(1*f.conflicts|0)+(16*(J(y=>x=>x>l?y:x>=d?y+1|0:y)(0)(a.outgoing)+J(y=>x=>x>h?y:x>=_?y+1|0:y)(0)(s.incoming)|0)|0)|0;return m<p?[{src:s.id,tgt:a.id,weight:p-m|0,kind:Io}]:m>p?[{src:a.id,tgt:s.id,weight:m-p|0,kind:Io}]:m>0?[{src:s.id,tgt:a.id,weight:0,kind:Io},{src:a.id,tgt:s.id,weight:0,kind:Io}]:[]};return J(u=>s=>J(a=>c=>K(P)(c._1)(c._2)(a))(u)((()=>{const a=J(S=>C=>{const U=C.edge.from.node+"|"+(()=>{if(C.edge.from.port.tag==="Just")return C.edge.from.port._1;if(C.edge.from.port.tag==="Nothing")return"_auto_"+C.edge.id;g()})(),Y=Rg(U)(S.entries);if(Y.tag==="Nothing")return{...S,entries:K(P)(U)({id:0,members:[C.edge.id],incoming:[C.fromPos._1],outgoing:[C.toPos._1],slot:0,mark:0,splitBy:T,splitPartner:T})(S.entries),order:[...S.order,U]};if(Y.tag==="Just")return{...S,entries:K(P)(U)({...Y._1,members:[...Y._1.members,C.edge.id],incoming:[...or(W=>W<C.fromPos._1)(Y._1.incoming).init,C.fromPos._1,...or(W=>W<=C.fromPos._1)(Y._1.incoming).rest],outgoing:[...or(W=>W<C.toPos._1)(Y._1.outgoing).init,C.toPos._1,...or(W=>W<=C.toPos._1)(Y._1.outgoing).rest]})(S.entries)};g()})({entries:A,order:[]})(s._2),c=At(S=>C=>({...C,id:S}))(xt(S=>Rg(S)(a.entries))(a.order));if(c.length===0)return[];const f=J(S=>C=>S.prev.tag==="Just"&&C-S.prev._1<1e-9?S:{prev:w("Just",C),out:[...S.out,C]})({prev:T,out:[]})(Lt(st.compare)([...Tt(c)(S=>S.incoming),...Tt(c)(S=>S.outgoing)])).out,d=f.length<2?.2*r:.2*J(S=>C=>{if(S.prev.tag==="Nothing")return{prev:w("Just",C),mn:S.mn};if(S.prev.tag==="Just")return{prev:w("Just",C),mn:dt(S.mn)(C-S.prev._1)};g()})({prev:T,mn:1e18})(f).mn,l={segments:c,deps:(()=>{const S=c.length;return Tt(Tt(Dt(0,S-2|0))(C=>Tt(Dt(C+1|0,S-1|0))(U=>[b(C,U)])))(C=>C._1>=0&&C._1<c.length?C._2>=0&&C._2<c.length?o(d,c[C._1],c[C._2]):[]:[])})()},_=at(S=>{if(S.kind==="Critical")return!0;if(S.kind==="Regular")return!1;g()},l.deps),h=(()=>{if(_.length<2)return l;const S=Ar((()=>{const z=l.segments;return O(R=>b(R.id,R.mark))((()=>{const R=z.length,G=D=>{let B=D,q=!0,V;for(;q;){const $=B,X=Xt(M=>{const et=Pt(M)($.inWeight);if(et.tag==="Nothing")return!0;if(et.tag==="Just")return et._1===0;g()})($.remaining);if(X.tag==="Nothing"){q=!1,V=$;continue}if(X.tag==="Just"){const M=X._1;B={...$,inWeight:J(et=>tt=>vt(it)(oe)(tt.tgt)(-tt.weight)(et))($.inWeight)((()=>{const et=Pt(M)($.depsBySrc);if(et.tag==="Nothing")return[];if(et.tag==="Just")return et._1;g()})()),marks:K(it)(M)($.nextSource)($.marks),nextSource:$.nextSource+1|0,outWeight:J(et=>tt=>vt(it)(oe)(tt.src)(-tt.weight)(et))($.outWeight)((()=>{const et=Pt(M)($.depsByTgt);if(et.tag==="Nothing")return[];if(et.tag==="Just")return et._1;g()})()),remaining:at(et=>et!==M,$.remaining)};continue}g()}return V},I=D=>{let B=D,q=!0,V;for(;q;){const $=B,X=Xt(M=>{const et=Pt(M)($.outWeight);if(et.tag==="Nothing")return!0;if(et.tag==="Just")return et._1===0;g()})($.remaining);if(X.tag==="Nothing"){q=!1,V=$;continue}if(X.tag==="Just"){const M=X._1;B={...$,inWeight:J(et=>tt=>vt(it)(oe)(tt.tgt)(-tt.weight)(et))($.inWeight)((()=>{const et=Pt(M)($.depsBySrc);if(et.tag==="Nothing")return[];if(et.tag==="Just")return et._1;g()})()),marks:K(it)(M)($.nextSink)($.marks),nextSink:$.nextSink-1|0,outWeight:J(et=>tt=>vt(it)(oe)(tt.src)(-tt.weight)(et))($.outWeight)((()=>{const et=Pt(M)($.depsByTgt);if(et.tag==="Nothing")return[];if(et.tag==="Just")return et._1;g()})()),remaining:at(et=>et!==M,$.remaining)};continue}g()}return V};return(D=>{let B=D,q=!0,V;for(;q;){const $=G(I(B));if($.remaining.length===0){q=!1,V=O(X=>{const M=Pt(X.id)($.marks),et=(()=>{if(M.tag==="Nothing")return X.id;if(M.tag==="Just")return M._1;g()})();return{...X,mark:et<R?(et+R|0)+1|0:et}})(z);continue}B=(()=>{const X=et=>{const tt=Pt(et)($.outWeight),gt=Pt(et)($.inWeight);return(()=>{if(tt.tag==="Nothing")return 0;if(tt.tag==="Just")return tt._1;g()})()-(()=>{if(gt.tag==="Nothing")return 0;if(gt.tag==="Just")return gt._1;g()})()|0},M=Lt(et=>tt=>it.compare(X(tt))(X(et)))($.remaining);if(0<M.length){const et=M[0];return{...$,inWeight:J(tt=>gt=>vt(it)(oe)(gt.tgt)(-gt.weight)(tt))($.inWeight)((()=>{const tt=Pt(et)($.depsBySrc);if(tt.tag==="Nothing")return[];if(tt.tag==="Just")return tt._1;g()})()),marks:K(it)(et)($.nextSource)($.marks),nextSource:$.nextSource+1|0,outWeight:J(tt=>gt=>vt(it)(oe)(gt.src)(-gt.weight)(tt))($.outWeight)((()=>{const tt=Pt(et)($.depsByTgt);if(tt.tag==="Nothing")return[];if(tt.tag==="Just")return tt._1;g()})()),remaining:at(tt=>tt!==et,$.remaining)}}return $})()}return V})({remaining:O(D=>D.id)(z),marks:A,inWeight:J(D=>B=>vt(it)(oe)(B.tgt)(B.weight)(D))(A)(_),outWeight:J(D=>B=>vt(it)(oe)(B.src)(B.weight)(D))(A)(_),depsBySrc:J(D=>B=>vt(it)(te)(B.src)([B])(D))(A)(_),depsByTgt:J(D=>B=>vt(it)(te)(B.tgt)([B])(D))(A)(_),nextSink:R-1|0,nextSource:R+1|0})})())})()),C=at(z=>{const R=Pt(z.src)(S),G=Pt(z.tgt)(S);return(()=>{if(R.tag==="Nothing")return 0;if(R.tag==="Just")return R._1;g()})()>(()=>{if(G.tag==="Nothing")return 0;if(G.tag==="Just")return G._1;g()})()},_);if(C.length===0)return l;const U=J(z=>R=>{if(Qe(xr)(R.src)(z.decisions)||Qe(xr)(R.tgt)(z.decisions))return z;const G=Pt(R.src)(z.segMap),I=Pt(R.tgt)(z.segMap);if(G.tag==="Just"&&I.tag==="Just"){const D=(G._1.incoming.length+G._1.outgoing.length|0)>2&&(I._1.incoming.length+I._1.outgoing.length|0)<=2,B=D?I._1:G._1;return{decisions:[...z.decisions,B.id],segMap:K(it)(B.id)({...B,splitBy:w("Just",D?G._1.id:I._1.id)})(z.segMap)}}return z})({decisions:[],segMap:Ar(O(z=>b(z.id,z))(l.segments))})(C),Y=U.segMap,W=J(z=>R=>{const G=dt(J(dt)(1e18)(R.incoming))(J(dt)(1e18)(R.outgoing)),I=ht(J(ht)(-1e18)(R.incoming))(J(ht)(-1e18)(R.outgoing)),D=at(X=>X.a.startPosition<=I&&X.a.endPosition>=G,At(X=>M=>({i:X,a:M}))(z.freeAreas));if(D.length===0){const X={...R,incoming:Lt(st.compare)(R.incoming),outgoing:Lt(st.compare)([(G+I)/2]),splitPartner:w("Just",z.nextId)},M={id:z.nextId,incoming:Lt(st.compare)([(G+I)/2]),mark:0,members:R.members,outgoing:Lt(st.compare)(R.outgoing),slot:0,splitBy:T,splitPartner:w("Just",R.id)};return{segMap:K(it)(M.id)(M)(K(it)(X.id)(X)(z.segMap)),freeAreas:z.freeAreas,nextId:z.nextId+1|0}}const B=0<D.length?w("Just",D[0]):T,q=(()=>{if(B.tag==="Nothing")return{i:0,a:{startPosition:0,endPosition:0,size:0}};if(B.tag==="Just"){if(D.length===1)return B._1;const X=O(M=>({c:M,rating:(()=>{const et=(M.a.startPosition+M.a.endPosition)/2,tt=[et],gt=[et],_t=J((()=>{const yt=z.segMap;return Et=>Rt=>{const pt=Pt(Rt.tgt)(yt);if(pt.tag==="Nothing")return Et;if(pt.tag==="Just"){const Qt=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),Jt=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),mt=dt(J(dt)(1e18)(R.incoming))(J(dt)(1e18)(tt)),nt=(()=>{const St=ht(J(ht)(-1e18)(R.incoming))(J(ht)(-1e18)(tt)),It=J(Ut=>_e=>_e>Jt?Ut:_e>=Qt?Ut+1|0:Ut)(0)(tt)+J(Ut=>_e=>_e>St?Ut:_e>=mt?Ut+1|0:Ut)(0)(pt._1.incoming)|0,je=dt(J(dt)(1e18)(R.incoming))(J(dt)(1e18)(tt)),Ze=ht(J(ht)(-1e18)(R.incoming))(J(ht)(-1e18)(tt)),kn=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),jr=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),_n=J(Ut=>_e=>_e>Ze?Ut:_e>=je?Ut+1|0:Ut)(0)(pt._1.outgoing)+J(Ut=>_e=>_e>jr?Ut:_e>=kn?Ut+1|0:Ut)(0)(R.incoming)|0;return It===_n?It>0?{...Et,deps:Et.deps+2|0,crossings:Et.crossings+It|0}:Et:{...Et,deps:Et.deps+1|0,crossings:Et.crossings+Fr(It)(_n)|0}})(),Z=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),ut=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),ft=dt(J(dt)(1e18)(gt))(J(dt)(1e18)(R.outgoing)),lt=ht(J(ht)(-1e18)(gt))(J(ht)(-1e18)(R.outgoing)),Nt=J(St=>It=>It>ut?St:It>=Z?St+1|0:St)(0)(R.outgoing)+J(St=>It=>It>lt?St:It>=ft?St+1|0:St)(0)(pt._1.incoming)|0,Ht=dt(J(dt)(1e18)(gt))(J(dt)(1e18)(R.outgoing)),Vt=ht(J(ht)(-1e18)(gt))(J(ht)(-1e18)(R.outgoing)),Pe=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),un=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),Ne=J(St=>It=>It>Vt?St:It>=Ht?St+1|0:St)(0)(pt._1.outgoing)+J(St=>It=>It>un?St:It>=Pe?St+1|0:St)(0)(gt)|0;return Nt===Ne?Nt>0?{...nt,deps:nt.deps+2|0,crossings:nt.crossings+Nt|0}:nt:{...nt,deps:nt.deps+1|0,crossings:nt.crossings+Fr(Nt)(Ne)|0}}g()}})())(J((()=>{const yt=z.segMap;return Et=>Rt=>{const pt=Pt(Rt.src)(yt);if(pt.tag==="Nothing")return Et;if(pt.tag==="Just"){const Qt=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),Jt=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),mt=dt(J(dt)(1e18)(R.incoming))(J(dt)(1e18)(tt)),nt=(()=>{const St=ht(J(ht)(-1e18)(R.incoming))(J(ht)(-1e18)(tt)),It=J(Ut=>_e=>_e>Jt?Ut:_e>=Qt?Ut+1|0:Ut)(0)(tt)+J(Ut=>_e=>_e>St?Ut:_e>=mt?Ut+1|0:Ut)(0)(pt._1.incoming)|0,je=dt(J(dt)(1e18)(R.incoming))(J(dt)(1e18)(tt)),Ze=ht(J(ht)(-1e18)(R.incoming))(J(ht)(-1e18)(tt)),kn=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),jr=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),_n=J(Ut=>_e=>_e>Ze?Ut:_e>=je?Ut+1|0:Ut)(0)(pt._1.outgoing)+J(Ut=>_e=>_e>jr?Ut:_e>=kn?Ut+1|0:Ut)(0)(R.incoming)|0;return It===_n?It>0?{...Et,deps:Et.deps+2|0,crossings:Et.crossings+It|0}:Et:{...Et,deps:Et.deps+1|0,crossings:Et.crossings+Fr(It)(_n)|0}})(),Z=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),ut=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),ft=dt(J(dt)(1e18)(gt))(J(dt)(1e18)(R.outgoing)),lt=ht(J(ht)(-1e18)(gt))(J(ht)(-1e18)(R.outgoing)),Nt=J(St=>It=>It>ut?St:It>=Z?St+1|0:St)(0)(R.outgoing)+J(St=>It=>It>lt?St:It>=ft?St+1|0:St)(0)(pt._1.incoming)|0,Ht=dt(J(dt)(1e18)(gt))(J(dt)(1e18)(R.outgoing)),Vt=ht(J(ht)(-1e18)(gt))(J(ht)(-1e18)(R.outgoing)),Pe=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),un=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),Ne=J(St=>It=>It>Vt?St:It>=Ht?St+1|0:St)(0)(pt._1.outgoing)+J(St=>It=>It>un?St:It>=Pe?St+1|0:St)(0)(gt)|0;return Nt===Ne?Nt>0?{...nt,deps:nt.deps+2|0,crossings:nt.crossings+Nt|0}:nt:{...nt,deps:nt.deps+1|0,crossings:nt.crossings+Fr(Nt)(Ne)|0}}g()}})())({crossings:0,deps:0})(at(yt=>yt.tgt===R.id,l.deps)))(at(yt=>yt.src===R.id,l.deps)),ct=(()=>{if(R.splitBy.tag==="Just")return Pt(R.splitBy._1)(z.segMap);if(R.splitBy.tag==="Nothing")return T;g()})();if(ct.tag==="Just")return{..._t,deps:_t.deps+2|0,crossings:(()=>{const yt=dt(J(dt)(1e18)(ct._1.incoming))(J(dt)(1e18)(ct._1.outgoing)),Et=dt(J(dt)(1e18)(gt))(J(dt)(1e18)(R.outgoing)),Rt=ht(J(ht)(-1e18)(ct._1.incoming))(J(ht)(-1e18)(ct._1.outgoing)),pt=ht(J(ht)(-1e18)(gt))(J(ht)(-1e18)(R.outgoing)),Qt=dt(J(dt)(1e18)(R.incoming))(J(dt)(1e18)(tt));return _t.crossings+(()=>{const Jt=dt(J(dt)(1e18)(ct._1.incoming))(J(dt)(1e18)(ct._1.outgoing)),mt=ht(J(ht)(-1e18)(R.incoming))(J(ht)(-1e18)(tt)),nt=ht(J(ht)(-1e18)(ct._1.incoming))(J(ht)(-1e18)(ct._1.outgoing));return((J(Z=>ut=>ut>Rt?Z:ut>=yt?Z+1|0:Z)(0)(tt)+J(Z=>ut=>ut>mt?Z:ut>=Qt?Z+1|0:Z)(0)(ct._1.incoming)|0)+J(Z=>ut=>ut>pt?Z:ut>=Et?Z+1|0:Z)(0)(ct._1.outgoing)|0)+J(Z=>ut=>ut>nt?Z:ut>=Jt?Z+1|0:Z)(0)(gt)|0})()|0})()};if(ct.tag==="Nothing")return _t;g()})()}))(D);return J(M=>et=>et.rating.crossings<M.rating.crossings||!(et.rating.crossings>M.rating.crossings)&&(et.rating.deps<M.rating.deps||!(et.rating.deps>M.rating.deps)&&et.c.a.size>M.c.a.size)?et:M)(0<X.length?X[0]:{c:B._1,rating:{crossings:1e6,deps:1e6}})(X).c}g()})(),V={...R,incoming:Lt(st.compare)(R.incoming),outgoing:Lt(st.compare)([(q.a.startPosition+q.a.endPosition)/2]),splitPartner:w("Just",z.nextId)},$={id:z.nextId,incoming:Lt(st.compare)([(q.a.startPosition+q.a.endPosition)/2]),mark:0,members:R.members,outgoing:Lt(st.compare)(R.outgoing),slot:0,splitBy:T,splitPartner:w("Just",R.id)};return{segMap:K(it)($.id)($)(K(it)(V.id)(V)(z.segMap)),freeAreas:(()=>{if(q.i>=0&&q.i<z.freeAreas.length){const X=za(Yt,T,q.i,z.freeAreas),M=(()=>{if(X.tag==="Nothing")return z.freeAreas;if(X.tag==="Just")return X._1;g()})();if(z.freeAreas[q.i].size/2<d)return M;const et=(z.freeAreas[q.i].startPosition+z.freeAreas[q.i].endPosition)/2,tt=et-d,gt=et+d;return[...q.i<1?[]:bt(0,q.i,M),...z.freeAreas[q.i].startPosition<=tt?[{startPosition:z.freeAreas[q.i].startPosition,endPosition:tt,size:tt-z.freeAreas[q.i].startPosition}]:[],...gt<=z.freeAreas[q.i].endPosition?[{startPosition:gt,endPosition:z.freeAreas[q.i].endPosition,size:z.freeAreas[q.i].endPosition-gt}]:[],...q.i<1?M:bt(q.i,M.length,M)]}return z.freeAreas})(),nextId:z.nextId+1|0}})({segMap:Y,freeAreas:(()=>{const z=Lt(st.compare)([...Tt(l.segments)(R=>R.incoming),...Tt(l.segments)(R=>R.outgoing)]);return xt(Ym)(Je(R=>G=>G-R>=2*d?w("Just",{startPosition:R+d,endPosition:G-d,size:G-R-2*d}):T,z,bt(1,z.length,z)))})(),nextId:l.segments.length})(Lt(z=>R=>st.compare(ht(J(ht)(-1e18)(z.incoming))(J(ht)(-1e18)(z.outgoing))-dt(J(dt)(1e18)(z.incoming))(J(dt)(1e18)(z.outgoing)))(ht(J(ht)(-1e18)(R.incoming))(J(ht)(-1e18)(R.outgoing))-dt(J(dt)(1e18)(R.incoming))(J(dt)(1e18)(R.outgoing))))(xt(z=>Pt(z)(Y))(U.decisions)));return{segments:(()=>{const z=(R,G)=>{if(R.tag==="Leaf")return G;if(R.tag==="Node")return z(R._5,Ot("Cons",R._4,z(R._6,G)));g()};return kt($t.foldr,z(W.segMap,qt))})(),deps:(()=>{const z=W.segMap,R=(D,B)=>{if(D.tag==="Leaf")return B;if(D.tag==="Node")return R(D._5,Ot("Cons",D._4,R(D._6,B)));g()},G=kt($t.foldr,R(z,qt)),I=G.length;return[...Tt(Tt(Dt(0,I-2|0))(D=>Tt(Dt(D+1|0,I-1|0))(B=>[b(D,B)])))(D=>D._1>=0&&D._1<G.length?D._2>=0&&D._2<G.length?G[D._1].splitPartner.tag!=="Nothing"&&G[D._1].splitPartner.tag==="Just"&&G[D._1].splitPartner._1===G[D._2].id||G[D._2].splitPartner.tag!=="Nothing"&&G[D._2].splitPartner.tag==="Just"&&G[D._2].splitPartner._1===G[D._1].id?[]:o(d,G[D._1],G[D._2]):[]:[]),...Tt(G)(D=>D.splitBy.tag==="Just"&&D.splitPartner.tag==="Just"&&(()=>{const B=Pt(D.splitPartner._1)(z);if(B.tag==="Nothing")return!1;if(B.tag==="Just")return!0;g()})()&&(()=>{const B=Pt(D.splitBy._1)(z);if(B.tag==="Nothing")return!1;if(B.tag==="Just")return!0;g()})()?[{src:D.id,tgt:D.splitBy._1,weight:1,kind:Do},{src:D.splitBy._1,tgt:D.splitPartner._1,weight:1,kind:Do}]:[])]})()}})(),m=h.segments,p=m.length,y=S=>{let C=S,U=!0,Y;for(;U;){const W=C,z=Xt(R=>{const G=Pt(R)(W.inWeight);if(G.tag==="Nothing")return!0;if(G.tag==="Just")return G._1===0;g()})(W.remaining);if(z.tag==="Nothing"){U=!1,Y=W;continue}if(z.tag==="Just"){const R=z._1;C={...W,inWeight:J(G=>I=>vt(it)(oe)(I.tgt)(-I.weight)(G))(W.inWeight)((()=>{const G=Pt(R)(W.depsBySrc);if(G.tag==="Nothing")return[];if(G.tag==="Just")return G._1;g()})()),marks:K(it)(R)(W.nextSource)(W.marks),nextSource:W.nextSource+1|0,outWeight:J(G=>I=>vt(it)(oe)(I.src)(-I.weight)(G))(W.outWeight)((()=>{const G=Pt(R)(W.depsByTgt);if(G.tag==="Nothing")return[];if(G.tag==="Just")return G._1;g()})()),remaining:at(G=>G!==R,W.remaining)};continue}g()}return Y},x=S=>{let C=S,U=!0,Y;for(;U;){const W=C,z=Xt(R=>{const G=Pt(R)(W.outWeight);if(G.tag==="Nothing")return!0;if(G.tag==="Just")return G._1===0;g()})(W.remaining);if(z.tag==="Nothing"){U=!1,Y=W;continue}if(z.tag==="Just"){const R=z._1;C={...W,inWeight:J(G=>I=>vt(it)(oe)(I.tgt)(-I.weight)(G))(W.inWeight)((()=>{const G=Pt(R)(W.depsBySrc);if(G.tag==="Nothing")return[];if(G.tag==="Just")return G._1;g()})()),marks:K(it)(R)(W.nextSink)(W.marks),nextSink:W.nextSink-1|0,outWeight:J(G=>I=>vt(it)(oe)(I.src)(-I.weight)(G))(W.outWeight)((()=>{const G=Pt(R)(W.depsByTgt);if(G.tag==="Nothing")return[];if(G.tag==="Just")return G._1;g()})()),remaining:at(G=>G!==R,W.remaining)};continue}g()}return Y},N=(S=>{let C=S,U=!0,Y;for(;U;){const W=y(x(C));if(W.remaining.length===0){U=!1,Y=O(z=>{const R=Pt(z.id)(W.marks),G=(()=>{if(R.tag==="Nothing")return z.id;if(R.tag==="Just")return R._1;g()})();return{...z,mark:G<p?(G+p|0)+1|0:G}})(m);continue}C=(()=>{const z=G=>{const I=Pt(G)(W.outWeight),D=Pt(G)(W.inWeight);return(()=>{if(I.tag==="Nothing")return 0;if(I.tag==="Just")return I._1;g()})()-(()=>{if(D.tag==="Nothing")return 0;if(D.tag==="Just")return D._1;g()})()|0},R=Lt(G=>I=>it.compare(z(I))(z(G)))(W.remaining);if(0<R.length){const G=R[0];return{...W,inWeight:J(I=>D=>vt(it)(oe)(D.tgt)(-D.weight)(I))(W.inWeight)((()=>{const I=Pt(G)(W.depsBySrc);if(I.tag==="Nothing")return[];if(I.tag==="Just")return I._1;g()})()),marks:K(it)(G)(W.nextSource)(W.marks),nextSource:W.nextSource+1|0,outWeight:J(I=>D=>vt(it)(oe)(D.src)(-D.weight)(I))(W.outWeight)((()=>{const I=Pt(G)(W.depsByTgt);if(I.tag==="Nothing")return[];if(I.tag==="Just")return I._1;g()})()),remaining:at(I=>I!==G,W.remaining)}}return W})()}return Y})({remaining:O(S=>S.id)(m),marks:A,inWeight:J(S=>C=>vt(it)(oe)(C.tgt)(C.weight)(S))(A)(h.deps),outWeight:J(S=>C=>vt(it)(oe)(C.src)(C.weight)(S))(A)(h.deps),depsBySrc:J(S=>C=>vt(it)(te)(C.src)([C])(S))(A)(h.deps),depsByTgt:J(S=>C=>vt(it)(te)(C.tgt)([C])(S))(A)(h.deps),nextSink:p-1|0,nextSource:p+1|0}),v=(()=>{const S=(()=>{const Y=Ar(O(W=>b(W.id,W.mark))(N));return{segments:N,deps:xt(W=>(()=>{if(W.kind==="Critical")return!0;if(W.kind==="Regular")return!1;g()})()?w("Just",W):(()=>{const z=Pt(W.src)(Y),R=Pt(W.tgt)(Y);return(()=>{if(z.tag==="Nothing")return 0;if(z.tag==="Just")return z._1;g()})()>(()=>{if(R.tag==="Nothing")return 0;if(R.tag==="Just")return R._1;g()})()})()?W.weight===0?T:w("Just",{src:W.tgt,tgt:W.src,weight:W.weight,kind:W.kind}):w("Just",W))(h.deps)}})(),C=J(Y=>W=>vt(it)(oe)(W.tgt)(1)(Y))(A)(S.deps),U=(Y=>{let W=Y,z=!0,R;for(;z;){const G=W,I=Bt(D=>T,D=>B=>w("Just",{head:D,tail:B}),G.queue);if(I.tag==="Nothing"){z=!1,R=G;continue}if(I.tag==="Just"){W=J((()=>{const D=Pt(I._1.head)(G.slots),B=(()=>{if(D.tag==="Nothing")return 0;if(D.tag==="Just")return D._1;g()})();return q=>V=>{const $=Pt(V)(q.inDegree),X=(()=>{if($.tag==="Nothing")return-1;if($.tag==="Just")return $._1-1|0;g()})();return{...q,slots:K(it)(V)(Fg((()=>{const M=Pt(V)(q.slots);if(M.tag==="Nothing")return 0;if(M.tag==="Just")return M._1;g()})())(B+1|0))(q.slots),inDegree:K(it)(V)(X)(q.inDegree),queue:X===0?[...q.queue,V]:q.queue}}})())({...G,queue:I._1.tail})((()=>{const D=Pt(I._1.head)(G.adj);if(D.tag==="Nothing")return[];if(D.tag==="Just")return D._1;g()})());continue}g()}return R})({slots:Ar(O(Y=>b(Y.id,0))(S.segments)),inDegree:C,adj:J(Y=>W=>vt(it)(te)(W.src)([W.tgt])(Y))(A)(S.deps),queue:O(Y=>Y.id)(at(Y=>{const W=Pt(Y.id)(C);if(W.tag==="Nothing")return!0;if(W.tag==="Just")return W._1===0;g()},S.segments))});return Lt(Y=>W=>it.compare(Y.slot)(W.slot))(O(Y=>({...Y,slot:(()=>{const W=Pt(Y.id)(U.slots);if(W.tag==="Nothing")return 0;if(W.tag==="Just")return W._1;g()})()}))(S.segments))})(),L=1+J(S=>C=>Fg(S)(C.slot))(0)(v)|0,k=Tt(v)(S=>S.members),E=at(S=>Qe(gn)(S.edge.id)(k),t),Q=J(ht)(-1e18)(O(S=>S.fromPos._2)(E)),H=J(dt)(1e18)(O(S=>S.toPos._2)(E));if(Q>H){const S=Ar(O(C=>b(C.id,C))(v));return Fe(O(C=>O(U=>b(U,{slot:C.slot,slotCount:L,gapTop:H,gapBottom:Q,partner:(()=>{if(C.splitPartner.tag==="Just"){const Y=Pt(C.splitPartner._1)(S);if(Y.tag==="Just")return w("Just",{slot:Y._1.slot,splitX:0<Y._1.incoming.length?Y._1.incoming[0]:0});if(Y.tag==="Nothing")return T;g()}if(C.splitPartner.tag==="Nothing")return T;g()})()}))(C.members))(at(C=>{if(C.splitPartner.tag==="Just"){const U=Pt(C.splitPartner._1)(S);return!(U.tag==="Just"&&(()=>{if(U._1.splitBy.tag==="Nothing")return!1;if(U._1.splitBy.tag==="Just")return!0;g()})())}if(C.splitPartner.tag==="Nothing")return!0;g()},v)))}const j=Ar(O(S=>b(S.id,S))(v));return Fe(O(S=>O(C=>b(C,{slot:S.slot,slotCount:L,gapTop:Q,gapBottom:H,partner:(()=>{if(S.splitPartner.tag==="Just"){const U=Pt(S.splitPartner._1)(j);if(U.tag==="Just")return w("Just",{slot:U._1.slot,splitX:0<U._1.incoming.length?U._1.incoming[0]:0});if(U.tag==="Nothing")return T;g()}if(S.splitPartner.tag==="Nothing")return T;g()})()}))(S.members))(at(S=>{if(S.splitPartner.tag==="Just"){const C=Pt(S.splitPartner._1)(j);return!(C.tag==="Just"&&(()=>{if(C._1.splitBy.tag==="Nothing")return!1;if(C._1.splitBy.tag==="Just")return!0;g()})())}if(S.splitPartner.tag==="Nothing")return!0;g()},v)))})()))(A)($m(J(u=>s=>{const a=Br(s.edge.from.node)(n);if(a.tag==="Just"){const c=Br(s.edge.to.node)(n);return c.tag==="Just"&&a._1.layer!==c._1.layer?vt(it)(te)(Fr(a._1.layer)(c._1.layer))([s])(u):u}return u})(A)((()=>{const u=s=>b((()=>{const a=Br(s.edge.from.node)(n);return a.tag==="Just"?a._1.layer:1e6})(),(()=>{const a=Br(s.edge.from.node)(n);return a.tag==="Just"?a._1.order:1e6})());return Lt(s=>a=>qm(u(s))(u(a)))(t)})())))},Vm=t=>e=>{const n=Qg(t)(e),r=J(i=>o=>K(P)(o.node)(o)(i))(A)(e);return J(i=>o=>{const u=Br(o.edge.from.node)(r);if(u.tag==="Just"){const s=Br(o.edge.to.node)(r);if(s.tag==="Just"&&u._1.layer!==s._1.layer){const a=Xm(o.edge.id)(n);if(a.tag==="Just")return K(it)(Fr(u._1.layer)(s._1.layer))(a._1.slotCount)(i)}return i}return i})(A)(t)},zg=zt.foldMap((()=>{const t={append:e=>n=>e||n};return{mempty:!1,Semigroup0:()=>t}})()),ce=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},ge=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},bi=t=>e=>n=>r=>zg(i=>n>=i.x&&n<i.x+i.w&&e>i.y&&t<i.y+i.h)(r),Ao=t=>e=>n=>r=>bi(ce(e)(n))(ge(e)(n))(r)(t),Bo=rt(4),Um=Oa(t=>{if(t.direction==="H"){const e=ce(t.start._1)(t.end._1);return[{x:e,y:t.start._2-1,w:ge(t.start._1)(t.end._1)-e,h:2}]}if(t.direction==="V"){const e=ce(t.start._2)(t.end._2);return[{x:t.start._1-1,y:e,w:2,h:ge(t.start._2)(t.end._2)-e}]}g()}),Li=Ha(t=>{const e=t.start._1-t.end._1;return!((e<0?-e<1e-6:e<1e-6)&&(()=>{const n=t.start._2-t.end._2;return n<0?-n<1e-6:n<1e-6})())}),jm=t=>e=>n=>{const r=Bt(i=>T,i=>o=>w("Just",{head:i,tail:o}),e);if(r.tag==="Nothing")return[{start:t.start,end:n.end,direction:t.direction}];if(r.tag==="Just"){const i=(r._1.head.direction==="H"?t.direction==="H":r._1.head.direction==="V"&&t.direction==="V")?[{start:t.start,end:r._1.head.end,direction:t.direction}]:[t,r._1.head],o=Xi(r._1.tail);if(o.tag==="Nothing"){const u=i.length-1|0;return u>=0&&u<i.length&&(i[u].direction==="H"?n.direction==="H":i[u].direction==="V"&&n.direction==="V")?[...(()=>{const s=i.length-1|0;return s<1?[]:bt(0,s,i)})(),{start:i[u].start,end:n.end,direction:n.direction}]:[...i,n]}if(o.tag==="Just")return(o._1.last.direction==="H"?n.direction==="H":o._1.last.direction==="V"&&n.direction==="V")?[...i,...o._1.init,{start:o._1.last.start,end:n.end,direction:n.direction}]:[...i,...r._1.tail,n]}g()},ki=t=>{const e=r=>i=>{const o=Bt(u=>T,u=>s=>w("Just",{head:u,tail:s}),i);if(o.tag==="Nothing")return[r];if(o.tag==="Just")return(r.direction==="H"?o._1.head.direction==="H":r.direction==="V"&&o._1.head.direction==="V")&&(()=>{if(r.direction==="H")return r.end._1-r.start._1>=0==o._1.head.end._1-o._1.head.start._1>=0;if(r.direction==="V")return r.end._2-r.start._2>=0==o._1.head.end._2-o._1.head.start._2>=0;g()})()?e({start:r.start,end:o._1.head.end,direction:r.direction})(o._1.tail):[r,...e(o._1.head)(o._1.tail)];g()},n=Bt(r=>T,r=>i=>w("Just",{head:r,tail:i}),t);if(n.tag==="Nothing")return[];if(n.tag==="Just")return e(n._1.head)(n._1.tail);g()},Ei=t=>e=>n=>r=>zg(i=>n>=i.y&&n<i.y+i.h&&e>i.x&&t<i.x+i.w)(r),Ci=t=>e=>n=>r=>Ei(ce(e)(n))(ge(e)(n))(r)(t),Zm=t=>e=>n=>r=>{const i=n+2|0,o=i<1?e:bt(i,e.length,e),u=n<1?[]:bt(0,n,e),s=(n+1|0)===(r-1|0),a=n===0,c=n>=0&&n<e.length?w("Just",e[n]):T;if(c.tag==="Just"){const f=n+1|0,d=f>=0&&f<e.length?w("Just",e[f]):T;if(d.tag==="Just"){const l=c._1.start._1===d._1.end._1&&(!a||c._1.direction==="V")&&(!s||d._1.direction==="V")&&!Ao(t)(ce(c._1.start._2)(d._1.end._2))(ge(c._1.start._2)(d._1.end._2))(c._1.start._1)?w("Just",[...u,{start:c._1.start,end:d._1.end,direction:ne},...o]):T,_=c._1.start._2===d._1.end._2&&(!a||c._1.direction==="H")&&(!s||d._1.direction==="H")&&!Ci(t)(ce(c._1.start._1)(d._1.end._1))(ge(c._1.start._1)(d._1.end._1))(c._1.start._2)?w("Just",[...u,{start:c._1.start,end:d._1.end,direction:ee},...o]):T;return l.tag==="Nothing"?_:l}if(d.tag==="Nothing")return T;g()}if(c.tag==="Nothing")return T;g()},Km=t=>e=>{const n=e.length;return(r=>{let i=r,o=!0,u;for(;o;){const s=i;if((s+1|0)>=n){o=!1,u=e;continue}const a=Zm(t)(e)(s)(n);if(a.tag==="Just"){o=!1,u=a._1;continue}if(a.tag==="Nothing"){i=s+1|0;continue}g()}return u})(0)},t2=t=>e=>n=>r=>{const i=(l,_,h)=>!Ao(t)(ce(_)(h))(ge(_)(h))(l),o=n+3|0,u=o<1?e:bt(o,e.length,e),s=n<1?[]:bt(0,n,e),a=(n+2|0)===(r-1|0),c=n===0,f=(l,_,h)=>!Ci(t)(ce(_)(h))(ge(_)(h))(l),d=n>=0&&n<e.length?w("Just",e[n]):T;if(d.tag==="Just"){const l=n+2|0,_=l>=0&&l<e.length?w("Just",e[l]):T;if(_.tag==="Just"){const h=d._1.start._1===_._1.end._1&&(!c||d._1.direction==="V")&&(!a||_._1.direction==="V")&&i(d._1.start._1,d._1.start._2,_._1.end._2)?w("Just",[...s,{start:d._1.start,end:_._1.end,direction:ne},...u]):d._1.start._2===_._1.end._2&&(!c||d._1.direction==="H")&&(!a||_._1.direction==="H")&&f(d._1.start._2,d._1.start._1,_._1.end._1)?w("Just",[...s,{start:d._1.start,end:_._1.end,direction:ee},...u]):T,m=(!c||d._1.direction==="V")&&(!a||_._1.direction==="H")&&i(d._1.start._1,d._1.start._2,_._1.end._2)&&f(_._1.end._2,d._1.start._1,_._1.end._1)?w("Just",[...s,{start:d._1.start,end:b(d._1.start._1,_._1.end._2),direction:ne},{start:b(d._1.start._1,_._1.end._2),end:_._1.end,direction:ee},...u]):T,p=(!c||d._1.direction==="H")&&(!a||_._1.direction==="V")&&f(d._1.start._2,d._1.start._1,_._1.end._1)&&i(_._1.end._1,d._1.start._2,_._1.end._2)?w("Just",[...s,{start:d._1.start,end:b(_._1.end._1,d._1.start._2),direction:ee},{start:b(_._1.end._1,d._1.start._2),end:_._1.end,direction:ne},...u]):T,y=m.tag==="Nothing"?p:m;return h.tag==="Nothing"?y:h}if(_.tag==="Nothing")return T;g()}if(d.tag==="Nothing")return T;g()},e2=t=>e=>{const n=e.length;return(r=>{let i=r,o=!0,u;for(;o;){const s=i;if((s+2|0)>=n){o=!1,u=e;continue}const a=t2(t)(e)(s)(n);if(a.tag==="Just"){o=!1,u=a._1;continue}if(a.tag==="Nothing"){i=s+1|0;continue}g()}return u})(0)},n2=t=>{const e=n=>{let r=n,i=!0,o;for(;i;){const u=r,s=ki(Li(Km(t)(e2(t)(u))));if(s.length<u.length){r=s;continue}i=!1,o=s}return o};return n=>e(ki(Li(n)))},r2=t=>e=>n=>r=>{const i=ce(n)(r),o=ge(n)(r),u=at(a=>e>=a.y&&e<a.y+a.h&&a.x+a.w>i&&a.x<o,t);if(r>n){const a=Lt(c=>f=>st.compare(c.x)(f.x))(u);return 0<a.length?a[0].x-1:(n+r)/2}const s=Lt(a=>c=>st.compare(c.x)(a.x))(O(a=>({...a,x:a.x+a.w}))(u));return 0<s.length?s[0].x+1:(n+r)/2},i2=t=>e=>n=>r=>{const i=ce(n)(r),o=ge(n)(r),u=at(a=>e>=a.x&&e<a.x+a.w&&a.y+a.h>i&&a.y<o,t);if(r>n){const a=Lt(c=>f=>st.compare(c.y)(f.y))(u);return 0<a.length?a[0].y-1:(n+r)/2}const s=Lt(a=>c=>st.compare(c.y)(a.y))(O(a=>({...a,y:a.y+a.h}))(u));return 0<s.length?s[0].y+1:(n+r)/2},o2=t=>e=>n=>r=>{const i=ce(n)(r),o=ge(n)(r),u=at(a=>e>=a.y&&e<a.y+a.h&&a.x+a.w>i&&a.x<o,t);if(r>n){const a=Lt(c=>f=>st.compare(f.x)(c.x))(O(c=>({...c,x:c.x+c.w}))(u));return 0<a.length?a[0].x:(n+r)/2}const s=Lt(a=>c=>st.compare(a.x)(c.x))(u);return 0<s.length?s[0].x-1:(n+r)/2},u2=t=>e=>n=>r=>{const i=ce(n)(r),o=ge(n)(r),u=at(a=>e>=a.x&&e<a.x+a.w&&a.y+a.h>i&&a.y<o,t);if(r>n){const a=Lt(c=>f=>st.compare(f.y)(c.y))(O(c=>({...c,y:c.y+c.h}))(u));return 0<a.length?a[0].y:(n+r)/2}const s=Lt(a=>c=>st.compare(a.y)(c.y))(u);return 0<s.length?s[0].y-1:(n+r)/2},Wg=t=>e=>n=>{let r=t,i=e,o=n,u=!0,s;for(;u;){const a=r,c=i,f=o;if(f>100){u=!1,s=c;continue}if(!a(c+f)){u=!1,s=c+f;continue}if(!a(c-f)){u=!1,s=c-f;continue}r=a,i=c,o=f+1}return s},Mg=t=>e=>n=>r=>i=>{const o=ce(e)(n),u=ge(e)(n);if(!bi(o)(u)(r)(t))return r;if(!bi(o)(u)(i)(t))return i;const s=(r+i)/2;return bi(o)(u)(s)(t)?Wg(a=>bi(o)(u)(a)(t))(s)(1):s},s2=t=>e=>n=>r=>i=>{const o=ce(e)(n),u=ge(e)(n);if(!Ei(o)(u)(r)(t))return r;if(!Ei(o)(u)(i)(t))return i;const s=(r+i)/2;return Ei(o)(u)(s)(t)?Wg(a=>Ei(o)(u)(a)(t))(s)(1):s},a2=t=>e=>n=>r=>{const i=ce(e)(n),o=ge(e)(n),u=at(c=>r>=c.x&&r<c.x+c.w&&c.y+c.h>i&&c.y<o,t),s=J(c=>f=>ge(c)(f.x+f.w+4))(r+4)(u),a=J(c=>f=>ce(c)(f.x-4))(r-4)(u);return(()=>{const c=s-r,f=a-r;return(c<0?-c:c)<=(f<0?-f:f)})()?s:a},c2=t=>e=>n=>r=>{const i=ce(e)(n),o=ge(e)(n),u=at(c=>r>=c.y&&r<c.y+c.h&&c.x+c.w>i&&c.x<o,t),s=J(c=>f=>ge(c)(f.y+f.h+4))(r+4)(u),a=J(c=>f=>ce(c)(f.y-4))(r-4)(u);return(()=>{const c=s-r,f=a-r;return(c<0?-c:c)<=(f<0?-f:f)})()?s:a},g2=t=>e=>n=>r=>i=>o=>u=>{const s=(()=>{if(r==="South")return b(i._1,i._2+4);if(r==="North")return b(i._1,i._2-4);if(r==="East")return b(i._1+4,i._2);if(r==="West")return b(i._1-4,i._2);g()})(),a=(()=>{if(o==="South")return b(u._1,u._2+4);if(o==="North")return b(u._1,u._2-4);if(o==="East")return b(u._1+4,u._2);if(o==="West")return b(u._1-4,u._2);g()})(),c=(L,k,E)=>!Ao(e)(ce(k)(E))(ge(k)(E))(L),f=(L,k,E)=>!Ao(n)(ce(k)(E))(ge(k)(E))(L),d=(L,k,E,Q)=>t.tag==="Just"&&!Ci(n)(ce(L)(k))(ge(L)(k))(t._1)?t._1:s2(e)(L)(k)(E)(Q),l=(L,k,E,Q)=>{if(L===E){const j=a2(e)(k)(Q)(L),S=i2(e)(L)(k)(Q),C=u2(e)(L)(k)(Q);return[{start:b(L,k),end:b(L,S),direction:ne},{start:b(L,S),end:b(j,S),direction:ee},{start:b(j,S),end:b(j,C),direction:ne},{start:b(j,C),end:b(E,C),direction:ee},{start:b(E,C),end:b(E,Q),direction:ne}]}const H=d(L,E,k,Q);return[{start:b(L,k),end:b(L,H),direction:ne},{start:b(L,H),end:b(E,H),direction:ee},{start:b(E,H),end:b(E,Q),direction:ne}]},_=(L,k,E,Q)=>{if(k===Q){const j=c2(e)(L)(E)(k),S=r2(e)(k)(L)(E),C=o2(e)(k)(L)(E);return[{start:b(L,k),end:b(S,k),direction:ee},{start:b(S,k),end:b(S,j),direction:ne},{start:b(S,j),end:b(C,j),direction:ee},{start:b(C,j),end:b(C,Q),direction:ne},{start:b(C,Q),end:b(E,Q),direction:ee}]}const H=Mg(e)(k)(Q)(L)(E);return[{start:b(L,k),end:b(H,k),direction:ee},{start:b(H,k),end:b(H,Q),direction:ne},{start:b(H,Q),end:b(E,Q),direction:ee}]},h=(L,k,E)=>!Ci(e)(ce(k)(E))(ge(k)(E))(L),m=(L,k,E)=>!Ci(n)(ce(k)(E))(ge(k)(E))(L),p=(L,k,E,Q)=>{if(m(k,L,E)&&f(E,k,Q))return[{start:b(L,k),end:b(E,k),direction:ee},{start:b(E,k),end:b(E,Q),direction:ne}];const H=Mg(e)(k)(Q)(L)(E);return[{start:b(L,k),end:b(H,k),direction:ee},{start:b(H,k),end:b(H,Q),direction:ne},{start:b(H,Q),end:b(E,Q),direction:ee}]},y=(L,k,E,Q)=>{if(f(L,k,Q)&&m(Q,L,E))return[{start:b(L,k),end:b(L,Q),direction:ne},{start:b(L,Q),end:b(E,Q),direction:ee}];const H=d(L,E,k,Q);return[{start:b(L,k),end:b(L,H),direction:ne},{start:b(L,H),end:b(E,H),direction:ee},{start:b(E,H),end:b(E,Q),direction:ne}]},x=(()=>{if(r==="South")return o==="North"?s._1===a._1&&c(s._1,s._2,a._2)?[{start:b(s._1,s._2),end:b(a._1,a._2),direction:ne}]:l(s._1,s._2,a._1,a._2):o==="East"||o==="West"?y(s._1,s._2,a._1,a._2):l(s._1,s._2,a._1,a._2);if(r==="North")return o==="South"?s._1===a._1&&c(s._1,s._2,a._2)?[{start:b(s._1,s._2),end:b(a._1,a._2),direction:ne}]:l(s._1,s._2,a._1,a._2):o==="East"||o==="West"?y(s._1,s._2,a._1,a._2):l(s._1,s._2,a._1,a._2);if(r==="East")return o==="West"?s._2===a._2&&h(s._2,s._1,a._1)?[{start:b(s._1,s._2),end:b(a._1,a._2),direction:ee}]:_(s._1,s._2,a._1,a._2):o==="North"||o==="South"?p(s._1,s._2,a._1,a._2):l(s._1,s._2,a._1,a._2);if(r==="West"){if(o==="East")return s._2===a._2&&h(s._2,s._1,a._1)?[{start:b(s._1,s._2),end:b(a._1,a._2),direction:ee}]:_(s._1,s._2,a._1,a._2);if(o==="North"||o==="South")return p(s._1,s._2,a._1,a._2)}return l(s._1,s._2,a._1,a._2)})(),N=(()=>{if(r==="South"||r==="North")return ne;if(r==="East"||r==="West")return ee;g()})(),v={start:b(a._1,a._2),end:b(u._1,u._2),direction:(()=>{if(o==="South"||o==="North")return ne;if(o==="East"||o==="West")return ee;g()})()};return s._1===a._1&&s._2===a._2?[{start:b(i._1,i._2),end:b(u._1,u._2),direction:N}]:jm({start:b(i._1,i._2),end:b(s._1,s._2),direction:N})(x)(v)},f2=O(t=>({x:t.position._1*Bo-2,y:t.position._2*Bo-2,w:t.size._1*Bo+4,h:t.size._2*Bo+4})),Gs=Kt(P)(zt),In=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Ps=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},_2=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t._1)(o._3._1);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(t._2==="North"){if(o._3._2==="North"){r=!1,i=w("Just",o._4);continue}n=o._5;continue}if(o._3._2==="North"){n=o._6;continue}if(t._2==="South"){if(o._3._2==="South"){r=!1,i=w("Just",o._4);continue}n=o._5;continue}if(o._3._2==="South"){n=o._6;continue}if(t._2==="East"){if(o._3._2==="East"){r=!1,i=w("Just",o._4);continue}n=o._5;continue}if(o._3._2==="East"){n=o._6;continue}if(t._2==="West"&&o._3._2==="West"){r=!1,i=w("Just",o._4);continue}}g()}return i},Hg=t=>e=>{const n=e.position._1+e.size._1,r=e.position._2*2+e.size._2,i=e.position._1*2+e.size._1,o=e.position._2+e.size._2;if(t==="South")return b(i,o*2);if(t==="North")return b(i,e.position._2*2);if(t==="East")return b(n*2,r);if(t==="West")return b(e.position._1*2,r);g()},Is=t=>e=>{const n=rt(4);if(t==="South")return{lo:e.position._1*n,hi:(e.position._1+e.size._1)*n};if(t==="North")return{lo:e.position._1*n,hi:(e.position._1+e.size._1)*n};if(t==="East")return{lo:e.position._2*n,hi:(e.position._2+e.size._2)*n};if(t==="West")return{lo:e.position._2*n,hi:(e.position._2+e.size._2)*n};g()},Og=t=>e=>J(n=>r=>vt(t)(te)(e(r))([r])(n))(A),qg=t=>e=>n=>r=>{const i=(t==="South"||t==="North")&&(e==="East"||e==="West")&&(()=>{if(t==="South")return r._2>n._2;if(t==="North")return r._2<n._2;if(t==="East")return r._2>n._2;if(t==="West")return r._2<n._2;g()})()&&(()=>{if(e==="East")return n._1>r._1;if(e==="West"||e==="North")return n._1<r._1;if(e==="South")return n._1>r._1;g()})(),o=(t==="East"||t==="West")&&(e==="North"||e==="South")&&(()=>{if(t==="South")return r._1>n._1;if(t==="North")return r._1<n._1;if(t==="East")return r._1>n._1;if(t==="West")return r._1<n._1;g()})()&&(()=>{if(e==="East")return n._2>r._2;if(e==="West"||e==="North")return n._2<r._2;if(e==="South")return n._2>r._2;g()})();return(t==="South"?e==="North"&&n._1===r._1&&r._2>n._2:t==="North"?e==="South"&&n._1===r._1&&r._2<n._2:t==="East"?e==="West"&&n._2===r._2&&r._1>n._1:t==="West"&&e==="East"&&n._2===r._2&&r._1<n._1)?0:i||o?1:2},$g=t=>e=>{const n=t.hi-t.lo,r=(t.lo+t.hi)/2,i=e.length;return i===0?A:Gs(i===1?O(o=>b(o,r))(e):At(o=>u=>b(u,t.lo+rt(o+1|0)*n/rt(i+1|0)))(e))},Yg=t=>e=>n=>r=>i=>{const o=Og(P)(_=>_.to.node)(t),u=Og(P)(_=>_.from.node)(t),s=J(_=>h=>K(P)(h.node)(h)(_))(A)(e),a=(_,h,m)=>{const p=In(_)(s);if(p.tag==="Nothing")return b(0,0);if(p.tag==="Just"){const y=In(_)(n);if(y.tag==="Nothing"){const x=rt(4);if(m==="South")return b(p._1.position._1*x+p._1.size._1*x/2,(p._1.position._2+p._1.size._2)*x);if(m==="North")return b(p._1.position._1*x+p._1.size._1*x/2,p._1.position._2*x);if(m==="East")return b((p._1.position._1+p._1.size._1)*x,p._1.position._2*x+p._1.size._2*x/2);if(m==="West")return b(p._1.position._1*x,p._1.position._2*x+p._1.size._2*x/2);g()}if(y.tag==="Just"){const x=Xt(N=>N.id===h)(y._1);if(x.tag==="Nothing"){const N=rt(4);if(m==="South")return b(p._1.position._1*N+p._1.size._1*N/2,(p._1.position._2+p._1.size._2)*N);if(m==="North")return b(p._1.position._1*N+p._1.size._1*N/2,p._1.position._2*N);if(m==="East")return b((p._1.position._1+p._1.size._1)*N,p._1.position._2*N+p._1.size._2*N/2);if(m==="West")return b(p._1.position._1*N,p._1.position._2*N+p._1.size._2*N/2);g()}if(x.tag==="Just"){const N=rt(4);if(x._1.side==="North")return b(p._1.position._1*N+rt(x._1.offset)*N,p._1.position._2*N);if(x._1.side==="South")return b(p._1.position._1*N+rt(x._1.offset)*N,(p._1.position._2+p._1.size._2)*N);if(x._1.side==="East")return b((p._1.position._1+p._1.size._1)*N,p._1.position._2*N+rt(x._1.offset)*N);if(x._1.side==="West")return b(p._1.position._1*N,p._1.position._2*N+rt(x._1.offset)*N)}}}g()},c=Gs(Tt(r)(_=>{if(_.nodes.length<=2)return[];const h=rt(4);if(1<_.nodes.length){const m=In(_.nodes[1])(s);if(m.tag==="Nothing")return[];if(m.tag==="Just"){const p=m._1.position._1*h+m._1.size._1*h/2;return O(y=>b(y,p))(Je(y=>x=>_.edgeId+":"+y+"->"+x,_.nodes,bt(1,_.nodes.length,_.nodes)))}g()}return[]})),f=_=>{const h=In(_.from.node)(s),m=In(_.to.node)(s);if(h.tag==="Just"&&m.tag==="Just"){const p=h._1,y=m._1,x=Lt(N=>v=>it.compare(N.score)(v.score))(O(N=>{const v=N._1,L=N._2;return{from:v,to:L,score:(()=>{const k=(j,S,C,U,Y)=>{const W=Is(j)(S),z=Is(j)(C);return W.lo<z.hi&&z.lo<W.hi&&(v==="South"?L==="North"&&Y._2>U._2:v==="North"?L==="South"&&Y._2<U._2:v==="East"?L==="West"&&Y._1>U._1:v==="West"&&L==="East"&&Y._1<U._1)?0:qg(v)(L)(U)(Y)},E=Hg(v)(p),Q=Hg(L)(y),H=qg(v)(L)(E)(Q);return(()=>{if(H>0){if(v==="South")return L==="North"?k(he,p,y,E,Q)*10|0:H*10|0;if(v==="North")return L==="South"?k(le,p,y,E,Q)*10|0:H*10|0;if(v==="East")return L==="West"?k(pn,p,y,E,Q)*10|0:H*10|0;if(v==="West"&&L==="East")return k(_r,p,y,E,Q)*10|0}return H*10|0})()+(v==="South"?L==="North"?0:15:v==="North"?L==="South"?0:15:v==="East"?L==="West"?5:15:v==="West"&&L==="East"?5:15)|0})()}})([b(he,le),b(pn,le),b(_r,le),b(he,pn),b(he,_r),b(le,he),b(le,pn),b(le,_r),b(pn,he),b(_r,he),b(pn,_r),b(_r,pn)]));if(0<x.length)return{from:x[0].from,to:x[0].to}}return{from:he,to:le}},d=Gs(O(_=>b(_.id,f(_)))(t)),l=(_,h,m,p,y,x)=>{const N=rt(4),v=In(h)(s);if(v.tag==="Nothing")return b(0,0);if(v.tag==="Just"){const L=_2(b(m,_))(i);if(L.tag==="Just"){const k=v._1.position._1*N+L._1,E=rt(4);if(_==="South")return b(k,(v._1.position._2+v._1.size._2)*E);if(_==="North")return b(k,v._1.position._2*E);if(_==="East")return b((v._1.position._1+v._1.size._1)*E,k);if(_==="West")return b(v._1.position._1*E,k);g()}if(L.tag==="Nothing"){const k=Is(_)(v._1),E=(k.lo+k.hi)/2,Q=Ps(m)($g(k)(O(S=>S.id)(Lt(S=>C=>st.compare(y(_)(S))(y(_)(C)))(at(S=>{const C=Ps(S.id)(d);if(C.tag==="Just"){const U=x(C._1);return U==="North"?_==="North":U==="South"?_==="South":U==="East"?_==="East":U==="West"&&_==="West"}if(C.tag==="Nothing")return!0;g()},(()=>{const S=In(h)(p);if(S.tag==="Nothing")return[];if(S.tag==="Just")return S._1;g()})()))))),H=(()=>{if(Q.tag==="Nothing")return E;if(Q.tag==="Just")return Q._1;g()})(),j=rt(4);if(_==="South")return b(H,(v._1.position._2+v._1.size._2)*j);if(_==="North")return b(H,v._1.position._2*j);if(_==="East")return b((v._1.position._1+v._1.size._1)*j,H);if(_==="West")return b(v._1.position._1*j,H)}}g()};return O(_=>{const h=Ps(_.edge.id)(c);if(h.tag==="Nothing")return _;if(h.tag==="Just")return{..._,fromPos:me(3)(_.edge.from.node)==="$d:"?b(h._1,_.fromPos._2):_.fromPos,toPos:me(3)(_.edge.to.node)==="$d:"?b(h._1,_.toPos._2):_.toPos};g()})(O(_=>{if(_.from.port.tag==="Just"&&_.to.port.tag==="Just")return{edge:_,fromPos:a(_.from.node,_.from.port._1,he),toPos:a(_.to.node,_.to.port._1,le),fromSide:he,toSide:le};const h=f(_);return{edge:_,fromPos:l(h.from,_.from.node,_.id,u,m=>p=>{const y=In(p.to.node)(s);if(y.tag==="Nothing")return 0;if(y.tag==="Just"){const x=rt(4);if(m==="South"||m==="North")return y._1.position._1*x+y._1.size._1*x/2;if(m==="East"||m==="West")return y._1.position._2*x+y._1.size._2*x/2}g()},m=>m.from),toPos:l(h.to,_.to.node,_.id,o,m=>p=>{const y=In(p.from.node)(s);if(y.tag==="Nothing")return 0;if(y.tag==="Just"){const x=rt(4);if(m==="South"||m==="North")return y._1.position._1*x+y._1.size._1*x/2;if(m==="East"||m==="West")return y._1.position._2*x+y._1.size._2*x/2}g()},m=>m.to),fromSide:h.from,toSide:h.to}})(t))},Xg=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Rr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},d2=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),Ds=t=>e=>t.gapTop+1*rt(4)+rt(e)*2.5*rt(4),l2=t=>e=>{const n=Xg(e.edge.id)(t);if(n.tag==="Just"){if(n._1.partner.tag==="Just")return w("Just",{slot1Y:Ds(n._1)(n._1.slot),splitX:n._1.partner._1.splitX,slot2Y:Ds(n._1)(n._1.partner._1.slot)});if(n._1.partner.tag==="Nothing")return T;g()}if(n.tag==="Nothing")return T;g()},h2=t=>e=>{const n=J(r=>i=>K(P)(i.node)(i)(r))(A)(e);return Fe(At(r=>i=>{const o=Rr(i.node)(n);if(o.tag==="Nothing")return[];if(o.tag==="Just"){const u=o._1;return At(s=>a=>{const c=i.edges.length,f=rt(4),d=u.position._1*f,l=u.position._2*f,_=u.size._2*f,h=rt((2*c|0)+1|0),m=l+_*rt(c-s|0)/h,p=l+_*rt((c+1|0)+s|0)/h,y=d-f*2.5*rt(s+1|0),x=[{start:b(d,m),end:b(y,m),direction:ee},{start:b(y,m),end:b(y,p),direction:ne},{start:b(y,p),end:b(d,p),direction:ee}];return{edge:a.id,segments:x,bends:Je(N=>v=>N.end,x,bt(1,3,x)),bendType:[],jumps:[],reversed:!1}})(i.edges)}g()})(O(r=>({node:r._1,edges:r._2}))(d2(J(r=>i=>vt(P)(te)(i.from.node)([i])(r))(A)(t)))))},p2=t=>e=>{const n=J(o=>u=>K(P)(u.node)(u)(o))(A)(e),r=o=>{const u=Rr(o)(n);if(u.tag==="Nothing")return 0;if(u.tag==="Just")return u._1.position._1;g()},i=o=>{const u=Rr(o)(n);if(u.tag==="Nothing")return 0;if(u.tag==="Just")return u._1.layer;g()};return Lt(o=>u=>{const s=it.compare(i(o.edge.from.node))(i(u.edge.from.node));if(s==="EQ"){const a=st.compare(r(o.edge.from.node))(r(u.edge.from.node));return a==="EQ"?st.compare(r(o.edge.to.node))(r(u.edge.to.node)):a}return s})(t)},Ie=t=>{const e=rt(4);return{x:t.position._1*e-2,y:t.position._2*e-2,w:t.size._1*e+4,h:t.size._2*e+4}},m2=t=>t.from.node===t.to.node,y2=t=>e=>n=>r=>{const i=n2(n)(g2(t)(e)(n)(r.fromSide)(r.fromPos)(r.toSide)(r.toPos));return{edge:r.edge.id,segments:i,bends:Je(o=>u=>o.end,i,bt(1,i.length,i)),bendType:[],jumps:[],reversed:!1}},x2=t=>e=>n=>r=>{const i=[{start:b(r.fromPos._1,r.fromPos._2),end:b(r.fromPos._1,t.slot1Y),direction:ne},{start:b(r.fromPos._1,t.slot1Y),end:b(t.splitX,t.slot1Y),direction:ee},{start:b(t.splitX,t.slot1Y),end:b(t.splitX,t.slot2Y),direction:ne},{start:b(t.splitX,t.slot2Y),end:b(r.toPos._1,t.slot2Y),direction:ee},{start:b(r.toPos._1,t.slot2Y),end:b(r.toPos._1,r.toPos._2),direction:ne}];return{edge:r.edge.id,segments:i,bends:Je(o=>u=>o.end,i,bt(1,5,i)),bendType:[],jumps:[],reversed:!1}},N2=t=>e=>n=>{const r=Rr(t.edge.from.node)(n);if(r.tag==="Just"){const o=Rr(t.edge.to.node)(n);return o.tag==="Just"?at(u=>!(u.h===Ie(r._1).h&&u.w===Ie(r._1).w&&u.x===Ie(r._1).x&&u.y===Ie(r._1).y)&&!(u.h===Ie(o._1).h&&u.w===Ie(o._1).w&&u.x===Ie(o._1).x&&u.y===Ie(o._1).y),e):at(u=>!(u.h===Ie(r._1).h&&u.w===Ie(r._1).w&&u.x===Ie(r._1).x&&u.y===Ie(r._1).y),e)}const i=Rr(t.edge.to.node)(n);return i.tag==="Just"?at(o=>!(o.h===Ie(i._1).h&&o.w===Ie(i._1).w&&o.x===Ie(i._1).x&&o.y===Ie(i._1).y),e):at(o=>!0,e)},J2=t=>e=>{const n=Xg(e.edge.id)(t);if(n.tag==="Just")return w("Just",Ds(n._1)(n._1.slot));if(n.tag==="Nothing")return T;g()},T2=t=>e=>n=>r=>i=>{const o=J(c=>f=>K(P)(f.node)(f)(c))(A)(e),u=f2(e),s=Yg(at(c=>c.from.node!==c.to.node,t))(e)(n)(r)(i),a=Qg(s)(e);return[...h2(at(m2,t))(e),...J(c=>f=>{const d=N2(f)(u)(o),l=[...d,...c.edgeObstacles],_=l2(a)(f),h=(()=>{if(_.tag==="Just")return x2(_._1)(d)(l)(f);if(_.tag==="Nothing")return y2(J2(a)(f))(d)(l)(f);g()})();return{results:[...c.results,h],edgeObstacles:[...c.edgeObstacles,...Um(h.segments)]}})({results:[],edgeObstacles:[]})(p2(s)(e)).results]},Kn=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},tr=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},v2=t=>e=>n=>{if(t.start._1!==e.start._1)return T;const r=tr(Kn(t.start._2)(t.end._2))(Kn(e.start._2)(e.end._2)),i=Kn(tr(t.start._2)(t.end._2))(tr(e.start._2)(e.end._2));return r<i?w("Just",{position:b(t.start._1,(r+i)/2),crossingEdge:n}):T},w2=t=>e=>n=>{if(t.start._2!==e.start._2)return T;const r=tr(Kn(t.start._1)(t.end._1))(Kn(e.start._1)(e.end._1)),i=Kn(tr(t.start._1)(t.end._1))(tr(e.start._1)(e.end._1));return r<i?w("Just",{position:b((r+i)/2,t.start._2),crossingEdge:n}):T},b2=t=>e=>n=>{if(t.direction==="H")return w2(t)(e)(n);if(t.direction==="V")return v2(t)(e)(n);g()},L2=t=>e=>n=>{const r=t+1|0,i=r<1?n:bt(r,n.length,n);return Tt(e.segments)(o=>Tt(i)(u=>xt(s=>b2(o)(s)(u.edge))(at(s=>s.direction==="H"?o.direction==="H":s.direction==="V"&&o.direction==="V",u.segments))))},k2=t=>e=>n=>e.start._1>Kn(t.start._1)(t.end._1)&&e.start._1<tr(t.start._1)(t.end._1)&&t.start._2>Kn(e.start._2)(e.end._2)&&t.start._2<tr(e.start._2)(e.end._2)?w("Just",{position:b(e.start._1,t.start._2),crossingEdge:n}):T,E2=t=>e=>Tt(at(n=>n.direction==="H",t.segments))(n=>Tt(e)(r=>xt(i=>k2(n)(i)(r.edge))(at(i=>i.direction==="V",r.segments)))),C2=t=>e=>n=>[...E2(e)(at(r=>r.edge!==e.edge,n)),...L2(t)(e)(n)],Vg=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Ug=t=>me(3)(t)==="$d:",S2=t=>e=>n=>J(r=>i=>{const o=Vg(i.from.node)(t),u=(()=>{if(o.tag==="Nothing")return 0;if(o.tag==="Just")return o._1;g()})(),s=Vg(i.to.node)(t),a=(()=>{if(s.tag==="Nothing")return-u;if(s.tag==="Just")return s._1-u|0;g()})();if(a<=1)return{...r,edges:[...r.edges,i],chains:[...r.chains,{edgeId:i.id,nodes:[i.from.node,i.to.node]}]};const c=i.id,f=O(l=>"$d:"+c+":"+ie(l))(Dt(1,a-1|0)),d=[i.from.node,...f,i.to.node];return{...r,layers:J(l=>_=>{const h=_._2,m=Ma(u+_._1|0)(p=>[...p,h])(l);if(m.tag==="Nothing")return l;if(m.tag==="Just")return m._1;g()})(r.layers)(Je(Hn,Dt(1,a-1|0),f)),edges:[...r.edges,...Je(l=>_=>({id:c+":"+l+"->"+_,from:{node:l,port:i.from.port},to:{node:_,port:i.to.port}}),d,bt(1,d.length,d))],chains:[...r.chains,{edgeId:i.id,nodes:d}]}})({layers:n,edges:[],chains:[]})(e),Fo=(()=>{const t={eq:e=>n=>e._1===n._1&&(e._2==="North"?n._2==="North":e._2==="South"?n._2==="South":e._2==="East"?n._2==="East":e._2==="West"&&n._2==="West")};return{compare:e=>n=>{const r=P.compare(e._1)(n._1);if(r==="LT")return ye;if(r==="GT")return xe;if(e._2==="North")return n._2==="North"?Ge:ye;if(n._2==="North")return xe;if(e._2==="South")return n._2==="South"?Ge:ye;if(n._2==="South")return xe;if(e._2==="East")return n._2==="East"?Ge:ye;if(n._2==="East")return xe;if(e._2==="West"&&n._2==="West")return Ge;g()},Eq0:()=>t}})(),G2=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=Fo.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},P2=Kt(P)(zt),As=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},I2=Kt(Fo)(zt),jg=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),Qr=t=>e=>n=>r=>{const i=G2(b(e,n))(t);if(i.tag==="Nothing")return r;if(i.tag==="Just")return i._1;g()},Zg=t=>e=>n=>{const r=P2(Fe(O(u=>At(s=>a=>b(a,s))(u))(t))),i=(u,s)=>{if(u==="South"){const a=As(s.to.node)(r);if(a.tag==="Nothing")return 0;if(a.tag==="Just")return a._1;g()}if(u==="North"){const a=As(s.from.node)(r);if(a.tag==="Nothing")return 0;if(a.tag==="Just")return a._1;g()}return 0},o=u=>J(s=>a=>Ce(Fo.compare,Le,I2(O(c=>b(b(c._1,u),c._2))(jg($g({lo:0,hi:(()=>{const c=As(a._1)(n);if(c.tag==="Just")return c._1._1;if(c.tag==="Nothing")return me(3)(a._1)==="$d:"?0:1;g()})()})(O(c=>c.id)(Lt(c=>f=>it.compare(i(u,c))(i(u,f)))(a._2)))))),s))(A)(jg(J(s=>a=>a.from.node===a.to.node?s:u==="South"?vt(P)(te)(a.from.node)([a])(s):u==="North"?vt(P)(te)(a.to.node)([a])(s):s)(A)(e)));return Ce(Fo.compare,Le,o(le),o(he))},Kg=t=>t,tf=t=>t,ef=t=>t,D2=J(t=>e=>K(P)(e)()(t))(A),A2=(()=>{const t=qe.unfoldr(e=>{if(e.tag==="Nil")return T;if(e.tag==="Cons")return w("Just",b(e._1,e._2));g()});return e=>t((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._3,n(r._6,i)));g()};return n(e,qt)})())})(),ot=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},en=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Nn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Jn=Kt(P)(zt),Bs=Ua(P),Fs=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),B2=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},F2=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},nf=ef("VDown"),rf=ef("VUp"),R2=tf("ForwardPhase"),Q2=tf("StackPhase"),of=Kg("HRight"),uf=Kg("HLeft"),sf=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},z2=t=>e=>n=>{const r=J(u=>s=>vt(P)(oe)(s.tgt)(1)(u))(A)(t),i=A2(D2([...O(u=>u.src)(t),...O(u=>u.tgt)(t),...(()=>{const u=(s,a)=>{if(s.tag==="Leaf")return a;if(s.tag==="Node")return u(s._5,Ot("Cons",s._4,u(s._6,a)));g()};return kt($t.foldr,u(e,qt))})()])),o=J(u=>s=>vt(P)(te)(s.src)([{target:s.tgt,sep:s.sep}])(u))(A)(t);return(u=>s=>a=>{let c=u,f=s,d=a,l=!0,_;for(;l;){const h=c,m=f,p=d,y=Bt(x=>T,x=>N=>w("Just",{head:x,tail:N}),h);if(y.tag==="Nothing"){l=!1,_=p;continue}if(y.tag==="Just"){const x=ot(y._1.head)(p),N=(()=>{if(x.tag==="Nothing")return 0;if(x.tag==="Just")return x._1;g()})(),v=J(L=>k=>{const E=ot(k.target)(L.result),Q=N+k.sep,H=ot(k.target)(L.indeg),j=(()=>{if(H.tag==="Nothing")return-1;if(H.tag==="Just")return H._1-1|0;g()})();return{newQueue:j===0?[...L.newQueue,k.target]:L.newQueue,result:K(P)(k.target)((()=>{if(E.tag==="Nothing")return Q;if(E.tag==="Just"){if(n==="VDown")return en(E._1)(Q);if(n==="VUp")return Nn(E._1)(Q)}g()})())(L.result),indeg:K(P)(k.target)(j)(L.indeg)}})({newQueue:[],result:p,indeg:m})((()=>{const L=ot(y._1.head)(o);if(L.tag==="Nothing")return[];if(L.tag==="Just")return L._1;g()})());c=[...y._1.tail,...v.newQueue],f=v.indeg,d=v.result;continue}g()}return _})(at(u=>{const s=ot(u)(r);if(s.tag==="Nothing")return!0;if(s.tag==="Just")return s._1===0;g()},i))(r)(J(u=>s=>K(P)(s)(0)(u))(A)(i))},W2=t=>{const e=(o,u)=>{if(o.tag==="Leaf")return u;if(o.tag==="Node")return e(o._5,Ot("Cons",o._4,e(o._6,u)));g()},n=kt($t.foldr,e(t,qt)),r=J(en)(999999)(n);if(r===0||n.length===0)return t;const i=o=>{if(o.tag==="Leaf")return A;if(o.tag==="Node")return Mt("Node",o._1,o._2,o._3,o._4-r,i(o._5),i(o._6));g()};return i(t)},af=t=>{const e=(o,u)=>{if(o.tag==="Leaf")return u;if(o.tag==="Node")return e(o._5,Ot("Cons",o._4,e(o._6,u)));g()},n=e(t,qt),r=o=>u=>{let s=o,a=u,c=!0,f;for(;c;){const d=s,l=a;if(l.tag==="Nil"){c=!1,f=d;continue}if(l.tag==="Cons"){s=Nn(d)(l._1),a=l._2;continue}g()}return f},i=o=>u=>{let s=o,a=u,c=!0,f;for(;c;){const d=s,l=a;if(l.tag==="Nil"){c=!1,f=d;continue}if(l.tag==="Cons"){s=en(d)(l._1),a=l._2;continue}g()}return f};return r(-999999)(n)-i(999999)(n)},Si=t=>e=>(n=>r=>{let i=n,o=r,u=!0,s;for(;u;){const a=i,c=o;if(a===e){u=!1,s=c;continue}i=(()=>{const f=ot(a)(t.align);if(f.tag==="Nothing")return e;if(f.tag==="Just")return f._1;g()})(),o=[...c,a]}return s})((()=>{const n=ot(e)(t.align);if(n.tag==="Nothing")return e;if(n.tag==="Just")return n._1;g()})())([e]),M2=t=>e=>n=>r=>i=>o=>u=>s=>a=>c=>f=>{const d=(G,I,D)=>{const B=G.from.node===I?G.from.port:G.to.node===I?G.to.port:T;if(B.tag==="Just"){const q=ot(I)(i);if(q.tag==="Just"){const V=Xt($=>$.id===B._1)(q._1);if(V.tag==="Just"){const $=rt(V._1.offset)*rt(4);return D==="North"||D==="South"?$:0}if(V.tag==="Nothing"){const $=ot(I)(r),X=Qr(u)(G.id)(D)((()=>{if($.tag==="Nothing")return .5;if($.tag==="Just")return $._1._1/2;g()})());return D==="North"||D==="South"?X:0}g()}if(q.tag==="Nothing"){const V=ot(I)(r),$=Qr(u)(G.id)(D)((()=>{if(V.tag==="Nothing")return .5;if(V.tag==="Just")return V._1._1/2;g()})());return D==="North"||D==="South"?$:0}g()}if(B.tag==="Nothing"){const q=ot(I)(r),V=Qr(u)(G.id)(D)((()=>{if(q.tag==="Nothing")return .5;if(q.tag==="Just")return q._1._1/2;g()})());return D==="North"||D==="South"?V:0}g()},l=(G,I)=>{if(G.from.node===I){if(f==="HRight")return he;if(f==="HLeft")return le;g()}if(f==="HRight")return le;if(f==="HLeft")return he;g()},_=(G,I,D)=>J(B=>q=>K(P)(q)((()=>{const V=ot(q)(B);if(V.tag==="Nothing")return 0+I;if(V.tag==="Just")return V._1+I;g()})())(B))(D)(Si(a)(G)),h=(()=>{if(f==="HRight")return n;if(f==="HLeft")return ke(n);g()})(),m=G=>{const I=ot(G)(r);if(I.tag==="Nothing")return 1;if(I.tag==="Just")return I._1._1;g()},p=Jn(Fe(At(G=>I=>O(D=>b(D,G))(I))(n))),y=(G,I)=>me(3)(G)==="$d:"&&me(3)(I)==="$d:"||me(3)(G)==="$d:"||me(3)(I)==="$d:"?10:rt(t.nodeGap),x=J(G=>I=>Bs(D=>w("Just",[...(()=>{if(D.tag==="Nothing")return[];if(D.tag==="Just")return D._1;g()})(),I]))(I.to.node)(G))(A)(o),N=J(G=>I=>Bs(D=>w("Just",[...(()=>{if(D.tag==="Nothing")return[];if(D.tag==="Just")return D._1;g()})(),I]))(I.from.node)(G))(A)(o),v=Fe(n),L=J(G=>I=>{const D=ot(I)(a.root),B=(()=>{if(D.tag==="Nothing")return I;if(D.tag==="Just")return D._1;g()})();return I===B?G:Bs(q=>w("Just",(()=>{if(q.tag==="Nothing")return!0;if(q.tag==="Just")return q._1;g()})()&&me(3)(I)==="$d:"))(B)(G)})(Jn(O(G=>b(G,!0))(Nr(P.compare)((()=>{const G=(I,D)=>{if(I.tag==="Leaf")return D;if(I.tag==="Node")return G(I._5,Ot("Cons",I._4,G(I._6,D)));g()};return kt($t.foldr,G(a.root,qt))})()))))(v),k=(G,I)=>{const D=G.free,B=ot(D)(a.root),q=(()=>{if(B.tag==="Nothing")return D;if(B.tag==="Just")return B._1;g()})(),V=ot(q)(L),$=(()=>{if(V.tag==="Nothing")return!0;if(V.tag==="Just")return V._1;g()})();return J(X=>M=>{if(X.edge.tag==="Just")return X;if(X.edge.tag==="Nothing"){if((()=>{const ct=ot(q)(I.su);return!$&&(()=>{const yt=ot(M.from.node)(p);return M.from.node!==M.to.node&&(()=>{const Et=ot(M.to.node)(p);return(()=>{if(yt.tag==="Nothing")return-1;if(yt.tag==="Just")return yt._1;g()})()===(()=>{if(Et.tag==="Nothing")return-1;if(Et.tag==="Just")return Et._1;g()})()})()})()||(()=>{if(ct.tag==="Nothing")return!1;if(ct.tag==="Just")return ct._1;g()})()})())return X;const et=M.from.node===D?M.to.node:M.from.node,tt=ot(et)(a.root),gt=(()=>{if(tt.tag==="Nothing")return et;if(tt.tag==="Just")return tt._1;g()})(),_t=gt!==q;return _t&&(()=>{const ct=ot(gt)(I.blockFinished);if(ct.tag==="Nothing")return!1;if(ct.tag==="Just")return ct._1;g()})()?{...X,edge:w("Just",M),hasEdges:!0}:{...X,hasEdges:X.hasEdges||_t}}g()})({edge:T,hasEdges:!1})((()=>{if(G.isRoot){if(f==="HRight"){const X=ot(D)(x);if(X.tag==="Nothing")return[];if(X.tag==="Just")return X._1;g()}if(f==="HLeft"){const X=ot(D)(N);if(X.tag==="Nothing")return[];if(X.tag==="Just")return X._1}g()}if(f==="HRight"){const X=ot(D)(N);if(X.tag==="Nothing")return[];if(X.tag==="Just")return X._1;g()}if(f==="HLeft"){const X=ot(D)(x);if(X.tag==="Nothing")return[];if(X.tag==="Just")return X._1}g()})())},E=(G,I,D,B)=>{const q=(()=>{if(c==="VDown")return-1e18;if(c==="VUp")return 1e18;g()})(),V={free:I,isRoot:D},$=k(V,B);if($.edge.tag==="Nothing")return $.hasEdges?{thresh:q,state:{...B,queue:[...B.queue,V]}}:{thresh:q,state:B};if($.edge.tag==="Just"){const X=$.edge._1.from.node===I?$.edge._1.to.node:$.edge._1.from.node;return{thresh:(()=>{const M=ot((()=>{const _t=ot(X)(a.root);if(_t.tag==="Nothing")return X;if(_t.tag==="Just")return _t._1;g()})())(B.x),et=ot(X)(s),tt=ot(I)(s),gt=(()=>{if(M.tag==="Just")return M._1;if(M.tag==="Nothing")return T;g()})();return(()=>{if(gt.tag==="Nothing")return 0;if(gt.tag==="Just")return gt._1;g()})()+(()=>{if(et.tag==="Nothing")return 0;if(et.tag==="Just")return et._1;g()})()+d($.edge._1,X,(()=>{if(D){if(f==="HRight")return he;if(f==="HLeft")return le;g()}if(f==="HRight")return le;if(f==="HLeft")return he;g()})())-(()=>{if(tt.tag==="Nothing")return 0;if(tt.tag==="Just")return tt._1;g()})()-d($.edge._1,I,(()=>{if(D){if(f==="HRight")return le;if(f==="HLeft")return he;g()}if(f==="HRight")return he;if(f==="HLeft")return le;g()})())})(),state:{...B,su:K(P)((()=>{const M=ot($.edge._1.from.node)(a.root);if(M.tag==="Nothing")return $.edge._1.from.node;if(M.tag==="Just")return M._1;g()})())(!0)(K(P)((()=>{const M=ot($.edge._1.to.node)(a.root);if(M.tag==="Nothing")return $.edge._1.to.node;if(M.tag==="Just")return M._1;g()})())(!0)(B.su))}}}g()},Q=(G,I,D,B)=>{const q=I===G,V=ot(I)(a.align),$=(()=>{if(V.tag==="Nothing")return I===G;if(V.tag==="Just")return V._1===G;g()})();if(!(q||$))return{thresh:D,state:B};const X=(()=>{if(c==="VDown")return q&&D<=-1e18;if(c==="VUp")return q&&D>=1e18;g()})()?E(G,I,!0,B):{thresh:D,state:B};return(()=>{if(c==="VDown")return X.thresh<=-1e18&&$;if(c==="VUp")return X.thresh>=1e18&&$;g()})()?E(G,I,!1,X.state):X},H=G=>I=>D=>{const B=ot(D)(e.nodeIndex),q=(()=>{if(B.tag==="Nothing")return 0;if(B.tag==="Just")return B._1;g()})(),V=Xt(tt=>Qe(gn)(D)(tt))(h),$=(()=>{if(V.tag==="Nothing")return[];if(V.tag==="Just")return V._1;g()})(),X=$.length;if((()=>{if(c==="VDown")return q<=0;if(c==="VUp")return q>=(X-1|0);g()})()){const tt=Q(G,D,I.thresh,I.st);return{...I,st:tt.state,thresh:tt.thresh}}const M=(()=>{if(c==="VDown")return q-1|0;if(c==="VUp")return q+1|0;g()})(),et=M>=0&&M<$.length?w("Just",$[M]):T;if(et.tag==="Nothing")return I;if(et.tag==="Just"){const tt=ot(et._1)(a.root),gt=(()=>{if(tt.tag==="Nothing")return et._1;if(tt.tag==="Just")return tt._1;g()})(),_t=Q(G,D,I.thresh,j(gt)(I.st)),ct=(()=>{const Vt=ot(G)(_t.state.sink);if(Vt.tag==="Nothing")return G===G;if(Vt.tag==="Just")return Vt._1===G;g()})()?{..._t.state,sink:K(P)(G)((()=>{const Vt=ot(gt)(_t.state.sink);if(Vt.tag==="Nothing")return gt;if(Vt.tag==="Just")return Vt._1;g()})())(_t.state.sink)}:_t.state,yt=ot(gt)(ct.sink),Et=(()=>{if(yt.tag==="Nothing")return gt;if(yt.tag==="Just")return yt._1;g()})(),Rt=ot(G)(ct.sink),pt=(()=>{if(Rt.tag==="Nothing")return G;if(Rt.tag==="Just")return Rt._1;g()})();if(pt===Et){const Vt=ot(gt)(ct.x),Pe=(()=>{if(Vt.tag==="Just")return Vt._1;if(Vt.tag==="Nothing")return T;g()})(),un=(()=>{if(Pe.tag==="Nothing")return 0;if(Pe.tag==="Just")return Pe._1;g()})(),Ne=ot(G)(ct.x),St=(()=>{if(Ne.tag==="Just")return Ne._1;if(Ne.tag==="Nothing")return T;g()})(),It=(()=>{if(St.tag==="Nothing")return 0;if(St.tag==="Just")return St._1;g()})(),je=y(D,et._1),Ze=ot(et._1)(s),kn=ot(D)(s),jr=(()=>{if(Ze.tag==="Nothing")return 0;if(Ze.tag==="Just")return Ze._1;g()})()-(()=>{if(kn.tag==="Nothing")return 0;if(kn.tag==="Just")return kn._1;g()})();if(c==="VDown"){const _n=Nn(un+jr+m(et._1)+je)(_t.thresh);return{st:{...ct,x:K(P)(G)(w("Just",I.initial?_n:Nn(It)(_n)))(ct.x)},initial:!1,thresh:_t.thresh}}if(c==="VUp"){const _n=en(un+jr-je-m(D))(_t.thresh);return{st:{...ct,x:K(P)(G)(w("Just",I.initial?_n:en(It)(_n)))(ct.x)},initial:!1,thresh:_t.thresh}}g()}const Qt=ot(gt)(ct.x),Jt=(()=>{if(Qt.tag==="Just")return Qt._1;if(Qt.tag==="Nothing")return T;g()})(),mt=(()=>{if(Jt.tag==="Nothing")return 0;if(Jt.tag==="Just")return Jt._1;g()})(),nt=ot(G)(ct.x),Z=(()=>{if(nt.tag==="Just")return nt._1;if(nt.tag==="Nothing")return T;g()})(),ut=(()=>{if(Z.tag==="Nothing")return 0;if(Z.tag==="Just")return Z._1;g()})(),ft=rt(t.nodeGap),lt=ot(D)(s),Nt=ot(et._1)(s),Ht=(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})()-(()=>{if(Nt.tag==="Nothing")return 0;if(Nt.tag==="Just")return Nt._1;g()})();return{st:{...ct,classEdges:[...ct.classEdges,{src:pt,tgt:Et,sep:(()=>{if(c==="VDown")return ut+Ht-mt-m(et._1)-ft;if(c==="VUp")return ut+Ht+m(D)+ft-mt;g()})()}]},initial:I.initial,thresh:_t.thresh}}g()},j=G=>I=>{const D=ot(G)(I.x),B=(()=>{if(D.tag==="Just")return D._1;if(D.tag==="Nothing")return T;g()})();if(B.tag==="Just")return I;if(B.tag==="Nothing"){const q=J(H(G))({st:{...I,x:K(P)(G)(w("Just",0))(I.x)},initial:!0,thresh:(()=>{if(c==="VDown")return-1e18;if(c==="VUp")return 1e18;g()})()})(Si(a)(G));return{...q.st,blockFinished:K(P)(G)(!0)(q.st.blockFinished)}}g()},S=J(G=>I=>J(D=>B=>{const q=ot(B)(a.root),V=(()=>{if(q.tag==="Nothing")return B;if(q.tag==="Just")return q._1;g()})();return V===B?j(V)(D):D})(G)((()=>{if(c==="VDown")return I;if(c==="VUp")return ke(I);g()})()))({x:Jn(O(G=>b(G,T))(v)),sink:Jn(O(G=>b(G,G))(v)),classEdges:[],su:A,blockFinished:A,queue:[]})(h),C=z2(S.classEdges)(S.sink)(c),U=(G,I,D,B)=>{const q=ot(I)(B),V=ot(I)(s);return(()=>{if(q.tag==="Nothing")return 0;if(q.tag==="Just")return q._1;g()})()+(()=>{if(V.tag==="Nothing")return 0;if(V.tag==="Just")return V._1;g()})()+d(G,I,D)},Y=Jn(O(G=>b(G,!0))(Nr(P.compare)((()=>{const G=(I,D)=>{if(I.tag==="Leaf")return D;if(I.tag==="Node")return G(I._5,Ot("Cons",I._4,G(I._6,D)));g()};return kt($t.foldr,G(a.root,qt))})()))),W=G=>I=>D=>{const B=k(D,{su:I.su,blockFinished:Y}),q={phase:G,ppFree:D.free,ppIsRoot:D.isRoot,edgeId:T,delta:0,avail:0,shift:0,freeSu:(()=>{const V=ot((()=>{const $=ot(D.free)(a.root);if($.tag==="Nothing")return D.free;if($.tag==="Just")return $._1;g()})())(I.su);if(V.tag==="Nothing")return!1;if(V.tag==="Just")return V._1;g()})(),hasEdges:B.hasEdges,candCount:(()=>{if(D.isRoot){if(f==="HRight"){const V=ot(D.free)(x);if(V.tag==="Nothing")return 0;if(V.tag==="Just")return V._1.length;g()}if(f==="HLeft"){const V=ot(D.free)(N);if(V.tag==="Nothing")return 0;if(V.tag==="Just")return V._1.length}g()}if(f==="HRight"){const V=ot(D.free)(N);if(V.tag==="Nothing")return 0;if(V.tag==="Just")return V._1.length;g()}if(f==="HLeft"){const V=ot(D.free)(x);if(V.tag==="Nothing")return 0;if(V.tag==="Just")return V._1.length}g()})()};if(B.edge.tag==="Nothing")return{...I,stack:[...I.stack,D],trace:[...I.trace,q],x:I.x};if(B.edge.tag==="Just"){const V=B.edge._1.from.node===D.free?b(B.edge._1.from.node,B.edge._1.to.node):b(B.edge._1.to.node,B.edge._1.from.node),$=U(B.edge._1,V._1,l(B.edge._1,V._1),I.x)-U(B.edge._1,V._2,l(B.edge._1,V._2),I.x),X=ot(V._1)(a.root),M=(()=>{if(X.tag==="Nothing")return V._1;if(X.tag==="Just")return X._1;g()})(),et={...q,edgeId:w("Just",B.edge._1.id),delta:$};if($>0&&$<1e300){const tt=J(ct=>yt=>{const Et=ot(yt)(p),Rt=(()=>{if(Et.tag==="Nothing")return-1;if(Et.tag==="Just")return Et._1;g()})();if(Rt>=0&&Rt<n.length){const Jt=n[Rt],mt=ot(yt)(e.nodeIndex),nt=(()=>{if(mt.tag==="Nothing")return-2;if(mt.tag==="Just")return mt._1-1|0;g()})();return nt>=0&&nt<Jt.length?en(ct)((()=>{const Z=ot(yt)(I.x),ut=ot(yt)(s),ft=ot(Jt[nt])(I.x),lt=ot(Jt[nt])(s);return(()=>{if(Z.tag==="Nothing")return 0;if(Z.tag==="Just")return Z._1;g()})()+(()=>{if(ut.tag==="Nothing")return 0;if(ut.tag==="Just")return ut._1;g()})()-((()=>{if(ft.tag==="Nothing")return 0;if(ft.tag==="Just")return ft._1;g()})()+(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})()+m(Jt[nt])+y(yt,Jt[nt]))})()):ct}const pt=ot(yt)(e.nodeIndex),Qt=(()=>{if(pt.tag==="Nothing")return-2;if(pt.tag==="Just")return pt._1-1|0;g()})();return Qt>=0&&Qt<0?en(ct)((()=>{const Jt=ot(yt)(I.x),mt=ot(yt)(s),nt=ot([][Qt])(I.x),Z=ot([][Qt])(s);return(()=>{if(Jt.tag==="Nothing")return 0;if(Jt.tag==="Just")return Jt._1;g()})()+(()=>{if(mt.tag==="Nothing")return 0;if(mt.tag==="Just")return mt._1;g()})()-((()=>{if(nt.tag==="Nothing")return 0;if(nt.tag==="Just")return nt._1;g()})()+(()=>{if(Z.tag==="Nothing")return 0;if(Z.tag==="Just")return Z._1;g()})()+m([][Qt])+y(yt,[][Qt]))})()):ct})($)(Si(a)(M)),gt=tt>0?-tt:0,_t={...I,x:tt>0?_(M,gt,I.x):I.x,trace:[...I.trace,{...et,avail:tt,shift:gt}]};return tt>0?_t:{..._t,stack:[..._t.stack,D]}}if($<0&&-$<1e300){const tt=J(ct=>yt=>{const Et=ot(yt)(p),Rt=(()=>{if(Et.tag==="Nothing")return-1;if(Et.tag==="Just")return Et._1;g()})();if(Rt>=0&&Rt<n.length){const Jt=n[Rt],mt=ot(yt)(e.nodeIndex),nt=(()=>{if(mt.tag==="Nothing")return 0;if(mt.tag==="Just")return mt._1+1|0;g()})();return nt>=0&&nt<Jt.length?en(ct)((()=>{const Z=ot(Jt[nt])(I.x),ut=ot(Jt[nt])(s),ft=ot(yt)(I.x),lt=ot(yt)(s);return(()=>{if(Z.tag==="Nothing")return 0;if(Z.tag==="Just")return Z._1;g()})()+(()=>{if(ut.tag==="Nothing")return 0;if(ut.tag==="Just")return ut._1;g()})()-((()=>{if(ft.tag==="Nothing")return 0;if(ft.tag==="Just")return ft._1;g()})()+(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})()+m(yt)+y(yt,Jt[nt]))})()):ct}const pt=ot(yt)(e.nodeIndex),Qt=(()=>{if(pt.tag==="Nothing")return 0;if(pt.tag==="Just")return pt._1+1|0;g()})();return Qt>=0&&Qt<0?en(ct)((()=>{const Jt=ot([][Qt])(I.x),mt=ot([][Qt])(s),nt=ot(yt)(I.x),Z=ot(yt)(s);return(()=>{if(Jt.tag==="Nothing")return 0;if(Jt.tag==="Just")return Jt._1;g()})()+(()=>{if(mt.tag==="Nothing")return 0;if(mt.tag==="Just")return mt._1;g()})()-((()=>{if(nt.tag==="Nothing")return 0;if(nt.tag==="Just")return nt._1;g()})()+(()=>{if(Z.tag==="Nothing")return 0;if(Z.tag==="Just")return Z._1;g()})()+m(yt)+y(yt,[][Qt]))})()):ct})(-$)(Si(a)(M)),gt=tt>0?tt:0,_t={...I,x:tt>0?_(M,gt,I.x):I.x,trace:[...I.trace,{...et,avail:tt,shift:gt}]};return tt>0?_t:{..._t,stack:[..._t.stack,D]}}return{...I,stack:[...I.stack,D],trace:[...I.trace,et],x:I.x}}g()},z=J(W(R2))({x:Jn(O(G=>b(G,(()=>{const I=ot(G)(a.root),D=(()=>{if(I.tag==="Nothing")return G;if(I.tag==="Just")return I._1;g()})(),B=ot(D)(S.x),q=ot((()=>{const $=ot(D)(S.sink);if($.tag==="Nothing")return D;if($.tag==="Just")return $._1;g()})())(C),V=(()=>{if(B.tag==="Just")return B._1;if(B.tag==="Nothing")return T;g()})();return(()=>{if(V.tag==="Nothing")return 0;if(V.tag==="Just")return V._1;g()})()+(()=>{if(q.tag==="Nothing")return 0;if(q.tag==="Just")return q._1;g()})()})()))(v)),su:S.su,stack:[],trace:[]})(S.queue),R=J(W(Q2))({...z,stack:[]})(ke(z.stack));return{x:R.x,queue:S.queue,trace:R.trace}},H2=t=>e=>n=>r=>i=>o=>u=>s=>a=>c=>f=>M2(t)(e)(n)(r)(i)(o)(u)(s)(a)(c)(f).x,O2=t=>e=>n=>r=>i=>o=>{const u=(a,c,f)=>{const d=ot(c)(n),l=(()=>{if(d.tag==="Nothing")return .5;if(d.tag==="Just")return d._1._1/2;g()})(),_=a.from.node===c?a.from.port:a.to.node===c?a.to.port:T;if(_.tag==="Just"){const h=ot(c)(e);if(h.tag==="Just"){const m=Xt(p=>p.id===_._1)(h._1);if(m.tag==="Just"){const p=rt(m._1.offset)*rt(4);return f==="North"||f==="South"?p:0}if(m.tag==="Nothing"){const p=Qr(i)(a.id)(f)(l);return f==="North"||f==="South"?p:0}g()}if(h.tag==="Nothing"){const m=Qr(i)(a.id)(f)(l);return f==="North"||f==="South"?m:0}g()}if(_.tag==="Nothing"){const h=Qr(i)(a.id)(f)(l);return f==="North"||f==="South"?h:0}g()},s=a=>c=>f=>d=>{let l=a,_=c,h=f,m=d,p=!0,y;for(;p;){const x=l,N=_,v=h,L=Bt(k=>T,k=>E=>w("Just",{head:k,tail:E}),m);if(L.tag==="Nothing"){p=!1,y=x;continue}if(L.tag==="Just"){const k=L._1.head,E=Xt(H=>H.from.node===v&&H.to.node===k||H.from.node===k&&H.to.node===v)(r),Q=(()=>{if(E.tag==="Nothing")return N+0;if(E.tag==="Just")return N+(u(E._1,v,E._1.from.node===v?he:le)-u(E._1,k,E._1.from.node===k?he:le));g()})();l=K(P)(k)(Q)(x),_=Q,h=k,m=L._1.tail;continue}g()}return y};return J(a=>c=>{const f=Bt(_=>T,_=>h=>w("Just",{head:_,tail:h}),Si(t)(c)),d=(()=>{if(f.tag==="Nothing")return K(P)(c)(0)(A);if(f.tag==="Just")return s(K(P)(f._1.head)(0)(A))(0)(f._1.head)(f._1.tail);g()})(),l=J(_=>h=>Nn(_)(-h._2))(0)(Fs(d));return J(_=>h=>K(P)(h._1)(h._2+l)(_))(a)(Fs(d))})(A)(Nr(P.compare)((()=>{const a=(c,f)=>{if(c.tag==="Leaf")return f;if(c.tag==="Node")return a(c._5,Ot("Cons",c._4,a(c._6,f)));g()};return kt($t.foldr,a(t.root,qt))})()))},q2=t=>e=>{const n=(i,o,u)=>me(3)(o)==="$d:"&&Wa(Ug,(()=>{const s=ot(o)(t.preds);if(s.tag==="Nothing")return[];if(s.tag==="Just")return s._1;g()})()),r=i=>o=>u=>s=>a=>c=>f=>{let d=i,l=o,_=s,h=c,m=f,p=!0,y;for(;p;){const x=d,N=l,v=_,L=h,k=m,E=N.length;if(k>=E){p=!1,y=x;continue}const Q=k>=0&&k<N.length?w("Just",N[k]):T,H=(()=>{if(Q.tag==="Nothing")return"";if(Q.tag==="Just")return Q._1;g()})(),j=n(t,H);if(k===(E-1|0)||j){const S=(()=>{if(j){const C=ot(H)(t.preds),U=(()=>{if(C.tag==="Nothing")return[];if(C.tag==="Just")return C._1;g()})();if(0<U.length){const Y=v-1|0,W=ot(U[0])(t.nodeIndex);if(W.tag==="Nothing")return Y;if(W.tag==="Just")return W._1;g()}}return v-1|0})();d=J(C=>U=>{if(U>=0&&U<N.length){const Y=N[U];return n(t,Y)?C:J(W=>z=>{const R=ot(z)(t.nodeIndex),G=(()=>{if(R.tag==="Nothing")return 0;if(R.tag==="Just")return R._1;g()})();return G<L||G>S?K(P)(z+"\u2192"+Y)()(W):W})(C)((()=>{const W=ot(Y)(t.preds);if(W.tag==="Nothing")return[];if(W.tag==="Just")return W._1;g()})())}return n(t,"")?C:J(Y=>W=>{const z=ot(W)(t.nodeIndex),R=(()=>{if(z.tag==="Nothing")return 0;if(z.tag==="Just")return z._1;g()})();return R<L||R>S?K(P)(W+"\u2192")()(Y):Y})(C)((()=>{const Y=ot("")(t.preds);if(Y.tag==="Nothing")return[];if(Y.tag==="Just")return Y._1;g()})())})(x)(Dt(0,k)),l=N,_=v,h=S,m=k+1|0;continue}d=x,l=N,_=v,h=L,m=k+1|0}return y};return e.length<3?A:J(i=>o=>{if(o>=0&&o<e.length){const u=e[o];return r(i)((()=>{const s=o+1|0;return s>=0&&s<e.length?e[s]:[]})())(u)(u.length)(o)(0)(0)}return r(i)((()=>{const u=o+1|0;return u>=0&&u<e.length?e[u]:[]})())([])(0)(o)(0)(0)})(A)(Dt(1,e.length-2|0))},$2=t=>e=>n=>r=>i=>{const o=Fe(e),u=J(s=>a=>{const c=J(f=>d=>{const l=(()=>{if(i==="HRight"){const p=ot(d)(t.preds);if(p.tag==="Nothing")return[];if(p.tag==="Just")return p._1;g()}if(i==="HLeft"){const p=ot(d)(t.succs);if(p.tag==="Nothing")return[];if(p.tag==="Just")return p._1}g()})(),_=l.length;if(_===0)return f;const h=En(_-1|0,2),m=En(_,2);return J(p=>y=>{if((()=>{const x=ot(d)(p.align);if(x.tag==="Nothing")return d!==d;if(x.tag==="Just")return x._1!==d;g()})())return p;if(y>=0&&y<l.length){const x=ot(l[y])(t.nodeIndex),N=(()=>{if(x.tag==="Nothing")return 0;if(x.tag==="Just")return x._1;g()})();if(!(sf(l[y]+"\u2192"+d)(n)||sf(d+"\u2192"+l[y])(n))&&(()=>{if(r==="VDown")return p.r<N;if(r==="VUp")return p.r>N;g()})()){const v=ot(l[y])(p.root),L=(()=>{if(v.tag==="Nothing")return l[y];if(v.tag==="Just")return v._1;g()})();return{root:K(P)(d)(L)(p.root),align:K(P)(l[y])(d)(K(P)(d)(L)(p.align)),r:N}}}return p})(f)((()=>{if(r==="VDown")return Dt(h,m);if(r==="VUp")return ke(Dt(h,m));g()})())})({root:s.root,align:s.align,r:(()=>{if(r==="VDown")return-1;if(r==="VUp")return 999999;g()})()})((()=>{if(r==="VDown")return a;if(r==="VUp")return ke(a);g()})());return{root:c.root,align:c.align}})({root:Jn(O(s=>b(s,s))(o)),align:Jn(O(s=>b(s,s))(o))})((()=>{if(i==="HRight")return e;if(i==="HLeft")return ke(e);g()})());return{root:u.root,align:u.align}},Ro=t=>e=>n=>r=>i=>o=>u=>s=>a=>c=>{const f=$2(e)(n)(s)(a)(c),d=O2(f)(i)(r)(o)(u)(c);return Nd()(l=>_=>w("Just",(()=>{const h=ot(l)(d);if(h.tag==="Nothing")return _+0;if(h.tag==="Just")return _+h._1;g()})()))(H2(t)(e)(n)(r)(i)(o)(u)(d)(f)(a)(c))},cf=t=>e=>At(n=>r=>J(i=>o=>o>=0&&o<e.length?o>=0&&o<t.length?i+e[o]+t[o]:i+e[o]+0:o>=0&&o<t.length?i+1+t[o]:i+1)(0)((()=>{const i=Dt(0,e.length-1|0);return n<1?[]:bt(0,n,i)})()))(e),Y2=t=>e=>n=>r=>i=>o=>u=>{const s=B2(0)(e.length-1|0),a=rt(t.layerGap),c=u(id(s,a)),f=Vm(Yg(i)(c)(r)(o)(A))(c);return O(d=>{const l=F2(d)(f);return l.tag==="Just"&&l._1>0?Nn(a)(2+rt(l._1-1|0)*2.5):a})(Dt(0,s-1|0))},gf=t=>e=>n=>r=>Wa(i=>J(o=>u=>{if(!o.ok)return o;const s=ot(u)(r),a=(()=>{if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})(),c=ot(u)(n),f=(()=>{if(c.tag==="Nothing")return a+1;if(c.tag==="Just")return a+c._1._1;g()})();return a+1e-4>o.pos&&f+1e-4>o.pos?{ok:!0,pos:f}:{ok:!1,pos:o.pos}})({ok:!0,pos:-1e18})(i).ok,e),X2=t=>e=>n=>r=>{const i=Lt(o=>u=>st.compare(o.w)(u.w))(O(o=>({l:o,w:af(o)}))(at(gf()(e)(n),r)));return 0<i.length?w("Just",i[0].l):T},V2=t=>e=>{const n=Jn(Fe(O(At(i=>o=>b(o,i)))(t))),r=i=>Lt(o=>u=>it.compare((()=>{const s=ot(o)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})())((()=>{const s=ot(u)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(i);return{preds:(()=>{const i=o=>{if(o.tag==="Leaf")return A;if(o.tag==="Node")return Mt("Node",o._1,o._2,o._3,r(o._4),i(o._5),i(o._6));g()};return i(J(o=>u=>vt(P)(te)(u.to.node)([u.from.node])(o))(A)(e))})(),succs:(()=>{const i=o=>{if(o.tag==="Leaf")return A;if(o.tag==="Node")return Mt("Node",o._1,o._2,o._3,r(o._4),i(o._5),i(o._6));g()};return i(J(o=>u=>vt(P)(te)(u.from.node)([u.to.node])(o))(A)(e))})(),nodeIndex:n}},U2=t=>e=>{const n=Lt(d=>l=>st.compare(d.w)(l.w))(At(d=>l=>({i:d,l,w:af(l)}))(e)),r=0<n.length?w("Just",n[0]):T,i=(()=>{if(r.tag==="Just")return r._1.i;if(r.tag==="Nothing")return 0;g()})(),o=i>=0&&i<e.length?w("Just",e[i]):T,u=(()=>{if(o.tag==="Just")return(d=>l=>{let _=d,h=l,m=!0,p;for(;m;){const y=_,x=h;if(x.tag==="Nil"){m=!1,p=y;continue}if(x.tag==="Cons"){_=en(y)(x._1),h=x._2;continue}g()}return p})(999999)((()=>{const d=(l,_)=>{if(l.tag==="Leaf")return _;if(l.tag==="Node")return d(l._5,Ot("Cons",l._4,d(l._6,_)));g()};return d(o._1,qt)})());if(o.tag==="Nothing")return 0;g()})(),s=d=>J(l=>_=>Nn(l)((()=>{const h=ot(_._1)(t);if(h.tag==="Nothing")return _._2+1;if(h.tag==="Just")return _._2+h._1._1;g()})()))(-999999)(Fs(d)),a=i>=0&&i<e.length?w("Just",e[i]):T,c=(()=>{if(a.tag==="Just")return s(a._1);if(a.tag==="Nothing")return 0;g()})(),f=Je(d=>l=>{const _=h=>{if(h.tag==="Leaf")return A;if(h.tag==="Node")return Mt("Node",h._1,h._2,h._3,h._4+l,_(h._5),_(h._6));g()};return _(d)},e,At(d=>l=>Xn(d)(2)===0?u-(_=>h=>{let m=_,p=h,y=!0,x;for(;y;){const N=m,v=p;if(v.tag==="Nil"){y=!1,x=N;continue}if(v.tag==="Cons"){m=en(N)(v._1),p=v._2;continue}g()}return x})(999999)((()=>{const _=(h,m)=>{if(h.tag==="Leaf")return m;if(h.tag==="Node")return _(h._5,Ot("Cons",h._4,_(h._6,m)));g()};return _(l,qt)})()):c-s(l))(e));return W2(J(d=>l=>{const _=Lt(st.compare)(xt(ot(l))(f));return K(P)(l)(_.length===4?1<_.length&&2<_.length?(_[1]+_[2])/2:0:0<_.length?_[0]:0)(d)})(A)(Nr(P.compare)(Fe(O(d=>{const l=_=>{if(_.tag==="Leaf")return A;if(_.tag==="Node")return Mt("Node",_._1,_._2,_._3,void 0,l(_._5),l(_._6));g()};return kt(We.foldr,l(d))})(f)))))},j2=t=>e=>n=>r=>i=>o=>{const u=V2(e)(i),s=q2(u)(e),a={nodeGap:t.nodeGap*4|0},c=Ce(P.compare,Le,Jn(O(_=>b(_,b(1,1)))(at(Ug,Fe(e)))),(()=>{const _=h=>{if(h.tag==="Leaf")return A;if(h.tag==="Node")return Mt("Node",h._1,h._2,h._3,b(h._4._1*rt(4),h._4._2),_(h._5),_(h._6));g()};return _(n)})()),f=[Ro(a)(u)(e)(c)(r)(i)(o)(s)(nf)(of),Ro(a)(u)(e)(c)(r)(i)(o)(s)(rf)(of),Ro(a)(u)(e)(c)(r)(i)(o)(s)(nf)(uf),Ro(a)(u)(e)(c)(r)(i)(o)(s)(rf)(uf)],d=U2(c)(f);if(gf()(e)(c)(d))return d;const l=X2()(e)(c)(f);if(l.tag==="Just")return l._1;if(l.tag==="Nothing")return f[0];g()},Z2=t=>e=>n=>r=>{const i=Fa(T,Ga,o=>o.node===e?w("Just",o.position):T,t);if(i.tag==="Nothing")return t;if(i.tag==="Just"){const o=i._1;return O(u=>u.node===n?{...u,position:b(o._1+r._1,o._2+r._2)}:u)(t)}g()},K2=t=>e=>n=>r=>{const i=at(u=>Qe(gn)(u.node)(e),t),o=(()=>{if(n==="Vertical"){if(r==="Start")return J(u=>s=>en(u)(s.position._1))(99999)(i);if(r==="End")return J(u=>s=>Nn(u)(s.position._1))(0)(i);if(r==="Center"){const u=J(s=>a=>s+a.position._1)(0)(i);return i.length===0?0:u/rt(i.length)}g()}if(n==="Horizontal"){if(r==="Start")return J(u=>s=>en(u)(s.position._2))(99999)(i);if(r==="End")return J(u=>s=>Nn(u)(s.position._2))(0)(i);if(r==="Center"){const u=J(s=>a=>s+a.position._2)(0)(i);return i.length===0?0:u/rt(i.length)}}g()})();return O(u=>{if(Qe(gn)(u.node)(e)){if(n==="Vertical")return{...u,position:b(o,u.position._2)};if(n==="Horizontal")return{...u,position:b(u.position._1,o)};g()}return u})(t)},ty=t=>e=>J(n=>r=>r.tag==="AlignGroup"?K2(n)(r._1.nodes)(r._1.axis)(r._1.alignment):r.tag==="RelativePosition"?Z2(n)(r._1.anchor)(r._1.target)(r._1.offset):n)(e)(t),ey=t=>e=>n=>r=>i=>o=>u=>s=>{const a=O(d=>J(l=>_=>Nn(l)((()=>{const h=ot(_)(r);if(h.tag==="Nothing")return 1;if(h.tag==="Just")return h._1._2;g()})()))(1)(d))(n),c=j2(t)(n)(r)(i)(o)(s),f=cf(Y2(t)(n)(r)(i)(o)(u)(d=>{const l=cf(d)(a);return Fe(At(_=>h=>At(m=>p=>({node:p,position:b((()=>{const y=ot(p)(c);return(()=>{if(y.tag==="Nothing")return 0;if(y.tag==="Just")return y._1;g()})()/rt(4)})(),_>=0&&_<l.length?l[_]:0),size:(()=>{const y=me(3)(p)==="$d:"?b(0,1):b(1,1),x=ot(p)(r);if(x.tag==="Nothing")return y;if(x.tag==="Just")return x._1;g()})(),layer:_,order:m}))(h))(n))}))(a);return ty(e)(Fe(At(d=>l=>At(_=>h=>({node:h,position:b((()=>{const m=ot(h)(c);return(()=>{if(m.tag==="Nothing")return 0;if(m.tag==="Just")return m._1;g()})()/rt(4)})(),d>=0&&d<f.length?f[d]:0),size:(()=>{const m=me(3)(h)==="$d:"?b(0,1):b(1,1),p=ot(h)(r);if(p.tag==="Nothing")return m;if(p.tag==="Just")return p._1;g()})(),layer:d,order:_}))(l))(n)))},Rs=Hu(uo)(gr(32)),ff=Hu(uo)(gr(31)),Gi=(()=>{const t=ml("25214903917");if(t.tag==="Nothing")return oc;if(t.tag==="Just")return t._1;g()})(),Pi=Mu(Hu(uo)(gr(48)))(uo),ny=t=>{const e=yl(t);return gi(uc((()=>{if(e.tag==="Nothing")return oc;if(e.tag==="Just")return e._1;g()})())(Gi))(Pi)},Qs=gr(11),Qo=t=>e=>{const n=gi(io(oo(e)(Gi))(Qs))(Pi);return b((()=>{const r=Ya(dl(Ou(n)(gr(48-t|0))));if(r.tag==="Nothing")return 0;if(r.tag==="Just")return r._1;g()})(),n)},ry=t=>{const e=Qo(26)(t),n=Qo(27)(e._2);return b((rt(e._1)*bu(2)(27)+rt(n._1))/bu(2)(53),n._2)},iy=t=>e=>{const n=J(r=>i=>{const o=ry(r.finalR);return{rs:[...r.rs,o._1],finalR:o._2}})({rs:[],finalR:t})(e);return b(O(r=>r.x)(Lt(r=>i=>st.compare(r.k)(i.k))(Je(r=>i=>({x:r,k:i}),e,n.rs))),n.finalR)},oy=t=>{const e=gi(io(oo(t)(Gi))(Qs))(Pi),n=gi(io(oo(e)(Gi))(Qs))(Pi);return b(io(oo((()=>{const r=Ou(e)(gr(16));return sc.compare(r)(ff)!=="LT"?Mu(r)(Rs):r})())(Rs))((()=>{const r=Ou(n)(gr(16));return sc.compare(r)(ff)!=="LT"?Mu(r)(Rs):r})()),n)},Ii=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},zo=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},zs=Kt(P)(zt),zr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Wo=Kt(P)(zt),uy=vu(ti),sy=J(Tr)(0),ay=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},_f=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},cy=t=>e=>n=>{if(t>=0&&t<n.length){const r=n[t];if(e>=0&&e<n.length){const i=qn(Yt,T,t,n[e],n);if(i.tag==="Just")return qn(Yt,T,e,r,i._1);if(i.tag==="Nothing")return T;g()}}return T},gy=t=>e=>n=>r=>i=>zs(J(o=>u=>{const s=Lt(a=>c=>it.compare((()=>{const f=Ii(a.id)(i);if(f.tag==="Nothing")return 1e6;if(f.tag==="Just")return f._1;g()})())((()=>{const f=Ii(c.id)(i);if(f.tag==="Nothing")return 1e6;if(f.tag==="Just")return f._1;g()})()))(at(a=>zo(a.to.node)(n),at(a=>a.from.node===u,r)));return{ranks:[...o.ranks,...At(a=>c=>b(c.id,rt((o.rankSum+a|0)+1|0)))(s)],rankSum:o.rankSum+s.length|0}})({ranks:[],rankSum:0})(t).ranks),fy=t=>e=>n=>r=>i=>zs(J(o=>u=>{const s=Lt(c=>f=>{const d=it.compare((()=>{const l=zr(f.from.node)(n);if(l.tag==="Nothing")return-1;if(l.tag==="Just")return l._1;g()})())((()=>{const l=zr(c.from.node)(n);if(l.tag==="Nothing")return-1;if(l.tag==="Just")return l._1;g()})());return d==="EQ"?it.compare((()=>{const l=Ii(c.id)(i);if(l.tag==="Nothing")return 1e6;if(l.tag==="Just")return l._1;g()})())((()=>{const l=Ii(f.id)(i);if(l.tag==="Nothing")return 1e6;if(l.tag==="Just")return l._1;g()})()):d})(at(c=>zo(c.from.node)(n),at(c=>c.to.node===u,r))),a=s.length;return{ranks:[...o.ranks,...At(c=>f=>b(f.id,rt((o.rankSum+a|0)-c|0)))(s)],rankSum:o.rankSum+a|0}})({ranks:[],rankSum:0})(t).ranks),Ws=t=>e=>n=>{const r=Wo(At(s=>a=>b(a,s))(t)),i=Wo(At(s=>a=>b(a,s))(e)),o=xt(s=>{const a=zr(s.from.node)(r),c=zr(s.to.node)(i);if(a.tag==="Just"&&c.tag==="Just")return w("Just",b(a._1,c._1));const f=zr(s.from.node)(i),d=zr(s.to.node)(r);return f.tag==="Just"&&d.tag==="Just"?w("Just",b(d._1,f._1)):T})(n),u=o.length;return J(s=>a=>J(c=>f=>a>=0&&a<o.length&&f>=0&&f<o.length&&((o[a]._1-o[f]._1|0)*(o[a]._2-o[f]._2|0)|0)<0?c+1|0:c)(s)(Dt(a+1|0,u-1|0)))(0)(Dt(0,u-2|0))},_y=t=>e=>n=>r=>{const i=o=>u=>{let s=o,a=u,c=!0,f;for(;c;){const d=s,l=a;if(l>=(d.length-1|0)){c=!1,f=d;continue}if(l>=0&&l<d.length){const _=l+1|0;if(_>=0&&_<d.length){const h=d[l],m=d[_];if(Re(N=>N.before===h&&N.after===m,r)){s=d,a=l+1|0;continue}const p=qn(Yt,T,l,m,d),y=(()=>{if(p.tag==="Just")return qn(Yt,T,l+1|0,h,p._1);if(p.tag==="Nothing")return T;g()})(),x=(()=>{if(y.tag==="Nothing")return d;if(y.tag==="Just")return y._1;g()})();if(Ws(e)(x)(n)<Ws(e)(d)(n)){s=x,a=l+1|0;continue}s=d,a=l+1|0;continue}c=!1,f=d;continue}c=!1,f=d}return f};return(o=>{let u=o,s=!0,a;for(;s;){const c=u,f=i(c)(0);if(uy(f)(c)){s=!1,a=c;continue}u=f}return a})(t)},Mo=t=>e=>J(n=>r=>{if(r>=0&&r<t.length){const i=t[r],o=r+1|0;if(o>=0&&o<t.length)return n+Ws(i)(t[o])(e)|0}return n})(0)(Dt(0,t.length-2|0)),dy=(()=>{const t=e=>{if(e.length<7){const o=u=>s=>{let a=u,c=s,f=!0,d;for(;f;){const l=a,_=c,h=_-1|0;if(h>=0&&h<l.length){if(_>=0&&_<l.length&&_>0&&l[h].key>l[_].key){const m=cy(_-1|0)(_)(l);if(m.tag==="Just"){a=m._1,c=_-1|0;continue}if(m.tag==="Nothing"){f=!1,d=l;continue}g()}f=!1,d=l;continue}f=!1,d=l}return d};return J(u=>s=>o(u)(s))(e)(Dt(1,e.length-1|0))}const n=En(e.length,2),r=t(bt(0,n,e)),i=t(bt(n,e.length,e));return(o=>u=>s=>{let a=o,c=u,f=s,d=!0,l;for(;d;){const _=a,h=c,m=f;if(h>=0&&h<r.length){if(m>=0&&m<i.length){if(r[h].key>i[m].key){a=Ft(_)(i[m]),c=h,f=m+1|0;continue}a=Ft(_)(r[h]),c=h+1|0,f=m;continue}d=!1,l=[..._,...h<1?r:bt(h,r.length,r)];continue}d=!1,l=[..._,...m<1?i:bt(m,i.length,i)]}return l})([])(0)(0)};return t})(),ly=t=>e=>n=>{const r=xt(c=>c.tag==="OrderConstraint"?w("Just",{before:c._1.before,after:c._1.after}):T)(t.constraints),i=c=>J(f=>d=>{const l=d.after,_=d.before,h=On(Yt,T,p=>p===_,f),m=On(Yt,T,p=>p===l,f);if(h.tag==="Just"&&m.tag==="Just"&&h._1>m._1){const p=za(Yt,T,h._1,f),y=(()=>{if(p.tag==="Nothing")return f;if(p.tag==="Just")return p._1;g()})(),x=Qa(Yt,T,m._1,_,y);if(x.tag==="Nothing")return y;if(x.tag==="Just")return x._1;g()}return f})(c)(r),o=zs(At(c=>f=>b(f.id,c))(n)),u=(c,f,d)=>{const l=c.length;return J(_=>h=>{const m=f?h-1|0:h+1|0,p=m>=0&&m<_._1.length?w("Just",_._1[m]):T;if(p.tag==="Just"){const y=h>=0&&h<_._1.length?w("Just",_._1[h]):T;if(y.tag==="Just"){const x=Wo(At(E=>Q=>b(Q,E))(p._1)),N=Wo(At(E=>Q=>b(Q,E))(y._1)),v=f?gy(p._1)(x)(N)(n)(o):fy(p._1)(x)(N)(n)(o),L=J(E=>Q=>{const H=xt(S=>Ii(S.id)(v))(at(f?S=>S.to.node===Q._2&&zo(S.from.node)(x):S=>S.from.node===Q._2&&zo(S.to.node)(x),n));if(H.length===0)return{...E,items:[...E.items,{n:Q._2,key:T,origIdx:Q._1}]};const j=Qo(24)(E.r);return{items:[...E.items,{n:Q._2,key:w("Just",(sy(H)+(rt(j._1)*4172325152040912e-24-.03500000014901161))/rt(H.length)),origIdx:Q._1}],r:j._2}})({items:[],r:_._2})(At(Hn)(y._1)),k=qn(Yt,T,h,_y(i(O(E=>E.n)(dy((()=>{const E=L.items,Q=H=>j=>{let S=H,C=j,U=!0,Y;for(;U;){const W=S,z=C;if(W>=0&&W<E.length){if(E[W].key.tag==="Just"){U=!1,Y=E[W].key._1;continue}if(E[W].key.tag==="Nothing"){S=W+1|0,C=z;continue}g()}U=!1,Y=z}return Y};return(H=>j=>S=>{let C=H,U=j,Y=S,W=!0,z;for(;W;){const R=C,G=U,I=Y;if(R>=0&&R<E.length){if(E[R].key.tag==="Just"){C=R+1|0,U=E[R].key._1,Y=[...I,{n:E[R].n,key:E[R].key._1,origIdx:E[R].origIdx}];continue}if(E[R].key.tag==="Nothing"){const D=(G+Q(R+1|0)(G+1))/2;C=R+1|0,U=D,Y=[...I,{n:E[R].n,key:D,origIdx:E[R].origIdx}];continue}g()}W=!1,z=I}return z})(0)(-1)([])})()))))(p._1)(n)(r),_._1);if(k.tag==="Just")return b(k._1,L.r);if(k.tag==="Nothing")return b(_._1,_._2);g()}if(y.tag==="Nothing")return b(_._1,_._2);g()}if(p.tag==="Nothing")return b(_._1,_._2);g()})(b(c,d))(f?Dt(1,l-1|0):ke(Dt(0,l-2|0)))},s=J(c=>f=>K(P)(f.from.node)()(K(P)(f.to.node)()(c)))(A)(n),a=J(c=>f=>{if(c.result.crossings===0)return c;const d=x=>N=>v=>L=>{let k=x,E=N,Q=v,H=L,j=!0,S;for(;j;){const C=k,U=E,Y=Q,W=H;if(Y===0){j=!1,S={layout:C,crossings:0,random:W};continue}const z=u(C,U,W),R=Mo(z._1)(n);if(R<Y){k=z._1,E=!U,Q=R,H=z._2;continue}j=!1,S={layout:C,crossings:Y,random:z._2}}return S},l=Qo(1)(c.result.random),_=l._1!==0,h=t.modelOrder.tag==="Leaf",m=(c.firstTry||c.secondTry)&&!h?c.firstTry:_,p=(()=>{if(!h){const L=u(e,m,l._2);return d(L._1)(!m)(Mo(L._1)(n))(L._2)}const x=m?0:ay(0)(e.length-1|0),N=x>=0&&x<e.length?w("Just",e[x]):T;if(N.tag==="Just"&&N._1.length>1){const L=at(k=>_f(k)(s),N._1);if(L.length>1){const k=iy(l._2)(L),E=k._1,Q=qn(Yt,T,x,i(J(H=>j=>_f(j)(s)?H.idx>=0&&H.idx<E.length?{idx:H.idx+1|0,result:[...H.result,E[H.idx]]}:{idx:H.idx,result:[...H.result,j]}:{idx:H.idx,result:[...H.result,j]})({idx:0,result:[]})(N._1).result),e);if(Q.tag==="Just"){const H=u(Q._1,m,k._2);return d(H._1)(!m)(Mo(H._1)(n))(H._2)}}}const v=u(e,m,l._2);return d(v._1)(!m)(Mo(v._1)(n))(v._2)})(),y=c.secondTry?!1:c.secondTry;return c.firstTry?{result:p.crossings<c.result.crossings?{layout:p.layout,crossings:p.crossings,random:p.random}:{...c.result,random:p.random},firstTry:!1,secondTry:!0}:{result:p.crossings<c.result.crossings?{layout:p.layout,crossings:p.crossings,random:p.random}:{...c.result,random:p.random},firstTry:c.firstTry,secondTry:y}})({result:{layout:e,crossings:1e9,random:gi(uc(oy(ny(1))._1)(Gi))(Pi)},firstTry:t.modelOrder.tag!=="Leaf",secondTry:!1})(Dt(1,t.iterations)).result;return e.length<=0||t.iterations<=0?e:a.layout},hy=t=>t,df=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},De=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Wr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Di=(()=>{const t={eq:e=>n=>e._1===n._1&&e._2===n._2};return{compare:e=>n=>{const r=P.compare(e._1)(n._1);return r==="LT"?ye:r==="GT"?xe:P.compare(e._2)(n._2)},Eq0:()=>t}})(),py=Kt(P)(zt),my=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=Di.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},yy=hy("Greedy"),Ms=t=>e=>n=>J(r=>i=>{if(i.from.node===i.to.node)return r;if(i.from.node===e&&!df(i.to.node)(r.marks)){const o=De(i.to.node)(r.inDeg),u=(()=>{if(o.tag==="Nothing")return-1;if(o.tag==="Just")return o._1-1|0;g()})(),s=K(P)(i.to.node)(u)(r.inDeg);return(()=>{const a=De(i.to.node)(r.outDeg);return u<=0&&(()=>{if(a.tag==="Nothing")return!1;if(a.tag==="Just")return a._1>0;g()})()&&!Qe(gn)(i.to.node)(r.sources)})()?{...r,inDeg:s,sources:[...r.sources,i.to.node]}:{...r,inDeg:s}}if(i.to.node===e&&!df(i.from.node)(r.marks)){const o=De(i.from.node)(r.outDeg),u=(()=>{if(o.tag==="Nothing")return-1;if(o.tag==="Just")return o._1-1|0;g()})(),s=K(P)(i.from.node)(u)(r.outDeg);return(()=>{const a=De(i.from.node)(r.inDeg);return u<=0&&(()=>{if(a.tag==="Nothing")return!1;if(a.tag==="Just")return a._1>0;g()})()&&!Qe(gn)(i.from.node)(r.sinks)})()?{...r,outDeg:s,sinks:[...r.sinks,i.from.node]}:{...r,outDeg:s}}return r})({...n,remaining:at(r=>r!==e,n.remaining)})(t),xy=J(t=>e=>{if(e.tag==="LayerConstraint"){if(e._1.pin.tag==="SpecificLayer")return K(P)(e._1.node)(e._1.pin._1)(t);if(e._1.pin.tag==="FirstLayer")return K(P)(e._1.node)(0)(t);if(e._1.pin.tag==="LastLayer")return K(P)(e._1.node)(99999)(t)}return t})(A),lf=t=>e=>n=>{const r=De(e)(t),i=De(n)(t);return r.tag==="Just"&&i.tag==="Just"&&r._1>i._1},hf=t=>e=>n=>r=>{if(Wr(n)(r.visited)||Wr(n)(r.visiting))return r;const i=J(Ny(t)(e)(n))({...r,visiting:K(P)(n)()(r.visiting)})((()=>{const o=De(n)(e);if(o.tag==="Nothing")return[];if(o.tag==="Just")return o._1;g()})());return{...i,visiting:ni(P)(n)(i.visiting),visited:K(P)(n)()(i.visited)}},Ny=t=>e=>n=>r=>i=>lf(t)(n)(i)?{...r,backEdges:K(Di)(b(n,i))()(r.backEdges)}:Wr(i)(r.visiting)?{...r,backEdges:K(Di)(b(n,i))()(r.backEdges)}:Wr(i)(r.visited)?r:hf(t)(e)(i)(r),Jy=t=>e=>n=>{const r=l=>{let _=l,h=!0,m;for(;h;){const p=_,y=Bt(x=>T,x=>N=>w("Just",{head:x,tail:N}),p.sinks);if(y.tag==="Just"){_=Ms(n)(y._1.head)({...p,sinks:y._1.tail,marks:K(P)(y._1.head)(p.nextRight)(p.marks),nextRight:p.nextRight-1|0});continue}if(y.tag==="Nothing"){const x=Bt(N=>T,N=>v=>w("Just",{head:N,tail:v}),p.sources);if(x.tag==="Just"){_=Ms(n)(x._1.head)({...p,sources:x._1.tail,marks:K(P)(x._1.head)(p.nextLeft)(p.marks),nextLeft:p.nextLeft+1|0});continue}if(x.tag==="Nothing"){const N=L=>{const k=De(L)(p.outDeg),E=De(L)(p.inDeg);return(()=>{if(k.tag==="Nothing")return 0;if(k.tag==="Just")return k._1;g()})()-(()=>{if(E.tag==="Nothing")return 0;if(E.tag==="Just")return E._1;g()})()|0},v=Lt(L=>k=>{const E=it.compare(N(k))(N(L));return E==="EQ"?it.compare((()=>{const Q=De(L)(e);if(Q.tag==="Nothing")return 1e6;if(Q.tag==="Just")return Q._1;g()})())((()=>{const Q=De(k)(e);if(Q.tag==="Nothing")return 1e6;if(Q.tag==="Just")return Q._1;g()})()):E})(p.remaining);if(0<v.length){const L=v[0];_=Ms(n)(L)({...p,remaining:at(k=>k!==L,p.remaining),marks:K(P)(L)(p.nextLeft)(p.marks),nextLeft:p.nextLeft+1|0});continue}h=!1,m=p;continue}}g()}return m},i=Nr(P.compare)([...O(l=>l.from.node)(n),...O(l=>l.to.node)(n)]),o=at(l=>l.from.node!==l.to.node,n),u=J(l=>_=>vt(P)(oe)(_.to.node)(1)(l))(A)(o),s=J(l=>_=>vt(P)(oe)(_.from.node)(1)(l))(A)(o),a=at(l=>{const _=De(l)(u);if(_.tag==="Nothing")return!0;if(_.tag==="Just")return _._1===0;g()},i),c=at(l=>{const _=De(l)(s);if(_.tag==="Nothing")return!0;if(_.tag==="Just")return _._1===0;g()},i),f=i.length+1|0,d=J(l=>_=>{const h=De(_)(l);return h.tag==="Just"&&h._1<0?K(P)(_)(h._1+f|0)(l):l})(r({remaining:at(l=>!Qe(gn)(l)(a)&&!Qe(gn)(l)(c),i),marks:A,inDeg:u,outDeg:s,sources:a,sinks:c,nextLeft:1,nextRight:-1}).marks)(i);return J(l=>_=>{if(_.from.node===_.to.node)return l;if(lf(t)(_.from.node)(_.to.node))return K(Di)(b(_.from.node,_.to.node))()(l);const h=De(_.from.node)(d),m=De(_.to.node)(d);return h.tag==="Just"&&m.tag==="Just"&&h._1>m._1?K(Di)(b(_.from.node,_.to.node))()(l):l})(A)(n)},Ty=J(t=>e=>vt(P)(te)(e.from.node)([e.to.node])(t))(A),vy=t=>e=>{const n=Ty(e),r=Nr(P.compare)([...O(o=>o.from.node)(e),...O(o=>o.to.node)(e)]),i=J(o=>u=>K(P)(u.to.node)()(o))(A)(e);return J(o=>u=>hf(t)(n)(u)(o))({visiting:A,visited:A,backEdges:A})([...at(o=>!Wr(o)(i),r),...at(o=>Wr(o)(i),r)]).backEdges},wy=t=>e=>n=>r=>{const i=py(At(s=>a=>b(a,s))(e)),o=xy(n),u=(()=>{if(t==="DepthFirst")return vy(o)(r);if(t==="Greedy")return Jy(o)(i)(r);g()})();return{edges:O(s=>my(b(s.from.node,s.to.node))(u)?{...s,from:s.to,to:s.from}:s)(r),reversedEdges:u}},pf=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},by=J(t=>e=>K(P)(e)()(t))(A),Ho=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Ly=Gg(P),Tn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},mf=t=>e=>{const n=it.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Hs=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},ky=Kt(it)(zt),Ey=t=>e=>Ce(P.compare,Le,t,e),yf=At(t=>e=>({src:e.src,tgt:e.tgt,delta:1,weight:1,eid:t})),Cy=t=>J(e=>n=>({base:(()=>{const r=i=>o=>{let u=i,s=o,a=!0,c;for(;a;){const f=u,d=s;if(d.tag==="Nil"){a=!1,c=f;continue}if(d.tag==="Cons"){u=pf(f)(d._1),s=d._2;continue}g()}return c};return(e.base+r(0)((()=>{const i=(o,u)=>{if(o.tag==="Leaf")return u;if(o.tag==="Node")return i(o._5,Ot("Cons",o._4,i(o._6,u)));g()};return i(n,qt)})())|0)+1|0})(),result:[...e.result,(()=>{if(e.base===0)return n;const r=i=>{if(i.tag==="Leaf")return A;if(i.tag==="Node")return Mt("Node",i._1,i._2,i._3,i._4+e.base|0,r(i._5),r(i._6));g()};return r(n)})()]}))({base:0,result:[]})(t).result,Sy=t=>e=>{const n=by(t);return Ly(t)(yf(at(r=>Ho(r.src)(n)&&Ho(r.tgt)(n),e)))},Gy=t=>e=>{const n=J(i=>o=>vt(P)(te)(o.tgt)([o.src])(vt(P)(te)(o.src)([o.tgt])(i)))(A)(e),r=i=>o=>u=>{let s=i,a=o,c=u,f=!0,d;for(;f;){const l=s,_=a,h=c,m=Bt(p=>T,p=>y=>w("Just",{head:p,tail:y}),l);if(m.tag==="Nothing"){f=!1,d={nodes:h};continue}if(m.tag==="Just"){if(Ho(m._1.head)(_)){s=m._1.tail,a=_,c=h;continue}s=[...m._1.tail,...(()=>{const p=Tn(m._1.head)(n);if(p.tag==="Nothing")return[];if(p.tag==="Just")return p._1;g()})()],a=K(P)(m._1.head)()(_),c=[...h,m._1.head];continue}g()}return d};return J(i=>o=>{if(Ho(o)(i.visited))return i;const u=r([o])(i.visited)([]);return{...i,visited:J(s=>a=>K(P)(a)()(s))(i.visited)(u.nodes),components:[...i.components,u.nodes]}})({visited:A,components:[]})(t).components},Py=t=>e=>n=>{const r=J(o=>u=>vt(P)(oe)(u.tgt)(1)(o))(A)(e),i=J(o=>u=>vt(P)(oe)(u.src)(1)(o))(A)(e);return J(o=>u=>{const s=Tn(u)(r),a=(()=>{if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})();if((()=>{const x=Tn(u)(i);return(()=>{if(x.tag==="Nothing")return a!==0;if(x.tag==="Just")return a!==x._1;g()})()||a===0})())return o;const c=Tn(u)(o.layers),f=(()=>{if(c.tag==="Nothing")return 0;if(c.tag==="Just")return c._1;g()})(),d=o.layers,l=J(x=>N=>N.tgt===u?{...x,mIn:mf(x.mIn)((()=>{const v=Tn(u)(d),L=Tn(N.src)(d);return(()=>{if(v.tag==="Nothing")return 0;if(v.tag==="Just")return v._1;g()})()-(()=>{if(L.tag==="Nothing")return 0;if(L.tag==="Just")return L._1;g()})()|0})())}:N.src===u?{...x,mOut:mf(x.mOut)((()=>{const v=Tn(N.tgt)(d),L=Tn(u)(d);return(()=>{if(v.tag==="Nothing")return 0;if(v.tag==="Just")return v._1;g()})()-(()=>{if(L.tag==="Nothing")return 0;if(L.tag==="Just")return L._1;g()})()|0})())}:x)({mIn:1e9,mOut:1e9})(e),_=l.mIn===1e9?-1:l.mIn,h=l.mOut===1e9?-1:l.mOut;if(_<0||h<0)return o;const m=(f-_|0)+1|0,p=(f+h|0)-1|0;if(p<m)return o;const y=J(x=>N=>{const v=Hs(N)(o.filling),L=(()=>{if(v.tag==="Nothing")return 0;if(v.tag==="Just")return v._1;g()})();return L<x.bestFill?{best:N,bestFill:L}:x})({best:f,bestFill:(()=>{const x=Hs(f)(o.filling);if(x.tag==="Nothing")return 0;if(x.tag==="Just")return x._1;g()})()})(Dt(m,p));return y.best===f?o:{layers:K(P)(u)(y.best)(o.layers),filling:K(it)(f)((()=>{const x=Hs(f)(o.filling);if(x.tag==="Nothing")return-1;if(x.tag==="Just")return x._1-1|0;g()})())(K(it)(y.best)(y.bestFill+1|0)(o.filling))}})({layers:n,filling:ky(O(o=>b(o,J(u=>s=>(()=>{const a=Tn(s)(n);return a.tag==="Nothing"?!1:a.tag==="Just"&&a._1===o})()?u+1|0:u)(0)(t)))(Dt(0,J(o=>u=>pf(o)((()=>{const s=Tn(u)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(0)(t))))})(t).layers},Iy=t=>e=>Py(t)(yf(e))(J(Ey)(A)(Cy(O(n=>Sy(n)(e))(Gy(t)(e))))),Dy=t=>t,hr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Oo=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},xf=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),Ay=Dy("NetworkSimplex"),By=t=>e=>J(n=>r=>{const i=J(Oo)(0)(xt(o=>hr(o)(n))(r));return J(o=>u=>K(P)(u)(i)(o))(n)(r)})(e)(t),Fy=t=>e=>({layers:O(n=>at(r=>{const i=hr(r)(e);return i.tag==="Nothing"?!1:i.tag==="Just"&&i._1===n},t))(Dt(0,(n=>r=>{let i=n,o=r,u=!0,s;for(;u;){const a=i,c=o;if(c.tag==="Nil"){u=!1,s=a;continue}if(c.tag==="Cons"){i=Oo(a)(c._1),o=c._2;continue}g()}return s})(0)((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return n(e,qt)})()))),nodeLayer:e}),Ry=t=>e=>n=>{const r=J(i=>o=>K(P)(o)(!0)(i))(A)(e);return J(i=>o=>K(P)(o._1)(o._2)(i))(Iy(e)(xt(i=>i.from.node===i.to.node||(()=>{const o=hr(i.from.node)(r);if(o.tag==="Nothing")return!0;if(o.tag==="Just")return!o._1;g()})()||(()=>{const o=hr(i.to.node)(r);if(o.tag==="Nothing")return!0;if(o.tag==="Just")return!o._1;g()})()?T:w("Just",{src:i.from.node,tgt:i.to.node}))(t)))(xf(n))},Qy=t=>e=>n=>r=>{const i=s=>a=>{const c=hr(a)(s);if(c.tag==="Just")return s;if(c.tag==="Nothing"){const f=at(l=>l!==a,(()=>{const l=hr(a)(t);if(l.tag==="Nothing")return[];if(l.tag==="Just")return l._1;g()})()),d=J(i)(s)(f);return K(P)(a)(1+J(Oo)(0)(xt(l=>hr(l)(d))(f))|0)(d)}g()},o=J(i)(A)(n),u=(s=>a=>{let c=s,f=a,d=!0,l;for(;d;){const _=c,h=f;if(h.tag==="Nil"){d=!1,l=_;continue}if(h.tag==="Cons"){c=Oo(_)(h._1),f=h._2;continue}g()}return l})(1)((()=>{const s=(a,c)=>{if(a.tag==="Leaf")return c;if(a.tag==="Node")return s(a._5,Ot("Cons",a._4,s(a._6,c)));g()};return s(o,qt)})());return J(s=>a=>K(P)(a._1)(a._2)(s))((()=>{const s=a=>{if(a.tag==="Leaf")return A;if(a.tag==="Node")return Mt("Node",a._1,a._2,a._3,u-a._4|0,s(a._5),s(a._6));g()};return s(o)})())(xf(r))},zy=J(t=>e=>{if(e.tag==="LayerConstraint"){if(e._1.pin.tag==="SpecificLayer")return K(P)(e._1.node)(e._1.pin._1)(t);if(e._1.pin.tag==="FirstLayer")return K(P)(e._1.node)(0)(t)}return t})(A),Wy=J(t=>e=>vt(P)(te)(e.to.node)([e.from.node])(t))(A),My=J(t=>e=>vt(P)(te)(e.from.node)([e.to.node])(t))(A),Hy=t=>e=>n=>r=>{const i=My(n),o=Wy(n),u=zy(e);return Fy(r)(By(xt(s=>s.tag==="SameLayer"?w("Just",s._1.nodes):T)(e))((()=>{if(t==="LongestPath")return Qy(i)(o)(r)(u);if(t==="NetworkSimplex")return Ry(n)(r)(u);g()})()))},Oy=Kt(P)(zt),qy=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Nf=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Jf=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Ai=Kt(P)(zt),$y=Kt(P)(zt),Tf=(()=>{const t=O(e=>({start:e.end,end:e.start,direction:e.direction}));return e=>ke(t(e))})(),Yy=t=>e=>n=>r=>{const i=Oy(O(u=>b(u.edge,u))(r)),o=u=>0<u.nodes.length&&(()=>{const s=qy(u.edgeId)(n);return s.tag==="Just"&&u.nodes[0]!==s._1._1})();return O(u=>{if(u.nodes.length<=2){const f=Nf(u.edgeId)(i);if(f.tag==="Just"){const d=o(u),l=ki(Li(d?Tf(f._1.segments):f._1.segments));return{...f._1,edge:u.edgeId,segments:l,bends:Je(_=>h=>_.end,l,bt(1,l.length,l)),reversed:d}}if(f.tag==="Nothing")return{edge:u.edgeId,segments:[],bends:[],bendType:[],jumps:[],reversed:!1};g()}const s=Tt(xt(f=>Nf(f)(i))(Je(f=>d=>u.edgeId+":"+f+"->"+d,u.nodes,bt(1,u.nodes.length,u.nodes))))(f=>f.segments),a=o(u),c=ki(Li(a?Tf(s):s));return{edge:u.edgeId,segments:c,bends:Je(f=>d=>f.end,c,bt(1,c.length,c)),bendType:[],jumps:[],reversed:a}})(t)},Xy={layers:[],edges:[],chains:[]},Vy={nodeGap:3,layerGap:2,iterations:8,layerer:Ay,cycleBreaker:yy,compactPostRouting:!1},Uy=t=>({pos:b(0,0),size:b(J(e=>n=>Jf(e)(n.position._1+n.size._1))(0)(t),J(e=>n=>Jf(e)(n.position._2+n.size._2))(0)(t))}),jy=t=>e=>n=>{const r=Ai(O(c=>b(c.id,c.ports))(e.nodes)),i=at(c=>me(3)(c.node)!=="$d:",n.placements),o=Yy(n.withDummies.chains)(n.acyclic.reversedEdges)($y(O(c=>b(c.id,b(c.from.node,c.to.node)))(e.edges)))(T2(n.withDummies.edges)(n.placements)(r)(n.withDummies.chains)(Zg(n.ordered)(at(c=>c.from.node!==c.to.node,n.withDummies.edges))((()=>{const c=f=>{if(f.tag==="Leaf")return A;if(f.tag==="Node")return Mt("Node",f._1,f._2,f._3,b(f._4._1*4,f._4._2),c(f._5),c(f._6));g()};return c(Ai(O(f=>b(f.id,f.size))(e.nodes)))})()))),u=t.compactPostRouting?Om()({nodes:i,edges:e.edges,paths:o,ports:r}):{nodes:i,edges:o},s=O(c=>{const f=ki(Li(c.segments));return{...c,segments:f,bends:Je(d=>l=>d.end,f,bt(1,f.length,f))}})(u.edges),a=At(c=>f=>({...f,jumps:C2(c)(f)(s)}))(s);return{nodes:u.nodes,edges:a,boundingBox:Uy(u.nodes),metrics:pp(u.nodes)(a)(0)}},Zy=t=>e=>n=>{const r=Ai(O(o=>b(o.id,o.size))(e.nodes)),i={...n,placements:ey({nodeGap:t.nodeGap,layerGap:t.layerGap})(e.constraints)(n.ordered)(r)(Ai(O(o=>b(o.id,o.ports))(e.nodes)))(n.withDummies.edges)(n.withDummies.chains)(Zg(n.ordered)(n.withDummies.edges)((()=>{const o=u=>{if(u.tag==="Leaf")return A;if(u.tag==="Node")return Mt("Node",u._1,u._2,u._3,b(u._4._1*4,u._4._2),o(u._5),o(u._6));g()};return o(r)})()))};return{pipeline:i,result:jy(t)(e)(i)}},Ky=t=>e=>n=>Zy(t)(e)({...n,ordered:ly({iterations:t.iterations,constraints:e.constraints,modelOrder:Ai(At(r=>i=>b(i.id,r))(e.nodes))})(n.withDummies.layers)(n.withDummies.edges)}),tx=t=>e=>n=>Ky(t)(e)({...n,withDummies:S2(n.layered.nodeLayer)(n.acyclic.edges)(n.layered.layers)}),ex=t=>e=>{const n=O(i=>i.id)(e.nodes),r=wy(t.cycleBreaker)(n)(e.constraints)(e.edges);return tx(t)(e)({acyclic:r,layered:Hy(t.layerer)(e.constraints)(r.edges)(n),withDummies:Xy,ordered:[],placements:[]})},qo=t=>t,nx=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Os=qo("TopSide"),qs=qo("BottomSide"),$s=qo("LeftSide"),Ys=qo("RightSide"),rx=t=>{const e=st.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=st.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},vf=t=>e=>n=>{const r=nx(t.h*.12)(t.w*.2),i=t.w/2;return(e<0?t.y+r:t.y+t.h-r)+e*r*Ee(rx((()=>{const o=(n-(t.x+i))/i;return 1-o*o})()))},er=t=>e=>n=>r=>{let i=t,o=e,u=n,s=r,a=!0,c;for(;a;){const f=i,d=o,l=u,_=s;if(f==="Rectangle"){if(l==="TopSide"){a=!1,c=d.y;continue}if(l==="BottomSide"){a=!1,c=d.y+d.h;continue}if(l==="LeftSide"){a=!1,c=d.x;continue}if(l==="RightSide"){a=!1,c=d.x+d.w;continue}i=jn,o=d,u=l,s=_;continue}if(f==="Cylinder"){if(l==="TopSide"){a=!1,c=vf(d)(-1)(_);continue}if(l==="BottomSide"){a=!1,c=vf(d)(1)(_);continue}if(l==="LeftSide"){a=!1,c=d.x;continue}if(l==="RightSide"){a=!1,c=d.x+d.w;continue}}i=jn,o=d,u=l,s=_}return c},wf=t=>e=>{const n=e.y-t.y,r=n<0?-n:n,i=e.x-(t.x+t.w),o=i<0?-i:i,u=e.x-t.x,s=u<0?-u:u,a=e.y-(t.y+t.h),c=a<0?-a:a;return r<=c&&r<=s&&r<=o?Os:c<=s&&c<=o?qs:s<=o?$s:Ys},Xs=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Bi=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},ix=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),$o=Kt(P)(zt),ox=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},ux=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},sx=J(t=>e=>K(P)(e)()(t))(A),ax=J(t=>e=>K(P)(e)()(t))(A),Yo=ir.traverse(Nu),Xo=Kt(P)(zt),cx=t=>e=>Ce(P.compare,Le,t,e),gx=J(t=>e=>K(P)(e)()(t))(A),fx=Kt(P)(zt),_x=t=>e=>Ce(P.compare,Le,t,e),dx=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},bf=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},lx=t=>e=>({...e,edges:$o(O(n=>b(n._1,(()=>{const r=Xs(n._1)(t);if(r.tag==="Nothing")return n._2;if(r.tag==="Just"){const i=Bi(r._1._2)(e.nodes),o=Bi(r._1._1)(e.nodes),u=(()=>{if(o.tag==="Nothing")return n._2;if(o.tag==="Just"){const s=Bt(a=>T,a=>c=>w("Just",{head:a,tail:c}),n._2);if(s.tag==="Nothing")return n._2;if(s.tag==="Just"){const a={x:o._1.x,y:o._1.y,w:o._1.w,h:o._1.h},c=wf(a)(s._1.head);return[(()=>{if(c==="TopSide")return{...s._1.head,y:er(o._1.shape)(a)(Os)(s._1.head.x)};if(c==="BottomSide")return{...s._1.head,y:er(o._1.shape)(a)(qs)(s._1.head.x)};if(c==="LeftSide")return{...s._1.head,x:er(o._1.shape)(a)($s)(s._1.head.y)};if(c==="RightSide")return{...s._1.head,x:er(o._1.shape)(a)(Ys)(s._1.head.y)};g()})(),...s._1.tail]}}g()})();if(i.tag==="Nothing")return u;if(i.tag==="Just"){const s=Xi(u);if(s.tag==="Nothing")return u;if(s.tag==="Just")return Ft(s._1.init)((()=>{const a={x:i._1.x,y:i._1.y,w:i._1.w,h:i._1.h},c=wf(a)(s._1.last);if(c==="TopSide")return{...s._1.last,y:er(i._1.shape)(a)(Os)(s._1.last.x)};if(c==="BottomSide")return{...s._1.last,y:er(i._1.shape)(a)(qs)(s._1.last.x)};if(c==="LeftSide")return{...s._1.last,x:er(i._1.shape)(a)($s)(s._1.last.y)};if(c==="RightSide")return{...s._1.last,x:er(i._1.shape)(a)(Ys)(s._1.last.y)};g()})())}}g()})()))(ix(e.edges)))}),hx=t=>e=>n=>{const r=Xt(i=>i.id===n)(t.graph.edges);if(r.tag==="Just")return w("Just",r._1);if(r.tag==="Nothing")return Xs(n)(e);g()},px=t=>e=>n=>r=>({x:r.position._1*t,y:r.position._2*t,w:r.size._1*t,h:r.size._2*t,label:(()=>{const i=Bi(r.node)(e);if(i.tag==="Just")return i._1;if(i.tag==="Nothing")return r.node;g()})(),shape:(()=>{const i=Bi(r.node)(n);if(i.tag==="Nothing")return jn;if(i.tag==="Just")return i._1;g()})()}),mx=t=>({id:t,size:b(1,1),ports:[],label:w("Just",t),shape:jn}),yx=t=>e=>n=>r=>b(r.node,px(t)(e)(n)(r)),Lf=t=>{const e=lo(`
|
|
6
|
-
`)(t);return e.length===0?[""]:e},kf=t=>{const e=(n,r)=>{if(n.tag==="Leaf")return r;if(n.tag==="Node")return e(n._5,Ot("Cons",n._4,e(n._6,r)));g()};return kt($t.foldr,e(t.interiors,qt))},xx=t=>$o(xt(e=>w("Just",b(e.edge,{id:e.edge,from:{node:e.from,port:T},to:{node:e.to,port:T}})))(Tt(t.scenes)(e=>e.tag==="DataFlow"?xt(n=>n.kind.tag==="SendToken"?w("Just",n.kind._1):T)(e._1.events):[]))),Ef=t=>{const e=Al(t),n=at(i=>ox(i.id)(e.nodes),t.graph.nodes),r=at(i=>ux(i.id)(e.edges),t.graph.edges);return{nodes:[...n,...O(mx)(kt(We.foldr,Cn(P.compare,e.nodes,sx(O(i=>i.id)(n)))))],edges:[...r,...xt(hx(t)(xx(t)))(kt(We.foldr,Cn(P.compare,e.edges,ax(O(i=>i.id)(r)))))],constraints:t.graph.constraints}},Nx=t=>{const e=Yo(n=>{const r=rg(ig)((()=>{if(n.label.tag==="Just")return n.label._1;if(n.label.tag==="Nothing")return n.id;g()})());return()=>{const i=r();return b(n.id,i)}})(Ef(t).nodes);return()=>{const n=e();return Xo(n)}},Cf=t=>{const e=Nx(t);return()=>{const n=e(),r=Yo(Cf)(kf(t))();return J(cx)(n)(r)}},Jx=t=>e=>{const n=Bt(r=>T,r=>i=>w("Just",{head:r,tail:i}),e.segments);if(n.tag==="Nothing")return[];if(n.tag==="Just")return[{x:n._1.head.start._1*t,y:n._1.head.start._2*t},...O(r=>({x:r.end._1*t,y:r.end._2*t}))([n._1.head,...n._1.tail])];g()},Tx=t=>e=>b(e.edge,Jx(t)(e)),vx=t=>e=>n=>r=>({nodes:Xo(O(yx(rt(4)*t)(e)(n))(r.nodes)),edges:$o(O(Tx(t))(r.edges)),chipExtras:A}),wx=t=>J(e=>n=>{if(n.tag==="Structural")return e;if(n.tag==="DataFlow")return J(r=>i=>{if(i.kind.tag==="SendToken")return J(o=>u=>K(P)(u)()(o))(r)(i.kind._1.labels);if(i.kind.tag==="FillNodeWithoutTransition")return J(o=>u=>K(P)(u)()(o))(r)(i.kind._1.labels);g()})(e)(n._1.events);if(n.tag==="EnterNode"||n.tag==="ExitNode")return e;g()})(A)(t.scenes),bx=t=>{const e=Yo(n=>{const r=rg(ig)(n);return()=>{const i=r();return b(n,{labelW:i,charCount:Un(Ir(n)),lineCount:1})}})(kt(We.foldr,gx(Tt(kt(We.foldr,wx(t)))(Lf))));return()=>{const n=e();return fx(n)}},Sf=t=>{const e=bx(t);return()=>{const n=e(),r=Yo(Sf)(kf(t))();return J(_x)(n)(r)}},Lx=rt(4)*8,kx=t=>e=>{const n=dp(Lx)(t)(_p(fp)(Ef(e)));return lx($o(O(r=>b(r.id,b(r.from.node,r.to.node)))(n.edges)))(vx(8)(Xo(O(r=>b(r.id,(()=>{if(r.label.tag==="Just")return r.label._1;if(r.label.tag==="Nothing")return r.id;g()})()))(n.nodes)))(Xo(O(r=>b(r.id,r.shape))(n.nodes)))(ex(Vy)(n).result))},Ex=t=>Tt(t.scenes)(e=>{if(e.tag==="Structural")return[];if(e.tag==="DataFlow")return e._1.events;if(e.tag==="EnterNode")return[];if(e.tag==="ExitNode")return[];g()}),Cx=t=>e=>n=>{const r=i=>{const o=xt(u=>{const s=dx(u)(t);return s.tag==="Just"?w("Just",{w:s._1.labelW+28,h:rt(up(1)(s._1.lineCount))*13.2+12}):T})(Tt(i)(Lf));return o.length===0?T:w("Just",{w:J(bf)(0)(O(u=>u.w)(o)),h:J(bf)(0)(O(u=>u.h)(o))})};return J(i=>o=>{if(o.kind.tag==="SendToken"){const u=Xs(o.kind._1.edge)(n.edges),s=r(o.kind._1.labels);if(s.tag==="Just"&&u.tag==="Just"){const a=s._1;return vt(P)(te)(o.kind._1.edge)(O(c=>({x:c.x+14+a.w,y:c.y-6-8-a.h}))(u._1))(i)}return i}if(o.kind.tag==="FillNodeWithoutTransition"){const u=Bi(o.kind._1.node)(n.nodes),s=r(o.kind._1.labels);return s.tag==="Just"&&u.tag==="Just"?vt(P)(te)("__fill__:"+o.kind._1.node)((()=>{const a=u._1.y-s._1.h-14,c=u._1.x+u._1.w/2,f=c-s._1.w/2,d=c+s._1.w/2,l=u._1.y-14;return[{x:f,y:a},{x:d,y:a},{x:f,y:l},{x:d,y:l}]})())(i):i}g()})(A)(Ex(e))},Gf=t=>e=>n=>({layout:(()=>{const r=kx(t)(n);return{...r,chipExtras:Cx(e)(n)(r)}})(),interiors:(()=>{const r=Gf(t)(e),i=o=>{if(o.tag==="Leaf")return A;if(o.tag==="Node")return Mt("Node",o._1,o._2,o._3,r(o._4),i(o._5),i(o._6));g()};return i(n.interiors)})()}),Pf=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Vs=t=>e=>n=>{const r=t<.05?t:.05,i=(u,s)=>{if(s.tag==="Leaf")return u;if(s.tag==="Node")return i((()=>{const a=Pf(s._3)(n),c=(()=>{if(a.tag==="Just")return a._1;if(a.tag==="Nothing")return{x:s._4.x,y:s._4.y,vx:0,vy:0};g()})(),f=c.vx+(180*(s._4.x-c.x)-22*c.vx)*r,d=c.vy+(180*(s._4.y-c.y)-22*c.vy)*r;return K(P)(s._3)({x:c.x+f*r,y:c.y+d*r,vx:f,vy:d})(i(u,s._5))})(),s._6);g()},o=i(A,e);return{springs:o,applied:(()=>{const u=(s,a)=>{if(a.tag==="Leaf")return s;if(a.tag==="Node")return u((()=>{const c=u(s,a._5),f=Pf(a._3)(o);if(f.tag==="Just")return K(P)(a._3)({...a._4,x:f._1.x,y:f._1.y})(c);if(f.tag==="Nothing")return K(P)(a._3)(a._4)(c);g()})(),a._6);g()};return u(A,e)})()}};(function(){var t={},e="Pure",n="Throw",r="Catch",i="Sync",o="Async",u="Bind",s="Bracket",a="Fork",c="Sequential",f="Map",d="Apply",l="Alt",_="Cons",h="Resume",m="Release",p="Finalizer",y="Finalized",x="Forked";function N(B,q,V,$){this.tag=B,this._1=q,this._2=V,this._3=$}function v(B){var q=function(V,$,X){return new N(B,V,$,X)};return q.tag=B,q}function L(B){return new N(e,void 0)}function k(B){try{B()}catch(q){setTimeout(function(){throw q},0)}}function E(B,q,V){try{return q(V())}catch($){return B($)}}function Q(B,q,V){try{return q(V)()}catch($){return V(B($))(),L}}var H=(function(){var B=1024,q=0,V=0,$=new Array(B),X=!1;function M(){var et;for(X=!0;q!==0;)q--,et=$[V],$[V]=void 0,V=(V+1)%B,et();X=!1}return{isDraining:function(){return X},enqueue:function(et){var tt;q===B&&(tt=X,M(),X=tt),$[(V+q)%B]=et,q++,X||M()}}})();function j(B){var q={},V=0,$=0;return{register:function(X){var M=V++;X.onComplete({rethrow:!0,handler:function(et){return function(){$--,delete q[M]}}})(),q[M]=X,$++},isEmpty:function(){return $===0},killAll:function(X,M){return function(){if($===0)return M();var et=0,tt={};function gt(ct){tt[ct]=q[ct].kill(X,function(yt){return function(){delete tt[ct],et--,B.isLeft(yt)&&B.fromLeft(yt)&&setTimeout(function(){throw B.fromLeft(yt)},0),et===0&&M()}})()}for(var _t in q)q.hasOwnProperty(_t)&&(et++,gt(_t));return q={},V=0,$=0,function(ct){return new N(i,function(){for(var yt in tt)tt.hasOwnProperty(yt)&&tt[yt]()})}}}}}var S=0,C=1,U=2,Y=3,W=4,z=5,R=6;function G(B,q,V){var $=0,X=S,M=V,et=null,tt=null,gt=null,_t=null,ct=null,yt=0,Et=0,Rt=null,pt=!0;function Qt(Z){for(var ut,ft,lt;;)switch(ut=null,ft=null,lt=null,X){case U:X=C;try{M=gt(M),_t===null?gt=null:(gt=_t._1,_t=_t._2)}catch(Ht){X=z,et=B.left(Ht),M=null}break;case Y:B.isLeft(M)?(X=z,et=M,M=null):gt===null?X=z:(X=U,M=B.fromRight(M));break;case C:switch(M.tag){case u:gt&&(_t=new N(_,gt,_t)),gt=M._2,X=C,M=M._1;break;case e:gt===null?(X=z,M=B.right(M._1)):(X=U,M=M._1);break;case i:X=Y,M=E(B.left,B.right,M._1);break;case o:X=W,M=Q(B.left,M._1,function(Ht){return function(){$===Z&&($++,H.enqueue(function(){$===Z+1&&(X=Y,M=Ht,Qt($))}))}});return;case n:X=z,et=B.left(M._1),M=null;break;case r:gt===null?ct=new N(_,M,ct,tt):ct=new N(_,M,new N(_,new N(h,gt,_t),ct,tt),tt),gt=null,_t=null,X=C,M=M._1;break;case s:yt++,gt===null?ct=new N(_,M,ct,tt):ct=new N(_,M,new N(_,new N(h,gt,_t),ct,tt),tt),gt=null,_t=null,X=C,M=M._1;break;case a:X=Y,ut=G(B,q,M._2),q&&q.register(ut),M._1&&ut.run(),M=B.right(ut);break;case c:X=C,M=D(B,q,M._1);break}break;case z:if(gt=null,_t=null,ct===null)X=R,M=tt||et||M;else switch(ut=ct._3,lt=ct._1,ct=ct._2,lt.tag){case r:tt&&tt!==ut&&yt===0?X=z:et&&(X=C,M=lt._2(B.fromLeft(et)),et=null);break;case h:tt&&tt!==ut&&yt===0||et?X=z:(gt=lt._1,_t=lt._2,X=U,M=B.fromRight(M));break;case s:yt--,et===null&&(ft=B.fromRight(M),ct=new N(_,new N(m,lt._2,ft),ct,ut),(tt===ut||yt>0)&&(X=C,M=lt._3(ft)));break;case m:ct=new N(_,new N(y,M,et),ct,tt),X=C,tt&&tt!==ut&&yt===0?M=lt._1.killed(B.fromLeft(tt))(lt._2):et?M=lt._1.failed(B.fromLeft(et))(lt._2):M=lt._1.completed(B.fromRight(M))(lt._2),et=null,yt++;break;case p:yt++,ct=new N(_,new N(y,M,et),ct,tt),X=C,M=lt._1;break;case y:yt--,X=z,M=lt._1,et=lt._2;break}break;case R:for(var Nt in Rt)Rt.hasOwnProperty(Nt)&&(pt=pt&&Rt[Nt].rethrow,k(Rt[Nt].handler(M)));Rt=null,tt&&et?setTimeout(function(){throw B.fromLeft(et)},0):B.isLeft(M)&&pt&&setTimeout(function(){if(pt)throw B.fromLeft(M)},0);return;case S:X=C;break;case W:return}}function Jt(Z){return function(){if(X===R)return pt=pt&&Z.rethrow,Z.handler(M)(),function(){};var ut=Et++;return Rt=Rt||{},Rt[ut]=Z,function(){Rt!==null&&delete Rt[ut]}}}function mt(Z,ut){return function(){if(X===R)return ut(B.right(void 0))(),function(){};var ft=Jt({rethrow:!1,handler:function(){return ut(B.right(void 0))}})();switch(X){case S:tt=B.left(Z),X=R,M=tt,Qt($);break;case W:tt===null&&(tt=B.left(Z)),yt===0&&(X===W&&(ct=new N(_,new N(p,M(Z)),ct,tt)),X=z,M=null,et=null,Qt(++$));break;default:tt===null&&(tt=B.left(Z)),yt===0&&(X=z,M=null,et=null)}return ft}}function nt(Z){return function(){var ut=Jt({rethrow:!1,handler:Z})();return X===S&&Qt($),ut}}return{kill:mt,join:nt,onComplete:Jt,isSuspended:function(){return X===S},run:function(){X===S&&(H.isDraining()?Qt($):H.enqueue(function(){Qt($)}))}}}function I(B,q,V,$){var X=0,M={},et=0,tt={},gt=new Error("[ParAff] Early exit"),_t=null,ct=t;function yt(Jt,mt,nt){var Z=mt,ut=null,ft=null,lt=0,Nt={},Ht,Vt;t:for(;;)switch(Ht=null,Z.tag){case x:if(Z._3===t&&(Ht=M[Z._1],Nt[lt++]=Ht.kill(Jt,function(Pe){return function(){lt--,lt===0&&nt(Pe)()}})),ut===null)break t;Z=ut._2,ft===null?ut=null:(ut=ft._1,ft=ft._2);break;case f:Z=Z._2;break;case d:case l:ut&&(ft=new N(_,ut,ft)),ut=Z,Z=Z._1;break}if(lt===0)nt(B.right(void 0))();else for(Vt=0,Ht=lt;Vt<Ht;Vt++)Nt[Vt]=Nt[Vt]();return Nt}function Et(Jt,mt,nt){var Z,ut,ft,lt,Nt,Ht;for(B.isLeft(Jt)?(Z=Jt,ut=null):(ut=Jt,Z=null);;){if(ft=null,lt=null,Nt=null,Ht=null,_t!==null)return;if(mt===null){$(Z||ut)();return}if(mt._3!==t)return;switch(mt.tag){case f:Z===null?(mt._3=B.right(mt._1(B.fromRight(ut))),ut=mt._3):mt._3=Z;break;case d:if(ft=mt._1._3,lt=mt._2._3,Z){if(mt._3=Z,Nt=!0,Ht=et++,tt[Ht]=yt(gt,Z===ft?mt._2:mt._1,function(){return function(){delete tt[Ht],Nt?Nt=!1:nt===null?Et(Z,null,null):Et(Z,nt._1,nt._2)}}),Nt){Nt=!1;return}}else{if(ft===t||lt===t)return;ut=B.right(B.fromRight(ft)(B.fromRight(lt))),mt._3=ut}break;case l:if(ft=mt._1._3,lt=mt._2._3,ft===t&&B.isLeft(lt)||lt===t&&B.isLeft(ft))return;if(ft!==t&&B.isLeft(ft)&<!==t&&B.isLeft(lt))Z=ut===ft?lt:ft,ut=null,mt._3=Z;else if(mt._3=ut,Nt=!0,Ht=et++,tt[Ht]=yt(gt,ut===ft?mt._2:mt._1,function(){return function(){delete tt[Ht],Nt?Nt=!1:nt===null?Et(ut,null,null):Et(ut,nt._1,nt._2)}}),Nt){Nt=!1;return}break}nt===null?mt=null:(mt=nt._1,nt=nt._2)}}function Rt(Jt){return function(mt){return function(){delete M[Jt._1],Jt._3=mt,Et(mt,Jt._2._1,Jt._2._2)}}}function pt(){var Jt=C,mt=V,nt=null,Z=null,ut,ft;t:for(;;)switch(ut=null,ft=null,Jt){case C:switch(mt.tag){case f:nt&&(Z=new N(_,nt,Z)),nt=new N(f,mt._1,t,t),mt=mt._2;break;case d:nt&&(Z=new N(_,nt,Z)),nt=new N(d,t,mt._2,t),mt=mt._1;break;case l:nt&&(Z=new N(_,nt,Z)),nt=new N(l,t,mt._2,t),mt=mt._1;break;default:ft=X++,Jt=z,ut=mt,mt=new N(x,ft,new N(_,nt,Z),t),ut=G(B,q,ut),ut.onComplete({rethrow:!1,handler:Rt(mt)})(),M[ft]=ut,q&&q.register(ut)}break;case z:if(nt===null)break t;nt._1===t?(nt._1=mt,Jt=C,mt=nt._2,nt._2=t):(nt._2=mt,mt=nt,Z===null?nt=null:(nt=Z._1,Z=Z._2))}for(ct=mt,ft=0;ft<X;ft++)M[ft].run()}function Qt(Jt,mt){_t=B.left(Jt);var nt;for(var Z in tt)if(tt.hasOwnProperty(Z)){nt=tt[Z];for(Z in nt)nt.hasOwnProperty(Z)&&nt[Z]()}tt=null;var ut=yt(Jt,ct,mt);return function(ft){return new N(o,function(lt){return function(){for(var Nt in ut)ut.hasOwnProperty(Nt)&&ut[Nt]();return L}})}}return pt(),function(Jt){return new N(o,function(mt){return function(){return Qt(Jt,mt)}})}}function D(B,q,V){return new N(o,function($){return function(){return I(B,q,V,$)}})}return N.EMPTY=t,N.Pure=v(e),N.Throw=v(n),N.Catch=v(r),N.Sync=v(i),N.Async=v(o),N.Bind=v(u),N.Bracket=v(s),N.Fork=v(a),N.Seq=v(c),N.ParMap=v(f),N.ParApply=v(d),N.ParAlt=v(l),N.Fiber=G,N.Supervisor=j,N.Scheduler=H,N.nonCanceler=L,N})();let If=null;function Sx(){return If||(typeof document>"u"?null:If=document.createElement("canvas").getContext("2d"))}const Us=new Map;function Df(t,e,n,r,i,o){const u=`${n} ${e}px ${t}`,s=u+"|"+r;if(Us.has(s))return Us.get(s);const a=Sx();if(!a)return o;a.font=u;const c=i(a.measureText(r)),f=typeof document<"u"?document.fonts:null;if(!f||f.check(u))Us.set(s,c);else if(f&&f.load)try{f.load(u)}catch{}return c}const Gx=(t,e,n,r)=>Df(t,e,n,r,i=>i.width,-1),Px=(t,e,n,r)=>Df(t,e,n,r,i=>({ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent}),{ascent:-1,descent:-1}),Af=t=>e=>{const n=Gx(t.family,t.size,t.weight,Ir(e));return n<0?rt(mo(e).length)*t.size*.62:n},Bf=t=>e=>{const n=Px(t.family,t.size,t.weight,Ir(e));return n.ascent<0?{ascent:t.size*.72,descent:t.size*.2}:n},Ff=t=>t,Rf=t=>t,Vo=t=>t,Qf=t=>t,Ix=t=>t,zf=t=>t,Wf=t=>t,Dx=Wf("BaselineTop"),Mr=Wf("BaselineMiddle"),js=zf("AlignLeft"),Uo=zf("AlignCenter"),Te=Ix("RoundJoin"),fn=Qf("ButtCap"),Dn=Qf("RoundCap"),Ax=Vo("LayerPolyOut"),Bx=Vo("LayerPolyIn"),Fx=Vo("LayerNodeMask"),Rx=Vo("LayerOverlay"),Zs=Rf("NonZero"),Qx=Rf("EvenOdd"),Mf=Ff("Normal"),jo=Ff("Difference"),re={r:255,g:255,b:255,a:255},An={r:26,g:26,b:26,a:255},zx=t=>t,Hf=t=>t,Wx=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},nn=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Of=t=>e=>n=>{const r=it.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=it.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},Ks=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Mx=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},Hx=Hf("FlatLevel"),Ox=Hf("NestedLevel"),qf=zx("GenieSilhouette"),qx=t=>e=>n=>r=>{if(e)return{prng:t,yLift:0};const i=Sr(t);return{prng:i.prng,yLift:i.value*n.yJitter*r}},$x=t=>e=>n=>r=>{if(e)return{prng:t,dx:0};const i=Sr(t);return{prng:i.prng,dx:(i.value*2-1)*n.xJitter*r}},$f=t=>e=>{const n=e.cy-t.cy,r=e.cx-t.cx,i=Ee(r*r+n*n),o=(t.r*t.r-e.r*e.r+i*i)/(2*i),u=Ee(Wx(0)(t.r*t.r-o*o)),s=t.cx+o*r/i,a=t.cy+o*n/i,c={x:s-u*n/i,y:a+u*r/i},f={x:s+u*n/i,y:a-u*r/i};return i===0||i>t.r+e.r?{x:(t.cx+e.cx)/2,y:t.cy}:c.y<f.y?c:f},Yx=t=>e=>{const n=nn(e)(nn(t.w/2)(t.h/2));return[1,t.x+n,t.y,2,t.x+t.w-n,t.y,3,t.x+t.w,t.y,t.x+t.w,t.y+n,2,t.x+t.w,t.y+t.h-n,3,t.x+t.w,t.y+t.h,t.x+t.w-n,t.y+t.h,2,t.x+n,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-n,2,t.x,t.y+n,3,t.x,t.y,t.x+n,t.y,5]},Xx=t=>e=>n=>r=>i=>o=>{if(e)return{prng:t,r:i};if(n)return{prng:t,r:i*(1+o.rJitter)};if(r)return{prng:t,r:i*o.smallScale};const u=Sr(t);return{prng:u.prng,r:i*(1+u.value*o.rJitter)}},Yf=t=>{const e=nn(t.w)(t.h)/2;return[1,t.x+e,t.y,2,t.x+t.w-e,t.y,4,t.x+t.w-e+.5522847498307936*e,t.y,t.x+t.w,t.y+e-.5522847498307936*e,t.x+t.w,t.y+e,4,t.x+t.w,t.y+e+.5522847498307936*e,t.x+t.w-e+.5522847498307936*e,t.y+t.h,t.x+t.w-e,t.y+t.h,2,t.x+e,t.y+t.h,4,t.x+e-.5522847498307936*e,t.y+t.h,t.x,t.y+e+.5522847498307936*e,t.x,t.y+e,4,t.x,t.y+e-.5522847498307936*e,t.x+e-.5522847498307936*e,t.y,t.x+e,t.y,5]},Vx=t=>e=>n=>{const r=Sr(t),i=e.length;return i===0?{prng:t,idx:-1}:{prng:r.prng,idx:(()=>{const o=Of(0)(i-1|0)(de(dn(r.value*rt(n))));return o>=0&&o<e.length?e[o]:-1})()}},Ux=t=>e=>{const n=Sr(t),r=e.length;return r===0?{prng:t,idx:-1}:{prng:n.prng,idx:(()=>{const i=Of(0)(r-1|0)(de(dn(n.value*rt(r))));return i>=0&&i<e.length?e[i]:-1})()}},Xf=t=>{const e=nn(t.w*.18)(t.h*.6);return[1,t.x+e,t.y,2,t.x+t.w,t.y,2,t.x+t.w-e,t.y+t.h,2,t.x,t.y+t.h,5]},Vf=t=>[1,t.x,t.y,2,t.x+t.w,t.y,2,t.x+t.w,t.y+t.h*.85,4,t.x+t.w*.66,t.y+t.h*1.05,t.x+t.w*.34,t.y+t.h*.65,t.x,t.y+t.h*.85,5],Uf={rBase:1.2,stepRatio:.7,rJitter:.35,yJitter:.2,xJitter:.2,heroShift:.2,smallScale:.85,smallShift:.15,seed:7,minN:3},jx=t=>{const e=nn(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+e,i=t.x+n;return[1,t.x,r,4,t.x,r+.5522847498*e,i-.5522847498*n,r+e,i,r+e,4,i+.5522847498*n,r+e,t.x+t.w,r+.5522847498*e,t.x+t.w,r]},jf=t=>{const e=nn(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+t.h+5,i=t.y+e,o=r-e,u=t.x+n;return[1,t.x,i,4,t.x,i-.5522847498*e,u-.5522847498*n,t.y,u,t.y,4,u+.5522847498*n,t.y,t.x+t.w,i-.5522847498*e,t.x+t.w,i,2,t.x+t.w,o,4,t.x+t.w,o+.5522847498*e,u+.5522847498*n,r,u,r,4,u-.5522847498*n,r,t.x,o+.5522847498*e,t.x,o,5]},Zf=t=>e=>{const n=e.y+e.h,r=fd(t.rBase*e.h)(e.w/(2*(1+(rt(t.minN)-1)*t.stepRatio))),i=e.w-2*r,o=2*r*t.stepRatio,u=Ks(t.minN)(i<=0||o<=0?t.minN:de(Yn(i/o))+1|0),s=u>=3?Dt(1,u-2|0):[],a=s.length,c=En(a+1|0,2),f=c<1?[]:bt(0,c,s),d=Ux(t.seed)((()=>{const p=a-c|0;return p<1?s:bt(p,s.length,s)})()),l=d.idx,_=Vx(d.prng)(at(p=>p!==l,f))(Ks(1)(f.length-(Qe(xr)(l)(f)?1:0)|0)),h=_.idx,m=u>=2?i/(rt(u)-1):0;return J(p=>y=>{const x=y===h,N=y===l,v=y===0||y===(u-1|0),L=Xx(p.prng)(v)(N)(x)(r)(t),k=qx(L.prng)(v)(t)(e.h),E=$x(k.prng)(v)(t)(m);return{prng:E.prng,circles:Ft(p.circles)({cx:e.x+Mx(L.r)(e.w-L.r)((u>=2?r+rt(y)/(rt(u)-1)*i+E.dx:r+0*i+E.dx)+(N?t.heroShift*m:x?-1*t.smallShift*m:0)),cy:n-k.yLift,r:L.r})}})({prng:_.prng,circles:[]})(Dt(0,u-1|0)).circles},Kf=t=>e=>{const n=t.length;return At(r=>i=>({c:i,p1:(()=>{if(r===0)return{x:i.cx-i.r,y:e};const o=r-1|0;return o>=0&&o<t.length?$f(t[o])(i):{x:i.cx-i.r,y:e}})(),p2:(()=>{if(r===(n-1|0))return{x:i.cx+i.r,y:e};const o=r+1|0;return o>=0&&o<t.length?$f(i)(t[o]):{x:i.cx+i.r,y:e}})()}))(t)},t_=t=>{const e=nn(t.h*.4)(t.w*.2);return[1,t.x+e,t.y,2,t.x+t.w-e,t.y,2,t.x+t.w,t.y+t.h/2,2,t.x+t.w-e,t.y+t.h,2,t.x+e,t.y+t.h,2,t.x,t.y+t.h/2,5]},Zx=t=>e=>n=>{const r=ur(e.y-t.cy)(e.x-t.cx),i=ur(n.y-t.cy)(n.x-t.cx),o=i>r?i-r:i+6.283185307179586-r,u=Ks(1)(de(Vi(o/1.5707963267948966))),s=o/rt(u),a=1.3333333333333333*_d(s/4);return Tt(Dt(0,u-1|0))(c=>{const f=r+rt(c+1|0)*s,d=t.cx+t.r*Ke(f),l=t.cy+t.r*Oe(f),_=r+rt(c)*s;return[4,t.cx+t.r*Ke(_)-a*t.r*Oe(_),t.cy+t.r*Oe(_)+a*t.r*Ke(_),d+a*t.r*Oe(f),l-a*t.r*Ke(f),d,l]})},e_=t=>e=>{const n=t.h*.38,r=Kf(Zf(Uf)({x:t.x,y:t.y-n,w:t.w,h:n}))(t.y),i=nn(e)(nn(t.w/2)(t.h/2));return 0<r.length?[1,r[0].p1.x,r[0].p1.y,...Tt(r)(o=>Zx(o.c)(o.p1)(o.p2)),2,t.x+t.w,t.y+t.h-i,3,t.x+t.w,t.y+t.h,t.x+t.w-i,t.y+t.h,2,t.x+i,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-i,2,r[0].p1.x,r[0].p1.y,5]:Yx(t)(e)},n_=t=>e=>n=>r=>i=>o=>{if(e==="Rectangle")return t.drawRoundedRect(n)(r)(i)(o);if(e==="Cylinder"){const u=jf(n);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Parallelogram"){const u=Xf(n);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Diamond"){const u=t_(n);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Ellipse"){const u=Yf(n);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Document"){const u=Vf(n);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Cloud"){const u=e_(n)(r);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}return t.drawRoundedRect(n)(r)(i)(o)},Kx=t=>()=>t.clip("evenodd"),tN=t=>e=>()=>{const n=Math.max(8,Math.ceil(8/Math.max(e.tile,.001))),r=Math.max(2,Math.round(e.tile*n)),i=document.createElement("canvas");i.width=r,i.height=r;const o=i.getContext("2d");o.scale(n,n),o.fillStyle=e.bgCss,o.fillRect(0,0,e.tile,e.tile),o.fillStyle=e.dotCss,o.beginPath(),o.arc(e.tile/2,e.tile/2,e.dotR,0,2*Math.PI),o.fill();const u=t.createPattern(i,"repeat");u&&typeof u.setTransform=="function"&&u.setTransform(new DOMMatrix().scaleSelf(1/n,1/n)),t.save(),t.fillStyle=u,t.fillRect(e.vx,e.vy,e.vw,e.vh),t.restore()},ta=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},ea=t=>e=>n=>{const r=e.stroke;return()=>{const i=r.value,o=Fd(t)(n);if(i!==n)return o(),e.stroke.value=n}},eN=t=>e=>n=>{const r=e.font;return()=>{const i=r.value,o=$d(t)(n);if(i!==n)return o(),e.font.value=n}},Fi=t=>e=>n=>{const r=e.fill;return()=>{const i=r.value,o=Bd(t)(n);if(i!==n)return o(),e.fill.value=n}},Zo=t=>e=>{const n=e.length,r=o=>{if(o>=n)return()=>{};const u=o>=0&&o<e.length?e[o]:0;if(u===1){const s=tc(t)((()=>{const c=o+1|0;return c>=0&&c<e.length?e[c]:0})())((()=>{const c=o+2|0;return c>=0&&c<e.length?e[c]:0})()),a=r(o+3|0);return()=>(s(),a())}if(u===2){const s=ui(t)((()=>{const c=o+1|0;return c>=0&&c<e.length?e[c]:0})())((()=>{const c=o+2|0;return c>=0&&c<e.length?e[c]:0})()),a=r(o+3|0);return()=>(s(),a())}if(u===3){const s=si(t)({cpx:(()=>{const c=o+1|0;return c>=0&&c<e.length?e[c]:0})(),cpy:(()=>{const c=o+2|0;return c>=0&&c<e.length?e[c]:0})(),x:(()=>{const c=o+3|0;return c>=0&&c<e.length?e[c]:0})(),y:(()=>{const c=o+4|0;return c>=0&&c<e.length?e[c]:0})()}),a=r(o+5|0);return()=>(s(),a())}if(u===4){const s=Xd(t)({cp1x:(()=>{const c=o+1|0;return c>=0&&c<e.length?e[c]:0})(),cp1y:(()=>{const c=o+2|0;return c>=0&&c<e.length?e[c]:0})(),cp2x:(()=>{const c=o+3|0;return c>=0&&c<e.length?e[c]:0})(),cp2y:(()=>{const c=o+4|0;return c>=0&&c<e.length?e[c]:0})(),x:(()=>{const c=o+5|0;return c>=0&&c<e.length?e[c]:0})(),y:(()=>{const c=o+6|0;return c>=0&&c<e.length?e[c]:0})()}),a=r(o+7|0);return()=>(s(),a())}if(u===5){const s=ec(t),a=r(o+1|0);return()=>(s(),a())}return()=>{}},i=Ka(t);return()=>(i(),r(0)())},nN=t=>e=>n=>r=>i=>o=>{const u=ta(o)(ta(r/2)(i/2)),s=tc(t)(e+u)(n);return()=>(s(),ui(t)(e+r-u)(n)(),si(t)({cpx:e+r,cpy:n,x:e+r,y:n+u})(),ui(t)(e+r)(n+i-u)(),si(t)({cpx:e+r,cpy:n+i,x:e+r-u,y:n+i})(),ui(t)(e+u)(n+i)(),si(t)({cpx:e,cpy:n+i,x:e,y:n+i-u})(),ui(t)(e)(n+u)(),si(t)({cpx:e,cpy:n,x:e+u,y:n})(),ec(t)())},rN=()=>({font:{value:""},fill:{value:""},stroke:{value:""}}),iN=t=>e=>{const n=Md(t)({x:0,y:0,width:e.width,height:e.height});return()=>{n();const r=rN();return{ctx:t,surface:e,styleCache:r,maskDepth:{value:0}}}},oN={map:t=>e=>n=>{const r=e(n);return()=>{const i=r();return t(i)}}},uN=t=>ie(t.weight)+" "+Ca(t.size)+"px "+t.family,vn=t=>{const e=Ca(rt(t.a)/255);return t.a>=255?"rgb("+ie(t.r)+","+ie(t.g)+","+ie(t.b)+")":"rgba("+ie(t.r)+","+ie(t.g)+","+ie(t.b)+","+e+")"},sN=t=>e=>n=>r=>{const i=Fi(t)(n)(vn(r));return()=>(i(),Wd(t)({x:0,y:0,width:e.width,height:e.height})())},aN=t=>e=>n=>{const r=e.font;return()=>(r.value="",e.fill.value="",e.stroke.value="",tN(t)({vx:n.viewport.vx,vy:n.viewport.vy,vw:n.viewport.vw,vh:n.viewport.vh,bgCss:vn(n.bgColor),dotCss:vn(n.dotColor),tile:n.tile,dotR:n.dotRadius})())},cN=t=>e=>n=>r=>{const i=Fi(t)(e)(vn(r));return()=>(i(),Zo(t)(n)(),Gu(t)())},gN=t=>e=>n=>r=>i=>{const o=Fi(t)(e)(vn(r));return()=>(o(),ea(t)(e)(vn(i.color))(),ku(t)(i.width)(),no(t)((()=>{if(i.lineJoin==="RoundJoin")return eo;if(i.lineJoin==="BevelJoin")return Bu;if(i.lineJoin==="MiterJoin")return Fu;g()})())(),Wu(t)((()=>{if(i.lineCap==="ButtCap")return zu;if(i.lineCap==="RoundCap")return Ru;if(i.lineCap==="SquareCap")return Qu;g()})())(),Zo(t)(n)(),Gu(t)(),Su(t)())},fN=t=>e=>n=>r=>i=>o=>{const u=Ka(t);return()=>{if(u(),nN(t)(n.x)(n.y)(n.w)(n.h)(r)(),i.tag==="Just"?(Fi(t)(e)(vn(i._1.color))(),Gu(t)()):i.tag==="Nothing"||g(),o.tag==="Just")return ea(t)(e)(vn(o._1.color))(),ku(t)(o._1.width)(),no(t)((()=>{if(o._1.lineJoin==="RoundJoin")return eo;if(o._1.lineJoin==="BevelJoin")return Bu;if(o._1.lineJoin==="MiterJoin")return Fu;g()})())(),Wu(t)((()=>{if(o._1.lineCap==="ButtCap")return zu;if(o._1.lineCap==="RoundCap")return Ru;if(o._1.lineCap==="SquareCap")return Qu;g()})())(),Su(t)();o.tag!=="Nothing"&&g()}},_N=t=>e=>n=>r=>{const i=ea(t)(e)(vn(r.color));return()=>(i(),ku(t)(r.width)(),no(t)((()=>{if(r.lineJoin==="RoundJoin")return eo;if(r.lineJoin==="BevelJoin")return Bu;if(r.lineJoin==="MiterJoin")return Fu;g()})())(),Wu(t)((()=>{if(r.lineCap==="ButtCap")return zu;if(r.lineCap==="RoundCap")return Ru;if(r.lineCap==="SquareCap")return Qu;g()})())(),Zo(t)(n)(),Su(t)())},r_=t=>e=>n=>{const r=Fi(t)(e)(vn(n.color));return()=>(r(),eN(t)(e)(uN(n.font))(),ol(t)((()=>{if(n.align==="AlignLeft")return Kd;if(n.align==="AlignCenter")return el;if(n.align==="AlignRight")return tl;g()})())(),il(t)((()=>{if(n.baseline==="BaselineTop")return Vd;if(n.baseline==="BaselineMiddle")return Ud;if(n.baseline==="BaselineAlphabetic")return jd;if(n.baseline==="BaselineBottom")return Zd;g()})())(),Yd(t)(n.content)(n.x)(n.y)())},i_={apply:t=>e=>n=>{const r=t(n),i=e(n);return()=>{const o=r(),u=i();return o(u)}},Functor0:()=>oN},dN={bind:t=>e=>n=>{const r=t(n);return()=>{const i=r();return e(i)(n)()}},Apply0:()=>i_},lN=t=>e=>n=>{const r=ta(e.width/n.vw)(e.height/n.vh),i=Pu(t)({translateX:(e.width-n.vw*r)/2-n.vx*r,translateY:(e.height-n.vh*r)/2-n.vy*r});return()=>(i(),Ki(t)({scaleX:r,scaleY:r})(),no(t)(eo)())},hN={pure:t=>e=>()=>t,Apply0:()=>i_},pN={Applicative0:()=>hN,Bind1:()=>dN},o_={fillPath:t=>e=>n=>{const r=cN(n.ctx)(n.styleCache)(t)(e.color),i=n.maskDepth;return()=>{if(i.value===0)return r()}},strokePath:t=>e=>n=>{const r=_N(n.ctx)(n.styleCache)(t)(e),i=n.maskDepth;return()=>{if(i.value===0)return r()}},fillStrokePath:t=>e=>n=>r=>{const i=gN(r.ctx)(r.styleCache)(t)(e.color)(n),o=r.maskDepth;return()=>{if(o.value===0)return i()}},drawRoundedRect:t=>e=>n=>r=>i=>{const o=fN(i.ctx)(i.styleCache)(t)(e)(n)(r),u=i.maskDepth;return()=>{if(u.value===0)return o()}},drawText:t=>e=>{const n=r_(e.ctx)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},drawTextAffine:t=>e=>n=>{const r=sr(n.ctx),i=n.maskDepth;return()=>{if(i.value===0)return r(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value="",Hd(n.ctx)(t)(),r_(n.ctx)(n.styleCache)(e)(),ar(n.ctx)(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value=""}},pushTransform:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0)return n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",Pu(e.ctx)({translateX:t.tx,translateY:t.ty})(),Ki(e.ctx)({scaleX:t.sx,scaleY:t.sy})()}},popTransform:t=>{const e=ar(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushBakedTransform:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0)return n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",Pu(e.ctx)({translateX:t.tx,translateY:t.ty})(),Ki(e.ctx)({scaleX:t.sx,scaleY:t.sy})()}},popBakedTransform:t=>{const e=ar(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushClip:t=>e=>n=>{const r=sr(n.ctx),i=n.maskDepth;return()=>{if(i.value===0){if(r(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value="",Zo(n.ctx)(t)(),e==="NonZero")return zd(n.ctx)();if(e==="EvenOdd")return Kx(n.ctx)();g()}}},popClip:t=>{const e=ar(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushBlend:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0){if(n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",t==="Normal")return rc(e.ctx)(nl)();if(t==="Difference")return rc(e.ctx)(rl)();g()}}},popBlend:t=>{const e=ar(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushAlpha:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0)return n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",Qd(e.ctx)(t)()}},popAlpha:t=>{const e=ar(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushLayer:t=>e=>{if(t==="LayerNodeMask"){const n=e.maskDepth;return()=>{const r=n.value;n.value=r+1|0}}return()=>{}},popLayer:t=>{const e=t.maskDepth;return()=>{const n=e.value,r=n-1|0;if(n>0)return t.maskDepth.value=r}},setViewport:t=>e=>{const n=lN(e.ctx)(e.surface)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},clearBackground:t=>e=>{const n=sN(e.ctx)(e.surface)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},backgroundDots:t=>e=>{const n=aN(e.ctx)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},measureText:t=>e=>n=>{const r=Af(t)(e);return()=>r},measureInk:t=>e=>n=>{const r=Bf(t)(e);return()=>r},insideTokenStyle:t=>e=>()=>qf,Monad0:()=>pN},mN=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Hr=t=>e=>n=>{const r=mN(.05)(1-t-e);return n<t?0:n>1-e?1:(n-t)/r},u_=t=>{const e=st.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=st.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},Ko=t=>{if(t.tag==="Hidden")return{alpha:0,scale:0};if(t.tag==="Visible")return{alpha:1,scale:1};if(t.tag==="PloppingIn")return{alpha:t._1>0?1:0,scale:pi(8)(.6)(u_(t._1))};if(t.tag==="PloppingOut")return{alpha:t._1<1?1:0,scale:pi(8)(.6)(u_(1-t._1))};g()};function yN(t,e){const n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function xN(t){const e=t.length,n=new Array(e);for(let r=0;r<e;r++){const i=t[r],o=t[(r+1)%e];n[r]={a:i,b:o,len:yN(i,o)}}return n}function NN(t,e,n){let r=0;for(let i=0;i<t.length;i++){const o=t[i],u=r,s=u+o.len;if(n<=s){const a=o.len>1e-6?(n-u)/o.len:0;return{x:o.a.x+(o.b.x-o.a.x)*a,y:o.a.y+(o.b.y-o.a.y)*a}}r=s}return e.length>0?e[e.length-1]:{x:0,y:0}}function s_(t,e){if(e.length===0)return[];const n=xN(e);let r=0;for(let o=0;o<n.length;o++)r+=n[o].len;const i=new Array(t);for(let o=0;o<t;o++)i[o]=NN(n,e,o*r/t);return i}function JN(t,e){const n=e.length;if(n===0)return e;const r=(t%n+n)%n|0,i=new Array(n);for(let o=0;o<n;o++)i[o]=e[(o+r)%n];return i}function TN(t,e){const n=e.length;if(n===0)return e;let r=0,i=1/0;for(let o=0;o<n;o++){let u=0;for(let s=0;s<n;s++){const a=t[s]||{x:0,y:0},c=e[(s+o)%n]||{x:0,y:0},f=a.x-c.x,d=a.y-c.y;u+=f*f+d*d}u<i&&(i=u,r=o)}return JN(r,e)}const a_=t=>e=>n=>{const r=s_(t,e),i=s_(t,n),o=TN(r,i);return{from:r,to:o}};function c_(t){const e=t.length;if(e===0)return{x:0,y:0};let n=0,r=0;for(let i=0;i<e;i++)n+=t[i].x,r+=t[i].y;return{x:n/e,y:r/e}}function vN(t,e){const n=e.x-t.x,r=e.y-t.y,i=Math.sqrt(n*n+r*r);return i<=1e-4?{x:1,y:0}:{x:n/i,y:r/i}}function wN(t,e){const n=e.length;if(n===0)return e;const r=new Array(n);for(let i=0;i<n;i++){const o=e[((i-1)%n+n)%n],u=e[((i+1)%n+n)%n],s=e[i];r[i]={x:s.x+((o.x+u.x)/2-s.x)*t,y:s.y+((o.y+u.y)/2-s.y)*t}}return r}function bN(t){return t<0?0:t>1?1:t}const g_=t=>e=>n=>r=>{const i=e.length;if(i===0)return[];const o=c_(e),u=c_(n),s=vN(o,u),a=new Array(i);let c=1/0,f=-1/0;for(let _=0;_<i;_++){const h=e[_],m=(h.x-o.x)*s.x+(h.y-o.y)*s.y;a[_]=m,m<c&&(c=m),m>f&&(f=m)}const d=f-c;let l=new Array(i);for(let _=0;_<i;_++){const h=e[_],m=n[_];if(m===void 0){l[_]=h;continue}const p=d<=1e-4?0:r.maxDelay*(1-(a[_]-c)/d),y=Math.max(1e-4,1-p),x=bN((t-p)/y),N=x*x*(3-2*x);l[_]={x:h.x+(m.x-h.x)*N,y:h.y+(m.y-h.y)*N}}for(let _=0;_<r.smoothPasses;_++)l=wN(.5,l);return l},wn=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},f_=J(Tr)(0),__=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},LN=J(t=>e=>t+e.len)(0),d_=t=>{const e=Bt(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Tt(bt(1,t.length,t))(n=>[2,n.x,n.y]),5];g()},kN=t=>e=>{const n=wn(e)(wn(t.w/2)(t.h/2));return[1,t.x+n,t.y,2,t.x+t.w-n,t.y,3,t.x+t.w,t.y,t.x+t.w,t.y+n,2,t.x+t.w,t.y+t.h-n,3,t.x+t.w,t.y+t.h,t.x+t.w-n,t.y+t.h,2,t.x+n,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-n,2,t.x,t.y+n,3,t.x,t.y,t.x+n,t.y,5]},EN=t=>{const e=Bt(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Tt(e._1.tail)(n=>[2,n.x,n.y])];g()},CN=t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h};if(t.shape==="Cylinder")return jf(e);if(t.shape==="Parallelogram")return Xf(e);if(t.shape==="Diamond")return t_(e);if(t.shape==="Ellipse")return Yf(e);if(t.shape==="Document")return Vf(e);if(t.shape==="Cloud")return e_(e)(7);if(t.shape==="Rectangle")return kN(e)(7);g()},pe=t=>e=>n=>O(r=>{const i=rt(r)/rt(n);return{x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}})(Dt(0,n-1|0)),SN=t=>{const e=nn(t.w*.18)(t.h*.6);return[...pe({x:t.x+e,y:t.y})({x:t.x+t.w,y:t.y})(16),...pe({x:t.x+t.w,y:t.y})({x:t.x+t.w-e,y:t.y+t.h})(16),...pe({x:t.x+t.w-e,y:t.y+t.h})({x:t.x,y:t.y+t.h})(16),...pe({x:t.x,y:t.y+t.h})({x:t.x+e,y:t.y})(16)]},Or=t=>e=>{const n=wn(t)(wn(e.w/2)(e.h/2));return{...e,x:e.x+n,y:e.y+n,w:e.w-2*n,h:e.h-2*n}},na=t=>e=>{const n=e.y-t.y,r=e.x-t.x;return Ee(r*r+n*n)},GN=t=>Je(e=>n=>({a:e,b:n,len:na(e)(n)}),t,bt(1,t.length,t)),PN=t=>e=>{const n=e.length-1|0,r=n>=0&&n<e.length?w("Just",e[n]):T,i=(()=>{if(r.tag==="Just")return[r._1];if(r.tag==="Nothing")return[];g()})(),o=0<e.length?w("Just",e[0]):T,u=(()=>{if(o.tag==="Just")return o._1;if(o.tag==="Nothing")return{x:0,y:0};g()})(),s=e.length;return s<3?e:[u,...Tt(Dt(1,s-2|0))(a=>{const c=a+1|0,f=c>=0&&c<e.length?w("Just",e[c]):T,d=a>=0&&a<e.length?w("Just",e[a]):T,l=a-1|0,_=l>=0&&l<e.length?w("Just",e[l]):T;if(_.tag==="Just"&&d.tag==="Just"&&f.tag==="Just"){const h=d._1,m=na(h)(f._1),p=na(_._1)(h),y=wn(t)(m/2),x=wn(t)(p/2),N=m>0?y/m:0,v=h.x+(f._1.x-h.x)*N,L=h.y+(f._1.y-h.y)*N,k=p>0?x/p:0,E=h.x+(_._1.x-h.x)*k,Q=h.y+(_._1.y-h.y)*k;return O(H=>{const j=rt(H)/rt(10),S=1-j;return{x:S*S*E+2*S*j*h.x+j*j*v,y:S*S*Q+2*S*j*h.y+j*j*L}})(Dt(0,10))}return[]}),...i]},IN=t=>e=>n=>r=>i=>O(o=>{const u=rt(o)/rt(i),s=1-u,a=u*u*u,c=3*s*u*u,f=3*s*s*u,d=s*s*s;return{x:d*t.x+f*e.x+c*n.x+a*r.x,y:d*t.y+f*e.y+c*n.y+a*r.y}})(Dt(0,i-1|0)),DN=t=>[...pe({x:t.x,y:t.y})({x:t.x+t.w,y:t.y})(12),...pe({x:t.x+t.w,y:t.y})({x:t.x+t.w,y:t.y+t.h*.85})(12),...IN({x:t.x+t.w,y:t.y+t.h*.85})({x:t.x+t.w*.66,y:t.y+t.h*1.05})({x:t.x+t.w*.34,y:t.y+t.h*.65})({x:t.x,y:t.y+t.h*.85})(32),...pe({x:t.x,y:t.y+t.h*.85})({x:t.x,y:t.y})(12)],l_=t=>e=>O(n=>{const r=6.283185307179586*rt(n)/rt(64);return{x:t.x+e*Ke(r),y:t.y+e*Oe(r)}})(Dt(0,63)),tu=t=>e=>{const n=.5522847498*e;return[1,t.x+e,t.y,4,t.x+e,t.y+n,t.x+n,t.y+e,t.x,t.y+e,4,t.x-n,t.y+e,t.x-e,t.y+n,t.x-e,t.y,4,t.x-e,t.y-n,t.x-n,t.y-e,t.x,t.y-e,4,t.x+n,t.y-e,t.x+e,t.y-n,t.x+e,t.y,5]},AN=t=>{const e=t.y+t.h/2,n=nn(t.h*.4)(t.w*.2);return[...pe({x:t.x+n,y:t.y})({x:t.x+t.w-n,y:t.y})(10),...pe({x:t.x+t.w-n,y:t.y})({x:t.x+t.w,y:e})(8),...pe({x:t.x+t.w,y:e})({x:t.x+t.w-n,y:t.y+t.h})(8),...pe({x:t.x+t.w-n,y:t.y+t.h})({x:t.x+n,y:t.y+t.h})(10),...pe({x:t.x+n,y:t.y+t.h})({x:t.x,y:e})(8),...pe({x:t.x,y:e})({x:t.x+n,y:t.y})(8)]},h_=t=>{const e=t.length;return e===0?{x:0,y:0}:{x:f_(O(n=>n.x)(t))/rt(e),y:f_(O(n=>n.y)(t))/rt(e)}},eu=t=>e=>n=>r=>i=>O(o=>{const u=n+(r-n)*(rt(o)/rt(i));return{x:t.x+e*Ke(u),y:t.y+e*Oe(u)}})(Dt(0,i-1|0)),p_=t=>e=>{const n=wn(t)(wn(e.w/2)(e.h/2));return[...pe({x:e.x+n,y:e.y})({x:e.x+e.w-n,y:e.y})(6),...eu({x:e.x+e.w-n,y:e.y+n})(n)(4.71238898038469)(6.283185307179586)(12),...pe({x:e.x+e.w,y:e.y+n})({x:e.x+e.w,y:e.y+e.h-n})(6),...eu({x:e.x+e.w-n,y:e.y+e.h-n})(n)(0)(1.5707963267948966)(12),...pe({x:e.x+e.w-n,y:e.y+e.h})({x:e.x+n,y:e.y+e.h})(6),...eu({x:e.x+n,y:e.y+e.h-n})(n)(1.5707963267948966)(3.141592653589793)(12),...pe({x:e.x,y:e.y+e.h-n})({x:e.x,y:e.y+n})(6),...eu({x:e.x+n,y:e.y+n})(n)(3.141592653589793)(4.71238898038469)(12)]},nu=t=>e=>n=>r=>i=>o=>O(u=>{const s=r+(i-r)*(rt(u)/rt(o));return{x:t.x+e*Ke(s),y:t.y+n*Oe(s)}})(Dt(0,o-1|0)),BN=t=>{const e=t.h*.38;return[...Tt(Kf(Zf(Uf)({x:t.x,y:t.y-e,w:t.w,h:e}))(t.y))(n=>{const r=ur(n.p2.y-n.c.cy)(n.p2.x-n.c.cx),i=ur(n.p1.y-n.c.cy)(n.p1.x-n.c.cx);return nu({x:n.c.cx,y:n.c.cy})(n.c.r)(n.c.r)(i)(r>i?r:r+6.283185307179586)(16)}),...pe({x:t.x+t.w,y:t.y})({x:t.x+t.w,y:t.y+t.h})(8),...pe({x:t.x+t.w,y:t.y+t.h})({x:t.x,y:t.y+t.h})(12),...pe({x:t.x,y:t.y+t.h})({x:t.x,y:t.y})(8)]},FN=t=>{const e=wn(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+e,i=t.y+t.h+5-e-2,o=t.x+n;return[...nu({x:o,y:r})(n)(e)(3.141592653589793)(6.283185307179586)(24),...pe({x:t.x+t.w,y:r})({x:t.x+t.w,y:i})(12),...nu({x:o,y:i})(n)(e)(0)(3.141592653589793)(24),...pe({x:t.x,y:i})({x:t.x,y:r})(12)]},ru=t=>e=>e.shape==="Cylinder"?FN(e):e.shape==="Parallelogram"?SN(e):e.shape==="Diamond"?AN(e):e.shape==="Ellipse"?p_(nn(e.w)(e.h)/2)(e):e.shape==="Document"?DN(e):e.shape==="Cloud"?BN(e):p_(t)(e),RN=t=>{const e=wn(t.h*.075)(t.w*.075),n=t.w/2;return nu({x:t.x+n,y:t.y+e})(n)(e)(0)(3.141592653589793)(24)},QN=t=>e=>n=>J(r=>i=>{const o=r.pos+i.len,u=n<o?(n-r.pos)/i.len:1,s={x:i.a.x+(i.b.x-i.a.x)*u,y:i.a.y+(i.b.y-i.a.y)*u},a=e>r.pos?(e-r.pos)/i.len:0,c={x:i.a.x+(i.b.x-i.a.x)*a,y:i.a.y+(i.b.y-i.a.y)*a},f=r.points.length-1|0,d=f>=0&&f<r.points.length?(()=>{const l=r.points[f].x-c.x;return(l<0?-l<1e-4:l<1e-4)&&(()=>{const _=r.points[f].y-c.y;return _<0?-_<1e-4:_<1e-4})()})()?Ft(r.points)(s):[...r.points,c,s]:[c,s];return i.len<=0||o<=e||r.pos>=n?{...r,pos:o}:{pos:o,points:d}})({pos:0,points:[]})(t).points,zN=t=>e=>n=>{const r=Bt(i=>T,i=>o=>w("Just",{head:i,tail:o}),t);if(r.tag==="Nothing")return[];if(r.tag==="Just"){const i=GN(t),o=LN(i),u=__(0)(o)(e*o),s=__(0)(o)(n*o);return s<=u?[]:QN(i)(u)(s)}g()},ra=t=>t,Bn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},pr=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},WN=Y1(Ba)(zt),MN=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},HN=t=>e=>{const n=it.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},m_=ra("SegMove"),ON=ra("SegLine"),qN=ra("SegQuad"),y_={offset:.4,passes:1,rMax:1.5},x_=t=>de(dn(t.x*7919+t.y*3001+t.w*113+t.h*17+1))*-1640531535|0,iu=t=>e=>n=>()=>{t.push(3),t.push(e.x),t.push(e.y),t.push(n.x),t.push(n.y)},ou=t=>e=>()=>{t.push(1),t.push(e.x),t.push(e.y)},Fn=t=>e=>()=>{t.push(2),t.push(e.x),t.push(e.y)},Ri=(()=>{const t=J(e=>n=>((e*31|0)+de(dn(n.x*100))|0)+de(dn(n.y*100))|0)(1);return e=>t(e)*-1640531535|0})(),$N=t=>{const e=[];let n=0,r={x:0,y:0};for(;n<t.length;){const i=n,o=r,u=i>=0&&i<t.length?w("Just",t[i]):T;if(u.tag==="Nothing"){n=t.length;continue}if(u.tag==="Just"){if(u._1===1){const s={x:(()=>{const a=i+1|0;return a>=0&&a<t.length?t[a]:0})(),y:(()=>{const a=i+2|0;return a>=0&&a<t.length?t[a]:0})()};e.push({kind:m_,m:o,c:o,p:s,len:0}),r=s,n=i+3|0;continue}if(u._1===2){const s={x:(()=>{const f=i+1|0;return f>=0&&f<t.length?t[f]:0})(),y:(()=>{const f=i+2|0;return f>=0&&f<t.length?t[f]:0})()},a=s.x-o.x,c=s.y-o.y;e.push({kind:ON,m:o,c:o,p:s,len:Ee(a*a+c*c)}),r=s,n=i+3|0;continue}if(u._1===3){const s={x:(()=>{const f=i+3|0;return f>=0&&f<t.length?t[f]:0})(),y:(()=>{const f=i+4|0;return f>=0&&f<t.length?t[f]:0})()},a=s.x-o.x,c=s.y-o.y;e.push({kind:qN,m:o,c:{x:(()=>{const f=i+1|0;return f>=0&&f<t.length?t[f]:0})(),y:(()=>{const f=i+2|0;return f>=0&&f<t.length?t[f]:0})()},p:s,len:Ee(a*a+c*c)*1.05}),r=s,n=i+5|0;continue}if(u._1===5){e.push({kind:m_,m:o,c:o,p:o,len:0}),n=i+1|0;continue}n=t.length;continue}g()}return e},YN=t=>e=>{const n=e.length-1|0,r=n<1?[]:bt(0,n,e),i=(()=>{const u=r.length-1|0;return u>=0&&u<r.length?w("Just",r[u]):T})(),o=e.length-1|0;if(o>=0&&o<e.length&&i.tag==="Just"){const u=e[o].y-i._1.y,s=e[o].x-i._1.x,a=Ee(s*s+u*u);return a<=1e-4?e:Ft((()=>{const c=e.length-1|0;return c<1?[]:bt(0,c,e)})())({x:e[o].x+s/a*t,y:e[o].y+u/a*t})}return e},XN=t=>e=>n=>ke(J(r=>i=>{const o=ae(0)(t)(r.prng),u=ae(0)(6.283185307179586)(o.prng);return{prng:u.prng,out:[{x:i.x+o.value*Ke(u.value),y:i.y+o.value*Oe(u.value)},...r.out]}})({prng:e,out:[]})(n).out),VN=t=>e=>n=>{if(e.kind==="SegMove")return ou(t)(e.p);if(e.kind==="SegLine")return Fn(t)({x:e.m.x+(e.p.x-e.m.x)*n,y:e.m.y+(e.p.y-e.m.y)*n});if(e.kind==="SegQuad")return Fn(t)({x:e.m.x+(e.p.x-e.m.x)*n,y:e.m.y+(e.p.y-e.m.y)*n});g()},UN=t=>e=>{if(e.kind==="SegMove")return ou(t)(e.p);if(e.kind==="SegLine")return Fn(t)(e.p);if(e.kind==="SegQuad")return iu(t)(e.c)(e.p);g()},N_=t=>e=>{const n=$N(e),r=J(s=>a=>s+a.len)(0)(n)*Bn(0)(pr(1)(t)),i=[];let o=0,u=0;for(;u<n.length;){const s=u,a=o;if(s>=0&&s<n.length){if(a+n[s].len<=r){const c=n[s];UN(i)(c)(),o=a+c.len,u=s+1|0;continue}if(a>=r){u=n.length;continue}VN(i)(n[s])((r-a)/Bn(n[s].len)(1e-4))()}u=n.length}return i},J_={offset:1.5,passes:2,rMax:14,overshoot:2.5},T_=t=>e=>n=>r=>{const i=r.y-n.y,o=n.y-e.y,u=r.x-n.x,s=Ee(u*u+i*i),a=n.x-e.x,c=Ee(a*a+o*o),f=pr(t.rMax*(gd(c>0&&s>0?Bn(-1)(pr(1)((a*u+o*i)/(c*s))):1)/3.141592653589793))(.4*pr(c)(s));return{inP:c>0?{x:n.x-a/c*f,y:n.y-o/c*f}:n,curr:n,outP:s>0?{x:n.x+u/s*f,y:n.y+i/s*f}:n}},v_=t=>e=>{const n=e.length,r=[],i=0<e.length?w("Just",e[0]):T;if(i.tag==="Just"?ou(r)(i._1)():i.tag==="Nothing"||g(),n>=3){let u=1;for(;u<=(n-2|0);){const s=u,a=s+1|0;if(a>=0&&a<e.length){if(s>=0&&s<e.length){const c=s-1|0;if(c>=0&&c<e.length){const f=T_(t)(e[c])(e[s])(e[a]);Fn(r)(f.inP)(),iu(r)(f.curr)(f.outP)()}}u=s+1|0;continue}u=s+1|0}}const o=e.length-1|0;return o>=0&&o<e.length&&n>=2&&Fn(r)(e[o])(),r},jN=t=>e=>n=>r=>i=>{if(i.length<4)return v_(t)(i);const o=0<i.length?w("Just",i[0]):T,u=(()=>{if(o.tag==="Nothing")return{x:0,y:0};if(o.tag==="Just")return o._1;g()})(),s=i.length-1|0,a=Xn(Xn(e)(s)+s|0)(s),c=_=>{const h=Xn(_+s|0)(s);return h>=0&&h<i.length?i[h]:u},f=O(_=>T_(t)(c((a+_|0)-1|0))(c(a+_|0))(c((a+_|0)+1|0)))(Dt(0,s-1|0)),d=[],l=0<f.length?w("Just",f[0]):T;if(l.tag==="Just")if(ou(d)(l._1.outP)(),WN((()=>{const _=Bt(h=>T,h=>m=>w("Just",m),f);if(_.tag==="Nothing")return[];if(_.tag==="Just")return _._1;g()})())(_=>{const h=Fn(d)(_.inP);return()=>(h(),iu(d)(_.curr)(_.outP)())})(),n)Fn(d)(l._1.inP)(),iu(d)(l._1.curr)(l._1.outP)(),d.push(5);else{const _=f.length-1|0;_>=0&&_<f.length?Fn(d)((()=>{const h=1-r;return{x:f[_].outP.x+(l._1.inP.x-f[_].outP.x)*h,y:f[_].outP.y+(l._1.inP.y-f[_].outP.y)*h}})())():Fn(d)(l._1.inP)()}else l.tag==="Nothing"||g();return d},qr=t=>e=>n=>r=>{const i=MN(1)(r.length-1|0),o=ae(0)(rt(i))(fs("shape")(e)),u=HN(i-1|0)(de(dn(o.value))),s=o.prng;return O(a=>{const c=ae(0)(1)(fs(ie(a))(s)),f=ae(-.18)(.3)(c.prng),d=c.value<.7,l=ae(.5)(.85)(f.prng),_=XN(t.offset)(l.prng)(r);return{path:n?jN(t)(u)(d)(f.value)(_):v_(t)(_),alpha:l.value}})(Dt(0,t.passes-1|0))},ZN=t=>e=>n=>qr(t)(e)(!0)([{x:n.x,y:n.y},{x:n.x+n.w,y:n.y},{x:n.x+n.w,y:n.y+n.h},{x:n.x,y:n.y+n.h},{x:n.x,y:n.y}]),KN=t=>e=>n=>{const r=Bn(0)(pr(1)(n)),i=e.h/rt(4),o=Bn(6)(i*1.4);return xt(u=>u)(O(u=>{if(r<Bn(0)(rt(u)/rt(4)-.05))return T;const s=fs(ie(u))(t),a=Bn(0)(rt(u)/rt(4)-.05),c=Xn(u)(2)===0,f=c?e.x-2:e.x+e.w+2,d=c?e.x+e.w+2:e.x-2,l=e.y+(rt(u)+.5)*i;return w("Just",{path:N_(Bn(0)(pr(1)((r-a)/Bn(1e-4)(pr(1)(rt(u+1|0)/rt(4)+.05)-a))))((()=>{const _={rMax:2,offset:.6,passes:1},h=ke(J(p=>y=>{const x=ae(-i*.08)(i*.08)(p.prng);return{prng:x.prng,out:[{x:f+(d-f)*(rt(y)/rt(4)),y:l+x.value},...p.out]}})({prng:s,out:[]})(Dt(0,4)).out),m=h.length<2?[]:qr(_)(s)(!1)(h);return 0<m.length?m[0].path:[]})()),width:o,alpha:1})})(Dt(0,3)))},ia=(t,e,n)=>({tag:t,_1:e,_2:n}),w_=t=>t,oa=(t,e,n)=>({tag:t,_1:e,_2:n}),uu=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},b_=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Qi=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},L_=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},fe=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Me=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),mr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},tJ=zt.foldMap(bd),su=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},k_=Kt(P)(zt),eJ=Ua(P),nJ=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},ua=w_("LabelsShown"),rJ=w_("LabelsHidden"),E_=t=>{const e=t.Monad0().Bind1(),n=t.popTransform,r=t.popAlpha;return i=>o=>u=>s=>a=>e.bind(t.pushAlpha(i.fadeAlpha))(()=>e.bind(t.pushTransform({tx:o*(1-i.popScale),ty:u*(1-i.popScale),sx:i.popScale,sy:i.popScale}))(()=>e.bind(t.pushTransform({tx:0,ty:s.y*(1-i.flipY),sx:1,sy:i.flipY}))(()=>e.bind(a)(()=>e.bind(n)(()=>e.bind(n)(()=>r))))))},rn=t=>{const e=t.Apply0();return n=>J(r=>i=>e.apply(e.Functor0().map(o=>Ea)(r))(n(i)))(t.pure())},C_=t=>e=>n=>r=>i=>o=>{const u={x:n.x+n.w/2,y:n.y+n.h/2},s={x:e.x+e.w/2,y:e.y+e.h/2},a=Hr(i)(o)(r),c=0<t.length?w("Just",t[0]):T,f=(()=>{if(c.tag==="Just")return c._1;if(c.tag==="Nothing")return s;g()})(),d=t.length-1|0,l=d>=0&&d<t.length?w("Just",t[d]):T,_=(()=>{if(l.tag==="Just")return l._1;if(l.tag==="Nothing")return u;g()})(),h=a_(128)(ru(4)(Or(2)(e)))(l_(f)(6)),m=f.x-s.x,p=2*(()=>{const U=f.y-s.y;return(m<0?-m:m)+(U<0?-U:U)})(),y=_.x-u.x,x=2*(()=>{const U=_.y-u.y;return(y<0?-y:y)+(U<0?-U:U)})(),N=p+_i(t)+x,v=N<=1e-4?1:1-x/N,L=N<=1e-4?0:p/N,k=v-L,E=a_(128)(l_(_)(6))(ru(4)(Or(2)(n))),Q={maxDelay:.4,smoothPasses:2},H=vr(t)(uu(0)(1)(k<=1e-4?0:(a-L)/k)),j=(()=>{if(H.tag==="Just")return H._1;if(H.tag==="Nothing")return f;g()})(),S=(()=>{if(v>=1)return 0;const U=(a-v)/(1-v),Y=U<0?0:U>1?1:U;return Y*Y*(3-2*Y)})(),C=(()=>{if(L<=1e-4)return 1;const U=a/L,Y=U<0?0:U>1?1:U;return Y*Y*(3-2*Y)})();return a<L?oa("PolyShape",g_(C)(h.from)(h.to)(Q)):a>=v?oa("PolyShape",g_(S)(E.from)(E.to)(Q)):oa("CircleShape",j,6)},S_=t=>e=>n=>r=>i=>o=>{const u=C_(t)(e)(n)(r)(i)(o);if(u.tag==="PolyShape")return h_(u._1);if(u.tag==="CircleShape")return u._1;g()},iJ=t=>e=>{const n=t.y+t.h-6,r=t.y+6,i=t.x+14,o=t.x+t.w-14,u=J(Qi)(0)(O(s=>i-10<s.x+s.w+12&&o+10>s.x-12&&r-10<s.y+s.h+12&&n+10>s.y-12?b_((s.x+s.w+12-(i-10))/.7071067811865476)((n+10-(s.y-12))/.7071067811865476):0)(e));return{...t,x:t.x+u*.7071067811865476,y:t.y-u*.7071067811865476}},oJ=t=>e=>n=>J(r=>i=>{const o=L_(i)(e);if(o.tag==="Nothing")return r;if(o.tag==="Just"){const u=iJ(o._1)(r.obstacles);return{acc:K(P)(i)(u)(r.acc),obstacles:Ft(r.obstacles)(u)}}g()})({acc:A,obstacles:n})(t).acc,sa=(()=>{const t={r:24,g:24,b:27,a:255},e={r:244,g:244,b:245,a:255},n={r:248,g:249,b:246,a:255},r={r:26,g:26,b:26,a:255},i={r:28,g:101,b:192,a:255},o={r:247,g:248,b:250,a:255},u={r:42,g:48,b:60,a:255},s={r:120,g:130,b:146,a:255};return a=>{if(a==="Light")return{bg:{r:255,g:255,b:255,a:255},bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:214,g:211,b:209,a:255},shadowFill:{r:255,g:255,b:255,a:255},shadowDot:{r:26,g:26,b:26,a:255},chip:{r:255,g:235,b:130,a:255},chipShadow:{r:214,g:211,b:209,a:255},chipText:An,nodeFill:re,nodeStroke:An,text:An,edge:An,arrowFill:An,tokenOutsideFill:An,tokenOutsideStroke:re,tokenInside:re,tokenInsideStroke:re,tokenInsideBlend:jo,tokenInsideAlpha:1,chipPillFill:An,chipPillText:re,chipHairline:{r:26,g:26,b:26,a:90},trailDot:An,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(a==="Dark")return{bg:t,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:63,g:63,b:70,a:255},shadowFill:t,shadowDot:e,chip:{r:234,g:179,b:8,a:255},chipShadow:{r:0,g:0,b:0,a:120},chipText:t,nodeFill:An,nodeStroke:e,text:e,edge:e,arrowFill:e,tokenOutsideFill:re,tokenOutsideStroke:re,tokenInside:re,tokenInsideStroke:re,tokenInsideBlend:jo,tokenInsideAlpha:1,chipPillFill:e,chipPillText:t,chipHairline:{r:244,g:244,b:245,a:120},trailDot:e,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(a==="Blueprint")return{bg:i,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:90,g:160,b:230,a:255},shadowFill:i,shadowDot:re,chip:re,chipShadow:{r:0,g:0,b:0,a:120},chipText:i,nodeFill:i,nodeStroke:re,text:re,edge:re,arrowFill:re,tokenOutsideFill:re,tokenOutsideStroke:re,tokenInside:re,tokenInsideStroke:re,tokenInsideBlend:Mf,tokenInsideAlpha:.35,chipPillFill:re,chipPillText:i,chipHairline:{r:255,g:255,b:255,a:120},trailDot:re,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(a==="Whiteboard")return{bg:n,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:0,g:0,b:0,a:0},shadowFill:n,shadowDot:r,chip:{r:217,g:74,b:56,a:255},chipShadow:{r:26,g:26,b:26,a:60},chipText:n,nodeFill:n,nodeStroke:r,text:r,edge:r,arrowFill:r,tokenOutsideFill:r,tokenOutsideStroke:n,tokenInside:n,tokenInsideStroke:n,tokenInsideBlend:Mf,tokenInsideAlpha:1,chipPillFill:r,chipPillText:n,chipHairline:{r:26,g:26,b:26,a:90},trailDot:r,wobble:!0,fontFamily:"Supermarker, Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(a==="Isometric")return{bg:o,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:214,g:218,b:224,a:255},shadowFill:o,shadowDot:u,chip:{r:255,g:235,b:130,a:255},chipShadow:{r:100,g:110,b:125,a:90},chipText:u,nodeFill:{r:236,g:239,b:244,a:255},nodeStroke:u,text:u,edge:s,arrowFill:s,tokenOutsideFill:u,tokenOutsideStroke:re,tokenInside:re,tokenInsideStroke:re,tokenInsideBlend:jo,tokenInsideAlpha:1,chipPillFill:u,chipPillText:re,chipHairline:{r:60,g:66,b:78,a:90},trailDot:u,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};g()}})(),aa=t=>e=>Tt(Me(t.nodes))(n=>{const r=fe(n._1)(e.nodes);return r.tag==="Just"&&Ko(r._1).alpha>0?CN(n._2):[]}),uJ=t=>e=>n=>[1,t.vx,t.vy,2,t.vx+t.vw,t.vy,2,t.vx+t.vw,t.vy+t.vh,2,t.vx,t.vy+t.vh,5,...aa(e)(n)],sJ=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0(),i=ir.traverse(r);return o=>u=>{const s=Vn(u),a=.32*o.size;return i(c=>n.bind(c===0?r.pure(0):t.measureText(o)(me(c)(u)))(f=>n.bind(t.measureText(o)(me(c+1|0)(u)))(d=>n.bind(t.measureInk(o)(c>=0&&c<s.length?ro(s[c]):" "))(l=>r.pure({x:f,w:d-f,up:l.ascent-a,down:l.descent+a})))))(Dt(0,s.length-1|0))}},aJ=t=>e=>{const n=i=>(i.x-e.x)*(i.x-e.x)+(i.y-e.y)*(i.y-e.y),r=J(i=>o=>n(o)<n(i)?o:i)({x:t.x,y:t.y})([{x:t.x,y:t.y},{x:t.x+t.w,y:t.y},{x:t.x,y:t.y+t.h},{x:t.x+t.w,y:t.y+t.h}]);return O(i=>{const o=rt(i)/5;return{x:r.x+(e.x-r.x)*o,y:r.y+(e.y-r.y)*o}})([1,2,3,4])},ca=t=>{const e=lo(`
|
|
7
|
-
`)(t);return e.length===0?[""]:e},
|
|
8
|
-
`)(p.label===""?m:p.label),L=v.length===0?[""]:v,k=N.size*1.2,E=p.shape==="Cylinder"?t.strokePath(jx({x:p.x,y:p.y,w:p.w,h:p.h}))({color:l.nodeStroke,width:1.25,lineJoin:Te,lineCap:fn}):i.pure(),Q=(p.shape==="Cylinder"?(p.y+(p.y+p.h+5-2*nn(p.h*.075)(p.w*.075)))/2:(p.y+p.y+p.h)/2)-rt(L.length)*k/2+k/2,H=y.tag==="PloppingOut"&&l.wobble?y._1:-1,j=H>=0,S=Ko(y),C=j?{alpha:1,scale:1}:S,U=p.x+p.w/2,Y=p.y+p.h/2,W=n.bind(t.pushAlpha(C.alpha*_))(()=>n.bind(t.pushTransform({tx:U*(1-C.scale),ty:Y*(1-C.scale),sx:C.scale,sy:C.scale}))(()=>{const z={x:p.x,y:p.y,w:p.w,h:p.h},R={color:l.nodeStroke,width:l.wobble?2:1.25,lineJoin:Te,lineCap:l.wobble?Dn:fn};return n.bind((()=>{if(l.wobble){if(p.shape==="Rectangle")return o(x)(ZN(J_)(x_(z))(z));const G=ru(7)(p);return n.bind(o(x)((()=>{const I=Ri(G);return G.length<4?[]:qr(y_)(I)(!0)(G)})()))(()=>u(I=>o(x)((()=>{const D=Ri(I);return I.length<2?[]:qr(y_)(D)(!1)(I)})()))(p.shape==="Cylinder"?[RN(p)]:[]))}return n.bind(n_(t)(p.shape)(z)(7)(w("Just",{color:l.nodeFill,flat:!1}))(w("Just",R)))(()=>E)})())(()=>n.bind((()=>{if(h.tag==="Just"&&l.wobble&&!j){const G=h._1;return n.bind(s(a(N))(L))(I=>{const D=Lt(nt=>Z=>st.compare(nt.x)(Z.x)),B=de(dn(p.x*7919+p.y*3001))*-1640531535|0,q=ae(5)(7.5)(B),V=ae(0)(q.value)(q.prng),$=-(1+2*ae(-1)(1)(V.prng).value*3.141592653589793/180),X=(nt,Z,ut,ft,lt)=>D(xt(Nt=>Nt)([$*Z+nt>=ft&&$*Z+nt<=lt?w("Just",{x:Z,y:$*Z+nt}):T,$*ut+nt>=ft&&$*ut+nt<=lt?w("Just",{x:ut,y:$*ut+nt}):T,(()=>{const Nt=(ft-nt)/$;return Nt>=Z&&Nt<=ut?w("Just",{x:Nt,y:ft}):T})(),(()=>{const Nt=(lt-nt)/$;return Nt>=Z&&Nt<=ut?w("Just",{x:Nt,y:lt}):T})()])),M=q.value,et=Xn(G.frameHash)(3),tt=et===0?{r:200,g:35,b:30,a:220}:et===1?{r:35,g:150,b:80,a:220}:{r:30,g:80,b:200,a:220},gt=p.x+p.w/2,_t=Fe(At(nt=>Z=>At((()=>{const ut=Q+rt(nt)*k,ft=gt-J(lt=>Nt=>lt+Nt.w)(0)(Z)/2;return lt=>Nt=>{const Ht=N.size*.1,Vt=lt-1|0,Pe=Vt>=0&&Vt<Z.length&<>0?(Z[Vt].x+Z[Vt].w+Nt.x)/2:Nt.x-Ht;return{x:ft+Pe-1,y:ut-Nt.up-1,w:Qi(0)((()=>{const un=lt+1|0;return un>=0&&un<Z.length&<<(Z.length-1|0)?(Nt.x+Nt.w+Z[un].x)/2-Pe:Nt.x+Nt.w+Ht-Pe})())+2,h:Nt.up+Nt.down+2}}})())(Z))(I)),ct=p.y+4,yt=p.x+p.w-4,Et=p.x+4,Rt=ct-$*Et+V.value,pt=p.y+p.h-4,Qt=Tt(Tt(At(nt=>Z=>{const ut=(Z.from.x+Z.to.x)/2,ft=(Z.from.y+Z.to.y)/2,lt=ae(-1)(1)(B+(911*(nt+1|0)|0)|0),Nt=ae(-3)(5)(lt.prng),Ht=lt.value*3.141592653589793/180,Vt=Ke(Ht),Pe=Oe(Ht),un=Ne=>({x:ut+(Ne.x-ut)*Vt-(Ne.y-ft)*Pe,y:ft+(Ne.x-ut)*Pe+(Ne.y-ft)*Vt});return{from:(()=>{const Ne=un(Z.from),St=Ne.y-ft,It=Ne.x-ut,je=Ee(It*It+St*St),Ze=je<1e-4?1:(je+Nt.value)/je;return{x:ut+It*Ze,y:ft+St*Ze}})(),to:(()=>{const Ne=un(Z.to),St=ae(-3)(5)(Nt.prng).value,It=Ne.y-ft,je=Ne.x-ut,Ze=Ee(je*je+It*It),kn=Ze<1e-4?1:(Ze+St)/Ze;return{x:ut+je*kn,y:ft+It*kn}})()}})(xt(nt=>{const Z=X(Rt+rt(nt)*M,Et,yt,ct,pt);return Z.length===2?w("Just",{from:Z[0],to:Z[1]}):T})(Dt(0,su(1)(de(dn((pt-$*yt-Rt)/M)))))))(nt=>at(Z=>Z.to.x-Z.from.x>1,J(Z=>ut=>Tt(Z)(ft=>{const lt=X(ft.from.y-$*ft.from.x,ut.x,ut.x+ut.w,ut.y,ut.y+ut.h);return lt.length===2?lt[0].x>ft.from.x+.001&<[1].x<ft.to.x-.001?[{from:ft.from,to:lt[0]},{from:lt[1],to:ft.to}]:lt[0].x<=ft.from.x+.001&<[1].x<ft.to.x-.001?[{from:lt[1],to:ft.to}]:lt[0].x>ft.from.x+.001&<[1].x>=ft.to.x-.001?[{from:ft.from,to:lt[0]}]:[]:[ft]}))([nt])(_t))))(nt=>(()=>{const Z=nt.to.x-nt.from.x;return Ee(2)*(Z>=0?Z:-Z)<=28})()?[nt]:[{from:nt.from,to:{x:nt.from.x+(nt.to.x-nt.from.x)*.495,y:nt.from.y+(nt.to.y-nt.from.y)*.495}},{from:{x:nt.from.x+(nt.to.x-nt.from.x)*.505,y:nt.from.y+(nt.to.y-nt.from.y)*.505},to:nt.to}]),Jt=Qt.length,mt=nt=>Qi(0)(b_(1)(G.t*rt(Jt)-rt(nt)));return o(nt=>{const Z=nt._1,ut=ae(1.4)(1.9)(B+(1303*(Z+1|0)|0)|0),ft=ae(.35)(.8)(ut.prng),lt=o(Nt=>n.bind(t.pushAlpha(Nt.alpha*ft.value))(()=>n.bind(t.strokePath(N_(mt(Z))(Nt.path))({color:tt,width:ut.value,lineJoin:Te,lineCap:Dn}))(()=>r)))(qr({...J_,rMax:0,offset:.5})(B+(53*(Z+1|0)|0)|0)(!1)([nt._2.from,nt._2.to]));return mt(Z)>0?lt:i.pure()})(At(Hn)(Qt))})}return i.pure()})())(()=>n.bind((()=>{if(d==="LabelsShown")return o(G=>t.drawText({x:p.x+p.w/2,y:Q+rt(G._1)*k,content:G._2,font:N,color:l.text,align:Uo,baseline:Mr}))(At(Hn)(L));if(d==="LabelsHidden")return i.pure();g()})())(()=>n.bind((()=>{const G=c(l)(z)(H);return j?G:i.pure()})())(()=>n.bind(f)(()=>r)))))}));return C.alpha*_>0?W:i.pure()}},dJ=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),i=P_(t),o=t.popAlpha,u=rn(n);return s=>a=>c=>{const f={...s,nodeFill:s.text,text:s.nodeFill,nodeStroke:s.nodeFill};return u(d=>{const l=fe(d._1)(c.nodes),_=fe(d._1)(a.nodes),h=(()=>{if(_.tag==="Just"&&l.tag==="Just"){const m=l._1,p=_._1;return r.bind(t.pushAlpha(d._2))(()=>r.bind(i(ua)(f)(1)(T)(d._1)(p)(m))(()=>o))}return n.pure()})();return d._2>0?h:n.pure()})(Me(c.nodeInvert))}},I_=t=>{const e=t.Monad0().Bind1();return n=>r=>i=>o=>r?e.bind(t.clearBackground(n.bgTransparent))(()=>t.setViewport(o)):n.wobble?e.bind(t.setViewport(o))(()=>t.clearBackground(n.bg)):e.bind(t.setViewport(o))(()=>t.backgroundDots({viewport:o,bgColor:n.bg,dotColor:n.bgDot,tile:12*i,dotRadius:.7*i}))},lJ=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),i=t.popAlpha;return o=>u=>s=>a=>c=>f=>d=>l=>_=>{const h=(()=>{if(_>1e-4&&d>1-_){const p=(1-d)/_;return p<0?0:p>1?1:p}if(l>1e-4&&d<l){const p=d/l;return p<0?0:p>1?1:p}return 1})(),m=C_(a)(c)(f)(d)(l)(_);if(m.tag==="CircleShape")return o?G_(t)(m._1)(m._2)({r:200,g:35,b:30,a:220}):t.fillStrokePath(tu(m._1)(m._2))({color:u,flat:!0})({color:s,width:1,lineJoin:Te,lineCap:fn});if(m.tag==="PolyShape"&&o&&m._1.length>=3)return r.bind(t.pushAlpha(h))(()=>r.bind(G_(t)(h_(m._1))(6)({r:200,g:35,b:30,a:220}))(()=>i));if(m.tag==="PolyShape")return o?n.pure():m._1.length>=3?t.fillStrokePath(d_(m._1))({color:u,flat:!0})({color:s,width:1,lineJoin:Te,lineCap:fn}):n.pure();g()}},hJ=t=>{const e=t.Monad0().Bind1(),n=t.popAlpha;return r=>i=>o=>u=>s=>a=>c=>{const f=Hr(a)(c)(s),d={x:o.x+o.w/2,y:o.y+o.h/2},l={x:u.x+u.w/2,y:u.y+u.h/2},_=(h,m)=>e.bind(t.pushAlpha(m))(()=>e.bind(t.fillStrokePath(tu(h)(6))({color:r,flat:!0})({color:i,width:1,lineJoin:Te,lineCap:fn}))(()=>n));return f<.5?_(d,(()=>{const h=f*2;return 1-(h<0?0:h>1?1:h)*(h<0?0:h>1?1:h)*(h<0?3:h>1?1:3-2*h)})()):_(l,(()=>{const h=(f-.5)*2;return(h<0?0:h>1?1:h)*(h<0?0:h>1?1:h)*(h<0?3:h>1?1:3-2*h)})())}},au=t=>{const e=lJ(t),n=hJ(t),r=t.Monad0().Applicative0(),i=rn(r);return o=>u=>s=>a=>c=>i(f=>{if(f._2.tag==="Travelling"){const d=fe(f._2._1.target)(u.nodes),l=fe(f._2._1.source)(u.nodes);if(l.tag==="Just"&&d.tag==="Just"){const _=mr(f._2._1.edge)(u.edges);if(_.tag==="Just")return e(o)(a)(c)((()=>{if(f._2._1.direction==="Forward")return _._1;if(f._2._1.direction==="Backward")return ke(_._1);g()})())(l._1)(d._1)(f._2._1.progress)(f._2._1.holdPre)(f._2._1.holdPost);if(_.tag==="Nothing")return n(a)(c)(l._1)(d._1)(f._2._1.progress)(f._2._1.holdPre)(f._2._1.holdPost);g()}return r.pure()}if(f._2.tag==="Filling"){if(o)return r.pure();const d=fe(f._2._1.node)(u.nodes);if(d.tag==="Just")return t.fillStrokePath(d_(ru(4)(Or(2)(d._1))))({color:a,flat:!0})({color:c,width:1,lineJoin:Te,lineCap:fn});if(d.tag==="Nothing")return r.pure();g()}return r.pure()})(Me(s.tokens))},D_=t=>{const e=au(t),n=t.Monad0(),r=n.Bind1(),i=au(t),o=fJ(t),u=t.popClip,s=t.popBlend,a=t.popLayer,c=n.Applicative0(),f=rn(c),d=t.popAlpha;return l=>_=>h=>m=>{const p=_.wobble?e(!0)(h)(m)(_.tokenInside)(_.tokenInsideStroke):r.bind(t.insideTokenStyle(l))(y=>{if(y==="GenieSilhouette")return i(!1)(h)(m)(_.tokenInside)(_.tokenInsideStroke);if(y==="ConvexAbsorb")return o(h)(m)(_.tokenInside)(_.tokenInsideStroke);g()});if(_.tokenInsideBlend==="Difference")return r.bind(t.pushLayer(Bx))(()=>r.bind(t.pushBlend(jo))(()=>r.bind(t.pushClip(aa(h)(m))(Zs))(()=>r.bind(p)(()=>r.bind(u)(()=>r.bind(s)(()=>r.bind(a)(()=>r.bind(t.pushLayer(Fx))(()=>r.bind(f(y=>{const x=fe(y._1)(m.nodes);return x.tag==="Just"&&Ko(x._1).alpha>0?n_(t)(y._2.shape)({x:y._2.x,y:y._2.y,w:y._2.w,h:y._2.h})(7)(w("Just",{color:re,flat:!1}))(T):c.pure()})(Me(h.nodes)))(()=>a)))))))));if(_.tokenInsideBlend==="Normal")return r.bind(t.pushClip(aa(h)(m))(Zs))(()=>r.bind(t.pushAlpha(_.tokenInsideAlpha))(()=>r.bind(p)(()=>r.bind(d)(()=>u))));g()}},A_=t=>{const e=t.Monad0().Bind1(),n=au(t),r=au(t),i=t.popClip,o=t.popLayer;return u=>s=>a=>c=>e.bind(t.pushLayer(Ax))(()=>e.bind(t.pushClip(uJ(s)(a)(c))(Qx))(()=>e.bind(u.wobble?n(!0)(a)(c)(u.tokenOutsideFill)(u.tokenOutsideStroke):r(!1)(a)(c)(u.tokenOutsideFill)(u.tokenOutsideStroke))(()=>e.bind(i)(()=>o))))},pJ=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0(),i=rn(r);return o=>u=>s=>a=>c=>f=>{const d=mo(f).length,l=rt(d+1|0),_=p=>{const y=(s*l-rt(p))/1.5,x=y<0?0:y>1?1:y;return x*x*(3-2*x)},h=(p=>{let y=p,x=!0,N;for(;x;){const v=y;if(v>=d){x=!1,N=v;continue}if(_(v)>=1){y=v+1|0;continue}x=!1,N=v}return N})(0),m=h>=d?[]:or(p=>_(p)>0)(Dt(h,d-1|0)).init;return n.bind((()=>{const p=t.drawText({x:a,y:c,content:me(h)(f),font:o,color:u,align:js,baseline:Mr});return h>0?p:r.pure()})())(()=>i(p=>n.bind(t.measureText(o)(me(p)(f)))(y=>{const x=_(p);return t.drawText({x:a+y,y:c-(1-x)*10,content:me(1)(ci(Un(me(p)(f)))(f)),font:o,color:{...u,a:de(dn(x*rt(u.a)))},align:js,baseline:Mr})}))(m))}},cu=t=>e=>n=>r=>{const i=O(_=>rt(su(1)(mo(_).length)))(r),o=Qi(1)(J(Tr)(0)(i)),u=Hr(e)(n)(t),s=u*o,a=su(1)(r.length),c=(_=>h=>m=>{let p=_,y=h,x=m,N=!0,v;for(;N;){const L=p,k=y,E=Bt(Q=>T,Q=>H=>w("Just",{head:Q,tail:H}),x);if(E.tag==="Nothing"){N=!1,v=su(0)(a-1|0);continue}if(E.tag==="Just"){if(k+E._1.head>=s){N=!1,v=L;continue}p=L+1|0,y=k+E._1.head,x=E._1.tail;continue}g()}return v})(0)(0)(i),f=J(Tr)(0)(c<1?[]:bt(0,c,i)),d=f/o;if(c>=0&&c<i.length){const _=(f+i[c])/o;return{line:c>=0&&c<r.length?r[c]:"",phaseInLabel:(()=>{if(_<=d)return 1;const h=(u-d)/(_-d);return h<0?0:h>1?1:h})()}}const l=(f+1)/o;return{line:c>=0&&c<r.length?r[c]:"",phaseInLabel:(()=>{if(l<=d)return 1;const _=(u-d)/(l-d);return _<0?0:_>1?1:_})()}},mJ=t=>{const e=t.Monad0();return n=>r=>i=>e.Bind1().bind(t.measureText({family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:500})(cu(r)(0)(0)(O(K1)(i)).line))(o=>{const u=o+28;return e.Applicative0().pure({x:n.x+n.w/2-u/2,y:n.y-25.2-14,w:u,h:25.2})})},yJ=t=>{const e=t.Monad0(),n=e.Bind1(),r=mJ(t),i=e.Applicative0(),o=ir.traverse(i);return u=>s=>n.Apply0().Functor0().map(a=>k_(xt(c=>c)(a)))(o(a=>{if(a._2.tag==="Filling"&&a._2._1.labels.length!==0){const c=fe(a._2._1.node)(u.nodes);if(c.tag==="Just")return n.bind(r(c._1)(a._2._1.progress)(a._2._1.labels))(f=>i.pure(w("Just",b(a._1,f))));if(c.tag==="Nothing")return i.pure(T);g()}return i.pure(T)})(Me(s.tokens)))},xJ=t=>{const e=t.Monad0();return n=>r=>i=>o=>u=>s=>a=>{const c=S_(n)(r)(i)(o)(u)(s);return e.Bind1().bind(t.measureText({family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:500})(cu(o)(u)(s)(Tt(a)(ca)).line))(f=>e.Applicative0().pure({x:c.x+14+f/2-f/2-14,y:c.y-6-8-6.6-6,w:f+28,h:25.2}))}},NJ=t=>{const e=t.Monad0(),n=e.Bind1(),r=xJ(t),i=e.Applicative0(),o=ir.traverse(i);return u=>s=>n.Apply0().Functor0().map(a=>k_(xt(c=>c)(a)))(o(a=>{if(a._2.tag==="Travelling"&&a._2._1.labels.length!==0){const c=fe(a._2._1.target)(u.nodes),f=fe(a._2._1.source)(u.nodes),d=mr(a._2._1.edge)(u.edges);if(d.tag==="Just"&&f.tag==="Just"&&c.tag==="Just")return n.bind(r((()=>{if(a._2._1.direction==="Forward")return d._1;if(a._2._1.direction==="Backward")return ke(d._1);g()})())(f._1)(c._1)(a._2._1.progress)(a._2._1.holdPre)(a._2._1.holdPost)(a._2._1.labels))(l=>i.pure(w("Just",b(a._1,l))))}return i.pure(T)})(Me(s.tokens)))},ga=t=>{const e=t.Monad0(),n=e.Bind1(),r=NJ(t),i=yJ(t);return o=>u=>n.bind(r(o)(u))(s=>n.bind(i(o)(u))(a=>e.Applicative0().pure(oJ((()=>{const c=f=>{if(f.tag==="Leaf")return A;if(f.tag==="Node")return Mt("Node",f._1,f._2,f._3,void 0,c(f._5),c(f._6));g()};return Lt(P.compare)(kt(We.foldr,c(s)))})())(s)([...xt(c=>{const f=fe(c._1)(u.nodes);return f.tag==="Just"&&Ko(f._1).alpha>0?w("Just",{x:c._2.x,y:c._2.y,w:c._2.w,h:c._2.h}):T})(Me(o.nodes)),...(()=>{const c=(f,d)=>{if(f.tag==="Leaf")return d;if(f.tag==="Node")return c(f._5,Ot("Cons",f._4,c(f._6,d)));g()};return kt($t.foldr,c(a,qt))})()]))))},B_=t=>e=>n=>{const r=pi(6)(.55)(uu(0)(1)((1-t)/.06)),i=t>.94,o=i&&n>1e-4,u=pi(6)(.55)(uu(0)(1)(t/.06)),s=t<.06,a=s&&e>1e-4,c=i&&n<=1e-4;return{popScale:a?u:o?r:1,flipY:s&&e<=1e-4?u:c?r:1,fadeAlpha:(()=>{if(a){const f=t/.06;return f<0?.55:f>1?1:.55+.44999999999999996*f}if(o){const f=(1-t)/.06;return f<0?.55:f>1?1:.55+.44999999999999996*f}return 1})()}},JJ=t=>{const e=t.Monad0().Bind1(),n=E_(t);return r=>i=>o=>u=>s=>{const a=B_(u)(0)(0),c={family:r.fontFamily,size:11,weight:500},f=cu(u)(0)(0)(Tt(s)(ca));return e.bind(t.measureText(c)(f.line))(d=>{const l=o.x+o.w/2,_=d+28,h=o.y-25.2-14,m=l-_/2,p=[1,l,h+25.2,2,l,o.y],y={x:l,y:h+12.6};return n(a)(l-_/2)(h+25.2)(y)(e.bind(t.drawRoundedRect({x:l-_/2,y:h+1.5,w:_,h:25.2})(6)(w("Just",{color:r.chipShadow,flat:!0}))(T))(()=>e.bind(t.drawRoundedRect({x:m,y:h,w:_,h:25.2})(6)(w("Just",{color:r.chip,flat:!0}))(w("Just",{color:r.chipHairline,width:1,lineJoin:Te,lineCap:fn})))(()=>e.bind(t.strokePath(p)({color:r.chipHairline,width:1,lineJoin:Te,lineCap:fn}))(()=>t.drawText({x:l,y:y.y,content:f.line,font:c,color:r.chipText,align:Uo,baseline:Mr})))))})}},TJ=t=>{const e=E_(t),n=t.Monad0(),r=n.Bind1(),i=rn(n.Applicative0()),o=pJ(t);return u=>s=>a=>c=>f=>d=>l=>_=>h=>{const m=cu(f)(d)(l)(Tt(_)(ca)),p=m.line,y=m.phaseInLabel/.45,x=y<0?0:y>1?1:y,N=h.w,v=h.y,L=h.x,k=L+14,E=h.h,Q=v+E/2;return e(B_(f)(d)(l))(L)(v+E)({x:L+N/2,y:Q})(r.bind(i(H=>t.fillPath(tu(H)(1.5))({color:u.trailDot,flat:!0}))(aJ(h)(S_(s)(a)(c)(f)(d)(l))))(()=>r.bind(t.drawRoundedRect({x:L,y:v,w:N,h:E})(3)(w("Just",{color:u.chipPillFill,flat:!0}))(T))(()=>o({family:u.fontFamily,size:11,weight:500})(u.chipPillText)(x)(k)(Q)(p))))}},fa=t=>{const e=TJ(t),n=t.Monad0(),r=n.Applicative0(),i=JJ(t),o=n.Bind1(),u=rn(r),s=t.popLayer;return a=>c=>f=>d=>o.bind(t.pushLayer(Rx))(()=>o.bind(u(l=>{if(l._2.tag==="Travelling"){if(l._2._1.labels.length!==0){const _=fe(l._2._1.target)(c.nodes),h=fe(l._2._1.source)(c.nodes),m=mr(l._2._1.edge)(c.edges),p=L_(l._1)(d);if(p.tag==="Just"&&m.tag==="Just"&&h.tag==="Just"&&_.tag==="Just")return e(a)((()=>{if(l._2._1.direction==="Forward")return m._1;if(l._2._1.direction==="Backward")return ke(m._1);g()})())(h._1)(_._1)(l._2._1.progress)(l._2._1.holdPre)(l._2._1.holdPost)(l._2._1.labels)(p._1)}return r.pure()}if(l._2.tag==="Filling"&&l._2._1.labels.length!==0){const _=fe(l._2._1.node)(c.nodes);if(_.tag==="Just")return i(a)(c)(_._1)(l._2._1.progress)(l._2._1.labels);if(_.tag==="Nothing")return r.pure();g()}return r.pure()})(Me(f.tokens)))(()=>s))},F_=t=>{const e=ga(t),n=fa(t);return r=>i=>o=>t.Monad0().Bind1().bind(e(i)(o))(u=>n(r)(i)(o)(u))},vJ=t=>{const e=t.Monad0(),n=e.Applicative0();return r=>i=>{const o=i.length-1|0,u=o<1?[]:bt(0,o,i),s=u.length-1|0,a=s>=0&&s<u.length?w("Just",u[s]):T,c=i.length-1|0,f=c>=0&&c<i.length?w("Just",i[c]):T;if(f.tag==="Just"&&a.tag==="Just"){const d=ae(.78)(1.18)(Ri(i)+19|0),l=ae(.4)(.62)(d.prng),_=r.wobble?8.75*l.value:4.375,h=ae(.4)(.62)(l.prng),m=r.wobble?8.75*h.value:4.375,p=f._1.y-a._1.y,y=f._1.x-a._1.x,x=Ee(y*y+p*p),N=p/x,v=-N,L=y/x,k=f._1.x+L*.875,E=f._1.y+N*.875,Q=r.wobble?8.75*d.value:8.75,H=k-L*Q,j=E-N*Q,S=H+v*_,C=j+L*_,U=[1,k,E,2,H+v*4.375,j+L*4.375,2,H-v*4.375,j-L*4.375,5],Y=H-v*m,W=j-L*m,z={color:r.arrowFill,width:2,lineJoin:Te,lineCap:Dn};return x<=1e-4?n.pure():r.wobble?e.Bind1().bind(t.strokePath([1,S,C,2,k,E])(z))(()=>t.strokePath([1,Y,W,2,k,E])(z)):t.fillPath(U)({color:r.arrowFill,flat:!0})}return n.pure()}},wJ=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),i=rn(n),o=t.popAlpha,u=vJ(t);return s=>a=>c=>f=>{const d=PN(8)(c);if(f.hi<=f.lo)return n.pure();const l=zN(d)(f.lo)(f.hi);if(l.length===0)return n.pure();const _={color:s.edge,width:s.wobble?2:.9375,lineJoin:Te,lineCap:Dn},h=s.wobble?ae(-10)(4)(Ri(l)).value:0,m=s.wobble?YN(h)(l):l;return r.bind(s.wobble?i(p=>r.bind(t.pushAlpha(p.alpha))(()=>r.bind(t.strokePath(p.path)(_))(()=>o)))((()=>{const p=Ri(l);return m.length<2?[]:qr(gJ)(p)(!1)(m)})()):t.strokePath(EN(l))(_))(()=>{const p=u(s)(m);return f.hi>=.999?p:n.pure()})}},R_=t=>{const e=wJ(t),n=t.Monad0().Applicative0(),r=rn(n);return i=>o=>u=>r(s=>{const a=mr(s._1)(u.edges);if(a.tag==="Just")return e(i)(s._1)(s._2)((()=>{if(a._1.tag==="Retracted")return{lo:0,hi:0};if(a._1.tag==="Extended")return{lo:0,hi:1};if(a._1.tag==="Extending")return{lo:0,hi:a._1._2};if(a._1.tag==="Retracting"){if(a._1._1==="FromSource")return{lo:a._1._2,hi:1};if(a._1._1==="FromTarget")return{lo:0,hi:1-a._1._2};if(a._1._1==="FromBoth")return{lo:a._1._2/2,hi:1-a._1._2/2}}g()})());if(a.tag==="Nothing")return n.pure();g()})(Me(o.edges))},bJ=t=>e=>{const n=o=>{const u=fe(o)(t.nodes);if(u.tag==="Nothing")return!1;if(u.tag==="Just"){const s=u._1;return!Re(a=>0<a._2.length&&a._2[0].x>=s.x&&a._2[0].x<=s.x+s.w&&a._2[0].y>=s.y&&a._2[0].y<=s.y+s.h,Me(t.edges))}g()},r=J(o=>u=>(o*31|0)+Sn(u)|0)(5381)(Vn(e.frameTitle)),i=o=>{const u=fe(o)(t.nodes);if(u.tag==="Nothing")return!1;if(u.tag==="Just"){const s=u._1;return!Re(a=>{const c=a._2.length-1|0;return c>=0&&c<a._2.length&&a._2[c].x>=s.x&&a._2[c].x<=s.x+s.w&&a._2[c].y>=s.y&&a._2[c].y<=s.y+s.h},Me(t.edges))}g()};return J(o=>u=>{const s=u._2;return eJ(a=>{if(a.tag==="Nothing")return w("Just",s);if(a.tag==="Just")return w("Just",{t:Qi(a._1.t)(s.t),angle:s.t>=a._1.t?s.angle:a._1.angle,bigCircle:a._1.bigCircle||s.bigCircle,frameHash:a._1.frameHash});g()})(u._1)(o)})(A)(Tt(Me(e.tokens))(o=>{if(o._2.tag==="Filling"){const u=o._2._1.node;return[b(u,{t:1,angle:(()=>{const s=xt(a=>(()=>{const c=fe(u)(t.nodes),f=a._2.length-1|0;return f>=0&&f<a._2.length&&c.tag==="Just"&&a._2[f].x>=c._1.x&&a._2[f].x<=c._1.x+c._1.w&&a._2[f].y>=c._1.y&&a._2[f].y<=c._1.y+c._1.h})()?w("Just",a._2):T)(Me(t.edges));if(0<s.length){const a=s[0].length-1|0,c=a<1?[]:bt(0,a,s[0]),f=c.length-1|0;if(f>=0&&f<c.length){const d=s[0].length-1|0;return d>=0&&d<s[0].length?ur(s[0][d].y-c[f].y)(s[0][d].x-c[f].x):0}s[0].length-1|0}return 0})(),bigCircle:n(u)||i(u),frameHash:r})]}if(o._2.tag==="Travelling"){if(o._2._1.progress>=.75)return[b(o._2._1.target,{t:(o._2._1.progress-.75)/.25,angle:(()=>{const u=mr(o._2._1.edge)(t.edges);if(u.tag==="Just"){const s=u._1.length-1|0,a=s<1?[]:bt(0,s,u._1),c=a.length-1|0;if(c>=0&&c<a.length){const f=u._1.length-1|0;return f>=0&&f<u._1.length?ur(u._1[f].y-a[c].y)(u._1[f].x-a[c].x):0}return u._1.length-1|0,0}if(u.tag==="Nothing")return 0;g()})(),bigCircle:n(o._2._1.target)||i(o._2._1.target),frameHash:r})];if(o._2._1.progress<.25)return[b(o._2._1.source,{t:o._2._1.progress/.25,angle:(()=>{const u=mr(o._2._1.edge)(t.edges);if(u.tag==="Just")return 1<u._1.length&&0<u._1.length?ur(u._1[1].y-u._1[0].y)(u._1[1].x-u._1[0].x):0;if(u.tag==="Nothing")return 0;g()})(),bigCircle:n(o._2._1.source)||i(o._2._1.source),frameHash:r})]}return[]}))},LJ=t=>J(e=>n=>(e*31|0)+Sn(n)|0)(5381)(Vn(t.frameTitle)),Q_=t=>{const e=P_(t),n=t.Monad0().Applicative0(),r=rn(n);return i=>o=>u=>s=>{const a=LJ(s),c=bJ(u)(s);return r(f=>{const d=fe(f._1)(s.nodes);if(d.tag==="Just")return e(i)(o)((()=>{const l=fe(f._1)(s.nodeFadeAlpha);if(l.tag==="Nothing")return 1;if(l.tag==="Just")return l._1;g()})())((()=>{const l=fe(f._1)(c);return l.tag==="Just"?w("Just",l._1):l.tag==="Nothing"&&nJ(f._1)(s.visited)?w("Just",{t:1,angle:0,bigCircle:!1,frameHash:a}):T})())(f._1)(f._2)(d._1);if(d.tag==="Nothing")return n.pure();g()})(Me(u.nodes))}},z_=t=>t,W_=t=>e=>{const n=e.vw/e.vh,r=e.vh*t,i={...e,vx:e.vx-(r-e.vw)/2,vw:r},o=e.vw/t,u={...e,vy:e.vy-(o-e.vh)/2,vh:o};return t<=0||e.vw<=0||e.vh<=0?e:t>n?i:t<n?u:e},kJ=t=>e=>n=>{const r=it.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=it.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},M_=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},H_=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},_a=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},EJ=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},CJ=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},SJ=t=>e=>{const n=Oe(t.angle),r=Ke(t.angle);return{a:r,b:n,c:0,d:1,e:-e*r,f:e*n-t.boxHeight/2}},GJ=t=>[t.box.ground.a,t.box.ground.b,t.box.ground.c,t.box.ground.d,t.box.top.a,t.box.top.b,t.box.top.c,t.box.top.d],$r=t=>e=>{const n=r=>kJ(0)(255)(de(Yn(rt(r)*t)));return{r:n(e.r),g:n(e.g),b:n(e.b),a:e.a}},Se=t=>e=>n=>r=>({x:(e-n)*Ke(t.angle),y:(e+n)*Oe(t.angle)-r}),yr=t=>{const e=Bt(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Tt(e._1.tail)(n=>[2,n.x,n.y]),5];g()},PJ=t=>e=>n=>r=>i=>{const o=(()=>{if(t==="Forward")return i;if(t==="Backward")return ke(i);g()})();if(0<o.length){const s=vr(o)(M_(0)(1)(Hr(n)(r)(e)));if(s.tag==="Nothing")return o[0];if(s.tag==="Just")return s._1;g()}const u=vr(o)(M_(0)(1)(Hr(n)(r)(e)));if(u.tag==="Nothing")return{x:0,y:0};if(u.tag==="Just")return u._1;g()},IJ=t=>{const e=Bt(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Tt(e._1.tail)(n=>[2,n.x,n.y])];g()},DJ=t=>{const e=Bt(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{vx:0,vy:0,vw:0,vh:0};if(e.tag==="Just"){const n=J(r=>i=>({minX:H_(r.minX)(i.x),minY:H_(r.minY)(i.y),maxX:_a(r.maxX)(i.x),maxY:_a(r.maxY)(i.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{vx:n.minX-40,vy:n.minY-40,vw:n.maxX-n.minX+80,vh:n.maxY-n.minY+80}}g()},AJ=t=>{const e=t.Monad0().Bind1();return n=>r=>i=>{const o=i.box,u=i.np,s={color:r.nodeStroke,width:1,lineJoin:Te,lineCap:fn};return e.bind(t.fillStrokePath(yr([o.ground.d,o.ground.c,o.top.c,o.top.d]))({color:$r(.66)(r.nodeFill),flat:!0})(s))(()=>e.bind(t.fillStrokePath(yr([o.ground.b,o.ground.c,o.top.c,o.top.b]))({color:$r(.82)(r.nodeFill),flat:!0})(s))(()=>e.bind(t.fillStrokePath(yr([o.top.a,o.top.b,o.top.c,o.top.d]))({color:$r(1)(r.nodeFill),flat:!0})(s))(()=>t.drawTextAffine(SJ(n)(u.y+u.h))({x:u.x+u.w/2,y:0,content:u.label,font:{family:r.fontFamily,size:11,weight:600},color:r.text,align:Uo,baseline:Mr}))))}},BJ=t=>{const e=t.Monad0().Bind1();return n=>r=>i=>o=>{const u={color:r.tokenOutsideStroke,width:1,lineJoin:Te,lineCap:fn},s=o.x-5.5,a=o.x+5.5,c=o.y-5.5,f=o.y+5.5,d=i+11,l=Se(n)(s)(c)(d),_=Se(n)(a)(c)(d),h=Se(n)(a)(f)(d),m=Se(n)(s)(f)(d),p=Se(n)(a)(f)(i),y=Se(n)(a)(c)(i);return e.bind(t.fillStrokePath(yr([Se(n)(s)(f)(i),p,h,m]))({color:$r(.66)(r.tokenOutsideFill),flat:!0})(u))(()=>e.bind(t.fillStrokePath(yr([y,p,h,_]))({color:$r(.82)(r.tokenOutsideFill),flat:!0})(u))(()=>t.fillStrokePath(yr([l,_,h,m]))({color:$r(1)(r.tokenOutsideFill),flat:!0})(u)))}},FJ=t=>{const e=BJ(t);return n=>r=>i=>o=>{if(o.tag==="Travelling"){const u=EJ(o._1.edge)(i.edges);return u.tag==="Just"?w("Just",(()=>{const s=PJ(o._1.direction)(o._1.progress)(o._1.holdPre)(o._1.holdPost)(u._1);return{depth:s.x+s.y,draw:e(n)(r)(0)(s)}})()):T}if(o.tag==="Filling"){const u=CJ(o._1.node)(i.nodes);if(u.tag==="Just")return w("Just",(()=>{const s={x:u._1.x+u._1.w/2,y:u._1.y+u._1.h/2};return{depth:s.x+s.y,draw:e(n)(r)(n.boxHeight)(s)}})())}return T}},RJ={angle:.5235987755982988,boxHeight:26,transparentBg:!0},QJ=t=>e=>{const n=e.y+e.h,r=e.x+e.w;return{ground:{a:Se(t)(e.x)(e.y)(0),b:Se(t)(r)(e.y)(0),c:Se(t)(r)(n)(0),d:Se(t)(e.x)(n)(0)},top:{a:Se(t)(e.x)(e.y)(t.boxHeight),b:Se(t)(r)(e.y)(t.boxHeight),c:Se(t)(r)(n)(t.boxHeight),d:Se(t)(e.x)(n)(t.boxHeight)},depth:(e.x+r)/2+(e.y+n)/2}},O_=t=>e=>O(n=>({np:n,box:QJ(t)(n)}))((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return kt($t.foldr,n(e.nodes,qt))})()),zJ=t=>e=>[...Tt(O_(t)(e))(GJ),...(()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return Tt(kt($t.foldr,n(e.edges,qt)))(O(r=>Se(t)(r.x)(r.y)(0)))})()],WJ=t=>{const e=t.to.y-t.from.y,n=t.to.x-t.from.x,r=_a(1e-4)(Ee(n*n+e*e)),i=e/r,o=n/r,u=t.to.y-i*7,s=t.to.x-o*7;return yr([t.to,{x:s-i*3,y:u+o*3},{x:s+i*3,y:u-o*3}])},MJ=t=>{const e=t.Monad0(),n=e.Applicative0();return r=>i=>o=>u=>s=>{const a=Se(r)(s.x)(s.y)(0),c=Se(r)(u.x)(u.y)(0);return e.Bind1().bind(t.strokePath(IJ([c,a]))({color:i.edge,width:1.5,lineJoin:Te,lineCap:Dn}))(()=>{const f=t.fillPath(WJ({from:c,to:a}))({color:i.arrowFill,flat:!0});return o?f:n.pure()})}},HJ=t=>{const e=MJ(t);return n=>r=>i=>{const o=Je(Hn,i,bt(1,i.length,i)),u=o.length-1|0;return At(s=>a=>({depth:(a._1.x+a._1.y+a._2.x+a._2.y)/2,draw:e(n)(r)(s===u)(a._1)(a._2)}))(o)}},OJ=t=>{const e=AJ(t),n=FJ(t),r=HJ(t),i=t.Monad0(),o=I_(t),u=Ju(i.Applicative0())(zt);return s=>a=>c=>f=>{const d=sa(a),l=[...(()=>{const _=(h,m)=>{if(h.tag==="Leaf")return m;if(h.tag==="Node")return _(h._5,Ot("Cons",h._4,_(h._6,m)));g()};return Tt(kt($t.foldr,_(c.edges,qt)))(r(s)(d))})(),...O(_=>({depth:_.box.depth,draw:e(s)(d)(_)}))(O_(s)(c)),...xt(n(s)(d)(c))((()=>{const _=(h,m)=>{if(h.tag==="Leaf")return m;if(h.tag==="Node")return _(h._5,Ot("Cons",h._4,_(h._6,m)));g()};return kt($t.foldr,_(f.tokens,qt))})())];return i.Bind1().bind(o(d)(s.transparentBg)(1)(DJ(zJ(s)(c))))(()=>u(_=>_.draw)(Lt(_=>h=>st.compare(_.depth)(h.depth))(l)))}},q_=(t,e)=>({tag:t,_1:e}),qJ=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},$J=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},YJ=q_("ResolvedLabels"),XJ=t=>{const e=Xt(n=>n.role==="FlyThrough")(t.levels);if(e.tag==="Just")return e._1;if(e.tag==="Nothing")return wo(t);g()},VJ=t=>e=>n=>{const r=n.frameTitle===""?0:40,i=Xu(e)(n.camera);return(()=>{if(t.outputAspect.tag==="Nothing")return z_;if(t.outputAspect.tag==="Just")return W_(t.outputAspect._1);g()})()({vx:i.x-t.padding,vy:i.y-t.padding-r,vw:i.w+2*t.padding,vh:i.h+2*t.padding+r})},UJ=t=>e=>{if(e.tag==="Nothing")return[];if(e.tag==="Just"){const n=qJ(e._1)(t.segment.layout.nodes);if(n.tag==="Nothing")return[];if(n.tag==="Just"){const r=n._1.x*t.segment.placement.scale+t.segment.placement.tx,i=n._1.y*t.segment.placement.scale+t.segment.placement.ty,o=n._1.w*t.segment.placement.scale,u=n._1.h*t.segment.placement.scale;return[1,r,i,2,r+o,i,2,r+o,i+u,2,r,i+u,5]}}g()},jJ=t=>{const e=t.Monad0(),n=e.Bind1();return r=>i=>{if(r==="")return e.Applicative0().pure();const o=i.vh/720,u=15*o,s={family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:u,weight:600};return n.bind(t.measureText(s)(r))(a=>{const c=i.vy+12*o,f=u+6*o*2,d=a+11*o*2,l=i.vx+i.vw/2;return n.bind(t.drawRoundedRect({x:l-d/2,y:c,w:d,h:f})(f/2)(w("Just",{color:{r:255,g:255,b:255,a:240},flat:!0}))(w("Just",{color:{r:0,g:0,b:0,a:255},width:1*o,lineJoin:Te,lineCap:Dn})))(()=>t.drawText({x:l,y:c+f/2,content:r,font:s,color:{r:28,g:30,b:36,a:255},align:Uo,baseline:Mr}))})}},ZJ=t=>{const e=F_(t),n=fa(t),r=t.Monad0(),i=r.Bind1(),o=I_(t),u=r.Applicative0(),s=R_(t),a=Q_(t)(ua),c=dJ(t),f=A_(t),d=D_(t),l=jJ(t);return _=>h=>m=>p=>y=>x=>N=>{const v=sa(_.theme),L=(()=>{if(N.tag==="ResolvedLabels")return e(v)(y)(x);if(N.tag==="SpringLabels")return n(v)(y)(x)(N._1);g()})();return i.bind(o(v)(_.transparentBg)(h)(p))(()=>i.bind((()=>{const k=i.bind(s(v)(y)(x))(()=>i.bind(a(v)(y)(x))(()=>i.bind(c(v)(y)(x))(()=>i.bind(f(v)(p)(y)(x))(()=>i.bind(d(Hx)(v)(y)(x))(()=>L)))));return m?k:u.pure()})())(()=>i.bind(_.watermark===""?t.Monad0().Applicative0().pure():t.drawText({x:p.vx+6,y:p.vy+6,content:_.watermark,font:{family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:9,weight:600},color:{r:180,g:180,b:180,a:255},align:js,baseline:Dx}))(()=>l(x.frameTitle)(p))))}},KJ=t=>{const e=t.Monad0(),n=F_(t),r=fa(t),i=e.Bind1(),o=R_(t),u=Q_(t),s=A_(t),a=t.popTransform,c=D_(t),f=t.popBakedTransform,d=t.popClip,l=t.popAlpha;return _=>h=>m=>p=>y=>{const x=y.state,N={tx:y.segment.placement.tx,ty:y.segment.placement.ty,sx:y.segment.placement.scale,sy:y.segment.placement.scale},v=sa(_.theme),L=y.segment.layout,k=Ye(L),E={vx:k.x-1e3,vy:k.y-1e3,vw:k.w+2e3,vh:k.h+2e3},Q=11*y.segment.placement.scale*h>=5?ua:rJ,H=(()=>{if(Q==="LabelsHidden")return e.Applicative0().pure();if(Q==="LabelsShown")return m.tag==="Leaf"?n(v)(L)(x):r(v)(L)(x)(m);g()})(),j=UJ(p)((()=>{const S=y.segment.path.length-1|0;return S>=0&&S<y.segment.path.length?w("Just",y.segment.path[S]):T})());return i.bind(t.pushAlpha(y.bgAlpha))(()=>i.bind(t.pushClip(j)(Zs))(()=>i.bind(t.pushTransform(N))(()=>i.bind(o(v)(L)(x))(()=>i.bind(u(Q)(v)(L)(x))(()=>i.bind(s(v)(E)(L)(x))(()=>i.bind(a)(()=>i.bind(t.pushBakedTransform(N))(()=>i.bind(c(Ox)(v)(L)(x))(()=>i.bind(f)(()=>i.bind(t.pushTransform(N))(()=>i.bind(H)(()=>i.bind(a)(()=>i.bind(d)(()=>l))))))))))))))}},tT=t=>e=>{const n=Xu(t)(e);return{vx:n.x,vy:n.y,vw:n.w,vh:n.h}},Yr=t=>e=>e.diving||e.levels.length>1?(()=>{if(t.outputAspect.tag==="Nothing")return z_;if(t.outputAspect.tag==="Just")return W_(t.outputAspect._1);g()})()(tT(e.rootLayout)(e.camera)):VJ(t)(e.rootLayout)({...wo(e).state,camera:e.camera}),$_=t=>{const e=OJ(t),n=t.Monad0(),r=n.Applicative0(),i=n.Bind1(),o=KJ(t),u=ZJ(t);return s=>a=>c=>{if(s.theme==="Isometric")return e({...RJ,transparentBg:s.transparentBg})(s.theme)(wo(c).segment.layout)(wo(c).state);const f=Yr(s)(c),d=_=>h=>{if(h.length===0)return r.pure();const m=Bt(p=>T,p=>y=>w("Just",{head:p,tail:y}),h);if(m.tag==="Nothing")return r.pure();if(m.tag==="Just"){const p=m._1.head,y=m._1.tail;return i.bind((()=>{const x=o(s)(c.camera.zoom)(p.role==="Active"?a:A)(_)(p);return c.diving||p.role==="Active"?x:r.pure()})())(()=>d(p)(y))}g()},l=Bt(_=>T,_=>h=>w("Just",{head:_,tail:h}),c.levels);if(l.tag==="Nothing")return r.pure();if(l.tag==="Just"){const _=l._1.tail,h=l._1.head;return i.bind(u(s)(c.hasDives?f.vw/$J(1)(Ye(c.rootLayout).w):1)(h.role==="Active"||h.role==="FlyThrough")(f)(h.segment.layout)(XJ(c).state)(_.length===0&&a.tag!=="Leaf"?q_("SpringLabels",a):YJ))(()=>d(h)(_))}g()}},Y_=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},eT=ga(o_),X_=$_(o_),V_=t=>{const e=t.vx+t.vw-4,n=t.vy+t.vh-4,r=t.vx+4,i=t.vy+4,o=u=>{if(u.tag==="Leaf")return A;if(u.tag==="Node")return Mt("Node",u._1,u._2,u._3,{...u._4,x:Y_(r)(e-u._4.w)(u._4.x),y:Y_(i)(n-u._4.h)(u._4.y)},o(u._5),o(u._6));g()};return o},nT=t=>e=>n=>r=>i=>o=>u=>{const s={padding:8,transparentBg:(()=>{if(e==="TransparentBackground")return!0;if(e==="PaintBackground")return!1;g()})(),halftoneShadows:!0,watermark:"",theme:t,outputAspect:r.width<=0||r.height<=0?T:w("Just",r.width/r.height)},a=iN(n)(r);return()=>{const c=a(),f=i.levels.length-1|0;if(f>=0&&f<i.levels.length){const l=eT(i.levels[f].segment.layout)(i.levels[f].state)(c)(),_=Vs(o)(V_(Yr(s)(i))(l))(u);return X_(s)(_.applied)(i)(c)(),_.springs}const d=Vs(o)(V_(Yr(s)(i))(A))(u);return X_(s)(d.applied)(i)(c)(),d.springs}},rT=t=>t,iT=(t=>t)("Light"),oT=rT("TransparentBackground"),nr=t=>"rgb("+ie(t.r)+","+ie(t.g)+","+ie(t.b)+")",bn=oi(ri("Fixed",ii(0)(20)(4))),uT=t=>"translate("+bn(t.tx)+","+bn(t.ty)+") scale("+bn(t.sx)+","+bn(t.sy)+")",wt=oi(ri("Fixed",ii(0)(20)(2))),da=t=>{const e=[];let n=0;for(;n<t.length;){const r=n,i=r>=0&&r<t.length?w("Just",t[r]):T;if(i.tag==="Nothing"){n=t.length;continue}if(i.tag==="Just"){if(i._1===1){e.push("M"),e.push(wt((()=>{const o=r+1|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+2|0;return o>=0&&o<t.length?t[o]:0})())),n=r+3|0;continue}if(i._1===2){e.push("L"),e.push(wt((()=>{const o=r+1|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+2|0;return o>=0&&o<t.length?t[o]:0})())),n=r+3|0;continue}if(i._1===3){e.push("Q"),e.push(wt((()=>{const o=r+1|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+2|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+3|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+4|0;return o>=0&&o<t.length?t[o]:0})())),n=r+5|0;continue}if(i._1===4){e.push("C"),e.push(wt((()=>{const o=r+1|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+2|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+3|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+4|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+5|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+6|0;return o>=0&&o<t.length?t[o]:0})())),n=r+7|0;continue}if(i._1===5){e.push("Z"),n=r+1|0;continue}n=t.length;continue}g()}return ho(" ")(e)},sT={map:t=>e=>n=>{const r=e(n);return()=>{const i=r();return t(i)}}},la=(()=>{const t=Zn("&")("&"),e=Zn("<")("<"),n=(()=>{const r=Zn(">")(">"),i=(()=>{const o=Zn('"')(""");return u=>o(r(u))})();return o=>i(e(o))})();return r=>n(t(r))})(),aT=t=>{if(t.style==="RunText")return"<tspan>"+la(t.text)+"</tspan>";if(t.style==="RunCode")return`<tspan font-family="'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace" font-weight="400">`+la(t.text)+"</tspan>";g()},Ae=t=>e=>{const n=e.maskDepth;return()=>{n.value===0&&e.out.push(t)}},cT=t=>e=>{const n=[];let r=0;const i=o=>{const u=o>=0&&o<e.length?t.sx*e[o]+t.tx:t.sx*0+t.tx;return()=>{n.push(u),n.push((()=>{const s=o+1|0;return s>=0&&s<e.length?t.sy*e[s]+t.ty:t.sy*0+t.ty})())}};for(;r<e.length;){const o=r,u=o>=0&&o<e.length?w("Just",e[o]):T;if(u.tag==="Nothing"){r=e.length;continue}if(u.tag==="Just"){if(u._1===1){n.push(u._1),i(o+1|0)(),r=o+3|0;continue}if(u._1===2){n.push(u._1),i(o+1|0)(),r=o+3|0;continue}if(u._1===3){n.push(u._1),i(o+1|0)(),i(o+3|0)(),r=o+5|0;continue}if(u._1===4){n.push(u._1),i(o+1|0)(),i(o+3|0)(),i(o+5|0)(),r=o+7|0;continue}if(u._1===5){n.push(u._1),r=o+1|0;continue}r=e.length;continue}g()}return n},gu=t=>e=>{const n=t.bake;return()=>{const r=n.value;if(r.tag==="Nothing")return e;if(r.tag==="Just")return cT(r._1)(e);g()}},U_={apply:t=>e=>n=>{const r=t(n),i=e(n);return()=>{const o=r(),u=i();return o(u)}},Functor0:()=>sT},gT={bind:t=>e=>n=>{const r=t(n);return()=>{const i=r();return e(i)(n)()}},Apply0:()=>U_},fT={pure:t=>e=>()=>t,Apply0:()=>U_},_T={Applicative0:()=>fT,Bind1:()=>gT},dT=t=>e=>'<defs><pattern id="'+t+'" x="0" y="0" width="'+wt(e.tile)+'" height="'+wt(e.tile)+'" patternUnits="userSpaceOnUse">'+(e.bgColor.a===0?"":'<rect width="'+wt(e.tile)+'" height="'+wt(e.tile)+'" fill="'+nr(e.bgColor)+'" fill-opacity="'+wt(rt(e.bgColor.a)/255)+'"/>')+'<circle cx="'+wt(e.tile/2)+'" cy="'+wt(e.tile/2)+'" r="'+wt(e.dotRadius)+'" fill="'+nr(e.dotColor)+'"/></pattern></defs><rect x="'+wt(e.viewport.vx)+'" y="'+wt(e.viewport.vy)+'" width="'+wt(e.viewport.vw)+'" height="'+wt(e.viewport.vh)+'" fill="url(#'+t+')"/>',j_=t=>e=>'<path d="'+da(t)+'" fill="'+nr(e)+'" fill-opacity="'+wt(rt(e.a)/255)+'"/>',lT=t=>e=>n=>r=>'<rect x="'+wt(t.x)+'" y="'+wt(t.y)+'" width="'+wt(t.w)+'" height="'+wt(t.h)+'" rx="'+wt(e)+'"'+(()=>{if(n.tag==="Just")return' fill="'+nr(n._1.color)+'" fill-opacity="'+wt(rt(n._1.color.a)/255)+'"';if(n.tag==="Nothing")return' fill="none"';g()})()+(()=>{if(r.tag==="Just")return' stroke="'+nr(r._1.color)+'" stroke-opacity="'+wt(rt(r._1.color.a)/255)+'" stroke-width="'+wt(r._1.width)+'" stroke-linejoin="'+(()=>{if(r._1.lineJoin==="RoundJoin")return"round";if(r._1.lineJoin==="BevelJoin")return"bevel";if(r._1.lineJoin==="MiterJoin")return"miter";g()})()+'" stroke-linecap="'+(()=>{if(r._1.lineCap==="ButtCap")return"butt";if(r._1.lineCap==="RoundCap")return"round";if(r._1.lineCap==="SquareCap")return"square";g()})()+'"';if(r.tag==="Nothing")return"";g()})()+"/>",Z_=t=>e=>'<path d="'+da(t)+'" fill="none" stroke="'+nr(e.color)+'" stroke-opacity="'+wt(rt(e.color.a)/255)+'" stroke-width="'+wt(e.width)+'" stroke-linejoin="'+(()=>{if(e.lineJoin==="RoundJoin")return"round";if(e.lineJoin==="BevelJoin")return"bevel";if(e.lineJoin==="MiterJoin")return"miter";g()})()+'" stroke-linecap="'+(()=>{if(e.lineCap==="ButtCap")return"butt";if(e.lineCap==="RoundCap")return"round";if(e.lineCap==="SquareCap")return"square";g()})()+'"/>',K_=t=>{const e=eg(Ir(t.content));return'<text x="'+wt(t.x)+'" y="'+wt(t.y)+'"'+(()=>{if(t.baseline==="BaselineTop")return' dy="0.8em"';if(t.baseline==="BaselineMiddle")return' dy="0.32em"';if(t.baseline==="BaselineAlphabetic"||t.baseline==="BaselineBottom")return"";g()})()+' fill="'+nr(t.color)+'" fill-opacity="'+wt(rt(t.color.a)/255)+'" font-size="'+wt(t.font.size)+'" font-family="Ilisarniq, ui-sans-serif, system-ui, sans-serif" font-weight="'+ie(t.font.weight)+'" text-anchor="'+(()=>{if(t.align==="AlignLeft")return"start";if(t.align==="AlignCenter")return"middle";if(t.align==="AlignRight")return"end";g()})()+'">'+(e.length===1&&e[0].style==="RunText"?la(e[0].text):ho("")(O(aT)(e)))+"</text>"},hT=t=>"matrix("+bn(t.a)+" "+bn(t.b)+" "+bn(t.c)+" "+bn(t.d)+" "+bn(t.e)+" "+bn(t.f)+")",t1={fillPath:t=>e=>n=>{const r=gu(n)(t);return()=>{const i=r();return Ae(j_(i)(e.color))(n)()}},strokePath:t=>e=>n=>{const r=gu(n)(t);return()=>{const i=r(),o=n.bake.value;return Ae(Z_(i)((()=>{if(o.tag==="Nothing")return e;if(o.tag==="Just")return{...e,width:o._1.sx*e.width};g()})()))(n)()}},fillStrokePath:t=>e=>n=>r=>{const i=gu(r)(t);return()=>{const o=i(),u=r.bake.value;return Ae(j_(o)(e.color)+Z_(o)((()=>{if(u.tag==="Nothing")return n;if(u.tag==="Just")return{...n,width:u._1.sx*n.width};g()})()))(r)()}},drawRoundedRect:t=>e=>n=>r=>i=>{const o=i.bake;return()=>{const u=o.value;return Ae(lT((()=>{if(u.tag==="Nothing")return t;if(u.tag==="Just")return{x:u._1.sx*t.x+u._1.tx,y:u._1.sy*t.y+u._1.ty,w:u._1.sx*t.w,h:u._1.sy*t.h};g()})())((()=>{if(u.tag==="Nothing")return e;if(u.tag==="Just")return u._1.sx*e;g()})())(n)(r.tag==="Just"?w("Just",(()=>{if(u.tag==="Nothing")return r._1;if(u.tag==="Just")return{...r._1,width:u._1.sx*r._1.width};g()})()):T))(i)()}},drawText:t=>e=>{const n=e.bake;return()=>{const r=n.value;return Ae(K_((()=>{if(r.tag==="Nothing")return t;if(r.tag==="Just")return{...t,x:r._1.sx*t.x+r._1.tx,y:r._1.sy*t.y+r._1.ty,font:{...t.font,size:r._1.sx*t.font.size}};g()})()))(e)()}},drawTextAffine:t=>e=>Ae((()=>{const n='transform="'+hT(t)+'"';return(n===""?"<g>":"<g "+n+">")+K_(e)+"</g>"})()),pushTransform:t=>Ae((()=>{const e='transform="'+uT(t)+'"';return e===""?"<g>":"<g "+e+">"})()),popTransform:Ae("</g>"),pushBakedTransform:t=>e=>{const n=e.bake;return()=>{n.value=w("Just",t)}},popBakedTransform:t=>{const e=t.bake;return()=>{e.value=T}},pushClip:t=>e=>n=>{const r=n.clipCounter;return()=>{const i=r.value;n.clipCounter.value=i+1|0;const o=gu(n)(t)(),u="clip"+ie(i);return Ae((()=>{const s='clip-path="url(#'+u+')"';return'<defs><clipPath id="'+u+'"><path d="'+da(o)+'"'+(()=>{if(e==="EvenOdd")return' clip-rule="evenodd"';if(e==="NonZero")return"";g()})()+"/></clipPath></defs>"+(s===""?"<g>":"<g "+s+">")})())(n)()}},popClip:Ae("</g>"),pushBlend:t=>Ae((()=>{const e=(()=>{if(t==="Normal")return'style="mix-blend-mode: normal"';if(t==="Difference")return'style="mix-blend-mode: difference"';g()})();return e===""?"<g>":"<g "+e+">"})()),popBlend:Ae("</g>"),pushAlpha:t=>Ae((()=>{const e='opacity="'+wt(t)+'"';return e===""?"<g>":"<g "+e+">"})()),popAlpha:Ae("</g>"),pushLayer:t=>e=>{const n=(()=>{if(t==="LayerNodeMask"){const r=e.maskDepth;return()=>{const i=r.value;e.maskDepth.value=i+1|0}}return()=>{}})();return()=>{n(),e.out.push("<g>")}},popLayer:t=>{const e=t.maskDepth;return()=>{const n=e.value,r=n-1|0;n>0&&(t.maskDepth.value=r),t.out.push("</g>")}},setViewport:t=>e=>()=>{},clearBackground:t=>e=>Ae('<rect x="'+wt(e.viewport.vx)+'" y="'+wt(e.viewport.vy)+'" width="'+wt(e.viewport.vw)+'" height="'+wt(e.viewport.vh)+'" fill="'+nr(t)+'" opacity="'+wt(rt(t.a)/255)+'"/>')(e),backgroundDots:t=>e=>{const n=e.patternCounter;return()=>{const r=n.value;return e.patternCounter.value=r+1|0,Ae(dT("bg-dots-"+ie(r))(t))(e)()}},measureText:t=>e=>n=>{const r=Af(t)(e);return()=>r},measureInk:t=>e=>n=>{const r=Bf(t)(e);return()=>r},insideTokenStyle:t=>e=>()=>qf,Monad0:()=>_T},pT=$_(t1),mT=ga(t1),yT=t=>e=>n=>r=>i=>{const o={padding:24,transparentBg:(()=>{if(r==="TransparentBackground")return!0;if(r==="PaintBackground")return!1;g()})(),halftoneShadows:!0,watermark:"",theme:n,outputAspect:t},u=Yr(o)(i);return{viewBox:wt(u.vx)+" "+wt(u.vy)+" "+wt(u.vw)+" "+wt(u.vh),body:(()=>{const s=[],a={value:0},c={value:0},f={value:0},d={value:T};return pT(o)(e)(i)({out:s,maskDepth:a,clipCounter:c,patternCounter:f,viewport:u,bake:d})(),ho("")(s)})(),vx:u.vx,vy:u.vy,vw:u.vw,vh:u.vh}},xT=t=>e=>n=>r=>i=>o=>{const u={padding:24,transparentBg:(()=>{if(n==="TransparentBackground")return!0;if(n==="PaintBackground")return!1;g()})(),outputAspect:t},s=Vs(i)((()=>{const a=[],c={value:0},f={value:0},d={value:0},l={value:T},_=r.levels.length-1|0;return _>=0&&_<r.levels.length?mT(r.levels[_].segment.layout)(r.levels[_].state)({out:a,maskDepth:c,clipCounter:f,patternCounter:d,viewport:Yr(u)(r),bake:l})():A})())(o);return{parts:yT(t)(s.applied)(e)(n)(r),springs:s.springs}},zi=t=>({bind:e=>n=>r=>t.Bind1().bind(e(r))(i=>n(i._1)(i._2)),Apply0:()=>e1(t)}),e1=t=>{const e=t.Bind1().Apply0().Functor0(),n={map:r=>i=>o=>e.map(u=>b(r(u._1),u._2))(i(o))};return{apply:(()=>{const r=zi(t);return i=>o=>r.bind(i)(u=>r.bind(o)(s=>Wi(t).pure(u(s))))})(),Functor0:()=>n}},Wi=t=>({pure:e=>n=>t.Applicative0().pure(b(e,n)),Apply0:()=>e1(t)}),NT=t=>{const e={Applicative0:()=>Wi(t),Bind1:()=>zi(t)};return{state:n=>r=>t.Applicative0().pure(n(r)),Monad0:()=>e}},ha=(t,e)=>({tag:t,_1:e}),Rn=(t,e)=>({tag:t,_1:e}),ve=NT(Mn),Wt=zi(Mn),Be=ve.state(t=>b(t,t)),ue=Wi(Mn),Qn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},n1=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},fu=Ju(ue)(zt),zn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},JT=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},TT=(()=>{const t=qe.unfoldr(e=>{if(e.tag==="Nil")return T;if(e.tag==="Cons")return w("Just",b(e._1,e._2));g()});return e=>t((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._3,n(r._6,i)));g()};return n(e,qt)})())})(),vT=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},_u=t=>e=>n=>J(r=>i=>t.Bind1().bind(r)(o=>e(o)(i)))(t.Applicative0().pure(n)),wT=J(t=>e=>K(P)(e)()(t))(A),bT=(()=>{const t=(e=>n=>{let r=e,i=n,o=!0,u;for(;o;){const s=r,a=i;if(a.tag==="Nil"){o=!1,u=s;continue}if(a.tag==="Cons"){r=K(P)(a._1)()(s),i=a._2;continue}g()}return u})(A);return e=>t((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._3,n(r._6,i)));g()};return n(e,qt)})())})(),LT=Rn("Exit"),kT=t=>ha("Par",t),r1=t=>ha("Seq",t),ET=t=>e=>n=>{const r=On(Yt,T,i=>i._1===t,n);if(r.tag==="Just"){const i=qn(Yt,T,r._1,b(t,e),n);if(i.tag==="Nothing")return n;if(i.tag==="Just")return i._1;g()}if(r.tag==="Nothing")return Ft(n)(b(t,e));g()},CT=t=>e=>O(n=>n._1===t?b(n._1,{...n._2,label:w("Just",e)}):b(n._1,n._2)),we=t=>ve.state(e=>b(void 0,(()=>{if(e.error.tag==="Just")return e;if(e.error.tag==="Nothing")return{...e,error:w("Just",{msg:t,line:e.currentLine,column:e.currentColumn})};g()})())),ST=t=>Wt.bind(ve.state(e=>b(void 0,{...e,currentLine:t.line,currentColumn:t.column})))(()=>Wt.bind(Be)(e=>{if(e.error.tag==="Just")return ue.pure();if(e.error.tag==="Nothing"){if(t.op.tag==="Enter"){if(!Qn(t.op._1.id)(e.currNodes))return we("cannot enter node "+t.op._1.id+": does not exist");if(!n1(t.op._1.id)(e.interiorOf))return we("cannot enter node "+t.op._1.id+": it has no `inside` block");if(Qe(gn)(t.op._1.id)(e.enterStack))return we("cannot enter node "+t.op._1.id+": already entered");const n=t.op._1;return ve.state(r=>b(void 0,{...r,enterStack:Ft(r.enterStack)(n.id),scenes:Ft(r.scenes)(ao("EnterNode",n.id))}))}if(t.op.tag==="Exit"){const n=Xi(e.enterStack);if(n.tag==="Nothing")return we("`exit` without a matching `enter`");if(n.tag==="Just"){const r=n._1.init;return ve.state(i=>b(void 0,{...i,enterStack:r,scenes:Ft(i.scenes)(Dl)}))}g()}return ue.pure()}g()})),GT=t=>Wt.bind(Be)(e=>{const n=t.tag==="Just"&&t._1!==""?t._1:"kf-"+ie(e.kfCounter);if(Re(i=>i.id===n,e.keyframes))return we("duplicate frame name "+n);const r={...e,keyframes:Ft(e.keyframes)({id:n,nodes:e.currNodes,edges:e.currEdges}),kfCounter:e.kfCounter+1|0,currentKf:w("Just",n)};return ve.state(i=>b(void 0,r))}),PT=fu(t=>Wt.bind(Be)(e=>{if(e.error.tag==="Just")return ue.pure();if(e.error.tag==="Nothing")return n1(t.node)(e.interiorOf)?we("node "+t.node+" has more than one `inside` block"):ve.state(n=>b(void 0,{...n,interiorOf:K(P)(t.node)(t.doc)(n.interiorOf)}));g()})),IT=t=>e=>{const n=e.from+"->"+e.to,r=e.newFrom+"->"+e.newTo,i=Gt("Left","cannot repoint "+e.from+"\u2192"+e.to+": edge does not exist"),o=zn(n)(t.currEdges)?Gt("Right",void 0):i;return(()=>{if(o.tag==="Left"){const u=o._1;return s=>Gt("Left",u)}if(o.tag==="Right"){const u=o._1;return s=>s(u)}g()})()(()=>{const u="cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": unknown node "+e.newFrom;if(!Qn(e.newFrom)(t.currNodes))return Gt("Left",u);const s="cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": unknown node "+e.newTo;if(!Qn(e.newTo)(t.currNodes))return Gt("Left",s);const a="cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": target edge already exists";return n!==r&&zn(r)(t.currEdges)?Gt("Left",a):Gt("Right",{nextCurrEdges:K(P)(r)()(ni(P)(n)(t.currEdges)),newId:r,newEdge:{id:r,from:{node:e.newFrom,port:T},to:{node:e.newTo,port:T}}})})},i1={graphNodes:[],graphEdges:A,currNodes:A,currEdges:A,keyframes:[],scenes:[],kfCounter:0,eventCounter:0,currentKf:T,currentLine:0,currentColumn:0,error:T,enterStack:[],interiorOf:A},o1=t=>e=>Wt.bind(Be)(n=>{const r="ev-"+ie(n.eventCounter);return Wt.bind((()=>{const i={...n,eventCounter:n.eventCounter+1|0};return ve.state(o=>b(void 0,i))})())(()=>ue.pure({events:[{id:r,kind:e,when:t}],firstId:w("Just",r),lastId:w("Just",r)}))}),DT=t=>e=>{if(e.tag==="Token"){const n=e._1;return Wt.bind(Be)(r=>{const i=!Qn(n.from)(r.currNodes),o=!Qn(n.to)(r.currNodes);if(i||o)return Wt.bind(we(i?o?"token references unknown node: "+n.from+", "+n.to:"token references unknown node: "+n.from:o?"token references unknown node: "+n.to:"token references unknown node: "))(()=>ue.pure({events:[],firstId:T,lastId:T}));const u=n.to+"->"+n.from,s=n.from+"->"+n.to;return zn(s)(r.currEdges)?o1(t)(dc("SendToken",{from:n.from,to:n.to,edge:s,direction:Pl,labels:n.labels})):zn(u)(r.currEdges)?o1(t)(dc("SendToken",{from:n.from,to:n.to,edge:u,direction:Il,labels:n.labels})):Wt.bind(we("token "+n.from+"\u2192"+n.to+": no edge between "+n.from+" and "+n.to))(()=>ue.pure({events:[],firstId:T,lastId:T}))})}return ue.pure({events:[],firstId:T,lastId:T})},AT=t=>e=>{if(0<t.length){const n=t[0];return Wt.bind(ve.state(r=>b(void 0,{...r,currentLine:n.line,currentColumn:n.column})))(()=>we(e))}return we(e)},BT=t=>xt(e=>JT(e)(t.graphEdges))(kt(Kr,TT(t.currEdges))),FT=t=>e=>{const n=at(i=>i.from.node===e.id||i.to.node===e.id,BT(t)),r=_u(Ia)(i=>o=>{const u=o.from+"->"+e.id,s=e.id+"->"+o.to,a=o.from+"->"+o.to,c="via "+o.from+" "+o.to+": no edge "+o.from+"\u2192"+e.id;if(!zn(u)(t.currEdges))return Gt("Left",c);const f="via "+o.from+" "+o.to+": no edge "+e.id+"\u2192"+o.to;if(!zn(s)(t.currEdges))return Gt("Left",f);const d="via "+o.from+" "+o.to+": would create "+o.from+"\u2192"+o.to+" but it already exists";return zn(a)(t.currEdges)||vT(a)(i.synthesized)?Gt("Left",d):Gt("Right",{consumed:K(P)(u)()(K(P)(s)()(i.consumed)),synthesized:K(P)(a)({id:a,from:{node:o.from,port:T},to:{node:o.to,port:T}})(i.synthesized)})})({consumed:A,synthesized:A})(e.via);return(()=>{if(r.tag==="Left"){const i=r._1;return o=>Gt("Left",i)}if(r.tag==="Right"){const i=r._1;return o=>o(i)}g()})()(i=>{const o=i.consumed,u=at(s=>!zn(s.id)(o),n);return u.length===0?Gt("Right",{nextCurrEdges:Ce(P.compare,Le,Cn(P.compare,t.currEdges,wT(O(s=>s.id)(n))),bT((()=>{const s=a=>{if(a.tag==="Leaf")return A;if(a.tag==="Node")return Mt("Node",a._1,a._2,a._3,void 0,s(a._5),s(a._6));g()};return s(i.synthesized)})())),synthesized:i.synthesized}):Gt("Left","cannot delete node "+e.id+": still connected ("+ho(", ")(O(s=>s.from.node+"\u2192"+s.to.node)(u))+"). Use -edge to drop them or `via a b` to merge "+e.id+"'s endpoints.")})},u1=t=>{if(t.tag==="Leaf")return[t._1];if(t.tag==="Par"||t.tag==="Seq")return Tt(t._1)(u1);g()},RT=Wt.bind(Be)(t=>{if(t.error.tag==="Just")return ue.pure();if(t.error.tag==="Nothing"){const e=t.enterStack.length-1|0;return e>=0&&e<t.enterStack.length?we("entered node "+t.enterStack[e]+" was never exited"):ue.pure()}g()}),QT=t=>({nodes:O($i)(t.graphNodes),edges:(()=>{const e=(n,r)=>{if(n.tag==="Leaf")return r;if(n.tag==="Node")return e(n._5,Ot("Cons",n._4,e(n._6,r)));g()};return kt($t.foldr,e(t.graphEdges,qt))})(),constraints:[]}),zT=t=>{if(t.tag==="AddNode"){const e=t._1;return ve.state(n=>b(void 0,{...n,graphNodes:ET(e.id)({id:e.id,size:b(1,1),ports:[],label:w("Just",e.label),shape:e.shape})(n.graphNodes),currNodes:K(P)(e.id)()(n.currNodes)}))}if(t.tag==="DelNode"){const e=t._1;return Wt.bind(Be)(n=>{if(!Qn(e.id)(n.currNodes))return we("cannot delete node "+e.id+": does not exist");const r=FT(n)(e);if(r.tag==="Left")return we(r._1);if(r.tag==="Right"){const i=r._1;return ve.state(o=>b(void 0,{...o,currNodes:ni(P)(e.id)(o.currNodes),currEdges:i.nextCurrEdges,graphEdges:Ce(P.compare,Le,i.synthesized,o.graphEdges)}))}g()})}if(t.tag==="ModNode"){const e=t._1;return Wt.bind(Be)(n=>{if(!Qn(e.id)(n.currNodes))return we("cannot modify node "+e.id+": does not exist");if(e.label.tag==="Just"){const r=e.label._1;return ve.state(i=>b(void 0,{...i,graphNodes:CT(e.id)(r)(i.graphNodes)}))}if(e.label.tag==="Nothing")return ue.pure();g()})}if(t.tag==="AddEdge"){const e=t._1;return Wt.bind(Be)(n=>{const r=!Qn(e.from)(n.currNodes),i=!Qn(e.to)(n.currNodes);if(r||i)return we("cannot add edge "+e.from+"\u2192"+e.to+": unknown node "+(r?i?e.from+", "+e.to:e.from:i?e.to:""));const o=e.from+"->"+e.to;return ve.state(u=>b(void 0,{...u,graphEdges:K(P)(o)({id:o,from:{node:e.from,port:T},to:{node:e.to,port:T}})(u.graphEdges),currEdges:K(P)(o)()(u.currEdges)}))})}if(t.tag==="DelEdge"){const e=t._1;return Wt.bind(Be)(n=>{const r=e.from+"->"+e.to;return zn(r)(n.currEdges)?ve.state(i=>b(void 0,{...i,currEdges:ni(P)(r)(i.currEdges)})):we("cannot delete edge "+e.from+"\u2192"+e.to+": does not exist")})}if(t.tag==="RepointEdge"){const e=t._1;return Wt.bind(Be)(n=>{const r=IT(n)(e);if(r.tag==="Left")return we(r._1);if(r.tag==="Right"){const i=r._1;return ve.state(o=>b(void 0,{...o,currEdges:i.nextCurrEdges,graphEdges:K(P)(i.newId)(i.newEdge)(o.graphEdges)}))}g()})}return ue.pure()},WT=t=>Wt.bind(ve.state(e=>b(void 0,{...e,currentLine:t.line,currentColumn:t.column})))(()=>zT(t.op)),MT=t=>e=>Wt.bind(fu(WT)(e))(()=>Wt.bind(Be)(n=>{const r=t.tag==="Just"&&t._1!==""?t._1:"kf-"+ie(n.kfCounter);if(Re(o=>o.id===r,n.keyframes))return we("duplicate frame name "+r);const i={...n,keyframes:Ft(n.keyframes)({id:r,nodes:n.currNodes,edges:n.currEdges}),kfCounter:n.kfCounter+1|0,currentKf:w("Just",r),scenes:(()=>{if(n.currentKf.tag==="Nothing")return n.scenes;if(n.currentKf.tag==="Just")return Ft(n.scenes)(ao("Structural",{from:n.currentKf._1,to:r,focus:T}));g()})()};return ve.state(o=>b(void 0,i))})),HT=t=>e=>{const n=Bt(r=>T,r=>i=>w("Just",{head:r,tail:i}),e);if(n.tag==="Nothing")return ue.pure({events:[],firstId:T,lastId:T});if(n.tag==="Just"){const r=n._1.tail;return Wt.bind(Mi(t)(n._1.head))(i=>Wt.bind(_u({Applicative0:()=>Wi(Mn),Bind1:()=>zi(Mn)})(o=>u=>Wt.bind(Mi((()=>{if(o.lastId.tag==="Just")return $u("After",o.lastId._1);if(o.lastId.tag==="Nothing")return t;g()})())(u))(s=>ue.pure({events:[...o.events,...s.events],firstId:(()=>{if(o.firstId.tag==="Just")return w("Just",o.firstId._1);if(o.firstId.tag==="Nothing")return s.firstId;g()})(),lastId:(()=>{if(s.lastId.tag==="Just")return w("Just",s.lastId._1);if(s.lastId.tag==="Nothing")return o.lastId;g()})()})))(i)(r))(o=>ue.pure(o)))}g()},OT=t=>e=>{const n=Bt(r=>T,r=>i=>w("Just",{head:r,tail:i}),e);if(n.tag==="Nothing")return ue.pure({events:[],firstId:T,lastId:T});if(n.tag==="Just"){const r=n._1.tail;return Wt.bind(Mi(t)(n._1.head))(i=>Wt.bind(qT((()=>{if(i.firstId.tag==="Just")return $u("With",i.firstId._1);if(i.firstId.tag==="Nothing")return t;g()})())(r))(o=>ue.pure({events:[...i.events,...o.events],firstId:i.firstId,lastId:(()=>{if(i.lastId.tag==="Just")return w("Just",i.lastId._1);if(i.lastId.tag==="Nothing")return o.lastId;g()})()})))}g()},Mi=t=>e=>{if(e.tag==="Leaf"){const n=e._1;return Wt.bind(ve.state(r=>b(void 0,{...r,currentLine:n.line,currentColumn:n.column})))(()=>DT(t)(n.op))}if(e.tag==="Seq")return HT(t)(e._1);if(e.tag==="Par")return OT(t)(e._1);g()},qT=t=>_u({Applicative0:()=>Wi(Mn),Bind1:()=>zi(Mn)})(e=>n=>Wt.bind(Mi(t)(n))(r=>ue.pure({events:[...e.events,...r.events],firstId:(()=>{if(e.firstId.tag==="Just")return w("Just",e.firstId._1);if(e.firstId.tag==="Nothing")return r.firstId;g()})(),lastId:(()=>{if(r.lastId.tag==="Just")return w("Just",r.lastId._1);if(r.lastId.tag==="Nothing")return e.lastId;g()})()})))({events:[],firstId:T,lastId:T}),$T=t=>Wt.bind(Be)(e=>{if(e.currentKf.tag==="Nothing")return we("flow ops before any structural frame");if(e.currentKf.tag==="Just"){const n=e.currentKf._1;return Wt.bind(Mi(Gl)(t))(r=>Wt.bind(Be)(i=>{const o={...i,scenes:Ft(i.scenes)(ao("DataFlow",{keyframe:n,events:r.events,focus:T}))};return ve.state(u=>b(void 0,o))}))}g()}),YT=t=>Wt.bind(Be)(e=>{if(e.error.tag==="Just")return ue.pure();if(e.error.tag==="Nothing"){const n=u1(t.ops),r=at(u=>u.op.tag==="AddNode"||u.op.tag==="DelNode"||u.op.tag==="ModNode"||u.op.tag==="AddEdge"||u.op.tag==="DelEdge"||u.op.tag==="RepointEdge",n),i=at(u=>u.op.tag==="Enter"||u.op.tag==="Exit",n),o=at(u=>!(u.op.tag==="AddNode"||u.op.tag==="DelNode"||u.op.tag==="ModNode"||u.op.tag==="AddEdge"||u.op.tag==="DelEdge"||u.op.tag==="RepointEdge")&&!(u.op.tag==="Enter"||u.op.tag==="Exit"),n);return i.length!==0&&o.length!==0?AT(i)("`enter`/`exit` cannot be mixed with flow tokens in the same frame"):Wt.bind((()=>{const u=MT(t.name)(r);return r.length!==0?u:ue.pure()})())(()=>Wt.bind((()=>{const u=GT(t.name);return r.length===0&&o.length!==0?u:ue.pure()})())(()=>Wt.bind((()=>{const u=$T(t.ops);return o.length!==0?u:ue.pure()})())(()=>fu(ST)(i))))}g()}),s1=t=>Wt.bind(PT(t.interiors))(()=>Wt.bind(fu(YT)(t.frames))(()=>Wt.bind(RT)(()=>Wt.bind(Be)(e=>{if(e.error.tag==="Just")return ue.pure(Gt("Left",e.error._1));if(e.error.tag==="Nothing"){const n=XT(t.interiors);if(n.tag==="Left")return ue.pure(Gt("Left",n._1));if(n.tag==="Right")return ue.pure(Gt("Right",{seed:t.seed,graph:QT(e),keyframes:e.keyframes,scenes:e.scenes,interiors:n._1}))}g()})))),XT=t=>{const e=_u(Ia)(n=>r=>{const i=s1(r.doc)(i1)._1;return(()=>{if(i.tag==="Left"){const o=i._1;return u=>Gt("Left",o)}if(i.tag==="Right"){const o=i._1;return u=>u(o)}g()})()(o=>Gt("Right",K(P)(r.node)(o)(n)))})(A)(t);if(e.tag==="Left")return Gt("Left",e._1);if(e.tag==="Right")return Gt("Right",e._1);g()},Xr=(t,e)=>({tag:"ParseError",_1:t,_2:e}),F=(t,e,n)=>({tag:"ParseState",_1:t,_2:e,_3:n}),du=(t,e,n)=>({tag:t,_1:e,_2:n}),VT=t=>du("More",t),UT=t=>du("Lift",t),jT={defer:t=>{const e=cl(t);return(n,r,i,o,u)=>gl(e)(n,r,i,o,u)}},a1={map:t=>e=>(n,r,i,o,u)=>r(s=>e(n,r,i,o,(a,c)=>r(f=>u(a,t(c)))))},ZT={alt:t=>e=>(n,r,i,o,u)=>{const s=n._1,a=n._2;return r(c=>t(F(s,a,!1),r,i,(f,d)=>{const l=f._3;return r(_=>l?o(f,d):e(n,r,i,o,u))},u))},Functor0:()=>a1},KT=t=>{const e=t.Monad0();return n=>r=>{const i=o=>{let u=o,s=!0,a;for(;s;){const c=u();if(c.tag==="More"){u=c._1;continue}if(c.tag==="Lift"){s=!1,a=e.Bind1().Apply0().Functor0().map(Aa)(c._1);continue}if(c.tag==="Stop"){s=!1,a=e.Applicative0().pure(Zr("Done",b(c._2,c._1)));continue}g()}return a};return t.tailRecM(i)(o=>r(n,VT,UT,(u,s)=>du("Stop",u,Gt("Left",s)),(u,s)=>du("Stop",u,Gt("Right",s))))}},c1=(t,e,n,r,i)=>i(t,t._2),tv={index:0,line:1,column:1},ev=(t=>{const e=KT(t);return n=>r=>t.Monad0().Bind1().Apply0().Functor0().map(Yi)(e(F(n,tv,!1))(r))})(R1),g1={apply:t=>e=>(n,r,i,o,u)=>r(s=>t(n,r,i,o,(a,c)=>r(f=>{const d=n._3&&!a._3?F(a._1,a._2,!0):a;return e(d,r,i,o,(l,_)=>r(h=>u(d._3&&!l._3?F(l._1,l._2,!0):l,c(_))))}))),Functor0:()=>a1},f1={pure:t=>(e,n,r,i,o)=>o(e,t),Apply0:()=>g1},nv={bind:t=>e=>(n,r,i,o,u)=>r(s=>t(n,r,i,o,(a,c)=>r(f=>e(c)(n._3&&!a._3?F(a._1,a._2,!0):a,r,i,o,u)))),Apply0:()=>g1},rv={Applicative0:()=>f1,Bind1:()=>nv},lu=t=>(e,n,r,i,o)=>n(u=>c1(e,n,r,i,(s,a)=>n(c=>i(e._3&&!s._3?F(s._1,s._2,!0):s,Xr(t,a))))),iv={empty:lu("No alternative"),Alt0:()=>ZT},ov={Applicative0:()=>f1,Plus1:()=>iv},on=(t=>e=>{const n=e.Plus1().Alt0(),r=e.Applicative0();return i=>t.tailRecM(o=>t.Monad0().Bind1().bind(n.alt(n.Functor0().map(Aa)(i))(r.pure(Zr("Done",void 0))))(u=>r.pure((()=>{if(u.tag==="Loop")return Zr("Loop",Ot("Cons",u._1,o));if(u.tag==="Done")return Zr("Done",(s=>a=>{let c=s,f=a,d=!0,l;for(;d;){const _=c,h=f;if(h.tag==="Nil"){d=!1,l=_;continue}if(h.tag==="Cons"){c=Ot("Cons",h._1,_),f=h._2;continue}g()}return l})(qt)(o));g()})())))(qt)})({tailRecM:t=>e=>(n,r,i,o,u)=>{const s=(a,c,f)=>t(c)(a,r,i,o,(d,l)=>{const _=a._3&&!d._3?F(d._1,d._2,!0):d;if(l.tag==="Loop")return f===0?r(h=>s(_,l._1,30)):s(_,l._1,f-1|0);if(l.tag==="Done")return u(_,l._1);g()});return s(n,e,30)},Monad0:()=>rv})(ov),Ct=t=>e=>{const n=lu("Expected "+e);return(r,i,o,u,s)=>{const a=r._1,c=r._2;return i(f=>t(F(a,c,!1),i,o,(d,l)=>{const _=d._3;return i(h=>_?u(d,l):n(r,i,o,u,s))},s))}},pa=t=>(e,n,r,i,o)=>{const u=e._3,s=e._1,a=e._2;return n(c=>{const f=(d,l)=>{const _=d._3;return n(h=>_?i(F(d._1,d._2,u),l):o(e,void 0))};return n(d=>n(l=>t(F(s,a,!1),n,r,(_,h)=>f(F(_._1,_._2,!1),h),(_,h)=>n(m=>n(p=>lu("Negated parser succeeded")(_,n,r,f,(y,x)=>n(N=>o(_._3&&!y._3?F(y._1,y._2,!0):y,x))))))))})},uv=t=>{const e=t.foldr(n=>r=>{if(r.tag==="Nothing")return w("Just",n);if(r.tag==="Just")return w("Just",(i,o,u,s,a)=>{const c=i._1,f=i._2;return o(d=>n(F(c,f,!1),o,u,(l,_)=>{const h=l._3;return o(m=>h?s(l,_):r._1(i,o,u,s,a))},a))});g()})(T);return n=>{const r=e(n);if(r.tag==="Nothing")return lu("No alternative");if(r.tag==="Just")return r._1;g()}},sv=t=>e=>n=>(r,i,o,u,s)=>i(a=>i(c=>i(f=>i(d=>t(r,i,o,u,(l,_)=>i(h=>i(m=>{const p=r._3&&!l._3?F(l._1,l._2,!0):l;return n(p,i,o,u,(y,x)=>i(N=>{const v=p._3&&!y._3?F(y._1,y._2,!0):y;return i(L=>i(k=>{const E=r._3&&!v._3?F(v._1,v._2,!0):v;return e(E,i,o,u,(Q,H)=>i(j=>s(E._3&&!Q._3?F(Q._1,Q._2,!0):Q,x)))}))}))}))))))),ma=t=>e=>n=>{if(e===10)return{index:t.index+1|0,line:t.line+1|0,column:1};if(e===13){const r=vh()(n);return r.tag==="Just"&&r._1===10?{index:t.index+1|0,line:t.line,column:t.column}:{index:t.index+1|0,line:t.line+1|0,column:1}}return e===9?{index:t.index+1|0,line:t.line,column:(t.column+8|0)-Xn(t.column-1|0)(8)|0}:{index:t.index+1|0,line:t.line,column:t.column+1|0}},av=t=>e=>n=>{let r=t,i=e,o=n,u=!0,s;for(;u;){const a=r,c=i,f=o,d=po(c);if(d.tag==="Nothing"){u=!1,s=a;continue}if(d.tag==="Just"){r=d._1.tail===""?ma(a)(d._1.head)(f):ma(a)(d._1.head)(d._1.tail),i=d._1.tail,o=f;continue}g()}return s},Zt=t=>(e,n,r,i,o)=>{const u=po(e._1);if(u.tag==="Nothing")return i(e,Xr("Unexpected EOF",e._2));if(u.tag==="Just"){if(u._1.head<0||u._1.head>65535)return i(e,Xr("Expected Char",e._2));if(u._1.head>=0&&u._1.head<=65535){const s=vc(u._1.head);return t(s)?o(F(u._1.tail,ma(e._2)(u._1.head)(u._1.tail),!0),s):i(e,Xr("Predicate unsatisfied",e._2))}}g()},ya=(t,e,n,r,i)=>t._1===""?i(F(t._1,t._2,!0),void 0):r(t,Xr("Expected EOF",t._2)),cv=t=>(e,n,r,i,o)=>{const u=t(e._1);if(u.tag==="Left")return i(e,Xr(u._1,e._2));if(u.tag==="Right")return o(F(u._1.remainder,av(e._2)(u._1.consumed)(u._1.remainder),u._1.consumed!==""),u._1.value);g()},Vr=t=>cv(e=>{const n=al(t)(e);return n.tag==="Just"?Gt("Right",{value:t,consumed:t,remainder:n._1}):Gt("Left","Expected "+L1(t))}),gv=Zt(t=>!0),_1=(t,e)=>({tag:t,_1:e}),fv=Kt(P)(zt),_v=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=P.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},d1=uv(zt),l1=(()=>{const t=Zt(e=>e===" "||e===" "||e===`
|
|
9
|
-
`||e==="\r");return(e,n,r,i,o)=>n(u=>t(e,n,r,i,(s,a)=>n(c=>o(e._3&&!s._3?
|
|
10
|
-
`)),f=t._3&&!u._3?
|
|
11
|
-
`||n==="\r");return(n,r,i,o,u)=>{const s=n._1,a=n._2;return r(c=>r(f=>t(
|
|
12
|
-
`:_==="t"?" ":_==="r"?"\r":_))))})))})(),
|
|
13
|
-
`);return(e,n,r,i,o)=>{const u=e._1,s=e._2;return n(a=>
|
|
14
|
-
`&&U!=="\r"&&U!=="#"&&U!=="}")),C=v._3&&!Q._3?F(Q._1,Q._2,!0):Q;return d(U=>S(C,d,l,x,(Y,W)=>d(z=>h(C._3&&!Y._3?F(Y._1,Y._2,!0):Y,fh(cr(kt($t.foldr,W)))))))}))))))})})('label ("\u2026", : rest-of-line, or |\u2026|)')(e._3&&!s._3?F(s._1,s._2,!0):s,n,r,i,o))))})(),mv=(t,e,n,r,i)=>{const o=t._1,u=t._2;return e(s=>h1(F(o,u,!1),e,n,(a,c)=>{const f=a._3;return e(d=>f?r(a,c):Na(t,e,n,r,i))},i))},Hi=Zt(t=>t>="0"&&t<="9"),be=(()=>{const t=Ct(Zt(e=>e==="_"))("'_'");return(e,n,r,i,o)=>n(u=>{const s=(f,d)=>n(l=>{const _=on((()=>{const m=Ct(Zt(y=>y==="_"))("'_'"),p=Ct(Zt(y=>y==="-"))("'-'");return(y,x,N,v,L)=>{const k=y._1,E=y._2;return x(Q=>hu(F(k,E,!1),x,N,(H,j)=>{const S=H._3;return x(C=>{if(S)return v(H,j);const U=y._1,Y=y._2;return x(W=>Hi(F(U,Y,!1),x,N,(z,R)=>{const G=z._3;return x(I=>{if(G)return v(z,R);const D=y._1,B=y._2;return x(q=>m(F(D,B,!1),x,N,(V,$)=>{const X=V._3;return x(M=>X?v(V,$):p(y,x,N,v,L))},L))})},L))})},L))}})()),h=e._3&&!f._3?F(f._1,f._2,!0):f;return n(m=>_(h,n,r,i,(p,y)=>n(x=>o(h._3&&!p._3?F(p._1,p._2,!0):p,ro(d)+cr(kt($t.foldr,y))))))}),a=e._1,c=e._2;return n(f=>hu(F(a,c,!1),n,r,(d,l)=>{const _=d._3;return n(h=>_?i(d,l):t(e,n,r,i,s))},s))})})(),yv=Ct((t,e,n,r,i)=>{const o=t._1,u=t._2;return e(s=>Na(F(o,u,!1),e,n,(a,c)=>{const f=a._3;return e(d=>f?r(a,c):be(t,e,n,r,i))},i))})("frame name (identifier or quoted string)"),p1=(t,e,n,r,i)=>e(o=>He(t,e,n,r,(u,s)=>e(a=>{const c=Ct(be)("attribute key"),f=t._3&&!u._3?F(u._1,u._2,!0):u;return e(d=>c(f,e,n,r,(l,_)=>e(h=>{const m=f._3&&!l._3?F(l._1,l._2,!0):l;return e(p=>He(m,e,n,r,(y,x)=>e(N=>{const v=Ct(Ct(Zt(k=>k===":"))("':'"))("':'"),L=m._3&&!y._3?F(y._1,y._2,!0):y;return e(k=>v(L,e,n,r,(E,Q)=>e(H=>{const j=L._3&&!E._3?F(E._1,E._2,!0):E;return e(S=>He(j,e,n,r,(C,U)=>e(Y=>{const W=Ct(be)("attribute value"),z=j._3&&!C._3?F(C._1,C._2,!0):C;return e(R=>W(z,e,n,r,(G,I)=>e(D=>{const B=z._3&&!G._3?F(G._1,G._2,!0):G;return e(q=>He(B,e,n,r,(V,$)=>e(X=>i(B._3&&!V._3?F(V._1,V._2,!0):V,b(_,I)))))})))})))})))})))})))}))),xv=(t,e,n,r,i)=>e(o=>be(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?F(u._1,u._2,!0):u;return e(f=>He(c,e,n,r,(d,l)=>e(_=>{const h=Ct((p,y,x,N,v)=>{const L=p._1,k=p._2;return y(E=>Vr("->")(F(L,k,!1),y,x,(Q,H)=>{const j=Q._3;return y(S=>j?N(Q,H):Vr("<-")(p,y,x,N,v))},v))})("'->' or '<-'"),m=c._3&&!d._3?F(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?F(y._1,y._2,!0):y;return e(L=>He(v,e,n,r,(k,E)=>e(Q=>{const H=Ct(be)("target node identifier"),j=v._3&&!k._3?F(k._1,k._2,!0):k;return e(S=>H(j,e,n,r,(C,U)=>e(Y=>{const W=on((R,G,I,D,B)=>{const q=R._3;return G(V=>G($=>He(R,G,I,(X,M)=>D(F(X._1,X._2,q),M),(X,M)=>G(et=>G(tt=>{const gt=R._3&&!X._3?F(X._1,X._2,!0):X;return mv(gt,G,I,(_t,ct)=>D(F(_t._1,_t._2,q),ct),(_t,ct)=>G(yt=>B(gt._3&&!_t._3?F(_t._1,_t._2,!0):_t,ct)))})))))}),z=j._3&&!C._3?F(C._1,C._2,!0):C;return e(R=>W(z,e,n,r,(G,I)=>e(D=>(()=>{if(x==="<-"){const q=Rn("Token",{from:U,to:s,labels:O(cc)(kt($t.foldr,I))});return(V,$,X,M,et)=>et(V,q)}const B=Rn("Token",{from:s,to:U,labels:O(cc)(kt($t.foldr,I))});return(q,V,$,X,M)=>M(q,B)})()(z._3&&!G._3?F(G._1,G._2,!0):G,e,n,r,i))))})))})))})))})))}))),Nv=(t,e,n,r,i)=>e(o=>Hi(t,e,n,r,(u,s)=>e(a=>{const c=on(Hi),f=t._3&&!u._3?F(u._1,u._2,!0):u;return e(d=>c(f,e,n,r,(l,_)=>e(h=>{const m=ld(ro(s)+cr(kt($t.foldr,_)));return(()=>{if(m.tag==="Just"){const p=m._1;return(y,x,N,v,L)=>L(y,p)}if(m.tag==="Nothing")return(p,y,x,N,v)=>v(p,0);g()})()(f._3&&!l._3?F(l._1,l._2,!0):l,e,n,r,i)})))}))),Oi=t=>(e,n,r,i,o)=>{const u=e._3;return n(s=>Vr(t)(e,n,r,(a,c)=>i(F(a._1,a._2,u),c),(a,c)=>n(f=>{const d=pa((()=>{const _=Ct(Zt(m=>m==="_"))("'_'"),h=Ct(Zt(m=>m==="-"))("'-'");return(m,p,y,x,N)=>{const v=m._1,L=m._2;return p(k=>hu(F(v,L,!1),p,y,(E,Q)=>{const H=E._3;return p(j=>{if(H)return x(E,Q);const S=m._1,C=m._2;return p(U=>Hi(F(S,C,!1),p,y,(Y,W)=>{const z=Y._3;return p(R=>{if(z)return x(Y,W);const G=m._1,I=m._2;return p(D=>_(F(G,I,!1),p,y,(B,q)=>{const V=B._3;return p($=>V?x(B,q):h(m,p,y,x,N))},N))})},N))})},N))}})()),l=e._3&&!a._3?F(a._1,a._2,!0):a;return n(_=>d(l,n,r,(h,m)=>i(F(h._1,h._2,u),m),(h,m)=>n(p=>{const y=l._3&&!h._3?F(h._1,h._2,!0):h;return n(x=>Ue(y,n,r,(N,v)=>i(F(N._1,N._2,u),v),(N,v)=>n(L=>o(y._3&&!N._3?F(N._1,N._2,!0):N,t))))})))})))},Jv=(t,e,n,r,i)=>e(o=>cn(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?F(u._1,u._2,!0):u;return e(f=>Oi("via")(c,e,n,r,(d,l)=>e(_=>{const h=c._3&&!d._3?F(d._1,d._2,!0):d;return e(m=>be(h,e,n,r,(p,y)=>e(x=>{const N=h._3&&!p._3?F(p._1,p._2,!0):p;return e(v=>cn(N,e,n,r,(L,k)=>e(E=>{const Q=N._3&&!L._3?F(L._1,L._2,!0):L;return e(H=>be(Q,e,n,r,(j,S)=>e(C=>i(Q._3&&!j._3?F(j._1,j._2,!0):j,{from:y,to:S}))))})))})))})))}))),rr=t=>(e,n,r,i,o)=>{const u=e._3;return n(s=>Vr(t)(e,n,r,(a,c)=>i(F(a._1,a._2,u),c),(a,c)=>n(f=>{const d=pa((()=>{const _=Ct(Zt(m=>m==="_"))("'_'"),h=Ct(Zt(m=>m==="-"))("'-'");return(m,p,y,x,N)=>{const v=m._1,L=m._2;return p(k=>hu(F(v,L,!1),p,y,(E,Q)=>{const H=E._3;return p(j=>{if(H)return x(E,Q);const S=m._1,C=m._2;return p(U=>Hi(F(S,C,!1),p,y,(Y,W)=>{const z=Y._3;return p(R=>{if(z)return x(Y,W);const G=m._1,I=m._2;return p(D=>_(F(G,I,!1),p,y,(B,q)=>{const V=B._3;return p($=>V?x(B,q):h(m,p,y,x,N))},N))})},N))})},N))}})()),l=e._3&&!a._3?F(a._1,a._2,!0):a;return n(_=>d(l,n,r,(h,m)=>i(F(h._1,h._2,u),m),(h,m)=>n(p=>o(l._3&&!h._3?F(h._1,h._2,!0):h,void 0))))})))},Tv=(t,e,n,r,i)=>e(o=>rr("+edge")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?F(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Ct(be)("source node identifier"),m=c._3&&!d._3?F(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?F(y._1,y._2,!0):y;return e(L=>cn(v,e,n,r,(k,E)=>e(Q=>{const H=Ct(be)("target node identifier"),j=v._3&&!k._3?F(k._1,k._2,!0):k;return e(S=>H(j,e,n,r,(C,U)=>e(Y=>i(j._3&&!C._3?F(C._1,C._2,!0):C,Rn("AddEdge",{from:x,to:U})))))})))})))})))}))),vv=(t,e,n,r,i)=>e(o=>rr("-edge")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?F(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Ct(be)("source node identifier"),m=c._3&&!d._3?F(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?F(y._1,y._2,!0):y;return e(L=>cn(v,e,n,r,(k,E)=>e(Q=>{const H=Ct(be)("target node identifier"),j=v._3&&!k._3?F(k._1,k._2,!0):k;return e(S=>H(j,e,n,r,(C,U)=>e(Y=>i(j._3&&!C._3?F(C._1,C._2,!0):C,Rn("DelEdge",{from:x,to:U})))))})))})))})))}))),wv=(t,e,n,r,i)=>e(o=>rr("-node")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?F(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Ct(be)("node identifier"),m=c._3&&!d._3?F(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=on((k,E,Q,H,j)=>{const S=k._3;return Jv(k,E,Q,(C,U)=>H(F(C._1,C._2,S),U),j)}),L=m._3&&!y._3?F(y._1,y._2,!0):y;return e(k=>v(L,e,n,r,(E,Q)=>e(H=>i(L._3&&!E._3?F(E._1,E._2,!0):E,Rn("DelNode",{id:x,via:kt($t.foldr,Q)})))))})))})))}))),bv=(t,e,n,r,i)=>e(o=>rr("enter")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?F(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Ct(be)("node identifier"),m=c._3&&!d._3?F(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>i(m._3&&!y._3?F(y._1,y._2,!0):y,Rn("Enter",{id:x})))))})))}))),Lv=(t,e,n,r,i)=>e(o=>rr("exit")(t,e,n,r,(u,s)=>e(a=>i(t._3&&!u._3?F(u._1,u._2,!0):u,LT)))),kv=(t,e,n,r,i)=>e(o=>rr("~edge")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?F(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Ct(be)("source node identifier"),m=c._3&&!d._3?F(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?F(y._1,y._2,!0):y;return e(L=>cn(v,e,n,r,(k,E)=>e(Q=>{const H=Ct(be)("target node identifier"),j=v._3&&!k._3?F(k._1,k._2,!0):k;return e(S=>H(j,e,n,r,(C,U)=>e(Y=>{const W=j._3&&!C._3?F(C._1,C._2,!0):C;return e(z=>Ue(W,e,n,r,(R,G)=>e(I=>{const D=Ct(Vr("->"))("'->'"),B=W._3&&!R._3?F(R._1,R._2,!0):R;return e(q=>D(B,e,n,r,(V,$)=>e(X=>{const M=B._3&&!V._3?F(V._1,V._2,!0):V;return e(et=>Ue(M,e,n,r,(tt,gt)=>e(_t=>{const ct=Ct(be)("new source node identifier"),yt=M._3&&!tt._3?F(tt._1,tt._2,!0):tt;return e(Et=>ct(yt,e,n,r,(Rt,pt)=>e(Qt=>{const Jt=yt._3&&!Rt._3?F(Rt._1,Rt._2,!0):Rt;return e(mt=>cn(Jt,e,n,r,(nt,Z)=>e(ut=>{const ft=Ct(be)("new target node identifier"),lt=Jt._3&&!nt._3?F(nt._1,nt._2,!0):nt;return e(Nt=>ft(lt,e,n,r,(Ht,Vt)=>e(Pe=>i(lt._3&&!Ht._3?F(Ht._1,Ht._2,!0):Ht,Rn("RepointEdge",{from:x,to:U,newFrom:pt,newTo:Vt})))))})))})))})))})))})))})))})))})))})))}))),Ev=(t,e,n,r,i)=>e(o=>rr("seed")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?F(u._1,u._2,!0):u;return e(f=>He(c,e,n,r,(d,l)=>e(_=>{const h=Ct(Nv)("integer (seed value)"),m=c._3&&!d._3?F(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?F(y._1,y._2,!0):y;return e(L=>Ue(v,e,n,r,(k,E)=>e(Q=>i(v._3&&!k._3?F(k._1,k._2,!0):k,x))))})))})))}))),qi=sv((()=>{const t=Ct(Zt(e=>e==="{"))("'{'");return(e,n,r,i,o)=>n(u=>n(s=>t(e,n,r,i,(a,c)=>n(f=>n(d=>{const l=e._3&&!a._3?F(a._1,a._2,!0):a;return Ue(l,n,r,i,(_,h)=>n(m=>o(l._3&&!_._3?F(_._1,_._2,!0):_,h)))})))))})())(Ct((()=>{const t=Ct(Zt(e=>e==="}"))("'}'");return(e,n,r,i,o)=>n(u=>n(s=>Ue(e,n,r,i,(a,c)=>n(f=>n(d=>{const l=e._3&&!a._3?F(a._1,a._2,!0):a;return t(l,n,r,i,(_,h)=>n(m=>o(l._3&&!_._3?F(_._1,_._2,!0):_,h)))})))))})())("closing '}'")),Cv=qi((t,e,n,r,i)=>e(o=>{const u=(c,f)=>e(d=>(()=>{if(f.tag==="Nothing")return(l,_,h,m,p)=>p(l,A);if(f.tag==="Just"){const l=f._1,_=on((()=>{const h=Ct(Zt(m=>m===","))("','");return(m,p,y,x,N)=>{const v=m._3;return p(L=>p(k=>p(E=>p(Q=>p(H=>p(j=>He(m,p,y,(S,C)=>x(F(S._1,S._2,v),C),(S,C)=>p(U=>p(Y=>{const W=m._3&&!S._3?F(S._1,S._2,!0):S;return h(W,p,y,(z,R)=>x(F(z._1,z._2,v),R),(z,R)=>p(G=>{const I=W._3&&!z._3?F(z._1,z._2,!0):z;return p(D=>p(B=>{const q=m._3&&!I._3?F(I._1,I._2,!0):I;return He(q,p,y,(V,$)=>x(F(V._1,V._2,v),$),(V,$)=>p(X=>{const M=q._3&&!V._3?F(V._1,V._2,!0):V;return p(et=>p(tt=>{const gt=m._3&&!M._3?F(M._1,M._2,!0):M;return p1(gt,p,y,(_t,ct)=>x(F(_t._1,_t._2,v),ct),(_t,ct)=>p(yt=>N(gt._3&&!_t._3?F(_t._1,_t._2,!0):_t,ct)))}))}))}))}))})))))))))}})());return(h,m,p,y,x)=>m(N=>_(h,m,p,y,(v,L)=>m(k=>x(h._3&&!v._3?F(v._1,v._2,!0):v,fv([l,...kt($t.foldr,L)])))))}g()})()(t._3&&!c._3?F(c._1,c._2,!0):c,e,n,r,i)),s=t._1,a=t._2;return e(c=>e(f=>p1(F(s,a,!1),e,n,(d,l)=>e(_=>u(t,T)),(d,l)=>e(_=>u(d,w("Just",l))))))})),Sv=(t,e,n,r,i)=>e(o=>rr("+node")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?F(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Ct(be)("node identifier"),m=c._3&&!d._3?F(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?F(y._1,y._2,!0):y;return e(L=>e(k=>He(v,e,n,r,(E,Q)=>e(H=>{const j=Zt(C=>C===`
|
|
15
|
-
`||
|
|
1
|
+
var Tw=(function(mu){"use strict";function ka(t){let e=0,n;return()=>{if(e===2)return n;if(e===1)throw new Error("Binding demanded before initialized");return e=1,n=t(),e=2,n}}function g(){throw new Error("Failed pattern match")}function En(t,e){return e>0?Math.floor(t/e):e<0?-Math.floor(t/-e):0}const Le=t=>e=>t,H=function(t){return function(e){for(var n=e.length,r=new Array(n),i=0;i<n;i++)r[i]=t(e[i]);return r}},T1={map:H},Ea=t=>t,Tt=typeof Array.prototype.flatMap=="function"?function(t){return function(e){return t.flatMap(e)}}:function(t){return function(e){for(var n=[],r=t.length,i=0;i<r;i++)for(var o=e(t[i]),u=o.length,s=0;s<u;s++)n.push(o[s]);return n}},ie=function(t){return t.toString()},Ga=function(t){var e=t.toString();return isNaN(e+".0")?e:e+".0"},v1=function(t){var e=t.length;return'"'+t.replace(/[\0-\x1F\x7F"\\]/g,function(n,r){switch(n){case'"':case"\\":return"\\"+n;case"\x07":return"\\a";case"\b":return"\\b";case"\f":return"\\f";case`
|
|
2
|
+
`:return"\\n";case"\r":return"\\r";case" ":return"\\t";case"\v":return"\\v"}var i=r+1,o=i<e&&t[i]>="0"&&t[i]<="9"?"\\&":"";return"\\"+n.charCodeAt(0).toString(10)+o})+'"'},yu=t=>t,ye=yu("LT"),xe=yu("GT"),Se=yu("EQ"),w=(t,e)=>({tag:t,_1:e}),T=w("Nothing"),Yt=t=>w("Just",t),Ca=t=>{if(t.tag==="Nothing")return!0;if(t.tag==="Just")return!1;g()},Sa=t=>{if(t.tag==="Nothing")return!1;if(t.tag==="Just")return!0;g()},St=(t,e)=>({tag:t,_1:e}),w1=t=>St("Right",t),b1={map:t=>e=>{if(e.tag==="Left")return St("Left",e._1);if(e.tag==="Right")return St("Right",t(e._1));g()}},Da={apply:t=>e=>{if(t.tag==="Left")return St("Left",t._1);if(t.tag==="Right"){if(e.tag==="Left")return St("Left",e._1);if(e.tag==="Right")return St("Right",t._1(e._1))}g()},Functor0:()=>b1},L1={bind:t=>{if(t.tag==="Left"){const e=t._1;return n=>St("Left",e)}if(t.tag==="Right"){const e=t._1;return n=>n(e)}g()},Apply0:()=>Da},k1={pure:w1,Apply0:()=>Da},Pa={Applicative0:()=>k1,Bind1:()=>L1},E1=t=>t,G1={map:t=>e=>t(e)},Ia={apply:t=>e=>t(e),Functor0:()=>G1},C1={bind:t=>e=>e(t),Apply0:()=>Ia},S1={pure:E1,Apply0:()=>Ia},Wn={Applicative0:()=>S1,Bind1:()=>C1},D1=function(t){return function(){return t}},P1={apply:t=>e=>()=>{const n=t(),r=e();return xu.pure(n(r))()},Functor0:()=>I1},xu={pure:D1,Apply0:()=>P1},I1={map:t=>e=>()=>{const n=e();return t(n)}},Zr=(t,e)=>({tag:t,_1:e}),Qa=t=>Zr("Loop",t),Q1={tailRecM:t=>{const e=n=>{let r=n,i=!0,o;for(;i;){const u=r;if(u.tag==="Loop"){r=t(u._1);continue}if(u.tag==="Done"){i=!1,o=u._1;continue}g()}return o};return n=>e(t(n))},Monad0:()=>Wn},F1=function(t){return function(e){return function(){return t(e())}}},A1=function(t){return function(){return t}},M1={map:F1},B1={apply:t=>e=>()=>{const n=t(),r=e();return Fa.pure(n(r))()},Functor0:()=>M1},Fa={pure:A1,Apply0:()=>B1},z1=(function(t){return function(e){return function(n){return function(){return t(e,n)}}}})(function(t,e){return e.push(t)}),R1=(t,e)=>({tag:"Iterator",_1:t,_2:e}),W1=t=>e=>n=>()=>{let r=!1;const i=e._2;for(;!r;){const o=i.value,u=e._1(o);if(u.tag==="Just"&&t(u._1)){n.push(u._1),e._2.value;const s=e._2.value;e._2.value=s+1|0;continue}r=!0}},H1=t=>e=>()=>{let n=!1;const r=t._2;for(;!n;){const i=r.value,o=r.value;r.value=o+1|0;const u=t._1(i);if(u.tag==="Just"){e(u._1)();continue}if(u.tag==="Nothing"){n=!0;continue}g()}},Kr=function(t){return function(e){return function(n){for(var r=e,i=n.length,o=i-1;o>=0;o--)r=t(n[o])(r);return r}}},J=function(t){return function(e){return function(n){for(var r=e,i=n.length,o=0;o<i;o++)r=t(r)(n[o]);return r}}},Nu=t=>{const e=t.Apply0();return n=>r=>n.foldr(i=>{const o=r(i);return u=>e.apply(e.Functor0().map(s=>Ea)(o))(u)})(t.pure())},O1=t=>{const e=Nu(t);return n=>{const r=e(n);return i=>o=>r(o)(i)}},Bt={foldr:Kr,foldl:J,foldMap:t=>{const e=t.mempty;return n=>Bt.foldr(r=>i=>t.Semigroup0().append(n(r))(i))(e)}},b=(t,e)=>({tag:"Tuple",_1:t,_2:e}),Hn=t=>e=>b(t,e),$i=t=>t._2,Yi=t=>t._1,Qt=function(t){return function(e){for(var n=e.length,r=Array(n),i=0;i<n;i++)r[i]=t(i)(e[i]);return r}};var Ju=function(t){return function(e){return t===e}};const q1=Ju,$1=Ju,ti=Ju,Tu=function(t){return function(e){return function(n){if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(!t(e[r])(n[r]))return!1;return!0}}},gn={eq:ti},Y1={eq:$1},xr={eq:q1};var vu=function(t){return function(e){return function(n){return function(r){return function(i){return r<i?t:r===i?e:n}}}}};const V1=vu,X1=vu,C={compare:vu(ye)(Se)(xe),Eq0:()=>gn},st={compare:X1(ye)(Se)(xe),Eq0:()=>Y1},it={compare:V1(ye)(Se)(xe),Eq0:()=>xr},U1=function(t){return t},j1=(function(){function t(i){return[i]}function e(i){return function(o){return[i,o]}}function n(i){return function(o){return function(u){return[i,o,u]}}}function r(i){return function(o){return i.concat(o)}}return function(i){return function(o){return function(u){return function(s){return function(a){function c(f,d){switch(d-f){case 0:return u([]);case 1:return o(t)(s(a[f]));case 2:return i(o(e)(s(a[f])))(s(a[f+1]));case 3:return i(i(o(n)(s(a[f])))(s(a[f+1])))(s(a[f+2]));default:var l=f+Math.floor((d-f)/4)*2;return i(o(r)(c(f,l)))(c(l,d))}}return c(0,a.length)}}}}}})(),Z1=t=>t,rr={traverse:t=>{const e=t.Apply0();return j1(e.apply)(e.Functor0().map)(t.pure)},sequence:t=>rr.traverse(t)(Z1),Functor0:()=>T1,Foldable1:()=>Bt},It=function(t,e){for(var n=t>e?-1:1,r=new Array(n*(e-t)+1),i=t,o=0;i!==e;)r[o++]=i,i+=n;return r[o]=i,r};var K1=function(t,e){if(t<1)return[];var n=new Array(t);return n.fill(e)},td=function(t,e){for(var n=[],r=0,i=0;i<t;i++)n[r++]=e;return n};const ed=typeof Array.prototype.fill=="function"?K1:td,kt=(function(){function t(i,o){this.head=i,this.tail=o}var e={};function n(i){return function(o){return new t(i,o)}}function r(i){for(var o=[],u=0,s=i;s!==e;)o[u++]=s.head,s=s.tail;return o}return function(i,o){return r(i(n)(e)(o))}})(),Ft=function(t,e,n){return n.length===0?t({}):e(n[0])(n.slice(1))},Aa=function(t,e,n,r){for(var i=0;i<r.length;i++){var o=n(r[i]);if(e(o))return o}return t},ir=function(t,e,n,r){for(var i=0,o=r.length;i<o;i++)if(n(r[i]))return t(i);return e},Ma=function(t,e,n,r){for(var i=r.length-1;i>=0;i--)if(n(r[i]))return t(i);return e},Ba=function(t,e,n,r,i){if(n<0||n>i.length)return e;var o=i.slice();return o.splice(n,0,r),t(o)},za=function(t,e,n,r){if(n<0||n>=r.length)return e;var i=r.slice();return i.splice(n,1),t(i)},On=function(t,e,n,r,i){if(n<0||n>=i.length)return e;var o=i.slice();return o[n]=r,t(o)},ke=function(t){return t.slice().reverse()},Ae=function(t){if(t.length<=1e4)return Array.prototype.concat.apply([],t);for(var e=[],n=0,r=t.length;n<r;n++)for(var i=t[n],o=0,u=i.length;o<u;o++)e.push(i[o]);return e},ct=function(t,e){return e.filter(t)},nd=function(t,e,n){for(var r=n.length,i=e,o=new Array(r),u=0;u<r;u++)i=t(i)(n[u]),o[u]=i;return o},rd=(function(){function t(e,n,r,i,o,u){var s,a,c,f,d,l,_;for(s=o+(u-o>>1),s-o>1&&t(e,n,i,r,o,s),u-s>1&&t(e,n,i,r,s,u),a=o,c=s,f=o;a<s&&c<u;)d=i[a],l=i[c],_=n(e(d)(l)),_>0?(r[f++]=l,++c):(r[f++]=d,++a);for(;a<s;)r[f++]=i[a++];for(;c<u;)r[f++]=i[c++]}return function(e,n,r){var i;return r.length<2?r:(i=r.slice(0),t(e,n,i,r.slice(0),0,r.length),i)}})(),bt=function(t,e,n){return n.slice(t,e)},Je=function(t,e,n){for(var r=e.length<n.length?e.length:n.length,i=new Array(r),o=0;o<r;o++)i[o]=t(e[o])(n[o]);return i},Me=function(t,e){for(var n=e.length,r=0;r<n;r++)if(t(e[r]))return!0;return!1},Ra=function(t,e){for(var n=e.length,r=0;r<n;r++)if(!t(e[r]))return!1;return!0},Lt=t=>e=>rd(t,n=>{if(n==="GT")return 1;if(n==="EQ")return 0;if(n==="LT")return-1;g()},e),id=t=>e=>Lt(n=>r=>t.compare(e(n))(e(r))),zt=t=>e=>(()=>{const n=z1(e);return()=>{const r=[...t];return n(r)(),r}})()(),Vi=t=>{if(t.length===0)return t.length-1|0,T;const e=t.length-1|0;return e>=0&&e<t.length?w("Just",{init:bt(0,t.length-1|0,t),last:t[e]}):T},od=t=>e=>n=>t>=0&&t<n.length?On(Yt,T,t,e(n[t]),n):T,or=t=>e=>{const n=(r=>{let i=r,o=!0,u;for(;o;){const s=i;if(s>=0&&s<e.length){if(t(e[s])){i=s+1|0;continue}o=!1,u=w("Just",s);continue}o=!1,u=T}return u})(0);if(n.tag==="Just")return n._1===0?{init:[],rest:e}:{init:bt(0,n._1,e),rest:bt(n._1,e.length,e)};if(n.tag==="Nothing")return{init:e,rest:[]};g()},Nr=t=>e=>{const n=Lt(r=>i=>t(r._2)(i._2))(Qt(Hn)(e));return 0<n.length?H($i)(id(it)(Yi)((()=>{const r=[n[0]];for(const i of n){const o=t((()=>{const u=r.length-1|0;if(u>=0&&u<r.length)return r[u]._2;g()})())(i._2);(o==="LT"||o==="GT"||o!=="EQ")&&r.push(i)}return r})())):[]},ud=t=>e=>{const n=[],r=R1(i=>i>=0&&i<e.length?w("Just",e[i]):T,{value:0});return H1(r)(i=>()=>{const o=[];o.push(i),W1(t(i))(r)(o)(),n.push(o)})(),n},Zt=t=>e=>{const n=ir(Yt,T,t,e);return n.tag==="Just"?w("Just",e[n._1]):T},Wa=t=>e=>ct(t,e),Be=t=>e=>n=>{const r=ir(Yt,T,i=>t.eq(i)(e),n);if(r.tag==="Nothing")return!1;if(r.tag==="Just")return!0;g()},Ha=t=>e=>Tt(e)(t),xt=t=>Ha(e=>{const n=t(e);if(n.tag==="Nothing")return[];if(n.tag==="Just")return[n._1];g()}),Oa=isFinite;function sd(t,e,n,r){var i=parseFloat(t);return e(i)?n(i):r}const qn=Math.abs,ad=Math.acos,ur=function(t){return function(e){return Math.atan2(t,e)}},Xi=Math.ceil,Ke=Math.cos,Ui=Math.exp,dn=Math.floor,qa=Math.log,cd=function(t){return function(e){return Math.min(t,e)}},wu=function(t){return function(e){return Math.pow(t,e)}},$n=Math.round,Oe=Math.sin,Ee=Math.sqrt,gd=Math.tan,fd=function(t){return function(e){return function(n){return(n|0)===n?t(n):e}}},rt=function(t){return t},_d=(function(t){return function(e){return function(n){var r;n<11?r="[0-"+(n-1).toString()+"]":n===11?r="[0-9a]":r="[0-9a-"+String.fromCharCode(86+n)+"]";var i=new RegExp("^[\\+\\-]?"+r+"+$","i");return function(o){if(i.test(o)){var u=parseInt(o,n);return(u|0)===u?t(u):e}else return e}}}})(Yt)(T)(10),$a=fd(Yt)(T),de=t=>{if(!Oa(t))return 0;if(t>=rt(2147483647))return 2147483647;if(t<=rt(-2147483648))return-2147483648;const e=$a(t);if(e.tag==="Nothing")return 0;if(e.tag==="Just")return e._1;g()},Ot=(t,e,n)=>({tag:t,_1:e,_2:n}),qt=Ot("Nil"),$t={foldr:t=>e=>{const n=$t.foldl(i=>o=>t(o)(i))(e),r=(i=>o=>{let u=i,s=o,a=!0,c;for(;a;){const f=u,d=s;if(d.tag==="Nil"){a=!1,c=f;continue}if(d.tag==="Cons"){u=Ot("Cons",d._1,f),s=d._2;continue}g()}return c})(qt);return i=>n(r(i))},foldl:t=>e=>n=>{let r=e,i=n,o=!0,u;for(;o;){const s=r,a=i;if(a.tag==="Nil"){o=!1,u=s;continue}if(a.tag==="Cons"){r=t(s)(a._1),i=a._2;continue}g()}return u},foldMap:t=>{const e=t.mempty;return n=>$t.foldl(r=>{const i=t.Semigroup0().append(r);return o=>i(n(o))})(e)}},dd=function(t){return function(e){return function(n){return function(r){return function(i){return function(o){for(var u=[],s=o;;){var a=i(s);u.push(n(a));var c=r(a);if(t(c))return u;s=e(c)}}}}}}},ld=t=>{if(t.tag==="Just")return t._1;g()},hd={unfoldr1:dd(Ca)(ld)(Yi)($i)},pd=function(t){return function(e){return function(n){return function(r){return function(i){return function(o){for(var u=[],s=o;;){var a=i(s);if(t(a))return u;var c=e(a);u.push(n(c)),s=r(c)}}}}}}},md=t=>{if(t.tag==="Just")return t._1;g()},qe={unfoldr:pd(Ca)(md)(Yi)($i),Unfoldable10:()=>hd},Wt=(t,e,n,r,i,o,u)=>({tag:t,_1:e,_2:n,_3:r,_4:i,_5:o,_6:u}),$e=(t,e,n,r)=>({tag:t,_1:e,_2:n,_3:r}),ji=(t,e,n)=>({tag:"Split",_1:t,_2:e,_3:n}),Ya=(t,e,n)=>({tag:"SplitLast",_1:t,_2:e,_3:n}),Q=Wt("Leaf"),ln=$e("IterLeaf"),se=(t,e,n,r)=>{if(n.tag==="Leaf"){if(r.tag==="Leaf")return Wt("Node",1,1,t,e,n,r);if(r.tag==="Node")return Wt("Node",1+r._1|0,1+r._2|0,t,e,n,r);g()}if(n.tag==="Node"){if(r.tag==="Leaf")return Wt("Node",1+n._1|0,1+n._2|0,t,e,n,r);if(r.tag==="Node")return Wt("Node",n._1>r._1?1+n._1|0:1+r._1|0,(1+n._2|0)+r._2|0,t,e,n,r)}g()},ze=(t,e,n,r)=>{if(n.tag==="Leaf")return r.tag==="Leaf"?Wt("Node",1,1,t,e,Q,Q):r.tag==="Node"&&r._1>1?r._5.tag==="Node"&&(()=>{if(r._6.tag==="Leaf")return r._5._1>0;if(r._6.tag==="Node")return r._5._1>r._6._1;g()})()?se(r._5._3,r._5._4,se(t,e,n,r._5._5),se(r._3,r._4,r._5._6,r._6)):se(r._3,r._4,se(t,e,n,r._5),r._6):se(t,e,n,r);if(n.tag==="Node")return r.tag==="Node"?r._1>(n._1+1|0)?r._5.tag==="Node"&&(()=>{if(r._6.tag==="Leaf")return r._5._1>0;if(r._6.tag==="Node")return r._5._1>r._6._1;g()})()?se(r._5._3,r._5._4,se(t,e,n,r._5._5),se(r._3,r._4,r._5._6,r._6)):se(r._3,r._4,se(t,e,n,r._5),r._6):n._1>(r._1+1|0)?n._6.tag==="Node"&&(()=>{if(n._5.tag==="Leaf")return 0<=n._6._1;if(n._5.tag==="Node")return n._5._1<=n._6._1;g()})()?se(n._6._3,n._6._4,se(n._3,n._4,n._5,n._6._5),se(t,e,n._6._6,r)):se(n._3,n._4,n._5,se(t,e,n._6,r)):se(t,e,n,r):r.tag==="Leaf"&&n._1>1?n._6.tag==="Node"&&(()=>{if(n._5.tag==="Leaf")return 0<=n._6._1;if(n._5.tag==="Node")return n._5._1<=n._6._1;g()})()?se(n._6._3,n._6._4,se(n._3,n._4,n._5,n._6._5),se(t,e,n._6._6,r)):se(n._3,n._4,n._5,se(t,e,n._6,r)):se(t,e,n,r);g()},Jr=(t,e,n)=>{if(n.tag==="Leaf")return ji(T,Q,Q);if(n.tag==="Node"){const r=t(e)(n._3);if(r==="LT"){const i=Jr(t,e,n._5);return ji(i._1,i._2,ze(n._3,n._4,i._3,n._6))}if(r==="GT"){const i=Jr(t,e,n._6);return ji(i._1,ze(n._3,n._4,n._5,i._2),i._3)}if(r==="EQ")return ji(w("Just",n._4),n._5,n._6)}g()},Va=(t,e,n,r)=>{if(r.tag==="Leaf")return Ya(t,e,n);if(r.tag==="Node"){const i=Va(r._3,r._4,r._5,r._6);return Ya(i._1,i._2,ze(t,e,n,i._3))}g()},ei=(t,e)=>{if(t.tag==="Leaf")return e;if(t.tag==="Node"){const n=Va(t._3,t._4,t._5,t._6);return ze(n._1,n._2,n._3,e)}g()},Gn=(t,e,n)=>{if(e.tag==="Leaf")return Q;if(n.tag==="Leaf")return e;if(n.tag==="Node"){const r=Jr(t,n._3,e);return ei(Gn(t,r._2,n._5),Gn(t,r._3,n._6))}g()},Zi=(t,e,n,r)=>{if(n.tag==="Leaf"||r.tag==="Leaf")return Q;if(r.tag==="Node"){const i=Jr(t,r._3,n),o=Zi(t,e,i._2,r._5),u=Zi(t,e,i._3,r._6);if(i._1.tag==="Just")return ze(r._3,e(i._1._1)(r._4),o,u);if(i._1.tag==="Nothing")return ei(o,u)}g()},Ge=(t,e,n,r)=>{if(n.tag==="Leaf")return r;if(r.tag==="Leaf")return n;if(r.tag==="Node"){const i=Jr(t,r._3,n),o=Ge(t,e,i._2,r._5),u=Ge(t,e,i._3,r._6);if(i._1.tag==="Just")return ze(r._3,e(i._1._1)(r._4),o,u);if(i._1.tag==="Nothing")return ze(r._3,r._4,o,u)}g()},yd=t=>e=>{const n=r=>{if(r.tag==="Leaf")return Q;if(r.tag==="Node"){const i=e(r._3)(r._4);if(i.tag==="Just")return ze(r._3,i._1,n(r._5),n(r._6));if(i.tag==="Nothing")return ei(n(r._5),n(r._6))}g()};return n},hn=(t=>e=>n=>{let r=n,i=!0,o;for(;i;){const u=r;if(u.tag==="IterLeaf"){i=!1,o=e();continue}if(u.tag==="IterEmit"){i=!1,o=t(u._1,u._2,u._3);continue}if(u.tag==="IterNode"){r=(s=>a=>{let c=s,f=a,d=!0,l;for(;d;){const _=c,h=f;if(h.tag==="Leaf"){d=!1,l=_;continue}if(h.tag==="Node"){if(h._6.tag==="Leaf"){c=$e("IterEmit",h._3,h._4,_),f=h._5;continue}c=$e("IterEmit",h._3,h._4,$e("IterNode",h._6,_)),f=h._5;continue}g()}return l})(u._2)(u._1);continue}g()}return o})((t,e,n)=>w("Just",b(b(t,e),n)))(t=>T),vt=t=>e=>n=>r=>{const i=o=>{if(o.tag==="Leaf")return Wt("Node",1,1,n,r,Q,Q);if(o.tag==="Node"){const u=t.compare(n)(o._3);if(u==="LT")return ze(o._3,o._4,i(o._5),o._6);if(u==="GT")return ze(o._3,o._4,o._5,i(o._6));if(u==="EQ")return Wt("Node",o._1,o._2,n,e(o._4)(r),o._5,o._6)}g()};return i},j=t=>e=>n=>{const r=i=>{if(i.tag==="Leaf")return Wt("Node",1,1,e,n,Q,Q);if(i.tag==="Node"){const o=t.compare(e)(i._3);if(o==="LT")return ze(i._3,i._4,r(i._5),i._6);if(o==="GT")return ze(i._3,i._4,i._5,r(i._6));if(o==="EQ")return Wt("Node",i._1,i._2,e,n,i._5,i._6)}g()};return r},Kt=t=>e=>e.foldl(n=>r=>j(t)(r._1)(r._2)(n))(Q),ni=t=>e=>{const n=r=>{if(r.tag==="Leaf")return Q;if(r.tag==="Node"){const i=t.compare(e)(r._3);if(i==="LT")return ze(r._3,r._4,n(r._5),r._6);if(i==="GT")return ze(r._3,r._4,r._5,n(r._6));if(i==="EQ")return ei(r._5,r._6)}g()};return n},Xa=t=>{const e=t.compare;return n=>r=>i=>{const o=Jr(e,r,i),u=n(o._1);if(u.tag==="Nothing")return ei(o._2,o._3);if(u.tag==="Just")return ze(r,u._1,o._2,o._3);g()}},oe=function(t){return function(e){return t+e|0}},Tr=function(t){return function(e){return t+e}},Yn=function(t){return function(e){if(e===0)return 0;var n=Math.abs(e);return(t%n+n)%n}},xd=function(t){return function(e){return t+e}},te=function(t){return function(e){return t.length===0?e:e.length===0?t:t.concat(e)}},Nd={append:xd},Jd={append:te},Td={mempty:"",Semigroup0:()=>Nd},vd={mempty:[],Semigroup0:()=>Jd},wd=null;function Ua(t,e,n){return t==null?e:n(t)}function Jw(t){return t}function bu(t){return function(e){return function(n){return t.apply(n,[e])}}}const bd=bu(Number.prototype.toPrecision),Ld=bu(Number.prototype.toFixed),kd=bu(Number.prototype.toExponential),ri=(t,e)=>({tag:t,_1:e}),ii=t=>e=>n=>{const r=it.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=it.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},oi=t=>{if(t.tag==="Precision")return bd(t._1);if(t.tag==="Fixed")return Ld(t._1);if(t.tag==="Exponential")return kd(t._1);g()},ja=function(t){return function(){console.log(t)}};function Ed(){return Date.now()}function Gd(t){return function(){return t.getContext("2d")}}function Cd(t){return function(){return t.width}}function Sd(t){return function(){return t.height}}function Dd(t){return function(e){return function(){t.width=e}}}function Pd(t){return function(e){return function(){t.height=e}}}function Lu(t){return function(e){return function(){t.lineWidth=e}}}function Id(t){return function(e){return function(){t.fillStyle=e}}}function Qd(t){return function(e){return function(){t.strokeStyle=e}}}function ku(t){return function(e){return function(){t.lineCap=e}}}function Eu(t){return function(e){return function(){t.lineJoin=e}}}function Fd(t){return function(e){return function(){t.globalCompositeOperation=e}}}function Ad(t){return function(e){return function(){t.globalAlpha=e}}}function Za(t){return function(){t.beginPath()}}function Gu(t){return function(){t.stroke()}}function Cu(t){return function(){t.fill()}}function Md(t){return function(){t.clip()}}function ui(t){return function(e){return function(n){return function(){t.lineTo(e,n)}}}}function Ka(t){return function(e){return function(n){return function(){t.moveTo(e,n)}}}}function tc(t){return function(){t.closePath()}}function Bd(t){return function(e){return function(){t.fillRect(e.x,e.y,e.width,e.height)}}}function zd(t){return function(e){return function(){t.clearRect(e.x,e.y,e.width,e.height)}}}function Ki(t){return function(e){return function(){t.scale(e.scaleX,e.scaleY)}}}function Su(t){return function(e){return function(){t.translate(e.translateX,e.translateY)}}}function Rd(t){return function(e){return function(){t.transform(e.a,e.b,e.c,e.d,e.e,e.f)}}}function Wd(t){return function(e){return function(){t.textAlign=e}}}function Hd(t){return function(e){return function(){t.textBaseline=e}}}function Od(t){return function(e){return function(){t.font=e}}}function qd(t){return function(e){return function(n){return function(r){return function(){t.fillText(e,n,r)}}}}}function sr(t){return function(){t.save()}}function ar(t){return function(){t.restore()}}function si(t){return function(e){return function(){t.quadraticCurveTo(e.cpx,e.cpy,e.x,e.y)}}}function $d(t){return function(e){return function(){t.bezierCurveTo(e.cp1x,e.cp1y,e.cp2x,e.cp2y,e.x,e.y)}}}const ec=t=>t,Du=t=>t,Pu=t=>t,Iu=t=>t,to=t=>t,Yd=to("BaselineTop"),Vd=to("BaselineMiddle"),Xd=to("BaselineAlphabetic"),Ud=to("BaselineBottom"),jd=Iu("AlignLeft"),Zd=Iu("AlignRight"),Kd=Iu("AlignCenter"),Qu=Pu("BevelJoin"),eo=Pu("RoundJoin"),Fu=Pu("MiterJoin"),Au=Du("Round"),Mu=Du("Square"),Bu=Du("Butt"),tl=ec("SourceOver"),el=ec("Difference"),nl=t=>e=>Hd(t)((()=>{if(e==="BaselineTop")return"top";if(e==="BaselineHanging")return"hanging";if(e==="BaselineMiddle")return"middle";if(e==="BaselineAlphabetic")return"alphabetic";if(e==="BaselineIdeographic")return"ideographic";if(e==="BaselineBottom")return"bottom";g()})()),rl=t=>e=>Wd(t)((()=>{if(e==="AlignLeft")return"left";if(e==="AlignRight")return"right";if(e==="AlignCenter")return"center";if(e==="AlignStart")return"start";if(e==="AlignEnd")return"end";g()})()),no=t=>e=>{if(e==="BevelJoin")return Eu(t)("bevel");if(e==="RoundJoin")return Eu(t)("round");if(e==="MiterJoin")return Eu(t)("miter");g()},zu=t=>e=>{if(e==="Round")return ku(t)("round");if(e==="Square")return ku(t)("square");if(e==="Butt")return ku(t)("butt");g()},nc=t=>e=>Fd(t)((()=>{if(e==="SourceOver")return"source-over";if(e==="SourceIn")return"source-in";if(e==="SourceOut")return"source-out";if(e==="SourceAtop")return"source-atop";if(e==="DestinationOver")return"destination-over";if(e==="DestinationIn")return"destination-in";if(e==="DestinationOut")return"destination-out";if(e==="DestinationAtop")return"destination-atop";if(e==="Lighter")return"lighter";if(e==="Copy")return"copy";if(e==="Xor")return"xor";if(e==="Multiply")return"multiply";if(e==="Screen")return"screen";if(e==="Overlay")return"overlay";if(e==="Darken")return"darken";if(e==="Lighten")return"lighten";if(e==="ColorDodge")return"color-dodge";if(e==="ColorBurn")return"color-burn";if(e==="HardLight")return"hard-light";if(e==="SoftLight")return"soft-light";if(e==="Difference")return"difference";if(e==="Exclusion")return"exclusion";if(e==="Hue")return"hue";if(e==="Saturation")return"saturation";if(e==="Color")return"color";if(e==="Luminosity")return"luminosity";g()})()),Re={foldr:t=>e=>{const n=$t.foldr(t)(e);return r=>n((()=>{const i=(o,u)=>{if(o.tag==="Leaf")return u;if(o.tag==="Node")return i(o._5,Ot("Cons",o._3,i(o._6,u)));g()};return i(r,qt)})())}},il=t=>{const e={append:(()=>{const n=t.compare;return r=>i=>Ge(n,Le,r,i)})()};return{mempty:Q,Semigroup0:()=>e}},ai=function(t){return function(e){if(t>=0&&t<e.length)return e.charAt(t);throw new Error("Data.String.Unsafe.charAt: Invalid index.")}},cr=function(t){return t.join("")},Vn=function(t){return t.split("")},ro=function(t){return t},Xn=function(t){return t.length},rc=function(t){return function(e){return e.substr(0,t)}},ci=function(t){return function(e){return e.substring(t)}},ol=function(t){return function(e){return{before:e.substring(0,t),after:e.substring(t)}}},ul=t=>e=>{const n=ol(Xn(t))(e);return n.before===t?w("Just",n.after):T},sl=function(t){var e=null;return function(){return t===void 0||(e=t(),t=void 0),e}},al=function(t){return t()},cl=t=>e=>n=>{try{var r=BigInt(n);return t(r)}catch{return e}},gl=t=>e=>n=>{try{var r=BigInt(n);return t(r)}catch{return e}},gr=t=>BigInt(t),fl=t=>Number(t),io=t=>e=>t+e,oo=t=>e=>t*e,Ru=t=>e=>t-e,ic=0n,uo=1n,oc=t=>e=>t^e,gi=t=>e=>t&e,Wu=t=>e=>t<<e,Hu=t=>e=>t>>e,_l=t=>e=>t==e,dl=t=>e=>t===e?0:t>e?1:-1,ll={eq:_l},uc={compare:t=>e=>{const n=dl(t)(e);return n===1?xe:n===0?Se:ye},Eq0:()=>ll},hl=cl(Yt)(T),pl=gl(Yt)(T),sc=(()=>{const t={eq:e=>n=>e._1===n._1&&e._2===n._2};return{compare:e=>n=>{const r=st.compare(e._1)(n._1);return r==="LT"?ye:r==="GT"?xe:st.compare(e._2)(n._2)},Eq0:()=>t}})(),ml=t=>e=>qn(t._1-e._1)+qn(t._2-e._2),fr=t=>t,so=t=>t,le=so("North"),he=so("South"),pn=so("East"),_r=so("West"),Un=fr("Rectangle"),yl=fr("Cylinder"),xl=fr("Parallelogram"),Nl=fr("Diamond"),Jl=fr("Ellipse"),Tl=fr("Document"),vl=fr("Cloud"),ac=t=>t,cc=J(Tr)(0),wl=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},mn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},fi=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},gc=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},vr=t=>e=>{const n=Je(u=>s=>({a:u,b:s,len:(()=>{const a=s.y-u.y,c=s.x-u.x;return Ee(c*c+a*a)})()}),t,bt(1,t.length,t)),r=cc(H(u=>u.len)(n)),i=wl(0)(r)(e*r),o=u=>s=>a=>{let c=u,f=s,d=a,l=!0,_;for(;l;){const h=c,m=f,p=d,y=Ft(x=>T,x=>N=>w("Just",{head:x,tail:N}),h);if(y.tag==="Nothing"){const x=t.length-1|0;if(x>=0&&x<t.length){l=!1,_=t[x];continue}l=!1,_=p;continue}if(y.tag==="Just"){if(m<=y._1.head.len){const x=y._1.head.len<=0?0:m/y._1.head.len;l=!1,_={x:y._1.head.a.x+(y._1.head.b.x-y._1.head.a.x)*x,y:y._1.head.a.y+(y._1.head.b.y-y._1.head.a.y)*x};continue}c=y._1.tail,f=m-y._1.head.len,d=p;continue}g()}return _};return 0<t.length?w("Just",o(n)(i)(t[0])):T},bl=t=>e=>{const n=mn(1)(t.w),r=mn(1)(t.h),i=mn(1)(e.w-8),o=mn(1)(e.h-8),u=fi(i/n)(o/r);return{scale:u,tx:e.x+4+(i-n*u)/2-t.x*u,ty:e.y+4+(o-r*u)/2-t.y*u}},_i=t=>cc(Je(e=>n=>{const r=n.y-e.y,i=n.x-e.x;return Ee(i*i+r*r)},t,bt(1,t.length,t))),Ll=t=>e=>n=>r=>i=>{const o=0<t.length?w("Just",t[0]):T,u=(()=>{if(o.tag==="Nothing")return e;if(o.tag==="Just")return o._1;g()})(),s=t.length-1|0,a=s>=0&&s<t.length?w("Just",t[s]):T,c=(()=>{if(a.tag==="Nothing")return n;if(a.tag==="Just")return a._1;g()})(),f=mn(.05)(1-i.pre-i.post),d=r<i.pre?0:r>1-i.post?1:(r-i.pre)/f,l=c.x-n.x,_=2*(()=>{const v=c.y-n.y;return(l<0?-l:l)+(v<0?-v:v)})(),h=u.x-e.x,m=2*(()=>{const v=u.y-e.y;return(h<0?-h:h)+(v<0?-v:v)})(),p=m+_i(t)+_,y=p<=1e-4?1:1-_/p,x=p<=1e-4?0:m/p;if(d<=x){const v=x<=1e-4?1:d/x;return{x:e.x+(u.x-e.x)*v,y:e.y+(u.y-e.y)*v}}if(d>=y){const v=y>=1?0:(d-y)/(1-y);return{x:c.x+(n.x-c.x)*v,y:c.y+(n.y-c.y)*v}}const N=vr(t)((d-x)/mn(1e-4)(y-x));if(N.tag==="Nothing")return u;if(N.tag==="Just")return N._1;g()},kl=t=>{const e=Ft(n=>T,n=>r=>w("Just",{head:n,tail:r}),(()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return Tt(kt($t.foldr,n(t.nodes,qt)))(r=>[{x:r.x,y:r.y},{x:r.x+r.w,y:r.y+r.h}])})());if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=J(r=>i=>({minX:fi(r.minX)(i.x),minY:fi(r.minY)(i.y),maxX:mn(r.maxX)(i.x),maxY:mn(r.maxY)(i.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},Ou={scale:1,tx:0,ty:0},Ye=t=>{const e=Ft(n=>T,n=>r=>w("Just",{head:n,tail:r}),[...(()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return Tt(kt($t.foldr,n(t.nodes,qt)))(r=>[{x:r.x,y:r.y},{x:r.x+r.w,y:r.y+r.h}])})(),...Ae((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return kt($t.foldr,n(t.edges,qt))})()),...Ae((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return kt($t.foldr,n(t.chipExtras,qt))})())]);if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=J(r=>i=>({minX:fi(r.minX)(i.x),minY:fi(r.minY)(i.y),maxX:mn(r.maxX)(i.x),maxY:mn(r.maxY)(i.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},El=t=>e=>(n=>r=>i=>{let o=n,u=r,s=i,a=!0,c;for(;a;){const f=o,d=u,l=s,_=Ft(h=>T,h=>m=>w("Just",{head:h,tail:m}),d);if(_.tag==="Nothing"){a=!1,c=l;continue}if(_.tag==="Just"){const h=gc(_._1.head)(f.interiors);if(h.tag==="Nothing"){a=!1,c=l;continue}if(h.tag==="Just"){o=h._1,u=_._1.tail,s=(()=>{const m=bl(Ye(h._1.layout))((()=>{const p=gc(_._1.head)(f.layout.nodes);if(p.tag==="Nothing")return{x:0,y:0,w:1,h:1,label:"",shape:Un};if(p.tag==="Just")return p._1;g()})());return{scale:l.scale*m.scale,tx:l.scale*m.tx+l.tx,ty:l.scale*m.ty+l.ty}})();continue}}g()}return c})(t)(e)(Ou),fc=t=>t,_c=(t,e)=>({tag:t,_1:e}),ao=(t,e)=>({tag:t,_1:e}),qu=(t,e)=>({tag:t,_1:e}),Gl=qu("First"),Cl=fc("Forward"),Sl=fc("Backward"),Dl=ao("ExitNode"),dc=Kt(C)(Bt),Pl=t=>Kr(e=>n=>({nodes:Ge(C.compare,Le,e.nodes,n.nodes),edges:Ge(C.compare,Le,e.edges,n.edges)}))({nodes:Q,edges:Q})(t.keyframes),Il=t=>e=>({entering:{nodes:Gn(C.compare,e.nodes,t.nodes),edges:Gn(C.compare,e.edges,t.edges)},leaving:{nodes:Gn(C.compare,t.nodes,e.nodes),edges:Gn(C.compare,t.edges,e.edges)},surviving:{nodes:Zi(C.compare,Le,t.nodes,e.nodes),edges:Zi(C.compare,Le,t.edges,e.edges)}}),co=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},wr=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},di=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},$u=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Ql=J(t=>e=>j(C)(e)()(t))(Q),Fl=J(t=>e=>j(C)(e)()(t))(Q),Al=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),lc=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},hc=Kt(C)(Bt),li=t=>{const e=Ft(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=J(r=>i=>({minX:co(r.minX)(i.x),minY:co(r.minY)(i.y),maxX:wr(r.maxX)(i.x),maxY:wr(r.maxY)(i.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},Ml=t=>{const e=Ft(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return T;if(e.tag==="Just")return w("Just",li(t));g()},Bl=t=>e=>n=>Ql(Tt(kt(Re.foldr,n))(r=>{const i=di(r)(t);if(i.tag==="Just")return ct(o=>!$u(o)(e),[i._1.source,i._1.target]);if(i.tag==="Nothing")return[];g()})),zl=t=>t.kind.tag==="SendToken"?w("Just",b(t.kind._1.edge,{source:t.kind._1.from,target:t.kind._1.to})):T,Rl=t=>t.tag==="DataFlow"?xt(zl)(t._1.events):[],Wl=t=>e=>Fl(xt(n=>$u(n._2.source)(e)||$u(n._2.target)(e)?w("Just",n._1):T)(Al(t))),Hl=t=>{const e=t.length-1|0;return e>=0&&e<t.length?0<t.length?t[0].x===t[e].x&&t[0].y===t[e].y?w("Just",li([t[0]])):w("Just",li([t[0],t[e]])):T:0<t.length?w("Just",li([t[0]])):T},go=t=>{const e=Ft(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{x:0,y:0,w:0,h:0};if(e.tag==="Just"){const n=J(r=>i=>({minX:co(r.minX)(i.x),minY:co(r.minY)(i.y),maxX:wr(r.maxX)(i.x+i.w),maxY:wr(r.maxY)(i.y+i.h)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x+e._1.head.w,maxY:e._1.head.y+e._1.head.h})(e._1.tail);return{x:n.minX,y:n.minY,w:n.maxX-n.minX,h:n.maxY-n.minY}}g()},pc=t=>e=>n=>{if(n.tag==="Leaf")return Ye(t);const r=Wl(e)(n),i=[...xt(o=>{const u=lc(o)(t.nodes);return u.tag==="Just"?w("Just",{x:u._1.x,y:u._1.y,w:u._1.w,h:u._1.h}):T})(kt(Re.foldr,Ge(C.compare,Le,n,Bl(e)(n)(r)))),...xt(o=>{const u=di(o)(t.edges);return u.tag==="Just"?w("Just",li(u._1)):T})(kt(Re.foldr,r)),...xt(o=>{const u=di(o)(t.chipExtras);if(u.tag==="Just")return Ml(u._1);if(u.tag==="Nothing")return T;g()})(kt(Re.foldr,r))];return i.length===0?Ye(t):go(i)},hi=t=>e=>n=>{const r=[...xt(i=>i)([(()=>{const i=di(n)(t.chipExtras);if(i.tag==="Just")return Hl(i._1);if(i.tag==="Nothing")return T;g()})()]),...(()=>{const i=di(n)(e);if(i.tag==="Just")return xt(o=>{const u=lc(o)(t.nodes);return u.tag==="Just"?w("Just",{x:u._1.x,y:u._1.y,w:u._1.w,h:u._1.h}):T})([i._1.source,i._1.target]);if(i.tag==="Nothing")return[];g()})()];return r.length===0?pc(t)(e)(Q):go(r)},Yu=t=>e=>{const n=Ye(t),r=n.w/wr(1e-4)(e.zoom),i=n.h/wr(1e-4)(e.zoom);return{x:e.center.x-r/2,y:e.center.y-i/2,w:r,h:i}},Ol=t=>Ge(C.compare,Le,hc(H(e=>b(e.id,{source:e.from.node,target:e.to.node}))(t.graph.edges)),hc(Tt(t.scenes)(Rl))),Vu=t=>t,ql=t=>t,dr=Vu("Linear"),$l=Vu("EaseInOutQuad"),Yl=Vu("SpringBouncy"),pi=t=>e=>n=>{const r=Ee(1-e*e),i=t*r;return 1-Ui(-e*t*n)*(Ke(i*n)+e/r*Oe(i*n))},Vl=t=>{const e=st.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=st.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},Xu=t=>e=>(()=>{if(t==="Linear")return ql;if(t==="EaseInQuad")return n=>n*n;if(t==="EaseOutQuad")return n=>1-(1-n)*(1-n);if(t==="EaseInOutQuad")return n=>n<.5?2*n*n:1-2*(1-n)*(1-n);if(t==="EaseInCubic")return n=>n*n*n;if(t==="EaseOutCubic")return n=>1-(1-n)*(1-n)*(1-n);if(t==="EaseInOutCubic")return n=>n<.5?4*n*n*n:1-(-2*n+2)*(-2*n+2)*(-2*n+2)/2;if(t==="EaseOutExpo")return n=>n>=1?1:1-wu(2)(-10*n);if(t==="Spring")return n=>1-(1+6*n)*Ui(-6*n);if(t==="SpringBouncy")return pi(6)(.7);g()})()(Vl(e)),mc=t=>t,Uu=t=>t,fo=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},mi=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},yc=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Xl=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Ul=Uu("Hold"),jl=Uu("Gap"),Zl=Uu("Move"),yi=mc("LinearLerp"),xc=mc("LogLerp"),Kl=t=>e=>n=>{const r=n.center.y-e.center.y,i=n.center.x-e.center.x,o=Ee(i*i+r*r),u=n.zoom-e.zoom,s=u<0?-u:u;return fo(t.minTransition)(t.maxTransition)(mi(t.panSpeed<=0?t.minTransition:o/t.panSpeed)(t.zoomSpeed<=0?t.minTransition:s/t.zoomSpeed))},th=J(t=>e=>{const n=t.length-1|0;return n>=0&&n<t.length&&t[n]===e?t:zt(t)(e)})([]),Nc=t=>e=>{const n={x:0,y:0},r=0<t.length?t[0].pos:n,i=Ma(Yt,T,o=>o.t<=e,t);if(i.tag==="Nothing")return r;if(i.tag==="Just"){const o=i._1+1|0;if(o>=0&&o<t.length){if(i._1>=0&&i._1<t.length){const u=fo(0)(1)(t[o].t<=t[i._1].t?0:(e-t[i._1].t)/(t[o].t-t[i._1].t));return{x:t[i._1].pos.x+(t[o].pos.x-t[i._1].pos.x)*u,y:t[i._1].pos.y+(t[o].pos.y-t[i._1].pos.y)*u}}return n}return i._1>=0&&i._1<t.length?t[i._1].pos:n}g()},ju=t=>e=>({center:{x:e.center.x*t.scale+t.tx,y:e.center.y*t.scale+t.ty},zoom:e.zoom/mi(1e-6)(t.scale)}),eh=t=>e=>n=>({center:{x:t.center.x+(e.center.x-t.center.x)*n,y:t.center.y+(e.center.y-t.center.y)*n},zoom:Ui((()=>{const r=qa(mi(1e-6)(t.zoom));return r+(qa(mi(1e-6)(e.zoom))-r)*n})())}),nh=t=>e=>n=>{const r=Xu(n.easing)(fo(0)(1)(n.endT<=n.startT?1:(e-n.startT)/(n.endT-n.startT)));if(n.interp==="LinearLerp")return{center:{x:n.fromCam.center.x+(n.toCam.center.x-n.fromCam.center.x)*r,y:n.fromCam.center.y+(n.toCam.center.y-n.fromCam.center.y)*r},zoom:n.fromCam.zoom+(n.toCam.zoom-n.fromCam.zoom)*r};if(n.interp==="LogLerp")return eh(n.fromCam)(n.toCam)(r);g()},rh=t=>e=>n=>r=>{const i=(u,s)=>yc(Kl(t)(u.toCam)(s.toCam))(u.endT-u.startT),o=J(u=>s=>{if(u.pending.tag==="Nothing")return{acc:u.acc,pending:w("Just",s)};if(u.pending.tag==="Just")return!(s.fromCam.zoom===s.toCam.zoom&&s.fromCam.center.x===s.toCam.center.x&&s.fromCam.center.y===s.toCam.center.y)||(()=>{const a=u.pending._1.toCam.center.x-s.toCam.center.x;return(a<0?-a<8:a<8)&&(()=>{const c=u.pending._1.toCam.center.y-s.toCam.center.y;return(c<0?-c<8:c<8)&&(()=>{const f=u.pending._1.toCam.zoom-s.toCam.zoom;return f<0?-f<.08:f<.08})()})()})()||i(u.pending._1,s)<=0?{acc:zt(u.acc)(u.pending._1),pending:w("Just",s)}:{acc:zt(zt(u.acc)({...u.pending._1,endT:s.startT-i(u.pending._1,s)}))({startT:s.startT-i(u.pending._1,s),endT:s.startT,fromCam:u.pending._1.toCam,toCam:s.toCam,easing:s.easing,interp:yi}),pending:w("Just",s)};g()})({acc:[],pending:T})(r);if(o.pending.tag==="Nothing")return o.acc;if(o.pending.tag==="Just")return zt(o.acc)(o.pending._1);g()},ih=t=>e=>{const n=r=>{const i=Ma(Yt,T,o=>o.kind==="Hold"||o.kind==="Move",r<1?[]:bt(0,r,e));if(i.tag==="Just")return i._1>=0&&i._1<e.length?w("Just",e[i._1].toCam):T;if(i.tag==="Nothing")return T;g()};return Qt(r=>i=>{if(i.kind==="Hold")return{startT:i.startT,endT:i.endT,fromCam:i.fromCam,toCam:i.toCam,easing:i.easing,interp:yi};if(i.kind==="Move")return{startT:i.startT,endT:i.endT,fromCam:i.fromCam,toCam:i.toCam,easing:dr,interp:yi};if(i.kind==="Gap")return{startT:i.startT,endT:i.endT,fromCam:(()=>{const o=n(r);if(o.tag==="Nothing")return t;if(o.tag==="Just")return o._1;g()})(),toCam:(()=>{const o=n(r),u=(()=>{if(o.tag==="Nothing")return t;if(o.tag==="Just")return o._1;g()})(),s=r+1|0,a=ir(Yt,T,c=>c.kind==="Hold"||c.kind==="Move",s<1?e:bt(s,e.length,e));if(a.tag==="Just"){const c=(r+1|0)+a._1|0;return c>=0&&c<e.length?e[c].fromCam:u}if(a.tag==="Nothing")return u;g()})(),easing:i.easing,interp:yi};g()})(e)},oh={padding:24,easing:dr,minZoom:.9,maxZoom:2.5,tokenZoomFloor:0,panSpeed:1500,zoomSpeed:4,minTransition:.15,maxTransition:.6,cameraDecay:16},Zu=t=>e=>n=>{const r=e.w+n*2,i=e.h+n*2,o=Ye(t);return r<=0||i<=0||o.w<=0||o.h<=0?1:yc(o.w/r)(o.h/i)},uh=J(t=>e=>{const n=t.length-1|0,r=n>=0&&n<t.length?w("Just",t[n]):T;return r.tag==="Just"&&r._1.fromCam.zoom===r._1.toCam.zoom&&r._1.fromCam.center.x===r._1.toCam.center.x&&r._1.fromCam.center.y===r._1.toCam.center.y&&e.fromCam.zoom===e.toCam.zoom&&e.fromCam.center.x===e.toCam.center.x&&e.fromCam.center.y===e.toCam.center.y&&(()=>{const i=r._1.toCam.center.x-e.toCam.center.x;return(i<0?-i<8:i<8)&&(()=>{const o=r._1.toCam.center.y-e.toCam.center.y;return(o<0?-o<8:o<8)&&(()=>{const u=r._1.toCam.zoom-e.toCam.zoom;return u<0?-u<.08:u<.08})()})()})()?zt((()=>{const i=t.length-1|0;return i<1?[]:bt(0,i,t)})())({...r._1,endT:e.endT}):zt(t)(e)})([]),xi=t=>e=>n=>r=>({center:{x:n.x+n.w/2,y:n.y+n.h/2},zoom:mi(r)(fo(t.minZoom)(t.maxZoom)(Zu(e)(n)(t.padding)))}),sh=t=>e=>n=>r=>{const i=Lt(s=>a=>it.compare(a.priority)(s.priority)),o=xi(t)(e)(Ye(e))(0),u=ct(s=>s>=0&&s<=n,th(Lt(st.compare)([0,n,...Tt(r)(s=>[s.startT,s.endT]),...Tt(r)(s=>{if(s.pathFollow.tag==="Nothing")return[];if(s.pathFollow.tag==="Just")return H(a=>a.t)(s.pathFollow._1.samples);g()})])));return rh(t)(e)(o)(uh(ih(o)(xt(s=>{const a=(s._1+s._2)/2;if(s._2<=s._1)return T;const c=xt(d=>d.pathFollow)(i(ct(d=>d.startT<=a&&a<d.endT,r)));if(0<c.length)return w("Just",{kind:Zl,startT:s._1,endT:s._2,fromCam:{center:Nc(c[0].samples)(s._1),zoom:c[0].zoom},toCam:{center:Nc(c[0].samples)(s._2),zoom:c[0].zoom},easing:dr});const f=H(d=>d.bbox)(ct(d=>d.priority===J(Xl)(0)(H(l=>l.priority)(ct(l=>l.startT<=a&&a<l.endT,r))),ct(d=>d.startT<=a&&a<d.endT,r)));return f.length===0?w("Just",{kind:jl,startT:s._1,endT:s._2,fromCam:o,toCam:o,easing:t.easing}):w("Just",{kind:Ul,startT:s._1,endT:s._2,fromCam:xi(t)(e)(go(f))(Me(d=>d.priority>=1,ct(d=>d.startT<=a&&a<d.endT,r))?t.tokenZoomFloor:0),toCam:xi(t)(e)(go(f))(Me(d=>d.priority>=1,ct(d=>d.startT<=a&&a<d.endT,r))?t.tokenZoomFloor:0),easing:t.easing})})(Je(Hn,u,bt(1,u.length,u))))))},Jc=t=>e=>n=>r=>{const i=Zt(o=>r>=o.startT&&r<o.endT)(n);if(i.tag==="Just")return nh()(r)(i._1);if(i.tag==="Nothing"){const o=n.length-1|0;if(o>=0&&o<n.length&&r>=n[o].endT)return n[o].toCam;const u=xi(t)(e)(Ye(e))(0);return 0<n.length?n[0].fromCam:u}g()};function Cn(t){return t.charCodeAt(0)}function Tc(t){return String.fromCharCode(t)}const jn=function(t){return function(e){return function(n){return n.replace(new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),e)}}},_o=function(t){return function(e){return e.split(t)}},ah=function(t){return t.trim()},lo=function(t){return function(e){return e.join(t)}};var ch=typeof Array.from=="function",gh=typeof Symbol<"u"&&Symbol!=null&&typeof Symbol.iterator<"u"&&typeof String.prototype[Symbol.iterator]=="function",fh=typeof String.prototype.fromCodePoint=="function",_h=typeof String.prototype.codePointAt=="function";const dh=function(t){return _h?function(e){return e.codePointAt(0)}:t},lh=function(t){return fh?String.fromCodePoint:t},hh=function(t){return function(e){return gh?function(n){for(var r="",i=n[Symbol.iterator](),o=0;o<e;++o){var u=i.next();if(u.done)return r;r+=u.value}return r}:t(e)}},ph=function(t){return function(e){return ch?function(n){return Array.from(n,e)}:t}},ho=t=>{const e=Xn(t);if(e===0)return T;if(e===1)return w("Just",{head:Cn(ai(0)(t)),tail:""});const n=Cn(ai(1)(t)),r=Cn(ai(0)(t));return 55296<=r&&r<=56319&&56320<=n&&n<=57343?w("Just",{head:(((r-55296|0)*1024|0)+(n-56320|0)|0)+65536|0,tail:ci(2)(t)}):w("Just",{head:r,tail:ci(1)(t)})},mh=t=>{const e=ho(t);return e.tag==="Just"?w("Just",b(e._1.head,e._1.tail)):T},yh=t=>qe.unfoldr(mh)(t),vc=dh(t=>{const e=Cn(ai(0)(t));if(55296<=e&&e<=56319&&Xn(t)>1){const n=Cn(ai(1)(t));if(56320<=n&&n<=57343)return(((e-55296|0)*1024|0)+(n-56320|0)|0)+65536|0}return e}),po=ph(yh)(vc),Ku=t=>ro(t>=0&&t<=65535?Tc(t):t<0?"\0":"\uFFFF"),xh=lh(t=>t<=65535?Ku(t):Ku(En(t-65536|0,1024)+55296|0)+Ku(Yn(t-65536|0)(1024)+56320|0)),wc=t=>e=>{if(t<1)return"";const n=ho(e);return n.tag==="Just"?xh(n._1.head)+wc(t-1|0)(n._1.tail):e},me=hh(wc),Nh=t=>e=>e===""?T:w("Just",vc(e)),br=(t,e,n)=>({tag:t,_1:e,_2:n}),Jh=()=>({tag:"ExtendFromSource"}),Lr=(t,e)=>({tag:t,_1:e}),ts=t=>t,mo=(t,e)=>({tag:t,_1:e}),es=mo("NotYet"),bc=mo("Consumed"),Th=ts("FromSource"),Lc=ts("FromTarget"),kc=ts("FromBoth"),yo=Lr("Hidden"),vh=Lr("Visible"),ns=Jh(),xo=br("Retracted"),wh=br("Extended"),Ec=t=>t,rs=(t,e)=>({tag:t,_1:e}),kr=(t,e,n)=>({tag:t,_1:e,_2:n}),Gc=t=>t,lr=(t,e)=>({tag:t,_1:e}),Er=(t,e,n,r,i,o,u,s,a)=>({tag:t,_1:e,_2:n,_3:r,_4:i,_5:o,_6:u,_7:s,_8:a}),Ni=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},yn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Cc=Kt(C)(Bt),is=Tu(ti),Ji=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},No=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Ti=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Sc=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Dc=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Gr=(()=>{const t=qe.unfoldr(e=>{if(e.tag==="Nil")return T;if(e.tag==="Cons")return w("Just",b(e._1,e._2));g()});return e=>t((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._3,n(r._6,i)));g()};return n(e,qt)})())})(),bh=J(t=>e=>j(C)(e)()(t))(Q),os=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},us=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Lh=lr("NoKeyframes"),kh=t=>lr("DuplicateEventId",t),Eh=t=>lr("UnknownEvent",t),Pc=Gc("PlopIn"),Gh=Gc("PlopOut"),Ch=Ec("DiveIn"),Sh=Ec("DiveOut"),Dh=t=>e=>n=>r=>{const i=Ni(r.edge)(e.edges),o=(()=>{if(i.tag==="Nothing")return 0;if(i.tag==="Just")return _i(i._1);g()})(),u=yn(t.minTokenDuration)(yn(rt(J(s=>a=>s+po(a).length|0)(0)(r.labels))*t.tokenReadSecPerChar)(t.tokenSpeed<=0?0:o/t.tokenSpeed))+n.pre+n.post;return{duration:u,holdPre:u<=0?0:n.pre/u,holdPost:u<=0?0:n.post/u}},Ph=t=>e=>Cc(xt(n=>{if(n.kind.tag==="SendToken")return w("Just",b(n.id,{pre:(()=>{const r=n.when;return(()=>{const i=n.kind._1.from;return Me(o=>{if(o.kind.tag==="SendToken")return(r.tag==="First"?!1:r.tag==="After"&&r._1===o.id)&&o.kind._1.to===i;if(o.kind.tag==="FillNodeWithoutTransition")return!1;g()},e)})()?0:t.tokenHold})(),post:(()=>{const r=n.id;return(()=>{const i=n.kind._1.to;return Me(o=>{if(o.kind.tag==="SendToken")return(o.when.tag==="First"?!1:o.when.tag==="After"&&o.when._1===r)&&o.kind._1.from===i;if(o.kind.tag==="FillNodeWithoutTransition")return!1;g()},e)})()?0:t.tokenHold})()}));if(n.kind.tag==="FillNodeWithoutTransition")return T;g()})(e)),Ih=t=>{if(t.event.kind.tag==="SendToken")return w("Just",{startT:t.startT,endT:t.endT,target:Er("TokenWindow",t.event.id,t.event.kind._1.edge,t.event.kind._1.direction,t.event.kind._1.from,t.event.kind._1.to,t.event.kind._1.labels,t.holdPre,t.holdPost)});if(t.event.kind.tag==="FillNodeWithoutTransition")return w("Just",{startT:t.startT,endT:t.endT,target:Er("FillWindow",t.event.id,t.event.kind._1.node,t.event.kind._1.labels)});g()},Qh=t=>e=>n=>r=>{const i=Zt(o=>is(o.path)(e)&&(qn(o.endT-n)<1e-4||qn(o.startT-r)<1e-4))(t.segments);if(i.tag==="Just")return w("Just",i._1);if(i.tag==="Nothing")return Zt(o=>is(o.path)(e))(t.segments);g()},Fh=t=>e=>n=>xt(r=>{const i=xt(o=>Ti(o)(t.nodes))(kt(Re.foldr,(()=>{if(r.scene.tag==="Structural")return Ge(C.compare,Le,(()=>{const o=Ji(r.scene._1.from)(n);if(o.tag==="Nothing")return Q;if(o.tag==="Just")return o._1.nodes;g()})(),(()=>{const o=Ji(r.scene._1.to)(n);if(o.tag==="Nothing")return Q;if(o.tag==="Just")return o._1.nodes;g()})());if(r.scene.tag==="DataFlow"){const o=Ji(r.scene._1.keyframe)(n);if(o.tag==="Nothing")return Q;if(o.tag==="Just")return o._1.nodes;g()}if(r.scene.tag==="EnterNode"||r.scene.tag==="ExitNode")return Q;g()})()));return i.length===0?T:w("Just",{startT:r.startT,endT:r.endT,bbox:(()=>{const o=J(u=>s=>({minX:No(u.minX)(s.x),minY:No(u.minY)(s.y),maxX:yn(u.maxX)(s.x+s.w),maxY:yn(u.maxY)(s.y+s.h)}))(0<i.length?{minX:i[0].x,minY:i[0].y,maxX:i[0].x+i[0].w,maxY:i[0].y+i[0].h}:{minX:0,minY:0,maxX:0,maxY:0})(bt(1,i.length,i));return{x:o.minX,y:o.minY,w:o.maxX-o.minX,h:o.maxY-o.minY}})(),priority:0,pathFollow:T})}),Ah=t=>e=>n=>{const r=Ni(n)(t);if(r.tag==="Nothing")return Lc;if(r.tag==="Just"){const i=Sc(r._1.target)(e);return Sc(r._1.source)(e)?i?kc:Th:Lc}g()},Mh={pre:0,post:0},Bh=t=>e=>n=>r=>i=>{const o=Dc(i.event.id)(n),u=(()=>{if(o.tag==="Nothing")return Mh;if(o.tag==="Just")return o._1;g()})(),s=(()=>{if(i.event.when.tag==="First")return 0;if(i.event.when.tag==="At")return i.event.when._1;if(i.event.when.tag==="After"){const c=i.event.when._1,f=Zt(d=>d.event.id===c)(r);if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1.endT;g()}if(i.event.when.tag==="With"){const c=i.event.when._1,f=Zt(d=>d.event.id===c)(r);if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1.startT}g()})(),a=(()=>{if(i.event.kind.tag==="SendToken")return Dh(t)(e)(u)(i.event.kind._1);if(i.event.kind.tag==="FillNodeWithoutTransition")return{duration:t.plop,holdPre:0,holdPost:0};g()})();return zt(r)({startT:s,endT:s+a.duration,event:i.event,holdPre:a.holdPre,holdPost:a.holdPost})},Ic=t=>e=>n=>J(Bh(t)(e)(Ph(t)(n)))([])(Qt(r=>i=>({event:i}))(n)),zh=t=>e=>{const n=Ti(e)(t.interiors);if(n.tag==="Nothing")return t;if(n.tag==="Just")return n._1;g()},Rh=t=>e=>({...e,fromCam:ju(t)(e.fromCam),toCam:ju(t)(e.toCam)}),Wh=t=>{if(t.when.tag==="First")return[];if(t.when.tag==="At")return[];if(t.when.tag==="After")return[t.when._1];if(t.when.tag==="With")return[t.when._1];g()},Qc={id:"",nodes:Q,edges:Q},Hh=t=>e=>Il((()=>{const n=Ji(e.from)(t);if(n.tag==="Nothing")return Qc;if(n.tag==="Just")return n._1;g()})())((()=>{const n=Ji(e.to)(t);if(n.tag==="Nothing")return Qc;if(n.tag==="Just")return n._1;g()})()),Oh=t=>e=>{const n=Ti(e)(t.interiors);if(n.tag==="Nothing")return{layout:t.layout,interiors:Q};if(n.tag==="Just")return n._1;g()},ss=t=>e=>n=>r=>{const i=Ni(r)(n.edges);if(i.tag==="Just")return t<=0?e:yn(e)(_i(i._1)/t);if(i.tag==="Nothing")return e;g()},Fc=t=>e=>n=>r=>i=>{const o=t.plop,u=Hh(n)(i),s=H(_=>({startT:0,endT:0+ss(t.edgeSpeed)(t.minEdgeDuration)(e)(_),target:Er("EdgeWindow",_,rs("Extend",ns))}))(Gr(u.entering.edges)),a=H(_=>({startT:0,endT:o,target:Er("NodeWindow",_,Pc)}))(Gr(u.entering.nodes)),c=J(yn)(0)(H(_=>ss(t.edgeSpeed)(t.minEdgeDuration)(e)(_))(Gr(u.leaving.edges))),f=_=>Me(h=>{const m=Ni(h)(r);if(m.tag==="Just")return m._1.source===_||m._1.target===_;if(m.tag==="Nothing")return!1;g()},Gr(u.leaving.edges))?c:0,d=H(_=>({startT:f(_),endT:f(_)+t.plop,target:Er("NodeWindow",_,Gh)}))(Gr(u.leaving.nodes)),l=H(_=>({startT:0,endT:ss(t.edgeSpeed)(t.minEdgeDuration)(e)(_),target:Er("EdgeWindow",_,rs("Retract",Ah(r)(u.leaving.nodes)(_)))}))(Gr(u.leaving.edges));return{duration:(()=>{const _=Lt(st.compare)([...H(m=>m.endT)(l),...H(m=>m.endT)(d),...H(m=>m.endT)(a),...H(m=>m.endT)(s)]),h=_.length-1|0;return h>=0&&h<_.length?_[h]+t.gap:t.gap})(),windows:[...l,...d,...a,...s]}},qh=t=>e=>n=>r=>i=>o=>H((()=>{const u=i.startT;return s=>({...s,startT:s.startT+u,endT:s.endT+u})})())(Fc(t)(e)(n)(r)(o).windows),$h=t=>xt(e=>kt(Kr,e).length>1?w("Just",(()=>{const n=Ft(r=>T,r=>i=>w("Just",{head:r,tail:i}),kt(Kr,e));if(n.tag==="Just")return n._1.head;if(n.tag==="Nothing")return"";g()})()):T)(ud(ti)(Lt(C.compare)(t))),Yh=t=>{const e=H(r=>r.id)(t),n=bh(e);return[...H(kh)($h(e)),...H(Eh)(ct(r=>!os(r)(n),Tt(t)(Wh)))]},Vh=t=>e=>n=>{const r=yn(t.minZoom)(t.tokenZoomFloor);return xt(i=>{if(i.target.tag==="NodeWindow"||i.target.tag==="EdgeWindow")return T;if(i.target.tag==="TokenWindow")return w("Just",(()=>{const o={pre:i.target._7,post:i.target._8};if(t.tokenZoomFloor<=0)return{startT:i.startT,endT:i.endT,bbox:hi(e)(n)(i.target._2),priority:1,pathFollow:T};const u=Ni(i.target._2)(e.edges);if(u.tag==="Just"){const s=Ti(i.target._4)(e.nodes);if(s.tag==="Just"){const a=Ti(i.target._5)(e.nodes);if(a.tag==="Just"){const c=a._1;return{startT:i.startT,endT:i.endT,bbox:hi(e)(n)(i.target._2),priority:1,pathFollow:w("Just",{samples:(()=>{const f=i.startT+o.pre*(i.endT-i.startT),d=yn(1e-4)(i.endT-o.post*(i.endT-i.startT)-f),l=i.endT-i.startT;return H(_=>{const h=f+rt(_)/rt(32)*d;return{t:h,pos:Ll(u._1)({x:s._1.x+s._1.w/2,y:s._1.y+s._1.h/2})({x:c.x+c.w/2,y:c.y+c.h/2})(l<=0?0:(h-i.startT)/l)(o)}})(It(0,32))})(),zoom:r})}}if(a.tag==="Nothing")return{startT:i.startT,endT:i.endT,bbox:hi(e)(n)(i.target._2),priority:1,pathFollow:T};g()}if(s.tag==="Nothing")return{startT:i.startT,endT:i.endT,bbox:hi(e)(n)(i.target._2),priority:1,pathFollow:T};g()}if(u.tag==="Nothing")return{startT:i.startT,endT:i.endT,bbox:hi(e)(n)(i.target._2),priority:1,pathFollow:T};g()})());if(i.target.tag==="FillWindow")return w("Just",{startT:i.startT,endT:i.endT,bbox:pc(e)(n)(Wt("Node",1,1,i.target._2,void 0,Q,Q)),priority:1,pathFollow:T});g()})},Xh=t=>e=>n=>r=>i=>sh(t)(i.layout)(r.endT)([...Fh(i.layout)(n)(e)(ct(o=>o.startT>=i.startT&&o.endT<=i.endT,r.spans)),...Vh(t)(i.layout)(n)(i.windows)]),Uh=t=>{const e=Cc(H(r=>b(r.id,(()=>{if(r.when.tag==="First")return[];if(r.when.tag==="At")return[];if(r.when.tag==="After")return[r.when._1];if(r.when.tag==="With")return[r.when._1];g()})()))(t)),n=r=>i=>o=>{if(os(o)(i))return[lr("ScheduleCycle",[...kt(Re.foldr,i),o])];if(os(o)(r))return[];const u=Dc(o)(e);if(u.tag==="Nothing")return[];if(u.tag==="Just")return Tt(u._1)(n(j(C)(o)()(r))(j(C)(o)()(i)));g()};return Tt(t)(r=>n(Q)(Q)(r.id))},jh={plop:.5,gap:.5,edgeSpeed:350,minEdgeDuration:.3,tokenSpeed:250,minTokenDuration:1.8,tokenHold:.5,hatchHold:.4,tokenReadSecPerChar:.06,nodeEasing:Yl,edgeEasing:$l,tokenEasing:dr,diveDur:1.2,retreatDur:1.2},Zh=t=>e=>n=>r=>H((()=>{const i=n.startT;return o=>({...o,startT:o.startT+i,endT:o.endT+i})})())(xt(Ih)(Ic(t)(e)(r.events))),Kh=t=>e=>n=>r=>i=>{if(i.scene.tag==="Structural")return qh(t)(e)(n)(r)(i)(i.scene._1);if(i.scene.tag==="DataFlow")return Zh(t)(e)(i)(i.scene._1);if(i.scene.tag==="EnterNode")return[];if(i.scene.tag==="ExitNode")return[];g()},t0=t=>e=>n=>{const r=Ic(t)(e)(n.events);return r.length===0?t.gap:J(yn)(0)(H(i=>i.endT)(r))+t.gap},e0=t=>e=>n=>r=>i=>{if(i.tag==="Structural")return Fc(t)(e)(n)(r)(i._1).duration;if(i.tag==="DataFlow")return t0(t)(e)(i._1);if(i.tag==="EnterNode"||i.tag==="ExitNode")return 0;g()},Ac=t=>e=>n=>r=>i=>o=>{const u=El(e)(r),s=n.layout,a=dc(H(m=>b(m.id,m))(i.keyframes)),c=0<i.keyframes.length?w("Just",i.keyframes[0]):T,f=(()=>{if(c.tag==="Just")return c._1.id;if(c.tag==="Nothing")return"";g()})(),d=Ol(i),l=m=>({segments:m.runSpans.length===0?m.segments:zt(m.segments)({startT:m.runStart,endT:m.t,path:r,layout:s,placement:u,windows:m.runWindows,spans:m.runSpans,keyframes:a,initialKeyframe:f,edgeEndpoints:d}),spans:m.spans,windows:m.windows,dives:m.dives}),_=J(m=>p=>{if(p.tag==="EnterNode"){const v=l(m),k=m.t+t.diveDur,L=zt(r)(p._1),E=Ac(t)(e)(Oh(n)(p._1))(L)(zh(i)(p._1))(k),B=E.endT+t.retreatDur;return{...m,t:B,runStart:B,runSpans:[],runWindows:[],segments:[...v.segments,...E.segments],spans:[...v.spans,...E.spans],windows:[...v.windows,...E.windows],dives:[...v.dives,{startT:m.t,endT:k,node:p._1,parentPath:r,childPath:L,direction:Ch},...E.dives,{startT:E.endT,endT:B,node:p._1,parentPath:r,childPath:L,direction:Sh}]}}if(p.tag==="ExitNode")return m;const y=m.t+e0(t)(s)(a)(d)(p),x={startT:m.t,endT:y,scene:p},N=Kh(t)(s)(a)(d)(x);return{...m,t:y,runSpans:zt(m.runSpans)(x),runWindows:[...m.runWindows,...N],spans:zt(m.spans)(x),windows:[...m.windows,...N]}})({t:o,runStart:o,runSpans:[],runWindows:[],segments:[],spans:[],windows:[],dives:[]})(i.scenes),h=l(_);return{endT:_.t,spans:h.spans,windows:Lt(m=>p=>st.compare(m.startT)(p.startT))(h.windows),segments:h.segments,dives:h.dives}},n0=t=>e=>n=>n.endT<=t||n.startT>=e?T:w("Just",{...n,startT:yn(t)(n.startT),endT:No(e)(n.endT)}),as=t=>e=>n=>{const r=Ye(n.layout),i={x:r.x*n.placement.scale+n.placement.tx,y:r.y*n.placement.scale+n.placement.ty,w:r.w*n.placement.scale,h:r.h*n.placement.scale};return{center:{x:i.x+i.w/2,y:i.y+i.h/2},zoom:No(Zu(e)(i)(t.padding*n.placement.scale))(40/(11*n.placement.scale))}},r0=t=>e=>n=>n.placement.scale===1&&n.placement.tx===0&&n.placement.ty===0?ju(n.placement)(xi(t)(n.layout)(Ye(n.layout))(0)):as(t)(e)(n),i0=t=>e=>n=>r=>xt(i=>{const o=Qh(r)(i.parentPath)(i.startT)(i.endT);if(o.tag==="Just"){const u=i.childPath,s=Zt(a=>is(a.path)(u))(r.segments);if(s.tag==="Just"){const a=r0(t)(e)(o._1),c=as(t)(e)(s._1);if(i.direction==="DiveIn")return w("Just",{startT:i.startT,endT:i.endT,fromCam:a,toCam:c,easing:dr,interp:xc});if(i.direction==="DiveOut")return w("Just",{startT:i.startT,endT:i.endT,fromCam:c,toCam:a,easing:dr,interp:xc});g()}if(s.tag==="Nothing")return T;g()}if(o.tag==="Nothing")return T;g()})(r.dives),o0=t=>e=>{if(e.tag==="Structural")return xt(n=>n)([us(e._1.from)(t)?T:w("Just",lr("UnknownKeyframe",e._1.from)),us(e._1.to)(t)?T:w("Just",lr("UnknownKeyframe",e._1.to))]);if(e.tag==="DataFlow")return[...xt(n=>n)([us(e._1.keyframe)(t)?T:w("Just",lr("UnknownKeyframe",e._1.keyframe))]),...Yh(e._1.events),...Uh(e._1.events)];if(e.tag==="EnterNode")return[];if(e.tag==="ExitNode")return[];g()},u0=t=>e=>{const n=Tt(e)(o0(t));return n.length===0?St("Right",void 0):St("Left",n)},s0=t=>e=>n=>r=>Lt(i=>o=>st.compare(i.startT)(o.startT))(Tt(r.segments)(i=>i.placement.scale===1&&i.placement.tx===0&&i.placement.ty===0?xt(n0(i.startT)(i.endT))(H(Rh(i.placement))(Xh(t)(n)(i.edgeEndpoints)(r)(i))):[(()=>{const o=as(t)(e)(i);return{startT:i.startT,endT:i.endT,fromCam:o,toCam:o,easing:dr,interp:yi}})()])),a0=t=>e=>n=>r=>{if(0<n.keyframes.length){const i=n.keyframes[0],o=dc(H(s=>b(s.id,s))(n.keyframes)),u=u0(o)(n.scenes);return(()=>{if(u.tag==="Left"){const s=u._1;return a=>St("Left",s)}if(u.tag==="Right"){const s=u._1;return a=>a(s)}g()})()(()=>{const s=Ac(e)(r)(r)([])(n)(0);return St("Right",{totalDuration:s.endT,windows:s.windows,spans:s.spans,keyframes:o,initialKeyframe:i.id,timing:e,layout:r.layout,cameraSpans:[...s0(t)(r.layout)(o)(s),...i0(t)(r.layout)(o)(s)],cameraConfig:t,levelTree:r,segments:s.segments,dives:s.dives,seed:n.seed})})}return St("Left",[Lh])},cs=t=>e=>Math.imul(t,e),Cr=t=>{const e=t+1831565813|0,n=cs(e^e>>>15)(e|1),r=n^(n+cs(n^n>>>7)(n|61)|0),i=r^r>>>14;return{prng:i,value:i<0?(rt(i)+4294967296)/4294967296:rt(i)/4294967296}},ae=t=>e=>n=>{const r=Cr(n);return{prng:r.prng,value:t+r.value*(e-t)}},gs=t=>e=>J(n=>r=>cs(n^r)(-2048144789))(e)(H(Cn)(Vn(t))),fs=t=>t,tn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Jo=Tu(ti),c0=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),Mc=Kt(C)(Bt),Bc=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},zc=Bt.foldMap(il(C)),Rc=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},g0=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Sr=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},f0=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},_0=Kt(C)(Bt),d0=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},l0=Kt(C)(Bt),h0=fs("Backdrop"),Wc=fs("FlyThrough"),To=fs("Active"),Hc=t=>e=>n=>{const r=(t+e)/2,i=n-r,o=i<0?-1:1,u=(e-t)/2,s=u*.15,a=u-s,c=i<0?-i:i;return e<=t?(t+e)/2:c<=a?n:r+o*(u-s*Ui(-(c-a)/s))},p0=t=>e=>n=>r=>{const i=Ye(t),o=i.w/tn(1e-4)(e.zoom)/2,u=i.h/tn(1e-4)(e.zoom)/2,s=n.y-e.center.y,a=n.x-e.center.x;return{...e,center:{x:o<=1e-4?e.center.x+0*r*.35:a<0?e.center.x+a/(1+-a/o)*r*.35:e.center.x+a/(1+a/o)*r*.35,y:u<=1e-4?e.center.y+0*r*.35:s<0?e.center.y+s/(1+-s/u)*r*.35:e.center.y+s/(1+s/u)*r*.35}}},_s=t=>e=>n=>{const r=Zt(i=>Jo(i.path)(e)&&n>=i.startT&&n<i.endT)(t.segments);if(r.tag==="Just")return w("Just",r._1);if(r.tag==="Nothing")return Zt(i=>Jo(i.path)(e))(t.segments);g()},m0=t=>({startT:0,endT:t.totalDuration,path:[],layout:t.layout,placement:Ou,windows:t.windows,spans:t.spans,keyframes:t.keyframes,initialKeyframe:t.initialKeyframe,edgeEndpoints:Q}),y0=t=>H(e=>e<1?[]:bt(0,e,t))(It(0,t.length-1|0)),x0=t=>J(e=>n=>(e*31|0)+Cn(n)|0)(7)(Vn(t)),Oc=t=>e=>n=>({...n,state:{...n.state,nodes:Mc(H(r=>b(r._1,t(r._1)(r._2)))(c0(n.state.nodes))),edges:(()=>{const r=i=>{if(i.tag==="Leaf")return Q;if(i.tag==="Node")return Wt("Node",i._1,i._2,i._3,e(i._4),r(i._5),r(i._6));g()};return r(n.state.edges)})()}}),ds=t=>e=>{const n=Bc(e)(t.keyframes);if(n.tag==="Nothing")return Q;if(n.tag==="Just")return n._1.nodes;g()},ls=t=>e=>{const n=Bc(e)(t.keyframes);if(n.tag==="Nothing")return Q;if(n.tag==="Just")return n._1.edges;g()},hs=t=>e=>{if(e<t.startT)return kr("AtKeyframe",t.initialKeyframe);const n=Zt(r=>e>=r.startT&&e<r.endT)(t.spans);if(n.tag==="Just"){if(n._1.scene.tag==="Structural")return kr("InTransition",n._1.scene._1.from,n._1.scene._1.to);if(n._1.scene.tag==="DataFlow")return kr("AtKeyframe",n._1.scene._1.keyframe);if(n._1.scene.tag==="EnterNode"||n._1.scene.tag==="ExitNode")return kr("AtKeyframe",t.initialKeyframe);g()}if(n.tag==="Nothing"){const r=t.spans.length-1|0;return r>=0&&r<t.spans.length?kr("AtKeyframe",(()=>{if(t.spans[r].scene.tag==="Structural")return t.spans[r].scene._1.to;if(t.spans[r].scene.tag==="DataFlow")return t.spans[r].scene._1.keyframe;if(t.spans[r].scene.tag==="EnterNode"||t.spans[r].scene.tag==="ExitNode")return t.initialKeyframe;g()})()):kr("AtKeyframe",t.initialKeyframe)}g()},N0=J(t=>e=>{const n=Vi(t);return n.tag==="Just"&&e.startT<=n._1.last.endT+1e-6?zt(n._1.init)({...n._1.last,endT:tn(n._1.last.endT)(e.endT),windows:zt(n._1.last.windows)(e)}):zt(t)({endT:e.endT,windows:[e]})})([]),J0=t=>e=>n=>zc(r=>zc(i=>i.target.tag==="FillWindow"?i.startT<=n?Wt("Node",1,1,i.target._2,void 0,Q,Q):Q:i.target.tag==="TokenWindow"&&i.startT+(i.endT-i.startT)*.25<=n?Wt("Node",1,1,i.target._4,void 0,Q,Q):Q)(r.windows))(ct(r=>n<=r.endT+t,N0(Lt(r=>i=>st.compare(r.startT)(i.startT))(ct(r=>r.target.tag==="FillWindow"||r.target.tag==="TokenWindow",e))))),T0=t=>e=>n=>Me(r=>r.endT<=e&&r.target.tag==="EdgeWindow"&&r.target._2.tag==="Retract"&&r.target._1===n,t),v0=t=>e=>n=>Me(r=>r.endT<=e&&r.target.tag==="NodeWindow"&&r.target._2==="PlopOut"&&r.target._1===n,t),w0=t=>e=>n=>Me(r=>r.startT>e&&r.target.tag==="NodeWindow"&&r.target._2==="PlopIn"&&r.target._1===n,t),b0=t=>e=>n=>Me(r=>r.startT>e&&r.target.tag==="EdgeWindow"&&r.target._2.tag==="Extend"&&r.target._1===n,t),L0=t=>e=>{const n=hs(t)(e);if(n.tag==="AtKeyframe")return me(3)(n._1)==="kf-"?"":n._1;if(n.tag==="InTransition")return me(3)(n._2)==="kf-"?"":n._2;g()},qc=t=>e=>n=>Zt(r=>n(r)&&e>=r.startT&&e<r.endT)(t),k0=t=>{const e=Rc(0)(1)(t/.2),n=Rc(0)(1)((1-t)/.2);return e*e*(3-2*e)*n*n*(3-2*n)},E0=t=>e=>{if(e.tag==="Travelling"){const n=g0(e._1.edge)(t.edges);if(n.tag==="Just"){const r=vr(n._1)(e._1.progress);return r.tag==="Just"?w("Just",{dot:r._1,weight:k0(e._1.progress)}):T}if(n.tag==="Nothing")return T;g()}return T},G0={segment:{startT:0,endT:0,path:[],layout:{nodes:Q,edges:Q,chipExtras:Q},placement:Ou,windows:[],spans:[],keyframes:Q,initialKeyframe:"",edgeEndpoints:Q},state:{nodes:Q,edges:Q,tokens:Q,camera:{center:{x:0,y:0},zoom:1},frameTitle:"",visited:Q,nodeFadeAlpha:Q,nodeInvert:Q},bgAlpha:1,role:To},vo=t=>{const e=t.levels.length-1|0;return e>=0&&e<t.levels.length?t.levels[e]:G0},C0=t=>e=>{const n=hs(t)(e);if(n.tag==="AtKeyframe")return ds(t)(n._1);if(n.tag==="InTransition")return Ge(C.compare,Le,ds(t)(n._1),ds(t)(n._2));g()},S0=t=>e=>{const n=hs(t)(e);if(n.tag==="AtKeyframe")return ls(t)(n._1);if(n.tag==="InTransition")return Ge(C.compare,Le,ls(t)(n._1),ls(t)(n._2));g()},D0=t=>e=>{const n=t.w/tn(1e-4)(e.zoom),r=t.h/tn(1e-4)(e.zoom);return{...e,center:{x:n>=t.w?t.x+t.w/2:Hc(t.x+n/2)(t.x+t.w-n/2)(e.center.x),y:r>=t.h?t.y+t.h/2:Hc(t.y+r/2)(t.y+t.h-r/2)(e.center.y)}}},P0=t=>D0((()=>{const e=Ye(t.layout),n=e.x*t.placement.scale+t.placement.tx,r=e.y*t.placement.scale+t.placement.ty;return{x:n,y:r,w:(e.x+e.w)*t.placement.scale+t.placement.tx-n,h:(e.y+e.h)*t.placement.scale+t.placement.ty-r}})()),I0=t=>e=>{const n=t.endT-t.startT;return n<=0?1:tn(0)(Sr(1)((e-t.startT)/n))},$c=t=>e=>n=>tn(0)(Sr(1)((n-ae(0)(.3)(t+x0(e)|0).value)/tn(1e-4)(.7))),Yc=t=>e=>n=>Oc(r=>i=>i.tag==="Hidden"?yo:Lr("PloppingOut",r===e?tn(0)(Sr(1)((n-.45)/tn(1e-4)(.55))):$c(t)(r)(n)))(r=>r.tag==="Retracted"?xo:br("Retracting",kc,n)),Vc=t=>e=>Oc(n=>r=>r.tag==="Hidden"?yo:Lr("PloppingIn",$c(t)(n)(e)))(n=>n.tag==="Retracted"?xo:br("Extending",ns,e)),wo=t=>e=>{const n=t.endT-t.startT;return n<=0?1:tn(0)(Sr(1)((e-t.startT)/n))},Q0=t=>e=>n=>r=>i=>{const o=qc(e)(n)(u=>u.target.tag==="EdgeWindow"&&u.target._1===i);if(o.tag==="Just"){const u=Xu(t.timing.edgeEasing)(wo(o._1)(n)),s=o._1.target.tag==="EdgeWindow"?o._1.target._2:rs("Extend",ns);if(s.tag==="Retract")return br("Retracting",s._1,u);if(s.tag==="Extend")return br("Extending",s._1,u);g()}if(o.tag==="Nothing")return b0(e)(n)(i)||T0(e)(n)(i)?xo:f0(i)(r)?wh:xo;g()},F0=t=>e=>n=>{const r=S0(e)(n);return _0(H(i=>b(i,Q0(t)(e.windows)(n)(r)(i)))((()=>{const i=o=>{if(o.tag==="Leaf")return Q;if(o.tag==="Node")return Wt("Node",o._1,o._2,o._3,void 0,i(o._5),i(o._6));g()};return kt(Re.foldr,i(e.layout.edges))})()))},A0=t=>e=>n=>r=>{const i=qc(t)(e)(o=>o.target.tag==="NodeWindow"&&o.target._1===r);if(i.tag==="Just"){const o=wo(i._1)(e),u=i._1.target.tag==="NodeWindow"?i._1.target._2:Pc;if(u==="PlopIn")return Lr("PloppingIn",o);if(u==="PlopOut")return Lr("PloppingOut",o);g()}if(i.tag==="Nothing")return w0(t)(e)(r)||v0(t)(e)(r)?yo:d0(r)(n)?vh:yo;g()},M0=t=>e=>n=>{const r=C0(e)(n);return Mc(H(i=>b(i,A0(e.windows)(n)(r)(i)))((()=>{const i=o=>{if(o.tag==="Leaf")return Q;if(o.tag==="Node")return Wt("Node",o._1,o._2,o._3,void 0,i(o._5),i(o._6));g()};return kt(Re.foldr,i(e.layout.nodes))})()))},B0=t=>e=>n=>e.target.tag==="TokenWindow"?b(e.target._1,n<e.startT?es:n>=e.endT?bc:mo("Travelling",{edge:e.target._2,direction:e.target._3,progress:Xu(t.timing.tokenEasing)(wo(e)(n)),labels:e.target._6,source:e.target._4,target:e.target._5,holdPre:e.target._7,holdPost:e.target._8})):e.target.tag==="FillWindow"?b(e.target._1,n<e.startT?es:n>=e.endT?bc:mo("Filling",{node:e.target._2,progress:wo(e)(n),labels:e.target._3})):b("",es),z0=t=>e=>n=>l0(H(r=>B0(t)(r)(n))(ct(r=>r.target.tag==="TokenWindow"||r.target.tag==="FillWindow",e))),Dr=t=>e=>n=>({nodes:M0()(e)(n),edges:F0(t)(e)(n),tokens:z0(t)(e.windows)(n),camera:Jc(t.cameraConfig)(e.layout)(t.cameraSpans)(n),frameTitle:L0(e)(n),visited:J0(t.timing.hatchHold)(e.windows)(n),nodeFadeAlpha:Q,nodeInvert:Q}),R0=t=>e=>n=>Aa(T,Sa,r=>r.direction==="DiveIn"&&Jo(r.parentPath)(e.path)&&n>=r.startT-.7&&n<r.startT?w("Just",{node:r.node,phase:(n-(r.startT-.7))/.7}):T,t.dives),W0=t=>e=>n=>r=>{const i=R0(t)(e)(n);if(i.tag==="Just"){const o=Oe(3.141592653589793*i._1.phase*3);return{...r,state:{...r.state,nodeInvert:Wt("Node",1,1,i._1.node,1*o*o,Q,Q)}}}if(i.tag==="Nothing")return r;g()},Xc=t=>e=>xt(n=>{const r=Zt(i=>i.direction==="DiveIn"&&Jo(i.childPath)((()=>{const o=n.length+1|0;return o<1?[]:bt(0,o,e)})()))(t.dives);if(r.tag==="Just"){const i=_s(t)(n)(r._1.startT-1e-4);if(i.tag==="Just")return w("Just",{bgAlpha:1,role:h0,segment:i._1,state:{...Dr(t)(i._1)(r._1.startT-1e-4),nodeFadeAlpha:Wt("Node",1,1,r._1.node,0,Q,Q)}});if(i.tag==="Nothing")return T;g()}if(r.tag==="Nothing")return T;g()})(y0(e)),Uc=t=>e=>{const n=ct(i=>e>=i.startT&&e<i.endT,t.segments),r=n.length-1|0;return r>=0&&r<n.length?n[r]:m0(t)},H0=t=>e=>n=>{const r=I0(n)(e),i=_s(t)(n.parentPath)((()=>{if(n.direction==="DiveIn")return n.startT-1e-4;if(n.direction==="DiveOut")return n.endT-1e-4;g()})()),o=_s(t)(n.childPath)((()=>{if(n.direction==="DiveIn")return n.endT;if(n.direction==="DiveOut")return n.startT-1e-4;g()})()),u=tn(0)(Sr(1)(r/.6)),s=tn(0)(Sr(1)((r-.4)/.6)),a=(()=>{if(n.direction==="DiveIn")return Yc(t.seed)(n.node)(u);if(n.direction==="DiveOut")return Vc(t.seed)(s);g()})(),c=(()=>{if(n.direction==="DiveIn")return Vc(t.seed)(s);if(n.direction==="DiveOut")return Yc(t.seed)(n.node)(u);g()})();return[...Xc(t)(n.parentPath),...(()=>{if(i.tag==="Just"){if(o.tag==="Just")return[a({segment:i._1,state:Dr(t)(i._1)((()=>{if(n.direction==="DiveIn")return n.startT-1e-4;if(n.direction==="DiveOut")return n.endT-1e-4;g()})()),bgAlpha:1,role:Wc}),c({segment:o._1,state:Dr(t)(o._1)((()=>{if(n.direction==="DiveIn")return n.endT;if(n.direction==="DiveOut")return n.startT-1e-4;g()})()),bgAlpha:1,role:To})];if(o.tag==="Nothing")return[a({segment:i._1,state:Dr(t)(i._1)((()=>{if(n.direction==="DiveIn")return n.startT-1e-4;if(n.direction==="DiveOut")return n.endT-1e-4;g()})()),bgAlpha:1,role:Wc})];g()}if(i.tag==="Nothing")return[(()=>{const f=Uc(t)(e);return{segment:f,state:Dr(t)(f)(e),bgAlpha:1,role:To}})()];g()})()]},O0=t=>e=>{const n=xt(E0(t))((()=>{const r=(i,o)=>{if(i.tag==="Leaf")return o;if(i.tag==="Node")return r(i._5,Ot("Cons",i._4,r(i._6,o)));g()};return kt($t.foldr,r(e.tokens,qt))})());return 0<n.length?w("Just",n[0]):T},q0=t=>e=>{const n=O0(t)(e);if(n.tag==="Nothing")return e.camera;if(n.tag==="Just")return p0(t)(e.camera)(n._1.dot)(n._1.weight);g()},$0=t=>e=>t.placement.scale===1&&t.placement.tx===0&&t.placement.ty===0?q0(t.layout)(e):e.camera,Y0=t=>e=>Zt(n=>e>=n.startT&&e<n.endT)(t.dives),V0=t=>e=>{const n=Uc(t)(e),r=Dr(t)(n)(e),i=t.dives.length!==0,o=Jc(t.cameraConfig)(t.layout)(t.cameraSpans)(e),u=P0(n)($0(n)({...r,camera:o})),s=W0(t)(n)(e)({bgAlpha:1,role:To,segment:n,state:{...r,camera:u}}),a=Xc(t)(n.path),c=Y0(t)(e);if(c.tag==="Just")return{levels:H0(t)(e)(c._1),camera:o,rootLayout:t.layout,hasDives:i,diving:!0};if(c.tag==="Nothing")return{levels:zt(a)(s),camera:u,rootLayout:t.layout,hasDives:i,diving:!1};g()},jc=t=>t,Zc=jc("RunText"),X0=jc("RunCode"),Kc=t=>e=>n=>e.length===0?n:zt(n)({style:t,text:cr(e)}),U0=t=>({style:(()=>{if(t.style==="RunText")return X0;if(t.style==="RunCode")return Zc;g()})(),buf:[],runs:Kc(t.style)(t.buf)(t.runs)}),j0=t=>e=>0<e.length?{...t,buf:zt(t.buf)(e[0])}:{...t,buf:zt(t.buf)("\\")},Z0=t=>e=>{let n=t,r=e,i=!0,o;for(;i;){const u=n,s=Ft(a=>T,a=>c=>w("Just",{head:a,tail:c}),r);if(s.tag==="Nothing"){i=!1,o=u;continue}if(s.tag==="Just"){if(s._1.head==="\\"){n=j0(u)(s._1.tail),r=bt(1,s._1.tail.length,s._1.tail);continue}if(s._1.head==="`"){n=U0(u),r=s._1.tail;continue}n={...u,buf:zt(u.buf)(s._1.head)},r=s._1.tail;continue}g()}return o},tg=t=>{const e=Z0({style:Zc,buf:[],runs:[]})(Vn(t));return Kc(e.style)(e.buf)(e.runs)};let ps=null;function K0(){return ps||(typeof document>"u"?null:(ps=document.createElement("canvas").getContext("2d"),ps))}const eg=new Map,tp=t=>e=>n=>r=>()=>{const i=`${n} ${e}px ${t}|${r}`,o=eg.get(i);if(o!==void 0)return o;const u=K0();if(!u)return r.length*e*.62;u.font=`${n} ${e}px ${t}`;const s=u.measureText(r).width;return eg.set(i,s),s},ep=rr.traverse(xu),np=J(Tr)(0),Pr=(()=>{const t=jn(`\r
|
|
3
|
+
`)(" "),e=jn(`
|
|
4
|
+
`)(" "),n=(()=>{const r=jn("\r")(" "),i=(()=>{const o=jn(" ")(" ");return u=>o(r(u))})();return o=>i(e(o))})();return r=>n(t(r))})(),ng=t=>e=>{const n=ep(r=>{const i=(()=>{if(r.style==="RunText")return t.text;if(r.style==="RunCode")return t.code;g()})();return tp(i.family)(i.size)(i.weight)(Pr(r.text))})(tg(Pr(e)));return()=>{const r=n();return np(r)}},rg={text:{family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:"500"},code:{family:"'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace",size:11,weight:"400"}},rp=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Ir=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},ip=t=>e=>{const n=it.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},op=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},up=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},ig=t=>cr(ke(or(e=>e===" ")(ke(or(e=>e===" ")(Vn(t)).rest)).rest)),sp=t=>J(e=>n=>n._1>0&&(n._2===" "||n._2==="-"||n._2==="_"||n._2===".")?w("Just",n._1):e)(T)(Qt(Hn)(t)),ms=t=>e=>{if(t<=0)return[e];if(Xn(e)<=t)return[e];const n=Vn(e),r=t<1?[]:bt(0,t,n),i=sp(r);if(i.tag==="Just"){const o=ig(rc(!(i._1>=0&&i._1<r.length)||r[i._1]===" "?i._1:i._1+1|0)(e)),u=ig(ci(i._1+1|0)(e));return u===""?[o]:[o,...ms(t)(u)]}if(i.tag==="Nothing"){const o=rc(t)(e),u=ci(t)(e);return u===""?[o]:[o,...ms(t)(u)]}g()},ap={cellW:7,cellH:3,maxLineWidth:20},cp=t=>e=>{const n=H(o=>b((()=>{if(o.label.tag==="Just")return o.label._1;if(o.label.tag==="Nothing")return o.id;g()})(),o))(e.nodes),r=Ir(1)(En((ip(t.maxLineWidth)(J(o=>u=>Ir(o)(Xn(u._1)))(0)(n))+2|0)+t.cellW|0,t.cellW)),i=(r*t.cellW|0)-1|0;return{...e,nodes:H(o=>{if(!(o._2.size._1===1&&o._2.size._2===1))return o._2;const u=Tt(_o(`
|
|
5
|
+
`)(o._1))(ms(i)),s=J(c=>f=>Ir(c)(Xn(f)))(0)(u),a=o._2.shape==="Cylinder"?Ir(1)(En((s+2|0)+t.cellW|0,t.cellW)):r;return{...o._2,size:b(rt(s>i?En((s+2|0)+t.cellW|0,t.cellW):a),rt(Ir(1)(En(u.length+t.cellH|0,t.cellH))+(o._2.shape==="Cylinder"?1:0)|0))}})(n)}},gp=t=>e=>n=>({...n,nodes:H(r=>{const i=up(r.id)(e);if(i.tag==="Nothing")return r;if(i.tag==="Just")return{...r,size:b(op(r.size._1)(rt(Ir(1)(de(Xi(r.shape==="Cylinder"?(i._1+0)/t:(i._1+32)/t))))),r.size._2)};g()})(n.nodes)}),fp=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},_p=t=>{const e=t.length;return(n=>r=>{let i=n,o=r,u=!0,s;for(;u;){const a=i,c=o;if(a>=e){u=!1,s=c;continue}const f=d=>l=>{let _=d,h=l,m=!0,p;for(;m;){const y=_,x=h;if(y>=e){m=!1,p=x;continue}if(a>=0&&a<t.length){if(y>=0&&y<t.length){_=y+1|0,h=(()=>{const N=t[a].position,v=t[a].size,k=t[y].position,L=t[y].size;return N._1<k._1+L._1&&k._1<N._1+v._1&&N._2<k._2+L._2&&k._2<N._2+v._2})()?x+1|0:x;continue}_=y+1|0,h=x;continue}m=!1,p=x}return p};i=a+1|0,o=f(a+1|0)(c)}return s})(0)(0)},og=t=>J(e=>n=>e+ml(n.start)(n.end))(0)(t.segments),dp=t=>e=>n=>({crossingCount:J(r=>i=>r+i.jumps.length|0)(0)(e),bendCount:J(r=>i=>r+i.bends.length|0)(0)(e),totalEdgeLength:J(r=>i=>r+og(i))(0)(e),maxEdgeLength:J(r=>i=>fp(r)(og(i)))(0)(e),nodeOverlapCount:_p(t),constraintViolations:n,jumpCount:J(r=>i=>r+i.jumps.length|0)(0)(e)}),ys=t=>t,Ut=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},xs=ys("LEFT"),lp=ys("RIGHT"),ug=ys("UNDEFINED"),hp={eq:t=>e=>t==="LEFT"?e==="LEFT":t==="RIGHT"?e==="RIGHT":t==="UP"?e==="UP":t==="DOWN"?e==="DOWN":t==="UNDEFINED"&&e==="UNDEFINED"},pp={compare:t=>e=>{if(t==="LEFT")return e==="LEFT"?Se:ye;if(e==="LEFT")return xe;if(t==="RIGHT")return e==="RIGHT"?Se:ye;if(e==="RIGHT")return xe;if(t==="UP")return e==="UP"?Se:ye;if(e==="UP")return xe;if(t==="DOWN")return e==="DOWN"?Se:ye;if(e==="DOWN")return xe;if(t==="UNDEFINED"&&e==="UNDEFINED")return Se;g()},Eq0:()=>hp},mp=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){if(t==="LEFT"){if(o._3==="LEFT"){r=!1,i=!0;continue}n=o._5;continue}if(o._3==="LEFT"){n=o._6;continue}if(t==="RIGHT"){if(o._3==="RIGHT"){r=!1,i=!0;continue}n=o._5;continue}if(o._3==="RIGHT"){n=o._6;continue}if(t==="UP"){if(o._3==="UP"){r=!1,i=!0;continue}n=o._5;continue}if(o._3==="UP"){n=o._6;continue}if(t==="DOWN"){if(o._3==="DOWN"){r=!1,i=!0;continue}n=o._5;continue}if(o._3==="DOWN"){n=o._6;continue}if(t==="UNDEFINED"&&o._3==="UNDEFINED"){r=!1,i=!0;continue}}g()}return i},yp={x:0,y:0},Ve=t=>e=>n=>{const r=Ut(t)(n.cNodes);if(r.tag==="Nothing")return n;if(r.tag==="Just")return{...n,cNodes:j(it)(t)(e(r._1))(n.cNodes)};g()},vi=t=>e=>n=>{const r=Ut(t)(n.cGroups);if(r.tag==="Nothing")return n;if(r.tag==="Just")return{...n,cGroups:j(it)(t)(e(r._1))(n.cGroups)};g()},xp=t=>J(e=>n=>Ve(n)(r=>({...r,hitboxPreCompaction:r.hitbox}))(e))(t)(t.cNodeOrder),Np=t=>{const e=J(n=>r=>{const i=Ut(r)(t.cNodes);if(i.tag==="Nothing")return n;if(i.tag==="Just")return J(o=>u=>vt(it)(te)(u)([r])(o))(n)(i._1.constraints);g()})(Q)(t.cNodeOrder);return J(n=>r=>Ve(r)(i=>({...i,constraints:(()=>{const o=Ut(r)(e);if(o.tag==="Nothing")return[];if(o.tag==="Just")return o._1;g()})()}))(n))(t)(t.cNodeOrder)},Jp=t=>e=>Ve(t)(n=>({...n,ignoreSpacing:{left:n.ignoreSpacing.left||e.left,right:n.ignoreSpacing.right||e.right,up:n.ignoreSpacing.up||e.up,down:n.ignoreSpacing.down||e.down}})),Tp=t=>{const e=J(n=>r=>vi(r)(i=>({...i,outDegree:i.outDegreeReal}))(n))(t)(t.cGroupOrder);return J(n=>r=>Ve(r)(i=>({...i,startPos:-1e308}))(n))(e)(e.cNodeOrder)},sn={left:!1,right:!1,up:!1,down:!1},vp={horizontalSpacing:t=>e=>0,verticalSpacing:t=>e=>0},Ns=t=>J(e=>n=>{const r=Ut(n)(e.cGroups);if(r.tag==="Nothing")return e;if(r.tag==="Just"){const i=J(u=>s=>{const a=Ut(s)(e.cNodes);if(a.tag==="Nothing")return u;if(a.tag==="Just"){if(u.tag==="Nothing")return w("Just",s);if(u.tag==="Just"){const c=Ut(u._1)(e.cNodes);if(c.tag==="Nothing")return w("Just",s);if(c.tag==="Just")return a._1.hitbox.x<c._1.hitbox.x?w("Just",s):w("Just",u._1)}}g()})(T)(r._1.cNodes),o=vi(n)(u=>({...u,reference:i}))(e);if(i.tag==="Nothing")return o;if(i.tag==="Just"){const u=Ut(i._1)(o.cNodes);if(u.tag==="Nothing")return o;if(u.tag==="Just"){const s=u._1;return J(a=>c=>Ve(c)(f=>({...f,cGroupOffset:{x:f.hitbox.x-s.hitbox.x,y:f.hitbox.y-s.hitbox.y}}))(a))(o)(r._1.cNodes)}}}g()})(t)(t.cGroupOrder),Xe=t=>Ns({...t,cNodes:(()=>{const e=n=>{if(n.tag==="Leaf")return Q;if(n.tag==="Node")return Wt("Node",n._1,n._2,n._3,{...n._4,hitbox:{...n._4.hitbox,x:-n._4.hitbox.x-n._4.hitbox.width}},e(n._5),e(n._6));g()};return e(t.cNodes)})()}),xn=t=>Ns({...t,cNodes:(()=>{const e=n=>{if(n.tag==="Leaf")return Q;if(n.tag==="Node")return Wt("Node",n._1,n._2,n._3,{...n._4,hitbox:{x:n._4.hitbox.y,y:n._4.hitbox.x,width:n._4.hitbox.height,height:n._4.hitbox.width},cGroupOffset:{x:n._4.cGroupOffset.y,y:n._4.cGroupOffset.x}},e(n._5),e(n._6));g()};return e(t.cNodes)})()}),sg=t=>{const e=J(n=>r=>vi(r)(i=>({...i,outDegree:0,outDegreeReal:0,incomingConstraints:[]}))(n))(t)(t.cGroupOrder);return J(n=>r=>{const i=Ut(r)(n.cNodes);if(i.tag==="Nothing")return n;if(i.tag==="Just"){if(i._1.cGroup.tag==="Nothing")return n;if(i._1.cGroup.tag==="Just"){const o=i._1.cGroup._1;return J(u=>s=>{const a=Ut(s)(u.cNodes);if(a.tag==="Nothing")return u;if(a.tag==="Just")return a._1.cGroup.tag==="Just"&&a._1.cGroup._1!==o?vi(a._1.cGroup._1)(c=>({...c,outDegree:c.outDegree+1|0,outDegreeReal:c.outDegreeReal+1|0}))(vi(o)(c=>Be(xr)(s)(c.incomingConstraints)?c:{...c,incomingConstraints:[...c.incomingConstraints,s]})(u)):u;g()})(n)(i._1.constraints)}}g()})(e)(e.cNodeOrder)},bo=t=>{const e=Np(t.cGraph);return{...t,cGraph:sg(J(n=>r=>Ve(r)(i=>({...i,startPos:-1e308}))(n))(e)(e.cNodeOrder))}},wp=t=>e=>J(n=>r=>{if(t==="LEFT"||t==="UP"){const o=r._2;return Ve(r._1)(u=>({...u,constraints:[...u.constraints,o]}))(n)}const i=r._1;return Ve(r._2)(o=>({...o,constraints:[...o.constraints,i]}))(n)})(e)(t==="LEFT"||t==="RIGHT"?e.predefinedHorizontalConstraints:e.predefinedVerticalConstraints),an=t=>{const e={...t,cGraph:wp(t.direction)({...t.cGraph,cNodes:(()=>{const n=r=>{if(r.tag==="Leaf")return Q;if(r.tag==="Node")return Wt("Node",r._1,r._2,r._3,{...r._4,constraints:[]},n(r._5),n(r._6));g()};return n(t.cGraph.cNodes)})()})};return{...e,cGraph:sg((()=>{if(e.constraintAlgorithm.tag==="Nothing")return e.cGraph;if(e.constraintAlgorithm.tag==="Just")return e.constraintAlgorithm._1(e);g()})())}},bp=t=>e=>n=>{const r={...n,direction:e};if(t==="UNDEFINED")return e==="LEFT"?an(r):e==="RIGHT"?an({...r,cGraph:Xe(r.cGraph)}):e==="UP"?an({...r,cGraph:xn(r.cGraph)}):e==="DOWN"?an({...r,cGraph:Xe(xn(r.cGraph))}):r;if(t==="LEFT")return e==="RIGHT"?bo({...r,cGraph:Xe(r.cGraph)}):e==="UP"?an({...r,cGraph:xn(r.cGraph)}):e==="DOWN"?an({...r,cGraph:Xe(xn(r.cGraph))}):r;if(t==="RIGHT")return e==="LEFT"?bo({...r,cGraph:Xe(r.cGraph)}):e==="UP"?an({...r,cGraph:xn(Xe(r.cGraph))}):e==="DOWN"?an({...r,cGraph:Xe(xn(Xe(r.cGraph)))}):r;if(t==="UP")return e==="LEFT"?an({...r,cGraph:xn(r.cGraph)}):e==="RIGHT"?an({...r,cGraph:Xe(xn(r.cGraph))}):e==="DOWN"?bo({...r,cGraph:Xe(r.cGraph)}):r;if(t==="DOWN")return e==="LEFT"?an({...r,cGraph:xn(Xe(r.cGraph))}):e==="RIGHT"?an({...r,cGraph:Xe(xn(Xe(r.cGraph)))}):e==="UP"?bo({...r,cGraph:Xe(r.cGraph)}):r;g()},ag=t=>e=>e.finished||!mp(t)(e.cGraph.supportedDirections)||(t==="LEFT"?e.direction==="LEFT":t==="RIGHT"?e.direction==="RIGHT":t==="UP"?e.direction==="UP":t==="DOWN"?e.direction==="DOWN":t==="UNDEFINED"&&e.direction==="UNDEFINED")?e:bp(e.direction)(t)(e),Lp=t=>{if(t.finished)return t;const e=t.direction==="UNDEFINED"?ag(xs)(t):t,n={...e,cGraph:Tp(e.cGraph)};if(n.compactionAlgorithm.tag==="Nothing")return n;if(n.compactionAlgorithm.tag==="Just")return n.compactionAlgorithm._1(n);g()},cg=t=>e=>n=>{const r=Ut(t)(n.cNodes),i=Ut(e)(n.cGroups);return r.tag==="Just"&&i.tag==="Just"?(()=>{if(r._1.cGroup.tag==="Nothing")return!1;if(r._1.cGroup.tag==="Just")return!0;g()})()&&(r._1.cGroup.tag==="Nothing"||!(r._1.cGroup.tag==="Just"&&r._1.cGroup._1===e))?n:{...n,cNodes:j(it)(t)({...r._1,cGroup:w("Just",e)})(n.cNodes),cGroups:j(it)(e)({...i._1,cNodes:Be(xr)(t)(i._1.cNodes)?i._1.cNodes:[...i._1.cNodes,t],reference:(()=>{if(i._1.reference.tag==="Nothing")return w("Just",t);if(i._1.reference.tag==="Just")return w("Just",i._1.reference._1);g()})()})(n.cGroups)}:n},gg=t=>e=>({id:e.nextCNodeId,graph:{...e,cNodes:j(it)(e.nextCNodeId)({id:e.nextCNodeId,origin:t.origin,kind:t.kind,cGroup:T,cGroupOffset:yp,hitbox:t.hitbox,hitboxPreCompaction:t.hitbox,constraints:[],startPos:-1e308,ignoreSpacing:sn})(e.cNodes),cNodeOrder:[...e.cNodeOrder,e.nextCNodeId],nextCNodeId:e.nextCNodeId+1|0}}),Js=t=>e=>{const n=e.nextCGroupId;return{id:n,graph:J(r=>i=>cg(i)(n)(r))({...e,cGroups:j(it)(n)({id:n,master:t.master,cNodes:[],startPos:-1e308,incomingConstraints:[],outDegree:0,outDegreeReal:0,reference:T,delta:0,deltaNormalized:0})(e.cGroups),cGroupOrder:[...e.cGroupOrder,n],nextCGroupId:n+1|0})(t.nodes)}},kp=t=>J(e=>n=>{const r=Ut(n)(e.cNodes);return r.tag==="Just"&&r._1.cGroup.tag==="Nothing"?Js({master:T,nodes:[n]})(e).graph:e})(t)(t.cNodeOrder),Ep=t=>({cGraph:xp(kp(Ns(t))),direction:ug,compactionAlgorithm:T,constraintAlgorithm:T,spacingsHandler:vp,lockFun:T,finished:!1}),fg=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Gp=t=>e=>{const n=st.compare(t._1)(e._1);return n==="LT"?ye:n==="GT"?xe:it.compare(t._2)(e._2)},Cp=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),_g=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},dg=t=>t.kind.tag==="Nothing"?!1:t.kind.tag==="Just"&&t.kind._1==="vs",lg=t=>t.kind.tag==="Nothing"||!(t.kind.tag==="Just"&&t.kind._1==="vs"),hg=rt(4),pg=fg(0)(hg/2-.5),Sp=fg(0)(hg/2-.5),Lo=t=>e=>Gp(b(t.hitbox.x+t.hitbox.width/2,t.id))(b(e.hitbox.x+e.hitbox.width/2,e.id)),Dp=t=>e=>{const n=ir(Yt,T,r=>Lo(t)(r)==="LT",e);if(n.tag==="Just"){const r=Ba(Yt,T,n._1,t,e);if(r.tag==="Nothing")return e;if(r.tag==="Just")return r._1;g()}if(n.tag==="Nothing")return zt(e)(t);g()},mg=t=>e=>{const n=ct(i=>Lo(i)(t)==="LT",e),r=n.length-1|0;return r>=0&&r<n.length?w("Just",n[r]):T},Pp=t=>e=>{const n=Dp(e)(t.intervals),r=Zt(o=>Lo(e)(o)==="LT")(n),i=j(it)(e.id)((()=>{const o=mg(e)(n);return o.tag==="Just"?w("Just",o._1.id):T})())(t.cand);return{...t,intervals:n,cand:(()=>{if(r.tag==="Just")return j(it)(r._1.id)(w("Just",e.id))(i);if(r.tag==="Nothing")return i;g()})()}},Ip=t=>e=>{const n=st.compare(t.low?t.node.hitbox.y:t.node.hitbox.y+t.node.hitbox.height)(e.low?e.node.hitbox.y:e.node.hitbox.y+e.node.hitbox.height);return n==="EQ"?t.low?t.low&&!e.low?xe:Se:e.low?ye:Se:n},Qp=t=>J(e=>n=>Ve(n.id)(r=>({...r,constraints:[]}))(e))(t)(xt(e=>Ut(e)(t.cNodes))(t.cNodeOrder)),Fp=t=>e=>J(n=>r=>{const i=Ut(r._1)(n.cNodes);if(i.tag==="Just")return Ve(r._1)(o=>({...o,constraints:[...o.constraints,...r._2]}))(n);if(i.tag==="Nothing")return n;g()})(e)(Cp(t)),yg=t=>e=>e.kind.tag!=="Nothing"&&e.kind.tag==="Just"&&e.kind._1==="vs"?e.ignoreSpacing.up?e.ignoreSpacing.down?e:{...e,hitbox:{...e.hitbox,height:e.hitbox.height+t+.01}}:{...e,hitbox:{...e.hitbox,y:e.hitbox.y-t-.01,height:e.hitbox.height+t+.01}}:{...e,hitbox:{...e.hitbox,y:e.hitbox.y-t,height:e.hitbox.height+2*t}},xg=t=>e=>n=>J(r=>i=>n(i)?Ve(i.id)(yg(t))(r):r)(e)(xt(r=>Ut(r)(e.cNodes))(e.cNodeOrder)),Ap=t=>e=>{const n=(r,i,o)=>{const u=Ve(o)(yg(t))(r);return i.length<=1?u:J(s=>a=>a===o?s:Ve(a)(c=>c.ignoreSpacing.up?{...c,hitbox:{...c.hitbox,y:c.hitbox.y+t+.01,height:c.hitbox.height-t-.01}}:c.ignoreSpacing.down?{...c,hitbox:{...c.hitbox,height:c.hitbox.height-t-.01}}:c)(s))(u)(i)};return J(r=>i=>{if(i.master.tag==="Nothing")return 0<i.cNodes.length?n(r,i.cNodes,i.cNodes[0]):r;if(i.master.tag==="Just")return n(r,i.cNodes,i.master._1);g()})(e)(xt(r=>Ut(r)(e.cGroups))(e.cGroupOrder))},Mp=t=>e=>{const n=mg(e)(t.intervals),r=Zt(o=>Lo(e)(o)==="LT")(t.intervals),i=n.tag==="Just"&&(()=>{const o=_g(e.id)(t.cand);return(o.tag==="Nothing"?!1:o.tag==="Just"&&(o._1.tag==="Nothing"?!1:o._1.tag==="Just"&&o._1._1===n._1.id))&&n._1.cGroup.tag==="Just"&&e.cGroup.tag==="Just"&&n._1.cGroup._1!==e.cGroup._1})()?vt(it)(te)(n._1.id)([e.id])(t.constraints):t.constraints;return{...t,constraints:r.tag==="Just"&&(()=>{const o=_g(r._1.id)(t.cand);return(o.tag==="Nothing"?!1:o.tag==="Just"&&(o._1.tag==="Nothing"?!1:o._1.tag==="Just"&&o._1._1===e.id))&&e.cGroup.tag==="Just"&&r._1.cGroup.tag==="Just"&&e.cGroup._1!==r._1.cGroup._1})()?vt(it)(te)(e.id)([r._1.id])(i):i,intervals:ct(o=>o.id!==e.id,t.intervals)}},Bp=t=>e=>e.low?Pp(t)(e.node):Mp(t)(e.node),Ts=t=>e=>Fp(J(Bp)({intervals:[],cand:Q,constraints:Q})(Lt(Ip)(Tt(ct(t,xt(n=>Ut(n)(e.cNodes))(e.cNodeOrder)))(n=>[{node:n,low:!0},{node:n,low:!1}]))).constraints)(e),zp=t=>Ts(e=>!0)(Ap(pg)(Ts(lg)(xg(pg)(Ts(dg)(xg(Sp)(t)(dg)))(lg)))),Rp=t=>zp(Qp(t.cGraph)),ko=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Ng=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},vs=t=>e=>n=>r=>i=>({id:t,representedEdges:[i],affectedBends:[e,n],hitbox:{x:ko(e._1)(n._1),y:ko(e._2)(n._2),width:qn(e._1-n._1),height:qn(e._2-n._2)},ignoreSpacing:sn,potentialGroupParents:(()=>{if(r.tag==="Nothing")return[];if(r.tag==="Just")return[r._1];g()})(),aPort:T}),Wp=t=>e=>{const n=ko(t.hitbox.x)(e.hitbox.x),r=ko(t.hitbox.y)(e.hitbox.y);return{...t,representedEdges:[...t.representedEdges,...e.representedEdges],affectedBends:[...t.affectedBends,...e.affectedBends],potentialGroupParents:[...t.potentialGroupParents,...e.potentialGroupParents],hitbox:{x:n,y:r,width:Ng(t.hitbox.x+t.hitbox.width)(e.hitbox.x+e.hitbox.width)-n,height:Ng(t.hitbox.y+t.hitbox.height)(e.hitbox.y+e.hitbox.height)-r},ignoreSpacing:{left:t.ignoreSpacing.left||e.ignoreSpacing.left,right:t.ignoreSpacing.right||e.ignoreSpacing.right,up:t.ignoreSpacing.up||e.ignoreSpacing.up,down:t.ignoreSpacing.down||e.ignoreSpacing.down},aPort:(()=>{if(t.aPort.tag==="Just")return t.aPort;if(t.aPort.tag==="Nothing")return e.aPort;g()})()}},Hp=t=>e=>qn(t.hitbox.x-e.hitbox.x)<=1e-4&&e.hitbox.y-(t.hitbox.y+t.hitbox.height)<=1e-4&&t.hitbox.y-(e.hitbox.y+e.hitbox.height)<=1e-4,Op=t=>e=>qn(t.hitbox.x-e.hitbox.x)<=1e-4?st.compare(t.hitbox.y)(e.hitbox.y):t.hitbox.x<e.hitbox.x?ye:xe,Jg=(t,e)=>({tag:t,_1:e}),ws=Kt(C)(Bt),Eo=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Tg=(()=>{const t={eq:n=>r=>n._1===r._1&&(n._2.tag==="Nothing"?r._2.tag==="Nothing":n._2.tag==="Just"&&r._2.tag==="Just"&&n._2._1===r._2._1)},e={compare:n=>r=>{const i=C.compare(n._1)(r._1);if(i==="LT")return ye;if(i==="GT")return xe;if(n._2.tag==="Nothing")return r._2.tag==="Nothing"?Se:ye;if(r._2.tag==="Nothing")return xe;if(n._2.tag==="Just"&&r._2.tag==="Just")return C.compare(n._2._1)(r._2._1);g()},Eq0:()=>t};return J(n=>r=>j(e)(r)()(n))(Q)})(),Sn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},qp=J(t=>e=>j(pp)(e)()(t))(Q),bs=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=sc.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},$p=t=>e=>{const n=ws(H(o=>b(o.id,o))(t)),r=xt(o=>Eo(o)(n))(e),i=it.compare((()=>{const o=Tg(H(u=>b(u.from.node,u.from.port))(r));if(o.tag==="Leaf")return 0;if(o.tag==="Node")return o._2;g()})())((()=>{const o=Tg(H(u=>b(u.to.node,u.to.port))(r));if(o.tag==="Leaf")return 0;if(o.tag==="Node")return o._2;g()})());if(i==="LT")return{...sn,left:!0,right:!1};if(i==="GT")return{...sn,left:!1,right:!0};if(i==="EQ")return sn;g()},Yp=t=>xt(e=>{if(e.direction==="V")return w("Just",{start:e.start,end:e.end});if(e.direction==="H")return T;g()})(t.segments),Go=t=>e=>n=>{if(n.tag==="Just"){const r=Sn(e)(t);if(r.tag==="Just"){const i=Zt(o=>o.id===n._1)(r._1);if(i.tag==="Just")return i._1.side;if(i.tag==="Nothing")return pn;g()}if(r.tag==="Nothing")return pn;g()}if(n.tag==="Nothing")return pn;g()},Vp=t=>e=>n=>{const r=gg({origin:w("Just",Jg("SegmentOrigin",n)),kind:w("Just","vs"),hitbox:n.hitbox})(e.cGraph),i=Jp(r.id)(n.ignoreSpacing)(r.graph);return{...e,cGraph:(()=>{if(0<n.potentialGroupParents.length){const o=Ut(n.potentialGroupParents[0])(i.cNodes);if(o.tag==="Just"){if(o._1.cGroup.tag==="Just")return cg(r.id)(o._1.cGroup._1)(i);if(o._1.cGroup.tag==="Nothing")return i;g()}if(o.tag==="Nothing")return i;g()}return Js({master:w("Just",r.id),nodes:[r.id]})(i).graph})(),edgeToCs:J(o=>u=>vt(C)(te)(u)([r.id])(o))(e.edgeToCs)(n.representedEdges),lockMap:j(it)(r.id)($p(t)(n.representedEdges))(e.lockMap)}},Xp=t=>e=>n=>{const r=Ft(i=>T,i=>o=>w("Just",{head:i,tail:o}),Lt(Op)(e));if(r.tag==="Nothing")return n;if(r.tag==="Just"){const i=J(o=>u=>Hp(o.survivor)(u)?{...o,survivor:Wp(o.survivor)(u)}:{survivor:u,merged:[...o.merged,o.survivor]})({survivor:r._1.head,merged:[]})(r._1.tail);return J(Vp(t))(n)([...i.merged,i.survivor])}g()},Up=t=>({cGraph:{cNodes:Q,cNodeOrder:[],cGroups:Q,cGroupOrder:[],supportedDirections:qp([ug,xs,lp]),predefinedHorizontalConstraints:[],predefinedVerticalConstraints:[],nextCNodeId:0,nextCGroupId:0},nodeToC:Q,edgeToCs:Q,lockMap:Q}),jp=t=>{const e=rt(4);return{x:t.position._1*e,y:t.position._2*e,width:t.size._1*e,height:t.size._2*e}},Zp=t=>e=>n=>J(r=>i=>{const o=gg({origin:w("Just",Jg("NodeOrigin",i.node)),kind:T,hitbox:jp(i)})(r.cGraph),u=Sn(i.node)(t),s=(()=>{if(u.tag==="Nothing")return b(0,0);if(u.tag==="Just")return u._1;g()})();return{...r,cGraph:Js({master:w("Just",o.id),nodes:[o.id]})(o.graph).graph,nodeToC:j(C)(i.node)(o.id)(r.nodeToC),lockMap:j(it)(o.id)((()=>{const a=s._1-s._2|0;return a<0?{...sn,left:!0}:a>0?{...sn,right:!0}:sn})())(r.lockMap)}})(n)(e),Kp=t=>J(e=>n=>vt(C)(r=>i=>b(r._1+i._1|0,r._2+i._2|0))(n.to.node)(b(1,0))(vt(C)(r=>i=>b(r._1+i._1|0,r._2+i._2|0))(n.from.node)(b(0,1))(e)))(Q)(t),tm=t=>J(e=>n=>n.origin.tag==="Just"&&n.origin._1.tag==="NodeOrigin"?j(C)(n.origin._1._1)(n.hitbox.x)(e):e)(Q)(xt(e=>Ut(e)(t.cNodes))(t.cNodeOrder)),em=t=>J(e=>n=>n.origin.tag==="Just"&&n.origin._1.tag==="NodeOrigin"?j(C)(n.origin._1._1)(n.hitbox.x-n.hitboxPreCompaction.x)(e):e)(Q)(xt(e=>Ut(e)(t.cNodes))(t.cNodeOrder)),nm=t=>J(e=>n=>{if(n.origin.tag==="Just"&&n.origin._1.tag==="SegmentOrigin"){const r=n.hitbox.x-n.hitboxPreCompaction.x;return J(i=>o=>j(sc)(o)(r)(i))(e)(n.origin._1._1.affectedBends)}return e})(Q)(xt(e=>Ut(e)(t.cNodes))(t.cNodeOrder)),vg=t=>{const e=ws(H(n=>b(n.id,n))(t.edges));return xt(n=>{const r=Eo(n.edge)(e);if(r.tag==="Just")return n.reversed?w("Just",{edgeId:n.edge,src:r._1.to.node,tgt:r._1.from.node,srcSide:Go(t.ports)(r._1.to.node)(r._1.to.port),tgtSide:Go(t.ports)(r._1.from.node)(r._1.from.port),path:n}):w("Just",{edgeId:n.edge,src:r._1.from.node,tgt:r._1.to.node,srcSide:Go(t.ports)(r._1.from.node)(r._1.from.port),tgtSide:Go(t.ports)(r._1.to.node)(r._1.to.port),path:n});if(r.tag==="Nothing")return T;g()})(t.paths)},rm=t=>e=>{const n=Tt(e)(r=>{if(r.src===r.tgt)return[];if((r.srcSide==="North"||r.srcSide==="South")&&(r.tgtSide==="North"||r.tgtSide==="South"))return[];const i=Sn(r.tgt)(t.nodeToC),o=(()=>{if(i.tag==="Just")return Ut(i._1)(t.cGraph.cNodes);if(i.tag==="Nothing")return T;g()})(),u=Sn(r.src)(t.nodeToC),s=(()=>{if(u.tag==="Just")return Ut(u._1)(t.cGraph.cNodes);if(u.tag==="Nothing")return T;g()})(),a=(()=>{if(s.tag==="Just"){if(o.tag==="Just"){if(s._1.cGroup.tag==="Just"){if(o._1.cGroup.tag==="Just")return w("Just",{srcGroup:s._1.cGroup._1,tgtGroup:o._1.cGroup._1,delta:0,weight:100});if(o._1.cGroup.tag==="Nothing")return T;g()}if(s._1.cGroup.tag==="Nothing")return T;g()}if(o.tag==="Nothing")return T;g()}if(s.tag==="Nothing")return T;g()})(),c=_=>h=>m=>{if(s.tag==="Just"){if(s._1.cGroup.tag==="Just"){if(m.cGroup.tag==="Just")return _(m.hitbox.x)&&m.cGroup._1!==s._1.cGroup._1?w("Just",h(m.cGroup._1)(s._1.cGroup._1)):T;if(m.cGroup.tag==="Nothing")return T;g()}if(s._1.cGroup.tag==="Nothing")return T;g()}if(s.tag==="Nothing")return T;g()},f=xt(_=>Ut(_)(t.cGraph.cNodes))((()=>{const _=Eo(r.edgeId)(t.edgeToCs);if(_.tag==="Nothing")return[];if(_.tag==="Just")return _._1;g()})()),d=(()=>{if(s.tag==="Just"&&r.srcSide==="West"){const _=s._1;return xt(c(h=>h<_.hitbox.x)(h=>m=>({srcGroup:h,tgtGroup:m,delta:1,weight:100})))(f)}return[]})(),l=(()=>{if(s.tag==="Just"&&r.tgtSide==="East"){const _=s._1;return xt(c(h=>h>_.hitbox.x)(h=>m=>({srcGroup:m,tgtGroup:h,delta:1,weight:100})))(f)}return[]})();if(a.tag==="Nothing")return[];if(a.tag==="Just")return[a._1,...d,...l];g()});return{sameEdgeVerticalSegments:r=>i=>r.origin.tag==="Just"&&r.origin._1.tag==="SegmentOrigin"&&i.origin.tag==="Just"&&i.origin._1.tag==="SegmentOrigin"&&(()=>{const o=i.origin._1._1;return Me(u=>Be(gn)(u)(o.representedEdges),r.origin._1._1.representedEdges)})(),vsLNodePair:r=>i=>r.origin.tag==="Just"&&i.origin.tag==="Just"&&(r.origin._1.tag==="SegmentOrigin"?i.origin._1.tag==="NodeOrigin":r.origin._1.tag==="NodeOrigin"&&i.origin._1.tag==="SegmentOrigin"),edgeLengthEdges:r=>n}},im=t=>e=>{const n=rt(4),r=tm(t),i=em(t),o=ws(H(s=>b(s.id,b(s.from.node,s.to.node)))(e.edges)),u=nm(t);return{nodes:H(s=>{const a=Sn(s.node)(r);if(a.tag==="Just")return{...s,position:b(a._1/n,s.position._2)};if(a.tag==="Nothing")return s;g()})(e.nodes),edges:H(s=>{const a=Eo(s.edge)(o),c=(()=>{if(a.tag==="Nothing")return s.segments;if(a.tag==="Just"){const f=Sn(a._1._1)(i),d=(()=>{if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1;g()})(),l=Sn(a._1._2)(i),_=(()=>{if(l.tag==="Nothing")return 0;if(l.tag==="Just")return l._1;g()})();return Qt((()=>{const h=s.reversed?_:d,m=s.reversed?d:_,p=s.segments.length;return y=>x=>{if(x.direction==="V"){const N=(()=>{if(y===0)return h;if(y===(p-1|0))return m;const v=bs(x.start)(u);if(v.tag==="Nothing")return 0;if(v.tag==="Just")return v._1;g()})();return{...x,start:b(x.start._1+N,x.start._2),end:b(x.end._1+N,x.end._2)}}if(x.direction==="H")return{...x,start:b((()=>{if(y===0)return x.start._1+h;const N=bs(x.start)(u);if(N.tag==="Nothing")return x.start._1+0;if(N.tag==="Just")return x.start._1+N._1;g()})(),x.start._2),end:b((()=>{if(y===(p-1|0))return x.end._1+m;const N=bs(x.end)(u);if(N.tag==="Nothing")return x.end._1+0;if(N.tag==="Just")return x.end._1+N._1;g()})(),x.end._2)};g()}})())(s.segments)}g()})();return{...s,segments:c,bends:Je(f=>d=>f.end,c,bt(1,c.length,c))}})(e.paths)}},om=t=>e=>n=>r=>i=>o=>{const u=vs(i.nextId)(o._2.start)(o._2.end)(T)(t.edgeId),s=(()=>{if(o._1===0){if(e.tag==="Nothing")return u;if(e.tag==="Just")return{...u,ignoreSpacing:o._2.end._2<e._1.y?{...u.ignoreSpacing,down:!0}:o._2.end._2>e._1.y+e._1.height?{...u.ignoreSpacing,up:!0}:{...u.ignoreSpacing,up:!0,down:!0}};g()}return u})();return{nextId:i.nextId+1|0,segments:[...i.segments,(()=>{if(o._1===r){if(n.tag==="Nothing")return s;if(n.tag==="Just")return{...s,ignoreSpacing:o._2.start._2<n._1.y?{...s.ignoreSpacing,down:!0}:o._2.start._2>n._1.y+n._1.height?{...s.ignoreSpacing,up:!0}:{...s.ignoreSpacing,up:!0,down:!0}};g()}return s})()]}},wg=t=>e=>n=>r=>i=>o=>({nextId:o.nextId+1|0,segments:[...o.segments,{...vs(o.nextId)(r.start)(b(r.start._1,i.down?n.y:n.y+n.height))(w("Just",e))(t.edgeId),aPort:w("Just",{node:t.src,side:i.side}),ignoreSpacing:i.down?{...sn,down:!0}:{...sn,up:!0}}]}),Co=t=>e=>n=>r=>i=>o=>({nextId:o.nextId+1|0,segments:[...o.segments,{...vs(o.nextId)(r.end)(b(r.end._1,i.down?n.y:n.y+n.height))(w("Just",e))(t.edgeId),aPort:w("Just",{node:t.tgt,side:i.side}),ignoreSpacing:i.down?{...sn,down:!0}:{...sn,up:!0}}]}),um=t=>e=>n=>{const r=Sn(n.src)(t.nodeToC),i=Sn(n.tgt)(t.nodeToC),o=(()=>{if(r.tag==="Just"){const f=Ut(r._1)(t.cGraph.cNodes);return f.tag==="Just"?w("Just",f._1.hitbox):T}if(r.tag==="Nothing")return T;g()})(),u=(()=>{if(i.tag==="Just"){const f=Ut(i._1)(t.cGraph.cNodes);return f.tag==="Just"?w("Just",f._1.hitbox):T}if(i.tag==="Nothing")return T;g()})(),s=Yp(n.path),a=J(om(n)(o)(u)(s.length-1|0))(e)(Qt(f=>d=>b(f,d))(s));if(0<s.length){const f=(()=>{if(r.tag==="Just"&&o.tag==="Just"){if(n.srcSide==="North")return wg(n)(r._1)(o._1)(s[0])({side:le,down:!0})(a);if(n.srcSide==="South")return wg(n)(r._1)(o._1)(s[0])({side:he,down:!1})(a)}return a})(),d=s.length-1|0;if(d>=0&&d<s.length&&i.tag==="Just"&&u.tag==="Just"){if(n.tgtSide==="North")return Co(n)(i._1)(u._1)(s[d])({side:le,down:!0})(f);if(n.tgtSide==="South")return Co(n)(i._1)(u._1)(s[d])({side:he,down:!1})(f)}return f}const c=s.length-1|0;if(c>=0&&c<s.length&&i.tag==="Just"&&u.tag==="Just"){if(n.tgtSide==="North")return Co(n)(i._1)(u._1)(s[c])({side:le,down:!0})(a);if(n.tgtSide==="South")return Co(n)(i._1)(u._1)(s[c])({side:he,down:!1})(a)}return a},sm=t=>e=>n=>Xp(t)(J(um(n))({nextId:0,segments:[]})(e).segments)(n),am=t=>sm(t.edges)(vg(t))(Zp(Kp(t.edges))(t.nodes)(Up())),Dn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Ls=t=>e=>{const n=it.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},ks=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},cm=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},gm=t=>{const e=t.Eq0();return n=>r=>{const i=s=>{let a=s,c=!0,f;for(;c;){const d=a,l=Ft(_=>T,_=>h=>w("Just",{head:_,tail:h}),d.queue);if(l.tag==="Nothing"){c=!1,f=d;continue}if(l.tag==="Just"){const _=l._1.head;if((m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=!1;continue}if(N.tag==="Node"){const v=t.compare(_)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=!0;continue}}g()}return x})(d.removedNodes)){a={...d,queue:l._1.tail};continue}const h=Zt(m=>!Dn(m.eid)(d.removedEdges)&&(e.eq(m.src)(_)||e.eq(m.tgt)(_)))(r);if(h.tag==="Nothing"){a={...d,queue:l._1.tail};continue}if(h.tag==="Just"){const m=e.eq(h._1.src)(_)?h._1.tgt:h._1.src,p={...d,degree:j(t)(m)((()=>{const y=(x=>{let N=x,v=!0,k;for(;v;){const L=N;if(L.tag==="Leaf"){v=!1,k=T;continue}if(L.tag==="Node"){const E=t.compare(m)(L._3);if(E==="LT"){N=L._5;continue}if(E==="GT"){N=L._6;continue}if(E==="EQ"){v=!1,k=w("Just",L._4);continue}}g()}return k})(d.degree);if(y.tag==="Nothing")return-1;if(y.tag==="Just")return y._1-1|0;g()})())(d.degree),removedNodes:j(t)(_)()(d.removedNodes),removedEdges:j(it)(h._1.eid)()(d.removedEdges),record:[...d.record,{node:_,neighbour:m,viaSrc:e.eq(h._1.src)(_)}],queue:l._1.tail};if((()=>{const y=(N=>{let v=N,k=!0,L;for(;k;){const E=v;if(E.tag==="Leaf"){k=!1,L=T;continue}if(E.tag==="Node"){const B=t.compare(m)(E._3);if(B==="LT"){v=E._5;continue}if(B==="GT"){v=E._6;continue}if(B==="EQ"){k=!1,L=w("Just",E._4);continue}}g()}return L})(p.degree),x=N=>{let v=N,k=!0,L;for(;k;){const E=v;if(E.tag==="Leaf"){k=!1,L=!1;continue}if(E.tag==="Node"){const B=t.compare(m)(E._3);if(B==="LT"){v=E._5;continue}if(B==="GT"){v=E._6;continue}if(B==="EQ"){k=!1,L=!0;continue}}g()}return L};return(()=>{if(y.tag==="Nothing")return!1;if(y.tag==="Just")return y._1===1;g()})()&&!x(p.removedNodes)})()){a={...p,queue:[...p.queue,m]};continue}a=p;continue}}g()}return f},o=J(s=>a=>vt(t)(oe)(a.src)(1)(vt(t)(oe)(a.tgt)(1)(s)))(Q)(r),u=i({degree:o,removedNodes:Q,removedEdges:Q,record:[],queue:ct(s=>{const a=(c=>{let f=c,d=!0,l;for(;d;){const _=f;if(_.tag==="Leaf"){d=!1,l=T;continue}if(_.tag==="Node"){const h=t.compare(s)(_._3);if(h==="LT"){f=_._5;continue}if(h==="GT"){f=_._6;continue}if(h==="EQ"){d=!1,l=w("Just",_._4);continue}}g()}return l})(o);if(a.tag==="Nothing")return!1;if(a.tag==="Just")return a._1===1;g()},n)});return{coreNodes:ct(s=>!(a=>{let c=a,f=!0,d;for(;f;){const l=c;if(l.tag==="Leaf"){f=!1,d=!1;continue}if(l.tag==="Node"){const _=t.compare(s)(l._3);if(_==="LT"){c=l._5;continue}if(_==="GT"){c=l._6;continue}if(_==="EQ"){f=!1,d=!0;continue}}g()}return d})(u.removedNodes),n),coreEdges:ct(s=>!Dn(s.eid)(u.removedEdges),r),removed:u.record}}},fm=t=>e=>n=>J(r=>i=>{const o=i.neighbour,u=(()=>{const s=(a=>{let c=a,f=!0,d;for(;f;){const l=c;if(l.tag==="Leaf"){f=!1,d=T;continue}if(l.tag==="Node"){const _=t.compare(o)(l._3);if(_==="LT"){c=l._5;continue}if(_==="GT"){c=l._6;continue}if(_==="EQ"){f=!1,d=w("Just",l._4);continue}}g()}return d})(r);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})();return j(t)(i.node)(i.viaSrc?u-1|0:u+1|0)(r)})(n)(ke(e)),Es=t=>{const e=t.Eq0();return n=>r=>i=>{const o={...i,treeNode:j(t)(r)()(i.treeNode)};return J(u=>s=>{if(Dn(s.eid)(u.st.edgeVisited))return u;const a={...u.st,edgeVisited:j(it)(s.eid)()(u.st.edgeVisited)},c=e.eq(s.src)((()=>{const f=s.src,d=_=>{let h=_,m=!0,p;for(;m;){const y=h;if(y.tag==="Leaf"){m=!1,p=!1;continue}if(y.tag==="Node"){const x=t.compare(f)(y._3);if(x==="LT"){h=y._5;continue}if(x==="GT"){h=y._6;continue}if(x==="EQ"){m=!1,p=!0;continue}}g()}return p},l=s.tgt;return d(a.treeNode)&&!(_=>{let h=_,m=!0,p;for(;m;){const y=h;if(y.tag==="Leaf"){m=!1,p=!1;continue}if(y.tag==="Node"){const x=t.compare(l)(y._3);if(x==="LT"){h=y._5;continue}if(x==="GT"){h=y._6;continue}if(x==="EQ"){m=!1,p=!0;continue}}g()}return p})(a.treeNode)})()?s.src:(()=>{const f=s.tgt,d=_=>{let h=_,m=!0,p;for(;m;){const y=h;if(y.tag==="Leaf"){m=!1,p=!1;continue}if(y.tag==="Node"){const x=t.compare(f)(y._3);if(x==="LT"){h=y._5;continue}if(x==="GT"){h=y._6;continue}if(x==="EQ"){m=!1,p=!0;continue}}g()}return p},l=s.src;return d(a.treeNode)&&!(_=>{let h=_,m=!0,p;for(;m;){const y=h;if(y.tag==="Leaf"){m=!1,p=!1;continue}if(y.tag==="Node"){const x=t.compare(l)(y._3);if(x==="LT"){h=y._5;continue}if(x==="GT"){h=y._6;continue}if(x==="EQ"){m=!1,p=!0;continue}}g()}return p})(a.treeNode)})()?s.tgt:s.src)?s.tgt:s.src;if(Dn(s.eid)(a.treeEdge)){if((d=>{let l=d,_=!0,h;for(;_;){const m=l;if(m.tag==="Leaf"){_=!1,h=!1;continue}if(m.tag==="Node"){const p=t.compare(c)(m._3);if(p==="LT"){l=m._5;continue}if(p==="GT"){l=m._6;continue}if(p==="EQ"){_=!1,h=!0;continue}}g()}return h})(a.treeNode))return{...u,st:a};const f=Es(t)(n)(c)(a);return{count:u.count+f.count|0,st:f.st}}if((()=>{const f=l=>{let _=l,h=!0,m;for(;h;){const p=_;if(p.tag==="Leaf"){h=!1,m=!1;continue}if(p.tag==="Node"){const y=t.compare(c)(p._3);if(y==="LT"){_=p._5;continue}if(y==="GT"){_=p._6;continue}if(y==="EQ"){h=!1,m=!0;continue}}g()}return m},d=s.tgt;return!f(a.treeNode)&&(()=>{const l=(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=T;continue}if(N.tag==="Node"){const v=t.compare(d)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=w("Just",N._4);continue}}g()}return x})(a.layer),_=s.src,h=(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=T;continue}if(N.tag==="Node"){const v=t.compare(_)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=w("Just",N._4);continue}}g()}return x})(a.layer);if(l.tag==="Nothing"){if(h.tag==="Nothing")return s.delta===0;if(h.tag==="Just")return s.delta===-h._1;g()}if(l.tag==="Just"){if(h.tag==="Nothing")return s.delta===(l._1-0|0);if(h.tag==="Just")return s.delta===(l._1-h._1|0)}g()})()})()){const f=Es(t)(n)(c)({...a,treeEdge:j(it)(s.eid)()(a.treeEdge)});return{count:u.count+f.count|0,st:f.st}}return{...u,st:a}})({count:1,st:o})(ct(u=>(e.eq(u.src)(r)||e.eq(u.tgt)(r))&&!Dn(u.eid)(o.edgeVisited),n))}},So=t=>e=>n=>r=>{const i=r.src,o=(l=>{let _=l,h=!0,m;for(;h;){const p=_;if(p.tag==="Leaf"){h=!1,m=T;continue}if(p.tag==="Node"){const y=t.compare(i)(p._3);if(y==="LT"){_=p._5;continue}if(y==="GT"){_=p._6;continue}if(y==="EQ"){h=!1,m=w("Just",p._4);continue}}g()}return m})(e.poID),u=(()=>{if(o.tag==="Nothing")return 0;if(o.tag==="Just")return o._1;g()})(),s=r.tgt,a=(l=>{let _=l,h=!0,m;for(;h;){const p=_;if(p.tag==="Leaf"){h=!1,m=T;continue}if(p.tag==="Node"){const y=t.compare(s)(p._3);if(y==="LT"){_=p._5;continue}if(y==="GT"){_=p._6;continue}if(y==="EQ"){h=!1,m=w("Just",p._4);continue}}g()}return m})(e.poID),c=(()=>{if(a.tag==="Nothing")return 0;if(a.tag==="Just")return a._1;g()})(),f=(l=>{let _=l,h=!0,m;for(;h;){const p=_;if(p.tag==="Leaf"){h=!1,m=T;continue}if(p.tag==="Node"){const y=t.compare(n)(p._3);if(y==="LT"){_=p._5;continue}if(y==="GT"){_=p._6;continue}if(y==="EQ"){h=!1,m=w("Just",p._4);continue}}g()}return m})(e.poID),d=(()=>{if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1;g()})();return(()=>{const l=r.src,_=(h=>{let m=h,p=!0,y;for(;p;){const x=m;if(x.tag==="Leaf"){p=!1,y=T;continue}if(x.tag==="Node"){const N=t.compare(l)(x._3);if(N==="LT"){m=x._5;continue}if(N==="GT"){m=x._6;continue}if(N==="EQ"){p=!1,y=w("Just",x._4);continue}}g()}return y})(e.lowestPoID);return(()=>{if(_.tag==="Nothing")return 0<=d;if(_.tag==="Just")return _._1<=d;g()})()&&(()=>{const h=r.tgt;return d<=u&&(()=>{const m=(p=>{let y=p,x=!0,N;for(;x;){const v=y;if(v.tag==="Leaf"){x=!1,N=T;continue}if(v.tag==="Node"){const k=t.compare(h)(v._3);if(k==="LT"){y=v._5;continue}if(k==="GT"){y=v._6;continue}if(k==="EQ"){x=!1,N=w("Just",v._4);continue}}g()}return N})(e.lowestPoID);return(()=>{if(m.tag==="Nothing")return 0<=d;if(m.tag==="Just")return m._1<=d;g()})()&&d<=c})()})()})()?u>=c:u<c},_m=t=>{const e=Kt(t)(Bt);return n=>({layer:e(H(r=>b(r,0))(n)),treeNode:Q,treeEdge:Q,poID:Q,lowestPoID:Q,cutvalue:Q,postOrder:1,edgeVisited:Q})},dm=t=>e=>n=>J(r=>i=>{if((()=>{const f=i.src,d=h=>{let m=h,p=!0,y;for(;p;){const x=m;if(x.tag==="Leaf"){p=!1,y=!1;continue}if(x.tag==="Node"){const N=t.compare(f)(x._3);if(N==="LT"){m=x._5;continue}if(N==="GT"){m=x._6;continue}if(N==="EQ"){p=!1,y=!0;continue}}g()}return y},l=i.tgt,_=h=>{let m=h,p=!0,y;for(;p;){const x=m;if(x.tag==="Leaf"){p=!1,y=!1;continue}if(x.tag==="Node"){const N=t.compare(l)(x._3);if(N==="LT"){m=x._5;continue}if(N==="GT"){m=x._6;continue}if(N==="EQ"){p=!1,y=!0;continue}}g()}return y};return d(n.treeNode)===_(n.treeNode)})())return r;const o=i.tgt,u=(f=>{let d=f,l=!0,_;for(;l;){const h=d;if(h.tag==="Leaf"){l=!1,_=T;continue}if(h.tag==="Node"){const m=t.compare(o)(h._3);if(m==="LT"){d=h._5;continue}if(m==="GT"){d=h._6;continue}if(m==="EQ"){l=!1,_=w("Just",h._4);continue}}g()}return _})(n.layer),s=i.src,a=(f=>{let d=f,l=!0,_;for(;l;){const h=d;if(h.tag==="Leaf"){l=!1,_=T;continue}if(h.tag==="Node"){const m=t.compare(s)(h._3);if(m==="LT"){d=h._5;continue}if(m==="GT"){d=h._6;continue}if(m==="EQ"){l=!1,_=w("Just",h._4);continue}}g()}return _})(n.layer),c=(()=>{if(u.tag==="Nothing"){if(a.tag==="Nothing")return-i.delta;if(a.tag==="Just")return-a._1-i.delta|0;g()}if(u.tag==="Just"){if(a.tag==="Nothing")return(u._1-0|0)-i.delta|0;if(a.tag==="Just")return(u._1-a._1|0)-i.delta|0}g()})();return c<r.slack?{edge:w("Just",i),slack:c}:r})({edge:T,slack:1e9})(e).edge,lm=t=>{const e=Kt(t)(Bt);return n=>r=>{const i=J(o=>u=>Ls(o)((()=>{const s=(a=>{let c=a,f=!0,d;for(;f;){const l=c;if(l.tag==="Leaf"){f=!1,d=T;continue}if(l.tag==="Node"){const _=t.compare(u)(l._3);if(_==="LT"){c=l._5;continue}if(_==="GT"){c=l._6;continue}if(_==="EQ"){f=!1,d=w("Just",l._4);continue}}g()}return d})(r);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(1e9)(n);return e(H(o=>b(o,(()=>{const u=(s=>{let a=s,c=!0,f;for(;c;){const d=a;if(d.tag==="Leaf"){c=!1,f=T;continue}if(d.tag==="Node"){const l=t.compare(o)(d._3);if(l==="LT"){a=d._5;continue}if(l==="GT"){a=d._6;continue}if(l==="EQ"){c=!1,f=w("Just",d._4);continue}}g()}return f})(r);if(u.tag==="Nothing")return-i;if(u.tag==="Just")return u._1-i|0;g()})()))(n))}},bg=t=>{const e=t.Eq0();return n=>r=>i=>{const o=J(s=>a=>{const c=bg(t)(n)(e.eq(a.src)(r)?a.tgt:a.src)({...s.st,edgeVisited:j(it)(a.eid)()(s.st.edgeVisited)});return{lowest:Ls(s.lowest)(c.lowest),st:c.st}})({lowest:1e9,st:i})(ct(s=>Dn(s.eid)(i.treeEdge)&&(e.eq(s.src)(r)||e.eq(s.tgt)(r))&&!Dn(s.eid)(i.edgeVisited),n)),u=Ls(o.lowest)(o.st.postOrder);return{lowest:u,st:{...o.st,poID:j(t)(r)(o.st.postOrder)(o.st.poID),lowestPoID:j(t)(r)(u)(o.st.lowestPoID),postOrder:o.st.postOrder+1|0}}}},Lg=t=>{const e=bg(t);return n=>r=>i=>0<n.length?e(r)(n[0])({...i,edgeVisited:Q,postOrder:1,poID:Q,lowestPoID:Q}).st:i},hm=t=>{const e=t.Eq0();return n=>r=>i=>ct(o=>Dn(o.eid)(r.treeEdge)&&(e.eq(o.src)(i)||e.eq(o.tgt)(i)),n)},pm=t=>e=>Zt(n=>{const r=ks(n.eid)(e.cutvalue);return Dn(n.eid)(e.treeEdge)&&(()=>{if(r.tag==="Nothing")return!1;if(r.tag==="Just")return r._1<-1e-10;g()})()})(t),kg=t=>{const e=Es(t);return n=>r=>i=>{const o=0<n.length?w("Just",n[0]):T;if(o.tag==="Nothing")return i;if(o.tag==="Just"){const u=e(r)(o._1)({...i,edgeVisited:Q,treeNode:Q,treeEdge:Q});if(u.count>=n.length)return u.st;const s=dm(t)(r)(u.st);if(s.tag==="Nothing")return u.st;if(s.tag==="Just"){const a=s._1.tgt,c=(h=>{let m=h,p=!0,y;for(;p;){const x=m;if(x.tag==="Leaf"){p=!1,y=T;continue}if(x.tag==="Node"){const N=t.compare(a)(x._3);if(N==="LT"){m=x._5;continue}if(N==="GT"){m=x._6;continue}if(N==="EQ"){p=!1,y=w("Just",x._4);continue}}g()}return y})(u.st.layer),f=s._1.src,d=(h=>{let m=h,p=!0,y;for(;p;){const x=m;if(x.tag==="Leaf"){p=!1,y=T;continue}if(x.tag==="Node"){const N=t.compare(f)(x._3);if(N==="LT"){m=x._5;continue}if(N==="GT"){m=x._6;continue}if(N==="EQ"){p=!1,y=w("Just",x._4);continue}}g()}return y})(u.st.layer),l=(()=>{if(c.tag==="Nothing"){if(d.tag==="Nothing")return-s._1.delta;if(d.tag==="Just")return-d._1-s._1.delta|0;g()}if(c.tag==="Just"){if(d.tag==="Nothing")return(c._1-0|0)-s._1.delta|0;if(d.tag==="Just")return(c._1-d._1|0)-s._1.delta|0}g()})(),_=(()=>{const h=s._1.tgt;return(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=!1;continue}if(N.tag==="Node"){const v=t.compare(h)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=!0;continue}}g()}return x})(u.st.treeNode)})()?-l:l;return kg(t)(n)(r)({...u.st,layer:J(h=>m=>(p=>{let y=p,x=!0,N;for(;x;){const v=y;if(v.tag==="Leaf"){x=!1,N=!1;continue}if(v.tag==="Node"){const k=t.compare(m)(v._3);if(k==="LT"){y=v._5;continue}if(k==="GT"){y=v._6;continue}if(k==="EQ"){x=!1,N=!0;continue}}g()}return N})(u.st.treeNode)?j(t)(m)((()=>{const p=(y=>{let x=y,N=!0,v;for(;N;){const k=x;if(k.tag==="Leaf"){N=!1,v=T;continue}if(k.tag==="Node"){const L=t.compare(m)(k._3);if(L==="LT"){x=k._5;continue}if(L==="GT"){x=k._6;continue}if(L==="EQ"){N=!1,v=w("Just",k._4);continue}}g()}return v})(u.st.layer);if(p.tag==="Nothing")return 0+_|0;if(p.tag==="Just")return p._1+_|0;g()})())(h):h)(u.st.layer)(n)})}}g()}},mm=t=>e=>n=>r=>J(i=>o=>{if(So(t)(r)(o.src)(n)&&!So(t)(r)(o.tgt)(n)){const u=o.tgt,s=(d=>{let l=d,_=!0,h;for(;_;){const m=l;if(m.tag==="Leaf"){_=!1,h=T;continue}if(m.tag==="Node"){const p=t.compare(u)(m._3);if(p==="LT"){l=m._5;continue}if(p==="GT"){l=m._6;continue}if(p==="EQ"){_=!1,h=w("Just",m._4);continue}}g()}return h})(r.layer),a=o.src,c=(d=>{let l=d,_=!0,h;for(;_;){const m=l;if(m.tag==="Leaf"){_=!1,h=T;continue}if(m.tag==="Node"){const p=t.compare(a)(m._3);if(p==="LT"){l=m._5;continue}if(p==="GT"){l=m._6;continue}if(p==="EQ"){_=!1,h=w("Just",m._4);continue}}g()}return h})(r.layer),f=(()=>{if(s.tag==="Nothing"){if(c.tag==="Nothing")return-o.delta;if(c.tag==="Just")return-c._1-o.delta|0;g()}if(s.tag==="Just"){if(c.tag==="Nothing")return(s._1-0|0)-o.delta|0;if(c.tag==="Just")return(s._1-c._1|0)-o.delta|0}g()})();if(f<i.slack)return{edge:w("Just",o),slack:f}}return i})({edge:T,slack:1e9})(e).edge,ym=t=>{const e=t.Eq0();return n=>r=>i=>o=>{const u=o.tgt,s=o.src;return J(a=>c=>{if((()=>{const f=ks(c.eid)(r.cutvalue);if(f.tag==="Just")return!0;if(f.tag==="Nothing")return!1;g()})()){const f=ks(c.eid)(r.cutvalue),d=(()=>{if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1;g()})();return e.eq(s)(c.src)||e.eq(u)(c.tgt)?a-(d-c.weight):a+(d-c.weight)}return e.eq(i)(s)?e.eq(c.src)(i)?a+c.weight:a-c.weight:e.eq(c.src)(i)?a-c.weight:a+c.weight})(o.weight)(ct(a=>a.eid!==o.eid&&(e.eq(a.src)(i)||e.eq(a.tgt)(i)),n))}},xm=t=>{const e=ym(t);return n=>r=>i=>{const o=(u,s,a)=>{const c=(f=>{let d=f,l=!0,_;for(;l;){const h=d;if(h.tag==="Leaf"){l=!1,_=T;continue}if(h.tag==="Node"){const m=t.compare(u)(h._3);if(m==="LT"){d=h._5;continue}if(m==="GT"){d=h._6;continue}if(m==="EQ"){l=!1,_=w("Just",h._4);continue}}g()}return _})(a);if(c.tag==="Just")return j(t)(u)(ct(f=>f.eid!==s.eid,c._1))(a);if(c.tag==="Nothing")return a;g()};return(u=>s=>{let a=u,c=s,f=!0,d;for(;f;){const l=a,_=c,h=(p=>{let y=p,x=!0,N;for(;x;){const v=y;if(v.tag==="Leaf"){x=!1,N=T;continue}if(v.tag==="Node"){const k=t.compare(_)(v._3);if(k==="LT"){y=v._5;continue}if(k==="GT"){y=v._6;continue}if(k==="EQ"){x=!1,N=w("Just",v._4);continue}}g()}return N})(l.unknown),m=(()=>{if(h.tag==="Nothing")return[];if(h.tag==="Just")return h._1;g()})();if(m.length===1){const p=t.Eq0().eq(m[0].src)(_)?m[0].tgt:m[0].src;a={unknown:o(_,m[0],o(p,m[0],l.unknown)),cutvalue:j(it)(m[0].eid)(e(n)(l)(_)(m[0]))(l.cutvalue)},c=p;continue}f=!1,d=l}return d})(r)(i)}},Eg=t=>{const e=t.Eq0(),n=t.Eq0(),r={eq:c=>f=>c.delta===f.delta&&c.eid===f.eid&&n.eq(c.src)(f.src)&&e.eq(c.tgt)(f.tgt)&&c.weight===f.weight},i={compare:c=>f=>{const d=it.compare(c.delta)(f.delta);if(d==="LT"||d==="GT"||d!=="EQ")return d;const l=it.compare(c.eid)(f.eid);if(l==="LT"||l==="GT"||l!=="EQ")return l;const _=t.compare(c.src)(f.src);if(_==="LT"||_==="GT"||_!=="EQ")return _;const h=t.compare(c.tgt)(f.tgt);if(h==="LT"||h==="GT"||h!=="EQ")return h;const m=st.compare(c.weight)(f.weight);return m==="LT"||m==="GT"||m!=="EQ"?m:Se},Eq0:()=>r},o=J(c=>f=>j(i)(f)()(c))(Q),u=hm(t),s=Kt(t)(Bt),a=xm(t);return c=>f=>d=>{const l={unknown:s(H(_=>b(_,kt(Re.foldr,o(u(f)(d)(_)))))(c)),cutvalue:Q};return{...d,cutvalue:J(a(f))(l)(ct(_=>{const h=(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=T;continue}if(N.tag==="Node"){const v=t.compare(_)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=w("Just",N._4);continue}}g()}return x})(l.unknown);if(h.tag==="Nothing")return!1;if(h.tag==="Just")return h._1.length===1;g()},c)).cutvalue}}},Nm=t=>{const e=Lg(t),n=Eg(t);return r=>i=>o=>u=>s=>{const a={...s,treeEdge:j(it)(u.eid)()(ni(it)(o.eid)(s.treeEdge))},c=u.tgt,f=(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=T;continue}if(N.tag==="Node"){const v=t.compare(c)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=w("Just",N._4);continue}}g()}return x})(a.layer),d=u.src,l=(m=>{let p=m,y=!0,x;for(;y;){const N=p;if(N.tag==="Leaf"){y=!1,x=T;continue}if(N.tag==="Node"){const v=t.compare(d)(N._3);if(v==="LT"){p=N._5;continue}if(v==="GT"){p=N._6;continue}if(v==="EQ"){y=!1,x=w("Just",N._4);continue}}g()}return x})(a.layer),_=(()=>{if(f.tag==="Nothing"){if(l.tag==="Nothing")return-u.delta;if(l.tag==="Just")return-l._1-u.delta|0;g()}if(f.tag==="Just"){if(l.tag==="Nothing")return(f._1-0|0)-u.delta|0;if(l.tag==="Just")return(f._1-l._1|0)-u.delta|0}g()})(),h=So(t)(a)(u.tgt)(o)?_:-_;return n(r)(i)(e(r)(i)({...a,layer:J(m=>p=>So(t)(a)(p)(o)?m:j(t)(p)((()=>{const y=(x=>{let N=x,v=!0,k;for(;v;){const L=N;if(L.tag==="Leaf"){v=!1,k=T;continue}if(L.tag==="Node"){const E=t.compare(p)(L._3);if(E==="LT"){N=L._5;continue}if(E==="GT"){N=L._6;continue}if(E==="EQ"){v=!1,k=w("Just",L._4);continue}}g()}return k})(a.layer);if(y.tag==="Nothing")return 0+h|0;if(y.tag==="Just")return y._1+h|0;g()})())(m))(a.layer)(r)}))}},Jm=t=>{const e=Nm(t);return n=>r=>i=>o=>(u=>s=>{let a=u,c=s,f=!0,d;for(;f;){const l=a,_=c;if(l===0){f=!1,d=_;continue}const h=pm(i)(_);if(h.tag==="Nothing"){f=!1,d=_;continue}if(h.tag==="Just"){const m=mm(t)(i)(h._1)(_);if(m.tag==="Nothing"){f=!1,d=_;continue}if(m.tag==="Just"){a=l-1|0,c=e(r)(i)(h._1)(m._1)(_);continue}}g()}return d})(n)(o)},Tm=t=>{const e=Eg(t),n=Lg(t),r=kg(t);return i=>o=>u=>e(i)(o)(n(i)(o)(r(i)(o)(u)))},Gg=t=>e=>J(n=>r=>vt(t)(te)(e(r))([r])(n))(Q),vm=t=>{const e=Kt(t)(Bt);return n=>r=>i=>{const o=a=>c=>f=>d=>{let l=a,_=c,h=f,m=d,p=!0,y;for(;p;){const x=l,N=_,v=h,k=m,L=Ft(E=>T,E=>B=>w("Just",{head:E,tail:B}),v);if(L.tag==="Nothing"){p=!1,y=k;continue}if(L.tag==="Just"){const E=L._1.head,B=(D=>{let S=D,Z=!0,X;for(;Z;){const W=S;if(W.tag==="Leaf"){Z=!1,X=T;continue}if(W.tag==="Node"){const z=t.compare(E)(W._3);if(z==="LT"){S=W._5;continue}if(z==="GT"){S=W._6;continue}if(z==="EQ"){Z=!1,X=w("Just",W._4);continue}}g()}return X})(k.layer),V=(()=>{if(B.tag==="Nothing")return 0;if(B.tag==="Just")return B._1;g()})(),et=J(D=>S=>{const Z=S.tgt,X=(z=>{let M=z,G=!0,P;for(;G;){const I=M;if(I.tag==="Leaf"){G=!1,P=T;continue}if(I.tag==="Node"){const F=t.compare(Z)(I._3);if(F==="LT"){M=I._5;continue}if(F==="GT"){M=I._6;continue}if(F==="EQ"){G=!1,P=w("Just",I._4);continue}}g()}return P})(D.incident),W=(()=>{if(X.tag==="Nothing")return-1;if(X.tag==="Just")return X._1-1|0;g()})();return{st:{...D.st,layer:j(t)(S.tgt)(cm((()=>{const z=S.tgt,M=(G=>{let P=G,I=!0,F;for(;I;){const O=P;if(O.tag==="Leaf"){I=!1,F=T;continue}if(O.tag==="Node"){const Y=t.compare(z)(O._3);if(Y==="LT"){P=O._5;continue}if(Y==="GT"){P=O._6;continue}if(Y==="EQ"){I=!1,F=w("Just",O._4);continue}}g()}return F})(D.st.layer);if(M.tag==="Nothing")return 0;if(M.tag==="Just")return M._1;g()})())(V+S.delta|0))(D.st.layer)},incident:j(t)(S.tgt)(W)(D.incident),queue:W===0?[...D.queue,S.tgt]:D.queue}})({st:k,incident:N,queue:L._1.tail})((()=>{const D=(S=>{let Z=S,X=!0,W;for(;X;){const z=Z;if(z.tag==="Leaf"){X=!1,W=T;continue}if(z.tag==="Node"){const M=t.compare(E)(z._3);if(M==="LT"){Z=z._5;continue}if(M==="GT"){Z=z._6;continue}if(M==="EQ"){X=!1,W=w("Just",z._4);continue}}g()}return W})(x);if(D.tag==="Nothing")return[];if(D.tag==="Just")return D._1;g()})());l=x,_=et.incident,h=et.queue,m=et.st;continue}g()}return y},u=Gg(t)(a=>a.tgt)(r),s=e(H(a=>b(a,(()=>{const c=(f=>{let d=f,l=!0,_;for(;l;){const h=d;if(h.tag==="Leaf"){l=!1,_=T;continue}if(h.tag==="Node"){const m=t.compare(a)(h._3);if(m==="LT"){d=h._5;continue}if(m==="GT"){d=h._6;continue}if(m==="EQ"){l=!1,_=w("Just",h._4);continue}}g()}return _})(u);if(c.tag==="Nothing")return 0;if(c.tag==="Just")return c._1.length;g()})()))(n));return o(Gg(t)(a=>a.src)(r))(s)(ct(a=>{const c=(f=>{let d=f,l=!0,_;for(;l;){const h=d;if(h.tag==="Leaf"){l=!1,_=T;continue}if(h.tag==="Node"){const m=t.compare(a)(h._3);if(m==="LT"){d=h._5;continue}if(m==="GT"){d=h._6;continue}if(m==="EQ"){l=!1,_=w("Just",h._4);continue}}g()}return _})(s);if(c.tag==="Nothing")return!0;if(c.tag==="Just")return c._1===0;g()},n))(i)}},wm=t=>{const e=_m(t),n=vm(t),r=Tm(t),i=Jm(t);return o=>u=>{const s=n(o)(u)(e(o));return u.length===0?s.layer:i(4*o.length|0)(o)(u)(r(o)(u)(s)).layer}},Cg=t=>{const e=lm(t),n=wm(t),r=gm(t);return i=>o=>{if(i.length===0)return Q;if(i.length<40)return e(i)(n(i)(o));const u=r(i)(o);return e(i)(fm(t)(u.removed)(n(u.coreNodes)(u.coreEdges)))}},Sg=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Gs=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},bm=Cg(it),wi=t=>e=>({...e,edges:[...e.edges,{src:t.src,tgt:t.tgt,delta:t.delta,weight:t.weight,eid:e.nextEid}],nextEid:e.nextEid+1|0}),Lm=t=>e=>n=>{if(n.cGroup.tag==="Nothing")return e;if(n.cGroup.tag==="Just"){const r=rt((()=>{const i=Sg(n.cGroup._1)(t);if(i.tag==="Nothing")return 0;if(i.tag==="Just")return i._1;g()})());return Ve(n.id)(i=>({...i,hitbox:{...i.hitbox,x:r+i.cGroupOffset.x}}))(e)}g()},km=t=>e=>({...e,cGraph:J(Lm(t))(e.cGraph)((()=>{const n=e.cGraph;return xt(r=>Ut(r)(n.cNodes))(n.cNodeOrder)})())}),Em=t=>e=>n=>r=>i=>{const o=de(Xi(e.cGroupOffset.x-t.cGroupOffset.x));return wi({src:i.nextNodeId,tgt:r,delta:Gs(0)(-o),weight:1})(wi({src:i.nextNodeId,tgt:n,delta:Gs(0)(o),weight:1})({...i,nodes:[...i.nodes,i.nextNodeId],nextNodeId:i.nextNodeId+1|0}))},Gm=t=>e=>n=>r=>i=>o=>u=>{const s=Gs(0)(de(Xi(n.cGroupOffset.x+n.hitbox.width+(e.direction==="LEFT"||e.direction==="RIGHT"?e.spacingsHandler.horizontalSpacing(n)(r):e.spacingsHandler.verticalSpacing(n)(r))-r.cGroupOffset.x)));return t.sameEdgeVerticalSegments(n)(r)?Em(n)(r)(i)(o)(u):wi({src:i,tgt:o,delta:s,weight:t.vsLNodePair(n)(r)?2:1})(u)},Cm=t=>e=>n=>r=>i=>{const o=Ut(i)(e.cGraph.cNodes);if(o.tag==="Nothing")return r;if(o.tag==="Just")return(n.cGroup.tag==="Nothing"?o._1.cGroup.tag==="Nothing":n.cGroup.tag==="Just"&&o._1.cGroup.tag==="Just"&&n.cGroup._1===o._1.cGroup._1)?r:n.cGroup.tag==="Just"&&o._1.cGroup.tag==="Just"?Gm(t)(e)(n)(o._1)(n.cGroup._1)(o._1.cGroup._1)(r):r;g()},Sm=t=>e=>n=>r=>J(Cm(t)(e)(r))(n)(r.constraints),Dm=t=>e=>wi({src:e.srcGroup,tgt:e.tgtGroup,delta:e.delta,weight:e.weight})(t),Pm=t=>{const e=J(i=>o=>vt(it)(oe)(o.tgt)(1)(i))(Q)(t.edges),n=ct(i=>{const o=Sg(i)(e);if(o.tag==="Nothing")return!0;if(o.tag==="Just")return o._1===0;g()},t.nodes);if(n.length<=1)return t;const r=t.nextNodeId;return J(i=>o=>wi({src:r,tgt:o,delta:1,weight:0})(i))({...t,nodes:[...t.nodes,r],nextNodeId:r+1|0})(n)},Im=t=>e=>{const n=Pm(J(Dm)(J(Sm(t)(e))({nodes:e.cGraph.cGroupOrder,edges:[],nextNodeId:e.cGraph.nextCGroupId,nextEid:0})((()=>{const r=e.cGraph;return xt(i=>Ut(i)(r.cNodes))(r.cNodeOrder)})()))(t.edgeLengthEdges(e.cGraph)));return{nodes:n.nodes,edges:n.edges}},Qm=t=>e=>{const n=Im(t)(e);return km(bm(n.nodes)(n.edges))(e)},Dg=t=>t,ee=Dg("H"),ne=Dg("V"),Fm=t=>b(t._2,t._1),Pg=t=>({...t,position:b(t.position._2,t.position._1),size:b(t.size._2,t.size._1)}),Am=t=>({start:b(t.start._2,t.start._1),end:b(t.end._2,t.end._1),direction:(()=>{if(t.direction==="H")return ne;if(t.direction==="V")return ee;g()})()}),Ig=t=>({...t,segments:H(Am)(t.segments),bends:H(Fm)(t.bends)}),Mm=t=>({nodes:H(Pg)(t.nodes),edges:t.edges,paths:H(Ig)(t.paths),ports:t.ports}),Bm=t=>({horizontalSpacing:e=>n=>{if(t.sameEdgeVerticalSegments(e)(n)||e.ignoreSpacing.right||n.ignoreSpacing.left)return 0;const r=n.kind.tag==="Nothing"?!1:n.kind.tag==="Just"&&n.kind._1==="vs";return e.kind.tag!=="Nothing"&&e.kind.tag==="Just"&&e.kind._1==="vs"?r?10:4:r?4:8},verticalSpacing:e=>n=>{if(t.sameEdgeVerticalSegments(e)(n))return 1;if(e.hitbox.y<=n.hitbox.y?e.ignoreSpacing.down||n.ignoreSpacing.up:e.ignoreSpacing.up||n.ignoreSpacing.down)return 0;const r=n.kind.tag==="Nothing"?!1:n.kind.tag==="Just"&&n.kind._1==="vs";return e.kind.tag!=="Nothing"&&e.kind.tag==="Just"&&e.kind._1==="vs"?r?10:4:r?4:8}}),zm=t=>e=>Qm(e),Rm=t=>e=>{const n=Mm(e),r=am(n),i=rm(r)(vg(n)),o=im(ag(xs)(Lp({...Ep(r.cGraph),compactionAlgorithm:w("Just",zm()(i)),constraintAlgorithm:w("Just",Rp),spacingsHandler:Bm(i)})).cGraph)({nodes:n.nodes,edges:n.edges,paths:n.paths});return{nodes:H(Pg)(o.nodes),edges:H(Ig)(o.edges)}},Qg=t=>t,Qr=Kt(it)(Bt),Dt=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Fg=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},dt=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},ht=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Fr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Wm=t=>e=>{const n=it.compare(t._1)(e._1);return n==="LT"?ye:n==="GT"?xe:it.compare(t._2)(e._2)},Ar=t=>e=>{const n=it.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Hm=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),Om=t=>t,Ag=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},qm=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Do=Qg("Regular"),Po=Qg("Critical"),Mg=t=>e=>{const n=J(u=>s=>j(C)(s.node)(s)(u))(Q)(e),r=1.25*rt(4),i=(u,s,a)=>(c=>f=>d=>{let l=c,_=f,h=d,m=!0,p;for(;m;){const y=l,x=_,N=h;if(N.critical){m=!1,p=N;continue}const v=Ft(L=>T,L=>E=>w("Just",{head:L,tail:E}),y),k=Ft(L=>T,L=>E=>w("Just",{head:L,tail:E}),x);if(v.tag==="Just"&&k.tag==="Just"){const L=v._1.head>k._1.head-u&&v._1.head<k._1.head+u?{...N,critical:!0}:v._1.head>k._1.head-r&&v._1.head<k._1.head+r?{...N,conflicts:N.conflicts+1|0}:N;if(L.critical){m=!1,p=L;continue}if(v._1.head<=k._1.head){l=v._1.tail,_=x,h=L;continue}l=y,_=k._1.tail,h=L;continue}m=!1,p=N}return p})(s)(a)({conflicts:0,critical:!1}),o=(u,s,a)=>{if(ht(J(ht)(-1e18)(s.incoming))(J(ht)(-1e18)(s.outgoing))-dt(J(dt)(1e18)(s.incoming))(J(dt)(1e18)(s.outgoing))<.001||ht(J(ht)(-1e18)(a.incoming))(J(ht)(-1e18)(a.outgoing))-dt(J(dt)(1e18)(a.incoming))(J(dt)(1e18)(a.outgoing))<.001)return[];const c=i(u,s.outgoing,a.incoming),f=i(u,a.outgoing,s.incoming);if(c.critical||f.critical)return[...c.critical?[{src:a.id,tgt:s.id,weight:1,kind:Po}]:[],...f.critical?[{src:s.id,tgt:a.id,weight:1,kind:Po}]:[]];const d=dt(J(dt)(1e18)(s.incoming))(J(dt)(1e18)(s.outgoing)),l=ht(J(ht)(-1e18)(s.incoming))(J(ht)(-1e18)(s.outgoing)),_=dt(J(dt)(1e18)(a.incoming))(J(dt)(1e18)(a.outgoing)),h=ht(J(ht)(-1e18)(a.incoming))(J(ht)(-1e18)(a.outgoing)),m=(1*c.conflicts|0)+(16*(J(y=>x=>x>h?y:x>=_?y+1|0:y)(0)(s.outgoing)+J(y=>x=>x>l?y:x>=d?y+1|0:y)(0)(a.incoming)|0)|0)|0,p=(1*f.conflicts|0)+(16*(J(y=>x=>x>l?y:x>=d?y+1|0:y)(0)(a.outgoing)+J(y=>x=>x>h?y:x>=_?y+1|0:y)(0)(s.incoming)|0)|0)|0;return m<p?[{src:s.id,tgt:a.id,weight:p-m|0,kind:Do}]:m>p?[{src:a.id,tgt:s.id,weight:m-p|0,kind:Do}]:m>0?[{src:s.id,tgt:a.id,weight:0,kind:Do},{src:a.id,tgt:s.id,weight:0,kind:Do}]:[]};return J(u=>s=>J(a=>c=>j(C)(c._1)(c._2)(a))(u)((()=>{const a=J(D=>S=>{const Z=S.edge.from.node+"|"+(()=>{if(S.edge.from.port.tag==="Just")return S.edge.from.port._1;if(S.edge.from.port.tag==="Nothing")return"_auto_"+S.edge.id;g()})(),X=Ag(Z)(D.entries);if(X.tag==="Nothing")return{...D,entries:j(C)(Z)({id:0,members:[S.edge.id],incoming:[S.fromPos._1],outgoing:[S.toPos._1],slot:0,mark:0,splitBy:T,splitPartner:T})(D.entries),order:[...D.order,Z]};if(X.tag==="Just")return{...D,entries:j(C)(Z)({...X._1,members:[...X._1.members,S.edge.id],incoming:[...or(W=>W<S.fromPos._1)(X._1.incoming).init,S.fromPos._1,...or(W=>W<=S.fromPos._1)(X._1.incoming).rest],outgoing:[...or(W=>W<S.toPos._1)(X._1.outgoing).init,S.toPos._1,...or(W=>W<=S.toPos._1)(X._1.outgoing).rest]})(D.entries)};g()})({entries:Q,order:[]})(s._2),c=Qt(D=>S=>({...S,id:D}))(xt(D=>Ag(D)(a.entries))(a.order));if(c.length===0)return[];const f=J(D=>S=>D.prev.tag==="Just"&&S-D.prev._1<1e-9?D:{prev:w("Just",S),out:[...D.out,S]})({prev:T,out:[]})(Lt(st.compare)([...Tt(c)(D=>D.incoming),...Tt(c)(D=>D.outgoing)])).out,d=f.length<2?.2*r:.2*J(D=>S=>{if(D.prev.tag==="Nothing")return{prev:w("Just",S),mn:D.mn};if(D.prev.tag==="Just")return{prev:w("Just",S),mn:dt(D.mn)(S-D.prev._1)};g()})({prev:T,mn:1e18})(f).mn,l={segments:c,deps:(()=>{const D=c.length;return Tt(Tt(It(0,D-2|0))(S=>Tt(It(S+1|0,D-1|0))(Z=>[b(S,Z)])))(S=>S._1>=0&&S._1<c.length?S._2>=0&&S._2<c.length?o(d,c[S._1],c[S._2]):[]:[])})()},_=ct(D=>{if(D.kind==="Critical")return!0;if(D.kind==="Regular")return!1;g()},l.deps),h=(()=>{if(_.length<2)return l;const D=Qr((()=>{const z=l.segments;return H(M=>b(M.id,M.mark))((()=>{const M=z.length,G=I=>{let F=I,O=!0,Y;for(;O;){const q=F,$=Zt(R=>{const tt=Dt(R)(q.inWeight);if(tt.tag==="Nothing")return!0;if(tt.tag==="Just")return tt._1===0;g()})(q.remaining);if($.tag==="Nothing"){O=!1,Y=q;continue}if($.tag==="Just"){const R=$._1;F={...q,inWeight:J(tt=>K=>vt(it)(oe)(K.tgt)(-K.weight)(tt))(q.inWeight)((()=>{const tt=Dt(R)(q.depsBySrc);if(tt.tag==="Nothing")return[];if(tt.tag==="Just")return tt._1;g()})()),marks:j(it)(R)(q.nextSource)(q.marks),nextSource:q.nextSource+1|0,outWeight:J(tt=>K=>vt(it)(oe)(K.src)(-K.weight)(tt))(q.outWeight)((()=>{const tt=Dt(R)(q.depsByTgt);if(tt.tag==="Nothing")return[];if(tt.tag==="Just")return tt._1;g()})()),remaining:ct(tt=>tt!==R,q.remaining)};continue}g()}return Y},P=I=>{let F=I,O=!0,Y;for(;O;){const q=F,$=Zt(R=>{const tt=Dt(R)(q.outWeight);if(tt.tag==="Nothing")return!0;if(tt.tag==="Just")return tt._1===0;g()})(q.remaining);if($.tag==="Nothing"){O=!1,Y=q;continue}if($.tag==="Just"){const R=$._1;F={...q,inWeight:J(tt=>K=>vt(it)(oe)(K.tgt)(-K.weight)(tt))(q.inWeight)((()=>{const tt=Dt(R)(q.depsBySrc);if(tt.tag==="Nothing")return[];if(tt.tag==="Just")return tt._1;g()})()),marks:j(it)(R)(q.nextSink)(q.marks),nextSink:q.nextSink-1|0,outWeight:J(tt=>K=>vt(it)(oe)(K.src)(-K.weight)(tt))(q.outWeight)((()=>{const tt=Dt(R)(q.depsByTgt);if(tt.tag==="Nothing")return[];if(tt.tag==="Just")return tt._1;g()})()),remaining:ct(tt=>tt!==R,q.remaining)};continue}g()}return Y};return(I=>{let F=I,O=!0,Y;for(;O;){const q=G(P(F));if(q.remaining.length===0){O=!1,Y=H($=>{const R=Dt($.id)(q.marks),tt=(()=>{if(R.tag==="Nothing")return $.id;if(R.tag==="Just")return R._1;g()})();return{...$,mark:tt<M?(tt+M|0)+1|0:tt}})(z);continue}F=(()=>{const $=tt=>{const K=Dt(tt)(q.outWeight),gt=Dt(tt)(q.inWeight);return(()=>{if(K.tag==="Nothing")return 0;if(K.tag==="Just")return K._1;g()})()-(()=>{if(gt.tag==="Nothing")return 0;if(gt.tag==="Just")return gt._1;g()})()|0},R=Lt(tt=>K=>it.compare($(K))($(tt)))(q.remaining);if(0<R.length){const tt=R[0];return{...q,inWeight:J(K=>gt=>vt(it)(oe)(gt.tgt)(-gt.weight)(K))(q.inWeight)((()=>{const K=Dt(tt)(q.depsBySrc);if(K.tag==="Nothing")return[];if(K.tag==="Just")return K._1;g()})()),marks:j(it)(tt)(q.nextSource)(q.marks),nextSource:q.nextSource+1|0,outWeight:J(K=>gt=>vt(it)(oe)(gt.src)(-gt.weight)(K))(q.outWeight)((()=>{const K=Dt(tt)(q.depsByTgt);if(K.tag==="Nothing")return[];if(K.tag==="Just")return K._1;g()})()),remaining:ct(K=>K!==tt,q.remaining)}}return q})()}return Y})({remaining:H(I=>I.id)(z),marks:Q,inWeight:J(I=>F=>vt(it)(oe)(F.tgt)(F.weight)(I))(Q)(_),outWeight:J(I=>F=>vt(it)(oe)(F.src)(F.weight)(I))(Q)(_),depsBySrc:J(I=>F=>vt(it)(te)(F.src)([F])(I))(Q)(_),depsByTgt:J(I=>F=>vt(it)(te)(F.tgt)([F])(I))(Q)(_),nextSink:M-1|0,nextSource:M+1|0})})())})()),S=ct(z=>{const M=Dt(z.src)(D),G=Dt(z.tgt)(D);return(()=>{if(M.tag==="Nothing")return 0;if(M.tag==="Just")return M._1;g()})()>(()=>{if(G.tag==="Nothing")return 0;if(G.tag==="Just")return G._1;g()})()},_);if(S.length===0)return l;const Z=J(z=>M=>{if(Be(xr)(M.src)(z.decisions)||Be(xr)(M.tgt)(z.decisions))return z;const G=Dt(M.src)(z.segMap),P=Dt(M.tgt)(z.segMap);if(G.tag==="Just"&&P.tag==="Just"){const I=(G._1.incoming.length+G._1.outgoing.length|0)>2&&(P._1.incoming.length+P._1.outgoing.length|0)<=2,F=I?P._1:G._1;return{decisions:[...z.decisions,F.id],segMap:j(it)(F.id)({...F,splitBy:w("Just",I?G._1.id:P._1.id)})(z.segMap)}}return z})({decisions:[],segMap:Qr(H(z=>b(z.id,z))(l.segments))})(S),X=Z.segMap,W=J(z=>M=>{const G=dt(J(dt)(1e18)(M.incoming))(J(dt)(1e18)(M.outgoing)),P=ht(J(ht)(-1e18)(M.incoming))(J(ht)(-1e18)(M.outgoing)),I=ct($=>$.a.startPosition<=P&&$.a.endPosition>=G,Qt($=>R=>({i:$,a:R}))(z.freeAreas));if(I.length===0){const $={...M,incoming:Lt(st.compare)(M.incoming),outgoing:Lt(st.compare)([(G+P)/2]),splitPartner:w("Just",z.nextId)},R={id:z.nextId,incoming:Lt(st.compare)([(G+P)/2]),mark:0,members:M.members,outgoing:Lt(st.compare)(M.outgoing),slot:0,splitBy:T,splitPartner:w("Just",M.id)};return{segMap:j(it)(R.id)(R)(j(it)($.id)($)(z.segMap)),freeAreas:z.freeAreas,nextId:z.nextId+1|0}}const F=0<I.length?w("Just",I[0]):T,O=(()=>{if(F.tag==="Nothing")return{i:0,a:{startPosition:0,endPosition:0,size:0}};if(F.tag==="Just"){if(I.length===1)return F._1;const $=H(R=>({c:R,rating:(()=>{const tt=(R.a.startPosition+R.a.endPosition)/2,K=[tt],gt=[tt],_t=J((()=>{const yt=z.segMap;return Et=>At=>{const pt=Dt(At.tgt)(yt);if(pt.tag==="Nothing")return Et;if(pt.tag==="Just"){const Mt=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),Jt=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),mt=dt(J(dt)(1e18)(M.incoming))(J(dt)(1e18)(K)),nt=(()=>{const Ct=ht(J(ht)(-1e18)(M.incoming))(J(ht)(-1e18)(K)),Pt=J(Xt=>_e=>_e>Jt?Xt:_e>=Mt?Xt+1|0:Xt)(0)(K)+J(Xt=>_e=>_e>Ct?Xt:_e>=mt?Xt+1|0:Xt)(0)(pt._1.incoming)|0,je=dt(J(dt)(1e18)(M.incoming))(J(dt)(1e18)(K)),Ze=ht(J(ht)(-1e18)(M.incoming))(J(ht)(-1e18)(K)),kn=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),jr=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),_n=J(Xt=>_e=>_e>Ze?Xt:_e>=je?Xt+1|0:Xt)(0)(pt._1.outgoing)+J(Xt=>_e=>_e>jr?Xt:_e>=kn?Xt+1|0:Xt)(0)(M.incoming)|0;return Pt===_n?Pt>0?{...Et,deps:Et.deps+2|0,crossings:Et.crossings+Pt|0}:Et:{...Et,deps:Et.deps+1|0,crossings:Et.crossings+Ar(Pt)(_n)|0}})(),U=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),ut=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),ft=dt(J(dt)(1e18)(gt))(J(dt)(1e18)(M.outgoing)),lt=ht(J(ht)(-1e18)(gt))(J(ht)(-1e18)(M.outgoing)),Nt=J(Ct=>Pt=>Pt>ut?Ct:Pt>=U?Ct+1|0:Ct)(0)(M.outgoing)+J(Ct=>Pt=>Pt>lt?Ct:Pt>=ft?Ct+1|0:Ct)(0)(pt._1.incoming)|0,Ht=dt(J(dt)(1e18)(gt))(J(dt)(1e18)(M.outgoing)),Vt=ht(J(ht)(-1e18)(gt))(J(ht)(-1e18)(M.outgoing)),De=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),un=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),Ne=J(Ct=>Pt=>Pt>Vt?Ct:Pt>=Ht?Ct+1|0:Ct)(0)(pt._1.outgoing)+J(Ct=>Pt=>Pt>un?Ct:Pt>=De?Ct+1|0:Ct)(0)(gt)|0;return Nt===Ne?Nt>0?{...nt,deps:nt.deps+2|0,crossings:nt.crossings+Nt|0}:nt:{...nt,deps:nt.deps+1|0,crossings:nt.crossings+Ar(Nt)(Ne)|0}}g()}})())(J((()=>{const yt=z.segMap;return Et=>At=>{const pt=Dt(At.src)(yt);if(pt.tag==="Nothing")return Et;if(pt.tag==="Just"){const Mt=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),Jt=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),mt=dt(J(dt)(1e18)(M.incoming))(J(dt)(1e18)(K)),nt=(()=>{const Ct=ht(J(ht)(-1e18)(M.incoming))(J(ht)(-1e18)(K)),Pt=J(Xt=>_e=>_e>Jt?Xt:_e>=Mt?Xt+1|0:Xt)(0)(K)+J(Xt=>_e=>_e>Ct?Xt:_e>=mt?Xt+1|0:Xt)(0)(pt._1.incoming)|0,je=dt(J(dt)(1e18)(M.incoming))(J(dt)(1e18)(K)),Ze=ht(J(ht)(-1e18)(M.incoming))(J(ht)(-1e18)(K)),kn=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),jr=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),_n=J(Xt=>_e=>_e>Ze?Xt:_e>=je?Xt+1|0:Xt)(0)(pt._1.outgoing)+J(Xt=>_e=>_e>jr?Xt:_e>=kn?Xt+1|0:Xt)(0)(M.incoming)|0;return Pt===_n?Pt>0?{...Et,deps:Et.deps+2|0,crossings:Et.crossings+Pt|0}:Et:{...Et,deps:Et.deps+1|0,crossings:Et.crossings+Ar(Pt)(_n)|0}})(),U=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),ut=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),ft=dt(J(dt)(1e18)(gt))(J(dt)(1e18)(M.outgoing)),lt=ht(J(ht)(-1e18)(gt))(J(ht)(-1e18)(M.outgoing)),Nt=J(Ct=>Pt=>Pt>ut?Ct:Pt>=U?Ct+1|0:Ct)(0)(M.outgoing)+J(Ct=>Pt=>Pt>lt?Ct:Pt>=ft?Ct+1|0:Ct)(0)(pt._1.incoming)|0,Ht=dt(J(dt)(1e18)(gt))(J(dt)(1e18)(M.outgoing)),Vt=ht(J(ht)(-1e18)(gt))(J(ht)(-1e18)(M.outgoing)),De=dt(J(dt)(1e18)(pt._1.incoming))(J(dt)(1e18)(pt._1.outgoing)),un=ht(J(ht)(-1e18)(pt._1.incoming))(J(ht)(-1e18)(pt._1.outgoing)),Ne=J(Ct=>Pt=>Pt>Vt?Ct:Pt>=Ht?Ct+1|0:Ct)(0)(pt._1.outgoing)+J(Ct=>Pt=>Pt>un?Ct:Pt>=De?Ct+1|0:Ct)(0)(gt)|0;return Nt===Ne?Nt>0?{...nt,deps:nt.deps+2|0,crossings:nt.crossings+Nt|0}:nt:{...nt,deps:nt.deps+1|0,crossings:nt.crossings+Ar(Nt)(Ne)|0}}g()}})())({crossings:0,deps:0})(ct(yt=>yt.tgt===M.id,l.deps)))(ct(yt=>yt.src===M.id,l.deps)),at=(()=>{if(M.splitBy.tag==="Just")return Dt(M.splitBy._1)(z.segMap);if(M.splitBy.tag==="Nothing")return T;g()})();if(at.tag==="Just")return{..._t,deps:_t.deps+2|0,crossings:(()=>{const yt=dt(J(dt)(1e18)(at._1.incoming))(J(dt)(1e18)(at._1.outgoing)),Et=dt(J(dt)(1e18)(gt))(J(dt)(1e18)(M.outgoing)),At=ht(J(ht)(-1e18)(at._1.incoming))(J(ht)(-1e18)(at._1.outgoing)),pt=ht(J(ht)(-1e18)(gt))(J(ht)(-1e18)(M.outgoing)),Mt=dt(J(dt)(1e18)(M.incoming))(J(dt)(1e18)(K));return _t.crossings+(()=>{const Jt=dt(J(dt)(1e18)(at._1.incoming))(J(dt)(1e18)(at._1.outgoing)),mt=ht(J(ht)(-1e18)(M.incoming))(J(ht)(-1e18)(K)),nt=ht(J(ht)(-1e18)(at._1.incoming))(J(ht)(-1e18)(at._1.outgoing));return((J(U=>ut=>ut>At?U:ut>=yt?U+1|0:U)(0)(K)+J(U=>ut=>ut>mt?U:ut>=Mt?U+1|0:U)(0)(at._1.incoming)|0)+J(U=>ut=>ut>pt?U:ut>=Et?U+1|0:U)(0)(at._1.outgoing)|0)+J(U=>ut=>ut>nt?U:ut>=Jt?U+1|0:U)(0)(gt)|0})()|0})()};if(at.tag==="Nothing")return _t;g()})()}))(I);return J(R=>tt=>tt.rating.crossings<R.rating.crossings||!(tt.rating.crossings>R.rating.crossings)&&(tt.rating.deps<R.rating.deps||!(tt.rating.deps>R.rating.deps)&&tt.c.a.size>R.c.a.size)?tt:R)(0<$.length?$[0]:{c:F._1,rating:{crossings:1e6,deps:1e6}})($).c}g()})(),Y={...M,incoming:Lt(st.compare)(M.incoming),outgoing:Lt(st.compare)([(O.a.startPosition+O.a.endPosition)/2]),splitPartner:w("Just",z.nextId)},q={id:z.nextId,incoming:Lt(st.compare)([(O.a.startPosition+O.a.endPosition)/2]),mark:0,members:M.members,outgoing:Lt(st.compare)(M.outgoing),slot:0,splitBy:T,splitPartner:w("Just",M.id)};return{segMap:j(it)(q.id)(q)(j(it)(Y.id)(Y)(z.segMap)),freeAreas:(()=>{if(O.i>=0&&O.i<z.freeAreas.length){const $=za(Yt,T,O.i,z.freeAreas),R=(()=>{if($.tag==="Nothing")return z.freeAreas;if($.tag==="Just")return $._1;g()})();if(z.freeAreas[O.i].size/2<d)return R;const tt=(z.freeAreas[O.i].startPosition+z.freeAreas[O.i].endPosition)/2,K=tt-d,gt=tt+d;return[...O.i<1?[]:bt(0,O.i,R),...z.freeAreas[O.i].startPosition<=K?[{startPosition:z.freeAreas[O.i].startPosition,endPosition:K,size:K-z.freeAreas[O.i].startPosition}]:[],...gt<=z.freeAreas[O.i].endPosition?[{startPosition:gt,endPosition:z.freeAreas[O.i].endPosition,size:z.freeAreas[O.i].endPosition-gt}]:[],...O.i<1?R:bt(O.i,R.length,R)]}return z.freeAreas})(),nextId:z.nextId+1|0}})({segMap:X,freeAreas:(()=>{const z=Lt(st.compare)([...Tt(l.segments)(M=>M.incoming),...Tt(l.segments)(M=>M.outgoing)]);return xt(Om)(Je(M=>G=>G-M>=2*d?w("Just",{startPosition:M+d,endPosition:G-d,size:G-M-2*d}):T,z,bt(1,z.length,z)))})(),nextId:l.segments.length})(Lt(z=>M=>st.compare(ht(J(ht)(-1e18)(z.incoming))(J(ht)(-1e18)(z.outgoing))-dt(J(dt)(1e18)(z.incoming))(J(dt)(1e18)(z.outgoing)))(ht(J(ht)(-1e18)(M.incoming))(J(ht)(-1e18)(M.outgoing))-dt(J(dt)(1e18)(M.incoming))(J(dt)(1e18)(M.outgoing))))(xt(z=>Dt(z)(X))(Z.decisions)));return{segments:(()=>{const z=(M,G)=>{if(M.tag==="Leaf")return G;if(M.tag==="Node")return z(M._5,Ot("Cons",M._4,z(M._6,G)));g()};return kt($t.foldr,z(W.segMap,qt))})(),deps:(()=>{const z=W.segMap,M=(I,F)=>{if(I.tag==="Leaf")return F;if(I.tag==="Node")return M(I._5,Ot("Cons",I._4,M(I._6,F)));g()},G=kt($t.foldr,M(z,qt)),P=G.length;return[...Tt(Tt(It(0,P-2|0))(I=>Tt(It(I+1|0,P-1|0))(F=>[b(I,F)])))(I=>I._1>=0&&I._1<G.length?I._2>=0&&I._2<G.length?G[I._1].splitPartner.tag!=="Nothing"&&G[I._1].splitPartner.tag==="Just"&&G[I._1].splitPartner._1===G[I._2].id||G[I._2].splitPartner.tag!=="Nothing"&&G[I._2].splitPartner.tag==="Just"&&G[I._2].splitPartner._1===G[I._1].id?[]:o(d,G[I._1],G[I._2]):[]:[]),...Tt(G)(I=>I.splitBy.tag==="Just"&&I.splitPartner.tag==="Just"&&(()=>{const F=Dt(I.splitPartner._1)(z);if(F.tag==="Nothing")return!1;if(F.tag==="Just")return!0;g()})()&&(()=>{const F=Dt(I.splitBy._1)(z);if(F.tag==="Nothing")return!1;if(F.tag==="Just")return!0;g()})()?[{src:I.id,tgt:I.splitBy._1,weight:1,kind:Po},{src:I.splitBy._1,tgt:I.splitPartner._1,weight:1,kind:Po}]:[])]})()}})(),m=h.segments,p=m.length,y=D=>{let S=D,Z=!0,X;for(;Z;){const W=S,z=Zt(M=>{const G=Dt(M)(W.inWeight);if(G.tag==="Nothing")return!0;if(G.tag==="Just")return G._1===0;g()})(W.remaining);if(z.tag==="Nothing"){Z=!1,X=W;continue}if(z.tag==="Just"){const M=z._1;S={...W,inWeight:J(G=>P=>vt(it)(oe)(P.tgt)(-P.weight)(G))(W.inWeight)((()=>{const G=Dt(M)(W.depsBySrc);if(G.tag==="Nothing")return[];if(G.tag==="Just")return G._1;g()})()),marks:j(it)(M)(W.nextSource)(W.marks),nextSource:W.nextSource+1|0,outWeight:J(G=>P=>vt(it)(oe)(P.src)(-P.weight)(G))(W.outWeight)((()=>{const G=Dt(M)(W.depsByTgt);if(G.tag==="Nothing")return[];if(G.tag==="Just")return G._1;g()})()),remaining:ct(G=>G!==M,W.remaining)};continue}g()}return X},x=D=>{let S=D,Z=!0,X;for(;Z;){const W=S,z=Zt(M=>{const G=Dt(M)(W.outWeight);if(G.tag==="Nothing")return!0;if(G.tag==="Just")return G._1===0;g()})(W.remaining);if(z.tag==="Nothing"){Z=!1,X=W;continue}if(z.tag==="Just"){const M=z._1;S={...W,inWeight:J(G=>P=>vt(it)(oe)(P.tgt)(-P.weight)(G))(W.inWeight)((()=>{const G=Dt(M)(W.depsBySrc);if(G.tag==="Nothing")return[];if(G.tag==="Just")return G._1;g()})()),marks:j(it)(M)(W.nextSink)(W.marks),nextSink:W.nextSink-1|0,outWeight:J(G=>P=>vt(it)(oe)(P.src)(-P.weight)(G))(W.outWeight)((()=>{const G=Dt(M)(W.depsByTgt);if(G.tag==="Nothing")return[];if(G.tag==="Just")return G._1;g()})()),remaining:ct(G=>G!==M,W.remaining)};continue}g()}return X},N=(D=>{let S=D,Z=!0,X;for(;Z;){const W=y(x(S));if(W.remaining.length===0){Z=!1,X=H(z=>{const M=Dt(z.id)(W.marks),G=(()=>{if(M.tag==="Nothing")return z.id;if(M.tag==="Just")return M._1;g()})();return{...z,mark:G<p?(G+p|0)+1|0:G}})(m);continue}S=(()=>{const z=G=>{const P=Dt(G)(W.outWeight),I=Dt(G)(W.inWeight);return(()=>{if(P.tag==="Nothing")return 0;if(P.tag==="Just")return P._1;g()})()-(()=>{if(I.tag==="Nothing")return 0;if(I.tag==="Just")return I._1;g()})()|0},M=Lt(G=>P=>it.compare(z(P))(z(G)))(W.remaining);if(0<M.length){const G=M[0];return{...W,inWeight:J(P=>I=>vt(it)(oe)(I.tgt)(-I.weight)(P))(W.inWeight)((()=>{const P=Dt(G)(W.depsBySrc);if(P.tag==="Nothing")return[];if(P.tag==="Just")return P._1;g()})()),marks:j(it)(G)(W.nextSource)(W.marks),nextSource:W.nextSource+1|0,outWeight:J(P=>I=>vt(it)(oe)(I.src)(-I.weight)(P))(W.outWeight)((()=>{const P=Dt(G)(W.depsByTgt);if(P.tag==="Nothing")return[];if(P.tag==="Just")return P._1;g()})()),remaining:ct(P=>P!==G,W.remaining)}}return W})()}return X})({remaining:H(D=>D.id)(m),marks:Q,inWeight:J(D=>S=>vt(it)(oe)(S.tgt)(S.weight)(D))(Q)(h.deps),outWeight:J(D=>S=>vt(it)(oe)(S.src)(S.weight)(D))(Q)(h.deps),depsBySrc:J(D=>S=>vt(it)(te)(S.src)([S])(D))(Q)(h.deps),depsByTgt:J(D=>S=>vt(it)(te)(S.tgt)([S])(D))(Q)(h.deps),nextSink:p-1|0,nextSource:p+1|0}),v=(()=>{const D=(()=>{const X=Qr(H(W=>b(W.id,W.mark))(N));return{segments:N,deps:xt(W=>(()=>{if(W.kind==="Critical")return!0;if(W.kind==="Regular")return!1;g()})()?w("Just",W):(()=>{const z=Dt(W.src)(X),M=Dt(W.tgt)(X);return(()=>{if(z.tag==="Nothing")return 0;if(z.tag==="Just")return z._1;g()})()>(()=>{if(M.tag==="Nothing")return 0;if(M.tag==="Just")return M._1;g()})()})()?W.weight===0?T:w("Just",{src:W.tgt,tgt:W.src,weight:W.weight,kind:W.kind}):w("Just",W))(h.deps)}})(),S=J(X=>W=>vt(it)(oe)(W.tgt)(1)(X))(Q)(D.deps),Z=(X=>{let W=X,z=!0,M;for(;z;){const G=W,P=Ft(I=>T,I=>F=>w("Just",{head:I,tail:F}),G.queue);if(P.tag==="Nothing"){z=!1,M=G;continue}if(P.tag==="Just"){W=J((()=>{const I=Dt(P._1.head)(G.slots),F=(()=>{if(I.tag==="Nothing")return 0;if(I.tag==="Just")return I._1;g()})();return O=>Y=>{const q=Dt(Y)(O.inDegree),$=(()=>{if(q.tag==="Nothing")return-1;if(q.tag==="Just")return q._1-1|0;g()})();return{...O,slots:j(it)(Y)(Fg((()=>{const R=Dt(Y)(O.slots);if(R.tag==="Nothing")return 0;if(R.tag==="Just")return R._1;g()})())(F+1|0))(O.slots),inDegree:j(it)(Y)($)(O.inDegree),queue:$===0?[...O.queue,Y]:O.queue}}})())({...G,queue:P._1.tail})((()=>{const I=Dt(P._1.head)(G.adj);if(I.tag==="Nothing")return[];if(I.tag==="Just")return I._1;g()})());continue}g()}return M})({slots:Qr(H(X=>b(X.id,0))(D.segments)),inDegree:S,adj:J(X=>W=>vt(it)(te)(W.src)([W.tgt])(X))(Q)(D.deps),queue:H(X=>X.id)(ct(X=>{const W=Dt(X.id)(S);if(W.tag==="Nothing")return!0;if(W.tag==="Just")return W._1===0;g()},D.segments))});return Lt(X=>W=>it.compare(X.slot)(W.slot))(H(X=>({...X,slot:(()=>{const W=Dt(X.id)(Z.slots);if(W.tag==="Nothing")return 0;if(W.tag==="Just")return W._1;g()})()}))(D.segments))})(),k=1+J(D=>S=>Fg(D)(S.slot))(0)(v)|0,L=Tt(v)(D=>D.members),E=ct(D=>Be(gn)(D.edge.id)(L),t),B=J(ht)(-1e18)(H(D=>D.fromPos._2)(E)),V=J(dt)(1e18)(H(D=>D.toPos._2)(E));if(B>V){const D=Qr(H(S=>b(S.id,S))(v));return Ae(H(S=>H(Z=>b(Z,{slot:S.slot,slotCount:k,gapTop:V,gapBottom:B,partner:(()=>{if(S.splitPartner.tag==="Just"){const X=Dt(S.splitPartner._1)(D);if(X.tag==="Just")return w("Just",{slot:X._1.slot,splitX:0<X._1.incoming.length?X._1.incoming[0]:0});if(X.tag==="Nothing")return T;g()}if(S.splitPartner.tag==="Nothing")return T;g()})()}))(S.members))(ct(S=>{if(S.splitPartner.tag==="Just"){const Z=Dt(S.splitPartner._1)(D);return!(Z.tag==="Just"&&(()=>{if(Z._1.splitBy.tag==="Nothing")return!1;if(Z._1.splitBy.tag==="Just")return!0;g()})())}if(S.splitPartner.tag==="Nothing")return!0;g()},v)))}const et=Qr(H(D=>b(D.id,D))(v));return Ae(H(D=>H(S=>b(S,{slot:D.slot,slotCount:k,gapTop:B,gapBottom:V,partner:(()=>{if(D.splitPartner.tag==="Just"){const Z=Dt(D.splitPartner._1)(et);if(Z.tag==="Just")return w("Just",{slot:Z._1.slot,splitX:0<Z._1.incoming.length?Z._1.incoming[0]:0});if(Z.tag==="Nothing")return T;g()}if(D.splitPartner.tag==="Nothing")return T;g()})()}))(D.members))(ct(D=>{if(D.splitPartner.tag==="Just"){const S=Dt(D.splitPartner._1)(et);return!(S.tag==="Just"&&(()=>{if(S._1.splitBy.tag==="Nothing")return!1;if(S._1.splitBy.tag==="Just")return!0;g()})())}if(D.splitPartner.tag==="Nothing")return!0;g()},v)))})()))(Q)(Hm(J(u=>s=>{const a=Fr(s.edge.from.node)(n);if(a.tag==="Just"){const c=Fr(s.edge.to.node)(n);return c.tag==="Just"&&a._1.layer!==c._1.layer?vt(it)(te)(Ar(a._1.layer)(c._1.layer))([s])(u):u}return u})(Q)((()=>{const u=s=>b((()=>{const a=Fr(s.edge.from.node)(n);return a.tag==="Just"?a._1.layer:1e6})(),(()=>{const a=Fr(s.edge.from.node)(n);return a.tag==="Just"?a._1.order:1e6})());return Lt(s=>a=>Wm(u(s))(u(a)))(t)})())))},$m=t=>e=>{const n=Mg(t)(e),r=J(i=>o=>j(C)(o.node)(o)(i))(Q)(e);return J(i=>o=>{const u=Fr(o.edge.from.node)(r);if(u.tag==="Just"){const s=Fr(o.edge.to.node)(r);if(s.tag==="Just"&&u._1.layer!==s._1.layer){const a=qm(o.edge.id)(n);if(a.tag==="Just")return j(it)(Ar(u._1.layer)(s._1.layer))(a._1.slotCount)(i)}return i}return i})(Q)(t)},Bg=Bt.foldMap((()=>{const t={append:e=>n=>e||n};return{mempty:!1,Semigroup0:()=>t}})()),ce=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},ge=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},bi=t=>e=>n=>r=>Bg(i=>n>=i.x&&n<i.x+i.w&&e>i.y&&t<i.y+i.h)(r),Io=t=>e=>n=>r=>bi(ce(e)(n))(ge(e)(n))(r)(t),Qo=rt(4),Ym=Ha(t=>{if(t.direction==="H"){const e=ce(t.start._1)(t.end._1);return[{x:e,y:t.start._2-1,w:ge(t.start._1)(t.end._1)-e,h:2}]}if(t.direction==="V"){const e=ce(t.start._2)(t.end._2);return[{x:t.start._1-1,y:e,w:2,h:ge(t.start._2)(t.end._2)-e}]}g()}),Li=Wa(t=>{const e=t.start._1-t.end._1;return!((e<0?-e<1e-6:e<1e-6)&&(()=>{const n=t.start._2-t.end._2;return n<0?-n<1e-6:n<1e-6})())}),Vm=t=>e=>n=>{const r=Ft(i=>T,i=>o=>w("Just",{head:i,tail:o}),e);if(r.tag==="Nothing")return[{start:t.start,end:n.end,direction:t.direction}];if(r.tag==="Just"){const i=(r._1.head.direction==="H"?t.direction==="H":r._1.head.direction==="V"&&t.direction==="V")?[{start:t.start,end:r._1.head.end,direction:t.direction}]:[t,r._1.head],o=Vi(r._1.tail);if(o.tag==="Nothing"){const u=i.length-1|0;return u>=0&&u<i.length&&(i[u].direction==="H"?n.direction==="H":i[u].direction==="V"&&n.direction==="V")?[...(()=>{const s=i.length-1|0;return s<1?[]:bt(0,s,i)})(),{start:i[u].start,end:n.end,direction:n.direction}]:[...i,n]}if(o.tag==="Just")return(o._1.last.direction==="H"?n.direction==="H":o._1.last.direction==="V"&&n.direction==="V")?[...i,...o._1.init,{start:o._1.last.start,end:n.end,direction:n.direction}]:[...i,...r._1.tail,n]}g()},ki=t=>{const e=r=>i=>{const o=Ft(u=>T,u=>s=>w("Just",{head:u,tail:s}),i);if(o.tag==="Nothing")return[r];if(o.tag==="Just")return(r.direction==="H"?o._1.head.direction==="H":r.direction==="V"&&o._1.head.direction==="V")&&(()=>{if(r.direction==="H")return r.end._1-r.start._1>=0==o._1.head.end._1-o._1.head.start._1>=0;if(r.direction==="V")return r.end._2-r.start._2>=0==o._1.head.end._2-o._1.head.start._2>=0;g()})()?e({start:r.start,end:o._1.head.end,direction:r.direction})(o._1.tail):[r,...e(o._1.head)(o._1.tail)];g()},n=Ft(r=>T,r=>i=>w("Just",{head:r,tail:i}),t);if(n.tag==="Nothing")return[];if(n.tag==="Just")return e(n._1.head)(n._1.tail);g()},Ei=t=>e=>n=>r=>Bg(i=>n>=i.y&&n<i.y+i.h&&e>i.x&&t<i.x+i.w)(r),Gi=t=>e=>n=>r=>Ei(ce(e)(n))(ge(e)(n))(r)(t),Xm=t=>e=>n=>r=>{const i=n+2|0,o=i<1?e:bt(i,e.length,e),u=n<1?[]:bt(0,n,e),s=(n+1|0)===(r-1|0),a=n===0,c=n>=0&&n<e.length?w("Just",e[n]):T;if(c.tag==="Just"){const f=n+1|0,d=f>=0&&f<e.length?w("Just",e[f]):T;if(d.tag==="Just"){const l=c._1.start._1===d._1.end._1&&(!a||c._1.direction==="V")&&(!s||d._1.direction==="V")&&!Io(t)(ce(c._1.start._2)(d._1.end._2))(ge(c._1.start._2)(d._1.end._2))(c._1.start._1)?w("Just",[...u,{start:c._1.start,end:d._1.end,direction:ne},...o]):T,_=c._1.start._2===d._1.end._2&&(!a||c._1.direction==="H")&&(!s||d._1.direction==="H")&&!Gi(t)(ce(c._1.start._1)(d._1.end._1))(ge(c._1.start._1)(d._1.end._1))(c._1.start._2)?w("Just",[...u,{start:c._1.start,end:d._1.end,direction:ee},...o]):T;return l.tag==="Nothing"?_:l}if(d.tag==="Nothing")return T;g()}if(c.tag==="Nothing")return T;g()},Um=t=>e=>{const n=e.length;return(r=>{let i=r,o=!0,u;for(;o;){const s=i;if((s+1|0)>=n){o=!1,u=e;continue}const a=Xm(t)(e)(s)(n);if(a.tag==="Just"){o=!1,u=a._1;continue}if(a.tag==="Nothing"){i=s+1|0;continue}g()}return u})(0)},jm=t=>e=>n=>r=>{const i=(l,_,h)=>!Io(t)(ce(_)(h))(ge(_)(h))(l),o=n+3|0,u=o<1?e:bt(o,e.length,e),s=n<1?[]:bt(0,n,e),a=(n+2|0)===(r-1|0),c=n===0,f=(l,_,h)=>!Gi(t)(ce(_)(h))(ge(_)(h))(l),d=n>=0&&n<e.length?w("Just",e[n]):T;if(d.tag==="Just"){const l=n+2|0,_=l>=0&&l<e.length?w("Just",e[l]):T;if(_.tag==="Just"){const h=d._1.start._1===_._1.end._1&&(!c||d._1.direction==="V")&&(!a||_._1.direction==="V")&&i(d._1.start._1,d._1.start._2,_._1.end._2)?w("Just",[...s,{start:d._1.start,end:_._1.end,direction:ne},...u]):d._1.start._2===_._1.end._2&&(!c||d._1.direction==="H")&&(!a||_._1.direction==="H")&&f(d._1.start._2,d._1.start._1,_._1.end._1)?w("Just",[...s,{start:d._1.start,end:_._1.end,direction:ee},...u]):T,m=(!c||d._1.direction==="V")&&(!a||_._1.direction==="H")&&i(d._1.start._1,d._1.start._2,_._1.end._2)&&f(_._1.end._2,d._1.start._1,_._1.end._1)?w("Just",[...s,{start:d._1.start,end:b(d._1.start._1,_._1.end._2),direction:ne},{start:b(d._1.start._1,_._1.end._2),end:_._1.end,direction:ee},...u]):T,p=(!c||d._1.direction==="H")&&(!a||_._1.direction==="V")&&f(d._1.start._2,d._1.start._1,_._1.end._1)&&i(_._1.end._1,d._1.start._2,_._1.end._2)?w("Just",[...s,{start:d._1.start,end:b(_._1.end._1,d._1.start._2),direction:ee},{start:b(_._1.end._1,d._1.start._2),end:_._1.end,direction:ne},...u]):T,y=m.tag==="Nothing"?p:m;return h.tag==="Nothing"?y:h}if(_.tag==="Nothing")return T;g()}if(d.tag==="Nothing")return T;g()},Zm=t=>e=>{const n=e.length;return(r=>{let i=r,o=!0,u;for(;o;){const s=i;if((s+2|0)>=n){o=!1,u=e;continue}const a=jm(t)(e)(s)(n);if(a.tag==="Just"){o=!1,u=a._1;continue}if(a.tag==="Nothing"){i=s+1|0;continue}g()}return u})(0)},Km=t=>{const e=n=>{let r=n,i=!0,o;for(;i;){const u=r,s=ki(Li(Um(t)(Zm(t)(u))));if(s.length<u.length){r=s;continue}i=!1,o=s}return o};return n=>e(ki(Li(n)))},t2=t=>e=>n=>r=>{const i=ce(n)(r),o=ge(n)(r),u=ct(a=>e>=a.y&&e<a.y+a.h&&a.x+a.w>i&&a.x<o,t);if(r>n){const a=Lt(c=>f=>st.compare(c.x)(f.x))(u);return 0<a.length?a[0].x-1:(n+r)/2}const s=Lt(a=>c=>st.compare(c.x)(a.x))(H(a=>({...a,x:a.x+a.w}))(u));return 0<s.length?s[0].x+1:(n+r)/2},e2=t=>e=>n=>r=>{const i=ce(n)(r),o=ge(n)(r),u=ct(a=>e>=a.x&&e<a.x+a.w&&a.y+a.h>i&&a.y<o,t);if(r>n){const a=Lt(c=>f=>st.compare(c.y)(f.y))(u);return 0<a.length?a[0].y-1:(n+r)/2}const s=Lt(a=>c=>st.compare(c.y)(a.y))(H(a=>({...a,y:a.y+a.h}))(u));return 0<s.length?s[0].y+1:(n+r)/2},n2=t=>e=>n=>r=>{const i=ce(n)(r),o=ge(n)(r),u=ct(a=>e>=a.y&&e<a.y+a.h&&a.x+a.w>i&&a.x<o,t);if(r>n){const a=Lt(c=>f=>st.compare(f.x)(c.x))(H(c=>({...c,x:c.x+c.w}))(u));return 0<a.length?a[0].x:(n+r)/2}const s=Lt(a=>c=>st.compare(a.x)(c.x))(u);return 0<s.length?s[0].x-1:(n+r)/2},r2=t=>e=>n=>r=>{const i=ce(n)(r),o=ge(n)(r),u=ct(a=>e>=a.x&&e<a.x+a.w&&a.y+a.h>i&&a.y<o,t);if(r>n){const a=Lt(c=>f=>st.compare(f.y)(c.y))(H(c=>({...c,y:c.y+c.h}))(u));return 0<a.length?a[0].y:(n+r)/2}const s=Lt(a=>c=>st.compare(a.y)(c.y))(u);return 0<s.length?s[0].y-1:(n+r)/2},zg=t=>e=>n=>{let r=t,i=e,o=n,u=!0,s;for(;u;){const a=r,c=i,f=o;if(f>100){u=!1,s=c;continue}if(!a(c+f)){u=!1,s=c+f;continue}if(!a(c-f)){u=!1,s=c-f;continue}r=a,i=c,o=f+1}return s},Rg=t=>e=>n=>r=>i=>{const o=ce(e)(n),u=ge(e)(n);if(!bi(o)(u)(r)(t))return r;if(!bi(o)(u)(i)(t))return i;const s=(r+i)/2;return bi(o)(u)(s)(t)?zg(a=>bi(o)(u)(a)(t))(s)(1):s},i2=t=>e=>n=>r=>i=>{const o=ce(e)(n),u=ge(e)(n);if(!Ei(o)(u)(r)(t))return r;if(!Ei(o)(u)(i)(t))return i;const s=(r+i)/2;return Ei(o)(u)(s)(t)?zg(a=>Ei(o)(u)(a)(t))(s)(1):s},o2=t=>e=>n=>r=>{const i=ce(e)(n),o=ge(e)(n),u=ct(c=>r>=c.x&&r<c.x+c.w&&c.y+c.h>i&&c.y<o,t),s=J(c=>f=>ge(c)(f.x+f.w+4))(r+4)(u),a=J(c=>f=>ce(c)(f.x-4))(r-4)(u);return(()=>{const c=s-r,f=a-r;return(c<0?-c:c)<=(f<0?-f:f)})()?s:a},u2=t=>e=>n=>r=>{const i=ce(e)(n),o=ge(e)(n),u=ct(c=>r>=c.y&&r<c.y+c.h&&c.x+c.w>i&&c.x<o,t),s=J(c=>f=>ge(c)(f.y+f.h+4))(r+4)(u),a=J(c=>f=>ce(c)(f.y-4))(r-4)(u);return(()=>{const c=s-r,f=a-r;return(c<0?-c:c)<=(f<0?-f:f)})()?s:a},s2=t=>e=>n=>r=>i=>o=>u=>{const s=(()=>{if(r==="South")return b(i._1,i._2+4);if(r==="North")return b(i._1,i._2-4);if(r==="East")return b(i._1+4,i._2);if(r==="West")return b(i._1-4,i._2);g()})(),a=(()=>{if(o==="South")return b(u._1,u._2+4);if(o==="North")return b(u._1,u._2-4);if(o==="East")return b(u._1+4,u._2);if(o==="West")return b(u._1-4,u._2);g()})(),c=(k,L,E)=>!Io(e)(ce(L)(E))(ge(L)(E))(k),f=(k,L,E)=>!Io(n)(ce(L)(E))(ge(L)(E))(k),d=(k,L,E,B)=>t.tag==="Just"&&!Gi(n)(ce(k)(L))(ge(k)(L))(t._1)?t._1:i2(e)(k)(L)(E)(B),l=(k,L,E,B)=>{if(k===E){const et=o2(e)(L)(B)(k),D=e2(e)(k)(L)(B),S=r2(e)(k)(L)(B);return[{start:b(k,L),end:b(k,D),direction:ne},{start:b(k,D),end:b(et,D),direction:ee},{start:b(et,D),end:b(et,S),direction:ne},{start:b(et,S),end:b(E,S),direction:ee},{start:b(E,S),end:b(E,B),direction:ne}]}const V=d(k,E,L,B);return[{start:b(k,L),end:b(k,V),direction:ne},{start:b(k,V),end:b(E,V),direction:ee},{start:b(E,V),end:b(E,B),direction:ne}]},_=(k,L,E,B)=>{if(L===B){const et=u2(e)(k)(E)(L),D=t2(e)(L)(k)(E),S=n2(e)(L)(k)(E);return[{start:b(k,L),end:b(D,L),direction:ee},{start:b(D,L),end:b(D,et),direction:ne},{start:b(D,et),end:b(S,et),direction:ee},{start:b(S,et),end:b(S,B),direction:ne},{start:b(S,B),end:b(E,B),direction:ee}]}const V=Rg(e)(L)(B)(k)(E);return[{start:b(k,L),end:b(V,L),direction:ee},{start:b(V,L),end:b(V,B),direction:ne},{start:b(V,B),end:b(E,B),direction:ee}]},h=(k,L,E)=>!Gi(e)(ce(L)(E))(ge(L)(E))(k),m=(k,L,E)=>!Gi(n)(ce(L)(E))(ge(L)(E))(k),p=(k,L,E,B)=>{if(m(L,k,E)&&f(E,L,B))return[{start:b(k,L),end:b(E,L),direction:ee},{start:b(E,L),end:b(E,B),direction:ne}];const V=Rg(e)(L)(B)(k)(E);return[{start:b(k,L),end:b(V,L),direction:ee},{start:b(V,L),end:b(V,B),direction:ne},{start:b(V,B),end:b(E,B),direction:ee}]},y=(k,L,E,B)=>{if(f(k,L,B)&&m(B,k,E))return[{start:b(k,L),end:b(k,B),direction:ne},{start:b(k,B),end:b(E,B),direction:ee}];const V=d(k,E,L,B);return[{start:b(k,L),end:b(k,V),direction:ne},{start:b(k,V),end:b(E,V),direction:ee},{start:b(E,V),end:b(E,B),direction:ne}]},x=(()=>{if(r==="South")return o==="North"?s._1===a._1&&c(s._1,s._2,a._2)?[{start:b(s._1,s._2),end:b(a._1,a._2),direction:ne}]:l(s._1,s._2,a._1,a._2):o==="East"||o==="West"?y(s._1,s._2,a._1,a._2):l(s._1,s._2,a._1,a._2);if(r==="North")return o==="South"?s._1===a._1&&c(s._1,s._2,a._2)?[{start:b(s._1,s._2),end:b(a._1,a._2),direction:ne}]:l(s._1,s._2,a._1,a._2):o==="East"||o==="West"?y(s._1,s._2,a._1,a._2):l(s._1,s._2,a._1,a._2);if(r==="East")return o==="West"?s._2===a._2&&h(s._2,s._1,a._1)?[{start:b(s._1,s._2),end:b(a._1,a._2),direction:ee}]:_(s._1,s._2,a._1,a._2):o==="North"||o==="South"?p(s._1,s._2,a._1,a._2):l(s._1,s._2,a._1,a._2);if(r==="West"){if(o==="East")return s._2===a._2&&h(s._2,s._1,a._1)?[{start:b(s._1,s._2),end:b(a._1,a._2),direction:ee}]:_(s._1,s._2,a._1,a._2);if(o==="North"||o==="South")return p(s._1,s._2,a._1,a._2)}return l(s._1,s._2,a._1,a._2)})(),N=(()=>{if(r==="South"||r==="North")return ne;if(r==="East"||r==="West")return ee;g()})(),v={start:b(a._1,a._2),end:b(u._1,u._2),direction:(()=>{if(o==="South"||o==="North")return ne;if(o==="East"||o==="West")return ee;g()})()};return s._1===a._1&&s._2===a._2?[{start:b(i._1,i._2),end:b(u._1,u._2),direction:N}]:Vm({start:b(i._1,i._2),end:b(s._1,s._2),direction:N})(x)(v)},a2=H(t=>({x:t.position._1*Qo-2,y:t.position._2*Qo-2,w:t.size._1*Qo+4,h:t.size._2*Qo+4})),Cs=Kt(C)(Bt),Pn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Ss=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},c2=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t._1)(o._3._1);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(t._2==="North"){if(o._3._2==="North"){r=!1,i=w("Just",o._4);continue}n=o._5;continue}if(o._3._2==="North"){n=o._6;continue}if(t._2==="South"){if(o._3._2==="South"){r=!1,i=w("Just",o._4);continue}n=o._5;continue}if(o._3._2==="South"){n=o._6;continue}if(t._2==="East"){if(o._3._2==="East"){r=!1,i=w("Just",o._4);continue}n=o._5;continue}if(o._3._2==="East"){n=o._6;continue}if(t._2==="West"&&o._3._2==="West"){r=!1,i=w("Just",o._4);continue}}g()}return i},Wg=t=>e=>{const n=e.position._1+e.size._1,r=e.position._2*2+e.size._2,i=e.position._1*2+e.size._1,o=e.position._2+e.size._2;if(t==="South")return b(i,o*2);if(t==="North")return b(i,e.position._2*2);if(t==="East")return b(n*2,r);if(t==="West")return b(e.position._1*2,r);g()},Ds=t=>e=>{const n=rt(4);if(t==="South")return{lo:e.position._1*n,hi:(e.position._1+e.size._1)*n};if(t==="North")return{lo:e.position._1*n,hi:(e.position._1+e.size._1)*n};if(t==="East")return{lo:e.position._2*n,hi:(e.position._2+e.size._2)*n};if(t==="West")return{lo:e.position._2*n,hi:(e.position._2+e.size._2)*n};g()},Hg=t=>e=>J(n=>r=>vt(t)(te)(e(r))([r])(n))(Q),Og=t=>e=>n=>r=>{const i=(t==="South"||t==="North")&&(e==="East"||e==="West")&&(()=>{if(t==="South")return r._2>n._2;if(t==="North")return r._2<n._2;if(t==="East")return r._2>n._2;if(t==="West")return r._2<n._2;g()})()&&(()=>{if(e==="East")return n._1>r._1;if(e==="West"||e==="North")return n._1<r._1;if(e==="South")return n._1>r._1;g()})(),o=(t==="East"||t==="West")&&(e==="North"||e==="South")&&(()=>{if(t==="South")return r._1>n._1;if(t==="North")return r._1<n._1;if(t==="East")return r._1>n._1;if(t==="West")return r._1<n._1;g()})()&&(()=>{if(e==="East")return n._2>r._2;if(e==="West"||e==="North")return n._2<r._2;if(e==="South")return n._2>r._2;g()})();return(t==="South"?e==="North"&&n._1===r._1&&r._2>n._2:t==="North"?e==="South"&&n._1===r._1&&r._2<n._2:t==="East"?e==="West"&&n._2===r._2&&r._1>n._1:t==="West"&&e==="East"&&n._2===r._2&&r._1<n._1)?0:i||o?1:2},qg=t=>e=>{const n=t.hi-t.lo,r=(t.lo+t.hi)/2,i=e.length;return i===0?Q:Cs(i===1?H(o=>b(o,r))(e):Qt(o=>u=>b(u,t.lo+rt(o+1|0)*n/rt(i+1|0)))(e))},$g=t=>e=>n=>r=>i=>{const o=Hg(C)(_=>_.to.node)(t),u=Hg(C)(_=>_.from.node)(t),s=J(_=>h=>j(C)(h.node)(h)(_))(Q)(e),a=(_,h,m)=>{const p=Pn(_)(s);if(p.tag==="Nothing")return b(0,0);if(p.tag==="Just"){const y=Pn(_)(n);if(y.tag==="Nothing"){const x=rt(4);if(m==="South")return b(p._1.position._1*x+p._1.size._1*x/2,(p._1.position._2+p._1.size._2)*x);if(m==="North")return b(p._1.position._1*x+p._1.size._1*x/2,p._1.position._2*x);if(m==="East")return b((p._1.position._1+p._1.size._1)*x,p._1.position._2*x+p._1.size._2*x/2);if(m==="West")return b(p._1.position._1*x,p._1.position._2*x+p._1.size._2*x/2);g()}if(y.tag==="Just"){const x=Zt(N=>N.id===h)(y._1);if(x.tag==="Nothing"){const N=rt(4);if(m==="South")return b(p._1.position._1*N+p._1.size._1*N/2,(p._1.position._2+p._1.size._2)*N);if(m==="North")return b(p._1.position._1*N+p._1.size._1*N/2,p._1.position._2*N);if(m==="East")return b((p._1.position._1+p._1.size._1)*N,p._1.position._2*N+p._1.size._2*N/2);if(m==="West")return b(p._1.position._1*N,p._1.position._2*N+p._1.size._2*N/2);g()}if(x.tag==="Just"){const N=rt(4);if(x._1.side==="North")return b(p._1.position._1*N+rt(x._1.offset)*N,p._1.position._2*N);if(x._1.side==="South")return b(p._1.position._1*N+rt(x._1.offset)*N,(p._1.position._2+p._1.size._2)*N);if(x._1.side==="East")return b((p._1.position._1+p._1.size._1)*N,p._1.position._2*N+rt(x._1.offset)*N);if(x._1.side==="West")return b(p._1.position._1*N,p._1.position._2*N+rt(x._1.offset)*N)}}}g()},c=Cs(Tt(r)(_=>{if(_.nodes.length<=2)return[];const h=rt(4);if(1<_.nodes.length){const m=Pn(_.nodes[1])(s);if(m.tag==="Nothing")return[];if(m.tag==="Just"){const p=m._1.position._1*h+m._1.size._1*h/2;return H(y=>b(y,p))(Je(y=>x=>_.edgeId+":"+y+"->"+x,_.nodes,bt(1,_.nodes.length,_.nodes)))}g()}return[]})),f=_=>{const h=Pn(_.from.node)(s),m=Pn(_.to.node)(s);if(h.tag==="Just"&&m.tag==="Just"){const p=h._1,y=m._1,x=Lt(N=>v=>it.compare(N.score)(v.score))(H(N=>{const v=N._1,k=N._2;return{from:v,to:k,score:(()=>{const L=(et,D,S,Z,X)=>{const W=Ds(et)(D),z=Ds(et)(S);return W.lo<z.hi&&z.lo<W.hi&&(v==="South"?k==="North"&&X._2>Z._2:v==="North"?k==="South"&&X._2<Z._2:v==="East"?k==="West"&&X._1>Z._1:v==="West"&&k==="East"&&X._1<Z._1)?0:Og(v)(k)(Z)(X)},E=Wg(v)(p),B=Wg(k)(y),V=Og(v)(k)(E)(B);return(()=>{if(V>0){if(v==="South")return k==="North"?L(he,p,y,E,B)*10|0:V*10|0;if(v==="North")return k==="South"?L(le,p,y,E,B)*10|0:V*10|0;if(v==="East")return k==="West"?L(pn,p,y,E,B)*10|0:V*10|0;if(v==="West"&&k==="East")return L(_r,p,y,E,B)*10|0}return V*10|0})()+(v==="South"?k==="North"?0:15:v==="North"?k==="South"?0:15:v==="East"?k==="West"?5:15:v==="West"&&k==="East"?5:15)|0})()}})([b(he,le),b(pn,le),b(_r,le),b(he,pn),b(he,_r),b(le,he),b(le,pn),b(le,_r),b(pn,he),b(_r,he),b(pn,_r),b(_r,pn)]));if(0<x.length)return{from:x[0].from,to:x[0].to}}return{from:he,to:le}},d=Cs(H(_=>b(_.id,f(_)))(t)),l=(_,h,m,p,y,x)=>{const N=rt(4),v=Pn(h)(s);if(v.tag==="Nothing")return b(0,0);if(v.tag==="Just"){const k=c2(b(m,_))(i);if(k.tag==="Just"){const L=v._1.position._1*N+k._1,E=rt(4);if(_==="South")return b(L,(v._1.position._2+v._1.size._2)*E);if(_==="North")return b(L,v._1.position._2*E);if(_==="East")return b((v._1.position._1+v._1.size._1)*E,L);if(_==="West")return b(v._1.position._1*E,L);g()}if(k.tag==="Nothing"){const L=Ds(_)(v._1),E=(L.lo+L.hi)/2,B=Ss(m)(qg(L)(H(D=>D.id)(Lt(D=>S=>st.compare(y(_)(D))(y(_)(S)))(ct(D=>{const S=Ss(D.id)(d);if(S.tag==="Just"){const Z=x(S._1);return Z==="North"?_==="North":Z==="South"?_==="South":Z==="East"?_==="East":Z==="West"&&_==="West"}if(S.tag==="Nothing")return!0;g()},(()=>{const D=Pn(h)(p);if(D.tag==="Nothing")return[];if(D.tag==="Just")return D._1;g()})()))))),V=(()=>{if(B.tag==="Nothing")return E;if(B.tag==="Just")return B._1;g()})(),et=rt(4);if(_==="South")return b(V,(v._1.position._2+v._1.size._2)*et);if(_==="North")return b(V,v._1.position._2*et);if(_==="East")return b((v._1.position._1+v._1.size._1)*et,V);if(_==="West")return b(v._1.position._1*et,V)}}g()};return H(_=>{const h=Ss(_.edge.id)(c);if(h.tag==="Nothing")return _;if(h.tag==="Just")return{..._,fromPos:me(3)(_.edge.from.node)==="$d:"?b(h._1,_.fromPos._2):_.fromPos,toPos:me(3)(_.edge.to.node)==="$d:"?b(h._1,_.toPos._2):_.toPos};g()})(H(_=>{if(_.from.port.tag==="Just"&&_.to.port.tag==="Just")return{edge:_,fromPos:a(_.from.node,_.from.port._1,he),toPos:a(_.to.node,_.to.port._1,le),fromSide:he,toSide:le};const h=f(_);return{edge:_,fromPos:l(h.from,_.from.node,_.id,u,m=>p=>{const y=Pn(p.to.node)(s);if(y.tag==="Nothing")return 0;if(y.tag==="Just"){const x=rt(4);if(m==="South"||m==="North")return y._1.position._1*x+y._1.size._1*x/2;if(m==="East"||m==="West")return y._1.position._2*x+y._1.size._2*x/2}g()},m=>m.from),toPos:l(h.to,_.to.node,_.id,o,m=>p=>{const y=Pn(p.from.node)(s);if(y.tag==="Nothing")return 0;if(y.tag==="Just"){const x=rt(4);if(m==="South"||m==="North")return y._1.position._1*x+y._1.size._1*x/2;if(m==="East"||m==="West")return y._1.position._2*x+y._1.size._2*x/2}g()},m=>m.to),fromSide:h.from,toSide:h.to}})(t))},Yg=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Mr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},g2=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),Ps=t=>e=>t.gapTop+1*rt(4)+rt(e)*2.5*rt(4),f2=t=>e=>{const n=Yg(e.edge.id)(t);if(n.tag==="Just"){if(n._1.partner.tag==="Just")return w("Just",{slot1Y:Ps(n._1)(n._1.slot),splitX:n._1.partner._1.splitX,slot2Y:Ps(n._1)(n._1.partner._1.slot)});if(n._1.partner.tag==="Nothing")return T;g()}if(n.tag==="Nothing")return T;g()},_2=t=>e=>{const n=J(r=>i=>j(C)(i.node)(i)(r))(Q)(e);return Ae(Qt(r=>i=>{const o=Mr(i.node)(n);if(o.tag==="Nothing")return[];if(o.tag==="Just"){const u=o._1;return Qt(s=>a=>{const c=i.edges.length,f=rt(4),d=u.position._1*f,l=u.position._2*f,_=u.size._2*f,h=rt((2*c|0)+1|0),m=l+_*rt(c-s|0)/h,p=l+_*rt((c+1|0)+s|0)/h,y=d-f*2.5*rt(s+1|0),x=[{start:b(d,m),end:b(y,m),direction:ee},{start:b(y,m),end:b(y,p),direction:ne},{start:b(y,p),end:b(d,p),direction:ee}];return{edge:a.id,segments:x,bends:Je(N=>v=>N.end,x,bt(1,3,x)),bendType:[],jumps:[],reversed:!1}})(i.edges)}g()})(H(r=>({node:r._1,edges:r._2}))(g2(J(r=>i=>vt(C)(te)(i.from.node)([i])(r))(Q)(t)))))},d2=t=>e=>{const n=J(o=>u=>j(C)(u.node)(u)(o))(Q)(e),r=o=>{const u=Mr(o)(n);if(u.tag==="Nothing")return 0;if(u.tag==="Just")return u._1.position._1;g()},i=o=>{const u=Mr(o)(n);if(u.tag==="Nothing")return 0;if(u.tag==="Just")return u._1.layer;g()};return Lt(o=>u=>{const s=it.compare(i(o.edge.from.node))(i(u.edge.from.node));if(s==="EQ"){const a=st.compare(r(o.edge.from.node))(r(u.edge.from.node));return a==="EQ"?st.compare(r(o.edge.to.node))(r(u.edge.to.node)):a}return s})(t)},Pe=t=>{const e=rt(4);return{x:t.position._1*e-2,y:t.position._2*e-2,w:t.size._1*e+4,h:t.size._2*e+4}},l2=t=>t.from.node===t.to.node,h2=t=>e=>n=>r=>{const i=Km(n)(s2(t)(e)(n)(r.fromSide)(r.fromPos)(r.toSide)(r.toPos));return{edge:r.edge.id,segments:i,bends:Je(o=>u=>o.end,i,bt(1,i.length,i)),bendType:[],jumps:[],reversed:!1}},p2=t=>e=>n=>r=>{const i=[{start:b(r.fromPos._1,r.fromPos._2),end:b(r.fromPos._1,t.slot1Y),direction:ne},{start:b(r.fromPos._1,t.slot1Y),end:b(t.splitX,t.slot1Y),direction:ee},{start:b(t.splitX,t.slot1Y),end:b(t.splitX,t.slot2Y),direction:ne},{start:b(t.splitX,t.slot2Y),end:b(r.toPos._1,t.slot2Y),direction:ee},{start:b(r.toPos._1,t.slot2Y),end:b(r.toPos._1,r.toPos._2),direction:ne}];return{edge:r.edge.id,segments:i,bends:Je(o=>u=>o.end,i,bt(1,5,i)),bendType:[],jumps:[],reversed:!1}},m2=t=>e=>n=>{const r=Mr(t.edge.from.node)(n);if(r.tag==="Just"){const o=Mr(t.edge.to.node)(n);return o.tag==="Just"?ct(u=>!(u.h===Pe(r._1).h&&u.w===Pe(r._1).w&&u.x===Pe(r._1).x&&u.y===Pe(r._1).y)&&!(u.h===Pe(o._1).h&&u.w===Pe(o._1).w&&u.x===Pe(o._1).x&&u.y===Pe(o._1).y),e):ct(u=>!(u.h===Pe(r._1).h&&u.w===Pe(r._1).w&&u.x===Pe(r._1).x&&u.y===Pe(r._1).y),e)}const i=Mr(t.edge.to.node)(n);return i.tag==="Just"?ct(o=>!(o.h===Pe(i._1).h&&o.w===Pe(i._1).w&&o.x===Pe(i._1).x&&o.y===Pe(i._1).y),e):ct(o=>!0,e)},y2=t=>e=>{const n=Yg(e.edge.id)(t);if(n.tag==="Just")return w("Just",Ps(n._1)(n._1.slot));if(n.tag==="Nothing")return T;g()},x2=t=>e=>n=>r=>i=>{const o=J(c=>f=>j(C)(f.node)(f)(c))(Q)(e),u=a2(e),s=$g(ct(c=>c.from.node!==c.to.node,t))(e)(n)(r)(i),a=Mg(s)(e);return[..._2(ct(l2,t))(e),...J(c=>f=>{const d=m2(f)(u)(o),l=[...d,...c.edgeObstacles],_=f2(a)(f),h=(()=>{if(_.tag==="Just")return p2(_._1)(d)(l)(f);if(_.tag==="Nothing")return h2(y2(a)(f))(d)(l)(f);g()})();return{results:[...c.results,h],edgeObstacles:[...c.edgeObstacles,...Ym(h.segments)]}})({results:[],edgeObstacles:[]})(d2(s)(e)).results]},Zn=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Kn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},N2=t=>e=>n=>{if(t.start._1!==e.start._1)return T;const r=Kn(Zn(t.start._2)(t.end._2))(Zn(e.start._2)(e.end._2)),i=Zn(Kn(t.start._2)(t.end._2))(Kn(e.start._2)(e.end._2));return r<i?w("Just",{position:b(t.start._1,(r+i)/2),crossingEdge:n}):T},J2=t=>e=>n=>{if(t.start._2!==e.start._2)return T;const r=Kn(Zn(t.start._1)(t.end._1))(Zn(e.start._1)(e.end._1)),i=Zn(Kn(t.start._1)(t.end._1))(Kn(e.start._1)(e.end._1));return r<i?w("Just",{position:b((r+i)/2,t.start._2),crossingEdge:n}):T},T2=t=>e=>n=>{if(t.direction==="H")return J2(t)(e)(n);if(t.direction==="V")return N2(t)(e)(n);g()},v2=t=>e=>n=>{const r=t+1|0,i=r<1?n:bt(r,n.length,n);return Tt(e.segments)(o=>Tt(i)(u=>xt(s=>T2(o)(s)(u.edge))(ct(s=>s.direction==="H"?o.direction==="H":s.direction==="V"&&o.direction==="V",u.segments))))},w2=t=>e=>n=>e.start._1>Zn(t.start._1)(t.end._1)&&e.start._1<Kn(t.start._1)(t.end._1)&&t.start._2>Zn(e.start._2)(e.end._2)&&t.start._2<Kn(e.start._2)(e.end._2)?w("Just",{position:b(e.start._1,t.start._2),crossingEdge:n}):T,b2=t=>e=>Tt(ct(n=>n.direction==="H",t.segments))(n=>Tt(e)(r=>xt(i=>w2(n)(i)(r.edge))(ct(i=>i.direction==="V",r.segments)))),L2=t=>e=>n=>[...b2(e)(ct(r=>r.edge!==e.edge,n)),...v2(t)(e)(n)],Vg=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Xg=t=>me(3)(t)==="$d:",k2=t=>e=>n=>J(r=>i=>{const o=Vg(i.from.node)(t),u=(()=>{if(o.tag==="Nothing")return 0;if(o.tag==="Just")return o._1;g()})(),s=Vg(i.to.node)(t),a=(()=>{if(s.tag==="Nothing")return-u;if(s.tag==="Just")return s._1-u|0;g()})();if(a<=1)return{...r,edges:[...r.edges,i],chains:[...r.chains,{edgeId:i.id,nodes:[i.from.node,i.to.node]}]};const c=i.id,f=H(l=>"$d:"+c+":"+ie(l))(It(1,a-1|0)),d=[i.from.node,...f,i.to.node];return{...r,layers:J(l=>_=>{const h=_._2,m=od(u+_._1|0)(p=>[...p,h])(l);if(m.tag==="Nothing")return l;if(m.tag==="Just")return m._1;g()})(r.layers)(Je(Hn,It(1,a-1|0),f)),edges:[...r.edges,...Je(l=>_=>({id:c+":"+l+"->"+_,from:{node:l,port:i.from.port},to:{node:_,port:i.to.port}}),d,bt(1,d.length,d))],chains:[...r.chains,{edgeId:i.id,nodes:d}]}})({layers:n,edges:[],chains:[]})(e),Fo=(()=>{const t={eq:e=>n=>e._1===n._1&&(e._2==="North"?n._2==="North":e._2==="South"?n._2==="South":e._2==="East"?n._2==="East":e._2==="West"&&n._2==="West")};return{compare:e=>n=>{const r=C.compare(e._1)(n._1);if(r==="LT")return ye;if(r==="GT")return xe;if(e._2==="North")return n._2==="North"?Se:ye;if(n._2==="North")return xe;if(e._2==="South")return n._2==="South"?Se:ye;if(n._2==="South")return xe;if(e._2==="East")return n._2==="East"?Se:ye;if(n._2==="East")return xe;if(e._2==="West"&&n._2==="West")return Se;g()},Eq0:()=>t}})(),E2=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=Fo.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},G2=Kt(C)(Bt),Is=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},C2=Kt(Fo)(Bt),Ug=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),Br=t=>e=>n=>r=>{const i=E2(b(e,n))(t);if(i.tag==="Nothing")return r;if(i.tag==="Just")return i._1;g()},jg=t=>e=>n=>{const r=G2(Ae(H(u=>Qt(s=>a=>b(a,s))(u))(t))),i=(u,s)=>{if(u==="South"){const a=Is(s.to.node)(r);if(a.tag==="Nothing")return 0;if(a.tag==="Just")return a._1;g()}if(u==="North"){const a=Is(s.from.node)(r);if(a.tag==="Nothing")return 0;if(a.tag==="Just")return a._1;g()}return 0},o=u=>J(s=>a=>Ge(Fo.compare,Le,C2(H(c=>b(b(c._1,u),c._2))(Ug(qg({lo:0,hi:(()=>{const c=Is(a._1)(n);if(c.tag==="Just")return c._1._1;if(c.tag==="Nothing")return me(3)(a._1)==="$d:"?0:1;g()})()})(H(c=>c.id)(Lt(c=>f=>it.compare(i(u,c))(i(u,f)))(a._2)))))),s))(Q)(Ug(J(s=>a=>a.from.node===a.to.node?s:u==="South"?vt(C)(te)(a.from.node)([a])(s):u==="North"?vt(C)(te)(a.to.node)([a])(s):s)(Q)(e)));return Ge(Fo.compare,Le,o(le),o(he))},Zg=t=>t,Kg=t=>t,tf=t=>t,S2=J(t=>e=>j(C)(e)()(t))(Q),D2=(()=>{const t=qe.unfoldr(e=>{if(e.tag==="Nil")return T;if(e.tag==="Cons")return w("Just",b(e._1,e._2));g()});return e=>t((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._3,n(r._6,i)));g()};return n(e,qt)})())})(),ot=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},en=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Nn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Jn=Kt(C)(Bt),Qs=Xa(C),Fs=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),P2=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},I2=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},ef=tf("VDown"),nf=tf("VUp"),Q2=Kg("ForwardPhase"),F2=Kg("StackPhase"),rf=Zg("HRight"),of=Zg("HLeft"),uf=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},A2=t=>e=>n=>{const r=J(u=>s=>vt(C)(oe)(s.tgt)(1)(u))(Q)(t),i=D2(S2([...H(u=>u.src)(t),...H(u=>u.tgt)(t),...(()=>{const u=(s,a)=>{if(s.tag==="Leaf")return a;if(s.tag==="Node")return u(s._5,Ot("Cons",s._4,u(s._6,a)));g()};return kt($t.foldr,u(e,qt))})()])),o=J(u=>s=>vt(C)(te)(s.src)([{target:s.tgt,sep:s.sep}])(u))(Q)(t);return(u=>s=>a=>{let c=u,f=s,d=a,l=!0,_;for(;l;){const h=c,m=f,p=d,y=Ft(x=>T,x=>N=>w("Just",{head:x,tail:N}),h);if(y.tag==="Nothing"){l=!1,_=p;continue}if(y.tag==="Just"){const x=ot(y._1.head)(p),N=(()=>{if(x.tag==="Nothing")return 0;if(x.tag==="Just")return x._1;g()})(),v=J(k=>L=>{const E=ot(L.target)(k.result),B=N+L.sep,V=ot(L.target)(k.indeg),et=(()=>{if(V.tag==="Nothing")return-1;if(V.tag==="Just")return V._1-1|0;g()})();return{newQueue:et===0?[...k.newQueue,L.target]:k.newQueue,result:j(C)(L.target)((()=>{if(E.tag==="Nothing")return B;if(E.tag==="Just"){if(n==="VDown")return en(E._1)(B);if(n==="VUp")return Nn(E._1)(B)}g()})())(k.result),indeg:j(C)(L.target)(et)(k.indeg)}})({newQueue:[],result:p,indeg:m})((()=>{const k=ot(y._1.head)(o);if(k.tag==="Nothing")return[];if(k.tag==="Just")return k._1;g()})());c=[...y._1.tail,...v.newQueue],f=v.indeg,d=v.result;continue}g()}return _})(ct(u=>{const s=ot(u)(r);if(s.tag==="Nothing")return!0;if(s.tag==="Just")return s._1===0;g()},i))(r)(J(u=>s=>j(C)(s)(0)(u))(Q)(i))},M2=t=>{const e=(o,u)=>{if(o.tag==="Leaf")return u;if(o.tag==="Node")return e(o._5,Ot("Cons",o._4,e(o._6,u)));g()},n=kt($t.foldr,e(t,qt)),r=J(en)(999999)(n);if(r===0||n.length===0)return t;const i=o=>{if(o.tag==="Leaf")return Q;if(o.tag==="Node")return Wt("Node",o._1,o._2,o._3,o._4-r,i(o._5),i(o._6));g()};return i(t)},sf=t=>{const e=(o,u)=>{if(o.tag==="Leaf")return u;if(o.tag==="Node")return e(o._5,Ot("Cons",o._4,e(o._6,u)));g()},n=e(t,qt),r=o=>u=>{let s=o,a=u,c=!0,f;for(;c;){const d=s,l=a;if(l.tag==="Nil"){c=!1,f=d;continue}if(l.tag==="Cons"){s=Nn(d)(l._1),a=l._2;continue}g()}return f},i=o=>u=>{let s=o,a=u,c=!0,f;for(;c;){const d=s,l=a;if(l.tag==="Nil"){c=!1,f=d;continue}if(l.tag==="Cons"){s=en(d)(l._1),a=l._2;continue}g()}return f};return r(-999999)(n)-i(999999)(n)},Ci=t=>e=>(n=>r=>{let i=n,o=r,u=!0,s;for(;u;){const a=i,c=o;if(a===e){u=!1,s=c;continue}i=(()=>{const f=ot(a)(t.align);if(f.tag==="Nothing")return e;if(f.tag==="Just")return f._1;g()})(),o=[...c,a]}return s})((()=>{const n=ot(e)(t.align);if(n.tag==="Nothing")return e;if(n.tag==="Just")return n._1;g()})())([e]),B2=t=>e=>n=>r=>i=>o=>u=>s=>a=>c=>f=>{const d=(G,P,I)=>{const F=G.from.node===P?G.from.port:G.to.node===P?G.to.port:T;if(F.tag==="Just"){const O=ot(P)(i);if(O.tag==="Just"){const Y=Zt(q=>q.id===F._1)(O._1);if(Y.tag==="Just"){const q=rt(Y._1.offset)*rt(4);return I==="North"||I==="South"?q:0}if(Y.tag==="Nothing"){const q=ot(P)(r),$=Br(u)(G.id)(I)((()=>{if(q.tag==="Nothing")return .5;if(q.tag==="Just")return q._1._1/2;g()})());return I==="North"||I==="South"?$:0}g()}if(O.tag==="Nothing"){const Y=ot(P)(r),q=Br(u)(G.id)(I)((()=>{if(Y.tag==="Nothing")return .5;if(Y.tag==="Just")return Y._1._1/2;g()})());return I==="North"||I==="South"?q:0}g()}if(F.tag==="Nothing"){const O=ot(P)(r),Y=Br(u)(G.id)(I)((()=>{if(O.tag==="Nothing")return .5;if(O.tag==="Just")return O._1._1/2;g()})());return I==="North"||I==="South"?Y:0}g()},l=(G,P)=>{if(G.from.node===P){if(f==="HRight")return he;if(f==="HLeft")return le;g()}if(f==="HRight")return le;if(f==="HLeft")return he;g()},_=(G,P,I)=>J(F=>O=>j(C)(O)((()=>{const Y=ot(O)(F);if(Y.tag==="Nothing")return 0+P;if(Y.tag==="Just")return Y._1+P;g()})())(F))(I)(Ci(a)(G)),h=(()=>{if(f==="HRight")return n;if(f==="HLeft")return ke(n);g()})(),m=G=>{const P=ot(G)(r);if(P.tag==="Nothing")return 1;if(P.tag==="Just")return P._1._1;g()},p=Jn(Ae(Qt(G=>P=>H(I=>b(I,G))(P))(n))),y=(G,P)=>me(3)(G)==="$d:"&&me(3)(P)==="$d:"||me(3)(G)==="$d:"||me(3)(P)==="$d:"?10:rt(t.nodeGap),x=J(G=>P=>Qs(I=>w("Just",[...(()=>{if(I.tag==="Nothing")return[];if(I.tag==="Just")return I._1;g()})(),P]))(P.to.node)(G))(Q)(o),N=J(G=>P=>Qs(I=>w("Just",[...(()=>{if(I.tag==="Nothing")return[];if(I.tag==="Just")return I._1;g()})(),P]))(P.from.node)(G))(Q)(o),v=Ae(n),k=J(G=>P=>{const I=ot(P)(a.root),F=(()=>{if(I.tag==="Nothing")return P;if(I.tag==="Just")return I._1;g()})();return P===F?G:Qs(O=>w("Just",(()=>{if(O.tag==="Nothing")return!0;if(O.tag==="Just")return O._1;g()})()&&me(3)(P)==="$d:"))(F)(G)})(Jn(H(G=>b(G,!0))(Nr(C.compare)((()=>{const G=(P,I)=>{if(P.tag==="Leaf")return I;if(P.tag==="Node")return G(P._5,Ot("Cons",P._4,G(P._6,I)));g()};return kt($t.foldr,G(a.root,qt))})()))))(v),L=(G,P)=>{const I=G.free,F=ot(I)(a.root),O=(()=>{if(F.tag==="Nothing")return I;if(F.tag==="Just")return F._1;g()})(),Y=ot(O)(k),q=(()=>{if(Y.tag==="Nothing")return!0;if(Y.tag==="Just")return Y._1;g()})();return J($=>R=>{if($.edge.tag==="Just")return $;if($.edge.tag==="Nothing"){if((()=>{const at=ot(O)(P.su);return!q&&(()=>{const yt=ot(R.from.node)(p);return R.from.node!==R.to.node&&(()=>{const Et=ot(R.to.node)(p);return(()=>{if(yt.tag==="Nothing")return-1;if(yt.tag==="Just")return yt._1;g()})()===(()=>{if(Et.tag==="Nothing")return-1;if(Et.tag==="Just")return Et._1;g()})()})()})()||(()=>{if(at.tag==="Nothing")return!1;if(at.tag==="Just")return at._1;g()})()})())return $;const tt=R.from.node===I?R.to.node:R.from.node,K=ot(tt)(a.root),gt=(()=>{if(K.tag==="Nothing")return tt;if(K.tag==="Just")return K._1;g()})(),_t=gt!==O;return _t&&(()=>{const at=ot(gt)(P.blockFinished);if(at.tag==="Nothing")return!1;if(at.tag==="Just")return at._1;g()})()?{...$,edge:w("Just",R),hasEdges:!0}:{...$,hasEdges:$.hasEdges||_t}}g()})({edge:T,hasEdges:!1})((()=>{if(G.isRoot){if(f==="HRight"){const $=ot(I)(x);if($.tag==="Nothing")return[];if($.tag==="Just")return $._1;g()}if(f==="HLeft"){const $=ot(I)(N);if($.tag==="Nothing")return[];if($.tag==="Just")return $._1}g()}if(f==="HRight"){const $=ot(I)(N);if($.tag==="Nothing")return[];if($.tag==="Just")return $._1;g()}if(f==="HLeft"){const $=ot(I)(x);if($.tag==="Nothing")return[];if($.tag==="Just")return $._1}g()})())},E=(G,P,I,F)=>{const O=(()=>{if(c==="VDown")return-1e18;if(c==="VUp")return 1e18;g()})(),Y={free:P,isRoot:I},q=L(Y,F);if(q.edge.tag==="Nothing")return q.hasEdges?{thresh:O,state:{...F,queue:[...F.queue,Y]}}:{thresh:O,state:F};if(q.edge.tag==="Just"){const $=q.edge._1.from.node===P?q.edge._1.to.node:q.edge._1.from.node;return{thresh:(()=>{const R=ot((()=>{const _t=ot($)(a.root);if(_t.tag==="Nothing")return $;if(_t.tag==="Just")return _t._1;g()})())(F.x),tt=ot($)(s),K=ot(P)(s),gt=(()=>{if(R.tag==="Just")return R._1;if(R.tag==="Nothing")return T;g()})();return(()=>{if(gt.tag==="Nothing")return 0;if(gt.tag==="Just")return gt._1;g()})()+(()=>{if(tt.tag==="Nothing")return 0;if(tt.tag==="Just")return tt._1;g()})()+d(q.edge._1,$,(()=>{if(I){if(f==="HRight")return he;if(f==="HLeft")return le;g()}if(f==="HRight")return le;if(f==="HLeft")return he;g()})())-(()=>{if(K.tag==="Nothing")return 0;if(K.tag==="Just")return K._1;g()})()-d(q.edge._1,P,(()=>{if(I){if(f==="HRight")return le;if(f==="HLeft")return he;g()}if(f==="HRight")return he;if(f==="HLeft")return le;g()})())})(),state:{...F,su:j(C)((()=>{const R=ot(q.edge._1.from.node)(a.root);if(R.tag==="Nothing")return q.edge._1.from.node;if(R.tag==="Just")return R._1;g()})())(!0)(j(C)((()=>{const R=ot(q.edge._1.to.node)(a.root);if(R.tag==="Nothing")return q.edge._1.to.node;if(R.tag==="Just")return R._1;g()})())(!0)(F.su))}}}g()},B=(G,P,I,F)=>{const O=P===G,Y=ot(P)(a.align),q=(()=>{if(Y.tag==="Nothing")return P===G;if(Y.tag==="Just")return Y._1===G;g()})();if(!(O||q))return{thresh:I,state:F};const $=(()=>{if(c==="VDown")return O&&I<=-1e18;if(c==="VUp")return O&&I>=1e18;g()})()?E(G,P,!0,F):{thresh:I,state:F};return(()=>{if(c==="VDown")return $.thresh<=-1e18&&q;if(c==="VUp")return $.thresh>=1e18&&q;g()})()?E(G,P,!1,$.state):$},V=G=>P=>I=>{const F=ot(I)(e.nodeIndex),O=(()=>{if(F.tag==="Nothing")return 0;if(F.tag==="Just")return F._1;g()})(),Y=Zt(K=>Be(gn)(I)(K))(h),q=(()=>{if(Y.tag==="Nothing")return[];if(Y.tag==="Just")return Y._1;g()})(),$=q.length;if((()=>{if(c==="VDown")return O<=0;if(c==="VUp")return O>=($-1|0);g()})()){const K=B(G,I,P.thresh,P.st);return{...P,st:K.state,thresh:K.thresh}}const R=(()=>{if(c==="VDown")return O-1|0;if(c==="VUp")return O+1|0;g()})(),tt=R>=0&&R<q.length?w("Just",q[R]):T;if(tt.tag==="Nothing")return P;if(tt.tag==="Just"){const K=ot(tt._1)(a.root),gt=(()=>{if(K.tag==="Nothing")return tt._1;if(K.tag==="Just")return K._1;g()})(),_t=B(G,I,P.thresh,et(gt)(P.st)),at=(()=>{const Vt=ot(G)(_t.state.sink);if(Vt.tag==="Nothing")return G===G;if(Vt.tag==="Just")return Vt._1===G;g()})()?{..._t.state,sink:j(C)(G)((()=>{const Vt=ot(gt)(_t.state.sink);if(Vt.tag==="Nothing")return gt;if(Vt.tag==="Just")return Vt._1;g()})())(_t.state.sink)}:_t.state,yt=ot(gt)(at.sink),Et=(()=>{if(yt.tag==="Nothing")return gt;if(yt.tag==="Just")return yt._1;g()})(),At=ot(G)(at.sink),pt=(()=>{if(At.tag==="Nothing")return G;if(At.tag==="Just")return At._1;g()})();if(pt===Et){const Vt=ot(gt)(at.x),De=(()=>{if(Vt.tag==="Just")return Vt._1;if(Vt.tag==="Nothing")return T;g()})(),un=(()=>{if(De.tag==="Nothing")return 0;if(De.tag==="Just")return De._1;g()})(),Ne=ot(G)(at.x),Ct=(()=>{if(Ne.tag==="Just")return Ne._1;if(Ne.tag==="Nothing")return T;g()})(),Pt=(()=>{if(Ct.tag==="Nothing")return 0;if(Ct.tag==="Just")return Ct._1;g()})(),je=y(I,tt._1),Ze=ot(tt._1)(s),kn=ot(I)(s),jr=(()=>{if(Ze.tag==="Nothing")return 0;if(Ze.tag==="Just")return Ze._1;g()})()-(()=>{if(kn.tag==="Nothing")return 0;if(kn.tag==="Just")return kn._1;g()})();if(c==="VDown"){const _n=Nn(un+jr+m(tt._1)+je)(_t.thresh);return{st:{...at,x:j(C)(G)(w("Just",P.initial?_n:Nn(Pt)(_n)))(at.x)},initial:!1,thresh:_t.thresh}}if(c==="VUp"){const _n=en(un+jr-je-m(I))(_t.thresh);return{st:{...at,x:j(C)(G)(w("Just",P.initial?_n:en(Pt)(_n)))(at.x)},initial:!1,thresh:_t.thresh}}g()}const Mt=ot(gt)(at.x),Jt=(()=>{if(Mt.tag==="Just")return Mt._1;if(Mt.tag==="Nothing")return T;g()})(),mt=(()=>{if(Jt.tag==="Nothing")return 0;if(Jt.tag==="Just")return Jt._1;g()})(),nt=ot(G)(at.x),U=(()=>{if(nt.tag==="Just")return nt._1;if(nt.tag==="Nothing")return T;g()})(),ut=(()=>{if(U.tag==="Nothing")return 0;if(U.tag==="Just")return U._1;g()})(),ft=rt(t.nodeGap),lt=ot(I)(s),Nt=ot(tt._1)(s),Ht=(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})()-(()=>{if(Nt.tag==="Nothing")return 0;if(Nt.tag==="Just")return Nt._1;g()})();return{st:{...at,classEdges:[...at.classEdges,{src:pt,tgt:Et,sep:(()=>{if(c==="VDown")return ut+Ht-mt-m(tt._1)-ft;if(c==="VUp")return ut+Ht+m(I)+ft-mt;g()})()}]},initial:P.initial,thresh:_t.thresh}}g()},et=G=>P=>{const I=ot(G)(P.x),F=(()=>{if(I.tag==="Just")return I._1;if(I.tag==="Nothing")return T;g()})();if(F.tag==="Just")return P;if(F.tag==="Nothing"){const O=J(V(G))({st:{...P,x:j(C)(G)(w("Just",0))(P.x)},initial:!0,thresh:(()=>{if(c==="VDown")return-1e18;if(c==="VUp")return 1e18;g()})()})(Ci(a)(G));return{...O.st,blockFinished:j(C)(G)(!0)(O.st.blockFinished)}}g()},D=J(G=>P=>J(I=>F=>{const O=ot(F)(a.root),Y=(()=>{if(O.tag==="Nothing")return F;if(O.tag==="Just")return O._1;g()})();return Y===F?et(Y)(I):I})(G)((()=>{if(c==="VDown")return P;if(c==="VUp")return ke(P);g()})()))({x:Jn(H(G=>b(G,T))(v)),sink:Jn(H(G=>b(G,G))(v)),classEdges:[],su:Q,blockFinished:Q,queue:[]})(h),S=A2(D.classEdges)(D.sink)(c),Z=(G,P,I,F)=>{const O=ot(P)(F),Y=ot(P)(s);return(()=>{if(O.tag==="Nothing")return 0;if(O.tag==="Just")return O._1;g()})()+(()=>{if(Y.tag==="Nothing")return 0;if(Y.tag==="Just")return Y._1;g()})()+d(G,P,I)},X=Jn(H(G=>b(G,!0))(Nr(C.compare)((()=>{const G=(P,I)=>{if(P.tag==="Leaf")return I;if(P.tag==="Node")return G(P._5,Ot("Cons",P._4,G(P._6,I)));g()};return kt($t.foldr,G(a.root,qt))})()))),W=G=>P=>I=>{const F=L(I,{su:P.su,blockFinished:X}),O={phase:G,ppFree:I.free,ppIsRoot:I.isRoot,edgeId:T,delta:0,avail:0,shift:0,freeSu:(()=>{const Y=ot((()=>{const q=ot(I.free)(a.root);if(q.tag==="Nothing")return I.free;if(q.tag==="Just")return q._1;g()})())(P.su);if(Y.tag==="Nothing")return!1;if(Y.tag==="Just")return Y._1;g()})(),hasEdges:F.hasEdges,candCount:(()=>{if(I.isRoot){if(f==="HRight"){const Y=ot(I.free)(x);if(Y.tag==="Nothing")return 0;if(Y.tag==="Just")return Y._1.length;g()}if(f==="HLeft"){const Y=ot(I.free)(N);if(Y.tag==="Nothing")return 0;if(Y.tag==="Just")return Y._1.length}g()}if(f==="HRight"){const Y=ot(I.free)(N);if(Y.tag==="Nothing")return 0;if(Y.tag==="Just")return Y._1.length;g()}if(f==="HLeft"){const Y=ot(I.free)(x);if(Y.tag==="Nothing")return 0;if(Y.tag==="Just")return Y._1.length}g()})()};if(F.edge.tag==="Nothing")return{...P,stack:[...P.stack,I],trace:[...P.trace,O],x:P.x};if(F.edge.tag==="Just"){const Y=F.edge._1.from.node===I.free?b(F.edge._1.from.node,F.edge._1.to.node):b(F.edge._1.to.node,F.edge._1.from.node),q=Z(F.edge._1,Y._1,l(F.edge._1,Y._1),P.x)-Z(F.edge._1,Y._2,l(F.edge._1,Y._2),P.x),$=ot(Y._1)(a.root),R=(()=>{if($.tag==="Nothing")return Y._1;if($.tag==="Just")return $._1;g()})(),tt={...O,edgeId:w("Just",F.edge._1.id),delta:q};if(q>0&&q<1e300){const K=J(at=>yt=>{const Et=ot(yt)(p),At=(()=>{if(Et.tag==="Nothing")return-1;if(Et.tag==="Just")return Et._1;g()})();if(At>=0&&At<n.length){const Jt=n[At],mt=ot(yt)(e.nodeIndex),nt=(()=>{if(mt.tag==="Nothing")return-2;if(mt.tag==="Just")return mt._1-1|0;g()})();return nt>=0&&nt<Jt.length?en(at)((()=>{const U=ot(yt)(P.x),ut=ot(yt)(s),ft=ot(Jt[nt])(P.x),lt=ot(Jt[nt])(s);return(()=>{if(U.tag==="Nothing")return 0;if(U.tag==="Just")return U._1;g()})()+(()=>{if(ut.tag==="Nothing")return 0;if(ut.tag==="Just")return ut._1;g()})()-((()=>{if(ft.tag==="Nothing")return 0;if(ft.tag==="Just")return ft._1;g()})()+(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})()+m(Jt[nt])+y(yt,Jt[nt]))})()):at}const pt=ot(yt)(e.nodeIndex),Mt=(()=>{if(pt.tag==="Nothing")return-2;if(pt.tag==="Just")return pt._1-1|0;g()})();return Mt>=0&&Mt<0?en(at)((()=>{const Jt=ot(yt)(P.x),mt=ot(yt)(s),nt=ot([][Mt])(P.x),U=ot([][Mt])(s);return(()=>{if(Jt.tag==="Nothing")return 0;if(Jt.tag==="Just")return Jt._1;g()})()+(()=>{if(mt.tag==="Nothing")return 0;if(mt.tag==="Just")return mt._1;g()})()-((()=>{if(nt.tag==="Nothing")return 0;if(nt.tag==="Just")return nt._1;g()})()+(()=>{if(U.tag==="Nothing")return 0;if(U.tag==="Just")return U._1;g()})()+m([][Mt])+y(yt,[][Mt]))})()):at})(q)(Ci(a)(R)),gt=K>0?-K:0,_t={...P,x:K>0?_(R,gt,P.x):P.x,trace:[...P.trace,{...tt,avail:K,shift:gt}]};return K>0?_t:{..._t,stack:[..._t.stack,I]}}if(q<0&&-q<1e300){const K=J(at=>yt=>{const Et=ot(yt)(p),At=(()=>{if(Et.tag==="Nothing")return-1;if(Et.tag==="Just")return Et._1;g()})();if(At>=0&&At<n.length){const Jt=n[At],mt=ot(yt)(e.nodeIndex),nt=(()=>{if(mt.tag==="Nothing")return 0;if(mt.tag==="Just")return mt._1+1|0;g()})();return nt>=0&&nt<Jt.length?en(at)((()=>{const U=ot(Jt[nt])(P.x),ut=ot(Jt[nt])(s),ft=ot(yt)(P.x),lt=ot(yt)(s);return(()=>{if(U.tag==="Nothing")return 0;if(U.tag==="Just")return U._1;g()})()+(()=>{if(ut.tag==="Nothing")return 0;if(ut.tag==="Just")return ut._1;g()})()-((()=>{if(ft.tag==="Nothing")return 0;if(ft.tag==="Just")return ft._1;g()})()+(()=>{if(lt.tag==="Nothing")return 0;if(lt.tag==="Just")return lt._1;g()})()+m(yt)+y(yt,Jt[nt]))})()):at}const pt=ot(yt)(e.nodeIndex),Mt=(()=>{if(pt.tag==="Nothing")return 0;if(pt.tag==="Just")return pt._1+1|0;g()})();return Mt>=0&&Mt<0?en(at)((()=>{const Jt=ot([][Mt])(P.x),mt=ot([][Mt])(s),nt=ot(yt)(P.x),U=ot(yt)(s);return(()=>{if(Jt.tag==="Nothing")return 0;if(Jt.tag==="Just")return Jt._1;g()})()+(()=>{if(mt.tag==="Nothing")return 0;if(mt.tag==="Just")return mt._1;g()})()-((()=>{if(nt.tag==="Nothing")return 0;if(nt.tag==="Just")return nt._1;g()})()+(()=>{if(U.tag==="Nothing")return 0;if(U.tag==="Just")return U._1;g()})()+m(yt)+y(yt,[][Mt]))})()):at})(-q)(Ci(a)(R)),gt=K>0?K:0,_t={...P,x:K>0?_(R,gt,P.x):P.x,trace:[...P.trace,{...tt,avail:K,shift:gt}]};return K>0?_t:{..._t,stack:[..._t.stack,I]}}return{...P,stack:[...P.stack,I],trace:[...P.trace,tt],x:P.x}}g()},z=J(W(Q2))({x:Jn(H(G=>b(G,(()=>{const P=ot(G)(a.root),I=(()=>{if(P.tag==="Nothing")return G;if(P.tag==="Just")return P._1;g()})(),F=ot(I)(D.x),O=ot((()=>{const q=ot(I)(D.sink);if(q.tag==="Nothing")return I;if(q.tag==="Just")return q._1;g()})())(S),Y=(()=>{if(F.tag==="Just")return F._1;if(F.tag==="Nothing")return T;g()})();return(()=>{if(Y.tag==="Nothing")return 0;if(Y.tag==="Just")return Y._1;g()})()+(()=>{if(O.tag==="Nothing")return 0;if(O.tag==="Just")return O._1;g()})()})()))(v)),su:D.su,stack:[],trace:[]})(D.queue),M=J(W(F2))({...z,stack:[]})(ke(z.stack));return{x:M.x,queue:D.queue,trace:M.trace}},z2=t=>e=>n=>r=>i=>o=>u=>s=>a=>c=>f=>B2(t)(e)(n)(r)(i)(o)(u)(s)(a)(c)(f).x,R2=t=>e=>n=>r=>i=>o=>{const u=(a,c,f)=>{const d=ot(c)(n),l=(()=>{if(d.tag==="Nothing")return .5;if(d.tag==="Just")return d._1._1/2;g()})(),_=a.from.node===c?a.from.port:a.to.node===c?a.to.port:T;if(_.tag==="Just"){const h=ot(c)(e);if(h.tag==="Just"){const m=Zt(p=>p.id===_._1)(h._1);if(m.tag==="Just"){const p=rt(m._1.offset)*rt(4);return f==="North"||f==="South"?p:0}if(m.tag==="Nothing"){const p=Br(i)(a.id)(f)(l);return f==="North"||f==="South"?p:0}g()}if(h.tag==="Nothing"){const m=Br(i)(a.id)(f)(l);return f==="North"||f==="South"?m:0}g()}if(_.tag==="Nothing"){const h=Br(i)(a.id)(f)(l);return f==="North"||f==="South"?h:0}g()},s=a=>c=>f=>d=>{let l=a,_=c,h=f,m=d,p=!0,y;for(;p;){const x=l,N=_,v=h,k=Ft(L=>T,L=>E=>w("Just",{head:L,tail:E}),m);if(k.tag==="Nothing"){p=!1,y=x;continue}if(k.tag==="Just"){const L=k._1.head,E=Zt(V=>V.from.node===v&&V.to.node===L||V.from.node===L&&V.to.node===v)(r),B=(()=>{if(E.tag==="Nothing")return N+0;if(E.tag==="Just")return N+(u(E._1,v,E._1.from.node===v?he:le)-u(E._1,L,E._1.from.node===L?he:le));g()})();l=j(C)(L)(B)(x),_=B,h=L,m=k._1.tail;continue}g()}return y};return J(a=>c=>{const f=Ft(_=>T,_=>h=>w("Just",{head:_,tail:h}),Ci(t)(c)),d=(()=>{if(f.tag==="Nothing")return j(C)(c)(0)(Q);if(f.tag==="Just")return s(j(C)(f._1.head)(0)(Q))(0)(f._1.head)(f._1.tail);g()})(),l=J(_=>h=>Nn(_)(-h._2))(0)(Fs(d));return J(_=>h=>j(C)(h._1)(h._2+l)(_))(a)(Fs(d))})(Q)(Nr(C.compare)((()=>{const a=(c,f)=>{if(c.tag==="Leaf")return f;if(c.tag==="Node")return a(c._5,Ot("Cons",c._4,a(c._6,f)));g()};return kt($t.foldr,a(t.root,qt))})()))},W2=t=>e=>{const n=(i,o,u)=>me(3)(o)==="$d:"&&Ra(Xg,(()=>{const s=ot(o)(t.preds);if(s.tag==="Nothing")return[];if(s.tag==="Just")return s._1;g()})()),r=i=>o=>u=>s=>a=>c=>f=>{let d=i,l=o,_=s,h=c,m=f,p=!0,y;for(;p;){const x=d,N=l,v=_,k=h,L=m,E=N.length;if(L>=E){p=!1,y=x;continue}const B=L>=0&&L<N.length?w("Just",N[L]):T,V=(()=>{if(B.tag==="Nothing")return"";if(B.tag==="Just")return B._1;g()})(),et=n(t,V);if(L===(E-1|0)||et){const D=(()=>{if(et){const S=ot(V)(t.preds),Z=(()=>{if(S.tag==="Nothing")return[];if(S.tag==="Just")return S._1;g()})();if(0<Z.length){const X=v-1|0,W=ot(Z[0])(t.nodeIndex);if(W.tag==="Nothing")return X;if(W.tag==="Just")return W._1;g()}}return v-1|0})();d=J(S=>Z=>{if(Z>=0&&Z<N.length){const X=N[Z];return n(t,X)?S:J(W=>z=>{const M=ot(z)(t.nodeIndex),G=(()=>{if(M.tag==="Nothing")return 0;if(M.tag==="Just")return M._1;g()})();return G<k||G>D?j(C)(z+"\u2192"+X)()(W):W})(S)((()=>{const W=ot(X)(t.preds);if(W.tag==="Nothing")return[];if(W.tag==="Just")return W._1;g()})())}return n(t,"")?S:J(X=>W=>{const z=ot(W)(t.nodeIndex),M=(()=>{if(z.tag==="Nothing")return 0;if(z.tag==="Just")return z._1;g()})();return M<k||M>D?j(C)(W+"\u2192")()(X):X})(S)((()=>{const X=ot("")(t.preds);if(X.tag==="Nothing")return[];if(X.tag==="Just")return X._1;g()})())})(x)(It(0,L)),l=N,_=v,h=D,m=L+1|0;continue}d=x,l=N,_=v,h=k,m=L+1|0}return y};return e.length<3?Q:J(i=>o=>{if(o>=0&&o<e.length){const u=e[o];return r(i)((()=>{const s=o+1|0;return s>=0&&s<e.length?e[s]:[]})())(u)(u.length)(o)(0)(0)}return r(i)((()=>{const u=o+1|0;return u>=0&&u<e.length?e[u]:[]})())([])(0)(o)(0)(0)})(Q)(It(1,e.length-2|0))},H2=t=>e=>n=>r=>i=>{const o=Ae(e),u=J(s=>a=>{const c=J(f=>d=>{const l=(()=>{if(i==="HRight"){const p=ot(d)(t.preds);if(p.tag==="Nothing")return[];if(p.tag==="Just")return p._1;g()}if(i==="HLeft"){const p=ot(d)(t.succs);if(p.tag==="Nothing")return[];if(p.tag==="Just")return p._1}g()})(),_=l.length;if(_===0)return f;const h=En(_-1|0,2),m=En(_,2);return J(p=>y=>{if((()=>{const x=ot(d)(p.align);if(x.tag==="Nothing")return d!==d;if(x.tag==="Just")return x._1!==d;g()})())return p;if(y>=0&&y<l.length){const x=ot(l[y])(t.nodeIndex),N=(()=>{if(x.tag==="Nothing")return 0;if(x.tag==="Just")return x._1;g()})();if(!(uf(l[y]+"\u2192"+d)(n)||uf(d+"\u2192"+l[y])(n))&&(()=>{if(r==="VDown")return p.r<N;if(r==="VUp")return p.r>N;g()})()){const v=ot(l[y])(p.root),k=(()=>{if(v.tag==="Nothing")return l[y];if(v.tag==="Just")return v._1;g()})();return{root:j(C)(d)(k)(p.root),align:j(C)(l[y])(d)(j(C)(d)(k)(p.align)),r:N}}}return p})(f)((()=>{if(r==="VDown")return It(h,m);if(r==="VUp")return ke(It(h,m));g()})())})({root:s.root,align:s.align,r:(()=>{if(r==="VDown")return-1;if(r==="VUp")return 999999;g()})()})((()=>{if(r==="VDown")return a;if(r==="VUp")return ke(a);g()})());return{root:c.root,align:c.align}})({root:Jn(H(s=>b(s,s))(o)),align:Jn(H(s=>b(s,s))(o))})((()=>{if(i==="HRight")return e;if(i==="HLeft")return ke(e);g()})());return{root:u.root,align:u.align}},Ao=t=>e=>n=>r=>i=>o=>u=>s=>a=>c=>{const f=H2(e)(n)(s)(a)(c),d=R2(f)(i)(r)(o)(u)(c);return yd()(l=>_=>w("Just",(()=>{const h=ot(l)(d);if(h.tag==="Nothing")return _+0;if(h.tag==="Just")return _+h._1;g()})()))(z2(t)(e)(n)(r)(i)(o)(u)(d)(f)(a)(c))},af=t=>e=>Qt(n=>r=>J(i=>o=>o>=0&&o<e.length?o>=0&&o<t.length?i+e[o]+t[o]:i+e[o]+0:o>=0&&o<t.length?i+1+t[o]:i+1)(0)((()=>{const i=It(0,e.length-1|0);return n<1?[]:bt(0,n,i)})()))(e),O2=t=>e=>n=>r=>i=>o=>u=>{const s=P2(0)(e.length-1|0),a=rt(t.layerGap),c=u(ed(s,a)),f=$m($g(i)(c)(r)(o)(Q))(c);return H(d=>{const l=I2(d)(f);return l.tag==="Just"&&l._1>0?Nn(a)(2+rt(l._1-1|0)*2.5):a})(It(0,s-1|0))},cf=t=>e=>n=>r=>Ra(i=>J(o=>u=>{if(!o.ok)return o;const s=ot(u)(r),a=(()=>{if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})(),c=ot(u)(n),f=(()=>{if(c.tag==="Nothing")return a+1;if(c.tag==="Just")return a+c._1._1;g()})();return a+1e-4>o.pos&&f+1e-4>o.pos?{ok:!0,pos:f}:{ok:!1,pos:o.pos}})({ok:!0,pos:-1e18})(i).ok,e),q2=t=>e=>n=>r=>{const i=Lt(o=>u=>st.compare(o.w)(u.w))(H(o=>({l:o,w:sf(o)}))(ct(cf()(e)(n),r)));return 0<i.length?w("Just",i[0].l):T},$2=t=>e=>{const n=Jn(Ae(H(Qt(i=>o=>b(o,i)))(t))),r=i=>Lt(o=>u=>it.compare((()=>{const s=ot(o)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})())((()=>{const s=ot(u)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(i);return{preds:(()=>{const i=o=>{if(o.tag==="Leaf")return Q;if(o.tag==="Node")return Wt("Node",o._1,o._2,o._3,r(o._4),i(o._5),i(o._6));g()};return i(J(o=>u=>vt(C)(te)(u.to.node)([u.from.node])(o))(Q)(e))})(),succs:(()=>{const i=o=>{if(o.tag==="Leaf")return Q;if(o.tag==="Node")return Wt("Node",o._1,o._2,o._3,r(o._4),i(o._5),i(o._6));g()};return i(J(o=>u=>vt(C)(te)(u.from.node)([u.to.node])(o))(Q)(e))})(),nodeIndex:n}},Y2=t=>e=>{const n=Lt(d=>l=>st.compare(d.w)(l.w))(Qt(d=>l=>({i:d,l,w:sf(l)}))(e)),r=0<n.length?w("Just",n[0]):T,i=(()=>{if(r.tag==="Just")return r._1.i;if(r.tag==="Nothing")return 0;g()})(),o=i>=0&&i<e.length?w("Just",e[i]):T,u=(()=>{if(o.tag==="Just")return(d=>l=>{let _=d,h=l,m=!0,p;for(;m;){const y=_,x=h;if(x.tag==="Nil"){m=!1,p=y;continue}if(x.tag==="Cons"){_=en(y)(x._1),h=x._2;continue}g()}return p})(999999)((()=>{const d=(l,_)=>{if(l.tag==="Leaf")return _;if(l.tag==="Node")return d(l._5,Ot("Cons",l._4,d(l._6,_)));g()};return d(o._1,qt)})());if(o.tag==="Nothing")return 0;g()})(),s=d=>J(l=>_=>Nn(l)((()=>{const h=ot(_._1)(t);if(h.tag==="Nothing")return _._2+1;if(h.tag==="Just")return _._2+h._1._1;g()})()))(-999999)(Fs(d)),a=i>=0&&i<e.length?w("Just",e[i]):T,c=(()=>{if(a.tag==="Just")return s(a._1);if(a.tag==="Nothing")return 0;g()})(),f=Je(d=>l=>{const _=h=>{if(h.tag==="Leaf")return Q;if(h.tag==="Node")return Wt("Node",h._1,h._2,h._3,h._4+l,_(h._5),_(h._6));g()};return _(d)},e,Qt(d=>l=>Yn(d)(2)===0?u-(_=>h=>{let m=_,p=h,y=!0,x;for(;y;){const N=m,v=p;if(v.tag==="Nil"){y=!1,x=N;continue}if(v.tag==="Cons"){m=en(N)(v._1),p=v._2;continue}g()}return x})(999999)((()=>{const _=(h,m)=>{if(h.tag==="Leaf")return m;if(h.tag==="Node")return _(h._5,Ot("Cons",h._4,_(h._6,m)));g()};return _(l,qt)})()):c-s(l))(e));return M2(J(d=>l=>{const _=Lt(st.compare)(xt(ot(l))(f));return j(C)(l)(_.length===4?1<_.length&&2<_.length?(_[1]+_[2])/2:0:0<_.length?_[0]:0)(d)})(Q)(Nr(C.compare)(Ae(H(d=>{const l=_=>{if(_.tag==="Leaf")return Q;if(_.tag==="Node")return Wt("Node",_._1,_._2,_._3,void 0,l(_._5),l(_._6));g()};return kt(Re.foldr,l(d))})(f)))))},V2=t=>e=>n=>r=>i=>o=>{const u=$2(e)(i),s=W2(u)(e),a={nodeGap:t.nodeGap*4|0},c=Ge(C.compare,Le,Jn(H(_=>b(_,b(1,1)))(ct(Xg,Ae(e)))),(()=>{const _=h=>{if(h.tag==="Leaf")return Q;if(h.tag==="Node")return Wt("Node",h._1,h._2,h._3,b(h._4._1*rt(4),h._4._2),_(h._5),_(h._6));g()};return _(n)})()),f=[Ao(a)(u)(e)(c)(r)(i)(o)(s)(ef)(rf),Ao(a)(u)(e)(c)(r)(i)(o)(s)(nf)(rf),Ao(a)(u)(e)(c)(r)(i)(o)(s)(ef)(of),Ao(a)(u)(e)(c)(r)(i)(o)(s)(nf)(of)],d=Y2(c)(f);if(cf()(e)(c)(d))return d;const l=q2()(e)(c)(f);if(l.tag==="Just")return l._1;if(l.tag==="Nothing")return f[0];g()},X2=t=>e=>n=>r=>{const i=Aa(T,Sa,o=>o.node===e?w("Just",o.position):T,t);if(i.tag==="Nothing")return t;if(i.tag==="Just"){const o=i._1;return H(u=>u.node===n?{...u,position:b(o._1+r._1,o._2+r._2)}:u)(t)}g()},U2=t=>e=>n=>r=>{const i=ct(u=>Be(gn)(u.node)(e),t),o=(()=>{if(n==="Vertical"){if(r==="Start")return J(u=>s=>en(u)(s.position._1))(99999)(i);if(r==="End")return J(u=>s=>Nn(u)(s.position._1))(0)(i);if(r==="Center"){const u=J(s=>a=>s+a.position._1)(0)(i);return i.length===0?0:u/rt(i.length)}g()}if(n==="Horizontal"){if(r==="Start")return J(u=>s=>en(u)(s.position._2))(99999)(i);if(r==="End")return J(u=>s=>Nn(u)(s.position._2))(0)(i);if(r==="Center"){const u=J(s=>a=>s+a.position._2)(0)(i);return i.length===0?0:u/rt(i.length)}}g()})();return H(u=>{if(Be(gn)(u.node)(e)){if(n==="Vertical")return{...u,position:b(o,u.position._2)};if(n==="Horizontal")return{...u,position:b(u.position._1,o)};g()}return u})(t)},j2=t=>e=>J(n=>r=>r.tag==="AlignGroup"?U2(n)(r._1.nodes)(r._1.axis)(r._1.alignment):r.tag==="RelativePosition"?X2(n)(r._1.anchor)(r._1.target)(r._1.offset):n)(e)(t),Z2=t=>e=>n=>r=>i=>o=>u=>s=>{const a=H(d=>J(l=>_=>Nn(l)((()=>{const h=ot(_)(r);if(h.tag==="Nothing")return 1;if(h.tag==="Just")return h._1._2;g()})()))(1)(d))(n),c=V2(t)(n)(r)(i)(o)(s),f=af(O2(t)(n)(r)(i)(o)(u)(d=>{const l=af(d)(a);return Ae(Qt(_=>h=>Qt(m=>p=>({node:p,position:b((()=>{const y=ot(p)(c);return(()=>{if(y.tag==="Nothing")return 0;if(y.tag==="Just")return y._1;g()})()/rt(4)})(),_>=0&&_<l.length?l[_]:0),size:(()=>{const y=me(3)(p)==="$d:"?b(0,1):b(1,1),x=ot(p)(r);if(x.tag==="Nothing")return y;if(x.tag==="Just")return x._1;g()})(),layer:_,order:m}))(h))(n))}))(a);return j2(e)(Ae(Qt(d=>l=>Qt(_=>h=>({node:h,position:b((()=>{const m=ot(h)(c);return(()=>{if(m.tag==="Nothing")return 0;if(m.tag==="Just")return m._1;g()})()/rt(4)})(),d>=0&&d<f.length?f[d]:0),size:(()=>{const m=me(3)(h)==="$d:"?b(0,1):b(1,1),p=ot(h)(r);if(p.tag==="Nothing")return m;if(p.tag==="Just")return p._1;g()})(),layer:d,order:_}))(l))(n)))},As=Wu(uo)(gr(32)),gf=Wu(uo)(gr(31)),Si=(()=>{const t=hl("25214903917");if(t.tag==="Nothing")return ic;if(t.tag==="Just")return t._1;g()})(),Di=Ru(Wu(uo)(gr(48)))(uo),K2=t=>{const e=pl(t);return gi(oc((()=>{if(e.tag==="Nothing")return ic;if(e.tag==="Just")return e._1;g()})())(Si))(Di)},Ms=gr(11),Mo=t=>e=>{const n=gi(io(oo(e)(Si))(Ms))(Di);return b((()=>{const r=$a(fl(Hu(n)(gr(48-t|0))));if(r.tag==="Nothing")return 0;if(r.tag==="Just")return r._1;g()})(),n)},ty=t=>{const e=Mo(26)(t),n=Mo(27)(e._2);return b((rt(e._1)*wu(2)(27)+rt(n._1))/wu(2)(53),n._2)},ey=t=>e=>{const n=J(r=>i=>{const o=ty(r.finalR);return{rs:[...r.rs,o._1],finalR:o._2}})({rs:[],finalR:t})(e);return b(H(r=>r.x)(Lt(r=>i=>st.compare(r.k)(i.k))(Je(r=>i=>({x:r,k:i}),e,n.rs))),n.finalR)},ny=t=>{const e=gi(io(oo(t)(Si))(Ms))(Di),n=gi(io(oo(e)(Si))(Ms))(Di);return b(io(oo((()=>{const r=Hu(e)(gr(16));return uc.compare(r)(gf)!=="LT"?Ru(r)(As):r})())(As))((()=>{const r=Hu(n)(gr(16));return uc.compare(r)(gf)!=="LT"?Ru(r)(As):r})()),n)},Pi=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Bo=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Bs=Kt(C)(Bt),zr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},zo=Kt(C)(Bt),ry=Tu(ti),iy=J(Tr)(0),oy=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},ff=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},uy=t=>e=>n=>{if(t>=0&&t<n.length){const r=n[t];if(e>=0&&e<n.length){const i=On(Yt,T,t,n[e],n);if(i.tag==="Just")return On(Yt,T,e,r,i._1);if(i.tag==="Nothing")return T;g()}}return T},sy=t=>e=>n=>r=>i=>Bs(J(o=>u=>{const s=Lt(a=>c=>it.compare((()=>{const f=Pi(a.id)(i);if(f.tag==="Nothing")return 1e6;if(f.tag==="Just")return f._1;g()})())((()=>{const f=Pi(c.id)(i);if(f.tag==="Nothing")return 1e6;if(f.tag==="Just")return f._1;g()})()))(ct(a=>Bo(a.to.node)(n),ct(a=>a.from.node===u,r)));return{ranks:[...o.ranks,...Qt(a=>c=>b(c.id,rt((o.rankSum+a|0)+1|0)))(s)],rankSum:o.rankSum+s.length|0}})({ranks:[],rankSum:0})(t).ranks),ay=t=>e=>n=>r=>i=>Bs(J(o=>u=>{const s=Lt(c=>f=>{const d=it.compare((()=>{const l=zr(f.from.node)(n);if(l.tag==="Nothing")return-1;if(l.tag==="Just")return l._1;g()})())((()=>{const l=zr(c.from.node)(n);if(l.tag==="Nothing")return-1;if(l.tag==="Just")return l._1;g()})());return d==="EQ"?it.compare((()=>{const l=Pi(c.id)(i);if(l.tag==="Nothing")return 1e6;if(l.tag==="Just")return l._1;g()})())((()=>{const l=Pi(f.id)(i);if(l.tag==="Nothing")return 1e6;if(l.tag==="Just")return l._1;g()})()):d})(ct(c=>Bo(c.from.node)(n),ct(c=>c.to.node===u,r))),a=s.length;return{ranks:[...o.ranks,...Qt(c=>f=>b(f.id,rt((o.rankSum+a|0)-c|0)))(s)],rankSum:o.rankSum+a|0}})({ranks:[],rankSum:0})(t).ranks),zs=t=>e=>n=>{const r=zo(Qt(s=>a=>b(a,s))(t)),i=zo(Qt(s=>a=>b(a,s))(e)),o=xt(s=>{const a=zr(s.from.node)(r),c=zr(s.to.node)(i);if(a.tag==="Just"&&c.tag==="Just")return w("Just",b(a._1,c._1));const f=zr(s.from.node)(i),d=zr(s.to.node)(r);return f.tag==="Just"&&d.tag==="Just"?w("Just",b(d._1,f._1)):T})(n),u=o.length;return J(s=>a=>J(c=>f=>a>=0&&a<o.length&&f>=0&&f<o.length&&((o[a]._1-o[f]._1|0)*(o[a]._2-o[f]._2|0)|0)<0?c+1|0:c)(s)(It(a+1|0,u-1|0)))(0)(It(0,u-2|0))},cy=t=>e=>n=>r=>{const i=o=>u=>{let s=o,a=u,c=!0,f;for(;c;){const d=s,l=a;if(l>=(d.length-1|0)){c=!1,f=d;continue}if(l>=0&&l<d.length){const _=l+1|0;if(_>=0&&_<d.length){const h=d[l],m=d[_];if(Me(N=>N.before===h&&N.after===m,r)){s=d,a=l+1|0;continue}const p=On(Yt,T,l,m,d),y=(()=>{if(p.tag==="Just")return On(Yt,T,l+1|0,h,p._1);if(p.tag==="Nothing")return T;g()})(),x=(()=>{if(y.tag==="Nothing")return d;if(y.tag==="Just")return y._1;g()})();if(zs(e)(x)(n)<zs(e)(d)(n)){s=x,a=l+1|0;continue}s=d,a=l+1|0;continue}c=!1,f=d;continue}c=!1,f=d}return f};return(o=>{let u=o,s=!0,a;for(;s;){const c=u,f=i(c)(0);if(ry(f)(c)){s=!1,a=c;continue}u=f}return a})(t)},Ro=t=>e=>J(n=>r=>{if(r>=0&&r<t.length){const i=t[r],o=r+1|0;if(o>=0&&o<t.length)return n+zs(i)(t[o])(e)|0}return n})(0)(It(0,t.length-2|0)),gy=(()=>{const t=e=>{if(e.length<7){const o=u=>s=>{let a=u,c=s,f=!0,d;for(;f;){const l=a,_=c,h=_-1|0;if(h>=0&&h<l.length){if(_>=0&&_<l.length&&_>0&&l[h].key>l[_].key){const m=uy(_-1|0)(_)(l);if(m.tag==="Just"){a=m._1,c=_-1|0;continue}if(m.tag==="Nothing"){f=!1,d=l;continue}g()}f=!1,d=l;continue}f=!1,d=l}return d};return J(u=>s=>o(u)(s))(e)(It(1,e.length-1|0))}const n=En(e.length,2),r=t(bt(0,n,e)),i=t(bt(n,e.length,e));return(o=>u=>s=>{let a=o,c=u,f=s,d=!0,l;for(;d;){const _=a,h=c,m=f;if(h>=0&&h<r.length){if(m>=0&&m<i.length){if(r[h].key>i[m].key){a=zt(_)(i[m]),c=h,f=m+1|0;continue}a=zt(_)(r[h]),c=h+1|0,f=m;continue}d=!1,l=[..._,...h<1?r:bt(h,r.length,r)];continue}d=!1,l=[..._,...m<1?i:bt(m,i.length,i)]}return l})([])(0)(0)};return t})(),fy=t=>e=>n=>{const r=xt(c=>c.tag==="OrderConstraint"?w("Just",{before:c._1.before,after:c._1.after}):T)(t.constraints),i=c=>J(f=>d=>{const l=d.after,_=d.before,h=ir(Yt,T,p=>p===_,f),m=ir(Yt,T,p=>p===l,f);if(h.tag==="Just"&&m.tag==="Just"&&h._1>m._1){const p=za(Yt,T,h._1,f),y=(()=>{if(p.tag==="Nothing")return f;if(p.tag==="Just")return p._1;g()})(),x=Ba(Yt,T,m._1,_,y);if(x.tag==="Nothing")return y;if(x.tag==="Just")return x._1;g()}return f})(c)(r),o=Bs(Qt(c=>f=>b(f.id,c))(n)),u=(c,f,d)=>{const l=c.length;return J(_=>h=>{const m=f?h-1|0:h+1|0,p=m>=0&&m<_._1.length?w("Just",_._1[m]):T;if(p.tag==="Just"){const y=h>=0&&h<_._1.length?w("Just",_._1[h]):T;if(y.tag==="Just"){const x=zo(Qt(E=>B=>b(B,E))(p._1)),N=zo(Qt(E=>B=>b(B,E))(y._1)),v=f?sy(p._1)(x)(N)(n)(o):ay(p._1)(x)(N)(n)(o),k=J(E=>B=>{const V=xt(D=>Pi(D.id)(v))(ct(f?D=>D.to.node===B._2&&Bo(D.from.node)(x):D=>D.from.node===B._2&&Bo(D.to.node)(x),n));if(V.length===0)return{...E,items:[...E.items,{n:B._2,key:T,origIdx:B._1}]};const et=Mo(24)(E.r);return{items:[...E.items,{n:B._2,key:w("Just",(iy(V)+(rt(et._1)*4172325152040912e-24-.03500000014901161))/rt(V.length)),origIdx:B._1}],r:et._2}})({items:[],r:_._2})(Qt(Hn)(y._1)),L=On(Yt,T,h,cy(i(H(E=>E.n)(gy((()=>{const E=k.items,B=V=>et=>{let D=V,S=et,Z=!0,X;for(;Z;){const W=D,z=S;if(W>=0&&W<E.length){if(E[W].key.tag==="Just"){Z=!1,X=E[W].key._1;continue}if(E[W].key.tag==="Nothing"){D=W+1|0,S=z;continue}g()}Z=!1,X=z}return X};return(V=>et=>D=>{let S=V,Z=et,X=D,W=!0,z;for(;W;){const M=S,G=Z,P=X;if(M>=0&&M<E.length){if(E[M].key.tag==="Just"){S=M+1|0,Z=E[M].key._1,X=[...P,{n:E[M].n,key:E[M].key._1,origIdx:E[M].origIdx}];continue}if(E[M].key.tag==="Nothing"){const I=(G+B(M+1|0)(G+1))/2;S=M+1|0,Z=I,X=[...P,{n:E[M].n,key:I,origIdx:E[M].origIdx}];continue}g()}W=!1,z=P}return z})(0)(-1)([])})()))))(p._1)(n)(r),_._1);if(L.tag==="Just")return b(L._1,k.r);if(L.tag==="Nothing")return b(_._1,_._2);g()}if(y.tag==="Nothing")return b(_._1,_._2);g()}if(p.tag==="Nothing")return b(_._1,_._2);g()})(b(c,d))(f?It(1,l-1|0):ke(It(0,l-2|0)))},s=J(c=>f=>j(C)(f.from.node)()(j(C)(f.to.node)()(c)))(Q)(n),a=J(c=>f=>{if(c.result.crossings===0)return c;const d=x=>N=>v=>k=>{let L=x,E=N,B=v,V=k,et=!0,D;for(;et;){const S=L,Z=E,X=B,W=V;if(X===0){et=!1,D={layout:S,crossings:0,random:W};continue}const z=u(S,Z,W),M=Ro(z._1)(n);if(M<X){L=z._1,E=!Z,B=M,V=z._2;continue}et=!1,D={layout:S,crossings:X,random:z._2}}return D},l=Mo(1)(c.result.random),_=l._1!==0,h=t.modelOrder.tag==="Leaf",m=(c.firstTry||c.secondTry)&&!h?c.firstTry:_,p=(()=>{if(!h){const k=u(e,m,l._2);return d(k._1)(!m)(Ro(k._1)(n))(k._2)}const x=m?0:oy(0)(e.length-1|0),N=x>=0&&x<e.length?w("Just",e[x]):T;if(N.tag==="Just"&&N._1.length>1){const k=ct(L=>ff(L)(s),N._1);if(k.length>1){const L=ey(l._2)(k),E=L._1,B=On(Yt,T,x,i(J(V=>et=>ff(et)(s)?V.idx>=0&&V.idx<E.length?{idx:V.idx+1|0,result:[...V.result,E[V.idx]]}:{idx:V.idx,result:[...V.result,et]}:{idx:V.idx,result:[...V.result,et]})({idx:0,result:[]})(N._1).result),e);if(B.tag==="Just"){const V=u(B._1,m,L._2);return d(V._1)(!m)(Ro(V._1)(n))(V._2)}}}const v=u(e,m,l._2);return d(v._1)(!m)(Ro(v._1)(n))(v._2)})(),y=c.secondTry?!1:c.secondTry;return c.firstTry?{result:p.crossings<c.result.crossings?{layout:p.layout,crossings:p.crossings,random:p.random}:{...c.result,random:p.random},firstTry:!1,secondTry:!0}:{result:p.crossings<c.result.crossings?{layout:p.layout,crossings:p.crossings,random:p.random}:{...c.result,random:p.random},firstTry:c.firstTry,secondTry:y}})({result:{layout:e,crossings:1e9,random:gi(oc(ny(K2(1))._1)(Si))(Di)},firstTry:t.modelOrder.tag!=="Leaf",secondTry:!1})(It(1,t.iterations)).result;return e.length<=0||t.iterations<=0?e:a.layout},_y=t=>t,_f=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Ie=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Rr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},Ii=(()=>{const t={eq:e=>n=>e._1===n._1&&e._2===n._2};return{compare:e=>n=>{const r=C.compare(e._1)(n._1);return r==="LT"?ye:r==="GT"?xe:C.compare(e._2)(n._2)},Eq0:()=>t}})(),dy=Kt(C)(Bt),ly=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=Ii.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},hy=_y("Greedy"),Rs=t=>e=>n=>J(r=>i=>{if(i.from.node===i.to.node)return r;if(i.from.node===e&&!_f(i.to.node)(r.marks)){const o=Ie(i.to.node)(r.inDeg),u=(()=>{if(o.tag==="Nothing")return-1;if(o.tag==="Just")return o._1-1|0;g()})(),s=j(C)(i.to.node)(u)(r.inDeg);return(()=>{const a=Ie(i.to.node)(r.outDeg);return u<=0&&(()=>{if(a.tag==="Nothing")return!1;if(a.tag==="Just")return a._1>0;g()})()&&!Be(gn)(i.to.node)(r.sources)})()?{...r,inDeg:s,sources:[...r.sources,i.to.node]}:{...r,inDeg:s}}if(i.to.node===e&&!_f(i.from.node)(r.marks)){const o=Ie(i.from.node)(r.outDeg),u=(()=>{if(o.tag==="Nothing")return-1;if(o.tag==="Just")return o._1-1|0;g()})(),s=j(C)(i.from.node)(u)(r.outDeg);return(()=>{const a=Ie(i.from.node)(r.inDeg);return u<=0&&(()=>{if(a.tag==="Nothing")return!1;if(a.tag==="Just")return a._1>0;g()})()&&!Be(gn)(i.from.node)(r.sinks)})()?{...r,outDeg:s,sinks:[...r.sinks,i.from.node]}:{...r,outDeg:s}}return r})({...n,remaining:ct(r=>r!==e,n.remaining)})(t),py=J(t=>e=>{if(e.tag==="LayerConstraint"){if(e._1.pin.tag==="SpecificLayer")return j(C)(e._1.node)(e._1.pin._1)(t);if(e._1.pin.tag==="FirstLayer")return j(C)(e._1.node)(0)(t);if(e._1.pin.tag==="LastLayer")return j(C)(e._1.node)(99999)(t)}return t})(Q),df=t=>e=>n=>{const r=Ie(e)(t),i=Ie(n)(t);return r.tag==="Just"&&i.tag==="Just"&&r._1>i._1},lf=t=>e=>n=>r=>{if(Rr(n)(r.visited)||Rr(n)(r.visiting))return r;const i=J(my(t)(e)(n))({...r,visiting:j(C)(n)()(r.visiting)})((()=>{const o=Ie(n)(e);if(o.tag==="Nothing")return[];if(o.tag==="Just")return o._1;g()})());return{...i,visiting:ni(C)(n)(i.visiting),visited:j(C)(n)()(i.visited)}},my=t=>e=>n=>r=>i=>df(t)(n)(i)?{...r,backEdges:j(Ii)(b(n,i))()(r.backEdges)}:Rr(i)(r.visiting)?{...r,backEdges:j(Ii)(b(n,i))()(r.backEdges)}:Rr(i)(r.visited)?r:lf(t)(e)(i)(r),yy=t=>e=>n=>{const r=l=>{let _=l,h=!0,m;for(;h;){const p=_,y=Ft(x=>T,x=>N=>w("Just",{head:x,tail:N}),p.sinks);if(y.tag==="Just"){_=Rs(n)(y._1.head)({...p,sinks:y._1.tail,marks:j(C)(y._1.head)(p.nextRight)(p.marks),nextRight:p.nextRight-1|0});continue}if(y.tag==="Nothing"){const x=Ft(N=>T,N=>v=>w("Just",{head:N,tail:v}),p.sources);if(x.tag==="Just"){_=Rs(n)(x._1.head)({...p,sources:x._1.tail,marks:j(C)(x._1.head)(p.nextLeft)(p.marks),nextLeft:p.nextLeft+1|0});continue}if(x.tag==="Nothing"){const N=k=>{const L=Ie(k)(p.outDeg),E=Ie(k)(p.inDeg);return(()=>{if(L.tag==="Nothing")return 0;if(L.tag==="Just")return L._1;g()})()-(()=>{if(E.tag==="Nothing")return 0;if(E.tag==="Just")return E._1;g()})()|0},v=Lt(k=>L=>{const E=it.compare(N(L))(N(k));return E==="EQ"?it.compare((()=>{const B=Ie(k)(e);if(B.tag==="Nothing")return 1e6;if(B.tag==="Just")return B._1;g()})())((()=>{const B=Ie(L)(e);if(B.tag==="Nothing")return 1e6;if(B.tag==="Just")return B._1;g()})()):E})(p.remaining);if(0<v.length){const k=v[0];_=Rs(n)(k)({...p,remaining:ct(L=>L!==k,p.remaining),marks:j(C)(k)(p.nextLeft)(p.marks),nextLeft:p.nextLeft+1|0});continue}h=!1,m=p;continue}}g()}return m},i=Nr(C.compare)([...H(l=>l.from.node)(n),...H(l=>l.to.node)(n)]),o=ct(l=>l.from.node!==l.to.node,n),u=J(l=>_=>vt(C)(oe)(_.to.node)(1)(l))(Q)(o),s=J(l=>_=>vt(C)(oe)(_.from.node)(1)(l))(Q)(o),a=ct(l=>{const _=Ie(l)(u);if(_.tag==="Nothing")return!0;if(_.tag==="Just")return _._1===0;g()},i),c=ct(l=>{const _=Ie(l)(s);if(_.tag==="Nothing")return!0;if(_.tag==="Just")return _._1===0;g()},i),f=i.length+1|0,d=J(l=>_=>{const h=Ie(_)(l);return h.tag==="Just"&&h._1<0?j(C)(_)(h._1+f|0)(l):l})(r({remaining:ct(l=>!Be(gn)(l)(a)&&!Be(gn)(l)(c),i),marks:Q,inDeg:u,outDeg:s,sources:a,sinks:c,nextLeft:1,nextRight:-1}).marks)(i);return J(l=>_=>{if(_.from.node===_.to.node)return l;if(df(t)(_.from.node)(_.to.node))return j(Ii)(b(_.from.node,_.to.node))()(l);const h=Ie(_.from.node)(d),m=Ie(_.to.node)(d);return h.tag==="Just"&&m.tag==="Just"&&h._1>m._1?j(Ii)(b(_.from.node,_.to.node))()(l):l})(Q)(n)},xy=J(t=>e=>vt(C)(te)(e.from.node)([e.to.node])(t))(Q),Ny=t=>e=>{const n=xy(e),r=Nr(C.compare)([...H(o=>o.from.node)(e),...H(o=>o.to.node)(e)]),i=J(o=>u=>j(C)(u.to.node)()(o))(Q)(e);return J(o=>u=>lf(t)(n)(u)(o))({visiting:Q,visited:Q,backEdges:Q})([...ct(o=>!Rr(o)(i),r),...ct(o=>Rr(o)(i),r)]).backEdges},Jy=t=>e=>n=>r=>{const i=dy(Qt(s=>a=>b(a,s))(e)),o=py(n),u=(()=>{if(t==="DepthFirst")return Ny(o)(r);if(t==="Greedy")return yy(o)(i)(r);g()})();return{edges:H(s=>ly(b(s.from.node,s.to.node))(u)?{...s,from:s.to,to:s.from}:s)(r),reversedEdges:u}},hf=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Ty=J(t=>e=>j(C)(e)()(t))(Q),Wo=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},vy=Cg(C),Tn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},pf=t=>e=>{const n=it.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Ws=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=it.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},wy=Kt(it)(Bt),by=t=>e=>Ge(C.compare,Le,t,e),mf=Qt(t=>e=>({src:e.src,tgt:e.tgt,delta:1,weight:1,eid:t})),Ly=t=>J(e=>n=>({base:(()=>{const r=i=>o=>{let u=i,s=o,a=!0,c;for(;a;){const f=u,d=s;if(d.tag==="Nil"){a=!1,c=f;continue}if(d.tag==="Cons"){u=hf(f)(d._1),s=d._2;continue}g()}return c};return(e.base+r(0)((()=>{const i=(o,u)=>{if(o.tag==="Leaf")return u;if(o.tag==="Node")return i(o._5,Ot("Cons",o._4,i(o._6,u)));g()};return i(n,qt)})())|0)+1|0})(),result:[...e.result,(()=>{if(e.base===0)return n;const r=i=>{if(i.tag==="Leaf")return Q;if(i.tag==="Node")return Wt("Node",i._1,i._2,i._3,i._4+e.base|0,r(i._5),r(i._6));g()};return r(n)})()]}))({base:0,result:[]})(t).result,ky=t=>e=>{const n=Ty(t);return vy(t)(mf(ct(r=>Wo(r.src)(n)&&Wo(r.tgt)(n),e)))},Ey=t=>e=>{const n=J(i=>o=>vt(C)(te)(o.tgt)([o.src])(vt(C)(te)(o.src)([o.tgt])(i)))(Q)(e),r=i=>o=>u=>{let s=i,a=o,c=u,f=!0,d;for(;f;){const l=s,_=a,h=c,m=Ft(p=>T,p=>y=>w("Just",{head:p,tail:y}),l);if(m.tag==="Nothing"){f=!1,d={nodes:h};continue}if(m.tag==="Just"){if(Wo(m._1.head)(_)){s=m._1.tail,a=_,c=h;continue}s=[...m._1.tail,...(()=>{const p=Tn(m._1.head)(n);if(p.tag==="Nothing")return[];if(p.tag==="Just")return p._1;g()})()],a=j(C)(m._1.head)()(_),c=[...h,m._1.head];continue}g()}return d};return J(i=>o=>{if(Wo(o)(i.visited))return i;const u=r([o])(i.visited)([]);return{...i,visited:J(s=>a=>j(C)(a)()(s))(i.visited)(u.nodes),components:[...i.components,u.nodes]}})({visited:Q,components:[]})(t).components},Gy=t=>e=>n=>{const r=J(o=>u=>vt(C)(oe)(u.tgt)(1)(o))(Q)(e),i=J(o=>u=>vt(C)(oe)(u.src)(1)(o))(Q)(e);return J(o=>u=>{const s=Tn(u)(r),a=(()=>{if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})();if((()=>{const x=Tn(u)(i);return(()=>{if(x.tag==="Nothing")return a!==0;if(x.tag==="Just")return a!==x._1;g()})()||a===0})())return o;const c=Tn(u)(o.layers),f=(()=>{if(c.tag==="Nothing")return 0;if(c.tag==="Just")return c._1;g()})(),d=o.layers,l=J(x=>N=>N.tgt===u?{...x,mIn:pf(x.mIn)((()=>{const v=Tn(u)(d),k=Tn(N.src)(d);return(()=>{if(v.tag==="Nothing")return 0;if(v.tag==="Just")return v._1;g()})()-(()=>{if(k.tag==="Nothing")return 0;if(k.tag==="Just")return k._1;g()})()|0})())}:N.src===u?{...x,mOut:pf(x.mOut)((()=>{const v=Tn(N.tgt)(d),k=Tn(u)(d);return(()=>{if(v.tag==="Nothing")return 0;if(v.tag==="Just")return v._1;g()})()-(()=>{if(k.tag==="Nothing")return 0;if(k.tag==="Just")return k._1;g()})()|0})())}:x)({mIn:1e9,mOut:1e9})(e),_=l.mIn===1e9?-1:l.mIn,h=l.mOut===1e9?-1:l.mOut;if(_<0||h<0)return o;const m=(f-_|0)+1|0,p=(f+h|0)-1|0;if(p<m)return o;const y=J(x=>N=>{const v=Ws(N)(o.filling),k=(()=>{if(v.tag==="Nothing")return 0;if(v.tag==="Just")return v._1;g()})();return k<x.bestFill?{best:N,bestFill:k}:x})({best:f,bestFill:(()=>{const x=Ws(f)(o.filling);if(x.tag==="Nothing")return 0;if(x.tag==="Just")return x._1;g()})()})(It(m,p));return y.best===f?o:{layers:j(C)(u)(y.best)(o.layers),filling:j(it)(f)((()=>{const x=Ws(f)(o.filling);if(x.tag==="Nothing")return-1;if(x.tag==="Just")return x._1-1|0;g()})())(j(it)(y.best)(y.bestFill+1|0)(o.filling))}})({layers:n,filling:wy(H(o=>b(o,J(u=>s=>(()=>{const a=Tn(s)(n);return a.tag==="Nothing"?!1:a.tag==="Just"&&a._1===o})()?u+1|0:u)(0)(t)))(It(0,J(o=>u=>hf(o)((()=>{const s=Tn(u)(n);if(s.tag==="Nothing")return 0;if(s.tag==="Just")return s._1;g()})()))(0)(t))))})(t).layers},Cy=t=>e=>Gy(t)(mf(e))(J(by)(Q)(Ly(H(n=>ky(n)(e))(Ey(t)(e))))),Sy=t=>t,hr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Ho=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},yf=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),Dy=Sy("NetworkSimplex"),Py=t=>e=>J(n=>r=>{const i=J(Ho)(0)(xt(o=>hr(o)(n))(r));return J(o=>u=>j(C)(u)(i)(o))(n)(r)})(e)(t),Iy=t=>e=>({layers:H(n=>ct(r=>{const i=hr(r)(e);return i.tag==="Nothing"?!1:i.tag==="Just"&&i._1===n},t))(It(0,(n=>r=>{let i=n,o=r,u=!0,s;for(;u;){const a=i,c=o;if(c.tag==="Nil"){u=!1,s=a;continue}if(c.tag==="Cons"){i=Ho(a)(c._1),o=c._2;continue}g()}return s})(0)((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return n(e,qt)})()))),nodeLayer:e}),Qy=t=>e=>n=>{const r=J(i=>o=>j(C)(o)(!0)(i))(Q)(e);return J(i=>o=>j(C)(o._1)(o._2)(i))(Cy(e)(xt(i=>i.from.node===i.to.node||(()=>{const o=hr(i.from.node)(r);if(o.tag==="Nothing")return!0;if(o.tag==="Just")return!o._1;g()})()||(()=>{const o=hr(i.to.node)(r);if(o.tag==="Nothing")return!0;if(o.tag==="Just")return!o._1;g()})()?T:w("Just",{src:i.from.node,tgt:i.to.node}))(t)))(yf(n))},Fy=t=>e=>n=>r=>{const i=s=>a=>{const c=hr(a)(s);if(c.tag==="Just")return s;if(c.tag==="Nothing"){const f=ct(l=>l!==a,(()=>{const l=hr(a)(t);if(l.tag==="Nothing")return[];if(l.tag==="Just")return l._1;g()})()),d=J(i)(s)(f);return j(C)(a)(1+J(Ho)(0)(xt(l=>hr(l)(d))(f))|0)(d)}g()},o=J(i)(Q)(n),u=(s=>a=>{let c=s,f=a,d=!0,l;for(;d;){const _=c,h=f;if(h.tag==="Nil"){d=!1,l=_;continue}if(h.tag==="Cons"){c=Ho(_)(h._1),f=h._2;continue}g()}return l})(1)((()=>{const s=(a,c)=>{if(a.tag==="Leaf")return c;if(a.tag==="Node")return s(a._5,Ot("Cons",a._4,s(a._6,c)));g()};return s(o,qt)})());return J(s=>a=>j(C)(a._1)(a._2)(s))((()=>{const s=a=>{if(a.tag==="Leaf")return Q;if(a.tag==="Node")return Wt("Node",a._1,a._2,a._3,u-a._4|0,s(a._5),s(a._6));g()};return s(o)})())(yf(r))},Ay=J(t=>e=>{if(e.tag==="LayerConstraint"){if(e._1.pin.tag==="SpecificLayer")return j(C)(e._1.node)(e._1.pin._1)(t);if(e._1.pin.tag==="FirstLayer")return j(C)(e._1.node)(0)(t)}return t})(Q),My=J(t=>e=>vt(C)(te)(e.to.node)([e.from.node])(t))(Q),By=J(t=>e=>vt(C)(te)(e.from.node)([e.to.node])(t))(Q),zy=t=>e=>n=>r=>{const i=By(n),o=My(n),u=Ay(e);return Iy(r)(Py(xt(s=>s.tag==="SameLayer"?w("Just",s._1.nodes):T)(e))((()=>{if(t==="LongestPath")return Fy(i)(o)(r)(u);if(t==="NetworkSimplex")return Qy(n)(r)(u);g()})()))},Ry=Kt(C)(Bt),Wy=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},xf=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Nf=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Qi=Kt(C)(Bt),Hy=Kt(C)(Bt),Jf=(()=>{const t=H(e=>({start:e.end,end:e.start,direction:e.direction}));return e=>ke(t(e))})(),Oy=t=>e=>n=>r=>{const i=Ry(H(u=>b(u.edge,u))(r)),o=u=>0<u.nodes.length&&(()=>{const s=Wy(u.edgeId)(n);return s.tag==="Just"&&u.nodes[0]!==s._1._1})();return H(u=>{if(u.nodes.length<=2){const f=xf(u.edgeId)(i);if(f.tag==="Just"){const d=o(u),l=ki(Li(d?Jf(f._1.segments):f._1.segments));return{...f._1,edge:u.edgeId,segments:l,bends:Je(_=>h=>_.end,l,bt(1,l.length,l)),reversed:d}}if(f.tag==="Nothing")return{edge:u.edgeId,segments:[],bends:[],bendType:[],jumps:[],reversed:!1};g()}const s=Tt(xt(f=>xf(f)(i))(Je(f=>d=>u.edgeId+":"+f+"->"+d,u.nodes,bt(1,u.nodes.length,u.nodes))))(f=>f.segments),a=o(u),c=ki(Li(a?Jf(s):s));return{edge:u.edgeId,segments:c,bends:Je(f=>d=>f.end,c,bt(1,c.length,c)),bendType:[],jumps:[],reversed:a}})(t)},qy={layers:[],edges:[],chains:[]},$y={nodeGap:3,layerGap:2,iterations:8,layerer:Dy,cycleBreaker:hy,compactPostRouting:!1},Yy=t=>({pos:b(0,0),size:b(J(e=>n=>Nf(e)(n.position._1+n.size._1))(0)(t),J(e=>n=>Nf(e)(n.position._2+n.size._2))(0)(t))}),Vy=t=>e=>n=>{const r=Qi(H(c=>b(c.id,c.ports))(e.nodes)),i=ct(c=>me(3)(c.node)!=="$d:",n.placements),o=Oy(n.withDummies.chains)(n.acyclic.reversedEdges)(Hy(H(c=>b(c.id,b(c.from.node,c.to.node)))(e.edges)))(x2(n.withDummies.edges)(n.placements)(r)(n.withDummies.chains)(jg(n.ordered)(ct(c=>c.from.node!==c.to.node,n.withDummies.edges))((()=>{const c=f=>{if(f.tag==="Leaf")return Q;if(f.tag==="Node")return Wt("Node",f._1,f._2,f._3,b(f._4._1*4,f._4._2),c(f._5),c(f._6));g()};return c(Qi(H(f=>b(f.id,f.size))(e.nodes)))})()))),u=t.compactPostRouting?Rm()({nodes:i,edges:e.edges,paths:o,ports:r}):{nodes:i,edges:o},s=H(c=>{const f=ki(Li(c.segments));return{...c,segments:f,bends:Je(d=>l=>d.end,f,bt(1,f.length,f))}})(u.edges),a=Qt(c=>f=>({...f,jumps:L2(c)(f)(s)}))(s);return{nodes:u.nodes,edges:a,boundingBox:Yy(u.nodes),metrics:dp(u.nodes)(a)(0)}},Xy=t=>e=>n=>{const r=Qi(H(o=>b(o.id,o.size))(e.nodes)),i={...n,placements:Z2({nodeGap:t.nodeGap,layerGap:t.layerGap})(e.constraints)(n.ordered)(r)(Qi(H(o=>b(o.id,o.ports))(e.nodes)))(n.withDummies.edges)(n.withDummies.chains)(jg(n.ordered)(n.withDummies.edges)((()=>{const o=u=>{if(u.tag==="Leaf")return Q;if(u.tag==="Node")return Wt("Node",u._1,u._2,u._3,b(u._4._1*4,u._4._2),o(u._5),o(u._6));g()};return o(r)})()))};return{pipeline:i,result:Vy(t)(e)(i)}},Uy=t=>e=>n=>Xy(t)(e)({...n,ordered:fy({iterations:t.iterations,constraints:e.constraints,modelOrder:Qi(Qt(r=>i=>b(i.id,r))(e.nodes))})(n.withDummies.layers)(n.withDummies.edges)}),jy=t=>e=>n=>Uy(t)(e)({...n,withDummies:k2(n.layered.nodeLayer)(n.acyclic.edges)(n.layered.layers)}),Zy=t=>e=>{const n=H(i=>i.id)(e.nodes),r=Jy(t.cycleBreaker)(n)(e.constraints)(e.edges);return jy(t)(e)({acyclic:r,layered:zy(t.layerer)(e.constraints)(r.edges)(n),withDummies:qy,ordered:[],placements:[]})},Oo=t=>t,Ky=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Hs=Oo("TopSide"),Os=Oo("BottomSide"),qs=Oo("LeftSide"),$s=Oo("RightSide"),tx=t=>{const e=st.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=st.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},Tf=t=>e=>n=>{const r=Ky(t.h*.12)(t.w*.2),i=t.w/2;return(e<0?t.y+r:t.y+t.h-r)+e*r*Ee(tx((()=>{const o=(n-(t.x+i))/i;return 1-o*o})()))},tr=t=>e=>n=>r=>{let i=t,o=e,u=n,s=r,a=!0,c;for(;a;){const f=i,d=o,l=u,_=s;if(f==="Rectangle"){if(l==="TopSide"){a=!1,c=d.y;continue}if(l==="BottomSide"){a=!1,c=d.y+d.h;continue}if(l==="LeftSide"){a=!1,c=d.x;continue}if(l==="RightSide"){a=!1,c=d.x+d.w;continue}i=Un,o=d,u=l,s=_;continue}if(f==="Cylinder"){if(l==="TopSide"){a=!1,c=Tf(d)(-1)(_);continue}if(l==="BottomSide"){a=!1,c=Tf(d)(1)(_);continue}if(l==="LeftSide"){a=!1,c=d.x;continue}if(l==="RightSide"){a=!1,c=d.x+d.w;continue}}i=Un,o=d,u=l,s=_}return c},vf=t=>e=>{const n=e.y-t.y,r=n<0?-n:n,i=e.x-(t.x+t.w),o=i<0?-i:i,u=e.x-t.x,s=u<0?-u:u,a=e.y-(t.y+t.h),c=a<0?-a:a;return r<=c&&r<=s&&r<=o?Hs:c<=s&&c<=o?Os:s<=o?qs:$s},Ys=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Fi=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},ex=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),qo=Kt(C)(Bt),nx=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},rx=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},ix=J(t=>e=>j(C)(e)()(t))(Q),ox=J(t=>e=>j(C)(e)()(t))(Q),$o=rr.traverse(xu),Yo=Kt(C)(Bt),ux=t=>e=>Ge(C.compare,Le,t,e),sx=J(t=>e=>j(C)(e)()(t))(Q),ax=Kt(C)(Bt),cx=t=>e=>Ge(C.compare,Le,t,e),gx=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},wf=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},fx=t=>e=>({...e,edges:qo(H(n=>b(n._1,(()=>{const r=Ys(n._1)(t);if(r.tag==="Nothing")return n._2;if(r.tag==="Just"){const i=Fi(r._1._2)(e.nodes),o=Fi(r._1._1)(e.nodes),u=(()=>{if(o.tag==="Nothing")return n._2;if(o.tag==="Just"){const s=Ft(a=>T,a=>c=>w("Just",{head:a,tail:c}),n._2);if(s.tag==="Nothing")return n._2;if(s.tag==="Just"){const a={x:o._1.x,y:o._1.y,w:o._1.w,h:o._1.h},c=vf(a)(s._1.head);return[(()=>{if(c==="TopSide")return{...s._1.head,y:tr(o._1.shape)(a)(Hs)(s._1.head.x)};if(c==="BottomSide")return{...s._1.head,y:tr(o._1.shape)(a)(Os)(s._1.head.x)};if(c==="LeftSide")return{...s._1.head,x:tr(o._1.shape)(a)(qs)(s._1.head.y)};if(c==="RightSide")return{...s._1.head,x:tr(o._1.shape)(a)($s)(s._1.head.y)};g()})(),...s._1.tail]}}g()})();if(i.tag==="Nothing")return u;if(i.tag==="Just"){const s=Vi(u);if(s.tag==="Nothing")return u;if(s.tag==="Just")return zt(s._1.init)((()=>{const a={x:i._1.x,y:i._1.y,w:i._1.w,h:i._1.h},c=vf(a)(s._1.last);if(c==="TopSide")return{...s._1.last,y:tr(i._1.shape)(a)(Hs)(s._1.last.x)};if(c==="BottomSide")return{...s._1.last,y:tr(i._1.shape)(a)(Os)(s._1.last.x)};if(c==="LeftSide")return{...s._1.last,x:tr(i._1.shape)(a)(qs)(s._1.last.y)};if(c==="RightSide")return{...s._1.last,x:tr(i._1.shape)(a)($s)(s._1.last.y)};g()})())}}g()})()))(ex(e.edges)))}),_x=t=>e=>n=>{const r=Zt(i=>i.id===n)(t.graph.edges);if(r.tag==="Just")return w("Just",r._1);if(r.tag==="Nothing")return Ys(n)(e);g()},dx=t=>e=>n=>r=>({x:r.position._1*t,y:r.position._2*t,w:r.size._1*t,h:r.size._2*t,label:(()=>{const i=Fi(r.node)(e);if(i.tag==="Just")return i._1;if(i.tag==="Nothing")return r.node;g()})(),shape:(()=>{const i=Fi(r.node)(n);if(i.tag==="Nothing")return Un;if(i.tag==="Just")return i._1;g()})()}),lx=t=>({id:t,size:b(1,1),ports:[],label:w("Just",t),shape:Un}),hx=t=>e=>n=>r=>b(r.node,dx(t)(e)(n)(r)),bf=t=>{const e=_o(`
|
|
6
|
+
`)(t);return e.length===0?[""]:e},Lf=t=>{const e=(n,r)=>{if(n.tag==="Leaf")return r;if(n.tag==="Node")return e(n._5,Ot("Cons",n._4,e(n._6,r)));g()};return kt($t.foldr,e(t.interiors,qt))},px=t=>qo(xt(e=>w("Just",b(e.edge,{id:e.edge,from:{node:e.from,port:T},to:{node:e.to,port:T}})))(Tt(t.scenes)(e=>e.tag==="DataFlow"?xt(n=>n.kind.tag==="SendToken"?w("Just",n.kind._1):T)(e._1.events):[]))),kf=t=>{const e=Pl(t),n=ct(i=>nx(i.id)(e.nodes),t.graph.nodes),r=ct(i=>rx(i.id)(e.edges),t.graph.edges);return{nodes:[...n,...H(lx)(kt(Re.foldr,Gn(C.compare,e.nodes,ix(H(i=>i.id)(n)))))],edges:[...r,...xt(_x(t)(px(t)))(kt(Re.foldr,Gn(C.compare,e.edges,ox(H(i=>i.id)(r)))))],constraints:t.graph.constraints}},mx=t=>{const e=$o(n=>{const r=ng(rg)((()=>{if(n.label.tag==="Just")return n.label._1;if(n.label.tag==="Nothing")return n.id;g()})());return()=>{const i=r();return b(n.id,i)}})(kf(t).nodes);return()=>{const n=e();return Yo(n)}},Ef=t=>{const e=mx(t);return()=>{const n=e(),r=$o(Ef)(Lf(t))();return J(ux)(n)(r)}},yx=t=>e=>{const n=Ft(r=>T,r=>i=>w("Just",{head:r,tail:i}),e.segments);if(n.tag==="Nothing")return[];if(n.tag==="Just")return[{x:n._1.head.start._1*t,y:n._1.head.start._2*t},...H(r=>({x:r.end._1*t,y:r.end._2*t}))([n._1.head,...n._1.tail])];g()},xx=t=>e=>b(e.edge,yx(t)(e)),Nx=t=>e=>n=>r=>({nodes:Yo(H(hx(rt(4)*t)(e)(n))(r.nodes)),edges:qo(H(xx(t))(r.edges)),chipExtras:Q}),Jx=t=>J(e=>n=>{if(n.tag==="Structural")return e;if(n.tag==="DataFlow")return J(r=>i=>{if(i.kind.tag==="SendToken")return J(o=>u=>j(C)(u)()(o))(r)(i.kind._1.labels);if(i.kind.tag==="FillNodeWithoutTransition")return J(o=>u=>j(C)(u)()(o))(r)(i.kind._1.labels);g()})(e)(n._1.events);if(n.tag==="EnterNode"||n.tag==="ExitNode")return e;g()})(Q)(t.scenes),Tx=t=>{const e=$o(n=>{const r=ng(rg)(n);return()=>{const i=r();return b(n,{labelW:i,charCount:Xn(Pr(n)),lineCount:1})}})(kt(Re.foldr,sx(Tt(kt(Re.foldr,Jx(t)))(bf))));return()=>{const n=e();return ax(n)}},Gf=t=>{const e=Tx(t);return()=>{const n=e(),r=$o(Gf)(Lf(t))();return J(cx)(n)(r)}},vx=rt(4)*8,wx=t=>e=>{const n=gp(vx)(t)(cp(ap)(kf(e)));return fx(qo(H(r=>b(r.id,b(r.from.node,r.to.node)))(n.edges)))(Nx(8)(Yo(H(r=>b(r.id,(()=>{if(r.label.tag==="Just")return r.label._1;if(r.label.tag==="Nothing")return r.id;g()})()))(n.nodes)))(Yo(H(r=>b(r.id,r.shape))(n.nodes)))(Zy($y)(n).result))},bx=t=>Tt(t.scenes)(e=>{if(e.tag==="Structural")return[];if(e.tag==="DataFlow")return e._1.events;if(e.tag==="EnterNode")return[];if(e.tag==="ExitNode")return[];g()}),Lx=t=>e=>n=>{const r=i=>{const o=xt(u=>{const s=gx(u)(t);return s.tag==="Just"?w("Just",{w:s._1.labelW+28,h:rt(rp(1)(s._1.lineCount))*13.2+12}):T})(Tt(i)(bf));return o.length===0?T:w("Just",{w:J(wf)(0)(H(u=>u.w)(o)),h:J(wf)(0)(H(u=>u.h)(o))})};return J(i=>o=>{if(o.kind.tag==="SendToken"){const u=Ys(o.kind._1.edge)(n.edges),s=r(o.kind._1.labels);if(s.tag==="Just"&&u.tag==="Just"){const a=s._1;return vt(C)(te)(o.kind._1.edge)(H(c=>({x:c.x+14+a.w,y:c.y-6-8-a.h}))(u._1))(i)}return i}if(o.kind.tag==="FillNodeWithoutTransition"){const u=Fi(o.kind._1.node)(n.nodes),s=r(o.kind._1.labels);return s.tag==="Just"&&u.tag==="Just"?vt(C)(te)("__fill__:"+o.kind._1.node)((()=>{const a=u._1.y-s._1.h-14,c=u._1.x+u._1.w/2,f=c-s._1.w/2,d=c+s._1.w/2,l=u._1.y-14;return[{x:f,y:a},{x:d,y:a},{x:f,y:l},{x:d,y:l}]})())(i):i}g()})(Q)(bx(e))},Cf=t=>e=>n=>({layout:(()=>{const r=wx(t)(n);return{...r,chipExtras:Lx(e)(n)(r)}})(),interiors:(()=>{const r=Cf(t)(e),i=o=>{if(o.tag==="Leaf")return Q;if(o.tag==="Node")return Wt("Node",o._1,o._2,o._3,r(o._4),i(o._5),i(o._6));g()};return i(n.interiors)})()}),Sf=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},Vs=t=>e=>n=>{const r=t<.05?t:.05,i=(u,s)=>{if(s.tag==="Leaf")return u;if(s.tag==="Node")return i((()=>{const a=Sf(s._3)(n),c=(()=>{if(a.tag==="Just")return a._1;if(a.tag==="Nothing")return{x:s._4.x,y:s._4.y,vx:0,vy:0};g()})(),f=c.vx+(180*(s._4.x-c.x)-22*c.vx)*r,d=c.vy+(180*(s._4.y-c.y)-22*c.vy)*r;return j(C)(s._3)({x:c.x+f*r,y:c.y+d*r,vx:f,vy:d})(i(u,s._5))})(),s._6);g()},o=i(Q,e);return{springs:o,applied:(()=>{const u=(s,a)=>{if(a.tag==="Leaf")return s;if(a.tag==="Node")return u((()=>{const c=u(s,a._5),f=Sf(a._3)(o);if(f.tag==="Just")return j(C)(a._3)({...a._4,x:f._1.x,y:f._1.y})(c);if(f.tag==="Nothing")return j(C)(a._3)(a._4)(c);g()})(),a._6);g()};return u(Q,e)})()}};(function(){var t={},e="Pure",n="Throw",r="Catch",i="Sync",o="Async",u="Bind",s="Bracket",a="Fork",c="Sequential",f="Map",d="Apply",l="Alt",_="Cons",h="Resume",m="Release",p="Finalizer",y="Finalized",x="Forked";function N(F,O,Y,q){this.tag=F,this._1=O,this._2=Y,this._3=q}function v(F){var O=function(Y,q,$){return new N(F,Y,q,$)};return O.tag=F,O}function k(F){return new N(e,void 0)}function L(F){try{F()}catch(O){setTimeout(function(){throw O},0)}}function E(F,O,Y){try{return O(Y())}catch(q){return F(q)}}function B(F,O,Y){try{return O(Y)()}catch(q){return Y(F(q))(),k}}var V=(function(){var F=1024,O=0,Y=0,q=new Array(F),$=!1;function R(){var tt;for($=!0;O!==0;)O--,tt=q[Y],q[Y]=void 0,Y=(Y+1)%F,tt();$=!1}return{isDraining:function(){return $},enqueue:function(tt){var K;O===F&&(K=$,R(),$=K),q[(Y+O)%F]=tt,O++,$||R()}}})();function et(F){var O={},Y=0,q=0;return{register:function($){var R=Y++;$.onComplete({rethrow:!0,handler:function(tt){return function(){q--,delete O[R]}}})(),O[R]=$,q++},isEmpty:function(){return q===0},killAll:function($,R){return function(){if(q===0)return R();var tt=0,K={};function gt(at){K[at]=O[at].kill($,function(yt){return function(){delete K[at],tt--,F.isLeft(yt)&&F.fromLeft(yt)&&setTimeout(function(){throw F.fromLeft(yt)},0),tt===0&&R()}})()}for(var _t in O)O.hasOwnProperty(_t)&&(tt++,gt(_t));return O={},Y=0,q=0,function(at){return new N(i,function(){for(var yt in K)K.hasOwnProperty(yt)&&K[yt]()})}}}}}var D=0,S=1,Z=2,X=3,W=4,z=5,M=6;function G(F,O,Y){var q=0,$=D,R=Y,tt=null,K=null,gt=null,_t=null,at=null,yt=0,Et=0,At=null,pt=!0;function Mt(U){for(var ut,ft,lt;;)switch(ut=null,ft=null,lt=null,$){case Z:$=S;try{R=gt(R),_t===null?gt=null:(gt=_t._1,_t=_t._2)}catch(Ht){$=z,tt=F.left(Ht),R=null}break;case X:F.isLeft(R)?($=z,tt=R,R=null):gt===null?$=z:($=Z,R=F.fromRight(R));break;case S:switch(R.tag){case u:gt&&(_t=new N(_,gt,_t)),gt=R._2,$=S,R=R._1;break;case e:gt===null?($=z,R=F.right(R._1)):($=Z,R=R._1);break;case i:$=X,R=E(F.left,F.right,R._1);break;case o:$=W,R=B(F.left,R._1,function(Ht){return function(){q===U&&(q++,V.enqueue(function(){q===U+1&&($=X,R=Ht,Mt(q))}))}});return;case n:$=z,tt=F.left(R._1),R=null;break;case r:gt===null?at=new N(_,R,at,K):at=new N(_,R,new N(_,new N(h,gt,_t),at,K),K),gt=null,_t=null,$=S,R=R._1;break;case s:yt++,gt===null?at=new N(_,R,at,K):at=new N(_,R,new N(_,new N(h,gt,_t),at,K),K),gt=null,_t=null,$=S,R=R._1;break;case a:$=X,ut=G(F,O,R._2),O&&O.register(ut),R._1&&ut.run(),R=F.right(ut);break;case c:$=S,R=I(F,O,R._1);break}break;case z:if(gt=null,_t=null,at===null)$=M,R=K||tt||R;else switch(ut=at._3,lt=at._1,at=at._2,lt.tag){case r:K&&K!==ut&&yt===0?$=z:tt&&($=S,R=lt._2(F.fromLeft(tt)),tt=null);break;case h:K&&K!==ut&&yt===0||tt?$=z:(gt=lt._1,_t=lt._2,$=Z,R=F.fromRight(R));break;case s:yt--,tt===null&&(ft=F.fromRight(R),at=new N(_,new N(m,lt._2,ft),at,ut),(K===ut||yt>0)&&($=S,R=lt._3(ft)));break;case m:at=new N(_,new N(y,R,tt),at,K),$=S,K&&K!==ut&&yt===0?R=lt._1.killed(F.fromLeft(K))(lt._2):tt?R=lt._1.failed(F.fromLeft(tt))(lt._2):R=lt._1.completed(F.fromRight(R))(lt._2),tt=null,yt++;break;case p:yt++,at=new N(_,new N(y,R,tt),at,K),$=S,R=lt._1;break;case y:yt--,$=z,R=lt._1,tt=lt._2;break}break;case M:for(var Nt in At)At.hasOwnProperty(Nt)&&(pt=pt&&At[Nt].rethrow,L(At[Nt].handler(R)));At=null,K&&tt?setTimeout(function(){throw F.fromLeft(tt)},0):F.isLeft(R)&&pt&&setTimeout(function(){if(pt)throw F.fromLeft(R)},0);return;case D:$=S;break;case W:return}}function Jt(U){return function(){if($===M)return pt=pt&&U.rethrow,U.handler(R)(),function(){};var ut=Et++;return At=At||{},At[ut]=U,function(){At!==null&&delete At[ut]}}}function mt(U,ut){return function(){if($===M)return ut(F.right(void 0))(),function(){};var ft=Jt({rethrow:!1,handler:function(){return ut(F.right(void 0))}})();switch($){case D:K=F.left(U),$=M,R=K,Mt(q);break;case W:K===null&&(K=F.left(U)),yt===0&&($===W&&(at=new N(_,new N(p,R(U)),at,K)),$=z,R=null,tt=null,Mt(++q));break;default:K===null&&(K=F.left(U)),yt===0&&($=z,R=null,tt=null)}return ft}}function nt(U){return function(){var ut=Jt({rethrow:!1,handler:U})();return $===D&&Mt(q),ut}}return{kill:mt,join:nt,onComplete:Jt,isSuspended:function(){return $===D},run:function(){$===D&&(V.isDraining()?Mt(q):V.enqueue(function(){Mt(q)}))}}}function P(F,O,Y,q){var $=0,R={},tt=0,K={},gt=new Error("[ParAff] Early exit"),_t=null,at=t;function yt(Jt,mt,nt){var U=mt,ut=null,ft=null,lt=0,Nt={},Ht,Vt;t:for(;;)switch(Ht=null,U.tag){case x:if(U._3===t&&(Ht=R[U._1],Nt[lt++]=Ht.kill(Jt,function(De){return function(){lt--,lt===0&&nt(De)()}})),ut===null)break t;U=ut._2,ft===null?ut=null:(ut=ft._1,ft=ft._2);break;case f:U=U._2;break;case d:case l:ut&&(ft=new N(_,ut,ft)),ut=U,U=U._1;break}if(lt===0)nt(F.right(void 0))();else for(Vt=0,Ht=lt;Vt<Ht;Vt++)Nt[Vt]=Nt[Vt]();return Nt}function Et(Jt,mt,nt){var U,ut,ft,lt,Nt,Ht;for(F.isLeft(Jt)?(U=Jt,ut=null):(ut=Jt,U=null);;){if(ft=null,lt=null,Nt=null,Ht=null,_t!==null)return;if(mt===null){q(U||ut)();return}if(mt._3!==t)return;switch(mt.tag){case f:U===null?(mt._3=F.right(mt._1(F.fromRight(ut))),ut=mt._3):mt._3=U;break;case d:if(ft=mt._1._3,lt=mt._2._3,U){if(mt._3=U,Nt=!0,Ht=tt++,K[Ht]=yt(gt,U===ft?mt._2:mt._1,function(){return function(){delete K[Ht],Nt?Nt=!1:nt===null?Et(U,null,null):Et(U,nt._1,nt._2)}}),Nt){Nt=!1;return}}else{if(ft===t||lt===t)return;ut=F.right(F.fromRight(ft)(F.fromRight(lt))),mt._3=ut}break;case l:if(ft=mt._1._3,lt=mt._2._3,ft===t&&F.isLeft(lt)||lt===t&&F.isLeft(ft))return;if(ft!==t&&F.isLeft(ft)&<!==t&&F.isLeft(lt))U=ut===ft?lt:ft,ut=null,mt._3=U;else if(mt._3=ut,Nt=!0,Ht=tt++,K[Ht]=yt(gt,ut===ft?mt._2:mt._1,function(){return function(){delete K[Ht],Nt?Nt=!1:nt===null?Et(ut,null,null):Et(ut,nt._1,nt._2)}}),Nt){Nt=!1;return}break}nt===null?mt=null:(mt=nt._1,nt=nt._2)}}function At(Jt){return function(mt){return function(){delete R[Jt._1],Jt._3=mt,Et(mt,Jt._2._1,Jt._2._2)}}}function pt(){var Jt=S,mt=Y,nt=null,U=null,ut,ft;t:for(;;)switch(ut=null,ft=null,Jt){case S:switch(mt.tag){case f:nt&&(U=new N(_,nt,U)),nt=new N(f,mt._1,t,t),mt=mt._2;break;case d:nt&&(U=new N(_,nt,U)),nt=new N(d,t,mt._2,t),mt=mt._1;break;case l:nt&&(U=new N(_,nt,U)),nt=new N(l,t,mt._2,t),mt=mt._1;break;default:ft=$++,Jt=z,ut=mt,mt=new N(x,ft,new N(_,nt,U),t),ut=G(F,O,ut),ut.onComplete({rethrow:!1,handler:At(mt)})(),R[ft]=ut,O&&O.register(ut)}break;case z:if(nt===null)break t;nt._1===t?(nt._1=mt,Jt=S,mt=nt._2,nt._2=t):(nt._2=mt,mt=nt,U===null?nt=null:(nt=U._1,U=U._2))}for(at=mt,ft=0;ft<$;ft++)R[ft].run()}function Mt(Jt,mt){_t=F.left(Jt);var nt;for(var U in K)if(K.hasOwnProperty(U)){nt=K[U];for(U in nt)nt.hasOwnProperty(U)&&nt[U]()}K=null;var ut=yt(Jt,at,mt);return function(ft){return new N(o,function(lt){return function(){for(var Nt in ut)ut.hasOwnProperty(Nt)&&ut[Nt]();return k}})}}return pt(),function(Jt){return new N(o,function(mt){return function(){return Mt(Jt,mt)}})}}function I(F,O,Y){return new N(o,function(q){return function(){return P(F,O,Y,q)}})}return N.EMPTY=t,N.Pure=v(e),N.Throw=v(n),N.Catch=v(r),N.Sync=v(i),N.Async=v(o),N.Bind=v(u),N.Bracket=v(s),N.Fork=v(a),N.Seq=v(c),N.ParMap=v(f),N.ParApply=v(d),N.ParAlt=v(l),N.Fiber=G,N.Supervisor=et,N.Scheduler=V,N.nonCanceler=k,N})();let Df=null;function kx(){return Df||(typeof document>"u"?null:Df=document.createElement("canvas").getContext("2d"))}const Xs=new Map;function Pf(t,e,n,r,i,o){const u=`${n} ${e}px ${t}`,s=u+"|"+r;if(Xs.has(s))return Xs.get(s);const a=kx();if(!a)return o;a.font=u;const c=i(a.measureText(r)),f=typeof document<"u"?document.fonts:null;if(!f||f.check(u))Xs.set(s,c);else if(f&&f.load)try{f.load(u)}catch{}return c}const Ex=(t,e,n,r)=>Pf(t,e,n,r,i=>i.width,-1),Gx=(t,e,n,r)=>Pf(t,e,n,r,i=>({ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent}),{ascent:-1,descent:-1}),If=t=>e=>{const n=Ex(t.family,t.size,t.weight,Pr(e));return n<0?rt(po(e).length)*t.size*.62:n},Qf=t=>e=>{const n=Gx(t.family,t.size,t.weight,Pr(e));return n.ascent<0?{ascent:t.size*.72,descent:t.size*.2}:n},Ff=t=>t,Af=t=>t,Vo=t=>t,Mf=t=>t,Cx=t=>t,Bf=t=>t,zf=t=>t,Sx=zf("BaselineTop"),Wr=zf("BaselineMiddle"),Us=Bf("AlignLeft"),Xo=Bf("AlignCenter"),Te=Cx("RoundJoin"),fn=Mf("ButtCap"),In=Mf("RoundCap"),Dx=Vo("LayerPolyOut"),Px=Vo("LayerPolyIn"),Ix=Vo("LayerNodeMask"),Qx=Vo("LayerOverlay"),js=Af("NonZero"),Fx=Af("EvenOdd"),Rf=Ff("Normal"),Uo=Ff("Difference"),re={r:255,g:255,b:255,a:255},Qn={r:26,g:26,b:26,a:255},Ax=t=>t,Wf=t=>t,Mx=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},nn=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Hf=t=>e=>n=>{const r=it.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=it.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},Zs=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Bx=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},zx=Wf("FlatLevel"),Rx=Wf("NestedLevel"),Of=Ax("GenieSilhouette"),Wx=t=>e=>n=>r=>{if(e)return{prng:t,yLift:0};const i=Cr(t);return{prng:i.prng,yLift:i.value*n.yJitter*r}},Hx=t=>e=>n=>r=>{if(e)return{prng:t,dx:0};const i=Cr(t);return{prng:i.prng,dx:(i.value*2-1)*n.xJitter*r}},qf=t=>e=>{const n=e.cy-t.cy,r=e.cx-t.cx,i=Ee(r*r+n*n),o=(t.r*t.r-e.r*e.r+i*i)/(2*i),u=Ee(Mx(0)(t.r*t.r-o*o)),s=t.cx+o*r/i,a=t.cy+o*n/i,c={x:s-u*n/i,y:a+u*r/i},f={x:s+u*n/i,y:a-u*r/i};return i===0||i>t.r+e.r?{x:(t.cx+e.cx)/2,y:t.cy}:c.y<f.y?c:f},Ox=t=>e=>{const n=nn(e)(nn(t.w/2)(t.h/2));return[1,t.x+n,t.y,2,t.x+t.w-n,t.y,3,t.x+t.w,t.y,t.x+t.w,t.y+n,2,t.x+t.w,t.y+t.h-n,3,t.x+t.w,t.y+t.h,t.x+t.w-n,t.y+t.h,2,t.x+n,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-n,2,t.x,t.y+n,3,t.x,t.y,t.x+n,t.y,5]},qx=t=>e=>n=>r=>i=>o=>{if(e)return{prng:t,r:i};if(n)return{prng:t,r:i*(1+o.rJitter)};if(r)return{prng:t,r:i*o.smallScale};const u=Cr(t);return{prng:u.prng,r:i*(1+u.value*o.rJitter)}},$f=t=>{const e=nn(t.w)(t.h)/2;return[1,t.x+e,t.y,2,t.x+t.w-e,t.y,4,t.x+t.w-e+.5522847498307936*e,t.y,t.x+t.w,t.y+e-.5522847498307936*e,t.x+t.w,t.y+e,4,t.x+t.w,t.y+e+.5522847498307936*e,t.x+t.w-e+.5522847498307936*e,t.y+t.h,t.x+t.w-e,t.y+t.h,2,t.x+e,t.y+t.h,4,t.x+e-.5522847498307936*e,t.y+t.h,t.x,t.y+e+.5522847498307936*e,t.x,t.y+e,4,t.x,t.y+e-.5522847498307936*e,t.x+e-.5522847498307936*e,t.y,t.x+e,t.y,5]},$x=t=>e=>n=>{const r=Cr(t),i=e.length;return i===0?{prng:t,idx:-1}:{prng:r.prng,idx:(()=>{const o=Hf(0)(i-1|0)(de(dn(r.value*rt(n))));return o>=0&&o<e.length?e[o]:-1})()}},Yx=t=>e=>{const n=Cr(t),r=e.length;return r===0?{prng:t,idx:-1}:{prng:n.prng,idx:(()=>{const i=Hf(0)(r-1|0)(de(dn(n.value*rt(r))));return i>=0&&i<e.length?e[i]:-1})()}},Yf=t=>{const e=nn(t.w*.18)(t.h*.6);return[1,t.x+e,t.y,2,t.x+t.w,t.y,2,t.x+t.w-e,t.y+t.h,2,t.x,t.y+t.h,5]},Vf=t=>[1,t.x,t.y,2,t.x+t.w,t.y,2,t.x+t.w,t.y+t.h*.85,4,t.x+t.w*.66,t.y+t.h*1.05,t.x+t.w*.34,t.y+t.h*.65,t.x,t.y+t.h*.85,5],Xf={rBase:1.2,stepRatio:.7,rJitter:.35,yJitter:.2,xJitter:.2,heroShift:.2,smallScale:.85,smallShift:.15,seed:7,minN:3},Vx=t=>{const e=nn(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+e,i=t.x+n;return[1,t.x,r,4,t.x,r+.5522847498*e,i-.5522847498*n,r+e,i,r+e,4,i+.5522847498*n,r+e,t.x+t.w,r+.5522847498*e,t.x+t.w,r]},Uf=t=>{const e=nn(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+t.h+5,i=t.y+e,o=r-e,u=t.x+n;return[1,t.x,i,4,t.x,i-.5522847498*e,u-.5522847498*n,t.y,u,t.y,4,u+.5522847498*n,t.y,t.x+t.w,i-.5522847498*e,t.x+t.w,i,2,t.x+t.w,o,4,t.x+t.w,o+.5522847498*e,u+.5522847498*n,r,u,r,4,u-.5522847498*n,r,t.x,o+.5522847498*e,t.x,o,5]},jf=t=>e=>{const n=e.y+e.h,r=cd(t.rBase*e.h)(e.w/(2*(1+(rt(t.minN)-1)*t.stepRatio))),i=e.w-2*r,o=2*r*t.stepRatio,u=Zs(t.minN)(i<=0||o<=0?t.minN:de($n(i/o))+1|0),s=u>=3?It(1,u-2|0):[],a=s.length,c=En(a+1|0,2),f=c<1?[]:bt(0,c,s),d=Yx(t.seed)((()=>{const p=a-c|0;return p<1?s:bt(p,s.length,s)})()),l=d.idx,_=$x(d.prng)(ct(p=>p!==l,f))(Zs(1)(f.length-(Be(xr)(l)(f)?1:0)|0)),h=_.idx,m=u>=2?i/(rt(u)-1):0;return J(p=>y=>{const x=y===h,N=y===l,v=y===0||y===(u-1|0),k=qx(p.prng)(v)(N)(x)(r)(t),L=Wx(k.prng)(v)(t)(e.h),E=Hx(L.prng)(v)(t)(m);return{prng:E.prng,circles:zt(p.circles)({cx:e.x+Bx(k.r)(e.w-k.r)((u>=2?r+rt(y)/(rt(u)-1)*i+E.dx:r+0*i+E.dx)+(N?t.heroShift*m:x?-1*t.smallShift*m:0)),cy:n-L.yLift,r:k.r})}})({prng:_.prng,circles:[]})(It(0,u-1|0)).circles},Zf=t=>e=>{const n=t.length;return Qt(r=>i=>({c:i,p1:(()=>{if(r===0)return{x:i.cx-i.r,y:e};const o=r-1|0;return o>=0&&o<t.length?qf(t[o])(i):{x:i.cx-i.r,y:e}})(),p2:(()=>{if(r===(n-1|0))return{x:i.cx+i.r,y:e};const o=r+1|0;return o>=0&&o<t.length?qf(i)(t[o]):{x:i.cx+i.r,y:e}})()}))(t)},Kf=t=>{const e=nn(t.h*.4)(t.w*.2);return[1,t.x+e,t.y,2,t.x+t.w-e,t.y,2,t.x+t.w,t.y+t.h/2,2,t.x+t.w-e,t.y+t.h,2,t.x+e,t.y+t.h,2,t.x,t.y+t.h/2,5]},Xx=t=>e=>n=>{const r=ur(e.y-t.cy)(e.x-t.cx),i=ur(n.y-t.cy)(n.x-t.cx),o=i>r?i-r:i+6.283185307179586-r,u=Zs(1)(de(Xi(o/1.5707963267948966))),s=o/rt(u),a=1.3333333333333333*gd(s/4);return Tt(It(0,u-1|0))(c=>{const f=r+rt(c+1|0)*s,d=t.cx+t.r*Ke(f),l=t.cy+t.r*Oe(f),_=r+rt(c)*s;return[4,t.cx+t.r*Ke(_)-a*t.r*Oe(_),t.cy+t.r*Oe(_)+a*t.r*Ke(_),d+a*t.r*Oe(f),l-a*t.r*Ke(f),d,l]})},t_=t=>e=>{const n=t.h*.38,r=Zf(jf(Xf)({x:t.x,y:t.y-n,w:t.w,h:n}))(t.y),i=nn(e)(nn(t.w/2)(t.h/2));return 0<r.length?[1,r[0].p1.x,r[0].p1.y,...Tt(r)(o=>Xx(o.c)(o.p1)(o.p2)),2,t.x+t.w,t.y+t.h-i,3,t.x+t.w,t.y+t.h,t.x+t.w-i,t.y+t.h,2,t.x+i,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-i,2,r[0].p1.x,r[0].p1.y,5]:Ox(t)(e)},e_=t=>e=>n=>r=>i=>o=>{if(e==="Rectangle")return t.drawRoundedRect(n)(r)(i)(o);if(e==="Cylinder"){const u=Uf(n);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Parallelogram"){const u=Yf(n);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Diamond"){const u=Kf(n);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Ellipse"){const u=$f(n);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Document"){const u=Vf(n);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}if(e==="Cloud"){const u=t_(n)(r);if(i.tag==="Just"){if(o.tag==="Just")return t.fillStrokePath(u)(i._1)(o._1);if(o.tag==="Nothing")return t.fillPath(u)(i._1);g()}if(i.tag==="Nothing"){if(o.tag==="Just")return t.strokePath(u)(o._1);if(o.tag==="Nothing")return t.Monad0().Applicative0().pure()}g()}return t.drawRoundedRect(n)(r)(i)(o)},Ux=t=>()=>t.clip("evenodd"),jx=t=>e=>()=>{const n=Math.max(8,Math.ceil(8/Math.max(e.tile,.001))),r=Math.max(2,Math.round(e.tile*n)),i=document.createElement("canvas");i.width=r,i.height=r;const o=i.getContext("2d");o.scale(n,n),o.fillStyle=e.bgCss,o.fillRect(0,0,e.tile,e.tile),o.fillStyle=e.dotCss,o.beginPath(),o.arc(e.tile/2,e.tile/2,e.dotR,0,2*Math.PI),o.fill();const u=t.createPattern(i,"repeat");u&&typeof u.setTransform=="function"&&u.setTransform(new DOMMatrix().scaleSelf(1/n,1/n)),t.save(),t.fillStyle=u,t.fillRect(e.vx,e.vy,e.vw,e.vh),t.restore()},Ks=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},ta=t=>e=>n=>{const r=e.stroke;return()=>{const i=r.value,o=Qd(t)(n);if(i!==n)return o(),e.stroke.value=n}},Zx=t=>e=>n=>{const r=e.font;return()=>{const i=r.value,o=Od(t)(n);if(i!==n)return o(),e.font.value=n}},Ai=t=>e=>n=>{const r=e.fill;return()=>{const i=r.value,o=Id(t)(n);if(i!==n)return o(),e.fill.value=n}},jo=t=>e=>{const n=e.length,r=o=>{if(o>=n)return()=>{};const u=o>=0&&o<e.length?e[o]:0;if(u===1){const s=Ka(t)((()=>{const c=o+1|0;return c>=0&&c<e.length?e[c]:0})())((()=>{const c=o+2|0;return c>=0&&c<e.length?e[c]:0})()),a=r(o+3|0);return()=>(s(),a())}if(u===2){const s=ui(t)((()=>{const c=o+1|0;return c>=0&&c<e.length?e[c]:0})())((()=>{const c=o+2|0;return c>=0&&c<e.length?e[c]:0})()),a=r(o+3|0);return()=>(s(),a())}if(u===3){const s=si(t)({cpx:(()=>{const c=o+1|0;return c>=0&&c<e.length?e[c]:0})(),cpy:(()=>{const c=o+2|0;return c>=0&&c<e.length?e[c]:0})(),x:(()=>{const c=o+3|0;return c>=0&&c<e.length?e[c]:0})(),y:(()=>{const c=o+4|0;return c>=0&&c<e.length?e[c]:0})()}),a=r(o+5|0);return()=>(s(),a())}if(u===4){const s=$d(t)({cp1x:(()=>{const c=o+1|0;return c>=0&&c<e.length?e[c]:0})(),cp1y:(()=>{const c=o+2|0;return c>=0&&c<e.length?e[c]:0})(),cp2x:(()=>{const c=o+3|0;return c>=0&&c<e.length?e[c]:0})(),cp2y:(()=>{const c=o+4|0;return c>=0&&c<e.length?e[c]:0})(),x:(()=>{const c=o+5|0;return c>=0&&c<e.length?e[c]:0})(),y:(()=>{const c=o+6|0;return c>=0&&c<e.length?e[c]:0})()}),a=r(o+7|0);return()=>(s(),a())}if(u===5){const s=tc(t),a=r(o+1|0);return()=>(s(),a())}return()=>{}},i=Za(t);return()=>(i(),r(0)())},Kx=t=>e=>n=>r=>i=>o=>{const u=Ks(o)(Ks(r/2)(i/2)),s=Ka(t)(e+u)(n);return()=>(s(),ui(t)(e+r-u)(n)(),si(t)({cpx:e+r,cpy:n,x:e+r,y:n+u})(),ui(t)(e+r)(n+i-u)(),si(t)({cpx:e+r,cpy:n+i,x:e+r-u,y:n+i})(),ui(t)(e+u)(n+i)(),si(t)({cpx:e,cpy:n+i,x:e,y:n+i-u})(),ui(t)(e)(n+u)(),si(t)({cpx:e,cpy:n,x:e+u,y:n})(),tc(t)())},tN=()=>({font:{value:""},fill:{value:""},stroke:{value:""}}),eN=t=>e=>{const n=zd(t)({x:0,y:0,width:e.width,height:e.height});return()=>{n();const r=tN();return{ctx:t,surface:e,styleCache:r,maskDepth:{value:0}}}},nN={map:t=>e=>n=>{const r=e(n);return()=>{const i=r();return t(i)}}},rN=t=>ie(t.weight)+" "+Ga(t.size)+"px "+t.family,vn=t=>{const e=Ga(rt(t.a)/255);return t.a>=255?"rgb("+ie(t.r)+","+ie(t.g)+","+ie(t.b)+")":"rgba("+ie(t.r)+","+ie(t.g)+","+ie(t.b)+","+e+")"},iN=t=>e=>n=>r=>{const i=Ai(t)(n)(vn(r));return()=>(i(),Bd(t)({x:0,y:0,width:e.width,height:e.height})())},oN=t=>e=>n=>{const r=e.font;return()=>(r.value="",e.fill.value="",e.stroke.value="",jx(t)({vx:n.viewport.vx,vy:n.viewport.vy,vw:n.viewport.vw,vh:n.viewport.vh,bgCss:vn(n.bgColor),dotCss:vn(n.dotColor),tile:n.tile,dotR:n.dotRadius})())},uN=t=>e=>n=>r=>{const i=Ai(t)(e)(vn(r));return()=>(i(),jo(t)(n)(),Cu(t)())},sN=t=>e=>n=>r=>i=>{const o=Ai(t)(e)(vn(r));return()=>(o(),ta(t)(e)(vn(i.color))(),Lu(t)(i.width)(),no(t)((()=>{if(i.lineJoin==="RoundJoin")return eo;if(i.lineJoin==="BevelJoin")return Qu;if(i.lineJoin==="MiterJoin")return Fu;g()})())(),zu(t)((()=>{if(i.lineCap==="ButtCap")return Bu;if(i.lineCap==="RoundCap")return Au;if(i.lineCap==="SquareCap")return Mu;g()})())(),jo(t)(n)(),Cu(t)(),Gu(t)())},aN=t=>e=>n=>r=>i=>o=>{const u=Za(t);return()=>{if(u(),Kx(t)(n.x)(n.y)(n.w)(n.h)(r)(),i.tag==="Just"?(Ai(t)(e)(vn(i._1.color))(),Cu(t)()):i.tag==="Nothing"||g(),o.tag==="Just")return ta(t)(e)(vn(o._1.color))(),Lu(t)(o._1.width)(),no(t)((()=>{if(o._1.lineJoin==="RoundJoin")return eo;if(o._1.lineJoin==="BevelJoin")return Qu;if(o._1.lineJoin==="MiterJoin")return Fu;g()})())(),zu(t)((()=>{if(o._1.lineCap==="ButtCap")return Bu;if(o._1.lineCap==="RoundCap")return Au;if(o._1.lineCap==="SquareCap")return Mu;g()})())(),Gu(t)();o.tag!=="Nothing"&&g()}},cN=t=>e=>n=>r=>{const i=ta(t)(e)(vn(r.color));return()=>(i(),Lu(t)(r.width)(),no(t)((()=>{if(r.lineJoin==="RoundJoin")return eo;if(r.lineJoin==="BevelJoin")return Qu;if(r.lineJoin==="MiterJoin")return Fu;g()})())(),zu(t)((()=>{if(r.lineCap==="ButtCap")return Bu;if(r.lineCap==="RoundCap")return Au;if(r.lineCap==="SquareCap")return Mu;g()})())(),jo(t)(n)(),Gu(t)())},n_=t=>e=>n=>{const r=Ai(t)(e)(vn(n.color));return()=>(r(),Zx(t)(e)(rN(n.font))(),rl(t)((()=>{if(n.align==="AlignLeft")return jd;if(n.align==="AlignCenter")return Kd;if(n.align==="AlignRight")return Zd;g()})())(),nl(t)((()=>{if(n.baseline==="BaselineTop")return Yd;if(n.baseline==="BaselineMiddle")return Vd;if(n.baseline==="BaselineAlphabetic")return Xd;if(n.baseline==="BaselineBottom")return Ud;g()})())(),qd(t)(n.content)(n.x)(n.y)())},r_={apply:t=>e=>n=>{const r=t(n),i=e(n);return()=>{const o=r(),u=i();return o(u)}},Functor0:()=>nN},gN={bind:t=>e=>n=>{const r=t(n);return()=>{const i=r();return e(i)(n)()}},Apply0:()=>r_},fN=t=>e=>n=>{const r=Ks(e.width/n.vw)(e.height/n.vh),i=Su(t)({translateX:(e.width-n.vw*r)/2-n.vx*r,translateY:(e.height-n.vh*r)/2-n.vy*r});return()=>(i(),Ki(t)({scaleX:r,scaleY:r})(),no(t)(eo)())},_N={pure:t=>e=>()=>t,Apply0:()=>r_},dN={Applicative0:()=>_N,Bind1:()=>gN},i_={fillPath:t=>e=>n=>{const r=uN(n.ctx)(n.styleCache)(t)(e.color),i=n.maskDepth;return()=>{if(i.value===0)return r()}},strokePath:t=>e=>n=>{const r=cN(n.ctx)(n.styleCache)(t)(e),i=n.maskDepth;return()=>{if(i.value===0)return r()}},fillStrokePath:t=>e=>n=>r=>{const i=sN(r.ctx)(r.styleCache)(t)(e.color)(n),o=r.maskDepth;return()=>{if(o.value===0)return i()}},drawRoundedRect:t=>e=>n=>r=>i=>{const o=aN(i.ctx)(i.styleCache)(t)(e)(n)(r),u=i.maskDepth;return()=>{if(u.value===0)return o()}},drawText:t=>e=>{const n=n_(e.ctx)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},drawTextAffine:t=>e=>n=>{const r=sr(n.ctx),i=n.maskDepth;return()=>{if(i.value===0)return r(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value="",Rd(n.ctx)(t)(),n_(n.ctx)(n.styleCache)(e)(),ar(n.ctx)(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value=""}},pushTransform:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0)return n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",Su(e.ctx)({translateX:t.tx,translateY:t.ty})(),Ki(e.ctx)({scaleX:t.sx,scaleY:t.sy})()}},popTransform:t=>{const e=ar(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushBakedTransform:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0)return n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",Su(e.ctx)({translateX:t.tx,translateY:t.ty})(),Ki(e.ctx)({scaleX:t.sx,scaleY:t.sy})()}},popBakedTransform:t=>{const e=ar(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushClip:t=>e=>n=>{const r=sr(n.ctx),i=n.maskDepth;return()=>{if(i.value===0){if(r(),n.styleCache.font.value="",n.styleCache.fill.value="",n.styleCache.stroke.value="",jo(n.ctx)(t)(),e==="NonZero")return Md(n.ctx)();if(e==="EvenOdd")return Ux(n.ctx)();g()}}},popClip:t=>{const e=ar(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushBlend:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0){if(n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",t==="Normal")return nc(e.ctx)(tl)();if(t==="Difference")return nc(e.ctx)(el)();g()}}},popBlend:t=>{const e=ar(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushAlpha:t=>e=>{const n=sr(e.ctx),r=e.maskDepth;return()=>{if(r.value===0)return n(),e.styleCache.font.value="",e.styleCache.fill.value="",e.styleCache.stroke.value="",Ad(e.ctx)(t)()}},popAlpha:t=>{const e=ar(t.ctx),n=t.maskDepth;return()=>{if(n.value===0)return e(),t.styleCache.font.value="",t.styleCache.fill.value="",t.styleCache.stroke.value=""}},pushLayer:t=>e=>{if(t==="LayerNodeMask"){const n=e.maskDepth;return()=>{const r=n.value;n.value=r+1|0}}return()=>{}},popLayer:t=>{const e=t.maskDepth;return()=>{const n=e.value,r=n-1|0;if(n>0)return t.maskDepth.value=r}},setViewport:t=>e=>{const n=fN(e.ctx)(e.surface)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},clearBackground:t=>e=>{const n=iN(e.ctx)(e.surface)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},backgroundDots:t=>e=>{const n=oN(e.ctx)(e.styleCache)(t),r=e.maskDepth;return()=>{if(r.value===0)return n()}},measureText:t=>e=>n=>{const r=If(t)(e);return()=>r},measureInk:t=>e=>n=>{const r=Qf(t)(e);return()=>r},insideTokenStyle:t=>e=>()=>Of,Monad0:()=>dN},lN=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},Hr=t=>e=>n=>{const r=lN(.05)(1-t-e);return n<t?0:n>1-e?1:(n-t)/r},o_=t=>{const e=st.compare(0)(t),n=(()=>{if(e==="LT")return t;if(e==="EQ"||e==="GT")return 0;g()})(),r=st.compare(1)(n);if(r==="LT"||r==="EQ")return 1;if(r==="GT")return n;g()},Zo=t=>{if(t.tag==="Hidden")return{alpha:0,scale:0};if(t.tag==="Visible")return{alpha:1,scale:1};if(t.tag==="PloppingIn")return{alpha:t._1>0?1:0,scale:pi(8)(.6)(o_(t._1))};if(t.tag==="PloppingOut")return{alpha:t._1<1?1:0,scale:pi(8)(.6)(o_(1-t._1))};g()};function hN(t,e){const n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function pN(t){const e=t.length,n=new Array(e);for(let r=0;r<e;r++){const i=t[r],o=t[(r+1)%e];n[r]={a:i,b:o,len:hN(i,o)}}return n}function mN(t,e,n){let r=0;for(let i=0;i<t.length;i++){const o=t[i],u=r,s=u+o.len;if(n<=s){const a=o.len>1e-6?(n-u)/o.len:0;return{x:o.a.x+(o.b.x-o.a.x)*a,y:o.a.y+(o.b.y-o.a.y)*a}}r=s}return e.length>0?e[e.length-1]:{x:0,y:0}}function u_(t,e){if(e.length===0)return[];const n=pN(e);let r=0;for(let o=0;o<n.length;o++)r+=n[o].len;const i=new Array(t);for(let o=0;o<t;o++)i[o]=mN(n,e,o*r/t);return i}function yN(t,e){const n=e.length;if(n===0)return e;const r=(t%n+n)%n|0,i=new Array(n);for(let o=0;o<n;o++)i[o]=e[(o+r)%n];return i}function xN(t,e){const n=e.length;if(n===0)return e;let r=0,i=1/0;for(let o=0;o<n;o++){let u=0;for(let s=0;s<n;s++){const a=t[s]||{x:0,y:0},c=e[(s+o)%n]||{x:0,y:0},f=a.x-c.x,d=a.y-c.y;u+=f*f+d*d}u<i&&(i=u,r=o)}return yN(r,e)}const s_=t=>e=>n=>{const r=u_(t,e),i=u_(t,n),o=xN(r,i);return{from:r,to:o}};function a_(t){const e=t.length;if(e===0)return{x:0,y:0};let n=0,r=0;for(let i=0;i<e;i++)n+=t[i].x,r+=t[i].y;return{x:n/e,y:r/e}}function NN(t,e){const n=e.x-t.x,r=e.y-t.y,i=Math.sqrt(n*n+r*r);return i<=1e-4?{x:1,y:0}:{x:n/i,y:r/i}}function JN(t,e){const n=e.length;if(n===0)return e;const r=new Array(n);for(let i=0;i<n;i++){const o=e[((i-1)%n+n)%n],u=e[((i+1)%n+n)%n],s=e[i];r[i]={x:s.x+((o.x+u.x)/2-s.x)*t,y:s.y+((o.y+u.y)/2-s.y)*t}}return r}function TN(t){return t<0?0:t>1?1:t}const c_=t=>e=>n=>r=>{const i=e.length;if(i===0)return[];const o=a_(e),u=a_(n),s=NN(o,u),a=new Array(i);let c=1/0,f=-1/0;for(let _=0;_<i;_++){const h=e[_],m=(h.x-o.x)*s.x+(h.y-o.y)*s.y;a[_]=m,m<c&&(c=m),m>f&&(f=m)}const d=f-c;let l=new Array(i);for(let _=0;_<i;_++){const h=e[_],m=n[_];if(m===void 0){l[_]=h;continue}const p=d<=1e-4?0:r.maxDelay*(1-(a[_]-c)/d),y=Math.max(1e-4,1-p),x=TN((t-p)/y),N=x*x*(3-2*x);l[_]={x:h.x+(m.x-h.x)*N,y:h.y+(m.y-h.y)*N}}for(let _=0;_<r.smoothPasses;_++)l=JN(.5,l);return l},wn=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},g_=J(Tr)(0),f_=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},vN=J(t=>e=>t+e.len)(0),__=t=>{const e=Ft(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Tt(bt(1,t.length,t))(n=>[2,n.x,n.y]),5];g()},wN=t=>e=>{const n=wn(e)(wn(t.w/2)(t.h/2));return[1,t.x+n,t.y,2,t.x+t.w-n,t.y,3,t.x+t.w,t.y,t.x+t.w,t.y+n,2,t.x+t.w,t.y+t.h-n,3,t.x+t.w,t.y+t.h,t.x+t.w-n,t.y+t.h,2,t.x+n,t.y+t.h,3,t.x,t.y+t.h,t.x,t.y+t.h-n,2,t.x,t.y+n,3,t.x,t.y,t.x+n,t.y,5]},bN=t=>{const e=Ft(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Tt(e._1.tail)(n=>[2,n.x,n.y])];g()},LN=t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h};if(t.shape==="Cylinder")return Uf(e);if(t.shape==="Parallelogram")return Yf(e);if(t.shape==="Diamond")return Kf(e);if(t.shape==="Ellipse")return $f(e);if(t.shape==="Document")return Vf(e);if(t.shape==="Cloud")return t_(e)(7);if(t.shape==="Rectangle")return wN(e)(7);g()},pe=t=>e=>n=>H(r=>{const i=rt(r)/rt(n);return{x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}})(It(0,n-1|0)),kN=t=>{const e=nn(t.w*.18)(t.h*.6);return[...pe({x:t.x+e,y:t.y})({x:t.x+t.w,y:t.y})(16),...pe({x:t.x+t.w,y:t.y})({x:t.x+t.w-e,y:t.y+t.h})(16),...pe({x:t.x+t.w-e,y:t.y+t.h})({x:t.x,y:t.y+t.h})(16),...pe({x:t.x,y:t.y+t.h})({x:t.x+e,y:t.y})(16)]},Or=t=>e=>{const n=wn(t)(wn(e.w/2)(e.h/2));return{...e,x:e.x+n,y:e.y+n,w:e.w-2*n,h:e.h-2*n}},ea=t=>e=>{const n=e.y-t.y,r=e.x-t.x;return Ee(r*r+n*n)},EN=t=>Je(e=>n=>({a:e,b:n,len:ea(e)(n)}),t,bt(1,t.length,t)),GN=t=>e=>{const n=e.length-1|0,r=n>=0&&n<e.length?w("Just",e[n]):T,i=(()=>{if(r.tag==="Just")return[r._1];if(r.tag==="Nothing")return[];g()})(),o=0<e.length?w("Just",e[0]):T,u=(()=>{if(o.tag==="Just")return o._1;if(o.tag==="Nothing")return{x:0,y:0};g()})(),s=e.length;return s<3?e:[u,...Tt(It(1,s-2|0))(a=>{const c=a+1|0,f=c>=0&&c<e.length?w("Just",e[c]):T,d=a>=0&&a<e.length?w("Just",e[a]):T,l=a-1|0,_=l>=0&&l<e.length?w("Just",e[l]):T;if(_.tag==="Just"&&d.tag==="Just"&&f.tag==="Just"){const h=d._1,m=ea(h)(f._1),p=ea(_._1)(h),y=wn(t)(m/2),x=wn(t)(p/2),N=m>0?y/m:0,v=h.x+(f._1.x-h.x)*N,k=h.y+(f._1.y-h.y)*N,L=p>0?x/p:0,E=h.x+(_._1.x-h.x)*L,B=h.y+(_._1.y-h.y)*L;return H(V=>{const et=rt(V)/rt(10),D=1-et;return{x:D*D*E+2*D*et*h.x+et*et*v,y:D*D*B+2*D*et*h.y+et*et*k}})(It(0,10))}return[]}),...i]},CN=t=>e=>n=>r=>i=>H(o=>{const u=rt(o)/rt(i),s=1-u,a=u*u*u,c=3*s*u*u,f=3*s*s*u,d=s*s*s;return{x:d*t.x+f*e.x+c*n.x+a*r.x,y:d*t.y+f*e.y+c*n.y+a*r.y}})(It(0,i-1|0)),SN=t=>[...pe({x:t.x,y:t.y})({x:t.x+t.w,y:t.y})(12),...pe({x:t.x+t.w,y:t.y})({x:t.x+t.w,y:t.y+t.h*.85})(12),...CN({x:t.x+t.w,y:t.y+t.h*.85})({x:t.x+t.w*.66,y:t.y+t.h*1.05})({x:t.x+t.w*.34,y:t.y+t.h*.65})({x:t.x,y:t.y+t.h*.85})(32),...pe({x:t.x,y:t.y+t.h*.85})({x:t.x,y:t.y})(12)],d_=t=>e=>H(n=>{const r=6.283185307179586*rt(n)/rt(64);return{x:t.x+e*Ke(r),y:t.y+e*Oe(r)}})(It(0,63)),Ko=t=>e=>{const n=.5522847498*e;return[1,t.x+e,t.y,4,t.x+e,t.y+n,t.x+n,t.y+e,t.x,t.y+e,4,t.x-n,t.y+e,t.x-e,t.y+n,t.x-e,t.y,4,t.x-e,t.y-n,t.x-n,t.y-e,t.x,t.y-e,4,t.x+n,t.y-e,t.x+e,t.y-n,t.x+e,t.y,5]},DN=t=>{const e=t.y+t.h/2,n=nn(t.h*.4)(t.w*.2);return[...pe({x:t.x+n,y:t.y})({x:t.x+t.w-n,y:t.y})(10),...pe({x:t.x+t.w-n,y:t.y})({x:t.x+t.w,y:e})(8),...pe({x:t.x+t.w,y:e})({x:t.x+t.w-n,y:t.y+t.h})(8),...pe({x:t.x+t.w-n,y:t.y+t.h})({x:t.x+n,y:t.y+t.h})(10),...pe({x:t.x+n,y:t.y+t.h})({x:t.x,y:e})(8),...pe({x:t.x,y:e})({x:t.x+n,y:t.y})(8)]},l_=t=>{const e=t.length;return e===0?{x:0,y:0}:{x:g_(H(n=>n.x)(t))/rt(e),y:g_(H(n=>n.y)(t))/rt(e)}},tu=t=>e=>n=>r=>i=>H(o=>{const u=n+(r-n)*(rt(o)/rt(i));return{x:t.x+e*Ke(u),y:t.y+e*Oe(u)}})(It(0,i-1|0)),h_=t=>e=>{const n=wn(t)(wn(e.w/2)(e.h/2));return[...pe({x:e.x+n,y:e.y})({x:e.x+e.w-n,y:e.y})(6),...tu({x:e.x+e.w-n,y:e.y+n})(n)(4.71238898038469)(6.283185307179586)(12),...pe({x:e.x+e.w,y:e.y+n})({x:e.x+e.w,y:e.y+e.h-n})(6),...tu({x:e.x+e.w-n,y:e.y+e.h-n})(n)(0)(1.5707963267948966)(12),...pe({x:e.x+e.w-n,y:e.y+e.h})({x:e.x+n,y:e.y+e.h})(6),...tu({x:e.x+n,y:e.y+e.h-n})(n)(1.5707963267948966)(3.141592653589793)(12),...pe({x:e.x,y:e.y+e.h-n})({x:e.x,y:e.y+n})(6),...tu({x:e.x+n,y:e.y+n})(n)(3.141592653589793)(4.71238898038469)(12)]},eu=t=>e=>n=>r=>i=>o=>H(u=>{const s=r+(i-r)*(rt(u)/rt(o));return{x:t.x+e*Ke(s),y:t.y+n*Oe(s)}})(It(0,o-1|0)),PN=t=>{const e=t.h*.38;return[...Tt(Zf(jf(Xf)({x:t.x,y:t.y-e,w:t.w,h:e}))(t.y))(n=>{const r=ur(n.p2.y-n.c.cy)(n.p2.x-n.c.cx),i=ur(n.p1.y-n.c.cy)(n.p1.x-n.c.cx);return eu({x:n.c.cx,y:n.c.cy})(n.c.r)(n.c.r)(i)(r>i?r:r+6.283185307179586)(16)}),...pe({x:t.x+t.w,y:t.y})({x:t.x+t.w,y:t.y+t.h})(8),...pe({x:t.x+t.w,y:t.y+t.h})({x:t.x,y:t.y+t.h})(12),...pe({x:t.x,y:t.y+t.h})({x:t.x,y:t.y})(8)]},IN=t=>{const e=wn(t.h*.075)(t.w*.075),n=t.w/2,r=t.y+e,i=t.y+t.h+5-e-2,o=t.x+n;return[...eu({x:o,y:r})(n)(e)(3.141592653589793)(6.283185307179586)(24),...pe({x:t.x+t.w,y:r})({x:t.x+t.w,y:i})(12),...eu({x:o,y:i})(n)(e)(0)(3.141592653589793)(24),...pe({x:t.x,y:i})({x:t.x,y:r})(12)]},nu=t=>e=>e.shape==="Cylinder"?IN(e):e.shape==="Parallelogram"?kN(e):e.shape==="Diamond"?DN(e):e.shape==="Ellipse"?h_(nn(e.w)(e.h)/2)(e):e.shape==="Document"?SN(e):e.shape==="Cloud"?PN(e):h_(t)(e),QN=t=>{const e=wn(t.h*.075)(t.w*.075),n=t.w/2;return eu({x:t.x+n,y:t.y+e})(n)(e)(0)(3.141592653589793)(24)},FN=t=>e=>n=>J(r=>i=>{const o=r.pos+i.len,u=n<o?(n-r.pos)/i.len:1,s={x:i.a.x+(i.b.x-i.a.x)*u,y:i.a.y+(i.b.y-i.a.y)*u},a=e>r.pos?(e-r.pos)/i.len:0,c={x:i.a.x+(i.b.x-i.a.x)*a,y:i.a.y+(i.b.y-i.a.y)*a},f=r.points.length-1|0,d=f>=0&&f<r.points.length?(()=>{const l=r.points[f].x-c.x;return(l<0?-l<1e-4:l<1e-4)&&(()=>{const _=r.points[f].y-c.y;return _<0?-_<1e-4:_<1e-4})()})()?zt(r.points)(s):[...r.points,c,s]:[c,s];return i.len<=0||o<=e||r.pos>=n?{...r,pos:o}:{pos:o,points:d}})({pos:0,points:[]})(t).points,AN=t=>e=>n=>{const r=Ft(i=>T,i=>o=>w("Just",{head:i,tail:o}),t);if(r.tag==="Nothing")return[];if(r.tag==="Just"){const i=EN(t),o=vN(i),u=f_(0)(o)(e*o),s=f_(0)(o)(n*o);return s<=u?[]:FN(i)(u)(s)}g()},na=t=>t,Fn=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},pr=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},MN=O1(Fa)(Bt),BN=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},zN=t=>e=>{const n=it.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},p_=na("SegMove"),RN=na("SegLine"),WN=na("SegQuad"),m_={offset:.4,passes:1,rMax:1.5},y_=t=>de(dn(t.x*7919+t.y*3001+t.w*113+t.h*17+1))*-1640531535|0,ru=t=>e=>n=>()=>{t.push(3),t.push(e.x),t.push(e.y),t.push(n.x),t.push(n.y)},iu=t=>e=>()=>{t.push(1),t.push(e.x),t.push(e.y)},An=t=>e=>()=>{t.push(2),t.push(e.x),t.push(e.y)},Mi=(()=>{const t=J(e=>n=>((e*31|0)+de(dn(n.x*100))|0)+de(dn(n.y*100))|0)(1);return e=>t(e)*-1640531535|0})(),HN=t=>{const e=[];let n=0,r={x:0,y:0};for(;n<t.length;){const i=n,o=r,u=i>=0&&i<t.length?w("Just",t[i]):T;if(u.tag==="Nothing"){n=t.length;continue}if(u.tag==="Just"){if(u._1===1){const s={x:(()=>{const a=i+1|0;return a>=0&&a<t.length?t[a]:0})(),y:(()=>{const a=i+2|0;return a>=0&&a<t.length?t[a]:0})()};e.push({kind:p_,m:o,c:o,p:s,len:0}),r=s,n=i+3|0;continue}if(u._1===2){const s={x:(()=>{const f=i+1|0;return f>=0&&f<t.length?t[f]:0})(),y:(()=>{const f=i+2|0;return f>=0&&f<t.length?t[f]:0})()},a=s.x-o.x,c=s.y-o.y;e.push({kind:RN,m:o,c:o,p:s,len:Ee(a*a+c*c)}),r=s,n=i+3|0;continue}if(u._1===3){const s={x:(()=>{const f=i+3|0;return f>=0&&f<t.length?t[f]:0})(),y:(()=>{const f=i+4|0;return f>=0&&f<t.length?t[f]:0})()},a=s.x-o.x,c=s.y-o.y;e.push({kind:WN,m:o,c:{x:(()=>{const f=i+1|0;return f>=0&&f<t.length?t[f]:0})(),y:(()=>{const f=i+2|0;return f>=0&&f<t.length?t[f]:0})()},p:s,len:Ee(a*a+c*c)*1.05}),r=s,n=i+5|0;continue}if(u._1===5){e.push({kind:p_,m:o,c:o,p:o,len:0}),n=i+1|0;continue}n=t.length;continue}g()}return e},ON=t=>e=>{const n=e.length-1|0,r=n<1?[]:bt(0,n,e),i=(()=>{const u=r.length-1|0;return u>=0&&u<r.length?w("Just",r[u]):T})(),o=e.length-1|0;if(o>=0&&o<e.length&&i.tag==="Just"){const u=e[o].y-i._1.y,s=e[o].x-i._1.x,a=Ee(s*s+u*u);return a<=1e-4?e:zt((()=>{const c=e.length-1|0;return c<1?[]:bt(0,c,e)})())({x:e[o].x+s/a*t,y:e[o].y+u/a*t})}return e},qN=t=>e=>n=>ke(J(r=>i=>{const o=ae(0)(t)(r.prng),u=ae(0)(6.283185307179586)(o.prng);return{prng:u.prng,out:[{x:i.x+o.value*Ke(u.value),y:i.y+o.value*Oe(u.value)},...r.out]}})({prng:e,out:[]})(n).out),$N=t=>e=>n=>{if(e.kind==="SegMove")return iu(t)(e.p);if(e.kind==="SegLine")return An(t)({x:e.m.x+(e.p.x-e.m.x)*n,y:e.m.y+(e.p.y-e.m.y)*n});if(e.kind==="SegQuad")return An(t)({x:e.m.x+(e.p.x-e.m.x)*n,y:e.m.y+(e.p.y-e.m.y)*n});g()},YN=t=>e=>{if(e.kind==="SegMove")return iu(t)(e.p);if(e.kind==="SegLine")return An(t)(e.p);if(e.kind==="SegQuad")return ru(t)(e.c)(e.p);g()},x_=t=>e=>{const n=HN(e),r=J(s=>a=>s+a.len)(0)(n)*Fn(0)(pr(1)(t)),i=[];let o=0,u=0;for(;u<n.length;){const s=u,a=o;if(s>=0&&s<n.length){if(a+n[s].len<=r){const c=n[s];YN(i)(c)(),o=a+c.len,u=s+1|0;continue}if(a>=r){u=n.length;continue}$N(i)(n[s])((r-a)/Fn(n[s].len)(1e-4))()}u=n.length}return i},N_={offset:1.5,passes:2,rMax:14,overshoot:2.5},J_=t=>e=>n=>r=>{const i=r.y-n.y,o=n.y-e.y,u=r.x-n.x,s=Ee(u*u+i*i),a=n.x-e.x,c=Ee(a*a+o*o),f=pr(t.rMax*(ad(c>0&&s>0?Fn(-1)(pr(1)((a*u+o*i)/(c*s))):1)/3.141592653589793))(.4*pr(c)(s));return{inP:c>0?{x:n.x-a/c*f,y:n.y-o/c*f}:n,curr:n,outP:s>0?{x:n.x+u/s*f,y:n.y+i/s*f}:n}},T_=t=>e=>{const n=e.length,r=[],i=0<e.length?w("Just",e[0]):T;if(i.tag==="Just"?iu(r)(i._1)():i.tag==="Nothing"||g(),n>=3){let u=1;for(;u<=(n-2|0);){const s=u,a=s+1|0;if(a>=0&&a<e.length){if(s>=0&&s<e.length){const c=s-1|0;if(c>=0&&c<e.length){const f=J_(t)(e[c])(e[s])(e[a]);An(r)(f.inP)(),ru(r)(f.curr)(f.outP)()}}u=s+1|0;continue}u=s+1|0}}const o=e.length-1|0;return o>=0&&o<e.length&&n>=2&&An(r)(e[o])(),r},VN=t=>e=>n=>r=>i=>{if(i.length<4)return T_(t)(i);const o=0<i.length?w("Just",i[0]):T,u=(()=>{if(o.tag==="Nothing")return{x:0,y:0};if(o.tag==="Just")return o._1;g()})(),s=i.length-1|0,a=Yn(Yn(e)(s)+s|0)(s),c=_=>{const h=Yn(_+s|0)(s);return h>=0&&h<i.length?i[h]:u},f=H(_=>J_(t)(c((a+_|0)-1|0))(c(a+_|0))(c((a+_|0)+1|0)))(It(0,s-1|0)),d=[],l=0<f.length?w("Just",f[0]):T;if(l.tag==="Just")if(iu(d)(l._1.outP)(),MN((()=>{const _=Ft(h=>T,h=>m=>w("Just",m),f);if(_.tag==="Nothing")return[];if(_.tag==="Just")return _._1;g()})())(_=>{const h=An(d)(_.inP);return()=>(h(),ru(d)(_.curr)(_.outP)())})(),n)An(d)(l._1.inP)(),ru(d)(l._1.curr)(l._1.outP)(),d.push(5);else{const _=f.length-1|0;_>=0&&_<f.length?An(d)((()=>{const h=1-r;return{x:f[_].outP.x+(l._1.inP.x-f[_].outP.x)*h,y:f[_].outP.y+(l._1.inP.y-f[_].outP.y)*h}})())():An(d)(l._1.inP)()}else l.tag==="Nothing"||g();return d},qr=t=>e=>n=>r=>{const i=BN(1)(r.length-1|0),o=ae(0)(rt(i))(gs("shape")(e)),u=zN(i-1|0)(de(dn(o.value))),s=o.prng;return H(a=>{const c=ae(0)(1)(gs(ie(a))(s)),f=ae(-.18)(.3)(c.prng),d=c.value<.7,l=ae(.5)(.85)(f.prng),_=qN(t.offset)(l.prng)(r);return{path:n?VN(t)(u)(d)(f.value)(_):T_(t)(_),alpha:l.value}})(It(0,t.passes-1|0))},XN=t=>e=>n=>qr(t)(e)(!0)([{x:n.x,y:n.y},{x:n.x+n.w,y:n.y},{x:n.x+n.w,y:n.y+n.h},{x:n.x,y:n.y+n.h},{x:n.x,y:n.y}]),UN=t=>e=>n=>{const r=Fn(0)(pr(1)(n)),i=e.h/rt(4),o=Fn(6)(i*1.4);return xt(u=>u)(H(u=>{if(r<Fn(0)(rt(u)/rt(4)-.05))return T;const s=gs(ie(u))(t),a=Fn(0)(rt(u)/rt(4)-.05),c=Yn(u)(2)===0,f=c?e.x-2:e.x+e.w+2,d=c?e.x+e.w+2:e.x-2,l=e.y+(rt(u)+.5)*i;return w("Just",{path:x_(Fn(0)(pr(1)((r-a)/Fn(1e-4)(pr(1)(rt(u+1|0)/rt(4)+.05)-a))))((()=>{const _={rMax:2,offset:.6,passes:1},h=ke(J(p=>y=>{const x=ae(-i*.08)(i*.08)(p.prng);return{prng:x.prng,out:[{x:f+(d-f)*(rt(y)/rt(4)),y:l+x.value},...p.out]}})({prng:s,out:[]})(It(0,4)).out),m=h.length<2?[]:qr(_)(s)(!1)(h);return 0<m.length?m[0].path:[]})()),width:o,alpha:1})})(It(0,3)))},ra=(t,e,n)=>({tag:t,_1:e,_2:n}),v_=t=>t,ia=(t,e,n)=>({tag:t,_1:e,_2:n}),ou=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},w_=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},Bi=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},b_=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},fe=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},We=(()=>{const t=qe.unfoldr(hn);return e=>t($e("IterNode",e,ln))})(),mr=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},jN=Bt.foldMap(vd),uu=t=>e=>{const n=it.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},L_=Kt(C)(Bt),ZN=Xa(C),KN=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},oa=v_("LabelsShown"),tJ=v_("LabelsHidden"),k_=t=>{const e=t.Monad0().Bind1(),n=t.popTransform,r=t.popAlpha;return i=>o=>u=>s=>a=>e.bind(t.pushAlpha(i.fadeAlpha))(()=>e.bind(t.pushTransform({tx:o*(1-i.popScale),ty:u*(1-i.popScale),sx:i.popScale,sy:i.popScale}))(()=>e.bind(t.pushTransform({tx:0,ty:s.y*(1-i.flipY),sx:1,sy:i.flipY}))(()=>e.bind(a)(()=>e.bind(n)(()=>e.bind(n)(()=>r))))))},rn=t=>{const e=t.Apply0();return n=>J(r=>i=>e.apply(e.Functor0().map(o=>Ea)(r))(n(i)))(t.pure())},E_=t=>e=>n=>r=>i=>o=>{const u={x:n.x+n.w/2,y:n.y+n.h/2},s={x:e.x+e.w/2,y:e.y+e.h/2},a=Hr(i)(o)(r),c=0<t.length?w("Just",t[0]):T,f=(()=>{if(c.tag==="Just")return c._1;if(c.tag==="Nothing")return s;g()})(),d=t.length-1|0,l=d>=0&&d<t.length?w("Just",t[d]):T,_=(()=>{if(l.tag==="Just")return l._1;if(l.tag==="Nothing")return u;g()})(),h=s_(128)(nu(4)(Or(2)(e)))(d_(f)(6)),m=f.x-s.x,p=2*(()=>{const Z=f.y-s.y;return(m<0?-m:m)+(Z<0?-Z:Z)})(),y=_.x-u.x,x=2*(()=>{const Z=_.y-u.y;return(y<0?-y:y)+(Z<0?-Z:Z)})(),N=p+_i(t)+x,v=N<=1e-4?1:1-x/N,k=N<=1e-4?0:p/N,L=v-k,E=s_(128)(d_(_)(6))(nu(4)(Or(2)(n))),B={maxDelay:.4,smoothPasses:2},V=vr(t)(ou(0)(1)(L<=1e-4?0:(a-k)/L)),et=(()=>{if(V.tag==="Just")return V._1;if(V.tag==="Nothing")return f;g()})(),D=(()=>{if(v>=1)return 0;const Z=(a-v)/(1-v),X=Z<0?0:Z>1?1:Z;return X*X*(3-2*X)})(),S=(()=>{if(k<=1e-4)return 1;const Z=a/k,X=Z<0?0:Z>1?1:Z;return X*X*(3-2*X)})();return a<k?ia("PolyShape",c_(S)(h.from)(h.to)(B)):a>=v?ia("PolyShape",c_(D)(E.from)(E.to)(B)):ia("CircleShape",et,6)},G_=t=>e=>n=>r=>i=>o=>{const u=E_(t)(e)(n)(r)(i)(o);if(u.tag==="PolyShape")return l_(u._1);if(u.tag==="CircleShape")return u._1;g()},eJ=t=>e=>{const n=t.y+t.h-6,r=t.y+6,i=t.x+14,o=t.x+t.w-14,u=J(Bi)(0)(H(s=>i-10<s.x+s.w+12&&o+10>s.x-12&&r-10<s.y+s.h+12&&n+10>s.y-12?w_((s.x+s.w+12-(i-10))/.7071067811865476)((n+10-(s.y-12))/.7071067811865476):0)(e));return{...t,x:t.x+u*.7071067811865476,y:t.y-u*.7071067811865476}},nJ=t=>e=>n=>J(r=>i=>{const o=b_(i)(e);if(o.tag==="Nothing")return r;if(o.tag==="Just"){const u=eJ(o._1)(r.obstacles);return{acc:j(C)(i)(u)(r.acc),obstacles:zt(r.obstacles)(u)}}g()})({acc:Q,obstacles:n})(t).acc,ua=(()=>{const t={r:24,g:24,b:27,a:255},e={r:244,g:244,b:245,a:255},n={r:248,g:249,b:246,a:255},r={r:26,g:26,b:26,a:255},i={r:28,g:101,b:192,a:255},o={r:247,g:248,b:250,a:255},u={r:42,g:48,b:60,a:255},s={r:120,g:130,b:146,a:255};return a=>{if(a==="Light")return{bg:{r:255,g:255,b:255,a:255},bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:214,g:211,b:209,a:255},shadowFill:{r:255,g:255,b:255,a:255},shadowDot:{r:26,g:26,b:26,a:255},chip:{r:255,g:235,b:130,a:255},chipShadow:{r:214,g:211,b:209,a:255},chipText:Qn,nodeFill:re,nodeStroke:Qn,text:Qn,edge:Qn,arrowFill:Qn,tokenOutsideFill:Qn,tokenOutsideStroke:re,tokenInside:re,tokenInsideStroke:re,tokenInsideBlend:Uo,tokenInsideAlpha:1,chipPillFill:Qn,chipPillText:re,chipHairline:{r:26,g:26,b:26,a:90},trailDot:Qn,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(a==="Dark")return{bg:t,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:63,g:63,b:70,a:255},shadowFill:t,shadowDot:e,chip:{r:234,g:179,b:8,a:255},chipShadow:{r:0,g:0,b:0,a:120},chipText:t,nodeFill:Qn,nodeStroke:e,text:e,edge:e,arrowFill:e,tokenOutsideFill:re,tokenOutsideStroke:re,tokenInside:re,tokenInsideStroke:re,tokenInsideBlend:Uo,tokenInsideAlpha:1,chipPillFill:e,chipPillText:t,chipHairline:{r:244,g:244,b:245,a:120},trailDot:e,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(a==="Blueprint")return{bg:i,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:90,g:160,b:230,a:255},shadowFill:i,shadowDot:re,chip:re,chipShadow:{r:0,g:0,b:0,a:120},chipText:i,nodeFill:i,nodeStroke:re,text:re,edge:re,arrowFill:re,tokenOutsideFill:re,tokenOutsideStroke:re,tokenInside:re,tokenInsideStroke:re,tokenInsideBlend:Rf,tokenInsideAlpha:.35,chipPillFill:re,chipPillText:i,chipHairline:{r:255,g:255,b:255,a:120},trailDot:re,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(a==="Whiteboard")return{bg:n,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:0,g:0,b:0,a:0},shadowFill:n,shadowDot:r,chip:{r:217,g:74,b:56,a:255},chipShadow:{r:26,g:26,b:26,a:60},chipText:n,nodeFill:n,nodeStroke:r,text:r,edge:r,arrowFill:r,tokenOutsideFill:r,tokenOutsideStroke:n,tokenInside:n,tokenInsideStroke:n,tokenInsideBlend:Rf,tokenInsideAlpha:1,chipPillFill:r,chipPillText:n,chipHairline:{r:26,g:26,b:26,a:90},trailDot:r,wobble:!0,fontFamily:"Supermarker, Ilisarniq, ui-sans-serif, system-ui, sans-serif"};if(a==="Isometric")return{bg:o,bgTransparent:{r:0,g:0,b:0,a:0},bgDot:{r:214,g:218,b:224,a:255},shadowFill:o,shadowDot:u,chip:{r:255,g:235,b:130,a:255},chipShadow:{r:100,g:110,b:125,a:90},chipText:u,nodeFill:{r:236,g:239,b:244,a:255},nodeStroke:u,text:u,edge:s,arrowFill:s,tokenOutsideFill:u,tokenOutsideStroke:re,tokenInside:re,tokenInsideStroke:re,tokenInsideBlend:Uo,tokenInsideAlpha:1,chipPillFill:u,chipPillText:re,chipHairline:{r:60,g:66,b:78,a:90},trailDot:u,wobble:!1,fontFamily:"Ilisarniq, ui-sans-serif, system-ui, sans-serif"};g()}})(),sa=t=>e=>Tt(We(t.nodes))(n=>{const r=fe(n._1)(e.nodes);return r.tag==="Just"&&Zo(r._1).alpha>0?LN(n._2):[]}),rJ=t=>e=>n=>[1,t.vx,t.vy,2,t.vx+t.vw,t.vy,2,t.vx+t.vw,t.vy+t.vh,2,t.vx,t.vy+t.vh,5,...sa(e)(n)],iJ=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0(),i=rr.traverse(r);return o=>u=>{const s=Vn(u),a=.32*o.size;return i(c=>n.bind(c===0?r.pure(0):t.measureText(o)(me(c)(u)))(f=>n.bind(t.measureText(o)(me(c+1|0)(u)))(d=>n.bind(t.measureInk(o)(c>=0&&c<s.length?ro(s[c]):" "))(l=>r.pure({x:f,w:d-f,up:l.ascent-a,down:l.descent+a})))))(It(0,s.length-1|0))}},oJ=t=>e=>{const n=i=>(i.x-e.x)*(i.x-e.x)+(i.y-e.y)*(i.y-e.y),r=J(i=>o=>n(o)<n(i)?o:i)({x:t.x,y:t.y})([{x:t.x,y:t.y},{x:t.x+t.w,y:t.y},{x:t.x,y:t.y+t.h},{x:t.x+t.w,y:t.y+t.h}]);return H(i=>{const o=rt(i)/5;return{x:r.x+(e.x-r.x)*o,y:r.y+(e.y-r.y)*o}})([1,2,3,4])},aa=t=>{const e=_o(`
|
|
7
|
+
`)(t);return e.length===0?[""]:e},uJ=t=>e=>n=>r=>i=>o=>{const u={x:n.x+n.w/2,y:n.y+n.h/2},s={x:e.x+e.w/2,y:e.y+e.h/2},a=Hr(i)(o)(r),c=0<t.length?w("Just",t[0]):T,f=(()=>{if(c.tag==="Just")return c._1;if(c.tag==="Nothing")return s;g()})(),d=t.length-1|0,l=d>=0&&d<t.length?w("Just",t[d]):T,_=(()=>{if(l.tag==="Just")return l._1;if(l.tag==="Nothing")return u;g()})(),h=f.x-s.x,m=2*(()=>{const B=f.y-s.y;return(h<0?-h:h)+(B<0?-B:B)})(),p=_.x-u.x,y=2*(()=>{const B=_.y-u.y;return(p<0?-p:p)+(B<0?-B:B)})(),x=m+_i(t)+y,N=x<=1e-4?1:1-y/x,v=x<=1e-4?0:m/x,k=N-v,L=vr(t)(ou(0)(1)(k<=1e-4?0:(a-v)/k)),E=(()=>{if(L.tag==="Just")return L._1;if(L.tag==="Nothing")return f;g()})();return a<v?ra("InsideRect",Or(2)(e)):a>=N?ra("InsideRect",Or(2)(n)):ra("InsideBall",E,6)},sJ={offset:.8,passes:2,rMax:5},aJ=t=>{const e=t.Monad0().Applicative0(),n=rn(e);return r=>i=>o=>u=>{const s={color:u,width:1,lineJoin:Te,lineCap:fn},a={color:o,flat:!0},c=f=>t.drawRoundedRect({x:f.x,y:f.y,w:f.w,h:f.h})(4)(w("Just",a))(w("Just",s));return n(f=>{if(f._2.tag==="Travelling"){const d=mr(f._2._1.edge)(r.edges),l=fe(f._2._1.target)(r.nodes),_=fe(f._2._1.source)(r.nodes);if(_.tag==="Just"&&l.tag==="Just"&&d.tag==="Just"){const h=uJ((()=>{if(f._2._1.direction==="Forward")return d._1;if(f._2._1.direction==="Backward")return ke(d._1);g()})())(_._1)(l._1)(f._2._1.progress)(f._2._1.holdPre)(f._2._1.holdPost);if(h.tag==="InsideRect")return c(h._1);if(h.tag==="InsideBall")return t.fillStrokePath(Ko(h._1)(h._2))(a)(s);g()}return e.pure()}if(f._2.tag==="Filling"){const d=fe(f._2._1.node)(r.nodes);if(d.tag==="Just")return c(Or(2)(d._1));if(d.tag==="Nothing")return e.pure();g()}return e.pure()})(We(i.tokens))}},C_=t=>e=>n=>r=>t.strokePath((()=>{const i=Ft(o=>T,o=>u=>w("Just",{head:o,tail:u}),H(o=>o.pt)(nd(o=>u=>{const s=rt(u)/rt(72),a=ae(-.18)(.18)(o.prng),c=ae(-.1)(.1)(a.prng),f=ae(-.07)(.07)(c.prng),d=n*(.05+.55*s)*(1+c.value),l=s*28.274333882308138+a.value;return{prng:f.prng,pt:{x:e.x+Ke(l)*d+f.value*n,y:e.y+Oe(l)*d+f.value*n}}},{prng:137,pt:{x:e.x,y:e.y}},It(0,72))));if(i.tag==="Just")return[1,i._1.head.x,i._1.head.y,...jN(o=>[2,o.x,o.y])(i._1.tail)];if(i.tag==="Nothing")return[];g()})())({color:r,width:5.5,lineJoin:Te,lineCap:In}),cJ=t=>{const e=t.Monad0(),n=e.Bind1(),r=t.popAlpha,i=rn(e.Applicative0());return o=>u=>s=>i(a=>n.bind(t.pushAlpha(a.alpha))(()=>n.bind(t.strokePath(a.path)({color:o.nodeFill,width:a.width,lineJoin:Te,lineCap:In}))(()=>r)))(UN(y_(u)+7777|0)(u)(s))},S_=t=>{const e=t.Monad0(),n=e.Bind1(),r=t.popAlpha,i=e.Applicative0(),o=rn(i),u=rn(i),s=rr.traverse(i),a=iJ(t),c=cJ(t),f=t.popTransform;return d=>l=>_=>h=>m=>p=>y=>{const x=z=>n.bind(t.pushAlpha(z.alpha))(()=>n.bind(t.strokePath(z.path)({color:l.nodeStroke,width:2,lineJoin:Te,lineCap:In}))(()=>r)),N={family:l.fontFamily,size:l.wobble?15:11,weight:l.wobble?800:500},v=_o(`
|
|
8
|
+
`)(p.label===""?m:p.label),k=v.length===0?[""]:v,L=N.size*1.2,E=p.shape==="Cylinder"?t.strokePath(Vx({x:p.x,y:p.y,w:p.w,h:p.h}))({color:l.nodeStroke,width:1.25,lineJoin:Te,lineCap:fn}):i.pure(),B=(p.shape==="Cylinder"?(p.y+(p.y+p.h+5-2*nn(p.h*.075)(p.w*.075)))/2:(p.y+p.y+p.h)/2)-rt(k.length)*L/2+L/2,V=y.tag==="PloppingOut"&&l.wobble?y._1:-1,et=V>=0,D=Zo(y),S=et?{alpha:1,scale:1}:D,Z=p.x+p.w/2,X=p.y+p.h/2,W=n.bind(t.pushAlpha(S.alpha*_))(()=>n.bind(t.pushTransform({tx:Z*(1-S.scale),ty:X*(1-S.scale),sx:S.scale,sy:S.scale}))(()=>{const z={x:p.x,y:p.y,w:p.w,h:p.h},M={color:l.nodeStroke,width:l.wobble?2:1.25,lineJoin:Te,lineCap:l.wobble?In:fn};return n.bind((()=>{if(l.wobble){if(p.shape==="Rectangle")return o(x)(XN(N_)(y_(z))(z));const G=nu(7)(p);return n.bind(o(x)((()=>{const P=Mi(G);return G.length<4?[]:qr(m_)(P)(!0)(G)})()))(()=>u(P=>o(x)((()=>{const I=Mi(P);return P.length<2?[]:qr(m_)(I)(!1)(P)})()))(p.shape==="Cylinder"?[QN(p)]:[]))}return n.bind(e_(t)(p.shape)(z)(7)(w("Just",{color:l.nodeFill,flat:!1}))(w("Just",M)))(()=>E)})())(()=>n.bind((()=>{if(h.tag==="Just"&&l.wobble&&!et){const G=h._1;return n.bind(s(a(N))(k))(P=>{const I=Lt(nt=>U=>st.compare(nt.x)(U.x)),F=de(dn(p.x*7919+p.y*3001))*-1640531535|0,O=ae(5)(7.5)(F),Y=ae(0)(O.value)(O.prng),q=-(1+2*ae(-1)(1)(Y.prng).value*3.141592653589793/180),$=(nt,U,ut,ft,lt)=>I(xt(Nt=>Nt)([q*U+nt>=ft&&q*U+nt<=lt?w("Just",{x:U,y:q*U+nt}):T,q*ut+nt>=ft&&q*ut+nt<=lt?w("Just",{x:ut,y:q*ut+nt}):T,(()=>{const Nt=(ft-nt)/q;return Nt>=U&&Nt<=ut?w("Just",{x:Nt,y:ft}):T})(),(()=>{const Nt=(lt-nt)/q;return Nt>=U&&Nt<=ut?w("Just",{x:Nt,y:lt}):T})()])),R=O.value,tt=Yn(G.frameHash)(3),K=tt===0?{r:200,g:35,b:30,a:220}:tt===1?{r:35,g:150,b:80,a:220}:{r:30,g:80,b:200,a:220},gt=p.x+p.w/2,_t=Ae(Qt(nt=>U=>Qt((()=>{const ut=B+rt(nt)*L,ft=gt-J(lt=>Nt=>lt+Nt.w)(0)(U)/2;return lt=>Nt=>{const Ht=N.size*.1,Vt=lt-1|0,De=Vt>=0&&Vt<U.length&<>0?(U[Vt].x+U[Vt].w+Nt.x)/2:Nt.x-Ht;return{x:ft+De-1,y:ut-Nt.up-1,w:Bi(0)((()=>{const un=lt+1|0;return un>=0&&un<U.length&<<(U.length-1|0)?(Nt.x+Nt.w+U[un].x)/2-De:Nt.x+Nt.w+Ht-De})())+2,h:Nt.up+Nt.down+2}}})())(U))(P)),at=p.y+4,yt=p.x+p.w-4,Et=p.x+4,At=at-q*Et+Y.value,pt=p.y+p.h-4,Mt=Tt(Tt(Qt(nt=>U=>{const ut=(U.from.x+U.to.x)/2,ft=(U.from.y+U.to.y)/2,lt=ae(-1)(1)(F+(911*(nt+1|0)|0)|0),Nt=ae(-3)(5)(lt.prng),Ht=lt.value*3.141592653589793/180,Vt=Ke(Ht),De=Oe(Ht),un=Ne=>({x:ut+(Ne.x-ut)*Vt-(Ne.y-ft)*De,y:ft+(Ne.x-ut)*De+(Ne.y-ft)*Vt});return{from:(()=>{const Ne=un(U.from),Ct=Ne.y-ft,Pt=Ne.x-ut,je=Ee(Pt*Pt+Ct*Ct),Ze=je<1e-4?1:(je+Nt.value)/je;return{x:ut+Pt*Ze,y:ft+Ct*Ze}})(),to:(()=>{const Ne=un(U.to),Ct=ae(-3)(5)(Nt.prng).value,Pt=Ne.y-ft,je=Ne.x-ut,Ze=Ee(je*je+Pt*Pt),kn=Ze<1e-4?1:(Ze+Ct)/Ze;return{x:ut+je*kn,y:ft+Pt*kn}})()}})(xt(nt=>{const U=$(At+rt(nt)*R,Et,yt,at,pt);return U.length===2?w("Just",{from:U[0],to:U[1]}):T})(It(0,uu(1)(de(dn((pt-q*yt-At)/R)))))))(nt=>ct(U=>U.to.x-U.from.x>1,J(U=>ut=>Tt(U)(ft=>{const lt=$(ft.from.y-q*ft.from.x,ut.x,ut.x+ut.w,ut.y,ut.y+ut.h);return lt.length===2?lt[0].x>ft.from.x+.001&<[1].x<ft.to.x-.001?[{from:ft.from,to:lt[0]},{from:lt[1],to:ft.to}]:lt[0].x<=ft.from.x+.001&<[1].x<ft.to.x-.001?[{from:lt[1],to:ft.to}]:lt[0].x>ft.from.x+.001&<[1].x>=ft.to.x-.001?[{from:ft.from,to:lt[0]}]:[]:[ft]}))([nt])(_t))))(nt=>(()=>{const U=nt.to.x-nt.from.x;return Ee(2)*(U>=0?U:-U)<=28})()?[nt]:[{from:nt.from,to:{x:nt.from.x+(nt.to.x-nt.from.x)*.495,y:nt.from.y+(nt.to.y-nt.from.y)*.495}},{from:{x:nt.from.x+(nt.to.x-nt.from.x)*.505,y:nt.from.y+(nt.to.y-nt.from.y)*.505},to:nt.to}]),Jt=Mt.length,mt=nt=>Bi(0)(w_(1)(G.t*rt(Jt)-rt(nt)));return o(nt=>{const U=nt._1,ut=ae(1.4)(1.9)(F+(1303*(U+1|0)|0)|0),ft=ae(.35)(.8)(ut.prng),lt=o(Nt=>n.bind(t.pushAlpha(Nt.alpha*ft.value))(()=>n.bind(t.strokePath(x_(mt(U))(Nt.path))({color:K,width:ut.value,lineJoin:Te,lineCap:In}))(()=>r)))(qr({...N_,rMax:0,offset:.5})(F+(53*(U+1|0)|0)|0)(!1)([nt._2.from,nt._2.to]));return mt(U)>0?lt:i.pure()})(Qt(Hn)(Mt))})}return i.pure()})())(()=>n.bind((()=>{if(d==="LabelsShown")return o(G=>t.drawText({x:p.x+p.w/2,y:B+rt(G._1)*L,content:G._2,font:N,color:l.text,align:Xo,baseline:Wr}))(Qt(Hn)(k));if(d==="LabelsHidden")return i.pure();g()})())(()=>n.bind((()=>{const G=c(l)(z)(V);return et?G:i.pure()})())(()=>n.bind(f)(()=>r)))))}));return S.alpha*_>0?W:i.pure()}},gJ=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),i=S_(t),o=t.popAlpha,u=rn(n);return s=>a=>c=>{const f={...s,nodeFill:s.text,text:s.nodeFill,nodeStroke:s.nodeFill};return u(d=>{const l=fe(d._1)(c.nodes),_=fe(d._1)(a.nodes),h=(()=>{if(_.tag==="Just"&&l.tag==="Just"){const m=l._1,p=_._1;return r.bind(t.pushAlpha(d._2))(()=>r.bind(i(oa)(f)(1)(T)(d._1)(p)(m))(()=>o))}return n.pure()})();return d._2>0?h:n.pure()})(We(c.nodeInvert))}},D_=t=>{const e=t.Monad0().Bind1();return n=>r=>i=>o=>r?e.bind(t.clearBackground(n.bgTransparent))(()=>t.setViewport(o)):n.wobble?e.bind(t.setViewport(o))(()=>t.clearBackground(n.bg)):e.bind(t.setViewport(o))(()=>t.backgroundDots({viewport:o,bgColor:n.bg,dotColor:n.bgDot,tile:12*i,dotRadius:.7*i}))},fJ=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),i=t.popAlpha;return o=>u=>s=>a=>c=>f=>d=>l=>_=>{const h=(()=>{if(_>1e-4&&d>1-_){const p=(1-d)/_;return p<0?0:p>1?1:p}if(l>1e-4&&d<l){const p=d/l;return p<0?0:p>1?1:p}return 1})(),m=E_(a)(c)(f)(d)(l)(_);if(m.tag==="CircleShape")return o?C_(t)(m._1)(m._2)({r:200,g:35,b:30,a:220}):t.fillStrokePath(Ko(m._1)(m._2))({color:u,flat:!0})({color:s,width:1,lineJoin:Te,lineCap:fn});if(m.tag==="PolyShape"&&o&&m._1.length>=3)return r.bind(t.pushAlpha(h))(()=>r.bind(C_(t)(l_(m._1))(6)({r:200,g:35,b:30,a:220}))(()=>i));if(m.tag==="PolyShape")return o?n.pure():m._1.length>=3?t.fillStrokePath(__(m._1))({color:u,flat:!0})({color:s,width:1,lineJoin:Te,lineCap:fn}):n.pure();g()}},_J=t=>{const e=t.Monad0().Bind1(),n=t.popAlpha;return r=>i=>o=>u=>s=>a=>c=>{const f=Hr(a)(c)(s),d={x:o.x+o.w/2,y:o.y+o.h/2},l={x:u.x+u.w/2,y:u.y+u.h/2},_=(h,m)=>e.bind(t.pushAlpha(m))(()=>e.bind(t.fillStrokePath(Ko(h)(6))({color:r,flat:!0})({color:i,width:1,lineJoin:Te,lineCap:fn}))(()=>n));return f<.5?_(d,(()=>{const h=f*2;return 1-(h<0?0:h>1?1:h)*(h<0?0:h>1?1:h)*(h<0?3:h>1?1:3-2*h)})()):_(l,(()=>{const h=(f-.5)*2;return(h<0?0:h>1?1:h)*(h<0?0:h>1?1:h)*(h<0?3:h>1?1:3-2*h)})())}},su=t=>{const e=fJ(t),n=_J(t),r=t.Monad0().Applicative0(),i=rn(r);return o=>u=>s=>a=>c=>i(f=>{if(f._2.tag==="Travelling"){const d=fe(f._2._1.target)(u.nodes),l=fe(f._2._1.source)(u.nodes);if(l.tag==="Just"&&d.tag==="Just"){const _=mr(f._2._1.edge)(u.edges);if(_.tag==="Just")return e(o)(a)(c)((()=>{if(f._2._1.direction==="Forward")return _._1;if(f._2._1.direction==="Backward")return ke(_._1);g()})())(l._1)(d._1)(f._2._1.progress)(f._2._1.holdPre)(f._2._1.holdPost);if(_.tag==="Nothing")return n(a)(c)(l._1)(d._1)(f._2._1.progress)(f._2._1.holdPre)(f._2._1.holdPost);g()}return r.pure()}if(f._2.tag==="Filling"){if(o)return r.pure();const d=fe(f._2._1.node)(u.nodes);if(d.tag==="Just")return t.fillStrokePath(__(nu(4)(Or(2)(d._1))))({color:a,flat:!0})({color:c,width:1,lineJoin:Te,lineCap:fn});if(d.tag==="Nothing")return r.pure();g()}return r.pure()})(We(s.tokens))},P_=t=>{const e=su(t),n=t.Monad0(),r=n.Bind1(),i=su(t),o=aJ(t),u=t.popClip,s=t.popBlend,a=t.popLayer,c=n.Applicative0(),f=rn(c),d=t.popAlpha;return l=>_=>h=>m=>{const p=_.wobble?e(!0)(h)(m)(_.tokenInside)(_.tokenInsideStroke):r.bind(t.insideTokenStyle(l))(y=>{if(y==="GenieSilhouette")return i(!1)(h)(m)(_.tokenInside)(_.tokenInsideStroke);if(y==="ConvexAbsorb")return o(h)(m)(_.tokenInside)(_.tokenInsideStroke);g()});if(_.tokenInsideBlend==="Difference")return r.bind(t.pushLayer(Px))(()=>r.bind(t.pushBlend(Uo))(()=>r.bind(t.pushClip(sa(h)(m))(js))(()=>r.bind(p)(()=>r.bind(u)(()=>r.bind(s)(()=>r.bind(a)(()=>r.bind(t.pushLayer(Ix))(()=>r.bind(f(y=>{const x=fe(y._1)(m.nodes);return x.tag==="Just"&&Zo(x._1).alpha>0?e_(t)(y._2.shape)({x:y._2.x,y:y._2.y,w:y._2.w,h:y._2.h})(7)(w("Just",{color:re,flat:!1}))(T):c.pure()})(We(h.nodes)))(()=>a)))))))));if(_.tokenInsideBlend==="Normal")return r.bind(t.pushClip(sa(h)(m))(js))(()=>r.bind(t.pushAlpha(_.tokenInsideAlpha))(()=>r.bind(p)(()=>r.bind(d)(()=>u))));g()}},I_=t=>{const e=t.Monad0().Bind1(),n=su(t),r=su(t),i=t.popClip,o=t.popLayer;return u=>s=>a=>c=>e.bind(t.pushLayer(Dx))(()=>e.bind(t.pushClip(rJ(s)(a)(c))(Fx))(()=>e.bind(u.wobble?n(!0)(a)(c)(u.tokenOutsideFill)(u.tokenOutsideStroke):r(!1)(a)(c)(u.tokenOutsideFill)(u.tokenOutsideStroke))(()=>e.bind(i)(()=>o))))},dJ=t=>{const e=t.Monad0(),n=e.Bind1(),r=e.Applicative0(),i=rn(r);return o=>u=>s=>a=>c=>f=>{const d=po(f).length,l=rt(d+1|0),_=p=>{const y=(s*l-rt(p))/1.5,x=y<0?0:y>1?1:y;return x*x*(3-2*x)},h=(p=>{let y=p,x=!0,N;for(;x;){const v=y;if(v>=d){x=!1,N=v;continue}if(_(v)>=1){y=v+1|0;continue}x=!1,N=v}return N})(0),m=h>=d?[]:or(p=>_(p)>0)(It(h,d-1|0)).init;return n.bind((()=>{const p=t.drawText({x:a,y:c,content:me(h)(f),font:o,color:u,align:Us,baseline:Wr});return h>0?p:r.pure()})())(()=>i(p=>n.bind(t.measureText(o)(me(p)(f)))(y=>{const x=_(p);return t.drawText({x:a+y,y:c-(1-x)*10,content:me(1)(ci(Xn(me(p)(f)))(f)),font:o,color:{...u,a:de(dn(x*rt(u.a)))},align:Us,baseline:Wr})}))(m))}},au=t=>e=>n=>r=>{const i=H(_=>rt(uu(1)(po(_).length)))(r),o=Bi(1)(J(Tr)(0)(i)),u=Hr(e)(n)(t),s=u*o,a=uu(1)(r.length),c=(_=>h=>m=>{let p=_,y=h,x=m,N=!0,v;for(;N;){const k=p,L=y,E=Ft(B=>T,B=>V=>w("Just",{head:B,tail:V}),x);if(E.tag==="Nothing"){N=!1,v=uu(0)(a-1|0);continue}if(E.tag==="Just"){if(L+E._1.head>=s){N=!1,v=k;continue}p=k+1|0,y=L+E._1.head,x=E._1.tail;continue}g()}return v})(0)(0)(i),f=J(Tr)(0)(c<1?[]:bt(0,c,i)),d=f/o;if(c>=0&&c<i.length){const _=(f+i[c])/o;return{line:c>=0&&c<r.length?r[c]:"",phaseInLabel:(()=>{if(_<=d)return 1;const h=(u-d)/(_-d);return h<0?0:h>1?1:h})()}}const l=(f+1)/o;return{line:c>=0&&c<r.length?r[c]:"",phaseInLabel:(()=>{if(l<=d)return 1;const _=(u-d)/(l-d);return _<0?0:_>1?1:_})()}},lJ=t=>{const e=t.Monad0();return n=>r=>i=>e.Bind1().bind(t.measureText({family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:500})(au(r)(0)(0)(H(U1)(i)).line))(o=>{const u=o+28;return e.Applicative0().pure({x:n.x+n.w/2-u/2,y:n.y-25.2-14,w:u,h:25.2})})},hJ=t=>{const e=t.Monad0(),n=e.Bind1(),r=lJ(t),i=e.Applicative0(),o=rr.traverse(i);return u=>s=>n.Apply0().Functor0().map(a=>L_(xt(c=>c)(a)))(o(a=>{if(a._2.tag==="Filling"&&a._2._1.labels.length!==0){const c=fe(a._2._1.node)(u.nodes);if(c.tag==="Just")return n.bind(r(c._1)(a._2._1.progress)(a._2._1.labels))(f=>i.pure(w("Just",b(a._1,f))));if(c.tag==="Nothing")return i.pure(T);g()}return i.pure(T)})(We(s.tokens)))},pJ=t=>{const e=t.Monad0();return n=>r=>i=>o=>u=>s=>a=>{const c=G_(n)(r)(i)(o)(u)(s);return e.Bind1().bind(t.measureText({family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:11,weight:500})(au(o)(u)(s)(Tt(a)(aa)).line))(f=>e.Applicative0().pure({x:c.x+14+f/2-f/2-14,y:c.y-6-8-6.6-6,w:f+28,h:25.2}))}},mJ=t=>{const e=t.Monad0(),n=e.Bind1(),r=pJ(t),i=e.Applicative0(),o=rr.traverse(i);return u=>s=>n.Apply0().Functor0().map(a=>L_(xt(c=>c)(a)))(o(a=>{if(a._2.tag==="Travelling"&&a._2._1.labels.length!==0){const c=fe(a._2._1.target)(u.nodes),f=fe(a._2._1.source)(u.nodes),d=mr(a._2._1.edge)(u.edges);if(d.tag==="Just"&&f.tag==="Just"&&c.tag==="Just")return n.bind(r((()=>{if(a._2._1.direction==="Forward")return d._1;if(a._2._1.direction==="Backward")return ke(d._1);g()})())(f._1)(c._1)(a._2._1.progress)(a._2._1.holdPre)(a._2._1.holdPost)(a._2._1.labels))(l=>i.pure(w("Just",b(a._1,l))))}return i.pure(T)})(We(s.tokens)))},ca=t=>{const e=t.Monad0(),n=e.Bind1(),r=mJ(t),i=hJ(t);return o=>u=>n.bind(r(o)(u))(s=>n.bind(i(o)(u))(a=>e.Applicative0().pure(nJ((()=>{const c=f=>{if(f.tag==="Leaf")return Q;if(f.tag==="Node")return Wt("Node",f._1,f._2,f._3,void 0,c(f._5),c(f._6));g()};return Lt(C.compare)(kt(Re.foldr,c(s)))})())(s)([...xt(c=>{const f=fe(c._1)(u.nodes);return f.tag==="Just"&&Zo(f._1).alpha>0?w("Just",{x:c._2.x,y:c._2.y,w:c._2.w,h:c._2.h}):T})(We(o.nodes)),...(()=>{const c=(f,d)=>{if(f.tag==="Leaf")return d;if(f.tag==="Node")return c(f._5,Ot("Cons",f._4,c(f._6,d)));g()};return kt($t.foldr,c(a,qt))})()]))))},Q_=t=>e=>n=>{const r=pi(6)(.55)(ou(0)(1)((1-t)/.06)),i=t>.94,o=i&&n>1e-4,u=pi(6)(.55)(ou(0)(1)(t/.06)),s=t<.06,a=s&&e>1e-4,c=i&&n<=1e-4;return{popScale:a?u:o?r:1,flipY:s&&e<=1e-4?u:c?r:1,fadeAlpha:(()=>{if(a){const f=t/.06;return f<0?.55:f>1?1:.55+.44999999999999996*f}if(o){const f=(1-t)/.06;return f<0?.55:f>1?1:.55+.44999999999999996*f}return 1})()}},yJ=t=>{const e=t.Monad0().Bind1(),n=k_(t);return r=>i=>o=>u=>s=>{const a=Q_(u)(0)(0),c={family:r.fontFamily,size:11,weight:500},f=au(u)(0)(0)(Tt(s)(aa));return e.bind(t.measureText(c)(f.line))(d=>{const l=o.x+o.w/2,_=d+28,h=o.y-25.2-14,m=l-_/2,p=[1,l,h+25.2,2,l,o.y],y={x:l,y:h+12.6};return n(a)(l-_/2)(h+25.2)(y)(e.bind(t.drawRoundedRect({x:l-_/2,y:h+1.5,w:_,h:25.2})(6)(w("Just",{color:r.chipShadow,flat:!0}))(T))(()=>e.bind(t.drawRoundedRect({x:m,y:h,w:_,h:25.2})(6)(w("Just",{color:r.chip,flat:!0}))(w("Just",{color:r.chipHairline,width:1,lineJoin:Te,lineCap:fn})))(()=>e.bind(t.strokePath(p)({color:r.chipHairline,width:1,lineJoin:Te,lineCap:fn}))(()=>t.drawText({x:l,y:y.y,content:f.line,font:c,color:r.chipText,align:Xo,baseline:Wr})))))})}},xJ=t=>{const e=k_(t),n=t.Monad0(),r=n.Bind1(),i=rn(n.Applicative0()),o=dJ(t);return u=>s=>a=>c=>f=>d=>l=>_=>h=>{const m=au(f)(d)(l)(Tt(_)(aa)),p=m.line,y=m.phaseInLabel/.45,x=y<0?0:y>1?1:y,N=h.w,v=h.y,k=h.x,L=k+14,E=h.h,B=v+E/2;return e(Q_(f)(d)(l))(k)(v+E)({x:k+N/2,y:B})(r.bind(i(V=>t.fillPath(Ko(V)(1.5))({color:u.trailDot,flat:!0}))(oJ(h)(G_(s)(a)(c)(f)(d)(l))))(()=>r.bind(t.drawRoundedRect({x:k,y:v,w:N,h:E})(3)(w("Just",{color:u.chipPillFill,flat:!0}))(T))(()=>o({family:u.fontFamily,size:11,weight:500})(u.chipPillText)(x)(L)(B)(p))))}},ga=t=>{const e=xJ(t),n=t.Monad0(),r=n.Applicative0(),i=yJ(t),o=n.Bind1(),u=rn(r),s=t.popLayer;return a=>c=>f=>d=>o.bind(t.pushLayer(Qx))(()=>o.bind(u(l=>{if(l._2.tag==="Travelling"){if(l._2._1.labels.length!==0){const _=fe(l._2._1.target)(c.nodes),h=fe(l._2._1.source)(c.nodes),m=mr(l._2._1.edge)(c.edges),p=b_(l._1)(d);if(p.tag==="Just"&&m.tag==="Just"&&h.tag==="Just"&&_.tag==="Just")return e(a)((()=>{if(l._2._1.direction==="Forward")return m._1;if(l._2._1.direction==="Backward")return ke(m._1);g()})())(h._1)(_._1)(l._2._1.progress)(l._2._1.holdPre)(l._2._1.holdPost)(l._2._1.labels)(p._1)}return r.pure()}if(l._2.tag==="Filling"&&l._2._1.labels.length!==0){const _=fe(l._2._1.node)(c.nodes);if(_.tag==="Just")return i(a)(c)(_._1)(l._2._1.progress)(l._2._1.labels);if(_.tag==="Nothing")return r.pure();g()}return r.pure()})(We(f.tokens)))(()=>s))},F_=t=>{const e=ca(t),n=ga(t);return r=>i=>o=>t.Monad0().Bind1().bind(e(i)(o))(u=>n(r)(i)(o)(u))},NJ=t=>{const e=t.Monad0(),n=e.Applicative0();return r=>i=>{const o=i.length-1|0,u=o<1?[]:bt(0,o,i),s=u.length-1|0,a=s>=0&&s<u.length?w("Just",u[s]):T,c=i.length-1|0,f=c>=0&&c<i.length?w("Just",i[c]):T;if(f.tag==="Just"&&a.tag==="Just"){const d=ae(.78)(1.18)(Mi(i)+19|0),l=ae(.4)(.62)(d.prng),_=r.wobble?8.75*l.value:4.375,h=ae(.4)(.62)(l.prng),m=r.wobble?8.75*h.value:4.375,p=f._1.y-a._1.y,y=f._1.x-a._1.x,x=Ee(y*y+p*p),N=p/x,v=-N,k=y/x,L=f._1.x+k*.875,E=f._1.y+N*.875,B=r.wobble?8.75*d.value:8.75,V=L-k*B,et=E-N*B,D=V+v*_,S=et+k*_,Z=[1,L,E,2,V+v*4.375,et+k*4.375,2,V-v*4.375,et-k*4.375,5],X=V-v*m,W=et-k*m,z={color:r.arrowFill,width:2,lineJoin:Te,lineCap:In};return x<=1e-4?n.pure():r.wobble?e.Bind1().bind(t.strokePath([1,D,S,2,L,E])(z))(()=>t.strokePath([1,X,W,2,L,E])(z)):t.fillPath(Z)({color:r.arrowFill,flat:!0})}return n.pure()}},JJ=t=>{const e=t.Monad0(),n=e.Applicative0(),r=e.Bind1(),i=rn(n),o=t.popAlpha,u=NJ(t);return s=>a=>c=>f=>{const d=GN(8)(c);if(f.hi<=f.lo)return n.pure();const l=AN(d)(f.lo)(f.hi);if(l.length===0)return n.pure();const _={color:s.edge,width:s.wobble?2:.9375,lineJoin:Te,lineCap:In},h=s.wobble?ae(-10)(4)(Mi(l)).value:0,m=s.wobble?ON(h)(l):l;return r.bind(s.wobble?i(p=>r.bind(t.pushAlpha(p.alpha))(()=>r.bind(t.strokePath(p.path)(_))(()=>o)))((()=>{const p=Mi(l);return m.length<2?[]:qr(sJ)(p)(!1)(m)})()):t.strokePath(bN(l))(_))(()=>{const p=u(s)(m);return f.hi>=.999?p:n.pure()})}},A_=t=>{const e=JJ(t),n=t.Monad0().Applicative0(),r=rn(n);return i=>o=>u=>r(s=>{const a=mr(s._1)(u.edges);if(a.tag==="Just")return e(i)(s._1)(s._2)((()=>{if(a._1.tag==="Retracted")return{lo:0,hi:0};if(a._1.tag==="Extended")return{lo:0,hi:1};if(a._1.tag==="Extending")return{lo:0,hi:a._1._2};if(a._1.tag==="Retracting"){if(a._1._1==="FromSource")return{lo:a._1._2,hi:1};if(a._1._1==="FromTarget")return{lo:0,hi:1-a._1._2};if(a._1._1==="FromBoth")return{lo:a._1._2/2,hi:1-a._1._2/2}}g()})());if(a.tag==="Nothing")return n.pure();g()})(We(o.edges))},TJ=t=>e=>{const n=o=>{const u=fe(o)(t.nodes);if(u.tag==="Nothing")return!1;if(u.tag==="Just"){const s=u._1;return!Me(a=>0<a._2.length&&a._2[0].x>=s.x&&a._2[0].x<=s.x+s.w&&a._2[0].y>=s.y&&a._2[0].y<=s.y+s.h,We(t.edges))}g()},r=J(o=>u=>(o*31|0)+Cn(u)|0)(5381)(Vn(e.frameTitle)),i=o=>{const u=fe(o)(t.nodes);if(u.tag==="Nothing")return!1;if(u.tag==="Just"){const s=u._1;return!Me(a=>{const c=a._2.length-1|0;return c>=0&&c<a._2.length&&a._2[c].x>=s.x&&a._2[c].x<=s.x+s.w&&a._2[c].y>=s.y&&a._2[c].y<=s.y+s.h},We(t.edges))}g()};return J(o=>u=>{const s=u._2;return ZN(a=>{if(a.tag==="Nothing")return w("Just",s);if(a.tag==="Just")return w("Just",{t:Bi(a._1.t)(s.t),angle:s.t>=a._1.t?s.angle:a._1.angle,bigCircle:a._1.bigCircle||s.bigCircle,frameHash:a._1.frameHash});g()})(u._1)(o)})(Q)(Tt(We(e.tokens))(o=>{if(o._2.tag==="Filling"){const u=o._2._1.node;return[b(u,{t:1,angle:(()=>{const s=xt(a=>(()=>{const c=fe(u)(t.nodes),f=a._2.length-1|0;return f>=0&&f<a._2.length&&c.tag==="Just"&&a._2[f].x>=c._1.x&&a._2[f].x<=c._1.x+c._1.w&&a._2[f].y>=c._1.y&&a._2[f].y<=c._1.y+c._1.h})()?w("Just",a._2):T)(We(t.edges));if(0<s.length){const a=s[0].length-1|0,c=a<1?[]:bt(0,a,s[0]),f=c.length-1|0;if(f>=0&&f<c.length){const d=s[0].length-1|0;return d>=0&&d<s[0].length?ur(s[0][d].y-c[f].y)(s[0][d].x-c[f].x):0}s[0].length-1|0}return 0})(),bigCircle:n(u)||i(u),frameHash:r})]}if(o._2.tag==="Travelling"){if(o._2._1.progress>=.75)return[b(o._2._1.target,{t:(o._2._1.progress-.75)/.25,angle:(()=>{const u=mr(o._2._1.edge)(t.edges);if(u.tag==="Just"){const s=u._1.length-1|0,a=s<1?[]:bt(0,s,u._1),c=a.length-1|0;if(c>=0&&c<a.length){const f=u._1.length-1|0;return f>=0&&f<u._1.length?ur(u._1[f].y-a[c].y)(u._1[f].x-a[c].x):0}return u._1.length-1|0,0}if(u.tag==="Nothing")return 0;g()})(),bigCircle:n(o._2._1.target)||i(o._2._1.target),frameHash:r})];if(o._2._1.progress<.25)return[b(o._2._1.source,{t:o._2._1.progress/.25,angle:(()=>{const u=mr(o._2._1.edge)(t.edges);if(u.tag==="Just")return 1<u._1.length&&0<u._1.length?ur(u._1[1].y-u._1[0].y)(u._1[1].x-u._1[0].x):0;if(u.tag==="Nothing")return 0;g()})(),bigCircle:n(o._2._1.source)||i(o._2._1.source),frameHash:r})]}return[]}))},vJ=t=>J(e=>n=>(e*31|0)+Cn(n)|0)(5381)(Vn(t.frameTitle)),M_=t=>{const e=S_(t),n=t.Monad0().Applicative0(),r=rn(n);return i=>o=>u=>s=>{const a=vJ(s),c=TJ(u)(s);return r(f=>{const d=fe(f._1)(s.nodes);if(d.tag==="Just")return e(i)(o)((()=>{const l=fe(f._1)(s.nodeFadeAlpha);if(l.tag==="Nothing")return 1;if(l.tag==="Just")return l._1;g()})())((()=>{const l=fe(f._1)(c);return l.tag==="Just"?w("Just",l._1):l.tag==="Nothing"&&KN(f._1)(s.visited)?w("Just",{t:1,angle:0,bigCircle:!1,frameHash:a}):T})())(f._1)(f._2)(d._1);if(d.tag==="Nothing")return n.pure();g()})(We(u.nodes))}},B_=t=>t,z_=t=>e=>{const n=e.vw/e.vh,r=e.vh*t,i={...e,vx:e.vx-(r-e.vw)/2,vw:r},o=e.vw/t,u={...e,vy:e.vy-(o-e.vh)/2,vh:o};return t<=0||e.vw<=0||e.vh<=0?e:t>n?i:t<n?u:e},wJ=t=>e=>n=>{const r=it.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=it.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},R_=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},W_=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},fa=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},bJ=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},LJ=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},kJ=t=>e=>{const n=Oe(t.angle),r=Ke(t.angle);return{a:r,b:n,c:0,d:1,e:-e*r,f:e*n-t.boxHeight/2}},EJ=t=>[t.box.ground.a,t.box.ground.b,t.box.ground.c,t.box.ground.d,t.box.top.a,t.box.top.b,t.box.top.c,t.box.top.d],$r=t=>e=>{const n=r=>wJ(0)(255)(de($n(rt(r)*t)));return{r:n(e.r),g:n(e.g),b:n(e.b),a:e.a}},Ce=t=>e=>n=>r=>({x:(e-n)*Ke(t.angle),y:(e+n)*Oe(t.angle)-r}),yr=t=>{const e=Ft(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Tt(e._1.tail)(n=>[2,n.x,n.y]),5];g()},GJ=t=>e=>n=>r=>i=>{const o=(()=>{if(t==="Forward")return i;if(t==="Backward")return ke(i);g()})();if(0<o.length){const s=vr(o)(R_(0)(1)(Hr(n)(r)(e)));if(s.tag==="Nothing")return o[0];if(s.tag==="Just")return s._1;g()}const u=vr(o)(R_(0)(1)(Hr(n)(r)(e)));if(u.tag==="Nothing")return{x:0,y:0};if(u.tag==="Just")return u._1;g()},CJ=t=>{const e=Ft(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return[];if(e.tag==="Just")return[1,e._1.head.x,e._1.head.y,...Tt(e._1.tail)(n=>[2,n.x,n.y])];g()},SJ=t=>{const e=Ft(n=>T,n=>r=>w("Just",{head:n,tail:r}),t);if(e.tag==="Nothing")return{vx:0,vy:0,vw:0,vh:0};if(e.tag==="Just"){const n=J(r=>i=>({minX:W_(r.minX)(i.x),minY:W_(r.minY)(i.y),maxX:fa(r.maxX)(i.x),maxY:fa(r.maxY)(i.y)}))({minX:e._1.head.x,minY:e._1.head.y,maxX:e._1.head.x,maxY:e._1.head.y})(e._1.tail);return{vx:n.minX-40,vy:n.minY-40,vw:n.maxX-n.minX+80,vh:n.maxY-n.minY+80}}g()},DJ=t=>{const e=t.Monad0().Bind1();return n=>r=>i=>{const o=i.box,u=i.np,s={color:r.nodeStroke,width:1,lineJoin:Te,lineCap:fn};return e.bind(t.fillStrokePath(yr([o.ground.d,o.ground.c,o.top.c,o.top.d]))({color:$r(.66)(r.nodeFill),flat:!0})(s))(()=>e.bind(t.fillStrokePath(yr([o.ground.b,o.ground.c,o.top.c,o.top.b]))({color:$r(.82)(r.nodeFill),flat:!0})(s))(()=>e.bind(t.fillStrokePath(yr([o.top.a,o.top.b,o.top.c,o.top.d]))({color:$r(1)(r.nodeFill),flat:!0})(s))(()=>t.drawTextAffine(kJ(n)(u.y+u.h))({x:u.x+u.w/2,y:0,content:u.label,font:{family:r.fontFamily,size:11,weight:600},color:r.text,align:Xo,baseline:Wr}))))}},PJ=t=>{const e=t.Monad0().Bind1();return n=>r=>i=>o=>{const u={color:r.tokenOutsideStroke,width:1,lineJoin:Te,lineCap:fn},s=o.x-5.5,a=o.x+5.5,c=o.y-5.5,f=o.y+5.5,d=i+11,l=Ce(n)(s)(c)(d),_=Ce(n)(a)(c)(d),h=Ce(n)(a)(f)(d),m=Ce(n)(s)(f)(d),p=Ce(n)(a)(f)(i),y=Ce(n)(a)(c)(i);return e.bind(t.fillStrokePath(yr([Ce(n)(s)(f)(i),p,h,m]))({color:$r(.66)(r.tokenOutsideFill),flat:!0})(u))(()=>e.bind(t.fillStrokePath(yr([y,p,h,_]))({color:$r(.82)(r.tokenOutsideFill),flat:!0})(u))(()=>t.fillStrokePath(yr([l,_,h,m]))({color:$r(1)(r.tokenOutsideFill),flat:!0})(u)))}},IJ=t=>{const e=PJ(t);return n=>r=>i=>o=>{if(o.tag==="Travelling"){const u=bJ(o._1.edge)(i.edges);return u.tag==="Just"?w("Just",(()=>{const s=GJ(o._1.direction)(o._1.progress)(o._1.holdPre)(o._1.holdPost)(u._1);return{depth:s.x+s.y,draw:e(n)(r)(0)(s)}})()):T}if(o.tag==="Filling"){const u=LJ(o._1.node)(i.nodes);if(u.tag==="Just")return w("Just",(()=>{const s={x:u._1.x+u._1.w/2,y:u._1.y+u._1.h/2};return{depth:s.x+s.y,draw:e(n)(r)(n.boxHeight)(s)}})())}return T}},QJ={angle:.5235987755982988,boxHeight:26,transparentBg:!0},FJ=t=>e=>{const n=e.y+e.h,r=e.x+e.w;return{ground:{a:Ce(t)(e.x)(e.y)(0),b:Ce(t)(r)(e.y)(0),c:Ce(t)(r)(n)(0),d:Ce(t)(e.x)(n)(0)},top:{a:Ce(t)(e.x)(e.y)(t.boxHeight),b:Ce(t)(r)(e.y)(t.boxHeight),c:Ce(t)(r)(n)(t.boxHeight),d:Ce(t)(e.x)(n)(t.boxHeight)},depth:(e.x+r)/2+(e.y+n)/2}},H_=t=>e=>H(n=>({np:n,box:FJ(t)(n)}))((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return kt($t.foldr,n(e.nodes,qt))})()),AJ=t=>e=>[...Tt(H_(t)(e))(EJ),...(()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._4,n(r._6,i)));g()};return Tt(kt($t.foldr,n(e.edges,qt)))(H(r=>Ce(t)(r.x)(r.y)(0)))})()],MJ=t=>{const e=t.to.y-t.from.y,n=t.to.x-t.from.x,r=fa(1e-4)(Ee(n*n+e*e)),i=e/r,o=n/r,u=t.to.y-i*7,s=t.to.x-o*7;return yr([t.to,{x:s-i*3,y:u+o*3},{x:s+i*3,y:u-o*3}])},BJ=t=>{const e=t.Monad0(),n=e.Applicative0();return r=>i=>o=>u=>s=>{const a=Ce(r)(s.x)(s.y)(0),c=Ce(r)(u.x)(u.y)(0);return e.Bind1().bind(t.strokePath(CJ([c,a]))({color:i.edge,width:1.5,lineJoin:Te,lineCap:In}))(()=>{const f=t.fillPath(MJ({from:c,to:a}))({color:i.arrowFill,flat:!0});return o?f:n.pure()})}},zJ=t=>{const e=BJ(t);return n=>r=>i=>{const o=Je(Hn,i,bt(1,i.length,i)),u=o.length-1|0;return Qt(s=>a=>({depth:(a._1.x+a._1.y+a._2.x+a._2.y)/2,draw:e(n)(r)(s===u)(a._1)(a._2)}))(o)}},RJ=t=>{const e=DJ(t),n=IJ(t),r=zJ(t),i=t.Monad0(),o=D_(t),u=Nu(i.Applicative0())(Bt);return s=>a=>c=>f=>{const d=ua(a),l=[...(()=>{const _=(h,m)=>{if(h.tag==="Leaf")return m;if(h.tag==="Node")return _(h._5,Ot("Cons",h._4,_(h._6,m)));g()};return Tt(kt($t.foldr,_(c.edges,qt)))(r(s)(d))})(),...H(_=>({depth:_.box.depth,draw:e(s)(d)(_)}))(H_(s)(c)),...xt(n(s)(d)(c))((()=>{const _=(h,m)=>{if(h.tag==="Leaf")return m;if(h.tag==="Node")return _(h._5,Ot("Cons",h._4,_(h._6,m)));g()};return kt($t.foldr,_(f.tokens,qt))})())];return i.Bind1().bind(o(d)(s.transparentBg)(1)(SJ(AJ(s)(c))))(()=>u(_=>_.draw)(Lt(_=>h=>st.compare(_.depth)(h.depth))(l)))}},O_=(t,e)=>({tag:t,_1:e}),WJ=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},HJ=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},OJ=O_("ResolvedLabels"),qJ=t=>{const e=Zt(n=>n.role==="FlyThrough")(t.levels);if(e.tag==="Just")return e._1;if(e.tag==="Nothing")return vo(t);g()},$J=t=>e=>n=>{const r=n.frameTitle===""?0:40,i=Yu(e)(n.camera);return(()=>{if(t.outputAspect.tag==="Nothing")return B_;if(t.outputAspect.tag==="Just")return z_(t.outputAspect._1);g()})()({vx:i.x-t.padding,vy:i.y-t.padding-r,vw:i.w+2*t.padding,vh:i.h+2*t.padding+r})},YJ=t=>e=>{if(e.tag==="Nothing")return[];if(e.tag==="Just"){const n=WJ(e._1)(t.segment.layout.nodes);if(n.tag==="Nothing")return[];if(n.tag==="Just"){const r=n._1.x*t.segment.placement.scale+t.segment.placement.tx,i=n._1.y*t.segment.placement.scale+t.segment.placement.ty,o=n._1.w*t.segment.placement.scale,u=n._1.h*t.segment.placement.scale;return[1,r,i,2,r+o,i,2,r+o,i+u,2,r,i+u,5]}}g()},VJ=t=>{const e=t.Monad0(),n=e.Bind1();return r=>i=>{if(r==="")return e.Applicative0().pure();const o=i.vh/720,u=15*o,s={family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:u,weight:600};return n.bind(t.measureText(s)(r))(a=>{const c=i.vy+12*o,f=u+6*o*2,d=a+11*o*2,l=i.vx+i.vw/2;return n.bind(t.drawRoundedRect({x:l-d/2,y:c,w:d,h:f})(f/2)(w("Just",{color:{r:255,g:255,b:255,a:240},flat:!0}))(w("Just",{color:{r:0,g:0,b:0,a:255},width:1*o,lineJoin:Te,lineCap:In})))(()=>t.drawText({x:l,y:c+f/2,content:r,font:s,color:{r:28,g:30,b:36,a:255},align:Xo,baseline:Wr}))})}},XJ=t=>{const e=F_(t),n=ga(t),r=t.Monad0(),i=r.Bind1(),o=D_(t),u=r.Applicative0(),s=A_(t),a=M_(t)(oa),c=gJ(t),f=I_(t),d=P_(t),l=VJ(t);return _=>h=>m=>p=>y=>x=>N=>{const v=ua(_.theme),k=(()=>{if(N.tag==="ResolvedLabels")return e(v)(y)(x);if(N.tag==="SpringLabels")return n(v)(y)(x)(N._1);g()})();return i.bind(o(v)(_.transparentBg)(h)(p))(()=>i.bind((()=>{const L=i.bind(s(v)(y)(x))(()=>i.bind(a(v)(y)(x))(()=>i.bind(c(v)(y)(x))(()=>i.bind(f(v)(p)(y)(x))(()=>i.bind(d(zx)(v)(y)(x))(()=>k)))));return m?L:u.pure()})())(()=>i.bind(_.watermark===""?t.Monad0().Applicative0().pure():t.drawText({x:p.vx+6,y:p.vy+6,content:_.watermark,font:{family:"Ilisarniq, ui-sans-serif, system-ui, sans-serif",size:9,weight:600},color:{r:180,g:180,b:180,a:255},align:Us,baseline:Sx}))(()=>l(x.frameTitle)(p))))}},UJ=t=>{const e=t.Monad0(),n=F_(t),r=ga(t),i=e.Bind1(),o=A_(t),u=M_(t),s=I_(t),a=t.popTransform,c=P_(t),f=t.popBakedTransform,d=t.popClip,l=t.popAlpha;return _=>h=>m=>p=>y=>{const x=y.state,N={tx:y.segment.placement.tx,ty:y.segment.placement.ty,sx:y.segment.placement.scale,sy:y.segment.placement.scale},v=ua(_.theme),k=y.segment.layout,L=Ye(k),E={vx:L.x-1e3,vy:L.y-1e3,vw:L.w+2e3,vh:L.h+2e3},B=11*y.segment.placement.scale*h>=5?oa:tJ,V=(()=>{if(B==="LabelsHidden")return e.Applicative0().pure();if(B==="LabelsShown")return m.tag==="Leaf"?n(v)(k)(x):r(v)(k)(x)(m);g()})(),et=YJ(p)((()=>{const D=y.segment.path.length-1|0;return D>=0&&D<y.segment.path.length?w("Just",y.segment.path[D]):T})());return i.bind(t.pushAlpha(y.bgAlpha))(()=>i.bind(t.pushClip(et)(js))(()=>i.bind(t.pushTransform(N))(()=>i.bind(o(v)(k)(x))(()=>i.bind(u(B)(v)(k)(x))(()=>i.bind(s(v)(E)(k)(x))(()=>i.bind(a)(()=>i.bind(t.pushBakedTransform(N))(()=>i.bind(c(Rx)(v)(k)(x))(()=>i.bind(f)(()=>i.bind(t.pushTransform(N))(()=>i.bind(V)(()=>i.bind(a)(()=>i.bind(d)(()=>l))))))))))))))}},jJ=t=>e=>{const n=Yu(t)(e);return{vx:n.x,vy:n.y,vw:n.w,vh:n.h}},Yr=t=>e=>e.diving||e.levels.length>1?(()=>{if(t.outputAspect.tag==="Nothing")return B_;if(t.outputAspect.tag==="Just")return z_(t.outputAspect._1);g()})()(jJ(e.rootLayout)(e.camera)):$J(t)(e.rootLayout)({...vo(e).state,camera:e.camera}),q_=t=>{const e=RJ(t),n=t.Monad0(),r=n.Applicative0(),i=n.Bind1(),o=UJ(t),u=XJ(t);return s=>a=>c=>{if(s.theme==="Isometric")return e({...QJ,transparentBg:s.transparentBg})(s.theme)(vo(c).segment.layout)(vo(c).state);const f=Yr(s)(c),d=_=>h=>{if(h.length===0)return r.pure();const m=Ft(p=>T,p=>y=>w("Just",{head:p,tail:y}),h);if(m.tag==="Nothing")return r.pure();if(m.tag==="Just"){const p=m._1.head,y=m._1.tail;return i.bind((()=>{const x=o(s)(c.camera.zoom)(p.role==="Active"?a:Q)(_)(p);return c.diving||p.role==="Active"?x:r.pure()})())(()=>d(p)(y))}g()},l=Ft(_=>T,_=>h=>w("Just",{head:_,tail:h}),c.levels);if(l.tag==="Nothing")return r.pure();if(l.tag==="Just"){const _=l._1.tail,h=l._1.head;return i.bind(u(s)(c.hasDives?f.vw/HJ(1)(Ye(c.rootLayout).w):1)(h.role==="Active"||h.role==="FlyThrough")(f)(h.segment.layout)(qJ(c).state)(_.length===0&&a.tag!=="Leaf"?O_("SpringLabels",a):OJ))(()=>d(h)(_))}g()}},$_=t=>e=>n=>{const r=st.compare(t)(n),i=(()=>{if(r==="LT")return n;if(r==="EQ"||r==="GT")return t;g()})(),o=st.compare(e)(i);if(o==="LT"||o==="EQ")return e;if(o==="GT")return i;g()},ZJ=ca(i_),Y_=q_(i_),V_=t=>{const e=t.vx+t.vw-4,n=t.vy+t.vh-4,r=t.vx+4,i=t.vy+4,o=u=>{if(u.tag==="Leaf")return Q;if(u.tag==="Node")return Wt("Node",u._1,u._2,u._3,{...u._4,x:$_(r)(e-u._4.w)(u._4.x),y:$_(i)(n-u._4.h)(u._4.y)},o(u._5),o(u._6));g()};return o},KJ=t=>e=>n=>r=>i=>o=>u=>{const s={padding:8,transparentBg:(()=>{if(e==="TransparentBackground")return!0;if(e==="PaintBackground")return!1;g()})(),halftoneShadows:!0,watermark:"",theme:t,outputAspect:r.width<=0||r.height<=0?T:w("Just",r.width/r.height)},a=eN(n)(r);return()=>{const c=a(),f=i.levels.length-1|0;if(f>=0&&f<i.levels.length){const l=ZJ(i.levels[f].segment.layout)(i.levels[f].state)(c)(),_=Vs(o)(V_(Yr(s)(i))(l))(u);return Y_(s)(_.applied)(i)(c)(),_.springs}const d=Vs(o)(V_(Yr(s)(i))(Q))(u);return Y_(s)(d.applied)(i)(c)(),d.springs}},tT=t=>t,eT=(t=>t)("Light"),nT=tT("TransparentBackground"),er=t=>"rgb("+ie(t.r)+","+ie(t.g)+","+ie(t.b)+")",bn=oi(ri("Fixed",ii(0)(20)(4))),rT=t=>"translate("+bn(t.tx)+","+bn(t.ty)+") scale("+bn(t.sx)+","+bn(t.sy)+")",wt=oi(ri("Fixed",ii(0)(20)(2))),_a=t=>{const e=[];let n=0;for(;n<t.length;){const r=n,i=r>=0&&r<t.length?w("Just",t[r]):T;if(i.tag==="Nothing"){n=t.length;continue}if(i.tag==="Just"){if(i._1===1){e.push("M"),e.push(wt((()=>{const o=r+1|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+2|0;return o>=0&&o<t.length?t[o]:0})())),n=r+3|0;continue}if(i._1===2){e.push("L"),e.push(wt((()=>{const o=r+1|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+2|0;return o>=0&&o<t.length?t[o]:0})())),n=r+3|0;continue}if(i._1===3){e.push("Q"),e.push(wt((()=>{const o=r+1|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+2|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+3|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+4|0;return o>=0&&o<t.length?t[o]:0})())),n=r+5|0;continue}if(i._1===4){e.push("C"),e.push(wt((()=>{const o=r+1|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+2|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+3|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+4|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+5|0;return o>=0&&o<t.length?t[o]:0})())),e.push(wt((()=>{const o=r+6|0;return o>=0&&o<t.length?t[o]:0})())),n=r+7|0;continue}if(i._1===5){e.push("Z"),n=r+1|0;continue}n=t.length;continue}g()}return lo(" ")(e)},iT={map:t=>e=>n=>{const r=e(n);return()=>{const i=r();return t(i)}}},da=(()=>{const t=jn("&")("&"),e=jn("<")("<"),n=(()=>{const r=jn(">")(">"),i=(()=>{const o=jn('"')(""");return u=>o(r(u))})();return o=>i(e(o))})();return r=>n(t(r))})(),oT=t=>{if(t.style==="RunText")return"<tspan>"+da(t.text)+"</tspan>";if(t.style==="RunCode")return`<tspan font-family="'CommitMono', ui-monospace, SFMono-Regular, Menlo, monospace" font-weight="400">`+da(t.text)+"</tspan>";g()},Qe=t=>e=>{const n=e.maskDepth;return()=>{n.value===0&&e.out.push(t)}},uT=t=>e=>{const n=[];let r=0;const i=o=>{const u=o>=0&&o<e.length?t.sx*e[o]+t.tx:t.sx*0+t.tx;return()=>{n.push(u),n.push((()=>{const s=o+1|0;return s>=0&&s<e.length?t.sy*e[s]+t.ty:t.sy*0+t.ty})())}};for(;r<e.length;){const o=r,u=o>=0&&o<e.length?w("Just",e[o]):T;if(u.tag==="Nothing"){r=e.length;continue}if(u.tag==="Just"){if(u._1===1){n.push(u._1),i(o+1|0)(),r=o+3|0;continue}if(u._1===2){n.push(u._1),i(o+1|0)(),r=o+3|0;continue}if(u._1===3){n.push(u._1),i(o+1|0)(),i(o+3|0)(),r=o+5|0;continue}if(u._1===4){n.push(u._1),i(o+1|0)(),i(o+3|0)(),i(o+5|0)(),r=o+7|0;continue}if(u._1===5){n.push(u._1),r=o+1|0;continue}r=e.length;continue}g()}return n},cu=t=>e=>{const n=t.bake;return()=>{const r=n.value;if(r.tag==="Nothing")return e;if(r.tag==="Just")return uT(r._1)(e);g()}},X_={apply:t=>e=>n=>{const r=t(n),i=e(n);return()=>{const o=r(),u=i();return o(u)}},Functor0:()=>iT},sT={bind:t=>e=>n=>{const r=t(n);return()=>{const i=r();return e(i)(n)()}},Apply0:()=>X_},aT={pure:t=>e=>()=>t,Apply0:()=>X_},cT={Applicative0:()=>aT,Bind1:()=>sT},gT=t=>e=>'<defs><pattern id="'+t+'" x="0" y="0" width="'+wt(e.tile)+'" height="'+wt(e.tile)+'" patternUnits="userSpaceOnUse">'+(e.bgColor.a===0?"":'<rect width="'+wt(e.tile)+'" height="'+wt(e.tile)+'" fill="'+er(e.bgColor)+'" fill-opacity="'+wt(rt(e.bgColor.a)/255)+'"/>')+'<circle cx="'+wt(e.tile/2)+'" cy="'+wt(e.tile/2)+'" r="'+wt(e.dotRadius)+'" fill="'+er(e.dotColor)+'"/></pattern></defs><rect x="'+wt(e.viewport.vx)+'" y="'+wt(e.viewport.vy)+'" width="'+wt(e.viewport.vw)+'" height="'+wt(e.viewport.vh)+'" fill="url(#'+t+')"/>',U_=t=>e=>'<path d="'+_a(t)+'" fill="'+er(e)+'" fill-opacity="'+wt(rt(e.a)/255)+'"/>',fT=t=>e=>n=>r=>'<rect x="'+wt(t.x)+'" y="'+wt(t.y)+'" width="'+wt(t.w)+'" height="'+wt(t.h)+'" rx="'+wt(e)+'"'+(()=>{if(n.tag==="Just")return' fill="'+er(n._1.color)+'" fill-opacity="'+wt(rt(n._1.color.a)/255)+'"';if(n.tag==="Nothing")return' fill="none"';g()})()+(()=>{if(r.tag==="Just")return' stroke="'+er(r._1.color)+'" stroke-opacity="'+wt(rt(r._1.color.a)/255)+'" stroke-width="'+wt(r._1.width)+'" stroke-linejoin="'+(()=>{if(r._1.lineJoin==="RoundJoin")return"round";if(r._1.lineJoin==="BevelJoin")return"bevel";if(r._1.lineJoin==="MiterJoin")return"miter";g()})()+'" stroke-linecap="'+(()=>{if(r._1.lineCap==="ButtCap")return"butt";if(r._1.lineCap==="RoundCap")return"round";if(r._1.lineCap==="SquareCap")return"square";g()})()+'"';if(r.tag==="Nothing")return"";g()})()+"/>",j_=t=>e=>'<path d="'+_a(t)+'" fill="none" stroke="'+er(e.color)+'" stroke-opacity="'+wt(rt(e.color.a)/255)+'" stroke-width="'+wt(e.width)+'" stroke-linejoin="'+(()=>{if(e.lineJoin==="RoundJoin")return"round";if(e.lineJoin==="BevelJoin")return"bevel";if(e.lineJoin==="MiterJoin")return"miter";g()})()+'" stroke-linecap="'+(()=>{if(e.lineCap==="ButtCap")return"butt";if(e.lineCap==="RoundCap")return"round";if(e.lineCap==="SquareCap")return"square";g()})()+'"/>',Z_=t=>{const e=tg(Pr(t.content));return'<text x="'+wt(t.x)+'" y="'+wt(t.y)+'"'+(()=>{if(t.baseline==="BaselineTop")return' dy="0.8em"';if(t.baseline==="BaselineMiddle")return' dy="0.32em"';if(t.baseline==="BaselineAlphabetic"||t.baseline==="BaselineBottom")return"";g()})()+' fill="'+er(t.color)+'" fill-opacity="'+wt(rt(t.color.a)/255)+'" font-size="'+wt(t.font.size)+'" font-family="Ilisarniq, ui-sans-serif, system-ui, sans-serif" font-weight="'+ie(t.font.weight)+'" text-anchor="'+(()=>{if(t.align==="AlignLeft")return"start";if(t.align==="AlignCenter")return"middle";if(t.align==="AlignRight")return"end";g()})()+'">'+(e.length===1&&e[0].style==="RunText"?da(e[0].text):lo("")(H(oT)(e)))+"</text>"},_T=t=>"matrix("+bn(t.a)+" "+bn(t.b)+" "+bn(t.c)+" "+bn(t.d)+" "+bn(t.e)+" "+bn(t.f)+")",K_={fillPath:t=>e=>n=>{const r=cu(n)(t);return()=>{const i=r();return Qe(U_(i)(e.color))(n)()}},strokePath:t=>e=>n=>{const r=cu(n)(t);return()=>{const i=r(),o=n.bake.value;return Qe(j_(i)((()=>{if(o.tag==="Nothing")return e;if(o.tag==="Just")return{...e,width:o._1.sx*e.width};g()})()))(n)()}},fillStrokePath:t=>e=>n=>r=>{const i=cu(r)(t);return()=>{const o=i(),u=r.bake.value;return Qe(U_(o)(e.color)+j_(o)((()=>{if(u.tag==="Nothing")return n;if(u.tag==="Just")return{...n,width:u._1.sx*n.width};g()})()))(r)()}},drawRoundedRect:t=>e=>n=>r=>i=>{const o=i.bake;return()=>{const u=o.value;return Qe(fT((()=>{if(u.tag==="Nothing")return t;if(u.tag==="Just")return{x:u._1.sx*t.x+u._1.tx,y:u._1.sy*t.y+u._1.ty,w:u._1.sx*t.w,h:u._1.sy*t.h};g()})())((()=>{if(u.tag==="Nothing")return e;if(u.tag==="Just")return u._1.sx*e;g()})())(n)(r.tag==="Just"?w("Just",(()=>{if(u.tag==="Nothing")return r._1;if(u.tag==="Just")return{...r._1,width:u._1.sx*r._1.width};g()})()):T))(i)()}},drawText:t=>e=>{const n=e.bake;return()=>{const r=n.value;return Qe(Z_((()=>{if(r.tag==="Nothing")return t;if(r.tag==="Just")return{...t,x:r._1.sx*t.x+r._1.tx,y:r._1.sy*t.y+r._1.ty,font:{...t.font,size:r._1.sx*t.font.size}};g()})()))(e)()}},drawTextAffine:t=>e=>Qe((()=>{const n='transform="'+_T(t)+'"';return(n===""?"<g>":"<g "+n+">")+Z_(e)+"</g>"})()),pushTransform:t=>Qe((()=>{const e='transform="'+rT(t)+'"';return e===""?"<g>":"<g "+e+">"})()),popTransform:Qe("</g>"),pushBakedTransform:t=>e=>{const n=e.bake;return()=>{n.value=w("Just",t)}},popBakedTransform:t=>{const e=t.bake;return()=>{e.value=T}},pushClip:t=>e=>n=>{const r=n.clipCounter;return()=>{const i=r.value;n.clipCounter.value=i+1|0;const o=cu(n)(t)(),u="clip"+ie(i);return Qe((()=>{const s='clip-path="url(#'+u+')"';return'<defs><clipPath id="'+u+'"><path d="'+_a(o)+'"'+(()=>{if(e==="EvenOdd")return' clip-rule="evenodd"';if(e==="NonZero")return"";g()})()+"/></clipPath></defs>"+(s===""?"<g>":"<g "+s+">")})())(n)()}},popClip:Qe("</g>"),pushBlend:t=>Qe((()=>{const e=(()=>{if(t==="Normal")return'style="mix-blend-mode: normal"';if(t==="Difference")return'style="mix-blend-mode: difference"';g()})();return e===""?"<g>":"<g "+e+">"})()),popBlend:Qe("</g>"),pushAlpha:t=>Qe((()=>{const e='opacity="'+wt(t)+'"';return e===""?"<g>":"<g "+e+">"})()),popAlpha:Qe("</g>"),pushLayer:t=>e=>{const n=(()=>{if(t==="LayerNodeMask"){const r=e.maskDepth;return()=>{const i=r.value;e.maskDepth.value=i+1|0}}return()=>{}})();return()=>{n(),e.out.push("<g>")}},popLayer:t=>{const e=t.maskDepth;return()=>{const n=e.value,r=n-1|0;n>0&&(t.maskDepth.value=r),t.out.push("</g>")}},setViewport:t=>e=>()=>{},clearBackground:t=>e=>Qe('<rect x="'+wt(e.viewport.vx)+'" y="'+wt(e.viewport.vy)+'" width="'+wt(e.viewport.vw)+'" height="'+wt(e.viewport.vh)+'" fill="'+er(t)+'" opacity="'+wt(rt(t.a)/255)+'"/>')(e),backgroundDots:t=>e=>{const n=e.patternCounter;return()=>{const r=n.value;return e.patternCounter.value=r+1|0,Qe(gT("bg-dots-"+ie(r))(t))(e)()}},measureText:t=>e=>n=>{const r=If(t)(e);return()=>r},measureInk:t=>e=>n=>{const r=Qf(t)(e);return()=>r},insideTokenStyle:t=>e=>()=>Of,Monad0:()=>cT},dT=q_(K_),lT=ca(K_),hT=t=>e=>n=>r=>i=>{const o={padding:24,transparentBg:(()=>{if(r==="TransparentBackground")return!0;if(r==="PaintBackground")return!1;g()})(),halftoneShadows:!0,watermark:"",theme:n,outputAspect:t},u=Yr(o)(i);return{viewBox:wt(u.vx)+" "+wt(u.vy)+" "+wt(u.vw)+" "+wt(u.vh),body:(()=>{const s=[],a={value:0},c={value:0},f={value:0},d={value:T};return dT(o)(e)(i)({out:s,maskDepth:a,clipCounter:c,patternCounter:f,viewport:u,bake:d})(),lo("")(s)})(),vx:u.vx,vy:u.vy,vw:u.vw,vh:u.vh}},pT=t=>e=>n=>r=>i=>o=>{const u={padding:24,transparentBg:(()=>{if(n==="TransparentBackground")return!0;if(n==="PaintBackground")return!1;g()})(),outputAspect:t},s=Vs(i)((()=>{const a=[],c={value:0},f={value:0},d={value:0},l={value:T},_=r.levels.length-1|0;return _>=0&&_<r.levels.length?lT(r.levels[_].segment.layout)(r.levels[_].state)({out:a,maskDepth:c,clipCounter:f,patternCounter:d,viewport:Yr(u)(r),bake:l})():Q})())(o);return{parts:hT(t)(s.applied)(e)(n)(r),springs:s.springs}},zi=t=>({bind:e=>n=>r=>t.Bind1().bind(e(r))(i=>n(i._1)(i._2)),Apply0:()=>t1(t)}),t1=t=>{const e=t.Bind1().Apply0().Functor0(),n={map:r=>i=>o=>e.map(u=>b(r(u._1),u._2))(i(o))};return{apply:(()=>{const r=zi(t);return i=>o=>r.bind(i)(u=>r.bind(o)(s=>Ri(t).pure(u(s))))})(),Functor0:()=>n}},Ri=t=>({pure:e=>n=>t.Applicative0().pure(b(e,n)),Apply0:()=>t1(t)}),mT=t=>{const e={Applicative0:()=>Ri(t),Bind1:()=>zi(t)};return{state:n=>r=>t.Applicative0().pure(n(r)),Monad0:()=>e}},la=(t,e)=>({tag:t,_1:e}),Mn=(t,e)=>({tag:t,_1:e}),ve=mT(Wn),Rt=zi(Wn),Fe=ve.state(t=>b(t,t)),ue=Ri(Wn),Bn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},e1=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},gu=Nu(ue)(Bt),zn=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},yT=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},xT=(()=>{const t=qe.unfoldr(e=>{if(e.tag==="Nil")return T;if(e.tag==="Cons")return w("Just",b(e._1,e._2));g()});return e=>t((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._3,n(r._6,i)));g()};return n(e,qt)})())})(),NT=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=!1;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=!0;continue}}g()}return i},fu=t=>e=>n=>J(r=>i=>t.Bind1().bind(r)(o=>e(o)(i)))(t.Applicative0().pure(n)),JT=J(t=>e=>j(C)(e)()(t))(Q),TT=(()=>{const t=(e=>n=>{let r=e,i=n,o=!0,u;for(;o;){const s=r,a=i;if(a.tag==="Nil"){o=!1,u=s;continue}if(a.tag==="Cons"){r=j(C)(a._1)()(s),i=a._2;continue}g()}return u})(Q);return e=>t((()=>{const n=(r,i)=>{if(r.tag==="Leaf")return i;if(r.tag==="Node")return n(r._5,Ot("Cons",r._3,n(r._6,i)));g()};return n(e,qt)})())})(),vT=Mn("Exit"),wT=t=>la("Par",t),n1=t=>la("Seq",t),bT=t=>e=>n=>{const r=ir(Yt,T,i=>i._1===t,n);if(r.tag==="Just"){const i=On(Yt,T,r._1,b(t,e),n);if(i.tag==="Nothing")return n;if(i.tag==="Just")return i._1;g()}if(r.tag==="Nothing")return zt(n)(b(t,e));g()},LT=t=>e=>H(n=>n._1===t?b(n._1,{...n._2,label:w("Just",e)}):b(n._1,n._2)),we=t=>ve.state(e=>b(void 0,(()=>{if(e.error.tag==="Just")return e;if(e.error.tag==="Nothing")return{...e,error:w("Just",{msg:t,line:e.currentLine,column:e.currentColumn})};g()})())),kT=t=>Rt.bind(ve.state(e=>b(void 0,{...e,currentLine:t.line,currentColumn:t.column})))(()=>Rt.bind(Fe)(e=>{if(e.error.tag==="Just")return ue.pure();if(e.error.tag==="Nothing"){if(t.op.tag==="Enter"){if(!Bn(t.op._1.id)(e.currNodes))return we("cannot enter node "+t.op._1.id+": does not exist");if(!e1(t.op._1.id)(e.interiorOf))return we("cannot enter node "+t.op._1.id+": it has no `inside` block");if(Be(gn)(t.op._1.id)(e.enterStack))return we("cannot enter node "+t.op._1.id+": already entered");const n=t.op._1;return ve.state(r=>b(void 0,{...r,enterStack:zt(r.enterStack)(n.id),scenes:zt(r.scenes)(ao("EnterNode",n.id))}))}if(t.op.tag==="Exit"){const n=Vi(e.enterStack);if(n.tag==="Nothing")return we("`exit` without a matching `enter`");if(n.tag==="Just"){const r=n._1.init;return ve.state(i=>b(void 0,{...i,enterStack:r,scenes:zt(i.scenes)(Dl)}))}g()}return ue.pure()}g()})),ET=t=>Rt.bind(Fe)(e=>{const n=t.tag==="Just"&&t._1!==""?t._1:"kf-"+ie(e.kfCounter);if(Me(i=>i.id===n,e.keyframes))return we("duplicate frame name "+n);const r={...e,keyframes:zt(e.keyframes)({id:n,nodes:e.currNodes,edges:e.currEdges}),kfCounter:e.kfCounter+1|0,currentKf:w("Just",n)};return ve.state(i=>b(void 0,r))}),GT=gu(t=>Rt.bind(Fe)(e=>{if(e.error.tag==="Just")return ue.pure();if(e.error.tag==="Nothing")return e1(t.node)(e.interiorOf)?we("node "+t.node+" has more than one `inside` block"):ve.state(n=>b(void 0,{...n,interiorOf:j(C)(t.node)(t.doc)(n.interiorOf)}));g()})),CT=t=>e=>{const n=e.from+"->"+e.to,r=e.newFrom+"->"+e.newTo,i=St("Left","cannot repoint "+e.from+"\u2192"+e.to+": edge does not exist"),o=zn(n)(t.currEdges)?St("Right",void 0):i;return(()=>{if(o.tag==="Left"){const u=o._1;return s=>St("Left",u)}if(o.tag==="Right"){const u=o._1;return s=>s(u)}g()})()(()=>{const u="cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": unknown node "+e.newFrom;if(!Bn(e.newFrom)(t.currNodes))return St("Left",u);const s="cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": unknown node "+e.newTo;if(!Bn(e.newTo)(t.currNodes))return St("Left",s);const a="cannot repoint "+e.from+"\u2192"+e.to+" to "+e.newFrom+"\u2192"+e.newTo+": target edge already exists";return n!==r&&zn(r)(t.currEdges)?St("Left",a):St("Right",{nextCurrEdges:j(C)(r)()(ni(C)(n)(t.currEdges)),newId:r,newEdge:{id:r,from:{node:e.newFrom,port:T},to:{node:e.newTo,port:T}}})})},r1={graphNodes:[],graphEdges:Q,currNodes:Q,currEdges:Q,keyframes:[],scenes:[],kfCounter:0,eventCounter:0,currentKf:T,currentLine:0,currentColumn:0,error:T,enterStack:[],interiorOf:Q},i1=t=>e=>Rt.bind(Fe)(n=>{const r="ev-"+ie(n.eventCounter);return Rt.bind((()=>{const i={...n,eventCounter:n.eventCounter+1|0};return ve.state(o=>b(void 0,i))})())(()=>ue.pure({events:[{id:r,kind:e,when:t}],firstId:w("Just",r),lastId:w("Just",r)}))}),ST=t=>e=>{if(e.tag==="Token"){const n=e._1;return Rt.bind(Fe)(r=>{const i=!Bn(n.from)(r.currNodes),o=!Bn(n.to)(r.currNodes);if(i||o)return Rt.bind(we(i?o?"token references unknown node: "+n.from+", "+n.to:"token references unknown node: "+n.from:o?"token references unknown node: "+n.to:"token references unknown node: "))(()=>ue.pure({events:[],firstId:T,lastId:T}));const u=n.to+"->"+n.from,s=n.from+"->"+n.to;return zn(s)(r.currEdges)?i1(t)(_c("SendToken",{from:n.from,to:n.to,edge:s,direction:Cl,labels:n.labels})):zn(u)(r.currEdges)?i1(t)(_c("SendToken",{from:n.from,to:n.to,edge:u,direction:Sl,labels:n.labels})):Rt.bind(we("token "+n.from+"\u2192"+n.to+": no edge between "+n.from+" and "+n.to))(()=>ue.pure({events:[],firstId:T,lastId:T}))})}return ue.pure({events:[],firstId:T,lastId:T})},DT=t=>e=>{if(0<t.length){const n=t[0];return Rt.bind(ve.state(r=>b(void 0,{...r,currentLine:n.line,currentColumn:n.column})))(()=>we(e))}return we(e)},PT=t=>xt(e=>yT(e)(t.graphEdges))(kt(Kr,xT(t.currEdges))),IT=t=>e=>{const n=ct(i=>i.from.node===e.id||i.to.node===e.id,PT(t)),r=fu(Pa)(i=>o=>{const u=o.from+"->"+e.id,s=e.id+"->"+o.to,a=o.from+"->"+o.to,c="via "+o.from+" "+o.to+": no edge "+o.from+"\u2192"+e.id;if(!zn(u)(t.currEdges))return St("Left",c);const f="via "+o.from+" "+o.to+": no edge "+e.id+"\u2192"+o.to;if(!zn(s)(t.currEdges))return St("Left",f);const d="via "+o.from+" "+o.to+": would create "+o.from+"\u2192"+o.to+" but it already exists";return zn(a)(t.currEdges)||NT(a)(i.synthesized)?St("Left",d):St("Right",{consumed:j(C)(u)()(j(C)(s)()(i.consumed)),synthesized:j(C)(a)({id:a,from:{node:o.from,port:T},to:{node:o.to,port:T}})(i.synthesized)})})({consumed:Q,synthesized:Q})(e.via);return(()=>{if(r.tag==="Left"){const i=r._1;return o=>St("Left",i)}if(r.tag==="Right"){const i=r._1;return o=>o(i)}g()})()(i=>{const o=i.consumed,u=ct(s=>!zn(s.id)(o),n);return u.length===0?St("Right",{nextCurrEdges:Ge(C.compare,Le,Gn(C.compare,t.currEdges,JT(H(s=>s.id)(n))),TT((()=>{const s=a=>{if(a.tag==="Leaf")return Q;if(a.tag==="Node")return Wt("Node",a._1,a._2,a._3,void 0,s(a._5),s(a._6));g()};return s(i.synthesized)})())),synthesized:i.synthesized}):St("Left","cannot delete node "+e.id+": still connected ("+lo(", ")(H(s=>s.from.node+"\u2192"+s.to.node)(u))+"). Use -edge to drop them or `via a b` to merge "+e.id+"'s endpoints.")})},o1=t=>{if(t.tag==="Leaf")return[t._1];if(t.tag==="Par"||t.tag==="Seq")return Tt(t._1)(o1);g()},QT=Rt.bind(Fe)(t=>{if(t.error.tag==="Just")return ue.pure();if(t.error.tag==="Nothing"){const e=t.enterStack.length-1|0;return e>=0&&e<t.enterStack.length?we("entered node "+t.enterStack[e]+" was never exited"):ue.pure()}g()}),FT=t=>({nodes:H($i)(t.graphNodes),edges:(()=>{const e=(n,r)=>{if(n.tag==="Leaf")return r;if(n.tag==="Node")return e(n._5,Ot("Cons",n._4,e(n._6,r)));g()};return kt($t.foldr,e(t.graphEdges,qt))})(),constraints:[]}),AT=t=>{if(t.tag==="AddNode"){const e=t._1;return ve.state(n=>b(void 0,{...n,graphNodes:bT(e.id)({id:e.id,size:b(1,1),ports:[],label:w("Just",e.label),shape:e.shape})(n.graphNodes),currNodes:j(C)(e.id)()(n.currNodes)}))}if(t.tag==="DelNode"){const e=t._1;return Rt.bind(Fe)(n=>{if(!Bn(e.id)(n.currNodes))return we("cannot delete node "+e.id+": does not exist");const r=IT(n)(e);if(r.tag==="Left")return we(r._1);if(r.tag==="Right"){const i=r._1;return ve.state(o=>b(void 0,{...o,currNodes:ni(C)(e.id)(o.currNodes),currEdges:i.nextCurrEdges,graphEdges:Ge(C.compare,Le,i.synthesized,o.graphEdges)}))}g()})}if(t.tag==="ModNode"){const e=t._1;return Rt.bind(Fe)(n=>{if(!Bn(e.id)(n.currNodes))return we("cannot modify node "+e.id+": does not exist");if(e.label.tag==="Just"){const r=e.label._1;return ve.state(i=>b(void 0,{...i,graphNodes:LT(e.id)(r)(i.graphNodes)}))}if(e.label.tag==="Nothing")return ue.pure();g()})}if(t.tag==="AddEdge"){const e=t._1;return Rt.bind(Fe)(n=>{const r=!Bn(e.from)(n.currNodes),i=!Bn(e.to)(n.currNodes);if(r||i)return we("cannot add edge "+e.from+"\u2192"+e.to+": unknown node "+(r?i?e.from+", "+e.to:e.from:i?e.to:""));const o=e.from+"->"+e.to;return ve.state(u=>b(void 0,{...u,graphEdges:j(C)(o)({id:o,from:{node:e.from,port:T},to:{node:e.to,port:T}})(u.graphEdges),currEdges:j(C)(o)()(u.currEdges)}))})}if(t.tag==="DelEdge"){const e=t._1;return Rt.bind(Fe)(n=>{const r=e.from+"->"+e.to;return zn(r)(n.currEdges)?ve.state(i=>b(void 0,{...i,currEdges:ni(C)(r)(i.currEdges)})):we("cannot delete edge "+e.from+"\u2192"+e.to+": does not exist")})}if(t.tag==="RepointEdge"){const e=t._1;return Rt.bind(Fe)(n=>{const r=CT(n)(e);if(r.tag==="Left")return we(r._1);if(r.tag==="Right"){const i=r._1;return ve.state(o=>b(void 0,{...o,currEdges:i.nextCurrEdges,graphEdges:j(C)(i.newId)(i.newEdge)(o.graphEdges)}))}g()})}return ue.pure()},MT=t=>Rt.bind(ve.state(e=>b(void 0,{...e,currentLine:t.line,currentColumn:t.column})))(()=>AT(t.op)),BT=t=>e=>Rt.bind(gu(MT)(e))(()=>Rt.bind(Fe)(n=>{const r=t.tag==="Just"&&t._1!==""?t._1:"kf-"+ie(n.kfCounter);if(Me(o=>o.id===r,n.keyframes))return we("duplicate frame name "+r);const i={...n,keyframes:zt(n.keyframes)({id:r,nodes:n.currNodes,edges:n.currEdges}),kfCounter:n.kfCounter+1|0,currentKf:w("Just",r),scenes:(()=>{if(n.currentKf.tag==="Nothing")return n.scenes;if(n.currentKf.tag==="Just")return zt(n.scenes)(ao("Structural",{from:n.currentKf._1,to:r,focus:T}));g()})()};return ve.state(o=>b(void 0,i))})),zT=t=>e=>{const n=Ft(r=>T,r=>i=>w("Just",{head:r,tail:i}),e);if(n.tag==="Nothing")return ue.pure({events:[],firstId:T,lastId:T});if(n.tag==="Just"){const r=n._1.tail;return Rt.bind(Wi(t)(n._1.head))(i=>Rt.bind(fu({Applicative0:()=>Ri(Wn),Bind1:()=>zi(Wn)})(o=>u=>Rt.bind(Wi((()=>{if(o.lastId.tag==="Just")return qu("After",o.lastId._1);if(o.lastId.tag==="Nothing")return t;g()})())(u))(s=>ue.pure({events:[...o.events,...s.events],firstId:(()=>{if(o.firstId.tag==="Just")return w("Just",o.firstId._1);if(o.firstId.tag==="Nothing")return s.firstId;g()})(),lastId:(()=>{if(s.lastId.tag==="Just")return w("Just",s.lastId._1);if(s.lastId.tag==="Nothing")return o.lastId;g()})()})))(i)(r))(o=>ue.pure(o)))}g()},RT=t=>e=>{const n=Ft(r=>T,r=>i=>w("Just",{head:r,tail:i}),e);if(n.tag==="Nothing")return ue.pure({events:[],firstId:T,lastId:T});if(n.tag==="Just"){const r=n._1.tail;return Rt.bind(Wi(t)(n._1.head))(i=>Rt.bind(WT((()=>{if(i.firstId.tag==="Just")return qu("With",i.firstId._1);if(i.firstId.tag==="Nothing")return t;g()})())(r))(o=>ue.pure({events:[...i.events,...o.events],firstId:i.firstId,lastId:(()=>{if(i.lastId.tag==="Just")return w("Just",i.lastId._1);if(i.lastId.tag==="Nothing")return o.lastId;g()})()})))}g()},Wi=t=>e=>{if(e.tag==="Leaf"){const n=e._1;return Rt.bind(ve.state(r=>b(void 0,{...r,currentLine:n.line,currentColumn:n.column})))(()=>ST(t)(n.op))}if(e.tag==="Seq")return zT(t)(e._1);if(e.tag==="Par")return RT(t)(e._1);g()},WT=t=>fu({Applicative0:()=>Ri(Wn),Bind1:()=>zi(Wn)})(e=>n=>Rt.bind(Wi(t)(n))(r=>ue.pure({events:[...e.events,...r.events],firstId:(()=>{if(e.firstId.tag==="Just")return w("Just",e.firstId._1);if(e.firstId.tag==="Nothing")return r.firstId;g()})(),lastId:(()=>{if(r.lastId.tag==="Just")return w("Just",r.lastId._1);if(r.lastId.tag==="Nothing")return e.lastId;g()})()})))({events:[],firstId:T,lastId:T}),HT=t=>Rt.bind(Fe)(e=>{if(e.currentKf.tag==="Nothing")return we("flow ops before any structural frame");if(e.currentKf.tag==="Just"){const n=e.currentKf._1;return Rt.bind(Wi(Gl)(t))(r=>Rt.bind(Fe)(i=>{const o={...i,scenes:zt(i.scenes)(ao("DataFlow",{keyframe:n,events:r.events,focus:T}))};return ve.state(u=>b(void 0,o))}))}g()}),OT=t=>Rt.bind(Fe)(e=>{if(e.error.tag==="Just")return ue.pure();if(e.error.tag==="Nothing"){const n=o1(t.ops),r=ct(u=>u.op.tag==="AddNode"||u.op.tag==="DelNode"||u.op.tag==="ModNode"||u.op.tag==="AddEdge"||u.op.tag==="DelEdge"||u.op.tag==="RepointEdge",n),i=ct(u=>u.op.tag==="Enter"||u.op.tag==="Exit",n),o=ct(u=>!(u.op.tag==="AddNode"||u.op.tag==="DelNode"||u.op.tag==="ModNode"||u.op.tag==="AddEdge"||u.op.tag==="DelEdge"||u.op.tag==="RepointEdge")&&!(u.op.tag==="Enter"||u.op.tag==="Exit"),n);return i.length!==0&&o.length!==0?DT(i)("`enter`/`exit` cannot be mixed with flow tokens in the same frame"):Rt.bind((()=>{const u=BT(t.name)(r);return r.length!==0?u:ue.pure()})())(()=>Rt.bind((()=>{const u=ET(t.name);return r.length===0&&o.length!==0?u:ue.pure()})())(()=>Rt.bind((()=>{const u=HT(t.ops);return o.length!==0?u:ue.pure()})())(()=>gu(kT)(i))))}g()}),u1=t=>Rt.bind(GT(t.interiors))(()=>Rt.bind(gu(OT)(t.frames))(()=>Rt.bind(QT)(()=>Rt.bind(Fe)(e=>{if(e.error.tag==="Just")return ue.pure(St("Left",e.error._1));if(e.error.tag==="Nothing"){const n=qT(t.interiors);if(n.tag==="Left")return ue.pure(St("Left",n._1));if(n.tag==="Right")return ue.pure(St("Right",{seed:t.seed,graph:FT(e),keyframes:e.keyframes,scenes:e.scenes,interiors:n._1}))}g()})))),qT=t=>{const e=fu(Pa)(n=>r=>{const i=u1(r.doc)(r1)._1;return(()=>{if(i.tag==="Left"){const o=i._1;return u=>St("Left",o)}if(i.tag==="Right"){const o=i._1;return u=>u(o)}g()})()(o=>St("Right",j(C)(r.node)(o)(n)))})(Q)(t);if(e.tag==="Left")return St("Left",e._1);if(e.tag==="Right")return St("Right",e._1);g()},Vr=(t,e)=>({tag:"ParseError",_1:t,_2:e}),A=(t,e,n)=>({tag:"ParseState",_1:t,_2:e,_3:n}),_u=(t,e,n)=>({tag:t,_1:e,_2:n}),$T=t=>_u("More",t),YT=t=>_u("Lift",t),VT={defer:t=>{const e=sl(t);return(n,r,i,o,u)=>al(e)(n,r,i,o,u)}},s1={map:t=>e=>(n,r,i,o,u)=>r(s=>e(n,r,i,o,(a,c)=>r(f=>u(a,t(c)))))},XT={alt:t=>e=>(n,r,i,o,u)=>{const s=n._1,a=n._2;return r(c=>t(A(s,a,!1),r,i,(f,d)=>{const l=f._3;return r(_=>l?o(f,d):e(n,r,i,o,u))},u))},Functor0:()=>s1},UT=t=>{const e=t.Monad0();return n=>r=>{const i=o=>{let u=o,s=!0,a;for(;s;){const c=u();if(c.tag==="More"){u=c._1;continue}if(c.tag==="Lift"){s=!1,a=e.Bind1().Apply0().Functor0().map(Qa)(c._1);continue}if(c.tag==="Stop"){s=!1,a=e.Applicative0().pure(Zr("Done",b(c._2,c._1)));continue}g()}return a};return t.tailRecM(i)(o=>r(n,$T,YT,(u,s)=>_u("Stop",u,St("Left",s)),(u,s)=>_u("Stop",u,St("Right",s))))}},a1=(t,e,n,r,i)=>i(t,t._2),jT={index:0,line:1,column:1},ZT=(t=>{const e=UT(t);return n=>r=>t.Monad0().Bind1().Apply0().Functor0().map(Yi)(e(A(n,jT,!1))(r))})(Q1),c1={apply:t=>e=>(n,r,i,o,u)=>r(s=>t(n,r,i,o,(a,c)=>r(f=>{const d=n._3&&!a._3?A(a._1,a._2,!0):a;return e(d,r,i,o,(l,_)=>r(h=>u(d._3&&!l._3?A(l._1,l._2,!0):l,c(_))))}))),Functor0:()=>s1},g1={pure:t=>(e,n,r,i,o)=>o(e,t),Apply0:()=>c1},KT={bind:t=>e=>(n,r,i,o,u)=>r(s=>t(n,r,i,o,(a,c)=>r(f=>e(c)(n._3&&!a._3?A(a._1,a._2,!0):a,r,i,o,u)))),Apply0:()=>c1},tv={Applicative0:()=>g1,Bind1:()=>KT},du=t=>(e,n,r,i,o)=>n(u=>a1(e,n,r,i,(s,a)=>n(c=>i(e._3&&!s._3?A(s._1,s._2,!0):s,Vr(t,a))))),ev={empty:du("No alternative"),Alt0:()=>XT},nv={Applicative0:()=>g1,Plus1:()=>ev},on=(t=>e=>{const n=e.Plus1().Alt0(),r=e.Applicative0();return i=>t.tailRecM(o=>t.Monad0().Bind1().bind(n.alt(n.Functor0().map(Qa)(i))(r.pure(Zr("Done",void 0))))(u=>r.pure((()=>{if(u.tag==="Loop")return Zr("Loop",Ot("Cons",u._1,o));if(u.tag==="Done")return Zr("Done",(s=>a=>{let c=s,f=a,d=!0,l;for(;d;){const _=c,h=f;if(h.tag==="Nil"){d=!1,l=_;continue}if(h.tag==="Cons"){c=Ot("Cons",h._1,_),f=h._2;continue}g()}return l})(qt)(o));g()})())))(qt)})({tailRecM:t=>e=>(n,r,i,o,u)=>{const s=(a,c,f)=>t(c)(a,r,i,o,(d,l)=>{const _=a._3&&!d._3?A(d._1,d._2,!0):d;if(l.tag==="Loop")return f===0?r(h=>s(_,l._1,30)):s(_,l._1,f-1|0);if(l.tag==="Done")return u(_,l._1);g()});return s(n,e,30)},Monad0:()=>tv})(nv),Gt=t=>e=>{const n=du("Expected "+e);return(r,i,o,u,s)=>{const a=r._1,c=r._2;return i(f=>t(A(a,c,!1),i,o,(d,l)=>{const _=d._3;return i(h=>_?u(d,l):n(r,i,o,u,s))},s))}},ha=t=>(e,n,r,i,o)=>{const u=e._3,s=e._1,a=e._2;return n(c=>{const f=(d,l)=>{const _=d._3;return n(h=>_?i(A(d._1,d._2,u),l):o(e,void 0))};return n(d=>n(l=>t(A(s,a,!1),n,r,(_,h)=>f(A(_._1,_._2,!1),h),(_,h)=>n(m=>n(p=>du("Negated parser succeeded")(_,n,r,f,(y,x)=>n(N=>o(_._3&&!y._3?A(y._1,y._2,!0):y,x))))))))})},rv=t=>{const e=t.foldr(n=>r=>{if(r.tag==="Nothing")return w("Just",n);if(r.tag==="Just")return w("Just",(i,o,u,s,a)=>{const c=i._1,f=i._2;return o(d=>n(A(c,f,!1),o,u,(l,_)=>{const h=l._3;return o(m=>h?s(l,_):r._1(i,o,u,s,a))},a))});g()})(T);return n=>{const r=e(n);if(r.tag==="Nothing")return du("No alternative");if(r.tag==="Just")return r._1;g()}},iv=t=>e=>n=>(r,i,o,u,s)=>i(a=>i(c=>i(f=>i(d=>t(r,i,o,u,(l,_)=>i(h=>i(m=>{const p=r._3&&!l._3?A(l._1,l._2,!0):l;return n(p,i,o,u,(y,x)=>i(N=>{const v=p._3&&!y._3?A(y._1,y._2,!0):y;return i(k=>i(L=>{const E=r._3&&!v._3?A(v._1,v._2,!0):v;return e(E,i,o,u,(B,V)=>i(et=>s(E._3&&!B._3?A(B._1,B._2,!0):B,x)))}))}))}))))))),pa=t=>e=>n=>{if(e===10)return{index:t.index+1|0,line:t.line+1|0,column:1};if(e===13){const r=Nh()(n);return r.tag==="Just"&&r._1===10?{index:t.index+1|0,line:t.line,column:t.column}:{index:t.index+1|0,line:t.line+1|0,column:1}}return e===9?{index:t.index+1|0,line:t.line,column:(t.column+8|0)-Yn(t.column-1|0)(8)|0}:{index:t.index+1|0,line:t.line,column:t.column+1|0}},ov=t=>e=>n=>{let r=t,i=e,o=n,u=!0,s;for(;u;){const a=r,c=i,f=o,d=ho(c);if(d.tag==="Nothing"){u=!1,s=a;continue}if(d.tag==="Just"){r=d._1.tail===""?pa(a)(d._1.head)(f):pa(a)(d._1.head)(d._1.tail),i=d._1.tail,o=f;continue}g()}return s},jt=t=>(e,n,r,i,o)=>{const u=ho(e._1);if(u.tag==="Nothing")return i(e,Vr("Unexpected EOF",e._2));if(u.tag==="Just"){if(u._1.head<0||u._1.head>65535)return i(e,Vr("Expected Char",e._2));if(u._1.head>=0&&u._1.head<=65535){const s=Tc(u._1.head);return t(s)?o(A(u._1.tail,pa(e._2)(u._1.head)(u._1.tail),!0),s):i(e,Vr("Predicate unsatisfied",e._2))}}g()},ma=(t,e,n,r,i)=>t._1===""?i(A(t._1,t._2,!0),void 0):r(t,Vr("Expected EOF",t._2)),uv=t=>(e,n,r,i,o)=>{const u=t(e._1);if(u.tag==="Left")return i(e,Vr(u._1,e._2));if(u.tag==="Right")return o(A(u._1.remainder,ov(e._2)(u._1.consumed)(u._1.remainder),u._1.consumed!==""),u._1.value);g()},Xr=t=>uv(e=>{const n=ul(t)(e);return n.tag==="Just"?St("Right",{value:t,consumed:t,remainder:n._1}):St("Left","Expected "+v1(t))}),sv=jt(t=>!0),f1=(t,e)=>({tag:t,_1:e}),av=Kt(C)(Bt),cv=t=>e=>{let n=e,r=!0,i;for(;r;){const o=n;if(o.tag==="Leaf"){r=!1,i=T;continue}if(o.tag==="Node"){const u=C.compare(t)(o._3);if(u==="LT"){n=o._5;continue}if(u==="GT"){n=o._6;continue}if(u==="EQ"){r=!1,i=w("Just",o._4);continue}}g()}return i},_1=rv(Bt),d1=(()=>{const t=jt(e=>e===" "||e===" "||e===`
|
|
9
|
+
`||e==="\r");return(e,n,r,i,o)=>n(u=>t(e,n,r,i,(s,a)=>n(c=>o(e._3&&!s._3?A(s._1,s._2,!0):s,void 0))))})(),ya=(t,e,n,r,i)=>e(o=>Xr("#")(t,e,n,r,(u,s)=>e(a=>{const c=on(jt(d=>d!==`
|
|
10
|
+
`)),f=t._3&&!u._3?A(u._1,u._2,!0):u;return e(d=>c(f,e,n,r,(l,_)=>e(h=>i(f._3&&!l._3?A(l._1,l._2,!0):l,void 0))))}))),gv=Gt((()=>{const t=Gt(jt(n=>n==="}"))("'}'"),e=jt(n=>n===`
|
|
11
|
+
`||n==="\r");return(n,r,i,o,u)=>{const s=n._1,a=n._2;return r(c=>r(f=>t(A(s,a,!1),r,i,(d,l)=>r(_=>{const h=n._1,m=n._2;return r(p=>r(y=>ya(A(h,m,!1),r,i,(x,N)=>{const v=x._3;return r(k=>{if(v)return o(x,N);const L=n._1,E=n._2;return r(B=>r(V=>e(A(L,E,!1),r,i,(et,D)=>{const S=et._3;return r(Z=>S?o(et,D):ma(n,r,i,o,u))},(et,D)=>r(S=>u(et,void 0)))))})},(x,N)=>r(v=>u(x,void 0)))))}),(d,l)=>r(_=>u(A(s,a,!1),void 0)))))}})())("newline or '}' (statements end at the end of the line)"),Ue=(()=>{const t=on((e,n,r,i,o)=>{const u=e._1,s=e._2;return n(a=>d1(A(u,s,!1),n,r,(c,f)=>{const d=c._3;return n(l=>d?i(c,f):ya(e,n,r,i,o))},o))});return(e,n,r,i,o)=>n(u=>t(e,n,r,i,(s,a)=>n(c=>o(e._3&&!s._3?A(s._1,s._2,!0):s,void 0))))})(),cn=(t,e,n,r,i)=>e(o=>{const u=(c,f)=>e(d=>Ue(t._3&&!c._3?A(c._1,c._2,!0):c,e,n,r,i)),s=t._1,a=t._2;return e(c=>d1(A(s,a,!1),e,n,(f,d)=>{const l=f._3;return e(_=>l?r(f,d):ya(t,e,n,r,u))},u))}),l1=(()=>{const t=Gt(jt(e=>e==="|"))("'|'");return(e,n,r,i,o)=>n(u=>t(e,n,r,i,(s,a)=>n(c=>{const f=on(jt(l=>l!=="|")),d=e._3&&!s._3?A(s._1,s._2,!0):s;return n(l=>f(d,n,r,i,(_,h)=>n(m=>{const p=Gt(Gt(jt(x=>x==="|"))("'|'"))("closing '|'"),y=d._3&&!_._3?A(_._1,_._2,!0):_;return n(x=>p(y,n,r,i,(N,v)=>n(k=>o(y._3&&!N._3?A(N._1,N._2,!0):N,cr(kt($t.foldr,h))))))})))})))})(),lu=jt(t=>t>="a"&&t<="z"||t>="A"&&t<="Z"),He=(()=>{const t=on(jt(e=>e===" "||e===" "));return(e,n,r,i,o)=>n(u=>t(e,n,r,i,(s,a)=>n(c=>o(e._3&&!s._3?A(s._1,s._2,!0):s,void 0))))})(),fv=(()=>{const t=Gt(jt(e=>e==="\\"))("'\\\\'");return(e,n,r,i,o)=>n(u=>t(e,n,r,i,(s,a)=>n(c=>{const f=e._3&&!s._3?A(s._1,s._2,!0):s;return n(d=>sv(f,n,r,i,(l,_)=>n(h=>o(f._3&&!l._3?A(l._1,l._2,!0):l,_==="n"?`
|
|
12
|
+
`:_==="t"?" ":_==="r"?"\r":_))))})))})(),_v=(()=>{const t=jt(e=>e!=='"'&&e!=="\\"&&e!==`
|
|
13
|
+
`);return(e,n,r,i,o)=>{const u=e._1,s=e._2;return n(a=>fv(A(u,s,!1),n,r,(c,f)=>n(d=>t(e,n,r,i,o)),o))}})(),xa=(()=>{const t=Gt(jt(e=>e==='"'))(`'"'`);return(e,n,r,i,o)=>n(u=>t(e,n,r,i,(s,a)=>n(c=>{const f=on(_v),d=e._3&&!s._3?A(s._1,s._2,!0):s;return n(l=>f(d,n,r,i,(_,h)=>n(m=>{const p=Gt(Gt(jt(x=>x==='"'))(`'"'`))(`closing '"' (unterminated string)`),y=d._3&&!_._3?A(_._1,_._2,!0):_;return n(x=>p(y,n,r,i,(N,v)=>n(k=>o(y._3&&!N._3?A(N._1,N._2,!0):N,cr(kt($t.foldr,h))))))})))})))})(),dv=(()=>{const t=Gt(jt(e=>e===":"))("':'");return(e,n,r,i,o)=>n(u=>He(e,n,r,i,(s,a)=>n(c=>Gt((f,d,l,_,h)=>{const m=f._1,p=f._2;return d(y=>{const x=(N,v)=>{const k=N._3;return d(L=>{if(k)return _(N,v);const E=f._1,B=f._2;return d(V=>l1(A(E,B,!1),d,l,(et,D)=>{const S=et._3;return d(Z=>S?_(et,D):xa(f,d,l,_,h))},h))})};return d(N=>t(A(m,p,!1),d,l,x,(v,k)=>d(L=>d(E=>He(v,d,l,x,(B,V)=>d(et=>{const D=on(jt(Z=>Z!==`
|
|
14
|
+
`&&Z!=="\r"&&Z!=="#"&&Z!=="}")),S=v._3&&!B._3?A(B._1,B._2,!0):B;return d(Z=>D(S,d,l,x,(X,W)=>d(z=>h(S._3&&!X._3?A(X._1,X._2,!0):X,ah(cr(kt($t.foldr,W)))))))}))))))})})('label ("\u2026", : rest-of-line, or |\u2026|)')(e._3&&!s._3?A(s._1,s._2,!0):s,n,r,i,o))))})(),lv=(t,e,n,r,i)=>{const o=t._1,u=t._2;return e(s=>l1(A(o,u,!1),e,n,(a,c)=>{const f=a._3;return e(d=>f?r(a,c):xa(t,e,n,r,i))},i))},Hi=jt(t=>t>="0"&&t<="9"),be=(()=>{const t=Gt(jt(e=>e==="_"))("'_'");return(e,n,r,i,o)=>n(u=>{const s=(f,d)=>n(l=>{const _=on((()=>{const m=Gt(jt(y=>y==="_"))("'_'"),p=Gt(jt(y=>y==="-"))("'-'");return(y,x,N,v,k)=>{const L=y._1,E=y._2;return x(B=>lu(A(L,E,!1),x,N,(V,et)=>{const D=V._3;return x(S=>{if(D)return v(V,et);const Z=y._1,X=y._2;return x(W=>Hi(A(Z,X,!1),x,N,(z,M)=>{const G=z._3;return x(P=>{if(G)return v(z,M);const I=y._1,F=y._2;return x(O=>m(A(I,F,!1),x,N,(Y,q)=>{const $=Y._3;return x(R=>$?v(Y,q):p(y,x,N,v,k))},k))})},k))})},k))}})()),h=e._3&&!f._3?A(f._1,f._2,!0):f;return n(m=>_(h,n,r,i,(p,y)=>n(x=>o(h._3&&!p._3?A(p._1,p._2,!0):p,ro(d)+cr(kt($t.foldr,y))))))}),a=e._1,c=e._2;return n(f=>lu(A(a,c,!1),n,r,(d,l)=>{const _=d._3;return n(h=>_?i(d,l):t(e,n,r,i,s))},s))})})(),hv=Gt((t,e,n,r,i)=>{const o=t._1,u=t._2;return e(s=>xa(A(o,u,!1),e,n,(a,c)=>{const f=a._3;return e(d=>f?r(a,c):be(t,e,n,r,i))},i))})("frame name (identifier or quoted string)"),h1=(t,e,n,r,i)=>e(o=>He(t,e,n,r,(u,s)=>e(a=>{const c=Gt(be)("attribute key"),f=t._3&&!u._3?A(u._1,u._2,!0):u;return e(d=>c(f,e,n,r,(l,_)=>e(h=>{const m=f._3&&!l._3?A(l._1,l._2,!0):l;return e(p=>He(m,e,n,r,(y,x)=>e(N=>{const v=Gt(Gt(jt(L=>L===":"))("':'"))("':'"),k=m._3&&!y._3?A(y._1,y._2,!0):y;return e(L=>v(k,e,n,r,(E,B)=>e(V=>{const et=k._3&&!E._3?A(E._1,E._2,!0):E;return e(D=>He(et,e,n,r,(S,Z)=>e(X=>{const W=Gt(be)("attribute value"),z=et._3&&!S._3?A(S._1,S._2,!0):S;return e(M=>W(z,e,n,r,(G,P)=>e(I=>{const F=z._3&&!G._3?A(G._1,G._2,!0):G;return e(O=>He(F,e,n,r,(Y,q)=>e($=>i(F._3&&!Y._3?A(Y._1,Y._2,!0):Y,b(_,P)))))})))})))})))})))})))}))),pv=(t,e,n,r,i)=>e(o=>be(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?A(u._1,u._2,!0):u;return e(f=>He(c,e,n,r,(d,l)=>e(_=>{const h=Gt((p,y,x,N,v)=>{const k=p._1,L=p._2;return y(E=>Xr("->")(A(k,L,!1),y,x,(B,V)=>{const et=B._3;return y(D=>et?N(B,V):Xr("<-")(p,y,x,N,v))},v))})("'->' or '<-'"),m=c._3&&!d._3?A(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?A(y._1,y._2,!0):y;return e(k=>He(v,e,n,r,(L,E)=>e(B=>{const V=Gt(be)("target node identifier"),et=v._3&&!L._3?A(L._1,L._2,!0):L;return e(D=>V(et,e,n,r,(S,Z)=>e(X=>{const W=on((M,G,P,I,F)=>{const O=M._3;return G(Y=>G(q=>He(M,G,P,($,R)=>I(A($._1,$._2,O),R),($,R)=>G(tt=>G(K=>{const gt=M._3&&!$._3?A($._1,$._2,!0):$;return lv(gt,G,P,(_t,at)=>I(A(_t._1,_t._2,O),at),(_t,at)=>G(yt=>F(gt._3&&!_t._3?A(_t._1,_t._2,!0):_t,at)))})))))}),z=et._3&&!S._3?A(S._1,S._2,!0):S;return e(M=>W(z,e,n,r,(G,P)=>e(I=>(()=>{if(x==="<-"){const O=Mn("Token",{from:Z,to:s,labels:H(ac)(kt($t.foldr,P))});return(Y,q,$,R,tt)=>tt(Y,O)}const F=Mn("Token",{from:s,to:Z,labels:H(ac)(kt($t.foldr,P))});return(O,Y,q,$,R)=>R(O,F)})()(z._3&&!G._3?A(G._1,G._2,!0):G,e,n,r,i))))})))})))})))})))}))),mv=(t,e,n,r,i)=>e(o=>Hi(t,e,n,r,(u,s)=>e(a=>{const c=on(Hi),f=t._3&&!u._3?A(u._1,u._2,!0):u;return e(d=>c(f,e,n,r,(l,_)=>e(h=>{const m=_d(ro(s)+cr(kt($t.foldr,_)));return(()=>{if(m.tag==="Just"){const p=m._1;return(y,x,N,v,k)=>k(y,p)}if(m.tag==="Nothing")return(p,y,x,N,v)=>v(p,0);g()})()(f._3&&!l._3?A(l._1,l._2,!0):l,e,n,r,i)})))}))),Oi=t=>(e,n,r,i,o)=>{const u=e._3;return n(s=>Xr(t)(e,n,r,(a,c)=>i(A(a._1,a._2,u),c),(a,c)=>n(f=>{const d=ha((()=>{const _=Gt(jt(m=>m==="_"))("'_'"),h=Gt(jt(m=>m==="-"))("'-'");return(m,p,y,x,N)=>{const v=m._1,k=m._2;return p(L=>lu(A(v,k,!1),p,y,(E,B)=>{const V=E._3;return p(et=>{if(V)return x(E,B);const D=m._1,S=m._2;return p(Z=>Hi(A(D,S,!1),p,y,(X,W)=>{const z=X._3;return p(M=>{if(z)return x(X,W);const G=m._1,P=m._2;return p(I=>_(A(G,P,!1),p,y,(F,O)=>{const Y=F._3;return p(q=>Y?x(F,O):h(m,p,y,x,N))},N))})},N))})},N))}})()),l=e._3&&!a._3?A(a._1,a._2,!0):a;return n(_=>d(l,n,r,(h,m)=>i(A(h._1,h._2,u),m),(h,m)=>n(p=>{const y=l._3&&!h._3?A(h._1,h._2,!0):h;return n(x=>Ue(y,n,r,(N,v)=>i(A(N._1,N._2,u),v),(N,v)=>n(k=>o(y._3&&!N._3?A(N._1,N._2,!0):N,t))))})))})))},yv=(t,e,n,r,i)=>e(o=>cn(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?A(u._1,u._2,!0):u;return e(f=>Oi("via")(c,e,n,r,(d,l)=>e(_=>{const h=c._3&&!d._3?A(d._1,d._2,!0):d;return e(m=>be(h,e,n,r,(p,y)=>e(x=>{const N=h._3&&!p._3?A(p._1,p._2,!0):p;return e(v=>cn(N,e,n,r,(k,L)=>e(E=>{const B=N._3&&!k._3?A(k._1,k._2,!0):k;return e(V=>be(B,e,n,r,(et,D)=>e(S=>i(B._3&&!et._3?A(et._1,et._2,!0):et,{from:y,to:D}))))})))})))})))}))),nr=t=>(e,n,r,i,o)=>{const u=e._3;return n(s=>Xr(t)(e,n,r,(a,c)=>i(A(a._1,a._2,u),c),(a,c)=>n(f=>{const d=ha((()=>{const _=Gt(jt(m=>m==="_"))("'_'"),h=Gt(jt(m=>m==="-"))("'-'");return(m,p,y,x,N)=>{const v=m._1,k=m._2;return p(L=>lu(A(v,k,!1),p,y,(E,B)=>{const V=E._3;return p(et=>{if(V)return x(E,B);const D=m._1,S=m._2;return p(Z=>Hi(A(D,S,!1),p,y,(X,W)=>{const z=X._3;return p(M=>{if(z)return x(X,W);const G=m._1,P=m._2;return p(I=>_(A(G,P,!1),p,y,(F,O)=>{const Y=F._3;return p(q=>Y?x(F,O):h(m,p,y,x,N))},N))})},N))})},N))}})()),l=e._3&&!a._3?A(a._1,a._2,!0):a;return n(_=>d(l,n,r,(h,m)=>i(A(h._1,h._2,u),m),(h,m)=>n(p=>o(l._3&&!h._3?A(h._1,h._2,!0):h,void 0))))})))},xv=(t,e,n,r,i)=>e(o=>nr("+edge")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?A(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Gt(be)("source node identifier"),m=c._3&&!d._3?A(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?A(y._1,y._2,!0):y;return e(k=>cn(v,e,n,r,(L,E)=>e(B=>{const V=Gt(be)("target node identifier"),et=v._3&&!L._3?A(L._1,L._2,!0):L;return e(D=>V(et,e,n,r,(S,Z)=>e(X=>i(et._3&&!S._3?A(S._1,S._2,!0):S,Mn("AddEdge",{from:x,to:Z})))))})))})))})))}))),Nv=(t,e,n,r,i)=>e(o=>nr("-edge")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?A(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Gt(be)("source node identifier"),m=c._3&&!d._3?A(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?A(y._1,y._2,!0):y;return e(k=>cn(v,e,n,r,(L,E)=>e(B=>{const V=Gt(be)("target node identifier"),et=v._3&&!L._3?A(L._1,L._2,!0):L;return e(D=>V(et,e,n,r,(S,Z)=>e(X=>i(et._3&&!S._3?A(S._1,S._2,!0):S,Mn("DelEdge",{from:x,to:Z})))))})))})))})))}))),Jv=(t,e,n,r,i)=>e(o=>nr("-node")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?A(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Gt(be)("node identifier"),m=c._3&&!d._3?A(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=on((L,E,B,V,et)=>{const D=L._3;return yv(L,E,B,(S,Z)=>V(A(S._1,S._2,D),Z),et)}),k=m._3&&!y._3?A(y._1,y._2,!0):y;return e(L=>v(k,e,n,r,(E,B)=>e(V=>i(k._3&&!E._3?A(E._1,E._2,!0):E,Mn("DelNode",{id:x,via:kt($t.foldr,B)})))))})))})))}))),Tv=(t,e,n,r,i)=>e(o=>nr("enter")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?A(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Gt(be)("node identifier"),m=c._3&&!d._3?A(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>i(m._3&&!y._3?A(y._1,y._2,!0):y,Mn("Enter",{id:x})))))})))}))),vv=(t,e,n,r,i)=>e(o=>nr("exit")(t,e,n,r,(u,s)=>e(a=>i(t._3&&!u._3?A(u._1,u._2,!0):u,vT)))),wv=(t,e,n,r,i)=>e(o=>nr("~edge")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?A(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Gt(be)("source node identifier"),m=c._3&&!d._3?A(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?A(y._1,y._2,!0):y;return e(k=>cn(v,e,n,r,(L,E)=>e(B=>{const V=Gt(be)("target node identifier"),et=v._3&&!L._3?A(L._1,L._2,!0):L;return e(D=>V(et,e,n,r,(S,Z)=>e(X=>{const W=et._3&&!S._3?A(S._1,S._2,!0):S;return e(z=>Ue(W,e,n,r,(M,G)=>e(P=>{const I=Gt(Xr("->"))("'->'"),F=W._3&&!M._3?A(M._1,M._2,!0):M;return e(O=>I(F,e,n,r,(Y,q)=>e($=>{const R=F._3&&!Y._3?A(Y._1,Y._2,!0):Y;return e(tt=>Ue(R,e,n,r,(K,gt)=>e(_t=>{const at=Gt(be)("new source node identifier"),yt=R._3&&!K._3?A(K._1,K._2,!0):K;return e(Et=>at(yt,e,n,r,(At,pt)=>e(Mt=>{const Jt=yt._3&&!At._3?A(At._1,At._2,!0):At;return e(mt=>cn(Jt,e,n,r,(nt,U)=>e(ut=>{const ft=Gt(be)("new target node identifier"),lt=Jt._3&&!nt._3?A(nt._1,nt._2,!0):nt;return e(Nt=>ft(lt,e,n,r,(Ht,Vt)=>e(De=>i(lt._3&&!Ht._3?A(Ht._1,Ht._2,!0):Ht,Mn("RepointEdge",{from:x,to:Z,newFrom:pt,newTo:Vt})))))})))})))})))})))})))})))})))})))})))}))),bv=(t,e,n,r,i)=>e(o=>nr("seed")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?A(u._1,u._2,!0):u;return e(f=>He(c,e,n,r,(d,l)=>e(_=>{const h=Gt(mv)("integer (seed value)"),m=c._3&&!d._3?A(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?A(y._1,y._2,!0):y;return e(k=>Ue(v,e,n,r,(L,E)=>e(B=>i(v._3&&!L._3?A(L._1,L._2,!0):L,x))))})))})))}))),qi=iv((()=>{const t=Gt(jt(e=>e==="{"))("'{'");return(e,n,r,i,o)=>n(u=>n(s=>t(e,n,r,i,(a,c)=>n(f=>n(d=>{const l=e._3&&!a._3?A(a._1,a._2,!0):a;return Ue(l,n,r,i,(_,h)=>n(m=>o(l._3&&!_._3?A(_._1,_._2,!0):_,h)))})))))})())(Gt((()=>{const t=Gt(jt(e=>e==="}"))("'}'");return(e,n,r,i,o)=>n(u=>n(s=>Ue(e,n,r,i,(a,c)=>n(f=>n(d=>{const l=e._3&&!a._3?A(a._1,a._2,!0):a;return t(l,n,r,i,(_,h)=>n(m=>o(l._3&&!_._3?A(_._1,_._2,!0):_,h)))})))))})())("closing '}'")),Lv=qi((t,e,n,r,i)=>e(o=>{const u=(c,f)=>e(d=>(()=>{if(f.tag==="Nothing")return(l,_,h,m,p)=>p(l,Q);if(f.tag==="Just"){const l=f._1,_=on((()=>{const h=Gt(jt(m=>m===","))("','");return(m,p,y,x,N)=>{const v=m._3;return p(k=>p(L=>p(E=>p(B=>p(V=>p(et=>He(m,p,y,(D,S)=>x(A(D._1,D._2,v),S),(D,S)=>p(Z=>p(X=>{const W=m._3&&!D._3?A(D._1,D._2,!0):D;return h(W,p,y,(z,M)=>x(A(z._1,z._2,v),M),(z,M)=>p(G=>{const P=W._3&&!z._3?A(z._1,z._2,!0):z;return p(I=>p(F=>{const O=m._3&&!P._3?A(P._1,P._2,!0):P;return He(O,p,y,(Y,q)=>x(A(Y._1,Y._2,v),q),(Y,q)=>p($=>{const R=O._3&&!Y._3?A(Y._1,Y._2,!0):Y;return p(tt=>p(K=>{const gt=m._3&&!R._3?A(R._1,R._2,!0):R;return h1(gt,p,y,(_t,at)=>x(A(_t._1,_t._2,v),at),(_t,at)=>p(yt=>N(gt._3&&!_t._3?A(_t._1,_t._2,!0):_t,at)))}))}))}))}))})))))))))}})());return(h,m,p,y,x)=>m(N=>_(h,m,p,y,(v,k)=>m(L=>x(h._3&&!v._3?A(v._1,v._2,!0):v,av([l,...kt($t.foldr,k)])))))}g()})()(t._3&&!c._3?A(c._1,c._2,!0):c,e,n,r,i)),s=t._1,a=t._2;return e(c=>e(f=>h1(A(s,a,!1),e,n,(d,l)=>e(_=>u(t,T)),(d,l)=>e(_=>u(d,w("Just",l))))))})),kv=(t,e,n,r,i)=>e(o=>nr("+node")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?A(u._1,u._2,!0):u;return e(f=>cn(c,e,n,r,(d,l)=>e(_=>{const h=Gt(be)("node identifier"),m=c._3&&!d._3?A(d._1,d._2,!0):d;return e(p=>h(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?A(y._1,y._2,!0):y;return e(k=>e(L=>He(v,e,n,r,(E,B)=>e(V=>{const et=jt(S=>S===`
|
|
15
|
+
`||S==="\r"||S==="#"||S==="}"||S==="{"),D=v._3&&!E._3?A(E._1,E._2,!0):E;return e(S=>{const Z=(z,M)=>e(G=>(M?((P,I,F,O,Y)=>Y(P,"")):dv)(D._3&&!z._3?A(z._1,z._2,!0):z,e,n,r,(P,I)=>e(F=>{const O=v._3&&!P._3?A(P._1,P._2,!0):P;return e(Y=>{const q=(tt,K)=>e(gt=>i(O._3&&!tt._3?A(tt._1,tt._2,!0):tt,Mn("AddNode",{id:x,label:I,shape:(()=>{const _t=cv("shape")(K);if(_t.tag==="Just")return _t._1==="rectangle"||_t._1==="rect"?Un:_t._1==="cylinder"||_t._1==="cyl"?yl:_t._1==="parallelogram"?xl:_t._1==="diamond"?Nl:_t._1==="ellipse"?Jl:_t._1==="document"||_t._1==="doc"?Tl:_t._1==="cloud"?vl:Un;if(_t.tag==="Nothing")return Un;g()})()}))),$=O._1,R=O._2;return e(tt=>{const K=(gt,_t)=>{const at=gt._3;return e(yt=>at?r(gt,_t):q(O,Q))};return e(gt=>e(_t=>He(A($,R,!1),e,n,(at,yt)=>K(A(at._1,at._2,!1),yt),(at,yt)=>e(Et=>e(At=>Lv(at,e,n,(pt,Mt)=>K(A(pt._1,pt._2,!1),Mt),(pt,Mt)=>e(Jt=>q(at._3&&!pt._3?A(pt._1,pt._2,!0):pt,Mt))))))))})})}))),X=D._1,W=D._2;return e(z=>{const M=(G,P)=>{const I=G._3;return e(F=>I?r(G,P):Z(D,!1))};return e(G=>e(P=>e(I=>ma(A(X,W,!1),e,n,(F,O)=>{const Y=F._3;return e(q=>Y?M(A(X,W,!1),O):e($=>et(A(X,W,!1),e,n,(R,tt)=>M(A(X,W,!1),tt),(R,tt)=>e(K=>e(gt=>Z(A(X,W,!1),!0))))))},(F,O)=>e(Y=>e(q=>Z(A(X,W,!1),!0)))))))})})}))))})))})))}))),Ev=(t,e,n,r,i)=>e(o=>a1(t,e,n,r,(u,s)=>e(a=>{const c=Gt(_1([kv,Jv,wv,xv,Nv,Tv,vv,pv]))("statement (+node, -node, +edge, -edge, ~edge, enter, exit, or 'a -> b')"),f=t._3&&!u._3?A(u._1,u._2,!0):u;return e(d=>c(f,e,n,r,(l,_)=>e(h=>i(f._3&&!l._3?A(l._1,l._2,!0):l,la("Leaf",{op:_,line:s.line,column:s.column})))))}))),Gv=(t,e,n,r,i)=>e(o=>Oi("seq")(t,e,n,r,(u,s)=>e(a=>qi(Na(n1))(t._3&&!u._3?A(u._1,u._2,!0):u,e,n,r,i)))),Cv=(t,e,n,r,i)=>e(o=>Oi("par")(t,e,n,r,(u,s)=>e(a=>qi(Na(wT))(t._3&&!u._3?A(u._1,u._2,!0):u,e,n,r,i)))),Na=t=>{const e=on(Sv());return(n,r,i,o,u)=>r(s=>e(n,r,i,o,(a,c)=>r(f=>u(n._3&&!a._3?A(a._1,a._2,!0):a,t(kt($t.foldr,c))))))},Sv=ka(()=>{const t=ha(Gt(jt(e=>e==="}"))("'}'"));return(e,n,r,i,o)=>n(u=>{const s=e._3;return n(a=>n(c=>Ue(e,n,r,(f,d)=>i(A(f._1,f._2,s),d),(f,d)=>n(l=>n(_=>{const h=e._3&&!f._3?A(f._1,f._2,!0):f;return t(h,n,r,(m,p)=>i(A(m._1,m._2,s),p),(m,p)=>n(y=>{const x=h._3&&!m._3?A(m._1,m._2,!0):m;return n(N=>{const v=_1([(L,E,B,V,et)=>{const D=L._3;return Cv(L,E,B,(S,Z)=>V(A(S._1,S._2,D),Z),et)},(L,E,B,V,et)=>{const D=L._3;return Gv(L,E,B,(S,Z)=>V(A(S._1,S._2,D),Z),et)},Ev]),k=e._3&&!x._3?A(x._1,x._2,!0):x;return n(L=>v(k,n,r,i,(E,B)=>n(V=>{const et=k._3&&!E._3?A(E._1,E._2,!0):E;return n(D=>He(et,n,r,i,(S,Z)=>n(X=>{const W=et._3&&!S._3?A(S._1,S._2,!0):S;return n(z=>gv(W,n,r,i,(M,G)=>n(P=>o(W._3&&!M._3?A(M._1,M._2,!0):M,B))))})))})))})}))})))))})}),Dv=(t,e,n,r,i)=>e(o=>Oi("frame")(t,e,n,r,(u,s)=>e(a=>{const c=t._3&&!u._3?A(u._1,u._2,!0):u;return e(f=>hv(c,e,n,r,(d,l)=>e(_=>{const h=c._3&&!d._3?A(d._1,d._2,!0):d;return e(m=>Ue(h,e,n,r,(p,y)=>e(x=>{const N=qi(Na(n1)),v=h._3&&!p._3?A(p._1,p._2,!0):p;return e(k=>N(v,e,n,r,(L,E)=>e(B=>{const V=v._3&&!L._3?A(L._1,L._2,!0):L;return e(et=>Ue(V,e,n,r,(D,S)=>e(Z=>i(V._3&&!D._3?A(D._1,D._2,!0):D,{name:w("Just",l),ops:E}))))})))})))})))}))),Pv=(t,e,n,r,i)=>e(o=>Oi("inside")(t,e,n,r,(u,s)=>e(a=>{const c=Gt(be)("node identifier"),f=t._3&&!u._3?A(u._1,u._2,!0):u;return e(d=>c(f,e,n,r,(l,_)=>e(h=>{const m=f._3&&!l._3?A(l._1,l._2,!0):l;return e(p=>Ue(m,e,n,r,(y,x)=>e(N=>{const v=m._3&&!y._3?A(y._1,y._2,!0):y;return e(k=>qi(p1)(v,e,n,r,(L,E)=>e(B=>{const V=v._3&&!L._3?A(L._1,L._2,!0):L;return e(et=>Ue(V,e,n,r,(D,S)=>e(Z=>i(V._3&&!D._3?A(D._1,D._2,!0):D,{node:_,doc:E}))))})))})))})))}))),p1=(t,e,n,r,i)=>e(o=>{const u=(c,f)=>e(d=>{const l=on(Iv()),_=t._3&&!c._3?A(c._1,c._2,!0):c;return e(h=>l(_,e,n,r,(m,p)=>e(y=>{const x=kt($t.foldr,p);return i(_._3&&!m._3?A(m._1,m._2,!0):m,{seed:(()=>{if(f.tag==="Nothing")return 0;if(f.tag==="Just")return f._1;g()})(),frames:xt(N=>{if(N.tag==="TopFrame")return w("Just",N._1);if(N.tag==="TopInside")return T;g()})(x),interiors:xt(N=>{if(N.tag==="TopInside")return w("Just",N._1);if(N.tag==="TopFrame")return T;g()})(x)})})))}),s=t._1,a=t._2;return e(c=>e(f=>bv(A(s,a,!1),e,n,(d,l)=>{const _=d._3;return e(h=>_?r(d,l):u(t,T))},(d,l)=>e(_=>u(d,w("Just",l))))))}),Iv=ka(()=>VT.defer(t=>(e,n,r,i,o)=>{const u=e._1,s=e._2;return n(a=>n(c=>Pv(A(u,s,!1),n,r,(f,d)=>n(l=>n(_=>Dv(e,n,r,i,(h,m)=>n(p=>o(h,f1("TopFrame",m)))))),(f,d)=>n(l=>o(f,f1("TopInside",d))))))})),Qv=(()=>{const t=Gt((e,n,r,i,o)=>n(u=>n(s=>Ue(e,n,r,i,(a,c)=>n(f=>n(d=>{const l=e._3&&!a._3?A(a._1,a._2,!0):a;return ma(l,n,r,i,(_,h)=>n(m=>o(l._3&&!_._3?A(_._1,_._2,!0):_,h)))}))))))("'frame', 'inside', or end of input");return(e,n,r,i,o)=>n(u=>n(s=>n(a=>n(c=>Ue(e,n,r,i,(f,d)=>n(l=>n(_=>{const h=e._3&&!f._3?A(f._1,f._2,!0):f;return p1(h,n,r,i,(m,p)=>n(y=>{const x=h._3&&!m._3?A(m._1,m._2,!0):m;return n(N=>n(v=>{const k=e._3&&!x._3?A(x._1,x._2,!0):x;return t(k,n,r,i,(L,E)=>n(B=>o(k._3&&!L._3?A(L._1,L._2,!0):L,p)))}))}))})))))))})(),Fv=t=>{const e=ZT(t)(Qv);if(e.tag==="Left")return St("Left",{msg:e._1._1,line:e._1._2.line,column:e._1._2.column});if(e.tag==="Right")return St("Right",e._1);g()},Av=t=>{const e=Fv(t);if(e.tag==="Left")return St("Left",e._1.msg);if(e.tag==="Right")return St("Right",e._1);g()};function Ja(t,e,n,r){if(typeof window<"u"){var i=window[n];if(i!=null&&r instanceof i)return e(r)}for(var o=r;o!=null;){var u=Object.getPrototypeOf(o),s=u.constructor.name;if(s===n)return e(r);if(s==="Object")return t;o=u}return t}function Ur(t){return function(e){return function(n){return function(){n.setAttribute(t,e)}}}}function Mv(t){return function(e){return function(){return e.getAttribute(t)}}}const Bv=t=>{const e=Mv(t);return n=>{const r=e(n);return()=>{const i=r();return Ua(i,T,Yt)}}};function zv(t){return function(e){return function(){e.textContent=t}}}function Rv(t){return function(){return function(e){return t(e)()}}}function Wv(t){return function(e){return function(n){return function(r){return function(){return r.addEventListener(t,e,n)}}}}}const Hv=function(){return window};function Ov(t){return function(e){return function(){e.value=t}}}function qv(t){return function(){return t.valueAsNumber}}function $v(t){return function(){return t.value}}function Yv(t){return function(e){return function(){return e.requestAnimationFrame(t)}}}const Vv=t=>t,Xv=t=>()=>t.clientWidth||0,Uv=()=>window.devicePixelRatio||1,Ta=(t,e)=>{e.innerHTML=t},va=(t,e,n)=>{t.style.setProperty(e,n)},jv=(t,e)=>t.querySelector(`[data-mg="${e}"]`),Zv=t=>e=>t===e,Kv=t=>t,tw=(t,e,n)=>({tag:t,_1:e,_2:n}),ew=Bt.foldMap(Td),m1=t=>e=>{const n=st.compare(t)(e);if(n==="LT"||n==="EQ")return t;if(n==="GT")return e;g()},nw=t=>e=>{const n=st.compare(t)(e);if(n==="LT")return e;if(n==="EQ"||n==="GT")return t;g()},rw=tw("AutoSize"),iw=Kv("CanvasRenderer"),ow=t=>e=>{const n=t-e*rt(de(dn(t/e)));return e<=0?0:n<0?n+e:n},uw=t=>J(e=>n=>{const r=t(n);return()=>(e(),r())})(()=>{}),sw=t=>{const e=Bv("data-markgraf-titles")(t);return()=>{const n=e();return n.tag==="Nothing"||!(n.tag==="Just"&&n._1==="false")}},aw=`
|
|
16
16
|
<canvas data-mg="stage" tabindex="0"></canvas>
|
|
17
17
|
<div data-mg="play-overlay" aria-hidden="true"></div>
|
|
18
18
|
<div data-mg="bar">
|
|
@@ -29,4 +29,4 @@ var vw=(function(yu){"use strict";function ka(t){let e=0,n;return()=>{if(e===2)r
|
|
|
29
29
|
<option value="2">2\xD7</option>
|
|
30
30
|
</select>
|
|
31
31
|
</div>
|
|
32
|
-
`,
|
|
32
|
+
`,Rn=t=>e=>n=>()=>{const r=jv(t,e),i=Ua(r,T,Yt);if(i.tag==="Just")return n(i._1)();i.tag!=="Nothing"&&g()},cw=t=>e=>{const n=e.totalDuration<=0?1:e.totalDuration,r=ew(i=>'<span class="mg-tick" style="left:'+oi(ri("Fixed",ii(0)(20)(2)))(100*i.startT/n)+'%" data-label="'+(()=>{if(i.scene.tag==="Structural")return i.scene._1.to;if(i.scene.tag==="DataFlow")return i.scene._1.keyframe;if(i.scene.tag==="EnterNode"||i.scene.tag==="ExitNode")return"";g()})()+'"></span>')(e.spans);return Rn(t)("ticks")(i=>()=>Ta(r,i))},gw=t=>e=>n=>Rn(t)("scrub")(r=>{const i=Ja(T,Yt,"HTMLInputElement",r);if(i.tag==="Nothing")return()=>{};if(i.tag==="Just")return n<=0?()=>{}:Ov(ie(de($n(e/n*1e3))))(i._1);g()}),wa=t=>e=>n=>{const r=Rv(i=>n);return()=>{const i=r();return Wv(t)(i)(!1)(e)()}},y1=()=>Ed()/1e3,ba=t=>e=>n=>r=>i=>o=>u=>s=>a=>c=>{const f=Ye(u.layout),d=kl(u.layout),l={center:{x:d.x+d.w/2,y:f.y+f.h/2},zoom:Zu(u.layout)(f)(0)},_=Yu(u.layout)(l),h=()=>{const N=y1(),v=a.value;return a.value=N,v===0?0:N-v},m=V0(u)(m1(c)(u.totalDuration)),p=o?m:{...m,levels:H(N=>({...N,state:{...N.state,frameTitle:""}}))(m.levels)},y=u.dives.length===0&&(_.w+48)*1.0909090909090908<=1100&&(_.h+48)*1.0909090909090908<=1400,x=y?{...p,camera:l,levels:H(N=>({...N,state:{...N.state,camera:l}}))(p.levels)}:p;if(e==="CanvasRenderer")return()=>{const N=h(),v=Vv(t),k=Yr({padding:8,outputAspect:T})(x),L=(()=>{if(n.tag==="FixedSize")return{w:n._1,h:n._2};if(n.tag==="AutoSize"){if(y)return{w:k.vw*1.0909090909090908,h:k.vh*1.0909090909090908};const M=Xv(t)();return{w:M,h:k.vw<=0?M:M*k.vh/k.vw}}g()})(),E=Uv(),B=L.w*E,V=L.h*E,et=Cd(v)(),D=Sd(v)(),S=Dd(v)(B);et!==B&&S();const Z=Pd(v)(V);if(D!==V&&Z(),va(t,"height",ie(de($n(L.h)))+"px"),n.tag==="FixedSize")va(t,"width",ie(de($n(L.w)))+"px");else if(n.tag==="AutoSize"){const M=ie(de($n(L.w)))+"px";y&&va(t,"width",M)}else g();const X=Gd(v)();sr(X)(),Ki(X)({scaleX:E,scaleY:E})();const W=s.value,z=KJ(r)(i)(X)({width:L.w,height:L.h})(x)(N)(W)();return s.value=z,ar(X)()};if(e==="SvgRenderer")return()=>{const N=h(),v=s.value,k=pT((()=>{if(n.tag==="AutoSize")return T;if(n.tag==="FixedSize")return n._1<=0||n._2<=0?T:w("Just",n._1/n._2);g()})())(r)(i)(x)(N)(v);return s.value=k.springs,Ur("viewBox")(k.parts.viewBox)(t)(),Ur("preserveAspectRatio")("xMidYMid meet")(t)(),n.tag==="FixedSize"?(Ur("width")(ie(de($n(n._1))))(t)(),Ur("height")(ie(de($n(n._2))))(t)()):n.tag==="AutoSize"||g(),Ta(k.parts.body,t)};g()},x1=t=>{const e=Av(t);if(e.tag==="Left")return St("Left",e._1);if(e.tag==="Right"){const n=u1(e._1)(r1)._1;if(n.tag==="Left")return St("Left",n._1.msg);if(n.tag==="Right")return St("Right",n._1)}g()},fw=t=>{const e=x1(t);if(e.tag==="Left")return e._1;if(e.tag==="Right")return wd;g()},La=t=>e=>{const n=Zt(r=>r.startT<=e&&e<r.endT)(t.spans);if(n.tag==="Just"){if(n._1.scene.tag==="Structural")return n._1.scene._1.to;if(n._1.scene.tag==="DataFlow")return n._1.scene._1.keyframe;if(n._1.scene.tag==="EnterNode"||n._1.scene.tag==="ExitNode")return"";g()}if(n.tag==="Nothing"){const r=t.spans.length-1|0;if(r>=0&&r<t.spans.length){if(t.spans[r].scene.tag==="Structural")return t.spans[r].scene._1.to;if(t.spans[r].scene.tag==="DataFlow")return t.spans[r].scene._1.keyframe;if(t.spans[r].scene.tag==="EnterNode"||t.spans[r].scene.tag==="ExitNode")return"";g()}return""}g()},_w=t=>e=>Rn(t)("speed")(n=>{const r=Ja(T,Yt,"HTMLSelectElement",n);if(r.tag==="Nothing")return()=>{};if(r.tag==="Just")return wa("change")(n)((()=>{const i=$v(r._1);return()=>{const o=i(),u=sd(o,Oa,Yt,T);if(u.tag==="Just")return e(u._1)();u.tag!=="Nothing"&&g()}})());g()}),dw=t=>e=>n=>Rn(t)("scrub")(r=>{const i=Ja(T,Yt,"HTMLInputElement",r);if(i.tag==="Nothing")return()=>{};if(i.tag==="Just")return wa("input")(r)((()=>{const o=qv(i._1);return()=>{const u=o();return n.pause(),n.seek(u/1e3*e.totalDuration)()}})());g()}),lw=t=>e=>n=>{const r=cw(t)(e);return()=>{r(),Rn(t)("play")(i=>Ur("data-mg-playing")("1")(i))(),_w(t)(n.setSpeed)(),Rn(t)("play")(i=>wa("click")(i)(n.toggle))(),dw(t)(e)(n)(),n.subscribe(i=>{const o=gw(t)(i.time)(e.totalDuration);return()=>(o(),Rn(t)("time")(u=>zv(oi(ri("Fixed",ii(0)(20)(2)))(i.time)+" / "+oi(ri("Fixed",ii(0)(20)(2)))(e.totalDuration))(u))(),Rn(t)("play")(u=>Ur("data-mg-playing")(i.playing?"1":"0")(u))())})()}},hw={...oh,tokenZoomFloor:1,minZoom:1.6,maxZoom:3.2},pw=t=>e=>{const n=Ef(t);return()=>{const r=n(),i=Gf(t)(),o=a0(hw)(jh)(t)(Cf(r)(i)(t));if(o.tag==="Left")return ja("[markgraf] precompute failed")();if(o.tag==="Right")return e(o._1)();g()}},mw=t=>e=>n=>r=>i=>o=>u=>()=>{let s=1,a=!0,c=!1,f=0,d=0;const l={value:Q},_={value:0};let h=!1,m=[];ba(t)(n)(r)(i)(o)(u)(e)(l)(_)(0)();const p=L=>()=>{const E=m,B=a,V={time:L,keyframe:La(e)(L),playing:B};return uw(et=>et(V))(E)()},y=()=>(a=!1,p(f)()),x=()=>{if(!h&&(c=!1,a)){const L=y1(),E=d;d=L;const B=s,V=f,et=ow(E===0?V+0*B:V+(L-E)*B)(e.totalDuration+.8);return f=et,ba(t)(n)(r)(i)(o)(u)(e)(l)(_)(et)(),p(et)(),N()}},N=()=>{if(!h&&!c){c=!0;const L=Hv();Yv(x)(L)()}},v=()=>(d=0,a=!0,N()),k=()=>(a||v(),p(f)());return v(),{play:k,pause:y,toggle:()=>a?y():k(),seek:L=>{const E=nw(0)(m1(e.totalDuration)(L));return()=>(f=E,d=0,ba(t)(n)(r)(i)(o)(u)(e)(l)(_)(E)(),p(E)())},setSpeed:L=>()=>s=L,currentTime:()=>f,currentKeyframe:()=>{const L=f;return La(e)(L)},isPlaying:()=>a,duration:e.totalDuration,subscribe:L=>()=>{m=zt(m)(L);const E=f,B=a;L({time:E,keyframe:La(e)(E),playing:B})();const V=Wa(et=>!Zv(et)(L));return()=>{m=V(m)}},destroy:()=>h=!0}},N1=t=>e=>{const n=x1(e);if(n.tag==="Left")return ja("[markgraf] parse failed: "+n._1);if(n.tag==="Right")return pw(n._1)(r=>{const i=sw(t);return()=>{const o=i();return Ta(aw,t),Rn(t)("stage")(u=>{const s=mw(u)(r)(iw)(rw)(eT)(nT)(o);return()=>{const a=s();return lw(t)(r)(a)()}})()}});g()},yw=t=>{const e=t.getAttribute("data-markgraf-src-b64");if(e)try{return decodeURIComponent(escape(atob(e)))}catch{return atob(e)}return t.getAttribute("data-markgraf-src")||t.textContent||""};let Ln=null;const hu=t=>t.querySelector('[data-mg="play"]')?.dataset.mgPlaying==="1",xw=t=>{const e=t.querySelector('[data-mg="play"]');if(!e)return;e.addEventListener("click",()=>{queueMicrotask(()=>{hu(t)?(Ln&&Ln!==t&&hu(Ln)&&Ln.querySelector('[data-mg="play"]').click(),Ln=t):Ln===t&&(Ln=null)})});const n=r=>{r.preventDefault(),e.click()};t.querySelector('[data-mg="stage"]')?.addEventListener("click",n)},Nw=t=>{if(t.dataset.markgrafMounted==="1")return;t.dataset.markgrafMounted="1";const e=yw(t),n=t.dataset.markgrafPaused==="true";t.textContent="",N1(t)(e)(),n?hu(t)&&t.querySelector('[data-mg="play"]').click():Ln===null?Ln=t:hu(t)&&t.querySelector('[data-mg="play"]').click(),xw(t)},pu=(t=document)=>{t.querySelectorAll("[data-markgraf]").forEach(Nw)},J1=()=>{document.addEventListener("keydown",t=>{if(t.code!=="Space"&&t.key!==" ")return;const e=t.target,n=e&&e.closest?.("[data-markgraf]");if(!n){const i=e?.tagName,o=(e?.type||"").toLowerCase();if(e?.isContentEditable||i==="TEXTAREA"||i==="SELECT"||i==="INPUT"&&!["range","checkbox","radio","button","submit","reset"].includes(o))return}const r=n||Ln||document.querySelector("[data-markgraf]");r&&(t.preventDefault(),r.querySelector('[data-mg="play"]')?.click())})};if(typeof window<"u"){const t=e=>{const n=fw(e);return n==null?{ok:!0}:{ok:!1,error:n}};window.markgraf={mount:(e,n)=>N1(e)(n)(),mountAll:pu,tryParse:t},document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{pu(),J1()}):(pu(),J1())}return mu.mountAll=pu,Object.defineProperty(mu,Symbol.toStringTag,{value:"Module"}),mu})({});
|