vizmatic 0.7.3 → 0.8.1

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.
@@ -1,7 +1,7 @@
1
- import{a as Ss}from"./chunk-VZNL6JY2.js";import{b as Cs}from"./chunk-SQE76S5B.js";var zt=[1,0,0,1,0,0],Rs={x:0,y:0,width:0,height:0},Ts=.5522847498307936,ae=10;function rt(n,t){return[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],n[0]*t[4]+n[2]*t[5]+n[4],n[1]*t[4]+n[3]*t[5]+n[5]]}function Wt(n){let t=n[0]*n[3]-n[1]*n[2];if(Math.abs(t)<1e-12)return zt;let e=1/t;return[n[3]*e,-n[1]*e,-n[2]*e,n[0]*e,(n[2]*n[5]-n[3]*n[4])*e,(n[1]*n[4]-n[0]*n[5])*e]}function Q(n,t,e){return[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]]}function fe(n,t,e,r,o,s,i){let a=e===0?1:Math.cos(e),l=e===0?0:Math.sin(e),c=a*r,u=l*r,h=-l*o,d=a*o;return[c,u,h,d,n-c*s-h*i,t-u*s-d*i]}function Xt(n){return Math.sqrt(Math.abs(n[0]*n[3]-n[1]*n[2]))}function Mt(n,t=!1){return{p:n instanceof Float64Array?n:Float64Array.from(n),closed:t}}function $t(n){return Math.max(0,(n.p.length-2)/6)}function Ct(n,t,e,r,o){n.push(t+(r-t)/3,e+(o-e)/3,t+(r-t)*2/3,e+(o-e)*2/3,r,o)}function le(n,t){let e=[n[0],n[1]];return Ct(e,n[0],n[1],t[0],t[1]),[Mt(e)]}function Z(n,t=!1){if(n.length===0)return[];let e=n[0],r=[e[0],e[1]];for(let o=1;o<n.length;o++)Ct(r,n[o-1][0],n[o-1][1],n[o][0],n[o][1]);if(t){let o=n[n.length-1];(o[0]!==e[0]||o[1]!==e[1])&&Ct(r,o[0],o[1],e[0],e[1])}return[Mt(r,t)]}function Lt(n,t=!1,e=1/6){let r=n.length;if(r===0)return[];if(r<3)return Z(n,t);let o=a=>t?n[(a+r)%r]:n[Math.max(0,Math.min(r-1,a))],s=[n[0][0],n[0][1]],i=t?r:r-1;for(let a=0;a<i;a++){let l=o(a-1),c=o(a),u=o(a+1),h=o(a+2);s.push(c[0]+(u[0]-l[0])*e,c[1]+(u[1]-l[1])*e,u[0]-(h[0]-c[0])*e,u[1]-(h[1]-c[1])*e,u[0],u[1])}return[Mt(s,t)]}function St(n,t,e,r,o,s){let i=s-o;if(i===0)return[];let a=Math.abs(Math.abs(i)-Math.PI*2)<1e-9,l=Math.max(1,Math.ceil(Math.abs(i)/(Math.PI/4)-1e-9)),c=i/l,u=4/3*Math.tan(c/4),h=[n+Math.cos(o)*e,t+Math.sin(o)*r];for(let d=0;d<l;d++){let m=o+d*c,p=m+c,f=Math.cos(m),b=Math.sin(m),y=Math.cos(p),g=Math.sin(p);h.push(n+(f-u*b)*e,t+(b+u*f)*r,n+(y+u*g)*e,t+(g-u*y)*r,n+y*e,t+g*r)}return a&&(h[h.length-2]=h[0],h[h.length-1]=h[1]),[Mt(h,a)]}function Dt(n,t,e){return St(n,t,e,e,0,Math.PI*2)}function K(n,t,e,r,o=0){let s=Math.max(0,Math.min(o,Math.abs(e)/2,Math.abs(r)/2));if(s===0)return Z([[n,t],[n+e,t],[n+e,t+r],[n,t+r]],!0);let i=s*(1-Ts),a=n+e,l=t+r,c=[n+s,t];return Ct(c,n+s,t,a-s,t),c.push(a-i,t,a,t+i,a,t+s),Ct(c,a,t+s,a,l-s),c.push(a,l-i,a-i,l,a-s,l),Ct(c,a-s,l,n+s,l),c.push(n+i,l,n,l-i,n,l-s),Ct(c,n,l-s,n,t+s),c.push(n,t+i,n+i,t,n+s,t),[Mt(c,!0)]}function He(n,t,e,r=64){let o=Math.max(2,Math.floor(r)),s=[];for(let i=0;i<=o;i++)s.push(n(t+(e-t)*i/o));return be(s)}function be(n){let t=[],e=[],r=()=>{e.length>=2&&t.push(...Lt(e)),e=[]};for(let o of n)Number.isFinite(o[0])&&Number.isFinite(o[1])?e.push(o):r();return r(),t}function Ma(...n){return n.flat()}function ot(n,t){if(t===zt)return n;let e=new Array(n.length);for(let r=0;r<n.length;r++){let o=n[r].p,s=new Float64Array(o.length);for(let i=0;i<o.length;i+=2){let a=o[i],l=o[i+1];s[i]=t[0]*a+t[2]*l+t[4],s[i+1]=t[1]*a+t[3]*l+t[5]}e[r]={p:s,closed:n[r].closed}}return e}function Yr(n,t,e=4){return(e>1?n.map(o=>Cn(o,e)):n).map(o=>{let s=$t(o),i=[];for(let l=0;l<=s;l++){let c=t(o.p[l*6],o.p[l*6+1]);i.push(c)}let a=[i[0][0],i[0][1]];for(let l=0;l<s;l++){let c=t(o.p[l*6+2],o.p[l*6+3]),u=t(o.p[l*6+4],o.p[l*6+5]);a.push(c[0],c[1],u[0],u[1],i[l+1][0],i[l+1][1])}return Mt(a,o.closed)})}function An(n,t,e,r,o){let s=n[t],i=n[t+1],a=n[t+2],l=n[t+3],c=n[t+4],u=n[t+5],h=n[t+6],d=n[t+7],m=s+(a-s)*e,p=i+(l-i)*e,f=a+(c-a)*e,b=l+(u-l)*e,y=c+(h-c)*e,g=u+(d-u)*e,w=m+(f-m)*e,x=p+(b-p)*e,k=f+(y-f)*e,M=b+(g-b)*e,v=w+(k-w)*e,P=x+(M-x)*e;r.push(m,p,w,x,v,P),o.length=0,o.push(v,P,k,M,y,g,h,d)}function Cn(n,t){let e=$t(n);if(t<=1||e===0)return n;let r=[n.p[0],n.p[1]];for(let o=0;o<e;o++){let s=Array.from(n.p.subarray(o*6,o*6+8));for(let i=t;i>1;i--){let a=[];An(s,0,1/i,r,a),s=a}r.push(s[2],s[3],s[4],s[5],s[6],s[7])}return Mt(r,n.closed)}var _r=new WeakMap;function Ke(n){let t=_r.get(n);if(t)return t;let e=$t(n),r=new Float64Array(e),o=new Float64Array(e*ae),s=0,i=n.p;for(let l=0;l<e;l++){let c=l*6,u=i[c],h=i[c+1],d=i[c+2],m=i[c+3],p=i[c+4],f=i[c+5],b=i[c+6],y=i[c+7],g=u,w=h,x=0;for(let k=1;k<=ae;k++){let M=k/ae,v=1-M,P=v*v*v,A=3*v*v*M,O=3*v*M*M,R=M*M*M,$=P*u+A*d+O*p+R*b,z=P*h+A*m+O*f+R*y;x+=Math.hypot($-g,z-w),o[l*ae+k-1]=x,g=$,w=z}s+=x,r[l]=s}let a={total:r,lut:o,length:s};return _r.set(n,a),a}function Te(n){return Ke(n).length}function Pt(n){let t=0;for(let e of n)t+=Ke(e).length;return t}function On(n,t){let e=n.total.length;if(e===0)return[0,0];if(t<=0)return[0,0];if(t>=n.length)return[e-1,1];let r=0,o=e-1;for(;r<o;){let d=r+o>>1;n.total[d]<t?r=d+1:o=d}let s=r===0?0:n.total[r-1],i=t-s,a=r*ae,l=0;for(;l<ae-1&&n.lut[a+l]<i;)l++;let c=l===0?0:n.lut[a+l-1],u=n.lut[a+l],h=u>c?(i-c)/(u-c):0;return[r,(l+h)/ae]}function Hr(n,t,e){if($t(n)===0)return null;let o=Math.max(0,Math.min(1,t)),s=Math.max(0,Math.min(1,e));if(s<=o)return null;if(o===0&&s===1)return n;let i=Ke(n);if(i.length===0)return null;let[a,l]=On(i,o*i.length),[c,u]=On(i,s*i.length),h=[];for(let d=a;d<=c;d++){let m=Array.from(n.p.subarray(d*6,d*6+8)),p=d===a?l:0,f=d===c?u:1;if(p>0){let b=[];An(m,0,p,[],b),m=b}if(f<1){let b=[],y=[],g=p>0?(f-p)/(1-p):f;An(m,0,g,b,y),m=[m[0],m[1],...b]}h.length===0&&h.push(m[0],m[1]),h.push(m[2],m[3],m[4],m[5],m[6],m[7])}return Mt(h,!1)}function Jt(n,t,e,r=!1){if(t<=0&&e>=1)return n;let o=[];if(r){for(let a of n){let l=Hr(a,t,e);l&&o.push(l)}return o}let s=Pt(n);if(s===0)return[];let i=0;for(let a of n){let l=Te(a),c=(t*s-i)/(l||1),u=(e*s-i)/(l||1);if(i+=l,u<=0||c>=1)continue;let h=Hr(a,Math.max(0,c),Math.min(1,u));h&&o.push(h)}return o}function Nt(n,t){let e=Pt(n);if(e===0){let o=n[0]?.p;return o?[o[0],o[1]]:[0,0]}let r=Math.max(0,Math.min(1,t))*e;for(let o=0;o<n.length;o++){let s=n[o],i=Te(s);if(r<=i||o===n.length-1){let[a,l]=On(Ke(s),r);return Fs(s.p,a*6,l)}r-=i}return[0,0]}function ge(n,t){let r=Nt(n,Math.max(0,t-.002)),o=Nt(n,Math.min(1,t+.002)),s=Math.hypot(o[0]-r[0],o[1]-r[1])||1;return[(o[0]-r[0])/s,(o[1]-r[1])/s]}function Fs(n,t,e){let r=1-e,o=r*r*r,s=3*r*r*e,i=3*r*e*e,a=e*e*e;return[o*n[t]+s*n[t+2]+i*n[t+4]+a*n[t+6],o*n[t+1]+s*n[t+3]+i*n[t+5]+a*n[t+7]]}function Kr(n,t,e,r,o){if(n[0]=Math.min(n[0],t,o),n[1]=Math.max(n[1],t,o),e>=n[0]&&e<=n[1]&&r>=n[0]&&r<=n[1])return;let s=-t+3*e-3*r+o,i=2*(t-2*e+r),a=e-t,l=[];if(Math.abs(s)<1e-9)Math.abs(i)>1e-9&&l.push(-a/i);else{let c=i*i-4*s*a;if(c>=0){let u=Math.sqrt(c);l.push((-i+u)/(2*s),(-i-u)/(2*s))}}for(let c of l){if(c<=0||c>=1)continue;let u=1-c,h=u*u*u*t+3*u*u*c*e+3*u*c*c*r+c*c*c*o;n[0]=Math.min(n[0],h),n[1]=Math.max(n[1],h)}}var Xr=new WeakMap;function qr(n){let t=Xr.get(n);if(t)return t;let e=n.p;if(e.length<2)return Rs;let r=[e[0],e[0]],o=[e[1],e[1]];for(let i=0;i+7<e.length;i+=6)Kr(r,e[i],e[i+2],e[i+4],e[i+6]),Kr(o,e[i+1],e[i+3],e[i+5],e[i+7]);let s={x:r[0],y:o[0],width:r[1]-r[0],height:o[1]-o[0]};return Xr.set(n,s),s}function bt(n){if(n.length===0)return null;let t=1/0,e=1/0,r=-1/0,o=-1/0;for(let s of n){if(s.p.length<2)continue;let i=qr(s);t=Math.min(t,i.x),e=Math.min(e,i.y),r=Math.max(r,i.x+i.width),o=Math.max(o,i.y+i.height)}return t===1/0?null:{x:t,y:e,width:r-t,height:o-e}}function Xe(n,t){if(!n)return t;if(!t)return n;let e=Math.min(n.x,t.x),r=Math.min(n.y,t.y);return{x:e,y:r,width:Math.max(n.x+n.width,t.x+t.width)-e,height:Math.max(n.y+n.height,t.y+t.height)-r}}function ce(n){let t=n.p,e=0;for(let r=0;r+7<t.length;r+=6)e+=t[r]*t[r+7]-t[r+6]*t[r+1];return e/2}function ue(n){let t=qr(n);return[t.x+t.width/2,t.y+t.height/2]}function Sn(n){let t=n.p,e=new Float64Array(t.length);for(let r=0;r<t.length;r+=2)e[r]=t[t.length-2-r],e[r+1]=t[t.length-1-r];return{p:e,closed:n.closed}}function vt(n){let t=n.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(!t)return[];let e=[],r=[],o=0,s=0,i=0,a=0,l=0,c="",u=0,h=0,d=()=>Number(t[o++]),m=()=>{let y=t[o];return y.length>1&&(y[0]==="0"||y[0]==="1")&&!y.startsWith("0.")&&!y.startsWith("1.")?(t[o]=y.slice(1),Number(y[0])):(o++,Number(y))},p=y=>{r.length>=8&&e.push(Mt(r,y)),r=[]},f=(y,g)=>{r.length===0&&r.push(y,g)},b="";for(;o<t.length;){let y=t[o];if(/^[a-zA-Z]$/.test(y))b=y,o++;else if(b==="M")b="L";else if(b==="m")b="l";else if(b==="")throw new Error(`Invalid SVG path data: ${n.slice(0,40)}`);let g=b>="a";switch(b.toUpperCase()){case"M":{p(!1),s=(g?s:0)+d(),i=(g?i:0)+d(),a=s,l=i,r.push(s,i);break}case"L":{let w=(g?s:0)+d(),x=(g?i:0)+d();f(s,i),Ct(r,s,i,w,x),s=w,i=x;break}case"H":{let w=(g?s:0)+d();f(s,i),Ct(r,s,i,w,i),s=w;break}case"V":{let w=(g?i:0)+d();f(s,i),Ct(r,s,i,s,w),i=w;break}case"C":{let w=g?s:0,x=g?i:0,k=w+d(),M=x+d(),v=w+d(),P=x+d(),A=w+d(),O=x+d();f(s,i),r.push(k,M,v,P,A,O),u=v,h=P,s=A,i=O;break}case"S":{let w=g?s:0,x=g?i:0,k="CScs".includes(c),M=k?2*s-u:s,v=k?2*i-h:i,P=w+d(),A=x+d(),O=w+d(),R=x+d();f(s,i),r.push(M,v,P,A,O,R),u=P,h=A,s=O,i=R;break}case"Q":{let w=g?s:0,x=g?i:0,k=w+d(),M=x+d(),v=w+d(),P=x+d();f(s,i),r.push(s+(k-s)*2/3,i+(M-i)*2/3,v+(k-v)*2/3,P+(M-P)*2/3,v,P),u=k,h=M,s=v,i=P;break}case"T":{let w=g?s:0,x=g?i:0,k="QTqt".includes(c),M=k?2*s-u:s,v=k?2*i-h:i,P=w+d(),A=x+d();f(s,i),r.push(s+(M-s)*2/3,i+(v-i)*2/3,P+(M-P)*2/3,A+(v-A)*2/3,P,A),u=M,h=v,s=P,i=A;break}case"A":{let w=d(),x=d(),k=d(),M=m(),v=m(),P=(g?s:0)+d(),A=(g?i:0)+d();f(s,i),Is(r,s,i,w,x,k,M===1,v===1,P,A),s=P,i=A;break}case"Z":{r.length>0&&((s!==a||i!==l)&&Ct(r,s,i,a,l),p(!0)),s=a,i=l;break}default:throw new Error(`Unsupported SVG path command: ${b}`)}c=b}return p(!1),e}function Is(n,t,e,r,o,s,i,a,l,c){let u=Math.abs(r),h=Math.abs(o);if(u===0||h===0||t===l&&e===c){Ct(n,t,e,l,c);return}let d=s*Math.PI/180,m=Math.cos(d),p=Math.sin(d),f=(t-l)/2,b=(e-c)/2,y=m*f+p*b,g=-p*f+m*b,w=y*y/(u*u)+g*g/(h*h);if(w>1){let G=Math.sqrt(w);u*=G,h*=G}let x=u*u*h*h-u*u*g*g-h*h*y*y,k=u*u*g*g+h*h*y*y,M=(i===a?-1:1)*Math.sqrt(Math.max(0,x/k)),v=M*u*g/h,P=-M*h*y/u,A=m*v-p*P+(t+l)/2,O=p*v+m*P+(e+c)/2,R=Math.atan2((g-P)/h,(y-v)/u),$=Math.atan2((-g-P)/h,(-y-v)/u)-R;a&&$<0&&($+=Math.PI*2),!a&&$>0&&($-=Math.PI*2);let z=Math.max(1,Math.ceil(Math.abs($)/(Math.PI/2)-1e-9)),B=$/z,W=4/3*Math.tan(B/4);for(let G=0;G<z;G++){let U=R+G*B,C=U+B,L=Math.cos(U),I=Math.sin(U),F=Math.cos(C),E=Math.sin(C),T=(L-W*I)*u,V=(I+W*L)*h,j=(F+W*E)*u,J=(E-W*F)*h,at=F*u,tt=E*h;n.push(m*T-p*V+A,p*T+m*V+O,m*j-p*J+A,p*j+m*J+O,G===z-1?l:m*at-p*tt+A,G===z-1?c:p*at+m*tt+O)}}function Bt(n){let t=Math.round(n*100)/100;return t===0?"0":String(t)}function Ur(n){let t=[];for(let e of n){let r=e.p;if(!(r.length<2)){if(t.push("M",Bt(r[0])," ",Bt(r[1])),e.straight){for(let o=2;o+5<r.length;o+=6)t.push("L",Bt(r[o+4])," ",Bt(r[o+5]));e.closed&&t.push("Z");continue}for(let o=2;o+5<r.length;o+=6)t.push("C",Bt(r[o])," ",Bt(r[o+1])," ",Bt(r[o+2])," ",Bt(r[o+3])," ",Bt(r[o+4])," ",Bt(r[o+5]));e.closed&&t.push("Z")}}return t.join("")}var Tn=n=>n<=0?0:n>=1?1:n,Fe=n=>n;function Rn(n){return 1/(1+Math.exp(-n))}function Es(n){let t=Rn(-n/2),e=Rn(n/2);return r=>r<=0?0:r>=1?1:(Rn(n*(r-.5))-t)/(e-t)}var dt=Es(10),Na=n=>{let t=Tn(n);return t*t*t*(t*(t*6-15)+10)},Pa=n=>n*n,Aa=n=>1-(1-n)*(1-n),Oa=n=>n*n*n,Ca=n=>1-Math.pow(1-n,3),Sa=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,Ra=n=>1-Math.pow(1-n,5),Ta=n=>n<.5?16*n*n*n*n*n:1-Math.pow(-2*n+2,5)/2,Fa=n=>n>=1?1:1-Math.pow(2,-10*n),Ia=n=>n<=0?0:Math.pow(2,10*n-10),Ea=n=>2*dt(n/2),za=n=>2*dt(n/2+.5)-1,$a=n=>Math.sqrt(Math.max(0,1-(1-n)*(1-n)));function La(n=1.70158){return t=>{let e=t-1;return e*e*((n+1)*e+n)+1}}function Va(n={}){let t=n.bounce??.28,e=n.frequency??2.2,r=-Math.log(Math.max(1e-4,t))*2.4;return o=>o<=0?0:o>=1?1:1-Math.exp(-r*o)*Math.cos(e*Math.PI*2*o)*(1-o)}var Ba=n=>n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375,Fn=n=>dt(n<.5?2*n:2*(1-n));function Wa(n=1/3){let t=(1-n)/2;return e=>e<t?dt(e/t):e<1-t?1:dt((1-e)/t)}function Zr(n=2){return t=>Fn(t)*Math.sin(n*Math.PI*2*t)}function Da(n=.7,t=dt){return e=>n*t(e)}function Ga(n=.25,t=dt){return e=>t(Tn(e/(1-n)))}function ja(n=-.5){return t=>{let e=1-t;return 15*e**4*t**2*n+20*e**3*t**3*n+15*e**2*t**4+6*e*t**5+t**6}}function _a(n,t,e=dt){return r=>e(Tn((r-n)/(t-n)))}function Ha(n,t,e,r){let o=3*n,s=3*(e-n)-o,i=1-o-s,a=3*t,l=3*(r-t)-a,c=1-a-l,u=m=>((i*m+s)*m+o)*m,h=m=>((c*m+l)*m+a)*m,d=m=>(3*i*m+2*s)*m+o;return m=>{if(m<=0)return 0;if(m>=1)return 1;let p=m;for(let f=0;f<8;f++){let b=u(p)-m,y=d(p);if(Math.abs(b)<1e-5||Math.abs(y)<1e-6)break;p-=b/y}return h(p)}}var Ye={name:"midnight",dark:!0,background:"#0b0c10",bloom:.2,colors:{bg:"#0b0c10",surface:"#15171d",ink:"#f2efe6",dim:"#a5a7ad",faint:"#5c5f68",grid:"#23303d",gridStrong:"#3d5266",blue:"#5cc4f0",teal:"#4fd8c4",green:"#8fe08a",yellow:"#ffd75e",gold:"#f2b84b",orange:"#ff9d57",red:"#ff6b6b",pink:"#ff8fc0",purple:"#b49cff"}},zs={name:"paper",dark:!1,background:"#f7f3ea",bloom:0,colors:{bg:"#f7f3ea",surface:"#efe9db",ink:"#1d1b16",dim:"#5e5a50",faint:"#a29c8d",grid:"#e2dbca",gridStrong:"#c4bba6",blue:"#1f6fb2",teal:"#0d8577",green:"#3f8a35",yellow:"#b98500",gold:"#a8740a",orange:"#cf5d12",red:"#c62f2f",pink:"#c2387e",purple:"#6a4bc4"}},$s={name:"blueprint",dark:!0,background:"#0b2340",bloom:.16,colors:{bg:"#0b2340",surface:"#123054",ink:"#eaf6ff",dim:"#9cc0dc",faint:"#5d86a8",grid:"#1a3f66",gridStrong:"#2c5f8e",blue:"#7fd4ff",teal:"#6fe6d6",green:"#9de8a4",yellow:"#ffe27a",gold:"#f5c566",orange:"#ffb27a",red:"#ff8d8d",pink:"#ffa8cf",purple:"#c5b4ff"}},Ls={name:"chalk",dark:!0,background:"#10201b",bloom:.1,colors:{bg:"#10201b",surface:"#172c25",ink:"#f4f1e4",dim:"#b1b9a9",faint:"#67786d",grid:"#20392f",gridStrong:"#355547",blue:"#8ccbe8",teal:"#7dd9c1",green:"#a9dc8f",yellow:"#f6dd7c",gold:"#e6bf62",orange:"#f2a874",red:"#ee8a80",pink:"#efa2c2",purple:"#bfa9e6"}},Vs={name:"neon",dark:!0,background:"#050507",bloom:.4,colors:{bg:"#050507",surface:"#101016",ink:"#ffffff",dim:"#a9a9b8",faint:"#55555f",grid:"#1a1f2e",gridStrong:"#2f3a55",blue:"#3fb2ff",teal:"#21f0d0",green:"#6dff8e",yellow:"#fff04d",gold:"#ffc22e",orange:"#ff8a2e",red:"#ff4560",pink:"#ff5fb0",purple:"#a56bff"}},Jr={midnight:Ye,paper:zs,blueprint:$s,chalk:Ls,neon:Vs};function qe(n){if(n===void 0)return Ye;if(typeof n!="string")return n;let t=Jr[n];if(!t)throw new Error(`Unknown look: ${JSON.stringify(n)}. Use one of: ${Object.keys(Jr).join(", ")}.`);return t}var no=Cs(Ss(),1);var Bs=[0,0,0,0],Qr=new Map,ro=Ye.colors;function zn(n){ro=n}function Gt(n){let e=ro[n]??n,r=Qr.get(e);if(r)return r;let o=(0,no.default)(e);if(!o)throw new Error(`Unknown color: ${JSON.stringify(n)}. Use a look token such as "blue" or a CSS color.`);let[s,i,a]=o.values;o.type==="hsl"&&([s,i,a]=Ws(s,i,a));let l=[s,i,a,o.alpha];return Qr.set(e,l),l}function Ws(n,t,e){let r=t/100*Math.min(e/100,1-e/100),o=s=>{let i=(s+n/30)%12;return 255*(e/100-r*Math.max(-1,Math.min(i-3,9-i,1)))};return[o(0),o(8),o(4)]}function X(n){return typeof n=="string"?Gt(n):n}function yt(n){return!Array.isArray(n)}function Yt(n,t=1){let e=n[3]*t,r=Math.round(n[0]),o=Math.round(n[1]),s=Math.round(n[2]);return e>=1?`rgb(${r},${o},${s})`:`rgba(${r},${o},${s},${Math.round(e*1e3)/1e3})`}function In(n){let t=n/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function En(n){let t=n<=.0031308?12.92*n:1.055*Math.pow(n,.4166666666666667)-.055;return Math.max(0,Math.min(255,t*255))}function to(n){let t=In(n[0]),e=In(n[1]),r=In(n[2]),o=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*r),s=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*r),i=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*r);return[.2104542553*o+.793617785*s-.0040720468*i,1.9779984951*o-2.428592205*s+.4505937099*i,.0259040371*o+.7827717662*s-.808675766*i]}function Ds(n,t){let e=n[0]+.3963377774*n[1]+.2158037573*n[2],r=n[0]-.1055613458*n[1]-.0638541728*n[2],o=n[0]-.0894841775*n[1]-1.291485548*n[2],s=e*e*e,i=r*r*r,a=o*o*o;return[En(4.0767416621*s-3.3077115913*i+.2309699292*a),En(-1.2684380046*s+2.6097574011*i-.3413193965*a),En(-.0041960863*s-.7034186147*i+1.707614701*a),t]}function he(n,t,e){if(e<=0)return n;if(e>=1)return t;let r=to(n),o=to(t);return Ds([r[0]+(o[0]-r[0])*e,r[1]+(o[1]-r[1])*e,r[2]+(o[2]-r[2])*e],n[3]+(t[3]-n[3])*e)}function oo(n,t,e){if(e<=0)return n;if(e>=1)return t;let r=yt(n),o=yt(t);if(!r&&!o)return he(n,t,e);if(r&&o&&n.type===t.type&&n.stops.length===t.stops.length){let a=n.stops.map((l,c)=>[l[0]+(t.stops[c][0]-l[0])*e,he(l[1],t.stops[c][1],e)]);return n.type==="linear"&&t.type==="linear"?{type:"linear",stops:a,from:[n.from[0]+(t.from[0]-n.from[0])*e,n.from[1]+(t.from[1]-n.from[1])*e],to:[n.to[0]+(t.to[0]-n.to[0])*e,n.to[1]+(t.to[1]-n.to[1])*e]}:n.type==="radial"&&t.type==="radial"?{type:"radial",stops:a,center:[n.center[0]+(t.center[0]-n.center[0])*e,n.center[1]+(t.center[1]-n.center[1])*e],radius:n.radius+(t.radius-n.radius)*e}:{type:"along",stops:a}}let s=r?lt(n.stops,.5):n,i=o?lt(t.stops,.5):t;return he(s,i,e)}function lt(n,t){if(n.length===0)return Bs;if(t<=n[0][0])return n[0][1];for(let e=1;e<n.length;e++)if(t<=n[e][0]){let[r,o]=n[e-1],[s,i]=n[e];return he(o,i,s>r?(t-r)/(s-r):0)}return n[n.length-1][1]}function Ue(n){let t=n.length;return n.map((e,r)=>Array.isArray(e)&&e.length===2&&typeof e[0]=="number"?[e[0],eo(e[1])]:[t===1?0:r/(t-1),eo(e)])}function eo(n){let t=X(n);return yt(t)?lt(t.stops,.5):t}function Gs(n,t,e){return{type:"linear",from:n,to:t,stops:Ue(e)}}function js(n,t,e){return{type:"radial",center:n,radius:t,stops:Ue(e)}}function _s(...n){return{type:"along",stops:Ue(n)}}function Ie(n,...t){let e=Ue(t);return Array.from({length:n},(r,o)=>lt(e,n===1?0:o/(n-1)))}var S={now:0,mode:"free",frame:0,capture:null},ye=class{constructor(t){this.initial=t}initial;keys=[];sample(t){let e=this.keys,r=0,o=e.length-1,s=-1;for(;r<=o;){let c=r+o>>1;e[c].t0<=t?(s=c,r=c+1):o=c-1}if(s<0)return this.initial;let i=e[s];if(t>=i.t1||!i.at)return i.to;let a=i.t1-i.t0,l=a>0?(t-i.t0)/a:1;return i.at(i.ease?i.ease(l):l)}add(t){let e=this.keys,r=e.length;for(;r>0&&e[r-1].t0>t.t0;)r--;e.splice(r,0,t)}step(t,e){this.add({t0:t,t1:t,ease:null,to:e,at:null})}get end(){let t=0;for(let e of this.keys)e.t1>t&&(t=e.t1);return t}};function so(n,t){let e=$t(n);if(e>=t||e===0)return n;let r=[];for(let s=0;s<e;s++){let i=s*6,a=Array.from(n.p.subarray(i,i+8));r.push({pts:a,length:$n(a)})}for(;r.length<t;){let s=0;for(let l=1;l<r.length;l++)r[l].length>r[s].length&&(s=l);let[i,a]=Hs(r[s].pts);r.splice(s,1,{pts:i,length:$n(i)},{pts:a,length:$n(a)})}let o=new Float64Array(2+t*6);o[0]=n.p[0],o[1]=n.p[1];for(let s=0;s<t;s++){let i=r[s].pts;for(let a=0;a<6;a++)o[2+s*6+a]=i[2+a]}return{p:o,closed:n.closed}}function $n(n){return Math.hypot(n[2]-n[0],n[3]-n[1])+Math.hypot(n[4]-n[2],n[5]-n[3])+Math.hypot(n[6]-n[4],n[7]-n[5])}function Hs(n){let t=(n[0]+n[2])/2,e=(n[1]+n[3])/2,r=(n[2]+n[4])/2,o=(n[3]+n[5])/2,s=(n[4]+n[6])/2,i=(n[5]+n[7])/2,a=(t+r)/2,l=(e+o)/2,c=(r+s)/2,u=(o+i)/2,h=(a+c)/2,d=(l+u)/2;return[[n[0],n[1],t,e,a,l,h,d],[h,d,c,u,s,i,n[6],n[7]]]}function Ks(n,t){let e=$t(t);if(!n.closed||!t.closed||e<2)return t;let[r,o]=ue(n),[s,i]=ue(t),a=Math.max(1,Math.floor(e/48)),l=0,c=1/0;for(let h=0;h<e;h+=a){let d=0;for(let m=0;m<e;m+=a){let p=(m+h)%e,f=n.p[m*6]-r-(t.p[p*6]-s),b=n.p[m*6+1]-o-(t.p[p*6+1]-i);d+=f*f+b*b}d<c&&(c=d,l=h)}if(l===0)return t;let u=new Float64Array(t.p.length);u[0]=t.p[l*6],u[1]=t.p[l*6+1];for(let h=0;h<e;h++){let d=(h+l)%e;for(let m=0;m<6;m++)u[2+h*6+m]=t.p[2+d*6+m]}return{p:u,closed:t.closed}}function io(n,t,e,r){let o=new Float64Array(2+e*6);for(let s=0;s<o.length;s+=2)o[s]=n,o[s+1]=t;return{p:o,closed:r}}function Xs(n,t){let e=a=>[...a].sort((l,c)=>Math.abs(ce(c))+Te(c)*.01-(Math.abs(ce(l))+Te(l)*.01)),r=e(n),o=e(t),s=[],i=o.slice();for(let a of r){if(i.length===0){let[d,m]=ue(a);s.push([a,io(d,m,$t(a),a.closed)]);continue}let[l,c]=ue(a),u=0,h=1/0;for(let d=0;d<Math.min(i.length,3);d++){let[m,p]=ue(i[d]),f=Math.hypot(l-m,c-p)+d*40;f<h&&(h=f,u=d)}s.push([a,i[u]]),i.splice(u,1)}for(let a of i){let[l,c]=ue(a);s.push([io(l,c,$t(a),a.closed),a])}return s}function Ys(n,t,e=12){let r=Xs(n,t),o=[],s=[],i=[];for(let[a,l]of r){let c=Math.max($t(a),$t(l),a.closed&&l.closed?e:1),u=so(a,c),h=so(l,c);if(u.closed&&h.closed)Math.sign(ce(u))!==Math.sign(ce(h))&&ce(u)!==0&&ce(h)!==0&&(h=Sn(h)),h=Ks(u,h);else if(!u.closed&&!h.closed){let d=u.p.length,m=Math.hypot(u.p[0]-h.p[0],u.p[1]-h.p[1])+Math.hypot(u.p[d-2]-h.p[d-2],u.p[d-1]-h.p[d-1]);Math.hypot(u.p[0]-h.p[d-2],u.p[1]-h.p[d-1])+Math.hypot(u.p[d-2]-h.p[0],u.p[d-1]-h.p[1])<m&&(h=Sn(h))}o.push(u.p),s.push(h.p),i.push(u.closed&&h.closed)}return{from:o,to:s,closed:i}}function Ze(n,t){if(n===t)return()=>t;if(Pt(n)===0&&n.length===0)return r=>r>=1?t:n;let e=Ys(n,t);return r=>{if(r<=0)return n;if(r>=1)return t;let o=new Array(e.from.length);for(let s=0;s<o.length;s++){let i=e.from[s],a=e.to[s],l=new Float64Array(i.length);for(let c=0;c<i.length;c++)l[c]=i[c]+(a[c]-i[c])*r;o[s]={p:l,closed:e.closed[s]}}return o}}function Je(n,t){let e=n.length,r=t.length,o=Array.from({length:e+1},()=>new Uint16Array(r+1));for(let l=e-1;l>=0;l--)for(let c=r-1;c>=0;c--)o[l][c]=n[l]===t[c]?o[l+1][c+1]+1:Math.max(o[l+1][c],o[l][c+1]);let s=[],i=0,a=0;for(;i<e&&a<r;)n[i]===t[a]?s.push([i++,a++]):o[i+1][a]>=o[i][a+1]?i++:a++;return s}var Ln={x:0,y:0,rotation:0,sx:1,sy:1,px:0,py:0,opacity:1,visible:!0,z:0,path:null,fill:null,fillOpacity:1,stroke:null,strokeOpacity:1,strokeWidth:3,cap:"round",join:"round",dash:null,dashOffset:0,trimFrom:0,trimTo:1,trimEach:!1,glow:0,glowColor:null,blend:"normal",fixed:!1,image:null},qs=new Set(["x","y","rotation","sx","sy","px","py","opacity","z","fillOpacity","strokeOpacity","strokeWidth","dashOffset","trimFrom","trimTo","glow"]);function Us(n,t,e){if(qs.has(n)){let r=t,o=e;return(s=>r+(o-r)*s)}if(n==="fill"||n==="stroke"){let r=t,o=e;return r&&o?(s=>oo(r,o,s)):null}if(n==="glowColor"){let r=t,o=e;return r&&o?(s=>he(r,o,s)):null}if(n==="path"){let r=t,o=e;return r&&o?Ze(r,o):null}return null}var ao=1,N=class n{id=ao++;parent=null;children=[];data={};label="";base=Object.create(Ln);tracks=null;overlay=null;overlayFrame=-1;mounted=!1;draw=null;rawOps=null;constructor(t){t&&(this.base.path=t)}get(t){let e=this.overlay;if(e!==null&&e.has(t)&&(this.overlayFrame===S.frame||S.capture!==null))return e.get(t);let r=this.tracks?.get(t);return r?r.sample(S.now):this.base[t]}set(t,e){return S.capture?(this.overlay??=new Map,this.overlay.set(t,e),S.capture.add(this),this):this.mounted?S.mode==="render"?(this.overlay??=new Map,this.overlayFrame!==S.frame&&(this.overlay.clear(),this.overlayFrame=S.frame),this.overlay.set(t,e),this):(this.track(t).step(S.now,e),this):(this.base[t]=e,this)}track(t){this.tracks??=new Map;let e=this.tracks.get(t);return e||(e=new ye(this.base[t]),this.tracks.set(t,e)),e}tween(t,e,r,o,s){let i=S.now;S.now=r;let a=this.get(t);S.now=i;let l=o>r?Us(t,a,e):null,c={t0:r,t1:o,ease:s,to:e,at:l};this.track(t).add(c)}add(...t){for(let e of t)e.parent!==this&&(e.parent?.drop(e),e.parent=this,this.children.push(e),this.mounted&&tn(e,S.now));return this}drop(t){let e=this.children.indexOf(t);return e>=0&&this.children.splice(e,1),t.parent=null,this}all(){let t=[],e=r=>{t.push(r);for(let o of r.children)e(o)};return e(this),t}leaves(){return this.all().filter(t=>t.get("path")!==null||t.draw!==null||t.get("image")!==null)}clone(){let t=Object.create(Object.getPrototypeOf(this));Object.assign(t,this),t.id=ao++,t.parent=null,t.mounted=!1,t.tracks=null,t.overlay=null,t.overlayFrame=-1,t.data={...this.data},t.base=Object.create(Ln);for(let e of Object.keys(Ln))t.base[e]=this.get(e);return t.children=this.children.map(e=>{let r=e.clone();return r.parent=t,r}),t}localMatrix(){return fe(this.get("x"),this.get("y"),this.get("rotation"),this.get("sx"),this.get("sy"),this.get("px"),this.get("py"))}worldMatrix(){let t=this.localMatrix();for(let e=this.parent;e;e=e.parent)t=rt(e.localMatrix(),t);return t}toWorld(t,e){return Q(this.worldMatrix(),t,e)}bounds(){return this.boundsFrom(this.parent?this.parent.worldMatrix():zt)??{x:0,y:0,width:0,height:0}}boundsFrom(t){let e=rt(t,this.localMatrix()),r=null,o=this.get("path");o&&(r=bt(ot(o,e)));let s=this.get("image");if(s&&(r=Xe(r,Zs(e,s.width,s.height))),this.draw){let i=this.draw(S.now),a=i===null?[]:Array.isArray(i)?i:[i];for(let l of a)r=Xe(r,l.boundsFrom(e))}for(let i of this.children)i.get("visible")&&(r=Xe(r,i.boundsFrom(e)));return r}get center(){let t=this.bounds();return[t.x+t.width/2,t.y+t.height/2]}get top(){let t=this.bounds();return[t.x+t.width/2,t.y]}get bottom(){let t=this.bounds();return[t.x+t.width/2,t.y+t.height]}get left(){let t=this.bounds();return[t.x,t.y+t.height/2]}get right(){let t=this.bounds();return[t.x+t.width,t.y+t.height/2]}get width(){return this.bounds().width}get height(){return this.bounds().height}at(t,e){let[r,o]=typeof t=="number"?[t,e??0]:t;return this.set("x",r),this.set("y",o),this}shift(t,e){let[r,o]=typeof t=="number"?[t,e??0]:t;return this.set("x",this.get("x")+r),this.set("y",this.get("y")+o),this}moveTo(t){let e=t instanceof n?t.center:t,[r,o]=this.center,s=this.parent?Wt(this.parent.worldMatrix()):zt,[i,a]=Q(s,r,o),[l,c]=Q(s,e[0],e[1]);return this.shift(l-i,c-a)}pivotAt(t){let e=this.parent?this.parent.worldMatrix():zt,r=rt(e,this.localMatrix()),[o,s]=Q(Wt(r),t[0],t[1]),[i,a]=Q(Wt(e),t[0],t[1]);return this.set("px",o),this.set("py",s),this.set("x",i),this.set("y",a),this}scale(t,e){let[r,o]=typeof t=="number"?[t,t]:t;return this.pivotAt(e??this.center),this.set("sx",this.get("sx")*r),this.set("sy",this.get("sy")*o),this}rotate(t,e){return this.pivotAt(e??this.center),this.set("rotation",this.get("rotation")+t),this}fitTo(t){let e=this.bounds(),r=[];return t.width!==void 0&&e.width>0&&r.push(t.width/e.width),t.height!==void 0&&e.height>0&&r.push(t.height/e.height),r.length?this.scale(Math.min(...r)):this}nextTo(t,e="right",r=28){let[o,s]=Qe(e),i=t instanceof n?t.bounds():{x:t[0],y:t[1],width:0,height:0},a=this.bounds(),l=i.x+i.width/2,c=i.y+i.height/2,u=l+o*(i.width/2+r+a.width/2),h=c+s*(i.height/2+r+a.height/2);return this.moveTo([u,h])}alignTo(t,e){let r=this.bounds(),o=t instanceof n?t.bounds():{x:t[0],y:t[1],width:0,height:0};return e==="left"?this.shift(o.x-r.x,0):e==="right"?this.shift(o.x+o.width-r.x-r.width,0):e==="top"?this.shift(0,o.y-r.y):this.shift(0,o.y+o.height-r.y-r.height)}arrange(t="right",e=24){let[r,o]=Qe(t),s=this.center,i=null;for(let a of this.children){if(i){let l=i.bounds(),c=a.bounds(),u=l.x+l.width/2+r*(l.width/2+e+c.width/2),h=l.y+l.height/2+o*(l.height/2+e+c.height/2);a.moveTo([r===0?l.x+l.width/2:u,o===0?l.y+l.height/2:h])}i=a}return this.moveTo(s)}fill(t,e){return this.set("fill",t===null?null:X(t)),e!==void 0&&this.set("fillOpacity",e),this}stroke(t,e,r){return this.set("stroke",t===null?null:X(t)),e!==void 0&&this.set("strokeWidth",e),r!==void 0&&this.set("strokeOpacity",r),this}color(t){let e=X(t);for(let r of this.all())r.get("stroke")&&r.set("stroke",e),r.get("fill")&&r.set("fill",e),r.get("glowColor")&&!yt(e)&&r.set("glowColor",e);return this}opacity(t){return this.set("opacity",t)}glow(t,e){if(this.set("glow",t),e!==void 0){let r=X(e);this.set("glowColor",yt(r)?null:r)}return this}dash(t,e=0){return this.set("dash",t),this.set("dashOffset",e)}zIndex(t){return this.set("z",t)}pin(){return this.set("fixed",!0)}hide(){return this.set("visible",!1)}show(){return this.set("visible",!0)}named(t){return this.label=t,this}};function Zs(n,t,e){let r=[Q(n,0,0),Q(n,t,0),Q(n,t,e),Q(n,0,e)],o=r.map(l=>l[0]),s=r.map(l=>l[1]),i=Math.min(...o),a=Math.min(...s);return{x:i,y:a,width:Math.max(...o)-i,height:Math.max(...s)-a}}function Qe(n){return typeof n!="string"?n:n==="left"?[-1,0]:n==="right"?[1,0]:n==="top"||n==="up"?[0,-1]:[0,1]}function tn(n,t){let e=n.base.visible;for(let r of n.all())r.mounted=!0;if(t>0||!e){let r=n.track("visible");r.initial=!1,e&&r.step(t,!0)}}function Vn(...n){return new N().add(...n)}function At(n){let t=new N;return t.draw=n,t}function Rt(n){return Array.isArray(n)?[...n]:[n]}function rn(n,t,e,r){S.now=t,n.schedule({t0:t,t1:e,ease:n.ease??r.ease,stage:r.stage})}function Bn(...n){let t=Math.max(0,...n.map(e=>e.duration));return{label:"par",duration:t,schedule(e){let r=t>0?(e.t1-e.t0)/t:1;for(let o of n)rn(o,e.t0,e.t0+o.duration*r,e)}}}function lo(...n){let t=n.reduce((e,r)=>e+r.duration,0);return{label:"seq",duration:t,schedule(e){let r=t>0?(e.t1-e.t0)/t:1,o=e.t0;for(let s of n){let i=o+s.duration*r;rn(s,o,i,e),o=i}}}}function ul(n,t={}){let e=t.lag??.15,r=Math.max(0,...n.map(s=>s.duration)),o=n.length===0?0:r*(1+(n.length-1)*e);return{label:"lagged",duration:t.duration??o,schedule(s){let i=s.t1-s.t0,a=n.length===0?0:i/(1+(n.length-1)*e);n.forEach((l,c)=>{let u=s.t0+c*e*a;rn(l,u,u+a,s)})}}}function hl(n,t){return{label:n.label,duration:n.duration+t,ease:n.ease,schedule(e){let r=n.duration+t>0?(e.t1-e.t0)/(n.duration+t):1;rn(n,e.t0+t*r,e.t1,e)}}}function Js(n,t){return{...n,duration:t.duration??n.duration,ease:t.ease??n.ease}}function dl(n){return{label:"call",duration:0,schedule:()=>n()}}function te(n,t,e){if(!n.mounted){let r=n;for(;r.parent&&r.parent!==e.root;)r=r.parent;e.mountAt(r,t)}for(let r=n;r&&r!==e.root;r=r.parent){let o=S.now;S.now=t;let s=r.get("visible");S.now=o,s||r.track("visible").step(t,!0)}}function jt(n,t){n.track("visible").step(t,!1)}function co(n,t,e){e<=t||(n.track("visible").step(t,!1),n.track("visible").step(e,!0))}var et=(n,t,e,r)=>{n.track(t).step(r,e)};function Qs(n,t,e){let r=S.now;S.now=e;let o=n.get(t);return S.now=r,o}function ti(n){return yt(n)?lt(n.stops,.5):n}function Qt(n){return Rt(n).flatMap(t=>t.leaves().filter(e=>e.get("path")))}function ei(n,t,e,r,o){let s=e-t,i=n.get("fill"),a=n.get("stroke"),l=n.get("fillOpacity"),c=n.get("strokeOpacity");if(i&&!a){let u=Qs(n,"strokeWidth",t);et(n,"stroke",ti(i),t),et(n,"strokeWidth",o,t),et(n,"strokeOpacity",1,t),et(n,"trimTo",0,t),et(n,"fillOpacity",0,t),n.tween("trimTo",1,t,t+s*.72,r),n.tween("fillOpacity",l,t+s*.42,e,r),n.tween("strokeOpacity",0,t+s*.62,e,r),et(n,"stroke",null,e),et(n,"strokeWidth",u,e),et(n,"strokeOpacity",c,e);return}et(n,"trimTo",0,t),n.tween("trimTo",1,t,i?t+s*.8:e,r),i&&(et(n,"fillOpacity",0,t),n.tween("fillOpacity",l,t+s*.5,e,r))}function uo(n,t,e,r){let o=Rt(t),s=Qt(o).length,i=e.lag??r.lag,a=e.duration??(s<=1?r.duration:Math.min(r.duration*2.4,r.duration+s*.035));return{label:n,duration:a,ease:e.ease,schedule(l){for(let d of o)te(d,l.t0,l.stage);let c=Qt(o);if(c.length===0)return;let h=(l.t1-l.t0)/(1+(c.length-1)*i);c.forEach((d,m)=>{let p=l.t0+m*i*h;S.now=p,co(d,l.t0,p),ei(d,p,p+h,l.ease,r.outline)}),S.now=l.t0}}}function ml(n,t={}){return uo("draw",n,t,{lag:.04,duration:1.3,outline:2})}function pl(n,t={}){return uo("write",n,t,{lag:.22,duration:1.1,outline:1.3})}function fl(n,t={}){let e=Rt(n);return{label:"erase",duration:t.duration??.8,ease:t.ease,schedule(r){let o=Qt(e),s=t.lag??.02,i=(r.t1-r.t0)/(1+Math.max(0,o.length-1)*s);o.forEach((a,l)=>{let c=r.t0+l*s*i;S.now=c;let u=a.get("fill");a.get("stroke")&&a.tween("trimFrom",1,c,c+i,r.ease),u&&a.tween("fillOpacity",0,c,c+i*.7,r.ease)});for(let a of e)jt(a,r.t1)}}}function bl(n,t={}){let e=Rt(n);return{label:"fadeIn",duration:t.duration??.8,ease:t.ease,schedule(r){let o=t.lag!==void 0&&e.length===1&&e[0].children.length>0?e[0].children:e;for(let a of e)te(a,r.t0,r.stage);let s=t.lag??0,i=(r.t1-r.t0)/(1+Math.max(0,o.length-1)*s);o.forEach((a,l)=>{let c=r.t0+l*s*i,u=c+i;S.now=c,co(a,r.t0,c);let h=a.get("opacity");if(et(a,"opacity",0,c),a.tween("opacity",h,c,u,r.ease),t.shift){let d=a.get("x"),m=a.get("y");et(a,"x",d+t.shift[0],c),et(a,"y",m+t.shift[1],c),a.tween("x",d,c,u,r.ease),a.tween("y",m,c,u,r.ease)}t.scale!==void 0&&ho(a,t.scale,c,u,r.ease)}),S.now=r.t0}}}function ho(n,t,e,r,o,s){let i=S.now;S.now=e,n.pivotAt(s??n.center);let a=n.get("sx"),l=n.get("sy");et(n,"sx",a*t,e),et(n,"sy",l*t,e),n.tween("sx",a,e,r,o),n.tween("sy",l,e,r,o),S.now=i}function gl(n,t={}){let e=Rt(n);return{label:"fadeOut",duration:t.duration??.6,ease:t.ease,schedule(r){for(let o of e){let s=o.get("opacity");o.tween("opacity",0,r.t0,r.t1,r.ease),t.shift&&(o.tween("x",o.get("x")+t.shift[0],r.t0,r.t1,r.ease),o.tween("y",o.get("y")+t.shift[1],r.t0,r.t1,r.ease)),t.scale!==void 0&&(o.pivotAt(o.center),o.tween("sx",o.get("sx")*t.scale,r.t0,r.t1,r.ease),o.tween("sy",o.get("sy")*t.scale,r.t0,r.t1,r.ease)),jt(o,r.t1),et(o,"opacity",s,r.t1)}}}}function yl(n,t={}){let e=Rt(n);return{label:"grow",duration:t.duration??.9,ease:t.ease,schedule(r){for(let o of e)te(o,r.t0,r.stage),ho(o,.001,r.t0,r.t1,r.ease,t.from)}}}function wl(n){let t=Rt(n);return{label:"appear",duration:0,schedule:e=>{for(let r of t)te(r,e.t0,e.stage)}}}function xl(n){let t=Rt(n);return{label:"vanish",duration:0,schedule:e=>{for(let r of t)jt(r,e.t0)}}}function de(n,t,e={}){return{label:"to",duration:e.duration??1,ease:e.ease,schedule(r){te(n,r.t0,r.stage);let o=new Set;S.capture=o;try{t(n)}finally{S.capture=null}for(let s of o){let i=s,a=new Map(i.overlay);i.overlay.clear(),ni(i,a,r,e.restore===!0)}}}}function ni(n,t,e,r){let{t0:o,t1:s,ease:i}=e,a=t,l=new Map,c=a.get("px"),u=a.get("py");if(c!==void 0||u!==void 0){let h=c??n.get("px"),d=u??n.get("py"),m=fe(n.get("x"),n.get("y"),n.get("rotation"),n.get("sx"),n.get("sy"),n.get("px"),n.get("py")),[p,f]=Q(m,h,d);et(n,"px",h,o),et(n,"py",d,o),et(n,"x",p,o),et(n,"y",f,o),a.delete("px"),a.delete("py")}S.now=o;for(let[h,d]of a){let m=n.get(h);m!==d&&(r&&l.set(h,m),n.tween(h,d,o,s,i))}for(let[h,d]of l)et(n,h,d,s)}function kl(n,t,e={}){return{...de(n,r=>r.moveTo(t),e),label:"moveTo"}}function Ml(n,t,e,r={}){return{...de(n,o=>o.shift(t,e),r),label:"shift"}}function vl(n,t,e={}){return{...de(n,r=>r.scale(t,e.about),e),label:"scale"}}function Nl(n,t,e={}){return{...de(n,r=>r.rotate(t,e.about),e),label:"rotate"}}function mo(n,t,e={}){return{...de(n,r=>r.color(t),e),label:"recolor"}}function po(n,t,e={}){return{...de(n,r=>r.opacity(t),{duration:.6,...e}),label:"fade"}}function Pl(n,t,e={}){return{label:"along",duration:e.duration??2,ease:e.ease,schedule(r){te(n,r.t0,r.stage);let o=t instanceof N?ot(t.get("path")??[],t.worldMatrix()):t,s=n.parent?fo(n.parent.worldMatrix()):null,i=c=>{let[u,h]=Nt(o,c);return s?Q(s,u,h):[u,h]},[a,l]=i(1);if(n.track("x").add({t0:r.t0,t1:r.t1,ease:r.ease,to:a,at:c=>i(c)[0]}),n.track("y").add({t0:r.t0,t1:r.t1,ease:r.ease,to:l,at:c=>i(c)[1]}),e.orient){let c=u=>{let[h,d]=ge(o,u);return Math.atan2(d,h)};n.track("rotation").add({t0:r.t0,t1:r.t1,ease:r.ease,to:c(1),at:c})}}}}function fo(n){let t=n[0]*n[3]-n[1]*n[2];if(Math.abs(t)<1e-12)return[1,0,0,1,0,0];let e=1/t;return[n[3]*e,-n[1]*e,-n[2]*e,n[0]*e,(n[2]*n[5]-n[3]*n[4])*e,(n[1]*n[4]-n[0]*n[5])*e]}function Wn(n,t,e={}){let r=Rt(n);return{label:"warp",duration:e.duration??2,ease:e.ease,schedule(o){for(let s of Qt(r)){te(s,o.t0,o.stage);let i=s.get("path"),a=s.worldMatrix(),l=fo(a),c=i.map(h=>Cn(h,e.subdivisions??6)),u=Yr(c,(h,d)=>{let[m,p]=Q(a,h,d),[f,b]=t(m,p);return Q(l,f,b)},1);s.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:u,at:h=>c.map((d,m)=>{let p=d.p,f=u[m].p,b=new Float64Array(p.length);for(let y=0;y<p.length;y++)b[y]=p[y]+(f[y]-p[y])*h;return{p:b,closed:d.closed}})})}}}}function Al(n,t,e={}){let[r,o]=e.origin??[0,0],s=e.yUp===!1?1:-1,[[i,a],[l,c]]=t;return{...Wn(n,(u,h)=>{let d=u-r,m=(h-o)*s,p=i*d+a*m,f=l*d+c*m;return[r+p,o+f*s]},{subdivisions:1,...e}),label:"applyMatrix"}}function ri(n){let t=1;for(let e=n;e;e=e.parent)t*=e.get("opacity");return t}function nn(n){let t=n.worldMatrix(),e=ri(n),r=0,o=!1;for(let s=n;s;s=s.parent)r+=s.get("z"),o||=s.get("fixed");return{path:ot(n.get("path")??[],t),fill:n.get("fill"),fillOpacity:n.get("fill")?n.get("fillOpacity")*e:0,stroke:n.get("stroke"),strokeOpacity:n.get("stroke")?n.get("strokeOpacity")*e:0,strokeWidth:n.get("strokeWidth")*Xt(t),glow:n.get("glow"),glowColor:n.get("glowColor"),cap:n.get("cap"),dash:n.get("dash"),z:r,fixed:o,key:n.data.key}}function en(n,t,e,r){let o=new N;return o.base.visible=!1,o.base.path=t.path,o.base.cap=t.cap,o.base.z=t.z,o.base.fixed=t.fixed,o.base.fill=t.fill??e.fill,o.base.stroke=t.stroke??e.stroke,o.base.fillOpacity=t.fillOpacity,o.base.strokeOpacity=t.strokeOpacity,o.base.strokeWidth=t.strokeWidth||e.strokeWidth,o.base.glow=t.glow,o.base.glowColor=t.glowColor??e.glowColor,n.root.add(o),o.track("visible").initial=!1,o.track("visible").keys.length=0,et(o,"visible",!0,r.appear??r.t0),o.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:e.path,at:Ze(t.path,e.path)}),t.fill&&e.fill&&o.tween("fill",e.fill,r.t0,r.t1,r.ease),t.stroke&&e.stroke&&o.tween("stroke",e.stroke,r.t0,r.t1,r.ease),o.tween("fillOpacity",e.fillOpacity,r.t0,r.t1,r.ease),o.tween("strokeOpacity",e.strokeOpacity,r.t0,r.t1,r.ease),o.tween("strokeWidth",e.strokeWidth||t.strokeWidth,r.t0,r.t1,r.ease),t.glow!==e.glow&&o.tween("glow",e.glow,r.t0,r.t1,r.ease),et(o,"visible",!1,r.hide??r.t1),o}function oi(n,t){let e=Math.max(n.length,t.length),r=[];for(let o=0;o<e;o++)r.push([n[Math.min(n.length-1,Math.floor(o*n.length/e))],t[Math.min(t.length-1,Math.floor(o*t.length/e))]]);return r}function Ol(n,t,e={}){let r=Rt(n),o=Rt(t);return{label:"morph",duration:e.duration??1.2,ease:e.ease,schedule(s){bo(o,s);let i=Qt(r).map(nn),a=Qt(o).map(nn);if(i.length===0||a.length===0){for(let h of r)jt(h,s.t0);for(let h of o)te(h,s.t0,s.stage);return}let l=oi(i,a),c=e.lag??0,u=(s.t1-s.t0)/(1+Math.max(0,l.length-1)*c);l.forEach(([h,d],m)=>{let p=s.t0+m*c*u;en(s.stage,h,d,{t0:p,t1:p+u,ease:s.ease,appear:s.t0,hide:s.t1})}),go(r,o,s)}}}function bo(n,t){S.now=t.t0;for(let e of n)t.stage.mountAt(e,t.t0),jt(e,t.t0)}function go(n,t,e){for(let r of n)jt(r,e.t0);for(let r of t)r.track("visible").step(e.t1,!0);S.now=e.t0}function we(n,t,e={}){return{label:"morphMatching",duration:e.duration??1.4,ease:e.ease,schedule(r){bo([t],r);let o=e.key??(f=>f.data.key),s=Qt(n),i=Qt(t),a=s.map(nn),l=i.map(nn),c=Je(s.map(o),i.map(o)),u=new Set(c.map(([f])=>f)),h=new Set(c.map(([,f])=>f));for(let[f,b]of c)en(r.stage,a[f],l[b],r);let d=r.t1-r.t0,m=e.fadeShift??[0,0],p=(f,b,y)=>ot(f,[1,0,0,1,b,y]);a.forEach((f,b)=>{u.has(b)||en(r.stage,f,{...f,path:p(f.path,m[0],m[1]),fillOpacity:0,strokeOpacity:0},{t0:r.t0,t1:r.t0+d*.55,ease:r.ease})}),l.forEach((f,b)=>{h.has(b)||en(r.stage,{...f,path:p(f.path,-m[0],-m[1]),fillOpacity:0,strokeOpacity:0},f,{t0:r.t0+d*.35,t1:r.t1,ease:r.ease})}),go([n],[t],r)}}}function Cl(n,t={}){let r=Rt(n).map(o=>Js(de(o,s=>{s.scale(t.scale??1.14),s.color(t.color??"yellow")},{restore:!0}),{ease:t.ease??Fn}));return{...Bn(...r),label:"indicate",duration:t.duration??.9}}function Sl(n,t={}){return{label:"shake",duration:t.duration??.8,ease:Zr(t.cycles??3),schedule(e){S.now=e.t0;let[r,o]=n.center;n.pivotAt([r,o]);let s=n.get("rotation"),i=t.angle??.08;n.track("rotation").add({t0:e.t0,t1:e.t1,ease:e.ease,to:s,at:l=>s+i*l})}}}function Rl(n,t={}){return{label:"circumscribe",duration:t.duration??1.3,ease:t.ease??Fe,schedule(e){let r=n.bounds(),o=t.pad??14,s=new N(K(r.x-o,r.y-o,r.width+o*2,r.height+o*2,t.radius??12)).stroke(t.color??"yellow",t.width??3).glow(8);e.stage.add(s);let i=e.t0,a=e.t1,l=i+(a-i)*.55;et(s,"trimTo",0,i),s.tween("trimTo",1,i,l,dt),s.tween("trimFrom",1,l-(a-i)*.08,a,dt),jt(s,a)}}}function Tl(n,t={}){return{label:"flash",duration:t.duration??.7,ease:t.ease??dt,schedule(e){let r=n instanceof N?n.center:n,o=t.radius??54,s=t.rays??12;for(let i=0;i<s;i++){let a=i/s*Math.PI*2,l=Math.cos(a),c=Math.sin(a),u=new N(le([r[0]+l*o*.35,r[1]+c*o*.35],[r[0]+l*o,r[1]+c*o])).stroke(t.color??"yellow",2.5).glow(5);e.stage.add(u),et(u,"trimTo",0,e.t0),u.tween("trimTo",1,e.t0,e.t0+(e.t1-e.t0)*.6,e.ease),u.tween("trimFrom",1,e.t0+(e.t1-e.t0)*.25,e.t1,e.ease),jt(u,e.t1)}}}}function Fl(n,t={}){return{label:"ripple",duration:t.duration??1,ease:t.ease??dt,schedule(e){let r=n instanceof N?n.center:n,o=new N(Dt(0,0,t.radius??90)).stroke(t.color??"blue",t.width??3).at(r);e.stage.add(o),et(o,"sx",.05,e.t0),et(o,"sy",.05,e.t0),o.tween("sx",1,e.t0,e.t1,e.ease),o.tween("sy",1,e.t0,e.t1,e.ease),o.tween("strokeOpacity",0,e.t0+(e.t1-e.t0)*.2,e.t1,e.ease),jt(o,e.t1)}}}function Dn(n,t={}){return{label:"pulse",duration:t.duration??1.1,ease:t.ease??dt,schedule(e){let r=n.get("path");if(!r)return;let o=new N(ot(r,n.worldMatrix())).stroke(t.color??"yellow",t.width??n.get("strokeWidth")+1.5).glow(t.glow??10);e.stage.add(o);let s=t.length??.18;et(o,"trimFrom",0,e.t0),et(o,"trimTo",0,e.t0),o.track("trimTo").add({t0:e.t0,t1:e.t1,ease:e.ease,to:1,at:i=>Math.min(1,i*(1+s))}),o.track("trimFrom").add({t0:e.t0,t1:e.t1,ease:e.ease,to:1,at:i=>Math.max(0,i*(1+s)-s)}),jt(o,e.t1)}}}var pt=class{track;constructor(t){this.track=new ye(t)}get value(){return this.track.sample(S.now)}set(t){return this.track.step(S.now,t),this}to(t,e={}){let r=this.track;return{label:"value",duration:e.duration??1,ease:e.ease,schedule(o){let s=r.sample(o.t0);r.add({t0:o.t0,t1:o.t1,ease:o.ease,to:t,at:i=>s+(t-s)*i})}}}};var si=()=>S.now,ii=14,ai=96;function yo(n,t){return!n||!yt(n)?n:n.type==="linear"?{...n,from:Q(t,n.from[0],n.from[1]),to:Q(t,n.to[0],n.to[1])}:n.type==="radial"?{...n,center:Q(t,n.center[0],n.center[1]),radius:n.radius*Xt(t)}:n}function li(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]&&n[4]===t[4]&&n[5]===t[5]}var wo=new WeakMap;function ci(n,t,e){let r=wo.get(n);if(r&&r.path===t&&li(r.matrix,e))return r.world;let o=ot(t,e);return wo.set(n,{path:t,matrix:e,world:o}),o}function ui(n,t,e,r,o){let s=n.get("fill"),i=n.get("stroke"),a=s?r*n.get("fillOpacity"):0,l=i?r*n.get("strokeOpacity"):0,c=n.get("glow");if(a<=.002&&l<=.002&&c<=0)return;let u=ci(n,t,e),h=Xt(e),d=n.get("trimFrom"),m=n.get("trimTo"),p=u;if((d>0||m<1)&&(p=Jt(u,d,m,n.get("trimEach"))),p.length===0&&a<=.002)return;let f=n.get("dash"),b={kind:"path",path:u,strokePath:p,fill:a>.002?yo(s,e):null,fillAlpha:a,stroke:l>.002?yo(i,e):null,strokeAlpha:l,strokeWidth:n.get("strokeWidth")*h,cap:n.get("cap"),join:n.get("join"),dash:f?f.map(y=>y*h):null,dashOffset:n.get("dashOffset")*h,glow:c*h,glowColor:n.get("glowColor"),blend:n.get("blend"),node:n};b.stroke&&yt(b.stroke)&&b.stroke.type==="along"?hi(b,b.stroke,o):o.push(b)}function hi(n,t,e){e.push({...n,stroke:null,strokeAlpha:0});let r={...n,fill:null,fillAlpha:0,glow:0},o=Pt(n.strokePath),s=Pt(n.path);if(o===0)return;let i=s>0?Math.min(1,o/s):1,a=Math.min(ai,Math.max(2,Math.ceil(o/ii))),l=.6/a;for(let c=0;c<a;c++){let u=c/a,h=Math.min(1,(c+1)/a+l),d=Jt(n.strokePath,u,h);d.length!==0&&e.push({...r,strokePath:d,path:d,stroke:lt(t.stops,(c+.5)/a*i),cap:c===0||c===a-1?n.cap:"butt"})}}function jn(n,t,e,r,o){if(!n.get("visible"))return;let s=n.get("opacity")*r;if(s<=.002)return;let i=n.get("fixed")?e:t,a=rt(i,n.localMatrix()),l=n.get("path");l&&l.length>0&&ui(n,l,a,s,o);let c=n.get("image");if(c&&o.push({kind:"image",image:c,matrix:a,alpha:s}),n.rawOps&&n.rawOps(a,s,o),n.draw){let m=n.draw(si());if(m){let p=Array.isArray(m)?m:[m];for(let f of p)jn(f,a,e,s,o)}}let u=n.children;if(u.length===0)return;let h=!1;for(let m=0;m<u.length;m++)if(u[m].get("z")!==0){h=!0;break}let d=h?u.map((m,p)=>({child:m,index:p,z:m.get("z")})).sort((m,p)=>m.z-p.z||m.index-p.index).map(m=>m.child):u;for(let m of d)jn(m,a,e,s,o)}function _n(n,t,e,r){let o=[1,0,0,1,e/2,r/2],s=rt(o,fe(0,0,-t.rotation,t.zoom,t.zoom,t.x,t.y)),i=[];return jn(n,s,o,1,i),i}var xo=7;function Po(n,t){let e=[];for(let r=xo;r>=1;r--){let o=r/xo;e.push({width:t+n*2*o,alpha:.16*(1-o)*(1-o)+.018})}return e}function Ao(n){if(n.glowColor)return n.glowColor;let t=n.stroke??n.fill;return t?yt(t)?lt(t.stops,.5):t:null}var ko=new WeakMap;function on(n){let t=ko.get(n);return t===void 0&&(t=Ur(n),ko.set(n,t)),t}function ft(n){return String(Math.round(n*1e3)/1e3)}function di(n,t){let e=t.stops.map(([r,o])=>`<stop offset="${ft(r)}" stop-color="${Yt([o[0],o[1],o[2],1])}"${o[3]<1?` stop-opacity="${ft(o[3])}"`:""}/>`).join("");return t.type==="linear"?`<linearGradient id="${n}" gradientUnits="userSpaceOnUse" x1="${ft(t.from[0])}" y1="${ft(t.from[1])}" x2="${ft(t.to[0])}" y2="${ft(t.to[1])}">${e}</linearGradient>`:t.type==="radial"?`<radialGradient id="${n}" gradientUnits="userSpaceOnUse" cx="${ft(t.center[0])}" cy="${ft(t.center[1])}" r="${ft(t.radius)}">${e}</radialGradient>`:""}function Mo(n){let t=` stroke-linecap="${n.cap}" stroke-linejoin="${n.join}"`;return n.dash&&(t+=` stroke-dasharray="${n.dash.map(ft).join(" ")}" stroke-dashoffset="${ft(n.dashOffset)}"`),t}function mi(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function Hn(n,t={}){let e=t.scale??1,r=n.width,o=n.height,s=[],i=[],a=0,l=(u,h,d)=>{if(yt(u)){let f=`g${a++}`;return s.push(di(f,u)),`${h}="url(#${f})"${d<1?` ${h}-opacity="${ft(d)}"`:""}`}let m=u,p=m[3]*d;return`${h}="${Yt([m[0],m[1],m[2],1])}"${p<1?` ${h}-opacity="${ft(p)}"`:""}`};n.background&&!t.transparent&&i.push(`<rect width="${r}" height="${o}" fill="${n.background}"/>`);for(let u of n.ops){if(u.kind==="image"){let d=u.matrix;i.push(`<image href="${mi(u.image.src)}" width="${u.image.width}" height="${u.image.height}" transform="matrix(${d.map(ft).join(" ")})"${u.alpha<1?` opacity="${ft(u.alpha)}"`:""} preserveAspectRatio="none"/>`);continue}let h=u.blend!=="normal"?` style="mix-blend-mode:${u.blend}"`:"";if(u.glow>0){let d=Ao(u),m=on(u.strokePath.length?u.strokePath:u.path);if(d&&m){let p=Math.max(u.fillAlpha,u.strokeAlpha),f=n.dark?' style="mix-blend-mode:screen"':"",b=Po(u.glow,u.stroke?u.strokeWidth:0).map(y=>`<path d="${m}" fill="none" stroke="${Yt([d[0],d[1],d[2],1])}" stroke-opacity="${ft(y.alpha*p)}" stroke-width="${ft(y.width)}" stroke-linecap="round" stroke-linejoin="round"/>`).join("");i.push(`<g${f}>${b}</g>`)}}if(u.fill&&u.stroke&&u.strokePath===u.path){i.push(`<path d="${on(u.path)}" ${l(u.fill,"fill",u.fillAlpha)} ${l(u.stroke,"stroke",u.strokeAlpha)} stroke-width="${ft(u.strokeWidth)}"${Mo(u)}${h}/>`);continue}u.fill&&i.push(`<path d="${on(u.path)}" ${l(u.fill,"fill",u.fillAlpha)}${h}/>`),u.stroke&&u.strokePath.length&&i.push(`<path d="${on(u.strokePath)}" fill="none" ${l(u.stroke,"stroke",u.strokeAlpha)} stroke-width="${ft(u.strokeWidth)}"${Mo(u)}${h}/>`)}let c=s.length?`<defs>${s.join("")}</defs>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${r*e}" height="${o*e}" viewBox="0 0 ${r} ${o}">${c}${i.join("")}</svg>`}var vo=new WeakMap;function Gn(n){let t=vo.get(n);if(t)return t;t=new Path2D;for(let e of n){let r=e.p;if(!(r.length<2)){if(t.moveTo(r[0],r[1]),e.straight)for(let o=2;o+5<r.length;o+=6)t.lineTo(r[o+4],r[o+5]);else for(let o=2;o+5<r.length;o+=6)t.bezierCurveTo(r[o],r[o+1],r[o+2],r[o+3],r[o+4],r[o+5]);e.closed&&t.closePath()}}return vo.set(n,t),t}function No(n,t){if(!yt(t))return Yt(t);let e=t.type==="linear"?n.createLinearGradient(t.from[0],t.from[1],t.to[0],t.to[1]):t.type==="radial"?n.createRadialGradient(t.center[0],t.center[1],0,t.center[0],t.center[1],t.radius):null;if(!e)return Yt(lt(t.stops,.5));for(let[r,o]of t.stops)e.addColorStop(r,Yt(o));return e}var pi={normal:"source-over",screen:"screen",multiply:"multiply",overlay:"overlay"};function Kn(n,t,e=1,r){n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.globalCompositeOperation="source-over",n.clearRect(0,0,t.width*e,t.height*e),n.setTransform(e,0,0,e,0,0),t.background&&(n.fillStyle=t.background,n.fillRect(0,0,t.width,t.height));for(let o of t.ops){if(o.kind==="image"){let s=r?.(o.image);if(!s)continue;let i=o.matrix;n.save(),n.transform(i[0],i[1],i[2],i[3],i[4],i[5]),n.globalAlpha=o.alpha,n.drawImage(s,0,0,o.image.width,o.image.height),n.restore();continue}if(n.globalCompositeOperation=pi[o.blend],o.glow>0){let s=Ao(o);if(s){let i=Math.max(o.fillAlpha,o.strokeAlpha),a=n.globalCompositeOperation;t.dark&&(n.globalCompositeOperation="screen"),n.strokeStyle=Yt([s[0],s[1],s[2],1]),n.lineCap="round",n.lineJoin="round",n.setLineDash([]);let l=Gn(o.strokePath.length?o.strokePath:o.path);for(let c of Po(o.glow,o.stroke?o.strokeWidth:0))n.globalAlpha=c.alpha*i,n.lineWidth=c.width,n.stroke(l);n.globalCompositeOperation=a}}o.fill&&(n.globalAlpha=o.fillAlpha,n.fillStyle=No(n,o.fill),n.fill(Gn(o.path))),o.stroke&&o.strokePath.length&&(n.globalAlpha=o.strokeAlpha,n.strokeStyle=No(n,o.stroke),n.lineWidth=o.strokeWidth,n.lineCap=o.cap,n.lineJoin=o.join,n.setLineDash(o.dash?[...o.dash]:[]),n.lineDashOffset=o.dashOffset,n.stroke(Gn(o.strokePath)))}n.globalAlpha=1,n.globalCompositeOperation="source-over"}function fi(n){let t=null;for(let e of n.ops){if(e.kind!=="path")continue;let r=bt(e.path);if(!r)continue;let o=e.stroke?e.strokeWidth/2:0,s={x:r.x-o,y:r.y-o,width:r.width+o*2,height:r.height+o*2};if(!t)t=s;else{let i=Math.min(t.x,s.x),a=Math.min(t.y,s.y);t={x:i,y:a,width:Math.max(t.x+t.width,s.x+s.width)-i,height:Math.max(t.y+t.height,s.y+s.height)-a}}}return t}var bi={"16:9":[1920,1080],"9:16":[1080,1920],"1:1":[1080,1080],"4:3":[1440,1080],"21:9":[2520,1080]},sn=class{root=new N;camera=new N;width;height;fps;look;chapters=[];clips=[];captions=[];updaters=[];time=0;ending=0;constructor(t){let[e,r]=bi[t.aspect??"16:9"];this.width=t.width??e,this.height=t.height??r,this.fps=t.fps??60,this.look=qe(t.look),this.root.mounted=!0,this.camera.mounted=!0}get right(){return this.width/2}get left(){return-this.width/2}get top(){return-this.height/2}get bottom(){return this.height/2}add(t,...e){S.now=this.time;for(let r of[t,...e])r.mounted?r.get("visible")||r.track("visible").step(this.time,!0):(r.parent?.drop(r),r.parent=this.root,this.root.children.push(r),tn(r,this.time));return t}mountAt(t,e){t.mounted||(t.parent?.drop(t),t.parent=this.root,this.root.children.push(t),tn(t,e))}remove(...t){for(let e of t)e.track("visible").step(this.time,!1)}play(...t){let e=t.filter(l=>"schedule"in l),r=t.find(l=>!("schedule"in l))??{};if(e.length===0)return this;let o=Math.max(...e.map(l=>l.duration)),s=r.duration??o,i=this.time,a=i+s;for(let l of e){S.now=i;let c=r.duration!==void 0?a:i+l.duration;l.schedule({t0:i,t1:c,ease:r.ease??l.ease??dt,stage:this})}return this.clips.push({t0:i,t1:a,labels:r.label?[r.label]:e.map(l=>l.label)}),this.time=a,this.ending=Math.max(this.ending,a),S.now=a,this}wait(t=1){return this.time+=t,this.ending=Math.max(this.ending,this.time),S.now=this.time,this}at(t,e){let r=this.time;return this.time=t,S.now=t,e(),this.ending=Math.max(this.ending,this.time),this.time=r,S.now=r,this}chapter(t){return this.chapters.push({title:t,time:this.time}),this}caption(t,e=3){return this.captions.push({t0:this.time,t1:this.time+e,text:t}),this.ending=Math.max(this.ending,this.time+e),this}value(t=0){return new pt(t)}update(t,e,r={}){return this.updaters.push({node:t,fn:e,from:r.from??this.time,to:r.to??1/0}),t}get duration(){return Math.max(this.ending,this.time)}};function gi(n,t){let e=typeof n=="function"?{}:n,r=typeof n=="function"?n:t;if(!r)throw new Error("film(options, build) needs a build function.");let o={kind:"vizmatic.film",options:e,build:r,compile:s=>ln(o,s)};return o}function Ee(n){return!!n&&typeof n=="object"&&n.kind==="vizmatic.film"}var Ot=class{constructor(t){this.promise=t}promise;isVizmaticSuspend=!0};function Xn(n){return typeof n=="object"&&n!==null&&n.isVizmaticSuspend===!0}var an=class{width;height;fps;duration;title;description;look;bloom;background;posterTime;bleed;chapters;clips;captions;stage;constructor(t,e,r){this.stage=t,this.width=t.width,this.height=t.height,this.fps=r.fps??t.fps,this.duration=Math.max(t.duration,1/this.fps),this.title=e.title??"",this.description=e.description??"",this.look=t.look,this.bloom=r.bloom??e.bloom??t.look.bloom;let o=r.background!==void 0?r.background:e.background!==void 0?e.background:t.look.background;this.background=o===null?null:t.look.colors[o]??o,this.posterTime=e.poster,this.bleed=e.bleed===!0,this.chapters=t.chapters,this.clips=t.clips,this.captions=t.captions}get frameCount(){return Math.max(1,Math.round(this.duration*this.fps))}frame(t){let e=Math.max(0,Math.min(this.duration,t)),r=this.stage,o={mode:S.mode,now:S.now};zn(r.look.colors),S.mode="render",S.now=e,S.frame++;try{for(let a of r.updaters)e>=a.from&&e<=a.to&&a.fn(a.node,e);let s=r.camera,i=_n(r.root,{x:s.get("x"),y:s.get("y"),zoom:s.get("sx"),rotation:s.get("rotation")},r.width,r.height);return{width:r.width,height:r.height,background:this.background,bloom:this.bloom,dark:r.look.dark,ops:i}}finally{S.mode=o.mode,S.now=o.now}}svg(t,e={}){return Hn(this.frame(t),e)}};async function ln(n,t={}){let e={...n.options,...t.look?{look:t.look}:{},...t.fps?{fps:t.fps}:{}};for(let r=0;r<64;r++){let o=new sn(e);zn(o.look.colors);let s={mode:S.mode,now:S.now};S.mode="compile",S.now=0;try{await n.build(o),S.mode=s.mode,S.now=s.now;let i=new an(o,e,t);return await yi(i),i}catch(i){if(S.mode=s.mode,S.now=s.now,S.capture=null,i instanceof Ot){await i.promise;continue}throw i}}throw new Error("The film kept requesting new assets while compiling.")}async function yi(n){let t=[0,.25,.5,.75,1];for(let e of t)for(let r=0;r<16;r++)try{n.frame(n.duration*e);break}catch(o){if(!(o instanceof Ot))throw o;await o.promise}}function Oo(n){return{contours:n.filter(t=>t.length>=8)}}var Co=null;function Yn(n){Co=n}var wi=typeof process<"u"&&!!process.versions?.node&&typeof globalThis.document>"u";function So(){let n=import.meta.url;return n||`file://${typeof __filename<"u"?__filename:""}`}async function xi(n){let t="node:fs/promises",e="node:path",r="node:url",[o,s,i]=await Promise.all([import(t),import(e),import(r)]),a=s.dirname(i.fileURLToPath(So()));for(let l=0;l<6;l++){let c=s.join(a,"assets",n);try{let u=await o.readFile(c);return u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength)}catch(u){if(u.code!=="ENOENT")throw u}a=s.dirname(a)}throw new Error(`Bundled asset not found: assets/${n}`)}async function Ro(n){if(wi)return xi(n);let t=Co??new URL("./assets/",So()).href,e=await fetch(new URL(n,t)),r=e.headers.get("content-type")??"";if(!e.ok||r.includes("text/html"))throw new Error(`Could not load ${n} from ${e.url} (HTTP ${e.status}, ${r||"no content type"}). Call setAssetBase() with the folder that holds fonts/.`);return e.arrayBuffer()}var Un=class{constructor(t,e=0){this.bytes=t;this.offset=e;this.view=new DataView(t)}bytes;offset;view;seek(t){return this.offset=t,this}get position(){return this.offset}u8(){return this.view.getUint8(this.offset++)}i8(){return this.view.getInt8(this.offset++)}u16(){let t=this.view.getUint16(this.offset);return this.offset+=2,t}i16(){let t=this.view.getInt16(this.offset);return this.offset+=2,t}u32(){let t=this.view.getUint32(this.offset);return this.offset+=4,t}tag(){let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.u8());return t}};function $o(n){let t=new Un(n),e=t.u32();if(e!==65536&&e!==1953658213)throw new Error("Stage text needs a TrueType (.ttf) font with glyf outlines.");let r=t.u16();t.seek(12);let o=new Map;for(let P=0;P<r;P++){let A=t.tag();t.u32(),o.set(A,{offset:t.u32(),length:t.u32()})}let s=P=>{let A=o.get(P);if(!A)throw new Error(`Font is missing its ${P} table.`);return A},i=s("head");t.seek(i.offset+18);let a=t.u16();t.seek(i.offset+50);let l=t.i16()===1,c=s("hhea");t.seek(c.offset+4);let u=t.i16(),h=t.i16(),d=t.i16();t.seek(c.offset+34);let m=t.u16();t.seek(s("maxp").offset+4);let p=t.u16(),f=s("hmtx"),b=s("loca"),y=s("glyf"),g=Mi(t,s("cmap").offset),w=o.has("GPOS")?vi(t,o.get("GPOS").offset):()=>0,x=P=>{let A=Math.min(P,m-1);return t.seek(f.offset+A*4),t.u16()},k=new Map,M=(P,A)=>{if(P>=p||A>6)return[];t.seek(b.offset+(l?P*4:P*2));let O=l?t.u32():t.u16()*2,R=l?t.u32():t.u16()*2;if(O===R)return[];t.seek(y.offset+O);let $=t.i16();if(t.seek(t.position+8),$<0)return v(P,A);let z=[];for(let T=0;T<$;T++)z.push(t.u16());let B=t.u16();t.seek(t.position+B);let W=(z[z.length-1]??-1)+1,G=[];for(;G.length<W;){let T=t.u8();if(G.push(T),T&8){let V=t.u8();for(;V-- >0;)G.push(T)}}let U=new Array(W),C=0;for(let T=0;T<W;T++){let V=G[T];if(V&2){let j=t.u8();C+=V&16?j:-j}else V&16||(C+=t.i16());U[T]=C}let L=new Array(W),I=0;for(let T=0;T<W;T++){let V=G[T];if(V&4){let j=t.u8();I+=V&32?j:-j}else V&32||(I+=t.i16());L[T]=I}let F=[],E=0;for(let T of z)F.push(ki(U,L,G,E,T)),E=T+1;return F};function v(P,A){let O=[],R=!0;for(;R;){let z=t.u16(),B=t.u16(),W=(z&1)!==0,G=(z&2)!==0,U=0,C=0;W?(U=t.i16(),C=t.i16()):(U=t.i8(),C=t.i8()),G||(U=0,C=0);let L=1,I=0,F=0,E=1,T=()=>t.i16()/16384;z&8?L=E=T():z&64?(L=T(),E=T()):z&128&&(L=T(),I=T(),F=T(),E=T()),O.push({glyph:B,m:[L,I,F,E,U,C]}),R=(z&32)!==0}let $=[];for(let z of O)for(let B of M(z.glyph,A+1)){let W=new Array(B.length),[G,U,C,L,I,F]=z.m;for(let E=0;E<B.length;E+=2)W[E]=G*B[E]+C*B[E+1]+I,W[E+1]=U*B[E]+L*B[E+1]+F;$.push(W)}return $}return{unitsPerEm:a,ascent:u,descent:h,lineGap:d,glyphFor(P){return g(P)},advance:x,kern(P,A){return w(P,A)},outline(P){if(k.has(P))return k.get(P);let A=M(P,0),O=A.length?Oo(A):null;return k.set(P,O),O}}}function ki(n,t,e,r,o){let s=o-r+1;if(s<2)return[];let i=w=>r+(w%s+s)%s,a=w=>(e[i(w)]&1)!==0,l=0;for(;l<s&&!a(l);)l++;let c,u;l===s?(c=(n[i(0)]+n[i(s-1)])/2,u=(t[i(0)]+t[i(s-1)])/2,l=0):(c=n[i(l)],u=t[i(l)],l+=1);let h=[c,u],d=c,m=u,p=0,f=0,b=!1,y=(w,x,k,M)=>{h.push(d+(w-d)*2/3,m+(x-m)*2/3,k+(w-k)*2/3,M+(x-M)*2/3,k,M),d=k,m=M},g=(w,x)=>{h.push(d+(w-d)/3,m+(x-m)/3,d+(w-d)*2/3,m+(x-m)*2/3,w,x),d=w,m=x};for(let w=0;w<s;w++){let x=l+w,k=n[i(x)],M=t[i(x)];a(x)?b?(y(p,f,k,M),b=!1):(k!==d||M!==m)&&g(k,M):(b&&y(p,f,(p+k)/2,(f+M)/2),p=k,f=M,b=!0)}return b?y(p,f,c,u):(d!==c||m!==u)&&g(c,u),h}function Mi(n,t){n.seek(t+2);let e=n.u16(),r=-1,o=-1;for(let i=0;i<e;i++){let a=n.u16(),l=n.u16(),c=n.u32(),u=a===3&&l===10?4:a===0&&l>=4?3:a===3&&l===1?2:a===0?1:0;u>o&&(o=u,r=t+c)}if(r<0)return()=>0;n.seek(r);let s=n.u16();if(s===12){n.seek(r+12);let i=n.u32(),a=[];for(let l=0;l<i;l++)a.push([n.u32(),n.u32(),n.u32()]);return l=>{let c=0,u=a.length-1;for(;c<=u;){let h=c+u>>1,[d,m,p]=a[h];if(l<d)u=h-1;else if(l>m)c=h+1;else return p+l-d}return 0}}if(s===4){n.seek(r+6);let i=n.u16(),a=i/2,l=r+14,c=l+i+2,u=c+i,h=u+i,d=new Map;for(let m=0;m<a;m++){let p=n.seek(l+m*2).u16(),f=n.seek(c+m*2).u16(),b=n.seek(u+m*2).i16(),y=n.seek(h+m*2).u16();for(let g=f;g<=p&&g!==65535;g++){let w;if(y===0)w=g+b&65535;else{let x=n.seek(h+m*2+y+(g-f)*2).u16();w=x===0?0:x+b&65535}w&&d.set(g,w)}}return m=>d.get(m)??0}return()=>0}function vi(n,t){let e=[];try{n.seek(t+6);let o=t+n.u16(),s=t+n.u16();n.seek(o);let i=n.u16(),a=new Set;for(let l=0;l<i;l++){n.seek(o+2+l*6);let c=n.tag(),u=n.u16();if(c!=="kern")continue;n.seek(o+u+2);let h=n.u16();for(let d=0;d<h;d++)a.add(n.u16())}for(let l of[...a].sort((c,u)=>c-u)){n.seek(s+2+l*2);let c=s+n.u16();n.seek(c);let u=n.u16();n.u16();let h=n.u16(),d=[];for(let p=0;p<h;p++)d.push(c+n.u16());let m=[];for(let p of d){let f=p,b=u;b===9&&(n.seek(f+2),b=n.u16(),f+=n.u32()),b===2&&m.push(Pi(n,f))}e.push(m)}}catch{}let r=new Map;return(o,s)=>{let i=o*65536+s,a=r.get(i);if(a!==void 0)return a;let l=0;for(let c of e)for(let u of c){let h=u(o,s);if(h!==void 0){l+=h;break}}return r.set(i,l),l}}function Ni(n,t){n.seek(t);let e=n.u16(),r=new Set;if(e===1){let o=n.u16();for(let s=0;s<o;s++)r.add(n.u16())}else if(e===2){let o=n.u16();for(let s=0;s<o;s++){let i=n.u16(),a=n.u16();n.u16();for(let l=i;l<=a;l++)r.add(l)}}return r}function To(n,t){n.seek(t);let e=n.u16(),r=new Map;if(e===1){let o=n.u16(),s=n.u16();for(let i=0;i<s;i++)r.set(o+i,n.u16())}else if(e===2){let o=n.u16();for(let s=0;s<o;s++){let i=n.u16(),a=n.u16(),l=n.u16();for(let c=i;c<=a;c++)r.set(c,l)}}return o=>r.get(o)??0}function Fo(n){let t=0;for(let e=0;e<8;e++)n&1<<e&&t++;return t*2}function Io(n,t){let e=0;t&1&&n.i16(),t&2&&n.i16(),t&4&&(e=n.i16()),t&8&&n.i16();for(let r=4;r<8;r++)t&1<<r&&n.u16();return e}function Pi(n,t){n.seek(t);let e=n.u16(),r=n.u16(),o=n.u16(),s=n.u16(),i=Fo(o),a=Fo(s);if(e===1){let l=n.u16(),c=[];for(let m=0;m<l;m++)c.push(n.u16());n.seek(t+r);let u=n.u16(),h=[];if(u===1){let m=n.u16();for(let p=0;p<m;p++)h.push(n.u16())}else if(u===2){let m=n.u16();for(let p=0;p<m;p++){let f=n.u16(),b=n.u16();n.u16();for(let y=f;y<=b;y++)h.push(y)}}let d=new Map;for(let m=0;m<l;m++){n.seek(t+c[m]);let p=n.u16(),f=new Map;for(let b=0;b<p;b++){let y=n.u16(),g=Io(n,o);n.seek(n.position+a),f.set(y,g)}h[m]!==void 0&&d.set(h[m],f)}return(m,p)=>d.get(m)?.get(p)}if(e===2){let l=n.u16(),c=n.u16(),u=n.u16(),h=n.u16(),d=n.position,m=Ni(n,t+r),p=To(n,t+l),f=To(n,t+c);return(b,y)=>{if(!m.has(b))return;let g=p(b),w=f(y);if(!(g>=u||w>=h))return n.seek(d+g*h*(i+a)+w*(i+a)),Io(n,o)}}return()=>{}}var Ai={sans:{400:"Inter-Regular.ttf",600:"Inter-SemiBold.ttf",700:"Inter-Bold.ttf"},serif:{400:"InstrumentSerif-Regular.ttf",italic:"InstrumentSerif-Italic.ttf"},"text-serif":{400:"SourceSerif4-24pt-Regular.ttf",italic:"SourceSerif4-24pt-Italic.ttf"},mono:{400:"JetBrainsMono-Regular.ttf"},noto:{400:"NotoSans-Regular.ttf"},math:{400:"NotoSansMath-Regular.ttf"}},Oi={sans:["noto","math"],serif:["text-serif","noto","math"],"text-serif":["noto","math"],mono:["noto","math"],noto:["math"]},Eo=new Map,qn=new Map;function xe(n,t=400,e=!1){let r=Ai[n],o=(e?r.italic:void 0)??r[String(t)]??r[400],s=Eo.get(o);if(s)return s;let i=qn.get(o);throw i||(i=Ro(`fonts/${o}`).then(a=>{Eo.set(o,$o(a)),qn.delete(o)}),qn.set(o,i)),new Ot(i)}function Lo(n,t,e=400,r=!1){for(let o of Oi[n]){let s=xe(o,e,r),i=s.glyphFor(t);if(i!==0)return{font:s,glyph:i}}return null}var zo=new WeakMap;function ze(n,t,e){let r=zo.get(n);r||zo.set(n,r=new Map);let o=r.get(e);o||r.set(e,o=new Map);let s=o.get(t);if(s)return s;let i=n.outline(t),a=e/n.unitsPerEm,l=i?i.contours.map(c=>{let u=new Float64Array(c.length);for(let h=0;h<c.length;h+=2)u[h]=c[h]*a,u[h+1]=-c[h+1]*a;return Mt(u,!0)}):[];return o.set(t,l),l}var cn=class extends N{chars=[];source="";find(t){let e=[],r=this.chars.map(s=>s.data.key).join(""),o=t.replace(/\s/g,"");for(let s=r.indexOf(o);s>=0;s=r.indexOf(o,s+1))e.push(...this.chars.slice(s,s+o.length));return e}};function Ci(n){let t=bt(n);if(!t)return{path:n,x:0,y:0};let e=t.x+t.width/2,r=t.y+t.height/2;return{path:ot(n,[1,0,0,1,-e,-r]),x:e,y:r}}function H(n,t={}){let e=t.size??40,r=t.font??"sans",o=t.weight??400,s=t.italic??!1,i=xe(r,o,s),a=e/i.unitsPerEm,l=(t.tracking??0)*e,c=(t.leading??1.3)*e,u=X(t.color??"ink"),h=t.uppercase?n.toUpperCase():n,d=x=>{let k=[],M=0,v=0,P=null;for(let A of x){let O=A.codePointAt(0),R=i,$=i.glyphFor(O);if($===0){let B=Lo(r,O,o,s);B&&(R=B.font,$=B.glyph)}let z=e/R.unitsPerEm;v&&P===R&&(M+=R.kern(v,$)*z),k.push({font:R,glyph:$,x:M,char:A}),M+=R.advance($)*z+l,v=$,P=R}return{glyphs:k,width:M}},m=[],p=i.advance(i.glyphFor(32))*a+l;for(let x of h.split(`
2
- `)){let k=[],M=0;for(let v of x.split(" ")){let P=d(v),A=k.length>0?p:0;t.maxWidth!==void 0&&k.length>0&&M+A+P.width>t.maxWidth&&(m.push({glyphs:k,width:M}),k=[],M=0);let O=M+(k.length>0?p:0);for(let R of P.glyphs)k.push({...R,x:R.x+O});M=O+P.width}m.push({glyphs:k,width:M})}let f=Math.max(0,...m.map(x=>x.width)),b=t.align??"left",y=new cn;y.source=n,m.forEach((x,k)=>{let M=b==="left"?0:b==="center"?(f-x.width)/2:f-x.width;for(let v of x.glyphs){let P=ze(v.font,v.glyph,e);if(P.length===0)continue;let A=Ci(P),O=new N(A.path).at(M+v.x+A.x,k*c+A.y);O.base.fill=u,O.base.trimEach=!0,O.data.key=v.char,v.glyph===0&&(O.data.missingGlyph=!0),y.chars.push(O),y.children.push(O),O.parent=y}});let g=i.ascent*a,w=(m.length-1)*c;return y.base.px=f/2,y.base.py=w/2-g*.36,y.data.size=e,y}var un=class extends N{glyphs=[];source="";part(t){let e=Wo(t),r=this.glyphs.map(o=>o.data.key);for(let o=0;o+e.length<=r.length;o++)if(e.every((s,i)=>s===r[o+i]))return this.glyphs.slice(o,o+e.length);return[]}parts(t){let e=Wo(t),r=this.glyphs.map(s=>s.data.key),o=[];for(let s=0;s+e.length<=r.length;s++)e.every((i,a)=>i===r[s+a])&&(o.push(this.glyphs.slice(s,s+e.length)),s+=e.length-1);return o}},Zn=null,Vo=null,Bo=new Map;function Si(){if(Zn)return Zn;throw Vo??=import("./math-4WFNHVV2.js").then(n=>{Zn=(t,e)=>n.renderMathSvg(t,{fontSize:1e3,display:e,color:"#000000"}).svg}),new Ot(Vo)}function Do(n,t){let e=`${t?"D":"I"}${n}`,r=Bo.get(e);if(r)return r;let o=Si()(n,t),s=[],i=[],a=[1,0,0,1,0,0],l=/viewBox="([^"]+)"/.exec(o)?.[1]?.trim().split(/[ ,]+/).map(Number)??[0,0,1e3,1e3],u=Number(/\swidth="([\d.]+)px"/.exec(o)?.[1]??1e3)/l[2]/1e3,h=/<(\/?)([a-zA-Z]+)((?:\s+[-\w:]+="[^"]*")*)\s*(\/?)>/g,d=0,m=null,p=[];for(let b=h.exec(o);b;b=h.exec(o)){let[,y,g,w="",x]=b,k=P=>new RegExp(`\\s${P}="([^"]*)"`).exec(w)?.[1];if(g==="svg"){if(y){d--,d>=1&&(a=i.pop()??a,m=p.pop()??null);continue}if(d++,d>1){let P=(k("viewBox")??"0 0 1 1").trim().split(/[ ,]+/).map(Number),A=Number(k("width")??P[2]),O=Number(k("height")??P[3]),R=rt([A/(P[2]||1),0,0,O/(P[3]||1),Number(k("x")??0),Number(k("y")??0)],[1,0,0,1,-P[0],-P[1]]);i.push(a),p.push(m),a=rt(a,R),m=[P[0],P[1],P[0]+P[2],P[1]+P[3]]}continue}if(y){g==="g"&&(a=i.pop()??a);continue}let M=k("transform"),v=M?Ti(M):[1,0,0,1,0,0];if(g==="g"){x||(i.push(a),a=rt(a,v));continue}if(g==="path"){let P=k("d");if(!P)continue;let A=k("data-c"),O=ot(vt(P),v);s.push({path:ot(m?Ri(O,m):O,a),key:A?String.fromCodePoint(parseInt(A,16)):"?"})}else if(g==="rect"){let P=Number(k("x")??0),A=Number(k("y")??0),O=Number(k("width")??0),R=Number(k("height")??0);O>0&&R>0&&s.push({path:ot(K(P,A,O,R),rt(a,v)),key:"rule"})}}let f=s.map(b=>({key:b.key,path:ot(b.path,[u,0,0,u,0,0])}));return Bo.set(e,f),f}function Ri(n,t){return n.map(e=>{let r=new Float64Array(e.p.length);for(let o=0;o<r.length;o+=2)r[o]=Math.max(t[0],Math.min(t[2],e.p[o])),r[o+1]=Math.max(t[1],Math.min(t[3],e.p[o+1]));return{p:r,closed:e.closed}})}function Ti(n){let t=[1,0,0,1,0,0];for(let e of n.matchAll(/(translate|scale|matrix)\(([^)]*)\)/g)){let r=e[2].trim().split(/[ ,]+/).map(Number);e[1]==="translate"?t=rt(t,[1,0,0,1,r[0]??0,r[1]??0]):e[1]==="scale"?t=rt(t,[r[0]??1,0,0,r[1]??r[0]??1,0,0]):r.length===6&&(t=rt(t,r))}return t}function Wo(n){return Do(n,!1).map(t=>t.key)}function st(n,t={}){let e=t.size??56,r=t.display??!0,o=Do(n,r),s=X(t.color??"ink"),i=new un;i.source=n;let a=1/0,l=1/0,c=-1/0,u=-1/0;for(let h of o){let d=ot(h.path,[e,0,0,e,0,0]),m=bt(d);if(!m)continue;a=Math.min(a,m.x),l=Math.min(l,m.y),c=Math.max(c,m.x+m.width),u=Math.max(u,m.y+m.height);let p=m.x+m.width/2,f=m.y+m.height/2,b=new N(ot(d,[1,0,0,1,-p,-f])).at(p,f);b.base.fill=s,b.base.trimEach=!0,b.data.key=h.key,i.glyphs.push(b),i.children.push(b),b.parent=i}return a!==1/0&&(i.base.px=(a+c)/2,i.base.py=(l+u)/2),i}function Tt(n,t,e){let r=t.fill!==void 0?t.fill:e.fill,o=t.stroke!==void 0?t.stroke:e.stroke;return r&&n.fill(r),o&&n.stroke(o,t.width??e.width??3),t.opacity!==void 0&&n.opacity(t.opacity),t.glow&&n.glow(t.glow),t.dash&&n.dash(t.dash),t.z!==void 0&&n.zIndex(t.z),n}function Fi(n,t={}){return Tt(new N(n),t,{stroke:"ink"})}function hc(n,t={}){return Fi(vt(n),t)}function Y(n,t,e={}){return Tt(new N(le(n,t)),e,{stroke:"ink"})}function dc(n,t={}){return Tt(new N(Z(n,t.closed)),t,{stroke:"ink"})}function mc(n,t={}){return Tt(new N(t.closed?Lt(n,!0):be(n)),t,{stroke:"ink"})}function pc(n,t,e,r={}){return Tt(new N(He(n,t,e,r.samples??96)),r,{stroke:"ink"})}function Go(n,t={}){return Tt(new N(Dt(0,0,n)),t,{stroke:"ink"})}function fc(n,t,e={}){return Tt(new N(St(0,0,n,t,0,Math.PI*2)),e,{stroke:"ink"})}function bc(n,t,e,r={}){return Tt(new N(St(0,0,n,n,t,e)),r,{stroke:"ink"})}function jo(n,t,e={}){return Tt(new N(K(-n/2,-t/2,n,t,e.radius??0)),e,{stroke:"ink"})}function Ii(n,t={}){return Tt(new N(Z(n,!0)),t,{stroke:"ink"})}function gc(n,t,e={}){let r=[];for(let o=0;o<n;o++){let s=-Math.PI/2+o/n*Math.PI*2;r.push([Math.cos(s)*t,Math.sin(s)*t])}return Ii(r,e)}function Ei(n){let t=/^data:image\/(png|gif|jpeg|jpg);base64,/.exec(n);if(!t||typeof atob!="function")return null;let e;try{e=atob(n.slice(t[0].length,t[0].length+(t[1]==="jpeg"||t[1]==="jpg"?87384:44)))}catch{return null}let r=o=>e.charCodeAt(o);if(t[1]==="png")return e.length>=24?[r(16)*16777216+r(17)*65536+r(18)*256+r(19),r(20)*16777216+r(21)*65536+r(22)*256+r(23)]:null;if(t[1]==="gif")return e.length>=10?[r(6)+r(7)*256,r(8)+r(9)*256]:null;for(let o=2;o+9<e.length;){if(r(o)!==255)return null;let s=r(o+1);if(s>=192&&s<=207&&s!==196&&s!==200&&s!==204)return[r(o+7)*256+r(o+8),r(o+5)*256+r(o+6)];o+=2+r(o+2)*256+r(o+3)}return null}function yc(n,t={}){let e=Ei(n),r=t.width,o=t.height;if(r===void 0&&o===void 0){if(!e)throw new Error("image() needs a width or a height when the picture is not a PNG, GIF, or JPEG data URL.");[r,o]=e}else if(r===void 0||o===void 0){if(!e)throw new Error("image() needs both width and height when the picture is not a PNG, GIF, or JPEG data URL.");r===void 0?r=o*e[0]/e[1]:o=r*e[1]/e[0]}if(!(r>0)||!(o>0))throw new Error("image() needs a positive width and height.");let s=new N().at(-r/2,-o/2);s.base.image={src:n,width:r,height:o};let i=new N;return i.add(s),t.opacity!==void 0&&i.opacity(t.opacity),i}function gt(n=9,t="ink",e={}){return Tt(new N(Dt(0,0,n)),e,{fill:t})}function $e(n,t,e={}){let r=e.stroke??"ink",o=e.width??3,s=e.tip??Math.max(13,o*4.2),i=e.tipRatio??.72,a=e.pad??0,l=t[0]-n[0],c=t[1]-n[1],u=Math.hypot(l,c)||1;l/=u,c/=u;let h=[n[0]+l*a,n[1]+c*a],d=[t[0]-l*a,t[1]-c*a],m=Math.max(0,u-a*2),p=Math.min(s,m*.45),f=new N,b=e.bend??0,y=[-c,l],g=[(h[0]+d[0])/2+y[0]*b,(h[1]+d[1])/2+y[1]*b],w=d[0]-g[0],x=d[1]-g[1],k=Math.hypot(w,x)||1;w/=k,x/=k;let M=d[0]-w*p,v=d[1]-x*p,P=b===0?le(e.both?[h[0]+l*p,h[1]+c*p]:h,[M,v]):vt(`M${h[0]} ${h[1]}Q${g[0]} ${g[1]} ${M} ${v}`),A=new N(P).stroke(r,o);e.dash&&A.dash(e.dash);let O=p*i/2,R=($,z,B,W)=>new N(Z([[$,z],[$-B*p-W*O,z-W*p+B*O],[$-B*p+W*O,z-W*p-B*O]],!0)).fill(r);return f.add(A,R(d[0],d[1],w,x)),e.both&&f.add(R(h[0],h[1],-l,-c)),e.opacity!==void 0&&f.opacity(e.opacity),e.glow&&A.glow(e.glow),f.data.shaft=A,f}function _o(n,t,e={}){let r=t[0]-n[0],o=t[1]-n[1],s=Math.hypot(r,o)||1,i=e.depth??Math.min(26,10+s*.05),a=s,l=i,c=1.6,u=Math.min(l,a/4),h=`M0 0C0 ${l*.5} ${u*.4} ${l*.5} ${u} ${l*.5}L${a/2-u} ${l*.5}C${a/2-u*.3} ${l*.5} ${a/2} ${l*.72} ${a/2} ${l}C${a/2} ${l*.72} ${a/2+u*.3} ${l*.5} ${a/2+u} ${l*.5}L${a-u} ${l*.5}C${a-u*.4} ${l*.5} ${a} ${l*.5} ${a} 0L${a-c*.2} ${c*.2}C${a-c*.4} ${l*.5-c} ${a-u*.4} ${l*.5-c} ${a-u} ${l*.5-c}L${a/2+u} ${l*.5-c}C${a/2+u*.3} ${l*.5-c} ${a/2+c*.4} ${l*.6} ${a/2} ${l*.82}C${a/2-c*.4} ${l*.6} ${a/2-u*.3} ${l*.5-c} ${a/2-u} ${l*.5-c}L${u} ${l*.5-c}C${u*.4} ${l*.5-c} ${c*.4} ${l*.5-c} ${c*.2} ${c*.2}Z`,d=r/s,m=o/s,p=ot(vt(h),[d,m,-m,d,n[0],n[1]]),f=Tt(new N(p),{...e,width:void 0},{fill:e.stroke??e.fill??"ink"});return f.data.tip=[(n[0]+t[0])/2-m*i,(n[1]+t[1])/2+d*i],f}var Jn=class extends N{xRange;yRange;plotWidth;plotHeight;lines=new N;grid=new N;numbers=new N;constructor(t={}){super(),this.xRange=t.x??[-5,5],this.yRange=t.y??[-3,3],this.plotWidth=t.width??1100,this.plotHeight=t.height??640;let e=t.color??"dim",r=t.xStep??Ho(this.xRange[1]-this.xRange[0]),o=t.yStep??Ho(this.yRange[1]-this.yRange[0]),s=hn(0,this.xRange),i=hn(0,this.yRange),a=this.p(this.xRange[0],i),l=this.p(this.xRange[1],i),c=this.p(s,this.yRange[0]),u=this.p(s,this.yRange[1]);if(t.grid){for(let p of ke(this.xRange,r))this.grid.add(Y(this.p(p,this.yRange[0]),this.p(p,this.yRange[1]),{stroke:"grid",width:1.25}));for(let p of ke(this.yRange,o))this.grid.add(Y(this.p(this.xRange[0],p),this.p(this.xRange[1],p),{stroke:"grid",width:1.25}))}let h=t.tips??!0,d=(p,f)=>h?$e(p,f,{stroke:e,width:2,tip:13}):Y(p,f,{stroke:e,width:2});this.lines.add(d(a,l),d(c,u));let m=6;for(let p of ke(this.xRange,r)){if(p===s)continue;let[f,b]=this.p(p,i);this.lines.add(Y([f,b-m],[f,b+m],{stroke:e,width:2}))}for(let p of ke(this.yRange,o)){if(p===i)continue;let[f,b]=this.p(s,p);this.lines.add(Y([f-m,b],[f+m,b],{stroke:e,width:2}))}if(t.labels??!0){let p=t.labelSize??20;for(let f of ke(this.xRange,r)){if(f===s)continue;let[b,y]=this.p(f,i);this.numbers.add(st(Ko(f),{size:p,color:"dim",display:!1}).moveTo([b,y+26]))}for(let f of ke(this.yRange,o)){if(f===i)continue;let[b,y]=this.p(s,f);this.numbers.add(st(Ko(f),{size:p,color:"dim",display:!1}).moveTo([b-28,y]))}}if(this.add(this.grid,this.lines,this.numbers),t.xLabel&&this.add(st(t.xLabel,{size:28,color:"ink",display:!1}).moveTo([l[0]+4,l[1]-26])),t.yLabel){let p=st(t.yLabel,{size:28,color:"ink",display:!1});this.add(p.moveTo([u[0]+16+p.width/2,u[1]+4]))}}p(t,e){let[r,o]=this.xRange,[s,i]=this.yRange;return[((t-r)/(o-r)-.5)*this.plotWidth,(.5-(e-s)/(i-s))*this.plotHeight]}world(t,e){let[r,o]=this.p(t,e);return this.toWorld(r,o)}plotPath(t,e={}){let r=e.from??this.xRange[0],o=e.to??this.xRange[1],s=e.samples??160,[i,a]=this.yRange,l=(a-i)*.02,c=[];for(let u=0;u<=s;u++){let h=r+(o-r)*u/s,d=t(h);c.push(Number.isFinite(d)&&d>=i-l&&d<=a+l?this.p(h,d):[NaN,NaN])}return be(c)}plot(t,e={}){let r=new N(this.plotPath(t,e)).stroke(e.stroke??"blue",e.width??4);return e.glow&&r.glow(e.glow),e.dash&&r.dash(e.dash),this.add(r),r}dotAt(t,e,r="yellow",o=9){let s=gt(o,r).at(this.p(t,e));return this.add(s),s}guides(t,e,r={}){let o=hn(0,this.xRange),s=hn(0,this.yRange),i=Vn(Y(this.p(t,s),this.p(t,e),{stroke:"dim",width:2,dash:[6,7],...r}),Y(this.p(o,e),this.p(t,e),{stroke:"dim",width:2,dash:[6,7],...r}));return this.add(i),i}};function Pc(n={}){return new Jn(n)}function hn(n,t){return Math.max(t[0],Math.min(t[1],n))}function Ho(n){let t=n/8,e=Math.pow(10,Math.floor(Math.log10(t))),r=t/e;return(r<1.5?1:r<3.5?2:r<7.5?5:10)*e}function ke(n,t){let e=[],r=Math.ceil(n[0]/t-1e-9)*t;for(let o=r;o<=n[1]+1e-9;o+=t)e.push(Math.round(o/t)*t);return e}function Ko(n){let t=Math.round(n*1e3)/1e3;return String(t)}var Le=class extends N{unit;major=new N;minor=new N;axes=new N;constructor(t={}){super(),this.unit=t.unit??120;let[e,r]=t.x??[-12,12],[o,s]=t.y??[-8,8],i=this.unit,a=t.color??"blue",l=t.width??1.6,c=t.minor??0,u=(p,f,b)=>{let y=[];for(let g=0;g<=b;g++)y.push([p[0]+(f[0]-p[0])*g/b,p[1]+(f[1]-p[1])*g/b]);return y.length>2?be(y):le(p,f)},h=16,d=(p,f,b,y,g,w)=>{p.add(new N(u(f,b,w)).stroke(y,g))};for(let p=e;p<=r;p++){if(c>0&&p<r)for(let f=1;f<c;f++){let b=p+f/c;d(this.minor,[b*i,o*i],[b*i,s*i],"grid",1,h)}p!==0&&d(this.major,[p*i,o*i],[p*i,s*i],a,l,h)}for(let p=o;p<=s;p++){if(c>0&&p<s)for(let f=1;f<c;f++){let b=p+f/c;d(this.minor,[e*i,b*i],[r*i,b*i],"grid",1,h)}p!==0&&d(this.major,[e*i,p*i],[r*i,p*i],a,l,h)}let m=t.axisColor??"ink";d(this.axes,[e*i,0],[r*i,0],m,2.6,h),d(this.axes,[0,o*i],[0,s*i],m,2.6,h),this.add(this.minor,this.major,this.axes)}p(t,e){return[t*this.unit,-e*this.unit]}vector(t,e,r={}){return $e([0,0],this.p(t,e),{stroke:"yellow",width:5,tip:22,...r})}};function Ac(n={}){return new Le(n)}function Oc(n,t={}){let e=new N;return e.draw=()=>{let r=n(),o=(t.prefix??"")+r.toFixed(t.digits??2)+(t.suffix??"");return H(o,{size:t.size??36,color:t.color??"ink",font:t.font??"mono"})},e}var dn=1,Xo=.08,Yo=.15,zi=.12,$i=.12,Li=5,qo=12,Uo=6,Vi=2,Qn=.25,Zo=.5,Bi=.2,Wi=2,Di=1.6,Jo=.9;function Qo(n){return yt(n)?lt(n.stops,.5):n}function ts(n){let t=e=>{let r=e/255;return r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)};return .2126*t(n[0])+.7152*t(n[1])+.0722*t(n[2])}function Gi(n,t,e){let r=n[3]*t,o=[n[0]*r+e[0]*(1-r),n[1]*r+e[1]*(1-r),n[2]*r+e[2]*(1-r),1],s=ts(o),i=ts(e);return(Math.max(s,i)+.05)/(Math.min(s,i)+.05)}function es(n,t){return{x:n.x-t,y:n.y-t,width:n.width+t*2,height:n.height+t*2}}function ji(n,t){let e=n.width*t,r=n.height*t;return{x:n.x+e,y:n.y+r,width:n.width-e*2,height:n.height-r*2}}function Ve(n,t){return n.x<t.x+t.width&&t.x<n.x+n.width&&n.y<t.y+t.height&&t.y<n.y+n.height}function _i(n,t){let e=Math.max(n.x,t.x),r=Math.max(n.y,t.y),o=Math.min(n.x+n.width,t.x+t.width),s=Math.min(n.y+n.height,t.y+t.height);return o>e&&s>r?{x:e,y:r,width:o-e,height:s-r}:null}function Hi(n,t){return n.x<=t.x&&n.y<=t.y&&n.x+n.width>=t.x+t.width&&n.y+n.height>=t.y+t.height}function mn(n,t){let e=Math.min(n.x,t.x),r=Math.min(n.y,t.y);return{x:e,y:r,width:Math.max(n.x+n.width,t.x+t.width)-e,height:Math.max(n.y+n.height,t.y+t.height)-r}}function Ki(n,t,e,r,o){let s=0,i=1,a=e-n,l=r-t,c=[[-a,n-o.x],[a,o.x+o.width-n],[-l,t-o.y],[l,o.y+o.height-t]];for(let[u,h]of c)if(u===0){if(h<0)return!1}else{let d=h/u;if(u<0){if(d>i)return!1;d>s&&(s=d)}else{if(d<s)return!1;d<i&&(i=d)}}return s<=i}function Xi(n,t){for(let e of n){let r=e.p;for(let o=0;o+7<r.length;o+=6){let s=r[o],i=r[o+1],a=r[o+2],l=r[o+3],c=r[o+4],u=r[o+5],h=r[o+6],d=r[o+7],m=Math.min(s,a,c,h),p=Math.max(s,a,c,h),f=Math.min(i,l,u,d),b=Math.max(i,l,u,d);if(p<t.x||m>t.x+t.width||b<t.y||f>t.y+t.height)continue;let y=s,g=i;for(let w=1;w<=Uo;w++){let x=w/Uo,k=1-x,M=k*k*k,v=3*k*k*x,P=3*k*x*x,A=x*x*x,O=M*s+v*a+P*c+A*h,R=M*i+v*l+P*u+A*d;if(Ki(y,g,O,R,t))return!0;y=O,g=R}}}return!1}function Yi(n){return n.data.key!==void 0?n.parent:null}function qi(n){return!!n.node&&n.node.data.key!==void 0}function tr(n){let t=n.source;return typeof t=="string"?t:""}function Ui(n){if(!n)return"unknown";let t=n;for(;t.parent&&t.parent.parent;)t=t.parent;return t.mounted?String(t.id):"dynamic"}function Zi(n,t){let e=new Set,r=n.clips,o=i=>r.some(a=>a.t0<i&&i<a.t1),s=.001;for(let i of r){let a=i.t1+s;a<n.duration&&!o(a)&&e.add(a)}e.add(Math.max(0,n.duration-s));for(let i=0;i<t;i++)e.add((i+.5)/t*n.duration);if(e.size<Li)for(let i=0;i<qo;i++){let a=(i+.5)/qo*n.duration;o(a)||e.add(a)}return[...e].sort((i,a)=>i-a)}function er(n,t){try{return n.frame(t)}catch(e){if(!Xn(e))throw e;return e.promise.then(()=>er(n,t))}}function ns(n,t){let e=n.stage.camera,r=e.tracks?.get("sx");return r?r.sample(t):e.base.sx}function rs(n,t,e,r){let o=[],{width:s,height:i,ops:a}=n,l=n.background?Gt(n.background):n.dark?[0,0,0,1]:[255,255,255,1],c={x:0,y:0,width:s,height:i},u=new Map,h=[],d=[],m=new Map,p=0;a.forEach((g,w)=>{if(g.kind!=="path"||g.path.length===0)return;let x=qi(g);if(Math.max(g.fillAlpha,g.strokeAlpha)<Xo)return;let M=bt(g.path);if(!M)return;let v=g.stroke?es(M,g.strokeWidth/2):M,P=x?Yi(g.node):null,A=v.x<-dn||v.y<-dn||v.x+v.width>s+dn||v.y+v.height>i+dn,O=v.x<=0&&v.x+v.width>=s||v.y<=0&&v.y+v.height>=i;if(A&&(x||!O&&!e&&!r)){let R=Ve(v,c),$=P?tr(P):void 0,z=x?`text:${$}`:"marks",B=m.get(z),W=x&&R&&!e?"error":"warning";B?(B.box=mn(B.box,v),x||(p+=1)):(x||(p=1),m.set(z,{key:`film.off_canvas:${z}`,code:"film.off_canvas",severity:W,time:t,box:v,message:x?`Text ${JSON.stringify($??"")} runs off the canvas${R?" and is clipped":""}.`:"",...$?{text:$}:{}}))}if(x&&g.node.data.missingGlyph&&g.fillAlpha>=Yo){let $=`U+${String(g.node.data.key).codePointAt(0).toString(16).toUpperCase().padStart(4,"0")}`,z=P?tr(P):"";o.push({key:`film.missing_glyph:${z}:${$}`,code:"film.missing_glyph",severity:"error",time:t,box:M,message:`Text ${JSON.stringify(z)} has a character that no bundled font can draw (${$}). It renders as an empty box.`,text:z})}if(x&&P&&g.fillAlpha>=Yo){let R=u.get(P);R||u.set(P,R={id:P,source:tr(P),bounds:M,glyphs:[]}),R.bounds=mn(R.bounds,M),R.glyphs.push({box:M,order:w})}else if(!x&&(g.fill&&g.fillAlpha>=Jo&&Qo(g.fill)[3]>=Jo&&g.path.some(R=>R.closed)&&h.push({order:w,bounds:M}),g.stroke&&g.strokeAlpha>=Xo&&g.strokePath.length>0)){let R=Gi(Qo(g.stroke),g.strokeAlpha,l);R>=Di&&d.push({op:g,order:w,contrast:R})}});let f=m.get("marks");f&&(f.message=`${p===1?"A mark extends":`${p} marks extend`} past the ${s}x${i} canvas.`),o.push(...m.values());let b=(g,w,x)=>h.some(k=>k.order>g&&k.order<w&&Hi(k.bounds,x)),y=[...u.values()];for(let g=0;g<y.length;g++){let w=y[g];for(let x=g+1;x<y.length;x++){let k=y[x];if(!Ve(w.bounds,k.bounds))continue;let M=null;for(let v of w.glyphs)if(Ve(v.box,k.bounds))for(let P of k.glyphs){let A=_i(v.box,P.box);if(!A)continue;let O=Math.min(v.box.width*v.box.height,P.box.width*P.box.height);O<=0||A.width*A.height/O<zi||b(Math.min(v.order,P.order),Math.max(v.order,P.order),v.order<P.order?v.box:P.box)||(M=M?mn(M,A):A)}M&&o.push({key:`film.text_overlap:${w.source}|${k.source}`,code:"film.text_overlap",severity:"error",time:t,box:M,message:`Text ${JSON.stringify(w.source)} overlaps text ${JSON.stringify(k.source)}.`,text:w.source,other:k.source})}}for(let g of y)for(let{op:w,order:x,contrast:k}of d){let M=bt(w.strokePath);if(!M||!Ve(es(M,w.strokeWidth),g.bounds))continue;let v=null;for(let P of g.glyphs){let A=ji(P.box,$i);Ve(M,A)&&Xi(w.strokePath,A)&&(x<P.order&&b(x,P.order,P.box)||(v=v?mn(v,P.box):P.box))}if(v){let P=w.strokeWidth>=Vi&&k>=Wi;o.push({key:`film.text_crossed:${g.source}:${Ui(w.node)}`,code:"film.text_crossed",severity:P?"error":"warning",time:t,box:v,message:`A stroke crosses text ${JSON.stringify(g.source)}.`,text:g.source})}}return o}function Ji(n,t){return n.ops.some(e=>{if(e.kind!=="path")return e.alpha>=Qn;let r=e.fill!==null&&e.fillAlpha>=Qn,o=e.stroke!==null&&e.strokeAlpha>=Qn&&e.strokeWidth>0;if(!r&&!o)return!1;let s=bt(r?e.path:e.strokePath);return s!==null&&s.y+s.height>t&&s.y<n.height&&s.x+s.width>0&&s.x<n.width})}async function Qi(n,t={}){let e=Ee(n)?await n.compile(t):n,r=t.times?[...t.times]:Zi(e,t.samples??0),o=new Map;for(let u of r){let h=await er(e,u);for(let{key:d,...m}of rs(h,u,ns(e,u)!==1,e.bleed)){let p=o.get(d);p?(p.until=u,m.severity==="error"&&(p.severity="error")):o.set(d,{...m,until:u,stage:{x:0,y:0}})}}let s=t.motion?Math.max(1,Math.round(e.duration*e.fps)):0,i=1/e.fps;if(t.motion){let u=t.contentTop??0,h=new Map,d=[];for(let p=0;p<s;p++){let f=p*i,b=await er(e,f);for(let g of rs(b,f,ns(e,f)!==1,e.bleed)){if(o.has(g.key))continue;let w=h.get(g.key);w||h.set(g.key,w=[]);let x=w[w.length-1];x&&x.to===p-1?x.to=p:w.push({from:p,to:p,first:g})}if(!(f<Zo||f>e.duration-Zo)&&!Ji(b,u)){let g=d[d.length-1];g&&g.to===p-1?g.to=p:d.push({from:p,to:p})}}let m=p=>Math.round(p*i*100)/100;for(let[p,f]of h){let b=f.reduce((w,x)=>x.to-x.from>w.to-w.from?x:w),{key:y,...g}=b.first;o.set(p,{...g,severity:"warning",until:b.to*i,stage:{x:0,y:0},motion:{spans:f.length,seconds:m(f.reduce((w,x)=>w+x.to-x.from+1,0))}})}for(let p of d){let f=m(p.to-p.from+1);f<Bi||o.set(`film.blank:${p.from}`,{code:"film.blank",severity:"warning",message:`Nothing is visible${u>0?` below y=${u}`:""} for ${f} s.`,time:p.from*i,until:p.to*i,box:{x:0,y:u,width:e.width,height:e.height-u},stage:{x:0,y:0},motion:{spans:1,seconds:f}})}}let a=u=>Math.round(u*100)/100,l=[...o.values()].map(u=>({...u,time:Math.round(u.time*1e3)/1e3,until:Math.round(u.until*1e3)/1e3,box:{x:a(u.box.x),y:a(u.box.y),width:a(u.box.width),height:a(u.box.height)},stage:{x:a(u.box.x+u.box.width/2-e.width/2),y:a(u.box.y+u.box.height/2-e.height/2)}})).sort((u,h)=>u.severity===h.severity?u.time-h.time:u.severity==="error"?-1:1),c=l.filter(u=>u.severity==="error").length;return{ok:c===0,width:e.width,height:e.height,duration:e.duration,sampled:r.map(u=>Math.round(u*1e3)/1e3),...t.motion?{frames:s}:{},diagnostics:l,summary:{errors:c,warnings:l.length-c}}}function it(n,t,e){n.mounted||(S.now=t,e.add(n));for(let r=n;r&&r!==e.root;r=r.parent)me(r,"visible",t)||r.track("visible").step(t,!0)}function me(n,t,e){let r=S.now;S.now=e;let o=n.get(t);return S.now=r,o}function D(n,t,e,r){n.track(t).step(r,e)}function wt(n,t,e,r,o){let s=n.track.sample(e);n.track.add({t0:e,t1:r,ease:o,to:t,at:i=>s+(t-s)*i})}function Vt(n,t,e,r){if(n===0)return[];let o=(r-e)/(1+(n-1)*t);return Array.from({length:n},(s,i)=>{let a=e+i*t*o;return[a,a+o]})}function nr(n,t){return typeof n!="string"?n:t.math?st(n,{size:t.size,color:t.color??"ink",display:!1}):H(n,{size:t.size,color:t.color??"ink",font:t.font??"sans",weight:t.weight??400})}function os(n){let t=e=>{let r=e/255;return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)};return .2126*t(n[0])+.7152*t(n[1])+.0722*t(n[2])}function Ft(n){return typeof n=="string"?Gt(n):Array.isArray(n)?n:n.stops[0][1]}function Be(n){let t=n>>>0;return()=>{t=t+1831565813>>>0;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function _t(n,t,e){let r=[],o=Math.ceil(n/e-1e-9)*e;for(let s=o;s<=t+e*1e-6;s+=e)r.push(Math.round(s/e)*e);return r}function pn(n,t,e=5){let o=(t-n||1)/Math.max(1,e),s=Math.pow(10,Math.floor(Math.log10(o))),i=o/s,a=(i<1.5?1:i<3.5?2:i<7.5?5:10)*s;return{ticks:_t(n,t,a),step:a}}function We(n,t){if(t!==void 0&&t<1){let r=Math.min(4,Math.ceil(-Math.log10(t)-1e-9));return n.toFixed(r)}let e=Math.round(n*1e3)/1e3;return Math.abs(e)>=1e3&&Number.isInteger(e)?e.toLocaleString("en-US"):String(e)}function pe(n){let t=n[0],e=new Array(2+(n.length-1)*6);e[0]=t[0],e[1]=t[1];for(let r=1;r<n.length;r++){let o=n[r-1],s=n[r],i=2+(r-1)*6;e[i]=o[0]+(s[0]-o[0])/3,e[i+1]=o[1]+(s[1]-o[1])/3,e[i+2]=o[0]+(s[0]-o[0])*2/3,e[i+3]=o[1]+(s[1]-o[1])*2/3,e[i+4]=s[0],e[i+5]=s[1]}return{p:Float64Array.from(e),closed:!1,straight:!0}}var ee=n=>typeof n=="function"?n():n,rr=class extends N{range;length;line;ticks=new N;numbers=new N;constructor(t={}){super(),this.range=t.range??[-5,5],this.length=t.length??1200;let e=t.color??"dim",r=t.width??2,o=this.length/2,s=t.tips??!0;this.line=s?$e([-o-36,0],[o+36,0],{stroke:e,width:r,tip:14,both:!0}):Y([-o,0],[o,0],{stroke:e,width:r});let i=t.step??1;for(let a of _t(this.range[0],this.range[1],i)){let[l]=this.p(a);if(this.ticks.add(Y([l,-7],[l,7],{stroke:e,width:r})),t.labels??!0){let c=t.labelSize??24,u=st(String(Math.round(a*1e3)/1e3),{size:c,color:"dim",display:!1});u.set("py",-c*.25),this.numbers.add(u.at(l,34))}}this.add(this.line,this.ticks,this.numbers)}p(t){let[e,r]=this.range;return[((t-e)/(r-e)-.5)*this.length,0]}world(t){let[e,r]=this.p(t);return this.toWorld(e,r)}marker(t,e={}){let r=e.color??"yellow",o=e.labelSize??28,s=()=>{let[a]=this.p(ee(t)),l=[gt(e.radius??9,r).at(a,0)];return e.label&&l.push(st(e.label,{size:o,color:r,display:!1}).at(a,-o*1.15)),l},i=typeof t=="function"?At(s):new N().add(...s());return this.add(i),i}interval(t,e,r={}){let o=r.color??"blue",s=r.offset??0,[i]=this.p(t),[a]=this.p(e),l=Y([i,s],[a,s],{stroke:o,width:r.width??7}),c=(h,d)=>d?gt(9,"bg").stroke(o,4).at(h,s):gt(9,o).at(h,s),u=new N().add(l,c(i,r.openLeft),c(a,r.openRight));return this.add(u),u}};function qc(n={}){return new rr(n)}var or=class extends Le{numbers=new N;constructor(t={}){super(t);let e=t.labelRange??3,r=t.labelSize??22;for(let o=-e;o<=e;o++){if(o===0)continue;let s=st(String(o),{size:r,color:"ink",display:!1});s.set("py",-r*.25),this.numbers.add(s.at(o*this.unit,22));let i=o===1?"i":o===-1?"-i":`${o}i`,a=st(i,{size:r,color:"ink",display:!1});a.set("py",-r*.25),this.numbers.add(a.at(-r*.9,-o*this.unit))}this.add(this.numbers)}z(t,e){return this.p(t,e)}};function Uc(n={}){return new or(n)}function Zc(n,t,e={}){let r=Wt(n.worldMatrix()),o=n.worldMatrix(),s=n.unit;return{...Wn([n.minor,n.major,n.axes],(a,l)=>{let[c,u]=Q(r,a,l),[h,d]=t(c/s,-u/s);return Q(o,h*s,-d*s)},{duration:3,...e}),label:"applyComplex"}}var Jc={mul:(n,t)=>[n[0]*t[0]-n[1]*t[1],n[0]*t[1]+n[1]*t[0]],div:(n,t)=>{let e=t[0]*t[0]+t[1]*t[1]||1e-12;return[(n[0]*t[0]+n[1]*t[1])/e,(n[1]*t[0]-n[0]*t[1])/e]},exp:n=>{let t=Math.exp(n[0]);return[t*Math.cos(n[1]),t*Math.sin(n[1])]},log:n=>[Math.log(Math.hypot(n[0],n[1])||1e-12),Math.atan2(n[1],n[0])],pow:(n,t)=>{let e=Math.pow(Math.hypot(n[0],n[1]),t),r=Math.atan2(n[1],n[0])*t;return[e*Math.cos(r),e*Math.sin(r)]},sin:n=>[Math.sin(n[0])*Math.cosh(n[1]),Math.cos(n[0])*Math.sinh(n[1])],cos:n=>[Math.cos(n[0])*Math.cosh(n[1]),-Math.sin(n[0])*Math.sinh(n[1])],inv:n=>{let t=n[0]*n[0]+n[1]*n[1]||1e-12;return[n[0]/t,-n[1]/t]}};function ta(n,t,e,r,o){let s=Math.hypot(e,r)||1e-6,i=e/s,a=r/s,l=Math.min(s*.42,o*5.2),c=o/2,u=l*.42,h=n+e-i*l,d=t+r-a*l,m=-a,p=i;return Z([[n+m*c,t+p*c],[h+m*c,d+p*c],[h+m*u,d+p*u],[n+e,t+r],[h-m*u,d-p*u],[h-m*c,d-p*c],[n-m*c,t-p*c]],!0)[0]}var sr=class extends N{constructor(e,r={}){super();this.f=e;let o=this.unit=r.unit??120,[s,i]=r.x??[-8,8],[a,l]=r.y??[-4.5,4.5],c=r.step??.5,u=r.maxLength??c*o*.92,h=r.width??2.6,d=(r.colors??["blue","teal","green","yellow","orange","red"]).map(y=>X(y)),m=d.map((y,g)=>[d.length===1?0:g/(d.length-1),y]),p=[];for(let y of _t(a,l,c))for(let g of _t(s,i,c))p.push([g,y]);let f=r.max??(()=>{let y=p.map(([g,w])=>{let[x,k]=e(g,w,0);return Math.hypot(x,k)}).filter(Number.isFinite).sort((g,w)=>g-w);return y[Math.floor(y.length*.9)]||1})(),b=(y,g,w)=>{let[x,k]=e(y,g,w),M=Math.hypot(x,k);if(!Number.isFinite(M)||M<1e-9)return null;let v=Math.min(1,M/f),P=u*(.22+.78*(1-Math.exp(-2.2*M/f))),A=x/M*P,O=-(k/M)*P,R=y*o,$=-g*o;return{ring:ta(R-A/2,$-O/2,A,O,h),at:v,cx:R,cy:$}};if(r.animate){this.draw=g=>{let w=Array.from({length:12},()=>[]);for(let[x,k]of p){let M=b(x,k,g);M&&w[Math.min(11,Math.floor(M.at*12))].push(M.ring)}return w.flatMap((x,k)=>x.length===0?[]:[new N(x).fill(lt(m,(k+.5)/12))])};return}for(let[y,g]of p){let w=b(y,g,0);if(!w)continue;let x=as([w.ring]).fill(lt(m,w.at));this.arrows.push(x),this.add(x)}}f;unit;arrows=[]};function as(n){let t=bt(n);if(!t)return new N(n);let e=t.x+t.width/2,r=t.y+t.height/2,o=n.map(s=>{let i=new Float64Array(s.p.length);for(let a=0;a<i.length;a+=2)i[a]=s.p[a]-e,i[a+1]=s.p[a+1]-r;return{p:i,closed:s.closed}});return new N(o).at(e,r)}function Qc(n,t={}){return new sr(n,t)}var ir=class extends N{lineCount;constructor(t,e={}){super();let r=e.unit??120,[o,s]=e.x??[-8.5,8.5],[i,a]=e.y??[-5,5],l=e.spacing??.55,c=e.dt??.03,u=e.steps??130,h=e.width??2.2,d=e.speed??.35,m=e.tail??.42,p=Be(e.seed??7),f=(e.colors??["blue","teal","green","yellow","orange","red"]).map(O=>X(O)),b=f.map((O,R)=>[f.length===1?0:R/(f.length-1),O]),y=[],g=[],w=.6;for(let O=i;O<=a;O+=l)for(let R=o;R<=s;R+=l){let $=R+(p()-.5)*l,z=O+(p()-.5)*l,B=p(),W=[[$*r,-z*r]],G=0;for(let C=0;C<u;C++){let[L,I]=t($,z,0),[F,E]=t($+L*c/2,z+I*c/2,0),[T,V]=t($+F*c/2,z+E*c/2,0),[j,J]=t($+T*c,z+V*c,0),at=(L+2*F+2*T+j)/6,tt=(I+2*E+2*V+J)/6;if(!Number.isFinite(at)||!Number.isFinite(tt))break;let ut=Math.hypot(at,tt);if(G+=ut,ut<1e-6||($+=at*c,z+=tt*c,$<o-w||$>s+w||z<i-w||z>a+w))break;C%2===1&&W.push([$*r,-z*r])}if(W.length<5)continue;let U=G/(W.length*2);g.push(U),y.push({points:W,phase:B,speedRate:.8+p()*.4,color:U})}let x=[...g].sort((O,R)=>O-R),k=e.max??(x[Math.floor(x.length*.92)]||1),M=8;for(let O of y)O.color=Math.min(M-1,Math.floor(Math.min(1,O.color/k)*M));this.lineCount=y.length;let v=6,P=e.trace??0,A=Array.from({length:M},()=>[]);if(P>0)for(let O of y)A[O.color].push(pe(O.points));this.draw=O=>{let R=Array.from({length:M*v},()=>[]);for(let z of y){let B=z.points.length,W=Math.max(3,Math.floor(B*m)),G=B+W,U=(O*d*z.speedRate+z.phase)%1*G;for(let C=0;C<v;C++){let L=Math.floor(U-W*(1-C/v)),I=Math.floor(U-W*(1-(C+1)/v)),F=Math.max(0,L),E=Math.min(B-1,I);E-F<1||R[z.color*v+C].push(pe(z.points.slice(F,E+1)))}}let $=[];return P>0&&A.forEach((z,B)=>{z.length&&$.push(new N(z).stroke(lt(b,(B+.5)/M),h*.6).set("strokeOpacity",P))}),R.forEach((z,B)=>{if(z.length===0)return;let W=Math.floor(B/v),G=B%v,U=new N(z).stroke(lt(b,(W+.5)/M),h);U.set("strokeOpacity",Math.pow((G+1)/v,1.6)),G<v-1&&U.set("cap","butt"),$.push(U)}),$}}};function tu(n,t={}){return new ir(n,t)}function eu(n,t,e={}){let r=e.from??n.xRange[0],o=e.to??n.xRange[1],s=e.n??12,i=e.rule??"mid",a=Ie(s,...e.colors??["blue","teal","green"]),l=new N,c=(o-r)/s;for(let u=0;u<s;u++){let h=r+u*c,d=i==="left"?h:i==="right"?h+c:h+c/2,m=t(d),[p,f]=n.p(h,0),[b,y]=n.p(h+c,m),g=as(Z([[p,f],[b,f],[b,y],[p,y]],!0));g.fill(a[u],e.opacity??.72),g.stroke(e.stroke??"bg",e.strokeWidth??(s>40?.5:1.4)),l.add(g)}return n.add(l),l}function ss(n,t,e,r,o){let s=[];for(let i=0;i<=o;i++){let a=e+(r-e)*i/o;s.push(n.p(a,t(a)))}return s.push(n.p(r,0),n.p(e,0)),Z(s,!0)}function nu(n,t,e={}){let r=e.samples??96,o=e.fill??"blue",s=e.opacity??.28,i=e.from??n.xRange[0],a=e.to??n.xRange[1],l=typeof i=="function"||typeof a=="function"?At(()=>{let c=ee(i),u=ee(a);return Math.abs(u-c)<1e-9?null:new N(ss(n,t,c,u,r)).fill(o,s)}):new N(ss(n,t,i,a,r)).fill(o,s);return n.add(l),l}function ea(n,t,e){let o=(n.xRange[1]-n.xRange[0])*1e-4,s=n.p(e-o,t(e-o)),i=n.p(e+o,t(e+o)),a=Math.hypot(i[0]-s[0],i[1]-s[1])||1;return{point:n.p(e,t(e)),ux:(i[0]-s[0])/a,uy:(i[1]-s[1])/a}}function ru(n,t,e,r={}){let o=r.length??420,s=r.stroke??"yellow",i=()=>{let{point:l,ux:c,uy:u}=ea(n,t,ee(e)),h=[Y([l[0]-c*o/2,l[1]-u*o/2],[l[0]+c*o/2,l[1]+u*o/2],{stroke:s,width:r.width??3.5,glow:r.glow,dash:r.dash})];return(r.point??!0)&&h.push(gt(8,s).at(l)),h},a=typeof e=="function"?At(i):new N().add(...i());return n.add(a),a}function ou(n,t,e,r,o={}){let s=o.extend??140,i=o.stroke??"yellow",a=()=>{let c=ee(e),u=ee(r),h=n.p(c,t(c)),d=n.p(u,t(u)),m=Math.hypot(d[0]-h[0],d[1]-h[1])||1,p=(d[0]-h[0])/m,f=(d[1]-h[1])/m,b=[Y([h[0]-p*s,h[1]-f*s],[d[0]+p*s,d[1]+f*s],{stroke:i,width:o.width??3.5,glow:o.glow})];if(o.legs){let y=[d[0],h[1]],g=o.legColor??"dim";b.unshift(Y(h,y,{stroke:g,width:2,dash:[6,7]}),Y(y,d,{stroke:g,width:2,dash:[6,7]}))}return(o.points??!0)&&b.push(gt(8,i).at(h),gt(8,i).at(d)),b},l=typeof e=="function"||typeof r=="function"?At(a):new N().add(...a());return n.add(l),l}function su(n,t,e,r={}){let o=()=>{let i=ee(t),a=ee(e),l=Math.max(n.xRange[0],Math.min(n.xRange[1],0)),c=Math.max(n.yRange[0],Math.min(n.yRange[1],0)),u={stroke:"dim",width:2,dash:[6,7],...r};return[Y(n.p(i,c),n.p(i,a),u),Y(n.p(l,a),n.p(i,a),u)]},s=typeof t=="function"||typeof e=="function"?At(o):new N().add(...o());return n.add(s),s}function iu(n,t,e,r={}){let o=r.radius??54,s=r.color??"yellow",i=Math.atan2(t[1]-n[1],t[0]-n[0]),a=Math.atan2(e[1]-n[1],e[0]-n[0])-i;for(;a<=-Math.PI;)a+=Math.PI*2;for(;a>Math.PI;)a-=Math.PI*2;r.reflex&&(a+=a>0?-Math.PI*2:Math.PI*2);let l=new N;if(r.fillOpacity){let c=[n];for(let u=0;u<=24;u++){let h=i+a*u/24;c.push([n[0]+Math.cos(h)*o,n[1]+Math.sin(h)*o])}l.add(new N(Z(c,!0)).fill(s,r.fillOpacity))}if(l.add(new N(St(n[0],n[1],o,o,i,i+a)).stroke(s,r.width??3)),r.label){let c=r.labelSize??30,u=i+a/2,h=o+c*.72;l.add(st(r.label,{size:c,color:s,display:!1}).at(n[0]+Math.cos(u)*h,n[1]+Math.sin(u)*h))}return l}function au(n,t,e,r={}){let o=r.size??26,s=u=>{let h=u[0]-n[0],d=u[1]-n[1],m=Math.hypot(h,d)||1;return[h/m,d/m]},[i,a]=s(t),[l,c]=s(e);return new N(Z([[n[0]+i*o,n[1]+a*o],[n[0]+(i+l)*o,n[1]+(a+c)*o],[n[0]+l*o,n[1]+c*o]])).stroke(r.color??"ink",r.width??2.5)}var na={"[":["[","]"],"(":["(",")"],"|":["|","|"]},ar=class extends N{cells;entries=new N;brackets=new N;rowCount;colCount;positions;options;constructor(t,e={}){super(),this.options=e;let r=e.size??52,o=e.color??"ink";this.rowCount=t.length,this.colCount=Math.max(0,...t.map(w=>w.length));let s=t.map(w=>w.map(x=>{let k=st(String(x),{size:r,color:o,display:!1});return k.set("py",-r*.25),k})),i=Array.from({length:this.colCount},(w,x)=>Math.max(0,...s.map(k=>k[x]?.width??0))),a=(e.gapX??.85)*r,l=(e.gapY??1.32)*r,c=i.reduce((w,x)=>w+x,0)+a*Math.max(0,this.colCount-1),u=l*Math.max(0,this.rowCount-1)+r,h=[],d=-c/2;for(let w of i)h.push(d+w/2),d+=w+a;this.positions=s.map((w,x)=>w.map((k,M)=>{let v=[h[M],(x-(this.rowCount-1)/2)*l];return k.at(v),this.entries.add(k),v})),this.cells=s;let m=na[e.bracket??"["],f=`\\rule{0pt}{${((u+r*.5)/r/2+.25).toFixed(3)}em}`,b=r*.42,y=st(`\\left${m[0]}${f}\\right.`,{size:r,color:e.bracketColor??o}),g=st(`\\left.${f}\\right${m[1]}`,{size:r,color:e.bracketColor??o});y.moveTo([-c/2-b-y.width/2,0]),g.moveTo([c/2+b+g.width/2,0]),this.brackets.add(y,g),this.add(this.brackets,this.entries)}cell(t,e){let r=this.cells[t]?.[e];if(!r)throw new Error(`Matrix has no cell (${t}, ${e}). It is ${this.rowCount} by ${this.colCount}.`);return r}row(t){return[...this.cells[t]??[]]}col(t){return this.cells.map(e=>e[t]).filter(Boolean)}setCell(t,e,r,o={}){let s=this.options.size??52,i=st(String(r),{size:s,color:this.options.color??"ink",display:!1});i.set("py",-s*.25);let a=this.positions[t][e];i.at(a);let l=this.cell(t,e),c=this,u=we(l,i,{duration:.8,...o});return{...u,schedule(h){c.entries.add(i),i.track("visible").initial=!1,c.cells[t][e]=i,u.schedule(h)}}}};function lu(n,t={}){return new ar(n,t)}function ls(n){let t=Array.isArray(n)?n:[n],e=1/0,r=1/0,o=-1/0,s=-1/0;for(let i of t){let a=i.bounds();e=Math.min(e,a.x),r=Math.min(r,a.y),o=Math.max(o,a.x+a.width),s=Math.max(s,a.y+a.height)}return{x:e,y:r,width:o-e,height:s-r}}function cu(n,t,e={}){let r=ls(n),o=e.side??"bottom",s=e.gap??12,i=e.color??"ink",a=e.size??34,l=r.x,c=r.x+r.width,u=r.y,h=r.y+r.height,[d,m]=o==="bottom"?[[l,h+s],[c,h+s]]:o==="top"?[[c,u-s],[l,u-s]]:o==="left"?[[l-s,u],[l-s,h]]:[[c+s,h],[c+s,u]],p=_o(d,m,{stroke:i,depth:e.depth}),f=p.data.tip,b=nr(t,{size:a,color:i,math:!e.plain});b.moveTo(f);let y=Qe(o),g=10+(y[0]!==0?b.width/2:b.height/2);return b.shift(y[0]*g,y[1]*g),new N().add(p,b)}function uu(n,t={}){let e=ls(n),r=t.pad??12,o=jo(e.width+r*2,e.height+r*2,{radius:t.radius??8,stroke:t.color??"yellow",width:t.width??2.5,glow:t.glow});return t.fill&&o.fill(t.fill,t.fillOpacity??.14),o.at(e.x+e.width/2,e.y+e.height/2)}var lr=class extends N{mark;caption;constructor(t,e={}){super();let r=e.color??"yellow";this.mark=gt(e.radius??9,r),this.caption=nr(t,{size:e.size??30,color:e.labelColor??r,math:!e.plain}),this.add(this.mark,this.caption),this.caption.nextTo(this.mark,e.side??[.72,-.72],e.gap??8)}};function hu(n,t={}){return new lr(n,t)}function du(n,t,e,r={}){let o=r.color??"yellow",s=r.width??3,i=r.rate??60,a=r.fade??(r.tail!==void 0?0:1),l=a>=1?1:10,c=new Map,u=h=>{let d=c.get(h);if(d)return d;let m=S.now;S.now=t+h/i;let p=n();return S.now=m,S.mode==="render"&&c.set(h,p),p};return At(h=>{if(h<=t)return null;let d=Math.min(h,e),m=r.tail!==void 0?Math.max(t,d-r.tail):t,p=Math.ceil((m-t)*i),f=Math.floor((d-t)*i);if(f-p<1)return null;let b=[];for(let w=p;w<=f;w++)b.push(u(w));let y=S.now;S.now=d,b.push(n()),S.now=y;let g=[];for(let w=0;w<l;w++){let x=Math.floor((b.length-1)*w/l),k=Math.min(b.length-1,Math.floor((b.length-1)*(w+1)/l));if(k-x<1)continue;let M=new N([pe(b.slice(x,k+1))]).stroke(o,s),v=l===1?1:a+(1-a)*Math.pow((w+1)/l,1.5);M.set("strokeOpacity",v),w<l-1&&M.set("cap","butt"),r.glow&&M.glow(r.glow),g.push(M)}return g})}function mu(n,t={}){let e=n.length,r=[];for(let o=0;o<e;o++){let s=o<=e/2?o:o-e,i=0,a=0;for(let l=0;l<e;l++){let c=-2*Math.PI*s*l/e,u=Math.cos(c),h=Math.sin(c),[d,m]=n[l];i+=d*u-m*h,a+=d*h+m*u}r.push({freq:s,amp:Math.hypot(i,a)/e,phase:Math.atan2(a,i)})}return r.sort((o,s)=>s.amp-o.amp||o.freq-s.freq),t.terms?r.slice(0,t.terms):r}function is(n,t){let e=0,r=0;for(let o of n){let s=2*Math.PI*o.freq*t+o.phase;e+=o.amp*Math.cos(s),r+=o.amp*Math.sin(s)}return[e,r]}function pu(n,t){return Pt(n)===0?[]:Array.from({length:t},(r,o)=>Nt(n,o/t))}var cr=class extends N{terms;outlinePoints;constructor(t,e){super(),this.terms=[...t].sort((h,d)=>(h.freq===0?-1:d.freq===0?1:0)||d.amp-h.amp);let r=e.samples??1024;this.outlinePoints=Array.from({length:r+1},(h,d)=>is(this.terms,d/r));let o=e.circles??64,s=e.circleColor??"blue",i=e.armColor??"ink",a=e.traceColor??"yellow",l=e.traceWidth??3.5,c=e.tail??1,u=12;this.draw=()=>{let h=e.u(),d=h-Math.floor(h),m=[],p=0,f=0,b=[],y=[[],[],[],[]];this.terms.forEach((k,M)=>{let v=2*Math.PI*k.freq*d+k.phase,P=p+k.amp*Math.cos(v),A=f+k.amp*Math.sin(v);M<o&&k.freq!==0&&k.amp>.4&&y[Math.min(3,Math.floor(M/Math.max(1,o)*4))].push(...Dt(p,f,k.amp)),p=P,f=A,M<o&&b.push([p,f])}),y.forEach((k,M)=>{k.length&&m.push(new N(k).stroke(s,1.2).set("strokeOpacity",[.55,.36,.22,.14][M]))}),b.length>=2&&m.push(new N([pe(b)]).stroke(i,1.4).set("strokeOpacity",.85));let g=this.outlinePoints.length-1,w=h>=1?g:Math.floor(d*g),x=Math.max(0,w-Math.floor(g*c));if(w-x>=2)if(c>=1){let k=new N([pe(this.outlinePoints.slice(x,w+1))]).stroke(a,l);e.glow&&k.glow(e.glow),m.push(k)}else for(let k=0;k<u;k++){let M=x+Math.floor((w-x)*k/u),v=Math.min(w,x+Math.floor((w-x)*(k+1)/u));if(v-M<1)continue;let P=new N([pe(this.outlinePoints.slice(M,v+1))]).stroke(a,l);P.set("strokeOpacity",Math.pow((k+1)/u,1.5)),k<u-1&&P.set("cap","butt"),m.push(P)}return h<1&&m.push(gt(5,a).at(p,f)),m}}outline(){return Z(this.outlinePoints.slice(0,-1),!0)}point(t){return is(this.terms,t)}};function fu(n,t){return new cr(n,t)}function bu(n,t=200){return He(n,0,1,t).map(r=>Mt(r.p,!0))}var re=["blue","yellow","teal","orange","purple","green","pink","red"];function It(n,t,e="dim",r="sans"){return H(n,{size:t,color:e,font:r})}var hr=class extends N{bars=[];labels=[];readouts=[];baseline;values;maxValue;minValue;w;h;horizontal;band;gap;fixedMax;fixedMin;constructor(t,e={}){super(),this.w=e.width??900,this.h=e.height??520,this.horizontal=e.horizontal??!1,this.gap=e.gap??.28,this.fixedMax=e.max,this.fixedMin=e.min;let r=e.labelSize??20,o=Math.max(1,t.length);this.band=(this.horizontal?this.h:this.w)/o;let s=t.map(d=>d.value);this.maxValue=new pt(e.max??Math.max(0,...s)),this.minValue=new pt(e.min??Math.min(0,...s)),this.values=t.map(d=>new pt(d.value));let i=e.format??(d=>We(Math.round(d*100)/100)),a=e.color??"faint",[l,c]=this.place(0,0,"start"),[u,h]=this.place(o-1,0,"end");this.baseline=Y([l,c],[u,h],{stroke:a,width:1.5}),t.forEach((d,m)=>{let p=d.color??re[m%re.length],f=new N(this.barPath(m,d.value)).fill(p,.84);this.bars.push(f);let b=It(d.label,r);this.labels.push(b);let[y,g]=this.place(m,0,"mid");if(this.horizontal?b.at(y-12-b.width/2,g):b.at(y,g+12+r/2),e.showValues??!0){let w=At(()=>{let x=this.values[m].value,[k,M]=this.tip(m,x),v=It(i(x),r,"ink","mono");return this.horizontal?v.at(k+12+v.width/2,M):v.at(k,M+(x>=0?-1:1)*(10+r*.6))});this.readouts.push(w)}}),this.add(...this.bars,this.baseline,...this.labels,...this.readouts)}lengthOf(t){let e=this.maxValue.value-this.minValue.value||1;return t/e*(this.horizontal?this.w:this.h)}place(t,e,r){let o=(t+.5)*this.band,s=this.band/2,i=r==="mid"?o:r==="start"?o-s:o+s,a=this.maxValue.value-this.minValue.value||1;if(this.horizontal)return[-this.minValue.value/a*this.w-this.w/2,i-this.h/2];let l=this.h/2- -this.minValue.value/a*this.h;return[i-this.w/2,l]}tip(t,e){let[r,o]=this.place(t,0,"mid"),s=this.lengthOf(e);return this.horizontal?[r+s,o]:[r,o-s]}barPath(t,e){let[r,o]=this.place(t,0,"mid"),s=this.band*(1-this.gap),i=this.lengthOf(e);return this.horizontal?K(r,o-s/2,i,s):K(r-s/2,o-i,s,i)}bar(t){return this.bars[t]}enter(t={}){let e=t.lag??.12;return{label:"barChart.enter",duration:t.duration??1.6,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=r.t1-r.t0;D(this.baseline,"trimTo",0,r.t0),this.baseline.tween("trimTo",1,r.t0,r.t0+o*.4,r.ease);let s=Vt(this.bars.length,e,r.t0+o*.1,r.t1);this.bars.forEach((i,a)=>{let[l,c]=s[a],u=this.values[a].track.sample(r.t0);this.values[a].track.step(r.t0,0),wt(this.values[a],u,l,c,r.ease),i.track("path").step(r.t0,this.barPath(a,0)),i.track("path").add({t0:l,t1:c,ease:r.ease,to:this.barPath(a,u),at:m=>this.barPath(a,u*m)});let h=this.labels[a];D(h,"opacity",0,r.t0),h.tween("opacity",1,l,l+(c-l)*.6,r.ease);let d=this.readouts[a];d&&(D(d,"opacity",0,r.t0),d.tween("opacity",1,l,l+(c-l)*.5,r.ease))})}}}update(t,e={}){return{label:"barChart.update",duration:e.duration??1.1,ease:e.ease,schedule:r=>{let o=this.values.map(c=>c.track.sample(r.t0)),s=this.maxValue.track.sample(r.t0),i=this.minValue.track.sample(r.t0),a=this.fixedMax??Math.max(0,...t),l=this.fixedMin??Math.min(0,...t);wt(this.maxValue,a,r.t0,r.t1,r.ease),wt(this.minValue,l,r.t0,r.t1,r.ease),t.forEach((c,u)=>{wt(this.values[u],c,r.t0,r.t1,r.ease);let h=this.bars[u];if(!h)return;let d=m=>this.barPathAt(u,o[u]+(c-o[u])*m,s+(a-s)*m,i+(l-i)*m);h.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:d(1),at:d})})}}}barPathAt(t,e,r,o){let s=r-o||1,i=(t+.5)*this.band,a=this.band*(1-this.gap);if(this.horizontal){let u=-o/s*this.w-this.w/2;return K(u,i-this.h/2-a/2,e/s*this.w,a)}let l=this.h/2- -o/s*this.h,c=e/s*this.h;return K(i-this.w/2-a/2,l-c,a,c)}};function Pu(n,t={}){return new hr(n,t)}var dr=class extends N{shown;bins;range;chartWidth;chartHeight;axis=new N;total;assigned;peak;constructor(t,e={}){super(),this.chartWidth=e.width??900,this.chartHeight=e.height??480,this.bins=e.bins??24;let r=e.range?.[0]??Math.min(...t),o=e.range?.[1]??Math.max(...t);this.range=[r,o],this.total=t.length,this.assigned=new Int32Array(t.length);let s=new Int32Array(this.bins);t.forEach((b,y)=>{let g=Math.min(this.bins-1,Math.floor((b-r)/(o-r||1)*this.bins));this.assigned[y]=b<r||b>o?-1:g,this.assigned[y]>=0&&s[g]++}),this.peak=e.max??Math.max(1,...s),this.shown=new pt(t.length);let i=e.labelSize??20,a=this.chartWidth,l=this.chartHeight,c=Y([-a/2,l/2],[a/2,l/2],{stroke:e.color??"faint",width:1.5});this.axis.add(c);let{ticks:u,step:h}=pn(r,o,e.ticks??6);for(let b of u){let y=this.xAt(b);this.axis.add(Y([y,l/2],[y,l/2+6],{stroke:"faint",width:1.5})),this.axis.add(It(We(b,h),i).at(y,l/2+12+i*.6))}let d=(e.colors??["blue"]).map(b=>Ft(b)),m=d.map((b,y)=>[d.length===1?0:y/(d.length-1),b]),p=e.gap??.12,f=At(()=>{let b=Math.max(0,Math.min(this.total,Math.round(this.shown.value))),y=new Int32Array(this.bins);for(let k=0;k<b;k++){let M=this.assigned[k];M>=0&&y[M]++}let g=a/this.bins,w=[],x=[];for(let k=0;k<this.bins;k++){let M=y[k]/this.peak*l;if(M<=0)continue;let v=K(-a/2+k*g+g*p/2,l/2-M,g*(1-p),M);d.length===1?w.push(...v):x.push(new N(v).fill(lt(m,k/Math.max(1,this.bins-1))))}return w.length&&x.push(new N(w).fill(d[0])),x});this.add(f,this.axis)}xAt(t){let[e,r]=this.range;return((t-e)/(r-e||1)-.5)*this.chartWidth}p(t,e){return[this.xAt(t),this.chartHeight/2-e/this.peak*this.chartHeight]}fillUp(t={}){let e=this.shown,r=t.count??this.total;return{label:"histogram.fill",duration:t.duration??3,ease:t.ease,schedule:o=>{it(this,o.t0,o.stage),e.track.keys.length===0&&(e.track.initial=0),wt(e,r,o.t0,o.t1,o.ease)}}}curve(t,e={}){let[r,o]=this.range,s=e.samples??120,i=[];for(let l=0;l<=s;l++){let c=r+(o-r)*l/s;i.push(this.p(c,t(c)))}let a=new N(Lt(i)).stroke(e.color??"yellow",e.width??4);return this.add(a),a}};function Au(n,t={}){return new dr(n,t)}function ne(n,t,e){let{xRange:r,yRange:o,w:s,h:i}=n;return[((t-r[0])/(r[1]-r[0]||1)-.5)*s,(.5-(e-o[0])/(o[1]-o[0]||1))*i]}function cs(n,t){let e=new N,r=t.labelSize,o=t.color??"faint",{w:s,h:i}=n,a=pn(n.xRange[0],n.xRange[1],t.xTicks??6),l=pn(n.yRange[0],n.yRange[1],t.yTicks??5);for(let c of l.ticks){let[,u]=ne(n,n.xRange[0],c);t.gridY!==!1&&e.add(Y([-s/2,u],[s/2,u],{stroke:"grid",width:1.25}));let h=It(t.yFormat?t.yFormat(c):We(c,l.step),r);e.add(h.at(-s/2-12-h.width/2,u))}e.add(Y([-s/2,i/2],[s/2,i/2],{stroke:o,width:1.5}));for(let c of a.ticks){let[u]=ne(n,c,n.yRange[0]);e.add(Y([u,i/2],[u,i/2+6],{stroke:o,width:1.5})),e.add(It(t.xFormat?t.xFormat(c):We(c,a.step),r).at(u,i/2+12+r*.6))}if(t.xLabel){let c=It(t.xLabel,r,"ink");e.add(c.at(s/2-c.width/2,i/2+18+r*1.6))}if(t.yLabel){let c=It(t.yLabel,r,"ink");e.add(c.at(-s/2+c.width/2,-i/2-12-r/2))}return e}var mr=class extends N{dots=[];axis;groupLabels=[];frame;constructor(t,e={}){super();let r=t.map(h=>h.x),o=t.map(h=>h.y),s=(h,d)=>(d-h||1)*.06,i=e.x??[Math.min(...r)-s(Math.min(...r),Math.max(...r)),Math.max(...r)+s(Math.min(...r),Math.max(...r))],a=e.y??[Math.min(...o)-s(Math.min(...o),Math.max(...o)),Math.max(...o)+s(Math.min(...o),Math.max(...o))];this.frame={xRange:i,yRange:a,w:e.width??900,h:e.height??520};let l=e.labelSize??18;this.axis=cs(this.frame,{labelSize:l,color:e.color,xLabel:e.xLabel,yLabel:e.yLabel});let c=new Map,u=t.map(h=>{let d=h.color;if(h.group!==void 0){let p=c.get(h.group);p||(p={color:d??re[c.size%re.length],sumX:0,top:-1/0,count:0},c.set(h.group,p)),d??=p.color,p.sumX+=h.x,p.top=Math.max(p.top,h.y),p.count++}let m=gt(h.radius??e.radius??6,d??"blue").at(ne(this.frame,h.x,h.y));return m.set("fillOpacity",.92),m});if(this.dots.push(...u),this.add(this.axis,...u),e.groupLabels??!0)for(let[h,d]of c){let m=It(h,l+2,d.color),[p,f]=ne(this.frame,d.sumX/d.count,d.top);m.at(p,f-l*1.2),this.groupLabels.push(m),this.add(m)}}p(t,e){return ne(this.frame,t,e)}enter(t={}){let e=t.lag??Math.min(.2,8/Math.max(1,this.dots.length));return{label:"scatter.enter",duration:t.duration??2,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=r.t1-r.t0;D(this.axis,"opacity",0,r.t0),this.axis.tween("opacity",1,r.t0,r.t0+o*.3,r.ease);let s=[...this.dots].sort((a,l)=>a.get("x")-l.get("x")),i=Vt(s.length,e,r.t0+o*.15,r.t1);s.forEach((a,l)=>{let[c,u]=i[l],h=a.get("sx");D(a,"sx",.001,r.t0),D(a,"sy",.001,r.t0),a.tween("sx",h,c,u,r.ease),a.tween("sy",h,c,u,r.ease)});for(let a of this.groupLabels)D(a,"opacity",0,r.t0),a.tween("opacity",1,r.t0+o*.7,r.t1,r.ease)}}}fit(t,e={}){let[r,o]=this.frame.xRange,s=e.samples??60,i=[];for(let l=0;l<=s;l++){let c=r+(o-r)*l/s;i.push(this.p(c,t(c)))}let a=new N(Lt(i)).stroke(e.color??"yellow",e.width??3.5);return this.add(a),a}};function Ou(n,t={}){return new mr(n,t)}var pr=class extends N{lines=[];areas=[];names=[];axis;byName=new Map;frame;constructor(t,e={}){super();let r=t.map(b=>b.points??(b.values??[]).map((y,g)=>[g,y])),o=r.flat().map(b=>b[0]),s=r.flat().map(b=>b[1]),i=Math.min(...s),a=Math.max(...s),l=(a-i||1)*.08,c=e.x??[Math.min(...o),Math.max(...o)],u=e.y??[i>=0&&i<(a-i)*.4?0:i-l,a+l],h=e.width??900,d=e.height??480;this.frame={xRange:c,yRange:u,w:h,h:d};let m=e.labelSize??18;this.axis=cs(this.frame,{labelSize:m,color:e.color,xLabel:e.xLabel,yLabel:e.yLabel,xFormat:e.xFormat,yFormat:e.yFormat,xTicks:e.xTicks,yTicks:e.yTicks}),this.add(this.axis);let p=[];t.forEach((b,y)=>{let g=b.color??re[y%re.length],w=r[y].map(([M,v])=>ne(this.frame,M,v));if(b.area){let M=ne(this.frame,c[0],Math.max(u[0],0))[1],v=Z([...w,[w[w.length-1][0],M],[w[0][0],M]],!0),P=new N(v).fill(g,b.area);this.areas.push(P),this.add(P)}let x=b.smooth===!1?Z(w):Lt(w),k=new N(x).stroke(g,b.width??3.5);if(b.dash&&k.dash(b.dash),this.lines.push(k),this.add(k),b.name){this.byName.set(b.name,k);let M=It(b.name,m+1,g),v=w[w.length-1];p.push({label:M,y:v[1]}),M.at(v[0]+12+M.width/2,v[1]),this.names.push(M),this.add(M)}}),p.sort((b,y)=>b.y-y.y);let f=m*1.25;for(let b=0;b<8;b++)for(let y=1;y<p.length;y++){let g=f-(p[y].y-p[y-1].y);g>0&&(p[y-1].y-=g/2,p[y].y+=g/2)}for(let b of p)b.label.at(b.label.get("x"),b.y)}p(t,e){return ne(this.frame,t,e)}series(t){let e=this.byName.get(t);if(!e)throw new Error(`No series named ${JSON.stringify(t)}.`);return e}enter(t={}){let e=t.lag??.1;return{label:"lineChart.enter",duration:t.duration??2.2,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=r.t1-r.t0;D(this.axis,"opacity",0,r.t0),this.axis.tween("opacity",1,r.t0,r.t0+o*.3,r.ease);let s=Vt(this.lines.length,e,r.t0+o*.15,r.t1);this.lines.forEach((i,a)=>{let[l,c]=s[a];D(i,"trimTo",0,r.t0),i.tween("trimTo",1,l,c,r.ease);let u=this.names[a];u&&(D(u,"opacity",0,r.t0),u.tween("opacity",1,c-(c-l)*.2,Math.min(r.t1,c+o*.1),r.ease))});for(let i of this.areas){let a=i.get("fillOpacity");D(i,"fillOpacity",0,r.t0),i.tween("fillOpacity",a,r.t0+o*.5,r.t1,r.ease)}}}}};function Cu(n,t={}){return new pr(n,t)}function ur(n,t,e,r){if(t-n<1e-4)return[];let o=St(0,0,r,r,n,t)[0].p,s=Array.from(o),i=s[s.length-2],a=s[s.length-1],l=(c,u,h,d)=>{s.push(c+(h-c)/3,u+(d-u)/3,c+(h-c)*2/3,u+(d-u)*2/3,h,d)};if(e>.01){let c=St(0,0,e,e,t,n)[0].p;l(i,a,c[0],c[1]);for(let u=2;u<c.length;u++)s.push(c[u]);l(c[c.length-2],c[c.length-1],o[0],o[1])}else l(i,a,0,0),l(0,0,o[0],o[1]);return[Mt(s,!0)]}var fn=class extends N{wedges=[];labels=[];leaders=[];centerText=null;shares;inner;outer;gap;constructor(t,e={}){super(),this.outer=e.radius??240,this.inner=this.outer*(e.hole??0),this.gap=e.gap??(this.inner>0?.018:.008);let r=t.reduce((i,a)=>i+Math.max(0,a.value),0)||1;this.shares=t.map(i=>Math.max(0,i.value)/r);let o=e.labelSize??20,s=this.angles(this.shares);if(t.forEach((i,a)=>{let l=i.color??re[a%re.length],[c,u]=s[a],h=new N(ur(c,u,this.inner,this.outer)).fill(l,.86);this.wedges.push(h),this.add(h)}),(e.labels??!0)&&t.forEach((i,a)=>{let[l,c]=s[a],u=(l+c)/2,h=Math.cos(u),d=Math.sin(u),m=this.outer+6,p=this.outer+30,f=h*p,b=d*p,y=f+(h>=0?18:-18),g=new N(Z([[h*m,d*m],[f,b],[y,b]])).stroke("faint",1.25),x=e.percent??!0?`${i.label} ${Math.round(this.shares[a]*100)}%`:i.label,k=It(x,o,"ink");k.at(y+(h>=0?8+k.width/2:-8-k.width/2),b),this.leaders.push(g),this.labels.push(k),this.add(g,k)}),e.centerLabel){let i=H(e.centerLabel,{size:e.centerSize??Math.max(24,this.inner*.34),font:"serif",color:"ink"}).at(0,0);this.centerText=i,this.add(i)}}angles(t,e=1){let r=-Math.PI/2;return t.map(o=>{let s=o*Math.PI*2*e,i=Math.min(this.gap*e,s*.45),a=[r+i/2,r+s-i/2];return r+=s,a})}enter(t={}){return{label:"pie.enter",duration:t.duration??1.6,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=e.t1-e.t0,o=e.t0+r*.78;this.wedges.forEach((s,i)=>{let a=l=>{let[c,u]=this.angles(this.shares,l)[i];return ur(c,u,this.inner,this.outer)};s.track("path").step(e.t0,[]),s.track("path").add({t0:e.t0,t1:o,ease:e.ease,to:a(1),at:a})});for(let s of[...this.labels,...this.leaders,...this.centerText?[this.centerText]:[]])D(s,"opacity",0,e.t0),s.tween("opacity",1,e.t0+r*.62,e.t1,e.ease)}}}update(t,e={}){return{label:"pie.update",duration:e.duration??1.1,ease:e.ease,schedule:r=>{let o=t.reduce((a,l)=>a+Math.max(0,l),0)||1,s=t.map(a=>Math.max(0,a)/o),i=[...this.shares];this.wedges.forEach((a,l)=>{let c=u=>{let h=i.map((p,f)=>p+((s[f]??0)-p)*u),[d,m]=this.angles(h)[l];return ur(d,m,this.inner,this.outer)};a.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:c(1),at:c})});for(let a of[...this.labels,...this.leaders])a.tween("opacity",0,r.t0,r.t0+(r.t1-r.t0)*.3,r.ease);s.forEach((a,l)=>{this.shares[l]=a})}}}};function Su(n,t={}){return new fn(n,t)}function Ru(n,t={}){return new fn(n,{hole:.62,...t})}var De=class extends N{cells=[];rowLabels=[];columnLabels=[];numbers=[];rowCount;colCount;stops;domain;constructor(t,e={}){super(),this.rowCount=t.length,this.colCount=Math.max(0,...t.map(m=>m.length));let r=e.cellWidth??e.cell??44,o=e.cellHeight??e.cell??44,s=e.gap??2,i=t.flat();this.domain=e.domain??[Math.min(...i),Math.max(...i)];let a=(e.colors??["surface","blue","yellow"]).map(m=>Ft(m));this.stops=a.map((m,p)=>[a.length===1?0:p/(a.length-1),m]);let l=this.colCount*r+(this.colCount-1)*s,c=this.rowCount*o+(this.rowCount-1)*s,u=e.labelSize??16,h=e.valueSize??Math.min(o*.38,r*.36),d=e.format??(m=>(Math.round(m*100)/100).toString());t.forEach((m,p)=>{let f=[],b=[];m.forEach((y,g)=>{let w=-l/2+g*(r+s)+r/2,x=-c/2+p*(o+s)+o/2,k=this.colorFor(y),M=new N(K(-r/2,-o/2,r,o,e.radius??0)).fill(k).at(w,x);if(f.push(M),this.add(M),e.values){let v=H(d(y),{size:h,font:"mono",color:os(k)>.32?"#101114":"#f2efe6"}).at(w,x);b.push(v),this.add(v)}}),this.cells.push(f),this.numbers.push(b)}),e.rowLabels?.forEach((m,p)=>{let f=It(m,u),b=-c/2+p*(o+s)+o/2;f.at(-l/2-10-f.width/2,b),this.rowLabels.push(f),this.add(f)}),e.columnLabels?.forEach((m,p)=>{let f=It(m,u),b=-l/2+p*(r+s)+r/2,y=e.columnLabelAngle??0;if(y!==0){let g=f.width;f.at(b+Math.cos(y)*g/2,-c/2-12+Math.sin(y)*g/2),f.set("rotation",y)}else f.at(b,-c/2-10-u/2);this.columnLabels.push(f),this.add(f)})}colorFor(t){let[e,r]=this.domain;return lt(this.stops,Math.max(0,Math.min(1,(t-e)/(r-e||1))))}cell(t,e){let r=this.cells[t]?.[e];if(!r)throw new Error(`Heatmap has no cell (${t}, ${e}). It is ${this.rowCount} by ${this.colCount}.`);return r}row(t){return[...this.cells[t]??[]]}col(t){return this.cells.map(e=>e[t]).filter(Boolean)}enter(t={}){return{label:"heatmap.enter",duration:t.duration??1.6,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=e.t1-e.t0,o=this.rowCount+this.colCount-1,s=r*.5,i=o>1?(r-s)/(o-1):0;this.cells.forEach((a,l)=>a.forEach((c,u)=>{let h=e.t0+(l+u)*i;D(c,"opacity",0,e.t0),c.tween("opacity",1,h,h+s,e.ease);let d=this.numbers[l]?.[u];d&&(D(d,"opacity",0,e.t0),d.tween("opacity",1,h,h+s,e.ease))}));for(let a of[...this.rowLabels,...this.columnLabels])D(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0,e.t0+r*.4,e.ease)}}}update(t,e={}){return{label:"heatmap.update",duration:e.duration??1,ease:e.ease,schedule:r=>{t.forEach((o,s)=>o.forEach((i,a)=>{let l=this.cells[s]?.[a];l&&l.tween("fill",this.colorFor(i),r.t0,r.t1,r.ease)}))}}}};function Tu(n,t={}){return new De(n,t)}var fr=null,us=null;function ra(){if(fr)return fr;throw us??=import("./dagre.esm-6F3RIGLP.js").then(n=>{fr=n.default??n}),new Ot(us)}var gr=class extends N{shape;caption=null;halfWidth=0;halfHeight=0;round=!0;edgePoint(t,e,r,o,s=0){let i=r-t,a=o-e,l=Math.hypot(i,a)||1;if(this.round)return[t+i/l*(this.halfWidth+s),e+a/l*(this.halfWidth+s)];let c=i===0?1/0:this.halfWidth/Math.abs(i),u=a===0?1/0:this.halfHeight/Math.abs(a),h=Math.min(c,u);return[t+i*h+i/l*s,e+a*h+a/l*s]}},yr=class extends N{shaft;tip=null;caption=null;from="";to="";tipSize=14};function br(n,t){let e=Pt(n);if(e<=t*1.1)return{head:[],trimmed:n};let r=1-t/e,o=Jt(n,0,r),[s,i]=Nt(n,1),[a,l]=ge(n,.997),c=t*.38,u=s-a*t,h=i-l*t;return{head:Z([[s,i],[u-l*c,h+a*c],[u+l*c,h-a*c]],!0),trimmed:o}}var bn=class extends N{nodes=new Map;edges=[];edgeLayer=new N;nodeLayer=new N;specs;constructor(t,e,r={}){super(),this.specs=t;let o=r.radius??30,s=r.labelSize??26,i=p=>p.width?[p.width,p.height??s*2]:[(p.radius??o)*2,(p.radius??o)*2],a=r.layout??"dagre",l=new Map,c=new Map;if(a==="dagre"){let p=ra(),f=new p.graphlib.Graph({multigraph:!0});f.setGraph({rankdir:r.direction??"LR",nodesep:r.nodeGap??60,ranksep:r.rankGap??110,edgesep:24,ranker:"network-simplex"}),f.setDefaultEdgeLabel(()=>({}));for(let w of t){let[x,k]=i(w);f.setNode(w.id,{width:x,height:k})}e.forEach((w,x)=>f.setEdge(w.from,w.to,{},String(x))),p.layout(f);let b=f.graph(),y=(b.width??0)/2,g=(b.height??0)/2;for(let w of t){let x=f.node(w.id);l.set(w.id,[x.x-y,x.y-g])}e.forEach((w,x)=>{let k=f.edge({v:w.from,w:w.to,name:String(x)});k?.points&&c.set(w,k.points.map(M=>[M.x-y,M.y-g]))})}else if(a==="circle"){let p=Math.min(r.width??700,r.height??700)/2;t.forEach((f,b)=>{let y=-Math.PI/2+b/t.length*Math.PI*2;l.set(f.id,[Math.cos(y)*p,Math.sin(y)*p])})}else if(a==="force")l=sa(t,e,r.width??900,r.height??620,r.seed??3);else for(let p of t)l.set(p.id,p.at??[0,0]);let u=r.nodeColor??"blue";for(let p of t){let f=new gr,b=p.color??u,[y,g]=i(p);f.halfWidth=y/2,f.halfHeight=g/2,f.round=!p.width,f.shape=new N(p.width?K(-y/2,-g/2,y,g,8):Dt(0,0,y/2)).fill(b,r.fillOpacity??.16).stroke(b,2.5),f.add(f.shape),p.label&&(f.caption=p.math?st(p.label,{size:s,color:"ink",display:!1}):H(p.label,{size:s,color:"ink"}),f.add(f.caption.at(0,0))),f.named(p.id),f.at(l.get(p.id)??[0,0]),this.nodes.set(p.id,f),this.nodeLayer.add(f)}let h=r.directed??!0,d=r.edgeColor??"dim",m=r.edgeLabelSize??20;for(let p of e){let f=this.nodes.get(p.from),b=this.nodes.get(p.to);if(!f||!b)throw new Error(`Graph edge ${p.from} -> ${p.to} refers to a node that does not exist.`);let y=new yr;y.from=p.from,y.to=p.to;let g=l.get(p.from),w=l.get(p.to),x=c.get(p),k=(r.direction??"LR")==="LR"||r.direction==="RL",M=oa(f,b,g,w,x,k),v=p.directed??h,P=p.color??d,{head:A,trimmed:O}=v?br(M,y.tipSize):{head:[],trimmed:M};if(y.shaft=new N(O).stroke(P,p.width??2.2),p.dash&&y.shaft.dash(p.dash),y.add(y.shaft),A.length&&(y.tip=new N(A).fill(P),y.add(y.tip)),p.label){let[R,$]=Nt(M,.5),z=H(p.label,{size:m,color:"ink",font:"mono"}).at(R,$),B=m*.34,W=new N(K(R-z.width/2-B,$-m*.68,z.width+B*2,m*1.36,4)).fill("bg");y.caption=new N().add(W,z),y.add(y.caption)}this.edges.push(y),this.edgeLayer.add(y)}this.add(this.edgeLayer,this.nodeLayer)}node(t){let e=this.nodes.get(t);if(!e)throw new Error(`Graph has no node ${JSON.stringify(t)}.`);return e}edge(t,e){let r=this.edges.find(o=>o.from===t&&o.to===e)??this.edges.find(o=>o.from===e&&o.to===t);if(!r)throw new Error(`Graph has no edge ${t} -> ${e}.`);return r}enter(t={}){let e=t.lag??.14;return{label:"graph.enter",duration:t.duration??2,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=this.specs.map(a=>this.nodes.get(a.id)),s=Vt(o.length,e,r.t0,r.t0+(r.t1-r.t0)*.78),i=new Map;o.forEach((a,l)=>{let[c,u]=s[l];i.set(a,u),gn(a,r.t0,c,u,r.ease)});for(let a of this.edges){let l=i.get(this.nodes.get(a.from))??r.t0,c=Math.min(r.t1,l+(r.t1-r.t0)*.22);D(a.shaft,"trimTo",0,r.t0),a.shaft.tween("trimTo",1,l,c,r.ease);for(let u of[a.tip,a.caption])u&&(D(u,"opacity",0,r.t0),u.tween("opacity",1,c-(c-l)*.3,c,r.ease))}}}}pulseEdge(t,e,r={}){let o=this.edge(t,e);return{...Dn(o.shaft,{color:r.color??"yellow",length:r.length??.3,...r}),label:"graph.pulse"}}visit(t,e={}){let r=this.node(t),o=e.color??"yellow";return{label:"graph.visit",duration:e.duration??.6,ease:e.ease,schedule:s=>{let i=X(o);r.shape.tween("stroke",i,s.t0,s.t1,s.ease),r.shape.tween("fill",i,s.t0,s.t1,s.ease);let a=s.t1-s.t0,l=r.get("sx");r.tween("sx",l*1.16,s.t0,s.t0+a*.45,s.ease),r.tween("sy",l*1.16,s.t0,s.t0+a*.45,s.ease),r.tween("sx",l,s.t0+a*.45,s.t1,s.ease),r.tween("sy",l,s.t0+a*.45,s.t1,s.ease)}}}moveNode(t,e,r={}){let o=this.node(t);return{label:"graph.move",duration:r.duration??1,ease:r.ease,schedule:s=>{let i=o.get("x"),a=o.get("y");o.tween("x",e[0],s.t0,s.t1,s.ease),o.tween("y",e[1],s.t0,s.t1,s.ease);for(let l of this.edges){if(l.from!==t&&l.to!==t)continue;let c=this.node(l.from===t?l.to:l.from),u=me(c,"x",s.t0),h=me(c,"y",s.t0),d=p=>{let f=i+(e[0]-i)*p,b=a+(e[1]-a)*p,y=l.from===t?o.edgePoint(f,b,u,h,2):c.edgePoint(u,h,f,b,2),g=l.from===t?c.edgePoint(u,h,f,b,4):o.edgePoint(f,b,u,h,4);return Z([y,g])},m=p=>l.tip?br(d(p),l.tipSize).trimmed:d(p);if(l.shaft.track("path").add({t0:s.t0,t1:s.t1,ease:s.ease,to:m(1),at:m}),l.tip){let p=f=>br(d(f),l.tipSize).head;l.tip.track("path").add({t0:s.t0,t1:s.t1,ease:s.ease,to:p(1),at:p})}}}}}};function oa(n,t,e,r,o,s){let i=o?o.slice(1,-1):[],a=i[0]??r,l=i[i.length-1]??e,c=n.edgePoint(e[0],e[1],a[0],a[1],2),u=t.edgePoint(r[0],r[1],l[0],l[1],4);if(!o)return Z([c,u]);if(i.length<=1){let h=u[0]-c[0],d=u[1]-c[1];if(Math.abs(s?d:h)<2)return Z([c,u]);let m=(s?h:d)*.5,p=s?`${c[0]+m} ${c[1]}`:`${c[0]} ${c[1]+m}`,f=s?`${u[0]-m} ${u[1]}`:`${u[0]} ${u[1]-m}`;return vt(`M${c[0]} ${c[1]}C${p} ${f} ${u[0]} ${u[1]}`)}return Lt([c,...i.slice(1,-1),u])}function gn(n,t,e,r,o){let s=me(n,"sx",e),i=me(n,"sy",e);D(n,"sx",s*.001,t),D(n,"sy",i*.001,t),n.tween("sx",s,e,r,o),n.tween("sy",i,e,r,o)}function sa(n,t,e,r,o){let s=Be(o),i=n.map(d=>d.id),a=new Float64Array(i.length),l=new Float64Array(i.length);for(let d=0;d<i.length;d++)a[d]=(s()-.5)*e,l[d]=(s()-.5)*r;let c=new Map(i.map((d,m)=>[d,m])),u=Math.sqrt(e*r/Math.max(1,i.length))*.72,h=Math.max(e,r)*.12;for(let d=0;d<420;d++){let m=new Float64Array(i.length),p=new Float64Array(i.length);for(let f=0;f<i.length;f++)for(let b=f+1;b<i.length;b++){let y=a[f]-a[b],g=l[f]-l[b],w=Math.max(1,Math.hypot(y,g)),x=u*u/w;m[f]+=y/w*x,p[f]+=g/w*x,m[b]-=y/w*x,p[b]-=g/w*x}for(let f of t){let b=c.get(f.from),y=c.get(f.to);if(b===void 0||y===void 0)continue;let g=a[b]-a[y],w=l[b]-l[y],x=Math.max(1,Math.hypot(g,w)),k=x*x/u;m[b]-=g/x*k,p[b]-=w/x*k,m[y]+=g/x*k,p[y]+=w/x*k}for(let f=0;f<i.length;f++){let b=Math.max(1e-6,Math.hypot(m[f],p[f]));a[f]+=m[f]/b*Math.min(b,h),l[f]+=p[f]/b*Math.min(b,h),a[f]=Math.max(-e/2,Math.min(e/2,a[f])),l[f]=Math.max(-r/2,Math.min(r/2,l[f]))}h*=.985}return new Map(i.map((d,m)=>[d,[a[m],l[m]]]))}function Hu(n,t,e={}){return new bn(n,t,e)}var wr=class extends bn{depths=new Map;constructor(t,e={}){let r=[],o=[],s=new Map,i=e.levelGap??130,a=e.siblingGap??96,l=0,c=0,u=(f,b)=>{let y=f.id??`n${l++}`;s.set(y,b);let g=f.children??[],w,x={id:y,label:f.label,color:f.color,math:f.math};if(r.push(x),g.length===0)w=c++;else{let k=g.map(M=>u(M,b+1));w=(k[0].position+k[k.length-1].position)/2;for(let M of k)o.push({from:y,to:M.id,directed:!1})}return x.at=e.direction==="right"?[b*i,w*a]:[w*a,b*i],{id:y,position:w}};u(t,0);let h=r.map(f=>f.at[0]),d=r.map(f=>f.at[1]),m=(Math.min(...h)+Math.max(...h))/2,p=(Math.min(...d)+Math.max(...d))/2;for(let f of r)f.at=[f.at[0]-m,f.at[1]-p];super(r,o,{layout:"manual",radius:e.radius??28,labelSize:e.labelSize??24,nodeColor:e.nodeColor,edgeColor:e.edgeColor,fillOpacity:e.fillOpacity,directed:!1});for(let[f,b]of s)this.depths.set(f,b)}enter(t={}){return{label:"tree.enter",duration:t.duration??2,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=Math.max(...this.depths.values())+1,o=(e.t1-e.t0)/r;for(let[s,i]of this.nodes){let a=this.depths.get(s)??0,l=e.t0+a*o;gn(i,e.t0,l,l+o,e.ease)}for(let s of this.edges){let i=this.depths.get(s.to)??1,a=e.t0+(i-1)*o+o*.3;D(s.shaft,"trimTo",0,e.t0),s.shaft.tween("trimTo",1,a,a+o*.8,e.ease)}}}}};function Ku(n,t={}){return new wr(n,t)}var xr=class extends N{slots=[];indexLabels=[];items=[];cellSize;step;constructor(t,e={}){super();let r=this.cellSize=e.cell??72,o=e.gap??6;this.step=r+o;let s=e.size??r*.38,i=e.color??"blue",a=-((t.length-1)*this.step)/2;t.forEach((l,c)=>{let u=a+c*this.step,h=new N(K(-r/2,-r/2,r,r,6)).stroke("faint",1.5).at(u,0);if(this.slots.push(h),this.add(h),e.indices??!0){let d=H(String(c),{size:e.indexSize??Math.max(13,r*.2),color:"faint",font:"mono"}).at(u,r/2+(e.indexSize??r*.2)+2);this.indexLabels.push(d),this.add(d)}}),t.forEach((l,c)=>{let u=a+c*this.step,h=new N().at(u,0),d=new N(K(-r/2+2,-r/2+2,r-4,r-4,5)).fill(i,.16).stroke(i,2),m=H(String(l),{size:s,font:e.font??"mono",color:"ink"}).at(0,0);h.add(d,m),h.data.box=d,h.data.value=l,this.items.push(h),this.add(h)})}cell(t){let e=this.items[t];if(!e)throw new Error(`Array has no index ${t}.`);return e}slotAt(t){return[this.slots[t].get("x"),this.slots[t].get("y")]}swap(t,e,r={}){return{label:"array.swap",duration:r.duration??.8,ease:r.ease,schedule:o=>{let s=this.items[t],i=this.items[e],[a,l]=this.slotAt(t),[c,u]=this.slotAt(e),h=r.lift??this.cellSize*.9+Math.abs(t-e)*6,d=(m,p,f,b,y,g)=>{m.track("x").add({t0:o.t0,t1:o.t1,ease:o.ease,to:b,at:w=>p+(b-p)*w}),m.track("y").add({t0:o.t0,t1:o.t1,ease:o.ease,to:y,at:w=>f+(y-f)*w-g*h*4*w*(1-w)})};d(s,a,l,c,u,1),d(i,c,u,a,l,-1),this.items[t]=i,this.items[e]=s}}}mark(t,e,r={}){let o=this.cell(t);return{...mo(o.data.box,e,{duration:.35,...r}),label:"array.mark"}}enter(t={}){let e=t.lag??.2;return{label:"array.enter",duration:t.duration??1.2,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=Vt(this.items.length,e,r.t0,r.t1);this.items.forEach((s,i)=>{let[a,l]=o[i];gn(s,r.t0,a,l,r.ease),D(this.slots[i],"opacity",0,r.t0),this.slots[i].tween("opacity",1,a,l,r.ease);let c=this.indexLabels[i];c&&(D(c,"opacity",0,r.t0),c.tween("opacity",1,a,l,r.ease))})}}}};function Xu(n,t={}){return new xr(n,t)}var hs={ts:new Set("const let var function return if else for while do switch case break continue new class extends implements interface type enum import export from default async await yield try catch finally throw typeof instanceof in of this super null undefined true false void as readonly public private protected static get set".split(" ")),python:new Set("def return if elif else for while in not and or is class import from as with try except finally raise lambda yield pass break continue global nonlocal None True False self async await assert del print".split(" ")),rust:new Set("fn let mut pub struct enum impl trait use mod match if else for while loop return self Self as in where const static crate super true false ref move async await dyn type".split(" ")),go:new Set("func var const type struct interface package import return if else for range switch case default break continue go defer select chan map nil true false".split(" ")),sql:new Set("select from where join left right inner outer on group by order having limit as and or not in is null insert into values update set delete create table with distinct count sum avg min max".split(" ")),bash:new Set("if then else elif fi for do done while case esac in function return export local echo cd exit set".split(" ")),plain:new Set};function ia(n,t="ts"){let e=t==="js"||t==="tsx"||t==="jsx"||t==="typescript"||t==="javascript"?"ts":t==="py"?"python":t,r=hs[e]??hs.ts,o=e==="sql",s=e==="python"||e==="bash",i=e==="sql",a=[];return n.split(`
3
- `).forEach((l,c)=>{let u=0;for(;u<l.length;){let h=l.slice(u),d=(y,g)=>{a.push({text:y,kind:g,line:c}),u+=y.length},m=/^\s+/.exec(h);if(m){d(m[0],"space");continue}if(!s&&!i&&h.startsWith("//")||s&&h[0]==="#"||i&&h.startsWith("--")){d(h,"comment");continue}let p=/^("(?:[^"\\]|\\.)*"?|'(?:[^'\\]|\\.)*'?|`(?:[^`\\]|\\.)*`?)/.exec(h);if(p){d(p[0],"string");continue}let f=/^(0x[\da-fA-F_]+|\d[\d_]*(?:\.\d+)?(?:e[-+]?\d+)?)/.exec(h);if(f){d(f[0],"number");continue}let b=/^[A-Za-z_$][\w$]*/.exec(h);if(b){let y=b[0],g=h.slice(y.length),x=r.has(o?y.toLowerCase():y)?"keyword":/^\s*\(/.test(g)?"function":/^[A-Z]/.test(y)?"type":"plain";d(y,x);continue}d(h[0],"punctuation")}}),a}var aa={keyword:"purple",string:"green",number:"orange",comment:"faint",function:"blue",type:"teal",punctuation:"dim",plain:"ink"},kr=class extends N{lines=[];tokens=[];chars=[];panelNode=null;body=new N;source;bar;rowHeight;originY;contentWidth;constructor(t,e={}){super(),this.source=t;let r=e.size??26,o=this.rowHeight=r*(e.leading??1.5),s=xe("mono",400),i=r/s.unitsPerEm,a=s.advance(s.glyphFor(48))*i,l=ia(t,e.language??"ts"),c=t.split(`
4
- `),u=e.lineNumbers?(String(c.length).length+2)*a:0,h=e.padding??r*.9,d=Math.max(e.minWidth??0,Math.max(...c.map(g=>g.length))*a+u+h*2),m=c.length*o+h*2-(o-r);this.contentWidth=d;let p=-d/2+h+u,f=-m/2+h+r*.82;if(this.originY=f,e.panel??!0){let g=new N(K(-d/2,-m/2,d,m,8)).fill("surface").stroke("gridStrong",1);this.panelNode=g,this.add(g)}this.bar=new N().fill("yellow",.1),this.bar.base.visible=!1,this.add(this.bar);for(let g=0;g<c.length;g++){let w=new N;if(this.lines.push(w),this.body.add(w),e.lineNumbers){let x=String(g+1).padStart(String(c.length).length," "),k=p-u;for(let M of x)M!==" "&&w.add(ds(s,M,r,"faint",k,f+g*o)),k+=a}}let b={...aa,...e.colors},y=new Map;for(let g of l){let w=y.get(g.line)??0;y.set(g.line,w+g.text.length);let x={...g,glyphs:[]};if(this.tokens.push(x),g.kind==="space")continue;let k=b[g.kind];[...g.text].forEach((M,v)=>{let P=ds(s,M,r,k,p+(w+v)*a,f+g.line*o);x.glyphs.push(P),this.chars.push(P),this.lines[g.line].add(P)})}this.add(this.body)}line(t){let e=this.lines[t];if(!e)throw new Error(`Code has no line ${t}.`);return e}find(t){return this.tokens.filter(e=>e.text===t).flatMap(e=>e.glyphs)}focus(t,e={}){let r=new Set(typeof t=="number"?[t]:t);return{label:"code.focus",duration:e.duration??.6,ease:e.ease,schedule:o=>{this.lines.forEach((d,m)=>{d.tween("opacity",r.has(m)?1:e.dim??.28,o.t0,o.t1,o.ease)});let s=[...r].sort((d,m)=>d-m),i=s[0]??0,a=s[s.length-1]??i,l=this.originY-this.rowHeight*.32+(i+a)/2*this.rowHeight,c=a-i+1,u=K(-this.contentWidth/2+2,-this.rowHeight*c/2,this.contentWidth-4,this.rowHeight*c,3);me(this.bar,"visible",o.t0)?(this.bar.tween("y",l,o.t0,o.t1,o.ease),this.bar.tween("path",u,o.t0,o.t1,o.ease)):(D(this.bar,"x",0,o.t0),D(this.bar,"y",l,o.t0),this.bar.track("path").step(o.t0,u),D(this.bar,"visible",!0,o.t0),D(this.bar,"opacity",0,o.t0),this.bar.tween("opacity",1,o.t0,o.t1,o.ease)),e.color&&this.bar.tween("fill",X(e.color),o.t0,o.t1,o.ease)}}}unfocus(t={}){return{label:"code.unfocus",duration:t.duration??.5,ease:t.ease,schedule:e=>{for(let r of this.lines)r.tween("opacity",1,e.t0,e.t1,e.ease);this.bar.tween("opacity",0,e.t0,e.t1,e.ease),D(this.bar,"visible",!1,e.t1)}}}};function ds(n,t,e,r,o,s){let i=new N(ze(n,n.glyphFor(t.codePointAt(0)),e));return i.base.fill=X(r),i.base.trimEach=!0,i.data.key=t,i.at(o,s)}function Yu(n,t={}){return new kr(n,t)}function qu(n,t,e={}){let r=u=>u.tokens.filter(h=>h.kind!=="space"&&h.glyphs.length>0),o=r(n),s=r(t),i=Je(o.map(u=>u.text),s.map(u=>u.text)),a=new Map;i.forEach(([u,h],d)=>{o[u].glyphs.forEach((m,p)=>a.set(m,`m${d}:${p}`)),s[h].glyphs.forEach((m,p)=>a.set(m,`m${d}:${p}`))}),n.panelNode&&t.panelNode&&(a.set(n.panelNode,"panel"),a.set(t.panelNode,"panel"));let l=0;return{...we(n,t,{duration:1.5,...e,key:u=>{let h=a.get(u);return h===void 0&&(h=`only:${l++}`,a.set(u,h)),h}}),label:"morphCode"}}var Mr=class extends N{neurons=[];links=[];edgeLayer=new N;neuronLayer=new N;captions=[];seed;layerColors;constructor(t,e={}){super();let r=e.width??1e3,o=e.height??560,s=e.radius??15,i=e.collapse??8,a=t.length>1?r/(t.length-1):0;this.seed=e.seed??11,this.layerColors=e.colors??["blue","teal","teal","yellow"];let l=e.edgeColor??"dim",c=e.edgeOpacity??.32,u=[];t.forEach((h,d)=>{let m=h>i?i:h,p=Math.min(s*3.6,o/Math.max(1,m+(h>i?1:0))),f=-r/2+d*a,b=[],y=[],g=this.layerColors[Math.min(d,this.layerColors.length-1)],w=Math.ceil(m/2);for(let k=0;k<m+(h>i?1:0);k++){let M=(k-(m+(h>i?1:0)-1)/2)*p;if(h>i&&k===w){this.neuronLayer.add(st("\\vdots",{size:s*1.9,color:"dim",display:!1}).at(f,M));continue}b.push([f,M]);let v=new N(Dt(0,0,s)).stroke(g,2.2).fill(g,.08).at(f,M);y.push(v),this.neuronLayer.add(v)}u.push(b),this.neurons.push(y);let x=e.layerLabels?.[d];if(x){let k=e.labelSize??22,M=H(x,{size:k,color:"dim"}).at(f,o/2+k*1.5);this.captions.push(M),this.add(M)}});for(let h=0;h+1<u.length;h++){let d=[];for(let m of u[h]){let p=[];for(let f of u[h+1]){let b=Math.hypot(f[0]-m[0],f[1]-m[1])||1,y=(f[0]-m[0])/b,g=(f[1]-m[1])/b,w=Y([m[0]+y*s,m[1]+g*s],[f[0]-y*s,f[1]-g*s],{stroke:l,width:1.1});w.set("strokeOpacity",c),p.push(w),this.edgeLayer.add(w)}d.push(p)}this.links.push(d)}this.add(this.edgeLayer,this.neuronLayer)}layer(t){return this.neurons[t]??[]}enter(t={}){return{label:"net.enter",duration:t.duration??2.2,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=e.t1-e.t0,o=this.neurons.length,s=r*.45,i=o>1?r*.55/(o-1):0;this.neurons.forEach((a,l)=>{let c=Vt(a.length,.12,e.t0+l*i,e.t0+l*i+s);a.forEach((u,h)=>gn(u,e.t0,c[h][0],c[h][1],e.ease))}),this.links.forEach((a,l)=>{let c=e.t0+l*i+s*.45;for(let u of a)for(let h of u)D(h,"trimTo",0,e.t0),h.tween("trimTo",1,c,c+s,e.ease)});for(let a of this.neuronLayer.children)a.get("path")||(D(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0+r*.3,e.t1,e.ease));for(let a of this.captions)D(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0+r*.3,e.t1,e.ease)}}}activate(t,e,r={}){return{label:"net.activate",duration:r.duration??.45,ease:r.ease,schedule:o=>{this.neurons[t].forEach((s,i)=>{let a=Math.max(.04,Math.min(1,e[i]??0));s.tween("fillOpacity",a,o.t0,o.t1,o.ease),r.color&&s.tween("fill",X(r.color),o.t0,o.t1,o.ease)})}}}forward(t={}){let e=Be(this.seed),r=this.neurons.map((a,l)=>t.activations?.[l]??a.map(()=>e()*e())),o=t.color??"yellow",s=[];r.forEach((a,l)=>{if(s.push(this.activate(l,a,{duration:.35})),l+1>=this.neurons.length)return;let c=[];this.links[l].forEach((h,d)=>h.forEach((m,p)=>{c.push({link:m,score:(a[d]??0)*(r[l+1]?.[p]??0)})})),c.sort((h,d)=>d.score-h.score);let u=c.slice(0,t.pulses??10);s.push(Bn(...u.map(({link:h,score:d})=>Dn(h,{color:o,length:.42,width:1.5+d*3,glow:4,duration:.7}))))});let i=lo(...s);return{...i,label:"net.forward",duration:t.duration??i.duration,ease:t.ease}}};function Uu(n,t={}){return new Mr(n,t)}var vr=class extends N{chips=[];constructor(t,e={}){super();let r=e.size??22,o=e.gap??r*.28,s=e.subSize??r*.62,i=r*.42,a=r*.3,l=t.map(b=>typeof b=="string"?{text:b}:b),c=e.colors?Ie(l.length,...e.colors):null,u=0,h=0,d=[],m=r+a*2+(l.some(b=>b.sub)?s*1.4:0);for(let b=0;b<l.length;b++){let y=l[b],g=y.color??(c?c[b]:e.color??"blue"),w=H(y.text.replace(/ /g,"\xB7"),{size:r,font:e.font??"mono",color:"ink"}),x=Math.max(w.width,r*.5)+i*2,k=r+a*2;e.maxWidth!==void 0&&u>0&&u+x>e.maxWidth&&(u=0,h+=m+o);let M=new N,v=new N(K(-x/2,-k/2,x,k,e.radius??4)).fill(g,.18).stroke(g,1.5);M.add(v,w.at(0,0)),y.sub&&M.add(H(y.sub,{size:s,font:"mono",color:"dim"}).at(0,k/2+s*.82)),M.data.box=v,d.push({node:M,x:u+x/2,y:h,w:x}),u+=x+o}let p=Math.max(...d.map(b=>b.x+b.w/2),0),f=Math.max(...d.map(b=>b.y),0);for(let b of d)b.node.at(b.x-p/2,b.y-f/2),this.chips.push(b.node),this.add(b.node)}token(t){let e=this.chips[t];if(!e)throw new Error(`Token row has no token ${t}.`);return e}enter(t={}){let e=t.lag??.16;return{label:"tokens.enter",duration:t.duration??1.2,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=Vt(this.chips.length,e,r.t0,r.t1);this.chips.forEach((s,i)=>{let[a,l]=o[i],c=s.get("y");D(s,"opacity",0,r.t0),D(s,"y",c+16,r.t0),s.tween("opacity",1,a,l,r.ease),s.tween("y",c,a,l,r.ease)})}}}arcs(t,e,r={}){let o=this.token(t).bounds(),s=new N,i=o.x+o.width/2,a=o.y-3;return e.forEach((l,c)=>{if(c===t||l<=.01)return;let u=this.token(c).bounds(),h=u.x+u.width/2,d=u.y-3,m=r.lift??40+Math.abs(h-i)*.22,p=vt(`M${i} ${a}C${i} ${a-m} ${h} ${d-m} ${h} ${d}`),f=new N(p).stroke(r.color??"yellow",.8+l*(r.maxWidth??6));f.set("strokeOpacity",.2+l*.8),s.add(f)}),s}};function Zu(n,t={}){return new vr(n,t)}function Ju(n,t,e,r={}){return new De(e,{cell:r.cell??42,gap:r.gap??2,colors:r.colors??["surface","teal","yellow"],domain:[0,Math.max(...e.flat())],values:r.values,rowLabels:n,columnLabels:t,labelSize:r.labelSize??18,columnLabelAngle:-Math.PI/4})}function qt(n,t,e,r="left"){let o=n.get("px");return n.at(r==="left"?t+o:r==="right"?t-o:t,e)}function Ht(n){return n.get("px")*2}var Pr=class extends N{frame;accentBar=null;titleNode;subtitleNode=null;badgeNode=null;rowLabels=[];rowValues=[];meters=[];tagNodes=[];boxWidth;boxHeight;valueSize;constructor(t){super();let e=t.size??14;this.valueSize=e;let r=e*.8,o=t.rows??[],s=e*1.56,i=H(t.title,{size:e*1.14,weight:600,color:"ink"}),a=t.subtitle?H(t.subtitle,{size:e*.86,font:"mono",color:"dim"}):null,l=t.badgeTone??t.accent??"dim",c=t.badge?H(t.badge,{size:e*.78,font:"mono",color:l}):null,u=o.map(M=>H(M.label,{size:e,color:"dim"})),h=o.map(M=>M.value!==void 0?H(M.value,{size:e,font:"mono",color:M.tone??"ink"}):null),d=e*3.6,m=Math.max(Ht(i)+(c?Ht(c)+e*1.6:0),a?Ht(a):0,...o.map((M,v)=>Ht(u[v])+(h[v]?Ht(h[v])+e*1.1:0)+(M.spark?d+e*.6:0)),0),p=this.boxWidth=Math.max(t.width??0,m+r*2),f=e*1.4+(a?e*1.2:0),b=o.reduce((M,v)=>M+s+(v.meter!==void 0?e*.32:0),0),y=t.tags?.length?e*1.72:0,g=this.boxHeight=r*1.5+f+(o.length?e*.55:0)+b+y,w=-p/2+r,x=p/2-r;if(this.frame=new N(K(-p/2,-g/2,p,g,t.radius??4)).fill(t.fill??"surface").stroke(t.border??"gridStrong",1),this.add(this.frame),t.accent){let M=new N(K(-p/2,-g/2+1,2.5,g-2)).fill(t.accent);this.accentBar=M,this.add(M)}let k=-g/2+r*.75+e*.62;if(this.titleNode=qt(i,w,k),this.add(i),c&&(this.badgeNode=qt(c,x,k,"right"),this.add(c)),k+=e*1.3,a&&(this.subtitleNode=qt(a,w,k-e*.1),this.add(a),k+=e*1.2),o.length){let M=k-e*.38;this.add(Y([-p/2+r,M],[p/2-r,M],{stroke:"grid",width:1})),k+=e*.5}if(o.forEach((M,v)=>{qt(u[v],w,k),this.rowLabels.push(u[v]),this.add(u[v]);let P=x,A=h[v];if(A&&(qt(A,P,k,"right"),this.add(A),P-=Ht(A)+e*.7),this.rowValues.push(A??null),M.spark){let O=la(M.spark,{width:d,height:e*.82,color:M.tone??"blue",dotted:!0,weight:1.2});this.add(O.at(P-d/2,k-e*.1))}if(k+=s,M.meter!==void 0){let O=k-e*.62;this.add(Y([w,O],[x,O],{stroke:"grid",width:2}));let R=Y([w,O],[w+(x-w)*Math.max(0,Math.min(1,M.meter)),O],{stroke:M.tone??"blue",width:2});R.set("cap","butt"),this.meters.push(R),this.add(R),k+=e*.32}}),t.tags?.length){let M=w,v=g/2-r*.7-e*.4;for(let P of t.tags){let A=H(P,{size:e*.78,font:"mono",color:"dim"}),O=Ht(A)+e*.7,R=new N(K(M,v-e*.62,O,e*1.24,2)).stroke("gridStrong",1);qt(A,M+e*.35,v),this.tagNodes.push(A),this.add(R,A),M+=O+e*.34}}}port(t,e=0){let r=this.bounds(),o=r.x+r.width/2,s=r.y+r.height/2;return t==="left"?[r.x,s+e*r.height/2]:t==="right"?[r.x+r.width,s+e*r.height/2]:t==="top"?[o+e*r.width/2,r.y]:[o+e*r.width/2,r.y+r.height]}enter(t={}){return{label:"infoBox.enter",duration:t.duration??.9,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=e.t1-e.t0,o=this.frame.get("fillOpacity");D(this.frame,"trimTo",0,e.t0),D(this.frame,"fillOpacity",0,e.t0),this.frame.tween("trimTo",1,e.t0,e.t0+r*.65,e.ease),this.frame.tween("fillOpacity",o,e.t0+r*.2,e.t0+r*.8,e.ease);let s=this.children.filter(a=>a!==this.frame),i=Vt(s.length,.06,e.t0+r*.25,e.t1);s.forEach((a,l)=>{let[c,u]=i[l],h=a.get("opacity");D(a,"opacity",0,e.t0),a.tween("opacity",h,c,u,e.ease)})}}}setValue(t,e,r={}){let o=this.rowValues[t];if(!o)throw new Error(`Info box row ${t} has no value to change.`);let s=H(e,{size:this.valueSize,font:"mono",color:r.tone??"ink"}),i=o.get("x")+o.get("px");qt(s,i,o.get("y"),"right");let a=we(o,s,{duration:.5,...r});return{...a,label:"infoBox.setValue",schedule:l=>{this.add(s),this.rowValues[t]=s,a.schedule(l)}}}};function ah(n){return new Pr(n)}function la(n,t={}){let e=t.width??80,r=t.height??20,o=Math.min(...n),i=Math.max(...n)-o||1,a=n.map((u,h)=>[(h/Math.max(1,n.length-1)-.5)*e,(.5-(u-o)/i)*r]),l=t.color??"blue",c=new N;return t.area&&c.add(new N(Z([...a,[e/2,r/2],[-e/2,r/2]],!0)).fill(l,t.area)),c.add(new N(n.length>2?Lt(a):Z(a)).stroke(l,t.weight??1.5)),t.dotted&&c.add(gt((t.weight??1.5)*1.5,l).at(a[a.length-1])),c}var ms={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]};function ps(n,t,e){let r=n.x+n.width/2,o=n.y+n.height/2;return t==="left"?[n.x,o+e*n.height/2]:t==="right"?[n.x+n.width,o+e*n.height/2]:t==="top"?[r+e*n.width/2,n.y]:[r+e*n.width/2,n.y+n.height]}function ca(n,t){let e=Math.max(t.x-(n.x+n.width),n.x-(t.x+t.width)),r=Math.max(t.y-(n.y+n.height),n.y-(t.y+t.height)),o=n.x+n.width/2,s=n.y+n.height/2,i=t.x+t.width/2,a=t.y+t.height/2;return e>=r?i>=o?["right","left"]:["left","right"]:a>=s?["bottom","top"]:["top","bottom"]}function Nr(n,t){let e=`M${n[0][0]} ${n[0][1]}`;for(let o=1;o<n.length-1;o++){let s=n[o-1],i=n[o],a=n[o+1],l=Math.hypot(i[0]-s[0],i[1]-s[1]),c=Math.hypot(a[0]-i[0],a[1]-i[1]),u=Math.min(t,l/2,c/2);if(u<.5){e+=`L${i[0]} ${i[1]}`;continue}let h=i[0]-(i[0]-s[0])/(l||1)*u,d=i[1]-(i[1]-s[1])/(l||1)*u,m=i[0]+(a[0]-i[0])/(c||1)*u,p=i[1]+(a[1]-i[1])/(c||1)*u;e+=`L${h} ${d}Q${i[0]} ${i[1]} ${m} ${p}`}let r=n[n.length-1];return vt(`${e}L${r[0]} ${r[1]}`)}var Ar=class extends N{fromEnd;toEnd;options;pulses=[];plate=null;caption=null;constructor(t,e,r={}){super([]),this.fromEnd=t,this.toEnd=e,this.options=r,this.base.stroke=X(r.color??"dim"),this.base.strokeWidth=r.width??1.6,this.draw=o=>this.build(o)}anchors(){let{fromEnd:t,toEnd:e,options:r}=this,o=r.gap??3,s=m=>m instanceof N?m.bounds():{x:m[0],y:m[1],width:0,height:0},i=s(t),a=s(e),[l,c]=ca(i,a),u=r.from??l,h=r.to??c,d=(m,p,f,b)=>{let y=ms[f];if(!(m instanceof N))return{point:m,normal:y};let[g,w]=ps(p,f,b);return{point:[g+y[0]*o,w+y[1]*o],normal:y}};return[d(t,i,u,r.fromOffset??0),d(e,a,h,r.toOffset??0)]}routeNow(){let[t,e]=this.anchors(),r=this.options.route??"curve";if(r==="straight")return Z([t.point,e.point]);if(r==="ortho"){let l=this.options.radius??8,c=t.normal[0]!==0,u=e.normal[0]!==0;if(c&&u){let d=(t.point[0]+e.point[0])/2;return Nr([t.point,[d,t.point[1]],[d,e.point[1]],e.point],l)}if(!c&&!u){let d=(t.point[1]+e.point[1])/2;return Nr([t.point,[t.point[0],d],[e.point[0],d],e.point],l)}let h=c?[e.point[0],t.point[1]]:[t.point[0],e.point[1]];return Nr([t.point,h,e.point],l)}let o=Math.hypot(e.point[0]-t.point[0],e.point[1]-t.point[1]),s=Math.max(18,o*(this.options.curvature??.42)),i=[t.point[0]+t.normal[0]*s,t.point[1]+t.normal[1]*s],a=[e.point[0]+e.normal[0]*s,e.point[1]+e.normal[1]*s];return vt(`M${t.point[0]} ${t.point[1]}C${i[0]} ${i[1]} ${a[0]} ${a[1]} ${e.point[0]} ${e.point[1]}`)}build(t){let e=this.parent&&this.parent!==null?Wt(this.worldMatrix()):zt,r=ot(this.routeNow(),e),o=Pt(r);if(o<1)return[];let s=this.get("trimTo"),i=this.options,a=this.get("stroke"),l=this.get("strokeWidth"),c=[],u=i.tip??!0,h=u?i.tipSize??Math.max(7,l*4.4):0,d=s*(1-h/o),m=Jt(r,this.get("trimFrom"),d),p=a??X("dim");if(m.length){let f=new N(m).stroke(p,l);(i.dash||i.flow)&&f.dash(i.dash??[6,6],i.flow?-t*i.flow:0),f.set("strokeOpacity",this.get("strokeOpacity")),c.push(f)}if(u&&s>.02){let[f,b]=Nt(r,s),[y,g]=ge(r,Math.min(.997,s)),w=h*.38,x=f-y*h,k=b-g*h;c.push(new N(Z([[f,b],[x-g*w,k+y*w],[x+g*w,k-y*w]],!0)).fill(p))}for(let f of this.pulses){if(t<f.t0||t>=f.t1)continue;let b=f.ease((t-f.t0)/(f.t1-f.t0)),y=Math.max(0,b*(1+f.length)-f.length),g=Math.min(1,b*(1+f.length)),w=Jt(r,y,g);w.length&&c.push(new N(w).stroke(f.color,f.width).glow(f.glow))}if(i.label&&s>.5){let f=i.labelSize??12;this.caption??=H(i.label,{size:f,font:"mono",color:i.labelColor??"dim"});let b=Ht(this.caption),y=f*.35;this.plate??=new N(K(-b/2-y,-f*.72,b+y*2,f*1.44,2)).fill(i.labelBackground??"bg");let[g,w]=Nt(r,i.labelAt??.5),x=Math.min(1,(s-.5)*4);c.push(this.plate.at(g,w).opacity(x),this.caption.at(g,w).opacity(x))}return c}pulse(t={}){return{label:"connector.pulse",duration:t.duration??.9,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage),this.pulses.push({t0:e.t0,t1:e.t1,ease:e.ease,color:t.color??"yellow",length:t.length??.22,width:t.width??this.get("strokeWidth")+1.2,glow:t.glow??6})}}}pointNow(t=.5){return Nt(this.routeNow(),t)}};function lh(n,t,e={}){return new Ar(n,t,e)}function ch(n,t={}){let e=t.size??13,r=(t.direction??"row")==="row",o=t.gap??(r?e*1.5:e*.6),s=e*1.5,i=new N,a=0,l=[];for(let d of n){let m=d.color??"dim",p=d.kind??"swatch",f=p==="line"?Y([-s/2,0],[s/2,0],{stroke:m,width:2.2}):p==="dash"?Y([-s/2,0],[s/2,0],{stroke:m,width:2,dash:[4,3.5]}):p==="dot"?gt(e*.32,m):p==="ring"?Go(e*.32,{stroke:m,width:1.6}):new N(K(-e*.42,-e*.42,e*.84,e*.84,1.5)).fill(m),b=H(d.label,{size:e,color:"dim"}),y=s+e*.5+Ht(b),g=new N;g.add(f.at(s/2,0)),qt(b,s+e*.5,0),g.add(b),l.push({node:g,width:y})}let c=l.reduce((d,m)=>d+m.width,0)+o*Math.max(0,l.length-1),u=Math.max(0,...l.map(d=>d.width)),h=e*1.2+o;return l.forEach((d,m)=>{r?(d.node.at(-c/2+a,0),a+=d.width+o):d.node.at(-u/2,(m-(l.length-1)/2)*h),i.add(d.node)}),i}var Or=class extends N{leader;marker;body;titleNode=null;constructor(t,e,r={}){super();let o=r.size??15,s=r.color??"yellow",i=r.side??"right",a=r.distance??72,l=r.width??280,c=ms[i],u=t instanceof N?t.bounds():{x:t[0],y:t[1],width:0,height:0},h=t instanceof N?ps(u,i,0):t,d=r.title?H(r.title,{size:o,weight:600,color:s}):null,m=H(e,{size:o*.94,color:r.bodyColor??"dim",maxWidth:l,leading:1.36}),p=d?o*1.42:0,f=Math.max(m.width,d?Ht(d):0),b=m.height,y=p+b,g=r.offset??0,w=i==="right"?h[0]+a:i==="left"?h[0]-a-f:h[0]-f/2+g,x=i==="bottom"?h[1]+a:i==="top"?h[1]-a-y:h[1]-y/2+g;if(r.plate){let v=o*.5;this.add(new N(K(w-v,x-v,f+v*2,y+v*2,3)).fill("bg",.86))}d&&(this.titleNode=qt(d,w,x+o*.62),this.add(d)),m.moveTo([w+m.width/2,x+p+b/2]),this.body=m,this.add(m);let k=i==="right"?[w-8,x+y/2]:i==="left"?[w+f+8,x+y/2]:i==="bottom"?[w+f/2,x-8]:[w+f/2,x+y+8],M=c[0]!==0?[h[0]+c[0]*a*.45,k[1]]:[k[0],h[1]+c[1]*a*.45];this.leader=new N(Z([h,M,k])).stroke(s,1.25),this.marker=gt(3,s).at(h),this.add(this.leader,this.marker)}enter(t={}){return{label:"callout.enter",duration:t.duration??.9,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=e.t1-e.t0;D(this.marker,"opacity",0,e.t0),this.marker.tween("opacity",1,e.t0,e.t0+r*.2,e.ease),D(this.leader,"trimTo",0,e.t0),this.leader.tween("trimTo",1,e.t0,e.t0+r*.55,e.ease);for(let o of this.children){if(o===this.marker||o===this.leader)continue;let s=o.get("opacity");D(o,"opacity",0,e.t0),o.tween("opacity",s,e.t0+r*.42,e.t1,e.ease)}}}}};function uh(n,t,e={}){return new Or(n,t,e)}function Ge(n){return Array.isArray(n)?[...n]:[n]}function fs(n){return Ge(n).flatMap(t=>t.leaves().filter(e=>e.get("path")))}function xh(n,t={}){let e=fs(n);return{label:"typewriter",duration:t.duration??Math.max(.5,e.length*.035),ease:t.ease??Fe,schedule(r){for(let a of Ge(n))it(a,r.t0,r.stage);let o=fs(n);if(o.length===0)return;let s=r.t1-r.t0,i=null;if(t.cursor){let l=o[0].bounds().height*1.35||24;i=new N(K(0,-l/2,Math.max(3,l*.1),l)).fill(t.cursorColor??"ink"),r.stage.add(i)}o.forEach((a,l)=>{let c=r.t0+s*r.ease(l/o.length),u=a.get("opacity");if(D(a,"opacity",0,r.t0),D(a,"opacity",u,c),i){S.now=c;let h=a.bounds();D(i,"x",h.x+h.width+3,c),D(i,"y",h.y+h.height/2,c),S.now=r.t0}}),i&&D(i,"visible",!1,r.t1)}}}function kh(n,t={}){return{label:"wipe",duration:t.duration??1.2,ease:t.ease??dt,schedule(e){let r=t.from??"left";for(let p of Ge(n))it(p,e.t0,e.stage);let o=Ge(n).flatMap(p=>p.leaves()),s=p=>{let f=p.bounds(),b=f.x+f.width/2,y=f.y+f.height/2;return r==="left"?b:r==="right"?-b:r==="top"?y:-y},i=o.map(s),a=Math.min(...i),l=Math.max(...i),c=t.soft??.25,u=t.travel??0,h=e.t1-e.t0,d=r==="left"?-u:r==="right"?u:0,m=r==="top"?-u:r==="bottom"?u:0;o.forEach((p,f)=>{let b=l>a?(i[f]-a)/(l-a):0,y=e.t0+h*(1-c)*e.ease(b),g=y+h*c,w=p.get("opacity");if(D(p,"opacity",0,e.t0),p.tween("opacity",w,y,g,dt),u){let x=p.get("x"),k=p.get("y");D(p,"x",x+d,e.t0),D(p,"y",k+m,e.t0),p.tween("x",x,y,g,dt),p.tween("y",k,y,g,dt)}})}}}var je=class extends N{value;constructor(t=0,e={}){super(),this.value=new pt(t);let r=e.digits??0,o=new Intl.NumberFormat("en-US",{minimumFractionDigits:r,maximumFractionDigits:r,useGrouping:e.grouped??!0}),s=At(()=>{let i=`${e.prefix??""}${o.format(this.value.value)}${e.suffix??""}`;return H(i,{size:e.size??48,color:e.color??"ink",font:e.font??"mono",weight:e.weight??400})});this.add(s)}};function Mh(n=0,t={}){return new je(n,t)}function vh(n,t,e={}){let r=n instanceof je?n.value:n;return{label:"countUp",duration:e.duration??1.2,ease:e.ease,schedule(o){n instanceof je&&it(n,o.t0,o.stage),wt(r,t,o.t0,o.t1,o.ease)}}}function Nh(n,t,e={}){return{label:"spin",duration:e.duration??2,ease:e.ease??Fe,schedule(r){it(n,r.t0,r.stage),S.now=r.t0,n.pivotAt(e.about??n.center);let o=n.get("rotation"),s=r.t1-r.t0;n.tween("rotation",o+t*s,r.t0,r.t1,r.ease)}}}function Ph(n,t,e={}){return{label:"swap",duration:e.duration??.9,ease:e.ease,schedule(r){it(n,r.t0,r.stage),it(t,r.t0,r.stage),S.now=r.t0;let o=n.center,s=t.center,i=e.lift??Math.max(60,Math.hypot(s[0]-o[0],s[1]-o[1])*.3),a=(l,c,u,h)=>{let d=l.parent?Wt(l.parent.worldMatrix()):[1,0,0,1,0,0],m=l.get("x"),p=l.get("y"),[f,b]=Q(d,c[0],c[1]),[y,g]=Q(d,u[0],u[1]),w=m+y-f,x=p+g-b;l.track("x").add({t0:r.t0,t1:r.t1,ease:r.ease,to:w,at:k=>m+(w-m)*k}),l.track("y").add({t0:r.t0,t1:r.t1,ease:r.ease,to:x,at:k=>p+(x-p)*k-h*i*4*k*(1-k)})};a(n,o,s,1),a(t,s,o,-1)}}}function Ah(n,t={}){let e=new N([]),r=Ge(n);return{mark:e,label:"highlightSweep",duration:t.duration??.7,ease:t.ease,schedule(o){let s=1/0,i=1/0,a=-1/0,l=-1/0;for(let M of r){let v=M.bounds();s=Math.min(s,v.x),i=Math.min(i,v.y),a=Math.max(a,v.x+v.width),l=Math.max(l,v.y+v.height)}let c=t.pad??6,u=s-c,h=i-c,d=a-s+c*2,m=l-i+c*2,p=t.radius??3,f=t.color??"yellow";e.base.fill=X(f),e.base.fillOpacity=t.opacity??.26;let b=o.stage.root;b.add(e);let g=r[0];for(;g.parent&&g.parent!==b;)g=g.parent;let w=b.children.indexOf(g);b.children.splice(b.children.indexOf(e),1),b.children.splice(w>=0?w:b.children.length,0,e);let x=t.from==="right",k=M=>{let v=Math.max(.01,d*M);return K(x?u+d-v:u,h,v,m,p)};e.track("path").step(o.t0,k(0)),e.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:k(1),at:k})}}}function bs(n){return n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&#(\d+);/g,(t,e)=>String.fromCodePoint(Number(e))).replace(/&#x([\da-fA-F]+);/g,(t,e)=>String.fromCodePoint(parseInt(e,16))).replace(/&amp;/g,"&")}function ua(n){let t={name:"#root",attrs:{},children:[],text:""},e=[t],r=/<!--[\s\S]*?-->|<!\[CDATA\[([\s\S]*?)\]\]>|<\?[\s\S]*?\?>|<!DOCTYPE[^>]*>|<\/([\w:.-]+)\s*>|<([\w:.-]+)((?:\s+[\w:.-]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>|([^<]+)/g;for(let o=r.exec(n);o;o=r.exec(n)){let s=e[e.length-1],[,i,a,l,c,u,h]=o;if(i!==void 0)s.text+=i;else if(a)e.length>1&&e.pop();else if(l){let d={name:l.replace(/^.*:/,""),attrs:{},children:[],text:""};for(let m of(c??"").matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))d.attrs[m[1]]=bs(m[2]??m[3]??"");s.children.push(d),u||e.push(d)}else h&&(s.text+=bs(h))}return t}function ha(n){if(!n)return zt;let t=zt;for(let e of n.matchAll(/(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/g)){let r=e[2].trim().split(/[\s,]+/).filter(Boolean).map(Number),o=e[1];if(o==="matrix"&&r.length===6)t=rt(t,r);else if(o==="translate")t=rt(t,[1,0,0,1,r[0]??0,r[1]??0]);else if(o==="scale")t=rt(t,[r[0]??1,0,0,r[1]??r[0]??1,0,0]);else if(o==="rotate"){let s=(r[0]??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),l=r[1]??0,c=r[2]??0;t=rt(t,[1,0,0,1,l,c]),t=rt(t,[i,a,-a,i,0,0]),t=rt(t,[1,0,0,1,-l,-c])}else o==="skewX"?t=rt(t,[1,0,Math.tan((r[0]??0)*Math.PI/180),1,0,0]):o==="skewY"&&(t=rt(t,[1,Math.tan((r[0]??0)*Math.PI/180),0,1,0,0]))}return t}var da=new Set(["defs","clipPath","mask","pattern","filter","symbol","marker","linearGradient","radialGradient","title","desc","metadata","style","script"]),wn=class extends N{byId=new Map;pictureWidth=0;pictureHeight=0;find(t){let e=this.byId.get(t);if(!e)throw new Error(`The SVG has no element with id ${JSON.stringify(t)}.`);return e}};function ma(n){let t=new Map,e=r=>{if(r.name==="style")for(let o of r.text.matchAll(/([^{}]+)\{([^{}]*)\}/g)){let s=Cr(o[2]);for(let i of o[1].split(",")){let a=i.trim();t.set(a,{...t.get(a),...s})}}r.children.forEach(e)};return e(n),t}function Cr(n){let t={};if(!n)return t;for(let e of n.split(";")){let r=e.indexOf(":");r>0&&(t[e.slice(0,r).trim()]=e.slice(r+1).trim())}return t}function yn(n){if(!n||n==="none"||n==="transparent")return null;try{return Gt(n)}catch{return null}}function pa(n){let t=n.map(s=>{let i=bt([s]);return{ring:s,b:i,area:i.width*i.height,owner:-1}}),e=t.map((s,i)=>i).sort((s,i)=>t[i].area-t[s].area);for(let s=0;s<e.length;s++){let i=t[e[s]];for(let a=s-1;a>=0;a--){let l=t[e[a]];if(l.owner!==-1)continue;if(i.b.x>=l.b.x-.01&&i.b.y>=l.b.y-.01&&i.b.x+i.b.width<=l.b.x+l.b.width+.01&&i.b.y+i.b.height<=l.b.y+l.b.height+.01){i.owner=e[a];break}}}let r=[],o=new Map;return t.forEach((s,i)=>{if(s.owner!==-1)return;let a={x:s.b.x,rings:[s.ring]};o.set(i,a),r.push(a)}),t.forEach(s=>{s.owner!==-1&&o.get(s.owner)?.rings.push(s.ring)}),r.sort((s,i)=>s.x-i.x).map(s=>s.rings)}function fa(n,t={}){let r=ua(n).children.find(C=>C.name==="svg");if(!r)throw new Error("fromSvg needs markup with an <svg> element.");let o=ma(r),s=new Map,i=C=>{C.attrs.id&&s.set(C.attrs.id,C),C.children.forEach(i)};i(r);let a=(r.attrs.viewBox??"").trim().split(/[\s,]+/).map(Number),l=parseFloat(r.attrs.width??""),c=parseFloat(r.attrs.height??""),u=a.length===4&&a[2]?a[2]:l||300,h=a.length===4&&a[3]?a[3]:c||150,d=a.length===4?a[0]:0,m=a.length===4?a[1]:0,p=Number.isFinite(l)&&l>0?l:u,f=Number.isFinite(c)&&c>0?c:h,b=1;if(t.width!==void 0||t.height!==void 0){let C=t.width!==void 0?t.width/u:1/0,L=t.height!==void 0?t.height/h:1/0;b=Math.min(C,L)}else b=Math.min(p/u,f/h);let y=t.center??!0,g=y?-(d+u/2)*b:-d*b,w=y?-(m+h/2)*b:-m*b,x=[b,0,0,b,g,w],k=new wn;k.pictureWidth=u*b,k.pictureHeight=h*b;let M=t.splitGlyphs??!0,v=t.background??!1,P=!0,A=(C,L,I)=>{let F=s.get(C);if(!F)return null;if(F.name==="pattern"){let E=F.children.find(j=>j.name==="linearGradient");if(E)return R(E,L,I,!0);let V=F.children.find(j=>j.attrs.fill?.startsWith("url(#"))?.attrs.fill?.match(/url\(#([^)]+)\)/)?.[1];return V?A(V,L,I):null}if(F.name==="linearGradient")return R(F,L,I,F.attrs.gradientUnits!=="userSpaceOnUse");if(F.name==="radialGradient"){let E=O(F);return E.length?E[E.length-1][1]:null}return null},O=C=>{let L=C.attrs.href??C.attrs["xlink:href"];return(C.children.some(F=>F.name==="stop")||!L?C:s.get(L.replace(/^#/,""))??C).children.filter(F=>F.name==="stop").map(F=>{let E=Cr(F.attrs.style),T=F.attrs.offset??"0",V=T.endsWith("%")?parseFloat(T)/100:parseFloat(T),j=yn(E["stop-color"]??F.attrs["stop-color"]??"#000000")??[0,0,0,1],J=parseFloat(E["stop-opacity"]??F.attrs["stop-opacity"]??"1");return[V,[j[0],j[1],j[2],j[3]*J]]})},R=(C,L,I,F)=>{let E=O(C);if(E.length===0)return null;let T=(_,ct)=>_===void 0?ct:_.endsWith("%")?parseFloat(_)/100:parseFloat(_),V=T(C.attrs.x1,0),j=T(C.attrs.y1,0),J=T(C.attrs.x2,1),at=T(C.attrs.y2,0),tt,ut;if(F){let _=bt(I)??{x:0,y:0,width:1,height:1};tt=[_.x+V*_.width,_.y+j*_.height],ut=[_.x+J*_.width,_.y+at*_.height]}else tt=Q(L,V,j),ut=Q(L,J,at);return{type:"linear",from:tt,to:ut,stops:E}},$=C=>{let L=C.attrs,I=(F,E=0)=>{let T=parseFloat(L[F]??"");return Number.isFinite(T)?T:E};switch(C.name){case"path":return L.d?vt(L.d):null;case"rect":{let F=I("width"),E=I("height");return F<=0||E<=0?null:K(I("x"),I("y"),F,E,I("rx",I("ry")))}case"circle":return I("r")>0?St(I("cx"),I("cy"),I("r"),I("r"),0,Math.PI*2):null;case"ellipse":return I("rx")>0&&I("ry")>0?St(I("cx"),I("cy"),I("rx"),I("ry"),0,Math.PI*2):null;case"line":return Z([[I("x1"),I("y1")],[I("x2"),I("y2")]]);case"polyline":case"polygon":{let F=(L.points??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),E=[];for(let T=0;T+1<F.length;T+=2)E.push([F[T],F[T+1]]);return E.length>=2?Z(E,C.name==="polygon"):null}default:return null}},z=(C,L)=>{let I=C.attrs,F=(I.class??"").split(/\s+/).filter(Boolean),E={...o.get(C.name)};for(let q of F)Object.assign(E,o.get(`.${q}`));I.id&&Object.assign(E,o.get(`#${I.id}`));let T=q=>Cr(I.style)[q]??I[q]??E[q],V={...L},j=T("color");j&&(V.color=j);let J=T("fill");J&&(V.fill=J==="currentColor"?V.color:J);let at=T("stroke");at&&(V.stroke=at==="currentColor"?V.color:at);let tt=T("stroke-width");tt!==void 0&&(V.strokeWidth=parseFloat(tt)||0);let ut=T("fill-opacity");ut!==void 0&&(V.fillOpacity=parseFloat(ut));let _=T("stroke-opacity");_!==void 0&&(V.strokeOpacity=parseFloat(_));let ct=T("stroke-linecap");(ct==="round"||ct==="butt"||ct==="square")&&(V.cap=ct);let mt=T("stroke-linejoin");(mt==="round"||mt==="miter"||mt==="bevel")&&(V.join=mt);let nt=T("stroke-dasharray");nt!==void 0&&(V.dash=nt==="none"?null:nt.trim().split(/[\s,]+/).map(Number));let ht=T("stroke-dashoffset");ht!==void 0&&(V.dashOffset=parseFloat(ht)||0);let xt=T("font-size");xt!==void 0&&(V.fontSize=parseFloat(xt)||V.fontSize);let kt=T("text-anchor");return kt&&(V.anchor=kt),{style:V,opacity:parseFloat(T("opacity")??"1")}},B=(C,L,I,F)=>{let E=ot(C,L),T=Xt(L),V=nt=>nt?.match(/^url\(#([^)]+)\)/)?.[1],j=V(F.fill),J=V(F.stroke),at=j?A(j,L,E):yn(F.fill),tt=J?A(J,L,E):yn(F.stroke),ut=at&&F.fillOpacity>0&&!(Array.isArray(at)&&at[3]===0),_=tt&&F.strokeOpacity>0&&F.strokeWidth>0&&!(Array.isArray(tt)&&tt[3]===0);if(!ut&&!_)return[];let ct=I.attrs["clip-path"]?.5:1;return(M&&ut&&!_&&E.length>1?pa(E):[E]).map(nt=>{let ht=bt(nt)??{x:0,y:0,width:0,height:0},xt=ht.x+ht.width/2,kt=ht.y+ht.height/2,q=new N(ot(nt,[1,0,0,1,-xt,-kt])).at(xt,kt);return ut&&(q.base.fill=gs(at,-xt,-kt),q.base.fillOpacity=F.fillOpacity),_&&(q.base.stroke=gs(tt,-xt,-kt),q.base.strokeWidth=F.strokeWidth*T*ct,q.base.strokeOpacity=F.strokeOpacity,q.base.cap=F.cap,q.base.join=F.join,F.dash&&(q.base.dash=F.dash.map(ie=>ie*T)),q.base.dashOffset=F.dashOffset*T),q.base.trimEach=!0,q})},W=(C,L,I,F)=>{if(da.has(C.name)||C.attrs.filter)return;let{style:E,opacity:T}=z(C,I),V=rt(F,ha(C.attrs.transform)),j=_=>{C.attrs.id&&k.byId.set(C.attrs.id,_)};if(C.name==="g"||C.name==="svg"||C.name==="a"){let _=new N;T<1&&(_.base.opacity=T),j(_),L.add(_);for(let ct of C.children)W(ct,_,E,V);return}if(C.name==="use"){let _=(C.attrs.href??C.attrs["xlink:href"]??"").replace(/^#/,""),ct=s.get(_);if(!ct)return;let mt=rt(V,[1,0,0,1,parseFloat(C.attrs.x??"0")||0,parseFloat(C.attrs.y??"0")||0]),nt=new N;if(T<1&&(nt.base.opacity=T),L.add(nt),ct.name==="symbol")for(let ht of ct.children)W(ht,nt,E,mt);else W(ct,nt,E,mt);return}if(C.name==="image"){let _=C.attrs.href??C.attrs["xlink:href"];if(!_)return;let ct=parseFloat(C.attrs.width??"0"),mt=parseFloat(C.attrs.height??"0"),[nt,ht]=Q(V,parseFloat(C.attrs.x??"0")||0,parseFloat(C.attrs.y??"0")||0),xt=Xt(V),kt={src:_,width:ct,height:mt},q=new N().at(nt,ht);q.base.image=kt,q.base.sx=xt,q.base.sy=xt,T<1&&(q.base.opacity=T),j(q),L.add(q);return}if(C.name==="text"){let _=(C.text+C.children.map(q=>q.text).join("")).trim();if(!_)return;let ct=yn(E.fill)??[0,0,0,1],mt=E.fontSize*Xt(V),nt=H(_,{size:mt,color:ct}),[ht,xt]=Q(V,parseFloat(C.attrs.x??"0")||0,parseFloat(C.attrs.y??"0")||0),kt=nt.get("px");nt.at(E.anchor==="middle"?ht:E.anchor==="end"?ht-kt:ht+kt,xt-mt*.34),T<1&&(nt.base.opacity=T),j(nt),L.add(nt);return}let J=$(C);if(!J||J.length===0)return;let at=P&&C.name==="rect"&&!v&&parseFloat(C.attrs.width??"0")>=u-.5&&parseFloat(C.attrs.height??"0")>=h-.5;if(P=!1,at)return;let tt=B(J,V,C,E);if(tt.length===0)return;if(tt.length===1){T<1&&(tt[0].base.opacity=T),j(tt[0]),L.add(tt[0]);return}let ut=new N;T<1&&(ut.base.opacity=T),ut.add(...tt),j(ut),L.add(ut)},G={fill:"#000000",stroke:null,strokeWidth:1,fillOpacity:1,strokeOpacity:1,cap:"butt",join:"miter",dash:null,dashOffset:0,color:"#000000",fontSize:16,anchor:"start"},{style:U}=z(r,G);for(let C of r.children)W(C,k,U,x);return k}function gs(n,t,e){if(Array.isArray(n))return n;let r=n;return r.type==="linear"?{...r,from:[r.from[0]+t,r.from[1]+e],to:[r.to[0]+t,r.to[1]+e]}:r.type==="radial"?{...r,center:[r.center[0]+t,r.center[1]+e]}:r}var ys=n=>n.toLowerCase().replace(/[^a-z0-9.]+/g," ").split(" ").map(t=>t.replace(/^\.+|\.+$/g,"")).filter(Boolean);function ws(n,t=74){let e=[];for(let r of n.match(/[^.?!]+(?:[.?!]+(?=\s|$)|\.\d[^.?!]*[.?!]?|$)/g)??[]){let o="";for(let s of r.split(/\s+/).filter(Boolean))o&&o.length+s.length+1>t?(e.push(o),o=s):o=o?`${o} ${s}`:s;o&&e.push(o)}return e}var xn=class{constructor(t,e,r,o,s){this.stage=t;this.id=e;this.start=r;this.end=o;this.beats=s}stage;id;start;end;beats;cue(t,e){let r=ys(t);if(r.length===0)throw new Error(`narration: scene "${this.id}": a cue needs at least one word`);if(e!==void 0&&!this.beats[e])throw new Error(`narration: scene "${this.id}" has no beat ${e}`);let o=e===void 0?this.beats:[this.beats[e]];for(let i of o){let a=i.words.flatMap(l=>ys(l.text).map(c=>({token:c,start:l.start,end:l.end})));for(let l=0;l+r.length<=a.length;l++)if(r.every((c,u)=>a[l+u].token===c))return{start:i.start+a[l].start,end:i.start+a[l+r.length-1].end}}let s=e===void 0?"":` in beat ${e}`;throw new Error(`narration: scene "${this.id}": the voice never says "${t}"${s}`)}on(t,e,r=0,o){return this.stage.at(Math.max(0,this.cue(t,o).start+r),e),this}after(t,e,r=0,o){return this.stage.at(Math.max(0,this.cue(t,o).end+r),e),this}onBeat(t,e,r=0){let o=this.beats[t];if(!o)throw new Error(`narration: scene "${this.id}" has no beat ${t}`);return this.stage.at(Math.max(0,o.start+r),e),this}at(t,e){return this.stage.at(Math.max(0,this.start+t),e),this}clear(t,e=.24,r=.26){return this.stage.at(this.end-e,()=>this.stage.play(...t.map(o=>po(o,0,{duration:r})))),this}},kn=class{scenes;duration;lead;gap;constructor(t,e,r={}){if(this.lead=r.lead??e.lead??.6,this.gap=r.gap??e.gap??.4,!(this.lead>=0)||!(this.gap>=0))throw new Error("narration: lead and gap must be zero or more seconds");let o=new Set,s=[],i=this.lead,a=i;for(let l of e.scenes){if(o.has(l.id))throw new Error(`narration: two scenes are named "${l.id}"`);o.add(l.id);let c=i,u=[];for(let h of l.beats){if(!(h.duration>0))throw new Error(`narration: scene "${l.id}" has a beat without a measured duration: "${h.say}"`);let d=h.hold??0;u.push({start:i,end:i+h.duration,until:i+h.duration+d,text:h.say,words:h.words??[]}),i+=h.duration+d}if(s.push(new xn(t,l.id,c,i,u)),r.chapters!==!1&&l.title&&t.chapters.push({title:l.title,time:s.length===1?0:c}),r.captions!==!1)for(let h of u){let d=ws(h.text,r.captionLength),m=d.reduce((f,b)=>f+b.length,0),p=h.start;for(let f of d){let b=p+(h.end-h.start)*f.length/m;t.captions.push({t0:p,t1:b,text:f}),p=b}}a=i,i+=this.gap}this.scenes=s,this.duration=a,t.at(a,()=>{})}scene(t){let e=this.scenes.find(r=>r.id===t);if(!e)throw new Error(`narration: no scene "${t}". The scenes are: ${this.scenes.map(r=>r.id).join(", ")}`);return e}placements(){return this.scenes.flatMap(t=>t.beats.map((e,r)=>({scene:t.id,beat:r,start:e.start,end:e.end})))}};function ba(n,t,e={}){return new kn(n,t,e)}var oe=n=>typeof n=="function"?n():n,xs=n=>{let t=Math.hypot(n[0],n[1],n[2])||1;return[n[0]/t,n[1]/t,n[2]/t]},Sr=class{ops=[];depths=[];rx=0;ry=0;ux=0;uy=0;uz=0;dx=0;dy=0;dz=0;fx=0;fy=0;fz=0;distance=12;unit=100;perspective=!0;matrix=[1,0,0,1,0,0];alpha=1;scale=1;light=[0,0,1];half=[0,0,1];ambient=.4;shine=.2;fog=0;fogColor=[0,0,0,1];depthRange=1;brightness=1;px=0;py=0;pz=0;ps=1;project(t,e,r){let o=t-this.fx,s=e-this.fy,i=r-this.fz,a=o*this.rx+s*this.ry,l=o*this.ux+s*this.uy+i*this.uz,c=o*this.dx+s*this.dy+i*this.dz,u=1;if(this.perspective){let p=this.distance-c;if(p<=.05)return!1;u=this.distance/p}let h=a*this.unit*u,d=-l*this.unit*u,m=this.matrix;return this.px=m[0]*h+m[2]*d+m[4],this.py=m[1]*h+m[3]*d+m[5],this.pz=c,this.ps=u,!0}screen(t,e,r){let o=t-this.fx,s=e-this.fy,i=r-this.fz,a=o*this.rx+s*this.ry,l=o*this.ux+s*this.uy+i*this.uz,c=o*this.dx+s*this.dy+i*this.dz,u=1;if(this.perspective){let h=this.distance-c;if(h<=.05)return null;u=this.distance/h}return[a*this.unit*u,-l*this.unit*u]}fogged(t,e,r,o){if(this.fog<=0)return[t,e,r,1];let s=Math.max(0,Math.min(1,-o/this.depthRange*this.fog));return[t+(this.fogColor[0]-t)*s,e+(this.fogColor[1]-e)*s,r+(this.fogColor[2]-r)*s,1]}push(t,e){this.ops.push(t),this.depths.push(e)}};function Me(n,t,e,r,o=0,s="round"){return{kind:"path",path:n,strokePath:n,fill:null,fillAlpha:0,stroke:t,strokeAlpha:e,strokeWidth:r,cap:s,join:"round",dash:null,dashOffset:0,glow:o,glowColor:null,blend:"normal"}}function ve(n,t,e,r,o,s){return{kind:"path",path:n,strokePath:n,fill:t,fillAlpha:e,stroke:r,strokeAlpha:o,strokeWidth:s,cap:"round",join:"round",dash:null,dashOffset:0,glow:0,glowColor:null,blend:"normal"}}function Mn(n,t,e,r){let o=e-n,s=r-t,i=new Float64Array(8);return i[0]=n,i[1]=t,i[2]=n+o/3,i[3]=t+s/3,i[4]=n+o*2/3,i[5]=t+s*2/3,i[6]=e,i[7]=r,{p:i,closed:!1,straight:!0}}function Lr(n){let t=n.length/2,e=new Float64Array(2+t*6);e[0]=n[0],e[1]=n[1];let r=2;for(let o=0;o<t;o++){let s=n[o*2],i=n[o*2+1],a=n[(o+1)%t*2],l=n[(o+1)%t*2+1];e[r++]=s+(a-s)/3,e[r++]=i+(l-i)/3,e[r++]=s+(a-s)*2/3,e[r++]=i+(l-i)*2/3,e[r++]=a,e[r++]=l}return{p:e,closed:!0,straight:!0}}var ga=.5522847498307936;function ks(n,t,e){let r=e*ga;return{closed:!0,p:Float64Array.of(n+e,t,n+e,t+r,n+r,t+e,n,t+e,n-r,t+e,n-e,t+r,n-e,t,n-e,t-r,n-r,t-e,n,t-e,n+r,t-e,n+e,t-r,n+e,t)}}var Et=class extends N{constructor(){super([])}labelsNow(t){return[]}objectAlpha(t){return t.alpha*this.get("opacity")}},Rr=class extends N{phi;theta;distance;unit;focusX;focusY;focusZ;orthographic;settings;spins=[];openSpin=null;constructor(t={}){super(),this.settings=t,this.phi=new pt(t.phi??1.15),this.theta=new pt(t.theta??-1),this.distance=new pt(t.distance??14),this.unit=new pt(t.unit??120),this.focusX=new pt(t.focus?.[0]??0),this.focusY=new pt(t.focus?.[1]??0),this.focusZ=new pt(t.focus?.[2]??0),this.orthographic=t.perspective===!1,this.rawOps=(e,r,o)=>this.render(e,r,o),this.draw=e=>{let r=this.view(this.worldless,1,e);return this.children.flatMap(o=>o instanceof Et&&o.get("visible")?o.labelsNow(r):[])}}worldless=[1,0,0,1,0,0];view(t,e,r){let o=new Sr,s=this.phi.value,i=this.theta.value;for(let m of this.spins)r>m.from&&(i+=(Math.min(r,m.to)-m.from)*m.rate);let a=Math.sin(s),l=Math.cos(s),c=Math.sin(i),u=Math.cos(i);o.rx=-c,o.ry=u,o.ux=-l*u,o.uy=-l*c,o.uz=a,o.dx=a*u,o.dy=a*c,o.dz=l,o.fx=this.focusX.value,o.fy=this.focusY.value,o.fz=this.focusZ.value,o.distance=this.distance.value,o.unit=this.unit.value,o.perspective=!this.orthographic,o.matrix=t,o.alpha=e,o.scale=Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]));let h=xs(this.settings.light??[-.45,-.55,.85]);o.light=h,o.half=xs([h[0]+o.dx,h[1]+o.dy,h[2]+o.dz]),o.ambient=this.settings.ambient??.26,o.shine=this.settings.shine??.2,o.fog=this.settings.fog??.6;let d=Gt("bg");return o.fogColor=this.settings.fogColor?Ft(this.settings.fogColor):d,o.depthRange=Math.max(3,o.distance*.5),o.brightness=this.settings.brightness??(d[0]+d[1]+d[2]<200?.8:1),o}render(t,e,r){let o=S.now,s=this.view(t,e,o);for(let c of this.children)c instanceof Et&&c.get("visible")&&c.emit(s,o);let i=s.ops.length,a=new Uint32Array(i);for(let c=0;c<i;c++)a[c]=c;let l=s.depths;a.sort((c,u)=>l[c]-l[u]);for(let c=0;c<i;c++)r.push(s.ops[a[c]])}orbit(t,e={}){return{label:"camera3d",duration:e.duration??2,ease:e.ease,schedule:r=>{t.phi!==void 0&&wt(this.phi,t.phi,r.t0,r.t1,r.ease),t.theta!==void 0&&wt(this.theta,t.theta,r.t0,r.t1,r.ease),t.distance!==void 0&&wt(this.distance,t.distance,r.t0,r.t1,r.ease),t.unit!==void 0&&wt(this.unit,t.unit,r.t0,r.t1,r.ease),t.focus&&(wt(this.focusX,t.focus[0],r.t0,r.t1,r.ease),wt(this.focusY,t.focus[1],r.t0,r.t1,r.ease),wt(this.focusZ,t.focus[2],r.t0,r.t1,r.ease))}}}spin(t=.12){return this.stopSpin(),this.openSpin={from:S.now,to:1/0,rate:t},this.spins.push(this.openSpin),this}stopSpin(){return this.openSpin&&(this.openSpin.to=S.now),this.openSpin=null,this}stagePoint(t){let e=this.view(this.worldMatrix(),1,S.now);return e.project(t[0],t[1],t[2])?[e.px,e.py]:[0,0]}};function Gh(n={}){return new Rr(n)}var _e=class extends Et{constructor(e,r,o,s={}){super();this.fn=e;this.uRange=r;this.vRange=o;this.options=s;let i=s.resolution??40;this.nu=typeof i=="number"?i:i[0],this.nv=typeof i=="number"?i:i[1];let a=(this.nu+1)*(this.nv+1);if(this.positions=new Float64Array(a*3),this.normals=new Float64Array(this.nu*this.nv*3),this.vertexNormals=new Float64Array(a*3),this.shadingNormals=new Float64Array(this.nu*this.nv*3),this.faceColors=new Float32Array(this.nu*this.nv*3),this.screenX=new Float64Array(a),this.screenY=new Float64Array(a),this.screenZ=new Float64Array(a),this.valid=new Uint8Array(a),this.meshColor=s.mesh?Ft(s.mesh):null,s.colors){let l=s.colors.map(c=>Ft(c));this.ramp=l.map((c,u)=>[l.length===1?0:u/(l.length-1),c])}s.checker&&(this.checkerColors=[Ft(s.checker[0]),Ft(s.checker[1])]),(s.color||!s.colors&&!s.checker&&!s.colorAt)&&(this.base.fill=X(s.color??"blue"))}fn;uRange;vRange;options;nu;nv;positions;normals;vertexNormals;shadingNormals;faceColors;computedFor=-1/0;screenX;screenY;screenZ;valid;meshColor;ramp=null;checkerColors=null;compute(e){let{nu:r,nv:o,positions:s,normals:i,faceColors:a,fn:l,uRange:c,vRange:u,options:h}=this,d=0,m=1/0,p=-1/0;for(let g=0;g<=r;g++){let w=c[0]+(c[1]-c[0])*g/r;for(let x=0;x<=o;x++){let k=u[0]+(u[1]-u[0])*x/o,M=l(w,k,e);s[d++]=M[0],s[d++]=M[1],s[d++]=M[2],M[2]<m&&(m=M[2]),M[2]>p&&(p=M[2])}}let f=o+1,b=this.vertexNormals;b.fill(0);for(let g=0;g<r;g++)for(let w=0;w<o;w++){let x=(g*f+w)*3,k=((g+1)*f+w)*3,M=((g+1)*f+w+1)*3,v=(g*f+w+1)*3,P=s[M]-s[x],A=s[M+1]-s[x+1],O=s[M+2]-s[x+2],R=s[v]-s[k],$=s[v+1]-s[k+1],z=s[v+2]-s[k+2],B=A*z-O*$,W=O*R-P*z,G=P*$-A*R,U=Math.hypot(B,W,G)||1;if(B/=U,W/=U,G/=U,h.outwardFrom){let[L,I,F]=h.outwardFrom,E=(s[x]+s[M])/2-L,T=(s[x+1]+s[M+1])/2-I,V=(s[x+2]+s[M+2])/2-F;B*E+W*T+G*V<0&&(B=-B,W=-W,G=-G)}let C=(g*o+w)*3;i[C]=B,i[C+1]=W,i[C+2]=G;for(let L of[x/3,k/3,M/3,v/3])b[L*3]+=B,b[L*3+1]+=W,b[L*3+2]+=G;if(this.ramp||this.checkerColors||h.colorAt){let L;if(h.colorAt){let I=(s[x]+s[M])/2,F=(s[x+1]+s[M+1])/2,E=(s[x+2]+s[M+2])/2;L=h.colorAt(I,F,E,(g+.5)/r,(w+.5)/o)}else if(this.checkerColors)L=this.checkerColors[(g+w)%2];else{let I=(s[x+2]+s[M+2]+s[k+2]+s[v+2])/4;L=lt(this.ramp,p>m?(I-m)/(p-m):0)}a[C]=L[0],a[C+1]=L[1],a[C+2]=L[2]}}let y=this.shadingNormals;for(let g=0;g<r;g++)for(let w=0;w<o;w++){let x=(g*f+w)*3,k=((g+1)*f+w)*3,M=((g+1)*f+w+1)*3,v=(g*f+w+1)*3,P=0,A=0,O=0;for(let z of[x,k,M,v])P+=b[z],A+=b[z+1],O+=b[z+2];let R=Math.hypot(P,A,O)||1,$=(g*o+w)*3;y[$]=P/R,y[$+1]=A/R,y[$+2]=O/R}}emit(e,r){let{options:o,nu:s,nv:i,normals:a,shadingNormals:l,faceColors:c,screenX:u,screenY:h,screenZ:d,valid:m}=this,p=this.objectAlpha(e)*(o.opacity??1)*this.get("fillOpacity");if(p<=.002)return;(o.animate?this.computedFor!==r:this.computedFor===-1/0)&&(this.compute(o.animate?r:0),this.computedFor=r);let f=this.positions,b=i+1,y=(s+1)*(i+1);for(let I=0;I<y;I++){let F=I*3;e.project(f[F],f[F+1],f[F+2])?(u[I]=e.px,h[I]=e.py,d[I]=e.pz,m[I]=1):m[I]=0}let g=this.ramp||this.checkerColors||o.colorAt?null:se(this.get("fill")),w=o.shaded??!0,x=p>=.995,k=this.get("trimTo"),M=Math.ceil(k*s),{light:v,half:P,ambient:A,shine:O,brightness:R,dx:$,dy:z,dz:B}=e,W=o.cull??!1,G=this.meshColor,U=(o.meshOpacity??.35)*p,C=(o.meshWidth??1)*e.scale,L=.55*e.scale;for(let I=0;I<M;I++)for(let F=0;F<i;F++){let E=I*b+F,T=(I+1)*b+F,V=(I+1)*b+F+1,j=I*b+F+1;if(!m[E]||!m[T]||!m[V]||!m[j])continue;let J=(I*i+F)*3,at=a[J]*$+a[J+1]*z+a[J+2]*B;if(at<0&&W)continue;let tt=at<0?-1:1,ut=l[J]*tt,_=l[J+1]*tt,ct=l[J+2]*tt,mt,nt,ht;if(g?(mt=g[0],nt=g[1],ht=g[2]):(mt=c[J],nt=c[J+1],ht=c[J+2]),w){let Ut=.5+.5*(ut*v[0]+_*v[1]+ct*v[2]),Kt=(A+(1-A)*Ut*Ut)*R,Zt=O>0?O*Math.pow(Math.max(0,ut*P[0]+_*P[1]+ct*P[2]),42)*255:0;mt=Math.min(255,mt*Kt+Zt),nt=Math.min(255,nt*Kt+Zt),ht=Math.min(255,ht*Kt+Zt)}let xt=(d[E]+d[T]+d[V]+d[j])/4,kt=e.fogged(mt,nt,ht,xt),q=u[E],ie=h[E],Pe=u[T],Ae=h[T],Oe=u[V],Ce=h[V],Se=u[j],Re=h[j];if(x&&!G){let Ut=(q+Pe+Oe+Se)/4,Kt=(ie+Ae+Ce+Re)/4,Zt=(As,Os)=>L/(Math.hypot(As-Ut,Os-Kt)||1),Wr=Zt(q,ie),Dr=Zt(Pe,Ae),Gr=Zt(Oe,Ce),jr=Zt(Se,Re);q+=(q-Ut)*Wr,ie+=(ie-Kt)*Wr,Pe+=(Pe-Ut)*Dr,Ae+=(Ae-Kt)*Dr,Oe+=(Oe-Ut)*Gr,Ce+=(Ce-Kt)*Gr,Se+=(Se-Ut)*jr,Re+=(Re-Kt)*jr}let Br=Lr([q,ie,Pe,Ae,Oe,Ce,Se,Re]);e.push(G?ve([Br],kt,p,G,U,C):ve([Br],kt,p,null,0,0),xt)}}};function se(n){return n?Array.isArray(n)?n:Ft(n):[90,180,240,1]}function jh(n,t,e,r={}){return new _e(n,t,e,r)}function _h(n,t={}){let e=t.x??[-4,4],r=t.y??[-4,4];return new _e((o,s,i)=>[o,s,n(o,s,i)],e,r,{colors:t.color||t.checker||t.colorAt?void 0:["blue","teal","yellow"],...t})}function Hh(n=1,t={}){let[e,r,o]=t.center??[0,0,0];return new _e((s,i)=>[e+n*Math.sin(i)*Math.cos(s),r+n*Math.sin(i)*Math.sin(s),o+n*Math.cos(i)],[0,Math.PI*2],[0,Math.PI],{cull:!0,resolution:[64,40],outwardFrom:[e,r,o],...t})}var Ne=1e6,Tr=class extends Et{constructor(e,r,o,s={}){super();this.style=s;let i=s.samples??240;this.points=new Float64Array((i+1)*3);for(let a=0;a<=i;a++){let[l,c,u]=e(r+(o-r)*a/i);this.points[a*3]=l,this.points[a*3+1]=c,this.points[a*3+2]=u}if(this.base.stroke=X(s.color??"yellow"),this.base.strokeWidth=s.width??3,s.colors){let a=s.colors.map(l=>Ft(l));this.stops=a.map((l,c)=>[a.length===1?0:c/(a.length-1),l])}else this.stops=null}style;points;stops;emit(e){let r=this.objectAlpha(e)*(this.style.opacity??1)*this.get("strokeOpacity");if(r<=.002)return;let o=this.get("trimTo"),s=this.points.length/3-1,i=Math.floor(o*s);if(i<1)return;let a=Math.max(2,Math.ceil(s/72)),l=this.get("stroke")??X("yellow"),c=this.get("strokeWidth")*e.scale,u=this.style.onTop?Ne:this.style.bias??.12,h=(this.style.glow??0)*e.scale;for(let d=0;d<i;d+=a){let m=Math.min(i,d+a),p=[],f=0,b=0,y=0;for(let x=d;x<=m;x++)e.project(this.points[x*3],this.points[x*3+1],this.points[x*3+2])&&(p.push([e.px,e.py]),f+=e.pz,b+=e.ps,y++);if(y<2)continue;f/=y,b/=y;let g=this.stops?lt(this.stops,(d+m)/2/s):se(l),w=e.fogged(g[0],g[1],g[2],f);e.push(Me([Ms(p)],w,r,c*b,h,"round"),f+u)}}};function Ms(n){let t=new Float64Array(2+(n.length-1)*6);t[0]=n[0][0],t[1]=n[0][1];let e=2;for(let r=1;r<n.length;r++){let o=n[r-1],s=n[r];t[e++]=o[0]+(s[0]-o[0])/3,t[e++]=o[1]+(s[1]-o[1])/3,t[e++]=o[0]+(s[0]-o[0])*2/3,t[e++]=o[1]+(s[1]-o[1])*2/3,t[e++]=s[0],t[e++]=s[1]}return{p:t,closed:!1,straight:!0}}function Kh(n,t,e,r={}){return new Tr(n,t,e,r)}var vn=class extends Et{constructor(e,r,o={}){super();this.a=e;this.b=r;this.style=o;this.base.stroke=X(o.color??"ink"),this.base.strokeWidth=o.width??2.5}a;b;style;emit(e){let r=this.objectAlpha(e)*(this.style.opacity??1)*this.get("strokeOpacity");if(r<=.002)return;let o=oe(this.a),s=oe(this.b),i=this.style.pieces??14,a=this.get("trimTo"),l=se(this.get("stroke")),c=this.get("strokeWidth")*e.scale,u=this.style.onTop?Ne:this.style.bias??0;for(let h=0;h<i;h++){let d=h/i*a,m=(h+1)/i*a;if(!e.project(o[0]+(s[0]-o[0])*d,o[1]+(s[1]-o[1])*d,o[2]+(s[2]-o[2])*d))continue;let p=e.px,f=e.py,b=e.pz,y=e.ps;if(!e.project(o[0]+(s[0]-o[0])*m,o[1]+(s[1]-o[1])*m,o[2]+(s[2]-o[2])*m))continue;let g=(b+e.pz)/2,w=e.fogged(l[0],l[1],l[2],g);e.push(Me([Mn(p,f,e.px,e.py)],w,r,c*(y+e.ps)/2,0,"butt"),g+u)}}};function Xh(n,t,e={}){return new vn(n,t,e)}var Fr=class extends vn{from3;to3;tipSize;tipBias;constructor(t,e,r={}){super(t,()=>{let o=oe(t),s=oe(e),i=Math.hypot(s[0]-o[0],s[1]-o[1],s[2]-o[2])||1,a=Math.min(.9,.22/i);return[s[0]-(s[0]-o[0])*a,s[1]-(s[1]-o[1])*a,s[2]-(s[2]-o[2])*a]},{color:"yellow",width:4,...r}),this.from3=t,this.to3=e,this.tipSize=r.tip??24,this.tipBias=r.onTop?Ne:r.bias??0}emit(t){if(super.emit(t),this.get("trimTo")<.98)return;let r=oe(this.from3),o=oe(this.to3),s=this.objectAlpha(t);if(!t.project(r[0],r[1],r[2]))return;let i=t.px,a=t.py;if(!t.project(o[0],o[1],o[2]))return;let l=t.px,c=t.py,u=t.pz,h=t.ps,d=Math.hypot(l-i,c-a)||1,m=(l-i)/d,p=(c-a)/d,f=this.tipSize*t.scale*h,b=f*.42,y=se(this.get("stroke")),g=t.fogged(y[0],y[1],y[2],u),w=Lr([l,c,l-m*f-p*b,c-p*f+m*b,l-m*f+p*b,c-p*f-m*b]);t.push(ve([w],g,s,null,0,0),u+.01+this.tipBias)}};function Yh(n,t,e={}){return new Fr(n,t,e)}var Nn=class extends Et{constructor(e,r={}){super();this.source=e;this.style=r;this.base.fill=X(r.color??"yellow")}source;style;emit(e){let r=this.objectAlpha(e)*(this.style.opacity??1)*this.get("fillOpacity");if(r<=.002)return;let o=typeof this.source=="function"?this.source():this.source,s=(this.style.radius??8)*e.scale,i=this.get("trimTo"),a=Math.ceil(o.length*i),l=se(this.get("fill")),c=this.style.onTop?Ne:this.style.bias??0;for(let u=0;u<a;u++){let h=o[u];if(!e.project(h[0],h[1],h[2]))continue;let d=this.style.colorAt?Ft(this.style.colorAt(u,h)):l,m=e.fogged(d[0],d[1],d[2],e.pz),p=s*e.ps;this.style.halo&&e.push(ve([ks(e.px,e.py,p*(1+this.style.halo))],m,r*.18,null,0,0),e.pz+c-.001),e.push(ve([ks(e.px,e.py,p)],m,r,null,0,0),e.pz+c)}}};function qh(n,t={}){return new Nn(n,t)}function Uh(n,t={}){return new Nn(()=>[oe(n)],t)}var Ir=class extends Et{constructor(e,r,o,s={}){super();this.point=e;this.from=r;this.to=o;this.style=s;this.base.stroke=X(s.color??"yellow"),this.base.strokeWidth=s.width??3}point;from;to;style;cache=new Map;sample(e,r){let o=this.cache.get(e);if(o)return o;let s=S.now;S.now=this.from+e/r;let i=this.point();return S.now=s,S.mode==="render"&&this.cache.set(e,i),i}emit(e,r){if(r<=this.from)return;let o=this.objectAlpha(e)*(this.style.opacity??1),s=this.style.rate??30,i=Math.min(r,this.to),a=this.style.tail,l=a!==void 0?Math.max(this.from,i-a):this.from,c=Math.ceil((l-this.from)*s),u=Math.floor((i-this.from)*s);if(u-c<1)return;let h=this.get("strokeWidth")*e.scale,d=se(this.get("stroke")),m=this.style.fade??(a!==void 0?0:1),p=this.style.onTop?Ne:this.style.bias??0,f=(this.style.glow??0)*e.scale,b=[],y=null;for(let x=c;x<=u;x++){let k=this.sample(x,s);y&&Math.abs(k[0]-y[0])+Math.abs(k[1]-y[1])+Math.abs(k[2]-y[2])<1e-9||(b.push(k),y=k)}let g=b.length-1;if(g<1)return;let w=Math.max(1,Math.ceil(g/48));for(let x=0;x<g;x+=w){let k=[],M=0,v=0;for(let R=x;R<=Math.min(g,x+w);R++){let $=b[R];e.project($[0],$[1],$[2])&&(k.push([e.px,e.py]),M+=e.pz,v+=e.ps)}if(k.length<2)continue;M/=k.length,v/=k.length;let P=Math.min(1,(x+w/2)/g),A=m+(1-m)*Math.pow(P,1.6),O=e.fogged(d[0],d[1],d[2],M);e.push(Me([Ms(k)],O,o*A,h*v,f,"butt"),M+p)}}};function Zh(n,t,e,r={}){return new Ir(n,t,e,r)}var Er=class extends Et{constructor(e={}){super();this.options=e;this.ranges=[e.x??[-4,4],e.y??[-4,4],e.z??[-2.5,2.5]],this.step=e.step??1,this.base.stroke=X(e.color??"dim"),this.base.strokeWidth=e.width??2;let r=e.labelSize??34,o=e.labels===!1?null:Array.isArray(e.labels)?e.labels:["x","y","z"];if(this.tags=o?o.map(s=>st(s,{size:r,display:!1,color:"ink"})):[],e.numbers){let s=[[1,0,0],[0,1,0],[0,0,1]];this.ranges.forEach((i,a)=>{for(let l of _t(i[0],i[1],this.step)){if(l===0)continue;let c=[s[a][0]*l,s[a][1]*l,s[a][2]*l];this.numberNodes.push({node:H(String(l),{size:18,color:"dim"}),at:c})}})}}options;ranges;step;tags;numberNodes=[];emit(e){let r=this.objectAlpha(e)*this.get("strokeOpacity");if(r<=.002)return;let o=this.get("trimTo"),s=se(this.get("stroke")),i=this.get("strokeWidth")*e.scale,a=[[1,0,0],[0,1,0],[0,0,1]],l=this.options.onTop?Ne:this.options.bias??.4;this.ranges.forEach((c,u)=>{let h=a[u],d=16,m=c[0],p=m+(c[1]-m)*o;for(let f=0;f<d;f++){let b=m+(p-m)*f/d,y=m+(p-m)*(f+1)/d;if(!e.project(h[0]*b,h[1]*b,h[2]*b))continue;let g=e.px,w=e.py,x=e.pz;if(!e.project(h[0]*y,h[1]*y,h[2]*y))continue;let k=(x+e.pz)/2;e.push(Me([Mn(g,w,e.px,e.py)],e.fogged(s[0],s[1],s[2],k),r,i,0,"butt"),k+l)}if(this.options.ticks??!0)for(let f of _t(c[0],p,this.step)){if(f===0||!e.project(h[0]*f,h[1]*f,h[2]*f))continue;let b=e.px,y=e.py,g=e.pz,w=5*e.ps*e.scale,x=Mn(b-(u===2?w:0),y-(u===2?0:w),b+(u===2?w:0),y+(u===2?0:w));e.push(Me([x],e.fogged(s[0],s[1],s[2],g),r,i*.8,0,"butt"),g+l)}if(o>.98&&e.project(h[0]*c[1],h[1]*c[1],h[2]*c[1])){let f=e.px,b=e.py,y=e.pz,g=c[1]-.2;if(e.project(h[0]*g,h[1]*g,h[2]*g)){let w=Math.hypot(f-e.px,b-e.py)||1,x=(f-e.px)/w,k=(b-e.py)/w,M=14*e.scale,v=M*.42,P=Lr([f,b,f-x*M-k*v,b-k*M+x*v,f-x*M+k*v,b-k*M-x*v]);e.push(ve([P],e.fogged(s[0],s[1],s[2],y),r,null,0,0),y+l)}}})}labelsNow(e){let r=this.get("opacity")*this.get("strokeOpacity");if(r<=.002||this.get("trimTo")<.9)return[];let o=[],s=[[1,0,0],[0,1,0],[0,0,1]];this.tags.forEach((i,a)=>{let l=s[a],c=this.ranges[a][1]+.35,u=e.screen(l[0]*c,l[1]*c,l[2]*c);u&&(i.at(u),i.set("opacity",r),o.push(i))});for(let{node:i,at:a}of this.numberNodes){let l=e.screen(a[0],a[1],a[2]);l&&(i.at(l[0]+12,l[1]+14),i.set("opacity",r),o.push(i))}return o}};function Jh(n={}){return new Er(n)}var zr=class extends Et{constructor(e={}){super();this.options=e;this.base.stroke=X(e.color??"grid"),this.base.strokeWidth=e.width??1.2}options;emit(e){let r=this.objectAlpha(e)*(this.options.opacity??1)*this.get("strokeOpacity");if(r<=.002)return;let[o,s]=this.options.x??[-5,5],[i,a]=this.options.y??[-5,5],l=this.options.z??0,c=this.options.step??1,u=se(this.get("stroke")),h=this.get("strokeWidth")*e.scale,d=this.get("trimTo"),m=(p,f,b,y)=>{for(let w=0;w<10;w++){let x=w/10*d,k=(w+1)/10*d;if(!e.project(p+(b-p)*x,f+(y-f)*x,l))continue;let M=e.px,v=e.py,P=e.pz;if(!e.project(p+(b-p)*k,f+(y-f)*k,l))continue;let A=(P+e.pz)/2;e.push(Me([Mn(M,v,e.px,e.py)],e.fogged(u[0],u[1],u[2],A),r,h,0,"butt"),A-.05)}};for(let p of _t(o,s,c))m(p,i,p,a);for(let p of _t(i,a,c))m(o,p,s,p)}};function Qh(n={}){return new zr(n)}var $r=class extends Et{constructor(e,r,o={}){super();this.position=r;this.content=typeof e=="string"?o.math===!1?H(e,{size:o.size??28,color:o.color??"ink"}):st(e,{size:o.size??32,color:o.color??"ink",display:!1}):e,this.offset=o.offset??[0,0]}position;content;offset;emit(){}labelsNow(e){let r=this.get("opacity");if(r<=.002)return[];let o=oe(this.position),s=e.screen(o[0],o[1],o[2]);return s?(this.content.at(s[0]+this.offset[0],s[1]+this.offset[1]),this.content.set("opacity",r*this.get("trimTo")),[this.content]):[]}};function td(n,t,e={}){return new $r(n,t,e)}var Pn=class{film;canvas;ctx;options;raf=0;last=0;currentTime=0;playing=!1;scale=1;images=new Map;bloomLayers=[];observer=null;speed;constructor(t,e,r={}){this.canvas=t,this.film=e,this.options=r,this.speed=r.speed??1;let o=t.getContext("2d",{alpha:e.background===null});if(!o)throw new Error("This browser could not create a 2D canvas.");this.ctx=o,this.resize(),typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(()=>this.resize()),this.observer.observe(t)),this.paint(),r.autoplay&&this.play()}get time(){return this.currentTime}get isPlaying(){return this.playing}swap(t){let e=t.width!==this.film.width||t.height!==this.film.height;this.film=t,e&&(this.bloomLayers=[],this.resize()),this.paint()}resize(){let t=this.canvas.getBoundingClientRect(),e=this.options.pixelRatio??Math.min(2,globalThis.devicePixelRatio||1),r=t.width||this.film.width,o=Math.max(2,Math.round(r*e)),s=Math.max(2,Math.round(o*this.film.height/this.film.width));(this.canvas.width!==o||this.canvas.height!==s)&&(this.canvas.width=o,this.canvas.height=s,this.bloomLayers=[]),this.scale=o/this.film.width,this.playing||this.paint()}play(){this.playing||(this.currentTime>=this.film.duration-1e-6&&(this.currentTime=0),this.playing=!0,this.last=performance.now(),this.options.onState?.({playing:!0}),this.raf=requestAnimationFrame(this.tick))}pause(){this.playing&&(this.playing=!1,cancelAnimationFrame(this.raf),this.options.onState?.({playing:!1}))}toggle(){this.playing?this.pause():this.play()}seek(t){this.currentTime=Math.max(0,Math.min(this.film.duration,t)),this.paint(),this.options.onTime?.(this.currentTime)}next(){let t=this.film.chapters.find(e=>e.time>this.currentTime+.001);this.seek(t?t.time:this.film.duration)}previous(){let t=[...this.film.chapters].reverse().find(e=>e.time<this.currentTime-.25);this.seek(t?t.time:0)}destroy(){this.pause(),this.observer?.disconnect()}tick=t=>{if(!this.playing)return;let e=Math.max(0,Math.min(.1,(t-this.last)/1e3));this.last=t;let r=this.currentTime,o=r+e*this.speed;if(this.options.stepped){let s=this.film.chapters.find(i=>i.time>r+.001&&i.time<=o);if(s){this.currentTime=s.time,this.paint(),this.options.onTime?.(this.currentTime),this.pause();return}}if(o>=this.film.duration)if(this.options.loop)o%=this.film.duration;else{this.currentTime=this.film.duration,this.paint(),this.options.onTime?.(this.currentTime),this.pause();return}this.currentTime=o,this.paint(),this.options.onTime?.(this.currentTime),this.raf=requestAnimationFrame(this.tick)};lookupImage=t=>{let e=this.images.get(t.src);return e||(e=new Image,e.src=t.src,e.onload=()=>{this.playing||this.paint()},this.images.set(t.src,e)),e.complete&&e.naturalWidth>0?e:null};paint(){let t;try{t=this.film.frame(this.currentTime)}catch(e){if(e instanceof Ot){e.promise.then(()=>this.paint());return}throw e}Kn(this.ctx,t,this.scale,this.lookupImage),t.bloom>0&&t.dark&&this.applyBloom(t)}applyBloom(t){if(this.bloomLayers.length===0){let{width:a,height:l}=this.canvas;this.bloomLayers=[[4,.55],[8,.3],[16,.15]].map(([c,u])=>{let h=document.createElement("canvas");return h.width=Math.max(1,Math.round(a/c)),h.height=Math.max(1,Math.round(l/c)),{canvas:h,ctx:h.getContext("2d"),factor:c,weight:u}})}let{width:e}=this.canvas,r="filter"in this.ctx,o=[2.83,3.65,3.65],s=this.canvas;this.bloomLayers.forEach((a,l)=>{let{ctx:c,canvas:u}=a;c.setTransform(1,0,0,1,0,0),c.globalCompositeOperation="source-over",c.clearRect(0,0,u.width,u.height),c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="medium",r&&(c.filter=`blur(${(o[l]*e/1920).toFixed(2)}px)`),c.drawImage(s,0,0,u.width,u.height),r&&(c.filter="none"),l===0&&t.background&&(c.globalCompositeOperation="difference",c.fillStyle=t.background,c.fillRect(0,0,u.width,u.height),c.globalCompositeOperation="source-over"),s=u});let i=this.ctx;i.setTransform(1,0,0,1,0,0),i.globalCompositeOperation="screen",i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high";for(let a of this.bloomLayers)i.globalAlpha=Math.min(1,t.bloom*a.weight*2.4),i.drawImage(a.canvas,0,0,this.canvas.width,this.canvas.height);i.globalAlpha=1,i.globalCompositeOperation="source-over"}};function vs(n){let t=Math.floor(n/60),e=Math.floor(n%60);return`${t}:${String(e).padStart(2,"0")}`}var ya=`
1
+ import{a as na}from"./chunk-VZNL6JY2.js";import{b as ea}from"./chunk-SQE76S5B.js";var Dt=[1,0,0,1,0,0],ra={x:0,y:0,width:0,height:0},oa=.5522847498307936,be=10;function it(n,t){return[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],n[0]*t[4]+n[2]*t[5]+n[4],n[1]*t[4]+n[3]*t[5]+n[5]]}function Xt(n){let t=n[0]*n[3]-n[1]*n[2];if(Math.abs(t)<1e-12)return Dt;let e=1/t;return[n[3]*e,-n[1]*e,-n[2]*e,n[0]*e,(n[2]*n[5]-n[3]*n[4])*e,(n[1]*n[4]-n[0]*n[5])*e]}function tt(n,t,e){return[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]]}function Oe(n,t,e,r,o,s,i){let a=e===0?1:Math.cos(e),l=e===0?0:Math.sin(e),c=a*r,h=l*r,u=-l*o,d=a*o;return[c,h,u,d,n-c*s-u*i,t-h*s-d*i]}function ee(n){return Math.sqrt(Math.abs(n[0]*n[3]-n[1]*n[2]))}function Ct(n,t=!1){return{p:n instanceof Float64Array?n:Float64Array.from(n),closed:t}}function Gt(n){return Math.max(0,(n.p.length-2)/6)}function zt(n,t,e,r,o){n.push(t+(r-t)/3,e+(o-e)/3,t+(r-t)*2/3,e+(o-e)*2/3,r,o)}function ye(n,t){let e=[n[0],n[1]];return zt(e,n[0],n[1],t[0],t[1]),[Ct(e)]}function et(n,t=!1){if(n.length===0)return[];let e=n[0],r=[e[0],e[1]];for(let o=1;o<n.length;o++)zt(r,n[o-1][0],n[o-1][1],n[o][0],n[o][1]);if(t){let o=n[n.length-1];(o[0]!==e[0]||o[1]!==e[1])&&zt(r,o[0],o[1],e[0],e[1])}return[Ct(r,t)]}function Wt(n,t=!1,e=1/6){let r=n.length;if(r===0)return[];if(r<3)return et(n,t);let o=a=>t?n[(a+r)%r]:n[Math.max(0,Math.min(r-1,a))],s=[n[0][0],n[0][1]],i=t?r:r-1;for(let a=0;a<i;a++){let l=o(a-1),c=o(a),h=o(a+1),u=o(a+2);s.push(c[0]+(h[0]-l[0])*e,c[1]+(h[1]-l[1])*e,h[0]-(u[0]-c[0])*e,h[1]-(u[1]-c[1])*e,h[0],h[1])}return[Ct(s,t)]}function $t(n,t,e,r,o,s){let i=s-o;if(i===0)return[];let a=Math.abs(Math.abs(i)-Math.PI*2)<1e-9,l=Math.max(1,Math.ceil(Math.abs(i)/(Math.PI/4)-1e-9)),c=i/l,h=4/3*Math.tan(c/4),u=[n+Math.cos(o)*e,t+Math.sin(o)*r];for(let d=0;d<l;d++){let f=o+d*c,p=f+c,m=Math.cos(f),g=Math.sin(f),y=Math.cos(p),b=Math.sin(p);u.push(n+(m-h*g)*e,t+(g+h*m)*r,n+(y+h*b)*e,t+(b-h*y)*r,n+y*e,t+b*r)}return a&&(u[u.length-2]=u[0],u[u.length-1]=u[1]),[Ct(u,a)]}function Yt(n,t,e){return $t(n,t,e,e,0,Math.PI*2)}function Y(n,t,e,r,o=0){let s=Math.max(0,Math.min(o,Math.abs(e)/2,Math.abs(r)/2));if(s===0)return et([[n,t],[n+e,t],[n+e,t+r],[n,t+r]],!0);let i=s*(1-oa),a=n+e,l=t+r,c=[n+s,t];return zt(c,n+s,t,a-s,t),c.push(a-i,t,a,t+i,a,t+s),zt(c,a,t+s,a,l-s),c.push(a,l-i,a-i,l,a-s,l),zt(c,a-s,l,n+s,l),c.push(n+i,l,n,l-i,n,l-s),zt(c,n,l-s,n,t+s),c.push(n,t+i,n+i,t,n+s,t),[Ct(c,!0)]}function gn(n,t,e,r=64){let o=Math.max(2,Math.floor(r)),s=[];for(let i=0;i<=o;i++)s.push(n(t+(e-t)*i/o));return Se(s)}function Se(n){let t=[],e=[],r=()=>{e.length>=2&&t.push(...Wt(e)),e=[]};for(let o of n)Number.isFinite(o[0])&&Number.isFinite(o[1])?e.push(o):r();return r(),t}function Tc(...n){return n.flat()}function at(n,t){if(t===Dt)return n;let e=new Array(n.length);for(let r=0;r<n.length;r++){let o=n[r].p,s=new Float64Array(o.length);for(let i=0;i<o.length;i+=2){let a=o[i],l=o[i+1];s[i]=t[0]*a+t[2]*l+t[4],s[i+1]=t[1]*a+t[3]*l+t[5]}e[r]={p:s,closed:n[r].closed}}return e}function jo(n,t,e=4){return(e>1?n.map(o=>lr(o,e)):n).map(o=>{let s=Gt(o),i=[];for(let l=0;l<=s;l++){let c=t(o.p[l*6],o.p[l*6+1]);i.push(c)}let a=[i[0][0],i[0][1]];for(let l=0;l<s;l++){let c=t(o.p[l*6+2],o.p[l*6+3]),h=t(o.p[l*6+4],o.p[l*6+5]);a.push(c[0],c[1],h[0],h[1],i[l+1][0],i[l+1][1])}return Ct(a,o.closed)})}function ir(n,t,e,r,o){let s=n[t],i=n[t+1],a=n[t+2],l=n[t+3],c=n[t+4],h=n[t+5],u=n[t+6],d=n[t+7],f=s+(a-s)*e,p=i+(l-i)*e,m=a+(c-a)*e,g=l+(h-l)*e,y=c+(u-c)*e,b=h+(d-h)*e,w=f+(m-f)*e,x=p+(g-p)*e,k=m+(y-m)*e,v=g+(b-g)*e,M=w+(k-w)*e,A=x+(v-x)*e;r.push(f,p,w,x,M,A),o.length=0,o.push(M,A,k,v,y,b,u,d)}function lr(n,t){let e=Gt(n);if(t<=1||e===0)return n;let r=[n.p[0],n.p[1]];for(let o=0;o<e;o++){let s=Array.from(n.p.subarray(o*6,o*6+8));for(let i=t;i>1;i--){let a=[];ir(s,0,1/i,r,a),s=a}r.push(s[2],s[3],s[4],s[5],s[6],s[7])}return Ct(r,n.closed)}var Bo=new WeakMap;function bn(n){let t=Bo.get(n);if(t)return t;let e=Gt(n),r=new Float64Array(e),o=new Float64Array(e*be),s=0,i=n.p;for(let l=0;l<e;l++){let c=l*6,h=i[c],u=i[c+1],d=i[c+2],f=i[c+3],p=i[c+4],m=i[c+5],g=i[c+6],y=i[c+7],b=h,w=u,x=0;for(let k=1;k<=be;k++){let v=k/be,M=1-v,A=M*M*M,C=3*M*M*v,O=3*M*v*v,P=v*v*v,L=A*h+C*d+O*p+P*g,F=A*u+C*f+O*m+P*y;x+=Math.hypot(L-b,F-w),o[l*be+k-1]=x,b=L,w=F}s+=x,r[l]=s}let a={total:r,lut:o,length:s};return Bo.set(n,a),a}function je(n){return bn(n).length}function Tt(n){let t=0;for(let e of n)t+=bn(e).length;return t}function ar(n,t){let e=n.total.length;if(e===0)return[0,0];if(t<=0)return[0,0];if(t>=n.length)return[e-1,1];let r=0,o=e-1;for(;r<o;){let d=r+o>>1;n.total[d]<t?r=d+1:o=d}let s=r===0?0:n.total[r-1],i=t-s,a=r*be,l=0;for(;l<be-1&&n.lut[a+l]<i;)l++;let c=l===0?0:n.lut[a+l-1],h=n.lut[a+l],u=h>c?(i-c)/(h-c):0;return[r,(l+u)/be]}function Do(n,t,e){if(Gt(n)===0)return null;let o=Math.max(0,Math.min(1,t)),s=Math.max(0,Math.min(1,e));if(s<=o)return null;if(o===0&&s===1)return n;let i=bn(n);if(i.length===0)return null;let[a,l]=ar(i,o*i.length),[c,h]=ar(i,s*i.length),u=[];for(let d=a;d<=c;d++){let f=Array.from(n.p.subarray(d*6,d*6+8)),p=d===a?l:0,m=d===c?h:1;if(p>0){let g=[];ir(f,0,p,[],g),f=g}if(m<1){let g=[],y=[],b=p>0?(m-p)/(1-p):m;ir(f,0,b,g,y),f=[f[0],f[1],...g]}u.length===0&&u.push(f[0],f[1]),u.push(f[2],f[3],f[4],f[5],f[6],f[7])}return Ct(u,!1)}function ae(n,t,e,r=!1){if(t<=0&&e>=1)return n;let o=[];if(r){for(let a of n){let l=Do(a,t,e);l&&o.push(l)}return o}let s=Tt(n);if(s===0)return[];let i=0;for(let a of n){let l=je(a),c=(t*s-i)/(l||1),h=(e*s-i)/(l||1);if(i+=l,h<=0||c>=1)continue;let u=Do(a,Math.max(0,c),Math.min(1,h));u&&o.push(u)}return o}function Et(n,t){let e=Tt(n);if(e===0){let o=n[0]?.p;return o?[o[0],o[1]]:[0,0]}let r=Math.max(0,Math.min(1,t))*e;for(let o=0;o<n.length;o++){let s=n[o],i=je(s);if(r<=i||o===n.length-1){let[a,l]=ar(bn(s),r);return sa(s.p,a*6,l)}r-=i}return[0,0]}function Pe(n,t){let r=Et(n,Math.max(0,t-.002)),o=Et(n,Math.min(1,t+.002)),s=Math.hypot(o[0]-r[0],o[1]-r[1])||1;return[(o[0]-r[0])/s,(o[1]-r[1])/s]}function sa(n,t,e){let r=1-e,o=r*r*r,s=3*r*r*e,i=3*r*e*e,a=e*e*e;return[o*n[t]+s*n[t+2]+i*n[t+4]+a*n[t+6],o*n[t+1]+s*n[t+3]+i*n[t+5]+a*n[t+7]]}function Go(n,t,e,r,o){if(n[0]=Math.min(n[0],t,o),n[1]=Math.max(n[1],t,o),e>=n[0]&&e<=n[1]&&r>=n[0]&&r<=n[1])return;let s=-t+3*e-3*r+o,i=2*(t-2*e+r),a=e-t,l=[];if(Math.abs(s)<1e-9)Math.abs(i)>1e-9&&l.push(-a/i);else{let c=i*i-4*s*a;if(c>=0){let h=Math.sqrt(c);l.push((-i+h)/(2*s),(-i-h)/(2*s))}}for(let c of l){if(c<=0||c>=1)continue;let h=1-c,u=h*h*h*t+3*h*h*c*e+3*h*c*c*r+c*c*c*o;n[0]=Math.min(n[0],u),n[1]=Math.max(n[1],u)}}var Wo=new WeakMap;function Ho(n){let t=Wo.get(n);if(t)return t;let e=n.p;if(e.length<2)return ra;let r=[e[0],e[0]],o=[e[1],e[1]];for(let i=0;i+7<e.length;i+=6)Go(r,e[i],e[i+2],e[i+4],e[i+6]),Go(o,e[i+1],e[i+3],e[i+5],e[i+7]);let s={x:r[0],y:o[0],width:r[1]-r[0],height:o[1]-o[0]};return Wo.set(n,s),s}function wt(n){if(n.length===0)return null;let t=1/0,e=1/0,r=-1/0,o=-1/0;for(let s of n){if(s.p.length<2)continue;let i=Ho(s);t=Math.min(t,i.x),e=Math.min(e,i.y),r=Math.max(r,i.x+i.width),o=Math.max(o,i.y+i.height)}return t===1/0?null:{x:t,y:e,width:r-t,height:o-e}}function yn(n,t){if(!n)return t;if(!t)return n;let e=Math.min(n.x,t.x),r=Math.min(n.y,t.y);return{x:e,y:r,width:Math.max(n.x+n.width,t.x+t.width)-e,height:Math.max(n.y+n.height,t.y+t.height)-r}}function we(n){let t=n.p,e=0;for(let r=0;r+7<t.length;r+=6)e+=t[r]*t[r+7]-t[r+6]*t[r+1];return e/2}function xe(n){let t=Ho(n);return[t.x+t.width/2,t.y+t.height/2]}function cr(n){let t=n.p,e=new Float64Array(t.length);for(let r=0;r<t.length;r+=2)e[r]=t[t.length-2-r],e[r+1]=t[t.length-1-r];return{p:e,closed:n.closed}}function St(n){let t=n.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(!t)return[];let e=[],r=[],o=0,s=0,i=0,a=0,l=0,c="",h=0,u=0,d=()=>Number(t[o++]),f=()=>{let y=t[o];return y.length>1&&(y[0]==="0"||y[0]==="1")&&!y.startsWith("0.")&&!y.startsWith("1.")?(t[o]=y.slice(1),Number(y[0])):(o++,Number(y))},p=y=>{r.length>=8&&e.push(Ct(r,y)),r=[]},m=(y,b)=>{r.length===0&&r.push(y,b)},g="";for(;o<t.length;){let y=t[o];if(/^[a-zA-Z]$/.test(y))g=y,o++;else if(g==="M")g="L";else if(g==="m")g="l";else if(g==="")throw new Error(`Invalid SVG path data: ${n.slice(0,40)}`);let b=g>="a";switch(g.toUpperCase()){case"M":{p(!1),s=(b?s:0)+d(),i=(b?i:0)+d(),a=s,l=i,r.push(s,i);break}case"L":{let w=(b?s:0)+d(),x=(b?i:0)+d();m(s,i),zt(r,s,i,w,x),s=w,i=x;break}case"H":{let w=(b?s:0)+d();m(s,i),zt(r,s,i,w,i),s=w;break}case"V":{let w=(b?i:0)+d();m(s,i),zt(r,s,i,s,w),i=w;break}case"C":{let w=b?s:0,x=b?i:0,k=w+d(),v=x+d(),M=w+d(),A=x+d(),C=w+d(),O=x+d();m(s,i),r.push(k,v,M,A,C,O),h=M,u=A,s=C,i=O;break}case"S":{let w=b?s:0,x=b?i:0,k="CScs".includes(c),v=k?2*s-h:s,M=k?2*i-u:i,A=w+d(),C=x+d(),O=w+d(),P=x+d();m(s,i),r.push(v,M,A,C,O,P),h=A,u=C,s=O,i=P;break}case"Q":{let w=b?s:0,x=b?i:0,k=w+d(),v=x+d(),M=w+d(),A=x+d();m(s,i),r.push(s+(k-s)*2/3,i+(v-i)*2/3,M+(k-M)*2/3,A+(v-A)*2/3,M,A),h=k,u=v,s=M,i=A;break}case"T":{let w=b?s:0,x=b?i:0,k="QTqt".includes(c),v=k?2*s-h:s,M=k?2*i-u:i,A=w+d(),C=x+d();m(s,i),r.push(s+(v-s)*2/3,i+(M-i)*2/3,A+(v-A)*2/3,C+(M-C)*2/3,A,C),h=v,u=M,s=A,i=C;break}case"A":{let w=d(),x=d(),k=d(),v=f(),M=f(),A=(b?s:0)+d(),C=(b?i:0)+d();m(s,i),ia(r,s,i,w,x,k,v===1,M===1,A,C),s=A,i=C;break}case"Z":{r.length>0&&((s!==a||i!==l)&&zt(r,s,i,a,l),p(!0)),s=a,i=l;break}default:throw new Error(`Unsupported SVG path command: ${g}`)}c=g}return p(!1),e}function ia(n,t,e,r,o,s,i,a,l,c){let h=Math.abs(r),u=Math.abs(o);if(h===0||u===0||t===l&&e===c){zt(n,t,e,l,c);return}let d=s*Math.PI/180,f=Math.cos(d),p=Math.sin(d),m=(t-l)/2,g=(e-c)/2,y=f*m+p*g,b=-p*m+f*g,w=y*y/(h*h)+b*b/(u*u);if(w>1){let D=Math.sqrt(w);h*=D,u*=D}let x=h*h*u*u-h*h*b*b-u*u*y*y,k=h*h*b*b+u*u*y*y,v=(i===a?-1:1)*Math.sqrt(Math.max(0,x/k)),M=v*h*b/u,A=-v*u*y/h,C=f*M-p*A+(t+l)/2,O=p*M+f*A+(e+c)/2,P=Math.atan2((b-A)/u,(y-M)/h),L=Math.atan2((-b-A)/u,(-y-M)/h)-P;a&&L<0&&(L+=Math.PI*2),!a&&L>0&&(L-=Math.PI*2);let F=Math.max(1,Math.ceil(Math.abs(L)/(Math.PI/2)-1e-9)),_=L/F,B=4/3*Math.tan(_/4);for(let D=0;D<F;D++){let K=P+D*_,S=K+_,V=Math.cos(K),R=Math.sin(K),T=Math.cos(S),z=Math.sin(S),I=(V-B*R)*h,U=(R+B*V)*u,W=(T+B*z)*h,X=(z-B*T)*u,st=T*h,J=z*u;n.push(f*I-p*U+C,p*I+f*U+O,f*W-p*X+C,p*W+f*X+O,D===F-1?l:f*st-p*J+C,D===F-1?c:p*st+f*J+O)}}function Kt(n){let t=Math.round(n*100)/100;return t===0?"0":String(t)}function Ko(n){let t=[];for(let e of n){let r=e.p;if(!(r.length<2)){if(t.push("M",Kt(r[0])," ",Kt(r[1])),e.straight){for(let o=2;o+5<r.length;o+=6)t.push("L",Kt(r[o+4])," ",Kt(r[o+5]));e.closed&&t.push("Z");continue}for(let o=2;o+5<r.length;o+=6)t.push("C",Kt(r[o])," ",Kt(r[o+1])," ",Kt(r[o+2])," ",Kt(r[o+3])," ",Kt(r[o+4])," ",Kt(r[o+5]));e.closed&&t.push("Z")}}return t.join("")}var ur=n=>n<=0?0:n>=1?1:n,He=n=>n;function hr(n){return 1/(1+Math.exp(-n))}function aa(n){let t=hr(-n/2),e=hr(n/2);return r=>r<=0?0:r>=1?1:(hr(n*(r-.5))-t)/(e-t)}var mt=aa(10),Fc=n=>{let t=ur(n);return t*t*t*(t*(t*6-15)+10)},zc=n=>n*n,$c=n=>1-(1-n)*(1-n),Lc=n=>n*n*n,Vc=n=>1-Math.pow(1-n,3),Uc=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,_c=n=>1-Math.pow(1-n,5),Bc=n=>n<.5?16*n*n*n*n*n:1-Math.pow(-2*n+2,5)/2,Dc=n=>n>=1?1:1-Math.pow(2,-10*n),Gc=n=>n<=0?0:Math.pow(2,10*n-10),Wc=n=>2*mt(n/2),jc=n=>2*mt(n/2+.5)-1,Hc=n=>Math.sqrt(Math.max(0,1-(1-n)*(1-n)));function Kc(n=1.70158){return t=>{let e=t-1;return e*e*((n+1)*e+n)+1}}function Xc(n={}){let t=n.bounce??.28,e=n.frequency??2.2,r=-Math.log(Math.max(1e-4,t))*2.4;return o=>o<=0?0:o>=1?1:1-Math.exp(-r*o)*Math.cos(e*Math.PI*2*o)*(1-o)}var Yc=n=>n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375,dr=n=>mt(n<.5?2*n:2*(1-n));function qc(n=1/3){let t=(1-n)/2;return e=>e<t?mt(e/t):e<1-t?1:mt((1-e)/t)}function Xo(n=2){return t=>dr(t)*Math.sin(n*Math.PI*2*t)}function Zc(n=.7,t=mt){return e=>n*t(e)}function Jc(n=.25,t=mt){return e=>t(ur(e/(1-n)))}function Qc(n=-.5){return t=>{let e=1-t;return 15*e**4*t**2*n+20*e**3*t**3*n+15*e**2*t**4+6*e*t**5+t**6}}function th(n,t,e=mt){return r=>e(ur((r-n)/(t-n)))}function eh(n,t,e,r){let o=3*n,s=3*(e-n)-o,i=1-o-s,a=3*t,l=3*(r-t)-a,c=1-a-l,h=f=>((i*f+s)*f+o)*f,u=f=>((c*f+l)*f+a)*f,d=f=>(3*i*f+2*s)*f+o;return f=>{if(f<=0)return 0;if(f>=1)return 1;let p=f;for(let m=0;m<8;m++){let g=h(p)-f,y=d(p);if(Math.abs(g)<1e-5||Math.abs(y)<1e-6)break;p-=g/y}return u(p)}}var wn={name:"midnight",dark:!0,background:"#0b0c10",bloom:.2,colors:{bg:"#0b0c10",surface:"#15171d",ink:"#f2efe6",dim:"#a5a7ad",faint:"#5c5f68",grid:"#23303d",gridStrong:"#3d5266",blue:"#5cc4f0",teal:"#4fd8c4",green:"#8fe08a",yellow:"#ffd75e",gold:"#f2b84b",orange:"#ff9d57",red:"#ff6b6b",pink:"#ff8fc0",purple:"#b49cff"}},la={name:"paper",dark:!1,background:"#f7f3ea",bloom:0,colors:{bg:"#f7f3ea",surface:"#efe9db",ink:"#1d1b16",dim:"#5e5a50",faint:"#a29c8d",grid:"#e2dbca",gridStrong:"#c4bba6",blue:"#1f6fb2",teal:"#0d8577",green:"#3f8a35",yellow:"#b98500",gold:"#a8740a",orange:"#cf5d12",red:"#c62f2f",pink:"#c2387e",purple:"#6a4bc4"}},ca={name:"blueprint",dark:!0,background:"#0b2340",bloom:.16,colors:{bg:"#0b2340",surface:"#123054",ink:"#eaf6ff",dim:"#9cc0dc",faint:"#5d86a8",grid:"#1a3f66",gridStrong:"#2c5f8e",blue:"#7fd4ff",teal:"#6fe6d6",green:"#9de8a4",yellow:"#ffe27a",gold:"#f5c566",orange:"#ffb27a",red:"#ff8d8d",pink:"#ffa8cf",purple:"#c5b4ff"}},ha={name:"chalk",dark:!0,background:"#10201b",bloom:.1,colors:{bg:"#10201b",surface:"#172c25",ink:"#f4f1e4",dim:"#b1b9a9",faint:"#67786d",grid:"#20392f",gridStrong:"#355547",blue:"#8ccbe8",teal:"#7dd9c1",green:"#a9dc8f",yellow:"#f6dd7c",gold:"#e6bf62",orange:"#f2a874",red:"#ee8a80",pink:"#efa2c2",purple:"#bfa9e6"}},ua={name:"neon",dark:!0,background:"#050507",bloom:.4,colors:{bg:"#050507",surface:"#101016",ink:"#ffffff",dim:"#a9a9b8",faint:"#55555f",grid:"#1a1f2e",gridStrong:"#2f3a55",blue:"#3fb2ff",teal:"#21f0d0",green:"#6dff8e",yellow:"#fff04d",gold:"#ffc22e",orange:"#ff8a2e",red:"#ff4560",pink:"#ff5fb0",purple:"#a56bff"}},Yo={midnight:wn,paper:la,blueprint:ca,chalk:ha,neon:ua};function xn(n){if(n===void 0)return wn;if(typeof n!="string")return n;let t=Yo[n];if(!t)throw new Error(`Unknown look: ${JSON.stringify(n)}. Use one of: ${Object.keys(Yo).join(", ")}.`);return t}var Qo=ea(na(),1);var da=[0,0,0,0],qo=new Map,ts=wn.colors;function mr(n){ts=n}function qt(n){let e=ts[n]??n,r=qo.get(e);if(r)return r;let o=(0,Qo.default)(e);if(!o)throw new Error(`Unknown color: ${JSON.stringify(n)}. Use a look token such as "blue" or a CSS color.`);let[s,i,a]=o.values;o.type==="hsl"&&([s,i,a]=fa(s,i,a));let l=[s,i,a,o.alpha];return qo.set(e,l),l}function fa(n,t,e){let r=t/100*Math.min(e/100,1-e/100),o=s=>{let i=(s+n/30)%12;return 255*(e/100-r*Math.max(-1,Math.min(i-3,9-i,1)))};return[o(0),o(8),o(4)]}function q(n){return typeof n=="string"?qt(n):n}function kt(n){return!Array.isArray(n)}function ne(n,t=1){let e=n[3]*t,r=Math.round(n[0]),o=Math.round(n[1]),s=Math.round(n[2]);return e>=1?`rgb(${r},${o},${s})`:`rgba(${r},${o},${s},${Math.round(e*1e3)/1e3})`}function fr(n){let t=n/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function pr(n){let t=n<=.0031308?12.92*n:1.055*Math.pow(n,.4166666666666667)-.055;return Math.max(0,Math.min(255,t*255))}function Zo(n){let t=fr(n[0]),e=fr(n[1]),r=fr(n[2]),o=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*r),s=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*r),i=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*r);return[.2104542553*o+.793617785*s-.0040720468*i,1.9779984951*o-2.428592205*s+.4505937099*i,.0259040371*o+.7827717662*s-.808675766*i]}function pa(n,t){let e=n[0]+.3963377774*n[1]+.2158037573*n[2],r=n[0]-.1055613458*n[1]-.0638541728*n[2],o=n[0]-.0894841775*n[1]-1.291485548*n[2],s=e*e*e,i=r*r*r,a=o*o*o;return[pr(4.0767416621*s-3.3077115913*i+.2309699292*a),pr(-1.2684380046*s+2.6097574011*i-.3413193965*a),pr(-.0041960863*s-.7034186147*i+1.707614701*a),t]}function ke(n,t,e){if(e<=0)return n;if(e>=1)return t;let r=Zo(n),o=Zo(t);return pa([r[0]+(o[0]-r[0])*e,r[1]+(o[1]-r[1])*e,r[2]+(o[2]-r[2])*e],n[3]+(t[3]-n[3])*e)}function es(n,t,e){if(e<=0)return n;if(e>=1)return t;let r=kt(n),o=kt(t);if(!r&&!o)return ke(n,t,e);if(r&&o&&n.type===t.type&&n.stops.length===t.stops.length){let a=n.stops.map((l,c)=>[l[0]+(t.stops[c][0]-l[0])*e,ke(l[1],t.stops[c][1],e)]);return n.type==="linear"&&t.type==="linear"?{type:"linear",stops:a,from:[n.from[0]+(t.from[0]-n.from[0])*e,n.from[1]+(t.from[1]-n.from[1])*e],to:[n.to[0]+(t.to[0]-n.to[0])*e,n.to[1]+(t.to[1]-n.to[1])*e]}:n.type==="radial"&&t.type==="radial"?{type:"radial",stops:a,center:[n.center[0]+(t.center[0]-n.center[0])*e,n.center[1]+(t.center[1]-n.center[1])*e],radius:n.radius+(t.radius-n.radius)*e}:{type:"along",stops:a}}let s=r?ht(n.stops,.5):n,i=o?ht(t.stops,.5):t;return ke(s,i,e)}function ht(n,t){if(n.length===0)return da;if(t<=n[0][0])return n[0][1];for(let e=1;e<n.length;e++)if(t<=n[e][0]){let[r,o]=n[e-1],[s,i]=n[e];return ke(o,i,s>r?(t-r)/(s-r):0)}return n[n.length-1][1]}function kn(n){let t=n.length;return n.map((e,r)=>Array.isArray(e)&&e.length===2&&typeof e[0]=="number"?[e[0],Jo(e[1])]:[t===1?0:r/(t-1),Jo(e)])}function Jo(n){let t=q(n);return kt(t)?ht(t.stops,.5):t}function ma(n,t,e){return{type:"linear",from:n,to:t,stops:kn(e)}}function ga(n,t,e){return{type:"radial",center:n,radius:t,stops:kn(e)}}function ba(...n){return{type:"along",stops:kn(n)}}function Ke(n,...t){let e=kn(t);return Array.from({length:n},(r,o)=>ht(e,n===1?0:o/(n-1)))}var E={now:0,mode:"free",frame:0,capture:null},Ie=class{constructor(t){this.initial=t}initial;keys=[];sample(t){let e=this.keys,r=0,o=e.length-1,s=-1;for(;r<=o;){let c=r+o>>1;e[c].t0<=t?(s=c,r=c+1):o=c-1}if(s<0)return this.initial;let i=e[s];if(t>=i.t1||!i.at)return i.to;let a=i.t1-i.t0,l=a>0?(t-i.t0)/a:1;return i.at(i.ease?i.ease(l):l)}add(t){let e=this.keys,r=e.length;for(;r>0&&e[r-1].t0>t.t0;)r--;e.splice(r,0,t)}step(t,e){this.add({t0:t,t1:t,ease:null,to:e,at:null})}get end(){let t=0;for(let e of this.keys)e.t1>t&&(t=e.t1);return t}};function ns(n,t){let e=Gt(n);if(e>=t||e===0)return n;let r=[];for(let s=0;s<e;s++){let i=s*6,a=Array.from(n.p.subarray(i,i+8));r.push({pts:a,length:gr(a)})}for(;r.length<t;){let s=0;for(let l=1;l<r.length;l++)r[l].length>r[s].length&&(s=l);let[i,a]=ya(r[s].pts);r.splice(s,1,{pts:i,length:gr(i)},{pts:a,length:gr(a)})}let o=new Float64Array(2+t*6);o[0]=n.p[0],o[1]=n.p[1];for(let s=0;s<t;s++){let i=r[s].pts;for(let a=0;a<6;a++)o[2+s*6+a]=i[2+a]}return{p:o,closed:n.closed}}function gr(n){return Math.hypot(n[2]-n[0],n[3]-n[1])+Math.hypot(n[4]-n[2],n[5]-n[3])+Math.hypot(n[6]-n[4],n[7]-n[5])}function ya(n){let t=(n[0]+n[2])/2,e=(n[1]+n[3])/2,r=(n[2]+n[4])/2,o=(n[3]+n[5])/2,s=(n[4]+n[6])/2,i=(n[5]+n[7])/2,a=(t+r)/2,l=(e+o)/2,c=(r+s)/2,h=(o+i)/2,u=(a+c)/2,d=(l+h)/2;return[[n[0],n[1],t,e,a,l,u,d],[u,d,c,h,s,i,n[6],n[7]]]}function wa(n,t){let e=Gt(t);if(!n.closed||!t.closed||e<2)return t;let[r,o]=xe(n),[s,i]=xe(t),a=Math.max(1,Math.floor(e/48)),l=0,c=1/0;for(let u=0;u<e;u+=a){let d=0;for(let f=0;f<e;f+=a){let p=(f+u)%e,m=n.p[f*6]-r-(t.p[p*6]-s),g=n.p[f*6+1]-o-(t.p[p*6+1]-i);d+=m*m+g*g}d<c&&(c=d,l=u)}if(l===0)return t;let h=new Float64Array(t.p.length);h[0]=t.p[l*6],h[1]=t.p[l*6+1];for(let u=0;u<e;u++){let d=(u+l)%e;for(let f=0;f<6;f++)h[2+u*6+f]=t.p[2+d*6+f]}return{p:h,closed:t.closed}}function rs(n,t,e,r){let o=new Float64Array(2+e*6);for(let s=0;s<o.length;s+=2)o[s]=n,o[s+1]=t;return{p:o,closed:r}}function xa(n,t){let e=a=>[...a].sort((l,c)=>Math.abs(we(c))+je(c)*.01-(Math.abs(we(l))+je(l)*.01)),r=e(n),o=e(t),s=[],i=o.slice();for(let a of r){if(i.length===0){let[d,f]=xe(a);s.push([a,rs(d,f,Gt(a),a.closed)]);continue}let[l,c]=xe(a),h=0,u=1/0;for(let d=0;d<Math.min(i.length,3);d++){let[f,p]=xe(i[d]),m=Math.hypot(l-f,c-p)+d*40;m<u&&(u=m,h=d)}s.push([a,i[h]]),i.splice(h,1)}for(let a of i){let[l,c]=xe(a);s.push([rs(l,c,Gt(a),a.closed),a])}return s}function ka(n,t,e=12){let r=xa(n,t),o=[],s=[],i=[];for(let[a,l]of r){let c=Math.max(Gt(a),Gt(l),a.closed&&l.closed?e:1),h=ns(a,c),u=ns(l,c);if(h.closed&&u.closed)Math.sign(we(h))!==Math.sign(we(u))&&we(h)!==0&&we(u)!==0&&(u=cr(u)),u=wa(h,u);else if(!h.closed&&!u.closed){let d=h.p.length,f=Math.hypot(h.p[0]-u.p[0],h.p[1]-u.p[1])+Math.hypot(h.p[d-2]-u.p[d-2],h.p[d-1]-u.p[d-1]);Math.hypot(h.p[0]-u.p[d-2],h.p[1]-u.p[d-1])+Math.hypot(h.p[d-2]-u.p[0],h.p[d-1]-u.p[1])<f&&(u=cr(u))}o.push(h.p),s.push(u.p),i.push(h.closed&&u.closed)}return{from:o,to:s,closed:i}}function vn(n,t){if(n===t)return()=>t;if(Tt(n)===0&&n.length===0)return r=>r>=1?t:n;let e=ka(n,t);return r=>{if(r<=0)return n;if(r>=1)return t;let o=new Array(e.from.length);for(let s=0;s<o.length;s++){let i=e.from[s],a=e.to[s],l=new Float64Array(i.length);for(let c=0;c<i.length;c++)l[c]=i[c]+(a[c]-i[c])*r;o[s]={p:l,closed:e.closed[s]}}return o}}function Mn(n,t){let e=n.length,r=t.length,o=Array.from({length:e+1},()=>new Uint16Array(r+1));for(let l=e-1;l>=0;l--)for(let c=r-1;c>=0;c--)o[l][c]=n[l]===t[c]?o[l+1][c+1]+1:Math.max(o[l+1][c],o[l][c+1]);let s=[],i=0,a=0;for(;i<e&&a<r;)n[i]===t[a]?s.push([i++,a++]):o[i+1][a]>=o[i][a+1]?i++:a++;return s}var br={x:0,y:0,rotation:0,sx:1,sy:1,px:0,py:0,opacity:1,visible:!0,z:0,path:null,fill:null,fillOpacity:1,stroke:null,strokeOpacity:1,strokeWidth:3,cap:"round",join:"round",dash:null,dashOffset:0,trimFrom:0,trimTo:1,trimEach:!1,glow:0,glowColor:null,blend:"normal",fixed:!1,image:null},va=new Set(["x","y","rotation","sx","sy","px","py","opacity","z","fillOpacity","strokeOpacity","strokeWidth","dashOffset","trimFrom","trimTo","glow"]);function Ma(n,t,e){if(va.has(n)){let r=t,o=e;return(s=>r+(o-r)*s)}if(n==="fill"||n==="stroke"){let r=t,o=e;return r&&o?(s=>es(r,o,s)):null}if(n==="glowColor"){let r=t,o=e;return r&&o?(s=>ke(r,o,s)):null}if(n==="path"){let r=t,o=e;return r&&o?vn(r,o):null}return null}var os=1,N=class n{id=os++;parent=null;children=[];data={};label="";base=Object.create(br);tracks=null;overlay=null;overlayFrame=-1;mounted=!1;draw=null;rawOps=null;constructor(t){t&&(this.base.path=t)}get(t){let e=this.overlay;if(e!==null&&e.has(t)&&(this.overlayFrame===E.frame||E.capture!==null))return e.get(t);let r=this.tracks?.get(t);return r?r.sample(E.now):this.base[t]}set(t,e){return E.capture?(this.overlay??=new Map,this.overlay.set(t,e),E.capture.add(this),this):this.mounted?E.mode==="render"?(this.overlay??=new Map,this.overlayFrame!==E.frame&&(this.overlay.clear(),this.overlayFrame=E.frame),this.overlay.set(t,e),this):(this.track(t).step(E.now,e),this):(this.base[t]=e,this)}track(t){this.tracks??=new Map;let e=this.tracks.get(t);return e||(e=new Ie(this.base[t]),this.tracks.set(t,e)),e}tween(t,e,r,o,s){let i=E.now;E.now=r;let a=this.get(t);E.now=i;let l=o>r?Ma(t,a,e):null,c={t0:r,t1:o,ease:s,to:e,at:l};this.track(t).add(c)}add(...t){for(let e of t)e.parent!==this&&(e.parent?.drop(e),e.parent=this,this.children.push(e),this.mounted&&Nn(e,E.now));return this}drop(t){let e=this.children.indexOf(t);return e>=0&&this.children.splice(e,1),t.parent=null,this}all(){let t=[],e=r=>{t.push(r);for(let o of r.children)e(o)};return e(this),t}leaves(){return this.all().filter(t=>t.get("path")!==null||t.draw!==null||t.get("image")!==null)}clone(){let t=Object.create(Object.getPrototypeOf(this));Object.assign(t,this),t.id=os++,t.parent=null,t.mounted=!1,t.tracks=null,t.overlay=null,t.overlayFrame=-1,t.data={...this.data},t.base=Object.create(br);for(let e of Object.keys(br))t.base[e]=this.get(e);return t.children=this.children.map(e=>{let r=e.clone();return r.parent=t,r}),t}localMatrix(){return Oe(this.get("x"),this.get("y"),this.get("rotation"),this.get("sx"),this.get("sy"),this.get("px"),this.get("py"))}worldMatrix(){let t=this.localMatrix();for(let e=this.parent;e;e=e.parent)t=it(e.localMatrix(),t);return t}toWorld(t,e){return tt(this.worldMatrix(),t,e)}bounds(){return this.boundsFrom(this.parent?this.parent.worldMatrix():Dt)??{x:0,y:0,width:0,height:0}}boundsFrom(t){let e=it(t,this.localMatrix()),r=null,o=this.get("path");o&&(r=wt(at(o,e)));let s=this.get("image");if(s&&(r=yn(r,Aa(e,s.width,s.height))),this.draw){let i=this.draw(E.now),a=i===null?[]:Array.isArray(i)?i:[i];for(let l of a)r=yn(r,l.boundsFrom(e))}for(let i of this.children)i.get("visible")&&(r=yn(r,i.boundsFrom(e)));return r}get center(){let t=this.bounds();return[t.x+t.width/2,t.y+t.height/2]}get top(){let t=this.bounds();return[t.x+t.width/2,t.y]}get bottom(){let t=this.bounds();return[t.x+t.width/2,t.y+t.height]}get left(){let t=this.bounds();return[t.x,t.y+t.height/2]}get right(){let t=this.bounds();return[t.x+t.width,t.y+t.height/2]}get width(){return this.bounds().width}get height(){return this.bounds().height}at(t,e){let[r,o]=typeof t=="number"?[t,e??0]:t;return this.set("x",r),this.set("y",o),this}shift(t,e){let[r,o]=typeof t=="number"?[t,e??0]:t;return this.set("x",this.get("x")+r),this.set("y",this.get("y")+o),this}moveTo(t){let e=t instanceof n?t.center:t,[r,o]=this.center,s=this.parent?Xt(this.parent.worldMatrix()):Dt,[i,a]=tt(s,r,o),[l,c]=tt(s,e[0],e[1]);return this.shift(l-i,c-a)}pivotAt(t){let e=this.parent?this.parent.worldMatrix():Dt,r=it(e,this.localMatrix()),[o,s]=tt(Xt(r),t[0],t[1]),[i,a]=tt(Xt(e),t[0],t[1]);return this.set("px",o),this.set("py",s),this.set("x",i),this.set("y",a),this}scale(t,e){let[r,o]=typeof t=="number"?[t,t]:t;return this.pivotAt(e??this.center),this.set("sx",this.get("sx")*r),this.set("sy",this.get("sy")*o),this}rotate(t,e){return this.pivotAt(e??this.center),this.set("rotation",this.get("rotation")+t),this}fitTo(t){let e=this.bounds(),r=[];return t.width!==void 0&&e.width>0&&r.push(t.width/e.width),t.height!==void 0&&e.height>0&&r.push(t.height/e.height),r.length?this.scale(Math.min(...r)):this}nextTo(t,e="right",r=28){let[o,s]=An(e),i=t instanceof n?t.bounds():{x:t[0],y:t[1],width:0,height:0},a=this.bounds(),l=i.x+i.width/2,c=i.y+i.height/2,h=l+o*(i.width/2+r+a.width/2),u=c+s*(i.height/2+r+a.height/2);return this.moveTo([h,u])}alignTo(t,e){let r=this.bounds(),o=t instanceof n?t.bounds():{x:t[0],y:t[1],width:0,height:0};return e==="left"?this.shift(o.x-r.x,0):e==="right"?this.shift(o.x+o.width-r.x-r.width,0):e==="top"?this.shift(0,o.y-r.y):this.shift(0,o.y+o.height-r.y-r.height)}arrange(t="right",e=24){let[r,o]=An(t),s=this.center,i=null;for(let a of this.children){if(i){let l=i.bounds(),c=a.bounds(),h=l.x+l.width/2+r*(l.width/2+e+c.width/2),u=l.y+l.height/2+o*(l.height/2+e+c.height/2);a.moveTo([r===0?l.x+l.width/2:h,o===0?l.y+l.height/2:u])}i=a}return this.moveTo(s)}fill(t,e){return this.set("fill",t===null?null:q(t)),e!==void 0&&this.set("fillOpacity",e),this}stroke(t,e,r){return this.set("stroke",t===null?null:q(t)),e!==void 0&&this.set("strokeWidth",e),r!==void 0&&this.set("strokeOpacity",r),this}color(t){let e=q(t);for(let r of this.all())r.get("stroke")&&r.set("stroke",e),r.get("fill")&&r.set("fill",e),r.get("glowColor")&&!kt(e)&&r.set("glowColor",e);return this}opacity(t){return this.set("opacity",t)}glow(t,e){if(this.set("glow",t),e!==void 0){let r=q(e);this.set("glowColor",kt(r)?null:r)}return this}dash(t,e=0){return this.set("dash",t),this.set("dashOffset",e)}zIndex(t){return this.set("z",t)}pin(){return this.set("fixed",!0)}hide(){return this.set("visible",!1)}show(){return this.set("visible",!0)}named(t){return this.label=t,this}};function Aa(n,t,e){let r=[tt(n,0,0),tt(n,t,0),tt(n,t,e),tt(n,0,e)],o=r.map(l=>l[0]),s=r.map(l=>l[1]),i=Math.min(...o),a=Math.min(...s);return{x:i,y:a,width:Math.max(...o)-i,height:Math.max(...s)-a}}function An(n){return typeof n!="string"?n:n==="left"?[-1,0]:n==="right"?[1,0]:n==="top"||n==="up"?[0,-1]:[0,1]}function Nn(n,t){let e=n.base.visible;for(let r of n.all())r.mounted=!0;if(t>0||!e){let r=n.track("visible");r.initial=!1,e&&r.step(t,!0)}}function yr(...n){return new N().add(...n)}function Rt(n){let t=new N;return t.draw=n,t}function Lt(n){return Array.isArray(n)?[...n]:[n]}function Sn(n,t,e,r){E.now=t,n.schedule({t0:t,t1:e,ease:n.ease??r.ease,stage:r.stage})}function wr(...n){let t=Math.max(0,...n.map(e=>e.duration));return{label:"par",duration:t,schedule(e){let r=t>0?(e.t1-e.t0)/t:1;for(let o of n)Sn(o,e.t0,e.t0+o.duration*r,e)}}}function ss(...n){let t=n.reduce((e,r)=>e+r.duration,0);return{label:"seq",duration:t,schedule(e){let r=t>0?(e.t1-e.t0)/t:1,o=e.t0;for(let s of n){let i=o+s.duration*r;Sn(s,o,i,e),o=i}}}}function xh(n,t={}){let e=t.lag??.15,r=Math.max(0,...n.map(s=>s.duration)),o=n.length===0?0:r*(1+(n.length-1)*e);return{label:"lagged",duration:t.duration??o,schedule(s){let i=s.t1-s.t0,a=n.length===0?0:i/(1+(n.length-1)*e);n.forEach((l,c)=>{let h=s.t0+c*e*a;Sn(l,h,h+a,s)})}}}function kh(n,t){return{label:n.label,duration:n.duration+t,ease:n.ease,schedule(e){let r=n.duration+t>0?(e.t1-e.t0)/(n.duration+t):1;Sn(n,e.t0+t*r,e.t1,e)}}}function Na(n,t){return{...n,duration:t.duration??n.duration,ease:t.ease??n.ease}}function vh(n){return{label:"call",duration:0,schedule:()=>n()}}function ce(n,t,e){if(!n.mounted){let r=n;for(;r.parent&&r.parent!==e.root;)r=r.parent;e.mountAt(r,t)}for(let r=n;r&&r!==e.root;r=r.parent){let o=E.now;E.now=t;let s=r.get("visible");E.now=o,s||r.track("visible").step(t,!0)}}function Zt(n,t){n.track("visible").step(t,!1)}function is(n,t,e){e<=t||(n.track("visible").step(t,!1),n.track("visible").step(e,!0))}var rt=(n,t,e,r)=>{n.track(t).step(r,e)};function Ca(n,t,e){let r=E.now;E.now=e;let o=n.get(t);return E.now=r,o}function Oa(n){return kt(n)?ht(n.stops,.5):n}function le(n){return Lt(n).flatMap(t=>t.leaves().filter(e=>e.get("path")))}function Sa(n,t,e,r,o){let s=e-t,i=n.get("fill"),a=n.get("stroke"),l=n.get("fillOpacity"),c=n.get("strokeOpacity");if(i&&!a){let h=Ca(n,"strokeWidth",t);rt(n,"stroke",Oa(i),t),rt(n,"strokeWidth",o,t),rt(n,"strokeOpacity",1,t),rt(n,"trimTo",0,t),rt(n,"fillOpacity",0,t),n.tween("trimTo",1,t,t+s*.72,r),n.tween("fillOpacity",l,t+s*.42,e,r),n.tween("strokeOpacity",0,t+s*.62,e,r),rt(n,"stroke",null,e),rt(n,"strokeWidth",h,e),rt(n,"strokeOpacity",c,e);return}rt(n,"trimTo",0,t),n.tween("trimTo",1,t,i?t+s*.8:e,r),i&&(rt(n,"fillOpacity",0,t),n.tween("fillOpacity",l,t+s*.5,e,r))}function as(n,t,e,r){let o=Lt(t),s=le(o).length,i=e.lag??r.lag,a=e.duration??(s<=1?r.duration:Math.min(r.duration*2.4,r.duration+s*.035));return{label:n,duration:a,ease:e.ease,schedule(l){for(let d of o)ce(d,l.t0,l.stage);let c=le(o);if(c.length===0)return;let u=(l.t1-l.t0)/(1+(c.length-1)*i);c.forEach((d,f)=>{let p=l.t0+f*i*u;E.now=p,is(d,l.t0,p),Sa(d,p,p+u,l.ease,r.outline)}),E.now=l.t0}}}function Mh(n,t={}){return as("draw",n,t,{lag:.04,duration:1.3,outline:2})}function Ah(n,t={}){return as("write",n,t,{lag:.22,duration:1.1,outline:1.3})}function Nh(n,t={}){let e=Lt(n);return{label:"erase",duration:t.duration??.8,ease:t.ease,schedule(r){let o=le(e),s=t.lag??.02,i=(r.t1-r.t0)/(1+Math.max(0,o.length-1)*s);o.forEach((a,l)=>{let c=r.t0+l*s*i;E.now=c;let h=a.get("fill");a.get("stroke")&&a.tween("trimFrom",1,c,c+i,r.ease),h&&a.tween("fillOpacity",0,c,c+i*.7,r.ease)});for(let a of e)Zt(a,r.t1)}}}function Ch(n,t={}){let e=Lt(n);return{label:"fadeIn",duration:t.duration??.8,ease:t.ease,schedule(r){let o=t.lag!==void 0&&e.length===1&&e[0].children.length>0?e[0].children:e;for(let a of e)ce(a,r.t0,r.stage);let s=t.lag??0,i=(r.t1-r.t0)/(1+Math.max(0,o.length-1)*s);o.forEach((a,l)=>{let c=r.t0+l*s*i,h=c+i;E.now=c,is(a,r.t0,c);let u=a.get("opacity");if(rt(a,"opacity",0,c),a.tween("opacity",u,c,h,r.ease),t.shift){let d=a.get("x"),f=a.get("y");rt(a,"x",d+t.shift[0],c),rt(a,"y",f+t.shift[1],c),a.tween("x",d,c,h,r.ease),a.tween("y",f,c,h,r.ease)}t.scale!==void 0&&ls(a,t.scale,c,h,r.ease)}),E.now=r.t0}}}function ls(n,t,e,r,o,s){let i=E.now;E.now=e,n.pivotAt(s??n.center);let a=n.get("sx"),l=n.get("sy");rt(n,"sx",a*t,e),rt(n,"sy",l*t,e),n.tween("sx",a,e,r,o),n.tween("sy",l,e,r,o),E.now=i}function Oh(n,t={}){let e=Lt(n);return{label:"fadeOut",duration:t.duration??.6,ease:t.ease,schedule(r){for(let o of e){let s=o.get("opacity");o.tween("opacity",0,r.t0,r.t1,r.ease),t.shift&&(o.tween("x",o.get("x")+t.shift[0],r.t0,r.t1,r.ease),o.tween("y",o.get("y")+t.shift[1],r.t0,r.t1,r.ease)),t.scale!==void 0&&(o.pivotAt(o.center),o.tween("sx",o.get("sx")*t.scale,r.t0,r.t1,r.ease),o.tween("sy",o.get("sy")*t.scale,r.t0,r.t1,r.ease)),Zt(o,r.t1),rt(o,"opacity",s,r.t1)}}}}function Sh(n,t={}){let e=Lt(n);return{label:"grow",duration:t.duration??.9,ease:t.ease,schedule(r){for(let o of e)ce(o,r.t0,r.stage),ls(o,.001,r.t0,r.t1,r.ease,t.from)}}}function Ph(n){let t=Lt(n);return{label:"appear",duration:0,schedule:e=>{for(let r of t)ce(r,e.t0,e.stage)}}}function Ih(n){let t=Lt(n);return{label:"vanish",duration:0,schedule:e=>{for(let r of t)Zt(r,e.t0)}}}function ve(n,t,e={}){return{label:"to",duration:e.duration??1,ease:e.ease,schedule(r){ce(n,r.t0,r.stage);let o=new Set;E.capture=o;try{t(n)}finally{E.capture=null}for(let s of o){let i=s,a=new Map(i.overlay);i.overlay.clear(),Pa(i,a,r,e.restore===!0)}}}}function Pa(n,t,e,r){let{t0:o,t1:s,ease:i}=e,a=t,l=new Map,c=a.get("px"),h=a.get("py");if(c!==void 0||h!==void 0){let u=c??n.get("px"),d=h??n.get("py"),f=Oe(n.get("x"),n.get("y"),n.get("rotation"),n.get("sx"),n.get("sy"),n.get("px"),n.get("py")),[p,m]=tt(f,u,d);rt(n,"px",u,o),rt(n,"py",d,o),rt(n,"x",p,o),rt(n,"y",m,o),a.delete("px"),a.delete("py")}E.now=o;for(let[u,d]of a){let f=n.get(u);f!==d&&(r&&l.set(u,f),n.tween(u,d,o,s,i))}for(let[u,d]of l)rt(n,u,d,s)}function Eh(n,t,e={}){return{...ve(n,r=>r.moveTo(t),e),label:"moveTo"}}function Th(n,t,e,r={}){return{...ve(n,o=>o.shift(t,e),r),label:"shift"}}function Rh(n,t,e={}){return{...ve(n,r=>r.scale(t,e.about),e),label:"scale"}}function Fh(n,t,e={}){return{...ve(n,r=>r.rotate(t,e.about),e),label:"rotate"}}function cs(n,t,e={}){return{...ve(n,r=>r.color(t),e),label:"recolor"}}function hs(n,t,e={}){return{...ve(n,r=>r.opacity(t),{duration:.6,...e}),label:"fade"}}function zh(n,t,e={}){return{label:"along",duration:e.duration??2,ease:e.ease,schedule(r){ce(n,r.t0,r.stage);let o=t instanceof N?at(t.get("path")??[],t.worldMatrix()):t,s=n.parent?us(n.parent.worldMatrix()):null,i=c=>{let[h,u]=Et(o,c);return s?tt(s,h,u):[h,u]},[a,l]=i(1);if(n.track("x").add({t0:r.t0,t1:r.t1,ease:r.ease,to:a,at:c=>i(c)[0]}),n.track("y").add({t0:r.t0,t1:r.t1,ease:r.ease,to:l,at:c=>i(c)[1]}),e.orient){let c=h=>{let[u,d]=Pe(o,h);return Math.atan2(d,u)};n.track("rotation").add({t0:r.t0,t1:r.t1,ease:r.ease,to:c(1),at:c})}}}}function us(n){let t=n[0]*n[3]-n[1]*n[2];if(Math.abs(t)<1e-12)return[1,0,0,1,0,0];let e=1/t;return[n[3]*e,-n[1]*e,-n[2]*e,n[0]*e,(n[2]*n[5]-n[3]*n[4])*e,(n[1]*n[4]-n[0]*n[5])*e]}function xr(n,t,e={}){let r=Lt(n);return{label:"warp",duration:e.duration??2,ease:e.ease,schedule(o){for(let s of le(r)){ce(s,o.t0,o.stage);let i=s.get("path"),a=s.worldMatrix(),l=us(a),c=i.map(u=>lr(u,e.subdivisions??6)),h=jo(c,(u,d)=>{let[f,p]=tt(a,u,d),[m,g]=t(f,p);return tt(l,m,g)},1);s.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:h,at:u=>c.map((d,f)=>{let p=d.p,m=h[f].p,g=new Float64Array(p.length);for(let y=0;y<p.length;y++)g[y]=p[y]+(m[y]-p[y])*u;return{p:g,closed:d.closed}})})}}}}function $h(n,t,e={}){let[r,o]=e.origin??[0,0],s=e.yUp===!1?1:-1,[[i,a],[l,c]]=t;return{...xr(n,(h,u)=>{let d=h-r,f=(u-o)*s,p=i*d+a*f,m=l*d+c*f;return[r+p,o+m*s]},{subdivisions:1,...e}),label:"applyMatrix"}}function Ia(n){let t=1;for(let e=n;e;e=e.parent)t*=e.get("opacity");return t}function On(n){let t=n.worldMatrix(),e=Ia(n),r=0,o=!1;for(let s=n;s;s=s.parent)r+=s.get("z"),o||=s.get("fixed");return{path:at(n.get("path")??[],t),fill:n.get("fill"),fillOpacity:n.get("fill")?n.get("fillOpacity")*e:0,stroke:n.get("stroke"),strokeOpacity:n.get("stroke")?n.get("strokeOpacity")*e:0,strokeWidth:n.get("strokeWidth")*ee(t),glow:n.get("glow"),glowColor:n.get("glowColor"),cap:n.get("cap"),dash:n.get("dash"),z:r,fixed:o,key:n.data.key}}function Cn(n,t,e,r){let o=new N;return o.base.visible=!1,o.base.path=t.path,o.base.cap=t.cap,o.base.z=t.z,o.base.fixed=t.fixed,o.base.fill=t.fill??e.fill,o.base.stroke=t.stroke??e.stroke,o.base.fillOpacity=t.fillOpacity,o.base.strokeOpacity=t.strokeOpacity,o.base.strokeWidth=t.strokeWidth||e.strokeWidth,o.base.glow=t.glow,o.base.glowColor=t.glowColor??e.glowColor,n.root.add(o),o.track("visible").initial=!1,o.track("visible").keys.length=0,rt(o,"visible",!0,r.appear??r.t0),o.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:e.path,at:vn(t.path,e.path)}),t.fill&&e.fill&&o.tween("fill",e.fill,r.t0,r.t1,r.ease),t.stroke&&e.stroke&&o.tween("stroke",e.stroke,r.t0,r.t1,r.ease),o.tween("fillOpacity",e.fillOpacity,r.t0,r.t1,r.ease),o.tween("strokeOpacity",e.strokeOpacity,r.t0,r.t1,r.ease),o.tween("strokeWidth",e.strokeWidth||t.strokeWidth,r.t0,r.t1,r.ease),t.glow!==e.glow&&o.tween("glow",e.glow,r.t0,r.t1,r.ease),rt(o,"visible",!1,r.hide??r.t1),o}function Ea(n,t){let e=Math.max(n.length,t.length),r=[];for(let o=0;o<e;o++)r.push([n[Math.min(n.length-1,Math.floor(o*n.length/e))],t[Math.min(t.length-1,Math.floor(o*t.length/e))]]);return r}function Lh(n,t,e={}){let r=Lt(n),o=Lt(t);return{label:"morph",duration:e.duration??1.2,ease:e.ease,schedule(s){ds(o,s);let i=le(r).map(On),a=le(o).map(On);if(i.length===0||a.length===0){for(let u of r)Zt(u,s.t0);for(let u of o)ce(u,s.t0,s.stage);return}let l=Ea(i,a),c=e.lag??0,h=(s.t1-s.t0)/(1+Math.max(0,l.length-1)*c);l.forEach(([u,d],f)=>{let p=s.t0+f*c*h;Cn(s.stage,u,d,{t0:p,t1:p+h,ease:s.ease,appear:s.t0,hide:s.t1})}),fs(r,o,s)}}}function ds(n,t){E.now=t.t0;for(let e of n)t.stage.mountAt(e,t.t0),Zt(e,t.t0)}function fs(n,t,e){for(let r of n)Zt(r,e.t0);for(let r of t)r.track("visible").step(e.t1,!0);E.now=e.t0}function Ee(n,t,e={}){return{label:"morphMatching",duration:e.duration??1.4,ease:e.ease,schedule(r){ds([t],r);let o=e.key??(m=>m.data.key),s=le(n),i=le(t),a=s.map(On),l=i.map(On),c=Mn(s.map(o),i.map(o)),h=new Set(c.map(([m])=>m)),u=new Set(c.map(([,m])=>m));for(let[m,g]of c)Cn(r.stage,a[m],l[g],r);let d=r.t1-r.t0,f=e.fadeShift??[0,0],p=(m,g,y)=>at(m,[1,0,0,1,g,y]);a.forEach((m,g)=>{h.has(g)||Cn(r.stage,m,{...m,path:p(m.path,f[0],f[1]),fillOpacity:0,strokeOpacity:0},{t0:r.t0,t1:r.t0+d*.55,ease:r.ease})}),l.forEach((m,g)=>{u.has(g)||Cn(r.stage,{...m,path:p(m.path,-f[0],-f[1]),fillOpacity:0,strokeOpacity:0},m,{t0:r.t0+d*.35,t1:r.t1,ease:r.ease})}),fs([n],[t],r)}}}function Vh(n,t={}){let r=Lt(n).map(o=>Na(ve(o,s=>{s.scale(t.scale??1.14),s.color(t.color??"yellow")},{restore:!0}),{ease:t.ease??dr}));return{...wr(...r),label:"indicate",duration:t.duration??.9}}function Uh(n,t={}){return{label:"shake",duration:t.duration??.8,ease:Xo(t.cycles??3),schedule(e){E.now=e.t0;let[r,o]=n.center;n.pivotAt([r,o]);let s=n.get("rotation"),i=t.angle??.08;n.track("rotation").add({t0:e.t0,t1:e.t1,ease:e.ease,to:s,at:l=>s+i*l})}}}function _h(n,t={}){return{label:"circumscribe",duration:t.duration??1.3,ease:t.ease??He,schedule(e){let r=n.bounds(),o=t.pad??14,s=new N(Y(r.x-o,r.y-o,r.width+o*2,r.height+o*2,t.radius??12)).stroke(t.color??"yellow",t.width??3).glow(8);e.stage.add(s);let i=e.t0,a=e.t1,l=i+(a-i)*.55;rt(s,"trimTo",0,i),s.tween("trimTo",1,i,l,mt),s.tween("trimFrom",1,l-(a-i)*.08,a,mt),Zt(s,a)}}}function Bh(n,t={}){return{label:"flash",duration:t.duration??.7,ease:t.ease??mt,schedule(e){let r=n instanceof N?n.center:n,o=t.radius??54,s=t.rays??12;for(let i=0;i<s;i++){let a=i/s*Math.PI*2,l=Math.cos(a),c=Math.sin(a),h=new N(ye([r[0]+l*o*.35,r[1]+c*o*.35],[r[0]+l*o,r[1]+c*o])).stroke(t.color??"yellow",2.5).glow(5);e.stage.add(h),rt(h,"trimTo",0,e.t0),h.tween("trimTo",1,e.t0,e.t0+(e.t1-e.t0)*.6,e.ease),h.tween("trimFrom",1,e.t0+(e.t1-e.t0)*.25,e.t1,e.ease),Zt(h,e.t1)}}}}function Dh(n,t={}){return{label:"ripple",duration:t.duration??1,ease:t.ease??mt,schedule(e){let r=n instanceof N?n.center:n,o=new N(Yt(0,0,t.radius??90)).stroke(t.color??"blue",t.width??3).at(r);e.stage.add(o),rt(o,"sx",.05,e.t0),rt(o,"sy",.05,e.t0),o.tween("sx",1,e.t0,e.t1,e.ease),o.tween("sy",1,e.t0,e.t1,e.ease),o.tween("strokeOpacity",0,e.t0+(e.t1-e.t0)*.2,e.t1,e.ease),Zt(o,e.t1)}}}function kr(n,t={}){return{label:"pulse",duration:t.duration??1.1,ease:t.ease??mt,schedule(e){let r=n.get("path");if(!r)return;let o=new N(at(r,n.worldMatrix())).stroke(t.color??"yellow",t.width??n.get("strokeWidth")+1.5).glow(t.glow??10);e.stage.add(o);let s=t.length??.18;rt(o,"trimFrom",0,e.t0),rt(o,"trimTo",0,e.t0),o.track("trimTo").add({t0:e.t0,t1:e.t1,ease:e.ease,to:1,at:i=>Math.min(1,i*(1+s))}),o.track("trimFrom").add({t0:e.t0,t1:e.t1,ease:e.ease,to:1,at:i=>Math.max(0,i*(1+s)-s)}),Zt(o,e.t1)}}}var yt=class{track;constructor(t){this.track=new Ie(t)}get value(){return this.track.sample(E.now)}set(t){return this.track.step(E.now,t),this}to(t,e={}){let r=this.track;return{label:"value",duration:e.duration??1,ease:e.ease,schedule(o){let s=r.sample(o.t0);r.add({t0:o.t0,t1:o.t1,ease:o.ease,to:t,at:i=>s+(t-s)*i})}}}};var Pt=Uint8Array,Me=Uint16Array,ps=Uint32Array,ms=new Pt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),gs=new Pt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ta=new Pt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bs=function(n,t){for(var e=new Me(31),r=0;r<31;++r)e[r]=t+=1<<n[r-1];for(var o=new ps(e[30]),r=1;r<30;++r)for(var s=e[r];s<e[r+1];++s)o[s]=s-e[r]<<5|r;return[e,o]},ys=bs(ms,2),ws=ys[0],Ra=ys[1];ws[28]=258,Ra[258]=28;var xs=bs(gs,0),Fa=xs[0],Wh=xs[1],Nr=new Me(32768);for(nt=0;nt<32768;++nt)re=(nt&43690)>>>1|(nt&21845)<<1,re=(re&52428)>>>2|(re&13107)<<2,re=(re&61680)>>>4|(re&3855)<<4,Nr[nt]=((re&65280)>>>8|(re&255)<<8)>>>1;var re,nt,Xe=(function(n,t,e){for(var r=n.length,o=0,s=new Me(t);o<r;++o)n[o]&&++s[n[o]-1];var i=new Me(t);for(o=0;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;var a;if(e){a=new Me(1<<t);var l=15-t;for(o=0;o<r;++o)if(n[o])for(var c=o<<4|n[o],h=t-n[o],u=i[n[o]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)a[Nr[u]>>>l]=c}else for(a=new Me(r),o=0;o<r;++o)n[o]&&(a[o]=Nr[i[n[o]-1]++]>>>15-n[o]);return a}),Ye=new Pt(288);for(nt=0;nt<144;++nt)Ye[nt]=8;var nt;for(nt=144;nt<256;++nt)Ye[nt]=9;var nt;for(nt=256;nt<280;++nt)Ye[nt]=7;var nt;for(nt=280;nt<288;++nt)Ye[nt]=8;var nt,ks=new Pt(32);for(nt=0;nt<32;++nt)ks[nt]=5;var nt;var za=Xe(Ye,9,1);var $a=Xe(ks,5,1),vr=function(n){for(var t=n[0],e=1;e<n.length;++e)n[e]>t&&(t=n[e]);return t},jt=function(n,t,e){var r=t/8|0;return(n[r]|n[r+1]<<8)>>(t&7)&e},Mr=function(n,t){var e=t/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(t&7)},La=function(n){return(n+7)/8|0},Pn=function(n,t,e){(t==null||t<0)&&(t=0),(e==null||e>n.length)&&(e=n.length);var r=new(n.BYTES_PER_ELEMENT==2?Me:n.BYTES_PER_ELEMENT==4?ps:Pt)(e-t);return r.set(n.subarray(t,e)),r};var Va=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ft=function(n,t,e){var r=new Error(t||Va[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,Ft),!e)throw r;return r},vs=function(n,t,e){var r=n.length;if(!r||e&&e.f&&!e.l)return t||new Pt(0);var o=!t||e,s=!e||e.i;e||(e={}),t||(t=new Pt(r*3));var i=function(X){var st=t.length;if(X>st){var J=new Pt(Math.max(st*2,X));J.set(t),t=J}},a=e.f||0,l=e.p||0,c=e.b||0,h=e.l,u=e.d,d=e.m,f=e.n,p=r*8;do{if(!h){a=jt(n,l,1);var m=jt(n,l+1,3);if(l+=3,m)if(m==1)h=za,u=$a,d=9,f=5;else if(m==2){var w=jt(n,l,31)+257,x=jt(n,l+10,15)+4,k=w+jt(n,l+5,31)+1;l+=14;for(var v=new Pt(k),M=new Pt(19),A=0;A<x;++A)M[Ta[A]]=jt(n,l+A*3,7);l+=x*3;for(var C=vr(M),O=(1<<C)-1,P=Xe(M,C,1),A=0;A<k;){var L=P[jt(n,l,O)];l+=L&15;var g=L>>>4;if(g<16)v[A++]=g;else{var F=0,_=0;for(g==16?(_=3+jt(n,l,3),l+=2,F=v[A-1]):g==17?(_=3+jt(n,l,7),l+=3):g==18&&(_=11+jt(n,l,127),l+=7);_--;)v[A++]=F}}var B=v.subarray(0,w),D=v.subarray(w);d=vr(B),f=vr(D),h=Xe(B,d,1),u=Xe(D,f,1)}else Ft(1);else{var g=La(l)+4,y=n[g-4]|n[g-3]<<8,b=g+y;if(b>r){s&&Ft(0);break}o&&i(c+y),t.set(n.subarray(g,b),c),e.b=c+=y,e.p=l=b*8,e.f=a;continue}if(l>p){s&&Ft(0);break}}o&&i(c+131072);for(var K=(1<<d)-1,S=(1<<f)-1,V=l;;V=l){var F=h[Mr(n,l)&K],R=F>>>4;if(l+=F&15,l>p){s&&Ft(0);break}if(F||Ft(2),R<256)t[c++]=R;else if(R==256){V=l,h=null;break}else{var T=R-254;if(R>264){var A=R-257,z=ms[A];T=jt(n,l,(1<<z)-1)+ws[A],l+=z}var I=u[Mr(n,l)&S],U=I>>>4;I||Ft(3),l+=I&15;var D=Fa[U];if(U>3){var z=gs[U];D+=Mr(n,l)&(1<<z)-1,l+=z}if(l>p){s&&Ft(0);break}o&&i(c+131072);for(var W=c+T;c<W;c+=4)t[c]=t[c-D],t[c+1]=t[c+1-D],t[c+2]=t[c+2-D],t[c+3]=t[c+3-D];c=W}}e.l=h,e.p=V,e.b=c,e.f=a,h&&(a=1,e.m=d,e.d=u,e.n=f)}while(!a);return c==t.length?t:Pn(t,0,c)};var Ua=new Pt(0);var _a=function(n){((n[0]&15)!=8||n[0]>>>4>7||(n[0]<<8|n[1])%31)&&Ft(6,"invalid zlib data"),n[1]&32&&Ft(6,"invalid zlib data: preset dictionaries not supported")};var Ar=(function(){function n(t){this.s={},this.p=new Pt(0),this.ondata=t}return n.prototype.e=function(t){this.ondata||Ft(5),this.d&&Ft(4);var e=this.p.length,r=new Pt(e+t.length);r.set(this.p),r.set(t,e),this.p=r},n.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,r=vs(this.p,this.o,this.s);this.ondata(Pn(r,e,this.s.b),this.d),this.o=Pn(r,this.s.b-32768),this.s.b=this.o.length,this.p=Pn(this.p,this.s.p/8|0),this.s.p&=7},n.prototype.push=function(t,e){this.e(t),this.c(e)},n})();var Te=(function(){function n(t){this.v=1,Ar.call(this,t)}return n.prototype.push=function(t,e){if(Ar.prototype.e.call(this,t),this.v){if(this.p.length<2&&!e)return;this.p=this.p.subarray(2),this.v=0}e&&(this.p.length<4&&Ft(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Ar.prototype.c.call(this,e)},n})();function Ms(n,t){return vs((_a(n),n.subarray(2,-4)),t)}var Ba=typeof TextDecoder<"u"&&new TextDecoder,Da=0;try{Ba.decode(Ua,{stream:!0}),Da=1}catch{}function Cr(n,t="utf8"){return new TextDecoder(t).decode(n)}var Ga=new TextEncoder;function As(n){return Ga.encode(n)}var Wa=1024*8,ja=(()=>{let n=new Uint8Array(4),t=new Uint32Array(n.buffer);return!((t[0]=1)&n[0])})(),Or={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array},qe=class n{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=Wa,e={}){let r=!1;typeof t=="number"?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);let o=e.offset?e.offset>>>0:0,s=t.byteLength-o,i=o;(ArrayBuffer.isView(t)||t instanceof n)&&(t.byteLength!==t.buffer.byteLength&&(i=t.byteOffset+o),t=t.buffer),r?this.lastWrittenByte=s:this.lastWrittenByte=0,this.buffer=t,this.length=s,this.byteLength=s,this.byteOffset=i,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,i,s),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}back(t=1){return this.offset-=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let t=this._marks.pop();if(t===void 0)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){let r=(this.offset+t)*2,o=new Uint8Array(r);o.set(new Uint8Array(this.buffer)),this.buffer=o.buffer,this.length=r,this.byteLength=r,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){return this.readArray(t,"uint8")}readArray(t,e){let r=Or[e].BYTES_PER_ELEMENT*t,o=this.byteOffset+this.offset,s=this.buffer.slice(o,o+r);if(this.littleEndian===ja&&e!=="uint8"&&e!=="int8"){let a=new Uint8Array(this.buffer.slice(o,o+r));a.reverse();let l=new Or[e](a.buffer);return this.offset+=r,l.reverse(),l}let i=new Or[e](s);return this.offset+=r,i}readInt16(){let t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){let t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){let t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){let t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){let t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){let t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readBigInt64(){let t=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,t}readBigUint64(){let t=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let e="";for(let r=0;r<t;r++)e+=this.readChar();return e}readUtf8(t=1){return Cr(this.readBytes(t))}decodeText(t=1,e="utf8"){return Cr(this.readBytes(t),e)}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let e=0;e<t.length;e++)this._data.setUint8(this.offset++,t[e]);return this._updateLastWrittenByte(),this}writeInt16(t){return this.ensureAvailable(2),this._data.setInt16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(t){return this.ensureAvailable(2),this._data.setUint16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(t){return this.ensureAvailable(4),this._data.setInt32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(t){return this.ensureAvailable(4),this._data.setUint32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(t){return this.ensureAvailable(4),this._data.setFloat32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(t){return this.ensureAvailable(8),this._data.setFloat64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(t){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(t){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(t){return this.writeUint8(t.charCodeAt(0))}writeChars(t){for(let e=0;e<t.length;e++)this.writeUint8(t.charCodeAt(e));return this}writeUtf8(t){return this.writeBytes(As(t))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}};var Cs=[];for(let n=0;n<256;n++){let t=n;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t=t>>>1;Cs[n]=t}var Ns=4294967295;function Ha(n,t,e){let r=n;for(let o=0;o<e;o++)r=Cs[(r^t[o])&255]^r>>>8;return r}function Ka(n,t){return(Ha(Ns,n,t)^Ns)>>>0}function Sr(n,t,e){let r=n.readUint32(),o=Ka(new Uint8Array(n.buffer,n.byteOffset+n.offset-t-4,t),t);if(o!==r)throw new Error(`CRC mismatch for chunk ${e}. Expected ${r}, found ${o}`)}function In(n,t,e){for(let r=0;r<e;r++)t[r]=n[r]}function En(n,t,e,r){let o=0;for(;o<r;o++)t[o]=n[o];for(;o<e;o++)t[o]=n[o]+t[o-r]&255}function Tn(n,t,e,r){let o=0;if(e.length===0)for(;o<r;o++)t[o]=n[o];else for(;o<r;o++)t[o]=n[o]+e[o]&255}function Rn(n,t,e,r,o){let s=0;if(e.length===0){for(;s<o;s++)t[s]=n[s];for(;s<r;s++)t[s]=n[s]+(t[s-o]>>1)&255}else{for(;s<o;s++)t[s]=n[s]+(e[s]>>1)&255;for(;s<r;s++)t[s]=n[s]+(t[s-o]+e[s]>>1)&255}}function Fn(n,t,e,r,o){let s=0;if(e.length===0){for(;s<o;s++)t[s]=n[s];for(;s<r;s++)t[s]=n[s]+t[s-o]&255}else{for(;s<o;s++)t[s]=n[s]+e[s]&255;for(;s<r;s++)t[s]=n[s]+Xa(t[s-o],e[s],e[s-o])&255}}function Xa(n,t,e){let r=n+t-e,o=Math.abs(r-n),s=Math.abs(r-t),i=Math.abs(r-e);return o<=s&&o<=i?n:s<=i?t:e}function Os(n,t,e,r,o,s){switch(n){case 0:In(t,e,o);break;case 1:En(t,e,o,s);break;case 2:Tn(t,e,r,o);break;case 3:Rn(t,e,r,o,s);break;case 4:Fn(t,e,r,o,s);break;default:throw new Error(`Unsupported filter: ${n}`)}}var Ya=new Uint16Array([255]),qa=new Uint8Array(Ya.buffer),Za=qa[0]===255;function Ss(n){let{data:t,width:e,height:r,channels:o,depth:s}=n,i=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],a=Math.ceil(s/8)*o,l=new Uint8Array(r*e*a),c=0;for(let h=0;h<7;h++){let u=i[h],d=Math.ceil((e-u.x)/u.xStep),f=Math.ceil((r-u.y)/u.yStep);if(d<=0||f<=0)continue;let p=d*a,m=new Uint8Array(p);for(let g=0;g<f;g++){let y=t[c++],b=t.subarray(c,c+p);c+=p;let w=new Uint8Array(p);Os(y,b,w,m,p,a),m.set(w);for(let x=0;x<d;x++){let k=u.x+x*u.xStep,v=u.y+g*u.yStep;if(!(k>=e||v>=r))for(let M=0;M<a;M++)l[(v*e+k)*a+M]=w[x*a+M]}}}if(s===16){let h=new Uint16Array(l.buffer);if(Za)for(let u=0;u<h.length;u++)h[u]=Ja(h[u]);return h}else return l}function Ja(n){return(n&255)<<8|n>>8&255}var Qa=new Uint16Array([255]),tl=new Uint8Array(Qa.buffer),el=tl[0]===255,nl=new Uint8Array(0);function Pr(n){let{data:t,width:e,height:r,channels:o,depth:s}=n,i=Math.ceil(s/8)*o,a=Math.ceil(s/8*o*e),l=new Uint8Array(r*a),c=nl,h=0,u,d;for(let f=0;f<r;f++){switch(u=t.subarray(h+1,h+1+a),d=l.subarray(f*a,(f+1)*a),t[h]){case 0:In(u,d,a);break;case 1:En(u,d,a,i);break;case 2:Tn(u,d,c,a);break;case 3:Rn(u,d,c,a,i);break;case 4:Fn(u,d,c,a,i);break;default:throw new Error(`Unsupported filter: ${t[h]}`)}c=d,h+=a+1}if(s===16){let f=new Uint16Array(l.buffer);if(el)for(let p=0;p<f.length;p++)f[p]=rl(f[p]);return f}else return l}function rl(n){return(n&255)<<8|n>>8&255}var zn=Uint8Array.of(137,80,78,71,13,10,26,10);function Ir(n){if(!Ps(n.readBytes(zn.length)))throw new Error("wrong PNG signature")}function Ps(n){if(n.length<zn.length)return!1;for(let t=0;t<zn.length;t++)if(n[t]!==zn[t])return!1;return!0}var Is="tEXt",sl=0,Es=new TextDecoder("latin1");function il(n){if(ll(n),n.length===0||n.length>79)throw new Error("keyword length must be between 1 and 79")}var al=/^[\u0000-\u00FF]*$/;function ll(n){if(!al.test(n))throw new Error("invalid latin1 text")}function Ts(n,t,e){let r=Er(t);n[r]=cl(t,e-r.length-1)}function Er(n){for(n.mark();n.readByte()!==sl;);let t=n.offset;n.reset();let e=Es.decode(n.readBytes(t-n.offset-1));return n.skip(1),il(e),e}function cl(n,t){return Es.decode(n.readBytes(t))}var Ot={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},Ze={UNKNOWN:-1,DEFLATE:0},$n={UNKNOWN:-1,ADAPTIVE:0},Je={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},Qe={NONE:0,BACKGROUND:1,PREVIOUS:2},Ln={SOURCE:0,OVER:1};var tn=class extends qe{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;_chunks;_inflatorResult;constructor(t,e={}){super(t);let{checkCrc:r=!1}=e;this._checkCrc=r,this._inflator=new Te((o,s)=>{if(this._chunks.push(o),s){let i=this._chunks.reduce((l,c)=>l+c.length,0);this._inflatorResult=new Uint8Array(i);let a=0;for(let l of this._chunks)this._inflatorResult.set(l,a),a+=l.length;this._chunks=[]}}),this._chunks=[],this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=Ze.UNKNOWN,this._filterMethod=$n.UNKNOWN,this._interlaceMethod=Je.UNKNOWN,this._colorType=Ot.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this._inflatorResult=new Uint8Array(0),this.setBigEndian()}decode(){for(Ir(this);!this._end;){let t=this.readUint32(),e=this.readChars(4);this.decodeChunk(t,e)}return this._inflator.push(new Uint8Array(0),!0),this.decodeImage(),this._png}decodeApng(){for(Ir(this);!this._end;){let t=this.readUint32(),e=this.readChars(4);this.decodeApngChunk(t,e)}return this.decodeApngImage(),this._apng}decodeChunk(t,e){let r=this.offset;switch(e){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(t);break;case"IDAT":this.decodeIDAT(t);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(t);break;case"iCCP":this.decodeiCCP(t);break;case Is:Ts(this._png.text,this,t);break;case"pHYs":this.decodepHYs();break;default:this.skip(t);break}if(this.offset-r!==t)throw new Error(`Length mismatch while decoding chunk ${e}`);this._checkCrc?Sr(this,t+4,e):this.skip(4)}decodeApngChunk(t,e){let r=this.offset;switch(e!=="fdAT"&&e!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),e){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(t);break;default:this.decodeChunk(t,e),this.offset=r+t;break}if(this.offset-r!==t)throw new Error(`Length mismatch while decoding chunk ${e}`);this._checkCrc?Sr(this,t+4,e):this.skip(4)}decodeIHDR(){let t=this._png;t.width=this.readUint32(),t.height=this.readUint32(),t.depth=hl(this.readUint8());let e=this.readUint8();this._colorType=e;let r;switch(e){case Ot.GREYSCALE:r=1;break;case Ot.TRUECOLOUR:r=3;break;case Ot.INDEXED_COLOUR:r=1;break;case Ot.GREYSCALE_ALPHA:r=2;break;case Ot.TRUECOLOUR_ALPHA:r=4;break;case Ot.UNKNOWN:default:throw new Error(`Unknown color type: ${e}`)}if(this._png.channels=r,this._compressionMethod=this.readUint8(),this._compressionMethod!==Ze.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){let t={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(t)}decodePLTE(t){if(t%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${t}`);let e=t/3;this._hasPalette=!0;let r=[];this._palette=r;for(let o=0;o<e;o++)r.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(t){this._writingDataChunks=!0;let e=t,r=this.offset+this.byteOffset;try{this._inflator.push(new Uint8Array(this.buffer,r,e),!1)}catch(o){throw new Error("Error while decompressing the data:",{cause:o})}this.skip(t)}decodeFDAT(t){this._writingDataChunks=!0;let e=t,r=this.offset+this.byteOffset;r+=4,e-=4;try{this._inflator.push(new Uint8Array(this.buffer,r,e),!1)}catch(o){throw new Error("Error while decompressing the data:",{cause:o})}this.skip(t)}decodetRNS(t){switch(this._colorType){case Ot.GREYSCALE:case Ot.TRUECOLOUR:{if(t%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${t}`);if(t/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${t/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(t/2);for(let e=0;e<t/2;e++)this._transparency[e]=this.readUint16();break}case Ot.INDEXED_COLOUR:{if(t>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${t} vs ${this._palette.length})`);let e=0;for(;e<t;e++){let r=this.readByte();this._palette[e].push(r)}for(;e<this._palette.length;e++)this._palette[e].push(255);break}case Ot.UNKNOWN:case Ot.GREYSCALE_ALPHA:case Ot.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(t){let e=Er(this),r=this.readUint8();if(r!==Ze.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${r}`);let o=this.readBytes(t-e.length-2);this._png.iccEmbeddedProfile={name:e,profile:Ms(o)}}decodepHYs(){let t=this.readUint32(),e=this.readUint32(),r=this.readByte();this._png.resolution={x:t,y:e,unit:r}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let t=0;t<this._numberOfFrames;t++){let e={sequenceNumber:this._frames[t].sequenceNumber,delayNumber:this._frames[t].delayNumber,delayDenominator:this._frames[t].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},r=this._frames.at(t);if(r){if(r.data=Pr({data:r.data,width:r.width,height:r.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),t===0||r.xOffset===0&&r.yOffset===0&&r.width===this._png.width&&r.height===this._png.height)e.data=r.data;else{let o=this._apng.frames.at(t-1);this.disposeFrame(r,o,e),this.addFrameDataToCanvas(e,r)}this._apng.frames.push(e)}}return this._apng}disposeFrame(t,e,r){switch(t.disposeOp){case Qe.NONE:break;case Qe.BACKGROUND:for(let o=0;o<this._png.height;o++)for(let s=0;s<this._png.width;s++){let i=(o*t.width+s)*this._png.channels;for(let a=0;a<this._png.channels;a++)r.data[i+a]=0}break;case Qe.PREVIOUS:r.data.set(e.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(t,e){let r=1<<this._png.depth,o=(s,i)=>{let a=((s+e.yOffset)*this._png.width+e.xOffset+i)*this._png.channels,l=(s*e.width+i)*this._png.channels;return{index:a,frameIndex:l}};switch(e.blendOp){case Ln.SOURCE:for(let s=0;s<e.height;s++)for(let i=0;i<e.width;i++){let{index:a,frameIndex:l}=o(s,i);for(let c=0;c<this._png.channels;c++)t.data[a+c]=e.data[l+c]}break;case Ln.OVER:for(let s=0;s<e.height;s++)for(let i=0;i<e.width;i++){let{index:a,frameIndex:l}=o(s,i);for(let c=0;c<this._png.channels;c++){let h=e.data[l+this._png.channels-1]/r,u=c%(this._png.channels-1)===0?1:e.data[l+c],d=Math.floor(h*u+(1-h)*t.data[a+c]);t.data[a+c]+=d}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){let t=this._inflatorResult;if(this._filterMethod!==$n.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===Je.NO_INTERLACE)this._png.data=Pr({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===Je.ADAM7)this._png.data=Ss({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){this._inflator.push(new Uint8Array(0),!0);let t=this._inflatorResult,e=this._frames.at(-1);e?e.data=t:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:Qe.NONE,blendOp:Ln.SOURCE,data:t}),this._inflator=new Te((r,o)=>{if(this._chunks.push(r),o){let s=this._chunks.reduce((a,l)=>a+l.length,0);this._inflatorResult=new Uint8Array(s);let i=0;for(let a of this._chunks)this._inflatorResult.set(a,i),i+=a.length;this._chunks=[]}}),this._chunks=[],this._writingDataChunks=!1}};function hl(n){if(n!==1&&n!==2&&n!==4&&n!==8&&n!==16)throw new Error(`invalid bit depth: ${n}`);return n}function Tr(n,t){return new tn(n,t).decode()}var gt=class extends Error{constructor(t){super(t),this.name="ImageAssetError"}},vt=16*1024*1024,nn=16*1024*1024,Rs="data:image/png;base64,",Rr=Symbol.for("vizmatic.stage.image.runtime.v1"),Fr=globalThis,Fs=Fr[Rr]??Object.freeze({prepared:new WeakSet,browserSources:new WeakMap});Fr[Rr]||Object.defineProperty(Fr,Rr,{value:Fs});var{prepared:$r,browserSources:en}=Fs,zr=new WeakMap,zs=Symbol.for("vizmatic.stage.image.visibility.v1");function $s(n,t){if(t!==void 0){let e=typeof t=="boolean"?t:Object.freeze({width:t.width,height:t.height,bits:Ls(t.mask)});Object.defineProperty(n,zs,{value:e}),zr.set(n,t)}return Object.freeze(n)}function $(n){throw new gt(n)}function Ls(n){let t=[];for(let e=0;e<n.length;e+=8192)t.push(String.fromCharCode(...n.subarray(e,e+8192)));return btoa(t.join(""))}function Vs(n,t="image/png"){return`data:${t};base64,${Ls(n)}`}async function Us(n,t){if(n instanceof Uint8Array)return n.byteLength>vt&&$(`Image asset exceeds ${vt} encoded bytes.`),Uint8Array.from(n);if((typeof n!="string"||!n)&&$("Image asset needs encoded bytes, a PNG data URI, or a local filename."),n.startsWith("data:")){n.startsWith(Rs)||$("Image assets currently support only image/png base64 data URIs.");let a=n.slice(Rs.length);(!a.length||a.length>Math.ceil(vt/3)*4||a.length%4||!/^[A-Za-z0-9+/]+={0,2}$/.test(a))&&$("Image asset contains invalid or oversized base64 data.");let l=Uint8Array.from(atob(a),c=>c.charCodeAt(0));return l.length>vt&&$(`Image asset exceeds ${vt} encoded bytes.`),l}(/^[a-z][\w+.-]*:/i.test(n)||n.startsWith("//"))&&$("Image assets must use local files or embedded bytes; remote URLs are not loaded."),(typeof process>"u"||!process.versions?.node)&&$("Resolve browser image assets from embedded bytes or a data URI before compiling.");let e="node:fs/promises",r="node:path",[o,s]=await Promise.all([import(e),import(r)]),i=s.resolve(t.baseDir??process.cwd(),n);try{(await o.stat(i)).size>vt&&$(`Image asset exceeds ${vt} encoded bytes: ${i}`);let a=await o.readFile(i);return a.length>vt&&$(`Image asset exceeds ${vt} encoded bytes: ${i}`),Uint8Array.from(a)}catch(a){if(a instanceof gt)throw a;$(`Could not read image asset ${JSON.stringify(i)}: ${a.message}`)}}function _s(n,t=!0){let e=[137,80,78,71,13,10,26,10];(n.length<33||e.some((b,w)=>n[w]!==b))&&$("Image asset is not a PNG.");let r=new DataView(n.buffer,n.byteOffset,n.byteLength),o=b=>String.fromCharCode(...n.subarray(b+4,b+8));(r.getUint32(8)!==13||o(8)!=="IHDR")&&$("Image PNG must begin with one IHDR chunk.");let s=r.getUint32(16),i=r.getUint32(20);(!s||!i||s*i>nn)&&$(`Image PNG must contain at most ${nn} pixels with positive dimensions.`);let a={0:1,2:3,3:1,4:2,6:4}[n[25]],l=n[24],c=n[28];t&&(l!==8||c!==0)&&$("Image assets support noninterlaced 8-bit PNGs, including RGB, RGBA, grayscale and palette images.");let h=n[25]===0?[1,2,4,8,16]:n[25]===3?[1,2,4,8]:[8,16];(!a||!h.includes(l)||n[26]!==0||n[27]!==0||c>1)&&$("Image PNG has unsupported header fields.");let d=(c?[[0,0,8,8],[4,0,8,8],[0,4,4,8],[2,0,4,4],[0,2,2,4],[1,0,2,2],[0,1,1,2]]:[[0,0,1,1]]).reduce((b,[w,x,k,v])=>{let M=Math.max(0,Math.ceil((s-w)/k)),A=Math.max(0,Math.ceil((i-x)/v));return b+(M&&A?A*(1+Math.ceil(M*a*l/8)):0)},0),f=0,p=!1,m=!1,g=!1,y=new Te(b=>{f+=b.length,f>d&&$("Image PNG expands beyond its declared dimensions.")});for(let b=8;b+12<=n.length;){let w=r.getUint32(b),x=o(b),k=b+w+12;if(k>n.length&&$("Image PNG chunk exceeds the encoded bytes."),x==="IHDR"&&b!==8&&$("Image PNG has more than one IHDR chunk."),t&&["iCCP","acTL","fcTL","fdAT"].includes(x)&&$("Image assets do not support compressed color profiles or animated PNGs."),x==="iCCP"){let v=b+8;for(;v<k-4&&n[v]!==0;)v++;(v+2>=k-4||n[v+1]!==0)&&$("Image PNG color profile is invalid.");let M=0,A=new Te(C=>{M+=C.length,M>vt&&$("Image PNG color profile exceeds the decoded byte limit.")});for(let C=v+2;C<k-4;C+=1024)A.push(n.subarray(C,Math.min(C+1024,k-4)),!1);A.push(new Uint8Array(0),!0)}if(x==="IDAT"){m&&$("Image PNG data chunks must be consecutive."),p=!0;for(let v=b+8;v<k-4;v+=1024)y.push(n.subarray(v,Math.min(v+1024,k-4)),!1)}else p&&(m=!0);if(x==="IEND"){(w||k!==n.length)&&$("Image PNG has an invalid end chunk."),g=!0;break}b=k}return(!p||!g)&&$("Image PNG is missing its data or end chunk."),y.push(new Uint8Array(0),!0),f!==d&&$("Image PNG scanlines do not match its dimensions."),{width:s,height:i}}async function ul(n,t={}){t.mediaType!==void 0&&t.mediaType!=="image/png"&&$(`Unsupported image asset media type: ${t.mediaType}. Use image/png.`),t.sha256!==void 0&&(typeof t.sha256!="string"||!/^[a-f\d]{64}$/i.test(t.sha256))&&$("Image asset SHA-256 must contain 64 hexadecimal digits."),t.id!==void 0&&(typeof t.id!="string"||!t.id.trim())&&$("Image asset ID must be a nonempty string.");let e=await Us(n,t),r,o;try{r=_s(e);let l=Tr(e,{checkCrc:!0});o=Gs(l),(l.width!==r.width||l.height!==r.height)&&$("Decoded image dimensions differ from the PNG header.")}catch(l){if(l instanceof gt)throw l;$(`Could not decode image asset: ${l.message}`)}for(let l of["width","height"])t[l]!==void 0&&t[l]!==r[l]&&$(`Image asset ${l} is ${r[l]}, not the declared ${t[l]}.`);let s=await globalThis.crypto.subtle.digest("SHA-256",Uint8Array.from(e).buffer),i=Array.from(new Uint8Array(s),l=>l.toString(16).padStart(2,"0")).join("");t.sha256!==void 0&&i!==t.sha256.toLowerCase()&&$(`Image asset SHA-256 mismatch: expected ${t.sha256.toLowerCase()}, received ${i}.`);let a=$s({...t.id?{id:t.id}:{},src:Vs(e),mediaType:"image/png",...r,sha256:i},o);return await Bs(a,e),$r.add(a),a}async function Bs(n,t){let e=n.mediaType==="image/jpeg"&&dl(t)>=5,r=e?n.height:n.width,o=e?n.width:n.height;if(n.mediaType==="image/gif"&&typeof createImageBitmap<"u")try{let s=await createImageBitmap(new Blob([Uint8Array.from(t).buffer],{type:n.mediaType}));(s.width!==r||s.height!==o)&&$("Browser image dimensions differ from the validated asset."),en.set(n,s)}catch(s){if(s instanceof gt)throw s;$(`Browser could not decode image asset: ${s.message}`)}else if(typeof Image<"u"){let s=new Image;s.src=n.src;try{await s.decode()}catch(i){$(`Browser could not decode image asset: ${i.message}`)}if((s.naturalWidth!==r||s.naturalHeight!==o)&&$("Browser image dimensions differ from the validated asset."),n.mediaType==="image/gif"){let i=document.createElement("canvas");i.width=n.width,i.height=n.height,i.getContext("2d").drawImage(s,0,0),en.set(n,i)}else en.set(n,s)}else if(typeof createImageBitmap<"u")try{let s=await createImageBitmap(new Blob([Uint8Array.from(t).buffer],{type:n.mediaType}));(s.width!==r||s.height!==o)&&$("Browser image dimensions differ from the validated asset."),en.set(n,s)}catch(s){if(s instanceof gt)throw s;$(`Browser could not decode image asset: ${s.message}`)}}function dl(n){let t=new DataView(n.buffer,n.byteOffset,n.byteLength);for(let e=2;e+4<=n.length&&n[e++]===255;){for(;n[e]===255;)e++;let r=n[e++];if(r===218||r===217||e+2>n.length)break;let o=t.getUint16(e),s=e+2,i=e+o;if(o<2||i>n.length)break;if(r===225&&i-s>=14&&String.fromCharCode(...n.subarray(s,s+6))==="Exif\0\0"){let a=s+6,l=t.getUint16(a),c=l===18761;if(![18761,19789].includes(l)||t.getUint16(a+2,c)!==42)return 1;let h=a+t.getUint32(a+4,c);if(h<a+8||h+2>i)return 1;let u=t.getUint16(h,c);for(let d=h+2;d+12<=i&&d<h+2+u*12;d+=12)if(t.getUint16(d,c)===274&&t.getUint16(d+2,c)===3&&t.getUint32(d+4,c)===1){let f=t.getUint16(d+8,c);return f>=1&&f<=8?f:1}}e=i}return 1}async function Ds(n,t){let e,r;if(n.startsWith("data:")){let c=/^data:(image\/(?:png|jpe?g|gif));base64,([A-Za-z0-9+/]+={0,2})$/.exec(n);(!c||c[2].length%4||c[2].length>Math.ceil(vt/3)*4)&&$("Image contains invalid, unsupported or oversized base64 data."),r=c[1]==="image/jpg"?"image/jpeg":c[1],e=Uint8Array.from(atob(c[2]),h=>h.charCodeAt(0))}else if(/^https?:\/\//i.test(n)||n.startsWith("//")||typeof window<"u"){let c=typeof process<"u"&&(process.env?.VIZMATIC_DISABLE_NETWORK==="1"||process.env?.VIZMATIC_OFFLINE==="1");(!t||c)&&$("Network image loading is disabled by imageNetwork: deny or the offline environment.");try{let h=typeof document<"u"?new URL(n,document.baseURI).href:n;/^https?:\/\//i.test(h)||$("Network images require an HTTP or HTTPS URL.");let u=await fetch(h,{signal:AbortSignal.timeout(1e4)});u.ok||$(`Image request failed with HTTP ${u.status}: ${h}`);let d=u.headers.get("content-length");d&&Number(d)>vt&&$(`Image exceeds ${vt} encoded bytes.`),r=u.headers.get("content-type")?.split(";")[0].trim();let f=u.body?.getReader();f||$("Image request returned no body.");let p=[],m=0;for(;;){let{value:y,done:b}=await f.read();if(b)break;m+=y.length,m>vt&&(await f.cancel(),$(`Image exceeds ${vt} encoded bytes.`)),p.push(y)}e=new Uint8Array(m);let g=0;for(let y of p)e.set(y,g),g+=y.length}catch(h){if(h instanceof gt)throw h;$(`Could not load image ${JSON.stringify(n)}: ${h.message}`)}}else e=await Us(n,{});let{visible:o,...s}=fl(e);r?.startsWith("image/")&&r!==s.mediaType&&$(`Image MIME type ${r} does not match ${s.mediaType} bytes.`);let i=await crypto.subtle.digest("SHA-256",Uint8Array.from(e).buffer),a=Array.from(new Uint8Array(i),c=>c.toString(16).padStart(2,"0")).join(""),l=$s({src:Vs(e,s.mediaType),sha256:a,...s},o);if(typeof process<"u"&&process.versions?.node){let c="@resvg/resvg-js",{Resvg:h}=await import(c);try{let u=new h(`<svg xmlns="http://www.w3.org/2000/svg" width="${l.width}" height="${l.height}"><image width="${l.width}" height="${l.height}" href="${l.src}"/></svg>`,{font:{loadSystemFonts:!1}});u.innerBBox()||$("Image decoder rejected the encoded image.");let d=u.render();l.mediaType==="image/jpeg"&&!d.pixels.some((f,p)=>p%4===3&&f>0)&&$("Image decoder rejected the JPEG pixel data.")}catch(u){if(u instanceof gt)throw u;$(`Could not decode image: ${u.message}`)}}return await Bs(l,e),$r.add(l),l}function fl(n){(!n.length||n.length>vt)&&$("Image bytes are empty or oversized.");let t=new DataView(n.buffer,n.byteOffset,n.byteLength),e=0,r=0,o,s;if(n.length>=33&&[137,80,78,71,13,10,26,10].every((i,a)=>n[a]===i)){o="image/png";try{({width:e,height:r}=_s(n,!1)),s=Gs(Tr(n,{checkCrc:!0}))}catch(i){if(i instanceof gt)throw i;$(`Could not decode image PNG: ${i.message}`)}}else if(n.length>=14&&/^GIF8[79]a$/.test(String.fromCharCode(...n.subarray(0,6)))){e=t.getUint16(6,!0),r=t.getUint16(8,!0),o="image/gif";let i=13+(n[10]&128?3*2**((n[10]&7)+1):0),a=0,l=!1,c=(h=!1)=>{let u=[],d=0;for(;;){i>=n.length&&$("Image GIF data is truncated.");let m=n[i++];if(!m)break;h&&(u.push(n.subarray(i,i+m)),d+=m),i+=m,i>n.length&&$("Image GIF block exceeds the encoded bytes.")}let f=new Uint8Array(d),p=0;for(let m of u)f.set(m,p),p+=m.length;return f};for(;i<n.length;){let h=n[i++];if(h===59){l=!0;break}if(h===33)i++,c();else if(h===44){i+9>n.length&&$("Image GIF descriptor is truncated.");let u=t.getUint16(i+4,!0),d=t.getUint16(i+6,!0),f=n[i+8];(!u||!d||u*d>nn)&&$("Image GIF frame dimensions are invalid."),i+=9+(f&128?3*2**((f&7)+1):0),(n[i]<2||n[i]>8)&&$("Image GIF compression code size is invalid.");let p=n[i++];pl(c(!0),p,u*d),a++}else $("Image GIF contains an invalid block.")}(!a||!l)&&$("Image GIF is missing its frame data or trailer.")}else if(n[0]===255&&n[1]===216){o="image/jpeg";for(let i=2;i+3<n.length;){for(n[i++]!==255&&$("Image JPEG contains an invalid marker.");n[i]===255;)i++;i+3>n.length&&$("Image JPEG marker is truncated.");let a=n[i++];if(a===218||a===217)break;let l=t.getUint16(i);(l<2||i+l>n.length)&&$("Image JPEG segment is truncated."),a>=192&&a<=207&&![196,200,204].includes(a)&&(l<8&&$("Image JPEG frame is truncated."),r=t.getUint16(i+3),e=t.getUint16(i+5)),i+=l}n.some((i,a)=>a>0&&i===217&&n[a-1]===255)||$("Image JPEG is missing its end marker.")}else $("Image bytes are not a supported PNG, JPEG or GIF.");return(!e||!r||e*r>nn)&&$(`Image must contain at most ${nn} pixels with positive dimensions.`),{width:e,height:r,mediaType:o,visible:s}}function Gs(n){let{width:t,height:e,channels:r,depth:o,data:s,palette:i,transparency:a}=n;if(r!==2&&r!==4&&!i&&!a)return!0;let l=new Uint8Array(Math.ceil(t*e/8)),c=(u,d,f=0)=>o>=8?s[(d*t+u)*r+f]:s[d*Math.ceil(t*o/8)+(u*o>>3)]>>8-o-u*o%8&(1<<o)-1,h=0;for(let u=0;u<e;u++)for(let d=0;d<t;d++){let f;if(r===2||r===4)f=c(d,u,r-1)>0;else if(i){let p=i[c(d,u)];p||$("Image PNG references a missing palette color."),f=(p[3]??255)>0}else f=!a.every((p,m)=>c(d,u,m)===p);if(f){let p=u*t+d;l[p>>3]|=1<<(p&7),h++}}return h===0?!1:h===t*e?!0:{width:t,height:e,mask:l,crops:new Map}}function rn(n,t){let e=n?zr.get(n):void 0;if(e===void 0&&n){let s=n[zs];e=typeof s=="boolean"?s:s?{width:s.width,height:s.height,mask:Uint8Array.from(atob(s.bits),i=>i.charCodeAt(0)),crops:new Map}:void 0,e!==void 0&&zr.set(n,e)}if(e===void 0)return!0;if(typeof e=="boolean")return e;if(!t||t.x===0&&t.y===0&&t.width===e.width&&t.height===e.height)return!0;let r=`${t.x},${t.y},${t.width},${t.height}`,o=e.crops.get(r);if(o!==void 0)return o;for(let s=Math.floor(t.y);s<Math.ceil(t.y+t.height);s++)for(let i=Math.floor(t.x);i<Math.ceil(t.x+t.width);i++){let a=s*e.width+i;if(e.mask[a>>3]&1<<(a&7))return e.crops.set(r,!0),!0}return e.crops.set(r,!1),!1}function pl(n,t,e){let r=1<<t,o=r+1,s=new Uint16Array(4096),i=t+1,a=o+1,l=0,c=0,h=0;for(;;){c+i>n.length*8&&$("Image GIF compressed data is truncated.");let u=0;for(let f=0;f<i;f++)u|=(n[c+f>>3]>>(c+f&7)&1)<<f;if(c+=i,u===r){i=t+1,a=o+1,l=0;continue}if(u===o){h!==e&&$("Image GIF decoded length does not match its frame dimensions.");return}let d=u<r?1:u<a?s[u]:u===a&&l?l+1:0;d||$("Image GIF contains an invalid compression reference."),h+=d,h>e&&$("Image GIF expands beyond its frame dimensions."),l&&a<4096&&(s[a++]=l+1,a===1<<i&&i<12&&i++),l=d}}function Vn(n){return!!n&&typeof n=="object"&&$r.has(n)}function Un(n){return n?en.get(n):void 0}function on(n,t){[n.width,n.height].every(r=>Number.isFinite(r)&&r>0)||$("Image destination dimensions must be positive finite numbers.");let e=n.crop;e&&(![e.x,e.y,e.width,e.height].every(Number.isFinite)||e.x<0||e.y<0||e.width<=0||e.height<=0||e.x+e.width>t.width||e.y+e.height>t.height)&&$("Image crop must be a nonempty region inside the intrinsic image pixels.")}function Ws(n,t={}){Vn(n)||$("Call and await resolveImageAsset before creating an image node."),t.fit!==void 0&&t.fit!=="contain"&&t.fit!=="cover"&&$("Image fit must be contain or cover.");let e={...t.crop??{x:0,y:0,width:n.width,height:n.height}},r=t.width??(t.height===void 0?e.width:t.height*e.width/e.height),o=t.height??r*e.height/e.width;if(on({src:n.src,width:r,height:o,crop:e},n),t.fit==="cover"){let i=r/o;if(e.width/e.height>i){let l=e.height*i;e={...e,x:e.x+(e.width-l)/2,width:l}}else{let l=e.width/i;e={...e,y:e.y+(e.height-l)/2,height:l}}}else{let i=Math.min(r/e.width,o/e.height);r=e.width*i,o=e.height*i}let s=new N().set("image",Object.freeze({src:n.src,width:r,height:o,crop:Object.freeze(e),asset:n}));return s.set("px",r/2).set("py",o/2),s.label=n.id??"image",s}var ml=()=>E.now,gl=14,bl=96;function js(n,t){return!n||!kt(n)?n:n.type==="linear"?{...n,from:tt(t,n.from[0],n.from[1]),to:tt(t,n.to[0],n.to[1])}:n.type==="radial"?{...n,center:tt(t,n.center[0],n.center[1]),radius:n.radius*ee(t)}:n}function yl(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]&&n[4]===t[4]&&n[5]===t[5]}var Hs=new WeakMap;function wl(n,t,e){let r=Hs.get(n);if(r&&r.path===t&&yl(r.matrix,e))return r.world;let o=at(t,e);return Hs.set(n,{path:t,matrix:e,world:o}),o}function xl(n,t,e,r,o){let s=n.get("fill"),i=n.get("stroke"),a=s?r*n.get("fillOpacity"):0,l=i?r*n.get("strokeOpacity"):0,c=n.get("glow");if(a<=.002&&l<=.002&&c<=0)return;let h=wl(n,t,e),u=ee(e),d=n.get("trimFrom"),f=n.get("trimTo"),p=h;if((d>0||f<1)&&(p=ae(h,d,f,n.get("trimEach"))),p.length===0&&a<=.002)return;let m=n.get("dash"),g={kind:"path",path:h,strokePath:p,fill:a>.002?js(s,e):null,fillAlpha:a,stroke:l>.002?js(i,e):null,strokeAlpha:l,strokeWidth:n.get("strokeWidth")*u,cap:n.get("cap"),join:n.get("join"),dash:m?m.map(y=>y*u):null,dashOffset:n.get("dashOffset")*u,glow:c*u,glowColor:n.get("glowColor"),blend:n.get("blend"),node:n};g.stroke&&kt(g.stroke)&&g.stroke.type==="along"?kl(g,g.stroke,o):o.push(g)}function kl(n,t,e){e.push({...n,stroke:null,strokeAlpha:0});let r={...n,fill:null,fillAlpha:0,glow:0},o=Tt(n.strokePath),s=Tt(n.path);if(o===0)return;let i=s>0?Math.min(1,o/s):1,a=Math.min(bl,Math.max(2,Math.ceil(o/gl))),l=.6/a;for(let c=0;c<a;c++){let h=c/a,u=Math.min(1,(c+1)/a+l),d=ae(n.strokePath,h,u);d.length!==0&&e.push({...r,strokePath:d,path:d,stroke:ht(t.stops,(c+.5)/a*i),cap:c===0||c===a-1?n.cap:"butt"})}}function Vr(n,t,e,r,o){if(!n.get("visible"))return;let s=n.get("opacity")*r;if(s<=.002)return;let i=n.get("fixed")?e:t,a=it(i,n.localMatrix()),l=n.get("path");l&&l.length>0&&xl(n,l,a,s,o);let c=n.get("image");if(c&&o.push({kind:"image",image:c,matrix:a,alpha:s,node:n}),n.rawOps&&n.rawOps(a,s,o),n.draw){let f=n.draw(ml());if(f){let p=Array.isArray(f)?f:[f];for(let m of p)Vr(m,a,e,s,o)}}let h=n.children;if(h.length===0)return;let u=!1;for(let f=0;f<h.length;f++)if(h[f].get("z")!==0){u=!0;break}let d=u?h.map((f,p)=>({child:f,index:p,z:f.get("z")})).sort((f,p)=>f.z-p.z||f.index-p.index).map(f=>f.child):h;for(let f of d)Vr(f,a,e,s,o)}function Ur(n,t,e,r){let o=[1,0,0,1,e/2,r/2],s=it(o,Oe(0,0,-t.rotation,t.zoom,t.zoom,t.x,t.y)),i=[];return Vr(n,s,o,1,i),i}var Ks=7;function Js(n,t){let e=[];for(let r=Ks;r>=1;r--){let o=r/Ks;e.push({width:t+n*2*o,alpha:.16*(1-o)*(1-o)+.018})}return e}function Qs(n){if(n.glowColor)return n.glowColor;let t=n.stroke??n.fill;return t?kt(t)?ht(t.stops,.5):t:null}var Xs=new WeakMap;function _n(n){let t=Xs.get(n);return t===void 0&&(t=Ko(n),Xs.set(n,t)),t}function dt(n){return String(Math.round(n*1e3)/1e3)}function vl(n,t){let e=t.stops.map(([r,o])=>`<stop offset="${dt(r)}" stop-color="${ne([o[0],o[1],o[2],1])}"${o[3]<1?` stop-opacity="${dt(o[3])}"`:""}/>`).join("");return t.type==="linear"?`<linearGradient id="${n}" gradientUnits="userSpaceOnUse" x1="${dt(t.from[0])}" y1="${dt(t.from[1])}" x2="${dt(t.to[0])}" y2="${dt(t.to[1])}">${e}</linearGradient>`:t.type==="radial"?`<radialGradient id="${n}" gradientUnits="userSpaceOnUse" cx="${dt(t.center[0])}" cy="${dt(t.center[1])}" r="${dt(t.radius)}">${e}</radialGradient>`:""}function Ys(n){let t=` stroke-linecap="${n.cap}" stroke-linejoin="${n.join}"`;return n.dash&&(t+=` stroke-dasharray="${n.dash.map(dt).join(" ")}" stroke-dashoffset="${dt(n.dashOffset)}"`),t}function Ml(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function _r(n,t={}){let e=t.scale??1,r=n.width,o=n.height,s=[],i=[],a=0,l=(h,u,d)=>{if(kt(h)){let m=`g${a++}`;return s.push(vl(m,h)),`${u}="url(#${m})"${d<1?` ${u}-opacity="${dt(d)}"`:""}`}let f=h,p=f[3]*d;return`${u}="${ne([f[0],f[1],f[2],1])}"${p<1?` ${u}-opacity="${dt(p)}"`:""}`};n.background&&!t.transparent&&i.push(`<rect width="${r}" height="${o}" fill="${n.background}"/>`);for(let h of n.ops){if(h.kind==="image"){let d=h.matrix,{image:f}=h,p=f.crop;if(p&&!f.asset)throw new gt("Cropped image SVG needs a prepared image asset.");let m=`<image href="${Ml(f.src)}" width="${p?f.asset.width:f.width}" height="${p?f.asset.height:f.height}" preserveAspectRatio="none"/>`,g=p?`<svg width="${dt(f.width)}" height="${dt(f.height)}" viewBox="${[p.x,p.y,p.width,p.height].map(dt).join(" ")}" preserveAspectRatio="none" overflow="hidden">${m}</svg>`:m;i.push(`<g transform="matrix(${d.map(dt).join(" ")})"${h.alpha<1?` opacity="${dt(h.alpha)}"`:""}>${g}</g>`);continue}let u=h.blend!=="normal"?` style="mix-blend-mode:${h.blend}"`:"";if(h.glow>0){let d=Qs(h),f=_n(h.strokePath.length?h.strokePath:h.path);if(d&&f){let p=Math.max(h.fillAlpha,h.strokeAlpha),m=n.dark?' style="mix-blend-mode:screen"':"",g=Js(h.glow,h.stroke?h.strokeWidth:0).map(y=>`<path d="${f}" fill="none" stroke="${ne([d[0],d[1],d[2],1])}" stroke-opacity="${dt(y.alpha*p)}" stroke-width="${dt(y.width)}" stroke-linecap="round" stroke-linejoin="round"/>`).join("");i.push(`<g${m}>${g}</g>`)}}if(h.fill&&h.stroke&&h.strokePath===h.path){i.push(`<path d="${_n(h.path)}" ${l(h.fill,"fill",h.fillAlpha)} ${l(h.stroke,"stroke",h.strokeAlpha)} stroke-width="${dt(h.strokeWidth)}"${Ys(h)}${u}/>`);continue}h.fill&&i.push(`<path d="${_n(h.path)}" ${l(h.fill,"fill",h.fillAlpha)}${u}/>`),h.stroke&&h.strokePath.length&&i.push(`<path d="${_n(h.strokePath)}" fill="none" ${l(h.stroke,"stroke",h.strokeAlpha)} stroke-width="${dt(h.strokeWidth)}"${Ys(h)}${u}/>`)}let c=s.length?`<defs>${s.join("")}</defs>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${r*e}" height="${o*e}" viewBox="0 0 ${r} ${o}">${c}${i.join("")}</svg>`}var qs=new WeakMap;function Lr(n){let t=qs.get(n);if(t)return t;t=new Path2D;for(let e of n){let r=e.p;if(!(r.length<2)){if(t.moveTo(r[0],r[1]),e.straight)for(let o=2;o+5<r.length;o+=6)t.lineTo(r[o+4],r[o+5]);else for(let o=2;o+5<r.length;o+=6)t.bezierCurveTo(r[o],r[o+1],r[o+2],r[o+3],r[o+4],r[o+5]);e.closed&&t.closePath()}}return qs.set(n,t),t}function Zs(n,t){if(!kt(t))return ne(t);let e=t.type==="linear"?n.createLinearGradient(t.from[0],t.from[1],t.to[0],t.to[1]):t.type==="radial"?n.createRadialGradient(t.center[0],t.center[1],0,t.center[0],t.center[1],t.radius):null;if(!e)return ne(ht(t.stops,.5));for(let[r,o]of t.stops)e.addColorStop(r,ne(o));return e}var Al={normal:"source-over",screen:"screen",multiply:"multiply",overlay:"overlay"};function Br(n,t,e=1,r){n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.globalCompositeOperation="source-over",n.clearRect(0,0,t.width*e,t.height*e),n.setTransform(e,0,0,e,0,0),t.background&&(n.fillStyle=t.background,n.fillRect(0,0,t.width,t.height));for(let o of t.ops){if(o.kind==="image"){let s=r?.(o.image)??Un(o.image.asset);if(!s)throw new gt("Image pixels are unavailable. Await image preparation and provide an ImageLookup outside the browser.");let i=o.matrix;n.save(),n.transform(i[0],i[1],i[2],i[3],i[4],i[5]),n.globalAlpha=o.alpha,n.globalCompositeOperation="source-over";let a=o.image.crop;a?n.drawImage(s,a.x,a.y,a.width,a.height,0,0,o.image.width,o.image.height):n.drawImage(s,0,0,o.image.width,o.image.height),n.restore();continue}if(n.globalCompositeOperation=Al[o.blend],o.glow>0){let s=Qs(o);if(s){let i=Math.max(o.fillAlpha,o.strokeAlpha),a=n.globalCompositeOperation;t.dark&&(n.globalCompositeOperation="screen"),n.strokeStyle=ne([s[0],s[1],s[2],1]),n.lineCap="round",n.lineJoin="round",n.setLineDash([]);let l=Lr(o.strokePath.length?o.strokePath:o.path);for(let c of Js(o.glow,o.stroke?o.strokeWidth:0))n.globalAlpha=c.alpha*i,n.lineWidth=c.width,n.stroke(l);n.globalCompositeOperation=a}}o.fill&&(n.globalAlpha=o.fillAlpha,n.fillStyle=Zs(n,o.fill),n.fill(Lr(o.path))),o.stroke&&o.strokePath.length&&(n.globalAlpha=o.strokeAlpha,n.strokeStyle=Zs(n,o.stroke),n.lineWidth=o.strokeWidth,n.lineCap=o.cap,n.lineJoin=o.join,n.setLineDash(o.dash?[...o.dash]:[]),n.lineDashOffset=o.dashOffset,n.stroke(Lr(o.strokePath)))}n.globalAlpha=1,n.globalCompositeOperation="source-over"}function Nl(n){let t=null;for(let e of n.ops){if(e.kind==="image"&&!rn(e.image.asset,e.image.crop))continue;let r=e.kind==="image"?Bn(e):wt(e.path);if(!r)continue;let o=e.kind==="path"&&e.stroke?e.strokeWidth/2:0,s={x:r.x-o,y:r.y-o,width:r.width+o*2,height:r.height+o*2};if(!t)t=s;else{let i=Math.min(t.x,s.x),a=Math.min(t.y,s.y);t={x:i,y:a,width:Math.max(t.x+t.width,s.x+s.width)-i,height:Math.max(t.y+t.height,s.y+s.height)-a}}}return t}function Bn(n){let{width:t,height:e}=n.image,r=[[0,0],[t,0],[0,e],[t,e]].map(([l,c])=>tt(n.matrix,l,c)),o=r.map(l=>l[0]),s=r.map(l=>l[1]),i=Math.min(...o),a=Math.min(...s);return{x:i,y:a,width:Math.max(...o)-i,height:Math.max(...s)-a}}var Cl={"16:9":[1920,1080],"9:16":[1080,1920],"1:1":[1080,1080],"4:3":[1440,1080],"21:9":[2520,1080]},Re=class{root=new N;camera=new N;width;height;fps;look;chapters=[];clips=[];captions=[];updaters=[];time=0;ending=0;constructor(t){let[e,r]=Cl[t.aspect??"16:9"];this.width=t.width??e,this.height=t.height??r,this.fps=t.fps??60,this.look=xn(t.look),this.root.mounted=!0,this.camera.mounted=!0}get right(){return this.width/2}get left(){return-this.width/2}get top(){return-this.height/2}get bottom(){return this.height/2}add(t,...e){E.now=this.time;for(let r of[t,...e])r.mounted?r.get("visible")||r.track("visible").step(this.time,!0):(r.parent?.drop(r),r.parent=this.root,this.root.children.push(r),Nn(r,this.time));return t}mountAt(t,e){t.mounted||(t.parent?.drop(t),t.parent=this.root,this.root.children.push(t),Nn(t,e))}remove(...t){for(let e of t)e.track("visible").step(this.time,!1)}play(...t){let e=t.filter(l=>"schedule"in l),r=t.find(l=>!("schedule"in l))??{};if(e.length===0)return this;let o=Math.max(...e.map(l=>l.duration)),s=r.duration??o,i=this.time,a=i+s;for(let l of e){E.now=i;let c=r.duration!==void 0?a:i+l.duration;l.schedule({t0:i,t1:c,ease:r.ease??l.ease??mt,stage:this})}return this.clips.push({t0:i,t1:a,labels:r.label?[r.label]:e.map(l=>l.label)}),this.time=a,this.ending=Math.max(this.ending,a),E.now=a,this}wait(t=1){return this.time+=t,this.ending=Math.max(this.ending,this.time),E.now=this.time,this}at(t,e){let r=this.time;return this.time=t,E.now=t,e(),this.ending=Math.max(this.ending,this.time),this.time=r,E.now=r,this}chapter(t){return this.chapters.push({title:t,time:this.time}),this}caption(t,e=3){return this.captions.push({t0:this.time,t1:this.time+e,text:t}),this.ending=Math.max(this.ending,this.time+e),this}value(t=0){return new yt(t)}update(t,e,r={}){return this.updaters.push({node:t,fn:e,from:r.from??this.time,to:r.to??1/0}),t}get duration(){return Math.max(this.ending,this.time)}};function Ol(n,t){let e=typeof n=="function"?{}:n,r=typeof n=="function"?n:t;if(!r)throw new Error("film(options, build) needs a build function.");let o={kind:"vizmatic.film",options:e,build:r,compile:s=>Gn(o,s)};return o}function Ae(n){return!!n&&typeof n=="object"&&n.kind==="vizmatic.film"}var It=class{constructor(t){this.promise=t}promise;isVizmaticSuspend=!0};function Dr(n){return typeof n=="object"&&n!==null&&n.isVizmaticSuspend===!0}var Dn=class{allowImageNetwork;imageAssets=new Map;imageLoads=new Map;width;height;fps;duration;title;description;look;bloom;background;posterTime;bleed;chapters;clips;captions;stage;constructor(t,e,r){this.allowImageNetwork=(r.imageNetwork??e.imageNetwork??"allow")==="allow",this.stage=t,this.width=t.width,this.height=t.height,this.fps=r.fps??t.fps,this.duration=Math.max(t.duration,1/this.fps),this.title=e.title??"",this.description=e.description??"",this.look=t.look,this.bloom=r.bloom??e.bloom??t.look.bloom;let o=r.background!==void 0?r.background:e.background!==void 0?e.background:t.look.background;this.background=o===null?null:t.look.colors[o]??o,this.posterTime=e.poster,this.bleed=e.bleed===!0,this.chapters=t.chapters,this.clips=t.clips,this.captions=t.captions}get frameCount(){return Math.max(1,Math.round(this.duration*this.fps))}async prepareImage(t){if(t.asset){if(!Vn(t.asset))throw new gt("Image asset was not prepared by resolveImageAsset.");return on(t,t.asset),t.asset}let e=this.imageLoads.get(t.src);e||(e=Ds(t.src,this.allowImageNetwork).then(o=>(this.imageAssets.set(t.src,o),o)),this.imageLoads.set(t.src,e));let r=await e;return on(t,r),r}async preloadImages(){for(let t of this.stage.root.all()){let e=t.tracks?.get("image"),r=[t.base.image,e?.initial,...e?.keys.map(o=>o.to)??[]];for(let o of r)o&&await this.prepareImage(o)}}frame(t){let e=Math.max(0,Math.min(this.duration,t)),r=this.stage,o={mode:E.mode,now:E.now};mr(r.look.colors),E.mode="render",E.now=e,E.frame++;try{for(let l of r.updaters)e>=l.from&&e<=l.to&&l.fn(l.node,e);let s=r.camera,a=Ur(r.root,{x:s.get("x"),y:s.get("y"),zoom:s.get("sx"),rotation:s.get("rotation")},r.width,r.height).map(l=>{if(l.kind!=="image")return l;let c=l.image.asset??this.imageAssets.get(l.image.src);if(!c)throw new It(this.prepareImage(l.image));if(!Vn(c))throw new gt("Image asset was not prepared by resolveImageAsset.");return on(l.image,c),{...l,image:{...l.image,src:c.src,asset:c}}});return{width:r.width,height:r.height,background:this.background,bloom:this.bloom,dark:r.look.dark,ops:a}}finally{E.mode=o.mode,E.now=o.now}}svg(t,e={}){return _r(this.frame(t),e)}};async function Gn(n,t={}){let e={...n.options,...t.look?{look:t.look}:{},...t.fps?{fps:t.fps}:{}};for(let r=0;r<64;r++){let o=new Re(e);mr(o.look.colors);let s={mode:E.mode,now:E.now};E.mode="compile",E.now=0;try{await n.build(o),E.mode=s.mode,E.now=s.now;let i=new Dn(o,e,t);return await i.preloadImages(),await Sl(i),i}catch(i){if(E.mode=s.mode,E.now=s.now,E.capture=null,i instanceof It){await i.promise;continue}throw i}}throw new Error("The film kept requesting new assets while compiling.")}async function Sl(n){let t=[0,.25,.5,.75,1];for(let e of t)for(let r=0;r<16;r++)try{n.frame(n.duration*e);break}catch(o){if(!(o instanceof It))throw o;await o.promise}}function ti(n){return{contours:n.filter(t=>t.length>=8)}}var ei=null;function Gr(n){ei=n}var Pl=typeof process<"u"&&!!process.versions?.node&&typeof globalThis.document>"u";function ni(){let n=import.meta.url;return n||`file://${typeof __filename<"u"?__filename:""}`}async function Il(n){let t="node:fs/promises",e="node:path",r="node:url",[o,s,i]=await Promise.all([import(t),import(e),import(r)]),a=s.dirname(i.fileURLToPath(ni()));for(let l=0;l<6;l++){let c=s.join(a,"assets",n);try{let h=await o.readFile(c);return h.buffer.slice(h.byteOffset,h.byteOffset+h.byteLength)}catch(h){if(h.code!=="ENOENT")throw h}a=s.dirname(a)}throw new Error(`Bundled asset not found: assets/${n}`)}async function ri(n){if(Pl)return Il(n);let t=ei??new URL("./assets/",ni()).href,e=await fetch(new URL(n,t)),r=e.headers.get("content-type")??"";if(!e.ok||r.includes("text/html"))throw new Error(`Could not load ${n} from ${e.url} (HTTP ${e.status}, ${r||"no content type"}). Call setAssetBase() with the folder that holds fonts/.`);return e.arrayBuffer()}var jr=class{constructor(t,e=0){this.bytes=t;this.offset=e;this.view=new DataView(t)}bytes;offset;view;seek(t){return this.offset=t,this}get position(){return this.offset}u8(){return this.view.getUint8(this.offset++)}i8(){return this.view.getInt8(this.offset++)}u16(){let t=this.view.getUint16(this.offset);return this.offset+=2,t}i16(){let t=this.view.getInt16(this.offset);return this.offset+=2,t}u32(){let t=this.view.getUint32(this.offset);return this.offset+=4,t}tag(){let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.u8());return t}};function ci(n){let t=new jr(n),e=t.u32();if(e!==65536&&e!==1953658213)throw new Error("Stage text needs a TrueType (.ttf) font with glyf outlines.");let r=t.u16();t.seek(12);let o=new Map;for(let A=0;A<r;A++){let C=t.tag();t.u32(),o.set(C,{offset:t.u32(),length:t.u32()})}let s=A=>{let C=o.get(A);if(!C)throw new Error(`Font is missing its ${A} table.`);return C},i=s("head");t.seek(i.offset+18);let a=t.u16();t.seek(i.offset+50);let l=t.i16()===1,c=s("hhea");t.seek(c.offset+4);let h=t.i16(),u=t.i16(),d=t.i16();t.seek(c.offset+34);let f=t.u16();t.seek(s("maxp").offset+4);let p=t.u16(),m=s("hmtx"),g=s("loca"),y=s("glyf"),b=Tl(t,s("cmap").offset),w=o.has("GPOS")?Rl(t,o.get("GPOS").offset):()=>0,x=A=>{let C=Math.min(A,f-1);return t.seek(m.offset+C*4),t.u16()},k=new Map,v=(A,C)=>{if(A>=p||C>6)return[];t.seek(g.offset+(l?A*4:A*2));let O=l?t.u32():t.u16()*2,P=l?t.u32():t.u16()*2;if(O===P)return[];t.seek(y.offset+O);let L=t.i16();if(t.seek(t.position+8),L<0)return M(A,C);let F=[];for(let I=0;I<L;I++)F.push(t.u16());let _=t.u16();t.seek(t.position+_);let B=(F[F.length-1]??-1)+1,D=[];for(;D.length<B;){let I=t.u8();if(D.push(I),I&8){let U=t.u8();for(;U-- >0;)D.push(I)}}let K=new Array(B),S=0;for(let I=0;I<B;I++){let U=D[I];if(U&2){let W=t.u8();S+=U&16?W:-W}else U&16||(S+=t.i16());K[I]=S}let V=new Array(B),R=0;for(let I=0;I<B;I++){let U=D[I];if(U&4){let W=t.u8();R+=U&32?W:-W}else U&32||(R+=t.i16());V[I]=R}let T=[],z=0;for(let I of F)T.push(El(K,V,D,z,I)),z=I+1;return T};function M(A,C){let O=[],P=!0;for(;P;){let F=t.u16(),_=t.u16(),B=(F&1)!==0,D=(F&2)!==0,K=0,S=0;B?(K=t.i16(),S=t.i16()):(K=t.i8(),S=t.i8()),D||(K=0,S=0);let V=1,R=0,T=0,z=1,I=()=>t.i16()/16384;F&8?V=z=I():F&64?(V=I(),z=I()):F&128&&(V=I(),R=I(),T=I(),z=I()),O.push({glyph:_,m:[V,R,T,z,K,S]}),P=(F&32)!==0}let L=[];for(let F of O)for(let _ of v(F.glyph,C+1)){let B=new Array(_.length),[D,K,S,V,R,T]=F.m;for(let z=0;z<_.length;z+=2)B[z]=D*_[z]+S*_[z+1]+R,B[z+1]=K*_[z]+V*_[z+1]+T;L.push(B)}return L}return{unitsPerEm:a,ascent:h,descent:u,lineGap:d,glyphFor(A){return b(A)},advance:x,kern(A,C){return w(A,C)},outline(A){if(k.has(A))return k.get(A);let C=v(A,0),O=C.length?ti(C):null;return k.set(A,O),O}}}function El(n,t,e,r,o){let s=o-r+1;if(s<2)return[];let i=w=>r+(w%s+s)%s,a=w=>(e[i(w)]&1)!==0,l=0;for(;l<s&&!a(l);)l++;let c,h;l===s?(c=(n[i(0)]+n[i(s-1)])/2,h=(t[i(0)]+t[i(s-1)])/2,l=0):(c=n[i(l)],h=t[i(l)],l+=1);let u=[c,h],d=c,f=h,p=0,m=0,g=!1,y=(w,x,k,v)=>{u.push(d+(w-d)*2/3,f+(x-f)*2/3,k+(w-k)*2/3,v+(x-v)*2/3,k,v),d=k,f=v},b=(w,x)=>{u.push(d+(w-d)/3,f+(x-f)/3,d+(w-d)*2/3,f+(x-f)*2/3,w,x),d=w,f=x};for(let w=0;w<s;w++){let x=l+w,k=n[i(x)],v=t[i(x)];a(x)?g?(y(p,m,k,v),g=!1):(k!==d||v!==f)&&b(k,v):(g&&y(p,m,(p+k)/2,(m+v)/2),p=k,m=v,g=!0)}return g?y(p,m,c,h):(d!==c||f!==h)&&b(c,h),u}function Tl(n,t){n.seek(t+2);let e=n.u16(),r=-1,o=-1;for(let i=0;i<e;i++){let a=n.u16(),l=n.u16(),c=n.u32(),h=a===3&&l===10?4:a===0&&l>=4?3:a===3&&l===1?2:a===0?1:0;h>o&&(o=h,r=t+c)}if(r<0)return()=>0;n.seek(r);let s=n.u16();if(s===12){n.seek(r+12);let i=n.u32(),a=[];for(let l=0;l<i;l++)a.push([n.u32(),n.u32(),n.u32()]);return l=>{let c=0,h=a.length-1;for(;c<=h;){let u=c+h>>1,[d,f,p]=a[u];if(l<d)h=u-1;else if(l>f)c=u+1;else return p+l-d}return 0}}if(s===4){n.seek(r+6);let i=n.u16(),a=i/2,l=r+14,c=l+i+2,h=c+i,u=h+i,d=new Map;for(let f=0;f<a;f++){let p=n.seek(l+f*2).u16(),m=n.seek(c+f*2).u16(),g=n.seek(h+f*2).i16(),y=n.seek(u+f*2).u16();for(let b=m;b<=p&&b!==65535;b++){let w;if(y===0)w=b+g&65535;else{let x=n.seek(u+f*2+y+(b-m)*2).u16();w=x===0?0:x+g&65535}w&&d.set(b,w)}}return f=>d.get(f)??0}return()=>0}function Rl(n,t){let e=[];try{n.seek(t+6);let o=t+n.u16(),s=t+n.u16();n.seek(o);let i=n.u16(),a=new Set;for(let l=0;l<i;l++){n.seek(o+2+l*6);let c=n.tag(),h=n.u16();if(c!=="kern")continue;n.seek(o+h+2);let u=n.u16();for(let d=0;d<u;d++)a.add(n.u16())}for(let l of[...a].sort((c,h)=>c-h)){n.seek(s+2+l*2);let c=s+n.u16();n.seek(c);let h=n.u16();n.u16();let u=n.u16(),d=[];for(let p=0;p<u;p++)d.push(c+n.u16());let f=[];for(let p of d){let m=p,g=h;g===9&&(n.seek(m+2),g=n.u16(),m+=n.u32()),g===2&&f.push(zl(n,m))}e.push(f)}}catch{}let r=new Map;return(o,s)=>{let i=o*65536+s,a=r.get(i);if(a!==void 0)return a;let l=0;for(let c of e)for(let h of c){let u=h(o,s);if(u!==void 0){l+=u;break}}return r.set(i,l),l}}function Fl(n,t){n.seek(t);let e=n.u16(),r=new Set;if(e===1){let o=n.u16();for(let s=0;s<o;s++)r.add(n.u16())}else if(e===2){let o=n.u16();for(let s=0;s<o;s++){let i=n.u16(),a=n.u16();n.u16();for(let l=i;l<=a;l++)r.add(l)}}return r}function oi(n,t){n.seek(t);let e=n.u16(),r=new Map;if(e===1){let o=n.u16(),s=n.u16();for(let i=0;i<s;i++)r.set(o+i,n.u16())}else if(e===2){let o=n.u16();for(let s=0;s<o;s++){let i=n.u16(),a=n.u16(),l=n.u16();for(let c=i;c<=a;c++)r.set(c,l)}}return o=>r.get(o)??0}function si(n){let t=0;for(let e=0;e<8;e++)n&1<<e&&t++;return t*2}function ii(n,t){let e=0;t&1&&n.i16(),t&2&&n.i16(),t&4&&(e=n.i16()),t&8&&n.i16();for(let r=4;r<8;r++)t&1<<r&&n.u16();return e}function zl(n,t){n.seek(t);let e=n.u16(),r=n.u16(),o=n.u16(),s=n.u16(),i=si(o),a=si(s);if(e===1){let l=n.u16(),c=[];for(let f=0;f<l;f++)c.push(n.u16());n.seek(t+r);let h=n.u16(),u=[];if(h===1){let f=n.u16();for(let p=0;p<f;p++)u.push(n.u16())}else if(h===2){let f=n.u16();for(let p=0;p<f;p++){let m=n.u16(),g=n.u16();n.u16();for(let y=m;y<=g;y++)u.push(y)}}let d=new Map;for(let f=0;f<l;f++){n.seek(t+c[f]);let p=n.u16(),m=new Map;for(let g=0;g<p;g++){let y=n.u16(),b=ii(n,o);n.seek(n.position+a),m.set(y,b)}u[f]!==void 0&&d.set(u[f],m)}return(f,p)=>d.get(f)?.get(p)}if(e===2){let l=n.u16(),c=n.u16(),h=n.u16(),u=n.u16(),d=n.position,f=Fl(n,t+r),p=oi(n,t+l),m=oi(n,t+c);return(g,y)=>{if(!f.has(g))return;let b=p(g),w=m(y);if(!(b>=h||w>=u))return n.seek(d+b*u*(i+a)+w*(i+a)),ii(n,o)}}return()=>{}}var $l={sans:{400:"Inter-Regular.ttf",600:"Inter-SemiBold.ttf",700:"Inter-Bold.ttf"},serif:{400:"InstrumentSerif-Regular.ttf",italic:"InstrumentSerif-Italic.ttf"},"text-serif":{400:"SourceSerif4-24pt-Regular.ttf",italic:"SourceSerif4-24pt-Italic.ttf"},mono:{400:"JetBrainsMono-Regular.ttf"},noto:{400:"NotoSans-Regular.ttf"},math:{400:"NotoSansMath-Regular.ttf"}},Ll={sans:["noto","math"],serif:["text-serif","noto","math"],"text-serif":["noto","math"],mono:["noto","math"],noto:["math"]},ai=new Map,Wr=new Map;function Fe(n,t=400,e=!1){let r=$l[n],o=(e?r.italic:void 0)??r[String(t)]??r[400],s=ai.get(o);if(s)return s;let i=Wr.get(o);throw i||(i=ri(`fonts/${o}`).then(a=>{ai.set(o,ci(a)),Wr.delete(o)}),Wr.set(o,i)),new It(i)}function hi(n,t,e=400,r=!1){for(let o of Ll[n]){let s=Fe(o,e,r),i=s.glyphFor(t);if(i!==0)return{font:s,glyph:i}}return null}var li=new WeakMap;function sn(n,t,e){let r=li.get(n);r||li.set(n,r=new Map);let o=r.get(e);o||r.set(e,o=new Map);let s=o.get(t);if(s)return s;let i=n.outline(t),a=e/n.unitsPerEm,l=i?i.contours.map(c=>{let h=new Float64Array(c.length);for(let u=0;u<c.length;u+=2)h[u]=c[u]*a,h[u+1]=-c[u+1]*a;return Ct(h,!0)}):[];return o.set(t,l),l}var Wn=class extends N{chars=[];source="";find(t){let e=[],r=this.chars.map(s=>s.data.key).join(""),o=t.replace(/\s/g,"");for(let s=r.indexOf(o);s>=0;s=r.indexOf(o,s+1))e.push(...this.chars.slice(s,s+o.length));return e}};function Vl(n){let t=wt(n);if(!t)return{path:n,x:0,y:0};let e=t.x+t.width/2,r=t.y+t.height/2;return{path:at(n,[1,0,0,1,-e,-r]),x:e,y:r}}function H(n,t={}){let e=t.size??40,r=t.font??"sans",o=t.weight??400,s=t.italic??!1,i=Fe(r,o,s),a=e/i.unitsPerEm,l=(t.tracking??0)*e,c=(t.leading??1.3)*e,h=q(t.color??"ink"),u=t.uppercase?n.toUpperCase():n,d=x=>{let k=[],v=0,M=0,A=null;for(let C of x){let O=C.codePointAt(0),P=i,L=i.glyphFor(O);if(L===0){let _=hi(r,O,o,s);_&&(P=_.font,L=_.glyph)}let F=e/P.unitsPerEm;M&&A===P&&(v+=P.kern(M,L)*F),k.push({font:P,glyph:L,x:v,char:C}),v+=P.advance(L)*F+l,M=L,A=P}return{glyphs:k,width:v}},f=[],p=i.advance(i.glyphFor(32))*a+l;for(let x of u.split(`
2
+ `)){let k=[],v=0;for(let M of x.split(" ")){let A=d(M),C=k.length>0?p:0;t.maxWidth!==void 0&&k.length>0&&v+C+A.width>t.maxWidth&&(f.push({glyphs:k,width:v}),k=[],v=0);let O=v+(k.length>0?p:0);for(let P of A.glyphs)k.push({...P,x:P.x+O});v=O+A.width}f.push({glyphs:k,width:v})}let m=Math.max(0,...f.map(x=>x.width)),g=t.align??"left",y=new Wn;y.source=n,f.forEach((x,k)=>{let v=g==="left"?0:g==="center"?(m-x.width)/2:m-x.width;for(let M of x.glyphs){let A=sn(M.font,M.glyph,e);if(A.length===0)continue;let C=Vl(A),O=new N(C.path).at(v+M.x+C.x,k*c+C.y);O.base.fill=h,O.base.trimEach=!0,O.data.key=M.char,M.glyph===0&&(O.data.missingGlyph=!0),y.chars.push(O),y.children.push(O),O.parent=y}});let b=i.ascent*a,w=(f.length-1)*c;return y.base.px=m/2,y.base.py=w/2-b*.36,y.data.size=e,y}var jn=class extends N{glyphs=[];source="";part(t){let e=fi(t),r=this.glyphs.map(o=>o.data.key);for(let o=0;o+e.length<=r.length;o++)if(e.every((s,i)=>s===r[o+i]))return this.glyphs.slice(o,o+e.length);return[]}parts(t){let e=fi(t),r=this.glyphs.map(s=>s.data.key),o=[];for(let s=0;s+e.length<=r.length;s++)e.every((i,a)=>i===r[s+a])&&(o.push(this.glyphs.slice(s,s+e.length)),s+=e.length-1);return o}},Hr=null,ui=null,di=new Map;function Ul(){if(Hr)return Hr;throw ui??=import("./math-4WFNHVV2.js").then(n=>{Hr=(t,e)=>n.renderMathSvg(t,{fontSize:1e3,display:e,color:"#000000"}).svg}),new It(ui)}function pi(n,t){let e=`${t?"D":"I"}${n}`,r=di.get(e);if(r)return r;let o=Ul()(n,t),s=[],i=[],a=[1,0,0,1,0,0],l=/viewBox="([^"]+)"/.exec(o)?.[1]?.trim().split(/[ ,]+/).map(Number)??[0,0,1e3,1e3],h=Number(/\swidth="([\d.]+)px"/.exec(o)?.[1]??1e3)/l[2]/1e3,u=/<(\/?)([a-zA-Z]+)((?:\s+[-\w:]+="[^"]*")*)\s*(\/?)>/g,d=0,f=null,p=[];for(let g=u.exec(o);g;g=u.exec(o)){let[,y,b,w="",x]=g,k=A=>new RegExp(`\\s${A}="([^"]*)"`).exec(w)?.[1];if(b==="svg"){if(y){d--,d>=1&&(a=i.pop()??a,f=p.pop()??null);continue}if(d++,d>1){let A=(k("viewBox")??"0 0 1 1").trim().split(/[ ,]+/).map(Number),C=Number(k("width")??A[2]),O=Number(k("height")??A[3]),P=it([C/(A[2]||1),0,0,O/(A[3]||1),Number(k("x")??0),Number(k("y")??0)],[1,0,0,1,-A[0],-A[1]]);i.push(a),p.push(f),a=it(a,P),f=[A[0],A[1],A[0]+A[2],A[1]+A[3]]}continue}if(y){b==="g"&&(a=i.pop()??a);continue}let v=k("transform"),M=v?Bl(v):[1,0,0,1,0,0];if(b==="g"){x||(i.push(a),a=it(a,M));continue}if(b==="path"){let A=k("d");if(!A)continue;let C=k("data-c"),O=at(St(A),M);s.push({path:at(f?_l(O,f):O,a),key:C?String.fromCodePoint(parseInt(C,16)):"?"})}else if(b==="rect"){let A=Number(k("x")??0),C=Number(k("y")??0),O=Number(k("width")??0),P=Number(k("height")??0);O>0&&P>0&&s.push({path:at(Y(A,C,O,P),it(a,M)),key:"rule"})}}let m=s.map(g=>({key:g.key,path:at(g.path,[h,0,0,h,0,0])}));return di.set(e,m),m}function _l(n,t){return n.map(e=>{let r=new Float64Array(e.p.length);for(let o=0;o<r.length;o+=2)r[o]=Math.max(t[0],Math.min(t[2],e.p[o])),r[o+1]=Math.max(t[1],Math.min(t[3],e.p[o+1]));return{p:r,closed:e.closed}})}function Bl(n){let t=[1,0,0,1,0,0];for(let e of n.matchAll(/(translate|scale|matrix)\(([^)]*)\)/g)){let r=e[2].trim().split(/[ ,]+/).map(Number);e[1]==="translate"?t=it(t,[1,0,0,1,r[0]??0,r[1]??0]):e[1]==="scale"?t=it(t,[r[0]??1,0,0,r[1]??r[0]??1,0,0]):r.length===6&&(t=it(t,r))}return t}function fi(n){return pi(n,!1).map(t=>t.key)}function lt(n,t={}){let e=t.size??56,r=t.display??!0,o=pi(n,r),s=q(t.color??"ink"),i=new jn;i.source=n;let a=1/0,l=1/0,c=-1/0,h=-1/0;for(let u of o){let d=at(u.path,[e,0,0,e,0,0]),f=wt(d);if(!f)continue;a=Math.min(a,f.x),l=Math.min(l,f.y),c=Math.max(c,f.x+f.width),h=Math.max(h,f.y+f.height);let p=f.x+f.width/2,m=f.y+f.height/2,g=new N(at(d,[1,0,0,1,-p,-m])).at(p,m);g.base.fill=s,g.base.trimEach=!0,g.data.key=u.key,i.glyphs.push(g),i.children.push(g),g.parent=i}return a!==1/0&&(i.base.px=(a+c)/2,i.base.py=(l+h)/2),i}function Vt(n,t,e){let r=t.fill!==void 0?t.fill:e.fill,o=t.stroke!==void 0?t.stroke:e.stroke;return r&&n.fill(r),o&&n.stroke(o,t.width??e.width??3),t.opacity!==void 0&&n.opacity(t.opacity),t.glow&&n.glow(t.glow),t.dash&&n.dash(t.dash),t.z!==void 0&&n.zIndex(t.z),n}function Dl(n,t={}){return Vt(new N(n),t,{stroke:"ink"})}function yd(n,t={}){return Dl(St(n),t)}function Z(n,t,e={}){return Vt(new N(ye(n,t)),e,{stroke:"ink"})}function wd(n,t={}){return Vt(new N(et(n,t.closed)),t,{stroke:"ink"})}function xd(n,t={}){return Vt(new N(t.closed?Wt(n,!0):Se(n)),t,{stroke:"ink"})}function kd(n,t,e,r={}){return Vt(new N(gn(n,t,e,r.samples??96)),r,{stroke:"ink"})}function mi(n,t={}){return Vt(new N(Yt(0,0,n)),t,{stroke:"ink"})}function vd(n,t,e={}){return Vt(new N($t(0,0,n,t,0,Math.PI*2)),e,{stroke:"ink"})}function Md(n,t,e,r={}){return Vt(new N($t(0,0,n,n,t,e)),r,{stroke:"ink"})}function gi(n,t,e={}){return Vt(new N(Y(-n/2,-t/2,n,t,e.radius??0)),e,{stroke:"ink"})}function Gl(n,t={}){return Vt(new N(et(n,!0)),t,{stroke:"ink"})}function Ad(n,t,e={}){let r=[];for(let o=0;o<n;o++){let s=-Math.PI/2+o/n*Math.PI*2;r.push([Math.cos(s)*t,Math.sin(s)*t])}return Gl(r,e)}function Wl(n){let t=/^data:image\/(png|gif|jpeg|jpg);base64,/.exec(n);if(!t||typeof atob!="function")return null;let e;try{e=atob(n.slice(t[0].length,t[0].length+(t[1]==="jpeg"||t[1]==="jpg"?87384:44)))}catch{return null}let r=o=>e.charCodeAt(o);if(t[1]==="png")return e.length>=24?[r(16)*16777216+r(17)*65536+r(18)*256+r(19),r(20)*16777216+r(21)*65536+r(22)*256+r(23)]:null;if(t[1]==="gif")return e.length>=10?[r(6)+r(7)*256,r(8)+r(9)*256]:null;for(let o=2;o+9<e.length;){if(r(o)!==255)return null;let s=r(o+1);if(s>=192&&s<=207&&s!==196&&s!==200&&s!==204)return[r(o+7)*256+r(o+8),r(o+5)*256+r(o+6)];o+=2+r(o+2)*256+r(o+3)}return null}function Nd(n,t={}){if(typeof n!="string"){let a=Ws(n,t);return t.opacity!==void 0&&a.opacity(t.opacity),a}if(t.crop!==void 0||t.fit!==void 0)throw new Error("Await resolveImageAsset before using image fit or crop options.");let e=Wl(n),r=t.width,o=t.height;if(r===void 0&&o===void 0){if(!e)throw new Error("image() needs a width or a height when the picture is not a PNG, GIF, or JPEG data URL.");[r,o]=e}else if(r===void 0||o===void 0){if(!e)throw new Error("image() needs both width and height when the picture is not a PNG, GIF, or JPEG data URL.");r===void 0?r=o*e[0]/e[1]:o=r*e[1]/e[0]}if(!(r>0)||!(o>0))throw new Error("image() needs a positive width and height.");let s=new N().at(-r/2,-o/2);s.base.image={src:n,width:r,height:o};let i=new N;return i.add(s),t.opacity!==void 0&&i.opacity(t.opacity),i}function xt(n=9,t="ink",e={}){return Vt(new N(Yt(0,0,n)),e,{fill:t})}function an(n,t,e={}){let r=e.stroke??"ink",o=e.width??3,s=e.tip??Math.max(13,o*4.2),i=e.tipRatio??.72,a=e.pad??0,l=t[0]-n[0],c=t[1]-n[1],h=Math.hypot(l,c)||1;l/=h,c/=h;let u=[n[0]+l*a,n[1]+c*a],d=[t[0]-l*a,t[1]-c*a],f=Math.max(0,h-a*2),p=Math.min(s,f*.45),m=new N,g=e.bend??0,y=[-c,l],b=[(u[0]+d[0])/2+y[0]*g,(u[1]+d[1])/2+y[1]*g],w=d[0]-b[0],x=d[1]-b[1],k=Math.hypot(w,x)||1;w/=k,x/=k;let v=d[0]-w*p,M=d[1]-x*p,A=g===0?ye(e.both?[u[0]+l*p,u[1]+c*p]:u,[v,M]):St(`M${u[0]} ${u[1]}Q${b[0]} ${b[1]} ${v} ${M}`),C=new N(A).stroke(r,o);e.dash&&C.dash(e.dash);let O=p*i/2,P=(L,F,_,B)=>new N(et([[L,F],[L-_*p-B*O,F-B*p+_*O],[L-_*p+B*O,F-B*p-_*O]],!0)).fill(r);return m.add(C,P(d[0],d[1],w,x)),e.both&&m.add(P(u[0],u[1],-l,-c)),e.opacity!==void 0&&m.opacity(e.opacity),e.glow&&C.glow(e.glow),m.data.shaft=C,m}function bi(n,t,e={}){let r=t[0]-n[0],o=t[1]-n[1],s=Math.hypot(r,o)||1,i=e.depth??Math.min(26,10+s*.05),a=s,l=i,c=1.6,h=Math.min(l,a/4),u=`M0 0C0 ${l*.5} ${h*.4} ${l*.5} ${h} ${l*.5}L${a/2-h} ${l*.5}C${a/2-h*.3} ${l*.5} ${a/2} ${l*.72} ${a/2} ${l}C${a/2} ${l*.72} ${a/2+h*.3} ${l*.5} ${a/2+h} ${l*.5}L${a-h} ${l*.5}C${a-h*.4} ${l*.5} ${a} ${l*.5} ${a} 0L${a-c*.2} ${c*.2}C${a-c*.4} ${l*.5-c} ${a-h*.4} ${l*.5-c} ${a-h} ${l*.5-c}L${a/2+h} ${l*.5-c}C${a/2+h*.3} ${l*.5-c} ${a/2+c*.4} ${l*.6} ${a/2} ${l*.82}C${a/2-c*.4} ${l*.6} ${a/2-h*.3} ${l*.5-c} ${a/2-h} ${l*.5-c}L${h} ${l*.5-c}C${h*.4} ${l*.5-c} ${c*.4} ${l*.5-c} ${c*.2} ${c*.2}Z`,d=r/s,f=o/s,p=at(St(u),[d,f,-f,d,n[0],n[1]]),m=Vt(new N(p),{...e,width:void 0},{fill:e.stroke??e.fill??"ink"});return m.data.tip=[(n[0]+t[0])/2-f*i,(n[1]+t[1])/2+d*i],m}var Kr=class extends N{xRange;yRange;plotWidth;plotHeight;lines=new N;grid=new N;numbers=new N;constructor(t={}){super(),this.xRange=t.x??[-5,5],this.yRange=t.y??[-3,3],this.plotWidth=t.width??1100,this.plotHeight=t.height??640;let e=t.color??"dim",r=t.xStep??yi(this.xRange[1]-this.xRange[0]),o=t.yStep??yi(this.yRange[1]-this.yRange[0]),s=Hn(0,this.xRange),i=Hn(0,this.yRange),a=this.p(this.xRange[0],i),l=this.p(this.xRange[1],i),c=this.p(s,this.yRange[0]),h=this.p(s,this.yRange[1]);if(t.grid){for(let p of ze(this.xRange,r))this.grid.add(Z(this.p(p,this.yRange[0]),this.p(p,this.yRange[1]),{stroke:"grid",width:1.25}));for(let p of ze(this.yRange,o))this.grid.add(Z(this.p(this.xRange[0],p),this.p(this.xRange[1],p),{stroke:"grid",width:1.25}))}let u=t.tips??!0,d=(p,m)=>u?an(p,m,{stroke:e,width:2,tip:13}):Z(p,m,{stroke:e,width:2});this.lines.add(d(a,l),d(c,h));let f=6;for(let p of ze(this.xRange,r)){if(p===s)continue;let[m,g]=this.p(p,i);this.lines.add(Z([m,g-f],[m,g+f],{stroke:e,width:2}))}for(let p of ze(this.yRange,o)){if(p===i)continue;let[m,g]=this.p(s,p);this.lines.add(Z([m-f,g],[m+f,g],{stroke:e,width:2}))}if(t.labels??!0){let p=t.labelSize??20;for(let m of ze(this.xRange,r)){if(m===s)continue;let[g,y]=this.p(m,i);this.numbers.add(lt(wi(m),{size:p,color:"dim",display:!1}).moveTo([g,y+26]))}for(let m of ze(this.yRange,o)){if(m===i)continue;let[g,y]=this.p(s,m);this.numbers.add(lt(wi(m),{size:p,color:"dim",display:!1}).moveTo([g-28,y]))}}if(this.add(this.grid,this.lines,this.numbers),t.xLabel&&this.add(lt(t.xLabel,{size:28,color:"ink",display:!1}).moveTo([l[0]+4,l[1]-26])),t.yLabel){let p=lt(t.yLabel,{size:28,color:"ink",display:!1});this.add(p.moveTo([h[0]+16+p.width/2,h[1]+4]))}}p(t,e){let[r,o]=this.xRange,[s,i]=this.yRange;return[((t-r)/(o-r)-.5)*this.plotWidth,(.5-(e-s)/(i-s))*this.plotHeight]}world(t,e){let[r,o]=this.p(t,e);return this.toWorld(r,o)}plotPath(t,e={}){let r=e.from??this.xRange[0],o=e.to??this.xRange[1],s=e.samples??160,[i,a]=this.yRange,l=(a-i)*.02,c=[];for(let h=0;h<=s;h++){let u=r+(o-r)*h/s,d=t(u);c.push(Number.isFinite(d)&&d>=i-l&&d<=a+l?this.p(u,d):[NaN,NaN])}return Se(c)}plot(t,e={}){let r=new N(this.plotPath(t,e)).stroke(e.stroke??"blue",e.width??4);return e.glow&&r.glow(e.glow),e.dash&&r.dash(e.dash),this.add(r),r}dotAt(t,e,r="yellow",o=9){let s=xt(o,r).at(this.p(t,e));return this.add(s),s}guides(t,e,r={}){let o=Hn(0,this.xRange),s=Hn(0,this.yRange),i=yr(Z(this.p(t,s),this.p(t,e),{stroke:"dim",width:2,dash:[6,7],...r}),Z(this.p(o,e),this.p(t,e),{stroke:"dim",width:2,dash:[6,7],...r}));return this.add(i),i}};function Td(n={}){return new Kr(n)}function Hn(n,t){return Math.max(t[0],Math.min(t[1],n))}function yi(n){let t=n/8,e=Math.pow(10,Math.floor(Math.log10(t))),r=t/e;return(r<1.5?1:r<3.5?2:r<7.5?5:10)*e}function ze(n,t){let e=[],r=Math.ceil(n[0]/t-1e-9)*t;for(let o=r;o<=n[1]+1e-9;o+=t)e.push(Math.round(o/t)*t);return e}function wi(n){let t=Math.round(n*1e3)/1e3;return String(t)}var ln=class extends N{unit;major=new N;minor=new N;axes=new N;constructor(t={}){super(),this.unit=t.unit??120;let[e,r]=t.x??[-12,12],[o,s]=t.y??[-8,8],i=this.unit,a=t.color??"blue",l=t.width??1.6,c=t.minor??0,h=(p,m,g)=>{let y=[];for(let b=0;b<=g;b++)y.push([p[0]+(m[0]-p[0])*b/g,p[1]+(m[1]-p[1])*b/g]);return y.length>2?Se(y):ye(p,m)},u=16,d=(p,m,g,y,b,w)=>{p.add(new N(h(m,g,w)).stroke(y,b))};for(let p=e;p<=r;p++){if(c>0&&p<r)for(let m=1;m<c;m++){let g=p+m/c;d(this.minor,[g*i,o*i],[g*i,s*i],"grid",1,u)}p!==0&&d(this.major,[p*i,o*i],[p*i,s*i],a,l,u)}for(let p=o;p<=s;p++){if(c>0&&p<s)for(let m=1;m<c;m++){let g=p+m/c;d(this.minor,[e*i,g*i],[r*i,g*i],"grid",1,u)}p!==0&&d(this.major,[e*i,p*i],[r*i,p*i],a,l,u)}let f=t.axisColor??"ink";d(this.axes,[e*i,0],[r*i,0],f,2.6,u),d(this.axes,[0,o*i],[0,s*i],f,2.6,u),this.add(this.minor,this.major,this.axes)}p(t,e){return[t*this.unit,-e*this.unit]}vector(t,e,r={}){return an([0,0],this.p(t,e),{stroke:"yellow",width:5,tip:22,...r})}};function Rd(n={}){return new ln(n)}function Fd(n,t={}){let e=new N;return e.draw=()=>{let r=n(),o=(t.prefix??"")+r.toFixed(t.digits??2)+(t.suffix??"");return H(o,{size:t.size??36,color:t.color??"ink",font:t.font??"mono"})},e}var he=1,Xr=.08,xi=.15,jl=.12,Hl=.12,Kl=5,ki=12,vi=6,Xl=2,Yr=.25,Mi=.5,Yl=.2,ql=2,Zl=1.6,Ai=.9;function Ni(n){return kt(n)?ht(n.stops,.5):n}function Ci(n){let t=e=>{let r=e/255;return r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)};return .2126*t(n[0])+.7152*t(n[1])+.0722*t(n[2])}function Jl(n,t,e){let r=n[3]*t,o=[n[0]*r+e[0]*(1-r),n[1]*r+e[1]*(1-r),n[2]*r+e[2]*(1-r),1],s=Ci(o),i=Ci(e);return(Math.max(s,i)+.05)/(Math.min(s,i)+.05)}function Oi(n,t){return{x:n.x-t,y:n.y-t,width:n.width+t*2,height:n.height+t*2}}function Ql(n,t){let e=n.width*t,r=n.height*t;return{x:n.x+e,y:n.y+r,width:n.width-e*2,height:n.height-r*2}}function cn(n,t){return n.x<t.x+t.width&&t.x<n.x+n.width&&n.y<t.y+t.height&&t.y<n.y+n.height}function tc(n,t){let e=Math.max(n.x,t.x),r=Math.max(n.y,t.y),o=Math.min(n.x+n.width,t.x+t.width),s=Math.min(n.y+n.height,t.y+t.height);return o>e&&s>r?{x:e,y:r,width:o-e,height:s-r}:null}function ec(n,t){return n.x<=t.x&&n.y<=t.y&&n.x+n.width>=t.x+t.width&&n.y+n.height>=t.y+t.height}function Kn(n,t){let e=Math.min(n.x,t.x),r=Math.min(n.y,t.y);return{x:e,y:r,width:Math.max(n.x+n.width,t.x+t.width)-e,height:Math.max(n.y+n.height,t.y+t.height)-r}}function nc(n,t,e,r,o){let s=0,i=1,a=e-n,l=r-t,c=[[-a,n-o.x],[a,o.x+o.width-n],[-l,t-o.y],[l,o.y+o.height-t]];for(let[h,u]of c)if(h===0){if(u<0)return!1}else{let d=u/h;if(h<0){if(d>i)return!1;d>s&&(s=d)}else{if(d<s)return!1;d<i&&(i=d)}}return s<=i}function rc(n,t){for(let e of n){let r=e.p;for(let o=0;o+7<r.length;o+=6){let s=r[o],i=r[o+1],a=r[o+2],l=r[o+3],c=r[o+4],h=r[o+5],u=r[o+6],d=r[o+7],f=Math.min(s,a,c,u),p=Math.max(s,a,c,u),m=Math.min(i,l,h,d),g=Math.max(i,l,h,d);if(p<t.x||f>t.x+t.width||g<t.y||m>t.y+t.height)continue;let y=s,b=i;for(let w=1;w<=vi;w++){let x=w/vi,k=1-x,v=k*k*k,M=3*k*k*x,A=3*k*x*x,C=x*x*x,O=v*s+M*a+A*c+C*u,P=v*i+M*l+A*h+C*d;if(nc(y,b,O,P,t))return!0;y=O,b=P}}}return!1}function oc(n){return n.data.key!==void 0?n.parent:null}function sc(n){return!!n.node&&n.node.data.key!==void 0}function qr(n){let t=n.source;return typeof t=="string"?t:""}function Si(n){if(!n)return"unknown";let t=n;for(;t.parent&&t.parent.parent;)t=t.parent;return t.mounted?String(t.id):"dynamic"}function ic(n,t){let e=new Set,r=n.clips,o=i=>r.some(a=>a.t0<i&&i<a.t1),s=.001;for(let i of r){let a=i.t1+s;a<n.duration&&!o(a)&&e.add(a)}e.add(Math.max(0,n.duration-s));for(let i=0;i<t;i++)e.add((i+.5)/t*n.duration);if(e.size<Kl)for(let i=0;i<ki;i++){let a=(i+.5)/ki*n.duration;o(a)||e.add(a)}return[...e].sort((i,a)=>i-a)}function Zr(n,t){try{return n.frame(t)}catch(e){if(!Dr(e))throw e;return e.promise.then(()=>Zr(n,t))}}function Pi(n,t){let e=n.stage.camera,r=e.tracks?.get("sx");return r?r.sample(t):e.base.sx}function Ii(n,t,e,r){let o=[],{width:s,height:i,ops:a}=n,l=n.background?qt(n.background):n.dark?[0,0,0,1]:[255,255,255,1],c={x:0,y:0,width:s,height:i},h=new Map,u=[],d=[],f=new Map,p=0;a.forEach((b,w)=>{if(b.kind==="image"){if(b.alpha<Xr||!rn(b.image.asset,b.image.crop))return;let P=Bn(b);(P.x<-he||P.y<-he||P.x+P.width>s+he||P.y+P.height>i+he)&&!e&&!r&&o.push({key:`film.off_canvas:image:${Si(b.node)}`,code:"film.off_canvas",severity:"warning",time:t,box:P,message:`Image ${JSON.stringify(b.image.asset?.id??b.node?.label??"image")} runs off the canvas.`});return}if(b.kind!=="path"||b.path.length===0)return;let x=sc(b);if(Math.max(b.fillAlpha,b.strokeAlpha)<Xr)return;let v=wt(b.path);if(!v)return;let M=b.stroke?Oi(v,b.strokeWidth/2):v,A=x?oc(b.node):null,C=M.x<-he||M.y<-he||M.x+M.width>s+he||M.y+M.height>i+he,O=M.x<=0&&M.x+M.width>=s||M.y<=0&&M.y+M.height>=i;if(C&&(x||!O&&!e&&!r)){let P=cn(M,c),L=A?qr(A):void 0,F=x?`text:${L}`:"marks",_=f.get(F),B=x&&P&&!e?"error":"warning";_?(_.box=Kn(_.box,M),x||(p+=1)):(x||(p=1),f.set(F,{key:`film.off_canvas:${F}`,code:"film.off_canvas",severity:B,time:t,box:M,message:x?`Text ${JSON.stringify(L??"")} runs off the canvas${P?" and is clipped":""}.`:"",...L?{text:L}:{}}))}if(x&&b.node.data.missingGlyph&&b.fillAlpha>=xi){let L=`U+${String(b.node.data.key).codePointAt(0).toString(16).toUpperCase().padStart(4,"0")}`,F=A?qr(A):"";o.push({key:`film.missing_glyph:${F}:${L}`,code:"film.missing_glyph",severity:"error",time:t,box:v,message:`Text ${JSON.stringify(F)} has a character that no bundled font can draw (${L}). It renders as an empty box.`,text:F})}if(x&&A&&b.fillAlpha>=xi){let P=h.get(A);P||h.set(A,P={id:A,source:qr(A),bounds:v,glyphs:[]}),P.bounds=Kn(P.bounds,v),P.glyphs.push({box:v,order:w})}else if(!x&&(b.fill&&b.fillAlpha>=Ai&&Ni(b.fill)[3]>=Ai&&b.path.some(P=>P.closed)&&u.push({order:w,bounds:v}),b.stroke&&b.strokeAlpha>=Xr&&b.strokePath.length>0)){let P=Jl(Ni(b.stroke),b.strokeAlpha,l);P>=Zl&&d.push({op:b,order:w,contrast:P})}});let m=f.get("marks");m&&(m.message=`${p===1?"A mark extends":`${p} marks extend`} past the ${s}x${i} canvas.`),o.push(...f.values());let g=(b,w,x)=>u.some(k=>k.order>b&&k.order<w&&ec(k.bounds,x)),y=[...h.values()];for(let b=0;b<y.length;b++){let w=y[b];for(let x=b+1;x<y.length;x++){let k=y[x];if(!cn(w.bounds,k.bounds))continue;let v=null;for(let M of w.glyphs)if(cn(M.box,k.bounds))for(let A of k.glyphs){let C=tc(M.box,A.box);if(!C)continue;let O=Math.min(M.box.width*M.box.height,A.box.width*A.box.height);O<=0||C.width*C.height/O<jl||g(Math.min(M.order,A.order),Math.max(M.order,A.order),M.order<A.order?M.box:A.box)||(v=v?Kn(v,C):C)}v&&o.push({key:`film.text_overlap:${w.source}|${k.source}`,code:"film.text_overlap",severity:"error",time:t,box:v,message:`Text ${JSON.stringify(w.source)} overlaps text ${JSON.stringify(k.source)}.`,text:w.source,other:k.source})}}for(let b of y)for(let{op:w,order:x,contrast:k}of d){let v=wt(w.strokePath);if(!v||!cn(Oi(v,w.strokeWidth),b.bounds))continue;let M=null;for(let A of b.glyphs){let C=Ql(A.box,Hl);cn(v,C)&&rc(w.strokePath,C)&&(x<A.order&&g(x,A.order,A.box)||(M=M?Kn(M,A.box):A.box))}if(M){let A=w.strokeWidth>=Xl&&k>=ql;o.push({key:`film.text_crossed:${b.source}:${Si(w.node)}`,code:"film.text_crossed",severity:A?"error":"warning",time:t,box:M,message:`A stroke crosses text ${JSON.stringify(b.source)}.`,text:b.source})}}return o}function ac(n,t){return n.ops.some(e=>{if(e.kind==="image"){let i=Bn(e);return e.alpha>=Yr&&rn(e.image.asset,e.image.crop)&&i.y+i.height>t&&i.y<n.height&&i.x+i.width>0&&i.x<n.width}let r=e.fill!==null&&e.fillAlpha>=Yr,o=e.stroke!==null&&e.strokeAlpha>=Yr&&e.strokeWidth>0;if(!r&&!o)return!1;let s=wt(r?e.path:e.strokePath);return s!==null&&s.y+s.height>t&&s.y<n.height&&s.x+s.width>0&&s.x<n.width})}async function lc(n,t={}){try{return await cc(n,t)}catch(e){if(!(e instanceof gt)&&e?.name!=="ImageAssetError")throw e;let r=Ae(n)?new Re(n.options):n;return{ok:!1,width:r.width,height:r.height,duration:Ae(n)?0:n.duration,sampled:[],diagnostics:[{code:"film.image_asset",severity:"error",message:e.message,time:0,until:0,box:{x:0,y:0,width:0,height:0},stage:{x:0,y:0}}],summary:{errors:1,warnings:0}}}}async function cc(n,t){let e=Ae(n)?await n.compile(t):n,r=t.times?[...t.times]:ic(e,t.samples??0),o=new Map;for(let h of r){let u=await Zr(e,h);for(let{key:d,...f}of Ii(u,h,Pi(e,h)!==1,e.bleed)){let p=o.get(d);p?(p.until=h,f.severity==="error"&&(p.severity="error")):o.set(d,{...f,until:h,stage:{x:0,y:0}})}}let s=t.motion?Math.max(1,Math.round(e.duration*e.fps)):0,i=1/e.fps;if(t.motion){let h=t.contentTop??0,u=new Map,d=[];for(let p=0;p<s;p++){let m=p*i,g=await Zr(e,m);for(let b of Ii(g,m,Pi(e,m)!==1,e.bleed)){if(o.has(b.key))continue;let w=u.get(b.key);w||u.set(b.key,w=[]);let x=w[w.length-1];x&&x.to===p-1?x.to=p:w.push({from:p,to:p,first:b})}if(!(m<Mi||m>e.duration-Mi)&&!ac(g,h)){let b=d[d.length-1];b&&b.to===p-1?b.to=p:d.push({from:p,to:p})}}let f=p=>Math.round(p*i*100)/100;for(let[p,m]of u){let g=m.reduce((w,x)=>x.to-x.from>w.to-w.from?x:w),{key:y,...b}=g.first;o.set(p,{...b,severity:"warning",until:g.to*i,stage:{x:0,y:0},motion:{spans:m.length,seconds:f(m.reduce((w,x)=>w+x.to-x.from+1,0))}})}for(let p of d){let m=f(p.to-p.from+1);m<Yl||o.set(`film.blank:${p.from}`,{code:"film.blank",severity:"warning",message:`Nothing is visible${h>0?` below y=${h}`:""} for ${m} s.`,time:p.from*i,until:p.to*i,box:{x:0,y:h,width:e.width,height:e.height-h},stage:{x:0,y:0},motion:{spans:1,seconds:m}})}}let a=h=>Math.round(h*100)/100,l=[...o.values()].map(h=>({...h,time:Math.round(h.time*1e3)/1e3,until:Math.round(h.until*1e3)/1e3,box:{x:a(h.box.x),y:a(h.box.y),width:a(h.box.width),height:a(h.box.height)},stage:{x:a(h.box.x+h.box.width/2-e.width/2),y:a(h.box.y+h.box.height/2-e.height/2)}})).sort((h,u)=>h.severity===u.severity?h.time-u.time:h.severity==="error"?-1:1),c=l.filter(h=>h.severity==="error").length;return{ok:c===0,width:e.width,height:e.height,duration:e.duration,sampled:r.map(h=>Math.round(h*1e3)/1e3),...t.motion?{frames:s}:{},diagnostics:l,summary:{errors:c,warnings:l.length-c}}}function ct(n,t,e){n.mounted||(E.now=t,e.add(n));for(let r=n;r&&r!==e.root;r=r.parent)Ne(r,"visible",t)||r.track("visible").step(t,!0)}function Ne(n,t,e){let r=E.now;E.now=e;let o=n.get(t);return E.now=r,o}function G(n,t,e,r){n.track(t).step(r,e)}function Mt(n,t,e,r,o){let s=n.track.sample(e);n.track.add({t0:e,t1:r,ease:o,to:t,at:i=>s+(t-s)*i})}function Ht(n,t,e,r){if(n===0)return[];let o=(r-e)/(1+(n-1)*t);return Array.from({length:n},(s,i)=>{let a=e+i*t*o;return[a,a+o]})}function Jr(n,t){return typeof n!="string"?n:t.math?lt(n,{size:t.size,color:t.color??"ink",display:!1}):H(n,{size:t.size,color:t.color??"ink",font:t.font??"sans",weight:t.weight??400})}function Ei(n){let t=e=>{let r=e/255;return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)};return .2126*t(n[0])+.7152*t(n[1])+.0722*t(n[2])}function Ut(n){return typeof n=="string"?qt(n):Array.isArray(n)?n:n.stops[0][1]}function hn(n){let t=n>>>0;return()=>{t=t+1831565813>>>0;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Jt(n,t,e){let r=[],o=Math.ceil(n/e-1e-9)*e;for(let s=o;s<=t+e*1e-6;s+=e)r.push(Math.round(s/e)*e);return r}function Xn(n,t,e=5){let o=(t-n||1)/Math.max(1,e),s=Math.pow(10,Math.floor(Math.log10(o))),i=o/s,a=(i<1.5?1:i<3.5?2:i<7.5?5:10)*s;return{ticks:Jt(n,t,a),step:a}}function un(n,t){if(t!==void 0&&t<1){let r=Math.min(4,Math.ceil(-Math.log10(t)-1e-9));return n.toFixed(r)}let e=Math.round(n*1e3)/1e3;return Math.abs(e)>=1e3&&Number.isInteger(e)?e.toLocaleString("en-US"):String(e)}function Ce(n){let t=n[0],e=new Array(2+(n.length-1)*6);e[0]=t[0],e[1]=t[1];for(let r=1;r<n.length;r++){let o=n[r-1],s=n[r],i=2+(r-1)*6;e[i]=o[0]+(s[0]-o[0])/3,e[i+1]=o[1]+(s[1]-o[1])/3,e[i+2]=o[0]+(s[0]-o[0])*2/3,e[i+3]=o[1]+(s[1]-o[1])*2/3,e[i+4]=s[0],e[i+5]=s[1]}return{p:Float64Array.from(e),closed:!1,straight:!0}}var ue=n=>typeof n=="function"?n():n,Qr=class extends N{range;length;line;ticks=new N;numbers=new N;constructor(t={}){super(),this.range=t.range??[-5,5],this.length=t.length??1200;let e=t.color??"dim",r=t.width??2,o=this.length/2,s=t.tips??!0;this.line=s?an([-o-36,0],[o+36,0],{stroke:e,width:r,tip:14,both:!0}):Z([-o,0],[o,0],{stroke:e,width:r});let i=t.step??1;for(let a of Jt(this.range[0],this.range[1],i)){let[l]=this.p(a);if(this.ticks.add(Z([l,-7],[l,7],{stroke:e,width:r})),t.labels??!0){let c=t.labelSize??24,h=lt(String(Math.round(a*1e3)/1e3),{size:c,color:"dim",display:!1});h.set("py",-c*.25),this.numbers.add(h.at(l,34))}}this.add(this.line,this.ticks,this.numbers)}p(t){let[e,r]=this.range;return[((t-e)/(r-e)-.5)*this.length,0]}world(t){let[e,r]=this.p(t);return this.toWorld(e,r)}marker(t,e={}){let r=e.color??"yellow",o=e.labelSize??28,s=()=>{let[a]=this.p(ue(t)),l=[xt(e.radius??9,r).at(a,0)];return e.label&&l.push(lt(e.label,{size:o,color:r,display:!1}).at(a,-o*1.15)),l},i=typeof t=="function"?Rt(s):new N().add(...s());return this.add(i),i}interval(t,e,r={}){let o=r.color??"blue",s=r.offset??0,[i]=this.p(t),[a]=this.p(e),l=Z([i,s],[a,s],{stroke:o,width:r.width??7}),c=(u,d)=>d?xt(9,"bg").stroke(o,4).at(u,s):xt(9,o).at(u,s),h=new N().add(l,c(i,r.openLeft),c(a,r.openRight));return this.add(h),h}};function of(n={}){return new Qr(n)}var to=class extends ln{numbers=new N;constructor(t={}){super(t);let e=t.labelRange??3,r=t.labelSize??22;for(let o=-e;o<=e;o++){if(o===0)continue;let s=lt(String(o),{size:r,color:"ink",display:!1});s.set("py",-r*.25),this.numbers.add(s.at(o*this.unit,22));let i=o===1?"i":o===-1?"-i":`${o}i`,a=lt(i,{size:r,color:"ink",display:!1});a.set("py",-r*.25),this.numbers.add(a.at(-r*.9,-o*this.unit))}this.add(this.numbers)}z(t,e){return this.p(t,e)}};function sf(n={}){return new to(n)}function af(n,t,e={}){let r=Xt(n.worldMatrix()),o=n.worldMatrix(),s=n.unit;return{...xr([n.minor,n.major,n.axes],(a,l)=>{let[c,h]=tt(r,a,l),[u,d]=t(c/s,-h/s);return tt(o,u*s,-d*s)},{duration:3,...e}),label:"applyComplex"}}var lf={mul:(n,t)=>[n[0]*t[0]-n[1]*t[1],n[0]*t[1]+n[1]*t[0]],div:(n,t)=>{let e=t[0]*t[0]+t[1]*t[1]||1e-12;return[(n[0]*t[0]+n[1]*t[1])/e,(n[1]*t[0]-n[0]*t[1])/e]},exp:n=>{let t=Math.exp(n[0]);return[t*Math.cos(n[1]),t*Math.sin(n[1])]},log:n=>[Math.log(Math.hypot(n[0],n[1])||1e-12),Math.atan2(n[1],n[0])],pow:(n,t)=>{let e=Math.pow(Math.hypot(n[0],n[1]),t),r=Math.atan2(n[1],n[0])*t;return[e*Math.cos(r),e*Math.sin(r)]},sin:n=>[Math.sin(n[0])*Math.cosh(n[1]),Math.cos(n[0])*Math.sinh(n[1])],cos:n=>[Math.cos(n[0])*Math.cosh(n[1]),-Math.sin(n[0])*Math.sinh(n[1])],inv:n=>{let t=n[0]*n[0]+n[1]*n[1]||1e-12;return[n[0]/t,-n[1]/t]}};function hc(n,t,e,r,o){let s=Math.hypot(e,r)||1e-6,i=e/s,a=r/s,l=Math.min(s*.42,o*5.2),c=o/2,h=l*.42,u=n+e-i*l,d=t+r-a*l,f=-a,p=i;return et([[n+f*c,t+p*c],[u+f*c,d+p*c],[u+f*h,d+p*h],[n+e,t+r],[u-f*h,d-p*h],[u-f*c,d-p*c],[n-f*c,t-p*c]],!0)[0]}var eo=class extends N{constructor(e,r={}){super();this.f=e;let o=this.unit=r.unit??120,[s,i]=r.x??[-8,8],[a,l]=r.y??[-4.5,4.5],c=r.step??.5,h=r.maxLength??c*o*.92,u=r.width??2.6,d=(r.colors??["blue","teal","green","yellow","orange","red"]).map(y=>q(y)),f=d.map((y,b)=>[d.length===1?0:b/(d.length-1),y]),p=[];for(let y of Jt(a,l,c))for(let b of Jt(s,i,c))p.push([b,y]);let m=r.max??(()=>{let y=p.map(([b,w])=>{let[x,k]=e(b,w,0);return Math.hypot(x,k)}).filter(Number.isFinite).sort((b,w)=>b-w);return y[Math.floor(y.length*.9)]||1})(),g=(y,b,w)=>{let[x,k]=e(y,b,w),v=Math.hypot(x,k);if(!Number.isFinite(v)||v<1e-9)return null;let M=Math.min(1,v/m),A=h*(.22+.78*(1-Math.exp(-2.2*v/m))),C=x/v*A,O=-(k/v)*A,P=y*o,L=-b*o;return{ring:hc(P-C/2,L-O/2,C,O,u),at:M,cx:P,cy:L}};if(r.animate){this.draw=b=>{let w=Array.from({length:12},()=>[]);for(let[x,k]of p){let v=g(x,k,b);v&&w[Math.min(11,Math.floor(v.at*12))].push(v.ring)}return w.flatMap((x,k)=>x.length===0?[]:[new N(x).fill(ht(f,(k+.5)/12))])};return}for(let[y,b]of p){let w=g(y,b,0);if(!w)continue;let x=Fi([w.ring]).fill(ht(f,w.at));this.arrows.push(x),this.add(x)}}f;unit;arrows=[]};function Fi(n){let t=wt(n);if(!t)return new N(n);let e=t.x+t.width/2,r=t.y+t.height/2,o=n.map(s=>{let i=new Float64Array(s.p.length);for(let a=0;a<i.length;a+=2)i[a]=s.p[a]-e,i[a+1]=s.p[a+1]-r;return{p:i,closed:s.closed}});return new N(o).at(e,r)}function cf(n,t={}){return new eo(n,t)}var no=class extends N{lineCount;constructor(t,e={}){super();let r=e.unit??120,[o,s]=e.x??[-8.5,8.5],[i,a]=e.y??[-5,5],l=e.spacing??.55,c=e.dt??.03,h=e.steps??130,u=e.width??2.2,d=e.speed??.35,f=e.tail??.42,p=hn(e.seed??7),m=(e.colors??["blue","teal","green","yellow","orange","red"]).map(O=>q(O)),g=m.map((O,P)=>[m.length===1?0:P/(m.length-1),O]),y=[],b=[],w=.6;for(let O=i;O<=a;O+=l)for(let P=o;P<=s;P+=l){let L=P+(p()-.5)*l,F=O+(p()-.5)*l,_=p(),B=[[L*r,-F*r]],D=0;for(let S=0;S<h;S++){let[V,R]=t(L,F,0),[T,z]=t(L+V*c/2,F+R*c/2,0),[I,U]=t(L+T*c/2,F+z*c/2,0),[W,X]=t(L+I*c,F+U*c,0),st=(V+2*T+2*I+W)/6,J=(R+2*z+2*U+X)/6;if(!Number.isFinite(st)||!Number.isFinite(J))break;let ft=Math.hypot(st,J);if(D+=ft,ft<1e-6||(L+=st*c,F+=J*c,L<o-w||L>s+w||F<i-w||F>a+w))break;S%2===1&&B.push([L*r,-F*r])}if(B.length<5)continue;let K=D/(B.length*2);b.push(K),y.push({points:B,phase:_,speedRate:.8+p()*.4,color:K})}let x=[...b].sort((O,P)=>O-P),k=e.max??(x[Math.floor(x.length*.92)]||1),v=8;for(let O of y)O.color=Math.min(v-1,Math.floor(Math.min(1,O.color/k)*v));this.lineCount=y.length;let M=6,A=e.trace??0,C=Array.from({length:v},()=>[]);if(A>0)for(let O of y)C[O.color].push(Ce(O.points));this.draw=O=>{let P=Array.from({length:v*M},()=>[]);for(let F of y){let _=F.points.length,B=Math.max(3,Math.floor(_*f)),D=_+B,K=(O*d*F.speedRate+F.phase)%1*D;for(let S=0;S<M;S++){let V=Math.floor(K-B*(1-S/M)),R=Math.floor(K-B*(1-(S+1)/M)),T=Math.max(0,V),z=Math.min(_-1,R);z-T<1||P[F.color*M+S].push(Ce(F.points.slice(T,z+1)))}}let L=[];return A>0&&C.forEach((F,_)=>{F.length&&L.push(new N(F).stroke(ht(g,(_+.5)/v),u*.6).set("strokeOpacity",A))}),P.forEach((F,_)=>{if(F.length===0)return;let B=Math.floor(_/M),D=_%M,K=new N(F).stroke(ht(g,(B+.5)/v),u);K.set("strokeOpacity",Math.pow((D+1)/M,1.6)),D<M-1&&K.set("cap","butt"),L.push(K)}),L}}};function hf(n,t={}){return new no(n,t)}function uf(n,t,e={}){let r=e.from??n.xRange[0],o=e.to??n.xRange[1],s=e.n??12,i=e.rule??"mid",a=Ke(s,...e.colors??["blue","teal","green"]),l=new N,c=(o-r)/s;for(let h=0;h<s;h++){let u=r+h*c,d=i==="left"?u:i==="right"?u+c:u+c/2,f=t(d),[p,m]=n.p(u,0),[g,y]=n.p(u+c,f),b=Fi(et([[p,m],[g,m],[g,y],[p,y]],!0));b.fill(a[h],e.opacity??.72),b.stroke(e.stroke??"bg",e.strokeWidth??(s>40?.5:1.4)),l.add(b)}return n.add(l),l}function Ti(n,t,e,r,o){let s=[];for(let i=0;i<=o;i++){let a=e+(r-e)*i/o;s.push(n.p(a,t(a)))}return s.push(n.p(r,0),n.p(e,0)),et(s,!0)}function df(n,t,e={}){let r=e.samples??96,o=e.fill??"blue",s=e.opacity??.28,i=e.from??n.xRange[0],a=e.to??n.xRange[1],l=typeof i=="function"||typeof a=="function"?Rt(()=>{let c=ue(i),h=ue(a);return Math.abs(h-c)<1e-9?null:new N(Ti(n,t,c,h,r)).fill(o,s)}):new N(Ti(n,t,i,a,r)).fill(o,s);return n.add(l),l}function uc(n,t,e){let o=(n.xRange[1]-n.xRange[0])*1e-4,s=n.p(e-o,t(e-o)),i=n.p(e+o,t(e+o)),a=Math.hypot(i[0]-s[0],i[1]-s[1])||1;return{point:n.p(e,t(e)),ux:(i[0]-s[0])/a,uy:(i[1]-s[1])/a}}function ff(n,t,e,r={}){let o=r.length??420,s=r.stroke??"yellow",i=()=>{let{point:l,ux:c,uy:h}=uc(n,t,ue(e)),u=[Z([l[0]-c*o/2,l[1]-h*o/2],[l[0]+c*o/2,l[1]+h*o/2],{stroke:s,width:r.width??3.5,glow:r.glow,dash:r.dash})];return(r.point??!0)&&u.push(xt(8,s).at(l)),u},a=typeof e=="function"?Rt(i):new N().add(...i());return n.add(a),a}function pf(n,t,e,r,o={}){let s=o.extend??140,i=o.stroke??"yellow",a=()=>{let c=ue(e),h=ue(r),u=n.p(c,t(c)),d=n.p(h,t(h)),f=Math.hypot(d[0]-u[0],d[1]-u[1])||1,p=(d[0]-u[0])/f,m=(d[1]-u[1])/f,g=[Z([u[0]-p*s,u[1]-m*s],[d[0]+p*s,d[1]+m*s],{stroke:i,width:o.width??3.5,glow:o.glow})];if(o.legs){let y=[d[0],u[1]],b=o.legColor??"dim";g.unshift(Z(u,y,{stroke:b,width:2,dash:[6,7]}),Z(y,d,{stroke:b,width:2,dash:[6,7]}))}return(o.points??!0)&&g.push(xt(8,i).at(u),xt(8,i).at(d)),g},l=typeof e=="function"||typeof r=="function"?Rt(a):new N().add(...a());return n.add(l),l}function mf(n,t,e,r={}){let o=()=>{let i=ue(t),a=ue(e),l=Math.max(n.xRange[0],Math.min(n.xRange[1],0)),c=Math.max(n.yRange[0],Math.min(n.yRange[1],0)),h={stroke:"dim",width:2,dash:[6,7],...r};return[Z(n.p(i,c),n.p(i,a),h),Z(n.p(l,a),n.p(i,a),h)]},s=typeof t=="function"||typeof e=="function"?Rt(o):new N().add(...o());return n.add(s),s}function gf(n,t,e,r={}){let o=r.radius??54,s=r.color??"yellow",i=Math.atan2(t[1]-n[1],t[0]-n[0]),a=Math.atan2(e[1]-n[1],e[0]-n[0])-i;for(;a<=-Math.PI;)a+=Math.PI*2;for(;a>Math.PI;)a-=Math.PI*2;r.reflex&&(a+=a>0?-Math.PI*2:Math.PI*2);let l=new N;if(r.fillOpacity){let c=[n];for(let h=0;h<=24;h++){let u=i+a*h/24;c.push([n[0]+Math.cos(u)*o,n[1]+Math.sin(u)*o])}l.add(new N(et(c,!0)).fill(s,r.fillOpacity))}if(l.add(new N($t(n[0],n[1],o,o,i,i+a)).stroke(s,r.width??3)),r.label){let c=r.labelSize??30,h=i+a/2,u=o+c*.72;l.add(lt(r.label,{size:c,color:s,display:!1}).at(n[0]+Math.cos(h)*u,n[1]+Math.sin(h)*u))}return l}function bf(n,t,e,r={}){let o=r.size??26,s=h=>{let u=h[0]-n[0],d=h[1]-n[1],f=Math.hypot(u,d)||1;return[u/f,d/f]},[i,a]=s(t),[l,c]=s(e);return new N(et([[n[0]+i*o,n[1]+a*o],[n[0]+(i+l)*o,n[1]+(a+c)*o],[n[0]+l*o,n[1]+c*o]])).stroke(r.color??"ink",r.width??2.5)}var dc={"[":["[","]"],"(":["(",")"],"|":["|","|"]},ro=class extends N{cells;entries=new N;brackets=new N;rowCount;colCount;positions;options;constructor(t,e={}){super(),this.options=e;let r=e.size??52,o=e.color??"ink";this.rowCount=t.length,this.colCount=Math.max(0,...t.map(w=>w.length));let s=t.map(w=>w.map(x=>{let k=lt(String(x),{size:r,color:o,display:!1});return k.set("py",-r*.25),k})),i=Array.from({length:this.colCount},(w,x)=>Math.max(0,...s.map(k=>k[x]?.width??0))),a=(e.gapX??.85)*r,l=(e.gapY??1.32)*r,c=i.reduce((w,x)=>w+x,0)+a*Math.max(0,this.colCount-1),h=l*Math.max(0,this.rowCount-1)+r,u=[],d=-c/2;for(let w of i)u.push(d+w/2),d+=w+a;this.positions=s.map((w,x)=>w.map((k,v)=>{let M=[u[v],(x-(this.rowCount-1)/2)*l];return k.at(M),this.entries.add(k),M})),this.cells=s;let f=dc[e.bracket??"["],m=`\\rule{0pt}{${((h+r*.5)/r/2+.25).toFixed(3)}em}`,g=r*.42,y=lt(`\\left${f[0]}${m}\\right.`,{size:r,color:e.bracketColor??o}),b=lt(`\\left.${m}\\right${f[1]}`,{size:r,color:e.bracketColor??o});y.moveTo([-c/2-g-y.width/2,0]),b.moveTo([c/2+g+b.width/2,0]),this.brackets.add(y,b),this.add(this.brackets,this.entries)}cell(t,e){let r=this.cells[t]?.[e];if(!r)throw new Error(`Matrix has no cell (${t}, ${e}). It is ${this.rowCount} by ${this.colCount}.`);return r}row(t){return[...this.cells[t]??[]]}col(t){return this.cells.map(e=>e[t]).filter(Boolean)}setCell(t,e,r,o={}){let s=this.options.size??52,i=lt(String(r),{size:s,color:this.options.color??"ink",display:!1});i.set("py",-s*.25);let a=this.positions[t][e];i.at(a);let l=this.cell(t,e),c=this,h=Ee(l,i,{duration:.8,...o});return{...h,schedule(u){c.entries.add(i),i.track("visible").initial=!1,c.cells[t][e]=i,h.schedule(u)}}}};function yf(n,t={}){return new ro(n,t)}function zi(n){let t=Array.isArray(n)?n:[n],e=1/0,r=1/0,o=-1/0,s=-1/0;for(let i of t){let a=i.bounds();e=Math.min(e,a.x),r=Math.min(r,a.y),o=Math.max(o,a.x+a.width),s=Math.max(s,a.y+a.height)}return{x:e,y:r,width:o-e,height:s-r}}function wf(n,t,e={}){let r=zi(n),o=e.side??"bottom",s=e.gap??12,i=e.color??"ink",a=e.size??34,l=r.x,c=r.x+r.width,h=r.y,u=r.y+r.height,[d,f]=o==="bottom"?[[l,u+s],[c,u+s]]:o==="top"?[[c,h-s],[l,h-s]]:o==="left"?[[l-s,h],[l-s,u]]:[[c+s,u],[c+s,h]],p=bi(d,f,{stroke:i,depth:e.depth}),m=p.data.tip,g=Jr(t,{size:a,color:i,math:!e.plain});g.moveTo(m);let y=An(o),b=10+(y[0]!==0?g.width/2:g.height/2);return g.shift(y[0]*b,y[1]*b),new N().add(p,g)}function xf(n,t={}){let e=zi(n),r=t.pad??12,o=gi(e.width+r*2,e.height+r*2,{radius:t.radius??8,stroke:t.color??"yellow",width:t.width??2.5,glow:t.glow});return t.fill&&o.fill(t.fill,t.fillOpacity??.14),o.at(e.x+e.width/2,e.y+e.height/2)}var oo=class extends N{mark;caption;constructor(t,e={}){super();let r=e.color??"yellow";this.mark=xt(e.radius??9,r),this.caption=Jr(t,{size:e.size??30,color:e.labelColor??r,math:!e.plain}),this.add(this.mark,this.caption),this.caption.nextTo(this.mark,e.side??[.72,-.72],e.gap??8)}};function kf(n,t={}){return new oo(n,t)}function vf(n,t,e,r={}){let o=r.color??"yellow",s=r.width??3,i=r.rate??60,a=r.fade??(r.tail!==void 0?0:1),l=a>=1?1:10,c=new Map,h=u=>{let d=c.get(u);if(d)return d;let f=E.now;E.now=t+u/i;let p=n();return E.now=f,E.mode==="render"&&c.set(u,p),p};return Rt(u=>{if(u<=t)return null;let d=Math.min(u,e),f=r.tail!==void 0?Math.max(t,d-r.tail):t,p=Math.ceil((f-t)*i),m=Math.floor((d-t)*i);if(m-p<1)return null;let g=[];for(let w=p;w<=m;w++)g.push(h(w));let y=E.now;E.now=d,g.push(n()),E.now=y;let b=[];for(let w=0;w<l;w++){let x=Math.floor((g.length-1)*w/l),k=Math.min(g.length-1,Math.floor((g.length-1)*(w+1)/l));if(k-x<1)continue;let v=new N([Ce(g.slice(x,k+1))]).stroke(o,s),M=l===1?1:a+(1-a)*Math.pow((w+1)/l,1.5);v.set("strokeOpacity",M),w<l-1&&v.set("cap","butt"),r.glow&&v.glow(r.glow),b.push(v)}return b})}function Mf(n,t={}){let e=n.length,r=[];for(let o=0;o<e;o++){let s=o<=e/2?o:o-e,i=0,a=0;for(let l=0;l<e;l++){let c=-2*Math.PI*s*l/e,h=Math.cos(c),u=Math.sin(c),[d,f]=n[l];i+=d*h-f*u,a+=d*u+f*h}r.push({freq:s,amp:Math.hypot(i,a)/e,phase:Math.atan2(a,i)})}return r.sort((o,s)=>s.amp-o.amp||o.freq-s.freq),t.terms?r.slice(0,t.terms):r}function Ri(n,t){let e=0,r=0;for(let o of n){let s=2*Math.PI*o.freq*t+o.phase;e+=o.amp*Math.cos(s),r+=o.amp*Math.sin(s)}return[e,r]}function Af(n,t){return Tt(n)===0?[]:Array.from({length:t},(r,o)=>Et(n,o/t))}var so=class extends N{terms;outlinePoints;constructor(t,e){super(),this.terms=[...t].sort((u,d)=>(u.freq===0?-1:d.freq===0?1:0)||d.amp-u.amp);let r=e.samples??1024;this.outlinePoints=Array.from({length:r+1},(u,d)=>Ri(this.terms,d/r));let o=e.circles??64,s=e.circleColor??"blue",i=e.armColor??"ink",a=e.traceColor??"yellow",l=e.traceWidth??3.5,c=e.tail??1,h=12;this.draw=()=>{let u=e.u(),d=u-Math.floor(u),f=[],p=0,m=0,g=[],y=[[],[],[],[]];this.terms.forEach((k,v)=>{let M=2*Math.PI*k.freq*d+k.phase,A=p+k.amp*Math.cos(M),C=m+k.amp*Math.sin(M);v<o&&k.freq!==0&&k.amp>.4&&y[Math.min(3,Math.floor(v/Math.max(1,o)*4))].push(...Yt(p,m,k.amp)),p=A,m=C,v<o&&g.push([p,m])}),y.forEach((k,v)=>{k.length&&f.push(new N(k).stroke(s,1.2).set("strokeOpacity",[.55,.36,.22,.14][v]))}),g.length>=2&&f.push(new N([Ce(g)]).stroke(i,1.4).set("strokeOpacity",.85));let b=this.outlinePoints.length-1,w=u>=1?b:Math.floor(d*b),x=Math.max(0,w-Math.floor(b*c));if(w-x>=2)if(c>=1){let k=new N([Ce(this.outlinePoints.slice(x,w+1))]).stroke(a,l);e.glow&&k.glow(e.glow),f.push(k)}else for(let k=0;k<h;k++){let v=x+Math.floor((w-x)*k/h),M=Math.min(w,x+Math.floor((w-x)*(k+1)/h));if(M-v<1)continue;let A=new N([Ce(this.outlinePoints.slice(v,M+1))]).stroke(a,l);A.set("strokeOpacity",Math.pow((k+1)/h,1.5)),k<h-1&&A.set("cap","butt"),f.push(A)}return u<1&&f.push(xt(5,a).at(p,m)),f}}outline(){return et(this.outlinePoints.slice(0,-1),!0)}point(t){return Ri(this.terms,t)}};function Nf(n,t){return new so(n,t)}function Cf(n,t=200){return gn(n,0,1,t).map(r=>Ct(r.p,!0))}var fe=["blue","yellow","teal","orange","purple","green","pink","red"];function _t(n,t,e="dim",r="sans"){return H(n,{size:t,color:e,font:r})}var ao=class extends N{bars=[];labels=[];readouts=[];baseline;values;maxValue;minValue;w;h;horizontal;band;gap;fixedMax;fixedMin;constructor(t,e={}){super(),this.w=e.width??900,this.h=e.height??520,this.horizontal=e.horizontal??!1,this.gap=e.gap??.28,this.fixedMax=e.max,this.fixedMin=e.min;let r=e.labelSize??20,o=Math.max(1,t.length);this.band=(this.horizontal?this.h:this.w)/o;let s=t.map(d=>d.value);this.maxValue=new yt(e.max??Math.max(0,...s)),this.minValue=new yt(e.min??Math.min(0,...s)),this.values=t.map(d=>new yt(d.value));let i=e.format??(d=>un(Math.round(d*100)/100)),a=e.color??"faint",[l,c]=this.place(0,0,"start"),[h,u]=this.place(o-1,0,"end");this.baseline=Z([l,c],[h,u],{stroke:a,width:1.5}),t.forEach((d,f)=>{let p=d.color??fe[f%fe.length],m=new N(this.barPath(f,d.value)).fill(p,.84);this.bars.push(m);let g=_t(d.label,r);this.labels.push(g);let[y,b]=this.place(f,0,"mid");if(this.horizontal?g.at(y-12-g.width/2,b):g.at(y,b+12+r/2),e.showValues??!0){let w=Rt(()=>{let x=this.values[f].value,[k,v]=this.tip(f,x),M=_t(i(x),r,"ink","mono");return this.horizontal?M.at(k+12+M.width/2,v):M.at(k,v+(x>=0?-1:1)*(10+r*.6))});this.readouts.push(w)}}),this.add(...this.bars,this.baseline,...this.labels,...this.readouts)}lengthOf(t){let e=this.maxValue.value-this.minValue.value||1;return t/e*(this.horizontal?this.w:this.h)}place(t,e,r){let o=(t+.5)*this.band,s=this.band/2,i=r==="mid"?o:r==="start"?o-s:o+s,a=this.maxValue.value-this.minValue.value||1;if(this.horizontal)return[-this.minValue.value/a*this.w-this.w/2,i-this.h/2];let l=this.h/2- -this.minValue.value/a*this.h;return[i-this.w/2,l]}tip(t,e){let[r,o]=this.place(t,0,"mid"),s=this.lengthOf(e);return this.horizontal?[r+s,o]:[r,o-s]}barPath(t,e){let[r,o]=this.place(t,0,"mid"),s=this.band*(1-this.gap),i=this.lengthOf(e);return this.horizontal?Y(r,o-s/2,i,s):Y(r-s/2,o-i,s,i)}bar(t){return this.bars[t]}enter(t={}){let e=t.lag??.12;return{label:"barChart.enter",duration:t.duration??1.6,ease:t.ease,schedule:r=>{ct(this,r.t0,r.stage);let o=r.t1-r.t0;G(this.baseline,"trimTo",0,r.t0),this.baseline.tween("trimTo",1,r.t0,r.t0+o*.4,r.ease);let s=Ht(this.bars.length,e,r.t0+o*.1,r.t1);this.bars.forEach((i,a)=>{let[l,c]=s[a],h=this.values[a].track.sample(r.t0);this.values[a].track.step(r.t0,0),Mt(this.values[a],h,l,c,r.ease),i.track("path").step(r.t0,this.barPath(a,0)),i.track("path").add({t0:l,t1:c,ease:r.ease,to:this.barPath(a,h),at:f=>this.barPath(a,h*f)});let u=this.labels[a];G(u,"opacity",0,r.t0),u.tween("opacity",1,l,l+(c-l)*.6,r.ease);let d=this.readouts[a];d&&(G(d,"opacity",0,r.t0),d.tween("opacity",1,l,l+(c-l)*.5,r.ease))})}}}update(t,e={}){return{label:"barChart.update",duration:e.duration??1.1,ease:e.ease,schedule:r=>{let o=this.values.map(c=>c.track.sample(r.t0)),s=this.maxValue.track.sample(r.t0),i=this.minValue.track.sample(r.t0),a=this.fixedMax??Math.max(0,...t),l=this.fixedMin??Math.min(0,...t);Mt(this.maxValue,a,r.t0,r.t1,r.ease),Mt(this.minValue,l,r.t0,r.t1,r.ease),t.forEach((c,h)=>{Mt(this.values[h],c,r.t0,r.t1,r.ease);let u=this.bars[h];if(!u)return;let d=f=>this.barPathAt(h,o[h]+(c-o[h])*f,s+(a-s)*f,i+(l-i)*f);u.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:d(1),at:d})})}}}barPathAt(t,e,r,o){let s=r-o||1,i=(t+.5)*this.band,a=this.band*(1-this.gap);if(this.horizontal){let h=-o/s*this.w-this.w/2;return Y(h,i-this.h/2-a/2,e/s*this.w,a)}let l=this.h/2- -o/s*this.h,c=e/s*this.h;return Y(i-this.w/2-a/2,l-c,a,c)}};function zf(n,t={}){return new ao(n,t)}var lo=class extends N{shown;bins;range;chartWidth;chartHeight;axis=new N;total;assigned;peak;constructor(t,e={}){super(),this.chartWidth=e.width??900,this.chartHeight=e.height??480,this.bins=e.bins??24;let r=e.range?.[0]??Math.min(...t),o=e.range?.[1]??Math.max(...t);this.range=[r,o],this.total=t.length,this.assigned=new Int32Array(t.length);let s=new Int32Array(this.bins);t.forEach((g,y)=>{let b=Math.min(this.bins-1,Math.floor((g-r)/(o-r||1)*this.bins));this.assigned[y]=g<r||g>o?-1:b,this.assigned[y]>=0&&s[b]++}),this.peak=e.max??Math.max(1,...s),this.shown=new yt(t.length);let i=e.labelSize??20,a=this.chartWidth,l=this.chartHeight,c=Z([-a/2,l/2],[a/2,l/2],{stroke:e.color??"faint",width:1.5});this.axis.add(c);let{ticks:h,step:u}=Xn(r,o,e.ticks??6);for(let g of h){let y=this.xAt(g);this.axis.add(Z([y,l/2],[y,l/2+6],{stroke:"faint",width:1.5})),this.axis.add(_t(un(g,u),i).at(y,l/2+12+i*.6))}let d=(e.colors??["blue"]).map(g=>Ut(g)),f=d.map((g,y)=>[d.length===1?0:y/(d.length-1),g]),p=e.gap??.12,m=Rt(()=>{let g=Math.max(0,Math.min(this.total,Math.round(this.shown.value))),y=new Int32Array(this.bins);for(let k=0;k<g;k++){let v=this.assigned[k];v>=0&&y[v]++}let b=a/this.bins,w=[],x=[];for(let k=0;k<this.bins;k++){let v=y[k]/this.peak*l;if(v<=0)continue;let M=Y(-a/2+k*b+b*p/2,l/2-v,b*(1-p),v);d.length===1?w.push(...M):x.push(new N(M).fill(ht(f,k/Math.max(1,this.bins-1))))}return w.length&&x.push(new N(w).fill(d[0])),x});this.add(m,this.axis)}xAt(t){let[e,r]=this.range;return((t-e)/(r-e||1)-.5)*this.chartWidth}p(t,e){return[this.xAt(t),this.chartHeight/2-e/this.peak*this.chartHeight]}fillUp(t={}){let e=this.shown,r=t.count??this.total;return{label:"histogram.fill",duration:t.duration??3,ease:t.ease,schedule:o=>{ct(this,o.t0,o.stage),e.track.keys.length===0&&(e.track.initial=0),Mt(e,r,o.t0,o.t1,o.ease)}}}curve(t,e={}){let[r,o]=this.range,s=e.samples??120,i=[];for(let l=0;l<=s;l++){let c=r+(o-r)*l/s;i.push(this.p(c,t(c)))}let a=new N(Wt(i)).stroke(e.color??"yellow",e.width??4);return this.add(a),a}};function $f(n,t={}){return new lo(n,t)}function de(n,t,e){let{xRange:r,yRange:o,w:s,h:i}=n;return[((t-r[0])/(r[1]-r[0]||1)-.5)*s,(.5-(e-o[0])/(o[1]-o[0]||1))*i]}function $i(n,t){let e=new N,r=t.labelSize,o=t.color??"faint",{w:s,h:i}=n,a=Xn(n.xRange[0],n.xRange[1],t.xTicks??6),l=Xn(n.yRange[0],n.yRange[1],t.yTicks??5);for(let c of l.ticks){let[,h]=de(n,n.xRange[0],c);t.gridY!==!1&&e.add(Z([-s/2,h],[s/2,h],{stroke:"grid",width:1.25}));let u=_t(t.yFormat?t.yFormat(c):un(c,l.step),r);e.add(u.at(-s/2-12-u.width/2,h))}e.add(Z([-s/2,i/2],[s/2,i/2],{stroke:o,width:1.5}));for(let c of a.ticks){let[h]=de(n,c,n.yRange[0]);e.add(Z([h,i/2],[h,i/2+6],{stroke:o,width:1.5})),e.add(_t(t.xFormat?t.xFormat(c):un(c,a.step),r).at(h,i/2+12+r*.6))}if(t.xLabel){let c=_t(t.xLabel,r,"ink");e.add(c.at(s/2-c.width/2,i/2+18+r*1.6))}if(t.yLabel){let c=_t(t.yLabel,r,"ink");e.add(c.at(-s/2+c.width/2,-i/2-12-r/2))}return e}var co=class extends N{dots=[];axis;groupLabels=[];frame;constructor(t,e={}){super();let r=t.map(u=>u.x),o=t.map(u=>u.y),s=(u,d)=>(d-u||1)*.06,i=e.x??[Math.min(...r)-s(Math.min(...r),Math.max(...r)),Math.max(...r)+s(Math.min(...r),Math.max(...r))],a=e.y??[Math.min(...o)-s(Math.min(...o),Math.max(...o)),Math.max(...o)+s(Math.min(...o),Math.max(...o))];this.frame={xRange:i,yRange:a,w:e.width??900,h:e.height??520};let l=e.labelSize??18;this.axis=$i(this.frame,{labelSize:l,color:e.color,xLabel:e.xLabel,yLabel:e.yLabel});let c=new Map,h=t.map(u=>{let d=u.color;if(u.group!==void 0){let p=c.get(u.group);p||(p={color:d??fe[c.size%fe.length],sumX:0,top:-1/0,count:0},c.set(u.group,p)),d??=p.color,p.sumX+=u.x,p.top=Math.max(p.top,u.y),p.count++}let f=xt(u.radius??e.radius??6,d??"blue").at(de(this.frame,u.x,u.y));return f.set("fillOpacity",.92),f});if(this.dots.push(...h),this.add(this.axis,...h),e.groupLabels??!0)for(let[u,d]of c){let f=_t(u,l+2,d.color),[p,m]=de(this.frame,d.sumX/d.count,d.top);f.at(p,m-l*1.2),this.groupLabels.push(f),this.add(f)}}p(t,e){return de(this.frame,t,e)}enter(t={}){let e=t.lag??Math.min(.2,8/Math.max(1,this.dots.length));return{label:"scatter.enter",duration:t.duration??2,ease:t.ease,schedule:r=>{ct(this,r.t0,r.stage);let o=r.t1-r.t0;G(this.axis,"opacity",0,r.t0),this.axis.tween("opacity",1,r.t0,r.t0+o*.3,r.ease);let s=[...this.dots].sort((a,l)=>a.get("x")-l.get("x")),i=Ht(s.length,e,r.t0+o*.15,r.t1);s.forEach((a,l)=>{let[c,h]=i[l],u=a.get("sx");G(a,"sx",.001,r.t0),G(a,"sy",.001,r.t0),a.tween("sx",u,c,h,r.ease),a.tween("sy",u,c,h,r.ease)});for(let a of this.groupLabels)G(a,"opacity",0,r.t0),a.tween("opacity",1,r.t0+o*.7,r.t1,r.ease)}}}fit(t,e={}){let[r,o]=this.frame.xRange,s=e.samples??60,i=[];for(let l=0;l<=s;l++){let c=r+(o-r)*l/s;i.push(this.p(c,t(c)))}let a=new N(Wt(i)).stroke(e.color??"yellow",e.width??3.5);return this.add(a),a}};function Lf(n,t={}){return new co(n,t)}var ho=class extends N{lines=[];areas=[];names=[];axis;byName=new Map;frame;constructor(t,e={}){super();let r=t.map(g=>g.points??(g.values??[]).map((y,b)=>[b,y])),o=r.flat().map(g=>g[0]),s=r.flat().map(g=>g[1]),i=Math.min(...s),a=Math.max(...s),l=(a-i||1)*.08,c=e.x??[Math.min(...o),Math.max(...o)],h=e.y??[i>=0&&i<(a-i)*.4?0:i-l,a+l],u=e.width??900,d=e.height??480;this.frame={xRange:c,yRange:h,w:u,h:d};let f=e.labelSize??18;this.axis=$i(this.frame,{labelSize:f,color:e.color,xLabel:e.xLabel,yLabel:e.yLabel,xFormat:e.xFormat,yFormat:e.yFormat,xTicks:e.xTicks,yTicks:e.yTicks}),this.add(this.axis);let p=[];t.forEach((g,y)=>{let b=g.color??fe[y%fe.length],w=r[y].map(([v,M])=>de(this.frame,v,M));if(g.area){let v=de(this.frame,c[0],Math.max(h[0],0))[1],M=et([...w,[w[w.length-1][0],v],[w[0][0],v]],!0),A=new N(M).fill(b,g.area);this.areas.push(A),this.add(A)}let x=g.smooth===!1?et(w):Wt(w),k=new N(x).stroke(b,g.width??3.5);if(g.dash&&k.dash(g.dash),this.lines.push(k),this.add(k),g.name){this.byName.set(g.name,k);let v=_t(g.name,f+1,b),M=w[w.length-1];p.push({label:v,y:M[1]}),v.at(M[0]+12+v.width/2,M[1]),this.names.push(v),this.add(v)}}),p.sort((g,y)=>g.y-y.y);let m=f*1.25;for(let g=0;g<8;g++)for(let y=1;y<p.length;y++){let b=m-(p[y].y-p[y-1].y);b>0&&(p[y-1].y-=b/2,p[y].y+=b/2)}for(let g of p)g.label.at(g.label.get("x"),g.y)}p(t,e){return de(this.frame,t,e)}series(t){let e=this.byName.get(t);if(!e)throw new Error(`No series named ${JSON.stringify(t)}.`);return e}enter(t={}){let e=t.lag??.1;return{label:"lineChart.enter",duration:t.duration??2.2,ease:t.ease,schedule:r=>{ct(this,r.t0,r.stage);let o=r.t1-r.t0;G(this.axis,"opacity",0,r.t0),this.axis.tween("opacity",1,r.t0,r.t0+o*.3,r.ease);let s=Ht(this.lines.length,e,r.t0+o*.15,r.t1);this.lines.forEach((i,a)=>{let[l,c]=s[a];G(i,"trimTo",0,r.t0),i.tween("trimTo",1,l,c,r.ease);let h=this.names[a];h&&(G(h,"opacity",0,r.t0),h.tween("opacity",1,c-(c-l)*.2,Math.min(r.t1,c+o*.1),r.ease))});for(let i of this.areas){let a=i.get("fillOpacity");G(i,"fillOpacity",0,r.t0),i.tween("fillOpacity",a,r.t0+o*.5,r.t1,r.ease)}}}}};function Vf(n,t={}){return new ho(n,t)}function io(n,t,e,r){if(t-n<1e-4)return[];let o=$t(0,0,r,r,n,t)[0].p,s=Array.from(o),i=s[s.length-2],a=s[s.length-1],l=(c,h,u,d)=>{s.push(c+(u-c)/3,h+(d-h)/3,c+(u-c)*2/3,h+(d-h)*2/3,u,d)};if(e>.01){let c=$t(0,0,e,e,t,n)[0].p;l(i,a,c[0],c[1]);for(let h=2;h<c.length;h++)s.push(c[h]);l(c[c.length-2],c[c.length-1],o[0],o[1])}else l(i,a,0,0),l(0,0,o[0],o[1]);return[Ct(s,!0)]}var Yn=class extends N{wedges=[];labels=[];leaders=[];centerText=null;shares;inner;outer;gap;constructor(t,e={}){super(),this.outer=e.radius??240,this.inner=this.outer*(e.hole??0),this.gap=e.gap??(this.inner>0?.018:.008);let r=t.reduce((i,a)=>i+Math.max(0,a.value),0)||1;this.shares=t.map(i=>Math.max(0,i.value)/r);let o=e.labelSize??20,s=this.angles(this.shares);if(t.forEach((i,a)=>{let l=i.color??fe[a%fe.length],[c,h]=s[a],u=new N(io(c,h,this.inner,this.outer)).fill(l,.86);this.wedges.push(u),this.add(u)}),(e.labels??!0)&&t.forEach((i,a)=>{let[l,c]=s[a],h=(l+c)/2,u=Math.cos(h),d=Math.sin(h),f=this.outer+6,p=this.outer+30,m=u*p,g=d*p,y=m+(u>=0?18:-18),b=new N(et([[u*f,d*f],[m,g],[y,g]])).stroke("faint",1.25),x=e.percent??!0?`${i.label} ${Math.round(this.shares[a]*100)}%`:i.label,k=_t(x,o,"ink");k.at(y+(u>=0?8+k.width/2:-8-k.width/2),g),this.leaders.push(b),this.labels.push(k),this.add(b,k)}),e.centerLabel){let i=H(e.centerLabel,{size:e.centerSize??Math.max(24,this.inner*.34),font:"serif",color:"ink"}).at(0,0);this.centerText=i,this.add(i)}}angles(t,e=1){let r=-Math.PI/2;return t.map(o=>{let s=o*Math.PI*2*e,i=Math.min(this.gap*e,s*.45),a=[r+i/2,r+s-i/2];return r+=s,a})}enter(t={}){return{label:"pie.enter",duration:t.duration??1.6,ease:t.ease,schedule:e=>{ct(this,e.t0,e.stage);let r=e.t1-e.t0,o=e.t0+r*.78;this.wedges.forEach((s,i)=>{let a=l=>{let[c,h]=this.angles(this.shares,l)[i];return io(c,h,this.inner,this.outer)};s.track("path").step(e.t0,[]),s.track("path").add({t0:e.t0,t1:o,ease:e.ease,to:a(1),at:a})});for(let s of[...this.labels,...this.leaders,...this.centerText?[this.centerText]:[]])G(s,"opacity",0,e.t0),s.tween("opacity",1,e.t0+r*.62,e.t1,e.ease)}}}update(t,e={}){return{label:"pie.update",duration:e.duration??1.1,ease:e.ease,schedule:r=>{let o=t.reduce((a,l)=>a+Math.max(0,l),0)||1,s=t.map(a=>Math.max(0,a)/o),i=[...this.shares];this.wedges.forEach((a,l)=>{let c=h=>{let u=i.map((p,m)=>p+((s[m]??0)-p)*h),[d,f]=this.angles(u)[l];return io(d,f,this.inner,this.outer)};a.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:c(1),at:c})});for(let a of[...this.labels,...this.leaders])a.tween("opacity",0,r.t0,r.t0+(r.t1-r.t0)*.3,r.ease);s.forEach((a,l)=>{this.shares[l]=a})}}}};function Uf(n,t={}){return new Yn(n,t)}function _f(n,t={}){return new Yn(n,{hole:.62,...t})}var dn=class extends N{cells=[];rowLabels=[];columnLabels=[];numbers=[];rowCount;colCount;stops;domain;constructor(t,e={}){super(),this.rowCount=t.length,this.colCount=Math.max(0,...t.map(f=>f.length));let r=e.cellWidth??e.cell??44,o=e.cellHeight??e.cell??44,s=e.gap??2,i=t.flat();this.domain=e.domain??[Math.min(...i),Math.max(...i)];let a=(e.colors??["surface","blue","yellow"]).map(f=>Ut(f));this.stops=a.map((f,p)=>[a.length===1?0:p/(a.length-1),f]);let l=this.colCount*r+(this.colCount-1)*s,c=this.rowCount*o+(this.rowCount-1)*s,h=e.labelSize??16,u=e.valueSize??Math.min(o*.38,r*.36),d=e.format??(f=>(Math.round(f*100)/100).toString());t.forEach((f,p)=>{let m=[],g=[];f.forEach((y,b)=>{let w=-l/2+b*(r+s)+r/2,x=-c/2+p*(o+s)+o/2,k=this.colorFor(y),v=new N(Y(-r/2,-o/2,r,o,e.radius??0)).fill(k).at(w,x);if(m.push(v),this.add(v),e.values){let M=H(d(y),{size:u,font:"mono",color:Ei(k)>.32?"#101114":"#f2efe6"}).at(w,x);g.push(M),this.add(M)}}),this.cells.push(m),this.numbers.push(g)}),e.rowLabels?.forEach((f,p)=>{let m=_t(f,h),g=-c/2+p*(o+s)+o/2;m.at(-l/2-10-m.width/2,g),this.rowLabels.push(m),this.add(m)}),e.columnLabels?.forEach((f,p)=>{let m=_t(f,h),g=-l/2+p*(r+s)+r/2,y=e.columnLabelAngle??0;if(y!==0){let b=m.width;m.at(g+Math.cos(y)*b/2,-c/2-12+Math.sin(y)*b/2),m.set("rotation",y)}else m.at(g,-c/2-10-h/2);this.columnLabels.push(m),this.add(m)})}colorFor(t){let[e,r]=this.domain;return ht(this.stops,Math.max(0,Math.min(1,(t-e)/(r-e||1))))}cell(t,e){let r=this.cells[t]?.[e];if(!r)throw new Error(`Heatmap has no cell (${t}, ${e}). It is ${this.rowCount} by ${this.colCount}.`);return r}row(t){return[...this.cells[t]??[]]}col(t){return this.cells.map(e=>e[t]).filter(Boolean)}enter(t={}){return{label:"heatmap.enter",duration:t.duration??1.6,ease:t.ease,schedule:e=>{ct(this,e.t0,e.stage);let r=e.t1-e.t0,o=this.rowCount+this.colCount-1,s=r*.5,i=o>1?(r-s)/(o-1):0;this.cells.forEach((a,l)=>a.forEach((c,h)=>{let u=e.t0+(l+h)*i;G(c,"opacity",0,e.t0),c.tween("opacity",1,u,u+s,e.ease);let d=this.numbers[l]?.[h];d&&(G(d,"opacity",0,e.t0),d.tween("opacity",1,u,u+s,e.ease))}));for(let a of[...this.rowLabels,...this.columnLabels])G(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0,e.t0+r*.4,e.ease)}}}update(t,e={}){return{label:"heatmap.update",duration:e.duration??1,ease:e.ease,schedule:r=>{t.forEach((o,s)=>o.forEach((i,a)=>{let l=this.cells[s]?.[a];l&&l.tween("fill",this.colorFor(i),r.t0,r.t1,r.ease)}))}}}};function Bf(n,t={}){return new dn(n,t)}var uo=null,Li=null;function fc(){if(uo)return uo;throw Li??=import("./dagre.esm-6F3RIGLP.js").then(n=>{uo=n.default??n}),new It(Li)}var po=class extends N{shape;caption=null;halfWidth=0;halfHeight=0;round=!0;edgePoint(t,e,r,o,s=0){let i=r-t,a=o-e,l=Math.hypot(i,a)||1;if(this.round)return[t+i/l*(this.halfWidth+s),e+a/l*(this.halfWidth+s)];let c=i===0?1/0:this.halfWidth/Math.abs(i),h=a===0?1/0:this.halfHeight/Math.abs(a),u=Math.min(c,h);return[t+i*u+i/l*s,e+a*u+a/l*s]}},mo=class extends N{shaft;tip=null;caption=null;from="";to="";tipSize=14};function fo(n,t){let e=Tt(n);if(e<=t*1.1)return{head:[],trimmed:n};let r=1-t/e,o=ae(n,0,r),[s,i]=Et(n,1),[a,l]=Pe(n,.997),c=t*.38,h=s-a*t,u=i-l*t;return{head:et([[s,i],[h-l*c,u+a*c],[h+l*c,u-a*c]],!0),trimmed:o}}var qn=class extends N{nodes=new Map;edges=[];edgeLayer=new N;nodeLayer=new N;specs;constructor(t,e,r={}){super(),this.specs=t;let o=r.radius??30,s=r.labelSize??26,i=p=>p.width?[p.width,p.height??s*2]:[(p.radius??o)*2,(p.radius??o)*2],a=r.layout??"dagre",l=new Map,c=new Map;if(a==="dagre"){let p=fc(),m=new p.graphlib.Graph({multigraph:!0});m.setGraph({rankdir:r.direction??"LR",nodesep:r.nodeGap??60,ranksep:r.rankGap??110,edgesep:24,ranker:"network-simplex"}),m.setDefaultEdgeLabel(()=>({}));for(let w of t){let[x,k]=i(w);m.setNode(w.id,{width:x,height:k})}e.forEach((w,x)=>m.setEdge(w.from,w.to,{},String(x))),p.layout(m);let g=m.graph(),y=(g.width??0)/2,b=(g.height??0)/2;for(let w of t){let x=m.node(w.id);l.set(w.id,[x.x-y,x.y-b])}e.forEach((w,x)=>{let k=m.edge({v:w.from,w:w.to,name:String(x)});k?.points&&c.set(w,k.points.map(v=>[v.x-y,v.y-b]))})}else if(a==="circle"){let p=Math.min(r.width??700,r.height??700)/2;t.forEach((m,g)=>{let y=-Math.PI/2+g/t.length*Math.PI*2;l.set(m.id,[Math.cos(y)*p,Math.sin(y)*p])})}else if(a==="force")l=mc(t,e,r.width??900,r.height??620,r.seed??3);else for(let p of t)l.set(p.id,p.at??[0,0]);let h=r.nodeColor??"blue";for(let p of t){let m=new po,g=p.color??h,[y,b]=i(p);m.halfWidth=y/2,m.halfHeight=b/2,m.round=!p.width,m.shape=new N(p.width?Y(-y/2,-b/2,y,b,8):Yt(0,0,y/2)).fill(g,r.fillOpacity??.16).stroke(g,2.5),m.add(m.shape),p.label&&(m.caption=p.math?lt(p.label,{size:s,color:"ink",display:!1}):H(p.label,{size:s,color:"ink"}),m.add(m.caption.at(0,0))),m.named(p.id),m.at(l.get(p.id)??[0,0]),this.nodes.set(p.id,m),this.nodeLayer.add(m)}let u=r.directed??!0,d=r.edgeColor??"dim",f=r.edgeLabelSize??20;for(let p of e){let m=this.nodes.get(p.from),g=this.nodes.get(p.to);if(!m||!g)throw new Error(`Graph edge ${p.from} -> ${p.to} refers to a node that does not exist.`);let y=new mo;y.from=p.from,y.to=p.to;let b=l.get(p.from),w=l.get(p.to),x=c.get(p),k=(r.direction??"LR")==="LR"||r.direction==="RL",v=pc(m,g,b,w,x,k),M=p.directed??u,A=p.color??d,{head:C,trimmed:O}=M?fo(v,y.tipSize):{head:[],trimmed:v};if(y.shaft=new N(O).stroke(A,p.width??2.2),p.dash&&y.shaft.dash(p.dash),y.add(y.shaft),C.length&&(y.tip=new N(C).fill(A),y.add(y.tip)),p.label){let[P,L]=Et(v,.5),F=H(p.label,{size:f,color:"ink",font:"mono"}).at(P,L),_=f*.34,B=new N(Y(P-F.width/2-_,L-f*.68,F.width+_*2,f*1.36,4)).fill("bg");y.caption=new N().add(B,F),y.add(y.caption)}this.edges.push(y),this.edgeLayer.add(y)}this.add(this.edgeLayer,this.nodeLayer)}node(t){let e=this.nodes.get(t);if(!e)throw new Error(`Graph has no node ${JSON.stringify(t)}.`);return e}edge(t,e){let r=this.edges.find(o=>o.from===t&&o.to===e)??this.edges.find(o=>o.from===e&&o.to===t);if(!r)throw new Error(`Graph has no edge ${t} -> ${e}.`);return r}enter(t={}){let e=t.lag??.14;return{label:"graph.enter",duration:t.duration??2,ease:t.ease,schedule:r=>{ct(this,r.t0,r.stage);let o=this.specs.map(a=>this.nodes.get(a.id)),s=Ht(o.length,e,r.t0,r.t0+(r.t1-r.t0)*.78),i=new Map;o.forEach((a,l)=>{let[c,h]=s[l];i.set(a,h),Zn(a,r.t0,c,h,r.ease)});for(let a of this.edges){let l=i.get(this.nodes.get(a.from))??r.t0,c=Math.min(r.t1,l+(r.t1-r.t0)*.22);G(a.shaft,"trimTo",0,r.t0),a.shaft.tween("trimTo",1,l,c,r.ease);for(let h of[a.tip,a.caption])h&&(G(h,"opacity",0,r.t0),h.tween("opacity",1,c-(c-l)*.3,c,r.ease))}}}}pulseEdge(t,e,r={}){let o=this.edge(t,e);return{...kr(o.shaft,{color:r.color??"yellow",length:r.length??.3,...r}),label:"graph.pulse"}}visit(t,e={}){let r=this.node(t),o=e.color??"yellow";return{label:"graph.visit",duration:e.duration??.6,ease:e.ease,schedule:s=>{let i=q(o);r.shape.tween("stroke",i,s.t0,s.t1,s.ease),r.shape.tween("fill",i,s.t0,s.t1,s.ease);let a=s.t1-s.t0,l=r.get("sx");r.tween("sx",l*1.16,s.t0,s.t0+a*.45,s.ease),r.tween("sy",l*1.16,s.t0,s.t0+a*.45,s.ease),r.tween("sx",l,s.t0+a*.45,s.t1,s.ease),r.tween("sy",l,s.t0+a*.45,s.t1,s.ease)}}}moveNode(t,e,r={}){let o=this.node(t);return{label:"graph.move",duration:r.duration??1,ease:r.ease,schedule:s=>{let i=o.get("x"),a=o.get("y");o.tween("x",e[0],s.t0,s.t1,s.ease),o.tween("y",e[1],s.t0,s.t1,s.ease);for(let l of this.edges){if(l.from!==t&&l.to!==t)continue;let c=this.node(l.from===t?l.to:l.from),h=Ne(c,"x",s.t0),u=Ne(c,"y",s.t0),d=p=>{let m=i+(e[0]-i)*p,g=a+(e[1]-a)*p,y=l.from===t?o.edgePoint(m,g,h,u,2):c.edgePoint(h,u,m,g,2),b=l.from===t?c.edgePoint(h,u,m,g,4):o.edgePoint(m,g,h,u,4);return et([y,b])},f=p=>l.tip?fo(d(p),l.tipSize).trimmed:d(p);if(l.shaft.track("path").add({t0:s.t0,t1:s.t1,ease:s.ease,to:f(1),at:f}),l.tip){let p=m=>fo(d(m),l.tipSize).head;l.tip.track("path").add({t0:s.t0,t1:s.t1,ease:s.ease,to:p(1),at:p})}}}}}};function pc(n,t,e,r,o,s){let i=o?o.slice(1,-1):[],a=i[0]??r,l=i[i.length-1]??e,c=n.edgePoint(e[0],e[1],a[0],a[1],2),h=t.edgePoint(r[0],r[1],l[0],l[1],4);if(!o)return et([c,h]);if(i.length<=1){let u=h[0]-c[0],d=h[1]-c[1];if(Math.abs(s?d:u)<2)return et([c,h]);let f=(s?u:d)*.5,p=s?`${c[0]+f} ${c[1]}`:`${c[0]} ${c[1]+f}`,m=s?`${h[0]-f} ${h[1]}`:`${h[0]} ${h[1]-f}`;return St(`M${c[0]} ${c[1]}C${p} ${m} ${h[0]} ${h[1]}`)}return Wt([c,...i.slice(1,-1),h])}function Zn(n,t,e,r,o){let s=Ne(n,"sx",e),i=Ne(n,"sy",e);G(n,"sx",s*.001,t),G(n,"sy",i*.001,t),n.tween("sx",s,e,r,o),n.tween("sy",i,e,r,o)}function mc(n,t,e,r,o){let s=hn(o),i=n.map(d=>d.id),a=new Float64Array(i.length),l=new Float64Array(i.length);for(let d=0;d<i.length;d++)a[d]=(s()-.5)*e,l[d]=(s()-.5)*r;let c=new Map(i.map((d,f)=>[d,f])),h=Math.sqrt(e*r/Math.max(1,i.length))*.72,u=Math.max(e,r)*.12;for(let d=0;d<420;d++){let f=new Float64Array(i.length),p=new Float64Array(i.length);for(let m=0;m<i.length;m++)for(let g=m+1;g<i.length;g++){let y=a[m]-a[g],b=l[m]-l[g],w=Math.max(1,Math.hypot(y,b)),x=h*h/w;f[m]+=y/w*x,p[m]+=b/w*x,f[g]-=y/w*x,p[g]-=b/w*x}for(let m of t){let g=c.get(m.from),y=c.get(m.to);if(g===void 0||y===void 0)continue;let b=a[g]-a[y],w=l[g]-l[y],x=Math.max(1,Math.hypot(b,w)),k=x*x/h;f[g]-=b/x*k,p[g]-=w/x*k,f[y]+=b/x*k,p[y]+=w/x*k}for(let m=0;m<i.length;m++){let g=Math.max(1e-6,Math.hypot(f[m],p[m]));a[m]+=f[m]/g*Math.min(g,u),l[m]+=p[m]/g*Math.min(g,u),a[m]=Math.max(-e/2,Math.min(e/2,a[m])),l[m]=Math.max(-r/2,Math.min(r/2,l[m]))}u*=.985}return new Map(i.map((d,f)=>[d,[a[f],l[f]]]))}function ep(n,t,e={}){return new qn(n,t,e)}var go=class extends qn{depths=new Map;constructor(t,e={}){let r=[],o=[],s=new Map,i=e.levelGap??130,a=e.siblingGap??96,l=0,c=0,h=(m,g)=>{let y=m.id??`n${l++}`;s.set(y,g);let b=m.children??[],w,x={id:y,label:m.label,color:m.color,math:m.math};if(r.push(x),b.length===0)w=c++;else{let k=b.map(v=>h(v,g+1));w=(k[0].position+k[k.length-1].position)/2;for(let v of k)o.push({from:y,to:v.id,directed:!1})}return x.at=e.direction==="right"?[g*i,w*a]:[w*a,g*i],{id:y,position:w}};h(t,0);let u=r.map(m=>m.at[0]),d=r.map(m=>m.at[1]),f=(Math.min(...u)+Math.max(...u))/2,p=(Math.min(...d)+Math.max(...d))/2;for(let m of r)m.at=[m.at[0]-f,m.at[1]-p];super(r,o,{layout:"manual",radius:e.radius??28,labelSize:e.labelSize??24,nodeColor:e.nodeColor,edgeColor:e.edgeColor,fillOpacity:e.fillOpacity,directed:!1});for(let[m,g]of s)this.depths.set(m,g)}enter(t={}){return{label:"tree.enter",duration:t.duration??2,ease:t.ease,schedule:e=>{ct(this,e.t0,e.stage);let r=Math.max(...this.depths.values())+1,o=(e.t1-e.t0)/r;for(let[s,i]of this.nodes){let a=this.depths.get(s)??0,l=e.t0+a*o;Zn(i,e.t0,l,l+o,e.ease)}for(let s of this.edges){let i=this.depths.get(s.to)??1,a=e.t0+(i-1)*o+o*.3;G(s.shaft,"trimTo",0,e.t0),s.shaft.tween("trimTo",1,a,a+o*.8,e.ease)}}}}};function np(n,t={}){return new go(n,t)}var bo=class extends N{slots=[];indexLabels=[];items=[];cellSize;step;constructor(t,e={}){super();let r=this.cellSize=e.cell??72,o=e.gap??6;this.step=r+o;let s=e.size??r*.38,i=e.color??"blue",a=-((t.length-1)*this.step)/2;t.forEach((l,c)=>{let h=a+c*this.step,u=new N(Y(-r/2,-r/2,r,r,6)).stroke("faint",1.5).at(h,0);if(this.slots.push(u),this.add(u),e.indices??!0){let d=H(String(c),{size:e.indexSize??Math.max(13,r*.2),color:"faint",font:"mono"}).at(h,r/2+(e.indexSize??r*.2)+2);this.indexLabels.push(d),this.add(d)}}),t.forEach((l,c)=>{let h=a+c*this.step,u=new N().at(h,0),d=new N(Y(-r/2+2,-r/2+2,r-4,r-4,5)).fill(i,.16).stroke(i,2),f=H(String(l),{size:s,font:e.font??"mono",color:"ink"}).at(0,0);u.add(d,f),u.data.box=d,u.data.value=l,this.items.push(u),this.add(u)})}cell(t){let e=this.items[t];if(!e)throw new Error(`Array has no index ${t}.`);return e}slotAt(t){return[this.slots[t].get("x"),this.slots[t].get("y")]}swap(t,e,r={}){return{label:"array.swap",duration:r.duration??.8,ease:r.ease,schedule:o=>{let s=this.items[t],i=this.items[e],[a,l]=this.slotAt(t),[c,h]=this.slotAt(e),u=r.lift??this.cellSize*.9+Math.abs(t-e)*6,d=(f,p,m,g,y,b)=>{f.track("x").add({t0:o.t0,t1:o.t1,ease:o.ease,to:g,at:w=>p+(g-p)*w}),f.track("y").add({t0:o.t0,t1:o.t1,ease:o.ease,to:y,at:w=>m+(y-m)*w-b*u*4*w*(1-w)})};d(s,a,l,c,h,1),d(i,c,h,a,l,-1),this.items[t]=i,this.items[e]=s}}}mark(t,e,r={}){let o=this.cell(t);return{...cs(o.data.box,e,{duration:.35,...r}),label:"array.mark"}}enter(t={}){let e=t.lag??.2;return{label:"array.enter",duration:t.duration??1.2,ease:t.ease,schedule:r=>{ct(this,r.t0,r.stage);let o=Ht(this.items.length,e,r.t0,r.t1);this.items.forEach((s,i)=>{let[a,l]=o[i];Zn(s,r.t0,a,l,r.ease),G(this.slots[i],"opacity",0,r.t0),this.slots[i].tween("opacity",1,a,l,r.ease);let c=this.indexLabels[i];c&&(G(c,"opacity",0,r.t0),c.tween("opacity",1,a,l,r.ease))})}}}};function rp(n,t={}){return new bo(n,t)}var Vi={ts:new Set("const let var function return if else for while do switch case break continue new class extends implements interface type enum import export from default async await yield try catch finally throw typeof instanceof in of this super null undefined true false void as readonly public private protected static get set".split(" ")),python:new Set("def return if elif else for while in not and or is class import from as with try except finally raise lambda yield pass break continue global nonlocal None True False self async await assert del print".split(" ")),rust:new Set("fn let mut pub struct enum impl trait use mod match if else for while loop return self Self as in where const static crate super true false ref move async await dyn type".split(" ")),go:new Set("func var const type struct interface package import return if else for range switch case default break continue go defer select chan map nil true false".split(" ")),sql:new Set("select from where join left right inner outer on group by order having limit as and or not in is null insert into values update set delete create table with distinct count sum avg min max".split(" ")),bash:new Set("if then else elif fi for do done while case esac in function return export local echo cd exit set".split(" ")),plain:new Set};function gc(n,t="ts"){let e=t==="js"||t==="tsx"||t==="jsx"||t==="typescript"||t==="javascript"?"ts":t==="py"?"python":t,r=Vi[e]??Vi.ts,o=e==="sql",s=e==="python"||e==="bash",i=e==="sql",a=[];return n.split(`
3
+ `).forEach((l,c)=>{let h=0;for(;h<l.length;){let u=l.slice(h),d=(y,b)=>{a.push({text:y,kind:b,line:c}),h+=y.length},f=/^\s+/.exec(u);if(f){d(f[0],"space");continue}if(!s&&!i&&u.startsWith("//")||s&&u[0]==="#"||i&&u.startsWith("--")){d(u,"comment");continue}let p=/^("(?:[^"\\]|\\.)*"?|'(?:[^'\\]|\\.)*'?|`(?:[^`\\]|\\.)*`?)/.exec(u);if(p){d(p[0],"string");continue}let m=/^(0x[\da-fA-F_]+|\d[\d_]*(?:\.\d+)?(?:e[-+]?\d+)?)/.exec(u);if(m){d(m[0],"number");continue}let g=/^[A-Za-z_$][\w$]*/.exec(u);if(g){let y=g[0],b=u.slice(y.length),x=r.has(o?y.toLowerCase():y)?"keyword":/^\s*\(/.test(b)?"function":/^[A-Z]/.test(y)?"type":"plain";d(y,x);continue}d(u[0],"punctuation")}}),a}var bc={keyword:"purple",string:"green",number:"orange",comment:"faint",function:"blue",type:"teal",punctuation:"dim",plain:"ink"},yo=class extends N{lines=[];tokens=[];chars=[];panelNode=null;body=new N;source;bar;rowHeight;originY;contentWidth;constructor(t,e={}){super(),this.source=t;let r=e.size??26,o=this.rowHeight=r*(e.leading??1.5),s=Fe("mono",400),i=r/s.unitsPerEm,a=s.advance(s.glyphFor(48))*i,l=gc(t,e.language??"ts"),c=t.split(`
4
+ `),h=e.lineNumbers?(String(c.length).length+2)*a:0,u=e.padding??r*.9,d=Math.max(e.minWidth??0,Math.max(...c.map(b=>b.length))*a+h+u*2),f=c.length*o+u*2-(o-r);this.contentWidth=d;let p=-d/2+u+h,m=-f/2+u+r*.82;if(this.originY=m,e.panel??!0){let b=new N(Y(-d/2,-f/2,d,f,8)).fill("surface").stroke("gridStrong",1);this.panelNode=b,this.add(b)}this.bar=new N().fill("yellow",.1),this.bar.base.visible=!1,this.add(this.bar);for(let b=0;b<c.length;b++){let w=new N;if(this.lines.push(w),this.body.add(w),e.lineNumbers){let x=String(b+1).padStart(String(c.length).length," "),k=p-h;for(let v of x)v!==" "&&w.add(Ui(s,v,r,"faint",k,m+b*o)),k+=a}}let g={...bc,...e.colors},y=new Map;for(let b of l){let w=y.get(b.line)??0;y.set(b.line,w+b.text.length);let x={...b,glyphs:[]};if(this.tokens.push(x),b.kind==="space")continue;let k=g[b.kind];[...b.text].forEach((v,M)=>{let A=Ui(s,v,r,k,p+(w+M)*a,m+b.line*o);x.glyphs.push(A),this.chars.push(A),this.lines[b.line].add(A)})}this.add(this.body)}line(t){let e=this.lines[t];if(!e)throw new Error(`Code has no line ${t}.`);return e}find(t){return this.tokens.filter(e=>e.text===t).flatMap(e=>e.glyphs)}focus(t,e={}){let r=new Set(typeof t=="number"?[t]:t);return{label:"code.focus",duration:e.duration??.6,ease:e.ease,schedule:o=>{this.lines.forEach((d,f)=>{d.tween("opacity",r.has(f)?1:e.dim??.28,o.t0,o.t1,o.ease)});let s=[...r].sort((d,f)=>d-f),i=s[0]??0,a=s[s.length-1]??i,l=this.originY-this.rowHeight*.32+(i+a)/2*this.rowHeight,c=a-i+1,h=Y(-this.contentWidth/2+2,-this.rowHeight*c/2,this.contentWidth-4,this.rowHeight*c,3);Ne(this.bar,"visible",o.t0)?(this.bar.tween("y",l,o.t0,o.t1,o.ease),this.bar.tween("path",h,o.t0,o.t1,o.ease)):(G(this.bar,"x",0,o.t0),G(this.bar,"y",l,o.t0),this.bar.track("path").step(o.t0,h),G(this.bar,"visible",!0,o.t0),G(this.bar,"opacity",0,o.t0),this.bar.tween("opacity",1,o.t0,o.t1,o.ease)),e.color&&this.bar.tween("fill",q(e.color),o.t0,o.t1,o.ease)}}}unfocus(t={}){return{label:"code.unfocus",duration:t.duration??.5,ease:t.ease,schedule:e=>{for(let r of this.lines)r.tween("opacity",1,e.t0,e.t1,e.ease);this.bar.tween("opacity",0,e.t0,e.t1,e.ease),G(this.bar,"visible",!1,e.t1)}}}};function Ui(n,t,e,r,o,s){let i=new N(sn(n,n.glyphFor(t.codePointAt(0)),e));return i.base.fill=q(r),i.base.trimEach=!0,i.data.key=t,i.at(o,s)}function op(n,t={}){return new yo(n,t)}function sp(n,t,e={}){let r=h=>h.tokens.filter(u=>u.kind!=="space"&&u.glyphs.length>0),o=r(n),s=r(t),i=Mn(o.map(h=>h.text),s.map(h=>h.text)),a=new Map;i.forEach(([h,u],d)=>{o[h].glyphs.forEach((f,p)=>a.set(f,`m${d}:${p}`)),s[u].glyphs.forEach((f,p)=>a.set(f,`m${d}:${p}`))}),n.panelNode&&t.panelNode&&(a.set(n.panelNode,"panel"),a.set(t.panelNode,"panel"));let l=0;return{...Ee(n,t,{duration:1.5,...e,key:h=>{let u=a.get(h);return u===void 0&&(u=`only:${l++}`,a.set(h,u)),u}}),label:"morphCode"}}var wo=class extends N{neurons=[];links=[];edgeLayer=new N;neuronLayer=new N;captions=[];seed;layerColors;constructor(t,e={}){super();let r=e.width??1e3,o=e.height??560,s=e.radius??15,i=e.collapse??8,a=t.length>1?r/(t.length-1):0;this.seed=e.seed??11,this.layerColors=e.colors??["blue","teal","teal","yellow"];let l=e.edgeColor??"dim",c=e.edgeOpacity??.32,h=[];t.forEach((u,d)=>{let f=u>i?i:u,p=Math.min(s*3.6,o/Math.max(1,f+(u>i?1:0))),m=-r/2+d*a,g=[],y=[],b=this.layerColors[Math.min(d,this.layerColors.length-1)],w=Math.ceil(f/2);for(let k=0;k<f+(u>i?1:0);k++){let v=(k-(f+(u>i?1:0)-1)/2)*p;if(u>i&&k===w){this.neuronLayer.add(lt("\\vdots",{size:s*1.9,color:"dim",display:!1}).at(m,v));continue}g.push([m,v]);let M=new N(Yt(0,0,s)).stroke(b,2.2).fill(b,.08).at(m,v);y.push(M),this.neuronLayer.add(M)}h.push(g),this.neurons.push(y);let x=e.layerLabels?.[d];if(x){let k=e.labelSize??22,v=H(x,{size:k,color:"dim"}).at(m,o/2+k*1.5);this.captions.push(v),this.add(v)}});for(let u=0;u+1<h.length;u++){let d=[];for(let f of h[u]){let p=[];for(let m of h[u+1]){let g=Math.hypot(m[0]-f[0],m[1]-f[1])||1,y=(m[0]-f[0])/g,b=(m[1]-f[1])/g,w=Z([f[0]+y*s,f[1]+b*s],[m[0]-y*s,m[1]-b*s],{stroke:l,width:1.1});w.set("strokeOpacity",c),p.push(w),this.edgeLayer.add(w)}d.push(p)}this.links.push(d)}this.add(this.edgeLayer,this.neuronLayer)}layer(t){return this.neurons[t]??[]}enter(t={}){return{label:"net.enter",duration:t.duration??2.2,ease:t.ease,schedule:e=>{ct(this,e.t0,e.stage);let r=e.t1-e.t0,o=this.neurons.length,s=r*.45,i=o>1?r*.55/(o-1):0;this.neurons.forEach((a,l)=>{let c=Ht(a.length,.12,e.t0+l*i,e.t0+l*i+s);a.forEach((h,u)=>Zn(h,e.t0,c[u][0],c[u][1],e.ease))}),this.links.forEach((a,l)=>{let c=e.t0+l*i+s*.45;for(let h of a)for(let u of h)G(u,"trimTo",0,e.t0),u.tween("trimTo",1,c,c+s,e.ease)});for(let a of this.neuronLayer.children)a.get("path")||(G(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0+r*.3,e.t1,e.ease));for(let a of this.captions)G(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0+r*.3,e.t1,e.ease)}}}activate(t,e,r={}){return{label:"net.activate",duration:r.duration??.45,ease:r.ease,schedule:o=>{this.neurons[t].forEach((s,i)=>{let a=Math.max(.04,Math.min(1,e[i]??0));s.tween("fillOpacity",a,o.t0,o.t1,o.ease),r.color&&s.tween("fill",q(r.color),o.t0,o.t1,o.ease)})}}}forward(t={}){let e=hn(this.seed),r=this.neurons.map((a,l)=>t.activations?.[l]??a.map(()=>e()*e())),o=t.color??"yellow",s=[];r.forEach((a,l)=>{if(s.push(this.activate(l,a,{duration:.35})),l+1>=this.neurons.length)return;let c=[];this.links[l].forEach((u,d)=>u.forEach((f,p)=>{c.push({link:f,score:(a[d]??0)*(r[l+1]?.[p]??0)})})),c.sort((u,d)=>d.score-u.score);let h=c.slice(0,t.pulses??10);s.push(wr(...h.map(({link:u,score:d})=>kr(u,{color:o,length:.42,width:1.5+d*3,glow:4,duration:.7}))))});let i=ss(...s);return{...i,label:"net.forward",duration:t.duration??i.duration,ease:t.ease}}};function ip(n,t={}){return new wo(n,t)}var xo=class extends N{chips=[];constructor(t,e={}){super();let r=e.size??22,o=e.gap??r*.28,s=e.subSize??r*.62,i=r*.42,a=r*.3,l=t.map(g=>typeof g=="string"?{text:g}:g),c=e.colors?Ke(l.length,...e.colors):null,h=0,u=0,d=[],f=r+a*2+(l.some(g=>g.sub)?s*1.4:0);for(let g=0;g<l.length;g++){let y=l[g],b=y.color??(c?c[g]:e.color??"blue"),w=H(y.text.replace(/ /g,"\xB7"),{size:r,font:e.font??"mono",color:"ink"}),x=Math.max(w.width,r*.5)+i*2,k=r+a*2;e.maxWidth!==void 0&&h>0&&h+x>e.maxWidth&&(h=0,u+=f+o);let v=new N,M=new N(Y(-x/2,-k/2,x,k,e.radius??4)).fill(b,.18).stroke(b,1.5);v.add(M,w.at(0,0)),y.sub&&v.add(H(y.sub,{size:s,font:"mono",color:"dim"}).at(0,k/2+s*.82)),v.data.box=M,d.push({node:v,x:h+x/2,y:u,w:x}),h+=x+o}let p=Math.max(...d.map(g=>g.x+g.w/2),0),m=Math.max(...d.map(g=>g.y),0);for(let g of d)g.node.at(g.x-p/2,g.y-m/2),this.chips.push(g.node),this.add(g.node)}token(t){let e=this.chips[t];if(!e)throw new Error(`Token row has no token ${t}.`);return e}enter(t={}){let e=t.lag??.16;return{label:"tokens.enter",duration:t.duration??1.2,ease:t.ease,schedule:r=>{ct(this,r.t0,r.stage);let o=Ht(this.chips.length,e,r.t0,r.t1);this.chips.forEach((s,i)=>{let[a,l]=o[i],c=s.get("y");G(s,"opacity",0,r.t0),G(s,"y",c+16,r.t0),s.tween("opacity",1,a,l,r.ease),s.tween("y",c,a,l,r.ease)})}}}arcs(t,e,r={}){let o=this.token(t).bounds(),s=new N,i=o.x+o.width/2,a=o.y-3;return e.forEach((l,c)=>{if(c===t||l<=.01)return;let h=this.token(c).bounds(),u=h.x+h.width/2,d=h.y-3,f=r.lift??40+Math.abs(u-i)*.22,p=St(`M${i} ${a}C${i} ${a-f} ${u} ${d-f} ${u} ${d}`),m=new N(p).stroke(r.color??"yellow",.8+l*(r.maxWidth??6));m.set("strokeOpacity",.2+l*.8),s.add(m)}),s}};function ap(n,t={}){return new xo(n,t)}function lp(n,t,e,r={}){return new dn(e,{cell:r.cell??42,gap:r.gap??2,colors:r.colors??["surface","teal","yellow"],domain:[0,Math.max(...e.flat())],values:r.values,rowLabels:n,columnLabels:t,labelSize:r.labelSize??18,columnLabelAngle:-Math.PI/4})}function oe(n,t,e,r="left"){let o=n.get("px");return n.at(r==="left"?t+o:r==="right"?t-o:t,e)}function Qt(n){return n.get("px")*2}var vo=class extends N{frame;accentBar=null;titleNode;subtitleNode=null;badgeNode=null;rowLabels=[];rowValues=[];meters=[];tagNodes=[];boxWidth;boxHeight;valueSize;constructor(t){super();let e=t.size??14;this.valueSize=e;let r=e*.8,o=t.rows??[],s=e*1.56,i=H(t.title,{size:e*1.14,weight:600,color:"ink"}),a=t.subtitle?H(t.subtitle,{size:e*.86,font:"mono",color:"dim"}):null,l=t.badgeTone??t.accent??"dim",c=t.badge?H(t.badge,{size:e*.78,font:"mono",color:l}):null,h=o.map(v=>H(v.label,{size:e,color:"dim"})),u=o.map(v=>v.value!==void 0?H(v.value,{size:e,font:"mono",color:v.tone??"ink"}):null),d=e*3.6,f=Math.max(Qt(i)+(c?Qt(c)+e*1.6:0),a?Qt(a):0,...o.map((v,M)=>Qt(h[M])+(u[M]?Qt(u[M])+e*1.1:0)+(v.spark?d+e*.6:0)),0),p=this.boxWidth=Math.max(t.width??0,f+r*2),m=e*1.4+(a?e*1.2:0),g=o.reduce((v,M)=>v+s+(M.meter!==void 0?e*.32:0),0),y=t.tags?.length?e*1.72:0,b=this.boxHeight=r*1.5+m+(o.length?e*.55:0)+g+y,w=-p/2+r,x=p/2-r;if(this.frame=new N(Y(-p/2,-b/2,p,b,t.radius??4)).fill(t.fill??"surface").stroke(t.border??"gridStrong",1),this.add(this.frame),t.accent){let v=new N(Y(-p/2,-b/2+1,2.5,b-2)).fill(t.accent);this.accentBar=v,this.add(v)}let k=-b/2+r*.75+e*.62;if(this.titleNode=oe(i,w,k),this.add(i),c&&(this.badgeNode=oe(c,x,k,"right"),this.add(c)),k+=e*1.3,a&&(this.subtitleNode=oe(a,w,k-e*.1),this.add(a),k+=e*1.2),o.length){let v=k-e*.38;this.add(Z([-p/2+r,v],[p/2-r,v],{stroke:"grid",width:1})),k+=e*.5}if(o.forEach((v,M)=>{oe(h[M],w,k),this.rowLabels.push(h[M]),this.add(h[M]);let A=x,C=u[M];if(C&&(oe(C,A,k,"right"),this.add(C),A-=Qt(C)+e*.7),this.rowValues.push(C??null),v.spark){let O=yc(v.spark,{width:d,height:e*.82,color:v.tone??"blue",dotted:!0,weight:1.2});this.add(O.at(A-d/2,k-e*.1))}if(k+=s,v.meter!==void 0){let O=k-e*.62;this.add(Z([w,O],[x,O],{stroke:"grid",width:2}));let P=Z([w,O],[w+(x-w)*Math.max(0,Math.min(1,v.meter)),O],{stroke:v.tone??"blue",width:2});P.set("cap","butt"),this.meters.push(P),this.add(P),k+=e*.32}}),t.tags?.length){let v=w,M=b/2-r*.7-e*.4;for(let A of t.tags){let C=H(A,{size:e*.78,font:"mono",color:"dim"}),O=Qt(C)+e*.7,P=new N(Y(v,M-e*.62,O,e*1.24,2)).stroke("gridStrong",1);oe(C,v+e*.35,M),this.tagNodes.push(C),this.add(P,C),v+=O+e*.34}}}port(t,e=0){let r=this.bounds(),o=r.x+r.width/2,s=r.y+r.height/2;return t==="left"?[r.x,s+e*r.height/2]:t==="right"?[r.x+r.width,s+e*r.height/2]:t==="top"?[o+e*r.width/2,r.y]:[o+e*r.width/2,r.y+r.height]}enter(t={}){return{label:"infoBox.enter",duration:t.duration??.9,ease:t.ease,schedule:e=>{ct(this,e.t0,e.stage);let r=e.t1-e.t0,o=this.frame.get("fillOpacity");G(this.frame,"trimTo",0,e.t0),G(this.frame,"fillOpacity",0,e.t0),this.frame.tween("trimTo",1,e.t0,e.t0+r*.65,e.ease),this.frame.tween("fillOpacity",o,e.t0+r*.2,e.t0+r*.8,e.ease);let s=this.children.filter(a=>a!==this.frame),i=Ht(s.length,.06,e.t0+r*.25,e.t1);s.forEach((a,l)=>{let[c,h]=i[l],u=a.get("opacity");G(a,"opacity",0,e.t0),a.tween("opacity",u,c,h,e.ease)})}}}setValue(t,e,r={}){let o=this.rowValues[t];if(!o)throw new Error(`Info box row ${t} has no value to change.`);let s=H(e,{size:this.valueSize,font:"mono",color:r.tone??"ink"}),i=o.get("x")+o.get("px");oe(s,i,o.get("y"),"right");let a=Ee(o,s,{duration:.5,...r});return{...a,label:"infoBox.setValue",schedule:l=>{this.add(s),this.rowValues[t]=s,a.schedule(l)}}}};function bp(n){return new vo(n)}function yc(n,t={}){let e=t.width??80,r=t.height??20,o=Math.min(...n),i=Math.max(...n)-o||1,a=n.map((h,u)=>[(u/Math.max(1,n.length-1)-.5)*e,(.5-(h-o)/i)*r]),l=t.color??"blue",c=new N;return t.area&&c.add(new N(et([...a,[e/2,r/2],[-e/2,r/2]],!0)).fill(l,t.area)),c.add(new N(n.length>2?Wt(a):et(a)).stroke(l,t.weight??1.5)),t.dotted&&c.add(xt((t.weight??1.5)*1.5,l).at(a[a.length-1])),c}var _i={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]};function Bi(n,t,e){let r=n.x+n.width/2,o=n.y+n.height/2;return t==="left"?[n.x,o+e*n.height/2]:t==="right"?[n.x+n.width,o+e*n.height/2]:t==="top"?[r+e*n.width/2,n.y]:[r+e*n.width/2,n.y+n.height]}function wc(n,t){let e=Math.max(t.x-(n.x+n.width),n.x-(t.x+t.width)),r=Math.max(t.y-(n.y+n.height),n.y-(t.y+t.height)),o=n.x+n.width/2,s=n.y+n.height/2,i=t.x+t.width/2,a=t.y+t.height/2;return e>=r?i>=o?["right","left"]:["left","right"]:a>=s?["bottom","top"]:["top","bottom"]}function ko(n,t){let e=`M${n[0][0]} ${n[0][1]}`;for(let o=1;o<n.length-1;o++){let s=n[o-1],i=n[o],a=n[o+1],l=Math.hypot(i[0]-s[0],i[1]-s[1]),c=Math.hypot(a[0]-i[0],a[1]-i[1]),h=Math.min(t,l/2,c/2);if(h<.5){e+=`L${i[0]} ${i[1]}`;continue}let u=i[0]-(i[0]-s[0])/(l||1)*h,d=i[1]-(i[1]-s[1])/(l||1)*h,f=i[0]+(a[0]-i[0])/(c||1)*h,p=i[1]+(a[1]-i[1])/(c||1)*h;e+=`L${u} ${d}Q${i[0]} ${i[1]} ${f} ${p}`}let r=n[n.length-1];return St(`${e}L${r[0]} ${r[1]}`)}var Mo=class extends N{fromEnd;toEnd;options;pulses=[];plate=null;caption=null;constructor(t,e,r={}){super([]),this.fromEnd=t,this.toEnd=e,this.options=r,this.base.stroke=q(r.color??"dim"),this.base.strokeWidth=r.width??1.6,this.draw=o=>this.build(o)}anchors(){let{fromEnd:t,toEnd:e,options:r}=this,o=r.gap??3,s=f=>f instanceof N?f.bounds():{x:f[0],y:f[1],width:0,height:0},i=s(t),a=s(e),[l,c]=wc(i,a),h=r.from??l,u=r.to??c,d=(f,p,m,g)=>{let y=_i[m];if(!(f instanceof N))return{point:f,normal:y};let[b,w]=Bi(p,m,g);return{point:[b+y[0]*o,w+y[1]*o],normal:y}};return[d(t,i,h,r.fromOffset??0),d(e,a,u,r.toOffset??0)]}routeNow(){let[t,e]=this.anchors(),r=this.options.route??"curve";if(r==="straight")return et([t.point,e.point]);if(r==="ortho"){let l=this.options.radius??8,c=t.normal[0]!==0,h=e.normal[0]!==0;if(c&&h){let d=(t.point[0]+e.point[0])/2;return ko([t.point,[d,t.point[1]],[d,e.point[1]],e.point],l)}if(!c&&!h){let d=(t.point[1]+e.point[1])/2;return ko([t.point,[t.point[0],d],[e.point[0],d],e.point],l)}let u=c?[e.point[0],t.point[1]]:[t.point[0],e.point[1]];return ko([t.point,u,e.point],l)}let o=Math.hypot(e.point[0]-t.point[0],e.point[1]-t.point[1]),s=Math.max(18,o*(this.options.curvature??.42)),i=[t.point[0]+t.normal[0]*s,t.point[1]+t.normal[1]*s],a=[e.point[0]+e.normal[0]*s,e.point[1]+e.normal[1]*s];return St(`M${t.point[0]} ${t.point[1]}C${i[0]} ${i[1]} ${a[0]} ${a[1]} ${e.point[0]} ${e.point[1]}`)}build(t){let e=this.parent&&this.parent!==null?Xt(this.worldMatrix()):Dt,r=at(this.routeNow(),e),o=Tt(r);if(o<1)return[];let s=this.get("trimTo"),i=this.options,a=this.get("stroke"),l=this.get("strokeWidth"),c=[],h=i.tip??!0,u=h?i.tipSize??Math.max(7,l*4.4):0,d=s*(1-u/o),f=ae(r,this.get("trimFrom"),d),p=a??q("dim");if(f.length){let m=new N(f).stroke(p,l);(i.dash||i.flow)&&m.dash(i.dash??[6,6],i.flow?-t*i.flow:0),m.set("strokeOpacity",this.get("strokeOpacity")),c.push(m)}if(h&&s>.02){let[m,g]=Et(r,s),[y,b]=Pe(r,Math.min(.997,s)),w=u*.38,x=m-y*u,k=g-b*u;c.push(new N(et([[m,g],[x-b*w,k+y*w],[x+b*w,k-y*w]],!0)).fill(p))}for(let m of this.pulses){if(t<m.t0||t>=m.t1)continue;let g=m.ease((t-m.t0)/(m.t1-m.t0)),y=Math.max(0,g*(1+m.length)-m.length),b=Math.min(1,g*(1+m.length)),w=ae(r,y,b);w.length&&c.push(new N(w).stroke(m.color,m.width).glow(m.glow))}if(i.label&&s>.5){let m=i.labelSize??12;this.caption??=H(i.label,{size:m,font:"mono",color:i.labelColor??"dim"});let g=Qt(this.caption),y=m*.35;this.plate??=new N(Y(-g/2-y,-m*.72,g+y*2,m*1.44,2)).fill(i.labelBackground??"bg");let[b,w]=Et(r,i.labelAt??.5),x=Math.min(1,(s-.5)*4);c.push(this.plate.at(b,w).opacity(x),this.caption.at(b,w).opacity(x))}return c}pulse(t={}){return{label:"connector.pulse",duration:t.duration??.9,ease:t.ease,schedule:e=>{ct(this,e.t0,e.stage),this.pulses.push({t0:e.t0,t1:e.t1,ease:e.ease,color:t.color??"yellow",length:t.length??.22,width:t.width??this.get("strokeWidth")+1.2,glow:t.glow??6})}}}pointNow(t=.5){return Et(this.routeNow(),t)}};function yp(n,t,e={}){return new Mo(n,t,e)}function wp(n,t={}){let e=t.size??13,r=(t.direction??"row")==="row",o=t.gap??(r?e*1.5:e*.6),s=e*1.5,i=new N,a=0,l=[];for(let d of n){let f=d.color??"dim",p=d.kind??"swatch",m=p==="line"?Z([-s/2,0],[s/2,0],{stroke:f,width:2.2}):p==="dash"?Z([-s/2,0],[s/2,0],{stroke:f,width:2,dash:[4,3.5]}):p==="dot"?xt(e*.32,f):p==="ring"?mi(e*.32,{stroke:f,width:1.6}):new N(Y(-e*.42,-e*.42,e*.84,e*.84,1.5)).fill(f),g=H(d.label,{size:e,color:"dim"}),y=s+e*.5+Qt(g),b=new N;b.add(m.at(s/2,0)),oe(g,s+e*.5,0),b.add(g),l.push({node:b,width:y})}let c=l.reduce((d,f)=>d+f.width,0)+o*Math.max(0,l.length-1),h=Math.max(0,...l.map(d=>d.width)),u=e*1.2+o;return l.forEach((d,f)=>{r?(d.node.at(-c/2+a,0),a+=d.width+o):d.node.at(-h/2,(f-(l.length-1)/2)*u),i.add(d.node)}),i}var Ao=class extends N{leader;marker;body;titleNode=null;constructor(t,e,r={}){super();let o=r.size??15,s=r.color??"yellow",i=r.side??"right",a=r.distance??72,l=r.width??280,c=_i[i],h=t instanceof N?t.bounds():{x:t[0],y:t[1],width:0,height:0},u=t instanceof N?Bi(h,i,0):t,d=r.title?H(r.title,{size:o,weight:600,color:s}):null,f=H(e,{size:o*.94,color:r.bodyColor??"dim",maxWidth:l,leading:1.36}),p=d?o*1.42:0,m=Math.max(f.width,d?Qt(d):0),g=f.height,y=p+g,b=r.offset??0,w=i==="right"?u[0]+a:i==="left"?u[0]-a-m:u[0]-m/2+b,x=i==="bottom"?u[1]+a:i==="top"?u[1]-a-y:u[1]-y/2+b;if(r.plate){let M=o*.5;this.add(new N(Y(w-M,x-M,m+M*2,y+M*2,3)).fill("bg",.86))}d&&(this.titleNode=oe(d,w,x+o*.62),this.add(d)),f.moveTo([w+f.width/2,x+p+g/2]),this.body=f,this.add(f);let k=i==="right"?[w-8,x+y/2]:i==="left"?[w+m+8,x+y/2]:i==="bottom"?[w+m/2,x-8]:[w+m/2,x+y+8],v=c[0]!==0?[u[0]+c[0]*a*.45,k[1]]:[k[0],u[1]+c[1]*a*.45];this.leader=new N(et([u,v,k])).stroke(s,1.25),this.marker=xt(3,s).at(u),this.add(this.leader,this.marker)}enter(t={}){return{label:"callout.enter",duration:t.duration??.9,ease:t.ease,schedule:e=>{ct(this,e.t0,e.stage);let r=e.t1-e.t0;G(this.marker,"opacity",0,e.t0),this.marker.tween("opacity",1,e.t0,e.t0+r*.2,e.ease),G(this.leader,"trimTo",0,e.t0),this.leader.tween("trimTo",1,e.t0,e.t0+r*.55,e.ease);for(let o of this.children){if(o===this.marker||o===this.leader)continue;let s=o.get("opacity");G(o,"opacity",0,e.t0),o.tween("opacity",s,e.t0+r*.42,e.t1,e.ease)}}}}};function xp(n,t,e={}){return new Ao(n,t,e)}function fn(n){return Array.isArray(n)?[...n]:[n]}function Di(n){return fn(n).flatMap(t=>t.leaves().filter(e=>e.get("path")))}function Ip(n,t={}){let e=Di(n);return{label:"typewriter",duration:t.duration??Math.max(.5,e.length*.035),ease:t.ease??He,schedule(r){for(let a of fn(n))ct(a,r.t0,r.stage);let o=Di(n);if(o.length===0)return;let s=r.t1-r.t0,i=null;if(t.cursor){let l=o[0].bounds().height*1.35||24;i=new N(Y(0,-l/2,Math.max(3,l*.1),l)).fill(t.cursorColor??"ink"),r.stage.add(i)}o.forEach((a,l)=>{let c=r.t0+s*r.ease(l/o.length),h=a.get("opacity");if(G(a,"opacity",0,r.t0),G(a,"opacity",h,c),i){E.now=c;let u=a.bounds();G(i,"x",u.x+u.width+3,c),G(i,"y",u.y+u.height/2,c),E.now=r.t0}}),i&&G(i,"visible",!1,r.t1)}}}function Ep(n,t={}){return{label:"wipe",duration:t.duration??1.2,ease:t.ease??mt,schedule(e){let r=t.from??"left";for(let p of fn(n))ct(p,e.t0,e.stage);let o=fn(n).flatMap(p=>p.leaves()),s=p=>{let m=p.bounds(),g=m.x+m.width/2,y=m.y+m.height/2;return r==="left"?g:r==="right"?-g:r==="top"?y:-y},i=o.map(s),a=Math.min(...i),l=Math.max(...i),c=t.soft??.25,h=t.travel??0,u=e.t1-e.t0,d=r==="left"?-h:r==="right"?h:0,f=r==="top"?-h:r==="bottom"?h:0;o.forEach((p,m)=>{let g=l>a?(i[m]-a)/(l-a):0,y=e.t0+u*(1-c)*e.ease(g),b=y+u*c,w=p.get("opacity");if(G(p,"opacity",0,e.t0),p.tween("opacity",w,y,b,mt),h){let x=p.get("x"),k=p.get("y");G(p,"x",x+d,e.t0),G(p,"y",k+f,e.t0),p.tween("x",x,y,b,mt),p.tween("y",k,y,b,mt)}})}}}var pn=class extends N{value;constructor(t=0,e={}){super(),this.value=new yt(t);let r=e.digits??0,o=new Intl.NumberFormat("en-US",{minimumFractionDigits:r,maximumFractionDigits:r,useGrouping:e.grouped??!0}),s=Rt(()=>{let i=`${e.prefix??""}${o.format(this.value.value)}${e.suffix??""}`;return H(i,{size:e.size??48,color:e.color??"ink",font:e.font??"mono",weight:e.weight??400})});this.add(s)}};function Tp(n=0,t={}){return new pn(n,t)}function Rp(n,t,e={}){let r=n instanceof pn?n.value:n;return{label:"countUp",duration:e.duration??1.2,ease:e.ease,schedule(o){n instanceof pn&&ct(n,o.t0,o.stage),Mt(r,t,o.t0,o.t1,o.ease)}}}function Fp(n,t,e={}){return{label:"spin",duration:e.duration??2,ease:e.ease??He,schedule(r){ct(n,r.t0,r.stage),E.now=r.t0,n.pivotAt(e.about??n.center);let o=n.get("rotation"),s=r.t1-r.t0;n.tween("rotation",o+t*s,r.t0,r.t1,r.ease)}}}function zp(n,t,e={}){return{label:"swap",duration:e.duration??.9,ease:e.ease,schedule(r){ct(n,r.t0,r.stage),ct(t,r.t0,r.stage),E.now=r.t0;let o=n.center,s=t.center,i=e.lift??Math.max(60,Math.hypot(s[0]-o[0],s[1]-o[1])*.3),a=(l,c,h,u)=>{let d=l.parent?Xt(l.parent.worldMatrix()):[1,0,0,1,0,0],f=l.get("x"),p=l.get("y"),[m,g]=tt(d,c[0],c[1]),[y,b]=tt(d,h[0],h[1]),w=f+y-m,x=p+b-g;l.track("x").add({t0:r.t0,t1:r.t1,ease:r.ease,to:w,at:k=>f+(w-f)*k}),l.track("y").add({t0:r.t0,t1:r.t1,ease:r.ease,to:x,at:k=>p+(x-p)*k-u*i*4*k*(1-k)})};a(n,o,s,1),a(t,s,o,-1)}}}function $p(n,t={}){let e=new N([]),r=fn(n);return{mark:e,label:"highlightSweep",duration:t.duration??.7,ease:t.ease,schedule(o){let s=1/0,i=1/0,a=-1/0,l=-1/0;for(let v of r){let M=v.bounds();s=Math.min(s,M.x),i=Math.min(i,M.y),a=Math.max(a,M.x+M.width),l=Math.max(l,M.y+M.height)}let c=t.pad??6,h=s-c,u=i-c,d=a-s+c*2,f=l-i+c*2,p=t.radius??3,m=t.color??"yellow";e.base.fill=q(m),e.base.fillOpacity=t.opacity??.26;let g=o.stage.root;g.add(e);let b=r[0];for(;b.parent&&b.parent!==g;)b=b.parent;let w=g.children.indexOf(b);g.children.splice(g.children.indexOf(e),1),g.children.splice(w>=0?w:g.children.length,0,e);let x=t.from==="right",k=v=>{let M=Math.max(.01,d*v);return Y(x?h+d-M:h,u,M,f,p)};e.track("path").step(o.t0,k(0)),e.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:k(1),at:k})}}}function Gi(n){return n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&#(\d+);/g,(t,e)=>String.fromCodePoint(Number(e))).replace(/&#x([\da-fA-F]+);/g,(t,e)=>String.fromCodePoint(parseInt(e,16))).replace(/&amp;/g,"&")}function xc(n){let t={name:"#root",attrs:{},children:[],text:""},e=[t],r=/<!--[\s\S]*?-->|<!\[CDATA\[([\s\S]*?)\]\]>|<\?[\s\S]*?\?>|<!DOCTYPE[^>]*>|<\/([\w:.-]+)\s*>|<([\w:.-]+)((?:\s+[\w:.-]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>|([^<]+)/g;for(let o=r.exec(n);o;o=r.exec(n)){let s=e[e.length-1],[,i,a,l,c,h,u]=o;if(i!==void 0)s.text+=i;else if(a)e.length>1&&e.pop();else if(l){let d={name:l.replace(/^.*:/,""),attrs:{},children:[],text:""};for(let f of(c??"").matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))d.attrs[f[1]]=Gi(f[2]??f[3]??"");s.children.push(d),h||e.push(d)}else u&&(s.text+=Gi(u))}return t}function kc(n){if(!n)return Dt;let t=Dt;for(let e of n.matchAll(/(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/g)){let r=e[2].trim().split(/[\s,]+/).filter(Boolean).map(Number),o=e[1];if(o==="matrix"&&r.length===6)t=it(t,r);else if(o==="translate")t=it(t,[1,0,0,1,r[0]??0,r[1]??0]);else if(o==="scale")t=it(t,[r[0]??1,0,0,r[1]??r[0]??1,0,0]);else if(o==="rotate"){let s=(r[0]??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),l=r[1]??0,c=r[2]??0;t=it(t,[1,0,0,1,l,c]),t=it(t,[i,a,-a,i,0,0]),t=it(t,[1,0,0,1,-l,-c])}else o==="skewX"?t=it(t,[1,0,Math.tan((r[0]??0)*Math.PI/180),1,0,0]):o==="skewY"&&(t=it(t,[1,Math.tan((r[0]??0)*Math.PI/180),0,1,0,0]))}return t}var vc=new Set(["defs","clipPath","mask","pattern","filter","symbol","marker","linearGradient","radialGradient","title","desc","metadata","style","script"]),Qn=class extends N{byId=new Map;pictureWidth=0;pictureHeight=0;find(t){let e=this.byId.get(t);if(!e)throw new Error(`The SVG has no element with id ${JSON.stringify(t)}.`);return e}};function Mc(n){let t=new Map,e=r=>{if(r.name==="style")for(let o of r.text.matchAll(/([^{}]+)\{([^{}]*)\}/g)){let s=No(o[2]);for(let i of o[1].split(",")){let a=i.trim();t.set(a,{...t.get(a),...s})}}r.children.forEach(e)};return e(n),t}function No(n){let t={};if(!n)return t;for(let e of n.split(";")){let r=e.indexOf(":");r>0&&(t[e.slice(0,r).trim()]=e.slice(r+1).trim())}return t}function Jn(n){if(!n||n==="none"||n==="transparent")return null;try{return qt(n)}catch{return null}}function Ac(n){let t=n.map(s=>{let i=wt([s]);return{ring:s,b:i,area:i.width*i.height,owner:-1}}),e=t.map((s,i)=>i).sort((s,i)=>t[i].area-t[s].area);for(let s=0;s<e.length;s++){let i=t[e[s]];for(let a=s-1;a>=0;a--){let l=t[e[a]];if(l.owner!==-1)continue;if(i.b.x>=l.b.x-.01&&i.b.y>=l.b.y-.01&&i.b.x+i.b.width<=l.b.x+l.b.width+.01&&i.b.y+i.b.height<=l.b.y+l.b.height+.01){i.owner=e[a];break}}}let r=[],o=new Map;return t.forEach((s,i)=>{if(s.owner!==-1)return;let a={x:s.b.x,rings:[s.ring]};o.set(i,a),r.push(a)}),t.forEach(s=>{s.owner!==-1&&o.get(s.owner)?.rings.push(s.ring)}),r.sort((s,i)=>s.x-i.x).map(s=>s.rings)}function Nc(n,t={}){let r=xc(n).children.find(S=>S.name==="svg");if(!r)throw new Error("fromSvg needs markup with an <svg> element.");let o=Mc(r),s=new Map,i=S=>{S.attrs.id&&s.set(S.attrs.id,S),S.children.forEach(i)};i(r);let a=(r.attrs.viewBox??"").trim().split(/[\s,]+/).map(Number),l=parseFloat(r.attrs.width??""),c=parseFloat(r.attrs.height??""),h=a.length===4&&a[2]?a[2]:l||300,u=a.length===4&&a[3]?a[3]:c||150,d=a.length===4?a[0]:0,f=a.length===4?a[1]:0,p=Number.isFinite(l)&&l>0?l:h,m=Number.isFinite(c)&&c>0?c:u,g=1;if(t.width!==void 0||t.height!==void 0){let S=t.width!==void 0?t.width/h:1/0,V=t.height!==void 0?t.height/u:1/0;g=Math.min(S,V)}else g=Math.min(p/h,m/u);let y=t.center??!0,b=y?-(d+h/2)*g:-d*g,w=y?-(f+u/2)*g:-f*g,x=[g,0,0,g,b,w],k=new Qn;k.pictureWidth=h*g,k.pictureHeight=u*g;let v=t.splitGlyphs??!0,M=t.background??!1,A=!0,C=(S,V,R)=>{let T=s.get(S);if(!T)return null;if(T.name==="pattern"){let z=T.children.find(W=>W.name==="linearGradient");if(z)return P(z,V,R,!0);let U=T.children.find(W=>W.attrs.fill?.startsWith("url(#"))?.attrs.fill?.match(/url\(#([^)]+)\)/)?.[1];return U?C(U,V,R):null}if(T.name==="linearGradient")return P(T,V,R,T.attrs.gradientUnits!=="userSpaceOnUse");if(T.name==="radialGradient"){let z=O(T);return z.length?z[z.length-1][1]:null}return null},O=S=>{let V=S.attrs.href??S.attrs["xlink:href"];return(S.children.some(T=>T.name==="stop")||!V?S:s.get(V.replace(/^#/,""))??S).children.filter(T=>T.name==="stop").map(T=>{let z=No(T.attrs.style),I=T.attrs.offset??"0",U=I.endsWith("%")?parseFloat(I)/100:parseFloat(I),W=Jn(z["stop-color"]??T.attrs["stop-color"]??"#000000")??[0,0,0,1],X=parseFloat(z["stop-opacity"]??T.attrs["stop-opacity"]??"1");return[U,[W[0],W[1],W[2],W[3]*X]]})},P=(S,V,R,T)=>{let z=O(S);if(z.length===0)return null;let I=(j,ut)=>j===void 0?ut:j.endsWith("%")?parseFloat(j)/100:parseFloat(j),U=I(S.attrs.x1,0),W=I(S.attrs.y1,0),X=I(S.attrs.x2,1),st=I(S.attrs.y2,0),J,ft;if(T){let j=wt(R)??{x:0,y:0,width:1,height:1};J=[j.x+U*j.width,j.y+W*j.height],ft=[j.x+X*j.width,j.y+st*j.height]}else J=tt(V,U,W),ft=tt(V,X,st);return{type:"linear",from:J,to:ft,stops:z}},L=S=>{let V=S.attrs,R=(T,z=0)=>{let I=parseFloat(V[T]??"");return Number.isFinite(I)?I:z};switch(S.name){case"path":return V.d?St(V.d):null;case"rect":{let T=R("width"),z=R("height");return T<=0||z<=0?null:Y(R("x"),R("y"),T,z,R("rx",R("ry")))}case"circle":return R("r")>0?$t(R("cx"),R("cy"),R("r"),R("r"),0,Math.PI*2):null;case"ellipse":return R("rx")>0&&R("ry")>0?$t(R("cx"),R("cy"),R("rx"),R("ry"),0,Math.PI*2):null;case"line":return et([[R("x1"),R("y1")],[R("x2"),R("y2")]]);case"polyline":case"polygon":{let T=(V.points??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),z=[];for(let I=0;I+1<T.length;I+=2)z.push([T[I],T[I+1]]);return z.length>=2?et(z,S.name==="polygon"):null}default:return null}},F=(S,V)=>{let R=S.attrs,T=(R.class??"").split(/\s+/).filter(Boolean),z={...o.get(S.name)};for(let Q of T)Object.assign(z,o.get(`.${Q}`));R.id&&Object.assign(z,o.get(`#${R.id}`));let I=Q=>No(R.style)[Q]??R[Q]??z[Q],U={...V},W=I("color");W&&(U.color=W);let X=I("fill");X&&(U.fill=X==="currentColor"?U.color:X);let st=I("stroke");st&&(U.stroke=st==="currentColor"?U.color:st);let J=I("stroke-width");J!==void 0&&(U.strokeWidth=parseFloat(J)||0);let ft=I("fill-opacity");ft!==void 0&&(U.fillOpacity=parseFloat(ft));let j=I("stroke-opacity");j!==void 0&&(U.strokeOpacity=parseFloat(j));let ut=I("stroke-linecap");(ut==="round"||ut==="butt"||ut==="square")&&(U.cap=ut);let bt=I("stroke-linejoin");(bt==="round"||bt==="miter"||bt==="bevel")&&(U.join=bt);let ot=I("stroke-dasharray");ot!==void 0&&(U.dash=ot==="none"?null:ot.trim().split(/[\s,]+/).map(Number));let pt=I("stroke-dashoffset");pt!==void 0&&(U.dashOffset=parseFloat(pt)||0);let At=I("font-size");At!==void 0&&(U.fontSize=parseFloat(At)||U.fontSize);let Nt=I("text-anchor");return Nt&&(U.anchor=Nt),{style:U,opacity:parseFloat(I("opacity")??"1")}},_=(S,V,R,T)=>{let z=at(S,V),I=ee(V),U=ot=>ot?.match(/^url\(#([^)]+)\)/)?.[1],W=U(T.fill),X=U(T.stroke),st=W?C(W,V,z):Jn(T.fill),J=X?C(X,V,z):Jn(T.stroke),ft=st&&T.fillOpacity>0&&!(Array.isArray(st)&&st[3]===0),j=J&&T.strokeOpacity>0&&T.strokeWidth>0&&!(Array.isArray(J)&&J[3]===0);if(!ft&&!j)return[];let ut=R.attrs["clip-path"]?.5:1;return(v&&ft&&!j&&z.length>1?Ac(z):[z]).map(ot=>{let pt=wt(ot)??{x:0,y:0,width:0,height:0},At=pt.x+pt.width/2,Nt=pt.y+pt.height/2,Q=new N(at(ot,[1,0,0,1,-At,-Nt])).at(At,Nt);return ft&&(Q.base.fill=Wi(st,-At,-Nt),Q.base.fillOpacity=T.fillOpacity),j&&(Q.base.stroke=Wi(J,-At,-Nt),Q.base.strokeWidth=T.strokeWidth*I*ut,Q.base.strokeOpacity=T.strokeOpacity,Q.base.cap=T.cap,Q.base.join=T.join,T.dash&&(Q.base.dash=T.dash.map(ge=>ge*I)),Q.base.dashOffset=T.dashOffset*I),Q.base.trimEach=!0,Q})},B=(S,V,R,T)=>{if(vc.has(S.name)||S.attrs.filter)return;let{style:z,opacity:I}=F(S,R),U=it(T,kc(S.attrs.transform)),W=j=>{S.attrs.id&&k.byId.set(S.attrs.id,j)};if(S.name==="g"||S.name==="svg"||S.name==="a"){let j=new N;I<1&&(j.base.opacity=I),W(j),V.add(j);for(let ut of S.children)B(ut,j,z,U);return}if(S.name==="use"){let j=(S.attrs.href??S.attrs["xlink:href"]??"").replace(/^#/,""),ut=s.get(j);if(!ut)return;let bt=it(U,[1,0,0,1,parseFloat(S.attrs.x??"0")||0,parseFloat(S.attrs.y??"0")||0]),ot=new N;if(I<1&&(ot.base.opacity=I),V.add(ot),ut.name==="symbol")for(let pt of ut.children)B(pt,ot,z,bt);else B(ut,ot,z,bt);return}if(S.name==="image"){let j=S.attrs.href??S.attrs["xlink:href"];if(!j)return;let ut=parseFloat(S.attrs.width??"0"),bt=parseFloat(S.attrs.height??"0"),[ot,pt]=tt(U,parseFloat(S.attrs.x??"0")||0,parseFloat(S.attrs.y??"0")||0),At=ee(U),Nt={src:j,width:ut,height:bt},Q=new N().at(ot,pt);Q.base.image=Nt,Q.base.sx=At,Q.base.sy=At,I<1&&(Q.base.opacity=I),W(Q),V.add(Q);return}if(S.name==="text"){let j=(S.text+S.children.map(Q=>Q.text).join("")).trim();if(!j)return;let ut=Jn(z.fill)??[0,0,0,1],bt=z.fontSize*ee(U),ot=H(j,{size:bt,color:ut}),[pt,At]=tt(U,parseFloat(S.attrs.x??"0")||0,parseFloat(S.attrs.y??"0")||0),Nt=ot.get("px");ot.at(z.anchor==="middle"?pt:z.anchor==="end"?pt-Nt:pt+Nt,At-bt*.34),I<1&&(ot.base.opacity=I),W(ot),V.add(ot);return}let X=L(S);if(!X||X.length===0)return;let st=A&&S.name==="rect"&&!M&&parseFloat(S.attrs.width??"0")>=h-.5&&parseFloat(S.attrs.height??"0")>=u-.5;if(A=!1,st)return;let J=_(X,U,S,z);if(J.length===0)return;if(J.length===1){I<1&&(J[0].base.opacity=I),W(J[0]),V.add(J[0]);return}let ft=new N;I<1&&(ft.base.opacity=I),ft.add(...J),W(ft),V.add(ft)},D={fill:"#000000",stroke:null,strokeWidth:1,fillOpacity:1,strokeOpacity:1,cap:"butt",join:"miter",dash:null,dashOffset:0,color:"#000000",fontSize:16,anchor:"start"},{style:K}=F(r,D);for(let S of r.children)B(S,k,K,x);return k}function Wi(n,t,e){if(Array.isArray(n))return n;let r=n;return r.type==="linear"?{...r,from:[r.from[0]+t,r.from[1]+e],to:[r.to[0]+t,r.to[1]+e]}:r.type==="radial"?{...r,center:[r.center[0]+t,r.center[1]+e]}:r}var ji=n=>n.toLowerCase().replace(/[^a-z0-9.]+/g," ").split(" ").map(t=>t.replace(/^\.+|\.+$/g,"")).filter(Boolean);function Hi(n,t=74){let e=[];for(let r of n.match(/[^.?!]+(?:[.?!]+(?=\s|$)|\.\d[^.?!]*[.?!]?|$)/g)??[]){let o="";for(let s of r.split(/\s+/).filter(Boolean))o&&o.length+s.length+1>t?(e.push(o),o=s):o=o?`${o} ${s}`:s;o&&e.push(o)}return e}var tr=class{constructor(t,e,r,o,s){this.stage=t;this.id=e;this.start=r;this.end=o;this.beats=s}stage;id;start;end;beats;cue(t,e){let r=ji(t);if(r.length===0)throw new Error(`narration: scene "${this.id}": a cue needs at least one word`);if(e!==void 0&&!this.beats[e])throw new Error(`narration: scene "${this.id}" has no beat ${e}`);let o=e===void 0?this.beats:[this.beats[e]];for(let i of o){let a=i.words.flatMap(l=>ji(l.text).map(c=>({token:c,start:l.start,end:l.end})));for(let l=0;l+r.length<=a.length;l++)if(r.every((c,h)=>a[l+h].token===c))return{start:i.start+a[l].start,end:i.start+a[l+r.length-1].end}}let s=e===void 0?"":` in beat ${e}`;throw new Error(`narration: scene "${this.id}": the voice never says "${t}"${s}`)}on(t,e,r=0,o){return this.stage.at(Math.max(0,this.cue(t,o).start+r),e),this}after(t,e,r=0,o){return this.stage.at(Math.max(0,this.cue(t,o).end+r),e),this}onBeat(t,e,r=0){let o=this.beats[t];if(!o)throw new Error(`narration: scene "${this.id}" has no beat ${t}`);return this.stage.at(Math.max(0,o.start+r),e),this}at(t,e){return this.stage.at(Math.max(0,this.start+t),e),this}clear(t,e=.24,r=.26){return this.stage.at(this.end-e,()=>this.stage.play(...t.map(o=>hs(o,0,{duration:r})))),this}},er=class{scenes;duration;lead;gap;constructor(t,e,r={}){if(this.lead=r.lead??e.lead??.6,this.gap=r.gap??e.gap??.4,!(this.lead>=0)||!(this.gap>=0))throw new Error("narration: lead and gap must be zero or more seconds");let o=new Set,s=[],i=this.lead,a=i;for(let l of e.scenes){if(o.has(l.id))throw new Error(`narration: two scenes are named "${l.id}"`);o.add(l.id);let c=i,h=[];for(let u of l.beats){if(!(u.duration>0))throw new Error(`narration: scene "${l.id}" has a beat without a measured duration: "${u.say}"`);let d=u.hold??0;h.push({start:i,end:i+u.duration,until:i+u.duration+d,text:u.say,words:u.words??[]}),i+=u.duration+d}if(s.push(new tr(t,l.id,c,i,h)),r.chapters!==!1&&l.title&&t.chapters.push({title:l.title,time:s.length===1?0:c}),r.captions!==!1)for(let u of h){let d=Hi(u.text,r.captionLength),f=d.reduce((m,g)=>m+g.length,0),p=u.start;for(let m of d){let g=p+(u.end-u.start)*m.length/f;t.captions.push({t0:p,t1:g,text:m}),p=g}}a=i,i+=this.gap}this.scenes=s,this.duration=a,t.at(a,()=>{})}scene(t){let e=this.scenes.find(r=>r.id===t);if(!e)throw new Error(`narration: no scene "${t}". The scenes are: ${this.scenes.map(r=>r.id).join(", ")}`);return e}placements(){return this.scenes.flatMap(t=>t.beats.map((e,r)=>({scene:t.id,beat:r,start:e.start,end:e.end})))}};function Cc(n,t,e={}){return new er(n,t,e)}var pe=n=>typeof n=="function"?n():n,Ki=n=>{let t=Math.hypot(n[0],n[1],n[2])||1;return[n[0]/t,n[1]/t,n[2]/t]},Co=class{ops=[];depths=[];rx=0;ry=0;ux=0;uy=0;uz=0;dx=0;dy=0;dz=0;fx=0;fy=0;fz=0;distance=12;unit=100;perspective=!0;matrix=[1,0,0,1,0,0];alpha=1;scale=1;light=[0,0,1];half=[0,0,1];ambient=.4;shine=.2;fog=0;fogColor=[0,0,0,1];depthRange=1;brightness=1;px=0;py=0;pz=0;ps=1;project(t,e,r){let o=t-this.fx,s=e-this.fy,i=r-this.fz,a=o*this.rx+s*this.ry,l=o*this.ux+s*this.uy+i*this.uz,c=o*this.dx+s*this.dy+i*this.dz,h=1;if(this.perspective){let p=this.distance-c;if(p<=.05)return!1;h=this.distance/p}let u=a*this.unit*h,d=-l*this.unit*h,f=this.matrix;return this.px=f[0]*u+f[2]*d+f[4],this.py=f[1]*u+f[3]*d+f[5],this.pz=c,this.ps=h,!0}screen(t,e,r){let o=t-this.fx,s=e-this.fy,i=r-this.fz,a=o*this.rx+s*this.ry,l=o*this.ux+s*this.uy+i*this.uz,c=o*this.dx+s*this.dy+i*this.dz,h=1;if(this.perspective){let u=this.distance-c;if(u<=.05)return null;h=this.distance/u}return[a*this.unit*h,-l*this.unit*h]}fogged(t,e,r,o){if(this.fog<=0)return[t,e,r,1];let s=Math.max(0,Math.min(1,-o/this.depthRange*this.fog));return[t+(this.fogColor[0]-t)*s,e+(this.fogColor[1]-e)*s,r+(this.fogColor[2]-r)*s,1]}push(t,e){this.ops.push(t),this.depths.push(e)}};function $e(n,t,e,r,o=0,s="round"){return{kind:"path",path:n,strokePath:n,fill:null,fillAlpha:0,stroke:t,strokeAlpha:e,strokeWidth:r,cap:s,join:"round",dash:null,dashOffset:0,glow:o,glowColor:null,blend:"normal"}}function Le(n,t,e,r,o,s){return{kind:"path",path:n,strokePath:n,fill:t,fillAlpha:e,stroke:r,strokeAlpha:o,strokeWidth:s,cap:"round",join:"round",dash:null,dashOffset:0,glow:0,glowColor:null,blend:"normal"}}function nr(n,t,e,r){let o=e-n,s=r-t,i=new Float64Array(8);return i[0]=n,i[1]=t,i[2]=n+o/3,i[3]=t+s/3,i[4]=n+o*2/3,i[5]=t+s*2/3,i[6]=e,i[7]=r,{p:i,closed:!1,straight:!0}}function Fo(n){let t=n.length/2,e=new Float64Array(2+t*6);e[0]=n[0],e[1]=n[1];let r=2;for(let o=0;o<t;o++){let s=n[o*2],i=n[o*2+1],a=n[(o+1)%t*2],l=n[(o+1)%t*2+1];e[r++]=s+(a-s)/3,e[r++]=i+(l-i)/3,e[r++]=s+(a-s)*2/3,e[r++]=i+(l-i)*2/3,e[r++]=a,e[r++]=l}return{p:e,closed:!0,straight:!0}}var Oc=.5522847498307936;function Xi(n,t,e){let r=e*Oc;return{closed:!0,p:Float64Array.of(n+e,t,n+e,t+r,n+r,t+e,n,t+e,n-r,t+e,n-e,t+r,n-e,t,n-e,t-r,n-r,t-e,n,t-e,n+r,t-e,n+e,t-r,n+e,t)}}var Bt=class extends N{constructor(){super([])}labelsNow(t){return[]}objectAlpha(t){return t.alpha*this.get("opacity")}},Oo=class extends N{phi;theta;distance;unit;focusX;focusY;focusZ;orthographic;settings;spins=[];openSpin=null;constructor(t={}){super(),this.settings=t,this.phi=new yt(t.phi??1.15),this.theta=new yt(t.theta??-1),this.distance=new yt(t.distance??14),this.unit=new yt(t.unit??120),this.focusX=new yt(t.focus?.[0]??0),this.focusY=new yt(t.focus?.[1]??0),this.focusZ=new yt(t.focus?.[2]??0),this.orthographic=t.perspective===!1,this.rawOps=(e,r,o)=>this.render(e,r,o),this.draw=e=>{let r=this.view(this.worldless,1,e);return this.children.flatMap(o=>o instanceof Bt&&o.get("visible")?o.labelsNow(r):[])}}worldless=[1,0,0,1,0,0];view(t,e,r){let o=new Co,s=this.phi.value,i=this.theta.value;for(let f of this.spins)r>f.from&&(i+=(Math.min(r,f.to)-f.from)*f.rate);let a=Math.sin(s),l=Math.cos(s),c=Math.sin(i),h=Math.cos(i);o.rx=-c,o.ry=h,o.ux=-l*h,o.uy=-l*c,o.uz=a,o.dx=a*h,o.dy=a*c,o.dz=l,o.fx=this.focusX.value,o.fy=this.focusY.value,o.fz=this.focusZ.value,o.distance=this.distance.value,o.unit=this.unit.value,o.perspective=!this.orthographic,o.matrix=t,o.alpha=e,o.scale=Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]));let u=Ki(this.settings.light??[-.45,-.55,.85]);o.light=u,o.half=Ki([u[0]+o.dx,u[1]+o.dy,u[2]+o.dz]),o.ambient=this.settings.ambient??.26,o.shine=this.settings.shine??.2,o.fog=this.settings.fog??.6;let d=qt("bg");return o.fogColor=this.settings.fogColor?Ut(this.settings.fogColor):d,o.depthRange=Math.max(3,o.distance*.5),o.brightness=this.settings.brightness??(d[0]+d[1]+d[2]<200?.8:1),o}render(t,e,r){let o=E.now,s=this.view(t,e,o);for(let c of this.children)c instanceof Bt&&c.get("visible")&&c.emit(s,o);let i=s.ops.length,a=new Uint32Array(i);for(let c=0;c<i;c++)a[c]=c;let l=s.depths;a.sort((c,h)=>l[c]-l[h]);for(let c=0;c<i;c++)r.push(s.ops[a[c]])}orbit(t,e={}){return{label:"camera3d",duration:e.duration??2,ease:e.ease,schedule:r=>{t.phi!==void 0&&Mt(this.phi,t.phi,r.t0,r.t1,r.ease),t.theta!==void 0&&Mt(this.theta,t.theta,r.t0,r.t1,r.ease),t.distance!==void 0&&Mt(this.distance,t.distance,r.t0,r.t1,r.ease),t.unit!==void 0&&Mt(this.unit,t.unit,r.t0,r.t1,r.ease),t.focus&&(Mt(this.focusX,t.focus[0],r.t0,r.t1,r.ease),Mt(this.focusY,t.focus[1],r.t0,r.t1,r.ease),Mt(this.focusZ,t.focus[2],r.t0,r.t1,r.ease))}}}spin(t=.12){return this.stopSpin(),this.openSpin={from:E.now,to:1/0,rate:t},this.spins.push(this.openSpin),this}stopSpin(){return this.openSpin&&(this.openSpin.to=E.now),this.openSpin=null,this}stagePoint(t){let e=this.view(this.worldMatrix(),1,E.now);return e.project(t[0],t[1],t[2])?[e.px,e.py]:[0,0]}};function Jp(n={}){return new Oo(n)}var mn=class extends Bt{constructor(e,r,o,s={}){super();this.fn=e;this.uRange=r;this.vRange=o;this.options=s;let i=s.resolution??40;this.nu=typeof i=="number"?i:i[0],this.nv=typeof i=="number"?i:i[1];let a=(this.nu+1)*(this.nv+1);if(this.positions=new Float64Array(a*3),this.normals=new Float64Array(this.nu*this.nv*3),this.vertexNormals=new Float64Array(a*3),this.shadingNormals=new Float64Array(this.nu*this.nv*3),this.faceColors=new Float32Array(this.nu*this.nv*3),this.screenX=new Float64Array(a),this.screenY=new Float64Array(a),this.screenZ=new Float64Array(a),this.valid=new Uint8Array(a),this.meshColor=s.mesh?Ut(s.mesh):null,s.colors){let l=s.colors.map(c=>Ut(c));this.ramp=l.map((c,h)=>[l.length===1?0:h/(l.length-1),c])}s.checker&&(this.checkerColors=[Ut(s.checker[0]),Ut(s.checker[1])]),(s.color||!s.colors&&!s.checker&&!s.colorAt)&&(this.base.fill=q(s.color??"blue"))}fn;uRange;vRange;options;nu;nv;positions;normals;vertexNormals;shadingNormals;faceColors;computedFor=-1/0;screenX;screenY;screenZ;valid;meshColor;ramp=null;checkerColors=null;compute(e){let{nu:r,nv:o,positions:s,normals:i,faceColors:a,fn:l,uRange:c,vRange:h,options:u}=this,d=0,f=1/0,p=-1/0;for(let b=0;b<=r;b++){let w=c[0]+(c[1]-c[0])*b/r;for(let x=0;x<=o;x++){let k=h[0]+(h[1]-h[0])*x/o,v=l(w,k,e);s[d++]=v[0],s[d++]=v[1],s[d++]=v[2],v[2]<f&&(f=v[2]),v[2]>p&&(p=v[2])}}let m=o+1,g=this.vertexNormals;g.fill(0);for(let b=0;b<r;b++)for(let w=0;w<o;w++){let x=(b*m+w)*3,k=((b+1)*m+w)*3,v=((b+1)*m+w+1)*3,M=(b*m+w+1)*3,A=s[v]-s[x],C=s[v+1]-s[x+1],O=s[v+2]-s[x+2],P=s[M]-s[k],L=s[M+1]-s[k+1],F=s[M+2]-s[k+2],_=C*F-O*L,B=O*P-A*F,D=A*L-C*P,K=Math.hypot(_,B,D)||1;if(_/=K,B/=K,D/=K,u.outwardFrom){let[V,R,T]=u.outwardFrom,z=(s[x]+s[v])/2-V,I=(s[x+1]+s[v+1])/2-R,U=(s[x+2]+s[v+2])/2-T;_*z+B*I+D*U<0&&(_=-_,B=-B,D=-D)}let S=(b*o+w)*3;i[S]=_,i[S+1]=B,i[S+2]=D;for(let V of[x/3,k/3,v/3,M/3])g[V*3]+=_,g[V*3+1]+=B,g[V*3+2]+=D;if(this.ramp||this.checkerColors||u.colorAt){let V;if(u.colorAt){let R=(s[x]+s[v])/2,T=(s[x+1]+s[v+1])/2,z=(s[x+2]+s[v+2])/2;V=u.colorAt(R,T,z,(b+.5)/r,(w+.5)/o)}else if(this.checkerColors)V=this.checkerColors[(b+w)%2];else{let R=(s[x+2]+s[v+2]+s[k+2]+s[M+2])/4;V=ht(this.ramp,p>f?(R-f)/(p-f):0)}a[S]=V[0],a[S+1]=V[1],a[S+2]=V[2]}}let y=this.shadingNormals;for(let b=0;b<r;b++)for(let w=0;w<o;w++){let x=(b*m+w)*3,k=((b+1)*m+w)*3,v=((b+1)*m+w+1)*3,M=(b*m+w+1)*3,A=0,C=0,O=0;for(let F of[x,k,v,M])A+=g[F],C+=g[F+1],O+=g[F+2];let P=Math.hypot(A,C,O)||1,L=(b*o+w)*3;y[L]=A/P,y[L+1]=C/P,y[L+2]=O/P}}emit(e,r){let{options:o,nu:s,nv:i,normals:a,shadingNormals:l,faceColors:c,screenX:h,screenY:u,screenZ:d,valid:f}=this,p=this.objectAlpha(e)*(o.opacity??1)*this.get("fillOpacity");if(p<=.002)return;(o.animate?this.computedFor!==r:this.computedFor===-1/0)&&(this.compute(o.animate?r:0),this.computedFor=r);let m=this.positions,g=i+1,y=(s+1)*(i+1);for(let R=0;R<y;R++){let T=R*3;e.project(m[T],m[T+1],m[T+2])?(h[R]=e.px,u[R]=e.py,d[R]=e.pz,f[R]=1):f[R]=0}let b=this.ramp||this.checkerColors||o.colorAt?null:me(this.get("fill")),w=o.shaded??!0,x=p>=.995,k=this.get("trimTo"),v=Math.ceil(k*s),{light:M,half:A,ambient:C,shine:O,brightness:P,dx:L,dy:F,dz:_}=e,B=o.cull??!1,D=this.meshColor,K=(o.meshOpacity??.35)*p,S=(o.meshWidth??1)*e.scale,V=.55*e.scale;for(let R=0;R<v;R++)for(let T=0;T<i;T++){let z=R*g+T,I=(R+1)*g+T,U=(R+1)*g+T+1,W=R*g+T+1;if(!f[z]||!f[I]||!f[U]||!f[W])continue;let X=(R*i+T)*3,st=a[X]*L+a[X+1]*F+a[X+2]*_;if(st<0&&B)continue;let J=st<0?-1:1,ft=l[X]*J,j=l[X+1]*J,ut=l[X+2]*J,bt,ot,pt;if(b?(bt=b[0],ot=b[1],pt=b[2]):(bt=c[X],ot=c[X+1],pt=c[X+2]),w){let se=.5+.5*(ft*M[0]+j*M[1]+ut*M[2]),te=(C+(1-C)*se*se)*P,ie=O>0?O*Math.pow(Math.max(0,ft*A[0]+j*A[1]+ut*A[2]),42)*255:0;bt=Math.min(255,bt*te+ie),ot=Math.min(255,ot*te+ie),pt=Math.min(255,pt*te+ie)}let At=(d[z]+d[I]+d[U]+d[W])/4,Nt=e.fogged(bt,ot,pt,At),Q=h[z],ge=u[z],Ue=h[I],_e=u[I],Be=h[U],De=u[U],Ge=h[W],We=u[W];if(x&&!D){let se=(Q+Ue+Be+Ge)/4,te=(ge+_e+De+We)/4,ie=(Qi,ta)=>V/(Math.hypot(Qi-se,ta-te)||1),Lo=ie(Q,ge),Vo=ie(Ue,_e),Uo=ie(Be,De),_o=ie(Ge,We);Q+=(Q-se)*Lo,ge+=(ge-te)*Lo,Ue+=(Ue-se)*Vo,_e+=(_e-te)*Vo,Be+=(Be-se)*Uo,De+=(De-te)*Uo,Ge+=(Ge-se)*_o,We+=(We-te)*_o}let $o=Fo([Q,ge,Ue,_e,Be,De,Ge,We]);e.push(D?Le([$o],Nt,p,D,K,S):Le([$o],Nt,p,null,0,0),At)}}};function me(n){return n?Array.isArray(n)?n:Ut(n):[90,180,240,1]}function Qp(n,t,e,r={}){return new mn(n,t,e,r)}function tm(n,t={}){let e=t.x??[-4,4],r=t.y??[-4,4];return new mn((o,s,i)=>[o,s,n(o,s,i)],e,r,{colors:t.color||t.checker||t.colorAt?void 0:["blue","teal","yellow"],...t})}function em(n=1,t={}){let[e,r,o]=t.center??[0,0,0];return new mn((s,i)=>[e+n*Math.sin(i)*Math.cos(s),r+n*Math.sin(i)*Math.sin(s),o+n*Math.cos(i)],[0,Math.PI*2],[0,Math.PI],{cull:!0,resolution:[64,40],outwardFrom:[e,r,o],...t})}var Ve=1e6,So=class extends Bt{constructor(e,r,o,s={}){super();this.style=s;let i=s.samples??240;this.points=new Float64Array((i+1)*3);for(let a=0;a<=i;a++){let[l,c,h]=e(r+(o-r)*a/i);this.points[a*3]=l,this.points[a*3+1]=c,this.points[a*3+2]=h}if(this.base.stroke=q(s.color??"yellow"),this.base.strokeWidth=s.width??3,s.colors){let a=s.colors.map(l=>Ut(l));this.stops=a.map((l,c)=>[a.length===1?0:c/(a.length-1),l])}else this.stops=null}style;points;stops;emit(e){let r=this.objectAlpha(e)*(this.style.opacity??1)*this.get("strokeOpacity");if(r<=.002)return;let o=this.get("trimTo"),s=this.points.length/3-1,i=Math.floor(o*s);if(i<1)return;let a=Math.max(2,Math.ceil(s/72)),l=this.get("stroke")??q("yellow"),c=this.get("strokeWidth")*e.scale,h=this.style.onTop?Ve:this.style.bias??.12,u=(this.style.glow??0)*e.scale;for(let d=0;d<i;d+=a){let f=Math.min(i,d+a),p=[],m=0,g=0,y=0;for(let x=d;x<=f;x++)e.project(this.points[x*3],this.points[x*3+1],this.points[x*3+2])&&(p.push([e.px,e.py]),m+=e.pz,g+=e.ps,y++);if(y<2)continue;m/=y,g/=y;let b=this.stops?ht(this.stops,(d+f)/2/s):me(l),w=e.fogged(b[0],b[1],b[2],m);e.push($e([Yi(p)],w,r,c*g,u,"round"),m+h)}}};function Yi(n){let t=new Float64Array(2+(n.length-1)*6);t[0]=n[0][0],t[1]=n[0][1];let e=2;for(let r=1;r<n.length;r++){let o=n[r-1],s=n[r];t[e++]=o[0]+(s[0]-o[0])/3,t[e++]=o[1]+(s[1]-o[1])/3,t[e++]=o[0]+(s[0]-o[0])*2/3,t[e++]=o[1]+(s[1]-o[1])*2/3,t[e++]=s[0],t[e++]=s[1]}return{p:t,closed:!1,straight:!0}}function nm(n,t,e,r={}){return new So(n,t,e,r)}var rr=class extends Bt{constructor(e,r,o={}){super();this.a=e;this.b=r;this.style=o;this.base.stroke=q(o.color??"ink"),this.base.strokeWidth=o.width??2.5}a;b;style;emit(e){let r=this.objectAlpha(e)*(this.style.opacity??1)*this.get("strokeOpacity");if(r<=.002)return;let o=pe(this.a),s=pe(this.b),i=this.style.pieces??14,a=this.get("trimTo"),l=me(this.get("stroke")),c=this.get("strokeWidth")*e.scale,h=this.style.onTop?Ve:this.style.bias??0;for(let u=0;u<i;u++){let d=u/i*a,f=(u+1)/i*a;if(!e.project(o[0]+(s[0]-o[0])*d,o[1]+(s[1]-o[1])*d,o[2]+(s[2]-o[2])*d))continue;let p=e.px,m=e.py,g=e.pz,y=e.ps;if(!e.project(o[0]+(s[0]-o[0])*f,o[1]+(s[1]-o[1])*f,o[2]+(s[2]-o[2])*f))continue;let b=(g+e.pz)/2,w=e.fogged(l[0],l[1],l[2],b);e.push($e([nr(p,m,e.px,e.py)],w,r,c*(y+e.ps)/2,0,"butt"),b+h)}}};function rm(n,t,e={}){return new rr(n,t,e)}var Po=class extends rr{from3;to3;tipSize;tipBias;constructor(t,e,r={}){super(t,()=>{let o=pe(t),s=pe(e),i=Math.hypot(s[0]-o[0],s[1]-o[1],s[2]-o[2])||1,a=Math.min(.9,.22/i);return[s[0]-(s[0]-o[0])*a,s[1]-(s[1]-o[1])*a,s[2]-(s[2]-o[2])*a]},{color:"yellow",width:4,...r}),this.from3=t,this.to3=e,this.tipSize=r.tip??24,this.tipBias=r.onTop?Ve:r.bias??0}emit(t){if(super.emit(t),this.get("trimTo")<.98)return;let r=pe(this.from3),o=pe(this.to3),s=this.objectAlpha(t);if(!t.project(r[0],r[1],r[2]))return;let i=t.px,a=t.py;if(!t.project(o[0],o[1],o[2]))return;let l=t.px,c=t.py,h=t.pz,u=t.ps,d=Math.hypot(l-i,c-a)||1,f=(l-i)/d,p=(c-a)/d,m=this.tipSize*t.scale*u,g=m*.42,y=me(this.get("stroke")),b=t.fogged(y[0],y[1],y[2],h),w=Fo([l,c,l-f*m-p*g,c-p*m+f*g,l-f*m+p*g,c-p*m-f*g]);t.push(Le([w],b,s,null,0,0),h+.01+this.tipBias)}};function om(n,t,e={}){return new Po(n,t,e)}var or=class extends Bt{constructor(e,r={}){super();this.source=e;this.style=r;this.base.fill=q(r.color??"yellow")}source;style;emit(e){let r=this.objectAlpha(e)*(this.style.opacity??1)*this.get("fillOpacity");if(r<=.002)return;let o=typeof this.source=="function"?this.source():this.source,s=(this.style.radius??8)*e.scale,i=this.get("trimTo"),a=Math.ceil(o.length*i),l=me(this.get("fill")),c=this.style.onTop?Ve:this.style.bias??0;for(let h=0;h<a;h++){let u=o[h];if(!e.project(u[0],u[1],u[2]))continue;let d=this.style.colorAt?Ut(this.style.colorAt(h,u)):l,f=e.fogged(d[0],d[1],d[2],e.pz),p=s*e.ps;this.style.halo&&e.push(Le([Xi(e.px,e.py,p*(1+this.style.halo))],f,r*.18,null,0,0),e.pz+c-.001),e.push(Le([Xi(e.px,e.py,p)],f,r,null,0,0),e.pz+c)}}};function sm(n,t={}){return new or(n,t)}function im(n,t={}){return new or(()=>[pe(n)],t)}var Io=class extends Bt{constructor(e,r,o,s={}){super();this.point=e;this.from=r;this.to=o;this.style=s;this.base.stroke=q(s.color??"yellow"),this.base.strokeWidth=s.width??3}point;from;to;style;cache=new Map;sample(e,r){let o=this.cache.get(e);if(o)return o;let s=E.now;E.now=this.from+e/r;let i=this.point();return E.now=s,E.mode==="render"&&this.cache.set(e,i),i}emit(e,r){if(r<=this.from)return;let o=this.objectAlpha(e)*(this.style.opacity??1),s=this.style.rate??30,i=Math.min(r,this.to),a=this.style.tail,l=a!==void 0?Math.max(this.from,i-a):this.from,c=Math.ceil((l-this.from)*s),h=Math.floor((i-this.from)*s);if(h-c<1)return;let u=this.get("strokeWidth")*e.scale,d=me(this.get("stroke")),f=this.style.fade??(a!==void 0?0:1),p=this.style.onTop?Ve:this.style.bias??0,m=(this.style.glow??0)*e.scale,g=[],y=null;for(let x=c;x<=h;x++){let k=this.sample(x,s);y&&Math.abs(k[0]-y[0])+Math.abs(k[1]-y[1])+Math.abs(k[2]-y[2])<1e-9||(g.push(k),y=k)}let b=g.length-1;if(b<1)return;let w=Math.max(1,Math.ceil(b/48));for(let x=0;x<b;x+=w){let k=[],v=0,M=0;for(let P=x;P<=Math.min(b,x+w);P++){let L=g[P];e.project(L[0],L[1],L[2])&&(k.push([e.px,e.py]),v+=e.pz,M+=e.ps)}if(k.length<2)continue;v/=k.length,M/=k.length;let A=Math.min(1,(x+w/2)/b),C=f+(1-f)*Math.pow(A,1.6),O=e.fogged(d[0],d[1],d[2],v);e.push($e([Yi(k)],O,o*C,u*M,m,"butt"),v+p)}}};function am(n,t,e,r={}){return new Io(n,t,e,r)}var Eo=class extends Bt{constructor(e={}){super();this.options=e;this.ranges=[e.x??[-4,4],e.y??[-4,4],e.z??[-2.5,2.5]],this.step=e.step??1,this.base.stroke=q(e.color??"dim"),this.base.strokeWidth=e.width??2;let r=e.labelSize??34,o=e.labels===!1?null:Array.isArray(e.labels)?e.labels:["x","y","z"];if(this.tags=o?o.map(s=>lt(s,{size:r,display:!1,color:"ink"})):[],e.numbers){let s=[[1,0,0],[0,1,0],[0,0,1]];this.ranges.forEach((i,a)=>{for(let l of Jt(i[0],i[1],this.step)){if(l===0)continue;let c=[s[a][0]*l,s[a][1]*l,s[a][2]*l];this.numberNodes.push({node:H(String(l),{size:18,color:"dim"}),at:c})}})}}options;ranges;step;tags;numberNodes=[];emit(e){let r=this.objectAlpha(e)*this.get("strokeOpacity");if(r<=.002)return;let o=this.get("trimTo"),s=me(this.get("stroke")),i=this.get("strokeWidth")*e.scale,a=[[1,0,0],[0,1,0],[0,0,1]],l=this.options.onTop?Ve:this.options.bias??.4;this.ranges.forEach((c,h)=>{let u=a[h],d=16,f=c[0],p=f+(c[1]-f)*o;for(let m=0;m<d;m++){let g=f+(p-f)*m/d,y=f+(p-f)*(m+1)/d;if(!e.project(u[0]*g,u[1]*g,u[2]*g))continue;let b=e.px,w=e.py,x=e.pz;if(!e.project(u[0]*y,u[1]*y,u[2]*y))continue;let k=(x+e.pz)/2;e.push($e([nr(b,w,e.px,e.py)],e.fogged(s[0],s[1],s[2],k),r,i,0,"butt"),k+l)}if(this.options.ticks??!0)for(let m of Jt(c[0],p,this.step)){if(m===0||!e.project(u[0]*m,u[1]*m,u[2]*m))continue;let g=e.px,y=e.py,b=e.pz,w=5*e.ps*e.scale,x=nr(g-(h===2?w:0),y-(h===2?0:w),g+(h===2?w:0),y+(h===2?0:w));e.push($e([x],e.fogged(s[0],s[1],s[2],b),r,i*.8,0,"butt"),b+l)}if(o>.98&&e.project(u[0]*c[1],u[1]*c[1],u[2]*c[1])){let m=e.px,g=e.py,y=e.pz,b=c[1]-.2;if(e.project(u[0]*b,u[1]*b,u[2]*b)){let w=Math.hypot(m-e.px,g-e.py)||1,x=(m-e.px)/w,k=(g-e.py)/w,v=14*e.scale,M=v*.42,A=Fo([m,g,m-x*v-k*M,g-k*v+x*M,m-x*v+k*M,g-k*v-x*M]);e.push(Le([A],e.fogged(s[0],s[1],s[2],y),r,null,0,0),y+l)}}})}labelsNow(e){let r=this.get("opacity")*this.get("strokeOpacity");if(r<=.002||this.get("trimTo")<.9)return[];let o=[],s=[[1,0,0],[0,1,0],[0,0,1]];this.tags.forEach((i,a)=>{let l=s[a],c=this.ranges[a][1]+.35,h=e.screen(l[0]*c,l[1]*c,l[2]*c);h&&(i.at(h),i.set("opacity",r),o.push(i))});for(let{node:i,at:a}of this.numberNodes){let l=e.screen(a[0],a[1],a[2]);l&&(i.at(l[0]+12,l[1]+14),i.set("opacity",r),o.push(i))}return o}};function lm(n={}){return new Eo(n)}var To=class extends Bt{constructor(e={}){super();this.options=e;this.base.stroke=q(e.color??"grid"),this.base.strokeWidth=e.width??1.2}options;emit(e){let r=this.objectAlpha(e)*(this.options.opacity??1)*this.get("strokeOpacity");if(r<=.002)return;let[o,s]=this.options.x??[-5,5],[i,a]=this.options.y??[-5,5],l=this.options.z??0,c=this.options.step??1,h=me(this.get("stroke")),u=this.get("strokeWidth")*e.scale,d=this.get("trimTo"),f=(p,m,g,y)=>{for(let w=0;w<10;w++){let x=w/10*d,k=(w+1)/10*d;if(!e.project(p+(g-p)*x,m+(y-m)*x,l))continue;let v=e.px,M=e.py,A=e.pz;if(!e.project(p+(g-p)*k,m+(y-m)*k,l))continue;let C=(A+e.pz)/2;e.push($e([nr(v,M,e.px,e.py)],e.fogged(h[0],h[1],h[2],C),r,u,0,"butt"),C-.05)}};for(let p of Jt(o,s,c))f(p,i,p,a);for(let p of Jt(i,a,c))f(o,p,s,p)}};function cm(n={}){return new To(n)}var Ro=class extends Bt{constructor(e,r,o={}){super();this.position=r;this.content=typeof e=="string"?o.math===!1?H(e,{size:o.size??28,color:o.color??"ink"}):lt(e,{size:o.size??32,color:o.color??"ink",display:!1}):e,this.offset=o.offset??[0,0]}position;content;offset;emit(){}labelsNow(e){let r=this.get("opacity");if(r<=.002)return[];let o=pe(this.position),s=e.screen(o[0],o[1],o[2]);return s?(this.content.at(s[0]+this.offset[0],s[1]+this.offset[1]),this.content.set("opacity",r*this.get("trimTo")),[this.content]):[]}};function hm(n,t,e={}){return new Ro(n,t,e)}var sr=class{film;canvas;ctx;options;raf=0;last=0;currentTime=0;playing=!1;scale=1;bloomLayers=[];observer=null;speed;constructor(t,e,r={}){this.canvas=t,this.film=e,this.options=r,this.speed=r.speed??1;let o=t.getContext("2d",{alpha:e.background===null});if(!o)throw new Error("This browser could not create a 2D canvas.");this.ctx=o,this.resize(),typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(()=>this.resize()),this.observer.observe(t)),this.paint(),r.autoplay&&this.play()}get time(){return this.currentTime}get isPlaying(){return this.playing}swap(t){let e=t.width!==this.film.width||t.height!==this.film.height;this.film=t,e&&(this.bloomLayers=[],this.resize()),this.paint()}resize(){let t=this.canvas.getBoundingClientRect(),e=this.options.pixelRatio??Math.min(2,globalThis.devicePixelRatio||1),r=t.width||this.film.width,o=Math.max(2,Math.round(r*e)),s=Math.max(2,Math.round(o*this.film.height/this.film.width));(this.canvas.width!==o||this.canvas.height!==s)&&(this.canvas.width=o,this.canvas.height=s,this.bloomLayers=[]),this.scale=o/this.film.width,this.playing||this.paint()}play(){this.playing||(this.currentTime>=this.film.duration-1e-6&&(this.currentTime=0),this.playing=!0,this.last=performance.now(),this.options.onState?.({playing:!0}),this.raf=requestAnimationFrame(this.tick))}pause(){this.playing&&(this.playing=!1,cancelAnimationFrame(this.raf),this.options.onState?.({playing:!1}))}toggle(){this.playing?this.pause():this.play()}seek(t){this.currentTime=Math.max(0,Math.min(this.film.duration,t)),this.paint(),this.options.onTime?.(this.currentTime)}next(){let t=this.film.chapters.find(e=>e.time>this.currentTime+.001);this.seek(t?t.time:this.film.duration)}previous(){let t=[...this.film.chapters].reverse().find(e=>e.time<this.currentTime-.25);this.seek(t?t.time:0)}destroy(){this.pause(),this.observer?.disconnect()}tick=t=>{if(!this.playing)return;let e=Math.max(0,Math.min(.1,(t-this.last)/1e3));this.last=t;let r=this.currentTime,o=r+e*this.speed;if(this.options.stepped){let s=this.film.chapters.find(i=>i.time>r+.001&&i.time<=o);if(s){this.currentTime=s.time,this.paint(),this.options.onTime?.(this.currentTime),this.pause();return}}if(o>=this.film.duration)if(this.options.loop)o%=this.film.duration;else{this.currentTime=this.film.duration,this.paint(),this.options.onTime?.(this.currentTime),this.pause();return}this.currentTime=o,this.paint(),this.options.onTime?.(this.currentTime),this.raf=requestAnimationFrame(this.tick)};lookupImage=t=>{let e=Un(t.asset);if(!e)throw new gt("The film image was not preloaded before playback.");return e};paint(){let t;try{t=this.film.frame(this.currentTime)}catch(e){if(e instanceof It){e.promise.then(()=>this.paint());return}throw e}Br(this.ctx,t,this.scale,this.lookupImage),t.bloom>0&&t.dark&&this.applyBloom(t)}applyBloom(t){if(this.bloomLayers.length===0){let{width:a,height:l}=this.canvas;this.bloomLayers=[[4,.55],[8,.3],[16,.15]].map(([c,h])=>{let u=document.createElement("canvas");return u.width=Math.max(1,Math.round(a/c)),u.height=Math.max(1,Math.round(l/c)),{canvas:u,ctx:u.getContext("2d"),factor:c,weight:h}})}let{width:e}=this.canvas,r="filter"in this.ctx,o=[2.83,3.65,3.65],s=this.canvas;this.bloomLayers.forEach((a,l)=>{let{ctx:c,canvas:h}=a;c.setTransform(1,0,0,1,0,0),c.globalCompositeOperation="source-over",c.clearRect(0,0,h.width,h.height),c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="medium",r&&(c.filter=`blur(${(o[l]*e/1920).toFixed(2)}px)`),c.drawImage(s,0,0,h.width,h.height),r&&(c.filter="none"),l===0&&t.background&&(c.globalCompositeOperation="difference",c.fillStyle=t.background,c.fillRect(0,0,h.width,h.height),c.globalCompositeOperation="source-over"),s=h});let i=this.ctx;i.setTransform(1,0,0,1,0,0),i.globalCompositeOperation="screen",i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high";for(let a of this.bloomLayers)i.globalAlpha=Math.min(1,t.bloom*a.weight*2.4),i.drawImage(a.canvas,0,0,this.canvas.width,this.canvas.height);i.globalAlpha=1,i.globalCompositeOperation="source-over"}};function qi(n){let t=Math.floor(n/60),e=Math.floor(n%60);return`${t}:${String(e).padStart(2,"0")}`}var Sc=`
5
5
  :host { display: block; position: relative; background: #0b0c10; border-radius: inherit; overflow: hidden; font: 12px/1 ui-monospace, "JetBrains Mono", monospace; color: #f2efe6; aspect-ratio: var(--vz-aspect, 16 / 9); }
6
6
  canvas { display: block; width: 100%; height: 100%; }
7
7
  .chrome { position: absolute; inset: auto 0 0 0; display: flex; align-items: center; gap: 12px; padding: 28px 14px 12px; background: linear-gradient(to top, rgba(0,0,0,.62), rgba(0,0,0,0)); opacity: 0; transition: opacity .18s ease; }
@@ -16,4 +16,4 @@ button:hover { background: rgba(255,255,255,.12); }
16
16
  .tick { position: absolute; top: 4px; width: 1px; height: 8px; background: rgba(255,255,255,.55); }
17
17
  .time { font-variant-numeric: tabular-nums; opacity: .82; white-space: nowrap; }
18
18
  svg { width: 14px; height: 14px; fill: currentColor; }
19
- `,Ns='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2.5v11l9-5.5z"/></svg>',wa='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2.5h3v11H4zM9 2.5h3v11H9z"/></svg>',xa='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 6V2h4v1.5H3.5V6zM10 2h4v4h-1.5V3.5H10zM2 10h1.5v2.5H6V14H2zM12.5 10H14v4h-4v-1.5h2.5z"/></svg>';function Vr(n,t="vz-film"){if(typeof customElements>"u"||customElements.get(t))return;class e extends HTMLElement{player=null;visible=!1;started=!1;wantsPlay=!1;intersection=null;keys=null;connectedCallback(){let o=this.shadowRoot??this.attachShadow({mode:"open"}),s=this.getAttribute("label")??"Animation";o.innerHTML=`<style>${ya}</style><canvas role="img"></canvas><div class="chrome"><button class="toggle" type="button" aria-label="Play">${Ns}</button><div class="track" role="slider" tabindex="0" aria-label="Seek" aria-valuemin="0"><div class="fill"></div></div><span class="time">0:00</span><button class="full" type="button" aria-label="Full screen">${xa}</button></div>`,o.querySelector("canvas").setAttribute("aria-label",s),this.setAttribute("data-paused",""),this.intersection=new IntersectionObserver(i=>{this.visible=i.some(a=>a.isIntersecting),this.visible&&!this.started&&this.start(),this.player&&(!this.visible&&this.player.isPlaying?(this.wantsPlay=!0,this.player.pause()):this.visible&&this.wantsPlay&&(this.wantsPlay=!1,this.player.play()))},{rootMargin:"240px"}),this.intersection.observe(this)}disconnectedCallback(){this.intersection?.disconnect(),this.player?.destroy(),this.player=null,this.started=!1}get controller(){return this.player}async start(){this.started=!0;let o=this.getAttribute("src");if(!o)return;let s=this.shadowRoot,i;try{i=await n(o,{look:this.getAttribute("look")??void 0,background:this.getAttribute("background")??void 0})}catch(g){let w=g instanceof Error?g.message:String(g);console.error(`vz-film: could not load ${o}:`,g);let x=document.createElement("div");x.setAttribute("role","alert"),x.style.cssText="position:absolute;inset:0;display:grid;place-items:center;padding:24px;text-align:center;line-height:1.5;color:#ff8d8d",x.textContent=`This film could not load: ${w}`,s.append(x),this.dispatchEvent(new CustomEvent("error",{detail:{error:g}}));return}this.style.setProperty("--vz-aspect",`${i.width} / ${i.height}`);let a=s.querySelector("canvas"),l=s.querySelector(".toggle"),c=s.querySelector(".fill"),u=s.querySelector(".time"),h=s.querySelector(".track"),d=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,m=this.hasAttribute("autoplay")&&!d;h.setAttribute("aria-valuemax",String(Math.round(i.duration)));for(let g of i.chapters){if(g.time<=0)continue;let w=document.createElement("div");w.className="tick",w.style.left=`${g.time/i.duration*100}%`,h.append(w)}let p=g=>{c.style.width=`${g/i.duration*100}%`,u.textContent=`${vs(g)} / ${vs(i.duration)}`,h.setAttribute("aria-valuenow",String(Math.round(g))),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:g}}))},f=new Pn(a,i,{loop:this.hasAttribute("loop"),stepped:this.hasAttribute("stepped"),onTime:p,onState:({playing:g})=>{l.innerHTML=g?wa:Ns,l.setAttribute("aria-label",g?"Pause":"Play"),g?this.removeAttribute("data-paused"):this.setAttribute("data-paused","")}});this.player=f;let b=this.getAttribute("start");d&&!this.hasAttribute("start")?f.seek(i.duration):b?f.seek(Number(b)):p(0),l.addEventListener("click",()=>f.toggle()),a.addEventListener("click",()=>f.toggle()),s.querySelector(".full").addEventListener("click",()=>{document.fullscreenElement?document.exitFullscreen():this.requestFullscreen()});let y=g=>{let w=h.getBoundingClientRect();f.seek((g.clientX-w.left)/w.width*i.duration)};h.addEventListener("pointerdown",g=>{h.setPointerCapture(g.pointerId),y(g);let w=x=>y(x);h.addEventListener("pointermove",w),h.addEventListener("pointerup",()=>h.removeEventListener("pointermove",w),{once:!0})}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.keys?.abort(),this.keys=new AbortController,this.addEventListener("keydown",g=>{g.metaKey||g.ctrlKey||g.altKey||(g.key===" "||g.key==="k"?(g.preventDefault(),f.toggle()):g.key==="ArrowRight"?(g.preventDefault(),this.hasAttribute("stepped")?f.play():f.seek(f.time+5)):g.key==="ArrowLeft"?(g.preventDefault(),this.hasAttribute("stepped")?f.previous():f.seek(f.time-5)):g.key==="f"&&(document.fullscreenElement?document.exitFullscreen():this.requestFullscreen()))},{signal:this.keys.signal}),m&&this.visible?f.play():m&&(this.wantsPlay=!0),this.dispatchEvent(new CustomEvent("ready",{detail:{film:i,player:f}}))}}customElements.define(t,e)}Yn(new URL("../../assets/",import.meta.url).href);var Ps=new Map;function ka(n,t={}){let e=new URL(n,document.baseURI).href,r=`${e}|${t.look??""}|${t.background??""}`,o=Ps.get(r);return o||(o=import(e).then(s=>{if(!Ee(s.default))throw new Error(`${n} must export a film as its default export.`);let i={};if(t.look&&(i.look=t.look),t.background){let a=qe(i.look??s.default.options.look);i.look={...a,background:t.background,colors:{...a.colors,bg:t.background}},i.background=t.background}return ln(s.default,i)}),Ps.set(r,o)),o}Vr(ka);export{xr as ArrayCells,Jn as Axes,Er as Axes3D,hr as BarChart,Or as Callout,kr as CodeBlock,an as CompiledFilm,or as ComplexPlane,Ar as Connector,je as Counter,Tr as Curve3D,Rs as EMPTY_BOUNDS,cr as Epicycles,Pn as FilmPlayer,bn as Graph,yr as GraphEdge,gr as GraphNode,zr as GridPlane3D,De as Heatmap,dr as Histogram,zt as IDENTITY,Pr as InfoBox,Jr as LOOKS,$r as Label3D,lr as LabeledDot,vn as Line3D,pr as LineChart,ar as MatrixNode,kn as Narration,Mr as NeuralNet,N as Node,rr as NumberLine,Le as NumberPlane,Et as Object3D,fn as PieChart,Nn as Points3D,mr as Scatter,Rr as Scene3D,xn as SceneClock,sn as Stage,ir as StreamLines,_e as Surface3D,Ot as Suspend,wn as SvgNode,un as TexNode,cn as TextNode,vr as TokenRow,Ir as Trail3D,wr as TreeGraph,pt as Value,Fr as Vector3D,sr as VectorField,Sr as View3D,Pl as along,iu as angleMark,wl as appear,Q as apply,Zc as applyComplex,Al as applyMatrix,bc as arc,St as arcPath,nu as areaUnder,Xu as arrayCells,$e as arrow,Ju as attentionMatrix,Pc as axes,Jh as axes3d,Pu as barChart,$s as blueprint,Ba as bounce,_o as brace,cu as braceLabel,_n as buildOps,dl as call,uh as callout,ws as captionLines,Ls as chalk,Qi as checkFilm,Go as circle,Dt as circlePath,Rl as circumscribe,Yu as codeBlock,_s as colorAlong,ln as compileFilm,Jc as complex,Uc as complexPlane,fe as compose,Ma as concat,lh as connector,vh as countUp,Mh as counter,Yt as css,Ha as cubicBezier,mc as curve,Kh as curve3d,be as curveThrough,su as dashedGuides,Oc as decimal,Vr as defineFilmElement,hl as delay,Ru as donut,gt as dot,ml as draw,_a as during,At as dynamic,Oa as easeInCubic,Ia as easeInExpo,Sa as easeInOutCubic,Ta as easeInOutQuint,Pa as easeInQuad,Ca as easeOutCubic,Fa as easeOutExpo,Aa as easeOutQuad,Ra as easeOutQuint,fc as ellipse,fu as epicycles,fl as erase,po as fade,bl as fadeIn,gl as fadeOut,gi as film,Tl as flash,xe as fontFor,mu as fourier,is as fourierPoint,fi as frameInkBounds,Hn as frameToSvg,fa as fromSvg,ze as glyphPath,Hu as graph,Qh as gridPlane3d,Vn as group,yl as grow,Tu as heatmap,Ah as highlightSweep,Au as histogram,yc as image,Cl as indicate,ah as infoBox,Wt as invert,Ee as isFilm,Xn as isSuspend,td as label3d,hu as labeledDot,ul as lagged,ch as legend,Y as line,Xh as line3d,Cu as lineChart,le as linePath,Fe as linear,Gs as linearGradient,Ga as lingering,ka as loadFilm,Xt as matScale,lu as matrix,Ye as midnight,he as mixColor,Ol as morph,qu as morphCode,we as morphMatching,kl as moveTo,rt as mul,ba as narration,Vs as neon,Uu as neuralNet,Da as notQuiteThere,qc as numberLine,La as overshoot,Kn as paintFrame,zs as paper,Bn as par,pc as parametric,He as parametricPath,jh as parametricSurface,Gt as parseColor,$o as parseFont,vt as parseSvgPath,bt as pathBounds,Pt as pathLength,Ur as pathToD,Su as pie,Ac as plane,Uh as point3d,Nt as pointAt,qh as points3d,Z as polyPath,Ii as polygon,dc as polyline,Dn as pulse,js as radialGradient,Ie as ramp,mo as recolor,jo as rect,K as rectPath,gc as regularPolygon,qe as resolveLook,Js as retime,Sn as reverseRing,eu as riemann,au as rightAngle,Mt as ring,ue as ringCenter,Te as ringLength,bu as ringThrough,Fl as ripple,Nl as rotate,ja as runningStart,za as rushFrom,Ea as rushInto,pu as samplePath,vl as scaleBy,Ou as scatter,Gh as scene3d,ou as secantLine,$t as segmentCount,lo as seq,Yn as setAssetBase,Sl as shake,Fi as shape,Ml as shift,ce as signedArea,$a as slowInto,dt as smooth,Es as smoothBy,Lt as smoothPath,Na as smoother,la as sparkline,Hh as sphere,Nh as spin,Va as spring,tu as streamLines,Cn as subdivideEach,_h as surface,uu as surroundingBox,hc as svgPath,Ph as swap,ge as tangentAt,ru as tangentLine,st as tex,H as text,Fn as thereAndBack,Wa as thereAndBackWithPause,de as to,X as toPaint,ia as tokenize,Zu as tokens,du as traced,Zh as trail3d,ot as transformPath,Ku as tree,Jt as trimPath,Hr as trimRing,xh as typewriter,Xe as unionBounds,xl as vanish,Yh as vector3d,Qc as vectorField,Wn as warp,Yr as warpPath,Zr as wiggle,kh as wipe,pl as write};
19
+ `,Zi='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2.5v11l9-5.5z"/></svg>',Pc='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2.5h3v11H4zM9 2.5h3v11H9z"/></svg>',Ic='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 6V2h4v1.5H3.5V6zM10 2h4v4h-1.5V3.5H10zM2 10h1.5v2.5H6V14H2zM12.5 10H14v4h-4v-1.5h2.5z"/></svg>';function zo(n,t="vz-film"){if(typeof customElements>"u"||customElements.get(t))return;class e extends HTMLElement{player=null;visible=!1;started=!1;wantsPlay=!1;intersection=null;keys=null;connectedCallback(){let o=this.shadowRoot??this.attachShadow({mode:"open"}),s=this.getAttribute("label")??"Animation";o.innerHTML=`<style>${Sc}</style><canvas role="img"></canvas><div class="chrome"><button class="toggle" type="button" aria-label="Play">${Zi}</button><div class="track" role="slider" tabindex="0" aria-label="Seek" aria-valuemin="0"><div class="fill"></div></div><span class="time">0:00</span><button class="full" type="button" aria-label="Full screen">${Ic}</button></div>`,o.querySelector("canvas").setAttribute("aria-label",s),this.setAttribute("data-paused",""),this.intersection=new IntersectionObserver(i=>{this.visible=i.some(a=>a.isIntersecting),this.visible&&!this.started&&this.start(),this.player&&(!this.visible&&this.player.isPlaying?(this.wantsPlay=!0,this.player.pause()):this.visible&&this.wantsPlay&&(this.wantsPlay=!1,this.player.play()))},{rootMargin:"240px"}),this.intersection.observe(this)}disconnectedCallback(){this.intersection?.disconnect(),this.player?.destroy(),this.player=null,this.started=!1}get controller(){return this.player}async start(){this.started=!0;let o=this.getAttribute("src");if(!o)return;let s=this.shadowRoot,i;try{i=await n(o,{look:this.getAttribute("look")??void 0,background:this.getAttribute("background")??void 0})}catch(b){let w=b instanceof Error?b.message:String(b);console.error(`vz-film: could not load ${o}:`,b);let x=document.createElement("div");x.setAttribute("role","alert"),x.style.cssText="position:absolute;inset:0;display:grid;place-items:center;padding:24px;text-align:center;line-height:1.5;color:#ff8d8d",x.textContent=`This film could not load: ${w}`,s.append(x),this.dispatchEvent(new CustomEvent("error",{detail:{error:b}}));return}this.style.setProperty("--vz-aspect",`${i.width} / ${i.height}`);let a=s.querySelector("canvas"),l=s.querySelector(".toggle"),c=s.querySelector(".fill"),h=s.querySelector(".time"),u=s.querySelector(".track"),d=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,f=this.hasAttribute("autoplay")&&!d;u.setAttribute("aria-valuemax",String(Math.round(i.duration)));for(let b of i.chapters){if(b.time<=0)continue;let w=document.createElement("div");w.className="tick",w.style.left=`${b.time/i.duration*100}%`,u.append(w)}let p=b=>{c.style.width=`${b/i.duration*100}%`,h.textContent=`${qi(b)} / ${qi(i.duration)}`,u.setAttribute("aria-valuenow",String(Math.round(b))),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:b}}))},m=new sr(a,i,{loop:this.hasAttribute("loop"),stepped:this.hasAttribute("stepped"),onTime:p,onState:({playing:b})=>{l.innerHTML=b?Pc:Zi,l.setAttribute("aria-label",b?"Pause":"Play"),b?this.removeAttribute("data-paused"):this.setAttribute("data-paused","")}});this.player=m;let g=this.getAttribute("start");d&&!this.hasAttribute("start")?m.seek(i.duration):g?m.seek(Number(g)):p(0),l.addEventListener("click",()=>m.toggle()),a.addEventListener("click",()=>m.toggle()),s.querySelector(".full").addEventListener("click",()=>{document.fullscreenElement?document.exitFullscreen():this.requestFullscreen()});let y=b=>{let w=u.getBoundingClientRect();m.seek((b.clientX-w.left)/w.width*i.duration)};u.addEventListener("pointerdown",b=>{u.setPointerCapture(b.pointerId),y(b);let w=x=>y(x);u.addEventListener("pointermove",w),u.addEventListener("pointerup",()=>u.removeEventListener("pointermove",w),{once:!0})}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.keys?.abort(),this.keys=new AbortController,this.addEventListener("keydown",b=>{b.metaKey||b.ctrlKey||b.altKey||(b.key===" "||b.key==="k"?(b.preventDefault(),m.toggle()):b.key==="ArrowRight"?(b.preventDefault(),this.hasAttribute("stepped")?m.play():m.seek(m.time+5)):b.key==="ArrowLeft"?(b.preventDefault(),this.hasAttribute("stepped")?m.previous():m.seek(m.time-5)):b.key==="f"&&(document.fullscreenElement?document.exitFullscreen():this.requestFullscreen()))},{signal:this.keys.signal}),f&&this.visible?m.play():f&&(this.wantsPlay=!0),this.dispatchEvent(new CustomEvent("ready",{detail:{film:i,player:m}}))}}customElements.define(t,e)}Gr(new URL("../../assets/",import.meta.url).href);var Ji=new Map;function Ec(n,t={}){let e=new URL(n,document.baseURI).href,r=`${e}|${t.look??""}|${t.background??""}`,o=Ji.get(r);return o||(o=import(e).then(s=>{if(!Ae(s.default))throw new Error(`${n} must export a film as its default export.`);let i={};if(t.look&&(i.look=t.look),t.background){let a=xn(i.look??s.default.options.look);i.look={...a,background:t.background,colors:{...a.colors,bg:t.background}},i.background=t.background}return Gn(s.default,i)}),Ji.set(r,o)),o}zo(Ec);export{bo as ArrayCells,Kr as Axes,Eo as Axes3D,ao as BarChart,Ao as Callout,yo as CodeBlock,Dn as CompiledFilm,to as ComplexPlane,Mo as Connector,pn as Counter,So as Curve3D,ra as EMPTY_BOUNDS,so as Epicycles,sr as FilmPlayer,qn as Graph,mo as GraphEdge,po as GraphNode,To as GridPlane3D,dn as Heatmap,lo as Histogram,Dt as IDENTITY,gt as ImageAssetError,vo as InfoBox,Yo as LOOKS,Ro as Label3D,oo as LabeledDot,rr as Line3D,ho as LineChart,ro as MatrixNode,er as Narration,wo as NeuralNet,N as Node,Qr as NumberLine,ln as NumberPlane,Bt as Object3D,Yn as PieChart,or as Points3D,co as Scatter,Oo as Scene3D,tr as SceneClock,Re as Stage,no as StreamLines,mn as Surface3D,It as Suspend,Qn as SvgNode,jn as TexNode,Wn as TextNode,xo as TokenRow,Io as Trail3D,go as TreeGraph,yt as Value,Po as Vector3D,eo as VectorField,Co as View3D,zh as along,gf as angleMark,Ph as appear,tt as apply,af as applyComplex,$h as applyMatrix,Md as arc,$t as arcPath,df as areaUnder,rp as arrayCells,an as arrow,lp as attentionMatrix,Td as axes,lm as axes3d,zf as barChart,ca as blueprint,Yc as bounce,bi as brace,wf as braceLabel,Ur as buildOps,vh as call,xp as callout,Hi as captionLines,ha as chalk,lc as checkFilm,mi as circle,Yt as circlePath,_h as circumscribe,op as codeBlock,ba as colorAlong,Gn as compileFilm,lf as complex,sf as complexPlane,Oe as compose,Tc as concat,yp as connector,Rp as countUp,Tp as counter,ne as css,eh as cubicBezier,xd as curve,nm as curve3d,Se as curveThrough,mf as dashedGuides,Fd as decimal,zo as defineFilmElement,kh as delay,_f as donut,xt as dot,Mh as draw,th as during,Rt as dynamic,Lc as easeInCubic,Gc as easeInExpo,Uc as easeInOutCubic,Bc as easeInOutQuint,zc as easeInQuad,Vc as easeOutCubic,Dc as easeOutExpo,$c as easeOutQuad,_c as easeOutQuint,vd as ellipse,Nf as epicycles,Nh as erase,hs as fade,Ch as fadeIn,Oh as fadeOut,Ol as film,Bh as flash,Fe as fontFor,Mf as fourier,Ri as fourierPoint,Nl as frameInkBounds,_r as frameToSvg,Nc as fromSvg,sn as glyphPath,ep as graph,cm as gridPlane3d,yr as group,Sh as grow,Bf as heatmap,$p as highlightSweep,$f as histogram,Nd as image,Vh as indicate,bp as infoBox,Xt as invert,Ae as isFilm,Dr as isSuspend,hm as label3d,kf as labeledDot,xh as lagged,wp as legend,Z as line,rm as line3d,Vf as lineChart,ye as linePath,He as linear,ma as linearGradient,Jc as lingering,Ec as loadFilm,ee as matScale,yf as matrix,wn as midnight,ke as mixColor,Lh as morph,sp as morphCode,Ee as morphMatching,Eh as moveTo,it as mul,Cc as narration,ua as neon,ip as neuralNet,Zc as notQuiteThere,of as numberLine,Kc as overshoot,Br as paintFrame,la as paper,wr as par,kd as parametric,gn as parametricPath,Qp as parametricSurface,qt as parseColor,ci as parseFont,St as parseSvgPath,wt as pathBounds,Tt as pathLength,Ko as pathToD,Uf as pie,Rd as plane,im as point3d,Et as pointAt,sm as points3d,et as polyPath,Gl as polygon,wd as polyline,kr as pulse,ga as radialGradient,Ke as ramp,cs as recolor,gi as rect,Y as rectPath,Ad as regularPolygon,ul as resolveImageAsset,xn as resolveLook,Na as retime,cr as reverseRing,uf as riemann,bf as rightAngle,Ct as ring,xe as ringCenter,je as ringLength,Cf as ringThrough,Dh as ripple,Fh as rotate,Qc as runningStart,jc as rushFrom,Wc as rushInto,Af as samplePath,Rh as scaleBy,Lf as scatter,Jp as scene3d,pf as secantLine,Gt as segmentCount,ss as seq,Gr as setAssetBase,Uh as shake,Dl as shape,Th as shift,we as signedArea,Hc as slowInto,mt as smooth,aa as smoothBy,Wt as smoothPath,Fc as smoother,yc as sparkline,em as sphere,Fp as spin,Xc as spring,hf as streamLines,lr as subdivideEach,tm as surface,xf as surroundingBox,yd as svgPath,zp as swap,Pe as tangentAt,ff as tangentLine,lt as tex,H as text,dr as thereAndBack,qc as thereAndBackWithPause,ve as to,q as toPaint,gc as tokenize,ap as tokens,vf as traced,am as trail3d,at as transformPath,np as tree,ae as trimPath,Do as trimRing,Ip as typewriter,yn as unionBounds,Ih as vanish,om as vector3d,cf as vectorField,xr as warp,jo as warpPath,Xo as wiggle,Ep as wipe,Ah as write};