vizmatic 0.3.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PROMPT.md +75 -525
- package/README.md +87 -578
- package/ROADMAP.md +49 -67
- package/SCIENCE.md +250 -0
- package/assets/THIRD_PARTY_LICENSES.md +40 -1
- package/assets/fonts/InstrumentSerif-Italic.ttf +0 -0
- package/assets/fonts/InstrumentSerif-Regular.ttf +0 -0
- package/assets/licenses/raster-codecs-MIT.txt +74 -0
- package/dist/chunk-3F2VQ7NW.js +1 -0
- package/dist/chunk-4XE64I2U.js +755 -0
- package/dist/chunk-JHHPLALU.js +79 -0
- package/dist/chunk-LTX44BAE.js +112 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-PSBF4TEK.js +1 -0
- package/dist/chunk-RPAHMKAR.js +605 -0
- package/dist/chunk-RWF4VBUL.js +3617 -0
- package/dist/chunk-WHT6HRMX.js +4201 -0
- package/dist/cli.js +371 -10
- package/dist/index.cjs +11129 -2922
- package/dist/index.d.cts +1225 -369
- package/dist/index.d.ts +1225 -369
- package/dist/index.js +6220 -3015
- package/dist/math-LXB4FH4E.js +7 -0
- package/dist/math-QVCETQDQ.js +1 -0
- package/dist/scene-browser-assets.d.ts +38 -0
- package/dist/scene-browser-assets.js +53 -0
- package/dist/scene-browser-chunks/chunk-5MVLYGXM.js +70 -0
- package/dist/scene-browser-chunks/chunk-ASXKN3NU.js +1 -0
- package/dist/scene-browser-chunks/chunk-CM5Y5LZP.js +1 -0
- package/dist/scene-browser-chunks/chunk-DP7NB4EW.js +6 -0
- package/dist/scene-browser-chunks/emscripten-module.browser-M5AEKJGE.js +1 -0
- package/dist/scene-browser-chunks/ffi-FL6ORJU3.js +1 -0
- package/dist/scene-browser-chunks/module-ES6BEMUI-JD5S5VKR.js +1 -0
- package/dist/scene-browser-chunks/module-asyncify-2EFITU5U-HWPFJFJC.js +1 -0
- package/dist/scene-browser-chunks/scene-browser-layout-M3XSXMV4.js +27 -0
- package/dist/scene-browser.d.ts +117 -0
- package/dist/scene-browser.js +220 -0
- package/dist/scene-cli.d.ts +1 -0
- package/dist/scene-cli.js +4 -0
- package/dist/scene-runtime.cjs +995 -0
- package/dist/scene-runtime.d.cts +81 -0
- package/dist/scene-runtime.d.ts +81 -0
- package/dist/scene-runtime.js +22 -0
- package/dist/server-2FYHZ4UO.js +331 -0
- package/dist/stage-browser/browser.d.ts +2482 -0
- package/dist/stage-browser/chunk-SQE76S5B.js +1 -0
- package/dist/stage-browser/chunk-VZNL6JY2.js +59 -0
- package/dist/stage-browser/dagre.esm-N2NIVIAZ.js +6 -0
- package/dist/stage-browser/math-4WFNHVV2.js +18 -0
- package/dist/stage-browser/stage.js +19 -0
- package/dist/stage-export.cjs +4950 -0
- package/dist/stage-export.d.cts +112 -0
- package/dist/stage-export.d.ts +112 -0
- package/dist/stage-export.js +544 -0
- package/dist/stage.cjs +9745 -0
- package/dist/stage.d.cts +1678 -0
- package/dist/stage.d.ts +1678 -0
- package/dist/stage.js +5404 -0
- package/dist/svg-import-Djj2q7Pc.d.cts +742 -0
- package/dist/svg-import-Djj2q7Pc.d.ts +742 -0
- package/dist/video-CcHW1qhV.d.cts +532 -0
- package/dist/video-CcHW1qhV.d.ts +532 -0
- package/examples/README.md +18 -0
- package/examples/agent-pipeline.tsx +4 -4
- package/examples/animated-pipeline.tsx +1 -5
- package/examples/attention-head.tsx +12 -12
- package/examples/aurora-incident.tsx +4 -3
- package/examples/building-blocks.tsx +8 -9
- package/examples/catalog-charts.tsx +4 -4
- package/examples/catalog-content.tsx +7 -9
- package/examples/catalog-convolution-kernel.tsx +116 -0
- package/examples/catalog-data.tsx +2 -8
- package/examples/catalog-dataflow.tsx +5 -9
- package/examples/catalog-dense.tsx +80 -0
- package/examples/catalog-deployment.tsx +5 -11
- package/examples/catalog-diagrams.tsx +13 -16
- package/examples/catalog-drawing.tsx +7 -7
- package/examples/catalog-flows.tsx +4 -4
- package/examples/catalog-foundations.tsx +11 -11
- package/examples/catalog-gaussian-blur.tsx +146 -0
- package/examples/catalog-image-tensors.tsx +115 -0
- package/examples/catalog-ml.tsx +36 -31
- package/examples/catalog-numeric-matrices.tsx +93 -0
- package/examples/catalog-photo-blur.tsx +209 -0
- package/examples/catalog-science-ai.tsx +130 -0
- package/examples/catalog-science-chemistry.tsx +103 -0
- package/examples/catalog-science-math.tsx +93 -0
- package/examples/catalog-science-physics.tsx +84 -0
- package/examples/catalog-sequence.tsx +59 -38
- package/examples/data-pipeline-lineage-presentation.tsx +5 -0
- package/examples/data-pipeline-lineage.tsx +85 -0
- package/examples/daybreak-launch.tsx +1 -0
- package/examples/desired-quadrant.tsx +7 -8
- package/examples/engineering-dashboard-presentation.tsx +13 -0
- package/examples/engineering-dashboard.tsx +160 -0
- package/examples/engineering-flow.tsx +2 -4
- package/examples/eval-dashboard.tsx +6 -6
- package/examples/films/attention.ts +278 -0
- package/examples/films/cache-miss.ts +431 -0
- package/examples/films/catalog.json +132 -0
- package/examples/films/central-limit.ts +269 -0
- package/examples/films/complex-maps.ts +273 -0
- package/examples/films/deck-example.ts +224 -0
- package/examples/films/euler-circle.ts +179 -0
- package/examples/films/fourier-epicycles.ts +265 -0
- package/examples/films/gradient-descent.ts +345 -0
- package/examples/films/linear-maps.ts +175 -0
- package/examples/films/lorenz.ts +207 -0
- package/examples/films/pythagoras.ts +185 -0
- package/examples/films/taylor-series.ts +159 -0
- package/examples/films/vizmatic-title.ts +117 -0
- package/examples/llm-serving-stack-presentation.tsx +5 -0
- package/examples/llm-serving-stack.tsx +94 -0
- package/examples/model-garden.tsx +1 -0
- package/examples/model-router.tsx +6 -6
- package/examples/nccl-all-gather.tsx +3 -3
- package/examples/nccl-all-reduce.tsx +3 -3
- package/examples/nccl-all-to-all.tsx +1 -1
- package/examples/nccl-broadcast.tsx +1 -1
- package/examples/nccl-reduce-scatter.tsx +5 -5
- package/examples/orthogonal-routing.tsx +4 -4
- package/examples/pareto-frontier.tsx +9 -10
- package/examples/presentation-frame.tsx +6 -6
- package/examples/pressure-mechanism.scene.json +14 -0
- package/examples/production-system-map-presentation.tsx +5 -0
- package/examples/production-system-map.tsx +130 -0
- package/examples/rag-graph.tsx +7 -7
- package/examples/release-card.tsx +5 -5
- package/examples/spec-anatomy.tsx +5 -5
- package/examples/system-architecture.tsx +19 -32
- package/examples/theme-system.tsx +1 -1
- package/examples/token-matrix.tsx +4 -2
- package/examples/transparent-badge.tsx +1 -2
- package/examples/videos/README.md +62 -0
- package/examples/videos/calculus-tangent.tsx +101 -0
- package/examples/videos/catalyst-pathway.tsx +56 -0
- package/examples/videos/causal-attention.tsx +91 -0
- package/examples/videos/convolution-kernel.tsx +34 -0
- package/examples/videos/gaussian-blur.tsx +32 -0
- package/examples/videos/image-to-matrix.tsx +22 -0
- package/examples/videos/matrix-multiplication.tsx +128 -0
- package/examples/videos/photo-gaussian-blur.tsx +39 -0
- package/examples/videos/request-lifecycle.tsx +99 -0
- package/examples/videos/signal-to-story.tsx +126 -0
- package/examples/videos/wave-interference.tsx +80 -0
- package/examples/vizmatic-bare.d.ts +1 -0
- package/examples/vizmatic-hero.tsx +9 -18
- package/examples/website-workflow.tsx +7 -7
- package/examples/weekend-field-notes.tsx +3 -2
- package/package.json +77 -12
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{a as ys}from"./chunk-VZNL6JY2.js";import{b as gs}from"./chunk-SQE76S5B.js";var zt=[1,0,0,1,0,0],ws={x:0,y:0,width:0,height:0},xs=.5522847498307936,ae=10;function ot(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,o,r,s,i){let a=e===0?1:Math.cos(e),l=e===0?0:Math.sin(e),c=a*o,u=l*o,h=-l*r,d=a*r;return[c,u,h,d,n-c*s-h*i,t-u*s-d*i]}function Kt(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 Vt(n){return Math.max(0,(n.p.length-2)/6)}function Ct(n,t,e,o,r){n.push(t+(o-t)/3,e+(r-e)/3,t+(o-t)*2/3,e+(r-e)*2/3,o,r)}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],o=[e[0],e[1]];for(let r=1;r<n.length;r++)Ct(o,n[r-1][0],n[r-1][1],n[r][0],n[r][1]);if(t){let r=n[n.length-1];(r[0]!==e[0]||r[1]!==e[1])&&Ct(o,r[0],r[1],e[0],e[1])}return[Mt(o,t)]}function Lt(n,t=!1,e=1/6){let o=n.length;if(o===0)return[];if(o<3)return Z(n,t);let r=a=>t?n[(a+o)%o]:n[Math.max(0,Math.min(o-1,a))],s=[n[0][0],n[0][1]],i=t?o:o-1;for(let a=0;a<i;a++){let l=r(a-1),c=r(a),u=r(a+1),h=r(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,o,r,s){let i=s-r;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(r)*e,t+Math.sin(r)*o];for(let d=0;d<l;d++){let m=r+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)*o,n+(y+u*g)*e,t+(g-u*y)*o,n+y*e,t+g*o)}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 X(n,t,e,o,r=0){let s=Math.max(0,Math.min(r,Math.abs(e)/2,Math.abs(o)/2));if(s===0)return Z([[n,t],[n+e,t],[n+e,t+o],[n,t+o]],!0);let i=s*(1-xs),a=n+e,l=t+o,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 _e(n,t,e,o=64){let r=Math.max(2,Math.floor(o)),s=[];for(let i=0;i<=r;i++)s.push(n(t+(e-t)*i/r));return be(s)}function be(n){let t=[],e=[],o=()=>{e.length>=2&&t.push(...Lt(e)),e=[]};for(let r of n)Number.isFinite(r[0])&&Number.isFinite(r[1])?e.push(r):o();return o(),t}function ca(...n){return n.flat()}function rt(n,t){if(t===zt)return n;let e=new Array(n.length);for(let o=0;o<n.length;o++){let r=n[o].p,s=new Float64Array(r.length);for(let i=0;i<r.length;i+=2){let a=r[i],l=r[i+1];s[i]=t[0]*a+t[2]*l+t[4],s[i+1]=t[1]*a+t[3]*l+t[5]}e[o]={p:s,closed:n[o].closed}}return e}function Ho(n,t,e=4){return(e>1?n.map(r=>An(r,e)):n).map(r=>{let s=Vt(r),i=[];for(let l=0;l<=s;l++){let c=t(r.p[l*6],r.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(r.p[l*6+2],r.p[l*6+3]),u=t(r.p[l*6+4],r.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,r.closed)})}function Pn(n,t,e,o,r){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,O=x+(M-x)*e;o.push(m,p,w,x,v,O),r.length=0,r.push(v,O,k,M,y,g,h,d)}function An(n,t){let e=Vt(n);if(t<=1||e===0)return n;let o=[n.p[0],n.p[1]];for(let r=0;r<e;r++){let s=Array.from(n.p.subarray(r*6,r*6+8));for(let i=t;i>1;i--){let a=[];Pn(s,0,1/i,o,a),s=a}o.push(s[2],s[3],s[4],s[5],s[6],s[7])}return Mt(o,n.closed)}var Wo=new WeakMap;function Xe(n){let t=Wo.get(n);if(t)return t;let e=Vt(n),o=new Float64Array(e),r=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,O=v*v*v,A=3*v*v*M,R=3*v*M*M,E=M*M*M,$=O*u+A*d+R*p+E*b,z=O*h+A*m+R*f+E*y;x+=Math.hypot($-g,z-w),r[l*ae+k-1]=x,g=$,w=z}s+=x,o[l]=s}let a={total:o,lut:r,length:s};return Wo.set(n,a),a}function Se(n){return Xe(n).length}function Ot(n){let t=0;for(let e of n)t+=Xe(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 o=0,r=e-1;for(;o<r;){let d=o+r>>1;n.total[d]<t?o=d+1:r=d}let s=o===0?0:n.total[o-1],i=t-s,a=o*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[o,(l+h)/ae]}function Do(n,t,e){if(Vt(n)===0)return null;let r=Math.max(0,Math.min(1,t)),s=Math.max(0,Math.min(1,e));if(s<=r)return null;if(r===0&&s===1)return n;let i=Xe(n);if(i.length===0)return null;let[a,l]=On(i,r*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=[];Pn(m,0,p,[],b),m=b}if(f<1){let b=[],y=[],g=p>0?(f-p)/(1-p):f;Pn(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,o=!1){if(t<=0&&e>=1)return n;let r=[];if(o){for(let a of n){let l=Do(a,t,e);l&&r.push(l)}return r}let s=Ot(n);if(s===0)return[];let i=0;for(let a of n){let l=Se(a),c=(t*s-i)/(l||1),u=(e*s-i)/(l||1);if(i+=l,u<=0||c>=1)continue;let h=Do(a,Math.max(0,c),Math.min(1,u));h&&r.push(h)}return r}function Pt(n,t){let e=Ot(n);if(e===0){let r=n[0]?.p;return r?[r[0],r[1]]:[0,0]}let o=Math.max(0,Math.min(1,t))*e;for(let r=0;r<n.length;r++){let s=n[r],i=Se(s);if(o<=i||r===n.length-1){let[a,l]=On(Xe(s),o);return ks(s.p,a*6,l)}o-=i}return[0,0]}function ge(n,t){let o=Pt(n,Math.max(0,t-.002)),r=Pt(n,Math.min(1,t+.002)),s=Math.hypot(r[0]-o[0],r[1]-o[1])||1;return[(r[0]-o[0])/s,(r[1]-o[1])/s]}function ks(n,t,e){let o=1-e,r=o*o*o,s=3*o*o*e,i=3*o*e*e,a=e*e*e;return[r*n[t]+s*n[t+2]+i*n[t+4]+a*n[t+6],r*n[t+1]+s*n[t+3]+i*n[t+5]+a*n[t+7]]}function Go(n,t,e,o,r){if(n[0]=Math.min(n[0],t,r),n[1]=Math.max(n[1],t,r),e>=n[0]&&e<=n[1]&&o>=n[0]&&o<=n[1])return;let s=-t+3*e-3*o+r,i=2*(t-2*e+o),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*o+c*c*c*r;n[0]=Math.min(n[0],h),n[1]=Math.max(n[1],h)}}var jo=new WeakMap;function _o(n){let t=jo.get(n);if(t)return t;let e=n.p;if(e.length<2)return ws;let o=[e[0],e[0]],r=[e[1],e[1]];for(let i=0;i+7<e.length;i+=6)Go(o,e[i],e[i+2],e[i+4],e[i+6]),Go(r,e[i+1],e[i+3],e[i+5],e[i+7]);let s={x:o[0],y:r[0],width:o[1]-o[0],height:r[1]-r[0]};return jo.set(n,s),s}function bt(n){if(n.length===0)return null;let t=1/0,e=1/0,o=-1/0,r=-1/0;for(let s of n){if(s.p.length<2)continue;let i=_o(s);t=Math.min(t,i.x),e=Math.min(e,i.y),o=Math.max(o,i.x+i.width),r=Math.max(r,i.y+i.height)}return t===1/0?null:{x:t,y:e,width:o-t,height:r-e}}function Ke(n,t){if(!n)return t;if(!t)return n;let e=Math.min(n.x,t.x),o=Math.min(n.y,t.y);return{x:e,y:o,width:Math.max(n.x+n.width,t.x+t.width)-e,height:Math.max(n.y+n.height,t.y+t.height)-o}}function ce(n){let t=n.p,e=0;for(let o=0;o+7<t.length;o+=6)e+=t[o]*t[o+7]-t[o+6]*t[o+1];return e/2}function ue(n){let t=_o(n);return[t.x+t.width/2,t.y+t.height/2]}function Nn(n){let t=n.p,e=new Float64Array(t.length);for(let o=0;o<t.length;o+=2)e[o]=t[t.length-2-o],e[o+1]=t[t.length-1-o];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=[],o=[],r=0,s=0,i=0,a=0,l=0,c="",u=0,h=0,d=()=>Number(t[r++]),m=()=>{let y=t[r];return y.length>1&&(y[0]==="0"||y[0]==="1")&&!y.startsWith("0.")&&!y.startsWith("1.")?(t[r]=y.slice(1),Number(y[0])):(r++,Number(y))},p=y=>{o.length>=8&&e.push(Mt(o,y)),o=[]},f=(y,g)=>{o.length===0&&o.push(y,g)},b="";for(;r<t.length;){let y=t[r];if(/^[a-zA-Z]$/.test(y))b=y,r++;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,o.push(s,i);break}case"L":{let w=(g?s:0)+d(),x=(g?i:0)+d();f(s,i),Ct(o,s,i,w,x),s=w,i=x;break}case"H":{let w=(g?s:0)+d();f(s,i),Ct(o,s,i,w,i),s=w;break}case"V":{let w=(g?i:0)+d();f(s,i),Ct(o,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(),O=x+d(),A=w+d(),R=x+d();f(s,i),o.push(k,M,v,O,A,R),u=v,h=O,s=A,i=R;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,O=w+d(),A=x+d(),R=w+d(),E=x+d();f(s,i),o.push(M,v,O,A,R,E),u=O,h=A,s=R,i=E;break}case"Q":{let w=g?s:0,x=g?i:0,k=w+d(),M=x+d(),v=w+d(),O=x+d();f(s,i),o.push(s+(k-s)*2/3,i+(M-i)*2/3,v+(k-v)*2/3,O+(M-O)*2/3,v,O),u=k,h=M,s=v,i=O;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,O=w+d(),A=x+d();f(s,i),o.push(s+(M-s)*2/3,i+(v-i)*2/3,O+(M-O)*2/3,A+(v-A)*2/3,O,A),u=M,h=v,s=O,i=A;break}case"A":{let w=d(),x=d(),k=d(),M=m(),v=m(),O=(g?s:0)+d(),A=(g?i:0)+d();f(s,i),Ms(o,s,i,w,x,k,M===1,v===1,O,A),s=O,i=A;break}case"Z":{o.length>0&&((s!==a||i!==l)&&Ct(o,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 Ms(n,t,e,o,r,s,i,a,l,c){let u=Math.abs(o),h=Math.abs(r);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,O=-M*h*y/u,A=m*v-p*O+(t+l)/2,R=p*v+m*O+(e+c)/2,E=Math.atan2((g-O)/h,(y-v)/u),$=Math.atan2((-g-O)/h,(-y-v)/u)-E;a&&$<0&&($+=Math.PI*2),!a&&$>0&&($-=Math.PI*2);let z=Math.max(1,Math.ceil(Math.abs($)/(Math.PI/2)-1e-9)),D=$/z,B=4/3*Math.tan(D/4);for(let G=0;G<z;G++){let U=E+G*D,N=U+D,V=Math.cos(U),F=Math.sin(U),T=Math.cos(N),I=Math.sin(N),S=(V-B*F)*u,L=(F+B*V)*h,j=(T+B*I)*u,J=(I-B*T)*h,at=T*u,tt=I*h;n.push(m*S-p*L+A,p*S+m*L+R,m*j-p*J+A,p*j+m*J+R,G===z-1?l:m*at-p*tt+A,G===z-1?c:p*at+m*tt+R)}}function Bt(n){let t=Math.round(n*100)/100;return t===0?"0":String(t)}function Xo(n){let t=[];for(let e of n){let o=e.p;if(!(o.length<2)){if(t.push("M",Bt(o[0])," ",Bt(o[1])),e.straight){for(let r=2;r+5<o.length;r+=6)t.push("L",Bt(o[r+4])," ",Bt(o[r+5]));e.closed&&t.push("Z");continue}for(let r=2;r+5<o.length;r+=6)t.push("C",Bt(o[r])," ",Bt(o[r+1])," ",Bt(o[r+2])," ",Bt(o[r+3])," ",Bt(o[r+4])," ",Bt(o[r+5]));e.closed&&t.push("Z")}}return t.join("")}var Sn=n=>n<=0?0:n>=1?1:n,Re=n=>n;function Cn(n){return 1/(1+Math.exp(-n))}function vs(n){let t=Cn(-n/2),e=Cn(n/2);return o=>o<=0?0:o>=1?1:(Cn(n*(o-.5))-t)/(e-t)}var dt=vs(10),ha=n=>{let t=Sn(n);return t*t*t*(t*(t*6-15)+10)},da=n=>n*n,ma=n=>1-(1-n)*(1-n),pa=n=>n*n*n,fa=n=>1-Math.pow(1-n,3),ba=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,ga=n=>1-Math.pow(1-n,5),ya=n=>n<.5?16*n*n*n*n*n:1-Math.pow(-2*n+2,5)/2,wa=n=>n>=1?1:1-Math.pow(2,-10*n),xa=n=>n<=0?0:Math.pow(2,10*n-10),ka=n=>2*dt(n/2),Ma=n=>2*dt(n/2+.5)-1,va=n=>Math.sqrt(Math.max(0,1-(1-n)*(1-n)));function Pa(n=1.70158){return t=>{let e=t-1;return e*e*((n+1)*e+n)+1}}function Oa(n={}){let t=n.bounce??.28,e=n.frequency??2.2,o=-Math.log(Math.max(1e-4,t))*2.4;return r=>r<=0?0:r>=1?1:1-Math.exp(-o*r)*Math.cos(e*Math.PI*2*r)*(1-r)}var Aa=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,Rn=n=>dt(n<.5?2*n:2*(1-n));function Na(n=1/3){let t=(1-n)/2;return e=>e<t?dt(e/t):e<1-t?1:dt((1-e)/t)}function Ko(n=2){return t=>Rn(t)*Math.sin(n*Math.PI*2*t)}function Ca(n=.7,t=dt){return e=>n*t(e)}function Sa(n=.25,t=dt){return e=>t(Sn(e/(1-n)))}function Ra(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 Ta(n,t,e=dt){return o=>e(Sn((o-n)/(t-n)))}function Fa(n,t,e,o){let r=3*n,s=3*(e-n)-r,i=1-r-s,a=3*t,l=3*(o-t)-a,c=1-a-l,u=m=>((i*m+s)*m+r)*m,h=m=>((c*m+l)*m+a)*m,d=m=>(3*i*m+2*s)*m+r;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"}},Ps={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"}},Os={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"}},As={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"}},Ns={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:Ye,paper:Ps,blueprint:Os,chalk:As,neon:Ns};function qe(n){if(n===void 0)return Ye;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 Jo=gs(ys(),1);var Cs=[0,0,0,0],qo=new Map,Qo=Ye.colors;function In(n){Qo=n}function Gt(n){let e=Qo[n]??n,o=qo.get(e);if(o)return o;let r=(0,Jo.default)(e);if(!r)throw new Error(`Unknown color: ${JSON.stringify(n)}. Use a look token such as "blue" or a CSS color.`);let[s,i,a]=r.values;r.type==="hsl"&&([s,i,a]=Ss(s,i,a));let l=[s,i,a,r.alpha];return qo.set(e,l),l}function Ss(n,t,e){let o=t/100*Math.min(e/100,1-e/100),r=s=>{let i=(s+n/30)%12;return 255*(e/100-o*Math.max(-1,Math.min(i-3,9-i,1)))};return[r(0),r(8),r(4)]}function K(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,o=Math.round(n[0]),r=Math.round(n[1]),s=Math.round(n[2]);return e>=1?`rgb(${o},${r},${s})`:`rgba(${o},${r},${s},${Math.round(e*1e3)/1e3})`}function Tn(n){let t=n/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Fn(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 Uo(n){let t=Tn(n[0]),e=Tn(n[1]),o=Tn(n[2]),r=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*o),s=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*o),i=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*o);return[.2104542553*r+.793617785*s-.0040720468*i,1.9779984951*r-2.428592205*s+.4505937099*i,.0259040371*r+.7827717662*s-.808675766*i]}function Rs(n,t){let e=n[0]+.3963377774*n[1]+.2158037573*n[2],o=n[0]-.1055613458*n[1]-.0638541728*n[2],r=n[0]-.0894841775*n[1]-1.291485548*n[2],s=e*e*e,i=o*o*o,a=r*r*r;return[Fn(4.0767416621*s-3.3077115913*i+.2309699292*a),Fn(-1.2684380046*s+2.6097574011*i-.3413193965*a),Fn(-.0041960863*s-.7034186147*i+1.707614701*a),t]}function he(n,t,e){if(e<=0)return n;if(e>=1)return t;let o=Uo(n),r=Uo(t);return Rs([o[0]+(r[0]-o[0])*e,o[1]+(r[1]-o[1])*e,o[2]+(r[2]-o[2])*e],n[3]+(t[3]-n[3])*e)}function tr(n,t,e){if(e<=0)return n;if(e>=1)return t;let o=yt(n),r=yt(t);if(!o&&!r)return he(n,t,e);if(o&&r&&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=o?lt(n.stops,.5):n,i=r?lt(t.stops,.5):t;return he(s,i,e)}function lt(n,t){if(n.length===0)return Cs;if(t<=n[0][0])return n[0][1];for(let e=1;e<n.length;e++)if(t<=n[e][0]){let[o,r]=n[e-1],[s,i]=n[e];return he(r,i,s>o?(t-o)/(s-o):0)}return n[n.length-1][1]}function Ue(n){let t=n.length;return n.map((e,o)=>Array.isArray(e)&&e.length===2&&typeof e[0]=="number"?[e[0],Zo(e[1])]:[t===1?0:o/(t-1),Zo(e)])}function Zo(n){let t=K(n);return yt(t)?lt(t.stops,.5):t}function Ts(n,t,e){return{type:"linear",from:n,to:t,stops:Ue(e)}}function Fs(n,t,e){return{type:"radial",center:n,radius:t,stops:Ue(e)}}function Is(...n){return{type:"along",stops:Ue(n)}}function Te(n,...t){let e=Ue(t);return Array.from({length:n},(o,r)=>lt(e,n===1?0:r/(n-1)))}var C={now:0,mode:"free",frame:0,capture:null},ye=class{constructor(t){this.initial=t}initial;keys=[];sample(t){let e=this.keys,o=0,r=e.length-1,s=-1;for(;o<=r;){let c=o+r>>1;e[c].t0<=t?(s=c,o=c+1):r=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,o=e.length;for(;o>0&&e[o-1].t0>t.t0;)o--;e.splice(o,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 er(n,t){let e=Vt(n);if(e>=t||e===0)return n;let o=[];for(let s=0;s<e;s++){let i=s*6,a=Array.from(n.p.subarray(i,i+8));o.push({pts:a,length:En(a)})}for(;o.length<t;){let s=0;for(let l=1;l<o.length;l++)o[l].length>o[s].length&&(s=l);let[i,a]=Es(o[s].pts);o.splice(s,1,{pts:i,length:En(i)},{pts:a,length:En(a)})}let r=new Float64Array(2+t*6);r[0]=n.p[0],r[1]=n.p[1];for(let s=0;s<t;s++){let i=o[s].pts;for(let a=0;a<6;a++)r[2+s*6+a]=i[2+a]}return{p:r,closed:n.closed}}function En(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 Es(n){let t=(n[0]+n[2])/2,e=(n[1]+n[3])/2,o=(n[2]+n[4])/2,r=(n[3]+n[5])/2,s=(n[4]+n[6])/2,i=(n[5]+n[7])/2,a=(t+o)/2,l=(e+r)/2,c=(o+s)/2,u=(r+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 zs(n,t){let e=Vt(t);if(!n.closed||!t.closed||e<2)return t;let[o,r]=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]-o-(t.p[p*6]-s),b=n.p[m*6+1]-r-(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 nr(n,t,e,o){let r=new Float64Array(2+e*6);for(let s=0;s<r.length;s+=2)r[s]=n,r[s+1]=t;return{p:r,closed:o}}function Vs(n,t){let e=a=>[...a].sort((l,c)=>Math.abs(ce(c))+Se(c)*.01-(Math.abs(ce(l))+Se(l)*.01)),o=e(n),r=e(t),s=[],i=r.slice();for(let a of o){if(i.length===0){let[d,m]=ue(a);s.push([a,nr(d,m,Vt(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([nr(l,c,Vt(a),a.closed),a])}return s}function Ls(n,t,e=12){let o=Vs(n,t),r=[],s=[],i=[];for(let[a,l]of o){let c=Math.max(Vt(a),Vt(l),a.closed&&l.closed?e:1),u=er(a,c),h=er(l,c);if(u.closed&&h.closed)Math.sign(ce(u))!==Math.sign(ce(h))&&ce(u)!==0&&ce(h)!==0&&(h=Nn(h)),h=zs(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=Nn(h))}r.push(u.p),s.push(h.p),i.push(u.closed&&h.closed)}return{from:r,to:s,closed:i}}function Ze(n,t){if(n===t)return()=>t;if(Ot(n)===0&&n.length===0)return o=>o>=1?t:n;let e=Ls(n,t);return o=>{if(o<=0)return n;if(o>=1)return t;let r=new Array(e.from.length);for(let s=0;s<r.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])*o;r[s]={p:l,closed:e.closed[s]}}return r}}function Je(n,t){let e=n.length,o=t.length,r=Array.from({length:e+1},()=>new Uint16Array(o+1));for(let l=e-1;l>=0;l--)for(let c=o-1;c>=0;c--)r[l][c]=n[l]===t[c]?r[l+1][c+1]+1:Math.max(r[l+1][c],r[l][c+1]);let s=[],i=0,a=0;for(;i<e&&a<o;)n[i]===t[a]?s.push([i++,a++]):r[i+1][a]>=r[i][a+1]?i++:a++;return s}var zn={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},$s=new Set(["x","y","rotation","sx","sy","px","py","opacity","z","fillOpacity","strokeOpacity","strokeWidth","dashOffset","trimFrom","trimTo","glow"]);function Bs(n,t,e){if($s.has(n)){let o=t,r=e;return(s=>o+(r-o)*s)}if(n==="fill"||n==="stroke"){let o=t,r=e;return o&&r?(s=>tr(o,r,s)):null}if(n==="glowColor"){let o=t,r=e;return o&&r?(s=>he(o,r,s)):null}if(n==="path"){let o=t,r=e;return o&&r?Ze(o,r):null}return null}var or=1,P=class n{id=or++;parent=null;children=[];data={};label="";base=Object.create(zn);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===C.frame||C.capture!==null))return e.get(t);let o=this.tracks?.get(t);return o?o.sample(C.now):this.base[t]}set(t,e){return C.capture?(this.overlay??=new Map,this.overlay.set(t,e),C.capture.add(this),this):this.mounted?C.mode==="render"?(this.overlay??=new Map,this.overlayFrame!==C.frame&&(this.overlay.clear(),this.overlayFrame=C.frame),this.overlay.set(t,e),this):(this.track(t).step(C.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,o,r,s){let i=C.now;C.now=o;let a=this.get(t);C.now=i;let l=r>o?Bs(t,a,e):null,c={t0:o,t1:r,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,C.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=o=>{t.push(o);for(let r of o.children)e(r)};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=or++,t.parent=null,t.mounted=!1,t.tracks=null,t.overlay=null,t.overlayFrame=-1,t.data={...this.data},t.base=Object.create(zn);for(let e of Object.keys(zn))t.base[e]=this.get(e);return t.children=this.children.map(e=>{let o=e.clone();return o.parent=t,o}),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=ot(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=ot(t,this.localMatrix()),o=null,r=this.get("path");r&&(o=bt(rt(r,e)));let s=this.get("image");if(s&&(o=Ke(o,Ws(e,s.width,s.height))),this.draw){let i=this.draw(C.now),a=i===null?[]:Array.isArray(i)?i:[i];for(let l of a)o=Ke(o,l.boundsFrom(e))}for(let i of this.children)i.get("visible")&&(o=Ke(o,i.boundsFrom(e)));return o}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[o,r]=typeof t=="number"?[t,e??0]:t;return this.set("x",o),this.set("y",r),this}shift(t,e){let[o,r]=typeof t=="number"?[t,e??0]:t;return this.set("x",this.get("x")+o),this.set("y",this.get("y")+r),this}moveTo(t){let e=t instanceof n?t.center:t,[o,r]=this.center,s=this.parent?Wt(this.parent.worldMatrix()):zt,[i,a]=Q(s,o,r),[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,o=ot(e,this.localMatrix()),[r,s]=Q(Wt(o),t[0],t[1]),[i,a]=Q(Wt(e),t[0],t[1]);return this.set("px",r),this.set("py",s),this.set("x",i),this.set("y",a),this}scale(t,e){let[o,r]=typeof t=="number"?[t,t]:t;return this.pivotAt(e??this.center),this.set("sx",this.get("sx")*o),this.set("sy",this.get("sy")*r),this}rotate(t,e){return this.pivotAt(e??this.center),this.set("rotation",this.get("rotation")+t),this}fitTo(t){let e=this.bounds(),o=[];return t.width!==void 0&&e.width>0&&o.push(t.width/e.width),t.height!==void 0&&e.height>0&&o.push(t.height/e.height),o.length?this.scale(Math.min(...o)):this}nextTo(t,e="right",o=28){let[r,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+r*(i.width/2+o+a.width/2),h=c+s*(i.height/2+o+a.height/2);return this.moveTo([u,h])}alignTo(t,e){let o=this.bounds(),r=t instanceof n?t.bounds():{x:t[0],y:t[1],width:0,height:0};return e==="left"?this.shift(r.x-o.x,0):e==="right"?this.shift(r.x+r.width-o.x-o.width,0):e==="top"?this.shift(0,r.y-o.y):this.shift(0,r.y+r.height-o.y-o.height)}arrange(t="right",e=24){let[o,r]=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+o*(l.width/2+e+c.width/2),h=l.y+l.height/2+r*(l.height/2+e+c.height/2);a.moveTo([o===0?l.x+l.width/2:u,r===0?l.y+l.height/2:h])}i=a}return this.moveTo(s)}fill(t,e){return this.set("fill",t===null?null:K(t)),e!==void 0&&this.set("fillOpacity",e),this}stroke(t,e,o){return this.set("stroke",t===null?null:K(t)),e!==void 0&&this.set("strokeWidth",e),o!==void 0&&this.set("strokeOpacity",o),this}color(t){let e=K(t);for(let o of this.all())o.get("stroke")&&o.set("stroke",e),o.get("fill")&&o.set("fill",e),o.get("glowColor")&&!yt(e)&&o.set("glowColor",e);return this}opacity(t){return this.set("opacity",t)}glow(t,e){if(this.set("glow",t),e!==void 0){let o=K(e);this.set("glowColor",yt(o)?null:o)}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 Ws(n,t,e){let o=[Q(n,0,0),Q(n,t,0),Q(n,t,e),Q(n,0,e)],r=o.map(l=>l[0]),s=o.map(l=>l[1]),i=Math.min(...r),a=Math.min(...s);return{x:i,y:a,width:Math.max(...r)-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 o of n.all())o.mounted=!0;if(t>0||!e){let o=n.track("visible");o.initial=!1,e&&o.step(t,!0)}}function Vn(...n){return new P().add(...n)}function At(n){let t=new P;return t.draw=n,t}function Rt(n){return Array.isArray(n)?[...n]:[n]}function on(n,t,e,o){C.now=t,n.schedule({t0:t,t1:e,ease:n.ease??o.ease,stage:o.stage})}function Ln(...n){let t=Math.max(0,...n.map(e=>e.duration));return{label:"par",duration:t,schedule(e){let o=t>0?(e.t1-e.t0)/t:1;for(let r of n)on(r,e.t0,e.t0+r.duration*o,e)}}}function rr(...n){let t=n.reduce((e,o)=>e+o.duration,0);return{label:"seq",duration:t,schedule(e){let o=t>0?(e.t1-e.t0)/t:1,r=e.t0;for(let s of n){let i=r+s.duration*o;on(s,r,i,e),r=i}}}}function Za(n,t={}){let e=t.lag??.15,o=Math.max(0,...n.map(s=>s.duration)),r=n.length===0?0:o*(1+(n.length-1)*e);return{label:"lagged",duration:t.duration??r,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;on(l,u,u+a,s)})}}}function Ja(n,t){return{label:n.label,duration:n.duration+t,ease:n.ease,schedule(e){let o=n.duration+t>0?(e.t1-e.t0)/(n.duration+t):1;on(n,e.t0+t*o,e.t1,e)}}}function Ds(n,t){return{...n,duration:t.duration??n.duration,ease:t.ease??n.ease}}function Qa(n){return{label:"call",duration:0,schedule:()=>n()}}function te(n,t,e){if(!n.mounted){let o=n;for(;o.parent&&o.parent!==e.root;)o=o.parent;e.mountAt(o,t)}for(let o=n;o&&o!==e.root;o=o.parent){let r=C.now;C.now=t;let s=o.get("visible");C.now=r,s||o.track("visible").step(t,!0)}}function jt(n,t){n.track("visible").step(t,!1)}function sr(n,t,e){e<=t||(n.track("visible").step(t,!1),n.track("visible").step(e,!0))}var et=(n,t,e,o)=>{n.track(t).step(o,e)};function Gs(n,t,e){let o=C.now;C.now=e;let r=n.get(t);return C.now=o,r}function js(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 Hs(n,t,e,o,r){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=Gs(n,"strokeWidth",t);et(n,"stroke",js(i),t),et(n,"strokeWidth",r,t),et(n,"strokeOpacity",1,t),et(n,"trimTo",0,t),et(n,"fillOpacity",0,t),n.tween("trimTo",1,t,t+s*.72,o),n.tween("fillOpacity",l,t+s*.42,e,o),n.tween("strokeOpacity",0,t+s*.62,e,o),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,o),i&&(et(n,"fillOpacity",0,t),n.tween("fillOpacity",l,t+s*.5,e,o))}function ir(n,t,e,o){let r=Rt(t),s=Qt(r).length,i=e.lag??o.lag,a=e.duration??(s<=1?o.duration:Math.min(o.duration*2.4,o.duration+s*.035));return{label:n,duration:a,ease:e.ease,schedule(l){for(let d of r)te(d,l.t0,l.stage);let c=Qt(r);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;C.now=p,sr(d,l.t0,p),Hs(d,p,p+h,l.ease,o.outline)}),C.now=l.t0}}}function tl(n,t={}){return ir("draw",n,t,{lag:.04,duration:1.3,outline:2})}function el(n,t={}){return ir("write",n,t,{lag:.22,duration:1.1,outline:1.3})}function nl(n,t={}){let e=Rt(n);return{label:"erase",duration:t.duration??.8,ease:t.ease,schedule(o){let r=Qt(e),s=t.lag??.02,i=(o.t1-o.t0)/(1+Math.max(0,r.length-1)*s);r.forEach((a,l)=>{let c=o.t0+l*s*i;C.now=c;let u=a.get("fill");a.get("stroke")&&a.tween("trimFrom",1,c,c+i,o.ease),u&&a.tween("fillOpacity",0,c,c+i*.7,o.ease)});for(let a of e)jt(a,o.t1)}}}function ol(n,t={}){let e=Rt(n);return{label:"fadeIn",duration:t.duration??.8,ease:t.ease,schedule(o){let r=t.lag!==void 0&&e.length===1&&e[0].children.length>0?e[0].children:e;for(let a of e)te(a,o.t0,o.stage);let s=t.lag??0,i=(o.t1-o.t0)/(1+Math.max(0,r.length-1)*s);r.forEach((a,l)=>{let c=o.t0+l*s*i,u=c+i;C.now=c,sr(a,o.t0,c);let h=a.get("opacity");if(et(a,"opacity",0,c),a.tween("opacity",h,c,u,o.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,o.ease),a.tween("y",m,c,u,o.ease)}t.scale!==void 0&&ar(a,t.scale,c,u,o.ease)}),C.now=o.t0}}}function ar(n,t,e,o,r,s){let i=C.now;C.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,o,r),n.tween("sy",l,e,o,r),C.now=i}function rl(n,t={}){let e=Rt(n);return{label:"fadeOut",duration:t.duration??.6,ease:t.ease,schedule(o){for(let r of e){let s=r.get("opacity");r.tween("opacity",0,o.t0,o.t1,o.ease),t.shift&&(r.tween("x",r.get("x")+t.shift[0],o.t0,o.t1,o.ease),r.tween("y",r.get("y")+t.shift[1],o.t0,o.t1,o.ease)),t.scale!==void 0&&(r.pivotAt(r.center),r.tween("sx",r.get("sx")*t.scale,o.t0,o.t1,o.ease),r.tween("sy",r.get("sy")*t.scale,o.t0,o.t1,o.ease)),jt(r,o.t1),et(r,"opacity",s,o.t1)}}}}function sl(n,t={}){let e=Rt(n);return{label:"grow",duration:t.duration??.9,ease:t.ease,schedule(o){for(let r of e)te(r,o.t0,o.stage),ar(r,.001,o.t0,o.t1,o.ease,t.from)}}}function il(n){let t=Rt(n);return{label:"appear",duration:0,schedule:e=>{for(let o of t)te(o,e.t0,e.stage)}}}function al(n){let t=Rt(n);return{label:"vanish",duration:0,schedule:e=>{for(let o of t)jt(o,e.t0)}}}function de(n,t,e={}){return{label:"to",duration:e.duration??1,ease:e.ease,schedule(o){te(n,o.t0,o.stage);let r=new Set;C.capture=r;try{t(n)}finally{C.capture=null}for(let s of r){let i=s,a=new Map(i.overlay);i.overlay.clear(),_s(i,a,o,e.restore===!0)}}}}function _s(n,t,e,o){let{t0:r,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,r),et(n,"py",d,r),et(n,"x",p,r),et(n,"y",f,r),a.delete("px"),a.delete("py")}C.now=r;for(let[h,d]of a){let m=n.get(h);m!==d&&(o&&l.set(h,m),n.tween(h,d,r,s,i))}for(let[h,d]of l)et(n,h,d,s)}function ll(n,t,e={}){return{...de(n,o=>o.moveTo(t),e),label:"moveTo"}}function cl(n,t,e,o={}){return{...de(n,r=>r.shift(t,e),o),label:"shift"}}function ul(n,t,e={}){return{...de(n,o=>o.scale(t,e.about),e),label:"scale"}}function hl(n,t,e={}){return{...de(n,o=>o.rotate(t,e.about),e),label:"rotate"}}function lr(n,t,e={}){return{...de(n,o=>o.color(t),e),label:"recolor"}}function dl(n,t,e={}){return{...de(n,o=>o.opacity(t),{duration:.6,...e}),label:"fade"}}function ml(n,t,e={}){return{label:"along",duration:e.duration??2,ease:e.ease,schedule(o){te(n,o.t0,o.stage);let r=t instanceof P?rt(t.get("path")??[],t.worldMatrix()):t,s=n.parent?cr(n.parent.worldMatrix()):null,i=c=>{let[u,h]=Pt(r,c);return s?Q(s,u,h):[u,h]},[a,l]=i(1);if(n.track("x").add({t0:o.t0,t1:o.t1,ease:o.ease,to:a,at:c=>i(c)[0]}),n.track("y").add({t0:o.t0,t1:o.t1,ease:o.ease,to:l,at:c=>i(c)[1]}),e.orient){let c=u=>{let[h,d]=ge(r,u);return Math.atan2(d,h)};n.track("rotation").add({t0:o.t0,t1:o.t1,ease:o.ease,to:c(1),at:c})}}}}function cr(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 $n(n,t,e={}){let o=Rt(n);return{label:"warp",duration:e.duration??2,ease:e.ease,schedule(r){for(let s of Qt(o)){te(s,r.t0,r.stage);let i=s.get("path"),a=s.worldMatrix(),l=cr(a),c=i.map(h=>An(h,e.subdivisions??6)),u=Ho(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:r.t0,t1:r.t1,ease:r.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 pl(n,t,e={}){let[o,r]=e.origin??[0,0],s=e.yUp===!1?1:-1,[[i,a],[l,c]]=t;return{...$n(n,(u,h)=>{let d=u-o,m=(h-r)*s,p=i*d+a*m,f=l*d+c*m;return[o+p,r+f*s]},{subdivisions:1,...e}),label:"applyMatrix"}}function Xs(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=Xs(n),o=0,r=!1;for(let s=n;s;s=s.parent)o+=s.get("z"),r||=s.get("fixed");return{path:rt(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")*Kt(t),glow:n.get("glow"),glowColor:n.get("glowColor"),cap:n.get("cap"),dash:n.get("dash"),z:o,fixed:r,key:n.data.key}}function en(n,t,e,o){let r=new P;return r.base.visible=!1,r.base.path=t.path,r.base.cap=t.cap,r.base.z=t.z,r.base.fixed=t.fixed,r.base.fill=t.fill??e.fill,r.base.stroke=t.stroke??e.stroke,r.base.fillOpacity=t.fillOpacity,r.base.strokeOpacity=t.strokeOpacity,r.base.strokeWidth=t.strokeWidth||e.strokeWidth,r.base.glow=t.glow,r.base.glowColor=t.glowColor??e.glowColor,n.root.add(r),r.track("visible").initial=!1,r.track("visible").keys.length=0,et(r,"visible",!0,o.appear??o.t0),r.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:e.path,at:Ze(t.path,e.path)}),t.fill&&e.fill&&r.tween("fill",e.fill,o.t0,o.t1,o.ease),t.stroke&&e.stroke&&r.tween("stroke",e.stroke,o.t0,o.t1,o.ease),r.tween("fillOpacity",e.fillOpacity,o.t0,o.t1,o.ease),r.tween("strokeOpacity",e.strokeOpacity,o.t0,o.t1,o.ease),r.tween("strokeWidth",e.strokeWidth||t.strokeWidth,o.t0,o.t1,o.ease),t.glow!==e.glow&&r.tween("glow",e.glow,o.t0,o.t1,o.ease),et(r,"visible",!1,o.t1),r}function Ks(n,t){let e=Math.max(n.length,t.length),o=[];for(let r=0;r<e;r++)o.push([n[Math.min(n.length-1,Math.floor(r*n.length/e))],t[Math.min(t.length-1,Math.floor(r*t.length/e))]]);return o}function fl(n,t,e={}){let o=Rt(n),r=Rt(t);return{label:"morph",duration:e.duration??1.2,ease:e.ease,schedule(s){ur(r,s);let i=Qt(o).map(nn),a=Qt(r).map(nn);if(i.length===0||a.length===0){for(let h of o)jt(h,s.t0);for(let h of r)te(h,s.t0,s.stage);return}let l=Ks(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})}),hr(o,r,s)}}}function ur(n,t){C.now=t.t0;for(let e of n)t.stage.mountAt(e,t.t0),jt(e,t.t0)}function hr(n,t,e){for(let o of n)jt(o,e.t0);for(let o of t)o.track("visible").step(e.t1,!0);C.now=e.t0}function we(n,t,e={}){return{label:"morphMatching",duration:e.duration??1.4,ease:e.ease,schedule(o){ur([t],o);let r=e.key??(f=>f.data.key),s=Qt(n),i=Qt(t),a=s.map(nn),l=i.map(nn),c=Je(s.map(r),i.map(r)),u=new Set(c.map(([f])=>f)),h=new Set(c.map(([,f])=>f));for(let[f,b]of c)en(o.stage,a[f],l[b],o);let d=o.t1-o.t0,m=e.fadeShift??[0,0],p=(f,b,y)=>rt(f,[1,0,0,1,b,y]);a.forEach((f,b)=>{u.has(b)||en(o.stage,f,{...f,path:p(f.path,m[0],m[1]),fillOpacity:0,strokeOpacity:0},{t0:o.t0,t1:o.t0+d*.55,ease:o.ease})}),l.forEach((f,b)=>{h.has(b)||en(o.stage,{...f,path:p(f.path,-m[0],-m[1]),fillOpacity:0,strokeOpacity:0},f,{t0:o.t0+d*.35,t1:o.t1,ease:o.ease})}),hr([n],[t],o)}}}function bl(n,t={}){let o=Rt(n).map(r=>Ds(de(r,s=>{s.scale(t.scale??1.14),s.color(t.color??"yellow")},{restore:!0}),{ease:t.ease??Rn}));return{...Ln(...o),label:"indicate",duration:t.duration??.9}}function gl(n,t={}){return{label:"shake",duration:t.duration??.8,ease:Ko(t.cycles??3),schedule(e){C.now=e.t0;let[o,r]=n.center;n.pivotAt([o,r]);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 yl(n,t={}){return{label:"circumscribe",duration:t.duration??1.3,ease:t.ease??Re,schedule(e){let o=n.bounds(),r=t.pad??14,s=new P(X(o.x-r,o.y-r,o.width+r*2,o.height+r*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 wl(n,t={}){return{label:"flash",duration:t.duration??.7,ease:t.ease??dt,schedule(e){let o=n instanceof P?n.center:n,r=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 P(le([o[0]+l*r*.35,o[1]+c*r*.35],[o[0]+l*r,o[1]+c*r])).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 xl(n,t={}){return{label:"ripple",duration:t.duration??1,ease:t.ease??dt,schedule(e){let o=n instanceof P?n.center:n,r=new P(Dt(0,0,t.radius??90)).stroke(t.color??"blue",t.width??3).at(o);e.stage.add(r),et(r,"sx",.05,e.t0),et(r,"sy",.05,e.t0),r.tween("sx",1,e.t0,e.t1,e.ease),r.tween("sy",1,e.t0,e.t1,e.ease),r.tween("strokeOpacity",0,e.t0+(e.t1-e.t0)*.2,e.t1,e.ease),jt(r,e.t1)}}}function Bn(n,t={}){return{label:"pulse",duration:t.duration??1.1,ease:t.ease??dt,schedule(e){let o=n.get("path");if(!o)return;let r=new P(rt(o,n.worldMatrix())).stroke(t.color??"yellow",t.width??n.get("strokeWidth")+1.5).glow(t.glow??10);e.stage.add(r);let s=t.length??.18;et(r,"trimFrom",0,e.t0),et(r,"trimTo",0,e.t0),r.track("trimTo").add({t0:e.t0,t1:e.t1,ease:e.ease,to:1,at:i=>Math.min(1,i*(1+s))}),r.track("trimFrom").add({t0:e.t0,t1:e.t1,ease:e.ease,to:1,at:i=>Math.max(0,i*(1+s)-s)}),jt(r,e.t1)}}}var pt=class{track;constructor(t){this.track=new ye(t)}get value(){return this.track.sample(C.now)}set(t){return this.track.step(C.now,t),this}to(t,e={}){let o=this.track;return{label:"value",duration:e.duration??1,ease:e.ease,schedule(r){let s=o.sample(r.t0);o.add({t0:r.t0,t1:r.t1,ease:r.ease,to:t,at:i=>s+(t-s)*i})}}}};var Ys=()=>C.now,qs=14,Us=96;function dr(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*Kt(t)}:n}function Zs(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 mr=new WeakMap;function Js(n,t,e){let o=mr.get(n);if(o&&o.path===t&&Zs(o.matrix,e))return o.world;let r=rt(t,e);return mr.set(n,{path:t,matrix:e,world:r}),r}function Qs(n,t,e,o,r){let s=n.get("fill"),i=n.get("stroke"),a=s?o*n.get("fillOpacity"):0,l=i?o*n.get("strokeOpacity"):0,c=n.get("glow");if(a<=.002&&l<=.002&&c<=0)return;let u=Js(n,t,e),h=Kt(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?dr(s,e):null,fillAlpha:a,stroke:l>.002?dr(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"?ti(b,b.stroke,r):r.push(b)}function ti(n,t,e){e.push({...n,stroke:null,strokeAlpha:0});let o={...n,fill:null,fillAlpha:0,glow:0},r=Ot(n.strokePath),s=Ot(n.path);if(r===0)return;let i=s>0?Math.min(1,r/s):1,a=Math.min(Us,Math.max(2,Math.ceil(r/qs))),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({...o,strokePath:d,path:d,stroke:lt(t.stops,(c+.5)/a*i),cap:c===0||c===a-1?n.cap:"butt"})}}function Dn(n,t,e,o,r){if(!n.get("visible"))return;let s=n.get("opacity")*o;if(s<=.002)return;let i=n.get("fixed")?e:t,a=ot(i,n.localMatrix()),l=n.get("path");l&&l.length>0&&Qs(n,l,a,s,r);let c=n.get("image");if(c&&r.push({kind:"image",image:c,matrix:a,alpha:s}),n.rawOps&&n.rawOps(a,s,r),n.draw){let m=n.draw(Ys());if(m){let p=Array.isArray(m)?m:[m];for(let f of p)Dn(f,a,e,s,r)}}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)Dn(m,a,e,s,r)}function Gn(n,t,e,o){let r=[1,0,0,1,e/2,o/2],s=ot(r,fe(0,0,-t.rotation,t.zoom,t.zoom,t.x,t.y)),i=[];return Dn(n,s,r,1,i),i}var pr=7;function wr(n,t){let e=[];for(let o=pr;o>=1;o--){let r=o/pr;e.push({width:t+n*2*r,alpha:.16*(1-r)*(1-r)+.018})}return e}function xr(n){if(n.glowColor)return n.glowColor;let t=n.stroke??n.fill;return t?yt(t)?lt(t.stops,.5):t:null}var fr=new WeakMap;function rn(n){let t=fr.get(n);return t===void 0&&(t=Xo(n),fr.set(n,t)),t}function ft(n){return String(Math.round(n*1e3)/1e3)}function ei(n,t){let e=t.stops.map(([o,r])=>`<stop offset="${ft(o)}" stop-color="${Yt([r[0],r[1],r[2],1])}"${r[3]<1?` stop-opacity="${ft(r[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 br(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 ni(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}function jn(n,t={}){let e=t.scale??1,o=n.width,r=n.height,s=[],i=[],a=0,l=(u,h,d)=>{if(yt(u)){let f=`g${a++}`;return s.push(ei(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="${o}" height="${r}" fill="${n.background}"/>`);for(let u of n.ops){if(u.kind==="image"){let d=u.matrix;i.push(`<image href="${ni(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=xr(u),m=rn(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=wr(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="${rn(u.path)}" ${l(u.fill,"fill",u.fillAlpha)} ${l(u.stroke,"stroke",u.strokeAlpha)} stroke-width="${ft(u.strokeWidth)}"${br(u)}${h}/>`);continue}u.fill&&i.push(`<path d="${rn(u.path)}" ${l(u.fill,"fill",u.fillAlpha)}${h}/>`),u.stroke&&u.strokePath.length&&i.push(`<path d="${rn(u.strokePath)}" fill="none" ${l(u.stroke,"stroke",u.strokeAlpha)} stroke-width="${ft(u.strokeWidth)}"${br(u)}${h}/>`)}let c=s.length?`<defs>${s.join("")}</defs>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${o*e}" height="${r*e}" viewBox="0 0 ${o} ${r}">${c}${i.join("")}</svg>`}var gr=new WeakMap;function Wn(n){let t=gr.get(n);if(t)return t;t=new Path2D;for(let e of n){let o=e.p;if(!(o.length<2)){if(t.moveTo(o[0],o[1]),e.straight)for(let r=2;r+5<o.length;r+=6)t.lineTo(o[r+4],o[r+5]);else for(let r=2;r+5<o.length;r+=6)t.bezierCurveTo(o[r],o[r+1],o[r+2],o[r+3],o[r+4],o[r+5]);e.closed&&t.closePath()}}return gr.set(n,t),t}function yr(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[o,r]of t.stops)e.addColorStop(o,Yt(r));return e}var oi={normal:"source-over",screen:"screen",multiply:"multiply",overlay:"overlay"};function Hn(n,t,e=1,o){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 r of t.ops){if(r.kind==="image"){let s=o?.(r.image);if(!s)continue;let i=r.matrix;n.save(),n.transform(i[0],i[1],i[2],i[3],i[4],i[5]),n.globalAlpha=r.alpha,n.drawImage(s,0,0,r.image.width,r.image.height),n.restore();continue}if(n.globalCompositeOperation=oi[r.blend],r.glow>0){let s=xr(r);if(s){let i=Math.max(r.fillAlpha,r.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=Wn(r.strokePath.length?r.strokePath:r.path);for(let c of wr(r.glow,r.stroke?r.strokeWidth:0))n.globalAlpha=c.alpha*i,n.lineWidth=c.width,n.stroke(l);n.globalCompositeOperation=a}}r.fill&&(n.globalAlpha=r.fillAlpha,n.fillStyle=yr(n,r.fill),n.fill(Wn(r.path))),r.stroke&&r.strokePath.length&&(n.globalAlpha=r.strokeAlpha,n.strokeStyle=yr(n,r.stroke),n.lineWidth=r.strokeWidth,n.lineCap=r.cap,n.lineJoin=r.join,n.setLineDash(r.dash?[...r.dash]:[]),n.lineDashOffset=r.dashOffset,n.stroke(Wn(r.strokePath)))}n.globalAlpha=1,n.globalCompositeOperation="source-over"}function ri(n){let t=null;for(let e of n.ops){if(e.kind!=="path")continue;let o=bt(e.path);if(!o)continue;let r=e.stroke?e.strokeWidth/2:0,s={x:o.x-r,y:o.y-r,width:o.width+r*2,height:o.height+r*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 si={"16:9":[1920,1080],"9:16":[1080,1920],"1:1":[1080,1080],"4:3":[1440,1080],"21:9":[2520,1080]},sn=class{root=new P;camera=new P;width;height;fps;look;chapters=[];clips=[];captions=[];updaters=[];time=0;ending=0;constructor(t){let[e,o]=si[t.aspect??"16:9"];this.width=t.width??e,this.height=t.height??o,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){C.now=this.time;for(let o of[t,...e])o.mounted?o.get("visible")||o.track("visible").step(this.time,!0):(o.parent?.drop(o),o.parent=this.root,this.root.children.push(o),tn(o,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),o=t.find(l=>!("schedule"in l))??{};if(e.length===0)return this;let r=Math.max(...e.map(l=>l.duration)),s=o.duration??r,i=this.time,a=i+s;for(let l of e){C.now=i;let c=o.duration!==void 0?a:i+l.duration;l.schedule({t0:i,t1:c,ease:o.ease??l.ease??dt,stage:this})}return this.clips.push({t0:i,t1:a,labels:o.label?[o.label]:e.map(l=>l.label)}),this.time=a,this.ending=Math.max(this.ending,a),C.now=a,this}wait(t=1){return this.time+=t,this.ending=Math.max(this.ending,this.time),C.now=this.time,this}at(t,e){let o=this.time;return this.time=t,C.now=t,e(),this.ending=Math.max(this.ending,this.time),this.time=o,C.now=o,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,o={}){return this.updaters.push({node:t,fn:e,from:o.from??this.time,to:o.to??1/0}),t}get duration(){return Math.max(this.ending,this.time)}};function ii(n,t){let e=typeof n=="function"?{}:n,o=typeof n=="function"?n:t;if(!o)throw new Error("film(options, build) needs a build function.");let r={kind:"vizmatic.film",options:e,build:o,compile:s=>ln(r,s)};return r}function Fe(n){return!!n&&typeof n=="object"&&n.kind==="vizmatic.film"}var Nt=class{constructor(t){this.promise=t}promise;isVizmaticSuspend=!0};function _n(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,o){this.stage=t,this.width=t.width,this.height=t.height,this.fps=o.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=o.bloom??e.bloom??t.look.bloom;let r=o.background!==void 0?o.background:e.background!==void 0?e.background:t.look.background;this.background=r===null?null:t.look.colors[r]??r,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)),o=this.stage,r={mode:C.mode,now:C.now};In(o.look.colors),C.mode="render",C.now=e,C.frame++;try{for(let a of o.updaters)e>=a.from&&e<=a.to&&a.fn(a.node,e);let s=o.camera,i=Gn(o.root,{x:s.get("x"),y:s.get("y"),zoom:s.get("sx"),rotation:s.get("rotation")},o.width,o.height);return{width:o.width,height:o.height,background:this.background,bloom:this.bloom,dark:o.look.dark,ops:i}}finally{C.mode=r.mode,C.now=r.now}}svg(t,e={}){return jn(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 o=0;o<64;o++){let r=new sn(e);In(r.look.colors);let s={mode:C.mode,now:C.now};C.mode="compile",C.now=0;try{await n.build(r),C.mode=s.mode,C.now=s.now;let i=new an(r,e,t);return await ai(i),i}catch(i){if(C.mode=s.mode,C.now=s.now,C.capture=null,i instanceof Nt){await i.promise;continue}throw i}}throw new Error("The film kept requesting new assets while compiling.")}async function ai(n){let t=[0,.25,.5,.75,1];for(let e of t)for(let o=0;o<16;o++)try{n.frame(n.duration*e);break}catch(r){if(!(r instanceof Nt))throw r;await r.promise}}function kr(n){return{contours:n.filter(t=>t.length>=8)}}var Mr=null;function Xn(n){Mr=n}var li=typeof process<"u"&&!!process.versions?.node&&typeof globalThis.document>"u";function vr(){let n=import.meta.url;return n||`file://${typeof __filename<"u"?__filename:""}`}async function ci(n){let t="node:fs/promises",e="node:path",o="node:url",[r,s,i]=await Promise.all([import(t),import(e),import(o)]),a=s.dirname(i.fileURLToPath(vr()));for(let l=0;l<6;l++){let c=s.join(a,"assets",n);try{let u=await r.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 Pr(n){if(li)return ci(n);let t=Mr??new URL("./assets/",vr()).href,e=await fetch(new URL(n,t)),o=e.headers.get("content-type")??"";if(!e.ok||o.includes("text/html"))throw new Error(`Could not load ${n} from ${e.url} (HTTP ${e.status}, ${o||"no content type"}). Call setAssetBase() with the folder that holds fonts/.`);return e.arrayBuffer()}var Yn=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 Rr(n){let t=new Yn(n),e=t.u32();if(e!==65536&&e!==1953658213)throw new Error("Stage text needs a TrueType (.ttf) font with glyf outlines.");let o=t.u16();t.seek(12);let r=new Map;for(let O=0;O<o;O++){let A=t.tag();t.u32(),r.set(A,{offset:t.u32(),length:t.u32()})}let s=O=>{let A=r.get(O);if(!A)throw new Error(`Font is missing its ${O} 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=hi(t,s("cmap").offset),w=r.has("GPOS")?di(t,r.get("GPOS").offset):()=>0,x=O=>{let A=Math.min(O,m-1);return t.seek(f.offset+A*4),t.u16()},k=new Map,M=(O,A)=>{if(O>=p||A>6)return[];t.seek(b.offset+(l?O*4:O*2));let R=l?t.u32():t.u16()*2,E=l?t.u32():t.u16()*2;if(R===E)return[];t.seek(y.offset+R);let $=t.i16();if(t.seek(t.position+8),$<0)return v(O,A);let z=[];for(let S=0;S<$;S++)z.push(t.u16());let D=t.u16();t.seek(t.position+D);let B=(z[z.length-1]??-1)+1,G=[];for(;G.length<B;){let S=t.u8();if(G.push(S),S&8){let L=t.u8();for(;L-- >0;)G.push(S)}}let U=new Array(B),N=0;for(let S=0;S<B;S++){let L=G[S];if(L&2){let j=t.u8();N+=L&16?j:-j}else L&16||(N+=t.i16());U[S]=N}let V=new Array(B),F=0;for(let S=0;S<B;S++){let L=G[S];if(L&4){let j=t.u8();F+=L&32?j:-j}else L&32||(F+=t.i16());V[S]=F}let T=[],I=0;for(let S of z)T.push(ui(U,V,G,I,S)),I=S+1;return T};function v(O,A){let R=[],E=!0;for(;E;){let z=t.u16(),D=t.u16(),B=(z&1)!==0,G=(z&2)!==0,U=0,N=0;B?(U=t.i16(),N=t.i16()):(U=t.i8(),N=t.i8()),G||(U=0,N=0);let V=1,F=0,T=0,I=1,S=()=>t.i16()/16384;z&8?V=I=S():z&64?(V=S(),I=S()):z&128&&(V=S(),F=S(),T=S(),I=S()),R.push({glyph:D,m:[V,F,T,I,U,N]}),E=(z&32)!==0}let $=[];for(let z of R)for(let D of M(z.glyph,A+1)){let B=new Array(D.length),[G,U,N,V,F,T]=z.m;for(let I=0;I<D.length;I+=2)B[I]=G*D[I]+N*D[I+1]+F,B[I+1]=U*D[I]+V*D[I+1]+T;$.push(B)}return $}return{unitsPerEm:a,ascent:u,descent:h,lineGap:d,glyphFor(O){return g(O)},advance:x,kern(O,A){return w(O,A)},outline(O){if(k.has(O))return k.get(O);let A=M(O,0),R=A.length?kr(A):null;return k.set(O,R),R}}}function ui(n,t,e,o,r){let s=r-o+1;if(s<2)return[];let i=w=>o+(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 hi(n,t){n.seek(t+2);let e=n.u16(),o=-1,r=-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>r&&(r=u,o=t+c)}if(o<0)return()=>0;n.seek(o);let s=n.u16();if(s===12){n.seek(o+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(o+6);let i=n.u16(),a=i/2,l=o+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 di(n,t){let e=[];try{n.seek(t+6);let r=t+n.u16(),s=t+n.u16();n.seek(r);let i=n.u16(),a=new Set;for(let l=0;l<i;l++){n.seek(r+2+l*6);let c=n.tag(),u=n.u16();if(c!=="kern")continue;n.seek(r+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 o=new Map;return(r,s)=>{let i=r*65536+s,a=o.get(i);if(a!==void 0)return a;let l=0;for(let c of e)for(let u of c){let h=u(r,s);if(h!==void 0){l+=h;break}}return o.set(i,l),l}}function mi(n,t){n.seek(t);let e=n.u16(),o=new Set;if(e===1){let r=n.u16();for(let s=0;s<r;s++)o.add(n.u16())}else if(e===2){let r=n.u16();for(let s=0;s<r;s++){let i=n.u16(),a=n.u16();n.u16();for(let l=i;l<=a;l++)o.add(l)}}return o}function Or(n,t){n.seek(t);let e=n.u16(),o=new Map;if(e===1){let r=n.u16(),s=n.u16();for(let i=0;i<s;i++)o.set(r+i,n.u16())}else if(e===2){let r=n.u16();for(let s=0;s<r;s++){let i=n.u16(),a=n.u16(),l=n.u16();for(let c=i;c<=a;c++)o.set(c,l)}}return r=>o.get(r)??0}function Ar(n){let t=0;for(let e=0;e<8;e++)n&1<<e&&t++;return t*2}function Nr(n,t){let e=0;t&1&&n.i16(),t&2&&n.i16(),t&4&&(e=n.i16()),t&8&&n.i16();for(let o=4;o<8;o++)t&1<<o&&n.u16();return e}function pi(n,t){n.seek(t);let e=n.u16(),o=n.u16(),r=n.u16(),s=n.u16(),i=Ar(r),a=Ar(s);if(e===1){let l=n.u16(),c=[];for(let m=0;m<l;m++)c.push(n.u16());n.seek(t+o);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=Nr(n,r);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=mi(n,t+o),p=Or(n,t+l),f=Or(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)),Nr(n,r)}}return()=>{}}var fi={sans:{400:"Inter-Regular.ttf",600:"Inter-SemiBold.ttf",700:"Inter-Bold.ttf"},serif:{400:"InstrumentSerif-Regular.ttf",italic:"InstrumentSerif-Italic.ttf"},mono:{400:"JetBrainsMono-Regular.ttf"},noto:{400:"NotoSans-Regular.ttf"}},Cr=new Map,Kn=new Map;function Ie(n,t=400,e=!1){let o=fi[n],r=(e?o.italic:void 0)??o[String(t)]??o[400],s=Cr.get(r);if(s)return s;let i=Kn.get(r);throw i||(i=Pr(`fonts/${r}`).then(a=>{Cr.set(r,Rr(a)),Kn.delete(r)}),Kn.set(r,i)),new Nt(i)}var Sr=new WeakMap;function Ee(n,t,e){let o=Sr.get(n);o||Sr.set(n,o=new Map);let r=o.get(e);r||o.set(e,r=new Map);let s=r.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 r.set(t,l),l}var cn=class extends P{chars=[];source="";find(t){let e=[],o=this.chars.map(s=>s.data.key).join(""),r=t.replace(/\s/g,"");for(let s=o.indexOf(r);s>=0;s=o.indexOf(r,s+1))e.push(...this.chars.slice(s,s+r.length));return e}};function bi(n){let t=bt(n);if(!t)return{path:n,x:0,y:0};let e=t.x+t.width/2,o=t.y+t.height/2;return{path:rt(n,[1,0,0,1,-e,-o]),x:e,y:o}}function _(n,t={}){let e=t.size??40,o=Ie(t.font??"sans",t.weight??400,t.italic??!1),r=e/o.unitsPerEm,s=(t.tracking??0)*e,i=(t.leading??1.3)*e,a=K(t.color??"ink"),l=t.uppercase?n.toUpperCase():n,c=y=>{let g=[],w=0,x=0;for(let k of y){let M=k.codePointAt(0),v=o.glyphFor(M);x&&(w+=o.kern(x,v)*r),g.push({code:M,glyph:v,x:w,char:k}),w+=o.advance(v)*r+s,x=v}return{glyphs:g,width:w}},u=[],h=o.advance(o.glyphFor(32))*r+s;for(let y of l.split(`
|
|
2
|
+
`)){let g=[],w=0;for(let x of y.split(" ")){let k=c(x),M=g.length>0?h:0;t.maxWidth!==void 0&&g.length>0&&w+M+k.width>t.maxWidth&&(u.push({glyphs:g,width:w}),g=[],w=0);let v=w+(g.length>0?h:0);for(let O of k.glyphs)g.push({...O,x:O.x+v});w=v+k.width}u.push({glyphs:g,width:w})}let d=Math.max(0,...u.map(y=>y.width)),m=t.align??"left",p=new cn;p.source=n,u.forEach((y,g)=>{let w=m==="left"?0:m==="center"?(d-y.width)/2:d-y.width;for(let x of y.glyphs){let k=Ee(o,x.glyph,e);if(k.length===0)continue;let M=bi(k),v=new P(M.path).at(w+x.x+M.x,g*i+M.y);v.base.fill=a,v.base.trimEach=!0,v.data.key=x.char,p.chars.push(v),p.children.push(v),v.parent=p}});let f=o.ascent*r,b=(u.length-1)*i;return p.base.px=d/2,p.base.py=b/2-f*.36,p.data.size=e,p}var un=class extends P{glyphs=[];source="";part(t){let e=Ir(t),o=this.glyphs.map(r=>r.data.key);for(let r=0;r+e.length<=o.length;r++)if(e.every((s,i)=>s===o[r+i]))return this.glyphs.slice(r,r+e.length);return[]}parts(t){let e=Ir(t),o=this.glyphs.map(s=>s.data.key),r=[];for(let s=0;s+e.length<=o.length;s++)e.every((i,a)=>i===o[s+a])&&(r.push(this.glyphs.slice(s,s+e.length)),s+=e.length-1);return r}},qn=null,Tr=null,Fr=new Map;function gi(){if(qn)return qn;throw Tr??=import("./math-4WFNHVV2.js").then(n=>{qn=(t,e)=>n.renderMathSvg(t,{fontSize:1e3,display:e,color:"#000000"}).svg}),new Nt(Tr)}function Er(n,t){let e=`${t?"D":"I"}${n}`,o=Fr.get(e);if(o)return o;let r=gi()(n,t),s=[],i=[],a=[1,0,0,1,0,0],l=/viewBox="([^"]+)"/.exec(r)?.[1]?.trim().split(/[ ,]+/).map(Number)??[0,0,1e3,1e3],u=Number(/\swidth="([\d.]+)px"/.exec(r)?.[1]??1e3)/l[2]/1e3,h=/<(\/?)([a-zA-Z]+)((?:\s+[-\w:]+="[^"]*")*)\s*(\/?)>/g,d=0,m=null,p=[];for(let b=h.exec(r);b;b=h.exec(r)){let[,y,g,w="",x]=b,k=O=>new RegExp(`\\s${O}="([^"]*)"`).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 O=(k("viewBox")??"0 0 1 1").trim().split(/[ ,]+/).map(Number),A=Number(k("width")??O[2]),R=Number(k("height")??O[3]),E=ot([A/(O[2]||1),0,0,R/(O[3]||1),Number(k("x")??0),Number(k("y")??0)],[1,0,0,1,-O[0],-O[1]]);i.push(a),p.push(m),a=ot(a,E),m=[O[0],O[1],O[0]+O[2],O[1]+O[3]]}continue}if(y){g==="g"&&(a=i.pop()??a);continue}let M=k("transform"),v=M?wi(M):[1,0,0,1,0,0];if(g==="g"){x||(i.push(a),a=ot(a,v));continue}if(g==="path"){let O=k("d");if(!O)continue;let A=k("data-c"),R=rt(vt(O),v);s.push({path:rt(m?yi(R,m):R,a),key:A?String.fromCodePoint(parseInt(A,16)):"?"})}else if(g==="rect"){let O=Number(k("x")??0),A=Number(k("y")??0),R=Number(k("width")??0),E=Number(k("height")??0);R>0&&E>0&&s.push({path:rt(X(O,A,R,E),ot(a,v)),key:"rule"})}}let f=s.map(b=>({key:b.key,path:rt(b.path,[u,0,0,u,0,0])}));return Fr.set(e,f),f}function yi(n,t){return n.map(e=>{let o=new Float64Array(e.p.length);for(let r=0;r<o.length;r+=2)o[r]=Math.max(t[0],Math.min(t[2],e.p[r])),o[r+1]=Math.max(t[1],Math.min(t[3],e.p[r+1]));return{p:o,closed:e.closed}})}function wi(n){let t=[1,0,0,1,0,0];for(let e of n.matchAll(/(translate|scale|matrix)\(([^)]*)\)/g)){let o=e[2].trim().split(/[ ,]+/).map(Number);e[1]==="translate"?t=ot(t,[1,0,0,1,o[0]??0,o[1]??0]):e[1]==="scale"?t=ot(t,[o[0]??1,0,0,o[1]??o[0]??1,0,0]):o.length===6&&(t=ot(t,o))}return t}function Ir(n){return Er(n,!1).map(t=>t.key)}function st(n,t={}){let e=t.size??56,o=t.display??!0,r=Er(n,o),s=K(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 r){let d=rt(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 P(rt(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 o=t.fill!==void 0?t.fill:e.fill,r=t.stroke!==void 0?t.stroke:e.stroke;return o&&n.fill(o),r&&n.stroke(r,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 xi(n,t={}){return Tt(new P(n),t,{stroke:"ink"})}function Ql(n,t={}){return xi(vt(n),t)}function Y(n,t,e={}){return Tt(new P(le(n,t)),e,{stroke:"ink"})}function tc(n,t={}){return Tt(new P(Z(n,t.closed)),t,{stroke:"ink"})}function ec(n,t={}){return Tt(new P(t.closed?Lt(n,!0):be(n)),t,{stroke:"ink"})}function nc(n,t,e,o={}){return Tt(new P(_e(n,t,e,o.samples??96)),o,{stroke:"ink"})}function zr(n,t={}){return Tt(new P(Dt(0,0,n)),t,{stroke:"ink"})}function oc(n,t,e={}){return Tt(new P(St(0,0,n,t,0,Math.PI*2)),e,{stroke:"ink"})}function rc(n,t,e,o={}){return Tt(new P(St(0,0,n,n,t,e)),o,{stroke:"ink"})}function Vr(n,t,e={}){return Tt(new P(X(-n/2,-t/2,n,t,e.radius??0)),e,{stroke:"ink"})}function ki(n,t={}){return Tt(new P(Z(n,!0)),t,{stroke:"ink"})}function sc(n,t,e={}){let o=[];for(let r=0;r<n;r++){let s=-Math.PI/2+r/n*Math.PI*2;o.push([Math.cos(s)*t,Math.sin(s)*t])}return ki(o,e)}function gt(n=9,t="ink",e={}){return Tt(new P(Dt(0,0,n)),e,{fill:t})}function ze(n,t,e={}){let o=e.stroke??"ink",r=e.width??3,s=e.tip??Math.max(13,r*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 P,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,O=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 P(O).stroke(o,r);e.dash&&A.dash(e.dash);let R=p*i/2,E=($,z,D,B)=>new P(Z([[$,z],[$-D*p-B*R,z-B*p+D*R],[$-D*p+B*R,z-B*p-D*R]],!0)).fill(o);return f.add(A,E(d[0],d[1],w,x)),e.both&&f.add(E(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 Lr(n,t,e={}){let o=t[0]-n[0],r=t[1]-n[1],s=Math.hypot(o,r)||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=o/s,m=r/s,p=rt(vt(h),[d,m,-m,d,n[0],n[1]]),f=Tt(new P(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 Un=class extends P{xRange;yRange;plotWidth;plotHeight;lines=new P;grid=new P;numbers=new P;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",o=t.xStep??$r(this.xRange[1]-this.xRange[0]),r=t.yStep??$r(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 xe(this.xRange,o))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 xe(this.yRange,r))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?ze(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 xe(this.xRange,o)){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 xe(this.yRange,r)){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 xe(this.xRange,o)){if(f===s)continue;let[b,y]=this.p(f,i);this.numbers.add(st(Br(f),{size:p,color:"dim",display:!1}).moveTo([b,y+26]))}for(let f of xe(this.yRange,r)){if(f===i)continue;let[b,y]=this.p(s,f);this.numbers.add(st(Br(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[o,r]=this.xRange,[s,i]=this.yRange;return[((t-o)/(r-o)-.5)*this.plotWidth,(.5-(e-s)/(i-s))*this.plotHeight]}world(t,e){let[o,r]=this.p(t,e);return this.toWorld(o,r)}plotPath(t,e={}){let o=e.from??this.xRange[0],r=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=o+(r-o)*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 o=new P(this.plotPath(t,e)).stroke(e.stroke??"blue",e.width??4);return e.glow&&o.glow(e.glow),e.dash&&o.dash(e.dash),this.add(o),o}dotAt(t,e,o="yellow",r=9){let s=gt(r,o).at(this.p(t,e));return this.add(s),s}guides(t,e,o={}){let r=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],...o}),Y(this.p(r,e),this.p(t,e),{stroke:"dim",width:2,dash:[6,7],...o}));return this.add(i),i}};function dc(n={}){return new Un(n)}function hn(n,t){return Math.max(t[0],Math.min(t[1],n))}function $r(n){let t=n/8,e=Math.pow(10,Math.floor(Math.log10(t))),o=t/e;return(o<1.5?1:o<3.5?2:o<7.5?5:10)*e}function xe(n,t){let e=[],o=Math.ceil(n[0]/t-1e-9)*t;for(let r=o;r<=n[1]+1e-9;r+=t)e.push(Math.round(r/t)*t);return e}function Br(n){let t=Math.round(n*1e3)/1e3;return String(t)}var Ve=class extends P{unit;major=new P;minor=new P;axes=new P;constructor(t={}){super(),this.unit=t.unit??120;let[e,o]=t.x??[-12,12],[r,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 P(u(f,b,w)).stroke(y,g))};for(let p=e;p<=o;p++){if(c>0&&p<o)for(let f=1;f<c;f++){let b=p+f/c;d(this.minor,[b*i,r*i],[b*i,s*i],"grid",1,h)}p!==0&&d(this.major,[p*i,r*i],[p*i,s*i],a,l,h)}for(let p=r;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],[o*i,b*i],"grid",1,h)}p!==0&&d(this.major,[e*i,p*i],[o*i,p*i],a,l,h)}let m=t.axisColor??"ink";d(this.axes,[e*i,0],[o*i,0],m,2.6,h),d(this.axes,[0,r*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,o={}){return ze([0,0],this.p(t,e),{stroke:"yellow",width:5,tip:22,...o})}};function mc(n={}){return new Ve(n)}function pc(n,t={}){let e=new P;return e.draw=()=>{let o=n(),r=(t.prefix??"")+o.toFixed(t.digits??2)+(t.suffix??"");return _(r,{size:t.size??36,color:t.color??"ink",font:t.font??"mono"})},e}var dn=1,Wr=.08,Mi=.15,vi=.12,Pi=.12,Oi=5,Dr=12,Gr=6,Ai=2,Ni=2,Ci=1.6,jr=.9;function Hr(n){return yt(n)?lt(n.stops,.5):n}function _r(n){let t=e=>{let o=e/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)};return .2126*t(n[0])+.7152*t(n[1])+.0722*t(n[2])}function Si(n,t,e){let o=n[3]*t,r=[n[0]*o+e[0]*(1-o),n[1]*o+e[1]*(1-o),n[2]*o+e[2]*(1-o),1],s=_r(r),i=_r(e);return(Math.max(s,i)+.05)/(Math.min(s,i)+.05)}function Xr(n,t){return{x:n.x-t,y:n.y-t,width:n.width+t*2,height:n.height+t*2}}function Ri(n,t){let e=n.width*t,o=n.height*t;return{x:n.x+e,y:n.y+o,width:n.width-e*2,height:n.height-o*2}}function Le(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 Ti(n,t){let e=Math.max(n.x,t.x),o=Math.max(n.y,t.y),r=Math.min(n.x+n.width,t.x+t.width),s=Math.min(n.y+n.height,t.y+t.height);return r>e&&s>o?{x:e,y:o,width:r-e,height:s-o}:null}function Fi(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),o=Math.min(n.y,t.y);return{x:e,y:o,width:Math.max(n.x+n.width,t.x+t.width)-e,height:Math.max(n.y+n.height,t.y+t.height)-o}}function Ii(n,t,e,o,r){let s=0,i=1,a=e-n,l=o-t,c=[[-a,n-r.x],[a,r.x+r.width-n],[-l,t-r.y],[l,r.y+r.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 Ei(n,t){for(let e of n){let o=e.p;for(let r=0;r+7<o.length;r+=6){let s=o[r],i=o[r+1],a=o[r+2],l=o[r+3],c=o[r+4],u=o[r+5],h=o[r+6],d=o[r+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<=Gr;w++){let x=w/Gr,k=1-x,M=k*k*k,v=3*k*k*x,O=3*k*x*x,A=x*x*x,R=M*s+v*a+O*c+A*h,E=M*i+v*l+O*u+A*d;if(Ii(y,g,R,E,t))return!0;y=R,g=E}}}return!1}function zi(n){return n.data.key!==void 0?n.parent:null}function Vi(n){return!!n.node&&n.node.data.key!==void 0}function Kr(n){let t=n.source;return typeof t=="string"?t:""}function Li(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 $i(n,t){let e=new Set,o=n.clips,r=i=>o.some(a=>a.t0<i&&i<a.t1),s=.001;for(let i of o){let a=i.t1+s;a<n.duration&&!r(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<Oi)for(let i=0;i<Dr;i++){let a=(i+.5)/Dr*n.duration;r(a)||e.add(a)}return[...e].sort((i,a)=>i-a)}function Yr(n,t){try{return n.frame(t)}catch(e){if(!_n(e))throw e;return e.promise.then(()=>Yr(n,t))}}function Bi(n,t){let e=n.stage.camera,o=e.tracks?.get("sx");return o?o.sample(t):e.base.sx}function Wi(n,t,e,o){let r=[],{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=Vi(g);if(Math.max(g.fillAlpha,g.strokeAlpha)<Wr)return;let M=bt(g.path);if(!M)return;let v=g.stroke?Xr(M,g.strokeWidth/2):M,O=x?zi(g.node):null,A=v.x<-dn||v.y<-dn||v.x+v.width>s+dn||v.y+v.height>i+dn,R=v.x<=0&&v.x+v.width>=s||v.y<=0&&v.y+v.height>=i;if(A&&(x||!R&&!e&&!o)){let E=Le(v,c),$=O?Kr(O):void 0,z=x?`text:${$}`:"marks",D=m.get(z),B=x&&E&&!e?"error":"warning";D?(D.box=mn(D.box,v),x||(p+=1)):(x||(p=1),m.set(z,{key:`film.off_canvas:${z}`,code:"film.off_canvas",severity:B,time:t,box:v,message:x?`Text ${JSON.stringify($??"")} runs off the canvas${E?" and is clipped":""}.`:"",...$?{text:$}:{}}))}if(x&&O&&g.fillAlpha>=Mi){let E=u.get(O);E||u.set(O,E={id:O,source:Kr(O),bounds:M,glyphs:[]}),E.bounds=mn(E.bounds,M),E.glyphs.push({box:M,order:w})}else if(!x&&(g.fill&&g.fillAlpha>=jr&&Hr(g.fill)[3]>=jr&&g.path.some(E=>E.closed)&&h.push({order:w,bounds:M}),g.stroke&&g.strokeAlpha>=Wr&&g.strokePath.length>0)){let E=Si(Hr(g.stroke),g.strokeAlpha,l);E>=Ci&&d.push({op:g,order:w,contrast:E})}});let f=m.get("marks");f&&(f.message=`${p===1?"A mark extends":`${p} marks extend`} past the ${s}x${i} canvas.`),r.push(...m.values());let b=(g,w,x)=>h.some(k=>k.order>g&&k.order<w&&Fi(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(!Le(w.bounds,k.bounds))continue;let M=null;for(let v of w.glyphs)if(Le(v.box,k.bounds))for(let O of k.glyphs){let A=Ti(v.box,O.box);if(!A)continue;let R=Math.min(v.box.width*v.box.height,O.box.width*O.box.height);R<=0||A.width*A.height/R<vi||b(Math.min(v.order,O.order),Math.max(v.order,O.order),v.order<O.order?v.box:O.box)||(M=M?mn(M,A):A)}M&&r.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||!Le(Xr(M,w.strokeWidth),g.bounds))continue;let v=null;for(let O of g.glyphs){let A=Ri(O.box,Pi);Le(M,A)&&Ei(w.strokePath,A)&&(x<O.order&&b(x,O.order,O.box)||(v=v?mn(v,O.box):O.box))}if(v){let O=w.strokeWidth>=Ai&&k>=Ni;r.push({key:`film.text_crossed:${g.source}:${Li(w.node)}`,code:"film.text_crossed",severity:O?"error":"warning",time:t,box:v,message:`A stroke crosses text ${JSON.stringify(g.source)}.`,text:g.source})}}return r}async function Di(n,t={}){let e=Fe(n)?await n.compile(t):n,o=t.times?[...t.times]:$i(e,t.samples??0),r=new Map;for(let l of o){let c=await Yr(e,l);for(let{key:u,...h}of Wi(c,l,Bi(e,l)!==1,e.bleed)){let d=r.get(u);d?(d.until=l,h.severity==="error"&&(d.severity="error")):r.set(u,{...h,until:l,stage:{x:0,y:0}})}}let s=l=>Math.round(l*100)/100,i=[...r.values()].map(l=>({...l,time:Math.round(l.time*1e3)/1e3,until:Math.round(l.until*1e3)/1e3,box:{x:s(l.box.x),y:s(l.box.y),width:s(l.box.width),height:s(l.box.height)},stage:{x:s(l.box.x+l.box.width/2-e.width/2),y:s(l.box.y+l.box.height/2-e.height/2)}})).sort((l,c)=>l.severity===c.severity?l.time-c.time:l.severity==="error"?-1:1),a=i.filter(l=>l.severity==="error").length;return{ok:a===0,width:e.width,height:e.height,duration:e.duration,sampled:o.map(l=>Math.round(l*1e3)/1e3),diagnostics:i,summary:{errors:a,warnings:i.length-a}}}function it(n,t,e){n.mounted||(C.now=t,e.add(n));for(let o=n;o&&o!==e.root;o=o.parent)me(o,"visible",t)||o.track("visible").step(t,!0)}function me(n,t,e){let o=C.now;C.now=e;let r=n.get(t);return C.now=o,r}function W(n,t,e,o){n.track(t).step(o,e)}function wt(n,t,e,o,r){let s=n.track.sample(e);n.track.add({t0:e,t1:o,ease:r,to:t,at:i=>s+(t-s)*i})}function $t(n,t,e,o){if(n===0)return[];let r=(o-e)/(1+(n-1)*t);return Array.from({length:n},(s,i)=>{let a=e+i*t*r;return[a,a+r]})}function Zn(n,t){return typeof n!="string"?n:t.math?st(n,{size:t.size,color:t.color??"ink",display:!1}):_(n,{size:t.size,color:t.color??"ink",font:t.font??"sans",weight:t.weight??400})}function qr(n){let t=e=>{let o=e/255;return o<=.04045?o/12.92:Math.pow((o+.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 $e(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 Ht(n,t,e){let o=[],r=Math.ceil(n/e-1e-9)*e;for(let s=r;s<=t+e*1e-6;s+=e)o.push(Math.round(s/e)*e);return o}function pn(n,t,e=5){let r=(t-n||1)/Math.max(1,e),s=Math.pow(10,Math.floor(Math.log10(r))),i=r/s,a=(i<1.5?1:i<3.5?2:i<7.5?5:10)*s;return{ticks:Ht(n,t,a),step:a}}function Be(n,t){if(t!==void 0&&t<1){let o=Math.min(4,Math.ceil(-Math.log10(t)-1e-9));return n.toFixed(o)}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 o=1;o<n.length;o++){let r=n[o-1],s=n[o],i=2+(o-1)*6;e[i]=r[0]+(s[0]-r[0])/3,e[i+1]=r[1]+(s[1]-r[1])/3,e[i+2]=r[0]+(s[0]-r[0])*2/3,e[i+3]=r[1]+(s[1]-r[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,Jn=class extends P{range;length;line;ticks=new P;numbers=new P;constructor(t={}){super(),this.range=t.range??[-5,5],this.length=t.length??1200;let e=t.color??"dim",o=t.width??2,r=this.length/2,s=t.tips??!0;this.line=s?ze([-r-36,0],[r+36,0],{stroke:e,width:o,tip:14,both:!0}):Y([-r,0],[r,0],{stroke:e,width:o});let i=t.step??1;for(let a of Ht(this.range[0],this.range[1],i)){let[l]=this.p(a);if(this.ticks.add(Y([l,-7],[l,7],{stroke:e,width:o})),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,o]=this.range;return[((t-e)/(o-e)-.5)*this.length,0]}world(t){let[e,o]=this.p(t);return this.toWorld(e,o)}marker(t,e={}){let o=e.color??"yellow",r=e.labelSize??28,s=()=>{let[a]=this.p(ee(t)),l=[gt(e.radius??9,o).at(a,0)];return e.label&&l.push(st(e.label,{size:r,color:o,display:!1}).at(a,-r*1.15)),l},i=typeof t=="function"?At(s):new P().add(...s());return this.add(i),i}interval(t,e,o={}){let r=o.color??"blue",s=o.offset??0,[i]=this.p(t),[a]=this.p(e),l=Y([i,s],[a,s],{stroke:r,width:o.width??7}),c=(h,d)=>d?gt(9,"bg").stroke(r,4).at(h,s):gt(9,r).at(h,s),u=new P().add(l,c(i,o.openLeft),c(a,o.openRight));return this.add(u),u}};function Vc(n={}){return new Jn(n)}var Qn=class extends Ve{numbers=new P;constructor(t={}){super(t);let e=t.labelRange??3,o=t.labelSize??22;for(let r=-e;r<=e;r++){if(r===0)continue;let s=st(String(r),{size:o,color:"ink",display:!1});s.set("py",-o*.25),this.numbers.add(s.at(r*this.unit,22));let i=r===1?"i":r===-1?"-i":`${r}i`,a=st(i,{size:o,color:"ink",display:!1});a.set("py",-o*.25),this.numbers.add(a.at(-o*.9,-r*this.unit))}this.add(this.numbers)}z(t,e){return this.p(t,e)}};function Lc(n={}){return new Qn(n)}function $c(n,t,e={}){let o=Wt(n.worldMatrix()),r=n.worldMatrix(),s=n.unit;return{...$n([n.minor,n.major,n.axes],(a,l)=>{let[c,u]=Q(o,a,l),[h,d]=t(c/s,-u/s);return Q(r,h*s,-d*s)},{duration:3,...e}),label:"applyComplex"}}var Bc={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),o=Math.atan2(n[1],n[0])*t;return[e*Math.cos(o),e*Math.sin(o)]},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 Gi(n,t,e,o,r){let s=Math.hypot(e,o)||1e-6,i=e/s,a=o/s,l=Math.min(s*.42,r*5.2),c=r/2,u=l*.42,h=n+e-i*l,d=t+o-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+o],[h-m*u,d-p*u],[h-m*c,d-p*c],[n-m*c,t-p*c]],!0)[0]}var to=class extends P{constructor(e,o={}){super();this.f=e;let r=this.unit=o.unit??120,[s,i]=o.x??[-8,8],[a,l]=o.y??[-4.5,4.5],c=o.step??.5,u=o.maxLength??c*r*.92,h=o.width??2.6,d=(o.colors??["blue","teal","green","yellow","orange","red"]).map(y=>K(y)),m=d.map((y,g)=>[d.length===1?0:g/(d.length-1),y]),p=[];for(let y of Ht(a,l,c))for(let g of Ht(s,i,c))p.push([g,y]);let f=o.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),O=u*(.22+.78*(1-Math.exp(-2.2*M/f))),A=x/M*O,R=-(k/M)*O,E=y*r,$=-g*r;return{ring:Gi(E-A/2,$-R/2,A,R,h),at:v,cx:E,cy:$}};if(o.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 P(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=Jr([w.ring]).fill(lt(m,w.at));this.arrows.push(x),this.add(x)}}f;unit;arrows=[]};function Jr(n){let t=bt(n);if(!t)return new P(n);let e=t.x+t.width/2,o=t.y+t.height/2,r=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]-o;return{p:i,closed:s.closed}});return new P(r).at(e,o)}function Wc(n,t={}){return new to(n,t)}var eo=class extends P{lineCount;constructor(t,e={}){super();let o=e.unit??120,[r,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=$e(e.seed??7),f=(e.colors??["blue","teal","green","yellow","orange","red"]).map(R=>K(R)),b=f.map((R,E)=>[f.length===1?0:E/(f.length-1),R]),y=[],g=[],w=.6;for(let R=i;R<=a;R+=l)for(let E=r;E<=s;E+=l){let $=E+(p()-.5)*l,z=R+(p()-.5)*l,D=p(),B=[[$*o,-z*o]],G=0;for(let N=0;N<u;N++){let[V,F]=t($,z,0),[T,I]=t($+V*c/2,z+F*c/2,0),[S,L]=t($+T*c/2,z+I*c/2,0),[j,J]=t($+S*c,z+L*c,0),at=(V+2*T+2*S+j)/6,tt=(F+2*I+2*L+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,$<r-w||$>s+w||z<i-w||z>a+w))break;N%2===1&&B.push([$*o,-z*o])}if(B.length<5)continue;let U=G/(B.length*2);g.push(U),y.push({points:B,phase:D,speedRate:.8+p()*.4,color:U})}let x=[...g].sort((R,E)=>R-E),k=e.max??(x[Math.floor(x.length*.92)]||1),M=8;for(let R of y)R.color=Math.min(M-1,Math.floor(Math.min(1,R.color/k)*M));this.lineCount=y.length;let v=6,O=e.trace??0,A=Array.from({length:M},()=>[]);if(O>0)for(let R of y)A[R.color].push(pe(R.points));this.draw=R=>{let E=Array.from({length:M*v},()=>[]);for(let z of y){let D=z.points.length,B=Math.max(3,Math.floor(D*m)),G=D+B,U=(R*d*z.speedRate+z.phase)%1*G;for(let N=0;N<v;N++){let V=Math.floor(U-B*(1-N/v)),F=Math.floor(U-B*(1-(N+1)/v)),T=Math.max(0,V),I=Math.min(D-1,F);I-T<1||E[z.color*v+N].push(pe(z.points.slice(T,I+1)))}}let $=[];return O>0&&A.forEach((z,D)=>{z.length&&$.push(new P(z).stroke(lt(b,(D+.5)/M),h*.6).set("strokeOpacity",O))}),E.forEach((z,D)=>{if(z.length===0)return;let B=Math.floor(D/v),G=D%v,U=new P(z).stroke(lt(b,(B+.5)/M),h);U.set("strokeOpacity",Math.pow((G+1)/v,1.6)),G<v-1&&U.set("cap","butt"),$.push(U)}),$}}};function Dc(n,t={}){return new eo(n,t)}function Gc(n,t,e={}){let o=e.from??n.xRange[0],r=e.to??n.xRange[1],s=e.n??12,i=e.rule??"mid",a=Te(s,...e.colors??["blue","teal","green"]),l=new P,c=(r-o)/s;for(let u=0;u<s;u++){let h=o+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=Jr(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 Ur(n,t,e,o,r){let s=[];for(let i=0;i<=r;i++){let a=e+(o-e)*i/r;s.push(n.p(a,t(a)))}return s.push(n.p(o,0),n.p(e,0)),Z(s,!0)}function jc(n,t,e={}){let o=e.samples??96,r=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 P(Ur(n,t,c,u,o)).fill(r,s)}):new P(Ur(n,t,i,a,o)).fill(r,s);return n.add(l),l}function ji(n,t,e){let r=(n.xRange[1]-n.xRange[0])*1e-4,s=n.p(e-r,t(e-r)),i=n.p(e+r,t(e+r)),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 Hc(n,t,e,o={}){let r=o.length??420,s=o.stroke??"yellow",i=()=>{let{point:l,ux:c,uy:u}=ji(n,t,ee(e)),h=[Y([l[0]-c*r/2,l[1]-u*r/2],[l[0]+c*r/2,l[1]+u*r/2],{stroke:s,width:o.width??3.5,glow:o.glow,dash:o.dash})];return(o.point??!0)&&h.push(gt(8,s).at(l)),h},a=typeof e=="function"?At(i):new P().add(...i());return n.add(a),a}function _c(n,t,e,o,r={}){let s=r.extend??140,i=r.stroke??"yellow",a=()=>{let c=ee(e),u=ee(o),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:r.width??3.5,glow:r.glow})];if(r.legs){let y=[d[0],h[1]],g=r.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(r.points??!0)&&b.push(gt(8,i).at(h),gt(8,i).at(d)),b},l=typeof e=="function"||typeof o=="function"?At(a):new P().add(...a());return n.add(l),l}function Xc(n,t,e,o={}){let r=()=>{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],...o};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(r):new P().add(...r());return n.add(s),s}function Kc(n,t,e,o={}){let r=o.radius??54,s=o.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;o.reflex&&(a+=a>0?-Math.PI*2:Math.PI*2);let l=new P;if(o.fillOpacity){let c=[n];for(let u=0;u<=24;u++){let h=i+a*u/24;c.push([n[0]+Math.cos(h)*r,n[1]+Math.sin(h)*r])}l.add(new P(Z(c,!0)).fill(s,o.fillOpacity))}if(l.add(new P(St(n[0],n[1],r,r,i,i+a)).stroke(s,o.width??3)),o.label){let c=o.labelSize??30,u=i+a/2,h=r+c*.72;l.add(st(o.label,{size:c,color:s,display:!1}).at(n[0]+Math.cos(u)*h,n[1]+Math.sin(u)*h))}return l}function Yc(n,t,e,o={}){let r=o.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 P(Z([[n[0]+i*r,n[1]+a*r],[n[0]+(i+l)*r,n[1]+(a+c)*r],[n[0]+l*r,n[1]+c*r]])).stroke(o.color??"ink",o.width??2.5)}var Hi={"[":["[","]"],"(":["(",")"],"|":["|","|"]},no=class extends P{cells;entries=new P;brackets=new P;rowCount;colCount;positions;options;constructor(t,e={}){super(),this.options=e;let o=e.size??52,r=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:o,color:r,display:!1});return k.set("py",-o*.25),k})),i=Array.from({length:this.colCount},(w,x)=>Math.max(0,...s.map(k=>k[x]?.width??0))),a=(e.gapX??.85)*o,l=(e.gapY??1.32)*o,c=i.reduce((w,x)=>w+x,0)+a*Math.max(0,this.colCount-1),u=l*Math.max(0,this.rowCount-1)+o,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=Hi[e.bracket??"["],f=`\\rule{0pt}{${((u+o*.5)/o/2+.25).toFixed(3)}em}`,b=o*.42,y=st(`\\left${m[0]}${f}\\right.`,{size:o,color:e.bracketColor??r}),g=st(`\\left.${f}\\right${m[1]}`,{size:o,color:e.bracketColor??r});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 o=this.cells[t]?.[e];if(!o)throw new Error(`Matrix has no cell (${t}, ${e}). It is ${this.rowCount} by ${this.colCount}.`);return o}row(t){return[...this.cells[t]??[]]}col(t){return this.cells.map(e=>e[t]).filter(Boolean)}setCell(t,e,o,r={}){let s=this.options.size??52,i=st(String(o),{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,...r});return{...u,schedule(h){c.entries.add(i),i.track("visible").initial=!1,c.cells[t][e]=i,u.schedule(h)}}}};function qc(n,t={}){return new no(n,t)}function Qr(n){let t=Array.isArray(n)?n:[n],e=1/0,o=1/0,r=-1/0,s=-1/0;for(let i of t){let a=i.bounds();e=Math.min(e,a.x),o=Math.min(o,a.y),r=Math.max(r,a.x+a.width),s=Math.max(s,a.y+a.height)}return{x:e,y:o,width:r-e,height:s-o}}function Uc(n,t,e={}){let o=Qr(n),r=e.side??"bottom",s=e.gap??12,i=e.color??"ink",a=e.size??34,l=o.x,c=o.x+o.width,u=o.y,h=o.y+o.height,[d,m]=r==="bottom"?[[l,h+s],[c,h+s]]:r==="top"?[[c,u-s],[l,u-s]]:r==="left"?[[l-s,u],[l-s,h]]:[[c+s,h],[c+s,u]],p=Lr(d,m,{stroke:i,depth:e.depth}),f=p.data.tip,b=Zn(t,{size:a,color:i,math:!e.plain});b.moveTo(f);let y=Qe(r),g=10+(y[0]!==0?b.width/2:b.height/2);return b.shift(y[0]*g,y[1]*g),new P().add(p,b)}function Zc(n,t={}){let e=Qr(n),o=t.pad??12,r=Vr(e.width+o*2,e.height+o*2,{radius:t.radius??8,stroke:t.color??"yellow",width:t.width??2.5,glow:t.glow});return t.fill&&r.fill(t.fill,t.fillOpacity??.14),r.at(e.x+e.width/2,e.y+e.height/2)}var oo=class extends P{mark;caption;constructor(t,e={}){super();let o=e.color??"yellow";this.mark=gt(e.radius??9,o),this.caption=Zn(t,{size:e.size??30,color:e.labelColor??o,math:!e.plain}),this.add(this.mark,this.caption),this.caption.nextTo(this.mark,e.side??[.72,-.72],e.gap??8)}};function Jc(n,t={}){return new oo(n,t)}function Qc(n,t,e,o={}){let r=o.color??"yellow",s=o.width??3,i=o.rate??60,a=o.fade??(o.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=C.now;C.now=t+h/i;let p=n();return C.now=m,C.mode==="render"&&c.set(h,p),p};return At(h=>{if(h<=t)return null;let d=Math.min(h,e),m=o.tail!==void 0?Math.max(t,d-o.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=C.now;C.now=d,b.push(n()),C.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 P([pe(b.slice(x,k+1))]).stroke(r,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"),o.glow&&M.glow(o.glow),g.push(M)}return g})}function tu(n,t={}){let e=n.length,o=[];for(let r=0;r<e;r++){let s=r<=e/2?r:r-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}o.push({freq:s,amp:Math.hypot(i,a)/e,phase:Math.atan2(a,i)})}return o.sort((r,s)=>s.amp-r.amp||r.freq-s.freq),t.terms?o.slice(0,t.terms):o}function Zr(n,t){let e=0,o=0;for(let r of n){let s=2*Math.PI*r.freq*t+r.phase;e+=r.amp*Math.cos(s),o+=r.amp*Math.sin(s)}return[e,o]}function eu(n,t){return Ot(n)===0?[]:Array.from({length:t},(o,r)=>Pt(n,r/t))}var ro=class extends P{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 o=e.samples??1024;this.outlinePoints=Array.from({length:o+1},(h,d)=>Zr(this.terms,d/o));let r=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,O=p+k.amp*Math.cos(v),A=f+k.amp*Math.sin(v);M<r&&k.freq!==0&&k.amp>.4&&y[Math.min(3,Math.floor(M/Math.max(1,r)*4))].push(...Dt(p,f,k.amp)),p=O,f=A,M<r&&b.push([p,f])}),y.forEach((k,M)=>{k.length&&m.push(new P(k).stroke(s,1.2).set("strokeOpacity",[.55,.36,.22,.14][M]))}),b.length>=2&&m.push(new P([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 P([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 O=new P([pe(this.outlinePoints.slice(M,v+1))]).stroke(a,l);O.set("strokeOpacity",Math.pow((k+1)/u,1.5)),k<u-1&&O.set("cap","butt"),m.push(O)}return h<1&&m.push(gt(5,a).at(p,f)),m}}outline(){return Z(this.outlinePoints.slice(0,-1),!0)}point(t){return Zr(this.terms,t)}};function nu(n,t){return new ro(n,t)}function ou(n,t=200){return _e(n,0,1,t).map(o=>Mt(o.p,!0))}var oe=["blue","yellow","teal","orange","purple","green","pink","red"];function It(n,t,e="dim",o="sans"){return _(n,{size:t,color:e,font:o})}var io=class extends P{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 o=e.labelSize??20,r=Math.max(1,t.length);this.band=(this.horizontal?this.h:this.w)/r;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=>Be(Math.round(d*100)/100)),a=e.color??"faint",[l,c]=this.place(0,0,"start"),[u,h]=this.place(r-1,0,"end");this.baseline=Y([l,c],[u,h],{stroke:a,width:1.5}),t.forEach((d,m)=>{let p=d.color??oe[m%oe.length],f=new P(this.barPath(m,d.value)).fill(p,.84);this.bars.push(f);let b=It(d.label,o);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+o/2),e.showValues??!0){let w=At(()=>{let x=this.values[m].value,[k,M]=this.tip(m,x),v=It(i(x),o,"ink","mono");return this.horizontal?v.at(k+12+v.width/2,M):v.at(k,M+(x>=0?-1:1)*(10+o*.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,o){let r=(t+.5)*this.band,s=this.band/2,i=o==="mid"?r:o==="start"?r-s:r+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[o,r]=this.place(t,0,"mid"),s=this.lengthOf(e);return this.horizontal?[o+s,r]:[o,r-s]}barPath(t,e){let[o,r]=this.place(t,0,"mid"),s=this.band*(1-this.gap),i=this.lengthOf(e);return this.horizontal?X(o,r-s/2,i,s):X(o-s/2,r-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:o=>{it(this,o.t0,o.stage);let r=o.t1-o.t0;W(this.baseline,"trimTo",0,o.t0),this.baseline.tween("trimTo",1,o.t0,o.t0+r*.4,o.ease);let s=$t(this.bars.length,e,o.t0+r*.1,o.t1);this.bars.forEach((i,a)=>{let[l,c]=s[a],u=this.values[a].track.sample(o.t0);this.values[a].track.step(o.t0,0),wt(this.values[a],u,l,c,o.ease),i.track("path").step(o.t0,this.barPath(a,0)),i.track("path").add({t0:l,t1:c,ease:o.ease,to:this.barPath(a,u),at:m=>this.barPath(a,u*m)});let h=this.labels[a];W(h,"opacity",0,o.t0),h.tween("opacity",1,l,l+(c-l)*.6,o.ease);let d=this.readouts[a];d&&(W(d,"opacity",0,o.t0),d.tween("opacity",1,l,l+(c-l)*.5,o.ease))})}}}update(t,e={}){return{label:"barChart.update",duration:e.duration??1.1,ease:e.ease,schedule:o=>{let r=this.values.map(c=>c.track.sample(o.t0)),s=this.maxValue.track.sample(o.t0),i=this.minValue.track.sample(o.t0),a=this.fixedMax??Math.max(0,...t),l=this.fixedMin??Math.min(0,...t);wt(this.maxValue,a,o.t0,o.t1,o.ease),wt(this.minValue,l,o.t0,o.t1,o.ease),t.forEach((c,u)=>{wt(this.values[u],c,o.t0,o.t1,o.ease);let h=this.bars[u];if(!h)return;let d=m=>this.barPathAt(u,r[u]+(c-r[u])*m,s+(a-s)*m,i+(l-i)*m);h.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:d(1),at:d})})}}}barPathAt(t,e,o,r){let s=o-r||1,i=(t+.5)*this.band,a=this.band*(1-this.gap);if(this.horizontal){let u=-r/s*this.w-this.w/2;return X(u,i-this.h/2-a/2,e/s*this.w,a)}let l=this.h/2- -r/s*this.h,c=e/s*this.h;return X(i-this.w/2-a/2,l-c,a,c)}};function du(n,t={}){return new io(n,t)}var ao=class extends P{shown;bins;range;chartWidth;chartHeight;axis=new P;total;assigned;peak;constructor(t,e={}){super(),this.chartWidth=e.width??900,this.chartHeight=e.height??480,this.bins=e.bins??24;let o=e.range?.[0]??Math.min(...t),r=e.range?.[1]??Math.max(...t);this.range=[o,r],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-o)/(r-o||1)*this.bins));this.assigned[y]=b<o||b>r?-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(o,r,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(Be(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=X(-a/2+k*g+g*p/2,l/2-M,g*(1-p),M);d.length===1?w.push(...v):x.push(new P(v).fill(lt(m,k/Math.max(1,this.bins-1))))}return w.length&&x.push(new P(w).fill(d[0])),x});this.add(f,this.axis)}xAt(t){let[e,o]=this.range;return((t-e)/(o-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,o=t.count??this.total;return{label:"histogram.fill",duration:t.duration??3,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage),e.track.keys.length===0&&(e.track.initial=0),wt(e,o,r.t0,r.t1,r.ease)}}}curve(t,e={}){let[o,r]=this.range,s=e.samples??120,i=[];for(let l=0;l<=s;l++){let c=o+(r-o)*l/s;i.push(this.p(c,t(c)))}let a=new P(Lt(i)).stroke(e.color??"yellow",e.width??4);return this.add(a),a}};function mu(n,t={}){return new ao(n,t)}function ne(n,t,e){let{xRange:o,yRange:r,w:s,h:i}=n;return[((t-o[0])/(o[1]-o[0]||1)-.5)*s,(.5-(e-r[0])/(r[1]-r[0]||1))*i]}function ts(n,t){let e=new P,o=t.labelSize,r=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):Be(c,l.step),o);e.add(h.at(-s/2-12-h.width/2,u))}e.add(Y([-s/2,i/2],[s/2,i/2],{stroke:r,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:r,width:1.5})),e.add(It(t.xFormat?t.xFormat(c):Be(c,a.step),o).at(u,i/2+12+o*.6))}if(t.xLabel){let c=It(t.xLabel,o,"ink");e.add(c.at(s/2-c.width/2,i/2+18+o*1.6))}if(t.yLabel){let c=It(t.yLabel,o,"ink");e.add(c.at(-s/2+c.width/2,-i/2-12-o/2))}return e}var lo=class extends P{dots=[];axis;groupLabels=[];frame;constructor(t,e={}){super();let o=t.map(h=>h.x),r=t.map(h=>h.y),s=(h,d)=>(d-h||1)*.06,i=e.x??[Math.min(...o)-s(Math.min(...o),Math.max(...o)),Math.max(...o)+s(Math.min(...o),Math.max(...o))],a=e.y??[Math.min(...r)-s(Math.min(...r),Math.max(...r)),Math.max(...r)+s(Math.min(...r),Math.max(...r))];this.frame={xRange:i,yRange:a,w:e.width??900,h:e.height??520};let l=e.labelSize??18;this.axis=ts(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??oe[c.size%oe.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:o=>{it(this,o.t0,o.stage);let r=o.t1-o.t0;W(this.axis,"opacity",0,o.t0),this.axis.tween("opacity",1,o.t0,o.t0+r*.3,o.ease);let s=[...this.dots].sort((a,l)=>a.get("x")-l.get("x")),i=$t(s.length,e,o.t0+r*.15,o.t1);s.forEach((a,l)=>{let[c,u]=i[l],h=a.get("sx");W(a,"sx",.001,o.t0),W(a,"sy",.001,o.t0),a.tween("sx",h,c,u,o.ease),a.tween("sy",h,c,u,o.ease)});for(let a of this.groupLabels)W(a,"opacity",0,o.t0),a.tween("opacity",1,o.t0+r*.7,o.t1,o.ease)}}}fit(t,e={}){let[o,r]=this.frame.xRange,s=e.samples??60,i=[];for(let l=0;l<=s;l++){let c=o+(r-o)*l/s;i.push(this.p(c,t(c)))}let a=new P(Lt(i)).stroke(e.color??"yellow",e.width??3.5);return this.add(a),a}};function pu(n,t={}){return new lo(n,t)}var co=class extends P{lines=[];areas=[];names=[];axis;byName=new Map;frame;constructor(t,e={}){super();let o=t.map(b=>b.points??(b.values??[]).map((y,g)=>[g,y])),r=o.flat().map(b=>b[0]),s=o.flat().map(b=>b[1]),i=Math.min(...s),a=Math.max(...s),l=(a-i||1)*.08,c=e.x??[Math.min(...r),Math.max(...r)],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=ts(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??oe[y%oe.length],w=o[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),O=new P(v).fill(g,b.area);this.areas.push(O),this.add(O)}let x=b.smooth===!1?Z(w):Lt(w),k=new P(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:o=>{it(this,o.t0,o.stage);let r=o.t1-o.t0;W(this.axis,"opacity",0,o.t0),this.axis.tween("opacity",1,o.t0,o.t0+r*.3,o.ease);let s=$t(this.lines.length,e,o.t0+r*.15,o.t1);this.lines.forEach((i,a)=>{let[l,c]=s[a];W(i,"trimTo",0,o.t0),i.tween("trimTo",1,l,c,o.ease);let u=this.names[a];u&&(W(u,"opacity",0,o.t0),u.tween("opacity",1,c-(c-l)*.2,Math.min(o.t1,c+r*.1),o.ease))});for(let i of this.areas){let a=i.get("fillOpacity");W(i,"fillOpacity",0,o.t0),i.tween("fillOpacity",a,o.t0+r*.5,o.t1,o.ease)}}}}};function fu(n,t={}){return new co(n,t)}function so(n,t,e,o){if(t-n<1e-4)return[];let r=St(0,0,o,o,n,t)[0].p,s=Array.from(r),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],r[0],r[1])}else l(i,a,0,0),l(0,0,r[0],r[1]);return[Mt(s,!0)]}var fn=class extends P{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 o=t.reduce((i,a)=>i+Math.max(0,a.value),0)||1;this.shares=t.map(i=>Math.max(0,i.value)/o);let r=e.labelSize??20,s=this.angles(this.shares);if(t.forEach((i,a)=>{let l=i.color??oe[a%oe.length],[c,u]=s[a],h=new P(so(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 P(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,r,"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=_(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 o=-Math.PI/2;return t.map(r=>{let s=r*Math.PI*2*e,i=Math.min(this.gap*e,s*.45),a=[o+i/2,o+s-i/2];return o+=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 o=e.t1-e.t0,r=e.t0+o*.78;this.wedges.forEach((s,i)=>{let a=l=>{let[c,u]=this.angles(this.shares,l)[i];return so(c,u,this.inner,this.outer)};s.track("path").step(e.t0,[]),s.track("path").add({t0:e.t0,t1:r,ease:e.ease,to:a(1),at:a})});for(let s of[...this.labels,...this.leaders,...this.centerText?[this.centerText]:[]])W(s,"opacity",0,e.t0),s.tween("opacity",1,e.t0+o*.62,e.t1,e.ease)}}}update(t,e={}){return{label:"pie.update",duration:e.duration??1.1,ease:e.ease,schedule:o=>{let r=t.reduce((a,l)=>a+Math.max(0,l),0)||1,s=t.map(a=>Math.max(0,a)/r),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 so(d,m,this.inner,this.outer)};a.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:c(1),at:c})});for(let a of[...this.labels,...this.leaders])a.tween("opacity",0,o.t0,o.t0+(o.t1-o.t0)*.3,o.ease);s.forEach((a,l)=>{this.shares[l]=a})}}}};function bu(n,t={}){return new fn(n,t)}function gu(n,t={}){return new fn(n,{hole:.62,...t})}var We=class extends P{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 o=e.cellWidth??e.cell??44,r=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*o+(this.colCount-1)*s,c=this.rowCount*r+(this.rowCount-1)*s,u=e.labelSize??16,h=e.valueSize??Math.min(r*.38,o*.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*(o+s)+o/2,x=-c/2+p*(r+s)+r/2,k=this.colorFor(y),M=new P(X(-o/2,-r/2,o,r,e.radius??0)).fill(k).at(w,x);if(f.push(M),this.add(M),e.values){let v=_(d(y),{size:h,font:"mono",color:qr(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*(r+s)+r/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*(o+s)+o/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,o]=this.domain;return lt(this.stops,Math.max(0,Math.min(1,(t-e)/(o-e||1))))}cell(t,e){let o=this.cells[t]?.[e];if(!o)throw new Error(`Heatmap has no cell (${t}, ${e}). It is ${this.rowCount} by ${this.colCount}.`);return o}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 o=e.t1-e.t0,r=this.rowCount+this.colCount-1,s=o*.5,i=r>1?(o-s)/(r-1):0;this.cells.forEach((a,l)=>a.forEach((c,u)=>{let h=e.t0+(l+u)*i;W(c,"opacity",0,e.t0),c.tween("opacity",1,h,h+s,e.ease);let d=this.numbers[l]?.[u];d&&(W(d,"opacity",0,e.t0),d.tween("opacity",1,h,h+s,e.ease))}));for(let a of[...this.rowLabels,...this.columnLabels])W(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0,e.t0+o*.4,e.ease)}}}update(t,e={}){return{label:"heatmap.update",duration:e.duration??1,ease:e.ease,schedule:o=>{t.forEach((r,s)=>r.forEach((i,a)=>{let l=this.cells[s]?.[a];l&&l.tween("fill",this.colorFor(i),o.t0,o.t1,o.ease)}))}}}};function yu(n,t={}){return new We(n,t)}var uo=null,es=null;function _i(){if(uo)return uo;throw es??=import("./dagre.esm-N2NIVIAZ.js").then(n=>{uo=n.default??n}),new Nt(es)}var mo=class extends P{shape;caption=null;halfWidth=0;halfHeight=0;round=!0;edgePoint(t,e,o,r,s=0){let i=o-t,a=r-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]}},po=class extends P{shaft;tip=null;caption=null;from="";to="";tipSize=14};function ho(n,t){let e=Ot(n);if(e<=t*1.1)return{head:[],trimmed:n};let o=1-t/e,r=Jt(n,0,o),[s,i]=Pt(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:r}}var bn=class extends P{nodes=new Map;edges=[];edgeLayer=new P;nodeLayer=new P;specs;constructor(t,e,o={}){super(),this.specs=t;let r=o.radius??30,s=o.labelSize??26,i=p=>p.width?[p.width,p.height??s*2]:[(p.radius??r)*2,(p.radius??r)*2],a=o.layout??"dagre",l=new Map,c=new Map;if(a==="dagre"){let p=_i(),f=new p.graphlib.Graph({multigraph:!0});f.setGraph({rankdir:o.direction??"LR",nodesep:o.nodeGap??60,ranksep:o.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(o.width??700,o.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=Ki(t,e,o.width??900,o.height??620,o.seed??3);else for(let p of t)l.set(p.id,p.at??[0,0]);let u=o.nodeColor??"blue";for(let p of t){let f=new mo,b=p.color??u,[y,g]=i(p);f.halfWidth=y/2,f.halfHeight=g/2,f.round=!p.width,f.shape=new P(p.width?X(-y/2,-g/2,y,g,8):Dt(0,0,y/2)).fill(b,o.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}):_(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=o.directed??!0,d=o.edgeColor??"dim",m=o.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 po;y.from=p.from,y.to=p.to;let g=l.get(p.from),w=l.get(p.to),x=c.get(p),k=(o.direction??"LR")==="LR"||o.direction==="RL",M=Xi(f,b,g,w,x,k),v=p.directed??h,O=p.color??d,{head:A,trimmed:R}=v?ho(M,y.tipSize):{head:[],trimmed:M};if(y.shaft=new P(R).stroke(O,p.width??2.2),p.dash&&y.shaft.dash(p.dash),y.add(y.shaft),A.length&&(y.tip=new P(A).fill(O),y.add(y.tip)),p.label){let[E,$]=Pt(M,.5),z=_(p.label,{size:m,color:"ink",font:"mono"}).at(E,$),D=m*.34,B=new P(X(E-z.width/2-D,$-m*.68,z.width+D*2,m*1.36,4)).fill("bg");y.caption=new P().add(B,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 o=this.edges.find(r=>r.from===t&&r.to===e)??this.edges.find(r=>r.from===e&&r.to===t);if(!o)throw new Error(`Graph has no edge ${t} -> ${e}.`);return o}enter(t={}){let e=t.lag??.14;return{label:"graph.enter",duration:t.duration??2,ease:t.ease,schedule:o=>{it(this,o.t0,o.stage);let r=this.specs.map(a=>this.nodes.get(a.id)),s=$t(r.length,e,o.t0,o.t0+(o.t1-o.t0)*.78),i=new Map;r.forEach((a,l)=>{let[c,u]=s[l];i.set(a,u),gn(a,o.t0,c,u,o.ease)});for(let a of this.edges){let l=i.get(this.nodes.get(a.from))??o.t0,c=Math.min(o.t1,l+(o.t1-o.t0)*.22);W(a.shaft,"trimTo",0,o.t0),a.shaft.tween("trimTo",1,l,c,o.ease);for(let u of[a.tip,a.caption])u&&(W(u,"opacity",0,o.t0),u.tween("opacity",1,c-(c-l)*.3,c,o.ease))}}}}pulseEdge(t,e,o={}){let r=this.edge(t,e);return{...Bn(r.shaft,{color:o.color??"yellow",length:o.length??.3,...o}),label:"graph.pulse"}}visit(t,e={}){let o=this.node(t),r=e.color??"yellow";return{label:"graph.visit",duration:e.duration??.6,ease:e.ease,schedule:s=>{let i=K(r);o.shape.tween("stroke",i,s.t0,s.t1,s.ease),o.shape.tween("fill",i,s.t0,s.t1,s.ease);let a=s.t1-s.t0,l=o.get("sx");o.tween("sx",l*1.16,s.t0,s.t0+a*.45,s.ease),o.tween("sy",l*1.16,s.t0,s.t0+a*.45,s.ease),o.tween("sx",l,s.t0+a*.45,s.t1,s.ease),o.tween("sy",l,s.t0+a*.45,s.t1,s.ease)}}}moveNode(t,e,o={}){let r=this.node(t);return{label:"graph.move",duration:o.duration??1,ease:o.ease,schedule:s=>{let i=r.get("x"),a=r.get("y");r.tween("x",e[0],s.t0,s.t1,s.ease),r.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?r.edgePoint(f,b,u,h,2):c.edgePoint(u,h,f,b,2),g=l.from===t?c.edgePoint(u,h,f,b,4):r.edgePoint(f,b,u,h,4);return Z([y,g])},m=p=>l.tip?ho(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=>ho(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 Xi(n,t,e,o,r,s){let i=r?r.slice(1,-1):[],a=i[0]??o,l=i[i.length-1]??e,c=n.edgePoint(e[0],e[1],a[0],a[1],2),u=t.edgePoint(o[0],o[1],l[0],l[1],4);if(!r)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,o,r){let s=me(n,"sx",e),i=me(n,"sy",e);W(n,"sx",s*.001,t),W(n,"sy",i*.001,t),n.tween("sx",s,e,o,r),n.tween("sy",i,e,o,r)}function Ki(n,t,e,o,r){let s=$e(r),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)*o;let c=new Map(i.map((d,m)=>[d,m])),u=Math.sqrt(e*o/Math.max(1,i.length))*.72,h=Math.max(e,o)*.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(-o/2,Math.min(o/2,l[f]))}h*=.985}return new Map(i.map((d,m)=>[d,[a[m],l[m]]]))}function Fu(n,t,e={}){return new bn(n,t,e)}var fo=class extends bn{depths=new Map;constructor(t,e={}){let o=[],r=[],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(o.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)r.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=o.map(f=>f.at[0]),d=o.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 o)f.at=[f.at[0]-m,f.at[1]-p];super(o,r,{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 o=Math.max(...this.depths.values())+1,r=(e.t1-e.t0)/o;for(let[s,i]of this.nodes){let a=this.depths.get(s)??0,l=e.t0+a*r;gn(i,e.t0,l,l+r,e.ease)}for(let s of this.edges){let i=this.depths.get(s.to)??1,a=e.t0+(i-1)*r+r*.3;W(s.shaft,"trimTo",0,e.t0),s.shaft.tween("trimTo",1,a,a+r*.8,e.ease)}}}}};function Iu(n,t={}){return new fo(n,t)}var bo=class extends P{slots=[];indexLabels=[];items=[];cellSize;step;constructor(t,e={}){super();let o=this.cellSize=e.cell??72,r=e.gap??6;this.step=o+r;let s=e.size??o*.38,i=e.color??"blue",a=-((t.length-1)*this.step)/2;t.forEach((l,c)=>{let u=a+c*this.step,h=new P(X(-o/2,-o/2,o,o,6)).stroke("faint",1.5).at(u,0);if(this.slots.push(h),this.add(h),e.indices??!0){let d=_(String(c),{size:e.indexSize??Math.max(13,o*.2),color:"faint",font:"mono"}).at(u,o/2+(e.indexSize??o*.2)+2);this.indexLabels.push(d),this.add(d)}}),t.forEach((l,c)=>{let u=a+c*this.step,h=new P().at(u,0),d=new P(X(-o/2+2,-o/2+2,o-4,o-4,5)).fill(i,.16).stroke(i,2),m=_(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,o={}){return{label:"array.swap",duration:o.duration??.8,ease:o.ease,schedule:r=>{let s=this.items[t],i=this.items[e],[a,l]=this.slotAt(t),[c,u]=this.slotAt(e),h=o.lift??this.cellSize*.9+Math.abs(t-e)*6,d=(m,p,f,b,y,g)=>{m.track("x").add({t0:r.t0,t1:r.t1,ease:r.ease,to:b,at:w=>p+(b-p)*w}),m.track("y").add({t0:r.t0,t1:r.t1,ease:r.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,o={}){let r=this.cell(t);return{...lr(r.data.box,e,{duration:.35,...o}),label:"array.mark"}}enter(t={}){let e=t.lag??.2;return{label:"array.enter",duration:t.duration??1.2,ease:t.ease,schedule:o=>{it(this,o.t0,o.stage);let r=$t(this.items.length,e,o.t0,o.t1);this.items.forEach((s,i)=>{let[a,l]=r[i];gn(s,o.t0,a,l,o.ease),W(this.slots[i],"opacity",0,o.t0),this.slots[i].tween("opacity",1,a,l,o.ease);let c=this.indexLabels[i];c&&(W(c,"opacity",0,o.t0),c.tween("opacity",1,a,l,o.ease))})}}}};function Eu(n,t={}){return new bo(n,t)}var ns={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 Yi(n,t="ts"){let e=t==="js"||t==="tsx"||t==="jsx"||t==="typescript"||t==="javascript"?"ts":t==="py"?"python":t,o=ns[e]??ns.ts,r=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=o.has(r?y.toLowerCase():y)?"keyword":/^\s*\(/.test(g)?"function":/^[A-Z]/.test(y)?"type":"plain";d(y,x);continue}d(h[0],"punctuation")}}),a}var qi={keyword:"purple",string:"green",number:"orange",comment:"faint",function:"blue",type:"teal",punctuation:"dim",plain:"ink"},go=class extends P{lines=[];tokens=[];chars=[];panelNode=null;body=new P;source;bar;rowHeight;originY;contentWidth;constructor(t,e={}){super(),this.source=t;let o=e.size??26,r=this.rowHeight=o*(e.leading??1.5),s=Ie("mono",400),i=o/s.unitsPerEm,a=s.advance(s.glyphFor(48))*i,l=Yi(t,e.language??"ts"),c=t.split(`
|
|
4
|
+
`),u=e.lineNumbers?(String(c.length).length+2)*a:0,h=e.padding??o*.9,d=Math.max(e.minWidth??0,Math.max(...c.map(g=>g.length))*a+u+h*2),m=c.length*r+h*2-(r-o);this.contentWidth=d;let p=-d/2+h+u,f=-m/2+h+o*.82;if(this.originY=f,e.panel??!0){let g=new P(X(-d/2,-m/2,d,m,8)).fill("surface").stroke("gridStrong",1);this.panelNode=g,this.add(g)}this.bar=new P().fill("yellow",.1),this.bar.base.visible=!1,this.add(this.bar);for(let g=0;g<c.length;g++){let w=new P;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(os(s,M,o,"faint",k,f+g*r)),k+=a}}let b={...qi,...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 O=os(s,M,o,k,p+(w+v)*a,f+g.line*r);x.glyphs.push(O),this.chars.push(O),this.lines[g.line].add(O)})}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 o=new Set(typeof t=="number"?[t]:t);return{label:"code.focus",duration:e.duration??.6,ease:e.ease,schedule:r=>{this.lines.forEach((d,m)=>{d.tween("opacity",o.has(m)?1:e.dim??.28,r.t0,r.t1,r.ease)});let s=[...o].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=X(-this.contentWidth/2+2,-this.rowHeight*c/2,this.contentWidth-4,this.rowHeight*c,3);me(this.bar,"visible",r.t0)?(this.bar.tween("y",l,r.t0,r.t1,r.ease),this.bar.tween("path",u,r.t0,r.t1,r.ease)):(W(this.bar,"x",0,r.t0),W(this.bar,"y",l,r.t0),this.bar.track("path").step(r.t0,u),W(this.bar,"visible",!0,r.t0),W(this.bar,"opacity",0,r.t0),this.bar.tween("opacity",1,r.t0,r.t1,r.ease)),e.color&&this.bar.tween("fill",K(e.color),r.t0,r.t1,r.ease)}}}unfocus(t={}){return{label:"code.unfocus",duration:t.duration??.5,ease:t.ease,schedule:e=>{for(let o of this.lines)o.tween("opacity",1,e.t0,e.t1,e.ease);this.bar.tween("opacity",0,e.t0,e.t1,e.ease),W(this.bar,"visible",!1,e.t1)}}}};function os(n,t,e,o,r,s){let i=new P(Ee(n,n.glyphFor(t.codePointAt(0)),e));return i.base.fill=K(o),i.base.trimEach=!0,i.data.key=t,i.at(r,s)}function zu(n,t={}){return new go(n,t)}function Vu(n,t,e={}){let o=u=>u.tokens.filter(h=>h.kind!=="space"&&h.glyphs.length>0),r=o(n),s=o(t),i=Je(r.map(u=>u.text),s.map(u=>u.text)),a=new Map;i.forEach(([u,h],d)=>{r[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 yo=class extends P{neurons=[];links=[];edgeLayer=new P;neuronLayer=new P;captions=[];seed;layerColors;constructor(t,e={}){super();let o=e.width??1e3,r=e.height??560,s=e.radius??15,i=e.collapse??8,a=t.length>1?o/(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,r/Math.max(1,m+(h>i?1:0))),f=-o/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 P(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=_(x,{size:k,color:"dim"}).at(f,r/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 o=e.t1-e.t0,r=this.neurons.length,s=o*.45,i=r>1?o*.55/(r-1):0;this.neurons.forEach((a,l)=>{let c=$t(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)W(h,"trimTo",0,e.t0),h.tween("trimTo",1,c,c+s,e.ease)});for(let a of this.neuronLayer.children)a.get("path")||(W(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0+o*.3,e.t1,e.ease));for(let a of this.captions)W(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0+o*.3,e.t1,e.ease)}}}activate(t,e,o={}){return{label:"net.activate",duration:o.duration??.45,ease:o.ease,schedule:r=>{this.neurons[t].forEach((s,i)=>{let a=Math.max(.04,Math.min(1,e[i]??0));s.tween("fillOpacity",a,r.t0,r.t1,r.ease),o.color&&s.tween("fill",K(o.color),r.t0,r.t1,r.ease)})}}}forward(t={}){let e=$e(this.seed),o=this.neurons.map((a,l)=>t.activations?.[l]??a.map(()=>e()*e())),r=t.color??"yellow",s=[];o.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)*(o[l+1]?.[p]??0)})})),c.sort((h,d)=>d.score-h.score);let u=c.slice(0,t.pulses??10);s.push(Ln(...u.map(({link:h,score:d})=>Bn(h,{color:r,length:.42,width:1.5+d*3,glow:4,duration:.7}))))});let i=rr(...s);return{...i,label:"net.forward",duration:t.duration??i.duration,ease:t.ease}}};function Lu(n,t={}){return new yo(n,t)}var wo=class extends P{chips=[];constructor(t,e={}){super();let o=e.size??22,r=e.gap??o*.28,s=e.subSize??o*.62,i=o*.42,a=o*.3,l=t.map(b=>typeof b=="string"?{text:b}:b),c=e.colors?Te(l.length,...e.colors):null,u=0,h=0,d=[],m=o+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=_(y.text.replace(/ /g,"\xB7"),{size:o,font:e.font??"mono",color:"ink"}),x=Math.max(w.width,o*.5)+i*2,k=o+a*2;e.maxWidth!==void 0&&u>0&&u+x>e.maxWidth&&(u=0,h+=m+r);let M=new P,v=new P(X(-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(_(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+r}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:o=>{it(this,o.t0,o.stage);let r=$t(this.chips.length,e,o.t0,o.t1);this.chips.forEach((s,i)=>{let[a,l]=r[i],c=s.get("y");W(s,"opacity",0,o.t0),W(s,"y",c+16,o.t0),s.tween("opacity",1,a,l,o.ease),s.tween("y",c,a,l,o.ease)})}}}arcs(t,e,o={}){let r=this.token(t).bounds(),s=new P,i=r.x+r.width/2,a=r.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=o.lift??40+Math.abs(h-i)*.22,p=vt(`M${i} ${a}C${i} ${a-m} ${h} ${d-m} ${h} ${d}`),f=new P(p).stroke(o.color??"yellow",.8+l*(o.maxWidth??6));f.set("strokeOpacity",.2+l*.8),s.add(f)}),s}};function $u(n,t={}){return new wo(n,t)}function Bu(n,t,e,o={}){return new We(e,{cell:o.cell??42,gap:o.gap??2,colors:o.colors??["surface","teal","yellow"],domain:[0,Math.max(...e.flat())],values:o.values,rowLabels:n,columnLabels:t,labelSize:o.labelSize??18,columnLabelAngle:-Math.PI/4})}function qt(n,t,e,o="left"){let r=n.get("px");return n.at(o==="left"?t+r:o==="right"?t-r:t,e)}function _t(n){return n.get("px")*2}var ko=class extends P{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 o=e*.8,r=t.rows??[],s=e*1.56,i=_(t.title,{size:e*1.14,weight:600,color:"ink"}),a=t.subtitle?_(t.subtitle,{size:e*.86,font:"mono",color:"dim"}):null,l=t.badgeTone??t.accent??"dim",c=t.badge?_(t.badge,{size:e*.78,font:"mono",color:l}):null,u=r.map(M=>_(M.label,{size:e,color:"dim"})),h=r.map(M=>M.value!==void 0?_(M.value,{size:e,font:"mono",color:M.tone??"ink"}):null),d=e*3.6,m=Math.max(_t(i)+(c?_t(c)+e*1.6:0),a?_t(a):0,...r.map((M,v)=>_t(u[v])+(h[v]?_t(h[v])+e*1.1:0)+(M.spark?d+e*.6:0)),0),p=this.boxWidth=Math.max(t.width??0,m+o*2),f=e*1.4+(a?e*1.2:0),b=r.reduce((M,v)=>M+s+(v.meter!==void 0?e*.32:0),0),y=t.tags?.length?e*1.72:0,g=this.boxHeight=o*1.5+f+(r.length?e*.55:0)+b+y,w=-p/2+o,x=p/2-o;if(this.frame=new P(X(-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 P(X(-p/2,-g/2+1,2.5,g-2)).fill(t.accent);this.accentBar=M,this.add(M)}let k=-g/2+o*.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),r.length){let M=k-e*.38;this.add(Y([-p/2+o,M],[p/2-o,M],{stroke:"grid",width:1})),k+=e*.5}if(r.forEach((M,v)=>{qt(u[v],w,k),this.rowLabels.push(u[v]),this.add(u[v]);let O=x,A=h[v];if(A&&(qt(A,O,k,"right"),this.add(A),O-=_t(A)+e*.7),this.rowValues.push(A??null),M.spark){let R=Ui(M.spark,{width:d,height:e*.82,color:M.tone??"blue",dotted:!0,weight:1.2});this.add(R.at(O-d/2,k-e*.1))}if(k+=s,M.meter!==void 0){let R=k-e*.62;this.add(Y([w,R],[x,R],{stroke:"grid",width:2}));let E=Y([w,R],[w+(x-w)*Math.max(0,Math.min(1,M.meter)),R],{stroke:M.tone??"blue",width:2});E.set("cap","butt"),this.meters.push(E),this.add(E),k+=e*.32}}),t.tags?.length){let M=w,v=g/2-o*.7-e*.4;for(let O of t.tags){let A=_(O,{size:e*.78,font:"mono",color:"dim"}),R=_t(A)+e*.7,E=new P(X(M,v-e*.62,R,e*1.24,2)).stroke("gridStrong",1);qt(A,M+e*.35,v),this.tagNodes.push(A),this.add(E,A),M+=R+e*.34}}}port(t,e=0){let o=this.bounds(),r=o.x+o.width/2,s=o.y+o.height/2;return t==="left"?[o.x,s+e*o.height/2]:t==="right"?[o.x+o.width,s+e*o.height/2]:t==="top"?[r+e*o.width/2,o.y]:[r+e*o.width/2,o.y+o.height]}enter(t={}){return{label:"infoBox.enter",duration:t.duration??.9,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let o=e.t1-e.t0,r=this.frame.get("fillOpacity");W(this.frame,"trimTo",0,e.t0),W(this.frame,"fillOpacity",0,e.t0),this.frame.tween("trimTo",1,e.t0,e.t0+o*.65,e.ease),this.frame.tween("fillOpacity",r,e.t0+o*.2,e.t0+o*.8,e.ease);let s=this.children.filter(a=>a!==this.frame),i=$t(s.length,.06,e.t0+o*.25,e.t1);s.forEach((a,l)=>{let[c,u]=i[l],h=a.get("opacity");W(a,"opacity",0,e.t0),a.tween("opacity",h,c,u,e.ease)})}}}setValue(t,e,o={}){let r=this.rowValues[t];if(!r)throw new Error(`Info box row ${t} has no value to change.`);let s=_(e,{size:this.valueSize,font:"mono",color:o.tone??"ink"}),i=r.get("x")+r.get("px");qt(s,i,r.get("y"),"right");let a=we(r,s,{duration:.5,...o});return{...a,label:"infoBox.setValue",schedule:l=>{this.add(s),this.rowValues[t]=s,a.schedule(l)}}}};function Yu(n){return new ko(n)}function Ui(n,t={}){let e=t.width??80,o=t.height??20,r=Math.min(...n),i=Math.max(...n)-r||1,a=n.map((u,h)=>[(h/Math.max(1,n.length-1)-.5)*e,(.5-(u-r)/i)*o]),l=t.color??"blue",c=new P;return t.area&&c.add(new P(Z([...a,[e/2,o/2],[-e/2,o/2]],!0)).fill(l,t.area)),c.add(new P(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 rs={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]};function ss(n,t,e){let o=n.x+n.width/2,r=n.y+n.height/2;return t==="left"?[n.x,r+e*n.height/2]:t==="right"?[n.x+n.width,r+e*n.height/2]:t==="top"?[o+e*n.width/2,n.y]:[o+e*n.width/2,n.y+n.height]}function Zi(n,t){let e=Math.max(t.x-(n.x+n.width),n.x-(t.x+t.width)),o=Math.max(t.y-(n.y+n.height),n.y-(t.y+t.height)),r=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>=o?i>=r?["right","left"]:["left","right"]:a>=s?["bottom","top"]:["top","bottom"]}function xo(n,t){let e=`M${n[0][0]} ${n[0][1]}`;for(let r=1;r<n.length-1;r++){let s=n[r-1],i=n[r],a=n[r+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 o=n[n.length-1];return vt(`${e}L${o[0]} ${o[1]}`)}var Mo=class extends P{fromEnd;toEnd;options;pulses=[];plate=null;caption=null;constructor(t,e,o={}){super([]),this.fromEnd=t,this.toEnd=e,this.options=o,this.base.stroke=K(o.color??"dim"),this.base.strokeWidth=o.width??1.6,this.draw=r=>this.build(r)}anchors(){let{fromEnd:t,toEnd:e,options:o}=this,r=o.gap??3,s=m=>m instanceof P?m.bounds():{x:m[0],y:m[1],width:0,height:0},i=s(t),a=s(e),[l,c]=Zi(i,a),u=o.from??l,h=o.to??c,d=(m,p,f,b)=>{let y=rs[f];if(!(m instanceof P))return{point:m,normal:y};let[g,w]=ss(p,f,b);return{point:[g+y[0]*r,w+y[1]*r],normal:y}};return[d(t,i,u,o.fromOffset??0),d(e,a,h,o.toOffset??0)]}routeNow(){let[t,e]=this.anchors(),o=this.options.route??"curve";if(o==="straight")return Z([t.point,e.point]);if(o==="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 xo([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 xo([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 xo([t.point,h,e.point],l)}let r=Math.hypot(e.point[0]-t.point[0],e.point[1]-t.point[1]),s=Math.max(18,r*(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,o=rt(this.routeNow(),e),r=Ot(o);if(r<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/r),m=Jt(o,this.get("trimFrom"),d),p=a??K("dim");if(m.length){let f=new P(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]=Pt(o,s),[y,g]=ge(o,Math.min(.997,s)),w=h*.38,x=f-y*h,k=b-g*h;c.push(new P(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(o,y,g);w.length&&c.push(new P(w).stroke(f.color,f.width).glow(f.glow))}if(i.label&&s>.5){let f=i.labelSize??12;this.caption??=_(i.label,{size:f,font:"mono",color:i.labelColor??"dim"});let b=_t(this.caption),y=f*.35;this.plate??=new P(X(-b/2-y,-f*.72,b+y*2,f*1.44,2)).fill(i.labelBackground??"bg");let[g,w]=Pt(o,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 Pt(this.routeNow(),t)}};function qu(n,t,e={}){return new Mo(n,t,e)}function Uu(n,t={}){let e=t.size??13,o=(t.direction??"row")==="row",r=t.gap??(o?e*1.5:e*.6),s=e*1.5,i=new P,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"?zr(e*.32,{stroke:m,width:1.6}):new P(X(-e*.42,-e*.42,e*.84,e*.84,1.5)).fill(m),b=_(d.label,{size:e,color:"dim"}),y=s+e*.5+_t(b),g=new P;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)+r*Math.max(0,l.length-1),u=Math.max(0,...l.map(d=>d.width)),h=e*1.2+r;return l.forEach((d,m)=>{o?(d.node.at(-c/2+a,0),a+=d.width+r):d.node.at(-u/2,(m-(l.length-1)/2)*h),i.add(d.node)}),i}var vo=class extends P{leader;marker;body;titleNode=null;constructor(t,e,o={}){super();let r=o.size??15,s=o.color??"yellow",i=o.side??"right",a=o.distance??72,l=o.width??280,c=rs[i],u=t instanceof P?t.bounds():{x:t[0],y:t[1],width:0,height:0},h=t instanceof P?ss(u,i,0):t,d=o.title?_(o.title,{size:r,weight:600,color:s}):null,m=_(e,{size:r*.94,color:o.bodyColor??"dim",maxWidth:l,leading:1.36}),p=d?r*1.42:0,f=Math.max(m.width,d?_t(d):0),b=m.height,y=p+b,g=o.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(o.plate){let v=r*.5;this.add(new P(X(w-v,x-v,f+v*2,y+v*2,3)).fill("bg",.86))}d&&(this.titleNode=qt(d,w,x+r*.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 P(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 o=e.t1-e.t0;W(this.marker,"opacity",0,e.t0),this.marker.tween("opacity",1,e.t0,e.t0+o*.2,e.ease),W(this.leader,"trimTo",0,e.t0),this.leader.tween("trimTo",1,e.t0,e.t0+o*.55,e.ease);for(let r of this.children){if(r===this.marker||r===this.leader)continue;let s=r.get("opacity");W(r,"opacity",0,e.t0),r.tween("opacity",s,e.t0+o*.42,e.t1,e.ease)}}}}};function Zu(n,t,e={}){return new vo(n,t,e)}function De(n){return Array.isArray(n)?[...n]:[n]}function is(n){return De(n).flatMap(t=>t.leaves().filter(e=>e.get("path")))}function ah(n,t={}){let e=is(n);return{label:"typewriter",duration:t.duration??Math.max(.5,e.length*.035),ease:t.ease??Re,schedule(o){for(let a of De(n))it(a,o.t0,o.stage);let r=is(n);if(r.length===0)return;let s=o.t1-o.t0,i=null;if(t.cursor){let l=r[0].bounds().height*1.35||24;i=new P(X(0,-l/2,Math.max(3,l*.1),l)).fill(t.cursorColor??"ink"),o.stage.add(i)}r.forEach((a,l)=>{let c=o.t0+s*o.ease(l/r.length),u=a.get("opacity");if(W(a,"opacity",0,o.t0),W(a,"opacity",u,c),i){C.now=c;let h=a.bounds();W(i,"x",h.x+h.width+3,c),W(i,"y",h.y+h.height/2,c),C.now=o.t0}}),i&&W(i,"visible",!1,o.t1)}}}function lh(n,t={}){return{label:"wipe",duration:t.duration??1.2,ease:t.ease??dt,schedule(e){let o=t.from??"left";for(let p of De(n))it(p,e.t0,e.stage);let r=De(n).flatMap(p=>p.leaves()),s=p=>{let f=p.bounds(),b=f.x+f.width/2,y=f.y+f.height/2;return o==="left"?b:o==="right"?-b:o==="top"?y:-y},i=r.map(s),a=Math.min(...i),l=Math.max(...i),c=t.soft??.25,u=t.travel??0,h=e.t1-e.t0,d=o==="left"?-u:o==="right"?u:0,m=o==="top"?-u:o==="bottom"?u:0;r.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(W(p,"opacity",0,e.t0),p.tween("opacity",w,y,g,dt),u){let x=p.get("x"),k=p.get("y");W(p,"x",x+d,e.t0),W(p,"y",k+m,e.t0),p.tween("x",x,y,g,dt),p.tween("y",k,y,g,dt)}})}}}var Ge=class extends P{value;constructor(t=0,e={}){super(),this.value=new pt(t);let o=e.digits??0,r=new Intl.NumberFormat("en-US",{minimumFractionDigits:o,maximumFractionDigits:o,useGrouping:e.grouped??!0}),s=At(()=>{let i=`${e.prefix??""}${r.format(this.value.value)}${e.suffix??""}`;return _(i,{size:e.size??48,color:e.color??"ink",font:e.font??"mono",weight:e.weight??400})});this.add(s)}};function ch(n=0,t={}){return new Ge(n,t)}function uh(n,t,e={}){let o=n instanceof Ge?n.value:n;return{label:"countUp",duration:e.duration??1.2,ease:e.ease,schedule(r){n instanceof Ge&&it(n,r.t0,r.stage),wt(o,t,r.t0,r.t1,r.ease)}}}function hh(n,t,e={}){return{label:"spin",duration:e.duration??2,ease:e.ease??Re,schedule(o){it(n,o.t0,o.stage),C.now=o.t0,n.pivotAt(e.about??n.center);let r=n.get("rotation"),s=o.t1-o.t0;n.tween("rotation",r+t*s,o.t0,o.t1,o.ease)}}}function dh(n,t,e={}){return{label:"swap",duration:e.duration??.9,ease:e.ease,schedule(o){it(n,o.t0,o.stage),it(t,o.t0,o.stage),C.now=o.t0;let r=n.center,s=t.center,i=e.lift??Math.max(60,Math.hypot(s[0]-r[0],s[1]-r[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:o.t0,t1:o.t1,ease:o.ease,to:w,at:k=>m+(w-m)*k}),l.track("y").add({t0:o.t0,t1:o.t1,ease:o.ease,to:x,at:k=>p+(x-p)*k-h*i*4*k*(1-k)})};a(n,r,s,1),a(t,s,r,-1)}}}function mh(n,t={}){let e=new P([]),o=De(n);return{mark:e,label:"highlightSweep",duration:t.duration??.7,ease:t.ease,schedule(r){let s=1/0,i=1/0,a=-1/0,l=-1/0;for(let M of o){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=K(f),e.base.fillOpacity=t.opacity??.26;let b=r.stage.root;b.add(e);let g=o[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 X(x?u+d-v:u,h,v,m,p)};e.track("path").step(r.t0,k(0)),e.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:k(1),at:k})}}}function as(n){return n.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,e)=>String.fromCodePoint(Number(e))).replace(/&#x([\da-fA-F]+);/g,(t,e)=>String.fromCodePoint(parseInt(e,16))).replace(/&/g,"&")}function Ji(n){let t={name:"#root",attrs:{},children:[],text:""},e=[t],o=/<!--[\s\S]*?-->|<!\[CDATA\[([\s\S]*?)\]\]>|<\?[\s\S]*?\?>|<!DOCTYPE[^>]*>|<\/([\w:.-]+)\s*>|<([\w:.-]+)((?:\s+[\w:.-]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>|([^<]+)/g;for(let r=o.exec(n);r;r=o.exec(n)){let s=e[e.length-1],[,i,a,l,c,u,h]=r;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]]=as(m[2]??m[3]??"");s.children.push(d),u||e.push(d)}else h&&(s.text+=as(h))}return t}function Qi(n){if(!n)return zt;let t=zt;for(let e of n.matchAll(/(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/g)){let o=e[2].trim().split(/[\s,]+/).filter(Boolean).map(Number),r=e[1];if(r==="matrix"&&o.length===6)t=ot(t,o);else if(r==="translate")t=ot(t,[1,0,0,1,o[0]??0,o[1]??0]);else if(r==="scale")t=ot(t,[o[0]??1,0,0,o[1]??o[0]??1,0,0]);else if(r==="rotate"){let s=(o[0]??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),l=o[1]??0,c=o[2]??0;t=ot(t,[1,0,0,1,l,c]),t=ot(t,[i,a,-a,i,0,0]),t=ot(t,[1,0,0,1,-l,-c])}else r==="skewX"?t=ot(t,[1,0,Math.tan((o[0]??0)*Math.PI/180),1,0,0]):r==="skewY"&&(t=ot(t,[1,Math.tan((o[0]??0)*Math.PI/180),0,1,0,0]))}return t}var ta=new Set(["defs","clipPath","mask","pattern","filter","symbol","marker","linearGradient","radialGradient","title","desc","metadata","style","script"]),wn=class extends P{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 ea(n){let t=new Map,e=o=>{if(o.name==="style")for(let r of o.text.matchAll(/([^{}]+)\{([^{}]*)\}/g)){let s=Po(r[2]);for(let i of r[1].split(",")){let a=i.trim();t.set(a,{...t.get(a),...s})}}o.children.forEach(e)};return e(n),t}function Po(n){let t={};if(!n)return t;for(let e of n.split(";")){let o=e.indexOf(":");o>0&&(t[e.slice(0,o).trim()]=e.slice(o+1).trim())}return t}function yn(n){if(!n||n==="none"||n==="transparent")return null;try{return Gt(n)}catch{return null}}function na(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 o=[],r=new Map;return t.forEach((s,i)=>{if(s.owner!==-1)return;let a={x:s.b.x,rings:[s.ring]};r.set(i,a),o.push(a)}),t.forEach(s=>{s.owner!==-1&&r.get(s.owner)?.rings.push(s.ring)}),o.sort((s,i)=>s.x-i.x).map(s=>s.rings)}function oa(n,t={}){let o=Ji(n).children.find(N=>N.name==="svg");if(!o)throw new Error("fromSvg needs markup with an <svg> element.");let r=ea(o),s=new Map,i=N=>{N.attrs.id&&s.set(N.attrs.id,N),N.children.forEach(i)};i(o);let a=(o.attrs.viewBox??"").trim().split(/[\s,]+/).map(Number),l=parseFloat(o.attrs.width??""),c=parseFloat(o.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 N=t.width!==void 0?t.width/u:1/0,V=t.height!==void 0?t.height/h:1/0;b=Math.min(N,V)}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,O=!0,A=(N,V,F)=>{let T=s.get(N);if(!T)return null;if(T.name==="pattern"){let I=T.children.find(j=>j.name==="linearGradient");if(I)return E(I,V,F,!0);let L=T.children.find(j=>j.attrs.fill?.startsWith("url(#"))?.attrs.fill?.match(/url\(#([^)]+)\)/)?.[1];return L?A(L,V,F):null}if(T.name==="linearGradient")return E(T,V,F,T.attrs.gradientUnits!=="userSpaceOnUse");if(T.name==="radialGradient"){let I=R(T);return I.length?I[I.length-1][1]:null}return null},R=N=>{let V=N.attrs.href??N.attrs["xlink:href"];return(N.children.some(T=>T.name==="stop")||!V?N:s.get(V.replace(/^#/,""))??N).children.filter(T=>T.name==="stop").map(T=>{let I=Po(T.attrs.style),S=T.attrs.offset??"0",L=S.endsWith("%")?parseFloat(S)/100:parseFloat(S),j=yn(I["stop-color"]??T.attrs["stop-color"]??"#000000")??[0,0,0,1],J=parseFloat(I["stop-opacity"]??T.attrs["stop-opacity"]??"1");return[L,[j[0],j[1],j[2],j[3]*J]]})},E=(N,V,F,T)=>{let I=R(N);if(I.length===0)return null;let S=(H,ct)=>H===void 0?ct:H.endsWith("%")?parseFloat(H)/100:parseFloat(H),L=S(N.attrs.x1,0),j=S(N.attrs.y1,0),J=S(N.attrs.x2,1),at=S(N.attrs.y2,0),tt,ut;if(T){let H=bt(F)??{x:0,y:0,width:1,height:1};tt=[H.x+L*H.width,H.y+j*H.height],ut=[H.x+J*H.width,H.y+at*H.height]}else tt=Q(V,L,j),ut=Q(V,J,at);return{type:"linear",from:tt,to:ut,stops:I}},$=N=>{let V=N.attrs,F=(T,I=0)=>{let S=parseFloat(V[T]??"");return Number.isFinite(S)?S:I};switch(N.name){case"path":return V.d?vt(V.d):null;case"rect":{let T=F("width"),I=F("height");return T<=0||I<=0?null:X(F("x"),F("y"),T,I,F("rx",F("ry")))}case"circle":return F("r")>0?St(F("cx"),F("cy"),F("r"),F("r"),0,Math.PI*2):null;case"ellipse":return F("rx")>0&&F("ry")>0?St(F("cx"),F("cy"),F("rx"),F("ry"),0,Math.PI*2):null;case"line":return Z([[F("x1"),F("y1")],[F("x2"),F("y2")]]);case"polyline":case"polygon":{let T=(V.points??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),I=[];for(let S=0;S+1<T.length;S+=2)I.push([T[S],T[S+1]]);return I.length>=2?Z(I,N.name==="polygon"):null}default:return null}},z=(N,V)=>{let F=N.attrs,T=(F.class??"").split(/\s+/).filter(Boolean),I={...r.get(N.name)};for(let q of T)Object.assign(I,r.get(`.${q}`));F.id&&Object.assign(I,r.get(`#${F.id}`));let S=q=>Po(F.style)[q]??F[q]??I[q],L={...V},j=S("color");j&&(L.color=j);let J=S("fill");J&&(L.fill=J==="currentColor"?L.color:J);let at=S("stroke");at&&(L.stroke=at==="currentColor"?L.color:at);let tt=S("stroke-width");tt!==void 0&&(L.strokeWidth=parseFloat(tt)||0);let ut=S("fill-opacity");ut!==void 0&&(L.fillOpacity=parseFloat(ut));let H=S("stroke-opacity");H!==void 0&&(L.strokeOpacity=parseFloat(H));let ct=S("stroke-linecap");(ct==="round"||ct==="butt"||ct==="square")&&(L.cap=ct);let mt=S("stroke-linejoin");(mt==="round"||mt==="miter"||mt==="bevel")&&(L.join=mt);let nt=S("stroke-dasharray");nt!==void 0&&(L.dash=nt==="none"?null:nt.trim().split(/[\s,]+/).map(Number));let ht=S("stroke-dashoffset");ht!==void 0&&(L.dashOffset=parseFloat(ht)||0);let xt=S("font-size");xt!==void 0&&(L.fontSize=parseFloat(xt)||L.fontSize);let kt=S("text-anchor");return kt&&(L.anchor=kt),{style:L,opacity:parseFloat(S("opacity")??"1")}},D=(N,V,F,T)=>{let I=rt(N,V),S=Kt(V),L=nt=>nt?.match(/^url\(#([^)]+)\)/)?.[1],j=L(T.fill),J=L(T.stroke),at=j?A(j,V,I):yn(T.fill),tt=J?A(J,V,I):yn(T.stroke),ut=at&&T.fillOpacity>0&&!(Array.isArray(at)&&at[3]===0),H=tt&&T.strokeOpacity>0&&T.strokeWidth>0&&!(Array.isArray(tt)&&tt[3]===0);if(!ut&&!H)return[];let ct=F.attrs["clip-path"]?.5:1;return(M&&ut&&!H&&I.length>1?na(I):[I]).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 P(rt(nt,[1,0,0,1,-xt,-kt])).at(xt,kt);return ut&&(q.base.fill=ls(at,-xt,-kt),q.base.fillOpacity=T.fillOpacity),H&&(q.base.stroke=ls(tt,-xt,-kt),q.base.strokeWidth=T.strokeWidth*S*ct,q.base.strokeOpacity=T.strokeOpacity,q.base.cap=T.cap,q.base.join=T.join,T.dash&&(q.base.dash=T.dash.map(ie=>ie*S)),q.base.dashOffset=T.dashOffset*S),q.base.trimEach=!0,q})},B=(N,V,F,T)=>{if(ta.has(N.name)||N.attrs.filter)return;let{style:I,opacity:S}=z(N,F),L=ot(T,Qi(N.attrs.transform)),j=H=>{N.attrs.id&&k.byId.set(N.attrs.id,H)};if(N.name==="g"||N.name==="svg"||N.name==="a"){let H=new P;S<1&&(H.base.opacity=S),j(H),V.add(H);for(let ct of N.children)B(ct,H,I,L);return}if(N.name==="use"){let H=(N.attrs.href??N.attrs["xlink:href"]??"").replace(/^#/,""),ct=s.get(H);if(!ct)return;let mt=ot(L,[1,0,0,1,parseFloat(N.attrs.x??"0")||0,parseFloat(N.attrs.y??"0")||0]),nt=new P;if(S<1&&(nt.base.opacity=S),V.add(nt),ct.name==="symbol")for(let ht of ct.children)B(ht,nt,I,mt);else B(ct,nt,I,mt);return}if(N.name==="image"){let H=N.attrs.href??N.attrs["xlink:href"];if(!H)return;let ct=parseFloat(N.attrs.width??"0"),mt=parseFloat(N.attrs.height??"0"),[nt,ht]=Q(L,parseFloat(N.attrs.x??"0")||0,parseFloat(N.attrs.y??"0")||0),xt=Kt(L),kt={src:H,width:ct,height:mt},q=new P().at(nt,ht);q.base.image=kt,q.base.sx=xt,q.base.sy=xt,S<1&&(q.base.opacity=S),j(q),V.add(q);return}if(N.name==="text"){let H=(N.text+N.children.map(q=>q.text).join("")).trim();if(!H)return;let ct=yn(I.fill)??[0,0,0,1],mt=I.fontSize*Kt(L),nt=_(H,{size:mt,color:ct}),[ht,xt]=Q(L,parseFloat(N.attrs.x??"0")||0,parseFloat(N.attrs.y??"0")||0),kt=nt.get("px");nt.at(I.anchor==="middle"?ht:I.anchor==="end"?ht-kt:ht+kt,xt-mt*.34),S<1&&(nt.base.opacity=S),j(nt),V.add(nt);return}let J=$(N);if(!J||J.length===0)return;let at=O&&N.name==="rect"&&!v&&parseFloat(N.attrs.width??"0")>=u-.5&&parseFloat(N.attrs.height??"0")>=h-.5;if(O=!1,at)return;let tt=D(J,L,N,I);if(tt.length===0)return;if(tt.length===1){S<1&&(tt[0].base.opacity=S),j(tt[0]),V.add(tt[0]);return}let ut=new P;S<1&&(ut.base.opacity=S),ut.add(...tt),j(ut),V.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(o,G);for(let N of o.children)B(N,k,U,x);return k}function ls(n,t,e){if(Array.isArray(n))return n;let o=n;return o.type==="linear"?{...o,from:[o.from[0]+t,o.from[1]+e],to:[o.to[0]+t,o.to[1]+e]}:o.type==="radial"?{...o,center:[o.center[0]+t,o.center[1]+e]}:o}var re=n=>typeof n=="function"?n():n,cs=n=>{let t=Math.hypot(n[0],n[1],n[2])||1;return[n[0]/t,n[1]/t,n[2]/t]},Oo=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,o){let r=t-this.fx,s=e-this.fy,i=o-this.fz,a=r*this.rx+s*this.ry,l=r*this.ux+s*this.uy+i*this.uz,c=r*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,o){let r=t-this.fx,s=e-this.fy,i=o-this.fz,a=r*this.rx+s*this.ry,l=r*this.ux+s*this.uy+i*this.uz,c=r*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,o,r){if(this.fog<=0)return[t,e,o,1];let s=Math.max(0,Math.min(1,-r/this.depthRange*this.fog));return[t+(this.fogColor[0]-t)*s,e+(this.fogColor[1]-e)*s,o+(this.fogColor[2]-o)*s,1]}push(t,e){this.ops.push(t),this.depths.push(e)}};function ke(n,t,e,o,r=0,s="round"){return{kind:"path",path:n,strokePath:n,fill:null,fillAlpha:0,stroke:t,strokeAlpha:e,strokeWidth:o,cap:s,join:"round",dash:null,dashOffset:0,glow:r,glowColor:null,blend:"normal"}}function Me(n,t,e,o,r,s){return{kind:"path",path:n,strokePath:n,fill:t,fillAlpha:e,stroke:o,strokeAlpha:r,strokeWidth:s,cap:"round",join:"round",dash:null,dashOffset:0,glow:0,glowColor:null,blend:"normal"}}function xn(n,t,e,o){let r=e-n,s=o-t,i=new Float64Array(8);return i[0]=n,i[1]=t,i[2]=n+r/3,i[3]=t+s/3,i[4]=n+r*2/3,i[5]=t+s*2/3,i[6]=e,i[7]=o,{p:i,closed:!1,straight:!0}}function Io(n){let t=n.length/2,e=new Float64Array(2+t*6);e[0]=n[0],e[1]=n[1];let o=2;for(let r=0;r<t;r++){let s=n[r*2],i=n[r*2+1],a=n[(r+1)%t*2],l=n[(r+1)%t*2+1];e[o++]=s+(a-s)/3,e[o++]=i+(l-i)/3,e[o++]=s+(a-s)*2/3,e[o++]=i+(l-i)*2/3,e[o++]=a,e[o++]=l}return{p:e,closed:!0,straight:!0}}var ra=.5522847498307936;function us(n,t,e){let o=e*ra;return{closed:!0,p:Float64Array.of(n+e,t,n+e,t+o,n+o,t+e,n,t+e,n-o,t+e,n-e,t+o,n-e,t,n-e,t-o,n-o,t-e,n,t-e,n+o,t-e,n+e,t-o,n+e,t)}}var Et=class extends P{constructor(){super([])}labelsNow(t){return[]}objectAlpha(t){return t.alpha*this.get("opacity")}},Ao=class extends P{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,o,r)=>this.render(e,o,r),this.draw=e=>{let o=this.view(this.worldless,1,e);return this.children.flatMap(r=>r instanceof Et&&r.get("visible")?r.labelsNow(o):[])}}worldless=[1,0,0,1,0,0];view(t,e,o){let r=new Oo,s=this.phi.value,i=this.theta.value;for(let m of this.spins)o>m.from&&(i+=(Math.min(o,m.to)-m.from)*m.rate);let a=Math.sin(s),l=Math.cos(s),c=Math.sin(i),u=Math.cos(i);r.rx=-c,r.ry=u,r.ux=-l*u,r.uy=-l*c,r.uz=a,r.dx=a*u,r.dy=a*c,r.dz=l,r.fx=this.focusX.value,r.fy=this.focusY.value,r.fz=this.focusZ.value,r.distance=this.distance.value,r.unit=this.unit.value,r.perspective=!this.orthographic,r.matrix=t,r.alpha=e,r.scale=Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]));let h=cs(this.settings.light??[-.45,-.55,.85]);r.light=h,r.half=cs([h[0]+r.dx,h[1]+r.dy,h[2]+r.dz]),r.ambient=this.settings.ambient??.26,r.shine=this.settings.shine??.2,r.fog=this.settings.fog??.6;let d=Gt("bg");return r.fogColor=this.settings.fogColor?Ft(this.settings.fogColor):d,r.depthRange=Math.max(3,r.distance*.5),r.brightness=this.settings.brightness??(d[0]+d[1]+d[2]<200?.8:1),r}render(t,e,o){let r=C.now,s=this.view(t,e,r);for(let c of this.children)c instanceof Et&&c.get("visible")&&c.emit(s,r);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++)o.push(s.ops[a[c]])}orbit(t,e={}){return{label:"camera3d",duration:e.duration??2,ease:e.ease,schedule:o=>{t.phi!==void 0&&wt(this.phi,t.phi,o.t0,o.t1,o.ease),t.theta!==void 0&&wt(this.theta,t.theta,o.t0,o.t1,o.ease),t.distance!==void 0&&wt(this.distance,t.distance,o.t0,o.t1,o.ease),t.unit!==void 0&&wt(this.unit,t.unit,o.t0,o.t1,o.ease),t.focus&&(wt(this.focusX,t.focus[0],o.t0,o.t1,o.ease),wt(this.focusY,t.focus[1],o.t0,o.t1,o.ease),wt(this.focusZ,t.focus[2],o.t0,o.t1,o.ease))}}}spin(t=.12){return this.stopSpin(),this.openSpin={from:C.now,to:1/0,rate:t},this.spins.push(this.openSpin),this}stopSpin(){return this.openSpin&&(this.openSpin.to=C.now),this.openSpin=null,this}stagePoint(t){let e=this.view(this.worldMatrix(),1,C.now);return e.project(t[0],t[1],t[2])?[e.px,e.py]:[0,0]}};function Nh(n={}){return new Ao(n)}var je=class extends Et{constructor(e,o,r,s={}){super();this.fn=e;this.uRange=o;this.vRange=r;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=K(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:o,nv:r,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<=o;g++){let w=c[0]+(c[1]-c[0])*g/o;for(let x=0;x<=r;x++){let k=u[0]+(u[1]-u[0])*x/r,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=r+1,b=this.vertexNormals;b.fill(0);for(let g=0;g<o;g++)for(let w=0;w<r;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,O=s[M]-s[x],A=s[M+1]-s[x+1],R=s[M+2]-s[x+2],E=s[v]-s[k],$=s[v+1]-s[k+1],z=s[v+2]-s[k+2],D=A*z-R*$,B=R*E-O*z,G=O*$-A*E,U=Math.hypot(D,B,G)||1;if(D/=U,B/=U,G/=U,h.outwardFrom){let[V,F,T]=h.outwardFrom,I=(s[x]+s[M])/2-V,S=(s[x+1]+s[M+1])/2-F,L=(s[x+2]+s[M+2])/2-T;D*I+B*S+G*L<0&&(D=-D,B=-B,G=-G)}let N=(g*r+w)*3;i[N]=D,i[N+1]=B,i[N+2]=G;for(let V of[x/3,k/3,M/3,v/3])b[V*3]+=D,b[V*3+1]+=B,b[V*3+2]+=G;if(this.ramp||this.checkerColors||h.colorAt){let V;if(h.colorAt){let F=(s[x]+s[M])/2,T=(s[x+1]+s[M+1])/2,I=(s[x+2]+s[M+2])/2;V=h.colorAt(F,T,I,(g+.5)/o,(w+.5)/r)}else if(this.checkerColors)V=this.checkerColors[(g+w)%2];else{let F=(s[x+2]+s[M+2]+s[k+2]+s[v+2])/4;V=lt(this.ramp,p>m?(F-m)/(p-m):0)}a[N]=V[0],a[N+1]=V[1],a[N+2]=V[2]}}let y=this.shadingNormals;for(let g=0;g<o;g++)for(let w=0;w<r;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,O=0,A=0,R=0;for(let z of[x,k,M,v])O+=b[z],A+=b[z+1],R+=b[z+2];let E=Math.hypot(O,A,R)||1,$=(g*r+w)*3;y[$]=O/E,y[$+1]=A/E,y[$+2]=R/E}}emit(e,o){let{options:r,nu:s,nv:i,normals:a,shadingNormals:l,faceColors:c,screenX:u,screenY:h,screenZ:d,valid:m}=this,p=this.objectAlpha(e)*(r.opacity??1)*this.get("fillOpacity");if(p<=.002)return;(r.animate?this.computedFor!==o:this.computedFor===-1/0)&&(this.compute(r.animate?o:0),this.computedFor=o);let f=this.positions,b=i+1,y=(s+1)*(i+1);for(let F=0;F<y;F++){let T=F*3;e.project(f[T],f[T+1],f[T+2])?(u[F]=e.px,h[F]=e.py,d[F]=e.pz,m[F]=1):m[F]=0}let g=this.ramp||this.checkerColors||r.colorAt?null:se(this.get("fill")),w=r.shaded??!0,x=p>=.995,k=this.get("trimTo"),M=Math.ceil(k*s),{light:v,half:O,ambient:A,shine:R,brightness:E,dx:$,dy:z,dz:D}=e,B=r.cull??!1,G=this.meshColor,U=(r.meshOpacity??.35)*p,N=(r.meshWidth??1)*e.scale,V=.55*e.scale;for(let F=0;F<M;F++)for(let T=0;T<i;T++){let I=F*b+T,S=(F+1)*b+T,L=(F+1)*b+T+1,j=F*b+T+1;if(!m[I]||!m[S]||!m[L]||!m[j])continue;let J=(F*i+T)*3,at=a[J]*$+a[J+1]*z+a[J+2]*D;if(at<0&&B)continue;let tt=at<0?-1:1,ut=l[J]*tt,H=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]+H*v[1]+ct*v[2]),Xt=(A+(1-A)*Ut*Ut)*E,Zt=R>0?R*Math.pow(Math.max(0,ut*O[0]+H*O[1]+ct*O[2]),42)*255:0;mt=Math.min(255,mt*Xt+Zt),nt=Math.min(255,nt*Xt+Zt),ht=Math.min(255,ht*Xt+Zt)}let xt=(d[I]+d[S]+d[L]+d[j])/4,kt=e.fogged(mt,nt,ht,xt),q=u[I],ie=h[I],ve=u[S],Pe=h[S],Oe=u[L],Ae=h[L],Ne=u[j],Ce=h[j];if(x&&!G){let Ut=(q+ve+Oe+Ne)/4,Xt=(ie+Pe+Ae+Ce)/4,Zt=(fs,bs)=>V/(Math.hypot(fs-Ut,bs-Xt)||1),Vo=Zt(q,ie),Lo=Zt(ve,Pe),$o=Zt(Oe,Ae),Bo=Zt(Ne,Ce);q+=(q-Ut)*Vo,ie+=(ie-Xt)*Vo,ve+=(ve-Ut)*Lo,Pe+=(Pe-Xt)*Lo,Oe+=(Oe-Ut)*$o,Ae+=(Ae-Xt)*$o,Ne+=(Ne-Ut)*Bo,Ce+=(Ce-Xt)*Bo}let zo=Io([q,ie,ve,Pe,Oe,Ae,Ne,Ce]);e.push(G?Me([zo],kt,p,G,U,N):Me([zo],kt,p,null,0,0),xt)}}};function se(n){return n?Array.isArray(n)?n:Ft(n):[90,180,240,1]}function Ch(n,t,e,o={}){return new je(n,t,e,o)}function Sh(n,t={}){let e=t.x??[-4,4],o=t.y??[-4,4];return new je((r,s,i)=>[r,s,n(r,s,i)],e,o,{colors:t.color||t.checker||t.colorAt?void 0:["blue","teal","yellow"],...t})}function Rh(n=1,t={}){let[e,o,r]=t.center??[0,0,0];return new je((s,i)=>[e+n*Math.sin(i)*Math.cos(s),o+n*Math.sin(i)*Math.sin(s),r+n*Math.cos(i)],[0,Math.PI*2],[0,Math.PI],{cull:!0,resolution:[64,40],outwardFrom:[e,o,r],...t})}var He=1e6,No=class extends Et{constructor(e,o,r,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(o+(r-o)*a/i);this.points[a*3]=l,this.points[a*3+1]=c,this.points[a*3+2]=u}if(this.base.stroke=K(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 o=this.objectAlpha(e)*(this.style.opacity??1)*this.get("strokeOpacity");if(o<=.002)return;let r=this.get("trimTo"),s=this.points.length/3-1,i=Math.floor(r*s);if(i<1)return;let a=Math.max(2,Math.ceil(s/72)),l=this.get("stroke")??K("yellow"),c=this.get("strokeWidth")*e.scale,u=this.style.onTop?He: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(ke([hs(p)],w,o,c*b,h,"round"),f+u)}}};function hs(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 o=1;o<n.length;o++){let r=n[o-1],s=n[o];t[e++]=r[0]+(s[0]-r[0])/3,t[e++]=r[1]+(s[1]-r[1])/3,t[e++]=r[0]+(s[0]-r[0])*2/3,t[e++]=r[1]+(s[1]-r[1])*2/3,t[e++]=s[0],t[e++]=s[1]}return{p:t,closed:!1,straight:!0}}function Th(n,t,e,o={}){return new No(n,t,e,o)}var kn=class extends Et{constructor(e,o,r={}){super();this.a=e;this.b=o;this.style=r;this.base.stroke=K(r.color??"ink"),this.base.strokeWidth=r.width??2.5}a;b;style;emit(e){let o=this.objectAlpha(e)*(this.style.opacity??1)*this.get("strokeOpacity");if(o<=.002)return;let r=re(this.a),s=re(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?He:this.style.bias??0;for(let h=0;h<i;h++){let d=h/i*a,m=(h+1)/i*a;if(!e.project(r[0]+(s[0]-r[0])*d,r[1]+(s[1]-r[1])*d,r[2]+(s[2]-r[2])*d))continue;let p=e.px,f=e.py,b=e.pz,y=e.ps;if(!e.project(r[0]+(s[0]-r[0])*m,r[1]+(s[1]-r[1])*m,r[2]+(s[2]-r[2])*m))continue;let g=(b+e.pz)/2,w=e.fogged(l[0],l[1],l[2],g);e.push(ke([xn(p,f,e.px,e.py)],w,o,c*(y+e.ps)/2,0,"butt"),g+u)}}};function Fh(n,t,e={}){return new kn(n,t,e)}var Co=class extends kn{from3;to3;tipSize;constructor(t,e,o={}){super(t,()=>{let r=re(t),s=re(e),i=Math.hypot(s[0]-r[0],s[1]-r[1],s[2]-r[2])||1,a=Math.min(.9,.22/i);return[s[0]-(s[0]-r[0])*a,s[1]-(s[1]-r[1])*a,s[2]-(s[2]-r[2])*a]},{color:"yellow",width:4,...o}),this.from3=t,this.to3=e,this.tipSize=o.tip??24}emit(t){if(super.emit(t),this.get("trimTo")<.98)return;let o=re(this.from3),r=re(this.to3),s=this.objectAlpha(t);if(!t.project(o[0],o[1],o[2]))return;let i=t.px,a=t.py;if(!t.project(r[0],r[1],r[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=Io([l,c,l-m*f-p*b,c-p*f+m*b,l-m*f+p*b,c-p*f-m*b]);t.push(Me([w],g,s,null,0,0),u+.01)}};function Ih(n,t,e={}){return new Co(n,t,e)}var Mn=class extends Et{constructor(e,o={}){super();this.source=e;this.style=o;this.base.fill=K(o.color??"yellow")}source;style;emit(e){let o=this.objectAlpha(e)*(this.style.opacity??1)*this.get("fillOpacity");if(o<=.002)return;let r=typeof this.source=="function"?this.source():this.source,s=(this.style.radius??8)*e.scale,i=this.get("trimTo"),a=Math.ceil(r.length*i),l=se(this.get("fill")),c=this.style.onTop?He:0;for(let u=0;u<a;u++){let h=r[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(Me([us(e.px,e.py,p*(1+this.style.halo))],m,o*.18,null,0,0),e.pz+c-.001),e.push(Me([us(e.px,e.py,p)],m,o,null,0,0),e.pz+c)}}};function Eh(n,t={}){return new Mn(n,t)}function zh(n,t={}){return new Mn(()=>[re(n)],t)}var So=class extends Et{constructor(e,o,r,s={}){super();this.point=e;this.from=o;this.to=r;this.style=s;this.base.stroke=K(s.color??"yellow"),this.base.strokeWidth=s.width??3}point;from;to;style;cache=new Map;sample(e,o){let r=this.cache.get(e);if(r)return r;let s=C.now;C.now=this.from+e/o;let i=this.point();return C.now=s,C.mode==="render"&&this.cache.set(e,i),i}emit(e,o){if(o<=this.from)return;let r=this.objectAlpha(e)*(this.style.opacity??1),s=this.style.rate??30,i=Math.min(o,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?He:this.style.bias??0,f=(this.style.glow??0)*e.scale,b=Math.max(1,Math.ceil((u-c)/48));for(let y=c;y<u;y+=b){let g=[],w=0,x=0;for(let O=y;O<=Math.min(u,y+b);O++){let A=this.sample(O,s);e.project(A[0],A[1],A[2])&&(g.push([e.px,e.py]),w+=e.pz,x+=e.ps)}if(g.length<2)continue;w/=g.length,x/=g.length;let k=(y+b/2-c)/(u-c),M=m+(1-m)*Math.pow(k,1.6),v=e.fogged(d[0],d[1],d[2],w);e.push(ke([hs(g)],v,r*M,h*x,f,"butt"),w+p)}}};function Vh(n,t,e,o={}){return new So(n,t,e,o)}var Ro=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=K(e.color??"dim"),this.base.strokeWidth=e.width??2;let o=e.labelSize??34,r=e.labels===!1?null:Array.isArray(e.labels)?e.labels:["x","y","z"];if(this.tags=r?r.map(s=>st(s,{size:o,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 Ht(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:_(String(l),{size:18,color:"dim"}),at:c})}})}}options;ranges;step;tags;numberNodes=[];emit(e){let o=this.objectAlpha(e)*this.get("strokeOpacity");if(o<=.002)return;let r=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?He:this.options.bias??.4;this.ranges.forEach((c,u)=>{let h=a[u],d=16,m=c[0],p=m+(c[1]-m)*r;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(ke([xn(g,w,e.px,e.py)],e.fogged(s[0],s[1],s[2],k),o,i,0,"butt"),k+l)}if(this.options.ticks??!0)for(let f of Ht(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=xn(b-(u===2?w:0),y-(u===2?0:w),b+(u===2?w:0),y+(u===2?0:w));e.push(ke([x],e.fogged(s[0],s[1],s[2],g),o,i*.8,0,"butt"),g+l)}if(r>.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,O=Io([f,b,f-x*M-k*v,b-k*M+x*v,f-x*M+k*v,b-k*M-x*v]);e.push(Me([O],e.fogged(s[0],s[1],s[2],y),o,null,0,0),y+l)}}})}labelsNow(e){let o=this.get("opacity")*this.get("strokeOpacity");if(o<=.002||this.get("trimTo")<.9)return[];let r=[],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",o),r.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",o),r.push(i))}return r}};function Lh(n={}){return new Ro(n)}var To=class extends Et{constructor(e={}){super();this.options=e;this.base.stroke=K(e.color??"grid"),this.base.strokeWidth=e.width??1.2}options;emit(e){let o=this.objectAlpha(e)*(this.options.opacity??1)*this.get("strokeOpacity");if(o<=.002)return;let[r,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,O=e.pz;if(!e.project(p+(b-p)*k,f+(y-f)*k,l))continue;let A=(O+e.pz)/2;e.push(ke([xn(M,v,e.px,e.py)],e.fogged(u[0],u[1],u[2],A),o,h,0,"butt"),A-.05)}};for(let p of Ht(r,s,c))m(p,i,p,a);for(let p of Ht(i,a,c))m(r,p,s,p)}};function $h(n={}){return new To(n)}var Fo=class extends Et{constructor(e,o,r={}){super();this.position=o;this.content=typeof e=="string"?r.math===!1?_(e,{size:r.size??28,color:r.color??"ink"}):st(e,{size:r.size??32,color:r.color??"ink",display:!1}):e,this.offset=r.offset??[0,0]}position;content;offset;emit(){}labelsNow(e){let o=this.get("opacity");if(o<=.002)return[];let r=re(this.position),s=e.screen(r[0],r[1],r[2]);return s?(this.content.at(s[0]+this.offset[0],s[1]+this.offset[1]),this.content.set("opacity",o*this.get("trimTo")),[this.content]):[]}};function Bh(n,t,e={}){return new Fo(n,t,e)}var vn=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,o={}){this.canvas=t,this.film=e,this.options=o,this.speed=o.speed??1;let r=t.getContext("2d",{alpha:e.background===null});if(!r)throw new Error("This browser could not create a 2D canvas.");this.ctx=r,this.resize(),typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(()=>this.resize()),this.observer.observe(t)),this.paint(),o.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),o=t.width||this.film.width,r=Math.max(2,Math.round(o*e)),s=Math.max(2,Math.round(r*this.film.height/this.film.width));(this.canvas.width!==r||this.canvas.height!==s)&&(this.canvas.width=r,this.canvas.height=s,this.bloomLayers=[]),this.scale=r/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 o=this.currentTime,r=o+e*this.speed;if(this.options.stepped){let s=this.film.chapters.find(i=>i.time>o+.001&&i.time<=r);if(s){this.currentTime=s.time,this.paint(),this.options.onTime?.(this.currentTime),this.pause();return}}if(r>=this.film.duration)if(this.options.loop)r%=this.film.duration;else{this.currentTime=this.film.duration,this.paint(),this.options.onTime?.(this.currentTime),this.pause();return}this.currentTime=r,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 Nt){e.promise.then(()=>this.paint());return}throw e}Hn(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,o="filter"in this.ctx,r=[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",o&&(c.filter=`blur(${(r[l]*e/1920).toFixed(2)}px)`),c.drawImage(s,0,0,u.width,u.height),o&&(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 ds(n){let t=Math.floor(n/60),e=Math.floor(n%60);return`${t}:${String(e).padStart(2,"0")}`}var sa=`
|
|
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
|
+
canvas { display: block; width: 100%; height: 100%; }
|
|
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; }
|
|
8
|
+
:host(:hover) .chrome, :host(:focus-within) .chrome, :host([data-paused]) .chrome { opacity: 1; }
|
|
9
|
+
:host([nocontrols]) .chrome { display: none; }
|
|
10
|
+
button { all: unset; cursor: pointer; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; }
|
|
11
|
+
button:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
|
|
12
|
+
button:hover { background: rgba(255,255,255,.12); }
|
|
13
|
+
.track { position: relative; flex: 1; height: 16px; cursor: pointer; touch-action: none; }
|
|
14
|
+
.track::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 2px; background: rgba(255,255,255,.26); border-radius: 2px; }
|
|
15
|
+
.fill { position: absolute; left: 0; top: 7px; height: 2px; background: #f2efe6; border-radius: 2px; }
|
|
16
|
+
.tick { position: absolute; top: 4px; width: 1px; height: 8px; background: rgba(255,255,255,.55); }
|
|
17
|
+
.time { font-variant-numeric: tabular-nums; opacity: .82; white-space: nowrap; }
|
|
18
|
+
svg { width: 14px; height: 14px; fill: currentColor; }
|
|
19
|
+
`,ms='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2.5v11l9-5.5z"/></svg>',ia='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2.5h3v11H4zM9 2.5h3v11H9z"/></svg>',aa='<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 Eo(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 r=this.shadowRoot??this.attachShadow({mode:"open"}),s=this.getAttribute("label")??"Animation";r.innerHTML=`<style>${sa}</style><canvas role="img"></canvas><div class="chrome"><button class="toggle" type="button" aria-label="Play">${ms}</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">${aa}</button></div>`,r.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 r=this.getAttribute("src");if(!r)return;let s=this.shadowRoot,i;try{i=await n(r,{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 ${r}:`,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=`${ds(g)} / ${ds(i.duration)}`,h.setAttribute("aria-valuenow",String(Math.round(g))),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:g}}))},f=new vn(a,i,{loop:this.hasAttribute("loop"),stepped:this.hasAttribute("stepped"),onTime:p,onState:({playing:g})=>{l.innerHTML=g?ia:ms,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)}Xn(new URL("../../assets/",import.meta.url).href);var ps=new Map;function la(n,t={}){let e=new URL(n,document.baseURI).href,o=`${e}|${t.look??""}|${t.background??""}`,r=ps.get(o);return r||(r=import(e).then(s=>{if(!Fe(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(o,r)),r}Eo(la);export{bo as ArrayCells,Un as Axes,Ro as Axes3D,io as BarChart,vo as Callout,go as CodeBlock,an as CompiledFilm,Qn as ComplexPlane,Mo as Connector,Ge as Counter,No as Curve3D,ws as EMPTY_BOUNDS,ro as Epicycles,vn as FilmPlayer,bn as Graph,po as GraphEdge,mo as GraphNode,To as GridPlane3D,We as Heatmap,ao as Histogram,zt as IDENTITY,ko as InfoBox,Yo as LOOKS,Fo as Label3D,oo as LabeledDot,kn as Line3D,co as LineChart,no as MatrixNode,yo as NeuralNet,P as Node,Jn as NumberLine,Ve as NumberPlane,Et as Object3D,fn as PieChart,Mn as Points3D,lo as Scatter,Ao as Scene3D,sn as Stage,eo as StreamLines,je as Surface3D,Nt as Suspend,wn as SvgNode,un as TexNode,cn as TextNode,wo as TokenRow,So as Trail3D,fo as TreeGraph,pt as Value,Co as Vector3D,to as VectorField,Oo as View3D,ml as along,Kc as angleMark,il as appear,Q as apply,$c as applyComplex,pl as applyMatrix,rc as arc,St as arcPath,jc as areaUnder,Eu as arrayCells,ze as arrow,Bu as attentionMatrix,dc as axes,Lh as axes3d,du as barChart,Os as blueprint,Aa as bounce,Lr as brace,Uc as braceLabel,Gn as buildOps,Qa as call,Zu as callout,As as chalk,Di as checkFilm,zr as circle,Dt as circlePath,yl as circumscribe,zu as codeBlock,Is as colorAlong,ln as compileFilm,Bc as complex,Lc as complexPlane,fe as compose,ca as concat,qu as connector,uh as countUp,ch as counter,Yt as css,Fa as cubicBezier,ec as curve,Th as curve3d,be as curveThrough,Xc as dashedGuides,pc as decimal,Eo as defineFilmElement,Ja as delay,gu as donut,gt as dot,tl as draw,Ta as during,At as dynamic,pa as easeInCubic,xa as easeInExpo,ba as easeInOutCubic,ya as easeInOutQuint,da as easeInQuad,fa as easeOutCubic,wa as easeOutExpo,ma as easeOutQuad,ga as easeOutQuint,oc as ellipse,nu as epicycles,nl as erase,dl as fade,ol as fadeIn,rl as fadeOut,ii as film,wl as flash,Ie as fontFor,tu as fourier,Zr as fourierPoint,ri as frameInkBounds,jn as frameToSvg,oa as fromSvg,Ee as glyphPath,Fu as graph,$h as gridPlane3d,Vn as group,sl as grow,yu as heatmap,mh as highlightSweep,mu as histogram,bl as indicate,Yu as infoBox,Wt as invert,Fe as isFilm,_n as isSuspend,Bh as label3d,Jc as labeledDot,Za as lagged,Uu as legend,Y as line,Fh as line3d,fu as lineChart,le as linePath,Re as linear,Ts as linearGradient,Sa as lingering,la as loadFilm,Kt as matScale,qc as matrix,Ye as midnight,he as mixColor,fl as morph,Vu as morphCode,we as morphMatching,ll as moveTo,ot as mul,Ns as neon,Lu as neuralNet,Ca as notQuiteThere,Vc as numberLine,Pa as overshoot,Hn as paintFrame,Ps as paper,Ln as par,nc as parametric,_e as parametricPath,Ch as parametricSurface,Gt as parseColor,Rr as parseFont,vt as parseSvgPath,bt as pathBounds,Ot as pathLength,Xo as pathToD,bu as pie,mc as plane,zh as point3d,Pt as pointAt,Eh as points3d,Z as polyPath,ki as polygon,tc as polyline,Bn as pulse,Fs as radialGradient,Te as ramp,lr as recolor,Vr as rect,X as rectPath,sc as regularPolygon,qe as resolveLook,Ds as retime,Nn as reverseRing,Gc as riemann,Yc as rightAngle,Mt as ring,ue as ringCenter,Se as ringLength,ou as ringThrough,xl as ripple,hl as rotate,Ra as runningStart,Ma as rushFrom,ka as rushInto,eu as samplePath,ul as scaleBy,pu as scatter,Nh as scene3d,_c as secantLine,Vt as segmentCount,rr as seq,Xn as setAssetBase,gl as shake,xi as shape,cl as shift,ce as signedArea,va as slowInto,dt as smooth,vs as smoothBy,Lt as smoothPath,ha as smoother,Ui as sparkline,Rh as sphere,hh as spin,Oa as spring,Dc as streamLines,An as subdivideEach,Sh as surface,Zc as surroundingBox,Ql as svgPath,dh as swap,ge as tangentAt,Hc as tangentLine,st as tex,_ as text,Rn as thereAndBack,Na as thereAndBackWithPause,de as to,K as toPaint,Yi as tokenize,$u as tokens,Qc as traced,Vh as trail3d,rt as transformPath,Iu as tree,Jt as trimPath,Do as trimRing,ah as typewriter,Ke as unionBounds,al as vanish,Ih as vector3d,Wc as vectorField,$n as warp,Ho as warpPath,Ko as wiggle,lh as wipe,el as write};
|