@weasel-js/headless 1.15.1 → 1.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/page.global.js +79 -79
  2. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
- "use strict";(()=>{var UH=Object.create;var ry=Object.defineProperty;var VH=Object.getOwnPropertyDescriptor;var WH=Object.getOwnPropertyNames;var zH=Object.getPrototypeOf,KH=Object.prototype.hasOwnProperty;var Z=(e,t)=>()=>(e&&(t=e(e=0)),t);var jH=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),$H=(e,t)=>{for(var n in t)ry(e,n,{get:t[n],enumerable:!0})},YH=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of WH(t))!KH.call(e,o)&&o!==n&&ry(e,o,{get:()=>t[o],enumerable:!(r=VH(t,o))||r.enumerable});return e};var qH=(e,t,n)=>(n=e!=null?UH(zH(e)):{},YH(t||!e||!e.__esModule?ry(n,"default",{value:e,enumerable:!0}):n,e));function ll(e){return e>0?1:e<0?-1:0}var FS=Z(()=>{"use strict"});function ad(e,t){return[1,0,0,1,e,t]}function ul(e){let t=Math.cos(e),n=Math.sin(e);return[t,n,-n,t,0,0]}function ht(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function cr(e){let t=e[0]*e[3]-e[1]*e[2],n=Math.max(e[0]*e[0]+e[1]*e[1],e[2]*e[2]+e[3]*e[3]);if(!(Math.abs(t)>1e-12*n))return null;let r=1/t,o=e[3]*r,i=-e[1]*r,s=-e[2]*r,a=e[0]*r;return[o,i,s,a,-(e[4]*o+e[5]*s),-(e[4]*i+e[5]*a)]}function xn(e,t,n){return[e[0]*t+e[2]*n+e[4],e[1]*t+e[3]*n+e[5]]}function dr(e,t,n,r,o,i,s,a){let l=n===0?1:s/n,u=r===0?1:a/r;return[l,0,0,u,o-e*l,i-t*u]}function Zr(e,t,n){return ht(ad(e,t),ht(ul(n),ad(-e,-t)))}function By(e,t){let n=new Float64Array(e.length),r=t[0],o=t[1],i=t[2],s=t[3],a=t[4],l=t[5];for(let u=0;u+1<e.length;u+=2){let c=e[u],d=e[u+1];n[u]=r*c+i*d+a,n[u+1]=o*c+s*d+l}return n}var ts=Z(()=>{"use strict"});function ld(e,t){return t[0]>=e[0]&&t[1]>=e[1]&&t[2]<=e[2]&&t[3]<=e[3]}function cl(e,t,n,r){return Float64Array.of(e,t,e+n,t,e+n,t+r,e,t+r)}var ud=Z(()=>{"use strict"});function _G(){let e=[];for(let{code:t,coords:n}of Object.values(qo))e[t]=n;return e}function eo(e){return LS[e]}function Ge(e,t,n){let r=0,o=0,i=0,s=0,a=0,l=!1;for(let u=0;u<e.length;u++){let c=e[u],d=!l&&c!==le&&c!==fe;if(d&&(s=o,a=i),l=c!==fe,n(c,r,o,i,u,d)===!1)return;let f=eo(c);if(f===void 0)throw new Error(`forEachSegment: unknown command code ${c}`);f>0?(o=t[r+f-2],i=t[r+f-1],r+=f,c===le&&(s=o,a=i)):c===fe&&(o=s,i=a)}}var qo,le,ce,xe,we,fe,LS,Je=Z(()=>{"use strict";qo={M:{code:0,coords:2},L:{code:1,coords:2},C:{code:2,coords:6},Q:{code:3,coords:4},Z:{code:4,coords:0}},le=qo.M.code,ce=qo.L.code,xe=qo.C.code,we=qo.Q.code,fe=qo.Z.code,LS=_G()});function We(e,t,n,r,o,i,s,a,l){let u=1-l,c=u*u*u,d=3*u*u*l,f=3*u*l*l,p=l*l*l;return[c*e+d*n+f*o+p*s,c*t+d*r+f*i+p*a]}function to(e,t,n,r,o,i){return[e+2/3*(n-e),t+2/3*(r-t),o+2/3*(n-o),i+2/3*(r-i)]}function _S(e,t,n,r){let o=-e+3*t-3*n+r,i=2*(e-2*t+n),s=-e+t,a=[],l=u=>{u>0&&u<1&&a.push(u)};if(Math.abs(o)<1e-12)Math.abs(i)>1e-12&&l(-s/i);else{let u=i*i-4*o*s;if(u>=0){let c=Math.sqrt(u);l((-i+c)/(2*o)),l((-i-c)/(2*o))}}return a}function Hy(e,t,n,r,o,i,s,a){let l=Math.min(e,s),u=Math.max(e,s),c=Math.min(t,a),d=Math.max(t,a);for(let f of _S(e,n,o,s)){let[p]=We(e,t,n,r,o,i,s,a,f);p<l&&(l=p),p>u&&(u=p)}for(let f of _S(t,r,i,a)){let[,p]=We(e,t,n,r,o,i,s,a,f);p<c&&(c=p),p>d&&(d=p)}return[l,c,u,d]}function no(e,t,n,r,o,i,s,a,l){let u=e+(n-e)*l,c=t+(r-t)*l,d=n+(o-n)*l,f=r+(i-r)*l,p=o+(s-o)*l,h=i+(a-i)*l,m=u+(d-u)*l,g=c+(f-c)*l,b=d+(p-d)*l,x=f+(h-f)*l,w=m+(b-m)*l,y=g+(x-g)*l;return[[e,t,u,c,m,g,w,y],[w,y,b,x,p,h,s,a]]}function DS(e,t,n,r,o,i,s){let a=e+(n-e)*s,l=t+(r-t)*s,u=n+(o-n)*s,c=r+(i-r)*s,d=a+(u-a)*s,f=l+(c-l)*s;return[[e,t,a,l,d,f],[d,f,u,c,o,i]]}var wn=Z(()=>{"use strict"});function dl(e,t,n,r,o,i){let s=o-n,a=i-r,l=s*s+a*a,u=l===0?0:((e-n)*s+(t-r)*a)/l;u=u<0?0:u>1?1:u;let c=u===1?o:n+u*s,d=u===1?i:r+u*a;return{x:c,y:d,t:u,dist:Math.hypot(e-c,t-d)}}function fl(e,t,n,r,o,i,s,a,l,u){let c=-n+3*o-3*s+l,d=-r+3*i-3*a+u,f=3*n-6*o+3*s,p=3*r-6*i+3*a,h=3*(o-n),m=3*(i-r),g=S=>{let[v,A]=We(n,r,o,i,s,a,l,u,S);return(v-e)**2+(A-t)**2},b=[];for(let S=0;S<=ro;S++)b.push(g(S/ro));let x=0,w=b[0];for(let S=0;S<=ro;S++){let v=b[S],A=S>0?b[S-1]:1/0,N=S<ro?b[S+1]:1/0;if(!(v<=A&&v<=N))continue;let M=Math.max(0,(S-1)/ro),C=Math.min(1,(S+1)/ro),F=S/ro;for(let V=0;V<DG;V++){let J=F*F,se=c*J*F+f*J+h*F+n-e,ke=d*J*F+p*J+m*F+r-t,ae=3*c*J+2*f*F+h,ve=3*d*J+2*p*F+m,G=6*c*F+2*f,K=6*d*F+2*p,$=se*ae+ke*ve,Q=ae*ae+ve*ve+se*G+ke*K;if($>0)C=F;else if($<0)M=F;else break;let te=Q>0?F-$/Q:NaN;te>M&&te<C||(te=(M+C)/2);let he=Math.abs(te-F);if(F=te,he<BS||C-M<BS)break}let B=g(F),[D,j]=B<=v?[F,B]:[S/ro,v];j<w&&(w=j,x=D)}let[y,P]=We(n,r,o,i,s,a,l,u,x);return{x:y,y:P,t:x,dist:Math.hypot(y-e,P-t)}}function HS(e,t,n,r,o,i,s,a){let[l,u,c,d]=to(n,r,o,i,s,a);return fl(e,t,n,r,l,u,c,d,s,a)}var ro,DG,BS,Gy=Z(()=>{"use strict";wn();ro=32,DG=40,BS=1e-14});function $e(e){return e.origin?GS(e,Float64Array.from(e.coords)):e.coords}function GS(e,t){let n=e.origin;if(n===void 0)return t;for(let r=0;r+1<t.length;r+=2)t[r]+=n.x,t[r+1]+=n.y;return t}function vt(e,t){let n=e?.x??0,r=e?.y??0,o=new Float32Array(t.length);for(let i=0;i+1<t.length;i+=2)o[i]=t[i]-n,o[i+1]=t[i+1]-r;return o}function Pn(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let s=0;s+1<e.length;s+=2){let a=e[s],l=e[s+1];a<t&&(t=a),a>r&&(r=a),l<n&&(n=l),l>o&&(o=l)}let i=Math.max(Math.abs(t),Math.abs(r),Math.abs(n),Math.abs(o));if(!(!(i>=US)||!Number.isFinite(i)))return{x:Math.round((t+r)/2),y:Math.round((n+o)/2)}}function Uy(e){let t=0,n=0;for(let l of e)t+=l.commands.length,n+=l.coords.length;let r=e[0]?.origin,o=new Uint8Array(t),i=new Float32Array(n),s=0,a=0;for(let l of e)o.set(l.commands,s),s+=l.commands.length,i.set(l.origin===r?l.coords:vt(r,$e(l)),a),a+=l.coords.length;return{kind:"polygon",commands:o,coords:i,fillRule:"nonzero",...r?{origin:r}:{}}}var uQ,US,Zt=Z(()=>{"use strict";uQ=Object.freeze({x:0,y:0});US=16384});function WS(e,t,n,r){return{kind:"rect",x:e,y:t,width:n,height:r}}function cd(e){let t=new _e,n=e[0];if(!n)return WS(0,0,0,0);t.moveTo(n.x,n.y);for(let r=1;r<e.length;r++){let o=e[r];o&&t.lineTo(o.x,o.y)}return t.build()}function Vy(e,t={}){if(e.length===0)return{kind:"polygon",commands:new Uint8Array,coords:new Float32Array,fillRule:t.fillRule??"nonzero"};let n=new _e;t.fillRule&&n.setFillRule(t.fillRule),n.moveTo(e[0].x,e[0].y);for(let r=1;r<e.length;r++)n.lineTo(e[r].x,e[r].y);return n.close(),n.build()}function Wy(e){let t=e.x+e.width/2,n=e.y+e.height/2,r=e.width/2,o=e.height/2,i=r*VS,s=o*VS,a=new _e;return a.moveTo(t+r,n),a.curveTo(t+r,n+s,t+i,n+o,t,n+o),a.curveTo(t-i,n+o,t-r,n+s,t-r,n),a.curveTo(t-r,n-s,t-i,n-o,t,n-o),a.curveTo(t+i,n-o,t+r,n-s,t+r,n),a.close(),a.build()}function zy(e,t,n,r=0){let o=new _e;for(let i=0;i<n;i++){let s=r+i/n*Math.PI*2,a=e.x+t*Math.cos(s),l=e.y+t*Math.sin(s);i===0?o.moveTo(a,l):o.lineTo(a,l)}return o.close(),o.build()}function Ky(e,t,n=5,r=t/2,o=0){let i=new _e,s=n*2;for(let a=0;a<s;a++){let l=o+a/s*Math.PI*2,u=a%2===0?t:r,c=e.x+u*Math.cos(l),d=e.y+u*Math.sin(l);a===0?i.moveTo(c,d):i.lineTo(c,d)}return i.close(),i.build()}function jy(e,t){let n=new _e;return n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.build()}var _e,VS,fr=Z(()=>{"use strict";Je();Zt();_e=class e{cmds=[];xs=[];fillRule="nonzero";origin;auto=!1;static fromPath(t){let n=new e;return n.cmds=Array.from(t.commands),n.xs=Array.from(t.coords),n.fillRule=t.fillRule,t.origin&&(n.origin={x:t.origin.x,y:t.origin.y}),n}setOrigin(t,n){let r=this.origin?.x??0,o=this.origin?.y??0;for(let i=0;i<this.xs.length;i+=2)this.xs[i]+=r-t,this.xs[i+1]+=o-n;return this.origin=t===0&&n===0?void 0:{x:t,y:n},this}autoOrigin(){return this.auto=!0,this}push(...t){let n=this.origin?.x??0,r=this.origin?.y??0;for(let o=0;o<t.length;o+=2)this.xs.push(t[o]-n,t[o+1]-r)}setFillRule(t){return this.fillRule=t,this}moveTo(t,n){return this.cmds.push(le),this.push(t,n),this}lineTo(t,n){return this.cmds.push(ce),this.push(t,n),this}curveTo(t,n,r,o,i,s){return this.cmds.push(xe),this.push(t,n,r,o,i,s),this}quadTo(t,n,r,o){return this.cmds.push(we),this.push(t,n,r,o),this}close(){return this.cmds.push(fe),this}build(){if(this.auto&&!this.origin){let t=Pn(this.xs);t&&this.setOrigin(t.x,t.y)}return{kind:"polygon",commands:new Uint8Array(this.cmds),coords:new Float32Array(this.xs),fillRule:this.fillRule,...this.origin?{origin:{...this.origin}}:{}}}};VS=.5522847498307936});function $y(e,t){let n=e.corners?.[t];return n&&n.radius>0?n:null}function dd(e){let t=e.corners;if(!t)return!1;for(let n of t)if(n&&n.radius>0)return!0;return!1}function fd(e){let t=e.length;for(;t>0&&!e[t-1];)t--;if(t===0)return;let n=new Array(t);for(let r=0;r<t;r++)n[r]=e[r]??null;return n}function Xo(e){if(e.corners===void 0)return e;let{corners:t,...n}=e;return n}function Yy(e,t){return!e.corners||t===1?e:{...e,corners:e.corners.map(n=>n?{shape:n.shape,radius:n.radius*t}:null)}}function qy(e,t,n){if(!e&&!t)return;let r=Math.max(e?.length??0,t?.length??0),o=new Array(r);for(let i=0;i<r;i++){let s=e?.[i]??null,a=t?.[i]??null,l=s??a;l?s&&a&&s.shape!==a.shape?o[i]=n<.5?s:a:o[i]={shape:l.shape,radius:(s?.radius??0)+((a?.radius??0)-(s?.radius??0))*n}:o[i]=null}return fd(o)}var pl=Z(()=>{"use strict"});function zS(e,t,n,r,o){let[i,s]=We(e.x,e.y,t.x,t.y,n.x,n.y,r.x,r.y,o);return{x:i,y:s}}var KS=Z(()=>{"use strict";wn()});function $S(e,t,n,r={}){let{cp1:o,cp2:i}=BG(e,t,n,r.passes??4,r.params);return{cp1:o,cp2:i}}function BG(e,t,n,r,o){let i=e.length,s=e[0],a=e[i-1],l=o?[...o]:HG(e);if(l===null)return{cp1:{...s},cp2:{...a},end:a,ts:e.map(()=>0)};let u=jS(e,l,s,a,t,n);for(let c=0;c<r;c++)GG(e,l,s,a,u),u=jS(e,l,s,a,t,n);return u}function HG(e){let t=e.length,n=new Array(t);n[0]=0;let r=0;for(let o=1;o<t;o++)r+=Xy(e[o-1],e[o]),n[o]=r;if(r===0)return null;for(let o=0;o<t;o++)n[o]/=r;return n}function jS(e,t,n,r,o,i){let s=e.length,a=0,l=0,u=0,c=0,d=0;for(let m=0;m<s;m++){let g=t[m],b=1-g,x=b*b*b,w=3*b*b*g,y=3*b*g*g,P=g*g*g,S=w*o.x,v=w*o.y,A=y*i.x,N=y*i.y;a+=S*S+v*v,l+=S*A+v*N,u+=A*A+N*N;let M=e[m].x-(x+w)*n.x-(y+P)*r.x,C=e[m].y-(x+w)*n.y-(y+P)*r.y;c+=S*M+v*C,d+=A*M+N*C}let f=a*u-l*l,p,h;return Math.abs(f)<1e-12?p=h=Xy(n,r)/3:(p=(u*c-l*d)/f,h=(a*d-l*c)/f,(p<1e-6||h<1e-6)&&(p=h=Xy(n,r)/3)),{cp1:{x:n.x+o.x*p,y:n.y+o.y*p},cp2:{x:r.x+i.x*h,y:r.y+i.y*h},end:r,ts:t}}function GG(e,t,n,r,o){for(let i=1;i<e.length-1;i++)t[i]=UG(e[i],t[i],e[0],o.cp1,o.cp2,e[e.length-1])}function UG(e,t,n,r,o,i){let s=1-t,{x:a,y:l}=zS(n,r,o,i,t),u=3*s*s*(r.x-n.x)+6*s*t*(o.x-r.x)+3*t*t*(i.x-o.x),c=3*s*s*(r.y-n.y)+6*s*t*(o.y-r.y)+3*t*t*(i.y-o.y),d=6*s*(o.x-2*r.x+n.x)+6*t*(i.x-2*o.x+r.x),f=6*s*(o.y-2*r.y+n.y)+6*t*(i.y-2*o.y+r.y),p=a-e.x,h=l-e.y,m=p*u+h*c,g=u*u+c*c+p*d+h*f;if(Math.abs(g)<1e-12)return t;let b=t-m/g;return b<0?0:b>1?1:b}function Xy(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}var YS=Z(()=>{"use strict";KS()});function ZS(e){return typeof e=="number"?e:VG[e]}function WG(e){let t=2**Math.abs(e);return 1-.5**(1/t)<ek/4?1/0:t}function hd(e,t){let n=2/e;return{x:Math.cos(t)**n,y:Math.sin(t)**n}}function XS(e,t){let n=2-2/e,r=Math.sin(t)**n,o=-(Math.cos(t)**n),i=Math.hypot(r,o);return{x:r/i,y:o/i}}function zG(e,[t,n,r],o){let i=1-o,s=i*i*i,a=3*i*i*o,l=3*i*o*o,u=o*o*o;return{x:s*e.x+a*t.x+l*n.x+u*r.x,y:s*e.y+a*t.y+l*n.y+u*r.y}}function KG(e,t,n){let r=a=>{let l=zG(t,n,a);return Math.hypot(l.x-e.x,l.y-e.y)},o=0;for(let a=1;a<=32;a++)r(a/32)<r(o/32)&&(o=a);let i=Math.max(0,(o-1)/32),s=Math.min(1,(o+1)/32);for(let a=0;a<30;a++){let l=i+(s-i)/3,u=s-(s-i)/3;r(l)<r(u)?s=u:i=l}return r((i+s)/2)}function jG(e,t,n,r,o){let i=0;for(let s=1;s<16;s++)i=Math.max(i,KG(hd(e,t+(n-t)*(s/16)),r,o));return i}function Jy(e,t,n,r,o,i){let s=hd(e,t),a=hd(e,n),l=[],u=[];for(let m=0;m<=12;m++)l.push(hd(e,t+(n-t)*(m/12))),u.push(m/12);let c=XS(e,n),{cp1:d,cp2:f}=$S(l,XS(e,t),{x:-c.x,y:-c.y},{params:u}),p=[d,f,a];if(o>=10||jG(e,t,n,s,p)<=r){i.push(p);return}let h=(t+n)/2;Jy(e,t,h,r,o+1,i),Jy(e,h,n,r,o+1,i)}function $G(e,t){if(e===2)return[[{x:qS,y:1},{x:1,y:qS},{x:1,y:0}]];let n=`${e}:${t}`,r=pd.get(n);return r||(r=[],Jy(e,Math.PI/2,0,t,0,r),pd.size>256&&pd.clear(),pd.set(n,r)),r}function YG(e,t){let n=JS(e.end,t),r=JS(e.start,t);return o=>({x:t.x+o.x*n.x+o.y*r.x,y:t.y+o.x*n.y+o.y*r.y})}function QS(e){return{x:e.start.x+e.end.x-e.outer.x,y:e.start.y+e.end.y-e.outer.y}}function tk(e,t,n=ek){if(e===0)return[{kind:"line",to:t.end}];let r=WG(e);if(r===1/0)return[{kind:"line",to:e>0?t.outer:QS(t)},{kind:"line",to:t.end}];let o=YG(t,e>0?QS(t):t.outer);return $G(r,n).map(([i,s,a])=>({kind:"cubic",c1:o(i),c2:o(s),to:o(a)}))}var VG,ek,qS,JS,pd,nk=Z(()=>{"use strict";YS();VG={square:1/0,squircle:2,round:1,bevel:0,scoop:-1,notch:-1/0};ek=.001,qS=4/3*Math.tan(Math.PI/8);JS=(e,t)=>({x:e.x-t.x,y:e.y-t.y});pd=new Map});function ml(e){let{commands:t}=e,n=$e(e),r=[],o=null,i=0,s=0,a=!1,l=()=>o.anchors[o.anchors.length-1],u=(c,d)=>{o.segs.push(d),o.anchors.push(c),o.sources.push(s++),i++};return Ge(t,n,(c,d,f,p,h,m)=>{if(m)return a=!0,!1;let g=b=>({x:n[d+b],y:n[d+b+1]});switch(c){case le:o&&r.push(o),o={anchors:[g(0)],segs:[],closed:!1,first:i++,sources:[s++]};break;case ce:u(g(0),ok(l(),g(0)));break;case xe:u(g(4),{line:!1,p0:l(),c1:g(0),c2:g(2),p3:g(4)});break;case we:{let b=l(),x=g(0),w=g(2),y={x:b.x+2/3*(x.x-b.x),y:b.y+2/3*(x.y-b.y)},P={x:w.x+2/3*(x.x-w.x),y:w.y+2/3*(x.y-w.y)};u(w,{line:!1,p0:b,c1:y,c2:P,p3:w});break}case fe:o&&qG(o,()=>i--),o&&r.push(o),o=null;break}}),a?null:(o&&r.push(o),r)}function qG(e,t){e.closed=!0;let n=e.anchors.length,r=e.anchors[0],o=e.anchors[n-1];if(n>1&&!e.segs[n-2].line&&o.x===r.x&&o.y===r.y){e.anchors.pop(),e.sources.pop(),t();return}e.segs.push(ok(o,r))}function md(e){return e.line?Math.hypot(e.p3.x-e.p0.x,e.p3.y-e.p0.y):ik(e)[hl]}function ik(e){let t=rk.get(e);if(t)return t;t=new Float64Array(hl+1);let n=e.p0;for(let r=1;r<=hl;r++){let o=rs(e,r/hl);t[r]=t[r-1]+Math.hypot(o.x-n.x,o.y-n.y),n=o}return rk.set(e,t),t}function Qy(e,t){let n=md(e);if(n<=0)return 0;if(e.line)return Math.min(1,Math.max(0,t/n));let r=ik(e);if(t<=0)return 0;if(t>=n)return 1;let o=1;for(;r[o]<t;)o++;let i=r[o]-r[o-1],s=i>0?(t-r[o-1])/i:0;return(o-1+s)/hl}function rs(e,t){if(e.line)return{x:e.p0.x+(e.p3.x-e.p0.x)*t,y:e.p0.y+(e.p3.y-e.p0.y)*t};let{p0:n,c1:r,c2:o,p3:i}=e,[s,a]=We(n.x,n.y,r.x,r.y,o.x,o.y,i.x,i.y,t);return{x:s,y:a}}function ns(e,t){let n=Math.hypot(e,t);return n>1e-12?{x:e/n,y:t/n}:null}function yl(e,t){let{p0:n,c1:r,c2:o,p3:i}=e;if(e.line)return ns(i.x-n.x,i.y-n.y);let s=1-t,a=3*(s*s*(r.x-n.x)+2*s*t*(o.x-r.x)+t*t*(i.x-o.x)),l=3*(s*s*(r.y-n.y)+2*s*t*(o.y-r.y)+t*t*(i.y-o.y)),u=ns(a,l);return u||(t<.5?ns(o.x-n.x,o.y-n.y)??ns(i.x-n.x,i.y-n.y):ns(i.x-r.x,i.y-r.y)??ns(i.x-n.x,i.y-n.y))}function sk(e,t,n){let{p0:r,c1:o,c2:i,p3:s}=e,a=[r.x,r.y,o.x,o.y,i.x,i.y,s.x,s.y];t>0&&(a=[...no(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],t)[1]]);let l=t<1?(n-t)/(1-t):1;return l<1&&(a=[...no(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],l)[0]]),[{x:a[2],y:a[3]},{x:a[4],y:a[5]},{x:a[6],y:a[7]}]}var ok,hl,rk,Zy=Z(()=>{"use strict";Je();wn();Zt();ok=(e,t)=>({line:!0,p0:e,c1:e,c2:t,p3:t});hl=32;rk=new WeakMap});function uk(e,t){let n=t.anchors.length,r=t.segs.map(md),o=t.anchors.map((s,a)=>{let l=a>0?t.segs[a-1]:t.closed?t.segs[n-1]:null,u=a<t.segs.length?t.segs[a]:null;if(!l||!u||l===u)return null;let c=yl(l,1),d=yl(u,0);if(!c||!d)return null;let f=Math.acos(Math.max(-1,Math.min(1,c.x*d.x+c.y*d.y)));if(f<ak||f>Math.PI-ak)return null;let p=d.x-c.x,h=d.y-c.y,m=Math.hypot(p,h),g=(Math.PI-f)/2,b=$y(e,t.first+a),x=b?b.radius:0;return{frame:{index:t.first+a,x:s.x,y:s.y,bisector:{x:p/m,y:h/m},halfAngle:g},spec:b,want:x,trim:x}}),i=o.map(()=>1);return t.segs.forEach((s,a)=>{let l=a,u=(a+1)%n,c=(o[l]?.want??0)+(o[u]?.want??0);if(c<=r[a])return;let d=r[a]/c;i[l]=Math.min(i[l],d),i[u]=Math.min(i[u],d)}),o.forEach((s,a)=>{s&&(s.trim=s.want*i[a])}),o}function os(e){if(e.corners===void 0)return{path:e,anchorSources:null};let t=lk.get(e);if(t)return t;let n=dd(e)?XG(e):{path:Xo(e),anchorSources:null};return lk.set(e,n),n}function Qe(e){return e.kind!=="polygon"?e:os(e).path}function gl(e,t,n){let r=new Array(t.length*n);for(let o=0;o<t.length;o++)for(let i=0;i<n;i++)r[o*n+i]=e[t[o]*n+i];return r}function XG(e){let t=ml(e);if(!t)return{path:Xo(e),anchorSources:null};let n=new eg;e.origin&&n.b.setOrigin(e.origin.x,e.origin.y);for(let i of t)JG(n,i,uk(e,i));let{commands:r,coords:o}=n.b.build();return{path:{...Xo(e),commands:r,coords:o},anchorSources:Uint32Array.from(n.sources)}}function ck(e,t,n){let r=e.segs[n],o=md(r),i=Qy(r,t[n]?.trim??0),s=Qy(r,o-(t[(n+1)%e.anchors.length]?.trim??0));return[i,Math.max(i,s)]}function dk(e,t,n,r){let o=(r+1)%e.anchors.length,i=t[o],s=e.segs[o];if(!i?.spec||i.trim<=0||!s)return null;let a=e.segs[r],l=rs(a,n[r][1]),u=rs(s,n[o][0]),c=QG({x:i.frame.x,y:i.frame.y},l,yl(a,n[r][1]),u,yl(s,n[o][0]));return{cut:i,start:l,end:u,pieces:tk(ZS(i.spec.shape),c)}}function yd(e){if(!dd(e))return[];let t=[];for(let n of ml(e)??[]){let r=uk(e,n),o=n.segs.map((i,s)=>ck(n,r,s));n.segs.forEach((i,s)=>{let a=dk(n,r,o,s);if(!a)return;let{frame:l}=a.cut;t.push({index:l.index,anchor:{x:l.x,y:l.y},spec:a.cut.spec,start:a.start,end:a.end,pieces:a.pieces})})}return t}function JG(e,t,n){let r=t.anchors.length,o=t.segs.map((s,a)=>ck(t,n,a)),i=t.closed&&t.segs.length>0?rs(t.segs[0],o[0][0]):t.anchors[0];e.src=t.sources[0],e.moveTo(i.x,i.y),t.segs.forEach((s,a)=>{let[l,u]=o[a];e.src=t.sources[(a+1)%r];let c=t.closed&&a===r-1&&!(n[0]?.spec&&n[0].trim>0);if(u>l&&!(c&&s.line))if(s.line){let p=rs(s,u);e.lineTo(p.x,p.y)}else{let[p,h,m]=sk(s,l,u);e.curveTo(p.x,p.y,h.x,h.y,m.x,m.y)}let d=dk(t,n,o,a);if(!d)return;let f=[...d.pieces];(a+1)%r===0&&f.at(-1)?.kind==="line"&&f.pop();for(let p of f)p.kind==="line"?e.lineTo(p.to.x,p.to.y):e.curveTo(p.c1.x,p.c1.y,p.c2.x,p.c2.y,p.to.x,p.to.y)}),t.closed&&e.close()}function QG(e,t,n,r,o){let i=n&&o?ZG(t,n,r,o):null,s=Math.hypot(r.x-t.x,r.y-t.y),a=!i||Math.hypot(i.x-e.x,i.y-e.y)>4*s;return{start:t,end:r,outer:a?e:i}}function ZG(e,t,n,r){let o=t.x*r.y-t.y*r.x;if(Math.abs(o)<1e-9)return null;let i=((n.x-e.x)*r.y-(n.y-e.y)*r.x)/o;return{x:e.x+t.x*i,y:e.y+t.y*i}}var ak,lk,eg,en=Z(()=>{"use strict";fr();pl();nk();Zy();ak=.001;lk=new WeakMap;eg=class{b=new _e;sources=[];src=0;moveTo(t,n){this.b.moveTo(t,n),this.sources.push(this.src)}lineTo(t,n){this.b.lineTo(t,n),this.sources.push(this.src)}curveTo(t,n,r,o,i,s){this.b.curveTo(t,n,r,o,i,s),this.sources.push(this.src)}close(){this.b.close()}}});function gd(e){return e>0?e:1e-6}function sg(e,t,n,r,o,i){return Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(o)&&Number.isFinite(i)}function fk(e,t,n,r,o,i,s,a){return sg(e,t,n,r,o,i)&&Number.isFinite(s)&&Number.isFinite(a)}function is(e,t,n,r,o,i){let s=o-n,a=i-r,l=s*s+a*a,u=l===0?0:((e-n)*s+(t-r)*a)/l;return u<=0?Math.hypot(e-n,t-r):u>=1?Math.hypot(e-o,t-i):Math.abs((e-n)*a-(t-r)*s)/Math.sqrt(l)}function pk(e,t,n,r,o,i,s,a,l,u){let c=tg(n-e,r-t,o-n,i-r)+tg(o-n,i-r,s-o,a-i);return o===n&&i===r&&(c+=tg(n-e,r-t,s-o,a-i)),c===0?!0:c>=Math.PI?!1:((Math.hypot(n-e,r-t)+Math.hypot(o-n,i-r)+Math.hypot(s-o,a-i))/c+l)*(1-Math.cos(c/2))<=u}function tg(e,t,n,r){let o=Math.sqrt((e*e+t*t)*(n*n+r*r));return o===0?0:Math.acos(Math.max(-1,Math.min(1,(e*n+t*r)/o)))}function Jo(e,t,n,r,o,i,s,a,l,u){if(!fk(e,t,n,r,o,i,s,a)){u.push(s,a);return}ng(e,t,n,r,o,i,s,a,gd(l),u,0)}function ng(e,t,n,r,o,i,s,a,l,u,c){let d=is(n,r,e,t,s,a),f=is(o,i,e,t,s,a);if(Math.max(d,f)<=l||c>=16){u.push(s,a);return}let p=(e+n)*.5,h=(t+r)*.5,m=(n+o)*.5,g=(r+i)*.5,b=(o+s)*.5,x=(i+a)*.5,w=(p+m)*.5,y=(h+g)*.5,P=(m+b)*.5,S=(g+x)*.5,v=(w+P)*.5,A=(y+S)*.5;ng(e,t,p,h,w,y,v,A,l,u,c+1),ng(v,A,P,S,b,x,s,a,l,u,c+1)}function hk(e,t,n,r,o,i,s,a){if(!sg(e,t,n,r,o,i)){a.push(o,i);return}rg(e,t,n,r,o,i,gd(s),a,0)}function rg(e,t,n,r,o,i,s,a,l){if(is(n,r,e,t,o,i)<=s||l>=16){a.push(o,i);return}let c=(e+n)*.5,d=(t+r)*.5,f=(n+o)*.5,p=(r+i)*.5,h=(c+f)*.5,m=(d+p)*.5;rg(e,t,c,d,h,m,s,a,l+1),rg(h,m,f,p,o,i,s,a,l+1)}function bd(e,t,n,r,o,i,s,a,l,u,c,d=0){return fk(e,t,n,r,o,i,s,a)?og(e,t,n,r,o,i,s,a,gd(l),d,u,c,0,0):(u.push(s,a),c.push(0),0)}function og(e,t,n,r,o,i,s,a,l,u,c,d,f,p){let h=is(n,r,e,t,s,a),m=is(o,i,e,t,s,a);if(Math.max(h,m)<=l&&(u===0||pk(e,t,n,r,o,i,s,a,u,l))||p>=16){let B=c.length>=2?c[c.length-2]:e,D=c.length>=2?c[c.length-1]:t,j=Math.hypot(s-B,a-D);return f+=j,c.push(s,a),d.push(f),f}let b=(e+n)*.5,x=(t+r)*.5,w=(n+o)*.5,y=(r+i)*.5,P=(o+s)*.5,S=(i+a)*.5,v=(b+w)*.5,A=(x+y)*.5,N=(w+P)*.5,M=(y+S)*.5,C=(v+N)*.5,F=(A+M)*.5;return f=og(e,t,b,x,v,A,C,F,l,u,c,d,f,p+1),f=og(C,F,N,M,P,S,s,a,l,u,c,d,f,p+1),f}function xd(e,t,n,r,o,i,s,a,l,u=0){return sg(e,t,n,r,o,i)?ig(e,t,n,r,o,i,gd(s),u,a,l,0,0):(a.push(o,i),l.push(0),0)}function ig(e,t,n,r,o,i,s,a,l,u,c,d){if(is(n,r,e,t,o,i)<=s&&(a===0||pk(e,t,n,r,o,i,o,i,a,s))||d>=16){let y=l.length>=2?l[l.length-2]:e,P=l.length>=2?l[l.length-1]:t,S=Math.hypot(o-y,i-P);return c+=S,l.push(o,i),u.push(c),c}let h=(e+n)*.5,m=(t+r)*.5,g=(n+o)*.5,b=(r+i)*.5,x=(h+g)*.5,w=(m+b)*.5;return c=ig(e,t,h,m,x,w,s,a,l,u,c,d+1),c=ig(x,w,g,b,o,i,s,a,l,u,c,d+1),c}var ss=Z(()=>{"use strict"});function as(e,t={}){return e.kind==="rect"?[e4(e)]:t4(Qe(e),t)}function e4(e){let{x:t,y:n,width:r,height:o}=e;return{points:Array.from(cl(t,n,r,o)),closed:!0,anchorA:new Uint32Array([0,1,2,3]),anchorB:new Uint32Array([0,1,2,3]),anchorT:new Float32Array([0,0,0,0])}}function t4(e,t){let n=t.flattenTolerance??.5,{commands:r,coords:o}=e,i=[],s=0,a=null,l=null,u=null,c=null,d=null,f=-1,p=0,h=()=>{a=[],l=[],u=[],c=[];let x={points:a,closed:!1};return i.push(x),x},m=()=>{if(!a||!l||!u||!c)return;let x=a.length/2;x<2||a[0]!==a[(x-1)*2]||a[1]!==a[(x-1)*2+1]||(a.length-=2,l.length-=1,u.length-=1,c.length-=1)},g=x=>{!a||!l||!u||!c||(x.anchorA=new Uint32Array(l),x.anchorB=new Uint32Array(u),x.anchorT=new Float32Array(c))},b=(x,w,y,P)=>{for(let v=0;v<w.length;v++)l.push(f),u.push(P),c.push(y>0?w[v]/y:0);let S=x+w.length-1;l[S]=P,u[S]=P,c[S]=0};return Ge(r,o,(x,w,y,P,S,v)=>{switch(v&&(d&&g(d),d=h(),a.push(y,P),l.push(p),u.push(p),c.push(0),f=p),x){case le:case ce:{x===le&&(d&&g(d),d=h(),p=s),a.push(o[w],o[w+1]),l.push(s),u.push(s),c.push(0),f=s,s++;break}case we:{let A=s,N=a.length/2,M=[],C=xd(y,P,o[w],o[w+1],o[w+2],o[w+3],n,a,M,t.offset);b(N,M,C,A),f=A,s++;break}case xe:{let A=s,N=a.length/2,M=[],C=bd(y,P,o[w],o[w+1],o[w+2],o[w+3],o[w+4],o[w+5],n,a,M,t.offset);b(N,M,C,A),f=A,s++;break}case fe:{d&&(d.closed=!0,m());break}default:throw new Error(`extractPolylines: unknown command code ${x}`)}}),d&&g(d),i}var mk=Z(()=>{"use strict";Je();en();ud();ss()});function ag(e){let t=Qe(e);if(t.kind==="rect"){let{x:s,y:a,width:l,height:u}=t;return`M${Ze(s)} ${Ze(a)}h${Ze(l)}v${Ze(u)}h${Ze(-l)}Z`}let n=t.commands,r=$e(t),o=[],i=0;for(let s=0;s<n.length;s++){let a=n[s];a===le?(o.push(`M${Ze(r[i])} ${Ze(r[i+1])}`),i+=2):a===ce?(o.push(`L${Ze(r[i])} ${Ze(r[i+1])}`),i+=2):a===xe?(o.push(`C${Ze(r[i])} ${Ze(r[i+1])} ${Ze(r[i+2])} ${Ze(r[i+3])} ${Ze(r[i+4])} ${Ze(r[i+5])}`),i+=6):a===we?(o.push(`Q${Ze(r[i])} ${Ze(r[i+1])} ${Ze(r[i+2])} ${Ze(r[i+3])}`),i+=4):a===fe&&o.push("Z")}return o.join("")}var Ze,yk=Z(()=>{"use strict";Je();en();Zt();Ze=e=>Number.isFinite(e)?String(Math.round(e*1e6)/1e6):"0"});function Hn(e,t,n,r=0,o=e.length>>1){if(o-r<3)return!1;let i=!1;for(let s=r,a=o-1;s<o;a=s++){let l=e[s*2],u=e[s*2+1],c=e[a*2],d=e[a*2+1];u>n!=d>n&&t<(c-l)*(n-u)/(d-u)+l&&(i=!i)}return i}function pr(e,t,n,r,o,i,s,a){let l=ll((s-o)*(t-i)-(a-i)*(e-o)),u=ll((s-o)*(r-i)-(a-i)*(n-o)),c=ll((n-e)*(i-t)-(r-t)*(o-e)),d=ll((n-e)*(a-t)-(r-t)*(s-e));return l!==u&&c!==d}var wd=Z(()=>{"use strict";FS()});function lg(){return gk}function Tn(e){return(e.openFill??gk)==="close"}var gk,Qo=Z(()=>{"use strict";gk="close"});function et(e){if(e.kind==="rect")return e;let{commands:t,coords:n}=Qe(e);if(t.length===0)return{kind:"rect",x:0,y:0,width:0,height:0};let r=1/0,o=1/0,i=-1/0,s=-1/0,a=!1,l=(u,c)=>{u<r&&(r=u),u>i&&(i=u),c<o&&(o=c),c>s&&(s=c),a=!0};return Ge(t,n,(u,c,d,f)=>{switch(u){case le:case ce:{l(n[c],n[c+1]);break}case xe:{let[p,h,m,g]=Hy(d,f,n[c],n[c+1],n[c+2],n[c+3],n[c+4],n[c+5]);l(p,h),l(m,g);break}case we:{let p=n[c+2],h=n[c+3],[m,g,b,x]=to(d,f,n[c],n[c+1],p,h),[w,y,P,S]=Hy(d,f,m,g,b,x,p,h);l(w,y),l(P,S);break}case fe:break;default:throw new Error(`boundsOfPath: unknown command ${u}`)}}),a?{kind:"rect",x:r+(e.origin?.x??0),y:o+(e.origin?.y??0),width:i-r,height:s-o}:{kind:"rect",x:0,y:0,width:0,height:0}}var ug=Z(()=>{"use strict";wn();Je();en()});function xk(e){let t=bk.get(e);if(t)return t;let{commands:n,coords:r}=e,o=[],i=0,s=0,a=0,l=0,u=0,c=0,d=0,f=!1;Ge(n,r,(h,m)=>{if(h===fe){a>1&&f&&c===l&&d===u&&(o[o.length-1]=s,i--),a=0;return}let g=eo(h);c=r[m+g-2],d=r[m+g-1],f=h===xe||h===we,(h===le||a===0)&&(s=i,l=c,u=d,a=0),a++,o.push(i++)});let p=Int32Array.from(o);return bk.set(e,p),p}var bk,wk=Z(()=>{"use strict";Je();bk=new WeakMap});function n4(e){return e.kind!=="polygon"?[]:yd(e).map(({anchor:t,spec:n,start:r,end:o,pieces:i})=>({anchor:t,spec:n,start:r,end:o,pieces:i}))}function fg(e,t,n=Sk){let r=e.flatMap(n4);return r.length===0?t:l4(t,r,n)}function cg(e,t,n){let r=t.start;for(let o of t.pieces){if((o.kind==="line"?dl(e.x,e.y,r.x,r.y,o.to.x,o.to.y).dist:fl(e.x,e.y,r.x,r.y,o.c1.x,o.c1.y,o.c2.x,o.c2.y,o.to.x,o.to.y).dist)<=n)return!0;r=o.to}return!1}function ls(e,t,n,r){let o=(c,d,f)=>({x:c.x+(d.x-c.x)*f,y:c.y+(d.y-c.y)*f}),i=o(e.p0,e.c1,t),s=o(e.c1,e.c2,t),a=o(e.c2,e.p3,t),l=o(i,s,n),u=o(s,a,n);return o(l,u,r)}function Pk(e,t,n,r){let o=l=>ls(e,l,l,l),i=l=>{let u=ls(e,l,l,0),c=ls(e,l,l,1);return{x:3*(c.x-u.x),y:3*(c.y-u.y)}},s=Math.hypot(i(n).x,i(n).y);if(s===0)return null;let a=n+(n===1?1:-1)*oo(o(n),t)/s;for(let l=0;l<30;l++){let u=o(a),c=i(a),d=c.x*c.x+c.y*c.y;if(d===0)break;a-=((u.x-t.x)*c.x+(u.y-t.y)*c.y)/d}return oo(o(a),t)<=r?a:null}function r4(e,t,n,r){let o=t??e.p0,i=n??e.p3;if(e.line)return{line:!0,p0:o,c1:o,c2:i,p3:i};let s=t?Pk(e,t,0,r):0,a=n?Pk(e,n,1,r):1;return s===null||a===null?null:{line:!1,p0:o,c1:ls(e,s,s,a),c2:ls(e,s,a,a),p3:i}}function Tk(e,t,n,r,o){return oo(e,n)<=o?!0:t.line&&cg(e,r,o)&&dl(n.x,n.y,t.p0.x,t.p0.y,t.p3.x,t.p3.y).dist<=o}function o4(e,t,n){let r=e.anchors.length;for(let o=e.closed?0:1;o<r;o++)for(let[i,s]of[[t.start,t.end],[t.end,t.start]])if(Tk(e.anchors[o],e.segs[(o-1+r)%r],i,t,n))for(let a=o+1,l=1;l<e.segs.length&&!(!e.closed&&a>=r-1);a++,l++){let u=e.anchors[a%r],c=e.segs[(a-1)%r];if(!c.line&&!cg(ls(c,.5,.5,.5),t,n))break;if(Tk(u,e.segs[a%r],s,t,n))return{from:o,to:a%r,trace:t};if(!cg(u,t,n))break}return null}function dg(e,t){let n=[];for(let r=e.from;;r=(r+1)%t)if(n.push(r),r===e.to)return n}function i4(e,t,n,r){let o=e.anchors.length,i=new Map,s=new Set;for(let p of t){i.set(p.from,p);for(let h of dg(p,o))s.add(h)}let a=0;if(e.closed){let p=e.anchors.findIndex((h,m)=>!s.has(m));a=p>=0?p:t[0].from}let l=[],u=[];for(let p=0,h=a;p<o;){let m=i.get(h);if(m){l.push({at:m.trace.anchor,spec:m.trace.spec}),u.push(m.to);let g=dg(m,o).length;p+=g,h=(m.to+1)%o}else l.push({at:e.anchors[h],spec:n[h]??null}),u.push(h),p++,h=(h+1)%o}let c=new Set(t.map(p=>p.to)),d=[],f=e.closed?l.length:l.length-1;for(let p=0;p<f;p++){let h=u[p],m=c.has(h)?l[p].at:void 0,g=i.has((h+1)%o)?l[(p+1)%l.length].at:void 0,b=r4(e.segs[h],m,g,r);if(!b)return null;d.push(b)}return{nodes:l,segs:d,closed:e.closed,folded:[...t]}}function s4(e,t){let n=new _e;t.origin&&n.setOrigin(t.origin.x,t.origin.y);let r=[];for(let{nodes:c,segs:d,closed:f}of e)n.moveTo(c[0].at.x,c[0].at.y),r.push(c[0].spec),d.forEach((p,h)=>{let m=c[(h+1)%c.length];f&&h===d.length-1&&p.line||(p.line?n.lineTo(m.at.x,m.at.y):n.curveTo(p.c1.x,p.c1.y,p.c2.x,p.c2.y,m.at.x,m.at.y),r.push(m.spec))}),f&&n.close();let{commands:o,coords:i}=n.build(),s={...Xo(t),commands:o,coords:i},a=xk(s),l=[];r.forEach((c,d)=>{if(c){for(;l.length<a[d];)l.push(null);l[a[d]]=c}});let u=fd(l);return u?{...s,corners:u}:s}function a4(e,t,n){let r=new Set(n.map(o=>o.trace));for(let o of yd(e))for(let i of r){if(oo(o.anchor,i.anchor)>t)continue;(oo(o.start,i.start)<=t&&oo(o.end,i.end)<=t||oo(o.start,i.end)<=t&&oo(o.end,i.start)<=t)&&r.delete(i)}return r}function l4(e,t,n=Sk){let r=ml(e);if(!r||t.length===0)return e;let o=new Set;for(let i=0;i<=t.length;i++){let s=[];for(let c of r){let d=[],f=new Set;for(let m of t){if(o.has(m))continue;let g=o4(c,m,n);if(!g)continue;let b=dg(g,c.anchors.length);b.some(x=>f.has(x))||(b.forEach(x=>f.add(x)),d.push(g))}let p=c.anchors.map((m,g)=>e.corners?.[c.first+g]??null),h=d.length>0?i4(c,d,p,n):null;if(d.length>0&&!h){d.forEach(m=>o.add(m.trace)),s.length=0;break}s.push(h??{nodes:c.anchors.map((m,g)=>({at:m,spec:p[g]})),segs:c.segs,closed:c.closed,folded:[]})}if(s.length!==r.length)continue;let a=s.flatMap(c=>c.folded);if(a.length===0)return e;let l=s4(s,e),u=a4(l,n,a);if(u.size===0)return l;u.forEach(c=>o.add(c))}return e}var Sk,oo,kk=Z(()=>{"use strict";Gy();fr();wk();Zy();pl();en();Sk=.001;oo=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y)});function vk(e,t){let n=Qe(e),{commands:r}=n,o=$e(n),i=[],s=[],a=[];return Ge(r,o,(l,u,c,d,f,p)=>{switch(p&&(a=[c,d]),l){case le:a.length>=2&&s.push(a),a=[o[u],o[u+1]];break;case ce:a.push(o[u],o[u+1]);break;case xe:Jo(c,d,o[u],o[u+1],o[u+2],o[u+3],o[u+4],o[u+5],t,a);break;case we:hk(c,d,o[u],o[u+1],o[u+2],o[u+3],t,a);break;case fe:a.length>=6?i.push(a):a.length>=2&&s.push(a),a=[];break;default:throw new Error(`pathHitTest: unknown command ${l}`)}}),a.length>=2&&s.push(a),{closed:i,open:s}}function Pd(e,t){let n=vk(e,t.tolerance??.5);return Tn(e)?{closed:[...n.closed,...n.open.filter(r=>r.length>=6)],open:n.open.filter(r=>r.length<6)}:n}function pg(e,t){return Pd(e,t).closed}var Ak=Z(()=>{"use strict";Je();ss();Qo();en();Zt()});function hg(e,t,n,r={}){if(e.kind==="rect")return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height;let o=0,i=0;for(let s of pg(e,r)){let a=s.length;for(let l=0;l<a;l+=2){let u=(l+2)%a,c=s[l+1],d=s[u+1];if(c>n==d>n)continue;let f=s[l],p=s[u];t>=f+(n-c)/(d-c)*(p-f)||(o++,i+=c<=n?1:-1)}}return e.fillRule==="evenodd"?(o&1)===1:i!==0}function Td(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]}function us(e){let t=new Array(e.length*2);for(let n=0;n<e.length;n++)t[n*2]=e[n].x,t[n*2+1]=e[n].y;return t}function c4(e,t){if(e.length===0||t.length===0)return!1;if(Hn(us(e),t[0].x,t[0].y)||Hn(us(t),e[0].x,e[0].y))return!0;for(let n=0;n<e.length;n++){let r=e[n],o=e[(n+1)%e.length];for(let i=0;i<t.length;i++){let s=t[i],a=t[(i+1)%t.length];if(pr(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y))return!0}}return!1}function Nk(e,t){for(let n of e){let r=n.length;for(let o=0;o<r;o+=2){let i=(o+2)%r;if(t(n[o],n[o+1],n[i],n[i+1]))return!0}}return!1}function d4(e,t){let n=t.x,r=t.y,o=t.x+t.width,i=t.y+t.height;return Nk(e,(s,a,l,u)=>pr(s,a,l,u,n,r,o,r)||pr(s,a,l,u,o,r,o,i)||pr(s,a,l,u,o,i,n,i)||pr(s,a,l,u,n,i,n,r))}function Ik(e,t){return t.length===0?!1:Nk(e,(n,r,o,i)=>{for(let s=0;s<t.length;s++){let a=t[s],l=t[(s+1)%t.length];if(pr(n,r,o,i,a.x,a.y,l.x,l.y))return!0}return!1})}function f4(e,t){for(let n of e)for(let r=0;r+3<n.length;r+=2){let o=n[r],i=n[r+1],s=n[r+2],a=n[r+3];for(let l=0;l<t.length;l++){let u=t[l],c=t[(l+1)%t.length];if(pr(o,i,s,a,u.x,u.y,c.x,c.y))return!0}}return!1}function p4(e,t){for(let n of e)for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];if(o>=t.x&&o<=t.x+t.width&&i>=t.y&&i<=t.y+t.height)return!0}return!1}function Rk(e,t){for(let n of e)for(let r=0;r<n.length;r+=2)if(Hn(t,n[r],n[r+1]))return!0;return!1}function Sd(e,t,n={}){if(e.kind==="rect")return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y;let r=pg(e,n);if(r.length===0)return!1;for(let o of Td(t))if(hg(e,o.x,o.y,n))return!0;return p4(r,t)?!0:d4(r,t)}function mg(e,t,n={}){if(e.length<3)return!1;let r;if(t.kind==="rect")r=[us(Td(t))];else{let{closed:i,open:s}=Pd(t,n);r=[...i,...s]}if(r.length===0)return!1;let o=us(e);for(let i of r)for(let s=0;s<i.length;s+=2)if(!Hn(o,i[s],i[s+1]))return!1;return!Ik(r,e)}function kd(e,t,n={}){if(e.length<3)return!1;let r=n.filled!==!1;if(t.kind==="rect"&&r)return c4(Td(t),e);let{closed:o,open:i}=t.kind==="rect"?{closed:[us(Td(t))],open:[]}:Pd(t,n),s=us(e);return Rk(o,s)||Rk(i,s)||Ik(o,e)||f4(i,e)?!0:r&&o.length>0&&hg(t,e[0].x,e[0].y,n)}var Ek=Z(()=>{"use strict";wd();Ak()});function At(e,t,n={}){let[r,o,i,s,a,l]=t;if(e.kind==="rect"){if(Math.abs(o)<Mk&&Math.abs(i)<Mk){let c=r*e.x+a,d=s*e.y+l,f=r*(e.x+e.width)+a,p=s*(e.y+e.height)+l;return{kind:"rect",x:Math.min(c,f),y:Math.min(d,p),width:Math.abs(f-c),height:Math.abs(p-d)}}let u=new _e().autoOrigin().moveTo(e.x,e.y).lineTo(e.x+e.width,e.y).lineTo(e.x+e.width,e.y+e.height).lineTo(e.x,e.y+e.height).close().build();return Ck(u,t,n)}return Ck(e,t,n)}function Ck(e,t,n){let r=Yy(e,Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]))),o=e.origin;if(o===void 0){let d=By(e.coords,t),f=n.autoOrigin!==!1?Pn(d):void 0;return f?{...r,coords:vt(f,d),origin:f}:{...r,coords:Float32Array.from(d)}}let[i,s,a,l,u,c]=t;return{...r,coords:Float32Array.from(By(e.coords,[i,s,a,l,0,0])),origin:{x:i*o.x+a*o.y+u,y:s*o.x+l*o.y+c}}}var Mk,bl=Z(()=>{"use strict";ts();fr();pl();Zt();Mk=1e-9});function yg(e,t,n){return e.kind==="rect"?{kind:"rect",x:e.x+t,y:e.y+n,width:e.width,height:e.height}:h4(e,t,n)}function h4(e,t,n){let r=e.origin;if(r)return{...e,coords:e.coords.slice(),origin:{x:r.x+t,y:r.y+n}};let o=new Float32Array(e.coords.length),{commands:i,coords:s}=e;return Ge(i,s,(a,l)=>{for(let u=0,c=eo(a);u<c;u+=2)o[l+u]=s[l+u]+t,o[l+u+1]=s[l+u+1]+n}),{...e,coords:o}}var Ok=Z(()=>{"use strict";Je()});function gg(e){if(e.kind==="rect")return 4;let t=e.commands,n=0;for(let r=0;r<t.length;r++){let o=t[r];(o===le||o===ce||o===xe||o===we)&&n++}return n}var Fk=Z(()=>{"use strict";Je()});function vd(e){if(e.kind==="rect")return e.width*e.height;let{commands:t,coords:n}=e,r=Tn(e),o=0,i=0,s=0,a=0,l=!1,u=0,c=0,d=f=>{l&&(f||r)&&(o+=i+u*a-s*c),i=0,l=!1};return Ge(t,n,(f,p,h,m)=>{if(f===le){d(!1),s=u=n[p],a=c=n[p+1],l=!0;return}if(f===fe){d(!0),u=s,c=a;return}if(l||(s=h,a=m,l=!0),f===ce){u=n[p],c=n[p+1],i+=h*c-u*m;return}let g=f===xe,b=n[p],x=n[p+1],w=n[p+2],y=n[p+3],P=g?n[p+4]:w,S=g?n[p+5]:y;for(let v=0;v<3;v++){let A=m4[v],N=1-A,M,C,F,B;g?(M=N*N*N*h+3*N*N*A*b+3*N*A*A*w+A*A*A*P,C=N*N*N*m+3*N*N*A*x+3*N*A*A*y+A*A*A*S,F=3*(N*N*(b-h)+2*N*A*(w-b)+A*A*(P-w)),B=3*(N*N*(x-m)+2*N*A*(y-x)+A*A*(S-y))):(M=N*N*h+2*N*A*b+A*A*w,C=N*N*m+2*N*A*x+A*A*y,F=2*(N*(b-h)+A*(w-b)),B=2*(N*(x-m)+A*(y-x))),i+=y4[v]*(M*B-C*F)}u=P,c=S}),d(!1),o/2}var m4,y4,bg=Z(()=>{"use strict";Je();Qo();m4=[.5-Math.sqrt(15)/10,.5,.5+Math.sqrt(15)/10],y4=[5/18,8/18,5/18]});function _k(e,t){let n=e[t];if(!/[A-Za-z]/.test(n))return!1;if(n!=="e"&&n!=="E"||!/[\d.]/.test(e[t-1]??""))return!0;let r=e[t+1]==="+"||e[t+1]==="-"?t+2:t+1;return!/\d/.test(e[r]??"")}function g4(e){let t=[],n=0;for(;n<e.length;)if(_k(e,n)){let r=n+1;for(;r<e.length&&!_k(e,r);)r++;let o=e.slice(n+1,r),i=e[n];t.push({cmd:i,args:i==="A"||i==="a"?x4(o):b4(o)}),n=r}else n++;return t}function b4(e){let t=[],n;for(Lk.lastIndex=0;(n=Lk.exec(e))!==null;){let r=Number(n[0]);Number.isFinite(r)&&t.push(r)}return t}function x4(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===","||r===" "||r===" "||r===`
2
- `||r==="\r"){n++;continue}let o=t.length%7;if(o===3||o===4){if(r!=="0"&&r!=="1")return t;t.push(r==="1"?1:0),n++;continue}xg.lastIndex=n;let i=xg.exec(e);if(!i)return t;t.push(Number(i[0])),n=xg.lastIndex}return t}function Zo(e,t){let n=g4(e),r=new _e().autoOrigin(),o={x:0,y:0,startX:0,startY:0,lastCubicCtrl:null,lastQuadCtrl:null},i=!1;for(let{cmd:s,args:a}of n){let l=s.toUpperCase(),u=s!==l,c=w4[l];if(c===void 0){t?.(`unknown path command: ${s}`);continue}if(!i&&l!=="M"){t?.(`path data does not begin with a moveto ("${s}" comes first); nothing is drawn`);break}if(l==="Z"){r.close(),o.x=o.startX,o.y=o.startY,o.lastCubicCtrl=null,o.lastQuadCtrl=null;continue}let d=Math.floor(a.length/c);for(let f=0;f<d;f++){let p=a.slice(f*c,(f+1)*c),h=l==="M"&&f>0?"L":l;P4(h,u,p,o,r),i=!0}if(d===0||a.length%c!==0){t?.(`path command "${s}" takes ${c} arguments at a time and has ${a.length}; the path ends before it`);break}}return r.build()}function P4(e,t,n,r,o){let i=t?r.x:0,s=t?r.y:0;switch(e){case"M":{let a=n[0]+i,l=n[1]+s;o.moveTo(a,l),r.x=a,r.y=l,r.startX=a,r.startY=l,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"L":{let a=n[0]+i,l=n[1]+s;o.lineTo(a,l),r.x=a,r.y=l,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"H":{let a=n[0]+(t?r.x:0);o.lineTo(a,r.y),r.x=a,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"V":{let a=n[0]+(t?r.y:0);o.lineTo(r.x,a),r.y=a,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"C":{let a=n[0]+i,l=n[1]+s,u=n[2]+i,c=n[3]+s,d=n[4]+i,f=n[5]+s;o.curveTo(a,l,u,c,d,f),r.x=d,r.y=f,r.lastCubicCtrl={x:u,y:c},r.lastQuadCtrl=null;return}case"S":{let a=r.lastCubicCtrl??{x:r.x,y:r.y},l=2*r.x-a.x,u=2*r.y-a.y,c=n[0]+i,d=n[1]+s,f=n[2]+i,p=n[3]+s;o.curveTo(l,u,c,d,f,p),r.x=f,r.y=p,r.lastCubicCtrl={x:c,y:d},r.lastQuadCtrl=null;return}case"Q":{let a=n[0]+i,l=n[1]+s,u=n[2]+i,c=n[3]+s;o.quadTo(a,l,u,c),r.x=u,r.y=c,r.lastQuadCtrl={x:a,y:l},r.lastCubicCtrl=null;return}case"T":{let a=r.lastQuadCtrl??{x:r.x,y:r.y},l=2*r.x-a.x,u=2*r.y-a.y,c=n[0]+i,d=n[1]+s;o.quadTo(l,u,c,d),r.x=c,r.y=d,r.lastQuadCtrl={x:l,y:u},r.lastCubicCtrl=null;return}case"A":{let a=Math.abs(n[0]),l=Math.abs(n[1]),u=n[2],c=n[3]!==0,d=n[4]!==0,f=n[5]+i,p=n[6]+s;T4(r.x,r.y,f,p,a,l,u,c,d,o),r.x=f,r.y=p,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}default:return}}function T4(e,t,n,r,o,i,s,a,l,u){if(e===n&&t===r)return;if(o===0||i===0){u.lineTo(n,r);return}let c=s*Math.PI/180,d=Math.cos(c),f=Math.sin(c),p=(e-n)/2,h=(t-r)/2,m=d*p+f*h,g=-f*p+d*h,b=o*o,x=i*i,w=m*m,y=g*g,P=w/b+y/x,S=o,v=i;if(P>1){let te=Math.sqrt(P);S=te*o,v=te*i,b=S*S,x=v*v}let A=a===l?-1:1,N=b*x-b*y-x*w,M=b*y+x*w,C=A*Math.sqrt(Math.max(0,N/M)),F=C*(S*g)/v,B=C*-(v*m)/S,D=d*F-f*B+(e+n)/2,j=f*F+d*B+(t+r)/2,V=(te,he,be,Fe)=>{let Se=te*be+he*Fe,ar=Math.sqrt((te*te+he*he)*(be*be+Fe*Fe)),Le=Math.acos(Math.max(-1,Math.min(1,Se/ar)));return te*Fe-he*be<0&&(Le=-Le),Le},J=V(1,0,(m-F)/S,(g-B)/v),se=V((m-F)/S,(g-B)/v,(-m-F)/S,(-g-B)/v);!l&&se>0?se-=2*Math.PI:l&&se<0&&(se+=2*Math.PI);let ke=Math.max(1,Math.ceil(Math.abs(se)/(Math.PI/2))),ae=se/ke,ve=4/3*Math.tan(ae/4),G=e,K=t,$=-Math.sin(J)*S,Q=Math.cos(J)*v;for(let te=1;te<=ke;te++){let he=J+te*ae,be=Math.cos(he),Fe=Math.sin(he),Se=d*(be*S)-f*(Fe*v)+D,ar=f*(be*S)+d*(Fe*v)+j,Le=-Fe*S,kt=be*v,Yt=G+d*(ve*$)-f*(ve*Q),Cc=K+f*(ve*$)+d*(ve*Q),ny=Se-d*(ve*Le)+f*(ve*kt),Oc=ar-f*(ve*Le)-d*(ve*kt);u.curveTo(Yt,Cc,ny,Oc,Se,ar),G=Se,K=ar,$=Le,Q=kt}}var Lk,xg,w4,Dk=Z(()=>{"use strict";fr();Lk=/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g,xg=/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/y;w4={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0}});function Ue(e,t,n,r){let o=(n-e)/3,i=(r-t)/3;return{c:[e,t,e+o,t+i,n-o,r-i,n,r],line:!0}}function ei(e){if(e.kind==="rect"){let{x:c,y:d,width:f,height:p}=e;return[{closed:!0,segs:[Ue(c,d,c+f,d),Ue(c+f,d,c+f,d+p),Ue(c+f,d+p,c,d+p),Ue(c,d+p,c,d)]}]}let t=[],n=null,r=0,o=0,i=(c,d,f)=>{n!==null&&(c&&((d!==r||f!==o)&&n.segs.push(Ue(d,f,r,o)),n.closed=!0),n.segs.length>0&&t.push(n),n=null)},s=Qe(e),{commands:a}=s,l=$e(s);Ge(a,l,(c,d,f,p,h,m)=>{switch(m&&(n={segs:[],closed:!1},r=f,o=p),c){case le:i(!1,f,p),n={segs:[],closed:!1},r=l[d],o=l[d+1];break;case ce:{let g=l[d],b=l[d+1];(g!==f||b!==p)&&n.segs.push(Ue(f,p,g,b));break}case we:{let[g,b,x,w]=to(f,p,l[d],l[d+1],l[d+2],l[d+3]);n.segs.push({c:[f,p,g,b,x,w,l[d+2],l[d+3]],line:!1});break}case xe:n.segs.push({c:[f,p,l[d],l[d+1],l[d+2],l[d+3],l[d+4],l[d+5]],line:!1});break;case fe:i(!0,f,p);break}});let u=n;if(u!==null){let c=u.segs.at(-1);i(!1,c?c.c[6]:r,c?c.c[7]:o)}return t}function wg(e,t="nonzero"){let n=new _e().setFillRule(t);for(let{segs:r,closed:o}of e)if(r.length!==0){n.moveTo(r[0].c[0],r[0].c[1]);for(let{c:i,line:s}of r)s?n.lineTo(i[6],i[7]):n.curveTo(i[2],i[3],i[4],i[5],i[6],i[7]);o&&n.close()}return n.build()}function cs(e,t){let[n,r]=no(...e.c,t);return[{c:[...n],line:e.line},{c:[...r],line:e.line}]}var Ad=Z(()=>{"use strict";wn();Je();fr();en();Zt()});function tt(e,t){let n=1-t;if(e.length===2)return{x:n*e[0].x+t*e[1].x,y:n*e[0].y+t*e[1].y};if(e.length===3){let a=n*n,l=2*n*t,u=t*t;return{x:a*e[0].x+l*e[1].x+u*e[2].x,y:a*e[0].y+l*e[1].y+u*e[2].y}}let r=n*n*n,o=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:r*e[0].x+o*e[1].x+i*e[2].x+s*e[3].x,y:r*e[0].y+o*e[1].y+i*e[2].y+s*e[3].y}}function wl(e,t){let n=e.length-1,r=[];for(let o=0;o<n;o++)r.push({x:n*(e[o+1].x-e[o].x),y:n*(e[o+1].y-e[o].y)});return r.length===1?r[0]:tt(r,t)}function Bk(e,t){let n=i=>{let s=[];for(let a=0;a<i.length;a+=2)s.push({x:i[a],y:i[a+1]});return s};if(e.length===2){let i=tt(e,t);return[[e[0],i],[i,e[1]]]}if(e.length===3){let[i,s]=DS(e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,t);return[n(i),n(s)]}let[r,o]=no(e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y,t);return[n(r),n(o)]}function ds(e,t,n,r,o){if(n-t<=0)return null;let i=e;t>0&&(i=Bk(i,t)[1]);let s=(n-t)/(1-t);return s<1&&(i=Bk(i,s)[0]),i=i.slice(),i[0]=r,i[i.length-1]=o,i}function S4(e){let t=[];for(let n of e){let r=n.length===2?1:16;for(let o=0;o<r;o++){let i=tt(n,o/r);t.push(i.x,i.y)}}return t}function Gk(e){let t=S4(e),n=0;for(let r=0;r<t.length;r+=2){let o=(r+2)%t.length;n+=t[r]*t[o+1]-t[o]*t[r+1]}return n/2}function Uk(e,t,n){return e.map(r=>n.x*(r.y-t.y)-n.y*(r.x-t.x))}function xl(e,t){let n=1-t;return e.length===2?n*e[0]+t*e[1]:e.length===3?n*n*e[0]+2*n*t*e[1]+t*t*e[2]:n*n*n*e[0]+3*n*n*t*e[1]+3*n*t*t*e[2]+t*t*t*e[3]}function Vk(e,t){let n=i=>i>0?1:i<0?-1:t?1:0,r=[0,...k4(e),1],o=[];for(let i=0;i+1<r.length;i++){let s=r[i],a=r[i+1],l=n(xl(e,s)),u=n(xl(e,a));if(l===0&&i>0){let c=n(xl(e,s-1e-7)),d=n(xl(e,s+1e-7));c*d<0&&o.push({t:s,before:c,after:d})}if(!(l*u>=0)){for(let c=0;c<64;c++){let d=(s+a)/2;n(xl(e,d))===l?s=d:a=d}o.push({t:(s+a)/2,before:l,after:u})}}return o}function k4(e){if(e.length<3)return[];let t=e.length-1,n=e.slice(1).map((l,u)=>t*(l-e[u])),r=0,o,i;n.length===2?(o=n[1]-n[0],i=n[0]):(r=n[0]-2*n[1]+n[2],o=2*(n[1]-n[0]),i=n[0]);let s=[],a=Math.max(Math.abs(r),Math.abs(o),Math.abs(i))||1;if(Math.abs(r)/a<1e-12)Math.abs(o)/a>1e-12&&s.push(-i/o);else{let l=o*o-4*r*i;if(l>=0){let u=-.5*(o+Math.sign(o||1)*Math.sqrt(l));s.push(u/r),u!==0&&s.push(i/u)}}return s.filter(l=>l>0&&l<1).sort((l,u)=>l-u)}var Hk,ti=Z(()=>{"use strict";wn();Hk=e=>e.map(t=>t.slice().reverse()).reverse()});function zk(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let i of e)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return[t,n,r,o]}function Kk(e){if(e.length===2)return 0;let t=e[0],n=e[e.length-1],r=n.x-t.x,o=n.y-t.y,i=Math.hypot(r,o),s=0;for(let a=1;a<e.length-1;a++){let l=e[a],u=i===0?Math.hypot(l.x-t.x,l.y-t.y):Math.abs((l.x-t.x)*o-(l.y-t.y)*r)/i;u>s&&(s=u)}return s}function jk(e){let t=e.pts,n=[t[0]],r=[t[t.length-1]];for(;t.length>1;){let i=[];for(let s=0;s+1<t.length;s++)i.push({x:(t[s].x+t[s+1].x)/2,y:(t[s].y+t[s+1].y)/2});t=i,n.push(t[0]),r.unshift(t[t.length-1])}let o=(e.t0+e.t1)/2;return[{pts:n,t0:e.t0,t1:o},{pts:r,t0:o,t1:e.t1}]}function $k(e,t,n,r,o){let i=t.x-e.x,s=t.y-e.y,a=r.x-n.x,l=r.y-n.y,u=i*l-s*a;if(u===0)return null;let c=n.x-e.x,d=n.y-e.y,f=(c*l-d*a)/u,p=(c*s-d*i)/u;return f<-o||f>1+o||p<-o||p>1+o?null:[f,p]}function R4(e,t,n,r){for(let o=0;o<12;o++){let i=tt(e,n),s=tt(t,r),a=i.x-s.x,l=i.y-s.y;if(Math.abs(a)+Math.abs(l)<1e-12)break;let u=wl(e,n),c=wl(t,r),d=-u.x*c.y+u.y*c.x;if(d===0)break;let f=(-a*-c.y- -l*-c.x)/d,p=(u.x*-l-u.y*-a)/d;n=Math.min(1,Math.max(0,n+f)),r=Math.min(1,Math.max(0,r+p))}return[n,r]}function Pg(e,t){if(e.length===2&&t.length===2){let i=$k(e[0],e[1],t[0],t[1],1e-12);if(!i)return[];let s=Math.min(1,Math.max(0,i[0])),a=Math.min(1,Math.max(0,i[1])),l=tt(e,s);return[{ta:s,tb:a,x:l.x,y:l.y}]}let n=[],r=(i,s)=>{[i,s]=R4(e,t,i,s);let a=tt(e,i),l=tt(t,s);Math.hypot(a.x-l.x,a.y-l.y)>1e-6*(1+Math.abs(a.x)+Math.abs(a.y))||n.some(u=>Math.abs(u.ta-i)<Wk&&Math.abs(u.tb-s)<Wk)||n.push({ta:i,tb:s,x:a.x,y:a.y})},o=[[{pts:e,t0:0,t1:1},{pts:t,t0:0,t1:1},0]];for(;o.length>0&&n.length<A4;){let[i,s,a]=o.pop(),l=zk(i.pts),u=zk(s.pts);if(l[0]>u[2]+fs||u[0]>l[2]+fs||l[1]>u[3]+fs||u[1]>l[3]+fs)continue;let c=Kk(i.pts),d=Kk(s.pts);if(c<=fs&&d<=fs||a>=v4){let f=$k(i.pts[0],i.pts[i.pts.length-1],s.pts[0],s.pts[s.pts.length-1],1e-6);f&&r(i.t0+f[0]*(i.t1-i.t0),s.t0+f[1]*(s.t1-s.t0));continue}if(c>=d){let[f,p]=jk(i);o.push([f,s,a+1],[p,s,a+1])}else{let[f,p]=jk(s);o.push([i,f,a+1],[i,p,a+1])}}return n.sort((i,s)=>i.ta-s.ta)}var fs,v4,Wk,A4,Yk=Z(()=>{"use strict";ti();fs=1e-4,v4=48,Wk=1e-7,A4=16});function qk(e){let t=e.kind==="rect"||Tn(e);return N4(e).filter(n=>n.closed||t).map(n=>n.segs)}function N4(e,t=!0){let n=Qe(e);if(n.kind==="rect"){let{x:c,y:d,width:f,height:p}=n,h=[{x:c,y:d},{x:c+f,y:d},{x:c+f,y:d+p},{x:c,y:d+p}];return[{segs:h.map((m,g)=>[m,h[(g+1)%4]]),closed:!0}]}let r=[],o=[],i={x:0,y:0},s=i,a=c=>{o.length>0&&(c||t)&&(s.x!==i.x||s.y!==i.y)&&o.push([s,i]),o.length>0&&r.push({segs:o,closed:c}),o=[],s=i},l=$e(n),u=0;for(let c of n.commands)if(c===le)a(!1),i=s={x:l[u],y:l[u+1]},u+=2;else if(c===ce){let d={x:l[u],y:l[u+1]};(d.x!==s.x||d.y!==s.y)&&o.push([s,d]),s=d,u+=2}else if(c===we){let d={x:l[u+2],y:l[u+3]};o.push([s,{x:l[u],y:l[u+1]},d]),s=d,u+=4}else if(c===xe){let d={x:l[u+4],y:l[u+5]};o.push([s,{x:l[u],y:l[u+1]},{x:l[u+2],y:l[u+3]},d]),s=d,u+=6}else c===fe&&a(!0);return a(!1),r}function Xk(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let i of e)for(let s of i)for(let a of s)t=Math.min(t,a.x),r=Math.max(r,a.x),n=Math.min(n,a.y),o=Math.max(o,a.y);return Math.hypot(r-t,o-n)}var Jk=Z(()=>{"use strict";Je();Qo();en();Zt()});function Gn(e,t){let n=new e.constructor(t);return n.set(e),n}function Tg(e,t,n,r,o){for(let i=0;i<o;i++)n[r+i]<e[t+i]&&(e[t+i]=n[r+i]),n[r+o+i]>e[t+o+i]&&(e[t+o+i]=n[r+o+i])}var Rd,Qk=Z(()=>{"use strict";Rd=class{dim;root=-1;nodeBox;left;right;parent;leafCount;leafItems;count;nodeCap=0;nodeTop=0;freeNodes=[];itemBox;itemCentroid2;itemLeaf;keys=[];itemCap=0;itemTop=0;freeItems=[];constructor(t){this.dim=t,this.nodeBox=new Float64Array(0),this.left=this.right=this.parent=this.leafCount=this.leafItems=this.count=new Int32Array(0),this.itemBox=new Float64Array(0),this.itemCentroid2=new Float64Array(0),this.itemLeaf=new Int32Array(0),this.growNodes(16),this.growItems(16)}growNodes(t){let n=2*this.dim;this.nodeBox=Gn(this.nodeBox,t*n),this.left=Gn(this.left,t),this.right=Gn(this.right,t),this.parent=Gn(this.parent,t),this.leafCount=Gn(this.leafCount,t),this.leafItems=Gn(this.leafItems,t*4),this.count=Gn(this.count,t),this.nodeCap=t}growItems(t){this.itemBox=Gn(this.itemBox,t*2*this.dim),this.itemCentroid2=Gn(this.itemCentroid2,t*this.dim),this.itemLeaf=Gn(this.itemLeaf,t),this.itemCap=t}allocNode(t){let n=this.freeNodes.pop();return n===void 0&&(this.nodeTop===this.nodeCap&&this.growNodes(this.nodeCap*2),n=this.nodeTop++),this.left[n]=-1,this.right[n]=-1,this.parent[n]=t,this.leafCount[n]=0,n}freeNode(t){this.freeNodes.push(t)}allocItem(t,n){let r=this.freeItems.pop();return r===void 0&&(this.itemTop===this.itemCap&&this.growItems(this.itemCap*2),r=this.itemTop++),this.keys[r]=t,this.writeItemBox(r,n),r}freeItem(t){this.keys[t]=void 0,this.itemLeaf[t]=-1,this.freeItems.push(t)}writeItemBox(t,n){let r=this.dim,o=2*r;for(let i=0;i<o;i++)this.itemBox[t*o+i]=n[i];for(let i=0;i<r;i++)this.itemCentroid2[t*r+i]=n[i]+n[r+i]}computeBox(t){let n=this.dim,r=2*n,o=this.nodeBox,i=t*r;for(let a=0;a<n;a++)o[i+a]=1/0,o[i+n+a]=-1/0;if(this.left[t]!==-1){Tg(o,i,o,this.left[t]*r,n),Tg(o,i,o,this.right[t]*r,n),this.count[t]=this.count[this.left[t]]+this.count[this.right[t]];return}this.count[t]=this.leafCount[t];let s=t*4;for(let a=0;a<this.leafCount[t];a++)Tg(o,i,this.itemBox,this.leafItems[s+a]*r,n)}refitUp(t){for(;t!==-1;t=this.parent[t])this.computeBox(t)}build(){this.freeNodes=[],this.nodeTop=0,this.root=-1;let t=[];for(let r=0;r<this.itemTop;r++)this.itemLeaf[r]!==-1&&t.push(r);if(t.length===0)return;this.nodeCap<2*t.length&&this.growNodes(2*t.length);let n=Int32Array.from(t);this.root=this.buildRange(n,0,n.length,-1)}rebuildSubtree(t){let n=this.parent[t],r=n!==-1&&this.left[n]===t,o=new Int32Array(this.count[t]),i=[t],s=0;for(;i.length>0;){let l=i.pop();if(this.left[l]!==-1)i.push(this.left[l],this.right[l]);else for(let u=0;u<this.leafCount[l];u++)o[s++]=this.leafItems[l*4+u];this.freeNode(l)}let a=this.buildRange(o,0,s,n);n===-1?this.root=a:r?this.left[n]=a:this.right[n]=a}buildRange(t,n,r,o,i=new Float64Array(t.length)){let s=this.allocNode(o);if(r-n<=4)for(let a=n;a<r;a++)this.placeInLeaf(s,t[a]);else{let a=n+r>>1;this.select(t,i,n,r,a,this.longestCentroidAxis(t,n,r));let l=this.buildRange(t,n,a,s,i),u=this.buildRange(t,a,r,s,i);this.left[s]=l,this.right[s]=u}return this.computeBox(s),s}placeInLeaf(t,n){this.leafItems[t*4+this.leafCount[t]++]=n,this.itemLeaf[n]=t}splitLeaf(t,n){let r=t*4,o=new Int32Array(5);for(let l=0;l<4;l++)o[l]=this.leafItems[r+l];o[4]=n;let i=o.length>>1;this.select(o,new Float64Array(o.length),0,o.length,i,this.longestCentroidAxis(o,0,o.length)),this.leafCount[t]=0;let s=this.allocNode(t),a=this.allocNode(t);for(let l=0;l<i;l++)this.placeInLeaf(s,o[l]);for(let l=i;l<o.length;l++)this.placeInLeaf(a,o[l]);this.left[t]=s,this.right[t]=a,this.computeBox(s),this.computeBox(a)}longestCentroidAxis(t,n,r){let o=this.dim,i=this.itemCentroid2,s=0,a=-1;for(let l=0;l<this.dim;l++){let u=1/0,c=-1/0;for(let d=n;d<r;d++){let f=i[t[d]*o+l];f<u&&(u=f),f>c&&(c=f)}c-u>a&&(a=c-u,s=l)}return s}select(t,n,r,o,i,s){let a=this.dim,l=this.itemCentroid2;for(let d=r;d<o;d++)n[d]=l[t[d]*a+s];let u=r,c=o-1;for(;u<c;){let d=n[u+c>>1],f=u,p=c;for(;f<=p;){for(;n[f]<d;)f++;for(;n[p]>d;)p--;if(f<=p){let h=t[f];t[f]=t[p],t[p]=h;let m=n[f];n[f]=n[p],n[p]=m,f++,p--}}if(i<=p)c=p;else if(i>=f)u=f;else return}}}});function Nd(e,t,n,r){e.ensureHeap(t+1);let o=e.heapT,i=e.heapId,s=t;for(;s>0;){let a=s-1>>1;if(o[a]<=n)break;o[s]=o[a],i[s]=i[a],s=a}return o[s]=n,i[s]=r,t+1}function I4(e,t){let n=e.heapT,r=e.heapId,o=t-1,i=n[o],s=r[o],a=0;for(;;){let l=2*a+1;if(l>=o||(l+1<o&&n[l+1]<n[l]&&l++,n[l]>=i))break;n[a]=n[l],r[a]=r[l],a=l}n[a]=i,r[a]=s}function Zk(e,t,n,r,o,i){for(let s=0;s<n;s++)if(e[t+s]>r[i+s]||r[o+s]>e[t+n+s])return!1;return!0}function Sg(e,t,n,r,o,i){if(e.root===-1)return;let s=t.take(),a=e.dim,l=2*a;try{let u=s.stackAt(0),c=0;for(u[c++]=e.root;c>0;){let d=u[--c];if(Zk(e.nodeBox,d*l,a,n,r,o)){if(e.left[d]===-1){let f=d*4;for(let p=0;p<e.leafCount[d];p++){let h=e.leafItems[f+p];if(Zk(e.itemBox,h*l,a,n,r,o)&&i(e.keys[h])===!1)return}continue}u=s.stackAt(c+1),u[c++]=e.left[d],u[c++]=e.right[d]}}}finally{s.release()}}function ev(e,t,n,r){for(let o=0;o<r.length;o++){let{normal:i,offset:s}=r[o],a=s;for(let l=0;l<n;l++)a+=i[l]*(i[l]>=0?e[t+n+l]:e[t+l]);if(a<0)return!1}return!0}function tv(e,t,n,r){if(e.root===-1)return;let o=t.take(),i=e.dim,s=2*i;try{let a=o.stackAt(0),l=0;for(a[l++]=e.root;l>0;){let u=a[--l];if(ev(e.nodeBox,u*s,i,n)){if(e.left[u]===-1){let c=u*4;for(let d=0;d<e.leafCount[u];d++){let f=e.leafItems[c+d];if(ev(e.itemBox,f*s,i,n)&&r(e.keys[f])===!1)return}continue}a=o.stackAt(l+1),a[l++]=e.left[u],a[l++]=e.right[u]}}}finally{o.release()}}function Id(e,t,n,r,o,i){let s=0,a=i;for(let l=0;l<n;l++){let u=e[t+l],c=e[t+n+l];if(o[l]===0){if(r[l]<u||r[l]>c)return-1;continue}let d=(u-r[l])/o[l],f=(c-r[l])/o[l];if(d<f?(d>s&&(s=d),f<a&&(a=f)):(f>s&&(s=f),d<a&&(a=d)),s>a)return-1}return s}function nv(e,t,n,r,o,i){if(e.root===-1)return;let s=e.dim,a=2*s,l=Id(e.nodeBox,e.root*a,s,n,r,i);if(l<0)return;let u=t.take();try{let c=Nd(u,0,l,e.root);for(;c>0;){let d=u.heapT[0],f=u.heapId[0];if(I4(u,c--),f<0){if(o(e.keys[-f-1],d)===!1)return;continue}if(e.left[f]===-1){let b=f*4;for(let x=0;x<e.leafCount[f];x++){let w=e.leafItems[b+x],y=Id(e.itemBox,w*a,s,n,r,i);y>=0&&(c=Nd(u,c,y,-w-1))}continue}let p=e.left[f],h=e.right[f],m=Id(e.nodeBox,p*a,s,n,r,i);m>=0&&(c=Nd(u,c,m,p));let g=Id(e.nodeBox,h*a,s,n,r,i);g>=0&&(c=Nd(u,c,g,h))}}finally{u.release()}}var Ed,rv=Z(()=>{"use strict";Ed=class e{stack=new Int32Array(64);heapT=new Float64Array(64);heapId=new Int32Array(64);busy=!1;take(){return this.busy?new e:(this.busy=!0,this)}release(){this.busy=!1}stackAt(t){if(t>=this.stack.length){let n=new Int32Array(this.stack.length*2);n.set(this.stack),this.stack=n}return this.stack}ensureHeap(t){if(t<this.heapT.length)return;let n=new Float64Array(this.heapT.length*2),r=new Int32Array(this.heapId.length*2);n.set(this.heapT),r.set(this.heapId),this.heapT=n,this.heapId=r}}});function ov(e){return 2*Math.ceil(Math.log2(Math.max(e,2)))}function M4(e){let t=0;for(;e>4;e=Math.ceil(e/2))t++;return t}function kg(e,t){if(e.length<2*t)return!1;for(let n=0;n<t;n++){let r=e[n],o=e[t+n];if(!Number.isFinite(r)||!Number.isFinite(o)||r>o)return!1}return!0}function Ag(e,t){if(!Number.isInteger(e)||e<1)throw new RangeError(`createBvh: dim must be a positive integer, got ${e}`);let n=new vg(e);return t&&(n.load(t),n.rebuild()),n}var E4,vg,iv=Z(()=>{"use strict";Qk();rv();E4=.7;vg=class{dim;tree;items=new Map;scratch=new Ed;peakSize=0;constructor(t){this.dim=t,this.tree=new Rd(t)}get size(){return this.items.size}load(t){for(let[n,r]of t){if(!kg(r,this.dim))continue;let o=this.items.get(n);if(o!==void 0){this.tree.writeItemBox(o,r);continue}let i=this.tree.allocItem(n,r);this.tree.itemLeaf[i]=0,this.items.set(n,i)}}insert(t,n){if(!kg(n,this.dim))return!1;if(this.items.has(t))return this.update(t,n);let r=this.tree.allocItem(t,n);return this.items.set(t,r),this.items.size>this.peakSize&&(this.peakSize=this.items.size),this.place(r),!0}update(t,n){let r=this.items.get(t);if(r===void 0||!kg(n,this.dim))return!1;let o=this.tree,i=o.itemLeaf[r];return this.leafHolds(i,n)?(o.writeItemBox(r,n),!0):(this.detach(r),o.writeItemBox(r,n),this.place(r),!0)}remove(t){let n=this.items.get(t);return n===void 0?!1:(this.detach(n),this.items.delete(t),this.tree.freeItem(n),this.items.size<this.peakSize>>1&&this.rebuild(),!0)}refit(){let t=this.tree;if(t.root===-1)return;let n=this.scratch.take();try{let r=n.stackAt(0);r[0]=t.root;let o=1;for(let i=0;i<o;i++){let s=r[i];t.left[s]!==-1&&(r=n.stackAt(o+1),r[o++]=t.left[s],r[o++]=t.right[s])}for(let i=o-1;i>=0;i--)t.computeBox(r[i])}finally{n.release()}}rebuild(){this.tree.build(),this.peakSize=this.items.size}maxDepth(){let t=this.tree;if(t.root===-1)return 0;let n=0,r=[[t.root,0]];for(;r.length>0;){let[o,i]=r.pop();t.left[o]===-1?n=Math.max(n,i):r.push([t.left[o],i+1],[t.right[o],i+1])}return n}queryBox(t,n){Sg(this.tree,this.scratch,t,0,this.dim,n)}queryPoint(t,n){Sg(this.tree,this.scratch,t,0,0,n)}raycast(t,n,r,o=1/0){nv(this.tree,this.scratch,t,n,r,o)}queryHalfSpaces(t,n){tv(this.tree,this.scratch,t,n)}leafHolds(t,n){let r=this.dim,o=t*2*r,i=this.tree.nodeBox;for(let s=0;s<r;s++)if(n[s]<i[o+s]||n[r+s]>i[o+r+s])return!1;return!0}place(t){let n=this.tree;if(n.root===-1){n.root=n.allocNode(-1),n.placeInLeaf(n.root,t),n.computeBox(n.root);return}let r=n.root,o=0;for(;n.left[r]!==-1;){let i=n.left[r],s=n.right[r],a=this.enlargement(i,t),l=this.enlargement(s,t);r=a<l||a===l&&n.count[i]<=n.count[s]?i:s,o++}n.leafCount[r]<4?n.placeInLeaf(r,t):(n.splitLeaf(r,t),o++),n.refitUp(r),o>ov(this.items.size)&&this.rebalance(n.itemLeaf[t],o)}rebalance(t,n){let r=this.tree,o=ov(this.items.size),i=-1;for(let s=t,a=r.parent[t],l=n-1;a!==-1;s=a,a=r.parent[a],l--)if(!(l+M4(r.count[a])>o)){if(r.count[s]>E4*r.count[a]){r.rebuildSubtree(a);return}i===-1&&(i=a)}i!==-1?r.rebuildSubtree(i):this.rebuild()}enlargement(t,n){let r=this.dim,o=this.tree.nodeBox,i=this.tree.itemBox,s=t*2*r,a=n*2*r,l=0;for(let u=0;u<r;u++){let c=Math.min(o[s+u],i[a+u]),d=Math.max(o[s+r+u],i[a+r+u]);l+=d-c-(o[s+r+u]-o[s+u])}return l}detach(t){let n=this.tree,r=n.itemLeaf[t],o=r*4,i=n.leafCount[r];for(let u=0;u<i;u++)if(n.leafItems[o+u]===t){n.leafItems[o+u]=n.leafItems[o+i-1];break}if(n.leafCount[r]=i-1,n.itemLeaf[t]=-1,i>1){n.refitUp(r);return}let s=n.parent[r];if(n.freeNode(r),s===-1){n.root=-1;return}let a=n.left[s]===r?n.right[s]:n.left[s],l=n.parent[s];n.parent[a]=l,l===-1?n.root=a:n.left[l]===s?n.left[l]=a:n.right[l]=a,n.freeNode(s),n.refitUp(l)}}});function sv(e,t){let n=[],r=[];for(let{segs:i,closed:s}of e){n.push(le),r.push(i[0][0].x,i[0][0].y);for(let a of i){n.push(a.length===2?ce:a.length===3?we:xe);for(let l=1;l<a.length;l++)r.push(a[l].x,a[l].y)}s&&n.push(fe)}let o=Pn(r);return{kind:"polygon",commands:new Uint8Array(n),coords:vt(o,r),fillRule:t,...o?{origin:o}:{}}}var av=Z(()=>{"use strict";Je();Zt()});function Ng(e,t,n={}){let r=new _e;if(!(t>0))return r.build();let o=vd(e)<0?-1:1,i={d:t,sigma:o,tol:n.tolerance??.1,join:n.join??"miter",miterLimit:n.miterLimit??4};for(let s of ei(e)){let a=s.segs.filter(c=>!z4(c));if(a.length===0)continue;let l=a.at(-1).c,u=a[0].c;(l[6]!==u[0]||l[7]!==u[1])&&a.push(Ue(l[6],l[7],u[0],u[1])),$4(r,F4(a,i))}return r.build()}function F4(e,t){let n=e.map(r=>({pieces:Rg(r,t,0),join:[]}));for(let r=0;r<e.length;r++){let o=(r+1)%e.length,i=dv(e[r].c),s=cv(e[o].c),a=[e[o].c[0],e[o].c[1]];n[r].join=L4(n[r],n[o],a,i,s,t)}return n}function L4(e,t,n,r,o,i){let s=j4(e.pieces.at(-1)),a=K4(t.pieces[0]),l=Math.hypot(a[0]-s[0],a[1]-s[1]);if(l<=i.tol*.001)return[];let u=r[0]*o[1]-r[1]*o[0],c=r[0]*o[0]+r[1]*o[1],d=i.sigma*u>0||Math.abs(u)<1e-9&&c<0;if(l<=i.tol)return _4(e,t,s);if(!d)return B4(e,t)?[]:[Ue(s[0],s[1],n[0],n[1]),Ue(n[0],n[1],a[0],a[1])];let f=Md(r,i.sigma),p=Md(o,i.sigma);if(i.join==="round")return U4(n,i.d,f,Math.atan2(u,c));let h=f[0]*p[0]+f[1]*p[1];if(1+h<1e-9||Math.sqrt(2/(1+h))>i.miterLimit)return[Ue(s[0],s[1],a[0],a[1])];let m=i.d/(1+h),g=[n[0]+(f[0]+p[0])*m,n[1]+(f[1]+p[1])*m];return D4(e,t,g)}function _4(e,t,n){let r=t.pieces[0];return r===e.pieces.at(-1)?[Ue(r.c[6],r.c[7],n[0],n[1])]:(t.pieces[0]=r.line?Ue(n[0],n[1],r.c[6],r.c[7]):{c:[n[0],n[1],r.c[2]+n[0]-r.c[0],r.c[3]+n[1]-r.c[1],r.c[4],r.c[5],r.c[6],r.c[7]],line:!1},[])}function D4(e,t,n){let r=e.pieces.at(-1),o=t.pieces[0],i=[];return r.line&&r!==o?e.pieces[e.pieces.length-1]=Ue(r.c[0],r.c[1],n[0],n[1]):i.push(Ue(r.c[6],r.c[7],n[0],n[1])),o.line&&r!==o?t.pieces[0]=Ue(n[0],n[1],o.c[6],o.c[7]):i.push(Ue(n[0],n[1],o.c[0],o.c[1])),i}function B4(e,t){let n=e.pieces.at(-1),r=t.pieces[0];if(n===r)return!1;let o=H4(n.c,r.c);if(o===null)return!1;let i=o[0]>=1?n:cs(n,o[0])[0],s=o[1]<=0?r:cs(r,o[1])[1],a=(i.c[6]+s.c[0])/2,l=(i.c[7]+s.c[1])/2;return e.pieces[e.pieces.length-1]=i.line?Ue(i.c[0],i.c[1],a,l):{c:[i.c[0],i.c[1],i.c[2],i.c[3],i.c[4]+a-i.c[6],i.c[5]+l-i.c[7],a,l],line:!1},t.pieces[0]=s.line?Ue(a,l,s.c[6],s.c[7]):{c:[a,l,s.c[2]+a-s.c[0],s.c[3]+l-s.c[1],s.c[4],s.c[5],s.c[6],s.c[7]],line:!1},!0}function H4(e,t){let n=lv(e),r=lv(t),o=null,i=1/0;for(let s=0;s<hs;s++)for(let a=0;a<hs;a++){let l=G4(n[s],n[s+1],r[a],r[a+1]);if(l===null)continue;let u=(s+l[0])/hs,c=(a+l[1])/hs;u<=1e-9||c>=1-1e-9||1-u+c>=i||(i=1-u+c,o=[u,c])}return o}function lv(e){let t=[];for(let n=0;n<=hs;n++)t.push(We(...e,n/hs));return t}function G4(e,t,n,r){let o=t[0]-e[0],i=t[1]-e[1],s=r[0]-n[0],a=r[1]-n[1],l=o*a-i*s;if(Math.abs(l)<1e-18)return null;let u=((n[0]-e[0])*a-(n[1]-e[1])*s)/l,c=((n[0]-e[0])*i-(n[1]-e[1])*o)/l;return u>=0&&u<=1&&c>=0&&c<=1?[u,c]:null}function U4(e,t,n,r){let o=Math.max(1,Math.ceil(Math.abs(r)/(Math.PI/2))),i=r/o,s=4/3*Math.tan(i/4)*t,a=Math.atan2(n[1],n[0]),l=[];for(let u=0;u<o;u++){let c=a+i*u,d=c+i,f=e[0]+Math.cos(c)*t,p=e[1]+Math.sin(c)*t,h=e[0]+Math.cos(d)*t,m=e[1]+Math.sin(d)*t;l.push({c:[f,p,f-Math.sin(c)*s,p+Math.cos(c)*s,h+Math.sin(d)*s,m-Math.cos(d)*s,h,m],line:!1})}return l}function Rg(e,t,n){let r=e.c,o=Md(cv(r),t.sigma),i=Md(dv(r),t.sigma),{d:s}=t;if(e.line)return[Ue(r[0]+o[0]*s,r[1]+o[1]*s,r[6]+o[0]*s,r[7]+o[1]*s)];let a=Math.max(0,1+t.sigma*s*uv(r,0)),l=Math.max(0,1+t.sigma*s*uv(r,1)),u=r[0]+o[0]*s,c=r[1]+o[1]*s,d=r[6]+i[0]*s,f=r[7]+i[1]*s,p={c:[u,c,u+(r[2]-r[0])*a,c+(r[3]-r[1])*a,d+(r[4]-r[6])*l,f+(r[5]-r[7])*l,d,f],line:!1};if(n>=C4||V4(r,p.c,t)<=t.tol)return[p];let[h,m]=cs(e,.5);return[...Rg(h,t,n+1),...Rg(m,t,n+1)]}function V4(e,t,n){let r=0;for(let o of O4){let[i,s]=W4(e,o),a=Math.hypot(i,s);if(a<1e-12)continue;let[l,u]=We(...e,o),c=l+n.sigma*s/a*n.d,d=u-n.sigma*i/a*n.d,[f,p]=We(...t,o);r=Math.max(r,Math.hypot(f-c,p-d))}return r}function W4(e,t){let n=1-t,r=3*n*n,o=6*n*t,i=3*t*t;return[r*(e[2]-e[0])+o*(e[4]-e[2])+i*(e[6]-e[4]),r*(e[3]-e[1])+o*(e[5]-e[3])+i*(e[7]-e[5])]}function uv(e,t){let[n,r]=t===0?[e[2]-e[0],e[3]-e[1]]:[e[6]-e[4],e[7]-e[5]],[o,i]=t===0?[e[0]-2*e[2]+e[4],e[1]-2*e[3]+e[5]]:[e[6]-2*e[4]+e[2],e[7]-2*e[5]+e[3]],s=Math.hypot(n,r);return s<1e-12?0:2/3*(n*i-r*o)/(s*s*s)}function cv(e){return ms(e[2]-e[0],e[3]-e[1])??ms(e[4]-e[0],e[5]-e[1])??ms(e[6]-e[0],e[7]-e[1])??[1,0]}function dv(e){return ms(e[6]-e[4],e[7]-e[5])??ms(e[6]-e[2],e[7]-e[3])??ms(e[6]-e[0],e[7]-e[1])??[1,0]}function ms(e,t){let n=Math.hypot(e,t);return n<1e-12?null:[e/n,t/n]}function Md(e,t){return[t*e[1],-t*e[0]]}function z4(e){let t=e.c;return t[0]===t[6]&&t[1]===t[7]&&t[0]===t[2]&&t[1]===t[3]&&t[0]===t[4]&&t[1]===t[5]}function $4(e,t){let n=t[0].pieces[0];e.moveTo(n.c[0],n.c[1]);for(let r of t)for(let o of[...r.pieces,...r.join])o.line?e.lineTo(o.c[6],o.c[7]):e.curveTo(o.c[2],o.c[3],o.c[4],o.c[5],o.c[6],o.c[7]);e.close()}var C4,O4,hs,K4,j4,fv=Z(()=>{"use strict";wn();fr();Ad();bg();C4=6,O4=[.2,.35,.5,.65,.8];hs=32;K4=e=>[e.c[0],e.c[1]],j4=e=>[e.c[6],e.c[7]]});function gv(e){let t=e.map(o=>Y4(o)),n=t.map(q4),r=[];for(let o=0;o<e.length;o++)for(let i=o+1;i<e.length;i++){if(!X4(n[o],n[i]))continue;let s=t[o],a=t[i];for(let l=0;l+1<s.length;l++)for(let u=0;u+1<a.length;u++){let c=J4(s[l],s[l+1],a[u],a[u+1]);if(c===null)continue;let d=[(l+c[0])/(s.length-1),(u+c[1])/(a.length-1)],[f,p]=e[o].line&&e[i].line?d:Q4(e[o].c,e[i].c,d);mv(f)&&mv(p)||r.some(h=>h.a===o&&h.b===i&&Math.abs(h.s-f)<1e-6&&Math.abs(h.t-p)<1e-6)||r.push({a:o,b:i,s:f,t:p})}}return r}function Y4(e){if(e.line)return[[e.c[0],e.c[1]],[e.c[6],e.c[7]]];let t=[];for(let n=0;n<=pv;n++)t.push(We(...e.c,n/pv));return t}function q4(e){let t=[1/0,1/0,-1/0,-1/0];for(let[n,r]of e)t[0]=Math.min(t[0],n),t[1]=Math.min(t[1],r),t[2]=Math.max(t[2],n),t[3]=Math.max(t[3],r);return t}function J4(e,t,n,r){let o=t[0]-e[0],i=t[1]-e[1],s=r[0]-n[0],a=r[1]-n[1],l=o*a-i*s;if(Math.abs(l)<1e-18)return null;let u=((n[0]-e[0])*a-(n[1]-e[1])*s)/l,c=((n[0]-e[0])*i-(n[1]-e[1])*o)/l;return u>=0&&u<=1&&c>=0&&c<=1?[u,c]:null}function Q4(e,t,n){let r=(l,u)=>{let c=We(...e,l),d=We(...t,u);return[c[0]-d[0],c[1]-d[1]]},[o,i]=n,s=r(o,i),a=Math.hypot(...s);for(let l=0;l<8&&Math.hypot(...s)>1e-13;l++){let u=yv(e,o),c=yv(t,i),d=-u[0]*c[1]+c[0]*u[1];if(Math.abs(d)<1e-18)break;o=Math.min(1,Math.max(0,o-(-c[1]*s[0]+c[0]*s[1])/d)),i=Math.min(1,Math.max(0,i-(-u[1]*s[0]+u[0]*s[1])/d)),s=r(o,i)}return Math.hypot(...s)<=a?[o,i]:n}function yv(e,t){let n=1-t,r=3*n*n,o=6*n*t,i=3*t*t;return[r*(e[2]-e[0])+o*(e[4]-e[2])+i*(e[6]-e[4]),r*(e[3]-e[1])+o*(e[5]-e[3])+i*(e[7]-e[5])]}var pv,hv,mv,X4,bv=Z(()=>{"use strict";wn();pv=16,hv=1e-7;mv=e=>e<hv||e>1-hv;X4=(e,t)=>e[0]<=t[2]&&t[0]<=e[2]&&e[1]<=t[3]&&t[1]<=e[3]});function Eg(e,t={}){let n=t.tolerance??.01,r=ei(e).filter(d=>d.segs.length>0),o=r.flatMap(d=>xv(d.segs,n*.001)),i=vd(e)<0,s=o.map(()=>[]);for(let d of gv(o)){let f=Z4(o[d.a],d.s,o[d.b],d.t);s[d.a].push({t:d.s,p:f}),s[d.b].push({t:d.t,p:f})}let a=nU(o,n/4),l=[],u=!1;o.forEach((d,f)=>{let p=eU(d,s[f]);p.length>1&&(u=!0);for(let h of p){let m=rU(h,a,n);m===null?u=!0:m===i?l.push(h):(u=!0,l.push(tU(h)))}});let c=new _e;if(!u){for(let d of r)Pv(c,xv(d.segs,n*.001));return c.build()}for(let d of oU(l))Pv(c,d);return c.build()}function xv(e,t){let n=o=>o.line&&Math.hypot(o.c[6]-o.c[0],o.c[7]-o.c[1])<=t,r=e.filter(o=>!n(o));if(r.length===0)return[];for(let o=0;o<r.length;o++){let i=r[(o+r.length-1)%r.length].c,s=r[o];(i[6]!==s.c[0]||i[7]!==s.c[1])&&(Math.hypot(i[6]-s.c[0],i[7]-s.c[1])<=t?r[o]=Ig(s,[i[6],i[7]],[s.c[6],s.c[7]]):o===0&&r.push(Ue(i[6],i[7],s.c[0],s.c[1])))}return r}function Z4(e,t,n,r){let o=(l,u)=>u<=1e-7?[l.c[0],l.c[1]]:u>=.9999999?[l.c[6],l.c[7]]:null,i=o(e,t)??o(n,r);if(i)return i;let s=We(...e.c,t),a=We(...n.c,r);return[(s[0]+a[0])/2,(s[1]+a[1])/2]}function eU(e,t){let n=t.filter(a=>a.t>1e-7&&a.t<.9999999).sort((a,l)=>a.t-l.t),r=[],o=e,i=0,s=[e.c[0],e.c[1]];for(let a of n){if(a.t-i<1e-9)continue;let[l,u]=cs(o,(a.t-i)/(1-i));r.push(Ig(l,s,a.p)),o=u,i=a.t,s=a.p}return r.push(Ig(o,s,[e.c[6],e.c[7]])),r}function Ig(e,t,n){let r=e.c;return{c:[t[0],t[1],r[2]+t[0]-r[0],r[3]+t[1]-r[1],r[4]+n[0]-r[6],r[5]+n[1]-r[7],n[0],n[1]],line:e.line}}function tU(e){let t=e.c;return{c:[t[6],t[7],t[4],t[5],t[2],t[3],t[0],t[1]],line:e.line}}function nU(e,t){let n=[],r=[];for(let{c:o,line:i}of e)r.length===0?r.push(o[0],o[1]):(r[r.length-2]!==o[0]||r[r.length-1]!==o[1])&&(n.push(r),r=[o[0],o[1]]),i?r.push(o[6],o[7]):Jo(...o,t,r);return r.length>0&&n.push(r),n}function wv(e,t,n){let r=0;for(let o of e)for(let i=0;i+3<o.length;i+=2){let s=o[i+1],a=o[i+3];if(s>n==a>n)continue;let l=o[i],u=o[i+2];t>=l+(n-s)/(a-s)*(u-l)||(r+=s<=n?1:-1)}return r}function rU(e,t,n){let r=e.c,[o,i]=We(...r,.5),s=r[6]+r[4]-r[2]-r[0],a=r[7]+r[5]-r[3]-r[1],l=Math.hypot(s,a);if(l<1e-12)return null;let u=a/l*n,c=-s/l*n,d=wv(t,o+u,i+c)!==0,f=wv(t,o-u,i-c)!==0;return d===f?null:d}function oU(e){let t=(i,s)=>`${i},${s}`,n=new Map;e.forEach((i,s)=>{let a=t(i.c[0],i.c[1]),l=n.get(a);l?l.push(s):n.set(a,[s])});let r=new Uint8Array(e.length),o=[];for(let i=0;i<e.length;i++){if(r[i])continue;let s=[],a=i;for(;a!==void 0&&!r[a];){r[a]=1;let l=e[a];s.push(l),a=n.get(t(l.c[6],l.c[7]))?.find(u=>!r[u])}o.push(s)}return o}function Pv(e,t){if(t.length===0)return;let[n,r]=t[0].c;e.moveTo(n,r);for(let[o,{c:i,line:s}]of t.entries()){if(s&&o===t.length-1&&i[6]===n&&i[7]===r)break;s?e.lineTo(i[6],i[7]):e.curveTo(i[2],i[3],i[4],i[5],i[6],i[7])}e.close()}var Tv=Z(()=>{"use strict";wn();ss();fr();Ad();bv();bg()});function ys(e,t,n,r,o,i){return new Float64Array([e,t,0,n,r,0,o,i,1])}function iU(){return ys(1,0,0,1,0,0)}function Mg(e,t){let n=e[0],r=e[1],o=e[3],i=e[4],s=e[6],a=e[7],l=t[0],u=t[1],c=t[3],d=t[4],f=t[6],p=t[7];return ys(n*l+o*u,r*l+i*u,n*c+o*d,r*c+i*d,n*f+o*p+s,r*f+i*p+a)}function sU(e,t,n){let r=ys(1,0,0,1,t,n);return Mg(e,r)}function aU(e,t,n){let r=ys(t,0,0,n,0,0);return Mg(e,r)}function Sv(e){return[e[0],e[1],e[3],e[4],e[6],e[7]]}function kv(e){return ys(e[0],e[1],e[2],e[3],e[4],e[5])}function lU(e){let t=cr(Sv(e));return t&&kv(t)}function uU(e){return Float32Array.from(e)}function cU(e,t,n){let r=e[0],o=e[1],i=e[3],s=e[4],a=e[6],l=e[7];return[r*t+i*n+a,o*t+s*n+l]}function dU(e,t){return ys(2/e,0,0,-2/t,-1,1)}function fU(e){return Math.sqrt(Math.abs(e[0]*e[4]-e[1]*e[3]))}function pU(e){let t=e[0]*e[0]+e[1]*e[1]+e[3]*e[3]+e[4]*e[4],n=e[0]*e[4]-e[1]*e[3];return Math.sqrt(Math.max(0,(t-Math.sqrt(Math.max(0,t*t-4*n*n)))/2))}var q,vv=Z(()=>{"use strict";ts();q={identity:iU,toAffine:Sv,fromAffine:kv,multiply:Mg,translated:sU,scaled:aU,invert:lU,toUniform:uU,apply:cU,screenToClip:dU,meanScaleOf:fU,minScaleOf:pU}});function hr(e){let t=e.scale.x,n=e.scale.y,r=-e.x*t+0,o=-e.y*n+0;return new Float64Array([t,0,0,0,n,0,r,o,1])}var Av=Z(()=>{"use strict"});function Cg(e){let t=e;return t.rotation&&t.x!=null&&t.y!=null&&t.width!=null&&t.height!=null?{cx:t.x+t.width/2,cy:t.y+t.height/2,rotation:t.rotation}:null}function Rv(e,t,n,r){return e.kind==="rect"?mU(e.x,e.y,e.width,e.height,t,n,r):hU(e,t,n,r)}function hU(e,t,n,r){let o=Math.cos(r),i=Math.sin(r);if(e.origin)return At(e,[o,i,-i,o,t-t*o+n*i,n-t*i-n*o]);let{commands:s,coords:a}=e,l=new Float32Array(a.length);return Ge(s,a,(u,c)=>{for(let d=0,f=eo(u);d<f;d+=2){let p=a[c+d]-t,h=a[c+d+1]-n;l[c+d]=t+p*o-h*i,l[c+d+1]=n+p*i+h*o}}),{...e,coords:l}}function mU(e,t,n,r,o,i,s){let a=Math.cos(s),l=Math.sin(s),u=(y,P)=>{let S=y-o,v=P-i;return[o+S*a-v*l,i+S*l+v*a]},[c,d]=u(e,t),[f,p]=u(e+n,t),[h,m]=u(e+n,t+r),[g,b]=u(e,t+r),x=new Uint8Array([le,ce,ce,ce,fe]),w=new Float32Array([c,d,f,p,h,m,g,b]);return{kind:"polygon",commands:x,coords:w,fillRule:"nonzero"}}var Nv=Z(()=>{"use strict";Je();bl()});function Un(e){let t=e?.transform;return!Array.isArray(t)||t.length!==4||t[0]===1&&t[1]===0&&t[2]===0&&t[3]===1?null:t}function Ce(e){let t=e;if(!t||t.x==null||t.y==null||t.width==null||t.height==null)return null;let n=Un(t);if(!t.rotation&&!n)return null;let r=t.x+t.width/2,o=t.y+t.height/2;if(!n)return Zr(r,o,t.rotation);let[i,s,a,l]=n,u=[i,s,a,l,r-(i*r+a*o),o-(s*r+l*o)];return t.rotation?ht(Zr(r,o,t.rotation),u):u}function ni(e){if(!Un(e)){let n=Cg(e);return n&&Zr(n.cx,n.cy,-n.rotation)}let t=Ce(e);return t&&cr(t)}function Pl(e,t){if(Un(t)){let r=Ce(t);return r?At(e,r):e}let n=Cg(t);return n?Rv(e,n.cx,n.cy,n.rotation):e}var Iv=Z(()=>{"use strict";ts();bl();Nv()});function Tl(e,t){if(e.kind==="rect")return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height?e:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height};let n=et(e);if(n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height)return e;let r=dr(n.x,n.y,n.width,n.height,t.x,t.y,t.width,t.height);return At(e,r)}var Ev=Z(()=>{"use strict";ts();ug();bl()});function Mv(e){if(e===null||typeof e!="object")return;let{__ta:t,data:n}=e;if(!(typeof t!="string"||!Object.hasOwn(Sl,t)||!Array.isArray(n)))return Sl[t].from(n)}function Og(e,t){let n=t(e);if(n!==void 0)return n;if(Array.isArray(e))return e.map(o=>Og(o,t));if(!gU(e))return e;let r={};for(let o of Object.keys(e))r[o]=Og(e[o],t);return r}function Fg(e){return Og(e,Mv)}var Sl,kee,yU,gU,Cv=Z(()=>{"use strict";Sl={i8:Int8Array,u8:Uint8Array,u8c:Uint8ClampedArray,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array},kee=new Map(Object.keys(Sl).map(e=>[Sl[e].name,e])),yU=e=>Object.prototype.toString.call(e).slice(8,-1);gU=e=>yU(e)==="Object"});var ee=Z(()=>{"use strict";ts();ud();Je();wd();Qo();fr();ug();Zt();en();pl();Ok();bl();Dk();yk();Ad();fv();Tv();Ek();Fk();vv();Av();Iv();Ev();Cv()});function Dt(e){return e!=null&&(e.kind===void 0||e.kind==="solid")}var Jg=Z(()=>{"use strict"});function Ne(e,t=null){return e===nn?t:e?.paint==null?null:e}function Re(e,t=null){return e===nn?t:e?.paint==null?null:e}var nn,Qg=Z(()=>{"use strict";nn="inherit"});function Yd(e){return Array.isArray(e)?`[${e.map(Yd).join(",")}]`:typeof e!="object"||e===null?JSON.stringify(e)??"null":`{${Object.keys(e).sort().filter(n=>e[n]!==void 0).map(n=>`${JSON.stringify(n)}:${Yd(e[n])}`).join(",")}}`}function ao(e){if(e==null)return"none";if(Dt(e))return`solid:${e.color}:${e.opacity??1}`;let t=RA.get(e);return t===void 0&&(t=Yd(e),RA.set(e,t)),t}function qd(e){return Ne(e)!==null}function mr(e){let t=Re(e);if(t===null)return!1;let n=t.width??1;return(typeof n=="number"?n:n.px)>0}function Cl(e){if(!mr(e))return"none";let t=NA.get(e);if(t===void 0){let{paint:n,width:r,join:o,cap:i,miterLimit:s,align:a,dash:l,...u}=e;t=Yd({...u,width:r??1,join:o??"miter",cap:i??"butt",miterLimit:s??4,align:a??"center",dash:l??[]}),NA.set(e,t)}return`${t}|${ao(e.paint)}`}var RA,NA,IA=Z(()=>{"use strict";Jg();Qg();RA=new WeakMap,NA=new WeakMap});function Ol(e){return e!==void 0&&DU.has(e)}function Zg(e){return Ol(e.kind)}function eb(e){return e.kind==="image"}function Xd(e){return e.kind==="texture"||e.kind==="image"||Ol(e.kind)}function Jd(e){let{units:t,origin:n,transform:r,opacity:o}=e;return{...t!==void 0?{units:t}:{},...n!==void 0?{origin:n}:{},...r!==void 0?{transform:r}:{},...o!==void 0?{opacity:o}:{}}}function tb(e){let{units:t,origin:n,transform:r,opacity:o,...i}=e;return i}var EA,DU,MA=Z(()=>{"use strict";EA=["hatch","crosshatch","dots","chunks"],DU=new Set(EA)});function Qd(e,t){let n=t/2;return typeof e=="number"?nb(e)?{left:e/2,right:e/2}:{left:n,right:n}:e==null||typeof e!="object"?{left:n,right:n}:{left:nb(e.left)?e.left:n,right:nb(e.right)?e.right:n}}function Fl(e,t){return typeof e=="number"?e*t:{left:e.left*t,right:e.right*t}}function rb(e,t){let n=e/2;if(t)for(let r of t){let{left:o,right:i}=Qd(r,e);n=Math.max(n,o,i)}return n}var nb,CA=Z(()=>{"use strict";nb=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0});function Bt(e,t){return typeof e=="number"?e:!Number.isFinite(t)||t===0?e.px:e.px/t}function ob(e,t,n=1){if(t==="center")return e;let o=(t==="inner"?-1:1)*n/2;return{x:e.x-o,y:e.y-o,width:e.width+2*o,height:e.height+2*o}}function Zd(e,t){if(e===void 0||e.length===0)return"solid";if(!e.every(Number.isFinite))return"non-finite";if(e.some(n=>n<0)||!e.some(n=>n>0))return"solid";if(t!==void 0){let n=e.reduce((r,o)=>r+o,0);if(t/n*e.length>OA)return"solid"}return e}var OA,FA=Z(()=>{"use strict";OA=1e5});function LA(e){if(!BU.test(e))return null;let t=e.slice(1),n=t.length<=4?t.replace(/./g,"$&$&"):t,r=o=>Number.parseInt(n.slice(o,o+2),16);return[r(0),r(2),r(4),n.length===8?r(6):255]}var BU,_A=Z(()=>{"use strict";BU=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i});function sb(e){if(e<=0)return 0;if(e>=1)return 255;let t=e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055;return Math.round(t*255)}function ef(e,t,n){return HU(ib[e&255],ib[t&255],ib[n&255])}function HU(e,t,n){let r=.4122214708*e+.5363325363*t+.0514459929*n,o=.2119034982*e+.6806995451*t+.1073969566*n,i=.0883024619*e+.2817188376*t+.6299787005*n,s=Math.cbrt(r),a=Math.cbrt(o),l=Math.cbrt(i);return[.2104542553*s+.793617785*a-.0040720468*l,1.9779984951*s-2.428592205*a+.4505937099*l,.0259040371*s+.7827717662*a-.808675766*l]}function Ll(e,t,n){let r=e+.3963377774*t+.2158037573*n,o=e-.1055613458*t-.0638541728*n,i=e-.0894841775*t-1.291485548*n,s=r*r*r,a=o*o*o,l=i*i*i;return[4.0767416621*s-3.3077115913*a+.2309699292*l,-1.2684380046*s+2.6097574011*a-.3413193965*l,-.0041960863*s-.7034186147*a+1.707614701*l]}function DA(e,t,n){return e>=-1e-6&&e<=1+1e-6&&t>=-1e-6&&t<=1+1e-6&&n>=-1e-6&&n<=1+1e-6}function GU(e,t,n){let[r,o,i]=Ll(e,t,n);if(DA(r,o,i))return[r,o,i];let s=0,a=1;for(let l=0;l<5;l++){let u=(s+a)/2;[r,o,i]=Ll(e,t*u,n*u),DA(r,o,i)?s=u:a=u}return[r,o,i]=Ll(e,t*s,n*s),[r,o,i]}function BA(e,t,n){let[r,o,i]=GU(e,t,n);return[sb(r),sb(o),sb(i)]}function UU(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function HA(e,t,n){let r=Math.hypot(t,n),o=Math.atan2(n,t);return[e,r,o]}function lb(e,t,n){return[e,t*Math.cos(n),t*Math.sin(n)]}function VU(e,t,n){let[r,o,i]=e,[s,a,l]=t,u=1e-4,c=o<u?l:i,d=a<u?i:l,f=Math.PI*2,p=d-c;for(;p>Math.PI;)p-=f;for(;p<-Math.PI;)p+=f;return[r+(s-r)*n,o+(a-o)*n,c+p*n]}function GA(e,t,n,r="rgb"){if(e.length!==t.length)throw new Error(`lerpColorArray: length mismatch (from=${e.length}, to=${t.length})`);if(e.length%4!==0)throw new Error(`lerpColorArray: length ${e.length} not divisible by 4`);let o=new Array(e.length),i=e.length/4;if(r==="rgb"){for(let s=0;s<e.length;s++)o[s]=e[s]+(t[s]-e[s])*n;return o}if(r==="oklch"){for(let s=0;s<i;s++){let a=s*4,l=ef(rn(e[a]),rn(e[a+1]),rn(e[a+2])),u=ef(rn(t[a]),rn(t[a+1]),rn(t[a+2])),c=HA(l[0],l[1],l[2]),d=HA(u[0],u[1],u[2]),f=VU(c,d,n),p=lb(f[0],f[1],f[2]),[h,m,g]=BA(p[0],p[1],p[2]);o[a]=vs(h),o[a+1]=vs(m),o[a+2]=vs(g),o[a+3]=e[a+3]+(t[a+3]-e[a+3])*n}return o}for(let s=0;s<i;s++){let a=s*4,l=ef(rn(e[a]),rn(e[a+1]),rn(e[a+2])),u=ef(rn(t[a]),rn(t[a+1]),rn(t[a+2])),c=UU(l,u,n),[d,f,p]=BA(c[0],c[1],c[2]);o[a]=vs(d),o[a+1]=vs(f),o[a+2]=vs(p),o[a+3]=e[a+3]+(t[a+3]-e[a+3])*n}return o}function ub(e){let t=Math.abs(e),n=t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055;return e<0?-n:n}function UA(e,t,n){if(t===0)return[n,n,n];let r=n<.5?n*(1+t):n+t-n*t,o=2*n-r,i=e/360;return[ab(o,r,i+1/3),ab(o,r,i),ab(o,r,i-1/3)]}function ab(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var ib,rn,vs,cb=Z(()=>{"use strict";ib=(()=>{let e=new Float64Array(256);for(let t=0;t<256;t++){let n=t/255;e[t]=n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}return e})();rn=e=>Math.max(0,Math.min(255,Math.round(e*255)));vs=e=>e/255});function VA(e){let t=tf.get(e);if(t!==void 0)return t;let n=zU(e);return tf.size>=WU&&tf.clear(),tf.set(e,n),n}function zU(e){let t=e.trim();if(t.startsWith("#"))return jU(t);let n=t.toLowerCase(),r=JU[n];if(r!==void 0)return r;if(n.startsWith("rgb")){let o=$U(n);if(o)return o}if(n.startsWith("hsl")){let o=YU(n);if(o)return o}if(n.startsWith("color(")){let o=qU(n);if(o)return o}if(n.startsWith("ok")){let o=XU(n);if(o)return o}throw new Error(`parseColor: unrecognized color "${e}"`)}function zn(e){let t=nf.get(e);if(t)return t;nf.size>=KU&&nf.clear();let r=VA(e);return nf.set(e,r),r}function jU(e){let t=LA(e);if(!t)throw new Error(`parseColor: invalid hex "${e}"`);return[t[0]/255,t[1]/255,t[2]/255,t[3]/255]}function ai(e,t){return!e.startsWith(t+"(")||!e.endsWith(")")?null:e.slice(t.length+1,-1).trim()}function of(e){if(e.includes(",")){let i=e.split(",").map(s=>s.trim());return i.length!==3&&i.length!==4?null:{rgb:[i[0],i[1],i[2]],alpha:i.length===4?i[3]:null}}let t=e.indexOf("/"),n=(t===-1?e:e.slice(0,t)).trim(),r=t===-1?null:e.slice(t+1).trim(),o=n.split(/\s+/);return o.length!==3||r!==null&&r===""?null:{rgb:[o[0],o[1],o[2]],alpha:r}}function rf(e,t){if(e.endsWith("%")){let r=Number(e.slice(0,-1));return Number.isFinite(r)?Wn(r/100):null}let n=Number(e);return Number.isFinite(n)?Wn(n/t):null}function sf(e){if(e===null)return 1;if(e.endsWith("%")){let n=Number(e.slice(0,-1));return Number.isFinite(n)?Wn(n/100):1}let t=Number(e);return Number.isFinite(t)?Wn(t):1}function $U(e){let t=ai(e,"rgba")??ai(e,"rgb");if(t===null)return null;let n=of(t);if(!n)return null;let r=rf(n.rgb[0],255),o=rf(n.rgb[1],255),i=rf(n.rgb[2],255);return r===null||o===null||i===null?null:[r,o,i,sf(n.alpha)]}function YU(e){let t=ai(e,"hsla")??ai(e,"hsl");if(t===null)return null;let n=of(t);if(!n)return null;let r=WA(n.rgb[0]),o=db(n.rgb[1]),i=db(n.rgb[2]);if(r===null||o===null||i===null)return null;let[s,a,l]=UA(r,o,i);return[s,a,l,sf(n.alpha)]}function qU(e){let t=ai(e,"color"),n=t?.match(/^(srgb-linear|srgb)\s+/);if(!t||!n||t.includes(","))return null;let r=of(t.slice(n[0].length));if(!r)return null;let o=r.rgb.map(l=>rf(l,1));if(o.some(l=>l===null))return null;let[i,s,a]=n[1]==="srgb"?o:o.map(l=>ub(l));return[Wn(i),Wn(s),Wn(a),sf(r.alpha)]}function XU(e){let t=ai(e,"oklch"),n=t??ai(e,"oklab");if(n===null||n.includes(","))return null;let r=of(n);if(!r)return null;let o=db(r.rgb[0]),i=Number(r.rgb[1]);if(o===null||!Number.isFinite(i))return null;let s=i,a=Number(r.rgb[2]);if(t!==null){let d=WA(r.rgb[2]);if(d===null)return null;[,s,a]=lb(o,i,d*(Math.PI/180))}else if(!Number.isFinite(a))return null;let[l,u,c]=Ll(o,s,a).map(d=>Wn(ub(d)));return[l,u,c,sf(r.alpha)]}function WA(e){let t;return e.endsWith("deg")?t=Number(e.slice(0,-3)):e.endsWith("grad")?t=Number(e.slice(0,-4))*.9:e.endsWith("rad")?t=Number(e.slice(0,-3))*(180/Math.PI):e.endsWith("turn")?t=Number(e.slice(0,-4))*360:t=Number(e),Number.isFinite(t)?(t%360+360)%360:null}function db(e){if(e.endsWith("%")){let n=Number(e.slice(0,-1));return Number.isFinite(n)?Wn(n/100):null}let t=Number(e);return Number.isFinite(t)?Wn(t):null}function Wn(e){return e<0?0:e>1?1:e}var tf,WU,KU,nf,JU,fb=Z(()=>{"use strict";cb();_A();tf=new Map,WU=1024;KU=1024,nf=new Map;JU=(()=>{let e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},t={transparent:[0,0,0,0]};for(let n in e){let r=e[n];t[n]=[(r>>16&255)/255,(r>>8&255)/255,(r&255)/255,1]}return t})()});function pb(e){return[...e].sort((t,n)=>t.offset-n.offset).map(t=>({offset:t.offset,rgba:zn(t.color)}))}function hb(e,t,n="rgb"){if(e.length===0)return ZU;let r=e[0],o=e[e.length-1];if(t<=r.offset)return r.rgba;if(t>=o.offset)return o.rgba;for(let i=0;i<e.length-1;i++){let s=e[i],a=e[i+1];if(t<s.offset||t>a.offset)continue;let l=a.offset-s.offset;if(l<=0)return a.rgba;let u=(t-s.offset)/l,[c,d,f,p]=GA(s.rgba,a.rgba,u,n);return[c,d,f,p]}return o.rgba}var ZU,zA=Z(()=>{"use strict";fb();cb();ZU=[0,0,0,0]});var Pe=Z(()=>{"use strict";Jg();IA();Qg();MA();CA();FA();fb();zA()});var hN=jH((nx,rx)=>{"use strict";(function(e,t){typeof nx=="object"&&typeof rx<"u"?rx.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.polygonClipping=t())})(nx,(function(){"use strict";function e(O,T){var k={label:0,sent:function(){if(I[0]&1)throw I[1];return I[1]},trys:[],ops:[]},R,E,I,H;return H={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function _(U){return function(X){return W([U,X])}}function W(U){if(R)throw new TypeError("Generator is already executing.");for(;k;)try{if(R=1,E&&(I=U[0]&2?E.return:U[0]?E.throw||((I=E.return)&&I.call(E),0):E.next)&&!(I=I.call(E,U[1])).done)return I;switch(E=0,I&&(U=[U[0]&2,I.value]),U[0]){case 0:case 1:I=U;break;case 4:return k.label++,{value:U[1],done:!1};case 5:k.label++,E=U[1],U=[0];continue;case 7:U=k.ops.pop(),k.trys.pop();continue;default:if(I=k.trys,!(I=I.length>0&&I[I.length-1])&&(U[0]===6||U[0]===2)){k=0;continue}if(U[0]===3&&(!I||U[1]>I[0]&&U[1]<I[3])){k.label=U[1];break}if(U[0]===6&&k.label<I[1]){k.label=I[1],I=U;break}if(I&&k.label<I[2]){k.label=I[2],k.ops.push(U);break}I[2]&&k.ops.pop(),k.trys.pop();continue}U=T.call(O,k)}catch(X){U=[6,X],E=0}finally{R=I=0}if(U[0]&5)throw U[1];return{value:U[0]?U[1]:void 0,done:!0}}}var t=(function(){function O(T,k){this.next=null,this.key=T,this.data=k,this.left=null,this.right=null}return O})();function n(O,T){return O>T?1:O<T?-1:0}function r(O,T,k){for(var R=new t(null,null),E=R,I=R;;){var H=k(O,T.key);if(H<0){if(T.left===null)break;if(k(O,T.left.key)<0){var _=T.left;if(T.left=_.right,_.right=T,T=_,T.left===null)break}I.left=T,I=T,T=T.left}else if(H>0){if(T.right===null)break;if(k(O,T.right.key)>0){var _=T.right;if(T.right=_.left,_.left=T,T=_,T.right===null)break}E.right=T,E=T,T=T.right}else break}return E.right=T.left,I.left=T.right,T.left=R.right,T.right=R.left,T}function o(O,T,k,R){var E=new t(O,T);if(k===null)return E.left=E.right=null,E;k=r(O,k,R);var I=R(O,k.key);return I<0?(E.left=k.left,E.right=k,k.left=null):I>=0&&(E.right=k.right,E.left=k,k.right=null),E}function i(O,T,k){var R=null,E=null;if(T){T=r(O,T,k);var I=k(T.key,O);I===0?(R=T.left,E=T.right):I<0?(E=T.right,T.right=null,R=T):(R=T.left,T.left=null,E=T)}return{left:R,right:E}}function s(O,T,k){return T===null?O:(O===null||(T=r(O.key,T,k),T.left=O),T)}function a(O,T,k,R,E){if(O){R(""+T+(k?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+E(O)+`
3
- `);var I=T+(k?" ":"\u2502 ");O.left&&a(O.left,I,!1,R,E),O.right&&a(O.right,I,!0,R,E)}}var l=(function(){function O(T){T===void 0&&(T=n),this._root=null,this._size=0,this._comparator=T}return O.prototype.insert=function(T,k){return this._size++,this._root=o(T,k,this._root,this._comparator)},O.prototype.add=function(T,k){var R=new t(T,k);this._root===null&&(R.left=R.right=null,this._size++,this._root=R);var E=this._comparator,I=r(T,this._root,E),H=E(T,I.key);return H===0?this._root=I:(H<0?(R.left=I.left,R.right=I,I.left=null):H>0&&(R.right=I.right,R.left=I,I.right=null),this._size++,this._root=R),this._root},O.prototype.remove=function(T){this._root=this._remove(T,this._root,this._comparator)},O.prototype._remove=function(T,k,R){var E;if(k===null)return null;k=r(T,k,R);var I=R(T,k.key);return I===0?(k.left===null?E=k.right:(E=r(T,k.left,R),E.right=k.right),this._size--,E):k},O.prototype.pop=function(){var T=this._root;if(T){for(;T.left;)T=T.left;return this._root=r(T.key,this._root,this._comparator),this._root=this._remove(T.key,this._root,this._comparator),{key:T.key,data:T.data}}return null},O.prototype.findStatic=function(T){for(var k=this._root,R=this._comparator;k;){var E=R(T,k.key);if(E===0)return k;E<0?k=k.left:k=k.right}return null},O.prototype.find=function(T){return this._root&&(this._root=r(T,this._root,this._comparator),this._comparator(T,this._root.key)!==0)?null:this._root},O.prototype.contains=function(T){for(var k=this._root,R=this._comparator;k;){var E=R(T,k.key);if(E===0)return!0;E<0?k=k.left:k=k.right}return!1},O.prototype.forEach=function(T,k){for(var R=this._root,E=[],I=!1;!I;)R!==null?(E.push(R),R=R.left):E.length!==0?(R=E.pop(),T.call(k,R),R=R.right):I=!0;return this},O.prototype.range=function(T,k,R,E){for(var I=[],H=this._comparator,_=this._root,W;I.length!==0||_;)if(_)I.push(_),_=_.left;else{if(_=I.pop(),W=H(_.key,k),W>0)break;if(H(_.key,T)>=0&&R.call(E,_))return this;_=_.right}return this},O.prototype.keys=function(){var T=[];return this.forEach(function(k){var R=k.key;return T.push(R)}),T},O.prototype.values=function(){var T=[];return this.forEach(function(k){var R=k.data;return T.push(R)}),T},O.prototype.min=function(){return this._root?this.minNode(this._root).key:null},O.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},O.prototype.minNode=function(T){if(T===void 0&&(T=this._root),T)for(;T.left;)T=T.left;return T},O.prototype.maxNode=function(T){if(T===void 0&&(T=this._root),T)for(;T.right;)T=T.right;return T},O.prototype.at=function(T){for(var k=this._root,R=!1,E=0,I=[];!R;)if(k)I.push(k),k=k.left;else if(I.length>0){if(k=I.pop(),E===T)return k;E++,k=k.right}else R=!0;return null},O.prototype.next=function(T){var k=this._root,R=null;if(T.right){for(R=T.right;R.left;)R=R.left;return R}for(var E=this._comparator;k;){var I=E(T.key,k.key);if(I===0)break;I<0?(R=k,k=k.left):k=k.right}return R},O.prototype.prev=function(T){var k=this._root,R=null;if(T.left!==null){for(R=T.left;R.right;)R=R.right;return R}for(var E=this._comparator;k;){var I=E(T.key,k.key);if(I===0)break;I<0?k=k.left:(R=k,k=k.right)}return R},O.prototype.clear=function(){return this._root=null,this._size=0,this},O.prototype.toList=function(){return d(this._root)},O.prototype.load=function(T,k,R){k===void 0&&(k=[]),R===void 0&&(R=!1);var E=T.length,I=this._comparator;if(R&&h(T,k,0,E-1,I),this._root===null)this._root=u(T,k,0,E),this._size=E;else{var H=p(this.toList(),c(T,k),I);E=this._size+E,this._root=f({head:H},0,E)}return this},O.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(O.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),O.prototype.toString=function(T){T===void 0&&(T=function(R){return String(R.key)});var k=[];return a(this._root,"",!0,function(R){return k.push(R)},T),k.join("")},O.prototype.update=function(T,k,R){var E=this._comparator,I=i(T,this._root,E),H=I.left,_=I.right;E(T,k)<0?_=o(k,R,_,E):H=o(k,R,H,E),this._root=s(H,_,E)},O.prototype.split=function(T){return i(T,this._root,this._comparator)},O.prototype[Symbol.iterator]=function(){var T,k,R;return e(this,function(E){switch(E.label){case 0:T=this._root,k=[],R=!1,E.label=1;case 1:return R?[3,6]:T===null?[3,2]:(k.push(T),T=T.left,[3,5]);case 2:return k.length===0?[3,4]:(T=k.pop(),[4,T]);case 3:return E.sent(),T=T.right,[3,5];case 4:R=!0,E.label=5;case 5:return[3,1];case 6:return[2]}})},O})();function u(O,T,k,R){var E=R-k;if(E>0){var I=k+Math.floor(E/2),H=O[I],_=T[I],W=new t(H,_);return W.left=u(O,T,k,I),W.right=u(O,T,I+1,R),W}return null}function c(O,T){for(var k=new t(null,null),R=k,E=0;E<O.length;E++)R=R.next=new t(O[E],T[E]);return R.next=null,k.next}function d(O){for(var T=O,k=[],R=!1,E=new t(null,null),I=E;!R;)T?(k.push(T),T=T.left):k.length>0?(T=I=I.next=k.pop(),T=T.right):R=!0;return I.next=null,E.next}function f(O,T,k){var R=k-T;if(R>0){var E=T+Math.floor(R/2),I=f(O,T,E),H=O.head;return H.left=I,O.head=O.head.next,H.right=f(O,E+1,k),H}return null}function p(O,T,k){for(var R=new t(null,null),E=R,I=O,H=T;I!==null&&H!==null;)k(I.key,H.key)<0?(E.next=I,I=I.next):(E.next=H,H=H.next),E=E.next;return I!==null?E.next=I:H!==null&&(E.next=H),R.next}function h(O,T,k,R,E){if(!(k>=R)){for(var I=O[k+R>>1],H=k-1,_=R+1;;){do H++;while(E(O[H],I)<0);do _--;while(E(O[_],I)>0);if(H>=_)break;var W=O[H];O[H]=O[_],O[_]=W,W=T[H],T[H]=T[_],T[_]=W}h(O,T,k,_,E),h(O,T,_+1,R,E)}}let m=(O,T)=>O.ll.x<=T.x&&T.x<=O.ur.x&&O.ll.y<=T.y&&T.y<=O.ur.y,g=(O,T)=>{if(T.ur.x<O.ll.x||O.ur.x<T.ll.x||T.ur.y<O.ll.y||O.ur.y<T.ll.y)return null;let k=O.ll.x<T.ll.x?T.ll.x:O.ll.x,R=O.ur.x<T.ur.x?O.ur.x:T.ur.x,E=O.ll.y<T.ll.y?T.ll.y:O.ll.y,I=O.ur.y<T.ur.y?O.ur.y:T.ur.y;return{ll:{x:k,y:E},ur:{x:R,y:I}}},b=Number.EPSILON;b===void 0&&(b=Math.pow(2,-52));let x=b*b,w=(O,T)=>{if(-b<O&&O<b&&-b<T&&T<b)return 0;let k=O-T;return k*k<x*O*T?0:O<T?-1:1};class y{constructor(){this.reset()}reset(){this.xRounder=new P,this.yRounder=new P}round(T,k){return{x:this.xRounder.round(T),y:this.yRounder.round(k)}}}class P{constructor(){this.tree=new l,this.round(0)}round(T){let k=this.tree.add(T),R=this.tree.prev(k);if(R!==null&&w(k.key,R.key)===0)return this.tree.remove(T),R.key;let E=this.tree.next(k);return E!==null&&w(k.key,E.key)===0?(this.tree.remove(T),E.key):T}}let S=new y,v=11102230246251565e-32,A=134217729,N=(3+8*v)*v;function M(O,T,k,R,E){let I,H,_,W,U=T[0],X=R[0],L=0,z=0;X>U==X>-U?(I=U,U=T[++L]):(I=X,X=R[++z]);let Y=0;if(L<O&&z<k)for(X>U==X>-U?(H=U+I,_=I-(H-U),U=T[++L]):(H=X+I,_=I-(H-X),X=R[++z]),I=H,_!==0&&(E[Y++]=_);L<O&&z<k;)X>U==X>-U?(H=I+U,W=H-I,_=I-(H-W)+(U-W),U=T[++L]):(H=I+X,W=H-I,_=I-(H-W)+(X-W),X=R[++z]),I=H,_!==0&&(E[Y++]=_);for(;L<O;)H=I+U,W=H-I,_=I-(H-W)+(U-W),U=T[++L],I=H,_!==0&&(E[Y++]=_);for(;z<k;)H=I+X,W=H-I,_=I-(H-W)+(X-W),X=R[++z],I=H,_!==0&&(E[Y++]=_);return(I!==0||Y===0)&&(E[Y++]=I),Y}function C(O,T){let k=T[0];for(let R=1;R<O;R++)k+=T[R];return k}function F(O){return new Float64Array(O)}let B=(3+16*v)*v,D=(2+12*v)*v,j=(9+64*v)*v*v,V=F(4),J=F(8),se=F(12),ke=F(16),ae=F(4);function ve(O,T,k,R,E,I,H){let _,W,U,X,L,z,Y,ie,re,ge,de,Ee,ct,je,dt,ft,qt,pt,pn=O-E,hn=k-E,mn=T-I,yn=R-I;je=pn*yn,z=A*pn,Y=z-(z-pn),ie=pn-Y,z=A*yn,re=z-(z-yn),ge=yn-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=mn*hn,z=A*mn,Y=z-(z-mn),ie=mn-Y,z=A*hn,re=z-(z-hn),ge=hn-re,qt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-qt,L=dt-de,V[0]=dt-(de+L)+(L-qt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,V[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,V[2]=Ee-(pt-L)+(de-L),V[3]=pt;let lr=C(4,V),$a=D*H;if(lr>=$a||-lr>=$a||(L=O-pn,_=O-(pn+L)+(L-E),L=k-hn,U=k-(hn+L)+(L-E),L=T-mn,W=T-(mn+L)+(L-I),L=R-yn,X=R-(yn+L)+(L-I),_===0&&W===0&&U===0&&X===0)||($a=j*H+N*Math.abs(lr),lr+=pn*X+yn*_-(mn*U+hn*W),lr>=$a||-lr>=$a))return lr;je=_*yn,z=A*_,Y=z-(z-_),ie=_-Y,z=A*yn,re=z-(z-yn),ge=yn-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=W*hn,z=A*W,Y=z-(z-W),ie=W-Y,z=A*hn,re=z-(z-hn),ge=hn-re,qt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-qt,L=dt-de,ae[0]=dt-(de+L)+(L-qt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,ae[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,ae[2]=Ee-(pt-L)+(de-L),ae[3]=pt;let BH=M(4,V,4,ae,J);je=pn*X,z=A*pn,Y=z-(z-pn),ie=pn-Y,z=A*X,re=z-(z-X),ge=X-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=mn*U,z=A*mn,Y=z-(z-mn),ie=mn-Y,z=A*U,re=z-(z-U),ge=U-re,qt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-qt,L=dt-de,ae[0]=dt-(de+L)+(L-qt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,ae[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,ae[2]=Ee-(pt-L)+(de-L),ae[3]=pt;let HH=M(BH,J,4,ae,se);je=_*X,z=A*_,Y=z-(z-_),ie=_-Y,z=A*X,re=z-(z-X),ge=X-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=W*U,z=A*W,Y=z-(z-W),ie=W-Y,z=A*U,re=z-(z-U),ge=U-re,qt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-qt,L=dt-de,ae[0]=dt-(de+L)+(L-qt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,ae[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,ae[2]=Ee-(pt-L)+(de-L),ae[3]=pt;let GH=M(HH,se,4,ae,ke);return ke[GH-1]}function G(O,T,k,R,E,I){let H=(T-I)*(k-E),_=(O-E)*(R-I),W=H-_,U=Math.abs(H+_);return Math.abs(W)>=B*U?W:-ve(O,T,k,R,E,I,U)}let K=(O,T)=>O.x*T.y-O.y*T.x,$=(O,T)=>O.x*T.x+O.y*T.y,Q=(O,T,k)=>{let R=G(O.x,O.y,T.x,T.y,k.x,k.y);return R>0?-1:R<0?1:0},te=O=>Math.sqrt($(O,O)),he=(O,T,k)=>{let R={x:T.x-O.x,y:T.y-O.y},E={x:k.x-O.x,y:k.y-O.y};return K(E,R)/te(E)/te(R)},be=(O,T,k)=>{let R={x:T.x-O.x,y:T.y-O.y},E={x:k.x-O.x,y:k.y-O.y};return $(E,R)/te(E)/te(R)},Fe=(O,T,k)=>T.y===0?null:{x:O.x+T.x/T.y*(k-O.y),y:k},Se=(O,T,k)=>T.x===0?null:{x:k,y:O.y+T.y/T.x*(k-O.x)},ar=(O,T,k,R)=>{if(T.x===0)return Se(k,R,O.x);if(R.x===0)return Se(O,T,k.x);if(T.y===0)return Fe(k,R,O.y);if(R.y===0)return Fe(O,T,k.y);let E=K(T,R);if(E==0)return null;let I={x:k.x-O.x,y:k.y-O.y},H=K(I,T)/E,_=K(I,R)/E,W=O.x+_*T.x,U=k.x+H*R.x,X=O.y+_*T.y,L=k.y+H*R.y,z=(W+U)/2,Y=(X+L)/2;return{x:z,y:Y}};class Le{static compare(T,k){let R=Le.comparePoints(T.point,k.point);return R!==0?R:(T.point!==k.point&&T.link(k),T.isLeft!==k.isLeft?T.isLeft?1:-1:Yt.compare(T.segment,k.segment))}static comparePoints(T,k){return T.x<k.x?-1:T.x>k.x?1:T.y<k.y?-1:T.y>k.y?1:0}constructor(T,k){T.events===void 0?T.events=[this]:T.events.push(this),this.point=T,this.isLeft=k}link(T){if(T.point===this.point)throw new Error("Tried to link already linked events");let k=T.point.events;for(let R=0,E=k.length;R<E;R++){let I=k[R];this.point.events.push(I),I.point=this.point}this.checkForConsuming()}checkForConsuming(){let T=this.point.events.length;for(let k=0;k<T;k++){let R=this.point.events[k];if(R.segment.consumedBy===void 0)for(let E=k+1;E<T;E++){let I=this.point.events[E];I.consumedBy===void 0&&R.otherSE.point.events===I.otherSE.point.events&&R.segment.consume(I.segment)}}}getAvailableLinkedEvents(){let T=[];for(let k=0,R=this.point.events.length;k<R;k++){let E=this.point.events[k];E!==this&&!E.segment.ringOut&&E.segment.isInResult()&&T.push(E)}return T}getLeftmostComparator(T){let k=new Map,R=E=>{let I=E.otherSE;k.set(E,{sine:he(this.point,T.point,I.point),cosine:be(this.point,T.point,I.point)})};return(E,I)=>{k.has(E)||R(E),k.has(I)||R(I);let{sine:H,cosine:_}=k.get(E),{sine:W,cosine:U}=k.get(I);return H>=0&&W>=0?_<U?1:_>U?-1:0:H<0&&W<0?_<U?-1:_>U?1:0:W<H?-1:W>H?1:0}}}let kt=0;class Yt{static compare(T,k){let R=T.leftSE.point.x,E=k.leftSE.point.x,I=T.rightSE.point.x,H=k.rightSE.point.x;if(H<R)return 1;if(I<E)return-1;let _=T.leftSE.point.y,W=k.leftSE.point.y,U=T.rightSE.point.y,X=k.rightSE.point.y;if(R<E){if(W<_&&W<U)return 1;if(W>_&&W>U)return-1;let L=T.comparePoint(k.leftSE.point);if(L<0)return 1;if(L>0)return-1;let z=k.comparePoint(T.rightSE.point);return z!==0?z:-1}if(R>E){if(_<W&&_<X)return-1;if(_>W&&_>X)return 1;let L=k.comparePoint(T.leftSE.point);if(L!==0)return L;let z=T.comparePoint(k.rightSE.point);return z<0?1:z>0?-1:1}if(_<W)return-1;if(_>W)return 1;if(I<H){let L=k.comparePoint(T.rightSE.point);if(L!==0)return L}if(I>H){let L=T.comparePoint(k.rightSE.point);if(L<0)return 1;if(L>0)return-1}if(I!==H){let L=U-_,z=I-R,Y=X-W,ie=H-E;if(L>z&&Y<ie)return 1;if(L<z&&Y>ie)return-1}return I>H?1:I<H||U<X?-1:U>X?1:T.id<k.id?-1:T.id>k.id?1:0}constructor(T,k,R,E){this.id=++kt,this.leftSE=T,T.segment=this,T.otherSE=k,this.rightSE=k,k.segment=this,k.otherSE=T,this.rings=R,this.windings=E}static fromRing(T,k,R){let E,I,H,_=Le.comparePoints(T,k);if(_<0)E=T,I=k,H=1;else if(_>0)E=k,I=T,H=-1;else throw new Error(`Tried to create degenerate segment at [${T.x}, ${T.y}]`);let W=new Le(E,!0),U=new Le(I,!1);return new Yt(W,U,[R],[H])}replaceRightSE(T){this.rightSE=T,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let T=this.leftSE.point.y,k=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:T<k?T:k},ur:{x:this.rightSE.point.x,y:T>k?T:k}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(T){return T.x===this.leftSE.point.x&&T.y===this.leftSE.point.y||T.x===this.rightSE.point.x&&T.y===this.rightSE.point.y}comparePoint(T){if(this.isAnEndpoint(T))return 0;let k=this.leftSE.point,R=this.rightSE.point,E=this.vector();if(k.x===R.x)return T.x===k.x?0:T.x<k.x?1:-1;let I=(T.y-k.y)/E.y,H=k.x+I*E.x;if(T.x===H)return 0;let _=(T.x-k.x)/E.x,W=k.y+_*E.y;return T.y===W?0:T.y<W?-1:1}getIntersection(T){let k=this.bbox(),R=T.bbox(),E=g(k,R);if(E===null)return null;let I=this.leftSE.point,H=this.rightSE.point,_=T.leftSE.point,W=T.rightSE.point,U=m(k,_)&&this.comparePoint(_)===0,X=m(R,I)&&T.comparePoint(I)===0,L=m(k,W)&&this.comparePoint(W)===0,z=m(R,H)&&T.comparePoint(H)===0;if(X&&U)return z&&!L?H:!z&&L?W:null;if(X)return L&&I.x===W.x&&I.y===W.y?null:I;if(U)return z&&H.x===_.x&&H.y===_.y?null:_;if(z&&L)return null;if(z)return H;if(L)return W;let Y=ar(I,this.vector(),_,T.vector());return Y===null||!m(E,Y)?null:S.round(Y.x,Y.y)}split(T){let k=[],R=T.events!==void 0,E=new Le(T,!0),I=new Le(T,!1),H=this.rightSE;this.replaceRightSE(I),k.push(I),k.push(E);let _=new Yt(E,H,this.rings.slice(),this.windings.slice());return Le.comparePoints(_.leftSE.point,_.rightSE.point)>0&&_.swapEvents(),Le.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),R&&(E.checkForConsuming(),I.checkForConsuming()),k}swapEvents(){let T=this.rightSE;this.rightSE=this.leftSE,this.leftSE=T,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let k=0,R=this.windings.length;k<R;k++)this.windings[k]*=-1}consume(T){let k=this,R=T;for(;k.consumedBy;)k=k.consumedBy;for(;R.consumedBy;)R=R.consumedBy;let E=Yt.compare(k,R);if(E!==0){if(E>0){let I=k;k=R,R=I}if(k.prev===R){let I=k;k=R,R=I}for(let I=0,H=R.rings.length;I<H;I++){let _=R.rings[I],W=R.windings[I],U=k.rings.indexOf(_);U===-1?(k.rings.push(_),k.windings.push(W)):k.windings[U]+=W}R.rings=null,R.windings=null,R.consumedBy=k,R.leftSE.consumedBy=k.leftSE,R.rightSE.consumedBy=k.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{let T=this.prev.consumedBy||this.prev;this._beforeState=T.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;let T=this.beforeState();this._afterState={rings:T.rings.slice(0),windings:T.windings.slice(0),multiPolys:[]};let k=this._afterState.rings,R=this._afterState.windings,E=this._afterState.multiPolys;for(let _=0,W=this.rings.length;_<W;_++){let U=this.rings[_],X=this.windings[_],L=k.indexOf(U);L===-1?(k.push(U),R.push(X)):R[L]+=X}let I=[],H=[];for(let _=0,W=k.length;_<W;_++){if(R[_]===0)continue;let U=k[_],X=U.poly;if(H.indexOf(X)===-1)if(U.isExterior)I.push(X);else{H.indexOf(X)===-1&&H.push(X);let L=I.indexOf(U.poly);L!==-1&&I.splice(L,1)}}for(let _=0,W=I.length;_<W;_++){let U=I[_].multiPoly;E.indexOf(U)===-1&&E.push(U)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;let T=this.beforeState().multiPolys,k=this.afterState().multiPolys;switch(fn.type){case"union":{let R=T.length===0,E=k.length===0;this._isInResult=R!==E;break}case"intersection":{let R,E;T.length<k.length?(R=T.length,E=k.length):(R=k.length,E=T.length),this._isInResult=E===fn.numMultiPolys&&R<E;break}case"xor":{let R=Math.abs(T.length-k.length);this._isInResult=R%2===1;break}case"difference":{let R=E=>E.length===1&&E[0].isSubject;this._isInResult=R(T)!==R(k);break}default:throw new Error(`Unrecognized operation type found ${fn.type}`)}return this._isInResult}}class Cc{constructor(T,k,R){if(!Array.isArray(T)||T.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=k,this.isExterior=R,this.segments=[],typeof T[0][0]!="number"||typeof T[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let E=S.round(T[0][0],T[0][1]);this.bbox={ll:{x:E.x,y:E.y},ur:{x:E.x,y:E.y}};let I=E;for(let H=1,_=T.length;H<_;H++){if(typeof T[H][0]!="number"||typeof T[H][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let W=S.round(T[H][0],T[H][1]);W.x===I.x&&W.y===I.y||(this.segments.push(Yt.fromRing(I,W,this)),W.x<this.bbox.ll.x&&(this.bbox.ll.x=W.x),W.y<this.bbox.ll.y&&(this.bbox.ll.y=W.y),W.x>this.bbox.ur.x&&(this.bbox.ur.x=W.x),W.y>this.bbox.ur.y&&(this.bbox.ur.y=W.y),I=W)}(E.x!==I.x||E.y!==I.y)&&this.segments.push(Yt.fromRing(I,E,this))}getSweepEvents(){let T=[];for(let k=0,R=this.segments.length;k<R;k++){let E=this.segments[k];T.push(E.leftSE),T.push(E.rightSE)}return T}}class ny{constructor(T,k){if(!Array.isArray(T))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new Cc(T[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let R=1,E=T.length;R<E;R++){let I=new Cc(T[R],this,!1);I.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=I.bbox.ll.x),I.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=I.bbox.ll.y),I.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=I.bbox.ur.x),I.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=I.bbox.ur.y),this.interiorRings.push(I)}this.multiPoly=k}getSweepEvents(){let T=this.exteriorRing.getSweepEvents();for(let k=0,R=this.interiorRings.length;k<R;k++){let E=this.interiorRings[k].getSweepEvents();for(let I=0,H=E.length;I<H;I++)T.push(E[I])}return T}}class Oc{constructor(T,k){if(!Array.isArray(T))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof T[0][0][0]=="number"&&(T=[T])}catch{}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let R=0,E=T.length;R<E;R++){let I=new ny(T[R],this);I.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=I.bbox.ll.x),I.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=I.bbox.ll.y),I.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=I.bbox.ur.x),I.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=I.bbox.ur.y),this.polys.push(I)}this.isSubject=k}getSweepEvents(){let T=[];for(let k=0,R=this.polys.length;k<R;k++){let E=this.polys[k].getSweepEvents();for(let I=0,H=E.length;I<H;I++)T.push(E[I])}return T}}class Fc{static factory(T){let k=[];for(let R=0,E=T.length;R<E;R++){let I=T[R];if(!I.isInResult()||I.ringOut)continue;let H=null,_=I.leftSE,W=I.rightSE,U=[_],X=_.point,L=[];for(;H=_,_=W,U.push(_),_.point!==X;)for(;;){let z=_.getAvailableLinkedEvents();if(z.length===0){let re=U[0].point,ge=U[U.length-1].point;throw new Error(`Unable to complete output ring starting at [${re.x}, ${re.y}]. Last matching segment found ends at [${ge.x}, ${ge.y}].`)}if(z.length===1){W=z[0].otherSE;break}let Y=null;for(let re=0,ge=L.length;re<ge;re++)if(L[re].point===_.point){Y=re;break}if(Y!==null){let re=L.splice(Y)[0],ge=U.splice(re.index);ge.unshift(ge[0].otherSE),k.push(new Fc(ge.reverse()));continue}L.push({index:U.length,point:_.point});let ie=_.getLeftmostComparator(H);W=z.sort(ie)[0].otherSE;break}k.push(new Fc(U))}return k}constructor(T){this.events=T;for(let k=0,R=T.length;k<R;k++)T[k].segment.ringOut=this;this.poly=null}getGeom(){let T=this.events[0].point,k=[T];for(let U=1,X=this.events.length-1;U<X;U++){let L=this.events[U].point,z=this.events[U+1].point;Q(L,T,z)!==0&&(k.push(L),T=L)}if(k.length===1)return null;let R=k[0],E=k[1];Q(R,T,E)===0&&k.shift(),k.push(k[0]);let I=this.isExteriorRing()?1:-1,H=this.isExteriorRing()?0:k.length-1,_=this.isExteriorRing()?k.length:-1,W=[];for(let U=H;U!=_;U+=I)W.push([k[U].x,k[U].y]);return W}isExteriorRing(){if(this._isExteriorRing===void 0){let T=this.enclosingRing();this._isExteriorRing=T?!T.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let T=this.events[0];for(let E=1,I=this.events.length;E<I;E++){let H=this.events[E];Le.compare(T,H)>0&&(T=H)}let k=T.segment.prevInResult(),R=k?k.prevInResult():null;for(;;){if(!k)return null;if(!R)return k.ringOut;if(R.ringOut!==k.ringOut)return R.ringOut.enclosingRing()!==k.ringOut?k.ringOut:k.ringOut.enclosingRing();k=R.prevInResult(),R=k?k.prevInResult():null}}}class k1{constructor(T){this.exteriorRing=T,T.poly=this,this.interiorRings=[]}addInterior(T){this.interiorRings.push(T),T.poly=this}getGeom(){let T=[this.exteriorRing.getGeom()];if(T[0]===null)return null;for(let k=0,R=this.interiorRings.length;k<R;k++){let E=this.interiorRings[k].getGeom();E!==null&&T.push(E)}return T}}class OH{constructor(T){this.rings=T,this.polys=this._composePolys(T)}getGeom(){let T=[];for(let k=0,R=this.polys.length;k<R;k++){let E=this.polys[k].getGeom();E!==null&&T.push(E)}return T}_composePolys(T){let k=[];for(let R=0,E=T.length;R<E;R++){let I=T[R];if(!I.poly)if(I.isExteriorRing())k.push(new k1(I));else{let H=I.enclosingRing();H.poly||k.push(new k1(H)),H.poly.addInterior(I)}}return k}}class FH{constructor(T){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Yt.compare;this.queue=T,this.tree=new l(k),this.segments=[]}process(T){let k=T.segment,R=[];if(T.consumedBy)return T.isLeft?this.queue.remove(T.otherSE):this.tree.remove(k),R;let E=T.isLeft?this.tree.add(k):this.tree.find(k);if(!E)throw new Error(`Unable to find segment #${k.id} [${k.leftSE.point.x}, ${k.leftSE.point.y}] -> [${k.rightSE.point.x}, ${k.rightSE.point.y}] in SweepLine tree.`);let I=E,H=E,_,W;for(;_===void 0;)I=this.tree.prev(I),I===null?_=null:I.key.consumedBy===void 0&&(_=I.key);for(;W===void 0;)H=this.tree.next(H),H===null?W=null:H.key.consumedBy===void 0&&(W=H.key);if(T.isLeft){let U=null;if(_){let L=_.getIntersection(k);if(L!==null&&(k.isAnEndpoint(L)||(U=L),!_.isAnEndpoint(L))){let z=this._splitSafely(_,L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}}let X=null;if(W){let L=W.getIntersection(k);if(L!==null&&(k.isAnEndpoint(L)||(X=L),!W.isAnEndpoint(L))){let z=this._splitSafely(W,L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}}if(U!==null||X!==null){let L=null;U===null?L=X:X===null?L=U:L=Le.comparePoints(U,X)<=0?U:X,this.queue.remove(k.rightSE),R.push(k.rightSE);let z=k.split(L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}R.length>0?(this.tree.remove(k),R.push(T)):(this.segments.push(k),k.prev=_)}else{if(_&&W){let U=_.getIntersection(W);if(U!==null){if(!_.isAnEndpoint(U)){let X=this._splitSafely(_,U);for(let L=0,z=X.length;L<z;L++)R.push(X[L])}if(!W.isAnEndpoint(U)){let X=this._splitSafely(W,U);for(let L=0,z=X.length;L<z;L++)R.push(X[L])}}}this.tree.remove(k)}return R}_splitSafely(T,k){this.tree.remove(T);let R=T.rightSE;this.queue.remove(R);let E=T.split(k);return E.push(R),T.consumedBy===void 0&&this.tree.add(T),E}}let v1=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,LH=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class _H{run(T,k,R){fn.type=T,S.reset();let E=[new Oc(k,!0)];for(let L=0,z=R.length;L<z;L++)E.push(new Oc(R[L],!1));if(fn.numMultiPolys=E.length,fn.type==="difference"){let L=E[0],z=1;for(;z<E.length;)g(E[z].bbox,L.bbox)!==null?z++:E.splice(z,1)}if(fn.type==="intersection")for(let L=0,z=E.length;L<z;L++){let Y=E[L];for(let ie=L+1,re=E.length;ie<re;ie++)if(g(Y.bbox,E[ie].bbox)===null)return[]}let I=new l(Le.compare);for(let L=0,z=E.length;L<z;L++){let Y=E[L].getSweepEvents();for(let ie=0,re=Y.length;ie<re;ie++)if(I.insert(Y[ie]),I.size>v1)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}let H=new FH(I),_=I.size,W=I.pop();for(;W;){let L=W.key;if(I.size===_){let Y=L.segment;throw new Error(`Unable to pop() ${L.isLeft?"left":"right"} SweepEvent [${L.point.x}, ${L.point.y}] from segment #${Y.id} [${Y.leftSE.point.x}, ${Y.leftSE.point.y}] -> [${Y.rightSE.point.x}, ${Y.rightSE.point.y}] from queue.`)}if(I.size>v1)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(H.segments.length>LH)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");let z=H.process(L);for(let Y=0,ie=z.length;Y<ie;Y++){let re=z[Y];re.consumedBy===void 0&&I.insert(re)}_=I.size,W=I.pop()}S.reset();let U=Fc.factory(H.segments);return new OH(U).getGeom()}}let fn=new _H;var DH={union:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return fn.run("union",O,k)},intersection:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return fn.run("intersection",O,k)},xor:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return fn.run("xor",O,k)},difference:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return fn.run("difference",O,k)}};return DH}))});function Ya(){let e=[];return{onRelease(t){e?e.push(t):t()},release(){let t=e;e=null;for(let n of t??[])n()}}}var Lc=class extends Error{constructor(n,r){super(`shader ${n} failure: ${r}`);this.stage=n;this.log=r;this.name="ShaderCompileError"}stage;log},_c=0,$r=class{constructor(t,n,r){this.gl=t;let o=this.compile(t.VERTEX_SHADER,n,"vertex"),i;try{i=this.compile(t.FRAGMENT_SHADER,r,"fragment")}catch(a){throw t.deleteShader(o),a}let s=t.createProgram();if(!s)throw t.deleteShader(o),t.deleteShader(i),new Error("createProgram returned null");if(t.attachShader(s,o),t.attachShader(s,i),t.bindAttribLocation(s,_c,"a_position"),t.linkProgram(s),t.deleteShader(o),t.deleteShader(i),!t.getProgramParameter(s,t.LINK_STATUS)){let a=t.getProgramInfoLog(s)??"";throw t.deleteProgram(s),new Lc("link",a)}this.handle=s}gl;handle;uniforms=new Map;arrays=new Map;attributes=new Map;compile(t,n,r){let o=this.gl,i=o.createShader(t);if(!i)throw new Error("createShader returned null");if(o.shaderSource(i,n),o.compileShader(i),!o.getShaderParameter(i,o.COMPILE_STATUS)){let s=o.getShaderInfoLog(i)??"";throw o.deleteShader(i),new Lc(r,s)}return i}lookupUniforms(t){for(let n of t){let r=this.gl.getUniformLocation(this.handle,n);r!==null&&this.uniforms.set(n,r)}}lookupUniformArrays(t){for(let[n,{type:r,size:o}]of t){let i=`${n}[0]`,s=this.uniforms.get(i)??this.gl.getUniformLocation(this.handle,i);s!==null&&this.arrays.set(n,{type:r,size:o,location:s})}}lookupAttributes(t){for(let n of t){let r=this.gl.getAttribLocation(this.handle,n);r>=0&&this.attributes.set(n,r)}}uniform(t){return this.uniforms.get(t)}uniformArray(t){return this.arrays.get(t)}attribute(t){return this.attributes.get(t)}};var A1=`#version 300 es
1
+ "use strict";(()=>{var eG=Object.create;var fy=Object.defineProperty;var tG=Object.getOwnPropertyDescriptor;var nG=Object.getOwnPropertyNames;var rG=Object.getPrototypeOf,oG=Object.prototype.hasOwnProperty;var Q=(e,t)=>()=>(e&&(t=e(e=0)),t);var iG=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),sG=(e,t)=>{for(var n in t)fy(e,n,{get:t[n],enumerable:!0})},aG=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of nG(t))!oG.call(e,o)&&o!==n&&fy(e,o,{get:()=>t[o],enumerable:!(r=tG(t,o))||r.enumerable});return e};var lG=(e,t,n)=>(n=e!=null?eG(rG(e)):{},aG(t||!e||!e.__esModule?fy(n,"default",{value:e,enumerable:!0}):n,e));function ls(e){return e<0?0:e>1?1:e}function fr(e,t,n){return e+(t-e)*n}function us(e){return e>0?1:e<0?-1:0}var ml=Q(()=>{"use strict"});function xd(e,t){return[1,0,0,1,e,t]}function yl(e){let t=Math.cos(e),n=Math.sin(e);return[t,n,-n,t,0,0]}function ht(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function pr(e){let t=e[0]*e[3]-e[1]*e[2],n=Math.max(e[0]*e[0]+e[1]*e[1],e[2]*e[2]+e[3]*e[3]);if(!(Math.abs(t)>1e-12*n))return null;let r=1/t,o=e[3]*r,i=-e[1]*r,s=-e[2]*r,a=e[0]*r;return[o,i,s,a,-(e[4]*o+e[5]*s),-(e[4]*i+e[5]*a)]}function wn(e,t,n){return[e[0]*t+e[2]*n+e[4],e[1]*t+e[3]*n+e[5]]}function hr(e,t,n,r,o,i,s,a){let l=n===0?1:s/n,u=r===0?1:a/r;return[l,0,0,u,o-e*l,i-t*u]}function ro(e,t,n){return ht(xd(e,t),ht(yl(n),xd(-e,-t)))}function $y(e,t){let n=new Float64Array(e.length),r=t[0],o=t[1],i=t[2],s=t[3],a=t[4],l=t[5];for(let u=0;u+1<e.length;u+=2){let c=e[u],d=e[u+1];n[u]=r*c+i*d+a,n[u+1]=o*c+s*d+l}return n}var cs=Q(()=>{"use strict"});function wd(e,t){return t[0]>=e[0]&&t[1]>=e[1]&&t[2]<=e[2]&&t[3]<=e[3]}function gl(e,t,n,r){return Float64Array.of(e,t,e+n,t,e+n,t+r,e,t+r)}function Yy(e,t){return e[0]<=t[2]&&t[0]<=e[2]&&e[1]<=t[3]&&t[1]<=e[3]}var bl=Q(()=>{"use strict"});function qG(){let e=[];for(let{code:t,coords:n}of Object.values(Zo))e[t]=n;return e}function oo(e){return zS[e]}function Ge(e,t,n){let r=0,o=0,i=0,s=0,a=0,l=!1;for(let u=0;u<e.length;u++){let c=e[u],d=!l&&c!==le&&c!==fe;if(d&&(s=o,a=i),l=c!==fe,n(c,r,o,i,u,d)===!1)return;let f=oo(c);if(f===void 0)throw new Error(`forEachSegment: unknown command code ${c}`);f>0?(o=t[r+f-2],i=t[r+f-1],r+=f,c===le&&(s=o,a=i)):c===fe&&(o=s,i=a)}}var Zo,le,ce,xe,we,fe,zS,Je=Q(()=>{"use strict";Zo={M:{code:0,coords:2},L:{code:1,coords:2},C:{code:2,coords:6},Q:{code:3,coords:4},Z:{code:4,coords:0}},le=Zo.M.code,ce=Zo.L.code,xe=Zo.C.code,we=Zo.Q.code,fe=Zo.Z.code,zS=qG()});function Ve(e,t,n,r,o,i,s,a,l){let u=1-l,c=u*u*u,d=3*u*u*l,f=3*u*l*l,p=l*l*l;return[c*e+d*n+f*o+p*s,c*t+d*r+f*i+p*a]}function io(e,t,n,r,o,i){return[e+2/3*(n-e),t+2/3*(r-t),o+2/3*(n-o),i+2/3*(r-i)]}function KS(e,t,n,r){let o=-e+3*t-3*n+r,i=2*(e-2*t+n),s=-e+t,a=[],l=u=>{u>0&&u<1&&a.push(u)};if(Math.abs(o)<1e-12)Math.abs(i)>1e-12&&l(-s/i);else{let u=i*i-4*o*s;if(u>=0){let c=Math.sqrt(u);l((-i+c)/(2*o)),l((-i-c)/(2*o))}}return a}function qy(e,t,n,r,o,i,s,a){let l=Math.min(e,s),u=Math.max(e,s),c=Math.min(t,a),d=Math.max(t,a);for(let f of KS(e,n,o,s)){let[p]=Ve(e,t,n,r,o,i,s,a,f);p<l&&(l=p),p>u&&(u=p)}for(let f of KS(t,r,i,a)){let[,p]=Ve(e,t,n,r,o,i,s,a,f);p<c&&(c=p),p>d&&(d=p)}return[l,c,u,d]}function so(e,t,n,r,o,i,s,a,l){let u=e+(n-e)*l,c=t+(r-t)*l,d=n+(o-n)*l,f=r+(i-r)*l,p=o+(s-o)*l,h=i+(a-i)*l,m=u+(d-u)*l,g=c+(f-c)*l,b=d+(p-d)*l,x=f+(h-f)*l,w=m+(b-m)*l,y=g+(x-g)*l;return[[e,t,u,c,m,g,w,y],[w,y,b,x,p,h,s,a]]}function jS(e,t,n,r,o,i,s){let a=e+(n-e)*s,l=t+(r-t)*s,u=n+(o-n)*s,c=r+(i-r)*s,d=a+(u-a)*s,f=l+(c-l)*s;return[[e,t,a,l,d,f],[d,f,u,c,o,i]]}var Pn=Q(()=>{"use strict"});function $S(e,t){if(!(t>0))return 0;let n=e/t;return n<0?0:n>1?1:n}var YS=Q(()=>{"use strict"});function XG(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function Bt(e,t){return Math.sqrt(XG(e,t))}function ei(e,t,n){return{x:fr(e.x,t.x,n),y:fr(e.y,t.y,n)}}function Xy(e,t,n,r,o,i){let s=o-n,a=i-r;return $S((e-n)*s+(t-r)*a,s*s+a*a)}function JG(e,t,n,r,o,i){let s=Xy(e,t,n,r,o,i),a=e-(s===1?o:fr(n,o,s)),l=t-(s===1?i:fr(r,i,s));return a*a+l*l}function Tn(e,t,n,r,o,i){return Math.sqrt(JG(e,t,n,r,o,i))}var ti=Q(()=>{"use strict";YS();ml()});function xl(e,t,n,r,o,i){let s=Xy(e,t,n,r,o,i),a=s===1?o:fr(n,o,s),l=s===1?i:fr(r,i,s);return{x:a,y:l,t:s,dist:Math.sqrt((e-a)*(e-a)+(t-l)*(t-l))}}function ni(e,t,n,r,o,i,s,a,l,u){let c=-n+3*o-3*s+l,d=-r+3*i-3*a+u,f=3*n-6*o+3*s,p=3*r-6*i+3*a,h=3*(o-n),m=3*(i-r),g=S=>{let[v,A]=Ve(n,r,o,i,s,a,l,u,S);return(v-e)**2+(A-t)**2},b=[];for(let S=0;S<=ao;S++)b.push(g(S/ao));let x=0,w=b[0];for(let S=0;S<=ao;S++){let v=b[S],A=S>0?b[S-1]:1/0,N=S<ao?b[S+1]:1/0;if(!(v<=A&&v<=N))continue;let M=Math.max(0,(S-1)/ao),C=Math.min(1,(S+1)/ao),F=S/ao;for(let W=0;W<QG;W++){let J=F*F,se=c*J*F+f*J+h*F+n-e,ke=d*J*F+p*J+m*F+r-t,ae=3*c*J+2*f*F+h,ve=3*d*J+2*p*F+m,G=6*c*F+2*f,K=6*d*F+2*p,$=se*ae+ke*ve,ee=ae*ae+ve*ve+se*G+ke*K;if($>0)C=F;else if($<0)M=F;else break;let te=ee>0?F-$/ee:NaN;te>M&&te<C||(te=(M+C)/2);let he=Math.abs(te-F);if(F=te,he<qS||C-M<qS)break}let B=g(F),[D,j]=B<=v?[F,B]:[S/ao,v];j<w&&(w=j,x=D)}let[y,P]=Ve(n,r,o,i,s,a,l,u,x);return{x:y,y:P,t:x,dist:Math.hypot(y-e,P-t)}}function XS(e,t,n,r,o,i,s,a){let[l,u,c,d]=io(n,r,o,i,s,a);return ni(e,t,n,r,l,u,c,d,s,a)}var ao,QG,qS,Pd=Q(()=>{"use strict";Pn();ti();ml();ao=32,QG=40,qS=1e-14});function $e(e){return e.origin?JS(e,Float64Array.from(e.coords)):e.coords}function JS(e,t){let n=e.origin;if(n===void 0)return t;for(let r=0;r+1<t.length;r+=2)t[r]+=n.x,t[r+1]+=n.y;return t}function At(e,t){let n=e?.x??0,r=e?.y??0,o=new Float32Array(t.length);for(let i=0;i+1<t.length;i+=2)o[i]=t[i]-n,o[i+1]=t[i+1]-r;return o}function Sn(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let s=0;s+1<e.length;s+=2){let a=e[s],l=e[s+1];a<t&&(t=a),a>r&&(r=a),l<n&&(n=l),l>o&&(o=l)}let i=Math.max(Math.abs(t),Math.abs(r),Math.abs(n),Math.abs(o));if(!(!(i>=QS)||!Number.isFinite(i)))return{x:Math.round((t+r)/2),y:Math.round((n+o)/2)}}function Jy(e){let t=0,n=0;for(let l of e)t+=l.commands.length,n+=l.coords.length;let r=e[0]?.origin,o=new Uint8Array(t),i=new Float32Array(n),s=0,a=0;for(let l of e)o.set(l.commands,s),s+=l.commands.length,i.set(l.origin===r?l.coords:At(r,$e(l)),a),a+=l.coords.length;return{kind:"polygon",commands:o,coords:i,fillRule:"nonzero",...r?{origin:r}:{}}}var IQ,QS,tn=Q(()=>{"use strict";IQ=Object.freeze({x:0,y:0});QS=16384});function ek(e,t,n,r){return{kind:"rect",x:e,y:t,width:n,height:r}}function Td(e){let t=new _e,n=e[0];if(!n)return ek(0,0,0,0);t.moveTo(n.x,n.y);for(let r=1;r<e.length;r++){let o=e[r];o&&t.lineTo(o.x,o.y)}return t.build()}function Qy(e,t={}){if(e.length===0)return{kind:"polygon",commands:new Uint8Array,coords:new Float32Array,fillRule:t.fillRule??"nonzero"};let n=new _e;t.fillRule&&n.setFillRule(t.fillRule),n.moveTo(e[0].x,e[0].y);for(let r=1;r<e.length;r++)n.lineTo(e[r].x,e[r].y);return n.close(),n.build()}function Zy(e){let t=e.x+e.width/2,n=e.y+e.height/2,r=e.width/2,o=e.height/2,i=r*ZS,s=o*ZS,a=new _e;return a.moveTo(t+r,n),a.curveTo(t+r,n+s,t+i,n+o,t,n+o),a.curveTo(t-i,n+o,t-r,n+s,t-r,n),a.curveTo(t-r,n-s,t-i,n-o,t,n-o),a.curveTo(t+i,n-o,t+r,n-s,t+r,n),a.close(),a.build()}function eg(e,t,n,r=0){let o=new _e;for(let i=0;i<n;i++){let s=r+i/n*Math.PI*2,a=e.x+t*Math.cos(s),l=e.y+t*Math.sin(s);i===0?o.moveTo(a,l):o.lineTo(a,l)}return o.close(),o.build()}function tg(e,t,n=5,r=t/2,o=0){let i=new _e,s=n*2;for(let a=0;a<s;a++){let l=o+a/s*Math.PI*2,u=a%2===0?t:r,c=e.x+u*Math.cos(l),d=e.y+u*Math.sin(l);a===0?i.moveTo(c,d):i.lineTo(c,d)}return i.close(),i.build()}function ng(e,t){let n=new _e;return n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.build()}var _e,ZS,mr=Q(()=>{"use strict";Je();tn();_e=class e{cmds=[];xs=[];fillRule="nonzero";origin;auto=!1;static fromPath(t){let n=new e;return n.cmds=Array.from(t.commands),n.xs=Array.from(t.coords),n.fillRule=t.fillRule,t.origin&&(n.origin={x:t.origin.x,y:t.origin.y}),n}setOrigin(t,n){let r=this.origin?.x??0,o=this.origin?.y??0;for(let i=0;i<this.xs.length;i+=2)this.xs[i]+=r-t,this.xs[i+1]+=o-n;return this.origin=t===0&&n===0?void 0:{x:t,y:n},this}autoOrigin(){return this.auto=!0,this}push(...t){let n=this.origin?.x??0,r=this.origin?.y??0;for(let o=0;o<t.length;o+=2)this.xs.push(t[o]-n,t[o+1]-r)}setFillRule(t){return this.fillRule=t,this}moveTo(t,n){return this.cmds.push(le),this.push(t,n),this}lineTo(t,n){return this.cmds.push(ce),this.push(t,n),this}curveTo(t,n,r,o,i,s){return this.cmds.push(xe),this.push(t,n,r,o,i,s),this}quadTo(t,n,r,o){return this.cmds.push(we),this.push(t,n,r,o),this}close(){return this.cmds.push(fe),this}build(){if(this.auto&&!this.origin){let t=Sn(this.xs);t&&this.setOrigin(t.x,t.y)}return{kind:"polygon",commands:new Uint8Array(this.cmds),coords:new Float32Array(this.xs),fillRule:this.fillRule,...this.origin?{origin:{...this.origin}}:{}}}};ZS=.5522847498307936});function rg(e,t){let n=e.corners?.[t];return n&&n.radius>0?n:null}function Sd(e){let t=e.corners;if(!t)return!1;for(let n of t)if(n&&n.radius>0)return!0;return!1}function kd(e){let t=e.length;for(;t>0&&!e[t-1];)t--;if(t===0)return;let n=new Array(t);for(let r=0;r<t;r++)n[r]=e[r]??null;return n}function ri(e){if(e.corners===void 0)return e;let{corners:t,...n}=e;return n}function og(e,t){return!e.corners||t===1?e:{...e,corners:e.corners.map(n=>n?{shape:n.shape,radius:n.radius*t}:null)}}function ig(e,t,n){if(!e&&!t)return;let r=Math.max(e?.length??0,t?.length??0),o=new Array(r);for(let i=0;i<r;i++){let s=e?.[i]??null,a=t?.[i]??null,l=s??a;l?s&&a&&s.shape!==a.shape?o[i]=n<.5?s:a:o[i]={shape:l.shape,radius:(s?.radius??0)+((a?.radius??0)-(s?.radius??0))*n}:o[i]=null}return kd(o)}var wl=Q(()=>{"use strict"});function tk(e,t,n,r,o){let[i,s]=Ve(e.x,e.y,t.x,t.y,n.x,n.y,r.x,r.y,o);return{x:i,y:s}}var nk=Q(()=>{"use strict";Pn()});function ok(e,t,n,r={}){let{cp1:o,cp2:i}=ZG(e,t,n,r.passes??4,r.params);return{cp1:o,cp2:i}}function ZG(e,t,n,r,o){let i=e.length,s=e[0],a=e[i-1],l=o?[...o]:e4(e);if(l===null)return{cp1:{...s},cp2:{...a},end:a,ts:e.map(()=>0)};let u=rk(e,l,s,a,t,n);for(let c=0;c<r;c++)t4(e,l,s,a,u),u=rk(e,l,s,a,t,n);return u}function e4(e){let t=e.length,n=new Array(t);n[0]=0;let r=0;for(let o=1;o<t;o++)r+=Bt(e[o-1],e[o]),n[o]=r;if(r===0)return null;for(let o=0;o<t;o++)n[o]/=r;return n}function rk(e,t,n,r,o,i){let s=e.length,a=0,l=0,u=0,c=0,d=0;for(let m=0;m<s;m++){let g=t[m],b=1-g,x=b*b*b,w=3*b*b*g,y=3*b*g*g,P=g*g*g,S=w*o.x,v=w*o.y,A=y*i.x,N=y*i.y;a+=S*S+v*v,l+=S*A+v*N,u+=A*A+N*N;let M=e[m].x-(x+w)*n.x-(y+P)*r.x,C=e[m].y-(x+w)*n.y-(y+P)*r.y;c+=S*M+v*C,d+=A*M+N*C}let f=a*u-l*l,p,h;return Math.abs(f)<1e-12?p=h=Bt(n,r)/3:(p=(u*c-l*d)/f,h=(a*d-l*c)/f,(p<1e-6||h<1e-6)&&(p=h=Bt(n,r)/3)),{cp1:{x:n.x+o.x*p,y:n.y+o.y*p},cp2:{x:r.x+i.x*h,y:r.y+i.y*h},end:r,ts:t}}function t4(e,t,n,r,o){for(let i=1;i<e.length-1;i++)t[i]=n4(e[i],t[i],e[0],o.cp1,o.cp2,e[e.length-1])}function n4(e,t,n,r,o,i){let s=1-t,{x:a,y:l}=tk(n,r,o,i,t),u=3*s*s*(r.x-n.x)+6*s*t*(o.x-r.x)+3*t*t*(i.x-o.x),c=3*s*s*(r.y-n.y)+6*s*t*(o.y-r.y)+3*t*t*(i.y-o.y),d=6*s*(o.x-2*r.x+n.x)+6*t*(i.x-2*o.x+r.x),f=6*s*(o.y-2*r.y+n.y)+6*t*(i.y-2*o.y+r.y),p=a-e.x,h=l-e.y,m=p*u+h*c,g=u*u+c*c+p*d+h*f;if(Math.abs(g)<1e-12)return t;let b=t-m/g;return b<0?0:b>1?1:b}var ik=Q(()=>{"use strict";nk();ti()});function ck(e){return typeof e=="number"?e:r4[e]}function o4(e){let t=2**Math.abs(e);return 1-.5**(1/t)<dk/4?1/0:t}function Pl(e,t){let n=.5**(1/e),r=i=>Math.max(0,1-i**e)**(1/e);if(t<=1){let i=t*n;return{x:i,y:r(i)}}let o=(2-t)*n;return{x:r(o),y:o}}function ak(e,t){let n=Pl(e,t),[r,o]=t<=1?[1,-((n.x/n.y)**(e-1))]:[(n.y/n.x)**(e-1),-1],i=Math.hypot(r,o);return{x:r/i,y:o/i}}function i4(e,t,n,r,[o,i,s]){let a=f=>{let p=Pl(e,f);return ni(p.x,p.y,r.x,r.y,o.x,o.y,i.x,i.y,s.x,s.y).dist},l=0,u=1;for(let f=1;f<vd;f++){let p=a(t+(n-t)*(f/vd));p>l&&(l=p,u=f)}let c=t+(n-t)*((u-1)/vd),d=t+(n-t)*((u+1)/vd);for(let f=0;f<24;f++){let p=c+(d-c)/3,h=d-(d-c)/3;a(p)>a(h)?d=h:c=p}return Math.max(l,a((c+d)/2))}function sg(e,t,n,r,o,i){let s=Pl(e,t),a=Pl(e,n),l=[],u=[];for(let m=0;m<=12;m++)l.push(Pl(e,t+(n-t)*(m/12))),u.push(m/12);let c=ak(e,n),{cp1:d,cp2:f}=ok(l,ak(e,t),{x:-c.x,y:-c.y},{params:u}),p=[d,f,a];if(o>=10||i4(e,t,n,s,p)<=r){i.push(p);return}let h=(t+n)/2;sg(e,t,h,r,o+1,i),sg(e,h,n,r,o+1,i)}function s4(e,t){if(e===2)return[[{x:sk,y:1},{x:1,y:sk},{x:1,y:0}]];let n=`${e}:${t}`,r=Ad.get(n);return r||(r=[],sg(e,0,2,t,0,r),Ad.size>256&&Ad.clear(),Ad.set(n,r)),r}function a4(e,t){let n=lk(e.end,t),r=lk(e.start,t);return o=>({x:t.x+o.x*n.x+o.y*r.x,y:t.y+o.x*n.y+o.y*r.y})}function uk(e){return{x:e.start.x+e.end.x-e.outer.x,y:e.start.y+e.end.y-e.outer.y}}function fk(e,t,n=dk){if(e===0)return[{kind:"line",to:t.end}];let r=o4(e);if(r===1/0)return[{kind:"line",to:e>0?t.outer:uk(t)},{kind:"line",to:t.end}];let o=a4(t,e>0?uk(t):t.outer);return s4(r,n).map(([i,s,a])=>({kind:"cubic",c1:o(i),c2:o(s),to:o(a)}))}var r4,dk,sk,lk,vd,Ad,pk=Q(()=>{"use strict";ik();Pd();r4={square:1/0,squircle:2,round:1,bevel:0,scoop:-1,notch:-1/0};dk=.001,sk=4/3*Math.tan(Math.PI/8);lk=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),vd=32;Ad=new Map});function Sl(e){let{commands:t}=e,n=$e(e),r=[],o=null,i=0,s=0,a=!1,l=()=>o.anchors[o.anchors.length-1],u=(c,d)=>{o.segs.push(d),o.anchors.push(c),o.sources.push(s++),i++};return Ge(t,n,(c,d,f,p,h,m)=>{if(m)return a=!0,!1;let g=b=>({x:n[d+b],y:n[d+b+1]});switch(c){case le:o&&r.push(o),o={anchors:[g(0)],segs:[],closed:!1,first:i++,sources:[s++]};break;case ce:u(g(0),mk(l(),g(0)));break;case xe:u(g(4),{line:!1,p0:l(),c1:g(0),c2:g(2),p3:g(4)});break;case we:{let b=l(),x=g(0),w=g(2),y={x:b.x+2/3*(x.x-b.x),y:b.y+2/3*(x.y-b.y)},P={x:w.x+2/3*(x.x-w.x),y:w.y+2/3*(x.y-w.y)};u(w,{line:!1,p0:b,c1:y,c2:P,p3:w});break}case fe:o&&l4(o,()=>i--),o&&r.push(o),o=null;break}}),a?null:(o&&r.push(o),r)}function l4(e,t){e.closed=!0;let n=e.anchors.length,r=e.anchors[0],o=e.anchors[n-1];if(n>1&&!e.segs[n-2].line&&o.x===r.x&&o.y===r.y){e.anchors.pop(),e.sources.pop(),t();return}e.segs.push(mk(o,r))}function Rd(e){return e.line?Math.hypot(e.p3.x-e.p0.x,e.p3.y-e.p0.y):yk(e)[Tl]}function yk(e){let t=hk.get(e);if(t)return t;t=new Float64Array(Tl+1);let n=e.p0;for(let r=1;r<=Tl;r++){let o=fs(e,r/Tl);t[r]=t[r-1]+Math.hypot(o.x-n.x,o.y-n.y),n=o}return hk.set(e,t),t}function ag(e,t){let n=Rd(e);if(n<=0)return 0;if(e.line)return Math.min(1,Math.max(0,t/n));let r=yk(e);if(t<=0)return 0;if(t>=n)return 1;let o=1;for(;r[o]<t;)o++;let i=r[o]-r[o-1],s=i>0?(t-r[o-1])/i:0;return(o-1+s)/Tl}function fs(e,t){if(e.line)return{x:e.p0.x+(e.p3.x-e.p0.x)*t,y:e.p0.y+(e.p3.y-e.p0.y)*t};let{p0:n,c1:r,c2:o,p3:i}=e,[s,a]=Ve(n.x,n.y,r.x,r.y,o.x,o.y,i.x,i.y,t);return{x:s,y:a}}function ds(e,t){let n=Math.hypot(e,t);return n>1e-12?{x:e/n,y:t/n}:null}function kl(e,t){let{p0:n,c1:r,c2:o,p3:i}=e;if(e.line)return ds(i.x-n.x,i.y-n.y);let s=1-t,a=3*(s*s*(r.x-n.x)+2*s*t*(o.x-r.x)+t*t*(i.x-o.x)),l=3*(s*s*(r.y-n.y)+2*s*t*(o.y-r.y)+t*t*(i.y-o.y)),u=ds(a,l);return u||(t<.5?ds(o.x-n.x,o.y-n.y)??ds(i.x-n.x,i.y-n.y):ds(i.x-r.x,i.y-r.y)??ds(i.x-n.x,i.y-n.y))}function gk(e,t,n){let{p0:r,c1:o,c2:i,p3:s}=e,a=[r.x,r.y,o.x,o.y,i.x,i.y,s.x,s.y];t>0&&(a=[...so(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],t)[1]]);let l=t<1?(n-t)/(1-t):1;return l<1&&(a=[...so(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],l)[0]]),[{x:a[2],y:a[3]},{x:a[4],y:a[5]},{x:a[6],y:a[7]}]}var mk,Tl,hk,lg=Q(()=>{"use strict";Je();Pn();tn();mk=(e,t)=>({line:!0,p0:e,c1:e,c2:t,p3:t});Tl=32;hk=new WeakMap});function wk(e,t){let n=t.anchors.length,r=t.segs.map(Rd),o=t.anchors.map((s,a)=>{let l=a>0?t.segs[a-1]:t.closed?t.segs[n-1]:null,u=a<t.segs.length?t.segs[a]:null;if(!l||!u||l===u)return null;let c=kl(l,1),d=kl(u,0);if(!c||!d)return null;let f=Math.acos(Math.max(-1,Math.min(1,c.x*d.x+c.y*d.y)));if(f<bk||f>Math.PI-bk)return null;let p=d.x-c.x,h=d.y-c.y,m=Math.hypot(p,h),g=(Math.PI-f)/2,b=rg(e,t.first+a),x=b?b.radius:0;return{frame:{index:t.first+a,x:s.x,y:s.y,bisector:{x:p/m,y:h/m},halfAngle:g},spec:b,want:x,trim:x}}),i=o.map(()=>1);return t.segs.forEach((s,a)=>{let l=a,u=(a+1)%n,c=(o[l]?.want??0)+(o[u]?.want??0);if(c<=r[a])return;let d=r[a]/c;i[l]=Math.min(i[l],d),i[u]=Math.min(i[u],d)}),o.forEach((s,a)=>{s&&(s.trim=s.want*i[a])}),o}function ps(e){if(e.corners===void 0)return{path:e,anchorSources:null};let t=xk.get(e);if(t)return t;let n=Sd(e)?u4(e):{path:ri(e),anchorSources:null};return xk.set(e,n),n}function Qe(e){return e.kind!=="polygon"?e:ps(e).path}function vl(e,t,n){let r=new Array(t.length*n);for(let o=0;o<t.length;o++)for(let i=0;i<n;i++)r[o*n+i]=e[t[o]*n+i];return r}function u4(e){let t=Sl(e);if(!t)return{path:ri(e),anchorSources:null};let n=new ug;e.origin&&n.b.setOrigin(e.origin.x,e.origin.y);for(let i of t)c4(n,i,wk(e,i));let{commands:r,coords:o}=n.b.build();return{path:{...ri(e),commands:r,coords:o},anchorSources:Uint32Array.from(n.sources)}}function Pk(e,t,n){let r=e.segs[n],o=Rd(r),i=ag(r,t[n]?.trim??0),s=ag(r,o-(t[(n+1)%e.anchors.length]?.trim??0));return[i,Math.max(i,s)]}function Tk(e,t,n,r){let o=(r+1)%e.anchors.length,i=t[o],s=e.segs[o];if(!i?.spec||i.trim<=0||!s)return null;let a=e.segs[r],l=fs(a,n[r][1]),u=fs(s,n[o][0]),c=d4({x:i.frame.x,y:i.frame.y},l,kl(a,n[r][1]),u,kl(s,n[o][0]));return{cut:i,start:l,end:u,pieces:fk(ck(i.spec.shape),c)}}function Nd(e){if(!Sd(e))return[];let t=[];for(let n of Sl(e)??[]){let r=wk(e,n),o=n.segs.map((i,s)=>Pk(n,r,s));n.segs.forEach((i,s)=>{let a=Tk(n,r,o,s);if(!a)return;let{frame:l}=a.cut;t.push({index:l.index,anchor:{x:l.x,y:l.y},spec:a.cut.spec,start:a.start,end:a.end,pieces:a.pieces})})}return t}function c4(e,t,n){let r=t.anchors.length,o=t.segs.map((s,a)=>Pk(t,n,a)),i=t.closed&&t.segs.length>0?fs(t.segs[0],o[0][0]):t.anchors[0];e.src=t.sources[0],e.moveTo(i.x,i.y),t.segs.forEach((s,a)=>{let[l,u]=o[a];e.src=t.sources[(a+1)%r];let c=t.closed&&a===r-1&&!(n[0]?.spec&&n[0].trim>0);if(u>l&&!(c&&s.line))if(s.line){let p=fs(s,u);e.lineTo(p.x,p.y)}else{let[p,h,m]=gk(s,l,u);e.curveTo(p.x,p.y,h.x,h.y,m.x,m.y)}let d=Tk(t,n,o,a);if(!d)return;let f=[...d.pieces];(a+1)%r===0&&f.at(-1)?.kind==="line"&&f.pop();for(let p of f)p.kind==="line"?e.lineTo(p.to.x,p.to.y):e.curveTo(p.c1.x,p.c1.y,p.c2.x,p.c2.y,p.to.x,p.to.y)}),t.closed&&e.close()}function d4(e,t,n,r,o){let i=n&&o?f4(t,n,r,o):null,s=Math.hypot(r.x-t.x,r.y-t.y),a=!i||Math.hypot(i.x-e.x,i.y-e.y)>4*s;return{start:t,end:r,outer:a?e:i}}function f4(e,t,n,r){let o=t.x*r.y-t.y*r.x;if(Math.abs(o)<1e-9)return null;let i=((n.x-e.x)*r.y-(n.y-e.y)*r.x)/o;return{x:e.x+t.x*i,y:e.y+t.y*i}}var bk,xk,ug,nn=Q(()=>{"use strict";mr();wl();pk();lg();bk=.001;xk=new WeakMap;ug=class{b=new _e;sources=[];src=0;moveTo(t,n){this.b.moveTo(t,n),this.sources.push(this.src)}lineTo(t,n){this.b.lineTo(t,n),this.sources.push(this.src)}curveTo(t,n,r,o,i,s){this.b.curveTo(t,n,r,o,i,s),this.sources.push(this.src)}close(){this.b.close()}}});function Ed(e){return e>0?e:p4}function mg(e,t,n,r,o,i){return Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(o)&&Number.isFinite(i)}function Sk(e,t,n,r,o,i,s,a){return mg(e,t,n,r,o,i)&&Number.isFinite(s)&&Number.isFinite(a)}function kk(e,t,n,r,o,i,s,a,l,u){let c=cg(n-e,r-t,o-n,i-r)+cg(o-n,i-r,s-o,a-i);return o===n&&i===r&&(c+=cg(n-e,r-t,s-o,a-i)),c===0?!0:c>=Math.PI?!1:((Math.hypot(n-e,r-t)+Math.hypot(o-n,i-r)+Math.hypot(s-o,a-i))/c+l)*(1-Math.cos(c/2))<=u}function cg(e,t,n,r){let o=Math.sqrt((e*e+t*t)*(n*n+r*r));return o===0?0:Math.acos(Math.max(-1,Math.min(1,(e*n+t*r)/o)))}function lo(e,t,n,r,o,i,s,a,l,u){if(!Sk(e,t,n,r,o,i,s,a)){u.push(s,a);return}dg(e,t,n,r,o,i,s,a,Ed(l),u,0)}function dg(e,t,n,r,o,i,s,a,l,u,c){let d=Tn(n,r,e,t,s,a),f=Tn(o,i,e,t,s,a);if(Math.max(d,f)<=l||c>=Id){u.push(s,a);return}let p=(e+n)*.5,h=(t+r)*.5,m=(n+o)*.5,g=(r+i)*.5,b=(o+s)*.5,x=(i+a)*.5,w=(p+m)*.5,y=(h+g)*.5,P=(m+b)*.5,S=(g+x)*.5,v=(w+P)*.5,A=(y+S)*.5;dg(e,t,p,h,w,y,v,A,l,u,c+1),dg(v,A,P,S,b,x,s,a,l,u,c+1)}function yg(e,t,n,r,o,i,s,a){if(!mg(e,t,n,r,o,i)){a.push(o,i);return}fg(e,t,n,r,o,i,Ed(s),a,0)}function fg(e,t,n,r,o,i,s,a,l){if(Tn(n,r,e,t,o,i)<=s||l>=Id){a.push(o,i);return}let c=(e+n)*.5,d=(t+r)*.5,f=(n+o)*.5,p=(r+i)*.5,h=(c+f)*.5,m=(d+p)*.5;fg(e,t,c,d,h,m,s,a,l+1),fg(h,m,f,p,o,i,s,a,l+1)}function Al(e,t,n,r,o,i,s,a,l,u,c,d=0){return Sk(e,t,n,r,o,i,s,a)?pg(e,t,n,r,o,i,s,a,Ed(l),d,u,c,0,0):(u.push(s,a),c.push(0),0)}function pg(e,t,n,r,o,i,s,a,l,u,c,d,f,p){let h=Tn(n,r,e,t,s,a),m=Tn(o,i,e,t,s,a);if(Math.max(h,m)<=l&&(u===0||kk(e,t,n,r,o,i,s,a,u,l))||p>=Id){let B=c.length>=2?c[c.length-2]:e,D=c.length>=2?c[c.length-1]:t,j=Math.hypot(s-B,a-D);return f+=j,c.push(s,a),d.push(f),f}let b=(e+n)*.5,x=(t+r)*.5,w=(n+o)*.5,y=(r+i)*.5,P=(o+s)*.5,S=(i+a)*.5,v=(b+w)*.5,A=(x+y)*.5,N=(w+P)*.5,M=(y+S)*.5,C=(v+N)*.5,F=(A+M)*.5;return f=pg(e,t,b,x,v,A,C,F,l,u,c,d,f,p+1),f=pg(C,F,N,M,P,S,s,a,l,u,c,d,f,p+1),f}function Rl(e,t,n,r,o,i,s,a,l,u=0){return mg(e,t,n,r,o,i)?hg(e,t,n,r,o,i,Ed(s),u,a,l,0,0):(a.push(o,i),l.push(0),0)}function hg(e,t,n,r,o,i,s,a,l,u,c,d){if(Tn(n,r,e,t,o,i)<=s&&(a===0||kk(e,t,n,r,o,i,o,i,a,s))||d>=Id){let y=l.length>=2?l[l.length-2]:e,P=l.length>=2?l[l.length-1]:t,S=Math.hypot(o-y,i-P);return c+=S,l.push(o,i),u.push(c),c}let h=(e+n)*.5,m=(t+r)*.5,g=(n+o)*.5,b=(r+i)*.5,x=(h+g)*.5,w=(m+b)*.5;return c=hg(e,t,h,m,x,w,s,a,l,u,c,d+1),c=hg(x,w,g,b,o,i,s,a,l,u,c,d+1),c}var mt,p4,Id,oi=Q(()=>{"use strict";ti();mt=.5,p4=1e-6,Id=16});function hs(e,t={}){return e.kind==="rect"?[h4(e)]:m4(Qe(e),t)}function h4(e){let{x:t,y:n,width:r,height:o}=e;return{points:Array.from(gl(t,n,r,o)),closed:!0,anchorA:new Uint32Array([0,1,2,3]),anchorB:new Uint32Array([0,1,2,3]),anchorT:new Float32Array([0,0,0,0])}}function m4(e,t){let n=t.flattenTolerance??mt,{commands:r,coords:o}=e,i=[],s=0,a=null,l=null,u=null,c=null,d=null,f=-1,p=0,h=()=>{a=[],l=[],u=[],c=[];let x={points:a,closed:!1};return i.push(x),x},m=()=>{if(!a||!l||!u||!c)return;let x=a.length/2;x<2||a[0]!==a[(x-1)*2]||a[1]!==a[(x-1)*2+1]||(a.length-=2,l.length-=1,u.length-=1,c.length-=1)},g=x=>{!a||!l||!u||!c||(x.anchorA=new Uint32Array(l),x.anchorB=new Uint32Array(u),x.anchorT=new Float32Array(c))},b=(x,w,y,P)=>{for(let v=0;v<w.length;v++)l.push(f),u.push(P),c.push(y>0?w[v]/y:0);let S=x+w.length-1;l[S]=P,u[S]=P,c[S]=0};return Ge(r,o,(x,w,y,P,S,v)=>{switch(v&&(d&&g(d),d=h(),a.push(y,P),l.push(p),u.push(p),c.push(0),f=p),x){case le:case ce:{x===le&&(d&&g(d),d=h(),p=s),a.push(o[w],o[w+1]),l.push(s),u.push(s),c.push(0),f=s,s++;break}case we:{let A=s,N=a.length/2,M=[],C=Rl(y,P,o[w],o[w+1],o[w+2],o[w+3],n,a,M,t.offset);b(N,M,C,A),f=A,s++;break}case xe:{let A=s,N=a.length/2,M=[],C=Al(y,P,o[w],o[w+1],o[w+2],o[w+3],o[w+4],o[w+5],n,a,M,t.offset);b(N,M,C,A),f=A,s++;break}case fe:{d&&(d.closed=!0,m());break}default:throw new Error(`extractPolylines: unknown command code ${x}`)}}),d&&g(d),i}var vk=Q(()=>{"use strict";Je();nn();bl();oi()});function gg(e){let t=Qe(e);if(t.kind==="rect"){let{x:s,y:a,width:l,height:u}=t;return`M${Ze(s)} ${Ze(a)}h${Ze(l)}v${Ze(u)}h${Ze(-l)}Z`}let n=t.commands,r=$e(t),o=[],i=0;for(let s=0;s<n.length;s++){let a=n[s];a===le?(o.push(`M${Ze(r[i])} ${Ze(r[i+1])}`),i+=2):a===ce?(o.push(`L${Ze(r[i])} ${Ze(r[i+1])}`),i+=2):a===xe?(o.push(`C${Ze(r[i])} ${Ze(r[i+1])} ${Ze(r[i+2])} ${Ze(r[i+3])} ${Ze(r[i+4])} ${Ze(r[i+5])}`),i+=6):a===we?(o.push(`Q${Ze(r[i])} ${Ze(r[i+1])} ${Ze(r[i+2])} ${Ze(r[i+3])}`),i+=4):a===fe&&o.push("Z")}return o.join("")}var Ze,Ak=Q(()=>{"use strict";Je();nn();tn();Ze=e=>Number.isFinite(e)?String(Math.round(e*1e6)/1e6):"0"});function Un(e,t,n,r=0,o=e.length>>1){if(o-r<3)return!1;let i=!1;for(let s=r,a=o-1;s<o;a=s++){let l=e[s*2],u=e[s*2+1],c=e[a*2],d=e[a*2+1];u>n!=d>n&&t<(c-l)*(n-u)/(d-u)+l&&(i=!i)}return i}function yr(e,t=0,n=e.length>>1){let r=0;for(let o=t;o<n;o++){let i=o+1===n?t:o+1;r+=e[o*2]*e[i*2+1]-e[i*2]*e[o*2+1]}return r*.5}function gr(e,t,n,r,o,i,s,a){let l=us((s-o)*(t-i)-(a-i)*(e-o)),u=us((s-o)*(r-i)-(a-i)*(n-o)),c=us((n-e)*(i-t)-(r-t)*(o-e)),d=us((n-e)*(a-t)-(r-t)*(s-e));return l!==u&&c!==d}var Nl=Q(()=>{"use strict";ml()});function bg(){return Rk}function kn(e){return(e.openFill??Rk)==="close"}var Rk,ii=Q(()=>{"use strict";Rk="close"});function et(e){if(e.kind==="rect")return e;let{commands:t,coords:n}=Qe(e);if(t.length===0)return{kind:"rect",x:0,y:0,width:0,height:0};let r=1/0,o=1/0,i=-1/0,s=-1/0,a=!1,l=(u,c)=>{u<r&&(r=u),u>i&&(i=u),c<o&&(o=c),c>s&&(s=c),a=!0};return Ge(t,n,(u,c,d,f)=>{switch(u){case le:case ce:{l(n[c],n[c+1]);break}case xe:{let[p,h,m,g]=qy(d,f,n[c],n[c+1],n[c+2],n[c+3],n[c+4],n[c+5]);l(p,h),l(m,g);break}case we:{let p=n[c+2],h=n[c+3],[m,g,b,x]=io(d,f,n[c],n[c+1],p,h),[w,y,P,S]=qy(d,f,m,g,b,x,p,h);l(w,y),l(P,S);break}case fe:break;default:throw new Error(`boundsOfPath: unknown command ${u}`)}}),a?{kind:"rect",x:r+(e.origin?.x??0),y:o+(e.origin?.y??0),width:i-r,height:s-o}:{kind:"rect",x:0,y:0,width:0,height:0}}var xg=Q(()=>{"use strict";Pn();Je();nn()});function Ik(e){let t=Nk.get(e);if(t)return t;let{commands:n,coords:r}=e,o=[],i=0,s=0,a=0,l=0,u=0,c=0,d=0,f=!1;Ge(n,r,(h,m)=>{if(h===fe){a>1&&f&&c===l&&d===u&&(o[o.length-1]=s,i--),a=0;return}let g=oo(h);c=r[m+g-2],d=r[m+g-1],f=h===xe||h===we,(h===le||a===0)&&(s=i,l=c,u=d,a=0),a++,o.push(i++)});let p=Int32Array.from(o);return Nk.set(e,p),p}var Nk,Ek=Q(()=>{"use strict";Je();Nk=new WeakMap});function y4(e){return e.kind!=="polygon"?[]:Nd(e).map(({anchor:t,spec:n,start:r,end:o,pieces:i})=>({anchor:t,spec:n,start:r,end:o,pieces:i}))}function Tg(e,t,n=Ok){let r=e.flatMap(y4);return r.length===0?t:T4(t,r,n)}function wg(e,t,n){let r=t.start;for(let o of t.pieces){if((o.kind==="line"?xl(e.x,e.y,r.x,r.y,o.to.x,o.to.y).dist:ni(e.x,e.y,r.x,r.y,o.c1.x,o.c1.y,o.c2.x,o.c2.y,o.to.x,o.to.y).dist)<=n)return!0;r=o.to}return!1}function ms(e,t,n,r){let o=ei(e.p0,e.c1,t),i=ei(e.c1,e.c2,t),s=ei(e.c2,e.p3,t),a=ei(o,i,n),l=ei(i,s,n);return ei(a,l,r)}function Mk(e,t,n,r){let o=l=>ms(e,l,l,l),i=l=>{let u=ms(e,l,l,0),c=ms(e,l,l,1);return{x:3*(c.x-u.x),y:3*(c.y-u.y)}},s=Math.hypot(i(n).x,i(n).y);if(s===0)return null;let a=n+(n===1?1:-1)*Bt(o(n),t)/s;for(let l=0;l<30;l++){let u=o(a),c=i(a),d=c.x*c.x+c.y*c.y;if(d===0)break;a-=((u.x-t.x)*c.x+(u.y-t.y)*c.y)/d}return Bt(o(a),t)<=r?a:null}function g4(e,t,n,r){let o=t??e.p0,i=n??e.p3;if(e.line)return{line:!0,p0:o,c1:o,c2:i,p3:i};let s=t?Mk(e,t,0,r):0,a=n?Mk(e,n,1,r):1;return s===null||a===null?null:{line:!1,p0:o,c1:ms(e,s,s,a),c2:ms(e,s,a,a),p3:i}}function Ck(e,t,n,r,o){return Bt(e,n)<=o?!0:t.line&&wg(e,r,o)&&xl(n.x,n.y,t.p0.x,t.p0.y,t.p3.x,t.p3.y).dist<=o}function b4(e,t,n){let r=e.anchors.length;for(let o=e.closed?0:1;o<r;o++)for(let[i,s]of[[t.start,t.end],[t.end,t.start]])if(Ck(e.anchors[o],e.segs[(o-1+r)%r],i,t,n))for(let a=o+1,l=1;l<e.segs.length&&!(!e.closed&&a>=r-1);a++,l++){let u=e.anchors[a%r],c=e.segs[(a-1)%r];if(!c.line&&!wg(ms(c,.5,.5,.5),t,n))break;if(Ck(u,e.segs[a%r],s,t,n))return{from:o,to:a%r,trace:t};if(!wg(u,t,n))break}return null}function Pg(e,t){let n=[];for(let r=e.from;;r=(r+1)%t)if(n.push(r),r===e.to)return n}function x4(e,t,n,r){let o=e.anchors.length,i=new Map,s=new Set;for(let p of t){i.set(p.from,p);for(let h of Pg(p,o))s.add(h)}let a=0;if(e.closed){let p=e.anchors.findIndex((h,m)=>!s.has(m));a=p>=0?p:t[0].from}let l=[],u=[];for(let p=0,h=a;p<o;){let m=i.get(h);if(m){l.push({at:m.trace.anchor,spec:m.trace.spec}),u.push(m.to);let g=Pg(m,o).length;p+=g,h=(m.to+1)%o}else l.push({at:e.anchors[h],spec:n[h]??null}),u.push(h),p++,h=(h+1)%o}let c=new Set(t.map(p=>p.to)),d=[],f=e.closed?l.length:l.length-1;for(let p=0;p<f;p++){let h=u[p],m=c.has(h)?l[p].at:void 0,g=i.has((h+1)%o)?l[(p+1)%l.length].at:void 0,b=g4(e.segs[h],m,g,r);if(!b)return null;d.push(b)}return{nodes:l,segs:d,closed:e.closed,folded:[...t]}}function w4(e,t){let n=new _e;t.origin&&n.setOrigin(t.origin.x,t.origin.y);let r=[];for(let{nodes:c,segs:d,closed:f}of e)n.moveTo(c[0].at.x,c[0].at.y),r.push(c[0].spec),d.forEach((p,h)=>{let m=c[(h+1)%c.length];f&&h===d.length-1&&p.line||(p.line?n.lineTo(m.at.x,m.at.y):n.curveTo(p.c1.x,p.c1.y,p.c2.x,p.c2.y,m.at.x,m.at.y),r.push(m.spec))}),f&&n.close();let{commands:o,coords:i}=n.build(),s={...ri(t),commands:o,coords:i},a=Ik(s),l=[];r.forEach((c,d)=>{if(c){for(;l.length<a[d];)l.push(null);l[a[d]]=c}});let u=kd(l);return u?{...s,corners:u}:s}function P4(e,t,n){let r=new Set(n.map(o=>o.trace));for(let o of Nd(e))for(let i of r){if(Bt(o.anchor,i.anchor)>t)continue;(Bt(o.start,i.start)<=t&&Bt(o.end,i.end)<=t||Bt(o.start,i.end)<=t&&Bt(o.end,i.start)<=t)&&r.delete(i)}return r}function T4(e,t,n=Ok){let r=Sl(e);if(!r||t.length===0)return e;let o=new Set;for(let i=0;i<=t.length;i++){let s=[];for(let c of r){let d=[],f=new Set;for(let m of t){if(o.has(m))continue;let g=b4(c,m,n);if(!g)continue;let b=Pg(g,c.anchors.length);b.some(x=>f.has(x))||(b.forEach(x=>f.add(x)),d.push(g))}let p=c.anchors.map((m,g)=>e.corners?.[c.first+g]??null),h=d.length>0?x4(c,d,p,n):null;if(d.length>0&&!h){d.forEach(m=>o.add(m.trace)),s.length=0;break}s.push(h??{nodes:c.anchors.map((m,g)=>({at:m,spec:p[g]})),segs:c.segs,closed:c.closed,folded:[]})}if(s.length!==r.length)continue;let a=s.flatMap(c=>c.folded);if(a.length===0)return e;let l=w4(s,e),u=P4(l,n,a);if(u.size===0)return l;u.forEach(c=>o.add(c))}return e}var Ok,Fk=Q(()=>{"use strict";Pd();mr();Ek();lg();wl();nn();ti();Ok=.001});function Lk(e,t){let n=Qe(e),{commands:r}=n,o=$e(n),i=[],s=[],a=[];return Ge(r,o,(l,u,c,d,f,p)=>{switch(p&&(a=[c,d]),l){case le:a.length>=2&&s.push(a),a=[o[u],o[u+1]];break;case ce:a.push(o[u],o[u+1]);break;case xe:lo(c,d,o[u],o[u+1],o[u+2],o[u+3],o[u+4],o[u+5],t,a);break;case we:yg(c,d,o[u],o[u+1],o[u+2],o[u+3],t,a);break;case fe:a.length>=6?i.push(a):a.length>=2&&s.push(a),a=[];break;default:throw new Error(`pathHitTest: unknown command ${l}`)}}),a.length>=2&&s.push(a),{closed:i,open:s}}function Md(e,t){let n=Lk(e,t.tolerance??mt);return kn(e)?{closed:[...n.closed,...n.open.filter(r=>r.length>=6)],open:n.open.filter(r=>r.length<6)}:n}function Sg(e,t){return Md(e,t).closed}var _k=Q(()=>{"use strict";Je();oi();ii();nn();tn()});function kg(e,t,n,r={}){if(e.kind==="rect")return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height;let o=0,i=0;for(let s of Sg(e,r)){let a=s.length;for(let l=0;l<a;l+=2){let u=(l+2)%a,c=s[l+1],d=s[u+1];if(c>n==d>n)continue;let f=s[l],p=s[u];t>=f+(n-c)/(d-c)*(p-f)||(o++,i+=c<=n?1:-1)}}return e.fillRule==="evenodd"?(o&1)===1:i!==0}function Cd(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]}function ys(e){let t=new Array(e.length*2);for(let n=0;n<e.length;n++)t[n*2]=e[n].x,t[n*2+1]=e[n].y;return t}function S4(e,t){if(e.length===0||t.length===0)return!1;if(Un(ys(e),t[0].x,t[0].y)||Un(ys(t),e[0].x,e[0].y))return!0;for(let n=0;n<e.length;n++){let r=e[n],o=e[(n+1)%e.length];for(let i=0;i<t.length;i++){let s=t[i],a=t[(i+1)%t.length];if(gr(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y))return!0}}return!1}function Bk(e,t){for(let n of e){let r=n.length;for(let o=0;o<r;o+=2){let i=(o+2)%r;if(t(n[o],n[o+1],n[i],n[i+1]))return!0}}return!1}function k4(e,t){let n=t.x,r=t.y,o=t.x+t.width,i=t.y+t.height;return Bk(e,(s,a,l,u)=>gr(s,a,l,u,n,r,o,r)||gr(s,a,l,u,o,r,o,i)||gr(s,a,l,u,o,i,n,i)||gr(s,a,l,u,n,i,n,r))}function Hk(e,t){return t.length===0?!1:Bk(e,(n,r,o,i)=>{for(let s=0;s<t.length;s++){let a=t[s],l=t[(s+1)%t.length];if(gr(n,r,o,i,a.x,a.y,l.x,l.y))return!0}return!1})}function v4(e,t){for(let n of e)for(let r=0;r+3<n.length;r+=2){let o=n[r],i=n[r+1],s=n[r+2],a=n[r+3];for(let l=0;l<t.length;l++){let u=t[l],c=t[(l+1)%t.length];if(gr(o,i,s,a,u.x,u.y,c.x,c.y))return!0}}return!1}function A4(e,t){for(let n of e)for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];if(o>=t.x&&o<=t.x+t.width&&i>=t.y&&i<=t.y+t.height)return!0}return!1}function Dk(e,t){for(let n of e)for(let r=0;r<n.length;r+=2)if(Un(t,n[r],n[r+1]))return!0;return!1}function Od(e,t,n={}){if(e.kind==="rect")return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y;let r=Sg(e,n);if(r.length===0)return!1;for(let o of Cd(t))if(kg(e,o.x,o.y,n))return!0;return A4(r,t)?!0:k4(r,t)}function vg(e,t,n={}){if(e.length<3)return!1;let r;if(t.kind==="rect")r=[ys(Cd(t))];else{let{closed:i,open:s}=Md(t,n);r=[...i,...s]}if(r.length===0)return!1;let o=ys(e);for(let i of r)for(let s=0;s<i.length;s+=2)if(!Un(o,i[s],i[s+1]))return!1;return!Hk(r,e)}function Fd(e,t,n={}){if(e.length<3)return!1;let r=n.filled!==!1;if(t.kind==="rect"&&r)return S4(Cd(t),e);let{closed:o,open:i}=t.kind==="rect"?{closed:[ys(Cd(t))],open:[]}:Md(t,n),s=ys(e);return Dk(o,s)||Dk(i,s)||Hk(o,e)||v4(i,e)?!0:r&&o.length>0&&kg(t,e[0].x,e[0].y,n)}var Gk=Q(()=>{"use strict";Nl();_k()});function Rt(e,t,n={}){let[r,o,i,s,a,l]=t;if(e.kind==="rect"){if(Math.abs(o)<Uk&&Math.abs(i)<Uk){let c=r*e.x+a,d=s*e.y+l,f=r*(e.x+e.width)+a,p=s*(e.y+e.height)+l;return{kind:"rect",x:Math.min(c,f),y:Math.min(d,p),width:Math.abs(f-c),height:Math.abs(p-d)}}let u=new _e().autoOrigin().moveTo(e.x,e.y).lineTo(e.x+e.width,e.y).lineTo(e.x+e.width,e.y+e.height).lineTo(e.x,e.y+e.height).close().build();return Wk(u,t,n)}return Wk(e,t,n)}function Wk(e,t,n){let r=og(e,Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]))),o=e.origin;if(o===void 0){let d=$y(e.coords,t),f=n.autoOrigin!==!1?Sn(d):void 0;return f?{...r,coords:At(f,d),origin:f}:{...r,coords:Float32Array.from(d)}}let[i,s,a,l,u,c]=t;return{...r,coords:Float32Array.from($y(e.coords,[i,s,a,l,0,0])),origin:{x:i*o.x+a*o.y+u,y:s*o.x+l*o.y+c}}}var Uk,Il=Q(()=>{"use strict";cs();mr();wl();tn();Uk=1e-9});function Ag(e,t,n){return e.kind==="rect"?{kind:"rect",x:e.x+t,y:e.y+n,width:e.width,height:e.height}:R4(e,t,n)}function R4(e,t,n){let r=e.origin;if(r)return{...e,coords:e.coords.slice(),origin:{x:r.x+t,y:r.y+n}};let o=new Float32Array(e.coords.length),{commands:i,coords:s}=e;return Ge(i,s,(a,l)=>{for(let u=0,c=oo(a);u<c;u+=2)o[l+u]=s[l+u]+t,o[l+u+1]=s[l+u+1]+n}),{...e,coords:o}}var Vk=Q(()=>{"use strict";Je()});function Rg(e){if(e.kind==="rect")return 4;let t=e.commands,n=0;for(let r=0;r<t.length;r++){let o=t[r];(o===le||o===ce||o===xe||o===we)&&n++}return n}var zk=Q(()=>{"use strict";Je()});function Ld(e){if(e.kind==="rect")return e.width*e.height;let{commands:t,coords:n}=e,r=kn(e),o=0,i=0,s=0,a=0,l=!1,u=0,c=0,d=f=>{l&&(f||r)&&(o+=i+u*a-s*c),i=0,l=!1};return Ge(t,n,(f,p,h,m)=>{if(f===le){d(!1),s=u=n[p],a=c=n[p+1],l=!0;return}if(f===fe){d(!0),u=s,c=a;return}if(l||(s=h,a=m,l=!0),f===ce){u=n[p],c=n[p+1],i+=h*c-u*m;return}let g=f===xe,b=n[p],x=n[p+1],w=n[p+2],y=n[p+3],P=g?n[p+4]:w,S=g?n[p+5]:y;for(let v=0;v<3;v++){let A=N4[v],N=1-A,M,C,F,B;g?(M=N*N*N*h+3*N*N*A*b+3*N*A*A*w+A*A*A*P,C=N*N*N*m+3*N*N*A*x+3*N*A*A*y+A*A*A*S,F=3*(N*N*(b-h)+2*N*A*(w-b)+A*A*(P-w)),B=3*(N*N*(x-m)+2*N*A*(y-x)+A*A*(S-y))):(M=N*N*h+2*N*A*b+A*A*w,C=N*N*m+2*N*A*x+A*A*y,F=2*(N*(b-h)+A*(w-b)),B=2*(N*(x-m)+A*(y-x))),i+=I4[v]*(M*B-C*F)}u=P,c=S}),d(!1),o/2}var N4,I4,Ng=Q(()=>{"use strict";Je();ii();N4=[.5-Math.sqrt(15)/10,.5,.5+Math.sqrt(15)/10],I4=[5/18,8/18,5/18]});function jk(e,t){let n=e[t];if(!/[A-Za-z]/.test(n))return!1;if(n!=="e"&&n!=="E"||!/[\d.]/.test(e[t-1]??""))return!0;let r=e[t+1]==="+"||e[t+1]==="-"?t+2:t+1;return!/\d/.test(e[r]??"")}function E4(e){let t=[],n=0;for(;n<e.length;)if(jk(e,n)){let r=n+1;for(;r<e.length&&!jk(e,r);)r++;let o=e.slice(n+1,r),i=e[n];t.push({cmd:i,args:i==="A"||i==="a"?C4(o):M4(o)}),n=r}else n++;return t}function M4(e){let t=[],n;for(Kk.lastIndex=0;(n=Kk.exec(e))!==null;){let r=Number(n[0]);Number.isFinite(r)&&t.push(r)}return t}function C4(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===","||r===" "||r===" "||r===`
2
+ `||r==="\r"){n++;continue}let o=t.length%7;if(o===3||o===4){if(r!=="0"&&r!=="1")return t;t.push(r==="1"?1:0),n++;continue}Ig.lastIndex=n;let i=Ig.exec(e);if(!i)return t;t.push(Number(i[0])),n=Ig.lastIndex}return t}function si(e,t){let n=E4(e),r=new _e().autoOrigin(),o={x:0,y:0,startX:0,startY:0,lastCubicCtrl:null,lastQuadCtrl:null},i=!1;for(let{cmd:s,args:a}of n){let l=s.toUpperCase(),u=s!==l,c=O4[l];if(c===void 0){t?.(`unknown path command: ${s}`);continue}if(!i&&l!=="M"){t?.(`path data does not begin with a moveto ("${s}" comes first); nothing is drawn`);break}if(l==="Z"){r.close(),o.x=o.startX,o.y=o.startY,o.lastCubicCtrl=null,o.lastQuadCtrl=null;continue}let d=Math.floor(a.length/c);for(let f=0;f<d;f++){let p=a.slice(f*c,(f+1)*c),h=l==="M"&&f>0?"L":l;F4(h,u,p,o,r),i=!0}if(d===0||a.length%c!==0){t?.(`path command "${s}" takes ${c} arguments at a time and has ${a.length}; the path ends before it`);break}}return r.build()}function F4(e,t,n,r,o){let i=t?r.x:0,s=t?r.y:0;switch(e){case"M":{let a=n[0]+i,l=n[1]+s;o.moveTo(a,l),r.x=a,r.y=l,r.startX=a,r.startY=l,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"L":{let a=n[0]+i,l=n[1]+s;o.lineTo(a,l),r.x=a,r.y=l,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"H":{let a=n[0]+(t?r.x:0);o.lineTo(a,r.y),r.x=a,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"V":{let a=n[0]+(t?r.y:0);o.lineTo(r.x,a),r.y=a,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"C":{let a=n[0]+i,l=n[1]+s,u=n[2]+i,c=n[3]+s,d=n[4]+i,f=n[5]+s;o.curveTo(a,l,u,c,d,f),r.x=d,r.y=f,r.lastCubicCtrl={x:u,y:c},r.lastQuadCtrl=null;return}case"S":{let a=r.lastCubicCtrl??{x:r.x,y:r.y},l=2*r.x-a.x,u=2*r.y-a.y,c=n[0]+i,d=n[1]+s,f=n[2]+i,p=n[3]+s;o.curveTo(l,u,c,d,f,p),r.x=f,r.y=p,r.lastCubicCtrl={x:c,y:d},r.lastQuadCtrl=null;return}case"Q":{let a=n[0]+i,l=n[1]+s,u=n[2]+i,c=n[3]+s;o.quadTo(a,l,u,c),r.x=u,r.y=c,r.lastQuadCtrl={x:a,y:l},r.lastCubicCtrl=null;return}case"T":{let a=r.lastQuadCtrl??{x:r.x,y:r.y},l=2*r.x-a.x,u=2*r.y-a.y,c=n[0]+i,d=n[1]+s;o.quadTo(l,u,c,d),r.x=c,r.y=d,r.lastQuadCtrl={x:l,y:u},r.lastCubicCtrl=null;return}case"A":{let a=Math.abs(n[0]),l=Math.abs(n[1]),u=n[2],c=n[3]!==0,d=n[4]!==0,f=n[5]+i,p=n[6]+s;L4(r.x,r.y,f,p,a,l,u,c,d,o),r.x=f,r.y=p,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}default:return}}function L4(e,t,n,r,o,i,s,a,l,u){if(e===n&&t===r)return;if(o===0||i===0){u.lineTo(n,r);return}let c=s*Math.PI/180,d=Math.cos(c),f=Math.sin(c),p=(e-n)/2,h=(t-r)/2,m=d*p+f*h,g=-f*p+d*h,b=o*o,x=i*i,w=m*m,y=g*g,P=w/b+y/x,S=o,v=i;if(P>1){let te=Math.sqrt(P);S=te*o,v=te*i,b=S*S,x=v*v}let A=a===l?-1:1,N=b*x-b*y-x*w,M=b*y+x*w,C=A*Math.sqrt(Math.max(0,N/M)),F=C*(S*g)/v,B=C*-(v*m)/S,D=d*F-f*B+(e+n)/2,j=f*F+d*B+(t+r)/2,W=(te,he,be,Fe)=>{let Se=te*be+he*Fe,ur=Math.sqrt((te*te+he*he)*(be*be+Fe*Fe)),Le=Math.acos(Math.max(-1,Math.min(1,Se/ur)));return te*Fe-he*be<0&&(Le=-Le),Le},J=W(1,0,(m-F)/S,(g-B)/v),se=W((m-F)/S,(g-B)/v,(-m-F)/S,(-g-B)/v);!l&&se>0?se-=2*Math.PI:l&&se<0&&(se+=2*Math.PI);let ke=Math.max(1,Math.ceil(Math.abs(se)/(Math.PI/2))),ae=se/ke,ve=4/3*Math.tan(ae/4),G=e,K=t,$=-Math.sin(J)*S,ee=Math.cos(J)*v;for(let te=1;te<=ke;te++){let he=J+te*ae,be=Math.cos(he),Fe=Math.sin(he),Se=d*(be*S)-f*(Fe*v)+D,ur=f*(be*S)+d*(Fe*v)+j,Le=-Fe*S,vt=be*v,Xt=G+d*(ve*$)-f*(ve*ee),Vc=K+f*(ve*$)+d*(ve*ee),dy=Se-d*(ve*Le)+f*(ve*vt),zc=ur-f*(ve*Le)-d*(ve*vt);u.curveTo(Xt,Vc,dy,zc,Se,ur),G=Se,K=ur,$=Le,ee=vt}}var Kk,Ig,O4,$k=Q(()=>{"use strict";mr();Kk=/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g,Ig=/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/y;O4={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0}});function Ue(e,t,n,r){let o=(n-e)/3,i=(r-t)/3;return{c:[e,t,e+o,t+i,n-o,r-i,n,r],line:!0}}function ai(e){if(e.kind==="rect"){let{x:c,y:d,width:f,height:p}=e;return[{closed:!0,segs:[Ue(c,d,c+f,d),Ue(c+f,d,c+f,d+p),Ue(c+f,d+p,c,d+p),Ue(c,d+p,c,d)]}]}let t=[],n=null,r=0,o=0,i=(c,d,f)=>{n!==null&&(c&&((d!==r||f!==o)&&n.segs.push(Ue(d,f,r,o)),n.closed=!0),n.segs.length>0&&t.push(n),n=null)},s=Qe(e),{commands:a}=s,l=$e(s);Ge(a,l,(c,d,f,p,h,m)=>{switch(m&&(n={segs:[],closed:!1},r=f,o=p),c){case le:i(!1,f,p),n={segs:[],closed:!1},r=l[d],o=l[d+1];break;case ce:{let g=l[d],b=l[d+1];(g!==f||b!==p)&&n.segs.push(Ue(f,p,g,b));break}case we:{let[g,b,x,w]=io(f,p,l[d],l[d+1],l[d+2],l[d+3]);n.segs.push({c:[f,p,g,b,x,w,l[d+2],l[d+3]],line:!1});break}case xe:n.segs.push({c:[f,p,l[d],l[d+1],l[d+2],l[d+3],l[d+4],l[d+5]],line:!1});break;case fe:i(!0,f,p);break}});let u=n;if(u!==null){let c=u.segs.at(-1);i(!1,c?c.c[6]:r,c?c.c[7]:o)}return t}function Eg(e,t="nonzero"){let n=new _e().setFillRule(t);for(let{segs:r,closed:o}of e)if(r.length!==0){n.moveTo(r[0].c[0],r[0].c[1]);for(let{c:i,line:s}of r)s?n.lineTo(i[6],i[7]):n.curveTo(i[2],i[3],i[4],i[5],i[6],i[7]);o&&n.close()}return n.build()}function gs(e,t){let[n,r]=so(...e.c,t);return[{c:[...n],line:e.line},{c:[...r],line:e.line}]}var _d=Q(()=>{"use strict";Pn();Je();mr();nn();tn()});function tt(e,t){let n=1-t;if(e.length===2)return{x:n*e[0].x+t*e[1].x,y:n*e[0].y+t*e[1].y};if(e.length===3){let a=n*n,l=2*n*t,u=t*t;return{x:a*e[0].x+l*e[1].x+u*e[2].x,y:a*e[0].y+l*e[1].y+u*e[2].y}}let r=n*n*n,o=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:r*e[0].x+o*e[1].x+i*e[2].x+s*e[3].x,y:r*e[0].y+o*e[1].y+i*e[2].y+s*e[3].y}}function Ml(e,t){let n=e.length-1,r=[];for(let o=0;o<n;o++)r.push({x:n*(e[o+1].x-e[o].x),y:n*(e[o+1].y-e[o].y)});return r.length===1?r[0]:tt(r,t)}function Yk(e,t){let n=i=>{let s=[];for(let a=0;a<i.length;a+=2)s.push({x:i[a],y:i[a+1]});return s};if(e.length===2){let i=tt(e,t);return[[e[0],i],[i,e[1]]]}if(e.length===3){let[i,s]=jS(e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,t);return[n(i),n(s)]}let[r,o]=so(e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y,t);return[n(r),n(o)]}function bs(e,t,n,r,o){if(n-t<=0)return null;let i=e;t>0&&(i=Yk(i,t)[1]);let s=(n-t)/(1-t);return s<1&&(i=Yk(i,s)[0]),i=i.slice(),i[0]=r,i[i.length-1]=o,i}function _4(e){let t=[];for(let n of e){let r=n.length===2?1:16;for(let o=0;o<r;o++){let i=tt(n,o/r);t.push(i.x,i.y)}}return t}function Xk(e){return yr(_4(e))}function Jk(e,t,n){return e.map(r=>n.x*(r.y-t.y)-n.y*(r.x-t.x))}function El(e,t){let n=1-t;return e.length===2?n*e[0]+t*e[1]:e.length===3?n*n*e[0]+2*n*t*e[1]+t*t*e[2]:n*n*n*e[0]+3*n*n*t*e[1]+3*n*t*t*e[2]+t*t*t*e[3]}function Qk(e,t){let n=i=>i>0?1:i<0?-1:t?1:0,r=[0,...D4(e),1],o=[];for(let i=0;i+1<r.length;i++){let s=r[i],a=r[i+1],l=n(El(e,s)),u=n(El(e,a));if(l===0&&i>0){let c=n(El(e,s-1e-7)),d=n(El(e,s+1e-7));c*d<0&&o.push({t:s,before:c,after:d})}if(!(l*u>=0)){for(let c=0;c<64;c++){let d=(s+a)/2;n(El(e,d))===l?s=d:a=d}o.push({t:(s+a)/2,before:l,after:u})}}return o}function D4(e){if(e.length<3)return[];let t=e.length-1,n=e.slice(1).map((l,u)=>t*(l-e[u])),r=0,o,i;n.length===2?(o=n[1]-n[0],i=n[0]):(r=n[0]-2*n[1]+n[2],o=2*(n[1]-n[0]),i=n[0]);let s=[],a=Math.max(Math.abs(r),Math.abs(o),Math.abs(i))||1;if(Math.abs(r)/a<1e-12)Math.abs(o)/a>1e-12&&s.push(-i/o);else{let l=o*o-4*r*i;if(l>=0){let u=-.5*(o+Math.sign(o||1)*Math.sqrt(l));s.push(u/r),u!==0&&s.push(i/u)}}return s.filter(l=>l>0&&l<1).sort((l,u)=>l-u)}var qk,li=Q(()=>{"use strict";Pn();Nl();qk=e=>e.map(t=>t.slice().reverse()).reverse()});function ev(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let i of e)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return[t,n,r,o]}function tv(e){if(e.length===2)return 0;let t=e[0],n=e[e.length-1],r=n.x-t.x,o=n.y-t.y,i=Math.hypot(r,o),s=0;for(let a=1;a<e.length-1;a++){let l=e[a],u=i===0?Math.hypot(l.x-t.x,l.y-t.y):Math.abs((l.x-t.x)*o-(l.y-t.y)*r)/i;u>s&&(s=u)}return s}function nv(e){let t=e.pts,n=[t[0]],r=[t[t.length-1]];for(;t.length>1;){let i=[];for(let s=0;s+1<t.length;s++)i.push({x:(t[s].x+t[s+1].x)/2,y:(t[s].y+t[s+1].y)/2});t=i,n.push(t[0]),r.unshift(t[t.length-1])}let o=(e.t0+e.t1)/2;return[{pts:n,t0:e.t0,t1:o},{pts:r,t0:o,t1:e.t1}]}function rv(e,t,n,r,o){let i=t.x-e.x,s=t.y-e.y,a=r.x-n.x,l=r.y-n.y,u=i*l-s*a;if(u===0)return null;let c=n.x-e.x,d=n.y-e.y,f=(c*l-d*a)/u,p=(c*s-d*i)/u;return f<-o||f>1+o||p<-o||p>1+o?null:[f,p]}function G4(e,t,n,r){for(let o=0;o<12;o++){let i=tt(e,n),s=tt(t,r),a=i.x-s.x,l=i.y-s.y;if(Math.abs(a)+Math.abs(l)<1e-12)break;let u=Ml(e,n),c=Ml(t,r),d=-u.x*c.y+u.y*c.x;if(d===0)break;let f=(-a*-c.y- -l*-c.x)/d,p=(u.x*-l-u.y*-a)/d;n=Math.min(1,Math.max(0,n+f)),r=Math.min(1,Math.max(0,r+p))}return[n,r]}function Mg(e,t){if(e.length===2&&t.length===2){let i=rv(e[0],e[1],t[0],t[1],1e-12);if(!i)return[];let s=Math.min(1,Math.max(0,i[0])),a=Math.min(1,Math.max(0,i[1])),l=tt(e,s);return[{ta:s,tb:a,x:l.x,y:l.y}]}let n=[],r=(i,s)=>{[i,s]=G4(e,t,i,s);let a=tt(e,i),l=tt(t,s);Math.hypot(a.x-l.x,a.y-l.y)>1e-6*(1+Math.abs(a.x)+Math.abs(a.y))||n.some(u=>Math.abs(u.ta-i)<Zk&&Math.abs(u.tb-s)<Zk)||n.push({ta:i,tb:s,x:a.x,y:a.y})},o=[[{pts:e,t0:0,t1:1},{pts:t,t0:0,t1:1},0]];for(;o.length>0&&n.length<H4;){let[i,s,a]=o.pop(),l=ev(i.pts),u=ev(s.pts);if(l[0]>u[2]+xs||u[0]>l[2]+xs||l[1]>u[3]+xs||u[1]>l[3]+xs)continue;let c=tv(i.pts),d=tv(s.pts);if(c<=xs&&d<=xs||a>=B4){let f=rv(i.pts[0],i.pts[i.pts.length-1],s.pts[0],s.pts[s.pts.length-1],1e-6);f&&r(i.t0+f[0]*(i.t1-i.t0),s.t0+f[1]*(s.t1-s.t0));continue}if(c>=d){let[f,p]=nv(i);o.push([f,s,a+1],[p,s,a+1])}else{let[f,p]=nv(s);o.push([i,f,a+1],[i,p,a+1])}}return n.sort((i,s)=>i.ta-s.ta)}var xs,B4,Zk,H4,ov=Q(()=>{"use strict";li();xs=1e-4,B4=48,Zk=1e-7,H4=16});function iv(e){let t=e.kind==="rect"||kn(e);return U4(e).filter(n=>n.closed||t).map(n=>n.segs)}function U4(e,t=!0){let n=Qe(e);if(n.kind==="rect"){let{x:c,y:d,width:f,height:p}=n,h=[{x:c,y:d},{x:c+f,y:d},{x:c+f,y:d+p},{x:c,y:d+p}];return[{segs:h.map((m,g)=>[m,h[(g+1)%4]]),closed:!0}]}let r=[],o=[],i={x:0,y:0},s=i,a=c=>{o.length>0&&(c||t)&&(s.x!==i.x||s.y!==i.y)&&o.push([s,i]),o.length>0&&r.push({segs:o,closed:c}),o=[],s=i},l=$e(n),u=0;for(let c of n.commands)if(c===le)a(!1),i=s={x:l[u],y:l[u+1]},u+=2;else if(c===ce){let d={x:l[u],y:l[u+1]};(d.x!==s.x||d.y!==s.y)&&o.push([s,d]),s=d,u+=2}else if(c===we){let d={x:l[u+2],y:l[u+3]};o.push([s,{x:l[u],y:l[u+1]},d]),s=d,u+=4}else if(c===xe){let d={x:l[u+4],y:l[u+5]};o.push([s,{x:l[u],y:l[u+1]},{x:l[u+2],y:l[u+3]},d]),s=d,u+=6}else c===fe&&a(!0);return a(!1),r}function sv(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let i of e)for(let s of i)for(let a of s)t=Math.min(t,a.x),r=Math.max(r,a.x),n=Math.min(n,a.y),o=Math.max(o,a.y);return Math.hypot(r-t,o-n)}var av=Q(()=>{"use strict";Je();ii();nn();tn()});function Wn(e,t){let n=new e.constructor(t);return n.set(e),n}function Cg(e,t,n,r,o){for(let i=0;i<o;i++)n[r+i]<e[t+i]&&(e[t+i]=n[r+i]),n[r+o+i]>e[t+o+i]&&(e[t+o+i]=n[r+o+i])}var Dd,lv=Q(()=>{"use strict";Dd=class{dim;root=-1;nodeBox;left;right;parent;leafCount;leafItems;count;nodeCap=0;nodeTop=0;freeNodes=[];itemBox;itemCentroid2;itemLeaf;keys=[];itemCap=0;itemTop=0;freeItems=[];constructor(t){this.dim=t,this.nodeBox=new Float64Array(0),this.left=this.right=this.parent=this.leafCount=this.leafItems=this.count=new Int32Array(0),this.itemBox=new Float64Array(0),this.itemCentroid2=new Float64Array(0),this.itemLeaf=new Int32Array(0),this.growNodes(16),this.growItems(16)}growNodes(t){let n=2*this.dim;this.nodeBox=Wn(this.nodeBox,t*n),this.left=Wn(this.left,t),this.right=Wn(this.right,t),this.parent=Wn(this.parent,t),this.leafCount=Wn(this.leafCount,t),this.leafItems=Wn(this.leafItems,t*4),this.count=Wn(this.count,t),this.nodeCap=t}growItems(t){this.itemBox=Wn(this.itemBox,t*2*this.dim),this.itemCentroid2=Wn(this.itemCentroid2,t*this.dim),this.itemLeaf=Wn(this.itemLeaf,t),this.itemCap=t}allocNode(t){let n=this.freeNodes.pop();return n===void 0&&(this.nodeTop===this.nodeCap&&this.growNodes(this.nodeCap*2),n=this.nodeTop++),this.left[n]=-1,this.right[n]=-1,this.parent[n]=t,this.leafCount[n]=0,n}freeNode(t){this.freeNodes.push(t)}allocItem(t,n){let r=this.freeItems.pop();return r===void 0&&(this.itemTop===this.itemCap&&this.growItems(this.itemCap*2),r=this.itemTop++),this.keys[r]=t,this.writeItemBox(r,n),r}freeItem(t){this.keys[t]=void 0,this.itemLeaf[t]=-1,this.freeItems.push(t)}writeItemBox(t,n){let r=this.dim,o=2*r;for(let i=0;i<o;i++)this.itemBox[t*o+i]=n[i];for(let i=0;i<r;i++)this.itemCentroid2[t*r+i]=n[i]+n[r+i]}computeBox(t){let n=this.dim,r=2*n,o=this.nodeBox,i=t*r;for(let a=0;a<n;a++)o[i+a]=1/0,o[i+n+a]=-1/0;if(this.left[t]!==-1){Cg(o,i,o,this.left[t]*r,n),Cg(o,i,o,this.right[t]*r,n),this.count[t]=this.count[this.left[t]]+this.count[this.right[t]];return}this.count[t]=this.leafCount[t];let s=t*4;for(let a=0;a<this.leafCount[t];a++)Cg(o,i,this.itemBox,this.leafItems[s+a]*r,n)}refitUp(t){for(;t!==-1;t=this.parent[t])this.computeBox(t)}build(){this.freeNodes=[],this.nodeTop=0,this.root=-1;let t=[];for(let r=0;r<this.itemTop;r++)this.itemLeaf[r]!==-1&&t.push(r);if(t.length===0)return;this.nodeCap<2*t.length&&this.growNodes(2*t.length);let n=Int32Array.from(t);this.root=this.buildRange(n,0,n.length,-1)}rebuildSubtree(t){let n=this.parent[t],r=n!==-1&&this.left[n]===t,o=new Int32Array(this.count[t]),i=[t],s=0;for(;i.length>0;){let l=i.pop();if(this.left[l]!==-1)i.push(this.left[l],this.right[l]);else for(let u=0;u<this.leafCount[l];u++)o[s++]=this.leafItems[l*4+u];this.freeNode(l)}let a=this.buildRange(o,0,s,n);n===-1?this.root=a:r?this.left[n]=a:this.right[n]=a}buildRange(t,n,r,o,i=new Float64Array(t.length)){let s=this.allocNode(o);if(r-n<=4)for(let a=n;a<r;a++)this.placeInLeaf(s,t[a]);else{let a=n+r>>1;this.select(t,i,n,r,a,this.longestCentroidAxis(t,n,r));let l=this.buildRange(t,n,a,s,i),u=this.buildRange(t,a,r,s,i);this.left[s]=l,this.right[s]=u}return this.computeBox(s),s}placeInLeaf(t,n){this.leafItems[t*4+this.leafCount[t]++]=n,this.itemLeaf[n]=t}splitLeaf(t,n){let r=t*4,o=new Int32Array(5);for(let l=0;l<4;l++)o[l]=this.leafItems[r+l];o[4]=n;let i=o.length>>1;this.select(o,new Float64Array(o.length),0,o.length,i,this.longestCentroidAxis(o,0,o.length)),this.leafCount[t]=0;let s=this.allocNode(t),a=this.allocNode(t);for(let l=0;l<i;l++)this.placeInLeaf(s,o[l]);for(let l=i;l<o.length;l++)this.placeInLeaf(a,o[l]);this.left[t]=s,this.right[t]=a,this.computeBox(s),this.computeBox(a)}longestCentroidAxis(t,n,r){let o=this.dim,i=this.itemCentroid2,s=0,a=-1;for(let l=0;l<this.dim;l++){let u=1/0,c=-1/0;for(let d=n;d<r;d++){let f=i[t[d]*o+l];f<u&&(u=f),f>c&&(c=f)}c-u>a&&(a=c-u,s=l)}return s}select(t,n,r,o,i,s){let a=this.dim,l=this.itemCentroid2;for(let d=r;d<o;d++)n[d]=l[t[d]*a+s];let u=r,c=o-1;for(;u<c;){let d=n[u+c>>1],f=u,p=c;for(;f<=p;){for(;n[f]<d;)f++;for(;n[p]>d;)p--;if(f<=p){let h=t[f];t[f]=t[p],t[p]=h;let m=n[f];n[f]=n[p],n[p]=m,f++,p--}}if(i<=p)c=p;else if(i>=f)u=f;else return}}}});function Bd(e,t,n,r){e.ensureHeap(t+1);let o=e.heapT,i=e.heapId,s=t;for(;s>0;){let a=s-1>>1;if(o[a]<=n)break;o[s]=o[a],i[s]=i[a],s=a}return o[s]=n,i[s]=r,t+1}function W4(e,t){let n=e.heapT,r=e.heapId,o=t-1,i=n[o],s=r[o],a=0;for(;;){let l=2*a+1;if(l>=o||(l+1<o&&n[l+1]<n[l]&&l++,n[l]>=i))break;n[a]=n[l],r[a]=r[l],a=l}n[a]=i,r[a]=s}function uv(e,t,n,r,o,i){for(let s=0;s<n;s++)if(e[t+s]>r[i+s]||r[o+s]>e[t+n+s])return!1;return!0}function Og(e,t,n,r,o,i){if(e.root===-1)return;let s=t.take(),a=e.dim,l=2*a;try{let u=s.stackAt(0),c=0;for(u[c++]=e.root;c>0;){let d=u[--c];if(uv(e.nodeBox,d*l,a,n,r,o)){if(e.left[d]===-1){let f=d*4;for(let p=0;p<e.leafCount[d];p++){let h=e.leafItems[f+p];if(uv(e.itemBox,h*l,a,n,r,o)&&i(e.keys[h])===!1)return}continue}u=s.stackAt(c+1),u[c++]=e.left[d],u[c++]=e.right[d]}}}finally{s.release()}}function cv(e,t,n,r){for(let o=0;o<r.length;o++){let{normal:i,offset:s}=r[o],a=s;for(let l=0;l<n;l++)a+=i[l]*(i[l]>=0?e[t+n+l]:e[t+l]);if(a<0)return!1}return!0}function dv(e,t,n,r){if(e.root===-1)return;let o=t.take(),i=e.dim,s=2*i;try{let a=o.stackAt(0),l=0;for(a[l++]=e.root;l>0;){let u=a[--l];if(cv(e.nodeBox,u*s,i,n)){if(e.left[u]===-1){let c=u*4;for(let d=0;d<e.leafCount[u];d++){let f=e.leafItems[c+d];if(cv(e.itemBox,f*s,i,n)&&r(e.keys[f])===!1)return}continue}a=o.stackAt(l+1),a[l++]=e.left[u],a[l++]=e.right[u]}}}finally{o.release()}}function Hd(e,t,n,r,o,i){let s=0,a=i;for(let l=0;l<n;l++){let u=e[t+l],c=e[t+n+l];if(o[l]===0){if(r[l]<u||r[l]>c)return-1;continue}let d=(u-r[l])/o[l],f=(c-r[l])/o[l];if(d<f?(d>s&&(s=d),f<a&&(a=f)):(f>s&&(s=f),d<a&&(a=d)),s>a)return-1}return s}function fv(e,t,n,r,o,i){if(e.root===-1)return;let s=e.dim,a=2*s,l=Hd(e.nodeBox,e.root*a,s,n,r,i);if(l<0)return;let u=t.take();try{let c=Bd(u,0,l,e.root);for(;c>0;){let d=u.heapT[0],f=u.heapId[0];if(W4(u,c--),f<0){if(o(e.keys[-f-1],d)===!1)return;continue}if(e.left[f]===-1){let b=f*4;for(let x=0;x<e.leafCount[f];x++){let w=e.leafItems[b+x],y=Hd(e.itemBox,w*a,s,n,r,i);y>=0&&(c=Bd(u,c,y,-w-1))}continue}let p=e.left[f],h=e.right[f],m=Hd(e.nodeBox,p*a,s,n,r,i);m>=0&&(c=Bd(u,c,m,p));let g=Hd(e.nodeBox,h*a,s,n,r,i);g>=0&&(c=Bd(u,c,g,h))}}finally{u.release()}}var Gd,pv=Q(()=>{"use strict";Gd=class e{stack=new Int32Array(64);heapT=new Float64Array(64);heapId=new Int32Array(64);busy=!1;take(){return this.busy?new e:(this.busy=!0,this)}release(){this.busy=!1}stackAt(t){if(t>=this.stack.length){let n=new Int32Array(this.stack.length*2);n.set(this.stack),this.stack=n}return this.stack}ensureHeap(t){if(t<this.heapT.length)return;let n=new Float64Array(this.heapT.length*2),r=new Int32Array(this.heapId.length*2);n.set(this.heapT),r.set(this.heapId),this.heapT=n,this.heapId=r}}});function hv(e){return 2*Math.ceil(Math.log2(Math.max(e,2)))}function z4(e){let t=0;for(;e>4;e=Math.ceil(e/2))t++;return t}function Fg(e,t){if(e.length<2*t)return!1;for(let n=0;n<t;n++){let r=e[n],o=e[t+n];if(!Number.isFinite(r)||!Number.isFinite(o)||r>o)return!1}return!0}function _g(e,t){if(!Number.isInteger(e)||e<1)throw new RangeError(`createBvh: dim must be a positive integer, got ${e}`);let n=new Lg(e);return t&&(n.load(t),n.rebuild()),n}var V4,Lg,mv=Q(()=>{"use strict";lv();pv();V4=.7;Lg=class{dim;tree;items=new Map;scratch=new Gd;peakSize=0;constructor(t){this.dim=t,this.tree=new Dd(t)}get size(){return this.items.size}load(t){for(let[n,r]of t){if(!Fg(r,this.dim))continue;let o=this.items.get(n);if(o!==void 0){this.tree.writeItemBox(o,r);continue}let i=this.tree.allocItem(n,r);this.tree.itemLeaf[i]=0,this.items.set(n,i)}}insert(t,n){if(!Fg(n,this.dim))return!1;if(this.items.has(t))return this.update(t,n);let r=this.tree.allocItem(t,n);return this.items.set(t,r),this.items.size>this.peakSize&&(this.peakSize=this.items.size),this.place(r),!0}update(t,n){let r=this.items.get(t);if(r===void 0||!Fg(n,this.dim))return!1;let o=this.tree,i=o.itemLeaf[r];return this.leafHolds(i,n)?(o.writeItemBox(r,n),!0):(this.detach(r),o.writeItemBox(r,n),this.place(r),!0)}remove(t){let n=this.items.get(t);return n===void 0?!1:(this.detach(n),this.items.delete(t),this.tree.freeItem(n),this.items.size<this.peakSize>>1&&this.rebuild(),!0)}refit(){let t=this.tree;if(t.root===-1)return;let n=this.scratch.take();try{let r=n.stackAt(0);r[0]=t.root;let o=1;for(let i=0;i<o;i++){let s=r[i];t.left[s]!==-1&&(r=n.stackAt(o+1),r[o++]=t.left[s],r[o++]=t.right[s])}for(let i=o-1;i>=0;i--)t.computeBox(r[i])}finally{n.release()}}rebuild(){this.tree.build(),this.peakSize=this.items.size}maxDepth(){let t=this.tree;if(t.root===-1)return 0;let n=0,r=[[t.root,0]];for(;r.length>0;){let[o,i]=r.pop();t.left[o]===-1?n=Math.max(n,i):r.push([t.left[o],i+1],[t.right[o],i+1])}return n}queryBox(t,n){Og(this.tree,this.scratch,t,0,this.dim,n)}queryPoint(t,n){Og(this.tree,this.scratch,t,0,0,n)}raycast(t,n,r,o=1/0){fv(this.tree,this.scratch,t,n,r,o)}queryHalfSpaces(t,n){dv(this.tree,this.scratch,t,n)}leafHolds(t,n){let r=this.dim,o=t*2*r,i=this.tree.nodeBox;for(let s=0;s<r;s++)if(n[s]<i[o+s]||n[r+s]>i[o+r+s])return!1;return!0}place(t){let n=this.tree;if(n.root===-1){n.root=n.allocNode(-1),n.placeInLeaf(n.root,t),n.computeBox(n.root);return}let r=n.root,o=0;for(;n.left[r]!==-1;){let i=n.left[r],s=n.right[r],a=this.enlargement(i,t),l=this.enlargement(s,t);r=a<l||a===l&&n.count[i]<=n.count[s]?i:s,o++}n.leafCount[r]<4?n.placeInLeaf(r,t):(n.splitLeaf(r,t),o++),n.refitUp(r),o>hv(this.items.size)&&this.rebalance(n.itemLeaf[t],o)}rebalance(t,n){let r=this.tree,o=hv(this.items.size),i=-1;for(let s=t,a=r.parent[t],l=n-1;a!==-1;s=a,a=r.parent[a],l--)if(!(l+z4(r.count[a])>o)){if(r.count[s]>V4*r.count[a]){r.rebuildSubtree(a);return}i===-1&&(i=a)}i!==-1?r.rebuildSubtree(i):this.rebuild()}enlargement(t,n){let r=this.dim,o=this.tree.nodeBox,i=this.tree.itemBox,s=t*2*r,a=n*2*r,l=0;for(let u=0;u<r;u++){let c=Math.min(o[s+u],i[a+u]),d=Math.max(o[s+r+u],i[a+r+u]);l+=d-c-(o[s+r+u]-o[s+u])}return l}detach(t){let n=this.tree,r=n.itemLeaf[t],o=r*4,i=n.leafCount[r];for(let u=0;u<i;u++)if(n.leafItems[o+u]===t){n.leafItems[o+u]=n.leafItems[o+i-1];break}if(n.leafCount[r]=i-1,n.itemLeaf[t]=-1,i>1){n.refitUp(r);return}let s=n.parent[r];if(n.freeNode(r),s===-1){n.root=-1;return}let a=n.left[s]===r?n.right[s]:n.left[s],l=n.parent[s];n.parent[a]=l,l===-1?n.root=a:n.left[l]===s?n.left[l]=a:n.right[l]=a,n.freeNode(s),n.refitUp(l)}}});function yv(e,t){let n=[],r=[];for(let{segs:i,closed:s}of e){n.push(le),r.push(i[0][0].x,i[0][0].y);for(let a of i){n.push(a.length===2?ce:a.length===3?we:xe);for(let l=1;l<a.length;l++)r.push(a[l].x,a[l].y)}s&&n.push(fe)}let o=Sn(r);return{kind:"polygon",commands:new Uint8Array(n),coords:At(o,r),fillRule:t,...o?{origin:o}:{}}}var gv=Q(()=>{"use strict";Je();tn()});function Bg(e,t,n={}){let r=new _e;if(!(t>0))return r.build();let o=Ld(e)<0?-1:1,i={d:t,sigma:o,tol:n.tolerance??.1,join:n.join??"miter",miterLimit:n.miterLimit??4};for(let s of ai(e)){let a=s.segs.filter(c=>!rU(c));if(a.length===0)continue;let l=a.at(-1).c,u=a[0].c;(l[6]!==u[0]||l[7]!==u[1])&&a.push(Ue(l[6],l[7],u[0],u[1])),sU(r,$4(a,i))}return r.build()}function $4(e,t){let n=e.map(r=>({pieces:Dg(r,t,0),join:[]}));for(let r=0;r<e.length;r++){let o=(r+1)%e.length,i=Pv(e[r].c),s=wv(e[o].c),a=[e[o].c[0],e[o].c[1]];n[r].join=Y4(n[r],n[o],a,i,s,t)}return n}function Y4(e,t,n,r,o,i){let s=iU(e.pieces.at(-1)),a=oU(t.pieces[0]),l=Math.hypot(a[0]-s[0],a[1]-s[1]);if(l<=i.tol*.001)return[];let u=r[0]*o[1]-r[1]*o[0],c=r[0]*o[0]+r[1]*o[1],d=i.sigma*u>0||Math.abs(u)<1e-9&&c<0;if(l<=i.tol)return q4(e,t,s);if(!d)return J4(e,t)?[]:[Ue(s[0],s[1],n[0],n[1]),Ue(n[0],n[1],a[0],a[1])];let f=Ud(r,i.sigma),p=Ud(o,i.sigma);if(i.join==="round")return eU(n,i.d,f,Math.atan2(u,c));let h=f[0]*p[0]+f[1]*p[1];if(1+h<1e-9||Math.sqrt(2/(1+h))>i.miterLimit)return[Ue(s[0],s[1],a[0],a[1])];let m=i.d/(1+h),g=[n[0]+(f[0]+p[0])*m,n[1]+(f[1]+p[1])*m];return X4(e,t,g)}function q4(e,t,n){let r=t.pieces[0];return r===e.pieces.at(-1)?[Ue(r.c[6],r.c[7],n[0],n[1])]:(t.pieces[0]=r.line?Ue(n[0],n[1],r.c[6],r.c[7]):{c:[n[0],n[1],r.c[2]+n[0]-r.c[0],r.c[3]+n[1]-r.c[1],r.c[4],r.c[5],r.c[6],r.c[7]],line:!1},[])}function X4(e,t,n){let r=e.pieces.at(-1),o=t.pieces[0],i=[];return r.line&&r!==o?e.pieces[e.pieces.length-1]=Ue(r.c[0],r.c[1],n[0],n[1]):i.push(Ue(r.c[6],r.c[7],n[0],n[1])),o.line&&r!==o?t.pieces[0]=Ue(n[0],n[1],o.c[6],o.c[7]):i.push(Ue(n[0],n[1],o.c[0],o.c[1])),i}function J4(e,t){let n=e.pieces.at(-1),r=t.pieces[0];if(n===r)return!1;let o=Q4(n.c,r.c);if(o===null)return!1;let i=o[0]>=1?n:gs(n,o[0])[0],s=o[1]<=0?r:gs(r,o[1])[1],a=(i.c[6]+s.c[0])/2,l=(i.c[7]+s.c[1])/2;return e.pieces[e.pieces.length-1]=i.line?Ue(i.c[0],i.c[1],a,l):{c:[i.c[0],i.c[1],i.c[2],i.c[3],i.c[4]+a-i.c[6],i.c[5]+l-i.c[7],a,l],line:!1},t.pieces[0]=s.line?Ue(a,l,s.c[6],s.c[7]):{c:[a,l,s.c[2]+a-s.c[0],s.c[3]+l-s.c[1],s.c[4],s.c[5],s.c[6],s.c[7]],line:!1},!0}function Q4(e,t){let n=bv(e),r=bv(t),o=null,i=1/0;for(let s=0;s<Ps;s++)for(let a=0;a<Ps;a++){let l=Z4(n[s],n[s+1],r[a],r[a+1]);if(l===null)continue;let u=(s+l[0])/Ps,c=(a+l[1])/Ps;u<=1e-9||c>=1-1e-9||1-u+c>=i||(i=1-u+c,o=[u,c])}return o}function bv(e){let t=[];for(let n=0;n<=Ps;n++)t.push(Ve(...e,n/Ps));return t}function Z4(e,t,n,r){let o=t[0]-e[0],i=t[1]-e[1],s=r[0]-n[0],a=r[1]-n[1],l=o*a-i*s;if(Math.abs(l)<1e-18)return null;let u=((n[0]-e[0])*a-(n[1]-e[1])*s)/l,c=((n[0]-e[0])*i-(n[1]-e[1])*o)/l;return u>=0&&u<=1&&c>=0&&c<=1?[u,c]:null}function eU(e,t,n,r){let o=Math.max(1,Math.ceil(Math.abs(r)/(Math.PI/2))),i=r/o,s=4/3*Math.tan(i/4)*t,a=Math.atan2(n[1],n[0]),l=[];for(let u=0;u<o;u++){let c=a+i*u,d=c+i,f=e[0]+Math.cos(c)*t,p=e[1]+Math.sin(c)*t,h=e[0]+Math.cos(d)*t,m=e[1]+Math.sin(d)*t;l.push({c:[f,p,f-Math.sin(c)*s,p+Math.cos(c)*s,h+Math.sin(d)*s,m-Math.cos(d)*s,h,m],line:!1})}return l}function Dg(e,t,n){let r=e.c,o=Ud(wv(r),t.sigma),i=Ud(Pv(r),t.sigma),{d:s}=t;if(e.line)return[Ue(r[0]+o[0]*s,r[1]+o[1]*s,r[6]+o[0]*s,r[7]+o[1]*s)];let a=Math.max(0,1+t.sigma*s*xv(r,0)),l=Math.max(0,1+t.sigma*s*xv(r,1)),u=r[0]+o[0]*s,c=r[1]+o[1]*s,d=r[6]+i[0]*s,f=r[7]+i[1]*s,p={c:[u,c,u+(r[2]-r[0])*a,c+(r[3]-r[1])*a,d+(r[4]-r[6])*l,f+(r[5]-r[7])*l,d,f],line:!1};if(n>=K4||tU(r,p.c,t)<=t.tol)return[p];let[h,m]=gs(e,.5);return[...Dg(h,t,n+1),...Dg(m,t,n+1)]}function tU(e,t,n){let r=0;for(let o of j4){let[i,s]=nU(e,o),a=Math.hypot(i,s);if(a<1e-12)continue;let[l,u]=Ve(...e,o),c=l+n.sigma*s/a*n.d,d=u-n.sigma*i/a*n.d,[f,p]=Ve(...t,o);r=Math.max(r,Math.hypot(f-c,p-d))}return r}function nU(e,t){let n=1-t,r=3*n*n,o=6*n*t,i=3*t*t;return[r*(e[2]-e[0])+o*(e[4]-e[2])+i*(e[6]-e[4]),r*(e[3]-e[1])+o*(e[5]-e[3])+i*(e[7]-e[5])]}function xv(e,t){let[n,r]=t===0?[e[2]-e[0],e[3]-e[1]]:[e[6]-e[4],e[7]-e[5]],[o,i]=t===0?[e[0]-2*e[2]+e[4],e[1]-2*e[3]+e[5]]:[e[6]-2*e[4]+e[2],e[7]-2*e[5]+e[3]],s=Math.hypot(n,r);return s<1e-12?0:2/3*(n*i-r*o)/(s*s*s)}function wv(e){return Ts(e[2]-e[0],e[3]-e[1])??Ts(e[4]-e[0],e[5]-e[1])??Ts(e[6]-e[0],e[7]-e[1])??[1,0]}function Pv(e){return Ts(e[6]-e[4],e[7]-e[5])??Ts(e[6]-e[2],e[7]-e[3])??Ts(e[6]-e[0],e[7]-e[1])??[1,0]}function Ts(e,t){let n=Math.hypot(e,t);return n<1e-12?null:[e/n,t/n]}function Ud(e,t){return[t*e[1],-t*e[0]]}function rU(e){let t=e.c;return t[0]===t[6]&&t[1]===t[7]&&t[0]===t[2]&&t[1]===t[3]&&t[0]===t[4]&&t[1]===t[5]}function sU(e,t){let n=t[0].pieces[0];e.moveTo(n.c[0],n.c[1]);for(let r of t)for(let o of[...r.pieces,...r.join])o.line?e.lineTo(o.c[6],o.c[7]):e.curveTo(o.c[2],o.c[3],o.c[4],o.c[5],o.c[6],o.c[7]);e.close()}var K4,j4,Ps,oU,iU,Tv=Q(()=>{"use strict";Pn();mr();_d();Ng();K4=6,j4=[.2,.35,.5,.65,.8];Ps=32;oU=e=>[e.c[0],e.c[1]],iU=e=>[e.c[6],e.c[7]]});function Rv(e){let t=e.map(o=>aU(o)),n=t.map(lU),r=[];for(let o=0;o<e.length;o++)for(let i=o+1;i<e.length;i++){if(!Yy(n[o],n[i]))continue;let s=t[o],a=t[i];for(let l=0;l+1<s.length;l++)for(let u=0;u+1<a.length;u++){let c=uU(s[l],s[l+1],a[u],a[u+1]);if(c===null)continue;let d=[(l+c[0])/(s.length-1),(u+c[1])/(a.length-1)],[f,p]=e[o].line&&e[i].line?d:cU(e[o].c,e[i].c,d);vv(f)&&vv(p)||r.some(h=>h.a===o&&h.b===i&&Math.abs(h.s-f)<1e-6&&Math.abs(h.t-p)<1e-6)||r.push({a:o,b:i,s:f,t:p})}}return r}function aU(e){if(e.line)return[[e.c[0],e.c[1]],[e.c[6],e.c[7]]];let t=[];for(let n=0;n<=Sv;n++)t.push(Ve(...e.c,n/Sv));return t}function lU(e){let t=[1/0,1/0,-1/0,-1/0];for(let[n,r]of e)t[0]=Math.min(t[0],n),t[1]=Math.min(t[1],r),t[2]=Math.max(t[2],n),t[3]=Math.max(t[3],r);return t}function uU(e,t,n,r){let o=t[0]-e[0],i=t[1]-e[1],s=r[0]-n[0],a=r[1]-n[1],l=o*a-i*s;if(Math.abs(l)<1e-18)return null;let u=((n[0]-e[0])*a-(n[1]-e[1])*s)/l,c=((n[0]-e[0])*i-(n[1]-e[1])*o)/l;return u>=0&&u<=1&&c>=0&&c<=1?[u,c]:null}function cU(e,t,n){let r=(l,u)=>{let c=Ve(...e,l),d=Ve(...t,u);return[c[0]-d[0],c[1]-d[1]]},[o,i]=n,s=r(o,i),a=Math.hypot(...s);for(let l=0;l<8&&Math.hypot(...s)>1e-13;l++){let u=Av(e,o),c=Av(t,i),d=-u[0]*c[1]+c[0]*u[1];if(Math.abs(d)<1e-18)break;o=Math.min(1,Math.max(0,o-(-c[1]*s[0]+c[0]*s[1])/d)),i=Math.min(1,Math.max(0,i-(-u[1]*s[0]+u[0]*s[1])/d)),s=r(o,i)}return Math.hypot(...s)<=a?[o,i]:n}function Av(e,t){let n=1-t,r=3*n*n,o=6*n*t,i=3*t*t;return[r*(e[2]-e[0])+o*(e[4]-e[2])+i*(e[6]-e[4]),r*(e[3]-e[1])+o*(e[5]-e[3])+i*(e[7]-e[5])]}var Sv,kv,vv,Nv=Q(()=>{"use strict";bl();Pn();Sv=16,kv=1e-7;vv=e=>e<kv||e>1-kv});function Gg(e,t={}){let n=t.tolerance??.01,r=ai(e).filter(d=>d.segs.length>0),o=r.flatMap(d=>Iv(d.segs,n*.001)),i=Ld(e)<0,s=o.map(()=>[]);for(let d of Rv(o)){let f=dU(o[d.a],d.s,o[d.b],d.t);s[d.a].push({t:d.s,p:f}),s[d.b].push({t:d.t,p:f})}let a=hU(o,n/4),l=[],u=!1;o.forEach((d,f)=>{let p=fU(d,s[f]);p.length>1&&(u=!0);for(let h of p){let m=mU(h,a,n);m===null?u=!0:m===i?l.push(h):(u=!0,l.push(pU(h)))}});let c=new _e;if(!u){for(let d of r)Mv(c,Iv(d.segs,n*.001));return c.build()}for(let d of yU(l))Mv(c,d);return c.build()}function Iv(e,t){let n=o=>o.line&&Math.hypot(o.c[6]-o.c[0],o.c[7]-o.c[1])<=t,r=e.filter(o=>!n(o));if(r.length===0)return[];for(let o=0;o<r.length;o++){let i=r[(o+r.length-1)%r.length].c,s=r[o];(i[6]!==s.c[0]||i[7]!==s.c[1])&&(Math.hypot(i[6]-s.c[0],i[7]-s.c[1])<=t?r[o]=Hg(s,[i[6],i[7]],[s.c[6],s.c[7]]):o===0&&r.push(Ue(i[6],i[7],s.c[0],s.c[1])))}return r}function dU(e,t,n,r){let o=(l,u)=>u<=1e-7?[l.c[0],l.c[1]]:u>=.9999999?[l.c[6],l.c[7]]:null,i=o(e,t)??o(n,r);if(i)return i;let s=Ve(...e.c,t),a=Ve(...n.c,r);return[(s[0]+a[0])/2,(s[1]+a[1])/2]}function fU(e,t){let n=t.filter(a=>a.t>1e-7&&a.t<.9999999).sort((a,l)=>a.t-l.t),r=[],o=e,i=0,s=[e.c[0],e.c[1]];for(let a of n){if(a.t-i<1e-9)continue;let[l,u]=gs(o,(a.t-i)/(1-i));r.push(Hg(l,s,a.p)),o=u,i=a.t,s=a.p}return r.push(Hg(o,s,[e.c[6],e.c[7]])),r}function Hg(e,t,n){let r=e.c;return{c:[t[0],t[1],r[2]+t[0]-r[0],r[3]+t[1]-r[1],r[4]+n[0]-r[6],r[5]+n[1]-r[7],n[0],n[1]],line:e.line}}function pU(e){let t=e.c;return{c:[t[6],t[7],t[4],t[5],t[2],t[3],t[0],t[1]],line:e.line}}function hU(e,t){let n=[],r=[];for(let{c:o,line:i}of e)r.length===0?r.push(o[0],o[1]):(r[r.length-2]!==o[0]||r[r.length-1]!==o[1])&&(n.push(r),r=[o[0],o[1]]),i?r.push(o[6],o[7]):lo(...o,t,r);return r.length>0&&n.push(r),n}function Ev(e,t,n){let r=0;for(let o of e)for(let i=0;i+3<o.length;i+=2){let s=o[i+1],a=o[i+3];if(s>n==a>n)continue;let l=o[i],u=o[i+2];t>=l+(n-s)/(a-s)*(u-l)||(r+=s<=n?1:-1)}return r}function mU(e,t,n){let r=e.c,[o,i]=Ve(...r,.5),s=r[6]+r[4]-r[2]-r[0],a=r[7]+r[5]-r[3]-r[1],l=Math.hypot(s,a);if(l<1e-12)return null;let u=a/l*n,c=-s/l*n,d=Ev(t,o+u,i+c)!==0,f=Ev(t,o-u,i-c)!==0;return d===f?null:d}function yU(e){let t=(i,s)=>`${i},${s}`,n=new Map;e.forEach((i,s)=>{let a=t(i.c[0],i.c[1]),l=n.get(a);l?l.push(s):n.set(a,[s])});let r=new Uint8Array(e.length),o=[];for(let i=0;i<e.length;i++){if(r[i])continue;let s=[],a=i;for(;a!==void 0&&!r[a];){r[a]=1;let l=e[a];s.push(l),a=n.get(t(l.c[6],l.c[7]))?.find(u=>!r[u])}o.push(s)}return o}function Mv(e,t){if(t.length===0)return;let[n,r]=t[0].c;e.moveTo(n,r);for(let[o,{c:i,line:s}]of t.entries()){if(s&&o===t.length-1&&i[6]===n&&i[7]===r)break;s?e.lineTo(i[6],i[7]):e.curveTo(i[2],i[3],i[4],i[5],i[6],i[7])}e.close()}var Cv=Q(()=>{"use strict";Pn();oi();mr();_d();Nv();Ng()});function Ss(e,t,n,r,o,i){return new Float64Array([e,t,0,n,r,0,o,i,1])}function gU(){return Ss(1,0,0,1,0,0)}function Ug(e,t){let n=e[0],r=e[1],o=e[3],i=e[4],s=e[6],a=e[7],l=t[0],u=t[1],c=t[3],d=t[4],f=t[6],p=t[7];return Ss(n*l+o*u,r*l+i*u,n*c+o*d,r*c+i*d,n*f+o*p+s,r*f+i*p+a)}function bU(e,t,n){let r=Ss(1,0,0,1,t,n);return Ug(e,r)}function xU(e,t,n){let r=Ss(t,0,0,n,0,0);return Ug(e,r)}function Ov(e){return[e[0],e[1],e[3],e[4],e[6],e[7]]}function Fv(e){return Ss(e[0],e[1],e[2],e[3],e[4],e[5])}function wU(e){let t=pr(Ov(e));return t&&Fv(t)}function PU(e){return Float32Array.from(e)}function TU(e,t,n){let r=e[0],o=e[1],i=e[3],s=e[4],a=e[6],l=e[7];return[r*t+i*n+a,o*t+s*n+l]}function SU(e,t){return Ss(2/e,0,0,-2/t,-1,1)}function kU(e){return Math.sqrt(Math.abs(e[0]*e[4]-e[1]*e[3]))}function vU(e){let t=e[0]*e[0]+e[1]*e[1]+e[3]*e[3]+e[4]*e[4],n=e[0]*e[4]-e[1]*e[3];return Math.sqrt(Math.max(0,(t-Math.sqrt(Math.max(0,t*t-4*n*n)))/2))}var q,Lv=Q(()=>{"use strict";cs();q={identity:gU,toAffine:Ov,fromAffine:Fv,multiply:Ug,translated:bU,scaled:xU,invert:wU,toUniform:PU,apply:TU,screenToClip:SU,meanScaleOf:kU,minScaleOf:vU}});function br(e){let t=e.scale.x,n=e.scale.y,r=-e.x*t+0,o=-e.y*n+0;return new Float64Array([t,0,0,0,n,0,r,o,1])}var _v=Q(()=>{"use strict"});function Wg(e){let t=e;return t.rotation&&t.x!=null&&t.y!=null&&t.width!=null&&t.height!=null?{cx:t.x+t.width/2,cy:t.y+t.height/2,rotation:t.rotation}:null}function Dv(e,t,n,r){return e.kind==="rect"?RU(e.x,e.y,e.width,e.height,t,n,r):AU(e,t,n,r)}function AU(e,t,n,r){let o=Math.cos(r),i=Math.sin(r);if(e.origin)return Rt(e,[o,i,-i,o,t-t*o+n*i,n-t*i-n*o]);let{commands:s,coords:a}=e,l=new Float32Array(a.length);return Ge(s,a,(u,c)=>{for(let d=0,f=oo(u);d<f;d+=2){let p=a[c+d]-t,h=a[c+d+1]-n;l[c+d]=t+p*o-h*i,l[c+d+1]=n+p*i+h*o}}),{...e,coords:l}}function RU(e,t,n,r,o,i,s){let a=Math.cos(s),l=Math.sin(s),u=(y,P)=>{let S=y-o,v=P-i;return[o+S*a-v*l,i+S*l+v*a]},[c,d]=u(e,t),[f,p]=u(e+n,t),[h,m]=u(e+n,t+r),[g,b]=u(e,t+r),x=new Uint8Array([le,ce,ce,ce,fe]),w=new Float32Array([c,d,f,p,h,m,g,b]);return{kind:"polygon",commands:x,coords:w,fillRule:"nonzero"}}var Bv=Q(()=>{"use strict";Je();Il()});function Vn(e){let t=e?.transform;return!Array.isArray(t)||t.length!==4||t[0]===1&&t[1]===0&&t[2]===0&&t[3]===1?null:t}function Ce(e){let t=e;if(!t||t.x==null||t.y==null||t.width==null||t.height==null)return null;let n=Vn(t);if(!t.rotation&&!n)return null;let r=t.x+t.width/2,o=t.y+t.height/2;if(!n)return ro(r,o,t.rotation);let[i,s,a,l]=n,u=[i,s,a,l,r-(i*r+a*o),o-(s*r+l*o)];return t.rotation?ht(ro(r,o,t.rotation),u):u}function ui(e){if(!Vn(e)){let n=Wg(e);return n&&ro(n.cx,n.cy,-n.rotation)}let t=Ce(e);return t&&pr(t)}function Cl(e,t){if(Vn(t)){let r=Ce(t);return r?Rt(e,r):e}let n=Wg(t);return n?Dv(e,n.cx,n.cy,n.rotation):e}var Hv=Q(()=>{"use strict";cs();Il();Bv()});function Ol(e,t){if(e.kind==="rect")return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height?e:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height};let n=et(e);if(n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height)return e;let r=hr(n.x,n.y,n.width,n.height,t.x,t.y,t.width,t.height);return Rt(e,r)}var Gv=Q(()=>{"use strict";cs();xg();Il()});function Uv(e){if(e===null||typeof e!="object")return;let{__ta:t,data:n}=e;if(!(typeof t!="string"||!Object.hasOwn(Fl,t)||!Array.isArray(n)))return Fl[t].from(n)}function Vg(e,t){let n=t(e);if(n!==void 0)return n;if(Array.isArray(e))return e.map(o=>Vg(o,t));if(!IU(e))return e;let r={};for(let o of Object.keys(e))r[o]=Vg(e[o],t);return r}function zg(e){return Vg(e,Uv)}var Fl,Yee,NU,IU,Wv=Q(()=>{"use strict";Fl={i8:Int8Array,u8:Uint8Array,u8c:Uint8ClampedArray,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array},Yee=new Map(Object.keys(Fl).map(e=>[Fl[e].name,e])),NU=e=>Object.prototype.toString.call(e).slice(8,-1);IU=e=>NU(e)==="Object"});var Z=Q(()=>{"use strict";ml();cs();bl();Je();oi();Nl();ii();mr();xg();tn();nn();wl();Vk();Il();$k();Ak();_d();Tv();Cv();Gk();zk();Lv();_v();Hv();Gv();Wv()});function Ht(e){return e!=null&&(e.kind===void 0||e.kind==="solid")}var sb=Q(()=>{"use strict"});function Ne(e,t=null){return e===rn?t:e?.paint==null?null:e}function Re(e,t=null){return e===rn?t:e?.paint==null?null:e}var rn,ab=Q(()=>{"use strict";rn="inherit"});function of(e){return Array.isArray(e)?`[${e.map(of).join(",")}]`:typeof e!="object"||e===null?JSON.stringify(e)??"null":`{${Object.keys(e).sort().filter(n=>e[n]!==void 0).map(n=>`${JSON.stringify(n)}:${of(e[n])}`).join(",")}}`}function fo(e){if(e==null)return"none";if(Ht(e))return`solid:${e.color}:${e.opacity??1}`;let t=DA.get(e);return t===void 0&&(t=of(e),DA.set(e,t)),t}function sf(e){return Ne(e)!==null}function xr(e){let t=Re(e);if(t===null)return!1;let n=t.width??1;return(typeof n=="number"?n:n.px)>0}function Vl(e){if(!xr(e))return"none";let t=BA.get(e);if(t===void 0){let{paint:n,width:r,join:o,cap:i,miterLimit:s,align:a,dash:l,...u}=e;t=of({...u,width:r??1,join:o??"miter",cap:i??"butt",miterLimit:s??4,align:a??"center",dash:l??[]}),BA.set(e,t)}return`${t}|${fo(e.paint)}`}var DA,BA,HA=Q(()=>{"use strict";sb();ab();DA=new WeakMap,BA=new WeakMap});function zl(e){return e!==void 0&&qU.has(e)}function lb(e){return zl(e.kind)}function ub(e){return e.kind==="image"}function af(e){return e.kind==="texture"||e.kind==="image"||zl(e.kind)}function lf(e){let{units:t,origin:n,transform:r,opacity:o}=e;return{...t!==void 0?{units:t}:{},...n!==void 0?{origin:n}:{},...r!==void 0?{transform:r}:{},...o!==void 0?{opacity:o}:{}}}function cb(e){let{units:t,origin:n,transform:r,opacity:o,...i}=e;return i}var GA,qU,UA=Q(()=>{"use strict";GA=["hatch","crosshatch","dots","chunks"],qU=new Set(GA)});function uf(e,t){let n=t/2;return typeof e=="number"?db(e)?{left:e/2,right:e/2}:{left:n,right:n}:e==null||typeof e!="object"?{left:n,right:n}:{left:db(e.left)?e.left:n,right:db(e.right)?e.right:n}}function Kl(e,t){return typeof e=="number"?e*t:{left:e.left*t,right:e.right*t}}function fb(e,t){let n=e/2;if(t)for(let r of t){let{left:o,right:i}=uf(r,e);n=Math.max(n,o,i)}return n}var db,WA=Q(()=>{"use strict";db=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0});function Gt(e,t){return typeof e=="number"?e:!Number.isFinite(t)||t===0?e.px:e.px/t}function pb(e,t,n=1){if(t==="center")return e;let o=(t==="inner"?-1:1)*n/2;return{x:e.x-o,y:e.y-o,width:e.width+2*o,height:e.height+2*o}}function cf(e,t){if(e===void 0||e.length===0)return"solid";if(!e.every(Number.isFinite))return"non-finite";if(e.some(n=>n<0)||!e.some(n=>n>0))return"solid";if(t!==void 0){let n=e.reduce((r,o)=>r+o,0);if(t/n*e.length>VA)return"solid"}return e}var VA,zA=Q(()=>{"use strict";VA=1e5});function KA(e){if(!XU.test(e))return null;let t=e.slice(1),n=t.length<=4?t.replace(/./g,"$&$&"):t,r=o=>Number.parseInt(n.slice(o,o+2),16);return[r(0),r(2),r(4),n.length===8?r(6):255]}var XU,jA=Q(()=>{"use strict";XU=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i});function $A(e){let t=e%hb;return t>Math.PI?t-hb:t<-Math.PI?t+hb:t}var hb,YA=Q(()=>{"use strict";hb=Math.PI*2});function yb(e){if(e<=0)return 0;if(e>=1)return 255;let t=e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055;return Math.round(t*255)}function df(e,t,n){return JU(mb[e&255],mb[t&255],mb[n&255])}function JU(e,t,n){let r=.4122214708*e+.5363325363*t+.0514459929*n,o=.2119034982*e+.6806995451*t+.1073969566*n,i=.0883024619*e+.2817188376*t+.6299787005*n,s=Math.cbrt(r),a=Math.cbrt(o),l=Math.cbrt(i);return[.2104542553*s+.793617785*a-.0040720468*l,1.9779984951*s-2.428592205*a+.4505937099*l,.0259040371*s+.7827717662*a-.808675766*l]}function jl(e,t,n){let r=e+.3963377774*t+.2158037573*n,o=e-.1055613458*t-.0638541728*n,i=e-.0894841775*t-1.291485548*n,s=r*r*r,a=o*o*o,l=i*i*i;return[4.0767416621*s-3.3077115913*a+.2309699292*l,-1.2684380046*s+2.6097574011*a-.3413193965*l,-.0041960863*s-.7034186147*a+1.707614701*l]}function qA(e,t,n){return e>=-1e-6&&e<=1+1e-6&&t>=-1e-6&&t<=1+1e-6&&n>=-1e-6&&n<=1+1e-6}function QU(e,t,n){let[r,o,i]=jl(e,t,n);if(qA(r,o,i))return[r,o,i];let s=0,a=1;for(let l=0;l<5;l++){let u=(s+a)/2;[r,o,i]=jl(e,t*u,n*u),qA(r,o,i)?s=u:a=u}return[r,o,i]=jl(e,t*s,n*s),[r,o,i]}function XA(e,t,n){let[r,o,i]=QU(e,t,n);return[yb(r),yb(o),yb(i)]}function ZU(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function JA(e,t,n){let r=Math.hypot(t,n),o=Math.atan2(n,t);return[e,r,o]}function bb(e,t,n){return[e,t*Math.cos(n),t*Math.sin(n)]}function eW(e,t,n){let[r,o,i]=e,[s,a,l]=t,u=1e-4,c=o<u?l:i,d=a<u?i:l,f=$A(d-c);return[r+(s-r)*n,o+(a-o)*n,c+f*n]}function QA(e,t,n,r="rgb"){if(e.length!==t.length)throw new Error(`lerpColorArray: length mismatch (from=${e.length}, to=${t.length})`);if(e.length%4!==0)throw new Error(`lerpColorArray: length ${e.length} not divisible by 4`);let o=new Array(e.length),i=e.length/4;if(r==="rgb"){for(let s=0;s<e.length;s++)o[s]=e[s]+(t[s]-e[s])*n;return o}if(r==="oklch"){for(let s=0;s<i;s++){let a=s*4,l=df(on(e[a]),on(e[a+1]),on(e[a+2])),u=df(on(t[a]),on(t[a+1]),on(t[a+2])),c=JA(l[0],l[1],l[2]),d=JA(u[0],u[1],u[2]),f=eW(c,d,n),p=bb(f[0],f[1],f[2]),[h,m,g]=XA(p[0],p[1],p[2]);o[a]=Cs(h),o[a+1]=Cs(m),o[a+2]=Cs(g),o[a+3]=e[a+3]+(t[a+3]-e[a+3])*n}return o}for(let s=0;s<i;s++){let a=s*4,l=df(on(e[a]),on(e[a+1]),on(e[a+2])),u=df(on(t[a]),on(t[a+1]),on(t[a+2])),c=ZU(l,u,n),[d,f,p]=XA(c[0],c[1],c[2]);o[a]=Cs(d),o[a+1]=Cs(f),o[a+2]=Cs(p),o[a+3]=e[a+3]+(t[a+3]-e[a+3])*n}return o}function xb(e){let t=Math.abs(e),n=t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055;return e<0?-n:n}function ZA(e,t,n){if(t===0)return[n,n,n];let r=n<.5?n*(1+t):n+t-n*t,o=2*n-r,i=e/360;return[gb(o,r,i+1/3),gb(o,r,i),gb(o,r,i-1/3)]}function gb(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var mb,on,Cs,wb=Q(()=>{"use strict";YA();mb=(()=>{let e=new Float64Array(256);for(let t=0;t<256;t++){let n=t/255;e[t]=n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}return e})();on=e=>Math.max(0,Math.min(255,Math.round(e*255)));Cs=e=>e/255});function eR(e){let t=ff.get(e);if(t!==void 0)return t;let n=nW(e);return ff.size>=tW&&ff.clear(),ff.set(e,n),n}function nW(e){let t=e.trim();if(t.startsWith("#"))return oW(t);let n=t.toLowerCase(),r=uW[n];if(r!==void 0)return r;if(n.startsWith("rgb")){let o=iW(n);if(o)return o}if(n.startsWith("hsl")){let o=sW(n);if(o)return o}if(n.startsWith("color(")){let o=aW(n);if(o)return o}if(n.startsWith("ok")){let o=lW(n);if(o)return o}throw new Error(`parseColor: unrecognized color "${e}"`)}function jn(e){let t=pf.get(e);if(t)return t;pf.size>=rW&&pf.clear();let r=eR(e);return pf.set(e,r),r}function oW(e){let t=KA(e);if(!t)throw new Error(`parseColor: invalid hex "${e}"`);return[t[0]/255,t[1]/255,t[2]/255,t[3]/255]}function hi(e,t){return!e.startsWith(t+"(")||!e.endsWith(")")?null:e.slice(t.length+1,-1).trim()}function mf(e){if(e.includes(",")){let i=e.split(",").map(s=>s.trim());return i.length!==3&&i.length!==4?null:{rgb:[i[0],i[1],i[2]],alpha:i.length===4?i[3]:null}}let t=e.indexOf("/"),n=(t===-1?e:e.slice(0,t)).trim(),r=t===-1?null:e.slice(t+1).trim(),o=n.split(/\s+/);return o.length!==3||r!==null&&r===""?null:{rgb:[o[0],o[1],o[2]],alpha:r}}function hf(e,t){if(e.endsWith("%")){let r=Number(e.slice(0,-1));return Number.isFinite(r)?Kn(r/100):null}let n=Number(e);return Number.isFinite(n)?Kn(n/t):null}function yf(e){if(e===null)return 1;if(e.endsWith("%")){let n=Number(e.slice(0,-1));return Number.isFinite(n)?Kn(n/100):1}let t=Number(e);return Number.isFinite(t)?Kn(t):1}function iW(e){let t=hi(e,"rgba")??hi(e,"rgb");if(t===null)return null;let n=mf(t);if(!n)return null;let r=hf(n.rgb[0],255),o=hf(n.rgb[1],255),i=hf(n.rgb[2],255);return r===null||o===null||i===null?null:[r,o,i,yf(n.alpha)]}function sW(e){let t=hi(e,"hsla")??hi(e,"hsl");if(t===null)return null;let n=mf(t);if(!n)return null;let r=tR(n.rgb[0]),o=Pb(n.rgb[1]),i=Pb(n.rgb[2]);if(r===null||o===null||i===null)return null;let[s,a,l]=ZA(r,o,i);return[s,a,l,yf(n.alpha)]}function aW(e){let t=hi(e,"color"),n=t?.match(/^(srgb-linear|srgb)\s+/);if(!t||!n||t.includes(","))return null;let r=mf(t.slice(n[0].length));if(!r)return null;let o=r.rgb.map(l=>hf(l,1));if(o.some(l=>l===null))return null;let[i,s,a]=n[1]==="srgb"?o:o.map(l=>xb(l));return[Kn(i),Kn(s),Kn(a),yf(r.alpha)]}function lW(e){let t=hi(e,"oklch"),n=t??hi(e,"oklab");if(n===null||n.includes(","))return null;let r=mf(n);if(!r)return null;let o=Pb(r.rgb[0]),i=Number(r.rgb[1]);if(o===null||!Number.isFinite(i))return null;let s=i,a=Number(r.rgb[2]);if(t!==null){let d=tR(r.rgb[2]);if(d===null)return null;[,s,a]=bb(o,i,d*(Math.PI/180))}else if(!Number.isFinite(a))return null;let[l,u,c]=jl(o,s,a).map(d=>Kn(xb(d)));return[l,u,c,yf(r.alpha)]}function tR(e){let t;return e.endsWith("deg")?t=Number(e.slice(0,-3)):e.endsWith("grad")?t=Number(e.slice(0,-4))*.9:e.endsWith("rad")?t=Number(e.slice(0,-3))*(180/Math.PI):e.endsWith("turn")?t=Number(e.slice(0,-4))*360:t=Number(e),Number.isFinite(t)?(t%360+360)%360:null}function Pb(e){if(e.endsWith("%")){let n=Number(e.slice(0,-1));return Number.isFinite(n)?Kn(n/100):null}let t=Number(e);return Number.isFinite(t)?Kn(t):null}function Kn(e){return e<0?0:e>1?1:e}var ff,tW,rW,pf,uW,Tb=Q(()=>{"use strict";wb();jA();ff=new Map,tW=1024;rW=1024,pf=new Map;uW=(()=>{let e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},t={transparent:[0,0,0,0]};for(let n in e){let r=e[n];t[n]=[(r>>16&255)/255,(r>>8&255)/255,(r&255)/255,1]}return t})()});function Sb(e){return[...e].sort((t,n)=>t.offset-n.offset).map(t=>({offset:t.offset,rgba:jn(t.color)}))}function kb(e,t,n="rgb"){if(e.length===0)return dW;let r=e[0],o=e[e.length-1];if(t<=r.offset)return r.rgba;if(t>=o.offset)return o.rgba;for(let i=0;i<e.length-1;i++){let s=e[i],a=e[i+1];if(t<s.offset||t>a.offset)continue;let l=a.offset-s.offset;if(l<=0)return a.rgba;let u=(t-s.offset)/l,[c,d,f,p]=QA(s.rgba,a.rgba,u,n);return[c,d,f,p]}return o.rgba}var dW,nR=Q(()=>{"use strict";Tb();wb();dW=[0,0,0,0]});var Pe=Q(()=>{"use strict";sb();HA();ab();UA();WA();zA();Tb();nR()});var AN=iG((fx,px)=>{"use strict";(function(e,t){typeof fx=="object"&&typeof px<"u"?px.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.polygonClipping=t())})(fx,(function(){"use strict";function e(O,T){var k={label:0,sent:function(){if(I[0]&1)throw I[1];return I[1]},trys:[],ops:[]},R,E,I,H;return H={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function _(U){return function(X){return V([U,X])}}function V(U){if(R)throw new TypeError("Generator is already executing.");for(;k;)try{if(R=1,E&&(I=U[0]&2?E.return:U[0]?E.throw||((I=E.return)&&I.call(E),0):E.next)&&!(I=I.call(E,U[1])).done)return I;switch(E=0,I&&(U=[U[0]&2,I.value]),U[0]){case 0:case 1:I=U;break;case 4:return k.label++,{value:U[1],done:!1};case 5:k.label++,E=U[1],U=[0];continue;case 7:U=k.ops.pop(),k.trys.pop();continue;default:if(I=k.trys,!(I=I.length>0&&I[I.length-1])&&(U[0]===6||U[0]===2)){k=0;continue}if(U[0]===3&&(!I||U[1]>I[0]&&U[1]<I[3])){k.label=U[1];break}if(U[0]===6&&k.label<I[1]){k.label=I[1],I=U;break}if(I&&k.label<I[2]){k.label=I[2],k.ops.push(U);break}I[2]&&k.ops.pop(),k.trys.pop();continue}U=T.call(O,k)}catch(X){U=[6,X],E=0}finally{R=I=0}if(U[0]&5)throw U[1];return{value:U[0]?U[1]:void 0,done:!0}}}var t=(function(){function O(T,k){this.next=null,this.key=T,this.data=k,this.left=null,this.right=null}return O})();function n(O,T){return O>T?1:O<T?-1:0}function r(O,T,k){for(var R=new t(null,null),E=R,I=R;;){var H=k(O,T.key);if(H<0){if(T.left===null)break;if(k(O,T.left.key)<0){var _=T.left;if(T.left=_.right,_.right=T,T=_,T.left===null)break}I.left=T,I=T,T=T.left}else if(H>0){if(T.right===null)break;if(k(O,T.right.key)>0){var _=T.right;if(T.right=_.left,_.left=T,T=_,T.right===null)break}E.right=T,E=T,T=T.right}else break}return E.right=T.left,I.left=T.right,T.left=R.right,T.right=R.left,T}function o(O,T,k,R){var E=new t(O,T);if(k===null)return E.left=E.right=null,E;k=r(O,k,R);var I=R(O,k.key);return I<0?(E.left=k.left,E.right=k,k.left=null):I>=0&&(E.right=k.right,E.left=k,k.right=null),E}function i(O,T,k){var R=null,E=null;if(T){T=r(O,T,k);var I=k(T.key,O);I===0?(R=T.left,E=T.right):I<0?(E=T.right,T.right=null,R=T):(R=T.left,T.left=null,E=T)}return{left:R,right:E}}function s(O,T,k){return T===null?O:(O===null||(T=r(O.key,T,k),T.left=O),T)}function a(O,T,k,R,E){if(O){R(""+T+(k?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+E(O)+`
3
+ `);var I=T+(k?" ":"\u2502 ");O.left&&a(O.left,I,!1,R,E),O.right&&a(O.right,I,!0,R,E)}}var l=(function(){function O(T){T===void 0&&(T=n),this._root=null,this._size=0,this._comparator=T}return O.prototype.insert=function(T,k){return this._size++,this._root=o(T,k,this._root,this._comparator)},O.prototype.add=function(T,k){var R=new t(T,k);this._root===null&&(R.left=R.right=null,this._size++,this._root=R);var E=this._comparator,I=r(T,this._root,E),H=E(T,I.key);return H===0?this._root=I:(H<0?(R.left=I.left,R.right=I,I.left=null):H>0&&(R.right=I.right,R.left=I,I.right=null),this._size++,this._root=R),this._root},O.prototype.remove=function(T){this._root=this._remove(T,this._root,this._comparator)},O.prototype._remove=function(T,k,R){var E;if(k===null)return null;k=r(T,k,R);var I=R(T,k.key);return I===0?(k.left===null?E=k.right:(E=r(T,k.left,R),E.right=k.right),this._size--,E):k},O.prototype.pop=function(){var T=this._root;if(T){for(;T.left;)T=T.left;return this._root=r(T.key,this._root,this._comparator),this._root=this._remove(T.key,this._root,this._comparator),{key:T.key,data:T.data}}return null},O.prototype.findStatic=function(T){for(var k=this._root,R=this._comparator;k;){var E=R(T,k.key);if(E===0)return k;E<0?k=k.left:k=k.right}return null},O.prototype.find=function(T){return this._root&&(this._root=r(T,this._root,this._comparator),this._comparator(T,this._root.key)!==0)?null:this._root},O.prototype.contains=function(T){for(var k=this._root,R=this._comparator;k;){var E=R(T,k.key);if(E===0)return!0;E<0?k=k.left:k=k.right}return!1},O.prototype.forEach=function(T,k){for(var R=this._root,E=[],I=!1;!I;)R!==null?(E.push(R),R=R.left):E.length!==0?(R=E.pop(),T.call(k,R),R=R.right):I=!0;return this},O.prototype.range=function(T,k,R,E){for(var I=[],H=this._comparator,_=this._root,V;I.length!==0||_;)if(_)I.push(_),_=_.left;else{if(_=I.pop(),V=H(_.key,k),V>0)break;if(H(_.key,T)>=0&&R.call(E,_))return this;_=_.right}return this},O.prototype.keys=function(){var T=[];return this.forEach(function(k){var R=k.key;return T.push(R)}),T},O.prototype.values=function(){var T=[];return this.forEach(function(k){var R=k.data;return T.push(R)}),T},O.prototype.min=function(){return this._root?this.minNode(this._root).key:null},O.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},O.prototype.minNode=function(T){if(T===void 0&&(T=this._root),T)for(;T.left;)T=T.left;return T},O.prototype.maxNode=function(T){if(T===void 0&&(T=this._root),T)for(;T.right;)T=T.right;return T},O.prototype.at=function(T){for(var k=this._root,R=!1,E=0,I=[];!R;)if(k)I.push(k),k=k.left;else if(I.length>0){if(k=I.pop(),E===T)return k;E++,k=k.right}else R=!0;return null},O.prototype.next=function(T){var k=this._root,R=null;if(T.right){for(R=T.right;R.left;)R=R.left;return R}for(var E=this._comparator;k;){var I=E(T.key,k.key);if(I===0)break;I<0?(R=k,k=k.left):k=k.right}return R},O.prototype.prev=function(T){var k=this._root,R=null;if(T.left!==null){for(R=T.left;R.right;)R=R.right;return R}for(var E=this._comparator;k;){var I=E(T.key,k.key);if(I===0)break;I<0?k=k.left:(R=k,k=k.right)}return R},O.prototype.clear=function(){return this._root=null,this._size=0,this},O.prototype.toList=function(){return d(this._root)},O.prototype.load=function(T,k,R){k===void 0&&(k=[]),R===void 0&&(R=!1);var E=T.length,I=this._comparator;if(R&&h(T,k,0,E-1,I),this._root===null)this._root=u(T,k,0,E),this._size=E;else{var H=p(this.toList(),c(T,k),I);E=this._size+E,this._root=f({head:H},0,E)}return this},O.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(O.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),O.prototype.toString=function(T){T===void 0&&(T=function(R){return String(R.key)});var k=[];return a(this._root,"",!0,function(R){return k.push(R)},T),k.join("")},O.prototype.update=function(T,k,R){var E=this._comparator,I=i(T,this._root,E),H=I.left,_=I.right;E(T,k)<0?_=o(k,R,_,E):H=o(k,R,H,E),this._root=s(H,_,E)},O.prototype.split=function(T){return i(T,this._root,this._comparator)},O.prototype[Symbol.iterator]=function(){var T,k,R;return e(this,function(E){switch(E.label){case 0:T=this._root,k=[],R=!1,E.label=1;case 1:return R?[3,6]:T===null?[3,2]:(k.push(T),T=T.left,[3,5]);case 2:return k.length===0?[3,4]:(T=k.pop(),[4,T]);case 3:return E.sent(),T=T.right,[3,5];case 4:R=!0,E.label=5;case 5:return[3,1];case 6:return[2]}})},O})();function u(O,T,k,R){var E=R-k;if(E>0){var I=k+Math.floor(E/2),H=O[I],_=T[I],V=new t(H,_);return V.left=u(O,T,k,I),V.right=u(O,T,I+1,R),V}return null}function c(O,T){for(var k=new t(null,null),R=k,E=0;E<O.length;E++)R=R.next=new t(O[E],T[E]);return R.next=null,k.next}function d(O){for(var T=O,k=[],R=!1,E=new t(null,null),I=E;!R;)T?(k.push(T),T=T.left):k.length>0?(T=I=I.next=k.pop(),T=T.right):R=!0;return I.next=null,E.next}function f(O,T,k){var R=k-T;if(R>0){var E=T+Math.floor(R/2),I=f(O,T,E),H=O.head;return H.left=I,O.head=O.head.next,H.right=f(O,E+1,k),H}return null}function p(O,T,k){for(var R=new t(null,null),E=R,I=O,H=T;I!==null&&H!==null;)k(I.key,H.key)<0?(E.next=I,I=I.next):(E.next=H,H=H.next),E=E.next;return I!==null?E.next=I:H!==null&&(E.next=H),R.next}function h(O,T,k,R,E){if(!(k>=R)){for(var I=O[k+R>>1],H=k-1,_=R+1;;){do H++;while(E(O[H],I)<0);do _--;while(E(O[_],I)>0);if(H>=_)break;var V=O[H];O[H]=O[_],O[_]=V,V=T[H],T[H]=T[_],T[_]=V}h(O,T,k,_,E),h(O,T,_+1,R,E)}}let m=(O,T)=>O.ll.x<=T.x&&T.x<=O.ur.x&&O.ll.y<=T.y&&T.y<=O.ur.y,g=(O,T)=>{if(T.ur.x<O.ll.x||O.ur.x<T.ll.x||T.ur.y<O.ll.y||O.ur.y<T.ll.y)return null;let k=O.ll.x<T.ll.x?T.ll.x:O.ll.x,R=O.ur.x<T.ur.x?O.ur.x:T.ur.x,E=O.ll.y<T.ll.y?T.ll.y:O.ll.y,I=O.ur.y<T.ur.y?O.ur.y:T.ur.y;return{ll:{x:k,y:E},ur:{x:R,y:I}}},b=Number.EPSILON;b===void 0&&(b=Math.pow(2,-52));let x=b*b,w=(O,T)=>{if(-b<O&&O<b&&-b<T&&T<b)return 0;let k=O-T;return k*k<x*O*T?0:O<T?-1:1};class y{constructor(){this.reset()}reset(){this.xRounder=new P,this.yRounder=new P}round(T,k){return{x:this.xRounder.round(T),y:this.yRounder.round(k)}}}class P{constructor(){this.tree=new l,this.round(0)}round(T){let k=this.tree.add(T),R=this.tree.prev(k);if(R!==null&&w(k.key,R.key)===0)return this.tree.remove(T),R.key;let E=this.tree.next(k);return E!==null&&w(k.key,E.key)===0?(this.tree.remove(T),E.key):T}}let S=new y,v=11102230246251565e-32,A=134217729,N=(3+8*v)*v;function M(O,T,k,R,E){let I,H,_,V,U=T[0],X=R[0],L=0,z=0;X>U==X>-U?(I=U,U=T[++L]):(I=X,X=R[++z]);let Y=0;if(L<O&&z<k)for(X>U==X>-U?(H=U+I,_=I-(H-U),U=T[++L]):(H=X+I,_=I-(H-X),X=R[++z]),I=H,_!==0&&(E[Y++]=_);L<O&&z<k;)X>U==X>-U?(H=I+U,V=H-I,_=I-(H-V)+(U-V),U=T[++L]):(H=I+X,V=H-I,_=I-(H-V)+(X-V),X=R[++z]),I=H,_!==0&&(E[Y++]=_);for(;L<O;)H=I+U,V=H-I,_=I-(H-V)+(U-V),U=T[++L],I=H,_!==0&&(E[Y++]=_);for(;z<k;)H=I+X,V=H-I,_=I-(H-V)+(X-V),X=R[++z],I=H,_!==0&&(E[Y++]=_);return(I!==0||Y===0)&&(E[Y++]=I),Y}function C(O,T){let k=T[0];for(let R=1;R<O;R++)k+=T[R];return k}function F(O){return new Float64Array(O)}let B=(3+16*v)*v,D=(2+12*v)*v,j=(9+64*v)*v*v,W=F(4),J=F(8),se=F(12),ke=F(16),ae=F(4);function ve(O,T,k,R,E,I,H){let _,V,U,X,L,z,Y,ie,re,ge,de,Ee,ct,je,dt,ft,Jt,pt,hn=O-E,mn=k-E,yn=T-I,gn=R-I;je=hn*gn,z=A*hn,Y=z-(z-hn),ie=hn-Y,z=A*gn,re=z-(z-gn),ge=gn-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=yn*mn,z=A*yn,Y=z-(z-yn),ie=yn-Y,z=A*mn,re=z-(z-mn),ge=mn-re,Jt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Jt,L=dt-de,W[0]=dt-(de+L)+(L-Jt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,W[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,W[2]=Ee-(pt-L)+(de-L),W[3]=pt;let cr=C(4,W),el=D*H;if(cr>=el||-cr>=el||(L=O-hn,_=O-(hn+L)+(L-E),L=k-mn,U=k-(mn+L)+(L-E),L=T-yn,V=T-(yn+L)+(L-I),L=R-gn,X=R-(gn+L)+(L-I),_===0&&V===0&&U===0&&X===0)||(el=j*H+N*Math.abs(cr),cr+=hn*X+gn*_-(yn*U+mn*V),cr>=el||-cr>=el))return cr;je=_*gn,z=A*_,Y=z-(z-_),ie=_-Y,z=A*gn,re=z-(z-gn),ge=gn-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=V*mn,z=A*V,Y=z-(z-V),ie=V-Y,z=A*mn,re=z-(z-mn),ge=mn-re,Jt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Jt,L=dt-de,ae[0]=dt-(de+L)+(L-Jt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,ae[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,ae[2]=Ee-(pt-L)+(de-L),ae[3]=pt;let JH=M(4,W,4,ae,J);je=hn*X,z=A*hn,Y=z-(z-hn),ie=hn-Y,z=A*X,re=z-(z-X),ge=X-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=yn*U,z=A*yn,Y=z-(z-yn),ie=yn-Y,z=A*U,re=z-(z-U),ge=U-re,Jt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Jt,L=dt-de,ae[0]=dt-(de+L)+(L-Jt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,ae[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,ae[2]=Ee-(pt-L)+(de-L),ae[3]=pt;let QH=M(JH,J,4,ae,se);je=_*X,z=A*_,Y=z-(z-_),ie=_-Y,z=A*X,re=z-(z-X),ge=X-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=V*U,z=A*V,Y=z-(z-V),ie=V-Y,z=A*U,re=z-(z-U),ge=U-re,Jt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Jt,L=dt-de,ae[0]=dt-(de+L)+(L-Jt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,ae[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,ae[2]=Ee-(pt-L)+(de-L),ae[3]=pt;let ZH=M(QH,se,4,ae,ke);return ke[ZH-1]}function G(O,T,k,R,E,I){let H=(T-I)*(k-E),_=(O-E)*(R-I),V=H-_,U=Math.abs(H+_);return Math.abs(V)>=B*U?V:-ve(O,T,k,R,E,I,U)}let K=(O,T)=>O.x*T.y-O.y*T.x,$=(O,T)=>O.x*T.x+O.y*T.y,ee=(O,T,k)=>{let R=G(O.x,O.y,T.x,T.y,k.x,k.y);return R>0?-1:R<0?1:0},te=O=>Math.sqrt($(O,O)),he=(O,T,k)=>{let R={x:T.x-O.x,y:T.y-O.y},E={x:k.x-O.x,y:k.y-O.y};return K(E,R)/te(E)/te(R)},be=(O,T,k)=>{let R={x:T.x-O.x,y:T.y-O.y},E={x:k.x-O.x,y:k.y-O.y};return $(E,R)/te(E)/te(R)},Fe=(O,T,k)=>T.y===0?null:{x:O.x+T.x/T.y*(k-O.y),y:k},Se=(O,T,k)=>T.x===0?null:{x:k,y:O.y+T.y/T.x*(k-O.x)},ur=(O,T,k,R)=>{if(T.x===0)return Se(k,R,O.x);if(R.x===0)return Se(O,T,k.x);if(T.y===0)return Fe(k,R,O.y);if(R.y===0)return Fe(O,T,k.y);let E=K(T,R);if(E==0)return null;let I={x:k.x-O.x,y:k.y-O.y},H=K(I,T)/E,_=K(I,R)/E,V=O.x+_*T.x,U=k.x+H*R.x,X=O.y+_*T.y,L=k.y+H*R.y,z=(V+U)/2,Y=(X+L)/2;return{x:z,y:Y}};class Le{static compare(T,k){let R=Le.comparePoints(T.point,k.point);return R!==0?R:(T.point!==k.point&&T.link(k),T.isLeft!==k.isLeft?T.isLeft?1:-1:Xt.compare(T.segment,k.segment))}static comparePoints(T,k){return T.x<k.x?-1:T.x>k.x?1:T.y<k.y?-1:T.y>k.y?1:0}constructor(T,k){T.events===void 0?T.events=[this]:T.events.push(this),this.point=T,this.isLeft=k}link(T){if(T.point===this.point)throw new Error("Tried to link already linked events");let k=T.point.events;for(let R=0,E=k.length;R<E;R++){let I=k[R];this.point.events.push(I),I.point=this.point}this.checkForConsuming()}checkForConsuming(){let T=this.point.events.length;for(let k=0;k<T;k++){let R=this.point.events[k];if(R.segment.consumedBy===void 0)for(let E=k+1;E<T;E++){let I=this.point.events[E];I.consumedBy===void 0&&R.otherSE.point.events===I.otherSE.point.events&&R.segment.consume(I.segment)}}}getAvailableLinkedEvents(){let T=[];for(let k=0,R=this.point.events.length;k<R;k++){let E=this.point.events[k];E!==this&&!E.segment.ringOut&&E.segment.isInResult()&&T.push(E)}return T}getLeftmostComparator(T){let k=new Map,R=E=>{let I=E.otherSE;k.set(E,{sine:he(this.point,T.point,I.point),cosine:be(this.point,T.point,I.point)})};return(E,I)=>{k.has(E)||R(E),k.has(I)||R(I);let{sine:H,cosine:_}=k.get(E),{sine:V,cosine:U}=k.get(I);return H>=0&&V>=0?_<U?1:_>U?-1:0:H<0&&V<0?_<U?-1:_>U?1:0:V<H?-1:V>H?1:0}}}let vt=0;class Xt{static compare(T,k){let R=T.leftSE.point.x,E=k.leftSE.point.x,I=T.rightSE.point.x,H=k.rightSE.point.x;if(H<R)return 1;if(I<E)return-1;let _=T.leftSE.point.y,V=k.leftSE.point.y,U=T.rightSE.point.y,X=k.rightSE.point.y;if(R<E){if(V<_&&V<U)return 1;if(V>_&&V>U)return-1;let L=T.comparePoint(k.leftSE.point);if(L<0)return 1;if(L>0)return-1;let z=k.comparePoint(T.rightSE.point);return z!==0?z:-1}if(R>E){if(_<V&&_<X)return-1;if(_>V&&_>X)return 1;let L=k.comparePoint(T.leftSE.point);if(L!==0)return L;let z=T.comparePoint(k.rightSE.point);return z<0?1:z>0?-1:1}if(_<V)return-1;if(_>V)return 1;if(I<H){let L=k.comparePoint(T.rightSE.point);if(L!==0)return L}if(I>H){let L=T.comparePoint(k.rightSE.point);if(L<0)return 1;if(L>0)return-1}if(I!==H){let L=U-_,z=I-R,Y=X-V,ie=H-E;if(L>z&&Y<ie)return 1;if(L<z&&Y>ie)return-1}return I>H?1:I<H||U<X?-1:U>X?1:T.id<k.id?-1:T.id>k.id?1:0}constructor(T,k,R,E){this.id=++vt,this.leftSE=T,T.segment=this,T.otherSE=k,this.rightSE=k,k.segment=this,k.otherSE=T,this.rings=R,this.windings=E}static fromRing(T,k,R){let E,I,H,_=Le.comparePoints(T,k);if(_<0)E=T,I=k,H=1;else if(_>0)E=k,I=T,H=-1;else throw new Error(`Tried to create degenerate segment at [${T.x}, ${T.y}]`);let V=new Le(E,!0),U=new Le(I,!1);return new Xt(V,U,[R],[H])}replaceRightSE(T){this.rightSE=T,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let T=this.leftSE.point.y,k=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:T<k?T:k},ur:{x:this.rightSE.point.x,y:T>k?T:k}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(T){return T.x===this.leftSE.point.x&&T.y===this.leftSE.point.y||T.x===this.rightSE.point.x&&T.y===this.rightSE.point.y}comparePoint(T){if(this.isAnEndpoint(T))return 0;let k=this.leftSE.point,R=this.rightSE.point,E=this.vector();if(k.x===R.x)return T.x===k.x?0:T.x<k.x?1:-1;let I=(T.y-k.y)/E.y,H=k.x+I*E.x;if(T.x===H)return 0;let _=(T.x-k.x)/E.x,V=k.y+_*E.y;return T.y===V?0:T.y<V?-1:1}getIntersection(T){let k=this.bbox(),R=T.bbox(),E=g(k,R);if(E===null)return null;let I=this.leftSE.point,H=this.rightSE.point,_=T.leftSE.point,V=T.rightSE.point,U=m(k,_)&&this.comparePoint(_)===0,X=m(R,I)&&T.comparePoint(I)===0,L=m(k,V)&&this.comparePoint(V)===0,z=m(R,H)&&T.comparePoint(H)===0;if(X&&U)return z&&!L?H:!z&&L?V:null;if(X)return L&&I.x===V.x&&I.y===V.y?null:I;if(U)return z&&H.x===_.x&&H.y===_.y?null:_;if(z&&L)return null;if(z)return H;if(L)return V;let Y=ur(I,this.vector(),_,T.vector());return Y===null||!m(E,Y)?null:S.round(Y.x,Y.y)}split(T){let k=[],R=T.events!==void 0,E=new Le(T,!0),I=new Le(T,!1),H=this.rightSE;this.replaceRightSE(I),k.push(I),k.push(E);let _=new Xt(E,H,this.rings.slice(),this.windings.slice());return Le.comparePoints(_.leftSE.point,_.rightSE.point)>0&&_.swapEvents(),Le.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),R&&(E.checkForConsuming(),I.checkForConsuming()),k}swapEvents(){let T=this.rightSE;this.rightSE=this.leftSE,this.leftSE=T,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let k=0,R=this.windings.length;k<R;k++)this.windings[k]*=-1}consume(T){let k=this,R=T;for(;k.consumedBy;)k=k.consumedBy;for(;R.consumedBy;)R=R.consumedBy;let E=Xt.compare(k,R);if(E!==0){if(E>0){let I=k;k=R,R=I}if(k.prev===R){let I=k;k=R,R=I}for(let I=0,H=R.rings.length;I<H;I++){let _=R.rings[I],V=R.windings[I],U=k.rings.indexOf(_);U===-1?(k.rings.push(_),k.windings.push(V)):k.windings[U]+=V}R.rings=null,R.windings=null,R.consumedBy=k,R.leftSE.consumedBy=k.leftSE,R.rightSE.consumedBy=k.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{let T=this.prev.consumedBy||this.prev;this._beforeState=T.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;let T=this.beforeState();this._afterState={rings:T.rings.slice(0),windings:T.windings.slice(0),multiPolys:[]};let k=this._afterState.rings,R=this._afterState.windings,E=this._afterState.multiPolys;for(let _=0,V=this.rings.length;_<V;_++){let U=this.rings[_],X=this.windings[_],L=k.indexOf(U);L===-1?(k.push(U),R.push(X)):R[L]+=X}let I=[],H=[];for(let _=0,V=k.length;_<V;_++){if(R[_]===0)continue;let U=k[_],X=U.poly;if(H.indexOf(X)===-1)if(U.isExterior)I.push(X);else{H.indexOf(X)===-1&&H.push(X);let L=I.indexOf(U.poly);L!==-1&&I.splice(L,1)}}for(let _=0,V=I.length;_<V;_++){let U=I[_].multiPoly;E.indexOf(U)===-1&&E.push(U)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;let T=this.beforeState().multiPolys,k=this.afterState().multiPolys;switch(pn.type){case"union":{let R=T.length===0,E=k.length===0;this._isInResult=R!==E;break}case"intersection":{let R,E;T.length<k.length?(R=T.length,E=k.length):(R=k.length,E=T.length),this._isInResult=E===pn.numMultiPolys&&R<E;break}case"xor":{let R=Math.abs(T.length-k.length);this._isInResult=R%2===1;break}case"difference":{let R=E=>E.length===1&&E[0].isSubject;this._isInResult=R(T)!==R(k);break}default:throw new Error(`Unrecognized operation type found ${pn.type}`)}return this._isInResult}}class Vc{constructor(T,k,R){if(!Array.isArray(T)||T.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=k,this.isExterior=R,this.segments=[],typeof T[0][0]!="number"||typeof T[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let E=S.round(T[0][0],T[0][1]);this.bbox={ll:{x:E.x,y:E.y},ur:{x:E.x,y:E.y}};let I=E;for(let H=1,_=T.length;H<_;H++){if(typeof T[H][0]!="number"||typeof T[H][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let V=S.round(T[H][0],T[H][1]);V.x===I.x&&V.y===I.y||(this.segments.push(Xt.fromRing(I,V,this)),V.x<this.bbox.ll.x&&(this.bbox.ll.x=V.x),V.y<this.bbox.ll.y&&(this.bbox.ll.y=V.y),V.x>this.bbox.ur.x&&(this.bbox.ur.x=V.x),V.y>this.bbox.ur.y&&(this.bbox.ur.y=V.y),I=V)}(E.x!==I.x||E.y!==I.y)&&this.segments.push(Xt.fromRing(I,E,this))}getSweepEvents(){let T=[];for(let k=0,R=this.segments.length;k<R;k++){let E=this.segments[k];T.push(E.leftSE),T.push(E.rightSE)}return T}}class dy{constructor(T,k){if(!Array.isArray(T))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new Vc(T[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let R=1,E=T.length;R<E;R++){let I=new Vc(T[R],this,!1);I.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=I.bbox.ll.x),I.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=I.bbox.ll.y),I.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=I.bbox.ur.x),I.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=I.bbox.ur.y),this.interiorRings.push(I)}this.multiPoly=k}getSweepEvents(){let T=this.exteriorRing.getSweepEvents();for(let k=0,R=this.interiorRings.length;k<R;k++){let E=this.interiorRings[k].getSweepEvents();for(let I=0,H=E.length;I<H;I++)T.push(E[I])}return T}}class zc{constructor(T,k){if(!Array.isArray(T))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof T[0][0][0]=="number"&&(T=[T])}catch{}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let R=0,E=T.length;R<E;R++){let I=new dy(T[R],this);I.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=I.bbox.ll.x),I.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=I.bbox.ll.y),I.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=I.bbox.ur.x),I.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=I.bbox.ur.y),this.polys.push(I)}this.isSubject=k}getSweepEvents(){let T=[];for(let k=0,R=this.polys.length;k<R;k++){let E=this.polys[k].getSweepEvents();for(let I=0,H=E.length;I<H;I++)T.push(E[I])}return T}}class Kc{static factory(T){let k=[];for(let R=0,E=T.length;R<E;R++){let I=T[R];if(!I.isInResult()||I.ringOut)continue;let H=null,_=I.leftSE,V=I.rightSE,U=[_],X=_.point,L=[];for(;H=_,_=V,U.push(_),_.point!==X;)for(;;){let z=_.getAvailableLinkedEvents();if(z.length===0){let re=U[0].point,ge=U[U.length-1].point;throw new Error(`Unable to complete output ring starting at [${re.x}, ${re.y}]. Last matching segment found ends at [${ge.x}, ${ge.y}].`)}if(z.length===1){V=z[0].otherSE;break}let Y=null;for(let re=0,ge=L.length;re<ge;re++)if(L[re].point===_.point){Y=re;break}if(Y!==null){let re=L.splice(Y)[0],ge=U.splice(re.index);ge.unshift(ge[0].otherSE),k.push(new Kc(ge.reverse()));continue}L.push({index:U.length,point:_.point});let ie=_.getLeftmostComparator(H);V=z.sort(ie)[0].otherSE;break}k.push(new Kc(U))}return k}constructor(T){this.events=T;for(let k=0,R=T.length;k<R;k++)T[k].segment.ringOut=this;this.poly=null}getGeom(){let T=this.events[0].point,k=[T];for(let U=1,X=this.events.length-1;U<X;U++){let L=this.events[U].point,z=this.events[U+1].point;ee(L,T,z)!==0&&(k.push(L),T=L)}if(k.length===1)return null;let R=k[0],E=k[1];ee(R,T,E)===0&&k.shift(),k.push(k[0]);let I=this.isExteriorRing()?1:-1,H=this.isExteriorRing()?0:k.length-1,_=this.isExteriorRing()?k.length:-1,V=[];for(let U=H;U!=_;U+=I)V.push([k[U].x,k[U].y]);return V}isExteriorRing(){if(this._isExteriorRing===void 0){let T=this.enclosingRing();this._isExteriorRing=T?!T.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let T=this.events[0];for(let E=1,I=this.events.length;E<I;E++){let H=this.events[E];Le.compare(T,H)>0&&(T=H)}let k=T.segment.prevInResult(),R=k?k.prevInResult():null;for(;;){if(!k)return null;if(!R)return k.ringOut;if(R.ringOut!==k.ringOut)return R.ringOut.enclosingRing()!==k.ringOut?k.ringOut:k.ringOut.enclosingRing();k=R.prevInResult(),R=k?k.prevInResult():null}}}class F1{constructor(T){this.exteriorRing=T,T.poly=this,this.interiorRings=[]}addInterior(T){this.interiorRings.push(T),T.poly=this}getGeom(){let T=[this.exteriorRing.getGeom()];if(T[0]===null)return null;for(let k=0,R=this.interiorRings.length;k<R;k++){let E=this.interiorRings[k].getGeom();E!==null&&T.push(E)}return T}}class jH{constructor(T){this.rings=T,this.polys=this._composePolys(T)}getGeom(){let T=[];for(let k=0,R=this.polys.length;k<R;k++){let E=this.polys[k].getGeom();E!==null&&T.push(E)}return T}_composePolys(T){let k=[];for(let R=0,E=T.length;R<E;R++){let I=T[R];if(!I.poly)if(I.isExteriorRing())k.push(new F1(I));else{let H=I.enclosingRing();H.poly||k.push(new F1(H)),H.poly.addInterior(I)}}return k}}class $H{constructor(T){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Xt.compare;this.queue=T,this.tree=new l(k),this.segments=[]}process(T){let k=T.segment,R=[];if(T.consumedBy)return T.isLeft?this.queue.remove(T.otherSE):this.tree.remove(k),R;let E=T.isLeft?this.tree.add(k):this.tree.find(k);if(!E)throw new Error(`Unable to find segment #${k.id} [${k.leftSE.point.x}, ${k.leftSE.point.y}] -> [${k.rightSE.point.x}, ${k.rightSE.point.y}] in SweepLine tree.`);let I=E,H=E,_,V;for(;_===void 0;)I=this.tree.prev(I),I===null?_=null:I.key.consumedBy===void 0&&(_=I.key);for(;V===void 0;)H=this.tree.next(H),H===null?V=null:H.key.consumedBy===void 0&&(V=H.key);if(T.isLeft){let U=null;if(_){let L=_.getIntersection(k);if(L!==null&&(k.isAnEndpoint(L)||(U=L),!_.isAnEndpoint(L))){let z=this._splitSafely(_,L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}}let X=null;if(V){let L=V.getIntersection(k);if(L!==null&&(k.isAnEndpoint(L)||(X=L),!V.isAnEndpoint(L))){let z=this._splitSafely(V,L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}}if(U!==null||X!==null){let L=null;U===null?L=X:X===null?L=U:L=Le.comparePoints(U,X)<=0?U:X,this.queue.remove(k.rightSE),R.push(k.rightSE);let z=k.split(L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}R.length>0?(this.tree.remove(k),R.push(T)):(this.segments.push(k),k.prev=_)}else{if(_&&V){let U=_.getIntersection(V);if(U!==null){if(!_.isAnEndpoint(U)){let X=this._splitSafely(_,U);for(let L=0,z=X.length;L<z;L++)R.push(X[L])}if(!V.isAnEndpoint(U)){let X=this._splitSafely(V,U);for(let L=0,z=X.length;L<z;L++)R.push(X[L])}}}this.tree.remove(k)}return R}_splitSafely(T,k){this.tree.remove(T);let R=T.rightSE;this.queue.remove(R);let E=T.split(k);return E.push(R),T.consumedBy===void 0&&this.tree.add(T),E}}let L1=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,YH=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class qH{run(T,k,R){pn.type=T,S.reset();let E=[new zc(k,!0)];for(let L=0,z=R.length;L<z;L++)E.push(new zc(R[L],!1));if(pn.numMultiPolys=E.length,pn.type==="difference"){let L=E[0],z=1;for(;z<E.length;)g(E[z].bbox,L.bbox)!==null?z++:E.splice(z,1)}if(pn.type==="intersection")for(let L=0,z=E.length;L<z;L++){let Y=E[L];for(let ie=L+1,re=E.length;ie<re;ie++)if(g(Y.bbox,E[ie].bbox)===null)return[]}let I=new l(Le.compare);for(let L=0,z=E.length;L<z;L++){let Y=E[L].getSweepEvents();for(let ie=0,re=Y.length;ie<re;ie++)if(I.insert(Y[ie]),I.size>L1)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}let H=new $H(I),_=I.size,V=I.pop();for(;V;){let L=V.key;if(I.size===_){let Y=L.segment;throw new Error(`Unable to pop() ${L.isLeft?"left":"right"} SweepEvent [${L.point.x}, ${L.point.y}] from segment #${Y.id} [${Y.leftSE.point.x}, ${Y.leftSE.point.y}] -> [${Y.rightSE.point.x}, ${Y.rightSE.point.y}] from queue.`)}if(I.size>L1)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(H.segments.length>YH)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");let z=H.process(L);for(let Y=0,ie=z.length;Y<ie;Y++){let re=z[Y];re.consumedBy===void 0&&I.insert(re)}_=I.size,V=I.pop()}S.reset();let U=Kc.factory(H.segments);return new jH(U).getGeom()}}let pn=new qH;var XH={union:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("union",O,k)},intersection:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("intersection",O,k)},xor:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("xor",O,k)},difference:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("difference",O,k)}};return XH}))});function tl(){let e=[];return{onRelease(t){e?e.push(t):t()},release(){let t=e;e=null;for(let n of t??[])n()}}}var jc=class extends Error{constructor(n,r){super(`shader ${n} failure: ${r}`);this.stage=n;this.log=r;this.name="ShaderCompileError"}stage;log},$c=0,Jr=class{constructor(t,n,r){this.gl=t;let o=this.compile(t.VERTEX_SHADER,n,"vertex"),i;try{i=this.compile(t.FRAGMENT_SHADER,r,"fragment")}catch(a){throw t.deleteShader(o),a}let s=t.createProgram();if(!s)throw t.deleteShader(o),t.deleteShader(i),new Error("createProgram returned null");if(t.attachShader(s,o),t.attachShader(s,i),t.bindAttribLocation(s,$c,"a_position"),t.linkProgram(s),t.deleteShader(o),t.deleteShader(i),!t.getProgramParameter(s,t.LINK_STATUS)){let a=t.getProgramInfoLog(s)??"";throw t.deleteProgram(s),new jc("link",a)}this.handle=s}gl;handle;uniforms=new Map;arrays=new Map;attributes=new Map;compile(t,n,r){let o=this.gl,i=o.createShader(t);if(!i)throw new Error("createShader returned null");if(o.shaderSource(i,n),o.compileShader(i),!o.getShaderParameter(i,o.COMPILE_STATUS)){let s=o.getShaderInfoLog(i)??"";throw o.deleteShader(i),new jc(r,s)}return i}lookupUniforms(t){for(let n of t){let r=this.gl.getUniformLocation(this.handle,n);r!==null&&this.uniforms.set(n,r)}}lookupUniformArrays(t){for(let[n,{type:r,size:o}]of t){let i=`${n}[0]`,s=this.uniforms.get(i)??this.gl.getUniformLocation(this.handle,i);s!==null&&this.arrays.set(n,{type:r,size:o,location:s})}}lookupAttributes(t){for(let n of t){let r=this.gl.getAttribLocation(this.handle,n);r>=0&&this.attributes.set(n,r)}}uniform(t){return this.uniforms.get(t)}uniformArray(t){return this.arrays.get(t)}attribute(t){return this.attributes.get(t)}};var _1=`#version 300 es
4
4
  in vec2 a_position;
5
5
  uniform mat3 u_proj;
6
6
  uniform mat3 u_model;
@@ -10,7 +10,7 @@ void main() {
10
10
  vec3 clip = u_proj * vec3(screen.xy, 1.0);
11
11
  gl_Position = vec4(clip.xy, 0.0, 1.0);
12
12
  }
13
- `,R1=`#version 300 es
13
+ `,D1=`#version 300 es
14
14
  precision highp float;
15
15
  uniform vec4 u_color;
16
16
  uniform float u_alpha;
@@ -22,7 +22,7 @@ void main() {
22
22
  float a = mapped.a * u_alpha;
23
23
  outColor = vec4(mapped.rgb * a, a);
24
24
  }
25
- `,N1=`#version 300 es
25
+ `,B1=`#version 300 es
26
26
  in vec2 a_position;
27
27
  in vec4 a_vertexColor;
28
28
  uniform mat3 u_proj;
@@ -35,7 +35,7 @@ void main() {
35
35
  gl_Position = vec4(clip.xy, 0.0, 1.0);
36
36
  v_vertexColor = a_vertexColor;
37
37
  }
38
- `,I1=`#version 300 es
38
+ `,H1=`#version 300 es
39
39
  precision highp float;
40
40
  in vec4 v_vertexColor;
41
41
  uniform vec4 u_color;
@@ -49,8 +49,8 @@ void main() {
49
49
  float a = mapped.a * u_alpha;
50
50
  outColor = vec4(mapped.rgb * a, a);
51
51
  }
52
- `,oy=["u_proj","u_model","u_origin","u_color","u_alpha","u_colorMatrix","u_colorBias"],E1=["a_position"],M1=["a_position","a_vertexColor"];var qa=e=>typeof e=="number"&&Number.isFinite(e);function C1(e){if(e===void 0)return;if(typeof e!="object"||e===null)throw new Error("parseBmFont: faceMetrics must be an object");let t=e,n={};if(t.ascent!==void 0||t.descent!==void 0){if(!qa(t.ascent)||!qa(t.descent)||t.ascent+t.descent<=0)throw new Error("parseBmFont: malformed faceMetrics.ascent/descent");n.ascent=t.ascent,n.descent=t.descent}let r=(o,i,s,a)=>{let l=t[o];if(l===void 0)return;let u=l;if(typeof u!="object"||u===null||!qa(u[i])||!qa(u[s])||u[a]<=0)throw new Error(`parseBmFont: malformed faceMetrics.${o}`);n[o]={[i]:u[i],[s]:u[s]}};r("underline","offset","thickness","thickness"),r("strikethrough","offset","thickness","thickness"),r("superscript","size","shift","size"),r("subscript","size","shift","size");for(let o of["xHeight","capHeight"]){let i=t[o];if(i!==void 0){if(!qa(i)||i<=0)throw new Error(`parseBmFont: malformed faceMetrics.${o}`);n[o]=i}}return Object.keys(n).length>0?n:void 0}function zo(e){return e.outlineFace?.faceMetrics??e.entry?.font.faceMetrics}function O1(e){if(typeof e!="object"||e===null)throw new Error("parseBmFont: expected object");let t=e;if(!t.info||typeof t.info!="object")throw new Error("parseBmFont: missing info");if(!t.common||typeof t.common!="object")throw new Error("parseBmFont: missing common");if(!Array.isArray(t.chars))throw new Error("parseBmFont: chars must be an array");let n=t.info,r=t.common,o=[["info.size",n.size],["common.scaleW",r.scaleW],["common.scaleH",r.scaleH]];for(let[d,f]of o)if(typeof f!="number"||!(f>0)||!Number.isFinite(f))throw new Error(`parseBmFont: ${d} must be a positive number`);if(typeof r.base!="number"||!Number.isFinite(r.base))throw new Error("parseBmFont: common.base must be a number");let i=t.chars,s=Array.isArray(t.kernings)?t.kernings:[],a=new Map;for(let d of i)a.set(d.id,d);let l=new Map;for(let d of s){let f=l.get(d.first);f||(f=new Map,l.set(d.first,f)),f.set(d.second,d.amount)}let u=C1(t.faceMetrics),c=t.distanceField?.distanceRange;return{info:n,common:r,chars:i,kernings:s,charMap:a,kerningMap:l,...u?{faceMetrics:u}:{},...typeof c=="number"&&c>0?{distanceRange:c}:{}}}var ji={family:"",weight:NaN,style:"",key:""};function $i(e,t,n){return ji.family===e&&ji.weight===t&&ji.style===n||(ji={family:e,weight:t,style:n,key:`${e}|${t}|${n}`}),ji.key}var F1=new Map;function Yr(e,t){let n=F1.get(t);n===void 0&&F1.set(t,n=new Map);let r=n.get(e);return r===void 0&&(r=`${e}|${t}`,n.size<1024&&n.set(e,r)),r}function Me(){let e=new Set;return{subscribe(t){return e.add(t),()=>{e.delete(t)}},emit(...t){if(e.size!==0){for(let n of[...e])if(e.has(n))try{n(...t)}catch(r){console.error("weasel: a subscriber threw",r)}}},get size(){return e.size}}}function bt(){let e=new Map,t=Me(),n=0,r=null;function o(){n++,t.emit()}let i={get:a=>e.get(a)?.at(-1)?.value,has:a=>e.has(a),entries(){if(r?.version===n)return r.entries;let a=[];for(let[l,u]of e){let c=u.at(-1);a.push(Object.freeze({key:l,live:c,value:c.value,source:c.source,shadowed:Object.freeze(u.slice(0,-1))}))}return r={version:n,entries:Object.freeze(a)},r.entries},subscribe:t.subscribe,getVersion:()=>n};function s(a,l){let u=e.get(a),c=u?u.lastIndexOf(l):-1;return c===-1?!1:(u.splice(c,1),u.length===0&&e.delete(a),o(),!0)}return{...i,reflection:i,release:s,push(a,l,u){let c=Object.freeze({value:l,source:u?.source}),d=e.get(a);return d?d.push(c):e.set(a,[c]),o(),()=>{s(a,c)}},set(a,l,u){let c=Object.freeze({value:l,source:u?.source}),d=e.get(a);d?d[d.length-1]=c:e.set(a,[c]),o()},delete(a){return e.delete(a)?(o(),!0):!1},clear(){e.size!==0&&(e.clear(),o())},bump:o}}function Xt(){try{return!1}catch{return!0}}function Yi(e){return e===Object.prototype||e===null||Object.getPrototypeOf(e)===null}function Jt(e){return typeof e=="object"&&e!==null&&Yi(Object.getPrototypeOf(e))}function qr(e,t,n={}){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((o,i)=>qr(o,t[i],n));if(!Jt(e)||!Jt(t))return!1;if(n.undefinedAsAbsent)return[...new Set([...Object.keys(e),...Object.keys(t)])].every(o=>qr(e[o],t[o],n));let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(o=>Object.hasOwn(t,o)&&qr(e[o],t[o],n))}var L1=Me(),iy=0;function Ko(){return iy}var _1=0;function Xa(){return _1}function gn(){iy++,_1++,L1.emit()}function D1(){iy++,L1.emit()}var XH="substitute",JH=null;function qi(){return XH}function Ja(){return JH}var sy=new Set;function Xr(e){return sy.has(e)?!1:(sy.add(e),!0)}function B1(e){return sy.has(e)}var Qa=class{constructor(t){this.format=t}format;pages=[];uploaded=new WeakMap;textureId(t){return`${this.format.idPrefix}${t}`}blit(t,n,r,o,i,s){let a=this.format.channels;for(;this.pages.length<=t;)this.pages.push({data:new Uint8Array(1024*1024*a),version:0,patches:[]});let l=this.pages[t];for(let u=0;u<i;u++)l.data.set(s.subarray(u*o*a,(u+1)*o*a),((r+u)*1024+n)*a);l.version++,l.patches.push({seq:l.version,x:n,y:r,w:o,h:i})}clear(){for(let t of this.pages)t.data.fill(0),t.version++,t.patches=[{seq:t.version,x:0,y:0,w:1024,h:1024}]}sync(t,n){let r=this.pages[n];if(!r)return!1;let o=this.format.channels,i=this.textureId(n),s=this.uploaded.get(t);if(s||(s=new Map,this.uploaded.set(t,s)),!t.has(i))return this.format.upload(t,i,r.data),s.set(n,r.version),!0;let a=s.get(n)??0;if(a>=r.version)return!0;for(let l of r.patches){if(l.seq<=a)continue;let u=new Uint8Array(l.w*l.h*o);for(let c=0;c<l.h;c++){let d=((l.y+c)*1024+l.x)*o;u.set(r.data.subarray(d,d+l.w*o),c*l.w*o)}this.format.patch(t,i,l.x,l.y,l.w,l.h,u)}return s.set(n,r.version),!0}},Dc=new Qa({channels:1,idPrefix:"weasel-dyn-sdf-page-",upload:(e,t,n)=>e.uploadR8(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageR8(t,n,r,o,i,s)}),Bc=new Qa({channels:4,idPrefix:"weasel-dyn-color-page-",upload:(e,t,n)=>e.uploadRGBA(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageRGBA(t,n,r,o,i,s)}),Za=new Qa({channels:4,idPrefix:"weasel-dyn-color-sharp-page-",upload:(e,t,n)=>e.uploadRGBA(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageRGBA(t,n,r,o,i,s)});function H1(e,t,n,r,o,i){Dc.blit(e,t,n,r,o,i)}function G1(e,t,n,r,o,i){Bc.blit(e,t,n,r,o,i)}function U1(e,t,n,r,o,i){Za.blit(e,t,n,r,o,i)}function V1(){Dc.clear(),Bc.clear(),Za.clear()}function W1(){Za.clear()}function Hc(e){return Dc.textureId(e)}function Gc(e){return Bc.textureId(e)}function Uc(e){return Za.textureId(e)}function Vc(e,t){return Dc.sync(e,t)}function Wc(e,t){return Bc.sync(e,t)}function zc(e,t){return Za.sync(e,t)}var Kc=class{constructor(t,n){this.pageSize=t;this.maxPages=n}pageSize;maxPages;pages=[];get pageCount(){return this.pages.length}fits(t,n){return t<=this.pageSize&&n<=this.pageSize}alloc(t,n){if(!this.fits(t,n))return null;for(let r=0;r<this.pages.length;r++){let o=this.allocInPage(this.pages[r],t,n);if(o)return{page:r,...o}}if(this.pages.length<this.maxPages){let r={shelves:[],nextY:0};this.pages.push(r);let o=this.allocInPage(r,t,n);if(o)return{page:this.pages.length-1,...o}}return null}allocInPage(t,n,r){for(let o of t.shelves)if(r<=o.height&&o.x+n<=this.pageSize){let i=o.x;return o.x+=n,{x:i,y:o.y}}if(t.nextY+r<=this.pageSize){let o={y:t.nextY,height:r,x:n};return t.shelves.push(o),t.nextY+=r,{x:0,y:o.y}}return null}};function z1(e,t,n,r,o){n[0]=0,r[0]=-1e20,r[1]=1e20;let i=0;for(let s=1;s<o;s++){let a=(e[s]+s*s-(e[n[i]]+n[i]*n[i]))/(2*s-2*n[i]);for(;a<=r[i];)i--,a=(e[s]+s*s-(e[n[i]]+n[i]*n[i]))/(2*s-2*n[i]);i++,n[i]=s,r[i]=a,r[i+1]=1e20}i=0;for(let s=0;s<o;s++){for(;r[i+1]<s;)i++;t[s]=(s-n[i])*(s-n[i])+e[n[i]]}}function K1(e,t,n,r,o,i,s){for(let a=0;a<t;a++){for(let l=0;l<n;l++)r[l]=e[l*t+a];z1(r,o,i,s,n);for(let l=0;l<n;l++)e[l*t+a]=o[l]}for(let a=0;a<n;a++){for(let l=0;l<t;l++)r[l]=e[a*t+l];z1(r,o,i,s,t);for(let l=0;l<t;l++)e[a*t+l]=o[l]}}function j1(e,t,n,r,o){let i=t*n,s=new Float64Array(i),a=new Float64Array(i),l=Math.max(t,n),u=new Float64Array(l),c=new Float64Array(l),d=new Int32Array(l),f=new Float64Array(l+1);for(let h=0;h<i;h++){let m=e[h]/255;s[h]=m===1?0:m===0?1e20:Math.max(0,.5-m)**2,a[h]=m===1?1e20:m===0?0:Math.max(0,m-.5)**2}K1(s,t,n,u,c,d,f),K1(a,t,n,u,c,d,f);let p=new Uint8Array(i);for(let h=0;h<i;h++){let m=Math.sqrt(s[h])-Math.sqrt(a[h]),g=Math.round(255-255*(m/r+o));p[h]=g<0?0:g>255?255:g}return p}var Xi=8,X1=.5,$o=16,jo=()=>({packer:new Kc(1024,4),settled:!0,reclaimScheduled:!1}),cy=jo(),dy=jo(),el=jo(),Bn=[],ay=!1,ly=$o,uy=0,J1=()=>{},fy=()=>{},$1=new Set;function Q1(e){J1=e}function Z1(e){fy=e}function Ji(e,t,n=!1){if(uy++,t.width===0||t.height===0){e.page=0;return}ly>0?(ly--,tS(e,t,n)):(Bn.push({char:e,raster:t,sharp:n}),nS())}function eS(e){Bn=Bn.filter(t=>!e.has(t.char))}function tS(e,t,n){let r="rgba"in t,o=n?el:r?dy:cy,i=o.packer.alloc(t.width,t.height);if(!i){QH(o,t,n?eG:ZH);return}if(r&&n)U1(i.page,i.x,i.y,t.width,t.height,t.rgba);else if(r)G1(i.page,i.x,i.y,t.width,t.height,t.rgba);else{let s=j1(t.alpha,t.width,t.height,Xi,X1);H1(i.page,i.x,i.y,t.width,t.height,s)}e.x=i.x,e.y=i.y,e.width=t.width,e.height=t.height,e.page=i.page}function QH(e,t,n){if(!e.packer.fits(t.width,t.height))Y1("weasel DynamicGlyphAtlas: a glyph is larger than a page and will not render.");else if(e.settled)e.reclaimScheduled||(e.reclaimScheduled=!0,setTimeout(n,0));else{if(e===el)return;Y1(`weasel DynamicGlyphAtlas: more glyphs are in use at once than its pages hold (${4} \xD7 ${1024}\xB2); the rest will not render.`)}}function Y1(e){$1.has(e)||($1.add(e),console.warn(e))}function ZH(){cy={...jo(),settled:!1},dy={...jo(),settled:!1},el={...jo(),settled:!1},Bn=[],V1(),J1(),fy(),gn()}function eG(){el={...jo(),settled:!1},Bn=Bn.filter(e=>!e.sharp),W1(),fy(),gn()}function nS(){ay||(ay=!0,setTimeout(tG,0))}function tG(){ay=!1;let e=0;for(;Bn.length>0&&e<$o;){let t=Bn.shift();t.char.page===-1&&(tS(t.char,t.raster,t.sharp),e++)}Bn.length>0&&nS(),D1()}function jc(e=$o){ly=e,uy===0&&Bn.length===0&&(cy.settled=!0,dy.settled=!0,el.settled=!0),uy=0}function py(e){return e.trim().replace(/^(["'])(.*)\1$/,"$2").toLowerCase()}function rS(e){let t=typeof document>"u"?void 0:document.fonts;if(!t?.addEventListener)return()=>{};let n=r=>{let o=r.fontfaces??[];o.length>0&&e(o.map(i=>i.family))};return t.addEventListener("loadingdone",n),()=>t.removeEventListener("loadingdone",n)}function oS(e){return/[,"']/.test(e)?e:nG.has(e.trim().toLowerCase())?e.trim():JSON.stringify(e)}var nG=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]);var He=48,Qt=8;function rG(e){let t=[1/0,1/0,-1/0,-1/0],n=e.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[];for(let r=0;r+1<n.length;r+=2){let o=Number(n[r]),i=Number(n[r+1]);o<t[0]&&(t[0]=o),i<t[1]&&(t[1]=i),o>t[2]&&(t[2]=o),i>t[3]&&(t[3]=i)}return t}var oG=240;function iG(e){let t=new Uint8ClampedArray(e.length),n=!1;for(let r=0;r<e.length;r+=4){let o=e[r+3];if(o===0)continue;let i=e[r],s=e[r+1],a=e[r+2];o>=128&&Math.min(i,s,a)<oG&&(n=!0),t[r]=Math.round(i*o/255),t[r+1]=Math.round(s*o/255),t[r+2]=Math.round(a*o/255),t[r+3]=o}return n?t:null}var $c=1e3;function sG(e,t,n,r=He){return`${t==="italic"?"italic ":""}${e} ${r}px ${oS(n)}`}function iS(){let e;if(typeof OffscreenCanvas<"u")e=new OffscreenCanvas(He*3,He*3);else if(typeof document<"u")e=document.createElement("canvas"),e.width=He*3,e.height=He*3;else throw new Error("weasel DynamicGlyphAtlas: no canvas available for glyph rasterization");let t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw new Error("weasel DynamicGlyphAtlas: 2D context unavailable");function n(o,i,s,a=He){t.font=sG(i,s,o,a),t.textBaseline="alphabetic",t.textAlign="left"}function r(o,i,s,a,l=He){n(o,i,s,l);let u=t.measureText(a),c=u.width,d=Math.ceil(u.actualBoundingBoxLeft??0),f=Math.ceil(u.actualBoundingBoxRight??c),p=Math.ceil(u.actualBoundingBoxAscent??l*.8),h=Math.ceil(u.actualBoundingBoxDescent??l*.2),m=d+f,g=p+h;if(m<=0||g<=0)return{data:new Uint8ClampedArray(0),width:0,height:0,left:0,top:0,advance:c};let b=m+2*Qt,x=g+2*Qt;return(e.width<b||e.height<x)&&(e.width=Math.max(e.width,b),e.height=Math.max(e.height,x),n(o,i,s,l)),t.clearRect(0,0,b,x),t.fillStyle="#fff",t.fillText(a,Qt+d,Qt+p),{data:t.getImageData(0,0,b,x).data,width:b,height:x,left:-(d+Qt),top:p+Qt,advance:c}}return{faceMetrics(o,i,s){n(o,i,s,$c);let a=t.measureText("Hg"),l=He/$c;return{ascent:(a.fontBoundingBoxAscent??$c*.8)*l,descent:(a.fontBoundingBoxDescent??$c*.2)*l}},rasterize(o,i,s,a){let{data:l,...u}=r(o,i,s,String.fromCodePoint(a)),c=new Uint8ClampedArray(u.width*u.height);for(let d=0;d<c.length;d++)c[d]=l[d*4+3];return{...u,alpha:c}},rasterizePath(o){let[i,s,a,l]=rG(o),u={width:0,height:0,alpha:new Uint8ClampedArray(0),left:0,top:0,advance:0};if(!(a>i&&l>s))return u;let c=Math.floor(i*He),d=Math.floor(s*He),f=Math.ceil(a*He)-c+2*Qt,p=Math.ceil(l*He)-d+2*Qt;(e.width<f||e.height<p)&&(e.width=Math.max(e.width,f),e.height=Math.max(e.height,p)),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,f,p),t.setTransform(He,0,0,He,Qt-c,Qt-d),t.fillStyle="#fff",t.fill(new Path2D(o)),t.setTransform(1,0,0,1,0,0);let h=t.getImageData(0,0,f,p).data,m=new Uint8ClampedArray(f*p);for(let g=0;g<m.length;g++)m[g]=h[g*4+3];return{width:f,height:p,alpha:m,left:c-Qt,top:Qt-d,advance:0}},rasterizeColor(o,i,s,a,l){let{data:u,...c}=r(o,i,s,a,l),d=iG(u);return d&&{...c,rgba:d}}}}var hy=3,my=new WeakMap,Yc=0;Z1(()=>{Yc++});function sS(e,t,n){my.set(e,{raster:n,base:t,levels:[],generation:Yc})}function yy(e){return e.generation!==Yc&&(e.levels=[],e.generation=Yc),e.levels}function aS(e){let t=my.get(e);return t?yy(t).flatMap(n=>n?[n.glyph]:[]):[]}function aG(e,t){let n=yy(e),r=n[t];if(r!==void 0)return r;let o=2**t,i=e.raster(He*o),s=i&&{level:t,glyph:{id:0,x:0,y:0,width:0,height:0,xoffset:i.left/o,yoffset:e.base-i.top/o,xadvance:i.advance/o,page:-1,color:!0}};return n[t]=s,s&&i&&Ji(s.glyph,i,!0),s}function qc(e,t){let n=my.get(e);if(!n||!(t>1))return null;let r=Math.min(hy,Math.ceil(Math.log2(t)));aG(n,r);let o=yy(n);for(let i=r;i>0;i--){let s=o[i];if(s&&s.glyph.page>=0)return s}return null}var Xc=new Set,Jc=new Set,Qc=new Map,gy=null,lG=null;function lS(e){e.font.charMap.clear(),e.font.chars.length=0,e.clusters.clear(),e.shaped.clear()}Q1(()=>{for(let e of Qc.values())lS(e)});function uS(){return gy||(gy=iS()),gy}function Zc(e){return Xc.has(e)?!Jc.has(e)||qi()==="canvas":!1}function cS(e){Xc.has(e)&&!Jc.has(e)||(Xc.add(e),Jc.add(e))}function by(e){return Xc.has(e)&&!Jc.has(e)}function ed(e,t,n){let r=`${e}|${t}|${n}`,o=Qc.get(r);if(o)return o;let i=uS(),s={info:{face:e,size:He},common:{lineHeight:0,base:0,scaleW:1024,scaleH:1024},chars:[],kernings:[],charMap:new Map,kerningMap:new Map},a=(d,f)=>({id:d,x:0,y:0,width:0,height:0,xoffset:f.left,yoffset:s.common.base-f.top,xadvance:f.advance,page:-1}),l=new Map,u=new Map,c={family:e,weight:t,style:n,font:s,clusters:l,shaped:u,requestGlyph(d){let f=s.charMap.get(d);if(f)return f;let p=i.rasterize(e,t,n,d),h=a(d,p);return s.charMap.set(d,h),s.chars.push(h),Ji(h,p),h},requestCluster(d){let f=l.get(d);if(f!==void 0)return f;let p=i.rasterizeColor?.(e,t,n,d)??null,h=p&&{...a(d.codePointAt(0),p),color:!0};return l.set(d,h),h&&p&&(Ji(h,p),sS(h,s.common.base,m=>i.rasterizeColor?.(e,t,n,d,m)??null)),h},requestShaped(d,f){let p=u.get(d);if(p!==void 0)return p;let h=typeof Path2D>"u"?null:i.rasterizePath?.(f)??null,m=h&&a(0,h);return u.set(d,m),m&&h&&Ji(m,h),m}};return dS(c),Qc.set(r,c),lG??=rS(uG),c}function dS(e){let{font:t}=e,n=uS().faceMetrics(e.family,e.weight,e.style);t.common.lineHeight=Math.round(n.ascent+n.descent),t.common.base=Math.round(n.ascent),t.faceMetrics={ascent:n.ascent/He,descent:n.descent/He},lS(e)}function uG(e){let t=e&&new Set(e.map(py)),n=new Set,r=0;for(let o of Qc.values())if(!(t&&!o.family.split(",").some(i=>t.has(py(i))))){for(let i of o.font.chars)n.add(i);for(let i of o.shaped.values())i&&n.add(i);for(let i of o.clusters.values())if(i){n.add(i);for(let s of aS(i))n.add(s)}dS(o),r++}r!==0&&(eS(n),gn())}var ur=bt(),cG=ur.reflection;function Yo(e,t,n){return`${e}|${t}|${n}`}function dG(e){return{weight:e.weight??400,style:e.style??"normal"}}function xy(e,t=400,n="normal"){return ur.has(Yo(e,t,n))}function wy(e,t=400,n="normal"){return ur.get(Yo(e,t,n))?.status??null}function fG(e){let t="",n=0;for(let r=1;r<e.length;r++){let o=e[r];o!=="M"&&o!=="m"||(t+=fS(e.slice(n,r)),n=r)}return t+fS(e.slice(n))}function fS(e){let t=e.trimEnd();if(t.length===0)return"";let n=t[t.length-1];return n==="Z"||n==="z"?t:`${t}Z`}function Py(e,t,n,r){let o=ur.get(Yo(e,t,n));if(!o)return null;if(o.status==="idle")return Sy(o),null;if(o.status!=="ready")return null;let i=o.glyphs.get(r);if(i!==void 0)return i;let s=null;try{let a=o.face.glyphD(r);s=a===null?null:fG(a)}catch(a){hS(`glyph|${Yo(e,t,n)}`,`weasel: outline face "${e}" (${t}/${n}) could not produce a glyph for U+${r.toString(16).toUpperCase().padStart(4,"0")} \u2014 ${a instanceof Error?a.message:String(a)}. Falling back to the SDF tier.`)}return o.glyphs.set(r,s),s}function tl(e,t,n){let r=ur.get(Yo(e,t,n));return r?r.status==="idle"?(Sy(r),null):r.status==="ready"?r.face:null:null}async function Ty(e,t={}){let{weight:n,style:r}=dG(t),o=ur.get(Yo(e,n,r));return o?(await Sy(o),o.status):null}function Sy(e){return e.load??=pG(e),e.load}async function pG(e){e.status="loading",ur.bump();try{let t=await yG(e.source);mG(e,t),e.face=await e.parser(t),e.status="ready",ur.bump(),gn()}catch(t){e.status="failed",ur.bump(),gn(),hS(`load|${Yo(e.family,e.weight,e.style)}`,`weasel registerFontOutlines("${e.family}" ${e.weight}/${e.style}): ${t instanceof Error?t.message:String(t)}. Large text in this face keeps rendering from the SDF tier.`)}}var hG=null;function mG(e,t){try{hG?.(e,t)}catch{}}async function yG(e){let t=typeof e=="function"?await e():e;if(typeof t=="string"){let n=await fetch(t);if(!n.ok)throw new Error(`HTTP ${n.status} fetching ${t}`);return n.arrayBuffer()}return t instanceof ArrayBuffer?t:t.arrayBuffer()}var pS=new Set;function hS(e,t){pS.has(e)||(pS.add(e),console.warn(t))}function Jr(e,t,n,r,o,i){return{entry:e,resolved:{family:t,weight:n,style:r},synthetic:{bold:o,italic:i},source:"atlas"}}var mS=new WeakMap;function yS(e,t,n,r){let o=mS.get(e);if(o!==void 0&&o.resolved.family===t&&o.resolved.weight===n&&o.resolved.style===r)return o;let i=Jr(e,t,n,r,!1,!1);return Object.freeze(i.resolved),Object.freeze(i.synthetic),mS.set(e,Object.freeze(i)),i}var _t=bt(),bG=_t.reflection;function xG(e){return{weight:e.weight??400,style:e.style??"normal"}}var nl=new Map,Qr=new Map,Qi=new Map,vy=new Set;function rl(e,t=400,n="normal"){return _t.get(e)?.get(Yr(t,n))??null}function xS(e,t,n,r){let o=`${e}|${t}`,i=Qr.get(o);if(i)return i;let s=wG(e,t,n,r);Qr.set(o,s);let a=()=>{Qr.get(o)===s&&Qr.delete(o)};s.then(a,a);let l=Qi.get(e)?.get(t);if(l){let u=Qi.get(e);u.delete(t),u.size===0&&Qi.delete(e),l.settle(s)}return s}async function wG(e,t,n,r){let[o,i]=t.split("|"),s={},a=nl.get(e)??new Set;nl.set(e,a.add(s));try{let[l,u]=await Promise.all([fetch(n),fetch(r)]);if(!l.ok)throw new Error(`HTTP ${l.status} fetching metrics from ${n}`);if(!u.ok)throw new Error(`HTTP ${u.status} fetching atlas from ${r}`);let[c,d]=await Promise.all([l.json(),u.blob()]),f=O1(c),p=await createImageBitmap(d);_t.set(e,new Map(_t.get(e)).set(t,{font:f,bitmap:p})),gS(e,s),gn()}catch(l){throw gS(e,s),gn(),new Error(`weasel registerFont("${e}" ${o}/${i}): ${l instanceof Error?l.message:String(l)}`)}}function wS(e,t,n){let r=Qi.get(e);if(!r)return;let o=Yr(t,n),i=r.has(o)?[o]:[...r.keys()];for(let s of i){let{metricsUrl:a,atlasUrl:l}=r.get(s);xS(e,s,a,l).catch(()=>{})}}function Ay(e){let t=[];for(let n of e??[...vy]){if(typeof n!="string"){let{weight:r,style:o}=xG(n);t.push(...TS(n.family,r,o));continue}if(!vy.has(n))return Promise.reject(new Error(`weasel warmFonts: "${n}" was never registered.`));for(let[r,{metricsUrl:o,atlasUrl:i}]of[...Qi.get(n)??[]])xS(n,r,o,i);t.push(...PS(n))}return Promise.all(t).then(()=>{})}function PS(e){return[...Qr].filter(([t])=>t.startsWith(`${e}|`)).map(([,t])=>t)}function TS(e,t,n){let r=[],o=xy(e,t,n);o&&r.push(Ty(e,{weight:t,style:n}));let i=Yr(t,n);if(_t.get(e)?.has(i))return r;wS(e,t,n);let s=Qr.get(`${e}|${i}`);if(s)return[...r,s];if(_t.has(e)||Zi(e))return[...r,...PS(e)];if(o||by(e)||qi()!=="substitute")return r;let a=Ja()??SS();return a!==null&&a!==e?[...r,...TS(a,t,n)]:r}function Zi(e){return nl.has(e)||Qi.has(e)}function gS(e,t){let n=nl.get(e);n?.delete(t)&&n.size===0&&nl.delete(e)}function nd(e,t=400,n="normal"){if(Zi(e))return!0;let r=wy(e,t,n==="italic"?"italic":"normal");return r==="idle"||r==="loading"}function Ry(e,t,n,r){let o=rl(e,t,n);return o?(r.upload($i(e,t,n),o.bitmap),!0):!1}function bS(e,t,n,r=!1){if(by(e))return{entry:null,dynamicFace:ed(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"};let o=tl(e,t,n==="italic"?"italic":"normal");if(o)return{entry:null,outlineFace:o,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"outline"};if(nd(e,t,n))return td(e,t,n);let i=qi();if(i==="canvas")return cS(e),{entry:null,dynamicFace:ed(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"};if(i==="substitute"){let s=Ja()??SS();if(s!==null&&s!==e){if(_t.has(s)||Zc(s)||Zi(s)){let a=kS(s,t,n,!0,!1);if(a.entry!==null||a.dynamicFace!==void 0)return r||PG(e,t,n,s),{...a,substituted:{requested:e,resolved:s}};if(Zi(s))return td(e,t,n)}r||TG(e,t,n,s)}else s===e&&!r&&(_t.has(e)?SG(e,t,n):kG(e,t,n))}return{entry:null,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"atlas"}}function SS(){for(let e of vy)if(_t.has(e)||Zi(e))return e;return null}function td(e,t,n){return{entry:null,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"atlas"}}function PG(e,t,n,r){if(!Xr(`substituted|${e}|${t}|${n}`))return;let o=_t.has(e)?`has no variant matching ${t}/${n}, and none of its registered variants are close enough for the within-family chain to substitute \u2014 rendering with "${r}" instead. Bake that variant with registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026)`:`is not registered \u2014 rendering with "${r}" instead. Call registerFont("${e}", \u2026)`;console.warn(`weasel: font family "${e}" (${t}/${n}) ${o}. Advance widths will differ from the requested font. Use setFontFallbackPolicy('none') to make this a hard miss instead.`)}function TG(e,t,n,r){if(!Xr(`unusable-default|${e}|${t}|${n}`))return;let o=Ja()===r?"set via setDefaultFontFamily":"the first registered family, since setDefaultFontFamily was never called",i=_t.has(r)||Zc(r)?`has no variant that can serve ${t}/${n}`:"is not registered either";console.warn(`weasel: font family "${e}" (${t}/${n}) is not available, and the fallback family "${r}" (${o}) ${i} \u2014 this text will not render at all. Bake that variant with registerFont("${r}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a family that covers it.`)}function SG(e,t,n){if(!Xr(`self-unusable-default|${e}|${t}|${n}`))return;let r=Ja()===e?"set via setDefaultFontFamily":"the first registered family, since setDefaultFontFamily was never called";console.warn(`weasel: font family "${e}" (${t}/${n}) has no variant that can serve this request, and "${e}" is also the fallback family (${r}) \u2014 there is nothing left to fall back to, so this text will not render at all. Bake that variant with registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a different family.`)}function kG(e,t,n){Xr(`unregistered-default|${e}|${t}|${n}`)&&console.warn(`weasel: font family "${e}" (${t}/${n}) was never registered, and it is also the fallback family \u2014 setDefaultFontFamily("${e}") names a family with no registered variants at all, so there is nothing left to fall back to and this text will not render at all. Call registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a family you have registered.`)}function ky(e){return e>=600?"bold":"regular"}function bn(e,t,n){return kS(e,t,n,!1,!0)}function rd(e,t,n){if(qi()==="none")return null;try{return{entry:null,dynamicFace:ed(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"}}catch{return null}}function kS(e,t,n,r,o){wS(e,t,n);let i=Yr(t,n);if(Qr.size>0&&Qr.has(`${e}|${i}`)&&!_t.get(e)?.has(i))return td(e,t,n);let s=_t.get(e);if(!s||s.size===0)return Zi(e)?td(e,t,n):bS(e,t,n,r);let a=s.get(i);if(a)return o?yS(a,e,t,n):Jr(a,e,t,n,!1,!1);let l=ky(t),u=null;for(let[h,m]of s){let[g,b]=h.split("|"),x=Number(g);if(b!==n||ky(x)!==l)continue;let w=Math.abs(x-t);(u===null||w<u.distance||w===u.distance&&x>u.weight)&&(u={entry:m,weight:x,distance:w})}if(u)return Jr(u.entry,e,u.weight,n,!1,!1);let c=s.get(Yr(400,n));if(c)return Jr(c,e,400,n,t>=600,!1);let d=s.get(Yr(t,"normal"));if(d)return Jr(d,e,t,"normal",!1,n==="italic");let f=null;for(let[h,m]of s){let[g,b]=h.split("|"),x=Number(g);if(b!=="normal"||ky(x)!==l)continue;let w=Math.abs(x-t);(f===null||w<f.distance||w===f.distance&&x>f.weight)&&(f={entry:m,weight:x,distance:w})}if(f)return Jr(f.entry,e,f.weight,"normal",!1,n==="italic");let p=s.get(Yr(400,"normal"));return p?Jr(p,e,400,"normal",t>=600,n==="italic"):bS(e,t,n,r)}var vG=[[173,173],[847,847],[1564,1564],[4447,4448],[6068,6069],[6155,6159],[8203,8207],[8234,8238],[8288,8303],[12644,12644],[65024,65039],[65279,65279],[65440,65440],[65520,65528],[113824,113827],[119155,119162],[917504,921599]];function vS(e){return vG.some(([t,n])=>e>=t&&e<=n)}function Iy(e){return e.xadvance>0||e.width>0||e.page<0||vS(e.id)}function RS(e,t){let n=null,r=.5,o,i=()=>{let s=e.faceMetrics;if(s!==n){n=s;let a=s?.ascent!==void 0&&s.descent!==void 0;r=a?s.ascent*e.info.size:.5,o=a?s.descent*e.info.size:void 0}return o!==void 0};return{size:e.info.size,get base(){return e.common.base},get ascent(){return i()?r:e.common.base},get descent(){return i()?o:void 0},advanceOf:t,kernOf:(s,a)=>e.kerningMap.get(s)?.get(a)??0}}function AG(e){let t=e.faceMetrics?.descent;return{size:1,base:e.ascender,ascent:e.faceMetrics?.ascent??e.ascender,...t!==void 0?{descent:t}:{},advanceOf:n=>e.advanceOf(n),kernOf:(n,r)=>e.kernOf(n,r)}}function RG(e){return RS(e.font,t=>{let n=e.requestGlyph(t);return Iy(n)?n.xadvance:null})}var AS=new WeakMap;function Ny(e,t){let n=AS.get(e);return n||(n=t(e),AS.set(e,n)),n}function es(e){if(e.outlineFace)return Ny(e.outlineFace,AG);if(e.entry)return Ny(e.entry.font,t=>RS(t,n=>t.charMap.get(n)?.xadvance??null));if(e.dynamicFace)return Ny(e.dynamicFace,RG)}var NG=/\p{Emoji_Presentation}|\p{Extended_Pictographic}\uFE0F|\uFE0F\u20E3/u;function NS(e){return e.length===1&&e.charCodeAt(0)<8986?!1:NG.test(e)&&!e.includes("\uFE0E")}function IS(e,t){if(!Xr(`missing-glyph|${e}|${t}`))return;let n=String.fromCodePoint(t);console.warn(`weasel: no glyph for U+${t.toString(16).toUpperCase().padStart(4,"0")} (${JSON.stringify(n)}) in "${e}", and the dynamic tier could not rasterize it \u2014 skipping the character. Bake it into the atlas, or call registerCanvasFont("${e}") to serve missing codepoints from installed fonts.`)}var IG=["unusable-default","self-unusable-default","unregistered-default"];function Ey(e,t,n){if(nd(e,t,n))return;let r=`${e}|${t}|${n}`;IG.some(o=>B1(`${o}|${r}`))||Xr(`no-metrics|${r}`)&&console.warn(`weasel: no metrics for "${e}" ${t}/${n} \u2014 neither an atlas nor an outline face resolved, so every run set in it lays out as nothing. Register it with registerFont / registerCanvasFont / registerFontOutlines. If you did, check for a duplicated @weasel-js/font in node_modules \u2014 its registry is module state, so a second copy is a second, empty one.`)}function ol(e,t,n){let r=es(e);if(!r)return null;if(e.outlineFace){let a=r.advanceOf(t);return a===null?null:ES(n,e,r,a,null,null)}let o=e.dynamicFace,i=e.entry?.font??o?.font,s=e.entry?i?.charMap.get(t):o?.requestGlyph(t);return!i||!s||o&&!Iy(s)?null:ES(n,e,r,s.xadvance,i,s)}function ES(e,t,n,r,o,i){return e?(e.resolved=t,e.metrics=n,e.advance=r,e.font=o,e.glyph=i,e):{resolved:t,metrics:n,advance:r,font:o,glyph:i}}function il(e,t,n,r,o,i=!0,s){let a=ol(e,o,s);if(a)return a;let l=rd(t,n,r),u=l&&ol(l,o,s);return u||(i&&IS(e.resolved.family,o),null)}function My(e,t,n,r,o){if(!NS(o))return null;let i=e.dynamicFace?e:rd(t,n,r),s=i?.dynamicFace,a=i&&es(i),l=s?.requestCluster(o);return!i||!s||!a||!l?null:{resolved:i,metrics:a,advance:l.xadvance,font:s.font,glyph:l}}var Cy=1,Oy=2,MS=.2,EG=.3,id=1;function Fy(e,t,n){return .5*(e[0]/t+e[1]/n)>MS*.9}var MG=`
53
- float area = smoothstep(${MS.toFixed(2)}, ${EG.toFixed(2)}, fieldPerPx);
52
+ `,py=["u_proj","u_model","u_origin","u_color","u_alpha","u_colorMatrix","u_colorBias"],G1=["a_position"],U1=["a_position","a_vertexColor"];var nl=e=>typeof e=="number"&&Number.isFinite(e);function W1(e){if(e===void 0)return;if(typeof e!="object"||e===null)throw new Error("parseBmFont: faceMetrics must be an object");let t=e,n={};if(t.ascent!==void 0||t.descent!==void 0){if(!nl(t.ascent)||!nl(t.descent)||t.ascent+t.descent<=0)throw new Error("parseBmFont: malformed faceMetrics.ascent/descent");n.ascent=t.ascent,n.descent=t.descent}let r=(o,i,s,a)=>{let l=t[o];if(l===void 0)return;let u=l;if(typeof u!="object"||u===null||!nl(u[i])||!nl(u[s])||u[a]<=0)throw new Error(`parseBmFont: malformed faceMetrics.${o}`);n[o]={[i]:u[i],[s]:u[s]}};r("underline","offset","thickness","thickness"),r("strikethrough","offset","thickness","thickness"),r("superscript","size","shift","size"),r("subscript","size","shift","size");for(let o of["xHeight","capHeight"]){let i=t[o];if(i!==void 0){if(!nl(i)||i<=0)throw new Error(`parseBmFont: malformed faceMetrics.${o}`);n[o]=i}}return Object.keys(n).length>0?n:void 0}function Yo(e){return e.outlineFace?.faceMetrics??e.entry?.font.faceMetrics}function V1(e){if(typeof e!="object"||e===null)throw new Error("parseBmFont: expected object");let t=e;if(!t.info||typeof t.info!="object")throw new Error("parseBmFont: missing info");if(!t.common||typeof t.common!="object")throw new Error("parseBmFont: missing common");if(!Array.isArray(t.chars))throw new Error("parseBmFont: chars must be an array");let n=t.info,r=t.common,o=[["info.size",n.size],["common.scaleW",r.scaleW],["common.scaleH",r.scaleH]];for(let[d,f]of o)if(typeof f!="number"||!(f>0)||!Number.isFinite(f))throw new Error(`parseBmFont: ${d} must be a positive number`);if(typeof r.base!="number"||!Number.isFinite(r.base))throw new Error("parseBmFont: common.base must be a number");let i=t.chars,s=Array.isArray(t.kernings)?t.kernings:[],a=new Map;for(let d of i)a.set(d.id,d);let l=new Map;for(let d of s){let f=l.get(d.first);f||(f=new Map,l.set(d.first,f)),f.set(d.second,d.amount)}let u=W1(t.faceMetrics),c=t.distanceField?.distanceRange;return{info:n,common:r,chars:i,kernings:s,charMap:a,kerningMap:l,...u?{faceMetrics:u}:{},...typeof c=="number"&&c>0?{distanceRange:c}:{}}}var Zi={family:"",weight:NaN,style:"",key:""};function es(e,t,n){return Zi.family===e&&Zi.weight===t&&Zi.style===n||(Zi={family:e,weight:t,style:n,key:`${e}|${t}|${n}`}),Zi.key}var z1=new Map;function Qr(e,t){let n=z1.get(t);n===void 0&&z1.set(t,n=new Map);let r=n.get(e);return r===void 0&&(r=`${e}|${t}`,n.size<1024&&n.set(e,r)),r}function Me(){let e=new Set;return{subscribe(t){return e.add(t),()=>{e.delete(t)}},emit(...t){if(e.size!==0){for(let n of[...e])if(e.has(n))try{n(...t)}catch(r){console.error("weasel: a subscriber threw",r)}}},get size(){return e.size}}}function xt(){let e=new Map,t=Me(),n=0,r=null;function o(){n++,t.emit()}let i={get:a=>e.get(a)?.at(-1)?.value,has:a=>e.has(a),entries(){if(r?.version===n)return r.entries;let a=[];for(let[l,u]of e){let c=u.at(-1);a.push(Object.freeze({key:l,live:c,value:c.value,source:c.source,shadowed:Object.freeze(u.slice(0,-1))}))}return r={version:n,entries:Object.freeze(a)},r.entries},subscribe:t.subscribe,getVersion:()=>n};function s(a,l){let u=e.get(a),c=u?u.lastIndexOf(l):-1;return c===-1?!1:(u.splice(c,1),u.length===0&&e.delete(a),o(),!0)}return{...i,reflection:i,release:s,push(a,l,u){let c=Object.freeze({value:l,source:u?.source}),d=e.get(a);return d?d.push(c):e.set(a,[c]),o(),()=>{s(a,c)}},set(a,l,u){let c=Object.freeze({value:l,source:u?.source}),d=e.get(a);d?d[d.length-1]=c:e.set(a,[c]),o()},delete(a){return e.delete(a)?(o(),!0):!1},clear(){e.size!==0&&(e.clear(),o())},bump:o}}function Qt(){try{return!1}catch{return!0}}function ts(e){return e===Object.prototype||e===null||Object.getPrototypeOf(e)===null}function Zt(e){return typeof e=="object"&&e!==null&&ts(Object.getPrototypeOf(e))}function Zr(e,t,n={}){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((o,i)=>Zr(o,t[i],n));if(!Zt(e)||!Zt(t))return!1;if(n.undefinedAsAbsent)return[...new Set([...Object.keys(e),...Object.keys(t)])].every(o=>Zr(e[o],t[o],n));let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(o=>Object.hasOwn(t,o)&&Zr(e[o],t[o],n))}function Yc(e,t,n=(r,o)=>r===o){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}var K1=Me(),hy=0;function qo(){return hy}var j1=0;function rl(){return j1}function bn(){hy++,j1++,K1.emit()}function $1(){hy++,K1.emit()}var uG="substitute",cG=null;function ns(){return uG}function ol(){return cG}var my=new Set;function eo(e){return my.has(e)?!1:(my.add(e),!0)}function Y1(e){return my.has(e)}var il=class{constructor(t){this.format=t}format;pages=[];uploaded=new WeakMap;textureId(t){return`${this.format.idPrefix}${t}`}blit(t,n,r,o,i,s){let a=this.format.channels;for(;this.pages.length<=t;)this.pages.push({data:new Uint8Array(1024*1024*a),version:0,patches:[]});let l=this.pages[t];for(let u=0;u<i;u++)l.data.set(s.subarray(u*o*a,(u+1)*o*a),((r+u)*1024+n)*a);l.version++,l.patches.push({seq:l.version,x:n,y:r,w:o,h:i})}clear(){for(let t of this.pages)t.data.fill(0),t.version++,t.patches=[{seq:t.version,x:0,y:0,w:1024,h:1024}]}sync(t,n){let r=this.pages[n];if(!r)return!1;let o=this.format.channels,i=this.textureId(n),s=this.uploaded.get(t);if(s||(s=new Map,this.uploaded.set(t,s)),!t.has(i))return this.format.upload(t,i,r.data),s.set(n,r.version),!0;let a=s.get(n)??0;if(a>=r.version)return!0;for(let l of r.patches){if(l.seq<=a)continue;let u=new Uint8Array(l.w*l.h*o);for(let c=0;c<l.h;c++){let d=((l.y+c)*1024+l.x)*o;u.set(r.data.subarray(d,d+l.w*o),c*l.w*o)}this.format.patch(t,i,l.x,l.y,l.w,l.h,u)}return s.set(n,r.version),!0}},qc=new il({channels:1,idPrefix:"weasel-dyn-sdf-page-",upload:(e,t,n)=>e.uploadR8(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageR8(t,n,r,o,i,s)}),Xc=new il({channels:4,idPrefix:"weasel-dyn-color-page-",upload:(e,t,n)=>e.uploadRGBA(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageRGBA(t,n,r,o,i,s)}),sl=new il({channels:4,idPrefix:"weasel-dyn-color-sharp-page-",upload:(e,t,n)=>e.uploadRGBA(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageRGBA(t,n,r,o,i,s)});function q1(e,t,n,r,o,i){qc.blit(e,t,n,r,o,i)}function X1(e,t,n,r,o,i){Xc.blit(e,t,n,r,o,i)}function J1(e,t,n,r,o,i){sl.blit(e,t,n,r,o,i)}function Q1(){qc.clear(),Xc.clear(),sl.clear()}function Z1(){sl.clear()}function Jc(e){return qc.textureId(e)}function Qc(e){return Xc.textureId(e)}function Zc(e){return sl.textureId(e)}function ed(e,t){return qc.sync(e,t)}function td(e,t){return Xc.sync(e,t)}function nd(e,t){return sl.sync(e,t)}var rd=class{constructor(t,n){this.pageSize=t;this.maxPages=n}pageSize;maxPages;pages=[];get pageCount(){return this.pages.length}fits(t,n){return t<=this.pageSize&&n<=this.pageSize}alloc(t,n){if(!this.fits(t,n))return null;for(let r=0;r<this.pages.length;r++){let o=this.allocInPage(this.pages[r],t,n);if(o)return{page:r,...o}}if(this.pages.length<this.maxPages){let r={shelves:[],nextY:0};this.pages.push(r);let o=this.allocInPage(r,t,n);if(o)return{page:this.pages.length-1,...o}}return null}allocInPage(t,n,r){for(let o of t.shelves)if(r<=o.height&&o.x+n<=this.pageSize){let i=o.x;return o.x+=n,{x:i,y:o.y}}if(t.nextY+r<=this.pageSize){let o={y:t.nextY,height:r,x:n};return t.shelves.push(o),t.nextY+=r,{x:0,y:o.y}}return null}};function eS(e,t,n,r,o){n[0]=0,r[0]=-1e20,r[1]=1e20;let i=0;for(let s=1;s<o;s++){let a=(e[s]+s*s-(e[n[i]]+n[i]*n[i]))/(2*s-2*n[i]);for(;a<=r[i];)i--,a=(e[s]+s*s-(e[n[i]]+n[i]*n[i]))/(2*s-2*n[i]);i++,n[i]=s,r[i]=a,r[i+1]=1e20}i=0;for(let s=0;s<o;s++){for(;r[i+1]<s;)i++;t[s]=(s-n[i])*(s-n[i])+e[n[i]]}}function tS(e,t,n,r,o,i,s){for(let a=0;a<t;a++){for(let l=0;l<n;l++)r[l]=e[l*t+a];eS(r,o,i,s,n);for(let l=0;l<n;l++)e[l*t+a]=o[l]}for(let a=0;a<n;a++){for(let l=0;l<t;l++)r[l]=e[a*t+l];eS(r,o,i,s,t);for(let l=0;l<t;l++)e[a*t+l]=o[l]}}function nS(e,t,n,r,o){let i=t*n,s=new Float64Array(i),a=new Float64Array(i),l=Math.max(t,n),u=new Float64Array(l),c=new Float64Array(l),d=new Int32Array(l),f=new Float64Array(l+1);for(let h=0;h<i;h++){let m=e[h]/255;s[h]=m===1?0:m===0?1e20:Math.max(0,.5-m)**2,a[h]=m===1?1e20:m===0?0:Math.max(0,m-.5)**2}tS(s,t,n,u,c,d,f),tS(a,t,n,u,c,d,f);let p=new Uint8Array(i);for(let h=0;h<i;h++){let m=Math.sqrt(s[h])-Math.sqrt(a[h]),g=Math.round(255-255*(m/r+o));p[h]=g<0?0:g>255?255:g}return p}var rs=8,sS=.5,Jo=16,Xo=()=>({packer:new rd(1024,4),settled:!0,reclaimScheduled:!1}),xy=Xo(),wy=Xo(),al=Xo(),Gn=[],yy=!1,gy=Jo,by=0,aS=()=>{},Py=()=>{},rS=new Set;function lS(e){aS=e}function uS(e){Py=e}function os(e,t,n=!1){if(by++,t.width===0||t.height===0){e.page=0;return}gy>0?(gy--,dS(e,t,n)):(Gn.push({char:e,raster:t,sharp:n}),fS())}function cS(e){Gn=Gn.filter(t=>!e.has(t.char))}function dS(e,t,n){let r="rgba"in t,o=n?al:r?wy:xy,i=o.packer.alloc(t.width,t.height);if(!i){dG(o,t,n?pG:fG);return}if(r&&n)J1(i.page,i.x,i.y,t.width,t.height,t.rgba);else if(r)X1(i.page,i.x,i.y,t.width,t.height,t.rgba);else{let s=nS(t.alpha,t.width,t.height,rs,sS);q1(i.page,i.x,i.y,t.width,t.height,s)}e.x=i.x,e.y=i.y,e.width=t.width,e.height=t.height,e.page=i.page}function dG(e,t,n){if(!e.packer.fits(t.width,t.height))oS("weasel DynamicGlyphAtlas: a glyph is larger than a page and will not render.");else if(e.settled)e.reclaimScheduled||(e.reclaimScheduled=!0,setTimeout(n,0));else{if(e===al)return;oS(`weasel DynamicGlyphAtlas: more glyphs are in use at once than its pages hold (${4} \xD7 ${1024}\xB2); the rest will not render.`)}}function oS(e){rS.has(e)||(rS.add(e),console.warn(e))}function fG(){xy={...Xo(),settled:!1},wy={...Xo(),settled:!1},al={...Xo(),settled:!1},Gn=[],Q1(),aS(),Py(),bn()}function pG(){al={...Xo(),settled:!1},Gn=Gn.filter(e=>!e.sharp),Z1(),Py(),bn()}function fS(){yy||(yy=!0,setTimeout(hG,0))}function hG(){yy=!1;let e=0;for(;Gn.length>0&&e<Jo;){let t=Gn.shift();t.char.page===-1&&(dS(t.char,t.raster,t.sharp),e++)}Gn.length>0&&fS(),$1()}function od(e=Jo){gy=e,by===0&&Gn.length===0&&(xy.settled=!0,wy.settled=!0,al.settled=!0),by=0}function Ty(e){return e.trim().replace(/^(["'])(.*)\1$/,"$2").toLowerCase()}function pS(e){let t=typeof document>"u"?void 0:document.fonts;if(!t?.addEventListener)return()=>{};let n=r=>{let o=r.fontfaces??[];o.length>0&&e(o.map(i=>i.family))};return t.addEventListener("loadingdone",n),()=>t.removeEventListener("loadingdone",n)}function hS(e){return/[,"']/.test(e)?e:mG.has(e.trim().toLowerCase())?e.trim():JSON.stringify(e)}var mG=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]);var He=48,en=8;function yG(e){let t=[1/0,1/0,-1/0,-1/0],n=e.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[];for(let r=0;r+1<n.length;r+=2){let o=Number(n[r]),i=Number(n[r+1]);o<t[0]&&(t[0]=o),i<t[1]&&(t[1]=i),o>t[2]&&(t[2]=o),i>t[3]&&(t[3]=i)}return t}var gG=240;function bG(e){let t=new Uint8ClampedArray(e.length),n=!1;for(let r=0;r<e.length;r+=4){let o=e[r+3];if(o===0)continue;let i=e[r],s=e[r+1],a=e[r+2];o>=128&&Math.min(i,s,a)<gG&&(n=!0),t[r]=Math.round(i*o/255),t[r+1]=Math.round(s*o/255),t[r+2]=Math.round(a*o/255),t[r+3]=o}return n?t:null}var id=1e3;function xG(e,t,n,r=He){return`${t==="italic"?"italic ":""}${e} ${r}px ${hS(n)}`}function mS(){let e;if(typeof OffscreenCanvas<"u")e=new OffscreenCanvas(He*3,He*3);else if(typeof document<"u")e=document.createElement("canvas"),e.width=He*3,e.height=He*3;else throw new Error("weasel DynamicGlyphAtlas: no canvas available for glyph rasterization");let t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw new Error("weasel DynamicGlyphAtlas: 2D context unavailable");function n(o,i,s,a=He){t.font=xG(i,s,o,a),t.textBaseline="alphabetic",t.textAlign="left"}function r(o,i,s,a,l=He){n(o,i,s,l);let u=t.measureText(a),c=u.width,d=Math.ceil(u.actualBoundingBoxLeft??0),f=Math.ceil(u.actualBoundingBoxRight??c),p=Math.ceil(u.actualBoundingBoxAscent??l*.8),h=Math.ceil(u.actualBoundingBoxDescent??l*.2),m=d+f,g=p+h;if(m<=0||g<=0)return{data:new Uint8ClampedArray(0),width:0,height:0,left:0,top:0,advance:c};let b=m+2*en,x=g+2*en;return(e.width<b||e.height<x)&&(e.width=Math.max(e.width,b),e.height=Math.max(e.height,x),n(o,i,s,l)),t.clearRect(0,0,b,x),t.fillStyle="#fff",t.fillText(a,en+d,en+p),{data:t.getImageData(0,0,b,x).data,width:b,height:x,left:-(d+en),top:p+en,advance:c}}return{faceMetrics(o,i,s){n(o,i,s,id);let a=t.measureText("Hg"),l=He/id;return{ascent:(a.fontBoundingBoxAscent??id*.8)*l,descent:(a.fontBoundingBoxDescent??id*.2)*l}},rasterize(o,i,s,a){let{data:l,...u}=r(o,i,s,String.fromCodePoint(a)),c=new Uint8ClampedArray(u.width*u.height);for(let d=0;d<c.length;d++)c[d]=l[d*4+3];return{...u,alpha:c}},rasterizePath(o){let[i,s,a,l]=yG(o),u={width:0,height:0,alpha:new Uint8ClampedArray(0),left:0,top:0,advance:0};if(!(a>i&&l>s))return u;let c=Math.floor(i*He),d=Math.floor(s*He),f=Math.ceil(a*He)-c+2*en,p=Math.ceil(l*He)-d+2*en;(e.width<f||e.height<p)&&(e.width=Math.max(e.width,f),e.height=Math.max(e.height,p)),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,f,p),t.setTransform(He,0,0,He,en-c,en-d),t.fillStyle="#fff",t.fill(new Path2D(o)),t.setTransform(1,0,0,1,0,0);let h=t.getImageData(0,0,f,p).data,m=new Uint8ClampedArray(f*p);for(let g=0;g<m.length;g++)m[g]=h[g*4+3];return{width:f,height:p,alpha:m,left:c-en,top:en-d,advance:0}},rasterizeColor(o,i,s,a,l){let{data:u,...c}=r(o,i,s,a,l),d=bG(u);return d&&{...c,rgba:d}}}}var Sy=3,ky=new WeakMap,sd=0;uS(()=>{sd++});function yS(e,t,n){ky.set(e,{raster:n,base:t,levels:[],generation:sd})}function vy(e){return e.generation!==sd&&(e.levels=[],e.generation=sd),e.levels}function gS(e){let t=ky.get(e);return t?vy(t).flatMap(n=>n?[n.glyph]:[]):[]}function wG(e,t){let n=vy(e),r=n[t];if(r!==void 0)return r;let o=2**t,i=e.raster(He*o),s=i&&{level:t,glyph:{id:0,x:0,y:0,width:0,height:0,xoffset:i.left/o,yoffset:e.base-i.top/o,xadvance:i.advance/o,page:-1,color:!0}};return n[t]=s,s&&i&&os(s.glyph,i,!0),s}function ad(e,t){let n=ky.get(e);if(!n||!(t>1))return null;let r=Math.min(Sy,Math.ceil(Math.log2(t)));wG(n,r);let o=vy(n);for(let i=r;i>0;i--){let s=o[i];if(s&&s.glyph.page>=0)return s}return null}var ld=new Set,ud=new Set,cd=new Map,Ay=null,PG=null;function bS(e){e.font.charMap.clear(),e.font.chars.length=0,e.clusters.clear(),e.shaped.clear()}lS(()=>{for(let e of cd.values())bS(e)});function xS(){return Ay||(Ay=mS()),Ay}function dd(e){return ld.has(e)?!ud.has(e)||ns()==="canvas":!1}function wS(e){ld.has(e)&&!ud.has(e)||(ld.add(e),ud.add(e))}function Ry(e){return ld.has(e)&&!ud.has(e)}function fd(e,t,n){let r=`${e}|${t}|${n}`,o=cd.get(r);if(o)return o;let i=xS(),s={info:{face:e,size:He},common:{lineHeight:0,base:0,scaleW:1024,scaleH:1024},chars:[],kernings:[],charMap:new Map,kerningMap:new Map},a=(d,f)=>({id:d,x:0,y:0,width:0,height:0,xoffset:f.left,yoffset:s.common.base-f.top,xadvance:f.advance,page:-1}),l=new Map,u=new Map,c={family:e,weight:t,style:n,font:s,clusters:l,shaped:u,requestGlyph(d){let f=s.charMap.get(d);if(f)return f;let p=i.rasterize(e,t,n,d),h=a(d,p);return s.charMap.set(d,h),s.chars.push(h),os(h,p),h},requestCluster(d){let f=l.get(d);if(f!==void 0)return f;let p=i.rasterizeColor?.(e,t,n,d)??null,h=p&&{...a(d.codePointAt(0),p),color:!0};return l.set(d,h),h&&p&&(os(h,p),yS(h,s.common.base,m=>i.rasterizeColor?.(e,t,n,d,m)??null)),h},requestShaped(d,f){let p=u.get(d);if(p!==void 0)return p;let h=typeof Path2D>"u"?null:i.rasterizePath?.(f)??null,m=h&&a(0,h);return u.set(d,m),m&&h&&os(m,h),m}};return PS(c),cd.set(r,c),PG??=pS(TG),c}function PS(e){let{font:t}=e,n=xS().faceMetrics(e.family,e.weight,e.style);t.common.lineHeight=Math.round(n.ascent+n.descent),t.common.base=Math.round(n.ascent),t.faceMetrics={ascent:n.ascent/He,descent:n.descent/He},bS(e)}function TG(e){let t=e&&new Set(e.map(Ty)),n=new Set,r=0;for(let o of cd.values())if(!(t&&!o.family.split(",").some(i=>t.has(Ty(i))))){for(let i of o.font.chars)n.add(i);for(let i of o.shaped.values())i&&n.add(i);for(let i of o.clusters.values())if(i){n.add(i);for(let s of gS(i))n.add(s)}PS(o),r++}r!==0&&(cS(n),bn())}var dr=xt(),SG=dr.reflection;function Qo(e,t,n){return`${e}|${t}|${n}`}function kG(e){return{weight:e.weight??400,style:e.style??"normal"}}function Ny(e,t=400,n="normal"){return dr.has(Qo(e,t,n))}function Iy(e,t=400,n="normal"){return dr.get(Qo(e,t,n))?.status??null}function vG(e){let t="",n=0;for(let r=1;r<e.length;r++){let o=e[r];o!=="M"&&o!=="m"||(t+=TS(e.slice(n,r)),n=r)}return t+TS(e.slice(n))}function TS(e){let t=e.trimEnd();if(t.length===0)return"";let n=t[t.length-1];return n==="Z"||n==="z"?t:`${t}Z`}function Ey(e,t,n,r){let o=dr.get(Qo(e,t,n));if(!o)return null;if(o.status==="idle")return Cy(o),null;if(o.status!=="ready")return null;let i=o.glyphs.get(r);if(i!==void 0)return i;let s=null;try{let a=o.face.glyphD(r);s=a===null?null:vG(a)}catch(a){kS(`glyph|${Qo(e,t,n)}`,`weasel: outline face "${e}" (${t}/${n}) could not produce a glyph for U+${r.toString(16).toUpperCase().padStart(4,"0")} \u2014 ${a instanceof Error?a.message:String(a)}. Falling back to the SDF tier.`)}return o.glyphs.set(r,s),s}function ll(e,t,n){let r=dr.get(Qo(e,t,n));return r?r.status==="idle"?(Cy(r),null):r.status==="ready"?r.face:null:null}async function My(e,t={}){let{weight:n,style:r}=kG(t),o=dr.get(Qo(e,n,r));return o?(await Cy(o),o.status):null}function Cy(e){return e.load??=AG(e),e.load}async function AG(e){e.status="loading",dr.bump();try{let t=await IG(e.source);NG(e,t),e.face=await e.parser(t),e.status="ready",dr.bump(),bn()}catch(t){e.status="failed",dr.bump(),bn(),kS(`load|${Qo(e.family,e.weight,e.style)}`,`weasel registerFontOutlines("${e.family}" ${e.weight}/${e.style}): ${t instanceof Error?t.message:String(t)}. Large text in this face keeps rendering from the SDF tier.`)}}var RG=null;function NG(e,t){try{RG?.(e,t)}catch{}}async function IG(e){let t=typeof e=="function"?await e():e;if(typeof t=="string"){let n=await fetch(t);if(!n.ok)throw new Error(`HTTP ${n.status} fetching ${t}`);return n.arrayBuffer()}return t instanceof ArrayBuffer?t:t.arrayBuffer()}var SS=new Set;function kS(e,t){SS.has(e)||(SS.add(e),console.warn(t))}function to(e,t,n,r,o,i){return{entry:e,resolved:{family:t,weight:n,style:r},synthetic:{bold:o,italic:i},source:"atlas"}}var vS=new WeakMap;function AS(e,t,n,r){let o=vS.get(e);if(o!==void 0&&o.resolved.family===t&&o.resolved.weight===n&&o.resolved.style===r)return o;let i=to(e,t,n,r,!1,!1);return Object.freeze(i.resolved),Object.freeze(i.synthetic),vS.set(e,Object.freeze(i)),i}var Dt=xt(),MG=Dt.reflection;function CG(e){return{weight:e.weight??400,style:e.style??"normal"}}var ul=new Map,no=new Map,is=new Map,Fy=new Set;function cl(e,t=400,n="normal"){return Dt.get(e)?.get(Qr(t,n))??null}function IS(e,t,n,r){let o=`${e}|${t}`,i=no.get(o);if(i)return i;let s=OG(e,t,n,r);no.set(o,s);let a=()=>{no.get(o)===s&&no.delete(o)};s.then(a,a);let l=is.get(e)?.get(t);if(l){let u=is.get(e);u.delete(t),u.size===0&&is.delete(e),l.settle(s)}return s}async function OG(e,t,n,r){let[o,i]=t.split("|"),s={},a=ul.get(e)??new Set;ul.set(e,a.add(s));try{let[l,u]=await Promise.all([fetch(n),fetch(r)]);if(!l.ok)throw new Error(`HTTP ${l.status} fetching metrics from ${n}`);if(!u.ok)throw new Error(`HTTP ${u.status} fetching atlas from ${r}`);let[c,d]=await Promise.all([l.json(),u.blob()]),f=V1(c),p=await createImageBitmap(d);Dt.set(e,new Map(Dt.get(e)).set(t,{font:f,bitmap:p})),RS(e,s),bn()}catch(l){throw RS(e,s),bn(),new Error(`weasel registerFont("${e}" ${o}/${i}): ${l instanceof Error?l.message:String(l)}`)}}function ES(e,t,n){let r=is.get(e);if(!r)return;let o=Qr(t,n),i=r.has(o)?[o]:[...r.keys()];for(let s of i){let{metricsUrl:a,atlasUrl:l}=r.get(s);IS(e,s,a,l).catch(()=>{})}}function Ly(e){let t=[];for(let n of e??[...Fy]){if(typeof n!="string"){let{weight:r,style:o}=CG(n);t.push(...CS(n.family,r,o));continue}if(!Fy.has(n))return Promise.reject(new Error(`weasel warmFonts: "${n}" was never registered.`));for(let[r,{metricsUrl:o,atlasUrl:i}]of[...is.get(n)??[]])IS(n,r,o,i);t.push(...MS(n))}return Promise.all(t).then(()=>{})}function MS(e){return[...no].filter(([t])=>t.startsWith(`${e}|`)).map(([,t])=>t)}function CS(e,t,n){let r=[],o=Ny(e,t,n);o&&r.push(My(e,{weight:t,style:n}));let i=Qr(t,n);if(Dt.get(e)?.has(i))return r;ES(e,t,n);let s=no.get(`${e}|${i}`);if(s)return[...r,s];if(Dt.has(e)||ss(e))return[...r,...MS(e)];if(o||Ry(e)||ns()!=="substitute")return r;let a=ol()??OS();return a!==null&&a!==e?[...r,...CS(a,t,n)]:r}function ss(e){return ul.has(e)||is.has(e)}function RS(e,t){let n=ul.get(e);n?.delete(t)&&n.size===0&&ul.delete(e)}function hd(e,t=400,n="normal"){if(ss(e))return!0;let r=Iy(e,t,n==="italic"?"italic":"normal");return r==="idle"||r==="loading"}function _y(e,t,n,r){let o=cl(e,t,n);return o?(r.upload(es(e,t,n),o.bitmap),!0):!1}function NS(e,t,n,r=!1){if(Ry(e))return{entry:null,dynamicFace:fd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"};let o=ll(e,t,n==="italic"?"italic":"normal");if(o)return{entry:null,outlineFace:o,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"outline"};if(hd(e,t,n))return pd(e,t,n);let i=ns();if(i==="canvas")return wS(e),{entry:null,dynamicFace:fd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"};if(i==="substitute"){let s=ol()??OS();if(s!==null&&s!==e){if(Dt.has(s)||dd(s)||ss(s)){let a=FS(s,t,n,!0,!1);if(a.entry!==null||a.dynamicFace!==void 0)return r||FG(e,t,n,s),{...a,substituted:{requested:e,resolved:s}};if(ss(s))return pd(e,t,n)}r||LG(e,t,n,s)}else s===e&&!r&&(Dt.has(e)?_G(e,t,n):DG(e,t,n))}return{entry:null,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"atlas"}}function OS(){for(let e of Fy)if(Dt.has(e)||ss(e))return e;return null}function pd(e,t,n){return{entry:null,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"atlas"}}function FG(e,t,n,r){if(!eo(`substituted|${e}|${t}|${n}`))return;let o=Dt.has(e)?`has no variant matching ${t}/${n}, and none of its registered variants are close enough for the within-family chain to substitute \u2014 rendering with "${r}" instead. Bake that variant with registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026)`:`is not registered \u2014 rendering with "${r}" instead. Call registerFont("${e}", \u2026)`;console.warn(`weasel: font family "${e}" (${t}/${n}) ${o}. Advance widths will differ from the requested font. Use setFontFallbackPolicy('none') to make this a hard miss instead.`)}function LG(e,t,n,r){if(!eo(`unusable-default|${e}|${t}|${n}`))return;let o=ol()===r?"set via setDefaultFontFamily":"the first registered family, since setDefaultFontFamily was never called",i=Dt.has(r)||dd(r)?`has no variant that can serve ${t}/${n}`:"is not registered either";console.warn(`weasel: font family "${e}" (${t}/${n}) is not available, and the fallback family "${r}" (${o}) ${i} \u2014 this text will not render at all. Bake that variant with registerFont("${r}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a family that covers it.`)}function _G(e,t,n){if(!eo(`self-unusable-default|${e}|${t}|${n}`))return;let r=ol()===e?"set via setDefaultFontFamily":"the first registered family, since setDefaultFontFamily was never called";console.warn(`weasel: font family "${e}" (${t}/${n}) has no variant that can serve this request, and "${e}" is also the fallback family (${r}) \u2014 there is nothing left to fall back to, so this text will not render at all. Bake that variant with registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a different family.`)}function DG(e,t,n){eo(`unregistered-default|${e}|${t}|${n}`)&&console.warn(`weasel: font family "${e}" (${t}/${n}) was never registered, and it is also the fallback family \u2014 setDefaultFontFamily("${e}") names a family with no registered variants at all, so there is nothing left to fall back to and this text will not render at all. Call registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a family you have registered.`)}function Oy(e){return e>=600?"bold":"regular"}function xn(e,t,n){return FS(e,t,n,!1,!0)}function md(e,t,n){if(ns()==="none")return null;try{return{entry:null,dynamicFace:fd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"}}catch{return null}}function FS(e,t,n,r,o){ES(e,t,n);let i=Qr(t,n);if(no.size>0&&no.has(`${e}|${i}`)&&!Dt.get(e)?.has(i))return pd(e,t,n);let s=Dt.get(e);if(!s||s.size===0)return ss(e)?pd(e,t,n):NS(e,t,n,r);let a=s.get(i);if(a)return o?AS(a,e,t,n):to(a,e,t,n,!1,!1);let l=Oy(t),u=null;for(let[h,m]of s){let[g,b]=h.split("|"),x=Number(g);if(b!==n||Oy(x)!==l)continue;let w=Math.abs(x-t);(u===null||w<u.distance||w===u.distance&&x>u.weight)&&(u={entry:m,weight:x,distance:w})}if(u)return to(u.entry,e,u.weight,n,!1,!1);let c=s.get(Qr(400,n));if(c)return to(c,e,400,n,t>=600,!1);let d=s.get(Qr(t,"normal"));if(d)return to(d,e,t,"normal",!1,n==="italic");let f=null;for(let[h,m]of s){let[g,b]=h.split("|"),x=Number(g);if(b!=="normal"||Oy(x)!==l)continue;let w=Math.abs(x-t);(f===null||w<f.distance||w===f.distance&&x>f.weight)&&(f={entry:m,weight:x,distance:w})}if(f)return to(f.entry,e,f.weight,"normal",!1,n==="italic");let p=s.get(Qr(400,"normal"));return p?to(p,e,400,"normal",t>=600,n==="italic"):NS(e,t,n,r)}var BG=[[173,173],[847,847],[1564,1564],[4447,4448],[6068,6069],[6155,6159],[8203,8207],[8234,8238],[8288,8303],[12644,12644],[65024,65039],[65279,65279],[65440,65440],[65520,65528],[113824,113827],[119155,119162],[917504,921599]];function LS(e){return BG.some(([t,n])=>e>=t&&e<=n)}function By(e){return e.xadvance>0||e.width>0||e.page<0||LS(e.id)}function DS(e,t){let n=null,r=.5,o,i=()=>{let s=e.faceMetrics;if(s!==n){n=s;let a=s?.ascent!==void 0&&s.descent!==void 0;r=a?s.ascent*e.info.size:.5,o=a?s.descent*e.info.size:void 0}return o!==void 0};return{size:e.info.size,get base(){return e.common.base},get ascent(){return i()?r:e.common.base},get descent(){return i()?o:void 0},advanceOf:t,kernOf:(s,a)=>e.kerningMap.get(s)?.get(a)??0}}function HG(e){let t=e.faceMetrics?.descent;return{size:1,base:e.ascender,ascent:e.faceMetrics?.ascent??e.ascender,...t!==void 0?{descent:t}:{},advanceOf:n=>e.advanceOf(n),kernOf:(n,r)=>e.kernOf(n,r)}}function GG(e){return DS(e.font,t=>{let n=e.requestGlyph(t);return By(n)?n.xadvance:null})}var _S=new WeakMap;function Dy(e,t){let n=_S.get(e);return n||(n=t(e),_S.set(e,n)),n}function as(e){if(e.outlineFace)return Dy(e.outlineFace,HG);if(e.entry)return Dy(e.entry.font,t=>DS(t,n=>t.charMap.get(n)?.xadvance??null));if(e.dynamicFace)return Dy(e.dynamicFace,GG)}var UG=/\p{Emoji_Presentation}|\p{Extended_Pictographic}\uFE0F|\uFE0F\u20E3/u;function BS(e){return e.length===1&&e.charCodeAt(0)<8986?!1:UG.test(e)&&!e.includes("\uFE0E")}function HS(e,t){if(!eo(`missing-glyph|${e}|${t}`))return;let n=String.fromCodePoint(t);console.warn(`weasel: no glyph for U+${t.toString(16).toUpperCase().padStart(4,"0")} (${JSON.stringify(n)}) in "${e}", and the dynamic tier could not rasterize it \u2014 skipping the character. Bake it into the atlas, or call registerCanvasFont("${e}") to serve missing codepoints from installed fonts.`)}var WG=["unusable-default","self-unusable-default","unregistered-default"];function Hy(e,t,n){if(hd(e,t,n))return;let r=`${e}|${t}|${n}`;WG.some(o=>Y1(`${o}|${r}`))||eo(`no-metrics|${r}`)&&console.warn(`weasel: no metrics for "${e}" ${t}/${n} \u2014 neither an atlas nor an outline face resolved, so every run set in it lays out as nothing. Register it with registerFont / registerCanvasFont / registerFontOutlines. If you did, check for a duplicated @weasel-js/font in node_modules \u2014 its registry is module state, so a second copy is a second, empty one.`)}function dl(e,t,n){let r=as(e);if(!r)return null;if(e.outlineFace){let a=r.advanceOf(t);return a===null?null:GS(n,e,r,a,null,null)}let o=e.dynamicFace,i=e.entry?.font??o?.font,s=e.entry?i?.charMap.get(t):o?.requestGlyph(t);return!i||!s||o&&!By(s)?null:GS(n,e,r,s.xadvance,i,s)}function GS(e,t,n,r,o,i){return e?(e.resolved=t,e.metrics=n,e.advance=r,e.font=o,e.glyph=i,e):{resolved:t,metrics:n,advance:r,font:o,glyph:i}}function fl(e,t,n,r,o,i=!0,s){let a=dl(e,o,s);if(a)return a;let l=md(t,n,r),u=l&&dl(l,o,s);return u||(i&&HS(e.resolved.family,o),null)}function Gy(e,t,n,r,o){if(!BS(o))return null;let i=e.dynamicFace?e:md(t,n,r),s=i?.dynamicFace,a=i&&as(i),l=s?.requestCluster(o);return!i||!s||!a||!l?null:{resolved:i,metrics:a,advance:l.xadvance,font:s.font,glyph:l}}var Uy=1,Wy=2,US=.2,VG=.3,gd=1;function Vy(e,t,n){return .5*(e[0]/t+e[1]/n)>US*.9}var zG=`
53
+ float area = smoothstep(${US.toFixed(2)}, ${VG.toFixed(2)}, fieldPerPx);
54
54
  if (area > 0.0) {
55
55
  float band = 0.5 * aaW;
56
56
  float lo = threshold - 0.5 * band;
@@ -62,15 +62,15 @@ void main() {
62
62
  at = vec2(-at.y, at.x);
63
63
  }
64
64
  coverage = mix(coverage, 0.25 * sum, area);
65
- }`,CG=`
65
+ }`,KG=`
66
66
  float glyphInCell(vec2 c, vec2 margin) {
67
67
  vec2 inside = step(margin, c) * step(c, 1.0 - margin);
68
68
  return inside.x * inside.y;
69
69
  }
70
- `,OG=`
70
+ `,jG=`
71
71
  vec2 dcx = dFdx(cell);
72
72
  vec2 dcy = dFdy(cell);
73
- vec2 margin = ${id.toFixed(1)} * vec2(length(vec2(dcx.x, dcy.x)), length(vec2(dcx.y, dcy.y)));`;function CS(e){return`
73
+ vec2 margin = ${gd.toFixed(1)} * vec2(length(vec2(dcx.x, dcy.x)), length(vec2(dcx.y, dcy.y)));`;function WS(e){return`
74
74
  float median(float r, float g, float b) {
75
75
  return max(min(r, g), min(max(r, g), b));
76
76
  }
@@ -78,53 +78,53 @@ float median(float r, float g, float b) {
78
78
  float glyphField(vec4 texel, float mode) {
79
79
  return mix(median(texel.r, texel.g, texel.b), texel.r, step(1.5, mode));
80
80
  }
81
- ${e?CG:""}
81
+ ${e?KG:""}
82
82
  float glyphCoverage(vec4 texel, float mode, float synthBold, vec2 uv, vec2 fieldPerUv${e?", vec2 cell":""}) {
83
83
  vec2 du = dFdx(uv);
84
- vec2 dv = dFdy(uv);${e?OG:""}
84
+ vec2 dv = dFdy(uv);${e?jG:""}
85
85
  float fieldPerPx = 0.5 * (length(du * fieldPerUv) + length(dv * fieldPerUv));
86
86
  float aaW = max(0.5 * fieldPerPx, 0.0005);
87
87
  float threshold = 0.5 - synthBold;
88
88
  float field = glyphField(texel, mode);
89
- float coverage = smoothstep(threshold - aaW, threshold + aaW, field)${e?" * glyphInCell(cell, margin)":""};${e?MG:""}
89
+ float coverage = smoothstep(threshold - aaW, threshold + aaW, field)${e?" * glyphInCell(cell, margin)":""};${e?zG:""}
90
90
  return coverage;
91
91
  }
92
- `}var al=CS(!0),Ly=CS(!1),OS=4,FG=[1024/Xi,1024/Xi];function _y(e,t,n,r){if(e==="canvas")return FG;let o=rl(t,n,r)?.font;if(!o)return;let i=o.distanceRange??OS,s=o.common.scaleW/i,a=o.common.scaleH/i;return(od[0]!==s||od[1]!==a)&&(od=[s,a]),od}var od=[NaN,NaN],sl=.08;function Dy(e,t,n,r){if(e==="canvas")return sl*Xi/He;let o=rl(t,n,r)?.font;if(o)return sl*(o.distanceRange??OS)/o.info.size}var sd=`
92
+ `}var hl=WS(!0),zy=WS(!1),VS=4,$G=[1024/rs,1024/rs];function Ky(e,t,n,r){if(e==="canvas")return $G;let o=cl(t,n,r)?.font;if(!o)return;let i=o.distanceRange??VS,s=o.common.scaleW/i,a=o.common.scaleH/i;return(yd[0]!==s||yd[1]!==a)&&(yd=[s,a]),yd}var yd=[NaN,NaN],pl=.08;function jy(e,t,n,r){if(e==="canvas")return pl*rs/He;let o=cl(t,n,r)?.font;if(o)return pl*(o.distanceRange??VS)/o.info.size}var bd=`
93
93
  vec3 straightRgb(vec4 premultiplied) {
94
94
  return premultiplied.rgb / max(premultiplied.a, 0.0001);
95
95
  }
96
- `;ee();var io=8,bs=64,Od=16,Sn=Od,Ov=2**24,_g=16384,Fd=32768,gs=_g,Lg=Fd;function Dv(e,t,n,r){let o=n/2,i=r/2;return{ax:e[0]*o,bx:e[3]*o,cx:(e[6]+1)*o+t[0],ay:e[1]*i,by:e[4]*i,cy:(e[7]+1)*i+t[1],midX:t[0]+o,midY:t[1]+i}}var Fv=new WeakMap;function Dg(e,t,n){let r=Fv.get(e);if(r!==void 0&&wU(r.m,t)&&PU(r.map,n))return r.hull;let o=TU(e,t,n);return Fv.set(e,{m:Float64Array.of(t[0],t[1],t[3],t[4],t[6],t[7]),map:n,hull:o}),o}var Lv=new WeakMap;function Bv(e,t,n){if(n.bx!==0||n.ay!==0)return null;let r=Dg(e,t,n);if(r===null)return null;let o=Lv.get(r);return o===void 0&&(o={rect:xU(r.path),hull:r},Lv.set(r,o)),o}function xU(e){if(e.kind==="rect")return{x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+e.height};let t=e.origin?.x??0,n=e.origin?.y??0,r=e.coords,o=1/0,i=1/0,s=-1/0,a=-1/0;for(let l=0;l<r.length;l+=2){let u=r[l]+t,c=r[l+1]+n;u<o&&(o=u),u>s&&(s=u),c<i&&(i=c),c>a&&(a=c)}return{x0:o,y0:i,x1:s,y1:a}}function wU(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[3]&&e[3]===t[4]&&e[4]===t[6]&&e[5]===t[7]}function PU(e,t){return e.ax===t.ax&&e.bx===t.bx&&e.cx===t.cx&&e.ay===t.ay&&e.by===t.by&&e.cy===t.cy&&e.midX===t.midX&&e.midY===t.midY}function TU(e,t,n){let r=Hg(e);if(r===null||r.length<6)return null;let o=[];for(let a=0;a<r.length;a+=2){let l=t[0]*r[a]+t[3]*r[a+1]+t[6],u=t[1]*r[a]+t[4]*r[a+1]+t[7],c=Math.round((n.ax*l+n.bx*u+n.cx)*Sn),d=Math.round((n.ay*l+n.by*u+n.cy)*Sn);if(!(Math.abs(c)<Ov&&Math.abs(d)<Ov))return null;let f=o.length;f>=2&&o[f-2]===c&&o[f-1]===d||o.push(c,d)}for(;o.length>=4&&o[0]===o[o.length-2]&&o[1]===o[o.length-1];)o.length-=2;Gg(o)<0&&Ug(o);let i=Vg(o),s=RU(i.length>=6?i:o,n);return i.length<6?{set:Hv,path:s}:i.length/2>io||!Wg(i)?null:{set:AU(i,n),path:s}}var Hv={planes:Int32Array.of(0,0,-1,Cd(0,0)),count:1},SU={planes:Int32Array.of(0,0,0,Cd(0,0)),count:1};function Bg(e,t){let n=[];for(let r of[e,t])for(let o=0;o<r.count;o++){let i=r.planes.subarray(4*o,4*o+4);if(i[0]===0&&i[1]===0){if(i[2]<0)return Hv;continue}let s=kU(n,i[0],i[1]);s<0?n.push(i[0],i[1],i[2],i[3]):_v(i,0)>_v(n,s)&&n.splice(s,4,i[0],i[1],i[2],i[3])}return n.length===0?SU:n.length/4>io?null:{planes:Int32Array.from(n),count:n.length/4}}function kU(e,t,n){for(let r=0;r<e.length;r+=4){let o=e[r],i=e[r+1];if(o*n===i*t&&o*t+i*n>0)return r}return-1}function _v(e,t){let n=e[t],r=e[t+1],o=e[t+3],i=o%Lg-gs,s=Math.floor(o/Lg)-gs,a=e[t+2]-Sn*(n*i+r*s);return Math.ceil(-a/vU(Math.abs(n),Math.abs(r)))}function vU(e,t){for(;t!==0;)[e,t]=[t,e%t];return e}function Hg(e){if(e.kind==="rect"){let{x:i,y:s,width:a,height:l}=e;return[i,s,i+a,s,i+a,s+l,i,s+l]}if(e.corners?.some(i=>i!==null))return null;let{commands:t,coords:n}=e;if(t.length<4||t[0]!==le||t[t.length-1]!==fe)return null;for(let i=1;i<t.length-1;i++)if(t[i]!==ce)return null;let r=e.origin?.x??0,o=e.origin?.y??0;return Array.from(n.subarray(0,(t.length-1)*2),(i,s)=>i+(s&1?o:r))}function Gg(e){let t=0;for(let n=0;n<e.length;n+=2){let r=(n+2)%e.length;t+=e[n]*e[r+1]-e[r]*e[n+1]}return t}function Ug(e){for(let t=0,n=e.length-2;t<n;t+=2,n-=2){let r=e[t],o=e[t+1];e[t]=e[n],e[t+1]=e[n+1],e[n]=r,e[n+1]=o}}function Gv(e,t,n,r){return(e[n]-e[t])*(e[r+1]-e[n+1])-(e[n+1]-e[t+1])*(e[r]-e[n])}function Vg(e){let t=[],n=e.length;for(let r=0;r<n;r+=2)Gv(e,(r-2+n)%n,r,(r+2)%n)!==0&&t.push(e[r],e[r+1]);return t}function Wg(e){let t=e.length,n=0,r=0;for(let o=0;o<t;o+=2){if(Gv(e,o,(o+2)%t,(o+4)%t)<=0)return!1;let i=Math.sign(e[(o+2)%t]-e[o]);i!==0&&(r!==0&&i!==r&&n++,r=i)}return n<=2}function Cd(e,t){return e+gs+(t+gs)*Lg}function AU(e,t){let n=e.length/2,r=new Int32Array(n*4),o=t.midX*Sn,i=t.midY*Sn;for(let s=0;s<n;s++){let a=e[2*s],l=e[2*s+1],u=e[(2*s+2)%e.length]-a,c=e[(2*s+3)%e.length]-l,d=-c,f=u,p=d>0||d===0&&f>0?0:1,h=((o-a)*u+(i-l)*c)/(u*u+c*c),m=Math.round((a+h*u)/Sn),g=Math.round((l+h*c)/Sn),b;Math.abs(m)<gs&&Math.abs(g)<gs?b=[d,f,d*(Sn*m-a)+f*(Sn*g-l)-p,Cd(m,g)]:b=[0,0,d*(o-a)+f*(i-l)>=p?0:-1,Cd(0,0)],r.set(b,s*4)}return{planes:r,count:n}}function RU(e,t){let n=t.ax*t.by-t.bx*t.ay,r=[];for(let o=0;o<e.length;o+=2){let i=e[o]/Sn-t.cx,s=e[o+1]/Sn-t.cy;r.push({x:(t.by*i-t.bx*s)/n,y:(t.ax*s-t.ay*i)/n})}return Vy(r)}var Uv=(2**30).toFixed(1),Vv=`
97
- uniform ivec4 u_hullPlanes[${bs}];
96
+ `;Z();var uo=8,vs=64,Vd=16,vn=Vd,Vv=2**24,jg=16384,zd=32768,ks=jg,Kg=zd;function $v(e,t,n,r){let o=n/2,i=r/2;return{ax:e[0]*o,bx:e[3]*o,cx:(e[6]+1)*o+t[0],ay:e[1]*i,by:e[4]*i,cy:(e[7]+1)*i+t[1],midX:t[0]+o,midY:t[1]+i}}var zv=new WeakMap;function $g(e,t,n){let r=zv.get(e);if(r!==void 0&&CU(r.m,t)&&OU(r.map,n))return r.hull;let o=FU(e,t,n);return zv.set(e,{m:Float64Array.of(t[0],t[1],t[3],t[4],t[6],t[7]),map:n,hull:o}),o}var Kv=new WeakMap;function Yv(e,t,n){if(n.bx!==0||n.ay!==0)return null;let r=$g(e,t,n);if(r===null)return null;let o=Kv.get(r);return o===void 0&&(o={rect:MU(r.path),hull:r},Kv.set(r,o)),o}function MU(e){if(e.kind==="rect")return{x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+e.height};let t=e.origin?.x??0,n=e.origin?.y??0,r=e.coords,o=1/0,i=1/0,s=-1/0,a=-1/0;for(let l=0;l<r.length;l+=2){let u=r[l]+t,c=r[l+1]+n;u<o&&(o=u),u>s&&(s=u),c<i&&(i=c),c>a&&(a=c)}return{x0:o,y0:i,x1:s,y1:a}}function CU(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[3]&&e[3]===t[4]&&e[4]===t[6]&&e[5]===t[7]}function OU(e,t){return e.ax===t.ax&&e.bx===t.bx&&e.cx===t.cx&&e.ay===t.ay&&e.by===t.by&&e.cy===t.cy&&e.midX===t.midX&&e.midY===t.midY}function FU(e,t,n){let r=qg(e);if(r===null||r.length<6)return null;let o=[];for(let a=0;a<r.length;a+=2){let l=t[0]*r[a]+t[3]*r[a+1]+t[6],u=t[1]*r[a]+t[4]*r[a+1]+t[7],c=Math.round((n.ax*l+n.bx*u+n.cx)*vn),d=Math.round((n.ay*l+n.by*u+n.cy)*vn);if(!(Math.abs(c)<Vv&&Math.abs(d)<Vv))return null;let f=o.length;f>=2&&o[f-2]===c&&o[f-1]===d||o.push(c,d)}for(;o.length>=4&&o[0]===o[o.length-2]&&o[1]===o[o.length-1];)o.length-=2;yr(o)<0&&Xg(o);let i=Jg(o),s=HU(i.length>=6?i:o,n);return i.length<6?{set:qv,path:s}:i.length/2>uo||!Qg(i)?null:{set:BU(i,n),path:s}}var qv={planes:Int32Array.of(0,0,-1,Wd(0,0)),count:1},LU={planes:Int32Array.of(0,0,0,Wd(0,0)),count:1};function Yg(e,t){let n=[];for(let r of[e,t])for(let o=0;o<r.count;o++){let i=r.planes.subarray(4*o,4*o+4);if(i[0]===0&&i[1]===0){if(i[2]<0)return qv;continue}let s=_U(n,i[0],i[1]);s<0?n.push(i[0],i[1],i[2],i[3]):jv(i,0)>jv(n,s)&&n.splice(s,4,i[0],i[1],i[2],i[3])}return n.length===0?LU:n.length/4>uo?null:{planes:Int32Array.from(n),count:n.length/4}}function _U(e,t,n){for(let r=0;r<e.length;r+=4){let o=e[r],i=e[r+1];if(o*n===i*t&&o*t+i*n>0)return r}return-1}function jv(e,t){let n=e[t],r=e[t+1],o=e[t+3],i=o%Kg-ks,s=Math.floor(o/Kg)-ks,a=e[t+2]-vn*(n*i+r*s);return Math.ceil(-a/DU(Math.abs(n),Math.abs(r)))}function DU(e,t){for(;t!==0;)[e,t]=[t,e%t];return e}function qg(e){if(e.kind==="rect"){let{x:i,y:s,width:a,height:l}=e;return[i,s,i+a,s,i+a,s+l,i,s+l]}if(e.corners?.some(i=>i!==null))return null;let{commands:t,coords:n}=e;if(t.length<4||t[0]!==le||t[t.length-1]!==fe)return null;for(let i=1;i<t.length-1;i++)if(t[i]!==ce)return null;let r=e.origin?.x??0,o=e.origin?.y??0;return Array.from(n.subarray(0,(t.length-1)*2),(i,s)=>i+(s&1?o:r))}function Xg(e){for(let t=0,n=e.length-2;t<n;t+=2,n-=2){let r=e[t],o=e[t+1];e[t]=e[n],e[t+1]=e[n+1],e[n]=r,e[n+1]=o}}function Xv(e,t,n,r){return(e[n]-e[t])*(e[r+1]-e[n+1])-(e[n+1]-e[t+1])*(e[r]-e[n])}function Jg(e){let t=[],n=e.length;for(let r=0;r<n;r+=2)Xv(e,(r-2+n)%n,r,(r+2)%n)!==0&&t.push(e[r],e[r+1]);return t}function Qg(e){let t=e.length,n=0,r=0;for(let o=0;o<t;o+=2){if(Xv(e,o,(o+2)%t,(o+4)%t)<=0)return!1;let i=Math.sign(e[(o+2)%t]-e[o]);i!==0&&(r!==0&&i!==r&&n++,r=i)}return n<=2}function Wd(e,t){return e+ks+(t+ks)*Kg}function BU(e,t){let n=e.length/2,r=new Int32Array(n*4),o=t.midX*vn,i=t.midY*vn;for(let s=0;s<n;s++){let a=e[2*s],l=e[2*s+1],u=e[(2*s+2)%e.length]-a,c=e[(2*s+3)%e.length]-l,d=-c,f=u,p=d>0||d===0&&f>0?0:1,h=((o-a)*u+(i-l)*c)/(u*u+c*c),m=Math.round((a+h*u)/vn),g=Math.round((l+h*c)/vn),b;Math.abs(m)<ks&&Math.abs(g)<ks?b=[d,f,d*(vn*m-a)+f*(vn*g-l)-p,Wd(m,g)]:b=[0,0,d*(o-a)+f*(i-l)>=p?0:-1,Wd(0,0)],r.set(b,s*4)}return{planes:r,count:n}}function HU(e,t){let n=t.ax*t.by-t.bx*t.ay,r=[];for(let o=0;o<e.length;o+=2){let i=e[o]/vn-t.cx,s=e[o+1]/vn-t.cy;r.push({x:(t.by*i-t.bx*s)/n,y:(t.ax*s-t.ay*i)/n})}return Qy(r)}var Jv=(2**30).toFixed(1),Qv=`
97
+ uniform ivec4 u_hullPlanes[${vs}];
98
98
  flat in int v_hullStart;
99
99
  flat in int v_hullCount;
100
100
  float hullCoverage() {
101
101
  ivec2 pixel = ivec2(gl_FragCoord.xy);
102
- for (int k = 0; k < ${io}; k++) {
102
+ for (int k = 0; k < ${uo}; k++) {
103
103
  if (k >= v_hullCount) break;
104
104
  ivec4 p = u_hullPlanes[v_hullStart + k];
105
- ivec2 origin = ivec2(p.w % ${Fd}, p.w / ${Fd}) - ${_g};
106
- ivec2 d = (pixel - origin) * ${Od} + ${Od/2};
105
+ ivec2 origin = ivec2(p.w % ${zd}, p.w / ${zd}) - ${jg};
106
+ ivec2 d = (pixel - origin) * ${Vd} + ${Vd/2};
107
107
  float estimate = float(p.x) * float(d.x) + float(p.y) * float(d.y) + float(p.z);
108
- if (estimate < -${Uv}) return 0.0;
109
- if (estimate < ${Uv}) {
108
+ if (estimate < -${Jv}) return 0.0;
109
+ if (estimate < ${Jv}) {
110
110
  uint e = uint(p.x) * uint(d.x) + uint(p.y) * uint(d.y) + uint(p.z);
111
111
  if (int(e) < 0) return 0.0;
112
112
  }
113
113
  }
114
114
  return 1.0;
115
115
  }
116
- `;var Wv=[0,2,6,4],Ld=`
116
+ `;var Zv=[0,2,6,4],Kd=`
117
117
  vec3 glyphCellOf(float post) {
118
118
  float corner = floor(post * 0.5);
119
119
  return vec3(mod(corner, 2.0), floor(corner * 0.5), post - 2.0 * corner);
120
120
  }
121
- `;var mt=16,zv=0,xs=mt-1,Vn=8,Kv=8,zg=mt*Kv,jv=zg*Vn,ri=0,$v=3,_d=4,ws=5,NU=(1/(2*Math.PI)).toFixed(10);function oi(e,t){return e+mt*t}function so(e,t){return e+zg*t}function Yv(e,t,n){return e+jv*(1+t*io+n-1)}var Kg={a_position:0,a_vertexColor:1,a_uv:2,a_post:3,a_texSlot:4},kl=Kg;function Dd(e,t,n,r=" "){if(e===t)return`${r}return ${n.replace("%s",`u_samplers[${e}]`)};`;let o=e+t+1>>1;return[`${r}if (slot < ${o}) {`,Dd(e,o-1,n,`${r} `),`${r}} else {`,Dd(o,t,n,`${r} `),`${r}}`].join(`
122
- `)}function qv(e){return`#version 300 es
123
- layout(location = ${kl.a_position}) in vec2 a_position;
124
- layout(location = ${kl.a_vertexColor}) in vec4 a_vertexColor;
125
- layout(location = ${kl.a_uv}) in vec2 a_uv;
126
- layout(location = ${kl.a_post}) in float a_post;
127
- layout(location = ${kl.a_texSlot}) in float a_texSlot;
121
+ `;var yt=16,eA=0,As=yt-1,zn=8,tA=8,Zg=yt*tA,nA=Zg*zn,ci=0,rA=3,jd=4,Rs=5,GU=(1/(2*Math.PI)).toFixed(10);function di(e,t){return e+yt*t}function co(e,t){return e+Zg*t}function oA(e,t,n){return e+nA*(1+t*uo+n-1)}var eb={a_position:0,a_vertexColor:1,a_uv:2,a_post:3,a_texSlot:4},Ll=eb;function $d(e,t,n,r=" "){if(e===t)return`${r}return ${n.replace("%s",`u_samplers[${e}]`)};`;let o=e+t+1>>1;return[`${r}if (slot < ${o}) {`,$d(e,o-1,n,`${r} `),`${r}} else {`,$d(o,t,n,`${r} `),`${r}}`].join(`
122
+ `)}function iA(e){return`#version 300 es
123
+ layout(location = ${Ll.a_position}) in vec2 a_position;
124
+ layout(location = ${Ll.a_vertexColor}) in vec4 a_vertexColor;
125
+ layout(location = ${Ll.a_uv}) in vec2 a_uv;
126
+ layout(location = ${Ll.a_post}) in float a_post;
127
+ layout(location = ${Ll.a_texSlot}) in float a_texSlot;
128
128
  uniform mat3 u_proj;
129
129
  uniform mat3 u_model;
130
130
  out vec4 v_vertexColor;
@@ -135,7 +135,7 @@ flat out float v_paintMode;
135
135
  flat out int v_matrix;
136
136
  flat out int v_hullStart;
137
137
  flat out int v_hullCount;${e?`
138
- out vec2 v_cell;${Ld}`:""}
138
+ out vec2 v_cell;${Kd}`:""}
139
139
  void main() {
140
140
  vec3 screen = u_model * vec3(a_position, 1.0);
141
141
  vec3 clip = u_proj * vec3(screen.xy, 1.0);
@@ -146,22 +146,22 @@ void main() {
146
146
  // slot + 16 * mode + 128 * matrix + 1024 * hull, unpacked \u2014 see the file
147
147
  // header for why they share a float.
148
148
  int packed = int(a_texSlot + 0.5);
149
- v_texSlot = packed % ${mt};
150
- v_paintMode = float((packed / ${mt}) % ${Kv});
151
- v_matrix = (packed / ${zg}) % ${Vn};
152
- int hull = packed / ${jv};
153
- v_hullStart = hull == 0 ? 0 : (hull - 1) / ${io};
154
- v_hullCount = hull == 0 ? 0 : (hull - 1) % ${io} + 1;${e?IU:""}
149
+ v_texSlot = packed % ${yt};
150
+ v_paintMode = float((packed / ${yt}) % ${tA});
151
+ v_matrix = (packed / ${Zg}) % ${zn};
152
+ int hull = packed / ${nA};
153
+ v_hullStart = hull == 0 ? 0 : (hull - 1) / ${uo};
154
+ v_hullCount = hull == 0 ? 0 : (hull - 1) % ${uo} + 1;${e?UU:""}
155
155
  }
156
- `}var IU=`
156
+ `}var UU=`
157
157
  bool glyph = v_paintMode > 0.5 && v_paintMode < 2.5;
158
158
  vec3 cell = glyph ? glyphCellOf(a_post) : vec3(0.0, 0.0, a_post);
159
159
  v_cell = cell.xy;
160
- v_post = cell.z;`,vl=qv(!1),Xv=qv(!0),EU=`vec4 glyphTap(vec2 uv) {
160
+ v_post = cell.z;`,_l=iA(!1),sA=iA(!0),WU=`vec4 glyphTap(vec2 uv) {
161
161
  int slot = v_texSlot;
162
- ${Dd(1,mt-1,"textureLod(%s, uv, 0.0)")}
162
+ ${$d(1,yt-1,"textureLod(%s, uv, 0.0)")}
163
163
  return vec4(0.0);
164
- }`;function Al(e,t=!1,n=!1){let r=e===1?"0":"v_matrix";return`#version 300 es
164
+ }`;function Dl(e,t=!1,n=!1){let r=e===1?"0":"v_matrix";return`#version 300 es
165
165
  precision highp float;
166
166
  ${t?"precision highp int;":""}
167
167
  in vec4 v_vertexColor;
@@ -171,25 +171,25 @@ flat in int v_texSlot;
171
171
  flat in float v_paintMode;
172
172
  flat in int v_matrix;${n?`
173
173
  in vec2 v_cell;`:""}
174
- uniform sampler2D u_samplers[${mt}];
174
+ uniform sampler2D u_samplers[${yt}];
175
175
  uniform vec4 u_color;
176
176
  uniform float u_alpha[${e}];
177
- uniform vec2 u_fieldScale[${mt}];
177
+ uniform vec2 u_fieldScale[${yt}];
178
178
  uniform mat4 u_colorMatrix[${e}];
179
179
  uniform vec4 u_colorBias[${e}];
180
180
  out vec4 outColor;
181
181
 
182
182
  vec4 sampleSlot(int slot, vec2 uv) {
183
- ${Dd(0,mt-1,"texture(%s, uv)")}
183
+ ${$d(0,yt-1,"texture(%s, uv)")}
184
184
  // Never reached: every slot returns above.
185
185
  return vec4(0.0);
186
186
  }
187
- ${n?EU:""}
188
- ${n?al:Ly}
189
- ${sd}
190
- ${t?Vv:""}
187
+ ${n?WU:""}
188
+ ${n?hl:zy}
189
+ ${bd}
190
+ ${t?Qv:""}
191
191
  void main() {
192
- float isGrad = step(2.5, v_paintMode) * step(v_paintMode, ${_d+.5});
192
+ float isGrad = step(2.5, v_paintMode) * step(v_paintMode, ${jd+.5});
193
193
  // A radial or conic vertex carries a gradient-space coordinate rather than a
194
194
  // texture coordinate, and its atlas row rather than an alpha. The sample is
195
195
  // split across the branch rather than the coordinate selected before it: an
@@ -204,15 +204,15 @@ void main() {
204
204
  // nothing in either arm is a derivative.
205
205
  vec4 texel;
206
206
  if (isGrad > 0.5) {
207
- float t = v_paintMode > ${_d-.5}
208
- ? fract(atan(v_uv.y, v_uv.x) * ${NU})
207
+ float t = v_paintMode > ${jd-.5}
208
+ ? fract(atan(v_uv.y, v_uv.x) * ${GU})
209
209
  : length(v_uv);
210
- texel = texture(u_samplers[${xs}], vec2(t, v_post));
210
+ texel = texture(u_samplers[${As}], vec2(t, v_post));
211
211
  } else {
212
212
  texel = sampleSlot(v_texSlot, v_uv);
213
213
  }
214
214
  // At 0 the mix is the texel itself, so a solid still gets its color exactly.
215
- texel.rgb = mix(texel.rgb, straightRgb(texel), step(${ws-.5}, v_paintMode));
215
+ texel.rgb = mix(texel.rgb, straightRgb(texel), step(${Rs-.5}, v_paintMode));
216
216
  float isGlyph = step(0.5, v_paintMode) * step(v_paintMode, 2.5);
217
217
  // Unconditional, and multiplied out afterwards rather than branched around:
218
218
  // see the file header. A glyph's a_post is its synthetic-bold shift. A slot
@@ -226,7 +226,7 @@ void main() {
226
226
  float a = mapped.a * u_alpha[${r}] * mix(v_post, 1.0, max(isGrad, isGlyph)) * mix(1.0, coverage, isGlyph)${t?" * hullCoverage()":""};
227
227
  outColor = vec4(mapped.rgb * a, a);
228
228
  }
229
- `}var Jv=Al(1),Qv=Al(Vn),Zv=Al(1,!0),eA=Al(Vn,!0);function tA(e,t){return Al(e?Vn:1,t,!0)}var Rl=["u_proj","u_model","u_samplers","u_color","u_alpha","u_fieldScale","u_colorMatrix","u_colorBias"],Bd=[...Rl,"u_hullPlanes"],Ps=["a_position","a_vertexColor","a_uv","a_post","a_texSlot"];var nA=`#version 300 es
229
+ `}var aA=Dl(1),lA=Dl(zn),uA=Dl(1,!0),cA=Dl(zn,!0);function dA(e,t){return Dl(e?zn:1,t,!0)}var Bl=["u_proj","u_model","u_samplers","u_color","u_alpha","u_fieldScale","u_colorMatrix","u_colorBias"],Yd=[...Bl,"u_hullPlanes"],Ns=["a_position","a_vertexColor","a_uv","a_post","a_texSlot"];var fA=`#version 300 es
230
230
  in vec2 a_position;
231
231
  uniform mat3 u_proj;
232
232
  uniform mat3 u_model;
@@ -240,7 +240,7 @@ void main() {
240
240
  vec3 world = u_worldInv * vec3(screen.xy, 1.0);
241
241
  v_world = world.xy;
242
242
  }
243
- `,jg=`
243
+ `,tb=`
244
244
  uniform sampler2D u_ramp;
245
245
  uniform float u_rampV;
246
246
  uniform float u_alpha;
@@ -275,15 +275,15 @@ vec4 shadePaint(vec2 world) {
275
275
  float a = mapped.a * u_alpha;
276
276
  return vec4(mapped.rgb * a, a);
277
277
  }
278
- `,rA=`#version 300 es
278
+ `,pA=`#version 300 es
279
279
  precision highp float;
280
280
  in vec2 v_world;
281
- ${jg}
281
+ ${tb}
282
282
  out vec4 outColor;
283
283
  void main() {
284
284
  outColor = shadePaint(v_world);
285
285
  }
286
- `,Hd=["u_proj","u_model","u_origin","u_worldInv","u_ramp","u_rampV","u_alpha","u_opacity","u_colorMatrix","u_colorBias","u_gradKind","u_gradDir","u_gradLen","u_gradRadius","u_gradAngle"],oA=["a_position"];var iA=`#version 300 es
286
+ `,qd=["u_proj","u_model","u_origin","u_worldInv","u_ramp","u_rampV","u_alpha","u_opacity","u_colorMatrix","u_colorBias","u_gradKind","u_gradDir","u_gradLen","u_gradRadius","u_gradAngle"],hA=["a_position"];var mA=`#version 300 es
287
287
  in vec2 a_position;
288
288
  uniform mat3 u_proj;
289
289
  uniform mat3 u_model;
@@ -297,14 +297,14 @@ void main() {
297
297
  vec3 world = u_worldInv * vec3(screen.xy, 1.0);
298
298
  v_world = world.xy;
299
299
  }
300
- `,$g=`
300
+ `,nb=`
301
301
  uniform sampler2D u_sampler;
302
302
  uniform vec2 u_tileSize;
303
303
  uniform float u_opacity;
304
304
  uniform float u_alpha;
305
305
  uniform mat4 u_colorMatrix;
306
306
  uniform vec4 u_colorBias;
307
- ${sd}
307
+ ${bd}
308
308
  vec4 shadePaint(vec2 world) {
309
309
  vec2 uv = world / max(u_tileSize, vec2(0.0001));
310
310
  vec4 texel = texture(u_sampler, uv);
@@ -312,19 +312,19 @@ vec4 shadePaint(vec2 world) {
312
312
  float a = mapped.a * u_opacity * u_alpha;
313
313
  return vec4(mapped.rgb * a, a);
314
314
  }
315
- `,sA=`#version 300 es
315
+ `,yA=`#version 300 es
316
316
  precision highp float;
317
317
  in vec2 v_world;
318
- ${$g}
318
+ ${nb}
319
319
  out vec4 outColor;
320
320
  void main() {
321
321
  outColor = shadePaint(v_world);
322
322
  }
323
- `,Gd=["u_proj","u_model","u_origin","u_worldInv","u_sampler","u_tileSize","u_opacity","u_alpha","u_colorMatrix","u_colorBias"],aA=["a_position"];var kn=class{constructor(t,n){this.gl=t;this.spec=n}gl;spec;program=null;get(){if(!this.program){let{vert:t,frag:n,uniforms:r,attributes:o}=this.spec,i=new $r(this.gl,t,n);i.lookupUniforms(r),i.lookupAttributes(o),this.program=i}return this.program}release(){this.program&&this.gl.deleteProgram(this.program.handle),this.program=null}abandon(){this.program=null}},lA={vert:A1,frag:R1,uniforms:oy,attributes:E1},uA={vert:N1,frag:I1,uniforms:oy,attributes:M1},cA={vert:nA,frag:rA,uniforms:Hd,attributes:oA},MU={vert:vl,frag:Qv,uniforms:Rl,attributes:Ps},CU={vert:vl,frag:Zv,uniforms:Bd,attributes:Ps},OU={vert:vl,frag:eA,uniforms:Bd,attributes:Ps},dA={vert:iA,frag:sA,uniforms:Gd,attributes:aA};function Yg(e){let t=new $r(e,vl,Jv);return t.lookupUniforms(Rl),t.lookupAttributes(Ps),t}var Ud=class{hulls;cuts=!0;matrices;hull;matricesHull;area;constructor(t){this.hulls=t.getParameter(t.SAMPLES)===0,this.matrices=new kn(t,MU),this.hull=new kn(t,CU),this.matricesHull=new kn(t,OU),this.area=[!1,!0].flatMap(n=>[!1,!0].map(r=>new kn(t,{vert:Xv,frag:tA(r,n),uniforms:n?Bd:Rl,attributes:Ps})))}get(t,n,r=!1){return r?this.area[Number(t)+2*Number(n)].get():n?(t?this.matricesHull:this.hull).get():this.matrices.get()}lazy(){return[this.matrices,this.hull,this.matricesHull,...this.area]}};var Vd=Kg,fA=`#version 300 es
324
- layout(location = ${Vd.a_position}) in vec2 a_position;
325
- layout(location = ${Vd.a_uv}) in vec2 a_uv;
326
- layout(location = ${Vd.a_post}) in float a_post;
327
- layout(location = ${Vd.a_texSlot}) in float a_texSlot;
323
+ `,Xd=["u_proj","u_model","u_origin","u_worldInv","u_sampler","u_tileSize","u_opacity","u_alpha","u_colorMatrix","u_colorBias"],gA=["a_position"];var An=class{constructor(t,n){this.gl=t;this.spec=n}gl;spec;program=null;get(){if(!this.program){let{vert:t,frag:n,uniforms:r,attributes:o}=this.spec,i=new Jr(this.gl,t,n);i.lookupUniforms(r),i.lookupAttributes(o),this.program=i}return this.program}release(){this.program&&this.gl.deleteProgram(this.program.handle),this.program=null}abandon(){this.program=null}},bA={vert:_1,frag:D1,uniforms:py,attributes:G1},xA={vert:B1,frag:H1,uniforms:py,attributes:U1},wA={vert:fA,frag:pA,uniforms:qd,attributes:hA},VU={vert:_l,frag:lA,uniforms:Bl,attributes:Ns},zU={vert:_l,frag:uA,uniforms:Yd,attributes:Ns},KU={vert:_l,frag:cA,uniforms:Yd,attributes:Ns},PA={vert:mA,frag:yA,uniforms:Xd,attributes:gA};function rb(e){let t=new Jr(e,_l,aA);return t.lookupUniforms(Bl),t.lookupAttributes(Ns),t}var Jd=class{hulls;cuts=!0;matrices;hull;matricesHull;area;constructor(t){this.hulls=t.getParameter(t.SAMPLES)===0,this.matrices=new An(t,VU),this.hull=new An(t,zU),this.matricesHull=new An(t,KU),this.area=[!1,!0].flatMap(n=>[!1,!0].map(r=>new An(t,{vert:sA,frag:dA(r,n),uniforms:n?Yd:Bl,attributes:Ns})))}get(t,n,r=!1){return r?this.area[Number(t)+2*Number(n)].get():n?(t?this.matricesHull:this.hull).get():this.matrices.get()}lazy(){return[this.matrices,this.hull,this.matricesHull,...this.area]}};var Qd=eb,TA=`#version 300 es
324
+ layout(location = ${Qd.a_position}) in vec2 a_position;
325
+ layout(location = ${Qd.a_uv}) in vec2 a_uv;
326
+ layout(location = ${Qd.a_post}) in float a_post;
327
+ layout(location = ${Qd.a_texSlot}) in float a_texSlot;
328
328
  uniform mat3 u_proj;
329
329
  uniform mat3 u_model;
330
330
  uniform mat3 u_worldInv;
@@ -332,17 +332,17 @@ out vec2 v_world;
332
332
  out vec2 v_uv;
333
333
  flat out float v_glyphMode;
334
334
  out vec2 v_cell;
335
- ${Ld}
335
+ ${Kd}
336
336
  void main() {
337
337
  vec3 screen = u_model * vec3(a_position, 1.0);
338
338
  vec3 clip = u_proj * vec3(screen.xy, 1.0);
339
339
  gl_Position = vec4(clip.xy, 0.0, 1.0);
340
340
  v_world = (u_worldInv * vec3(screen.xy, 1.0)).xy;
341
341
  v_uv = a_uv;
342
- v_glyphMode = float(int(a_texSlot + 0.5) / ${mt});
342
+ v_glyphMode = float(int(a_texSlot + 0.5) / ${yt});
343
343
  v_cell = glyphCellOf(a_post).xy;
344
344
  }
345
- `;function qg(e){return`#version 300 es
345
+ `;function ob(e){return`#version 300 es
346
346
  precision highp float;
347
347
  in vec2 v_world;
348
348
  in vec2 v_uv;
@@ -355,18 +355,18 @@ ${e}
355
355
  vec4 glyphTap(vec2 uv) {
356
356
  return textureLod(u_atlas, uv, 0.0);
357
357
  }
358
- ${al}
358
+ ${hl}
359
359
  out vec4 outColor;
360
360
  void main() {
361
361
  float coverage = glyphCoverage(texture(u_atlas, v_uv), v_glyphMode, u_synthBold, v_uv, u_fieldScale, v_cell);
362
362
  outColor = shadePaint(v_world) * coverage;
363
363
  }
364
- `}var FU=`
364
+ `}var jU=`
365
365
  uniform sampler2D u_sampler;
366
366
  vec4 shadePaint(vec2 uv) {
367
367
  return texture(u_sampler, uv);
368
368
  }
369
- `,pA=qg($g),hA=qg(jg),mA=qg(FU),Xg=["u_atlas","u_synthBold","u_fieldScale"],yA=e=>e!=="u_origin",gA=[...Gd.filter(yA),...Xg],bA=[...Hd.filter(yA),...Xg],xA=["u_proj","u_model","u_worldInv","u_sampler",...Xg],wA=["a_position","a_uv","a_post","a_texSlot"];var Wd=class{gl;target=null;constructor(t){this.gl=t}acquire(t,n){let r=this.target;if(r&&r.width>=t&&r.height>=n)return r;let o=Math.max(r?.width??0,PA(t)),i=Math.max(r?.height??0,PA(n));return this.release(),this.target=this.create(o,i),this.target}release(){this.target&&(this.gl.deleteFramebuffer(this.target.fbo),this.gl.deleteTexture(this.target.texture),this.target=null)}create(t,n){let r=this.gl,o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texImage2D(r.TEXTURE_2D,0,r.RGBA8,t,n,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null);let i=r.createFramebuffer();return r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,o,0),r.bindFramebuffer(r.FRAMEBUFFER,null),{fbo:i,texture:o,width:t,height:n}}};function PA(e){let t=64;for(;t<e;)t*=2;return t}var Nl=class{constructor(t){this.gl=t;this.finalizer=new FinalizationRegistry(n=>{this.persistent.delete(n)&&this.pendingDeletes.push(n)})}gl;map=new WeakMap;seen=new WeakSet;finalizer;persistent=new Set;pendingDeletes=[];disposed=!1;transientThisFrame=[];handleFor(t){let n=this.map.get(t);if(n)return n;let{handle:r,vbo:o,ibo:i}=this.upload(t);this.map.set(t,r);let s={vao:r.vao,vbo:o,ibo:i};return this.persistent.add(s),this.finalizer.register(t,s,t),r}uploadTransient(t){let{handle:n,vbo:r,ibo:o}=this.upload(t);return this.transientThisFrame.push({vao:n.vao,vbo:r,ibo:o}),n}uploadRecurring(t){return this.seen.has(t)?this.handleFor(t):(this.seen.add(t),this.uploadTransient(t))}freeTransient(){if(this.transientThisFrame.length===0)return;let t=this.gl;if(t.isContextLost()){this.transientThisFrame.length=0;return}for(let n of this.transientThisFrame)t.deleteVertexArray(n.vao),t.deleteBuffer(n.vbo),t.deleteBuffer(n.ibo);this.transientThisFrame.length=0}_transientCount(){return this.transientThisFrame.length}drainPendingDeletes(){if(this.pendingDeletes.length===0)return;let t=this.gl;if(t.isContextLost()){this.pendingDeletes.length=0;return}for(let n of this.pendingDeletes)t.deleteVertexArray(n.vao),t.deleteBuffer(n.vbo),t.deleteBuffer(n.ibo);this.pendingDeletes.length=0}dispose(){if(!this.disposed){this.disposed=!0,this.freeTransient();for(let t of this.persistent)this.pendingDeletes.push(t);this.persistent.clear(),this.drainPendingDeletes()}}_pendingDeleteCount(){return this.pendingDeletes.length}_enqueueDeleteForTest(t){this.pendingDeletes.push(t)}upload(t){let n=this.gl,r=n.createVertexArray();if(!r)throw new Error("createVertexArray returned null");n.bindVertexArray(r);let o=n.createBuffer();if(!o)throw new Error("createBuffer (VBO) returned null");n.bindBuffer(n.ARRAY_BUFFER,o),n.bufferData(n.ARRAY_BUFFER,t.vertices,n.STATIC_DRAW),n.enableVertexAttribArray(_c),n.vertexAttribPointer(_c,2,n.FLOAT,!1,0,0);let i=n.createBuffer();if(!i)throw new Error("createBuffer (IBO) returned null");return n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.indices,n.STATIC_DRAW),n.bindVertexArray(null),{handle:{vao:r,indexCount:t.indices.length,requiresStencil:t.requiresStencil??!1,anchorA:t.anchorA,anchorB:t.anchorB,anchorT:t.anchorT},vbo:o,ibo:i}}};function Il(e,t){e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1)}function LU(e,t){e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t)}var El=class{constructor(t){this.gl=t}gl;map=new Map;wraps=new Map;registered=new Map;sweptVersion=-1;has(t){return this.map.has(t)}upload(t,n,r="clamp"){return this.ensure(t,n,r,LU)}ensure(t,n,r,o){let i=this.map.get(t);if(i)return this.wraps.get(t)!==r&&this.applyWrap(t,i,r),t;let s=this.gl,a=s.createTexture();if(!a)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);let l=r==="repeat"?s.REPEAT:s.CLAMP_TO_EDGE;return s.bindTexture(s.TEXTURE_2D,a),o(s,n),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,l),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,l),s.bindTexture(s.TEXTURE_2D,null),this.map.set(t,a),this.wraps.set(t,r),t}uploadRegistered(t,n,r="clamp"){let o=this.map.get(t);if(o&&this.registered.get(t)!==n){let i=this.gl;i.bindTexture(i.TEXTURE_2D,o),Il(i,n),i.bindTexture(i.TEXTURE_2D,null)}return this.registered.set(t,n),this.ensure(t,n,r,Il)}replaces(t,n){return this.map.has(t)&&this.registered.get(t)!==n}sweep(t){let n=t.getVersion();if(n!==this.sweptVersion){this.sweptVersion=n;for(let r of this.registered.keys())t.has(r)||(this.gl.deleteTexture(this.map.get(r)??null),this.map.delete(r),this.wraps.delete(r),this.registered.delete(r))}}applyWrap(t,n,r){let o=this.gl,i=r==="repeat"?o.REPEAT:o.CLAMP_TO_EDGE;o.bindTexture(o.TEXTURE_2D,n),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,i),o.bindTexture(o.TEXTURE_2D,null),this.wraps.set(t,r)}uploadR8(t,n,r,o){if(this.map.has(t))return;let i=this.gl,s=i.createTexture();if(!s)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);i.bindTexture(i.TEXTURE_2D,s),i.pixelStorei(i.UNPACK_ALIGNMENT,1),i.texImage2D(i.TEXTURE_2D,0,i.R8,n,r,0,i.RED,i.UNSIGNED_BYTE,o),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.wraps.set(t,"clamp")}subImageR8(t,n,r,o,i,s){let a=this.map.get(t);if(!a)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let l=this.gl;l.bindTexture(l.TEXTURE_2D,a),l.pixelStorei(l.UNPACK_ALIGNMENT,1),l.texSubImage2D(l.TEXTURE_2D,0,n,r,o,i,l.RED,l.UNSIGNED_BYTE,s),l.pixelStorei(l.UNPACK_ALIGNMENT,4),l.bindTexture(l.TEXTURE_2D,null)}uploadRGBA(t,n,r,o){if(this.map.has(t))return;let i=this.gl,s=i.createTexture();if(!s)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n,r,0,i.RGBA,i.UNSIGNED_BYTE,o),i.generateMipmap(i.TEXTURE_2D),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.wraps.set(t,"clamp")}subImageRGBA(t,n,r,o,i,s){let a=this.map.get(t);if(!a)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let l=this.gl;l.bindTexture(l.TEXTURE_2D,a),l.texSubImage2D(l.TEXTURE_2D,0,n,r,o,i,l.RGBA,l.UNSIGNED_BYTE,s),l.generateMipmap(l.TEXTURE_2D),l.bindTexture(l.TEXTURE_2D,null)}bind(t,n){let r=this.map.get(t);if(!r)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let o=this.gl;o.activeTexture(o.TEXTURE0+n),o.bindTexture(o.TEXTURE_2D,r)}free(){let t=this.gl;for(let n of this.map.values())t.deleteTexture(n);this.map.clear(),this.wraps.clear(),this.registered.clear()}};var Ts=bt(),si=Ts.reflection;var ii=[];function zd(e,t){let n={prefix:e,owner:t};return ii.push(n),()=>{let r=ii.indexOf(n);r!==-1&&ii.splice(r,1)}}function TA(e){return SA(e)!==void 0}function SA(e){for(let t=0;t<ii.length;t++)if(e.startsWith(ii[t].prefix))return ii[t].owner}function Ss(e){let t=ii.length>0?SA(e):void 0,n=Ts.get(e);return n?t?.touched?(t.touched(e),Ts.get(e)??null):n:t?(t.revive(e),Ts.get(e)??null):null}function Kd(e,t,n){return Ts.set(e,n?{source:t,size:n}:{source:t}),{id:e}}function jd(e){return Ts.delete(e.id)}var kA=4096,Ml=new Set;function $d(e){for(let t of Ml)t.release(e)}function vA(e){for(let t of Ml)if(t.drewInLatestFrame(e))return!0;return!1}function AA(){let e=1/0;for(let t of Ml)e=Math.min(e,t.maxTextureSide);return Number.isFinite(e)?e:kA}var ks=class{constructor(t,n="linear"){this.gl=t;this.minification=n;let r=t.getParameter(t.MAX_TEXTURE_SIZE);this.maxTextureSide=typeof r=="number"&&r>0?r:kA,this.finalizer=new FinalizationRegistry(o=>{this.textures.delete(o)&&this.pendingDeletes.push(o)}),Ml.add(this)}gl;minification;maxTextureSide;map=new WeakMap;textures=new Set;magFilters=new WeakMap;minFilters=new WeakMap;finalizer;pendingDeletes=[];mipped=new WeakSet;frame=0;lastDrawn=new WeakMap;beginFrame(){this.frame++,this.drainPendingDeletes()}drewInLatestFrame(t){return this.lastDrawn.get(t)===this.frame}drainPendingDeletes(){if(this.pendingDeletes.length!==0){for(let t of this.pendingDeletes)this.gl.deleteTexture(t);this.pendingDeletes.length=0}}release(t){let n=this.map.get(t);n&&(this.gl.deleteTexture(n),this.textures.delete(n),this.finalizer.unregister(t),this.map.delete(t),this.magFilters.delete(t),this.minFilters.delete(t),this.lastDrawn.delete(t),this.mipped.delete(t))}dispose(){for(let t of this.textures)this.gl.deleteTexture(t);this.drainPendingDeletes(),this.abandon()}abandon(){this.textures.clear(),this.pendingDeletes.length=0,Ml.delete(this)}upload(t,n,r){this.lastDrawn.set(t,this.frame);let o=this.map.get(t);if(o)return o;let i=this.gl,s=i.createTexture();if(!s)throw new Error("GLImageCache: createTexture failed");i.bindTexture(i.TEXTURE_2D,s),Il(i,n),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),this.minFilters.set(t,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),this.magFilters.set(t,i.LINEAR);let[a,l]=_U(i,r);return i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,a),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,l),this.minification==="mipmap"&&(i.generateMipmap(i.TEXTURE_2D),this.mipped.add(t)),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.textures.add(s),this.finalizer.register(t,s,t),s}lacksMipmaps(t){return this.minification==="auto"&&!this.mipped.has(t)}hasMipmaps(t){return this.mipped.has(t)}buildMipmaps(t){let n=this.map.get(t);if(!n||this.mipped.has(t))return;let r=this.gl;r.bindTexture(r.TEXTURE_2D,n),r.generateMipmap(r.TEXTURE_2D),r.bindTexture(r.TEXTURE_2D,null),this.mipped.add(t)}setMinFilter(t,n){let r=this.gl,o=n&&this.mipped.has(t)?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;this.minFilters.get(t)!==o&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),this.minFilters.set(t,o))}bind(t,n){let r=this.map.get(t);if(!r)throw new Error("GLImageCache: image not uploaded; call upload() first");this.lastDrawn.set(t,this.frame);let o=this.gl;o.activeTexture(o.TEXTURE0+n),o.bindTexture(o.TEXTURE_2D,r)}setMagFilter(t,n){this.magFilters.get(t)!==n&&(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,n),this.magFilters.set(t,n))}};function _U(e,t){switch(t){case"repeat":return[e.REPEAT,e.REPEAT];case"repeat-x":return[e.REPEAT,e.CLAMP_TO_EDGE];case"repeat-y":return[e.CLAMP_TO_EDGE,e.REPEAT];default:return[e.CLAMP_TO_EDGE,e.CLAMP_TO_EDGE]}}Pe();var li=256,eV=16,tV=1024;function nV(e,t="rgb"){let n=new Uint8ClampedArray(li*4);if(e.length===0)return n;let r=pb(e);for(let o=0;o<li;o++){let[i,s,a,l]=hb(r,o/(li-1),t);n[o*4]=i*255,n[o*4+1]=s*255,n[o*4+2]=a*255,n[o*4+3]=l*255}return n}function KA(e,t){return`${t}|${JSON.stringify(e)}`}var _l=class{constructor(t){this.gl=t}gl;rowByKey=new Map;texture=null;rows=0;pixels=new Uint8ClampedArray(0);totalQueries=0;cacheHits=0;get height(){return this.rows}upload(t,n="rgb"){let r=KA(t,n);this.totalQueries++;let o=this.rowByKey.get(r);if(o!==void 0)return this.cacheHits++,this.rowByKey.delete(r),this.rowByKey.set(r,o),o;let i=this.claimRow();return this.writeRow(i,nV(t,n)),this.rowByKey.set(r,i),i}wouldReshape(t,n="rgb"){return this.rowByKey.size===0?!1:!this.rowByKey.has(KA(t,n))&&this.rowByKey.size>=this.rows}rowV(t){return(t+.5)/(this.rows||1)}bind(t){let n=this.gl;n.activeTexture(n.TEXTURE0+t),n.bindTexture(n.TEXTURE_2D,this.texture)}hitRate(){return this.totalQueries===0?0:this.cacheHits/this.totalQueries}resetStats(){this.totalQueries=0,this.cacheHits=0}free(){this.texture&&this.gl.deleteTexture(this.texture),this.texture=null,this.rows=0,this.pixels=new Uint8ClampedArray(0),this.rowByKey.clear()}claimRow(){if(this.rowByKey.size<this.rows)return this.rowByKey.size;if(this.rows<tV)return this.resize(this.rows===0?eV:this.rows*2),this.rowByKey.size;let[t,n]=this.rowByKey.entries().next().value;return this.rowByKey.delete(t),n}resize(t){let n=this.gl,r=new Uint8ClampedArray(li*t*4);if(r.set(this.pixels),this.pixels=r,this.rows=t,this.texture)n.bindTexture(n.TEXTURE_2D,this.texture);else{let o=n.createTexture();if(!o)throw new Error("GradientRampAtlas: createTexture failed");this.texture=o,n.bindTexture(n.TEXTURE_2D,o),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}n.texImage2D(n.TEXTURE_2D,0,n.RGBA,li,t,0,n.RGBA,n.UNSIGNED_BYTE,this.pixels),n.bindTexture(n.TEXTURE_2D,null)}writeRow(t,n){let r=this.gl;this.pixels.set(n,t*li*4),r.bindTexture(r.TEXTURE_2D,this.texture),r.texSubImage2D(r.TEXTURE_2D,0,0,t,li,1,r.RGBA,r.UNSIGNED_BYTE,n),r.bindTexture(r.TEXTURE_2D,null)}};ee();var af=e=>e<0?0:e>1?1:e;function jA(e,t,n){for(let r=0;r<4;r++)for(let o=0;o<5;o++){let i=o===4?e[r*5+4]:0;for(let s=0;s<4;s++)i+=e[r*5+s]*t[s*5+o];n[r*5+o]=i}return n}function $A(e,t,n,r,o){return[af(e[0]*t+e[1]*n+e[2]*r+e[3]*o+e[4]),af(e[5]*t+e[6]*n+e[7]*r+e[8]*o+e[9]),af(e[10]*t+e[11]*n+e[12]*r+e[13]*o+e[14]),af(e[15]*t+e[16]*n+e[17]*r+e[18]*o+e[19])]}var Ht=new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),lf=class{transformStack=[q.identity()];alphaStack=[1];colorMatrixStack=[Ht];get transform(){return this.transformStack[this.transformStack.length-1]}get alpha(){return this.alphaStack[this.alphaStack.length-1]}get colorMatrix(){return this.colorMatrixStack[this.colorMatrixStack.length-1]}push(t){let n=this.transform,r=t.transform?q.multiply(n,t.transform):n,o=t.alpha!==void 0?this.alpha*t.alpha:this.alpha,i=t.colorMatrix?jA(this.colorMatrix,t.colorMatrix instanceof Float32Array?t.colorMatrix:new Float32Array(t.colorMatrix),new Float32Array(20)):this.colorMatrix;this.transformStack.push(r),this.alphaStack.push(o),this.colorMatrixStack.push(i)}pushIsolated(t){this.push(t);let n={alpha:this.alpha,colorMatrix:this.colorMatrix};this.pop();let r=this.transform;return this.transformStack.push(t.transform?q.multiply(r,t.transform):r),this.alphaStack.push(1),this.colorMatrixStack.push(Ht),n}reset(){this.transformStack.length=1,this.alphaStack.length=1,this.colorMatrixStack.length=1}pop(){if(this.transformStack.length<=1)throw new Error("GroupState.pop: cannot pop root frame");this.transformStack.pop(),this.alphaStack.pop(),this.colorMatrixStack.pop()}};var YA=.5;function qA(e,t){if(typeof e=="number")return e;let n=e?.px??YA,[r,o,,i,s]=t,a=r*r+o*o+i*i+s*s,l=r*s-o*i,u=Math.sqrt((a+Math.sqrt(Math.max(0,a*a-4*l*l)))/2),c=n/u;return!(c>0)||!Number.isFinite(c)?.5:2**Math.floor(Math.log2(c))}function XA(e,t){return typeof e=="number"?e:{px:(e?.px??YA)/t}}ee();var Hl=new Set,mb=!1;function pf(e,t,n=2){let r=t&&t.length,o=r?t[0]*n:e.length;Hl.size&&Hl.clear();let i=eR(e,0,o,n,!0),s=[];if(!i||i.next===i.prev)return s;let a=0,l=0,u=0;if(r&&(i=aV(e,t,i,n)),e.length>80*n){a=e[0],l=e[1];let c=a,d=l;for(let f=n;f<o;f+=n){let p=e[f],h=e[f+1];p<a&&(a=p),h<l&&(l=h),p>c&&(c=p),h>d&&(d=h)}u=Math.max(c-a,d-l),u=u!==0?32767/u:0}return yb(i,s,a,l,u),s}function eR(e,t,n,r,o){let i=null;if(o===wV(e,t,n,r)>0)for(let s=t;s<n;s+=r)i=ZA(s/r|0,e[s],e[s+1],i);else for(let s=n-r;s>=t;s-=r)i=ZA(s/r|0,e[s],e[s+1],i);return i&&Gl(i,i.next)&&(Vl(i),i=i.next),i}function ci(e,t=e){let n=t===e,r=e,o;do o=!1,r!==r.next&&(Hl.size===0||!Hl.has(r))&&(Gl(r,r.next)||Ye(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),mb=!0,Vl(r),r=r.prev,o=!0):(n||r!==t)&&(r=r.next,o=!n);while(o||r!==t);return t}function yb(e,t,n,r,o){o&&hV(e,n,r,o);let i=e,s=!1;for(;e.prev!==e.next;){let a=e.prev,l=e.next;if(Ye(a,e,l)<0&&(o?oV(e,n,r,o):rV(e))){t.push(a.i,e.i,l.i),Vl(e),e=l,i=l;continue}if(e=l,e===i){if(mb=!1,e=ci(e),mb){i=e;continue}if(!s){e=iV(e,t),i=e,s=!0;continue}sV(e,t,n,r,o);break}}}function rV(e){let t=e.prev,n=e,r=e.next,o=t.x,i=n.x,s=r.x,a=t.y,l=n.y,u=r.y,c=Math.min(o,i,s),d=Math.min(a,l,u),f=Math.max(o,i,s),p=Math.max(a,l,u),h=r.next;for(;h!==t;){if(h.x>=c&&h.x<=f&&h.y>=d&&h.y<=p&&!(o===h.x&&a===h.y)&&ff(o,a,i,l,s,u,h.x,h.y)&&Ye(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function oV(e,t,n,r){let o=e.prev,i=e,s=e.next,a=o.x,l=i.x,u=s.x,c=o.y,d=i.y,f=s.y,p=Math.min(a,l,u),h=Math.min(c,d,f),m=Math.max(a,l,u),g=Math.max(c,d,f),b=wb(p,h,t,n,r),x=wb(m,g,t,n,r),w=e.prevZ;for(;w&&w.z>=b;){if(w.x>=p&&w.x<=m&&w.y>=h&&w.y<=g&&w!==s&&!(a===w.x&&c===w.y)&&ff(a,c,l,d,u,f,w.x,w.y)&&Ye(w.prev,w,w.next)>=0)return!1;w=w.prevZ}let y=e.nextZ;for(;y&&y.z<=x;){if(y.x>=p&&y.x<=m&&y.y>=h&&y.y<=g&&y!==s&&!(a===y.x&&c===y.y)&&ff(a,c,l,d,u,f,y.x,y.y)&&Ye(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function iV(e,t){let n=e,r=!1;do{let o=n.prev,i=n.next.next;rR(o,n,n.next,i,!1)&&Ul(o,i)&&Ul(i,o)&&(t.push(o.i,n.i,i.i),Vl(n),Vl(n.next),n=e=i,r=!0),n=n.next}while(n!==e);return r?ci(n):n}function sV(e,t,n,r,o){let i=e;do{let s=i.next.next;for(;s!==i.prev;){if(i.i!==s.i&&gV(i,s)){let a=oR(i,s);i=ci(i,i.next),a=ci(a,a.next),yb(i,t,n,r,o),yb(a,t,n,r,o);return}s=s.next}i=i.next}while(i!==e)}var gb=!1;function aV(e,t,n,r){let o=[];for(let i=0,s=t.length;i<s;i++){let a=t[i]*r,l=i<s-1?t[i+1]*r:e.length,u=eR(e,a,l,r,!1);u===u.next&&Hl.add(u),o.push(yV(u))}o.sort(lV),cV(e.length/r,t.length),nR(n,n),gb=!0;for(let i=0;i<o.length;i++)n=uV(o[i],n);return gb=!1,ci(n)}function lV(e,t){return e.x-t.x||e.y-t.y||(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}function uV(e,t){let n=fV(e,t);if(!n)return t;let r=oR(n,e),o=r.next;return nR(n,o.next),ci(r,r.next),ci(n,n.next)}var tR=16,Ve=new Float64Array(0),df=0,bb=[],xb=[];function cV(e,t){let n=Math.ceil((e+2*t)/tR)+t+2;Ve.length<n*4&&(Ve=new Float64Array(n*4)),df=0}function nR(e,t){let n=e;do{let r=df++;bb[r]=n;let o=n.x,i=n.y,s=n.x,a=n.y,l=0;do{let c=n.next;n.z=r,c.x<o&&(o=c.x),c.x>s&&(s=c.x),c.y<i&&(i=c.y),c.y>a&&(a=c.y),n=c}while(++l<tR&&n!==t);xb[r]=n;let u=r*4;Ve[u]=o,Ve[u+1]=i,Ve[u+2]=s,Ve[u+3]=a}while(n!==t)}function dV(e,t){let n=e.z*4;t.x<Ve[n]&&(Ve[n]=t.x),t.y<Ve[n+1]&&(Ve[n+1]=t.y),t.x>Ve[n+2]&&(Ve[n+2]=t.x),t.y>Ve[n+3]&&(Ve[n+3]=t.y)}function JA(e){let t=xb[e];for(;t.prev.next!==t;)t=t.next;return xb[e]=t,t}function QA(e){let t=bb[e];for(;t.prev.next!==t;)t=t.next;return bb[e]=t,t}function fV(e,t){let n=t,r=e.x,o=e.y,i=-1/0,s;if(Gl(e,n))return n;for(let f=0,p=0;f<df;f++,p+=4){if(o<Ve[p+1]||o>Ve[p+3]||Ve[p]>r||Ve[p+2]<=i)continue;let h=JA(f);n=QA(f);do{if(n.prev.next===n){if(Gl(e,n.next))return n.next;if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){let m=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(m<=r&&m>i&&(i=m,s=n.x<n.next.x?n:n.next,m===r))return s}}n=n.next}while(n!==h)}if(!s)return null;let a=s.x,l=s.y,u=Math.min(o,l),c=Math.max(o,l),d=1/0;for(let f=0,p=0;f<df;f++,p+=4){if(Ve[p+2]<a||Ve[p]>r||Ve[p+3]<u||Ve[p+1]>c)continue;let h=JA(f);n=QA(f);do{if(n.prev.next===n&&r>=n.x&&n.x>=a&&r!==n.x&&ff(o<l?r:i,o,a,l,o<l?i:r,o,n.x,n.y)){let m=Math.abs(o-n.y)/(r-n.x);(Ul(n,e)||n.y===o&&n.next.y===o&&n.next.x>r)&&(m<d||m===d&&(n.x>s.x||n.x===s.x&&pV(s,n)))&&(s=n,d=m)}n=n.next}while(n!==h)}return s}function pV(e,t){return Ye(e.prev,e,t.prev)<0&&Ye(t.next,e,e.next)<0}var Gt=[],As=[],ui=new Uint32Array(0),Dl=new Uint32Array(0),Bl=new Uint32Array(256);function hV(e,t,n,r){let o=e,i=0;do o.z=wb(o.x,o.y,t,n,r),Gt[i++]=o,o=o.next;while(o!==e);mV(i);let s=null;for(let a=0;a<i;a++){let l=Gt[a];l.prevZ=s,s&&(s.nextZ=l),s=l}s.nextZ=null,Gt.fill(null,0,i),As.fill(null,0,i)}function mV(e){if(e<=32){for(let t=1;t<e;t++){let n=Gt[t],r=n.z,o=t-1;for(;o>=0&&Gt[o].z>r;)Gt[o+1]=Gt[o],o--;Gt[o+1]=n}return}ui.length<e&&(ui=new Uint32Array(e),Dl=new Uint32Array(e),As=new Array(e));for(let t=0;t<e;t++)ui[t]=Gt[t].z;uf(e,Gt,ui,As,Dl,0),uf(e,As,Dl,Gt,ui,8),uf(e,Gt,ui,As,Dl,16),uf(e,As,Dl,Gt,ui,24)}function uf(e,t,n,r,o,i){Bl.fill(0);for(let a=0;a<e;a++)Bl[n[a]>>>i&255]++;let s=0;for(let a=0;a<256;a++){let l=Bl[a];Bl[a]=s,s+=l}for(let a=0;a<e;a++){let l=n[a],u=Bl[l>>>i&255]++;r[u]=t[a],o[u]=l}}function wb(e,t,n,r,o){return e=(e-n)*o|0,t=(t-r)*o|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function yV(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function ff(e,t,n,r,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(r-a)>=(n-s)*(t-a)&&(n-s)*(i-a)>=(o-s)*(r-a)}function gV(e,t){let n=Gl(e,t)&&Ye(e.prev,e,e.next)>0&&Ye(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||Ul(e,t)&&Ul(t,e)&&(Ye(e.prev,e,t.prev)!==0||Ye(e,t.prev,t)!==0))&&!bV(e,t)&&(n||xV(e,t))}function Ye(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Gl(e,t){return e.x===t.x&&e.y===t.y}function rR(e,t,n,r,o=!0){let i=Ye(e,t,n),s=Ye(e,t,r),a=Ye(n,r,e),l=Ye(n,r,t);return(i>0&&s<0||i<0&&s>0)&&(a>0&&l<0||a<0&&l>0)?!0:o?!!(i===0&&cf(e,n,t)||s===0&&cf(e,r,t)||a===0&&cf(n,e,r)||l===0&&cf(n,t,r)):!1}function cf(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function bV(e,t){let n=Math.min(e.x,t.x),r=Math.max(e.x,t.x),o=Math.min(e.y,t.y),i=Math.max(e.y,t.y),s=e;do{let a=s.next;if(s.x>r&&a.x>r||s.x<n&&a.x<n||s.y>i&&a.y>i||s.y<o&&a.y<o){s=a;continue}if(s.i!==e.i&&a.i!==e.i&&s.i!==t.i&&a.i!==t.i&&rR(s,a,e,t))return!0;s=a}while(s!==e);return!1}function Ul(e,t){return Ye(e.prev,e,e.next)<0?Ye(e,t,e.next)>=0&&Ye(e,e.prev,t)>=0:Ye(e,t,e.prev)<0||Ye(e,e.next,t)<0}function xV(e,t){let n=e,r=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do{let s=n.next;n.y>i!=s.y>i&&o<(s.x-n.x)*(i-n.y)/(s.y-n.y)+n.x&&(r=!r),n=s}while(n!==e);return r}function oR(e,t){let n=Pb(e.i,e.x,e.y),r=Pb(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function ZA(e,t,n,r){let o=Pb(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function Vl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ),gb&&dV(e.prev,e.next)}function Pb(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function wV(e,t,n,r){let o=0;for(let i=t,s=n-r;i<n;i+=r)o+=(e[s]-e[i])*(e[i+1]+e[s+1]),s=i;return o}Je();en();Zt();ud();Qo();ss();var Tb=new Uint8Array(new Uint16Array([1]).buffer)[0]===1?0:1,PV=2**-19;function Sb(e,t,n){let r=TV(e,t),o=new Uint32Array(r.buffer);for(let i=0;i<t;i++){let s=o[i*2+Tb],a=s*4,l=e[a],u=e[a+1],c=e[a+2],d=e[a+3],f=Math.max(l,c),p=f+Math.abs(f)*PV+1e-300;for(let h=i+1;h<t&&!(r[h]>p);h++){let m=o[h*2+Tb],g=m*4,b=e[g],x=e[g+1],w=e[g+2],y=e[g+3];if(Math.max(u,d)<Math.min(x,y)||Math.max(x,y)<Math.min(u,d))continue;let P=SV(l,u,c,d,b,x,w,y);if(P&&n(s,m,P[0],P[1]))return}}}function TV(e,t){let n=new Float64Array(t),r=new Uint32Array(n.buffer);for(let o=0;o<t;o++)n[o]=Math.min(e[o*4],e[o*4+2]),r[o*2+Tb]=o;return n.sort()}function SV(e,t,n,r,o,i,s,a){let l=n-e,u=r-t,c=s-o,d=a-i,f=l*d-u*c;if(f===0)return null;let p=o-e,h=i-t,m=(p*d-h*c)/f,g=(p*u-h*l)/f,b=1e-9,x=1-1e-9;return m<=b||m>=x||g<=b||g>=x?null:[m,g]}var di=e=>`${e.x},${e.y}`;function kb(e,t=!1){return!t&&!AV(e)?null:sR(e,n=>n!==0).contours}var kV=2**20;function iR(e){let t=vV(e),n=Math.floor((kV/t-t)/2);if(!(n>=0))return null;let r=sR(e,o=>(o&1)!==0,n);return r!==null&&r.complete?r.contours:null}function sR(e,t,n=1/0){let r=RV(e),o=EV(r);if(!NV(r,n))return null;IV(r,o),MV(r,o);let i=OV(r,t),{loops:s,complete:a}=LV(i);return{contours:DV(s),complete:a}}function vV(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=0;return n.forEach((i,s)=>{let a=s+1<n.length?n[s+1]:r;for(let l=i;l<a;l++){let u=l+1<a?l+1:i;(t[l*2]!==t[u*2]||t[l*2+1]!==t[u*2+1])&&o++}}),o}function AV(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=new Float64Array(r*4),i=0;n.forEach((a,l)=>{let u=l+1<n.length?n[l+1]:r;for(let c=a;c<u;c++){let d=c+1<u?c+1:a,f=t[c*2],p=t[c*2+1],h=t[d*2],m=t[d*2+1];f===h&&p===m||(o[i*4]=f,o[i*4+1]=p,o[i*4+2]=h,o[i*4+3]=m,i++)}});let s=!1;return Sb(o,i,()=>s=!0),s}function RV(e){let{coords:t,contourStarts:n,anchorA:r,anchorB:o,anchorT:i}=e,s=t.length/2,a=u=>({x:t[u*2],y:t[u*2+1],a:r[u],b:o[u],t:i[u]}),l=[];return n.forEach((u,c)=>{let d=c+1<n.length?n[c+1]:s;for(let f=u;f<d;f++){let p=a(f),h=a(f+1<d?f+1:u);(p.x!==h.x||p.y!==h.y)&&l.push({from:p,to:h,cuts:[]})}}),l}function NV(e,t){let n=new Float64Array(e.length*4);e.forEach(({from:o,to:i},s)=>n.set([o.x,o.y,i.x,i.y],s*4));let r=0;return Sb(n,e.length,(o,i,s,a)=>{if(++r>t)return!0;let l=e[o],u={x:l.from.x+(l.to.x-l.from.x)*s,y:l.from.y+(l.to.y-l.from.y)*s,...CV(l,s)};return l.cuts.push({s,node:u}),e[i].cuts.push({s:a,node:u}),!1}),r<=t}function IV(e,t){let n=e.map((o,i)=>i),r=o=>Math.min(o.from.x,o.to.x);n.sort((o,i)=>r(e[o])-r(e[i]));for(let o=0;o<n.length;o++){let i=e[n[o]],s=Math.max(i.from.x,i.to.x)+t;for(let a=o+1;a<n.length;a++){let l=e[n[a]];if(r(l)>s)break;Math.max(i.from.y,i.to.y)+t<Math.min(l.from.y,l.to.y)||Math.max(l.from.y,l.to.y)+t<Math.min(i.from.y,i.to.y)||(hf(i,l.from,t),hf(i,l.to,t),hf(l,i.from,t),hf(l,i.to,t))}}}function EV(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let{from:i}of e)t=Math.min(t,i.x),r=Math.max(r,i.x),n=Math.min(n,i.y),o=Math.max(o,i.y);return Math.max(r-t,o-n,Math.abs(t),Math.abs(r),Math.abs(n),Math.abs(o))*1e-9}function MV(e,t){let n=[];for(let r of e){n.push(r.from,r.to);for(let o of r.cuts)n.push(o.node)}n.sort((r,o)=>r.x-o.x);for(let r=0;r<n.length;r++){let o=n[r];for(let i=r+1;i<n.length&&n[i].x-o.x<=t;i++){let s=n[i];s!==o&&Math.abs(s.y-o.y)<=t&&(s.x!==o.x||s.y!==o.y)&&(s.x=o.x,s.y=o.y)}}}function hf(e,t,n){let r=e.to.x-e.from.x,o=e.to.y-e.from.y,i=r*r+o*o,s=((t.x-e.from.x)*r+(t.y-e.from.y)*o)/i;if(!(s>0&&s<1)||Math.hypot(e.from.x+r*s-t.x,e.from.y+o*s-t.y)>n)return;let a=l=>Math.abs(l.x-t.x)<=n&&Math.abs(l.y-t.y)<=n;a(e.from)||a(e.to)||e.cuts.some(l=>a(l.node))||e.cuts.push({s,node:t})}function CV(e,t){let{from:n,to:r}=e;if(n.a===r.a&&n.b===r.b)return{a:n.a,b:n.b,t:n.t+(r.t-n.t)*t};let o=t<.5?n:r;return{a:o.a,b:o.b,t:o.t}}function OV(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let{from:d}of e)n=Math.min(n,d.x),o=Math.max(o,d.x),r=Math.min(r,d.y),i=Math.max(i,d.y);let s=Math.max(Math.hypot(o-n,i-r)*1e-7,1e-9),a=(d,f)=>t(FV(e,d,f)),l=[],u=new Set,c=(d,f)=>{let p=`${di(d)}>${di(f)}`;u.has(p)||(u.add(p),l.push({from:d,to:f}))};for(let d of e){let f=[d.from,...d.cuts.sort((p,h)=>p.s-h.s).map(p=>p.node),d.to];for(let p=0;p+1<f.length;p++){let h=f[p],m=f[p+1],g=m.x-h.x,b=m.y-h.y,x=Math.hypot(g,b);if(x===0)continue;let w=(h.x+m.x)/2,y=(h.y+m.y)/2,P=-b/x*s,S=g/x*s,v=a(w+P,y+S),A=a(w-P,y-S);v&&!A?c(h,m):A&&!v&&c(m,h)}}return l}function FV(e,t,n){let r=0;for(let{from:o,to:i}of e){let s=(i.x-o.x)*(n-o.y)-(t-o.x)*(i.y-o.y);o.y<=n&&i.y>n&&s>0?r++:i.y<=n&&o.y>n&&s<0&&r--}return r}function LV(e){let t=new Map;for(let i of e){let s=di(i.from),a=t.get(s);a?a.push(i):t.set(s,[i])}let n=new Set,r=[],o=!0;for(let i of e){if(n.has(i))continue;n.add(i);let s=[i.from],a=di(i.from),l=i;for(;di(l.to)!==a;){let u=_V(l,(t.get(di(l.to))??[]).filter(c=>!n.has(c)));if(!u)break;n.add(u),s.push(u.from),l=u}di(l.to)!==a?o=!1:s.length>=3&&r.push(s)}return{loops:r,complete:o}}function _V(e,t){let n=e.to.x-e.from.x,r=e.to.y-e.from.y,o,i=-1/0;for(let s of t){let a=s.to.x-s.from.x,l=s.to.y-s.from.y,u=Math.atan2(n*l-r*a,n*a+r*l);u>i&&(i=u,o=s)}return o}function DV(e){let t={coords:[],contourStarts:[],anchorA:[],anchorB:[],anchorT:[]};for(let n of e){t.contourStarts.push(t.coords.length/2);for(let r of n)t.coords.push(r.x,r.y),t.anchorA.push(r.a),t.anchorB.push(r.b),t.anchorT.push(r.t)}return t}wd();function fi(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=n.map((a,l)=>{let u=l+1<n.length?n[l+1]:r;return{start:a,end:u,area:UV(t,a,u),parent:-1,winding:0}}),i=o.map(a=>GV(t,a.start,a.end)),s=o.map((a,l)=>l).filter(a=>o[a].area!==0);s.sort((a,l)=>Math.abs(o[l].area)-Math.abs(o[a].area));for(let a=0;a<s.length;a++){let l=o[s[a]];for(let u=a-1;u>=0;u--){let c=s[u];if(BV(t,o[c],i[c],l)){l.parent=c;break}}l.winding=Math.sign(l.area)+(l.parent>=0?o[l.parent].winding:0)}return o}function BV(e,t,n,r){let o=Math.max(n[2]-n[0],n[3]-n[1])*1e-9;for(let i=r.start;i<r.end;i++){let s=e[i*2],a=e[i*2+1];if(s<n[0]||s>n[2]||a<n[1]||a>n[3])return!1;if(!HV(e,t,s,a,o))return Hn(e,s,a,t.start,t.end)}return!1}function HV(e,t,n,r,o){for(let i=t.start;i<t.end;i++){let s=i+1===t.end?t.start:i+1,a=e[i*2],l=e[i*2+1],u=e[s*2]-a,c=e[s*2+1]-l,d=u*u+c*c,f=d>0?Math.max(0,Math.min(1,((n-a)*u+(r-l)*c)/d)):0;if(Math.hypot(a+u*f-n,l+c*f-r)<=o)return!0}return!1}function GV(e,t,n){let r=1/0,o=1/0,i=-1/0,s=-1/0;for(let a=t;a<n;a++){let l=e[a*2],u=e[a*2+1];r=Math.min(r,l),i=Math.max(i,l),o=Math.min(o,u),s=Math.max(s,u)}return[r,o,i,s]}function UV(e,t,n){let r=0;for(let o=t;o<n;o++){let i=o+1===n?t:o+1;r+=e[o*2]*e[i*2+1]-e[i*2]*e[o*2+1]}return r*.5}function lR(e){if(WV(e))return null;let t=fi(e);if(t.some(n=>n.area===0))return null;for(let n of t){let r=0;for(let o=n.parent;o>=0;o=t[o].parent)r++;n.winding=r%2===0?1:0}return t}function VV(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=new Float64Array(r*4),i=new Uint32Array(r),s=new Uint32Array(r),a=[],l=0;return n.forEach((u,c)=>{let d=c+1<n.length?n[c+1]:r,f=0;for(let p=u;p<d;p++){let h=p+1<d?p+1:u,m=t[p*2],g=t[p*2+1],b=t[h*2],x=t[h*2+1];m===b&&g===x||(o.set([m,g,b,x],l*4),i[l]=c,s[l]=f++,l++)}a.push(f)}),{ends:o,contour:i,pos:s,count:a,n:l}}function WV(e){let t=VV(e),{ends:n,n:r}=t,o=1/0,i=1/0,s=-1/0,a=-1/0;for(let d=0;d<r*4;d+=2)o=Math.min(o,n[d]),s=Math.max(s,n[d]),i=Math.min(i,n[d+1]),a=Math.max(a,n[d+1]);let l=Math.max(s-o,a-i,Math.abs(o),Math.abs(s),Math.abs(i),Math.abs(a))*1e-9,u=Array.from({length:r},(d,f)=>f),c=d=>Math.min(n[d*4],n[d*4+2]);u.sort((d,f)=>c(d)-c(f));for(let d=0;d<r;d++){let f=u[d],p=Math.max(n[f*4],n[f*4+2])+l;for(let h=d+1;h<r;h++){let m=u[h];if(c(m)>p)break;if(zV(t,f,m,l))return!0}}return!1}function zV(e,t,n,r){let{ends:o}=e,i=o[t*4],s=o[t*4+1],a=o[t*4+2],l=o[t*4+3],u=o[n*4],c=o[n*4+1],d=o[n*4+2],f=o[n*4+3];if(Math.max(s,l)+r<Math.min(c,f)||Math.max(c,f)+r<Math.min(s,l))return!1;let p=KV(e,t,n);return p==="e-to"?aR(a-i,l-s,d-u,f-c)||Rs(i,s,u,c,d,f,r):p==="f-to"?aR(d-u,f-c,a-i,l-s)||Rs(u,c,i,s,a,l,r):Rs(i,s,u,c,d,f,r)||Rs(a,l,u,c,d,f,r)||Rs(u,c,i,s,a,l,r)||Rs(d,f,i,s,a,l,r)||jV(i,s,a,l,u,c,d,f)}function KV(e,t,n){if(e.contour[t]!==e.contour[n])return null;let r=e.count[e.contour[t]];return r<3?null:(e.pos[t]+1)%r===e.pos[n]?"e-to":(e.pos[n]+1)%r===e.pos[t]?"f-to":null}function aR(e,t,n,r){let o=e*r-t*n;return Math.abs(o)<=1e-9*Math.hypot(e,t)*Math.hypot(n,r)&&e*n+t*r<0}function Rs(e,t,n,r,o,i,s){let a=o-n,l=i-r,u=a*a+l*l,c=u>0?Math.max(0,Math.min(1,((e-n)*a+(t-r)*l)/u)):0;return Math.hypot(n+a*c-e,r+l*c-t)<=s}function jV(e,t,n,r,o,i,s,a){let l=mf(e,t,n,r,o,i),u=mf(e,t,n,r,s,a),c=mf(o,i,s,a,e,t),d=mf(o,i,s,a,n,r);return l*u<=0&&c*d<=0}var mf=(e,t,n,r,o,i)=>Math.sign((n-e)*(i-t)-(r-t)*(o-e));function zl(e,t={}){if(e.kind==="rect")return $V(e);let n=XV(Qe(e),t);return e.origin?{...n,origin:e.origin}:n}function $V(e){let t=cl(e.x,e.y,e.width,e.height),n=Pn(t);return{vertices:vt(n,t),indices:new Uint32Array([0,1,2,0,2,3]),anchorA:new Uint32Array([0,1,2,3]),anchorB:new Uint32Array([0,1,2,3]),anchorT:new Float32Array([0,0,0,0]),...n?{origin:n}:{}}}function YV(e,t){let n=new Set,r=qV(e,t,n);if(Tn(e))return r;let o={coords:[],contourStarts:[],anchorA:[],anchorB:[],anchorT:[]};return r.contourStarts.forEach((i,s)=>{if(!n.has(s))return;let a=s+1<r.contourStarts.length?r.contourStarts[s+1]:r.coords.length/2;o.contourStarts.push(o.coords.length/2),o.coords.push(...r.coords.slice(i*2,a*2)),o.anchorA.push(...r.anchorA.slice(i,a)),o.anchorB.push(...r.anchorB.slice(i,a)),o.anchorT.push(...r.anchorT.slice(i,a))}),o}function qV(e,t,n){let{commands:r,coords:o}=e,i=[],s=[],a=[],l=[],u=[],c=-1,d=-1,f=0,p=(h,m,g,b)=>{for(let w=0;w<m.length;w++)s.push(d),a.push(b),l.push(g>0?m[w]/g:0);let x=h+m.length-1;s[x]=b,a[x]=b,l[x]=0};return Ge(r,o,(h,m,g,b,x,w)=>{if(w){let y=Math.max(c,0);u.push(i.length/2),i.push(g,b),s.push(y),a.push(y),l.push(0),d=y}switch(h){case le:case ce:{h===le&&(u.push(i.length/2),c=f),i.push(o[m],o[m+1]),s.push(f),a.push(f),l.push(0),d=f,f++;break}case we:{let y=f,P=[],S=s.length,v=xd(g,b,o[m],o[m+1],o[m+2],o[m+3],t,i,P);p(S,P,v,y),d=y,f++;break}case xe:{let y=f,P=[],S=s.length,v=bd(g,b,o[m],o[m+1],o[m+2],o[m+3],o[m+4],o[m+5],t,i,P);p(S,P,v,y),d=y,f++;break}case fe:n.add(u.length-1),d=c;break;default:throw new Error(`tessellate: unknown command code ${h}`)}}),{coords:i,contourStarts:u,anchorA:s,anchorB:a,anchorT:l}}function XV(e,t){let n=t.flattenTolerance??.5,r=YV(e,n);if(e.fillRule==="evenodd"){let a=lR(r);if(a)return Wl(r,a);let l=iR(r);if(l)return Wl(l,fi(l));let{coords:u,contourStarts:c,anchorA:d,anchorB:f,anchorT:p}=r;return JV(u,c,d,f,p)}let o=kb(r);if(o)return Wl(o,fi(o));let i=fi(r);if(i.every(a=>Math.abs(a.winding)<=1))return Wl(r,i);let s=kb(r,!0);return Wl(s,fi(s))}function Wl(e,t){let{coords:n,contourStarts:r,anchorA:o,anchorB:i,anchorT:s}=e,a=[],l=new Map;if(t.forEach((h,m)=>{h.area!==0&&(h.winding!==0?a.push(m):l.has(h.parent)?l.get(h.parent).push(m):l.set(h.parent,[m]))}),a.length<=1&&(a[0]??0)===0){let h=pf(n,r.length>1?r.slice(1):void 0);return{vertices:new Float32Array(n),indices:new Uint32Array(h),anchorA:new Uint32Array(o),anchorB:new Uint32Array(i),anchorT:new Float32Array(s)}}let u=[],c=[],d=[],f=[],p=[];for(let h of a){let m=l.get(h)??[],g=u.length/2,b=[],x=[0];for(let y=t[h].start;y<t[h].end;y++)b.push(n[y*2],n[y*2+1]),c.push(o[y]),d.push(i[y]),f.push(s[y]);for(let y of m){x.push(b.length/2);for(let P=t[y].start;P<t[y].end;P++)b.push(n[P*2],n[P*2+1]),c.push(o[P]),d.push(i[P]),f.push(s[P])}let w=pf(b,x.length>1?x.slice(1):void 0);for(let y of b)u.push(y);for(let y of w)p.push(y+g)}return{vertices:new Float32Array(u),indices:new Uint32Array(p),anchorA:new Uint32Array(c),anchorB:new Uint32Array(d),anchorT:new Float32Array(f)}}function JV(e,t,n,r,o){let i=[],s=e.length/2;for(let a=0;a<t.length;a++){let l=t[a],u=a+1<t.length?t[a+1]:s;for(let c=l+1;c<u-1;c++)i.push(l,c,c+1)}return{vertices:new Float32Array(e),indices:new Uint32Array(i),requiresStencil:!0,anchorA:new Uint32Array(n),anchorB:new Uint32Array(r),anchorT:new Float32Array(o)}}mk();function Kl(e,t,n,r,o,i,s){return e===r&&t===o?[e,t,n+(i-n)*s]:s<.5?[e,t,n]:[r,o,i]}var cR=1e-9;function uR(e,t,n,r,o,i,s,a,l){let u=t.length,c=1;for(;c<u-1&&(l?t[c]<=a:t[c]<a);)c++;let d=t[c-1],f=t[c]-d,p=f>cR?(a-d)/f:0,h=e.points[(c-1)*2],m=e.points[(c-1)*2+1],g=e.points[c*2],b=e.points[c*2+1],[x,w,y]=Kl(n[c-1],r[c-1],o[c-1],n[c],r[c],o[c],p),P=i?i[c-1]+(i[c]-i[c-1])*p:0,S=s?s[c-1]+(s[c]-s[c-1])*p:0;return{x:h+(g-h)*p,y:m+(b-m)*p,a:x,b:w,t:y,w:P,o:S,next:c}}function yf(e,t,n){let r=Math.max(0,t),o=Math.max(0,n);if(r<=0&&o<=0||e.closed)return e;let i=e.points.length/2;if(i<2)return null;let s=e.anchorA??new Uint32Array(i),a=e.anchorB??new Uint32Array(i),l=e.anchorT??new Float32Array(i),u=e.widths,c=e.offsets,d=new Float64Array(i);for(let v=1;v<i;v++){let A=e.points[v*2]-e.points[(v-1)*2],N=e.points[v*2+1]-e.points[(v-1)*2+1];d[v]=d[v-1]+Math.hypot(A,N)}let f=d[i-1],p=r,h=f-o;if(h-p<=cR)return null;let m=uR(e,d,s,a,l,u,c,p,!0),g=uR(e,d,s,a,l,u,c,h,!1),b=[m.x,m.y],x=[m.a],w=[m.b],y=[m.t],P=u?[m.w]:void 0,S=c?[m.o]:void 0;for(let v=m.next;v<g.next;v++)b.push(e.points[v*2],e.points[v*2+1]),x.push(s[v]),w.push(a[v]),y.push(l[v]),P&&P.push(u[v]),S&&S.push(c[v]);return b.push(g.x,g.y),x.push(g.a),w.push(g.b),y.push(g.t),P&&P.push(g.w),S&&S.push(g.o),{points:b,closed:!1,anchorA:new Uint32Array(x),anchorB:new Uint32Array(w),anchorT:new Float32Array(y),...P?{widths:new Float32Array(P)}:{},...S?{offsets:new Float32Array(S)}:{}}}var QV=4,dR=new WeakMap;function fR(e,t=.5){let n=lg(),r=dR.get(e);r===void 0&&dR.set(e,r=new Map);let o=r.get(t);if(o!==void 0&&o.openFill===n)return o.mesh;let i=zl(e,{flattenTolerance:t});return o===void 0&&r.size>=QV&&r.clear(),r.set(t,{mesh:i,openFill:n}),i}var ZV={"source-over":{source:"one",destination:"one-minus-source-alpha"},"source-in":{source:"destination-alpha",destination:"zero"},"source-out":{source:"one-minus-destination-alpha",destination:"zero"},"source-atop":{source:"destination-alpha",destination:"one-minus-source-alpha"},"destination-over":{source:"one-minus-destination-alpha",destination:"one"},"destination-in":{source:"zero",destination:"source-alpha"},"destination-out":{source:"zero",destination:"one-minus-source-alpha"},"destination-atop":{source:"one-minus-destination-alpha",destination:"source-alpha"},xor:{source:"one-minus-destination-alpha",destination:"one-minus-source-alpha"},lighter:{source:"one",destination:"one"},copy:{source:"one",destination:"zero"}};function vb(e){return typeof e=="string"?ZV[e]:e}function Kn(e){if(e===void 0)return!1;let{source:t,destination:n}=vb(e);return t!=="one"||n!=="one-minus-source-alpha"}function mR(e){let{destination:t}=vb(e);return t==="one"||t==="one-minus-source-alpha"}var pR=new WeakMap;function Ab(e){let t=pR.get(e);if(t!==void 0)return t;let n=e.some(r=>r.kind==="group"&&(Kn(r.composite)||Ab(r.children)));return pR.set(e,n),n}function hR(e,t){switch(t){case"zero":return e.ZERO;case"one":return e.ONE;case"source-alpha":return e.SRC_ALPHA;case"one-minus-source-alpha":return e.ONE_MINUS_SRC_ALPHA;case"destination-alpha":return e.DST_ALPHA;case"one-minus-destination-alpha":return e.ONE_MINUS_DST_ALPHA}}function Rb(e,t){let{source:n,destination:r}=vb(t);e.blendFunc(hR(e,n),hR(e,r))}ee();function De(e,t,n){e.gl.drawElements(e.gl.TRIANGLES,t,n,0),e.stats&&e.stats.drawCalls++}function xt(e,t=e.clipDepth){let n=e.gl;if(t===0){n.disable(n.STENCIL_TEST);return}let r=pi(t);n.enable(n.STENCIL_TEST),n.stencilFunc(n.EQUAL,r,r),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)}function pi(e){return e===0?0:(1<<e+1)-1&254}function Nb(e,t){let n=e.gl;n.enable(n.STENCIL_TEST),n.colorMask(!1,!1,!1,!1),n.stencilMask(1),n.stencilFunc(n.ALWAYS,0,1),n.stencilOp(n.KEEP,n.KEEP,n.INVERT),De(e,t,e.gl.UNSIGNED_INT);let r=pi(e.clipDepth);n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.EQUAL,r|1,r|1),n.stencilOp(n.KEEP,n.KEEP,n.INVERT)}function Ib(e){let t=e.gl;t.stencilMask(1),t.clear(t.STENCIL_BUFFER_BIT),t.disable(t.STENCIL_TEST)}ee();Pe();var yR=new WeakMap,gR=new WeakMap;function xf(e,t){let n=yR.get(e);n||(n=new WeakMap,yR.set(e,n));let r=n.get(t);return r||(r={},n.set(t,r)),r}function yr(e,t){if(e===void 0||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Eb(e,t,n,r,o,i){let s=t.uniform("u_color");if(s===void 0)return;let a=xf(e,t),l=a.color;l!==void 0&&l[0]===n&&l[1]===r&&l[2]===o&&l[3]===i||(e.gl.uniform4f(s,n,r,o,i),a.color=[n,r,o,i])}function wf(e,t,n){let r=t.uniform("u_alpha");if(r===void 0)return;let o=xf(e,t);o.alpha!==n&&(e.gl.uniform1f(r,n),o.alpha=n)}function jl(e){if(e.projection)return e.projection;let t=gR.get(e);return t||(t=q.toUniform(q.screenToClip(e.widthCss,e.heightCss)),gR.set(e,t)),t}var gf=new Float32Array(16);function vn(e,t,n=e.state.colorMatrix){let r=e.gl,o=xf(e,t),i=t.uniform("u_colorMatrix");if(i!==void 0){for(let a=0;a<4;a++)for(let l=0;l<4;l++)gf[l*4+a]=n[a*5+l];yr(o.colorMatrix,gf)||(r.uniformMatrix4fv(i,!1,gf),o.colorMatrix=Float32Array.from(gf))}let s=t.uniform("u_colorBias");if(s!==void 0){let a=[n[4],n[9],n[14],n[19]];yr(o.colorBias,a)||(r.uniform4f(s,a[0],a[1],a[2],a[3]),o.colorBias=Float32Array.from(a))}}var bR=65536;function Pf(e){let t=e.meshOrigin;return t?q.translated(e.state.transform,t.x,t.y):e.state.transform}function Tf(e,t,n){let r=e.meshOrigin;if(t===r)return n();e.meshOrigin=t;try{return n()}finally{e.meshOrigin=r}}var Ns=new Float32Array(9),bf=new Float32Array(9);function nt(e,t,n=Pf(e),r=jl(e)){let o=e.gl,i=xf(e,t);bf.set(r),yr(i.proj,bf)||(o.uniformMatrix3fv(t.uniform("u_proj"),!1,bf),i.proj=Float32Array.from(bf)),Ns.set(n);let s=t.uniform("u_origin");if(s!==void 0){let a=0,l=0,u=n[6],c=n[7];if(Math.abs(u)>=bR||Math.abs(c)>=bR){let d=n[0],f=n[1],p=n[3],h=n[4],m=d*h-f*p,g=Math.fround((p*c-h*u)/m),b=Math.fround((f*u-d*c)/m);Number.isFinite(g)&&Number.isFinite(b)&&(a=g,l=b,Ns[6]=d*a+p*l+u,Ns[7]=f*a+h*l+c)}(i.originX!==a||i.originY!==l)&&(o.uniform2f(s,a,l),i.originX=a,i.originY=l)}yr(i.model,Ns)||(o.uniformMatrix3fv(t.uniform("u_model"),!1,Ns),i.model=Float32Array.from(Ns))}function Is(e,t,n,r){let[o,i,s,a]=zn(n);Eb(e,t,o,i,s,a*(r??1)),wf(e,t,e.state.alpha)}var xR=new Set;function PR(e,t){xR.has(e)||(xR.add(e),Xt()&&console.warn(t))}function Mb(e,t){PR(`${e}:${t}`,`weasel drawShader: uniform "${t}" not found in program "${e}". Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`)}function eW(e,t,n,r,o){if(n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Float32Array)&&"id"in n&&typeof n.id=="string"){let i=n,s=Ss(i.id);if(!s){Xt()&&console.warn(`weasel setUniform: TextureHandle "${i.id}" not registered`);return}let a=o.value++;e.activeTexture(e.TEXTURE0+a),r.uploadRegistered(i.id,s.source),r.bind(i.id,a),e.uniform1i(t,a);return}if(n instanceof Float64Array&&(n=Float32Array.from(n)),n instanceof Float32Array){if(n.length===9)e.uniformMatrix3fv(t,!1,n);else if(n.length===16)e.uniformMatrix4fv(t,!1,n);else if(Xt())throw new TypeError(`weasel setUniform: Float32Array must be length 9 (mat3) or 16 (mat4), got ${n.length}`);return}if(Array.isArray(n)){let i=n;switch(i.length){case 2:e.uniform2fv(t,i);break;case 3:e.uniform3fv(t,i);break;case 4:e.uniform4fv(t,i);break;default:if(Xt())throw new TypeError(`weasel setUniform: array length ${i.length} not supported`)}return}if(typeof n=="number"){e.uniform1f(t,n);return}}var tW={float:{fn:"uniform1fv",n:1},vec2:{fn:"uniform2fv",n:2},vec3:{fn:"uniform3fv",n:3},vec4:{fn:"uniform4fv",n:4},int:{fn:"uniform1iv",n:1},ivec2:{fn:"uniform2iv",n:2},ivec3:{fn:"uniform3iv",n:3},ivec4:{fn:"uniform4iv",n:4},bool:{fn:"uniform1iv",n:1},bvec2:{fn:"uniform2iv",n:2},bvec3:{fn:"uniform3iv",n:3},bvec4:{fn:"uniform4iv",n:4},uint:{fn:"uniform1uiv",n:1},uvec2:{fn:"uniform2uiv",n:2},uvec3:{fn:"uniform3uiv",n:3},uvec4:{fn:"uniform4uiv",n:4},mat2:{fn:"uniformMatrix2fv",n:4,matrix:!0},mat3:{fn:"uniformMatrix3fv",n:9,matrix:!0},mat4:{fn:"uniformMatrix4fv",n:16,matrix:!0},mat2x2:{fn:"uniformMatrix2fv",n:4,matrix:!0},mat3x3:{fn:"uniformMatrix3fv",n:9,matrix:!0},mat4x4:{fn:"uniformMatrix4fv",n:16,matrix:!0},mat2x3:{fn:"uniformMatrix2x3fv",n:6,matrix:!0},mat2x4:{fn:"uniformMatrix2x4fv",n:8,matrix:!0},mat3x2:{fn:"uniformMatrix3x2fv",n:6,matrix:!0},mat3x4:{fn:"uniformMatrix3x4fv",n:12,matrix:!0},mat4x2:{fn:"uniformMatrix4x2fv",n:8,matrix:!0},mat4x3:{fn:"uniformMatrix4x3fv",n:12,matrix:!0}};function nW(e){return Array.isArray(e)||e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint32Array}function rW(e,t,n,r){let o=tW[n.type];if(!o){Xt()&&console.warn(`weasel setUniform: array uniform "${t}" has type ${n.type}, which cannot be written as a whole`);return}if(r.length%o.n!==0||r.length>o.n*n.size){if(Xt())throw new TypeError(`weasel setUniform: "${t}" is ${n.type}[${n.size}], so its value must hold a multiple of ${o.n} numbers, at most ${o.n*n.size}; got ${r.length}`);return}if(r.length===0)return;let i=e[o.fn];o.matrix?i.call(e,n.location,!1,r):i.call(e,n.location,r)}function Cb(e,t,n,r,o,i){for(let[s,a]of Object.entries(r)){let l=t.uniformArray(s);if(l&&nW(a)){rW(e,s,l,a);continue}let u=t.uniform(s);if(u===void 0){Mb(n,s);continue}eW(e,u,a,o,i)}}function TR(e,t){let{gl:n,programRegistry:r,quadVbo:o,quadIbo:i,textureCache:s}=e,a=e.ensureProgram?.(t.program.id)??r.get(t.program.id);if(!a){PR(`${t.program.id}:(program)`,`weasel drawShader: program "${t.program.id}" has no compiled program on this renderer. Register its source with the module-level registerProgram() first; a source that failed to compile is reported above.`);return}if(!o||!i){console.warn("weasel drawShader: quad geometry not initialized");return}n.useProgram(a.handle);let l=a.attribute("a_position"),u=a.attribute("a_uv");n.bindBuffer(n.ARRAY_BUFFER,o),l!==void 0&&(n.enableVertexAttribArray(l),n.vertexAttribPointer(l,2,n.FLOAT,!1,16,0)),u!==void 0&&(n.enableVertexAttribArray(u),n.vertexAttribPointer(u,2,n.FLOAT,!1,16,8)),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i);let c=a.uniform("u_proj");c!==void 0&&n.uniformMatrix3fv(c,!1,q.toUniform(jl(e)));let d=a.uniform("u_bounds");d!==void 0&&n.uniform4f(d,t.bounds.x,t.bounds.y,t.bounds.w,t.bounds.h);let f=a.uniform("u_fragOrigin");if(f!==void 0){let[h,m]=(e.renderTarget?e.renderTarget.fragOrigin:e.fragOrigin)??[0,0];n.uniform2f(f,h,m)}let p=a.uniform("u_view");p!==void 0&&n.uniformMatrix3fv(p,!1,q.toUniform(e.state.transform)),oW(n,a,e.state.transform,t.bounds),Cb(n,a,t.program.id,t.uniforms,s,{value:1}),xt(e),De(e,6,e.gl.UNSIGNED_SHORT),l!==void 0&&n.disableVertexAttribArray(l),u!==void 0&&n.disableVertexAttribArray(u),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}function oW(e,t,n,r){let o=t.uniform("u_screenToLocal"),i=t.uniform("u_worldOrigin");if(o===void 0&&i===void 0)return;let s=q.invert(n),a=0,l=0,u=q.scaled(q.identity(),0,0);if(s){let c=s[0]*r.x+s[3]*r.y+s[6],d=s[1]*r.x+s[4]*r.y+s[7];(Math.abs(c)>=wR||Math.abs(d)>=wR)&&(a=Math.fround(c),l=Math.fround(d)),u=q.multiply(q.translated(q.identity(),-a,-l),s)}o!==void 0&&e.uniformMatrix3fv(o,!1,q.toUniform(u)),i!==void 0&&e.uniform2f(i,a,l)}var wR=8192;ee();function kR(e,t){if(e.kind!=="rect"||!(t[1]===0&&t[3]===0||t[0]===0&&t[4]===0))return null;let r=t[0]*e.x+t[3]*e.y+t[6],o=t[1]*e.x+t[4]*e.y+t[7],i=e.x+e.width,s=e.y+e.height,a=t[0]*i+t[3]*s+t[6],l=t[1]*i+t[4]*s+t[7];return{x0:Math.min(r,a),y0:Math.min(o,l),x1:Math.max(r,a),y1:Math.max(o,l)}}function vR(e,t){return{x0:Math.max(e.x0,t.x0),y0:Math.max(e.y0,t.y0),x1:Math.min(e.x1,t.x1),y1:Math.min(e.y1,t.y1)}}var AR=16,iW=8,sW=new Float64Array(0);function RR(e,t,n){if(e===null&&t.length===0)return null;let r=sW;if(t.length===1)r=t[0];else if(t.length>1){r=new Float64Array(t.reduce((i,s)=>i+s.length,0));let o=0;for(let i of t)r.set(i,o),o+=i.length}return{rect:e,planes:r,slanted:n}}var SR=new WeakMap;function NR(e,t){let n=SR.get(e);if(n!==void 0&&n.m[0]===t[0]&&n.m[1]===t[1]&&n.m[2]===t[3]&&n.m[3]===t[4]&&n.m[4]===t[6]&&n.m[5]===t[7])return n.planes;let r=aW(e,t);return SR.set(e,{m:Float64Array.of(t[0],t[1],t[3],t[4],t[6],t[7]),planes:r}),r}function aW(e,t){let n=Hg(e);if(n===null)return null;let r=[];for(let o=0;o<n.length;o+=2)r.push(t[0]*n[o]+t[3]*n[o+1]+t[6],t[1]*n[o]+t[4]*n[o+1]+t[7]);return Fb(r,iW)}function Fb(e,t){let n=[];for(let s=0;s<e.length;s+=2){let a=n.length;a>=2&&n[a-2]===e[s]&&n[a-1]===e[s+1]||n.push(e[s],e[s+1])}for(;n.length>=4&&n[0]===n[n.length-2]&&n[1]===n[n.length-1];)n.length-=2;if(n.length<6)return null;Gg(n)<0&&Ug(n);let r=Vg(n);if(r.length<6||r.length/2>t||!Wg(r))return null;let o=r.length/2,i=new Float64Array(o*3);for(let s=0;s<o;s++){let a=r[s*2],l=r[s*2+1],u=r[(s+1)%o*2],c=r[(s+1)%o*2+1],d=Math.hypot(u-a,c-l),f=-(c-l)/d,p=(u-a)/d;i[s*3]=f,i[s*3+1]=p,i[s*3+2]=-(f*a+p*l)}return i}function gr(e,t,n){let r=e.rect;if(r!==null&&(t<r.x0||t>r.x1||n<r.y0||n>r.y1))return!1;let o=e.planes;for(let i=0;i<o.length;i+=3)if(o[i]*t+o[i+1]*n+o[i+2]<0)return!1;return!0}function Sf(e,t,n,r,o){let i=e.rect;if(i!==null){let a=!0,l=!0,u=!0,c=!0;for(let d=0,f=n;d<r;d++,f+=o){let p=t[f],h=t[f+1];a&&=p<=i.x0,l&&=p>=i.x1,u&&=h<=i.y0,c&&=h>=i.y1}if(a||l||u||c)return!0}let s=e.planes;for(let a=0;a<s.length;a+=3){let l=!0;for(let u=0,c=n;u<r&&l;u++,c+=o)l=s[a]*t[c]+s[a+1]*t[c+1]+s[a+2]<=0;if(l)return!0}return!1}function Lb(e,t,n,r,o,i){let s=r.rect,a=r.planes,l=s===null?0:4,u=l+a.length/3;if(u===0)return o.set(e.subarray(0,t*n)),t;let c=e,d=u%2===0?i:o,f=t;for(let p=0;p<u;p++){if(p<l){let h=p<2?0:1,m=p===0?s.x0:p===1?s.x1:p===2?s.y0:s.y1;f=lW(c,f,n,h,m,p%2===0?1:-1,d)}else{let h=(p-l)*3;f=$l(c,f,n,a[h],a[h+1],a[h+2],d)}c=d,d=d===o?i:o}return f}function lW(e,t,n,r,o,i,s){if(t===0)return 0;let a=0,l=t-1,u=i*(e[l*n+r]-o)>=0;for(let c=0;c<t;c++){let d=i*(e[c*n+r]-o)>=0;if(d!==u){let[f,p]=IR(e,l*n,c*n),h=(o-e[f+r])/(e[p+r]-e[f+r]);ER(e,f,p,h,n,s,a*n),s[a*n+r]=o,a++}d&&(s.set(e.subarray(c*n,c*n+n),a*n),a++),l=c,u=d}return a}function $l(e,t,n,r,o,i,s){if(t===0)return 0;let a=0,l=t-1,u=r*e[l*n]+o*e[l*n+1]+i>=0;for(let c=0;c<t;c++){let d=c*n,f=r*e[d]+o*e[d+1]+i>=0;if(f!==u){let[p,h]=IR(e,l*n,d),m=r*e[p]+o*e[p+1]+i,g=r*e[h]+o*e[h+1]+i;ER(e,p,h,m/(m-g),n,s,a*n),a++}f&&(s.set(e.subarray(c*n,c*n+n),a*n),a++),l=c,u=f}return a}var Ob=[0,0];function IR(e,t,n){let r=e[n]<e[t]||e[n]===e[t]&&e[n+1]<e[t+1];return Ob[0]=r?n:t,Ob[1]=r?t:n,Ob}function ER(e,t,n,r,o,i,s){for(let a=0;a<o;a++)i[s+a]=e[t+a]+r*(e[n+a]-e[t+a])}function Es(e){return qA(e.flattenTolerance,e.state.transform)}function kf(e,t){return fR(t,Es(e))}function _b(e,t){return e.meshCache.handleFor(t)}function Yl(e,t){return _b(e,kf(e,t))}ee();function vf(e){return e===Ht||yr(Ht,e)}var ql={enabled:!0};function Xl(e){return ql.enabled||vf(e.state.colorMatrix)}function Db(e,t,n,r,o){let i=e.state.colorMatrix,s=e.state.alpha;if(vf(i))return[t,n,r,o*s];if(!ql.enabled)return[t,n,r,o];let a=$A(i,t,n,r,o);return a[3]*=s,a}function Af(e,t,n,r,o,i){return vf(e.state.colorMatrix)?(i[0]=t,i[1]=n,i[2]=r,i[3]=o*e.state.alpha,i):Db(e,t,n,r,o)}var MR=[1,1,1,1],uW=[0,6,12,18];function cW(e){let t=e.state.colorMatrix,n=e.state.alpha;if(vf(t))return n===1?MR:[1,1,1,n];if(!ql.enabled)return null;for(let r=0;r<20;r++){let o=t[r];if(uW.includes(r)?o<0||o>1:o!==0)return null}return[t[0],t[6],t[12],t[18]*n]}function Ms(e,t){let n=cW(e);if(n!==null)return{colorMatrix:Ht,alpha:1,tint:n,slot:0};let r=e.state.colorMatrix,o=e.state.alpha;return t?{colorMatrix:r,alpha:o,tint:MR,slot:0}:{colorMatrix:r,alpha:1,tint:[1,1,1,o],slot:0}}function Bb(e,t,n){for(let r=0;r<e.length;r++){let o=e[r];if(o.alpha===n&&(o.colorMatrix===t||yr(o.colorMatrix,t)))return r}return e.length<(ql.enabled?Vn:1)?e.length:-1}var CR=new Float32Array(16*Vn),OR=new Float32Array(4*Vn),FR=new Float32Array(Vn),LR=new WeakMap;function dW(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;n++){let r=e[n],o=t[n];if(r.alpha!==o.alpha||r.colorMatrix!==o.colorMatrix&&!yr(r.colorMatrix,o.colorMatrix))return!1}return!0}function _R(e,t,n){let r=LR.get(e);r||(r=new WeakMap,LR.set(e,r));let o=r.get(t);if(o!==void 0&&dW(o,n))return;let i=n.length;for(let a=0;a<i;a++){let l=n[a].colorMatrix;for(let u=0;u<4;u++){for(let c=0;c<4;c++)CR[16*a+c*4+u]=l[u*5+c];OR[4*a+u]=l[u*5+4]}FR[a]=n[a].alpha}let s=e.gl;s.uniformMatrix4fv(t.uniform("u_colorMatrix"),!1,CR.subarray(0,16*i)),s.uniform4fv(t.uniform("u_colorBias"),OR.subarray(0,4*i)),s.uniform1fv(t.uniform("u_alpha"),FR.subarray(0,i)),r.set(t,n.slice())}var Cs=q.identity(),fW=new Int32Array(Array.from({length:mt},(e,t)=>t)),Hb=new Float32Array(2*mt),DR=new Int32Array(4*bs);function ye(e){let t=e.drawBatch,n=e.batchState;if(t.length===0||n===void 0){e.batchState=void 0;return}let r=e.gl,o=n.matrices.length>1,i=n.hulls!==void 0,s=n.areaGlyphs,a=(o||i||s)&&e.batchVariants?e.batchVariants.get(o,i,s):e.batchFill;r.useProgram(a.handle);let l=t.uploadAndBind();nt(e,a,Cs),Eb(e,a,1,1,1,1),_R(e,a,n.matrices),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,e.whiteTexture);for(let u=0;u<n.textures.length;u++){let c=n.textures[u];if(c.kind==="atlas"){e.textureCache.bind(c.id,u+1),Hb[2*(u+1)]=c.fieldScale[0],Hb[2*(u+1)+1]=c.fieldScale[1];continue}e.imageCache.bind(c.image,u+1),e.imageCache.setMagFilter(c.image,c.sampling==="nearest"?r.NEAREST:r.LINEAR),e.imageCache.setMinFilter(c.image,c.mips)}n.ramps&&e.gradRamps.bind(xs),r.uniform1iv(a.uniform("u_samplers"),fW),r.uniform2fv(a.uniform("u_fieldScale"),Hb),i&&pW(r,a,n),xt(e,n.clipDepth),De(e,l,e.gl.UNSIGNED_INT),r.activeTexture(r.TEXTURE0),r.bindVertexArray(null),t.reset(),e.batchState=void 0}function pW(e,t,n){for(let{set:r,start:o}of n.hulls)DR.set(r.planes,4*o);e.uniform4iv(t.uniform("u_hullPlanes"),DR,0,4*n.hullPlanes)}function Ql(e,t,n=e.state.transform){let r=e.clipStack.reduce((o,i)=>o+(i.depth===0?1:0),0);if(e.clipDepth+r+1>7)throw new Error("weasel: clip nesting depth exceeded (max 7). You can't nest more than 7 levels of clipped containers in a single draw tree. Flatten the hierarchy or compose poses outside the scene graph.");mW(e,t,n)}var hW=q.identity();function mW(e,t,n){let r=kR(t,n),o=r===null?null:Gb(e),i=o===null?null:Bv(t,n,o),s=i?i.rect:r,a=Rf(e),l=e.clipStack[e.clipStack.length-1],u=l===void 0?null:l.uncutHulls,c=s===null?gW(e,t,n):null,d=c&&(a?Bg(a,c.set):c.set),f=s===null&&c===null?yW(e,t,n):null;if(s!==null){let p=i?i.hull:null,h=p?BR(u,p.set):!1;e.clipStack.push({path:t,transform:n,rect:s,hull:p,planes:null,hulls:a,uncutHulls:h,depth:0})}else if(c&&d){let p=BR(u,c.set);e.clipStack.push({path:t,transform:n,rect:null,hull:c,planes:null,hulls:d,uncutHulls:p,depth:0})}else if(f!==null)e.clipStack.push({path:t,transform:n,rect:null,hull:null,planes:f,hulls:a,uncutHulls:u,depth:0});else{Vb(e);let p=e.clipDepth+1;WR(e,t,p,n),e.clipDepth=p,e.clipStack.push({path:t,transform:n,rect:null,hull:null,planes:null,hulls:a,uncutHulls:u,depth:p})}VR(e)}function yW(e,t,n){if(!HR(e))return null;let r=NR(t,n);if(r===null)return null;let o=r.length/3;for(let i of e.clipStack)i.planes&&(o+=i.planes.length/3);return o<=AR?r:null}function BR(e,t){return e===!1?!1:(e?Bg(e,t):t)??!1}function Gb(e){return!e.batchVariants?.hulls||e.renderTarget||e.projection||e.deviceWidth===void 0||e.deviceHeight===void 0?null:Dv(jl(e),e.fragOrigin??[0,0],e.deviceWidth,e.deviceHeight)}function HR(e){return e.batchVariants?.cuts!==!1&&Gb(e)===null}function gW(e,t,n){let r=Gb(e);return r===null?null:Dg(t,n,r)}function Rf(e){if(e.uncutHulls!==void 0)return e.uncutHulls;let t=e.clipStack;return t.length===0?null:t[t.length-1].hulls}function Ub(e){let t=e.clipStack.pop();t.depth>0&&(bW(e,GR(t),t.depth-1,UR(t)),e.clipDepth=t.depth-1),VR(e)}function GR(e){return e.hull?e.hull.path:e.path}function UR(e){return e.hull?hW:e.transform}function Vb(e){for(let t of e.clipStack){if(t.depth!==0)continue;let n=e.clipDepth+1;WR(e,GR(t),n,UR(t)),t.depth=n,e.clipDepth=n}}function VR(e){let t=null,n=[];for(let r of e.clipStack)r.rect&&(t=t?vR(t,r.rect):r.rect),r.planes&&n.push(r.planes);e.drawBatch.clip=RR(t,n,HR(e))}function Wb(e){let t=e.clipStack;if(t.length===0||e.uncut)return e.clipDepth;for(let n=t.length-1;n>=0;n--)if(t[n].rect===null&&t[n].hull===null&&t[n].planes===null)return t[n].depth;for(let n of t)if(n.depth>0)return n.depth-1;return e.clipDepth}function lo(e){let t=e.drawBatch.clip;e.drawBatch.clip=null;let n=e.clipStack[e.clipStack.length-1];return n!==void 0&&n.uncutHulls?(e.uncutHulls=n.uncutHulls,t):(Vb(e),e.uncut=!0,t)}function uo(e,t){e.drawBatch.clip=t,e.uncut=!1,e.uncutHulls=void 0}function on(e,t,n,r){let o=lo(e);r(e,t,n),uo(e,o)}function sn(e){ye(e),e.clipStack.length>0&&Vb(e)}function Jl(e,t,n){let r=e.gl,o=Yl(e,t);r.useProgram(e.pathFill.handle),r.bindVertexArray(o.vao);let i=t.kind==="polygon"?t.origin:void 0;nt(e,e.pathFill,i?q.translated(n,i.x,i.y):n),De(e,o.indexCount,e.gl.UNSIGNED_INT),r.bindVertexArray(null)}function WR(e,t,n,r=e.state.transform){ye(e);let o=e.gl,i=pi(n-1),s=1<<n,a=i|s;o.enable(o.STENCIL_TEST),o.colorMask(!1,!1,!1,!1),Yl(e,t).requiresStencil?(o.stencilMask(1),o.stencilFunc(o.ALWAYS,0,1),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),Jl(e,t,r),o.stencilMask(s),o.stencilFunc(o.EQUAL,a|1,i|1),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),Jl(e,t,r),o.stencilMask(1),o.stencilFunc(o.ALWAYS,0,1),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),Jl(e,t,r)):(o.stencilMask(s),o.stencilFunc(o.EQUAL,a,i),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),Jl(e,t,r)),o.colorMask(!0,!0,!0,!0),o.stencilMask(255)}function bW(e,t,n,r=e.state.transform){e.batchState!==void 0&&e.batchState.clipDepth>n&&ye(e);let o=e.gl;o.enable(o.STENCIL_TEST);let i=1<<n+1,s=pi(n)|i;o.colorMask(!1,!1,!1,!1),o.stencilMask(i),o.stencilFunc(o.EQUAL,s,s),o.stencilOp(o.KEEP,o.KEEP,o.ZERO),Jl(e,t,r),o.colorMask(!0,!0,!0,!0),o.stencilMask(255)}var Nf=bt(),Poe=Nf.reflection;function An(e){return Nf.get(e)??null}function If(e,t,n){if(Nf.has(e)&&!Xt())throw new Error(`weasel registerProgram: duplicate program id "${e}". In production, re-registration is not allowed. Pass a unique id or call in dev mode.`);return Nf.set(e,{vert:t,frag:n}),{id:e}}var zR=`#version 300 es
369
+ `,SA=ob(nb),kA=ob(tb),vA=ob(jU),ib=["u_atlas","u_synthBold","u_fieldScale"],AA=e=>e!=="u_origin",RA=[...Xd.filter(AA),...ib],NA=[...qd.filter(AA),...ib],IA=["u_proj","u_model","u_worldInv","u_sampler",...ib],EA=["a_position","a_uv","a_post","a_texSlot"];var Zd=class{gl;target=null;constructor(t){this.gl=t}acquire(t,n){let r=this.target;if(r&&r.width>=t&&r.height>=n)return r;let o=Math.max(r?.width??0,MA(t)),i=Math.max(r?.height??0,MA(n));return this.release(),this.target=this.create(o,i),this.target}release(){this.target&&(this.gl.deleteFramebuffer(this.target.fbo),this.gl.deleteTexture(this.target.texture),this.target=null)}create(t,n){let r=this.gl,o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texImage2D(r.TEXTURE_2D,0,r.RGBA8,t,n,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null);let i=r.createFramebuffer();return r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,o,0),r.bindFramebuffer(r.FRAMEBUFFER,null),{fbo:i,texture:o,width:t,height:n}}};function MA(e){let t=64;for(;t<e;)t*=2;return t}var Hl=class{constructor(t){this.gl=t;this.finalizer=new FinalizationRegistry(n=>{this.persistent.delete(n)&&this.pendingDeletes.push(n)})}gl;map=new WeakMap;seen=new WeakSet;finalizer;persistent=new Set;pendingDeletes=[];disposed=!1;transientThisFrame=[];handleFor(t){let n=this.map.get(t);if(n)return n;let{handle:r,vbo:o,ibo:i}=this.upload(t);this.map.set(t,r);let s={vao:r.vao,vbo:o,ibo:i};return this.persistent.add(s),this.finalizer.register(t,s,t),r}uploadTransient(t){let{handle:n,vbo:r,ibo:o}=this.upload(t);return this.transientThisFrame.push({vao:n.vao,vbo:r,ibo:o}),n}uploadRecurring(t){return this.seen.has(t)?this.handleFor(t):(this.seen.add(t),this.uploadTransient(t))}freeTransient(){if(this.transientThisFrame.length===0)return;let t=this.gl;if(t.isContextLost()){this.transientThisFrame.length=0;return}for(let n of this.transientThisFrame)t.deleteVertexArray(n.vao),t.deleteBuffer(n.vbo),t.deleteBuffer(n.ibo);this.transientThisFrame.length=0}_transientCount(){return this.transientThisFrame.length}drainPendingDeletes(){if(this.pendingDeletes.length===0)return;let t=this.gl;if(t.isContextLost()){this.pendingDeletes.length=0;return}for(let n of this.pendingDeletes)t.deleteVertexArray(n.vao),t.deleteBuffer(n.vbo),t.deleteBuffer(n.ibo);this.pendingDeletes.length=0}dispose(){if(!this.disposed){this.disposed=!0,this.freeTransient();for(let t of this.persistent)this.pendingDeletes.push(t);this.persistent.clear(),this.drainPendingDeletes()}}_pendingDeleteCount(){return this.pendingDeletes.length}_enqueueDeleteForTest(t){this.pendingDeletes.push(t)}upload(t){let n=this.gl,r=n.createVertexArray();if(!r)throw new Error("createVertexArray returned null");n.bindVertexArray(r);let o=n.createBuffer();if(!o)throw new Error("createBuffer (VBO) returned null");n.bindBuffer(n.ARRAY_BUFFER,o),n.bufferData(n.ARRAY_BUFFER,t.vertices,n.STATIC_DRAW),n.enableVertexAttribArray($c),n.vertexAttribPointer($c,2,n.FLOAT,!1,0,0);let i=n.createBuffer();if(!i)throw new Error("createBuffer (IBO) returned null");return n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.indices,n.STATIC_DRAW),n.bindVertexArray(null),{handle:{vao:r,indexCount:t.indices.length,requiresStencil:t.requiresStencil??!1,anchorA:t.anchorA,anchorB:t.anchorB,anchorT:t.anchorT},vbo:o,ibo:i}}};function Gl(e,t){e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1)}function $U(e,t){e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t)}var Ul=class{constructor(t){this.gl=t}gl;map=new Map;wraps=new Map;registered=new Map;sweptVersion=-1;has(t){return this.map.has(t)}upload(t,n,r="clamp"){return this.ensure(t,n,r,$U)}ensure(t,n,r,o){let i=this.map.get(t);if(i)return this.wraps.get(t)!==r&&this.applyWrap(t,i,r),t;let s=this.gl,a=s.createTexture();if(!a)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);let l=r==="repeat"?s.REPEAT:s.CLAMP_TO_EDGE;return s.bindTexture(s.TEXTURE_2D,a),o(s,n),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,l),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,l),s.bindTexture(s.TEXTURE_2D,null),this.map.set(t,a),this.wraps.set(t,r),t}uploadRegistered(t,n,r="clamp"){let o=this.map.get(t);if(o&&this.registered.get(t)!==n){let i=this.gl;i.bindTexture(i.TEXTURE_2D,o),Gl(i,n),i.bindTexture(i.TEXTURE_2D,null)}return this.registered.set(t,n),this.ensure(t,n,r,Gl)}replaces(t,n){return this.map.has(t)&&this.registered.get(t)!==n}sweep(t){let n=t.getVersion();if(n!==this.sweptVersion){this.sweptVersion=n;for(let r of this.registered.keys())t.has(r)||(this.gl.deleteTexture(this.map.get(r)??null),this.map.delete(r),this.wraps.delete(r),this.registered.delete(r))}}applyWrap(t,n,r){let o=this.gl,i=r==="repeat"?o.REPEAT:o.CLAMP_TO_EDGE;o.bindTexture(o.TEXTURE_2D,n),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,i),o.bindTexture(o.TEXTURE_2D,null),this.wraps.set(t,r)}uploadR8(t,n,r,o){if(this.map.has(t))return;let i=this.gl,s=i.createTexture();if(!s)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);i.bindTexture(i.TEXTURE_2D,s),i.pixelStorei(i.UNPACK_ALIGNMENT,1),i.texImage2D(i.TEXTURE_2D,0,i.R8,n,r,0,i.RED,i.UNSIGNED_BYTE,o),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.wraps.set(t,"clamp")}subImageR8(t,n,r,o,i,s){let a=this.map.get(t);if(!a)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let l=this.gl;l.bindTexture(l.TEXTURE_2D,a),l.pixelStorei(l.UNPACK_ALIGNMENT,1),l.texSubImage2D(l.TEXTURE_2D,0,n,r,o,i,l.RED,l.UNSIGNED_BYTE,s),l.pixelStorei(l.UNPACK_ALIGNMENT,4),l.bindTexture(l.TEXTURE_2D,null)}uploadRGBA(t,n,r,o){if(this.map.has(t))return;let i=this.gl,s=i.createTexture();if(!s)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n,r,0,i.RGBA,i.UNSIGNED_BYTE,o),i.generateMipmap(i.TEXTURE_2D),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.wraps.set(t,"clamp")}subImageRGBA(t,n,r,o,i,s){let a=this.map.get(t);if(!a)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let l=this.gl;l.bindTexture(l.TEXTURE_2D,a),l.texSubImage2D(l.TEXTURE_2D,0,n,r,o,i,l.RGBA,l.UNSIGNED_BYTE,s),l.generateMipmap(l.TEXTURE_2D),l.bindTexture(l.TEXTURE_2D,null)}bind(t,n){let r=this.map.get(t);if(!r)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let o=this.gl;o.activeTexture(o.TEXTURE0+n),o.bindTexture(o.TEXTURE_2D,r)}free(){let t=this.gl;for(let n of this.map.values())t.deleteTexture(n);this.map.clear(),this.wraps.clear(),this.registered.clear()}};var Is=xt(),pi=Is.reflection;var fi=[];function ef(e,t){let n={prefix:e,owner:t};return fi.push(n),()=>{let r=fi.indexOf(n);r!==-1&&fi.splice(r,1)}}function CA(e){return OA(e)!==void 0}function OA(e){for(let t=0;t<fi.length;t++)if(e.startsWith(fi[t].prefix))return fi[t].owner}function Es(e){let t=fi.length>0?OA(e):void 0,n=Is.get(e);return n?t?.touched?(t.touched(e),Is.get(e)??null):n:t?(t.revive(e),Is.get(e)??null):null}function tf(e,t,n){return Is.set(e,n?{source:t,size:n}:{source:t}),{id:e}}function nf(e){return Is.delete(e.id)}var FA=4096,Wl=new Set;function rf(e){for(let t of Wl)t.release(e)}function LA(e){for(let t of Wl)if(t.drewInLatestFrame(e))return!0;return!1}function _A(){let e=1/0;for(let t of Wl)e=Math.min(e,t.maxTextureSide);return Number.isFinite(e)?e:FA}var Ms=class{constructor(t,n="linear"){this.gl=t;this.minification=n;let r=t.getParameter(t.MAX_TEXTURE_SIZE);this.maxTextureSide=typeof r=="number"&&r>0?r:FA,this.finalizer=new FinalizationRegistry(o=>{this.textures.delete(o)&&this.pendingDeletes.push(o)}),Wl.add(this)}gl;minification;maxTextureSide;map=new WeakMap;textures=new Set;magFilters=new WeakMap;minFilters=new WeakMap;finalizer;pendingDeletes=[];mipped=new WeakSet;frame=0;lastDrawn=new WeakMap;beginFrame(){this.frame++,this.drainPendingDeletes()}drewInLatestFrame(t){return this.lastDrawn.get(t)===this.frame}drainPendingDeletes(){if(this.pendingDeletes.length!==0){for(let t of this.pendingDeletes)this.gl.deleteTexture(t);this.pendingDeletes.length=0}}release(t){let n=this.map.get(t);n&&(this.gl.deleteTexture(n),this.textures.delete(n),this.finalizer.unregister(t),this.map.delete(t),this.magFilters.delete(t),this.minFilters.delete(t),this.lastDrawn.delete(t),this.mipped.delete(t))}dispose(){for(let t of this.textures)this.gl.deleteTexture(t);this.drainPendingDeletes(),this.abandon()}abandon(){this.textures.clear(),this.pendingDeletes.length=0,Wl.delete(this)}upload(t,n,r){this.lastDrawn.set(t,this.frame);let o=this.map.get(t);if(o)return o;let i=this.gl,s=i.createTexture();if(!s)throw new Error("GLImageCache: createTexture failed");i.bindTexture(i.TEXTURE_2D,s),Gl(i,n),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),this.minFilters.set(t,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),this.magFilters.set(t,i.LINEAR);let[a,l]=YU(i,r);return i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,a),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,l),this.minification==="mipmap"&&(i.generateMipmap(i.TEXTURE_2D),this.mipped.add(t)),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.textures.add(s),this.finalizer.register(t,s,t),s}lacksMipmaps(t){return this.minification==="auto"&&!this.mipped.has(t)}hasMipmaps(t){return this.mipped.has(t)}buildMipmaps(t){let n=this.map.get(t);if(!n||this.mipped.has(t))return;let r=this.gl;r.bindTexture(r.TEXTURE_2D,n),r.generateMipmap(r.TEXTURE_2D),r.bindTexture(r.TEXTURE_2D,null),this.mipped.add(t)}setMinFilter(t,n){let r=this.gl,o=n&&this.mipped.has(t)?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;this.minFilters.get(t)!==o&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),this.minFilters.set(t,o))}bind(t,n){let r=this.map.get(t);if(!r)throw new Error("GLImageCache: image not uploaded; call upload() first");this.lastDrawn.set(t,this.frame);let o=this.gl;o.activeTexture(o.TEXTURE0+n),o.bindTexture(o.TEXTURE_2D,r)}setMagFilter(t,n){this.magFilters.get(t)!==n&&(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,n),this.magFilters.set(t,n))}};function YU(e,t){switch(t){case"repeat":return[e.REPEAT,e.REPEAT];case"repeat-x":return[e.REPEAT,e.CLAMP_TO_EDGE];case"repeat-y":return[e.CLAMP_TO_EDGE,e.REPEAT];default:return[e.CLAMP_TO_EDGE,e.CLAMP_TO_EDGE]}}Pe();var mi=256,fW=16,pW=1024;function hW(e,t="rgb"){let n=new Uint8ClampedArray(mi*4);if(e.length===0)return n;let r=Sb(e);for(let o=0;o<mi;o++){let[i,s,a,l]=kb(r,o/(mi-1),t);n[o*4]=i*255,n[o*4+1]=s*255,n[o*4+2]=a*255,n[o*4+3]=l*255}return n}function rR(e,t){return`${t}|${JSON.stringify(e)}`}var $l=class{constructor(t){this.gl=t}gl;rowByKey=new Map;texture=null;rows=0;pixels=new Uint8ClampedArray(0);totalQueries=0;cacheHits=0;get height(){return this.rows}upload(t,n="rgb"){let r=rR(t,n);this.totalQueries++;let o=this.rowByKey.get(r);if(o!==void 0)return this.cacheHits++,this.rowByKey.delete(r),this.rowByKey.set(r,o),o;let i=this.claimRow();return this.writeRow(i,hW(t,n)),this.rowByKey.set(r,i),i}wouldReshape(t,n="rgb"){return this.rowByKey.size===0?!1:!this.rowByKey.has(rR(t,n))&&this.rowByKey.size>=this.rows}rowV(t){return(t+.5)/(this.rows||1)}bind(t){let n=this.gl;n.activeTexture(n.TEXTURE0+t),n.bindTexture(n.TEXTURE_2D,this.texture)}hitRate(){return this.totalQueries===0?0:this.cacheHits/this.totalQueries}resetStats(){this.totalQueries=0,this.cacheHits=0}free(){this.texture&&this.gl.deleteTexture(this.texture),this.texture=null,this.rows=0,this.pixels=new Uint8ClampedArray(0),this.rowByKey.clear()}claimRow(){if(this.rowByKey.size<this.rows)return this.rowByKey.size;if(this.rows<pW)return this.resize(this.rows===0?fW:this.rows*2),this.rowByKey.size;let[t,n]=this.rowByKey.entries().next().value;return this.rowByKey.delete(t),n}resize(t){let n=this.gl,r=new Uint8ClampedArray(mi*t*4);if(r.set(this.pixels),this.pixels=r,this.rows=t,this.texture)n.bindTexture(n.TEXTURE_2D,this.texture);else{let o=n.createTexture();if(!o)throw new Error("GradientRampAtlas: createTexture failed");this.texture=o,n.bindTexture(n.TEXTURE_2D,o),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}n.texImage2D(n.TEXTURE_2D,0,n.RGBA,mi,t,0,n.RGBA,n.UNSIGNED_BYTE,this.pixels),n.bindTexture(n.TEXTURE_2D,null)}writeRow(t,n){let r=this.gl;this.pixels.set(n,t*mi*4),r.bindTexture(r.TEXTURE_2D,this.texture),r.texSubImage2D(r.TEXTURE_2D,0,0,t,mi,1,r.RGBA,r.UNSIGNED_BYTE,n),r.bindTexture(r.TEXTURE_2D,null)}};Z();Z();function oR(e,t,n){for(let r=0;r<4;r++)for(let o=0;o<5;o++){let i=o===4?e[r*5+4]:0;for(let s=0;s<4;s++)i+=e[r*5+s]*t[s*5+o];n[r*5+o]=i}return n}function iR(e,t,n,r,o){return[ls(e[0]*t+e[1]*n+e[2]*r+e[3]*o+e[4]),ls(e[5]*t+e[6]*n+e[7]*r+e[8]*o+e[9]),ls(e[10]*t+e[11]*n+e[12]*r+e[13]*o+e[14]),ls(e[15]*t+e[16]*n+e[17]*r+e[18]*o+e[19])]}var Ut=new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),gf=class{transformStack=[q.identity()];alphaStack=[1];colorMatrixStack=[Ut];get transform(){return this.transformStack[this.transformStack.length-1]}get alpha(){return this.alphaStack[this.alphaStack.length-1]}get colorMatrix(){return this.colorMatrixStack[this.colorMatrixStack.length-1]}push(t){let n=this.transform,r=t.transform?q.multiply(n,t.transform):n,o=t.alpha!==void 0?this.alpha*t.alpha:this.alpha,i=t.colorMatrix?oR(this.colorMatrix,t.colorMatrix instanceof Float32Array?t.colorMatrix:new Float32Array(t.colorMatrix),new Float32Array(20)):this.colorMatrix;this.transformStack.push(r),this.alphaStack.push(o),this.colorMatrixStack.push(i)}pushIsolated(t){this.push(t);let n={alpha:this.alpha,colorMatrix:this.colorMatrix};this.pop();let r=this.transform;return this.transformStack.push(t.transform?q.multiply(r,t.transform):r),this.alphaStack.push(1),this.colorMatrixStack.push(Ut),n}reset(){this.transformStack.length=1,this.alphaStack.length=1,this.colorMatrixStack.length=1}pop(){if(this.transformStack.length<=1)throw new Error("GroupState.pop: cannot pop root frame");this.transformStack.pop(),this.alphaStack.pop(),this.colorMatrixStack.pop()}};Z();var sR=mt;function aR(e,t){if(typeof e=="number")return e;let n=e?.px??sR,[r,o,,i,s]=t,a=r*r+o*o+i*i+s*s,l=r*s-o*i,u=Math.sqrt((a+Math.sqrt(Math.max(0,a*a-4*l*l)))/2),c=n/u;return!(c>0)||!Number.isFinite(c)?mt:2**Math.floor(Math.log2(c))}function lR(e,t){return typeof e=="number"?e:{px:(e?.px??sR)/t}}Z();var Xl=new Set,vb=!1;function Tf(e,t,n=2){let r=t&&t.length,o=r?t[0]*n:e.length;Xl.size&&Xl.clear();let i=fR(e,0,o,n,!0),s=[];if(!i||i.next===i.prev)return s;let a=0,l=0,u=0;if(r&&(i=xW(e,t,i,n)),e.length>80*n){a=e[0],l=e[1];let c=a,d=l;for(let f=n;f<o;f+=n){let p=e[f],h=e[f+1];p<a&&(a=p),h<l&&(l=h),p>c&&(c=p),h>d&&(d=h)}u=Math.max(c-a,d-l),u=u!==0?32767/u:0}return Ab(i,s,a,l,u),s}function fR(e,t,n,r,o){let i=null;if(o===CW(e,t,n,r)>0)for(let s=t;s<n;s+=r)i=dR(s/r|0,e[s],e[s+1],i);else for(let s=n-r;s>=t;s-=r)i=dR(s/r|0,e[s],e[s+1],i);return i&&Jl(i,i.next)&&(Zl(i),i=i.next),i}function gi(e,t=e){let n=t===e,r=e,o;do o=!1,r!==r.next&&(Xl.size===0||!Xl.has(r))&&(Jl(r,r.next)||Ye(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),vb=!0,Zl(r),r=r.prev,o=!0):(n||r!==t)&&(r=r.next,o=!n);while(o||r!==t);return t}function Ab(e,t,n,r,o){o&&AW(e,n,r,o);let i=e,s=!1;for(;e.prev!==e.next;){let a=e.prev,l=e.next;if(Ye(a,e,l)<0&&(o?yW(e,n,r,o):mW(e))){t.push(a.i,e.i,l.i),Zl(e),e=l,i=l;continue}if(e=l,e===i){if(vb=!1,e=gi(e),vb){i=e;continue}if(!s){e=gW(e,t),i=e,s=!0;continue}bW(e,t,n,r,o);break}}}function mW(e){let t=e.prev,n=e,r=e.next,o=t.x,i=n.x,s=r.x,a=t.y,l=n.y,u=r.y,c=Math.min(o,i,s),d=Math.min(a,l,u),f=Math.max(o,i,s),p=Math.max(a,l,u),h=r.next;for(;h!==t;){if(h.x>=c&&h.x<=f&&h.y>=d&&h.y<=p&&!(o===h.x&&a===h.y)&&Pf(o,a,i,l,s,u,h.x,h.y)&&Ye(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function yW(e,t,n,r){let o=e.prev,i=e,s=e.next,a=o.x,l=i.x,u=s.x,c=o.y,d=i.y,f=s.y,p=Math.min(a,l,u),h=Math.min(c,d,f),m=Math.max(a,l,u),g=Math.max(c,d,f),b=Eb(p,h,t,n,r),x=Eb(m,g,t,n,r),w=e.prevZ;for(;w&&w.z>=b;){if(w.x>=p&&w.x<=m&&w.y>=h&&w.y<=g&&w!==s&&!(a===w.x&&c===w.y)&&Pf(a,c,l,d,u,f,w.x,w.y)&&Ye(w.prev,w,w.next)>=0)return!1;w=w.prevZ}let y=e.nextZ;for(;y&&y.z<=x;){if(y.x>=p&&y.x<=m&&y.y>=h&&y.y<=g&&y!==s&&!(a===y.x&&c===y.y)&&Pf(a,c,l,d,u,f,y.x,y.y)&&Ye(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function gW(e,t){let n=e,r=!1;do{let o=n.prev,i=n.next.next;mR(o,n,n.next,i,!1)&&Ql(o,i)&&Ql(i,o)&&(t.push(o.i,n.i,i.i),Zl(n),Zl(n.next),n=e=i,r=!0),n=n.next}while(n!==e);return r?gi(n):n}function bW(e,t,n,r,o){let i=e;do{let s=i.next.next;for(;s!==i.prev;){if(i.i!==s.i&&IW(i,s)){let a=yR(i,s);i=gi(i,i.next),a=gi(a,a.next),Ab(i,t,n,r,o),Ab(a,t,n,r,o);return}s=s.next}i=i.next}while(i!==e)}var Rb=!1;function xW(e,t,n,r){let o=[];for(let i=0,s=t.length;i<s;i++){let a=t[i]*r,l=i<s-1?t[i+1]*r:e.length,u=fR(e,a,l,r,!1);u===u.next&&Xl.add(u),o.push(NW(u))}o.sort(wW),TW(e.length/r,t.length),hR(n,n),Rb=!0;for(let i=0;i<o.length;i++)n=PW(o[i],n);return Rb=!1,gi(n)}function wW(e,t){return e.x-t.x||e.y-t.y||(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}function PW(e,t){let n=kW(e,t);if(!n)return t;let r=yR(n,e),o=r.next;return hR(n,o.next),gi(r,r.next),gi(n,n.next)}var pR=16,We=new Float64Array(0),wf=0,Nb=[],Ib=[];function TW(e,t){let n=Math.ceil((e+2*t)/pR)+t+2;We.length<n*4&&(We=new Float64Array(n*4)),wf=0}function hR(e,t){let n=e;do{let r=wf++;Nb[r]=n;let o=n.x,i=n.y,s=n.x,a=n.y,l=0;do{let c=n.next;n.z=r,c.x<o&&(o=c.x),c.x>s&&(s=c.x),c.y<i&&(i=c.y),c.y>a&&(a=c.y),n=c}while(++l<pR&&n!==t);Ib[r]=n;let u=r*4;We[u]=o,We[u+1]=i,We[u+2]=s,We[u+3]=a}while(n!==t)}function SW(e,t){let n=e.z*4;t.x<We[n]&&(We[n]=t.x),t.y<We[n+1]&&(We[n+1]=t.y),t.x>We[n+2]&&(We[n+2]=t.x),t.y>We[n+3]&&(We[n+3]=t.y)}function uR(e){let t=Ib[e];for(;t.prev.next!==t;)t=t.next;return Ib[e]=t,t}function cR(e){let t=Nb[e];for(;t.prev.next!==t;)t=t.next;return Nb[e]=t,t}function kW(e,t){let n=t,r=e.x,o=e.y,i=-1/0,s;if(Jl(e,n))return n;for(let f=0,p=0;f<wf;f++,p+=4){if(o<We[p+1]||o>We[p+3]||We[p]>r||We[p+2]<=i)continue;let h=uR(f);n=cR(f);do{if(n.prev.next===n){if(Jl(e,n.next))return n.next;if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){let m=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(m<=r&&m>i&&(i=m,s=n.x<n.next.x?n:n.next,m===r))return s}}n=n.next}while(n!==h)}if(!s)return null;let a=s.x,l=s.y,u=Math.min(o,l),c=Math.max(o,l),d=1/0;for(let f=0,p=0;f<wf;f++,p+=4){if(We[p+2]<a||We[p]>r||We[p+3]<u||We[p+1]>c)continue;let h=uR(f);n=cR(f);do{if(n.prev.next===n&&r>=n.x&&n.x>=a&&r!==n.x&&Pf(o<l?r:i,o,a,l,o<l?i:r,o,n.x,n.y)){let m=Math.abs(o-n.y)/(r-n.x);(Ql(n,e)||n.y===o&&n.next.y===o&&n.next.x>r)&&(m<d||m===d&&(n.x>s.x||n.x===s.x&&vW(s,n)))&&(s=n,d=m)}n=n.next}while(n!==h)}return s}function vW(e,t){return Ye(e.prev,e,t.prev)<0&&Ye(t.next,e,e.next)<0}var Wt=[],Os=[],yi=new Uint32Array(0),Yl=new Uint32Array(0),ql=new Uint32Array(256);function AW(e,t,n,r){let o=e,i=0;do o.z=Eb(o.x,o.y,t,n,r),Wt[i++]=o,o=o.next;while(o!==e);RW(i);let s=null;for(let a=0;a<i;a++){let l=Wt[a];l.prevZ=s,s&&(s.nextZ=l),s=l}s.nextZ=null,Wt.fill(null,0,i),Os.fill(null,0,i)}function RW(e){if(e<=32){for(let t=1;t<e;t++){let n=Wt[t],r=n.z,o=t-1;for(;o>=0&&Wt[o].z>r;)Wt[o+1]=Wt[o],o--;Wt[o+1]=n}return}yi.length<e&&(yi=new Uint32Array(e),Yl=new Uint32Array(e),Os=new Array(e));for(let t=0;t<e;t++)yi[t]=Wt[t].z;bf(e,Wt,yi,Os,Yl,0),bf(e,Os,Yl,Wt,yi,8),bf(e,Wt,yi,Os,Yl,16),bf(e,Os,Yl,Wt,yi,24)}function bf(e,t,n,r,o,i){ql.fill(0);for(let a=0;a<e;a++)ql[n[a]>>>i&255]++;let s=0;for(let a=0;a<256;a++){let l=ql[a];ql[a]=s,s+=l}for(let a=0;a<e;a++){let l=n[a],u=ql[l>>>i&255]++;r[u]=t[a],o[u]=l}}function Eb(e,t,n,r,o){return e=(e-n)*o|0,t=(t-r)*o|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function NW(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Pf(e,t,n,r,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(r-a)>=(n-s)*(t-a)&&(n-s)*(i-a)>=(o-s)*(r-a)}function IW(e,t){let n=Jl(e,t)&&Ye(e.prev,e,e.next)>0&&Ye(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||Ql(e,t)&&Ql(t,e)&&(Ye(e.prev,e,t.prev)!==0||Ye(e,t.prev,t)!==0))&&!EW(e,t)&&(n||MW(e,t))}function Ye(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Jl(e,t){return e.x===t.x&&e.y===t.y}function mR(e,t,n,r,o=!0){let i=Ye(e,t,n),s=Ye(e,t,r),a=Ye(n,r,e),l=Ye(n,r,t);return(i>0&&s<0||i<0&&s>0)&&(a>0&&l<0||a<0&&l>0)?!0:o?!!(i===0&&xf(e,n,t)||s===0&&xf(e,r,t)||a===0&&xf(n,e,r)||l===0&&xf(n,t,r)):!1}function xf(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function EW(e,t){let n=Math.min(e.x,t.x),r=Math.max(e.x,t.x),o=Math.min(e.y,t.y),i=Math.max(e.y,t.y),s=e;do{let a=s.next;if(s.x>r&&a.x>r||s.x<n&&a.x<n||s.y>i&&a.y>i||s.y<o&&a.y<o){s=a;continue}if(s.i!==e.i&&a.i!==e.i&&s.i!==t.i&&a.i!==t.i&&mR(s,a,e,t))return!0;s=a}while(s!==e);return!1}function Ql(e,t){return Ye(e.prev,e,e.next)<0?Ye(e,t,e.next)>=0&&Ye(e,e.prev,t)>=0:Ye(e,t,e.prev)<0||Ye(e,e.next,t)<0}function MW(e,t){let n=e,r=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do{let s=n.next;n.y>i!=s.y>i&&o<(s.x-n.x)*(i-n.y)/(s.y-n.y)+n.x&&(r=!r),n=s}while(n!==e);return r}function yR(e,t){let n=Mb(e.i,e.x,e.y),r=Mb(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function dR(e,t,n,r){let o=Mb(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function Zl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ),Rb&&SW(e.prev,e.next)}function Mb(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function CW(e,t,n,r){let o=0;for(let i=t,s=n-r;i<n;i+=r)o+=(e[s]-e[i])*(e[i+1]+e[s+1]),s=i;return o}Je();nn();tn();bl();ii();oi();var Cb=new Uint8Array(new Uint16Array([1]).buffer)[0]===1?0:1,OW=2**-19;function Ob(e,t,n){let r=FW(e,t),o=new Uint32Array(r.buffer);for(let i=0;i<t;i++){let s=o[i*2+Cb],a=s*4,l=e[a],u=e[a+1],c=e[a+2],d=e[a+3],f=Math.max(l,c),p=f+Math.abs(f)*OW+1e-300;for(let h=i+1;h<t&&!(r[h]>p);h++){let m=o[h*2+Cb],g=m*4,b=e[g],x=e[g+1],w=e[g+2],y=e[g+3];if(Math.max(u,d)<Math.min(x,y)||Math.max(x,y)<Math.min(u,d))continue;let P=LW(l,u,c,d,b,x,w,y);if(P&&n(s,m,P[0],P[1]))return}}}function FW(e,t){let n=new Float64Array(t),r=new Uint32Array(n.buffer);for(let o=0;o<t;o++)n[o]=Math.min(e[o*4],e[o*4+2]),r[o*2+Cb]=o;return n.sort()}function LW(e,t,n,r,o,i,s,a){let l=n-e,u=r-t,c=s-o,d=a-i,f=l*d-u*c;if(f===0)return null;let p=o-e,h=i-t,m=(p*d-h*c)/f,g=(p*u-h*l)/f,b=1e-9,x=1-1e-9;return m<=b||m>=x||g<=b||g>=x?null:[m,g]}var bi=e=>`${e.x},${e.y}`;function Fb(e,t=!1){return!t&&!BW(e)?null:bR(e,n=>n!==0).contours}var _W=2**20;function gR(e){let t=DW(e),n=Math.floor((_W/t-t)/2);if(!(n>=0))return null;let r=bR(e,o=>(o&1)!==0,n);return r!==null&&r.complete?r.contours:null}function bR(e,t,n=1/0){let r=HW(e),o=WW(r);if(!GW(r,n))return null;UW(r,o),VW(r,o);let i=KW(r,t),{loops:s,complete:a}=$W(i);return{contours:qW(s),complete:a}}function DW(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=0;return n.forEach((i,s)=>{let a=s+1<n.length?n[s+1]:r;for(let l=i;l<a;l++){let u=l+1<a?l+1:i;(t[l*2]!==t[u*2]||t[l*2+1]!==t[u*2+1])&&o++}}),o}function BW(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=new Float64Array(r*4),i=0;n.forEach((a,l)=>{let u=l+1<n.length?n[l+1]:r;for(let c=a;c<u;c++){let d=c+1<u?c+1:a,f=t[c*2],p=t[c*2+1],h=t[d*2],m=t[d*2+1];f===h&&p===m||(o[i*4]=f,o[i*4+1]=p,o[i*4+2]=h,o[i*4+3]=m,i++)}});let s=!1;return Ob(o,i,()=>s=!0),s}function HW(e){let{coords:t,contourStarts:n,anchorA:r,anchorB:o,anchorT:i}=e,s=t.length/2,a=u=>({x:t[u*2],y:t[u*2+1],a:r[u],b:o[u],t:i[u]}),l=[];return n.forEach((u,c)=>{let d=c+1<n.length?n[c+1]:s;for(let f=u;f<d;f++){let p=a(f),h=a(f+1<d?f+1:u);(p.x!==h.x||p.y!==h.y)&&l.push({from:p,to:h,cuts:[]})}}),l}function GW(e,t){let n=new Float64Array(e.length*4);e.forEach(({from:o,to:i},s)=>n.set([o.x,o.y,i.x,i.y],s*4));let r=0;return Ob(n,e.length,(o,i,s,a)=>{if(++r>t)return!0;let l=e[o],u={x:l.from.x+(l.to.x-l.from.x)*s,y:l.from.y+(l.to.y-l.from.y)*s,...zW(l,s)};return l.cuts.push({s,node:u}),e[i].cuts.push({s:a,node:u}),!1}),r<=t}function UW(e,t){let n=e.map((o,i)=>i),r=o=>Math.min(o.from.x,o.to.x);n.sort((o,i)=>r(e[o])-r(e[i]));for(let o=0;o<n.length;o++){let i=e[n[o]],s=Math.max(i.from.x,i.to.x)+t;for(let a=o+1;a<n.length;a++){let l=e[n[a]];if(r(l)>s)break;Math.max(i.from.y,i.to.y)+t<Math.min(l.from.y,l.to.y)||Math.max(l.from.y,l.to.y)+t<Math.min(i.from.y,i.to.y)||(Sf(i,l.from,t),Sf(i,l.to,t),Sf(l,i.from,t),Sf(l,i.to,t))}}}function WW(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let{from:i}of e)t=Math.min(t,i.x),r=Math.max(r,i.x),n=Math.min(n,i.y),o=Math.max(o,i.y);return Math.max(r-t,o-n,Math.abs(t),Math.abs(r),Math.abs(n),Math.abs(o))*1e-9}function VW(e,t){let n=[];for(let r of e){n.push(r.from,r.to);for(let o of r.cuts)n.push(o.node)}n.sort((r,o)=>r.x-o.x);for(let r=0;r<n.length;r++){let o=n[r];for(let i=r+1;i<n.length&&n[i].x-o.x<=t;i++){let s=n[i];s!==o&&Math.abs(s.y-o.y)<=t&&(s.x!==o.x||s.y!==o.y)&&(s.x=o.x,s.y=o.y)}}}function Sf(e,t,n){let r=e.to.x-e.from.x,o=e.to.y-e.from.y,i=r*r+o*o,s=((t.x-e.from.x)*r+(t.y-e.from.y)*o)/i;if(!(s>0&&s<1)||Math.hypot(e.from.x+r*s-t.x,e.from.y+o*s-t.y)>n)return;let a=l=>Math.abs(l.x-t.x)<=n&&Math.abs(l.y-t.y)<=n;a(e.from)||a(e.to)||e.cuts.some(l=>a(l.node))||e.cuts.push({s,node:t})}function zW(e,t){let{from:n,to:r}=e;if(n.a===r.a&&n.b===r.b)return{a:n.a,b:n.b,t:n.t+(r.t-n.t)*t};let o=t<.5?n:r;return{a:o.a,b:o.b,t:o.t}}function KW(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let{from:d}of e)n=Math.min(n,d.x),o=Math.max(o,d.x),r=Math.min(r,d.y),i=Math.max(i,d.y);let s=Math.max(Math.hypot(o-n,i-r)*1e-7,1e-9),a=(d,f)=>t(jW(e,d,f)),l=[],u=new Set,c=(d,f)=>{let p=`${bi(d)}>${bi(f)}`;u.has(p)||(u.add(p),l.push({from:d,to:f}))};for(let d of e){let f=[d.from,...d.cuts.sort((p,h)=>p.s-h.s).map(p=>p.node),d.to];for(let p=0;p+1<f.length;p++){let h=f[p],m=f[p+1],g=m.x-h.x,b=m.y-h.y,x=Math.hypot(g,b);if(x===0)continue;let w=(h.x+m.x)/2,y=(h.y+m.y)/2,P=-b/x*s,S=g/x*s,v=a(w+P,y+S),A=a(w-P,y-S);v&&!A?c(h,m):A&&!v&&c(m,h)}}return l}function jW(e,t,n){let r=0;for(let{from:o,to:i}of e){let s=(i.x-o.x)*(n-o.y)-(t-o.x)*(i.y-o.y);o.y<=n&&i.y>n&&s>0?r++:i.y<=n&&o.y>n&&s<0&&r--}return r}function $W(e){let t=new Map;for(let i of e){let s=bi(i.from),a=t.get(s);a?a.push(i):t.set(s,[i])}let n=new Set,r=[],o=!0;for(let i of e){if(n.has(i))continue;n.add(i);let s=[i.from],a=bi(i.from),l=i;for(;bi(l.to)!==a;){let u=YW(l,(t.get(bi(l.to))??[]).filter(c=>!n.has(c)));if(!u)break;n.add(u),s.push(u.from),l=u}bi(l.to)!==a?o=!1:s.length>=3&&r.push(s)}return{loops:r,complete:o}}function YW(e,t){let n=e.to.x-e.from.x,r=e.to.y-e.from.y,o,i=-1/0;for(let s of t){let a=s.to.x-s.from.x,l=s.to.y-s.from.y,u=Math.atan2(n*l-r*a,n*a+r*l);u>i&&(i=u,o=s)}return o}function qW(e){let t={coords:[],contourStarts:[],anchorA:[],anchorB:[],anchorT:[]};for(let n of e){t.contourStarts.push(t.coords.length/2);for(let r of n)t.coords.push(r.x,r.y),t.anchorA.push(r.a),t.anchorB.push(r.b),t.anchorT.push(r.t)}return t}Nl();ti();function xi(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=n.map((a,l)=>{let u=l+1<n.length?n[l+1]:r;return{start:a,end:u,area:yr(t,a,u),parent:-1,winding:0}}),i=o.map(a=>QW(t,a.start,a.end)),s=o.map((a,l)=>l).filter(a=>o[a].area!==0);s.sort((a,l)=>Math.abs(o[l].area)-Math.abs(o[a].area));for(let a=0;a<s.length;a++){let l=o[s[a]];for(let u=a-1;u>=0;u--){let c=s[u];if(XW(t,o[c],i[c],l)){l.parent=c;break}}l.winding=Math.sign(l.area)+(l.parent>=0?o[l.parent].winding:0)}return o}function XW(e,t,n,r){let o=Math.max(n[2]-n[0],n[3]-n[1])*1e-9;for(let i=r.start;i<r.end;i++){let s=e[i*2],a=e[i*2+1];if(s<n[0]||s>n[2]||a<n[1]||a>n[3])return!1;if(!JW(e,t,s,a,o))return Un(e,s,a,t.start,t.end)}return!1}function JW(e,t,n,r,o){for(let i=t.start;i<t.end;i++){let s=i+1===t.end?t.start:i+1,a=e[i*2],l=e[i*2+1];if(Tn(n,r,a,l,e[s*2],e[s*2+1])<=o)return!0}return!1}function QW(e,t,n){let r=1/0,o=1/0,i=-1/0,s=-1/0;for(let a=t;a<n;a++){let l=e[a*2],u=e[a*2+1];r=Math.min(r,l),i=Math.max(i,l),o=Math.min(o,u),s=Math.max(s,u)}return[r,o,i,s]}ti();function wR(e){if(eV(e))return null;let t=xi(e);if(t.some(n=>n.area===0))return null;for(let n of t){let r=0;for(let o=n.parent;o>=0;o=t[o].parent)r++;n.winding=r%2===0?1:0}return t}function ZW(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=new Float64Array(r*4),i=new Uint32Array(r),s=new Uint32Array(r),a=[],l=0;return n.forEach((u,c)=>{let d=c+1<n.length?n[c+1]:r,f=0;for(let p=u;p<d;p++){let h=p+1<d?p+1:u,m=t[p*2],g=t[p*2+1],b=t[h*2],x=t[h*2+1];m===b&&g===x||(o.set([m,g,b,x],l*4),i[l]=c,s[l]=f++,l++)}a.push(f)}),{ends:o,contour:i,pos:s,count:a,n:l}}function eV(e){let t=ZW(e),{ends:n,n:r}=t,o=1/0,i=1/0,s=-1/0,a=-1/0;for(let d=0;d<r*4;d+=2)o=Math.min(o,n[d]),s=Math.max(s,n[d]),i=Math.min(i,n[d+1]),a=Math.max(a,n[d+1]);let l=Math.max(s-o,a-i,Math.abs(o),Math.abs(s),Math.abs(i),Math.abs(a))*1e-9,u=Array.from({length:r},(d,f)=>f),c=d=>Math.min(n[d*4],n[d*4+2]);u.sort((d,f)=>c(d)-c(f));for(let d=0;d<r;d++){let f=u[d],p=Math.max(n[f*4],n[f*4+2])+l;for(let h=d+1;h<r;h++){let m=u[h];if(c(m)>p)break;if(tV(t,f,m,l))return!0}}return!1}function tV(e,t,n,r){let{ends:o}=e,i=o[t*4],s=o[t*4+1],a=o[t*4+2],l=o[t*4+3],u=o[n*4],c=o[n*4+1],d=o[n*4+2],f=o[n*4+3];if(Math.max(s,l)+r<Math.min(c,f)||Math.max(c,f)+r<Math.min(s,l))return!1;let p=nV(e,t,n);return p==="e-to"?xR(a-i,l-s,d-u,f-c)||Fs(i,s,u,c,d,f,r):p==="f-to"?xR(d-u,f-c,a-i,l-s)||Fs(u,c,i,s,a,l,r):Fs(i,s,u,c,d,f,r)||Fs(a,l,u,c,d,f,r)||Fs(u,c,i,s,a,l,r)||Fs(d,f,i,s,a,l,r)||rV(i,s,a,l,u,c,d,f)}function nV(e,t,n){if(e.contour[t]!==e.contour[n])return null;let r=e.count[e.contour[t]];return r<3?null:(e.pos[t]+1)%r===e.pos[n]?"e-to":(e.pos[n]+1)%r===e.pos[t]?"f-to":null}function xR(e,t,n,r){let o=e*r-t*n;return Math.abs(o)<=1e-9*Math.hypot(e,t)*Math.hypot(n,r)&&e*n+t*r<0}function Fs(e,t,n,r,o,i,s){return Tn(e,t,n,r,o,i)<=s}function rV(e,t,n,r,o,i,s,a){let l=kf(e,t,n,r,o,i),u=kf(e,t,n,r,s,a),c=kf(o,i,s,a,e,t),d=kf(o,i,s,a,n,r);return l*u<=0&&c*d<=0}var kf=(e,t,n,r,o,i)=>Math.sign((n-e)*(i-t)-(r-t)*(o-e));function tu(e,t={}){if(e.kind==="rect")return oV(e);let n=aV(Qe(e),t);return e.origin?{...n,origin:e.origin}:n}function oV(e){let t=gl(e.x,e.y,e.width,e.height),n=Sn(t);return{vertices:At(n,t),indices:new Uint32Array([0,1,2,0,2,3]),anchorA:new Uint32Array([0,1,2,3]),anchorB:new Uint32Array([0,1,2,3]),anchorT:new Float32Array([0,0,0,0]),...n?{origin:n}:{}}}function iV(e,t){let n=new Set,r=sV(e,t,n);if(kn(e))return r;let o={coords:[],contourStarts:[],anchorA:[],anchorB:[],anchorT:[]};return r.contourStarts.forEach((i,s)=>{if(!n.has(s))return;let a=s+1<r.contourStarts.length?r.contourStarts[s+1]:r.coords.length/2;o.contourStarts.push(o.coords.length/2),o.coords.push(...r.coords.slice(i*2,a*2)),o.anchorA.push(...r.anchorA.slice(i,a)),o.anchorB.push(...r.anchorB.slice(i,a)),o.anchorT.push(...r.anchorT.slice(i,a))}),o}function sV(e,t,n){let{commands:r,coords:o}=e,i=[],s=[],a=[],l=[],u=[],c=-1,d=-1,f=0,p=(h,m,g,b)=>{for(let w=0;w<m.length;w++)s.push(d),a.push(b),l.push(g>0?m[w]/g:0);let x=h+m.length-1;s[x]=b,a[x]=b,l[x]=0};return Ge(r,o,(h,m,g,b,x,w)=>{if(w){let y=Math.max(c,0);u.push(i.length/2),i.push(g,b),s.push(y),a.push(y),l.push(0),d=y}switch(h){case le:case ce:{h===le&&(u.push(i.length/2),c=f),i.push(o[m],o[m+1]),s.push(f),a.push(f),l.push(0),d=f,f++;break}case we:{let y=f,P=[],S=s.length,v=Rl(g,b,o[m],o[m+1],o[m+2],o[m+3],t,i,P);p(S,P,v,y),d=y,f++;break}case xe:{let y=f,P=[],S=s.length,v=Al(g,b,o[m],o[m+1],o[m+2],o[m+3],o[m+4],o[m+5],t,i,P);p(S,P,v,y),d=y,f++;break}case fe:n.add(u.length-1),d=c;break;default:throw new Error(`tessellate: unknown command code ${h}`)}}),{coords:i,contourStarts:u,anchorA:s,anchorB:a,anchorT:l}}function aV(e,t){let n=t.flattenTolerance??mt,r=iV(e,n);if(e.fillRule==="evenodd"){let a=wR(r);if(a)return eu(r,a);let l=gR(r);if(l)return eu(l,xi(l));let{coords:u,contourStarts:c,anchorA:d,anchorB:f,anchorT:p}=r;return lV(u,c,d,f,p)}let o=Fb(r);if(o)return eu(o,xi(o));let i=xi(r);if(i.every(a=>Math.abs(a.winding)<=1))return eu(r,i);let s=Fb(r,!0);return eu(s,xi(s))}function eu(e,t){let{coords:n,contourStarts:r,anchorA:o,anchorB:i,anchorT:s}=e,a=[],l=new Map;if(t.forEach((h,m)=>{h.area!==0&&(h.winding!==0?a.push(m):l.has(h.parent)?l.get(h.parent).push(m):l.set(h.parent,[m]))}),a.length<=1&&(a[0]??0)===0){let h=Tf(n,r.length>1?r.slice(1):void 0);return{vertices:new Float32Array(n),indices:new Uint32Array(h),anchorA:new Uint32Array(o),anchorB:new Uint32Array(i),anchorT:new Float32Array(s)}}let u=[],c=[],d=[],f=[],p=[];for(let h of a){let m=l.get(h)??[],g=u.length/2,b=[],x=[0];for(let y=t[h].start;y<t[h].end;y++)b.push(n[y*2],n[y*2+1]),c.push(o[y]),d.push(i[y]),f.push(s[y]);for(let y of m){x.push(b.length/2);for(let P=t[y].start;P<t[y].end;P++)b.push(n[P*2],n[P*2+1]),c.push(o[P]),d.push(i[P]),f.push(s[P])}let w=Tf(b,x.length>1?x.slice(1):void 0);for(let y of b)u.push(y);for(let y of w)p.push(y+g)}return{vertices:new Float32Array(u),indices:new Uint32Array(p),anchorA:new Uint32Array(c),anchorB:new Uint32Array(d),anchorT:new Float32Array(f)}}function lV(e,t,n,r,o){let i=[],s=e.length/2;for(let a=0;a<t.length;a++){let l=t[a],u=a+1<t.length?t[a+1]:s;for(let c=l+1;c<u-1;c++)i.push(l,c,c+1)}return{vertices:new Float32Array(e),indices:new Uint32Array(i),requiresStencil:!0,anchorA:new Uint32Array(n),anchorB:new Uint32Array(r),anchorT:new Float32Array(o)}}vk();function nu(e,t,n,r,o,i,s){return e===r&&t===o?[e,t,n+(i-n)*s]:s<.5?[e,t,n]:[r,o,i]}var TR=1e-9;function PR(e,t,n,r,o,i,s,a,l){let u=t.length,c=1;for(;c<u-1&&(l?t[c]<=a:t[c]<a);)c++;let d=t[c-1],f=t[c]-d,p=f>TR?(a-d)/f:0,h=e.points[(c-1)*2],m=e.points[(c-1)*2+1],g=e.points[c*2],b=e.points[c*2+1],[x,w,y]=nu(n[c-1],r[c-1],o[c-1],n[c],r[c],o[c],p),P=i?i[c-1]+(i[c]-i[c-1])*p:0,S=s?s[c-1]+(s[c]-s[c-1])*p:0;return{x:h+(g-h)*p,y:m+(b-m)*p,a:x,b:w,t:y,w:P,o:S,next:c}}function vf(e,t,n){let r=Math.max(0,t),o=Math.max(0,n);if(r<=0&&o<=0||e.closed)return e;let i=e.points.length/2;if(i<2)return null;let s=e.anchorA??new Uint32Array(i),a=e.anchorB??new Uint32Array(i),l=e.anchorT??new Float32Array(i),u=e.widths,c=e.offsets,d=new Float64Array(i);for(let v=1;v<i;v++){let A=e.points[v*2]-e.points[(v-1)*2],N=e.points[v*2+1]-e.points[(v-1)*2+1];d[v]=d[v-1]+Math.hypot(A,N)}let f=d[i-1],p=r,h=f-o;if(h-p<=TR)return null;let m=PR(e,d,s,a,l,u,c,p,!0),g=PR(e,d,s,a,l,u,c,h,!1),b=[m.x,m.y],x=[m.a],w=[m.b],y=[m.t],P=u?[m.w]:void 0,S=c?[m.o]:void 0;for(let v=m.next;v<g.next;v++)b.push(e.points[v*2],e.points[v*2+1]),x.push(s[v]),w.push(a[v]),y.push(l[v]),P&&P.push(u[v]),S&&S.push(c[v]);return b.push(g.x,g.y),x.push(g.a),w.push(g.b),y.push(g.t),P&&P.push(g.w),S&&S.push(g.o),{points:b,closed:!1,anchorA:new Uint32Array(x),anchorB:new Uint32Array(w),anchorT:new Float32Array(y),...P?{widths:new Float32Array(P)}:{},...S?{offsets:new Float32Array(S)}:{}}}var uV=4,SR=new WeakMap;function kR(e,t=mt){let n=bg(),r=SR.get(e);r===void 0&&SR.set(e,r=new Map);let o=r.get(t);if(o!==void 0&&o.openFill===n)return o.mesh;let i=tu(e,{flattenTolerance:t});return o===void 0&&r.size>=uV&&r.clear(),r.set(t,{mesh:i,openFill:n}),i}var cV={"source-over":{source:"one",destination:"one-minus-source-alpha"},"source-in":{source:"destination-alpha",destination:"zero"},"source-out":{source:"one-minus-destination-alpha",destination:"zero"},"source-atop":{source:"destination-alpha",destination:"one-minus-source-alpha"},"destination-over":{source:"one-minus-destination-alpha",destination:"one"},"destination-in":{source:"zero",destination:"source-alpha"},"destination-out":{source:"zero",destination:"one-minus-source-alpha"},"destination-atop":{source:"one-minus-destination-alpha",destination:"source-alpha"},xor:{source:"one-minus-destination-alpha",destination:"one-minus-source-alpha"},lighter:{source:"one",destination:"one"},copy:{source:"one",destination:"zero"}};function Lb(e){return typeof e=="string"?cV[e]:e}function $n(e){if(e===void 0)return!1;let{source:t,destination:n}=Lb(e);return t!=="one"||n!=="one-minus-source-alpha"}function RR(e){let{destination:t}=Lb(e);return t==="one"||t==="one-minus-source-alpha"}var vR=new WeakMap;function _b(e){let t=vR.get(e);if(t!==void 0)return t;let n=e.some(r=>r.kind==="group"&&($n(r.composite)||_b(r.children)));return vR.set(e,n),n}function AR(e,t){switch(t){case"zero":return e.ZERO;case"one":return e.ONE;case"source-alpha":return e.SRC_ALPHA;case"one-minus-source-alpha":return e.ONE_MINUS_SRC_ALPHA;case"destination-alpha":return e.DST_ALPHA;case"one-minus-destination-alpha":return e.ONE_MINUS_DST_ALPHA}}function Db(e,t){let{source:n,destination:r}=Lb(t);e.blendFunc(AR(e,n),AR(e,r))}Z();function De(e,t,n){e.gl.drawElements(e.gl.TRIANGLES,t,n,0),e.stats&&e.stats.drawCalls++}function wt(e,t=e.clipDepth){let n=e.gl;if(t===0){n.disable(n.STENCIL_TEST);return}let r=wi(t);n.enable(n.STENCIL_TEST),n.stencilFunc(n.EQUAL,r,r),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)}function wi(e){return e===0?0:(1<<e+1)-1&254}function Bb(e,t){let n=e.gl;n.enable(n.STENCIL_TEST),n.colorMask(!1,!1,!1,!1),n.stencilMask(1),n.stencilFunc(n.ALWAYS,0,1),n.stencilOp(n.KEEP,n.KEEP,n.INVERT),De(e,t,e.gl.UNSIGNED_INT);let r=wi(e.clipDepth);n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.EQUAL,r|1,r|1),n.stencilOp(n.KEEP,n.KEEP,n.INVERT)}function Hb(e){let t=e.gl;t.stencilMask(1),t.clear(t.STENCIL_BUFFER_BIT),t.disable(t.STENCIL_TEST)}Z();Pe();var NR=new WeakMap,IR=new WeakMap;function Nf(e,t){let n=NR.get(e);n||(n=new WeakMap,NR.set(e,n));let r=n.get(t);return r||(r={},n.set(t,r)),r}function wr(e,t){if(e===void 0||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Gb(e,t,n,r,o,i){let s=t.uniform("u_color");if(s===void 0)return;let a=Nf(e,t),l=a.color;l!==void 0&&l[0]===n&&l[1]===r&&l[2]===o&&l[3]===i||(e.gl.uniform4f(s,n,r,o,i),a.color=[n,r,o,i])}function If(e,t,n){let r=t.uniform("u_alpha");if(r===void 0)return;let o=Nf(e,t);o.alpha!==n&&(e.gl.uniform1f(r,n),o.alpha=n)}function ru(e){if(e.projection)return e.projection;let t=IR.get(e);return t||(t=q.toUniform(q.screenToClip(e.widthCss,e.heightCss)),IR.set(e,t)),t}var Af=new Float32Array(16);function Rn(e,t,n=e.state.colorMatrix){let r=e.gl,o=Nf(e,t),i=t.uniform("u_colorMatrix");if(i!==void 0){for(let a=0;a<4;a++)for(let l=0;l<4;l++)Af[l*4+a]=n[a*5+l];wr(o.colorMatrix,Af)||(r.uniformMatrix4fv(i,!1,Af),o.colorMatrix=Float32Array.from(Af))}let s=t.uniform("u_colorBias");if(s!==void 0){let a=[n[4],n[9],n[14],n[19]];wr(o.colorBias,a)||(r.uniform4f(s,a[0],a[1],a[2],a[3]),o.colorBias=Float32Array.from(a))}}var ER=65536;function Ef(e){let t=e.meshOrigin;return t?q.translated(e.state.transform,t.x,t.y):e.state.transform}function Mf(e,t,n){let r=e.meshOrigin;if(t===r)return n();e.meshOrigin=t;try{return n()}finally{e.meshOrigin=r}}var Ls=new Float32Array(9),Rf=new Float32Array(9);function nt(e,t,n=Ef(e),r=ru(e)){let o=e.gl,i=Nf(e,t);Rf.set(r),wr(i.proj,Rf)||(o.uniformMatrix3fv(t.uniform("u_proj"),!1,Rf),i.proj=Float32Array.from(Rf)),Ls.set(n);let s=t.uniform("u_origin");if(s!==void 0){let a=0,l=0,u=n[6],c=n[7];if(Math.abs(u)>=ER||Math.abs(c)>=ER){let d=n[0],f=n[1],p=n[3],h=n[4],m=d*h-f*p,g=Math.fround((p*c-h*u)/m),b=Math.fround((f*u-d*c)/m);Number.isFinite(g)&&Number.isFinite(b)&&(a=g,l=b,Ls[6]=d*a+p*l+u,Ls[7]=f*a+h*l+c)}(i.originX!==a||i.originY!==l)&&(o.uniform2f(s,a,l),i.originX=a,i.originY=l)}wr(i.model,Ls)||(o.uniformMatrix3fv(t.uniform("u_model"),!1,Ls),i.model=Float32Array.from(Ls))}function _s(e,t,n,r){let[o,i,s,a]=jn(n);Gb(e,t,o,i,s,a*(r??1)),If(e,t,e.state.alpha)}var MR=new Set;function OR(e,t){MR.has(e)||(MR.add(e),Qt()&&console.warn(t))}function Ub(e,t){OR(`${e}:${t}`,`weasel drawShader: uniform "${t}" not found in program "${e}". Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`)}function dV(e,t,n,r,o){if(n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Float32Array)&&"id"in n&&typeof n.id=="string"){let i=n,s=Es(i.id);if(!s){Qt()&&console.warn(`weasel setUniform: TextureHandle "${i.id}" not registered`);return}let a=o.value++;e.activeTexture(e.TEXTURE0+a),r.uploadRegistered(i.id,s.source),r.bind(i.id,a),e.uniform1i(t,a);return}if(n instanceof Float64Array&&(n=Float32Array.from(n)),n instanceof Float32Array){if(n.length===9)e.uniformMatrix3fv(t,!1,n);else if(n.length===16)e.uniformMatrix4fv(t,!1,n);else if(Qt())throw new TypeError(`weasel setUniform: Float32Array must be length 9 (mat3) or 16 (mat4), got ${n.length}`);return}if(Array.isArray(n)){let i=n;switch(i.length){case 2:e.uniform2fv(t,i);break;case 3:e.uniform3fv(t,i);break;case 4:e.uniform4fv(t,i);break;default:if(Qt())throw new TypeError(`weasel setUniform: array length ${i.length} not supported`)}return}if(typeof n=="number"){e.uniform1f(t,n);return}}var fV={float:{fn:"uniform1fv",n:1},vec2:{fn:"uniform2fv",n:2},vec3:{fn:"uniform3fv",n:3},vec4:{fn:"uniform4fv",n:4},int:{fn:"uniform1iv",n:1},ivec2:{fn:"uniform2iv",n:2},ivec3:{fn:"uniform3iv",n:3},ivec4:{fn:"uniform4iv",n:4},bool:{fn:"uniform1iv",n:1},bvec2:{fn:"uniform2iv",n:2},bvec3:{fn:"uniform3iv",n:3},bvec4:{fn:"uniform4iv",n:4},uint:{fn:"uniform1uiv",n:1},uvec2:{fn:"uniform2uiv",n:2},uvec3:{fn:"uniform3uiv",n:3},uvec4:{fn:"uniform4uiv",n:4},mat2:{fn:"uniformMatrix2fv",n:4,matrix:!0},mat3:{fn:"uniformMatrix3fv",n:9,matrix:!0},mat4:{fn:"uniformMatrix4fv",n:16,matrix:!0},mat2x2:{fn:"uniformMatrix2fv",n:4,matrix:!0},mat3x3:{fn:"uniformMatrix3fv",n:9,matrix:!0},mat4x4:{fn:"uniformMatrix4fv",n:16,matrix:!0},mat2x3:{fn:"uniformMatrix2x3fv",n:6,matrix:!0},mat2x4:{fn:"uniformMatrix2x4fv",n:8,matrix:!0},mat3x2:{fn:"uniformMatrix3x2fv",n:6,matrix:!0},mat3x4:{fn:"uniformMatrix3x4fv",n:12,matrix:!0},mat4x2:{fn:"uniformMatrix4x2fv",n:8,matrix:!0},mat4x3:{fn:"uniformMatrix4x3fv",n:12,matrix:!0}};function pV(e){return Array.isArray(e)||e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint32Array}function hV(e,t,n,r){let o=fV[n.type];if(!o){Qt()&&console.warn(`weasel setUniform: array uniform "${t}" has type ${n.type}, which cannot be written as a whole`);return}if(r.length%o.n!==0||r.length>o.n*n.size){if(Qt())throw new TypeError(`weasel setUniform: "${t}" is ${n.type}[${n.size}], so its value must hold a multiple of ${o.n} numbers, at most ${o.n*n.size}; got ${r.length}`);return}if(r.length===0)return;let i=e[o.fn];o.matrix?i.call(e,n.location,!1,r):i.call(e,n.location,r)}function Wb(e,t,n,r,o,i){for(let[s,a]of Object.entries(r)){let l=t.uniformArray(s);if(l&&pV(a)){hV(e,s,l,a);continue}let u=t.uniform(s);if(u===void 0){Ub(n,s);continue}dV(e,u,a,o,i)}}function FR(e,t){let{gl:n,programRegistry:r,quadVbo:o,quadIbo:i,textureCache:s}=e,a=e.ensureProgram?.(t.program.id)??r.get(t.program.id);if(!a){OR(`${t.program.id}:(program)`,`weasel drawShader: program "${t.program.id}" has no compiled program on this renderer. Register its source with the module-level registerProgram() first; a source that failed to compile is reported above.`);return}if(!o||!i){console.warn("weasel drawShader: quad geometry not initialized");return}n.useProgram(a.handle);let l=a.attribute("a_position"),u=a.attribute("a_uv");n.bindBuffer(n.ARRAY_BUFFER,o),l!==void 0&&(n.enableVertexAttribArray(l),n.vertexAttribPointer(l,2,n.FLOAT,!1,16,0)),u!==void 0&&(n.enableVertexAttribArray(u),n.vertexAttribPointer(u,2,n.FLOAT,!1,16,8)),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i);let c=a.uniform("u_proj");c!==void 0&&n.uniformMatrix3fv(c,!1,q.toUniform(ru(e)));let d=a.uniform("u_bounds");d!==void 0&&n.uniform4f(d,t.bounds.x,t.bounds.y,t.bounds.w,t.bounds.h);let f=a.uniform("u_fragOrigin");if(f!==void 0){let[h,m]=(e.renderTarget?e.renderTarget.fragOrigin:e.fragOrigin)??[0,0];n.uniform2f(f,h,m)}let p=a.uniform("u_view");p!==void 0&&n.uniformMatrix3fv(p,!1,q.toUniform(e.state.transform)),mV(n,a,e.state.transform,t.bounds),Wb(n,a,t.program.id,t.uniforms,s,{value:1}),wt(e),De(e,6,e.gl.UNSIGNED_SHORT),l!==void 0&&n.disableVertexAttribArray(l),u!==void 0&&n.disableVertexAttribArray(u),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}function mV(e,t,n,r){let o=t.uniform("u_screenToLocal"),i=t.uniform("u_worldOrigin");if(o===void 0&&i===void 0)return;let s=q.invert(n),a=0,l=0,u=q.scaled(q.identity(),0,0);if(s){let c=s[0]*r.x+s[3]*r.y+s[6],d=s[1]*r.x+s[4]*r.y+s[7];(Math.abs(c)>=CR||Math.abs(d)>=CR)&&(a=Math.fround(c),l=Math.fround(d)),u=q.multiply(q.translated(q.identity(),-a,-l),s)}o!==void 0&&e.uniformMatrix3fv(o,!1,q.toUniform(u)),i!==void 0&&e.uniform2f(i,a,l)}var CR=8192;Z();Z();function _R(e,t){if(e.kind!=="rect"||!(t[1]===0&&t[3]===0||t[0]===0&&t[4]===0))return null;let r=t[0]*e.x+t[3]*e.y+t[6],o=t[1]*e.x+t[4]*e.y+t[7],i=e.x+e.width,s=e.y+e.height,a=t[0]*i+t[3]*s+t[6],l=t[1]*i+t[4]*s+t[7];return{x0:Math.min(r,a),y0:Math.min(o,l),x1:Math.max(r,a),y1:Math.max(o,l)}}function DR(e,t){return{x0:Math.max(e.x0,t.x0),y0:Math.max(e.y0,t.y0),x1:Math.min(e.x1,t.x1),y1:Math.min(e.y1,t.y1)}}var BR=16,yV=8,gV=new Float64Array(0);function HR(e,t,n){if(e===null&&t.length===0)return null;let r=gV;if(t.length===1)r=t[0];else if(t.length>1){r=new Float64Array(t.reduce((i,s)=>i+s.length,0));let o=0;for(let i of t)r.set(i,o),o+=i.length}return{rect:e,planes:r,slanted:n}}var LR=new WeakMap;function GR(e,t){let n=LR.get(e);if(n!==void 0&&n.m[0]===t[0]&&n.m[1]===t[1]&&n.m[2]===t[3]&&n.m[3]===t[4]&&n.m[4]===t[6]&&n.m[5]===t[7])return n.planes;let r=bV(e,t);return LR.set(e,{m:Float64Array.of(t[0],t[1],t[3],t[4],t[6],t[7]),planes:r}),r}function bV(e,t){let n=qg(e);if(n===null)return null;let r=[];for(let o=0;o<n.length;o+=2)r.push(t[0]*n[o]+t[3]*n[o+1]+t[6],t[1]*n[o]+t[4]*n[o+1]+t[7]);return zb(r,yV)}function zb(e,t){let n=[];for(let s=0;s<e.length;s+=2){let a=n.length;a>=2&&n[a-2]===e[s]&&n[a-1]===e[s+1]||n.push(e[s],e[s+1])}for(;n.length>=4&&n[0]===n[n.length-2]&&n[1]===n[n.length-1];)n.length-=2;if(n.length<6)return null;yr(n)<0&&Xg(n);let r=Jg(n);if(r.length<6||r.length/2>t||!Qg(r))return null;let o=r.length/2,i=new Float64Array(o*3);for(let s=0;s<o;s++){let a=r[s*2],l=r[s*2+1],u=r[(s+1)%o*2],c=r[(s+1)%o*2+1],d=Math.hypot(u-a,c-l),f=-(c-l)/d,p=(u-a)/d;i[s*3]=f,i[s*3+1]=p,i[s*3+2]=-(f*a+p*l)}return i}function Pr(e,t,n){let r=e.rect;if(r!==null&&(t<r.x0||t>r.x1||n<r.y0||n>r.y1))return!1;let o=e.planes;for(let i=0;i<o.length;i+=3)if(o[i]*t+o[i+1]*n+o[i+2]<0)return!1;return!0}function Cf(e,t,n,r,o){let i=e.rect;if(i!==null){let a=!0,l=!0,u=!0,c=!0;for(let d=0,f=n;d<r;d++,f+=o){let p=t[f],h=t[f+1];a&&=p<=i.x0,l&&=p>=i.x1,u&&=h<=i.y0,c&&=h>=i.y1}if(a||l||u||c)return!0}let s=e.planes;for(let a=0;a<s.length;a+=3){let l=!0;for(let u=0,c=n;u<r&&l;u++,c+=o)l=s[a]*t[c]+s[a+1]*t[c+1]+s[a+2]<=0;if(l)return!0}return!1}function Kb(e,t,n,r,o,i){let s=r.rect,a=r.planes,l=s===null?0:4,u=l+a.length/3;if(u===0)return o.set(e.subarray(0,t*n)),t;let c=e,d=u%2===0?i:o,f=t;for(let p=0;p<u;p++){if(p<l){let h=p<2?0:1,m=p===0?s.x0:p===1?s.x1:p===2?s.y0:s.y1;f=xV(c,f,n,h,m,p%2===0?1:-1,d)}else{let h=(p-l)*3;f=ou(c,f,n,a[h],a[h+1],a[h+2],d)}c=d,d=d===o?i:o}return f}function xV(e,t,n,r,o,i,s){if(t===0)return 0;let a=0,l=t-1,u=i*(e[l*n+r]-o)>=0;for(let c=0;c<t;c++){let d=i*(e[c*n+r]-o)>=0;if(d!==u){let[f,p]=UR(e,l*n,c*n),h=(o-e[f+r])/(e[p+r]-e[f+r]);WR(e,f,p,h,n,s,a*n),s[a*n+r]=o,a++}d&&(s.set(e.subarray(c*n,c*n+n),a*n),a++),l=c,u=d}return a}function ou(e,t,n,r,o,i,s){if(t===0)return 0;let a=0,l=t-1,u=r*e[l*n]+o*e[l*n+1]+i>=0;for(let c=0;c<t;c++){let d=c*n,f=r*e[d]+o*e[d+1]+i>=0;if(f!==u){let[p,h]=UR(e,l*n,d),m=r*e[p]+o*e[p+1]+i,g=r*e[h]+o*e[h+1]+i;WR(e,p,h,m/(m-g),n,s,a*n),a++}f&&(s.set(e.subarray(c*n,c*n+n),a*n),a++),l=c,u=f}return a}var Vb=[0,0];function UR(e,t,n){let r=e[n]<e[t]||e[n]===e[t]&&e[n+1]<e[t+1];return Vb[0]=r?n:t,Vb[1]=r?t:n,Vb}function WR(e,t,n,r,o,i,s){for(let a=0;a<o;a++)i[s+a]=e[t+a]+r*(e[n+a]-e[t+a])}function Ds(e){return aR(e.flattenTolerance,e.state.transform)}function Of(e,t){return kR(t,Ds(e))}function jb(e,t){return e.meshCache.handleFor(t)}function iu(e,t){return jb(e,Of(e,t))}Z();function Ff(e){return e===Ut||wr(Ut,e)}var su={enabled:!0};function au(e){return su.enabled||Ff(e.state.colorMatrix)}function $b(e,t,n,r,o){let i=e.state.colorMatrix,s=e.state.alpha;if(Ff(i))return[t,n,r,o*s];if(!su.enabled)return[t,n,r,o];let a=iR(i,t,n,r,o);return a[3]*=s,a}function Lf(e,t,n,r,o,i){return Ff(e.state.colorMatrix)?(i[0]=t,i[1]=n,i[2]=r,i[3]=o*e.state.alpha,i):$b(e,t,n,r,o)}var VR=[1,1,1,1],wV=[0,6,12,18];function PV(e){let t=e.state.colorMatrix,n=e.state.alpha;if(Ff(t))return n===1?VR:[1,1,1,n];if(!su.enabled)return null;for(let r=0;r<20;r++){let o=t[r];if(wV.includes(r)?o<0||o>1:o!==0)return null}return[t[0],t[6],t[12],t[18]*n]}function Bs(e,t){let n=PV(e);if(n!==null)return{colorMatrix:Ut,alpha:1,tint:n,slot:0};let r=e.state.colorMatrix,o=e.state.alpha;return t?{colorMatrix:r,alpha:o,tint:VR,slot:0}:{colorMatrix:r,alpha:1,tint:[1,1,1,o],slot:0}}function Yb(e,t,n){for(let r=0;r<e.length;r++){let o=e[r];if(o.alpha===n&&(o.colorMatrix===t||wr(o.colorMatrix,t)))return r}return e.length<(su.enabled?zn:1)?e.length:-1}var zR=new Float32Array(16*zn),KR=new Float32Array(4*zn),jR=new Float32Array(zn),$R=new WeakMap;function TV(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;n++){let r=e[n],o=t[n];if(r.alpha!==o.alpha||r.colorMatrix!==o.colorMatrix&&!wr(r.colorMatrix,o.colorMatrix))return!1}return!0}function YR(e,t,n){let r=$R.get(e);r||(r=new WeakMap,$R.set(e,r));let o=r.get(t);if(o!==void 0&&TV(o,n))return;let i=n.length;for(let a=0;a<i;a++){let l=n[a].colorMatrix;for(let u=0;u<4;u++){for(let c=0;c<4;c++)zR[16*a+c*4+u]=l[u*5+c];KR[4*a+u]=l[u*5+4]}jR[a]=n[a].alpha}let s=e.gl;s.uniformMatrix4fv(t.uniform("u_colorMatrix"),!1,zR.subarray(0,16*i)),s.uniform4fv(t.uniform("u_colorBias"),KR.subarray(0,4*i)),s.uniform1fv(t.uniform("u_alpha"),jR.subarray(0,i)),r.set(t,n.slice())}var Hs=q.identity(),SV=new Int32Array(Array.from({length:yt},(e,t)=>t)),qb=new Float32Array(2*yt),qR=new Int32Array(4*vs);function ye(e){let t=e.drawBatch,n=e.batchState;if(t.length===0||n===void 0){e.batchState=void 0;return}let r=e.gl,o=n.matrices.length>1,i=n.hulls!==void 0,s=n.areaGlyphs,a=(o||i||s)&&e.batchVariants?e.batchVariants.get(o,i,s):e.batchFill;r.useProgram(a.handle);let l=t.uploadAndBind();nt(e,a,Hs),Gb(e,a,1,1,1,1),YR(e,a,n.matrices),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,e.whiteTexture);for(let u=0;u<n.textures.length;u++){let c=n.textures[u];if(c.kind==="atlas"){e.textureCache.bind(c.id,u+1),qb[2*(u+1)]=c.fieldScale[0],qb[2*(u+1)+1]=c.fieldScale[1];continue}e.imageCache.bind(c.image,u+1),e.imageCache.setMagFilter(c.image,c.sampling==="nearest"?r.NEAREST:r.LINEAR),e.imageCache.setMinFilter(c.image,c.mips)}n.ramps&&e.gradRamps.bind(As),r.uniform1iv(a.uniform("u_samplers"),SV),r.uniform2fv(a.uniform("u_fieldScale"),qb),i&&kV(r,a,n),wt(e,n.clipDepth),De(e,l,e.gl.UNSIGNED_INT),r.activeTexture(r.TEXTURE0),r.bindVertexArray(null),t.reset(),e.batchState=void 0}function kV(e,t,n){for(let{set:r,start:o}of n.hulls)qR.set(r.planes,4*o);e.uniform4iv(t.uniform("u_hullPlanes"),qR,0,4*n.hullPlanes)}function uu(e,t,n=e.state.transform){let r=e.clipStack.reduce((o,i)=>o+(i.depth===0?1:0),0);if(e.clipDepth+r+1>7)throw new Error("weasel: clip nesting depth exceeded (max 7). You can't nest more than 7 levels of clipped containers in a single draw tree. Flatten the hierarchy or compose poses outside the scene graph.");AV(e,t,n)}var vV=q.identity();function AV(e,t,n){let r=_R(t,n),o=r===null?null:Xb(e),i=o===null?null:Yv(t,n,o),s=i?i.rect:r,a=_f(e),l=e.clipStack[e.clipStack.length-1],u=l===void 0?null:l.uncutHulls,c=s===null?NV(e,t,n):null,d=c&&(a?Yg(a,c.set):c.set),f=s===null&&c===null?RV(e,t,n):null;if(s!==null){let p=i?i.hull:null,h=p?XR(u,p.set):!1;e.clipStack.push({path:t,transform:n,rect:s,hull:p,planes:null,hulls:a,uncutHulls:h,depth:0})}else if(c&&d){let p=XR(u,c.set);e.clipStack.push({path:t,transform:n,rect:null,hull:c,planes:null,hulls:d,uncutHulls:p,depth:0})}else if(f!==null)e.clipStack.push({path:t,transform:n,rect:null,hull:null,planes:f,hulls:a,uncutHulls:u,depth:0});else{Qb(e);let p=e.clipDepth+1;tN(e,t,p,n),e.clipDepth=p,e.clipStack.push({path:t,transform:n,rect:null,hull:null,planes:null,hulls:a,uncutHulls:u,depth:p})}eN(e)}function RV(e,t,n){if(!JR(e))return null;let r=GR(t,n);if(r===null)return null;let o=r.length/3;for(let i of e.clipStack)i.planes&&(o+=i.planes.length/3);return o<=BR?r:null}function XR(e,t){return e===!1?!1:(e?Yg(e,t):t)??!1}function Xb(e){return!e.batchVariants?.hulls||e.renderTarget||e.projection||e.deviceWidth===void 0||e.deviceHeight===void 0?null:$v(ru(e),e.fragOrigin??[0,0],e.deviceWidth,e.deviceHeight)}function JR(e){return e.batchVariants?.cuts!==!1&&Xb(e)===null}function NV(e,t,n){let r=Xb(e);return r===null?null:$g(t,n,r)}function _f(e){if(e.uncutHulls!==void 0)return e.uncutHulls;let t=e.clipStack;return t.length===0?null:t[t.length-1].hulls}function Jb(e){let t=e.clipStack.pop();t.depth>0&&(IV(e,QR(t),t.depth-1,ZR(t)),e.clipDepth=t.depth-1),eN(e)}function QR(e){return e.hull?e.hull.path:e.path}function ZR(e){return e.hull?vV:e.transform}function Qb(e){for(let t of e.clipStack){if(t.depth!==0)continue;let n=e.clipDepth+1;tN(e,QR(t),n,ZR(t)),t.depth=n,e.clipDepth=n}}function eN(e){let t=null,n=[];for(let r of e.clipStack)r.rect&&(t=t?DR(t,r.rect):r.rect),r.planes&&n.push(r.planes);e.drawBatch.clip=HR(t,n,JR(e))}function Zb(e){let t=e.clipStack;if(t.length===0||e.uncut)return e.clipDepth;for(let n=t.length-1;n>=0;n--)if(t[n].rect===null&&t[n].hull===null&&t[n].planes===null)return t[n].depth;for(let n of t)if(n.depth>0)return n.depth-1;return e.clipDepth}function po(e){let t=e.drawBatch.clip;e.drawBatch.clip=null;let n=e.clipStack[e.clipStack.length-1];return n!==void 0&&n.uncutHulls?(e.uncutHulls=n.uncutHulls,t):(Qb(e),e.uncut=!0,t)}function ho(e,t){e.drawBatch.clip=t,e.uncut=!1,e.uncutHulls=void 0}function sn(e,t,n,r){let o=po(e);r(e,t,n),ho(e,o)}function an(e){ye(e),e.clipStack.length>0&&Qb(e)}function lu(e,t,n){let r=e.gl,o=iu(e,t);r.useProgram(e.pathFill.handle),r.bindVertexArray(o.vao);let i=t.kind==="polygon"?t.origin:void 0;nt(e,e.pathFill,i?q.translated(n,i.x,i.y):n),De(e,o.indexCount,e.gl.UNSIGNED_INT),r.bindVertexArray(null)}function tN(e,t,n,r=e.state.transform){ye(e);let o=e.gl,i=wi(n-1),s=1<<n,a=i|s;o.enable(o.STENCIL_TEST),o.colorMask(!1,!1,!1,!1),iu(e,t).requiresStencil?(o.stencilMask(1),o.stencilFunc(o.ALWAYS,0,1),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),lu(e,t,r),o.stencilMask(s),o.stencilFunc(o.EQUAL,a|1,i|1),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),lu(e,t,r),o.stencilMask(1),o.stencilFunc(o.ALWAYS,0,1),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),lu(e,t,r)):(o.stencilMask(s),o.stencilFunc(o.EQUAL,a,i),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),lu(e,t,r)),o.colorMask(!0,!0,!0,!0),o.stencilMask(255)}function IV(e,t,n,r=e.state.transform){e.batchState!==void 0&&e.batchState.clipDepth>n&&ye(e);let o=e.gl;o.enable(o.STENCIL_TEST);let i=1<<n+1,s=wi(n)|i;o.colorMask(!1,!1,!1,!1),o.stencilMask(i),o.stencilFunc(o.EQUAL,s,s),o.stencilOp(o.KEEP,o.KEEP,o.ZERO),lu(e,t,r),o.colorMask(!0,!0,!0,!0),o.stencilMask(255)}var Df=xt(),fie=Df.reflection;function Nn(e){return Df.get(e)??null}function Bf(e,t,n){if(Df.has(e)&&!Qt())throw new Error(`weasel registerProgram: duplicate program id "${e}". In production, re-registration is not allowed. Pass a unique id or call in dev mode.`);return Df.set(e,{vert:t,frag:n}),{id:e}}var nN=`#version 300 es
370
370
  in vec2 a_position;
371
371
  in vec2 a_uv;
372
372
  out vec2 v_uv;
@@ -375,7 +375,7 @@ void main() {
375
375
  v_uv = a_uv;
376
376
  gl_Position = vec4(a_position, 0.0, 1.0);
377
377
  }
378
- `;var KR=`#version 300 es
378
+ `;var rN=`#version 300 es
379
379
  precision highp float;
380
380
  in vec2 v_uv;
381
381
  uniform sampler2D u_source;
@@ -394,7 +394,7 @@ void main() {
394
394
  c.a *= u_alpha;
395
395
  outColor = vec4(clamp(c.rgb, 0.0, 1.0) * c.a, c.a);
396
396
  }
397
- `;var zb="weasel:effect-composite";function Ef(){return An(zb)||If(zb,zR,KR),zb}function Os(e){let t=0;for(let n of e){if(n.reach===void 0||!(n.reach>=0))return 1/0;t+=n.reach}return t}ee();ee();Pe();ee();Pe();Pe();function jR(e,t,n){return{pts:[e.x,e.y],a:[e.a],b:[e.b],t:[e.t],w:t?[e.w]:null,o:n?[e.o]:null}}function Kb(e,t){e.pts.push(t.x,t.y),e.a.push(t.a),e.b.push(t.b),e.t.push(t.t),e.w?.push(t.w),e.o?.push(t.o)}function Mf(e,t=!1){let n={points:e.pts,closed:t,anchorA:new Uint32Array(e.a),anchorB:new Uint32Array(e.b),anchorT:new Float32Array(e.t)};return e.w&&(n.widths=new Float32Array(e.w)),e.o&&(n.offsets=new Float32Array(e.o)),n}function $R(e,t){let n=Zd(t,xW(e));return n==="solid"?[...e]:n==="non-finite"?[]:e.flatMap(r=>wW(r,n))}function xW(e){return e.reduce((t,n)=>t+YR(n),0)}function YR(e){let t=e.points,n=t.length/2,r=0;for(let o=1;o<n;o++)r+=Math.hypot(t[o*2]-t[o*2-2],t[o*2+1]-t[o*2-1]);return e.closed&&n>1&&(r+=Math.hypot(t[0]-t[n*2-2],t[1]-t[n*2-1])),r}function wW(e,t){let n=Zd(t,YR(e));if(n==="solid")return[e];if(n==="non-finite")return[];let r=[],o=e.points.length/2,i=e.anchorA??new Uint32Array(o),s=e.anchorB??new Uint32Array(o),a=e.anchorT??new Float32Array(o),l=e.widths,u=e.offsets,c=y=>({x:e.points[y*2],y:e.points[y*2+1],a:i[y],b:s[y],t:a[y],w:l?l[y]:0,o:u?u[y]:0}),d=0,f=n[0],p=!0,h=jR(c(0),!!l,!!u),m=y=>{h&&h.pts.length>=4&&r.push(Mf(h)),d=(d+1)%n.length,f=n[d],p=!p,h=p?jR(y,!!l,!!u):null},g=e.points[0],b=e.points[1],x=e.closed?o:o-1;for(let y=0;y<x;y++){let P=c(y),S=c((y+1)%o),v=Math.hypot(S.x-g,S.y-b);if(v<=1e-9){p&&h&&Kb(h,S);continue}let A=v,N=0;for(;A>1e-9;)if(A<=f)p&&h&&Kb(h,S),f-=A,g=S.x,b=S.y,A=0,f<=1e-9&&m(S);else{N+=f;let M=N/v,[C,F,B]=Kl(P.a,P.b,P.t,S.a,S.b,S.t,M),D={x:P.x+(S.x-P.x)*M,y:P.y+(S.y-P.y)*M,a:C,b:F,t:B,w:P.w+(S.w-P.w)*M,o:P.o+(S.o-P.o)*M};p&&h&&Kb(h,D),g=D.x,b=D.y,A=Math.hypot(S.x-g,S.y-b),m(D)}}let w=h;return w&&w.pts.length>=4&&PW(e,w,r),r}function PW(e,t,n){let r=t.pts[t.pts.length-2],o=t.pts[t.pts.length-1],i=(s,a)=>Math.hypot(r-s,o-a)<=1e-9;e.closed&&n.length>0&&i(n[0].points[0],n[0].points[1])?n[0]=TW(Mf(t),n[0]):e.closed&&n.length===0&&i(t.pts[0],t.pts[1])?n.push(Mf({pts:t.pts.slice(0,-2),a:t.a.slice(0,-1),b:t.b.slice(0,-1),t:t.t.slice(0,-1),w:t.w?t.w.slice(0,-1):null,o:t.o?t.o.slice(0,-1):null},!0)):n.push(Mf(t))}function TW(e,t){let n={points:[...e.points,...t.points.slice(2)],closed:!1,anchorA:Uint32Array.from([...e.anchorA,...t.anchorA.subarray(1)]),anchorB:Uint32Array.from([...e.anchorB,...t.anchorB.subarray(1)]),anchorT:Float32Array.from([...e.anchorT,...t.anchorT.subarray(1)])};return e.widths&&t.widths&&(n.widths=Float32Array.from([...e.widths,...t.widths.subarray(1)])),e.offsets&&t.offsets&&(n.offsets=Float32Array.from([...e.offsets,...t.offsets.subarray(1)])),n}Pe();function SW(e){let t=Math.cos(e.angle),n=-Math.sin(e.angle),r=Math.min(1,Math.max(0,e.ratio));return(o,i)=>{let s=t*i-n*o,a=t*o+n*i;return Math.sqrt(s*s+r*r*a*a)}}function qR(e,t,n){let r=e.points.length/2;if(r<2)return;let o=e.points,i=SW(t),s=e.closed?r:r-1,a=[];for(let y=0;y<s;y++){let P=(y+1)%r,S=o[P*2]-o[y*2],v=o[P*2+1]-o[y*2+1],A=Math.hypot(S,v);a.push(A>0?i(S/A,v/A):NaN)}for(let y=0;y<s;y++)Number.isNaN(a[y])&&(a[y]=y>0?a[y-1]:a.find(P=>!Number.isNaN(P))??1);let l=e.anchorA,u=e.anchorB,c=e.anchorT,d=e.widths,f=e.offsets,p=[],h=[],m=[],g=[],b=[],x=[],w=(y,P)=>{p.push(o[y*2],o[y*2+1]),h.push(l?l[y]:0),m.push(u?u[y]:0),g.push(c?c[y]:0),b.push((d?d[y]:n)*P),f&&x.push(f[y]*P)};w(0,a[0]);for(let y=1;y<r;y++)w(y,a[y-1]),y<s&&w(y,a[y]);e.closed&&w(0,a[s-1]),e.points=p,e.anchorA=Uint32Array.from(h),e.anchorB=Uint32Array.from(m),e.anchorT=Float32Array.from(g),e.widths=Float32Array.from(b),f&&(e.offsets=Float32Array.from(x))}function XR(e,t,n,r){let o=e.points.length/2;if(o===0)return;let i=e.anchorA??new Uint32Array(o),s=e.anchorB??new Uint32Array(o),a=e.anchorT??new Float32Array(o),l=new Float32Array(o),u=new Float32Array(o),c=!1,d=n/2,f=1,p=h=>{let m=Qd(t[h],NaN);return[Number.isNaN(m.left)?d:m.left*f,Number.isNaN(m.right)?d:m.right*f]};for(let h=0;h<o;h++){r&&(f=kW(e,h,r));let m=i[h],g=s[h],b=a[h],[x,w]=p(m);if(m!==g){let[y,P]=p(g);x+=(y-x)*b,w+=(P-w)*b}l[h]=x+w,u[h]=(w-x)/2,u[h]!==0&&(c=!0)}e.widths=l,c&&(e.offsets=u)}function hi(e,t){return 2*rb(e,t)}function JR(e,t,n,r,o){t&&XR(e,t,r,o),n&&qR(e,n,r)}function kW(e,t,n){let r=e.points,o=r.length/2,i=0,s=0,a=(u,c)=>{let d=r[c*2]-r[u*2],f=r[c*2+1]-r[u*2+1],p=Math.hypot(d,f);p>0&&(i+=d/p,s+=f/p)};t>0?a(t-1,t):e.closed&&o>1&&a(o-1,0),t<o-1?a(t,t+1):e.closed&&o>1&&a(o-1,0);let l=Math.hypot(i,s);return l>0?n(i/l,s/l):1}function Cf(e,t,n){let r=e??.5,o=hi(t,n);return o/2>r?{flattenTolerance:e,offset:o/2}:{flattenTolerance:e}}function Zl(e){return e===void 0?"":`${co(e.metric)}@${e.pxPerUnit}`}var QR=1e-9;function eu(e,t,n,r){let o=Math.abs(e*r-t*n),i=Math.sqrt(o);if(!(o>0)||!Number.isFinite(o))return{scale:0,metric:null};let s=(e*e+t*t)/o,a=(e*n+t*r)/o,l=(n*n+r*r)/o,u=Math.sqrt(s+l+2),c=(s+1)/u,d=a/u,f=(l+1)/u;return Math.abs(d)<QR&&Math.abs(c-f)<QR?{scale:i,metric:null}:{scale:i,metric:{p:c,q:d,r:f}}}function co(e){return e===void 0?"":`${e.p},${e.q},${e.r}`}function tu(e,t){let n=e.points;for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];n[r]=t.p*o+t.q*i,n[r+1]=t.q*o+t.r*i}}function jb(e,t){let n=e.points;for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];n[r]=t.r*o-t.q*i,n[r+1]=t.p*i-t.q*o}}function Of(e,t){return e===t?!0:e!==null&&t!==null&&e.p===t.p&&e.q===t.q&&e.r===t.r}function $b(e,t,n){return Math.hypot(e.r*t-e.q*n,e.p*n-e.q*t)}function Yb(e,t,n){return 1/Math.hypot(e.p*t+e.q*n,e.q*t+e.r*n)}function nu(e,t){for(let n=0;n<e.length;n+=2){let r=e[n],o=e[n+1];e[n]=t.r*r-t.q*o,e[n+1]=t.p*o-t.q*r}}function Ff(e){return e.q===0}function qb(e,t){return Ff(t)?{kind:"rect",x:t.p*e.x,y:t.r*e.y,width:t.p*e.width,height:t.r*e.height}:null}var ZR=(e,t)=>e===void 0?{length:0,metric:t}:typeof e=="number"?{length:e,metric:t}:e;function eN(e,t,n,r,o){let i=ZR(r,n),s=ZR(o,n),a=e,l=t,u=c=>{a===null||Of(l,c)||(l!==null&&jb(a,l),c!==null&&tu(a,c),l=c)};if(i.length>0||s.length>0)if(Of(i.metric,s.metric))u(i.metric),a=yf(a,i.length,s.length);else for(let[c,d,f]of[[i.length,i.metric,!0],[s.length,s.metric,!1]])!(c>0)||a===null||(u(d),a=yf(a,f?c:0,f?0:c));return u(n),a}var vW=10*Math.PI/180;function Jb(e,t,n,r,o,i,s,a,l,u,c,d,f,p,h){let m=r?1:-1,g=(e.bx-e.ax)/e.len*m,b=(e.by-e.ay)/e.len*m,x=(o+i)/2,w=(o-i)/2,y=(r?e.bx:e.ax)+e.nxUnit*w,P=(r?e.by:e.ay)+e.nyUnit*w,S=e.nxUnit*x,v=e.nyUnit*x;if(s==="square"){let A=y+g*x,N=P+b*x,M=a.length/2;a.push(A+S,N+v),u.push(f),c.push(p),d.push(h);let C=a.length/2;a.push(A-S,N-v),u.push(f),c.push(p),d.push(h),r?l.push(t,M,C,t,C,n):l.push(t,C,M,t,n,C);return}if(s==="round"){let A=a.length/2;a.push(y,P),u.push(f),c.push(p),d.push(h);let N=Math.atan2(v,S),M=r?-Math.PI:Math.PI,C=Math.max(1,Math.ceil(Math.abs(M)/vW)),F=M/C,B=t;for(let D=1;D<C;D++){let j=N+D*F,V=y+Math.cos(j)*x,J=P+Math.sin(j)*x,se=a.length/2;a.push(V,J),u.push(f),c.push(p),d.push(h),r?l.push(B,se,A):l.push(B,A,se),B=se}r?l.push(B,n,A):l.push(B,A,n)}}function Qb(e,t,n,r,o,i,s,a){let l=n-e,u=r-t,c=Math.hypot(l,u);return c===0?null:{ax:e,ay:t,bx:n,by:r,nxUnit:-u/c,nyUnit:l/c,posA:o,negA:i,posB:s,negB:a,len:c}}function tN(e,t,n,r,o,i,s,a,l,u,c,d,f,p,h,m=-1){let g=e[n],b=e[(n+1)%e.length],x=t[n],w=t[(n+1)%e.length],y=g.bx-g.ax,P=g.by-g.ay,S=b.bx-b.ax,v=b.by-b.ay,A=y*v-P*S;if(A===0)return;let N=A>0,M=N?x+3:x+2,C=N?w+1:w+0,F=(n+1)%e.length,B=d[F],D=f[B],j=p[B],V=h[B],J=N?[g.negA,g.negB]:[g.posA,g.posB],se=N?[b.negA,b.negB]:[b.posA,b.posB],ke=J[1],ae=Math.max(...J)/Math.max(1e-9,Math.min(...J)),ve=Math.max(...se)/Math.max(1e-9,Math.min(...se)),G=ae>i||ve>i;if(r==="bevel"||G){Xb(g,M,C,N,s,a,l,u,c,D,j,V,m);return}if(r==="miter"){let K=s[M*2],$=s[M*2+1],Q=s[C*2],te=s[C*2+1],he=NW(K,$,y,P,Q,te,-S,-v);if(!he){Xb(g,M,C,N,s,a,l,u,c,D,j,V,m);return}if(Math.hypot(he[0]-g.bx,he[1]-g.by)>o*ke){Xb(g,M,C,N,s,a,l,u,c,D,j,V,m);return}let Fe=s.length/2;s.push(he[0],he[1]),l.push(D),u.push(j),c.push(V);let Se=m>=0?m:Zb(g,s,l,u,c,D,j,V);N?(a.push(M,Fe,C),a.push(M,C,Se)):(a.push(M,C,Fe),a.push(M,Se,C));return}if(r==="round"){RW(g,M,C,N,s,a,l,u,c,D,j,V,m);return}}var AW=10*Math.PI/180;function RW(e,t,n,r,o,i,s,a,l,u,c,d,f){let p=e.bx,h=e.by,m=f>=0?f:Zb(e,o,s,a,l,u,c,d),g=o[t*2]-p,b=o[t*2+1]-h,x=o[n*2]-p,w=o[n*2+1]-h,y=Math.hypot(g,b),P=Math.hypot(x,w),S=Math.atan2(b,g),A=Math.atan2(w,x)-S;r&&A<0?A+=2*Math.PI:!r&&A>0&&(A-=2*Math.PI);let N=Math.max(1,Math.ceil(Math.abs(A)/AW)),M=A/N,C=t;for(let F=1;F<N;F++){let B=S+F*M,D=y+(P-y)*F/N;o.push(p+Math.cos(B)*D,h+Math.sin(B)*D);let j=o.length/2-1;s.push(u),a.push(c),l.push(d),r?i.push(C,m,j):i.push(C,j,m),C=j}r?i.push(C,m,n):i.push(C,n,m)}function Xb(e,t,n,r,o,i,s,a,l,u,c,d,f){let p=f>=0?f:Zb(e,o,s,a,l,u,c,d);r?i.push(t,p,n):i.push(t,n,p)}function Zb(e,t,n,r,o,i,s,a){let l=t.length/2;return t.push(e.bx,e.by),n.push(i),r.push(s),o.push(a),l}function NW(e,t,n,r,o,i,s,a){let l=n*a-r*s;if(Math.abs(l)<1e-9)return null;let u=((o-e)*a-(i-t)*s)/l;return[e+u*n,t+u*r]}function nN(e,t,n,r){let o=e.length,i=n?o:o-1,s=[];for(let l=0;l<i;l++)s.push(IW(e,t,l,r));for(let l=!0;l;){l=!1;for(let u=0;u<o;u++){let c=u>0||n?s[(u-1+o)%o]??null:null,d=u<i?s[u]:null;c&&d&&c.side===d.side&&c.u>d.s&&(s[(u-1+o)%o]=null,s[u]=null,l=!0)}}let a=[];for(let l=0;l<i;l++){let u=s[l];if(!u){a.push(-1);continue}let c=t[l]+2+u.side,d=t[(l+1)%o]+u.side;r[c*2]=u.x,r[c*2+1]=u.y,r[d*2]=u.x,r[d*2+1]=u.y,a.push(c)}return a}function IW(e,t,n,r){let o=e[n],i=e[(n+1)%e.length],s=(o.bx-o.ax)*(i.by-i.ay)-(o.by-o.ay)*(i.bx-i.ax);if(s===0)return null;let a=s>0?0:1,l=t[n],u=t[(n+1)%e.length],c=r[(l+a)*2],d=r[(l+a)*2+1],f=r[(l+2+a)*2],p=r[(l+2+a)*2+1],h=r[(u+a)*2],m=r[(u+a)*2+1],g=r[(u+2+a)*2],b=r[(u+2+a)*2+1],x=f-c,w=p-d,y=g-h,P=b-m,S=x*P-w*y;if(S===0)return null;let v=h-c,A=m-d,N=(v*P-A*y)/S,M=(v*w-A*x)/S;return N>0&&N<=1&&M>=0&&M<1?{side:a,x:c+x*N,y:d+w*N,s:N,u:M}:null}var EW={vertices:new Float32Array(0),indices:new Uint32Array(0),anchorA:new Uint32Array(0),anchorB:new Uint32Array(0),anchorT:new Float32Array(0)};function at(e,t){return Bt(e,t)}function mi(e,t,n={}){let r=at(t.width??1,1);if(r<=0)return EW;let o=t.join??"miter",i=t.cap??"butt",s=t.align??"center",a=t.miterLimit??CW,l=t.varyingWidthJoinThreshold??OW,u=n.metric,c=u&&e.kind==="rect"?qb(e,u):null,d=c??e;d.kind==="rect"&&s!=="center"&&(d={kind:"rect",...ob(d,s,r)});let f=d.kind==="polygon"?os(d):null;f&&(d=f.path);let p=t.vertexWidths&&t.vertexWidths.length>0?t.vertexWidths:null,h=p&&f?.anchorSources?gl(p,f.anchorSources,1):p,m=as(d,Cf(n.flattenTolerance,r,h??void 0)),g=u?c?(N,M)=>$b(u,N,M):(N,M)=>Yb(u,N,M):void 0,b=[],x=[],w=[],y=[],P=[],S=u??null,v=[];for(let N of m){JR(N,h,t.nib,r,g);let M=eN(N,c?S:null,S,n.startInset,n.endInset);M!==null&&v.push(M)}for(let N of $R(v,t.dash))MW(N,r,o,i,a,l,b,x,w,y,P);let A=new Float32Array(b);return u&&nu(A,u),{vertices:A,indices:new Uint32Array(x),anchorA:new Uint32Array(w),anchorB:new Uint32Array(y),anchorT:new Float32Array(P),...e.kind==="polygon"&&e.origin?{origin:e.origin}:{}}}function MW(e,t,n,r,o,i,s,a,l,u,c){let d=t/2,f=e.points,p=f.length/2,h=p-1;if(h<1)return;let m=e.anchorA??new Uint32Array(p),g=e.anchorB??new Uint32Array(p),b=e.anchorT??new Float32Array(p),x=e.widths,w=e.offsets,y=F=>(x?x[F]/2:d)+(w?w[F]:0),P=F=>(x?x[F]/2:d)-(w?w[F]:0),S=[],v=[];for(let F=0;F<h;F++){let B=Qb(f[F*2],f[F*2+1],f[(F+1)*2],f[(F+1)*2+1],y(F),P(F),y(F+1),P(F+1));B&&(S.push(B),v.push(F))}let A=-1;if(e.closed&&S.length>=1){let F=S[S.length-1],B=S[0],D=Qb(F.bx,F.by,B.ax,B.ay,y(p-1),P(p-1),y(0),P(0));D&&(S.push(D),A=p-1,v.push(A))}if(S.length===0)return;let N=[];for(let F=0;F<S.length;F++){let B=S[F],D=v[F],j=F===S.length-1&&e.closed&&A>=0?0:D+1,V=s.length/2;N.push(V);let{nxUnit:J,nyUnit:se}=B;s.push(B.ax+J*B.posA,B.ay+se*B.posA),l.push(m[D]),u.push(g[D]),c.push(b[D]),s.push(B.ax-J*B.negA,B.ay-se*B.negA),l.push(m[D]),u.push(g[D]),c.push(b[D]),s.push(B.bx+J*B.posB,B.by+se*B.posB),l.push(m[j]),u.push(g[j]),c.push(b[j]),s.push(B.bx-J*B.negB,B.by-se*B.negB),l.push(m[j]),u.push(g[j]),c.push(b[j]),a.push(V,V+1,V+2,V+1,V+3,V+2)}let M=e.closed?S.length:S.length-1,C=nN(S,N,e.closed,s);for(let F=0;F<M;F++)tN(S,N,F,n,o,i,s,a,l,u,c,v,m,g,b,C[F]);if(!e.closed&&r!=="butt"){let F=S[0],B=N[0];Jb(F,B+0,B+1,!1,F.posA,F.negA,r,s,a,l,u,c,m[0],g[0],b[0]);let D=S[S.length-1],j=N[S.length-1],V=v[S.length-1]+1;Jb(D,j+2,j+3,!0,D.posB,D.negB,r,s,a,l,u,c,m[V],g[V],b[V])}}var CW=4,OW=1.5;ee();function Fs(e,...t){let n=0,r=0;for(let[l,u]of t)n+=l.length/2+(u?1:0),r+=l.length;let o=new Uint8Array(n),i=new Float32Array(r),s=0,a=0;for(let[l,u]of t){for(let c=0;c<l.length;c+=2)o[s++]=c===0?le:ce,i[a++]=l[c]*e,i[a++]=l[c+1]*e;u&&(o[s++]=fe)}return{kind:"polygon",commands:o,coords:i,fillRule:"nonzero"}}function br(e,t,n=!0){return Fs(t,[e,n])}function sN(e,t,n=32){let r=[];for(let o=0;o<n;o++){let i=o/n*Math.PI*2;r.push(e+t*Math.cos(i),t*Math.sin(i))}return r}function rN(e,t,n){return br(sN(e,t),n)}var Lf=e=>[[e,-2,e,2],!1],ex=[[[-4,0,0,-2.5],!1],[[-4,0,0,2.5],!1]],oN=2,iN=e=>[[sN(e,oN),!0],[[e+oN,0,0,0],!1]],ru={reads:[],fill:"none",outline:{width:1}},aN=[{id:"arrow",reads:[],inset:3,path:({size:e})=>br([0,0,-3,-1.5,-3,1.5],e)},{id:"arrow-open",reads:[],inset:0,fill:"none",outline:{width:1},path:({size:e})=>br([-2.867,-2.007,0,0,-2.867,2.007],e,!1)},{id:"arrow-concave",reads:[],inset:3,path:({size:e})=>br([0,0,-3,-1.5,-2,0,-3,1.5],e)},{id:"triangle-hollow",reads:[],inset:4,fill:"none",outline:{width:.5},path:({size:e})=>br([0,0,-4,-2,-4,2],e)},{id:"diamond",reads:[],inset:4,path:({size:e})=>br([0,0,-2,-1.2,-4,0,-2,1.2],e)},{id:"diamond-hollow",reads:[],inset:4,fill:"none",outline:{width:.5},path:({size:e})=>br([0,0,-2,-1.2,-4,0,-2,1.2],e)},{id:"circle",reads:[],inset:2,path:({size:e})=>rN(-1,1,e)},{id:"square",reads:[],inset:2,path:({size:e})=>br([0,-1,0,1,-2,1,-2,-1],e)},{id:"bar",reads:[],inset:0,fill:"none",outline:{width:1},path:({size:e})=>br([0,-1.5,0,1.5],e,!1)},{id:"dot",reads:[],inset:0,path:({size:e})=>rN(0,1.2,e)},{id:"crow-one",...ru,inset:0,path:({size:e})=>Fs(e,Lf(-2),Lf(-4),[[-4,0,0,0],!1])},{id:"crow-many",...ru,inset:0,path:({size:e})=>Fs(e,...ex)},{id:"crow-zero-one",...ru,inset:7.5,path:({size:e})=>Fs(e,Lf(-2),...iN(-5.5))},{id:"crow-one-many",...ru,inset:0,path:({size:e})=>Fs(e,...ex,Lf(-5.5))},{id:"crow-zero-many",...ru,inset:9.5,path:({size:e})=>Fs(e,...ex,...iN(-7.5))}];var _f=bt();function FW(){for(let e of aN)_f.push(e.id,e,{source:"kit"})}FW();var LW=_f.reflection;function ou(){return _f.getVersion()}function fo(e){return e===void 0?void 0:_f.get(e)}Pe();function Ls(e,t,n=1){return typeof e=="string"||e.size===void 0?t:Bt(e.size,n)}function yi(e){return typeof e=="string"?e:e.key}function tx(e,t,n=1){if(e===void 0)return 0;let r=fo(yi(e));return r===void 0?0:(r.inset??0)*Ls(e,t,n)}function _s(e,t){return{start:tx(e.markerStart,t),end:tx(e.markerEnd,t)}}function Ds(e,t,n){let r=e.points[n*2]-e.points[t*2],o=e.points[n*2+1]-e.points[t*2+1],i=Math.hypot(r,o);return i<1e-9?null:{x:r/i,y:o/i}}function lN(e,t,n){for(let r=t+1;r<n;r++)if(Ds(e,t,r))return r;return-1}function uN(e,t){for(let n=t-1;n>=0;n--)if(Ds(e,n,t))return n;return-1}function cN(e,t){let n=[],r=e.points.length/2;if(r<2)return n;if(t.start&&!e.closed){let o=lN(e,0,r),i=o>=0?Ds(e,0,o):null;i&&n.push({x:e.points[0],y:e.points[1],angle:Math.atan2(-i.y,-i.x),role:"start"})}if(t.mid){let o=e.anchorA,i=e.anchorB,s=e.anchorT;if(o&&i&&s)for(let a=1;a<r-1;a++){if(o[a]!==i[a]||s[a]!==0)continue;let l=uN(e,a),u=lN(e,a,r);if(l<0||u<0)continue;let c=Ds(e,l,a),d=Ds(e,a,u),f=c.x+d.x,p=c.y+d.y;Math.hypot(f,p)<1e-9&&(f=c.x,p=c.y),n.push({x:e.points[a*2],y:e.points[a*2+1],angle:Math.atan2(p,f),role:"mid"})}}if(t.end&&!e.closed){let o=r-1,i=uN(e,o),s=i>=0?Ds(e,i,o):null;s&&n.push({x:e.points[o*2],y:e.points[o*2+1],angle:Math.atan2(s.y,s.x),role:"end"})}return n}ee();function _W(e,t,n){let{origin:r,...o}=e,i=Math.cos(t.angle),s=Math.sin(t.angle),a=new Float32Array(o.coords.length);for(let l=0;l<o.coords.length;l+=2){let u=o.coords[l],c=o.coords[l+1];a[l]=t.x+u*i-c*s,a[l+1]=t.y+u*s+c*i}return n?{...o,coords:a,origin:n}:{...o,coords:a}}function iu(e,t,n,r,o={}){let i={start:t.markerStart,mid:t.markerMid,end:t.markerEnd};if(i.start===void 0&&i.mid===void 0&&i.end===void 0)return[];let s=new Map;for(let u of["start","mid","end"]){if(i[u]===void 0)continue;let c=o[u],d=s.get(c);d===void 0&&s.set(c,d={start:!1,mid:!1,end:!1}),d[u]=!0}let a=[],l=e.kind==="polygon"?e.origin:void 0;for(let u of as(e,Cf(r,n,t.vertexWidths)))for(let[c,d]of s){let f=c?{...u,points:u.points.slice()}:u;c&&tu(f,c.metric);for(let p of cN(f,d)){let h=i[p.role];if(h===void 0)continue;let m=fo(yi(h));if(m===void 0)continue;let g=Ls(h,n),b=m.orient===void 0||m.orient==="auto"?p.angle:m.orient,x=_W(m.path({size:g,stroke:t}),{...p,angle:b},l);c&&nu(x.coords,c.metric),a.push(c?{entry:m,size:g,path:x,space:c}:{entry:m,size:g,path:x})}}return a}function Df(e,t){if(e.reads===void 0)return null;let n="";for(let r of e.reads)n+=`${JSON.stringify(t[r])??""}|`;return n}var DW=64,dN=new WeakMap,fN=new WeakMap;function pN(e,t){let n=et(e.path({size:1,stroke:t}));return Math.max(Math.abs(n.x),Math.abs(n.x+n.width),Math.abs(n.y),Math.abs(n.y+n.height))+(e.outline?e.outline.width/2:0)}function BW(e,t){let n=Df(e,t);if(n===null){let i=fN.get(e);i===void 0&&fN.set(e,i=new WeakMap);let s=i.get(t);return s===void 0&&i.set(t,s=pN(e,t)),s}let r=dN.get(e);r===void 0&&dN.set(e,r=new Map);let o=r.get(n);return o===void 0&&(r.size>=DW&&r.clear(),r.set(n,o=pN(e,t))),o}function su(e){let t={world:0,px:0},n=e.width??1;for(let r of[e.markerStart,e.markerMid,e.markerEnd]){if(r===void 0)continue;let o=fo(yi(r));if(o===void 0)continue;let i=typeof r=="string"||r.size===void 0?n:r.size,s=BW(o,e);typeof i=="number"?t.world=Math.max(t.world,s*i):t.px=Math.max(t.px,s*i.px)}return t}var au=qH(hN(),1);Je();wn();ss();Qo();en();Zt();function mN(e,t={}){let n=Qe(e);if(n.kind==="rect"){let{x:m,y:g,width:b,height:x}=n;return[[[[m,g],[m+b,g],[m+b,g+x],[m,g+x],[m,g]]]]}let r=t.tolerance??.5,o=[],i=null,s=0,a=0,l=0,u=0,c=0,{commands:d}=n,f=$e(n),p=Tn(n),h=(m=p)=>{if(m||(i=null),!i||i.length===0)return;let g=i[0],b=i[i.length-1];(g[0]!==b[0]||g[1]!==b[1])&&i.push([g[0],g[1]]),i.length>=4&&o.push(i),i=null};for(let m=0;m<d.length;m++){let g=d[m];switch(g){case le:{h(),s=f[c],a=f[c+1],l=s,u=a,i=[[s,a]],c+=2;break}case ce:{i??=[[s,a]],s=f[c],a=f[c+1],i.push([s,a]),c+=2;break}case xe:{let b=f[c],x=f[c+1],w=f[c+2],y=f[c+3],P=f[c+4],S=f[c+5],v=[];Jo(s,a,b,x,w,y,P,S,r,v),i??=[[s,a]];for(let A=0;A<v.length;A+=2)i.push([v[A],v[A+1]]);s=P,a=S,c+=6;break}case we:{let b=f[c],x=f[c+1],w=f[c+2],y=f[c+3],[P,S,v,A]=to(s,a,b,x,w,y),N=[];Jo(s,a,P,S,v,A,w,y,r,N),i??=[[s,a]];for(let M=0;M<N.length;M+=2)i.push([N[M],N[M+1]]);s=w,a=y,c+=4;break}case fe:{h(!0),s=l,a=u;break}default:throw new Error(`pathToMultiPolygon: unknown command ${g}`)}}return h(),o.length===0?[]:WW(o,n.fillRule)}function HW(e){let t=0;for(let n=0,r=e.length-1;n<r;n++)t+=e[n][0]*e[n+1][1]-e[n+1][0]*e[n][1];return t*.5}function GW(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let[i,s]of e)i<t&&(t=i),i>r&&(r=i),s<n&&(n=s),s>o&&(o=s);return[t,n,r,o]}function UW(e,t,n){let r=!1;for(let o=0,i=e.length-1;o<i;o++){let[s,a]=e[o],[l,u]=e[o+1];a>n!=u>n&&t<(l-s)*(n-a)/(u-a)+s&&(r=!r)}return r}function VW(e,t,n,r){if(r[0]<t[0]||r[1]<t[1]||r[2]>t[2]||r[3]>t[3])return!1;let o=n.length-1,i=0;for(let s of[0,Math.floor(o/3),Math.floor(2*o/3)])UW(e,n[s][0],n[s][1])&&i++;return i>=2}function WW(e,t){let n=e.length;if(n===1)return[[e[0]]];let r=e.map(GW),o=e.map(u=>HW(u)>=0?1:-1),i=new Array(n).fill(-1),s=e.map(()=>[]);for(let u=0;u<n;u++){let c=-1,d=1/0;for(let f=0;f<n;f++){if(u===f||!VW(e[f],r[f],e[u],r[u]))continue;let p=(r[f][2]-r[f][0])*(r[f][3]-r[f][1]);p<d&&(d=p,c=f)}i[u]=c}for(let u=0;u<n;u++)i[u]>=0&&s[i[u]].push(u);let a=new Array(n);for(let u=0;u<n;u++){let c=0,d=0;for(let f=u;f>=0;f=i[f])d+=o[f],f!==u&&c++;a[u]=t==="evenodd"?c%2===0:d!==0}let l=[];for(let u=0;u<n;u++){if(!a[u]||i[u]>=0&&a[i[u]])continue;let c=[e[u]],d=[...s[u]];for(;d.length>0;){let f=d.pop();a[f]?d.push(...s[f]):c.push(e[f])}l.push(c)}return l}function ox(e){let t=0,n=0;for(let l of e)for(let u of l){if(u.length<4)continue;let c=u.length-1;t+=1+(c-1)+1,n+=c*2}let r=new Uint8Array(t),o=new Float64Array(n),i=0,s=0;for(let l of e)for(let u of l){if(u.length<4)continue;let c=u.length-1;r[i++]=le,o[s++]=u[0][0],o[s++]=u[0][1];for(let d=1;d<c;d++)r[i++]=ce,o[s++]=u[d][0],o[s++]=u[d][1];r[i++]=fe}let a=Pn(o);return{kind:"polygon",commands:r,coords:vt(a,o),fillRule:"nonzero",...a?{origin:a}:{}}}Je();en();ti();Jk();av();Yk();ti();Gy();ti();function Bf(e,t){return e.length===2?dl(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y):e.length===3?HS(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y):fl(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y)}var yN=[.25,.5,.75];function gN(e,t,n){let r=[],o=s=>{r.some(a=>Math.hypot(a.p.x-s.p.x,a.p.y-s.p.y)<=n)||r.push(s)};for(let[s,a]of[[0,t[0]],[1,t[t.length-1]]]){let l=Bf(e,a);l.dist<=n&&o({ta:l.t,tb:s,p:a})}for(let[s,a]of[[0,e[0]],[1,e[e.length-1]]]){let l=Bf(t,a);l.dist<=n&&o({ta:s,tb:l.t,p:a})}let i=null;for(let s=0;s<r.length;s++)for(let a=s+1;a<r.length;a++){let[l,u]=r[s].ta<=r[a].ta?[r[s],r[a]]:[r[a],r[s]];if(i&&u.ta-l.ta<=i[1].ta-i[0].ta)continue;yN.every(d=>Bf(t,tt(e,l.ta+(u.ta-l.ta)*d)).dist<=n)&&(i=[l,u])}return i}function zW(e,t,n){return!(e.from===t.from&&e.to===t.to)&&!(e.from===t.to&&e.to===t.from)?!1:yN.every(o=>Bf(t.seg,tt(e.seg,o)).dist<=n)}function bN(e,t){let n=new Map,r=[];for(let o of e){let i=o.from<o.to?`${o.from},${o.to}`:`${o.to},${o.from}`,s=n.get(i)??[],a=s.find(l=>zW(l,o,t));if(a){(a.also??=[]).push({operand:o.operand,sign:a.from===o.from?1:-1});continue}s.push(o),n.set(i,s),r.push(o)}return r}var KW=16,Hf=1e-9,ix=class{constructor(t){this.snap=t}snap;points=[];grid=new Map;id(t){let n=Math.floor(t.x/this.snap),r=Math.floor(t.y/this.snap);for(let a=-1;a<=1;a++)for(let l=-1;l<=1;l++)for(let u of this.grid.get(`${n+a},${r+l}`)??[]){let c=this.points[u];if(Math.hypot(c.x-t.x,c.y-t.y)<=this.snap)return u}let o=this.points.length;this.points.push({x:t.x,y:t.y});let i=`${n},${r}`,s=this.grid.get(i);return s?s.push(o):this.grid.set(i,[o]),o}};function jW(e){let t=[];return e.forEach((n,r)=>n.forEach((o,i)=>o.forEach((s,a)=>{let l=1/0,u=1/0,c=-1/0,d=-1/0;for(let f of s)l=Math.min(l,f.x),c=Math.max(c,f.x),u=Math.min(u,f.y),d=Math.max(d,f.y);t.push({seg:s,operand:r,contour:i,index:a,count:o.length,box:[l,u,c,d]})}))),t}var $W=(e,t)=>{if(e.operand!==t.operand||e.contour!==t.contour)return!1;let n=Math.abs(e.index-t.index);return n===1||n===e.count-1};function YW(e){if(e.length<4)return!1;let t=tt(e,.5),n=ds(e,0,.5,e[0],t),r=ds(e,.5,1,t,e[3]);return!n||!r?!1:Pg(n,r).some(o=>o.ta<1-1e-6||o.tb>1e-6)}function xN(e,t){let n=jW(e);if(n.some(a=>YW(a.seg)))return null;let r=new ix(t),o=n.map(({seg:a})=>[r.id(a[0]),r.id(a[a.length-1])]),i=n.map(()=>[]);for(let a=0;a<n.length;a++){let l=n[a];for(let u=a+1;u<n.length;u++){let c=n[u];if(l.box[0]>c.box[2]+t||c.box[0]>l.box[2]+t||l.box[1]>c.box[3]+t||c.box[1]>l.box[3]+t)continue;let d=gN(l.seg,c.seg,t);if(d){for(let h of d){let m=r.id(h.p);i[a].push({t:h.ta,v:m}),i[u].push({t:h.tb,v:m})}continue}let f=Pg(l.seg,c.seg);if(f.length>=KW)return null;let p=$W(l,c);for(let h of f){if(p&&(h.ta>1-Hf&&h.tb<Hf||h.ta<Hf&&h.tb>1-Hf))continue;let m=r.id(h);i[a].push({t:h.ta,v:m}),i[u].push({t:h.tb,v:m})}}}let s=[];return n.forEach((a,l)=>{let{seg:u}=a,c=[{t:0,v:o[l][0]},...i[l].sort((p,h)=>p.t-h.t),{t:1,v:o[l][1]}],d=[c[0]];for(let p=1;p<c.length;p++){let h=c[p];h.v!==d[d.length-1].v?d.push(h):p===c.length-1&&d.length>1&&(d[d.length-1]=h)}let f=Math.hypot(a.box[2]-a.box[0],a.box[3]-a.box[1]);d.length===1&&u.length>2&&f>100*t&&d.push(c[c.length-1]);for(let p=0;p+1<d.length;p++){let h=d[p],m=d[p+1],g=h.t===0&&m.t===1?u.slice():ds(u,h.t,m.t,r.points[h.v],r.points[m.v]);g&&(g[0]=r.points[h.v],g[g.length-1]=r.points[m.v],s.push({seg:g,from:h.v,to:m.v,operand:a.operand,source:u,t0:h.t,t1:m.t,key:l+h.t*.5,reversed:!1}))}}),{edges:bN(s,t),points:r.points}}ti();function TN(e,t){let n=e.flat(),r=new Float64Array(n.length*4);return n.forEach((o,i)=>{let s=1/0,a=1/0,l=-1/0,u=-1/0;for(let c of o)s=Math.min(s,c.x),l=Math.max(l,c.x),a=Math.min(a,c.y),u=Math.max(u,c.y);r.set([s,a,l,u],i*4)}),{segs:n,boxes:r,fillRule:t}}var qW={x:1,y:0};function wN(e,t){let n=0,{segs:r,boxes:o}=t;for(let i=0;i<r.length;i++){if(e.y<o[i*4+1]||e.y>o[i*4+3]||o[i*4+2]<e.x)continue;let s=r[i];for(let a of Vk(Uk(s,e,qW),!0))tt(s,a.t).x>e.x&&(n+=a.after>0?1:-1)}return n}var PN=(e,t)=>t==="evenodd"?(e&1)!==0:e!==0,SN=e=>({...e,seg:e.seg.slice().reverse(),from:e.to,to:e.from,reversed:!0});function XW(e,t){let n=new Array(t).fill(0);n[e.operand]=1;for(let{operand:r,sign:o}of e.also??[])n[r]+=o;return n}function kN(e,t,n){let r=[];for(let o of e){let i=(o.t0+o.t1)/2,s=tt(o.source,i),a=wl(o.source,i),l=Math.hypot(a.x,a.y);if(l===0){let g=o.seg[0],b=o.seg[o.seg.length-1];if(a={x:b.x-g.x,y:b.y-g.y},l=Math.hypot(a.x,a.y),l===0)continue}let u=-a.y/l*n,c=a.x/l*n,d={x:s.x+u,y:s.y+c},f={x:s.x-u,y:s.y-c},p=XW(o,t.length),h=new Array(t.length),m=new Array(t.length);for(let g=0;g<t.length;g++){let b=wN(d,t[g]),x=wN(f,t[g]);if(Math.abs(b-x)!==Math.abs(p[g]))return null;h[g]=PN(b,t[g].fillRule),m[g]=PN(x,t[g].fillRule)}r.push({edge:o,inL:h,inR:m})}return r}ti();var ax=Math.PI*2,sx=1e-7;function JW(e){let t=e[0];for(let n=1;n<e.length;n++)if(e[n].x!==t.x||e[n].y!==t.y)return{x:e[n].x-t.x,y:e[n].y-t.y};return{x:0,y:0}}var QW=e=>e.slice().reverse();function ZW(e,t){let n=0;for(let o=0;o+1<e.length;o++)n+=Math.hypot(e[o+1].x-e[o].x,e[o+1].y-e[o].y);let r=tt(e,n===0?0:Math.min(1,t/n));return{x:r.x-e[0].x,y:r.y-e[0].y}}var vN=e=>Math.atan2(e.y,e.x);function e6(e,t){let n=(e-t)%ax;return n<=0?n+ax:n}function AN(e){let t=e[0],n=e[e.length-1];return Math.hypot(n.x-t.x,n.y-t.y)||Math.hypot(e[1].x-t.x,e[1].y-t.y)}function t6(e,t){let n=t[e.to];if(!n||n.length===0)return-1;if(n.length===1)return n[0].key;let r=QW(e.seg),o=l=>{let u=vN(l(r));return n.map(c=>e6(u,vN(l(c.seg))))},i=l=>{let u=l.slice().sort((c,d)=>c-d);return u[0]<sx||u[u.length-1]>ax-sx||u[1]-u[0]<sx},s=o(JW);if(i(s)){let l=.001*Math.min(AN(e.seg),...n.map(u=>AN(u.seg)));if(s=o(u=>ZW(u,l)),i(s))return-1}let a=0;for(let l=1;l<s.length;l++)s[l]<s[a]&&(a=l);return n[a].key}function RN(e,t){if(e.source!==t.source||e.reversed!==t.reversed)return null;let[n,r]=e.reversed?[t,e]:[e,t];if(n.t1!==r.t0)return null;let o=n.t0,i=r.t1,s=n.seg[e.reversed?n.seg.length-1:0],a=r.seg[e.reversed?0:r.seg.length-1],l=o===0&&i===1?n.source.slice():ds(n.source,o,i,s,a);return l?(l[0]=s,l[l.length-1]=a,e.reversed&&l.reverse(),{...e,seg:l,from:e.from,to:t.to,t0:o,t1:i}):null}function n6(e){let t=[];for(let n of e){let r=t.length>0?RN(t[t.length-1],n):null;r?t[t.length-1]=r:t.push(n)}for(;t.length>1;){let n=RN(t[t.length-1],t[0]);if(!n)break;t.pop(),t[0]=n}return t.map(n=>n.seg)}function NN(e,t){let n=new Map,r=Array.from({length:t},()=>[]);if(e.forEach((a,l)=>{n.set(a.key,l),r[a.from].push(a)}),n.size!==e.length)return null;let o=e.map(a=>{let l=t6(a,r);return l<0?-1:n.get(l)});if(o.includes(-1))return null;let i=new Int32Array(e.length).fill(-1),s=[];for(let a=0;a<e.length;a++){if(i[a]>=0)continue;let l=[],u=a;do{if(i[u]>=0)return null;i[u]=s.length,l.push(u),u=o[u]}while(u!==a);let c=0;for(let d=1;d<l.length;d++)e[l[d]].key<e[l[c]].key&&(c=d);s.push(n6([...l.slice(c),...l.slice(0,c)].map(d=>e[d])))}return s}var r6=4096;function o6(e){let t=Qe(e);return t.kind==="polygon"&&t.commands.some(n=>n===xe||n===we)}function i6(e){return e.length<2?e:e[e.length-1].length===2?e.slice(0,-1):e}function s6(e){if(!e.some(o6))return null;let t=e.map(a=>qk(a)),n=t.reduce((a,l)=>a+l.reduce((u,c)=>u+c.length,0),0);if(n===0||n>r6)return null;let r=Xk(t.flat())||1,o=xN(t,r*1e-6);if(!o)return null;let i=t.map((a,l)=>{let u=e[l];return TN(a,u.kind==="polygon"?u.fillRule:"nonzero")}),s=kN(o.edges,i,r*1e-7);return s?{edges:s,vertexCount:o.points.length,clockwise:t.map(u6)}:null}function a6(e,t){let n=new Map,r=(i,s)=>{let a=n.get(i);a?a.push(s):n.set(i,[s])};for(let{edge:i,inL:s,inR:a}of e.edges){let l=t(s),u=t(a);l!==u&&(l!==-1&&r(l,i),u!==-1&&r(u,SN(i)))}let o=new Map;for(let[i,s]of n){let a=NN(s,e.vertexCount);if(!a)return null;o.set(i,a)}return o}function l6(e,t){let n=t?e.map(c6):e;return sv(n.map(r=>({segs:i6(r),closed:!0})),"nonzero")}function IN(e,t){let n=s6(e);if(!n)return null;let r=a6(n,o=>t(o)?0:-1);return r?l6(r.get(0)??[],n.clockwise[0]):null}function u6(e){let t=0;for(let n of e){let r=Gk(n);Math.abs(r)>Math.abs(t)&&(t=r)}return t<0}function c6(e){let t=Hk(e);return[t[t.length-1],...t.slice(0,-1)]}kk();function d6(e,t){return fg(t,ox(e))}function Gf(e,t,n){if(e.length===0)return ox([]);let r=IN(e,t);if(r)return fg(e,r);let[o,...i]=e.map(s=>mN(s));return d6(n(o,...i),e)}var f6=e=>e.includes(!0),p6=e=>!e.includes(!1),h6=e=>e[0]&&!e[1],m6=e=>e.filter(Boolean).length%2===1;function Uf(...e){return Gf(e,f6,au.default.union)}function lx(...e){return Gf(e,p6,au.default.intersection)}function ux(e,t){return Gf([e,t],h6,au.default.difference)}function cx(...e){return Gf(e,m6,au.default.xor)}ee();function EN(e){if(typeof e=="string")return e.length===0?[]:[{text:e}];for(let t=0;t<e.length;t++)if(typeof e[t]?.text!="string")throw new Error(`toRuns: run at index ${t} is missing string \`text\``);return e}Pe();function dx(e,t,n){if(!(t>0))return 0;let r=(Math.floor(e/t)+1)*t-e;return r<n?r+t:r}function MN(e,t,n,r,o,i){let s=0,a=e,l=u=>{u<=a||(i?.(a,u,s),s+=o(a,u))};for(let u of n){if(u<e)continue;if(u>=t)break;l(u);let{stop:c,min:d}=r(u);s+=dx(s,c,d),a=u+1}return l(t),s}function px(e,t){return e==="start"||e==="justify"?t==="rtl"?"right":"left":e==="end"?t==="rtl"?"left":"right":e}var CN={kind:"solid",color:"#000"};function fx(e){return Dt(e)?e.color:"#000"}var ON="",FN="";function LN(e){return e!==ON&&(FN=`color-mix(in srgb, ${e} 25%, transparent)`,ON=e),FN}var Ie={fontSize:16,fontFamily:"sans-serif",fontWeight:400,fontStyle:"normal",align:"left",direction:"auto",lineHeight:1.2,tabSize:8,wrap:!1,fill:null,caretColor:fx(CN),selectionBackground:LN(fx(CN)),selectionColor:null,letterSpacing:0,underline:!1,strikethrough:!1,overline:!1,textTransform:"none",fontVariantCaps:"normal"};function hx(e,t,n=1){return!e&&Ne(t?.fill)===null&&(t?.stroke??void 0)===void 0?Ie:Wf({...Ie},e,t,n)}function Wf(e,t,n,r=1){let o=t??y6,i=Ne(n?.fill),s=n?.stroke??void 0,a=o.caretColor??fx(i?.paint??null),l;o.selectionBackground==="none"?l=null:o.selectionBackground!=null?l=o.selectionBackground:l=LN(a),e.fontSize=Bt(o.fontSize??Ie.fontSize,r),e.fontFamily=o.fontFamily??Ie.fontFamily,e.fontWeight=o.fontWeight??Ie.fontWeight,e.fontStyle=o.fontStyle??Ie.fontStyle,e.align=o.align??Ie.align,e.direction=o.direction??Ie.direction,e.lineHeight=o.lineHeight??Ie.lineHeight,e.tabSize=o.tabSize??Ie.tabSize,e.wrap=o.wrap??Ie.wrap,e.fill=i,e.caretColor=a,e.selectionBackground=l,e.selectionColor=o.selectionColor??null,e.letterSpacing=Bt(o.letterSpacing??Ie.letterSpacing,r),e.underline=o.underline??Ie.underline,e.strikethrough=o.strikethrough??Ie.strikethrough,e.overline=o.overline??Ie.overline,e.textTransform=o.textTransform??Ie.textTransform,e.fontVariantCaps=o.fontVariantCaps??Ie.fontVariantCaps,(o.script!==void 0||e.script!==void 0)&&(e.script=o.script);let u=o.lang||void 0;return(u!==void 0||e.lang!==void 0)&&(e.lang=u),(s!==void 0||e.stroke!==void 0)&&(e.stroke=s),e}var y6=Object.freeze({});Pe();var g6=new Map([[223,"Ss"],[452,"\u01C5"],[453,"\u01C5"],[454,"\u01C5"],[455,"\u01C8"],[456,"\u01C8"],[457,"\u01C8"],[458,"\u01CB"],[459,"\u01CB"],[460,"\u01CB"],[497,"\u01F2"],[498,"\u01F2"],[499,"\u01F2"],[1415,"\u0535\u0582"],[64256,"Ff"],[64257,"Fi"],[64258,"Fl"],[64259,"Ffi"],[64260,"Ffl"],[64261,"St"],[64262,"St"],[64275,"\u0544\u0576"],[64276,"\u0544\u0565"],[64277,"\u0544\u056B"],[64278,"\u054E\u0576"],[64279,"\u0544\u056D"],[8115,"\u1FBC"],[8124,"\u1FBC"],[8131,"\u1FCC"],[8140,"\u1FCC"],[8179,"\u1FFC"],[8188,"\u1FFC"],[8114,"\u1FBA\u0345"],[8116,"\u0386\u0345"],[8119,"\u0391\u0342\u0345"],[8130,"\u1FCA\u0345"],[8132,"\u0389\u0345"],[8135,"\u0397\u0342\u0345"],[8178,"\u1FFA\u0345"],[8180,"\u038F\u0345"],[8183,"\u03A9\u0342\u0345"]]);function b6(e,t){let n=e.codePointAt(0);return n>=8064&&n<=8111?String.fromCodePoint(n|8):g6.get(n)??e.toLocaleUpperCase(t)}function mx(e){if(e)try{return Intl.getCanonicalLocales(e)[0]}catch{return}}var x6=/[\p{L}\p{N}][\p{L}\p{N}\p{M}\p{Pc}'’]*/gu;function w6(e){let t=new Set;if(typeof Intl<"u"&&"Segmenter"in Intl){let n=new Intl.Segmenter(void 0,{granularity:"word"});for(let r of n.segment(e))r.isWordLike&&t.add(r.index);return t}for(let n of e.matchAll(x6))t.add(n.index);return t}function _N(e,t,n){let r=0;for(let o of e)for(let i of o)r+=n(i).length;return r===t.length}function DN(e,t,n=[]){if(t.every(b=>b==="none"))return e.map(b=>({text:b}));let r=e.map((b,x)=>mx(n[x])),o=r.every(b=>b===r[0])?r[0]:void 0,i=(b,x=o)=>b.toLocaleUpperCase(x),s=(b,x=o)=>b.toLocaleLowerCase(x),a=e.join(""),l=t.includes("uppercase")?a.toLocaleUpperCase(o):"",u=t.includes("lowercase")?a.toLocaleLowerCase(o):"",c=l!==""&&_N(e,l,i),d=u!==""&&_N(e,u,s),f=t.includes("capitalize")?w6(a):null,p=[],h=0,m=0,g=0;for(let b=0;b<e.length;b++){let x=e[b],w=t[b]??"none",y=r[b],P=y===o,S="",v=[],A=[],N=!1,M=0;for(let C of x){let F=i(C),B=s(C),D=C;w==="uppercase"?D=c&&P?l.slice(m,m+F.length):i(C,y):w==="lowercase"?D=d&&P?u.slice(g,g+B.length):s(C,y):w==="capitalize"&&f.has(h+M)&&i(C,y)!==C&&(D=b6(C,y)),m+=F.length,g+=B.length,D.length!==C.length&&(N=!0),S+=D;for(let j=0;j<D.length;j++)v.push(M),A.push(M+C.length);M+=C.length}p.push(N?{text:S,srcMap:{length:x.length,starts:v,ends:A}}:{text:S}),h+=x.length}return p}var P6=.7;function T6(e){let t=e?.xHeight,n=e?.capHeight;return t===void 0||n===void 0||t>=n?P6:t/n}function BN(e,t,n){return T6(zo(bn(e,t,n)))}function HN(e,t,n){let r=mx(n),o="",i=[],s=[],a=[],l=!1,u=!1,c=0;for(let f of e){let p=f.toLocaleUpperCase(r),h=p!==f,m=h?p:f;m.length!==f.length&&(l=!0),u||=h;let g=t?t.starts[c]:c,b=t?t.ends[c]:c+f.length;for(let x=0;x<m.length;x++)i.push(h),s.push(g),a.push(b);o+=m,c+=f.length}if(!u)return t?{text:e,srcMap:t}:{text:e};let d=l?{length:t?.length??e.length,starts:s,ends:a}:t;return{text:o,...d?{srcMap:d}:{},small:i}}var UN=null;function VN(){return UN}var GN=new WeakMap;function yx(e){let{family:t,weight:n,style:r}=e.resolved,o=e.outlineFace??(e.source==="outline"?void 0:tl(t,n,r==="italic"?"italic":"normal"));if(!o)return null;let i=GN.get(o);return i===void 0&&(i=o.embedding?.()??null,GN.set(o,i)),i}function S6(e){return yx(e)?.sfnt??null}function WN(e,t,n,r,o=UN){if(o===null)return!1;let i=S6(bn(e,t,n));return i!==null&&o.hasFeature(i,r)}var k6=Object.freeze(["smcp"]),zf=Object.freeze({super:Object.freeze({size:.583,shift:.333}),sub:Object.freeze({size:.583,shift:-.333})}),zN=new WeakMap;function KN(e){if(!e||!e.superscript&&!e.subscript)return zf;let t=zN.get(e);return t||(t=Object.freeze({super:e.superscript??zf.super,sub:e.subscript??zf.sub}),zN.set(e,t)),t}function jN(e,t,n){return KN(zo(bn(e,t,n)))}function $N(e){if(typeof e=="number")return e;if(e==="bold"||e==="bolder")return 700;if(e==="normal")return 400;let t=Number(e);return Number.isFinite(t)?t:400}function YN(e,t){return{fontFamily:e.fontFamily??t.fontFamily,fontWeight:e.fontWeight??(e.bold?700:$N(t.fontWeight)),fontStyle:e.italic?"italic":t.fontStyle}}function lu(e,t,n=1){return gx(new Array(e.length),e,t,n)}function gx(e,t,n,r=1){e.length!==t.length&&(e.length=t.length);let o=!1;for(let s of t)(s.textTransform??n.textTransform)!=="none"&&(o=!0);let i=o?DN(t.map(s=>s.text),t.map(s=>s.textTransform??n.textTransform),t.map(s=>s.lang??n.lang)):null;for(let s=0;s<t.length;s++){let a=t[s],l=i?i[s].text:a.text,u=i?.[s].srcMap,c=a.script??n.script,{fontFamily:d,fontWeight:f,fontStyle:p}=YN(a,n),h=c?jN(d,f,p)[c]:void 0,m=a.baselineShift??h?.shift??0,g=a.fontScale??h?.size??1,b=a.fontSize===void 0&&g!==1,x=a.fontSize!==void 0?Bt(a.fontSize,r):n.fontSize*g,w,y,P=(a.fontVariantCaps??n.fontVariantCaps)==="small-caps";if(P&&WN(d,f,p,"smcp"))y=k6;else if(P){let V=HN(l,u,a.lang??n.lang);if(l=V.text,u=V.srcMap,V.small){let J=x*BN(d,f,p);w=V.small.map(se=>se?J:x)}}let S=a.lang??n.lang,v=a.fill!==void 0?a.fill:n.fill,A=a.letterSpacing!==void 0?Bt(a.letterSpacing,r):n.letterSpacing,N=a.underline||n.underline,M=a.strikethrough||n.strikethrough,C=a.overline||n.overline,F=a.stroke??n.stroke,B=a.rotate&&Number.isFinite(a.rotate)?a.rotate:void 0,D=e[s];if(D!==void 0&&D.srcMap!==void 0==(u!==void 0)&&D.sizeMap!==void 0==(w!==void 0)&&D.stroke!==void 0==(F!==void 0)&&D.strutSize!==void 0===b&&D.rotate!==void 0==(B!==void 0)&&D.fontFeatures!==void 0==(y!==void 0)&&D.lang!==void 0==!!S){D.text=l,D.fontFamily=d,D.fontSize=x,D.fontWeight=f,D.fontStyle=p,D.fill=v,D.letterSpacing=A,D.underline=N,D.strikethrough=M,D.overline=C,D.baselineShift=m*n.fontSize,u&&(D.srcMap=u),w&&(D.sizeMap=w),F!==void 0&&(D.stroke=F),b&&(D.strutSize=n.fontSize),B!==void 0&&(D.rotate=B),y&&(D.fontFeatures=y),S&&(D.lang=S);continue}let j={text:l,fontFamily:d,fontSize:x,fontWeight:f,fontStyle:p,fill:v,letterSpacing:A,underline:N,strikethrough:M,overline:C,baselineShift:m*n.fontSize};u&&(j.srcMap=u),w&&(j.sizeMap=w),F!==void 0&&(j.stroke=F),b&&(j.strutSize=n.fontSize),B!==void 0&&(j.rotate=B),y&&(j.fontFeatures=y),S&&(j.lang=S),e[s]=j}return e}var qN=["underline","strikethrough","overline"],Kf=Object.freeze({underline:Object.freeze({offset:.1,thickness:.05}),strikethrough:Object.freeze({offset:-.3,thickness:.05}),overline:Object.freeze({offset:-.9,thickness:.05})}),XN=new WeakMap;function v6(e){if(!e)return Kf;let t=XN.get(e);if(!t){let n=e.underline??Kf.underline;t=Object.freeze({underline:n,strikethrough:e.strikethrough??Kf.strikethrough,overline:Object.freeze({offset:Kf.overline.offset,thickness:n.thickness})}),XN.set(e,t)}return t}function A6(e,t,n,r){let o=v6(r)[e],i=t+n*o.offset;return{y0:i,y1:i+n*o.thickness}}function JN(e,t,n){let r=[],o=null,i=()=>{let s=o;if(o=null,!(!s||s.x1<=s.x0))for(let a of qN){if(!s.style[a])continue;let{y0:l,y1:u}=A6(a,s.baselineY,s.style.fontSize,s.face);r.push({kind:a,x0:s.x0,y0:l,x1:s.x1,y1:u,run:s.run})}};return{add(s){let a=e[s.run],l=a.underline||a.strikethrough||a.overline?n(s.run):null;if(l===null){o!==null&&i();return}let u=t(s.run);o!==null&&qN.every(d=>o.style[d]===a[d])&&o.style.fontSize===a.fontSize&&o.face===u&&o.baselineY===s.baselineY&&o.paint===l?o.x1=s.x+s.step:(i(),o={run:s.run,style:a,face:u,paint:l,baselineY:s.baselineY,x0:s.x,x1:s.x+s.step})},end(){return i(),r}}}function ZN(e,t,n,r){let o=[],i=0;for(let a=0;a<=t.length;a++)a<t.length&&!n(a)||(a>i&&o.push({start:i,end:a,analysis:e.analyze(t.slice(i,a),r)}),i=a+1);let s=a=>{let l=0,u=o.length-1;for(;l<u;){let d=l+u>>1;o[d].end<=a?l=d+1:u=d}let c=o[l];return c!==void 0&&a>=c.start&&a<c.end?c:void 0};return{reorder(a,l){let u=s(a);if(u===void 0||l>u.end)return{order:[],levels:[]};let c=e.reorder(u.analysis,a-u.start,l-u.start);return{order:c.order.map(d=>d+u.start),levels:c.levels}},baseLevel(a){let l=s(a);return l===void 0?0:e.baseLevel(l.analysis)}}}function R6(e,t,n){if(e.length===t)return[...e];let r=new Set(e),o=[],i=new Map,s=-1,a=-1;for(let u=0;u<t;u++)if(r.has(u))s=u,a<0&&(a=u);else if(s<0)o.push(u);else{let c=i.get(s);c?c.push(u):i.set(s,[u])}if(a<0)return o;let l=[];for(let u of e){let c=i.get(u)??[],d=u===a?o:[];n(u)?l.push(...[...c].reverse(),u,...[...d].reverse()):l.push(...d,u,...c)}return l}var N6=1024,QN=[];function I6(e){let t=QN[e];if(t!==void 0)return t;let n={visual:Array.from({length:e},(r,o)=>o),levels:new Array(e).fill(0)};return e<=N6&&(QN[e]=n),n}function eI(e,t,n){return e===null||n===0?I6(n):E6(e,t,n)}function E6(e,t,n){let r=new Array(n).fill(0),o=e.reorder(t,t+n);for(let s=0;s<n;s++){let a=o.levels[s];typeof a=="number"&&a>=0&&(r[s]=a)}let i=new Set;for(let s of o.order){let a=s-t;Number.isInteger(a)&&a>=0&&a<n&&i.add(a)}return{visual:R6([...i],n,s=>r[s]%2===1),levels:r}}var xx={};$H(xx,{AK:()=>yz,AL:()=>iz,AP:()=>gz,AS:()=>bz,B2:()=>z6,BA:()=>V6,BB:()=>W6,BK:()=>C6,CB:()=>j6,CL:()=>$6,CLASS_MASK:()=>Sz,CM:()=>H6,CP:()=>Y6,CR:()=>O6,EAST_ASIAN:()=>kz,EB:()=>lz,EM:()=>uz,EX:()=>q6,GL:()=>U6,H2:()=>cz,H3:()=>dz,HL:()=>sz,HY:()=>K6,ID:()=>az,IN:()=>X6,IS:()=>ez,JL:()=>fz,JT:()=>hz,JV:()=>pz,LF:()=>F6,NL:()=>L6,NS:()=>J6,NU:()=>tz,OP:()=>Q6,PICTOGRAPHIC_CN:()=>vz,PO:()=>nz,PR:()=>rz,QU:()=>Z6,QU_PF:()=>Tz,QU_PI:()=>Pz,RI:()=>mz,SP:()=>_6,SY:()=>oz,UNICODE_VERSION:()=>M6,VF:()=>xz,VI:()=>wz,WJ:()=>G6,ZW:()=>D6,ZWJ:()=>B6,lineBreakPropsOf:()=>Nz});var M6="16.0.0",C6=0,O6=1,F6=2,L6=3,_6=4,D6=5,B6=6,H6=7,G6=8,U6=9,V6=10,W6=11,z6=12,K6=13,j6=14,$6=15,Y6=16,q6=17,X6=18,J6=19,Q6=20,Z6=21,ez=22,tz=23,nz=24,rz=25,oz=26,iz=27,sz=28,az=29,lz=30,uz=31,cz=32,dz=33,fz=34,pz=35,hz=36,mz=37,yz=38,gz=39,bz=40,xz=41,wz=42,Pz=43,Tz=44,Sz=63,kz=64,vz=128,tI="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+,-./:;<=>?@[]^_{|}~",Az=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,35,36,37,38,39,40,41,42,43,44,71,73,74,79,81,82,83,84,88,89,91,93,94,95,96,97,98,155,157],nI=2787,rI="9H1K1C2A1B18H1E1R1V1b1Z1Y1b1V1U1Q1b1Z1W1N1W1a10X2W3b1R27b1U1Z1Q29b1U1K1P1b6H1D26H1J1U1Y3Z5b1n1b1K2b1Y1Z2b1L6b1o3b1U520b1L3b1L18b1L32b79H1J12H7J13H14b1W260b7H255b1W1K4b1Z1b45H1K1H1b2H1b2H1R1H8b27c4b4c13b6X3b3Y2W2b11H1R1H3R43b21H10X1Y2X3b1H99b1R1b7H1X1b6H2b2H1b4H2b10X23b1H30b27H91b11H15b10X33b9H4b1W1R3b1H2Z22b4H1b9H1b3H1b5H43b3H52b2X5b9H42b24H1X33H54b3H1b18H1b7H10b2H2K10X17b3H56b1H1b7H2b2H2b3H9b1H10b2H2b10X2b2Y5b1Y1b1Z2b1H2b3H56b1H1b5H4b2H2b3H3b1H20b10X2H3b1H11b3H56b1H1b8H1b3H1b3H20b2H2b10X1b1Z8b6H1b3H56b1H1b7H2b2H2b3H7b3H10b2H2b10X18b1H59b5H3b3H1b4H9b1H14b10X9b1Z6b5H55b1H1b7H1b3H1b4H7b2H11b2H2b10X7b1L9b3H1L55b1H1b7H1b3H1b4H7b2H11b2H2b10X3b1H12b4H55b2H1b7H1b3H1b4H9b1H10b2H2b10X9b1Y7b3H70b1H4b6H1b1H1b8H6b10X2b2H61b1H2b7H4b1Z7b8H1b10X2K85b1H2b9H11b7H1b10X39b4L1b2L1J2L1K1J5R1J1b1R3b2H6b10X10b1K1H1b1H1b1H1U1P1U1P2H49b14H1K5H1K2H5b11H1b36H1b2K6b1H9b2L1K1L5b2J80b20H1b10X2K10b4H4b3H1b3H2b7H3b4H13b12H1b1H10X4H98b96(72f88g349b3H1b1K158b1K639b1K26b1U1P78b3K36b4H28b3H2K27b2H30b2H64b32H2K1T1b1K1b1K1Z1b1H2b10X24b2R2K1L1b2R1b3H1J1H10X107b2H34b1H118b12H4b12H8b2R10X128b11X60b5H57b10H1b29H2b1H10X6b10X22b31H49b5H47i16H1m8i1b2K10k2K1d4K10d9H9d3K3H30b13H2b10X6b38k12H2l48b20H3b5K10X6b10X36b2K80b3H1b21H4b1H6b1H2b3H198b13H1J46H1J3H509b1L2b7K1J3K1F1H1G2H1K1J2K1M3b1n1o1U2n1o1U1n4b3S1K2A5H1J8Y1b1n1o1b2T6b1W1U1P3T12b1K1Y4K1b3K1I5b10H13b1U1P14b1U1P17b7Z1Y1Z1y12Z1Y4Z1Y2Z1Y1Z1Y15Z33H18b1Y5b1Y12b1Z251b2Z219b1S24b1U1P1U1P14b2!13b1w1s190b4z3b1!2d1!521b2z1b4d16b2!2b1d1b3d1e2d16b8z1b3d12b12z20b1d22b1!10b6z3b1z13b1z8b2z17b2!5d2!3d4b1d1z3d1b1d1!3b2d2b1d2b3d8b1!6b1d2!1d1!1b2d1e1!2b1!7d1z2b2d2#2e26b1z35b1z1b1z4b3z1b1z3b6V1b2R1d3b1U1P1U1P1U1P1U1P1U1P1U1P1U1P31b3z24b1z14b1z5b1U1P31b1U1P1U1P1U1P1U1P1U1P403b1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P63b1U1P1U1P32b1U1P285b2z51b1z4b1z409b3H7b1R3K1b1R1K112b1K14b1H96b32H2V1n1o1n1o3V1n1o1V1n1o8K1b1K1U1K2b1n1o2b1n1o1U1P1U1P1U1P1U1P4K1R1b2K1b2K5b2M3K1b2K1U8K1b1K1b2K3b2R1U1Q1U1Q1U1Q1U1Q1K34b26!1b89!12b214!26b16!1r2s2!1v2!1w1s1w1s1w1s1w1s1w1s2!1w1s1w1s1w1s1w1s1v1w2s10!6p5!1p5!2v2!1d1b1v1!1v1!1v1!1v1!1v25!1v31!1v1!1v1!1v6!1v6!2v2b2p4v1!2v1!1v1!1v1!1v1!1v25!1v31!1v1!1v1!1v6!1v6!2v4!4v1!5b43!1b94!1b86!9b1!16v31!1b40!8b7024!64z21013!1v1143!3b55!55b2K269b1K1R1K16b10X69b4H1b10H32b2H80b2H1b5K266b1H3b1H4b1H23b5H4b1H11b1Y59b2L2R8b2H50b18H8b2K10X6b18H10b1L2b1H10X28b8H2K23b13H12b29(3b4H47i13H1m6d3K4d1b1K10k4b2d5b1H10b10X6b41k14H9b3K1H8K2H2b10k2b1d3K27b3H50b1H1b3H2b2H5b2H1b1H41b5H2K3b2H236b8H1K2H2b10X6b1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&12b23f4b49g8452b512!29b1c1H10c1b13c1b5c1b1c1b2c1b2c1b10c494b1P1U188b1Y3b16H3s2v2t1w1s1u6b1J1H1J1H1J1H2J1H1J1H1J1H2J1H5!1w1s1w1s1w1s1w1s1w1s1w1s1w1s1w1s2!1w1s7!1s1!1s1b2v2t1!1w1s1w1s1w1s8!1b1!1y1x1!147b1I1b1t2!1y1x2!1w1s2!1s1!1s11!2v3!1t27!1w1!1s29!1w1!1s1!1w2s1w2s1v1!10v45!2v31!3b6!2b6!2b6!2b3!3b1x1y3!2y1b7z10b3H1O259b3K250b1H226b1H149b5H36b1K48b1K207b10X941b1K199b1K225b3H1b2H5b4H40b3H4b1H16b8K141b2H9b6K1S66b7K484b4H8b10X6b10X31b5H1K316b2H1K78b4H70b11H49b4H122b3H2j51i14H1m2K5d4b20d10k1H2i2H1i9b1J3H45b11H2b1X4K1H10b1X34b10X6b3H36b14H1b10X4K1b2H44b1H1b1L10b3H48b14H4b2K1b1K4H1b2H10X1b1L1b3K76b12H2K1b2K1b1H2b1H103b1K53b12H5b10X6b4H1b8i2b2i2b22i1b7i1b2i1b5i1b2H1K7H2b2H2b2H1m2b1k6b1H5b1K2k2i2H2b7H3b5H11b10k1b1k2b1k1b2k36i1b1d9H1b1H2b1H1b4H1b4H1m1j1H3d1b2d8b2H82b18H4b4K1b10X2K2b1H81b20H12b10X213b7H2b9H1L2K2R3b15K4b2H82b17H2K13b10X6b13L62b13H8b10X6b20X57b15H4b10X2b3K237b15H165b10X22b7i2b1i2b8i1b2i1b24i6H1b2H2b3H1m1j1H1j2H3K9b10k119b7H2b7H1b1L1b1H28b10H40b7H1b4H1L1b4K1L1b1H9b11H46b16H3K1b3L2K93b10L230b10X53b8H1b8H1b5K10b10X22b1L1R32b22H1b14H122b6H3b1H1b2H1b7H1b1H8b10X48b5H1b2H1b5H8b10X310b18k1K4H2K7b2H1j1H13i1b34i7H3b4H1m2K11d10k1H130b4Y30b1K1136b5K3555b3U3P36b1P3b1U1P1U1P239b1U2P179b1U7J1U1P3J1U1P1U1P1H6b15H4472b1U1P6960b30k18H10k2342b10X4b2K80b10X38b5H1K58b7H3K10b1K11b10X532b2K10X285b2K182b1H1b55H7b4H77b4v1q11b2p14b6136!8b768!470z41b1z9!8935b4z1b7z1b2z1b291!15b1v29b3v2b1v14b4v8b396!2465b2H1K4H4172b10X518b46H2b23H542b5H3b22H2b7H30b4H148b3H187b87z9b23z1111b50X512b55H4b50H8b1H14b1H2b4K16b5H1b15H1360b7H1b17H2b7H1b2H1b5H100b1H160b7H9b10X356b1H61b4H10X5b1Z492b4H10X244b2H1b10X725b7H109b7H5b10X4b2U844b1Y3b1Y847b4d1!39d4*100d12*15d2*15d1*14d1!1*37d10*142b1z2b10z19b56*26h3!13*44!4*9!7*2!14*6!154*33!12d9!1d70!1d7!1#14!8d2b2d21!2z5!1z5!3#2!1#2!1#2e2d5!12d17!3d1!3d3!5$63!1d1!1d2#2!11#21!19#3!1#4!3#1!3#7!1#1!1#14!1z1!1z1!1z5!1#4!1z1!2z74!2d1!7z16!14z13!12z12b1d4!1d24!12d2e4d1#21d1e4d2#13d1!47d8b24d6b1d74!3#3!5#38b3V3T4b35!1#16!3#9!1#5!6d1#3d3!2d3!4*4!11d2!3*4d9!3*116b3d4*5d85b5d6*12!4*1!15*12b4)56b8)10b6)40b8)30b2)12b4)2b62)12b1#2!1#8!8#6!1#9!10#1!1d3#7!1d48!1#61!2#1!2#1!1#17!3#1!13#34!84b12*14d2*13!3*10!5*52!3#1!7*15!2*11!6*9#7*240b10X6b1022*2b65534!2b65534!655363b1H30b96H128b240H196112b",bx=null,oI=null,iI=null;function Rz(){let e=new Uint8Array(65536),t=new Int32Array(nI),n=new Uint8Array(nI),r=new Uint8Array(128);for(let a=0;a<tI.length;a++)r[tI.charCodeAt(a)]=Az[a];let o=0,i=0,s=0;for(let a=0;a<rI.length;a++){let l=rI.charCodeAt(a);if(l<=57&&l>=48)s=s*10+l-48;else{let u=r[l];t[i]=o,n[i]=u,o<65536&&e.fill(u,o,Math.min(o+s,65536)),i++,o+=s,s=0}}bx=e,oI=t,iI=n}function Nz(e){if(bx===null&&Rz(),e<65536)return bx[e];if(e>1114111)return 27;let t=oI,n=0,r=t.length-1;for(;n<r;){let o=n+r+1>>1;t[o]<=e?n=o:r=o-1}return iI[n]}var{lineBreakPropsOf:Ox,CLASS_MASK:Fx,EAST_ASIAN:Iz,PICTOGRAPHIC_CN:Ez,BK:Mz,CR:hI,LF:mI,NL:Cz,SP:wr,ZW:Gs,ZWJ:vx,CM:sI,WJ:wx,GL:uu,BA:Px,BB:Oz,B2:aI,HY:cu,CB:Tx,CL:jf,CP:du,EX:lI,IN:Fz,NS:uI,OP:$f,QU:Ax,IS:po,NU:an,PO:Bs,PR:Hs,SY:fu,AL:Lx,HL:Jf,ID:Lz,EB:yI,EM:gI,H2:Rx,H3:Nx,JL:Ix,JV:Qf,JT:Zf,RI:Sx,AK:Yf,AP:_z,AS:kx,VF:cI,VI:dI,QU_PI:Ex,QU_PF:Mx}=xx,ne=0,pu=1,bI=2,Dz=8208,qf=9676,Xf=e=>e===Ax||e===Ex||e===Mx,gi=e=>e===Mz||e===hI||e===mI||e===Cz;function bi(e){return gi(Ox(e)&Fx)}var xr=e=>e===Lx||e===Jf,fI=e=>e===Ix||e===Qf||e===Zf||e===Rx||e===Nx,pI=e=>e===Lz||e===yI||e===gI,_x=e=>({cls:new Uint8Array(e),ea:new Uint8Array(e),pict:new Uint8Array(e),cp:new Int32Array(e),start:new Int32Array(e)}),xI=65536,Nn=_x(64);function Bz(e){return Nn.cls.length<e&&(Nn=_x(Math.min(xI,Math.max(e,Nn.cls.length*2)))),Nn}var wI=[],Cx=wI,Ae=Nn.cls,Rn=Nn.ea,hu=Nn.pict,mo=Nn.cp,mu=Nn.start,ho=0;function PI(e){return Dx(e,new Uint8Array(e.length+1))}function Dx(e,t){let n=e.length;for(let i=0;i<n;i++)t[i]=ne;if(n===0)return t[0]=ne,t;t[n]=bI;let r=n<=xI?Bz(n):_x(n);Cx=e,{cls:Ae,ea:Rn,pict:hu,cp:mo,start:mu}=r;let o=0;for(let i=0;i<n;i++){let s=Ox(e[i]),a=s&Fx;if((a===sI||a===vx)&&o>0){let l=Ae[o-1];if(!gi(l)&&l!==wr&&l!==Gs)continue}a===sI||a===vx?(Ae[o]=Lx,Rn[o]=0,hu[o]=0):(Ae[o]=a,Rn[o]=s&Iz?1:0,hu[o]=s&Ez?1:0),mo[o]=e[i],mu[o]=i,o++}ho=o;for(let i=1;i<ho;i++)t[mu[i]]=Uz(i);return Cx=wI,r!==Nn&&({cls:Ae,ea:Rn,pict:hu,cp:mo,start:mu}=Nn),t}var Hz=e=>(Ox(Cx[mu[e]-1])&Fx)===vx;function Gz(e){for(;e>=0&&Ae[e]===wr;)e--;return e}function Uz(e){let t=e-1,n=Ae[t],r=Ae[e];if(n===hI&&r===mI)return ne;if(gi(n))return bI;if(gi(r)||r===wr||r===Gs)return ne;let o=Gz(t);if(o>=0&&Ae[o]===Gs)return pu;if(Hz(e)||n===wx||r===wx||n===uu||r===uu&&n!==wr&&n!==Px&&n!==cu||r===jf||r===du||r===lI||r===fu)return ne;let i=o>=0?Ae[o]:-1;if(i===$f)return ne;if(i===Ex){let l=o-1;if(l<0)return ne;let u=Ae[l];if(gi(u)||u===$f||Xf(u)||u===uu||u===wr||u===Gs)return ne}if(r===Mx){if(e+1>=ho)return ne;let l=Ae[e+1];if(l===wr||l===uu||l===wx||l===jf||Xf(l)||l===du||l===lI||l===po||l===fu||gi(l)||l===Gs)return ne}if(n===wr&&r===po&&e+1<ho&&Ae[e+1]===an)return pu;if(r===po||(i===jf||i===du)&&r===uI||i===aI&&r===aI)return ne;if(n===wr)return pu;if(r===Ax||r===Mx||n===Ax||n===Ex||Xf(r)&&(!Rn[t]||e+1>=ho||!Rn[e+1])||Xf(n)&&(!Rn[e]||t===0||!Rn[t-1]))return ne;if(n===Tx||r===Tx)return pu;if((n===cu||mo[t]===Dz)&&r===Lx){if(t===0)return ne;let l=Ae[t-1];if(gi(l)||l===wr||l===Gs||l===Tx||l===uu)return ne}if(r===Px||r===cu||r===uI||n===Oz||t>0&&Ae[t-1]===Jf&&(n===cu||n===Px&&!Rn[t])&&r!==Jf||n===fu&&r===Jf||r===Fz||xr(n)&&r===an||n===an&&xr(r)||n===Hs&&pI(r)||pI(n)&&r===Bs||(n===Hs||n===Bs)&&xr(r)||xr(n)&&(r===Hs||r===Bs))return ne;if(r===Bs||r===Hs){let l=n===jf||n===du?t-1:t;for(;l>=0&&(Ae[l]===fu||Ae[l]===po);)l--;if(l>=0&&Ae[l]===an)return ne}if(n===Bs||n===Hs){if(r===an)return ne;if(r===$f&&e+1<ho){let l=Ae[e+1];if(l===an||l===po&&e+2<ho&&Ae[e+2]===an)return ne}}if((n===cu||n===po)&&r===an)return ne;if(r===an){let l=t;for(;l>=0&&(Ae[l]===fu||Ae[l]===po);)l--;if(l>=0&&Ae[l]===an)return ne}if(n===Ix&&(r===Ix||r===Qf||r===Rx||r===Nx)||(n===Qf||n===Rx)&&(r===Qf||r===Zf)||(n===Zf||n===Nx)&&r===Zf||fI(n)&&r===Bs||n===Hs&&fI(r)||xr(n)&&xr(r))return ne;let s=n===Yf||n===kx||mo[t]===qf,a=r===Yf||r===kx||mo[e]===qf;if(n===_z&&a||s&&(r===cI||r===dI)||n===dI&&t>0&&(Ae[t-1]===Yf||Ae[t-1]===kx||mo[t-1]===qf)&&(r===Yf||mo[e]===qf)||s&&a&&e+1<ho&&Ae[e+1]===cI||n===po&&xr(r)||(xr(n)||n===an)&&r===$f&&!Rn[e]||n===du&&!Rn[t]&&(xr(r)||r===an))return ne;if(n===Sx&&r===Sx){let l=t;for(;l>=0&&Ae[l]===Sx;)l--;if((t-l)%2===1)return ne}return r===gI&&(n===yI||hu[t])?ne:pu}var Vz=null;function SI(){return Vz}function kI(e){return e%2===1?"rtl":"ltr"}var Wz=[[1424,1535],[1536,1983],[2144,2303],[64285,65023],[65136,65279],[67584,69631],[124928,126975]],zz=[[1536,1541],[1632,1644],[1757,1757],[1776,1785],[2274,2274],[68912,68921],[69216,69246]],Kz=[[1548,1548],[64830,64831],[65279,65279]];function Bx(e,t){for(let n=0;n<e.length;n++)if(t>=e[n][0]&&t<=e[n][1])return!0;return!1}var TI=!1;function vI(e,t="weasel layoutRuns"){if(!TI)for(let n=0;n<e.length;n++){let r=e[n];if(!(!Bx(Wz,r)||Bx(zz,r)||Bx(Kz,r))){TI=!0,console.warn(`${t}: this text contains right-to-left characters but no \`bidi\` engine is registered, so it is being laid out in logical order \u2014 the glyphs will appear reversed. Import \`bidi\` out of the \`@weasel-js/bidi\` package and call \`registerBidi(bidi)\` once at startup.`);return}}}var yu=[.5];function xi(e){if(e>65536)return new Array(e).fill(.5);for(;yu.length<e;)yu=yu.concat(yu);return yu.slice(0,e)}var jz=1<<18,AI=new Map,RI=new Map,Hx=0;function NI(e,t){let n=e.get(t);if(n===void 0||n.n===0)return;Hx-=t;let r=n.items[--n.n];return n.items[n.n]=void 0,r}function II(e,t){let n=t.length;if(n===0||Hx+n>jz)return;let r=e.get(n);r===void 0&&e.set(n,r={items:[],n:0}),r.items[r.n++]=t,Hx+=n}function gu(e){return NI(AI,e)??xi(e)}function Gx(e){return NI(RI,e)??new Array(e)}function ep(e){II(AI,e)}function EI(e){II(RI,e)}function yt(e,t){for(;e.length>t;)e.pop()}var Pr=13,Ux=0,tp=1,MI=2,CI=3,OI=4,FI=5,LI=6,Vx=7,_I=8,Wx=9,DI=10,BI=11,HI=12,zx=1,GI=2,np=5,$z=[],Yz=[],Kx=[],qz=1024,Xz=0,rp=class e{num;ref;boxes=[];bounds={width:.5,height:.5};laid=null;stamp=0;paintings=[];owners=0;listed=!1;pinned=!1;constructor(t){this.num=gu(t*Pr),this.ref=Gx(t*np)}static take(t){let n=Kx.pop();return n===void 0?n=new e(t):(n.num=gu(t*Pr),n.ref=Gx(t*np)),n.stamp=++Xz,n}recycle(){ep(this.num);let{ref:t}=this;for(let n=0;n<t.length;n++)t[n]=void 0;EI(t),this.num=$z,this.ref=Yz,yt(this.paintings,0),this.owners=0,this.listed=!1,this.pinned=!1,Kx.length<qz&&Kx.push(this)}set(t,n,r,o,i,s){let a=t*Pr,l=t*np,{num:u,ref:c}=this;u[a+Ux]=o,u[a+tp]=i,u[a+MI]=n.advance,u[a+CI]=n.fontSize,u[a+OI]=s,u[a+FI]=n.srcIndex,u[a+LI]=n.srcEnd,u[a+Vx]=n.cp,u[a+_I]=r,u[a+DI]=n.run,u[a+HI]=n.rotate,u[a+Wx]=(n.drawsInk?zx:0)|(n.clusterEnd?GI:0),c[l]=n.resolved,c[l+1]=n.metrics,c[l+2]=n.font,c[l+3]=n.glyph,c[l+4]=n.shaped}widen(t,n){this.num[t*Pr+tp]+=n}setVisual(t,n,r){this.num[(t+n)*Pr+BI]=r}visual(t,n){return this.num[(t+n)*Pr+BI]}glyph(t,n,r){let o=t+n,i=o*Pr,s=o*np,{num:a,ref:l}=this;return r.run=a[i+DI],r.cell=n,r.cp=a[i+Vx],r.fontSize=a[i+CI],r.resolved=l[s],r.metrics=l[s+1],r.font=l[s+2],r.glyph=l[s+3],r.shaped=l[s+4],r.x=a[i+Ux],r.baselineY=a[i+OI],r.advance=a[i+MI],r.step=a[i+tp],r.rotate=a[i+HI],r}drawsInk(t,n){return(this.num[(t+n)*Pr+Wx]&zx)!==0}cell(t,n){let r=(t+n)*Pr,{num:o}=this,i=o[r+Wx];return{srcIndex:o[r+FI],srcEnd:o[r+LI],cp:o[r+Vx],x:o[r+Ux],advance:o[r+tp],level:o[r+_I],drawsInk:(i&zx)!==0,clusterEnd:(i&GI)!==0}}};function jx(){return{run:0,cell:0,cp:0,fontSize:.5,resolved:null,metrics:null,font:null,glyph:null,shaped:null,x:.5,baselineY:.5,advance:.5,step:.5,rotate:.5}}var wt=class e{#t;#n;#e;#r=!1;constructor(t,n,r,o,i,s,a,l,u,c){this.x0=t,this.y0=n,this.x1=r,this.y1=o,this.baselineY=i,this.srcEnd=s,this.justified=a,this.#t=l,this.#n=u,this.#e=c,Object.defineProperties(this,e.#o)}refill(t,n,r,o,i,s,a,l,u){return this.x0=t,this.y0=n,this.x1=r,this.y1=o,this.baselineY=i,this.srcEnd=s,this.justified=a,this.#n=l,this.#e=u,this.#r&&(this.#r=!1,Object.defineProperties(this,e.#o)),this}static columns(t){return t instanceof e?t.#t:null}static start(t){return t instanceof e?t.#n:0}static count(t){return t instanceof e?t.#e:t.glyphs.length}static#o={cells:op("cells",t=>{t.#r=!0;let n=new Array(t.#e);for(let r=0;r<t.#e;r++)n[r]=t.#t.cell(t.#n,r);return n}),glyphs:op("glyphs",t=>{t.#r=!0;let n=new Array(t.#e);for(let r=0;r<t.#e;r++)n[r]=t.#t.glyph(t.#n,t.#t.visual(t.#n,r),jx());return n})}};function op(e,t){return{enumerable:!0,configurable:!0,get(){let n=t(this);return Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!1}),n}}}var $x,Jz=/[\r\u0300-\uffff]/;function Qz(){return $x===void 0&&($x=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null),$x}function sp(e,t){let n=t??[],r=0;if(Jz.test(e)){let o=Qz();if(o)r=Zz(o,e,n);else{let i=0;for(let s of e)n[r++]=i+=s.length}}else for(let o=1;o<=e.length;o++)n[r++]=o;return n.length=r,n}var ip=e=>e<768&&e!==13;function Zz(e,t,n){let r=t.length,o=null,i=0,s=0;for(;s<r;){if(ip(t.charCodeAt(s))&&(s+1===r||ip(t.charCodeAt(s+1)))){n[i++]=++s;continue}let a=s+1;for(;;){for(;a<r&&!ip(t.charCodeAt(a));)a++;if(a===r||(a++,a===r||ip(t.charCodeAt(a))))break}for(o??=e.segment(t);s<a;){let l=o.containing(s);n[i++]=s=l.index+l.segment.length}}return i}var WI=Object.freeze({d:null,key:"",glyphs:Object.freeze([]),rtl:!1,text:""}),UI=Object.freeze({cluster:WI,advance:0}),e7=new WeakMap,t7=new WeakMap,VI=e=>String(Math.round(e*1e5)/1e5);function zI(e,t,n){if(n===null)return null;let r=yx(t);if(r===null)return null;let o=r.sfnt,i=n.shape(o,e.text,e.fontFeatures,e.lang),s=t.source==="outline"?e7:t7,a=s.get(i);if(a)return a;let l=t.source==="outline"?null:u=>r.glyphIndexOf(u);return a=n7(n,o,e.text,i,l),s.set(i,a),a}function n7(e,t,n,r,o){let i=new Array(n.length),s=sp(n),a=0,l=0;for(;l<r.length;){let u=r[l].cluster,c=l;for(;c<r.length&&r[c].cluster===u;)c++;let d=c<r.length?r[c].cluster:n.length;for(;a<s.length&&s[a]<=u;)a++;let f=0;for(let p=a;p<s.length&&s[p]<d;p++)f++;if(!i7(r,l,c)&&!(o&&r7(r[l],c-l,n,u,d,o))){let p=o7(r,l,c),h=p/(f+1),m=r[l].rtl?h-p:0;i[u]=s7(e,t,r,l,c,n.slice(u,d),m,h);let g=h===0?UI:{cluster:WI,advance:h};for(let b=u+1,x=a;b<d;b++){let w=x<s.length&&s[x]===b;w&&x++,i[b]=w?g:UI}}l=c}return i}function r7(e,t,n,r,o,i){if(t!==1||e.dx!==0||e.dy!==0)return!1;let s=n.codePointAt(r);return o-r===(s>65535?2:1)&&i(s)===e.gid}function o7(e,t,n){let r=0;for(let o=t;o<n;o++)r+=e[o].advance;return r}function i7(e,t,n){for(let r=t;r<n;r++)if(e[r].gid===0)return!0;return!1}function s7(e,t,n,r,o,i,s,a){let l=[],u=s,c="",d="";for(let f=r;f<o;f++){let p=n[f],h=u+p.dx,m=p.dy;l.push({gid:p.gid,x:h,y:m,advance:p.advance}),c+=e.glyphD(t,p.gid,h,m)??"",d+=`${f===r?"":";"}${p.gid}${h===0&&m===0?"":`@${VI(h)},${VI(m)}`}`,u+=p.advance}return{cluster:{d:c.length>0?c:null,key:d,glyphs:l,rtl:n[r].rtl,text:i},advance:a}}var a7=/^[\p{Mn}\p{Me}]$/u;function $I(e,t,n,r,o=null){let i=r??[],s=0,a,l=0;for(let u=0;u<e.length;u++){let c=e[u],d=bn(c.fontFamily,c.fontWeight,c.fontStyle),f=es(d);if(!f){Ey(c.fontFamily,c.fontWeight,c.fontStyle),l+=c.srcMap?.length??c.text.length,a=void 0;continue}let p=l,h=c.srcMap,m=sp(c.text,u7),g=zI(c,d,o),b=0,x=0,w=null,y=0,P=c.text;for(;y<P.length;){let S=P.codePointAt(y),v=S>65535?2:1,A=g?.[y],N=c.sizeMap?c.sizeMap[y]:c.fontSize;y===x&&(w=My(d,c.fontFamily,c.fontWeight,c.fontStyle,c.text.slice(y,m[b])));let M=y+v===m[b];M&&(x=m[b++]);let C=M?c.letterSpacing:0,F=h?p+h.starts[y]:p+y,B=h?p+h.ends[y]:p+y+v;y+=v,l=h?p+h.length:B;let D=l7(S),j=a&&!D?a.metrics.kernOf(a.cp,S)*(a.fontSize/a.metrics.size):0,V=d7(n,s,u,c,S,N,F,B,M,d,f);if(w)M&&(V.tracking=C,jI(V,w)),i[s++]=V,a=void 0;else if(bi(S))i[s++]=V,a=void 0;else if(S===9||S===32){let J=f.advanceOf(32),se=J!==null?J*(N/f.size):N*.25;if(S===9)i[s++]={...V,tab:{stop:t*(se+c.letterSpacing),min:se/2}},a=void 0;else{let ke=ol(d,32,KI);V.font=ke?.font??null,V.glyph=ke?.glyph??null,V.advance=se,V.tracking=C,V.kerningBefore=j,a=V,i[s++]=a}}else if(A!==void 0)V.tracking=C,i[s++]=f7(V,A),a=void 0;else{let J=il(d,c.fontFamily,c.fontWeight,c.fontStyle,S,!0,KI);J&&(V.kerningBefore=j,V.tracking=C,jI(V,J)),i[s++]=V,D||(a=V)}}}return i.length=s,i}function l7(e){return e>=768&&a7.test(String.fromCodePoint(e))}var u7=[],KI={resolved:null,metrics:null,advance:0,font:null,glyph:null},c7=4096;function d7(e,t,n,r,o,i,s,a,l,u,c){let d=Math.max(r.fontSize,r.strutSize??0),f=r.baselineShift??0,p=r.rotate??0,h=e?.[t];if(!h){let m={run:n,cp:o,fontSize:i,lineSize:d,baselineShift:f,rotate:p,srcIndex:s,srcEnd:a,clusterEnd:l,resolved:u,metrics:c,font:null,glyph:null,advance:0,tracking:0,kerningBefore:0,tab:void 0,shaped:null,drawsInk:!1};return e&&t<c7&&(e[t]=m),m}return h.run=n,h.cp=o,h.fontSize=i,h.lineSize=d,h.baselineShift=f,h.rotate=p,h.srcIndex=s,h.srcEnd=a,h.clusterEnd=l,h.resolved=u,h.metrics=c,h.font=null,h.glyph=null,h.advance=0,h.tracking=0,h.kerningBefore=0,h.tab=void 0,h.shaped=null,h.drawsInk=!1,h}function jI(e,t){e.resolved=t.resolved,e.metrics=t.metrics,e.font=t.font,e.glyph=t.glyph,e.advance=t.advance*(e.fontSize/t.metrics.size),e.drawsInk=!0}function f7(e,t){return e.shaped=t.cluster,e.advance=t.advance*e.fontSize,e.drawsInk=t.cluster.d!==null,e}function YI(e,t,n,r){return e.map((o,i)=>{let s=t[i]%2===1;if(o.shaped!==null&&o.shaped.rtl!==s){let c=n(o.cp);c!==null&&c!==o.cp&&(o=p7(o,r[o.run]))}if(!s||o.shaped!==null)return o;let a=n(o.cp);if(a===null||a===o.cp)return o;if(o.font===null)return{...o,cp:a};let l=r[o.run],u=il(o.resolved,l.fontFamily,l.fontWeight,l.fontStyle,a,!1);return u?{...o,cp:a,resolved:u.resolved,metrics:u.metrics,font:u.font,glyph:u.glyph}:o})}function p7(e,t){if(e.resolved.source==="outline")return{...e,shaped:null};let n=il(e.resolved,t.fontFamily,t.fontWeight,t.fontStyle,e.cp,!1);return n?{...e,shaped:null,resolved:n.resolved,metrics:n.metrics,font:n.font,glyph:n.glyph}:{...e,shaped:null}}var lp=e=>e===32||e===9;var ap=new Uint8Array(64),Yx=!1,h7=65536;function qI(e,t,n,r){let o=e.length;if(!Number.isFinite(t.maxWidth))qx(e,t,n,r,null);else if(Yx||o>=h7)qx(e,t,n,r,PI(e));else{ap.length<o+1&&(ap=new Uint8Array(Math.max(o+1,ap.length*2))),Yx=!0;try{qx(e,t,n,r,Dx(e,ap))}finally{Yx=!1}}}function qx(e,t,n,r,o){let i=e.length,s=0,a=0;for(;a<i;){let l=e[a];if(bi(l)){r(s,a,!1),a+=l===13&&e[a+1]===10?2:1,s=a;continue}if(lp(l)){a++;continue}let u=a+1,c=a+1;for(;u<i&&!bi(e[u])&&(!o||o[u]===ne);)lp(e[u])||(c=u+1),u++;o&&a>s&&n(s,c)>t.maxWidth&&(r(s,a,!0),s=a),a=u}s<i&&r(s,i,!1)}function XI(e,t){let n=e.lineSize/e.metrics.size,r=e.metrics.ascent*n;return e.metrics.descent===void 0?r:(e.lineSize*t-r-e.metrics.descent*n)/2+r}var QI=[],xu=QI,wi=xi(64),Jx=[],bu=[],Qx=0,JI=[],m7=64;function ZI(e,t){return xu[e].advance+xu[e].tracking+wi[t]-wi[e+1]}var y7=e=>xu[e].tab;function g7(e,t){return MN(e,t,Jx,y7,ZI)}function b7(e,t,n){let r=Qx++,o=JI[r];o===void 0&&(o={start:0,entries:[],width:.5,height:.5,ascent:.5,wrapped:!1,srcEnd:0,end:0},r<m7&&(JI[r]=o)),o.start=e,o.end=t,o.wrapped=n,o.width=0,o.height=0,o.ascent=0,o.srcEnd=0,bu[r]=o}function eE(e,t,n){let{lineHeight:r}=n;wi.length<e.length+1&&(wi=xi(e.length+1)),wi[0]=0;let o=0;Qx=0;for(let i=0;i<e.length;i++){let s=e[i];wi[i+1]=wi[i]+s.kerningBefore+s.advance+s.tracking,s.tab&&(Jx[o++]=i)}Jx.length=o,xu=e,qI(t,n,o===0?ZI:g7,b7),xu=QI,bu.length=Qx;for(let i=0;i<bu.length;i++){let s=bu[i];if(s.start===s.end){let l=e[s.end];s.height=l.lineSize*r,s.ascent=XI(l,r),s.srcEnd=l.srcIndex,yt(s.entries,0);continue}let a=s.entries;for(let l=s.start;l<s.end;l++){let u=e[l];l===s.start&&(u.kerningBefore=0),u.tab&&(u.advance=dx(s.width,u.tab.stop,u.tab.min)),a[l-s.start]=u,s.width+=u.kerningBefore+u.advance+u.tracking,s.height=Math.max(s.height,u.lineSize*r),s.ascent=Math.max(s.ascent,XI(u,r))}a.length=s.end-s.start,s.srcEnd=e[s.end-1].srcEnd}return bu}function x7(e){let t=0;for(let n=e.length-1;n>=0&&lp(e[n].cp);n--){let r=e[n];t+=r.kerningBefore+r.advance+r.tracking}return t}function w7(e){let t=new Set,n=0;for(;n<e.length&&e[n].cp===32;)n++;let r=e.length-1;for(;r>n&&e[r].cp===32;)r--;for(let o=n+1;o<r;o++)e[o].cp===32&&t.add(o);return t}function P7(e,t,n){if(e==="left")return 0;if(!Number.isFinite(t))return e==="center"?-n/2:-n;let r=t-n;return e==="center"?r/2:r}var T7=new Set,Xx={box:null,inkWidth:.5};function tE(e,t,n,r,o,i,s,a){let{alignWidth:l,justify:u}=o,{entries:c}=e,d=x7(c),f=e.width-d,p=l-f,h=u&&e.wrapped&&Number.isFinite(l)&&p>0?w7(c):T7,m=h.size>0?p/h.size:0,g=m*h.size,b=g>0?0:P7(r,l,f),w=d>0&&n.levels[c.length-1]%2===1?b-d:b,y=t+e.ascent,P=w,S=-1,v=-1,A=0,{visual:N}=n;for(let B=0;B<N.length;B++){let D=N[B],j=c[D],V=S<0?0:D===S+1?j.kerningBefore:S===D+1?c[S].kerningBefore:0;V!==0&&i.widen(s+(v>=0?v:S),V),P+=V,S=D;let J=j.advance+j.tracking+(h.has(D)?m:0);J!==0&&(v=D),i.set(s+D,j,n.levels[D],P,J,y-j.baselineShift),i.setVisual(s,A++,D),P+=J}let M=w+e.width+g,C=t+e.height,F=i.boxes[a];return Xx.box=F!==void 0?F.refill(w,t,M,C,y,e.srcEnd,g>0,s,c.length):i.boxes[a]=new wt(w,t,M,C,y,e.srcEnd,g>0,i,s,c.length),Xx.inkWidth=f+g,Xx}function Zx(e,t={maxWidth:0,alignWidth:0,lineHeight:0,align:"left",justify:!1,bidi:null,shaper:null,direction:"auto",tabSize:0}){return t.maxWidth=e.maxWidth,up(t,e),t.lineHeight=e.lineHeight,t.align=e.align,t.justify=e.justify===!0||e.align==="justify",t.bidi=e0(e),t.shaper=wu(e),t.direction=e.direction??"auto",t.tabSize=e.tabSize??8,t}function up(e,t){t.alignWidth===void 0?e.alignWidth=t.maxWidth:e.alignWidth=t.alignWidth}function e0(e){return e.bidi??SI()}function wu(e){return e.shaper??VN()}var S7=[],k7=[],nE=[],v7=Zx({maxWidth:0,lineHeight:0,align:"left"}),A7={maxWidth:.5,alignWidth:.5,lineHeight:.5,justify:!1},R7=e=>bi(nE[e]);function N7(e,t,n,r){return YI(t,n,o=>e.mirror(o),r)}function rE(e,t){let{maxWidth:n,alignWidth:r,lineHeight:o,align:i,justify:s,bidi:a,shaper:l,direction:u,tabSize:c}=Zx(t,v7),d=$I(e,c,S7,k7,l),f=nE;f.length=d.length;for(let S=0;S<d.length;S++)f[S]=d[S].cp;let p=a?ZN(a,f,R7,u):null;a||vI(f);let h=A7;h.maxWidth=n,h.alignWidth=r,h.lineHeight=o,h.justify=s;let m=eE(d,f,h),g=0;for(let S=0;S<m.length;S++)g+=m[S].entries.length;let b=m.length>0?rp.take(g):null,x=b!==null?b.boxes:[],w=0,y=0,P=0;for(let S=0;S<m.length;S++){let v=m[S],A=eI(p,v.start,v.entries.length);a&&(v.entries=N7(a,v.entries,A.levels,e));let N=u!=="auto"?u:kI(v.entries.length>0?p?.baseLevel(v.start)??0:0),M=tE(v,w,A,px(i,N),h,b,P,S);P+=v.entries.length,y=Math.max(y,M.inkWidth),w+=v.height}return x.length=m.length,b===null?{lines:x,bounds:{width:y,height:w}}:(b.bounds.width=y,b.bounds.height=w,b.laid??={lines:x,bounds:b.bounds})}Pe();Pe();var Tr=11;function oE(e){let{font:t,glyph:n}=e;return t!==null&&n!==null&&n.width!==0&&n.page>=0}function t0(e,t,n){let r=e.font,o=e.glyph,i=e.fontSize/e.metrics.size,s=e.x+o.xoffset*i,a=e.baselineY+(o.yoffset-e.metrics.base)*i;t[n]=s,t[n+1]=a,t[n+2]=s+o.width*i,t[n+3]=a+o.height*i,t[n+4]=o.x/r.common.scaleW,t[n+5]=o.y/r.common.scaleH,t[n+6]=(o.x+o.width)/r.common.scaleW,t[n+7]=(o.y+o.height)/r.common.scaleH,t[n+8]=e.baselineY,t[n+9]=e.x,t[n+10]=e.rotate??0}var n0=new WeakSet,iE={quads:op("quads",e=>{n0.add(e);let t=e.quadData,n=[];for(let r=0,o=0;r<t.length;r+=Tr,o++){let i={x0:t[r],y0:t[r+1],x1:t[r+2],y1:t[r+3],u0:t[r+4],v0:t[r+5],u1:t[r+6],v1:t[r+7],baselineY:t[r+8],penX:t[r+9],rotate:t[r+10]};e.colorGlyphs&&(i.colorGlyph=e.colorGlyphs[o]),n.push(i)}return n})};function lE(e,t){return t==="outline"&&mr(e.stroke)?e.stroke:void 0}function sE(e,t){return`${ao(e.fill?.paint)}|${Cl(lE(e,t))}`}function o0(e,t,n){let{family:r,weight:o,style:i}=t.resolved.resolved,{synthetic:s}=t.resolved,a=n==="outline"?0:t.glyph.page;if(qe.group!==null&&qe.run===t.run&&qe.source===n&&qe.page===a&&qe.family===r&&qe.weight===o&&qe.style===i&&qe.bold===s.bold&&qe.italic===s.italic)return qe.group;let l=e[t.run],u=null,c=null;for(let d=0;d<yo.length;d++){let f=yo[d],p=f.group;if(!(p.source!==n||p.page!==a||p.family!==r||p.weight!==o||p.style!==i||p.synthetic.bold!==s.bold||p.synthetic.italic!==s.italic)&&!(f.run!==t.run&&(c??=sE(l,n),f.paint??=sE(e[f.run],n),f.paint!==c))){u=p;break}}if(u===null){let d=lE(l,n);u=d===void 0&&n!=="color"?r0.pop()??null:null,u!==null?(u.family=r,u.weight=o,u.style=i,u.synthetic.bold=s.bold,u.synthetic.italic=s.italic,u.source=n,u.page=a,u.fill=l.fill):(u=Object.defineProperties({family:r,weight:o,style:i,synthetic:{bold:s.bold,italic:s.italic},source:n,page:a,fill:l.fill,quadData:Us,glyphs:[]},iE),d&&(u.stroke=d),n==="color"&&(u.colorGlyphs=[]));let f=yo.length,p=aE[f];p===void 0?(p={group:u,run:t.run,paint:c},f<E7&&(aE[f]=p)):(p.group=u,p.run=t.run,p.paint=c),yo.push(p)}return qe.group=u,qe.run=t.run,qe.family=r,qe.weight=o,qe.style=i,qe.bold=s.bold,qe.italic=s.italic,qe.source=n,qe.page=a,u}var Us=[],r0=[],I7=1024;function uE(e){r0.length>=I7||e.stroke!==void 0||e.colorGlyphs!==void 0||n0.has(e)||(e.quadData=Us,yt(e.glyphs,0),r0.push(e))}var yo=[],aE=[],E7=64,qe={group:null,run:-1,family:"",weight:0,style:"normal",bold:!1,italic:!1,source:"atlas",page:0};function cE(e){for(let t=0;t<yo.length;t++)e.push(yo[t].group),yo[t].group=null;yt(yo,0),qe.group=null}Pe();ee();var dE=5e-4,fE=4096,cp=new Map,dp=new Map;function pE(e){if(!e.synthetic.bold)return null;let{source:t}=e;if(t!=="atlas"&&t!=="canvas")return null;let{family:n,weight:r,style:o}=e.resolved,i=Dy(t,n,r,o);return i===void 0||!(i>0)?null:{growth:i,join:t==="atlas"?"miter":"round"}}function M7(e,t,n){let r=pE(n);if(r===null)return e;let o=`${r.growth}|${r.join}|${t}`,i=cp.get(o);return i||(i=Eg(Ng(e,r.growth,{join:r.join,tolerance:dE}),{tolerance:dE}),cp.size>=fE&&cp.clear(),cp.set(o,i),i)}function hE(e,t){let n=pE(t);if(n===null)return null;let r=`bold:${n.growth}:${n.join}`,o=`${r}|${e}`,i=dp.get(o);return i===void 0&&(i=ag(M7(Zo(e),e,t)),dp.size>=fE&&dp.clear(),dp.set(o,i)),{d:i,tag:r}}function mE(e,t,n,r=!1){let o=e.resolved.source==="outline";if(!o&&!r&&(n===void 0||t.fontSize<n&&!mr(t.stroke)))return null;let i=C7(e);if(i===null)return null;let{family:s,weight:a,style:l}=e.resolved.resolved,u=e.shaped?`${s}|${a}|${l}|#${e.shaped.key}`:`${s}|${a}|${l}|${e.cp}`;if(o||!e.resolved.synthetic.bold)return{d:i,key:u};let c=hE(i,e.resolved);return c&&{d:c.d,key:`${u}|${c.tag}`}}function C7(e){if(e.shaped)return e.shaped.d;if(e.glyph?.color)return null;let{family:t,weight:n,style:r}=e.resolved.resolved;return e.resolved.source!=="outline"&&e.glyph===null?null:Py(t,n,r,e.cp)}function O7(e){let t=e.resolved.dynamicFace,n=e.shaped;if(!t||n.d===null)return null;let r=t.requestShaped(n.key,n.d);return!r||r.page<0||r.width===0?null:{...e,font:t.font,glyph:r}}function F7(e){let t=e.map(n=>zo(bn(n.fontFamily,n.fontWeight,n.fontStyle)));return n=>t[n]}var L7=e=>e.underline||e.strikethrough||e.overline;function _7(e){return t=>qd(e[t].fill)?ao(e[t].fill.paint):null}var D7=jx(),Pu=[],yE=16384;function i0(e,t,n,r){let{groups:o,decorations:i}=r;yt(o,0),yt(i,0);let s=t.some(L7)?F7(t):null,a=s&&_7(t),l=0,{lines:u}=e;for(let h=0;h<u.length;h++)l+=wt.count(u[h]);let c=l*Tr;c<=yE&&Pu.length<c&&(Pu=xi(c));let d=c<=yE?Pu:xi(c),f=null,p=0;for(let h=0;h<u.length;h++){let m=u[h],g=wt.columns(m),b=g!==null?wt.start(m):0,x=wt.count(m),w=s&&JN(t,s,a);for(let y=0;y<x;y++){let P=g!==null?g.visual(b,y):-1,S=g!==null?g.glyph(b,P,D7):m.glyphs[y];w?.add(S);let v=t[S.run],A=g!==null?g.drawsInk(b,P):m.cells[S.cell].drawsInk,N=A?mE(S,v,n.outlineMinSize):null,M=S;if(A&&N===null&&S.shaped){let B=O7(S);B?M=B:N=mE(S,v,n.outlineMinSize,!0)}if(!qd(v.fill)&&!(N!==null&&mr(v.stroke)))continue;if(N!==null){let B={...N,x:S.x,baselineY:S.baselineY,scale:S.fontSize};S.rotate&&(B.rotate=S.rotate),o0(t,S,"outline").glyphs.push(B);continue}if(!oE(M))continue;let C=o0(t,M,M.glyph.color?"color":M.resolved.source);f===null&&(f=C,C.quadData=d);let F=C.quadData;F===Us&&(C.quadData=F=[]),C===f?(t0(M,F,p),p+=Tr):t0(M,F,F.length),C.colorGlyphs?.push(M.glyph)}if(w)for(let y of w.end()){let{run:P,...S}=y;i.push({...S,fill:t[P].fill})}}if(f!==null&&d!==Pu)d.length=p;else if(f!==null){let h=gu(p);for(let m=0;m<p;m++)h[m]=Pu[m];f.quadData=h}return cE(o),r}var s0=new WeakMap,B7=[];function a0(e){return s0.get(e)}function fp(e){let t=s0.get(e);return t===void 0&&(t=B7.pop()??{generation:-1,variants:[],painting:null,paintedOn:null,paintedStamp:0,paintMin:void 0,listed:null},s0.set(e,t)),t}var H7=32,pp=new WeakMap;function G7(e){return e.lines.length>0?wt.columns(e.lines[0])?.stamp??0:0}function U7(e){let t=e.lines.length>0?wt.columns(e.lines[0]):null;if(t!==null)return t.paintings;let n=pp.get(e);return n===void 0&&pp.set(e,n=[]),n}var u0=[],V7=1024;function gE(e,t,n,r,o,i){let s=u0.pop();return s===void 0?{generation:r,key:o,bucket:i,runs:o===null?t:null,painted:i0(e,t,n,{groups:[],decorations:[]}),pinned:!1}:(s.generation=r,s.key=o,s.bucket=i,s.runs=o===null?t:null,s.pinned=!1,i0(e,t,n,s.painted),s)}function W7(e,t){if(t===void 0)return-1;let n=0;for(let r=0;r<e.length;r++){let o=e[r].fontSize;if(!(o>=t))continue;let i=!1;for(let s=0;s<r&&!i;s++)i=e[s].fontSize===o;i||n++}return n}function bE(e,t){let n=`${t}`;for(let r of e)n+=`|${r.underline?1:0}${r.strikethrough?1:0}${r.overline?1:0}${ao(r.fill?.paint)}|${Cl(r.stroke)}`;return n}function xE(e){return e.key===null&&(e.key=bE(e.runs,e.bucket),e.runs=null),e.key}function c0(e,t,n={},r="keep"){let o=Ko(),i=n.outlineMinSize,s=a0(t),a=G7(e),l=s!==void 0&&s.paintedOn===e&&s.paintedStamp===a?s.painting:null,u=l!==null&&l.generation===o;if(u&&s.paintMin===i)return l0(l,r);let c=W7(t,i);if(u&&l.bucket===c)return s.paintMin=i,l0(l,r);let d=U7(e),f=null;if(d.length>0){let h=bE(t,c);for(let m=0;m<d.length;m++){let g=d[m];if(!(g.bucket!==c||xE(g)!==h)){d.splice(m,1),g.generation===o&&(f=g);break}}f??=gE(e,t,n,o,h,c)}else f=gE(e,t,n,o,null,c);d.length>=H7&&d.shift(),d.push(f);let p=s??fp(t);return p.painting!==null&&p.painting!==f&&wE(p.painting,t),p.paintedOn=e,p.paintedStamp=a,p.painting=f,p.paintMin=i,l0(f,r)}function wE(e,t){e.runs===t&&xE(e)}function l0(e,t){return t==="keep"&&(e.pinned=!0),e.painted}function PE(e){let t=e.lines.length>0?wt.columns(e.lines[0]):null,n;if(t!==null)n=t.paintings;else{if(n=pp.get(e),n===void 0)return;pp.delete(e)}for(let r=0;r<n.length;r++){let o=n[r];if(o.pinned)continue;let{groups:i}=o.painted;for(let s=0;s<i.length;s++){let a=i[s];a.quadData.length>0&&ep(a.quadData),a.quadData=Us,uE(a)}yt(i,0),yt(o.painted.decorations,0),o.runs=null,o.key=null,u0.length<V7&&u0.push(o)}yt(n,0)}var NE=8,IE=64,Sr=[],TE=-1,SE=0,In=(e,t)=>e===t||e!==e&&t!==t;function EE(e,t,n){return In(e.maxWidth,t.maxWidth)&&In(e.alignWidth,t.alignWidth??t.maxWidth)&&In(e.lineHeight,t.lineHeight)&&e.align===t.align&&e.justify===(t.justify===!0||t.align==="justify")&&e.direction===(t.direction??"auto")&&In(e.tabSize,t.tabSize??8)&&e.bidi===n&&e.shaper===wu(t)}var zs=e=>e.lines.length>0?wt.columns(e.lines[0]):null;function kE(e,t){if(t==="keep"){let n=zs(e);n!==null&&(n.pinned=!0)}return e}function ME(e){let t=zs(e);t===null||t.owners>0||t.listed||t.pinned||(PE(e),t.recycle())}var f0=[],z7=1024;function vE(e){for(let t=0;t<e.length;t++){let n=e[t],r=zs(n.laid);r!==null&&(r.owners--,ME(n.laid)),n.laid=K7,f0.length<z7&&f0.push(n)}yt(e,0)}var K7={lines:[],bounds:{width:0,height:0}};function p0(e,t,n,r){return e.maxWidth=t.maxWidth,up(e,t),e.lineHeight=t.lineHeight,e.align=t.align,e.justify=t.justify===!0||t.align==="justify",e.direction=t.direction??"auto",e.tabSize=t.tabSize??8,e.bidi=n,e.shaper=wu(t),e.laid=r,e}function j7(e,t,n){let r=f0.pop();if(r!==void 0)return p0(r,e,t,n);let o={maxWidth:e.maxWidth,alignWidth:e.maxWidth,lineHeight:e.lineHeight,align:e.align,justify:e.justify===!0||e.align==="justify",direction:e.direction??"auto",tabSize:e.tabSize??8,bidi:t,shaper:wu(e),laid:n};return up(o,e),o}function Ws(e,t){return Math.imul(e^t,16777619)}function Vs(e,t){return Ws(e,t===(t|0)?t:Math.round(t*4096))}function d0(e,t){e=Ws(e,t.length);for(let n=0;n<t.length;n++)e=Ws(e,t.charCodeAt(n));return e}function $7(e){let t=Ws(2166136261,e.length);for(let n=0;n<e.length;n++){let r=e[n];t=d0(t,r.text),t=d0(t,r.fontFamily),t=Vs(t,r.fontSize),t=Vs(t,r.fontWeight),t=Ws(t,r.fontStyle==="italic"?1:0),t=Vs(t,r.letterSpacing),t=Vs(t,r.baselineShift),t=Vs(t,r.rotate??0),t=Vs(t,r.strutSize??-1),t=Ws(t,r.fontFeatures?.length??0),t=d0(t,r.lang??"")}return t&1073741823}function AE(e,t){if(e===t)return!0;if(e===void 0||t===void 0||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!In(e[n],t[n]))return!1;return!0}function Y7(e,t){if(e===t)return!0;if((e?.length??0)!==(t?.length??0))return!1;for(let n=0;n<(e?.length??0);n++)if(e[n]!==t[n])return!1;return!0}function q7(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],o=t[n];if(r===o)continue;if(r.text!==o.text||r.fontFamily!==o.fontFamily||!In(r.fontSize,o.fontSize)||!In(r.fontWeight,o.fontWeight)||r.fontStyle!==o.fontStyle||!In(r.letterSpacing,o.letterSpacing)||!In(r.baselineShift,o.baselineShift)||!In(r.strutSize,o.strutSize)||!In(r.rotate??0,o.rotate??0)||!AE(r.sizeMap,o.sizeMap)||!Y7(r.fontFeatures,o.fontFeatures)||r.lang!==o.lang)return!1;let i=r.srcMap,s=o.srcMap;if(i!==s&&(i===void 0||s===void 0||i.length!==s.length||!AE(i.starts,s.starts)))return!1}return!0}function Tu(e,t,n="keep"){let r=Xa(),o=e0(t),i=fp(e);if(i.generation!==r)i.generation=r,vE(i.variants);else{let u=i.variants;for(let c=0;c<u.length;c++){let d=u[c];if(EE(d,t,o)){for(let f=c;f>0;f--)u[f]=u[f-1];return u[0]=d,kE(d.laid,n)}}}let s=X7(e,t,o,r,i),a=i.variants;a.length>=NE&&vE(a),a.unshift(j7(t,o,s));let l=zs(s);return l!==null&&l.owners++,kE(s,n)}function X7(e,t,n,r,o){if(TE!==r){for(let d of Sr)RE(d),d.runs=J7;Sr=[],TE=r}let i=$7(e),s=0;for(let d=0;d<Sr.length;d++){let f=Sr[d];if(f.hash===i&&EE(f,t,n)&&q7(f.runs,e))return f.used=++SE,f.laid;f.used<Sr[s].used&&(s=d)}let a=Sr.length>=IE;a&&RE(Sr[s]);let l=rE(e,t),u=a?p0(Sr[s],t,n,l):Q7(t,n,l);u.hash=i,u.runs=e,u.used=++SE,o.listed=u;let c=zs(l);return c!==null&&(c.listed=!0),a||Sr.push(u),l}var J7=[];function Q7(e,t,n){return p0({maxWidth:0,alignWidth:0,lineHeight:0,align:"left",justify:!1,direction:"auto",tabSize:0,bidi:null,shaper:null,laid:n,hash:0,runs:[],used:0},e,t,n)}function RE(e){let t=zs(e.laid);t!==null&&(t.listed=!1,ME(e.laid))}function Su(e,t,n){if(e===void 0||e==="top"||t===void 0)return 0;let r=t-n;return e==="center"?r/2:r}function hp(e,t=1){let n=hx(e.style,{fill:e.fill,stroke:e.stroke},t),r=e.runs&&e.runs.length>0?e.runs:e.text;return{style:n,runs:lu(EN(r),n,t),opts:{maxWidth:n.wrap?e.width:1/0,alignWidth:e.width,lineHeight:n.lineHeight,align:n.align,direction:n.direction,tabSize:n.tabSize,justify:n.align==="justify"}}}function h0(e,t=1){let{runs:n,opts:r}=hp(e,t),o=Tu(n,r);return{laid:o,x:e.x,y:e.y+Su(e.verticalAlign,e.height,o.bounds.height)}}function mp(e,t={}){let n=t.padding??0,{laid:r,x:o,y:i}=h0(e),s=[];for(let a of r.lines)!t.includeEmpty&&a.x1<=a.x0||s.push({x:a.x0+o-n,y:a.y0+i-n,width:a.x1-a.x0+n*2,height:a.y1-a.y0+n*2});return s}function go(e){if(!e)return Z7;let t=e*Math.PI/180;return[Math.cos(t),Math.sin(t)]}var Z7=[1,0];var bo={maxWidth:0,alignWidth:void 0,lineHeight:0,align:"left",direction:"auto",tabSize:0,justify:void 0},yp={laid:null,dx:0,dy:0};function gp(e){let t=e.style;bo.maxWidth=e.maxWidth??1/0,bo.alignWidth=e.width,bo.lineHeight=t.lineHeight??Ie.lineHeight,bo.align=e.align??t.align??Ie.align,bo.direction=e.direction??t.direction??Ie.direction,bo.tabSize=t.tabSize??Ie.tabSize,bo.justify=e.justify;let n=Tu(e.runs,bo,"read");return yp.laid=n,yp.dx=e.x,yp.dy=e.y+Su(e.verticalAlign,e.height,n.bounds.height),yp}var bp={side:.5,above:1.5,below:1};function CE(e,t){let{laid:n,dx:r,dy:o}=gp(e),i=q.meanScaleOf(t),s=q.minScaleOf(t),a=e.runs.map(f=>f.stroke?Ks(f.stroke,i,s):0),l=1/0,u=1/0,c=-1/0,d=-1/0;for(let f of n.lines)for(let p of f.glyphs){let h=p.fontSize,m=a[p.run]??0,g=-bp.side*h-m,b=p.advance+bp.side*h+m,x=-bp.above*h-m,w=bp.below*h+m,[y,P]=go(p.rotate);for(let S=0;S<4;S++){let v=S===0||S===3?g:b,A=S<2?x:w,N=p.x+v*y-A*P,M=p.baselineY+v*P+A*y;N<l&&(l=N),N>c&&(c=N),M<u&&(u=M),M>d&&(d=M)}}return l===1/0?null:Pi(l+r,u+o,c+r,d+o,t)}var e5=4,Ti={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Si={minX:-1/0,minY:-1/0,maxX:1/0,maxY:1/0};function y0(e,t,n){let r=Ti;for(let o of e)if(r=r5(r,g0(o,t,n)),r===Si)break;return r}function g0(e,t,n){switch(e.kind){case"group":{let r=e.transform?q.multiply(t,e.transform):t,o=y0(e.children,r,n);return e.effects&&e.effects.length>0&&(o=n5(o,Os(e.effects)/n)),e.clip?b0(o,xp(e.clip,void 0,r)):o}case"path":case"image":case"sprites":return x0(e,t)??Si;case"text":return CE(e,t)??Ti;case"shader":return t5(e)??Si}}function t5(e){let t=An(e.program.id);if(!t||t.vert!==""||/\bgl_FragCoord\b/.test(t.frag)&&!/\bu_fragOrigin\b/.test(t.frag))return null;let{x:n,y:r,w:o,h:i}=e.bounds;return{minX:Math.min(n,n+o),minY:Math.min(r,r+i),maxX:Math.max(n,n+o),maxY:Math.max(r,r+i)}}function n5(e,t){return e===Ti||e===Si||t===0?e:Number.isFinite(t)?{minX:e.minX-t,minY:e.minY-t,maxX:e.maxX+t,maxY:e.maxY+t}:Si}function r5(e,t){return e===Ti||t===Si?t:t===Ti||e===Si?e:{minX:Math.min(e.minX,t.minX),minY:Math.min(e.minY,t.minY),maxX:Math.max(e.maxX,t.maxX),maxY:Math.max(e.maxY,t.maxY)}}function b0(e,t){if(!t||e===Ti)return e;let n={minX:Math.max(e.minX,t.minX),minY:Math.max(e.minY,t.minY),maxX:Math.min(e.maxX,t.maxX),maxY:Math.min(e.maxY,t.maxY)};return n.minX>n.maxX||n.minY>n.maxY?Ti:n}function x0(e,t){switch(e.kind){case"path":return xp(e.path,e.stroke,t);case"image":return Pi(e.x,e.y,e.x+e.w,e.y+e.h,t);case"sprites":return i5(e.sprites,t)}}function xp(e,t,n){let r,o,i,s;if(e.kind==="rect")r=Math.min(e.x,e.x+e.width),i=Math.max(e.x,e.x+e.width),o=Math.min(e.y,e.y+e.height),s=Math.max(e.y,e.y+e.height);else if(e.kind==="polygon"){let l=e.coords;if(l.length<2)return null;r=i=l[0],o=s=l[1];for(let c=2;c+1<l.length;c+=2){let d=l[c],f=l[c+1];d<r?r=d:d>i&&(i=d),f<o?o=f:f>s&&(s=f)}let u=e.origin;u&&(r+=u.x,i+=u.x,o+=u.y,s+=u.y)}else return null;let a=t?o5(t,n):0;return Pi(r-a,o-a,i+a,s+a,n)}function o5(e,t){return Ks(e,q.meanScaleOf(t),q.minScaleOf(t))}function Ks(e,t,n=t){let r=n>0?n:t,o=at(e.width??1,typeof e.width=="object"?r:t),i=hi(o,e.vertexWidths),s=Math.max(e.miterLimit??e5,Math.SQRT2),a=su(e);return Math.max(Math.abs(i)*s,a.world,Bt({px:a.px},r))}function i5(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let s=0;s+9<=e.length;s+=9){let a=e[s],l=e[s+1],u=a+e[s+2],c=l+e[s+3];n=Math.min(n,a,u),o=Math.max(o,a,u),r=Math.min(r,l,c),i=Math.max(i,l,c)}return n===1/0?null:Pi(n,r,o,i,t)}function Pi(e,t,n,r,o){let[i,s]=q.apply(o,e,t),[a,l]=q.apply(o,n,t),[u,c]=q.apply(o,n,r),[d,f]=q.apply(o,e,r);return{minX:Math.min(i,a,u,d),minY:Math.min(s,l,c,f),maxX:Math.max(i,a,u,d),maxY:Math.max(s,l,c,f)}}var kr=1;function P0(e,t,n,r){return OE(e,t,FE(n),r)}function OE(e,t,n,r){let o=null;for(let i=0;i<e.length;i++){let s=e[i],a=s5(s,t,n,r);if(a===s){o?.push(s);continue}o??=e.slice(0,i),a&&o.push(a)}return o??e}function s5(e,t,n,r){switch(e.kind){case"group":{if(Kn(e.composite))return e;if(e.effects&&e.effects.length>0)return w0(g0(e,t,r),n)?null:e;let o=e.transform?q.multiply(t,e.transform):t,i=OE(e.children,o,n,r);return i===e.children?e:i.length===0?null:{...e,children:i}}case"path":case"image":case"sprites":return w0(x0(e,t),n)?null:e;default:return e}}function T0(e,t,n){let r=Math.min(e.x,e.x+e.width),o=Math.max(e.x,e.x+e.width),i=Math.min(e.y,e.y+e.height),s=Math.max(e.y,e.y+e.height);return w0(Pi(r,i,o,s,t),FE(n))}function FE(e){return{minX:e.x-kr,minY:e.y-kr,maxX:e.x+e.width+kr,maxY:e.y+e.height+kr}}function w0(e,t){return e!==null&&(e.maxX<t.minX||e.minX>t.maxX||e.maxY<t.minY||e.minY>t.maxY)}function ku(e,t,n,r){let o=y0(e,t,r);for(let i of n)o=b0(o,xp(i.path,void 0,i.transform));return a5(o,r)}function a5(e,t){let n=Math.floor((e.minX-kr)*t),r=Math.floor((e.minY-kr)*t),o=Math.ceil((e.maxX+kr)*t),i=Math.ceil((e.maxY+kr)*t);return[n,r,o,i].some(Number.isNaN)?{x0:-1/0,y0:-1/0,x1:1/0,y1:1/0}:{x0:n,y0:r,x1:o,y1:i}}function ki(e,t){let n=Math.max(t.x,e.x0),r=Math.max(t.y,e.y0),o=Math.min(t.x+t.width,e.x1),i=Math.min(t.y+t.height,e.y1);return o<=n||i<=r?{x:0,y:0,width:0,height:0}:{x:n,y:r,width:o-n,height:i-r}}ee();function js(e,t,n,r){let o=e.gl,i=e.renderTarget??null;o.bindFramebuffer(o.FRAMEBUFFER,i?i.fbo:null),i?i.restore?i.restore():o.viewport(0,0,t,n):(e.restoreTargetRect?.(),r&&o.enable(o.SCISSOR_TEST))}function S0(e,t,n,r,o,i,s,a){let l=e.gl;l.useProgram(t.handle);let u=t.attribute("a_position"),c=t.attribute("a_uv");l.bindBuffer(l.ARRAY_BUFFER,e.quadVbo),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.quadIbo),u!==void 0&&u>=0&&(l.enableVertexAttribArray(u),l.vertexAttribPointer(u,2,l.FLOAT,!1,16,0)),c!==void 0&&c>=0&&(l.enableVertexAttribArray(c),l.vertexAttribPointer(c,2,l.FLOAT,!1,16,8)),l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,n);let d=t.uniform("u_source");d!==void 0&&l.uniform1i(d,0);let f=t.uniform("u_resolution");f!==void 0&&l.uniform2f(f,r,o);let p=t.uniform("u_texel");if(p!==void 0&&l.uniform2f(p,1/r,1/o),s){let h=t.uniform("u_alpha");h!==void 0&&l.uniform1f(h,s.alpha),vn(e,t,s.colorMatrix)}i&&Cb(l,t,a??"effect",i,e.textureCache,{value:1}),De(e,6,e.gl.UNSIGNED_SHORT),u!==void 0&&u>=0&&l.disableVertexAttribArray(u),c!==void 0&&c>=0&&l.disableVertexAttribArray(c),l.bindBuffer(l.ARRAY_BUFFER,null),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null)}function wp(e,t,n,r,o){let i=e.gl,s=e.deviceWidth,a=e.deviceHeight,l=e.renderTarget??null,[u,c]=(l?l.fragOrigin:e.fragOrigin)??[0,0];i.viewport(u+r.x,c+a-r.y-r.height,r.width,r.height),S0(e,t,n,r.width,r.height,void 0,o),l?l.restore?l.restore():i.viewport(0,0,s,a):e.restoreTargetRect?.()}function Pp(e,t){let n=q.screenToClip(e.width/t,e.height/t);return q.toUniform(q.translated(n,-e.x/t,-e.y/t))}function vu(e,t,n){return e.x>=0&&e.y>=0&&e.x+e.width<=t&&e.y+e.height<=n}var Tp=64;function l5(e,t,n,r,o,i,s){let a=e.effects&&e.effects.length>0?Os(e.effects):0;if(!Number.isFinite(a))return{x:0,y:0,width:r,height:o};if(Kn(e.composite)&&!mR(e.composite))return n;let l=Math.ceil(a),u={x:n.x-l,y:n.y-l,width:n.width+2*l,height:n.height+2*l},c=ku([{...e,clip:void 0}],t,[],i),d=ki(c,u);if(d.width===0||d.height===0)return null;let f=Math.min(s,Math.ceil(d.width/Tp)*Tp),p=Math.min(s,Math.ceil(d.height/Tp)*Tp),h=vu(d,r,o);return{x:h&&f<=r?Math.min(d.x,r-f):d.x,y:h&&p<=o?Math.min(d.y,o-p):d.y,width:f,height:p}}function LE(e,t,n,r,o,i){let s=e.gl,a=e.renderTarget??null,l=r/e.widthCss,u=l5(t,e.state.transform,a?.window??{x:0,y:0,width:r,height:o},r,o,l,e.imageCache.maxTextureSide);if(!u)return;sn(e);let c=e.clipDepth,d=e.clipStack,f=e.drawBatch.clip,p=e.projection,h=s.isEnabled(s.SCISSOR_TEST),m=n.acquire(u.width,u.height),g=e.state.pushIsolated({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix});e.clipDepth=0,e.clipStack=[],e.drawBatch.clip=null;let b=vu(u,r,o);e.projection=b?void 0:Pp(u,l);let x=()=>{b?s.viewport(-u.x,u.y+u.height-o,r,o):s.viewport(0,0,u.width,u.height),s.disable(s.SCISSOR_TEST)};e.renderTarget={fbo:m.fbo,restore:x,fragOrigin:[-u.x,u.y+u.height-o],window:u},s.bindFramebuffer(s.FRAMEBUFFER,m.fbo),x(),s.stencilMask(255),s.clear(s.COLOR_BUFFER_BIT|s.STENCIL_BUFFER_BIT);for(let y of t.children)i(e,y);ye(e),s.disable(s.BLEND),s.disable(s.STENCIL_TEST);for(let y of t.effects??[]){let P=e.ensureProgram?.(y.program.id)??null;if(!P){Mb(y.program.id,"(program)");continue}let S=n.acquire(u.width,u.height);s.bindFramebuffer(s.FRAMEBUFFER,S.fbo),s.viewport(0,0,u.width,u.height),s.clear(s.COLOR_BUFFER_BIT),S0(e,P,m.texture,u.width,u.height,y.uniforms,void 0,y.program.id),n.release(m),m=S}s.enable(s.BLEND),e.state.pop(),e.clipDepth=c,e.clipStack=d,e.drawBatch.clip=f,e.projection=p,e.renderTarget=a,js(e,r,o,h);let w=e.ensureProgram?.(Ef())??null;if(w){xt(e);let y=Kn(t.composite);y&&Rb(s,t.composite),wp(e,w,m.texture,u,g),y&&Rb(s,"source-over")}n.release(m)}var u5=new WeakMap,c5=new WeakMap;function k0(e,t){let n=t?u5:c5,r=n.get(e);if(r!==void 0)return r;let o=e.every(i=>d5(i,t));return n.set(e,o),o}function d5(e,t){switch(e.kind){case"group":return e.effects&&e.effects.length>0&&!Number.isFinite(Os(e.effects))?!1:k0(e.children,t);case"path":return Sp(e.fill?.paint,t)&&Sp(e.stroke?.paint,t);case"text":return e.runs.every(n=>Sp(n.fill?.paint,t,!0)&&Sp(n.stroke?.paint,t,!0));case"image":case"sprites":return!0;case"shader":return!1}}function Sp(e,t,n=!1){if(!e||e.kind===void 0||e.kind==="solid")return!0;if(n&&e.kind==="texture")return!1;let r="units"in e?e.units:void 0;return r==="local"||r==="world"&&t}var f5={alpha:1,colorMatrix:Ht},_E=new WeakSet;function DE(e,t,n,r){let o=e.retained,i=e.deviceWidth,s=e.deviceHeight;if(!o||!i||!s)return!1;if(e.renderTarget!=null&&_E.has(e.renderTarget)||Kn(t.composite)||Ab(t.children))return o.decline(),!1;let l=t.retain;e.state.push({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix});let u=e.clipStack.map(({path:y,transform:P})=>({path:y,transform:P}));t.clip&&u.push({path:t.clip,transform:e.state.transform});let c={children:t.children,transform:e.state.transform,alpha:e.state.alpha,colorMatrix:e.state.colorMatrix,viewMatrix:e.viewMatrix,screenMatrix:e.screenMatrix,clips:u,effects:t.effects,isolate:t.isolate===!0,window:e.renderTarget?.window},d=!e.renderTarget,f=n?[{kind:"group",effects:t.effects,isolate:t.isolate,children:t.children}]:t.children,p=i/e.widthCss,h=d&&k0(f,e.viewMatrix!==void 0),m=o.lookup(l,i,s,c,d,h?p:void 0),g;if(m.kind==="through")return e.state.pop(),!1;if(m.kind==="kept")g=m.pixels;else{let y=c.window??m.window,P=ku(f,e.state.transform,u,p),S=o.reserve(l,i,s,ki(P,y),d,h?{box:P,window:y}:void 0);if(!S)return e.state.pop(),!1;ye(e),S.fbo&&p5(e,f,u,S.fbo,S,r),g=S.commit(c)}e.state.pop();let{texture:b,rect:x}=g;if(!b)return!0;ye(e);let w=e.ensureProgram?.(Ef())??null;return w&&(xt(e,0),wp(e,w,b,x,f5)),!0}function p5(e,t,n,r,o,i){let s=e.gl,a=e.deviceWidth,l=e.deviceHeight,{rect:u,tiles:c}=o,d=e.renderTarget??null,f=e.clipDepth,p=e.clipStack,h=e.drawBatch.clip,m=e.projection,g=s.isEnabled(s.SCISSOR_TEST),b=a/e.widthCss,x=vu(u,a,l);e.projection=x?void 0:Pp(u,b);let w=c.length>1?t.map(y=>ku([y],e.state.transform,[],b)):null;for(let y of c){let P=y.y+y.height,S=()=>{x?s.viewport(-y.x,P-l,a,l):s.viewport(u.x-y.x,P-u.y-u.height,u.width,u.height),s.scissor(0,0,y.width,y.height),s.enable(s.SCISSOR_TEST)},v={fbo:r,restore:S,fragOrigin:[-y.x,P-l],window:y};_E.add(v),e.renderTarget=v,e.clipDepth=0,e.clipStack=[],e.drawBatch.clip=null,s.bindFramebuffer(s.FRAMEBUFFER,r),S(),s.stencilMask(255),s.clear(s.COLOR_BUFFER_BIT|s.STENCIL_BUFFER_BIT);for(let A of n)Ql(e,A.path,A.transform);for(let A=0;A<t.length;A++)(!w||h5(w[A],y))&&i(e,t[A]);ye(e),o.resolve(y)}e.clipDepth=f,e.clipStack=p,e.drawBatch.clip=h,e.projection=m,e.renderTarget=d,js(e,a,l,g)}function h5(e,t){return e.x0<t.x+t.width&&e.x1>t.x&&e.y0<t.y+t.height&&e.y1>t.y}Pe();var $s=bt(),Ru=$s.reflection;function HE(e){if(e.inPoseFrame===void 0!=(e.toBoundsFrame===void 0)){let t=e.inPoseFrame===void 0?"inPoseFrame":"toBoundsFrame";throw new Error(`weasel registerPaintKind: kind "${e.id}" is missing ${t}. A kind that converts one frame direction and not the other drifts on the next resize; supply both or neither.`)}for(let[t,n]of Object.entries(e.programs??{})){let r=An(t);(!r||r.vert!==n.vert||r.frag!==n.frag)&&If(t,n.vert,n.frag)}return $s.push(e.id,e)}function vi(e){let t=e??"solid",n=$s.get(t);return!n&&Au.has(t)&&GE(t).catch(()=>{}),n}var Au=new Map,BE=new Map;function GE(e){let t=BE.get(e);if(t)return t;let r=Au.get(e)().then(o=>{if(o.id!==e)throw new Error(`weasel: the loader for paint kind "${e}" resolved to "${o.id}".`);$s.has(e)||HE(o)}).catch(o=>{throw console.error(`weasel: paint kind "${e}" failed to load:`,o),o});return BE.set(e,r),r}function v0(e){return $s.has(e)||Au.has(e)}function A0(e){let t=e??[...Au.keys()],n=[];for(let r of t)if(!$s.has(r)){if(!Au.has(r))return Promise.reject(new Error(`weasel warmPaintKinds: "${r}" is neither registered nor loadable.`));n.push(GE(r))}return Promise.all(n).then(()=>{})}var R0=8,m5=1/8;function kp(e,t){if(!(e>0)||!(t>0)||!Number.isFinite(t))return t;let n=Math.ceil(Math.LN2/(2*Math.log1p(m5/e)));return 2**(Math.round(Math.log2(t)*n)/n)}var UE=new WeakMap;function y5(e,t,n){let r=at(e.width??1,1),o=_s(e,r),i=n.ribbon?.metric;return[r,e.cap??"butt",e.join??"miter",e.miterLimit??"",e.align??"center",(e.dash??[]).join(","),e.varyingWidthJoinThreshold??"",e.nib?`${e.nib.angle}:${e.nib.ratio}`:"",t??"",o.start,o.end,co(i),co(n.start?.metric),co(n.end?.metric)].join("|")}function vp(e,t,n,r={}){let o=UE.get(e);o===void 0&&(o=new Map,UE.set(e,o));let i=y5(t,n,r),s=o.get(i);if(s!==void 0&&s.vertexWidths===t.vertexWidths)return s.mesh;let a=at(t.width??1,1),l=_s(t,a),u=mi(e,t,{flattenTolerance:n,startInset:VE(l.start,r.start,r.ribbon),endInset:VE(l.end,r.end,r.ribbon),metric:r.ribbon?.metric});return s===void 0&&o.size>=R0&&o.clear(),o.set(i,{mesh:u,vertexWidths:t.vertexWidths}),u}function VE(e,t,n){return t?.metric===n?.metric?e:{length:e,metric:t?.metric??null}}var g5={};function Nu(e,t,n={}){let r=n.quantize===!1?(m,g)=>g:kp,o=t.stroke,{markerStart:i,markerMid:s,markerEnd:a}=o;if(typeof o.width!="object"&&!Ys(i)&&!Ys(s)&&!Ys(a))return{cmd:t,spaces:g5};let l={...o},{scale:u,metric:c}=eu(e[0],e[1],e[3],e[4]),d=m=>c===null?void 0:{metric:c,pxPerUnit:m},f;if(typeof o.width=="object"){let m=r(o.width.px,u);l.width=at(o.width,m),o.dash&&m>0&&(l.dash=o.dash.map(g=>g/m)),f=d(m)}let p=m=>{if(m===void 0||typeof m=="string"||m.size===void 0)return f;if(typeof m.size!="number")return d(r(m.size.px,u))},h={ribbon:f,start:p(i),mid:p(s),end:p(a)};return Ys(i)&&(l.markerStart=N0(i,u,r)),Ys(s)&&(l.markerMid=N0(s,u,r)),Ys(a)&&(l.markerEnd=N0(a,u,r)),{cmd:{...t,stroke:l},spaces:h}}function Ys(e){return typeof e=="object"&&typeof e.size=="object"}function N0(e,t,n){return{...e,size:Ls(e,0,n(e.size.px,t))}}ee();Pe();function WE(e,t){if(!w5(e))return vi(e.kind)?.inPoseFrame?.(e,t)??e;if(b5(e)){let r=e.origin??{x:0,y:0};return{...e,origin:{x:t.x+r.x,y:t.y+r.y},units:"local"}}if(!x5(e))return e;let n=r=>({x:t.x+r.x*t.width,y:t.y+r.y*t.height});if(e.kind==="linear-gradient")return{...e,from:n(e.from),to:n(e.to),units:"local"};if(e.kind==="radial-gradient"){let r=Math.hypot(t.width,t.height)/Math.SQRT2;return{...e,center:n(e.center),radius:e.radius*r,units:"local"}}return{...e,center:n(e.center),units:"local"}}function b5(e){return Xd(e)&&e.units==="bounds"}function x5(e){if(e===void 0)return!1;let t=e.kind;return t!=="linear-gradient"&&t!=="radial-gradient"&&t!=="conic-gradient"?!1:e.units==="bounds"}function w5(e){let t=e.kind??"solid";return t==="solid"||Xd(e)||t==="linear-gradient"||t==="radial-gradient"||t==="conic-gradient"}Pe();function zE(e){let t;try{t=new OffscreenCanvas(e.size,e.size)}catch{if(typeof document>"u")return null;let r=document.createElement("canvas");r.width=e.size,r.height=e.size,t=r}let n=t.getContext("2d");return!n||(e.draw(n,e.size),typeof t.transferToImageBitmap!="function")?null:t.transferToImageBitmap()}var P5=4096*4096,T5=4,S5=300,k5=150,v5=256*1024*1024,Rt=new Map,KE=v5,E0=0,jE=0,A5=Me(),Ap=new Map;function M0(e){return/^data:image\/svg\+xml[;,]/i.test(e)?!0:/^(data|blob):/i.test(e)?!1:/\.svgz?$/i.test(e.replace(/[?#].*$/,""))}function R5(){if(typeof Image>"u"||typeof createImageBitmap>"u")throw new Error("weasel imageCache: no DOM image loader in this environment")}async function YE(e){let t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}function N5(e){let t=Ap.get(e);return t||(t=YE(e),Ap.set(e,t),t.catch(()=>Ap.delete(e))),t}async function I5(e,t){let n=await N5(e),r=t?.width??(n.naturalWidth||S5),o=t?.height??(n.naturalHeight||k5),i=typeof OffscreenCanvas<"u"?new OffscreenCanvas(r,o):Object.assign(document.createElement("canvas"),{width:r,height:o}),s=i.getContext("2d");if(!s)throw new Error("weasel imageCache: no 2D context to rasterize an SVG");return s.drawImage(n,0,0,r,o),createImageBitmap(i)}var E5=async(e,t)=>(R5(),M0(e)?I5(e,t):createImageBitmap(await YE(e))),qE=E5;function I0(){A5.emit()}var $E=e=>e?e.width*e.height*4:0;function XE(e){let t=0;for(let n of Rt.values())t+=$E(n.bitmap);if(t>KE){let n=[...Rt].filter(([r,o])=>r!==e&&o.bitmap!==void 0&&o.readAt<=jE&&!vA(o.bitmap));n.sort((r,o)=>r[1].readAt-o[1].readAt);for(let[r,o]of n){if(t<=KE)break;t-=$E(o.bitmap),ZE(r)}}jE=E0}function M5(e){let t={status:"loading",readAt:++E0};Rt.set(e,t),qE(e).then(n=>{Rt.get(e)===t&&(Rt.set(e,{status:"ready",bitmap:n,readAt:t.readAt,...M0(e)?{vector:{natural:{width:n.width,height:n.height},scale:1,failed:new Set,floor:0}}:{}}),XE(e),I0())},()=>{Rt.get(e)===t&&(Rt.set(e,{status:"error",readAt:t.readAt}),I0())})}function C5(e,t){let n=Math.max(t.width/e.width,t.height/e.height);if(!(n>0)||!Number.isFinite(n))return;let r=AA(),o=Math.min(r/e.width,r/e.height,Math.sqrt(P5/(e.width*e.height)));return Math.min(2**Math.ceil(Math.log2(n)),o)}function O5(e,t,n,r){if(n.pending!==void 0)return;let o=C5(n.natural,r);if(o===void 0)return;let i=o>n.scale;i&&n.shrunkTo===n.scale&&(n.floor=Math.max(n.floor,o));let s=i?o:Math.max(o,n.floor);if(!i&&s*T5>n.scale)return;for(let l of n.failed)if(s===l||i&&l>n.scale&&s>=l)return;n.pending=s;let a={width:Math.max(1,Math.round(n.natural.width*s)),height:Math.max(1,Math.round(n.natural.height*s))};qE(e,a).then(l=>{if(Rt.get(e)!==t)return;n.pending=void 0;let u=t.bitmap;t.bitmap=l,n.shrunkTo=i?void 0:s,n.scale=s,u&&u!==l&&$d(u),XE(e),I0()},()=>{Rt.get(e)===t&&(n.pending=void 0,n.failed.add(s))})}function Xs(e,t){if(e.startsWith(JE))return qs.get(e)?.deref();let n=Rt.get(e);if(!n){M5(e);return}return n.readAt=++E0,t&&n.vector&&O5(e,n,n.vector,t),n.bitmap}var JE="weasel-bitmap:",qs=new Map,F5=new WeakMap;var L5=new FinalizationRegistry(e=>{qs.get(e)?.deref()===void 0&&qs.delete(e)});function QE(e){let t=Rt.get(e);if(t?.vector)return t.vector.natural;let n=t?.bitmap??qs.get(e)?.deref();return n?{width:n.width,height:n.height}:void 0}function C0(e){return e.startsWith(JE)?Xs(e)===void 0?"idle":"ready":Rt.get(e)?.status??"idle"}function ZE(e){let t=qs.get(e)?.deref();qs.delete(e),t!==void 0&&(F5.delete(t),L5.unregister(t),$d(t));let n=Rt.get(e);Rt.delete(e),Ap.delete(e),n?.bitmap&&$d(n.bitmap)}var O0="image:";function tM(e){return{id:O0+e.src}}function eM(e){let t=e.slice(O0.length),n=Xs(t),r=si.get(e)?.source;n!==r&&(n?Kd(e,n,QE(t)):jd({id:e}))}zd(O0,{revive:eM,touched:eM});function F0(e){if(e.size!==void 0)return e.size;switch(e.kind){case"hatch":return 5;case"crosshatch":return 6;case"dots":return 6;case"chunks":return 48;default:return 8}}function _5(e){let t=e|0;return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function rM(e){let t=F0(e),{color:n}=e;switch(e.kind){case"hatch":{let r=e.lineWidth??1;return{size:t,shapes:nM(t,r,n)}}case"crosshatch":{let r=e.lineWidth??.8;return{size:t,shapes:[...nM(t,r,n),...D5(t,r,n)]}}case"dots":{let r=e.radius??1;return{size:t,shapes:[{kind:"circle",cx:t/2,cy:t/2,r,color:n}]}}case"chunks":{let r=e.density??.35,o=e.chunkSize??3,i=_5(e.seed??42),s=Math.round(t*t*r/(o*o)),a=[];e.bg!==void 0&&a.push({kind:"rect",x:0,y:0,width:t,height:t,color:e.bg});for(let l=0;l<s;l++){let u=i()*t,c=i()*t,d=o*(.5+i()),f=o*(.5+i()),p=i()*Math.PI;a.push({kind:"ellipse",cx:u,cy:c,rx:d/2,ry:f/2,rotation:p,color:n})}return{size:t,shapes:a}}default:return{size:t,shapes:[]}}}function nM(e,t,n){return[{kind:"line",x1:-1,y1:e+1,x2:e+1,y2:-1,width:t,color:n},{kind:"line",x1:-1,y1:1,x2:1,y2:-1,width:t,color:n},{kind:"line",x1:e-1,y1:e+1,x2:e+1,y2:e-1,width:t,color:n}]}function D5(e,t,n){return[{kind:"line",x1:-1,y1:-1,x2:e+1,y2:e+1,width:t,color:n},{kind:"line",x1:e-1,y1:-1,x2:e+1,y2:1,width:t,color:n},{kind:"line",x1:-1,y1:e-1,x2:1,y2:e+1,width:t,color:n}]}function oM(e,t){for(let n of t.shapes){if(n.kind==="line"){e.strokeStyle=n.color,e.lineWidth=n.width,e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.stroke();continue}if(e.fillStyle=n.color,n.kind==="rect"){e.fillRect(n.x,n.y,n.width,n.height);continue}e.beginPath(),n.kind==="circle"?e.arc(n.cx,n.cy,n.r,0,Math.PI*2):e.ellipse(n.cx,n.cy,n.rx,n.ry,n.rotation,0,Math.PI*2),e.fill()}}var B5=256,L0="pattern:",vr=new Map;function H5(e){let t=e,n={};for(let r of Object.keys(t).sort())n[r]=t[r];return L0+JSON.stringify(n)}function G5(e){let t=tb(e),n=H5(t),r=vr.get(n);return r!==void 0?(iM(n),r):sM(n,t)}function iM(e){let t=vr.get(e);t!==void 0&&(vr.delete(e),vr.set(e,t))}function sM(e,t){let n=Ol(t.kind)?zE({size:F0(t),draw:o=>oM(o,rM(t))}):null,r=n?Kd(e,n):null;for(vr.delete(e),vr.set(e,r);vr.size>B5;)U5(vr.keys().next().value);return r}function U5(e){vr.delete(e);let t=si.get(e)?.source;jd({id:e}),t&&"close"in t&&t.close()}function V5(e){let t;try{t=JSON.parse(e.slice(L0.length))}catch{return}typeof t!="object"||t===null||!("kind"in t)||sM(e,t)}zd(L0,{revive:V5,touched:iM});function aM(e){if(eb(e)){let{width:n,height:r}=e;return{kind:"texture",texture:tM(e),...n!==void 0?{width:n}:{},...r!==void 0?{height:r}:{},...Jd(e)}}if(!Zg(e))return e;let t=G5(e);return t?{kind:"texture",texture:t,...Jd(e)}:null}function Ai(e,t){return aM(WE(e,t))}function Ut(e,t){if(e.paint==null)return null;let n=Ai(e.paint,t);return n===null?null:n===e.paint?e:{...e,paint:n}}function Ri(e,t){if(e.paint==null)return null;let n=Ai(e.paint,t);return n===null?null:n===e.paint?e:{...e,paint:n}}function lM(e,t,n,r){let o=e??n;if(o!=="none")return o==="line"?t.paint:Ai(o,et(r))??void 0}function _0(e,t){let n=[];for(let{entry:r,path:o,size:i,space:s}of e){let a=lM(r.fill,t,"line",o),l=r.outline?r.outline.width*i:0,u=r.outline?{paint:lM(r.outline.paint,t,"line",o),width:s?{px:l*s.pxPerUnit}:l}:null;a===void 0&&(u===null||u.paint===void 0)||n.push({kind:"path",path:o,...a?{fill:{paint:a}}:{},...u&&u.paint?{stroke:{paint:u.paint,width:u.width,cap:"round",join:"round"}}:{}})}return n}var uM=new WeakMap,cM=new WeakMap,D0=e=>e===void 0?"":typeof e=="string"?e:`${e.key}@${String(e.size??"")}`;function W5(e){let t="";for(let n of[e.markerStart,e.markerMid,e.markerEnd]){let r=n===void 0?void 0:fo(yi(n));if(r===void 0){t+="/";continue}let o=Df(r,e);if(o===null)return null;t+=`${o}/`}return t}function z5(e,t,n){if(n!==null){let i=uM.get(e);return i===void 0&&uM.set(e,i=new Map),i}let r=cM.get(e);r===void 0&&cM.set(e,r=new WeakMap);let o=r.get(t);return o===void 0&&r.set(t,o=new Map),o}function dM(e,t,n,r,o,i={}){if(n.markerStart===void 0&&n.markerMid===void 0&&n.markerEnd===void 0)return[];let s=W5(n),a=z5(e,t,s),l=[r,o??"",ou(),D0(n.markerStart),D0(n.markerMid),D0(n.markerEnd),s??"",Zl(i.start),Zl(i.mid),Zl(i.end)].join("|"),u=a.get(l);if(u===void 0){let c=iu(e,n,r,o,i);u={heads:c,paint:n.paint,cmds:_0(c,n)},a.size>=R0&&a.clear(),a.set(l,u)}else u.paint!==n.paint&&(u.paint=n.paint,u.cmds=_0(u.heads,n));return u.cmds}ee();var fM=new WeakMap;function B0(e,t,n){let r=fM.get(e);r===void 0&&(r=new WeakMap,fM.set(e,r));let o=r.get(t);return o===void 0&&(o=gl(e,t,n),r.set(t,o)),o}function pM(e){if(e.path.kind!=="polygon")return e;let{path:t,anchorSources:n}=os(e.path);if(t===e.path)return e;let r={...e,path:t};if(n&&e.vertexColors&&(r.vertexColors=B0(e.vertexColors,n,4)),n&&e.stroke&&(e.stroke.vertexColors||e.stroke.vertexWidths)){let{vertexColors:o,vertexWidths:i}=e.stroke;r.stroke={...e.stroke,...o?{vertexColors:B0(o,n,4)}:{},...i?{vertexWidths:B0(i,n,1)}:{}}}return r}var K5=65536;function mM(e,t,n,r=K5){let o=q5(t,e.origin),i={verts:[],idx:[]},s={left:r},a=new Int32Array(o.count),l=[],u=e.vertices,c=e.indices,d=new Float32Array(6);for(let f=0;f<c.length;f+=3){for(let h=0;h<3;h++)d[h*2]=u[c[f+h]*2],d[h*2+1]=u[c[f+h]*2+1];if(Y5(o,d,f/3+1,a,l),!(n?j5(d,o,l,i,s):$5(d,o,l,i,s)))return null}return{vertices:new Float32Array(i.verts),indices:new Uint32Array(i.idx),...e.origin?{origin:e.origin}:{}}}function j5(e,t,n,r,o){for(let i of n){if(--o.left<0)return!1;let s=yM(e,3,t.planes,i);if(s===U0)continue;if(s===0)return G0(e,3,r),!0;let a=e,l=3;for(let u=0;u<3&&l>=3;u++)if((s&1<<u)!==0){if(--o.left<0)return!1;[a,l]=H0(a,l,t.planes,(i*3+u)*3,1)}G0(a,l,r)}return!0}function $5(e,t,n,r,o){let i=[[e,3]];for(let s of n){let a=[];for(let[l,u]of i){if(--o.left<0)return!1;let c=yM(l,u,t.planes,s);if(c===U0){a.push([l,u]);continue}let d=l,f=u;for(let p=0;p<3&&f>=3;p++){if((c&1<<p)===0)continue;if(o.left-=2,o.left<0)return!1;let h=(s*3+p)*3,[m,g]=H0(d,f,t.planes,h,-1);g>=3&&a.push([m,g]),[d,f]=H0(d,f,t.planes,h,1)}}if(i=a,i.length===0)return!0}for(let[s,a]of i)G0(s,a,r);return!0}var U0=-1;function yM(e,t,n,r){let o=0;for(let i=0;i<3;i++){let s=(r*3+i)*3,a=0;for(let l=0;l<t;l++)n[s]*e[l*2]+n[s+1]*e[l*2+1]+n[s+2]>=0&&a++;if(a===0)return U0;a<t&&(o|=1<<i)}return o}var Rp={buf:new Float32Array(16)};function H0(e,t,n,r,o){Rp.buf.length<(t+1)*2&&(Rp.buf=new Float32Array((t+1)*4));let i=$l(e,t,2,o*n[r],o*n[r+1],o*n[r+2],Rp.buf);return[Rp.buf.slice(0,i*2),i]}function G0(e,t,n){if(t<3)return;let r=n.verts.length/2;for(let o=0;o<t*2;o++)n.verts.push(e[o]);for(let o=1;o<t-1;o++)n.idx.push(r,r+o,r+o+1)}function Y5(e,t,n,r,o){o.length=0;let i=Math.min(t[0],t[2],t[4]),s=Math.max(t[0],t[2],t[4]),a=Math.min(t[1],t[3],t[5]),l=Math.max(t[1],t[3],t[5]),u=e.grid,c=Math.max(0,Math.floor((i-u.x0)/u.cell)),d=Math.min(u.cols-1,Math.floor((s-u.x0)/u.cell)),f=Math.max(0,Math.floor((a-u.y0)/u.cell)),p=Math.min(u.rows-1,Math.floor((l-u.y0)/u.cell)),h=e.boxes;for(let m=f;m<=p;m++)for(let g=c;g<=d;g++)for(let b of u.cells[m*u.cols+g])r[b]!==n&&(r[b]=n,!(h[b*4]>s||h[b*4+2]<i||h[b*4+1]>l||h[b*4+3]<a)&&o.push(b))}var hM=new WeakMap;function q5(e,t){let n=hM.get(e);if(n!==void 0&&n.origin===t)return n.tris;let r=X5(e,t);return hM.set(e,{origin:t,tris:r}),r}function X5(e,t){let n=(e.origin?.x??0)-(t?.x??0),r=(e.origin?.y??0)-(t?.y??0),o=e.vertices,i=e.indices,s=[],a=[],l=new Float64Array(6);for(let c=0;c<i.length;c+=3){for(let p=0;p<3;p++)l[p*2]=o[i[c+p]*2]+n,l[p*2+1]=o[i[c+p]*2+1]+r;let d=(l[2]-l[0])*(l[5]-l[1])-(l[4]-l[0])*(l[3]-l[1]);if(d===0)continue;let f=d>0?[0,1,2]:[0,2,1];for(let p=0;p<3;p++)J5(l,f[p],f[(p+1)%3],s);a.push(Math.min(l[0],l[2],l[4]),Math.min(l[1],l[3],l[5]),Math.max(l[0],l[2],l[4]),Math.max(l[1],l[3],l[5]))}let u=a.length/4;return{planes:new Float64Array(s),boxes:new Float64Array(a),count:u,grid:Q5(a,u)}}function J5(e,t,n,r){let o=e[n*2]<e[t*2]||e[n*2]===e[t*2]&&e[n*2+1]<e[t*2+1],[i,s]=o?[n,t]:[t,n],a=e[i*2],l=e[i*2+1],u=e[s*2],c=e[s*2+1],d=Math.hypot(u-a,c-l),f=-(c-l)/d,p=(u-a)/d,h=-(f*a+p*l),m=o?-1:1;r.push(m*f,m*p,m*h)}function Q5(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let d=0;d<t;d++)n=Math.min(n,e[d*4]),r=Math.min(r,e[d*4+1]),o=Math.max(o,e[d*4+2]),i=Math.max(i,e[d*4+3]);if(t===0)return{x0:0,y0:0,cell:1,cols:1,rows:1,cells:[[]]};let s=Math.min(64,Math.max(1,Math.ceil(Math.sqrt(t)))),a=Math.max(o-n,i-r,1e-6)/s,l=Math.max(1,Math.ceil((o-n)/a)),u=Math.max(1,Math.ceil((i-r)/a)),c=Array.from({length:l*u},()=>[]);for(let d=0;d<t;d++){let f=Math.min(l-1,Math.floor((e[d*4]-n)/a)),p=Math.min(l-1,Math.floor((e[d*4+2]-n)/a)),h=Math.min(u-1,Math.floor((e[d*4+1]-r)/a)),m=Math.min(u-1,Math.floor((e[d*4+3]-r)/a));for(let g=h;g<=m;g++)for(let b=f;b<=p;b++)c[g*l+b].push(d)}return{x0:n,y0:r,cell:a,cols:l,rows:u,cells:c}}var Z5=512,gM=new WeakMap;function xM(e,t,n){let r=gM.get(e);if(r!==void 0&&r.fill===t&&r.inner===n)return r.mesh;let o=t.requiresStencil?null:eK(e,t,n);return gM.set(e,{fill:t,inner:n,mesh:o}),o}function eK(e,t,n){let r=tK(t,e.origin);return r===null?mM(e,t,n):nK(e,r,n)}function tK(e,t){let n=e.vertices,r=(e.origin?.x??0)-(t?.x??0),o=(e.origin?.y??0)-(t?.y??0),i=[];for(let a=0;a<n.length;a+=2){let l=i.length,u=n[a]+r,c=n[a+1]+o;l>=2&&i[l-2]===u&&i[l-1]===c||i.push(u,c)}for(;i.length>=4&&i[0]===i[i.length-2]&&i[1]===i[i.length-1];)i.length-=2;let s=i.length/2;return s<3||e.indices.length!==(s-2)*3?null:Fb(i,Z5)}var Ar={a:new Float32Array(0),b:new Float32Array(0)};function nK(e,t,n){let r=t.length/3;Ar.a.length<(r+4)*2&&(Ar.a=new Float32Array((r+4)*2),Ar.b=new Float32Array((r+4)*2));let o=e.vertices,i=e.indices,s=[],a=[],l=[],u=new Float32Array(6);for(let c=0;c<i.length;c+=3){for(let f=0;f<3;f++)u[f*2]=o[i[c+f]*2],u[f*2+1]=o[i[c+f]*2+1];l.length=0;let d=!1;for(let f=0;f<t.length&&!d;f+=3){let p=0;for(let h=0;h<3;h++)t[f]*u[h*2]+t[f+1]*u[h*2+1]+t[f+2]>=0&&p++;p===0?d=!0:p<3&&l.push(f)}if(d){n||V0(u,3,s,a);continue}if(n)V0(Ar.a,bM(u,l,l.length,t,-1),s,a);else for(let f=0;f<l.length;f++)V0(Ar.a,bM(u,l,f,t,l[f]),s,a)}return{vertices:new Float32Array(s),indices:new Uint32Array(a),...e.origin?{origin:e.origin}:{}}}function bM(e,t,n,r,o){let i=Ar.a,s=Ar.b;i.set(e);let a=3;for(let l=0;l<=n&&a>=3&&!(l===n&&o<0);l++){let u=l===n?o:t[l],c=l===n?-1:1;a=$l(i,a,2,c*r[u],c*r[u+1],c*r[u+2],s);let d=i;i=s,s=d}return i!==Ar.a&&Ar.a.set(i.subarray(0,a*2)),a}function V0(e,t,n,r){if(t<3)return;let o=n.length/2;for(let i=0;i<t*2;i++)n.push(e[i]);for(let i=1;i<t-1;i++)r.push(o,o+i,o+i+1)}Pe();function W0(e,t,n,r){for(let o=0;o<e.textures.length;o++){let i=e.textures[o];if(!(i.kind!=="bitmap"||i.image!==t))return i.sampling===n&&i.mips===r?o+1:-1}return K0(e)}function z0(e){return e.ramps?xs:K0(e)<0?-1:xs}function Rr(e,t){for(let n=0;n<e.textures.length;n++){let r=e.textures[n];if(r.kind==="atlas"&&r.id===t)return n+1}return K0(e)}function K0(e){return e.textures.length+(e.ramps?1:0)+1<mt?e.textures.length+1:-1}function xo(e,t,n,r){return t.clipDepth===Wb(e)&&Bb(t.matrices,n,r)>=0&&rK(t,Rf(e))}function rK(e,t){return t===null||wM(e,t)!==void 0?!0:e.hullPlanes+t.count<=bs}function wM(e,t){let n=e.hulls;if(n!==void 0){for(let r=0;r<n.length;r++)if(n[r].set===t)return n[r]}}function wo(e){return e.batchState??={clipDepth:Wb(e),matrices:[],textures:[],ramps:!1,hullPlanes:0,areaGlyphs:!1},e.batchState}function Po(e,t,n){let r=Rf(e);if(r===null)return n;let o=wM(t,r);return o===void 0&&(o={set:r,start:t.hullPlanes},(t.hulls??=[]).push(o),t.hullPlanes+=r.count),Yv(n,o.start,r.count)}function To(e,t,n){let r=Bb(e.matrices,t,n);return r===e.matrices.length&&e.matrices.push({colorMatrix:t,alpha:n}),r}ee();ee();ee();function Np(e,t,n){let r=n??oK,o=cr([r[0],r[1],r[2],r[3],t.x,t.y]);if(!o)return null;let i=e;return q.fromAffine([o[0]*i[0]+o[2]*i[1],o[1]*i[0]+o[3]*i[1],o[0]*i[3]+o[2]*i[4],o[1]*i[3]+o[3]*i[4],o[0]*i[6]+o[2]*i[7]+o[4],o[1]*i[6]+o[3]*i[7]+o[5]])}var oK=[1,0,0,1];var iK=[0,0];function PM(e,t){let n=Ss(t.texture.id);if(!n)return;let r=Ni(e,t.units),o=r&&Np(r,t.origin??{x:0,y:0},t.transform);if(!o)return null;let i=q.multiply(o,e.state.transform),[s,a]=j0(t,n);return{kind:"pattern",id:t.texture.id,source:n.source,opacity:t.opacity??1,uv:{ux:i[0]/s,uy:i[3]/s,u0:i[6]/s,vx:i[1]/a,vy:i[4]/a,v0:i[7]/a}}}function j0(e,{source:t,size:n}){let r=e.width??n?.width??("naturalWidth"in t?t.naturalWidth:t.width),o=e.height??n?.height??("naturalHeight"in t?t.naturalHeight:t.height);return[r>0?r:1,o>0?o:1]}function TM(e,t,n){let r=Ms(e,!1),o=e.batchState;o!==void 0&&(!xo(e,o,r.colorMatrix,r.alpha)||Rr(o,t.id)<0||Rr(o,t.id)<=o.textures.length&&e.textureCache.replaces(t.id,t.source))&&ye(e),e.drawBatch.wouldOverflow(n)&&ye(e),e.textureCache.uploadRegistered(t.id,t.source,"repeat");let i=wo(e),s=Rr(i,t.id);return s>i.textures.length&&(i.textures.push({kind:"atlas",id:t.id,fieldScale:iK}),s=i.textures.length),r.slot=Po(e,i,so(s,To(i,r.colorMatrix,r.alpha))),r}function SM(e,t,n){return{...e,u0:e.u0-Math.floor(e.ux*t+e.uy*n+e.u0),v0:e.v0-Math.floor(e.vx*t+e.vy*n+e.v0)}}function $0(e,t,n){let{slot:r,tint:o}=TM(e,n,4);e.drawBatch.pushGradientRect(t.x,t.y,t.width,t.height,e.state.transform,SM(n.uv,t.x,t.y),n.opacity*o[3],r,ws,o[0],o[1],o[2],1)||on(e,t,n,$0)}function Y0(e,t,n){let{slot:r,tint:o}=TM(e,n,t.vertices.length>>1),i=t.vertices.length>0?{x:t.vertices[0]+(t.origin?.x??0),y:t.vertices[1]+(t.origin?.y??0)}:{x:0,y:0};e.drawBatch.pushGradientMesh(t,e.state.transform,SM(n.uv,i.x,i.y),n.opacity*o[3],r,ws,o[0],o[1],o[2],1)||on(e,t,n,Y0)}function Iu(e,t,n){if(n)return;let r=t.kind??"solid";if(r==="solid"){let s=t;return{kind:"solid",color:s.color,opacity:s.opacity}}if(r==="texture")return PM(e,t);if(r!=="linear-gradient"&&r!=="radial-gradient"&&r!=="conic-gradient")return;let o=t,i=sK(e,o.units);return i?o.kind==="linear-gradient"?q0(o,ri,aK(i,o)):o.kind==="radial-gradient"?q0(o,$v,lK(i,o)):q0(o,_d,uK(i,o)):null}function q0(e,t,n){return{kind:"ramp",stops:e.stops,space:e.interpolate??"rgb",opacity:e.opacity,mode:t,uv:n}}function sK(e,t){let n=Ni(e,t);return n&&q.multiply(n,e.state.transform)}function aK(e,t){let n=t.to.x-t.from.x,r=t.to.y-t.from.y,o=Math.hypot(n,r)||1,i=1/(o*o);return{ux:(e[0]*n+e[1]*r)*i,uy:(e[3]*n+e[4]*r)*i,u0:((e[6]-t.from.x)*n+(e[7]-t.from.y)*r)*i,vx:0,vy:0,v0:0}}function lK(e,t){let n=1/Math.max(t.radius,1e-4);return{ux:e[0]*n,uy:e[3]*n,u0:(e[6]-t.center.x)*n,vx:e[1]*n,vy:e[4]*n,v0:(e[7]-t.center.y)*n}}function uK(e,t){let n=Math.cos(t.angle),r=Math.sin(t.angle),o=e[6]-t.center.x,i=e[7]-t.center.y;return{ux:n*e[0]+r*e[1],uy:n*e[3]+r*e[4],u0:n*o+r*i,vx:n*e[1]-r*e[0],vy:n*e[4]-r*e[3],v0:n*i-r*o}}function X0(e,t){return e.mode===ri?{uv:{...e.uv,v0:t},post:1}:{uv:e.uv,post:t}}function Ni(e,t){return t==="local"?q.invert(e.state.transform):t==="world"&&e.viewMatrix?q.invert(e.viewMatrix):e.screenMatrix?q.invert(e.screenMatrix):q.identity()}function J0(e,t,n){let r=Ni(e,t);return!r||!n||n.x===0&&n.y===0?r:q.multiply(q.translated(q.identity(),-n.x,-n.y),r)}function kM(e,t){let n=Ni(e,t),r=n&&q.invert(n);if(!r)return null;let o=e.deviceWidth&&e.widthCss>0?e.deviceWidth/e.widthCss:1;return q.multiply(q.scaled(q.identity(),o,o),r)}var cK=96,dK=1024,vM={maxVertices:cK,maxVerticesInRun:dK};function Q0(e,t){if(t.requiresStencil)return!1;let n=e.drawBatch.length>0?vM.maxVerticesInRun:vM.maxVertices;return t.vertices.length>>1<=n}function Ip(e,t){let n=Xl(e);return Ep(e,t,n?Ht:e.state.colorMatrix,n?1:e.state.alpha)}function Ep(e,t,n,r){let o=e.batchState;o!==void 0&&!xo(e,o,n,r)&&ye(e),e.drawBatch.wouldOverflow(t)&&ye(e);let i=wo(e),s=To(i,n,r);return oi(Po(e,i,so(zv,s)),ri)}function Z0(e,t,n,r){let o=Ms(e,!1),i=e.batchState;i!==void 0&&(!xo(e,i,o.colorMatrix,o.alpha)||W0(i,t,n,r)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let s=wo(e),a=W0(s,t,n,r);return a>s.textures.length&&(s.textures.push({kind:"bitmap",image:t,sampling:n,mips:r}),a=s.textures.length),o.slot=Po(e,s,so(a,To(s,o.colorMatrix,o.alpha))),o}function Eu(e,t,n,r){let o=Xl(e),i=o?Ht:e.state.colorMatrix,s=o?1:e.state.alpha,a=e.batchState;a!==void 0&&(!xo(e,a,i,s)||Rr(a,t)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let l=wo(e),u=Rr(l,t);return u>l.textures.length&&(l.textures.push({kind:"atlas",id:t,fieldScale:n}),u=l.textures.length),r&&(l.areaGlyphs=!0),Po(e,l,so(u,To(l,i,s)))}function AM(e,t,n,r){e.gradRamps.wouldReshape(t,n)&&ye(e);let o=Ms(e,!0),i=e.batchState;i!==void 0&&(!xo(e,i,o.colorMatrix,o.alpha)||z0(i)<0)&&ye(e),e.drawBatch.wouldOverflow(r)&&ye(e);let s=wo(e),a=z0(s);return s.ramps=!0,{slot:Po(e,s,so(a,To(s,o.colorMatrix,o.alpha))),tint:o.tint,rowV:e.gradRamps.rowV(e.gradRamps.upload(t,n))}}function Js(e){let[t,n,r,o]=zn(e.color);return[t,n,r,o*(e.opacity??1)]}var fK=[0,0,0,0];function RM(e,t){let n=zn(t.color);return Af(e,n[0],n[1],n[2],n[3]*(t.opacity??1),fK)}function ew(e,t,n){let r=Ip(e,4);e.drawBatch.pushRect(t.x,t.y,t.width,t.height,e.state.transform,RM(e,n),r)||on(e,t,n,ew)}function NM(e,t,n){let r=Ip(e,t.vertices.length>>1),[o,i,s,a]=RM(e,n);e.drawBatch.pushMesh(t,e.state.transform,o,i,s,a,r)||on(e,t,n,NM)}function tw(e,t,n){let{slot:r,tint:o,rowV:i}=AM(e,n.stops,n.space,4),{uv:s,post:a}=X0(n,i);e.drawBatch.pushGradientRect(t.x,t.y,t.width,t.height,e.state.transform,s,a,r,n.mode,o[0],o[1],o[2],(n.opacity??1)*o[3])||on(e,t,n,tw)}function IM(e,t,n){let{slot:r,tint:o,rowV:i}=AM(e,n.stops,n.space,t.vertices.length>>1),{uv:s,post:a}=X0(n,i);e.drawBatch.pushGradientMesh(t,e.state.transform,s,a,r,n.mode,o[0],o[1],o[2],(n.opacity??1)*o[3])||on(e,t,n,IM)}function Mu(e,t,n){return n!==void 0&&Q0(e,t)?(n.kind==="ramp"?IM(e,t,n):n.kind==="pattern"?Y0(e,t,n):NM(e,t,n),!0):(sn(e),!1)}var pK=[0,0];function nw(e,t){let n=Ms(e,!1),r=e.batchState;r!==void 0&&(!xo(e,r,n.colorMatrix,n.alpha)||Rr(r,t)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let o=wo(e),i=Rr(o,t);return i>o.textures.length&&(o.textures.push({kind:"atlas",id:t,fieldScale:pK}),i=o.textures.length),n.slot=Po(e,o,so(i,To(o,n.colorMatrix,n.alpha))),n}ee();function Mp(e){let t=EM.get(e);if(t)return t;let n={gl:e.gl,get alpha(){return e.state.alpha},program:r=>e.ensureProgram?.(r)??e.programRegistry.get(r)??null,setProjAndModel:r=>nt(e,r),spaceInverse:(r,o)=>J0(e,r,o),spaceToDevice:r=>kM(e,r),get maxTextureSize(){return e.imageCache.maxTextureSide},resources:e.paintResources??hK(e.gl),bindRamp:(r,o,i)=>{let s=e.gradRamps.upload(r,i);return e.gradRamps.bind(o),e.gradRamps.rowV(s)}};return EM.set(e,n),n}var EM=new WeakMap,MM=new WeakMap;function hK(e){let t=MM.get(e);return t||(t=Ya(),MM.set(e,t)),t}function Cp(e,t,n,r){let o=n.texture,i=Ss(o.id);if(!i)return Xt()&&!TA(o.id)&&console.warn(`weasel: pattern TextureHandle "${o.id}" not registered`),null;let s=Ni(e,n.units);if(!s)return null;let a=Np(s,n.origin??{x:0,y:0},n.transform);if(!a)return null;e.textureCache.uploadRegistered(o.id,i.source,"repeat");let l=e.gl;l.useProgram(t.handle),nt(e,t,r),vn(e,t);let[u,c]=j0(n,i);return a[6]-=Math.floor(a[6]/u)*u,a[7]-=Math.floor(a[7]/c)*c,l.uniformMatrix3fv(t.uniform("u_worldInv"),!1,q.toUniform(a)),l.uniform2f(t.uniform("u_tileSize"),u,c),e.textureCache.bind(o.id,0),l.uniform1i(t.uniform("u_sampler"),0),l.uniform1f(t.uniform("u_opacity"),n.opacity??1),wf(e,t,e.state.alpha),t}function Op(e,t,n,r){let o=J0(e,n.units,n.kind==="linear-gradient"?n.from:n.center);if(!o)return null;let i=e.gl,s=e.gradRamps.upload(n.stops,n.interpolate??"rgb");if(i.useProgram(t.handle),nt(e,t,r),i.uniformMatrix3fv(t.uniform("u_worldInv"),!1,q.toUniform(o)),vn(e,t),e.gradRamps.bind(0),i.uniform1i(t.uniform("u_ramp"),0),i.uniform1f(t.uniform("u_rampV"),e.gradRamps.rowV(s)),wf(e,t,e.state.alpha),i.uniform1f(t.uniform("u_opacity"),n.opacity??1),n.kind==="linear-gradient"){i.uniform1i(t.uniform("u_gradKind"),0);let a=n.to.x-n.from.x,l=n.to.y-n.from.y,u=Math.hypot(a,l)||1;i.uniform2f(t.uniform("u_gradDir"),a/u,l/u),i.uniform1f(t.uniform("u_gradLen"),u),i.uniform1f(t.uniform("u_gradRadius"),0),i.uniform1f(t.uniform("u_gradAngle"),0)}else n.kind==="radial-gradient"?(i.uniform1i(t.uniform("u_gradKind"),1),i.uniform2f(t.uniform("u_gradDir"),0,0),i.uniform1f(t.uniform("u_gradLen"),0),i.uniform1f(t.uniform("u_gradRadius"),n.radius),i.uniform1f(t.uniform("u_gradAngle"),0)):(i.uniform1i(t.uniform("u_gradKind"),2),i.uniform2f(t.uniform("u_gradDir"),0,0),i.uniform1f(t.uniform("u_gradLen"),0),i.uniform1f(t.uniform("u_gradRadius"),0),i.uniform1f(t.uniform("u_gradAngle"),n.angle));return t}function CM(e,t,n){let r=t.anchorA,o=t.anchorB,i=t.anchorT;if(!r||!o||!i){if(n===void 0)return Float32Array.from(e);let l=Math.min(n.length,e.length);for(let u=0;u<l;u++)n[u]=e[u];return n}let s=r.length,a=n??new Float32Array(s*4);for(let l=0;l<s;l++){let u=r[l]*4,c=o[l]*4,d=i[l];for(let f=0;f<4;f++)a[l*4+f]=e[u+f]+(e[c+f]-e[u+f])*d}return a}function Lp(e,t,n,r){let o=e.createBuffer();if(!o)throw new Error("attachVertexColors: createBuffer returned null");e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,CM(n,r),e.DYNAMIC_DRAW);let i=t.attribute("a_vertexColor");return i!==void 0&&(e.enableVertexAttribArray(i),e.vertexAttribPointer(i,4,e.FLOAT,!1,0,0)),{vbo:o,location:i}}function _p(e,{vbo:t,location:n}){n!==void 0&&e.disableVertexAttribArray(n),e.deleteBuffer(t)}var Fp=new Float32Array(256);function mK(e,t,n,r){for(let s=0;s<n*4;s++)t[s]*=r[s&3];if(!Xl(e))return!1;let o=e.state.colorMatrix,i=e.state.alpha;for(let s=0;s<n*4;s+=4){let a=t[s],l=t[s+1],u=t[s+2],c=t[s+3];for(let d=0;d<4;d++){let f=d*5,p=o[f]*a+o[f+1]*l+o[f+2]*u+o[f+3]*c+o[f+4];if(!(p>=0&&p<=1))return!1}}for(let s=0;s<n*4;s+=4){let a=t[s],l=t[s+1],u=t[s+2],c=t[s+3];t[s]=o[0]*a+o[1]*l+o[2]*u+o[3]*c+o[4],t[s+1]=o[5]*a+o[6]*l+o[7]*u+o[8]*c+o[9],t[s+2]=o[10]*a+o[11]*l+o[12]*u+o[13]*c+o[14],t[s+3]=(o[15]*a+o[16]*l+o[17]*u+o[18]*c+o[19])*i}return!0}function Dp(e){return e.kind===void 0||e.kind==="solid"?e:{color:"#ffffff",opacity:e.opacity}}function OM(e,t,n){let r=t.vertices.length>>1;Fp.length<r*4&&(Fp=new Float32Array(Math.max(r*4,Fp.length*2)));let o=CM(n.perAnchor,t,Fp),s=mK(e,o,r,Js(n.paint))?Ep(e,r,Ht,1):Ep(e,r,e.state.colorMatrix,e.state.alpha);e.drawBatch.pushMesh(t,e.state.transform,1,1,1,1,s,o)||on(e,t,n,OM)}function rw(e,t,n,r){let o=t.vertices.length>>1;return(t.anchorA!==void 0||n.length>=o*4)&&Q0(e,t)?(OM(e,t,{perAnchor:n,paint:r}),!0):(sn(e),!1)}function ow(e,t){let n=pM(t);n.fill?.paint&&yK(e,n,n.fill.paint),n.stroke?.paint&&TK(e,n)}function yK(e,t,n){let r=n.kind===void 0||n.kind==="solid",o=!!(t.vertexColors&&t.vertexColors.length>0),i=n,s=Iu(e,n,o);if(s===null)return;if(s!==void 0&&t.path.kind==="rect"){s.kind==="ramp"?tw(e,t.path,s):s.kind==="pattern"?$0(e,t.path,s):ew(e,t.path,s);return}let a=kf(e,t.path);if(r&&o?rw(e,a,t.vertexColors,i):Mu(e,a,s))return;let u=_b(e,a);Tf(e,a.origin,()=>{r&&o?gK(e,t,i,u):u.requiresStencil?PK(e,n,u):Bp(e,n,u)})}function gK(e,t,n,r){let o=e.gl,i=e.pathFillVColor;o.useProgram(i.handle),o.bindVertexArray(r.vao),nt(e,i),Is(e,i,n.color,n.opacity),vn(e,i);let s=Lp(o,i,t.vertexColors,r);r.requiresStencil?(Nb(e,r.indexCount),De(e,r.indexCount,e.gl.UNSIGNED_INT),Ib(e)):(xt(e),De(e,r.indexCount,e.gl.UNSIGNED_INT)),_p(o,s),o.bindVertexArray(null)}function iw(e,t){let n=t.kind??"solid";if(n==="solid")return bK(e,t);if(n==="texture")return xK(e,t);if(n==="linear-gradient"||n==="radial-gradient"||n==="conic-gradient")return wK(e,t);let r=vi(n)?.bind;return r?r(Mp(e),t):null}function Bp(e,t,n){if(!iw(e,t))return;let o=e.gl;o.bindVertexArray(n.vao),xt(e),De(e,n.indexCount,e.gl.UNSIGNED_INT),o.bindVertexArray(null)}function bK(e,t){let n=e.pathFill;return e.gl.useProgram(n.handle),nt(e,n),Is(e,n,t.color,t.opacity),vn(e,n),n}function xK(e,t){return Cp(e,e.patternFill,t,Pf(e))}function wK(e,t){return Op(e,e.gradFill,t,Pf(e))}function PK(e,t,n){let r=e.gl;r.useProgram(e.pathFill.handle),r.bindVertexArray(n.vao),nt(e,e.pathFill),Nb(e,n.indexCount),iw(e,t)&&De(e,n.indexCount,e.gl.UNSIGNED_INT),Ib(e),r.bindVertexArray(null)}function TK(e,t){let{cmd:n,spaces:r}=Nu(e.state.transform,t),o=n.stroke,i=o.align??"center",s=r.ribbon?.metric,a=n.path.kind==="polygon"||s!==void 0&&!Ff(s),l=a&&i!=="center"?kK(e,n,i,r):null;l!==null?LM(e,n,l):a&&i!=="center"?(sn(e),Tf(e,n.path.kind==="polygon"?n.path.origin:void 0,()=>RK(e,n,i,r))):SK(e,n,r);let u=at(o.width??1,1),c=dM(n.path,t.stroke,o,u,Es(e),r);for(let d of c)ow(e,d)}function SK(e,t,n){LM(e,t,vp(t.path,t.stroke,Es(e),n))}function kK(e,t,n,r){if(t.stroke.vertexColors&&t.stroke.vertexColors.length>0||e.batchVariants?.cuts===!1)return null;let o=vp(t.path,_M(t.stroke),Es(e),r);return xM(o,kf(e,t.path),n==="inner")}function LM(e,t,n){let r=t.stroke,o=r.paint;if(n.indices.length===0)return;let i=!!(r.vertexColors&&r.vertexColors.length>0),s=Iu(e,o,i);s===null||(i?rw(e,n,r.vertexColors,Dp(o)):Mu(e,n,s))||Tf(e,n.origin,()=>vK(e,r,n,i))}function vK(e,t,n,r){let o=t.paint,i=o.kind===void 0||o.kind==="solid",s=o,a=r?e.meshCache.uploadTransient(n):e.meshCache.uploadRecurring(n);if(!i&&!r){Bp(e,o,a);return}let l=e.gl;if(r){let u=e.pathFillVColor;l.useProgram(u.handle),l.bindVertexArray(a.vao),nt(e,u);let c=Dp(o);Is(e,u,c.color,c.opacity),vn(e,u);let d=Lp(l,u,t.vertexColors,a);xt(e),De(e,a.indexCount,e.gl.UNSIGNED_INT),_p(l,d),l.bindVertexArray(null);return}l.useProgram(e.pathFill.handle),l.bindVertexArray(a.vao),nt(e,e.pathFill),Is(e,e.pathFill,s.color,s.opacity),vn(e,e.pathFill),xt(e),De(e,a.indexCount,e.gl.UNSIGNED_INT),l.bindVertexArray(null)}var FM=new WeakMap;function AK(e){let t=FM.get(e);return t===void 0&&(t=e.map(n=>Fl(n,2)),FM.set(e,t)),t}function _M(e){return{...e,width:at(e.width??1,1)*2,...e.vertexWidths?{vertexWidths:AK(e.vertexWidths)}:{},align:"center"}}function RK(e,t,n,r){let o=t.stroke,i=o.paint,s=_M(o),a=!!(o.vertexColors&&o.vertexColors.length>0),l=Yl(e,t.path),u=vp(t.path,s,Es(e),r);if(u.indices.length===0)return;let c=a?e.meshCache.uploadTransient(u):e.meshCache.uploadRecurring(u),d=e.gl,f=a?e.pathFillVColor:e.pathFill;d.useProgram(f.handle),nt(e,f),d.enable(d.STENCIL_TEST),d.colorMask(!1,!1,!1,!1),d.stencilMask(1),d.stencilFunc(d.ALWAYS,1,1),d.stencilOp(d.KEEP,d.KEEP,l.requiresStencil?d.INVERT:d.REPLACE),d.bindVertexArray(l.vao),De(e,l.indexCount,e.gl.UNSIGNED_INT);let p=pi(e.clipDepth);d.colorMask(!0,!0,!0,!0),n==="inner"?d.stencilFunc(d.EQUAL,p|1,p|1):d.stencilFunc(d.EQUAL,p,p|1),d.stencilOp(d.KEEP,d.KEEP,d.KEEP);let h=f;if(a){let g=Dp(i);Is(e,f,g.color,g.opacity),vn(e,f)}else h=iw(e,i);if(!h){d.stencilMask(1),d.clear(d.STENCIL_BUFFER_BIT),d.disable(d.STENCIL_TEST),d.bindVertexArray(null);return}d.bindVertexArray(c.vao);let m=a?Lp(d,h,o.vertexColors,c):null;De(e,c.indexCount,e.gl.UNSIGNED_INT),d.stencilMask(1),d.clear(d.STENCIL_BUFFER_BIT),d.disable(d.STENCIL_TEST),m&&_p(d,m),d.bindVertexArray(null)}Pe();Pe();ee();var sw=1/4096,NK=2048,Hp=new Map;function DM(e,t){let n=Hp.get(e);if(n!==void 0)return n;Hp.size>=NK&&(Hp=new Map);let r=zl(Zo(t),{flattenTolerance:sw});return Hp.set(e,r),r}ee();var IK=2048,BM=1/1024,Gp=new Map;function HM(e){return Math.round(e/BM)*BM}function aw(e,t,n,r,o){if(!(n>0))return null;let i=[e,n,r.join??"miter",r.cap??"butt",r.miterLimit??"",r.align??"center",(r.dash??[]).join(","),co(o)].join("|"),s=Gp.get(i);if(s!==void 0)return s.indices.length===0?null:s;Gp.size>=IK&&(Gp=new Map);let a=mi(Zo(t),{...r,width:n},{flattenTolerance:sw,metric:o});return Gp.set(i,a),a.indices.length===0?null:a}function GM(e,t,n){return lw(e,t,n,r=>DM(r.key,r.d))}function UM(e,t,n,r){let o=e.stroke;if(!mr(o))return null;let i=o.width??1;if(typeof i=="object"){let s=VM(e),[a,l,u,c]=[r[0],r[1],r[3],r[4]];return lw(e,t,n,d=>{if(!(d.scale>0))return null;let f=d.scale,[p,h]=go(d.rotate),m=[p*f,h*f],g=[-(p*s+h)*f,(p-h*s)*f],b=eu(a*m[0]+u*m[1],l*m[0]+c*m[1],a*g[0]+u*g[1],l*g[0]+c*g[1]),x=kp(i.px,b.scale);if(!(x>0))return null;let w=o.dash?.map(y=>y/x);return aw(d.key,d.d,i.px/x,{...o,dash:w},b.metric??void 0)})}return lw(e,t,n,s=>s.scale>0?aw(s.key,s.d,HM(i/s.scale),{...o,dash:o.dash?.map(a=>a/s.scale)}):null)}var VM=e=>e.synthetic.italic?Math.tan(.2094):0;function lw(e,t,n,r){let o=[],i=0,s=0;for(let p of e.glyphs){let h=r(p);!h||h.indices.length===0||(o.push({mesh:h,glyph:p}),i+=h.vertices.length,s+=h.indices.length)}if(o.length===0)return null;let a=VM(e),l=new Float32Array(i),u=new Uint32Array(s),c=0,d=0,f=0;for(let{mesh:p,glyph:h}of o){let{x:m,baselineY:g,scale:b}=h,[x,w]=go(h.rotate);for(let y=0;y<p.vertices.length;y+=2){let P=p.vertices[y],S=p.vertices[y+1],v=(P-S*a)*b,A=S*b;l[c++]=m+t+v*x-A*w,l[c++]=g+n+v*w+A*x}for(let y=0;y<p.indices.length;y++)u[d++]=f+p.indices[y];f+=p.vertices.length/2}return{vertices:l,indices:u}}function WM(e,t,n,r,o,i){let s=e[t]+n,a=e[t+1]+r,l=e[t+2]+n,u=e[t+3]+r,c=e[t+8]+r,d=(c-a)*o,f=(c-u)*o;i[0]=s+d,i[1]=a,i[2]=l+d,i[3]=a,i[4]=l+f,i[5]=u,i[6]=s+f,i[7]=u;let p=e[t+10];if(!p)return;let[h,m]=go(p),g=e[t+9]+n;for(let b=0;b<8;b+=2){let x=i[b]-g,w=i[b+1]-c;i[b]=g+x*h-w*m,i[b+1]=c+x*m+w*h}}var Qs=new Array(11).fill(0);function Up(e,t,n,r,o,i,s,a){let l=a.xy;WM(e,t,n,r,o,l),zM(i,l);let u=a.uv;for(let b=0;b<4;b++)u[b]=e[t+4+b];if(s<=0)return;let c=Math.abs((l[2]-l[0])*(l[7]-l[1])-(l[3]-l[1])*(l[6]-l[0]));if(c===0)return;let d=e[t+2]-e[t],f=e[t+3]-e[t+1],p=s*d*Math.hypot(l[6]-l[0],l[7]-l[1])/c,h=s*f*Math.hypot(l[2]-l[0],l[3]-l[1])/c;for(let b=0;b<11;b++)Qs[b]=e[t+b];Qs[0]-=p,Qs[2]+=p,Qs[1]-=h,Qs[3]+=h;let m=(u[2]-u[0])*p/d,g=(u[3]-u[1])*h/f;u[0]-=m,u[2]+=m,u[1]-=g,u[3]+=g,WM(Qs,0,n,r,o,l),zM(i,l)}function zM(e,t){for(let n=0;n<8;n+=2){let r=t[n],o=t[n+1];t[n]=e[0]*r+e[3]*o+e[6],t[n+1]=e[1]*r+e[4]*o+e[7]}}Pe();ee();function Vp(e){let t=Math.hypot(e[0],e[1]),n=Math.hypot(e[3],e[4]);return Math.sqrt(t*n)||1}function KM(e,t,n,r){let o=t.fill?.paint;if(o===void 0||t.quads.length===0||!Wc(e.textureCache,t.page))return;let i=Dt(o)?Js(o)[3]:1,s=Gc(t.page),a=e.drawBatch,l=e.state.transform,u=e.deviceWidth&&e.widthCss?e.deviceWidth/e.widthCss:1,c=Vp(l)*u,d=s,{slot:f,tint:p}=nw(e,d),h=()=>{({slot:f,tint:p}=nw(e,d))};for(let m of t.quads){let g=EK(e,m,c),b=g?.quad??m,x=g?.atlasId??s;x!==d&&(d=x,h()),a.wouldOverflow(4)&&(ye(e),h());let w,y=b.rotate?q.multiply(l,q.fromAffine(Zr(b.penX+n,b.baselineY+r,b.rotate*Math.PI/180))):l;for(;!a.pushQuad(b.x0+n,b.y0+r,b.x1-b.x0,b.y1-b.y0,y,b.u0,b.v0,b.u1,b.v1,i*p[3],f,p[0],p[1],p[2]);)w=lo(e),h();w!==void 0&&(uo(e,w),h())}}function EK(e,t,n){let r=t.colorGlyph;if(!r||r.width===0)return null;let o=(t.x1-t.x0)/r.width,i=qc(r,o*n);if(!i||!zc(e.textureCache,i.glyph.page))return null;let s=i.glyph,a=2**i.level,l=t.x0+(s.xoffset-r.xoffset)*o,u=t.y0+(s.yoffset-r.yoffset)*o;return{quad:{x0:l,y0:u,x1:l+s.width/a*o,y1:u+s.height/a*o,u0:s.x/1024,v0:s.y/1024,u1:(s.x+s.width)/1024,v1:(s.y+s.height)/1024,baselineY:t.baselineY,penX:t.penX,rotate:t.rotate},atlasId:Uc(s.page)}}var jM={vertices:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])};function $M(e,t,n){let r=e.paintScratch,o=vi(t.kind)?.bind;if(!r||!o)return null;let i=e.deviceWidth&&e.widthCss>0?e.deviceWidth/e.widthCss:1,s=e.deviceWidth??Math.round(e.widthCss),a=e.deviceHeight??Math.round(e.heightCss),l=e.renderTarget?.window??{x:0,y:0,width:s,height:a},u=Math.max(l.x,Math.floor(n.x0*i)),c=Math.max(l.y,Math.floor(n.y0*i)),d=e.imageCache.maxTextureSide,f=Math.min(d,Math.min(l.x+l.width,Math.ceil(n.x1*i))-u),p=Math.min(d,Math.min(l.y+l.height,Math.ceil(n.y1*i))-c);if(!(f>0&&p>0))return null;let h=u/i,m=c/i,g=f/i,b=p/i,x=new Float32Array([g,0,0,0,b,0,h,m,1]),w=new Float32Array([2/g,0,0,0,2/b,0,-1-2*h/g,-1-2*m/b,1]),y=Mp(e),P={...y,alpha:e.state.alpha,maxTextureSize:y.maxTextureSize,setProjAndModel:M=>nt(e,M,x,w)},S=e.gl,v=r.acquire(f,p),A=S.isEnabled(S.SCISSOR_TEST);S.activeTexture(S.TEXTURE0),S.bindTexture(S.TEXTURE_2D,null),S.bindFramebuffer(S.FRAMEBUFFER,v.fbo),S.viewport(0,0,f,p),S.disable(S.SCISSOR_TEST),S.disable(S.STENCIL_TEST),S.clear(S.COLOR_BUFFER_BIT),S.disable(S.BLEND);let N=o(P,t);return N&&(S.bindVertexArray(e.meshCache.uploadRecurring(jM).vao),De(e,jM.indices.length,S.UNSIGNED_INT),S.bindVertexArray(null)),S.enable(S.BLEND),js(e,s,a,A),N?{texture:v.texture,uvFromScreen:new Float32Array([i/v.width,0,0,0,i/v.height,0,-u/v.width,-c/v.height,1])}:null}function YM(e,t,n){let r=e.gl;return r.useProgram(t.handle),nt(e,t,Cs),r.uniformMatrix3fv(t.uniform("u_worldInv"),!1,n.uvFromScreen),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.texture),r.uniform1i(t.uniform("u_sampler"),0),t}var Wp=48,qM={outlineMinSize:void 0};function JM(e,t){let n=e.textOutlineMinScreenSize??Wp,r=Number.isFinite(n)?n/Vp(e.state.transform):void 0,{laid:o,dx:i,dy:s}=gp(t);qM.outlineMinSize=r;let{groups:a,decorations:l}=c0(o,t.runs,qM,"read");if(!(a.length===0&&l.length===0)){for(let u of a)u.source==="outline"?MK(e,u,i,s):u.source==="color"?KM(e,u,i,s):FK(e,u,i,s);CK(e,l,i,s)}}function MK(e,t,n,r){let o=t.fill?.paint;if(o!==void 0){let a=GM(t,n,r);a&&dw(e,o,a)}let i=t.stroke?.paint;if(!i)return;let s=UM(t,n,r,e.state.transform);s&&dw(e,i,s)}function dw(e,t,n){let r=Iu(e,t,!1);r!==null&&(Mu(e,n,r)||Bp(e,t,e.meshCache.uploadTransient(n)))}function CK(e,t,n,r){for(let o of t){let i=o.fill.paint;if(i===void 0)continue;if(ZM(i)!==null){dw(e,i,OK(o.x0+n,o.y0+r,o.x1+n,o.y1+r));continue}let[s,a,l,u]=Dt(i)?Js(i):[0,0,0,1],c;for(;;){let d=Ip(e,4),f=Db(e,s,a,l,u);if(e.drawBatch.pushRect(o.x0+n,o.y0+r,o.x1-o.x0,o.y1-o.y0,e.state.transform,f,d))break;c=lo(e)}c!==void 0&&uo(e,c)}}function OK(e,t,n,r){return{vertices:new Float32Array([e,t,n,t,n,r,e,r]),indices:new Uint32Array([0,1,2,0,2,3])}}function QM(e,t,n,r){let o=(e.deviceWidth??e.widthCss)/(e.widthCss||1),i=Math.hypot(n[0],n[1])*o*(t[2]-t[0])/Math.abs(t[6]-t[4]),s=Math.hypot(n[3],n[4])*o*(t[3]-t[1])/Math.abs(t[7]-t[5]);return Fy(r,i,s)?id/o:0}function FK(e,t,n,r){if(t.source==="canvas"){if(!Vc(e.textureCache,t.page))return}else if(!Ry(t.family,t.weight,t.style,e.textureCache))return;if(t.quadData.length===0)return;let o=t.source==="canvas"?Hc(t.page):$i(t.family,t.weight,t.style),i=t.source==="canvas"?Oy:Cy,s=_y(t.source==="canvas"?"canvas":"atlas",t.family,t.weight,t.style);if(!s)return;let a=t.synthetic.bold?sl:0,l=t.synthetic.italic?Math.tan(.2094):0,u=t.fill?.paint;if(u===void 0)return;let c=ZM(u);if(c!==null){BK(e,t,n,r,c,o,i,a,l,s);return}let d=Dt(u)?zn(u.color):LK,f=Dt(u)?u.opacity??1:1,p=e.drawBatch,h=e.state.transform,m=QM(e,t.quadData,h,s),g=m>0,b=Eu(e,o,s,g),x=Af(e,d[0],d[1],d[2],d[3]*f,_K),w=t.quadData;for(let y=0;y<w.length;y+=Tr){p.wouldOverflow(4)&&(ye(e),b=Eu(e,o,s,g));let P;for(;!p.pushGlyph(w,y,n,r,l,h,x,b,i,a,m);)P=lo(e),b=Eu(e,o,s,g);P!==void 0&&(uo(e,P),b=Eu(e,o,s,g))}}var LK=[0,0,0,1],_K=[0,0,0,0];function ZM(e){let t=e.kind??"solid";return t==="texture"?"pattern":t==="linear-gradient"||t==="radial-gradient"||t==="conic-gradient"?"gradient":t==="solid"?null:"texture"}var cw=1,DK=[1,1,1,1];function BK(e,t,n,r,o,i,s,a,l,u){let c=e.glyphPaintProgram?.(o);if(!c)return;sn(e);let d=t.fill.paint,f=e.state.transform,p=QM(e,t.quadData,f,u),h;if(o==="pattern")h=Cp(e,c,d,Cs);else if(o==="gradient")h=Op(e,c,d,Cs);else{let w=$M(e,d,HK(t,n,r,l,f,p));h=w&&YM(e,c,w)}if(!h)return;let m=e.gl;e.textureCache.bind(i,cw),m.uniform1i(c.uniform("u_atlas"),cw),m.uniform1f(c.uniform("u_synthBold"),a),m.uniform2f(c.uniform("u_fieldScale"),u[0],u[1]),xt(e);let g=e.drawBatch,b=g.clip;g.clip=null;let x=t.quadData;for(let w=0;w<x.length;w+=Tr)g.wouldOverflow(4)&&XM(e),g.pushGlyph(x,w,n,r,l,f,DK,cw,s,0,p);XM(e),g.clip=b,m.activeTexture(m.TEXTURE0),m.bindVertexArray(null)}function XM(e){let t=e.drawBatch;t.length!==0&&(De(e,t.uploadAndBind(),e.gl.UNSIGNED_INT),t.reset())}function HK(e,t,n,r,o,i){let s={x0:1/0,y0:1/0,x1:-1/0,y1:-1/0},a=e.quadData,l={xy:[],uv:[]};for(let u=0;u<a.length;u+=Tr){Up(a,u,t,n,r,o,i,l);let c=l.xy;for(let d=0;d<8;d+=2)s.x0=Math.min(s.x0,c[d]),s.x1=Math.max(s.x1,c[d]),s.y0=Math.min(s.y0,c[d+1]),s.y1=Math.max(s.y1,c[d+1])}return s}var GK=2;function UK(e){let t=e.state.transform,n=e.deviceWidth&&e.widthCss?e.deviceWidth/e.widthCss:1,r=(GK*n)**2;return[r*(t[0]*t[0]+t[1]*t[1]),r*(t[3]*t[3]+t[4]*t[4])]}var VK=(e,t,n,r,o)=>t*t>=e[0]*r*r||n*n>=e[1]*o*o,WK=(e,t)=>!t||t.x<=0&&t.y<=0&&t.x+t.w>=e.width&&t.y+t.h>=e.height;function fw(e,t){e.imageCache.upload(t.image,t.image);let n=WK(t.image,t.source);n&&e.imageCache.lacksMipmaps(t.image)&&VK(UK(e),t.image.width,t.image.height,t.w,t.h)&&e.imageCache.buildMipmaps(t.image);let r=n&&e.imageCache.hasMipmaps(t.image),{slot:o,tint:i}=Z0(e,t.image,t.sampling??"linear",r),s=t.source,a=0,l=0,u=1,c=1;if(s){let d=t.image.width,f=t.image.height;a=s.x/d,u=(s.x+s.w)/d,l=s.y/f,c=(s.y+s.h)/f}if(t.flipX){let d=a;a=u,u=d}if(t.flipY){let d=l;l=c,c=d}e.drawBatch.pushQuad(t.x,t.y,t.w,t.h,e.state.transform,a,l,u,c,(t.opacity??1)*i[3],o,i[0],i[1],i[2])||on(e,t,void 0,fw)}function eC(e,t){let n=t.sprites,r=Math.floor(n.length/9);if(r===0)return;e.imageCache.upload(t.image,t.image);let o=t.sampling??"linear",i=()=>Z0(e,t.image,o,!1),{slot:s,tint:a}=i(),l=e.drawBatch,u=e.state.transform,c=t.image.width,d=t.image.height;for(let f=0,p=0;f<r;f++,p+=9){l.wouldOverflow(4)&&(ye(e),{slot:s,tint:a}=i());let h=n[p+4],m=n[p+5],g=n[p+6],b=n[p+7],x;for(;!l.pushQuad(n[p],n[p+1],n[p+2],n[p+3],u,h/c,m/d,(h+g)/c,(m+b)/d,n[p+8]*a[3],s,a[0],a[1],a[2]);)x=lo(e),{slot:s,tint:a}=i();x!==void 0&&(uo(e,x),{slot:s,tint:a}=i())}}function Ii(e,t){switch(t.kind){case"group":return zK(e,t);case"path":return ow(e,t);case"text":return JM(e,t);case"image":return fw(e,t);case"sprites":return eC(e,t);case"shader":return sn(e),TR(e,t)}}function tC(e){return e.isolate===!0||Kn(e.composite)||e.effects!==void 0&&e.effects.length>0}function zK(e,t){if(!(t.retain!==void 0&&DE(e,t,tC(t),Ii))){if(tC(t)&&e.effectTargets&&e.deviceWidth&&e.deviceHeight){if(t.clip){e.state.push({transform:t.transform});try{Ql(e,t.clip)}finally{e.state.pop()}}LE(e,t,e.effectTargets,e.deviceWidth,e.deviceHeight,Ii),t.clip&&Ub(e);return}if(e.state.push({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix}),t.clip)try{Ql(e,t.clip)}catch(n){throw e.state.pop(),n}for(let n of t.children)Ii(e,n);t.clip&&Ub(e),e.state.pop()}}var jn=10,oe=jn,KK=256,jK=384,pw=32;function So(e,t){let n=e;for(;n<t;)n*=2;return n}var zp=class{verts=new Float32Array(KK*oe);idx=new Uint32Array(jK);nVerts=0;nIdx=0;pureRects=!0;clip=null;polyIn=new Float32Array(pw*oe);polyOut=new Float32Array(pw*oe);polyTmp=new Float32Array(pw*oe);triangles=new Uint32Array(0);writeVertex(t,n,r,o,i,s,a,l,u,c,d){let f=this.verts;return f[t]=n,f[t+1]=r,f[t+2]=o,f[t+3]=i,f[t+4]=s,f[t+5]=a,f[t+6]=l,f[t+7]=u,f[t+8]=c,f[t+9]=d,t+oe}pushQuadIndices(){let t=this.nVerts,n=this.nIdx;this.idx[n++]=t,this.idx[n++]=t+1,this.idx[n++]=t+2,this.idx[n++]=t,this.idx[n++]=t+2,this.idx[n++]=t+3,this.nVerts+=4,this.nIdx+=6}reserve(t,n){let r=(this.nVerts+t)*oe;if(r>this.verts.length){let i=new Float32Array(So(this.verts.length,r));i.set(this.verts),this.verts=i}let o=this.nIdx+n;if(o>this.idx.length){let i=new Uint32Array(So(this.idx.length,o));i.set(this.idx),this.idx=i}}fitQuad(t,n){let r=this.clip;if(r===null)return!0;let o=this.verts,i=t*oe;if(gr(r,o[i],o[i+1])&&gr(r,o[i+oe],o[i+oe+1])&&gr(r,o[i+2*oe],o[i+2*oe+1])&&gr(r,o[i+3*oe],o[i+3*oe+1])||(this.nVerts=t,this.nIdx=n,Sf(r,o,i,4,oe)))return!0;if(!r.slanted){let s=o[i],a=o[i+1],l=o[i+oe],u=o[i+oe+1],c=o[i+2*oe],d=o[i+2*oe+1],f=o[i+3*oe],p=o[i+3*oe+1];if(!(a===u&&l===c&&d===p&&f===s||s===l&&u===d&&c===f&&p===a)||r.planes.length>0)return!1}return this.polyIn.set(o.subarray(i,i+4*oe)),this.appendFan(Lb(this.polyIn,4,oe,r,this.polyOut,this.polyTmp)),!0}fitMesh(t,n){let r=this.clip;if(r===null)return!0;let o=this.verts,i=!0;for(let u=t*oe;u<this.nVerts*oe&&i;u+=oe)i=gr(r,o[u],o[u+1]);if(i)return!0;let s=this.nIdx,a=Sf(r,o,t*oe,this.nVerts-t,oe);if(a||!r.slanted)return this.nVerts=t,this.nIdx=n,a;this.triangles.length<s-n&&(this.triangles=new Uint32Array(So(64,s-n)));let l=this.triangles;l.set(this.idx.subarray(n,s)),this.nIdx=n;for(let u=0;u<s-n;u+=3)this.fitTriangle(r,l[u],l[u+1],l[u+2]);return!0}fitTriangle(t,n,r,o){let i=this.verts;if(gr(t,i[n*oe],i[n*oe+1])&&gr(t,i[r*oe],i[r*oe+1])&&gr(t,i[o*oe],i[o*oe+1])){this.reserve(0,3),this.idx[this.nIdx++]=n,this.idx[this.nIdx++]=r,this.idx[this.nIdx++]=o;return}let s=this.polyIn;s.set(i.subarray(n*oe,n*oe+oe),0),s.set(i.subarray(r*oe,r*oe+oe),oe),s.set(i.subarray(o*oe,o*oe+oe),2*oe),!Sf(t,s,0,3,oe)&&this.appendFan(Lb(s,3,oe,t,this.polyOut,this.polyTmp))}appendFan(t){if(t<3)return;this.reserve(t,(t-2)*3),t!==4&&(this.pureRects=!1);let n=this.nVerts;this.verts.set(this.polyOut.subarray(0,t*oe),n*oe);let r=this.nIdx;for(let o=1;o<t-1;o++)this.idx[r++]=n,this.idx[r++]=n+o,this.idx[r++]=n+o+1;this.nVerts+=t,this.nIdx=r}};var $K=32768;var hw={xy:new Array(8).fill(0),uv:[0,0,0,0]},YK=[0,0,0,0],Cu=.5,Ou=.5,qK={ux:0,uy:0,u0:Cu,vx:0,vy:0,v0:Ou},XK=64,Nr=[{vertices:16,indices:24},{vertices:1024,indices:3072}],JK=Nr[Nr.length-1].vertices,nC=4;function QK(e){let t=new Uint32Array(e*6);for(let n=0;n<e;n++){let r=n*4,o=n*6;t[o]=r,t[o+1]=r+1,t[o+2]=r+2,t[o+3]=r,t[o+4]=r+2,t[o+5]=r+3}return t}var Fu=class extends zp{gl;aPos;aColor;aUv;aPost;aSlot;rings=Nr.map(()=>new Array(XK).fill(void 0));nextInRing=Nr.map(()=>0);largeRing=new Array(nC).fill(void 0);nextLarge=0;constructor(t,n){super();let r=n.attribute("a_position"),o=n.attribute("a_vertexColor"),i=n.attribute("a_uv"),s=n.attribute("a_post"),a=n.attribute("a_texSlot");if(r===void 0||o===void 0||i===void 0||s===void 0||a===void 0)throw new Error("DrawBatch: batch program is missing a_position / a_vertexColor / a_uv / a_post / a_texSlot");this.gl=t,this.aPos=r,this.aColor=o,this.aUv=i,this.aPost=s,this.aSlot=a}get length(){return this.nIdx}wouldOverflow(t){return this.nVerts+t>$K}pushRect(t,n,r,o,i,s,a){let l=s[0],u=s[1],c=s[2],d=s[3];this.reserve(4,6);let f=this.nVerts*jn,p=i[0],h=i[1],m=i[3],g=i[4],b=i[6],x=i[7],w=t+r,y=n+o,P=p*t+m*n+b,S=h*t+g*n+x,v=p*w+m*n+b,A=h*w+g*n+x,N=p*w+m*y+b,M=h*w+g*y+x,C=p*t+m*y+b,F=h*t+g*y+x;return f=this.writeVertex(f,P,S,l,u,c,d,Cu,Ou,1,a),f=this.writeVertex(f,v,A,l,u,c,d,Cu,Ou,1,a),f=this.writeVertex(f,N,M,l,u,c,d,Cu,Ou,1,a),this.writeVertex(f,C,F,l,u,c,d,Cu,Ou,1,a),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushQuad(t,n,r,o,i,s,a,l,u,c,d,f=1,p=1,h=1){this.reserve(4,6);let m=this.nVerts*jn,g=i[0],b=i[1],x=i[3],w=i[4],y=i[6],P=i[7],S=t+r,v=n+o,A=g*t+x*n+y,N=b*t+w*n+P,M=g*S+x*n+y,C=b*S+w*n+P,F=g*S+x*v+y,B=b*S+w*v+P,D=g*t+x*v+y,j=b*t+w*v+P,V=oi(d,ws);return m=this.writeVertex(m,A,N,f,p,h,1,s,a,c,V),m=this.writeVertex(m,M,C,f,p,h,1,l,a,c,V),m=this.writeVertex(m,F,B,f,p,h,1,l,u,c,V),this.writeVertex(m,D,j,f,p,h,1,s,u,c,V),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGlyph(t,n,r,o,i,s,a,l,u,c,d=0){this.reserve(4,6);let f=this.nVerts*jn;Up(t,n,r,o,i,s,d,hw);let p=hw.xy,h=hw.uv,m=a[0],g=a[1],b=a[2],x=a[3],w=oi(l,u),y=d>0?Wv:YK;return f=this.writeVertex(f,p[0],p[1],m,g,b,x,h[0],h[1],c+y[0],w),f=this.writeVertex(f,p[2],p[3],m,g,b,x,h[2],h[1],c+y[1],w),f=this.writeVertex(f,p[4],p[5],m,g,b,x,h[2],h[3],c+y[2],w),this.writeVertex(f,p[6],p[7],m,g,b,x,h[0],h[3],c+y[3],w),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGradientRect(t,n,r,o,i,s,a,l,u,c,d,f,p){this.reserve(4,6);let h=this.nVerts*jn,m=i[0],g=i[1],b=i[3],x=i[4],w=i[6],y=i[7],P=t+r,S=n+o,v=oi(l,u),A=(N,M)=>{let C=h;return h=this.writeVertex(C,m*N+b*M+w,g*N+x*M+y,c,d,f,p,s.ux*N+s.uy*M+s.u0,s.vx*N+s.vy*M+s.v0,a,v),h};return A(t,n),A(P,n),A(P,S),A(t,S),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGradientMesh(t,n,r,o,i,s,a,l,u,c,d){let f=t.vertices,p=t.indices,h=f.length>>1;this.reserve(h,p.length),this.pureRects=!1;let m=this.verts,g=this.nVerts*jn,b=n[0],x=n[1],w=n[3],y=n[4],P=n[6],S=n[7],v=oi(i,s),A=t.origin?.x??0,N=t.origin?.y??0;for(let B=0;B<h;B++){let D=f[B*2]+A,j=f[B*2+1]+N;if(m[g++]=b*D+w*j+P,m[g++]=x*D+y*j+S,d===void 0)m[g++]=a,m[g++]=l,m[g++]=u,m[g++]=c;else{let V=B*4;m[g++]=a*d[V],m[g++]=l*d[V+1],m[g++]=u*d[V+2],m[g++]=c*d[V+3]}m[g++]=r.ux*D+r.uy*j+r.u0,m[g++]=r.vx*D+r.vy*j+r.v0,m[g++]=o,m[g++]=v}let M=this.nVerts,C=this.idx,F=this.nIdx;for(let B=0;B<p.length;B++)C[F++]=M+p[B];return this.nVerts+=h,this.nIdx+=p.length,this.fitMesh(M,this.nIdx-p.length)}pushMesh(t,n,r,o,i,s,a,l){return this.pushGradientMesh(t,n,qK,1,a,ri,r,o,i,s,l)}uploadAndBind(){let t=this.gl,n=Nr.findIndex(o=>this.nVerts<=o.vertices&&this.nIdx<=o.indices),r=n<0?this.nextLargeSlot():this.nextRingSlot(n);if(t.bindVertexArray(r.vao),t.bindBuffer(t.ARRAY_BUFFER,r.vbo),t.bufferSubData(t.ARRAY_BUFFER,0,this.verts,0,this.nVerts*jn),!this.pureRects)t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,this.idx,0,this.nIdx),r.canonicalQuads=0;else if(r.canonicalQuads<this.nVerts>>2){let o=Math.min(r.vertexCapacity>>2,Math.floor(r.indexCapacity/6));t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,QK(o)),r.canonicalQuads=o}return this.nIdx}reset(){this.nVerts=0,this.nIdx=0,this.pureRects=!0}dispose(){for(let t of[...this.rings.flat(),...this.largeRing])t&&this.deleteSet(t);for(let t of this.rings)t.fill(void 0);this.largeRing.fill(void 0)}nextRingSlot(t){let n=this.rings[t],r=this.nextInRing[t];this.nextInRing[t]=(r+1)%n.length;let o=n[r];if(o)return o;let i=this.createSet(Nr[t].vertices,Nr[t].indices);return n[r]=i,i}nextLargeSlot(){let t=this.gl,n=this.nextLarge;this.nextLarge=(n+1)%nC;let r=this.largeRing[n];return r?(this.nVerts>r.vertexCapacity&&(r.vertexCapacity=So(r.vertexCapacity,this.nVerts),t.bindBuffer(t.ARRAY_BUFFER,r.vbo),t.bufferData(t.ARRAY_BUFFER,r.vertexCapacity*jn*4,t.DYNAMIC_DRAW)),this.nIdx>r.indexCapacity&&(r.indexCapacity=So(r.indexCapacity,this.nIdx),t.bindVertexArray(r.vao),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r.ibo),t.bufferData(t.ELEMENT_ARRAY_BUFFER,r.indexCapacity*4,t.DYNAMIC_DRAW),t.bindVertexArray(null),r.canonicalQuads=0),r):(r=this.createSet(So(JK,this.nVerts),So(Nr[Nr.length-1].indices,this.nIdx)),this.largeRing[n]=r,r)}createSet(t,n){let r=this.gl,o=r.createVertexArray(),i=r.createBuffer(),s=r.createBuffer();if(!o||!i||!s)throw new Error("DrawBatch: failed to create GL objects");let a=jn*4;return r.bindVertexArray(o),r.bindBuffer(r.ARRAY_BUFFER,i),r.bufferData(r.ARRAY_BUFFER,t*a,r.DYNAMIC_DRAW),r.enableVertexAttribArray(this.aPos),r.vertexAttribPointer(this.aPos,2,r.FLOAT,!1,a,0),r.enableVertexAttribArray(this.aColor),r.vertexAttribPointer(this.aColor,4,r.FLOAT,!1,a,8),r.enableVertexAttribArray(this.aUv),r.vertexAttribPointer(this.aUv,2,r.FLOAT,!1,a,24),r.enableVertexAttribArray(this.aPost),r.vertexAttribPointer(this.aPost,1,r.FLOAT,!1,a,32),r.enableVertexAttribArray(this.aSlot),r.vertexAttribPointer(this.aSlot,1,r.FLOAT,!1,a,36),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,s),r.bufferData(r.ELEMENT_ARRAY_BUFFER,n*4,r.DYNAMIC_DRAW),r.bindVertexArray(null),{vao:o,vbo:i,ibo:s,vertexCapacity:t,indexCapacity:n,canonicalQuads:0}}deleteSet(t){let n=this.gl;n.deleteBuffer(t.vbo),n.deleteBuffer(t.ibo),n.deleteVertexArray(t.vao)}};var rC=`#version 300 es
397
+ `;var ex="weasel:effect-composite";function Hf(){return Nn(ex)||Bf(ex,nN,rN),ex}function Gs(e){let t=0;for(let n of e){if(n.reach===void 0||!(n.reach>=0))return 1/0;t+=n.reach}return t}Z();Z();Pe();Z();Pe();Pe();function oN(e,t,n){return{pts:[e.x,e.y],a:[e.a],b:[e.b],t:[e.t],w:t?[e.w]:null,o:n?[e.o]:null}}function tx(e,t){e.pts.push(t.x,t.y),e.a.push(t.a),e.b.push(t.b),e.t.push(t.t),e.w?.push(t.w),e.o?.push(t.o)}function Gf(e,t=!1){let n={points:e.pts,closed:t,anchorA:new Uint32Array(e.a),anchorB:new Uint32Array(e.b),anchorT:new Float32Array(e.t)};return e.w&&(n.widths=new Float32Array(e.w)),e.o&&(n.offsets=new Float32Array(e.o)),n}function iN(e,t){let n=cf(t,EV(e));return n==="solid"?[...e]:n==="non-finite"?[]:e.flatMap(r=>MV(r,n))}function EV(e){return e.reduce((t,n)=>t+sN(n),0)}function sN(e){let t=e.points,n=t.length/2,r=0;for(let o=1;o<n;o++)r+=Math.hypot(t[o*2]-t[o*2-2],t[o*2+1]-t[o*2-1]);return e.closed&&n>1&&(r+=Math.hypot(t[0]-t[n*2-2],t[1]-t[n*2-1])),r}function MV(e,t){let n=cf(t,sN(e));if(n==="solid")return[e];if(n==="non-finite")return[];let r=[],o=e.points.length/2,i=e.anchorA??new Uint32Array(o),s=e.anchorB??new Uint32Array(o),a=e.anchorT??new Float32Array(o),l=e.widths,u=e.offsets,c=y=>({x:e.points[y*2],y:e.points[y*2+1],a:i[y],b:s[y],t:a[y],w:l?l[y]:0,o:u?u[y]:0}),d=0,f=n[0],p=!0,h=oN(c(0),!!l,!!u),m=y=>{h&&h.pts.length>=4&&r.push(Gf(h)),d=(d+1)%n.length,f=n[d],p=!p,h=p?oN(y,!!l,!!u):null},g=e.points[0],b=e.points[1],x=e.closed?o:o-1;for(let y=0;y<x;y++){let P=c(y),S=c((y+1)%o),v=Math.hypot(S.x-g,S.y-b);if(v<=1e-9){p&&h&&tx(h,S);continue}let A=v,N=0;for(;A>1e-9;)if(A<=f)p&&h&&tx(h,S),f-=A,g=S.x,b=S.y,A=0,f<=1e-9&&m(S);else{N+=f;let M=N/v,[C,F,B]=nu(P.a,P.b,P.t,S.a,S.b,S.t,M),D={x:P.x+(S.x-P.x)*M,y:P.y+(S.y-P.y)*M,a:C,b:F,t:B,w:P.w+(S.w-P.w)*M,o:P.o+(S.o-P.o)*M};p&&h&&tx(h,D),g=D.x,b=D.y,A=Math.hypot(S.x-g,S.y-b),m(D)}}let w=h;return w&&w.pts.length>=4&&CV(e,w,r),r}function CV(e,t,n){let r=t.pts[t.pts.length-2],o=t.pts[t.pts.length-1],i=(s,a)=>Math.hypot(r-s,o-a)<=1e-9;e.closed&&n.length>0&&i(n[0].points[0],n[0].points[1])?n[0]=OV(Gf(t),n[0]):e.closed&&n.length===0&&i(t.pts[0],t.pts[1])?n.push(Gf({pts:t.pts.slice(0,-2),a:t.a.slice(0,-1),b:t.b.slice(0,-1),t:t.t.slice(0,-1),w:t.w?t.w.slice(0,-1):null,o:t.o?t.o.slice(0,-1):null},!0)):n.push(Gf(t))}function OV(e,t){let n={points:[...e.points,...t.points.slice(2)],closed:!1,anchorA:Uint32Array.from([...e.anchorA,...t.anchorA.subarray(1)]),anchorB:Uint32Array.from([...e.anchorB,...t.anchorB.subarray(1)]),anchorT:Float32Array.from([...e.anchorT,...t.anchorT.subarray(1)])};return e.widths&&t.widths&&(n.widths=Float32Array.from([...e.widths,...t.widths.subarray(1)])),e.offsets&&t.offsets&&(n.offsets=Float32Array.from([...e.offsets,...t.offsets.subarray(1)])),n}Z();Pe();function FV(e){let t=Math.cos(e.angle),n=-Math.sin(e.angle),r=Math.min(1,Math.max(0,e.ratio));return(o,i)=>{let s=t*i-n*o,a=t*o+n*i;return Math.sqrt(s*s+r*r*a*a)}}function aN(e,t,n){let r=e.points.length/2;if(r<2)return;let o=e.points,i=FV(t),s=e.closed?r:r-1,a=[];for(let y=0;y<s;y++){let P=(y+1)%r,S=o[P*2]-o[y*2],v=o[P*2+1]-o[y*2+1],A=Math.hypot(S,v);a.push(A>0?i(S/A,v/A):NaN)}for(let y=0;y<s;y++)Number.isNaN(a[y])&&(a[y]=y>0?a[y-1]:a.find(P=>!Number.isNaN(P))??1);let l=e.anchorA,u=e.anchorB,c=e.anchorT,d=e.widths,f=e.offsets,p=[],h=[],m=[],g=[],b=[],x=[],w=(y,P)=>{p.push(o[y*2],o[y*2+1]),h.push(l?l[y]:0),m.push(u?u[y]:0),g.push(c?c[y]:0),b.push((d?d[y]:n)*P),f&&x.push(f[y]*P)};w(0,a[0]);for(let y=1;y<r;y++)w(y,a[y-1]),y<s&&w(y,a[y]);e.closed&&w(0,a[s-1]),e.points=p,e.anchorA=Uint32Array.from(h),e.anchorB=Uint32Array.from(m),e.anchorT=Float32Array.from(g),e.widths=Float32Array.from(b),f&&(e.offsets=Float32Array.from(x))}function lN(e,t,n,r){let o=e.points.length/2;if(o===0)return;let i=e.anchorA??new Uint32Array(o),s=e.anchorB??new Uint32Array(o),a=e.anchorT??new Float32Array(o),l=new Float32Array(o),u=new Float32Array(o),c=!1,d=n/2,f=1,p=h=>{let m=uf(t[h],NaN);return[Number.isNaN(m.left)?d:m.left*f,Number.isNaN(m.right)?d:m.right*f]};for(let h=0;h<o;h++){r&&(f=LV(e,h,r));let m=i[h],g=s[h],b=a[h],[x,w]=p(m);if(m!==g){let[y,P]=p(g);x+=(y-x)*b,w+=(P-w)*b}l[h]=x+w,u[h]=(w-x)/2,u[h]!==0&&(c=!0)}e.widths=l,c&&(e.offsets=u)}function Pi(e,t){return 2*fb(e,t)}function uN(e,t,n,r,o){t&&lN(e,t,r,o),n&&aN(e,n,r)}function LV(e,t,n){let r=e.points,o=r.length/2,i=0,s=0,a=(u,c)=>{let d=r[c*2]-r[u*2],f=r[c*2+1]-r[u*2+1],p=Math.hypot(d,f);p>0&&(i+=d/p,s+=f/p)};t>0?a(t-1,t):e.closed&&o>1&&a(o-1,0),t<o-1?a(t,t+1):e.closed&&o>1&&a(o-1,0);let l=Math.hypot(i,s);return l>0?n(i/l,s/l):1}function Uf(e,t,n){let r=e??mt,o=Pi(t,n);return o/2>r?{flattenTolerance:e,offset:o/2}:{flattenTolerance:e}}function cu(e){return e===void 0?"":`${mo(e.metric)}@${e.pxPerUnit}`}var cN=1e-9;function du(e,t,n,r){let o=Math.abs(e*r-t*n),i=Math.sqrt(o);if(!(o>0)||!Number.isFinite(o))return{scale:0,metric:null};let s=(e*e+t*t)/o,a=(e*n+t*r)/o,l=(n*n+r*r)/o,u=Math.sqrt(s+l+2),c=(s+1)/u,d=a/u,f=(l+1)/u;return Math.abs(d)<cN&&Math.abs(c-f)<cN?{scale:i,metric:null}:{scale:i,metric:{p:c,q:d,r:f}}}function mo(e){return e===void 0?"":`${e.p},${e.q},${e.r}`}function fu(e,t){let n=e.points;for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];n[r]=t.p*o+t.q*i,n[r+1]=t.q*o+t.r*i}}function nx(e,t){let n=e.points;for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];n[r]=t.r*o-t.q*i,n[r+1]=t.p*i-t.q*o}}function Wf(e,t){return e===t?!0:e!==null&&t!==null&&e.p===t.p&&e.q===t.q&&e.r===t.r}function rx(e,t,n){return Math.hypot(e.r*t-e.q*n,e.p*n-e.q*t)}function ox(e,t,n){return 1/Math.hypot(e.p*t+e.q*n,e.q*t+e.r*n)}function pu(e,t){for(let n=0;n<e.length;n+=2){let r=e[n],o=e[n+1];e[n]=t.r*r-t.q*o,e[n+1]=t.p*o-t.q*r}}function Vf(e){return e.q===0}function ix(e,t){return Vf(t)?{kind:"rect",x:t.p*e.x,y:t.r*e.y,width:t.p*e.width,height:t.r*e.height}:null}var dN=(e,t)=>e===void 0?{length:0,metric:t}:typeof e=="number"?{length:e,metric:t}:e;function fN(e,t,n,r,o){let i=dN(r,n),s=dN(o,n),a=e,l=t,u=c=>{a===null||Wf(l,c)||(l!==null&&nx(a,l),c!==null&&fu(a,c),l=c)};if(i.length>0||s.length>0)if(Wf(i.metric,s.metric))u(i.metric),a=vf(a,i.length,s.length);else for(let[c,d,f]of[[i.length,i.metric,!0],[s.length,s.metric,!1]])!(c>0)||a===null||(u(d),a=vf(a,f?c:0,f?0:c));return u(n),a}var _V=10*Math.PI/180;function ax(e,t,n,r,o,i,s,a,l,u,c,d,f,p,h){let m=r?1:-1,g=(e.bx-e.ax)/e.len*m,b=(e.by-e.ay)/e.len*m,x=(o+i)/2,w=(o-i)/2,y=(r?e.bx:e.ax)+e.nxUnit*w,P=(r?e.by:e.ay)+e.nyUnit*w,S=e.nxUnit*x,v=e.nyUnit*x;if(s==="square"){let A=y+g*x,N=P+b*x,M=a.length/2;a.push(A+S,N+v),u.push(f),c.push(p),d.push(h);let C=a.length/2;a.push(A-S,N-v),u.push(f),c.push(p),d.push(h),r?l.push(t,M,C,t,C,n):l.push(t,C,M,t,n,C);return}if(s==="round"){let A=a.length/2;a.push(y,P),u.push(f),c.push(p),d.push(h);let N=Math.atan2(v,S),M=r?-Math.PI:Math.PI,C=Math.max(1,Math.ceil(Math.abs(M)/_V)),F=M/C,B=t;for(let D=1;D<C;D++){let j=N+D*F,W=y+Math.cos(j)*x,J=P+Math.sin(j)*x,se=a.length/2;a.push(W,J),u.push(f),c.push(p),d.push(h),r?l.push(B,se,A):l.push(B,A,se),B=se}r?l.push(B,n,A):l.push(B,A,n)}}function lx(e,t,n,r,o,i,s,a){let l=n-e,u=r-t,c=Math.hypot(l,u);return c===0?null:{ax:e,ay:t,bx:n,by:r,nxUnit:-u/c,nyUnit:l/c,posA:o,negA:i,posB:s,negB:a,len:c}}function pN(e,t,n,r,o,i,s,a,l,u,c,d,f,p,h,m=-1){let g=e[n],b=e[(n+1)%e.length],x=t[n],w=t[(n+1)%e.length],y=g.bx-g.ax,P=g.by-g.ay,S=b.bx-b.ax,v=b.by-b.ay,A=y*v-P*S;if(A===0)return;let N=A>0,M=N?x+3:x+2,C=N?w+1:w+0,F=(n+1)%e.length,B=d[F],D=f[B],j=p[B],W=h[B],J=N?[g.negA,g.negB]:[g.posA,g.posB],se=N?[b.negA,b.negB]:[b.posA,b.posB],ke=J[1],ae=Math.max(...J)/Math.max(1e-9,Math.min(...J)),ve=Math.max(...se)/Math.max(1e-9,Math.min(...se)),G=ae>i||ve>i;if(r==="bevel"||G){sx(g,M,C,N,s,a,l,u,c,D,j,W,m);return}if(r==="miter"){let K=s[M*2],$=s[M*2+1],ee=s[C*2],te=s[C*2+1],he=HV(K,$,y,P,ee,te,-S,-v);if(!he){sx(g,M,C,N,s,a,l,u,c,D,j,W,m);return}if(Math.hypot(he[0]-g.bx,he[1]-g.by)>o*ke){sx(g,M,C,N,s,a,l,u,c,D,j,W,m);return}let Fe=s.length/2;s.push(he[0],he[1]),l.push(D),u.push(j),c.push(W);let Se=m>=0?m:ux(g,s,l,u,c,D,j,W);N?(a.push(M,Fe,C),a.push(M,C,Se)):(a.push(M,C,Fe),a.push(M,Se,C));return}if(r==="round"){BV(g,M,C,N,s,a,l,u,c,D,j,W,m);return}}var DV=10*Math.PI/180;function BV(e,t,n,r,o,i,s,a,l,u,c,d,f){let p=e.bx,h=e.by,m=f>=0?f:ux(e,o,s,a,l,u,c,d),g=o[t*2]-p,b=o[t*2+1]-h,x=o[n*2]-p,w=o[n*2+1]-h,y=Math.hypot(g,b),P=Math.hypot(x,w),S=Math.atan2(b,g),A=Math.atan2(w,x)-S;r&&A<0?A+=2*Math.PI:!r&&A>0&&(A-=2*Math.PI);let N=Math.max(1,Math.ceil(Math.abs(A)/DV)),M=A/N,C=t;for(let F=1;F<N;F++){let B=S+F*M,D=y+(P-y)*F/N;o.push(p+Math.cos(B)*D,h+Math.sin(B)*D);let j=o.length/2-1;s.push(u),a.push(c),l.push(d),r?i.push(C,m,j):i.push(C,j,m),C=j}r?i.push(C,m,n):i.push(C,n,m)}function sx(e,t,n,r,o,i,s,a,l,u,c,d,f){let p=f>=0?f:ux(e,o,s,a,l,u,c,d);r?i.push(t,p,n):i.push(t,n,p)}function ux(e,t,n,r,o,i,s,a){let l=t.length/2;return t.push(e.bx,e.by),n.push(i),r.push(s),o.push(a),l}function HV(e,t,n,r,o,i,s,a){let l=n*a-r*s;if(Math.abs(l)<1e-9)return null;let u=((o-e)*a-(i-t)*s)/l;return[e+u*n,t+u*r]}function hN(e,t,n,r){let o=e.length,i=n?o:o-1,s=[];for(let l=0;l<i;l++)s.push(GV(e,t,l,r));for(let l=!0;l;){l=!1;for(let u=0;u<o;u++){let c=u>0||n?s[(u-1+o)%o]??null:null,d=u<i?s[u]:null;c&&d&&c.side===d.side&&c.u>d.s&&(s[(u-1+o)%o]=null,s[u]=null,l=!0)}}let a=[];for(let l=0;l<i;l++){let u=s[l];if(!u){a.push(-1);continue}let c=t[l]+2+u.side,d=t[(l+1)%o]+u.side;r[c*2]=u.x,r[c*2+1]=u.y,r[d*2]=u.x,r[d*2+1]=u.y,a.push(c)}return a}function GV(e,t,n,r){let o=e[n],i=e[(n+1)%e.length],s=(o.bx-o.ax)*(i.by-i.ay)-(o.by-o.ay)*(i.bx-i.ax);if(s===0)return null;let a=s>0?0:1,l=t[n],u=t[(n+1)%e.length],c=r[(l+a)*2],d=r[(l+a)*2+1],f=r[(l+2+a)*2],p=r[(l+2+a)*2+1],h=r[(u+a)*2],m=r[(u+a)*2+1],g=r[(u+2+a)*2],b=r[(u+2+a)*2+1],x=f-c,w=p-d,y=g-h,P=b-m,S=x*P-w*y;if(S===0)return null;let v=h-c,A=m-d,N=(v*P-A*y)/S,M=(v*w-A*x)/S;return N>0&&N<=1&&M>=0&&M<1?{side:a,x:c+x*N,y:d+w*N,s:N,u:M}:null}var UV={vertices:new Float32Array(0),indices:new Uint32Array(0),anchorA:new Uint32Array(0),anchorB:new Uint32Array(0),anchorT:new Float32Array(0)};function at(e,t){return Gt(e,t)}function Ti(e,t,n={}){let r=at(t.width??1,1);if(r<=0)return UV;let o=t.join??"miter",i=t.cap??"butt",s=t.align??"center",a=t.miterLimit??VV,l=t.varyingWidthJoinThreshold??zV,u=n.metric,c=u&&e.kind==="rect"?ix(e,u):null,d=c??e;d.kind==="rect"&&s!=="center"&&(d={kind:"rect",...pb(d,s,r)});let f=d.kind==="polygon"?ps(d):null;f&&(d=f.path);let p=t.vertexWidths&&t.vertexWidths.length>0?t.vertexWidths:null,h=p&&f?.anchorSources?vl(p,f.anchorSources,1):p,m=hs(d,Uf(n.flattenTolerance,r,h??void 0)),g=u?c?(N,M)=>rx(u,N,M):(N,M)=>ox(u,N,M):void 0,b=[],x=[],w=[],y=[],P=[],S=u??null,v=[];for(let N of m){uN(N,h,t.nib,r,g);let M=fN(N,c?S:null,S,n.startInset,n.endInset);M!==null&&v.push(M)}for(let N of iN(v,t.dash))WV(N,r,o,i,a,l,b,x,w,y,P);let A=new Float32Array(b);return u&&pu(A,u),{vertices:A,indices:new Uint32Array(x),anchorA:new Uint32Array(w),anchorB:new Uint32Array(y),anchorT:new Float32Array(P),...e.kind==="polygon"&&e.origin?{origin:e.origin}:{}}}function WV(e,t,n,r,o,i,s,a,l,u,c){let d=t/2,f=e.points,p=f.length/2,h=p-1;if(h<1)return;let m=e.anchorA??new Uint32Array(p),g=e.anchorB??new Uint32Array(p),b=e.anchorT??new Float32Array(p),x=e.widths,w=e.offsets,y=F=>(x?x[F]/2:d)+(w?w[F]:0),P=F=>(x?x[F]/2:d)-(w?w[F]:0),S=[],v=[];for(let F=0;F<h;F++){let B=lx(f[F*2],f[F*2+1],f[(F+1)*2],f[(F+1)*2+1],y(F),P(F),y(F+1),P(F+1));B&&(S.push(B),v.push(F))}let A=-1;if(e.closed&&S.length>=1){let F=S[S.length-1],B=S[0],D=lx(F.bx,F.by,B.ax,B.ay,y(p-1),P(p-1),y(0),P(0));D&&(S.push(D),A=p-1,v.push(A))}if(S.length===0)return;let N=[];for(let F=0;F<S.length;F++){let B=S[F],D=v[F],j=F===S.length-1&&e.closed&&A>=0?0:D+1,W=s.length/2;N.push(W);let{nxUnit:J,nyUnit:se}=B;s.push(B.ax+J*B.posA,B.ay+se*B.posA),l.push(m[D]),u.push(g[D]),c.push(b[D]),s.push(B.ax-J*B.negA,B.ay-se*B.negA),l.push(m[D]),u.push(g[D]),c.push(b[D]),s.push(B.bx+J*B.posB,B.by+se*B.posB),l.push(m[j]),u.push(g[j]),c.push(b[j]),s.push(B.bx-J*B.negB,B.by-se*B.negB),l.push(m[j]),u.push(g[j]),c.push(b[j]),a.push(W,W+1,W+2,W+1,W+3,W+2)}let M=e.closed?S.length:S.length-1,C=hN(S,N,e.closed,s);for(let F=0;F<M;F++)pN(S,N,F,n,o,i,s,a,l,u,c,v,m,g,b,C[F]);if(!e.closed&&r!=="butt"){let F=S[0],B=N[0];ax(F,B+0,B+1,!1,F.posA,F.negA,r,s,a,l,u,c,m[0],g[0],b[0]);let D=S[S.length-1],j=N[S.length-1],W=v[S.length-1]+1;ax(D,j+2,j+3,!0,D.posB,D.negB,r,s,a,l,u,c,m[W],g[W],b[W])}}var VV=4,zV=1.5;Z();function Us(e,...t){let n=0,r=0;for(let[l,u]of t)n+=l.length/2+(u?1:0),r+=l.length;let o=new Uint8Array(n),i=new Float32Array(r),s=0,a=0;for(let[l,u]of t){for(let c=0;c<l.length;c+=2)o[s++]=c===0?le:ce,i[a++]=l[c]*e,i[a++]=l[c+1]*e;u&&(o[s++]=fe)}return{kind:"polygon",commands:o,coords:i,fillRule:"nonzero"}}function Tr(e,t,n=!0){return Us(t,[e,n])}function bN(e,t,n=32){let r=[];for(let o=0;o<n;o++){let i=o/n*Math.PI*2;r.push(e+t*Math.cos(i),t*Math.sin(i))}return r}function mN(e,t,n){return Tr(bN(e,t),n)}var zf=e=>[[e,-2,e,2],!1],cx=[[[-4,0,0,-2.5],!1],[[-4,0,0,2.5],!1]],yN=2,gN=e=>[[bN(e,yN),!0],[[e+yN,0,0,0],!1]],hu={reads:[],fill:"none",outline:{width:1}},xN=[{id:"arrow",reads:[],inset:3,path:({size:e})=>Tr([0,0,-3,-1.5,-3,1.5],e)},{id:"arrow-open",reads:[],inset:0,fill:"none",outline:{width:1},path:({size:e})=>Tr([-2.867,-2.007,0,0,-2.867,2.007],e,!1)},{id:"arrow-concave",reads:[],inset:3,path:({size:e})=>Tr([0,0,-3,-1.5,-2,0,-3,1.5],e)},{id:"triangle-hollow",reads:[],inset:4,fill:"none",outline:{width:.5},path:({size:e})=>Tr([0,0,-4,-2,-4,2],e)},{id:"diamond",reads:[],inset:4,path:({size:e})=>Tr([0,0,-2,-1.2,-4,0,-2,1.2],e)},{id:"diamond-hollow",reads:[],inset:4,fill:"none",outline:{width:.5},path:({size:e})=>Tr([0,0,-2,-1.2,-4,0,-2,1.2],e)},{id:"circle",reads:[],inset:2,path:({size:e})=>mN(-1,1,e)},{id:"square",reads:[],inset:2,path:({size:e})=>Tr([0,-1,0,1,-2,1,-2,-1],e)},{id:"bar",reads:[],inset:0,fill:"none",outline:{width:1},path:({size:e})=>Tr([0,-1.5,0,1.5],e,!1)},{id:"dot",reads:[],inset:0,path:({size:e})=>mN(0,1.2,e)},{id:"crow-one",...hu,inset:0,path:({size:e})=>Us(e,zf(-2),zf(-4),[[-4,0,0,0],!1])},{id:"crow-many",...hu,inset:0,path:({size:e})=>Us(e,...cx)},{id:"crow-zero-one",...hu,inset:7.5,path:({size:e})=>Us(e,zf(-2),...gN(-5.5))},{id:"crow-one-many",...hu,inset:0,path:({size:e})=>Us(e,...cx,zf(-5.5))},{id:"crow-zero-many",...hu,inset:9.5,path:({size:e})=>Us(e,...cx,...gN(-7.5))}];var Kf=xt();function KV(){for(let e of xN)Kf.push(e.id,e,{source:"kit"})}KV();var jV=Kf.reflection;function mu(){return Kf.getVersion()}function yo(e){return e===void 0?void 0:Kf.get(e)}Pe();function Ws(e,t,n=1){return typeof e=="string"||e.size===void 0?t:Gt(e.size,n)}function Si(e){return typeof e=="string"?e:e.key}function dx(e,t,n=1){if(e===void 0)return 0;let r=yo(Si(e));return r===void 0?0:(r.inset??0)*Ws(e,t,n)}function Vs(e,t){return{start:dx(e.markerStart,t),end:dx(e.markerEnd,t)}}function zs(e,t,n){let r=e.points[n*2]-e.points[t*2],o=e.points[n*2+1]-e.points[t*2+1],i=Math.hypot(r,o);return i<1e-9?null:{x:r/i,y:o/i}}function wN(e,t,n){for(let r=t+1;r<n;r++)if(zs(e,t,r))return r;return-1}function PN(e,t){for(let n=t-1;n>=0;n--)if(zs(e,n,t))return n;return-1}function TN(e,t){let n=[],r=e.points.length/2;if(r<2)return n;if(t.start&&!e.closed){let o=wN(e,0,r),i=o>=0?zs(e,0,o):null;i&&n.push({x:e.points[0],y:e.points[1],angle:Math.atan2(-i.y,-i.x),role:"start"})}if(t.mid){let o=e.anchorA,i=e.anchorB,s=e.anchorT;if(o&&i&&s)for(let a=1;a<r-1;a++){if(o[a]!==i[a]||s[a]!==0)continue;let l=PN(e,a),u=wN(e,a,r);if(l<0||u<0)continue;let c=zs(e,l,a),d=zs(e,a,u),f=c.x+d.x,p=c.y+d.y;Math.hypot(f,p)<1e-9&&(f=c.x,p=c.y),n.push({x:e.points[a*2],y:e.points[a*2+1],angle:Math.atan2(p,f),role:"mid"})}}if(t.end&&!e.closed){let o=r-1,i=PN(e,o),s=i>=0?zs(e,i,o):null;s&&n.push({x:e.points[o*2],y:e.points[o*2+1],angle:Math.atan2(s.y,s.x),role:"end"})}return n}Z();function $V(e,t,n){let{origin:r,...o}=e,i=Math.cos(t.angle),s=Math.sin(t.angle),a=new Float32Array(o.coords.length);for(let l=0;l<o.coords.length;l+=2){let u=o.coords[l],c=o.coords[l+1];a[l]=t.x+u*i-c*s,a[l+1]=t.y+u*s+c*i}return n?{...o,coords:a,origin:n}:{...o,coords:a}}function yu(e,t,n,r,o={}){let i={start:t.markerStart,mid:t.markerMid,end:t.markerEnd};if(i.start===void 0&&i.mid===void 0&&i.end===void 0)return[];let s=new Map;for(let u of["start","mid","end"]){if(i[u]===void 0)continue;let c=o[u],d=s.get(c);d===void 0&&s.set(c,d={start:!1,mid:!1,end:!1}),d[u]=!0}let a=[],l=e.kind==="polygon"?e.origin:void 0;for(let u of hs(e,Uf(r,n,t.vertexWidths)))for(let[c,d]of s){let f=c?{...u,points:u.points.slice()}:u;c&&fu(f,c.metric);for(let p of TN(f,d)){let h=i[p.role];if(h===void 0)continue;let m=yo(Si(h));if(m===void 0)continue;let g=Ws(h,n),b=m.orient===void 0||m.orient==="auto"?p.angle:m.orient,x=$V(m.path({size:g,stroke:t}),{...p,angle:b},l);c&&pu(x.coords,c.metric),a.push(c?{entry:m,size:g,path:x,space:c}:{entry:m,size:g,path:x})}}return a}function jf(e,t){if(e.reads===void 0)return null;let n="";for(let r of e.reads)n+=`${JSON.stringify(t[r])??""}|`;return n}var YV=64,SN=new WeakMap,kN=new WeakMap;function vN(e,t){let n=et(e.path({size:1,stroke:t}));return Math.max(Math.abs(n.x),Math.abs(n.x+n.width),Math.abs(n.y),Math.abs(n.y+n.height))+(e.outline?e.outline.width/2:0)}function qV(e,t){let n=jf(e,t);if(n===null){let i=kN.get(e);i===void 0&&kN.set(e,i=new WeakMap);let s=i.get(t);return s===void 0&&i.set(t,s=vN(e,t)),s}let r=SN.get(e);r===void 0&&SN.set(e,r=new Map);let o=r.get(n);return o===void 0&&(r.size>=YV&&r.clear(),r.set(n,o=vN(e,t))),o}function gu(e){let t={world:0,px:0},n=e.width??1;for(let r of[e.markerStart,e.markerMid,e.markerEnd]){if(r===void 0)continue;let o=yo(Si(r));if(o===void 0)continue;let i=typeof r=="string"||r.size===void 0?n:r.size,s=qV(o,e);typeof i=="number"?t.world=Math.max(t.world,s*i):t.px=Math.max(t.px,s*i.px)}return t}var bu=lG(AN(),1);Je();Pn();oi();ii();nn();tn();function RN(e,t={}){let n=Qe(e);if(n.kind==="rect"){let{x:m,y:g,width:b,height:x}=n;return[[[[m,g],[m+b,g],[m+b,g+x],[m,g+x],[m,g]]]]}let r=t.tolerance??mt,o=[],i=null,s=0,a=0,l=0,u=0,c=0,{commands:d}=n,f=$e(n),p=kn(n),h=(m=p)=>{if(m||(i=null),!i||i.length===0)return;let g=i[0],b=i[i.length-1];(g[0]!==b[0]||g[1]!==b[1])&&i.push([g[0],g[1]]),i.length>=4&&o.push(i),i=null};for(let m=0;m<d.length;m++){let g=d[m];switch(g){case le:{h(),s=f[c],a=f[c+1],l=s,u=a,i=[[s,a]],c+=2;break}case ce:{i??=[[s,a]],s=f[c],a=f[c+1],i.push([s,a]),c+=2;break}case xe:{let b=f[c],x=f[c+1],w=f[c+2],y=f[c+3],P=f[c+4],S=f[c+5],v=[];lo(s,a,b,x,w,y,P,S,r,v),i??=[[s,a]];for(let A=0;A<v.length;A+=2)i.push([v[A],v[A+1]]);s=P,a=S,c+=6;break}case we:{let b=f[c],x=f[c+1],w=f[c+2],y=f[c+3],[P,S,v,A]=io(s,a,b,x,w,y),N=[];lo(s,a,P,S,v,A,w,y,r,N),i??=[[s,a]];for(let M=0;M<N.length;M+=2)i.push([N[M],N[M+1]]);s=w,a=y,c+=4;break}case fe:{h(!0),s=l,a=u;break}default:throw new Error(`pathToMultiPolygon: unknown command ${g}`)}}return h(),o.length===0?[]:e6(o,n.fillRule)}function XV(e){let t=0;for(let n=0,r=e.length-1;n<r;n++)t+=e[n][0]*e[n+1][1]-e[n+1][0]*e[n][1];return t*.5}function JV(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let[i,s]of e)i<t&&(t=i),i>r&&(r=i),s<n&&(n=s),s>o&&(o=s);return[t,n,r,o]}function QV(e,t,n){let r=!1;for(let o=0,i=e.length-1;o<i;o++){let[s,a]=e[o],[l,u]=e[o+1];a>n!=u>n&&t<(l-s)*(n-a)/(u-a)+s&&(r=!r)}return r}function ZV(e,t,n,r){if(r[0]<t[0]||r[1]<t[1]||r[2]>t[2]||r[3]>t[3])return!1;let o=n.length-1,i=0;for(let s of[0,Math.floor(o/3),Math.floor(2*o/3)])QV(e,n[s][0],n[s][1])&&i++;return i>=2}function e6(e,t){let n=e.length;if(n===1)return[[e[0]]];let r=e.map(JV),o=e.map(u=>XV(u)>=0?1:-1),i=new Array(n).fill(-1),s=e.map(()=>[]);for(let u=0;u<n;u++){let c=-1,d=1/0;for(let f=0;f<n;f++){if(u===f||!ZV(e[f],r[f],e[u],r[u]))continue;let p=(r[f][2]-r[f][0])*(r[f][3]-r[f][1]);p<d&&(d=p,c=f)}i[u]=c}for(let u=0;u<n;u++)i[u]>=0&&s[i[u]].push(u);let a=new Array(n);for(let u=0;u<n;u++){let c=0,d=0;for(let f=u;f>=0;f=i[f])d+=o[f],f!==u&&c++;a[u]=t==="evenodd"?c%2===0:d!==0}let l=[];for(let u=0;u<n;u++){if(!a[u]||i[u]>=0&&a[i[u]])continue;let c=[e[u]],d=[...s[u]];for(;d.length>0;){let f=d.pop();a[f]?d.push(...s[f]):c.push(e[f])}l.push(c)}return l}function hx(e){let t=0,n=0;for(let l of e)for(let u of l){if(u.length<4)continue;let c=u.length-1;t+=1+(c-1)+1,n+=c*2}let r=new Uint8Array(t),o=new Float64Array(n),i=0,s=0;for(let l of e)for(let u of l){if(u.length<4)continue;let c=u.length-1;r[i++]=le,o[s++]=u[0][0],o[s++]=u[0][1];for(let d=1;d<c;d++)r[i++]=ce,o[s++]=u[d][0],o[s++]=u[d][1];r[i++]=fe}let a=Sn(o);return{kind:"polygon",commands:r,coords:At(a,o),fillRule:"nonzero",...a?{origin:a}:{}}}Je();nn();li();av();gv();ov();li();Pd();li();function $f(e,t){return e.length===2?xl(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y):e.length===3?XS(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y):ni(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y)}var NN=[.25,.5,.75];function IN(e,t,n){let r=[],o=s=>{r.some(a=>Math.hypot(a.p.x-s.p.x,a.p.y-s.p.y)<=n)||r.push(s)};for(let[s,a]of[[0,t[0]],[1,t[t.length-1]]]){let l=$f(e,a);l.dist<=n&&o({ta:l.t,tb:s,p:a})}for(let[s,a]of[[0,e[0]],[1,e[e.length-1]]]){let l=$f(t,a);l.dist<=n&&o({ta:s,tb:l.t,p:a})}let i=null;for(let s=0;s<r.length;s++)for(let a=s+1;a<r.length;a++){let[l,u]=r[s].ta<=r[a].ta?[r[s],r[a]]:[r[a],r[s]];if(i&&u.ta-l.ta<=i[1].ta-i[0].ta)continue;NN.every(d=>$f(t,tt(e,l.ta+(u.ta-l.ta)*d)).dist<=n)&&(i=[l,u])}return i}function t6(e,t,n){return!(e.from===t.from&&e.to===t.to)&&!(e.from===t.to&&e.to===t.from)?!1:NN.every(o=>$f(t.seg,tt(e.seg,o)).dist<=n)}function EN(e,t){let n=new Map,r=[];for(let o of e){let i=o.from<o.to?`${o.from},${o.to}`:`${o.to},${o.from}`,s=n.get(i)??[],a=s.find(l=>t6(l,o,t));if(a){(a.also??=[]).push({operand:o.operand,sign:a.from===o.from?1:-1});continue}s.push(o),n.set(i,s),r.push(o)}return r}var n6=16,Yf=1e-9,mx=class{constructor(t){this.snap=t}snap;points=[];grid=new Map;id(t){let n=Math.floor(t.x/this.snap),r=Math.floor(t.y/this.snap);for(let a=-1;a<=1;a++)for(let l=-1;l<=1;l++)for(let u of this.grid.get(`${n+a},${r+l}`)??[]){let c=this.points[u];if(Math.hypot(c.x-t.x,c.y-t.y)<=this.snap)return u}let o=this.points.length;this.points.push({x:t.x,y:t.y});let i=`${n},${r}`,s=this.grid.get(i);return s?s.push(o):this.grid.set(i,[o]),o}};function r6(e){let t=[];return e.forEach((n,r)=>n.forEach((o,i)=>o.forEach((s,a)=>{let l=1/0,u=1/0,c=-1/0,d=-1/0;for(let f of s)l=Math.min(l,f.x),c=Math.max(c,f.x),u=Math.min(u,f.y),d=Math.max(d,f.y);t.push({seg:s,operand:r,contour:i,index:a,count:o.length,box:[l,u,c,d]})}))),t}var o6=(e,t)=>{if(e.operand!==t.operand||e.contour!==t.contour)return!1;let n=Math.abs(e.index-t.index);return n===1||n===e.count-1};function i6(e){if(e.length<4)return!1;let t=tt(e,.5),n=bs(e,0,.5,e[0],t),r=bs(e,.5,1,t,e[3]);return!n||!r?!1:Mg(n,r).some(o=>o.ta<1-1e-6||o.tb>1e-6)}function MN(e,t){let n=r6(e);if(n.some(a=>i6(a.seg)))return null;let r=new mx(t),o=n.map(({seg:a})=>[r.id(a[0]),r.id(a[a.length-1])]),i=n.map(()=>[]);for(let a=0;a<n.length;a++){let l=n[a];for(let u=a+1;u<n.length;u++){let c=n[u];if(l.box[0]>c.box[2]+t||c.box[0]>l.box[2]+t||l.box[1]>c.box[3]+t||c.box[1]>l.box[3]+t)continue;let d=IN(l.seg,c.seg,t);if(d){for(let h of d){let m=r.id(h.p);i[a].push({t:h.ta,v:m}),i[u].push({t:h.tb,v:m})}continue}let f=Mg(l.seg,c.seg);if(f.length>=n6)return null;let p=o6(l,c);for(let h of f){if(p&&(h.ta>1-Yf&&h.tb<Yf||h.ta<Yf&&h.tb>1-Yf))continue;let m=r.id(h);i[a].push({t:h.ta,v:m}),i[u].push({t:h.tb,v:m})}}}let s=[];return n.forEach((a,l)=>{let{seg:u}=a,c=[{t:0,v:o[l][0]},...i[l].sort((p,h)=>p.t-h.t),{t:1,v:o[l][1]}],d=[c[0]];for(let p=1;p<c.length;p++){let h=c[p];h.v!==d[d.length-1].v?d.push(h):p===c.length-1&&d.length>1&&(d[d.length-1]=h)}let f=Math.hypot(a.box[2]-a.box[0],a.box[3]-a.box[1]);d.length===1&&u.length>2&&f>100*t&&d.push(c[c.length-1]);for(let p=0;p+1<d.length;p++){let h=d[p],m=d[p+1],g=h.t===0&&m.t===1?u.slice():bs(u,h.t,m.t,r.points[h.v],r.points[m.v]);g&&(g[0]=r.points[h.v],g[g.length-1]=r.points[m.v],s.push({seg:g,from:h.v,to:m.v,operand:a.operand,source:u,t0:h.t,t1:m.t,key:l+h.t*.5,reversed:!1}))}}),{edges:EN(s,t),points:r.points}}li();function FN(e,t){let n=e.flat(),r=new Float64Array(n.length*4);return n.forEach((o,i)=>{let s=1/0,a=1/0,l=-1/0,u=-1/0;for(let c of o)s=Math.min(s,c.x),l=Math.max(l,c.x),a=Math.min(a,c.y),u=Math.max(u,c.y);r.set([s,a,l,u],i*4)}),{segs:n,boxes:r,fillRule:t}}var s6={x:1,y:0};function CN(e,t){let n=0,{segs:r,boxes:o}=t;for(let i=0;i<r.length;i++){if(e.y<o[i*4+1]||e.y>o[i*4+3]||o[i*4+2]<e.x)continue;let s=r[i];for(let a of Qk(Jk(s,e,s6),!0))tt(s,a.t).x>e.x&&(n+=a.after>0?1:-1)}return n}var ON=(e,t)=>t==="evenodd"?(e&1)!==0:e!==0,LN=e=>({...e,seg:e.seg.slice().reverse(),from:e.to,to:e.from,reversed:!0});function a6(e,t){let n=new Array(t).fill(0);n[e.operand]=1;for(let{operand:r,sign:o}of e.also??[])n[r]+=o;return n}function _N(e,t,n){let r=[];for(let o of e){let i=(o.t0+o.t1)/2,s=tt(o.source,i),a=Ml(o.source,i),l=Math.hypot(a.x,a.y);if(l===0){let g=o.seg[0],b=o.seg[o.seg.length-1];if(a={x:b.x-g.x,y:b.y-g.y},l=Math.hypot(a.x,a.y),l===0)continue}let u=-a.y/l*n,c=a.x/l*n,d={x:s.x+u,y:s.y+c},f={x:s.x-u,y:s.y-c},p=a6(o,t.length),h=new Array(t.length),m=new Array(t.length);for(let g=0;g<t.length;g++){let b=CN(d,t[g]),x=CN(f,t[g]);if(Math.abs(b-x)!==Math.abs(p[g]))return null;h[g]=ON(b,t[g].fillRule),m[g]=ON(x,t[g].fillRule)}r.push({edge:o,inL:h,inR:m})}return r}li();var gx=Math.PI*2,yx=1e-7;function l6(e){let t=e[0];for(let n=1;n<e.length;n++)if(e[n].x!==t.x||e[n].y!==t.y)return{x:e[n].x-t.x,y:e[n].y-t.y};return{x:0,y:0}}var u6=e=>e.slice().reverse();function c6(e,t){let n=0;for(let o=0;o+1<e.length;o++)n+=Math.hypot(e[o+1].x-e[o].x,e[o+1].y-e[o].y);let r=tt(e,n===0?0:Math.min(1,t/n));return{x:r.x-e[0].x,y:r.y-e[0].y}}var DN=e=>Math.atan2(e.y,e.x);function d6(e,t){let n=(e-t)%gx;return n<=0?n+gx:n}function BN(e){let t=e[0],n=e[e.length-1];return Math.hypot(n.x-t.x,n.y-t.y)||Math.hypot(e[1].x-t.x,e[1].y-t.y)}function f6(e,t){let n=t[e.to];if(!n||n.length===0)return-1;if(n.length===1)return n[0].key;let r=u6(e.seg),o=l=>{let u=DN(l(r));return n.map(c=>d6(u,DN(l(c.seg))))},i=l=>{let u=l.slice().sort((c,d)=>c-d);return u[0]<yx||u[u.length-1]>gx-yx||u[1]-u[0]<yx},s=o(l6);if(i(s)){let l=.001*Math.min(BN(e.seg),...n.map(u=>BN(u.seg)));if(s=o(u=>c6(u,l)),i(s))return-1}let a=0;for(let l=1;l<s.length;l++)s[l]<s[a]&&(a=l);return n[a].key}function HN(e,t){if(e.source!==t.source||e.reversed!==t.reversed)return null;let[n,r]=e.reversed?[t,e]:[e,t];if(n.t1!==r.t0)return null;let o=n.t0,i=r.t1,s=n.seg[e.reversed?n.seg.length-1:0],a=r.seg[e.reversed?0:r.seg.length-1],l=o===0&&i===1?n.source.slice():bs(n.source,o,i,s,a);return l?(l[0]=s,l[l.length-1]=a,e.reversed&&l.reverse(),{...e,seg:l,from:e.from,to:t.to,t0:o,t1:i}):null}function p6(e){let t=[];for(let n of e){let r=t.length>0?HN(t[t.length-1],n):null;r?t[t.length-1]=r:t.push(n)}for(;t.length>1;){let n=HN(t[t.length-1],t[0]);if(!n)break;t.pop(),t[0]=n}return t.map(n=>n.seg)}function GN(e,t){let n=new Map,r=Array.from({length:t},()=>[]);if(e.forEach((a,l)=>{n.set(a.key,l),r[a.from].push(a)}),n.size!==e.length)return null;let o=e.map(a=>{let l=f6(a,r);return l<0?-1:n.get(l)});if(o.includes(-1))return null;let i=new Int32Array(e.length).fill(-1),s=[];for(let a=0;a<e.length;a++){if(i[a]>=0)continue;let l=[],u=a;do{if(i[u]>=0)return null;i[u]=s.length,l.push(u),u=o[u]}while(u!==a);let c=0;for(let d=1;d<l.length;d++)e[l[d]].key<e[l[c]].key&&(c=d);s.push(p6([...l.slice(c),...l.slice(0,c)].map(d=>e[d])))}return s}var h6=4096;function m6(e){let t=Qe(e);return t.kind==="polygon"&&t.commands.some(n=>n===xe||n===we)}function y6(e){return e.length<2?e:e[e.length-1].length===2?e.slice(0,-1):e}function g6(e){if(!e.some(m6))return null;let t=e.map(a=>iv(a)),n=t.reduce((a,l)=>a+l.reduce((u,c)=>u+c.length,0),0);if(n===0||n>h6)return null;let r=sv(t.flat())||1,o=MN(t,r*1e-6);if(!o)return null;let i=t.map((a,l)=>{let u=e[l];return FN(a,u.kind==="polygon"?u.fillRule:"nonzero")}),s=_N(o.edges,i,r*1e-7);return s?{edges:s,vertexCount:o.points.length,clockwise:t.map(w6)}:null}function b6(e,t){let n=new Map,r=(i,s)=>{let a=n.get(i);a?a.push(s):n.set(i,[s])};for(let{edge:i,inL:s,inR:a}of e.edges){let l=t(s),u=t(a);l!==u&&(l!==-1&&r(l,i),u!==-1&&r(u,LN(i)))}let o=new Map;for(let[i,s]of n){let a=GN(s,e.vertexCount);if(!a)return null;o.set(i,a)}return o}function x6(e,t){let n=t?e.map(P6):e;return yv(n.map(r=>({segs:y6(r),closed:!0})),"nonzero")}function UN(e,t){let n=g6(e);if(!n)return null;let r=b6(n,o=>t(o)?0:-1);return r?x6(r.get(0)??[],n.clockwise[0]):null}function w6(e){let t=0;for(let n of e){let r=Xk(n);Math.abs(r)>Math.abs(t)&&(t=r)}return t<0}function P6(e){let t=qk(e);return[t[t.length-1],...t.slice(0,-1)]}Fk();function T6(e,t){return Tg(t,hx(e))}function qf(e,t,n){if(e.length===0)return hx([]);let r=UN(e,t);if(r)return Tg(e,r);let[o,...i]=e.map(s=>RN(s));return T6(n(o,...i),e)}var S6=e=>e.includes(!0),k6=e=>!e.includes(!1),v6=e=>e[0]&&!e[1],A6=e=>e.filter(Boolean).length%2===1;function Xf(...e){return qf(e,S6,bu.default.union)}function bx(...e){return qf(e,k6,bu.default.intersection)}function xx(e,t){return qf([e,t],v6,bu.default.difference)}function wx(...e){return qf(e,A6,bu.default.xor)}Z();function WN(e){if(typeof e=="string")return e.length===0?[]:[{text:e}];for(let t=0;t<e.length;t++)if(typeof e[t]?.text!="string")throw new Error(`toRuns: run at index ${t} is missing string \`text\``);return e}Pe();function Px(e,t,n){if(!(t>0))return 0;let r=(Math.floor(e/t)+1)*t-e;return r<n?r+t:r}function VN(e,t,n,r,o,i){let s=0,a=e,l=u=>{u<=a||(i?.(a,u,s),s+=o(a,u))};for(let u of n){if(u<e)continue;if(u>=t)break;l(u);let{stop:c,min:d}=r(u);s+=Px(s,c,d),a=u+1}return l(t),s}function Sx(e,t){return e==="start"||e==="justify"?t==="rtl"?"right":"left":e==="end"?t==="rtl"?"left":"right":e}var zN={kind:"solid",color:"#000"};function Tx(e){return Ht(e)?e.color:"#000"}var KN="",jN="";function $N(e){return e!==KN&&(jN=`color-mix(in srgb, ${e} 25%, transparent)`,KN=e),jN}var Ie={fontSize:16,fontFamily:"sans-serif",fontWeight:400,fontStyle:"normal",align:"left",direction:"auto",lineHeight:1.2,tabSize:8,wrap:!1,fill:null,caretColor:Tx(zN),selectionBackground:$N(Tx(zN)),selectionColor:null,letterSpacing:0,underline:!1,strikethrough:!1,overline:!1,textTransform:"none",fontVariantCaps:"normal"};function kx(e,t,n=1){return!e&&Ne(t?.fill)===null&&(t?.stroke??void 0)===void 0?Ie:Qf({...Ie},e,t,n)}function Qf(e,t,n,r=1){let o=t??R6,i=Ne(n?.fill),s=n?.stroke??void 0,a=o.caretColor??Tx(i?.paint??null),l;o.selectionBackground==="none"?l=null:o.selectionBackground!=null?l=o.selectionBackground:l=$N(a),e.fontSize=Gt(o.fontSize??Ie.fontSize,r),e.fontFamily=o.fontFamily??Ie.fontFamily,e.fontWeight=o.fontWeight??Ie.fontWeight,e.fontStyle=o.fontStyle??Ie.fontStyle,e.align=o.align??Ie.align,e.direction=o.direction??Ie.direction,e.lineHeight=o.lineHeight??Ie.lineHeight,e.tabSize=o.tabSize??Ie.tabSize,e.wrap=o.wrap??Ie.wrap,e.fill=i,e.caretColor=a,e.selectionBackground=l,e.selectionColor=o.selectionColor??null,e.letterSpacing=Gt(o.letterSpacing??Ie.letterSpacing,r),e.underline=o.underline??Ie.underline,e.strikethrough=o.strikethrough??Ie.strikethrough,e.overline=o.overline??Ie.overline,e.textTransform=o.textTransform??Ie.textTransform,e.fontVariantCaps=o.fontVariantCaps??Ie.fontVariantCaps,(o.script!==void 0||e.script!==void 0)&&(e.script=o.script);let u=o.lang||void 0;return(u!==void 0||e.lang!==void 0)&&(e.lang=u),(s!==void 0||e.stroke!==void 0)&&(e.stroke=s),e}var R6=Object.freeze({});Pe();var N6=new Map([[223,"Ss"],[452,"\u01C5"],[453,"\u01C5"],[454,"\u01C5"],[455,"\u01C8"],[456,"\u01C8"],[457,"\u01C8"],[458,"\u01CB"],[459,"\u01CB"],[460,"\u01CB"],[497,"\u01F2"],[498,"\u01F2"],[499,"\u01F2"],[1415,"\u0535\u0582"],[64256,"Ff"],[64257,"Fi"],[64258,"Fl"],[64259,"Ffi"],[64260,"Ffl"],[64261,"St"],[64262,"St"],[64275,"\u0544\u0576"],[64276,"\u0544\u0565"],[64277,"\u0544\u056B"],[64278,"\u054E\u0576"],[64279,"\u0544\u056D"],[8115,"\u1FBC"],[8124,"\u1FBC"],[8131,"\u1FCC"],[8140,"\u1FCC"],[8179,"\u1FFC"],[8188,"\u1FFC"],[8114,"\u1FBA\u0345"],[8116,"\u0386\u0345"],[8119,"\u0391\u0342\u0345"],[8130,"\u1FCA\u0345"],[8132,"\u0389\u0345"],[8135,"\u0397\u0342\u0345"],[8178,"\u1FFA\u0345"],[8180,"\u038F\u0345"],[8183,"\u03A9\u0342\u0345"]]);function I6(e,t){let n=e.codePointAt(0);return n>=8064&&n<=8111?String.fromCodePoint(n|8):N6.get(n)??e.toLocaleUpperCase(t)}function vx(e){if(e)try{return Intl.getCanonicalLocales(e)[0]}catch{return}}var E6=/[\p{L}\p{N}][\p{L}\p{N}\p{M}\p{Pc}'’]*/gu;function M6(e){let t=new Set;if(typeof Intl<"u"&&"Segmenter"in Intl){let n=new Intl.Segmenter(void 0,{granularity:"word"});for(let r of n.segment(e))r.isWordLike&&t.add(r.index);return t}for(let n of e.matchAll(E6))t.add(n.index);return t}function YN(e,t,n){let r=0;for(let o of e)for(let i of o)r+=n(i).length;return r===t.length}function qN(e,t,n=[]){if(t.every(b=>b==="none"))return e.map(b=>({text:b}));let r=e.map((b,x)=>vx(n[x])),o=r.every(b=>b===r[0])?r[0]:void 0,i=(b,x=o)=>b.toLocaleUpperCase(x),s=(b,x=o)=>b.toLocaleLowerCase(x),a=e.join(""),l=t.includes("uppercase")?a.toLocaleUpperCase(o):"",u=t.includes("lowercase")?a.toLocaleLowerCase(o):"",c=l!==""&&YN(e,l,i),d=u!==""&&YN(e,u,s),f=t.includes("capitalize")?M6(a):null,p=[],h=0,m=0,g=0;for(let b=0;b<e.length;b++){let x=e[b],w=t[b]??"none",y=r[b],P=y===o,S="",v=[],A=[],N=!1,M=0;for(let C of x){let F=i(C),B=s(C),D=C;w==="uppercase"?D=c&&P?l.slice(m,m+F.length):i(C,y):w==="lowercase"?D=d&&P?u.slice(g,g+B.length):s(C,y):w==="capitalize"&&f.has(h+M)&&i(C,y)!==C&&(D=I6(C,y)),m+=F.length,g+=B.length,D.length!==C.length&&(N=!0),S+=D;for(let j=0;j<D.length;j++)v.push(M),A.push(M+C.length);M+=C.length}p.push(N?{text:S,srcMap:{length:x.length,starts:v,ends:A}}:{text:S}),h+=x.length}return p}var C6=.7;function O6(e){let t=e?.xHeight,n=e?.capHeight;return t===void 0||n===void 0||t>=n?C6:t/n}function XN(e,t,n){return O6(Yo(xn(e,t,n)))}function JN(e,t,n){let r=vx(n),o="",i=[],s=[],a=[],l=!1,u=!1,c=0;for(let f of e){let p=f.toLocaleUpperCase(r),h=p!==f,m=h?p:f;m.length!==f.length&&(l=!0),u||=h;let g=t?t.starts[c]:c,b=t?t.ends[c]:c+f.length;for(let x=0;x<m.length;x++)i.push(h),s.push(g),a.push(b);o+=m,c+=f.length}if(!u)return t?{text:e,srcMap:t}:{text:e};let d=l?{length:t?.length??e.length,starts:s,ends:a}:t;return{text:o,...d?{srcMap:d}:{},small:i}}var ZN=null;function eI(){return ZN}var QN=new WeakMap;function Ax(e){let{family:t,weight:n,style:r}=e.resolved,o=e.outlineFace??(e.source==="outline"?void 0:ll(t,n,r==="italic"?"italic":"normal"));if(!o)return null;let i=QN.get(o);return i===void 0&&(i=o.embedding?.()??null,QN.set(o,i)),i}function F6(e){return Ax(e)?.sfnt??null}function tI(e,t,n,r,o=ZN){if(o===null)return!1;let i=F6(xn(e,t,n));return i!==null&&o.hasFeature(i,r)}var L6=Object.freeze(["smcp"]),Zf=Object.freeze({super:Object.freeze({size:.583,shift:.333}),sub:Object.freeze({size:.583,shift:-.333})}),nI=new WeakMap;function rI(e){if(!e||!e.superscript&&!e.subscript)return Zf;let t=nI.get(e);return t||(t=Object.freeze({super:e.superscript??Zf.super,sub:e.subscript??Zf.sub}),nI.set(e,t)),t}function oI(e,t,n){return rI(Yo(xn(e,t,n)))}function iI(e){if(typeof e=="number")return e;if(e==="bold"||e==="bolder")return 700;if(e==="normal")return 400;let t=Number(e);return Number.isFinite(t)?t:400}function sI(e,t){return{fontFamily:e.fontFamily??t.fontFamily,fontWeight:e.fontWeight??(e.bold?700:iI(t.fontWeight)),fontStyle:e.italic?"italic":t.fontStyle}}function xu(e,t,n=1){return Rx(new Array(e.length),e,t,n)}function Rx(e,t,n,r=1){e.length!==t.length&&(e.length=t.length);let o=!1;for(let s of t)(s.textTransform??n.textTransform)!=="none"&&(o=!0);let i=o?qN(t.map(s=>s.text),t.map(s=>s.textTransform??n.textTransform),t.map(s=>s.lang??n.lang)):null;for(let s=0;s<t.length;s++){let a=t[s],l=i?i[s].text:a.text,u=i?.[s].srcMap,c=a.script??n.script,{fontFamily:d,fontWeight:f,fontStyle:p}=sI(a,n),h=c?oI(d,f,p)[c]:void 0,m=a.baselineShift??h?.shift??0,g=a.fontScale??h?.size??1,b=a.fontSize===void 0&&g!==1,x=a.fontSize!==void 0?Gt(a.fontSize,r):n.fontSize*g,w,y,P=(a.fontVariantCaps??n.fontVariantCaps)==="small-caps";if(P&&tI(d,f,p,"smcp"))y=L6;else if(P){let W=JN(l,u,a.lang??n.lang);if(l=W.text,u=W.srcMap,W.small){let J=x*XN(d,f,p);w=W.small.map(se=>se?J:x)}}let S=a.lang??n.lang,v=a.fill!==void 0?a.fill:n.fill,A=a.letterSpacing!==void 0?Gt(a.letterSpacing,r):n.letterSpacing,N=a.underline||n.underline,M=a.strikethrough||n.strikethrough,C=a.overline||n.overline,F=a.stroke??n.stroke,B=a.rotate&&Number.isFinite(a.rotate)?a.rotate:void 0,D=e[s];if(D!==void 0&&D.srcMap!==void 0==(u!==void 0)&&D.sizeMap!==void 0==(w!==void 0)&&D.stroke!==void 0==(F!==void 0)&&D.strutSize!==void 0===b&&D.rotate!==void 0==(B!==void 0)&&D.fontFeatures!==void 0==(y!==void 0)&&D.lang!==void 0==!!S){D.text=l,D.fontFamily=d,D.fontSize=x,D.fontWeight=f,D.fontStyle=p,D.fill=v,D.letterSpacing=A,D.underline=N,D.strikethrough=M,D.overline=C,D.baselineShift=m*n.fontSize,u&&(D.srcMap=u),w&&(D.sizeMap=w),F!==void 0&&(D.stroke=F),b&&(D.strutSize=n.fontSize),B!==void 0&&(D.rotate=B),y&&(D.fontFeatures=y),S&&(D.lang=S);continue}let j={text:l,fontFamily:d,fontSize:x,fontWeight:f,fontStyle:p,fill:v,letterSpacing:A,underline:N,strikethrough:M,overline:C,baselineShift:m*n.fontSize};u&&(j.srcMap=u),w&&(j.sizeMap=w),F!==void 0&&(j.stroke=F),b&&(j.strutSize=n.fontSize),B!==void 0&&(j.rotate=B),y&&(j.fontFeatures=y),S&&(j.lang=S),e[s]=j}return e}var aI=["underline","strikethrough","overline"],ep=Object.freeze({underline:Object.freeze({offset:.1,thickness:.05}),strikethrough:Object.freeze({offset:-.3,thickness:.05}),overline:Object.freeze({offset:-.9,thickness:.05})}),lI=new WeakMap;function _6(e){if(!e)return ep;let t=lI.get(e);if(!t){let n=e.underline??ep.underline;t=Object.freeze({underline:n,strikethrough:e.strikethrough??ep.strikethrough,overline:Object.freeze({offset:ep.overline.offset,thickness:n.thickness})}),lI.set(e,t)}return t}function D6(e,t,n,r){let o=_6(r)[e],i=t+n*o.offset;return{y0:i,y1:i+n*o.thickness}}function uI(e,t,n){let r=[],o=null,i=()=>{let s=o;if(o=null,!(!s||s.x1<=s.x0))for(let a of aI){if(!s.style[a])continue;let{y0:l,y1:u}=D6(a,s.baselineY,s.style.fontSize,s.face);r.push({kind:a,x0:s.x0,y0:l,x1:s.x1,y1:u,run:s.run})}};return{add(s){let a=e[s.run],l=a.underline||a.strikethrough||a.overline?n(s.run):null;if(l===null){o!==null&&i();return}let u=t(s.run);o!==null&&aI.every(d=>o.style[d]===a[d])&&o.style.fontSize===a.fontSize&&o.face===u&&o.baselineY===s.baselineY&&o.paint===l?o.x1=s.x+s.step:(i(),o={run:s.run,style:a,face:u,paint:l,baselineY:s.baselineY,x0:s.x,x1:s.x+s.step})},end(){return i(),r}}}function dI(e,t,n,r){let o=[],i=0;for(let a=0;a<=t.length;a++)a<t.length&&!n(a)||(a>i&&o.push({start:i,end:a,analysis:e.analyze(t.slice(i,a),r)}),i=a+1);let s=a=>{let l=0,u=o.length-1;for(;l<u;){let d=l+u>>1;o[d].end<=a?l=d+1:u=d}let c=o[l];return c!==void 0&&a>=c.start&&a<c.end?c:void 0};return{reorder(a,l){let u=s(a);if(u===void 0||l>u.end)return{order:[],levels:[]};let c=e.reorder(u.analysis,a-u.start,l-u.start);return{order:c.order.map(d=>d+u.start),levels:c.levels}},baseLevel(a){let l=s(a);return l===void 0?0:e.baseLevel(l.analysis)}}}function B6(e,t,n){if(e.length===t)return[...e];let r=new Set(e),o=[],i=new Map,s=-1,a=-1;for(let u=0;u<t;u++)if(r.has(u))s=u,a<0&&(a=u);else if(s<0)o.push(u);else{let c=i.get(s);c?c.push(u):i.set(s,[u])}if(a<0)return o;let l=[];for(let u of e){let c=i.get(u)??[],d=u===a?o:[];n(u)?l.push(...[...c].reverse(),u,...[...d].reverse()):l.push(...d,u,...c)}return l}var H6=1024,cI=[];function G6(e){let t=cI[e];if(t!==void 0)return t;let n={visual:Array.from({length:e},(r,o)=>o),levels:new Array(e).fill(0)};return e<=H6&&(cI[e]=n),n}function fI(e,t,n){return e===null||n===0?G6(n):U6(e,t,n)}function U6(e,t,n){let r=new Array(n).fill(0),o=e.reorder(t,t+n);for(let s=0;s<n;s++){let a=o.levels[s];typeof a=="number"&&a>=0&&(r[s]=a)}let i=new Set;for(let s of o.order){let a=s-t;Number.isInteger(a)&&a>=0&&a<n&&i.add(a)}return{visual:B6([...i],n,s=>r[s]%2===1),levels:r}}var Ix={};sG(Ix,{AK:()=>Rz,AL:()=>yz,AP:()=>Nz,AS:()=>Iz,B2:()=>tz,BA:()=>Z6,BB:()=>ez,BK:()=>V6,CB:()=>rz,CL:()=>oz,CLASS_MASK:()=>Fz,CM:()=>X6,CP:()=>iz,CR:()=>z6,EAST_ASIAN:()=>Lz,EB:()=>xz,EM:()=>wz,EX:()=>sz,GL:()=>Q6,H2:()=>Pz,H3:()=>Tz,HL:()=>gz,HY:()=>nz,ID:()=>bz,IN:()=>az,IS:()=>dz,JL:()=>Sz,JT:()=>vz,JV:()=>kz,LF:()=>K6,NL:()=>j6,NS:()=>lz,NU:()=>fz,OP:()=>uz,PICTOGRAPHIC_CN:()=>_z,PO:()=>pz,PR:()=>hz,QU:()=>cz,QU_PF:()=>Oz,QU_PI:()=>Cz,RI:()=>Az,SP:()=>$6,SY:()=>mz,UNICODE_VERSION:()=>W6,VF:()=>Ez,VI:()=>Mz,WJ:()=>J6,ZW:()=>Y6,ZWJ:()=>q6,lineBreakPropsOf:()=>Hz});var W6="16.0.0",V6=0,z6=1,K6=2,j6=3,$6=4,Y6=5,q6=6,X6=7,J6=8,Q6=9,Z6=10,ez=11,tz=12,nz=13,rz=14,oz=15,iz=16,sz=17,az=18,lz=19,uz=20,cz=21,dz=22,fz=23,pz=24,hz=25,mz=26,yz=27,gz=28,bz=29,xz=30,wz=31,Pz=32,Tz=33,Sz=34,kz=35,vz=36,Az=37,Rz=38,Nz=39,Iz=40,Ez=41,Mz=42,Cz=43,Oz=44,Fz=63,Lz=64,_z=128,pI="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+,-./:;<=>?@[]^_{|}~",Dz=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,35,36,37,38,39,40,41,42,43,44,71,73,74,79,81,82,83,84,88,89,91,93,94,95,96,97,98,155,157],hI=2787,mI="9H1K1C2A1B18H1E1R1V1b1Z1Y1b1V1U1Q1b1Z1W1N1W1a10X2W3b1R27b1U1Z1Q29b1U1K1P1b6H1D26H1J1U1Y3Z5b1n1b1K2b1Y1Z2b1L6b1o3b1U520b1L3b1L18b1L32b79H1J12H7J13H14b1W260b7H255b1W1K4b1Z1b45H1K1H1b2H1b2H1R1H8b27c4b4c13b6X3b3Y2W2b11H1R1H3R43b21H10X1Y2X3b1H99b1R1b7H1X1b6H2b2H1b4H2b10X23b1H30b27H91b11H15b10X33b9H4b1W1R3b1H2Z22b4H1b9H1b3H1b5H43b3H52b2X5b9H42b24H1X33H54b3H1b18H1b7H10b2H2K10X17b3H56b1H1b7H2b2H2b3H9b1H10b2H2b10X2b2Y5b1Y1b1Z2b1H2b3H56b1H1b5H4b2H2b3H3b1H20b10X2H3b1H11b3H56b1H1b8H1b3H1b3H20b2H2b10X1b1Z8b6H1b3H56b1H1b7H2b2H2b3H7b3H10b2H2b10X18b1H59b5H3b3H1b4H9b1H14b10X9b1Z6b5H55b1H1b7H1b3H1b4H7b2H11b2H2b10X7b1L9b3H1L55b1H1b7H1b3H1b4H7b2H11b2H2b10X3b1H12b4H55b2H1b7H1b3H1b4H9b1H10b2H2b10X9b1Y7b3H70b1H4b6H1b1H1b8H6b10X2b2H61b1H2b7H4b1Z7b8H1b10X2K85b1H2b9H11b7H1b10X39b4L1b2L1J2L1K1J5R1J1b1R3b2H6b10X10b1K1H1b1H1b1H1U1P1U1P2H49b14H1K5H1K2H5b11H1b36H1b2K6b1H9b2L1K1L5b2J80b20H1b10X2K10b4H4b3H1b3H2b7H3b4H13b12H1b1H10X4H98b96(72f88g349b3H1b1K158b1K639b1K26b1U1P78b3K36b4H28b3H2K27b2H30b2H64b32H2K1T1b1K1b1K1Z1b1H2b10X24b2R2K1L1b2R1b3H1J1H10X107b2H34b1H118b12H4b12H8b2R10X128b11X60b5H57b10H1b29H2b1H10X6b10X22b31H49b5H47i16H1m8i1b2K10k2K1d4K10d9H9d3K3H30b13H2b10X6b38k12H2l48b20H3b5K10X6b10X36b2K80b3H1b21H4b1H6b1H2b3H198b13H1J46H1J3H509b1L2b7K1J3K1F1H1G2H1K1J2K1M3b1n1o1U2n1o1U1n4b3S1K2A5H1J8Y1b1n1o1b2T6b1W1U1P3T12b1K1Y4K1b3K1I5b10H13b1U1P14b1U1P17b7Z1Y1Z1y12Z1Y4Z1Y2Z1Y1Z1Y15Z33H18b1Y5b1Y12b1Z251b2Z219b1S24b1U1P1U1P14b2!13b1w1s190b4z3b1!2d1!521b2z1b4d16b2!2b1d1b3d1e2d16b8z1b3d12b12z20b1d22b1!10b6z3b1z13b1z8b2z17b2!5d2!3d4b1d1z3d1b1d1!3b2d2b1d2b3d8b1!6b1d2!1d1!1b2d1e1!2b1!7d1z2b2d2#2e26b1z35b1z1b1z4b3z1b1z3b6V1b2R1d3b1U1P1U1P1U1P1U1P1U1P1U1P1U1P31b3z24b1z14b1z5b1U1P31b1U1P1U1P1U1P1U1P1U1P403b1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P63b1U1P1U1P32b1U1P285b2z51b1z4b1z409b3H7b1R3K1b1R1K112b1K14b1H96b32H2V1n1o1n1o3V1n1o1V1n1o8K1b1K1U1K2b1n1o2b1n1o1U1P1U1P1U1P1U1P4K1R1b2K1b2K5b2M3K1b2K1U8K1b1K1b2K3b2R1U1Q1U1Q1U1Q1U1Q1K34b26!1b89!12b214!26b16!1r2s2!1v2!1w1s1w1s1w1s1w1s1w1s2!1w1s1w1s1w1s1w1s1v1w2s10!6p5!1p5!2v2!1d1b1v1!1v1!1v1!1v1!1v25!1v31!1v1!1v1!1v6!1v6!2v2b2p4v1!2v1!1v1!1v1!1v1!1v25!1v31!1v1!1v1!1v6!1v6!2v4!4v1!5b43!1b94!1b86!9b1!16v31!1b40!8b7024!64z21013!1v1143!3b55!55b2K269b1K1R1K16b10X69b4H1b10H32b2H80b2H1b5K266b1H3b1H4b1H23b5H4b1H11b1Y59b2L2R8b2H50b18H8b2K10X6b18H10b1L2b1H10X28b8H2K23b13H12b29(3b4H47i13H1m6d3K4d1b1K10k4b2d5b1H10b10X6b41k14H9b3K1H8K2H2b10k2b1d3K27b3H50b1H1b3H2b2H5b2H1b1H41b5H2K3b2H236b8H1K2H2b10X6b1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&12b23f4b49g8452b512!29b1c1H10c1b13c1b5c1b1c1b2c1b2c1b10c494b1P1U188b1Y3b16H3s2v2t1w1s1u6b1J1H1J1H1J1H2J1H1J1H1J1H2J1H5!1w1s1w1s1w1s1w1s1w1s1w1s1w1s1w1s2!1w1s7!1s1!1s1b2v2t1!1w1s1w1s1w1s8!1b1!1y1x1!147b1I1b1t2!1y1x2!1w1s2!1s1!1s11!2v3!1t27!1w1!1s29!1w1!1s1!1w2s1w2s1v1!10v45!2v31!3b6!2b6!2b6!2b3!3b1x1y3!2y1b7z10b3H1O259b3K250b1H226b1H149b5H36b1K48b1K207b10X941b1K199b1K225b3H1b2H5b4H40b3H4b1H16b8K141b2H9b6K1S66b7K484b4H8b10X6b10X31b5H1K316b2H1K78b4H70b11H49b4H122b3H2j51i14H1m2K5d4b20d10k1H2i2H1i9b1J3H45b11H2b1X4K1H10b1X34b10X6b3H36b14H1b10X4K1b2H44b1H1b1L10b3H48b14H4b2K1b1K4H1b2H10X1b1L1b3K76b12H2K1b2K1b1H2b1H103b1K53b12H5b10X6b4H1b8i2b2i2b22i1b7i1b2i1b5i1b2H1K7H2b2H2b2H1m2b1k6b1H5b1K2k2i2H2b7H3b5H11b10k1b1k2b1k1b2k36i1b1d9H1b1H2b1H1b4H1b4H1m1j1H3d1b2d8b2H82b18H4b4K1b10X2K2b1H81b20H12b10X213b7H2b9H1L2K2R3b15K4b2H82b17H2K13b10X6b13L62b13H8b10X6b20X57b15H4b10X2b3K237b15H165b10X22b7i2b1i2b8i1b2i1b24i6H1b2H2b3H1m1j1H1j2H3K9b10k119b7H2b7H1b1L1b1H28b10H40b7H1b4H1L1b4K1L1b1H9b11H46b16H3K1b3L2K93b10L230b10X53b8H1b8H1b5K10b10X22b1L1R32b22H1b14H122b6H3b1H1b2H1b7H1b1H8b10X48b5H1b2H1b5H8b10X310b18k1K4H2K7b2H1j1H13i1b34i7H3b4H1m2K11d10k1H130b4Y30b1K1136b5K3555b3U3P36b1P3b1U1P1U1P239b1U2P179b1U7J1U1P3J1U1P1U1P1H6b15H4472b1U1P6960b30k18H10k2342b10X4b2K80b10X38b5H1K58b7H3K10b1K11b10X532b2K10X285b2K182b1H1b55H7b4H77b4v1q11b2p14b6136!8b768!470z41b1z9!8935b4z1b7z1b2z1b291!15b1v29b3v2b1v14b4v8b396!2465b2H1K4H4172b10X518b46H2b23H542b5H3b22H2b7H30b4H148b3H187b87z9b23z1111b50X512b55H4b50H8b1H14b1H2b4K16b5H1b15H1360b7H1b17H2b7H1b2H1b5H100b1H160b7H9b10X356b1H61b4H10X5b1Z492b4H10X244b2H1b10X725b7H109b7H5b10X4b2U844b1Y3b1Y847b4d1!39d4*100d12*15d2*15d1*14d1!1*37d10*142b1z2b10z19b56*26h3!13*44!4*9!7*2!14*6!154*33!12d9!1d70!1d7!1#14!8d2b2d21!2z5!1z5!3#2!1#2!1#2e2d5!12d17!3d1!3d3!5$63!1d1!1d2#2!11#21!19#3!1#4!3#1!3#7!1#1!1#14!1z1!1z1!1z5!1#4!1z1!2z74!2d1!7z16!14z13!12z12b1d4!1d24!12d2e4d1#21d1e4d2#13d1!47d8b24d6b1d74!3#3!5#38b3V3T4b35!1#16!3#9!1#5!6d1#3d3!2d3!4*4!11d2!3*4d9!3*116b3d4*5d85b5d6*12!4*1!15*12b4)56b8)10b6)40b8)30b2)12b4)2b62)12b1#2!1#8!8#6!1#9!10#1!1d3#7!1d48!1#61!2#1!2#1!1#17!3#1!13#34!84b12*14d2*13!3*10!5*52!3#1!7*15!2*11!6*9#7*240b10X6b1022*2b65534!2b65534!655363b1H30b96H128b240H196112b",Nx=null,yI=null,gI=null;function Bz(){let e=new Uint8Array(65536),t=new Int32Array(hI),n=new Uint8Array(hI),r=new Uint8Array(128);for(let a=0;a<pI.length;a++)r[pI.charCodeAt(a)]=Dz[a];let o=0,i=0,s=0;for(let a=0;a<mI.length;a++){let l=mI.charCodeAt(a);if(l<=57&&l>=48)s=s*10+l-48;else{let u=r[l];t[i]=o,n[i]=u,o<65536&&e.fill(u,o,Math.min(o+s,65536)),i++,o+=s,s=0}}Nx=e,yI=t,gI=n}function Hz(e){if(Nx===null&&Bz(),e<65536)return Nx[e];if(e>1114111)return 27;let t=yI,n=0,r=t.length-1;for(;n<r;){let o=n+r+1>>1;t[o]<=e?n=o:r=o-1}return gI[n]}var{lineBreakPropsOf:Vx,CLASS_MASK:zx,EAST_ASIAN:Gz,PICTOGRAPHIC_CN:Uz,BK:Wz,CR:AI,LF:RI,NL:Vz,SP:kr,ZW:$s,ZWJ:Lx,CM:bI,WJ:Ex,GL:wu,BA:Mx,BB:zz,B2:xI,HY:Pu,CB:Cx,CL:tp,CP:Tu,EX:wI,IN:Kz,NS:PI,OP:np,QU:_x,IS:go,NU:ln,PO:Ks,PR:js,SY:Su,AL:Kx,HL:sp,ID:jz,EB:NI,EM:II,H2:Dx,H3:Bx,JL:Hx,JV:ap,JT:lp,RI:Ox,AK:rp,AP:$z,AS:Fx,VF:TI,VI:SI,QU_PI:Gx,QU_PF:Ux}=Ix,ne=0,ku=1,EI=2,Yz=8208,op=9676,ip=e=>e===_x||e===Gx||e===Ux,ki=e=>e===Wz||e===AI||e===RI||e===Vz;function vi(e){return ki(Vx(e)&zx)}var Sr=e=>e===Kx||e===sp,kI=e=>e===Hx||e===ap||e===lp||e===Dx||e===Bx,vI=e=>e===jz||e===NI||e===II,jx=e=>({cls:new Uint8Array(e),ea:new Uint8Array(e),pict:new Uint8Array(e),cp:new Int32Array(e),start:new Int32Array(e)}),MI=65536,En=jx(64);function qz(e){return En.cls.length<e&&(En=jx(Math.min(MI,Math.max(e,En.cls.length*2)))),En}var CI=[],Wx=CI,Ae=En.cls,In=En.ea,vu=En.pict,xo=En.cp,Au=En.start,bo=0;function OI(e){return $x(e,new Uint8Array(e.length+1))}function $x(e,t){let n=e.length;for(let i=0;i<n;i++)t[i]=ne;if(n===0)return t[0]=ne,t;t[n]=EI;let r=n<=MI?qz(n):jx(n);Wx=e,{cls:Ae,ea:In,pict:vu,cp:xo,start:Au}=r;let o=0;for(let i=0;i<n;i++){let s=Vx(e[i]),a=s&zx;if((a===bI||a===Lx)&&o>0){let l=Ae[o-1];if(!ki(l)&&l!==kr&&l!==$s)continue}a===bI||a===Lx?(Ae[o]=Kx,In[o]=0,vu[o]=0):(Ae[o]=a,In[o]=s&Gz?1:0,vu[o]=s&Uz?1:0),xo[o]=e[i],Au[o]=i,o++}bo=o;for(let i=1;i<bo;i++)t[Au[i]]=Qz(i);return Wx=CI,r!==En&&({cls:Ae,ea:In,pict:vu,cp:xo,start:Au}=En),t}var Xz=e=>(Vx(Wx[Au[e]-1])&zx)===Lx;function Jz(e){for(;e>=0&&Ae[e]===kr;)e--;return e}function Qz(e){let t=e-1,n=Ae[t],r=Ae[e];if(n===AI&&r===RI)return ne;if(ki(n))return EI;if(ki(r)||r===kr||r===$s)return ne;let o=Jz(t);if(o>=0&&Ae[o]===$s)return ku;if(Xz(e)||n===Ex||r===Ex||n===wu||r===wu&&n!==kr&&n!==Mx&&n!==Pu||r===tp||r===Tu||r===wI||r===Su)return ne;let i=o>=0?Ae[o]:-1;if(i===np)return ne;if(i===Gx){let l=o-1;if(l<0)return ne;let u=Ae[l];if(ki(u)||u===np||ip(u)||u===wu||u===kr||u===$s)return ne}if(r===Ux){if(e+1>=bo)return ne;let l=Ae[e+1];if(l===kr||l===wu||l===Ex||l===tp||ip(l)||l===Tu||l===wI||l===go||l===Su||ki(l)||l===$s)return ne}if(n===kr&&r===go&&e+1<bo&&Ae[e+1]===ln)return ku;if(r===go||(i===tp||i===Tu)&&r===PI||i===xI&&r===xI)return ne;if(n===kr)return ku;if(r===_x||r===Ux||n===_x||n===Gx||ip(r)&&(!In[t]||e+1>=bo||!In[e+1])||ip(n)&&(!In[e]||t===0||!In[t-1]))return ne;if(n===Cx||r===Cx)return ku;if((n===Pu||xo[t]===Yz)&&r===Kx){if(t===0)return ne;let l=Ae[t-1];if(ki(l)||l===kr||l===$s||l===Cx||l===wu)return ne}if(r===Mx||r===Pu||r===PI||n===zz||t>0&&Ae[t-1]===sp&&(n===Pu||n===Mx&&!In[t])&&r!==sp||n===Su&&r===sp||r===Kz||Sr(n)&&r===ln||n===ln&&Sr(r)||n===js&&vI(r)||vI(n)&&r===Ks||(n===js||n===Ks)&&Sr(r)||Sr(n)&&(r===js||r===Ks))return ne;if(r===Ks||r===js){let l=n===tp||n===Tu?t-1:t;for(;l>=0&&(Ae[l]===Su||Ae[l]===go);)l--;if(l>=0&&Ae[l]===ln)return ne}if(n===Ks||n===js){if(r===ln)return ne;if(r===np&&e+1<bo){let l=Ae[e+1];if(l===ln||l===go&&e+2<bo&&Ae[e+2]===ln)return ne}}if((n===Pu||n===go)&&r===ln)return ne;if(r===ln){let l=t;for(;l>=0&&(Ae[l]===Su||Ae[l]===go);)l--;if(l>=0&&Ae[l]===ln)return ne}if(n===Hx&&(r===Hx||r===ap||r===Dx||r===Bx)||(n===ap||n===Dx)&&(r===ap||r===lp)||(n===lp||n===Bx)&&r===lp||kI(n)&&r===Ks||n===js&&kI(r)||Sr(n)&&Sr(r))return ne;let s=n===rp||n===Fx||xo[t]===op,a=r===rp||r===Fx||xo[e]===op;if(n===$z&&a||s&&(r===TI||r===SI)||n===SI&&t>0&&(Ae[t-1]===rp||Ae[t-1]===Fx||xo[t-1]===op)&&(r===rp||xo[e]===op)||s&&a&&e+1<bo&&Ae[e+1]===TI||n===go&&Sr(r)||(Sr(n)||n===ln)&&r===np&&!In[e]||n===Tu&&!In[t]&&(Sr(r)||r===ln))return ne;if(n===Ox&&r===Ox){let l=t;for(;l>=0&&Ae[l]===Ox;)l--;if((t-l)%2===1)return ne}return r===II&&(n===NI||vu[t])?ne:ku}var Zz=null;function LI(){return Zz}function _I(e){return e%2===1?"rtl":"ltr"}var e7=[[1424,1535],[1536,1983],[2144,2303],[64285,65023],[65136,65279],[67584,69631],[124928,126975]],t7=[[1536,1541],[1632,1644],[1757,1757],[1776,1785],[2274,2274],[68912,68921],[69216,69246]],n7=[[1548,1548],[64830,64831],[65279,65279]];function Yx(e,t){for(let n=0;n<e.length;n++)if(t>=e[n][0]&&t<=e[n][1])return!0;return!1}var FI=!1;function DI(e,t="weasel layoutRuns"){if(!FI)for(let n=0;n<e.length;n++){let r=e[n];if(!(!Yx(e7,r)||Yx(t7,r)||Yx(n7,r))){FI=!0,console.warn(`${t}: this text contains right-to-left characters but no \`bidi\` engine is registered, so it is being laid out in logical order \u2014 the glyphs will appear reversed. Import \`bidi\` out of the \`@weasel-js/bidi\` package and call \`registerBidi(bidi)\` once at startup.`);return}}}var Ru=[.5];function Ai(e){if(e>65536)return new Array(e).fill(.5);for(;Ru.length<e;)Ru=Ru.concat(Ru);return Ru.slice(0,e)}var r7=1<<18,BI=new Map,HI=new Map,qx=0;function GI(e,t){let n=e.get(t);if(n===void 0||n.n===0)return;qx-=t;let r=n.items[--n.n];return n.items[n.n]=void 0,r}function UI(e,t){let n=t.length;if(n===0||qx+n>r7)return;let r=e.get(n);r===void 0&&e.set(n,r={items:[],n:0}),r.items[r.n++]=t,qx+=n}function Nu(e){return GI(BI,e)??Ai(e)}function Xx(e){return GI(HI,e)??new Array(e)}function up(e){UI(BI,e)}function WI(e){UI(HI,e)}function gt(e,t){for(;e.length>t;)e.pop()}var vr=13,Jx=0,cp=1,VI=2,zI=3,KI=4,jI=5,$I=6,Qx=7,YI=8,Zx=9,qI=10,XI=11,JI=12,e0=1,QI=2,dp=5,o7=[],i7=[],t0=[],s7=1024,a7=0,fp=class e{num;ref;boxes=[];bounds={width:.5,height:.5};laid=null;stamp=0;paintings=[];owners=0;listed=!1;pinned=!1;constructor(t){this.num=Nu(t*vr),this.ref=Xx(t*dp)}static take(t){let n=t0.pop();return n===void 0?n=new e(t):(n.num=Nu(t*vr),n.ref=Xx(t*dp)),n.stamp=++a7,n}recycle(){up(this.num);let{ref:t}=this;for(let n=0;n<t.length;n++)t[n]=void 0;WI(t),this.num=o7,this.ref=i7,gt(this.paintings,0),this.owners=0,this.listed=!1,this.pinned=!1,t0.length<s7&&t0.push(this)}set(t,n,r,o,i,s){let a=t*vr,l=t*dp,{num:u,ref:c}=this;u[a+Jx]=o,u[a+cp]=i,u[a+VI]=n.advance,u[a+zI]=n.fontSize,u[a+KI]=s,u[a+jI]=n.srcIndex,u[a+$I]=n.srcEnd,u[a+Qx]=n.cp,u[a+YI]=r,u[a+qI]=n.run,u[a+JI]=n.rotate,u[a+Zx]=(n.drawsInk?e0:0)|(n.clusterEnd?QI:0),c[l]=n.resolved,c[l+1]=n.metrics,c[l+2]=n.font,c[l+3]=n.glyph,c[l+4]=n.shaped}widen(t,n){this.num[t*vr+cp]+=n}setVisual(t,n,r){this.num[(t+n)*vr+XI]=r}visual(t,n){return this.num[(t+n)*vr+XI]}glyph(t,n,r){let o=t+n,i=o*vr,s=o*dp,{num:a,ref:l}=this;return r.run=a[i+qI],r.cell=n,r.cp=a[i+Qx],r.fontSize=a[i+zI],r.resolved=l[s],r.metrics=l[s+1],r.font=l[s+2],r.glyph=l[s+3],r.shaped=l[s+4],r.x=a[i+Jx],r.baselineY=a[i+KI],r.advance=a[i+VI],r.step=a[i+cp],r.rotate=a[i+JI],r}drawsInk(t,n){return(this.num[(t+n)*vr+Zx]&e0)!==0}cell(t,n){let r=(t+n)*vr,{num:o}=this,i=o[r+Zx];return{srcIndex:o[r+jI],srcEnd:o[r+$I],cp:o[r+Qx],x:o[r+Jx],advance:o[r+cp],level:o[r+YI],drawsInk:(i&e0)!==0,clusterEnd:(i&QI)!==0}}};function n0(){return{run:0,cell:0,cp:0,fontSize:.5,resolved:null,metrics:null,font:null,glyph:null,shaped:null,x:.5,baselineY:.5,advance:.5,step:.5,rotate:.5}}var Pt=class e{#t;#n;#e;#r=!1;constructor(t,n,r,o,i,s,a,l,u,c){this.x0=t,this.y0=n,this.x1=r,this.y1=o,this.baselineY=i,this.srcEnd=s,this.justified=a,this.#t=l,this.#n=u,this.#e=c,Object.defineProperties(this,e.#o)}refill(t,n,r,o,i,s,a,l,u){return this.x0=t,this.y0=n,this.x1=r,this.y1=o,this.baselineY=i,this.srcEnd=s,this.justified=a,this.#n=l,this.#e=u,this.#r&&(this.#r=!1,Object.defineProperties(this,e.#o)),this}static columns(t){return t instanceof e?t.#t:null}static start(t){return t instanceof e?t.#n:0}static count(t){return t instanceof e?t.#e:t.glyphs.length}static#o={cells:pp("cells",t=>{t.#r=!0;let n=new Array(t.#e);for(let r=0;r<t.#e;r++)n[r]=t.#t.cell(t.#n,r);return n}),glyphs:pp("glyphs",t=>{t.#r=!0;let n=new Array(t.#e);for(let r=0;r<t.#e;r++)n[r]=t.#t.glyph(t.#n,t.#t.visual(t.#n,r),n0());return n})}};function pp(e,t){return{enumerable:!0,configurable:!0,get(){let n=t(this);return Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!1}),n}}}var r0,l7=/[\r\u0300-\uffff]/;function u7(){return r0===void 0&&(r0=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null),r0}function mp(e,t){let n=t??[],r=0;if(l7.test(e)){let o=u7();if(o)r=c7(o,e,n);else{let i=0;for(let s of e)n[r++]=i+=s.length}}else for(let o=1;o<=e.length;o++)n[r++]=o;return n.length=r,n}var hp=e=>e<768&&e!==13;function c7(e,t,n){let r=t.length,o=null,i=0,s=0;for(;s<r;){if(hp(t.charCodeAt(s))&&(s+1===r||hp(t.charCodeAt(s+1)))){n[i++]=++s;continue}let a=s+1;for(;;){for(;a<r&&!hp(t.charCodeAt(a));)a++;if(a===r||(a++,a===r||hp(t.charCodeAt(a))))break}for(o??=e.segment(t);s<a;){let l=o.containing(s);n[i++]=s=l.index+l.segment.length}}return i}var tE=Object.freeze({d:null,key:"",glyphs:Object.freeze([]),rtl:!1,text:""}),ZI=Object.freeze({cluster:tE,advance:0}),d7=new WeakMap,f7=new WeakMap,eE=e=>String(Math.round(e*1e5)/1e5);function nE(e,t,n){if(n===null)return null;let r=Ax(t);if(r===null)return null;let o=r.sfnt,i=n.shape(o,e.text,e.fontFeatures,e.lang),s=t.source==="outline"?d7:f7,a=s.get(i);if(a)return a;let l=t.source==="outline"?null:u=>r.glyphIndexOf(u);return a=p7(n,o,e.text,i,l),s.set(i,a),a}function p7(e,t,n,r,o){let i=new Array(n.length),s=mp(n),a=0,l=0;for(;l<r.length;){let u=r[l].cluster,c=l;for(;c<r.length&&r[c].cluster===u;)c++;let d=c<r.length?r[c].cluster:n.length;for(;a<s.length&&s[a]<=u;)a++;let f=0;for(let p=a;p<s.length&&s[p]<d;p++)f++;if(!y7(r,l,c)&&!(o&&h7(r[l],c-l,n,u,d,o))){let p=m7(r,l,c),h=p/(f+1),m=r[l].rtl?h-p:0;i[u]=g7(e,t,r,l,c,n.slice(u,d),m,h);let g=h===0?ZI:{cluster:tE,advance:h};for(let b=u+1,x=a;b<d;b++){let w=x<s.length&&s[x]===b;w&&x++,i[b]=w?g:ZI}}l=c}return i}function h7(e,t,n,r,o,i){if(t!==1||e.dx!==0||e.dy!==0)return!1;let s=n.codePointAt(r);return o-r===(s>65535?2:1)&&i(s)===e.gid}function m7(e,t,n){let r=0;for(let o=t;o<n;o++)r+=e[o].advance;return r}function y7(e,t,n){for(let r=t;r<n;r++)if(e[r].gid===0)return!0;return!1}function g7(e,t,n,r,o,i,s,a){let l=[],u=s,c="",d="";for(let f=r;f<o;f++){let p=n[f],h=u+p.dx,m=p.dy;l.push({gid:p.gid,x:h,y:m,advance:p.advance}),c+=e.glyphD(t,p.gid,h,m)??"",d+=`${f===r?"":";"}${p.gid}${h===0&&m===0?"":`@${eE(h)},${eE(m)}`}`,u+=p.advance}return{cluster:{d:c.length>0?c:null,key:d,glyphs:l,rtl:n[r].rtl,text:i},advance:a}}var b7=/^[\p{Mn}\p{Me}]$/u;function iE(e,t,n,r,o=null){let i=r??[],s=0,a,l=0;for(let u=0;u<e.length;u++){let c=e[u],d=xn(c.fontFamily,c.fontWeight,c.fontStyle),f=as(d);if(!f){Hy(c.fontFamily,c.fontWeight,c.fontStyle),l+=c.srcMap?.length??c.text.length,a=void 0;continue}let p=l,h=c.srcMap,m=mp(c.text,w7),g=nE(c,d,o),b=0,x=0,w=null,y=0,P=c.text;for(;y<P.length;){let S=P.codePointAt(y),v=S>65535?2:1,A=g?.[y],N=c.sizeMap?c.sizeMap[y]:c.fontSize;y===x&&(w=Gy(d,c.fontFamily,c.fontWeight,c.fontStyle,c.text.slice(y,m[b])));let M=y+v===m[b];M&&(x=m[b++]);let C=M?c.letterSpacing:0,F=h?p+h.starts[y]:p+y,B=h?p+h.ends[y]:p+y+v;y+=v,l=h?p+h.length:B;let D=x7(S),j=a&&!D?a.metrics.kernOf(a.cp,S)*(a.fontSize/a.metrics.size):0,W=T7(n,s,u,c,S,N,F,B,M,d,f);if(w)M&&(W.tracking=C,oE(W,w)),i[s++]=W,a=void 0;else if(vi(S))i[s++]=W,a=void 0;else if(S===9||S===32){let J=f.advanceOf(32),se=J!==null?J*(N/f.size):N*.25;if(S===9)i[s++]={...W,tab:{stop:t*(se+c.letterSpacing),min:se/2}},a=void 0;else{let ke=dl(d,32,rE);W.font=ke?.font??null,W.glyph=ke?.glyph??null,W.advance=se,W.tracking=C,W.kerningBefore=j,a=W,i[s++]=a}}else if(A!==void 0)W.tracking=C,i[s++]=S7(W,A),a=void 0;else{let J=fl(d,c.fontFamily,c.fontWeight,c.fontStyle,S,!0,rE);J&&(W.kerningBefore=j,W.tracking=C,oE(W,J)),i[s++]=W,D||(a=W)}}}return i.length=s,i}function x7(e){return e>=768&&b7.test(String.fromCodePoint(e))}var w7=[],rE={resolved:null,metrics:null,advance:0,font:null,glyph:null},P7=4096;function T7(e,t,n,r,o,i,s,a,l,u,c){let d=Math.max(r.fontSize,r.strutSize??0),f=r.baselineShift??0,p=r.rotate??0,h=e?.[t];if(!h){let m={run:n,cp:o,fontSize:i,lineSize:d,baselineShift:f,rotate:p,srcIndex:s,srcEnd:a,clusterEnd:l,resolved:u,metrics:c,font:null,glyph:null,advance:0,tracking:0,kerningBefore:0,tab:void 0,shaped:null,drawsInk:!1};return e&&t<P7&&(e[t]=m),m}return h.run=n,h.cp=o,h.fontSize=i,h.lineSize=d,h.baselineShift=f,h.rotate=p,h.srcIndex=s,h.srcEnd=a,h.clusterEnd=l,h.resolved=u,h.metrics=c,h.font=null,h.glyph=null,h.advance=0,h.tracking=0,h.kerningBefore=0,h.tab=void 0,h.shaped=null,h.drawsInk=!1,h}function oE(e,t){e.resolved=t.resolved,e.metrics=t.metrics,e.font=t.font,e.glyph=t.glyph,e.advance=t.advance*(e.fontSize/t.metrics.size),e.drawsInk=!0}function S7(e,t){return e.shaped=t.cluster,e.advance=t.advance*e.fontSize,e.drawsInk=t.cluster.d!==null,e}function sE(e,t,n,r){return e.map((o,i)=>{let s=t[i]%2===1;if(o.shaped!==null&&o.shaped.rtl!==s){let c=n(o.cp);c!==null&&c!==o.cp&&(o=k7(o,r[o.run]))}if(!s||o.shaped!==null)return o;let a=n(o.cp);if(a===null||a===o.cp)return o;if(o.font===null)return{...o,cp:a};let l=r[o.run],u=fl(o.resolved,l.fontFamily,l.fontWeight,l.fontStyle,a,!1);return u?{...o,cp:a,resolved:u.resolved,metrics:u.metrics,font:u.font,glyph:u.glyph}:o})}function k7(e,t){if(e.resolved.source==="outline")return{...e,shaped:null};let n=fl(e.resolved,t.fontFamily,t.fontWeight,t.fontStyle,e.cp,!1);return n?{...e,shaped:null,resolved:n.resolved,metrics:n.metrics,font:n.font,glyph:n.glyph}:{...e,shaped:null}}var gp=e=>e===32||e===9;var yp=new Uint8Array(64),o0=!1,v7=65536;function aE(e,t,n,r){let o=e.length;if(!Number.isFinite(t.maxWidth))i0(e,t,n,r,null);else if(o0||o>=v7)i0(e,t,n,r,OI(e));else{yp.length<o+1&&(yp=new Uint8Array(Math.max(o+1,yp.length*2))),o0=!0;try{i0(e,t,n,r,$x(e,yp))}finally{o0=!1}}}function i0(e,t,n,r,o){let i=e.length,s=0,a=0;for(;a<i;){let l=e[a];if(vi(l)){r(s,a,!1),a+=l===13&&e[a+1]===10?2:1,s=a;continue}if(gp(l)){a++;continue}let u=a+1,c=a+1;for(;u<i&&!vi(e[u])&&(!o||o[u]===ne);)gp(e[u])||(c=u+1),u++;o&&a>s&&n(s,c)>t.maxWidth&&(r(s,a,!0),s=a),a=u}s<i&&r(s,i,!1)}function lE(e,t){let n=e.lineSize/e.metrics.size,r=e.metrics.ascent*n;return e.metrics.descent===void 0?r:(e.lineSize*t-r-e.metrics.descent*n)/2+r}var cE=[],Eu=cE,Ri=Ai(64),a0=[],Iu=[],l0=0,uE=[],A7=64;function dE(e,t){return Eu[e].advance+Eu[e].tracking+Ri[t]-Ri[e+1]}var R7=e=>Eu[e].tab;function N7(e,t){return VN(e,t,a0,R7,dE)}function I7(e,t,n){let r=l0++,o=uE[r];o===void 0&&(o={start:0,entries:[],width:.5,height:.5,ascent:.5,wrapped:!1,srcEnd:0,end:0},r<A7&&(uE[r]=o)),o.start=e,o.end=t,o.wrapped=n,o.width=0,o.height=0,o.ascent=0,o.srcEnd=0,Iu[r]=o}function fE(e,t,n){let{lineHeight:r}=n;Ri.length<e.length+1&&(Ri=Ai(e.length+1)),Ri[0]=0;let o=0;l0=0;for(let i=0;i<e.length;i++){let s=e[i];Ri[i+1]=Ri[i]+s.kerningBefore+s.advance+s.tracking,s.tab&&(a0[o++]=i)}a0.length=o,Eu=e,aE(t,n,o===0?dE:N7,I7),Eu=cE,Iu.length=l0;for(let i=0;i<Iu.length;i++){let s=Iu[i];if(s.start===s.end){let l=e[s.end];s.height=l.lineSize*r,s.ascent=lE(l,r),s.srcEnd=l.srcIndex,gt(s.entries,0);continue}let a=s.entries;for(let l=s.start;l<s.end;l++){let u=e[l];l===s.start&&(u.kerningBefore=0),u.tab&&(u.advance=Px(s.width,u.tab.stop,u.tab.min)),a[l-s.start]=u,s.width+=u.kerningBefore+u.advance+u.tracking,s.height=Math.max(s.height,u.lineSize*r),s.ascent=Math.max(s.ascent,lE(u,r))}a.length=s.end-s.start,s.srcEnd=e[s.end-1].srcEnd}return Iu}function E7(e){let t=0;for(let n=e.length-1;n>=0&&gp(e[n].cp);n--){let r=e[n];t+=r.kerningBefore+r.advance+r.tracking}return t}function M7(e){let t=new Set,n=0;for(;n<e.length&&e[n].cp===32;)n++;let r=e.length-1;for(;r>n&&e[r].cp===32;)r--;for(let o=n+1;o<r;o++)e[o].cp===32&&t.add(o);return t}function C7(e,t,n){if(e==="left")return 0;if(!Number.isFinite(t))return e==="center"?-n/2:-n;let r=t-n;return e==="center"?r/2:r}var O7=new Set,s0={box:null,inkWidth:.5};function pE(e,t,n,r,o,i,s,a){let{alignWidth:l,justify:u}=o,{entries:c}=e,d=E7(c),f=e.width-d,p=l-f,h=u&&e.wrapped&&Number.isFinite(l)&&p>0?M7(c):O7,m=h.size>0?p/h.size:0,g=m*h.size,b=g>0?0:C7(r,l,f),w=d>0&&n.levels[c.length-1]%2===1?b-d:b,y=t+e.ascent,P=w,S=-1,v=-1,A=0,{visual:N}=n;for(let B=0;B<N.length;B++){let D=N[B],j=c[D],W=S<0?0:D===S+1?j.kerningBefore:S===D+1?c[S].kerningBefore:0;W!==0&&i.widen(s+(v>=0?v:S),W),P+=W,S=D;let J=j.advance+j.tracking+(h.has(D)?m:0);J!==0&&(v=D),i.set(s+D,j,n.levels[D],P,J,y-j.baselineShift),i.setVisual(s,A++,D),P+=J}let M=w+e.width+g,C=t+e.height,F=i.boxes[a];return s0.box=F!==void 0?F.refill(w,t,M,C,y,e.srcEnd,g>0,s,c.length):i.boxes[a]=new Pt(w,t,M,C,y,e.srcEnd,g>0,i,s,c.length),s0.inkWidth=f+g,s0}function u0(e,t={maxWidth:0,alignWidth:0,lineHeight:0,align:"left",justify:!1,bidi:null,shaper:null,direction:"auto",tabSize:0}){return t.maxWidth=e.maxWidth,bp(t,e),t.lineHeight=e.lineHeight,t.align=e.align,t.justify=e.justify===!0||e.align==="justify",t.bidi=c0(e),t.shaper=Mu(e),t.direction=e.direction??"auto",t.tabSize=e.tabSize??8,t}function bp(e,t){t.alignWidth===void 0?e.alignWidth=t.maxWidth:e.alignWidth=t.alignWidth}function c0(e){return e.bidi??LI()}function Mu(e){return e.shaper??eI()}var F7=[],L7=[],hE=[],_7=u0({maxWidth:0,lineHeight:0,align:"left"}),D7={maxWidth:.5,alignWidth:.5,lineHeight:.5,justify:!1},B7=e=>vi(hE[e]);function H7(e,t,n,r){return sE(t,n,o=>e.mirror(o),r)}function mE(e,t){let{maxWidth:n,alignWidth:r,lineHeight:o,align:i,justify:s,bidi:a,shaper:l,direction:u,tabSize:c}=u0(t,_7),d=iE(e,c,F7,L7,l),f=hE;f.length=d.length;for(let S=0;S<d.length;S++)f[S]=d[S].cp;let p=a?dI(a,f,B7,u):null;a||DI(f);let h=D7;h.maxWidth=n,h.alignWidth=r,h.lineHeight=o,h.justify=s;let m=fE(d,f,h),g=0;for(let S=0;S<m.length;S++)g+=m[S].entries.length;let b=m.length>0?fp.take(g):null,x=b!==null?b.boxes:[],w=0,y=0,P=0;for(let S=0;S<m.length;S++){let v=m[S],A=fI(p,v.start,v.entries.length);a&&(v.entries=H7(a,v.entries,A.levels,e));let N=u!=="auto"?u:_I(v.entries.length>0?p?.baseLevel(v.start)??0:0),M=pE(v,w,A,Sx(i,N),h,b,P,S);P+=v.entries.length,y=Math.max(y,M.inkWidth),w+=v.height}return x.length=m.length,b===null?{lines:x,bounds:{width:y,height:w}}:(b.bounds.width=y,b.bounds.height=w,b.laid??={lines:x,bounds:b.bounds})}Pe();Pe();var Ar=11;function yE(e){let{font:t,glyph:n}=e;return t!==null&&n!==null&&n.width!==0&&n.page>=0}function d0(e,t,n){let r=e.font,o=e.glyph,i=e.fontSize/e.metrics.size,s=e.x+o.xoffset*i,a=e.baselineY+(o.yoffset-e.metrics.base)*i;t[n]=s,t[n+1]=a,t[n+2]=s+o.width*i,t[n+3]=a+o.height*i,t[n+4]=o.x/r.common.scaleW,t[n+5]=o.y/r.common.scaleH,t[n+6]=(o.x+o.width)/r.common.scaleW,t[n+7]=(o.y+o.height)/r.common.scaleH,t[n+8]=e.baselineY,t[n+9]=e.x,t[n+10]=e.rotate??0}var f0=new WeakSet,gE={quads:pp("quads",e=>{f0.add(e);let t=e.quadData,n=[];for(let r=0,o=0;r<t.length;r+=Ar,o++){let i={x0:t[r],y0:t[r+1],x1:t[r+2],y1:t[r+3],u0:t[r+4],v0:t[r+5],u1:t[r+6],v1:t[r+7],baselineY:t[r+8],penX:t[r+9],rotate:t[r+10]};e.colorGlyphs&&(i.colorGlyph=e.colorGlyphs[o]),n.push(i)}return n})};function wE(e,t){return t==="outline"&&xr(e.stroke)?e.stroke:void 0}function bE(e,t){return`${fo(e.fill?.paint)}|${Vl(wE(e,t))}`}function h0(e,t,n){let{family:r,weight:o,style:i}=t.resolved.resolved,{synthetic:s}=t.resolved,a=n==="outline"?0:t.glyph.page;if(qe.group!==null&&qe.run===t.run&&qe.source===n&&qe.page===a&&qe.family===r&&qe.weight===o&&qe.style===i&&qe.bold===s.bold&&qe.italic===s.italic)return qe.group;let l=e[t.run],u=null,c=null;for(let d=0;d<wo.length;d++){let f=wo[d],p=f.group;if(!(p.source!==n||p.page!==a||p.family!==r||p.weight!==o||p.style!==i||p.synthetic.bold!==s.bold||p.synthetic.italic!==s.italic)&&!(f.run!==t.run&&(c??=bE(l,n),f.paint??=bE(e[f.run],n),f.paint!==c))){u=p;break}}if(u===null){let d=wE(l,n);u=d===void 0&&n!=="color"?p0.pop()??null:null,u!==null?(u.family=r,u.weight=o,u.style=i,u.synthetic.bold=s.bold,u.synthetic.italic=s.italic,u.source=n,u.page=a,u.fill=l.fill):(u=Object.defineProperties({family:r,weight:o,style:i,synthetic:{bold:s.bold,italic:s.italic},source:n,page:a,fill:l.fill,quadData:Ys,glyphs:[]},gE),d&&(u.stroke=d),n==="color"&&(u.colorGlyphs=[]));let f=wo.length,p=xE[f];p===void 0?(p={group:u,run:t.run,paint:c},f<U7&&(xE[f]=p)):(p.group=u,p.run=t.run,p.paint=c),wo.push(p)}return qe.group=u,qe.run=t.run,qe.family=r,qe.weight=o,qe.style=i,qe.bold=s.bold,qe.italic=s.italic,qe.source=n,qe.page=a,u}var Ys=[],p0=[],G7=1024;function PE(e){p0.length>=G7||e.stroke!==void 0||e.colorGlyphs!==void 0||f0.has(e)||(e.quadData=Ys,gt(e.glyphs,0),p0.push(e))}var wo=[],xE=[],U7=64,qe={group:null,run:-1,family:"",weight:0,style:"normal",bold:!1,italic:!1,source:"atlas",page:0};function TE(e){for(let t=0;t<wo.length;t++)e.push(wo[t].group),wo[t].group=null;gt(wo,0),qe.group=null}Pe();Z();var SE=5e-4,kE=4096,xp=new Map,wp=new Map;function vE(e){if(!e.synthetic.bold)return null;let{source:t}=e;if(t!=="atlas"&&t!=="canvas")return null;let{family:n,weight:r,style:o}=e.resolved,i=jy(t,n,r,o);return i===void 0||!(i>0)?null:{growth:i,join:t==="atlas"?"miter":"round"}}function W7(e,t,n){let r=vE(n);if(r===null)return e;let o=`${r.growth}|${r.join}|${t}`,i=xp.get(o);return i||(i=Gg(Bg(e,r.growth,{join:r.join,tolerance:SE}),{tolerance:SE}),xp.size>=kE&&xp.clear(),xp.set(o,i),i)}function AE(e,t){let n=vE(t);if(n===null)return null;let r=`bold:${n.growth}:${n.join}`,o=`${r}|${e}`,i=wp.get(o);return i===void 0&&(i=gg(W7(si(e),e,t)),wp.size>=kE&&wp.clear(),wp.set(o,i)),{d:i,tag:r}}function RE(e,t,n,r=!1){let o=e.resolved.source==="outline";if(!o&&!r&&(n===void 0||t.fontSize<n&&!xr(t.stroke)))return null;let i=V7(e);if(i===null)return null;let{family:s,weight:a,style:l}=e.resolved.resolved,u=e.shaped?`${s}|${a}|${l}|#${e.shaped.key}`:`${s}|${a}|${l}|${e.cp}`;if(o||!e.resolved.synthetic.bold)return{d:i,key:u};let c=AE(i,e.resolved);return c&&{d:c.d,key:`${u}|${c.tag}`}}function V7(e){if(e.shaped)return e.shaped.d;if(e.glyph?.color)return null;let{family:t,weight:n,style:r}=e.resolved.resolved;return e.resolved.source!=="outline"&&e.glyph===null?null:Ey(t,n,r,e.cp)}function z7(e){let t=e.resolved.dynamicFace,n=e.shaped;if(!t||n.d===null)return null;let r=t.requestShaped(n.key,n.d);return!r||r.page<0||r.width===0?null:{...e,font:t.font,glyph:r}}function K7(e){let t=e.map(n=>Yo(xn(n.fontFamily,n.fontWeight,n.fontStyle)));return n=>t[n]}var j7=e=>e.underline||e.strikethrough||e.overline;function $7(e){return t=>sf(e[t].fill)?fo(e[t].fill.paint):null}var Y7=n0(),Cu=[],NE=16384;function m0(e,t,n,r){let{groups:o,decorations:i}=r;gt(o,0),gt(i,0);let s=t.some(j7)?K7(t):null,a=s&&$7(t),l=0,{lines:u}=e;for(let h=0;h<u.length;h++)l+=Pt.count(u[h]);let c=l*Ar;c<=NE&&Cu.length<c&&(Cu=Ai(c));let d=c<=NE?Cu:Ai(c),f=null,p=0;for(let h=0;h<u.length;h++){let m=u[h],g=Pt.columns(m),b=g!==null?Pt.start(m):0,x=Pt.count(m),w=s&&uI(t,s,a);for(let y=0;y<x;y++){let P=g!==null?g.visual(b,y):-1,S=g!==null?g.glyph(b,P,Y7):m.glyphs[y];w?.add(S);let v=t[S.run],A=g!==null?g.drawsInk(b,P):m.cells[S.cell].drawsInk,N=A?RE(S,v,n.outlineMinSize):null,M=S;if(A&&N===null&&S.shaped){let B=z7(S);B?M=B:N=RE(S,v,n.outlineMinSize,!0)}if(!sf(v.fill)&&!(N!==null&&xr(v.stroke)))continue;if(N!==null){let B={...N,x:S.x,baselineY:S.baselineY,scale:S.fontSize};S.rotate&&(B.rotate=S.rotate),h0(t,S,"outline").glyphs.push(B);continue}if(!yE(M))continue;let C=h0(t,M,M.glyph.color?"color":M.resolved.source);f===null&&(f=C,C.quadData=d);let F=C.quadData;F===Ys&&(C.quadData=F=[]),C===f?(d0(M,F,p),p+=Ar):d0(M,F,F.length),C.colorGlyphs?.push(M.glyph)}if(w)for(let y of w.end()){let{run:P,...S}=y;i.push({...S,fill:t[P].fill})}}if(f!==null&&d!==Cu)d.length=p;else if(f!==null){let h=Nu(p);for(let m=0;m<p;m++)h[m]=Cu[m];f.quadData=h}return TE(o),r}var y0=new WeakMap,q7=[];function g0(e){return y0.get(e)}function Pp(e){let t=y0.get(e);return t===void 0&&(t=q7.pop()??{generation:-1,variants:[],painting:null,paintedOn:null,paintedStamp:0,paintMin:void 0,listed:null},y0.set(e,t)),t}var X7=32,Tp=new WeakMap;function J7(e){return e.lines.length>0?Pt.columns(e.lines[0])?.stamp??0:0}function Q7(e){let t=e.lines.length>0?Pt.columns(e.lines[0]):null;if(t!==null)return t.paintings;let n=Tp.get(e);return n===void 0&&Tp.set(e,n=[]),n}var x0=[],Z7=1024;function IE(e,t,n,r,o,i){let s=x0.pop();return s===void 0?{generation:r,key:o,bucket:i,runs:o===null?t:null,painted:m0(e,t,n,{groups:[],decorations:[]}),pinned:!1}:(s.generation=r,s.key=o,s.bucket=i,s.runs=o===null?t:null,s.pinned=!1,m0(e,t,n,s.painted),s)}function e5(e,t){if(t===void 0)return-1;let n=0;for(let r=0;r<e.length;r++){let o=e[r].fontSize;if(!(o>=t))continue;let i=!1;for(let s=0;s<r&&!i;s++)i=e[s].fontSize===o;i||n++}return n}function EE(e,t){let n=`${t}`;for(let r of e)n+=`|${r.underline?1:0}${r.strikethrough?1:0}${r.overline?1:0}${fo(r.fill?.paint)}|${Vl(r.stroke)}`;return n}function ME(e){return e.key===null&&(e.key=EE(e.runs,e.bucket),e.runs=null),e.key}function w0(e,t,n={},r="keep"){let o=qo(),i=n.outlineMinSize,s=g0(t),a=J7(e),l=s!==void 0&&s.paintedOn===e&&s.paintedStamp===a?s.painting:null,u=l!==null&&l.generation===o;if(u&&s.paintMin===i)return b0(l,r);let c=e5(t,i);if(u&&l.bucket===c)return s.paintMin=i,b0(l,r);let d=Q7(e),f=null;if(d.length>0){let h=EE(t,c);for(let m=0;m<d.length;m++){let g=d[m];if(!(g.bucket!==c||ME(g)!==h)){d.splice(m,1),g.generation===o&&(f=g);break}}f??=IE(e,t,n,o,h,c)}else f=IE(e,t,n,o,null,c);d.length>=X7&&d.shift(),d.push(f);let p=s??Pp(t);return p.painting!==null&&p.painting!==f&&CE(p.painting,t),p.paintedOn=e,p.paintedStamp=a,p.painting=f,p.paintMin=i,b0(f,r)}function CE(e,t){e.runs===t&&ME(e)}function b0(e,t){return t==="keep"&&(e.pinned=!0),e.painted}function OE(e){let t=e.lines.length>0?Pt.columns(e.lines[0]):null,n;if(t!==null)n=t.paintings;else{if(n=Tp.get(e),n===void 0)return;Tp.delete(e)}for(let r=0;r<n.length;r++){let o=n[r];if(o.pinned)continue;let{groups:i}=o.painted;for(let s=0;s<i.length;s++){let a=i[s];a.quadData.length>0&&up(a.quadData),a.quadData=Ys,PE(a)}gt(i,0),gt(o.painted.decorations,0),o.runs=null,o.key=null,x0.length<Z7&&x0.push(o)}gt(n,0)}var UE=8,WE=64,Rr=[],FE=-1,LE=0,Mn=(e,t)=>e===t||e!==e&&t!==t;function VE(e,t,n){return Mn(e.maxWidth,t.maxWidth)&&Mn(e.alignWidth,t.alignWidth??t.maxWidth)&&Mn(e.lineHeight,t.lineHeight)&&e.align===t.align&&e.justify===(t.justify===!0||t.align==="justify")&&e.direction===(t.direction??"auto")&&Mn(e.tabSize,t.tabSize??8)&&e.bidi===n&&e.shaper===Mu(t)}var Js=e=>e.lines.length>0?Pt.columns(e.lines[0]):null;function _E(e,t){if(t==="keep"){let n=Js(e);n!==null&&(n.pinned=!0)}return e}function zE(e){let t=Js(e);t===null||t.owners>0||t.listed||t.pinned||(OE(e),t.recycle())}var T0=[],t5=1024;function DE(e){for(let t=0;t<e.length;t++){let n=e[t],r=Js(n.laid);r!==null&&(r.owners--,zE(n.laid)),n.laid=n5,T0.length<t5&&T0.push(n)}gt(e,0)}var n5={lines:[],bounds:{width:0,height:0}};function S0(e,t,n,r){return e.maxWidth=t.maxWidth,bp(e,t),e.lineHeight=t.lineHeight,e.align=t.align,e.justify=t.justify===!0||t.align==="justify",e.direction=t.direction??"auto",e.tabSize=t.tabSize??8,e.bidi=n,e.shaper=Mu(t),e.laid=r,e}function r5(e,t,n){let r=T0.pop();if(r!==void 0)return S0(r,e,t,n);let o={maxWidth:e.maxWidth,alignWidth:e.maxWidth,lineHeight:e.lineHeight,align:e.align,justify:e.justify===!0||e.align==="justify",direction:e.direction??"auto",tabSize:e.tabSize??8,bidi:t,shaper:Mu(e),laid:n};return bp(o,e),o}function Xs(e,t){return Math.imul(e^t,16777619)}function qs(e,t){return Xs(e,t===(t|0)?t:Math.round(t*4096))}function P0(e,t){e=Xs(e,t.length);for(let n=0;n<t.length;n++)e=Xs(e,t.charCodeAt(n));return e}function o5(e){let t=Xs(2166136261,e.length);for(let n=0;n<e.length;n++){let r=e[n];t=P0(t,r.text),t=P0(t,r.fontFamily),t=qs(t,r.fontSize),t=qs(t,r.fontWeight),t=Xs(t,r.fontStyle==="italic"?1:0),t=qs(t,r.letterSpacing),t=qs(t,r.baselineShift),t=qs(t,r.rotate??0),t=qs(t,r.strutSize??-1),t=Xs(t,r.fontFeatures?.length??0),t=P0(t,r.lang??"")}return t&1073741823}var BE=[];function HE(e,t){return e===t||e!==void 0&&t!==void 0&&Yc(e,t,Mn)}var i5=(e,t)=>Yc(e??BE,t??BE);function s5(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],o=t[n];if(r===o)continue;if(r.text!==o.text||r.fontFamily!==o.fontFamily||!Mn(r.fontSize,o.fontSize)||!Mn(r.fontWeight,o.fontWeight)||r.fontStyle!==o.fontStyle||!Mn(r.letterSpacing,o.letterSpacing)||!Mn(r.baselineShift,o.baselineShift)||!Mn(r.strutSize,o.strutSize)||!Mn(r.rotate??0,o.rotate??0)||!HE(r.sizeMap,o.sizeMap)||!i5(r.fontFeatures,o.fontFeatures)||r.lang!==o.lang)return!1;let i=r.srcMap,s=o.srcMap;if(i!==s&&(i===void 0||s===void 0||i.length!==s.length||!HE(i.starts,s.starts)))return!1}return!0}function Ou(e,t,n="keep"){let r=rl(),o=c0(t),i=Pp(e);if(i.generation!==r)i.generation=r,DE(i.variants);else{let u=i.variants;for(let c=0;c<u.length;c++){let d=u[c];if(VE(d,t,o)){for(let f=c;f>0;f--)u[f]=u[f-1];return u[0]=d,_E(d.laid,n)}}}let s=a5(e,t,o,r,i),a=i.variants;a.length>=UE&&DE(a),a.unshift(r5(t,o,s));let l=Js(s);return l!==null&&l.owners++,_E(s,n)}function a5(e,t,n,r,o){if(FE!==r){for(let d of Rr)GE(d),d.runs=l5;Rr=[],FE=r}let i=o5(e),s=0;for(let d=0;d<Rr.length;d++){let f=Rr[d];if(f.hash===i&&VE(f,t,n)&&s5(f.runs,e))return f.used=++LE,f.laid;f.used<Rr[s].used&&(s=d)}let a=Rr.length>=WE;a&&GE(Rr[s]);let l=mE(e,t),u=a?S0(Rr[s],t,n,l):u5(t,n,l);u.hash=i,u.runs=e,u.used=++LE,o.listed=u;let c=Js(l);return c!==null&&(c.listed=!0),a||Rr.push(u),l}var l5=[];function u5(e,t,n){return S0({maxWidth:0,alignWidth:0,lineHeight:0,align:"left",justify:!1,direction:"auto",tabSize:0,bidi:null,shaper:null,laid:n,hash:0,runs:[],used:0},e,t,n)}function GE(e){let t=Js(e.laid);t!==null&&(t.listed=!1,zE(e.laid))}function Fu(e,t,n){if(e===void 0||e==="top"||t===void 0)return 0;let r=t-n;return e==="center"?r/2:r}function Sp(e,t=1){let n=kx(e.style,{fill:e.fill,stroke:e.stroke},t),r=e.runs&&e.runs.length>0?e.runs:e.text;return{style:n,runs:xu(WN(r),n,t),opts:{maxWidth:n.wrap?e.width:1/0,alignWidth:e.width,lineHeight:n.lineHeight,align:n.align,direction:n.direction,tabSize:n.tabSize,justify:n.align==="justify"}}}function k0(e,t=1){let{runs:n,opts:r}=Sp(e,t),o=Ou(n,r);return{laid:o,x:e.x,y:e.y+Fu(e.verticalAlign,e.height,o.bounds.height)}}function kp(e,t={}){let n=t.padding??0,{laid:r,x:o,y:i}=k0(e),s=[];for(let a of r.lines)!t.includeEmpty&&a.x1<=a.x0||s.push({x:a.x0+o-n,y:a.y0+i-n,width:a.x1-a.x0+n*2,height:a.y1-a.y0+n*2});return s}function Po(e){if(!e)return c5;let t=e*Math.PI/180;return[Math.cos(t),Math.sin(t)]}var c5=[1,0];var To={maxWidth:0,alignWidth:void 0,lineHeight:0,align:"left",direction:"auto",tabSize:0,justify:void 0},vp={laid:null,dx:0,dy:0};function Ap(e){let t=e.style;To.maxWidth=e.maxWidth??1/0,To.alignWidth=e.width,To.lineHeight=t.lineHeight??Ie.lineHeight,To.align=e.align??t.align??Ie.align,To.direction=e.direction??t.direction??Ie.direction,To.tabSize=t.tabSize??Ie.tabSize,To.justify=e.justify;let n=Ou(e.runs,To,"read");return vp.laid=n,vp.dx=e.x,vp.dy=e.y+Fu(e.verticalAlign,e.height,n.bounds.height),vp}var Rp={side:.5,above:1.5,below:1};function KE(e,t){let{laid:n,dx:r,dy:o}=Ap(e),i=q.meanScaleOf(t),s=q.minScaleOf(t),a=e.runs.map(f=>f.stroke?Qs(f.stroke,i,s):0),l=1/0,u=1/0,c=-1/0,d=-1/0;for(let f of n.lines)for(let p of f.glyphs){let h=p.fontSize,m=a[p.run]??0,g=-Rp.side*h-m,b=p.advance+Rp.side*h+m,x=-Rp.above*h-m,w=Rp.below*h+m,[y,P]=Po(p.rotate);for(let S=0;S<4;S++){let v=S===0||S===3?g:b,A=S<2?x:w,N=p.x+v*y-A*P,M=p.baselineY+v*P+A*y;N<l&&(l=N),N>c&&(c=N),M<u&&(u=M),M>d&&(d=M)}}return l===1/0?null:Ni(l+r,u+o,c+r,d+o,t)}var d5=4,Ii={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Ei={minX:-1/0,minY:-1/0,maxX:1/0,maxY:1/0};function A0(e,t,n){let r=Ii;for(let o of e)if(r=h5(r,R0(o,t,n)),r===Ei)break;return r}function R0(e,t,n){switch(e.kind){case"group":{let r=e.transform?q.multiply(t,e.transform):t,o=A0(e.children,r,n);return e.effects&&e.effects.length>0&&(o=p5(o,Gs(e.effects)/n)),e.clip?N0(o,Np(e.clip,void 0,r)):o}case"path":case"image":case"sprites":return I0(e,t)??Ei;case"text":return KE(e,t)??Ii;case"shader":return f5(e)??Ei}}function f5(e){let t=Nn(e.program.id);if(!t||t.vert!==""||/\bgl_FragCoord\b/.test(t.frag)&&!/\bu_fragOrigin\b/.test(t.frag))return null;let{x:n,y:r,w:o,h:i}=e.bounds;return{minX:Math.min(n,n+o),minY:Math.min(r,r+i),maxX:Math.max(n,n+o),maxY:Math.max(r,r+i)}}function p5(e,t){return e===Ii||e===Ei||t===0?e:Number.isFinite(t)?{minX:e.minX-t,minY:e.minY-t,maxX:e.maxX+t,maxY:e.maxY+t}:Ei}function h5(e,t){return e===Ii||t===Ei?t:t===Ii||e===Ei?e:{minX:Math.min(e.minX,t.minX),minY:Math.min(e.minY,t.minY),maxX:Math.max(e.maxX,t.maxX),maxY:Math.max(e.maxY,t.maxY)}}function N0(e,t){if(!t||e===Ii)return e;let n={minX:Math.max(e.minX,t.minX),minY:Math.max(e.minY,t.minY),maxX:Math.min(e.maxX,t.maxX),maxY:Math.min(e.maxY,t.maxY)};return n.minX>n.maxX||n.minY>n.maxY?Ii:n}function I0(e,t){switch(e.kind){case"path":return Np(e.path,e.stroke,t);case"image":return Ni(e.x,e.y,e.x+e.w,e.y+e.h,t);case"sprites":return y5(e.sprites,t)}}function Np(e,t,n){let r,o,i,s;if(e.kind==="rect")r=Math.min(e.x,e.x+e.width),i=Math.max(e.x,e.x+e.width),o=Math.min(e.y,e.y+e.height),s=Math.max(e.y,e.y+e.height);else if(e.kind==="polygon"){let l=e.coords;if(l.length<2)return null;r=i=l[0],o=s=l[1];for(let c=2;c+1<l.length;c+=2){let d=l[c],f=l[c+1];d<r?r=d:d>i&&(i=d),f<o?o=f:f>s&&(s=f)}let u=e.origin;u&&(r+=u.x,i+=u.x,o+=u.y,s+=u.y)}else return null;let a=t?m5(t,n):0;return Ni(r-a,o-a,i+a,s+a,n)}function m5(e,t){return Qs(e,q.meanScaleOf(t),q.minScaleOf(t))}function Qs(e,t,n=t){let r=n>0?n:t,o=at(e.width??1,typeof e.width=="object"?r:t),i=Pi(o,e.vertexWidths),s=Math.max(e.miterLimit??d5,Math.SQRT2),a=gu(e);return Math.max(Math.abs(i)*s,a.world,Gt({px:a.px},r))}function y5(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let s=0;s+9<=e.length;s+=9){let a=e[s],l=e[s+1],u=a+e[s+2],c=l+e[s+3];n=Math.min(n,a,u),o=Math.max(o,a,u),r=Math.min(r,l,c),i=Math.max(i,l,c)}return n===1/0?null:Ni(n,r,o,i,t)}function Ni(e,t,n,r,o){let[i,s]=q.apply(o,e,t),[a,l]=q.apply(o,n,t),[u,c]=q.apply(o,n,r),[d,f]=q.apply(o,e,r);return{minX:Math.min(i,a,u,d),minY:Math.min(s,l,c,f),maxX:Math.max(i,a,u,d),maxY:Math.max(s,l,c,f)}}var Nr=1;function M0(e,t,n,r){return jE(e,t,$E(n),r)}function jE(e,t,n,r){let o=null;for(let i=0;i<e.length;i++){let s=e[i],a=g5(s,t,n,r);if(a===s){o?.push(s);continue}o??=e.slice(0,i),a&&o.push(a)}return o??e}function g5(e,t,n,r){switch(e.kind){case"group":{if($n(e.composite))return e;if(e.effects&&e.effects.length>0)return E0(R0(e,t,r),n)?null:e;let o=e.transform?q.multiply(t,e.transform):t,i=jE(e.children,o,n,r);return i===e.children?e:i.length===0?null:{...e,children:i}}case"path":case"image":case"sprites":return E0(I0(e,t),n)?null:e;default:return e}}function C0(e,t,n){let r=Math.min(e.x,e.x+e.width),o=Math.max(e.x,e.x+e.width),i=Math.min(e.y,e.y+e.height),s=Math.max(e.y,e.y+e.height);return E0(Ni(r,i,o,s,t),$E(n))}function $E(e){return{minX:e.x-Nr,minY:e.y-Nr,maxX:e.x+e.width+Nr,maxY:e.y+e.height+Nr}}function E0(e,t){return e!==null&&(e.maxX<t.minX||e.minX>t.maxX||e.maxY<t.minY||e.minY>t.maxY)}function Lu(e,t,n,r){let o=A0(e,t,r);for(let i of n)o=N0(o,Np(i.path,void 0,i.transform));return b5(o,r)}function b5(e,t){let n=Math.floor((e.minX-Nr)*t),r=Math.floor((e.minY-Nr)*t),o=Math.ceil((e.maxX+Nr)*t),i=Math.ceil((e.maxY+Nr)*t);return[n,r,o,i].some(Number.isNaN)?{x0:-1/0,y0:-1/0,x1:1/0,y1:1/0}:{x0:n,y0:r,x1:o,y1:i}}function Mi(e,t){let n=Math.max(t.x,e.x0),r=Math.max(t.y,e.y0),o=Math.min(t.x+t.width,e.x1),i=Math.min(t.y+t.height,e.y1);return o<=n||i<=r?{x:0,y:0,width:0,height:0}:{x:n,y:r,width:o-n,height:i-r}}Z();function Zs(e,t,n,r){let o=e.gl,i=e.renderTarget??null;o.bindFramebuffer(o.FRAMEBUFFER,i?i.fbo:null),i?i.restore?i.restore():o.viewport(0,0,t,n):(e.restoreTargetRect?.(),r&&o.enable(o.SCISSOR_TEST))}function O0(e,t,n,r,o,i,s,a){let l=e.gl;l.useProgram(t.handle);let u=t.attribute("a_position"),c=t.attribute("a_uv");l.bindBuffer(l.ARRAY_BUFFER,e.quadVbo),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.quadIbo),u!==void 0&&u>=0&&(l.enableVertexAttribArray(u),l.vertexAttribPointer(u,2,l.FLOAT,!1,16,0)),c!==void 0&&c>=0&&(l.enableVertexAttribArray(c),l.vertexAttribPointer(c,2,l.FLOAT,!1,16,8)),l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,n);let d=t.uniform("u_source");d!==void 0&&l.uniform1i(d,0);let f=t.uniform("u_resolution");f!==void 0&&l.uniform2f(f,r,o);let p=t.uniform("u_texel");if(p!==void 0&&l.uniform2f(p,1/r,1/o),s){let h=t.uniform("u_alpha");h!==void 0&&l.uniform1f(h,s.alpha),Rn(e,t,s.colorMatrix)}i&&Wb(l,t,a??"effect",i,e.textureCache,{value:1}),De(e,6,e.gl.UNSIGNED_SHORT),u!==void 0&&u>=0&&l.disableVertexAttribArray(u),c!==void 0&&c>=0&&l.disableVertexAttribArray(c),l.bindBuffer(l.ARRAY_BUFFER,null),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null)}function Ip(e,t,n,r,o){let i=e.gl,s=e.deviceWidth,a=e.deviceHeight,l=e.renderTarget??null,[u,c]=(l?l.fragOrigin:e.fragOrigin)??[0,0];i.viewport(u+r.x,c+a-r.y-r.height,r.width,r.height),O0(e,t,n,r.width,r.height,void 0,o),l?l.restore?l.restore():i.viewport(0,0,s,a):e.restoreTargetRect?.()}function Ep(e,t){let n=q.screenToClip(e.width/t,e.height/t);return q.toUniform(q.translated(n,-e.x/t,-e.y/t))}function _u(e,t,n){return e.x>=0&&e.y>=0&&e.x+e.width<=t&&e.y+e.height<=n}var Mp=64;function x5(e,t,n,r,o,i,s){let a=e.effects&&e.effects.length>0?Gs(e.effects):0;if(!Number.isFinite(a))return{x:0,y:0,width:r,height:o};if($n(e.composite)&&!RR(e.composite))return n;let l=Math.ceil(a),u={x:n.x-l,y:n.y-l,width:n.width+2*l,height:n.height+2*l},c=Lu([{...e,clip:void 0}],t,[],i),d=Mi(c,u);if(d.width===0||d.height===0)return null;let f=Math.min(s,Math.ceil(d.width/Mp)*Mp),p=Math.min(s,Math.ceil(d.height/Mp)*Mp),h=_u(d,r,o);return{x:h&&f<=r?Math.min(d.x,r-f):d.x,y:h&&p<=o?Math.min(d.y,o-p):d.y,width:f,height:p}}function YE(e,t,n,r,o,i){let s=e.gl,a=e.renderTarget??null,l=r/e.widthCss,u=x5(t,e.state.transform,a?.window??{x:0,y:0,width:r,height:o},r,o,l,e.imageCache.maxTextureSide);if(!u)return;an(e);let c=e.clipDepth,d=e.clipStack,f=e.drawBatch.clip,p=e.projection,h=s.isEnabled(s.SCISSOR_TEST),m=n.acquire(u.width,u.height),g=e.state.pushIsolated({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix});e.clipDepth=0,e.clipStack=[],e.drawBatch.clip=null;let b=_u(u,r,o);e.projection=b?void 0:Ep(u,l);let x=()=>{b?s.viewport(-u.x,u.y+u.height-o,r,o):s.viewport(0,0,u.width,u.height),s.disable(s.SCISSOR_TEST)};e.renderTarget={fbo:m.fbo,restore:x,fragOrigin:[-u.x,u.y+u.height-o],window:u},s.bindFramebuffer(s.FRAMEBUFFER,m.fbo),x(),s.stencilMask(255),s.clear(s.COLOR_BUFFER_BIT|s.STENCIL_BUFFER_BIT);for(let y of t.children)i(e,y);ye(e),s.disable(s.BLEND),s.disable(s.STENCIL_TEST);for(let y of t.effects??[]){let P=e.ensureProgram?.(y.program.id)??null;if(!P){Ub(y.program.id,"(program)");continue}let S=n.acquire(u.width,u.height);s.bindFramebuffer(s.FRAMEBUFFER,S.fbo),s.viewport(0,0,u.width,u.height),s.clear(s.COLOR_BUFFER_BIT),O0(e,P,m.texture,u.width,u.height,y.uniforms,void 0,y.program.id),n.release(m),m=S}s.enable(s.BLEND),e.state.pop(),e.clipDepth=c,e.clipStack=d,e.drawBatch.clip=f,e.projection=p,e.renderTarget=a,Zs(e,r,o,h);let w=e.ensureProgram?.(Hf())??null;if(w){wt(e);let y=$n(t.composite);y&&Db(s,t.composite),Ip(e,w,m.texture,u,g),y&&Db(s,"source-over")}n.release(m)}var w5=new WeakMap,P5=new WeakMap;function F0(e,t){let n=t?w5:P5,r=n.get(e);if(r!==void 0)return r;let o=e.every(i=>T5(i,t));return n.set(e,o),o}function T5(e,t){switch(e.kind){case"group":return e.effects&&e.effects.length>0&&!Number.isFinite(Gs(e.effects))?!1:F0(e.children,t);case"path":return Cp(e.fill?.paint,t)&&Cp(e.stroke?.paint,t);case"text":return e.runs.every(n=>Cp(n.fill?.paint,t,!0)&&Cp(n.stroke?.paint,t,!0));case"image":case"sprites":return!0;case"shader":return!1}}function Cp(e,t,n=!1){if(!e||e.kind===void 0||e.kind==="solid")return!0;if(n&&e.kind==="texture")return!1;let r="units"in e?e.units:void 0;return r==="local"||r==="world"&&t}var S5={alpha:1,colorMatrix:Ut},qE=new WeakSet;function XE(e,t,n,r){let o=e.retained,i=e.deviceWidth,s=e.deviceHeight;if(!o||!i||!s)return!1;if(e.renderTarget!=null&&qE.has(e.renderTarget)||$n(t.composite)||_b(t.children))return o.decline(),!1;let l=t.retain;e.state.push({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix});let u=e.clipStack.map(({path:y,transform:P})=>({path:y,transform:P}));t.clip&&u.push({path:t.clip,transform:e.state.transform});let c={children:t.children,transform:e.state.transform,alpha:e.state.alpha,colorMatrix:e.state.colorMatrix,viewMatrix:e.viewMatrix,screenMatrix:e.screenMatrix,clips:u,effects:t.effects,isolate:t.isolate===!0,window:e.renderTarget?.window},d=!e.renderTarget,f=n?[{kind:"group",effects:t.effects,isolate:t.isolate,children:t.children}]:t.children,p=i/e.widthCss,h=d&&F0(f,e.viewMatrix!==void 0),m=o.lookup(l,i,s,c,d,h?p:void 0),g;if(m.kind==="through")return e.state.pop(),!1;if(m.kind==="kept")g=m.pixels;else{let y=c.window??m.window,P=Lu(f,e.state.transform,u,p),S=o.reserve(l,i,s,Mi(P,y),d,h?{box:P,window:y}:void 0);if(!S)return e.state.pop(),!1;ye(e),S.fbo&&k5(e,f,u,S.fbo,S,r),g=S.commit(c)}e.state.pop();let{texture:b,rect:x}=g;if(!b)return!0;ye(e);let w=e.ensureProgram?.(Hf())??null;return w&&(wt(e,0),Ip(e,w,b,x,S5)),!0}function k5(e,t,n,r,o,i){let s=e.gl,a=e.deviceWidth,l=e.deviceHeight,{rect:u,tiles:c}=o,d=e.renderTarget??null,f=e.clipDepth,p=e.clipStack,h=e.drawBatch.clip,m=e.projection,g=s.isEnabled(s.SCISSOR_TEST),b=a/e.widthCss,x=_u(u,a,l);e.projection=x?void 0:Ep(u,b);let w=c.length>1?t.map(y=>Lu([y],e.state.transform,[],b)):null;for(let y of c){let P=y.y+y.height,S=()=>{x?s.viewport(-y.x,P-l,a,l):s.viewport(u.x-y.x,P-u.y-u.height,u.width,u.height),s.scissor(0,0,y.width,y.height),s.enable(s.SCISSOR_TEST)},v={fbo:r,restore:S,fragOrigin:[-y.x,P-l],window:y};qE.add(v),e.renderTarget=v,e.clipDepth=0,e.clipStack=[],e.drawBatch.clip=null,s.bindFramebuffer(s.FRAMEBUFFER,r),S(),s.stencilMask(255),s.clear(s.COLOR_BUFFER_BIT|s.STENCIL_BUFFER_BIT);for(let A of n)uu(e,A.path,A.transform);for(let A=0;A<t.length;A++)(!w||v5(w[A],y))&&i(e,t[A]);ye(e),o.resolve(y)}e.clipDepth=f,e.clipStack=p,e.drawBatch.clip=h,e.projection=m,e.renderTarget=d,Zs(e,a,l,g)}function v5(e,t){return e.x0<t.x+t.width&&e.x1>t.x&&e.y0<t.y+t.height&&e.y1>t.y}Pe();var ea=xt(),Bu=ea.reflection;function QE(e){if(e.inPoseFrame===void 0!=(e.toBoundsFrame===void 0)){let t=e.inPoseFrame===void 0?"inPoseFrame":"toBoundsFrame";throw new Error(`weasel registerPaintKind: kind "${e.id}" is missing ${t}. A kind that converts one frame direction and not the other drifts on the next resize; supply both or neither.`)}for(let[t,n]of Object.entries(e.programs??{})){let r=Nn(t);(!r||r.vert!==n.vert||r.frag!==n.frag)&&Bf(t,n.vert,n.frag)}return ea.push(e.id,e)}function Ci(e){let t=e??"solid",n=ea.get(t);return!n&&Du.has(t)&&ZE(t).catch(()=>{}),n}var Du=new Map,JE=new Map;function ZE(e){let t=JE.get(e);if(t)return t;let r=Du.get(e)().then(o=>{if(o.id!==e)throw new Error(`weasel: the loader for paint kind "${e}" resolved to "${o.id}".`);ea.has(e)||QE(o)}).catch(o=>{throw console.error(`weasel: paint kind "${e}" failed to load:`,o),o});return JE.set(e,r),r}function L0(e){return ea.has(e)||Du.has(e)}function _0(e){let t=e??[...Du.keys()],n=[];for(let r of t)if(!ea.has(r)){if(!Du.has(r))return Promise.reject(new Error(`weasel warmPaintKinds: "${r}" is neither registered nor loadable.`));n.push(ZE(r))}return Promise.all(n).then(()=>{})}var D0=8,A5=1/8;function Op(e,t){if(!(e>0)||!(t>0)||!Number.isFinite(t))return t;let n=Math.ceil(Math.LN2/(2*Math.log1p(A5/e)));return 2**(Math.round(Math.log2(t)*n)/n)}var eM=new WeakMap;function R5(e,t,n){let r=at(e.width??1,1),o=Vs(e,r),i=n.ribbon?.metric;return[r,e.cap??"butt",e.join??"miter",e.miterLimit??"",e.align??"center",(e.dash??[]).join(","),e.varyingWidthJoinThreshold??"",e.nib?`${e.nib.angle}:${e.nib.ratio}`:"",t??"",o.start,o.end,mo(i),mo(n.start?.metric),mo(n.end?.metric)].join("|")}function Fp(e,t,n,r={}){let o=eM.get(e);o===void 0&&(o=new Map,eM.set(e,o));let i=R5(t,n,r),s=o.get(i);if(s!==void 0&&s.vertexWidths===t.vertexWidths)return s.mesh;let a=at(t.width??1,1),l=Vs(t,a),u=Ti(e,t,{flattenTolerance:n,startInset:tM(l.start,r.start,r.ribbon),endInset:tM(l.end,r.end,r.ribbon),metric:r.ribbon?.metric});return s===void 0&&o.size>=D0&&o.clear(),o.set(i,{mesh:u,vertexWidths:t.vertexWidths}),u}function tM(e,t,n){return t?.metric===n?.metric?e:{length:e,metric:t?.metric??null}}var N5={};function Hu(e,t,n={}){let r=n.quantize===!1?(m,g)=>g:Op,o=t.stroke,{markerStart:i,markerMid:s,markerEnd:a}=o;if(typeof o.width!="object"&&!ta(i)&&!ta(s)&&!ta(a))return{cmd:t,spaces:N5};let l={...o},{scale:u,metric:c}=du(e[0],e[1],e[3],e[4]),d=m=>c===null?void 0:{metric:c,pxPerUnit:m},f;if(typeof o.width=="object"){let m=r(o.width.px,u);l.width=at(o.width,m),o.dash&&m>0&&(l.dash=o.dash.map(g=>g/m)),f=d(m)}let p=m=>{if(m===void 0||typeof m=="string"||m.size===void 0)return f;if(typeof m.size!="number")return d(r(m.size.px,u))},h={ribbon:f,start:p(i),mid:p(s),end:p(a)};return ta(i)&&(l.markerStart=B0(i,u,r)),ta(s)&&(l.markerMid=B0(s,u,r)),ta(a)&&(l.markerEnd=B0(a,u,r)),{cmd:{...t,stroke:l},spaces:h}}function ta(e){return typeof e=="object"&&typeof e.size=="object"}function B0(e,t,n){return{...e,size:Ws(e,0,n(e.size.px,t))}}Z();Pe();function nM(e,t){if(!M5(e))return Ci(e.kind)?.inPoseFrame?.(e,t)??e;if(I5(e)){let r=e.origin??{x:0,y:0};return{...e,origin:{x:t.x+r.x,y:t.y+r.y},units:"local"}}if(!E5(e))return e;let n=r=>({x:t.x+r.x*t.width,y:t.y+r.y*t.height});if(e.kind==="linear-gradient")return{...e,from:n(e.from),to:n(e.to),units:"local"};if(e.kind==="radial-gradient"){let r=Math.hypot(t.width,t.height)/Math.SQRT2;return{...e,center:n(e.center),radius:e.radius*r,units:"local"}}return{...e,center:n(e.center),units:"local"}}function I5(e){return af(e)&&e.units==="bounds"}function E5(e){if(e===void 0)return!1;let t=e.kind;return t!=="linear-gradient"&&t!=="radial-gradient"&&t!=="conic-gradient"?!1:e.units==="bounds"}function M5(e){let t=e.kind??"solid";return t==="solid"||af(e)||t==="linear-gradient"||t==="radial-gradient"||t==="conic-gradient"}Pe();function rM(e){let t;try{t=new OffscreenCanvas(e.size,e.size)}catch{if(typeof document>"u")return null;let r=document.createElement("canvas");r.width=e.size,r.height=e.size,t=r}let n=t.getContext("2d");return!n||(e.draw(n,e.size),typeof t.transferToImageBitmap!="function")?null:t.transferToImageBitmap()}var C5=4096*4096,O5=4,F5=300,L5=150,_5=256*1024*1024,Nt=new Map,oM=_5,G0=0,iM=0,D5=Me(),Lp=new Map;function U0(e){return/^data:image\/svg\+xml[;,]/i.test(e)?!0:/^(data|blob):/i.test(e)?!1:/\.svgz?$/i.test(e.replace(/[?#].*$/,""))}function B5(){if(typeof Image>"u"||typeof createImageBitmap>"u")throw new Error("weasel imageCache: no DOM image loader in this environment")}async function aM(e){let t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}function H5(e){let t=Lp.get(e);return t||(t=aM(e),Lp.set(e,t),t.catch(()=>Lp.delete(e))),t}async function G5(e,t){let n=await H5(e),r=t?.width??(n.naturalWidth||F5),o=t?.height??(n.naturalHeight||L5),i=typeof OffscreenCanvas<"u"?new OffscreenCanvas(r,o):Object.assign(document.createElement("canvas"),{width:r,height:o}),s=i.getContext("2d");if(!s)throw new Error("weasel imageCache: no 2D context to rasterize an SVG");return s.drawImage(n,0,0,r,o),createImageBitmap(i)}var U5=async(e,t)=>(B5(),U0(e)?G5(e,t):createImageBitmap(await aM(e))),lM=U5;function H0(){D5.emit()}var sM=e=>e?e.width*e.height*4:0;function uM(e){let t=0;for(let n of Nt.values())t+=sM(n.bitmap);if(t>oM){let n=[...Nt].filter(([r,o])=>r!==e&&o.bitmap!==void 0&&o.readAt<=iM&&!LA(o.bitmap));n.sort((r,o)=>r[1].readAt-o[1].readAt);for(let[r,o]of n){if(t<=oM)break;t-=sM(o.bitmap),fM(r)}}iM=G0}function W5(e){let t={status:"loading",readAt:++G0};Nt.set(e,t),lM(e).then(n=>{Nt.get(e)===t&&(Nt.set(e,{status:"ready",bitmap:n,readAt:t.readAt,...U0(e)?{vector:{natural:{width:n.width,height:n.height},scale:1,failed:new Set,floor:0}}:{}}),uM(e),H0())},()=>{Nt.get(e)===t&&(Nt.set(e,{status:"error",readAt:t.readAt}),H0())})}function V5(e,t){let n=Math.max(t.width/e.width,t.height/e.height);if(!(n>0)||!Number.isFinite(n))return;let r=_A(),o=Math.min(r/e.width,r/e.height,Math.sqrt(C5/(e.width*e.height)));return Math.min(2**Math.ceil(Math.log2(n)),o)}function z5(e,t,n,r){if(n.pending!==void 0)return;let o=V5(n.natural,r);if(o===void 0)return;let i=o>n.scale;i&&n.shrunkTo===n.scale&&(n.floor=Math.max(n.floor,o));let s=i?o:Math.max(o,n.floor);if(!i&&s*O5>n.scale)return;for(let l of n.failed)if(s===l||i&&l>n.scale&&s>=l)return;n.pending=s;let a={width:Math.max(1,Math.round(n.natural.width*s)),height:Math.max(1,Math.round(n.natural.height*s))};lM(e,a).then(l=>{if(Nt.get(e)!==t)return;n.pending=void 0;let u=t.bitmap;t.bitmap=l,n.shrunkTo=i?void 0:s,n.scale=s,u&&u!==l&&rf(u),uM(e),H0()},()=>{Nt.get(e)===t&&(n.pending=void 0,n.failed.add(s))})}function ra(e,t){if(e.startsWith(cM))return na.get(e)?.deref();let n=Nt.get(e);if(!n){W5(e);return}return n.readAt=++G0,t&&n.vector&&z5(e,n,n.vector,t),n.bitmap}var cM="weasel-bitmap:",na=new Map,K5=new WeakMap;var j5=new FinalizationRegistry(e=>{na.get(e)?.deref()===void 0&&na.delete(e)});function dM(e){let t=Nt.get(e);if(t?.vector)return t.vector.natural;let n=t?.bitmap??na.get(e)?.deref();return n?{width:n.width,height:n.height}:void 0}function W0(e){return e.startsWith(cM)?ra(e)===void 0?"idle":"ready":Nt.get(e)?.status??"idle"}function fM(e){let t=na.get(e)?.deref();na.delete(e),t!==void 0&&(K5.delete(t),j5.unregister(t),rf(t));let n=Nt.get(e);Nt.delete(e),Lp.delete(e),n?.bitmap&&rf(n.bitmap)}var V0="image:";function hM(e){return{id:V0+e.src}}function pM(e){let t=e.slice(V0.length),n=ra(t),r=pi.get(e)?.source;n!==r&&(n?tf(e,n,dM(t)):nf({id:e}))}ef(V0,{revive:pM,touched:pM});function z0(e){if(e.size!==void 0)return e.size;switch(e.kind){case"hatch":return 5;case"crosshatch":return 6;case"dots":return 6;case"chunks":return 48;default:return 8}}function $5(e){let t=e|0;return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function yM(e){let t=z0(e),{color:n}=e;switch(e.kind){case"hatch":{let r=e.lineWidth??1;return{size:t,shapes:mM(t,r,n)}}case"crosshatch":{let r=e.lineWidth??.8;return{size:t,shapes:[...mM(t,r,n),...Y5(t,r,n)]}}case"dots":{let r=e.radius??1;return{size:t,shapes:[{kind:"circle",cx:t/2,cy:t/2,r,color:n}]}}case"chunks":{let r=e.density??.35,o=e.chunkSize??3,i=$5(e.seed??42),s=Math.round(t*t*r/(o*o)),a=[];e.bg!==void 0&&a.push({kind:"rect",x:0,y:0,width:t,height:t,color:e.bg});for(let l=0;l<s;l++){let u=i()*t,c=i()*t,d=o*(.5+i()),f=o*(.5+i()),p=i()*Math.PI;a.push({kind:"ellipse",cx:u,cy:c,rx:d/2,ry:f/2,rotation:p,color:n})}return{size:t,shapes:a}}default:return{size:t,shapes:[]}}}function mM(e,t,n){return[{kind:"line",x1:-1,y1:e+1,x2:e+1,y2:-1,width:t,color:n},{kind:"line",x1:-1,y1:1,x2:1,y2:-1,width:t,color:n},{kind:"line",x1:e-1,y1:e+1,x2:e+1,y2:e-1,width:t,color:n}]}function Y5(e,t,n){return[{kind:"line",x1:-1,y1:-1,x2:e+1,y2:e+1,width:t,color:n},{kind:"line",x1:e-1,y1:-1,x2:e+1,y2:1,width:t,color:n},{kind:"line",x1:-1,y1:e-1,x2:1,y2:e+1,width:t,color:n}]}function gM(e,t){for(let n of t.shapes){if(n.kind==="line"){e.strokeStyle=n.color,e.lineWidth=n.width,e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.stroke();continue}if(e.fillStyle=n.color,n.kind==="rect"){e.fillRect(n.x,n.y,n.width,n.height);continue}e.beginPath(),n.kind==="circle"?e.arc(n.cx,n.cy,n.r,0,Math.PI*2):e.ellipse(n.cx,n.cy,n.rx,n.ry,n.rotation,0,Math.PI*2),e.fill()}}var q5=256,K0="pattern:",Ir=new Map;function X5(e){let t=e,n={};for(let r of Object.keys(t).sort())n[r]=t[r];return K0+JSON.stringify(n)}function J5(e){let t=cb(e),n=X5(t),r=Ir.get(n);return r!==void 0?(bM(n),r):xM(n,t)}function bM(e){let t=Ir.get(e);t!==void 0&&(Ir.delete(e),Ir.set(e,t))}function xM(e,t){let n=zl(t.kind)?rM({size:z0(t),draw:o=>gM(o,yM(t))}):null,r=n?tf(e,n):null;for(Ir.delete(e),Ir.set(e,r);Ir.size>q5;)Q5(Ir.keys().next().value);return r}function Q5(e){Ir.delete(e);let t=pi.get(e)?.source;nf({id:e}),t&&"close"in t&&t.close()}function Z5(e){let t;try{t=JSON.parse(e.slice(K0.length))}catch{return}typeof t!="object"||t===null||!("kind"in t)||xM(e,t)}ef(K0,{revive:Z5,touched:bM});function wM(e){if(ub(e)){let{width:n,height:r}=e;return{kind:"texture",texture:hM(e),...n!==void 0?{width:n}:{},...r!==void 0?{height:r}:{},...lf(e)}}if(!lb(e))return e;let t=J5(e);return t?{kind:"texture",texture:t,...lf(e)}:null}function Oi(e,t){return wM(nM(e,t))}function Vt(e,t){if(e.paint==null)return null;let n=Oi(e.paint,t);return n===null?null:n===e.paint?e:{...e,paint:n}}function Fi(e,t){if(e.paint==null)return null;let n=Oi(e.paint,t);return n===null?null:n===e.paint?e:{...e,paint:n}}function PM(e,t,n,r){let o=e??n;if(o!=="none")return o==="line"?t.paint:Oi(o,et(r))??void 0}function j0(e,t){let n=[];for(let{entry:r,path:o,size:i,space:s}of e){let a=PM(r.fill,t,"line",o),l=r.outline?r.outline.width*i:0,u=r.outline?{paint:PM(r.outline.paint,t,"line",o),width:s?{px:l*s.pxPerUnit}:l}:null;a===void 0&&(u===null||u.paint===void 0)||n.push({kind:"path",path:o,...a?{fill:{paint:a}}:{},...u&&u.paint?{stroke:{paint:u.paint,width:u.width,cap:"round",join:"round"}}:{}})}return n}var TM=new WeakMap,SM=new WeakMap,$0=e=>e===void 0?"":typeof e=="string"?e:`${e.key}@${String(e.size??"")}`;function eK(e){let t="";for(let n of[e.markerStart,e.markerMid,e.markerEnd]){let r=n===void 0?void 0:yo(Si(n));if(r===void 0){t+="/";continue}let o=jf(r,e);if(o===null)return null;t+=`${o}/`}return t}function tK(e,t,n){if(n!==null){let i=TM.get(e);return i===void 0&&TM.set(e,i=new Map),i}let r=SM.get(e);r===void 0&&SM.set(e,r=new WeakMap);let o=r.get(t);return o===void 0&&r.set(t,o=new Map),o}function kM(e,t,n,r,o,i={}){if(n.markerStart===void 0&&n.markerMid===void 0&&n.markerEnd===void 0)return[];let s=eK(n),a=tK(e,t,s),l=[r,o??"",mu(),$0(n.markerStart),$0(n.markerMid),$0(n.markerEnd),s??"",cu(i.start),cu(i.mid),cu(i.end)].join("|"),u=a.get(l);if(u===void 0){let c=yu(e,n,r,o,i);u={heads:c,paint:n.paint,cmds:j0(c,n)},a.size>=D0&&a.clear(),a.set(l,u)}else u.paint!==n.paint&&(u.paint=n.paint,u.cmds=j0(u.heads,n));return u.cmds}Z();var vM=new WeakMap;function Y0(e,t,n){let r=vM.get(e);r===void 0&&(r=new WeakMap,vM.set(e,r));let o=r.get(t);return o===void 0&&(o=vl(e,t,n),r.set(t,o)),o}function AM(e){if(e.path.kind!=="polygon")return e;let{path:t,anchorSources:n}=ps(e.path);if(t===e.path)return e;let r={...e,path:t};if(n&&e.vertexColors&&(r.vertexColors=Y0(e.vertexColors,n,4)),n&&e.stroke&&(e.stroke.vertexColors||e.stroke.vertexWidths)){let{vertexColors:o,vertexWidths:i}=e.stroke;r.stroke={...e.stroke,...o?{vertexColors:Y0(o,n,4)}:{},...i?{vertexWidths:Y0(i,n,1)}:{}}}return r}var nK=65536;function NM(e,t,n,r=nK){let o=sK(t,e.origin),i={verts:[],idx:[]},s={left:r},a=new Int32Array(o.count),l=[],u=e.vertices,c=e.indices,d=new Float32Array(6);for(let f=0;f<c.length;f+=3){for(let h=0;h<3;h++)d[h*2]=u[c[f+h]*2],d[h*2+1]=u[c[f+h]*2+1];if(iK(o,d,f/3+1,a,l),!(n?rK(d,o,l,i,s):oK(d,o,l,i,s)))return null}return{vertices:new Float32Array(i.verts),indices:new Uint32Array(i.idx),...e.origin?{origin:e.origin}:{}}}function rK(e,t,n,r,o){for(let i of n){if(--o.left<0)return!1;let s=IM(e,3,t.planes,i);if(s===J0)continue;if(s===0)return X0(e,3,r),!0;let a=e,l=3;for(let u=0;u<3&&l>=3;u++)if((s&1<<u)!==0){if(--o.left<0)return!1;[a,l]=q0(a,l,t.planes,(i*3+u)*3,1)}X0(a,l,r)}return!0}function oK(e,t,n,r,o){let i=[[e,3]];for(let s of n){let a=[];for(let[l,u]of i){if(--o.left<0)return!1;let c=IM(l,u,t.planes,s);if(c===J0){a.push([l,u]);continue}let d=l,f=u;for(let p=0;p<3&&f>=3;p++){if((c&1<<p)===0)continue;if(o.left-=2,o.left<0)return!1;let h=(s*3+p)*3,[m,g]=q0(d,f,t.planes,h,-1);g>=3&&a.push([m,g]),[d,f]=q0(d,f,t.planes,h,1)}}if(i=a,i.length===0)return!0}for(let[s,a]of i)X0(s,a,r);return!0}var J0=-1;function IM(e,t,n,r){let o=0;for(let i=0;i<3;i++){let s=(r*3+i)*3,a=0;for(let l=0;l<t;l++)n[s]*e[l*2]+n[s+1]*e[l*2+1]+n[s+2]>=0&&a++;if(a===0)return J0;a<t&&(o|=1<<i)}return o}var _p={buf:new Float32Array(16)};function q0(e,t,n,r,o){_p.buf.length<(t+1)*2&&(_p.buf=new Float32Array((t+1)*4));let i=ou(e,t,2,o*n[r],o*n[r+1],o*n[r+2],_p.buf);return[_p.buf.slice(0,i*2),i]}function X0(e,t,n){if(t<3)return;let r=n.verts.length/2;for(let o=0;o<t*2;o++)n.verts.push(e[o]);for(let o=1;o<t-1;o++)n.idx.push(r,r+o,r+o+1)}function iK(e,t,n,r,o){o.length=0;let i=Math.min(t[0],t[2],t[4]),s=Math.max(t[0],t[2],t[4]),a=Math.min(t[1],t[3],t[5]),l=Math.max(t[1],t[3],t[5]),u=e.grid,c=Math.max(0,Math.floor((i-u.x0)/u.cell)),d=Math.min(u.cols-1,Math.floor((s-u.x0)/u.cell)),f=Math.max(0,Math.floor((a-u.y0)/u.cell)),p=Math.min(u.rows-1,Math.floor((l-u.y0)/u.cell)),h=e.boxes;for(let m=f;m<=p;m++)for(let g=c;g<=d;g++)for(let b of u.cells[m*u.cols+g])r[b]!==n&&(r[b]=n,!(h[b*4]>s||h[b*4+2]<i||h[b*4+1]>l||h[b*4+3]<a)&&o.push(b))}var RM=new WeakMap;function sK(e,t){let n=RM.get(e);if(n!==void 0&&n.origin===t)return n.tris;let r=aK(e,t);return RM.set(e,{origin:t,tris:r}),r}function aK(e,t){let n=(e.origin?.x??0)-(t?.x??0),r=(e.origin?.y??0)-(t?.y??0),o=e.vertices,i=e.indices,s=[],a=[],l=new Float64Array(6);for(let c=0;c<i.length;c+=3){for(let p=0;p<3;p++)l[p*2]=o[i[c+p]*2]+n,l[p*2+1]=o[i[c+p]*2+1]+r;let d=(l[2]-l[0])*(l[5]-l[1])-(l[4]-l[0])*(l[3]-l[1]);if(d===0)continue;let f=d>0?[0,1,2]:[0,2,1];for(let p=0;p<3;p++)lK(l,f[p],f[(p+1)%3],s);a.push(Math.min(l[0],l[2],l[4]),Math.min(l[1],l[3],l[5]),Math.max(l[0],l[2],l[4]),Math.max(l[1],l[3],l[5]))}let u=a.length/4;return{planes:new Float64Array(s),boxes:new Float64Array(a),count:u,grid:uK(a,u)}}function lK(e,t,n,r){let o=e[n*2]<e[t*2]||e[n*2]===e[t*2]&&e[n*2+1]<e[t*2+1],[i,s]=o?[n,t]:[t,n],a=e[i*2],l=e[i*2+1],u=e[s*2],c=e[s*2+1],d=Math.hypot(u-a,c-l),f=-(c-l)/d,p=(u-a)/d,h=-(f*a+p*l),m=o?-1:1;r.push(m*f,m*p,m*h)}function uK(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let d=0;d<t;d++)n=Math.min(n,e[d*4]),r=Math.min(r,e[d*4+1]),o=Math.max(o,e[d*4+2]),i=Math.max(i,e[d*4+3]);if(t===0)return{x0:0,y0:0,cell:1,cols:1,rows:1,cells:[[]]};let s=Math.min(64,Math.max(1,Math.ceil(Math.sqrt(t)))),a=Math.max(o-n,i-r,1e-6)/s,l=Math.max(1,Math.ceil((o-n)/a)),u=Math.max(1,Math.ceil((i-r)/a)),c=Array.from({length:l*u},()=>[]);for(let d=0;d<t;d++){let f=Math.min(l-1,Math.floor((e[d*4]-n)/a)),p=Math.min(l-1,Math.floor((e[d*4+2]-n)/a)),h=Math.min(u-1,Math.floor((e[d*4+1]-r)/a)),m=Math.min(u-1,Math.floor((e[d*4+3]-r)/a));for(let g=h;g<=m;g++)for(let b=f;b<=p;b++)c[g*l+b].push(d)}return{x0:n,y0:r,cell:a,cols:l,rows:u,cells:c}}var cK=512,EM=new WeakMap;function CM(e,t,n){let r=EM.get(e);if(r!==void 0&&r.fill===t&&r.inner===n)return r.mesh;let o=t.requiresStencil?null:dK(e,t,n);return EM.set(e,{fill:t,inner:n,mesh:o}),o}function dK(e,t,n){let r=fK(t,e.origin);return r===null?NM(e,t,n):pK(e,r,n)}function fK(e,t){let n=e.vertices,r=(e.origin?.x??0)-(t?.x??0),o=(e.origin?.y??0)-(t?.y??0),i=[];for(let a=0;a<n.length;a+=2){let l=i.length,u=n[a]+r,c=n[a+1]+o;l>=2&&i[l-2]===u&&i[l-1]===c||i.push(u,c)}for(;i.length>=4&&i[0]===i[i.length-2]&&i[1]===i[i.length-1];)i.length-=2;let s=i.length/2;return s<3||e.indices.length!==(s-2)*3?null:zb(i,cK)}var Er={a:new Float32Array(0),b:new Float32Array(0)};function pK(e,t,n){let r=t.length/3;Er.a.length<(r+4)*2&&(Er.a=new Float32Array((r+4)*2),Er.b=new Float32Array((r+4)*2));let o=e.vertices,i=e.indices,s=[],a=[],l=[],u=new Float32Array(6);for(let c=0;c<i.length;c+=3){for(let f=0;f<3;f++)u[f*2]=o[i[c+f]*2],u[f*2+1]=o[i[c+f]*2+1];l.length=0;let d=!1;for(let f=0;f<t.length&&!d;f+=3){let p=0;for(let h=0;h<3;h++)t[f]*u[h*2]+t[f+1]*u[h*2+1]+t[f+2]>=0&&p++;p===0?d=!0:p<3&&l.push(f)}if(d){n||Q0(u,3,s,a);continue}if(n)Q0(Er.a,MM(u,l,l.length,t,-1),s,a);else for(let f=0;f<l.length;f++)Q0(Er.a,MM(u,l,f,t,l[f]),s,a)}return{vertices:new Float32Array(s),indices:new Uint32Array(a),...e.origin?{origin:e.origin}:{}}}function MM(e,t,n,r,o){let i=Er.a,s=Er.b;i.set(e);let a=3;for(let l=0;l<=n&&a>=3&&!(l===n&&o<0);l++){let u=l===n?o:t[l],c=l===n?-1:1;a=ou(i,a,2,c*r[u],c*r[u+1],c*r[u+2],s);let d=i;i=s,s=d}return i!==Er.a&&Er.a.set(i.subarray(0,a*2)),a}function Q0(e,t,n,r){if(t<3)return;let o=n.length/2;for(let i=0;i<t*2;i++)n.push(e[i]);for(let i=1;i<t-1;i++)r.push(o,o+i,o+i+1)}Pe();function Z0(e,t,n,r){for(let o=0;o<e.textures.length;o++){let i=e.textures[o];if(!(i.kind!=="bitmap"||i.image!==t))return i.sampling===n&&i.mips===r?o+1:-1}return tw(e)}function ew(e){return e.ramps?As:tw(e)<0?-1:As}function Mr(e,t){for(let n=0;n<e.textures.length;n++){let r=e.textures[n];if(r.kind==="atlas"&&r.id===t)return n+1}return tw(e)}function tw(e){return e.textures.length+(e.ramps?1:0)+1<yt?e.textures.length+1:-1}function So(e,t,n,r){return t.clipDepth===Zb(e)&&Yb(t.matrices,n,r)>=0&&hK(t,_f(e))}function hK(e,t){return t===null||OM(e,t)!==void 0?!0:e.hullPlanes+t.count<=vs}function OM(e,t){let n=e.hulls;if(n!==void 0){for(let r=0;r<n.length;r++)if(n[r].set===t)return n[r]}}function ko(e){return e.batchState??={clipDepth:Zb(e),matrices:[],textures:[],ramps:!1,hullPlanes:0,areaGlyphs:!1},e.batchState}function vo(e,t,n){let r=_f(e);if(r===null)return n;let o=OM(t,r);return o===void 0&&(o={set:r,start:t.hullPlanes},(t.hulls??=[]).push(o),t.hullPlanes+=r.count),oA(n,o.start,r.count)}function Ao(e,t,n){let r=Yb(e.matrices,t,n);return r===e.matrices.length&&e.matrices.push({colorMatrix:t,alpha:n}),r}Z();Z();Z();function Dp(e,t,n){let r=n??mK,o=pr([r[0],r[1],r[2],r[3],t.x,t.y]);if(!o)return null;let i=e;return q.fromAffine([o[0]*i[0]+o[2]*i[1],o[1]*i[0]+o[3]*i[1],o[0]*i[3]+o[2]*i[4],o[1]*i[3]+o[3]*i[4],o[0]*i[6]+o[2]*i[7]+o[4],o[1]*i[6]+o[3]*i[7]+o[5]])}var mK=[1,0,0,1];var yK=[0,0];function FM(e,t){let n=Es(t.texture.id);if(!n)return;let r=Li(e,t.units),o=r&&Dp(r,t.origin??{x:0,y:0},t.transform);if(!o)return null;let i=q.multiply(o,e.state.transform),[s,a]=nw(t,n);return{kind:"pattern",id:t.texture.id,source:n.source,opacity:t.opacity??1,uv:{ux:i[0]/s,uy:i[3]/s,u0:i[6]/s,vx:i[1]/a,vy:i[4]/a,v0:i[7]/a}}}function nw(e,{source:t,size:n}){let r=e.width??n?.width??("naturalWidth"in t?t.naturalWidth:t.width),o=e.height??n?.height??("naturalHeight"in t?t.naturalHeight:t.height);return[r>0?r:1,o>0?o:1]}function LM(e,t,n){let r=Bs(e,!1),o=e.batchState;o!==void 0&&(!So(e,o,r.colorMatrix,r.alpha)||Mr(o,t.id)<0||Mr(o,t.id)<=o.textures.length&&e.textureCache.replaces(t.id,t.source))&&ye(e),e.drawBatch.wouldOverflow(n)&&ye(e),e.textureCache.uploadRegistered(t.id,t.source,"repeat");let i=ko(e),s=Mr(i,t.id);return s>i.textures.length&&(i.textures.push({kind:"atlas",id:t.id,fieldScale:yK}),s=i.textures.length),r.slot=vo(e,i,co(s,Ao(i,r.colorMatrix,r.alpha))),r}function _M(e,t,n){return{...e,u0:e.u0-Math.floor(e.ux*t+e.uy*n+e.u0),v0:e.v0-Math.floor(e.vx*t+e.vy*n+e.v0)}}function rw(e,t,n){let{slot:r,tint:o}=LM(e,n,4);e.drawBatch.pushGradientRect(t.x,t.y,t.width,t.height,e.state.transform,_M(n.uv,t.x,t.y),n.opacity*o[3],r,Rs,o[0],o[1],o[2],1)||sn(e,t,n,rw)}function ow(e,t,n){let{slot:r,tint:o}=LM(e,n,t.vertices.length>>1),i=t.vertices.length>0?{x:t.vertices[0]+(t.origin?.x??0),y:t.vertices[1]+(t.origin?.y??0)}:{x:0,y:0};e.drawBatch.pushGradientMesh(t,e.state.transform,_M(n.uv,i.x,i.y),n.opacity*o[3],r,Rs,o[0],o[1],o[2],1)||sn(e,t,n,ow)}function Gu(e,t,n){if(n)return;let r=t.kind??"solid";if(r==="solid"){let s=t;return{kind:"solid",color:s.color,opacity:s.opacity}}if(r==="texture")return FM(e,t);if(r!=="linear-gradient"&&r!=="radial-gradient"&&r!=="conic-gradient")return;let o=t,i=gK(e,o.units);return i?o.kind==="linear-gradient"?iw(o,ci,bK(i,o)):o.kind==="radial-gradient"?iw(o,rA,xK(i,o)):iw(o,jd,wK(i,o)):null}function iw(e,t,n){return{kind:"ramp",stops:e.stops,space:e.interpolate??"rgb",opacity:e.opacity,mode:t,uv:n}}function gK(e,t){let n=Li(e,t);return n&&q.multiply(n,e.state.transform)}function bK(e,t){let n=t.to.x-t.from.x,r=t.to.y-t.from.y,o=Math.hypot(n,r)||1,i=1/(o*o);return{ux:(e[0]*n+e[1]*r)*i,uy:(e[3]*n+e[4]*r)*i,u0:((e[6]-t.from.x)*n+(e[7]-t.from.y)*r)*i,vx:0,vy:0,v0:0}}function xK(e,t){let n=1/Math.max(t.radius,1e-4);return{ux:e[0]*n,uy:e[3]*n,u0:(e[6]-t.center.x)*n,vx:e[1]*n,vy:e[4]*n,v0:(e[7]-t.center.y)*n}}function wK(e,t){let n=Math.cos(t.angle),r=Math.sin(t.angle),o=e[6]-t.center.x,i=e[7]-t.center.y;return{ux:n*e[0]+r*e[1],uy:n*e[3]+r*e[4],u0:n*o+r*i,vx:n*e[1]-r*e[0],vy:n*e[4]-r*e[3],v0:n*i-r*o}}function sw(e,t){return e.mode===ci?{uv:{...e.uv,v0:t},post:1}:{uv:e.uv,post:t}}function Li(e,t){return t==="local"?q.invert(e.state.transform):t==="world"&&e.viewMatrix?q.invert(e.viewMatrix):e.screenMatrix?q.invert(e.screenMatrix):q.identity()}function aw(e,t,n){let r=Li(e,t);return!r||!n||n.x===0&&n.y===0?r:q.multiply(q.translated(q.identity(),-n.x,-n.y),r)}function DM(e,t){let n=Li(e,t),r=n&&q.invert(n);if(!r)return null;let o=e.deviceWidth&&e.widthCss>0?e.deviceWidth/e.widthCss:1;return q.multiply(q.scaled(q.identity(),o,o),r)}var PK=96,TK=1024,BM={maxVertices:PK,maxVerticesInRun:TK};function lw(e,t){if(t.requiresStencil)return!1;let n=e.drawBatch.length>0?BM.maxVerticesInRun:BM.maxVertices;return t.vertices.length>>1<=n}function Bp(e,t){let n=au(e);return Hp(e,t,n?Ut:e.state.colorMatrix,n?1:e.state.alpha)}function Hp(e,t,n,r){let o=e.batchState;o!==void 0&&!So(e,o,n,r)&&ye(e),e.drawBatch.wouldOverflow(t)&&ye(e);let i=ko(e),s=Ao(i,n,r);return di(vo(e,i,co(eA,s)),ci)}function uw(e,t,n,r){let o=Bs(e,!1),i=e.batchState;i!==void 0&&(!So(e,i,o.colorMatrix,o.alpha)||Z0(i,t,n,r)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let s=ko(e),a=Z0(s,t,n,r);return a>s.textures.length&&(s.textures.push({kind:"bitmap",image:t,sampling:n,mips:r}),a=s.textures.length),o.slot=vo(e,s,co(a,Ao(s,o.colorMatrix,o.alpha))),o}function Uu(e,t,n,r){let o=au(e),i=o?Ut:e.state.colorMatrix,s=o?1:e.state.alpha,a=e.batchState;a!==void 0&&(!So(e,a,i,s)||Mr(a,t)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let l=ko(e),u=Mr(l,t);return u>l.textures.length&&(l.textures.push({kind:"atlas",id:t,fieldScale:n}),u=l.textures.length),r&&(l.areaGlyphs=!0),vo(e,l,co(u,Ao(l,i,s)))}function HM(e,t,n,r){e.gradRamps.wouldReshape(t,n)&&ye(e);let o=Bs(e,!0),i=e.batchState;i!==void 0&&(!So(e,i,o.colorMatrix,o.alpha)||ew(i)<0)&&ye(e),e.drawBatch.wouldOverflow(r)&&ye(e);let s=ko(e),a=ew(s);return s.ramps=!0,{slot:vo(e,s,co(a,Ao(s,o.colorMatrix,o.alpha))),tint:o.tint,rowV:e.gradRamps.rowV(e.gradRamps.upload(t,n))}}function oa(e){let[t,n,r,o]=jn(e.color);return[t,n,r,o*(e.opacity??1)]}var SK=[0,0,0,0];function GM(e,t){let n=jn(t.color);return Lf(e,n[0],n[1],n[2],n[3]*(t.opacity??1),SK)}function cw(e,t,n){let r=Bp(e,4);e.drawBatch.pushRect(t.x,t.y,t.width,t.height,e.state.transform,GM(e,n),r)||sn(e,t,n,cw)}function UM(e,t,n){let r=Bp(e,t.vertices.length>>1),[o,i,s,a]=GM(e,n);e.drawBatch.pushMesh(t,e.state.transform,o,i,s,a,r)||sn(e,t,n,UM)}function dw(e,t,n){let{slot:r,tint:o,rowV:i}=HM(e,n.stops,n.space,4),{uv:s,post:a}=sw(n,i);e.drawBatch.pushGradientRect(t.x,t.y,t.width,t.height,e.state.transform,s,a,r,n.mode,o[0],o[1],o[2],(n.opacity??1)*o[3])||sn(e,t,n,dw)}function WM(e,t,n){let{slot:r,tint:o,rowV:i}=HM(e,n.stops,n.space,t.vertices.length>>1),{uv:s,post:a}=sw(n,i);e.drawBatch.pushGradientMesh(t,e.state.transform,s,a,r,n.mode,o[0],o[1],o[2],(n.opacity??1)*o[3])||sn(e,t,n,WM)}function Wu(e,t,n){return n!==void 0&&lw(e,t)?(n.kind==="ramp"?WM(e,t,n):n.kind==="pattern"?ow(e,t,n):UM(e,t,n),!0):(an(e),!1)}var kK=[0,0];function fw(e,t){let n=Bs(e,!1),r=e.batchState;r!==void 0&&(!So(e,r,n.colorMatrix,n.alpha)||Mr(r,t)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let o=ko(e),i=Mr(o,t);return i>o.textures.length&&(o.textures.push({kind:"atlas",id:t,fieldScale:kK}),i=o.textures.length),n.slot=vo(e,o,co(i,Ao(o,n.colorMatrix,n.alpha))),n}Z();function Gp(e){let t=VM.get(e);if(t)return t;let n={gl:e.gl,get alpha(){return e.state.alpha},program:r=>e.ensureProgram?.(r)??e.programRegistry.get(r)??null,setProjAndModel:r=>nt(e,r),spaceInverse:(r,o)=>aw(e,r,o),spaceToDevice:r=>DM(e,r),get maxTextureSize(){return e.imageCache.maxTextureSide},resources:e.paintResources??vK(e.gl),bindRamp:(r,o,i)=>{let s=e.gradRamps.upload(r,i);return e.gradRamps.bind(o),e.gradRamps.rowV(s)}};return VM.set(e,n),n}var VM=new WeakMap,zM=new WeakMap;function vK(e){let t=zM.get(e);return t||(t=tl(),zM.set(e,t)),t}function Up(e,t,n,r){let o=n.texture,i=Es(o.id);if(!i)return Qt()&&!CA(o.id)&&console.warn(`weasel: pattern TextureHandle "${o.id}" not registered`),null;let s=Li(e,n.units);if(!s)return null;let a=Dp(s,n.origin??{x:0,y:0},n.transform);if(!a)return null;e.textureCache.uploadRegistered(o.id,i.source,"repeat");let l=e.gl;l.useProgram(t.handle),nt(e,t,r),Rn(e,t);let[u,c]=nw(n,i);return a[6]-=Math.floor(a[6]/u)*u,a[7]-=Math.floor(a[7]/c)*c,l.uniformMatrix3fv(t.uniform("u_worldInv"),!1,q.toUniform(a)),l.uniform2f(t.uniform("u_tileSize"),u,c),e.textureCache.bind(o.id,0),l.uniform1i(t.uniform("u_sampler"),0),l.uniform1f(t.uniform("u_opacity"),n.opacity??1),If(e,t,e.state.alpha),t}function Wp(e,t,n,r){let o=aw(e,n.units,n.kind==="linear-gradient"?n.from:n.center);if(!o)return null;let i=e.gl,s=e.gradRamps.upload(n.stops,n.interpolate??"rgb");if(i.useProgram(t.handle),nt(e,t,r),i.uniformMatrix3fv(t.uniform("u_worldInv"),!1,q.toUniform(o)),Rn(e,t),e.gradRamps.bind(0),i.uniform1i(t.uniform("u_ramp"),0),i.uniform1f(t.uniform("u_rampV"),e.gradRamps.rowV(s)),If(e,t,e.state.alpha),i.uniform1f(t.uniform("u_opacity"),n.opacity??1),n.kind==="linear-gradient"){i.uniform1i(t.uniform("u_gradKind"),0);let a=n.to.x-n.from.x,l=n.to.y-n.from.y,u=Math.hypot(a,l)||1;i.uniform2f(t.uniform("u_gradDir"),a/u,l/u),i.uniform1f(t.uniform("u_gradLen"),u),i.uniform1f(t.uniform("u_gradRadius"),0),i.uniform1f(t.uniform("u_gradAngle"),0)}else n.kind==="radial-gradient"?(i.uniform1i(t.uniform("u_gradKind"),1),i.uniform2f(t.uniform("u_gradDir"),0,0),i.uniform1f(t.uniform("u_gradLen"),0),i.uniform1f(t.uniform("u_gradRadius"),n.radius),i.uniform1f(t.uniform("u_gradAngle"),0)):(i.uniform1i(t.uniform("u_gradKind"),2),i.uniform2f(t.uniform("u_gradDir"),0,0),i.uniform1f(t.uniform("u_gradLen"),0),i.uniform1f(t.uniform("u_gradRadius"),0),i.uniform1f(t.uniform("u_gradAngle"),n.angle));return t}function KM(e,t,n){let r=t.anchorA,o=t.anchorB,i=t.anchorT;if(!r||!o||!i){if(n===void 0)return Float32Array.from(e);let l=Math.min(n.length,e.length);for(let u=0;u<l;u++)n[u]=e[u];return n}let s=r.length,a=n??new Float32Array(s*4);for(let l=0;l<s;l++){let u=r[l]*4,c=o[l]*4,d=i[l];for(let f=0;f<4;f++)a[l*4+f]=e[u+f]+(e[c+f]-e[u+f])*d}return a}function zp(e,t,n,r){let o=e.createBuffer();if(!o)throw new Error("attachVertexColors: createBuffer returned null");e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,KM(n,r),e.DYNAMIC_DRAW);let i=t.attribute("a_vertexColor");return i!==void 0&&(e.enableVertexAttribArray(i),e.vertexAttribPointer(i,4,e.FLOAT,!1,0,0)),{vbo:o,location:i}}function Kp(e,{vbo:t,location:n}){n!==void 0&&e.disableVertexAttribArray(n),e.deleteBuffer(t)}var Vp=new Float32Array(256);function AK(e,t,n,r){for(let s=0;s<n*4;s++)t[s]*=r[s&3];if(!au(e))return!1;let o=e.state.colorMatrix,i=e.state.alpha;for(let s=0;s<n*4;s+=4){let a=t[s],l=t[s+1],u=t[s+2],c=t[s+3];for(let d=0;d<4;d++){let f=d*5,p=o[f]*a+o[f+1]*l+o[f+2]*u+o[f+3]*c+o[f+4];if(!(p>=0&&p<=1))return!1}}for(let s=0;s<n*4;s+=4){let a=t[s],l=t[s+1],u=t[s+2],c=t[s+3];t[s]=o[0]*a+o[1]*l+o[2]*u+o[3]*c+o[4],t[s+1]=o[5]*a+o[6]*l+o[7]*u+o[8]*c+o[9],t[s+2]=o[10]*a+o[11]*l+o[12]*u+o[13]*c+o[14],t[s+3]=(o[15]*a+o[16]*l+o[17]*u+o[18]*c+o[19])*i}return!0}function jp(e){return e.kind===void 0||e.kind==="solid"?e:{color:"#ffffff",opacity:e.opacity}}function jM(e,t,n){let r=t.vertices.length>>1;Vp.length<r*4&&(Vp=new Float32Array(Math.max(r*4,Vp.length*2)));let o=KM(n.perAnchor,t,Vp),s=AK(e,o,r,oa(n.paint))?Hp(e,r,Ut,1):Hp(e,r,e.state.colorMatrix,e.state.alpha);e.drawBatch.pushMesh(t,e.state.transform,1,1,1,1,s,o)||sn(e,t,n,jM)}function pw(e,t,n,r){let o=t.vertices.length>>1;return(t.anchorA!==void 0||n.length>=o*4)&&lw(e,t)?(jM(e,t,{perAnchor:n,paint:r}),!0):(an(e),!1)}function hw(e,t){let n=AM(t);n.fill?.paint&&RK(e,n,n.fill.paint),n.stroke?.paint&&OK(e,n)}function RK(e,t,n){let r=n.kind===void 0||n.kind==="solid",o=!!(t.vertexColors&&t.vertexColors.length>0),i=n,s=Gu(e,n,o);if(s===null)return;if(s!==void 0&&t.path.kind==="rect"){s.kind==="ramp"?dw(e,t.path,s):s.kind==="pattern"?rw(e,t.path,s):cw(e,t.path,s);return}let a=Of(e,t.path);if(r&&o?pw(e,a,t.vertexColors,i):Wu(e,a,s))return;let u=jb(e,a);Mf(e,a.origin,()=>{r&&o?NK(e,t,i,u):u.requiresStencil?CK(e,n,u):$p(e,n,u)})}function NK(e,t,n,r){let o=e.gl,i=e.pathFillVColor;o.useProgram(i.handle),o.bindVertexArray(r.vao),nt(e,i),_s(e,i,n.color,n.opacity),Rn(e,i);let s=zp(o,i,t.vertexColors,r);r.requiresStencil?(Bb(e,r.indexCount),De(e,r.indexCount,e.gl.UNSIGNED_INT),Hb(e)):(wt(e),De(e,r.indexCount,e.gl.UNSIGNED_INT)),Kp(o,s),o.bindVertexArray(null)}function mw(e,t){let n=t.kind??"solid";if(n==="solid")return IK(e,t);if(n==="texture")return EK(e,t);if(n==="linear-gradient"||n==="radial-gradient"||n==="conic-gradient")return MK(e,t);let r=Ci(n)?.bind;return r?r(Gp(e),t):null}function $p(e,t,n){if(!mw(e,t))return;let o=e.gl;o.bindVertexArray(n.vao),wt(e),De(e,n.indexCount,e.gl.UNSIGNED_INT),o.bindVertexArray(null)}function IK(e,t){let n=e.pathFill;return e.gl.useProgram(n.handle),nt(e,n),_s(e,n,t.color,t.opacity),Rn(e,n),n}function EK(e,t){return Up(e,e.patternFill,t,Ef(e))}function MK(e,t){return Wp(e,e.gradFill,t,Ef(e))}function CK(e,t,n){let r=e.gl;r.useProgram(e.pathFill.handle),r.bindVertexArray(n.vao),nt(e,e.pathFill),Bb(e,n.indexCount),mw(e,t)&&De(e,n.indexCount,e.gl.UNSIGNED_INT),Hb(e),r.bindVertexArray(null)}function OK(e,t){let{cmd:n,spaces:r}=Hu(e.state.transform,t),o=n.stroke,i=o.align??"center",s=r.ribbon?.metric,a=n.path.kind==="polygon"||s!==void 0&&!Vf(s),l=a&&i!=="center"?LK(e,n,i,r):null;l!==null?YM(e,n,l):a&&i!=="center"?(an(e),Mf(e,n.path.kind==="polygon"?n.path.origin:void 0,()=>BK(e,n,i,r))):FK(e,n,r);let u=at(o.width??1,1),c=kM(n.path,t.stroke,o,u,Ds(e),r);for(let d of c)hw(e,d)}function FK(e,t,n){YM(e,t,Fp(t.path,t.stroke,Ds(e),n))}function LK(e,t,n,r){if(t.stroke.vertexColors&&t.stroke.vertexColors.length>0||e.batchVariants?.cuts===!1)return null;let o=Fp(t.path,qM(t.stroke),Ds(e),r);return CM(o,Of(e,t.path),n==="inner")}function YM(e,t,n){let r=t.stroke,o=r.paint;if(n.indices.length===0)return;let i=!!(r.vertexColors&&r.vertexColors.length>0),s=Gu(e,o,i);s===null||(i?pw(e,n,r.vertexColors,jp(o)):Wu(e,n,s))||Mf(e,n.origin,()=>_K(e,r,n,i))}function _K(e,t,n,r){let o=t.paint,i=o.kind===void 0||o.kind==="solid",s=o,a=r?e.meshCache.uploadTransient(n):e.meshCache.uploadRecurring(n);if(!i&&!r){$p(e,o,a);return}let l=e.gl;if(r){let u=e.pathFillVColor;l.useProgram(u.handle),l.bindVertexArray(a.vao),nt(e,u);let c=jp(o);_s(e,u,c.color,c.opacity),Rn(e,u);let d=zp(l,u,t.vertexColors,a);wt(e),De(e,a.indexCount,e.gl.UNSIGNED_INT),Kp(l,d),l.bindVertexArray(null);return}l.useProgram(e.pathFill.handle),l.bindVertexArray(a.vao),nt(e,e.pathFill),_s(e,e.pathFill,s.color,s.opacity),Rn(e,e.pathFill),wt(e),De(e,a.indexCount,e.gl.UNSIGNED_INT),l.bindVertexArray(null)}var $M=new WeakMap;function DK(e){let t=$M.get(e);return t===void 0&&(t=e.map(n=>Kl(n,2)),$M.set(e,t)),t}function qM(e){return{...e,width:at(e.width??1,1)*2,...e.vertexWidths?{vertexWidths:DK(e.vertexWidths)}:{},align:"center"}}function BK(e,t,n,r){let o=t.stroke,i=o.paint,s=qM(o),a=!!(o.vertexColors&&o.vertexColors.length>0),l=iu(e,t.path),u=Fp(t.path,s,Ds(e),r);if(u.indices.length===0)return;let c=a?e.meshCache.uploadTransient(u):e.meshCache.uploadRecurring(u),d=e.gl,f=a?e.pathFillVColor:e.pathFill;d.useProgram(f.handle),nt(e,f),d.enable(d.STENCIL_TEST),d.colorMask(!1,!1,!1,!1),d.stencilMask(1),d.stencilFunc(d.ALWAYS,1,1),d.stencilOp(d.KEEP,d.KEEP,l.requiresStencil?d.INVERT:d.REPLACE),d.bindVertexArray(l.vao),De(e,l.indexCount,e.gl.UNSIGNED_INT);let p=wi(e.clipDepth);d.colorMask(!0,!0,!0,!0),n==="inner"?d.stencilFunc(d.EQUAL,p|1,p|1):d.stencilFunc(d.EQUAL,p,p|1),d.stencilOp(d.KEEP,d.KEEP,d.KEEP);let h=f;if(a){let g=jp(i);_s(e,f,g.color,g.opacity),Rn(e,f)}else h=mw(e,i);if(!h){d.stencilMask(1),d.clear(d.STENCIL_BUFFER_BIT),d.disable(d.STENCIL_TEST),d.bindVertexArray(null);return}d.bindVertexArray(c.vao);let m=a?zp(d,h,o.vertexColors,c):null;De(e,c.indexCount,e.gl.UNSIGNED_INT),d.stencilMask(1),d.clear(d.STENCIL_BUFFER_BIT),d.disable(d.STENCIL_TEST),m&&Kp(d,m),d.bindVertexArray(null)}Pe();Pe();Z();var yw=1/4096,HK=2048,Yp=new Map;function XM(e,t){let n=Yp.get(e);if(n!==void 0)return n;Yp.size>=HK&&(Yp=new Map);let r=tu(si(t),{flattenTolerance:yw});return Yp.set(e,r),r}Z();var GK=2048,JM=1/1024,qp=new Map;function QM(e){return Math.round(e/JM)*JM}function gw(e,t,n,r,o){if(!(n>0))return null;let i=[e,n,r.join??"miter",r.cap??"butt",r.miterLimit??"",r.align??"center",(r.dash??[]).join(","),mo(o)].join("|"),s=qp.get(i);if(s!==void 0)return s.indices.length===0?null:s;qp.size>=GK&&(qp=new Map);let a=Ti(si(t),{...r,width:n},{flattenTolerance:yw,metric:o});return qp.set(i,a),a.indices.length===0?null:a}function ZM(e,t,n){return bw(e,t,n,r=>XM(r.key,r.d))}function eC(e,t,n,r){let o=e.stroke;if(!xr(o))return null;let i=o.width??1;if(typeof i=="object"){let s=tC(e),[a,l,u,c]=[r[0],r[1],r[3],r[4]];return bw(e,t,n,d=>{if(!(d.scale>0))return null;let f=d.scale,[p,h]=Po(d.rotate),m=[p*f,h*f],g=[-(p*s+h)*f,(p-h*s)*f],b=du(a*m[0]+u*m[1],l*m[0]+c*m[1],a*g[0]+u*g[1],l*g[0]+c*g[1]),x=Op(i.px,b.scale);if(!(x>0))return null;let w=o.dash?.map(y=>y/x);return gw(d.key,d.d,i.px/x,{...o,dash:w},b.metric??void 0)})}return bw(e,t,n,s=>s.scale>0?gw(s.key,s.d,QM(i/s.scale),{...o,dash:o.dash?.map(a=>a/s.scale)}):null)}var tC=e=>e.synthetic.italic?Math.tan(.2094):0;function bw(e,t,n,r){let o=[],i=0,s=0;for(let p of e.glyphs){let h=r(p);!h||h.indices.length===0||(o.push({mesh:h,glyph:p}),i+=h.vertices.length,s+=h.indices.length)}if(o.length===0)return null;let a=tC(e),l=new Float32Array(i),u=new Uint32Array(s),c=0,d=0,f=0;for(let{mesh:p,glyph:h}of o){let{x:m,baselineY:g,scale:b}=h,[x,w]=Po(h.rotate);for(let y=0;y<p.vertices.length;y+=2){let P=p.vertices[y],S=p.vertices[y+1],v=(P-S*a)*b,A=S*b;l[c++]=m+t+v*x-A*w,l[c++]=g+n+v*w+A*x}for(let y=0;y<p.indices.length;y++)u[d++]=f+p.indices[y];f+=p.vertices.length/2}return{vertices:l,indices:u}}function nC(e,t,n,r,o,i){let s=e[t]+n,a=e[t+1]+r,l=e[t+2]+n,u=e[t+3]+r,c=e[t+8]+r,d=(c-a)*o,f=(c-u)*o;i[0]=s+d,i[1]=a,i[2]=l+d,i[3]=a,i[4]=l+f,i[5]=u,i[6]=s+f,i[7]=u;let p=e[t+10];if(!p)return;let[h,m]=Po(p),g=e[t+9]+n;for(let b=0;b<8;b+=2){let x=i[b]-g,w=i[b+1]-c;i[b]=g+x*h-w*m,i[b+1]=c+x*m+w*h}}var ia=new Array(11).fill(0);function Xp(e,t,n,r,o,i,s,a){let l=a.xy;nC(e,t,n,r,o,l),rC(i,l);let u=a.uv;for(let b=0;b<4;b++)u[b]=e[t+4+b];if(s<=0)return;let c=Math.abs((l[2]-l[0])*(l[7]-l[1])-(l[3]-l[1])*(l[6]-l[0]));if(c===0)return;let d=e[t+2]-e[t],f=e[t+3]-e[t+1],p=s*d*Math.hypot(l[6]-l[0],l[7]-l[1])/c,h=s*f*Math.hypot(l[2]-l[0],l[3]-l[1])/c;for(let b=0;b<11;b++)ia[b]=e[t+b];ia[0]-=p,ia[2]+=p,ia[1]-=h,ia[3]+=h;let m=(u[2]-u[0])*p/d,g=(u[3]-u[1])*h/f;u[0]-=m,u[2]+=m,u[1]-=g,u[3]+=g,nC(ia,0,n,r,o,l),rC(i,l)}function rC(e,t){for(let n=0;n<8;n+=2){let r=t[n],o=t[n+1];t[n]=e[0]*r+e[3]*o+e[6],t[n+1]=e[1]*r+e[4]*o+e[7]}}Pe();Z();function Jp(e){let t=Math.hypot(e[0],e[1]),n=Math.hypot(e[3],e[4]);return Math.sqrt(t*n)||1}function oC(e,t,n,r){let o=t.fill?.paint;if(o===void 0||t.quads.length===0||!td(e.textureCache,t.page))return;let i=Ht(o)?oa(o)[3]:1,s=Qc(t.page),a=e.drawBatch,l=e.state.transform,u=e.deviceWidth&&e.widthCss?e.deviceWidth/e.widthCss:1,c=Jp(l)*u,d=s,{slot:f,tint:p}=fw(e,d),h=()=>{({slot:f,tint:p}=fw(e,d))};for(let m of t.quads){let g=UK(e,m,c),b=g?.quad??m,x=g?.atlasId??s;x!==d&&(d=x,h()),a.wouldOverflow(4)&&(ye(e),h());let w,y=b.rotate?q.multiply(l,q.fromAffine(ro(b.penX+n,b.baselineY+r,b.rotate*Math.PI/180))):l;for(;!a.pushQuad(b.x0+n,b.y0+r,b.x1-b.x0,b.y1-b.y0,y,b.u0,b.v0,b.u1,b.v1,i*p[3],f,p[0],p[1],p[2]);)w=po(e),h();w!==void 0&&(ho(e,w),h())}}function UK(e,t,n){let r=t.colorGlyph;if(!r||r.width===0)return null;let o=(t.x1-t.x0)/r.width,i=ad(r,o*n);if(!i||!nd(e.textureCache,i.glyph.page))return null;let s=i.glyph,a=2**i.level,l=t.x0+(s.xoffset-r.xoffset)*o,u=t.y0+(s.yoffset-r.yoffset)*o;return{quad:{x0:l,y0:u,x1:l+s.width/a*o,y1:u+s.height/a*o,u0:s.x/1024,v0:s.y/1024,u1:(s.x+s.width)/1024,v1:(s.y+s.height)/1024,baselineY:t.baselineY,penX:t.penX,rotate:t.rotate},atlasId:Zc(s.page)}}var iC={vertices:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])};function sC(e,t,n){let r=e.paintScratch,o=Ci(t.kind)?.bind;if(!r||!o)return null;let i=e.deviceWidth&&e.widthCss>0?e.deviceWidth/e.widthCss:1,s=e.deviceWidth??Math.round(e.widthCss),a=e.deviceHeight??Math.round(e.heightCss),l=e.renderTarget?.window??{x:0,y:0,width:s,height:a},u=Math.max(l.x,Math.floor(n.x0*i)),c=Math.max(l.y,Math.floor(n.y0*i)),d=e.imageCache.maxTextureSide,f=Math.min(d,Math.min(l.x+l.width,Math.ceil(n.x1*i))-u),p=Math.min(d,Math.min(l.y+l.height,Math.ceil(n.y1*i))-c);if(!(f>0&&p>0))return null;let h=u/i,m=c/i,g=f/i,b=p/i,x=new Float32Array([g,0,0,0,b,0,h,m,1]),w=new Float32Array([2/g,0,0,0,2/b,0,-1-2*h/g,-1-2*m/b,1]),y=Gp(e),P={...y,alpha:e.state.alpha,maxTextureSize:y.maxTextureSize,setProjAndModel:M=>nt(e,M,x,w)},S=e.gl,v=r.acquire(f,p),A=S.isEnabled(S.SCISSOR_TEST);S.activeTexture(S.TEXTURE0),S.bindTexture(S.TEXTURE_2D,null),S.bindFramebuffer(S.FRAMEBUFFER,v.fbo),S.viewport(0,0,f,p),S.disable(S.SCISSOR_TEST),S.disable(S.STENCIL_TEST),S.clear(S.COLOR_BUFFER_BIT),S.disable(S.BLEND);let N=o(P,t);return N&&(S.bindVertexArray(e.meshCache.uploadRecurring(iC).vao),De(e,iC.indices.length,S.UNSIGNED_INT),S.bindVertexArray(null)),S.enable(S.BLEND),Zs(e,s,a,A),N?{texture:v.texture,uvFromScreen:new Float32Array([i/v.width,0,0,0,i/v.height,0,-u/v.width,-c/v.height,1])}:null}function aC(e,t,n){let r=e.gl;return r.useProgram(t.handle),nt(e,t,Hs),r.uniformMatrix3fv(t.uniform("u_worldInv"),!1,n.uvFromScreen),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.texture),r.uniform1i(t.uniform("u_sampler"),0),t}var Qp=48,lC={outlineMinSize:void 0};function cC(e,t){let n=e.textOutlineMinScreenSize??Qp,r=Number.isFinite(n)?n/Jp(e.state.transform):void 0,{laid:o,dx:i,dy:s}=Ap(t);lC.outlineMinSize=r;let{groups:a,decorations:l}=w0(o,t.runs,lC,"read");if(!(a.length===0&&l.length===0)){for(let u of a)u.source==="outline"?WK(e,u,i,s):u.source==="color"?oC(e,u,i,s):KK(e,u,i,s);VK(e,l,i,s)}}function WK(e,t,n,r){let o=t.fill?.paint;if(o!==void 0){let a=ZM(t,n,r);a&&Pw(e,o,a)}let i=t.stroke?.paint;if(!i)return;let s=eC(t,n,r,e.state.transform);s&&Pw(e,i,s)}function Pw(e,t,n){let r=Gu(e,t,!1);r!==null&&(Wu(e,n,r)||$p(e,t,e.meshCache.uploadTransient(n)))}function VK(e,t,n,r){for(let o of t){let i=o.fill.paint;if(i===void 0)continue;if(fC(i)!==null){Pw(e,i,zK(o.x0+n,o.y0+r,o.x1+n,o.y1+r));continue}let[s,a,l,u]=Ht(i)?oa(i):[0,0,0,1],c;for(;;){let d=Bp(e,4),f=$b(e,s,a,l,u);if(e.drawBatch.pushRect(o.x0+n,o.y0+r,o.x1-o.x0,o.y1-o.y0,e.state.transform,f,d))break;c=po(e)}c!==void 0&&ho(e,c)}}function zK(e,t,n,r){return{vertices:new Float32Array([e,t,n,t,n,r,e,r]),indices:new Uint32Array([0,1,2,0,2,3])}}function dC(e,t,n,r){let o=(e.deviceWidth??e.widthCss)/(e.widthCss||1),i=Math.hypot(n[0],n[1])*o*(t[2]-t[0])/Math.abs(t[6]-t[4]),s=Math.hypot(n[3],n[4])*o*(t[3]-t[1])/Math.abs(t[7]-t[5]);return Vy(r,i,s)?gd/o:0}function KK(e,t,n,r){if(t.source==="canvas"){if(!ed(e.textureCache,t.page))return}else if(!_y(t.family,t.weight,t.style,e.textureCache))return;if(t.quadData.length===0)return;let o=t.source==="canvas"?Jc(t.page):es(t.family,t.weight,t.style),i=t.source==="canvas"?Wy:Uy,s=Ky(t.source==="canvas"?"canvas":"atlas",t.family,t.weight,t.style);if(!s)return;let a=t.synthetic.bold?pl:0,l=t.synthetic.italic?Math.tan(.2094):0,u=t.fill?.paint;if(u===void 0)return;let c=fC(u);if(c!==null){qK(e,t,n,r,c,o,i,a,l,s);return}let d=Ht(u)?jn(u.color):jK,f=Ht(u)?u.opacity??1:1,p=e.drawBatch,h=e.state.transform,m=dC(e,t.quadData,h,s),g=m>0,b=Uu(e,o,s,g),x=Lf(e,d[0],d[1],d[2],d[3]*f,$K),w=t.quadData;for(let y=0;y<w.length;y+=Ar){p.wouldOverflow(4)&&(ye(e),b=Uu(e,o,s,g));let P;for(;!p.pushGlyph(w,y,n,r,l,h,x,b,i,a,m);)P=po(e),b=Uu(e,o,s,g);P!==void 0&&(ho(e,P),b=Uu(e,o,s,g))}}var jK=[0,0,0,1],$K=[0,0,0,0];function fC(e){let t=e.kind??"solid";return t==="texture"?"pattern":t==="linear-gradient"||t==="radial-gradient"||t==="conic-gradient"?"gradient":t==="solid"?null:"texture"}var ww=1,YK=[1,1,1,1];function qK(e,t,n,r,o,i,s,a,l,u){let c=e.glyphPaintProgram?.(o);if(!c)return;an(e);let d=t.fill.paint,f=e.state.transform,p=dC(e,t.quadData,f,u),h;if(o==="pattern")h=Up(e,c,d,Hs);else if(o==="gradient")h=Wp(e,c,d,Hs);else{let w=sC(e,d,XK(t,n,r,l,f,p));h=w&&aC(e,c,w)}if(!h)return;let m=e.gl;e.textureCache.bind(i,ww),m.uniform1i(c.uniform("u_atlas"),ww),m.uniform1f(c.uniform("u_synthBold"),a),m.uniform2f(c.uniform("u_fieldScale"),u[0],u[1]),wt(e);let g=e.drawBatch,b=g.clip;g.clip=null;let x=t.quadData;for(let w=0;w<x.length;w+=Ar)g.wouldOverflow(4)&&uC(e),g.pushGlyph(x,w,n,r,l,f,YK,ww,s,0,p);uC(e),g.clip=b,m.activeTexture(m.TEXTURE0),m.bindVertexArray(null)}function uC(e){let t=e.drawBatch;t.length!==0&&(De(e,t.uploadAndBind(),e.gl.UNSIGNED_INT),t.reset())}function XK(e,t,n,r,o,i){let s={x0:1/0,y0:1/0,x1:-1/0,y1:-1/0},a=e.quadData,l={xy:[],uv:[]};for(let u=0;u<a.length;u+=Ar){Xp(a,u,t,n,r,o,i,l);let c=l.xy;for(let d=0;d<8;d+=2)s.x0=Math.min(s.x0,c[d]),s.x1=Math.max(s.x1,c[d]),s.y0=Math.min(s.y0,c[d+1]),s.y1=Math.max(s.y1,c[d+1])}return s}var JK=2;function QK(e){let t=e.state.transform,n=e.deviceWidth&&e.widthCss?e.deviceWidth/e.widthCss:1,r=(JK*n)**2;return[r*(t[0]*t[0]+t[1]*t[1]),r*(t[3]*t[3]+t[4]*t[4])]}var ZK=(e,t,n,r,o)=>t*t>=e[0]*r*r||n*n>=e[1]*o*o,ej=(e,t)=>!t||t.x<=0&&t.y<=0&&t.x+t.w>=e.width&&t.y+t.h>=e.height;function Tw(e,t){e.imageCache.upload(t.image,t.image);let n=ej(t.image,t.source);n&&e.imageCache.lacksMipmaps(t.image)&&ZK(QK(e),t.image.width,t.image.height,t.w,t.h)&&e.imageCache.buildMipmaps(t.image);let r=n&&e.imageCache.hasMipmaps(t.image),{slot:o,tint:i}=uw(e,t.image,t.sampling??"linear",r),s=t.source,a=0,l=0,u=1,c=1;if(s){let d=t.image.width,f=t.image.height;a=s.x/d,u=(s.x+s.w)/d,l=s.y/f,c=(s.y+s.h)/f}if(t.flipX){let d=a;a=u,u=d}if(t.flipY){let d=l;l=c,c=d}e.drawBatch.pushQuad(t.x,t.y,t.w,t.h,e.state.transform,a,l,u,c,(t.opacity??1)*i[3],o,i[0],i[1],i[2])||sn(e,t,void 0,Tw)}function pC(e,t){let n=t.sprites,r=Math.floor(n.length/9);if(r===0)return;e.imageCache.upload(t.image,t.image);let o=t.sampling??"linear",i=()=>uw(e,t.image,o,!1),{slot:s,tint:a}=i(),l=e.drawBatch,u=e.state.transform,c=t.image.width,d=t.image.height;for(let f=0,p=0;f<r;f++,p+=9){l.wouldOverflow(4)&&(ye(e),{slot:s,tint:a}=i());let h=n[p+4],m=n[p+5],g=n[p+6],b=n[p+7],x;for(;!l.pushQuad(n[p],n[p+1],n[p+2],n[p+3],u,h/c,m/d,(h+g)/c,(m+b)/d,n[p+8]*a[3],s,a[0],a[1],a[2]);)x=po(e),{slot:s,tint:a}=i();x!==void 0&&(ho(e,x),{slot:s,tint:a}=i())}}function _i(e,t){switch(t.kind){case"group":return tj(e,t);case"path":return hw(e,t);case"text":return cC(e,t);case"image":return Tw(e,t);case"sprites":return pC(e,t);case"shader":return an(e),FR(e,t)}}function hC(e){return e.isolate===!0||$n(e.composite)||e.effects!==void 0&&e.effects.length>0}function tj(e,t){if(!(t.retain!==void 0&&XE(e,t,hC(t),_i))){if(hC(t)&&e.effectTargets&&e.deviceWidth&&e.deviceHeight){if(t.clip){e.state.push({transform:t.transform});try{uu(e,t.clip)}finally{e.state.pop()}}YE(e,t,e.effectTargets,e.deviceWidth,e.deviceHeight,_i),t.clip&&Jb(e);return}if(e.state.push({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix}),t.clip)try{uu(e,t.clip)}catch(n){throw e.state.pop(),n}for(let n of t.children)_i(e,n);t.clip&&Jb(e),e.state.pop()}}var Yn=10,oe=Yn,nj=256,rj=384,Sw=32;function Ro(e,t){let n=e;for(;n<t;)n*=2;return n}var Zp=class{verts=new Float32Array(nj*oe);idx=new Uint32Array(rj);nVerts=0;nIdx=0;pureRects=!0;clip=null;polyIn=new Float32Array(Sw*oe);polyOut=new Float32Array(Sw*oe);polyTmp=new Float32Array(Sw*oe);triangles=new Uint32Array(0);writeVertex(t,n,r,o,i,s,a,l,u,c,d){let f=this.verts;return f[t]=n,f[t+1]=r,f[t+2]=o,f[t+3]=i,f[t+4]=s,f[t+5]=a,f[t+6]=l,f[t+7]=u,f[t+8]=c,f[t+9]=d,t+oe}pushQuadIndices(){let t=this.nVerts,n=this.nIdx;this.idx[n++]=t,this.idx[n++]=t+1,this.idx[n++]=t+2,this.idx[n++]=t,this.idx[n++]=t+2,this.idx[n++]=t+3,this.nVerts+=4,this.nIdx+=6}reserve(t,n){let r=(this.nVerts+t)*oe;if(r>this.verts.length){let i=new Float32Array(Ro(this.verts.length,r));i.set(this.verts),this.verts=i}let o=this.nIdx+n;if(o>this.idx.length){let i=new Uint32Array(Ro(this.idx.length,o));i.set(this.idx),this.idx=i}}fitQuad(t,n){let r=this.clip;if(r===null)return!0;let o=this.verts,i=t*oe;if(Pr(r,o[i],o[i+1])&&Pr(r,o[i+oe],o[i+oe+1])&&Pr(r,o[i+2*oe],o[i+2*oe+1])&&Pr(r,o[i+3*oe],o[i+3*oe+1])||(this.nVerts=t,this.nIdx=n,Cf(r,o,i,4,oe)))return!0;if(!r.slanted){let s=o[i],a=o[i+1],l=o[i+oe],u=o[i+oe+1],c=o[i+2*oe],d=o[i+2*oe+1],f=o[i+3*oe],p=o[i+3*oe+1];if(!(a===u&&l===c&&d===p&&f===s||s===l&&u===d&&c===f&&p===a)||r.planes.length>0)return!1}return this.polyIn.set(o.subarray(i,i+4*oe)),this.appendFan(Kb(this.polyIn,4,oe,r,this.polyOut,this.polyTmp)),!0}fitMesh(t,n){let r=this.clip;if(r===null)return!0;let o=this.verts,i=!0;for(let u=t*oe;u<this.nVerts*oe&&i;u+=oe)i=Pr(r,o[u],o[u+1]);if(i)return!0;let s=this.nIdx,a=Cf(r,o,t*oe,this.nVerts-t,oe);if(a||!r.slanted)return this.nVerts=t,this.nIdx=n,a;this.triangles.length<s-n&&(this.triangles=new Uint32Array(Ro(64,s-n)));let l=this.triangles;l.set(this.idx.subarray(n,s)),this.nIdx=n;for(let u=0;u<s-n;u+=3)this.fitTriangle(r,l[u],l[u+1],l[u+2]);return!0}fitTriangle(t,n,r,o){let i=this.verts;if(Pr(t,i[n*oe],i[n*oe+1])&&Pr(t,i[r*oe],i[r*oe+1])&&Pr(t,i[o*oe],i[o*oe+1])){this.reserve(0,3),this.idx[this.nIdx++]=n,this.idx[this.nIdx++]=r,this.idx[this.nIdx++]=o;return}let s=this.polyIn;s.set(i.subarray(n*oe,n*oe+oe),0),s.set(i.subarray(r*oe,r*oe+oe),oe),s.set(i.subarray(o*oe,o*oe+oe),2*oe),!Cf(t,s,0,3,oe)&&this.appendFan(Kb(s,3,oe,t,this.polyOut,this.polyTmp))}appendFan(t){if(t<3)return;this.reserve(t,(t-2)*3),t!==4&&(this.pureRects=!1);let n=this.nVerts;this.verts.set(this.polyOut.subarray(0,t*oe),n*oe);let r=this.nIdx;for(let o=1;o<t-1;o++)this.idx[r++]=n,this.idx[r++]=n+o,this.idx[r++]=n+o+1;this.nVerts+=t,this.nIdx=r}};var oj=32768;var kw={xy:new Array(8).fill(0),uv:[0,0,0,0]},ij=[0,0,0,0],Vu=.5,zu=.5,sj={ux:0,uy:0,u0:Vu,vx:0,vy:0,v0:zu},aj=64,Cr=[{vertices:16,indices:24},{vertices:1024,indices:3072}],lj=Cr[Cr.length-1].vertices,mC=4;function uj(e){let t=new Uint32Array(e*6);for(let n=0;n<e;n++){let r=n*4,o=n*6;t[o]=r,t[o+1]=r+1,t[o+2]=r+2,t[o+3]=r,t[o+4]=r+2,t[o+5]=r+3}return t}var Ku=class extends Zp{gl;aPos;aColor;aUv;aPost;aSlot;rings=Cr.map(()=>new Array(aj).fill(void 0));nextInRing=Cr.map(()=>0);largeRing=new Array(mC).fill(void 0);nextLarge=0;constructor(t,n){super();let r=n.attribute("a_position"),o=n.attribute("a_vertexColor"),i=n.attribute("a_uv"),s=n.attribute("a_post"),a=n.attribute("a_texSlot");if(r===void 0||o===void 0||i===void 0||s===void 0||a===void 0)throw new Error("DrawBatch: batch program is missing a_position / a_vertexColor / a_uv / a_post / a_texSlot");this.gl=t,this.aPos=r,this.aColor=o,this.aUv=i,this.aPost=s,this.aSlot=a}get length(){return this.nIdx}wouldOverflow(t){return this.nVerts+t>oj}pushRect(t,n,r,o,i,s,a){let l=s[0],u=s[1],c=s[2],d=s[3];this.reserve(4,6);let f=this.nVerts*Yn,p=i[0],h=i[1],m=i[3],g=i[4],b=i[6],x=i[7],w=t+r,y=n+o,P=p*t+m*n+b,S=h*t+g*n+x,v=p*w+m*n+b,A=h*w+g*n+x,N=p*w+m*y+b,M=h*w+g*y+x,C=p*t+m*y+b,F=h*t+g*y+x;return f=this.writeVertex(f,P,S,l,u,c,d,Vu,zu,1,a),f=this.writeVertex(f,v,A,l,u,c,d,Vu,zu,1,a),f=this.writeVertex(f,N,M,l,u,c,d,Vu,zu,1,a),this.writeVertex(f,C,F,l,u,c,d,Vu,zu,1,a),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushQuad(t,n,r,o,i,s,a,l,u,c,d,f=1,p=1,h=1){this.reserve(4,6);let m=this.nVerts*Yn,g=i[0],b=i[1],x=i[3],w=i[4],y=i[6],P=i[7],S=t+r,v=n+o,A=g*t+x*n+y,N=b*t+w*n+P,M=g*S+x*n+y,C=b*S+w*n+P,F=g*S+x*v+y,B=b*S+w*v+P,D=g*t+x*v+y,j=b*t+w*v+P,W=di(d,Rs);return m=this.writeVertex(m,A,N,f,p,h,1,s,a,c,W),m=this.writeVertex(m,M,C,f,p,h,1,l,a,c,W),m=this.writeVertex(m,F,B,f,p,h,1,l,u,c,W),this.writeVertex(m,D,j,f,p,h,1,s,u,c,W),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGlyph(t,n,r,o,i,s,a,l,u,c,d=0){this.reserve(4,6);let f=this.nVerts*Yn;Xp(t,n,r,o,i,s,d,kw);let p=kw.xy,h=kw.uv,m=a[0],g=a[1],b=a[2],x=a[3],w=di(l,u),y=d>0?Zv:ij;return f=this.writeVertex(f,p[0],p[1],m,g,b,x,h[0],h[1],c+y[0],w),f=this.writeVertex(f,p[2],p[3],m,g,b,x,h[2],h[1],c+y[1],w),f=this.writeVertex(f,p[4],p[5],m,g,b,x,h[2],h[3],c+y[2],w),this.writeVertex(f,p[6],p[7],m,g,b,x,h[0],h[3],c+y[3],w),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGradientRect(t,n,r,o,i,s,a,l,u,c,d,f,p){this.reserve(4,6);let h=this.nVerts*Yn,m=i[0],g=i[1],b=i[3],x=i[4],w=i[6],y=i[7],P=t+r,S=n+o,v=di(l,u),A=(N,M)=>{let C=h;return h=this.writeVertex(C,m*N+b*M+w,g*N+x*M+y,c,d,f,p,s.ux*N+s.uy*M+s.u0,s.vx*N+s.vy*M+s.v0,a,v),h};return A(t,n),A(P,n),A(P,S),A(t,S),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGradientMesh(t,n,r,o,i,s,a,l,u,c,d){let f=t.vertices,p=t.indices,h=f.length>>1;this.reserve(h,p.length),this.pureRects=!1;let m=this.verts,g=this.nVerts*Yn,b=n[0],x=n[1],w=n[3],y=n[4],P=n[6],S=n[7],v=di(i,s),A=t.origin?.x??0,N=t.origin?.y??0;for(let B=0;B<h;B++){let D=f[B*2]+A,j=f[B*2+1]+N;if(m[g++]=b*D+w*j+P,m[g++]=x*D+y*j+S,d===void 0)m[g++]=a,m[g++]=l,m[g++]=u,m[g++]=c;else{let W=B*4;m[g++]=a*d[W],m[g++]=l*d[W+1],m[g++]=u*d[W+2],m[g++]=c*d[W+3]}m[g++]=r.ux*D+r.uy*j+r.u0,m[g++]=r.vx*D+r.vy*j+r.v0,m[g++]=o,m[g++]=v}let M=this.nVerts,C=this.idx,F=this.nIdx;for(let B=0;B<p.length;B++)C[F++]=M+p[B];return this.nVerts+=h,this.nIdx+=p.length,this.fitMesh(M,this.nIdx-p.length)}pushMesh(t,n,r,o,i,s,a,l){return this.pushGradientMesh(t,n,sj,1,a,ci,r,o,i,s,l)}uploadAndBind(){let t=this.gl,n=Cr.findIndex(o=>this.nVerts<=o.vertices&&this.nIdx<=o.indices),r=n<0?this.nextLargeSlot():this.nextRingSlot(n);if(t.bindVertexArray(r.vao),t.bindBuffer(t.ARRAY_BUFFER,r.vbo),t.bufferSubData(t.ARRAY_BUFFER,0,this.verts,0,this.nVerts*Yn),!this.pureRects)t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,this.idx,0,this.nIdx),r.canonicalQuads=0;else if(r.canonicalQuads<this.nVerts>>2){let o=Math.min(r.vertexCapacity>>2,Math.floor(r.indexCapacity/6));t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,uj(o)),r.canonicalQuads=o}return this.nIdx}reset(){this.nVerts=0,this.nIdx=0,this.pureRects=!0}dispose(){for(let t of[...this.rings.flat(),...this.largeRing])t&&this.deleteSet(t);for(let t of this.rings)t.fill(void 0);this.largeRing.fill(void 0)}nextRingSlot(t){let n=this.rings[t],r=this.nextInRing[t];this.nextInRing[t]=(r+1)%n.length;let o=n[r];if(o)return o;let i=this.createSet(Cr[t].vertices,Cr[t].indices);return n[r]=i,i}nextLargeSlot(){let t=this.gl,n=this.nextLarge;this.nextLarge=(n+1)%mC;let r=this.largeRing[n];return r?(this.nVerts>r.vertexCapacity&&(r.vertexCapacity=Ro(r.vertexCapacity,this.nVerts),t.bindBuffer(t.ARRAY_BUFFER,r.vbo),t.bufferData(t.ARRAY_BUFFER,r.vertexCapacity*Yn*4,t.DYNAMIC_DRAW)),this.nIdx>r.indexCapacity&&(r.indexCapacity=Ro(r.indexCapacity,this.nIdx),t.bindVertexArray(r.vao),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r.ibo),t.bufferData(t.ELEMENT_ARRAY_BUFFER,r.indexCapacity*4,t.DYNAMIC_DRAW),t.bindVertexArray(null),r.canonicalQuads=0),r):(r=this.createSet(Ro(lj,this.nVerts),Ro(Cr[Cr.length-1].indices,this.nIdx)),this.largeRing[n]=r,r)}createSet(t,n){let r=this.gl,o=r.createVertexArray(),i=r.createBuffer(),s=r.createBuffer();if(!o||!i||!s)throw new Error("DrawBatch: failed to create GL objects");let a=Yn*4;return r.bindVertexArray(o),r.bindBuffer(r.ARRAY_BUFFER,i),r.bufferData(r.ARRAY_BUFFER,t*a,r.DYNAMIC_DRAW),r.enableVertexAttribArray(this.aPos),r.vertexAttribPointer(this.aPos,2,r.FLOAT,!1,a,0),r.enableVertexAttribArray(this.aColor),r.vertexAttribPointer(this.aColor,4,r.FLOAT,!1,a,8),r.enableVertexAttribArray(this.aUv),r.vertexAttribPointer(this.aUv,2,r.FLOAT,!1,a,24),r.enableVertexAttribArray(this.aPost),r.vertexAttribPointer(this.aPost,1,r.FLOAT,!1,a,32),r.enableVertexAttribArray(this.aSlot),r.vertexAttribPointer(this.aSlot,1,r.FLOAT,!1,a,36),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,s),r.bufferData(r.ELEMENT_ARRAY_BUFFER,n*4,r.DYNAMIC_DRAW),r.bindVertexArray(null),{vao:o,vbo:i,ibo:s,vertexCapacity:t,indexCapacity:n,canonicalQuads:0}}deleteSet(t){let n=this.gl;n.deleteBuffer(t.vbo),n.deleteBuffer(t.ibo),n.deleteVertexArray(t.vao)}};var yC=`#version 300 es
398
398
  in vec2 a_position;
399
399
  in vec2 a_uv;
400
400
  uniform vec4 u_bounds;
@@ -419,15 +419,15 @@ void main() {
419
419
  vec3 clip = u_proj * vec3(sx, sy, 1.0);
420
420
  gl_Position = vec4(clip.xy, 0.0, 1.0);
421
421
  }
422
- `,oC=["a_position","a_uv"],iC=["u_bounds","u_view","u_proj","u_screenToLocal","u_worldOrigin"],sC=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),aC=new Uint16Array([0,1,2,0,2,3]);var Kp=class{gl;all=[];free=[];constructor(t){this.gl=t}get allocated(){return this.all.length>0}acquire(t,n){let r=this.free.findIndex(i=>i.width===t&&i.height===n),o=r>=0?this.free.splice(r,1)[0]:this.create(t,n);return o.used=!0,o}release(t){this.free.push(t)}reclaim(){let t=[];for(let n of this.all)n.used?t.push(n):this.destroy(n),n.used=!1;this.all=t,this.free=[...t]}releaseAll(){for(let t of this.all)this.destroy(t);this.all=[],this.free=[]}destroy(t){let n=this.gl;n.deleteFramebuffer(t.fbo),n.deleteTexture(t.texture),n.deleteRenderbuffer(t.stencil)}create(t,n){let r=this.gl,o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texImage2D(r.TEXTURE_2D,0,r.RGBA8,t,n,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null);let i=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,i),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH24_STENCIL8,t,n),r.bindRenderbuffer(r.RENDERBUFFER,null);let s=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,s),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,o,0),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,i),r.bindFramebuffer(r.FRAMEBUFFER,null);let a={fbo:s,texture:o,stencil:i,width:t,height:n,used:!1};return this.all.push(a),a}};function cC(e){return{...e,transform:e.transform.slice(),colorMatrix:e.colorMatrix.slice(),viewMatrix:e.viewMatrix?.slice(),screenMatrix:e.screenMatrix?.slice(),clips:e.clips.map(t=>({path:t.path,transform:t.transform.slice()})),window:e.window&&{...e.window}}}function dC(e,t){return e.children===t.children&&e.alpha===t.alpha&&Zs(e.transform,t.transform)&&Zs(e.colorMatrix,t.colorMatrix)&&mw(e.viewMatrix,t.viewMatrix)&&mw(e.screenMatrix,t.screenMatrix)&&tj(e.clips,t.clips)&&e.isolate===t.isolate&&pC(e.effects,t.effects)&&hC(e.window,t.window)}function fC(e,t){if(e.children!==t.children||e.alpha!==t.alpha||e.isolate!==t.isolate||!Zs(e.colorMatrix,t.colorMatrix)||!mw(e.screenMatrix,t.screenMatrix)||!pC(e.effects,t.effects)||e.clips.length!==t.clips.length||!hC(e.window,t.window))return null;let n=lC(e.transform,t.transform);if(!n)return null;let r=(o,i)=>{if(o===void 0||i===void 0)return o===i;let s=lC(o,i);return s!==null&&uC(s[0],n[0])&&uC(s[1],n[1])};if(!r(e.viewMatrix,t.viewMatrix))return null;for(let o=0;o<e.clips.length;o++)if(e.clips[o].path!==t.clips[o].path||!r(e.clips[o].transform,t.clips[o].transform))return null;return n}function lC(e,t){for(let n of[0,1,2,3,4,5,8])if(e[n]!==t[n])return null;return[t[6]-e[6],t[7]-e[7]]}function uC(e,t){return Math.abs(e-t)<=1e-6*Math.max(1,Math.abs(e),Math.abs(t))}function pC(e,t){if(e===t)return!0;if((e?.length??0)!==(t?.length??0))return!1;for(let n=0;n<(e?.length??0);n++){let r=e[n],o=t[n];if(r.program.id!==o.program.id||r.reach!==o.reach||!ZK(r.uniforms,o.uniforms))return!1}return!0}function ZK(e,t){if(e===t)return!0;let n=Object.keys(e??{});return n.length!==Object.keys(t??{}).length?!1:n.every(r=>ej(e[r],t?.[r]))}function ej(e,t){return typeof e=="number"||t===void 0||typeof t=="number"?e===t:"id"in e||"id"in t?"id"in e&&"id"in t&&e.id===t.id:Zs(e,t)}function mw(e,t){return e===void 0?t===void 0:t!==void 0&&Zs(e,t)}function hC(e,t){return e===void 0||t===void 0?e===t:e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function tj(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].path!==t[n].path||!Zs(e[n].transform,t[n].transform))return!1;return!0}function Zs(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function mC(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function yC(e,t,n){let r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,t,n,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null);let o=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,o),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0),e.bindFramebuffer(e.FRAMEBUFFER,null),{texture:r,fbo:o}}function gC(e,t){e.deleteFramebuffer(t.fbo),e.deleteTexture(t.texture)}function bC(e,t,n,r){let o=l=>{let u=e.createRenderbuffer();return e.bindRenderbuffer(e.RENDERBUFFER,u),r>0?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,l,t,n):e.renderbufferStorage(e.RENDERBUFFER,l,t,n),u},i=o(e.RGBA8),s=o(e.DEPTH24_STENCIL8);e.bindRenderbuffer(e.RENDERBUFFER,null);let a=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,s),e.bindFramebuffer(e.FRAMEBUFFER,null),{fbo:a,color:i,stencil:s,width:t,height:n,samples:r,resolved:null}}function xC(e,t){e.deleteFramebuffer(t.fbo),e.deleteRenderbuffer(t.color),e.deleteRenderbuffer(t.stencil),t.resolved&&(e.deleteFramebuffer(t.resolved.fbo),e.deleteRenderbuffer(t.resolved.color))}function wC(e,t,n,r,o,i=0,s=0){let a=e.isEnabled(e.SCISSOR_TEST),l=e.getParameter(e.READ_FRAMEBUFFER_BINDING)??null,u=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING)??null;if(e.disable(e.SCISSOR_TEST),e.bindFramebuffer(e.READ_FRAMEBUFFER,t.fbo),t.samples>0&&(i!==0||s!==0||r!==t.width||o!==t.height)){let c=nj(e,t);e.bindFramebuffer(e.DRAW_FRAMEBUFFER,c),e.blitFramebuffer(0,0,r,o,0,0,r,o,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,c)}e.bindFramebuffer(e.DRAW_FRAMEBUFFER,n.fbo),e.blitFramebuffer(0,0,r,o,i,s,i+r,s+o,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,l),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,u),a&&e.enable(e.SCISSOR_TEST)}function nj(e,t){if(t.resolved)return t.resolved.fbo;let n=e.createRenderbuffer();e.bindRenderbuffer(e.RENDERBUFFER,n),e.renderbufferStorage(e.RENDERBUFFER,e.RGBA8,t.width,t.height),e.bindRenderbuffer(e.RENDERBUFFER,null);let r=e.createFramebuffer(),o=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING);return e.bindFramebuffer(e.DRAW_FRAMEBUFFER,r),e.framebufferRenderbuffer(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,n),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,o),t.resolved={fbo:r,color:n},r}var PC=1e-4,TC=1/8,rj=1024,jp=class{gl;budget;samples;surfaces=new Map;scratches=new Map;width=0;height=0;frame=0;stamp=[];tile=rj;composited=0;redrawn=0;declined=0;constructor(t,n){this.gl=t,this.budget=n;let r=t.getParameter(t.SAMPLES);this.samples=typeof r=="number"&&r>1?r:0}get bytes(){let t=this.keptBytes();for(let[n,r]of this.scratches)t+=r.width*r.height*(Math.max(1,n)*8+(r.resolved?4:0));return t}setBudget(t){this.budget=t,this.keptBytes()>t&&this.releaseAll()}beginFrame(t){this.frame++,this.stamp=t,this.composited=0,this.redrawn=0,this.declined=0}lookup(t,n,r,o,i=!0,s){this.fitTo(n,r);let a={x:0,y:0,width:n,height:r},l=this.surfaces.get(t);if(!l?.key||l.samples!==(i?this.samples:0)||!mC(l.stamp,this.stamp))return{kind:"redraw",window:a};let u=[o.transform[6],o.transform[7]],c=l.seen!==null&&l.seen[0]===u[0]&&l.seen[1]===u[1];if(dC(l.key,o))return l.frame=this.frame,l.seen=u,this.composited++,{kind:"kept",pixels:yw(l,0,0)};let d=fC(l.key,o),f=s!==void 0&&l.reach!==null,p=Math.round(n*TC),h=Math.round(r*TC),m={x:-p,y:-h,width:n+2*p,height:r+2*h};if(!d)return{kind:"redraw",window:l.panned&&f?m:a};if(l.seen=u,l.frame=this.frame,!f)return c?{kind:"redraw",window:a}:(this.declined++,{kind:"through"});let g=l.panned&&l.reach.window.width===n&&l.reach.window.height===r;l.panned=!0;let b=d[0]*s,x=d[1]*s,w=Math.round(b),y=Math.round(x),P=Math.abs(b-w)<=PC&&Math.abs(x-y)<=PC;return P&&oj(l.reach,w,y,n,r)?(this.composited++,{kind:"kept",pixels:yw(l,w,y)}):(!P||g)&&!c?(this.declined++,{kind:"through"}):{kind:"redraw",window:m}}reserve(t,n,r,o,i=!0,s){this.fitTo(n,r);let a={x:0,y:0,width:n,height:r};if(s&&(s.window.width>n||s.window.height>r)&&!this.fits(t,o))return this.reserve(t,n,r,ki(s.box,a),i,{box:s.box,window:a});let l=this.surfaces.get(t),u=o.width===0||o.height===0,c=i?this.samples:0,d=this.scratches.get(c),f=Math.max(d?.width??0,u?0:Math.min(o.width,this.tile)),p=Math.max(d?.height??0,u?0:Math.min(o.height,this.tile));if(!this.fits(t,o))return this.declined++,null;let h=l??{gl:null,rect:o,key:null,stamp:[],frame:this.frame,samples:c,reach:null,panned:!1,seen:null};this.surfaces.set(t,h),this.fitSurface(h,o),h.frame=this.frame,h.samples=c,this.redrawn++;let m=h.gl?this.scratchFor(c,f,p):null,g=h.rect;return{fbo:m?.fbo??null,rect:g,tiles:m?ij(g,this.tile):[],resolve:b=>{!m||!h.gl||wC(this.gl,m,h.gl,b.width,b.height,b.x-g.x,g.y+g.height-b.y-b.height)},commit:b=>(h.key=cC(b),h.stamp=this.stamp,h.reach=s?{box:{...s.box},window:{...s.window}}:null,h.seen=[b.transform[6],b.transform[7]],yw(h,0,0))}}decline(){this.declined++}endFrame(){let t=new Map;for(let[n,r]of this.surfaces){if(r.frame===this.frame){let o=t.get(r.samples)??{w:0,h:0},{width:i,height:s}=r.rect;t.set(r.samples,{w:Math.max(o.w,Math.min(i,this.tile)),h:Math.max(o.h,Math.min(s,this.tile))});continue}this.deleteSurface(r),this.surfaces.delete(n)}for(let[n,r]of this.scratches){let o=t.get(n)??{w:0,h:0};(this.redrawn===0||r.width>o.w||r.height>o.h)&&this.dropScratch(n)}}releaseAll(){for(let t of this.surfaces.values())this.deleteSurface(t);this.surfaces.clear();for(let t of[...this.scratches.keys()])this.dropScratch(t)}fitTo(t,n){t===this.width&&n===this.height||(this.releaseAll(),this.width=t,this.height=n)}fits(t,n){let r=this.surfaces.get(t);return this.keptBytes()+gw(n)-(r?gw(r.rect):0)<=this.budget}keptBytes(){let t=0;for(let n of this.surfaces.values())t+=gw(n.rect);return t}scratchFor(t,n,r){let o=this.scratches.get(t);if(o&&o.width===n&&o.height===r)return o;this.dropScratch(t);let i=bC(this.gl,n,r,t);return this.scratches.set(t,i),i}fitSurface(t,n){let r=t.rect;t.rect={...n},!(t.gl&&r.width===n.width&&r.height===n.height)&&(this.deleteSurface(t),n.width>0&&n.height>0&&(t.gl=yC(this.gl,n.width,n.height)))}deleteSurface(t){t.gl&&gC(this.gl,t.gl),t.gl=null}dropScratch(t){let n=this.scratches.get(t);n&&xC(this.gl,n),this.scratches.delete(t)}};function yw(e,t,n){let{rect:r}=e;return{texture:e.gl?.texture??null,rect:t===0&&n===0?r:{...r,x:r.x+t,y:r.y+n}}}function oj(e,t,n,r,o){let i=ki(e.box,{x:-t,y:-n,width:r,height:o});if(i.width===0||i.height===0)return!0;let s=e.window;return i.x>=s.x&&i.y>=s.y&&i.x+i.width<=s.x+s.width&&i.y+i.height<=s.y+s.height}function ij(e,t){let n=[];for(let r=0;r<e.height;r+=t)for(let o=0;o<e.width;o+=t)n.push({x:e.x+o,y:e.y+r,width:Math.min(t,e.width-o),height:Math.min(t,e.height-r)});return n}function gw(e){return e.width*e.height*4}function bw(e){let t=e.createTexture();return t?(e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([255,255,255,255])),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),t):null}var xw=new Set(["lowp","mediump","highp","precise","invariant","centroid","flat","smooth","noperspective"]),ww=/^[A-Za-z_]\w*$/,SC=16;function Pw(e){return[...AC(e).names]}function Tw(e){return AC(e).arrays}function AC(e){let{code:t,defines:n}=sj(e),r=kC(t),o=new Map,i=new Map,s=new Set,a=new Map,l=(g,b)=>{if(b>SC)return null;let x=null;for(let w of n.get(g)??[]){let y=vC(kC(w),P=>l(P,b+1));y!==null&&(x===null||y>x)&&(x=y)}return x??o.get(g)??null},u=(g,b)=>vC(r.slice(g,b),x=>l(x,0)),c=g=>{let b=0;for(let x=g;x<r.length;x++)if(r[x]==="("||r[x]==="["||r[x]==="{")b++;else if((r[x]===")"||r[x]==="]"||r[x]==="}")&&--b===0)return x;return r.length},d=g=>{if(r[g]!=="[")return[void 0,g];let b=c(g);return[u(g+1,b),b+1]},f=(g,b)=>{let x=[];for(;g<r.length&&r[g]!==";"&&r[g]!=="}";){let w=r[g],[y,P]=d(g+1);for(g=P,ww.test(w)&&x.push({name:w,size:y===void 0?b:y});g<r.length&&r[g]!==","&&r[g]!==";"&&r[g]!=="}";)g=r[g]==="("||r[g]==="["||r[g]==="{"?c(g)+1:g+1;r[g]===","&&g++}return[x,g]},p=g=>{let b=g+1,x=r[b]!=="{"?r[b++]:void 0,w=[];if(r[b]!=="{")return[w,b];let y=c(b);for(b++;b<y;){for(;xw.has(r[b]);)b++;let P;r[b]==="struct"?[P,b]=p(b):P=r[b++];let[S,v]=d(b),[A,N]=f(v,S);for(let M of A)M.size!==null&&w.push({type:P,name:M.name,size:M.size??null});b=N+1}if(x){let P=i.get(x)??[];for(let S of w)P.some(v=>v.name===S.name)||P.push(S);i.set(x,P)}return[w,y+1]},h=(g,b,x,w)=>{if(w>SC)return;if(x!==null){if(typeof b=="string"&&!i.has(b)){let P=a.get(g);(!P||x>P.size)&&a.set(g,{type:b,size:x})}for(let P=0;P<x;P++)h(`${g}[${P}]`,b,null,w+1);return}let y=typeof b=="string"?i.get(b):b;if(!y){s.add(g);return}for(let P of y)h(`${g}.${P.name}`,P.type,P.size,w+1)},m=0;for(let g=0;g<r.length;g++){let b=r[g];if(b==="{")m++;else if(b==="}")m--;else if(b==="struct")g=p(g)[1]-1;else if(m===0&&b==="const"){let x=g+1;for(;xw.has(r[x]);)x++;if((r[x]==="int"||r[x]==="uint")&&ww.test(r[x+1]??"")&&r[x+2]==="="){let w=x+3;for(;w<r.length&&r[w]!==";";)w++;let y=u(x+3,w),P=o.get(r[x+1]);y!==null&&(P===void 0||y>P)&&o.set(r[x+1],y)}}else if(m===0&&b==="uniform"){let x=g+1;for(;xw.has(r[x]);)x++;let w;if(r[x]==="struct")[w,x]=p(x);else if(r[x+1]==="{"){for(x=c(x+1)+1;x<r.length&&r[x]!==";";)x++;g=x;continue}else w=r[x++];let[y,P]=d(x),[S,v]=f(P,y);for(let A of S)A.size!==null&&h(A.name,w,A.size??null,0);g=v}}return{names:s,arrays:a}}function sj(e){let t=e.replace(/\\\r?\n/g,""),n="";for(let i=0;i<t.length;i++)if(t[i]==="/"&&t[i+1]==="/"){for(;i<t.length&&t[i]!==`
422
+ `,gC=["a_position","a_uv"],bC=["u_bounds","u_view","u_proj","u_screenToLocal","u_worldOrigin"],xC=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),wC=new Uint16Array([0,1,2,0,2,3]);var eh=class{gl;all=[];free=[];constructor(t){this.gl=t}get allocated(){return this.all.length>0}acquire(t,n){let r=this.free.findIndex(i=>i.width===t&&i.height===n),o=r>=0?this.free.splice(r,1)[0]:this.create(t,n);return o.used=!0,o}release(t){this.free.push(t)}reclaim(){let t=[];for(let n of this.all)n.used?t.push(n):this.destroy(n),n.used=!1;this.all=t,this.free=[...t]}releaseAll(){for(let t of this.all)this.destroy(t);this.all=[],this.free=[]}destroy(t){let n=this.gl;n.deleteFramebuffer(t.fbo),n.deleteTexture(t.texture),n.deleteRenderbuffer(t.stencil)}create(t,n){let r=this.gl,o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texImage2D(r.TEXTURE_2D,0,r.RGBA8,t,n,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null);let i=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,i),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH24_STENCIL8,t,n),r.bindRenderbuffer(r.RENDERBUFFER,null);let s=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,s),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,o,0),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,i),r.bindFramebuffer(r.FRAMEBUFFER,null);let a={fbo:s,texture:o,stencil:i,width:t,height:n,used:!1};return this.all.push(a),a}};function SC(e){return{...e,transform:e.transform.slice(),colorMatrix:e.colorMatrix.slice(),viewMatrix:e.viewMatrix?.slice(),screenMatrix:e.screenMatrix?.slice(),clips:e.clips.map(t=>({path:t.path,transform:t.transform.slice()})),window:e.window&&{...e.window}}}function kC(e,t){return e.children===t.children&&e.alpha===t.alpha&&sa(e.transform,t.transform)&&sa(e.colorMatrix,t.colorMatrix)&&vw(e.viewMatrix,t.viewMatrix)&&vw(e.screenMatrix,t.screenMatrix)&&fj(e.clips,t.clips)&&e.isolate===t.isolate&&AC(e.effects,t.effects)&&RC(e.window,t.window)}function vC(e,t){if(e.children!==t.children||e.alpha!==t.alpha||e.isolate!==t.isolate||!sa(e.colorMatrix,t.colorMatrix)||!vw(e.screenMatrix,t.screenMatrix)||!AC(e.effects,t.effects)||e.clips.length!==t.clips.length||!RC(e.window,t.window))return null;let n=PC(e.transform,t.transform);if(!n)return null;let r=(o,i)=>{if(o===void 0||i===void 0)return o===i;let s=PC(o,i);return s!==null&&TC(s[0],n[0])&&TC(s[1],n[1])};if(!r(e.viewMatrix,t.viewMatrix))return null;for(let o=0;o<e.clips.length;o++)if(e.clips[o].path!==t.clips[o].path||!r(e.clips[o].transform,t.clips[o].transform))return null;return n}function PC(e,t){for(let n of[0,1,2,3,4,5,8])if(e[n]!==t[n])return null;return[t[6]-e[6],t[7]-e[7]]}function TC(e,t){return Math.abs(e-t)<=1e-6*Math.max(1,Math.abs(e),Math.abs(t))}function AC(e,t){if(e===t)return!0;if((e?.length??0)!==(t?.length??0))return!1;for(let n=0;n<(e?.length??0);n++){let r=e[n],o=t[n];if(r.program.id!==o.program.id||r.reach!==o.reach||!cj(r.uniforms,o.uniforms))return!1}return!0}function cj(e,t){if(e===t)return!0;let n=Object.keys(e??{});return n.length!==Object.keys(t??{}).length?!1:n.every(r=>dj(e[r],t?.[r]))}function dj(e,t){return typeof e=="number"||t===void 0||typeof t=="number"?e===t:"id"in e||"id"in t?"id"in e&&"id"in t&&e.id===t.id:sa(e,t)}function vw(e,t){return e===void 0?t===void 0:t!==void 0&&sa(e,t)}function RC(e,t){return e===void 0||t===void 0?e===t:e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function fj(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].path!==t[n].path||!sa(e[n].transform,t[n].transform))return!1;return!0}function sa(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function NC(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function IC(e,t,n){let r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,t,n,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null);let o=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,o),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0),e.bindFramebuffer(e.FRAMEBUFFER,null),{texture:r,fbo:o}}function EC(e,t){e.deleteFramebuffer(t.fbo),e.deleteTexture(t.texture)}function MC(e,t,n,r){let o=l=>{let u=e.createRenderbuffer();return e.bindRenderbuffer(e.RENDERBUFFER,u),r>0?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,l,t,n):e.renderbufferStorage(e.RENDERBUFFER,l,t,n),u},i=o(e.RGBA8),s=o(e.DEPTH24_STENCIL8);e.bindRenderbuffer(e.RENDERBUFFER,null);let a=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,s),e.bindFramebuffer(e.FRAMEBUFFER,null),{fbo:a,color:i,stencil:s,width:t,height:n,samples:r,resolved:null}}function CC(e,t){e.deleteFramebuffer(t.fbo),e.deleteRenderbuffer(t.color),e.deleteRenderbuffer(t.stencil),t.resolved&&(e.deleteFramebuffer(t.resolved.fbo),e.deleteRenderbuffer(t.resolved.color))}function OC(e,t,n,r,o,i=0,s=0){let a=e.isEnabled(e.SCISSOR_TEST),l=e.getParameter(e.READ_FRAMEBUFFER_BINDING)??null,u=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING)??null;if(e.disable(e.SCISSOR_TEST),e.bindFramebuffer(e.READ_FRAMEBUFFER,t.fbo),t.samples>0&&(i!==0||s!==0||r!==t.width||o!==t.height)){let c=pj(e,t);e.bindFramebuffer(e.DRAW_FRAMEBUFFER,c),e.blitFramebuffer(0,0,r,o,0,0,r,o,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,c)}e.bindFramebuffer(e.DRAW_FRAMEBUFFER,n.fbo),e.blitFramebuffer(0,0,r,o,i,s,i+r,s+o,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,l),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,u),a&&e.enable(e.SCISSOR_TEST)}function pj(e,t){if(t.resolved)return t.resolved.fbo;let n=e.createRenderbuffer();e.bindRenderbuffer(e.RENDERBUFFER,n),e.renderbufferStorage(e.RENDERBUFFER,e.RGBA8,t.width,t.height),e.bindRenderbuffer(e.RENDERBUFFER,null);let r=e.createFramebuffer(),o=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING);return e.bindFramebuffer(e.DRAW_FRAMEBUFFER,r),e.framebufferRenderbuffer(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,n),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,o),t.resolved={fbo:r,color:n},r}var FC=1e-4,LC=1/8,hj=1024,th=class{gl;budget;samples;surfaces=new Map;scratches=new Map;width=0;height=0;frame=0;stamp=[];tile=hj;composited=0;redrawn=0;declined=0;constructor(t,n){this.gl=t,this.budget=n;let r=t.getParameter(t.SAMPLES);this.samples=typeof r=="number"&&r>1?r:0}get bytes(){let t=this.keptBytes();for(let[n,r]of this.scratches)t+=r.width*r.height*(Math.max(1,n)*8+(r.resolved?4:0));return t}setBudget(t){this.budget=t,this.keptBytes()>t&&this.releaseAll()}beginFrame(t){this.frame++,this.stamp=t,this.composited=0,this.redrawn=0,this.declined=0}lookup(t,n,r,o,i=!0,s){this.fitTo(n,r);let a={x:0,y:0,width:n,height:r},l=this.surfaces.get(t);if(!l?.key||l.samples!==(i?this.samples:0)||!NC(l.stamp,this.stamp))return{kind:"redraw",window:a};let u=[o.transform[6],o.transform[7]],c=l.seen!==null&&l.seen[0]===u[0]&&l.seen[1]===u[1];if(kC(l.key,o))return l.frame=this.frame,l.seen=u,this.composited++,{kind:"kept",pixels:Aw(l,0,0)};let d=vC(l.key,o),f=s!==void 0&&l.reach!==null,p=Math.round(n*LC),h=Math.round(r*LC),m={x:-p,y:-h,width:n+2*p,height:r+2*h};if(!d)return{kind:"redraw",window:l.panned&&f?m:a};if(l.seen=u,l.frame=this.frame,!f)return c?{kind:"redraw",window:a}:(this.declined++,{kind:"through"});let g=l.panned&&l.reach.window.width===n&&l.reach.window.height===r;l.panned=!0;let b=d[0]*s,x=d[1]*s,w=Math.round(b),y=Math.round(x),P=Math.abs(b-w)<=FC&&Math.abs(x-y)<=FC;return P&&mj(l.reach,w,y,n,r)?(this.composited++,{kind:"kept",pixels:Aw(l,w,y)}):(!P||g)&&!c?(this.declined++,{kind:"through"}):{kind:"redraw",window:m}}reserve(t,n,r,o,i=!0,s){this.fitTo(n,r);let a={x:0,y:0,width:n,height:r};if(s&&(s.window.width>n||s.window.height>r)&&!this.fits(t,o))return this.reserve(t,n,r,Mi(s.box,a),i,{box:s.box,window:a});let l=this.surfaces.get(t),u=o.width===0||o.height===0,c=i?this.samples:0,d=this.scratches.get(c),f=Math.max(d?.width??0,u?0:Math.min(o.width,this.tile)),p=Math.max(d?.height??0,u?0:Math.min(o.height,this.tile));if(!this.fits(t,o))return this.declined++,null;let h=l??{gl:null,rect:o,key:null,stamp:[],frame:this.frame,samples:c,reach:null,panned:!1,seen:null};this.surfaces.set(t,h),this.fitSurface(h,o),h.frame=this.frame,h.samples=c,this.redrawn++;let m=h.gl?this.scratchFor(c,f,p):null,g=h.rect;return{fbo:m?.fbo??null,rect:g,tiles:m?yj(g,this.tile):[],resolve:b=>{!m||!h.gl||OC(this.gl,m,h.gl,b.width,b.height,b.x-g.x,g.y+g.height-b.y-b.height)},commit:b=>(h.key=SC(b),h.stamp=this.stamp,h.reach=s?{box:{...s.box},window:{...s.window}}:null,h.seen=[b.transform[6],b.transform[7]],Aw(h,0,0))}}decline(){this.declined++}endFrame(){let t=new Map;for(let[n,r]of this.surfaces){if(r.frame===this.frame){let o=t.get(r.samples)??{w:0,h:0},{width:i,height:s}=r.rect;t.set(r.samples,{w:Math.max(o.w,Math.min(i,this.tile)),h:Math.max(o.h,Math.min(s,this.tile))});continue}this.deleteSurface(r),this.surfaces.delete(n)}for(let[n,r]of this.scratches){let o=t.get(n)??{w:0,h:0};(this.redrawn===0||r.width>o.w||r.height>o.h)&&this.dropScratch(n)}}releaseAll(){for(let t of this.surfaces.values())this.deleteSurface(t);this.surfaces.clear();for(let t of[...this.scratches.keys()])this.dropScratch(t)}fitTo(t,n){t===this.width&&n===this.height||(this.releaseAll(),this.width=t,this.height=n)}fits(t,n){let r=this.surfaces.get(t);return this.keptBytes()+Rw(n)-(r?Rw(r.rect):0)<=this.budget}keptBytes(){let t=0;for(let n of this.surfaces.values())t+=Rw(n.rect);return t}scratchFor(t,n,r){let o=this.scratches.get(t);if(o&&o.width===n&&o.height===r)return o;this.dropScratch(t);let i=MC(this.gl,n,r,t);return this.scratches.set(t,i),i}fitSurface(t,n){let r=t.rect;t.rect={...n},!(t.gl&&r.width===n.width&&r.height===n.height)&&(this.deleteSurface(t),n.width>0&&n.height>0&&(t.gl=IC(this.gl,n.width,n.height)))}deleteSurface(t){t.gl&&EC(this.gl,t.gl),t.gl=null}dropScratch(t){let n=this.scratches.get(t);n&&CC(this.gl,n),this.scratches.delete(t)}};function Aw(e,t,n){let{rect:r}=e;return{texture:e.gl?.texture??null,rect:t===0&&n===0?r:{...r,x:r.x+t,y:r.y+n}}}function mj(e,t,n,r,o){let i=Mi(e.box,{x:-t,y:-n,width:r,height:o});if(i.width===0||i.height===0)return!0;let s=e.window;return i.x>=s.x&&i.y>=s.y&&i.x+i.width<=s.x+s.width&&i.y+i.height<=s.y+s.height}function yj(e,t){let n=[];for(let r=0;r<e.height;r+=t)for(let o=0;o<e.width;o+=t)n.push({x:e.x+o,y:e.y+r,width:Math.min(t,e.width-o),height:Math.min(t,e.height-r)});return n}function Rw(e){return e.width*e.height*4}function Nw(e){let t=e.createTexture();return t?(e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([255,255,255,255])),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),t):null}var Iw=new Set(["lowp","mediump","highp","precise","invariant","centroid","flat","smooth","noperspective"]),Ew=/^[A-Za-z_]\w*$/,_C=16;function Mw(e){return[...HC(e).names]}function Cw(e){return HC(e).arrays}function HC(e){let{code:t,defines:n}=gj(e),r=DC(t),o=new Map,i=new Map,s=new Set,a=new Map,l=(g,b)=>{if(b>_C)return null;let x=null;for(let w of n.get(g)??[]){let y=BC(DC(w),P=>l(P,b+1));y!==null&&(x===null||y>x)&&(x=y)}return x??o.get(g)??null},u=(g,b)=>BC(r.slice(g,b),x=>l(x,0)),c=g=>{let b=0;for(let x=g;x<r.length;x++)if(r[x]==="("||r[x]==="["||r[x]==="{")b++;else if((r[x]===")"||r[x]==="]"||r[x]==="}")&&--b===0)return x;return r.length},d=g=>{if(r[g]!=="[")return[void 0,g];let b=c(g);return[u(g+1,b),b+1]},f=(g,b)=>{let x=[];for(;g<r.length&&r[g]!==";"&&r[g]!=="}";){let w=r[g],[y,P]=d(g+1);for(g=P,Ew.test(w)&&x.push({name:w,size:y===void 0?b:y});g<r.length&&r[g]!==","&&r[g]!==";"&&r[g]!=="}";)g=r[g]==="("||r[g]==="["||r[g]==="{"?c(g)+1:g+1;r[g]===","&&g++}return[x,g]},p=g=>{let b=g+1,x=r[b]!=="{"?r[b++]:void 0,w=[];if(r[b]!=="{")return[w,b];let y=c(b);for(b++;b<y;){for(;Iw.has(r[b]);)b++;let P;r[b]==="struct"?[P,b]=p(b):P=r[b++];let[S,v]=d(b),[A,N]=f(v,S);for(let M of A)M.size!==null&&w.push({type:P,name:M.name,size:M.size??null});b=N+1}if(x){let P=i.get(x)??[];for(let S of w)P.some(v=>v.name===S.name)||P.push(S);i.set(x,P)}return[w,y+1]},h=(g,b,x,w)=>{if(w>_C)return;if(x!==null){if(typeof b=="string"&&!i.has(b)){let P=a.get(g);(!P||x>P.size)&&a.set(g,{type:b,size:x})}for(let P=0;P<x;P++)h(`${g}[${P}]`,b,null,w+1);return}let y=typeof b=="string"?i.get(b):b;if(!y){s.add(g);return}for(let P of y)h(`${g}.${P.name}`,P.type,P.size,w+1)},m=0;for(let g=0;g<r.length;g++){let b=r[g];if(b==="{")m++;else if(b==="}")m--;else if(b==="struct")g=p(g)[1]-1;else if(m===0&&b==="const"){let x=g+1;for(;Iw.has(r[x]);)x++;if((r[x]==="int"||r[x]==="uint")&&Ew.test(r[x+1]??"")&&r[x+2]==="="){let w=x+3;for(;w<r.length&&r[w]!==";";)w++;let y=u(x+3,w),P=o.get(r[x+1]);y!==null&&(P===void 0||y>P)&&o.set(r[x+1],y)}}else if(m===0&&b==="uniform"){let x=g+1;for(;Iw.has(r[x]);)x++;let w;if(r[x]==="struct")[w,x]=p(x);else if(r[x+1]==="{"){for(x=c(x+1)+1;x<r.length&&r[x]!==";";)x++;g=x;continue}else w=r[x++];let[y,P]=d(x),[S,v]=f(P,y);for(let A of S)A.size!==null&&h(A.name,w,A.size??null,0);g=v}}return{names:s,arrays:a}}function gj(e){let t=e.replace(/\\\r?\n/g,""),n="";for(let i=0;i<t.length;i++)if(t[i]==="/"&&t[i+1]==="/"){for(;i<t.length&&t[i]!==`
423
423
  `;)i++;n+=`
424
424
  `}else if(t[i]==="/"&&t[i+1]==="*"){let s=t.indexOf("*/",i+2);i=s<0?t.length:s+1,n+=" "}else n+=t[i];let r=new Map;return{code:n.split(`
425
425
  `).map(i=>{if(!/^\s*#/.test(i))return i;let s=/^\s*#\s*define\s+([A-Za-z_]\w*)(\(?)(.*)$/.exec(i);return s&&!s[2]&&r.set(s[1],[...r.get(s[1])??[],s[3].trim()]),""}).join(`
426
- `),defines:r}}function kC(e){return e.match(/[A-Za-z_]\w*|\d[\w.]*|\S/g)??[]}function aj(e){let t=/^(?:0[xX]([0-9a-fA-F]+)|(0[0-7]*)|([1-9]\d*))[uU]?$/.exec(e);return t?t[1]!==void 0?parseInt(t[1],16):t[2]!==void 0?parseInt(t[2],8):parseInt(t[3],10):null}function vC(e,t){let n=0,r=()=>{let a=e[n++];if(a==="("){let l=i();return e[n++]===")"?l:null}if(a==="-"){let l=r();return l===null?null:-l}return a==="+"?r():a===void 0?null:aj(a)??(ww.test(a)?t(a):null)},o=()=>{let a=r();for(;a!==null&&(e[n]==="*"||e[n]==="/"||e[n]==="%");){let l=e[n++],u=r();if(u===null||l!=="*"&&u===0)return null;a=l==="*"?a*u:l==="/"?Math.trunc(a/u):a%u}return a},i=()=>{let a=o();for(;a!==null&&(e[n]==="+"||e[n]==="-");){let l=e[n++],u=o();if(u===null)return null;a=l==="+"?a+u:a-u}return a},s=i();return n===e.length&&s!==null&&s>=0?s:null}function lj(e,t){return[...iC,...Pw(e),...Pw(t)]}function Sw(e,t){let n=t.vert===""?rC:t.vert,r=new $r(e,n,t.frag);return r.lookupUniforms(lj(n,t.frag)),r.lookupUniformArrays(new Map([...Tw(n),...Tw(t.frag)])),r.lookupAttributes(oC),r}var NC={composited:0,redrawn:0,declined:0,bytes:0};function $p(){return typeof performance<"u"?performance.now():Date.now()}var uj={pattern:[pA,gA],gradient:[hA,bA],texture:[mA,xA]},Lu=class{gl;stats={drawCalls:0,ms:0,spans:[],retained:NC};pathFill;pathFillVColor;batchFill;batchVariants;gradFill;patternFill;glyphPaintPrograms=new Map;meshCache;textureCache;imageCache;gradRamps;programRegistry=new Map;programSources=new Map;quadVbo=null;quadIbo=null;drawBatch;whiteTexture=null;groupState=new lf;widthCss;heightCss;dpr;canvas=null;lossTarget=null;target=null;effectTargets;retained;programEpoch=0;paintScratch;imageMinification;flattenTolerance;bakeBudget;textOutlineMinScreenSize;contextLost=!1;boundOnLost=t=>this.onContextLost(t);boundOnRestored=()=>this.onContextRestored();disposed=!1;paintResources=Ya();constructor(t){if(!t.gl&&!t.canvas)throw new Error("WeaselRenderer requires either gl or canvas");let n=t.gl??t.canvas.getContext("webgl2",{stencil:!0});if(!n)throw new Error("WeaselRenderer: WebGL2 not available");this.gl=n,this.effectTargets=new Kp(this.gl),this.retained=new jp(this.gl,t.retainBudget??402653184),this.paintScratch=new Wd(this.gl);let r=typeof this.gl.getContextAttributes=="function"?this.gl.getContextAttributes():null;if(r&&r.stencil===!1)throw new Error("WeaselRenderer: the supplied WebGL2 context has no stencil buffer. Create it with { stencil: true } \u2014 clips and even-odd fills need one.");this.widthCss=t.width,this.heightCss=t.height,this.dpr=t.dpr,this.imageMinification=t.imageMinification??"auto",this.flattenTolerance=t.flattenTolerance,this.bakeBudget=t.bakeBudget??$o,this.textOutlineMinScreenSize=t.textOutlineMinScreenSize??Wp,this.canvas=t.canvas??null,this.canvas&&(this.canvas.width=Math.round(t.width*t.dpr),this.canvas.height=Math.round(t.height*t.dpr));let o=this.canvas??this.gl.canvas??null;o&&typeof o.addEventListener=="function"&&(this.lossTarget=o,this.lossTarget.addEventListener("webglcontextlost",this.boundOnLost),this.lossTarget.addEventListener("webglcontextrestored",this.boundOnRestored)),this.applyGlState(),this.applyTarget(),this.pathFill=new kn(this.gl,lA),this.pathFillVColor=new kn(this.gl,uA),this.gradFill=new kn(this.gl,cA),this.patternFill=new kn(this.gl,dA),this.batchVariants=new Ud(this.gl),this.batchFill=Yg(this.gl),this.meshCache=new Nl(this.gl),this.textureCache=new El(this.gl),this.imageCache=new ks(this.gl,this.imageMinification),this.gradRamps=new _l(this.gl),this.uploadQuadGeometry(),this.drawBatch=new Fu(this.gl,this.batchFill),this.whiteTexture=bw(this.gl)}lazyPrograms(){return[this.pathFill,this.pathFillVColor,this.gradFill,this.patternFill,...this.batchVariants.lazy()]}uploadQuadGeometry(){let t=this.gl;if(this.quadVbo=t.createBuffer(),this.quadIbo=t.createBuffer(),!this.quadVbo||!this.quadIbo)throw new Error("WeaselRenderer: failed to create quad geometry buffers");t.bindBuffer(t.ARRAY_BUFFER,this.quadVbo),t.bufferData(t.ARRAY_BUFFER,sC,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.quadIbo),t.bufferData(t.ELEMENT_ARRAY_BUFFER,aC,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}registerProgram(t){if(this.disposed)return;let n=An(t.id);if(!n)throw new Error(`WeaselRenderer.registerProgram: program "${t.id}" not found in source registry. Call the module-level registerProgram() first.`);this.installProgram(t.id,n,Sw(this.gl,n))}installProgram(t,n,r){let o=this.programRegistry.get(t);o&&(this.gl.deleteProgram(o.handle),this.programEpoch++),this.programRegistry.set(t,r),this.programSources.set(t,n)}refreshPrograms(){for(let[t,n]of this.programSources){let r=An(t);if(!(!r||r===n)){if(r.vert===n.vert&&r.frag===n.frag){this.programSources.set(t,r);continue}try{this.installProgram(t,r,Sw(this.gl,r))}catch(o){this.programSources.set(t,r),console.error(`weasel: failed to recompile re-registered program "${t}"; still drawing the previous one:`,o)}}}}ensureProgram(t){let n=this.programRegistry.get(t);if(n)return n;if(this.disposed||!An(t))return null;try{this.registerProgram({id:t})}catch(r){return console.error(`weasel: failed to compile paint program "${t}":`,r),null}return this.programRegistry.get(t)??null}glyphPaintProgram(t){let n=this.glyphPaintPrograms.get(t);if(n)return n;let[r,o]=uj[t],i=new $r(this.gl,fA,r);return i.lookupUniforms(o),i.lookupAttributes(wA),this.glyphPaintPrograms.set(t,i),i}applyGlState(){let t=this.gl;t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.clearColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.bindVertexArray(null),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1)}deviceRect(){let t=this.target?.origin.x??0,n=this.target?.origin.y??0,r=Math.round(t*this.dpr),o=Math.round(n*this.dpr),i=Math.round((t+this.widthCss)*this.dpr)-r;return{x:r,y:o,width:i,height:Math.round((n+this.heightCss)*this.dpr)-o}}applyTarget(){let t=this.gl,{x:n,y:r,width:o,height:i}=this.glRect();if(t.viewport(n,r,o,i),!this.target){t.disable(t.SCISSOR_TEST);return}t.scissor(n,r,o,i),t.enable(t.SCISSOR_TEST)}glRect(){let{x:t,y:n,width:r,height:o}=this.deviceRect();return this.target?{x:t,y:this.gl.drawingBufferHeight-n-o,width:r,height:o}:{x:0,y:0,width:r,height:o}}setTarget(t){this.target=t,this.applyTarget()}getTarget(){return this.target}isContextLost(){return this.contextLost}onContextLost(t){t.preventDefault(),this.contextLost=!0}onContextRestored(){this.contextLost=!1,this.applyGlState(),this.applyTarget(),this.effectTargets.releaseAll(),this.retained.releaseAll(),this.paintScratch.release(),this.paintResources.release(),this.paintResources=Ya();for(let t of this.lazyPrograms())t.abandon();this.batchFill=Yg(this.gl),this.glyphPaintPrograms.clear(),this.meshCache=new Nl(this.gl),this.textureCache=new El(this.gl),this.imageCache.abandon(),this.imageCache=new ks(this.gl,this.imageMinification),this.gradRamps=new _l(this.gl),this.uploadQuadGeometry(),this.drawBatch=new Fu(this.gl,this.batchFill),this.whiteTexture=bw(this.gl);for(let t of this.programRegistry.keys()){let n=An(t);if(n)try{this.programRegistry.set(t,Sw(this.gl,n)),this.programSources.set(t,n)}catch(r){console.error(`weasel: failed to recompile program "${t}" after context restore:`,r)}}}dispose(){if(this.disposed)return;this.disposed=!0;let t=this.gl;this.lossTarget&&(this.lossTarget.removeEventListener("webglcontextlost",this.boundOnLost),this.lossTarget.removeEventListener("webglcontextrestored",this.boundOnRestored)),this.meshCache.dispose(),this.paintResources.release();for(let n of this.lazyPrograms())n.release();for(let n of[this.batchFill,...this.glyphPaintPrograms.values()])t.deleteProgram(n.handle);this.glyphPaintPrograms.clear();for(let n of this.programRegistry.values())t.deleteProgram(n.handle);this.programRegistry.clear(),this.programSources.clear(),this.textureCache.free(),this.imageCache.dispose(),this.gradRamps.free(),this.quadVbo&&t.deleteBuffer(this.quadVbo),this.quadIbo&&t.deleteBuffer(this.quadIbo),this.drawBatch.dispose(),this.whiteTexture&&t.deleteTexture(this.whiteTexture),this.whiteTexture=null,this.effectTargets.releaseAll(),this.retained.releaseAll(),this.paintScratch.release()}render(t,n,r){if(this.contextLost||this.disposed)return;let o=$p(),i={drawCalls:0},s=[];this.stats={drawCalls:0,ms:0,spans:s,retained:NC};let a=this.gl;this.meshCache.drainPendingDeletes(),this.imageCache.beginFrame(),this.textureCache.sweep(si),this.refreshPrograms(),this.retained.beginFrame([Ko(),si.getVersion(),Ru.getVersion(),this.programEpoch,this.flattenTolerance,this.widthCss,this.heightCss,this.dpr]),jc(this.bakeBudget),this.groupState.reset(),this.drawBatch.reset(),this.effectTargets.reclaim(),a.bindFramebuffer(a.FRAMEBUFFER,null),this.applyGlState(),this.applyTarget(),this.target?.clear!==!1&&(a.stencilMask(255),a.clear(a.COLOR_BUFFER_BIT|a.STENCIL_BUFFER_BIT));let l=this.deviceRect(),u=this.glRect(),{pathFill:c,pathFillVColor:d,gradFill:f,patternFill:p}=this,h={gl:a,get pathFill(){return c.get()},get pathFillVColor(){return d.get()},batchFill:this.batchFill,batchVariants:this.batchVariants,get gradFill(){return f.get()},get patternFill(){return p.get()},meshCache:this.meshCache,textureCache:this.textureCache,imageCache:this.imageCache,gradRamps:this.gradRamps,programRegistry:this.programRegistry,ensureProgram:x=>this.ensureProgram(x),glyphPaintProgram:x=>this.glyphPaintProgram(x),quadVbo:this.quadVbo,quadIbo:this.quadIbo,drawBatch:this.drawBatch,whiteTexture:this.whiteTexture,state:this.groupState,widthCss:this.widthCss,heightCss:this.heightCss,clipDepth:0,clipStack:[],flattenTolerance:XA(this.flattenTolerance,this.dpr),textOutlineMinScreenSize:this.textOutlineMinScreenSize,viewMatrix:n,screenMatrix:r?.screen,effectTargets:this.effectTargets,retained:this.retained,paintScratch:this.paintScratch,renderTarget:null,fragOrigin:[u.x,u.y],deviceWidth:l.width,deviceHeight:l.height,restoreTargetRect:()=>this.applyTarget(),paintResources:this.paintResources,stats:i};this.drawBatch.clip=null;let m=r?.spans??[],g=0;for(let x=0;x<m.length;x++){let w=m[x];for(;g<w.start;g++)Ii(h,t[g]);let y=i.drawCalls,P=$p();for(;g<w.end;g++)Ii(h,t[g]);x===m.length-1&&g>=t.length&&ye(h),s.push({id:w.id,drawCalls:i.drawCalls-y,ms:$p()-P})}for(;g<t.length;g++)Ii(h,t[g]);ye(h),this.meshCache.freeTransient();let b=this.retained;b.endFrame(),this.stats.retained={composited:b.composited,redrawn:b.redrawn,declined:b.declined,bytes:b.bytes},this.stats.drawCalls=i.drawCalls,this.stats.ms=$p()-o}lastFrameStats(){return this.stats}setFlattenTolerance(t){this.flattenTolerance=t}setRetainBudget(t){this.retained.setBudget(t??402653184)}setImageMinification(t){let n=t??"auto";n!==this.imageMinification&&(this.imageMinification=n,this.imageCache.dispose(),this.imageCache=new ks(this.gl,n))}resize(t){this.widthCss=t.width,this.heightCss=t.height,this.dpr=t.dpr,this.canvas&&(this.canvas.width=Math.round(t.width*t.dpr),this.canvas.height=Math.round(t.height*t.dpr)),this.applyTarget()}_gl(){return this.gl}_pathFill(){return this.pathFill.get()}_pathFillVColor(){return this.pathFillVColor.get()}_drawBatch(){return this.drawBatch}_batchFill(){return this.batchFill}_batchVariants(){return this.batchVariants}_gradFill(){return this.gradFill.get()}_patternFill(){return this.patternFill.get()}_meshCache(){return this.meshCache}_textureCache(){return this.textureCache}_imageCache(){return this.imageCache}_gradRamps(){return this.gradRamps}_groupState(){return this.groupState}_widthCss(){return this.widthCss}_heightCss(){return this.heightCss}_dpr(){return this.dpr}};Pe();var cj={...Ie};function kw(e,t,n,r,o,i,s,a,l,u=1){let c=Wf(cj,r,a,u);return{kind:"text",x:e,y:t,runs:lu(n,c,u),align:c.align,direction:c.direction,justify:c.align==="justify",maxWidth:o,style:r??{},height:i,verticalAlign:s,width:l}}function vw(e,t=1){let{runs:n,opts:r}=hp(e,t);return{kind:"text",x:e.x,y:e.y,runs:dj(n,e),align:r.align,direction:r.direction,justify:r.justify,maxWidth:r.maxWidth,width:r.alignWidth,style:e.style??{},height:e.height,verticalAlign:e.verticalAlign}}function dj(e,t){return e.every(n=>IC(n.fill?.paint)&&IC(n.stroke?.paint))?e:e.map(n=>{let r=n.fill&&Ut(n.fill,t),o=n.stroke?.paint&&Ai(n.stroke.paint,t);return{...n,fill:r,stroke:n.stroke&&{...n.stroke,paint:o||void 0}}})}function IC(e){return e==null||Dt(e)}function EC(e){return typeof e=="number"?{x:e,y:e}:e}function Aw(e,t){let n=EC(t.pan),r=EC(t.zoom??1),o=t.anchor??{x:0,y:0};return{x:o.x+(e.x-o.x)*n.x,y:o.y+(e.y-o.y)*n.y,scale:{x:1+(e.scale.x-1)*r.x,y:1+(e.scale.y-1)*r.y}}}function Yp(e,t){let n=Aw(e,t),r=e.scale.x/n.scale.x,o=e.scale.y/n.scale.y;return{scale:{x:r,y:o},offset:{x:n.x-r*e.x,y:n.y-o*e.y}}}function Rw(e,t){return{x:t.x*e.scale.x+e.offset.x,y:t.y*e.scale.y+e.offset.y}}function fj(e,t){let n=t({x:e.x,y:e.y}),r=t({x:e.x+e.width,y:e.y+e.height});return{x:Math.min(n.x,r.x),y:Math.min(n.y,r.y),width:Math.abs(r.x-n.x),height:Math.abs(r.y-n.y)}}function CC(e,t){return{...t,...fj(t,n=>Rw(e,n))}}function Nw(e,t){if(e===t)return null;let n=e??MC,r=t??MC,o=r.scale.x/n.scale.x,i=r.scale.y/n.scale.y,s={scale:{x:o,y:i},offset:{x:r.offset.x-n.offset.x*o,y:r.offset.y-n.offset.y*i}};return s.scale.x===1&&s.scale.y===1&&s.offset.x===0&&s.offset.y===0?null:s}var MC={scale:{x:1,y:1},offset:{x:0,y:0}};function Iw(e){return[e.scale.x,0,0,e.scale.y,e.offset.x,e.offset.y]}var pj=["weasel.debug","weaseldraw.debug"],Ew=null;function hj(){let e={all:!1,set:new Set};if(typeof localStorage>"u")return e;try{for(let t of pj){let n=localStorage.getItem(t);if(!(n==null||n===""))return n==="1"||n==="true"||n==="*"?{all:!0,set:new Set}:{all:!1,set:new Set(n.split(/[\s,]+/).filter(Boolean))}}return e}catch{return e}}function mj(){return Ew===null&&(Ew=hj()),Ew}function qp(e){let t=mj();return t.all?!0:e===void 0?t.set.size>0:t.set.has(e)}function Xp(e,...t){qp(e)&&console.debug(`[${e}]`,...t)}function Nt(e,...t){qp(e)&&console.warn(`[${e}]`,...t)}ee();function It(e){return e.closure!=="identity"}function Vt(e,t,n){let r=[t],o=new Set([t]),i=e.getParent(t);for(;i!==null&&!o.has(i);)o.add(i),(e.definesFrame?.(i)??!0)&&r.push(i),i=e.getParent(i);let s=e.getPose(r[r.length-1]),a=e.childFrame;for(let l=r.length-2;l>=0;l--){let u=a===void 0?s:a.call(e,r[l+1],s);s=n(u,e.getPose(r[l]))}return s}function ea(e,t,n){return FC(e,t,Vt(e,t,n))}function FC(e,t,n){return e.childFrame===void 0||!(e.definesFrame?.(t)??!0)?n:e.childFrame(t,n)}function ta(e,t,n,r,o){let i=$n(e,n);return i===null?t:o(ea(e,i,r),t)}function $n(e,t){let n=new Set,r=t;for(;r!==null&&!n.has(r);){if(e.definesFrame?.(r)??!0)return r;n.add(r),r=e.getParent(r)}return null}var OC=new WeakMap;function LC(e){let t=OC.get(e);if(t!==void 0)return t;let n=new WeakMap,r=(o,i)=>{if(typeof o!="object"||o===null||typeof i!="object"||i===null)return e(o,i);let s=n.get(o);s===void 0&&n.set(o,s=new WeakMap);let a=s.get(i);return a===void 0&&s.set(i,a=e(o,i)),a};return OC.set(e,r),r}function _C(e,t,n){return{...e,x:e.x+t,y:e.y+n}}function Mw(e,t){return t===0&&e.rotation===void 0?e:{...e,rotation:t}}function DC(e,t,n){let[r,o,i,s]=ht(ul(-t),n),a=Math.abs(r-1)<1e-12&&Math.abs(o)<1e-12&&Math.abs(i)<1e-12&&Math.abs(s-1)<1e-12,l=Mw({...e},t);return a?delete l.transform:l.transform=[r,o,i,s],l}function BC(e,t,n){return{...e,x:t-e.width/2,y:n-e.height/2}}var HC=[1,0,0,1,0,0];function GC(e,t,n,r,o){let i=Math.cos(n),s=Math.sin(n);return[e+(r-e)*i-(o-t)*s,t+(r-e)*s+(o-t)*i]}function yj(e,t){let n=e.rotation??0,r=Un(e)&&Ce(e);if(r){let[s,a]=xn(r,e.x+t.x+t.width/2,e.y+t.y+t.height/2),l=ht(r,Ce(t)??HC);return DC(BC(t,s,a),(t.rotation??0)+n,l)}let[o,i]=GC(e.x+e.width/2,e.y+e.height/2,n,e.x+t.x+t.width/2,e.y+t.y+t.height/2);return Mw({...t,x:o-t.width/2,y:i-t.height/2},(t.rotation??0)+n)}function gj(e,t){let n=e.rotation??0,r=Un(e)&&ni(e);if(r){let[s,a]=xn(r,t.x+t.width/2,t.y+t.height/2),l=ht(r,Ce(t)??HC);return DC(BC(t,s-e.x,a-e.y),(t.rotation??0)-n,l)}let[o,i]=GC(e.x+e.width/2,e.y+e.height/2,-n,t.x+t.width/2,t.y+t.height/2);return Mw({...t,x:o-e.x-t.width/2,y:i-e.y-t.height/2},(t.rotation??0)-n)}function bj(e,t){return _C(e,-t.x,-t.y)}function xj(e,t){let n=Ce(e);if(!n)return bj(e,t);let[r,o,i,s]=n;return _C(e,-(r*t.x+i*t.y),-(o*t.x+s*t.y))}var Jp={compose:yj,decompose:gj,closure:"rigid",scroll:xj};var na=!1;function UC(){na=!0}function VC(e){let t=na;na=!1;try{return{value:e(),fonts:na}}finally{na=t||na}}function Cw(){return Xa()}var WC=4;function Ow(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Qp(e,t=WC){if(t<=0)return e;if(Array.isArray(e))return e.map(n=>Qp(n,t-1));if(Ow(e))return e.slice();if(Jt(e)){let n={...e};for(let r in n){let o=n[r];typeof o=="object"&&o!==null&&(n[r]=Qp(o,t-1))}return n}return e}function ko(e,t,n=WC){if(e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return Object.is(e,t);if(n<=0)return!1;let r=Object.getPrototypeOf(e);if(Yi(r)){if(!Yi(Object.getPrototypeOf(t)))return!1;let o=e,i=t,s=0;for(let a in o){s++;let l=o[a],u=i[a];if(l===u){if(u===void 0&&!(a in i))return!1;continue}if(!ko(l,u,n-1))return!1}for(let a in i)if(--s<0)return!1;return!0}if(Array.isArray(e)||Ow(e)){let o=e;if(!(Array.isArray(t)||Ow(t)))return!1;let i=t;if(o.length!==i.length)return!1;for(let s=0;s<o.length;s++)if(!ko(o[s],i[s],n-1))return!1;return!0}return!1}function _u(){return{nodes:[],poses:[],data:[],layers:[],paths:[],children:[],faces:null}}var Fw=class{constructor(t,n,r){this.dep=t;this.record=n;this.index=r;this.node=t.node,this.pose=t.pose}dep;record;index;node;pose;get path(){return this.record.paths[this.index]=this.dep.path}get inherited(){return this.dep.inherited}get children(){let t=this.dep.children;if(t===void 0)return;let n=this.record.children[this.index]=_u();return zC(n,t)}};function zC(e,t){return e.nodes.length=0,e.poses.length=0,e.data.length=0,e.layers.length=0,e.paths.length=0,e.children.length=0,t.map((n,r)=>(e.nodes.push(n?.node),e.poses.push(n===void 0?void 0:Qp(n.pose)),e.data.push(n?.node.data),e.layers.push(n?.node.layer),e.paths.push(void 0),e.children.push(void 0),n===void 0?void 0:new Fw(n,e,r)))}function Zp(e,t,n){let r=zC(e,t),o=Cw(),{value:i,fonts:s}=VC(()=>n(r));return e.faces=s?o:null,i}function eh(e,t,n){if(e.nodes.length!==t.length||e.faces!==null&&e.faces!==Cw())return!1;for(let r=0;r<t.length;r++)if(!KC(e,r,n(t[r])))return!1;return e.faces!==null&&UC(),!0}function KC(e,t,n){if(e.nodes[t]!==(n===void 0?void 0:n.node))return!1;if(n===void 0)return!0;if(e.data[t]!==n.node.data||e.layers[t]!==n.node.layer||!ko(e.poses[t],n.pose))return!1;let r=e.paths[t];if(r!==void 0&&r!==n.path)return!1;let o=e.children[t];if(o===void 0)return!0;let i=n.children;return i===void 0||i.length!==o.nodes.length?!1:i.every((s,a)=>KC(o,a,s))}ee();ee();Pe();function jC(e,t,n){return{fill:Ne(e.fill,Ne(t?.fill,n?.fill)),stroke:Re(e.stroke,Re(t?.stroke,n?.stroke))}}var $C=new WeakMap;function YC(e){if(e.length===0)return null;let t=e.length===1?e[0].path:wj(e.map(r=>r.path)),n=t===e[0].path?{...t}:t;return $C.set(n,e),n}function th(e){return e==null?void 0:$C.get(e)}function wj(e){return Uy(e.map(t=>t.kind==="rect"?wg(ei(t)):t))}function XC(e,t,n,r,o){if(e===void 0||!It(e))return null;let i={getPose:a=>r(a),getParent:a=>n(a)?.parent??null,definesFrame:a=>o(a)},s=$n(i,t.parent??null);return(a,l)=>{let u=$n(i,n(a)?.parent??null);if(u===s)return l;let c=u===null?l:e.compose(Vt(i,u,e.compose),l);return s===null?c:e.decompose(Vt(i,s,e.compose),c)}}function ra(e){let t=e;return typeof t=="object"&&t!==null&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"}function nh(e,t,n){return!ra(t)||!ra(n)||t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height?e:Du(e,dr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height))}function JC(e,t,n){if(!ra(t)||!ra(n))return e;let r=ni(t),o=Ce(n),i=dr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height);return r!==null&&(i=ht(i,r)),o!==null&&(i=ht(o,i)),Du(e,i)}function rh(e,t,n){if(!ra(t)||!ra(n))return e;let r=Ce(n),o=t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height;if(r===null&&o)return e;let i=dr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height);return Du(e,r===null?i:ht(r,i))}function Du(e,t){let n=t.join(","),r=qC.get(e);if(r?.key===n)return r.path;let o=th(e),i=o===void 0?At(e,t):YC(o.map(s=>({...s,path:At(s.path,t)})));return qC.set(e,{key:n,path:i}),i}var qC=new WeakMap;var oh=Object.freeze([]);var Bu=e=>Array.isArray(e?.dependsOn)?e.dependsOn:oh;function ih(e,t){let n=e.dependsOn;return n===void 0?oh:n==="children"?t(e.id):n}function QC(){let e=new Map,t=new Map;function n(r){let o=t.get(r);if(o!==void 0){for(let i of o){let s=e.get(i);s!==void 0&&(s.delete(r),s.size===0&&e.delete(i))}t.delete(r)}}return{add(r,o){if(n(r),o.length!==0){t.set(r,[...o]);for(let i of o){let s=e.get(i);s===void 0&&(s=new Set,e.set(i,s)),s.add(r)}}},remove(r){n(r)},clear(){e.clear(),t.clear()},isEmpty(){return e.size===0},dependentsOf(r){let o=e.get(r);return o===void 0?oh:[...o]},transitiveDependentsOf(r){let o=e.get(r);if(o===void 0)return oh;let i=new Set,s=[...o];for(;s.length>0;){let a=s.pop();if(!i.has(a)){i.add(a);for(let l of e.get(a)??[])s.push(l)}}return i}}}function ZC(e,t){if(e===t)return!0;if(e===void 0||t===void 0||e==="children"||t==="children"||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function e2(){return new WeakMap}var oa=new WeakMap,Ir=0;function rt(e,t,n,r,o){if(typeof t!="string")return Pj(e,t,n,r,o);let i=oa.get(e);i===void 0?(i={generation:Ir,slots:new Map,drops:0},oa.set(e,i)):i.generation!==Ir&&(i.generation=Ir,i.slots.clear());let s=e.data,a=i.slots.get(t);if(a!==void 0&&a.pose===n&&a.data===s&&a.also===o)return a.value;let l=r();return a!==void 0?(a.pose=n,a.data=s,a.also=o,a.value=l):i.slots.set(t,{pose:n,data:s,also:o,value:l}),l}function Pj(e,t,n,r,o){let i=t,s=e.data,a=oa.get(e)?.drops??0,l=i.get(e);if(l!==void 0&&l.generation===Ir&&l.pose===n&&l.data===s&&l.also===o&&(n===void 0||l.drops===a))return l.value;let u=r(),c=oa.get(e)?.drops??0;return l!==void 0?(l.pose=n,l.data=s,l.also=o,l.value=u,l.generation=Ir,l.drops=c):i.set(e,{pose:n,data:s,also:o,value:u,generation:Ir,drops:c}),u}function Hu(){Ir++}function t2(){return Ir}function ln(e){let t=oa.get(e);if(t===void 0){oa.set(e,{generation:Ir,slots:new Map,drops:1});return}t.drops++;for(let[n,r]of t.slots)r.pose!==void 0&&t.slots.delete(n)}var Tj="kit:derivedPath",Lw=new Set,_w=0;function Er(e,t,n,r=Tj){let o=e.derivePath;if(o===void 0)return null;let i=ih(e,n);if(i.length===0)return null;if(Lw.has(e.id))return _w++,null;Lw.add(e.id);let s=_w;try{let a=!1,l=rt(e,r,e.pose,()=>(a=!0,n2(e,o,i.map(t),{..._u(),path:null})));return!a&&!eh(l,i,t)&&n2(e,o,i.map(t),l),_w!==s&&ln(e),l.path}finally{Lw.delete(e.id)}}function n2(e,t,n,r){return r.path=Zp(r,n,o=>t(e,o)),r}Pe();function Gu(e){let t=e.data;return t?.fill===nn||t?.stroke===nn}var r2=new WeakMap;function ia(e,t){let n=e.data,r=n?.fill===nn,o=n?.stroke===nn,i=null,s=null;for(let u of t){if(!r&&!o)break;let c=u.data;r&&c?.fill!==nn&&(i=Ne(c?.fill),r=!1),o&&c?.stroke!==nn&&(s=Re(c?.stroke),o=!1)}let a=r2.get(e);if(a!==void 0&&a.fill===i&&a.stroke===s)return a;let l={fill:i,stroke:s};return r2.set(e,l),l}function sa(e,t){if(Gu(t))return ia(t,o2(n=>e.get(n),t))}function*o2(e,t){let n=new Set,r=t.parent??null;for(;r!==null&&!n.has(r);){n.add(r);let o=e(r);if(o===void 0)return;yield o,r=o.parent??null}}var Uu=()=>{throw new Error("documentOf: the document reading holds no overrides; write them to the scene")},Sj=Object.freeze({set:Uu,get:()=>{},read:e=>{},has:()=>!1,ids:()=>[],clear:Uu,clearAll:Uu,commit:Uu,subscribe:()=>()=>{},getGeneration:()=>0,hold:()=>Uu()});function sh(e){return e.overrides===Sj}var s2=Symbol("weasel.shownData"),Dw=new WeakMap;function Pt(e,t){if(s2 in t)return t;let n=e.read(t.id)?.data;if(n===void 0)return t;let r=Dw.get(t);if(r!==void 0&&r.data===n&&r.stored===t.data)return r.shown;let o=kj(t,n(t.data));return Dw.set(t,{stored:t.data,data:n,shown:o}),o}function kj(e,t){return{...e,data:t,[s2]:!0}}function a2(e){return Dw.get(e)?.shown}function aa(e){return{get:t=>{let n=e.get(t);return n===void 0?void 0:Pt(e.overrides,n)}}}var i2=new WeakMap;function ah(e,t){let n=e.getGeneration(),r=i2.get(e);return(r===void 0||r.at!==n)&&(r={at:n,any:e.ids().some(o=>e.read(o)?.data!==void 0)},i2.set(e,r)),r.any?t.map(o=>Pt(e,o)):t}var vj={effective:"kit:derivedPose",document:"kit:derivedPose:document"},Aj={effective:void 0,document:"kit:derivedPath:document"},Bw=new Set,Hw=0;function u2(e){return sh(e)?"document":"effective"}function c2(e,t,n){let r=d2(e,t,n),o=r.derivePose;if(o===void 0)return null;let i=ih(r,e.childrenOf);if(i.length===0)return null;if(Bw.has(r.id))return Hw++,null;Bw.add(r.id);let s=Hw;try{let a=Vw(e,r,n),l=!1,u=rt(r,vj[n],r.pose,()=>(l=!0,l2(r,o,i.map(a),{..._u(),value:null})));return!l&&!eh(u,i,a)&&l2(r,o,i.map(a),u),Hw!==s&&ln(r),u.value}finally{Bw.delete(r.id)}}function l2(e,t,n,r){return r.value=Zp(r,n,o=>t(e,o)),r}function Uw(e,t,n){let r=u2(e);return n===void 0?Ww(e,t,r):Vw(e,n,r)(t)}function Vw(e,t,n){let r=i=>Ww(e,i,n);if(t.dependsOn==="children")return r;let o=XC(e.composition,t,i=>e.get(i),i=>zw(e,e.get(i),n),i=>{let s=e.get(i);return s===void 0||lt(s)});return o===null?r:i=>{let s=r(i);if(s===void 0)return;let a=o(i,s.pose);return a===s.pose?s:new lh(s,a)}}var lh=class{constructor(t,n){this.dep=t;this.pose=n;this.node=t.node}dep;pose;node;get path(){let t=this.dep.path;return t===null?null:JC(t,this.dep.pose,this.pose)}get inherited(){return this.dep.inherited}};function Ww(e,t,n){let r=e.get(t);if(r!==void 0)return new Gw(e,r,n)}var Gw=class{constructor(t,n,r){this.source=t;this.reading=r;let o=d2(t,n,r);this.posed=o,this.node=o;let i=r==="effective"?t.overrides.read(o.id):void 0;this.shown=i?.path,this.pose=i?.pose??c2(t,o,r)??o.pose}source;reading;node;pose;shown;posed;get path(){if(this.shown!==void 0)return rh(this.shown,this.pose,this.pose);let{source:t,reading:n}=this;return Er(this.posed,Vw(t,this.posed,n),r=>t.childrenOf(r),Aj[n])}get inherited(){let{source:t,reading:n}=this;return sa(n==="effective"?aa(t):t,this.posed)}get children(){let{source:t,reading:n}=this,r=t.composition,o=r&&It(r)&&lt(this.posed)?r.compose:null;return t.childrenOf(this.posed.id).map(i=>{let s=Ww(t,i,n);return s===void 0||o===null?s:new lh(s,o(this.pose,s.pose))})}};function d2(e,t,n){return n==="effective"?Pt(e.overrides,t):t}function zw(e,t,n){if(n==="effective"){let r=e.overrides.read(t.id)?.pose;if(r!==void 0)return r}return c2(e,t,n)??t.pose}function Mr(e,t){return zw(e,t,"document")}function Yn(e,t){return zw(e,t,u2(e))}function lt(e){return!Rj(e)}function Rj(e){return e.dependsOn==="children"&&e.derivePose!==void 0}ee();ee();function Kw(e){let t=Ce(e);if(!t)return{x:e.x,y:e.y,width:e.width,height:e.height};let n=1/0,r=1/0,o=-1/0,i=-1/0,s=[[e.x,e.y],[e.x+e.width,e.y],[e.x+e.width,e.y+e.height],[e.x,e.y+e.height]];for(let[a,l]of s){let[u,c]=xn(t,a,l);u<n&&(n=u),u>o&&(o=u),c<r&&(r=c),c>i&&(i=c)}return{x:n,y:r,width:o-n,height:i-r}}function f2(e){let t=1/0,n=1/0,r=-1/0,o=-1/0,i=!1;for(let s of e){if(!s)continue;let a=Kw(s);i=!0,a.x<t&&(t=a.x),a.y<n&&(n=a.y);let l=a.x+a.width,u=a.y+a.height;l>r&&(r=l),u>o&&(o=u)}return i?{x:t,y:n,width:r-t,height:o-n}:null}ee();function Cr(e,t){return e.forNode?.(t)??e}var Et={getBounds:e=>e,remapBounds:(e,t,n)=>{let r=t.width===0?1:n.width/t.width,o=t.height===0?1:n.height/t.height;return{...e,x:n.x+(e.x-t.x)*r,y:n.y+(e.y-t.y)*o,width:e.width*r,height:e.height*o}},fromBounds:e=>({x:e.x,y:e.y,width:e.width,height:e.height}),translate:(e,t,n)=>({...e,x:e.x+t,y:e.y+n}),lerp:(e,t,n)=>({...e,x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,width:e.width+(t.width-e.width)*n,height:e.height+(t.height-e.height)*n}),axes:e=>[e.x,e.y,e.width,e.height].every(n=>typeof n=="number")?{count:5,names:["x","y","width","height","rotation"],angles:[4],to:n=>[n.x,n.y,n.width,n.height,n.rotation??0],from:n=>{let r={...e,x:n[0],y:n[1],width:n[2],height:n[3]};return(e.rotation!==void 0||n[4]!==0)&&(r.rotation=n[4]),r},add:(n,r)=>{let o={...n,x:n.x+r[0],y:n.y+r[1],width:n.width+r[2],height:n.height+r[3]},i=(n.rotation??0)+r[4];return(n.rotation!==void 0||i!==0)&&(o.rotation=i),o},write:(n,r,o)=>{r[o]=n.x,r[o+1]=n.y,r[o+2]=n.width,r[o+3]=n.height,r[o+4]=n.rotation??0}}:null,getRotation:e=>e.rotation??0,withRotation:(e,t)=>({...e,rotation:t})},Nj={getBounds:Et.getBounds,remapBounds:Et.remapBounds,translate:Et.translate,lerp:Et.lerp,axes:Et.axes,fromBounds:e=>({x:e.x,y:e.y,width:e.width,height:e.height,rotation:0}),getRotation:e=>e.rotation,withRotation:(e,t)=>({...e,rotation:t})};function Ei(e,t){return Kw(jw(e,t))}function jw(e,t){let n=t.getBounds(e),r=t.getRotation?.(e)??n.rotation??0,o=Un(e)??Un(n);return!r&&!o?n:{...n,...r?{rotation:r}:{},...o?{transform:o}:{}}}function $w(e,t,n,r,o){if(r.translate)return o?r.translate(e,t,n,o):r.translate(e,t,n);let i=r.getBounds(e),s={x:i.x+t,y:i.y+n,width:i.width,height:i.height};return r.remapBounds(e,i,s)}function h2(){let e=new Map,t=Me(),n=0,r=()=>{n++,t.emit()};return{get:o=>e.get(o),set(o,i){let s=e.get(o);if(i===null||i.x===0&&i.y===0&&!i.z){if(s===void 0)return;e.delete(o)}else{if(s!==void 0&&s.x===i.x&&s.y===i.y&&(s.z??0)===(i.z??0))return;e.set(o,{...i})}r()},ids:()=>e.keys(),clearAll(){e.size!==0&&(e.clear(),r())},subscribe:t.subscribe,getGeneration:()=>n}}var p2=new WeakMap;function Ij(e,t,n){if(typeof t!="object"||t===null)return e(t,n);let r=p2.get(e);r===void 0&&p2.set(e,r=new WeakMap);let o=r.get(t);if(o!==void 0&&o.offset===n)return o.out;let i=e(t,n);return r.set(t,{offset:n,out:i}),i}function Yw(e){let t=e.scroll,n=e.composition?.scroll;if(!(t===void 0||n===void 0)&&!(e.overrides!==void 0&&sh(e)))return(r,o)=>{let i=t.get(r);return i===void 0?o:Ij(n,o,i)}}function uh(e,t){let n=Yw(e);return n===void 0?t:{...t,childFrame:n}}function m2(e,t,n,r=()=>!1){let{poses:o,composition:i}=e,s=new Set([t]),a=new Map,l=u=>{for(let c of e.childrenOf(u)){if(r(c))continue;s.add(c);let d=o.getParent(c),f=$n(o,d);if(f===null||!s.has(f)){let p=n(Vt(o,c,i.compose),c);p!==null&&a.set(c,ta(o,p,d,i.compose,i.decompose))}l(c)}};return l(t),a}function y2(e,t,n="animator: `axes`"){let{count:r,names:o}=e,i=[];for(let s of t){if(typeof s=="number"){if(!Number.isInteger(s)||s<0||s>=r)throw new Error(`${n} names axis ${s} of a target with ${r}`);i.push(s);continue}if(!o)throw new Error(`${n} names "${s}" on a target whose axes have no names`);let a=i.length,l=`${s}.`;for(let u=0;u<o.length;u++)(o[u]===s||o[u].startsWith(l))&&i.push(u);if(i.length===a){let u=o.slice(0,8).map(c=>`"${c}"`).join(", ");throw new Error(`${n} names "${s}", and the target's axes are ${u}${o.length>8?", \u2026":""}`)}}return i}function Ej(e){let[t,n,r,o]=e;switch(e.length){case 1:return{add:(i,s)=>({[t]:i[t]+s[0]}),write:(i,s,a)=>{s[a]=i[t]}};case 2:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n]}};case 3:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1],[r]:i[r]+s[2]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n],s[a+2]=i[r]}};case 4:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1],[r]:i[r]+s[2],[o]:i[o]+s[3]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n],s[a+2]=i[r],s[a+3]=i[o]}};default:return null}}function Vu(e){if(typeof e=="number")return{count:1,shape:"number",to:n=>[n],from:(n,r=0)=>n[r],add:(n,r)=>n+r[0],write:(n,r,o)=>{r[o]=n}};if(Array.isArray(e))return e.every(n=>typeof n=="number")?{count:e.length,shape:`array:${e.length}`,to:n=>n.slice(),from:(n,r=0)=>{let o=new Array(e.length);for(let i=0;i<o.length;i++)o[i]=n[r+i];return o},add:(n,r)=>{let o=new Array(e.length);for(let i=0;i<o.length;i++)o[i]=n[i]+r[i];return o},write:(n,r,o)=>{for(let i=0;i<e.length;i++)r[o+i]=n[i]}}:null;if(!Jt(e))return null;let t=Object.keys(e).sort();return t.length===0||!t.every(n=>typeof e[n]=="number")?null:{count:t.length,shape:`object:${JSON.stringify(t)}`,names:t,to:n=>t.map(r=>n[r]),from:(n,r=0)=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[r+i];return o},...Ej(t)??{add:(n,r)=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[t[i]]+r[i];return o},write:(n,r,o)=>{for(let i=0;i<t.length;i++)r[o+i]=n[t[i]]}}}}var Mj=new WeakMap,qw=new Float64Array(16),g2=(e,t,n)=>1-e*(1-(1-t)*n);function Cj(e,t,n,r,o){let i=e.axes.count,{behind:s}=e;for(let a=0;a<s.length;a++){let l=s[a],{slot:u,adjust:c,kept:d,share:f}=l;if(u)for(let p=0;p<i;p++){let h=u.cols[u.at+p]+(c?c[p]:0);t[n+p]=t[n+p]+(r||d?h*g2(f[p],r?r[o+p]:0,d?d[p]:1):h)}else if(r||d){let p=l.own();for(let h=0;h<i;h++)t[n+h]=t[n+h]-p[h]*(1-g2(f[h],r?r[o+h]:0,d?d[h]:1))}}}function Xw(e,t,n){let r=e.axes.count,{slot:o,adjust:i,beside:s}=e;for(let l=0;l<r;l++)t[n+l]=t[n+l]+(o?o.cols[o.at+l]:0)+i[l]+(s?s[l]:0);let a=e.holds;e.behind.length>0&&(e.row||a||e.dimmed)&&Cj(e,t,n,a?a.store.cover:null,a?a.row*r:0)}function b2(e,t){let n=e.axes.to(t),r=e.holds;if(!r)return n;let o=r.row*n.length,{store:i}=r;for(let s=0;s<n.length;s++)if(n[s]!==i.at[o+s]){i.refold(r.row);break}for(let s=0;s<n.length;s++)n[s]=n[s]+i.delta[o+s];return n}function Oj(e){let t=e.get();if(e.live===0)return t;let{axes:n}=e;if(!n.add||e.holds||e.dimmed){let i=b2(e,t);return Xw(e,i,0),n.from(i)}let r=n.count;qw.length<r&&(qw=new Float64Array(r));let o=qw;return o.fill(0,0,r),Xw(e,o,0),n.add(t,o)}function Fj(e,t,n){let r=e.get(),{axes:o}=e,i=e.live>0;if(o.write&&!(i&&e.holds))o.write(r,t,n);else{let s=i?b2(e,r):o.to(r);for(let a=0;a<s.length;a++)t[n+a]=s[a]}i&&Xw(e,t,n)}function Jw(e){let t=e.axes??Vu(e.get());if(!t)throw new Error("createTarget: `axes` is required for a value that is not a number, an array of numbers, or an object of numeric fields");let n={get:e.get,set:e.set,show:e.show,publish:e.publish,axes:t,write:null,owner:null,discard:!1,held:0,holds:null,behind:[],dimmed:!1,beside:null,parts:new Set,row:null,live:0,slot:null,adjust:new Array(t.count).fill(0),stale:!1},r={read:()=>Oj(n),readInto:(o,i=0)=>Fj(n,o,i),axisCount:t.count,axes:t,axisIndexes:o=>y2(t,o),committed:e.get,commit:e.set,get active(){return n.live>0},stop(o){let i=n.owner;if(i){n.discard=o?.commit===!1;try{i.stop(n)}finally{n.discard=!1}}}};return Mj.set(r,n),r}var ch="0.16.1";function dh(e){let t=Symbol.for(`@msb235/blits/${e}`),n=globalThis,r=n[t];return r===void 0&&(r=new WeakMap,n[t]=r),r}var w2={on:Number.MIN_VALUE,off:0},Mt=(e,t,n)=>e+(t-e)*n,Lj=Mt,_j=dh("lerp-into@1");function fh(e){return _j.get(e)}var Dj=(e,t)=>e+t,x2=(e,t)=>e*t,P2=(e,t)=>e*t,T2=(e,t)=>1+(e-1)*t,Bj=(e,t)=>e>t?e:t,S2=dh("numeric@1");function qn(e){return S2.get(e)}var Hj=dh("width@1");function k2(e){let t=e.rest;return Array.isArray(t)?t.length:Hj.get(e)??1}function Oe(e,t,n,r){return e==="sum"?Dj(t,x2(n,r)):e==="mul"?P2(t,T2(n,r)):e==="max"?Bj(t,x2(n,r)):+n}function v2(e){let t=qn(e);if(!(t===void 0||t.axes!==1||t.turn!==void 0||e.fold!==void 0)&&typeof e.rest=="number")return t.op==="sum"||t.op==="mul"||t.op==="max"?t.op:void 0}var Gj=(e,t)=>t===void 0?e:`${e}[${t[0]}, ${t[1]}]`;function Qw(e){let t={kind:Gj("mul",e?.bounds),bounds:e?.bounds,rest:1,merge:P2,scale:T2,lerp:Lj};return S2.set(t,{op:"mul",axes:1}),t}function ph(e){return{kind:e?.lerp?void 0:"last",merge:(t,n)=>n,lerp:e?.lerp??((t,n,r)=>r<.5?t:n)}}function Xn(e,t){if(e===0)return[];let n=[.5];for(let r=1;r<e;r++)n.push(.5);for(let r=0;r<e;r++)n[r]=t;return n}function A2(e){let t=e??!1;return t===!0?Number.POSITIVE_INFINITY:t===!1?1:t}var R2=(e,t,n)=>Number.isFinite(n)&&e>=t*n;function Or(e,t,n){return t>0?R2(e,t,n)?1:e%t/t:0}function Jn(e,t,n){return t>0?R2(e,t,n)?n-1:Math.floor(e/t):0}function hh(e,t,n,r,o,i,s=Number.POSITIVE_INFINITY){let a=t&&!t.rest&&t.at<r?t.at:r;s<a&&(a=s);let l=a-o;if(i!==null)for(let c=0;c<i.length;c+=2){let d=Math.max(i[c],o),f=Math.min(i[c+1],a);f>d&&(l-=f-d)}let u=l/e;return u>=1?1:n?n(Math.max(0,u)):Math.max(0,u)}function la(e,t,n,r,o,i,s=null,a=null){let l=1;if(e>0&&!r&&(l*=hh(e,t,n,o,i,a)),s&&!r){let u=s.from+(o-s.at)/s.over;u<1&&(l*=n?n(Math.max(0,u)):Math.max(0,u))}if(t&&!t.rest){if(r||t.over===0)return 0;let u=1-(o-t.at)/t.over,c=u<0?0:u>1?1:u;l*=n?n(c):c}return l}function mh(e,t,n,r){return e>=0?n&&e>r?r:e:t?0:Number.NaN}function Wt(e,t){return e===t?e!==0||1/e===1/t:Number.isNaN(e)&&Number.isNaN(t)}function Fr(e){return e<0?0:e>1?1:e}function zt(e,t,n){return Fr(e*(t*n))}function yh(e,t){return!(t>0)&&e.out?.rest!==!0}function ze(e,t){let n=t-e.anchorNow,r=e.ramp;if(r===null)return e.anchorElapsed+n*e.rate;if(n<=0)return e.anchorElapsed+n*r.from;let o=r.to-r.from;return n<=r.over?e.anchorElapsed+r.from*n+o*n*n/(2*r.over):e.anchorElapsed+r.from*r.over+o*r.over/2+r.to*(n-r.over)}function En(e,t){let n=e.anchorElapsed,r=e.ramp;if(r===null)return e.rate>0?e.anchorNow+(t-n)/e.rate:t<=n?e.anchorNow:Number.POSITIVE_INFINITY;if(t<=n)return r.from>0?e.anchorNow+(t-n)/r.from:e.anchorNow;let o=(r.to-r.from)/(2*r.over),i=n+r.from*r.over+o*r.over*r.over,s=r.from>0&&r.to<0?n-r.from*r.from/(4*o):i;if(t<=s){let a=n-t,l=Math.abs(o)<1e-12?-a/r.from:(-r.from+Math.sqrt(Math.max(0,r.from*r.from-4*o*a)))/(2*o);return e.anchorNow+l}return r.to<=0?Number.POSITIVE_INFINITY:e.anchorNow+r.over+(t-i)/r.to}function Wu(e,t){let n=e.ramp;return En({anchorNow:e.anchorNow,anchorElapsed:-e.anchorElapsed,rate:-e.rate,ramp:n===null?null:{from:-n.from,to:-n.to,over:n.over}},-t)}function N2(e,t){if(!(t>0))return 0;let n=e%t;return(n<0?n+t:n)/t}function ua(e,t){let n=e.ramp;if(n===null)return e.rate;let r=(t-e.anchorNow)/n.over;return r>=1?n.to:r<=0?n.from:n.from+(n.to-n.from)*r}function Zw(e,t){let n=ua(e,t);e.anchorElapsed=ze(e,t);let r=e.ramp;if(r!==null){let o=e.anchorNow+r.over-t;e.ramp=o>0?{from:n,to:r.to,over:o}:null}e.anchorNow=t}function ca(e,t,n,r){Zw(e,t);let o=ua(e,t);e.ramp=r>0&&n!==o?{from:o,to:n,over:r}:null,e.rate=n}function vo(e,t){let n=t.spec.stepMs??e.opts.stepMs;return n!==void 0&&n>0&&!e.reducedNow?n:void 0}var Uj=!1,da={u:Number.NaN,ease:void 0,left:0};function Lr(e,t,n){return Math.max(0,e-t)/n}function Ao(e,t){return(t!==da.u||e!==da.ease)&&(da.u=t,da.ease=e,da.left=t>=1?0:1-e(t)),da.left}function Ro(e,t,n){return n===0?t:t+(e-t)*n}function I2(e,t,n,r,o,i,s,a,l,u){let c=Ao(e,n),d=0;if(Uj&&n<1){let f=Math.max(0,n-1e-4),p=Math.min(1,n+1e-4);d=(e(p)-e(f))/(p-f)*(1e3/r)}for(let f=0;f<t;f++){let p=o[i+f],h=s[a+f];l[f]=Ro(p,h,c),u[f]=-(p-h)*d}return c===0}var E2=0,M2=1,C2=2;var Vj=4,Wj=5,ot={y:0,dy:0},Tt={e:0,e2:0,cos:0,sin:0},zj={form:Number.NaN,k1:Number.NaN,k2:Number.NaN,k3:Number.NaN,t:Number.NaN};function Kj(e,t){let n=e[0],r=e[2],o=e[3],i=e[4],s=zj;if(!(Wt(t,s.t)&&n===s.form&&r===s.k1&&o===s.k2&&i===s.k3))switch(s.form=n,s.k1=r,s.k2=o,s.k3=i,s.t=t,n){case E2:{let a=e[2],l=e[3],u=e[4];Tt.e=Math.exp(-a*l*t),Tt.cos=Math.cos(u*t),Tt.sin=Math.sin(u*t);return}case M2:{let a=e[3];Tt.e=Math.exp(-a*t);return}case C2:{Tt.e=Math.exp(e[2]*t),Tt.e2=Math.exp(e[3]*t);return}default:Tt.e=Math.exp(-t/e[2])}}function jj(e,t,n,r){let o=e[0];o===E2?$j(e,t,n):o===M2?Yj(e,t,n,r):o===C2?qj(e,t,n):O2(e,t)}function $j(e,t,n){let r=e[2],o=e[3],i=e[4],s=Tt.e,a=(n+r*o*t)/i,l=Tt.cos,u=Tt.sin,c=s*(t*l+a*u);ot.y=c,ot.dy=-r*o*c+s*i*(a*l-t*u)}function Yj(e,t,n,r){let o=e[3],i=Tt.e,s=n+o*t,a=i*(t+s*r);ot.y=a,ot.dy=i*s-o*a}function qj(e,t,n){let r=e[2],o=e[3],i=(n-o*t)/(r-o),s=t-i,a=Tt.e,l=Tt.e2;ot.y=i*a+s*l,ot.dy=i*r*a+s*o*l}function O2(e,t){let n=e[2],r=Tt.e;ot.y=t*r,ot.dy=-t/n*r}function Xj(e,t,n,r,o){let i=e[2],s=t-n,a=t+r*i-n;if(a===0){O2(e,s);return}let l=e[3];if(s*a>0){let h=Math.exp(-l*o),m=r+l*s,g=h*(s+m*o);ot.y=g,ot.dy=h*m-l*g;return}let u=1+s/(r*i),c=u>0?-i*Math.log(u):Number.POSITIVE_INFINITY;if(o<c){let h=Tt.e;ot.y=s+r*i*(1-h),ot.dy=r*h;return}let d=o-c,f=r*u,p=Math.exp(-l*d);ot.y=p*f*d,ot.dy=p*f*(1-l*d)}function F2(e,t,n,r,o,i,s,a,l,u,c,d,f,p){if(e[0]===Vj)return I2(t,n,Lr(d,r,o),o,i,s,u,c,f,p);let h=Math.max(0,d-r)/1e3,m=e[1],g=m>0;Kj(e,h);for(let b=0;b<n;b++){let x=u[c+b];e[0]===Wj?Xj(e,i[s+b],x,a[l+b],h):jj(e,i[s+b]-x,a[l+b],h),f[b]=x+ot.y,p[b]=ot.dy,(Math.abs(ot.y)>m||Math.abs(ot.dy)>m)&&(g=!1)}if(g)for(let b=0;b<n;b++)f[b]=u[c+b],p[b]=0;return g}var L2=1e-4,_r=[0,0];function eP(e,t,n,r){let o=t<L2?n:e,s=(r<L2?e:n)-o;s>Math.PI?s-=2*Math.PI:s<-Math.PI&&(s+=2*Math.PI),_r[0]=o,_r[1]=s}function _2(e,t,n,r,o){let i=e[t+3]??0,s=n[r+3]??0,a=s>0?1/s:0,l=(n[r]??0)*a,u=(n[r+1]??0)*a,c=(n[r+2]??0)*a,d=i>0?1/i:0,f=i>0?(e[t]??0)*d:l,p=i>0?(e[t+1]??0)*d:u,h=i>0?(e[t+2]??0)*d:c,m=s>0?l:f,g=s>0?u:p,b=s>0?c:h,x=Math.sqrt(p*p+h*h),w=Math.sqrt(g*g+b*b);eP(Math.atan2(h,p),x,Math.atan2(b,g),w),o[0]=f,o[1]=x,o[2]=_r[0],o[3]=i,o[4]=m,o[5]=w,o[6]=_r[0]+_r[1],o[7]=s}var ume=new Float64Array(8),cme=new Float64Array(4),dme=new Float64Array(4),fme=new Float64Array(4),pme=new Float64Array(4);function zu(){try{return!0}catch{return!1}}var D2=new WeakSet;function Qn(e,t){D2.has(e)||zu()||(D2.add(e),console.warn(`blits: ${t}`))}var fa=Mt,Zj=Array.from({length:256},(e,t)=>{let n=t/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),e$=Zj.map((e,t)=>{let n=(t-.5)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),B2=4096,wme=Array.from({length:B2+1},(e,t)=>{let n=0;for(;n<255&&t/B2>=e$[n+1];)n++;return n});var gh=256,Pme=new Int32Array(gh).fill(-1),Tme=new Float64Array(gh),Sme=new Float64Array(gh),kme=new Float64Array(gh);var U2=new Float64Array(8);function t$(e,t,n){let r=U2;_2(e,0,t,0,r);let o=fa(r[3],r[7],n),i=fa(r[1],r[5],n),s=r[2]+_r[1]*n;return[fa(r[0],r[4],n)*o,i*Math.cos(s)*o,i*Math.sin(s)*o,o]}var n$=1e-9;function H2(e,t,n){let r=e.length>4,o=(r?e[4]:e[3])??0,i=o>0?1/o:0,s=(e[1]??0)*i,a=(e[2]??0)*i,l=Math.sqrt(s*s+a*a);t[n]=(e[0]??0)*i,t[n+1]=r?l<n$?0:(e[3]??0)*i:l,t[n+2]=Math.atan2(a,s),t[n+3]=o}function G2(e,t,n){let r=e[1]??0,o=e[2]??0,i=e.length>4;return n[0]=(e[0]??0)*t,n[1]=r*t,n[2]=o*t,n[3]=(i?e[3]??0:Math.sqrt(r*r+o*o))*t,n[4]=((i?e[4]:e[3])??0)*t,n}function r$(e,t,n){if(n===0)return G2(e,1,Xn(5,0));if(n===1)return G2(t,1,Xn(5,0));let r=U2;H2(e,r,0),H2(t,r,4);let o=r[3]>0?0:4,i=r[7]>0?4:0,s=r[o+1],a=r[i+1];eP(r[o+2],s,r[i+2],a);let l=fa(r[3],r[7],n),u=fa(s,a,n)*l,c=_r[0]+_r[1]*n;return[fa(r[o],r[i],n)*l,Math.cos(c)*u,Math.sin(c)*u,u,l]}function tP(e){let t=e.lerp;return t===t$||t===r$}var vme=Xn(5,0);var rP=e=>e;function W2(e){return e===void 0||e===rP}function Ku(e,t,n,r){let o=3*e,i=3*(n-e)-o,s=1-o-i,a=3*t,l=3*(r-t)-a,u=1-a-l,c=p=>((s*p+i)*p+o)*p,d=p=>(3*s*p+2*i)*p+o,f=p=>((u*p+l)*p+a)*p;return p=>{if(p<=0)return 0;if(p>=1)return 1;let h=p;for(let b=0;b<8;b++){let x=c(h)-p;if(Math.abs(x)<1e-7)return f(h);let w=d(h);if(Math.abs(w)<1e-6)break;h-=x/w}let m=0,g=1;for(h=p;g-m>1e-7;)c(h)<p?m=h:g=h,h=(m+g)/2;return f(h)}}var o$={linear:rP,ease:Ku(.25,.1,.25,1),"ease-in":Ku(.42,0,1,1),"ease-out":Ku(0,0,.58,1),"ease-in-out":Ku(.42,0,.58,1)},V2=new WeakMap,nP=new WeakMap([[rP,1]]);function i$(e,t,n,r){return e>0?t/e:t>0?Number.POSITIVE_INFINITY:n>0?r/n:r>0?Number.POSITIVE_INFINITY:1}function z2(e){let t=nP.get(e);if(t!==void 0)return t;let n=1e-6,r=e(n);return r>.001?Number.POSITIVE_INFINITY:r/n}function No(e){if(typeof e=="function")return e;if(typeof e=="string"){let r=o$[e];if(!r)throw new Error(`blits: no easing named ${e}`);return r}let t=V2.get(e);if(t)return t;let n;if("bezier"in e)n=Ku(...e.bezier),nP.set(n,i$(...e.bezier));else{let r=e.steps,o=e.jump==="start";n=i=>{let s=i<=0?0:i>=1?1:i;return(o?Math.min(r,Math.floor(s*r)+1):Math.floor(s*r))/r},nP.set(n,o?Number.POSITIVE_INFINITY:0)}return V2.set(e,n),n}function K2(e,t){return e==="queue"?1:e==="together"?0:t}function s$(e,t){return{rate:t.map(()=>1),skip:t.map(()=>!1),share:K2(e.order,e.share),allow:0}}function iP(e,t,n){let r=K2(e.order,e.share),o=[],i=0,s=0,a=0;return t.forEach((l,u)=>{let c=n.skip[u]?0:l.natural/n.rate[u],d=l.state==="playing"?0:Math.max(u===0?Number.NEGATIVE_INFINITY:s+(l.overlap?Math.min(n.share,r):r)*a,l.floor??0);o.push(d),i=Math.max(i,d+c),s=d,a=c}),{at:o,length:i}}var Zn=(e,t,n)=>iP(e,t,n).length<=e.left+n.allow+1e-9;function oP(e,t,n){if(n(e))return e;if(!n(t))return t;if(t===Number.POSITIVE_INFINITY)for(t=Math.max(e,1)*2;!n(t);)e=t,t*=2;for(let r=0;r<60;r++){let o=(e+t)/2;n(o)?t=o:e=o}return t}function a$(e,t,n){if(!Zn(e,t,n)){let s=Math.max(1,...t.map(l=>l.faster)),a=l=>({...n,rate:t.map((u,c)=>Math.max(n.rate[c],Math.min(l,u.faster)))});return a(oP(1,s,l=>Zn(e,t,a(l))))}if(!Number.isFinite(e.left))return n;let r=Math.max(1,...t.map(s=>s.slower));if(r===1)return n;let o=s=>({...n,rate:t.map((a,l)=>n.rate[l]/Math.min(s,a.slower))}),i=oP(1,r,s=>!Zn(e,t,o(s)));return Zn(e,t,o(i))?o(i):o(Math.max(1,i-1e-9))}function l$(){return(e,t,n)=>{if(Zn(e,t,n)||!t.some(i=>i.overlap))return n;let r=i=>({...n,share:i}),o=oP(0,n.share,i=>Zn(e,t,r(n.share-i)));return r(n.share-o)}}function u$(){return(e,t,n)=>{let r=n;for(let o=t.length-1;o>=0&&!Zn(e,t,r);o--){if(!t[o].ballast||r.skip[o])continue;let i=r.skip.slice();i[o]=!0,r={...r,skip:i}}return r}}function c$(...e){return(t,n,r)=>{let o=r;for(let i of e){if(Zn(t,n,o))break;o=i(t,n,o)}return o}}var j2=c$(l$(),u$()),bh={weak:0,strong:1,required:2};function $2(e,t,n,r){let o=n(e,t,a$(e,t,s$(e,t)));return Zn(e,t,o)||bh[e.priority]===0||r==="overrun"?{plan:o,fell:!Zn(e,t,o)&&bh[e.priority]>0}:(o={...o,skip:t.map((i,s)=>o.skip[s]||bh[i.priority]<bh[e.priority])},{plan:o,fell:!0})}var Io=e=>!Number.isNaN(e.restedAt);function Mn(e,t,n){return{reaches:t,delay:0,since:0,shown:0,weight:0,restedAt:Number.NaN,bands:null,state:n,stepped:-0,ticks:0,probed:Number.NaN,delta:null,phase:0,seeks:0,rebuilt:0,copied:!1,base:void 0,slope:void 0,kept:null,unkept:void 0,snaps:void 0,from:void 0,unknown:void 0,inputs:void 0,replay:void 0,voice:e,next:null,version:Number.NaN,roles:null,slot:-1,run:-1,freed:-1,restored:null}}function d$(){return Mn(null,!1,void 0)}function Y2(e){let t=this.chains.get(e);return t!==void 0&&t.version===this.version?t:this.relink(e,t)}function q2(e,t){let n=this.lanes,r=t!==void 0?t.slot:n!==null?n.number(e):-1;t===void 0&&r>=0&&this.places?.number(e,r);let o=t!==void 0&&r>=0&&n?.renew(r)===!0,i=t===void 0||o?void 0:this.steps.patch(t.voice===null?null:t,t.version,this,e,r);i===void 0&&(i=f$(this,e,r,t??null));let s=i??d$();return s.version=this.version,t!==void 0&&t!==s&&(o||(s.roles=t.roles),t.roles=null,t.slot=-1),s.slot=r,t!==s&&this.chains.set(e,s),s}function ut(e,t){let n=e.chains.get(t);return n!==void 0&&n.slot>=0&&e.lanes?.sought(n.slot)===!0?void 0:n}function f$(e,t,n,r){let o=null,i=r,s=null,a=e.naming===0?void 0:e.named.get(t),l=0,u=e.general;for(let c=0;c<=u.length;c++){let d=c<u.length?u[c]:null;for(;;){let f=a!==void 0&&l<a.length?a[l]:null,p=f!==null&&(d===null||f.id<d.id)?f:d;if(p===null)break;p===f&&l++;let h=i!==null&&i.voice===p?i:null;h!==null&&(i=h.next);let m=e.linkable(p,t,n,h);if(m!==null&&(m.voice=p,m.next=null,s===null?o=m:s.next=m,s=m),p===d)break}}return o}function X2(e,t,n,r=null){let o=e.state;if(o==="done"||o==="pending"&&!e.freezesBefore)return null;if(e.sharing&&this.share.everyoneOf(this,e)!==null)return n>=0&&this.share.sight(e,n,this.lanes.cap),null;let i=this.held(e,t,n,r);return i.reaches?i:null}function J2(e,t){return Q2(e,t,this.now)}function Q2(e,t,n,r=Number.POSITIVE_INFINITY){let o=e.parted?.get(t);return o!==void 0&&!(n<o.at)&&o.seq<=r?!1:e.named!==null?e.named.has(t):e.spec.target?e.spec.target(t):!0}function xh(e,t,n,r,o){return n!==void 0&&!n.reaches&&Q2(e,t,r,o)?void 0:n}function Dr(e,t){if(t.holding!==null){e.lanes?.refill();return}if(e.lanes?.touch(t),t.named===null){e.steps.push(t,++e.version);return}for(let n of t.named.list){let r=ut(e,n);r!==void 0&&ju(e,r)}e.relinks++}function ju(e,t){t.version=Number.NaN;let n=++e.relinks;t.slot>=0&&e.lanes!==null&&(e.lanes.unlinked[t.slot]=n)}function sP(e,t){if(t.holding===null){if(t.named===null){if(e.general.push(t),t.sharing){let n=e.sharers,r=n.length;for(;r>0&&n[r-1].id>t.id;)r--;n.splice(r,0,t)}return}e.naming++;for(let n of t.named.list){let r=e.named.get(n);r===void 0?e.named.set(n,[t]):r.push(t)}}}function Z2(e,t){e.naming--;for(let n of t.named.list){let r=e.named.get(n);if(r===void 0)continue;let o=r.indexOf(t);o>=0&&r.splice(o,1),r.length===0&&e.named.delete(n)}}var wh=class{size=0;every=[];everyTokens=[];spare=[];spareTokens=[];everySorted=!0;at=new Float64Array(64);tokens=new Float64Array(64);voices=[];limit=64;push(t,n,r){if(t===Number.NEGATIVE_INFINITY){this.every.length>=this.limit&&this.pruneEvery(),this.every.push(n),this.everyTokens.push(r);return}this.size>=this.limit&&this.prune(),this.size===this.at.length&&this.grow();let o=this.at,i=this.size++;for(;i>0;){let s=i-1>>1;if(o[s]<=t)break;this.move(s,i),i=s}o[i]=t,this.tokens[i]=r,this.voices[i]=n}first(){return this.every.length>0?Number.NEGATIVE_INFINITY:this.size>0?this.at[0]:Number.POSITIVE_INFINITY}takeEvery(){let t=this.every,n=this.everyTokens,r=0,o=!0,i=Number.NEGATIVE_INFINITY;for(let s=0;s<t.length;s++){let a=t[s];n[s]!==a.dueToken||a.state==="done"||(a.dueToken++,a.id<i&&(o=!1),i=a.id,t[r++]=a)}return t.length=r,n.length=0,this.spare.length=0,this.every=this.spare,this.everyTokens=this.spareTokens,this.spare=t,this.spareTokens=n,this.everySorted=o,t}pop(){let t=this.voices[0],n=this.tokens[0],r=--this.size;return r>0&&this.sink(0,this.at[r],this.tokens[r],this.voices[r]),this.voices[r]=void 0,n===t.dueToken&&t.state!=="done"?t:void 0}clear(){this.size=0,this.every.length=0,this.everyTokens.length=0,this.spare.length=0,this.spareTokens.length=0,this.voices=[],this.limit=64}move(t,n){this.at[n]=this.at[t],this.tokens[n]=this.tokens[t],this.voices[n]=this.voices[t]}sink(t,n,r,o){let i=this.at,s=this.size;for(;;){let a=2*t+1,l=a+1,u=t,c=n;if(a<s&&i[a]<c&&(u=a,c=i[a]),l<s&&i[l]<c&&(u=l),u===t)break;this.move(u,t),t=u}i[t]=n,this.tokens[t]=r,this.voices[t]=o}grow(){let t=new Float64Array(this.at.length*2);t.set(this.at),this.at=t;let n=new Float64Array(this.tokens.length*2);n.set(this.tokens),this.tokens=n}pruneEvery(){let t=this.every,n=this.everyTokens,r=0;for(let o=0;o<t.length;o++){let i=t[o];n[o]===i.dueToken&&(t[r]=i,n[r++]=n[o])}t.length=r,n.length=r,this.limit=Math.max(this.limit,2*r)}prune(){let t=0;for(let n=0;n<this.size;n++){let r=this.voices[n];this.tokens[n]===r.dueToken&&(t!==n&&this.move(n,t),t++)}for(let n=t;n<this.size;n++)this.voices[n]=void 0;this.size=t;for(let n=(t>>1)-1;n>=0;n--)this.sink(n,this.at[n],this.tokens[n],this.voices[n]);this.limit=Math.max(64,2*t)}};function p$(e,t){if(t.state==="done")return Number.POSITIVE_INFINITY;if(Number.isNaN(t.opened)||t.owner!==null||t.holding!==null)return Number.NEGATIVE_INFINITY;let n=Number.POSITIVE_INFINITY;if(t.parts!==null)for(let o of t.parts.values())n=Math.min(n,o.at+o.over);let r=t.back;if(r!==null&&(n=Math.min(n,r.at+(1-r.from)*r.over)),t.state==="pending")return Math.min(n,Number.isNaN(t.start)?n:t.start);if(t.turns)return Number.NEGATIVE_INFINITY;if(t.state==="fading"){let o=t.out;return o===null||o.rest?Number.NEGATIVE_INFINITY:Math.min(n,o.at+o.over)}if(n=Math.min(n,t.outAt),t.state==="frozen"){let o=Number.isNaN(e.now)?Number.NaN:t.elapsedAt(e.now),i=t.ramp;if((i===null?t.rate<=0:i.from<=0&&i.to<=0)&&!t.beginless&&o<=t.soonest)return n;if(t.rate<=0||i!==null||o<t.span+t.latest)return Number.NEGATIVE_INFINITY}return t.state==="live"&&(n=Math.min(n,t.endsAt())),n}function it(e,t){if(e.projecting)return;e.lanes?.voiceChanged(t);let n=++t.dueToken,r=p$(e,t);r!==Number.POSITIVE_INFINITY&&e.due.push(Number.isNaN(r)?Number.NEGATIVE_INFINITY:r,t,n)}function eO(e,t){let n=e.due,r=n.takeEvery(),o=n.everySorted,i=r.length;for(;n.first()<=t;){let s=n.pop();s!==void 0&&(s.dueToken++,r.push(s))}return i===0||!o?Mi(r):i===r.length?r:h$(r,i)}function h$(e,t){let n=Mi(e.slice(t)),r=[],o=0,i=0;for(;o<t&&i<n.length;){let s=e[o],a=n[i];a.id<s.id?(r.push(a),i++):(r.push(s),o++)}for(;o<t;)r.push(e[o++]);for(;i<n.length;)r.push(n[i++]);return r}var m$=8;function Mi(e){if(e.length>m$)return e.sort((t,n)=>t.id-n.id);for(let t=1;t<e.length;t++){let n=e[t],r=t;for(;r>0&&e[r-1].id>n.id;r--)e[r]=e[r-1];e[r]=n}return e}var un=Symbol("slow");function gt(e){let t=aP(e,2);for(let n=0;n<Ph;n++)lP[n]=void 0;return Ph=0,t===un?structuredClone(e):t}var lP=[],Ph=0;function y$(e){for(let t=0;t<Ph;t++)if(lP[t]===e)return!0;return!1}function aP(e,t){if(typeof e=="symbol"||typeof e=="function")return un;if(typeof e!="object"||e===null)return e;if(t===0||y$(e))return un;if(lP[Ph++]=e,Array.isArray(e)){if(Object.getPrototypeOf(e)!==Array.prototype)return un;let o=[];for(let s=0;s<e.length;s++){if(!(s in e))return un;let a=aP(e[s],t-1);if(a===un)return un;o.push(a)}let i=0;for(let s in e)if(++i>e.length)return un;return o}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)return un;let r={};for(let o in e){if(o==="__proto__")return un;let i=aP(e[o],t-1);if(i===un)return un;r[o]=i}return r}function pa(e){return typeof e!="object"||e===null?e:Array.isArray(e)?[...e]:ArrayBuffer.isView(e)?e.slice():nO(e)?gt(e):e}function Ci(e){return Array.isArray(e)?[...e]:e}function tO(e){return Array.isArray(e)||ArrayBuffer.isView(e)||nO(e)}function nO(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Kt(e,t,n=!1){return t<e.seq||t===e.seq&&(!e.strict||n)}var rO=new WeakMap,uP=new Map,me=class{weak=rO;strong=uP;oneKey=ha;oneValue=void 0;get(t){return typeof t=="object"&&t!==null?this.weak.get(t):cP(this.oneKey,t)?this.oneValue:this.strong.get(t)}set(t,n){if(typeof t=="object"&&t!==null){this.weak===rO&&(this.weak=new WeakMap),this.weak.set(t,n);return}if(this.strong===uP&&(this.oneKey===ha||cP(this.oneKey,t))){this.oneKey=t,this.oneValue=n;return}this.strong===uP&&(this.strong=new Map),this.oneKey!==ha&&(this.strong.set(this.oneKey,this.oneValue),this.oneKey=ha,this.oneValue=void 0),this.strong.set(t,n)}find(t,n){return this.get(t)}has(t){return this.get(t)!==void 0}delete(t){typeof t=="object"&&t!==null?this.weak.delete(t):cP(this.oneKey,t)?(this.oneKey=ha,this.oneValue=void 0):this.strong.delete(t)}clear(){this.oneKey=ha,this.oneValue=void 0,this.strong.clear()}},$u=class extends me{under;hidden=new me;constructor(t){super(),this.under=t}get(t){return super.get(t)??(this.hidden.get(t)?void 0:this.under.get(t))}delete(t){super.delete(t),this.hidden.set(t,!0)}},ha=Symbol("none"),cP=(e,t)=>e===t||Object.is(e,t),Th=class extends me{make;gone=null;constructor(t){super(),this.make=t}get(t){let n=super.get(t);return n===void 0&&this.gone?.get(t)!==!0&&(n=this.make(t),n!==void 0&&super.set(t,n)),n}delete(t){super.delete(t),this.gone??=new me,this.gone.set(t,!0)}};var Cn=class e{list=[];head=0;by=new me;static from(t){if(t.length===0)return null;let n=new e;for(let r of t)n.push(r);return n}push(t){this.list.push(t);let n=this.by.get(t.subject);n===void 0?this.by.set(t.subject,[t]):n.push(t)}expire(t,n){let r=this.list,o=this.head;for(;o<r.length&&!(r[o].at>=t);){let i=r[o++];n!==null&&n(i);let s=this.by.get(i.subject);s.length===1?this.by.delete(i.subject):s.shift()}this.head=o,o>=32&&o*2>=r.length&&(this.list=r.slice(o),this.head=0)}at(t,n){let r=this.by.get(t);if(r!==void 0){for(let o of r)if(!Kt(n,o.seq,o.sync))return!o.held.reaches&&o.parted!==null&&o.parted.seq>n.seq?void 0:o.held}}after(t){let n=[],r=new Set;for(let o of this.all())!Kt(t,o.seq,o.sync)&&!r.has(o.subject)&&(r.add(o.subject),n.push(o));return n}of(t){return this.by.get(t)??[]}all(){return this.head===0?this.list:this.list.slice(this.head)}};function Oi(e,t){let n=e.patch,r=[...t.kept?.values()??[],...t.unkept??[]],o={reaches:t.reaches,delay:t.delay,since:t.since,shown:t.shown,weight:t.weight,rested:Io(t),restedAt:t.restedAt,bands:t.bands===null?null:Array.from(t.bands),state:t.state===void 0?void 0:n.pack?n.pack(t.state):gt(t.state),stepped:t.stepped,ticks:t.ticks,rebuilt:t.rebuilt,kept:r.length===0?null:r.map(gt)};return t.copied&&(o.copied=!0),t.base!==void 0&&(o.base=gt(t.base)),t.slope!==void 0&&(o.slope=gt(t.slope)),t.snaps!==void 0&&(o.snaps=t.snaps.map(i=>[i.at,i.seq,Oi(e,i.held)])),t.inputs!==void 0&&(o.inputs=t.inputs.map(i=>({...i}))),o}function Fi(e,t){let n=e.patch,r=t.bands===null?null:Uint8Array.from(t.bands),o=Mn(e,t.reaches,t.state===void 0?void 0:n.unpack?n.unpack(t.state):t.state);return o.delay=t.delay,o.since=t.since,o.shown=t.shown,o.weight=t.weight,o.restedAt=t.restedAt,o.bands=r,o.stepped=t.stepped,o.ticks=t.ticks,o.rebuilt=t.rebuilt,o.copied=t.copied===!0,t.kept!==null&&(o.unkept=t.kept),t.base!==void 0&&(o.base=t.base),t.slope!==void 0&&(o.slope=t.slope),t.snaps!==void 0&&(o.snaps=t.snaps.map(([i,s,a])=>({at:i,seq:s,held:Fi(e,a)}))),t.inputs!==void 0&&(o.inputs=t.inputs),o}var Yu=class extends Error{mix;stream;at;constructor(t,n,r){super(`blits: ${r} reaches past memory into ${n} records of ${t===""?"the mix":t} that were not loaded; await prepare(${r}) first`),this.mix=t,this.stream=n,this.at=r,this.name="HistoryMiss"}},Sh=class{store;loaded=null;last=null;constructor(t){this.store=t}},kh=class{of;refs=new Map;gone=new FinalizationRegistry(t=>{let n=this.refs.get(t);n!==void 0&&n.deref()===void 0&&this.refs.delete(t)});constructor(t){this.of=t}key(t){if(t===void 0||typeof t=="string"||typeof t=="number")return t;let n=this.of;if(n===void 0||typeof t!="object"||t===null)throw new Error("blits: a mix whose history has a store pages its subjects by key; give it keyOf for subjects that are not strings or numbers");let r=n(t);return this.refs.get(r)?.deref()!==t&&(this.refs.set(r,new WeakRef(t)),this.gone.register(t,r)),r}subject(t){if(t!==void 0)return this.refs.get(t)?.deref()??t}};function er(e,t,n,r,o,i,s){if(e.transport.pager===null||o.length===0)return;let l=e.name??"",u=[];for(let c=0;c<o.length;c++){let d=o[c];if(c+1<o.length&&o[c+1].seq===d.seq)continue;let f={mix:l,stream:t,at:d.at,seq:d.seq,data:i(d)};n!==void 0&&(f.voice=n),r!==void 0&&(f.subject=r),u.push(f)}oO(e.transport,u,s)}function oO(e,t,n){let r=e.pager;r.store.page(t);let o=r.loaded;o!==null&&(e.now-o.now>(e.history?.ms??0)?r.loaded=null:o.records.push(...t));let i=t[t.length-1];r.last={mix:i.mix,stream:i.stream},n>e.floor&&(e.floor=n)}function iO(e){let t=e.history;if(t===void 0||e.pager===null)return;let n=e.now-t.ms,r=[];e.frames.shed(n,s=>r.push({mix:"",stream:"frame",at:s.at,seq:s.seq,data:s.u}));let o=e.pace,i=s=>o===null?s:o.reading(s);if(e.announced.some(s=>i(s.at)<n)){let s=[];for(let a of e.announced)i(a.at)<n?r.push({mix:"",stream:"mark",subject:a.order,at:i(a.at),seq:a.seq,data:a}):s.push(a);e.announced=s}if(o!==null)for(let s of o.shed(n))r.push({mix:"",stream:"pace",at:s.anchorElapsed,seq:s.seq,data:s});r.length>0&&oO(e,r,n)}async function sO(e,t){let n=e.pager;if(n===null||e.reaches(t))return;let r=await n.store.load(t);n.loaded={t,now:e.now,records:[...r]}}var vh=class{cued=null;by=new Map;gone=null;goneBy=new Map;versions=new Map;held=new Set};function Ah(e,t){let n=e.scored.held;if(n.has(t)||e.dropped)return;n.add(t);let r=e.transport.holders,o=e,i=r.get(t);if(i===void 0){r.set(t,[o]);return}let s=i.findIndex(a=>a.slot>o.slot);s<0?i.push(o):i.splice(s,0,o)}function aO(e,t){return e.transport.holders.get(t)??hO}function dP(e,t){e.scored.held.delete(t);let n=e.transport.holders,r=n.get(t);if(r===void 0)return;let o=r.indexOf(e);o>=0&&r.splice(o,1),r.length===0&&n.delete(t)}function lO(e){for(let t of e.cued)t.spec.score!==void 0&&Ah(e,t.spec.score);for(let t of e.gone)t.spec.score!==void 0&&Ah(e,t.spec.score)}function uO(e){for(let t of[...e.scored.held])dP(e,t)}function ma(e,t,n=!1){let r=t.spec.score;if(r===void 0)return;let o=e.scored;if(o.versions.set(r,(o.versions.get(r)??0)+1),!n||t.state!=="done")return;let i=o.goneBy.get(r);i!==void 0&&o.goneBy.set(r,[...i])}function cO(e,t){return e.scored.versions.get(t)??0}function dO(e,t){let n=t.spec.score;if(n===void 0)return;let r=e.get(n);r===void 0?e.set(n,new Set([t])):r.add(t)}function fO(e,t){let n=e.scored;if(n.cued!==e.cued){n.by=new Map;for(let r of e.cued)dO(n.by,r);n.cued=e.cued}return n.by.get(t)??g$}var g$=new Set;function pO(e,t){let n=e.scored;if(n.gone!==e.gone){n.goneBy=new Map;for(let r of e.gone)mO(n.goneBy,r);n.gone=e.gone}return n.goneBy.get(t)??hO}var hO=[];function mO(e,t){let n=t.spec.score;if(n===void 0)return;let r=e.get(n);r===void 0?e.set(n,[t]):r.push(t)}function Rh(e,t){t.spec.score!==void 0&&Ah(e,t.spec.score);let n=e.scored;n.gone===e.gone&&mO(n.goneBy,t)}function fP(e,t,n){let r=e.scored;if(r.gone!==t)return;r.gone=e.gone;let o=new Map;for(let i of n){let s=i.spec.score;if(s===void 0)continue;let a=o.get(s);a===void 0?o.set(s,new Set([i])):a.add(i)}for(let[i,s]of o){let a=(r.goneBy.get(i)??[]).filter(l=>!s.has(l));a.length===0?r.goneBy.delete(i):r.goneBy.set(i,a)}}function yO(e,t){ma(e,t),t.spec.score!==void 0&&Ah(e,t.spec.score);let n=e.scored;n.cued===e.cued&&dO(n.by,t)}function gO(e,t){for(let r of t)ma(e,r);let n=e.scored;if(n.cued===e.cued)for(let r of t){let o=r.spec.score;if(o===void 0)continue;let i=n.by.get(o);i!==void 0&&(i.delete(r),i.size===0&&n.by.delete(o))}}var tr=Symbol("absent"),bO=Symbol("unit"),Nh=class{owner;next=0;free=null;refs=[void 0];registry=null;lone=null;loneSlot=-1;constructor(t){this.owner=t}adopt(t){this.owner=t}get size(){return this.next}take(t){let n=this.free?.pop()??this.next++,r=-1;if(typeof t=="object"&&t!==null){let o=new WeakRef(t);if(this.refs[n]=o,this.registry===null){if(this.lone===null)return this.lone=o,this.loneSlot=n,n;this.registry=new FinalizationRegistry(s=>this.release(s));let i=this.lone.deref();i!==void 0?this.registry.register(i,this.loneSlot,this.lone):r=this.loneSlot,this.lone=null}this.registry.register(t,n,o)}else this.refs[n]=t===void 0?bO:t;return r>=0&&this.release(r),n}has(t){return this.refs[t]!==void 0}subject(t){let n=this.refs[t];if(n===void 0)return tr;if(n!==bO){if(n instanceof WeakRef){let r=n.deref();return r===void 0?tr:r}return n}}move(t,n){let r=this.refs[t],o=this.free;if(r===void 0||n>=this.next||this.refs[n]!==void 0||o===null)return!1;let i=o.lastIndexOf(n);if(i<0)return!1;if(r instanceof WeakRef){let s=r.deref();if(s===void 0)return!1;r===this.lone?this.loneSlot=n:this.registry!==null&&(this.registry.unregister(r),this.registry.register(s,n,r))}return o.splice(i,1),o.push(t),this.refs[n]=r,this.refs[t]=void 0,!0}release(t){let n=this.refs[t];n!==void 0&&(n===this.lone?this.lone=null:n instanceof WeakRef&&this.registry?.unregister(n),this.refs[t]=void 0,this.owner.forget(t),this.free===null?this.free=[t]:this.free.push(t))}};var pe={live:!0,horizon:Number.POSITIVE_INFINITY,kept:0,moved:0,inputs:0,ahead:null,back:null};var b$=(e,t)=>e.seq===void 0||Number.isNaN(e.seq)||Kt(t,e.seq,e.early===!0);function x$(e,t){let n=e[e.length-1];if(t>=n.at||e.length===1)return n;if(e[0].at>t)return e[0];let r=0,o=e.length-2;for(;r<o;){let i=r+o+1>>1;e[i].at<=t?r=i:o=i-1}return e[r]}function Ih(e,t,n,r){let o=e.runThen(t,r)??e.freshRun(t),i=o.stretches,s=o.pending??[],a=[],l=!1;for(let c of[...i.slice(1).map(d=>d.change),...s])c===void 0||b$(c,r)?c!==void 0&&a.push(c):l=!0;l&&(i=[i[0]],s=a.filter(c=>c.at!==void 0).sort((c,d)=>c.at-d.at));let u=x$(i,n);for(let c of s){let d=c.at;if(d===void 0||!(d<=n))break;d>=u.at&&(u=e.applied(t,u,c,d))}return e.evaluateSegment(u,n,e.xs,e.vs),o.flags}var w$=e=>typeof e=="number"?[e]:[...e];var wO=Symbol.for(`@msb235/blits/motions@${ch}`),xO=new Map,pP=class{motions;writes;constructor(t,n){this.motions=n;let r=xO.get(t);r===void 0&&(r=Object.freeze([t]),xO.set(t,r)),this.writes=r}form="motion";duration=0;get motion(){return this.motions.spec()}get[wO](){return this.motions}at(t,n,r){let o=this.motions,i=pe.back;if(i!==null){let a=Ih(o,n,r.elapsed,i);return{[this.writes[0]]:o.valueOf(a,o.xs)}}let s=o.slot(n);return o.sample(s,r.elapsed,o.xs,o.vs),{[this.writes[0]]:o.value(s,o.xs)}}set(t,n,r){this.motions.change(t,{at:r,x:w$(n)})}read(t,n){let r=this.motions,o=r.read(t,n);if(o!==void 0)return{value:r.value(o.s,o.x),velocity:r.value(o.s,o.v)}}};function On(e){return e instanceof pP?e.motions:e[wO]}var Eh=class{list;set;delays=null;latest=0;soonest=0;constructor(t,n){if(Array.isArray(t)&&P$(t)){this.list=t.slice(),this.set=null,n&&(this.delays=PO(this.list,n)),[this.latest,this.soonest]=TO(this.delays);return}let r=[],o=null;for(let i of t)o!==null?o.has(i)||(o.add(i),r.push(i)):r.includes(i)||(r.push(i),r.length>8&&(o=new Set(r)));this.list=r.slice(),this.set=o,n&&(this.delays=PO(this.list,n)),[this.latest,this.soonest]=TO(this.delays)}get size(){return this.list.length}has(t){return this.set===null?this.list.includes(t):this.set.has(t)}};function PO(e,t){let n=new Map;for(let r of e)n.set(r,t(r));return n}function TO(e){let t=0,n=0;for(let r of e?.values()??[])r>t&&(t=r),r<n&&(n=r);return[t,n]}function P$(e){let t=e.length;if(t>8)return!1;for(let n=1;n<t;n++){let r=e[n];for(let o=0;o<n;o++){let i=e[o];if(r===i||Number.isNaN(r)&&Number.isNaN(i))return!1}}return!0}var T$=256;function Eo(e,t,n=!1){let r=e.clocks;if(r!==null&&r.length>=T$)return;let o=e.holding!==null||e.spec.stagger!==void 0?Number.POSITIVE_INFINITY:0;if(r!==null&&SO(r,0)>=o&&SO(r,kO(e))>=o)return;let{anchorNow:i,anchorElapsed:s,rate:a,ramp:l,rebuilds:u}=e,c={anchorNow:i,anchorElapsed:s,rate:a,ramp:l,until:t,rebuilds:u,sought:n};r===null?e.clocks=[c]:r.push(c)}function SO(e,t){let n=Number.NEGATIVE_INFINITY;for(let r=t;r<e.length;r++){let o=e[r],i=ze(o,o.until);i>n&&(n=i)}return n}function kO(e){let t=e.clocks;if(t===null)return 0;let n=0;for(;n<t.length&&t[n].rebuilds!==e.rebuilds;)n++;return n}function S$(e,t,n){for(let r=t.length-1;r>=0;r--)if(t[r].sought&&(t[r+1]?.anchorElapsed??e.anchorElapsed)<n)return r+1;return 0}function Mh(e,t,n){let r=e.clocks,o=e.beginless?e.start:Number.NaN;if(r!==null&&Number.isNaN(o)){let i=n?Math.max(kO(e),S$(e,r,t)):0;for(let s=i;s<r.length;s++){let a=r[s],l=En(a,t);if(l<=a.until){o=l;break}}}return Number.isNaN(o)&&(o=En(e,t),o===Number.POSITIVE_INFINITY&&(o=e.start+t)),e.owner===null?o:Mh(e.owner,o,n)}function Mo(e){return e.owner===null?e.start:Mh(e.owner,e.start,!1)}var Li=Object.freeze({form:"fn",duration:0,writes:[],at:()=>({})}),Co=class{children=[];kids=0;played=0;coasts=[];cutSeq=Number.POSITIVE_INFINITY;get coast(){let t=this.coasts.length;return t===0?Number.NEGATIVE_INFINITY:this.coasts[t-1]}left(t,n){t===void 0?n<this.cutSeq&&(this.cutSeq=n):t>this.coast&&this.coasts.push(n,t)}back(t){let n=this.coasts;for(;n.length>0&&n[n.length-2]>t;)n.length-=2;this.cutSeq>t&&(this.cutSeq=Number.POSITIVE_INFINITY)}};function Te(e,t){let n=e.owner===null?t:Te(e.owner,t);return n>=e.start?ze(e,n):Number.NEGATIVE_INFINITY}function vO(e,t,n){let r=Te(t,n);return r===Number.NEGATIVE_INFINITY?r:ze(e,r)}function Oo(e,t){let n=e.backs?Wu(e,t):En(e,t);return e.owner===null?n:Oo(e.owner,n)}function Ch(e){let t=!1;for(let n=e.owner;n!==null;n=n.owner)n.backs&&(t=!t);return t}function AO(e,t){let n=e.holding;n.children.push(t),n.kids++}function RO(e,t){let n=e.owner,r=n.holding,o=r.children.indexOf(e);return o>=0&&r.children.splice(o,1),!Br(n,t)&&n.state!=="done"?n:null}function Br(e,t){for(let n of e.holding.children)if(!n.quietAt(t))return!0;return!1}function NO(e,t,n){let r=e.holding;++r.played===r.kids&&e.play(!0,t,n)}function _i(e,t){for(let n of e.holding.children)t(n),n.holding!==null&&_i(n,t)}function IO(e){for(let t=e.owner;t!==null;t=t.owner)if(typeof t.spec.weight=="function")return!0;return!1}function EO(e){for(let t=e.owner;t!==null;t=t.owner){let n=t.spec.weight;if(typeof n=="function"&&n.input)return!0}return!1}function hP(e,t,n,r){let o=typeof e.spec.weight=="function"?r(e):e.weight,i=Mo(e),s=e.freezesBefore&&e.opened<i?e.opened:i;return Fr(o*la(e.fade.in??0,e.out,e.ease,n,t,s,e.back,e.stalls))}function MO(e,t,n,r){let o=1,i=e;for(let s=e.owner;s!==null;i=s,s=s.owner)o*=hP(s,t,n,r),s.arc!==null&&(o*=CO(s,i,t,n));return o}function ya(e,t){let n=new Map;for(let r of e)if(n.set(r.id,r),r.holding!==null){let o=new Co;o.kids=r.holding.kids,o.played=r.holding.played,o.coasts=r.holding.coasts.slice(),o.cutSeq=r.holding.cutSeq,t!==void 0&&o.back(t),r.holding=o}for(let r of e){let o=r.owner===null?void 0:n.get(r.owner.id);o!==void 0&&(r.owner=o,o.holding.children.push(r))}}function yP(e,t,n){let r=n.writes??(n.kit?Object.keys(n.kit):void 0);if(r===void 0)throw new Error("blits: a patch needs writes, or a kit to take them from");return{form:"fn",duration:e,writes:r,kit:n.kit,reads:n.reads,at:t,state:n.state,step:n.step,pack:n.pack,unpack:n.unpack}}var k$=(e,t,n)=>e+(t-e)*n;function mP(e,t,n){if(typeof e=="number"&&typeof t=="number")return k$(e,t,n);if(Array.isArray(e)&&Array.isArray(t)){let r=new Array(e.length);for(let o=0;o<e.length;o++)r[o]=mP(e[o],t[o],n);return r}return n<.5?e:t}function v$(e,t,n,r){let o=r.ease===void 0?void 0:No(r.ease),i=[];for(let s of t){let a=r.easeBy?.(s),l=a===void 0?o:No(a),u=[];for(let p of e){let h=p.delta[s];h!==void 0&&u.push({at:p.at,value:Array.isArray(h)?[...h]:ArrayBuffer.isView(h)?h.slice():h,ease:p.ease===void 0?l:No(p.ease)})}u.sort((p,h)=>p.at-h.at);let c=u.filter(p=>p.at!==0),d=r.lerpBy?.(s)??r.kit?.[s]?.lerp,f=u.length>0&&(d===void 0||d===Mt)&&u.every(p=>typeof p.value=="number");i.push({channel:s,all:u,tail:c,ats:u.map(p=>p.at),tailAts:null,delay:r.delayBy?.(s)??0,lerp:d,numbers:f?{ats:Float64Array.from(u,p=>p.at),values:Float64Array.from(u,p=>p.value),eases:u.map(p=>p.ease)}:null})}return{tracks:i,duration:n}}var Fh=0,ga=1,A$=2,Be={a:void 0,b:void 0,u:0,eased:0,first:!1,len:0,ease:void 0};function gP(e,t,n){return bP(e.delay,t,n)}function bP(e,t,n){return e===0||n===0?t:e>=n?t>=1?1:0:Math.max(0,(t*n-e)/(n-e))}function xP(e,t,n,r,o){return r===0?-2:o<=e[t]?-1:o>=e[t+(r-1)*n]?r:FO(e,t,n,1,r-1,o)}function FO(e,t,n,r,o,i){for(;r<o;){let s=r+o>>1;e[t+s*n]>=i?o=s:r=s+1}return r}function wP(e,t,n){return(e-t)/(n-t)}function PP(e,t,n){let r,o=n===void 0?0:1,i=o===0?e.all:e.tail;if(o===0){let c=i.length;if(r=xP(e.ats,0,1,c,t),r===-2)return Fh;if(r===-1||r===c)return Be.a=i[r===-1?0:c-1].value,ga}else{let c=i.length+1;if(t<=0)return Be.a=n,ga;let d=i[i.length-1];if(d===void 0||t>=d.at)return Be.a=d===void 0?n:d.value,ga;e.tailAts??=i.map(f=>f.at),r=FO(e.tailAts,-1,1,1,c-1,t)}let s=i[r-o],a=r-1<o?0:i[r-1-o].at,l=wP(t,a,s.at),u=s.ease?s.ease(l):l;return Be.a=r-1<o?n:i[r-1-o].value,Be.b=s.value,Be.u=l,Be.eased=u,Be.first=r-1<o,Be.len=s.at-a,Be.ease=s.ease,A$}function R$(e,t){let n=e.ats,r=e.values,o=n.length;if(t<=n[0])return r[0];if(t>=n[o-1])return r[o-1];let i=1,s=o-1;for(;i<s;){let f=i+s>>1;n[f]>=t?s=f:i=f+1}let a=n[i-1],l=(t-a)/(n[i]-a),u=e.eases[i],c=u?u(l):l,d=r[i-1];return d+(r[i]-d)*c}function N$(e,t,n,r,o,i,s,a){let l=e.numbers;if(l!==null&&n===void 0&&o===void 0&&(r===void 0||r===Mt||e.lerp!==void 0))return R$(l,t);let u=PP(e,t,n);if(u===Fh)return;if(u===ga)return Be.a;let c=Be.a,d=Be.b,f=Be.u,p=Be.eased,h=Be.first,m=Be.len,g=Be.ease,b;if(s!==void 0)b=s(a,c,d,p),Oh.wrote=b;else{let y=e.lerp??r;b=y?y(c,d,p):mP(c,d,p)}if(o===void 0||!h)return b;let x=g?z2(g):1;if(x===Number.POSITIVE_INFINITY)return b;let w=(y,P,S)=>(y*i*m-(S-P)*x)*f*(1-f)*(1-f);if(typeof b=="number"&&typeof o=="number")return b+w(o,c,d);if(Array.isArray(b)&&Array.isArray(o)){let y=b===Oh.wrote?b:new Array(b.length),P,S=()=>{let v=e.lerp??r,A=N=>s!==void 0?s(void 0,c,d,N):v?v(c,d,N):mP(c,d,N);return P=[A(0),A(1)],P};for(let v=0;v<b.length;v++){let A=b[v],N=o[v];if(typeof A!="number"||typeof N!="number"){y[v]=A;continue}let M=c[v],C=d[v];if(typeof M!="number"||typeof C!="number"){let[F,B]=P??S();M=F?.[v],C=B?.[v]}y[v]=typeof M=="number"&&typeof C=="number"?A+w(N,M,C):A}return y}return b}var Oh={wrote:void 0};function LO(e,t){return e.tracks.map((n,r)=>{let o=t[r];return n.lerp===void 0||n.lerp===o.lerp?fh(o):void 0})}function Lh(e,t,n,r,o,i,s,a){let l=e.duration;for(let u=0;u<e.tracks.length;u++){let c=e.tracks[u],d=i?.[c.channel],f=a===void 0?void 0:s?.[u];Oh.wrote=void 0;let p=N$(c,gP(c,t,l),r?.[c.channel],o?.[u],l===0?void 0:d,l,f,f===void 0?void 0:a[u]);f!==void 0&&p===Oh.wrote&&(a[u]=p),p!==void 0?n[c.channel]=p:n[c.channel]!==void 0&&(n[c.channel]=void 0)}return n}var OO=new WeakMap;function _O(e){let t=OO.get(e);return t===void 0&&(t=v$(e.keys,e.writes,e.duration,e),OO.set(e,t)),t}function TP(e){return function(n,r){let o=e.keepOn,i=o===null?e.ownKept:o.kept;if(i===null&&(i=new Map,o===null?e.ownKept=i:o.kept=i),i.has(n))return i.get(n);let s=o?.unkept,a=s===void 0?r():s.shift();return s?.length===0&&o!==null&&(o.unkept=void 0),i.set(n,a),pe.kept++,a}}var _h=class{host;send;voice;timestamp=0;dt=0;elapsed=0;pass=0;weight=0;state=void 0;mark=0;kept=null;constructor(t,n,r){this.host=t,this.send=n,this.voice=r}get keep(){return this.kept===null&&(this.kept=TP(this.voice)),this.kept}};function qu(e,t){let n=e.named?.delays?.get(t);return n!==void 0?n:e.spec.stagger?e.spec.stagger(t):0}function Xu(e,t){let n=e.unreachedBits;if(n===null||t<0)return!1;let r=t>>>5;return r<n.length&&(n[r]&1<<(t&31))!==0}function Hr(e,t,n){let r=e.unreachedBits,o=t>>>5;if(r===null||o>=r.length){if(!n)return;let s=new Uint32Array(Math.max(o+1,(r?.length??0)*2,2));r!==null&&s.set(r),e.unreachedBits=s,r=s}let i=1<<(t&31);r[o]=n?r[o]|i:r[o]&~i}function SP(e,t,n){Xu(e,t)&&(Hr(e,n,!0),Hr(e,t,!1))}function DO(e,t){let n=this.sinceOf(e,0),r=Mn(e,!1,void 0);return r.since=n,r.shown=this.shownOf(e,n),r.stepped=t,r.rebuilt=e.rebuilds,e.unreached=r,r}function BO(e,t,n,r=null){if(e.sharing){let d=this.share.everyoneOf(this,e);if(d!==null)return d}if(Xu(e,n))return e.unreached;let o=r===null?e.subjects.get(t):e.subjects.find(t,r);if(o!==void 0)return o;let i=this.now;if(!this.aims(e,t)){let d=e.unreached??this.unreachedOf(e,i);return n>=0&&e.named===null?Hr(e,n,!0):e.subjects.set(t,d),d}this.keys!==null&&(e.keyed??=new Set,e.keyed.add(this.keys.key(t)));let a=qu(e,t),l=this.sinceOf(e,a),u=this.shownOf(e,l);o=Mn(e,!0,e.patch.state?e.patch.state(t):void 0),o.delay=a,o.since=l,o.shown=u;let c=kP(this,e,o,i);return o.rebuilt=e.rebuilds,this.projecting&&(o.from=o.stepped,o.unknown=this.backward&&e.spec.from==="current"||c),e.subjects.set(t,o),vP(e,o,i),e.sighted!==null&&this.share?.sighted(e,n)?this.share.inherit(e,o,n):e.seen++,a>e.latest&&(e.latest=a,e.state==="frozen"&&it(this,e)),a<e.soonest&&(e.soonest=a,it(this,e)),o}function kP(e,t,n,r){let o=n.since;if(!(o<r))return n.stepped=r,!1;if(t.spec.catchUp!=="fresh"||t.patch.step===void 0)return n.stepped=o,!1;let i=vo(e,t);return i===void 0?n.stepped=r:(n.ticks=Math.floor((r-o)/i+1e-9),n.stepped=o+n.ticks*i),n.stepped>o}function HO(e,t){let n=e.patch;return Mh(e,t,n.state!==void 0||n.step!==void 0||e.keeping)}function GO(e,t){let n=Mo(e),r=t<n?n:t;return e.freezesBefore&&e.opened<r?e.opened:r}function UO(e,t,n){return!(t.since<=n)||e.motion!==void 0&&!(t.probed>=t.since)}function vP(e,t,n){if(t.since<=n)return;e.early??=[];let r=e.early;if(r.length>=64&&(r.length&r.length-1)===0){let o=0;for(let i of r)UO(e,i,n)&&(r[o++]=i);r.length=o}r.push(t)}function ba(e,t,n){t.state="live",t.begunSeq=e.transport.seq,t.anchorElapsed!==0&&(t.seeks++,t.rebuilds++,t.note(n,e.transport.seq,!0)),cn(e,t,n),Dr(e,t)}function xa(e,t,n){let r=n.since;n.since=e.sinceOf(t,n.delay),n.since!==r&&(n.ticks>0||n.stepped>r)&&(n.rebuilt=-1),n.shown=e.shownOf(t,n.since),n.ticks===0&&n.stepped>n.since&&(n.stepped=n.since)}function cn(e,t,n){let r=t.early;if(r===null)return;let o=0;for(let i of r)xa(e,t,i),UO(t,i,n)&&(r[o++]=i);r.length=o,o===0&&(t.early=null),e.lanes?.reshown(t.id)}var Dh=class{of=null;count=0;general=[];named=new me;latest=Number.NEGATIVE_INFINITY;slack=0};function I$(e,t){let n=t.reachedTo;if(n<e.latest?e.slack=Math.max(e.slack,e.latest-n):e.latest=n,t.named===null){e.general.push(t);return}for(let r of t.named.list){let o=e.named.get(r);o===void 0?e.named.set(r,[t]):o.push(t)}}function VO(e,t){let n=!1;for(let r of t){if(r.named===null){n=!0;continue}for(let o of r.named.list){let i=e.named.get(o);if(i===void 0)continue;let s=i.indexOf(r);s>=0&&i.splice(s,1),i.length===0&&e.named.delete(o)}}if(n){let r=new Set(t);e.general=e.general.filter(o=>!r.has(o))}}function Fo(e){let t=e.goneIx,n=e.gone;(t.of!==n||t.count>n.length)&&(t.general=[],t.named=new me,t.count=0,t.of=n,t.latest=Number.NEGATIVE_INFINITY,t.slack=0);for(let r=t.count;r<n.length;r++)I$(t,n[r]);return t.count=n.length,t}function WO(e,t){for(let n of t)e.parters.delete(n),e.departed.add(e,n),n.doneAt>e.transport.forgotTo&&(e.transport.forgotTo=n.doneAt)}function AP(e,t){let n=Fo(e),r=e.gone,o=0;for(;o<r.length&&t(r[o]);)o++;if(o===r.length)return;let i=r.slice(0,o),s=[r[o]];for(o++;o<r.length;o++){let a=r[o];(t(a)?i:s).push(a)}VO(n,s),WO(e,s),e.gone=i,fP(e,r,s),n.of=i,n.count=i.length}function zO(e,t){let n=Fo(e);if(!Number.isFinite(n.slack)){AP(e,u=>u.reachedTo>=t);return}let r=e.gone,o=t+n.slack,i=0,s=!1;for(let u=Number.NEGATIVE_INFINITY;i<r.length&&u<o;i++){let c=r[i].reachedTo;c<t&&(s=!0),c>u&&(u=c)}if(!s)return;let a=[],l=[];for(let u=0;u<i;u++){let c=r[u];(c.reachedTo<t?l:a).push(c)}r.splice(0,i,...a),VO(n,l),WO(e,l),fP(e,r,l),n.count=r.length}var KO=[];function RP(e,t){return e>=0&&(t>0?e<t:Number.isFinite(e))}function jO(e,t){for(let n of e)if(!RP(n.at,t))throw new RangeError(t>0?`blits: a hit's at is voice ms into a pass, 0 up to ${t}, not ${n.at}`:`blits: a hit's at is voice ms, 0 or more, not ${n.at}`)}var Bh=class{host;opts;est=Number.NaN;last=Number.NaN;prev=Number.NaN;round=0;canceled=!1;floor=Number.NEGATIVE_INFINITY;marked=new Map;tracks=new Map;due=[];constructor(t,n){this.host=t,this.opts=n}sync(){if(this.canceled)return;let t=this.host,n=t.timestamp,r=this.opts.clock();if(Number.isNaN(this.est))this.est=r;else{let a=this.est+(n-this.last),l=r-a;this.est=Math.abs(l)>50?r:a+l*.05}this.last=n;let o=Number.isNaN(this.prev)?t.now:this.prev;this.prev=t.now,this.round++,this.marks(n),this.hits(n,o);let i=this.due;i.sort((a,l)=>a.time-l.time);let s=this.opts.late;for(let a of i){let l=a.time<n?n-a.time:0;if(l>s)continue;let u=this.est+(a.time-n),c={time:a.time,at:u,taken:void 0};a.into.set(a.key,c),c.taken=this.opts.take(a.item,l>0?r:Math.max(u,r),l)}i.length=0;for(let a of this.tracks.values())for(let[l,u]of a.booked)u.time<=n&&a.booked.delete(l)}cancel(){if(!this.canceled){this.canceled=!0;for(let t of this.marked.values())t.time>this.last&&t.taken?.cancel();for(let t of this.tracks.values())for(let n of t.booked.values())n.time>this.last&&n.taken?.cancel();this.marked.clear(),this.tracks.clear(),this.host.unhook(this)}}sought(){if(this.canceled)return;let t=this.last;for(let r of this.marked.values())r.time>t&&r.taken?.cancel();for(let r of this.tracks.values())for(let o of r.booked.values())o.time>t&&o.taken?.cancel();this.marked.clear(),this.tracks.clear();let n=this.host;this.floor=n.timestamp,this.prev=n.now;for(let r of n.voices)r.spec.hits!==void 0&&r.state!=="done"&&this.tracks.set(r,{seenTo:r.elapsedAt(n.now),jumps:r.jumps,booked:new Map,met:this.round})}at(t){return this.est+(t-this.last)}stands(t,n){return n===void 0||!Number.isFinite(n)?!1:Math.abs(this.est+(n-this.last)-t.at)<=1}fits(t,n){let{tag:r,score:o}=this.opts;return(o===void 0||t===o)&&(r===void 0||n.includes(r))}marks(t){let n=this.host.marks(t-this.opts.late,t+this.opts.ahead),r=this.marked,o=new Set;for(let i of n){if(!this.fits(i.score,i.tags)||i.timestamp<=this.floor)continue;let s=E$(i);o.add(s);let a=r.get(s);if(a!==void 0){if(a.time<=t||this.stands(a,i.timestamp))continue;a.taken?.cancel(),r.delete(s)}let{order:l,...u}=i;this.due.push({time:i.timestamp,item:u,into:r,key:s})}for(let[i,s]of r)o.has(i)||(s.time>t&&s.taken?.cancel(),r.delete(i))}hits(t,n){let r=this.host,o=this.round,{ahead:i,late:s}=this.opts,a=r.readingAt(t+i),l=Number.isFinite(s)?r.readingAt(t-s):Number.NEGATIVE_INFINITY;for(let u of r.voices){let c=u.spec.hits;if(c===void 0||c.length===0||u.state==="done"||!this.fits(u.spec.score,u.spec.tags??KO))continue;let d=this.tracks.get(u);d===void 0&&(d={seenTo:Number.NEGATIVE_INFINITY,jumps:u.jumps,booked:new Map,met:o},this.tracks.set(u,d)),d.met=o,d.jumps!==u.jumps&&(d.jumps=u.jumps,d.seenTo=u.elapsedAt(n));let f=r.endOf(u),p=c.length,h=!1;for(let[w,y]of d.booked){if(y.time<=t)continue;let P=this.timeOfHit(u,c,Math.floor(w/p),w%p,f);this.stands(y,P)||(y.taken?.cancel(),d.booked.delete(w),h=!0)}h&&(d.seenTo=Math.min(d.seenTo,u.elapsedAt(n)));let m=u.elapsedAt(a);if(!(m>d.seenTo))continue;let g=Math.max(d.seenTo,u.elapsedAt(l));if(!(g<=m)){d.seenTo=m;continue}let b=u.duration,x=b>0?Math.min(u.passes-1,Math.floor(m/b)):0;for(let w=b>0?Math.max(0,Math.floor(g/b)):0;w<=x;w++)for(let y=0;y<p;y++){let P=w*b+c[y].at;if(!(P>d.seenTo&&P<=m))continue;let S=w*p+y;if(d.booked.has(S))continue;let v=this.timeOfHit(u,c,w,y,f);if(v===void 0||!Number.isFinite(v))continue;let A={timestamp:v,voice:u.id,hit:y,pass:w,event:c[y].event,score:u.spec.score,name:u.spec.name,tags:u.spec.tags??KO,subjects:u.named?.list};this.due.push({time:v,item:A,into:d.booked,key:S})}d.seenTo=m}for(let[u,c]of this.tracks)if(c.met!==o){for(let d of c.booked.values())d.time>t&&d.taken?.cancel();this.tracks.delete(u)}}timeOfHit(t,n,r,o,i){if(t.state==="done"||r>=t.passes)return;let s=t.timeAt(r*t.duration+n[o].at);if(!(!Number.isFinite(s)||i!==void 0&&s>=i))return this.host.hostOf(s)}};function E$(e){let t=e.order*6;switch(e.mark){case void 0:return t;case"start":return t+1;case"in":return t+2;case"coast":return t+3;case"out":return t+4;case"end":return t+5;default:return`${e.order}\0${e.mark}`}}var Di=["start","in","coast","out","end"];function qO(e,t){for(let n of Object.keys(e)){if(Di.includes(n))throw new Error(`blits: ${n} is one of a voice's own marks; a mark placed inside it needs another name`);let r=e[n];if(!RP(r,t))throw new RangeError(t>0?`blits: mark ${n} is voice ms into a pass, 0 up to ${t}, not ${r}`:`blits: mark ${n} is voice ms, 0 or more, not ${r}`)}}function NP(e,t){return(e.pace===null?t:e.pace.timeOf(t))+e.offset}function XO(e,t){return e.pace===null?t:e.pace.reading(t)}function Hh(e,t,n){let r=eF(e,t,n);for(let o of ZO(e.transport,t,n))(o.score!==void 0||o.slot===e.slot)&&r.push(o.listed);return QO(r)}function JO(e,t,n){let r=[];for(let o of e.members)r.push(...eF(o,t,n));for(let o of ZO(e,t,n))r.push(o.listed);return QO(r)}function QO(e){return e.sort((t,n)=>t.timestamp-n.timestamp||t.order-n.order)}function ZO(e,t,n){let r=t-e.offset,o=n-e.offset,i=[];for(let s of e.announced)s.at>=r&&s.at<=o&&i.push({score:s.score,slot:s.slot,listed:{timestamp:s.at+e.offset,mark:void 0,voice:void 0,score:s.score,name:s.name,tags:s.tags,mix:s.mix,order:s.order}});return i}function eF(e,t,n){let r=t-e.offset,o=n-e.offset,i=[];for(let s of[...e.cued,...e.gone]){for(let l of Di)$O(e,s,l,r,o,i);let a=s.spec.marks;if(a!==void 0)for(let l of Object.keys(a))$O(e,s,l,r,o,i)}return i}function $O(e,t,n,r,o,i){let s=Xe(e,t,n),a=s===void 0?s:NP(e,s)-e.offset;a===void 0||a<r||a>o||i.push({timestamp:a+e.offset,mark:n,voice:t.id,score:t.spec.score,name:t.spec.name,tags:t.spec.tags??dn,mix:e.name,order:t.id})}function Xe(e,t,n){if(!Number.isFinite(t.start))return;let r=Fn(t);if(!Number.isFinite(r))return;if(n==="start")return r;if(t.arc!==null&&(n==="in"||n==="coast"||n==="out"||n==="end"))return nF(t,r,n);if(n==="in")return r+(t.fade.in??0);if(n==="coast")return C$(e,t,r);if(n!=="out"&&n!=="end")return M$(e,t,r,n);let o=t.out,i,s=!1;if(o!==null)i=o.at;else if(Number.isFinite(t.outAt))i=t.outAt;else if(t.fitting!==null){let l=t.timeAt(t.fitting.end);Number.isFinite(l)&&(i=Math.max(r,l))}else if(t.holding!==null){let l=tF(e,t.holding.children,"end");l!==void 0&&(i=Math.max(r,l),s=!0)}else if(!(t.backs?t.freezesBefore:t.freezesAfter)){let l=t.endsAt();Number.isFinite(l)&&(i=Math.max(r,l))}if(n==="out")return t.state==="done"&&i===void 0?t.doneAt:i;if(t.state==="done")return t.doneAt;if(o!==null)return o.rest?o.deadline===void 0?void 0:o.at+o.deadline:o.at+o.over;if(s)return i;let a=Number.isNaN(t.outOver)?t.fade.out??0:t.outOver;return i===void 0?void 0:i+(e.reduced?0:a)}var YO=1e-9;function M$(e,t,n,r){let o=t.spec.marks;if(o===void 0||!Object.hasOwn(o,r)||t.backs)return;let i=o[r],s=t.elapsedAt(n),a=t.duration,l=0;if(a>0)l=Math.max(0,Math.ceil((s-i)/a-YO));else if(i<s-YO)return;if(l>=t.passes)return;let u=t.timeAt(l*a+i);if(!Number.isFinite(u))return;let c=Xe(e,t,"end");return c!==void 0&&u>=c?void 0:Math.max(n,u)}function C$(e,t,n){if(t.unplayed)return;let r;if(t.fitting!==null)r=t.timeAt(t.fitting.end);else if(t.holding!==null){let i=t.holding;if(i.cutSeq!==Number.POSITIVE_INFINITY)return;i.children.length===0?r=t.state==="done"?i.coast:void 0:(r=tF(e,i.children,"coast"),r!==void 0&&(r=Math.max(r,i.coast)))}else r=t.endsAt();return r===void 0||!Number.isFinite(r)?void 0:(r=Math.max(n,r),(t.out!==null?t.out.at:t.state==="done"?t.doneAt:t.outAt)<r?void 0:r)}function tF(e,t,n){if(t.length===0)return;let r=Number.NEGATIVE_INFINITY;for(let o of t){let i=Xe(e,o,n);if(i===void 0)return;i>r&&(r=i)}return r}var Gh=class{start=void 0;in=void 0;coast=void 0;out=void 0;end=void 0};Object.setPrototypeOf(Gh.prototype,null);var Uh=class{scopes=new Map;all=new Set;add(t,n){if(n.owner?.state==="done")return;let r=new Gh;for(let a=0;a<Di.length;a++){let l=Di[a];r[l]=Xe(t,n,l)}let o=n.spec.marks;if(o!==void 0)for(let a of Object.keys(o))r[a]=Xe(t,n,a);let i={id:n.id,score:n.spec.score,owner:n.owner?.id??-1,name:n.spec.name,tags:n.spec.tags??dn,writes:n.patch.writes,marks:r,held:0},s=this.scopeOf(i.score,i.owner);s.whole===void 0?(s.whole={first:i,last:i},i.held+=2):this.hold(s.whole,i),i.name!==void 0&&this.keep(s.names,i.name,i);for(let a=0;a<i.tags.length;a++)this.keep(s.tags,i.tags[a],i);for(let a=0;a<i.writes.length;a++)this.keep(s.writes,i.writes[a],i);i.held>0&&this.all.add(i),n.holding!==null&&this.dropOwner(n.id)}dropOwner(t){for(let n of this.scopes.values()){let r=n.get(t);if(r!==void 0){n.delete(t),r.whole!==void 0&&this.forget(r.whole);for(let o of r.names.values())this.forget(o);for(let o of r.tags.values())this.forget(o);for(let o of r.writes.values())this.forget(o)}}}scopeOf(t,n){let r=this.scopes.get(t);r===void 0&&(r=new Map,this.scopes.set(t,r));let o=r.get(n);return o===void 0&&(o={whole:void 0,names:new Map,tags:new Map,writes:new Map},r.set(n,o)),o}keep(t,n,r){let o=t.get(n);o===void 0?(t.set(n,{first:r,last:r}),r.held+=2):this.hold(o,r)}hold(t,n){this.release(t.last),t.last=n,n.held++}forget(t){this.all.delete(t.first),this.all.delete(t.last)}release(t){--t.held===0&&this.all.delete(t)}};function rF(e,t,n,r,o){return e.score===n&&(r||e.owner===o)&&(t.name===void 0||e.name===t.name)&&(t.tag===void 0||e.tags.includes(t.tag))&&(t.writes===void 0||e.writes.includes(t.writes))}function Ju(e,t){return t.owner===null?e.now:Te(t.owner,e.now)}function Fn(e){return e.owner===null?e.start:Oo(e.owner,e.start)}function Bi(e,t){return e.pace===null?t:e.pace.at(t,e.u)}function Lo(e,t,n){e.pins??=new Map,e.pins.set(t,n),t.pinned=n}function iF(e){let t=e.pins;for(let[n,r]of t)n.state!=="pending"?t.delete(n):Ta(e,n,Bi(e,r))}function Ta(e,t,n){return n===t.start?!1:(t.start=n,t.anchorNow=n,t.clocks=null,t.seeks++,cn(e,t,e.now),Ke(e,t),!0)}function sF(e,t,n,r){if(n.start!==void 0&&n.in!==void 0)throw new Error("blits: a placement anchors start or in, not both");if(n.out!==void 0&&n.end!==void 0)throw new Error("blits: a placement anchors out or end, not both");if(t.start!==void 0&&(n.start!==void 0||n.in!==void 0))throw new Error("blits: a voice takes start or an anchored start, not both");let o={id:e.nextId,spec:t,owner:r,slot:e.slot,writes:t.patch?.writes??dn},i=[o];for(let u of e.transport.members)for(let c of[u.gone,u.cued])for(let d of c)i.push({id:d.id,spec:d.spec,owner:d.owner,slot:u.slot,writes:d.patch.writes});let s=()=>{throw new Error(`blits: ${t.name??"a voice"}'s placement waits on itself`)},a=(u,c)=>{if("all"in c)return c.all.flatMap(y=>a(u,y));if("any"in c)return c.any.flatMap(y=>a(u,y));let d="of"in c?c.of:"after"in c?c.after:"with"in c?c.with:c.before,f="of"in c?c.mark:"after"in c?"end":"start",p=typeof d=="string"?{name:d}:d,h=p.score??u.spec.score,m=p.score!==void 0;u===o&&p.name!==void 0&&p.name===t.name&&h===t.score&&s();let g=i.filter(y=>y!==u&&y.spec.score===h&&(m||y.owner===u.owner&&y.slot===u.slot)&&(p.name===void 0||y.spec.name===p.name)&&(p.tag===void 0||(y.spec.tags??dn).includes(p.tag))&&(p.writes===void 0||y.writes.includes(p.writes))),b=p.resolver??"last",x=g.length>1&&(b==="first"||b==="last")?[g.reduce((y,P)=>(b==="last"?P.id>y.id:P.id<y.id)?P:y)]:g,w=f==="out"||f==="end"?"out":"start";return x.map(y=>({voice:y,side:w}))},l=(u,c)=>{let d=u.spec.anchor,f=c==="start"?[d?.start,d?.in]:[d?.out,d?.end],p=c==="out"?[{voice:u,side:"start"}]:[];for(let h of f)h!==void 0&&typeof h!="number"&&p.push(...a(u,h));return p};for(let u of["start","out"]){let c={start:new Set,out:new Set},d=l(o,u);for(;d.length>0;){let{voice:f,side:p}=d.pop();f===o&&p===u&&s(),!c[p].has(f)&&(c[p].add(f),d.push(...l(f,p)))}}}function Gr(e){for(let t=0;t<=e.cued.length;t++){let n=!1;for(let r of e.cued){let o=r.spec.anchor;if(!(o===void 0||r.state==="done")){if(r.placing&&r.state==="pending"){let i=o.start??o.in,s=i===void 0?void 0:Pa(e,i,r);if(s!==void 0){let a=r.owner,l=r.fade.in??0,u=o.start!==void 0?s:a===null?s-l:Te(a,Oo(a,s)-l);Number.isFinite(u)&&Ta(e,r,u)&&(n=!0)}}if(r.state!=="fading"&&!r.outSet){let i=o.out??o.end,s=i===void 0?void 0:Pa(e,i,r);if(s!==void 0){let a=r.owner===null?s:Oo(r.owner,s),l=Fn(r),u=o.out!==void 0?a:a-(r.fade.out??0),c=Number.NaN;u<l&&Number.isFinite(l)&&(u=l,o.end!==void 0&&(c=a>l?a-l:0,a<l&&!e.projecting&&Qn(r,`${r.spec.name??`voice ${r.id}`}'s placement ends before it starts, so it plays as an instant`))),(u!==r.outAt||!Wt(c,r.outOver))&&(r.outAt=u,r.outOver=c,Ke(e,r),n=!0)}}}}if(!n)break}aF(e)}function Pa(e,t,n,r){let o=n.owner;if(typeof t=="number")return o===null?Bi(e,t-n.offset):t;if("all"in t){let c=Number.NEGATIVE_INFINITY;for(let d of t.all){let f=oF(e,d,n,r);if(f===void 0)return;c=Math.max(c,f)}return t.all.length===0?void 0:c}if("any"in t){let c=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:Ju(e,n),d=Number.POSITIVE_INFINITY,f=!1;for(let p of t.any){let h=oF(e,p,n,r);h===void 0?f=!0:d=Math.min(d,h)}return d===Number.POSITIVE_INFINITY||f&&d>c?void 0:d}let i,s,a=t.by??0;"of"in t?(i=t.of,s=t.mark):"after"in t?(i=t.after,s="end"):"with"in t?(i=t.with,s="start"):(i=t.before,s="start",a=-a);let l=O$(e,i,s,n);if(l===void 0)return;if(o===null)return l+a;let u=Te(o,l);return u===Number.NEGATIVE_INFINITY?r:Number.isFinite(u)?u+a:void 0}function oF(e,t,n,r){let o=Pa(e,t,n,r);return o===void 0?n.answers?.get(t):(e.projecting||(n.answers??=new Map,n.answers.set(t,o)),o)}var wa=class{resolver;now;any=!1;firstOrder=Number.POSITIVE_INFINITY;lastOrder=Number.NEGATIVE_INFINITY;first;last;pick;constructor(t,n){this.resolver=t,this.now=n}take(t,n){this.any=!0,t<this.firstOrder&&(this.firstOrder=t,this.first=n),t>this.lastOrder&&(this.lastOrder=t,this.last=n),n!==void 0&&this.consider(n)}merge(t){t.any&&(this.any=!0,t.firstOrder<this.firstOrder&&(this.firstOrder=t.firstOrder,this.first=t.first),t.lastOrder>this.lastOrder&&(this.lastOrder=t.lastOrder,this.last=t.last),t.pick!==void 0&&this.consider(t.pick))}consider(t){let n=this.pick;(this.resolver==="earliest"?n===void 0||t<n:this.resolver==="latest"?n===void 0||t>n:this.resolver==="next"&&t>=this.now&&(n===void 0||t<n))&&(this.pick=t)}answer(){if(this.any)return this.resolver==="first"?this.first:this.resolver==="last"?this.last:this.pick}};function O$(e,t,n,r){let o=typeof t=="string"?{name:t}:t,i=o.score??r.spec.score,s=o.score!==void 0,a=o.resolver??"last",l=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,u=new wa(a,l),c=m=>m!==r&&m.spec.score===i&&(s||m.owner===r.owner)&&(o.name===void 0||m.spec.name===o.name)&&(o.tag===void 0||(m.spec.tags??dn).includes(o.tag))&&(o.writes===void 0||m.patch.writes.includes(o.writes)),d=s&&i!==void 0&&!e.projecting,f=s?d?aO(e,i):e.transport.members:[e],p=r.owner?.id??-1,h=new wa(a,l);for(let m=0;m<f.length;m++){let g=f[m],b=!1;for(let v of g.departed.all)rF(v,o,i,s,p)&&(h.take(v.id,v.marks[n]),b=!0);if(i===void 0||g.projecting||e.projecting){for(let v of[...g.gone,...g.cued])c(v)&&u.take(v.id,Xe(g,v,n));continue}let x=fO(g,i),w=pO(g,i);if(x.size===0&&w.length===0&&!b){d&&(dP(g,i),m--);continue}if(a==="next"){for(let v of x)c(v)&&u.take(v.id,Xe(g,v,n));for(let v of w)c(v)&&u.take(v.id,Xe(g,v,n));continue}let y=F$(g,w,t,n,r,a),P=cO(g,i),S=g.reduced;if(y.live===null||y.liveOf!==g.cued||y.liveVersion!==P||y.liveReduced!==S){let v=new wa(a,Number.NEGATIVE_INFINITY),A=!0;for(let N of x)c(N)&&((N.owner!==null||N.holding!==null||N.fitting!==null)&&(A=!1),v.take(N.id,Xe(g,N,n)));y.live=v,y.liveOf=A?g.cued:null,y.liveVersion=P,y.liveReduced=S}for(u.merge(y.live);y.seen<w.length;y.seen++){let v=w[y.seen];c(v)&&(v.owner===null?y.pick.take(v.id,Xe(g,v,n)):y.owned.push(v))}u.merge(y.pick);for(let v of y.owned)u.take(v.id,Xe(g,v,n))}if(o.writes===void 0&&(s||r.owner===null))for(let m of e.announced)m.score===i&&(i!==void 0||m.slot===e.slot)&&(o.name===void 0||m.name===o.name)&&(o.tag===void 0||m.tags.includes(o.tag))&&u.take(m.order,Number.isNaN(m.at)?void 0:Bi(e,m.at));return(u.any?u:h).answer()}function F$(e,t,n,r,o,i){o.folds??=new Map;let s=o.folds.get(n);s===void 0&&(s=new Map,o.folds.set(n,s));let a=s.get(e);return(a===void 0||a.list!==t||a.mark!==r)&&(a={list:t,mark:r,seen:0,pick:new wa(i,Number.NEGATIVE_INFINITY),owned:[],live:null,liveOf:null,liveVersion:-1,liveReduced:!1},s.set(e,a)),a}function EP(e){if(!Number.isFinite(e))throw new RangeError(`blits: a voice's rate is a finite number, not ${e}`)}function MP(e){if(Number.isNaN(e))throw new RangeError("blits: a voice\u2019s weight is a number, not NaN")}var Ur=class{id;#t;#n=null;#e;constructor(t,n){this.id=t.id,this.#t=t,this.#e=n}static voiceOf(t){return t.#t}static page(t,n){t.#t=null,t.#n=n}static rehome(t,n){t.#t=n,t.#n=null}get state(){return this.#t?.state??"done"}get owner(){return this.#t?.owner?.handle??void 0}get played(){return this.#t?.played??Promise.resolve(this.#n?.played??!1)}get done(){return this.#t?.done??Promise.resolve()}get result(){return this.#t?.fitting?.report}get weight(){return this.#t?.weight??this.#n?.weight??0}get#r(){let t=this.#t;return t===null||t.parked?null:t}set weight(t){MP(t);let n=this.#r;n!==null&&(n.written=!0,n.weight=t,this.#e.changed(n),this.#e.taping()&&this.#e.record(this,"weight",r=>{r.weight=t}))}get rate(){let t=this.#t;return t===null?0:t.rateAt(this.#e.nowFor(t))}set rate(t){this.ramp(t,0)}ramp(t,n){EP(t);let r=this.#r;if(r!==null){if(r.written=!0,r.state==="pending"){let o=r.ramp===null?r.rate:r.ramp.from;r.ramp=n>0&&t!==o?{from:o,to:t,over:n}:null,r.rate=t}else{let o=this.#e.nowFor(r);Eo(r,o),ca(r,o,t,n)}this.#e.changed(r),this.#e.taping()&&this.#e.record(this,"rate",o=>o.ramp(t,n))}}seek(t,n){let r=this.#r;if(r===null)return"exact";r.written=!0;let o=!1;if(r.state!=="pending"){let s=this.#e.nowFor(r);Eo(r,s,!0),r.rebase(s),o=t>r.anchorElapsed}r.anchorElapsed=t,r.seeks++;let i=this.#e.sought(r,n?.state!=="keep",o);return this.#e.changed(r),this.#e.taping()&&this.#e.record(this,"seek",s=>s.seek(t,n)),i}fade(t){let n=this.#r;n!==null&&(n.written=!0,this.#e.fade(n,t),this.#e.taping()&&this.#e.record(this,"fade",r=>r.fade(t)))}rise(t){let n=this.#r;n!==null&&(n.written=!0,this.#e.rise(n,t),this.#e.taping()&&this.#e.record(this,"rise",r=>r.rise(t)))}release(){let t=this.#r;t!==null&&(t.written=!0,this.#e.release(t),this.#e.taping()&&this.#e.record(this,"release",n=>n.release()))}weightOf(t){let n=this.#t;return n===null?0:this.#e.weightOf(n,t)}to(t,n,r){let o=this.#t;o!==null&&IP(o.patch,"to","a spring or a tween").to(t,n,r)}push(t,n,r){let o=this.#t;o!==null&&IP(o.patch,"push","a spring or a glide").push(t,n,r)}set(t,n,r){let o=this.#t;o!==null&&IP(o.patch,"set","a motion patch").set(t,n,r)}read(t,n){let r=this.#t;if(!(r===null||On(r.patch)===void 0))return r.patch.read(t,n)}};function IP(e,t,n){if(On(e)===void 0||typeof e[t]!="function")throw new Error(`blits: ${t} needs a voice playing ${n}`);return e}var L$=new WeakSet,lF=e=>L$.has(e);function Qu(e,t,n){let r=n===0?0:Math.abs(e*n-t);return r>=1?0:1-r}var Wh={transport:e=>e,mix:e=>e},Zu=Wh,Vh;function Sa(e){throw new Error(`blits: the tape holds ${e}, which a read ahead cannot play; seek there to see it`)}var uF={apply(){},invert:()=>uF};function cF(e){let t=e.history?.tape;if(t!==void 0)return t(e,{now:()=>Number.isNaN(e.u)?Number.NEGATIVE_INFINITY:e.u,branching:!0,coalesceWindowMs:0})}function Vr(e){return e.tape!==void 0&&!e.replaying&&!e.projecting}function Ct(e,t,n){let r=e.tape;if(r===void 0||!Vr(e))return;let o={label:t,apply(){if(Zu===Wh)n(Zu);else try{n(Zu)}catch(i){Vh??={error:i}}},invert:()=>uF};r.recordEntry([o],t)}function Hi(e,t){return e.pace===null?t:e.pace.timeOf(t)}function Wr(e,t){let n=Hi(e,t);return e.u>n?e.u:n}function ka(e,t,n=e,r=Wh){let o=e.tape;if(o===void 0)return Number.NaN;let i=n.u,s=Number.NaN;try{for(;;){let a=o.timestampAt(o.undoDepth());if(a===void 0||!t(a))return s;if(a!==s){s=a,n.u=a;let l=n.pace===null?a:n.pace.reading(a);if(l>n.now)for(let u of n.members)zr(u,l);n.tick(n.now)}e.replaying=!0,Zu=r;try{o.redo()}finally{e.replaying=!1,Zu=Wh}if(Vh!==void 0){let{error:l}=Vh;throw Vh=void 0,l}}}finally{n.u=i}}function dF(e,t,n){let r=e.strays.get(n);r===void 0?e.strays.set(n,[t]):r.includes(t)||r.push(t)}function fF(e,t){let n=t.motion;if(n===void 0)return;let r=(e.playing.get(n)??1)-1;if(r<=0){e.playing.delete(n),e.strayAll.delete(n);return}if(e.playing.set(n,r),t.named===null)e.strayAll.add(n);else for(let o of t.named.list)dF(e,n,o)}function pF(e){return{frame(t,n){let r=e.deref(),o=r===void 0?void 0:_o(r,t);return r===void 0||o===void 0?Number.NaN:hF(r,o,n)},now(){return e.deref()?.now??Number.NaN},seq(){return e.deref()?.transport.seq??Number.NaN},early(){let t=e.deref();return t!==void 0&&(t.syncing||!t.looked)},changed(t,n,r,o){let i=e.deref();i!==void 0&&Vr(i)&&_$(i,t,n,r,o)},page(t,n,r,o){let i=e.deref(),s=i?.opts.history?.ms;i===void 0||i.keys===null||s===void 0||er(i,n,t,i.keys.key(r),o,a=>a.data,i.now-s)},revive(t,n){let r=e.deref();if(r===void 0)return Number.NaN;r.stir();let o=_o(r,t);return o===void 0||(o.motion!==void 0&&o.named!==null&&!o.named.has(n)&&dF(r,o.motion,n),o.parted?.has(n)!==!0)?Number.NaN:(OP(r,o,n),CP(r,o,qu(o,n)))}}}function _$(e,t,n,r,o){Ct(e,"motion",i=>{let s=i.mix(e);if(s===void 0)return;if(s!==e)return D$(s,t,n,r,o);((_o(e,t)??e.gone.find(l=>l.id===t))?.motion??n).change(r,{...o})})}function D$(e,t,n,r,o){let i=r,s=_o(e,t),a=o.at;if(s!==void 0){let p=s.parted?.has(i)===!0;if(p&&OP(e,s,i),a===void 0){let h=hF(e,s,i),m=p?CP(e,s,qu(s,i)):h;Number.isNaN(h)?Number.isNaN(m)||(a=m):a=h}}a===void 0&&Sa("a change to a motion made before its voice met the subject");let l=a,u=e.transport.ahead,c=u.get(n);c===void 0&&(c=new Map,u.set(n,c));let d=c.get(i),f={at:a,to:o.to,x:o.x,v:o.v};if(d===void 0)c.set(i,[f]);else{let p=d.length;for(;p>0&&d[p-1].at>l;)p--;d.splice(p,0,f)}}function _o(e,t){let n=e.cued,r=0,o=n.length-1;for(;r<=o;){let i=r+o>>1,s=n[i];if(s.id===t)return s;s.id<t?r=i+1:o=i-1}}function hF(e,t,n){let r=t.subjects.get(n);return r===void 0||!r.reaches?Number.NaN:CP(e,t,r.delay)}function CP(e,t,n){if(Number.isNaN(e.now)||t.state==="pending")return Number.NaN;let r=t.elapsedAt(e.now)-n;return r<0?Number.NaN:r}function gF(e,t){if(e.projecting)throw new Error("blits: a projection books nothing");let n={get voices(){return e.cued},get timestamp(){return e.last},get now(){return e.now},hostOf:o=>NP(e,o),readingAt:o=>XO(e,o-e.offset),endOf:o=>Xe(e,o,"end"),marks:(o,i)=>Hh(e,o,i),unhook:o=>{let i=(e.bookers??[]).filter(s=>s!==o);e.bookers=i.length===0?null:i}},r=new Bh(n,t);return e.bookers=[...e.bookers??[],r],r}function zh(e){return{get voices(){return e.cued},channels:e.channels,names:e.names,clock:e,fits:t=>B$(e,t),meet:(t,n,r,o)=>{for(let i=r;i!==null;i=i.next)if(i.voice===t)return i;return e.held(t,n,o)},forgot:t=>{e.places?.forgot(t);for(let n of e.general)Hr(n,t,!1),n.sighted!==null&&e.share?.unsight(n,t);for(let n of Fo(e).general)Hr(n,t,!1)},passes:(t,n)=>e.passes(t,n),naming:t=>e.naming===0?void 0:e.named.get(t),slotOf:t=>ut(e,t)?.slot??-1,envelope:(t,n)=>t.owner===null?e.envelope(t,e.now,n):e.envelope(t,e.now,n)*e.ownedBy(t,void 0),parting:(t,n)=>e.parting(t,n,e.now),ready:(t,n,r)=>{let o=e.lanes.arg;e.primeLaned(t,r,o),t.setting.weight=o[0],e.sending.voice=t,e.sending.subject=n},signal:(t,n,r,o)=>{let i=e.lanes.arg,s=t.blend===null?Number.NaN:e.laneRead(t,o);if(!Number.isNaN(s)){i[0]=s;return}e.primeLaned(t,r,i);let a=pe.kept,l=e.base(t,n,e.now,r,o);pe.kept!==a&&!t.keeping&&Gi(e,t),i[0]=l},horizon:(t,n)=>{t.motion!==void 0&&(pe.horizon=e.horizonFor(t,n,e.now))},keeps:e.opts.history!==void 0,after:(t,n,r)=>Kh(e,t,n,r),kept:t=>Gi(e,t)}}function Ui(e){return e.named!==null&&e.named.size===1&&e.spec.role===void 0&&(e.slots.length===1||e.motion===void 0)&&e.motion?.round!==!0}function B$(e,t){let n=t.spec,r=t.patch;if(t.keeping||(t.freezesBefore||t.state==="fading")&&t.unstarted(e.now)||t.beginless||t.out?.back===!0||t.owner!==null&&IO(t))return!1;let o=n.weight;if(typeof o=="function"&&o.input&&(e.opts.history?.inputs||!lF(o))||r.reads!==void 0&&r.reads.length>0||n.role!==void 0&&t.motion!==void 0||n.from==="current"||(t.motion!==void 0||n.role!==void 0||Ui(t))&&t.slots.some(s=>qn(e.channels[s])?.op==="last")||t.out?.rest||r.state!==void 0||r.step!==void 0)return!1;let i=t.built;return i===null||i.tracks.every((s,a)=>s.lerp===void 0||s.lerp===t.lerps[a])}var mF={exact:0,stepped:1,held:2};function yF(e,t,n){let r=t.patch;if(r.state===void 0&&r.step===void 0&&!t.keeping)return"exact";if(!n)return"held";let o=t.spec.weight;return r.reads!==void 0&&r.reads.length>0||typeof o=="function"&&o.input?"held":t.keeping?"stepped":r.step===void 0||vo(e,t)!==void 0&&e.opts.maxDt===void 0?"exact":"stepped"}function Gi(e,t){t.keeping||(t.keeping=!0,t.sharing&&e.share?.unshare(e,t,!0,e.sending.subject),e.lanes?.invalidate())}function ec(e,t){return e.handles??=H$(e),new Ur(t,e.handles)}function H$(e){return{nowFor:t=>{if(Number.isNaN(e.now))return t.start;let n=Ju(e,t);return Number.isFinite(n)?n:t.start},changed:t=>{e.frame=st(),cn(e,t,e.now),t.holding!==null&&_i(t,n=>cn(e,n,e.now)),Ke(e,t),e.lanes?.refill()},sought:(t,n,r)=>{r&&t.holding!==null&&!e.projecting&&(e.leapt??=new Set,e.leapt.add(t)),n&&t.rebuilds++;let o=yF(e,t,n);return t.holding!==null&&_i(t,i=>{i.seeks++,n&&i.rebuilds++;let s=yF(e,i,n);mF[s]>mF[o]&&(o=s),it(e,i)}),o},fade:(t,n)=>{if(t.holding!==null&&n!==void 0&&("subject"in n||n.at==="rest"))throw new Error("blits: an owner fades as a whole, not by subject or at rest");n!==void 0&&"subject"in n?bF(e,t,n.subject,n.over):typeof n?.at=="number"?wF(e,t,n.at,n.over):Kr(e,t,n??{})},rise:(t,n)=>xF(e,t,n??{}),release:t=>PF(e,t),weightOf:(t,n)=>{if(t.state==="done")return 0;if(t.holding!==null)return hP(t,e.now,e.reducedNow,i=>e.ownerBase(i,n));let r=e.lanes===null?-1:ut(e,n)?.slot??-1;if(t.laned&&e.lanes!==null){let i=e.lanes.weightOf(t.id,r);if(i!==void 0)return i}let o=t.sharing?void 0:t.subjects.get(n);return o!==void 0?o.weight:e.share===null?0:e.share.weightAt(t,r)},taping:()=>Vr(e),record:(t,n,r)=>Ct(e,n,o=>{let i=o.mix(e);if(i===e)r(t);else if(i!==void 0){let s=_o(i,t.id);s!==void 0&&r(ec(i,s))}})}}function tc(e,t){return{by:e,stops:t,members:[],frame:0,subject:void 0,value:0,reads:new me,frames:new Float64Array(0),values:new Float64Array(0)}}function va(e){let t=new Map;for(let n of e){if(n.blend===null)continue;let r=t.get(n.blend.of);r===void 0&&(r=tc(n.blend.of.by,n.blend.of.stops),t.set(n.blend.of,r)),n.blend={of:r,i:n.blend.i},r.members.push(n)}}function TF(e,t,n,r){let{of:o,i}=e.blend,s=this.frame,a;if(r<0){if(o.frame===s&&o.subject===t)return Qu(o.value,i,o.stops);if(a=o.reads.get(t),a?.frame===s)return Qu(a.value,i,o.stops)}else if(r>=o.frames.length){let c=Math.max(r+1,o.frames.length*2,64),d=new Float64Array(c),f=new Float64Array(c);d.set(o.frames),f.set(o.values),o.frames=d,o.values=f}let l=pe.kept,u=o.by(t,e.setting);return pe.kept!==l&&!this.projecting&&this.shareKept(o,e,t,n),r<0?(o.frame=s,o.subject=t,o.value=u,a===void 0?o.reads.set(t,{frame:s,value:u}):(a.frame=s,a.value=u)):(o.frames[r]=s,o.values[r]=u),Qu(u,i,o.stops)}function SF(e,t){let{of:n,i:r}=e.blend;return t<n.frames.length&&n.frames[t]===this.frame?Qu(n.values[t],r,n.stops):Number.NaN}function kF(e,t,n,r){for(let o of e.members){let i=o===t?void 0:o.subjects.get(n);i?.reaches&&i.kept===null&&(i.kept=r.kept),Gi(this,o)}}var vF=new WeakMap,AF=e=>typeof e=="function"?vF.get(e):void 0;function RF(e,t={}){if(typeof e!="object"||e===null)throw new TypeError("blits: around takes a circle, { x, y, r }");let n=No(t.ease??"linear"),r=o=>{let i=this.places;if(i===null)return 0;let s=i.cur>=0?i.cur:i.at.get(o)??-1,a=i.xy;if(s<0||2*s+1>=a.length)return 0;let l=e.r,u=a[2*s]-e.x,c=a[2*s+1]-e.y,d=u*u+c*c;return!(l>0)||!(d<=l*l)?0:n(1-Math.sqrt(d)/l)};return vF.set(r,e),r}var G$=pa;function U$(e,t){let n=new Uint8Array(t);return e.bands=n,n}function rc(e,t){return typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<1e-9:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,r)=>rc(n,t[r])):e===t}function nc(e,t,n){let r=e.merge(t,n);if(r!==n||!Array.isArray(r))return r;if(!Array.isArray(t)||t.length!==r.length)return[...r];for(let o=0;o<r.length;o++)t[o]=r[o];return t}function St(e){e?.bands&&e.bands.fill(2)}function NF(e,t){let{on:n,off:r}=this.band;return t>=n?!0:t<=r?!1:e??t>=n}function IF(e,t,n,r,o){let i=t.slots;for(let s=0;s<i.length;s++){let a=i[s],l=this.names[a],u=r[l];if(u===void 0)continue;let c=this.scalars[a];if(c!==void 0&&typeof u=="number"){e[l]=Oe(c,e[l],u,o);continue}let d=this.channels[a];if(d.rest!==void 0&&d.scale){e[l]=d.fold?d.fold(e[l],u,o):nc(d,e[l],d.scale(u,o));continue}let f=n.bands??U$(n,i.length),p=f[s],h=this.passes(p===0?void 0:p===1,o);f[s]=h?1:2,h&&(e[l]=e[l]===void 0?Ci(u):nc(d,e[l],u))}}function EF(e){for(let t of this.bounded){let n=this.names[t];e[n]=V$(this.channels[t],e[n])}return e}function V$(e,t){let[n,r]=e.bounds;if(typeof t=="number")return t<n?n:t>r?r:t;if(Array.isArray(t))for(let o=0;o<t.length;o++){let i=t[o];t[o]=i<n?n:i>r?r:i}return t}function MF(e,t,n,r){if(e.sharing){if(t<0)return r;let s=this.lanes;return this.share.weighAt(e,t,n.weight,s.cap),this.share.shut(e,n,t,s.cap),r}let o=this.sharers,i=0;for(;i<o.length&&o[i].id<e.id;)i++;return i}function CF(e,t,n=!1,r){let o=this.folded(e,t,n,r);return this.bounded.length===0?o:this.clamp(o)}function OF(e,t,n=!1,r){let o=this.linked(e);return this.foldWith(e,t??this.pose(),o,this.linkedLaned,n,r)}function FF(e){let t=Number.isNaN(this.now)?null:this.chain(e),n=this.lanes;return t!==null&&n!==null&&n.laned.length===0&&n.frameAt===this.now&&n.qualifiedVersion===this.version&&n.touched.length===0&&!n.filling?(t.slot>=0&&(n.per[t.slot*6+4]=++n.probes),this.linkedLaned=!1,t):(this.linkedLaned=t!==null&&n?.prepare(t.slot,e,this.version,t)===!0,t)}function LF(e,t,n,r,o,i){let s=t,a=this.lanes,l=r?a.copies:null;for(let c=0;c<this.names.length;c++){if(l?.[c])continue;let d=this.channels[c],f=d.rest,p=this.names[c];if(f===void 0){s[p]!==void 0&&(s[p]=void 0);continue}let h=this.lerpsInto[c]===void 0?void 0:s[p];if(Array.isArray(h)&&h!==f&&h.length===f.length)for(let m=0;m<h.length;m++)h[m]=f[m];else s[p]=d.copy?d.copy(f):G$(f)}if(n===null)return s;let u=-1;if(r){let c=a;if(c.copy(n.slot,s),c.owes(n.slot))u=n.slot;else if(c.whole)return s}if(this.detours===0){let c=this.now;for(let d=n;d!==null;d=d.next){let f=d.voice;if(f===null||r&&f.laned&&!this.owedBy(u,f)||f.id===i||f.state==="done")continue;let p=this.read(f,e,c,o,d);u>=0&&f.laned&&a.paid(f.id,u,d.weight),d.weight>0||St(d),!(p===null||this.w<=0)&&this.apply(s,f,d,p,this.w)}return s}return this.foldDetour(e,s,n,r,o,i,u)}function _F(e,t,n,r,o,i,s){let a=n.version===this.version?n:this.chain(e);if(this.roleVoices!==0)return this.foldRoles(e,t,a,r,o,i,s);let l=this.now,u=this.lanes,c=this.sharers,d=0;for(let f=a;f!==null;f=f.next){let p=f.voice;if(p===null||(d<c.length&&c[d].id<p.id&&(d=this.foldSharers(t,e,a,d,p.id,r,o,i,s)),r&&p.laned&&!this.owedBy(s,p))||p.id===i||p.state==="done")continue;let h=this.read(p,e,l,o,f);s>=0&&p.laned&&u.paid(p.id,s,f.weight),f.weight>0||St(f),!(h===null||this.w<=0)&&this.apply(t,p,f,h,this.w)}return d<c.length&&this.foldSharers(t,e,a,d,Number.MAX_SAFE_INTEGER,r,o,i,s),t}function DF(e,t,n,r,o,i,s,a,l){let u=this.sharers,c=this.now;for(;r<u.length;){let d=u[r];if(d.id>=o)break;r++;let f=d.state==="pending"?null:d.everyone;if(f===null||i&&d.laned&&!this.owedBy(l,d)||d.id===a||d.state==="done")continue;this.share.open(d,f,n.slot);let p=this.read(d,t,c,s,f);l>=0&&d.laned&&this.lanes.paid(d.id,l,f.weight),r=this.shared(d,n.slot,f,r),!(p===null||this.w<=0)&&this.apply(e,d,f,p,this.w)}return r}function BF(e,t){return e>=0&&this.lanes.owesVoice(e,t.id)}var jh=5,$h=new Map,HF=new WeakMap,GF=0,W$=0;function z$(e){if(e===void 0)return 0;let t=HF.get(e);return t===void 0&&(t=++W$,HF.set(e,t)),t}var FP=e=>Object.is(e,-0)?"-0":String(e);function K$(e){let t=FP(e.duration);for(let r of e.tracks){if(r===void 0)return++GF;t+=`|${FP(r.delay)}`;for(let o of r.all)t+=`,${FP(o.at)}:${z$(o.ease)}`}let n=$h.get(t);return n===void 0&&($h.size>=4096&&$h.clear(),n=++GF,$h.set(t,n)),n}var Aa=class{data=new Float64Array(64);used=0;eases=[];lastTiming=-1;lastPhase=Number.NaN;found=new Int32Array(4);easedAt=new Float64Array(4);add(t,n){let r=jh,o=0;for(let l=0;l<t.tracks.length;l++){let u=t.tracks[l],c=n[l];if(u===void 0||c===void 0||!c.plain||!c.straight)return-1;for(let d of u.all)if(!j$(d.value,c))return-1;r+=2+u.all.length*(1+c.axes),o+=u.all.length}let i=this.reserve(r),s=this.data;s[i]=r,s[i+1]=this.eases.length,s[i+2]=t.duration,s[i+3]=o,s[i+4]=K$(t);let a=i+jh;for(let l=0;l<t.tracks.length;l++){let u=t.tracks[l],c=n[l];s[a++]=u.all.length,s[a++]=u.delay;for(let d of u.all){if(s[a++]=d.at,c.scalar)s[a++]=d.value;else{let f=d.value;for(let p=0;p<c.axes;p++)s[a++]=f[p]??c.rest}this.eases.push(d.ease)}}return i}copy(t,n){let r=t.data[n],o=this.reserve(r);this.data.set(t.data.subarray(n,n+r),o);let i=t.data[n+1],s=t.data[n+3];this.data[o+1]=this.eases.length;for(let a=0;a<s;a++)this.eases.push(t.eases[i+a]);return o}fold(t,n,r,o,i){let s=this.data;(s[t+4]!==this.lastTiming||n!==this.lastPhase||n===0)&&this.search(t,n,r);let l=this.found,u=this.easedAt,c=t+jh,d=t+s[t];for(let f=0;c<d;f++){let p=r[f],h=p.axes,m=1+h,g=s[c],b=c+2;c=b+g*m;let x=l[f];if(x===-2)continue;let w=p.values,y=o*h;if(x===-1||x===g){let A=b+(x===-1?0:g-1)*m+1;for(let N=0;N<h;N++)w[y+N]=Oe(p.op,w[y+N],s[A+N],i);continue}let P=b+x*m,S=P-m,v=u[f];for(let A=0;A<h;A++){let N=Mt(s[S+1+A],s[P+1+A],v);w[y+A]=Oe(p.op,w[y+A],N,i)}}}search(t,n,r){let o=this.data;this.lastTiming=-1;let i=o[t+2],s=o[t+1],a=t+jh,l=t+o[t];for(let u=0;a<l;u++){u>=this.found.length&&this.grow(u+1);let c=1+r[u].axes,d=o[a],f=bP(o[a+1],n,i),p=a+2;a=p+d*c;let h=xP(o,p,c,d,f);if(this.found[u]=h,h>=0&&h<d){let m=p+h*c,g=wP(f,o[m-c],o[m]),b=this.eases[s+h];this.easedAt[u]=b?b(g):g}s+=d}this.lastTiming=o[t+4],this.lastPhase=n}grow(t){let n=new Int32Array(t*2);n.set(this.found),this.found=n;let r=new Float64Array(t*2);r.set(this.easedAt),this.easedAt=r}reserve(t){let n=this.used;if(n+t>this.data.length){let r=new Float64Array(Math.max(n+t,this.data.length*2));r.set(this.data.subarray(0,n)),this.data=r}return this.used=n+t,n}};function j$(e,t){if(t.scalar)return typeof e=="number";if(!(Array.isArray(e)||ArrayBuffer.isView(e)))return!1;let n=e;for(let r=0;r<t.axes;r++){let o=n[r];if(o!==void 0&&typeof o!="number")return!1}return!0}function UF(e,t,n){let r=t.voice,o=t.data,i=e.per,s=t.list,a=t.records,l=t.chans[0],u=e.fills,c=e.frameProbes,d=e.lately,f=r.seeks,p=r.elapsedAt(e.now),h=t.flat,m=r.parts!==null,g=typeof r.spec.weight=="function",b=e.probes!==c,x=Fr(r.weight),w=e.arg,y=n.n,P=l.op;if(y>0&&(t.axes!==y&&(t.axes=y,t.samples=new Float64Array(0)),s.length*y>t.samples.length)){let D=new Float64Array(Math.max(s.length,t.samples.length/y*2,4)*y);D.set(t.samples),t.samples=D}let S=t.samples,v=n.xs,A=n.round?void 0:n.ease;n.watcher===null&&(n.watcher=e,n.watchId=r.id);let N=A!==void 0&&!g&&n.watcher===e&&n.watchId===r.id,M=y===l.axes&&l.plain,C=Number.NaN,F=Number.NaN,B=0;for(let D=0;D<s.length;D++){if(g&&r.keeping)return;let j=s[D],V=D*8,J=j*6;if(Ot(o,V,i,J,u),d>=0&&e.unread(j)){Ra(t,D);continue}let se=o[V+0],ke=p-se;if(!(ke>=0)){Ra(t,D),o[V+2]=0;continue}if(!h){let Q=o[V+1];(!t.weighed||!Wt(Q,t.weighedSince))&&(t.fade=e.host.envelope(r,Q),t.weighed=!0,t.weighedSince=Q)}let ae;if(g){if(w[1]=ke,w[3]=Jn(ke,r.duration,r.passes),w[5]=t.fade,!e.signalled(r,j,a[D])){o[V+2]=0;continue}ae=w[0]}else if(m)ae=zt(r.weight,t.fade,e.parting(r,j));else if(h)ae=x;else{let Q=t.fade,te=r.weight;(Q!==C||te!==F||Q===0||te===0)&&(C=Q,F=te,B=zt(te,Q,1)),ae=B}if(o[V+2]=ae,o[V+7]===0){if(Number.isNaN(a[D].probed)){Ra(t,D),e.late.push(j);continue}o[V+7]=1}let ve=o[V+4],G=-1,K=!1;if(ve>=0){G=5+ve*n.stride;let Q=n.runs[G+1];(Q&6)!==0&&(G=-1),K=(Q&1)!==0}if(G<0||b&&(i[J+3]>c||i[J+4]>c)){w[1]=ke,w[4]=se,w[0]=ae,oc(e,t,n,D,j,a[D]);continue}let $=n.runs;if(N&&M&&K===l.scalar){if(o[V+5]!==-2&&(o[V+5]=-2,t.deltas[D]=null),ae<=0)continue;let Q=Ao(A,Lr(ke,$[G],$[G+2])),te=l.values,he=j*y,be=G+3,Fe=be+2*y;for(let Se=0;Se<y;Se++)te[he+Se]=Oe(P,te[he+Se],Ro($[be+Se],$[Fe+Se],Q),ae);continue}if(A!==void 0){let Q=Ao(A,Lr(ke,$[G],$[G+2])),te=G+3,he=te+2*y;for(let be=0;be<y;be++)v[be]=Ro($[te+be],$[he+be],Q)}else n.sampleBare(ve,ke,v,n.vs);for(let Q=0;Q<y;Q++)S[D*y+Q]=v[Q];if(t.deltas[D]!==null&&(t.deltas[D]=null),o[V+5]=u,o[V+6]=f,!(ae<=0))if(M&&K===l.scalar){let Q=l.values,te=j*y;for(let he=0;he<y;he++)Q[te+he]=Oe(P,Q[te+he],v[he],ae)}else w[0]=ae,e.foldInto(l,j,n.value(ve,v))}N&&(t.bareFill=u,t.bareElapsed=p,t.bareSeeks=f)}function oc(e,t,n,r,o,i){let s=e.arg[1],a=e.arg[4],l=e.arg[0],u=t.voiceAt(r),c=t.data,d=r*8,f=t.chans[0];if(ic(e,t,r,o,i),!(l>0))return;let p=i.delta;if(p===null||i.probed!==e.now||i.seeks!==u.seeks||!e.probedThisFrame(o)){let h=c[d+4];if(h<0){let g=e.subjectAt(o);if(g===tr)return;h=n.slot(g),c[d+4]=h,t.numbered(r,h)}if(e.keeps?e.host.horizon(u,a):pe.horizon=Number.POSITIVE_INFINITY,!n.quiet(h,s)){e.late.push(o);return}n.sample(h,s,n.xs,n.vs);let m=n.n;if(t.keep(r,n.xs,m),t.deltas[r]=null,c[d+5]=e.fills,c[d+6]=u.seeks,l<=0)return;m===f.axes&&n.scalar(h)===f.scalar?e.foldRun(f,o,n.xs):e.foldInto(f,o,n.value(h,n.xs));return}t.deltas[r]=p,c[d+5]=e.fills,c[d+6]=u.seeks,l>0&&e.foldInto(f,o,p[f.name])}function $$(e,t){let n=e.motionAt(t);e.kept(t,n.xs);let r=e.data[t*8+4],o={[e.chans[0].name]:n.value(r,n.xs)};return e.deltas[t]=o,o}function ic(e,t,n,r,o){t.fix(n);let i=n*8;o.probed===e.now&&o.seeks===t.data[i+6]||!(e.per[r*6+3]>e.frameProbes)||t.data[i+5]!==e.per[r*6+5]||(o.delta=t.deltas[n]??$$(t,n),o.probed=e.now,o.seeks=t.data[i+6])}var WF=new Float64Array(0);function LP(e){return(e&2043)===1211}var Yh=class{chans;axes;list=[];data=new Float64Array(0);hot=new Float64Array(0);stride;samples=new Float64Array(0);deltas=[];records=[];voices=[];motions=[];eases=[];laws=[];idle=!1;line=Jh.other;cursor=0;dead=0;stale=!1;staleRows=[];xs;vs;delta={};keys=new Aa;scratch=[];bareFill=-1;bareNow=Number.NaN;constructor(t,n){this.chans=t,this.axes=n,this.stride=11+3*n,this.xs=new Float64Array(n),this.vs=new Float64Array(n)}voiceAt(t){return this.voices[t]}fix(t){Xh(this,t)}numbered(){}restale(t,n){this.hot[t*this.stride+0]=(n|4)&-2049,this.stale=!0,this.staleRows.push(t)}odd=null;keep(t,n,r){if(r===this.axes){for(let o=0;o<r;o++)this.samples[t*r+o]=n[o];this.odd?.delete(t);return}this.odd??=new Map,this.odd.set(t,n.slice(0,r))}kept(t,n){let r=this.odd?.get(t);if(r!==void 0){n.set(r);return}let o=this.axes;for(let i=0;i<o;i++)n[i]=this.samples[t*o+i]}motionAt(t){return this.motions[t]}get size(){return this.list.length}reserve(t){if(t*8<=this.data.length)return;let n=Math.max(t,this.data.length/8*2,16),r=new Float64Array(n*8);r.set(this.data),this.data=r;let o=new Float64Array(n*this.stride);o.set(this.hot),this.hot=o;let i=new Float64Array(n*this.axes);i.set(this.samples),this.samples=i}};function _P(e,t){if(!e.overlap){for(let n of e.crowds)!n.idle&&n.cursor<n.size&&VF(e,n,t);return}for(;;){let n,r=t,o=t;for(let i of e.crowds){if(i.idle||i.cursor>=i.size)continue;let s=i.hot[i.cursor*i.stride+7];s<r?(o=r,r=s,n=i):s<o&&(o=s)}if(n===void 0)return;VF(e,n,o)}}function VF(e,t,n){let r=t.list,o=t.hot,i=t.cursor;for(;i=jF(e,t,i,n),!(i>=r.length||o[i*t.stride+7]>=n);)i=Y$(e,t,i,n);t.cursor=i}function Y$(e,t,n,r){let o=t.data,i=t.hot,s=t.stride,a=e.per,l=e.arg,u=t.list,c=t.chans[0],d=t.axes,f=e.fills,p=e.frameProbes,h=e.probes!==p,m=e.now,g=t.xs,b=t.vs,x=t.samples,w=n;for(;w<u.length;w++){let y=w*s;if(i[y+7]>=r)break;let P=i[y+0];if(w>n&&LP(P))break;if(o[w*8+5]===-2&&Xh(t,w),(P&64)!==0&&(P=q$(t,w)),(P&1)===0||(P&16)===0)continue;let S=u[w],v=w*8,A=S*6;if(Ot(o,v,a,A,f),e.lately>=0&&e.unread(S))continue;let N=o[v+0],M=(P&2)!==0,C=t.voices[w],B=(M?qh(i,y,m):C.elapsedAt(m))-N;if((P&256)!==0&&(B=B>=0?B>C.span?C.hidesPast?Number.NaN:C.freezesAfter?C.span:B:B:C.freezesBefore?0:Number.NaN),!(B>=0)){o[v+2]=0;continue}let D;if(M)D=i[y+4];else if(typeof C.spec.weight=="function"){let V=e.host.envelope(C,o[v+1]);if(l[1]=B,l[3]=Jn(B,C.duration,C.passes),l[5]=V,!e.signalled(C,S,t.records[w])){o[v+2]=0;continue}D=l[0]}else D=zt(C.weight,e.host.envelope(C,o[v+1]),e.parting(C,S));if(o[v+2]=D,(P&512)!==0){D>0&&t.keys.fold(i[y+9],Or(B,i[y+11],i[y+10]),t.chans,S,D);continue}if(l[1]=B,l[4]=N,l[0]=D,(P&128)===0){e.row(t,w,C,S);continue}if(o[v+7]===0){if(Number.isNaN(t.records[w].probed)){e.late.push(S);continue}o[v+7]=1}let j=o[v+4];if(j<0||(P&8)===0||h&&(a[A+3]>p||a[A+4]>p)){let V=t.motions[w];oc(e,t,V,w,S,t.records[w]),j<0&&t.restale(w,i[y+0]);continue}F2(t.laws[w],t.eases[w],d,i[y+9],i[y+10],i,y+11,i,y+11+d,i,y+11+2*d,B,g,b);for(let V=0;V<d;V++)x[w*d+V]=g[V];t.deltas[w]!==null&&(t.deltas[w]=null),o[v+5]=f,o[v+6]=i[y+5],!(D<=0)&&((P&32)!==0?e.foldRun(c,S,g):e.foldInto(c,S,t.motions[w].value(j,g)))}return w}function zF(e,t,n,r){let o=this.arg,i=o[1],s=n.duration;if(o[2]=Or(i,s,n.passes),n.built!==null){o[0]>0&&this.foldKeys(n,e.chans,r);return}let a=e.records[t];if(Number.isNaN(a.probed)){this.late.push(r);return}o[3]=Jn(i,s,n.passes),this.call(n,e.chans,a,r)}function q$(e,t){let n=e.voices[t],r=t*e.stride,o=e.hot[r+0]&-324;return(n.state==="live"||n.state==="frozen"||n.state==="fading")&&(o|=1),(n.freezesBefore||n.freezesAfter||n.motion===void 0&&(n.owner!==null||n.hidesPast))&&(o|=256),n.ramp===null&&n.owner===null&&!((n.fade.in??0)>0)&&n.out===null&&n.back===null&&n.parts===null&&!n.keeping&&typeof n.spec.weight!="function"&&(o|=2),e.hot[r+1]=n.anchorNow,e.hot[r+2]=n.anchorElapsed,e.hot[r+3]=n.rate,e.hot[r+4]=Fr(n.weight),e.hot[r+5]=n.seeks,e.hot[r+0]=o,o}function KF(e){e.stale=!1;let t=e.hot,n=e.stride,r=e.staleRows;e.staleRows=[];for(let o=0;o<r.length;o++){let i=r[o];if(i>=e.list.length)continue;let s=t[i*n+0];if((s&4)===0||(s&128)===0)continue;let a=e.data[i*8+4];a>=0&&X$(e,i,a)}}function X$(e,t,n){Xh(e,t);let r=e.motions[t],o=t*e.stride,i=e.hot[o+0]&-45,s=e.chans[0];return r.n===e.axes&&r.stretchInto(n,e.hot,o+9)&&(i|=8,r.scalar(n)===s.scalar&&s.plain&&(i|=32)),e.hot[o+0]=i,i}function qh(e,t,n){return e[t+2]+(n-e[t+1])*e[t+3]}function jF(e,t,n,r){let o=t.data,i=t.hot,s=t.stride,a=e.per,l=t.list,u=t.chans[0],c=t.axes,d=e.fills,f=e.frameProbes,p=e.probes!==f,h=e.lately,m=e.now,g=u.op,b=r!==Number.POSITIVE_INFINITY;for(;n<l.length;n++){let x=n*s,w=i[x+0];if(b&&i[x+7]>=r||!LP(w))break;let y=n*8,P=(w&2048)!==0;if(!P&&(o[y+4]<0||o[y+7]===0))break;let S=l[n],v=S*6;if(p&&(a[v+3]>f||a[v+4]>f)||h>=0&&!(a[v+3]>h||a[v+4]>h))break;let A=P&&m>=i[x+8],N=0;if(!A&&(N=qh(i,x,m)-o[y+0],!(N>=0)))break;Ot(o,y,a,v,d);let M=i[x+4];if(o[y+2]=M,P||(o[y+5]!==-2&&(o[y+5]=-2,t.deltas[n]=null),i[x+0]=w|2048,i[x+8]=Number.POSITIVE_INFINITY),M<=0)continue;let C=u.values,F=S*c,B=x+11,D=B+2*c;if(A){for(let J=0;J<c;J++)C[F+J]=Oe(g,C[F+J],i[D+J],M);continue}let j=Lr(N,i[x+9],i[x+10]),V=Ao(t.eases[n],j);j>=1&&i[x+3]>0&&(i[x+8]=m);for(let J=0;J<c;J++)C[F+J]=Oe(g,C[F+J],Ro(i[B+J],i[D+J],V),M)}return n}function Xh(e,t){let n=t*8,r=e.data;if(r[n+5]!==-2)return;let o=e.hot,i=t*e.stride;o[i+0]=o[i+0]&-2049;let s=e.axes,a=qh(o,i,e.bareNow)-r[n+0],l=Ao(e.eases[t],Lr(a,o[i+9],o[i+10])),u=i+11,c=u+2*s;for(let d=0;d<s;d++)e.samples[t*s+d]=Ro(o[u+d],o[c+d],l);r[n+5]=e.bareFill,r[n+6]=o[i+5]}function Ra(e,t){let n=t*8,r=e.data;if(r[n+5]!==-2)return;let o=e.motion,i=o.runs,s=o.n,a=o.base(r[n+4]),l=e.bareElapsed-r[n+0],u=Ao(o.ease,Lr(l,i[a],i[a+2])),c=a+3,d=c+2*s;for(let f=0;f<s;f++)e.samples[t*s+f]=Ro(i[c+f],i[d+f],u);r[n+5]=e.bareFill,r[n+6]=e.bareSeeks}function Ot(e,t,n,r,o){let i=e[t+2];(i!==e[t+3]||i===0)&&n[r+5]===o-1&&(e[t+3]=i)}var Jh={keys:{stop:.15,start:.25},other:{stop:.6,start:.8}},sc=class{voice;list=[];at=new Int32Array(0);idle=!1;line;epoch=0;made=0;data=new Float64Array(0);records=[];deltas=[];samples=new Float64Array(0);axes=0;delta={};scratch=[];chans=[];values=[];nums=new Float64Array(0);kinds=new Uint8Array(0);placed=!1;placedAt=0;phase=0;pass=0;read=!1;readAt=0;weighed=!1;weighedSince=0;fade=1;flat=!1;ran=-1;elapsedNow=0;motion;byMotion=new Int32Array(0);bareFill=-1;bareElapsed=Number.NaN;bareSeeks=Number.NaN;group=null;mark=Number.NaN;every=!1;voiceAt(){return this.voice}fix(t){Ra(this,t)}numbered(t,n){if(n>=this.byMotion.length){let r=new Int32Array(Math.max(n+1,this.byMotion.length*2,64));r.set(this.byMotion),this.byMotion=r}this.byMotion[n]=t+1}positionOfMotion(t){return t<this.byMotion.length?this.byMotion[t]-1:-1}keep(t,n,r){if(this.axes!==r&&(this.axes=r,this.samples=new Float64Array(0)),(t+1)*r>this.samples.length){let o=new Float64Array(Math.max(t+1,this.samples.length/r*2,4)*r);o.set(this.samples),this.samples=o}for(let o=0;o<r;o++)this.samples[t*r+o]=n[o]}kept(t,n){let r=this.axes;for(let o=0;o<r;o++)n[o]=this.samples[t*r+o]}motionAt(){return this.motion}constructor(t){this.voice=t,this.motion=On(t.patch),this.line=t.built!==null?Jh.keys:Jh.other}positionOf(t){return t<this.at.length?this.at[t]-1:-1}reserve(t,n){if(t*8>this.data.length){let r=new Float64Array(t*8);r.set(this.data),this.data=r}if(n>this.at.length){let r=new Int32Array(n);r.set(this.at),this.at=r}}add(t,n){let r=this.list.length;if(this.list.push(t),t>=this.at.length){let i=new Int32Array(Math.max(t+1,this.at.length*2,64));i.set(this.at),this.at=i}if(this.at[t]=r+1,(r+1)*8>this.data.length){let i=new Float64Array(Math.max(r+1,this.data.length/8*2,4)*8);i.set(this.data),this.data=i}let o=r*8;this.data[o+0]=n.delay,this.data[o+1]=n.shown,this.data[o+2]=0,this.data[o+3]=0,this.data[o+4]=-1,this.data[o+5]=-1,this.data[o+7]=0,this.records[r]=n,this.deltas[r]=null}renumber(t,n){let r=this.positionOf(t);if(!(r<0)){if(n>=this.at.length){let o=new Int32Array(Math.max(n+1,this.at.length*2,64));o.set(this.at),this.at=o}this.list[r]=n,this.at[n]=r+1,this.at[t]=0}}remove(t){let n=this.positionOf(t);if(n<0)return;let r=this.list.length-1,o=this.data[n*8+4];if(o>=0&&(this.byMotion[o]=0),n!==r){let i=this.data[r*8+4];i>=0&&(this.byMotion[i]=n+1);let s=this.list[r];this.list[n]=s,this.at[s]=n+1,this.data.copyWithin(n*8,r*8,(r+1)*8),this.records[n]=this.records[r],this.deltas[n]=this.deltas[r]??null;let a=this.axes;a>0&&this.samples.copyWithin(n*a,r*a,(r+1)*a)}this.list.pop(),this.at[t]=0,this.records[r]=void 0,this.deltas[r]=null}};var em=8,Qh=4,DP=class{mix;voice;area;finder;hitAt=new Float64Array(0);marks=0;markedIn=Number.NaN;missed=new Int32Array(Qh);vets;frame=Number.NaN;x=0;y=0;r=0;r2=0;lit=[];spare=[];inAt=new Float64Array(0);litAt=new Float64Array(0);checks;frames=0;checkedAt=-1;constructor(t,n,r){this.mix=t,this.voice=n,this.area=r,this.finder=J$(r)?r:null,this.checks=!zu(),this.vets=this.checks&&this.finder!==null}},J$=e=>typeof e.find=="function";function $F(e,t){let n=t.within;if(n!==void 0){if(typeof n!="object"||n===null)throw new TypeError("blits: within takes a circle, { x, y, r }, or a finder, { find(out) }");if(e.places===null)throw new Error("blits: within needs indices: call mix.place or mix.plot first");if(typeof t.weight!="function")throw new Error("blits: within needs a signal weight; for a hard-edged disk use weight: mix.around(circle, { steps: 1, jump: 'start' })")}}function tm(e,t){let n=t.spec,r=AF(n.weight),o=n.within??(r!==void 0&&e.places!==null?r:void 0);o!==void 0&&(t.bound=new DP(e,t,o),o===r&&(t.bound.checks=!1))}function YF(e,t){if(e.frame!==t.frame&&(e.frame=t.frame,e.checks&&e.frames++,e.finder===null)){let n=e.area;if(e.x=n.x,e.y=n.y,e.r=n.r,e.r2=n.r*n.r,e.checks&&e.frames%em===0){let r=t.places;qF(e,r.found,r.ring(e.x,e.y,e.r))}}}function BP(e){let t=e.mix.places;YF(e,e.mix);let n=e.finder;if(n===null)return t.query(e.x,e.y,e.r,e.r2);t.found.length<t.n&&(t.found=new Int32Array(Math.max(t.n,t.found.length*2)));let r=t.found,o=n.find(r);if(!(Number.isInteger(o)&&o>=0&&o<=r.length))throw new RangeError(`blits: within's find returned ${o}, not a count of the indices it wrote, 0 to ${r.length}`);return t.count=o,e.vets&&Q$(e,r,o,t.n),e.checks&&e.frames%em===0&&e.checkedAt!==e.frames&&(e.checkedAt=e.frames,qF(e,e.missed,Z$(e,t,o))),o}function Q$(e,t,n,r){for(let o=0;o<n;o++){let i=t[o];if(i>=0&&i<r)continue;e.vets=!1;let s=e.voice;Qn(s,`${s.spec.name??`voice ${s.id}`}'s within finder found index ${i}, which place never handed out: it is skipped`);return}}function qF(e,t,n){if(n===0)return;let r=e.mix.places,o=e.voice,i=o.spec.weight,s=e.mix.now,a={timestamp:s,dt:0,elapsed:o.elapsedAt(s),pass:o.setting.pass,weight:0,state:void 0,host:o.setting.host,keep:(f,p)=>p(),send:()=>{}},l=Math.max(1,Math.floor(n/Qh)),u=e.frames/em%l,c=t.slice(0,n),d=o.named;for(let f=u;f<n;f+=l){let p=r.subjectAt(c[f]);if(p===void 0||d!==null&&!d.has(p))continue;let h=i(p,a);if(h>0){e.checks=!1,Qn(o,e.finder===null?`${o.spec.name??`voice ${o.id}`}'s weight signal reads ${h} just outside its within circle (r ${e.r}), which cuts it off there: widen r to where the signal falls to 0`:`${o.spec.name??`voice ${o.id}`}'s weight signal reads ${h} for a subject its within finder did not find, which cuts it off there: find every subject the signal is above 0 for`);return}}}function Z$(e,t,n){let r=XF(e,t,n),o=t.n,i=e.hitAt,s=o===0?0:e.frames/em*Qh%o,a=0;for(let l=0;l<o&&a<Qh;l++){let u=(s+l)%o;i[u]!==r&&t.subjectAt(u)!==void 0&&(e.missed[a++]=u)}return a}function XF(e,t,n){e.markedIn=e.mix.frame,e.hitAt.length<t.n&&(e.hitAt=new Float64Array(Math.max(t.n,e.hitAt.length*2)));let r=++e.marks,o=t.found,i=e.hitAt;for(let s=0;s<n;s++){let a=o[s];a>=0&&a<i.length&&(i[a]=r)}return r}function e8(e){if(e.markedIn===e.mix.frame)return e.marks;let t=BP(e);return e.markedIn===e.mix.frame?e.marks:XF(e,e.mix.places,t)}function JF(e,t,n){let r=e.places;if(r===null)return!1;if(t.finder!==null){let o=r.at.get(n);if(o===void 0)return!1;let i=e8(t);return t.hitAt[o]===i}if(e.projecting){let o=t.area;return r.inside(n,o.x,o.y,o.r*o.r)}return YF(t,e),r.inside(n,t.x,t.y,t.r2)}function Zh(e,t,n){t>=e.litAt.length&&HP(e,t+1),e.litAt[t]!==n&&(e.litAt[t]=n,e.lit.push(t))}function HP(e,t){if(t<=e.inAt.length)return;let n=Math.max(t,e.inAt.length*2,64),r=new Float64Array(n);r.set(e.inAt),e.inAt=r;let o=new Float64Array(n);o.set(e.litAt),e.litAt=o}function QF(e,t,n){let r=n.mix.places,o=BP(n),i=e.fills;HP(n,e.cap);let s=n.lit;n.lit=n.spare,n.lit.length=0,n.spare=s;let a=t.voice,l=n.inAt,u=r.found,c=r.slots;for(let p=0;p<o;p++){let h=c[u[p]]??-1;if(h<0||l[h]===i)continue;l[h]=i;let m=t.positionOf(h);if(!(m<0)){Zh(n,h,i),r.cur=u[p];try{e.one(t,m,h)}finally{r.cur=-1}if(a.keeping)return}}let d=t.data,f=e.per;for(let p=0;p<s.length;p++){let h=s[p];if(l[h]===i||l[h]===-i)continue;l[h]=-i;let m=t.positionOf(h);if(m<0)continue;let g=m*8;Ot(d,g,f,h*6,i),d[g+2]!==0&&(d[g+2]=0,St(t.records[m])),d[g+3]!==0&&Zh(n,h,i)}}function GP(e,t){let n=t.mix.places,r=BP(t),o=e.fills;HP(t,e.cap);let i=t.inAt,s=n.found,a=n.slots;for(let l=0;l<r;l++){let u=a[s[l]]??-1;u>=0&&(i[u]=o)}}var UP=(e,t,n)=>e.inAt[t]===n;function VP(e,t,n,r){let o=t.data,i=n*8;Ot(o,i,e.per,r*6,e.fills),o[i+2]!==0&&(o[i+2]=0,St(t.records[n]))}function Do(e){e.detours=e.roleVoices+e.sharers.length+(e.unshared?1:0)}function WP(e,t,n){t.spec.role!==void 0&&(e.roleVoices+=n);let r=t.spec.earliest;(t.spec.anchor!==void 0||r!==void 0&&typeof r!="number")&&(e.anchored+=n)}function ZF(e,t){t.holding!==null&&(e.owners??=[],e.owners.push(t)),sP(e,t),WP(e,t,1),Do(e)}function eL(e,t){t.named!==null&&Z2(e,t),t.holding!==null&&e.owners!==null&&(e.owners=e.owners.filter(n=>n!==t)),WP(e,t,-1),Do(e)}function Bo(e){e.named=new me,e.naming=0,e.general=[],e.sharers=[],e.roleVoices=0,e.anchored=0;for(let t of e.cued)sP(e,t),WP(e,t,1);Do(e),e.steps.push(null,++e.version)}function rL(e,t){let n=zP(e,t),r=n.patch;if(KP(e,n),n.from==="current"&&r.form!=="keys")throw new Error("blits: from: 'current' needs a keys patch");if(n.subjects!==void 0&&n.target!==void 0)throw new Error("blits: a voice takes target or subjects, not both");let o=n.anchor,i=n.owner===void 0?null:s8(e,n.owner);o&&sF(e,n,o,i),n.hits!==void 0&&jO(n.hits,r.duration),n.marks!==void 0&&qO(n.marks,r.duration),$F(e,n);let s=o!==void 0&&(o.start!==void 0||o.in!==void 0),a=i===null?e.now:Te(i,e.now),l=s||i?.fitting?Number.POSITIVE_INFINITY:i!==null?n.start??(a>0?a:0):n.start!==void 0?Bi(e,n.start-e.offset):Number.isNaN(e.now)?0:e.asleep?Number.POSITIVE_INFINITY:e.now,u=new Na(e.nextId++,n,r,n.fade??t8,a,l,e.slotOf,e.channels,e.opts.host,e.send,i);u.offset=e.offset,r===Li&&e.fitting!==null&&(u.fitting=e.fitting),r===Li&&e.arcing!==null&&(u.arc=e.arcing,u.hold=e.arcing.hold),i?.fitting&&sL(n,u),e.pace!==null&&i===null&&n.start!==void 0&&u.state==="pending"&&(u.pinned=n.start-e.offset),l===Number.POSITIVE_INFINITY&&!s&&!i?.fitting&&Number.isNaN(u.pinned)&&(u.waking=!0,e.waking=!0),tm(e,u),iL(e,u);let c=ec(e,u);return u.handle=c,Vr(e)&&n8(e,c),c}var t8=Object.freeze({});function n8(e,t){Ct(e,"cue",n=>{let r=Ur.voiceOf(t)??i8(t),o=n.mix(e);o===e?tL(e,r):o!==void 0&&tL(o,o8(o,r))})}function r8(e,t){for(let n of e.writes){if(!(n in t))throw new Error(`blits: kit has no channel ${String(n)}, which this patch writes`);let r=e.kit?.[n],o=t[n],i=o.rest;if(o.fold&&!o.copy&&typeof i=="object"&&i!==null&&!tO(i))throw new Error(`blits: channel ${String(n)} folds into a copy of its rest, which the mix cannot copy; give the channel a copy`);if(r&&r!==o&&(r.kind===void 0||r.kind!==o.kind))throw new Error(`blits: channel ${String(n)} is ${o.kind??"a custom channel"} in this kit, but the patch was written for ${r.kind??"a custom channel"}`)}}function zP(e,t){let n=t;if(n.locus!==void 0){if(n.role!==void 0&&n.role!==n.locus)throw new Error(`blits: a voice plays one role, not both role ${n.role} and locus ${n.locus}; locus is role's old name`);Qn(e,"locus is renamed role; cue the voice with role");let{locus:s,...a}=n;n={...a,role:s}}let r=e.roleTags,o=n.tags;if(r===void 0||o===void 0)return n;let i=n.role;for(let s of o)if(!(!r.includes(s)||s===i)){if(i!==void 0)throw new Error(`blits: a voice plays one role, not both ${i} and ${s}`);i=s}return i===n.role?n:{...n,role:i}}function oL(e){let{roles:t,loci:n}=e;if(n===void 0)return t;if(t!==void 0&&(t.length!==n.length||t.some((r,o)=>r!==n[o])))throw new Error("blits: a mix takes roles or loci, not both; loci is roles' old name");return Qn(e,"the mix option loci is renamed roles; make the mix with roles"),n}function KP(e,t){let n=t.patch,r=t.loop;if(typeof r=="number"&&!(Number.isInteger(r)&&r>=1))throw new RangeError(`blits: loop takes true, false or a whole number of passes, not ${r}`);if(t.rate!==void 0&&EP(t.rate),t.seek!==void 0&&!Number.isFinite(t.seek))throw new RangeError(`blits: a voice's seek is a finite number of ms, not ${t.seek}`);if(t.stepMs!==void 0&&!(t.stepMs>=0&&t.stepMs<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a voice's stepMs is a finite number of ms, 0 or more, not ${t.stepMs}`);if(t.catchUp!==void 0&&t.catchUp!=="exact"&&t.catchUp!=="fresh")throw new RangeError(`blits: catchUp takes 'exact' or 'fresh', not ${String(t.catchUp)}`);typeof t.weight=="number"&&MP(t.weight),r8(n,e.kit);let o=On(n);if(o!==void 0){let i=n.writes[0],s=e.kit[i],a=s.rest;typeof a=="number"?o.cuedOn(String(i),!0):Array.isArray(a)||ArrayBuffer.isView(a)?o.cuedOn(String(i),!1,tP(s)):tP(s)&&o.cuedOn(String(i),!1,!0)}if(n.reads){let i=e.opts.host;for(let s of n.reads)if(typeof i!="object"||i===null||!(s in i))throw new Error(`blits: the patch reads host.${s}, which this mix's host lacks`)}if(e.transport.pager!==null&&(n.state!==void 0||n.step!==void 0)&&(n.pack===void 0||n.unpack===void 0))throw new Error("blits: this mix's history has a store, which keeps a stateful patch's state as data; give the patch pack and unpack");if(t.as!==void 0&&e.transport.pager!==null&&!e.opts.history?.revive)throw new Error("blits: a voice cued with as needs history.revive to rebuild it from")}function tL(e,t){let n=t.owner;!n?.fitting&&(n===null?e.now:Te(n,e.now))>=t.start&&(t.state="live"),iL(e,t)}var nL=new WeakMap;function o8(e,t){let n=t.copy(()=>{});if(t.owner!==null){let r=_o(e,t.owner.id);(r===void 0||r.holding===null)&&Sa("a cue under an owner that has left"),n.owner=r}if(n.holding!==null&&(n.holding=new Co),n.blend!==null){let r=nL.get(e);r===void 0&&(r=new Map,nL.set(e,r));let o=n.blend.of,i=r.get(o);i===void 0&&(i=tc(n.blend.of.by,n.blend.of.stops),r.set(o,i)),n.blend={of:i,i:n.blend.i},i.members.push(n)}return n}function i8(e){throw new Error(`blits: voice ${e.id} is paged out, and the seek that plays its cue again did not load it`)}function iL(e,t){let n=t.spec,r=t.owner,o=n.anchor,i=o!==void 0&&(o.start!==void 0||o.in!==void 0),s=t.motion;t.parked=!1,r!==null&&AO(r,t),Number.isNaN(e.now)||(t.cuedAt=e.now,t.cuedSeq=e.transport.seq,t.opened=e.now,t.state!=="pending"&&(t.begunSeq=e.transport.seq)),t.placing=i,!Number.isNaN(t.pinned)&&t.state==="pending"&&Lo(e,t,t.pinned),s!==void 0&&!e.projecting&&(e.playing.set(s,(e.playing.get(s)??0)+1),e.owner??=pF(new WeakRef(e)),s.owner=e.owner,s.ownerId=t.id);let a=e.cued,l=a.length;for(;l>0&&a[l-1].id>t.id;)l--;a.splice(l,0,t),yO(e,t),t.sharing=e.share?.shares(e,t)===!0,ZF(e,t),Dr(e,t),e.stir(),n.from==="current"&&(e.wantsPose=!0),o&&(Gr(e),!Number.isNaN(e.now)&&t.state==="pending"&&Ju(e,t)>=t.start&&ba(e,t,e.now)),r?.fitting&&Ln(e,r),e.opts.history&&(t.log=[],t.note(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),t.first??=t.log[0]),it(e,t)}function s8(e,t){let n=e.owners?.find(r=>r.handle===t);if(n===void 0)throw new Error("blits: owner is not a handle mix.owns returned on this mix");if(n.state==="done")throw new Error("blits: that owner has left the mix");return n}var nm=class{out=new Map;gone=new FinalizationRegistry(t=>{this.out.get(t)?.handle.deref()===void 0&&this.out.delete(t)});add(t,n,r){this.out.set(t,{doneAt:n,handle:new WeakRef(r)}),this.gone.register(r,t)}take(t){let n=this.out.get(t);return this.out.delete(t),n?.handle.deref()}missing(t,n){for(let[r,o]of this.out)if(o.doneAt>t&&!n(r))return r}};function a8(e){return e.spec.as!==void 0&&e.owner===null&&e.holding===null&&e.blend===null&&e.answers===null&&e.fitting===null}function aL(e,t,n){if(!a8(t))return!1;let r=e.keys,o=l8(t,r);er(e,"voice",t.id,void 0,[{at:t.doneAt,seq:t.doneSeq}],()=>o,n);let i=t.handle;return Ur.page(i,{weight:t.weight,played:t.settled.played===!0}),e.outs.add(t.id,t.doneAt,i),e.parters.delete(t),!0}function l8(e,t){let n=s=>t.subject(s),r=[],o=[];for(let s of e.keyed??[]){let a=n(s),l=e.subjects.get(a);l?.reaches&&r.push([s,Oi(e,l)]);let u=e.motion?.pack(a);u!==void 0&&o.push([s,u])}let i=e.settled;return{as:e.spec.as,start:e.start,anchorNow:e.anchorNow,anchorElapsed:e.anchorElapsed,rate:e.rate,ramp:e.ramp,weight:e.weight,out:e.out,back:e.back,stalls:e.stalls,outAt:e.outAt,outOver:e.outOver,outSet:e.outSet,rebuilds:e.rebuilds,hold:e.hold,past:e.clocks?.length??0,earlier:e.earlier,later:e.later,clocks:e.clocks,cuedAt:e.cuedAt,cuedSeq:e.cuedSeq,begunSeq:e.begunSeq,doneAt:e.doneAt,doneSeq:e.doneSeq,opened:e.opened,pinned:e.pinned,offset:e.offset,latest:e.latest,soonest:e.soonest,keeping:e.keeping,first:e.first,log:e.log,played:i.played,playedAt:i.at,playedSeq:i.seq,records:r,runs:o,left:(e.left?.all()??[]).map(s=>[t.key(s.subject),s.at,s.seq,Oi(e,s.held),s.sync,s.ramp,s.parted]),parts:[...e.parts??[]].map(([s,a])=>[t.key(s),a.at,a.over,a.seq]),parted:[...e.parted??[]].map(([s,a])=>a.ramp===void 0?[t.key(s),a.at,a.seq]:[t.key(s),a.at,a.seq,a.ramp])}}function lL(e,t,n){let r=e.opts.history?.revive;if(r===void 0)throw new Error("blits: a paged voice needs history.revive");let o=zP(e,{...r(n.as),as:n.as});KP(e,o);let i=new Na(t,o,o.patch,o.fade??{},Number.NEGATIVE_INFINITY,n.start,e.slotOf,e.channels,e.opts.host,e.send,null);i.clocks=n.clocks,i.take(n),i.cuedAt=n.cuedAt,i.cuedSeq=n.cuedSeq,i.begunSeq=n.begunSeq??Number.POSITIVE_INFINITY,i.doneAt=n.doneAt,i.doneSeq=n.doneSeq,i.opened=n.opened,i.pinned=n.pinned,i.offset=n.offset??0,i.latest=n.latest,i.soonest=n.soonest??0,i.keeping=n.keeping,i.first=n.first,i.log=n.log,i.state="done",n.played!==void 0&&i.play(n.played,n.playedAt,n.playedSeq),i.resolve();let s=e.keys,a=u=>s.subject(u);i.keyed=new Set;for(let[u,c]of n.records)i.subjects.set(a(u),Fi(i,c)),i.keyed.add(u);for(let[u,c]of n.runs)i.motion?.unpack(a(u),c);i.left=Cn.from(n.left.map(([u,c,d,f,p,h=null,m=null])=>({subject:a(u),at:c,seq:d,sync:p,held:Fi(i,f),ramp:h,parted:m}))),n.parts.length>0&&(i.parts=new Map(n.parts.map(([u,c,d,f])=>[a(u),{at:c,over:d,seq:f}]))),n.parted.length>0&&(i.parted=new Map(n.parted.map(([u,c,d,f])=>[a(u),{at:c,seq:d,ramp:f??void 0}])));let l=e.outs?.take(t);return l===void 0?i.handle=ec(e,i):(Ur.rehome(l,i),i.handle=l),i}var u8=0;function st(){return++u8}function pL(e){return e.stirred||e.anchored>0||e.pins!==null&&e.pins.size>0}function zr(e,t){e.moving=!0;try{c8(e,t)}finally{e.moving=!1}}function c8(e,t){e.now=t,e.looked=!1,e.unshared&&(e.unshared=!1,Do(e)),e.frame=st(),e.reducedNow=e.reduced;for(let i of e.announced)Number.isNaN(i.at)&&(i.at=e.u);if(e.waking&&m8(e,t),e.pins!==null&&e.pins.size>0&&iF(e),e.anchored>0&&Gr(e),e.announced.length>0){let i=e.opts.history===void 0?t:e.transport.keepsFrom();e.announced=e.announced.filter(s=>Bi(e,s.at)>=i)}let n=e.projecting||e.walkAll?e.cued:eO(e,t),r=null;for(let i of n)i.state!=="done"&&ac(e,i,t,i.owner!==null&&i.owner.fitting!==null)&&(r??=[],r.push(i));let o=e.leapt===null&&r===null?null:d8(e,r,t);e.leapt=null,o===null?hL(e,r,t):f8(e,o,r,t),e.sharers.length>0&&!e.projecting&&e.share?.outgrow(e),e.stirred=!1,e.asleep=!1,e.retired.length>0&&w8(e),T8(e)}function hL(e,t,n){t!==null&&p8(e,t,n),e.owners!==null&&(gL(e,n),bL(e,n))}function d8(e,t,n){let r=null;if(e.leapt!==null)for(let o of e.leapt)r=uL(o,n,r);if(t!==null)for(let o of t)r=uL(o.owner,n,r);return r}function uL(e,t,n){for(let r=e;r!==null;r=r.owner)r.state==="done"||r.owner?.fitting||n?.includes(r)||r.rateAt(r.owner===null?t:Te(r.owner,t))>0||(n??=[],n.push(r));return n}function f8(e,t,n,r){let o=t.map(i=>{let{anchorNow:s,anchorElapsed:a,rate:l,ramp:u,start:c}=i,d=i.owner===null?r:Te(i.owner,r);return i.anchorElapsed=ze(i,d),i.anchorNow=d,i.rate=1,i.ramp=null,i.start=d-i.anchorElapsed,{anchorNow:s,anchorElapsed:a,rate:l,ramp:u,start:c,logged:i.log?.length??0}});try{if(e.anchored>0){Gr(e);for(let i of t)_i(i,s=>{s.state==="pending"&&s.spec.anchor!==void 0&&s.owner?.fitting===null&&ac(e,s,r)})}hL(e,n,r)}finally{t.forEach((i,s)=>{let{logged:a,...l}=o[s];Object.assign(i,l);let u=i.log;if(u!==null)for(let c=a;c<u.length;c++)Object.assign(u[c],l)})}e.frame=st();for(let i of t)i.state!=="done"&&it(e,i),_i(i,s=>{s.state!=="done"&&(cn(e,s,r),it(e,s))});e.lanes?.refill()}function ac(e,t,n,r=!1){Number.isNaN(t.opened)&&(t.opened=n),(t.earlier!==null||t.later!==null)&&YP(e,t,n);let o=t.owner===null?n:Te(t.owner,n);if(r&&yL(t,o,n))return!0;if(t.state==="pending"&&mL(t,o,n)&&ba(e,t,n),(t.state==="live"||t.state==="frozen")&&t.outAt<=n&&!(t.state==="live"&&!t.freezesAfter&&!t.freezesBefore&&t.endsAt()<t.outAt)&&Kr(e,t,{over:Number.isNaN(t.outOver)?void 0:t.outOver},Math.max(Mo(t),t.outAt)),t.state!=="pending"){t.turns&&y8(e,t,n),t.state==="live"&&t.out!==null&&!t.quietAt(n)&&QP(e,t,n);let s=Math.sign(t.rateAt(o))*(t.owner===null?1:$P(t.owner,n)),a=o===Number.NEGATIVE_INFINITY?o:ze(t,o),l=s<0,u=!t.beginless&&a<=t.soonest,c=t.holding!==null&&Br(t,n);(l?u&&!c:Number.isFinite(t.span)&&a>=t.span+t.latest)?(t.play(!0,n,e.transport.seq),t.state==="live"&&t.out===null&&((l?t.freezesBefore:t.freezesAfter)?t.state="frozen":Kr(e,t,{back:l,stays:t.owner!==null&&e.opts.history!==void 0},Math.max(Fn(t),Math.min(n,t.endsAt()))))):t.state==="frozen"&&!(u&&s===0)&&(t.state="live")}if(t.parts!==null&&!e.projecting)for(let[s,a]of t.parts)n-a.at>=a.over&&XP(e,t,s,a.at+a.over);let i=t.back;if(i!==null&&n>=i.at+(1-i.from)*i.over&&!e.projecting&&(t.back=null,e.lanes?.refill()),t.state==="fading"&&t.out){let{at:s,over:a,rest:l,deadline:u}=t.out,c=n-s;if(l){let d=u!==void 0&&c>=u,f=t.seen>0&&t.restedCount>=t.seen;d?_n(e,t,s+u):f&&_n(e,t)}else c>=a&&(t.out.stays?JP(e,t,s+a):_n(e,t,s+a))}return e.projecting||it(e,t),!1}function mL(e,t,n){return t>e.start||t===e.start&&(e.owner===null||$P(e.owner,n)>=0)}function jP(e,t,n){return(t.earlier!==null||t.later!==null)&&YP(e,t,n),yL(t,Te(t.owner,n),n)}function yL(e,t,n){if(e.state==="pending")return mL(e,t,n);if(e.state!=="live")return!1;let r=e.out;if(e.fitting!==null)return r===null&&qP(e,n);if(!Number.isFinite(e.span)||r!==null&&!(r.stays===!0&&r.back===!0))return!1;let o=t===Number.NEGATIVE_INFINITY?t:ze(e,t),i=r===null?e.span+e.latest:e.soonest;return o>i||o===i&&$P(e,n)>0}function p8(e,t,n){let r=t.length===1?t[0]:null;if(r!==null&&r.state==="pending"&&r.holding===null&&(ba(e,r,n),!jP(e,r,n))){ac(e,r,n);return}let o=t,i=[];for(;;){let s,a=Number.POSITIVE_INFINITY;for(let l=0;l<o.length;l++){let u=o[l];if(u.state==="done"||i.includes(u)||!jP(e,u,n))continue;let c=u.state==="pending"?Fn(u):u.fitting!==null?h8(u):u.out!==null?u.reaches(u.soonest):u.endsAt();(s===void 0||c<a||c===a&&dL(u)<dL(s))&&(s=u,a=c)}if(s===void 0)break;if(s.state==="pending")ba(e,s,n),s.holding!==null&&cL(e,s,n,o,i);else if(s.out!==null)QP(e,s,n);else{i.push(s),s.fitting!==null?lc(e,s,a):ac(e,s,n);for(let l=s.owner;l?.fitting;l=l.owner)cL(e,l,n,o,i)}}Mi(o);for(let s=0;s<o.length;s++){let a=o[s];!i.includes(a)&&a.state!=="done"&&ac(e,a,n)}}function h8(e){return e.timeAt(e.fitting.budget)}function cL(e,t,n,r,o){let i=t.holding.children;for(let s=0;s<i.length;s++){let a=i[s];a.state!=="done"&&!o.includes(a)&&!r.includes(a)&&jP(e,a,n)&&r.push(a)}}function dL(e){return(e.state==="pending"||e.out!==null?2**40:0)+e.id}function m8(e,t){e.waking=!1;for(let n of e.cued){if(!n.waking||(n.waking=!1,n.state!=="pending"))continue;Ta(e,n,t);let r=n.first;r!==null&&(r.start=t,r.anchorNow=t),e.projecting||it(e,n)}}function $P(e,t){let n=1;for(let r=e;r!==null;r=r.owner)n*=Math.sign(r.rateAt(r.owner===null?t:Te(r.owner,t)));return n}function y8(e,t,n){let r=t.ramp,o=t.anchorNow+r.over*r.from/(r.from-r.to);(t.owner===null?n:Te(t.owner,n))<o||(Eo(t,o),t.anchorElapsed=ze(t,o),t.ramp={from:0,to:r.to,over:t.anchorNow+r.over-o},t.anchorNow=o,Ke(e,t))}var g8=8,b8=32,x8=4;function w8(e){let t=e.retired;e.retired=[];let n=e.cued,r=null;if((t.length<=g8||t.length*b8<=n.length)&&!e.projecting){Mi(t),r=[];for(let i=0;i<t.length;i++){let s=t[i],a=s===t[i-1]?-1:P8(n,s);if(a<0){r=null;break}r.push(a)}}let o=!1;if(r!==null){for(let i of t)o=fL(e,i)||o;if(r.length<=x8)for(let i=r.length-1;i>=0;i--)n.splice(r[i],1);else{let i=r[0],s=0;for(let a=i;a<n.length;a++)r[s]===a?s++:n[i++]=n[a];n.length=i}}else{let i=0;for(let s=0;s<n.length;s++){let a=n[s];a.state!=="done"?n[i++]=a:o=fL(e,a)||o}n.length=i}o&&(e.general=e.general.filter(i=>i.state!=="done"),e.sharers.length>0&&(e.sharers=e.sharers.filter(i=>i.state!=="done")),Do(e))}function P8(e,t){let n=0,r=e.length-1;for(;n<=r;){let o=n+r>>>1,i=e[o].id;if(i===t.id)return e[o]===t?o:-1;i<t.id?n=o+1:r=o-1}return-1}function fL(e,t){return gO(e,[t]),e.opts.history?(e.gone.push(t),Rh(e,t)):(e.parters.delete(t),e.departed.add(e,t)),fF(e,t),Dr(e,t),eL(e,t),t.named===null}function T8(e){let t=e.opts.history;if(t&&e.gone.length>0)if(e.transport.pager!==null){let n=e.now-t.ms;AP(e,r=>r.reachedTo>=n||!aL(e,r,n))}else zO(e,e.transport.keepsFrom())}var rm=class{budget;claim;fit;spill;end;report;constructor(t){let n=t.duration??Number.POSITIVE_INFINITY;if(!(n>=0))throw new Error("blits: a span lasts 0 ms or more");let r=t.share??.5;if(!(r>=0&&r<=1))throw new Error("blits: a span staggers by a share in 0..1");this.budget=n,this.claim={budget:n,priority:t.priority??"strong",order:t.order??"queue",share:r},this.fit=t.fit??j2,this.spill=t.spill??"instant",this.end=Number.isFinite(n)?n:0,this.report={budget:n,length:0,over:0,skipped:0,fell:!1}}};function sL(e,t){if(e.start!==void 0||e.anchor?.start!==void 0||e.anchor?.in!==void 0)throw new Error("blits: a span places the voices it holds, so one takes no start of its own");if(t.arc!==null){if(!Number.isFinite(dc(t)))throw new Error("blits: a span cannot fit an arc held open, which never ends")}else if(t.holding!==null){if(t.fitting===null)throw new Error("blits: a span holds voices, spans and arcs, not owners")}else if(!Number.isFinite(t.span))throw new Error("blits: a span cannot fit a voice that never ends")}function S8(e,t){for(let n of e.holding.children)if(n.out?.stays===!0&&(n.out.back===!0||n.start>t))return!0;return!1}function YP(e,t,n){let r=Te(t.owner,n),o=!1;for(let i=t.earlier;i!==null&&r<t.anchorNow;i=t.earlier)t.later={...ZP(t),prev:t.later},xL(t,i),t.earlier=i.prev,o=!0;for(let i=t.later;i!==null&&r>=i.anchorNow;i=t.later)t.earlier={...ZP(t),prev:t.earlier},xL(t,i),t.later=i.prev,o=!0;o&&(e.frame=st(),cn(e,t,n),Ke(e,t),e.lanes?.refill())}function ZP(e){let{anchorNow:t,anchorElapsed:n,rate:r,ramp:o,skipped:i}=e;return{anchorNow:t,anchorElapsed:n,rate:r,ramp:o,skipped:i}}function xL(e,t){e.anchorNow=t.anchorNow,e.anchorElapsed=t.anchorElapsed,e.rate=t.rate,e.ramp=t.ramp,e.skipped!==t.skipped&&e.seeks++,e.skipped=t.skipped}function k8(e,t){if(Number.isNaN(t))return 0;let n=wL(e,t);return Number.isFinite(n)?Math.max(0,n):0}function wL(e,t){let n=e.owner===null?t:wL(e.owner,t);return n===Number.NEGATIVE_INFINITY||e.state==="pending"&&!(n>=e.start)?Number.NEGATIVE_INFINITY:ze(e,n)}function uc(e,t){return e.state!=="pending"||e.start<t}function v8(e,t,n){return uc(e,n)?Math.max(0,ze(e,t)):0}function PL(e,t,n){let r=e.fitting!==null?e.fitting.end:e.arc!==null?dc(e):e.span;return Math.max(0,r-v8(e,t,n))}function Ln(e,t,n=e.now){let r=t.fitting;if(e.projecting||t.state==="done")return;let o=k8(t,n);if(S8(t,o))return;let i=n<e.now?o:Number.NEGATIVE_INFINITY,{kids:s,floors:a,waiting:l}=A8(e,t,o,i),u=s.map((P,S)=>{let v=P.spec;return{floor:a[S],natural:PL(P,o,i)/(v.rate??1),state:uc(P,i)?"playing":"pending",faster:Math.max(1,v.faster??1),slower:Math.max(1,v.slower??1),overlap:v.overlap===!0,ballast:v.ballast===!0&&P.holding===null,priority:v.priority??"weak"}}),c={...r.claim,left:r.budget-o},{plan:d,fell:f}=$2(c,u,r.fit,r.spill),{at:p,length:h}=iP(c,u,d);s.forEach((P,S)=>{let v=(P.spec.rate??1)*d.rate[S],A=d.skip[S]&&P.holding===null,N=P.skipped;P.skipped=A;let M=!1;if(uc(P,i))(A||P.rate!==v||P.ramp!==null)&&(P.earlier={...ZP(P),skipped:N,prev:P.earlier},P.later=null),A&&(Eo(P,o),P.rebase(o),P.anchorElapsed=P.span,P.seeks++,M=!0),(P.rate!==v||P.ramp!==null)&&(Eo(P,o),ca(P,o,v,0),M=!0);else{let C=o+p[S],F=A?P.span:0;(P.start!==C||P.rate!==v||P.anchorElapsed!==F||P.ramp!==null)&&(P.start=C,P.anchorNow=C,P.anchorElapsed=F,P.rate=v,P.ramp=null,P.clocks=null,P.earlier=null,P.later=null,M=!0)}M&&(e.frame=st(),cn(e,P,e.now),Ke(e,P))});for(let P of l)P.start!==Number.POSITIVE_INFINITY&&(P.start=Number.POSITIVE_INFINITY,P.anchorNow=Number.POSITIVE_INFINITY,P.anchorElapsed=0,P.clocks=null,P.earlier=null,P.later=null,e.frame=st(),cn(e,P,e.now),Ke(e,P));s.length>0&&e.lanes?.refill();let m=o+h,g=Number.isFinite(r.budget)?Math.max(0,m-r.budget):0,b=g<1e-6,x=Number.isFinite(r.budget)&&b?r.budget:m,w=r.report,y={budget:r.budget,length:m,over:b?0:g,skipped:d.skip.filter((P,S)=>P&&s[S]?.holding===null).length,fell:f};r.report=y,x!==r.end?(r.end=x,Ke(e,t),t.owner?.fitting&&Ln(e,t.owner,n)):(y.length!==w.length||y.over!==w.over||y.skipped!==w.skipped||y.fell!==w.fell)&&Ke(e,t)}function A8(e,t,n,r){let o=(t.holding?.children??[]).filter(c=>c.state!=="done"&&c.state!=="frozen"&&c.out===null&&PL(c,n,r)>0),i=o.filter(c=>uc(c,r)),s=i.map(()=>{}),a=[],l=o.filter(c=>!uc(c,r)).sort((c,d)=>(c.spec.rank??0)-(d.spec.rank??0)),u=t.fitting.claim.order!=="together";for(let c of l){let d=c.spec.earliest,f=d===void 0?void 0:Pa(e,d,c,Number.NEGATIVE_INFINITY);if(c.floorSeen=f??Number.NaN,d!==void 0&&f===void 0||u&&a.length>0){a.push(c);continue}i.push(c);let p=f===void 0||f===Number.NEGATIVE_INFINITY?void 0:f-n;s.push(p===void 0||c.cuedSeq===e.transport.seq?p:Math.max(0,p))}return{kids:i,floors:s,waiting:a}}function aF(e){if(!e.projecting)for(let t of e.owners??[]){if(t.fitting===null||t.state==="done")continue;(t.holding?.children??[]).some(r=>{let o=r.spec.earliest;if(r.state!=="pending"||o===void 0||typeof o=="number")return!1;let i=Pa(e,o,r,Number.NEGATIVE_INFINITY)??Number.NaN;return!Object.is(i,r.floorSeen)})&&Ln(e,t)}}function cc(e,t){let n=e.fitting;return n!==null&&Number.isFinite(n.budget)&&Te(e,t)<n.budget}function gL(e,t){let n=e.owners??[];for(let r=n.length-1;r>=0;r--){let o=n[r];o.out?.stays!==!0&&qP(o,t)&&lc(e,o,o.timeAt(o.fitting.budget))}}function qP(e,t){let n=e.fitting;return n===null||e.state==="done"||!Number.isFinite(n.budget)?!1:!Br(e,t)&&Te(e,t)>=n.budget}var dn=Object.freeze([]),R8=()=>{},TL=new WeakMap;function N8(e,t,n){if(e.length!==1)return SL(e,t,n);let r=TL.get(t);r===void 0&&(r=new Map,TL.set(t,r));let o=e[0],i=r.get(o);return i===void 0&&(i=SL(e,t,n),r.set(o,i)),i}function SL(e,t,n){let r=e.map(o=>t.get(o));return{slots:r,lerps:r.map(o=>n[o].lerp)}}var Na=class e{id;spec;patch;fade;start;owner;state="pending";rate;weight;anchorNow;anchorElapsed=0;ramp=null;out=null;back=null;stalls=null;subjects=new me;named;slots;built;lerps;intos;scratch=[];holder=null;laned=!1;seat=null;seeks=0;written=!1;touches=0;get jumps(){return this.seeks-this.touches}rebuilds=0;skipped=!1;floorSeen=Number.NaN;keeping=!1;parts=null;parted=null;left=null;ease;passes;duration;span;motion;beginless;freezesBefore;freezesAfter;opened=Number.NaN;unchecked=!0;dueToken=0;early=null;clocks=null;earlier=null;later=null;setting;seen=0;latest=0;soonest=0;restedCount=0;parked=!1;cuedAt=Number.NEGATIVE_INFINITY;cuedSeq=Number.NEGATIVE_INFINITY;begunSeq=Number.POSITIVE_INFINITY;doneAt=Number.POSITIVE_INFINITY;doneSeq=Number.POSITIVE_INFINITY;decidedAt=Number.NEGATIVE_INFINITY;get reachedTo(){return this.doneAt>this.decidedAt?this.doneAt:this.decidedAt}log=null;first=null;outAt=Number.POSITIVE_INFINITY;outOver=Number.NaN;outSet=!1;pinned=Number.NaN;offset=0;waking=!1;placing=!1;answers=null;folds=null;keepOn=null;ownKept=null;blend=null;spares=null;unreached=null;unreachedBits=null;sharing=!1;bound=null;shared=0;everyone=null;sighted=null;weights=null;stamps=null;deltas=null;handle=null;keyed=null;holding;fitting=null;arc=null;hold=0;part=-1;finished=!1;playedAs=void 0;playedAt=Number.NaN;playedSeq=Number.NaN;donePromise=null;doneSettle=null;playedPromise=null;playedSettle=null;quiet=!1;get done(){return this.donePromise===null&&(this.donePromise=this.finished?Promise.resolve():new Promise(t=>{this.doneSettle=t})),this.donePromise}get played(){if(this.playedPromise===null){let t=this.playedAs;this.playedPromise=t!==void 0?Promise.resolve(t):new Promise(n=>{this.playedSettle=n})}return this.playedPromise}resolve(){this.quiet||this.finished||(this.finished=!0,this.doneSettle?.())}play(t,n,r){this.quiet||this.playedAs!==void 0||(this.playedAs=t,this.playedAt=n,this.playedSeq=r,this.playedSettle?.(t),t&&this.owner!==null&&NO(this.owner,n,r))}get settled(){return{played:this.playedAs,at:this.playedAt,seq:this.playedSeq}}get passed(){return this.playedAs===!0}get unplayed(){return this.playedAs===!1}reopen(t){let n=!1;return this.playedAs!==void 0&&!(this.playedSeq<=t)&&(n=this.playedAs,this.playedAs=void 0,this.playedPromise=null,this.playedSettle=null),this.finished&&!(this.doneSeq<=t)&&(this.finished=!1,this.donePromise=null,this.doneSettle=null),n}take(t){this.anchorNow=t.anchorNow,this.anchorElapsed=t.anchorElapsed,this.rate=t.rate,this.ramp=t.ramp,this.weight=t.weight,this.out=t.out,this.back=t.back,this.stalls=t.stalls??null,this.start=t.start,this.outAt=t.outAt,this.outOver=t.outOver,this.outSet=t.outSet,this.rebuilds=t.rebuilds,this.hold=t.hold,this.earlier=t.earlier??null,this.later=t.later??null;let n=t.fitted;n&&this.fitting!==null&&(this.fitting.end=n.end,this.fitting.report=n.report);let r=this.clocks;r!==null&&r.length!==t.past&&(this.clocks=t.past===0?null:r.slice(0,t.past))}park(){this.reopen(Number.NEGATIVE_INFINITY),this.take(this.first),this.parked=!0,this.log=null,this.state="pending",this.subjects=new me,this.scratch=[],this.holder=null,this.laned=!1,this.seeks++,this.keeping=!1,this.parts=null,this.parted=null,this.opened=Number.NaN,this.dueToken++,this.early=null,this.seen=0,this.latest=this.named?.latest??0,this.soonest=this.named?.soonest??0,this.restedCount=0,this.cuedAt=Number.NEGATIVE_INFINITY,this.cuedSeq=Number.NEGATIVE_INFINITY,this.begunSeq=Number.POSITIVE_INFINITY,this.doneAt=Number.POSITIVE_INFINITY,this.doneSeq=Number.POSITIVE_INFINITY,this.placing=!1,this.answers=null,this.folds=null,this.keepOn=null,this.ownKept=null,this.unreached=null,this.unreachedBits=null,this.sharing=!1,this.everyone=null,this.sighted=null,this.weights=null,this.stamps=null,this.deltas=null,this.holding!==null&&(this.holding=new Co)}constructor(t,n,r,o,i,s,a,l,u,c,d){this.id=t,this.spec=n,this.patch=r,this.fade=o,this.start=s,this.owner=d,this.holding=r===Li?new Co:null;let f=N8(r.writes,a,l);this.slots=f.slots,this.named=n.subjects?new Eh(n.subjects,n.stagger):null,this.latest=this.named?.latest??0,this.soonest=this.named?.soonest??0,this.built=r.form==="keys"&&r.keys?_O(r):null,this.lerps=f.lerps,this.intos=this.built?LO(this.built,this.slots.map(g=>l[g])):void 0,this.ease=o.ease===void 0?void 0:No(o.ease),this.passes=A2(n.loop),this.duration=r.duration,this.span=this.duration>0&&Number.isFinite(this.passes)?this.duration*this.passes:Number.POSITIVE_INFINITY,this.motion=On(r);let p=this.motion===void 0?n.freeze:void 0,h=p===void 0&&this.motion===void 0&&d!==null;this.freezesBefore=h?d.freezesBefore:p==="before"||p==="both",this.freezesAfter=h?d.freezesAfter:p==="after"||p==="both",this.setting=new _h(u,c,this),this.rate=n.rate??1,this.weight=typeof n.weight=="number"?n.weight:1;let m=!Number.isFinite(this.span);this.beginless=this.rate<0&&m&&this.motion===void 0,this.anchorNow=s,this.anchorElapsed=n.seek??(this.rate<0&&!m?this.span:0),i>=s&&(this.state="live")}elapsedAt(t){return this.owner===null?ze(this,t):vO(this,this.owner,t)}timeAt(t){let n=En(this,t);return this.owner===null?n:Oo(this.owner,n)}get backs(){let t=this.ramp;return t===null?this.rate<0:t.from<=0&&t.to<=0&&(t.from<0||t.to<0)}get turns(){let t=this.ramp;return t!==null&&t.from*t.to<0}endsAt(){if(this.turns)return Number.POSITIVE_INFINITY;let t=this.backs,n;if(t!==(this.owner!==null&&Ch(this))){if(this.beginless)return Number.POSITIVE_INFINITY;n=this.soonest}else{if(!Number.isFinite(this.span))return Number.POSITIVE_INFINITY;n=this.span+this.latest}return this.reaches(n)}reaches(t){let n=this.backs?Wu(this,t):En(this,t);return this.owner===null?n:Oo(this.owner,n)}stateAt(t,n){let r=this.out;return r!==null?r.stays&&t>=r.at+r.over?"live":"fading":(this.owner===null?t:Te(this.owner,t))<this.start&&!(n!==void 0&&Kt(n,this.begunSeq,!0))?"pending":this.freezesAfter&&this.elapsedAt(t)>=this.span+this.latest?"frozen":"live"}quietAt(t){let n=this.out;if(this.state!=="live"||n?.stays!==!0)return!1;if(this.holding!==null&&n.back!==!0)return!Br(this,t)&&!cc(this,t);if(this.skipped&&Te(this.owner,t)<this.start)return!0;let r=this.elapsedAt(t),o=this.span+this.latest,i=this.backs!==(this.owner!==null&&Ch(this));return r>o||r===o&&!i?!0:!this.beginless&&(r<this.soonest||r===this.soonest&&i)}ranBackTo(t,n){if(this.beginless||!this.backs||this.owner!==null)return Number.NaN;let r=Wu(this,t);return r>=this.anchorNow&&r<=n?r:Number.NaN}unstarted(t){let n=this.state;return n==="pending"?!0:n!=="fading"?!1:!((this.owner===null?t:Te(this.owner,t))>=this.start)}rawAt(t,n){return(this.unstarted(t)?this.anchorElapsed:this.elapsedAt(t))-n}before(t,n){return!(t>=0)&&!this.beginless||this.unstarted(n)}get holdsFirst(){return this.freezesBefore||this.out?.back===!0}get hidesPast(){return!this.freezesAfter&&this.backs!==(this.owner!==null&&Ch(this))}shownAt(t){return this.beginless?t:t>this.span&&this.hidesPast?Number.NaN:mh(t,this.holdsFirst,this.freezesAfter,this.span)}note(t,n,r=!1){this.log?.push({at:t,seq:n,sync:r,anchorNow:this.anchorNow,anchorElapsed:this.anchorElapsed,rate:this.rate,ramp:this.ramp,weight:this.weight,out:this.out,back:this.back,stalls:this.stalls,start:this.start,outAt:this.outAt,outOver:this.outOver,outSet:this.outSet,rebuilds:this.rebuilds,hold:this.hold,past:this.clocks?.length??0,earlier:this.earlier,later:this.later,fitted:this.fitting===null?null:{end:this.fitting.end,report:this.fitting.report}})}copy(t,n,r=!1){let o={__proto__:e.prototype,...this},i=o;i.subjects=new Th(t),i.setting={...this.setting,keep:TP(o),send:R8},o.keepOn=null,o.ownKept=null,o.scratch=[],o.holder=null,o.laned=!1,o.seat=null,o.log=null,o.early=null,n&&o.take(n),o.clocks===this.clocks&&o.clocks!==null&&(o.clocks=o.clocks.slice()),o.quiet=!0,o.unreached=null,o.unreachedBits=null;let s=r&&this.sharing?this.everyone:null;return o.sharing=s!==null,o.everyone=s===null?null:{...s,delta:null,probed:Number.NaN,from:s.stepped},o.sighted=null,o.weights=null,o.stamps=null,o.deltas=null,o}rateAt(t){return ua(this,t)}rebase(t){Zw(this,t)}};function kL(e,t){if(e.unchecked=!1,t===null||typeof t!="object")return;let n=e.patch.writes;for(let r in t)n.includes(r)||Qn(e.patch,`${e.spec.name??`voice ${e.id}`}'s patch returns ${r} from at(), which is not in its writes, so the mix drops it`)}function Ia(e,t,n){return e[eT(e,t,n)]}function eT(e,t,n){let r=0,o=e.length-1,i=-1;for(;r<=o;){let s=r+o>>1,a=e[s];a.at<t||a.at===t&&(typeof n=="function"?n(a):n)?(i=s,r=s+1):o=s-1}return i}function fc(e,t){let n=0,r=e.length-1,o;for(;n<=r;){let i=n+r>>1,s=e[i];Kt(t,s.seq,s.sync)?(o=s,n=i+1):r=i-1}return o}function vL(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let o of n)if(!vL(e[o],t[o]))return!1;return!0}function tT(e,t,n){let r=t.log,o=r===null?void 0:Ia(r,n,!0);return ze(o??t,t.owner===null?n:I8(e,t.owner,n))}function I8(e,t,n){return tT(e,t,n)}function Ke(e,t){ma(e,t,!0),e.stir(),it(e,t);let n=t.log;if(n===null)return;t.note(Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,e.transport.seq,e.moving||!e.looked);let r=e.now-e.opts.history.ms,o=0;for(;o+1<n.length&&n[o+1].at<=r;)o++;o>0&&er(e,"controls",t.id,void 0,n.splice(0,o),E8,r)}var E8=e=>({...e}),M8=Object.freeze([]);function AL(e,t){let n=RL(e,t);return n===0?M8:e.splice(0,n)}function RL(e,t){let n=0;for(;n+1<e.length&&e[n+1].at<=t;)n++;return n}function Ea(e,t){let n=e.patch;return n.clone?n.clone(t):gt(t)}function Ho(e,t,n=!1){let r=NL(t);return Ma({reaches:t.reaches,delay:t.delay,since:t.since,shown:t.shown,weight:t.weight,restedAt:t.restedAt,bands:t.bands===null?null:t.bands.slice(),state:t.state===void 0||n?t.state:Ea(e,t.state),stepped:t.stepped,ticks:t.ticks,probed:t.probed,delta:t.delta,phase:t.phase,seeks:t.seeks,rebuilt:t.rebuilt,copied:t.copied,base:t.base===void 0?void 0:gt(t.base),slope:t.slope===void 0?void 0:gt(t.slope),kept:r,unkept:t.unkept?.map(gt),snaps:t.snaps,from:t.from,unknown:t.unknown,inputs:t.inputs,replay:t.replay,voice:t.voice,next:t.next,version:t.version,roles:t.roles,slot:t.slot,run:t.run,freed:t.freed,restored:null})}function NL(e){if(e.kept===null)return null;let t=new Map;for(let[n,r]of e.kept)t.set(n,gt(r));return t}function nT(e,t,n,r=!1){return n.reaches=t.reaches,n.delay=t.delay,n.since=t.since,n.shown=t.shown,n.weight=t.weight,n.restedAt=t.restedAt,n.bands=t.bands===null?null:t.bands.slice(),n.state=t.state===void 0||r?t.state:Ea(e,t.state),n.stepped=t.stepped,n.ticks=t.ticks,n.rebuilt=t.rebuilt,n.copied=t.copied,n.base=t.base===void 0?void 0:gt(t.base),n.slope=t.slope===void 0?void 0:gt(t.slope),n.kept=NL(t),n.unkept=t.unkept?.map(gt),n.from=t.from,n.unknown=t.unknown,n.replay=t.replay,n.voice=t.voice,n.slot=t.slot,n.run=t.run,n.freed=t.freed,n.restored=null,Ma(n)}function Ma(e){return e.probed=Number.NaN,e.delta=null,e.phase=0,e.seeks=0,e.snaps=void 0,e.inputs=void 0,e.next=null,e.version=Number.NaN,e.roles=null,e}function IL(e,t){let n=e.hostLog,r=n[n.length-1],o=e.transport.seq;if(r!==void 0&&r.seq===o)return;let i=e.opts.host,s={};for(let l of e.cued)for(let u of l.patch.reads??dn)u in s||(s[u]=gt(i[u]));if(r!==void 0&&vL(r.fields,s))return;n.push({at:t,seq:o,fields:s});let a=t-e.opts.history.ms;er(e,"host",void 0,void 0,AL(n,a),l=>l.fields,a)}function om(e,t,n,r,o){let i=e.opts.history;if(!i?.inputs||e.projecting)return;let s=r.inputs??[];r.inputs=s;let a=s[s.length-1];if(a!==void 0&&(a.value===o||a.at===e.now)){a.at===e.now&&(a.value=o);return}s.push({at:e.now,seq:e.transport.seq,value:o});let l=e.now-i.ms,u=AL(s,l);u.length>0&&er(e,"input",t.id,e.keys?.key(n),u,c=>c.value,l)}function pc(e){return e.every??200}function C8(e,t,n,r){let o=t.spares?.pop()??r;return o===void 0?{at:e.now,seq:e.transport.seq,held:Ho(t,n)}:(o.at=e.now,o.seq=e.transport.seq,nT(t,n,o.held),o)}function Kh(e,t,n,r){let o=e.opts.history;if(!o||e.projecting||t.patch.step===void 0&&(r.kept===null||r.kept.size===0)&&r.base===void 0)return;let i=r.snaps??[];r.snaps=i;let s=i[i.length-1];if(s!==void 0&&e.now-s.at<pc(o))return;let a=e.now-o.ms,l=RL(i,a),u;l>0&&(e.transport.pager!==null&&er(e,"snap",t.id,e.keys?.key(n),i.slice(0,l),c=>Oi(t,c.held),a),u=O8(i,l),l===1?i.shift():i.splice(0,l)),i.push(C8(e,t,r,u))}function O8(e,t){for(let n=0;n<t;n++){let r=e[n];if(!r.shared)return r.ahead=void 0,r}}function im(e,t,n,r){let o=e.opts.history;if(o===void 0||r===void 0)return;let i=e.now-o.ms,s=t.left??new Cn;t.left=s;let a=e.keys;s.expire(i,a===null?null:l=>er(e,"left",t.id,a.key(l.subject),[l],u=>[Oi(t,u.held),u.sync,u.ramp,u.parted],i)),s.push({subject:n,at:Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,seq:e.transport.seq,sync:e.syncing||!e.looked,held:r,ramp:t.parts?.get(n)??null,parted:t.parted?.get(n)??null})}function sm(e){let t=e.opts.history;return t===void 0||Number.isNaN(e.now)?[]:[e.now,e.now-t.ms,e.transport.seq,e.syncing||!e.looked]}function bF(e,t,n,r){if(t.state==="done"||t.parted?.has(n)||t.parts?.has(n))return;e.share?.unshare(e,t),e.stir();let o=e.reduced?0:r??t.fade.out??0,i=Number.isNaN(e.now)?Fn(t):e.now;if(o===0){XP(e,t,n,i);return}t.parts??=new Map,t.parts.set(n,{at:i,over:o,seq:e.transport.seq}),e.parters.add(t),it(e,t),e.lanes?.refill()}function EL(e,t,n){let r=e.parts?.get(t);if(r===void 0)return 1;let o=this.reducedNow,i=la(0,{at:r.at,over:r.over,rest:!1},e.ease,o,n,0),s=e.fade.in??0,a=e.subjects.get(t)?.shown;if(!(s>0)||o||a===void 0||!(r.at<n))return i;let l=e.out,u=hh(s,l,e.ease,n,a,e.stalls);return u>0?i*(hh(s,l,e.ease,n,a,e.stalls,r.at)/u):i}function XP(e,t,n,r){let o=t.parts?.get(n);t.parts?.delete(n),t.parts?.size===0&&(t.parts=null),t.parted??=new Map,t.parted.set(n,{at:r,seq:e.transport.seq,ramp:o}),e.parters.add(t),ML(e,t,n);let i=t.motion;i!==void 0&&CL(e,i,t)&&i.release(n,...sm(e))}function OP(e,t,n){if(t.parted?.has(n)!==!0)return;t.subjects.get(n)===void 0&&rT(e,t,n),ML(e,t,n),t.parted.delete(n),t.parted.size===0&&(t.parted=null);let r=ut(e,n)?.slot??-1;r>=0&&e.lanes?.rejoin(r)}function rT(e,t,n){let r=t.subjects.get(n);r!==void 0||t.parted?.has(n)!==!0?im(e,t,n,r):im(e,t,n,t.unreached??e.unreachedOf(t,e.now))}function am(e,t,n){for(let r of t){let o=r.parted;if(o!==null&&o.seq<=n){e.parted??=new Map,e.parted.set(r.subject,o);continue}let i=r.ramp??o?.ramp;i==null||i.seq>n||(e.parts??=new Map,e.parts.set(r.subject,i))}}function ML(e,t,n){let r=ut(e,n);r!==void 0&&r.slot>=0&&(Hr(t,r.slot,!1),e.share?.unsight(t,r.slot));let o=t.subjects.get(n);o!==void 0&&(im(e,t,n,o),t.subjects.delete(n),o.reaches&&t.seen--,Io(o)&&t.restedCount--,t.holder===o&&(t.holder=null)),r!==void 0&&(ju(e,r),t.laned&&r.slot>=0&&e.lanes?.part(t.id,r.slot),e.lanes?.refill())}function Kr(e,t,n,r){if(t.state==="done"||t.state==="fading")return;let o=e.reduced?0:n.over??t.fade.out??0,i=t.state==="pending";i&&Dr(e,t),n.at==="rest"&&(e.share?.unshare(e,t),t.seeks++),t.state="fading",t.out={from:1,at:r??(Number.isNaN(e.now)?Fn(t):e.now),over:o,rest:n.at==="rest",deadline:n.deadline},n.back&&(t.out.back=!0),n.stays&&(t.out.stays=!0),Ke(e,t),n.at==="rest"||n.back||i?e.lanes?.invalidate():e.lanes?.refill(),o===0&&n.at!=="rest"&&(n.stays?JP(e,t,t.out.at):_n(e,t,t.out.at))}function JP(e,t,n){t.state="live",e.lanes?.refill();let r=t.owner;if(r.state==="done")return;let o=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now;Br(r,o)||cc(r,n)?r.fitting!==null&&!t.skipped&&Ln(e,r,n):lc(e,r,n)}function lc(e,t,n){t.owner!==null&&t.state==="live"&&e.opts.history!==void 0?Kr(e,t,{over:0,stays:!0},n):_n(e,t,n)}function xF(e,t,n){let r=t.out;if(t.state!=="fading"&&t.outSet){t.outAt=Number.POSITIVE_INFINITY,t.outOver=Number.NaN,t.outSet=!1,Ke(e,t);return}if(t.state!=="fading"||r===null)return;let o=Number.isNaN(e.now)?Fn(t):e.now,i=e.reduced?0:n.over??t.fade.in??t.fade.out??0,s=r.rest||r.over===0?1:1-(o-r.at)/r.over,a=s<0?0:s>1?1:s,l=Number.isNaN(e.now)||(t.owner===null?o:Te(t.owner,o))<t.start;t.out=null,t.outAt=Number.POSITIVE_INFINITY,t.state=l?"pending":"live",l&&(t.begunSeq=Number.POSITIVE_INFINITY),t.back=i>0&&a<1?{from:a,at:o,over:i}:null,!r.rest&&r.at<o&&(t.stalls=[...t.stalls??[],r.at,o]),l&&Dr(e,t),Ke(e,t),l?e.lanes?.invalidate():e.lanes?.refill()}function wF(e,t,n,r){if(t.state==="done"||t.state==="fading")return;let o=Number.isNaN(e.now)?Fn(t):e.now;if(n<=o){Kr(e,t,{over:r},Math.max(Mo(t),n)),e.stir();return}t.outAt=n,t.outOver=r??Number.NaN,t.outSet=!0,Ke(e,t)}function QP(e,t,n){let r=t.out,o=r.back===!0?t.soonest:t.span+t.latest,i=t.reaches(o),s=Math.max(r.at+r.over,i<=n?i:n),a=e.reduced?0:r.over;t.out=null,t.back=a>0?{from:0,at:s,over:a}:null,Ke(e,t),e.lanes?.refill()}function CL(e,t,n){return t.owner===e.owner&&t.ownerId===n.id}function F8(e,t){t.owner.holding.left(t.passed?Xe(e,t,"coast"):void 0,t.doneSeq)}function _n(e,t,n){t.holding===null&&e.lanes?.touch(t);let r=t.motion;r!==void 0&&CL(e,r,t)&&(r.owner=null),t.state="done",ma(e,t),t.keepOn=null,e.retired.push(t);let o=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now;if(t.doneAt=n??o,t.decidedAt=o,t.doneSeq=e.transport.seq,e.transport.settle(),t.play(!1,t.doneAt,t.doneSeq),t.resolve(),t.holding!==null)for(let i of[...t.holding.children])i.state!=="done"&&_n(e,i,t.doneAt);if(t.owner!==null){let i=t.owner;F8(e,t);let s=RO(t,o);s!==null&&!cc(s,t.doneAt)?_n(e,s,t.doneAt):i.fitting!==null&&i.state!=="done"&&!t.skipped&&Ln(e,i,t.doneAt)}}var L8=["enter","active","exit"],iT=class{enter;exit;blend;has;hold;constructor(t,n,r,o,i){this.enter=t,this.exit=n,this.blend=r,this.has=o,this.hold=i}};function FL(e,t){let n=[0,e.enter,e.enter+t,e.enter+t+e.exit],r=n[3],o=[null,null,null];for(let i=0;i<3;i++){if(!e.has[i])continue;let s=i+1;for(;s<3&&!e.has[s];)s++;o[i]=[n[i],s<3?n[s]:r]}return o}function dc(e){let t=e.arc;return t.enter+e.hold+t.exit}function OL(e,t,n,r,o){if(t<=e)return 0;let i=r/2,s=e===0,a=t===n;if(!s&&o<e-i||!a&&o>=t+i)return 0;let l=s?1:r>0?Math.min(1,(o-e+i)/r):1,u=a?1:r>0?Math.min(1,(t+i-o)/r):1;return Math.min(l,u)}function CO(e,t,n,r){let o=e.arc,i=Te(e,n);if(!(i>=0))return 0;let s=FL(o,e.hold),a=o.enter+e.hold+o.exit,l=r?0:o.blend,u=s[t.part];if(u==null)return 0;let c=OL(u[0],u[1],a,l,i);if(c<=0)return 0;let d=0;for(let f of s)f!==null&&(d+=OL(f[0],f[1],a,l,i));return d>1?c/d:c}function _8(e){let t=0;for(let n of e){let r=n.loop,o=r===void 0||r===!1?1:r===!0?1/0:r,i=n.duration??(n.patch.duration>0?n.patch.duration*o:0);if(!(i>=0))throw new RangeError(`blits: an arc's part lasts 0 ms or more, not ${i}`);i>t&&(t=i)}return t}var oT=e=>e===void 0?void 0:Array.isArray(e)?e:[e];function LL(e,t){if((t.rate??1)<0)throw new Error("blits: an arc plays its parts forward from its start, so it is not cued backward");if(t.freeze!==void 0)throw new Error("blits: an arc holds each part\u2019s first and last frames itself, so it takes no freeze");let{enter:n,active:r,exit:o,hold:i,blend:s,...a}=t,l=[oT(n),oT(r),oT(o)],u=l.map(m=>m===void 0?0:_8(m));for(let m of[0,2])if(!Number.isFinite(u[m]))throw new Error(`blits: an arc's ${L8[m]} has to end, so it cannot loop for good`);let c=i==="open"?Number.POSITIVE_INFINITY:i??u[1]??0;if(!(c>=0))throw new RangeError(`blits: an arc holds for 0 ms or more, not ${i}`);let d=s??0;if(!(d>=0&&Number.isFinite(d)))throw new RangeError(`blits: an arc blends over 0 ms or more, not ${s}`);let f=new iT(u[0],u[2],d,l.map(m=>m!==void 0),c);e.arcing=f;let p;try{p=e.owns(a)}finally{e.arcing=null}let h=[0,f.enter,f.enter+c];return l.forEach((m,g)=>{for(let b of m??[]){let{duration:x,...w}=b,y={...w,owner:p,start:h[g],freeze:"both"};g===1&&i!==void 0&&b.loop===void 0&&(y.loop=!0),e.cue(y),e.cued[e.cued.length-1].part=g}}),p}function PF(e,t){let n=t.arc;if(n===null)throw new Error("blits: release ends an arc\u2019s hold, and this is no arc");if(t.state==="done"||t.state==="fading")return;let r=Te(t,e.now),o=n.exit>0&&!e.reduced?n.blend/2:0,i=Math.max(n.enter,r+o);if(i<n.enter+t.hold){t.hold=i-n.enter;for(let s of t.holding?.children??[])s.part===2&&s.state==="pending"&&Ta(e,s,i);D8(e,t)}}function D8(e,t){Ke(e,t),t.owner?.fitting&&Ln(e,t.owner),e.lanes?.refill()}function bL(e,t){for(let n of e.owners??[]){let r=n.arc;if(r===null||n.state==="done"||n.state==="pending")continue;let o=Te(n,t);if(!Number.isFinite(o))continue;let i=dc(n);if(o>=i){let l=n.timeAt(i);n.play(!0,l,e.transport.seq),_n(e,n,l);continue}let s=FL(r,n.hold),a=e.reduced?0:r.blend/2;for(let l of[...n.holding?.children??[]]){let u=s[l.part];u==null||u[1]===i||l.state==="done"||o>=u[1]+a&&_n(e,l,n.timeAt(u[1]+a))}}}function nF(e,t,n){let r=e.arc,o=u=>{let c=e.timeAt(u);return Number.isFinite(c)?Math.max(t,c):void 0};if(n==="in"){let u=o(r.enter);return u===void 0?u:Math.max(u,t+(e.fade.in??0))}let i=o(r.enter+e.hold),s=e.out,a=s!==null?s.at:Number.isFinite(e.outAt)?e.outAt:void 0,l=a!==void 0&&(i===void 0||a<i);if(n==="coast")return l?void 0:i;if(n==="out")return l?a:e.state==="done"&&i===void 0?e.doneAt:i;if(e.state==="done")return e.doneAt;if(l){if(s!==null)return s.at+s.over;let u=Number.isNaN(e.outOver)?e.fade.out??0:e.outOver;return a+u}return o(dc(e))}function _L(e,t){let n=[],r=[];for(let s=0;s<e.length;s++){let a=t[s].rest;a!==void 0&&(n.push(e[s]),r.push(typeof a=="number"?a:void 0))}function o(){for(let s=0;s<n.length;s++)this[n[s]]=r[s]}o.prototype=Object.prototype;let i=o;return()=>new i}function DL(e,t,n,r,o){let i,s=pe.back;if(s!==null)i=(Ih(e,n,r.elapsed,s)&1)!==0;else{let f=o.run;o.freed!==e.freed&&(f=e.slot(n),o.run=f,o.freed=e.freed),e.sample(f,r.elapsed,e.xs,e.vs),i=e.scalar(f)}let a=e.xs,l=o.delta??{};if(i)return l[t]=a[0],l;let u=e.n,c=l[t],d=Array.isArray(c)&&c.length===u?c:Xn(u,0);for(let f=0;f<u;f++)d[f]=a[f];return l[t]=d,l}var BL=pa;function HL(e,t,n,r,o){o.rebuilt=t.rebuilds;let i=t.patch;i.state===void 0&&i.step===void 0&&o.kept===null||(o.state=i.state?i.state(n):void 0,o.kept=null,o.unkept=void 0,o.since=e.sinceOf(t,o.delay),o.shown=e.shownOf(t,o.since),o.ticks=0,o.stepped=o.since<r?o.since:r,o.probed=Number.NaN)}function B8(e,t,n){let r=t.patch;return r.state===void 0&&r.step===void 0&&!t.keeping?!1:e.sinceOf(t,n.delay)!==n.since}function GL(e,t,n){return e<0?N2(e,t):Or(e,t,n)}var H8=Object.freeze({});function UL(e,t,n,r){if(r.weight=0,!r.reaches)return null;let o=e.bound!==null&&r.replay===void 0&&!JF(this,e.bound,t),i=o&&e.spec.weight.input===!0&&!!this.opts.history?.inputs;if(o&&!i&&e.patch.step===void 0&&e.spec.from!=="current"||e.out?.rest&&Io(r))return null;r.rebuilt!==e.rebuilds?HL(this,e,t,n,r):r.seeks!==e.seeks&&B8(this,e,r)&&(HL(this,e,t,n,r),vP(e,r,n));let s=e.rawAt(n,r.delay),a=e.before(s,n);if(a&&!e.holdsFirst)return null;let l=e.shownAt(s);if(Number.isNaN(l))return null;let u=a?-1:e.freezesAfter&&s>e.span?1:0,c=e.duration,d=Jn(l,c,e.passes),f=this.primed;f[0]=n,f[1]=l,f[2]=d,this.prime(e,r);let p=e.setting,h=pe.kept,m=o?0:this.weigh(e,t,n,r);if(i&&om(this,e,t,r,0),pe.kept!==h&&!e.keeping&&Gi(this,e),p.weight=m,r.weight=m,r.probed===n&&r.delta&&r.seeks===e.seeks)return e.holder!==r&&e.scratch.length>0&&this.keyed(e,t,r),this.w=m,r.delta;let g=pe.kept,b=this.opts.history;if(b?.inputs&&e.patch.reads!==void 0&&!this.projecting&&IL(this,n),e.motion!==void 0&&(pe.horizon=this.horizonFor(e,r.delay,n)),e.patch.step&&r.probed!==n){let y=u===0?n:u===1?e.timeAt(r.delay+e.span):e.ranBackTo(r.delay,n),P=r.snaps,S=Number.isNaN(r.probed)&&P!==void 0;if(Number.isNaN(y))S&&sT(e,r);else{r.stepped<r.since&&(r.stepped=r.since,p.dt=this.capped(n-r.since));let v=vo(this,e);v!==void 0&&S&&G8(this,e,t,r,P,v,y),S&&sT(e,r),v!==void 0?this.tick(e,t,r,v,y):(u===0?n!==r.stepped:y>r.stepped)&&(u!==0&&(p.dt=this.capped(y-r.stepped)),e.patch.step(r.state,p.dt,t,p),r.stepped=y)}}let x=null,w=!1;if(yh(e,m)&&(e.built===null||e.spec.role===void 0))w=e.spec.role!==void 0,e.built&&e.spec.from==="current"&&r.base===void 0&&(r.base=this.baseFor(e,t),r.slope=this.slopeFor(e,t));else if(e.built)r.phase=GL(l,c,e.passes),x=this.keyed(e,t,r);else if(e.motion!==void 0)x=DL(e.motion,e.patch.writes[0],t,p,r);else{let y=GL(l,c,e.passes);x=e.patch.at(y,t,p),e.unchecked&&kL(e,x)}return r.delta=x,r.probed=n,r.seeks=e.seeks,b!==void 0&&Kh(this,e,t,r),pe.kept!==g&&!e.keeping&&Gi(this,e),x===null?w?(this.w=m,H8):null:e.out?.rest&&this.isRest(x)?(r.weight=0,r.restedAt=n,e.restedCount++,null):(this.w=m,x)}function VL(e,t,n){let r;e.spec.from==="current"&&(n.base===void 0&&(n.base=this.baseFor(e,t),n.slope=this.slopeFor(e,t)),r=n.base);let o=Lh(e.built,n.phase,n.delta??{},r,e.lerps,n.slope,e.intos,e.scratch);return n.delta=o,e.scratch.length>0&&(e.holder=n),o}function WL(e,t,n){return Math.floor((n-e.since)/t+1e-9)}function G8(e,t,n,r,o,i,s){let a=o[o.length-1],l=a?.ahead;if(a===void 0||l===void 0||l.put!==r)return;l.put=null;let u=t.patch.reads;if(e.opts.maxDt!==void 0||u!==void 0&&u.length>0)return;let c=a.held;if(r.ticks!==c.ticks||r.since!==l.since||r.rebuilt!==c.rebuilt)return;let d=l.sought,f=WL(r,i,s),p=l.state!==void 0&&l.ticks<=f;if(l.left!==void 0&&l.leftTicks<=f&&!(p&&l.ticks>l.leftTicks)){r.state=l.left,l.left=void 0,t.setting.state=r.state,r.ticks=l.leftTicks;return}p&&(r.state=Ea(t,l.state),t.setting.state=r.state,r.ticks=l.ticks);let h=p?l.at:a.at;!(d<s)||d-h<pc(e.opts.history)||(sT(t,r),e.tick(t,n,r,i,d),l.state=Ea(t,r.state),l.ticks=r.ticks,l.at=d)}function sT(e,t){let n=t.snaps,r=n[n.length-1];r!==void 0&&t.state!==void 0&&t.state===r.held.state&&(t.state=Ea(e,t.state),e.setting.state=t.state)}function zL(e,t,n,r,o){let i=this.now,s=e.setting,a=s.dt,l=n.ticks,u=WL(n,r,o),c=this.opts.maxDt;if(c!==void 0){let f=Math.floor(c/r);u-l>f&&(l=u-f)}let d=e.patch.step;for(s.dt=r,l++;l<=u;l++)s.timestamp=n.since+l*r,d(n.state,r,t,s);n.ticks=u>n.ticks?u:n.ticks,n.stepped=n.since+n.ticks*r,s.timestamp=i,s.dt=a}function KL(e,t){let n=this.lastPoses.get(t)?.pose;if(n===void 0&&!this.folding.has(e.id)){this.folding.add(e.id);try{n=this.fold(t,void 0,!1,e.id)}finally{this.folding.delete(e.id)}}let r={};for(let o of e.patch.writes){let i=this.kit[o],s=n?.[o],a=i.rest;s!==void 0?r[o]=BL(s):a!==void 0&&(r[o]=BL(a))}return r}function jL(e,t){let n=this.lastPoses.get(t);if(n?.prev===void 0||!(n.at>n.prevAt))return;let r=n.at-n.prevAt,o=n.pose,i=n.prev,s={};for(let a of e.patch.writes){let l=i[a],u=o[a];typeof l=="number"&&typeof u=="number"?s[a]=(u-l)/r:Array.isArray(l)&&Array.isArray(u)&&l.length===u.length&&(s[a]=u.map((c,d)=>(c-l[d])/r))}return s}function $L(e){for(let t of Object.keys(e)){if(e[t]===void 0)continue;let n=this.kit[t];if(n.rest===void 0||!rc(e[t],n.rest))return!1}return!0}function YL(e,t,n,r,o){if(r&&o.reaches&&o.probed===n&&o.delta&&o.seeks===e.seeks){let i=e.setting,s=e.shownAt(e.rawAt(n,o.delay));return i.timestamp=n,i.dt=0,i.elapsed=s,i.pass=Jn(s,e.duration,e.passes),i.weight=0,i.state=o.state,i.mark=0,e.keepOn=o,this.w=this.weigh(e,t,n,o),o.weight=this.w,e.holder!==o&&e.scratch.length>0&&this.keyed(e,t,o),o.delta}return this.contribution(e,t,n,o)}function qL(e){this.frame=st();let t=ut(this,e);t!==void 0&&ju(this,t);let n=this.chains.get(e)?.slot??-1;n>=0&&this.lanes!==null&&this.lanes.release(n),this.projecting&&!(this.lastPoses instanceof $u)&&(this.lastPoses=new $u(this.lastPoses)),this.projecting||this.places?.drop(e),this.lastPoses.delete(e),this.restStamps?.delete(e),this.chains.delete(e),this.stir();let r=sm(this);for(let l of this.general)this.forgetIn(l,e,r);let o=this.named.get(e);if(o!==void 0)for(let l of[...o])this.forgetIn(l,e,r);let i=Fo(this);for(let l of i.general)this.forgetIn(l,e,r);let s=i.named.get(e);if(s!==void 0)for(let l of s)this.forgetIn(l,e,r);if(this.owners!==null)for(let l of this.owners)this.forgetIn(l,e,r);for(let l of this.parters)this.forgetIn(l,e,r),l.parts?.size===0&&(l.parts=null),l.parted?.size===0&&(l.parted=null),l.parts===null&&l.parted===null&&this.parters.delete(l);let a=this.strays.get(e);if(a!==void 0)for(let l of a)this.releaseIn(l,e,r);this.strays.delete(e);for(let l of this.strayAll)this.releaseIn(l,e,r);Vr(this)&&this.recordDrop(e)}function XL(e,t,n){rT(this,e,t),e.subjects.delete(t),e.motion!==void 0&&this.releaseIn(e.motion,t,n),e.parts?.delete(t),e.parted?.delete(t),e.blend?.of.reads.delete(t)}function JL(e,t,n){this.projecting?e.holds(t)&&Sa("a drop of a subject a motion patch holds"):e.release(t,n[0],n[1],n[2],n[3])}function QL(e){Ct(this,"drop",t=>t.mix(this)?.drop(e))}var U8=Symbol("unread");function aT(e,t,n,[r,o]){for(let i=t;i<t+n;i++){let s=e[i];e[i]=s<r?r:s>o?o:s}}function V8(e,t,n){let r=n*e.axes;if(typeof t=="number"&&e.axes===1)e.out[r]=t;else if(Array.isArray(t)&&t.length===e.axes)for(let o=0;o<e.axes;o++)e.out[r+o]=t[o];else if(t===void 0)e.out.fill(Number.NaN,r,r+e.axes);else throw new TypeError(`blits: pull reads ${e.key} as ${e.axes===1?"a number":`${e.axes} numbers`} a subject, and the pose has ${String(t)}`)}function ZL(e,t,n){let r;if(n===void 0||this.wantsPose){r={};for(let o of this.names){let i=t[o];i!==void 0&&(r[o]=pa(i))}}if(r!==void 0){let o=this.lastPoses.get(e);o===void 0?this.lastPoses.set(e,{pose:r,at:this.now,prev:void 0,prevAt:Number.NaN}):o.at===this.now?o.pose=r:(o.prev=o.pose,o.prevAt=o.at,o.pose=r,o.at=this.now)}}function e_(e,t,n){let r=z8(e,n),o=e.lanes,i=e.now;e.scratch===void 0&&(e.scratch=e.pose());let s=Number.POSITIVE_INFINITY,a="";for(let x of r){let w=Math.floor(x.out.length/x.axes);w<s&&(s=w,a=x.key)}let l;if(Array.isArray(t))l=t;else{let x=[];for(let w of t)if(x.push(w)>s)break;l=x}if(l.length>s)throw new RangeError(`blits: pull's array for ${a} has room for ${s} subjects, and was given more`);let u=o!==null&&!e.wantsPose,c=e.pulled,d=e.pulledHeads;if(e.pulledSlots.length<l.length){let x=new Int32Array(Math.max(64,l.length)).fill(-1);x.set(e.pulledSlots),e.pulledSlots=x}l.length<c.length&&e.pulledSlots.fill(-1,l.length,c.length);for(let x=c.length;x<l.length;x++)c.push(U8);c.length=l.length,d.length=l.length;let f=e.version,p=e.relinks,h=!Number.isNaN(i),m=h&&e.pulledVersion===f&&e.pulledRelinks===p,g=m?Number.POSITIVE_INFINITY:h&&e.pulledVersion===f?e.pulledRelinks:-1;try{W8(e,l,r,h,m,g,u)}finally{o!==null&&o.pulls.flush(o)}let b=h&&e.version===f&&e.relinks===p;e.pulledVersion=b?f:Number.NaN,e.pulledRelinks=p}function W8(e,t,n,r,o,i,s){let a=e.lanes,l=e.now,u=e.scratch,c=e.pulled,d=e.pulledHeads,f=e.pulledSlots,p=e.version,h=r&&s;for(let m=0;m<t.length&&!(h&&(m=a.pulls.pullRun(a,f,t,c,i,m,n,l,e.version),m===t.length));m++){let g=t[m],b=-1;if(r)if(o&&c[m]===g)b=f[m];else{let S=d[m],v=c[m]===g&&S!==void 0&&S.version===p?S:e.chain(g);c[m]=g,d[m]=v,b=v.slot;let A=m===0?0:f[m-1]+1;if(h&&b>=0&&b!==A&&A>=0&&a.pulls.renumber(e,g,v,A)){for(let N=c.indexOf(g);N>=0;N=c.indexOf(g,N+1))f[N]=A;b=A}f[m]=b}let x=r&&a?.prepare(b,g,e.version,d[m]??null)===!0;if(x&&s&&a.whole&&!a.owes(b)){a.pulls.writeLater(a,b,n,m,f);continue}let w=r?d[m]:null,y=e.foldWith(g,u,w,x,!1),P=e.bounded.length===0?y:e.clamp(y);e.keep(g,P,u);for(let S of n)V8(S,P[S.key],m)}}function z8(e,t){let n=[];e.pullColumns??=new Map;let r=e.pullColumns;for(let o of Object.keys(t)){let i=t[o];if(i===void 0)continue;let s=r.get(o);if(s!==void 0){s.out=i,n.push(s);continue}let a=e.slotOf.get(o);if(a===void 0)throw new Error(`blits: pull was handed ${o}, which the kit lacks`);let l=e.channels[a],u=l.rest,c=k2(l),d=l.bounds,f=new Float64Array(c).fill(Number.NaN);typeof u=="number"?f[0]=u:Array.isArray(u)&&f.set(u),d!==void 0&&aT(f,0,c,d);let p={key:o,slot:a,axes:c,out:i,rest:f,bounds:d};r.set(o,p),n.push(p)}return n}function t_(e){e.pulled=[],e.pulledHeads=[],e.pulledSlots=new Int32Array(0),e.pulledVersion=Number.NaN,e.pulledRelinks=-1}function r_(e,t,n,r,o,i,s,a,l){if((e.filled(a,l)?1:e.begin(a,l))!==1||!e.whole)return i;let c=e.per,d=e.fills,f=e.busyFill,p=e.wide,h=e.frameProbes,m=e.subjects,g=e.unlinked,b=e.holds,x=e.owed.any(),w=o===Number.POSITIVE_INFINITY;i_(e,s,t),s_(e,e.queued+n.length-i);let y=i,P=-1,S=i;for(;y<n.length;y++){let v=n[y];if(r[y]!==v)break;let A=t[y],N=A*6;if(A<0||!w&&!(g[A]<=o)||c[N+0]>=f||c[N+2]!==0||c[N+1]<p||x&&e.owes(A))break;c[N+3]>h||c[N+4]>h||e.distinct++,c[N+3]=++e.probes,c[N+5]=d,b&&(m[A]=v),A!==P+(y-S)&&(P>=0&&uT(e,P,S,y-S),P=A,S=y)}return P>=0&&uT(e,P,S,y-S),y>i&&b&&(e.holding=!0),y}function o_(e,t,n,r,o){i_(e,n,o),uT(e,t,r,1)}function i_(e,t,n){t===e.queuedFor&&n===e.queueFrom||(Vi(e),e.queuedFor=t,e.queueFrom=n)}var n_=16;function uT(e,t,n,r){let o=e.queued;if(o>0){let i=o-1,s=e.queueCounts[i];if(n===e.queueRows[i]+s){let a=e.queueSlots[i];if(a>=0&&t===a+s){e.queueCounts[i]=s+r;return}if(r<n_&&(a<0||s<n_)){e.queueSlots[i]=-1,e.queueCounts[i]=s+r;return}}}s_(e,o+1),e.queueSlots[o]=t,e.queueRows[o]=n,e.queueCounts[o]=r,e.queued=o+1}function s_(e,t){if(t<=e.queueSlots.length)return;let n=Math.max(64,t,e.queueSlots.length*2);e.queueSlots=lT(e.queueSlots,n),e.queueRows=lT(e.queueRows,n),e.queueCounts=lT(e.queueCounts,n)}function lT(e,t){let n=new Int32Array(t);return n.set(e),n}function Vi(e){let t=e.queued,n=e.queuedFor;if(!(t===0||n===null)){e.queued=0;for(let r=0;r<n.length;r++){let o=n[r],i=e.bySlot[o.slot];if(i===void 0?K8(e,o,t):$8(e,o,i.values,t),o.bounds!==void 0)for(let s=0;s<t;s++)aT(o.out,e.queueRows[s]*o.axes,e.queueCounts[s]*o.axes,o.bounds)}}}function K8(e,t,n){let r=e.queueRows,o=e.queueCounts,i=t.out,s=t.axes;if(s===1){let a=t.rest[0];for(let l=0;l<n;l++){let u=r[l],c=u+o[l];if(c-u>64)i.fill(a,u,c);else for(let d=u;d<c;d++)i[d]=a}return}for(let a=0;a<n;a++){let l=r[a]*s,u=l+o[a]*s;for(let c=l;c<u;c+=s)for(let d=0;d<s;d++)i[c+d]=t.rest[d]}}var j8=256;function $8(e,t,n,r){let o=e.queueSlots,i=e.queueRows,s=e.queueCounts,a=t.out,l=t.axes,u=e.queueFrom;for(let c=0;c<r;c++){let d=o[c];if(d<0){let m=i[c],g=m+s[c];if(l===1)for(let b=m;b<g;b++)a[b]=n[u[b]];else for(let b=m;b<g;b++){let x=b*l,w=u[b]*l;for(let y=0;y<l;y++)a[x+y]=n[w+y]}continue}let f=i[c]*l,p=d*l,h=s[c]*l;if(h>j8)a.set(n.subarray(p,p+h),f);else for(let m=0;m<h;m++)a[f+m]=n[p+m]}}function u_(e,t){this.copier===null&&(this.copier=Y8(this.laned)),this.copier(t,e)}function c_(e,t,n){let r=e.start,o=e.axes,i=t*o;if(Array.isArray(n)&&n!==r&&n.length===(r.length>o?r.length:o)){for(let a=0;a<o;a++)n[a]=e.values[i+a];for(let a=o;a<r.length;a++)n[a]=r[a];return n}let s=[...r];for(let a=0;a<o;a++)s[a]=e.values[i+a];return s}var a_=new Map,l_=!1;function Y8(e){let t=[];for(let o=0;o<e.length;o++){let i=e[o],s=`o[${JSON.stringify(i.name)}]`,a=i.scalar?"s":`s * ${i.axes}`,l=`if (${s} !== undefined) ${s} = undefined;`,u=i.scalar?`${s} = v;`:`{ const h = ${s}, a = f(c${o}, s, h); if (a !== h) ${s} = a; }`;t.push(`{ const v = c${o}.values[${a}];`),t.push(i.op==="last"?`if (v !== v) { ${l} } else ${u} }`:`${u} }`)}let n=t.join(`
427
- `),r=a_.get(n);if(r===void 0&&!l_){let o=e.map((i,s)=>`const c${s} = chans[${s}];`).join(" ");try{r=new Function("chans","f",`${o}
426
+ `),defines:r}}function DC(e){return e.match(/[A-Za-z_]\w*|\d[\w.]*|\S/g)??[]}function bj(e){let t=/^(?:0[xX]([0-9a-fA-F]+)|(0[0-7]*)|([1-9]\d*))[uU]?$/.exec(e);return t?t[1]!==void 0?parseInt(t[1],16):t[2]!==void 0?parseInt(t[2],8):parseInt(t[3],10):null}function BC(e,t){let n=0,r=()=>{let a=e[n++];if(a==="("){let l=i();return e[n++]===")"?l:null}if(a==="-"){let l=r();return l===null?null:-l}return a==="+"?r():a===void 0?null:bj(a)??(Ew.test(a)?t(a):null)},o=()=>{let a=r();for(;a!==null&&(e[n]==="*"||e[n]==="/"||e[n]==="%");){let l=e[n++],u=r();if(u===null||l!=="*"&&u===0)return null;a=l==="*"?a*u:l==="/"?Math.trunc(a/u):a%u}return a},i=()=>{let a=o();for(;a!==null&&(e[n]==="+"||e[n]==="-");){let l=e[n++],u=o();if(u===null)return null;a=l==="+"?a+u:a-u}return a},s=i();return n===e.length&&s!==null&&s>=0?s:null}function xj(e,t){return[...bC,...Mw(e),...Mw(t)]}function Ow(e,t){let n=t.vert===""?yC:t.vert,r=new Jr(e,n,t.frag);return r.lookupUniforms(xj(n,t.frag)),r.lookupUniformArrays(new Map([...Cw(n),...Cw(t.frag)])),r.lookupAttributes(gC),r}var UC={composited:0,redrawn:0,declined:0,bytes:0};function nh(){return typeof performance<"u"?performance.now():Date.now()}var wj={pattern:[SA,RA],gradient:[kA,NA],texture:[vA,IA]},ju=class{gl;stats={drawCalls:0,ms:0,spans:[],retained:UC};pathFill;pathFillVColor;batchFill;batchVariants;gradFill;patternFill;glyphPaintPrograms=new Map;meshCache;textureCache;imageCache;gradRamps;programRegistry=new Map;programSources=new Map;quadVbo=null;quadIbo=null;drawBatch;whiteTexture=null;groupState=new gf;widthCss;heightCss;dpr;canvas=null;lossTarget=null;target=null;effectTargets;retained;programEpoch=0;paintScratch;imageMinification;flattenTolerance;bakeBudget;textOutlineMinScreenSize;contextLost=!1;boundOnLost=t=>this.onContextLost(t);boundOnRestored=()=>this.onContextRestored();disposed=!1;paintResources=tl();constructor(t){if(!t.gl&&!t.canvas)throw new Error("WeaselRenderer requires either gl or canvas");let n=t.gl??t.canvas.getContext("webgl2",{stencil:!0});if(!n)throw new Error("WeaselRenderer: WebGL2 not available");this.gl=n,this.effectTargets=new eh(this.gl),this.retained=new th(this.gl,t.retainBudget??402653184),this.paintScratch=new Zd(this.gl);let r=typeof this.gl.getContextAttributes=="function"?this.gl.getContextAttributes():null;if(r&&r.stencil===!1)throw new Error("WeaselRenderer: the supplied WebGL2 context has no stencil buffer. Create it with { stencil: true } \u2014 clips and even-odd fills need one.");this.widthCss=t.width,this.heightCss=t.height,this.dpr=t.dpr,this.imageMinification=t.imageMinification??"auto",this.flattenTolerance=t.flattenTolerance,this.bakeBudget=t.bakeBudget??Jo,this.textOutlineMinScreenSize=t.textOutlineMinScreenSize??Qp,this.canvas=t.canvas??null,this.canvas&&(this.canvas.width=Math.round(t.width*t.dpr),this.canvas.height=Math.round(t.height*t.dpr));let o=this.canvas??this.gl.canvas??null;o&&typeof o.addEventListener=="function"&&(this.lossTarget=o,this.lossTarget.addEventListener("webglcontextlost",this.boundOnLost),this.lossTarget.addEventListener("webglcontextrestored",this.boundOnRestored)),this.applyGlState(),this.applyTarget(),this.pathFill=new An(this.gl,bA),this.pathFillVColor=new An(this.gl,xA),this.gradFill=new An(this.gl,wA),this.patternFill=new An(this.gl,PA),this.batchVariants=new Jd(this.gl),this.batchFill=rb(this.gl),this.meshCache=new Hl(this.gl),this.textureCache=new Ul(this.gl),this.imageCache=new Ms(this.gl,this.imageMinification),this.gradRamps=new $l(this.gl),this.uploadQuadGeometry(),this.drawBatch=new Ku(this.gl,this.batchFill),this.whiteTexture=Nw(this.gl)}lazyPrograms(){return[this.pathFill,this.pathFillVColor,this.gradFill,this.patternFill,...this.batchVariants.lazy()]}uploadQuadGeometry(){let t=this.gl;if(this.quadVbo=t.createBuffer(),this.quadIbo=t.createBuffer(),!this.quadVbo||!this.quadIbo)throw new Error("WeaselRenderer: failed to create quad geometry buffers");t.bindBuffer(t.ARRAY_BUFFER,this.quadVbo),t.bufferData(t.ARRAY_BUFFER,xC,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.quadIbo),t.bufferData(t.ELEMENT_ARRAY_BUFFER,wC,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}registerProgram(t){if(this.disposed)return;let n=Nn(t.id);if(!n)throw new Error(`WeaselRenderer.registerProgram: program "${t.id}" not found in source registry. Call the module-level registerProgram() first.`);this.installProgram(t.id,n,Ow(this.gl,n))}installProgram(t,n,r){let o=this.programRegistry.get(t);o&&(this.gl.deleteProgram(o.handle),this.programEpoch++),this.programRegistry.set(t,r),this.programSources.set(t,n)}refreshPrograms(){for(let[t,n]of this.programSources){let r=Nn(t);if(!(!r||r===n)){if(r.vert===n.vert&&r.frag===n.frag){this.programSources.set(t,r);continue}try{this.installProgram(t,r,Ow(this.gl,r))}catch(o){this.programSources.set(t,r),console.error(`weasel: failed to recompile re-registered program "${t}"; still drawing the previous one:`,o)}}}}ensureProgram(t){let n=this.programRegistry.get(t);if(n)return n;if(this.disposed||!Nn(t))return null;try{this.registerProgram({id:t})}catch(r){return console.error(`weasel: failed to compile paint program "${t}":`,r),null}return this.programRegistry.get(t)??null}glyphPaintProgram(t){let n=this.glyphPaintPrograms.get(t);if(n)return n;let[r,o]=wj[t],i=new Jr(this.gl,TA,r);return i.lookupUniforms(o),i.lookupAttributes(EA),this.glyphPaintPrograms.set(t,i),i}applyGlState(){let t=this.gl;t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.clearColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.bindVertexArray(null),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1)}deviceRect(){let t=this.target?.origin.x??0,n=this.target?.origin.y??0,r=Math.round(t*this.dpr),o=Math.round(n*this.dpr),i=Math.round((t+this.widthCss)*this.dpr)-r;return{x:r,y:o,width:i,height:Math.round((n+this.heightCss)*this.dpr)-o}}applyTarget(){let t=this.gl,{x:n,y:r,width:o,height:i}=this.glRect();if(t.viewport(n,r,o,i),!this.target){t.disable(t.SCISSOR_TEST);return}t.scissor(n,r,o,i),t.enable(t.SCISSOR_TEST)}glRect(){let{x:t,y:n,width:r,height:o}=this.deviceRect();return this.target?{x:t,y:this.gl.drawingBufferHeight-n-o,width:r,height:o}:{x:0,y:0,width:r,height:o}}setTarget(t){this.target=t,this.applyTarget()}getTarget(){return this.target}isContextLost(){return this.contextLost}onContextLost(t){t.preventDefault(),this.contextLost=!0}onContextRestored(){this.contextLost=!1,this.applyGlState(),this.applyTarget(),this.effectTargets.releaseAll(),this.retained.releaseAll(),this.paintScratch.release(),this.paintResources.release(),this.paintResources=tl();for(let t of this.lazyPrograms())t.abandon();this.batchFill=rb(this.gl),this.glyphPaintPrograms.clear(),this.meshCache=new Hl(this.gl),this.textureCache=new Ul(this.gl),this.imageCache.abandon(),this.imageCache=new Ms(this.gl,this.imageMinification),this.gradRamps=new $l(this.gl),this.uploadQuadGeometry(),this.drawBatch=new Ku(this.gl,this.batchFill),this.whiteTexture=Nw(this.gl);for(let t of this.programRegistry.keys()){let n=Nn(t);if(n)try{this.programRegistry.set(t,Ow(this.gl,n)),this.programSources.set(t,n)}catch(r){console.error(`weasel: failed to recompile program "${t}" after context restore:`,r)}}}dispose(){if(this.disposed)return;this.disposed=!0;let t=this.gl;this.lossTarget&&(this.lossTarget.removeEventListener("webglcontextlost",this.boundOnLost),this.lossTarget.removeEventListener("webglcontextrestored",this.boundOnRestored)),this.meshCache.dispose(),this.paintResources.release();for(let n of this.lazyPrograms())n.release();for(let n of[this.batchFill,...this.glyphPaintPrograms.values()])t.deleteProgram(n.handle);this.glyphPaintPrograms.clear();for(let n of this.programRegistry.values())t.deleteProgram(n.handle);this.programRegistry.clear(),this.programSources.clear(),this.textureCache.free(),this.imageCache.dispose(),this.gradRamps.free(),this.quadVbo&&t.deleteBuffer(this.quadVbo),this.quadIbo&&t.deleteBuffer(this.quadIbo),this.drawBatch.dispose(),this.whiteTexture&&t.deleteTexture(this.whiteTexture),this.whiteTexture=null,this.effectTargets.releaseAll(),this.retained.releaseAll(),this.paintScratch.release()}render(t,n,r){if(this.contextLost||this.disposed)return;let o=nh(),i={drawCalls:0},s=[];this.stats={drawCalls:0,ms:0,spans:s,retained:UC};let a=this.gl;this.meshCache.drainPendingDeletes(),this.imageCache.beginFrame(),this.textureCache.sweep(pi),this.refreshPrograms(),this.retained.beginFrame([qo(),pi.getVersion(),Bu.getVersion(),this.programEpoch,this.flattenTolerance,this.widthCss,this.heightCss,this.dpr]),od(this.bakeBudget),this.groupState.reset(),this.drawBatch.reset(),this.effectTargets.reclaim(),a.bindFramebuffer(a.FRAMEBUFFER,null),this.applyGlState(),this.applyTarget(),this.target?.clear!==!1&&(a.stencilMask(255),a.clear(a.COLOR_BUFFER_BIT|a.STENCIL_BUFFER_BIT));let l=this.deviceRect(),u=this.glRect(),{pathFill:c,pathFillVColor:d,gradFill:f,patternFill:p}=this,h={gl:a,get pathFill(){return c.get()},get pathFillVColor(){return d.get()},batchFill:this.batchFill,batchVariants:this.batchVariants,get gradFill(){return f.get()},get patternFill(){return p.get()},meshCache:this.meshCache,textureCache:this.textureCache,imageCache:this.imageCache,gradRamps:this.gradRamps,programRegistry:this.programRegistry,ensureProgram:x=>this.ensureProgram(x),glyphPaintProgram:x=>this.glyphPaintProgram(x),quadVbo:this.quadVbo,quadIbo:this.quadIbo,drawBatch:this.drawBatch,whiteTexture:this.whiteTexture,state:this.groupState,widthCss:this.widthCss,heightCss:this.heightCss,clipDepth:0,clipStack:[],flattenTolerance:lR(this.flattenTolerance,this.dpr),textOutlineMinScreenSize:this.textOutlineMinScreenSize,viewMatrix:n,screenMatrix:r?.screen,effectTargets:this.effectTargets,retained:this.retained,paintScratch:this.paintScratch,renderTarget:null,fragOrigin:[u.x,u.y],deviceWidth:l.width,deviceHeight:l.height,restoreTargetRect:()=>this.applyTarget(),paintResources:this.paintResources,stats:i};this.drawBatch.clip=null;let m=r?.spans??[],g=0;for(let x=0;x<m.length;x++){let w=m[x];for(;g<w.start;g++)_i(h,t[g]);let y=i.drawCalls,P=nh();for(;g<w.end;g++)_i(h,t[g]);x===m.length-1&&g>=t.length&&ye(h),s.push({id:w.id,drawCalls:i.drawCalls-y,ms:nh()-P})}for(;g<t.length;g++)_i(h,t[g]);ye(h),this.meshCache.freeTransient();let b=this.retained;b.endFrame(),this.stats.retained={composited:b.composited,redrawn:b.redrawn,declined:b.declined,bytes:b.bytes},this.stats.drawCalls=i.drawCalls,this.stats.ms=nh()-o}lastFrameStats(){return this.stats}setFlattenTolerance(t){this.flattenTolerance=t}setRetainBudget(t){this.retained.setBudget(t??402653184)}setImageMinification(t){let n=t??"auto";n!==this.imageMinification&&(this.imageMinification=n,this.imageCache.dispose(),this.imageCache=new Ms(this.gl,n))}resize(t){this.widthCss=t.width,this.heightCss=t.height,this.dpr=t.dpr,this.canvas&&(this.canvas.width=Math.round(t.width*t.dpr),this.canvas.height=Math.round(t.height*t.dpr)),this.applyTarget()}_gl(){return this.gl}_pathFill(){return this.pathFill.get()}_pathFillVColor(){return this.pathFillVColor.get()}_drawBatch(){return this.drawBatch}_batchFill(){return this.batchFill}_batchVariants(){return this.batchVariants}_gradFill(){return this.gradFill.get()}_patternFill(){return this.patternFill.get()}_meshCache(){return this.meshCache}_textureCache(){return this.textureCache}_imageCache(){return this.imageCache}_gradRamps(){return this.gradRamps}_groupState(){return this.groupState}_widthCss(){return this.widthCss}_heightCss(){return this.heightCss}_dpr(){return this.dpr}};Pe();var Pj={...Ie};function Fw(e,t,n,r,o,i,s,a,l,u=1){let c=Qf(Pj,r,a,u);return{kind:"text",x:e,y:t,runs:xu(n,c,u),align:c.align,direction:c.direction,justify:c.align==="justify",maxWidth:o,style:r??{},height:i,verticalAlign:s,width:l}}function Lw(e,t=1){let{runs:n,opts:r}=Sp(e,t);return{kind:"text",x:e.x,y:e.y,runs:Tj(n,e),align:r.align,direction:r.direction,justify:r.justify,maxWidth:r.maxWidth,width:r.alignWidth,style:e.style??{},height:e.height,verticalAlign:e.verticalAlign}}function Tj(e,t){return e.every(n=>WC(n.fill?.paint)&&WC(n.stroke?.paint))?e:e.map(n=>{let r=n.fill&&Vt(n.fill,t),o=n.stroke?.paint&&Oi(n.stroke.paint,t);return{...n,fill:r,stroke:n.stroke&&{...n.stroke,paint:o||void 0}}})}function WC(e){return e==null||Ht(e)}function VC(e){return typeof e=="number"?{x:e,y:e}:e}function _w(e,t){let n=VC(t.pan),r=VC(t.zoom??1),o=t.anchor??{x:0,y:0};return{x:o.x+(e.x-o.x)*n.x,y:o.y+(e.y-o.y)*n.y,scale:{x:1+(e.scale.x-1)*r.x,y:1+(e.scale.y-1)*r.y}}}function rh(e,t){let n=_w(e,t),r=e.scale.x/n.scale.x,o=e.scale.y/n.scale.y;return{scale:{x:r,y:o},offset:{x:n.x-r*e.x,y:n.y-o*e.y}}}function Dw(e,t){return{x:t.x*e.scale.x+e.offset.x,y:t.y*e.scale.y+e.offset.y}}function Sj(e,t){let n=t({x:e.x,y:e.y}),r=t({x:e.x+e.width,y:e.y+e.height});return{x:Math.min(n.x,r.x),y:Math.min(n.y,r.y),width:Math.abs(r.x-n.x),height:Math.abs(r.y-n.y)}}function KC(e,t){return{...t,...Sj(t,n=>Dw(e,n))}}function Bw(e,t){if(e===t)return null;let n=e??zC,r=t??zC,o=r.scale.x/n.scale.x,i=r.scale.y/n.scale.y,s={scale:{x:o,y:i},offset:{x:r.offset.x-n.offset.x*o,y:r.offset.y-n.offset.y*i}};return s.scale.x===1&&s.scale.y===1&&s.offset.x===0&&s.offset.y===0?null:s}var zC={scale:{x:1,y:1},offset:{x:0,y:0}};function Hw(e){return[e.scale.x,0,0,e.scale.y,e.offset.x,e.offset.y]}var kj=["weasel.debug","weaseldraw.debug"],Gw=null;function vj(){let e={all:!1,set:new Set};if(typeof localStorage>"u")return e;try{for(let t of kj){let n=localStorage.getItem(t);if(!(n==null||n===""))return n==="1"||n==="true"||n==="*"?{all:!0,set:new Set}:{all:!1,set:new Set(n.split(/[\s,]+/).filter(Boolean))}}return e}catch{return e}}function Aj(){return Gw===null&&(Gw=vj()),Gw}function oh(e){let t=Aj();return t.all?!0:e===void 0?t.set.size>0:t.set.has(e)}function ih(e,...t){oh(e)&&console.debug(`[${e}]`,...t)}function It(e,...t){oh(e)&&console.warn(`[${e}]`,...t)}Z();function Et(e){return e.closure!=="identity"}function zt(e,t,n){let r=[t],o=new Set([t]),i=e.getParent(t);for(;i!==null&&!o.has(i);)o.add(i),(e.definesFrame?.(i)??!0)&&r.push(i),i=e.getParent(i);let s=e.getPose(r[r.length-1]),a=e.childFrame;for(let l=r.length-2;l>=0;l--){let u=a===void 0?s:a.call(e,r[l+1],s);s=n(u,e.getPose(r[l]))}return s}function aa(e,t,n){return $C(e,t,zt(e,t,n))}function $C(e,t,n){return e.childFrame===void 0||!(e.definesFrame?.(t)??!0)?n:e.childFrame(t,n)}function la(e,t,n,r,o){let i=qn(e,n);return i===null?t:o(aa(e,i,r),t)}function qn(e,t){let n=new Set,r=t;for(;r!==null&&!n.has(r);){if(e.definesFrame?.(r)??!0)return r;n.add(r),r=e.getParent(r)}return null}var jC=new WeakMap;function YC(e){let t=jC.get(e);if(t!==void 0)return t;let n=new WeakMap,r=(o,i)=>{if(typeof o!="object"||o===null||typeof i!="object"||i===null)return e(o,i);let s=n.get(o);s===void 0&&n.set(o,s=new WeakMap);let a=s.get(i);return a===void 0&&s.set(i,a=e(o,i)),a};return jC.set(e,r),r}function qC(e,t,n){return{...e,x:e.x+t,y:e.y+n}}function Uw(e,t){return t===0&&e.rotation===void 0?e:{...e,rotation:t}}function XC(e,t,n){let[r,o,i,s]=ht(yl(-t),n),a=Math.abs(r-1)<1e-12&&Math.abs(o)<1e-12&&Math.abs(i)<1e-12&&Math.abs(s-1)<1e-12,l=Uw({...e},t);return a?delete l.transform:l.transform=[r,o,i,s],l}function JC(e,t,n){return{...e,x:t-e.width/2,y:n-e.height/2}}var QC=[1,0,0,1,0,0];function ZC(e,t,n,r,o){let i=Math.cos(n),s=Math.sin(n);return[e+(r-e)*i-(o-t)*s,t+(r-e)*s+(o-t)*i]}function Rj(e,t){let n=e.rotation??0,r=Vn(e)&&Ce(e);if(r){let[s,a]=wn(r,e.x+t.x+t.width/2,e.y+t.y+t.height/2),l=ht(r,Ce(t)??QC);return XC(JC(t,s,a),(t.rotation??0)+n,l)}let[o,i]=ZC(e.x+e.width/2,e.y+e.height/2,n,e.x+t.x+t.width/2,e.y+t.y+t.height/2);return Uw({...t,x:o-t.width/2,y:i-t.height/2},(t.rotation??0)+n)}function Nj(e,t){let n=e.rotation??0,r=Vn(e)&&ui(e);if(r){let[s,a]=wn(r,t.x+t.width/2,t.y+t.height/2),l=ht(r,Ce(t)??QC);return XC(JC(t,s-e.x,a-e.y),(t.rotation??0)-n,l)}let[o,i]=ZC(e.x+e.width/2,e.y+e.height/2,-n,t.x+t.width/2,t.y+t.height/2);return Uw({...t,x:o-e.x-t.width/2,y:i-e.y-t.height/2},(t.rotation??0)-n)}function Ij(e,t){return qC(e,-t.x,-t.y)}function Ej(e,t){let n=Ce(e);if(!n)return Ij(e,t);let[r,o,i,s]=n;return qC(e,-(r*t.x+i*t.y),-(o*t.x+s*t.y))}var sh={compose:Rj,decompose:Nj,closure:"rigid",scroll:Ej};var ua=!1;function e2(){ua=!0}function t2(e){let t=ua;ua=!1;try{return{value:e(),fonts:ua}}finally{ua=t||ua}}function Ww(){return rl()}var n2=4;function Vw(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ah(e,t=n2){if(t<=0)return e;if(Array.isArray(e))return e.map(n=>ah(n,t-1));if(Vw(e))return e.slice();if(Zt(e)){let n={...e};for(let r in n){let o=n[r];typeof o=="object"&&o!==null&&(n[r]=ah(o,t-1))}return n}return e}function No(e,t,n=n2){if(e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return Object.is(e,t);if(n<=0)return!1;let r=Object.getPrototypeOf(e);if(ts(r)){if(!ts(Object.getPrototypeOf(t)))return!1;let o=e,i=t,s=0;for(let a in o){s++;let l=o[a],u=i[a];if(l===u){if(u===void 0&&!(a in i))return!1;continue}if(!No(l,u,n-1))return!1}for(let a in i)if(--s<0)return!1;return!0}if(Array.isArray(e)||Vw(e)){let o=e;if(!(Array.isArray(t)||Vw(t)))return!1;let i=t;if(o.length!==i.length)return!1;for(let s=0;s<o.length;s++)if(!No(o[s],i[s],n-1))return!1;return!0}return!1}function $u(){return{nodes:[],poses:[],data:[],layers:[],paths:[],children:[],faces:null}}var zw=class{constructor(t,n,r){this.dep=t;this.record=n;this.index=r;this.node=t.node,this.pose=t.pose}dep;record;index;node;pose;get path(){return this.record.paths[this.index]=this.dep.path}get inherited(){return this.dep.inherited}get children(){let t=this.dep.children;if(t===void 0)return;let n=this.record.children[this.index]=$u();return r2(n,t)}};function r2(e,t){return e.nodes.length=0,e.poses.length=0,e.data.length=0,e.layers.length=0,e.paths.length=0,e.children.length=0,t.map((n,r)=>(e.nodes.push(n?.node),e.poses.push(n===void 0?void 0:ah(n.pose)),e.data.push(n?.node.data),e.layers.push(n?.node.layer),e.paths.push(void 0),e.children.push(void 0),n===void 0?void 0:new zw(n,e,r)))}function lh(e,t,n){let r=r2(e,t),o=Ww(),{value:i,fonts:s}=t2(()=>n(r));return e.faces=s?o:null,i}function uh(e,t,n){if(e.nodes.length!==t.length||e.faces!==null&&e.faces!==Ww())return!1;for(let r=0;r<t.length;r++)if(!o2(e,r,n(t[r])))return!1;return e.faces!==null&&e2(),!0}function o2(e,t,n){if(e.nodes[t]!==(n===void 0?void 0:n.node))return!1;if(n===void 0)return!0;if(e.data[t]!==n.node.data||e.layers[t]!==n.node.layer||!No(e.poses[t],n.pose))return!1;let r=e.paths[t];if(r!==void 0&&r!==n.path)return!1;let o=e.children[t];if(o===void 0)return!0;let i=n.children;return i===void 0||i.length!==o.nodes.length?!1:i.every((s,a)=>o2(o,a,s))}Z();Z();Pe();function i2(e,t,n){return{fill:Ne(e.fill,Ne(t?.fill,n?.fill)),stroke:Re(e.stroke,Re(t?.stroke,n?.stroke))}}var s2=new WeakMap;function a2(e){if(e.length===0)return null;let t=e.length===1?e[0].path:Mj(e.map(r=>r.path)),n=t===e[0].path?{...t}:t;return s2.set(n,e),n}function ch(e){return e==null?void 0:s2.get(e)}function Mj(e){return Jy(e.map(t=>t.kind==="rect"?Eg(ai(t)):t))}function u2(e,t,n,r,o){if(e===void 0||!Et(e))return null;let i={getPose:a=>r(a),getParent:a=>n(a)?.parent??null,definesFrame:a=>o(a)},s=qn(i,t.parent??null);return(a,l)=>{let u=qn(i,n(a)?.parent??null);if(u===s)return l;let c=u===null?l:e.compose(zt(i,u,e.compose),l);return s===null?c:e.decompose(zt(i,s,e.compose),c)}}function ca(e){let t=e;return typeof t=="object"&&t!==null&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"}function dh(e,t,n){return!ca(t)||!ca(n)||t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height?e:Yu(e,hr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height))}function c2(e,t,n){if(!ca(t)||!ca(n))return e;let r=ui(t),o=Ce(n),i=hr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height);return r!==null&&(i=ht(i,r)),o!==null&&(i=ht(o,i)),Yu(e,i)}function fh(e,t,n){if(!ca(t)||!ca(n))return e;let r=Ce(n),o=t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height;if(r===null&&o)return e;let i=hr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height);return Yu(e,r===null?i:ht(r,i))}function Yu(e,t){let n=t.join(","),r=l2.get(e);if(r?.key===n)return r.path;let o=ch(e),i=o===void 0?Rt(e,t):a2(o.map(s=>({...s,path:Rt(s.path,t)})));return l2.set(e,{key:n,path:i}),i}var l2=new WeakMap;var ph=Object.freeze([]);var qu=e=>Array.isArray(e?.dependsOn)?e.dependsOn:ph;function hh(e,t){let n=e.dependsOn;return n===void 0?ph:n==="children"?t(e.id):n}function d2(){let e=new Map,t=new Map;function n(r){let o=t.get(r);if(o!==void 0){for(let i of o){let s=e.get(i);s!==void 0&&(s.delete(r),s.size===0&&e.delete(i))}t.delete(r)}}return{add(r,o){if(n(r),o.length!==0){t.set(r,[...o]);for(let i of o){let s=e.get(i);s===void 0&&(s=new Set,e.set(i,s)),s.add(r)}}},remove(r){n(r)},clear(){e.clear(),t.clear()},isEmpty(){return e.size===0},dependentsOf(r){let o=e.get(r);return o===void 0?ph:[...o]},transitiveDependentsOf(r){let o=e.get(r);if(o===void 0)return ph;let i=new Set,s=[...o];for(;s.length>0;){let a=s.pop();if(!i.has(a)){i.add(a);for(let l of e.get(a)??[])s.push(l)}}return i}}}function f2(e,t){if(e===t)return!0;if(e===void 0||t===void 0||e==="children"||t==="children"||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function p2(){return new WeakMap}var da=new WeakMap,Or=0;function rt(e,t,n,r,o){if(typeof t!="string")return Cj(e,t,n,r,o);let i=da.get(e);i===void 0?(i={generation:Or,slots:new Map,drops:0},da.set(e,i)):i.generation!==Or&&(i.generation=Or,i.slots.clear());let s=e.data,a=i.slots.get(t);if(a!==void 0&&a.pose===n&&a.data===s&&a.also===o)return a.value;let l=r();return a!==void 0?(a.pose=n,a.data=s,a.also=o,a.value=l):i.slots.set(t,{pose:n,data:s,also:o,value:l}),l}function Cj(e,t,n,r,o){let i=t,s=e.data,a=da.get(e)?.drops??0,l=i.get(e);if(l!==void 0&&l.generation===Or&&l.pose===n&&l.data===s&&l.also===o&&(n===void 0||l.drops===a))return l.value;let u=r(),c=da.get(e)?.drops??0;return l!==void 0?(l.pose=n,l.data=s,l.also=o,l.value=u,l.generation=Or,l.drops=c):i.set(e,{pose:n,data:s,also:o,value:u,generation:Or,drops:c}),u}function Xu(){Or++}function h2(){return Or}function un(e){let t=da.get(e);if(t===void 0){da.set(e,{generation:Or,slots:new Map,drops:1});return}t.drops++;for(let[n,r]of t.slots)r.pose!==void 0&&t.slots.delete(n)}var Oj="kit:derivedPath",Kw=new Set,jw=0;function Fr(e,t,n,r=Oj){let o=e.derivePath;if(o===void 0)return null;let i=hh(e,n);if(i.length===0)return null;if(Kw.has(e.id))return jw++,null;Kw.add(e.id);let s=jw;try{let a=!1,l=rt(e,r,e.pose,()=>(a=!0,m2(e,o,i.map(t),{...$u(),path:null})));return!a&&!uh(l,i,t)&&m2(e,o,i.map(t),l),jw!==s&&un(e),l.path}finally{Kw.delete(e.id)}}function m2(e,t,n,r){return r.path=lh(r,n,o=>t(e,o)),r}Pe();function Ju(e){let t=e.data;return t?.fill===rn||t?.stroke===rn}var y2=new WeakMap;function fa(e,t){let n=e.data,r=n?.fill===rn,o=n?.stroke===rn,i=null,s=null;for(let u of t){if(!r&&!o)break;let c=u.data;r&&c?.fill!==rn&&(i=Ne(c?.fill),r=!1),o&&c?.stroke!==rn&&(s=Re(c?.stroke),o=!1)}let a=y2.get(e);if(a!==void 0&&a.fill===i&&a.stroke===s)return a;let l={fill:i,stroke:s};return y2.set(e,l),l}function pa(e,t){if(Ju(t))return fa(t,g2(n=>e.get(n),t))}function*g2(e,t){let n=new Set,r=t.parent??null;for(;r!==null&&!n.has(r);){n.add(r);let o=e(r);if(o===void 0)return;yield o,r=o.parent??null}}var Qu=()=>{throw new Error("documentOf: the document reading holds no overrides; write them to the scene")},Fj=Object.freeze({set:Qu,get:()=>{},read:e=>{},has:()=>!1,ids:()=>[],clear:Qu,clearAll:Qu,commit:Qu,subscribe:()=>()=>{},getGeneration:()=>0,hold:()=>Qu()});function mh(e){return e.overrides===Fj}var x2=Symbol("weasel.shownData"),$w=new WeakMap;function Tt(e,t){if(x2 in t)return t;let n=e.read(t.id)?.data;if(n===void 0)return t;let r=$w.get(t);if(r!==void 0&&r.data===n&&r.stored===t.data)return r.shown;let o=Lj(t,n(t.data));return $w.set(t,{stored:t.data,data:n,shown:o}),o}function Lj(e,t){return{...e,data:t,[x2]:!0}}function w2(e){return $w.get(e)?.shown}function ha(e){return{get:t=>{let n=e.get(t);return n===void 0?void 0:Tt(e.overrides,n)}}}var b2=new WeakMap;function yh(e,t){let n=e.getGeneration(),r=b2.get(e);return(r===void 0||r.at!==n)&&(r={at:n,any:e.ids().some(o=>e.read(o)?.data!==void 0)},b2.set(e,r)),r.any?t.map(o=>Tt(e,o)):t}var _j={effective:"kit:derivedPose",document:"kit:derivedPose:document"},Dj={effective:void 0,document:"kit:derivedPath:document"},Yw=new Set,qw=0;function T2(e){return mh(e)?"document":"effective"}function S2(e,t,n){let r=k2(e,t,n),o=r.derivePose;if(o===void 0)return null;let i=hh(r,e.childrenOf);if(i.length===0)return null;if(Yw.has(r.id))return qw++,null;Yw.add(r.id);let s=qw;try{let a=Qw(e,r,n),l=!1,u=rt(r,_j[n],r.pose,()=>(l=!0,P2(r,o,i.map(a),{...$u(),value:null})));return!l&&!uh(u,i,a)&&P2(r,o,i.map(a),u),qw!==s&&un(r),u.value}finally{Yw.delete(r.id)}}function P2(e,t,n,r){return r.value=lh(r,n,o=>t(e,o)),r}function Jw(e,t,n){let r=T2(e);return n===void 0?Zw(e,t,r):Qw(e,n,r)(t)}function Qw(e,t,n){let r=i=>Zw(e,i,n);if(t.dependsOn==="children")return r;let o=u2(e.composition,t,i=>e.get(i),i=>eP(e,e.get(i),n),i=>{let s=e.get(i);return s===void 0||lt(s)});return o===null?r:i=>{let s=r(i);if(s===void 0)return;let a=o(i,s.pose);return a===s.pose?s:new gh(s,a)}}var gh=class{constructor(t,n){this.dep=t;this.pose=n;this.node=t.node}dep;pose;node;get path(){let t=this.dep.path;return t===null?null:c2(t,this.dep.pose,this.pose)}get inherited(){return this.dep.inherited}};function Zw(e,t,n){let r=e.get(t);if(r!==void 0)return new Xw(e,r,n)}var Xw=class{constructor(t,n,r){this.source=t;this.reading=r;let o=k2(t,n,r);this.posed=o,this.node=o;let i=r==="effective"?t.overrides.read(o.id):void 0;this.shown=i?.path,this.pose=i?.pose??S2(t,o,r)??o.pose}source;reading;node;pose;shown;posed;get path(){if(this.shown!==void 0)return fh(this.shown,this.pose,this.pose);let{source:t,reading:n}=this;return Fr(this.posed,Qw(t,this.posed,n),r=>t.childrenOf(r),Dj[n])}get inherited(){let{source:t,reading:n}=this;return pa(n==="effective"?ha(t):t,this.posed)}get children(){let{source:t,reading:n}=this,r=t.composition,o=r&&Et(r)&&lt(this.posed)?r.compose:null;return t.childrenOf(this.posed.id).map(i=>{let s=Zw(t,i,n);return s===void 0||o===null?s:new gh(s,o(this.pose,s.pose))})}};function k2(e,t,n){return n==="effective"?Tt(e.overrides,t):t}function eP(e,t,n){if(n==="effective"){let r=e.overrides.read(t.id)?.pose;if(r!==void 0)return r}return S2(e,t,n)??t.pose}function Lr(e,t){return eP(e,t,"document")}function Xn(e,t){return eP(e,t,T2(e))}function lt(e){return!Bj(e)}function Bj(e){return e.dependsOn==="children"&&e.derivePose!==void 0}Z();Z();function tP(e){let t=Ce(e);if(!t)return{x:e.x,y:e.y,width:e.width,height:e.height};let n=1/0,r=1/0,o=-1/0,i=-1/0,s=[[e.x,e.y],[e.x+e.width,e.y],[e.x+e.width,e.y+e.height],[e.x,e.y+e.height]];for(let[a,l]of s){let[u,c]=wn(t,a,l);u<n&&(n=u),u>o&&(o=u),c<r&&(r=c),c>i&&(i=c)}return{x:n,y:r,width:o-n,height:i-r}}function v2(e){let t=1/0,n=1/0,r=-1/0,o=-1/0,i=!1;for(let s of e){if(!s)continue;let a=tP(s);i=!0,a.x<t&&(t=a.x),a.y<n&&(n=a.y);let l=a.x+a.width,u=a.y+a.height;l>r&&(r=l),u>o&&(o=u)}return i?{x:t,y:n,width:r-t,height:o-n}:null}Z();function _r(e,t){return e.forNode?.(t)??e}var Mt={getBounds:e=>e,remapBounds:(e,t,n)=>{let r=t.width===0?1:n.width/t.width,o=t.height===0?1:n.height/t.height;return{...e,x:n.x+(e.x-t.x)*r,y:n.y+(e.y-t.y)*o,width:e.width*r,height:e.height*o}},fromBounds:e=>({x:e.x,y:e.y,width:e.width,height:e.height}),translate:(e,t,n)=>({...e,x:e.x+t,y:e.y+n}),lerp:(e,t,n)=>({...e,x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,width:e.width+(t.width-e.width)*n,height:e.height+(t.height-e.height)*n}),axes:e=>[e.x,e.y,e.width,e.height].every(n=>typeof n=="number")?{count:5,names:["x","y","width","height","rotation"],angles:[4],to:n=>[n.x,n.y,n.width,n.height,n.rotation??0],from:n=>{let r={...e,x:n[0],y:n[1],width:n[2],height:n[3]};return(e.rotation!==void 0||n[4]!==0)&&(r.rotation=n[4]),r},add:(n,r)=>{let o={...n,x:n.x+r[0],y:n.y+r[1],width:n.width+r[2],height:n.height+r[3]},i=(n.rotation??0)+r[4];return(n.rotation!==void 0||i!==0)&&(o.rotation=i),o},write:(n,r,o)=>{r[o]=n.x,r[o+1]=n.y,r[o+2]=n.width,r[o+3]=n.height,r[o+4]=n.rotation??0}}:null,getRotation:e=>e.rotation??0,withRotation:(e,t)=>({...e,rotation:t})},Hj={getBounds:Mt.getBounds,remapBounds:Mt.remapBounds,translate:Mt.translate,lerp:Mt.lerp,axes:Mt.axes,fromBounds:e=>({x:e.x,y:e.y,width:e.width,height:e.height,rotation:0}),getRotation:e=>e.rotation,withRotation:(e,t)=>({...e,rotation:t})};function Di(e,t){return tP(nP(e,t))}function nP(e,t){let n=t.getBounds(e),r=t.getRotation?.(e)??n.rotation??0,o=Vn(e)??Vn(n);return!r&&!o?n:{...n,...r?{rotation:r}:{},...o?{transform:o}:{}}}function rP(e,t,n,r,o){if(r.translate)return o?r.translate(e,t,n,o):r.translate(e,t,n);let i=r.getBounds(e),s={x:i.x+t,y:i.y+n,width:i.width,height:i.height};return r.remapBounds(e,i,s)}function R2(){let e=new Map,t=Me(),n=0,r=()=>{n++,t.emit()};return{get:o=>e.get(o),set(o,i){let s=e.get(o);if(i===null||i.x===0&&i.y===0&&!i.z){if(s===void 0)return;e.delete(o)}else{if(s!==void 0&&s.x===i.x&&s.y===i.y&&(s.z??0)===(i.z??0))return;e.set(o,{...i})}r()},ids:()=>e.keys(),clearAll(){e.size!==0&&(e.clear(),r())},subscribe:t.subscribe,getGeneration:()=>n}}var A2=new WeakMap;function Gj(e,t,n){if(typeof t!="object"||t===null)return e(t,n);let r=A2.get(e);r===void 0&&A2.set(e,r=new WeakMap);let o=r.get(t);if(o!==void 0&&o.offset===n)return o.out;let i=e(t,n);return r.set(t,{offset:n,out:i}),i}function oP(e){let t=e.scroll,n=e.composition?.scroll;if(!(t===void 0||n===void 0)&&!(e.overrides!==void 0&&mh(e)))return(r,o)=>{let i=t.get(r);return i===void 0?o:Gj(n,o,i)}}function bh(e,t){let n=oP(e);return n===void 0?t:{...t,childFrame:n}}function N2(e,t,n,r=()=>!1){let{poses:o,composition:i}=e,s=new Set([t]),a=new Map,l=u=>{for(let c of e.childrenOf(u)){if(r(c))continue;s.add(c);let d=o.getParent(c),f=qn(o,d);if(f===null||!s.has(f)){let p=n(zt(o,c,i.compose),c);p!==null&&a.set(c,la(o,p,d,i.compose,i.decompose))}l(c)}};return l(t),a}function I2(e,t,n="animator: `axes`"){let{count:r,names:o}=e,i=[];for(let s of t){if(typeof s=="number"){if(!Number.isInteger(s)||s<0||s>=r)throw new Error(`${n} names axis ${s} of a target with ${r}`);i.push(s);continue}if(!o)throw new Error(`${n} names "${s}" on a target whose axes have no names`);let a=i.length,l=`${s}.`;for(let u=0;u<o.length;u++)(o[u]===s||o[u].startsWith(l))&&i.push(u);if(i.length===a){let u=o.slice(0,8).map(c=>`"${c}"`).join(", ");throw new Error(`${n} names "${s}", and the target's axes are ${u}${o.length>8?", \u2026":""}`)}}return i}function Uj(e){let[t,n,r,o]=e;switch(e.length){case 1:return{add:(i,s)=>({[t]:i[t]+s[0]}),write:(i,s,a)=>{s[a]=i[t]}};case 2:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n]}};case 3:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1],[r]:i[r]+s[2]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n],s[a+2]=i[r]}};case 4:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1],[r]:i[r]+s[2],[o]:i[o]+s[3]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n],s[a+2]=i[r],s[a+3]=i[o]}};default:return null}}function Zu(e){if(typeof e=="number")return{count:1,shape:"number",to:n=>[n],from:(n,r=0)=>n[r],add:(n,r)=>n+r[0],write:(n,r,o)=>{r[o]=n}};if(Array.isArray(e))return e.every(n=>typeof n=="number")?{count:e.length,shape:`array:${e.length}`,to:n=>n.slice(),from:(n,r=0)=>{let o=new Array(e.length);for(let i=0;i<o.length;i++)o[i]=n[r+i];return o},add:(n,r)=>{let o=new Array(e.length);for(let i=0;i<o.length;i++)o[i]=n[i]+r[i];return o},write:(n,r,o)=>{for(let i=0;i<e.length;i++)r[o+i]=n[i]}}:null;if(!Zt(e))return null;let t=Object.keys(e).sort();return t.length===0||!t.every(n=>typeof e[n]=="number")?null:{count:t.length,shape:`object:${JSON.stringify(t)}`,names:t,to:n=>t.map(r=>n[r]),from:(n,r=0)=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[r+i];return o},...Uj(t)??{add:(n,r)=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[t[i]]+r[i];return o},write:(n,r,o)=>{for(let i=0;i<t.length;i++)r[o+i]=n[t[i]]}}}}var Wj=new WeakMap,iP=new Float64Array(16),E2=(e,t,n)=>1-e*(1-(1-t)*n);function Vj(e,t,n,r,o){let i=e.axes.count,{behind:s}=e;for(let a=0;a<s.length;a++){let l=s[a],{slot:u,adjust:c,kept:d,share:f}=l;if(u)for(let p=0;p<i;p++){let h=u.cols[u.at+p]+(c?c[p]:0);t[n+p]=t[n+p]+(r||d?h*E2(f[p],r?r[o+p]:0,d?d[p]:1):h)}else if(r||d){let p=l.own();for(let h=0;h<i;h++)t[n+h]=t[n+h]-p[h]*(1-E2(f[h],r?r[o+h]:0,d?d[h]:1))}}}function sP(e,t,n){let r=e.axes.count,{slot:o,adjust:i,beside:s}=e;for(let l=0;l<r;l++)t[n+l]=t[n+l]+(o?o.cols[o.at+l]:0)+i[l]+(s?s[l]:0);let a=e.holds;e.behind.length>0&&(e.row||a||e.dimmed)&&Vj(e,t,n,a?a.store.cover:null,a?a.row*r:0)}function M2(e,t){let n=e.axes.to(t),r=e.holds;if(!r)return n;let o=r.row*n.length,{store:i}=r;for(let s=0;s<n.length;s++)if(n[s]!==i.at[o+s]){i.refold(r.row);break}for(let s=0;s<n.length;s++)n[s]=n[s]+i.delta[o+s];return n}function zj(e){let t=e.get();if(e.live===0)return t;let{axes:n}=e;if(!n.add||e.holds||e.dimmed){let i=M2(e,t);return sP(e,i,0),n.from(i)}let r=n.count;iP.length<r&&(iP=new Float64Array(r));let o=iP;return o.fill(0,0,r),sP(e,o,0),n.add(t,o)}function Kj(e,t,n){let r=e.get(),{axes:o}=e,i=e.live>0;if(o.write&&!(i&&e.holds))o.write(r,t,n);else{let s=i?M2(e,r):o.to(r);for(let a=0;a<s.length;a++)t[n+a]=s[a]}i&&sP(e,t,n)}function aP(e){let t=e.axes??Zu(e.get());if(!t)throw new Error("createTarget: `axes` is required for a value that is not a number, an array of numbers, or an object of numeric fields");let n={get:e.get,set:e.set,show:e.show,publish:e.publish,axes:t,write:null,owner:null,discard:!1,held:0,holds:null,behind:[],dimmed:!1,beside:null,parts:new Set,row:null,live:0,slot:null,adjust:new Array(t.count).fill(0),stale:!1},r={read:()=>zj(n),readInto:(o,i=0)=>Kj(n,o,i),axisCount:t.count,axes:t,axisIndexes:o=>I2(t,o),committed:e.get,commit:e.set,get active(){return n.live>0},stop(o){let i=n.owner;if(i){n.discard=o?.commit===!1;try{i.stop(n)}finally{n.discard=!1}}}};return Wj.set(r,n),r}var xh="0.16.1";function wh(e){let t=Symbol.for(`@msb235/blits/${e}`),n=globalThis,r=n[t];return r===void 0&&(r=new WeakMap,n[t]=r),r}var O2={on:Number.MIN_VALUE,off:0},Ct=(e,t,n)=>e+(t-e)*n,jj=Ct,$j=wh("lerp-into@1");function Ph(e){return $j.get(e)}var Yj=(e,t)=>e+t,C2=(e,t)=>e*t,F2=(e,t)=>e*t,L2=(e,t)=>1+(e-1)*t,qj=(e,t)=>e>t?e:t,_2=wh("numeric@1");function Jn(e){return _2.get(e)}var Xj=wh("width@1");function D2(e){let t=e.rest;return Array.isArray(t)?t.length:Xj.get(e)??1}function Oe(e,t,n,r){return e==="sum"?Yj(t,C2(n,r)):e==="mul"?F2(t,L2(n,r)):e==="max"?qj(t,C2(n,r)):+n}function B2(e){let t=Jn(e);if(!(t===void 0||t.axes!==1||t.turn!==void 0||e.fold!==void 0)&&typeof e.rest=="number")return t.op==="sum"||t.op==="mul"||t.op==="max"?t.op:void 0}var Jj=(e,t)=>t===void 0?e:`${e}[${t[0]}, ${t[1]}]`;function lP(e){let t={kind:Jj("mul",e?.bounds),bounds:e?.bounds,rest:1,merge:F2,scale:L2,lerp:jj};return _2.set(t,{op:"mul",axes:1}),t}function Th(e){return{kind:e?.lerp?void 0:"last",merge:(t,n)=>n,lerp:e?.lerp??((t,n,r)=>r<.5?t:n)}}function Qn(e,t){if(e===0)return[];let n=[.5];for(let r=1;r<e;r++)n.push(.5);for(let r=0;r<e;r++)n[r]=t;return n}function H2(e){let t=e??!1;return t===!0?Number.POSITIVE_INFINITY:t===!1?1:t}var G2=(e,t,n)=>Number.isFinite(n)&&e>=t*n;function Dr(e,t,n){return t>0?G2(e,t,n)?1:e%t/t:0}function Zn(e,t,n){return t>0?G2(e,t,n)?n-1:Math.floor(e/t):0}function Sh(e,t,n,r,o,i,s=Number.POSITIVE_INFINITY){let a=t&&!t.rest&&t.at<r?t.at:r;s<a&&(a=s);let l=a-o;if(i!==null)for(let c=0;c<i.length;c+=2){let d=Math.max(i[c],o),f=Math.min(i[c+1],a);f>d&&(l-=f-d)}let u=l/e;return u>=1?1:n?n(Math.max(0,u)):Math.max(0,u)}function ma(e,t,n,r,o,i,s=null,a=null){let l=1;if(e>0&&!r&&(l*=Sh(e,t,n,o,i,a)),s&&!r){let u=s.from+(o-s.at)/s.over;u<1&&(l*=n?n(Math.max(0,u)):Math.max(0,u))}if(t&&!t.rest){if(r||t.over===0)return 0;let u=1-(o-t.at)/t.over,c=u<0?0:u>1?1:u;l*=n?n(c):c}return l}function kh(e,t,n,r){return e>=0?n&&e>r?r:e:t?0:Number.NaN}function Kt(e,t){return e===t?e!==0||1/e===1/t:Number.isNaN(e)&&Number.isNaN(t)}function Br(e){return e<0?0:e>1?1:e}function jt(e,t,n){return Br(e*(t*n))}function vh(e,t){return!(t>0)&&e.out?.rest!==!0}function ze(e,t){let n=t-e.anchorNow,r=e.ramp;if(r===null)return e.anchorElapsed+n*e.rate;if(n<=0)return e.anchorElapsed+n*r.from;let o=r.to-r.from;return n<=r.over?e.anchorElapsed+r.from*n+o*n*n/(2*r.over):e.anchorElapsed+r.from*r.over+o*r.over/2+r.to*(n-r.over)}function Cn(e,t){let n=e.anchorElapsed,r=e.ramp;if(r===null)return e.rate>0?e.anchorNow+(t-n)/e.rate:t<=n?e.anchorNow:Number.POSITIVE_INFINITY;if(t<=n)return r.from>0?e.anchorNow+(t-n)/r.from:e.anchorNow;let o=(r.to-r.from)/(2*r.over),i=n+r.from*r.over+o*r.over*r.over,s=r.from>0&&r.to<0?n-r.from*r.from/(4*o):i;if(t<=s){let a=n-t,l=Math.abs(o)<1e-12?-a/r.from:(-r.from+Math.sqrt(Math.max(0,r.from*r.from-4*o*a)))/(2*o);return e.anchorNow+l}return r.to<=0?Number.POSITIVE_INFINITY:e.anchorNow+r.over+(t-i)/r.to}function ec(e,t){let n=e.ramp;return Cn({anchorNow:e.anchorNow,anchorElapsed:-e.anchorElapsed,rate:-e.rate,ramp:n===null?null:{from:-n.from,to:-n.to,over:n.over}},-t)}function U2(e,t){if(!(t>0))return 0;let n=e%t;return(n<0?n+t:n)/t}function ya(e,t){let n=e.ramp;if(n===null)return e.rate;let r=(t-e.anchorNow)/n.over;return r>=1?n.to:r<=0?n.from:n.from+(n.to-n.from)*r}function uP(e,t){let n=ya(e,t);e.anchorElapsed=ze(e,t);let r=e.ramp;if(r!==null){let o=e.anchorNow+r.over-t;e.ramp=o>0?{from:n,to:r.to,over:o}:null}e.anchorNow=t}function ga(e,t,n,r){uP(e,t);let o=ya(e,t);e.ramp=r>0&&n!==o?{from:o,to:n,over:r}:null,e.rate=n}function Io(e,t){let n=t.spec.stepMs??e.opts.stepMs;return n!==void 0&&n>0&&!e.reducedNow?n:void 0}var Qj=!1,ba={u:Number.NaN,ease:void 0,left:0};function Hr(e,t,n){return Math.max(0,e-t)/n}function Eo(e,t){return(t!==ba.u||e!==ba.ease)&&(ba.u=t,ba.ease=e,ba.left=t>=1?0:1-e(t)),ba.left}function Mo(e,t,n){return n===0?t:t+(e-t)*n}function W2(e,t,n,r,o,i,s,a,l,u){let c=Eo(e,n),d=0;if(Qj&&n<1){let f=Math.max(0,n-1e-4),p=Math.min(1,n+1e-4);d=(e(p)-e(f))/(p-f)*(1e3/r)}for(let f=0;f<t;f++){let p=o[i+f],h=s[a+f];l[f]=Mo(p,h,c),u[f]=-(p-h)*d}return c===0}var V2=0,z2=1,K2=2;var Zj=4,e$=5,ot={y:0,dy:0},St={e:0,e2:0,cos:0,sin:0},t$={form:Number.NaN,k1:Number.NaN,k2:Number.NaN,k3:Number.NaN,t:Number.NaN};function n$(e,t){let n=e[0],r=e[2],o=e[3],i=e[4],s=t$;if(!(Kt(t,s.t)&&n===s.form&&r===s.k1&&o===s.k2&&i===s.k3))switch(s.form=n,s.k1=r,s.k2=o,s.k3=i,s.t=t,n){case V2:{let a=e[2],l=e[3],u=e[4];St.e=Math.exp(-a*l*t),St.cos=Math.cos(u*t),St.sin=Math.sin(u*t);return}case z2:{let a=e[3];St.e=Math.exp(-a*t);return}case K2:{St.e=Math.exp(e[2]*t),St.e2=Math.exp(e[3]*t);return}default:St.e=Math.exp(-t/e[2])}}function r$(e,t,n,r){let o=e[0];o===V2?o$(e,t,n):o===z2?i$(e,t,n,r):o===K2?s$(e,t,n):j2(e,t)}function o$(e,t,n){let r=e[2],o=e[3],i=e[4],s=St.e,a=(n+r*o*t)/i,l=St.cos,u=St.sin,c=s*(t*l+a*u);ot.y=c,ot.dy=-r*o*c+s*i*(a*l-t*u)}function i$(e,t,n,r){let o=e[3],i=St.e,s=n+o*t,a=i*(t+s*r);ot.y=a,ot.dy=i*s-o*a}function s$(e,t,n){let r=e[2],o=e[3],i=(n-o*t)/(r-o),s=t-i,a=St.e,l=St.e2;ot.y=i*a+s*l,ot.dy=i*r*a+s*o*l}function j2(e,t){let n=e[2],r=St.e;ot.y=t*r,ot.dy=-t/n*r}function a$(e,t,n,r,o){let i=e[2],s=t-n,a=t+r*i-n;if(a===0){j2(e,s);return}let l=e[3];if(s*a>0){let h=Math.exp(-l*o),m=r+l*s,g=h*(s+m*o);ot.y=g,ot.dy=h*m-l*g;return}let u=1+s/(r*i),c=u>0?-i*Math.log(u):Number.POSITIVE_INFINITY;if(o<c){let h=St.e;ot.y=s+r*i*(1-h),ot.dy=r*h;return}let d=o-c,f=r*u,p=Math.exp(-l*d);ot.y=p*f*d,ot.dy=p*f*(1-l*d)}function $2(e,t,n,r,o,i,s,a,l,u,c,d,f,p){if(e[0]===Zj)return W2(t,n,Hr(d,r,o),o,i,s,u,c,f,p);let h=Math.max(0,d-r)/1e3,m=e[1],g=m>0;n$(e,h);for(let b=0;b<n;b++){let x=u[c+b];e[0]===e$?a$(e,i[s+b],x,a[l+b],h):r$(e,i[s+b]-x,a[l+b],h),f[b]=x+ot.y,p[b]=ot.dy,(Math.abs(ot.y)>m||Math.abs(ot.dy)>m)&&(g=!1)}if(g)for(let b=0;b<n;b++)f[b]=u[c+b],p[b]=0;return g}var Y2=1e-4,Gr=[0,0];function cP(e,t,n,r){let o=t<Y2?n:e,s=(r<Y2?e:n)-o;s>Math.PI?s-=2*Math.PI:s<-Math.PI&&(s+=2*Math.PI),Gr[0]=o,Gr[1]=s}function q2(e,t,n,r,o){let i=e[t+3]??0,s=n[r+3]??0,a=s>0?1/s:0,l=(n[r]??0)*a,u=(n[r+1]??0)*a,c=(n[r+2]??0)*a,d=i>0?1/i:0,f=i>0?(e[t]??0)*d:l,p=i>0?(e[t+1]??0)*d:u,h=i>0?(e[t+2]??0)*d:c,m=s>0?l:f,g=s>0?u:p,b=s>0?c:h,x=Math.sqrt(p*p+h*h),w=Math.sqrt(g*g+b*b);cP(Math.atan2(h,p),x,Math.atan2(b,g),w),o[0]=f,o[1]=x,o[2]=Gr[0],o[3]=i,o[4]=m,o[5]=w,o[6]=Gr[0]+Gr[1],o[7]=s}var nye=new Float64Array(8),rye=new Float64Array(4),oye=new Float64Array(4),iye=new Float64Array(4),sye=new Float64Array(4);function tc(){try{return!0}catch{return!1}}var X2=new WeakSet;function er(e,t){X2.has(e)||tc()||(X2.add(e),console.warn(`blits: ${t}`))}var xa=Ct,c$=Array.from({length:256},(e,t)=>{let n=t/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),d$=c$.map((e,t)=>{let n=(t-.5)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),J2=4096,pye=Array.from({length:J2+1},(e,t)=>{let n=0;for(;n<255&&t/J2>=d$[n+1];)n++;return n});var Ah=256,hye=new Int32Array(Ah).fill(-1),mye=new Float64Array(Ah),yye=new Float64Array(Ah),gye=new Float64Array(Ah);var eO=new Float64Array(8);function f$(e,t,n){let r=eO;q2(e,0,t,0,r);let o=xa(r[3],r[7],n),i=xa(r[1],r[5],n),s=r[2]+Gr[1]*n;return[xa(r[0],r[4],n)*o,i*Math.cos(s)*o,i*Math.sin(s)*o,o]}var p$=1e-9;function Q2(e,t,n){let r=e.length>4,o=(r?e[4]:e[3])??0,i=o>0?1/o:0,s=(e[1]??0)*i,a=(e[2]??0)*i,l=Math.sqrt(s*s+a*a);t[n]=(e[0]??0)*i,t[n+1]=r?l<p$?0:(e[3]??0)*i:l,t[n+2]=Math.atan2(a,s),t[n+3]=o}function Z2(e,t,n){let r=e[1]??0,o=e[2]??0,i=e.length>4;return n[0]=(e[0]??0)*t,n[1]=r*t,n[2]=o*t,n[3]=(i?e[3]??0:Math.sqrt(r*r+o*o))*t,n[4]=((i?e[4]:e[3])??0)*t,n}function h$(e,t,n){if(n===0)return Z2(e,1,Qn(5,0));if(n===1)return Z2(t,1,Qn(5,0));let r=eO;Q2(e,r,0),Q2(t,r,4);let o=r[3]>0?0:4,i=r[7]>0?4:0,s=r[o+1],a=r[i+1];cP(r[o+2],s,r[i+2],a);let l=xa(r[3],r[7],n),u=xa(s,a,n)*l,c=Gr[0]+Gr[1]*n;return[xa(r[o],r[i],n)*l,Math.cos(c)*u,Math.sin(c)*u,u,l]}function dP(e){let t=e.lerp;return t===f$||t===h$}var bye=Qn(5,0);var pP=e=>e;function nO(e){return e===void 0||e===pP}function nc(e,t,n,r){let o=3*e,i=3*(n-e)-o,s=1-o-i,a=3*t,l=3*(r-t)-a,u=1-a-l,c=p=>((s*p+i)*p+o)*p,d=p=>(3*s*p+2*i)*p+o,f=p=>((u*p+l)*p+a)*p;return p=>{if(p<=0)return 0;if(p>=1)return 1;let h=p;for(let b=0;b<8;b++){let x=c(h)-p;if(Math.abs(x)<1e-7)return f(h);let w=d(h);if(Math.abs(w)<1e-6)break;h-=x/w}let m=0,g=1;for(h=p;g-m>1e-7;)c(h)<p?m=h:g=h,h=(m+g)/2;return f(h)}}var m$={linear:pP,ease:nc(.25,.1,.25,1),"ease-in":nc(.42,0,1,1),"ease-out":nc(0,0,.58,1),"ease-in-out":nc(.42,0,.58,1)},tO=new WeakMap,fP=new WeakMap([[pP,1]]);function y$(e,t,n,r){return e>0?t/e:t>0?Number.POSITIVE_INFINITY:n>0?r/n:r>0?Number.POSITIVE_INFINITY:1}function rO(e){let t=fP.get(e);if(t!==void 0)return t;let n=1e-6,r=e(n);return r>.001?Number.POSITIVE_INFINITY:r/n}function Co(e){if(typeof e=="function")return e;if(typeof e=="string"){let r=m$[e];if(!r)throw new Error(`blits: no easing named ${e}`);return r}let t=tO.get(e);if(t)return t;let n;if("bezier"in e)n=nc(...e.bezier),fP.set(n,y$(...e.bezier));else{let r=e.steps,o=e.jump==="start";n=i=>{let s=i<=0?0:i>=1?1:i;return(o?Math.min(r,Math.floor(s*r)+1):Math.floor(s*r))/r},fP.set(n,o?Number.POSITIVE_INFINITY:0)}return tO.set(e,n),n}function oO(e,t){return e==="queue"?1:e==="together"?0:t}function g$(e,t){return{rate:t.map(()=>1),skip:t.map(()=>!1),share:oO(e.order,e.share),allow:0}}function mP(e,t,n){let r=oO(e.order,e.share),o=[],i=0,s=0,a=0;return t.forEach((l,u)=>{let c=n.skip[u]?0:l.natural/n.rate[u],d=l.state==="playing"?0:Math.max(u===0?Number.NEGATIVE_INFINITY:s+(l.overlap?Math.min(n.share,r):r)*a,l.floor??0);o.push(d),i=Math.max(i,d+c),s=d,a=c}),{at:o,length:i}}var tr=(e,t,n)=>mP(e,t,n).length<=e.left+n.allow+1e-9;function hP(e,t,n){if(n(e))return e;if(!n(t))return t;if(t===Number.POSITIVE_INFINITY)for(t=Math.max(e,1)*2;!n(t);)e=t,t*=2;for(let r=0;r<60;r++){let o=(e+t)/2;n(o)?t=o:e=o}return t}function b$(e,t,n){if(!tr(e,t,n)){let s=Math.max(1,...t.map(l=>l.faster)),a=l=>({...n,rate:t.map((u,c)=>Math.max(n.rate[c],Math.min(l,u.faster)))});return a(hP(1,s,l=>tr(e,t,a(l))))}if(!Number.isFinite(e.left))return n;let r=Math.max(1,...t.map(s=>s.slower));if(r===1)return n;let o=s=>({...n,rate:t.map((a,l)=>n.rate[l]/Math.min(s,a.slower))}),i=hP(1,r,s=>!tr(e,t,o(s)));return tr(e,t,o(i))?o(i):o(Math.max(1,i-1e-9))}function x$(){return(e,t,n)=>{if(tr(e,t,n)||!t.some(i=>i.overlap))return n;let r=i=>({...n,share:i}),o=hP(0,n.share,i=>tr(e,t,r(n.share-i)));return r(n.share-o)}}function w$(){return(e,t,n)=>{let r=n;for(let o=t.length-1;o>=0&&!tr(e,t,r);o--){if(!t[o].ballast||r.skip[o])continue;let i=r.skip.slice();i[o]=!0,r={...r,skip:i}}return r}}function P$(...e){return(t,n,r)=>{let o=r;for(let i of e){if(tr(t,n,o))break;o=i(t,n,o)}return o}}var iO=P$(x$(),w$()),Rh={weak:0,strong:1,required:2};function sO(e,t,n,r){let o=n(e,t,b$(e,t,g$(e,t)));return tr(e,t,o)||Rh[e.priority]===0||r==="overrun"?{plan:o,fell:!tr(e,t,o)&&Rh[e.priority]>0}:(o={...o,skip:t.map((i,s)=>o.skip[s]||Rh[i.priority]<Rh[e.priority])},{plan:o,fell:!0})}var Oo=e=>!Number.isNaN(e.restedAt);function On(e,t,n){return{reaches:t,delay:0,since:0,shown:0,weight:0,restedAt:Number.NaN,bands:null,state:n,stepped:-0,ticks:0,probed:Number.NaN,delta:null,phase:0,seeks:0,rebuilt:0,copied:!1,base:void 0,slope:void 0,kept:null,unkept:void 0,snaps:void 0,from:void 0,unknown:void 0,inputs:void 0,replay:void 0,voice:e,next:null,version:Number.NaN,roles:null,slot:-1,run:-1,freed:-1,restored:null}}function T$(){return On(null,!1,void 0)}function aO(e){let t=this.chains.get(e);return t!==void 0&&t.version===this.version?t:this.relink(e,t)}function lO(e,t){let n=this.lanes,r=t!==void 0?t.slot:n!==null?n.number(e):-1;t===void 0&&r>=0&&this.places?.number(e,r);let o=t!==void 0&&r>=0&&n?.renew(r)===!0,i=t===void 0||o?void 0:this.steps.patch(t.voice===null?null:t,t.version,this,e,r);i===void 0&&(i=S$(this,e,r,t??null));let s=i??T$();return s.version=this.version,t!==void 0&&t!==s&&(o||(s.roles=t.roles),t.roles=null,t.slot=-1),s.slot=r,t!==s&&this.chains.set(e,s),s}function ut(e,t){let n=e.chains.get(t);return n!==void 0&&n.slot>=0&&e.lanes?.sought(n.slot)===!0?void 0:n}function S$(e,t,n,r){let o=null,i=r,s=null,a=e.naming===0?void 0:e.named.get(t),l=0,u=e.general;for(let c=0;c<=u.length;c++){let d=c<u.length?u[c]:null;for(;;){let f=a!==void 0&&l<a.length?a[l]:null,p=f!==null&&(d===null||f.id<d.id)?f:d;if(p===null)break;p===f&&l++;let h=i!==null&&i.voice===p?i:null;h!==null&&(i=h.next);let m=e.linkable(p,t,n,h);if(m!==null&&(m.voice=p,m.next=null,s===null?o=m:s.next=m,s=m),p===d)break}}return o}function uO(e,t,n,r=null){let o=e.state;if(o==="done"||o==="pending"&&!e.freezesBefore)return null;if(e.sharing&&this.share.everyoneOf(this,e)!==null)return n>=0&&this.share.sight(e,n,this.lanes.cap),null;let i=this.held(e,t,n,r);return i.reaches?i:null}function cO(e,t){return dO(e,t,this.now)}function dO(e,t,n,r=Number.POSITIVE_INFINITY){let o=e.parted?.get(t);return o!==void 0&&!(n<o.at)&&o.seq<=r?!1:e.named!==null?e.named.has(t):e.spec.target?e.spec.target(t):!0}function Nh(e,t,n,r,o){return n!==void 0&&!n.reaches&&dO(e,t,r,o)?void 0:n}function Ur(e,t){if(t.holding!==null){e.lanes?.refill();return}if(e.lanes?.touch(t),t.named===null){e.steps.push(t,++e.version);return}for(let n of t.named.list){let r=ut(e,n);r!==void 0&&rc(e,r)}e.relinks++}function rc(e,t){t.version=Number.NaN;let n=++e.relinks;t.slot>=0&&e.lanes!==null&&(e.lanes.unlinked[t.slot]=n)}function yP(e,t){if(t.holding===null){if(t.named===null){if(e.general.push(t),t.sharing){let n=e.sharers,r=n.length;for(;r>0&&n[r-1].id>t.id;)r--;n.splice(r,0,t)}return}e.naming++;for(let n of t.named.list){let r=e.named.get(n);r===void 0?e.named.set(n,[t]):r.push(t)}}}function fO(e,t){e.naming--;for(let n of t.named.list){let r=e.named.get(n);if(r===void 0)continue;let o=r.indexOf(t);o>=0&&r.splice(o,1),r.length===0&&e.named.delete(n)}}var Ih=class{size=0;every=[];everyTokens=[];spare=[];spareTokens=[];everySorted=!0;at=new Float64Array(64);tokens=new Float64Array(64);voices=[];limit=64;push(t,n,r){if(t===Number.NEGATIVE_INFINITY){this.every.length>=this.limit&&this.pruneEvery(),this.every.push(n),this.everyTokens.push(r);return}this.size>=this.limit&&this.prune(),this.size===this.at.length&&this.grow();let o=this.at,i=this.size++;for(;i>0;){let s=i-1>>1;if(o[s]<=t)break;this.move(s,i),i=s}o[i]=t,this.tokens[i]=r,this.voices[i]=n}first(){return this.every.length>0?Number.NEGATIVE_INFINITY:this.size>0?this.at[0]:Number.POSITIVE_INFINITY}takeEvery(){let t=this.every,n=this.everyTokens,r=0,o=!0,i=Number.NEGATIVE_INFINITY;for(let s=0;s<t.length;s++){let a=t[s];n[s]!==a.dueToken||a.state==="done"||(a.dueToken++,a.id<i&&(o=!1),i=a.id,t[r++]=a)}return t.length=r,n.length=0,this.spare.length=0,this.every=this.spare,this.everyTokens=this.spareTokens,this.spare=t,this.spareTokens=n,this.everySorted=o,t}pop(){let t=this.voices[0],n=this.tokens[0],r=--this.size;return r>0&&this.sink(0,this.at[r],this.tokens[r],this.voices[r]),this.voices[r]=void 0,n===t.dueToken&&t.state!=="done"?t:void 0}clear(){this.size=0,this.every.length=0,this.everyTokens.length=0,this.spare.length=0,this.spareTokens.length=0,this.voices=[],this.limit=64}move(t,n){this.at[n]=this.at[t],this.tokens[n]=this.tokens[t],this.voices[n]=this.voices[t]}sink(t,n,r,o){let i=this.at,s=this.size;for(;;){let a=2*t+1,l=a+1,u=t,c=n;if(a<s&&i[a]<c&&(u=a,c=i[a]),l<s&&i[l]<c&&(u=l),u===t)break;this.move(u,t),t=u}i[t]=n,this.tokens[t]=r,this.voices[t]=o}grow(){let t=new Float64Array(this.at.length*2);t.set(this.at),this.at=t;let n=new Float64Array(this.tokens.length*2);n.set(this.tokens),this.tokens=n}pruneEvery(){let t=this.every,n=this.everyTokens,r=0;for(let o=0;o<t.length;o++){let i=t[o];n[o]===i.dueToken&&(t[r]=i,n[r++]=n[o])}t.length=r,n.length=r,this.limit=Math.max(this.limit,2*r)}prune(){let t=0;for(let n=0;n<this.size;n++){let r=this.voices[n];this.tokens[n]===r.dueToken&&(t!==n&&this.move(n,t),t++)}for(let n=t;n<this.size;n++)this.voices[n]=void 0;this.size=t;for(let n=(t>>1)-1;n>=0;n--)this.sink(n,this.at[n],this.tokens[n],this.voices[n]);this.limit=Math.max(64,2*t)}};function k$(e,t){if(t.state==="done")return Number.POSITIVE_INFINITY;if(Number.isNaN(t.opened)||t.owner!==null||t.holding!==null)return Number.NEGATIVE_INFINITY;let n=Number.POSITIVE_INFINITY;if(t.parts!==null)for(let o of t.parts.values())n=Math.min(n,o.at+o.over);let r=t.back;if(r!==null&&(n=Math.min(n,r.at+(1-r.from)*r.over)),t.state==="pending")return Math.min(n,Number.isNaN(t.start)?n:t.start);if(t.turns)return Number.NEGATIVE_INFINITY;if(t.state==="fading"){let o=t.out;return o===null||o.rest?Number.NEGATIVE_INFINITY:Math.min(n,o.at+o.over)}if(n=Math.min(n,t.outAt),t.state==="frozen"){let o=Number.isNaN(e.now)?Number.NaN:t.elapsedAt(e.now),i=t.ramp;if((i===null?t.rate<=0:i.from<=0&&i.to<=0)&&!t.beginless&&o<=t.soonest)return n;if(t.rate<=0||i!==null||o<t.span+t.latest)return Number.NEGATIVE_INFINITY}return t.state==="live"&&(n=Math.min(n,t.endsAt())),n}function it(e,t){if(e.projecting)return;e.lanes?.voiceChanged(t);let n=++t.dueToken,r=k$(e,t);r!==Number.POSITIVE_INFINITY&&e.due.push(Number.isNaN(r)?Number.NEGATIVE_INFINITY:r,t,n)}function pO(e,t){let n=e.due,r=n.takeEvery(),o=n.everySorted,i=r.length;for(;n.first()<=t;){let s=n.pop();s!==void 0&&(s.dueToken++,r.push(s))}return i===0||!o?Bi(r):i===r.length?r:v$(r,i)}function v$(e,t){let n=Bi(e.slice(t)),r=[],o=0,i=0;for(;o<t&&i<n.length;){let s=e[o],a=n[i];a.id<s.id?(r.push(a),i++):(r.push(s),o++)}for(;o<t;)r.push(e[o++]);for(;i<n.length;)r.push(n[i++]);return r}var A$=8;function Bi(e){if(e.length>A$)return e.sort((t,n)=>t.id-n.id);for(let t=1;t<e.length;t++){let n=e[t],r=t;for(;r>0&&e[r-1].id>n.id;r--)e[r]=e[r-1];e[r]=n}return e}var cn=Symbol("slow");function bt(e){let t=gP(e,2);for(let n=0;n<Eh;n++)bP[n]=void 0;return Eh=0,t===cn?structuredClone(e):t}var bP=[],Eh=0;function R$(e){for(let t=0;t<Eh;t++)if(bP[t]===e)return!0;return!1}function gP(e,t){if(typeof e=="symbol"||typeof e=="function")return cn;if(typeof e!="object"||e===null)return e;if(t===0||R$(e))return cn;if(bP[Eh++]=e,Array.isArray(e)){if(Object.getPrototypeOf(e)!==Array.prototype)return cn;let o=[];for(let s=0;s<e.length;s++){if(!(s in e))return cn;let a=gP(e[s],t-1);if(a===cn)return cn;o.push(a)}let i=0;for(let s in e)if(++i>e.length)return cn;return o}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)return cn;let r={};for(let o in e){if(o==="__proto__")return cn;let i=gP(e[o],t-1);if(i===cn)return cn;r[o]=i}return r}function wa(e){return typeof e!="object"||e===null?e:Array.isArray(e)?[...e]:ArrayBuffer.isView(e)?e.slice():mO(e)?bt(e):e}function Hi(e){return Array.isArray(e)?[...e]:e}function hO(e){return Array.isArray(e)||ArrayBuffer.isView(e)||mO(e)}function mO(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function $t(e,t,n=!1){return t<e.seq||t===e.seq&&(!e.strict||n)}var yO=new WeakMap,xP=new Map,me=class{weak=yO;strong=xP;oneKey=Pa;oneValue=void 0;get(t){return typeof t=="object"&&t!==null?this.weak.get(t):wP(this.oneKey,t)?this.oneValue:this.strong.get(t)}set(t,n){if(typeof t=="object"&&t!==null){this.weak===yO&&(this.weak=new WeakMap),this.weak.set(t,n);return}if(this.strong===xP&&(this.oneKey===Pa||wP(this.oneKey,t))){this.oneKey=t,this.oneValue=n;return}this.strong===xP&&(this.strong=new Map),this.oneKey!==Pa&&(this.strong.set(this.oneKey,this.oneValue),this.oneKey=Pa,this.oneValue=void 0),this.strong.set(t,n)}find(t,n){return this.get(t)}has(t){return this.get(t)!==void 0}delete(t){typeof t=="object"&&t!==null?this.weak.delete(t):wP(this.oneKey,t)?(this.oneKey=Pa,this.oneValue=void 0):this.strong.delete(t)}clear(){this.oneKey=Pa,this.oneValue=void 0,this.strong.clear()}},oc=class extends me{under;hidden=new me;constructor(t){super(),this.under=t}get(t){return super.get(t)??(this.hidden.get(t)?void 0:this.under.get(t))}delete(t){super.delete(t),this.hidden.set(t,!0)}},Pa=Symbol("none"),wP=(e,t)=>e===t||Object.is(e,t),Mh=class extends me{make;gone=null;constructor(t){super(),this.make=t}get(t){let n=super.get(t);return n===void 0&&this.gone?.get(t)!==!0&&(n=this.make(t),n!==void 0&&super.set(t,n)),n}delete(t){super.delete(t),this.gone??=new me,this.gone.set(t,!0)}};var Fn=class e{list=[];head=0;by=new me;static from(t){if(t.length===0)return null;let n=new e;for(let r of t)n.push(r);return n}push(t){this.list.push(t);let n=this.by.get(t.subject);n===void 0?this.by.set(t.subject,[t]):n.push(t)}expire(t,n){let r=this.list,o=this.head;for(;o<r.length&&!(r[o].at>=t);){let i=r[o++];n!==null&&n(i);let s=this.by.get(i.subject);s.length===1?this.by.delete(i.subject):s.shift()}this.head=o,o>=32&&o*2>=r.length&&(this.list=r.slice(o),this.head=0)}at(t,n){let r=this.by.get(t);if(r!==void 0){for(let o of r)if(!$t(n,o.seq,o.sync))return!o.held.reaches&&o.parted!==null&&o.parted.seq>n.seq?void 0:o.held}}after(t){let n=[],r=new Set;for(let o of this.all())!$t(t,o.seq,o.sync)&&!r.has(o.subject)&&(r.add(o.subject),n.push(o));return n}of(t){return this.by.get(t)??[]}all(){return this.head===0?this.list:this.list.slice(this.head)}};function Gi(e,t){let n=e.patch,r=[...t.kept?.values()??[],...t.unkept??[]],o={reaches:t.reaches,delay:t.delay,since:t.since,shown:t.shown,weight:t.weight,rested:Oo(t),restedAt:t.restedAt,bands:t.bands===null?null:Array.from(t.bands),state:t.state===void 0?void 0:n.pack?n.pack(t.state):bt(t.state),stepped:t.stepped,ticks:t.ticks,rebuilt:t.rebuilt,kept:r.length===0?null:r.map(bt)};return t.copied&&(o.copied=!0),t.base!==void 0&&(o.base=bt(t.base)),t.slope!==void 0&&(o.slope=bt(t.slope)),t.snaps!==void 0&&(o.snaps=t.snaps.map(i=>[i.at,i.seq,Gi(e,i.held)])),t.inputs!==void 0&&(o.inputs=t.inputs.map(i=>({...i}))),o}function Ui(e,t){let n=e.patch,r=t.bands===null?null:Uint8Array.from(t.bands),o=On(e,t.reaches,t.state===void 0?void 0:n.unpack?n.unpack(t.state):t.state);return o.delay=t.delay,o.since=t.since,o.shown=t.shown,o.weight=t.weight,o.restedAt=t.restedAt,o.bands=r,o.stepped=t.stepped,o.ticks=t.ticks,o.rebuilt=t.rebuilt,o.copied=t.copied===!0,t.kept!==null&&(o.unkept=t.kept),t.base!==void 0&&(o.base=t.base),t.slope!==void 0&&(o.slope=t.slope),t.snaps!==void 0&&(o.snaps=t.snaps.map(([i,s,a])=>({at:i,seq:s,held:Ui(e,a)}))),t.inputs!==void 0&&(o.inputs=t.inputs),o}var ic=class extends Error{mix;stream;at;constructor(t,n,r){super(`blits: ${r} reaches past memory into ${n} records of ${t===""?"the mix":t} that were not loaded; await prepare(${r}) first`),this.mix=t,this.stream=n,this.at=r,this.name="HistoryMiss"}},Ch=class{store;loaded=null;last=null;constructor(t){this.store=t}},Oh=class{of;refs=new Map;gone=new FinalizationRegistry(t=>{let n=this.refs.get(t);n!==void 0&&n.deref()===void 0&&this.refs.delete(t)});constructor(t){this.of=t}key(t){if(t===void 0||typeof t=="string"||typeof t=="number")return t;let n=this.of;if(n===void 0||typeof t!="object"||t===null)throw new Error("blits: a mix whose history has a store pages its subjects by key; give it keyOf for subjects that are not strings or numbers");let r=n(t);return this.refs.get(r)?.deref()!==t&&(this.refs.set(r,new WeakRef(t)),this.gone.register(t,r)),r}subject(t){if(t!==void 0)return this.refs.get(t)?.deref()??t}};function nr(e,t,n,r,o,i,s){if(e.transport.pager===null||o.length===0)return;let l=e.name??"",u=[];for(let c=0;c<o.length;c++){let d=o[c];if(c+1<o.length&&o[c+1].seq===d.seq)continue;let f={mix:l,stream:t,at:d.at,seq:d.seq,data:i(d)};n!==void 0&&(f.voice=n),r!==void 0&&(f.subject=r),u.push(f)}gO(e.transport,u,s)}function gO(e,t,n){let r=e.pager;r.store.page(t);let o=r.loaded;o!==null&&(e.now-o.now>(e.history?.ms??0)?r.loaded=null:o.records.push(...t));let i=t[t.length-1];r.last={mix:i.mix,stream:i.stream},n>e.floor&&(e.floor=n)}function bO(e){let t=e.history;if(t===void 0||e.pager===null)return;let n=e.now-t.ms,r=[];e.frames.shed(n,s=>r.push({mix:"",stream:"frame",at:s.at,seq:s.seq,data:s.u}));let o=e.pace,i=s=>o===null?s:o.reading(s);if(e.announced.some(s=>i(s.at)<n)){let s=[];for(let a of e.announced)i(a.at)<n?r.push({mix:"",stream:"mark",subject:a.order,at:i(a.at),seq:a.seq,data:a}):s.push(a);e.announced=s}if(o!==null)for(let s of o.shed(n))r.push({mix:"",stream:"pace",at:s.anchorElapsed,seq:s.seq,data:s});r.length>0&&gO(e,r,n)}async function xO(e,t){let n=e.pager;if(n===null||e.reaches(t))return;let r=await n.store.load(t);n.loaded={t,now:e.now,records:[...r]}}var Fh=class{cued=null;by=new Map;gone=null;goneBy=new Map;versions=new Map;held=new Set};function Lh(e,t){let n=e.scored.held;if(n.has(t)||e.dropped)return;n.add(t);let r=e.transport.holders,o=e,i=r.get(t);if(i===void 0){r.set(t,[o]);return}let s=i.findIndex(a=>a.slot>o.slot);s<0?i.push(o):i.splice(s,0,o)}function wO(e,t){return e.transport.holders.get(t)??RO}function PP(e,t){e.scored.held.delete(t);let n=e.transport.holders,r=n.get(t);if(r===void 0)return;let o=r.indexOf(e);o>=0&&r.splice(o,1),r.length===0&&n.delete(t)}function PO(e){for(let t of e.cued)t.spec.score!==void 0&&Lh(e,t.spec.score);for(let t of e.gone)t.spec.score!==void 0&&Lh(e,t.spec.score)}function TO(e){for(let t of[...e.scored.held])PP(e,t)}function Ta(e,t,n=!1){let r=t.spec.score;if(r===void 0)return;let o=e.scored;if(o.versions.set(r,(o.versions.get(r)??0)+1),!n||t.state!=="done")return;let i=o.goneBy.get(r);i!==void 0&&o.goneBy.set(r,[...i])}function SO(e,t){return e.scored.versions.get(t)??0}function kO(e,t){let n=t.spec.score;if(n===void 0)return;let r=e.get(n);r===void 0?e.set(n,new Set([t])):r.add(t)}function vO(e,t){let n=e.scored;if(n.cued!==e.cued){n.by=new Map;for(let r of e.cued)kO(n.by,r);n.cued=e.cued}return n.by.get(t)??N$}var N$=new Set;function AO(e,t){let n=e.scored;if(n.gone!==e.gone){n.goneBy=new Map;for(let r of e.gone)NO(n.goneBy,r);n.gone=e.gone}return n.goneBy.get(t)??RO}var RO=[];function NO(e,t){let n=t.spec.score;if(n===void 0)return;let r=e.get(n);r===void 0?e.set(n,[t]):r.push(t)}function _h(e,t){t.spec.score!==void 0&&Lh(e,t.spec.score);let n=e.scored;n.gone===e.gone&&NO(n.goneBy,t)}function TP(e,t,n){let r=e.scored;if(r.gone!==t)return;r.gone=e.gone;let o=new Map;for(let i of n){let s=i.spec.score;if(s===void 0)continue;let a=o.get(s);a===void 0?o.set(s,new Set([i])):a.add(i)}for(let[i,s]of o){let a=(r.goneBy.get(i)??[]).filter(l=>!s.has(l));a.length===0?r.goneBy.delete(i):r.goneBy.set(i,a)}}function IO(e,t){Ta(e,t),t.spec.score!==void 0&&Lh(e,t.spec.score);let n=e.scored;n.cued===e.cued&&kO(n.by,t)}function EO(e,t){for(let r of t)Ta(e,r);let n=e.scored;if(n.cued===e.cued)for(let r of t){let o=r.spec.score;if(o===void 0)continue;let i=n.by.get(o);i!==void 0&&(i.delete(r),i.size===0&&n.by.delete(o))}}var rr=Symbol("absent"),MO=Symbol("unit"),Dh=class{owner;next=0;free=null;refs=[void 0];registry=null;lone=null;loneSlot=-1;constructor(t){this.owner=t}adopt(t){this.owner=t}get size(){return this.next}take(t){let n=this.free?.pop()??this.next++,r=-1;if(typeof t=="object"&&t!==null){let o=new WeakRef(t);if(this.refs[n]=o,this.registry===null){if(this.lone===null)return this.lone=o,this.loneSlot=n,n;this.registry=new FinalizationRegistry(s=>this.release(s));let i=this.lone.deref();i!==void 0?this.registry.register(i,this.loneSlot,this.lone):r=this.loneSlot,this.lone=null}this.registry.register(t,n,o)}else this.refs[n]=t===void 0?MO:t;return r>=0&&this.release(r),n}has(t){return this.refs[t]!==void 0}subject(t){let n=this.refs[t];if(n===void 0)return rr;if(n!==MO){if(n instanceof WeakRef){let r=n.deref();return r===void 0?rr:r}return n}}move(t,n){let r=this.refs[t],o=this.free;if(r===void 0||n>=this.next||this.refs[n]!==void 0||o===null)return!1;let i=o.lastIndexOf(n);if(i<0)return!1;if(r instanceof WeakRef){let s=r.deref();if(s===void 0)return!1;r===this.lone?this.loneSlot=n:this.registry!==null&&(this.registry.unregister(r),this.registry.register(s,n,r))}return o.splice(i,1),o.push(t),this.refs[n]=r,this.refs[t]=void 0,!0}release(t){let n=this.refs[t];n!==void 0&&(n===this.lone?this.lone=null:n instanceof WeakRef&&this.registry?.unregister(n),this.refs[t]=void 0,this.owner.forget(t),this.free===null?this.free=[t]:this.free.push(t))}};var pe={live:!0,horizon:Number.POSITIVE_INFINITY,kept:0,moved:0,inputs:0,ahead:null,back:null};var I$=(e,t)=>e.seq===void 0||Number.isNaN(e.seq)||$t(t,e.seq,e.early===!0);function E$(e,t){let n=e[e.length-1];if(t>=n.at||e.length===1)return n;if(e[0].at>t)return e[0];let r=0,o=e.length-2;for(;r<o;){let i=r+o+1>>1;e[i].at<=t?r=i:o=i-1}return e[r]}function Bh(e,t,n,r){let o=e.runThen(t,r)??e.freshRun(t),i=o.stretches,s=o.pending??[],a=[],l=!1;for(let c of[...i.slice(1).map(d=>d.change),...s])c===void 0||I$(c,r)?c!==void 0&&a.push(c):l=!0;l&&(i=[i[0]],s=a.filter(c=>c.at!==void 0).sort((c,d)=>c.at-d.at));let u=E$(i,n);for(let c of s){let d=c.at;if(d===void 0||!(d<=n))break;d>=u.at&&(u=e.applied(t,u,c,d))}return e.evaluateSegment(u,n,e.xs,e.vs),o.flags}var M$=e=>typeof e=="number"?[e]:[...e];var OO=Symbol.for(`@msb235/blits/motions@${xh}`),CO=new Map,SP=class{motions;writes;constructor(t,n){this.motions=n;let r=CO.get(t);r===void 0&&(r=Object.freeze([t]),CO.set(t,r)),this.writes=r}form="motion";duration=0;get motion(){return this.motions.spec()}get[OO](){return this.motions}at(t,n,r){let o=this.motions,i=pe.back;if(i!==null){let a=Bh(o,n,r.elapsed,i);return{[this.writes[0]]:o.valueOf(a,o.xs)}}let s=o.slot(n);return o.sample(s,r.elapsed,o.xs,o.vs),{[this.writes[0]]:o.value(s,o.xs)}}set(t,n,r){this.motions.change(t,{at:r,x:M$(n)})}read(t,n){let r=this.motions,o=r.read(t,n);if(o!==void 0)return{value:r.value(o.s,o.x),velocity:r.value(o.s,o.v)}}};function Ln(e){return e instanceof SP?e.motions:e[OO]}var Hh=class{list;set;delays=null;latest=0;soonest=0;constructor(t,n){if(Array.isArray(t)&&C$(t)){this.list=t.slice(),this.set=null,n&&(this.delays=FO(this.list,n)),[this.latest,this.soonest]=LO(this.delays);return}let r=[],o=null;for(let i of t)o!==null?o.has(i)||(o.add(i),r.push(i)):r.includes(i)||(r.push(i),r.length>8&&(o=new Set(r)));this.list=r.slice(),this.set=o,n&&(this.delays=FO(this.list,n)),[this.latest,this.soonest]=LO(this.delays)}get size(){return this.list.length}has(t){return this.set===null?this.list.includes(t):this.set.has(t)}};function FO(e,t){let n=new Map;for(let r of e)n.set(r,t(r));return n}function LO(e){let t=0,n=0;for(let r of e?.values()??[])r>t&&(t=r),r<n&&(n=r);return[t,n]}function C$(e){let t=e.length;if(t>8)return!1;for(let n=1;n<t;n++){let r=e[n];for(let o=0;o<n;o++){let i=e[o];if(r===i||Number.isNaN(r)&&Number.isNaN(i))return!1}}return!0}var O$=256;function Fo(e,t,n=!1){let r=e.clocks;if(r!==null&&r.length>=O$)return;let o=e.holding!==null||e.spec.stagger!==void 0?Number.POSITIVE_INFINITY:0;if(r!==null&&_O(r,0)>=o&&_O(r,DO(e))>=o)return;let{anchorNow:i,anchorElapsed:s,rate:a,ramp:l,rebuilds:u}=e,c={anchorNow:i,anchorElapsed:s,rate:a,ramp:l,until:t,rebuilds:u,sought:n};r===null?e.clocks=[c]:r.push(c)}function _O(e,t){let n=Number.NEGATIVE_INFINITY;for(let r=t;r<e.length;r++){let o=e[r],i=ze(o,o.until);i>n&&(n=i)}return n}function DO(e){let t=e.clocks;if(t===null)return 0;let n=0;for(;n<t.length&&t[n].rebuilds!==e.rebuilds;)n++;return n}function F$(e,t,n){for(let r=t.length-1;r>=0;r--)if(t[r].sought&&(t[r+1]?.anchorElapsed??e.anchorElapsed)<n)return r+1;return 0}function Gh(e,t,n){let r=e.clocks,o=e.beginless?e.start:Number.NaN;if(r!==null&&Number.isNaN(o)){let i=n?Math.max(DO(e),F$(e,r,t)):0;for(let s=i;s<r.length;s++){let a=r[s],l=Cn(a,t);if(l<=a.until){o=l;break}}}return Number.isNaN(o)&&(o=Cn(e,t),o===Number.POSITIVE_INFINITY&&(o=e.start+t)),e.owner===null?o:Gh(e.owner,o,n)}function Lo(e){return e.owner===null?e.start:Gh(e.owner,e.start,!1)}var Wi=Object.freeze({form:"fn",duration:0,writes:[],at:()=>({})}),_o=class{children=[];kids=0;played=0;coasts=[];cutSeq=Number.POSITIVE_INFINITY;get coast(){let t=this.coasts.length;return t===0?Number.NEGATIVE_INFINITY:this.coasts[t-1]}left(t,n){t===void 0?n<this.cutSeq&&(this.cutSeq=n):t>this.coast&&this.coasts.push(n,t)}back(t){let n=this.coasts;for(;n.length>0&&n[n.length-2]>t;)n.length-=2;this.cutSeq>t&&(this.cutSeq=Number.POSITIVE_INFINITY)}};function Te(e,t){let n=e.owner===null?t:Te(e.owner,t);return n>=e.start?ze(e,n):Number.NEGATIVE_INFINITY}function BO(e,t,n){let r=Te(t,n);return r===Number.NEGATIVE_INFINITY?r:ze(e,r)}function Do(e,t){let n=e.backs?ec(e,t):Cn(e,t);return e.owner===null?n:Do(e.owner,n)}function Uh(e){let t=!1;for(let n=e.owner;n!==null;n=n.owner)n.backs&&(t=!t);return t}function HO(e,t){let n=e.holding;n.children.push(t),n.kids++}function GO(e,t){let n=e.owner,r=n.holding,o=r.children.indexOf(e);return o>=0&&r.children.splice(o,1),!Wr(n,t)&&n.state!=="done"?n:null}function Wr(e,t){for(let n of e.holding.children)if(!n.quietAt(t))return!0;return!1}function UO(e,t,n){let r=e.holding;++r.played===r.kids&&e.play(!0,t,n)}function Vi(e,t){for(let n of e.holding.children)t(n),n.holding!==null&&Vi(n,t)}function WO(e){for(let t=e.owner;t!==null;t=t.owner)if(typeof t.spec.weight=="function")return!0;return!1}function VO(e){for(let t=e.owner;t!==null;t=t.owner){let n=t.spec.weight;if(typeof n=="function"&&n.input)return!0}return!1}function kP(e,t,n,r){let o=typeof e.spec.weight=="function"?r(e):e.weight,i=Lo(e),s=e.freezesBefore&&e.opened<i?e.opened:i;return Br(o*ma(e.fade.in??0,e.out,e.ease,n,t,s,e.back,e.stalls))}function zO(e,t,n,r){let o=1,i=e;for(let s=e.owner;s!==null;i=s,s=s.owner)o*=kP(s,t,n,r),s.arc!==null&&(o*=KO(s,i,t,n));return o}function Sa(e,t){let n=new Map;for(let r of e)if(n.set(r.id,r),r.holding!==null){let o=new _o;o.kids=r.holding.kids,o.played=r.holding.played,o.coasts=r.holding.coasts.slice(),o.cutSeq=r.holding.cutSeq,t!==void 0&&o.back(t),r.holding=o}for(let r of e){let o=r.owner===null?void 0:n.get(r.owner.id);o!==void 0&&(r.owner=o,o.holding.children.push(r))}}function AP(e,t,n){let r=n.writes??(n.kit?Object.keys(n.kit):void 0);if(r===void 0)throw new Error("blits: a patch needs writes, or a kit to take them from");return{form:"fn",duration:e,writes:r,kit:n.kit,reads:n.reads,at:t,state:n.state,step:n.step,pack:n.pack,unpack:n.unpack}}var L$=(e,t,n)=>e+(t-e)*n;function vP(e,t,n){if(typeof e=="number"&&typeof t=="number")return L$(e,t,n);if(Array.isArray(e)&&Array.isArray(t)){let r=new Array(e.length);for(let o=0;o<e.length;o++)r[o]=vP(e[o],t[o],n);return r}return n<.5?e:t}function _$(e,t,n,r){let o=r.ease===void 0?void 0:Co(r.ease),i=[];for(let s of t){let a=r.easeBy?.(s),l=a===void 0?o:Co(a),u=[];for(let p of e){let h=p.delta[s];h!==void 0&&u.push({at:p.at,value:Array.isArray(h)?[...h]:ArrayBuffer.isView(h)?h.slice():h,ease:p.ease===void 0?l:Co(p.ease)})}u.sort((p,h)=>p.at-h.at);let c=u.filter(p=>p.at!==0),d=r.lerpBy?.(s)??r.kit?.[s]?.lerp,f=u.length>0&&(d===void 0||d===Ct)&&u.every(p=>typeof p.value=="number");i.push({channel:s,all:u,tail:c,ats:u.map(p=>p.at),tailAts:null,delay:r.delayBy?.(s)??0,lerp:d,numbers:f?{ats:Float64Array.from(u,p=>p.at),values:Float64Array.from(u,p=>p.value),eases:u.map(p=>p.ease)}:null})}return{tracks:i,duration:n}}var Vh=0,ka=1,D$=2,Be={a:void 0,b:void 0,u:0,eased:0,first:!1,len:0,ease:void 0};function RP(e,t,n){return NP(e.delay,t,n)}function NP(e,t,n){return e===0||n===0?t:e>=n?t>=1?1:0:Math.max(0,(t*n-e)/(n-e))}function IP(e,t,n,r,o){return r===0?-2:o<=e[t]?-1:o>=e[t+(r-1)*n]?r:$O(e,t,n,1,r-1,o)}function $O(e,t,n,r,o,i){for(;r<o;){let s=r+o>>1;e[t+s*n]>=i?o=s:r=s+1}return r}function EP(e,t,n){return(e-t)/(n-t)}function MP(e,t,n){let r,o=n===void 0?0:1,i=o===0?e.all:e.tail;if(o===0){let c=i.length;if(r=IP(e.ats,0,1,c,t),r===-2)return Vh;if(r===-1||r===c)return Be.a=i[r===-1?0:c-1].value,ka}else{let c=i.length+1;if(t<=0)return Be.a=n,ka;let d=i[i.length-1];if(d===void 0||t>=d.at)return Be.a=d===void 0?n:d.value,ka;e.tailAts??=i.map(f=>f.at),r=$O(e.tailAts,-1,1,1,c-1,t)}let s=i[r-o],a=r-1<o?0:i[r-1-o].at,l=EP(t,a,s.at),u=s.ease?s.ease(l):l;return Be.a=r-1<o?n:i[r-1-o].value,Be.b=s.value,Be.u=l,Be.eased=u,Be.first=r-1<o,Be.len=s.at-a,Be.ease=s.ease,D$}function B$(e,t){let n=e.ats,r=e.values,o=n.length;if(t<=n[0])return r[0];if(t>=n[o-1])return r[o-1];let i=1,s=o-1;for(;i<s;){let f=i+s>>1;n[f]>=t?s=f:i=f+1}let a=n[i-1],l=(t-a)/(n[i]-a),u=e.eases[i],c=u?u(l):l,d=r[i-1];return d+(r[i]-d)*c}function H$(e,t,n,r,o,i,s,a){let l=e.numbers;if(l!==null&&n===void 0&&o===void 0&&(r===void 0||r===Ct||e.lerp!==void 0))return B$(l,t);let u=MP(e,t,n);if(u===Vh)return;if(u===ka)return Be.a;let c=Be.a,d=Be.b,f=Be.u,p=Be.eased,h=Be.first,m=Be.len,g=Be.ease,b;if(s!==void 0)b=s(a,c,d,p),Wh.wrote=b;else{let y=e.lerp??r;b=y?y(c,d,p):vP(c,d,p)}if(o===void 0||!h)return b;let x=g?rO(g):1;if(x===Number.POSITIVE_INFINITY)return b;let w=(y,P,S)=>(y*i*m-(S-P)*x)*f*(1-f)*(1-f);if(typeof b=="number"&&typeof o=="number")return b+w(o,c,d);if(Array.isArray(b)&&Array.isArray(o)){let y=b===Wh.wrote?b:new Array(b.length),P,S=()=>{let v=e.lerp??r,A=N=>s!==void 0?s(void 0,c,d,N):v?v(c,d,N):vP(c,d,N);return P=[A(0),A(1)],P};for(let v=0;v<b.length;v++){let A=b[v],N=o[v];if(typeof A!="number"||typeof N!="number"){y[v]=A;continue}let M=c[v],C=d[v];if(typeof M!="number"||typeof C!="number"){let[F,B]=P??S();M=F?.[v],C=B?.[v]}y[v]=typeof M=="number"&&typeof C=="number"?A+w(N,M,C):A}return y}return b}var Wh={wrote:void 0};function YO(e,t){return e.tracks.map((n,r)=>{let o=t[r];return n.lerp===void 0||n.lerp===o.lerp?Ph(o):void 0})}function zh(e,t,n,r,o,i,s,a){let l=e.duration;for(let u=0;u<e.tracks.length;u++){let c=e.tracks[u],d=i?.[c.channel],f=a===void 0?void 0:s?.[u];Wh.wrote=void 0;let p=H$(c,RP(c,t,l),r?.[c.channel],o?.[u],l===0?void 0:d,l,f,f===void 0?void 0:a[u]);f!==void 0&&p===Wh.wrote&&(a[u]=p),p!==void 0?n[c.channel]=p:n[c.channel]!==void 0&&(n[c.channel]=void 0)}return n}var jO=new WeakMap;function qO(e){let t=jO.get(e);return t===void 0&&(t=_$(e.keys,e.writes,e.duration,e),jO.set(e,t)),t}function CP(e){return function(n,r){let o=e.keepOn,i=o===null?e.ownKept:o.kept;if(i===null&&(i=new Map,o===null?e.ownKept=i:o.kept=i),i.has(n))return i.get(n);let s=o?.unkept,a=s===void 0?r():s.shift();return s?.length===0&&o!==null&&(o.unkept=void 0),i.set(n,a),pe.kept++,a}}var Kh=class{host;send;voice;timestamp=0;dt=0;elapsed=0;pass=0;weight=0;state=void 0;mark=0;kept=null;constructor(t,n,r){this.host=t,this.send=n,this.voice=r}get keep(){return this.kept===null&&(this.kept=CP(this.voice)),this.kept}};function sc(e,t){let n=e.named?.delays?.get(t);return n!==void 0?n:e.spec.stagger?e.spec.stagger(t):0}function ac(e,t){let n=e.unreachedBits;if(n===null||t<0)return!1;let r=t>>>5;return r<n.length&&(n[r]&1<<(t&31))!==0}function Vr(e,t,n){let r=e.unreachedBits,o=t>>>5;if(r===null||o>=r.length){if(!n)return;let s=new Uint32Array(Math.max(o+1,(r?.length??0)*2,2));r!==null&&s.set(r),e.unreachedBits=s,r=s}let i=1<<(t&31);r[o]=n?r[o]|i:r[o]&~i}function OP(e,t,n){ac(e,t)&&(Vr(e,n,!0),Vr(e,t,!1))}function XO(e,t){let n=this.sinceOf(e,0),r=On(e,!1,void 0);return r.since=n,r.shown=this.shownOf(e,n),r.stepped=t,r.rebuilt=e.rebuilds,e.unreached=r,r}function JO(e,t,n,r=null){if(e.sharing){let d=this.share.everyoneOf(this,e);if(d!==null)return d}if(ac(e,n))return e.unreached;let o=r===null?e.subjects.get(t):e.subjects.find(t,r);if(o!==void 0)return o;let i=this.now;if(!this.aims(e,t)){let d=e.unreached??this.unreachedOf(e,i);return n>=0&&e.named===null?Vr(e,n,!0):e.subjects.set(t,d),d}this.keys!==null&&(e.keyed??=new Set,e.keyed.add(this.keys.key(t)));let a=sc(e,t),l=this.sinceOf(e,a),u=this.shownOf(e,l);o=On(e,!0,e.patch.state?e.patch.state(t):void 0),o.delay=a,o.since=l,o.shown=u;let c=FP(this,e,o,i);return o.rebuilt=e.rebuilds,this.projecting&&(o.from=o.stepped,o.unknown=this.backward&&e.spec.from==="current"||c),e.subjects.set(t,o),LP(e,o,i),e.sighted!==null&&this.share?.sighted(e,n)?this.share.inherit(e,o,n):e.seen++,a>e.latest&&(e.latest=a,e.state==="frozen"&&it(this,e)),a<e.soonest&&(e.soonest=a,it(this,e)),o}function FP(e,t,n,r){let o=n.since;if(!(o<r))return n.stepped=r,!1;if(t.spec.catchUp!=="fresh"||t.patch.step===void 0)return n.stepped=o,!1;let i=Io(e,t);return i===void 0?n.stepped=r:(n.ticks=Math.floor((r-o)/i+1e-9),n.stepped=o+n.ticks*i),n.stepped>o}function QO(e,t){let n=e.patch;return Gh(e,t,n.state!==void 0||n.step!==void 0||e.keeping)}function ZO(e,t){let n=Lo(e),r=t<n?n:t;return e.freezesBefore&&e.opened<r?e.opened:r}function eF(e,t,n){return!(t.since<=n)||e.motion!==void 0&&!(t.probed>=t.since)}function LP(e,t,n){if(t.since<=n)return;e.early??=[];let r=e.early;if(r.length>=64&&(r.length&r.length-1)===0){let o=0;for(let i of r)eF(e,i,n)&&(r[o++]=i);r.length=o}r.push(t)}function va(e,t,n){t.state="live",t.begunSeq=e.transport.seq,t.anchorElapsed!==0&&(t.seeks++,t.rebuilds++,t.note(n,e.transport.seq,!0)),dn(e,t,n),Ur(e,t)}function Aa(e,t,n){let r=n.since;n.since=e.sinceOf(t,n.delay),n.since!==r&&(n.ticks>0||n.stepped>r)&&(n.rebuilt=-1),n.shown=e.shownOf(t,n.since),n.ticks===0&&n.stepped>n.since&&(n.stepped=n.since)}function dn(e,t,n){let r=t.early;if(r===null)return;let o=0;for(let i of r)Aa(e,t,i),eF(t,i,n)&&(r[o++]=i);r.length=o,o===0&&(t.early=null),e.lanes?.reshown(t.id)}var jh=class{of=null;count=0;general=[];named=new me;latest=Number.NEGATIVE_INFINITY;slack=0};function G$(e,t){let n=t.reachedTo;if(n<e.latest?e.slack=Math.max(e.slack,e.latest-n):e.latest=n,t.named===null){e.general.push(t);return}for(let r of t.named.list){let o=e.named.get(r);o===void 0?e.named.set(r,[t]):o.push(t)}}function tF(e,t){let n=!1;for(let r of t){if(r.named===null){n=!0;continue}for(let o of r.named.list){let i=e.named.get(o);if(i===void 0)continue;let s=i.indexOf(r);s>=0&&i.splice(s,1),i.length===0&&e.named.delete(o)}}if(n){let r=new Set(t);e.general=e.general.filter(o=>!r.has(o))}}function Bo(e){let t=e.goneIx,n=e.gone;(t.of!==n||t.count>n.length)&&(t.general=[],t.named=new me,t.count=0,t.of=n,t.latest=Number.NEGATIVE_INFINITY,t.slack=0);for(let r=t.count;r<n.length;r++)G$(t,n[r]);return t.count=n.length,t}function nF(e,t){for(let n of t)e.parters.delete(n),e.departed.add(e,n),n.doneAt>e.transport.forgotTo&&(e.transport.forgotTo=n.doneAt)}function _P(e,t){let n=Bo(e),r=e.gone,o=0;for(;o<r.length&&t(r[o]);)o++;if(o===r.length)return;let i=r.slice(0,o),s=[r[o]];for(o++;o<r.length;o++){let a=r[o];(t(a)?i:s).push(a)}tF(n,s),nF(e,s),e.gone=i,TP(e,r,s),n.of=i,n.count=i.length}function rF(e,t){let n=Bo(e);if(!Number.isFinite(n.slack)){_P(e,u=>u.reachedTo>=t);return}let r=e.gone,o=t+n.slack,i=0,s=!1;for(let u=Number.NEGATIVE_INFINITY;i<r.length&&u<o;i++){let c=r[i].reachedTo;c<t&&(s=!0),c>u&&(u=c)}if(!s)return;let a=[],l=[];for(let u=0;u<i;u++){let c=r[u];(c.reachedTo<t?l:a).push(c)}r.splice(0,i,...a),tF(n,l),nF(e,l),TP(e,r,l),n.count=r.length}var oF=[];function DP(e,t){return e>=0&&(t>0?e<t:Number.isFinite(e))}function iF(e,t){for(let n of e)if(!DP(n.at,t))throw new RangeError(t>0?`blits: a hit's at is voice ms into a pass, 0 up to ${t}, not ${n.at}`:`blits: a hit's at is voice ms, 0 or more, not ${n.at}`)}var $h=class{host;opts;est=Number.NaN;last=Number.NaN;prev=Number.NaN;round=0;canceled=!1;floor=Number.NEGATIVE_INFINITY;marked=new Map;tracks=new Map;due=[];constructor(t,n){this.host=t,this.opts=n}sync(){if(this.canceled)return;let t=this.host,n=t.timestamp,r=this.opts.clock();if(Number.isNaN(this.est))this.est=r;else{let a=this.est+(n-this.last),l=r-a;this.est=Math.abs(l)>50?r:a+l*.05}this.last=n;let o=Number.isNaN(this.prev)?t.now:this.prev;this.prev=t.now,this.round++,this.marks(n),this.hits(n,o);let i=this.due;i.sort((a,l)=>a.time-l.time);let s=this.opts.late;for(let a of i){let l=a.time<n?n-a.time:0;if(l>s)continue;let u=this.est+(a.time-n),c={time:a.time,at:u,taken:void 0};a.into.set(a.key,c),c.taken=this.opts.take(a.item,l>0?r:Math.max(u,r),l)}i.length=0;for(let a of this.tracks.values())for(let[l,u]of a.booked)u.time<=n&&a.booked.delete(l)}cancel(){if(!this.canceled){this.canceled=!0;for(let t of this.marked.values())t.time>this.last&&t.taken?.cancel();for(let t of this.tracks.values())for(let n of t.booked.values())n.time>this.last&&n.taken?.cancel();this.marked.clear(),this.tracks.clear(),this.host.unhook(this)}}sought(){if(this.canceled)return;let t=this.last;for(let r of this.marked.values())r.time>t&&r.taken?.cancel();for(let r of this.tracks.values())for(let o of r.booked.values())o.time>t&&o.taken?.cancel();this.marked.clear(),this.tracks.clear();let n=this.host;this.floor=n.timestamp,this.prev=n.now;for(let r of n.voices)r.spec.hits!==void 0&&r.state!=="done"&&this.tracks.set(r,{seenTo:r.elapsedAt(n.now),jumps:r.jumps,booked:new Map,met:this.round})}at(t){return this.est+(t-this.last)}stands(t,n){return n===void 0||!Number.isFinite(n)?!1:Math.abs(this.est+(n-this.last)-t.at)<=1}fits(t,n){let{tag:r,score:o}=this.opts;return(o===void 0||t===o)&&(r===void 0||n.includes(r))}marks(t){let n=this.host.marks(t-this.opts.late,t+this.opts.ahead),r=this.marked,o=new Set;for(let i of n){if(!this.fits(i.score,i.tags)||i.timestamp<=this.floor)continue;let s=U$(i);o.add(s);let a=r.get(s);if(a!==void 0){if(a.time<=t||this.stands(a,i.timestamp))continue;a.taken?.cancel(),r.delete(s)}let{order:l,...u}=i;this.due.push({time:i.timestamp,item:u,into:r,key:s})}for(let[i,s]of r)o.has(i)||(s.time>t&&s.taken?.cancel(),r.delete(i))}hits(t,n){let r=this.host,o=this.round,{ahead:i,late:s}=this.opts,a=r.readingAt(t+i),l=Number.isFinite(s)?r.readingAt(t-s):Number.NEGATIVE_INFINITY;for(let u of r.voices){let c=u.spec.hits;if(c===void 0||c.length===0||u.state==="done"||!this.fits(u.spec.score,u.spec.tags??oF))continue;let d=this.tracks.get(u);d===void 0&&(d={seenTo:Number.NEGATIVE_INFINITY,jumps:u.jumps,booked:new Map,met:o},this.tracks.set(u,d)),d.met=o,d.jumps!==u.jumps&&(d.jumps=u.jumps,d.seenTo=u.elapsedAt(n));let f=r.endOf(u),p=c.length,h=!1;for(let[w,y]of d.booked){if(y.time<=t)continue;let P=this.timeOfHit(u,c,Math.floor(w/p),w%p,f);this.stands(y,P)||(y.taken?.cancel(),d.booked.delete(w),h=!0)}h&&(d.seenTo=Math.min(d.seenTo,u.elapsedAt(n)));let m=u.elapsedAt(a);if(!(m>d.seenTo))continue;let g=Math.max(d.seenTo,u.elapsedAt(l));if(!(g<=m)){d.seenTo=m;continue}let b=u.duration,x=b>0?Math.min(u.passes-1,Math.floor(m/b)):0;for(let w=b>0?Math.max(0,Math.floor(g/b)):0;w<=x;w++)for(let y=0;y<p;y++){let P=w*b+c[y].at;if(!(P>d.seenTo&&P<=m))continue;let S=w*p+y;if(d.booked.has(S))continue;let v=this.timeOfHit(u,c,w,y,f);if(v===void 0||!Number.isFinite(v))continue;let A={timestamp:v,voice:u.id,hit:y,pass:w,event:c[y].event,score:u.spec.score,name:u.spec.name,tags:u.spec.tags??oF,subjects:u.named?.list};this.due.push({time:v,item:A,into:d.booked,key:S})}d.seenTo=m}for(let[u,c]of this.tracks)if(c.met!==o){for(let d of c.booked.values())d.time>t&&d.taken?.cancel();this.tracks.delete(u)}}timeOfHit(t,n,r,o,i){if(t.state==="done"||r>=t.passes)return;let s=t.timeAt(r*t.duration+n[o].at);if(!(!Number.isFinite(s)||i!==void 0&&s>=i))return this.host.hostOf(s)}};function U$(e){let t=e.order*6;switch(e.mark){case void 0:return t;case"start":return t+1;case"in":return t+2;case"coast":return t+3;case"out":return t+4;case"end":return t+5;default:return`${e.order}\0${e.mark}`}}var zi=["start","in","coast","out","end"];function lF(e,t){for(let n of Object.keys(e)){if(zi.includes(n))throw new Error(`blits: ${n} is one of a voice's own marks; a mark placed inside it needs another name`);let r=e[n];if(!DP(r,t))throw new RangeError(t>0?`blits: mark ${n} is voice ms into a pass, 0 up to ${t}, not ${r}`:`blits: mark ${n} is voice ms, 0 or more, not ${r}`)}}function BP(e,t){return(e.pace===null?t:e.pace.timeOf(t))+e.offset}function uF(e,t){return e.pace===null?t:e.pace.reading(t)}function Yh(e,t,n){let r=pF(e,t,n);for(let o of fF(e.transport,t,n))(o.score!==void 0||o.slot===e.slot)&&r.push(o.listed);return dF(r)}function cF(e,t,n){let r=[];for(let o of e.members)r.push(...pF(o,t,n));for(let o of fF(e,t,n))r.push(o.listed);return dF(r)}function dF(e){return e.sort((t,n)=>t.timestamp-n.timestamp||t.order-n.order)}function fF(e,t,n){let r=t-e.offset,o=n-e.offset,i=[];for(let s of e.announced)s.at>=r&&s.at<=o&&i.push({score:s.score,slot:s.slot,listed:{timestamp:s.at+e.offset,mark:void 0,voice:void 0,score:s.score,name:s.name,tags:s.tags,mix:s.mix,order:s.order}});return i}function pF(e,t,n){let r=t-e.offset,o=n-e.offset,i=[];for(let s of[...e.cued,...e.gone]){for(let l of zi)sF(e,s,l,r,o,i);let a=s.spec.marks;if(a!==void 0)for(let l of Object.keys(a))sF(e,s,l,r,o,i)}return i}function sF(e,t,n,r,o,i){let s=Xe(e,t,n),a=s===void 0?s:BP(e,s)-e.offset;a===void 0||a<r||a>o||i.push({timestamp:a+e.offset,mark:n,voice:t.id,score:t.spec.score,name:t.spec.name,tags:t.spec.tags??fn,mix:e.name,order:t.id})}function Xe(e,t,n){if(!Number.isFinite(t.start))return;let r=_n(t);if(!Number.isFinite(r))return;if(n==="start")return r;if(t.arc!==null&&(n==="in"||n==="coast"||n==="out"||n==="end"))return mF(t,r,n);if(n==="in")return r+(t.fade.in??0);if(n==="coast")return V$(e,t,r);if(n!=="out"&&n!=="end")return W$(e,t,r,n);let o=t.out,i,s=!1;if(o!==null)i=o.at;else if(Number.isFinite(t.outAt))i=t.outAt;else if(t.fitting!==null){let l=t.timeAt(t.fitting.end);Number.isFinite(l)&&(i=Math.max(r,l))}else if(t.holding!==null){let l=hF(e,t.holding.children,"end");l!==void 0&&(i=Math.max(r,l),s=!0)}else if(!(t.backs?t.freezesBefore:t.freezesAfter)){let l=t.endsAt();Number.isFinite(l)&&(i=Math.max(r,l))}if(n==="out")return t.state==="done"&&i===void 0?t.doneAt:i;if(t.state==="done")return t.doneAt;if(o!==null)return o.rest?o.deadline===void 0?void 0:o.at+o.deadline:o.at+o.over;if(s)return i;let a=Number.isNaN(t.outOver)?t.fade.out??0:t.outOver;return i===void 0?void 0:i+(e.reduced?0:a)}var aF=1e-9;function W$(e,t,n,r){let o=t.spec.marks;if(o===void 0||!Object.hasOwn(o,r)||t.backs)return;let i=o[r],s=t.elapsedAt(n),a=t.duration,l=0;if(a>0)l=Math.max(0,Math.ceil((s-i)/a-aF));else if(i<s-aF)return;if(l>=t.passes)return;let u=t.timeAt(l*a+i);if(!Number.isFinite(u))return;let c=Xe(e,t,"end");return c!==void 0&&u>=c?void 0:Math.max(n,u)}function V$(e,t,n){if(t.unplayed)return;let r;if(t.fitting!==null)r=t.timeAt(t.fitting.end);else if(t.holding!==null){let i=t.holding;if(i.cutSeq!==Number.POSITIVE_INFINITY)return;i.children.length===0?r=t.state==="done"?i.coast:void 0:(r=hF(e,i.children,"coast"),r!==void 0&&(r=Math.max(r,i.coast)))}else r=t.endsAt();return r===void 0||!Number.isFinite(r)?void 0:(r=Math.max(n,r),(t.out!==null?t.out.at:t.state==="done"?t.doneAt:t.outAt)<r?void 0:r)}function hF(e,t,n){if(t.length===0)return;let r=Number.NEGATIVE_INFINITY;for(let o of t){let i=Xe(e,o,n);if(i===void 0)return;i>r&&(r=i)}return r}var qh=class{start=void 0;in=void 0;coast=void 0;out=void 0;end=void 0};Object.setPrototypeOf(qh.prototype,null);var Xh=class{scopes=new Map;all=new Set;add(t,n){if(n.owner?.state==="done")return;let r=new qh;for(let a=0;a<zi.length;a++){let l=zi[a];r[l]=Xe(t,n,l)}let o=n.spec.marks;if(o!==void 0)for(let a of Object.keys(o))r[a]=Xe(t,n,a);let i={id:n.id,score:n.spec.score,owner:n.owner?.id??-1,name:n.spec.name,tags:n.spec.tags??fn,writes:n.patch.writes,marks:r,held:0},s=this.scopeOf(i.score,i.owner);s.whole===void 0?(s.whole={first:i,last:i},i.held+=2):this.hold(s.whole,i),i.name!==void 0&&this.keep(s.names,i.name,i);for(let a=0;a<i.tags.length;a++)this.keep(s.tags,i.tags[a],i);for(let a=0;a<i.writes.length;a++)this.keep(s.writes,i.writes[a],i);i.held>0&&this.all.add(i),n.holding!==null&&this.dropOwner(n.id)}dropOwner(t){for(let n of this.scopes.values()){let r=n.get(t);if(r!==void 0){n.delete(t),r.whole!==void 0&&this.forget(r.whole);for(let o of r.names.values())this.forget(o);for(let o of r.tags.values())this.forget(o);for(let o of r.writes.values())this.forget(o)}}}scopeOf(t,n){let r=this.scopes.get(t);r===void 0&&(r=new Map,this.scopes.set(t,r));let o=r.get(n);return o===void 0&&(o={whole:void 0,names:new Map,tags:new Map,writes:new Map},r.set(n,o)),o}keep(t,n,r){let o=t.get(n);o===void 0?(t.set(n,{first:r,last:r}),r.held+=2):this.hold(o,r)}hold(t,n){this.release(t.last),t.last=n,n.held++}forget(t){this.all.delete(t.first),this.all.delete(t.last)}release(t){--t.held===0&&this.all.delete(t)}};function yF(e,t,n,r,o){return e.score===n&&(r||e.owner===o)&&(t.name===void 0||e.name===t.name)&&(t.tag===void 0||e.tags.includes(t.tag))&&(t.writes===void 0||e.writes.includes(t.writes))}function lc(e,t){return t.owner===null?e.now:Te(t.owner,e.now)}function _n(e){return e.owner===null?e.start:Do(e.owner,e.start)}function Ki(e,t){return e.pace===null?t:e.pace.at(t,e.u)}function Ho(e,t,n){e.pins??=new Map,e.pins.set(t,n),t.pinned=n}function bF(e){let t=e.pins;for(let[n,r]of t)n.state!=="pending"?t.delete(n):Ia(e,n,Ki(e,r))}function Ia(e,t,n){return n===t.start?!1:(t.start=n,t.anchorNow=n,t.clocks=null,t.seeks++,dn(e,t,e.now),Ke(e,t),!0)}function xF(e,t,n,r){if(n.start!==void 0&&n.in!==void 0)throw new Error("blits: a placement anchors start or in, not both");if(n.out!==void 0&&n.end!==void 0)throw new Error("blits: a placement anchors out or end, not both");if(t.start!==void 0&&(n.start!==void 0||n.in!==void 0))throw new Error("blits: a voice takes start or an anchored start, not both");let o={id:e.nextId,spec:t,owner:r,slot:e.slot,writes:t.patch?.writes??fn},i=[o];for(let u of e.transport.members)for(let c of[u.gone,u.cued])for(let d of c)i.push({id:d.id,spec:d.spec,owner:d.owner,slot:u.slot,writes:d.patch.writes});let s=()=>{throw new Error(`blits: ${t.name??"a voice"}'s placement waits on itself`)},a=(u,c)=>{if("all"in c)return c.all.flatMap(y=>a(u,y));if("any"in c)return c.any.flatMap(y=>a(u,y));let d="of"in c?c.of:"after"in c?c.after:"with"in c?c.with:c.before,f="of"in c?c.mark:"after"in c?"end":"start",p=typeof d=="string"?{name:d}:d,h=p.score??u.spec.score,m=p.score!==void 0;u===o&&p.name!==void 0&&p.name===t.name&&h===t.score&&s();let g=i.filter(y=>y!==u&&y.spec.score===h&&(m||y.owner===u.owner&&y.slot===u.slot)&&(p.name===void 0||y.spec.name===p.name)&&(p.tag===void 0||(y.spec.tags??fn).includes(p.tag))&&(p.writes===void 0||y.writes.includes(p.writes))),b=p.resolver??"last",x=g.length>1&&(b==="first"||b==="last")?[g.reduce((y,P)=>(b==="last"?P.id>y.id:P.id<y.id)?P:y)]:g,w=f==="out"||f==="end"?"out":"start";return x.map(y=>({voice:y,side:w}))},l=(u,c)=>{let d=u.spec.anchor,f=c==="start"?[d?.start,d?.in]:[d?.out,d?.end],p=c==="out"?[{voice:u,side:"start"}]:[];for(let h of f)h!==void 0&&typeof h!="number"&&p.push(...a(u,h));return p};for(let u of["start","out"]){let c={start:new Set,out:new Set},d=l(o,u);for(;d.length>0;){let{voice:f,side:p}=d.pop();f===o&&p===u&&s(),!c[p].has(f)&&(c[p].add(f),d.push(...l(f,p)))}}}function zr(e){for(let t=0;t<=e.cued.length;t++){let n=!1;for(let r of e.cued){let o=r.spec.anchor;if(!(o===void 0||r.state==="done")){if(r.placing&&r.state==="pending"){let i=o.start??o.in,s=i===void 0?void 0:Na(e,i,r);if(s!==void 0){let a=r.owner,l=r.fade.in??0,u=o.start!==void 0?s:a===null?s-l:Te(a,Do(a,s)-l);Number.isFinite(u)&&Ia(e,r,u)&&(n=!0)}}if(r.state!=="fading"&&!r.outSet){let i=o.out??o.end,s=i===void 0?void 0:Na(e,i,r);if(s!==void 0){let a=r.owner===null?s:Do(r.owner,s),l=_n(r),u=o.out!==void 0?a:a-(r.fade.out??0),c=Number.NaN;u<l&&Number.isFinite(l)&&(u=l,o.end!==void 0&&(c=a>l?a-l:0,a<l&&!e.projecting&&er(r,`${r.spec.name??`voice ${r.id}`}'s placement ends before it starts, so it plays as an instant`))),(u!==r.outAt||!Kt(c,r.outOver))&&(r.outAt=u,r.outOver=c,Ke(e,r),n=!0)}}}}if(!n)break}wF(e)}function Na(e,t,n,r){let o=n.owner;if(typeof t=="number")return o===null?Ki(e,t-n.offset):t;if("all"in t){let c=Number.NEGATIVE_INFINITY;for(let d of t.all){let f=gF(e,d,n,r);if(f===void 0)return;c=Math.max(c,f)}return t.all.length===0?void 0:c}if("any"in t){let c=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:lc(e,n),d=Number.POSITIVE_INFINITY,f=!1;for(let p of t.any){let h=gF(e,p,n,r);h===void 0?f=!0:d=Math.min(d,h)}return d===Number.POSITIVE_INFINITY||f&&d>c?void 0:d}let i,s,a=t.by??0;"of"in t?(i=t.of,s=t.mark):"after"in t?(i=t.after,s="end"):"with"in t?(i=t.with,s="start"):(i=t.before,s="start",a=-a);let l=z$(e,i,s,n);if(l===void 0)return;if(o===null)return l+a;let u=Te(o,l);return u===Number.NEGATIVE_INFINITY?r:Number.isFinite(u)?u+a:void 0}function gF(e,t,n,r){let o=Na(e,t,n,r);return o===void 0?n.answers?.get(t):(e.projecting||(n.answers??=new Map,n.answers.set(t,o)),o)}var Ra=class{resolver;now;any=!1;firstOrder=Number.POSITIVE_INFINITY;lastOrder=Number.NEGATIVE_INFINITY;first;last;pick;constructor(t,n){this.resolver=t,this.now=n}take(t,n){this.any=!0,t<this.firstOrder&&(this.firstOrder=t,this.first=n),t>this.lastOrder&&(this.lastOrder=t,this.last=n),n!==void 0&&this.consider(n)}merge(t){t.any&&(this.any=!0,t.firstOrder<this.firstOrder&&(this.firstOrder=t.firstOrder,this.first=t.first),t.lastOrder>this.lastOrder&&(this.lastOrder=t.lastOrder,this.last=t.last),t.pick!==void 0&&this.consider(t.pick))}consider(t){let n=this.pick;(this.resolver==="earliest"?n===void 0||t<n:this.resolver==="latest"?n===void 0||t>n:this.resolver==="next"&&t>=this.now&&(n===void 0||t<n))&&(this.pick=t)}answer(){if(this.any)return this.resolver==="first"?this.first:this.resolver==="last"?this.last:this.pick}};function z$(e,t,n,r){let o=typeof t=="string"?{name:t}:t,i=o.score??r.spec.score,s=o.score!==void 0,a=o.resolver??"last",l=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,u=new Ra(a,l),c=m=>m!==r&&m.spec.score===i&&(s||m.owner===r.owner)&&(o.name===void 0||m.spec.name===o.name)&&(o.tag===void 0||(m.spec.tags??fn).includes(o.tag))&&(o.writes===void 0||m.patch.writes.includes(o.writes)),d=s&&i!==void 0&&!e.projecting,f=s?d?wO(e,i):e.transport.members:[e],p=r.owner?.id??-1,h=new Ra(a,l);for(let m=0;m<f.length;m++){let g=f[m],b=!1;for(let v of g.departed.all)yF(v,o,i,s,p)&&(h.take(v.id,v.marks[n]),b=!0);if(i===void 0||g.projecting||e.projecting){for(let v of[...g.gone,...g.cued])c(v)&&u.take(v.id,Xe(g,v,n));continue}let x=vO(g,i),w=AO(g,i);if(x.size===0&&w.length===0&&!b){d&&(PP(g,i),m--);continue}if(a==="next"){for(let v of x)c(v)&&u.take(v.id,Xe(g,v,n));for(let v of w)c(v)&&u.take(v.id,Xe(g,v,n));continue}let y=K$(g,w,t,n,r,a),P=SO(g,i),S=g.reduced;if(y.live===null||y.liveOf!==g.cued||y.liveVersion!==P||y.liveReduced!==S){let v=new Ra(a,Number.NEGATIVE_INFINITY),A=!0;for(let N of x)c(N)&&((N.owner!==null||N.holding!==null||N.fitting!==null)&&(A=!1),v.take(N.id,Xe(g,N,n)));y.live=v,y.liveOf=A?g.cued:null,y.liveVersion=P,y.liveReduced=S}for(u.merge(y.live);y.seen<w.length;y.seen++){let v=w[y.seen];c(v)&&(v.owner===null?y.pick.take(v.id,Xe(g,v,n)):y.owned.push(v))}u.merge(y.pick);for(let v of y.owned)u.take(v.id,Xe(g,v,n))}if(o.writes===void 0&&(s||r.owner===null))for(let m of e.announced)m.score===i&&(i!==void 0||m.slot===e.slot)&&(o.name===void 0||m.name===o.name)&&(o.tag===void 0||m.tags.includes(o.tag))&&u.take(m.order,Number.isNaN(m.at)?void 0:Ki(e,m.at));return(u.any?u:h).answer()}function K$(e,t,n,r,o,i){o.folds??=new Map;let s=o.folds.get(n);s===void 0&&(s=new Map,o.folds.set(n,s));let a=s.get(e);return(a===void 0||a.list!==t||a.mark!==r)&&(a={list:t,mark:r,seen:0,pick:new Ra(i,Number.NEGATIVE_INFINITY),owned:[],live:null,liveOf:null,liveVersion:-1,liveReduced:!1},s.set(e,a)),a}function GP(e){if(!Number.isFinite(e))throw new RangeError(`blits: a voice's rate is a finite number, not ${e}`)}function UP(e){if(Number.isNaN(e))throw new RangeError("blits: a voice\u2019s weight is a number, not NaN")}var Kr=class{id;#t;#n=null;#e;constructor(t,n){this.id=t.id,this.#t=t,this.#e=n}static voiceOf(t){return t.#t}static page(t,n){t.#t=null,t.#n=n}static rehome(t,n){t.#t=n,t.#n=null}get state(){return this.#t?.state??"done"}get owner(){return this.#t?.owner?.handle??void 0}get played(){return this.#t?.played??Promise.resolve(this.#n?.played??!1)}get done(){return this.#t?.done??Promise.resolve()}get result(){return this.#t?.fitting?.report}get weight(){return this.#t?.weight??this.#n?.weight??0}get#r(){let t=this.#t;return t===null||t.parked?null:t}set weight(t){UP(t);let n=this.#r;n!==null&&(n.written=!0,n.weight=t,this.#e.changed(n),this.#e.taping()&&this.#e.record(this,"weight",r=>{r.weight=t}))}get rate(){let t=this.#t;return t===null?0:t.rateAt(this.#e.nowFor(t))}set rate(t){this.ramp(t,0)}ramp(t,n){GP(t);let r=this.#r;if(r!==null){if(r.written=!0,r.state==="pending"){let o=r.ramp===null?r.rate:r.ramp.from;r.ramp=n>0&&t!==o?{from:o,to:t,over:n}:null,r.rate=t}else{let o=this.#e.nowFor(r);Fo(r,o),ga(r,o,t,n)}this.#e.changed(r),this.#e.taping()&&this.#e.record(this,"rate",o=>o.ramp(t,n))}}seek(t,n){let r=this.#r;if(r===null)return"exact";r.written=!0;let o=!1;if(r.state!=="pending"){let s=this.#e.nowFor(r);Fo(r,s,!0),r.rebase(s),o=t>r.anchorElapsed}r.anchorElapsed=t,r.seeks++;let i=this.#e.sought(r,n?.state!=="keep",o);return this.#e.changed(r),this.#e.taping()&&this.#e.record(this,"seek",s=>s.seek(t,n)),i}fade(t){let n=this.#r;n!==null&&(n.written=!0,this.#e.fade(n,t),this.#e.taping()&&this.#e.record(this,"fade",r=>r.fade(t)))}rise(t){let n=this.#r;n!==null&&(n.written=!0,this.#e.rise(n,t),this.#e.taping()&&this.#e.record(this,"rise",r=>r.rise(t)))}release(){let t=this.#r;t!==null&&(t.written=!0,this.#e.release(t),this.#e.taping()&&this.#e.record(this,"release",n=>n.release()))}weightOf(t){let n=this.#t;return n===null?0:this.#e.weightOf(n,t)}to(t,n,r){let o=this.#t;o!==null&&HP(o.patch,"to","a spring or a tween").to(t,n,r)}push(t,n,r){let o=this.#t;o!==null&&HP(o.patch,"push","a spring or a glide").push(t,n,r)}set(t,n,r){let o=this.#t;o!==null&&HP(o.patch,"set","a motion patch").set(t,n,r)}read(t,n){let r=this.#t;if(!(r===null||Ln(r.patch)===void 0))return r.patch.read(t,n)}};function HP(e,t,n){if(Ln(e)===void 0||typeof e[t]!="function")throw new Error(`blits: ${t} needs a voice playing ${n}`);return e}var j$=new WeakSet,PF=e=>j$.has(e);function uc(e,t,n){let r=n===0?0:Math.abs(e*n-t);return r>=1?0:1-r}var Qh={transport:e=>e,mix:e=>e},cc=Qh,Jh;function Ea(e){throw new Error(`blits: the tape holds ${e}, which a read ahead cannot play; seek there to see it`)}var TF={apply(){},invert:()=>TF};function SF(e){let t=e.history?.tape;if(t!==void 0)return t(e,{now:()=>Number.isNaN(e.u)?Number.NEGATIVE_INFINITY:e.u,branching:!0,coalesceWindowMs:0})}function jr(e){return e.tape!==void 0&&!e.replaying&&!e.projecting}function Ot(e,t,n){let r=e.tape;if(r===void 0||!jr(e))return;let o={label:t,apply(){if(cc===Qh)n(cc);else try{n(cc)}catch(i){Jh??={error:i}}},invert:()=>TF};r.recordEntry([o],t)}function ji(e,t){return e.pace===null?t:e.pace.timeOf(t)}function $r(e,t){let n=ji(e,t);return e.u>n?e.u:n}function Ma(e,t,n=e,r=Qh){let o=e.tape;if(o===void 0)return Number.NaN;let i=n.u,s=Number.NaN;try{for(;;){let a=o.timestampAt(o.undoDepth());if(a===void 0||!t(a))return s;if(a!==s){s=a,n.u=a;let l=n.pace===null?a:n.pace.reading(a);if(l>n.now)for(let u of n.members)Yr(u,l);n.tick(n.now)}e.replaying=!0,cc=r;try{o.redo()}finally{e.replaying=!1,cc=Qh}if(Jh!==void 0){let{error:l}=Jh;throw Jh=void 0,l}}}finally{n.u=i}}function kF(e,t,n){let r=e.strays.get(n);r===void 0?e.strays.set(n,[t]):r.includes(t)||r.push(t)}function vF(e,t){let n=t.motion;if(n===void 0)return;let r=(e.playing.get(n)??1)-1;if(r<=0){e.playing.delete(n),e.strayAll.delete(n);return}if(e.playing.set(n,r),t.named===null)e.strayAll.add(n);else for(let o of t.named.list)kF(e,n,o)}function AF(e){return{frame(t,n){let r=e.deref(),o=r===void 0?void 0:Go(r,t);return r===void 0||o===void 0?Number.NaN:RF(r,o,n)},now(){return e.deref()?.now??Number.NaN},seq(){return e.deref()?.transport.seq??Number.NaN},early(){let t=e.deref();return t!==void 0&&(t.syncing||!t.looked)},changed(t,n,r,o){let i=e.deref();i!==void 0&&jr(i)&&$$(i,t,n,r,o)},page(t,n,r,o){let i=e.deref(),s=i?.opts.history?.ms;i===void 0||i.keys===null||s===void 0||nr(i,n,t,i.keys.key(r),o,a=>a.data,i.now-s)},revive(t,n){let r=e.deref();if(r===void 0)return Number.NaN;r.stir();let o=Go(r,t);return o===void 0||(o.motion!==void 0&&o.named!==null&&!o.named.has(n)&&kF(r,o.motion,n),o.parted?.has(n)!==!0)?Number.NaN:(VP(r,o,n),WP(r,o,sc(o,n)))}}}function $$(e,t,n,r,o){Ot(e,"motion",i=>{let s=i.mix(e);if(s===void 0)return;if(s!==e)return Y$(s,t,n,r,o);((Go(e,t)??e.gone.find(l=>l.id===t))?.motion??n).change(r,{...o})})}function Y$(e,t,n,r,o){let i=r,s=Go(e,t),a=o.at;if(s!==void 0){let p=s.parted?.has(i)===!0;if(p&&VP(e,s,i),a===void 0){let h=RF(e,s,i),m=p?WP(e,s,sc(s,i)):h;Number.isNaN(h)?Number.isNaN(m)||(a=m):a=h}}a===void 0&&Ea("a change to a motion made before its voice met the subject");let l=a,u=e.transport.ahead,c=u.get(n);c===void 0&&(c=new Map,u.set(n,c));let d=c.get(i),f={at:a,to:o.to,x:o.x,v:o.v};if(d===void 0)c.set(i,[f]);else{let p=d.length;for(;p>0&&d[p-1].at>l;)p--;d.splice(p,0,f)}}function Go(e,t){let n=e.cued,r=0,o=n.length-1;for(;r<=o;){let i=r+o>>1,s=n[i];if(s.id===t)return s;s.id<t?r=i+1:o=i-1}}function RF(e,t,n){let r=t.subjects.get(n);return r===void 0||!r.reaches?Number.NaN:WP(e,t,r.delay)}function WP(e,t,n){if(Number.isNaN(e.now)||t.state==="pending")return Number.NaN;let r=t.elapsedAt(e.now)-n;return r<0?Number.NaN:r}function EF(e,t){if(e.projecting)throw new Error("blits: a projection books nothing");let n={get voices(){return e.cued},get timestamp(){return e.last},get now(){return e.now},hostOf:o=>BP(e,o),readingAt:o=>uF(e,o-e.offset),endOf:o=>Xe(e,o,"end"),marks:(o,i)=>Yh(e,o,i),unhook:o=>{let i=(e.bookers??[]).filter(s=>s!==o);e.bookers=i.length===0?null:i}},r=new $h(n,t);return e.bookers=[...e.bookers??[],r],r}function Zh(e){return{get voices(){return e.cued},channels:e.channels,names:e.names,clock:e,fits:t=>q$(e,t),meet:(t,n,r,o)=>{for(let i=r;i!==null;i=i.next)if(i.voice===t)return i;return e.held(t,n,o)},forgot:t=>{e.places?.forgot(t);for(let n of e.general)Vr(n,t,!1),n.sighted!==null&&e.share?.unsight(n,t);for(let n of Bo(e).general)Vr(n,t,!1)},passes:(t,n)=>e.passes(t,n),naming:t=>e.naming===0?void 0:e.named.get(t),slotOf:t=>ut(e,t)?.slot??-1,envelope:(t,n)=>t.owner===null?e.envelope(t,e.now,n):e.envelope(t,e.now,n)*e.ownedBy(t,void 0),parting:(t,n)=>e.parting(t,n,e.now),ready:(t,n,r)=>{let o=e.lanes.arg;e.primeLaned(t,r,o),t.setting.weight=o[0],e.sending.voice=t,e.sending.subject=n},signal:(t,n,r,o)=>{let i=e.lanes.arg,s=t.blend===null?Number.NaN:e.laneRead(t,o);if(!Number.isNaN(s)){i[0]=s;return}e.primeLaned(t,r,i);let a=pe.kept,l=e.base(t,n,e.now,r,o);pe.kept!==a&&!t.keeping&&$i(e,t),i[0]=l},horizon:(t,n)=>{t.motion!==void 0&&(pe.horizon=e.horizonFor(t,n,e.now))},keeps:e.opts.history!==void 0,after:(t,n,r)=>em(e,t,n,r),kept:t=>$i(e,t)}}function Yi(e){return e.named!==null&&e.named.size===1&&e.spec.role===void 0&&(e.slots.length===1||e.motion===void 0)&&e.motion?.round!==!0}function q$(e,t){let n=t.spec,r=t.patch;if(t.keeping||(t.freezesBefore||t.state==="fading")&&t.unstarted(e.now)||t.beginless||t.out?.back===!0||t.owner!==null&&WO(t))return!1;let o=n.weight;if(typeof o=="function"&&o.input&&(e.opts.history?.inputs||!PF(o))||r.reads!==void 0&&r.reads.length>0||n.role!==void 0&&t.motion!==void 0||n.from==="current"||(t.motion!==void 0||n.role!==void 0||Yi(t))&&t.slots.some(s=>Jn(e.channels[s])?.op==="last")||t.out?.rest||r.state!==void 0||r.step!==void 0)return!1;let i=t.built;return i===null||i.tracks.every((s,a)=>s.lerp===void 0||s.lerp===t.lerps[a])}var NF={exact:0,stepped:1,held:2};function IF(e,t,n){let r=t.patch;if(r.state===void 0&&r.step===void 0&&!t.keeping)return"exact";if(!n)return"held";let o=t.spec.weight;return r.reads!==void 0&&r.reads.length>0||typeof o=="function"&&o.input?"held":t.keeping?"stepped":r.step===void 0||Io(e,t)!==void 0&&e.opts.maxDt===void 0?"exact":"stepped"}function $i(e,t){t.keeping||(t.keeping=!0,t.sharing&&e.share?.unshare(e,t,!0,e.sending.subject),e.lanes?.invalidate())}function dc(e,t){return e.handles??=X$(e),new Kr(t,e.handles)}function X$(e){return{nowFor:t=>{if(Number.isNaN(e.now))return t.start;let n=lc(e,t);return Number.isFinite(n)?n:t.start},changed:t=>{e.frame=st(),dn(e,t,e.now),t.holding!==null&&Vi(t,n=>dn(e,n,e.now)),Ke(e,t),e.lanes?.refill()},sought:(t,n,r)=>{r&&t.holding!==null&&!e.projecting&&(e.leapt??=new Set,e.leapt.add(t)),n&&t.rebuilds++;let o=IF(e,t,n);return t.holding!==null&&Vi(t,i=>{i.seeks++,n&&i.rebuilds++;let s=IF(e,i,n);NF[s]>NF[o]&&(o=s),it(e,i)}),o},fade:(t,n)=>{if(t.holding!==null&&n!==void 0&&("subject"in n||n.at==="rest"))throw new Error("blits: an owner fades as a whole, not by subject or at rest");n!==void 0&&"subject"in n?MF(e,t,n.subject,n.over):typeof n?.at=="number"?OF(e,t,n.at,n.over):qr(e,t,n??{})},rise:(t,n)=>CF(e,t,n??{}),release:t=>FF(e,t),weightOf:(t,n)=>{if(t.state==="done")return 0;if(t.holding!==null)return kP(t,e.now,e.reducedNow,i=>e.ownerBase(i,n));let r=e.lanes===null?-1:ut(e,n)?.slot??-1;if(t.laned&&e.lanes!==null){let i=e.lanes.weightOf(t.id,r);if(i!==void 0)return i}let o=t.sharing?void 0:t.subjects.get(n);return o!==void 0?o.weight:e.share===null?0:e.share.weightAt(t,r)},taping:()=>jr(e),record:(t,n,r)=>Ot(e,n,o=>{let i=o.mix(e);if(i===e)r(t);else if(i!==void 0){let s=Go(i,t.id);s!==void 0&&r(dc(i,s))}})}}function fc(e,t){return{by:e,stops:t,members:[],frame:0,subject:void 0,value:0,reads:new me,frames:new Float64Array(0),values:new Float64Array(0)}}function Ca(e){let t=new Map;for(let n of e){if(n.blend===null)continue;let r=t.get(n.blend.of);r===void 0&&(r=fc(n.blend.of.by,n.blend.of.stops),t.set(n.blend.of,r)),n.blend={of:r,i:n.blend.i},r.members.push(n)}}function LF(e,t,n,r){let{of:o,i}=e.blend,s=this.frame,a;if(r<0){if(o.frame===s&&o.subject===t)return uc(o.value,i,o.stops);if(a=o.reads.get(t),a?.frame===s)return uc(a.value,i,o.stops)}else if(r>=o.frames.length){let c=Math.max(r+1,o.frames.length*2,64),d=new Float64Array(c),f=new Float64Array(c);d.set(o.frames),f.set(o.values),o.frames=d,o.values=f}let l=pe.kept,u=o.by(t,e.setting);return pe.kept!==l&&!this.projecting&&this.shareKept(o,e,t,n),r<0?(o.frame=s,o.subject=t,o.value=u,a===void 0?o.reads.set(t,{frame:s,value:u}):(a.frame=s,a.value=u)):(o.frames[r]=s,o.values[r]=u),uc(u,i,o.stops)}function _F(e,t){let{of:n,i:r}=e.blend;return t<n.frames.length&&n.frames[t]===this.frame?uc(n.values[t],r,n.stops):Number.NaN}function DF(e,t,n,r){for(let o of e.members){let i=o===t?void 0:o.subjects.get(n);i?.reaches&&i.kept===null&&(i.kept=r.kept),$i(this,o)}}var BF=new WeakMap,HF=e=>typeof e=="function"?BF.get(e):void 0;function GF(e,t={}){if(typeof e!="object"||e===null)throw new TypeError("blits: around takes a circle, { x, y, r }");let n=Co(t.ease??"linear"),r=o=>{let i=this.places;if(i===null)return 0;let s=i.cur>=0?i.cur:i.at.get(o)??-1,a=i.xy;if(s<0||2*s+1>=a.length)return 0;let l=e.r,u=a[2*s]-e.x,c=a[2*s+1]-e.y,d=u*u+c*c;return!(l>0)||!(d<=l*l)?0:n(1-Math.sqrt(d)/l)};return BF.set(r,e),r}var J$=wa;function Q$(e,t){let n=new Uint8Array(t);return e.bands=n,n}function hc(e,t){return typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<1e-9:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,r)=>hc(n,t[r])):e===t}function pc(e,t,n){let r=e.merge(t,n);if(r!==n||!Array.isArray(r))return r;if(!Array.isArray(t)||t.length!==r.length)return[...r];for(let o=0;o<r.length;o++)t[o]=r[o];return t}function kt(e){e?.bands&&e.bands.fill(2)}function UF(e,t){let{on:n,off:r}=this.band;return t>=n?!0:t<=r?!1:e??t>=n}function WF(e,t,n,r,o){let i=t.slots;for(let s=0;s<i.length;s++){let a=i[s],l=this.names[a],u=r[l];if(u===void 0)continue;let c=this.scalars[a];if(c!==void 0&&typeof u=="number"){e[l]=Oe(c,e[l],u,o);continue}let d=this.channels[a];if(d.rest!==void 0&&d.scale){e[l]=d.fold?d.fold(e[l],u,o):pc(d,e[l],d.scale(u,o));continue}let f=n.bands??Q$(n,i.length),p=f[s],h=this.passes(p===0?void 0:p===1,o);f[s]=h?1:2,h&&(e[l]=e[l]===void 0?Hi(u):pc(d,e[l],u))}}function VF(e){for(let t of this.bounded){let n=this.names[t];e[n]=Z$(this.channels[t],e[n])}return e}function Z$(e,t){let[n,r]=e.bounds;if(typeof t=="number")return t<n?n:t>r?r:t;if(Array.isArray(t))for(let o=0;o<t.length;o++){let i=t[o];t[o]=i<n?n:i>r?r:i}return t}function zF(e,t,n,r){if(e.sharing){if(t<0)return r;let s=this.lanes;return this.share.weighAt(e,t,n.weight,s.cap),this.share.shut(e,n,t,s.cap),r}let o=this.sharers,i=0;for(;i<o.length&&o[i].id<e.id;)i++;return i}function KF(e,t,n=!1,r){let o=this.folded(e,t,n,r);return this.bounded.length===0?o:this.clamp(o)}function jF(e,t,n=!1,r){let o=this.linked(e);return this.foldWith(e,t??this.pose(),o,this.linkedLaned,n,r)}function $F(e){let t=Number.isNaN(this.now)?null:this.chain(e),n=this.lanes;return t!==null&&n!==null&&n.laned.length===0&&n.frameAt===this.now&&n.qualifiedVersion===this.version&&n.touched.length===0&&!n.filling?(t.slot>=0&&(n.per[t.slot*6+4]=++n.probes),this.linkedLaned=!1,t):(this.linkedLaned=t!==null&&n?.prepare(t.slot,e,this.version,t)===!0,t)}function YF(e,t,n,r,o,i){let s=t,a=this.lanes,l=r?a.copies:null;for(let c=0;c<this.names.length;c++){if(l?.[c])continue;let d=this.channels[c],f=d.rest,p=this.names[c];if(f===void 0){s[p]!==void 0&&(s[p]=void 0);continue}let h=this.lerpsInto[c]===void 0?void 0:s[p];if(Array.isArray(h)&&h!==f&&h.length===f.length)for(let m=0;m<h.length;m++)h[m]=f[m];else s[p]=d.copy?d.copy(f):J$(f)}if(n===null)return s;let u=-1;if(r){let c=a;if(c.copy(n.slot,s),c.owes(n.slot))u=n.slot;else if(c.whole)return s}if(this.detours===0){let c=this.now;for(let d=n;d!==null;d=d.next){let f=d.voice;if(f===null||r&&f.laned&&!this.owedBy(u,f)||f.id===i||f.state==="done")continue;let p=this.read(f,e,c,o,d);u>=0&&f.laned&&a.paid(f.id,u,d.weight),d.weight>0||kt(d),!(p===null||this.w<=0)&&this.apply(s,f,d,p,this.w)}return s}return this.foldDetour(e,s,n,r,o,i,u)}function qF(e,t,n,r,o,i,s){let a=n.version===this.version?n:this.chain(e);if(this.roleVoices!==0)return this.foldRoles(e,t,a,r,o,i,s);let l=this.now,u=this.lanes,c=this.sharers,d=0;for(let f=a;f!==null;f=f.next){let p=f.voice;if(p===null||(d<c.length&&c[d].id<p.id&&(d=this.foldSharers(t,e,a,d,p.id,r,o,i,s)),r&&p.laned&&!this.owedBy(s,p))||p.id===i||p.state==="done")continue;let h=this.read(p,e,l,o,f);s>=0&&p.laned&&u.paid(p.id,s,f.weight),f.weight>0||kt(f),!(h===null||this.w<=0)&&this.apply(t,p,f,h,this.w)}return d<c.length&&this.foldSharers(t,e,a,d,Number.MAX_SAFE_INTEGER,r,o,i,s),t}function XF(e,t,n,r,o,i,s,a,l){let u=this.sharers,c=this.now;for(;r<u.length;){let d=u[r];if(d.id>=o)break;r++;let f=d.state==="pending"?null:d.everyone;if(f===null||i&&d.laned&&!this.owedBy(l,d)||d.id===a||d.state==="done")continue;this.share.open(d,f,n.slot);let p=this.read(d,t,c,s,f);l>=0&&d.laned&&this.lanes.paid(d.id,l,f.weight),r=this.shared(d,n.slot,f,r),!(p===null||this.w<=0)&&this.apply(e,d,f,p,this.w)}return r}function JF(e,t){return e>=0&&this.lanes.owesVoice(e,t.id)}var tm=5,nm=new Map,QF=new WeakMap,ZF=0,e8=0;function t8(e){if(e===void 0)return 0;let t=QF.get(e);return t===void 0&&(t=++e8,QF.set(e,t)),t}var zP=e=>Object.is(e,-0)?"-0":String(e);function n8(e){let t=zP(e.duration);for(let r of e.tracks){if(r===void 0)return++ZF;t+=`|${zP(r.delay)}`;for(let o of r.all)t+=`,${zP(o.at)}:${t8(o.ease)}`}let n=nm.get(t);return n===void 0&&(nm.size>=4096&&nm.clear(),n=++ZF,nm.set(t,n)),n}var Oa=class{data=new Float64Array(64);used=0;eases=[];lastTiming=-1;lastPhase=Number.NaN;found=new Int32Array(4);easedAt=new Float64Array(4);add(t,n){let r=tm,o=0;for(let l=0;l<t.tracks.length;l++){let u=t.tracks[l],c=n[l];if(u===void 0||c===void 0||!c.plain||!c.straight)return-1;for(let d of u.all)if(!r8(d.value,c))return-1;r+=2+u.all.length*(1+c.axes),o+=u.all.length}let i=this.reserve(r),s=this.data;s[i]=r,s[i+1]=this.eases.length,s[i+2]=t.duration,s[i+3]=o,s[i+4]=n8(t);let a=i+tm;for(let l=0;l<t.tracks.length;l++){let u=t.tracks[l],c=n[l];s[a++]=u.all.length,s[a++]=u.delay;for(let d of u.all){if(s[a++]=d.at,c.scalar)s[a++]=d.value;else{let f=d.value;for(let p=0;p<c.axes;p++)s[a++]=f[p]??c.rest}this.eases.push(d.ease)}}return i}copy(t,n){let r=t.data[n],o=this.reserve(r);this.data.set(t.data.subarray(n,n+r),o);let i=t.data[n+1],s=t.data[n+3];this.data[o+1]=this.eases.length;for(let a=0;a<s;a++)this.eases.push(t.eases[i+a]);return o}fold(t,n,r,o,i){let s=this.data;(s[t+4]!==this.lastTiming||n!==this.lastPhase||n===0)&&this.search(t,n,r);let l=this.found,u=this.easedAt,c=t+tm,d=t+s[t];for(let f=0;c<d;f++){let p=r[f],h=p.axes,m=1+h,g=s[c],b=c+2;c=b+g*m;let x=l[f];if(x===-2)continue;let w=p.values,y=o*h;if(x===-1||x===g){let A=b+(x===-1?0:g-1)*m+1;for(let N=0;N<h;N++)w[y+N]=Oe(p.op,w[y+N],s[A+N],i);continue}let P=b+x*m,S=P-m,v=u[f];for(let A=0;A<h;A++){let N=Ct(s[S+1+A],s[P+1+A],v);w[y+A]=Oe(p.op,w[y+A],N,i)}}}search(t,n,r){let o=this.data;this.lastTiming=-1;let i=o[t+2],s=o[t+1],a=t+tm,l=t+o[t];for(let u=0;a<l;u++){u>=this.found.length&&this.grow(u+1);let c=1+r[u].axes,d=o[a],f=NP(o[a+1],n,i),p=a+2;a=p+d*c;let h=IP(o,p,c,d,f);if(this.found[u]=h,h>=0&&h<d){let m=p+h*c,g=EP(f,o[m-c],o[m]),b=this.eases[s+h];this.easedAt[u]=b?b(g):g}s+=d}this.lastTiming=o[t+4],this.lastPhase=n}grow(t){let n=new Int32Array(t*2);n.set(this.found),this.found=n;let r=new Float64Array(t*2);r.set(this.easedAt),this.easedAt=r}reserve(t){let n=this.used;if(n+t>this.data.length){let r=new Float64Array(Math.max(n+t,this.data.length*2));r.set(this.data.subarray(0,n)),this.data=r}return this.used=n+t,n}};function r8(e,t){if(t.scalar)return typeof e=="number";if(!(Array.isArray(e)||ArrayBuffer.isView(e)))return!1;let n=e;for(let r=0;r<t.axes;r++){let o=n[r];if(o!==void 0&&typeof o!="number")return!1}return!0}function eL(e,t,n){let r=t.voice,o=t.data,i=e.per,s=t.list,a=t.records,l=t.chans[0],u=e.fills,c=e.frameProbes,d=e.lately,f=r.seeks,p=r.elapsedAt(e.now),h=t.flat,m=r.parts!==null,g=typeof r.spec.weight=="function",b=e.probes!==c,x=Br(r.weight),w=e.arg,y=n.n,P=l.op;if(y>0&&(t.axes!==y&&(t.axes=y,t.samples=new Float64Array(0)),s.length*y>t.samples.length)){let D=new Float64Array(Math.max(s.length,t.samples.length/y*2,4)*y);D.set(t.samples),t.samples=D}let S=t.samples,v=n.xs,A=n.round?void 0:n.ease;n.watcher===null&&(n.watcher=e,n.watchId=r.id);let N=A!==void 0&&!g&&n.watcher===e&&n.watchId===r.id,M=y===l.axes&&l.plain,C=Number.NaN,F=Number.NaN,B=0;for(let D=0;D<s.length;D++){if(g&&r.keeping)return;let j=s[D],W=D*8,J=j*6;if(Ft(o,W,i,J,u),d>=0&&e.unread(j)){Fa(t,D);continue}let se=o[W+0],ke=p-se;if(!(ke>=0)){Fa(t,D),o[W+2]=0;continue}if(!h){let ee=o[W+1];(!t.weighed||!Kt(ee,t.weighedSince))&&(t.fade=e.host.envelope(r,ee),t.weighed=!0,t.weighedSince=ee)}let ae;if(g){if(w[1]=ke,w[3]=Zn(ke,r.duration,r.passes),w[5]=t.fade,!e.signalled(r,j,a[D])){o[W+2]=0;continue}ae=w[0]}else if(m)ae=jt(r.weight,t.fade,e.parting(r,j));else if(h)ae=x;else{let ee=t.fade,te=r.weight;(ee!==C||te!==F||ee===0||te===0)&&(C=ee,F=te,B=jt(te,ee,1)),ae=B}if(o[W+2]=ae,o[W+7]===0){if(Number.isNaN(a[D].probed)){Fa(t,D),e.late.push(j);continue}o[W+7]=1}let ve=o[W+4],G=-1,K=!1;if(ve>=0){G=5+ve*n.stride;let ee=n.runs[G+1];(ee&6)!==0&&(G=-1),K=(ee&1)!==0}if(G<0||b&&(i[J+3]>c||i[J+4]>c)){w[1]=ke,w[4]=se,w[0]=ae,mc(e,t,n,D,j,a[D]);continue}let $=n.runs;if(N&&M&&K===l.scalar){if(o[W+5]!==-2&&(o[W+5]=-2,t.deltas[D]=null),ae<=0)continue;let ee=Eo(A,Hr(ke,$[G],$[G+2])),te=l.values,he=j*y,be=G+3,Fe=be+2*y;for(let Se=0;Se<y;Se++)te[he+Se]=Oe(P,te[he+Se],Mo($[be+Se],$[Fe+Se],ee),ae);continue}if(A!==void 0){let ee=Eo(A,Hr(ke,$[G],$[G+2])),te=G+3,he=te+2*y;for(let be=0;be<y;be++)v[be]=Mo($[te+be],$[he+be],ee)}else n.sampleBare(ve,ke,v,n.vs);for(let ee=0;ee<y;ee++)S[D*y+ee]=v[ee];if(t.deltas[D]!==null&&(t.deltas[D]=null),o[W+5]=u,o[W+6]=f,!(ae<=0))if(M&&K===l.scalar){let ee=l.values,te=j*y;for(let he=0;he<y;he++)ee[te+he]=Oe(P,ee[te+he],v[he],ae)}else w[0]=ae,e.foldInto(l,j,n.value(ve,v))}N&&(t.bareFill=u,t.bareElapsed=p,t.bareSeeks=f)}function mc(e,t,n,r,o,i){let s=e.arg[1],a=e.arg[4],l=e.arg[0],u=t.voiceAt(r),c=t.data,d=r*8,f=t.chans[0];if(yc(e,t,r,o,i),!(l>0))return;let p=i.delta;if(p===null||i.probed!==e.now||i.seeks!==u.seeks||!e.probedThisFrame(o)){let h=c[d+4];if(h<0){let g=e.subjectAt(o);if(g===rr)return;h=n.slot(g),c[d+4]=h,t.numbered(r,h)}if(e.keeps?e.host.horizon(u,a):pe.horizon=Number.POSITIVE_INFINITY,!n.quiet(h,s)){e.late.push(o);return}n.sample(h,s,n.xs,n.vs);let m=n.n;if(t.keep(r,n.xs,m),t.deltas[r]=null,c[d+5]=e.fills,c[d+6]=u.seeks,l<=0)return;m===f.axes&&n.scalar(h)===f.scalar?e.foldRun(f,o,n.xs):e.foldInto(f,o,n.value(h,n.xs));return}t.deltas[r]=p,c[d+5]=e.fills,c[d+6]=u.seeks,l>0&&e.foldInto(f,o,p[f.name])}function o8(e,t){let n=e.motionAt(t);e.kept(t,n.xs);let r=e.data[t*8+4],o={[e.chans[0].name]:n.value(r,n.xs)};return e.deltas[t]=o,o}function yc(e,t,n,r,o){t.fix(n);let i=n*8;o.probed===e.now&&o.seeks===t.data[i+6]||!(e.per[r*6+3]>e.frameProbes)||t.data[i+5]!==e.per[r*6+5]||(o.delta=t.deltas[n]??o8(t,n),o.probed=e.now,o.seeks=t.data[i+6])}var nL=new Float64Array(0);function KP(e){return(e&2043)===1211}var rm=class{chans;axes;list=[];data=new Float64Array(0);hot=new Float64Array(0);stride;samples=new Float64Array(0);deltas=[];records=[];voices=[];motions=[];eases=[];laws=[];idle=!1;line=sm.other;cursor=0;dead=0;stale=!1;staleRows=[];xs;vs;delta={};keys=new Oa;scratch=[];bareFill=-1;bareNow=Number.NaN;constructor(t,n){this.chans=t,this.axes=n,this.stride=11+3*n,this.xs=new Float64Array(n),this.vs=new Float64Array(n)}voiceAt(t){return this.voices[t]}fix(t){im(this,t)}numbered(){}restale(t,n){this.hot[t*this.stride+0]=(n|4)&-2049,this.stale=!0,this.staleRows.push(t)}odd=null;keep(t,n,r){if(r===this.axes){for(let o=0;o<r;o++)this.samples[t*r+o]=n[o];this.odd?.delete(t);return}this.odd??=new Map,this.odd.set(t,n.slice(0,r))}kept(t,n){let r=this.odd?.get(t);if(r!==void 0){n.set(r);return}let o=this.axes;for(let i=0;i<o;i++)n[i]=this.samples[t*o+i]}motionAt(t){return this.motions[t]}get size(){return this.list.length}reserve(t){if(t*8<=this.data.length)return;let n=Math.max(t,this.data.length/8*2,16),r=new Float64Array(n*8);r.set(this.data),this.data=r;let o=new Float64Array(n*this.stride);o.set(this.hot),this.hot=o;let i=new Float64Array(n*this.axes);i.set(this.samples),this.samples=i}};function jP(e,t){if(!e.overlap){for(let n of e.crowds)!n.idle&&n.cursor<n.size&&tL(e,n,t);return}for(;;){let n,r=t,o=t;for(let i of e.crowds){if(i.idle||i.cursor>=i.size)continue;let s=i.hot[i.cursor*i.stride+7];s<r?(o=r,r=s,n=i):s<o&&(o=s)}if(n===void 0)return;tL(e,n,o)}}function tL(e,t,n){let r=t.list,o=t.hot,i=t.cursor;for(;i=iL(e,t,i,n),!(i>=r.length||o[i*t.stride+7]>=n);)i=i8(e,t,i,n);t.cursor=i}function i8(e,t,n,r){let o=t.data,i=t.hot,s=t.stride,a=e.per,l=e.arg,u=t.list,c=t.chans[0],d=t.axes,f=e.fills,p=e.frameProbes,h=e.probes!==p,m=e.now,g=t.xs,b=t.vs,x=t.samples,w=n;for(;w<u.length;w++){let y=w*s;if(i[y+7]>=r)break;let P=i[y+0];if(w>n&&KP(P))break;if(o[w*8+5]===-2&&im(t,w),(P&64)!==0&&(P=s8(t,w)),(P&1)===0||(P&16)===0)continue;let S=u[w],v=w*8,A=S*6;if(Ft(o,v,a,A,f),e.lately>=0&&e.unread(S))continue;let N=o[v+0],M=(P&2)!==0,C=t.voices[w],B=(M?om(i,y,m):C.elapsedAt(m))-N;if((P&256)!==0&&(B=B>=0?B>C.span?C.hidesPast?Number.NaN:C.freezesAfter?C.span:B:B:C.freezesBefore?0:Number.NaN),!(B>=0)){o[v+2]=0;continue}let D;if(M)D=i[y+4];else if(typeof C.spec.weight=="function"){let W=e.host.envelope(C,o[v+1]);if(l[1]=B,l[3]=Zn(B,C.duration,C.passes),l[5]=W,!e.signalled(C,S,t.records[w])){o[v+2]=0;continue}D=l[0]}else D=jt(C.weight,e.host.envelope(C,o[v+1]),e.parting(C,S));if(o[v+2]=D,(P&512)!==0){D>0&&t.keys.fold(i[y+9],Dr(B,i[y+11],i[y+10]),t.chans,S,D);continue}if(l[1]=B,l[4]=N,l[0]=D,(P&128)===0){e.row(t,w,C,S);continue}if(o[v+7]===0){if(Number.isNaN(t.records[w].probed)){e.late.push(S);continue}o[v+7]=1}let j=o[v+4];if(j<0||(P&8)===0||h&&(a[A+3]>p||a[A+4]>p)){let W=t.motions[w];mc(e,t,W,w,S,t.records[w]),j<0&&t.restale(w,i[y+0]);continue}$2(t.laws[w],t.eases[w],d,i[y+9],i[y+10],i,y+11,i,y+11+d,i,y+11+2*d,B,g,b);for(let W=0;W<d;W++)x[w*d+W]=g[W];t.deltas[w]!==null&&(t.deltas[w]=null),o[v+5]=f,o[v+6]=i[y+5],!(D<=0)&&((P&32)!==0?e.foldRun(c,S,g):e.foldInto(c,S,t.motions[w].value(j,g)))}return w}function rL(e,t,n,r){let o=this.arg,i=o[1],s=n.duration;if(o[2]=Dr(i,s,n.passes),n.built!==null){o[0]>0&&this.foldKeys(n,e.chans,r);return}let a=e.records[t];if(Number.isNaN(a.probed)){this.late.push(r);return}o[3]=Zn(i,s,n.passes),this.call(n,e.chans,a,r)}function s8(e,t){let n=e.voices[t],r=t*e.stride,o=e.hot[r+0]&-324;return(n.state==="live"||n.state==="frozen"||n.state==="fading")&&(o|=1),(n.freezesBefore||n.freezesAfter||n.motion===void 0&&(n.owner!==null||n.hidesPast))&&(o|=256),n.ramp===null&&n.owner===null&&!((n.fade.in??0)>0)&&n.out===null&&n.back===null&&n.parts===null&&!n.keeping&&typeof n.spec.weight!="function"&&(o|=2),e.hot[r+1]=n.anchorNow,e.hot[r+2]=n.anchorElapsed,e.hot[r+3]=n.rate,e.hot[r+4]=Br(n.weight),e.hot[r+5]=n.seeks,e.hot[r+0]=o,o}function oL(e){e.stale=!1;let t=e.hot,n=e.stride,r=e.staleRows;e.staleRows=[];for(let o=0;o<r.length;o++){let i=r[o];if(i>=e.list.length)continue;let s=t[i*n+0];if((s&4)===0||(s&128)===0)continue;let a=e.data[i*8+4];a>=0&&a8(e,i,a)}}function a8(e,t,n){im(e,t);let r=e.motions[t],o=t*e.stride,i=e.hot[o+0]&-45,s=e.chans[0];return r.n===e.axes&&r.stretchInto(n,e.hot,o+9)&&(i|=8,r.scalar(n)===s.scalar&&s.plain&&(i|=32)),e.hot[o+0]=i,i}function om(e,t,n){return e[t+2]+(n-e[t+1])*e[t+3]}function iL(e,t,n,r){let o=t.data,i=t.hot,s=t.stride,a=e.per,l=t.list,u=t.chans[0],c=t.axes,d=e.fills,f=e.frameProbes,p=e.probes!==f,h=e.lately,m=e.now,g=u.op,b=r!==Number.POSITIVE_INFINITY;for(;n<l.length;n++){let x=n*s,w=i[x+0];if(b&&i[x+7]>=r||!KP(w))break;let y=n*8,P=(w&2048)!==0;if(!P&&(o[y+4]<0||o[y+7]===0))break;let S=l[n],v=S*6;if(p&&(a[v+3]>f||a[v+4]>f)||h>=0&&!(a[v+3]>h||a[v+4]>h))break;let A=P&&m>=i[x+8],N=0;if(!A&&(N=om(i,x,m)-o[y+0],!(N>=0)))break;Ft(o,y,a,v,d);let M=i[x+4];if(o[y+2]=M,P||(o[y+5]!==-2&&(o[y+5]=-2,t.deltas[n]=null),i[x+0]=w|2048,i[x+8]=Number.POSITIVE_INFINITY),M<=0)continue;let C=u.values,F=S*c,B=x+11,D=B+2*c;if(A){for(let J=0;J<c;J++)C[F+J]=Oe(g,C[F+J],i[D+J],M);continue}let j=Hr(N,i[x+9],i[x+10]),W=Eo(t.eases[n],j);j>=1&&i[x+3]>0&&(i[x+8]=m);for(let J=0;J<c;J++)C[F+J]=Oe(g,C[F+J],Mo(i[B+J],i[D+J],W),M)}return n}function im(e,t){let n=t*8,r=e.data;if(r[n+5]!==-2)return;let o=e.hot,i=t*e.stride;o[i+0]=o[i+0]&-2049;let s=e.axes,a=om(o,i,e.bareNow)-r[n+0],l=Eo(e.eases[t],Hr(a,o[i+9],o[i+10])),u=i+11,c=u+2*s;for(let d=0;d<s;d++)e.samples[t*s+d]=Mo(o[u+d],o[c+d],l);r[n+5]=e.bareFill,r[n+6]=o[i+5]}function Fa(e,t){let n=t*8,r=e.data;if(r[n+5]!==-2)return;let o=e.motion,i=o.runs,s=o.n,a=o.base(r[n+4]),l=e.bareElapsed-r[n+0],u=Eo(o.ease,Hr(l,i[a],i[a+2])),c=a+3,d=c+2*s;for(let f=0;f<s;f++)e.samples[t*s+f]=Mo(i[c+f],i[d+f],u);r[n+5]=e.bareFill,r[n+6]=e.bareSeeks}function Ft(e,t,n,r,o){let i=e[t+2];(i!==e[t+3]||i===0)&&n[r+5]===o-1&&(e[t+3]=i)}var sm={keys:{stop:.15,start:.25},other:{stop:.6,start:.8}},gc=class{voice;list=[];at=new Int32Array(0);idle=!1;line;epoch=0;made=0;data=new Float64Array(0);records=[];deltas=[];samples=new Float64Array(0);axes=0;delta={};scratch=[];chans=[];values=[];nums=new Float64Array(0);kinds=new Uint8Array(0);placed=!1;placedAt=0;phase=0;pass=0;read=!1;readAt=0;weighed=!1;weighedSince=0;fade=1;flat=!1;ran=-1;elapsedNow=0;motion;byMotion=new Int32Array(0);bareFill=-1;bareElapsed=Number.NaN;bareSeeks=Number.NaN;group=null;mark=Number.NaN;every=!1;voiceAt(){return this.voice}fix(t){Fa(this,t)}numbered(t,n){if(n>=this.byMotion.length){let r=new Int32Array(Math.max(n+1,this.byMotion.length*2,64));r.set(this.byMotion),this.byMotion=r}this.byMotion[n]=t+1}positionOfMotion(t){return t<this.byMotion.length?this.byMotion[t]-1:-1}keep(t,n,r){if(this.axes!==r&&(this.axes=r,this.samples=new Float64Array(0)),(t+1)*r>this.samples.length){let o=new Float64Array(Math.max(t+1,this.samples.length/r*2,4)*r);o.set(this.samples),this.samples=o}for(let o=0;o<r;o++)this.samples[t*r+o]=n[o]}kept(t,n){let r=this.axes;for(let o=0;o<r;o++)n[o]=this.samples[t*r+o]}motionAt(){return this.motion}constructor(t){this.voice=t,this.motion=Ln(t.patch),this.line=t.built!==null?sm.keys:sm.other}positionOf(t){return t<this.at.length?this.at[t]-1:-1}reserve(t,n){if(t*8>this.data.length){let r=new Float64Array(t*8);r.set(this.data),this.data=r}if(n>this.at.length){let r=new Int32Array(n);r.set(this.at),this.at=r}}add(t,n){let r=this.list.length;if(this.list.push(t),t>=this.at.length){let i=new Int32Array(Math.max(t+1,this.at.length*2,64));i.set(this.at),this.at=i}if(this.at[t]=r+1,(r+1)*8>this.data.length){let i=new Float64Array(Math.max(r+1,this.data.length/8*2,4)*8);i.set(this.data),this.data=i}let o=r*8;this.data[o+0]=n.delay,this.data[o+1]=n.shown,this.data[o+2]=0,this.data[o+3]=0,this.data[o+4]=-1,this.data[o+5]=-1,this.data[o+7]=0,this.records[r]=n,this.deltas[r]=null}renumber(t,n){let r=this.positionOf(t);if(!(r<0)){if(n>=this.at.length){let o=new Int32Array(Math.max(n+1,this.at.length*2,64));o.set(this.at),this.at=o}this.list[r]=n,this.at[n]=r+1,this.at[t]=0}}remove(t){let n=this.positionOf(t);if(n<0)return;let r=this.list.length-1,o=this.data[n*8+4];if(o>=0&&(this.byMotion[o]=0),n!==r){let i=this.data[r*8+4];i>=0&&(this.byMotion[i]=n+1);let s=this.list[r];this.list[n]=s,this.at[s]=n+1,this.data.copyWithin(n*8,r*8,(r+1)*8),this.records[n]=this.records[r],this.deltas[n]=this.deltas[r]??null;let a=this.axes;a>0&&this.samples.copyWithin(n*a,r*a,(r+1)*a)}this.list.pop(),this.at[t]=0,this.records[r]=void 0,this.deltas[r]=null}};var um=8,am=4,$P=class{mix;voice;area;finder;hitAt=new Float64Array(0);marks=0;markedIn=Number.NaN;missed=new Int32Array(am);vets;frame=Number.NaN;x=0;y=0;r=0;r2=0;lit=[];spare=[];inAt=new Float64Array(0);litAt=new Float64Array(0);checks;frames=0;checkedAt=-1;constructor(t,n,r){this.mix=t,this.voice=n,this.area=r,this.finder=l8(r)?r:null,this.checks=!tc(),this.vets=this.checks&&this.finder!==null}},l8=e=>typeof e.find=="function";function sL(e,t){let n=t.within;if(n!==void 0){if(typeof n!="object"||n===null)throw new TypeError("blits: within takes a circle, { x, y, r }, or a finder, { find(out) }");if(e.places===null)throw new Error("blits: within needs indices: call mix.place or mix.plot first");if(typeof t.weight!="function")throw new Error("blits: within needs a signal weight; for a hard-edged disk use weight: mix.around(circle, { steps: 1, jump: 'start' })")}}function cm(e,t){let n=t.spec,r=HF(n.weight),o=n.within??(r!==void 0&&e.places!==null?r:void 0);o!==void 0&&(t.bound=new $P(e,t,o),o===r&&(t.bound.checks=!1))}function aL(e,t){if(e.frame!==t.frame&&(e.frame=t.frame,e.checks&&e.frames++,e.finder===null)){let n=e.area;if(e.x=n.x,e.y=n.y,e.r=n.r,e.r2=n.r*n.r,e.checks&&e.frames%um===0){let r=t.places;lL(e,r.found,r.ring(e.x,e.y,e.r))}}}function YP(e){let t=e.mix.places;aL(e,e.mix);let n=e.finder;if(n===null)return t.query(e.x,e.y,e.r,e.r2);t.found.length<t.n&&(t.found=new Int32Array(Math.max(t.n,t.found.length*2)));let r=t.found,o=n.find(r);if(!(Number.isInteger(o)&&o>=0&&o<=r.length))throw new RangeError(`blits: within's find returned ${o}, not a count of the indices it wrote, 0 to ${r.length}`);return t.count=o,e.vets&&u8(e,r,o,t.n),e.checks&&e.frames%um===0&&e.checkedAt!==e.frames&&(e.checkedAt=e.frames,lL(e,e.missed,c8(e,t,o))),o}function u8(e,t,n,r){for(let o=0;o<n;o++){let i=t[o];if(i>=0&&i<r)continue;e.vets=!1;let s=e.voice;er(s,`${s.spec.name??`voice ${s.id}`}'s within finder found index ${i}, which place never handed out: it is skipped`);return}}function lL(e,t,n){if(n===0)return;let r=e.mix.places,o=e.voice,i=o.spec.weight,s=e.mix.now,a={timestamp:s,dt:0,elapsed:o.elapsedAt(s),pass:o.setting.pass,weight:0,state:void 0,host:o.setting.host,keep:(f,p)=>p(),send:()=>{}},l=Math.max(1,Math.floor(n/am)),u=e.frames/um%l,c=t.slice(0,n),d=o.named;for(let f=u;f<n;f+=l){let p=r.subjectAt(c[f]);if(p===void 0||d!==null&&!d.has(p))continue;let h=i(p,a);if(h>0){e.checks=!1,er(o,e.finder===null?`${o.spec.name??`voice ${o.id}`}'s weight signal reads ${h} just outside its within circle (r ${e.r}), which cuts it off there: widen r to where the signal falls to 0`:`${o.spec.name??`voice ${o.id}`}'s weight signal reads ${h} for a subject its within finder did not find, which cuts it off there: find every subject the signal is above 0 for`);return}}}function c8(e,t,n){let r=uL(e,t,n),o=t.n,i=e.hitAt,s=o===0?0:e.frames/um*am%o,a=0;for(let l=0;l<o&&a<am;l++){let u=(s+l)%o;i[u]!==r&&t.subjectAt(u)!==void 0&&(e.missed[a++]=u)}return a}function uL(e,t,n){e.markedIn=e.mix.frame,e.hitAt.length<t.n&&(e.hitAt=new Float64Array(Math.max(t.n,e.hitAt.length*2)));let r=++e.marks,o=t.found,i=e.hitAt;for(let s=0;s<n;s++){let a=o[s];a>=0&&a<i.length&&(i[a]=r)}return r}function d8(e){if(e.markedIn===e.mix.frame)return e.marks;let t=YP(e);return e.markedIn===e.mix.frame?e.marks:uL(e,e.mix.places,t)}function cL(e,t,n){let r=e.places;if(r===null)return!1;if(t.finder!==null){let o=r.at.get(n);if(o===void 0)return!1;let i=d8(t);return t.hitAt[o]===i}if(e.projecting){let o=t.area;return r.inside(n,o.x,o.y,o.r*o.r)}return aL(t,e),r.inside(n,t.x,t.y,t.r2)}function lm(e,t,n){t>=e.litAt.length&&qP(e,t+1),e.litAt[t]!==n&&(e.litAt[t]=n,e.lit.push(t))}function qP(e,t){if(t<=e.inAt.length)return;let n=Math.max(t,e.inAt.length*2,64),r=new Float64Array(n);r.set(e.inAt),e.inAt=r;let o=new Float64Array(n);o.set(e.litAt),e.litAt=o}function dL(e,t,n){let r=n.mix.places,o=YP(n),i=e.fills;qP(n,e.cap);let s=n.lit;n.lit=n.spare,n.lit.length=0,n.spare=s;let a=t.voice,l=n.inAt,u=r.found,c=r.slots;for(let p=0;p<o;p++){let h=c[u[p]]??-1;if(h<0||l[h]===i)continue;l[h]=i;let m=t.positionOf(h);if(!(m<0)){lm(n,h,i),r.cur=u[p];try{e.one(t,m,h)}finally{r.cur=-1}if(a.keeping)return}}let d=t.data,f=e.per;for(let p=0;p<s.length;p++){let h=s[p];if(l[h]===i||l[h]===-i)continue;l[h]=-i;let m=t.positionOf(h);if(m<0)continue;let g=m*8;Ft(d,g,f,h*6,i),d[g+2]!==0&&(d[g+2]=0,kt(t.records[m])),d[g+3]!==0&&lm(n,h,i)}}function XP(e,t){let n=t.mix.places,r=YP(t),o=e.fills;qP(t,e.cap);let i=t.inAt,s=n.found,a=n.slots;for(let l=0;l<r;l++){let u=a[s[l]]??-1;u>=0&&(i[u]=o)}}var JP=(e,t,n)=>e.inAt[t]===n;function QP(e,t,n,r){let o=t.data,i=n*8;Ft(o,i,e.per,r*6,e.fills),o[i+2]!==0&&(o[i+2]=0,kt(t.records[n]))}function Uo(e){e.detours=e.roleVoices+e.sharers.length+(e.unshared?1:0)}function ZP(e,t,n){t.spec.role!==void 0&&(e.roleVoices+=n);let r=t.spec.earliest;(t.spec.anchor!==void 0||r!==void 0&&typeof r!="number")&&(e.anchored+=n)}function fL(e,t){t.holding!==null&&(e.owners??=[],e.owners.push(t)),yP(e,t),ZP(e,t,1),Uo(e)}function pL(e,t){t.named!==null&&fO(e,t),t.holding!==null&&e.owners!==null&&(e.owners=e.owners.filter(n=>n!==t)),ZP(e,t,-1),Uo(e)}function Wo(e){e.named=new me,e.naming=0,e.general=[],e.sharers=[],e.roleVoices=0,e.anchored=0;for(let t of e.cued)yP(e,t),ZP(e,t,1);Uo(e),e.steps.push(null,++e.version)}function yL(e,t){let n=eT(e,t),r=n.patch;if(tT(e,n),n.from==="current"&&r.form!=="keys")throw new Error("blits: from: 'current' needs a keys patch");if(n.subjects!==void 0&&n.target!==void 0)throw new Error("blits: a voice takes target or subjects, not both");let o=n.anchor,i=n.owner===void 0?null:g8(e,n.owner);o&&xF(e,n,o,i),n.hits!==void 0&&iF(n.hits,r.duration),n.marks!==void 0&&lF(n.marks,r.duration),sL(e,n);let s=o!==void 0&&(o.start!==void 0||o.in!==void 0),a=i===null?e.now:Te(i,e.now),l=s||i?.fitting?Number.POSITIVE_INFINITY:i!==null?n.start??(a>0?a:0):n.start!==void 0?Ki(e,n.start-e.offset):Number.isNaN(e.now)?0:e.asleep?Number.POSITIVE_INFINITY:e.now,u=new La(e.nextId++,n,r,n.fade??f8,a,l,e.slotOf,e.channels,e.opts.host,e.send,i);u.offset=e.offset,r===Wi&&e.fitting!==null&&(u.fitting=e.fitting),r===Wi&&e.arcing!==null&&(u.arc=e.arcing,u.hold=e.arcing.hold),i?.fitting&&xL(n,u),e.pace!==null&&i===null&&n.start!==void 0&&u.state==="pending"&&(u.pinned=n.start-e.offset),l===Number.POSITIVE_INFINITY&&!s&&!i?.fitting&&Number.isNaN(u.pinned)&&(u.waking=!0,e.waking=!0),cm(e,u),bL(e,u);let c=dc(e,u);return u.handle=c,jr(e)&&p8(e,c),c}var f8=Object.freeze({});function p8(e,t){Ot(e,"cue",n=>{let r=Kr.voiceOf(t)??y8(t),o=n.mix(e);o===e?hL(e,r):o!==void 0&&hL(o,m8(o,r))})}function h8(e,t){for(let n of e.writes){if(!(n in t))throw new Error(`blits: kit has no channel ${String(n)}, which this patch writes`);let r=e.kit?.[n],o=t[n],i=o.rest;if(o.fold&&!o.copy&&typeof i=="object"&&i!==null&&!hO(i))throw new Error(`blits: channel ${String(n)} folds into a copy of its rest, which the mix cannot copy; give the channel a copy`);if(r&&r!==o&&(r.kind===void 0||r.kind!==o.kind))throw new Error(`blits: channel ${String(n)} is ${o.kind??"a custom channel"} in this kit, but the patch was written for ${r.kind??"a custom channel"}`)}}function eT(e,t){let n=t;if(n.locus!==void 0){if(n.role!==void 0&&n.role!==n.locus)throw new Error(`blits: a voice plays one role, not both role ${n.role} and locus ${n.locus}; locus is role's old name`);er(e,"locus is renamed role; cue the voice with role");let{locus:s,...a}=n;n={...a,role:s}}let r=e.roleTags,o=n.tags;if(r===void 0||o===void 0)return n;let i=n.role;for(let s of o)if(!(!r.includes(s)||s===i)){if(i!==void 0)throw new Error(`blits: a voice plays one role, not both ${i} and ${s}`);i=s}return i===n.role?n:{...n,role:i}}function gL(e){let{roles:t,loci:n}=e;if(n===void 0)return t;if(t!==void 0&&(t.length!==n.length||t.some((r,o)=>r!==n[o])))throw new Error("blits: a mix takes roles or loci, not both; loci is roles' old name");return er(e,"the mix option loci is renamed roles; make the mix with roles"),n}function tT(e,t){let n=t.patch,r=t.loop;if(typeof r=="number"&&!(Number.isInteger(r)&&r>=1))throw new RangeError(`blits: loop takes true, false or a whole number of passes, not ${r}`);if(t.rate!==void 0&&GP(t.rate),t.seek!==void 0&&!Number.isFinite(t.seek))throw new RangeError(`blits: a voice's seek is a finite number of ms, not ${t.seek}`);if(t.stepMs!==void 0&&!(t.stepMs>=0&&t.stepMs<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a voice's stepMs is a finite number of ms, 0 or more, not ${t.stepMs}`);if(t.catchUp!==void 0&&t.catchUp!=="exact"&&t.catchUp!=="fresh")throw new RangeError(`blits: catchUp takes 'exact' or 'fresh', not ${String(t.catchUp)}`);typeof t.weight=="number"&&UP(t.weight),h8(n,e.kit);let o=Ln(n);if(o!==void 0){let i=n.writes[0],s=e.kit[i],a=s.rest;typeof a=="number"?o.cuedOn(String(i),!0):Array.isArray(a)||ArrayBuffer.isView(a)?o.cuedOn(String(i),!1,dP(s)):dP(s)&&o.cuedOn(String(i),!1,!0)}if(n.reads){let i=e.opts.host;for(let s of n.reads)if(typeof i!="object"||i===null||!(s in i))throw new Error(`blits: the patch reads host.${s}, which this mix's host lacks`)}if(e.transport.pager!==null&&(n.state!==void 0||n.step!==void 0)&&(n.pack===void 0||n.unpack===void 0))throw new Error("blits: this mix's history has a store, which keeps a stateful patch's state as data; give the patch pack and unpack");if(t.as!==void 0&&e.transport.pager!==null&&!e.opts.history?.revive)throw new Error("blits: a voice cued with as needs history.revive to rebuild it from")}function hL(e,t){let n=t.owner;!n?.fitting&&(n===null?e.now:Te(n,e.now))>=t.start&&(t.state="live"),bL(e,t)}var mL=new WeakMap;function m8(e,t){let n=t.copy(()=>{});if(t.owner!==null){let r=Go(e,t.owner.id);(r===void 0||r.holding===null)&&Ea("a cue under an owner that has left"),n.owner=r}if(n.holding!==null&&(n.holding=new _o),n.blend!==null){let r=mL.get(e);r===void 0&&(r=new Map,mL.set(e,r));let o=n.blend.of,i=r.get(o);i===void 0&&(i=fc(n.blend.of.by,n.blend.of.stops),r.set(o,i)),n.blend={of:i,i:n.blend.i},i.members.push(n)}return n}function y8(e){throw new Error(`blits: voice ${e.id} is paged out, and the seek that plays its cue again did not load it`)}function bL(e,t){let n=t.spec,r=t.owner,o=n.anchor,i=o!==void 0&&(o.start!==void 0||o.in!==void 0),s=t.motion;t.parked=!1,r!==null&&HO(r,t),Number.isNaN(e.now)||(t.cuedAt=e.now,t.cuedSeq=e.transport.seq,t.opened=e.now,t.state!=="pending"&&(t.begunSeq=e.transport.seq)),t.placing=i,!Number.isNaN(t.pinned)&&t.state==="pending"&&Ho(e,t,t.pinned),s!==void 0&&!e.projecting&&(e.playing.set(s,(e.playing.get(s)??0)+1),e.owner??=AF(new WeakRef(e)),s.owner=e.owner,s.ownerId=t.id);let a=e.cued,l=a.length;for(;l>0&&a[l-1].id>t.id;)l--;a.splice(l,0,t),IO(e,t),t.sharing=e.share?.shares(e,t)===!0,fL(e,t),Ur(e,t),e.stir(),n.from==="current"&&(e.wantsPose=!0),o&&(zr(e),!Number.isNaN(e.now)&&t.state==="pending"&&lc(e,t)>=t.start&&va(e,t,e.now)),r?.fitting&&Dn(e,r),e.opts.history&&(t.log=[],t.note(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),t.first??=t.log[0]),it(e,t)}function g8(e,t){let n=e.owners?.find(r=>r.handle===t);if(n===void 0)throw new Error("blits: owner is not a handle mix.owns returned on this mix");if(n.state==="done")throw new Error("blits: that owner has left the mix");return n}var dm=class{out=new Map;gone=new FinalizationRegistry(t=>{this.out.get(t)?.handle.deref()===void 0&&this.out.delete(t)});add(t,n,r){this.out.set(t,{doneAt:n,handle:new WeakRef(r)}),this.gone.register(r,t)}take(t){let n=this.out.get(t);return this.out.delete(t),n?.handle.deref()}missing(t,n){for(let[r,o]of this.out)if(o.doneAt>t&&!n(r))return r}};function b8(e){return e.spec.as!==void 0&&e.owner===null&&e.holding===null&&e.blend===null&&e.answers===null&&e.fitting===null}function wL(e,t,n){if(!b8(t))return!1;let r=e.keys,o=x8(t,r);nr(e,"voice",t.id,void 0,[{at:t.doneAt,seq:t.doneSeq}],()=>o,n);let i=t.handle;return Kr.page(i,{weight:t.weight,played:t.settled.played===!0}),e.outs.add(t.id,t.doneAt,i),e.parters.delete(t),!0}function x8(e,t){let n=s=>t.subject(s),r=[],o=[];for(let s of e.keyed??[]){let a=n(s),l=e.subjects.get(a);l?.reaches&&r.push([s,Gi(e,l)]);let u=e.motion?.pack(a);u!==void 0&&o.push([s,u])}let i=e.settled;return{as:e.spec.as,start:e.start,anchorNow:e.anchorNow,anchorElapsed:e.anchorElapsed,rate:e.rate,ramp:e.ramp,weight:e.weight,out:e.out,back:e.back,stalls:e.stalls,outAt:e.outAt,outOver:e.outOver,outSet:e.outSet,rebuilds:e.rebuilds,hold:e.hold,past:e.clocks?.length??0,earlier:e.earlier,later:e.later,clocks:e.clocks,cuedAt:e.cuedAt,cuedSeq:e.cuedSeq,begunSeq:e.begunSeq,doneAt:e.doneAt,doneSeq:e.doneSeq,opened:e.opened,pinned:e.pinned,offset:e.offset,latest:e.latest,soonest:e.soonest,keeping:e.keeping,first:e.first,log:e.log,played:i.played,playedAt:i.at,playedSeq:i.seq,records:r,runs:o,left:(e.left?.all()??[]).map(s=>[t.key(s.subject),s.at,s.seq,Gi(e,s.held),s.sync,s.ramp,s.parted]),parts:[...e.parts??[]].map(([s,a])=>[t.key(s),a.at,a.over,a.seq]),parted:[...e.parted??[]].map(([s,a])=>a.ramp===void 0?[t.key(s),a.at,a.seq]:[t.key(s),a.at,a.seq,a.ramp])}}function PL(e,t,n){let r=e.opts.history?.revive;if(r===void 0)throw new Error("blits: a paged voice needs history.revive");let o=eT(e,{...r(n.as),as:n.as});tT(e,o);let i=new La(t,o,o.patch,o.fade??{},Number.NEGATIVE_INFINITY,n.start,e.slotOf,e.channels,e.opts.host,e.send,null);i.clocks=n.clocks,i.take(n),i.cuedAt=n.cuedAt,i.cuedSeq=n.cuedSeq,i.begunSeq=n.begunSeq??Number.POSITIVE_INFINITY,i.doneAt=n.doneAt,i.doneSeq=n.doneSeq,i.opened=n.opened,i.pinned=n.pinned,i.offset=n.offset??0,i.latest=n.latest,i.soonest=n.soonest??0,i.keeping=n.keeping,i.first=n.first,i.log=n.log,i.state="done",n.played!==void 0&&i.play(n.played,n.playedAt,n.playedSeq),i.resolve();let s=e.keys,a=u=>s.subject(u);i.keyed=new Set;for(let[u,c]of n.records)i.subjects.set(a(u),Ui(i,c)),i.keyed.add(u);for(let[u,c]of n.runs)i.motion?.unpack(a(u),c);i.left=Fn.from(n.left.map(([u,c,d,f,p,h=null,m=null])=>({subject:a(u),at:c,seq:d,sync:p,held:Ui(i,f),ramp:h,parted:m}))),n.parts.length>0&&(i.parts=new Map(n.parts.map(([u,c,d,f])=>[a(u),{at:c,over:d,seq:f}]))),n.parted.length>0&&(i.parted=new Map(n.parted.map(([u,c,d,f])=>[a(u),{at:c,seq:d,ramp:f??void 0}])));let l=e.outs?.take(t);return l===void 0?i.handle=dc(e,i):(Kr.rehome(l,i),i.handle=l),i}var w8=0;function st(){return++w8}function AL(e){return e.stirred||e.anchored>0||e.pins!==null&&e.pins.size>0}function Yr(e,t){e.moving=!0;try{P8(e,t)}finally{e.moving=!1}}function P8(e,t){e.now=t,e.looked=!1,e.unshared&&(e.unshared=!1,Uo(e)),e.frame=st(),e.reducedNow=e.reduced;for(let i of e.announced)Number.isNaN(i.at)&&(i.at=e.u);if(e.waking&&A8(e,t),e.pins!==null&&e.pins.size>0&&bF(e),e.anchored>0&&zr(e),e.announced.length>0){let i=e.opts.history===void 0?t:e.transport.keepsFrom();e.announced=e.announced.filter(s=>Ki(e,s.at)>=i)}let n=e.projecting||e.walkAll?e.cued:pO(e,t),r=null;for(let i of n)i.state!=="done"&&bc(e,i,t,i.owner!==null&&i.owner.fitting!==null)&&(r??=[],r.push(i));let o=e.leapt===null&&r===null?null:T8(e,r,t);e.leapt=null,o===null?RL(e,r,t):S8(e,o,r,t),e.sharers.length>0&&!e.projecting&&e.share?.outgrow(e),e.stirred=!1,e.asleep=!1,e.retired.length>0&&M8(e),O8(e)}function RL(e,t,n){t!==null&&k8(e,t,n),e.owners!==null&&(EL(e,n),ML(e,n))}function T8(e,t,n){let r=null;if(e.leapt!==null)for(let o of e.leapt)r=TL(o,n,r);if(t!==null)for(let o of t)r=TL(o.owner,n,r);return r}function TL(e,t,n){for(let r=e;r!==null;r=r.owner)r.state==="done"||r.owner?.fitting||n?.includes(r)||r.rateAt(r.owner===null?t:Te(r.owner,t))>0||(n??=[],n.push(r));return n}function S8(e,t,n,r){let o=t.map(i=>{let{anchorNow:s,anchorElapsed:a,rate:l,ramp:u,start:c}=i,d=i.owner===null?r:Te(i.owner,r);return i.anchorElapsed=ze(i,d),i.anchorNow=d,i.rate=1,i.ramp=null,i.start=d-i.anchorElapsed,{anchorNow:s,anchorElapsed:a,rate:l,ramp:u,start:c,logged:i.log?.length??0}});try{if(e.anchored>0){zr(e);for(let i of t)Vi(i,s=>{s.state==="pending"&&s.spec.anchor!==void 0&&s.owner?.fitting===null&&bc(e,s,r)})}RL(e,n,r)}finally{t.forEach((i,s)=>{let{logged:a,...l}=o[s];Object.assign(i,l);let u=i.log;if(u!==null)for(let c=a;c<u.length;c++)Object.assign(u[c],l)})}e.frame=st();for(let i of t)i.state!=="done"&&it(e,i),Vi(i,s=>{s.state!=="done"&&(dn(e,s,r),it(e,s))});e.lanes?.refill()}function bc(e,t,n,r=!1){Number.isNaN(t.opened)&&(t.opened=n),(t.earlier!==null||t.later!==null)&&oT(e,t,n);let o=t.owner===null?n:Te(t.owner,n);if(r&&IL(t,o,n))return!0;if(t.state==="pending"&&NL(t,o,n)&&va(e,t,n),(t.state==="live"||t.state==="frozen")&&t.outAt<=n&&!(t.state==="live"&&!t.freezesAfter&&!t.freezesBefore&&t.endsAt()<t.outAt)&&qr(e,t,{over:Number.isNaN(t.outOver)?void 0:t.outOver},Math.max(Lo(t),t.outAt)),t.state!=="pending"){t.turns&&R8(e,t,n),t.state==="live"&&t.out!==null&&!t.quietAt(n)&&lT(e,t,n);let s=Math.sign(t.rateAt(o))*(t.owner===null?1:rT(t.owner,n)),a=o===Number.NEGATIVE_INFINITY?o:ze(t,o),l=s<0,u=!t.beginless&&a<=t.soonest,c=t.holding!==null&&Wr(t,n);(l?u&&!c:Number.isFinite(t.span)&&a>=t.span+t.latest)?(t.play(!0,n,e.transport.seq),t.state==="live"&&t.out===null&&((l?t.freezesBefore:t.freezesAfter)?t.state="frozen":qr(e,t,{back:l,stays:t.owner!==null&&e.opts.history!==void 0},Math.max(_n(t),Math.min(n,t.endsAt()))))):t.state==="frozen"&&!(u&&s===0)&&(t.state="live")}if(t.parts!==null&&!e.projecting)for(let[s,a]of t.parts)n-a.at>=a.over&&sT(e,t,s,a.at+a.over);let i=t.back;if(i!==null&&n>=i.at+(1-i.from)*i.over&&!e.projecting&&(t.back=null,e.lanes?.refill()),t.state==="fading"&&t.out){let{at:s,over:a,rest:l,deadline:u}=t.out,c=n-s;if(l){let d=u!==void 0&&c>=u,f=t.seen>0&&t.restedCount>=t.seen;d?Bn(e,t,s+u):f&&Bn(e,t)}else c>=a&&(t.out.stays?aT(e,t,s+a):Bn(e,t,s+a))}return e.projecting||it(e,t),!1}function NL(e,t,n){return t>e.start||t===e.start&&(e.owner===null||rT(e.owner,n)>=0)}function nT(e,t,n){return(t.earlier!==null||t.later!==null)&&oT(e,t,n),IL(t,Te(t.owner,n),n)}function IL(e,t,n){if(e.state==="pending")return NL(e,t,n);if(e.state!=="live")return!1;let r=e.out;if(e.fitting!==null)return r===null&&iT(e,n);if(!Number.isFinite(e.span)||r!==null&&!(r.stays===!0&&r.back===!0))return!1;let o=t===Number.NEGATIVE_INFINITY?t:ze(e,t),i=r===null?e.span+e.latest:e.soonest;return o>i||o===i&&rT(e,n)>0}function k8(e,t,n){let r=t.length===1?t[0]:null;if(r!==null&&r.state==="pending"&&r.holding===null&&(va(e,r,n),!nT(e,r,n))){bc(e,r,n);return}let o=t,i=[];for(;;){let s,a=Number.POSITIVE_INFINITY;for(let l=0;l<o.length;l++){let u=o[l];if(u.state==="done"||i.includes(u)||!nT(e,u,n))continue;let c=u.state==="pending"?_n(u):u.fitting!==null?v8(u):u.out!==null?u.reaches(u.soonest):u.endsAt();(s===void 0||c<a||c===a&&kL(u)<kL(s))&&(s=u,a=c)}if(s===void 0)break;if(s.state==="pending")va(e,s,n),s.holding!==null&&SL(e,s,n,o,i);else if(s.out!==null)lT(e,s,n);else{i.push(s),s.fitting!==null?xc(e,s,a):bc(e,s,n);for(let l=s.owner;l?.fitting;l=l.owner)SL(e,l,n,o,i)}}Bi(o);for(let s=0;s<o.length;s++){let a=o[s];!i.includes(a)&&a.state!=="done"&&bc(e,a,n)}}function v8(e){return e.timeAt(e.fitting.budget)}function SL(e,t,n,r,o){let i=t.holding.children;for(let s=0;s<i.length;s++){let a=i[s];a.state!=="done"&&!o.includes(a)&&!r.includes(a)&&nT(e,a,n)&&r.push(a)}}function kL(e){return(e.state==="pending"||e.out!==null?2**40:0)+e.id}function A8(e,t){e.waking=!1;for(let n of e.cued){if(!n.waking||(n.waking=!1,n.state!=="pending"))continue;Ia(e,n,t);let r=n.first;r!==null&&(r.start=t,r.anchorNow=t),e.projecting||it(e,n)}}function rT(e,t){let n=1;for(let r=e;r!==null;r=r.owner)n*=Math.sign(r.rateAt(r.owner===null?t:Te(r.owner,t)));return n}function R8(e,t,n){let r=t.ramp,o=t.anchorNow+r.over*r.from/(r.from-r.to);(t.owner===null?n:Te(t.owner,n))<o||(Fo(t,o),t.anchorElapsed=ze(t,o),t.ramp={from:0,to:r.to,over:t.anchorNow+r.over-o},t.anchorNow=o,Ke(e,t))}var N8=8,I8=32,E8=4;function M8(e){let t=e.retired;e.retired=[];let n=e.cued,r=null;if((t.length<=N8||t.length*I8<=n.length)&&!e.projecting){Bi(t),r=[];for(let i=0;i<t.length;i++){let s=t[i],a=s===t[i-1]?-1:C8(n,s);if(a<0){r=null;break}r.push(a)}}let o=!1;if(r!==null){for(let i of t)o=vL(e,i)||o;if(r.length<=E8)for(let i=r.length-1;i>=0;i--)n.splice(r[i],1);else{let i=r[0],s=0;for(let a=i;a<n.length;a++)r[s]===a?s++:n[i++]=n[a];n.length=i}}else{let i=0;for(let s=0;s<n.length;s++){let a=n[s];a.state!=="done"?n[i++]=a:o=vL(e,a)||o}n.length=i}o&&(e.general=e.general.filter(i=>i.state!=="done"),e.sharers.length>0&&(e.sharers=e.sharers.filter(i=>i.state!=="done")),Uo(e))}function C8(e,t){let n=0,r=e.length-1;for(;n<=r;){let o=n+r>>>1,i=e[o].id;if(i===t.id)return e[o]===t?o:-1;i<t.id?n=o+1:r=o-1}return-1}function vL(e,t){return EO(e,[t]),e.opts.history?(e.gone.push(t),_h(e,t)):(e.parters.delete(t),e.departed.add(e,t)),vF(e,t),Ur(e,t),pL(e,t),t.named===null}function O8(e){let t=e.opts.history;if(t&&e.gone.length>0)if(e.transport.pager!==null){let n=e.now-t.ms;_P(e,r=>r.reachedTo>=n||!wL(e,r,n))}else rF(e,e.transport.keepsFrom())}var fm=class{budget;claim;fit;spill;end;report;constructor(t){let n=t.duration??Number.POSITIVE_INFINITY;if(!(n>=0))throw new Error("blits: a span lasts 0 ms or more");let r=t.share??.5;if(!(r>=0&&r<=1))throw new Error("blits: a span staggers by a share in 0..1");this.budget=n,this.claim={budget:n,priority:t.priority??"strong",order:t.order??"queue",share:r},this.fit=t.fit??iO,this.spill=t.spill??"instant",this.end=Number.isFinite(n)?n:0,this.report={budget:n,length:0,over:0,skipped:0,fell:!1}}};function xL(e,t){if(e.start!==void 0||e.anchor?.start!==void 0||e.anchor?.in!==void 0)throw new Error("blits: a span places the voices it holds, so one takes no start of its own");if(t.arc!==null){if(!Number.isFinite(Tc(t)))throw new Error("blits: a span cannot fit an arc held open, which never ends")}else if(t.holding!==null){if(t.fitting===null)throw new Error("blits: a span holds voices, spans and arcs, not owners")}else if(!Number.isFinite(t.span))throw new Error("blits: a span cannot fit a voice that never ends")}function F8(e,t){for(let n of e.holding.children)if(n.out?.stays===!0&&(n.out.back===!0||n.start>t))return!0;return!1}function oT(e,t,n){let r=Te(t.owner,n),o=!1;for(let i=t.earlier;i!==null&&r<t.anchorNow;i=t.earlier)t.later={...uT(t),prev:t.later},CL(t,i),t.earlier=i.prev,o=!0;for(let i=t.later;i!==null&&r>=i.anchorNow;i=t.later)t.earlier={...uT(t),prev:t.earlier},CL(t,i),t.later=i.prev,o=!0;o&&(e.frame=st(),dn(e,t,n),Ke(e,t),e.lanes?.refill())}function uT(e){let{anchorNow:t,anchorElapsed:n,rate:r,ramp:o,skipped:i}=e;return{anchorNow:t,anchorElapsed:n,rate:r,ramp:o,skipped:i}}function CL(e,t){e.anchorNow=t.anchorNow,e.anchorElapsed=t.anchorElapsed,e.rate=t.rate,e.ramp=t.ramp,e.skipped!==t.skipped&&e.seeks++,e.skipped=t.skipped}function L8(e,t){if(Number.isNaN(t))return 0;let n=OL(e,t);return Number.isFinite(n)?Math.max(0,n):0}function OL(e,t){let n=e.owner===null?t:OL(e.owner,t);return n===Number.NEGATIVE_INFINITY||e.state==="pending"&&!(n>=e.start)?Number.NEGATIVE_INFINITY:ze(e,n)}function wc(e,t){return e.state!=="pending"||e.start<t}function _8(e,t,n){return wc(e,n)?Math.max(0,ze(e,t)):0}function FL(e,t,n){let r=e.fitting!==null?e.fitting.end:e.arc!==null?Tc(e):e.span;return Math.max(0,r-_8(e,t,n))}function Dn(e,t,n=e.now){let r=t.fitting;if(e.projecting||t.state==="done")return;let o=L8(t,n);if(F8(t,o))return;let i=n<e.now?o:Number.NEGATIVE_INFINITY,{kids:s,floors:a,waiting:l}=D8(e,t,o,i),u=s.map((P,S)=>{let v=P.spec;return{floor:a[S],natural:FL(P,o,i)/(v.rate??1),state:wc(P,i)?"playing":"pending",faster:Math.max(1,v.faster??1),slower:Math.max(1,v.slower??1),overlap:v.overlap===!0,ballast:v.ballast===!0&&P.holding===null,priority:v.priority??"weak"}}),c={...r.claim,left:r.budget-o},{plan:d,fell:f}=sO(c,u,r.fit,r.spill),{at:p,length:h}=mP(c,u,d);s.forEach((P,S)=>{let v=(P.spec.rate??1)*d.rate[S],A=d.skip[S]&&P.holding===null,N=P.skipped;P.skipped=A;let M=!1;if(wc(P,i))(A||P.rate!==v||P.ramp!==null)&&(P.earlier={...uT(P),skipped:N,prev:P.earlier},P.later=null),A&&(Fo(P,o),P.rebase(o),P.anchorElapsed=P.span,P.seeks++,M=!0),(P.rate!==v||P.ramp!==null)&&(Fo(P,o),ga(P,o,v,0),M=!0);else{let C=o+p[S],F=A?P.span:0;(P.start!==C||P.rate!==v||P.anchorElapsed!==F||P.ramp!==null)&&(P.start=C,P.anchorNow=C,P.anchorElapsed=F,P.rate=v,P.ramp=null,P.clocks=null,P.earlier=null,P.later=null,M=!0)}M&&(e.frame=st(),dn(e,P,e.now),Ke(e,P))});for(let P of l)P.start!==Number.POSITIVE_INFINITY&&(P.start=Number.POSITIVE_INFINITY,P.anchorNow=Number.POSITIVE_INFINITY,P.anchorElapsed=0,P.clocks=null,P.earlier=null,P.later=null,e.frame=st(),dn(e,P,e.now),Ke(e,P));s.length>0&&e.lanes?.refill();let m=o+h,g=Number.isFinite(r.budget)?Math.max(0,m-r.budget):0,b=g<1e-6,x=Number.isFinite(r.budget)&&b?r.budget:m,w=r.report,y={budget:r.budget,length:m,over:b?0:g,skipped:d.skip.filter((P,S)=>P&&s[S]?.holding===null).length,fell:f};r.report=y,x!==r.end?(r.end=x,Ke(e,t),t.owner?.fitting&&Dn(e,t.owner,n)):(y.length!==w.length||y.over!==w.over||y.skipped!==w.skipped||y.fell!==w.fell)&&Ke(e,t)}function D8(e,t,n,r){let o=(t.holding?.children??[]).filter(c=>c.state!=="done"&&c.state!=="frozen"&&c.out===null&&FL(c,n,r)>0),i=o.filter(c=>wc(c,r)),s=i.map(()=>{}),a=[],l=o.filter(c=>!wc(c,r)).sort((c,d)=>(c.spec.rank??0)-(d.spec.rank??0)),u=t.fitting.claim.order!=="together";for(let c of l){let d=c.spec.earliest,f=d===void 0?void 0:Na(e,d,c,Number.NEGATIVE_INFINITY);if(c.floorSeen=f??Number.NaN,d!==void 0&&f===void 0||u&&a.length>0){a.push(c);continue}i.push(c);let p=f===void 0||f===Number.NEGATIVE_INFINITY?void 0:f-n;s.push(p===void 0||c.cuedSeq===e.transport.seq?p:Math.max(0,p))}return{kids:i,floors:s,waiting:a}}function wF(e){if(!e.projecting)for(let t of e.owners??[]){if(t.fitting===null||t.state==="done")continue;(t.holding?.children??[]).some(r=>{let o=r.spec.earliest;if(r.state!=="pending"||o===void 0||typeof o=="number")return!1;let i=Na(e,o,r,Number.NEGATIVE_INFINITY)??Number.NaN;return!Object.is(i,r.floorSeen)})&&Dn(e,t)}}function Pc(e,t){let n=e.fitting;return n!==null&&Number.isFinite(n.budget)&&Te(e,t)<n.budget}function EL(e,t){let n=e.owners??[];for(let r=n.length-1;r>=0;r--){let o=n[r];o.out?.stays!==!0&&iT(o,t)&&xc(e,o,o.timeAt(o.fitting.budget))}}function iT(e,t){let n=e.fitting;return n===null||e.state==="done"||!Number.isFinite(n.budget)?!1:!Wr(e,t)&&Te(e,t)>=n.budget}var fn=Object.freeze([]),B8=()=>{},LL=new WeakMap;function H8(e,t,n){if(e.length!==1)return _L(e,t,n);let r=LL.get(t);r===void 0&&(r=new Map,LL.set(t,r));let o=e[0],i=r.get(o);return i===void 0&&(i=_L(e,t,n),r.set(o,i)),i}function _L(e,t,n){let r=e.map(o=>t.get(o));return{slots:r,lerps:r.map(o=>n[o].lerp)}}var La=class e{id;spec;patch;fade;start;owner;state="pending";rate;weight;anchorNow;anchorElapsed=0;ramp=null;out=null;back=null;stalls=null;subjects=new me;named;slots;built;lerps;intos;scratch=[];holder=null;laned=!1;seat=null;seeks=0;written=!1;touches=0;get jumps(){return this.seeks-this.touches}rebuilds=0;skipped=!1;floorSeen=Number.NaN;keeping=!1;parts=null;parted=null;left=null;ease;passes;duration;span;motion;beginless;freezesBefore;freezesAfter;opened=Number.NaN;unchecked=!0;dueToken=0;early=null;clocks=null;earlier=null;later=null;setting;seen=0;latest=0;soonest=0;restedCount=0;parked=!1;cuedAt=Number.NEGATIVE_INFINITY;cuedSeq=Number.NEGATIVE_INFINITY;begunSeq=Number.POSITIVE_INFINITY;doneAt=Number.POSITIVE_INFINITY;doneSeq=Number.POSITIVE_INFINITY;decidedAt=Number.NEGATIVE_INFINITY;get reachedTo(){return this.doneAt>this.decidedAt?this.doneAt:this.decidedAt}log=null;first=null;outAt=Number.POSITIVE_INFINITY;outOver=Number.NaN;outSet=!1;pinned=Number.NaN;offset=0;waking=!1;placing=!1;answers=null;folds=null;keepOn=null;ownKept=null;blend=null;spares=null;unreached=null;unreachedBits=null;sharing=!1;bound=null;shared=0;everyone=null;sighted=null;weights=null;stamps=null;deltas=null;handle=null;keyed=null;holding;fitting=null;arc=null;hold=0;part=-1;finished=!1;playedAs=void 0;playedAt=Number.NaN;playedSeq=Number.NaN;donePromise=null;doneSettle=null;playedPromise=null;playedSettle=null;quiet=!1;get done(){return this.donePromise===null&&(this.donePromise=this.finished?Promise.resolve():new Promise(t=>{this.doneSettle=t})),this.donePromise}get played(){if(this.playedPromise===null){let t=this.playedAs;this.playedPromise=t!==void 0?Promise.resolve(t):new Promise(n=>{this.playedSettle=n})}return this.playedPromise}resolve(){this.quiet||this.finished||(this.finished=!0,this.doneSettle?.())}play(t,n,r){this.quiet||this.playedAs!==void 0||(this.playedAs=t,this.playedAt=n,this.playedSeq=r,this.playedSettle?.(t),t&&this.owner!==null&&UO(this.owner,n,r))}get settled(){return{played:this.playedAs,at:this.playedAt,seq:this.playedSeq}}get passed(){return this.playedAs===!0}get unplayed(){return this.playedAs===!1}reopen(t){let n=!1;return this.playedAs!==void 0&&!(this.playedSeq<=t)&&(n=this.playedAs,this.playedAs=void 0,this.playedPromise=null,this.playedSettle=null),this.finished&&!(this.doneSeq<=t)&&(this.finished=!1,this.donePromise=null,this.doneSettle=null),n}take(t){this.anchorNow=t.anchorNow,this.anchorElapsed=t.anchorElapsed,this.rate=t.rate,this.ramp=t.ramp,this.weight=t.weight,this.out=t.out,this.back=t.back,this.stalls=t.stalls??null,this.start=t.start,this.outAt=t.outAt,this.outOver=t.outOver,this.outSet=t.outSet,this.rebuilds=t.rebuilds,this.hold=t.hold,this.earlier=t.earlier??null,this.later=t.later??null;let n=t.fitted;n&&this.fitting!==null&&(this.fitting.end=n.end,this.fitting.report=n.report);let r=this.clocks;r!==null&&r.length!==t.past&&(this.clocks=t.past===0?null:r.slice(0,t.past))}park(){this.reopen(Number.NEGATIVE_INFINITY),this.take(this.first),this.parked=!0,this.log=null,this.state="pending",this.subjects=new me,this.scratch=[],this.holder=null,this.laned=!1,this.seeks++,this.keeping=!1,this.parts=null,this.parted=null,this.opened=Number.NaN,this.dueToken++,this.early=null,this.seen=0,this.latest=this.named?.latest??0,this.soonest=this.named?.soonest??0,this.restedCount=0,this.cuedAt=Number.NEGATIVE_INFINITY,this.cuedSeq=Number.NEGATIVE_INFINITY,this.begunSeq=Number.POSITIVE_INFINITY,this.doneAt=Number.POSITIVE_INFINITY,this.doneSeq=Number.POSITIVE_INFINITY,this.placing=!1,this.answers=null,this.folds=null,this.keepOn=null,this.ownKept=null,this.unreached=null,this.unreachedBits=null,this.sharing=!1,this.everyone=null,this.sighted=null,this.weights=null,this.stamps=null,this.deltas=null,this.holding!==null&&(this.holding=new _o)}constructor(t,n,r,o,i,s,a,l,u,c,d){this.id=t,this.spec=n,this.patch=r,this.fade=o,this.start=s,this.owner=d,this.holding=r===Wi?new _o:null;let f=H8(r.writes,a,l);this.slots=f.slots,this.named=n.subjects?new Hh(n.subjects,n.stagger):null,this.latest=this.named?.latest??0,this.soonest=this.named?.soonest??0,this.built=r.form==="keys"&&r.keys?qO(r):null,this.lerps=f.lerps,this.intos=this.built?YO(this.built,this.slots.map(g=>l[g])):void 0,this.ease=o.ease===void 0?void 0:Co(o.ease),this.passes=H2(n.loop),this.duration=r.duration,this.span=this.duration>0&&Number.isFinite(this.passes)?this.duration*this.passes:Number.POSITIVE_INFINITY,this.motion=Ln(r);let p=this.motion===void 0?n.freeze:void 0,h=p===void 0&&this.motion===void 0&&d!==null;this.freezesBefore=h?d.freezesBefore:p==="before"||p==="both",this.freezesAfter=h?d.freezesAfter:p==="after"||p==="both",this.setting=new Kh(u,c,this),this.rate=n.rate??1,this.weight=typeof n.weight=="number"?n.weight:1;let m=!Number.isFinite(this.span);this.beginless=this.rate<0&&m&&this.motion===void 0,this.anchorNow=s,this.anchorElapsed=n.seek??(this.rate<0&&!m?this.span:0),i>=s&&(this.state="live")}elapsedAt(t){return this.owner===null?ze(this,t):BO(this,this.owner,t)}timeAt(t){let n=Cn(this,t);return this.owner===null?n:Do(this.owner,n)}get backs(){let t=this.ramp;return t===null?this.rate<0:t.from<=0&&t.to<=0&&(t.from<0||t.to<0)}get turns(){let t=this.ramp;return t!==null&&t.from*t.to<0}endsAt(){if(this.turns)return Number.POSITIVE_INFINITY;let t=this.backs,n;if(t!==(this.owner!==null&&Uh(this))){if(this.beginless)return Number.POSITIVE_INFINITY;n=this.soonest}else{if(!Number.isFinite(this.span))return Number.POSITIVE_INFINITY;n=this.span+this.latest}return this.reaches(n)}reaches(t){let n=this.backs?ec(this,t):Cn(this,t);return this.owner===null?n:Do(this.owner,n)}stateAt(t,n){let r=this.out;return r!==null?r.stays&&t>=r.at+r.over?"live":"fading":(this.owner===null?t:Te(this.owner,t))<this.start&&!(n!==void 0&&$t(n,this.begunSeq,!0))?"pending":this.freezesAfter&&this.elapsedAt(t)>=this.span+this.latest?"frozen":"live"}quietAt(t){let n=this.out;if(this.state!=="live"||n?.stays!==!0)return!1;if(this.holding!==null&&n.back!==!0)return!Wr(this,t)&&!Pc(this,t);if(this.skipped&&Te(this.owner,t)<this.start)return!0;let r=this.elapsedAt(t),o=this.span+this.latest,i=this.backs!==(this.owner!==null&&Uh(this));return r>o||r===o&&!i?!0:!this.beginless&&(r<this.soonest||r===this.soonest&&i)}ranBackTo(t,n){if(this.beginless||!this.backs||this.owner!==null)return Number.NaN;let r=ec(this,t);return r>=this.anchorNow&&r<=n?r:Number.NaN}unstarted(t){let n=this.state;return n==="pending"?!0:n!=="fading"?!1:!((this.owner===null?t:Te(this.owner,t))>=this.start)}rawAt(t,n){return(this.unstarted(t)?this.anchorElapsed:this.elapsedAt(t))-n}before(t,n){return!(t>=0)&&!this.beginless||this.unstarted(n)}get holdsFirst(){return this.freezesBefore||this.out?.back===!0}get hidesPast(){return!this.freezesAfter&&this.backs!==(this.owner!==null&&Uh(this))}shownAt(t){return this.beginless?t:t>this.span&&this.hidesPast?Number.NaN:kh(t,this.holdsFirst,this.freezesAfter,this.span)}note(t,n,r=!1){this.log?.push({at:t,seq:n,sync:r,anchorNow:this.anchorNow,anchorElapsed:this.anchorElapsed,rate:this.rate,ramp:this.ramp,weight:this.weight,out:this.out,back:this.back,stalls:this.stalls,start:this.start,outAt:this.outAt,outOver:this.outOver,outSet:this.outSet,rebuilds:this.rebuilds,hold:this.hold,past:this.clocks?.length??0,earlier:this.earlier,later:this.later,fitted:this.fitting===null?null:{end:this.fitting.end,report:this.fitting.report}})}copy(t,n,r=!1){let o={__proto__:e.prototype,...this},i=o;i.subjects=new Mh(t),i.setting={...this.setting,keep:CP(o),send:B8},o.keepOn=null,o.ownKept=null,o.scratch=[],o.holder=null,o.laned=!1,o.seat=null,o.log=null,o.early=null,n&&o.take(n),o.clocks===this.clocks&&o.clocks!==null&&(o.clocks=o.clocks.slice()),o.quiet=!0,o.unreached=null,o.unreachedBits=null;let s=r&&this.sharing?this.everyone:null;return o.sharing=s!==null,o.everyone=s===null?null:{...s,delta:null,probed:Number.NaN,from:s.stepped},o.sighted=null,o.weights=null,o.stamps=null,o.deltas=null,o}rateAt(t){return ya(this,t)}rebase(t){uP(this,t)}};function DL(e,t){if(e.unchecked=!1,t===null||typeof t!="object")return;let n=e.patch.writes;for(let r in t)n.includes(r)||er(e.patch,`${e.spec.name??`voice ${e.id}`}'s patch returns ${r} from at(), which is not in its writes, so the mix drops it`)}function _a(e,t,n){return e[cT(e,t,n)]}function cT(e,t,n){let r=0,o=e.length-1,i=-1;for(;r<=o;){let s=r+o>>1,a=e[s];a.at<t||a.at===t&&(typeof n=="function"?n(a):n)?(i=s,r=s+1):o=s-1}return i}function Sc(e,t){let n=0,r=e.length-1,o;for(;n<=r;){let i=n+r>>1,s=e[i];$t(t,s.seq,s.sync)?(o=s,n=i+1):r=i-1}return o}function BL(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let o of n)if(!BL(e[o],t[o]))return!1;return!0}function dT(e,t,n){let r=t.log,o=r===null?void 0:_a(r,n,!0);return ze(o??t,t.owner===null?n:G8(e,t.owner,n))}function G8(e,t,n){return dT(e,t,n)}function Ke(e,t){Ta(e,t,!0),e.stir(),it(e,t);let n=t.log;if(n===null)return;t.note(Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,e.transport.seq,e.moving||!e.looked);let r=e.now-e.opts.history.ms,o=0;for(;o+1<n.length&&n[o+1].at<=r;)o++;o>0&&nr(e,"controls",t.id,void 0,n.splice(0,o),U8,r)}var U8=e=>({...e}),W8=Object.freeze([]);function HL(e,t){let n=GL(e,t);return n===0?W8:e.splice(0,n)}function GL(e,t){let n=0;for(;n+1<e.length&&e[n+1].at<=t;)n++;return n}function Da(e,t){let n=e.patch;return n.clone?n.clone(t):bt(t)}function Vo(e,t,n=!1){let r=UL(t);return Ba({reaches:t.reaches,delay:t.delay,since:t.since,shown:t.shown,weight:t.weight,restedAt:t.restedAt,bands:t.bands===null?null:t.bands.slice(),state:t.state===void 0||n?t.state:Da(e,t.state),stepped:t.stepped,ticks:t.ticks,probed:t.probed,delta:t.delta,phase:t.phase,seeks:t.seeks,rebuilt:t.rebuilt,copied:t.copied,base:t.base===void 0?void 0:bt(t.base),slope:t.slope===void 0?void 0:bt(t.slope),kept:r,unkept:t.unkept?.map(bt),snaps:t.snaps,from:t.from,unknown:t.unknown,inputs:t.inputs,replay:t.replay,voice:t.voice,next:t.next,version:t.version,roles:t.roles,slot:t.slot,run:t.run,freed:t.freed,restored:null})}function UL(e){if(e.kept===null)return null;let t=new Map;for(let[n,r]of e.kept)t.set(n,bt(r));return t}function fT(e,t,n,r=!1){return n.reaches=t.reaches,n.delay=t.delay,n.since=t.since,n.shown=t.shown,n.weight=t.weight,n.restedAt=t.restedAt,n.bands=t.bands===null?null:t.bands.slice(),n.state=t.state===void 0||r?t.state:Da(e,t.state),n.stepped=t.stepped,n.ticks=t.ticks,n.rebuilt=t.rebuilt,n.copied=t.copied,n.base=t.base===void 0?void 0:bt(t.base),n.slope=t.slope===void 0?void 0:bt(t.slope),n.kept=UL(t),n.unkept=t.unkept?.map(bt),n.from=t.from,n.unknown=t.unknown,n.replay=t.replay,n.voice=t.voice,n.slot=t.slot,n.run=t.run,n.freed=t.freed,n.restored=null,Ba(n)}function Ba(e){return e.probed=Number.NaN,e.delta=null,e.phase=0,e.seeks=0,e.snaps=void 0,e.inputs=void 0,e.next=null,e.version=Number.NaN,e.roles=null,e}function WL(e,t){let n=e.hostLog,r=n[n.length-1],o=e.transport.seq;if(r!==void 0&&r.seq===o)return;let i=e.opts.host,s={};for(let l of e.cued)for(let u of l.patch.reads??fn)u in s||(s[u]=bt(i[u]));if(r!==void 0&&BL(r.fields,s))return;n.push({at:t,seq:o,fields:s});let a=t-e.opts.history.ms;nr(e,"host",void 0,void 0,HL(n,a),l=>l.fields,a)}function pm(e,t,n,r,o){let i=e.opts.history;if(!i?.inputs||e.projecting)return;let s=r.inputs??[];r.inputs=s;let a=s[s.length-1];if(a!==void 0&&(a.value===o||a.at===e.now)){a.at===e.now&&(a.value=o);return}s.push({at:e.now,seq:e.transport.seq,value:o});let l=e.now-i.ms,u=HL(s,l);u.length>0&&nr(e,"input",t.id,e.keys?.key(n),u,c=>c.value,l)}function kc(e){return e.every??200}function V8(e,t,n,r){let o=t.spares?.pop()??r;return o===void 0?{at:e.now,seq:e.transport.seq,held:Vo(t,n)}:(o.at=e.now,o.seq=e.transport.seq,fT(t,n,o.held),o)}function em(e,t,n,r){let o=e.opts.history;if(!o||e.projecting||t.patch.step===void 0&&(r.kept===null||r.kept.size===0)&&r.base===void 0)return;let i=r.snaps??[];r.snaps=i;let s=i[i.length-1];if(s!==void 0&&e.now-s.at<kc(o))return;let a=e.now-o.ms,l=GL(i,a),u;l>0&&(e.transport.pager!==null&&nr(e,"snap",t.id,e.keys?.key(n),i.slice(0,l),c=>Gi(t,c.held),a),u=z8(i,l),l===1?i.shift():i.splice(0,l)),i.push(V8(e,t,r,u))}function z8(e,t){for(let n=0;n<t;n++){let r=e[n];if(!r.shared)return r.ahead=void 0,r}}function hm(e,t,n,r){let o=e.opts.history;if(o===void 0||r===void 0)return;let i=e.now-o.ms,s=t.left??new Fn;t.left=s;let a=e.keys;s.expire(i,a===null?null:l=>nr(e,"left",t.id,a.key(l.subject),[l],u=>[Gi(t,u.held),u.sync,u.ramp,u.parted],i)),s.push({subject:n,at:Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,seq:e.transport.seq,sync:e.syncing||!e.looked,held:r,ramp:t.parts?.get(n)??null,parted:t.parted?.get(n)??null})}function mm(e){let t=e.opts.history;return t===void 0||Number.isNaN(e.now)?[]:[e.now,e.now-t.ms,e.transport.seq,e.syncing||!e.looked]}function MF(e,t,n,r){if(t.state==="done"||t.parted?.has(n)||t.parts?.has(n))return;e.share?.unshare(e,t),e.stir();let o=e.reduced?0:r??t.fade.out??0,i=Number.isNaN(e.now)?_n(t):e.now;if(o===0){sT(e,t,n,i);return}t.parts??=new Map,t.parts.set(n,{at:i,over:o,seq:e.transport.seq}),e.parters.add(t),it(e,t),e.lanes?.refill()}function VL(e,t,n){let r=e.parts?.get(t);if(r===void 0)return 1;let o=this.reducedNow,i=ma(0,{at:r.at,over:r.over,rest:!1},e.ease,o,n,0),s=e.fade.in??0,a=e.subjects.get(t)?.shown;if(!(s>0)||o||a===void 0||!(r.at<n))return i;let l=e.out,u=Sh(s,l,e.ease,n,a,e.stalls);return u>0?i*(Sh(s,l,e.ease,n,a,e.stalls,r.at)/u):i}function sT(e,t,n,r){let o=t.parts?.get(n);t.parts?.delete(n),t.parts?.size===0&&(t.parts=null),t.parted??=new Map,t.parted.set(n,{at:r,seq:e.transport.seq,ramp:o}),e.parters.add(t),zL(e,t,n);let i=t.motion;i!==void 0&&KL(e,i,t)&&i.release(n,...mm(e))}function VP(e,t,n){if(t.parted?.has(n)!==!0)return;t.subjects.get(n)===void 0&&pT(e,t,n),zL(e,t,n),t.parted.delete(n),t.parted.size===0&&(t.parted=null);let r=ut(e,n)?.slot??-1;r>=0&&e.lanes?.rejoin(r)}function pT(e,t,n){let r=t.subjects.get(n);r!==void 0||t.parted?.has(n)!==!0?hm(e,t,n,r):hm(e,t,n,t.unreached??e.unreachedOf(t,e.now))}function ym(e,t,n){for(let r of t){let o=r.parted;if(o!==null&&o.seq<=n){e.parted??=new Map,e.parted.set(r.subject,o);continue}let i=r.ramp??o?.ramp;i==null||i.seq>n||(e.parts??=new Map,e.parts.set(r.subject,i))}}function zL(e,t,n){let r=ut(e,n);r!==void 0&&r.slot>=0&&(Vr(t,r.slot,!1),e.share?.unsight(t,r.slot));let o=t.subjects.get(n);o!==void 0&&(hm(e,t,n,o),t.subjects.delete(n),o.reaches&&t.seen--,Oo(o)&&t.restedCount--,t.holder===o&&(t.holder=null)),r!==void 0&&(rc(e,r),t.laned&&r.slot>=0&&e.lanes?.part(t.id,r.slot),e.lanes?.refill())}function qr(e,t,n,r){if(t.state==="done"||t.state==="fading")return;let o=e.reduced?0:n.over??t.fade.out??0,i=t.state==="pending";i&&Ur(e,t),n.at==="rest"&&(e.share?.unshare(e,t),t.seeks++),t.state="fading",t.out={from:1,at:r??(Number.isNaN(e.now)?_n(t):e.now),over:o,rest:n.at==="rest",deadline:n.deadline},n.back&&(t.out.back=!0),n.stays&&(t.out.stays=!0),Ke(e,t),n.at==="rest"||n.back||i?e.lanes?.invalidate():e.lanes?.refill(),o===0&&n.at!=="rest"&&(n.stays?aT(e,t,t.out.at):Bn(e,t,t.out.at))}function aT(e,t,n){t.state="live",e.lanes?.refill();let r=t.owner;if(r.state==="done")return;let o=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now;Wr(r,o)||Pc(r,n)?r.fitting!==null&&!t.skipped&&Dn(e,r,n):xc(e,r,n)}function xc(e,t,n){t.owner!==null&&t.state==="live"&&e.opts.history!==void 0?qr(e,t,{over:0,stays:!0},n):Bn(e,t,n)}function CF(e,t,n){let r=t.out;if(t.state!=="fading"&&t.outSet){t.outAt=Number.POSITIVE_INFINITY,t.outOver=Number.NaN,t.outSet=!1,Ke(e,t);return}if(t.state!=="fading"||r===null)return;let o=Number.isNaN(e.now)?_n(t):e.now,i=e.reduced?0:n.over??t.fade.in??t.fade.out??0,s=r.rest||r.over===0?1:1-(o-r.at)/r.over,a=s<0?0:s>1?1:s,l=Number.isNaN(e.now)||(t.owner===null?o:Te(t.owner,o))<t.start;t.out=null,t.outAt=Number.POSITIVE_INFINITY,t.state=l?"pending":"live",l&&(t.begunSeq=Number.POSITIVE_INFINITY),t.back=i>0&&a<1?{from:a,at:o,over:i}:null,!r.rest&&r.at<o&&(t.stalls=[...t.stalls??[],r.at,o]),l&&Ur(e,t),Ke(e,t),l?e.lanes?.invalidate():e.lanes?.refill()}function OF(e,t,n,r){if(t.state==="done"||t.state==="fading")return;let o=Number.isNaN(e.now)?_n(t):e.now;if(n<=o){qr(e,t,{over:r},Math.max(Lo(t),n)),e.stir();return}t.outAt=n,t.outOver=r??Number.NaN,t.outSet=!0,Ke(e,t)}function lT(e,t,n){let r=t.out,o=r.back===!0?t.soonest:t.span+t.latest,i=t.reaches(o),s=Math.max(r.at+r.over,i<=n?i:n),a=e.reduced?0:r.over;t.out=null,t.back=a>0?{from:0,at:s,over:a}:null,Ke(e,t),e.lanes?.refill()}function KL(e,t,n){return t.owner===e.owner&&t.ownerId===n.id}function K8(e,t){t.owner.holding.left(t.passed?Xe(e,t,"coast"):void 0,t.doneSeq)}function Bn(e,t,n){t.holding===null&&e.lanes?.touch(t);let r=t.motion;r!==void 0&&KL(e,r,t)&&(r.owner=null),t.state="done",Ta(e,t),t.keepOn=null,e.retired.push(t);let o=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now;if(t.doneAt=n??o,t.decidedAt=o,t.doneSeq=e.transport.seq,e.transport.settle(),t.play(!1,t.doneAt,t.doneSeq),t.resolve(),t.holding!==null)for(let i of[...t.holding.children])i.state!=="done"&&Bn(e,i,t.doneAt);if(t.owner!==null){let i=t.owner;K8(e,t);let s=GO(t,o);s!==null&&!Pc(s,t.doneAt)?Bn(e,s,t.doneAt):i.fitting!==null&&i.state!=="done"&&!t.skipped&&Dn(e,i,t.doneAt)}}var j8=["enter","active","exit"],mT=class{enter;exit;blend;has;hold;constructor(t,n,r,o,i){this.enter=t,this.exit=n,this.blend=r,this.has=o,this.hold=i}};function $L(e,t){let n=[0,e.enter,e.enter+t,e.enter+t+e.exit],r=n[3],o=[null,null,null];for(let i=0;i<3;i++){if(!e.has[i])continue;let s=i+1;for(;s<3&&!e.has[s];)s++;o[i]=[n[i],s<3?n[s]:r]}return o}function Tc(e){let t=e.arc;return t.enter+e.hold+t.exit}function jL(e,t,n,r,o){if(t<=e)return 0;let i=r/2,s=e===0,a=t===n;if(!s&&o<e-i||!a&&o>=t+i)return 0;let l=s?1:r>0?Math.min(1,(o-e+i)/r):1,u=a?1:r>0?Math.min(1,(t+i-o)/r):1;return Math.min(l,u)}function KO(e,t,n,r){let o=e.arc,i=Te(e,n);if(!(i>=0))return 0;let s=$L(o,e.hold),a=o.enter+e.hold+o.exit,l=r?0:o.blend,u=s[t.part];if(u==null)return 0;let c=jL(u[0],u[1],a,l,i);if(c<=0)return 0;let d=0;for(let f of s)f!==null&&(d+=jL(f[0],f[1],a,l,i));return d>1?c/d:c}function $8(e){let t=0;for(let n of e){let r=n.loop,o=r===void 0||r===!1?1:r===!0?1/0:r,i=n.duration??(n.patch.duration>0?n.patch.duration*o:0);if(!(i>=0))throw new RangeError(`blits: an arc's part lasts 0 ms or more, not ${i}`);i>t&&(t=i)}return t}var hT=e=>e===void 0?void 0:Array.isArray(e)?e:[e];function YL(e,t){if((t.rate??1)<0)throw new Error("blits: an arc plays its parts forward from its start, so it is not cued backward");if(t.freeze!==void 0)throw new Error("blits: an arc holds each part\u2019s first and last frames itself, so it takes no freeze");let{enter:n,active:r,exit:o,hold:i,blend:s,...a}=t,l=[hT(n),hT(r),hT(o)],u=l.map(m=>m===void 0?0:$8(m));for(let m of[0,2])if(!Number.isFinite(u[m]))throw new Error(`blits: an arc's ${j8[m]} has to end, so it cannot loop for good`);let c=i==="open"?Number.POSITIVE_INFINITY:i??u[1]??0;if(!(c>=0))throw new RangeError(`blits: an arc holds for 0 ms or more, not ${i}`);let d=s??0;if(!(d>=0&&Number.isFinite(d)))throw new RangeError(`blits: an arc blends over 0 ms or more, not ${s}`);let f=new mT(u[0],u[2],d,l.map(m=>m!==void 0),c);e.arcing=f;let p;try{p=e.owns(a)}finally{e.arcing=null}let h=[0,f.enter,f.enter+c];return l.forEach((m,g)=>{for(let b of m??[]){let{duration:x,...w}=b,y={...w,owner:p,start:h[g],freeze:"both"};g===1&&i!==void 0&&b.loop===void 0&&(y.loop=!0),e.cue(y),e.cued[e.cued.length-1].part=g}}),p}function FF(e,t){let n=t.arc;if(n===null)throw new Error("blits: release ends an arc\u2019s hold, and this is no arc");if(t.state==="done"||t.state==="fading")return;let r=Te(t,e.now),o=n.exit>0&&!e.reduced?n.blend/2:0,i=Math.max(n.enter,r+o);if(i<n.enter+t.hold){t.hold=i-n.enter;for(let s of t.holding?.children??[])s.part===2&&s.state==="pending"&&Ia(e,s,i);Y8(e,t)}}function Y8(e,t){Ke(e,t),t.owner?.fitting&&Dn(e,t.owner),e.lanes?.refill()}function ML(e,t){for(let n of e.owners??[]){let r=n.arc;if(r===null||n.state==="done"||n.state==="pending")continue;let o=Te(n,t);if(!Number.isFinite(o))continue;let i=Tc(n);if(o>=i){let l=n.timeAt(i);n.play(!0,l,e.transport.seq),Bn(e,n,l);continue}let s=$L(r,n.hold),a=e.reduced?0:r.blend/2;for(let l of[...n.holding?.children??[]]){let u=s[l.part];u==null||u[1]===i||l.state==="done"||o>=u[1]+a&&Bn(e,l,n.timeAt(u[1]+a))}}}function mF(e,t,n){let r=e.arc,o=u=>{let c=e.timeAt(u);return Number.isFinite(c)?Math.max(t,c):void 0};if(n==="in"){let u=o(r.enter);return u===void 0?u:Math.max(u,t+(e.fade.in??0))}let i=o(r.enter+e.hold),s=e.out,a=s!==null?s.at:Number.isFinite(e.outAt)?e.outAt:void 0,l=a!==void 0&&(i===void 0||a<i);if(n==="coast")return l?void 0:i;if(n==="out")return l?a:e.state==="done"&&i===void 0?e.doneAt:i;if(e.state==="done")return e.doneAt;if(l){if(s!==null)return s.at+s.over;let u=Number.isNaN(e.outOver)?e.fade.out??0:e.outOver;return a+u}return o(Tc(e))}function qL(e,t){let n=[],r=[];for(let s=0;s<e.length;s++){let a=t[s].rest;a!==void 0&&(n.push(e[s]),r.push(typeof a=="number"?a:void 0))}function o(){for(let s=0;s<n.length;s++)this[n[s]]=r[s]}o.prototype=Object.prototype;let i=o;return()=>new i}function XL(e,t,n,r,o){let i,s=pe.back;if(s!==null)i=(Bh(e,n,r.elapsed,s)&1)!==0;else{let f=o.run;o.freed!==e.freed&&(f=e.slot(n),o.run=f,o.freed=e.freed),e.sample(f,r.elapsed,e.xs,e.vs),i=e.scalar(f)}let a=e.xs,l=o.delta??{};if(i)return l[t]=a[0],l;let u=e.n,c=l[t],d=Array.isArray(c)&&c.length===u?c:Qn(u,0);for(let f=0;f<u;f++)d[f]=a[f];return l[t]=d,l}var JL=wa;function QL(e,t,n,r,o){o.rebuilt=t.rebuilds;let i=t.patch;i.state===void 0&&i.step===void 0&&o.kept===null||(o.state=i.state?i.state(n):void 0,o.kept=null,o.unkept=void 0,o.since=e.sinceOf(t,o.delay),o.shown=e.shownOf(t,o.since),o.ticks=0,o.stepped=o.since<r?o.since:r,o.probed=Number.NaN)}function q8(e,t,n){let r=t.patch;return r.state===void 0&&r.step===void 0&&!t.keeping?!1:e.sinceOf(t,n.delay)!==n.since}function ZL(e,t,n){return e<0?U2(e,t):Dr(e,t,n)}var X8=Object.freeze({});function e_(e,t,n,r){if(r.weight=0,!r.reaches)return null;let o=e.bound!==null&&r.replay===void 0&&!cL(this,e.bound,t),i=o&&e.spec.weight.input===!0&&!!this.opts.history?.inputs;if(o&&!i&&e.patch.step===void 0&&e.spec.from!=="current"||e.out?.rest&&Oo(r))return null;r.rebuilt!==e.rebuilds?QL(this,e,t,n,r):r.seeks!==e.seeks&&q8(this,e,r)&&(QL(this,e,t,n,r),LP(e,r,n));let s=e.rawAt(n,r.delay),a=e.before(s,n);if(a&&!e.holdsFirst)return null;let l=e.shownAt(s);if(Number.isNaN(l))return null;let u=a?-1:e.freezesAfter&&s>e.span?1:0,c=e.duration,d=Zn(l,c,e.passes),f=this.primed;f[0]=n,f[1]=l,f[2]=d,this.prime(e,r);let p=e.setting,h=pe.kept,m=o?0:this.weigh(e,t,n,r);if(i&&pm(this,e,t,r,0),pe.kept!==h&&!e.keeping&&$i(this,e),p.weight=m,r.weight=m,r.probed===n&&r.delta&&r.seeks===e.seeks)return e.holder!==r&&e.scratch.length>0&&this.keyed(e,t,r),this.w=m,r.delta;let g=pe.kept,b=this.opts.history;if(b?.inputs&&e.patch.reads!==void 0&&!this.projecting&&WL(this,n),e.motion!==void 0&&(pe.horizon=this.horizonFor(e,r.delay,n)),e.patch.step&&r.probed!==n){let y=u===0?n:u===1?e.timeAt(r.delay+e.span):e.ranBackTo(r.delay,n),P=r.snaps,S=Number.isNaN(r.probed)&&P!==void 0;if(Number.isNaN(y))S&&yT(e,r);else{r.stepped<r.since&&(r.stepped=r.since,p.dt=this.capped(n-r.since));let v=Io(this,e);v!==void 0&&S&&J8(this,e,t,r,P,v,y),S&&yT(e,r),v!==void 0?this.tick(e,t,r,v,y):(u===0?n!==r.stepped:y>r.stepped)&&(u!==0&&(p.dt=this.capped(y-r.stepped)),e.patch.step(r.state,p.dt,t,p),r.stepped=y)}}let x=null,w=!1;if(vh(e,m)&&(e.built===null||e.spec.role===void 0))w=e.spec.role!==void 0,e.built&&e.spec.from==="current"&&r.base===void 0&&(r.base=this.baseFor(e,t),r.slope=this.slopeFor(e,t));else if(e.built)r.phase=ZL(l,c,e.passes),x=this.keyed(e,t,r);else if(e.motion!==void 0)x=XL(e.motion,e.patch.writes[0],t,p,r);else{let y=ZL(l,c,e.passes);x=e.patch.at(y,t,p),e.unchecked&&DL(e,x)}return r.delta=x,r.probed=n,r.seeks=e.seeks,b!==void 0&&em(this,e,t,r),pe.kept!==g&&!e.keeping&&$i(this,e),x===null?w?(this.w=m,X8):null:e.out?.rest&&this.isRest(x)?(r.weight=0,r.restedAt=n,e.restedCount++,null):(this.w=m,x)}function t_(e,t,n){let r;e.spec.from==="current"&&(n.base===void 0&&(n.base=this.baseFor(e,t),n.slope=this.slopeFor(e,t)),r=n.base);let o=zh(e.built,n.phase,n.delta??{},r,e.lerps,n.slope,e.intos,e.scratch);return n.delta=o,e.scratch.length>0&&(e.holder=n),o}function n_(e,t,n){return Math.floor((n-e.since)/t+1e-9)}function J8(e,t,n,r,o,i,s){let a=o[o.length-1],l=a?.ahead;if(a===void 0||l===void 0||l.put!==r)return;l.put=null;let u=t.patch.reads;if(e.opts.maxDt!==void 0||u!==void 0&&u.length>0)return;let c=a.held;if(r.ticks!==c.ticks||r.since!==l.since||r.rebuilt!==c.rebuilt)return;let d=l.sought,f=n_(r,i,s),p=l.state!==void 0&&l.ticks<=f;if(l.left!==void 0&&l.leftTicks<=f&&!(p&&l.ticks>l.leftTicks)){r.state=l.left,l.left=void 0,t.setting.state=r.state,r.ticks=l.leftTicks;return}p&&(r.state=Da(t,l.state),t.setting.state=r.state,r.ticks=l.ticks);let h=p?l.at:a.at;!(d<s)||d-h<kc(e.opts.history)||(yT(t,r),e.tick(t,n,r,i,d),l.state=Da(t,r.state),l.ticks=r.ticks,l.at=d)}function yT(e,t){let n=t.snaps,r=n[n.length-1];r!==void 0&&t.state!==void 0&&t.state===r.held.state&&(t.state=Da(e,t.state),e.setting.state=t.state)}function r_(e,t,n,r,o){let i=this.now,s=e.setting,a=s.dt,l=n.ticks,u=n_(n,r,o),c=this.opts.maxDt;if(c!==void 0){let f=Math.floor(c/r);u-l>f&&(l=u-f)}let d=e.patch.step;for(s.dt=r,l++;l<=u;l++)s.timestamp=n.since+l*r,d(n.state,r,t,s);n.ticks=u>n.ticks?u:n.ticks,n.stepped=n.since+n.ticks*r,s.timestamp=i,s.dt=a}function o_(e,t){let n=this.lastPoses.get(t)?.pose;if(n===void 0&&!this.folding.has(e.id)){this.folding.add(e.id);try{n=this.fold(t,void 0,!1,e.id)}finally{this.folding.delete(e.id)}}let r={};for(let o of e.patch.writes){let i=this.kit[o],s=n?.[o],a=i.rest;s!==void 0?r[o]=JL(s):a!==void 0&&(r[o]=JL(a))}return r}function i_(e,t){let n=this.lastPoses.get(t);if(n?.prev===void 0||!(n.at>n.prevAt))return;let r=n.at-n.prevAt,o=n.pose,i=n.prev,s={};for(let a of e.patch.writes){let l=i[a],u=o[a];typeof l=="number"&&typeof u=="number"?s[a]=(u-l)/r:Array.isArray(l)&&Array.isArray(u)&&l.length===u.length&&(s[a]=u.map((c,d)=>(c-l[d])/r))}return s}function s_(e){for(let t of Object.keys(e)){if(e[t]===void 0)continue;let n=this.kit[t];if(n.rest===void 0||!hc(e[t],n.rest))return!1}return!0}function a_(e,t,n,r,o){if(r&&o.reaches&&o.probed===n&&o.delta&&o.seeks===e.seeks){let i=e.setting,s=e.shownAt(e.rawAt(n,o.delay));return i.timestamp=n,i.dt=0,i.elapsed=s,i.pass=Zn(s,e.duration,e.passes),i.weight=0,i.state=o.state,i.mark=0,e.keepOn=o,this.w=this.weigh(e,t,n,o),o.weight=this.w,e.holder!==o&&e.scratch.length>0&&this.keyed(e,t,o),o.delta}return this.contribution(e,t,n,o)}function l_(e){this.frame=st();let t=ut(this,e);t!==void 0&&rc(this,t);let n=this.chains.get(e)?.slot??-1;n>=0&&this.lanes!==null&&this.lanes.release(n),this.projecting&&!(this.lastPoses instanceof oc)&&(this.lastPoses=new oc(this.lastPoses)),this.projecting||this.places?.drop(e),this.lastPoses.delete(e),this.restStamps?.delete(e),this.chains.delete(e),this.stir();let r=mm(this);for(let l of this.general)this.forgetIn(l,e,r);let o=this.named.get(e);if(o!==void 0)for(let l of[...o])this.forgetIn(l,e,r);let i=Bo(this);for(let l of i.general)this.forgetIn(l,e,r);let s=i.named.get(e);if(s!==void 0)for(let l of s)this.forgetIn(l,e,r);if(this.owners!==null)for(let l of this.owners)this.forgetIn(l,e,r);for(let l of this.parters)this.forgetIn(l,e,r),l.parts?.size===0&&(l.parts=null),l.parted?.size===0&&(l.parted=null),l.parts===null&&l.parted===null&&this.parters.delete(l);let a=this.strays.get(e);if(a!==void 0)for(let l of a)this.releaseIn(l,e,r);this.strays.delete(e);for(let l of this.strayAll)this.releaseIn(l,e,r);jr(this)&&this.recordDrop(e)}function u_(e,t,n){pT(this,e,t),e.subjects.delete(t),e.motion!==void 0&&this.releaseIn(e.motion,t,n),e.parts?.delete(t),e.parted?.delete(t),e.blend?.of.reads.delete(t)}function c_(e,t,n){this.projecting?e.holds(t)&&Ea("a drop of a subject a motion patch holds"):e.release(t,n[0],n[1],n[2],n[3])}function d_(e){Ot(this,"drop",t=>t.mix(this)?.drop(e))}var Q8=Symbol("unread");function gT(e,t,n,[r,o]){for(let i=t;i<t+n;i++){let s=e[i];e[i]=s<r?r:s>o?o:s}}function Z8(e,t,n){let r=n*e.axes;if(typeof t=="number"&&e.axes===1)e.out[r]=t;else if(Array.isArray(t)&&t.length===e.axes)for(let o=0;o<e.axes;o++)e.out[r+o]=t[o];else if(t===void 0)e.out.fill(Number.NaN,r,r+e.axes);else throw new TypeError(`blits: pull reads ${e.key} as ${e.axes===1?"a number":`${e.axes} numbers`} a subject, and the pose has ${String(t)}`)}function f_(e,t,n){let r;if(n===void 0||this.wantsPose){r={};for(let o of this.names){let i=t[o];i!==void 0&&(r[o]=wa(i))}}if(r!==void 0){let o=this.lastPoses.get(e);o===void 0?this.lastPoses.set(e,{pose:r,at:this.now,prev:void 0,prevAt:Number.NaN}):o.at===this.now?o.pose=r:(o.prev=o.pose,o.prevAt=o.at,o.pose=r,o.at=this.now)}}function p_(e,t,n){let r=tY(e,n),o=e.lanes,i=e.now;e.scratch===void 0&&(e.scratch=e.pose());let s=Number.POSITIVE_INFINITY,a="";for(let x of r){let w=Math.floor(x.out.length/x.axes);w<s&&(s=w,a=x.key)}let l;if(Array.isArray(t))l=t;else{let x=[];for(let w of t)if(x.push(w)>s)break;l=x}if(l.length>s)throw new RangeError(`blits: pull's array for ${a} has room for ${s} subjects, and was given more`);let u=o!==null&&!e.wantsPose,c=e.pulled,d=e.pulledHeads;if(e.pulledSlots.length<l.length){let x=new Int32Array(Math.max(64,l.length)).fill(-1);x.set(e.pulledSlots),e.pulledSlots=x}l.length<c.length&&e.pulledSlots.fill(-1,l.length,c.length);for(let x=c.length;x<l.length;x++)c.push(Q8);c.length=l.length,d.length=l.length;let f=e.version,p=e.relinks,h=!Number.isNaN(i),m=h&&e.pulledVersion===f&&e.pulledRelinks===p,g=m?Number.POSITIVE_INFINITY:h&&e.pulledVersion===f?e.pulledRelinks:-1;try{eY(e,l,r,h,m,g,u)}finally{o!==null&&o.pulls.flush(o)}let b=h&&e.version===f&&e.relinks===p;e.pulledVersion=b?f:Number.NaN,e.pulledRelinks=p}function eY(e,t,n,r,o,i,s){let a=e.lanes,l=e.now,u=e.scratch,c=e.pulled,d=e.pulledHeads,f=e.pulledSlots,p=e.version,h=r&&s;for(let m=0;m<t.length&&!(h&&(m=a.pulls.pullRun(a,f,t,c,i,m,n,l,e.version),m===t.length));m++){let g=t[m],b=-1;if(r)if(o&&c[m]===g)b=f[m];else{let S=d[m],v=c[m]===g&&S!==void 0&&S.version===p?S:e.chain(g);c[m]=g,d[m]=v,b=v.slot;let A=m===0?0:f[m-1]+1;if(h&&b>=0&&b!==A&&A>=0&&a.pulls.renumber(e,g,v,A)){for(let N=c.indexOf(g);N>=0;N=c.indexOf(g,N+1))f[N]=A;b=A}f[m]=b}let x=r&&a?.prepare(b,g,e.version,d[m]??null)===!0;if(x&&s&&a.whole&&!a.owes(b)){a.pulls.writeLater(a,b,n,m,f);continue}let w=r?d[m]:null,y=e.foldWith(g,u,w,x,!1),P=e.bounded.length===0?y:e.clamp(y);e.keep(g,P,u);for(let S of n)Z8(S,P[S.key],m)}}function tY(e,t){let n=[];e.pullColumns??=new Map;let r=e.pullColumns;for(let o of Object.keys(t)){let i=t[o];if(i===void 0)continue;let s=r.get(o);if(s!==void 0){s.out=i,n.push(s);continue}let a=e.slotOf.get(o);if(a===void 0)throw new Error(`blits: pull was handed ${o}, which the kit lacks`);let l=e.channels[a],u=l.rest,c=D2(l),d=l.bounds,f=new Float64Array(c).fill(Number.NaN);typeof u=="number"?f[0]=u:Array.isArray(u)&&f.set(u),d!==void 0&&gT(f,0,c,d);let p={key:o,slot:a,axes:c,out:i,rest:f,bounds:d};r.set(o,p),n.push(p)}return n}function h_(e){e.pulled=[],e.pulledHeads=[],e.pulledSlots=new Int32Array(0),e.pulledVersion=Number.NaN,e.pulledRelinks=-1}function y_(e,t,n,r,o,i,s,a,l){if((e.filled(a,l)?1:e.begin(a,l))!==1||!e.whole)return i;let c=e.per,d=e.fills,f=e.busyFill,p=e.wide,h=e.frameProbes,m=e.subjects,g=e.unlinked,b=e.holds,x=e.owed.any(),w=o===Number.POSITIVE_INFINITY;b_(e,s,t),x_(e,e.queued+n.length-i);let y=i,P=-1,S=i;for(;y<n.length;y++){let v=n[y];if(r[y]!==v)break;let A=t[y],N=A*6;if(A<0||!w&&!(g[A]<=o)||c[N+0]>=f||c[N+2]!==0||c[N+1]<p||x&&e.owes(A))break;c[N+3]>h||c[N+4]>h||e.distinct++,c[N+3]=++e.probes,c[N+5]=d,b&&(m[A]=v),A!==P+(y-S)&&(P>=0&&xT(e,P,S,y-S),P=A,S=y)}return P>=0&&xT(e,P,S,y-S),y>i&&b&&(e.holding=!0),y}function g_(e,t,n,r,o){b_(e,n,o),xT(e,t,r,1)}function b_(e,t,n){t===e.queuedFor&&n===e.queueFrom||(qi(e),e.queuedFor=t,e.queueFrom=n)}var m_=16;function xT(e,t,n,r){let o=e.queued;if(o>0){let i=o-1,s=e.queueCounts[i];if(n===e.queueRows[i]+s){let a=e.queueSlots[i];if(a>=0&&t===a+s){e.queueCounts[i]=s+r;return}if(r<m_&&(a<0||s<m_)){e.queueSlots[i]=-1,e.queueCounts[i]=s+r;return}}}x_(e,o+1),e.queueSlots[o]=t,e.queueRows[o]=n,e.queueCounts[o]=r,e.queued=o+1}function x_(e,t){if(t<=e.queueSlots.length)return;let n=Math.max(64,t,e.queueSlots.length*2);e.queueSlots=bT(e.queueSlots,n),e.queueRows=bT(e.queueRows,n),e.queueCounts=bT(e.queueCounts,n)}function bT(e,t){let n=new Int32Array(t);return n.set(e),n}function qi(e){let t=e.queued,n=e.queuedFor;if(!(t===0||n===null)){e.queued=0;for(let r=0;r<n.length;r++){let o=n[r],i=e.bySlot[o.slot];if(i===void 0?nY(e,o,t):oY(e,o,i.values,t),o.bounds!==void 0)for(let s=0;s<t;s++)gT(o.out,e.queueRows[s]*o.axes,e.queueCounts[s]*o.axes,o.bounds)}}}function nY(e,t,n){let r=e.queueRows,o=e.queueCounts,i=t.out,s=t.axes;if(s===1){let a=t.rest[0];for(let l=0;l<n;l++){let u=r[l],c=u+o[l];if(c-u>64)i.fill(a,u,c);else for(let d=u;d<c;d++)i[d]=a}return}for(let a=0;a<n;a++){let l=r[a]*s,u=l+o[a]*s;for(let c=l;c<u;c+=s)for(let d=0;d<s;d++)i[c+d]=t.rest[d]}}var rY=256;function oY(e,t,n,r){let o=e.queueSlots,i=e.queueRows,s=e.queueCounts,a=t.out,l=t.axes,u=e.queueFrom;for(let c=0;c<r;c++){let d=o[c];if(d<0){let m=i[c],g=m+s[c];if(l===1)for(let b=m;b<g;b++)a[b]=n[u[b]];else for(let b=m;b<g;b++){let x=b*l,w=u[b]*l;for(let y=0;y<l;y++)a[x+y]=n[w+y]}continue}let f=i[c]*l,p=d*l,h=s[c]*l;if(h>rY)a.set(n.subarray(p,p+h),f);else for(let m=0;m<h;m++)a[f+m]=n[p+m]}}function T_(e,t){this.copier===null&&(this.copier=iY(this.laned)),this.copier(t,e)}function S_(e,t,n){let r=e.start,o=e.axes,i=t*o;if(Array.isArray(n)&&n!==r&&n.length===(r.length>o?r.length:o)){for(let a=0;a<o;a++)n[a]=e.values[i+a];for(let a=o;a<r.length;a++)n[a]=r[a];return n}let s=[...r];for(let a=0;a<o;a++)s[a]=e.values[i+a];return s}var w_=new Map,P_=!1;function iY(e){let t=[];for(let o=0;o<e.length;o++){let i=e[o],s=`o[${JSON.stringify(i.name)}]`,a=i.scalar?"s":`s * ${i.axes}`,l=`if (${s} !== undefined) ${s} = undefined;`,u=i.scalar?`${s} = v;`:`{ const h = ${s}, a = f(c${o}, s, h); if (a !== h) ${s} = a; }`;t.push(`{ const v = c${o}.values[${a}];`),t.push(i.op==="last"?`if (v !== v) { ${l} } else ${u} }`:`${u} }`)}let n=t.join(`
427
+ `),r=w_.get(n);if(r===void 0&&!P_){let o=e.map((i,s)=>`const c${s} = chans[${s}];`).join(" ");try{r=new Function("chans","f",`${o}
428
428
  return function copyLaned(o, s) {
429
429
  ${n}
430
- };`),a_.set(n,r)}catch{l_=!0}}return r===void 0?(o,i)=>q8(e,o,i):r(e,c_)}function q8(e,t,n){for(let r=0;r<e.length;r++){let o=e[r],i=o.values[o.scalar?n:n*o.axes];if(o.op==="last"&&Number.isNaN(i))t[o.name]!==void 0&&(t[o.name]=void 0);else if(o.scalar)t[o.name]=i;else{let s=t[o.name],a=c_(o,n,s);a!==s&&(t[o.name]=a)}}}function X8(e,t){let n=t.spec,r=t.patch;return e.lanes!==null&&!e.projecting&&e.opts.history===void 0&&t.named===null&&n.target===void 0&&n.stagger===void 0&&n.role===void 0&&n.anchor===void 0&&n.from!=="current"&&typeof n.weight!="function"&&r.state===void 0&&r.step===void 0&&t.motion===void 0&&t.owner===null&&t.holding===null&&t.blend===null&&!t.freezesBefore&&!t.beginless&&t.slots.every(o=>{let i=e.channels[o];return i.rest!==void 0&&qn(i)?.op!=="last"})}var J8=60;function Q8(e){let t=e.sharers;for(let n=t.length-1;n>=0;n--){let r=t[n];r.built!==null||r.state==="pending"||r.state==="done"||++r.shared>=J8&&fT(e,r)}}function Z8(e,t){if(t.everyone!==null)return t.everyone;let n=e.sinceOf(t,0);if(!(n<=e.now))return fT(e,t),null;let r=Mn(t,!0,void 0);return r.since=n,r.shown=e.shownOf(t,n),r.stepped=n,r.rebuilt=t.rebuilds,t.everyone=r,r}function cT(e,t){let n=e.sighted,r=t>>>5;return n!==null&&t>=0&&r<n.length&&(n[r]&1<<(t&31))!==0}function d_(e,t,n){let r=e.sighted,o=t>>>5;if(r===null||o>=r.length){let s=new Uint32Array(Math.max(o+1,(n>>>5)+1));r!==null&&s.set(r),e.sighted=s,r=s}let i=1<<(t&31);(r[o]&i)===0&&(r[o]=r[o]|i,e.seen++)}function dT(e,t){let n=e.weights;return n!==null&&t>=0&&t<n.length?n[t]:0}function lm(e,t,n,r){let o=e.weights;if(o===null||t>=o.length){if(n===0)return;let i=new Float64Array(Math.max(t+1,r));o!==null&&i.set(o),e.weights=i,o=i}o[t]=n}function Ca(e,t,n){if(e.built!==null)return;let r=e.stamps,o=n*2;if(t.stepped=t.since,r===null||o>=r.length){t.probed=Number.NaN,t.seeks=0,t.delta=null;return}let i=r[o+0];t.probed=i,t.seeks=r[o+1],t.delta=Number.isNaN(i)?null:e.deltas[n]??null}function hc(e,t,n,r){if(e.built!==null)return;let o=e.stamps,i=n*2;if(o===null||i>=o.length){if(Number.isNaN(t.probed))return;let s=new Float64Array(Math.max(n+1,r)*2).fill(Number.NaN);o!==null&&s.set(o),e.stamps=s,o=s,e.deltas??=[]}o[i+0]=t.probed,o[i+1]=t.seeks,e.deltas[n]=t.delta}function eY(e,t){let n=e.stamps,r=t*2;n!==null&&t>=0&&r<n.length&&(n[r+1]=-1),e.built!==null&&e.everyone!==null&&(e.everyone.seeks=-1)}function f_(e,t,n,r){if(cT(e,t)){let a=e.seen;d_(e,n,r),e.seen=a}let o=dT(e,t);(o!==0||e.weights!==null&&n<e.weights.length)&&lm(e,n,o,r);let i=e.stamps,s=t*2;if(i!==null&&s<i.length){let a=n*2;if(a>=i.length){let u=new Float64Array(Math.max(n+1,r)*2).fill(Number.NaN);u.set(i),e.stamps=u,i=u}i[a+0]=i[s+0],i[a+1]=i[s+1];let l=e.deltas;l[n]=l[t]??null}um(e,t)}function um(e,t){let n=e.sighted,r=t>>>5;n!==null&&r<n.length&&(n[r]=n[r]&~(1<<(t&31)));let o=e.weights;o!==null&&t<o.length&&(o[t]=0);let i=e.stamps,s=t*2;i!==null&&s<i.length&&(i[s+0]=Number.NaN,e.deltas[t]=null)}function fT(e,t,n=!1,r){if(!t.sharing)return;t.sharing=!1;let o=t.everyone;t.everyone=null;let i=e.sharers.indexOf(t);i>=0&&e.sharers.splice(i,1);let s=n?ut(e,r)?.slot??-1:-1;o!==null&&n&&(e.projecting||cT(t,s))?(s>=0&&um(t,s),t.subjects.set(r,o)):t.holder===o&&(t.holder=null),e.lanes?.rerecord(t.id,(a,l)=>e.held(t,a,l)),t.state!=="done"&&e.steps.push(t,++e.version),e.unshared=!0,Do(e),e.lanes?.refill()}function tY(e,t,n){t.weight=dT(e,n),Ca(e,t,n),um(e,n)}var p_={shares:X8,outgrow:Q8,everyoneOf:Z8,sighted:cT,sight:d_,weightAt:dT,weighAt:lm,open:Ca,shut:hc,restamp:eY,unsight:um,unshare:fT,inherit:tY};function Fa(e,t){return e-t*Math.round(e/t)}var Oa=Xn(4,0),pT=Xn(4,0);function hT(e,t,n,r){let o=r.length===n?r:Xn(n,0);for(let i=0;i<n;i++)o[i]=e[t+i];return o}function cm(e,t,n,r,o){if(e.turn>0){t[n]=t[n]+Fa(r,e.turn)*o;return}let i=e.axes;Oa=hT(t,n,i,Oa);let s=e.channel.fold(Oa,r,o);for(let a=0;a<i;a++)t[n+a]=s[a]}function h_(e,t,n,r,o,i){if(e.turn>0){cm(e,t,n,r[o],i);return}pT=hT(r,o,e.axes,pT),cm(e,t,n,pT,i)}function m_(e,t,n,r,o,i){if(e.turn>0){let l=t[n],u=r;t[n]=o===0?u:l+Fa(u-l,e.turn)*i;return}let s=e.axes,a=r;(o!==0||a.length!==s)&&(Oa=hT(t,n,s,Oa),a=e.channel.lerp(Oa,r,i));for(let l=0;l<s;l++)t[n+l]=a[l]}function y_(e,t){let n=e.values,r=e.axes;if(e.op!=="own"){n.fill(e.rest,0,t*r);return}let o=e.start;for(let i=0;i<t*r;i+=r)for(let s=0;s<r;s++)n[i+s]=o[s]}function mc(e,t){if(e.length>=t)return e;let n=new Float64Array(t);return n.set(e),n}function g_(e,t){let n=e.cap;t.met.length<n&&(t.met=mc(t.met,n),t.first=mc(t.first,n),t.sum=mc(t.sum,n));for(let r=0;r<t.values.length;r++){let o=t.values[r],i=t.taken[r],s=e.laned[r].axes;o!==void 0&&(t.values[r]=mc(o,n*s)),i!==void 0&&(t.taken[r]=mc(i,n))}if(t.inline=nY(t),!t.inline){e.into=t;try{for(let r of t.members){let o=r.voice;if(r.idle||o.state==="pending"||o.state==="done")continue;e.intoId=o.id,e.reset(r),r.elapsedNow=o.elapsedAt(e.now);let i=r.list,s=o.bound;s!==null&&GP(e,s);let a=e.fills;for(let l=0;l<i.length;l++){let u=i[l];if(s!==null&&!UP(s,u,a)){VP(e,r,l,u);continue}if(e.one(r,l,u)&&(fm(e,t,u),t.sum[u]=t.sum[u]+r.data[l*8+2]),o.keeping)break}}}finally{e.into=null}}}function fm(e,t,n){if(t.met[n]===e.fills)return;t.met[n]=e.fills,t.first[n]=e.intoId,t.sum[n]=0;let r=t.taken;for(let o=0;o<r.length;o++){let i=r[o];i!==void 0&&(i[n]=0)}}function dm(e,t,n,r){let o=e.arg,i=o[7],s=t.values[n.index],a=t.taken[n.index];if(s===void 0||a===void 0){b_(e,t,n,r,i);return}let l=o[0];fm(e,t,r);let u=a[r],c=u+l;s[r]=u===0?i:Mt(s[r],i,l/c),a[r]=c}function b_(e,t,n,r,o){let i=e.arg[0];fm(e,t,r);let s=n.index,a=t.values[s],l=t.taken[s];(a===void 0||l===void 0)&&(a=new Float64Array(e.cap*n.axes),l=new Float64Array(e.cap),t.values[s]=a,t.taken[s]=l);let u=l[r],c=u+i,d=i/c;if(!n.plain||!n.straight)m_(n,a,r*n.axes,o,u,d);else if(n.scalar)a[r]=u===0?o:Mt(a[r],o,d);else{let f=Array.isArray(o)||ArrayBuffer.isView(o)?o:null,p=r*n.axes;for(let h=0;h<n.axes;h++){let m=f===null?n.rest:f[h]??n.rest;a[p+h]=u===0?m:Mt(a[p+h],m,d)}}l[r]=c}function x_(e,t,n){let r=t.voice.id,o=e.fills,i=t.list;for(let s=0;s<i.length;s++){let a=i[s];n.met[a]!==o||n.first[a]!==r||n.sum[a]>0&&w_(e,n,a)}}function w_(e,t,n){for(let r=0;r<t.values.length;r++){let o=t.taken[r],i=o===void 0?0:o[n];if(!(i>0))continue;let s=i>1?1:i,a=e.laned[r],l=t.values[r],u=a.values,c=n*a.axes;if(!a.plain){h_(a,u,c,l,c,s);continue}for(let d=0;d<a.axes;d++)u[c+d]=Oe(a.op,u[c+d],l[c+d],s)}}function nY(e){if(!e.contiguous)return!1;let t=e.members,n=t[0].list;for(let r of t){let o=r.voice;if(r.idle||o.keeping||o.state==="pending"||o.state==="done")return!1;let i=r.list;if(i!==n){if(i.length!==n.length)return!1;for(let s=0;s<n.length;s++)if(i[s]!==n[s])return!1}}return!0}function P_(e,t){let n=t.members,r=e.arg;for(let s of n){e.reset(s),s.elapsedNow=s.voice.elapsedAt(e.now);let a=s.voice.bound;a!==null&&GP(e,a)}let o=e.fills,i=n[0].list;e.into=t;try{for(let s=0;s<i.length;s++){let a=i[s],l=0;for(let u=0;u<n.length;u++){let c=n[u];if(c.voice.keeping)continue;let d=c.voice.bound;if(d!==null&&!UP(d,a,o)){VP(e,c,s,a);continue}r[6]=c.mark,e.one(c,s,a)&&(fm(e,t,a),l+=c.data[s*8+2])}l>0&&w_(e,t,a)}}finally{e.into=null}}function T_(e,t){let n=e.chans;for(let r=0;r<n.length;r++)e.values[r]=t[n[r].name]}function S_(e,t){let n=e.chans;for(let r=0;r<n.length;r++)this.foldInto(n[r],t,e.values[r])}function k_(e,t,n){let r=e.length,o=this.arg,i=e[0];if(r>0){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Oe(i.op,l[t],s,o[0])}else o[7]=s,dm(this,a,i,t)}else this.foldInto(i,t,s)}if(i=e[1],r>1){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Oe(i.op,l[t],s,o[0])}else o[7]=s,dm(this,a,i,t)}else this.foldInto(i,t,s)}if(i=e[2],r>2){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Oe(i.op,l[t],s,o[0])}else o[7]=s,dm(this,a,i,t)}else this.foldInto(i,t,s)}for(let s=3;s<r;s++){i=e[s];let a=n[i.name];if(typeof a=="number"&&i.scalar&&i.plain){let l=this.into;if(l===null){let u=i.values;u[t]=Oe(i.op,u[t],a,o[0])}else o[7]=a,dm(this,l,i,t)}else this.foldInto(i,t,a)}}function v_(e,t,n){if(!e.plain){this.unplain(e,t,e.scalar?n[0]:n);return}let r=this.arg[0],o=e.values,i=t*e.axes;for(let s=0;s<e.axes;s++)o[i+s]=Oe(e.op,o[i+s],n[s],r)}function A_(e,t,n){if(n===void 0)return;if(this.into!==null){b_(this,this.into,e,t,n);return}if(!e.plain&&!this.unplain(e,t,n))return;let r=this.arg[0],o=e.values;if(e.scalar){o[t]=Oe(e.op,o[t],n,r);return}let i=t*e.axes,s=Array.isArray(n)||ArrayBuffer.isView(n)?n:null;for(let a=0;a<e.axes;a++){let l=s===null?e.rest:s[a]??e.rest;o[i+a]=Oe(e.op,o[i+a],l,r)}}function R_(e){let t=this.arg[0],n=this.folding,r=this.rec,o=n.chans.indexOf(e),i=r.bands??new Uint8Array(n.chans.length);r.bands=i;let s=i[o],a=this.host.passes(s===0?void 0:s===1,t);return i[o]=a?1:2,a}function N_(e,t,n){if(e.op==="last")return this.gate(e);let r=this.arg[0],o=e.values;return e.turn>0?o[t]=o[t]+Fa(n,e.turn)*r:cm(e,o,t*e.axes,n,r),!1}function I_(e,t){let n=t.voice,r=t.data,o=e.per,i=t.list,s=t.records,a=t.chans,l=t.values,u=a.length,c=e.fills,d=e.lately,f=n.elapsedAt(e.now);t.elapsedNow=f;let p=n.duration,h=n.passes,m=n.freezesBefore,g=n.freezesAfter,b=n.span,x=n.hidesPast,w=t.flat,y=n.parts!==null,P=Fr(n.weight),S=0;for(let N=0;N<u;N++)S+=a[N].axes;t.nums.length<S&&(t.nums=new Float64Array(S)),t.kinds.length<u&&(t.kinds=new Uint8Array(u));let v=t.nums,A=t.kinds;for(let N=0;N<i.length;N++){let M=i[N],C=N*8;if(Ot(r,C,o,M*6,c),d>=0&&e.unread(M))continue;let F=f-r[C+0],B=F>b&&x?Number.NaN:mh(F,m,g,b);if(!(B>=0)){r[C+2]=0,St(s[N]);continue}if(!w){let V=r[C+1];(!t.weighed||!Wt(V,t.weighedSince))&&(t.fade=e.host.envelope(n,V),t.weighed=!0,t.weighedSince=V)}let D=w&&!y?P:zt(n.weight,t.fade,e.parting(n,M));if(r[C+2]=D,(!t.read||!Wt(B,t.readAt))&&(e.readKeyed(n,Or(B,p,h),t.delta,t.scratch),t.read=!0,t.readAt=B,e.gather(t,t.delta),rY(a,l,v,A)),!(D>0)){St(s[N]);continue}let j=0;for(let V=0;V<u;V++){let J=a[V],se=J.axes,ke=A[V];if(ke===1){let ae=J.values,ve=M*se;for(let G=0;G<se;G++)ae[ve+G]=Oe(J.op,ae[ve+G],v[j+G],D)}else ke===2&&(e.folding=t,e.rec=s[N]??null,e.arg[0]=D,e.foldInto(J,M,l[V]));j+=se}}}function rY(e,t,n,r){let o=0;for(let i=0;i<e.length;i++){let s=e[i],a=t[i];if(a===void 0)r[i]=0;else if(!s.plain)r[i]=oY(s,a,n,o);else if(r[i]=1,s.scalar)n[o]=a;else{let l=Array.isArray(a)||ArrayBuffer.isView(a)?a:null;for(let u=0;u<s.axes;u++)n[o+u]=l===null?s.rest:l[u]??s.rest}o+=s.axes}}function oY(e,t,n,r){return e.turn>0?(n[r]=Fa(t,e.turn),1):2}var pm=class{lanes;crowd;row;made;constructor(t,n,r,o=0){this.lanes=t,this.crowd=n,this.row=r,this.made=o}};function Dn(e,t){let n=t.seat;return n!==null&&n.lanes===e?n:null}function E_(e,t,n,r){let o=Dn(e,t);return o!==null&&o.crowd===n&&o.row===r}function iY(e,t){if(e.metCrowd||e.owes(t))return!1;let n=e.met,r=e.metN;if(e.owed.last(n,r))return!0;let o=Number.NEGATIVE_INFINITY;for(let i of e.lanes){let s=i.voice.id;if(s<=o)continue;let a=n.indexOf(s);(a<0||a>=r)&&(o=s)}for(let i of e.crowds)i.size>0&&(o=Math.max(o,i.hot[(i.size-1)*i.stride+7]));for(let i=0;i<r;i++){let s=n[i];if(s<=o||e.byId.get(s).group!==null)return!1}return!0}function M_(e,t,n,r,o){let i=e.per[t*6+1],s=i<0?-1-i:i;e.per[t*6+1]=e.epochs;let a=!1;e.metN=0,e.metCrowd=!1;let l=e.dense;for(let f=l.length-1;f>=0;f--){let p=l[f];if(p.epoch<=s)break;if(p.positionOf(t)>=0)continue;let h=e.host.meet(p.voice,n,r,t);h.reaches&&(p.add(t,h),p.idle&&jt(e,t,1),e.met[e.metN++]=p.voice.id,a=!0)}let u=i<0?e.host.naming(n):void 0;if(u!==void 0)for(let f of u){let p=e.byId.get(f.id);if(p===void 0){lY(e,f,t,n,s,r)&&(a=!0,e.metCrowd=!0);continue}if(p.epoch<=s||p.positionOf(t)>=0)continue;let h=e.host.meet(f,n,r,t);h.reaches&&(p.add(t,h),p.idle&&jt(e,t,1),e.met[e.metN++]=f.id,a=!0)}if(!a)return o;let c=e.met;for(let f=1;f<e.metN;f++){let p=c[f],h=f-1;for(;h>=0&&c[h]>p;h--)c[h+1]=c[h];c[h+1]=p}let d=t*6;if(o&&e.per[d+2]===0){let f=sY(e,t);if(f||iY(e,t))return aY(e,t,n,f)||e.owed.owe(t,e.met,e.metN),!0}return e.per[d+0]=e.fills,!1}function sY(e,t){if(e.foldsFill!==e.fills||e.metCrowd||e.owes(t))return!1;let n=e.folds,r=e.metN;if(n.length!==r)return!1;for(let o=0;o<r;o++)if(n[o]!==e.met[o])return!1;return!0}function aY(e,t,n,r){if(e.filling)return!1;let o=e.lately,i=t*6;if(o>=0&&!(e.per[i+3]>o||e.per[i+4]>o))return!1;let s=e.met,a=e.metN;for(let l=0;l<a&&!r;l++){let u=e.byId.get(s[l]),c=u.voice;if(u.ran!==e.fills||u.motion!==void 0||c.keeping||typeof c.spec.weight=="function"||c.sharing&&c.everyone===null)return!1}r||(e.folds=s.slice(0,a),e.foldsFill=e.fills),e.subjects[t]===void 0&&(e.subjects[t]=n,e.holding=!0),e.meeting=!0;try{for(let l=0;l<a;l++){let u=e.byId.get(s[l]),c=u.voice,d=u.positionOf(t);if(!c.sharing){e.one(u,d,t);continue}let f=c.everyone;Ca(c,f,t),e.one(u,d,t),c.keeping||hc(c,f,t,e.cap)}}finally{e.meeting=!1}for(let l=0;l<a;l++)e.byId.get(s[l]).voice.keeping&&(e.foldsFill=-1);return!0}function lY(e,t,n,r,o,i){let s=Dn(e,t);if(s===null)return!1;let a=s.crowd,l=s.row,u=l*a.stride,c=a.hot[u+0];if(a.hot[u+6]<=o||(c&16)!==0)return!1;let d=e.host.meet(t,r,i,n);if(!d.reaches)return!1;let f=l*8;return a.list[l]=n,e.placed.add(n,t.id),a.data[f+0]=d.delay,a.data[f+1]=d.shown,a.data[f+2]=0,a.data[f+3]=0,a.data[f+4]=-1,a.data[f+5]=-1,a.data[f+7]=0,a.records[l]=d,a.deltas[l]=null,a.restale(l,c|16),a.idle&&jt(e,n,1),!0}function jt(e,t,n){let r=t*6+2;e.per[r]=e.per[r]+n}var uY=Ca,cY=hc,dY=0;function fY(e){if(e<2)return 1;for(let t=e;;t++){let n=!0;for(let r=2;r*r<=t;r++)if(t%r===0){n=!1;break}if(n)return t}}function yT(e,t,n){Vi(e);let r=e.host;e.filling=!0;let o=e.lookups;try{e.fills++,e.owed.begin(e.fills),e.now=t,e.filledAt=t,e.filledVersion=n;let i=e.numbers.size;e.keeps=r.keeps;let s=e.fresh;e.fresh=!1;let a=e.live>0?e.lastDistinct/e.live:1;e.lately=a<1?e.lastFrom:-1;let l=!1;for(let u of e.lanes){if(s){let c=u.line,d=u.list.length;d>=64?C_(e,u):d===1&&u.motion===void 0?u.idle||O_(e,u):(u.idle?a>=c.start:a<c.stop)&&mT(e,u)}u.idle||(l=!0)}for(let u of e.crowds)s&&(u.size>=64?C_(e,u):(u.idle?a>=u.line.start:a<u.line.stop)&&mT(e,u)),u.cursor=0,u.stale&&KF(u),!u.idle&&u.size>0&&(l=!0);if(l){for(let u of e.laned)y_(u,i);for(let u of e.roles)g_(e,u);for(let u of e.lanes)u.idle||(e.crowds.length>0&&(e.arg[6]=Number.NaN,_P(e,u.voice.id)),e.run(u));e.crowds.length>0&&(e.arg[6]=Number.NaN,_P(e,Number.POSITIVE_INFINITY));for(let u of e.crowds)u.idle||(u.bareFill=e.fills,u.bareNow=t)}e.busyFill=l?e.fills:0;for(let u of e.late)e.per[u*6+0]=e.fills;e.holding&&(e.subjects.fill(void 0,0,i),e.holding=!1),e.moved=pe.moved,e.inputs=pe.inputs,e.holds=e.lookups!==o}finally{e.filling=!1,e.late.length=0}}function C_(e,t){let n=t.list,r=t.line,o=e.lastFrom,i=e.lastTo,s=fY(Math.floor(n.length/256)),a=0,l=0;for(let c=e.fills%s;c<n.length;c+=s){let d=n[c];if(d<0)continue;let f=e.per[d*6+3],p=e.per[d*6+4];(f>o&&f<=i||p>o&&p<=i)&&l++,a++}let u=a>0?l/a:1;(t.idle?u>=r.start:u<r.stop)&&mT(e,t)}function mT(e,t){t.idle?gT(e,t):O_(e,t)}function O_(e,t){t.idle=!0;let n=t.list,r=t.data;for(let o=0;o<n.length;o++){let i=n[o];i<0||(jt(e,i,1),Ot(r,o*8,e.per,i*6,e.fills))}}function gT(e,t){t.idle=!1;for(let n of t.list)n>=0&&jt(e,n,-1)}function F_(e,t,n){let r=this.arg,o=r[5];if(Number.isNaN(n.probed))return this.late.push(t),!1;let i=this.subjectAt(t);return i===tr?(r[0]=0,!0):(this.host.signal(e,i,n,t),r[0]=zt(r[0],o,e.parts===null?1:this.host.parting(e,i)),!0)}function L_(e,t){if(e.parts===null)return 1;let n=this.subjectAt(t);return n===tr?1:this.host.parting(e,n)}function __(e){this.lookups++;let t=this.subjects[e];return t===void 0&&(t=this.numbers.subject(e),this.subjects[e]=t,this.holding=!0),t}function D_(e){let t=e.voice;e.placed=!1,this.arg[6]=Number.NaN,e.read=!1,e.weighed=!1,e.flat=!((t.fade.in??0)>0)&&t.out===null&&t.back===null&&t.owner===null,e.fade=1}function B_(e){let t=e.voice;if(t.state==="pending"||t.state==="done")return;let n=e.group;if(n!==null){n.inline?e===n.members[0]&&P_(this,n):x_(this,e,n);return}if(this.reset(e),e.ran=this.fills,e.motion!==void 0&&!t.keeping){UF(this,e,e.motion);return}if(t.built!==null&&typeof t.spec.weight!="function"){I_(this,e);return}e.elapsedNow=t.elapsedAt(this.now);let r=e.list;if(t.sharing){this.runEveryone(e);return}if(t.bound!==null){QF(this,e,t.bound);return}for(let o=0;o<r.length;o++)if(this.one(e,o,r[o]),t.keeping)return}function H_(e){let t=e.voice,n=t.everyone,r=e.list,o=this.cap;for(let i=0;i<r.length;i++){let s=r[i];if(uY(t,n,s),this.one(e,i,s),t.keeping)return;cY(t,n,s,o)}}function G_(e,t,n){let r=this.host,o=e.voice,i=e.elapsedNow,s=this.arg,a=e.data,l=t*8;if(Ot(a,l,this.per,n*6,this.fills),this.lately>=0&&this.unread(n))return!1;let u=a[l+0],c=i-u,d=c>=0?c>o.span?o.hidesPast?Number.NaN:o.freezesAfter?o.span:c:c:o.freezesBefore?0:Number.NaN;if(!(d>=0))return a[l+2]=0,St(e.records[t]),!1;(!e.placed||!Wt(d,e.placedAt))&&(e.placed=!0,e.placedAt=d,e.phase=Or(d,o.duration,o.passes),e.pass=Jn(d,o.duration,o.passes),s[6]=++dY,e.mark=s[6]);let f=a[l+1];!e.flat&&(!e.weighed||!Wt(f,e.weighedSince))&&(e.fade=r.envelope(o,f),e.weighed=!0,e.weighedSince=f);let p;if(typeof o.spec.weight=="function"){if(s[1]=d,s[3]=e.pass,s[5]=e.fade,!this.signalled(o,n,e.records[t]))return a[l+2]=0,St(e.records[t]),!1;p=s[0]}else p=zt(o.weight,e.fade,this.parting(o,n));if(a[l+2]=p,p>0||St(e.records[t]),this.folding=e,this.rec=e.records[t]??null,o.built!==null){if((!e.read||!Wt(d,e.readAt))&&(this.readKeyed(o,e.phase,e.delta,e.scratch),e.read=!0,e.readAt=d,this.gather(e,e.delta)),typeof o.spec.weight=="function"){let m=e.records[t];m.probed=this.now,m.seeks=o.seeks,m.delta=null}return p>0&&(s[0]=p,this.fold(e,n)),!0}let h=e.records[t];return Number.isNaN(h.probed)&&!this.meeting&&!e.every?(this.late.push(n),!1):(s[1]=d,s[4]=u,s[0]=p,e.motion!==void 0?(oc(this,e,e.motion,t,n,h),!0):(s[2]=e.phase,s[3]=e.pass,this.call(o,e.chans,h,n)))}function U_(e,t,n){let r=this.arg[2],o=this.arg[0],i=e.built,s=i.tracks;for(let a=0;a<s.length;a++){let l=s[a],u=t[a],c=PP(l,gP(l,r,i.duration),void 0);if(c===Fh)continue;if(c===ga){this.foldInto(u,n,Be.a);continue}let d=Be.a,f=Be.b,p=Be.eased;if(u.scalar||!u.plain||!u.straight){this.foldInto(u,n,e.lerps[a](d,f,p));continue}let h=d,m=f,g=u.values,b=n*u.axes,x=u.rest;for(let w=0;w<u.axes;w++){let y=Mt(h[w]??x,m[w]??x,p);g[b+w]=Oe(u.op,g[b+w],y,o)}}}function V_(e,t,n,r){Lh(e.built,t,n,void 0,e.lerps,void 0,e.intos,r)}function W_(e,t,n,r){let o=this.arg,i=o[2],s=o[4],a=o[0],l=this.host,u=this.subjectAt(r);if(u===tr)return!1;if(n.probed===this.now&&n.delta!==null&&n.seeks===e.seeks)return a>0&&this.foldDelta(t,r,n.delta),!0;if(yh(e,a))return n.delta=null,n.probed=this.now,n.seeks=e.seeks,e.spec.role!==void 0;let c=pe.kept;l.ready(e,u,n),this.keeps?l.horizon(e,s):pe.horizon=Number.POSITIVE_INFINITY;let d=e.patch.at(i,u,e.setting);return n.delta=d,n.probed=this.now,n.seeks=e.seeks,this.keeps&&l.after(e,u,n),pe.kept!==c&&!e.keeping&&l.kept(e),a>0&&this.foldDelta(t,r,d),!0}var hm=class{fill=new Int32Array(0);at=new Int32Array(0);lists=[];now=0;begin(t){this.now=t,this.lists.length=0}grow(t){let n=new Int32Array(t);n.set(this.fill),this.fill=n;let r=new Int32Array(t);r.set(this.at),this.at=r}any(){return this.lists.length>0}owes(t){return this.lists.length>0&&this.fill[t]===this.now}owesVoice(t,n){return this.lists[this.at[t]].includes(n)}owe(t,n,r){this.last(n,r)||this.lists.push(n.slice(0,r)),this.fill[t]=this.now,this.at[t]=this.lists.length-1}last(t,n){let r=this.lists[this.lists.length-1];if(r===void 0||r.length!==n)return!1;for(let o=0;o<n;o++)if(r[o]!==t[o])return!1;return!0}};var mm=class{one=new Int32Array(0);rest=null;grow(t){let n=new Int32Array(t);n.set(this.one),this.one=n}any(t){return this.one[t]|0}all(t){let n=this.any(t);return n===0?[]:[n,...this.rest?.get(t)??[]]}add(t,n){if(this.one[t]===0){this.one[t]=n;return}this.rest??=new Map;let r=this.rest.get(t);r===void 0?this.rest.set(t,[n]):r.push(n)}remove(t,n){let r=this.rest?.get(t);if(this.one[t]===n)this.one[t]=r===void 0?0:r.pop();else if(r!==void 0){let o=r.indexOf(n);if(o<0)return;r[o]=r[r.length-1],r.pop()}else return;r!==void 0&&r.length===0&&this.rest.delete(t)}};function pY(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function xT(e,t,n){let r=t.list[n];r>=0&&(t.idle&&jt(e,r,-1),e.placed.remove(r,t.voices[n].id)),t.list[n]=-1,t.records[n]=void 0,t.deltas[n]=null;let o=n*t.stride+0;t.hot[o]=t.hot[o]&-2065;let i=n*8;t.data[i+4]=-1,t.data[i+5]=-1,t.data[i+7]=0}function z_(e,t){let n=0;for(let o of t){if(!e.seats.has(o.id))return!1;n++}let r=0;for(let o of e.seats.values())o.crowd.voices[o.row].state!=="done"&&r++;return r===n}function K_(e,t){let n=new Set(t.map(i=>i.id));for(let i of e.crowds)for(let s=0;s<i.size;s++){let a=i.voices[s];(!n.has(a.id)||a.state==="done")&&Y_(e,i,s)}let r=e.crowds,o=new Map(e.seats);for(let i of o.values())i.lanes=null;e.crowds=[],e.seats.clear(),e.overlap=!1;for(let i of t){let s=o.get(i.id);wT(e,i,s?.crowd,s?.row,r)}e.crowds.length===0&&(e.lawsByKey.clear(),e.lastLaw=null)}function wT(e,t,n,r,o){let i=t.slots.map(u=>e.bySlot[u]),s=e.crowds.find(u=>pY(u.chans,i));if(s===void 0){s=new Yh(i,i[0].axes);let u=i.map(d=>d.name).join(" "),c=o.find(d=>d.chans.map(f=>f.name).join(" ")===u);c!==void 0&&(s.idle=c.idle);for(let d of e.crowds)d.chans.some(f=>i.includes(f))&&(e.overlap=!0);e.crowds.push(s)}let a=s.size;s.reserve(a+1),n!==void 0&&r!==void 0?j_(n,r,s,a):mY(e,s,a,t),s.hot[a*s.stride+6]===0&&t.state!=="pending"&&(s.hot[a*s.stride+6]=ym(e,t));let l=new pm(e,s,a,n===void 0?e.probes:0);e.seats.set(t.id,l),t.seat=l,t.laned=!0}function PT(e,t,n,r){let o=n*t.stride;t.hot[o+6]===0&&r.state!=="pending"&&(t.hot[o+6]=ym(e,r)),t.hot[o+0]=t.hot[o+0]|64}function TT(e){for(let t of e.crowds)t.dead>64&&t.dead*4>=t.size&&hY(e,t)}function hY(e,t){let n=t.keys;t.keys=new Aa;let r=0;for(let o=0;o<t.size;o++){let i=t.voices[o],s=Dn(e,i);if(s===null||s.crowd!==t||s.row!==o){t.odd?.delete(o);continue}r!==o?(j_(t,o,t,r,n),t.odd?.delete(o),s.row=r):$_(n,t,r),r++}t.list.length=r,t.voices.length=r,t.records.length=r,t.deltas.length=r,t.motions.length=r,t.eases.length=r,t.laws.length=r,t.dead=0}function ST(e,t,n){let r=t.voices[n];Y_(e,t,n),t.list[n]=-1,t.records[n]=void 0,t.deltas[n]=null,t.motions[n]=void 0,t.hot[n*t.stride+0]=0,e.seats.delete(r.id);let o=r.seat;o!==null&&o.lanes===e&&(o.lanes=null,r.seat=null),t.dead++}function bT(e,t,n,r,o){for(let i=0;i<o;i++)n[r+i]=e[t+i]}function j_(e,t,n,r,o=e.keys){e.fix(t),n.list[r]=e.list[t],bT(e.data,t*8,n.data,r*8,8),bT(e.hot,t*e.stride,n.hot,r*n.stride,e.stride),$_(o,n,r),(e.hot[t*e.stride+0]&4)!==0&&(n.stale=!0,n.staleRows.push(r)),bT(e.samples,t*e.axes,n.samples,r*n.axes,e.axes),n.deltas[r]=e.deltas[t]??null,n.records[r]=e.records[t],n.voices[r]=e.voices[t],n.motions[r]=e.motions[t],n.eases[r]=e.eases[t],n.laws[r]=e.laws[t];let i=e.odd?.get(t);i!==void 0&&(n.odd??=new Map,n.odd.set(r,i))}function $_(e,t,n){let r=n*t.stride;(t.hot[r+0]&512)!==0&&(t.hot[r+9]=t.keys.copy(e,t.hot[r+9]))}function mY(e,t,n,r){let o=On(r.patch),i=n*t.stride;t.hot.fill(0,i,i+t.stride);let s=r.built===null?-1:t.keys.add(r.built,t.chans);s>=0&&(t.hot[i+9]=s,t.hot[i+11]=r.duration,t.hot[i+10]=r.passes),t.restale(n,64|(o===void 0?0:128)|(o?.ease===void 0?0:1024)|(s>=0?512:0)),t.hot[i+7]=r.id,t.list[n]=-1;let a=n*8;if(t.data.fill(0,a,a+8),t.data[a+4]=-1,t.data[a+5]=-1,t.deltas[n]=null,t.records[n]=void 0,t.voices[n]=r,t.motions[n]=o,o===void 0){t.laws[n]=WF,t.eases[n]=void 0;return}t.laws[n]=yY(e,o),t.eases[n]=o.ease;let l=o.watcher===e?e.byId.get(o.watchId):void 0;if(l!==void 0)for(let u=0;u<l.list.length;u++)l.fix(u);o.watcher=e,o.watchId=r.id}function yY(e,t){let n=e.lastLaw;if(n!==null&&t.hasLaw(n))return n;let r=gY(e,t);return e.lastLaw=r,r}function gY(e,t){let n=t.law(),r=n.join(" "),o=e.lawsByKey.get(r);return o!==void 0?o:(e.lawsByKey.set(r,n),n)}function Y_(e,t,n){let r=t.list[n],o=t.records[n];if(r>=0){e.placed.remove(r,t.voices[n].id),t.idle&&jt(e,r,-1);let a=kT(e,t,n,r);o!==void 0&&a!==void 0&&(o.weight=a),o!==void 0&&t.motions[n]!==void 0&&ic(e,t,n,r,o)}let i=t.motions[n],s=t.voices[n];i!==void 0&&i.watcher===e&&i.watchId===s.id&&(i.watcher=null),s.laned=!1}function kT(e,t,n,r){let o=r*6;if(!(e.per[o+3]>e.per[o+4])||t.list[n]!==r)return;let i=Dn(e,t.voices[n])?.made??0;if(e.per[o+3]>i)return t.data[n*8+(e.per[o+5]===e.fills?2:3)]}function q_(e,t){let n=e.slice(),r=!0;for(;r;){r=!1;for(let s of t)if(!(s.fits&&s.slots.every(a=>n[a])))for(let a of s.slots)n[a]&&(n[a]=!1,r=!0)}let o=new Set,i=e.map(()=>!1);for(let s of t)if(!(!s.fits||!s.slots.every(a=>n[a]))){o.add(s.id);for(let a of s.slots)i[a]=!0}return{channels:i,voices:o}}function gm(e,t){Vi(e);let n=e.host;e.qualifiedVersion=t,e.filledVersion=Number.NaN;let r=e.touched.slice();e.touched.length=0;let o=n.voices.filter(h=>h.state!=="done"&&h.holding===null);for(let h of o)h.id>e.known&&(e.known=h.id);let i=n.channels.map(h=>qn(h)!==void 0),s=o.map(h=>h.slots.length>0&&n.fits(h));X_&&xY(o,s,n.channels);let a=()=>o.map((h,m)=>({id:h.id,fits:s[m],slots:h.slots})),{channels:l,voices:u}=q_(i,a());for(let h=!0;h;){h=!1;let m=new Map;o.forEach((g,b)=>{let x=g.spec.role;if(x===void 0)return;let w=m.get(x);w===void 0?m.set(x,[b]):w.push(b)});for(let g of m.values()){let b=g.filter(x=>u.has(o[x].id)).length;if(!(b===0||b===g.length)){for(let x of g)s[x]=!1;h=!0}}h&&({channels:l,voices:u}=q_(i,a()))}for(let h of e.lanes)u.has(h.voice.id)||J_(e,h);let c=[],d=0;for(let h of o){if(!u.has(h.id))continue;if(Ui(h)){d++;continue}let m=e.byId.get(h.id);m===void 0&&(m=new sc(h),m.made=e.probes),h.laned=!0,m.epoch===0&&h.state!=="pending"&&RT(e,m),c.push(m)}e.lanes=c,e.roles=[];let f=new Map;for(let h of c){h.group=null;let m=h.voice.spec.role;if(m===void 0)continue;let g=f.get(m);g===void 0&&(g={members:[],met:new Float64Array(e.cap),first:new Float64Array(e.cap),sum:new Float64Array(e.cap),values:[],taken:[],contiguous:!1,inline:!1},f.set(m,g),e.roles.push(g)),g.members.push(h),h.group=g}for(let[h,m]of f)m.contiguous=vY(o,u,h,m.members);e.dense=c.filter(h=>h.voice.named===null&&h.epoch>0).sort((h,m)=>h.epoch-m.epoch),e.whole=c.length+d===o.length,e.byId.clear();for(let h of c)e.byId.set(h.voice.id,h);c.length===0&&d===0&&(e.subjects=[]);let p=o.filter(h=>u.has(h.id)&&Ui(h));if(wY(e,l)&&z_(e,p)){for(let h of c)h.chans=h.voice.slots.map(m=>e.bySlot[m]),h.values=h.chans.map(()=>{});for(let h of e.crowds)for(let m=0;m<h.size;m++){let g=h.voices[m];E_(e,g,h,m)&&g.state==="done"&&ST(e,h,m)}for(let h of r){if(h.state==="done")continue;let m=Dn(e,h);m!==null&&PT(e,m.crowd,m.row,h)}TT(e);return}e.laned=[],e.copier=null,e.bySlot=n.channels.map(()=>{}),l.forEach((h,m)=>{if(!h)return;let g=n.channels[m],b=qn(g),x=g.rest??Number.NaN,w=typeof x=="number"&&b.axes===1,y=b.folds??b.op,P={name:n.names[m],op:y,plain:y!=="last"&&y!=="own"&&b.turn===void 0,straight:b.folds===void 0,turn:b.turn??0,channel:g,scalar:w,rest:typeof x=="number"?x:x[0],axes:b.axes,values:new Float64Array(e.cap*b.axes),start:typeof x=="number"?[]:x,index:e.laned.length};e.laned.push(P),e.bySlot[m]=P}),e.copies.length=0;for(let h of e.bySlot)e.copies.push(h!==void 0);for(let h of c)h.chans=h.voice.slots.map(m=>e.bySlot[m]),h.values=h.chans.map(()=>{});K_(e,p)}var X_=!0;function vT(e,t){return e.built===null&&e.motion===void 0&&e.slots.every(n=>bY(t[n]))}function bY(e){return Array.isArray(e.rest)&&qn(e)?.op!=="last"}function xY(e,t,n){let r=new Array(n.length).fill(!1),o=new Array(n.length).fill(!1);e.forEach((i,s)=>{if(!t[s])return;let a=Ui(i);if(vT(i,n)){if(!a)for(let l of i.slots)o[l]&&(r[l]=!0),o[l]=!0}else for(let l of i.slots)r[l]=!0}),e.forEach((i,s)=>{t[s]&&vT(i,n)&&!i.slots.some(a=>r[a])&&(t[s]=!1)})}function wY(e,t){let n=e.bySlot;if(n.length!==t.length)return!1;for(let r=0;r<n.length;r++)if(n[r]!==void 0!==t[r])return!1;return!0}function ym(e,t){let n=++e.epochs;if(t.named===null)return e.wide=n,n;for(let r of t.named.list){let o=e.host.slotOf(r);if(o<0||o>=e.cap)continue;let i=o*6+1,s=e.per[i],a=s<0?-1-s:s;e.per[i]=-1-Math.min(a,n-1)}return n}function AT(e){let t=Mi(e.touched);e.touched=[];let n=0;for(let o=0;o<t.length;o++)(o===0||t[o]!==t[o-1])&&(t[n++]=t[o]);t.length=n;let r=()=>(e.touched=t,!1);for(let o of t){let i=o.id<=e.known;o.id>e.known&&(e.known=o.id);let s=Dn(e,o);if(s!==null){if(o.state==="done"){ST(e,s.crowd,s.row);continue}PT(e,s.crowd,s.row,o);continue}if(o.state==="done"&&!i)continue;let a=e.byId.get(o.id);if(a!==void 0){if(!kY(e,a))return r();continue}if(o.state==="done"||o.spec.role!==void 0)return r();let l=o.slots.some(c=>e.bySlot[c]!==void 0),u=o.slots.length>0&&e.host.fits(o);if(!l&&(!u||X_&&Ui(o)&&vT(o,e.host.channels))){e.whole=!1;continue}if(i||!u||!l||o.slots.some(c=>e.bySlot[c]===void 0))return r();Ui(o)?wT(e,o,void 0,void 0,e.crowds):SY(e,o)}return TT(e),e.lanes.length===0&&e.crowds.every(o=>o.dead===o.size)&&(e.subjects=[]),!0}function RT(e,t){let n=t.voice;t.epoch=ym(e,n),n.named===null&&n.spec.target===void 0&&(t.reserve(e.live,e.cap),PY(e,t)&&TY(e,t))}function PY(e,t){let n=t.voice;return n.sharing&&n.everyone!==null&&t.motion===void 0&&!n.keeping&&typeof n.spec.weight!="function"&&t.list.length===0&&e.lastDistinct>=e.live}function TY(e,t){let n=t.voice.everyone,r=e.numbers,o=Math.min(r.size,e.cap);for(let i=0;i<o;i++)r.has(i)&&(t.add(i,n),t.idle&&jt(e,i,1));t.every=!0}function SY(e,t){let n=new sc(t);n.made=e.probes,t.laned=!0,t.state!=="pending"&&RT(e,n),n.chans=t.slots.map(r=>e.bySlot[r]),n.values=n.chans.map(()=>{}),e.lanes.push(n),e.byId.set(t.id,n),t.named===null&&n.epoch>0&&e.dense.push(n)}function kY(e,t){let n=t.voice;if(n.state!=="done")return t.epoch===0&&n.state!=="pending"&&(RT(e,t),n.named===null&&e.dense.push(t)),!0;if(t.group!==null)return!1;J_(e,t),e.lanes.splice(e.lanes.indexOf(t),1);let r=e.dense.indexOf(t);return r>=0&&e.dense.splice(r,1),e.byId.delete(n.id),!0}function J_(e,t){t.idle&&gT(e,t);let n=t.voice.state==="done";if(!n||t.motion!==void 0)for(let o=0;o<t.list.length;o++){let i=t.records[o],s=t.list[o],a=n?void 0:e.reported(t,s);i!==void 0&&a!==void 0&&(t.voice.sharing?lm(t.voice,s,a,e.cap):i.weight=a),i!==void 0&&t.motion!==void 0&&ic(e,t,o,s,i)}let r=t.motion;if(r!==void 0&&r.watcher===e&&r.watchId===t.voice.id){for(let o=0;o<t.list.length;o++)t.fix(o);r.watcher=null}t.voice.laned=!1}function vY(e,t,n,r){for(let s=1;s<r.length;s++)if(r[s].voice.id<=r[s-1].voice.id)return!1;let o=r[0].voice.id,i=r[r.length-1].voice.id;for(let s of e)if(s.id>o&&s.id<i&&t.has(s.id)&&s.spec.role!==n)return!1;return!0}function Z_(e,t,n,r){let o=e.lanes,i=n.slot;if(i<0||o.filling||o.host.keeps||e.projecting||o.roles.length>0||o.owed.any()||o.lanes.some(u=>u.voice.bound!==null)||!o.numbers.move(i,r))return!1;for(let u of o.lanes)u.renumber(i,r);let s=o.placed;for(let u of s.all(i)){s.remove(i,u);let c=o.seats.get(u);c===void 0||c.crowd.list[c.row]!==i||(c.crowd.list[c.row]=r,s.add(r,u))}let a=o.per;a.copyWithin(r*6,i*6,(i+1)*6),a[i*6+0]=o.fills,o.unlinked[r]=o.unlinked[i],o.subjects[r]=o.subjects[i],o.subjects[i]=void 0;for(let u of o.laned)u.values.copyWithin(r*u.axes,i*u.axes,(i+1)*u.axes);e.places?.forgot(i),e.places?.number(t,r);let l=o.cap;for(let u of e.general)SP(u,i,r),f_(u,i,r,l),Q_(e,u,i,r);for(let u of Fo(e).general)SP(u,i,r);for(let u=n;u!==null;u=u.next)u.voice!==null&&Q_(e,u.voice,i,r);return n.slot=r,!0}function Q_(e,t,n,r){let o=t.blend?.of;if(!(o===void 0||n>=o.frames.length||o.frames[n]!==e.frame)){if(r>=o.frames.length){let i=Math.max(r+1,o.frames.length*2,64),s=new Float64Array(i),a=new Float64Array(i);s.set(o.frames),a.set(o.values),o.frames=s,o.values=a}o.frames[r]=e.frame,o.values[r]=o.values[n],o.frames[n]=Number.NaN}}var yc=class{host;static share=p_;pulls={pullRun:r_,writeLater:o_,flush:Vi,renumber:Z_};numbers;lanes=[];dense=[];byId=new Map;crowds=[];seats=new Map;placed=new mm;unlinked=new Float64Array(0);overlap=!1;roles=[];folding=null;meeting=!1;folds=[];foldsFill=-1;rec=null;arg=new Float64Array(8);into=null;intoId=0;lawsByKey=new Map;lastLaw=null;met=[];metN=0;metCrowd=!1;owed=new hm;laned=[];copier=null;bySlot=[];copies=[];whole=!1;cap=0;epochs=0;wide=0;touched=[];known=0;per=new Float64Array(0);fills=0;busyFill=0;probes=0;subjects=[];holding=!1;holds=!0;lookups=0;filling=!1;late=[];queueSlots=new Int32Array(0);queueRows=new Int32Array(0);queueCounts=new Int32Array(0);queued=0;queuedFor=null;queueFrom=null;keeps=!1;now=Number.NaN;filledAt=Number.NaN;moved=0;inputs=0;frameAt=Number.NaN;frameProbes=0;lastFrom=0;lastTo=0;fresh=!1;distinct=0;lastDistinct=0;live=0;lately=-1;filledVersion=Number.NaN;qualifiedVersion=Number.NaN;constructor(t,n){if(this.host=t,n===void 0){this.numbers=new Nh(this);return}this.numbers=n.numbers,this.numbers.adopt(this),this.live=n.live;let r=this.numbers.size;this.grow(r);let o=this.per;for(let i=0;i<r;i++)o[i*6+0]=Number.NaN,o[i*6+1]=-1}invalidate(){this.qualifiedVersion=Number.NaN,this.filledVersion=Number.NaN}refill(){this.filledVersion=Number.NaN}touch(t){this.touched.push(t),this.filledVersion=Number.NaN}number(t){let n=this.numbers.take(t);return this.live++,this.grow(n+1),this.per[n*6+0]=this.fills,this.per[n*6+1]=-1,this.per[n*6+2]=0,this.per[n*6+3]=0,this.per[n*6+4]=0,this.per[n*6+5]=0,this.filling&&this.late.push(n),n}release(t){this.numbers.release(t)}sought(t){return Number.isNaN(this.per[t*6+0])}renew(t){return this.sought(t)?(this.per[t*6+0]=this.fills,this.filling&&this.late.push(t),!0):!1}part(t,n){let r=this.byId.get(t);if(r!==void 0){if(r.positionOf(n)<0)return;r.idle&&jt(this,n,-1),r.remove(n);return}let o=this.seats.get(t);o!==void 0&&o.crowd.list[o.row]===n&&xT(this,o.crowd,o.row)}rejoin(t){t<this.cap&&(this.per[t*6+1]=-1)}weightOf(t,n){if(n<0)return;let r=this.byId.get(t);if(r!==void 0)return this.reported(r,n);let o=this.seats.get(t);return o===void 0?void 0:kT(this,o.crowd,o.row,n)}reported(t,n){let r=n*6,o=this.per[r+3];if(!(o>this.per[r+4])||!(o>t.made))return;let i=t.positionOf(n);if(!(i<0))return t.data[i*8+(this.per[r+5]===this.fills?2:3)]}prepare(t,n,r,o){let i=this.host.clock.now;if(!this.filled(i,r)&&this.begin(i,r)===0)return this.general(t);if(t<0)return!1;this.probedThisFrame(t)||this.distinct++;let s=++this.probes,a=this.per,l=t*6,u=a[l+0]<this.busyFill&&a[l+2]===0;return a[l+1]<this.wide&&(u=M_(this,t,n,o,u)),u?(a[l+3]=s,a[l+5]=this.fills,this.holds&&(this.subjects[t]=n,this.holding=!0)):a[l+4]=s,u}filled(t,n){return this.frameAt===t&&this.qualifiedVersion===n&&this.touched.length===0&&!this.filling&&this.current(t,n)}current(t,n){return this.filledAt===t&&this.filledVersion===n&&this.moved===pe.moved&&this.inputs===pe.inputs}begin(t,n){if(t!==this.frameAt&&(this.lastFrom=this.frameProbes,this.lastTo=this.probes,this.lastDistinct=this.distinct,this.distinct=0,this.frameAt=t,this.frameProbes=this.probes,this.fresh=!0),this.filling||(this.qualifiedVersion!==n?!Number.isNaN(this.qualifiedVersion)&&this.touched.length>0&&AT(this)?this.qualifiedVersion=n:gm(this,n):this.touched.length>0&&!AT(this)&&gm(this,n),this.laned.length===0))return 0;if(!this.current(t,n)&&(yT(this,t,n),this.qualifiedVersion!==n)){if(gm(this,n),this.laned.length===0)return 0;yT(this,t,n)}return 1}general(t){return t>=0&&(this.per[t*6+4]=++this.probes),!1}unread(t){let n=this.per,r=t*6,o=this.lately;return n[r+3]>o||n[r+4]>o?!1:(n[r+0]=this.fills,!0)}probedThisFrame(t){let n=this.frameProbes,r=t*6;return this.per[r+3]>n||this.per[r+4]>n}owes(t){return this.owed.owes(t)}owesVoice(t,n){return this.owed.owesVoice(t,n)}paid(t,n,r){let o=this.byId.get(t),i=o===void 0?-1:o.positionOf(n);if(i<0)return;o.data[i*8+2]=r;let s=o.voice.bound;s!==null&&r!==0&&Zh(s,n,this.fills)}rests(t){for(let n of this.laned){let r=n.values;if(n.op==="last"){if(!Number.isNaN(r[t*n.axes]))return!1;continue}if(n.scalar){if(!(Math.abs(r[t]-n.rest)<1e-9))return!1;continue}if(n.start.length<n.axes)return!1;let o=t*n.axes;for(let i=0;i<n.axes;i++)if(!(Math.abs(r[o+i]-n.start[i])<1e-9))return!1}return!0}forget(t){this.host.forgot(t),this.live--;for(let r of this.lanes)r.remove(t);let n=this.placed;for(let r=n.any(t);r!==0;r=n.any(t)){let o=this.seats.get(r);o!==void 0&&o.crowd.list[o.row]===t?xT(this,o.crowd,o.row):n.remove(t,r)}t<this.cap&&(this.per[t*6+0]=this.fills),this.subjects[t]=void 0}grow(t){if(t<=this.cap)return;let n=Math.max(t,this.cap*2,64),r=new Float64Array(n*6);r.set(this.per),this.per=r,this.owed.grow(n),this.placed.grow(n);let o=new Float64Array(n);o.set(this.unlinked),this.unlinked=o;for(let i of this.laned){let s=new Float64Array(n*i.axes);s.set(i.values),i.values=s}this.cap=n}stretchChanged(t,n){let r=this.seats.get(t);if(r!==void 0){let s=r.crowd;s.restale(r.row,s.hot[r.row*s.stride+0]);return}let o=this.byId.get(t),i=o===void 0?-1:o.positionOfMotion(n);i>=0&&o.fix(i)}rerecord(t,n){let r=this.byId.get(t);if(r!==void 0)for(let o=0;o<r.list.length;o++){let i=r.list[o],s=this.subjectAt(i);s!==tr&&(r.records[o]=n(s,i))}}reshown(t){let n=this.seats.get(t);if(n!==void 0){let o=n.crowd.records[n.row];o!==void 0&&(n.crowd.data[n.row*8+1]=o.shown)}let r=this.byId.get(t);if(r!==void 0)for(let o=0;o<r.list.length;o++){let i=r.records[o];i!==void 0&&(r.data[o*8+1]=i.shown)}}voiceChanged(t){let n=Dn(this,t);if(n===null)return;let r=n.crowd,o=n.row*r.stride+0;r.hot[o]=r.hot[o]|64}},AY={copy:u_,row:zF,signalled:F_,parting:L_,subjectAt:__,reset:D_,run:B_,runEveryone:H_,one:G_,foldKeys:U_,readKeyed:V_,call:W_,gather:T_,fold:S_,foldDelta:k_,foldRun:v_,foldInto:A_,gate:R_,unplain:N_};for(let[e,t]of Object.entries(AY))Object.defineProperty(yc.prototype,e,{value:t,writable:!0,configurable:!0});var xm=class{xy=new Float64Array(0);n=0;cell=Number.NaN;dirty=!0;x0=0;y0=0;size=1;cols=0;rows=0;starts=new Int32Array(1);order=new Int32Array(0);home=new Int32Array(0);strays=[];stray=new Uint8Array(0);found=new Int32Array(64);count=0;put(t,n,r){if(this.xy[2*t]=n,this.xy[2*t+1]=r,this.dirty)return;if(this.cols===0||t>=this.home.length){this.dirty=!0;return}let o=Math.floor((n-this.x0)/this.size),i=Math.floor((r-this.y0)/this.size);(o>=0&&o<this.cols&&i>=0&&i<this.rows?i*this.cols+o:-2)===this.home[t]||this.stray[t]===1||(this.stray[t]=1,this.strays.push(t),this.strays.length>Math.max(32,this.n>>4)&&(this.dirty=!0))}build(){this.dirty=!1;for(let m of this.strays)this.stray[m]=0;this.strays.length=0;let t=this.xy,n=Math.min(this.n,t.length>>1),r=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let m=0;m<n;m++){let g=t[2*m],b=t[2*m+1];g<r&&(r=g),g>i&&(i=g),b<o&&(o=b),b>s&&(s=b)}if(!(i>=r)||!(s>=o)){this.cols=0,this.rows=0;return}let a=Number.isNaN(this.cell)?Math.sqrt(2*Math.max(i-r,1e-9)*Math.max(s-o,1e-9)/n):this.cell,l=4*n+64;(Math.floor((i-r)/a)+1)*(Math.floor((s-o)/a)+1)>l&&(a=Math.max(a,Math.sqrt((i-r)*(s-o)/n),(i-r+s-o)/l));let u=Math.floor((i-r)/a)+1,c=Math.floor((s-o)/a)+1;this.x0=r,this.y0=o,this.size=a,this.cols=u,this.rows=c;let d=u*c;this.starts.length<d+1?this.starts=new Int32Array(d+1):this.starts.fill(0,0,d+1),this.order.length<n&&(this.order=new Int32Array(n)),this.home.length<n&&(this.home=new Int32Array(n),this.stray=new Uint8Array(n));let f=this.starts,p=this.order;for(let m=0;m<n;m++){let g=eD(t,m,r,o,a,u);this.home[m]=g,g>=0&&(f[g+1]=f[g+1]+1)}for(let m=0;m<d;m++)f[m+1]=f[m+1]+f[m];let h=f[d];for(let m=n-1;m>=0;m--){let g=eD(t,m,r,o,a,u);if(g<0)continue;let b=f[g+1]-1;f[g+1]=b,p[b]=m}for(let m=0;m<d;m++)f[m]=f[m+1];f[d]=h}push(t,n){if(n===this.found.length){let r=new Int32Array(this.found.length*2);r.set(this.found),this.found=r}return this.found[n]=t,n+1}query(t,n,r,o){if(this.dirty&&this.build(),this.count=0,this.cols===0||!(r>=0))return 0;let i=this.size,s=Math.max(0,bm((t-r-this.x0)/i,-1)),a=Math.min(this.cols-1,bm((t+r-this.x0)/i,1)),l=Math.max(0,bm((n-r-this.y0)/i,-1)),u=Math.min(this.rows-1,bm((n+r-this.y0)/i,1)),c=this.xy,d=this.order,f=this.starts,p=this.strays.length>0,h=0;for(let m=l;m<=u&&s<=a;m++){let g=f[m*this.cols+s],b=f[m*this.cols+a+1];for(let x=g;x<b;x++){let w=d[x];if(p&&this.stray[w]===1)continue;let y=c[2*w]-t,P=c[2*w+1]-n;y*y+P*P<=o&&(h=this.push(w,h))}}for(let m of this.strays){let g=c[2*m]-t,b=c[2*m+1]-n;g*g+b*b<=o&&(h=this.push(m,h))}return this.count=h,h}ring(t,n,r){if(this.dirty&&this.build(),this.count=0,this.cols===0||!(r>=0))return 0;let o=this.size,i=r+o,s=r*r,a=i*i,l=Math.max(0,Math.floor((t-i-this.x0)/o)),u=Math.min(this.cols-1,Math.floor((t+i-this.x0)/o)),c=Math.max(0,Math.floor((n-i-this.y0)/o)),d=Math.min(this.rows-1,Math.floor((n+i-this.y0)/o)),f=this.xy,p=0;for(let h=c;h<=d;h++)for(let m=l;m<=u;m++){let g=this.x0+m*o-t,b=this.y0+h*o-n;if(Math.max(g*g,(g+o)**2)+Math.max(b*b,(b+o)**2)<=s)continue;let w=h*this.cols+m;for(let y=this.starts[w];y<this.starts[w+1];y++){let P=this.order[y];if(this.stray[P]===1)continue;let S=f[2*P]-t,v=f[2*P+1]-n,A=S*S+v*v;A>s&&A<=a&&(p=this.push(P,p))}}for(let h of this.strays){let m=f[2*h]-t,g=f[2*h+1]-n,b=m*m+g*g;b>s&&b<=a&&(p=this.push(h,p))}return this.count=p,p}};function eD(e,t,n,r,o,i){let s=e[2*t],a=e[2*t+1];return!(s>=n)||!(a>=r)?-1:Math.floor((s-n)/o)+Math.floor((a-r)/o)*i}function bm(e,t){let n=Math.floor(e);return t<0?e-n<1e-6?n-1:n:n+1-e<1e-6?n+1:n}var wm=class extends xm{slotOf;keepRefs;at=new me;slots=new Int32Array(0);placeOf=new Int32Array(0);refs=null;cur=-1;free=[];owned=!0;tokens=[];registry=null;constructor(t,n){super(),this.slotOf=t,this.keepRefs=n,this.refs=n?[]:null}set(t,n,r){let o=t.length;this.at=new me;for(let i=0;i<o;i++)this.at.set(t[i],i);this.slots=new Int32Array(Math.max(o,16)).fill(-1),this.placeOf.fill(-1),this.refs=this.keepRefs?[]:null,this.tokens=[],this.free=[];for(let i=0;i<o;i++){let s=t[i];this.at.get(s)===i&&this.hold(s,i)}this.n=o,this.xy=n,this.owned=!1,this.cell=r,this.dirty=!0}place(t){let n=this.at.get(t);if(n!==void 0)return n;let r=this.free.pop()??this.n++;return this.room(r+1),this.at.set(t,r),this.hold(t,r),this.owned&&this.put(r,Number.NaN,Number.NaN),r}hold(t,n){let r=this.slotOf(t);r>=0&&this.numbered(r,n);let o=typeof t=="object"&&t!==null;if(this.refs!==null&&(this.refs[n]=o?new WeakRef(t):t),!o)return;let i={i:n};this.tokens[n]=i,this.registry??=new FinalizationRegistry(s=>{this.tokens[s.i]===s&&this.release(s.i)}),this.registry.register(t,i,i)}room(t){if(this.slots.length<t){let n=new Int32Array(Math.max(t,this.slots.length*2)).fill(-1);n.set(this.slots),this.slots=n}if(this.owned&&this.xy.length<2*t){let n=new Float64Array(Math.max(2*t,this.xy.length*2,32)).fill(Number.NaN);n.set(this.xy),this.xy=n}}number(t,n){let r=this.at.get(t);r!==void 0&&this.numbered(n,r)}numbered(t,n){if(t>=this.placeOf.length){let r=new Int32Array(Math.max(t+1,this.placeOf.length*2,64)).fill(-1);r.set(this.placeOf),this.placeOf=r}this.placeOf[t]=n,this.slots[n]=t}forgot(t){if(t>=this.placeOf.length)return;let n=this.placeOf[t];n<0||(this.placeOf[t]=-1,this.slots[n]===t&&(this.slots[n]=-1))}drop(t){let n=this.at.get(t);if(n===void 0)return;this.at.delete(t);let r=this.tokens[n];r!==void 0&&this.registry?.unregister(r),this.release(n)}release(t){this.tokens[t]=void 0,this.refs!==null&&(this.refs[t]=void 0);let n=this.slots[t];n>=0&&(this.placeOf[n]=-1),this.slots[t]=-1,this.owned&&this.put(t,Number.NaN,Number.NaN),this.free.push(t)}subjectAt(t){let n=this.refs?.[t],r=n instanceof WeakRef?n.deref():n;return r!==void 0&&this.at.get(r)===t?r:void 0}inside(t,n,r,o){let i=this.at.get(t);if(i===void 0||2*i+1>=this.xy.length)return!1;let s=this.xy[2*i]-n,a=this.xy[2*i+1]-r;return s*s+a*a<=o}};function tD(e,t,n){if(t.length<2*e.length)throw new RangeError(`blits: plot takes two numbers a subject, x then y: ${e.length} subjects need ${2*e.length}, not ${t.length}`);if(n!==void 0&&!(n>0&&n<Number.POSITIVE_INFINITY))throw new RangeError(`blits: plot's cell is a size above 0, not ${n}`);rD(this).set(e,t,n??Number.NaN),this.moved()}function nD(e){return rD(this).place(e)}function rD(e){if(e.places!==null)return e.places;let t=new wm(n=>e.chains.get(n)?.slot??-1,!zu());e.places=t;for(let n of e.cued)n.bound===null&&tm(e,n);return t}function oD(){this.places!==null&&(this.places.dirty=!0),this.lanes?.refill(),this.stir()}function iD(e,t,n){let r=this.places,o=r===null?void 0:r.at.get(e);if(r===null||o===void 0)throw new Error("blits: put takes a subject with an index: place or plot it first");if(2*o+1>=r.xy.length)throw new RangeError(`blits: put's subject is at index ${o}, past the positions plot was given: plot again with room for it`);r.put(o,t,n),this.lanes?.refill(),this.stir()}var Pm=class{list=[];head=0;get length(){return this.list.length-this.head}push(t){this.list.push(t)}shed(t,n){let r=this.list,o=this.head;for(;o+1<r.length&&r[o+1].at<=t;)n?.(r[o]),o++;o>=512&&o*2>=r.length&&(r.splice(0,o),o=0),this.head=o}at(t){let n=this.list,r=this.head,o=n.length-1,i;for(;r<=o;){let s=r+o>>1,a=n[s];a.at<=t?(i=a,r=s+1):o=s-1}return i}numbered(t){let n=this.list,r=this.head,o=n.length-1;for(;r<=o;){let i=r+o>>1,s=n[i];if(s.seq===t)return s;s.seq<t?r=i+1:o=i-1}}all(){return this.list.slice(this.head)}set(t){this.list=t,this.head=0}};var Tm=class e{keeps;log;constructor(t,n=[{anchorNow:0,anchorElapsed:0,rate:1,ramp:null,seq:Number.NEGATIVE_INFINITY}]){this.keeps=t,this.log=n}get clock(){return this.log[this.log.length-1]}get waiting(){return Number.isNaN(this.clock.anchorNow)}sync(t){return this.waiting&&(this.log=[{...this.clock,anchorNow:t,anchorElapsed:t}]),this.reading(t)}reading(t){if(this.waiting)return t;let n=this.log,r=n.length-1;for(;r>0&&n[r].anchorNow>t;)r--;return ze(n[r],t)}at(t,n){if(!(t>n)||this.waiting)return this.reading(t);let r=this.clock,o=r.ramp;return(o===null?r.rate<=0:o.to<=0&&t>r.anchorNow+o.over)?Number.POSITIVE_INFINITY:ze(r,t)}timeOf(t){if(this.waiting)return t;let n=this.log,r=0;for(;r+1<n.length&&t>n[r+1].anchorElapsed;)r++;return En(n[r],t)}rateAt(t){let n=this.clock;return this.waiting||Number.isNaN(t)?n.ramp===null?n.rate:n.ramp.from:ua(n,t)}stopped(t){let n=this.clock,r=n.ramp;return r===null?n.rate===0:r.to===0&&!this.waiting&&t>=n.anchorNow+r.over}change(t,n,r,o,i){let s=this.clock,a={...s,seq:i};if(Number.isNaN(t)||this.waiting){let u=this.rateAt(Number.NaN);a.ramp=r>0&&n!==u?{from:u,to:n,over:r}:null,a.rate=n,a.anchorNow=Number.NaN,this.log=[a];return}ca(a,t,n,r);let l=this.log;this.keeps&&s.anchorNow<t?l.push(a):l[l.length-1]=a,this.shed(o)}shed(t){let n=this.log,r=0;for(;r+1<n.length&&n[r+1].anchorElapsed<=t;)r++;return r>0?n.splice(0,r):[]}unshed(t){let n=this.log[0].anchorNow,r=t.filter(o=>o.anchorNow<n).sort((o,i)=>o.anchorNow-i.anchorNow);r.length>0&&(this.log=[...r,...this.log])}cut(t){let n=this.log,r=1;for(;r<n.length&&n[r].anchorNow<=t;)r++;n.length=r}until(t){let n=this.log,r=1;for(;r<n.length&&n[r].anchorNow<t;)r++;return new e(this.keeps,n.slice(0,r))}};var Sm=e=>({t:Number.NaN,seq:0,up:null,rank:0,left:null,cut:null,of:e}),sD=Sm(null);function RY(e){let t=e,n=t.up;for(;n!==null;){let r=n.up;if(r===null)return n;t.up=r,t=r,n=t.up}return t}var gc=class extends me{own;now;make;stamp=Sm(this);first=this.stamp;at=new me;roots=[];kept=0;ready=[];aging=[];top=Number.NaN;constructor(t,n,r){super(),this.own=t,this.now=n,this.make=r}back(t,n,r){let o=this.stamp;r!==null&&(o.left=r,o.cut=n);let i=this.roots,s=o,a=null;for(;i.length>0;){let l=i[i.length-1].deref();if(l!==void 0&&l.t<t)break;let u=i.pop();l!==void 0&&(l.rank>s.rank?(s.up=l,s=l,a=u):(l.up=s,l.rank===s.rank&&s.rank++))}s.t=t,s.seq=n.seq,i.push(a??new WeakRef(s)),i.length>2*this.kept+16&&(this.roots=i.filter(l=>l.deref()!==void 0),this.kept=this.roots.length),this.stamp=this.fresh(),this.top=t}fresh(){if(this.ready.length===0){let t=Math.min(64,Math.max(1,this.aging.length*2));this.ready=this.aging.reverse(),this.aging=[];for(let n=0;n<t;n++)this.aging.push(Sm(this))}return this.ready.pop()??Sm(this)}sure=!0;get(t){return this.from(t,this.own.get(t))}find(t,n){let r=n.restored;return r!==null&&r.of===this&&this.sure?this.from(t,n):this.get(t)}from(t,n){let r=n?.reaches,o=(r?n.restored:this.at.get(t))??this.first,i=this.stamp;if(o===i)return n;r?n.restored=i:this.at.set(t,i);let s=RY(o),a=o.left?.at(t,o.cut),l=a??this.now(t,n,s),u=l&&this.make(l,s,a===void 0);return u===void 0?(this.shed(t),r&&this.at.set(t,i)):u!==n?this.set(t,u):u.reaches||this.at.set(t,i),u}set(t,n){let r=this.own.get(t);if(r===n){n.reaches?n.restored=this.stamp:this.at.set(t,this.stamp);return}r?.reaches&&(r.restored=sD),n.reaches&&n.restored!==null&&(this.sure=!1),this.own.set(t,n),n.reaches?n.restored=this.stamp:this.at.set(t,this.stamp)}delete(t){this.shed(t),this.at.set(t,this.stamp)}shed(t){let n=this.own.get(t);n?.reaches&&(n.restored=sD),this.own.delete(t)}clear(){this.sure=!1,this.own.clear(),this.at.clear()}};function La(e,t){if(e.reaches(t))return!1;let n=e.pager;if(n===null)throw new Error(`blits: ${t} is older than this mix's history reaches`);let r=n.loaded;if(r===null||r.t>t){let o=n.last;throw new Yu(o?.mix??"",o?.stream??"history",t)}for(let o of[...e.members,...e.dropped.map(i=>i.mix)]){let i=o.name??"";if(o.outs?.missing(r.t,a=>r.records.some(l=>l.stream==="voice"&&l.voice===a&&l.mix===i))!==void 0)throw new Yu(i,"voice",t)}return n.loaded=null,NY(e,r.records),e.floor=r.t,!0}function km(e,t){if(!Number.isInteger(t))throw new RangeError(`blits: a frame is a number \`seq\` read, not ${t}`);let n=e.frames.numbered(t),r=e.pager;if(n===void 0&&r!==null&&t<=e.seq){let o=r.loaded?.records.find(i=>i.stream==="frame"&&i.mix===""&&i.seq===t);if(o!==void 0)La(e,o.at),n=e.frames.numbered(t);else if(t<(e.frames.all()[0]?.seq??Number.POSITIVE_INFINITY))throw new Error(`blits: frame ${t} reaches past memory; await prepare with its mix time first`)}if(n===void 0)throw new Error(`blits: frame ${t} is not one this mix's history holds: not played yet, let go, or after a moment a seek went back to`);return La(e,n.at),n}function lD(e,t){let n=e.pager;if(n===null)return;n.store.cut(t);let r=n.loaded;r!==null&&(r.records=r.records.filter(o=>o.seq<=t))}function NY(e,t){IY(e,t);let n=new Map;for(let o of[...e.members,...e.dropped.map(i=>i.mix)])n.set(o.name??"",o);let r=new Map;for(let o of[...t].sort((i,s)=>i.seq-s.seq)){let i=n.get(o.mix);if(i===void 0)continue;let s=r.get(i);s===void 0?r.set(i,[o]):s.push(o)}for(let[o,i]of r)EY(o,i)}function IY(e,t){let n=t.filter(a=>a.mix===""&&a.voice===void 0),r=n.filter(a=>a.stream==="pace").map(a=>a.data);r.length>0&&e.pace?.unshed(r);let o=n.filter(a=>a.stream==="frame").map(a=>({seq:a.seq,at:a.at,u:a.data}));e.frames.set(bc(o,e.frames.all()));let i=new Set(e.announced.map(a=>a.order)),s=n.filter(a=>a.stream==="mark"&&!i.has(a.data.order)).map(a=>a.data);s.length>0&&(e.announced=[...s,...e.announced].sort((a,l)=>a.order-l.order))}function EY(e,t){let n=new Map;for(let s of[...e.cued,...e.gone])n.set(s.id,s);for(let s of t)if(s.stream==="voice"&&s.voice!==void 0&&!n.has(s.voice)){let a=lL(e,s.voice,s.data);n.set(a.id,a),e.gone.push(a),Rh(e,a)}let r=t.filter(s=>s.stream==="host");e.hostLog=bc(r.map(s=>({at:s.at,seq:s.seq,fields:s.data})),e.hostLog);let o=new Map;for(let s of t){if(s.voice===void 0)continue;let a=o.get(s.voice);a===void 0?o.set(s.voice,[s]):a.push(s)}let i=e.keys;for(let[s,a]of o){let l=n.get(s);l!==void 0&&MY(l,a,i)}}function MY(e,t,n){let r=s=>t.filter(a=>a.stream===s);e.log!==null&&(e.log=bc(r("controls").map(s=>s.data),e.log));let o=r("left");if(o.length>0){let s=[...e.left?.all()??[]];for(let a of o){let l=n.subject(a.subject);if(s.some(p=>p.seq===a.seq&&Object.is(p.subject,l)))continue;let[u,c,d=null,f=null]=a.data;s.push({subject:l,at:a.at,seq:a.seq,sync:c,held:Fi(e,u),ramp:d,parted:f})}s.sort((a,l)=>a.seq-l.seq),e.left=Cn.from(s)}for(let[s,a]of NT(r("snap"))){let l=n.subject(s);for(let[u,c]of aD(e,l,a))u.snaps=bc(c.map(d=>({at:d.at,seq:d.seq,held:Fi(e,d.data)})),u.snaps??[])}for(let[s,a]of NT(r("input"))){let l=n.subject(s);for(let[u,c]of aD(e,l,a))u.inputs=bc(c.map(d=>({at:d.at,seq:d.seq,value:d.data})),u.inputs??[])}let i=e.motion;if(i!==void 0){for(let s of r("released"))i.reclaim(n.subject(s.subject),s.at,s.seq,s.data);for(let[s,a]of NT(r("stretch")))i.restretch(n.subject(s),a)}}function NT(e){let t=new Map;for(let n of e){let r=t.get(n.subject);r===void 0?t.set(n.subject,[n]):r.push(n)}return t}function aD(e,t,n){let r=e.left?.of(t)??[],o=[],i=Number.NEGATIVE_INFINITY;for(let a of r)o.push([a.held,n.filter(l=>l.seq>i&&l.seq<=a.seq)]),i=a.seq;let s=e.subjects.get(t);return s?.reaches&&o.push([s,n.filter(a=>a.seq>i)]),o}function bc(e,t){let n=t[0]?.seq??Number.POSITIVE_INFINITY,r=[];for(let o of e)o.seq<n&&(r.length>0&&r[r.length-1].seq===o.seq?r[r.length-1]=o:r.push(o));return r.length===0?t:[...r,...t]}function CY(e,t,n,r,o,i){let s=r.t,a=n.inputs?.filter(P=>P.at<=s),l=n.snaps;if(l===void 0){let P=i&&n.reaches?Ma(n):Ho(t,n);return P.stepped>s&&(P.stepped=s),uD(P,n,s),P.weight=0,P.inputs=a,P.since<=s||xa(e,t,P),P}let u=l.length,c=u>0&&l[u-1].at<=s?u-1:u>1&&l[u-2].at<=s?u-2:eT(l,s,!0);if(c<0)return;let d=l[c],{ticks:f,since:p,rebuilt:h,state:m,slot:g,restored:b}=n,x;i&&n.reaches?(x=nT(t,d.held,n,!0),x.slot=g,x.restored=b):x=Ho(t,d.held,!0),x.weight=0,uD(x,n,s),d.at<s&&(x.copied=!0);let w=c+1;if(i)OY(t,l,w);else for(let P=0;P<w;P++)l[P].shared=!0;x.snaps=i?l:l.slice(0,w),x.inputs=a,x.since<=d.at||xa(e,t,x);let y=i&&f>x.ticks&&p===x.since&&h===x.rebuilt;if(t.patch.step!==void 0&&(d.ahead!==void 0||s-d.at>=o||y)){let P=d.ahead;P===void 0||P.since!==x.since?(P={put:x,sought:s,since:x.since,at:d.at,ticks:x.ticks,state:void 0,leftTicks:0,left:void 0},d.ahead=P):(P.put=x,P.sought=s),y&&(P.leftTicks=f,P.left=m)}return x}function uD(e,t,n){e.restedAt=t.restedAt<=n?t.restedAt:Number.NaN}function OY(e,t,n){for(;t.length>n;){let r=t.pop();r.shared||(r.ahead=void 0,e.spares??=[],e.spares.push(r))}}function FY(e,t){let n=t.owner;n?.holding&&(n.holding.kids--,t.passed&&n.holding.played--);let r=t.motion;r!==void 0&&r.owner===e.owner&&r.ownerId===t.id&&(r.owner=null),t.park()}function LY(e,t,n,r){let o={seq:r,strict:!1},i=t.log,s=fc(i,o)??i[0];if(i.length=i.indexOf(s)+1,t.take(s),t.reopen(r)&&t.owner?.holding&&t.owner.holding.played--,t.doneAt=Number.POSITIVE_INFINITY,t.doneSeq=Number.POSITIVE_INFINITY,t.parts!==null){for(let[c,d]of t.parts)d.seq>r&&t.parts.delete(c);t.parts.size===0&&(t.parts=null)}if(t.parted!==null){for(let[c,d]of t.parted)d.seq<=r||(t.parted.delete(c),!(d.ramp===void 0||d.ramp.seq>r)&&(t.parts??=new Map,t.parts.set(c,d.ramp)));t.parted.size===0&&(t.parted=null)}t.seen=0,t.restedCount=0,t.early=null,t.holder=null,t.keepOn=null,t.laned=!1,t.unreached=null,t.unreachedBits=null,t.seeks++,t.spares=null;let a=t.left?.all()??[];t.left!==null&&am(t,t.left.after(o),r),t.left=Cn.from(a.filter(c=>c.seq<=r));let l=Cn.from(a.filter(c=>c.seq>r)),u=t.subjects;if(!(u instanceof gc)){let c=pc(e.opts.history),d=(p,h,m)=>xh(t,p,h,m.t,m.seq),f=new gc(u,d,(p,h,m)=>{let g=CY(e,t,p,h,c,m);return g===void 0||(g.reaches&&t.seen++,Io(g)&&t.restedCount++,g.since<=f.top||(t.early??=[],t.early.push(g))),g});u=f,t.subjects=u}u.back(n,o,l)}function _a(e,t){if(e.projecting)throw new Error("blits: a projection does not seek");if(!e.history)throw new Error("blits: seeking needs a mix made with history");let r=e.tape;if(r===void 0)throw new Error("blits: seeking needs history.tape, which keeps the calls a seek plays again");if(Number.isNaN(e.now))throw new Error("blits: a mix that has never synced has nothing to seek");let o,i;if(typeof t=="number"){if(o=t,o===Number.POSITIVE_INFINITY)throw new RangeError("blits: a mix seeks to a finite time");if(!(o>=e.born))throw new Error(`blits: ${o} is older than this mix's history reaches`);if(La(e,o),o<e.now&&(i=e.frames.at(o),i===void 0))throw new Error(`blits: ${o} is older than this mix's history reaches`)}else{let s=km(e,t.frame);o=s.at,s.seq!==e.seq&&(i=s)}if(i===void 0){let s=ka(e,c=>(e.pace===null?c:e.pace.reading(c))<=o),a=e.left,l=a!==null&&a.t===o&&a.u>=e.u&&(e.pace===null?a.u:e.pace.reading(a.u))===o?a.u:Wr(e,o),u=Number.isNaN(s)?l:Math.max(s,l);if(!Number.isFinite(u))throw new RangeError(`blits: the mix's rate never reaches ${o}`);if(e.u=u,Number.isNaN(s)||e.now!==o)for(let c of e.members)zr(c,o)}else{let s=i.at===o?i.u:Hi(e,o),a=i.seq;e.left={t:e.now,u:e.u},r.goto(r.depthAt(s)),e.undrop(a),e.announced=e.announced.filter(l=>l.seq<=a),e.frames.set(e.frames.all().filter(l=>l.seq<=a)),e.pacedSeq>a?(e.pace=null,e.pacedSeq=Number.POSITIVE_INFINITY):e.pace?.cut(s),e.u=s,e.now=o;for(let l of e.members)_Y(l,o,a,i.at<o);lD(e,a)}e.tick(o),e.offset=e.last-e.u,e.kept();for(let s of e.members){s.stir();let a=s.bookers;if(a!==null)for(let l of a)l.sought()}}function _Y(e,t,n,r){let o=[...e.cued,...e.gone].sort((c,d)=>c.id-d.id),i=[],s=[],a=new Set;for(let c of o)c.motion!==void 0&&a.add(c.motion);for(let c of o)c.cuedSeq>n?FY(e,c):c.doneSeq<=n?s.push(c):i.push(c);for(let c of i)LY(e,c,t,n);let l={seq:n,strict:!1};for(let c of i)c.state=c.stateAt(t,l),c.begunSeq>n&&(c.begunSeq=Number.POSITIVE_INFINITY);e.cued=i,e.gone=s,e.retired=[];for(let c of i)c.holding!==null&&(c.holding.children=i.filter(d=>d.owner===c),c.holding.back(n));let u=e.lanes;u!==null&&e.lanesOf!==null?e.lanes=new e.lanesOf(zh(e),u):e.chains=new me,e.owners=i.some(c=>c.holding!==null)?i.filter(c=>c.holding!==null):null,Bo(e),e.parters.clear();for(let c of[...i,...s])(c.parts!==null||c.parted!==null)&&e.parters.add(c);e.relinks++,e.lastPoses=new me,e.restStamps!==null&&(e.restStamps=new me),t_(e);for(let c of[...i,...s]){c.unreached=null,c.unreachedBits=null;let d=c.blend?.of;d!==void 0&&(d.frame=0,d.reads=new me,d.frames=new Float64Array(0),d.values=new Float64Array(0))}e.playing.clear();for(let c of i){let d=c.motion;d!==void 0&&(e.playing.set(d,(e.playing.get(d)??0)+1),e.owner!==null&&(d.owner=e.owner,d.ownerId=c.id))}for(let c of a)u!==null&&c.watcher===u&&(c.watcher=null),c.rewind(n);e.hostLog=e.hostLog.filter(c=>c.seq<=n),e.sent=e.sent.filter(c=>c.timestamp<=t),e.sentTo=t,e.pins=null;for(let c of i)c.state==="pending"&&!Number.isNaN(c.pinned)&&(e.pins??=new Map,e.pins.set(c,c.pinned));e.due.clear();for(let c of i)it(e,c);if(e.stir(),r)zr(e,t);else{e.frame=st(),e.reducedNow=e.reduced;let c=e.opts.history.ms;e.anchored>0&&e.transport.forgotTo>=t-c&&Gr(e)}}var ET=Symbol.for("@msb235/blits/watch/1"),MT=globalThis;function CT(){let e=MT[ET];if(e!==void 0)return e;let t=new Map,n=new Set,r=new WeakMap;return e={refs:t,entries_:r,fns:n,labels:new WeakMap,next:1,counted:0,history:void 0,gone:new FinalizationRegistry(o=>{t.delete(o);for(let i of[...n])i({kind:"gone",id:o})}),entries(){let o=[];for(let i of t.values()){let s=i.deref(),a=s===void 0?void 0:r.get(s);a!==void 0&&o.push(a)}return o},on(o){return n.add(o),()=>{n.delete(o)}}},MT[ET]=e,e}var dD=new WeakSet;function fD(e){let t=MT[ET]?.history;return e.history!==void 0||e.transport!==void 0||t===void 0?{history:e.history,added:!1}:{history:t,added:!0}}function pD(e){dD.add(e)}function hD(e){let t=CT(),n=t.next++,r=e.transport,o={id:n,release:ch,name:e.name,mix:e,get history(){let i=r.history;return i===void 0?void 0:{ms:i.ms,tape:r.tape!==void 0,added:dD.has(r)}},get reach(){return bD(r,!1)},channels:e.names,voice:i=>{let s=e.cued.find(a=>a.handle===i)??e.gone.find(a=>a.handle===i);return s===void 0?void 0:{name:s.spec.name,tags:s.spec.tags??[],within:s.bound?.area}},label:i=>DY(e,i),watch:i=>GY(e,i),subjects:()=>HY(e),read:(i,s=e.now)=>e.project(s).probe(i),hold:()=>WY(r)};t.entries_.set(e,o),t.refs.set(n,new WeakRef(e)),t.gone.register(e,n,e);for(let i of[...t.fns])i({kind:"add",entry:o})}function mD(e){let t=CT(),n=t.entries_.get(e);if(n===void 0||!t.refs.has(n.id))return;t.refs.delete(n.id),t.gone.unregister(e),yD(e);let r=e.transport,o=xc(r).held,i=s=>t.refs.has(t.entries_.get(s)?.id??-1);o!==null&&!r.members.some(i)&&o.free();for(let s of[...t.fns])s({kind:"gone",id:n.id})}function DY(e,t){return e.opts.labelOf?.(t)??BY(t)}function BY(e){if(typeof e!="object"||e===null)return typeof e=="function"?e.name||"function":String(e);let t=globalThis.Element;if(t!==void 0&&e instanceof t){let i=e.id?`#${e.id}`:"",s=[...e.classList].map(a=>`.${a}`).join("");return`${e.tagName.toLowerCase()}${i}${s}`}let n=e;for(let i of["name","id"]){let s=n[i];if(typeof s=="string"&&s!==""||typeof s=="number")return String(s)}let r=CT(),o=r.labels.get(e);return o===void 0&&(o=`${e.constructor?.name||"Object"} #${++r.counted}`,r.labels.set(e,o)),o}function HY(e){let t=nr.get(e),n=new Set(t?.was);for(let r of t?.seen??[])n.add(r);for(let r of e.cued)if(r.state!=="done")for(let o of r.spec.subjects??[])n.add(o);return[...n]}var cD=new WeakMap;function xc(e){let t=cD.get(e);return t===void 0&&(t={tapped:0,held:null,unsync:null},cD.set(e,t)),t}function vm(e){let t=xc(e),n=t.tapped>0||t.held!==null;if(n&&t.unsync===null){let r=Am(e).sync;t.unsync=jr(e,"sync",o=>{for(let s of e.members)gD(s);let i=t.held;i===null?r.call(e,o):i.sync(o)})}else!n&&t.unsync!==null&&(t.unsync(),t.unsync=null)}function jr(e,t,n){let r=e,o=r[t];return r[t]=n,()=>{r[t]=o}}function Am(e){return Object.getPrototypeOf(e)}var nr=new WeakMap;function GY(e,t){let n=nr.get(e);if(n===void 0){let r=Am(e),o=r.probe,i=r.pull,s=r.drain,a=[jr(e,"probe",(l,u)=>{let c=o.call(e,l,u);return IT(e).probed.push({subject:l,pose:VY(c)}),nr.get(e).seen.add(l),c}),jr(e,"pull",(l,u)=>{let c=Array.isArray(l)?l:[...l];i.call(e,c,u);let d={};for(let[p,h]of Object.entries(u))h!==void 0&&(d[p]=h.slice());IT(e).pulled.push({subjects:[...c],columns:d});let f=nr.get(e).seen;for(let p of c)f.add(p)}),jr(e,"drain",l=>{let u=s.call(e,l);return u.length>0&&IT(e).sent.push(...u),u})];n={fns:new Set,frame:null,seen:new Set,was:new Set,untap:()=>{for(let l of a)l()}},nr.set(e,n),xc(e.transport).tapped++,vm(e.transport)}return n.fns.add(t),UY(new WeakRef(e),t)}function UY(e,t){return()=>{let n=e.deref(),r=n===void 0?void 0:nr.get(n);n===void 0||r===void 0||!r.fns.delete(t)||r.fns.size>0||yD(n)}}function yD(e){let t=nr.get(e);t!==void 0&&(t.untap(),nr.delete(e),xc(e.transport).tapped--,vm(e.transport))}function IT(e){let t=nr.get(e);return t.frame!==null&&t.frame.seq===e.transport.seq||(gD(e),t.was=t.seen,t.seen=new Set,t.frame={seq:e.transport.seq,now:e.now,timestamp:e.timestamp,probed:[],pulled:[],sent:[],voices:e.voices()}),t.frame}function gD(e){let t=nr.get(e),n=t?.frame;if(!(t===void 0||n==null)){t.frame=null;for(let r of[...t.fns])r(n)}}function VY(e){try{return globalThis.structuredClone(e)}catch{return{...e}}}function bD(e,t){let n=e.history;if(n===void 0||t&&e.tape===void 0)return e.now;let r=e.pager!==null?Number.NEGATIVE_INFINITY:e.now-n.ms;return Math.max(e.born,e.floor,r)}function WY(e){let t=xc(e);if(t.held!==null)throw new Error("blits: that mix is held already; free it first");let n=Am(e),r=n.ramp,o=n.rebase,i=n.sync,s=n.seek,a=[],l=0,u=!1,c=!1,d=e.last,f=e.last,p=y=>{let P=u;u=!0;try{y()}finally{u=P}},h=y=>{e.replaying||u?y():a.push(y)},m=()=>{e.rebasing&&!Number.isNaN(e.last)&&i.call(e,e.last),i.call(e,d)},g=[],b=e.tape;if(b!==void 0){let y=b.recordEntry;g.push(jr(b,"recordEntry",(...P)=>{u||b.timestampAt(b.undoDepth())!==void 0||y.apply(b,P)}))}g.push(jr(e,"ramp",(y,P)=>{if(!(y>=0&&y<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a mix's rate is a finite number, 0 or more, not ${y}`);h(()=>r.call(e,y,P))}),jr(e,"rebase",()=>h(()=>o.call(e))),jr(e,"seek",y=>h(()=>s.call(e,y))));for(let y of e.members){let P=Am(y).seek;g.push(jr(y,"seek",S=>{e.shared?P.call(y,S):h(()=>P.call(y,S))}))}t.held={sync(y){Number.isNaN(d)?d=y:!Number.isNaN(f)&&y>f&&(d+=(y-f)*l),f=y,m()},free:()=>w.free()},vm(e),e.woke();let x=()=>{if(c)throw new Error("blits: that hold was freed")},w={get mixes(){return[...e.members]},get now(){return e.now},get reach(){return bD(e,!0)},get rate(){return l},set rate(y){if(x(),!(y>=0&&y<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a hold's rate is a finite number, 0 or more, not ${y}`);l=y},seek(y){x(),p(()=>_a(e,y))},step(y){if(x(),!(y>0))return;if(Number.isNaN(d))throw new Error("blits: a mix that has never synced has nothing to step");let P=Wr(e,e.now+y);if(!Number.isFinite(P))throw new RangeError("blits: the mix's own rate is 0, so it never moves");d=Math.max(d,P+e.offset),m();for(let S of e.members)S.stir()},free(){if(!c){c=!0;try{o.call(e);for(let y of a)y()}finally{for(let y of g.reverse())y();t.held=null,vm(e),e.woke()}}}};return w}var zY=1e3,Go=class{history;shared;members=[];dropped=[];slots=0;holders=new Map;wakeFns=[];woken=!1;now=Number.NaN;seq=0;frames=new Pm;u=Number.NaN;offset=0;left=null;born=Number.NaN;floor=Number.NEGATIVE_INFINITY;last=Number.NaN;rebasing=!1;taped=Number.NEGATIVE_INFINITY;pace=null;forgotTo=Number.NEGATIVE_INFINITY;settled=Number.NEGATIVE_INFINITY;settle(){this.now>this.settled&&(this.settled=this.now)}pacedSeq=Number.POSITIVE_INFINITY;ahead=new Map;replaying=!1;announced=[];nextId=1;tape;pager;constructor(t,n){this.history=t,this.shared=n,this.tape=cF(this),this.pager=t?.store===void 0?null:new Sh(t.store)}get projecting(){return this.members.some(t=>t.projecting)}join(t,n=this.slots++){t.slot=n;let r=this.members.findIndex(o=>o.slot>n);r<0?this.members.push(t):this.members.splice(r,0,t),lO(t)}drop(t){let n=t,r=this.members.indexOf(n);if(r<0)throw new Error(`blits: ${n.name??"that mix"} is not on this transport`);this.members.splice(r,1),uO(n),n.dropped=!0,this.history!==void 0&&(this.dropped.push({mix:n,at:this.now,seq:this.seq}),Ct(this,"drop",o=>{let i=o.mix(n);i!==void 0&&o.transport(this).drop(i)}))}undrop(t){let n=this.dropped.filter(r=>r.seq>t);if(n.length!==0){this.dropped=this.dropped.filter(r=>r.seq<=t);for(let r of n)r.mix.dropped=!1,this.join(r.mix,r.mix.slot)}}seek(t){_a(this,t)}prepare(t){return sO(this,t)}announce(t,n){if(n?.score===void 0)throw new Error("blits: a transport announces on a named score, which every mix on it sees");OT(this,t,n,-1,void 0)}marks(t,n){return JO(this,t,n).map(({order:r,...o})=>o)}project(t){return Rm(this,t)}get live(){return this.members.some(t=>t.live)}get inert(){return this.members.every(t=>t.inert)}onWake(t){let n=this.wakeFns;return n.push(t),()=>{let r=n.indexOf(t);r>=0&&n.splice(r,1)}}woke(){if(!this.woken){this.woken=!0;for(let t of[...this.wakeFns])t()}}sync(t){let n=this.members;for(let r of n)r.syncing=!0;try{this.syncAt(t)}finally{for(let r of n)r.syncing=!1}}syncAt(t){if(Number.isNaN(t))throw new RangeError("blits: sync was given NaN; it takes the host clock as a number");if(t<this.last&&!this.rebasing)throw new RangeError(`blits: sync went back from ${this.last} to ${t}; the host's clock only goes forward, and seek moves the mix`);this.rebasing&&!Number.isNaN(this.last)&&(this.offset+=t-this.last),this.rebasing=!1,this.last=t;let n=t-this.offset,r=this.pace,o=r===null?n:r.sync(n),i=n!==this.u,s=i&&o===this.now;this.u=n,Number.isNaN(this.born)&&(this.born=o);let a=!1;if(this.tape!==void 0&&i&&(a=ka(this,c=>c<=n)===n,r=this.pace,o=r===null?n:r.reading(n)),!a){this.tick(o);let c=o!==this.now;for(let d of this.members)(c||i&&r!==null&&pL(d))&&zr(d,o)}let l=this.history;this.kept();let u=this.keepsFrom();if(this.tape!==void 0&&l!==void 0&&!(u-this.taped<zY)){let c=Hi(this,u);c<Number.POSITIVE_INFINITY&&this.tape.prune(c),this.taped=u}if(l!==void 0&&this.dropped.length>0&&(this.dropped=this.dropped.filter(c=>c.at>=u)),this.frames.shed(u),iO(this),this.woken=!1,s)for(let c of this.members)c.frame=st(),c.lanes?.refill();for(let c of this.members){let d=c.bookers;if(d!==null)for(let f of d)f.sync()}}tick(t){let n=++this.seq;this.history!==void 0&&this.frames.push({seq:n,at:t,u:this.u});for(let r of this.members)r.looked=!1}rebase(){this.rebasing=!0,this.settle()}kept(){let t=this.history;t!==void 0&&this.pager===null&&this.now-t.ms>this.floor&&(this.floor=this.now-t.ms)}reaches(t){return this.pager!==null?t>=this.floor:t>=this.floor&&t>=this.now-(this.history?.ms??0)}keepsFrom(){let t=this.history;return t===void 0?Number.POSITIVE_INFINITY:this.pager===null?this.now-t.ms:Number.NEGATIVE_INFINITY}get rate(){return this.pace===null?1:this.pace.rateAt(this.u)}set rate(t){this.ramp(t,0)}ramp(t,n){if(!(t>=0&&t<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a mix's rate is a finite number, 0 or more, not ${t}`);if(this.pace===null){this.pace=new Tm(this.history!==void 0||this.projecting),this.pacedSeq=this.seq;for(let o of this.members)for(let i of o.cued)i.state==="pending"&&!i.placing&&i.owner===null&&i.spec.start!==void 0&&Lo(o,i,i.start)}let r=this.history===void 0?Number.NEGATIVE_INFINITY:this.keepsFrom();this.pace.change(this.u,t,n,r,this.seq);for(let o of this.members)o.stir();Ct(this,"rate",o=>o.transport(this).ramp(t,n))}};function OT(e,t,n,r,o){let i=n.at!==void 0?n.at-e.offset:e.u,s={name:t,score:n.score,tags:n.tags??[],at:i,order:e.nextId++,seq:e.seq,slot:r,mix:o};e.announced.push(s),e.settle(),Ct(e,"announce",a=>{let l=a.transport(e);l.announced.push({...s,seq:l.seq})})}function PD(e,t,n,r,o){let i=e.tape,s=i?.undoDepth()??0;try{for(;;){let a=KY(i,t,r);if(!(a<r))break;if(xD(e,t,n,a),!TD(t))continue;for(let u of t.members)u.anchored>0&&Gr(u);let l=jY(t);for(let[u,c]of n){let d=new Uo(c.kit,{...c.opts,transport:l},null);d.slot=c.slot,d.projecting=!0,d.share=c.share,FT(c,d);let f=o.get(u);f===void 0?o.set(u,{at:[c],met:new Set}):f.at.push(c),n.set(u,d)}t=l}xD(e,t,n,r)}finally{i!==void 0&&i.undoDepth()!==s&&i.goto(s)}return t}function TD(e){for(let t of e.members)for(let n of t.cued)if(n.state!=="done"&&(n.patch.step!==void 0||typeof n.spec.weight=="function"))return!0;return!1}function KY(e,t,n){let r=t.now,o=Number.POSITIVE_INFINITY,i=e?.timestampAt(e.undoDepth());if(i!==void 0&&(o=t.pace===null?i:t.pace.reading(i)),!TD(t))return o<n?o:Number.POSITIVE_INFINITY;for(let s of t.members)for(let a of s.cued){if(a.state==="done")continue;for(let u of Di){let c=Xe(s,a,u);c!==void 0&&c>r&&c<o&&(o=c)}let l=a.spec.marks;if(l!==void 0)for(let u of Object.keys(l)){let c=Xe(s,a,u);c!==void 0&&c>r&&c<o&&(o=c)}}for(let s of t.announced){let a=t.pace===null?s.at:t.pace.at(s.at,t.u);a>r&&a<o&&(o=a)}return o<n?o:Number.POSITIVE_INFINITY}function xD(e,t,n,r){let o=e.tape,i=a=>(t.pace===null?a:t.pace.reading(a))<=r,s=o?.timestampAt(o.undoDepth());if(t.u=Wr(t,r),s!==void 0&&i(s)){for(let l of t.members)for(let u of l.cued)u.parts!==null&&(u.parts=new Map(u.parts)),u.parted!==null&&(u.parted=new Map(u.parted));let a=ka(e,i,t,{transport:()=>t,mix:l=>n.get(l)});t.u=Math.max(a,Wr(t,r))}if(!(t.now>=r))for(let a of t.members)zr(a,r)}function jY(e){let t=new Go(void 0,!0);return t.offset=e.offset,t.u=e.u,t.nextId=e.nextId,t.now=e.now,t.pace=e.pace===null?null:e.pace.until(Number.POSITIVE_INFINITY),t.announced=e.announced.map(n=>({...n})),t.ahead=e.ahead,t}function FT(e,t){wc(e,t),t.cued=e.cued.filter(n=>n.state!=="done").map(n=>{let r={mix:e,voice:n,up:wD.get(n),seen:0,shared:!1,filled:!1},o=n.copy(s=>XY(r,s,t,o),void 0,!0);r.seen=o.seen,r.shared=o.sharing,wD.set(o,r);let i=e.pins?.get(n);return i!==void 0&&Lo(t,o,i),o}),t.waking=e.waking,va(t.cued),(e.owners!==null||e.projecting&&t.cued.some(n=>n.holding!==null))&&ya(t.cued),Bo(t)}function wc(e,t){t.lastPoses=e.lastPoses,t.wantsPose=e.wantsPose,t.reducedNow=e.reducedNow}function Nm(e,t,n){if(t.sharing){let o=ut(e,n)?.slot??-1,i=e.share;if(!i.sighted(t,o))return;let s=t.everyone;return i.open(t,s,o),s.weight=i.weightAt(t,o),s}let r=t.subjects.get(n);return r!==void 0||t.unreachedBits===null?r:Xu(t,ut(e,n)?.slot??-1)?t.unreached:void 0}var wD=new WeakMap;function $Y(e,t){return e.seen===t.seen&&!t.filled&&!t.shared&&e.unreached===null&&e.unreachedBits===null}function YY(e,t,n){return e.projecting&&n.reaches&&!t.sharing&&n!==t.unreached}function qY(e){return e.restored=null,Ma(e)}function XY(e,t,n,r){let o=e.mix,i=e.voice,s=e;for(;s.up!==void 0&&$Y(s.voice,s.up);)s=s.up;if(s!==e&&Nm(s.mix,s.voice,t)===void 0)return;let a=Nm(o,i,t);if(a===void 0)return;let l=YY(o,i,a)?qY(a):Ho(i,a);return l.reaches&&!(l.since<=o.now)&&(l.since=n.sinceOf(r,l.delay),l.shown=n.shownOf(r,l.since)),l.from=l.stepped,e.filled=!0,l}function JY(e,t){let n=t.patch,r=t.spec;if(n.state!==void 0||n.step!==void 0)return"its patch keeps state";if(t.motion!==void 0)return"it plays a motion";if(t.keeping)return"its patch or its weight keeps state";if(r.from==="current")return"it starts from the pose its subjects had";if(t.written)return"its handle has been written to";if(r.anchor!==void 0)return"an anchor places it";if(t.holding!==null)return"it is an owner";if(t.owner!==null)return"it plays under an owner";if(!(typeof r.weight!="function"&&r.role===void 0&&!((t.fade.in??0)>0)&&!((t.fade.out??0)>0))&&t.slots.some(i=>e.channels[i]?.rest===void 0))return"it writes a channel with no rest at a weight that moves"}function SD(e,t){let n=`blits: reading back to ${t} needs a mix made with history`;if(e.pace!==null)throw new Error(`${n}: the mix's rate has been set`);if(t<e.settled)throw new Error(`${n}: a mix changed or a voice left at ${e.settled}, and without history a mix keeps only how it stands now`);for(let r of e.members)for(let o of r.cued){if(o.state==="done")continue;let i=JY(r,o);if(i!==void 0)throw new Error(`${n}: voice ${o.id} is cued, and ${i}`)}}function kD(e,t,n,r){wc(e,t),t.backward=!0,t.cued=e.cued.filter(o=>o.state!=="done").map(o=>{let i=o.copy(a=>_T(e,o,a,n,r));i.out!==null&&i.out.at>n&&(i.out=null);let s=e.pins?.get(o);return s!==void 0&&Lo(t,i,s),i}),va(t.cued),e.owners!==null&&ya(t.cued),LT(t,n),Bo(t)}function Rm(e,t){let n=e.history!==void 0,r,o;if(typeof t=="number")r=t;else{if(!n)throw new Error("blits: reading a frame back needs a mix made with history");o=km(e,t.frame),r=o.at}let i=o!==void 0?o.seq===e.seq:Number.isNaN(e.now)||r>=e.now,s=e.pace,a={seq:e.seq,strict:!1},l=i?Wr(e,r):Hi(e,r);if(!i&&n){o===void 0&&La(e,r);let m=o??e.frames.at(r);m!==void 0&&(a={seq:m.seq,strict:m.at===r},m.at===r&&(l=m.u))}else i||SD(e,r);let u=new Go(void 0,!0);u.offset=e.offset,u.u=l,u.nextId=e.nextId,u.now=i?e.now:r,u.pace=s===null||!Kt(a,e.pacedSeq)?null:s.until(i?Number.POSITIVE_INFINITY:l),u.announced=(i?e.announced:e.announced.filter(m=>Kt(a,m.seq))).map(m=>({...m}));let c=new Map;for(let m of e.members){let g=new Uo(m.kit,{...m.opts,history:void 0,lanes:!1,transport:u},null);g.slot=m.slot,g.projecting=!0,g.share=m.share,g.places=m.places,c.set(m,g),i?FT(m,g):n?QY(m,g,r,a):kD(m,g,r,a)}let d=u,f=null;i&&r!==e.now&&(f=new Map,d=PD(e,u,c,r,f));let p=!i&&n?a:null,h=m=>{pe.live=!1,pe.ahead=d.ahead.size>0?d.ahead:null,pe.back=p;try{return m()}finally{pe.live=!0,pe.ahead=null,pe.back=null}};return{timestamp:r,of(m){let g=m,b=c.get(g);if(b===void 0)throw new Error("blits: that mix is not on this transport");let x=f?.get(g),w=x===void 0?null:y=>{if(!x.met.has(y)){x.met.add(y);for(let P of x.at)P.fold(y)}};return{timestamp:r,probe:(y,P)=>h(()=>(w?.(y),b.fold(y,P))),assess:y=>h(()=>(w?.(y),b.fold(y),ZY(b,y)))}}}}function QY(e,t,n,r){wc(e,t),t.backward=!0;let o=fc(e.hostLog,{seq:r.seq,strict:!1}),i=e.opts.host,s=o&&typeof i=="object"&&i!==null?Object.assign(Object.create(i),o.fields):void 0;o&&(t.hostThen=o),t.cued=[...e.cued,...e.gone].filter(a=>a.cuedSeq<=r.seq&&!Kt(r,a.doneSeq,!0)).sort((a,l)=>a.id-l.id).map(a=>{let l=a.log,u=a.copy(c=>_T(e,a,c,n,r,t,u),fc(l,r)??l[0]);if(s!==void 0&&(u.setting.host=s),a.parts!==null&&(u.parts=new Map(a.parts)),a.parted!==null&&(u.parted=new Map(a.parted)),a.left!==null&&am(u,a.left.after(r),r.seq),u.parted!==null)for(let[c,d]of u.parted)d.ramp===void 0||!(n<d.at)||(u.parts??=new Map,u.parts.set(c,d.ramp));return u}),va(t.cued),e.owners!==null&&ya(t.cued,r.seq),LT(t,n,r),Bo(t)}function LT(e,t,n){for(let r of e.cued)r.state=r.stateAt(t,n)}function _T(e,t,n,r,o,i,s){let a=t.left?.at(n,o)??xh(t,n,Nm(e,t,n),r,o.seq);if(a===void 0)return;let l=a.snaps&&Ia(a.snaps,r,!0);if(l){let f=Ho(t,l.held);return i!==void 0&&s!==void 0&&!(f.since<=l.at)&&xa(i,s,f),f.from=f.stepped,f.replay=a.inputs,f}let u=i===void 0||s===void 0?a.since:i.sinceOf(s,a.delay),c=Mn(t,a.reaches,a.reaches&&t.patch.state?t.patch.state(n):void 0);c.delay=a.delay,c.since=u,c.shown=i===void 0||s===void 0?a.shown:i.shownOf(s,u);let d=kP(e,t,c,r);return c.rebuilt=t.rebuilds,c.from=c.stepped,c.unknown=t.spec.from==="current"||d,c.replay=a.inputs,c}function ZY(e,t){let n={};for(let i of e.names)n[i]="exact";let r={exact:0,stepped:1,held:2};for(let i of e.cued){let s=i.spec.anchor;if(!(s===void 0||i.state==="done"||!(i.state==="pending"&&!Number.isFinite(i.start)||i.state!=="pending"&&i.state!=="fading"&&(s.out!==void 0||s.end!==void 0)&&!Number.isFinite(i.outAt))||!e.aims(i,t)))for(let l of i.slots)n[e.names[l]]="held"}let o=(i,s)=>{if(i.state==="done"||s.weight<=0)return;let a=eq(e,i,s);for(let l of i.slots){let u=e.names[l];r[a]>r[n[u]]&&(n[u]=a)}};for(let i=e.chain(t);i!==null;i=i.next)i.voice!==null&&o(i.voice,i);for(let i of e.sharers)i.everyone!==null&&i.state!=="pending"&&o(i,i.everyone);return n}function eq(e,t,n){let r=t.spec.weight;if(n.unknown)return"held";let o=n.replay!==void 0&&Ia(n.replay,e.now,!0)!==void 0;if(typeof r=="function"&&r.input&&!o||t.owner!==null&&EO(t))return"held";let i=t.patch.reads;if(i!==void 0&&i.length>0){let s=e.hostThen?.fields;if(s===void 0||!i.every(a=>a in s))return"held"}if(e.now>(n.from??e.now)){let s=vo(e,t)!==void 0,a=n.kept!==null&&n.kept.size>0&&!o&&e.backward;if(t.patch.step&&!s||a)return"stepped"}return n.copied&&n.kept!==null&&n.kept.size>0&&!o?"stepped":"exact"}var Im=class{list=[];from=0;push(t,n){this.list.length>=64&&(this.list=this.list.slice(32),this.from+=32),this.from+this.list.length!==n-1&&(this.list=[],this.from=n-1),this.list.push(t)}patch(t,n,r,o,i){if(!(n>=this.from))return;let s=this.list;for(let a=n-this.from;a<s.length;a++){let l=s[a];if(l==null)return;let u=null,c=t;for(;c!==null&&c.voice.id<l.id;)u=c,c=c.next;let d=c!==null&&c.voice===l?c:null,f=r.linkable(l,o,i);if(f===d)continue;let p=d===null?c:d.next;f!==null&&(f.voice=l,f.next=p);let h=f??p;u===null?t=h:u.next=h}return t}};function vD(e){this.restStamps??=new me;let t=this.linked(e),n=this.linkedLaned,r=this.lanes;if(n&&this.restsLaned()){let s=t.slot;if(!r.owes(s))return r.rests(s)}let o=(this.restStamps.get(e)??Number.NaN)-2*this.restsKey();if(o>=0)return o===1;this.restScratch??=this.pose();let i=this.foldWith(e,this.restScratch,t,n,!0);return this.rests(this.bounded.length===0?i:this.clamp(i))}function AD(e){for(let t=0;t<this.names.length;t++){let n=this.channels[t],r=e[this.names[t]];if(n.rest===void 0){if(r!==void 0)return!1}else if(!rc(r,n.rest))return!1}return!0}function RD(){return this.pace?.stopped(this.u)?this.cued.every(e=>e.state==="done"||e.state!=="pending"&&typeof e.spec.weight!="function"&&e.spec.anchor===void 0):this.cued.every(e=>this.still(e,this.now))}function ND(e,t){if(e.state==="done")return!0;if(e.state!=="frozen"&&e.state!=="live"||typeof e.spec.weight=="function"||e.parts!==null)return!1;let n=this.reducedNow?0:e.fade.in??0;if(n>0&&t-this.sinceOf(e,e.latest)<n)return!1;if(e.state==="frozen"||e.holding!==null)return!0;let r=e.motion;if(r===void 0||!(e.elapsedAt(t)>=e.latest))return!1;let o=e.early;if(o!==null){for(let i of o)if(i.since<=t&&!(i.probed>=i.since))return!1}return r.landed()}function ID(){return this.lanes.whole&&this.bounded.length===0}function ED(){return(this.frame!==this.restsFrame||this.version!==this.restsVersion||this.relinks!==this.restsRelinks||this.stirs!==this.restsStirs)&&(this.restsEpoch++,this.restsFrame=this.frame,this.restsVersion=this.version,this.restsRelinks=this.relinks,this.restsStirs=this.stirs),this.restsEpoch}function MD(e){return{n:0,voices:[],helds:[],deltas:[],weights:[],groups:[],names:[],m:0,mVoices:[],mDeltas:[],mWeights:[],mGroups:[],values:new Array(e).fill(void 0),taken:new Float64Array(e),heaviest:new Float64Array(e),met:new Uint8Array(e),touched:[],owned:new Array(e).fill(void 0)}}function tq(e,t,n,r){let o=e.owned[t];o===void 0&&(o=r.slice(),e.owned[t]=o);for(let i=0;i<o.length;i++)o[i]=i<n.length?n[i]:r[i];return o}function CD(e,t){e.touched.length=0;let n=0;for(let o=0;o<e.m;o++)e.mGroups[o]===t&&(n+=e.mWeights[o]);if(n<=0)return 0;let r=e.taken;for(let o=0;o<e.m;o++){if(e.mGroups[o]!==t)continue;let i=e.mWeights[o];if(i<=0)continue;let s=e.mDeltas[o],a=e.mVoices[o].slots;for(let l=0;l<a.length;l++){let u=a[l],c=s[this.names[u]];if(c===void 0)continue;let d=this.channels[u];if(e.met[u]===0){e.met[u]=1,e.touched.push(u),r[u]=i,e.heaviest[u]=i,e.values[u]=this.lerpsInto[u]!==void 0&&d.scale&&Array.isArray(c)?tq(e,u,c,d.rest):Ci(c);continue}let f=r[u]+i;if(r[u]=f,d.kind==="last"){i>=e.heaviest[u]&&(e.heaviest[u]=i,e.values[u]=Ci(c));continue}let p=e.values[u],h=this.lerpsInto[u];e.values[u]=h!==void 0&&p===e.owned[u]?h(p,p,c,i/f):d.lerp(p,c,i/f)}}for(let o=0;o<e.touched.length;o++)e.met[e.touched[o]]=0;return n>1?1:n}function nq(e,t,n){return e===null?!1:n>=t.length||e.voice===null?!0:t[n].id>e.voice.id}function OD(e,t,n,r,o,i,s){let a=this.now,l=this.roleScratch[this.roleDepth];l===void 0&&(l=MD(this.channels.length),this.roleScratch[this.roleDepth]=l),this.roleDepth++;try{l.n=0,l.m=0,l.names.length=0;let u=this.sharers,c=0,d=n;for(;d!==null||c<u.length;){let p=nq(d,u,c),h,m;if(p?(m=d,h=m.voice,d=m.next):(h=u[c++],m=h.state==="pending"?null:h.everyone),h===null||m===null||r&&h.laned&&!this.owedBy(s,h)||h.id===i||h.state==="done")continue;let g=m;p||this.share.open(h,g,n.slot);let b=this.read(h,e,a,o,g);s>=0&&h.laned&&this.lanes.paid(h.id,s,g.weight),p||(c=this.shared(h,n.slot,g,c));let x=h.spec.role;if(b===null){x===void 0&&!(g.weight>0)&&St(g);continue}let w=-1;if(x!==void 0){w=l.names.indexOf(x);let P=l.m++;if(l.mVoices[P]=h,l.mDeltas[P]=b,l.mWeights[P]=this.w,w>=0){l.mGroups[P]=w;continue}w=l.names.length,l.names.push(x),l.mGroups[P]=w}let y=l.n++;l.voices[y]=h,l.helds[y]=g,l.deltas[y]=b,l.weights[y]=x===void 0?this.w:0,l.groups[y]=w}let f=n.roles;f===null&&(f=new Map,n.roles=f);for(let p=0;p<l.n;p++){let h=l.groups[p];if(h<0){let x=l.weights[p];x>0?this.apply(t,l.voices[p],l.helds[p],l.deltas[p],x):St(l.helds[p]);continue}let m=this.foldRole(l,h),g=l.names[h];if(!(m>0)){f.get(g)?.fill(2);continue}let b=f.get(g);b===void 0&&(b=new Uint8Array(this.channels.length),f.set(g,b));for(let x=0;x<l.touched.length;x++){let w=l.touched[x],y=l.values[w];l.values[w]=void 0;let P=this.names[w],S=this.channels[w],v=l.taken[w],A=v>1?1:v;if(S.rest!==void 0&&S.scale){t[P]=S.fold?S.fold(t[P],y,A):nc(S,t[P],S.scale(y,A));continue}let N=b[w],M=this.passes(N===0?void 0:N===1,A);b[w]=M?1:2,M&&(t[P]=t[P]===void 0?Ci(y):nc(S,t[P],y))}}return t}finally{for(let u=0;u<l.n;u++)l.voices[u]=null,l.helds[u]=null,l.deltas[u]=null;for(let u=0;u<l.m;u++)l.mVoices[u]=null,l.mDeltas[u]=null;for(let u=0;u<l.touched.length;u++){let c=l.touched[u];l.met[c]=0,l.values[c]=void 0}l.touched.length=0,this.roleDepth--}}function FD(e,t){if(e.frame=st(),t===void 0)for(let n of e.cued)n.motion===void 0&&n.holding===null&&(n.seeks++,n.touches++);else{let n=ut(e,t)??null;for(;n!==null;n=n.next)n.seeks=-1;let r=ut(e,t)?.slot??-1;for(let o of e.sharers)e.share?.restamp(o,r)}e.lanes?.refill(),e.stir()}var rq=1e-6,oq=(e,t)=>Math.abs(e-t)<=1e-6*Math.max(1,Math.abs(e),Math.abs(t));function LD(e,t,n,r={}){if(!(t<=n)||!Number.isFinite(t)||!Number.isFinite(n))throw new RangeError(`blits: a trace runs from a time to one no earlier, not ${t} to ${n}`);let o=r.grid??5;if(!(o>0&&o<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a trace's grid is a finite number of ms above 0, not ${o}`);let i=iq(e,t),s=new Map,a=new Map,l=new Map,u=(c,d)=>{let f=a.get(c);f===void 0&&(f=new Map,a.set(c,f));let p=f.get(d);if(p===void 0){let h=s.get(d);h===void 0&&(h=e.project(d),s.set(d,h)),p=h.probe(c,e.pose()),f.set(d,p)}return p};return{from:t,to:n,of(c,d){let f=d,p=e.slotOf.get(f);if(p===void 0)throw new Error(`blits: the mix has no channel ${f}`);let h=N=>{let M=u(c,N)[f];return typeof M=="number"?M:Number.NaN},m=l.get(c);m===void 0&&(m=sq(e,c,t,n),l.set(c,m));let g=e.scalars[p],b=i&&!m.unknown.has(p)&&!e.bounded.includes(p)&&(g==="sum"||g==="mul"&&(m.writers.get(p)??0)<=1),x=m.bent.get(p),w=(N,M)=>b&&(x===void 0||x.every(([C,F])=>!(C<M&&F>N)));if(t===n)return{at:[t],value:[h(t)],exact:b};let y=[],P=[],S=!0,v=(N,M)=>{let C=y.length;C>0&&y[C-1]===N&&oq(P[C-1],M)?P[C-1]=M:(y.push(N),P.push(M))},A=[t,...m.knots.get(p)??[],n];for(let N=0;N+1<A.length;N++){let M=A[N],C=A[N+1];if(w(M,C)){let B=M+(C-M)/3,D=C-(C-M)/3,j=h(B),V=(h(D)-j)/(D-B);v(M,j-V*(B-M)),v(C,j+V*(C-B));continue}S=!1;let F=Math.min(rq,(C-M)/4);v(M,h(M===t?M:M+F));for(let B=Math.max(0,Math.ceil((M-t)/o));;B++){let D=t+B*o;if(D>=C-F)break;D>M+F&&v(D,h(D))}v(C,h(C===n?C:C-F))}return{at:y,value:P,exact:S}}}}function iq(e,t){let n=e.transport;if(!(t>=e.now))return!1;let r=n.tape;return r===void 0||r.timestampAt(r.undoDepth())===void 0}function sq(e,t,n,r){let o={knots:new Map,bent:new Map,unknown:new Set,writers:new Map};for(let i of e.cued)if(!(i.state==="done"||!e.aims(i,t))&&!lq(e,i,t,n,r,o))for(let s of i.slots)o.unknown.add(s);for(let[i,s]of o.knots)o.knots.set(i,s.sort((a,l)=>a-l).filter((a,l,u)=>l===0||a!==u[l-1]));return o}var aq=4096;function lq(e,t,n,r,o,i){let s=t.spec,a=t.built,l=t.patch;if(l.form!=="keys"||a===null||l.step!==void 0||typeof s.weight=="function"||t.owner!==null||t.holding!==null||t.fitting!==null||t.arc!==null||t.blend!==null||s.anchor!==void 0||s.role!==void 0||s.within!==void 0||s.stepMs!==void 0||s.from!==void 0||t.ramp!==null||!(t.rate>0)||t.out!==null||t.back!==null||t.stalls!==null||t.parts!==null||t.parted!==null||t.left!==null||Number.isFinite(t.outAt)||t.state==="fading"||t.state==="pending"&&e.transport.pace!==null)return!1;let u=[],c=[],d=new Map,f=P=>{P>r&&P<o&&u.push(P)},p=e.reduced,h=t.sharing?void 0:t.subjects.get(n),m=h?.delay??(s.stagger?s.stagger(n):0),g=P=>t.timeAt(P+m),b=p?0:t.fade.in??0;if(b>0){if(h===void 0)return!1;h.shown+b>r&&(c.push([h.shown,h.shown+b]),f(h.shown),f(h.shown+b))}let x=t.duration,w=t.span;f(t.start),f(g(0)),Number.isFinite(w)&&f(g(w));let y=t.endsAt();if(f(y),!t.freezesAfter&&Number.isFinite(y)){let P=p?0:Number.isNaN(t.outOver)?t.fade.out??0:t.outOver,S=Math.max(t.start,y);f(S),P>0&&(c.push([S,S+P]),f(S+P)),s.stagger!==void 0&&c.push([g(w),Number.POSITIVE_INFINITY])}if(x>0){let P=Math.max(0,Math.floor((t.elapsedAt(r)-m)/x)),S=Math.min(Math.ceil(t.passes)-1,Math.floor((t.elapsedAt(o)-m)/x)),v=0;for(let A of a.tracks)v+=A.all.length+1;if((S-P+1)*v>aq)return!1;for(let A=P;A<=S;A++){let N=A*x;f(g(N)),f(g(N+x));for(let M of a.tracks){let C=e.slotOf.get(M.channel);if(M.numbers===null)return!1;let F=M.delay;if(F>=x)continue;F>0&&f(g(N+F));let B=Number.NaN;for(let D of M.all){let j=g(N+F+Math.min(1,Math.max(0,D.at))*(x-F));if(f(j),!Number.isNaN(B)&&!W2(D.ease)){let V=d.get(C);V===void 0?d.set(C,[[B,j]]):V.push([B,j])}B=j}}}}for(let P of t.slots){let S=i.knots.get(P);S===void 0?i.knots.set(P,[...u]):S.push(...u),i.writers.set(P,(i.writers.get(P)??0)+1);let v=[...c,...d.get(P)??[]];if(v.length===0)continue;let A=i.bent.get(P);A===void 0?i.bent.set(P,v):A.push(...v)}return!0}function _D(e,t){let n=this.primed[0],r=this.primed[1],o=this.primed[2],i=e.setting;i.timestamp=n,e.patch.step===void 0&&t.probed<n&&(t.stepped=t.probed),i.dt=this.capped(n-t.stepped),i.elapsed=r,i.pass=o,i.weight=0,i.state=t.state,i.mark=0,e.keepOn=t}function DD(e,t,n){let r=this.now,o=e.setting;o.mark!==n[6]&&uq(o,r,n),e.patch.step===void 0&&t.probed<r&&(t.stepped=t.probed),o.dt=this.capped(r-t.stepped),o.weight=0,o.state=t.state,e.keepOn=t}function uq(e,t,n){e.timestamp=t,e.elapsed=n[1],e.pass=n[3],e.mark=n[6]}function BD(e){let t=this.opts.maxDt;return this.reducedNow?Number.POSITIVE_INFINITY:t!==void 0&&e>t?t:e}function HD(e,t,n){let r=this.opts.history;return r===void 0?Number.POSITIVE_INFINITY:tT(this,e,n-r.ms)-t}function GD(e,t,n){return la(e.fade.in??0,e.out,e.ease,this.reducedNow,t,n,e.back,e.stalls)}function UD(e,t){return MO(e,this.now,this.reducedNow,n=>this.ownerBase(n,t))}function VD(e,t){let n=this.now,r=this.held(e,t,-1);if(r.probed===this.frame)return r.phase;let o=pe.kept;r.probed=Number.NaN;let i=this.primed;i[0]=n,i[1]=e.elapsedAt(n),i[2]=0,this.prime(e,r);let s=this.base(e,t,n,r);return pe.kept=o,r.stepped=n,r.probed=this.frame,r.phase=s,s}function WD(e,t,n,r){if(e.owner!==null)return this.weighOwned(e,t,n,r);let o=this.base(e,t,n,r),i=this.envelope(e,n,r.shown);return zt(o,i,e.parts===null?1:this.parting(e,t,n))}function zD(e,t,n,r){let o=this.ownedBy(e,t),i=this.base(e,t,n,r),s=this.envelope(e,n,r.shown)*o;return zt(i,s,e.parts===null?1:this.parting(e,t,n))}function KD(e,t,n,r,o=-1){this.sending.voice=e,this.sending.subject=t;let i=typeof e.spec.weight=="function"?e.spec.weight:null;if(i===null)return e.weight;let s=r.replay&&Ia(r.replay,n,!0),a=s?s.value:e.blend===null?i(t,e.setting):this.blended(e,t,r,o);return i.input&&!s&&om(this,e,t,r,a),a}var cq={lanes:!0},Uo=class{kit;opts;lanesOf;cued=[];gone=[];goneIx=new Dh;scored=new vh;projecting=!1;backward=!1;moving=!1;looked=!1;hostLog=[];hostThen;lastPoses=new me;transport;slot=-1;dropped=!1;name;frame=st();pins=null;wantsPose=!1;scratch;due=new wh;retired=[];walkAll=!1;leapt=null;pulled=[];pulledHeads=[];pulledSlots=new Int32Array(0);pulledVersion=Number.NaN;pulledRelinks=-1;pullColumns=null;relinks=0;reducedNow=!1;stirred=!1;asleep=!1;waking=!1;stirs=0;syncing=!1;stirFns=null;stir(){if(this.stirs++,this.moving||this.transport.settle(),this.stirred||(this.stirred=!0,this.syncing))return;let t=this.stirFns;if(t!==null)for(let n of[...t])n();this.transport.woke()}onWake(t){this.stirFns===null&&(this.stirFns=[]);let n=this.stirFns;return n.push(t),()=>{let r=n.indexOf(t);r>=0&&n.splice(r,1)}}chains=new me;version=0;places=null;primed=new Float64Array(3);steps=new Im;named=new me;parters=new Set;departed=new Uh;strays=new me;strayAll=new Set;playing=new Map;naming=0;general=[];sharers=[];unshared=!1;detours=0;roleVoices=0;roleTags;owner=null;anchored=0;sent=[];sending={voice:null,subject:void 0};send=t=>{let{voice:n,subject:r}=this.sending;n===null||this.projecting||n.setting.timestamp<=this.sentTo||this.sent.push({timestamp:n.setting.timestamp,subject:r,voice:n.id,tags:n.spec.tags??dn,event:t})};sentTo=Number.NEGATIVE_INFINITY;w=0;names;channels;bounded;lerpsInto;scalars;roleScratch=[];roleDepth=0;slotOf=new Map;lanes;share;handles=null;bookers=null;fitting=null;arcing=null;owners=null;keys=null;outs=null;pose;constructor(t,n,r){if(this.kit=t,this.opts=n,this.lanesOf=r,this.names=Object.keys(t),this.channels=this.names.map(i=>t[i]),this.bounded=this.channels.flatMap((i,s)=>i.bounds?[s]:[]),this.lerpsInto=this.channels.map(i=>fh(i)),this.pose=_L(this.names,this.channels),this.scalars=this.channels.map(i=>v2(i)),this.names.forEach((i,s)=>{this.slotOf.set(i,s)}),r===null&&n.lanes===!0)throw new Error("blits: '@msb235/blits/lean' has no lanes; take mix from '@msb235/blits'");this.share=r?.share??null,this.lanes=r!==null&&(n.lanes??cq.lanes)?new r(zh(this)):null,this.name=n.name,this.roleTags=oL(n);let o=n.transport;if(o!==void 0){if(n.history!==void 0)throw new Error("blits: a mix on a transport keeps the history the transport keeps, not its own");this.opts={...n,history:o.history},this.transport=o}else this.transport=new Go(n.history,!1);this.transport.pager!==null&&(this.keys=new kh(n.keyOf),this.outs=new nm,o!==void 0&&fq(o,n.name)),this.transport.join(this)}own(t){if(this.transport.shared)throw new Error(`blits: ${this.name??"this mix"} plays on a transport, so ${t} goes to the transport`);return this.transport}get now(){return this.transport.now}set now(t){this.transport.now=t}get u(){return this.transport.u}set u(t){this.transport.u=t}get offset(){return this.transport.offset}set offset(t){this.transport.offset=t}get pace(){return this.transport.pace}set pace(t){this.transport.pace=t}get announced(){return this.transport.announced}set announced(t){this.transport.announced=t}get nextId(){return this.transport.nextId}set nextId(t){this.transport.nextId=t}get timestamp(){return this.transport.last}get seq(){return this.transport.seq}get last(){return this.transport.last}get tape(){return this.transport.tape}get replaying(){return this.transport.replaying}get reduced(){let t=this.opts.reduce;return typeof t=="function"?t():t===!0}get band(){return this.opts.band??w2}cue(t){this.attached();let n=this.opts.engine;if(n!==void 0&&!n.runs.has(t.patch.form))throw new Error(`blits: engine ${n.name} does not run ${t.patch.form} patches`);return rL(this,t)}blend(t,n,r={}){let o=`blend:${this.nextId}`,i=tc(n,t.length-1);return t.map((s,a)=>{let l={...r,patch:s,weight:n,role:o};"patch"in s&&(l.patch=s.patch,s.name!==void 0&&(l.name=s.name),s.tags!==void 0&&(l.tags=s.tags),s.hits!==void 0&&(l.hits=s.hits));let u=this.cue(l),c=this.cued[this.cued.length-1];return c.blend={of:i,i:a},i.members.push(c),u})}owns(t){if(t.loop!==void 0)throw new Error("blits: an owner does not loop: a pass would have to restart its children");return this.cue({...t,patch:Li})}span(t){if((t.rate??1)<0)throw new Error("blits: a span lays out its children forward from its start, so it is not cued backward");this.fitting=new rm(t);try{let n=this.owns(t);return Ln(this,this.owners?.find(r=>r.handle===n)),n}finally{this.fitting=null}}arc(t){return LL(this,t)}sync(t){this.own("sync").sync(t)}book(t){return gF(this,t)}probe(t,n){this.looked=!0;let r=this.fold(t,n);return this.keep(t,r,n),this.restStamps!==null&&!(this.linkedLaned&&this.restsLaned())&&this.restStamps.set(t,2*this.restsKey()+(this.rests(r)?1:0)),r}pull(t,n){this.looked=!0,e_(this,t,n)}seek(t){if(this.projecting)throw new Error("blits: a projection does not seek");_a(this.own("seek"),t)}prepare(t){return this.own("prepare").prepare(t)}project(t){return Rm(this.transport,t).of(this)}trace(t,n,r){return LD(this,t,n,r)}announce(t,n={}){this.attached(),OT(this.transport,t,n,this.slot,this.name)}attached(){if(this.dropped)throw new Error(`blits: ${this.name??"this mix"} was dropped from its transport`)}marks(t,n){return Hh(this,t,n).map(({order:r,...o})=>o)}rebase(){this.own("rebase").rebase()}voices(t){let n=[];for(let r of this.cued)r.state!=="done"&&(t===void 0||r.spec.tags?.includes(t))&&n.push(r.handle);return n}get live(){return this.cued.some(t=>t.state!=="done")}get inert(){if(this.stirred)return!1;let t=this.restful();return t&&!Number.isNaN(this.now)&&(this.asleep=!0),t}get rate(){return this.transport.rate}set rate(t){this.own("rate").ramp(t,0)}ramp(t,n){this.own("ramp").ramp(t,n)}close(){mD(this)}mute(t){for(let n of this.cued)n.written=!0,Kr(this,n,{over:t?.over});Ct(this,"mute",n=>n.mix(this)?.mute(t))}touch(t){this.attached(),FD(this,t)}drain(t){let n=this.sent;if(n.length===0)return[];let r=n;if(t===void 0)this.sent=[];else{r=[];let o=[];for(let i of n)(i.tags.includes(t)?r:o).push(i);this.sent=o}return r.sort((o,i)=>o.timestamp-i.timestamp)}folding=new Set;linkedLaned=!1;restStamps=null;restsEpoch=0;restsFrame=Number.NaN;restsVersion=Number.NaN;restsRelinks=-1;restsStirs=-1;restScratch},dq={fold:CF,folded:OF,linked:FF,foldWith:LF,owedBy:BF,foldRoles:OD,foldDetour:_F,foldSharers:DF,shared:MF,read:YL,contribution:UL,keyed:VL,tick:zL,apply:IF,clamp:EF,passes:NF,isRest:$L,baseFor:KL,slopeFor:jL,prime:_D,primeLaned:DD,capped:BD,horizonFor:HD,weigh:WD,weighOwned:zD,base:KD,envelope:GD,ownedBy:UD,ownerBase:VD,blended:TF,laneRead:SF,shareKept:kF,parting:EL,chain:Y2,relink:q2,linkable:X2,aims:J2,held:BO,unreachedOf:DO,sinceOf:HO,shownOf:GO,keep:ZL,foldRole:CD,atRest:vD,rests:AD,restful:RD,still:ND,restsLaned:ID,restsKey:ED,plot:tD,place:nD,moved:oD,put:iD,around:RF,drop:qL,forgetIn:XL,releaseIn:JL,recordDrop:QL};for(let[e,t]of Object.entries(dq))Object.defineProperty(Uo.prototype,e,{value:t,writable:!0,configurable:!0});function fq(e,t){if(t===void 0)throw new Error("blits: a mix on a transport whose history has a store needs a name, which its records are keyed by");if([...e.members,...e.dropped.map(r=>r.mix)].some(r=>r.name===t))throw new Error(`blits: a mix named ${t} is already on this transport, or a seek could bring it back`)}function pq(e,t,n){let{history:r,added:o}=fD(t),i=new Uo(e,o?{...t,history:r}:t,n);return o&&pD(i.transport),hD(i),i}var jD={name:"mixer",runs:new Set(["fn","keys","motion"]),create(e,t){return pq(e,t,yc)}};function DT(e,t={}){return(t.engine??jD).create(e,t)}function Em(e,t,n){for(let r=t;r!=null;r=n(r))if(e.has(r))return r;return null}function Pc(e,t){if(e.length<2)return e;let n=new Set(e),r=o=>{let i=t(o);return i!=null&&Em(n,i,t)!==null};return e.some(r)?e.filter(o=>!r(o)):e}ee();var Da={getBounds:e=>et(e),remapBounds:(e,t,n)=>At(e,dr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height)),fromBounds:e=>({kind:"rect",x:e.x,y:e.y,width:e.width,height:e.height}),translate:(e,t,n)=>yg(e,t,n),lerp:(e,t,n)=>{if(e.kind==="rect"&&t.kind==="rect")return{kind:"rect",x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,width:e.width+(t.width-e.width)*n,height:e.height+(t.height-e.height)*n};if(e.kind==="polygon"&&t.kind==="polygon"&&e.coords.length===t.coords.length){let r=$e(e),o=$e(t),i=new Float64Array(r.length);for(let c=0;c<r.length;c++)i[c]=r[c]+(o[c]-r[c])*n;let s=vt(e.origin,i),{corners:a,...l}=e,u=qy(e.corners,t.corners,n);return u?{...l,coords:s,corners:u}:{...l,coords:s}}throw new Error("pathPoseDescriptor.lerp: incompatible path shapes")},axes:e=>e.kind==="rect"?{count:4,names:["x","y","width","height"],to:t=>t.kind==="rect"?[t.x,t.y,t.width,t.height]:[],from:t=>({kind:"rect",x:t[0],y:t[1],width:t[2],height:t[3]}),add:(t,n)=>t.kind!=="rect"?t:{kind:"rect",x:t.x+n[0],y:t.y+n[1],width:t.width+n[2],height:t.height+n[3]},write:(t,n,r)=>{t.kind==="rect"&&(n[r]=t.x,n[r+1]=t.y,n[r+2]=t.width,n[r+3]=t.height)}}:{count:e.coords.length,to:t=>t.kind==="polygon"?Array.from($e(t)):[],from:t=>({...e,coords:vt(e.origin,t)}),add:(t,n)=>{if(t.kind!=="polygon")return t;let r=Float64Array.from($e(t));for(let o=0;o<r.length;o++)r[o]+=n[o];return{...e,coords:vt(e.origin,r)}},write:(t,n,r)=>{if(t.kind!=="polygon")return;let o=$e(t);for(let i=0;i<o.length;i++)n[r+i]=o[i]}},supportsRotation:()=>!1};function rr(e){return!!e&&typeof e=="object"&&"kind"in e&&(e.kind==="polygon"||e.kind==="rect")}function Ba(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"}var Vo={getBounds:e=>rr(e)?Da.getBounds(e):Et.getBounds(e),remapBounds:(e,t,n)=>rr(e)?Da.remapBounds(e,t,n):Et.remapBounds(e,t,n),fromBounds:(e,t)=>rr(t)?Da.fromBounds(e,t):Et.fromBounds(e,t),translate:(e,t,n)=>rr(e)?Da.translate(e,t,n):Et.translate(e,t,n),axes:e=>Ba(e)?Et.axes(e):rr(e)?Da.axes(e):null,getRotation:e=>{if(rr(e))return 0;let t=e.rotation;return typeof t=="number"?t:0},supportsRotation:e=>!rr(e),withRotation:(e,t)=>rr(e)?e:{...e,rotation:t}};function $D(e){return t=>sa(e,t)}function YD(e,t){let n=$D(e);return(r,o,i,s)=>{let a=s?.inherited??n(r);return a===void 0?t(r,o,i,s):t(r,o,i,{...s,inherited:a})}}function qD(e,t){let n=$D(e);return(r,o,i,s)=>{let a=s?.inherited??n(r);return t(r,o,i,a===void 0?s:{...s,inherited:a})}}ee();function BT(e,t){switch(e){case"union":return Uf(...t);case"intersect":return lx(...t);case"exclude":return cx(...t);case"subtract":{let n=t.length===2?t[1]:Uf(...t.slice(1));return ux(t[0],n)}}}var HT="kit:booleanOfChildren",mq=new Set(["union","intersect","subtract","exclude"]);function XD(e){let t=e?.boolean;return typeof t=="string"&&mq.has(t)?t:"union"}var JD=e=>e.path;function QD(e){JD=e}function yq(e){if(e.node.kind!=="group")return JD(e);let t=ZD(e.children??[]);return t.length<=1?t[0]??null:BT("union",t)}function ZD(e){let t=[];for(let n of e){if(n===void 0||n.node.hidden===!0)continue;let r=yq(n);r!==null&&t.push(r)}return t}function GT(e,t){let n=ZD(t);if(n.length===0)return null;let r=XD(e.data);return n.length===1&&r!=="subtract"?n[0]:BT(r,n)}ee();var Ha="shape:paint";function Mm(e){return(e.dependsOn?.length??0)>0&&e.derivePath!==void 0}ee();Pe();Pe();ee();Ru.subscribe(Hu);function or(e,t){if(e===null)return{outset:0,inset:0};let n=su(e),r=(l,u)=>{switch(e.align??"center"){case"inner":return{outset:u,inset:l};case"outer":return{outset:l+u,inset:0};default:return{outset:l/2+u,inset:l/2}}},o=e.width??1,i=hi(typeof o=="object"?0:at(o,t??1),e.vertexWidths),s=r(i,n.world);if(typeof o!="object"&&!(n.px>0))return s;let a=r(typeof o=="object"?o.px:0,n.px);return{outset:s.outset,inset:s.inset,outsetPx:a.outset,insetPx:a.inset}}function gq(e,t){let n=or(e,t);return n.outset+(n.outsetPx??0)/(t>0?t:1)}function Cm(e,t){let n=t?.scale??1,r=t?.screen;if(!r){let d=gq(e,n);return{x:d,y:d}}let o=or(e,n),i=o.outsetPx??0;if(i===0)return{x:o.outset,y:o.outset};let[s,a,l,u]=r,c=Math.abs(s*u-a*l);return c>0?{x:o.outset+i*Math.hypot(l,u)/c,y:o.outset+i*Math.hypot(s,a)/c}:{x:o.outset,y:o.outset}}function Ga(e,t){let n=t?.vertexColors,r=e[0];if(n===void 0||r?.kind!=="path")return e;let o=4*gg(r.path),i=r.fill?n("fill",r.vertexColors):void 0,s=r.stroke?n("stroke",r.stroke.vertexColors):void 0,a=i?.length===o&&i!==r.vertexColors,l=s?.length===o&&s!==r.stroke?.vertexColors;return!a&&!l?e:[{...r,...a?{vertexColors:i}:{},...l?{stroke:{...r.stroke,vertexColors:s}}:{}},...e.slice(1)]}function UT(e,t){let n=Re(e.stroke,t?.stroke),r=Ne(e.fill,t?.fill);return n!==null?{fill:r,stroke:n}:{fill:r}}function WT(e,t,n,r){let{sized:o,spaces:i}=r?xq(e,t,r):bq(t,n),s=at(o.width??1,1);if(!(s>0))return null;let a=new VT,l=t.align??"center";if(l!=="inner"){let u=l==="outer"?2:1,c=_s(o,s),d=mi(e,{...o,width:s*u,align:"center",vertexWidths:t.vertexWidths?.map(m=>Fl(m,u))},{startInset:eB(c.start,i.start,i.ribbon),endInset:eB(c.end,i.end,i.ribbon),...i.ribbon?{metric:i.ribbon.metric}:{}}),f=d.vertices,p=d.origin?.x??0,h=d.origin?.y??0;for(let m=0;m+1<f.length;m+=2)a.add(f[m]+p,f[m+1]+h,0)}for(let{entry:u,path:c,size:d}of iu(e,o,s,void 0,i)){let f=et(c),p=u.outline?u.outline.width*d/2:0;a.add(f.x,f.y,p),a.add(f.x+f.width,f.y+f.height,p)}return a.bounds()}function bq(e,t){return{sized:{...e,width:at(e.width??1,t)},spaces:{}}}function xq(e,t,[n,r,o,i]){let s=new Float32Array([n,r,0,o,i,0,0,0,1]),{cmd:a,spaces:l}=Nu(s,{kind:"path",path:e,stroke:t});return{sized:a.stroke,spaces:l}}function eB(e,t,n){return t?.metric===n?.metric?e:{length:e,metric:t?.metric??null}}var VT=class{x0=1/0;y0=1/0;x1=-1/0;y1=-1/0;add(t,n,r){this.x0=Math.min(this.x0,t-r),this.y0=Math.min(this.y0,n-r),this.x1=Math.max(this.x1,t+r),this.y1=Math.max(this.y1,n+r)}bounds(){return this.x0===1/0?null:{x:this.x0,y:this.y0,width:this.x1-this.x0,height:this.y1-this.y0}}},wq="shape:drawn";function tB(e,t,n){let r=nB(e);if(!t)return r;let o=Cm(t,n);return{x:r.x-o.x,y:r.y-o.y,width:r.width+2*o.x,height:r.height+2*o.y}}function Om(e,t,n,r,o){let i=nB(t);if(n===null)return i;let s=r?.scale??1,a=r?.screen,l=rt(e,wq,void 0,()=>({width:NaN,height:NaN,scale:NaN,screen:void 0,box:null}));if(l.width!==t.width||l.height!==t.height||l.scale!==s||!Pq(l.screen,a)){let p={x:0,y:0,width:t.width,height:t.height};l.width=t.width,l.height=t.height,l.scale=s,l.screen=a,l.box=WT(o(p),n,s,a)}if(l.box===null)return i;let u=Math.min(i.x,t.x+l.box.x),c=Math.min(i.y,t.y+l.box.y),d=Math.max(i.x+i.width,t.x+l.box.x+l.box.width),f=Math.max(i.y+i.height,t.y+l.box.y+l.box.height);return{x:u,y:c,width:d-u,height:f-c}}function Pq(e,t){return e===t?!0:!!e&&!!t&&e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function nB(e){return{x:Math.min(e.x,e.x+e.width),y:Math.min(e.y,e.y+e.height),width:Math.abs(e.width),height:Math.abs(e.height)}}Pe();function rB(e,t,n,r){let o=et(e),i=t&&Ut(t,o),s=n&&Ri(n,o);return{kind:"path",path:e,...i?{fill:i}:{},...i&&r?{vertexColors:r}:{},...s?{stroke:s}:{}}}function zT(e,t){let n=t?.derivedPath,r=Re(e.data?.stroke,t?.inherited?.stroke);return n==null||r===null?null:WT(n,r,t?.scale??1,t?.screen)}function Tq(e,t,n){let{fill:r,stroke:o}=jC(e,t,n);return rB(e.path,r,o,void 0)}var Fm={id:"kit:derived",matches:Mm,paint:(e,t,n)=>{let r=n?.derivedPath;if(r==null)return[];let o=e.data,i=th(r);if(i!==void 0)return i.map(l=>Tq(l,o,n?.inherited));let s=Re(o?.stroke,n?.inherited?.stroke),a=Ne(o?.fill,n?.inherited?.fill);return Ga([rB(r,a,s,o?.vertexColors)],n)},silhouette:(e,t,n)=>n?.derivedPath??null,drawnBounds:(e,t,n)=>zT(e,n),ink:(e,t,n)=>{let r=e.data,o=Re(r?.stroke,n?.inherited?.stroke);return{filled:Ne(r?.fill,n?.inherited?.fill)!==null,...or(o,n?.scale)}}};ee();function Ft(e){return e===void 0||Ba(e)}function Wo(e,t,n){if(!Ba(e))return null;let r=t?Ks(t,n?.scale??1,n?.leastScale):0,o=Math.min(e.x,e.x+e.width),i=Math.min(e.y,e.y+e.height);return{x:o-r,y:i-r,width:Math.abs(e.width)+2*r,height:Math.abs(e.height)+2*r}}function Sq(e,t){return{x:e.x*t.width,y:e.y*t.height,w:e.width*t.width,h:e.height*t.height}}function kq(e,t,n){if(n&&n>0)return{width:Math.abs(e.width)*n/(t?.width||1),height:Math.abs(e.height)*n/(t?.height||1)}}var oB={id:"kit:image",snapsToBox:!0,matches:e=>{if(!Ft(e.pose))return!1;let t=e.data?.image?.src;return typeof t=="string"&&t.length>0},paint:(e,t,n)=>{let r=e.data,o=t,i=n?.resolveImage?n.resolveImage(e):Xs(r.image.src,kq(o,r.image.source,n?.pixelScale));if(i)return[{kind:"image",image:i,x:o.x,y:o.y,w:o.width,h:o.height,...r.image.opacity!==void 0?{opacity:r.image.opacity}:{},...r.image.source?{source:Sq(r.image.source,i)}:{},...r.image.flipX?{flipX:!0}:{},...r.image.flipY?{flipY:!0}:{}}];let s=n?.resolveImage?!1:C0(r.image.src)==="error",a=s?"#d08a8a":"#bbbbbb",l=[{kind:"path",path:{kind:"rect",x:o.x,y:o.y,width:o.width,height:o.height},stroke:{paint:{color:a},width:1}}];return s&&l.push({kind:"path",path:jy({x:o.x,y:o.y},{x:o.x+o.width,y:o.y+o.height}),stroke:{paint:{color:a},width:1}}),l},silhouette:(e,t)=>{let n=t;return{kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height}},bounds:(e,t,n)=>Wo(t,vq,n)},vq={paint:{color:"#000"},width:1};ee();var iB={cut:{paint:{color:"#e23b3b"},width:1,dash:[6,4]},connector:{paint:{color:"#7ba7c7"},width:2,dash:[4,4]},falloff:{paint:{color:"rgba(52, 120, 246, 0.28)"},width:10,cap:"round",join:"round"},measure:{paint:{color:"#1f8fff"},width:1},lock:{paint:{color:"#d9480f"},width:1.5},target:{paint:{color:"#1f8fff"},width:1.5,dash:[5,3]},insert:{paint:{color:"#1f8fff"},width:3,cap:"round"},refused:{paint:{color:"#ff5d5d"},width:3,cap:"round"}};function KT(e){let t=e?.data?.measure;return!t||typeof t!="object"||!t.start||!t.end?null:t}var Aq=5;function Rq(e,t,n){let r={...iB.measure,width:{px:1}},o=Math.hypot(t.x-e.x,t.y-e.y),i=o>0?-(t.y-e.y)/o:0,s=o>0?(t.x-e.x)/o:1,a=Aq*n,l=c=>({kind:"path",path:cd([{x:c.x-i*a,y:c.y-s*a},{x:c.x+i*a,y:c.y+s*a}]),stroke:r}),u=[l(e),l(t)];return o>0&&u.unshift({kind:"path",path:cd([e,t]),stroke:r}),u}var sB={id:"kit:measure",matches:e=>Ft(e.pose)&&KT(e)!==null,paint:(e,t,n)=>{let r=KT(e);if(!r)return[];let o=globalThis.devicePixelRatio||1;return Rq(r.start,r.end,o/(n?.pixelScale??o))}};ee();Pe();var aB={id:"kit:path",matches:e=>Ft(e.pose)?e.data?.path!=null:!1,paint:(e,t,n)=>n?.derivedPath!=null?Fm.paint(e,t,n):Ga(rt(e,Ha,t,()=>{let r=e.data,o=Tl(r.path,t),{fill:i,stroke:s}=UT(r,n?.inherited),a=i&&Ut(i,t),l=s&&Ri(s,t);return[{kind:"path",path:o,...a?{fill:a}:{},...a&&r.vertexColors?{vertexColors:r.vertexColors}:{},...l?{stroke:l}:{}}]},n?.inherited),n),silhouette:(e,t,n)=>{if(n?.derivedPath!=null)return n.derivedPath;let r=e.data;return Tl(r.path,t)},ink:(e,t,n)=>{let{fill:r,stroke:o}=UT(e.data,n?.inherited);return{filled:r!==null,...or(o??null,n?.scale)}},bounds:(e,t,n)=>Wo(t,Re(e.data.stroke,n?.inherited?.stroke),n),drawnBounds:(e,t,n)=>{if(n?.derivedPath!=null)return zT(e,n);let r=e.data;return Om(e,t,Re(r.stroke,n?.inherited?.stroke),n,o=>Tl(r.path,o))}};Pe();var lB={id:"kit:rect-fallback",matches:e=>e.kind!=="group"&&Ft(e.pose),paint:(e,t,n)=>{let r=e.data,o=t,i=Ne(r?.fill,n?.inherited?.fill),s=i&&Ut(i,o);return[{kind:"path",path:{kind:"rect",x:o.x,y:o.y,width:o.width,height:o.height},...s?{fill:s}:{}}]},silhouette:(e,t)=>{let n=t;return{kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height}},bounds:(e,t)=>Wo(t,null,void 0)};ee();Pe();var uB={id:"kit:shape",matches:e=>{if(!Ft(e.pose))return!1;let t=e.data?.shape;return t!=null&&Nq.has(t)},paint:(e,t,n)=>Ga(rt(e,Ha,t,()=>{let r=e.data,o=jT(r,t),i=Ne(r.fill,n?.inherited?.fill),s=i&&Ut(i,t),a=Re(r.stroke,n?.inherited?.stroke),l=a&&Ri(a,t);return[{kind:"path",path:o,...s?{fill:s}:{},...l?{stroke:l}:{}}]},n?.inherited),n),silhouette:(e,t)=>{let n=e.data;return jT(n,t)},ink:(e,t,n)=>{let r=e.data;return{filled:Ne(r.fill,n?.inherited?.fill)!==null,...or(Re(r.stroke,n?.inherited?.stroke),n?.scale)}},bounds:(e,t,n)=>Wo(t,Re(e.data.stroke,n?.inherited?.stroke),n),drawnBounds:(e,t,n)=>{let r=e.data,o=Re(r.stroke,n?.inherited?.stroke);return r.shape==="polygon"||r.shape==="star"?Om(e,t,o,n,i=>jT(r,i)):tB(t,o,n)}},Nq=new Set(["rect","ellipse","polygon","star"]);function jT(e,t){switch(e.shape){case"ellipse":return Wy(t);case"polygon":{let n=t.x+t.width/2,r=t.y+t.height/2,o=Math.min(t.width,t.height)/2;return zy({x:n,y:r},o,e.sides??6)}case"star":{let n=t.x+t.width/2,r=t.y+t.height/2,o=Math.min(t.width,t.height)/2;return Ky({x:n,y:r},o,e.points??5)}default:return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height}}}ee();Pe();function Iq(e,t){return{kind:"group",clip:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height},children:[e]}}function Eq(e,t){let n=Math.max(0,e.padding??0),r=Math.min(n,t.width/2),o=Math.min(n,t.height/2);return{x:t.x+r,y:t.y+o,width:t.width-2*r,height:t.height-2*o}}function $T(e,t,n){return{...Eq(e,t),text:e.text,runs:e.runs,style:e.style,fill:e.fill===nn?Ne(e.fill,n?.fill):e.fill,stroke:Re(e.stroke,n?.stroke)??void 0,verticalAlign:e.verticalAlign}}var YT={id:"kit:text",snapsToBox:!0,matches:e=>Ft(e.pose)?e.data?.text!=null:!1,paint:(e,t,n)=>rt(e,Ha,t,()=>{let r=e.data,o=vw($T(r,t,n?.inherited)),i=r.overflow==="clip"?Iq(o,t):o,s=Ne(r.background);if(!s)return[i];let a=Ut(s,t);return[{kind:"path",path:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height},...a?{fill:a}:{}},i]},n?.inherited),silhouette:(e,t)=>{let n=e.data;if(Ne(n.background))return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height};let r=mp($T(n,t)),o=n.overflow==="clip"?Mq(r,t):r;return o.length===0?null:Oq(o)},ink:(e,t,n)=>{let r=e.data;return{filled:!0,...or(Re(r.stroke,n?.inherited?.stroke),n?.scale)}},drawnBounds:(e,t,n)=>{let r=e.data,o=Re(r.stroke,n?.inherited?.stroke);return o?Cq(t,mp($T(r,t,n?.inherited)),Cm(o,n)):null}};function Mq(e,t){let n=[];for(let r of e){let o=Math.max(r.x,t.x),i=Math.max(r.y,t.y),s=Math.min(r.x+r.width,t.x+t.width),a=Math.min(r.y+r.height,t.y+t.height);s>o&&a>i&&n.push({x:o,y:i,width:s-o,height:a-i})}return n}function Cq(e,t,n){if(!(n.x>0||n.y>0))return null;let r=e.x,o=e.y,i=e.x+e.width,s=e.y+e.height;for(let a of t){let l=Math.max(a.x,e.x),u=Math.max(a.y,e.y),c=Math.min(a.x+a.width,e.x+e.width),d=Math.min(a.y+a.height,e.y+e.height);c<=l||d<=u||(r=Math.min(r,l-n.x),o=Math.min(o,u-n.y),i=Math.max(i,c+n.x),s=Math.max(s,d+n.y))}return{x:r,y:o,width:i-r,height:s-o}}function Oq(e){let t=new Uint8Array(e.length*6),n=new Float32Array(e.length*10),r=0,o=0;for(let i of e){let{x:s,y:a,width:l,height:u}=i;t[o++]=le,n[r++]=s,n[r++]=a,t[o++]=ce,n[r++]=s+l,n[r++]=a,t[o++]=ce,n[r++]=s+l,n[r++]=a+u,t[o++]=ce,n[r++]=s,n[r++]=a+u,t[o++]=ce,n[r++]=s,n[r++]=a,t[o++]=fe}return{kind:"polygon",commands:t,coords:n,fillRule:"nonzero"}}var Xke=Object.freeze({filled:!0,outset:0,inset:0}),Ua={high:[],normal:[]},cB=!1;function qT(){cB||(cB=!0,Uq())}function Wi(e,t={}){qT();let n=t.priority==="high"?Ua.high:Ua.normal;return n.push(e),Hu(),()=>{let r=n.indexOf(e);r>=0&&n.splice(r,1),Hu()}}var Fq="shape:painter",Lq="shape:painter:nonrect",_q="shape:painter:derived",Dq="shape:painter:derived:nonrect",Bq="shape:silhouette",Hq="shape:silhouette:text";function Tc(e){let t=Ft(e.pose),n=Mm(e)?t?_q:Dq:t?Fq:Lq;return rt(e,n,void 0,()=>Gq(e))}function Gq(e){qT();for(let t of Ua.high)if(t.matches(e))return t;for(let t of Ua.normal)if(t.matches(e))return t}function Sc(e,t,n){let r=()=>{let o=Tc(e)?.silhouette?.(e,t,n)??null;return o&&Pl(o,t)};if(n?.derivedPath!=null)return r();if(Tc(e)===YT){let o=Ko(),i=rt(e,Hq,t,()=>({epoch:o,path:r()}));return i.epoch!==o&&(i.epoch=o,i.path=r()),i.path}return rt(e,Bq,t,r)}QD(e=>Sc(e.node,e.pose,{derivedPath:e.path}));function Lm(e,t,n){return Tc(e)?.ink?.(e,t,n)??null}function dB(){return qT(),[...Ua.high,...Ua.normal]}function Uq(){Wi(YT),Wi(sB),Wi(Fm),Wi(aB),Wi(uB),Wi(oB),Wi(lB)}function _m(e){return`scene:${e}`}function fB(e,t){let{layerVisibility:n,layerOrder:r}=t;return n===void 0&&r===void 0?e:(r?r.map(i=>e.find(s=>_m(s.id)===i)).filter(i=>i!==void 0):e).filter(i=>n?.[_m(i.id)]!==!1)}ee();function Dm(e){if(e===null)return r=>r;let t=r=>r===void 0?null:e(r),n=new WeakMap;return(r,o,i)=>{let s=t(i),a=Nw(t(o),s);if(a===null)return r;let l=n.get(r);l===void 0&&n.set(r,l=new Map);let u=l.get(s);return u===void 0&&l.set(s,u=At(r,Iw(a))),u}}function pB(e,t){let n=Nw(e,t);return n===null?void 0:q.fromAffine(Iw(n))}var hB=Object.freeze({preserveDrawingBuffer:!0,stencil:!0});ee();ee();ee();function mB(e,t){if(e.length===0)return e;let n=Ce(t);return n?[{kind:"group",transform:q.fromAffine(n),children:e}]:e}var gB=new WeakSet;function Bm(e){let t={kind:"group",children:e};return gB.add(t),t}function yB(e){return gB.has(e)}var Vq=[];function Hm(e){if(!e.some(yB))return{under:e,over:Vq};let t=[],n=[];for(let r of e)yB(r)?n.push(...r.children):t.push(r);return{under:t,over:n}}function xB(e,t,n){let{under:r,over:o}=Hm(e),i=bB(r,t,n);return o.length>0?[...i,Bm(bB(o,t,n))]:i}function bB(e,t,n){let r=mB(e,t);return n!==1&&r.length>0?[{kind:"group",alpha:n,children:r}]:r}function Wq(e,t,n){return Sc(e,t,{derivedPath:n?.()??null})}function Gm(e,t,n){return typeof e.clipFromPose=="function"?e.clipFromPose(t):e.clip!=="outline"?null:Wq(e,t,n)}ee();ee();function PB(e,t,n,r,o,i,s,a){let l=s&&o.inCopy!==void 0?i(e):null;if(l===null||!l.some(f=>a.copiesOf(f).length>0)){if(!o.hits(e,t,n,r))return!1;let f=l??i(e);for(let p=0;p<f.length;p++)if(!wB(a,o,f[p],e,t,n))return!1;return!0}let u=(f,p)=>wB(a,f,p,e,t,n),c=[...l].reverse(),d=(f,p)=>{if(f===c.length)return p.hits(e,t,n,r);let h=c[f];if(u(p,h)&&d(f+1,p))return!0;for(let m of a.copiesOf(h)){let g=p.inCopy?.(m);if(g!==void 0&&u(g,h)&&d(f+1,g))return!0}return!1};return d(0,o)}function wB(e,t,n,r,o,i){let s=e.clipOf(n);return s===null||t.clipAdmits(e.carry(s,n.layer,r.layer),r,o,i)}var ue=e=>e;function zq(e){return e?.annotation===!0}function Um(e){let t=new Set;for(let n of e??[])zq(n)&&t.add(n.id);return t}function kc(e){return e.hidden===!0}function Va(e){let t=Vm(e,"hidden"),n=Vm(e,"locked"),r=n===null?a=>a.locked===!0:a=>a.locked===!0||n.has(a.layer),o=a=>{let l=new Map,u=[];return c=>{if(c===null)return!1;let d=!1,f=null;u.length=0;for(let p=c;p!==null;){let h=l.get(p);if(h!==void 0){d=h;break}let m=e.get(p);if(m===void 0)break;if(u.length>64){if(f??=new Set(u),f.has(p))break;f.add(p)}if(u.push(p),a(m)){d=!0;break}p=m.parent??null}for(let p of u)l.set(p,d);return d}},i=o(kc),s=o(r);return{hidden(a){let l=typeof a=="string"?e.get(a):a;return l===void 0?!1:t?.has(l.layer)===!0||kc(l)||i(l.parent??null)},locked(a){let l=typeof a=="string"?e.get(a):a;return l===void 0?!1:r(l)||s(l.parent??null)}}}function TB(e,t,n){let r=null,o=0;for(let i=t;i!==null;){let s=e.get(i);if(s===void 0)return!1;if(++o>64){if(r??=new Set,r.has(i))return!1;r.add(i)}if(n(s))return!0;i=s.parent??null}return!1}function Vm(e,t){let n=null;for(let r of e.layers??[])(t==="locked"?r.locked===!0:r.visible===!1)&&(n??=new Set).add(r.id);return n}function SB(e,t){let n=e.get(t);return n===void 0?!1:Vm(e,"hidden")?.has(n.layer)===!0||TB(e,t,kc)}function kB(e,t){let n=Vm(e,"locked");return TB(e,t,n===null?r=>r.locked===!0:r=>r.locked===!0||n.has(r.layer))}ee();function AB(e,t){let n=Pt(e.overrides,t),r=Yn(e,t);return r===n.pose?n:{...n,pose:r}}function JT(e,t){return n=>t(AB(e,n))}function RB(e,t){return t===void 0?n=>e.overrides.read(n.id)?.path:n=>{let r=e.overrides.read(n.id)?.path;if(r===void 0)return;let o=AB(e,n);return nh(r,o.pose,t(o))}}function vc(e,t){let n=t?JT(e,t):o=>Yn(e,o);if(!It(e.composition))return n;let r=uh(e,{getPose:o=>{let i=e.get(ue(o));return i?n(i):void 0},getParent:o=>e.get(ue(o))?.parent??null,definesFrame:o=>{let i=e.get(ue(o));return i===void 0||lt(i)}});return o=>Vt(r,o.id,e.composition.compose)}function Kq(e,t){let n=NB(t,It(e.composition));if(n===void 0)return o=>Uw(e,o);let r={at:vc(e,t),local:t?JT(e,t):o=>Yn(e,o),slot:n,shown:RB(e,t),childrenOf:o=>e.childrenOf(o),scene:aa(e),lookup:o=>{let i=e.get(o);return i===void 0?void 0:new XT(Pt(e.overrides,i),r)}};return r.lookup}var XT=class{constructor(t,n){this.ctx=n;this.node=t,this.pose=n.at(t)}ctx;node;pose;get path(){let t=this.ctx.shown(this.node);return t!==void 0?rh(t,this.ctx.local(this.node),this.pose):Er(this.node,this.ctx.lookup,this.ctx.childrenOf,this.ctx.slot)}get inherited(){return sa(this.ctx.scene,this.node)}get children(){return this.ctx.childrenOf(this.node.id).map(this.ctx.lookup)}};function QT(e,t){return t.dependsOn!==void 0||e.overrides.read(t.id)?.path!==void 0}function Ac(e,t){let n=Kq(e,t),r=NB(t,It(e.composition)),o=a=>e.childrenOf(a),i=a=>Er(a,n,o,r),s=RB(e,t);return a=>s(a)??i(a)}var vB=new WeakMap;function NB(e,t){let n=t?"world":"local";if(e===void 0)return n==="world"?"kit:derivedPath:world":void 0;let r=vB.get(e);return r===void 0&&(r={},vB.set(e,r)),r[n]??=e2()}function IB(e,t,n){let r=Ac(e,n),o=It(e.composition)?n?JT(e,n):i=>Yn(e,i):null;return(i,s,a,l)=>{if(!QT(e,i))return t(i,s,a,l);let u=r(i);return u!==null&&o!==null&&e.overrides.read(i.id)?.path===void 0&&(u=jq(u,s,o(i))),t(i,s,a,{...l,derivedPath:u})}}function jq(e,t,n){let r=ni(t);if(r===null)return e;let o=t,i=n,s=Ce({x:o.x,y:o.y,width:o.width,height:o.height,rotation:i?.rotation,transform:i?.transform});return Du(e,s===null?r:ht(r,s))}iv();function $q(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function ZT({reads:e=2}={}){if(!(e>=1)||!Number.isInteger(e))throw new RangeError(`createSettledCache: reads must be a positive integer, got ${e}`);let t,n=0,r=null;return{read(o,i){return(t===void 0||!$q(t,o))&&(t=o.slice(),n=0,r=null),r!==null?r.value:++n<e?null:(r={value:i()},r.value)},clear(){t=void 0,n=0,r=null}}}var Yq=[];function Wm(e){return t=>{let n=t.parent??null;if(n===null)return Yq;let r=[],o=new Set;for(;n!==null&&!o.has(n);){o.add(n);let i=e.get(ue(n));if(!i)break;r.push(i),n=i.parent??null}return r}}function zm(e){let t=Ac(e);return n=>{let r=n;return QT(e,r)?t(r):null}}ee();ee();ee();function EB(e){let{x:t,y:n,width:r,height:o}=e;return Rc([t,n,t+r,n,t+r,n+o,t,n+o],{x:t,y:n,width:r,height:o},!0)}function Rc(e,t,n=!1){let r=[],o=[],i=1/0,s=1/0,a=-1/0,l=-1/0;for(let u=0;u+1<e.length;u+=2){let c=e[u],d=e[u+1];r.push({x:c,y:d}),o.push(c,d),c<i&&(i=c),d<s&&(s=d),c>a&&(a=c),d>l&&(l=d)}return r.length===0?null:{verts:r,coords:o,bounds:t??{x:i,y:s,width:a-i,height:l-s},isRect:n}}function MB(e){if(e.length<3)return null;let t=[];for(let n of e)t.push(n.x,n.y);return Rc(t)}function CB(e){return e!==null&&typeof e=="object"&&e.kind==="polygon"}function Km(e,t,n){return CB(t)?rt(e,"aabb",t,()=>n.getBounds(t)):Ei(t,n)}function OB(e,t){if(Ce(e)){let n=e;return Pl({kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height},e)}return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height}}function e1(e,t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y)||!Number.isFinite(n.width)||!Number.isFinite(n.height))return!1;let r=e.bounds;if(n.x>=r.x+r.width||n.x+n.width<=r.x||n.y>=r.y+r.height||n.y+n.height<=r.y)return!1;if(t==="centers")return Hn(e.coords,n.x+n.width/2,n.y+n.height/2);if(t==="intersect"&&e.isRect&&ld([r.x,r.y,r.x+r.width,r.y+r.height],[n.x,n.y,n.x+n.width,n.y+n.height]))return!0}function FB(e,t,n,r,o,i=()=>!0){let s=e1(e,t,r);if(s!==void 0)return s;let a=e.bounds,l=CB(n);if(t==="enclosed")return l&&!ld([a.x,a.y,a.x+a.width,a.y+a.height],[r.x,r.y,r.x+r.width,r.y+r.height])?!1:mg(e.verts,l?n:o());let u=l?n:o();return i()?u.kind==="rect"&&e.isRect?u.x<a.x+a.width&&u.x+u.width>a.x&&u.y<a.y+a.height&&u.y+u.height>a.y:kd(e.verts,u):kd(e.verts,u,{filled:!1})}function Nc(e,t,n){let r=t.x+t.width,o=t.y+t.height;e[0]=Math.min(e[0],Math.min(t.x,r)-n),e[1]=Math.min(e[1],Math.min(t.y,o)-n),e[2]=Math.max(e[2],Math.max(t.x,r)+n),e[3]=Math.max(e[3],Math.max(t.y,o)+n)}function qq(e,t,n,r){let o=rr(t)?et(t):n.getBounds(t),i=n===Vo?t:jw(t,n),s=Ce(i);if(!s){Nc(e,o,r);return}let a=o.x-r,l=o.y-r,u=o.x+o.width+r,c=o.y+o.height+r;for(let[d,f]of[[a,l],[u,l],[u,c],[a,c]]){let[p,h]=xn(s,d,f);Nc(e,{x:p,y:h,width:0,height:0},0)}}function Xq(e){let t=1e-9*(1+Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])));e[0]-=t,e[1]-=t,e[2]+=t,e[3]+=t}var Jq=Object.freeze({scale:1});function LB(e,t,n,r,o,i){let s=Lm(e,t,r===void 0?Jq:{scale:1,inherited:r}),a=Math.max(0,s?.outset??0);if(i[0]=i[1]=1/0,i[2]=i[3]=-1/0,n)Nc(i,et(n),a);else{let l=Cr(o,e);o===Vo&&l===o&&Ba(t)&&Ce(t)===null?Nc(i,t,a):(Nc(i,Km(e,t,l),a),qq(i,t,o,a))}return Xq(i),Math.max(0,s?.outsetPx??0)}var Qq=0;var _B=new WeakMap,Zq=.5,t1=class{constructor(t,n,r,o){this.built=t;this.trees=n;this.always=r;this.maxOutsetPx=o;this.layers=[...n.keys()],this.order=t,this.marks=new Uint8Array(t.length),this.found=new Int32Array(Math.max(16,r.length))}built;trees;always;maxOutsetPx;layers;order;remap=null;marks;found;rankBy(t){if(t===this.order)return;if(this.order=t,t===this.built){this.remap=null;return}let n=new Map;for(let o=0;o<t.length;o++)n.set(t[o].id,o);let r=new Int32Array(this.built.length);for(let o=0;o<r.length;o++)r[o]=n.get(this.built[o].id)??-1;this.remap=r}candidates(t){let n=Math.floor(this.order.length*Zq),r=0,o=i=>{let s=this.remap===null?i:this.remap[i];if(s<0)return!0;if(r===this.found.length){let a=new Int32Array(r*2);a.set(this.found),this.found=a}return this.found[r++]=s,r<=n};for(let i of this.always)if(!o(i))return null;for(let i=0;i<this.layers.length;i++){let s=t[i],a=this.trees.get(this.layers[i]);if(s===null||a===void 0)continue;let{x:l,y:u,width:c,height:d}=s.box,f=s.pxPerWorld,p=this.maxOutsetPx>0&&f!==void 0?f>0?this.maxOutsetPx/f:1/0:0,h=!1;if(a.queryBox([l-p,u-p,l+c+p,u+d+p],m=>o(m)?!0:(h=!0,!1)),h)return null}return this.readOut(r)}readOut(t){let{order:n,found:r}=this,o=new Array(t);if(t*32<n.length){let a=r.subarray(0,t).sort();for(let l=0;l<t;l++)o[l]=n[a[l]];return o}let i=this.marks.length>=n.length?this.marks:new Uint8Array(n.length);for(let a=0;a<t;a++)i[r[a]]=1;let s=0;for(let a=0;s<t&&a<n.length;a++)i[a]!==0&&(i[a]=0,o[s++]=n[a]);return o}};function eX(e){return e.some(t=>typeof t.copiesFromPose=="function")}function tX(e,t,n){Qq++;let r=vc(e),o=zm(e),i=Wm(e),s=new Map,a=[],l=0;for(let c=0;c<n.length;c++){let d=n[c],f=i(d);if(eX(f)){a.push(c);continue}let p=[0,0,0,0],h;try{let g=Gu(d)?ia(d,f):void 0;h=LB(d,r(d),o(d),g,t,p)}catch{a.push(c);continue}if(!Number.isFinite(h)||!p.every(Number.isFinite)){a.push(c);continue}h>l&&(l=h);let m=s.get(d.layer);m===void 0&&s.set(d.layer,m=[]),m.push([c,p])}let u=new Map;for(let[c,d]of s){let f=Ag(2,d);if(f.size!==d.length)for(let[p,h]of d)h[0]<=h[2]&&h[1]<=h[3]||a.push(p);u.set(c,f)}return new t1(n,u,Int32Array.from(a),l)}function nX(e,t){dB();let n=e.getVersion(),r=e.overrides.getGeneration(),o=e.scroll?.getGeneration()??0,i=t2(),s=ou(),a=_B.get(e);a===void 0&&_B.set(e,a=new WeakMap);let l=a.get(t);l===void 0&&a.set(t,l=ZT());let u=ah(e.overrides,e.renderOrderNodes()),c=l.read([n,r,o,i,s],()=>tX(e,t,u));return c?.rankBy(u),c}function DB(e,t,n){let r=nX(e,t);if(r===null)return null;let o=[];for(let i of r.layers){let s=n(i);if(s===void 0||s!==null&&Number.isNaN(s.box.x+s.box.y+s.box.width+s.box.height))return null;o.push(s)}return r.candidates(o)}function n1(e,t={}){let n=Va(e),r=typeof e.overrides?.ids=="function",o=w=>e.overrides?Pt(e.overrides,w):w,i=w=>r?ah(e.overrides,w):w.map(o),s=Um(e.layers),{getPose:a,alphaOf:l,layerIsPainted:u}=t,c=null;if(!l&&r)for(let w of e.overrides.ids()){let y=e.overrides.read(w)?.alpha;y!==void 0&&y<=0&&(c??=new Set).add(w)}let d=l??(r?c?w=>c.has(w)?0:1:void 0:w=>e.overrides.read(ue(w))?.alpha??1),f=vc(e),p=a?w=>a(w.id):w=>f(w),h=w=>e.childrenOf(w),m=w=>{let y=e.get(w);if(y===void 0)return;let P=o(y);return{node:P,pose:p(P),get path(){return Er(P,m,h)}}},g=a?w=>{let y=w;return y.dependsOn===void 0?null:Er(y,m,h)}:zm(e),b=t.camera?jm(e.layers,t.camera):null,x=a||typeof e.getVersion!="function"?void 0:t.index;return{...b?{planeOf:b}:{},...x?{candidates:w=>{let y=DB(e,x.descriptor,w);return y===null?null:i(y)}}:{},order:()=>i(e.renderOrderNodes()),derivedPathOf:g,poseOf:p,parentsOf:Wm(e),...d?{alphaOf:d}:{},isLocked:w=>n.locked(w),isHidden:w=>n.hidden(w),...s.size>0||u?{layerIsPainted:w=>!s.has(w)&&(u===void 0||u(w))}:{}}}function jm(e,t){let n=null;for(let o of e??[])o.parallax&&(n??=new Map).set(o.id,Yp(t,o.parallax));if(n===null)return null;let r=n;return o=>r.get(o)??null}function BB(e,t){let n=t.includeGroups??!0,r=t.includeLocked===!0?void 0:e.isLocked,o=[],i=new Map,s=Dm(e.planeOf??null),a=b=>{let x=i.get(b.id);if(x!==void 0)return x;let w=Gm(b,e.poseOf(b),()=>e.derivedPathOf?.(b));return i.set(b.id,w),w},l=new Map,u=b=>{let x=l.get(b.id);if(x===void 0){let w=b.copiesFromPose;x=(w?w(e.poseOf(b),b)??[]:[]).map(cr).filter(P=>P!==null),l.set(b.id,x)}return x},c=new Map,d=b=>{if(b===void 0||e.planeOf===void 0)return t;let x=c.get(b);if(x===void 0){let w=e.planeOf(b);x=w===null?t:t.inPlane?.(w)??null,c.set(b,x)}return x},f={clipOf:a,copiesOf:u,carry:s},p=b=>e.parentsOf(b),h=e.order(),m=h.some(b=>typeof b.copiesFromPose=="function"),g=(t.broad!==void 0?e.candidates?.(b=>{let x=d(b);return x===null?null:x.broad}):null)??h;for(let b of g){if(!n&&b.kind==="group"||b.pickable===!1||e.isHidden?.(b)===!0||b.layer!==void 0&&e.layerIsPainted?.(b.layer)===!1||e.alphaOf!==void 0&&e.alphaOf(b.id)<=0||r!==void 0&&r(b))continue;let x=d(b.layer);if(x===null)continue;let w=e.poseOf(b),y=e.derivedPathOf?.(b),P=Gu(b)?ia(b,e.parentsOf(b)):void 0;PB(b,w,y,P,x,p,m,f)&&o.push(b.id)}return o}function rX(e,t,n,r){let o={kind:"group",children:e};for(let i=t.length-1;i>=0;i--){let s=t[i];o="copy"in s?{kind:"group",children:[o],transform:q.fromAffine(s.copy)}:{kind:"group",children:[o],clip:r(s.path,s.layer,n)}}return o}function HB(e,t,n,r,o,i){let s=e.getLayers(),a=new Map;for(let h of s)h.visible&&a.set(h.id,[]);let l=null;for(let h of s)h.parallax&&(l??=new Map).set(h.id,Aw(n,h.parallax));let u=e.composePose?.bind(e),c=u?e.childFrame?.bind(e):void 0,d=Dm(l?jm(s,n):null);function f(h,m,g,b){let x=e.getNode(h);if(!x||kc(x))return;let w=e.getPose(h),y=u&&g!==null?u(g,w):w,P=r===void 0||x.layer===r?a.get(x.layer):void 0,S=l?.get(x.layer)??n,{under:v,over:A}=Hm(P&&(b||!i?.(x,y,S))?t(x,y,S):[]),N=m,M=null,C=x,F=Gm(C,y,()=>o?.(x,y));F&&(M={path:F,layer:x.layer},N=[...m,M]);let B=J=>m.length>0?rX(J,m,x.layer,d):{kind:"group",children:J};P&&P.push(B(v));let D=lt(x)?c?c(h,y):y:g,j=x.consumesChildren===!0?[]:e.getChildren(h);for(let J of j)f(J,N,D,b);let V=typeof C.copiesFromPose=="function"?C.copiesFromPose(y,x):null;for(let J of V??[]){let se=[...m,{copy:J},...M?[M]:[]];for(let ke of j)f(ke,se,D,!0)}P&&A.length>0&&P.push(B(A))}for(let h of e.getChildren(null))f(h,[],null,!1);let p=[];for(let h of s){if(!h.visible||r!==void 0&&h.id!==r)continue;let m=a.get(h.id)??[],g=h.parallax?pB(Yp(n,h.parallax),null):void 0;p.push(g?{kind:"group",transform:g,children:m}:{kind:"group",children:m})}return p}var Wa=[{field:"clipFromPose",opKey:"clipKey",jsonKey:"clipFromPoseKey",lost:"clip"},{field:"copiesFromPose",opKey:"copiesKey",jsonKey:"copiesFromPoseKey",lost:"copies"},{field:"derivePath",opKey:"derivePathKey",jsonKey:"derivePathKey",lost:"derived path"},{field:"derivePose",opKey:"derivePoseKey",jsonKey:"derivePoseKey",lost:"derived pose"},{field:"layout",opKey:"layoutKey",jsonKey:"layoutKey",lost:"layout"}];function $m(e,t){return Wa.map(n=>{let r=e[n.field],o=new Map;if(r)for(let[i,s]of Object.entries(r))o.set(s,i);return{spec:n,keyOf:i=>o.get(i),fnOf:i=>r?.[i],read:i=>i[n.field],write:(i,s)=>{i[n.field]=s,t?.(n.field,i)}}})}function Ic(e,t,n,r,o){let i=e.fnOf(n);if(i===void 0){o("scene",`${r}: ${e.spec.opKey} "${n}" not in this scene's registry \u2014 node "${t.id}" restored without its ${e.spec.lost}. Register a function with this key in the registry option to restore it.`);return}e.write(t,i)}function zi(e,t,n,r){let o={};for(let i of e){let s=i.read(t);if(s===void 0)continue;let a=i.keyOf(s);if(a===void 0){r?.(i);continue}o[i.spec[n]]=a}return o}function Ym(e){let t=e,n={};for(let r of Wa){let o=t[r.field];o!==void 0&&(n[r.field]=o)}return n}function ir(e){let t={};return e.pickable!==void 0&&(t.pickable=e.pickable),e.hidden===!0&&(t.hidden=!0),e.locked===!0&&(t.locked=!0),e.units!==void 0&&(t.units=e.units),e.clip!==void 0&&(t.clip=e.clip),e.consumesChildren===!0&&(t.consumesChildren=!0),t}function qm(e){let t=n=>n===null?[...e.roots]:[...e.childrenOf(ue(n))];return{getNode:n=>e.get(ue(n)),getParent:n=>e.get(ue(n))?.parent??null,getChildren:t,getRemovalClosure:n=>[...e.removalClosure(n.map(ue))],setPose:(n,r)=>e.setPose(ue(n),r),setParent:(n,r)=>e.move(ue(n),r==null?null:ue(r)),setChildOrder:(n,r)=>{e.batch("Reorder",()=>{for(let o=0;o<r.length;o++)t(n)[o]!==r[o]&&e.reorder(ue(r[o]),o)})},setData:(n,r)=>e.update(ue(n),{data:r}),setLayer:(n,r)=>e.setLayer(ue(n),r),setDependsOn:(n,r)=>e.setDependsOn(ue(n),Array.isArray(r)?r.map(ue):r),setLayout:(n,r)=>e.setLayout(ue(n),r),setHidden:(n,r)=>e.setHidden(ue(n),r),setLocked:(n,r)=>e.setLocked(ue(n),r),removeNode:n=>e.remove(ue(n)),insertNode:(n,r)=>{e.add({kind:n.kind,layer:n.layer,pose:n.pose,data:n.data,id:n.id,...r!==void 0?{index:r}:{},...n.parent!=null?{parent:n.parent}:{},...n.dependsOn!==void 0?{dependsOn:n.dependsOn}:{},...ir(n),...Ym(n)})}}}function GB(e){return{getPose:t=>Mr(e,e.get(ue(t))),getNodes:()=>[...e.renderOrderNodes()]}}function UB(e,t,n){for(let r of t)r.apply(e)}ee();function WB(e,t){let n=e?.get?.();return{...t?{alphaOf:t}:{},...e?.layerIsPainted?{layerIsPainted:r=>e.layerIsPainted(r)}:{},...n?{camera:n}:{}}}function zB(e,t,n,r=Vo,o={}){return jB(e,EB(t),"intersect",n,r,o)}function KB(e,t,n,r,o=Vo,i={}){let s=MB(t);return s?jB(e,s,n,r,o,i):[]}function VB(e,t){return t?.kind!=="polygon"||e()?t:{...t,openFill:"none"}}function jB(e,t,n,r,o,i){let s=n1(e,{...r,index:{descriptor:o}});return BB(s,r1(t,n,o,i))}function r1(e,t,n,r){return{includeGroups:r.includeGroups===!0,broad:{box:e.bounds},clipAdmits:(o,i,s,a)=>{let l=Cr(n,i);return Sd(o,a?et(a):Ei(s,l))&&Sd(o,e.bounds)},hits:(o,i,s,a)=>{let l=Cr(n,o),u=s?et(s):Km(o,i,l),c=e1(e,t,u);if(c!==void 0)return c;let d,f=()=>d??=Lm(o,i,{inherited:a})?.filled!==!1;return FB(e,t,VB(f,i),u,()=>VB(f,Sc(o,i,{derivedPath:s})??s??OB(i,u)),f)},inPlane:o=>r1(oX(e,o),t,n,r),inCopy:o=>({...r1(iX(e,o),t,n,r),broad:void 0})}}function oX(e,t){let n=[];for(let r of e.verts){let o=Rw(t,r);n.push(o.x,o.y)}return Rc(n,CC(t,e.bounds),e.isRect)}function iX(e,t){let n=[],r=1/0,o=1/0,i=-1/0,s=-1/0;for(let l of e.verts){let[u,c]=xn(t,l.x,l.y);n.push(u,c),r=Math.min(r,u),o=Math.min(o,c),i=Math.max(i,u),s=Math.max(s,c)}let a=t[1]===0&&t[2]===0||t[0]===0&&t[3]===0;return Rc(n,{x:r,y:o,width:i-r,height:s-o},e.isRect&&a)}function sX(e,t,n,r){return r!==void 0?r(t,n):e.get(t)?.kind==="group"}function $B(e,t,n,r){return sX(e,t,n,r)===!0}function YB(e,t,n){return t==null||!e||e.get(t)===void 0?null:$B(e,t,[],n)?t:null}function qB(e,t,n){let r=YB(e,t,n);if(r===null)return{parent:null,layer:e.layers[0]?.id??"default",local:a=>a};let o=e.get(r),i=e.composition;if(i===void 0||!It(i))return{parent:o.id,layer:o.layer,local:a=>a};let s=ea(uh(e,{getPose:a=>e.get(a).pose,getParent:a=>e.get(a)?.parent??null,definesFrame:a=>lt(e.get(a)??{})}),o.id,i.compose);return{parent:o.id,layer:o.layer,local:a=>i.decompose(s,a)}}function o1(e,t){return e?.axes?.(t)??Vu(t)}var XB=new WeakMap;function aX(e){let t=XB.get(e);return t||(t=()=>e.commit(),XB.set(e,t)),t}function lX(e,t){let n=t(),r=o1(e,n);if(!r)return null;let{count:o,angles:i}=r,s=()=>{let a=t();if(a!==n){let l=o1(e,a);l&&l.count===o&&(r=l),n=a}return r};return{count:o,angles:i,to:a=>s().to(a),from:a=>s().from(a),add:r.add&&((a,l)=>{let u=s();return u.add?u.add(a,l):u.from(u.to(a).map((c,d)=>c+l[d]))}),write:r.write&&((a,l,u)=>{let c=s();c.write?c.write(a,l,u):c.to(a).forEach((d,f)=>{l[u+f]=d})})}}function uX(e,t,n){let{overrides:r}=e,o=e.id,i=lX(e.descriptor,e.get);if(!i)return null;let s={},a=!1,l=null,u=()=>{a=!1,l?.(),l=null,r.clear(o,s),t?.()},c=Jw({get:e.get,set:e.set,axes:i,show(d){if(c.active&&n?.()&&c.stop({commit:!1}),!c.active){u();return}s.pose=d,r.has(o,s)||r.set(o,s),a=!0,n&&l===null&&(l=r.subscribe(()=>{!c.active||!n()||(c.stop({commit:!1}),a&&u())}))},publish:aX(r)});return c}var JB=new WeakMap;function QB(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=e,r=t,o=0;for(let i in n)if(Object.hasOwn(n,i)){if(!Object.hasOwn(r,i)||n[i]!==r[i])return!1;o++}for(let i in r)Object.hasOwn(r,i)&&o--;return o===0}function ZB(e,t,n){let r=JB.get(e.overrides);r||(r=new Map,JB.set(e.overrides,r));let o=t,i=e.get(o),s=n??Et,a=r.get(t),l=!a||a.active||!i||o1(s,Mr(e,i))?.count===a.axisCount;if(a&&l)return a;if(!i)return;let u=Mr(e,i),c,d=!1,f=r,p=null;if(p=uX({id:t,descriptor:s,overrides:e.overrides,get(){let h=e.get(o);return h&&(u=Mr(e,h)),h&&!p?.active&&(c=h.pose),u},set(h){let m=e.get(o);if(m){d=!0;try{QB(m.pose,h)||e.untracked(()=>e.setPose(o,h))}finally{d=!1}c=e.get(o)?.pose}}},()=>{e.get(o)||f.delete(t)},()=>{if(d)return!1;let h=e.get(o);return!!h&&c!==void 0&&!QB(h.pose,c)}),!!p)return r.set(t,p),p}function $t(e){return e.children!==void 0&&e.children.length>0}function za(e){return Array.isArray(e)?[...e]:e!==null&&typeof e=="object"?{...e}:e}function e3(e,t){let{scene:n}=e,r=$m(n.registry),o=new Set(t),i=new Set,s=[],a=(p,h)=>{if(h)return e.worldPoseOf(p.id);let m=e.frameAtOrAbove(p.parent);return m!==null&&i.has(m)?p.pose:e.worldPoseOf(p.id)},l=(p,h=!1)=>{if(i.has(p))return;let m=n.get(ue(p));if(m&&(i.add(p),s.push({kind:m.kind,id:m.id,layer:m.layer,parent:m.parent,pose:za(a(m,h)),data:za(m.data),...m.children!==void 0?{children:[...m.children]}:{},...ir(m),...m.dependsOn!==void 0?{dependsOn:za(m.dependsOn)}:{},...Ym(m),...zi(r,m,"jsonKey")}),$t(m)))for(let g of n.childrenOf(ue(p)))l(g)},u=p=>n.get(ue(p))?.parent,c=p=>Em(o,p,u)!==null,d=new Set,f=p=>{if(d.has(p))return;d.add(p);let h=n.get(ue(p));if(h){for(let m of Bu(h))i.has(m)||c(m)||n.get(m)?.hidden!==!0||(f(m),l(m,!0));if($t(h))for(let m of n.childrenOf(ue(p)))f(m)}};for(let p of Pc(t,u))f(p),l(p,!0);return{items:s}}var cX=e=>typeof e=="function"||typeof e=="object"&&e!==null&&Object.values(e).some(t=>typeof t=="function");function dX(e,t){let n={},r=e.registry;for(let o of Wa){let i=t[o.jsonKey],a=(typeof i=="string"?r[o.field]?.[i]:void 0)??(cX(t[o.field])?t[o.field]:void 0);a!==void 0&&(n[o.field]=a)}return n}function fX(e,t){let n=new Map,r=new Set(e.map(o=>o.id));for(let o=!0;o;){o=!1;for(let i of e){if(n.has(i.id))continue;let s,a=Bu(i),l=a.filter(c=>!r.has(c)),u=t.get(i.id);i.parent!==null&&n.has(i.parent)?s={id:i.id,reason:"container-not-pasted"}:l.length>0?s={id:i.id,reason:"dependency-not-copied",missing:l}:a.length>0&&u.derivePath===void 0&&u.derivePose===void 0&&(s={id:i.id,reason:"derivation-not-registered"}),s!==void 0&&(n.set(i.id,s),r.delete(i.id),o=!0)}}return n}function t3(e,t,n,r){let o=t.items;if(o.length===0)return[];let i=new Map(o.map(b=>[b.id,dX(e.scene,b)])),s=fX(o,i);if(r?.onOmit)for(let b of o){let x=s.get(b.id);x&&r.onOmit(x)}let a=s.size===0?o:o.filter(b=>!s.has(b.id)),l=new Map;for(let b of a)l.set(b.id,e.scene.mintId());let u=b=>b.parent===null||!l.has(b.parent),c=new Map(a.map(b=>[b.id,b])),d=b=>{let x=b.parent===null?void 0:c.get(b.parent);for(;x!==void 0;){if(lt(x))return!0;x=x.parent===null?void 0:c.get(x.parent)}return!1},f=n.dx,p=n.dy;if(r?.dropPoint){let b=1/0,x=1/0;for(let w of a){if(!u(w))continue;let y=e.poseBounds(w.pose,w);y.x<b&&(b=y.x),y.y<x&&(x=y.y)}Number.isFinite(b)&&Number.isFinite(x)&&(f=r.dropPoint.x-b,p=r.dropPoint.y-x)}let h=e.landing?.(),m=h?.parent!=null?h:null,g=b=>{if(d(b))return za(b.pose);let x=e.translate(za(b.pose),f,p,b);return m&&u(b)?m.local(x):x};return a.map(b=>({id:l.get(b.id),kind:b.kind,layer:m&&u(b)?m.layer:b.layer,parent:u(b)?m?.parent??null:l.get(b.parent),pose:g(b),data:za(b.data),...ir(b),...b.children!==void 0?{children:b.children.filter(x=>l.has(x)).map(x=>l.get(x))}:{},...b.dependsOn==="children"?{dependsOn:"children"}:Bu(b).length>0?{dependsOn:Bu(b).map(x=>l.get(x))}:{},...i.get(b.id)}))}function pX(e){let t=It(e.composition),n=LC(e.composition.compose),r=t?Yw(e):void 0,o={getParent:i=>e.get(ue(i))?.parent??null,getPose(i){let s=e.get(ue(i));if(!s)throw new Error(`sceneToAdapter: unknown node "${i}"`);return Yn(e,s)},definesFrame(i){let s=e.get(ue(i));return s===void 0||lt(s)},...r?{childFrame:r}:{}};return{getPose:o.getPose,definesFrame:o.definesFrame,getWorldPose:i=>t?Vt(o,i,n):o.getPose(i),worldOfStored(i,s){let a=t?$n(o,o.getParent(i)):null;return a===null?s:n(ea(o,a,n),s)},...t?{composePose:n}:{},...r?{childFrame:r}:{}}}function n3(e,t={}){let n=t.selection,r=n?.getSelection??n?.get??(()=>[]),o=n?.setSelection??n?.set??(()=>{}),i=t.poseDescriptor??Vo,s=(f,p)=>Ei(f,Cr(i,p)),a=(f,p,h,m)=>$w(f,p,h,m===void 0?i:Cr(i,m)),l={},u=f=>f?{...l,...WB(f,void 0)}:l,c={scene:e,worldPoseOf:f=>d.getWorldPose(f),frameAtOrAbove:f=>$n(d,f),poseBounds:s,translate:a,...t.pasteInto?{landing:()=>qB(e,t.pasteInto())}:{}},d={...qm(e),getNodes(){let f=Va(e);return e.renderOrderNodes().filter(p=>!f.hidden(p.id))},...pX(e),poseTarget:(f,p)=>ZB(e,f,p??i),getLayers:()=>e.layers.map(f=>({id:f.id,visible:f.visible,parallax:f.parallax})),subscribeLayers:f=>e.subscribe(f),getLayout:f=>e.layoutOf(ue(f)),applyOps(f,p){p!==void 0?e.applyBatch(f,p,this):UB(this,f)},getSelection:r,setSelection:o,hitTestArea(f,p){return zB(e,f,u(p),i,{includeGroups:!0})},hitTestLasso(f,p,h){return KB(e,f,p,u(h),i,{includeGroups:!0})},...t.commitInsert?{commitInsert:f=>{let p=t.commitInsert(f);if(!p)return null;let h=t.insertLayer??"default";return{kind:"mark",id:p.id===void 0?e.mintId():ue(p.id),layer:h,pose:p.pose,data:p.data,parent:null}}}:{},snapshotSelection(f){return e3(c,f)},commitPaste(f,p,h){return t3(c,f,p,h)},getPasteOffset(){return{dx:12,dy:12}}};return d}var hX=()=>typeof performance<"u"?performance.now():Date.now();function r3(e,t,n=hX){return(r,o,i,s)=>{if(!e.has(r.id))return t(r,o,i,s);let a=n();return t(r,o,i,{...s,vertexColors:(l,u)=>e.resolve(r.id,l,u,a)})}}ee();ee();function o3(e,t,n){let r=t,o=hr(t);return(i,s,a=t)=>{a!==r&&(r=a,o=hr(a));let l=e(i,s,a);if(!l)return!1;let u=Ce(s),c=u?q.multiply(o,q.fromAffine(u)):o;return T0(l,c,n)}}function s3(e){let t=typeof window<"u"&&window.devicePixelRatio||1;return Math.max(Math.abs(e.scale.x),Math.abs(e.scale.y))*t}var i3,i1={};function mX(e){let t=s3(e);return(e!==i3||i1.pixelScale!==t)&&(i3=e,i1={pixelScale:t}),i1}function a3(e,t,n,r){let o=e.kind==="group"?void 0:Tc(e),i=!n||r?.pixelScale!==void 0?r:r?{...r,pixelScale:s3(n)}:mX(n),s=o?o.paint(e,t,i):[],a=e.data;if(a?.label&&a.text==null){let l=t,u=kw(l.x+6,l.y+14,[{text:a.label,fill:{paint:{kind:"solid",color:"rgba(0,0,0,0.7)"}}}],{fontFamily:"sans-serif",fontSize:11});return[...s,e.kind==="group"?Bm([u]):u]}return s}function l3(e,t){return(n,r,o,i)=>t(Pt(e,n),r,o,i)}function yX(e,t={}){let{getNode:n,getChildren:r,getPose:o,composePose:i,childFrame:s}=n3(e);return{getLayers:()=>fB(e.layers,t).map(a=>({id:a.id,visible:a.visible,parallax:a.parallax})),getNode:n,getChildren:r,getPose:o,...i?{composePose:i}:{},...s?{childFrame:s}:{}}}function u3(e,t,n,r,o,i,s,a){let l=aa(e),u=IB(e,YD(l,n)),c=s?r3(s,u):u,d=Ac(e),f=w=>d(Pt(e.overrides,w)),p=(w,y,P)=>{let S=e.overrides.read(w.id)?.alpha??1;return xB(c(Pt(e.overrides,w),y,P),y,(o?o(w.id):1)*S)},h=yX(e,i),m=a?{x:0,y:0,width:a.width,height:a.height}:void 0,g=m&&a?.paintBounds?o3(l3(e.overrides,qD(l,a.paintBounds)),t,m):void 0,b=HB(h,p,t,void 0,f,g),x=a&&m?P0(b,hr(t),m,a.dpr):b;if(r&&r.length>0)for(let w of r)x.push(w);return[{kind:"group",transform:hr(t),children:x}]}ee();function c3(e){let t=new Map,n=new Set,r=i=>{i&&n.add(i.kind??"solid")},o=i=>{for(let s of i)if(s.kind==="group")o(s.children);else if(s.kind==="path")r(s.fill?.paint),r(s.stroke?.paint);else if(s.kind==="text")for(let a of s.runs){let l=`${a.fontFamily}|${a.fontWeight}|${a.fontStyle}`;t.has(l)||t.set(l,{family:a.fontFamily,weight:a.fontWeight,style:a.fontStyle}),r(a.fill?.paint),r(a.stroke?.paint)}};return o(e),{fonts:[...t.values()],paintKinds:[...n]}}function d3(e,t,n){let r=gX(e,t,n);return bX(r),r}function gX(e,t,n){let r=t*4,o=new Uint8ClampedArray(e.length);for(let i=0;i<n;i++)o.set(e.subarray((n-1-i)*r,(n-i)*r),i*r);return o}function bX(e){for(let t=0;t<e.length;t+=4){let n=e[t+3];if(n===0||n===255)continue;let r=255/n;e[t]=e[t]*r,e[t+1]=e[t+1]*r,e[t+2]=e[t+2]*r}}function s1(e){let{sourceRect:t,scale:n}=e;for(let[c,d]of[["sourceRect.width",t.width],["sourceRect.height",t.height]])if(!Number.isFinite(d)||d<=0)throw new Error(`renderSceneToPixels: ${c} must be a positive finite number, got ${d}`);for(let[c,d]of[["scale.x",n.x],["scale.y",n.y]])if(!Number.isFinite(d)||d===0)throw new Error(`renderSceneToPixels: ${c} must be a nonzero finite number, got ${d}`);for(let[c,d]of[["sourceRect.x",t.x],["sourceRect.y",t.y]])if(!Number.isFinite(d))throw new Error(`renderSceneToPixels: ${c} must be a finite number, got ${d}`);let r=Math.max(1,Math.round(t.width*Math.abs(n.x))),o=Math.max(1,Math.round(t.height*Math.abs(n.y))),i={x:n.x<0?t.x+t.width:t.x,y:n.y<0?t.y+t.height:t.y,scale:{x:n.x,y:n.y}},s=e.resolveImage,a=e.drawOne??((c,d,f,p)=>a3(c,d,f,{...p,resolveImage:s})),l=[];e.background!==void 0&&l.push({kind:"path",path:{kind:"rect",x:0,y:0,width:r,height:o},fill:{paint:{kind:"solid",color:e.background}}});let u=e.annotations?void 0:{layerVisibility:Object.fromEntries([...Um(e.scene.layers)].map(c=>[_m(c),!1]))};return l.push(...u3(e.scene,i,a,void 0,e.alphaFor,u,e.colorOverrides)),e.overlay&&l.push(...e.overlay),{width:r,height:o,view:i,commands:l}}function xX(e,t){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,t);if(typeof document<"u"){let n=document.createElement("canvas");return n.width=e,n.height=t,n}throw new Error("renderSceneToPixels: no canvas source in this environment \u2014 supply `gl` or `createCanvas`")}function a1(e={}){if(e.gl&&e.createCanvas)throw new Error("raster session: `gl` and `createCanvas` are mutually exclusive");let t=null,n=e.gl,r=null,o=!1;function i(s,a){if(e.gl||(t?(t.width<s&&(t.width=s),t.height<a&&(t.height=a)):(t=(e.createCanvas??xX)(s,a),t.width=s,t.height=a,n=t.getContext("webgl2",hB)??void 0)),!n||typeof n.enable!="function")throw new Error("raster session: WebGL2 is unavailable \u2014 supply `gl` or a WebGL2-capable `createCanvas`");if(f3(n))throw new Error("raster session: the WebGL2 context is lost \u2014 dispose this session and open another");let{drawingBufferWidth:l,drawingBufferHeight:u}=n;if(l<s||u<a)throw new Error(`raster session: a ${s} \xD7 ${a} render does not fit the context's ${l} \xD7 ${u} drawing buffer \u2014 lower \`scale\` or render the source rect in tiles`);return n}return{render(s){if(o)throw new Error("raster session: render() on a disposed session");let a=s1(s),{width:l,height:u}=a,c=i(l,u),d={px:s.flattenTolerancePx??.25};if(r?(r.resize({width:l,height:u,dpr:1}),r.setFlattenTolerance(d)):r=new Lu({gl:c,width:l,height:u,dpr:1,imageMinification:"mipmap",flattenTolerance:d,bakeBudget:1/0}),r.render(a.commands,hr(a.view),{screen:s.screen}),f3(c))throw new Error("raster session: the WebGL2 context was lost during render");let f=new Uint8Array(l*u*4);return c.readPixels(0,0,l,u,c.RGBA,c.UNSIGNED_BYTE,f),{width:l,height:u,data:d3(f,l,u)}},dispose(){o||(o=!0,r?.dispose(),r=null,t&&!e.createCanvas&&n?.getExtension("WEBGL_lose_context")?.loseContext(),t=null,n=void 0)}}}function f3(e){return typeof e.isContextLost=="function"&&e.isContextLost()===!0}function l1(e={}){let{families:t,paintKinds:n}=e;if(e.render||e.commands){let r;try{r=e.render?s1(e.render).commands:[]}catch(i){return Promise.reject(i)}let o=c3([...r,...e.commands??[]]);t??=o.fonts,n??=o.paintKinds.filter(v0)}return Promise.all([Ay(t),A0(n)]).then(()=>{})}async function u1(e){let t=new ImageData(new Uint8ClampedArray(e.data),e.width,e.height);if(typeof OffscreenCanvas<"u"){let o=new OffscreenCanvas(e.width,e.height),i=o.getContext("2d");if(!i)throw new Error("rasterToPng: no 2D context");return i.putImageData(t,0,0),o.convertToBlob({type:"image/png"})}if(typeof document>"u")throw new Error("rasterToPng: no canvas in this environment");let n=document.createElement("canvas");n.width=e.width,n.height=e.height;let r=n.getContext("2d");if(!r)throw new Error("rasterToPng: no 2D context");return r.putImageData(t,0,0),new Promise((o,i)=>{n.toBlob(s=>s?o(s):i(new Error("rasterToPng: encoding failed")),"image/png")})}var Ka=class extends Error{arrivals;constructor(t){let n=[...t.keys()].map(r=>`"${r}"`).join(", ");super(`Scene: ${n} refused the nodes joining it`),this.name="SceneArrivalRefused",this.arrivals=t}};var c1=bt(),TNe=c1.reflection;function p3(e,t){c1.set(e,t)}function Xm(e,t){let n=c1.get(e);return n?n(t):null}function h3(e,{compose:t,decompose:n},r,o){let i=n(e,e),s=r(i),a=r(e);if(s===null||a===null)return null;let l=o(i,s,{...s,x:a.x+(a.width-s.width)/2,y:a.y+(a.height-s.height)/2}),u=r(l);if(u===null)return null;let c=!ko(l,e);return{upright:l,bounds:u,turned:c,toStrategy:d=>c?t(l,n(e,d)):d,toWorld:d=>c?t(e,n(l,d)):d}}function m3(e){let t=e?.data?.pathEffect;return t&&typeof t=="object"&&typeof t.kind=="string"?t:null}var d1="kit:clipNothing",f1=()=>null;var y3="kit:unionOfChildren";function g3(e,t){let n=[];for(let o of t){if(o===void 0)continue;let i=p1(o.pose);if(i===null)return null;n.push(i)}if(n.length===0)return null;let r=f2(n);return r===null?null:r}function p1(e){if(e===null||typeof e!="object")return null;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"?e:null}function b3(e){return{...e,clipFromPose:{[d1]:f1,...e.clipFromPose},derivePath:{[HT]:GT,...e.derivePath},derivePose:{[y3]:g3,...e.derivePose}}}function P3(e,t){let{undoStack:n,redoStack:r,forks:o,floorId:i,nextEntryId:s}=e,a=0,l=b=>(a+=b.length,b.map(x=>wX(x,t))),u=b=>{let x=l(b);return x.slice(x.lastIndexOf(null)+1)},c=u(n),d=u(r),f=c.length===n.length?i:n[n.length-c.length-1].id,p=new Set([f,...[...c,...d].map(b=>b.id)]),h=[...o].flatMap(([b,x])=>x.map(w=>{let y=l(w),P=y.indexOf(null);return{at:b,entries:P<0?y:y.slice(0,P)}})).filter(b=>b.entries.length>0),m=[];for(let b=!0;b;){b=!1;let x=[];for(let w of h){if(!p.has(w.at)){x.push(w);continue}m.push(w);for(let y of w.entries)p.add(y.id);b=!0}h=x}let g=c.length+d.length+m.reduce((b,x)=>b+x.entries.length,0);return{version:1,undoStack:c,redoStack:d,...m.length>0?{branches:m}:{},...f!==0?{floor:f}:{},nextEntryId:s,droppedEntries:a-g}}function T3(e,t,n){let r=u=>TX(u,t,n),o=e.undoStack.map(r),i=e.redoStack.map(r),s=new Map;for(let u of e.branches??[]){let c=u.entries.map(r),d=s.get(u.at);d?d.push(c):s.set(u.at,[c])}let a=e.nextEntryId,l=[o,i,...[...s.values()].flat()];for(let u of l)for(let c of u)c.id>=a&&(a=c.id+1);return{undoStack:o,redoStack:i,forks:s,floorId:e.floor??0,nextEntryId:a}}function Ki(e){let t=new Set;for(let n of e){if(n.args===null||typeof n.args!="object")continue;let r=n.args;if(typeof r.id=="string")t.add(r.id);else if(r.node!==null&&typeof r.node=="object"){let o=r.node;typeof o.id=="string"&&t.add(o.id)}else if(Array.isArray(r.nodes))for(let o of r.nodes){let i=o!==null&&typeof o=="object"?o.id:void 0;typeof i=="string"&&t.add(i)}}return t}function x3(e){return typeof e.name!="string"?null:{name:e.name,args:e.args}}function wX(e,t){let n=[];for(let o of e.forwardOps){let i=x3(o);if(i===null)return t.log(`serialize: dropping entry id=${e.id} "${e.label}" \u2014 forwardOp without name`),null;n.push(i)}let r=[];for(let o of e.baseOps){let i=x3(o);if(i===null)return t.log(`serialize: dropping entry id=${e.id} "${e.label}" \u2014 baseOp without name`),null;r.push(i)}return{id:e.id,label:e.label,forwardOps:n,baseOps:r,pushes:e.pushes,timestamp:e.timestamp,...e.selectionBefore?{selectionBefore:e.selectionBefore}:{},...e.selectionAfter?{selectionAfter:e.selectionAfter}:{}}}function PX(e,t,n){let r={name:e,args:t,label:n,apply:()=>"noop",invert:()=>r};return r}function w3(e,t,n,r){let o=n?n(e.name,e.args):null;return o!==null?o:(r.log(`restore: unknown op name "${e.name}" \u2014 substituting no-op placeholder`),PX(e.name,e.args,t))}function TX(e,t,n){let r=e.forwardOps.map(i=>w3(i,e.label,t,n)),o=e.baseOps.map(i=>w3(i,e.label,t,n));return{id:e.id,label:e.label,forwardOps:r,baseOps:o,timestamp:e.timestamp??0,pushes:e.pushes??1,touchedIds:Ki(r),...e.selectionBefore?{selectionBefore:[...e.selectionBefore]}:{},...e.selectionAfter?{selectionAfter:[...e.selectionAfter]}:{}}}function S3(e,t){if(e.length===0||t.length===0||e.length!==t.length)return!1;let n=new Map;for(let r of e){let o=r.coalesceKey;if(o===void 0)return!1;n.set(o,(n.get(o)??0)+1)}for(let r of t){let o=r.coalesceKey,i=o===void 0?0:n.get(o)??0;if(!i)return!1;n.set(o,i-1)}return!0}function h1(e){return{id:e.id,label:e.label,timestamp:e.timestamp,pushes:e.pushes,touchedIds:e.touchedIds,...e.selectionBefore?{selectionBefore:e.selectionBefore}:{},...e.selectionAfter?{selectionAfter:e.selectionAfter}:{}}}function sr(e,t=[]){return{kind:e,entries:t.map(n=>({id:n.id,label:n.label,ops:n.forwardOps}))}}function k3(e,t){function n(o){for(let i of o)try{i.apply(e)}catch(s){t.warn(`unwinding a failed step: op "${i.name??"?"}" threw: ${String(s)}`)}}function r(o,i,s){let a=!1,l=0;try{for(;l<o.length;l++){let u=o[l].apply(e);u!==!1&&u!=="noop"?a=!0:s?.push(o[l])}}catch(u){throw l>0&&(n(o.slice(0,l).reverse().map(c=>c.invert())),i&&n(i())),u}return a}return r}function v3(e,t,n){let r=e.forwardOps===e.baseOps;e.forwardOps=[...e.forwardOps,...t],e.baseOps=r?e.forwardOps:[...e.baseOps,...t],e.timestamp=n,e.pushes++;let o=new Set(e.touchedIds);for(let i of Ki(t))o.add(i);e.touchedIds=o}function A3(e){for(let t=0;t<e.length;t++)if(e[t].caused!==void 0)return!0;return!1}var Jm=new WeakMap;function R3(e){let t=Jm.get(e);if(!t)throw new Error("Journal is not resumable (already committed or cancelled)");t()}function N3(e,t,n,r,o={}){let i=Ec(t,{...o,...n.coalesceWindowMs!==void 0?{coalesceWindowMs:n.coalesceWindowMs}:{}}),s=o.selection,a=0,l=Me();function u(){a++,l.emit()}i.subscribe(u);let c=e.currentEntryId(),d=s?[...s.get()]:void 0,f="active",h={targetId:n.targetId,forkedAtEntryId:c,applyBatch(m,g){if(f!=="active")throw new Error("Journal is not active");i.applyOps(m,g)},undo(){if(f!=="active")throw new Error("Journal is not active");i.undo()},redo(){if(f!=="active")throw new Error("Journal is not active");i.redo()},canUndo(){return i.canUndo()},canRedo(){return i.canRedo()},entries(){return i.entries()},seal(){i.seal()},observe:m=>i.observe(m),beginJournal(m){if(f!=="active")throw new Error("Journal is not active");return i.beginJournal(m)},getVersion:()=>a,subscribe:l.subscribe,commit(m){if(f!=="active")throw new Error("Journal is not active");let{forwardOps:g,baseOps:b}=m1(i).appliedOps();m1(e).record(g,b,m,d?{selectionBefore:d}:void 0),f="closed",Jm.delete(h),r?.(),u()},cancel(){if(f!=="active")throw new Error("Journal is not active");i.goto(0),f="closed",Jm.delete(h),r?.(),u()},suspend(){if(f!=="active")throw new Error("Journal is not active");f="suspended",r?.(),u()},isActive(){return f==="active"}};return Jm.set(h,()=>{if(f!=="suspended")throw new Error("Journal is not suspended");f="active",u()}),h}var I3=new WeakMap;function m1(e){let t=I3.get(e);if(!t)throw new Error("Not a history built by createHistory");return t}var SX={log:()=>{},warn:()=>{}};function Ec(e,t={}){let n=[],r=[],o=null,i=t.coalesceWindowMs??0,s=t.now??(()=>Date.now()),a=Math.max(0,t.historyLimit??1/0),l=t.onEvict,u=t.branching??!1,c=new Map,d=0,f=t.rebuildOp,p=t.selection,h=t.debug??SX,m=1,g=0,b=-1,x=Me(),w=Me();function y(G){g++,G&&w.size>0&&w.emit(typeof G=="function"?G():G),x.emit()}function P(G){if(l)for(let K of G)try{l({id:K.id,label:K.label,forwardOps:K.forwardOps,baseOps:K.baseOps})}catch($){h.warn(`onEvict callback threw for entry id=${K.id} "${K.label}": ${String($)}`)}}function S(G){P(G);for(let K of G){let $=c.get(K.id);if($){c.delete(K.id);for(let Q of $)S(Q)}}}function v(G){for(let K of G){l&&P([K]);let $=c.size>0?c.get(d):void 0;if($!==void 0&&c.delete(d),d=K.id,$!==void 0)for(let Q of $)S(Q)}}function A(){return n[n.length-1]?.id??d}function N(G){if(r.length===0)return;let K=r.splice(0);if(!u)return S(K);let $=c.get(G);$?$.push(K.reverse()):c.set(G,[K.reverse()])}function M(){for(;n.length>a;)v([n.shift()])}let C=k3(e,h);function F(G){return[...G.baseOps].reverse().map(K=>K.invert())}function B(){return p?[...p.get()]:void 0}function D(G){let K=B(),$=G.forwardOps!==G.baseOps;C(F(G),$?()=>G.forwardOps:void 0),K&&(G.selectionAfter=K),p&&G.selectionBefore&&p.set(G.selectionBefore)}function j(G){let K=B(),$=G.forwardOps!==G.baseOps;C(G.forwardOps,$?()=>F(G):void 0),K&&(G.selectionBefore=K),p&&G.selectionAfter&&p.set(G.selectionAfter)}function V(G){let K=[];for(;n.length>G;){let $=n[n.length-1];D($),n.pop(),r.push($),K.push($)}for(;n.length<G&&r.length>0;){let $=r[r.length-1];j($),r.pop(),n.push($),K.push($)}return K}function J(G,K){let $=typeof i=="function"?i():i;return!($>0)||G.coalesceKey!==void 0||g!==b||s()-G.timestamp>$?!1:S3(G.forwardOps,K)}function se(G,K){if(G.length===0)return;let $=B(),Q=[],te=C(G,void 0,Q),he=Q.length===0?G:G.filter(kt=>!(kt.elideNoop&&Q.includes(kt))),be=A3(he)?he.flatMap(kt=>kt.caused?.()??[kt]):he.slice();if(!te){h.warn(`'${K}' batch was a no-op \u2014 every op reported false/'noop'. Skipping the undo entry; consider gating the dispatch upstream to avoid the wasted work.`);return}if(be.length===0)return;let Fe=Ki(be),Se=n[n.length-1];if(Se&&J(Se,be)){if(Se.forwardOps=be,Se.timestamp=s(),Se.pushes++,Fe.size>0){let kt=new Set(Se.touchedIds);for(let Yt of Fe)kt.add(Yt);Se.touchedIds=kt}h.log(`coalesce '${K}' into entry id=${Se.id} (${be.length} ops)`),y(()=>({kind:"coalesce",entries:[{id:Se.id,label:Se.label,ops:be}]})),b=g;return}h.log(`push '${K}' (${be.length} ops)`);let ar=A(),Le={id:m++,forwardOps:be,baseOps:be,label:K,timestamp:s(),pushes:1,touchedIds:Fe,...$?{selectionBefore:$}:{}};n.push(Le),N(ar),M(),y(()=>sr("push",[Le])),b=g}function ke(G,K){v3(G,K,s()),y(()=>({kind:"coalesce",entries:[{id:G.id,label:G.label,ops:K}]})),b=g}function ae(G,K,$,Q={}){if(G.length===0)return;let te=Q.coalesceKey,he=n[n.length-1];if(te!==void 0&&he?.coalesceKey===te&&g===b&&G===K)return ke(he,G);let be=A(),Fe={id:m++,forwardOps:G,baseOps:K,label:$,timestamp:s(),pushes:1,touchedIds:Ki(G),...Q.selectionBefore?{selectionBefore:[...Q.selectionBefore]}:{},...te!==void 0?{coalesceKey:te}:{}};n.push(Fe),N(be),M(),y(()=>sr("push",[Fe])),te!==void 0&&(b=g)}let ve={apply(G,K){se([G],K??G.label??"")},applyOps(G,K){se(G,K)},undo(){n.length!==0&&y(sr("undo",V(n.length-1)))},redo(){r.length!==0&&y(sr("redo",V(n.length+1)))},seal(){b=-1},canUndo:()=>n.length>0,canRedo:()=>r.length>0,undoDepth:()=>n.length,redoDepth:()=>r.length,clear:()=>{let G=n.length>0||r.length>0||c.size>0;n.length=0,r.length=0,c.clear(),d=0,G&&y(sr("clear"))},entries(){return{undo:n.map(h1),redo:[...r].reverse().map(h1)}},goto(G){let K=n.length+r.length;if(G<0||G>K||G===n.length)return;let $=n.length,Q;try{Q=V(G)}catch(te){try{V($)}catch(he){h.warn(`goto: returning to depth ${$} threw: ${String(he)}`)}throw n.length!==$&&y(),te}y(sr("goto",Q))},timestampAt(G){if(!(G<0))return G<n.length?n[G].timestamp:r[r.length-1-(G-n.length)]?.timestamp},depthAt(G){let K=n.length;for(;K>0&&n[K-1].timestamp>G;)K--;if(K<n.length)return K;for(let $=r.length-1;$>=0&&r[$].timestamp<=G;$--)K++;return K},prune(G){let K=0;for(;K<n.length&&n[K].timestamp<G;)K++;if(K===0)return;let $=n.splice(0,K);v($),y(sr("prune",$))},branches(){let G=($,Q)=>{let te=$[0];return{id:te.id,label:te.label,timestamp:te.timestamp,length:$.length,current:Q}},K=(c.get(A())??[]).map($=>G($,!1));return r.length>0&&K.push(G([...r].reverse(),!0)),K.sort(($,Q)=>$.id-Q.id)},switchBranch(G){if(r[r.length-1]?.id===G)return;let K=A(),$=c.get(K)??[],Q=$.findIndex(he=>he[0].id===G);if(Q<0)throw new Error(`No branch ${G} forks from entry ${K}`);let[te]=$.splice(Q,1);r.length>0&&$.push(r.splice(0).reverse()),$.length>0?c.set(K,$):c.delete(K),r.push(...[...te].reverse()),y(sr("branch",te))},getVersion:()=>g,subscribe:x.subscribe,observe:w.subscribe,serialize:()=>P3({undoStack:n,redoStack:r,forks:c,floorId:d,nextEntryId:m},h),recordEntry(G,K,$){ae(G,G,K,$)},allForwardOps(){let G=[];for(let K of n)for(let $ of K.forwardOps)G.push($);return G},currentEntryId:()=>m,beginJournal(G){if(o!==null&&o.isActive())throw new Error("A journal is already active \u2014 commit, cancel, or suspend it first");let K=N3(ve,e,G,()=>{o=null},{coalesceWindowMs:i,now:s,debug:h,...p?{selection:p}:{}});return o=K,K},activeJournal:()=>o?.isActive()?o:null,resumeJournal(G){if(o!==null&&o!==G&&o.isActive())throw new Error("A journal is already active \u2014 commit, cancel, or suspend it first");R3(G),o=G},restore(G){let K=T3(G,f,h);n.splice(0,n.length,...K.undoStack),r.splice(0,r.length,...K.redoStack),c.clear();for(let[$,Q]of K.forks)c.set($,Q);d=K.floorId,m=K.nextEntryId,y(sr("restore"))}};return I3.set(ve,{appliedOps:()=>({forwardOps:n.flatMap(G=>G.forwardOps),baseOps:n.flatMap(G=>G.baseOps)}),record:ae}),ve}function E3(e,t){let n=new Map,r=new Set,o=i=>{r.clear();for(let[s,a]of i){r.add(s);let l=n.get(s);if(l){l.pose=a.pose,l.data=a.data,e.has(s,l)||e.set(s,l);continue}let u={pose:a.pose,data:a.data};n.set(s,u),e.set(s,u)}for(let[s,a]of n)r.has(s)||(n.delete(s),e.clear(s,a));e.commit()};return{set(i){o(kX(i))},show:o,others(){let i=new Map;for(let s of e.ids()){let a=t(s)??[],l=n.get(s);for(let u=a.length-1;u>=0;u--){let c=a[u];if(!(c===l||c.pose===void 0)){i.set(s,c.pose);break}}}return i},drop(){if(n.size!==0){for(let[i,s]of n)e.clear(i,s);n.clear(),e.commit()}}}}function*kX(e){for(let[t,n]of e)yield[t,{pose:n}]}var vX=Object.freeze({}),M3=new WeakMap;function AX(e,t){let n=M3.get(e);n===void 0&&M3.set(e,n=new WeakMap);let r=n.get(t);return r===void 0&&n.set(t,r=o=>t(e(o))),r}var RX={merge:AX,lerp:(e,t,n)=>n<.5?e:t};function C3(e){let t=DT({pose:ph(),alpha:Qw(),path:ph(),data:RX}),n=[],r=0,o=i=>{for(;n.length>i;)n.pop().fade({over:0});for(;n.length<i;){let s=n.length;n.push(t.cue({patch:yP(0,(a,l)=>e.get(l)?.[s]??vX,{writes:["pose","alpha","path","data"]})}))}t.sync(r++)};return o(1),{probe:(i,s)=>{t.probe(i,s)},publish:o,drop:i=>{t.drop(i)}}}function F3(){let e=new Map,t=new WeakMap,n=0,r=[],o=0,i=(s,a)=>{for(s>0&&r[s]--,a>0&&(r[a]=(r[a]??0)+1),a>o&&(o=a);o>0&&(r[o]??0)===0;)o--};return{plies:e,claim(s,a){let l=e.get(s);l===void 0&&e.set(s,l=[]);let u=l.indexOf(a);u>=0&&l.splice(u,1);let c=u>=0?void 0:t.get(a);c===void 0&&t.set(a,c=++n);let d=l.length;for(;d>0&&t.get(l[d-1])>c;)d--;l.splice(d,0,a),u<0&&i(l.length-1,l.length)},release(s,a){t.delete(a);let l=e.get(s),u=l?.indexOf(a)??-1;return l===void 0||u<0?!1:(l.splice(u,1),i(l.length+1,l.length),l.length===0&&e.delete(s),!0)},drop(s){let a=e.get(s);return a===void 0?!1:(e.delete(s),i(a.length,0),!0)},dropAll(){e.clear(),r.length=0,o=0},depth:()=>Math.max(o,1)}}var O3=e=>{let t=e;return t!==null&&typeof t=="object"&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"?t:null},y1=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height;function L3(e,t,n){for(let r=e.length-1;r>=0;r--){let o=e[r];if(o.path===void 0)continue;let i=O3(o.pose),s=O3(t);if(i===null||s===null||y1(i,s))return o.path;let a=n.carried;return a!==void 0&&a.source===o.path&&y1(a.from,i)&&y1(a.to,s)?a.path:(n.carried={source:o.path,from:{...i},to:{...s},path:nh(o.path,i,s)},n.carried.path)}}function g1(e,t){let n=F3(),{plies:r}=n,o=C3(r),i=Me(),s=0,a=new Map;function l(f){let p=e(f);if(p){ln(p);let h=a2(p);h&&ln(h)}t?.(f)}function u(){s++,o.publish(n.depth()),i.emit()}function c(f){a.delete(f),o.drop(f)}let d={set(f,p){n.claim(f,p),l(f),u()},get(f){return r.get(f)?.at(-1)},read(f){let p=r.get(f);if(p===void 0)return;let h=a.get(f);return h===void 0&&(h={out:{},at:-1},a.set(f,h)),h.at!==s&&(o.probe(f,h.out),h.out.path=L3(p,h.out.pose,h),h.at=s),h.out},has(f,p){let h=r.get(f);return h!==void 0&&(p===void 0||h.includes(p))},ids(){return[...r.keys()]},clear(f,p){(p===void 0?n.drop(f):n.release(f,p))&&(r.has(f)||c(f),l(f),u())},clearAll(){if(r.size!==0){for(let f of r.keys())c(f),l(f);n.dropAll(),u()}},commit(){for(let f of r.keys())l(f);u()},subscribe:i.subscribe,getGeneration(){return s},hold:()=>E3(d,f=>r.get(f))};return d}function Qm(e,t,n){let r={...e.placed?{placed:e.placed}:{}};return{name:"arrange",args:r,label:"Arrange",elideNoop:!0,get coalesceKey(){return r.placed===void 0?void 0:`arrange:${r.placed.map(o=>o.id).sort().join(",")}`},apply(o){r.placed===void 0&&(r.placed=t?.()??[]);let i=n??((s,a)=>o.setPose(s,a));for(let s of r.placed)i(s.id,s.to);return r.placed.length>0?void 0:"noop"},invert(){let o=r.placed??[];return Qm({placed:[...o].reverse().map(i=>({id:i.id,from:i.to,to:i.from}))},void 0,n)}}}p3("arrange",e=>Qm(e));function _3(e,t,n){let r=new Map;for(let[o,i]of t){let s=i.filter(a=>e.get(a)?.parent===o===n);s.length>0&&e.has(o)&&r.set(o,s)}return r}function D3(e){let{nodes:t}=e,n=null,r=!1,o=null,i=new Map,s=new Set,a=null,l=Me(),u=()=>n??(r?e.layoutPass:null);function c(m=!1){return o!==null||!m&&u()===null?!1:(o=new Map,i=new Map,s=new Set,a=null,!0)}function d(){let m=a;a=null,!(m===null||m.length===0)&&l.emit(m)}function f(){let m=o;o=null;let g=u();if(m===null||g===null)return[];let b=_3(t,m,!0),x=_3(t,i,!1);i=new Map;let w=new Set([...s].filter(S=>t.has(S)));if(b.size===0&&w.size===0)return[];let y=g(b,w,x);if(y===null)throw new Ka(b);let P=[];for(let[S,v]of y){let A=t.get(S);A&&P.push({id:S,from:A.pose,to:v})}return a=P,P}function p(){o=null,a=null}function h(m){return c(!0)?{ops:[...m,Qm({},f,e.writePose)],owned:!0}:{ops:m,owned:!1}}return{layoutDeclared:()=>{r=!0},setHandler(m){return n=m,()=>{n===m&&(n=null)}},onReflow:l.subscribe,noteArrival(m,g,b){if(o===null||g===null||g===b)return;s.add(g);let x=o.get(g);x===void 0?o.set(g,[m]):x.includes(m)||x.push(m)},noteDeparture(m,g,b){if(o===null||g===null||g===b||(s.add(g),o.get(g)?.includes(m)))return;let x=i.get(g);x===void 0?i.set(g,[m]):x.includes(m)||x.push(m)},noteChange(m){o!==null&&m!==null&&s.add(m)},bareLayoutEdit:()=>u()!==null&&o===null&&e.recordsBareEdits(),open:c,settle:f,emitReflow:d,abandon:p,runEdit(m,g){let{ops:b,owned:x}=h(m);if(!x)return g(b),!0;try{return g(b),d(),!0}catch(w){if(!(w instanceof Ka))throw w;return!1}finally{p()}}}}function B3(){let e=Me(),t=0,n=0,r=!1;return{notify(){if(t++,n>0){r=!0;return}e.emit()},version:()=>t,subscribe:e.subscribe,deferred(o,i){n++;try{return o()}finally{n--,i?.(),n===0&&r&&(r=!1,e.emit())}},muted(o){let i=r;n++;try{return o()}finally{n--,r=i}}}}function H3(e,t){return{subscribe:e.subscribe,getVersion:e.version,getContentVersion:()=>e.version()-t.changes()}}function G3(e){let t=new Map;return{seeOff(n,r,o,i){let s=new Map;for(let u of r){let c=s.get(u.parent);c?c.push(u):s.set(u.parent,[u])}let a=u=>{let c=e(u.id);if(!c)return null;let d=(s.get(u.id)??[]).map(a).filter(f=>f!==null);return{node:c.node,pose:c.pose,children:d}},l=n.map(u=>[u,a(u)]);return()=>{let u=new Set;for(let c of r){let d=i.get(c.id);d&&d.from===void 0&&u.add(c.id),i.delete(c.id)}for(let[c,d]of l)d&&!u.has(c.id)&&t.set(c.id,{id:c.id,parent:c.parent,...d,...o})}},takeBack(n){let r=t.get(n);return t.delete(n),r?.pose},drain(){if(t.size===0)return[];let n=[];for(let r of t.values()){let o=r.parent!==null?t.get(r.parent):void 0;o?o.children.push(r):n.push(r)}return t.clear(),n}}}var NX=()=>{};function U3(e){let t=Me(),n=new Map,r=G3(e.shown),o=null,i="call",s=0,a=0,l=0,u=0,c=()=>u>0&&l===0;function d(x){return s>0?{origin:x?"undo":"redo"}:a>0?{origin:"layout"}:e.untracked()?{origin:"untracked"}:o!==null?{origin:i,label:o}:{origin:"call"}}function f(x,w,y,P){if(!c())return;let S=n.get(x);S?S.to=y:n.set(x,{id:x,from:w,to:y,...d(P)})}function p(x,w){if(c())for(let y of x)n.set(y.id,{id:y.id,from:r.takeBack(y.id),to:y.pose,...d(w)})}let h=(x,w,y)=>c()?r.seeOff(x,w,d(y),n):NX;function m(x,w,y){w();try{return x()}finally{y()}}let g={"kit:setPose":x=>({...x,apply:w=>{x.apply(w);let y=w;f(y.id,y.from,y.to,!1)},revert:w=>{x.revert(w);let y=w;f(y.id,y.to,y.from,!0)}}),"kit:add":x=>({...x,apply:w=>{x.apply(w),c()&&p([w],!1)},revert:w=>{let y=h([w],[w],!0);x.revert(w),y()}}),"kit:remove":x=>({...x,apply:w=>{let y=w,P=h(y.detached,y.nodes,!1);x.apply(w),P()},revert:w=>{x.revert(w),p(w.nodes,!0)}})};function b(){let x=r.drain();if(n.size===0&&x.length===0)return;let w=[...n.values()].filter(y=>!qr(y.from,y.to));n.clear(),(w.length>0||x.length>0)&&t.emit(w,x)}return e.changes.subscribe(b),{subscribe(x){let w=t.subscribe(x);u++;let y=!0;return()=>{y&&(y=!1,u--,w())}},labeled(x,w,y){if(o!==null)return y();o=x,i=w;try{return y()}finally{o=null}},replaying:x=>m(x,()=>{s++},()=>{s--}),layout:x=>m(x,()=>{a++},()=>{a--}),quiet:x=>m(x,()=>{l++},()=>{l--}),reporting:x=>(w,y)=>x(w,g[w]?.(y)??y)}}function V3(){let e={batch:0,engine:0,untracked:0,own:0},t=0;return{open:()=>t>0,records:()=>e.engine+e.untracked===0,untracked:()=>e.untracked>0,during(n,r){e[n]++,t++;try{return r()}finally{e[n]--,t--}}}}var W3="kit:setDoc";function b1(e,t,n){n===void 0?e.delete(t):e.set(t,n)}function z3(e){return{toJSON(){return e.size===0?void 0:Object.fromEntries(e)},reset(t){e.clear();for(let[n,r]of Object.entries(t??{}))b1(e,n,r)}}}function K3(e){let{values:t}=e;return e.register(W3,{apply:n=>{let{key:r,to:o}=n;b1(t,r,o)},revert:n=>{let{key:r,from:o}=n;b1(t,r,o)}}),{get:n=>t.get(n),set(n,r){let o=t.get(n);qr(o,r)||e.record(W3,{key:n,from:o,to:r},"setDoc")},keys:()=>[...t.keys()]}}function Zm(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,r)=>Zm(n,t[r]));if(Jt(e)&&Jt(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(r=>r in t&&Zm(e[r],t[r]))}return!1}function j3(e,t,n){n===void 0?delete e[t]:e[t]=n}var $3={units:"kit:setUnits",clip:"kit:setClip"};function Y3(e){for(let n of["units","clip"])e.register($3[n],{apply:r=>{let{id:o,to:i}=r;j3(e.requireNode(o),n,i)},revert:r=>{let{id:o,from:i}=r;j3(e.requireNode(o),n,i)}});let t=(n,r,o)=>(i,s)=>{let a=e.requireNode(i)[n];e.refuse(i,o),!Zm(a,s??void 0)&&e.record($3[n],{id:i,from:a,to:s??void 0},r)};return{setUnits:t("units","setUnits","set the units of"),setClip:t("clip","setClip","set the clip of")}}function q3(e,t,n){let r=m3({data:e}),o=r?.foundHidden;if(!r||!o||o.length===0)return null;let i=Array.isArray(t)?t:[],s=new Set(o.map(u=>i[u])),a=(Array.isArray(n)?n:[]).flatMap((u,c)=>s.has(u)?[c]:[]);if(a.length===o.length&&a.every((u,c)=>u===o[c]))return null;let l={...r,foundHidden:a};return a.length===0&&delete l.foundHidden,{...e,pathEffect:l}}function X3(e){return{bounds:e?.bounds??(t=>{let n=p1(t);return n===null?null:{x:n.x,y:n.y,width:n.width,height:n.height}}),remap:e?.remap??((t,n,r)=>({...t,...r}))}}function x1(e,t,n,r){let o=e.bounds(n,t),i=e.bounds(r,t);return o===null||i===null?o!==i:o.width!==i.width||o.height!==i.height}var IX=16;function J3(e,t,n,r,o,i=new Map){let s=new Map,a=w=>s.get(w)??Mr(e,e.get(w)),l={getPose:w=>a(w),getParent:w=>e.get(w)?.parent??null,definesFrame:w=>{let y=e.get(w);return y===void 0||lt(y)}},{compose:u,decompose:c}=e.composition,d=w=>Vt(l,w,u),f=[...new Set([...n.keys(),...r])],p=new Map,h=(w,y)=>{let P=a(w);ko(P,y)||(s.set(w,y),w!==m&&t(w)!==null&&x1(o,w,P,y)&&f.push(w))},m=null,g=w=>{let y=h3(d(w),e.composition,S=>o.bounds(S,w),(S,v,A)=>o.remap(S,v,A,w));if(y===null)return null;let P=e.childrenOf(w).map(S=>({id:S,pose:y.toStrategy(d(S))}));return{...y,container:{id:w,bounds:y.bounds},children:P}},b=(w,y,P)=>{if(P.bounds){let S=e.get(w),v=y.toWorld(o.remap(y.upright,y.container.bounds,P.bounds,w));h(w,ta(l,v,S.parent,u,c))}for(let[S,v]of P.poses){let A=S;if(e.get(A)?.parent!==w)continue;let N=o.bounds(d(A),A);h(A,ta(l,y.toWorld(v),w,u,c)),x(A,N)}},x=(w,y)=>{let P=o.bounds(d(w),w);if(y===null||P===null)return;let S=P.x-y.x,v=P.y-y.y;if(S===0&&v===0)return;let A=m2({childrenOf:N=>e.childrenOf(N),poses:l,composition:e.composition},w,(N,M)=>{let C=o.bounds(N,M);return C===null?null:o.remap(N,C,{...C,x:C.x+S,y:C.y+v},M)});for(let[N,M]of A)h(N,M)};for(;f.length>0;){let w=f.shift();m=w;let y=(p.get(w)??0)+1;if(p.set(w,y),y>IX)continue;let P=t(w);if(P===null||e.get(w)===void 0)continue;let S=y===1?n.get(w):void 0,v=y===1?i.get(w):void 0,A=!1;if(v!==void 0&&P.depart){let N=g(w);if(N===null)continue;let M=new Set(S??[]),C=N.children.filter(F=>!M.has(F.id));b(w,N,P.depart(N.container,C,new Set(v))),A=!0}if(S!==void 0&&P.arrive){let N=g(w);if(N===null)continue;let M=P.arrive(N.container,N.children,new Set(S));if(M===null)return null;b(w,N,M)}else if(!A||S!==void 0){let N=g(w);if(N===null)continue;b(w,N,{poses:P.childPoses(N.container,N.children)})}}return s}function Q3(e){let{layoutFrame:t,layoutField:n,layoutRefs:r}=e,{requireNode:o,descendants:i}=e.store,{refuse:s,refuseLayer:a}=e.locks,{requireLayerIndex:l,assertSubtreeLayer:u}=e.layers,{record:c,edit:d,batch:f}=e.recorder,{noteChange:p,layoutDeclared:h}=e.arrivals;return{update(m,g){let b=o(m);s(m,"update"),c("kit:setData",{id:m,from:b.data,to:g.data},"update")},setPose(m,g){let b=o(m);s(m,"set the pose of");let x=b.layout!==void 0&&x1(t,m,b.pose,g),w=b.parent===null?void 0:o(b.parent),y=w?.layout!==void 0?w.id:null;d("setPose",x||y!==null,()=>{x&&p(m),p(y),c("kit:setPose",{id:m,from:b.pose,to:g},"setPose")})},setLayer(m,g){l(g);let b=o(m);if(s(m,"relayer"),b.layer!==g&&a(g,"move nodes onto"),b.parent!==null){let w=o(b.parent);u(m,g,b.parent,w.layer,"relayer")}if(b.layer===g)return;let x=[m];i(m,x);for(let w of x)s(w,"relayer");x.length===1?c("kit:setLayer",{id:m,from:b.layer,to:g},"setLayer"):f("setLayer",()=>{for(let w of x){let y=o(w);y.layer!==g&&c("kit:setLayer",{id:w,from:y.layer,to:g},"setLayer")}})},setDependsOn(m,g){let b=o(m);if(s(m,"retarget"),ZC(b.dependsOn,g))return;let x=q3(b.data,b.dependsOn,g);if(x===null)return void c("kit:setDependsOn",{id:m,from:b.dependsOn,to:g},"setDependsOn");f("setDependsOn",()=>{c("kit:setDependsOn",{id:m,from:b.dependsOn,to:g},"setDependsOn"),c("kit:setData",{id:m,from:b.data,to:x},"setDependsOn")})},setLayout(m,g){let b=o(m);s(m,"set the layout of");let x;if(typeof g=="string"){if(x=n.fnOf(g)??null,x===null)throw new Error(`Scene: no layout "${g}" in this scene's registry`)}else x=g;let w=b.layout??null;if(w===x)return;x!==null&&h();let y=w===null?void 0:n.keyOf(w),P=x===null?void 0:n.keyOf(x),S={id:m,...y!==void 0?{fromKey:y}:{},...P!==void 0?{toKey:P}:{}};r.set(S,{from:w,to:x}),d("setLayout",!0,()=>{p(m),c("kit:setLayout",S,"setLayout")})}}}function Z3(e,t){t===void 0?delete e.parallax:e.parallax=t}function eH(e){let{state:t,requireLayerIndex:n,rebuildLayerIndex:r}=e;function o(s,a){e.register(s,a)}o("kit:setLayerVisible",{apply:s=>{t.layers[n(s.layer)].visible=s.to,s.to||e.narrowSelection()},revert:s=>{t.layers[n(s.layer)].visible=s.from}}),o("kit:setLayerLocked",{apply:s=>{t.layers[n(s.layer)].locked=s.to,s.to&&e.narrowSelection()},revert:s=>{t.layers[n(s.layer)].locked=s.from}}),o("kit:setLayerParallax",{apply:s=>{Z3(t.layers[n(s.layer)],s.to)},revert:s=>{Z3(t.layers[n(s.layer)],s.from)}}),o("kit:addLayer",{apply:s=>{t.layers.splice(s.index,0,{...s.record}),r()},revert:s=>{t.layers.splice(s.index,1),r()}}),o("kit:removeLayer",{apply:s=>{t.layers.splice(s.index,1),r()},revert:s=>{t.layers.splice(s.index,0,{...s.record}),r()}}),o("kit:renameLayer",{apply:s=>{t.layers[n(s.layer)].name=s.to},revert:s=>{t.layers[n(s.layer)].name=s.from}});function i(s,a){let[l]=t.layers.splice(n(s),1);t.layers.splice(a,0,l),r()}o("kit:moveLayer",{apply:s=>i(s.layer,s.to),revert:s=>i(s.layer,s.from)})}function EX(e){let{detach:t,attach:n,invalidateChildDerivedFrom:r,invalidateDependents:o}=e.store;return(i,s,a,l)=>{t(i),n(i,a,l),r(s),o(i),s!==a&&e.narrowSelection()}}function tH(e){let{state:t,requireLayerIndex:n,invalidateOrder:r,fnFields:o}=e,{dependents:i,childDerived:s,invalidateDependents:a,invalidateChildDerivedFrom:l,trackChildDerived:u,retarget:c,requireNode:d,detach:f,attach:p,addedFns:h,restoreNodeFunctions:m}=e.store;function g(y,P){e.register(y,P)}let b=EX(e);g("kit:add",{apply:y=>{if(t.nodes.has(y.id))throw new Error(`Scene: id collision on "${y.id}"`);let P={kind:y.kind,id:y.id,layer:y.layer,pose:y.pose,data:y.data,parent:y.parent};t.nodes.set(y.id,P),p(y.id,y.parent,y.index),y.dependsOn!==void 0&&(P.dependsOn=y.dependsOn),Object.assign(P,ir(y)),e.noteWritten(P),i.add(y.id,y.dependsOn==="children"?[]:y.dependsOn??[]),u(y.id,y.dependsOn);let S=P,v=h.get(y);for(let A of o){let N=v?.get(A);if(N!==void 0){A.write(S,N);continue}let M=y[A.spec.opKey];M!==void 0&&Ic(A,S,M,"kit:add",Nt)}a(y.id)},revert:y=>{e.clearOverride(y.id),f(y.id),t.nodes.delete(y.id),i.remove(y.id),s.delete(y.id),l(y.parent),a(y.id)}}),g("kit:remove",{apply:y=>{for(let P of y.nodes)e.clearOverride(P.id);for(let P of y.detached)f(P.id);for(let P of y.nodes)t.nodes.delete(P.id),i.remove(P.id),s.delete(P.id);for(let P of y.detached)l(P.parent);e.narrowSelection(new Set(y.nodes.map(P=>P.id)))},revert:y=>{let P=new Map((y.fnKeys??[]).map(S=>[S.id,S]));for(let S of y.nodes){let v=S.children?{...S,children:[...S.children]}:{...S};m(v,P.get(S.id)),t.nodes.set(S.id,v),e.noteWritten(v),i.add(S.id,v.dependsOn==="children"?[]:v.dependsOn??[]),u(S.id,v.dependsOn)}for(let S of y.detached)p(S.id,S.parent,S.index);for(let S of y.detached)l(S.parent)}}),g("kit:setPose",{apply:y=>{d(y.id).pose=y.to,a(y.id)},revert:y=>{d(y.id).pose=y.from,a(y.id)}}),g("kit:setData",{apply:y=>{d(y.id).data=y.to,a(y.id)},revert:y=>{d(y.id).data=y.from,a(y.id)}}),g("kit:setLayer",{apply:y=>{n(y.to),d(y.id).layer=y.to,r(),a(y.id)},revert:y=>{d(y.id).layer=y.from,r(),a(y.id)}}),g("kit:setDependsOn",{apply:y=>{c(y.id,y.to)},revert:y=>{c(y.id,y.from)}});let x=new WeakMap;function w(y,P){let S=d(y.id),v=o.find(C=>C.spec.field==="layout"),A=x.get(y),N=P==="from"?y.fromKey:y.toKey;if(A===void 0&&N!==void 0){delete S.layout,Ic(v,S,N,"kit:setLayout",Nt);return}let M=A?.[P]??null;M===null?delete S.layout:v.write(S,M)}return g("kit:setLayout",{apply:y=>{w(y,"to")},revert:y=>{w(y,"from")}}),g("kit:move",{apply:y=>b(y.id,y.fromParent,y.toParent,y.toIndex),revert:y=>b(y.id,y.toParent,y.fromParent,y.fromIndex)}),eH(e),{layoutRefs:x}}function nH(e,t,n){n?e[t]=!0:delete e[t]}var rH={hidden:"kit:setHidden",locked:"kit:setLocked"};function oH(e){for(let n of["hidden","locked"])e.register(rH[n],{apply:r=>{let{id:o,to:i}=r,s=e.requireNode(o);nH(s,n,i),e.noteWritten(s),n==="hidden"&&e.invalidateDependents(o),i&&e.narrowSelection()},revert:r=>{let{id:o,from:i}=r,s=e.requireNode(o);nH(s,n,i),e.noteWritten(s),n==="hidden"&&e.invalidateDependents(o)}});let t=(n,r)=>(o,i)=>{let s=e.requireNode(o)[n]===!0;s!==i&&e.record(rH[n],{id:o,from:s,to:i},r)};return{setHidden:t("hidden","setHidden"),setLocked:t("locked","setLocked")}}function iH(e,t){function n(s){e.layers.length=0,e.layerIndex.clear(),t();for(let a of s){if(e.layerIndex.has(a.id))throw new Error(`Scene: duplicate ${a.kind} layer id "${a.id}"`);e.layerIndex.set(a.id,e.layers.length),e.layers.push(a)}}function r(s){let a=e.layerIndex.get(s);if(a===void 0)throw new Error(`Scene: unknown layer "${s}"`);return a}function o(){t(),e.layerIndex.clear();for(let s=0;s<e.layers.length;s++)e.layerIndex.set(e.layers[s].id,s)}function i(s,a,l,u,c="place"){if(r(a)<r(u)){let d=c==="place"?`cannot place node '${s??"<new>"}' on layer '${a}' under parent '${l}' on layer '${u}'`:`cannot setLayer('${s??"<new>"}', '${a}') \u2014 node has parent '${l}' on layer '${u}'`;throw new Error(`Scene: ${d} \u2014 a child may not render below its parent's layer`)}}return{reset:n,requireLayerIndex:r,rebuildLayerIndex:o,assertSubtreeLayer:i}}function MX(e,t,n,r){let o=new Map;for(let i=0;i<t.length;i++)o.set(t[i].id,i);for(let i of e.values()){if(i.parent===null)continue;let s=e.get(i.parent);if(s&&o.get(i.layer)<o.get(s.layer))throw new Error(`Scene: moveLayer("${n}", ${r}) \u2014 a child may not render below its parent's layer`)}}function sH(e){let{layers:t,nodes:n,requireLayerIndex:r,record:o}=e;function i(s,a){let l=t[r(s)];if(l.kind!=="user")throw new Error(`Scene: cannot ${a} system layer "${s}"`);return l}return{setLayerVisible(s,a){let l=t[r(s)];o("kit:setLayerVisible",{layer:s,from:l.visible,to:a},"setLayerVisible")},setLayerLocked(s,a){let l=t[r(s)];o("kit:setLayerLocked",{layer:s,from:l.locked,to:a},"setLayerLocked")},setLayerParallax(s,a){let l=t[r(s)];o("kit:setLayerParallax",{layer:s,from:l.parallax,to:a},"setLayerParallax")},addLayer(s){if(e.layerIndex.has(s.id))throw new Error(`Scene: duplicate layer id "${s.id}"`);let a=Math.max(0,Math.min(s.index??t.length,t.length)),l={kind:"user",id:s.id,name:s.name,visible:s.visible??!0,locked:s.locked??!1,...s.parallax?{parallax:s.parallax}:{},...s.annotation?{annotation:!0}:{}};o("kit:addLayer",{record:l,index:a},"addLayer")},removeLayer(s){let a=i(s,"remove");e.lifted(()=>e.batch("removeLayer",()=>{let l=[];for(let[u,c]of n)c.layer===s&&l.push(u);e.removeMany(l),o("kit:removeLayer",{record:a,index:r(s)},"removeLayer")}))},renameLayer(s,a){let l=i(s,"rename");o("kit:renameLayer",{layer:s,from:l.name,to:a},"renameLayer")},moveLayer(s,a){let l=r(s),u=Math.max(0,Math.min(a,t.length-1));if(l===u)return;let c=[...t],[d]=c.splice(l,1);c.splice(u,0,d),MX(n,c,s,a),o("kit:moveLayer",{layer:s,from:l,to:u},"moveLayer")}}}var ja=class extends Error{};function aH(e){let t=0,n=new WeakMap,r=a=>a===null||e.has(a),o=(a,l)=>{let u=e.get(a);return u===void 0||!$t(u)||u.children.every(c=>l?.has(c)===!0)};function i(a,l,u){switch(a){case"kit:add":{let c=l;return u?e.has(c.id)||!r(c.parent):!e.has(c.id)||!o(c.id)}case"kit:remove":{let c=l;if(!u)return c.nodes.some(f=>e.has(f.id))||!c.detached.every(f=>r(f.parent));let d=new Set(c.nodes.map(f=>f.id));return!c.nodes.every(f=>e.has(f.id)&&o(f.id,d))}case"kit:move":{let c=l;return!e.has(c.id)||!r(u?c.toParent:c.fromParent)}case"kit:setPose":case"kit:setData":case"kit:setLayer":case"kit:setDependsOn":case"kit:setLayout":case"kit:setUnits":case"kit:setClip":return!e.has(l.id);default:return!1}}function s(a,l,u){return t===0||typeof l!="object"||l===null?!1:n.get(l)===!u?n.delete(l):i(a,l,u)?(n.set(l,u),!0):!1}return{during(a){t++;try{return a()}finally{t--}},skips:s}}function CX(e,t,n,r){let o=e.map(a=>{let l=n.requireNode(a);return l.children?{...l,children:[...l.children]}:{...l}}),i=o.filter(a=>a.parent===null||!t.has(a.parent)).map(a=>({id:a.id,parent:a.parent,index:n.siblingsOf(a.parent).indexOf(a.id)})).sort((a,l)=>a.index-l.index),s=o.flatMap(a=>{let l=zi(r,a,"opKey");return Object.keys(l).length===0?[]:[{id:a.id,...l}]});return{nodes:o,detached:i,...s.length>0?{fnKeys:s}:{}}}function lH(e){let{nodes:t,fnFields:n}=e,{requireNode:r,siblingsOf:o,descendants:i,removalClosure:s,patchNodeFunctions:a}=e.store,{refuse:l,refuseLayer:u}=e.locks,{requireLayerIndex:c,assertSubtreeLayer:d}=e.layers,{record:f,edit:p}=e.recorder,{noteArrival:h,noteDeparture:m,noteChange:g}=e.arrivals;function b(w){let y=w.id??e.generateId();if(t.has(y))throw new ja(`Scene: id collision on "${y}"`);c(w.layer),u(w.layer,"add to");let P=w.parent??null;if(P!==null){let v=r(P);d(w.id,w.layer,P,v.layer),l(P,"add under")}let S={id:y,kind:w.kind,layer:w.layer,pose:w.pose,data:w.data,parent:P,index:w.index??o(P).length};return w.dependsOn!==void 0&&(S.dependsOn=w.dependsOn),Object.assign(S,ir(w),zi(n,w,"opKey"))}function x(w){if(w.length===0)return;let{ids:y,removing:P}=s(w);for(let A of y)l(A,"remove");let S=CX(y,P,e.store,n),{detached:v}=S;p("remove",v.some(A=>A.parent!==null),()=>{for(let A of v)m(A.id,A.parent,null);f("kit:remove",S,"remove")})}return{construct(w){e.locks.lifted(()=>{for(let y of w){let P=b(y);e.runOp("kit:add",P),a(y,P.id,null)}})},add(w){let y=b(w),P=`add ${w.kind}`;return p(P,y.parent!==null,()=>(h(y.id,y.parent,null),f("kit:add",y,P),a(w,y.id,y),y.id))},remove:w=>x([w]),removalClosure:w=>s(w).ids,removeMany:x,move(w,y,P){let S=r(w);if(l(w,"move"),y!==null){l(y,"move nodes into");let A=r(y);if(d(w,S.layer,y,A.layer),y===w)throw new Error("Scene: cannot parent a node to itself");let N=[];if(i(w,N),N.includes(y))throw new Error("Scene: cannot parent a node to its own descendant")}let v=S.parent;p("move",y!==null||v!==null,()=>{let A=o(v).indexOf(w),N=P??o(y).length;h(w,y,v),m(w,v,y),g(v),f("kit:move",{id:w,fromParent:v,fromIndex:A,toParent:y,toIndex:N},"move")})},reorder(w,y){let P=r(w);l(w,"reorder");let S=P.parent;p("reorder",S!==null,()=>{g(S);let v=o(S).indexOf(w);f("kit:move",{id:w,fromParent:S,fromIndex:v,toParent:S,toIndex:y},"reorder")})}}}function uH(e){let{state:t,store:n,locks:r,layers:o,fnFields:i,recorder:s,arrivals:a}=e,{layoutRefs:l}=tH({state:t,register:e.ops.register,store:n,requireLayerIndex:o.requireLayerIndex,rebuildLayerIndex:o.rebuildLayerIndex,invalidateOrder:e.invalidateOrder,fnFields:i,narrowSelection:e.narrowSelection,clearOverride:e.clearOverride,noteWritten:r.noteWritten}),{construct:u,...c}=lH({nodes:t.nodes,generateId:e.generateId,store:n,locks:r,layers:o,fnFields:i,runOp:e.ops.run,recorder:s,arrivals:a}),d=Q3({store:n,locks:r,layers:o,recorder:s,arrivals:a,layoutFrame:e.layoutFrame,layoutField:i.find(g=>g.spec.field==="layout"),layoutRefs:l}),f=sH({layers:t.layers,layerIndex:t.layerIndex,nodes:t.nodes,requireLayerIndex:o.requireLayerIndex,record:s.record,lifted:r.lifted,batch:s.batch,removeMany:c.removeMany}),p=oH({register:e.ops.register,requireNode:n.requireNode,record:s.record,narrowSelection:()=>e.narrowSelection(),invalidateDependents:n.invalidateDependents,noteWritten:r.noteWritten}),h=Y3({register:e.ops.register,requireNode:n.requireNode,refuse:r.refuse,record:s.record}),m=K3({values:t.docValues,register:e.ops.register,record:s.record});return{construct:u,methods:{...c,...d,...f,...p,...h,doc:m}}}var OX={log:e=>Xp("history",e),warn:e=>Nt("history",e)};function cH(e,t={}){let n=t.rebuildOp;return Ec(e,{debug:OX,...t,rebuildOp:(r,o)=>n?.(r,o)??Xm(r,o)})}function dH(e){let t=null;return{atomically(n,r){let o=t,i=[],s=e.getSelection();t=i;try{let a=n();return o&&!r()&&o.push(...i),a}catch(a){throw t=null,e.lifted(()=>{for(let l=i.length-1;l>=0;l--){let{kind:u,payload:c,reverted:d}=i[l],f=e.registered.get(u);(d?f.apply:f.revert)(c)}}),e.setSelection(s),i.length>0&&e.notify(),a}finally{t=o}},logApplied(n,r,o){t?.push(o===void 0?{kind:n,payload:r}:{kind:n,payload:r,reverted:o})}}}var FX=()=>({added:new Set,removed:new Set,posed:new Set,reparented:new Set,dataChanged:new Set,docChanged:new Set}),LX=e=>({added:new Set(e.added),removed:new Set(e.removed),posed:new Set(e.posed),reparented:new Set(e.reparented),dataChanged:new Set(e.dataChanged),docChanged:new Set(e.docChanged)}),fH={name:"editPass",args:{},elideNoop:!0,apply:()=>"noop",invert:()=>fH};function _X(e,t,n){let r=n;switch(t){case"kit:add":e.added.add(r.id);break;case"kit:remove":for(let o of r.nodes??[])e.removed.add(o.id);break;case"kit:setPose":e.posed.add(r.id);break;case"kit:setData":e.dataChanged.add(r.id);break;case"kit:setDoc":e.docChanged.add(r.key);break;case"kit:move":r.fromParent!==r.toParent&&e.reparented.add(r.id);break;default:break}}function pH(e){let t=[],n=null;function r(){let o=n;if(o===null)return 0;let i=0;try{for(let{pass:s}of[...t]){let a=s(LX(o));if(a===null)continue;let l=e.adapter();for(let u of a)u.apply(l),i++}}finally{n=null}return i}return{add(o,i){let s={pass:o,order:i?.order??0},a=t.findIndex(l=>l.order>s.order);return t.splice(a<0?t.length:a,0,s),()=>{let l=t.indexOf(s);l>=0&&t.splice(l,1)}},any:()=>t.length>0,open(){return n!==null||t.length===0?!1:(n=FX(),!0)},note(o,i){n!==null&&!e.untracked()&&_X(n,o,i)},run:r,abandon(){n=null},op(){return{name:"editPass",args:{},label:"Edit pass",elideNoop:!0,apply:()=>r()>0?void 0:"noop",invert:()=>fH}}}}function DX(e,t,n){let{replay:r,notify:o}=t,i={targetId:e.targetId,forkedAtEntryId:e.forkedAtEntryId,applyBatch(s,a){t.labeled(a,()=>t.runArrivalEdit(s,l=>{t.applying(()=>e.applyBatch(l.map(t.causing),a)),o()}))},undo(){r(()=>e.undo()),o()},redo(){r(()=>e.redo()),o()},canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),entries:()=>e.entries(),seal:()=>e.seal(),observe:s=>e.observe(s),beginJournal:s=>n.wrap(e.beginJournal(s)),getVersion:()=>e.getVersion(),subscribe:s=>e.subscribe(s),commit(s){e.commit(s),n.close(i),o()},cancel(){r(()=>e.cancel()),n.close(i),o()},suspend:()=>e.suspend(),isActive:()=>e.isActive()};return i}function hH(e){let t=new WeakMap,n=[],r={wrap(o){let i=DX(o,e,r);return t.set(i,o),n.push(i),i},close(o){let i=n.indexOf(o);i>=0&&n.splice(i,1)}};return{begin(o){let i=e.activeJournal();return r.wrap(i?(t.get(i)??i).beginJournal(o):e.engine.beginJournal(o))},resume:o=>e.engine.resumeJournal(t.get(o)??o),innermost(){for(let o=n.length-1;o>=0;o--)if(n[o].isActive())return n[o];return null}}}function yH(e){let{engine:t,replay:n,notify:r,refuseUntracked:o,runArrivalEdit:i}=e,s=hH(e);function a(d,f){return d()?(n(f),r(),!0):!1}let l=()=>e.activeJournal()??t,u={undo(){let d=e.activeJournal();return d?d.canUndo()?(d.undo(),!0):!1:a(()=>t.canUndo(),()=>t.undo())},redo(){let d=e.activeJournal();return d?d.canRedo()?(d.redo(),!0):!1:a(()=>t.canRedo(),()=>t.redo())},canUndo:()=>l().canUndo(),canRedo:()=>l().canRedo(),historyEntries(){let{undo:d,redo:f}=t.entries();return[...d,...f].map(p=>({id:String(p.id),label:p.label}))},historyIndex:()=>t.undoDepth(),jumpToHistoryIndex(d){let f=t.undoDepth()+t.redoDepth(),p=Math.max(0,Math.min(f,d));return a(()=>p!==t.undoDepth(),()=>t.goto(p))},serializeHistory:()=>({...t.serialize(),form:4}),restoreHistory(d){if(d.form!==4){Nt("scene","restoreHistory: snapshot is not in the current recorded form \u2014 dropped");return}t.restore(d),r()}};return{history:{apply(d,f){o("history.apply"),e.labeled(f??d.label??"",()=>i([d],p=>{let h=()=>p.length===1?t.apply(e.causing(d),f):t.applyOps(p.map(e.causing),f??d.label??"");e.applying(h),r()}))},applyOps(d,f){o("history.applyOps"),e.labeled(f,()=>i(d,p=>{e.applying(()=>t.applyOps(p.map(e.causing),f)),r()}))},undo:()=>{u.undo()},redo:()=>{u.redo()},goto:d=>{u.jumpToHistoryIndex(d)},clear(){t.clear(),r()},recordEntry(d,f,p){t.recordEntry(d,f,p),r()},prune(d){t.prune(d),r()},switchBranch(d){t.switchBranch(d),r()},restore:u.restoreHistory,canUndo:u.canUndo,canRedo:u.canRedo,undoDepth:()=>t.undoDepth(),redoDepth:()=>t.redoDepth(),entries:()=>t.entries(),timestampAt:d=>t.timestampAt(d),depthAt:d=>t.depthAt(d),branches:()=>t.branches(),getVersion:()=>t.getVersion(),subscribe:d=>t.subscribe(d),observe:d=>t.observe(d),serialize:u.serializeHistory,allForwardOps:()=>t.allForwardOps(),seal:()=>t.seal(),currentEntryId:()=>t.currentEntryId(),beginJournal:s.begin,resumeJournal:s.resume,activeJournal:()=>e.activeJournal()},methods:u,openJournal:s.innermost}}function gH(e){let t=new Map;function n(s){let a=t.get(s);if(!a)throw new Error(`Scene: no registered op for kind "${s}"`);return a}function r(s,a){let l;if(s.startsWith("kit:")){if(a===null||typeof a!="object")return;let u=a;l=typeof u.id=="string"?u.id:typeof u.layer=="string"?u.layer:void 0}else l=t.get(s)?.coalesceKey?.(a);return l===void 0?void 0:`${s}:${l}`}function o(s,a,l){let u=n(s);if(e.skips(s,a,l))return"noop";(l?u.apply:u.revert)(a),e.applied(s,a,!l)}function i(s,a,l=!0){return n(s),{name:s,args:a,coalesceKey:r(s,a),apply:()=>{if(e.driven())return o(s,a,l);let u;return e.replayAlone(()=>{u=o(s,a,l)}),u},invert:()=>i(s,a,!l)}}return{handlers:t,register:(s,a)=>{t.set(s,a)},run:(s,a)=>n(s).apply(a),op:(s,a)=>i(s,a)}}function Mc(e,t){return{name:e.name,args:e.args,label:e.label,get coalesceKey(){return e.coalesceKey},elideNoop:e.elideNoop,apply:()=>e.apply(t),invert:()=>Mc(e.invert(),t)}}function w1(e,t){return{name:e.name,args:e.args,label:e.label,get coalesceKey(){return e.coalesceKey},elideNoop:e.elideNoop,apply:()=>{let n=t();if(!n)return Nt("scene",`restored op "${e.name??"?"}" has no history adapter \u2014 skipping (setHistoryAdapter was not wired)`),"noop";try{return e.apply(n())}catch(r){return Nt("scene",`restored op "${e.name??"?"}" failed against the history adapter \u2014 skipping: ${String(r)}`),"noop"}},invert:()=>w1(e.invert(),t)}}function BX(e,t){let n=t===void 0||e.coalesceKey===void 0?void 0:`${t}>${e.coalesceKey}`;return{name:e.name,args:e.args,coalesceKey:n,apply:e.apply,invert:e.invert}}function bH(e){let t=null,n=e.getActiveJournal;function r(o,i=o){if(o.caused)return o;let s=[i];return{get name(){return o.name},get args(){return o.args},label:o.label,get coalesceKey(){return o.coalesceKey},elideNoop:o.elideNoop,apply(a){let{result:l,ops:u}=e.recorder().capturing(()=>i.apply(a));return u.length>0&&(s=u.map(c=>BX(c,o.coalesceKey))),l},caused:()=>s,invert:()=>i.invert()}}return{rebuild(o,i){let s=e.own(o,i);if(s!==null)return s;let a=Xm(o,i);return a===null?null:w1(a,()=>t)},causing:o=>r(o),apply(o,i,s,a){if(e.recorder().joins())return e.recorder().join(i,a);let l=e.openJournal()??n?.()??null;e.driving(()=>{let u=i.map(c=>r(c,Mc(c,a)));l?l.applyBatch(u,s):o.applyOps(u,s)})},setHistoryAdapter(o){t=o},setActiveJournalAccessor(o){n=o},activeJournal:()=>e.openJournal()??n?.()??null}}function xH(e){for(let t=e.length-1;t>=0;t--)try{e[t].invert().apply(void 0)}catch{}}function wH(e){let{notifier:t,mode:n,engine:r,log:o,arrivals:i,passes:s}=e,a=null,l=null;function u(f,p,h=!1){let m=f();if(p)for(let g of i.settle())e.writePose(g.id,g.to);return h&&s.run(),m}function c(f,p,h={}){let m=!n.open();m&&(a={label:f,ops:[],outer:[],entry:{selectionBefore:e.selection(),...h}});let g=m&&i.open(!0),b=m&&s.open();return e.labeled(f,"call",()=>t.deferred(()=>n.during("batch",()=>{if(!m)return p();try{let x=o.atomically(()=>u(p,g,b),()=>(a?.ops.length??0)>0);return g&&i.emitReflow(),x}catch(x){throw xH(a?.outer??[]),a=null,x}}),()=>{if(g&&i.abandon(),b&&s.abandon(),!m||!a)return;let x=a;a=null,x.ops.length>0&&r.recordEntry(x.ops,x.label,x.entry)}))}function d(f,p,h){if(n.records()&&!a&&s.any())return void c(h,()=>d(f,p,h));s.note(f,p),e.labeled(h,"call",()=>{n.records()&&!a?n.during("own",()=>r.applyOps([e.makeOp(f,p)],h)):(e.runOp(f,p),o.logApplied(f,p),n.records()?a.ops.push(e.makeOp(f,p)):n.untracked()||l?.push(e.makeOp(f,p)))}),t.notify()}return{record:d,edit:(f,p,h)=>p&&i.bareLayoutEdit()?c(f,h):h(),batch:c,untracked(f){let p=t.version(),h=i.open(!0);return t.deferred(()=>n.during("untracked",()=>{let m=o.atomically(()=>u(f,h),()=>!1);return h&&i.emitReflow(),m}),()=>{h&&i.abandon(),t.version()!==p&&r.seal()})},joins:()=>n.records()&&a!==null,join(f,p){let h=a,m=h.ops.length,g=[];try{o.atomically(()=>{for(let b of f){let x=h.ops.length,w=b.apply(p);h.ops.length>x||w===!1||w==="noop"||(g.push(Mc(b,p)),h.ops.push(g[g.length-1]))}},()=>!1)}catch(b){throw xH(g),h.ops.length=m,b}h.outer.push(...g)},capturing(f){let p=l,h=[];l=h;try{return{result:f(),ops:h}}finally{l=p}},engineDriven:f=>n.during("engine",()=>t.muted(f))}}function PH(e){let{notifier:t,mode:n,stale:r,lifted:o,selection:i,arrivals:s,config:a,poseWrites:l}=e,{notify:u}=t,c=pH({adapter:e.passAdapter,untracked:n.untracked}),d=(M,C)=>s.runEdit(M,F=>{if(!c.open())return C(F);try{C([...F,c.op()])}finally{c.abandon()}}),f=gH({driven:n.open,replayAlone:M=>{P(M),u()},skips:r.skips,applied:(M,C,F)=>{n.records()||b(M,C,F)}}),p=bH({own:(M,C)=>f.handlers.has(M)?f.op(M,C):null,recorder:()=>x,driving:M=>t.deferred(()=>n.during("engine",()=>g(M,()=>!0))),getActiveJournal:a.getActiveJournal??null,openJournal:()=>N()}),h=cH(void 0,{selection:{get:i.get,set:M=>i.set(M)},...a.coalesceWindowMs!==void 0?{coalesceWindowMs:a.coalesceWindowMs}:{},...a.historyLimit!==void 0?{historyLimit:a.historyLimit}:{},rebuildOp:p.rebuild}),m=dH({registered:f.handlers,lifted:o,getSelection:i.get,setSelection:i.replace,notify:u}),{atomically:g,logApplied:b}=m,x=wH({notifier:t,mode:n,engine:h,runOp:f.run,makeOp:f.op,log:m,arrivals:s,passes:c,selection:i.get,writePose:e.writePose,labeled:l.labeled}),{record:w,engineDriven:y}=x;function P(M){l.replaying(()=>g(()=>o(()=>r.during(()=>y(M))),()=>!0))}function S(M){if(n.untracked())throw new Error(`Scene: cannot ${M} inside untracked() \u2014 it records`)}let{history:v,methods:A,openJournal:N}=yH({engine:h,applying:M=>g(()=>y(M),()=>!0),causing:p.causing,replay:P,notify:u,refuseUntracked:S,runArrivalEdit:d,labeled:(M,C)=>l.labeled(M,"ops",C),activeJournal:p.activeJournal});return{ops:f,recorder:x,clearHistory:()=>h.clear(),methods:{registerOp(M,C){if(M.startsWith("kit:"))throw new Error(`Scene: op kind "${M}" is reserved (kit:* prefix)`);f.register(M,C)},recordOp(M){w(M.kind,M.payload,M.kind)},applyBatch(M,C,F){return S("applyBatch"),l.labeled(C,"ops",()=>d(M,B=>p.apply(h,B,C,F)))},history:v,...A,batch:x.batch,untracked:x.untracked,setActiveJournalAccessor:p.setActiveJournalAccessor,setHistoryAdapter:p.setHistoryAdapter,addEditPass:c.add}}}function TH(e,t){let n=s=>Pc(e(s),t),r=[],o=0,i=Me();return{get:()=>r,legal:n,set(s){r=n(s),o++,i.emit()},narrow(s){let a=s!==void 0&&r.some(l=>s.has(l))?r.filter(l=>!s.has(l)):r;r=n(a)},replace(s){r=s},subscribe:i.subscribe,changes:()=>o}}function SH(e){let t=0,n=!1,r={get layers(){return e.layers},get:i=>e.nodes.get(i)},o=i=>(n||e.layers.some(s=>s.locked))&&kB(r,i);return{isLocked:o,isHidden:i=>SB(r,i),refuse(i,s){if(!(t>0||!o(i)))throw new Error(`Scene: cannot ${s} "${i}" \u2014 it is locked`)},refuseLayer(i,s){if(!(t>0||!e.layers[e.layerIndex.get(i)??-1]?.locked))throw new Error(`Scene: cannot ${s} layer "${i}" \u2014 it is locked`)},reachable(i){if(i.length===0)return i;let s=Va(r);return i.some(a=>s.locked(a)||s.hidden(a))?i.filter(a=>!s.locked(a)&&!s.hidden(a)):i},noteWritten(i){i.locked===!0&&(n=!0)},lifted(i){t++;try{return i()}finally{t--}}}}function kH(e,t,n){let r=QC(),o=new Set;function i(x){if(s(e.nodes.get(x)?.parent??null),r.isEmpty())return;let w=[x];p(x,w);for(let y of w)for(let P of r.transitiveDependentsOf(y)){let S=e.nodes.get(P);S!==void 0&&ln(S)}}function s(x){if(o.size===0)return;let w=x;for(;w!==null;){let y=e.nodes.get(w);if(y===void 0)return;if(o.has(w)){ln(y);for(let P of r.transitiveDependentsOf(w)){let S=e.nodes.get(P);S!==void 0&&ln(S)}}w=y.parent}}function a(x,w){w==="children"?o.add(x):o.delete(x)}function l(x,w){let y=u(x);w===void 0?delete y.dependsOn:y.dependsOn=w,r.add(x,w===void 0||w==="children"?[]:w),a(x,w),ln(u(x)),i(x)}function u(x){let w=e.nodes.get(x);if(!w)throw new ja(`Scene: unknown node id "${x}"`);return w}function c(x){if(x===null)return e.roots;let w=u(x);return w.children??=[]}function d(x){let w=u(x),y=c(w.parent),P=y.indexOf(x);if(P<0)throw new Error(`Scene: node "${x}" not found in its parent's children`);return y.splice(P,1),t(),{parent:w.parent,index:P}}function f(x,w,y){let P=c(w),S=Math.max(0,Math.min(y,P.length));P.splice(S,0,x);let v=u(x);v.parent=w,t()}function p(x,w){let y=e.nodes.get(x);if(y?.children)for(let P of y.children)w.push(P),p(P,w)}function h(x){let w=[],y=new Set;function P(S){if(y.has(S))return;y.add(S),w.push(S);let v=[];p(S,v);for(let A of v)y.has(A)||(y.add(A),w.push(A))}for(let S of x)P(S);for(let S=0;S<w.length;S++)for(let v of r.transitiveDependentsOf(w[S]))P(v);return{ids:w,removing:y}}let m=new WeakMap;function g(x,w,y){let P=e.nodes.get(w);if(P===void 0)return;let S=new Map;for(let v of n){let A=x[v.spec.field];A!==void 0&&(v.write(P,A),S.set(v,A))}y&&S.size>0&&m.set(y,S)}function b(x,w){if(!w)return;let y=x;for(let P of n){if(P.read(y)!==void 0)continue;let S=w[P.spec.opKey];S!==void 0&&Ic(P,y,S,"kit:remove",Nt)}}return{dependents:r,childDerived:o,invalidateDependents:i,invalidateChildDerivedFrom:s,trackChildDerived:a,retarget:l,requireNode:u,siblingsOf:c,detach:d,attach:f,descendants:p,removalClosure:h,addedFns:m,patchNodeFunctions:g,restoreNodeFunctions:b}}function vH(e){function t(){return e.layers.length===1?l():c()}function n(){return e.layers.length===1?u():d()}let r=0,o={gen:0};function i(){r++}let s=[];function a(){return o.gen!==r&&(o={gen:r}),o}function l(){let f=e.layers[0].id,p=[],h=[...e.roots].reverse();for(;h.length>0;){let m=h.pop(),g=e.nodes.get(m);if(g&&(g.layer===f&&p.push(m),$t(g)))for(let b=g.children.length-1;b>=0;b--)h.push(g.children[b])}return p}function u(){let f=e.layers[0].id,p=[],h=[...e.roots].reverse();for(;h.length>0;){let m=h.pop(),g=e.nodes.get(m);if(g&&(g.layer===f&&p.push(g),$t(g)))for(let b=g.children.length-1;b>=0;b--)h.push(g.children[b])}return p}function c(){let f=e.layers.map(()=>[]),p=[...e.roots].reverse();for(;p.length>0;){let m=p.pop(),g=e.nodes.get(m);if(!g)continue;let b=f[e.layerIndex.get(g.layer)??-1];if(b&&b.push(m),$t(g))for(let x=g.children.length-1;x>=0;x--)p.push(g.children[x])}let h=[];for(let m of f)for(let g of m)h.push(g);return h}function d(){let f=e.layers.map(()=>[]),p=[...e.roots].reverse();for(;p.length>0;){let m=p.pop(),g=e.nodes.get(m);if(!g)continue;let b=f[e.layerIndex.get(g.layer)??-1];if(b&&b.push(g),$t(g))for(let x=g.children.length-1;x>=0;x--)p.push(g.children[x])}let h=[];for(let m of f)for(let g of m)h.push(g);return h}return{ids(){let f=a();return f.ids??=t()},nodes(){let f=a();return f.nodes??=n()},nodesOnLayer(f){let p=a(),h=p.byLayer;if(!h){h=new Map;for(let m of p.nodes??=n()){let g=h.get(m.layer);g||h.set(m.layer,g=[]),g.push(m)}p.byLayer=h}return h.get(f)??s},invalidate:i}}function AH(e,t){let n=[],r=[...e].reverse();for(;r.length>0;){let o=t.get(r.pop());if(o&&(n.push(o),$t(o)))for(let i=o.children.length-1;i>=0;i--)r.push(o.children[i])}return n}function P1(e,t){let n=new Map;for(let o of e)o.id!==void 0&&n.set(o.id,o);let r=o=>{let i=new Set,s=o.parent==null?void 0:n.get(o.parent);for(;s!==void 0&&s.id!==void 0&&!i.has(s.id);){if(lt(s))return s;i.add(s.id),s=s.parent==null?void 0:n.get(s.parent)}return null};return e.map(o=>{let i=r(o);return i===null?o:{...o,pose:t.decompose(i.pose,o.pose)}})}function S1(e){let t={id:e.id,visible:e.visible??!0,locked:e.locked??!1,...e.parallax?{parallax:e.parallax}:{},...e.annotation?{annotation:!0}:{}};return e.kind==="user"?{...t,kind:"user",name:e.name??e.id}:{...t,kind:"system"}}function RH(e,t,n){let r=[];for(let i of AH(e.roots,e.nodes)){let s=i.id,a={id:s,kind:i.kind,layer:i.layer,pose:i.pose,data:i.data};i.parent!=null&&(a.parent=i.parent),i.dependsOn==="children"?a.dependsOn="children":i.dependsOn&&i.dependsOn.length>0&&(a.dependsOn=i.dependsOn),i.pickable===!1&&(a.pickable=!1),i.hidden===!0&&(a.hidden=!0),i.locked===!0&&(a.locked=!0),i.units!==void 0&&(a.units=i.units),i.clip!==void 0&&(a.clip=i.clip),i.consumesChildren===!0&&(a.consumesChildren=!0),Object.assign(a,zi(t,i,"jsonKey",l=>{throw new Error(`Scene.toJSON: node '${s}' has ${l.spec.field} but no matching registry key. The function must be registered via createScene's registry option to round-trip.`)})),r.push(a)}return{version:3,systemLayers:e.layers.map(i=>{let s={id:i.id};return i.visible===!1&&(s.visible=!1),i.locked===!0&&(s.locked=!0),i.parallax&&(s.parallax=i.parallax),i.annotation&&(s.annotation=!0),i.kind==="user"&&(s.kind="user",s.name=i.name),s}),nodes:r,...n?{doc:n}:{}}}function ey(e,t,n={}){let r=HX(e,t,n);return e.version===3?r:P1(r,n.composition??Jp)}function HX(e,t,n){let r;if(e.version===1)r=e.nodes.map(o=>({n:o,kind:T1(1,o,n.classifyV1)}));else if(e.version===2||e.version===3)r=e.nodes.map(o=>({n:o,kind:T1(2,o)}));else throw new Error(`Scene: unsupported version ${String(Reflect.get(e,"version"))}; versions 1, 2 and 3 are supported`);return r.map(({n:o,kind:i})=>{let s={id:o.id,kind:i,layer:o.layer,pose:o.pose,data:o.data};o.parent!==void 0&&(s.parent=o.parent),o.pickable!==void 0&&(s.pickable=o.pickable),o.hidden===!0&&(s.hidden=!0),o.locked===!0&&(s.locked=!0),o.units!==void 0&&(s.units=o.units),o.clip!==void 0&&(s.clip=o.clip),o.consumesChildren===!0&&(s.consumesChildren=!0),o.dependsOn!==void 0&&(s.dependsOn=o.dependsOn==="children"?"children":o.dependsOn);let a=o;for(let l of Wa){let u=a[l.jsonKey];if(u===void 0)continue;let c=t[l.field]?.[u];if(!c&&n.unknownKeys==="skip"){n.onSkip?.({id:s.id,field:l.field,key:u});continue}if(!c)throw new Error(`Scene: unknown ${l.field} key '${u}'. Register a function with this key in the registry option.`);s[l.field]=c}return GX(e.version,s)&&(s.clip="outline"),s})}function GX(e,t){return e===1&&t.kind==="group"&&t.clipFromPose===void 0}function T1(e,t,n){return e===2?t.kind:t.kind==="leaf"?"mark":n?n(t):"group"}function NH(e){let t=new WeakMap,n=1;return{get:r=>e.get(r),incarnation(r){let o=e.get(r);if(!o)return;let i=t.get(o);return i===void 0&&(i=n++,t.set(o,i)),i},childrenOf(r){return e.get(r)?.children??[]},ancestorsOf(r){let o=[],i=e.get(r)?.parent??null;for(;i!==null;)o.push(i),i=e.get(i)?.parent??null;return o}}}function IH(e,t,n,r){let o={nodes:new Map,roots:[],layers:[],layerIndex:new Map,docValues:new Map},i=vH(o),s=$m(e,f=>{f==="layout"&&n()}),a=kH(o,i.invalidate,s),l=iH(o,i.invalidate);l.reset(t);let u=SH(o),c=z3(o.docValues);c.reset(r);let d={...NH(o.nodes),renderOrder:i.ids,renderOrderNodes:i.nodes,nodesOnLayer:i.nodesOnLayer,isLocked:f=>u.isLocked(f),isHidden:f=>u.isHidden(f),layoutOf(f){return o.nodes.get(f)?.layout??null},toJSON:()=>RH(o,s,c.toJSON())};return{state:o,order:i,locks:u,stale:aH(o.nodes),fnFields:s,store:a,layers:l,reads:d,docValues:c,reset(f,p){c.reset(p),a.dependents.clear(),a.childDerived.clear(),o.nodes.clear(),o.roots.length=0,l.reset(f)}}}function UX(e,t){let n=e.get(t);return n&&{node:n,pose:Yn(e,n)}}var VX=0,WX=()=>ue(`n${(VX++).toString(36)}-${Math.random().toString(36).slice(2,8)}`);function zX(e,t,n,r){if(t.length===0)throw new Error("Scene: systemLayers must declare at least one layer");let o=b3(e.registry??{}),i=IH(o,t,()=>h.layoutDeclared(),r),{state:s,locks:a,reads:l}=i,u=B3(),c=V3(),d=U3({untracked:c.untracked,changes:u,shown:v=>UX(P,v)}),f=(v,A)=>d.layout(()=>P.setPose(ue(v),A)),p=X3(e.layoutFrame),h=D3({nodes:s.nodes,layoutPass:(v,A,N)=>J3(P,l.layoutOf,v,A,p,N),recordsBareEdits:()=>!c.open(),writePose:f}),m=e.generateId??WX,g=TH(a.reachable,v=>s.nodes.get(v)?.parent);g.subscribe(u.notify);let b=g1(v=>s.nodes.get(v),i.store.invalidateDependents),x=h2(),w=PH({notifier:u,mode:c,passAdapter:()=>({...qm(P),...GB(P)}),stale:i.stale,lifted:a.lifted,selection:g,arrivals:h,writePose:f,poseWrites:d,config:e}),y=uH({state:s,store:i.store,locks:a,layers:i.layers,invalidateOrder:i.order.invalidate,fnFields:i.fnFields,ops:{...w.ops,register:d.reporting(w.ops.register)},recorder:w.recorder,arrivals:h,layoutFrame:p,generateId:m,narrowSelection:g.narrow,clearOverride:b.clear});for(let[v,A]of Object.entries(e.ops??{}))w.ops.register(v,A);let P={get nodes(){return s.nodes},get roots(){return s.roots},get layers(){return s.layers},registry:o,...l,mintId:m,composition:e.composition??Jp,...y.methods,...w.methods,unlocked:v=>a.lifted(v),setArrivalHandler:h.setHandler,onReflow:h.onReflow,onPoseWrite:d.subscribe,overrides:b,scroll:x,getSelection:g.get,setSelection:v=>g.set([...v]),loadState(v,A){let N=ey(v,o,{composition:P.composition,...A});if(c.open())throw new Error("Scene: cannot loadState inside another edit \u2014 it replaces the state that edit would revert to");b.clearAll(),x.clearAll(),i.reset(v.systemLayers.map(S1),v.doc),w.clearHistory(),d.quiet(()=>y.construct(N)),g.replace(g.legal(g.get().filter(M=>s.nodes.has(M)))),u.notify()},...H3(u,g)},S=n(o);return S&&(d.quiet(()=>y.construct(S)),u.notify()),P}function ty(e,t={}){return zX(t,e.systemLayers.map(S1),n=>ey(e,n,t),e.doc)}ee();var EH="__weaselHeadless";function MH(e){return Fg(e)}var jX=a1();function CH(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}async function $X(e){let{scene:t,screen:n,format:r,overlay:o,...i}=e,s={...i,scene:ty(MH(t)),...o?{overlay:o}:{},...n?{screen:Float64Array.from(n)}:{}};await l1({render:s});let a=jX.render(s);if(r==="png"){let u=await u1(a);return{width:a.width,height:a.height,base64:CH(new Uint8Array(await u.arrayBuffer()))}}let l=new Uint8Array(a.data.buffer,a.data.byteOffset,a.data.byteLength);return{width:a.width,height:a.height,base64:CH(l)}}var YX={render:$X};globalThis[EH]=YX;})();
430
+ };`),w_.set(n,r)}catch{P_=!0}}return r===void 0?(o,i)=>sY(e,o,i):r(e,S_)}function sY(e,t,n){for(let r=0;r<e.length;r++){let o=e[r],i=o.values[o.scalar?n:n*o.axes];if(o.op==="last"&&Number.isNaN(i))t[o.name]!==void 0&&(t[o.name]=void 0);else if(o.scalar)t[o.name]=i;else{let s=t[o.name],a=S_(o,n,s);a!==s&&(t[o.name]=a)}}}function aY(e,t){let n=t.spec,r=t.patch;return e.lanes!==null&&!e.projecting&&e.opts.history===void 0&&t.named===null&&n.target===void 0&&n.stagger===void 0&&n.role===void 0&&n.anchor===void 0&&n.from!=="current"&&typeof n.weight!="function"&&r.state===void 0&&r.step===void 0&&t.motion===void 0&&t.owner===null&&t.holding===null&&t.blend===null&&!t.freezesBefore&&!t.beginless&&t.slots.every(o=>{let i=e.channels[o];return i.rest!==void 0&&Jn(i)?.op!=="last"})}var lY=60;function uY(e){let t=e.sharers;for(let n=t.length-1;n>=0;n--){let r=t[n];r.built!==null||r.state==="pending"||r.state==="done"||++r.shared>=lY&&TT(e,r)}}function cY(e,t){if(t.everyone!==null)return t.everyone;let n=e.sinceOf(t,0);if(!(n<=e.now))return TT(e,t),null;let r=On(t,!0,void 0);return r.since=n,r.shown=e.shownOf(t,n),r.stepped=n,r.rebuilt=t.rebuilds,t.everyone=r,r}function wT(e,t){let n=e.sighted,r=t>>>5;return n!==null&&t>=0&&r<n.length&&(n[r]&1<<(t&31))!==0}function k_(e,t,n){let r=e.sighted,o=t>>>5;if(r===null||o>=r.length){let s=new Uint32Array(Math.max(o+1,(n>>>5)+1));r!==null&&s.set(r),e.sighted=s,r=s}let i=1<<(t&31);(r[o]&i)===0&&(r[o]=r[o]|i,e.seen++)}function PT(e,t){let n=e.weights;return n!==null&&t>=0&&t<n.length?n[t]:0}function gm(e,t,n,r){let o=e.weights;if(o===null||t>=o.length){if(n===0)return;let i=new Float64Array(Math.max(t+1,r));o!==null&&i.set(o),e.weights=i,o=i}o[t]=n}function Ha(e,t,n){if(e.built!==null)return;let r=e.stamps,o=n*2;if(t.stepped=t.since,r===null||o>=r.length){t.probed=Number.NaN,t.seeks=0,t.delta=null;return}let i=r[o+0];t.probed=i,t.seeks=r[o+1],t.delta=Number.isNaN(i)?null:e.deltas[n]??null}function vc(e,t,n,r){if(e.built!==null)return;let o=e.stamps,i=n*2;if(o===null||i>=o.length){if(Number.isNaN(t.probed))return;let s=new Float64Array(Math.max(n+1,r)*2).fill(Number.NaN);o!==null&&s.set(o),e.stamps=s,o=s,e.deltas??=[]}o[i+0]=t.probed,o[i+1]=t.seeks,e.deltas[n]=t.delta}function dY(e,t){let n=e.stamps,r=t*2;n!==null&&t>=0&&r<n.length&&(n[r+1]=-1),e.built!==null&&e.everyone!==null&&(e.everyone.seeks=-1)}function v_(e,t,n,r){if(wT(e,t)){let a=e.seen;k_(e,n,r),e.seen=a}let o=PT(e,t);(o!==0||e.weights!==null&&n<e.weights.length)&&gm(e,n,o,r);let i=e.stamps,s=t*2;if(i!==null&&s<i.length){let a=n*2;if(a>=i.length){let u=new Float64Array(Math.max(n+1,r)*2).fill(Number.NaN);u.set(i),e.stamps=u,i=u}i[a+0]=i[s+0],i[a+1]=i[s+1];let l=e.deltas;l[n]=l[t]??null}bm(e,t)}function bm(e,t){let n=e.sighted,r=t>>>5;n!==null&&r<n.length&&(n[r]=n[r]&~(1<<(t&31)));let o=e.weights;o!==null&&t<o.length&&(o[t]=0);let i=e.stamps,s=t*2;i!==null&&s<i.length&&(i[s+0]=Number.NaN,e.deltas[t]=null)}function TT(e,t,n=!1,r){if(!t.sharing)return;t.sharing=!1;let o=t.everyone;t.everyone=null;let i=e.sharers.indexOf(t);i>=0&&e.sharers.splice(i,1);let s=n?ut(e,r)?.slot??-1:-1;o!==null&&n&&(e.projecting||wT(t,s))?(s>=0&&bm(t,s),t.subjects.set(r,o)):t.holder===o&&(t.holder=null),e.lanes?.rerecord(t.id,(a,l)=>e.held(t,a,l)),t.state!=="done"&&e.steps.push(t,++e.version),e.unshared=!0,Uo(e),e.lanes?.refill()}function fY(e,t,n){t.weight=PT(e,n),Ha(e,t,n),bm(e,n)}var A_={shares:aY,outgrow:uY,everyoneOf:cY,sighted:wT,sight:k_,weightAt:PT,weighAt:gm,open:Ha,shut:vc,restamp:dY,unsight:bm,unshare:TT,inherit:fY};function Ua(e,t){return e-t*Math.round(e/t)}var Ga=Qn(4,0),ST=Qn(4,0);function kT(e,t,n,r){let o=r.length===n?r:Qn(n,0);for(let i=0;i<n;i++)o[i]=e[t+i];return o}function xm(e,t,n,r,o){if(e.turn>0){t[n]=t[n]+Ua(r,e.turn)*o;return}let i=e.axes;Ga=kT(t,n,i,Ga);let s=e.channel.fold(Ga,r,o);for(let a=0;a<i;a++)t[n+a]=s[a]}function R_(e,t,n,r,o,i){if(e.turn>0){xm(e,t,n,r[o],i);return}ST=kT(r,o,e.axes,ST),xm(e,t,n,ST,i)}function N_(e,t,n,r,o,i){if(e.turn>0){let l=t[n],u=r;t[n]=o===0?u:l+Ua(u-l,e.turn)*i;return}let s=e.axes,a=r;(o!==0||a.length!==s)&&(Ga=kT(t,n,s,Ga),a=e.channel.lerp(Ga,r,i));for(let l=0;l<s;l++)t[n+l]=a[l]}function I_(e,t){let n=e.values,r=e.axes;if(e.op!=="own"){n.fill(e.rest,0,t*r);return}let o=e.start;for(let i=0;i<t*r;i+=r)for(let s=0;s<r;s++)n[i+s]=o[s]}function Ac(e,t){if(e.length>=t)return e;let n=new Float64Array(t);return n.set(e),n}function E_(e,t){let n=e.cap;t.met.length<n&&(t.met=Ac(t.met,n),t.first=Ac(t.first,n),t.sum=Ac(t.sum,n));for(let r=0;r<t.values.length;r++){let o=t.values[r],i=t.taken[r],s=e.laned[r].axes;o!==void 0&&(t.values[r]=Ac(o,n*s)),i!==void 0&&(t.taken[r]=Ac(i,n))}if(t.inline=pY(t),!t.inline){e.into=t;try{for(let r of t.members){let o=r.voice;if(r.idle||o.state==="pending"||o.state==="done")continue;e.intoId=o.id,e.reset(r),r.elapsedNow=o.elapsedAt(e.now);let i=r.list,s=o.bound;s!==null&&XP(e,s);let a=e.fills;for(let l=0;l<i.length;l++){let u=i[l];if(s!==null&&!JP(s,u,a)){QP(e,r,l,u);continue}if(e.one(r,l,u)&&(Pm(e,t,u),t.sum[u]=t.sum[u]+r.data[l*8+2]),o.keeping)break}}}finally{e.into=null}}}function Pm(e,t,n){if(t.met[n]===e.fills)return;t.met[n]=e.fills,t.first[n]=e.intoId,t.sum[n]=0;let r=t.taken;for(let o=0;o<r.length;o++){let i=r[o];i!==void 0&&(i[n]=0)}}function wm(e,t,n,r){let o=e.arg,i=o[7],s=t.values[n.index],a=t.taken[n.index];if(s===void 0||a===void 0){M_(e,t,n,r,i);return}let l=o[0];Pm(e,t,r);let u=a[r],c=u+l;s[r]=u===0?i:Ct(s[r],i,l/c),a[r]=c}function M_(e,t,n,r,o){let i=e.arg[0];Pm(e,t,r);let s=n.index,a=t.values[s],l=t.taken[s];(a===void 0||l===void 0)&&(a=new Float64Array(e.cap*n.axes),l=new Float64Array(e.cap),t.values[s]=a,t.taken[s]=l);let u=l[r],c=u+i,d=i/c;if(!n.plain||!n.straight)N_(n,a,r*n.axes,o,u,d);else if(n.scalar)a[r]=u===0?o:Ct(a[r],o,d);else{let f=Array.isArray(o)||ArrayBuffer.isView(o)?o:null,p=r*n.axes;for(let h=0;h<n.axes;h++){let m=f===null?n.rest:f[h]??n.rest;a[p+h]=u===0?m:Ct(a[p+h],m,d)}}l[r]=c}function C_(e,t,n){let r=t.voice.id,o=e.fills,i=t.list;for(let s=0;s<i.length;s++){let a=i[s];n.met[a]!==o||n.first[a]!==r||n.sum[a]>0&&O_(e,n,a)}}function O_(e,t,n){for(let r=0;r<t.values.length;r++){let o=t.taken[r],i=o===void 0?0:o[n];if(!(i>0))continue;let s=i>1?1:i,a=e.laned[r],l=t.values[r],u=a.values,c=n*a.axes;if(!a.plain){R_(a,u,c,l,c,s);continue}for(let d=0;d<a.axes;d++)u[c+d]=Oe(a.op,u[c+d],l[c+d],s)}}function pY(e){if(!e.contiguous)return!1;let t=e.members,n=t[0].list;for(let r of t){let o=r.voice;if(r.idle||o.keeping||o.state==="pending"||o.state==="done")return!1;let i=r.list;if(i!==n){if(i.length!==n.length)return!1;for(let s=0;s<n.length;s++)if(i[s]!==n[s])return!1}}return!0}function F_(e,t){let n=t.members,r=e.arg;for(let s of n){e.reset(s),s.elapsedNow=s.voice.elapsedAt(e.now);let a=s.voice.bound;a!==null&&XP(e,a)}let o=e.fills,i=n[0].list;e.into=t;try{for(let s=0;s<i.length;s++){let a=i[s],l=0;for(let u=0;u<n.length;u++){let c=n[u];if(c.voice.keeping)continue;let d=c.voice.bound;if(d!==null&&!JP(d,a,o)){QP(e,c,s,a);continue}r[6]=c.mark,e.one(c,s,a)&&(Pm(e,t,a),l+=c.data[s*8+2])}l>0&&O_(e,t,a)}}finally{e.into=null}}function L_(e,t){let n=e.chans;for(let r=0;r<n.length;r++)e.values[r]=t[n[r].name]}function __(e,t){let n=e.chans;for(let r=0;r<n.length;r++)this.foldInto(n[r],t,e.values[r])}function D_(e,t,n){let r=e.length,o=this.arg,i=e[0];if(r>0){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Oe(i.op,l[t],s,o[0])}else o[7]=s,wm(this,a,i,t)}else this.foldInto(i,t,s)}if(i=e[1],r>1){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Oe(i.op,l[t],s,o[0])}else o[7]=s,wm(this,a,i,t)}else this.foldInto(i,t,s)}if(i=e[2],r>2){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Oe(i.op,l[t],s,o[0])}else o[7]=s,wm(this,a,i,t)}else this.foldInto(i,t,s)}for(let s=3;s<r;s++){i=e[s];let a=n[i.name];if(typeof a=="number"&&i.scalar&&i.plain){let l=this.into;if(l===null){let u=i.values;u[t]=Oe(i.op,u[t],a,o[0])}else o[7]=a,wm(this,l,i,t)}else this.foldInto(i,t,a)}}function B_(e,t,n){if(!e.plain){this.unplain(e,t,e.scalar?n[0]:n);return}let r=this.arg[0],o=e.values,i=t*e.axes;for(let s=0;s<e.axes;s++)o[i+s]=Oe(e.op,o[i+s],n[s],r)}function H_(e,t,n){if(n===void 0)return;if(this.into!==null){M_(this,this.into,e,t,n);return}if(!e.plain&&!this.unplain(e,t,n))return;let r=this.arg[0],o=e.values;if(e.scalar){o[t]=Oe(e.op,o[t],n,r);return}let i=t*e.axes,s=Array.isArray(n)||ArrayBuffer.isView(n)?n:null;for(let a=0;a<e.axes;a++){let l=s===null?e.rest:s[a]??e.rest;o[i+a]=Oe(e.op,o[i+a],l,r)}}function G_(e){let t=this.arg[0],n=this.folding,r=this.rec,o=n.chans.indexOf(e),i=r.bands??new Uint8Array(n.chans.length);r.bands=i;let s=i[o],a=this.host.passes(s===0?void 0:s===1,t);return i[o]=a?1:2,a}function U_(e,t,n){if(e.op==="last")return this.gate(e);let r=this.arg[0],o=e.values;return e.turn>0?o[t]=o[t]+Ua(n,e.turn)*r:xm(e,o,t*e.axes,n,r),!1}function W_(e,t){let n=t.voice,r=t.data,o=e.per,i=t.list,s=t.records,a=t.chans,l=t.values,u=a.length,c=e.fills,d=e.lately,f=n.elapsedAt(e.now);t.elapsedNow=f;let p=n.duration,h=n.passes,m=n.freezesBefore,g=n.freezesAfter,b=n.span,x=n.hidesPast,w=t.flat,y=n.parts!==null,P=Br(n.weight),S=0;for(let N=0;N<u;N++)S+=a[N].axes;t.nums.length<S&&(t.nums=new Float64Array(S)),t.kinds.length<u&&(t.kinds=new Uint8Array(u));let v=t.nums,A=t.kinds;for(let N=0;N<i.length;N++){let M=i[N],C=N*8;if(Ft(r,C,o,M*6,c),d>=0&&e.unread(M))continue;let F=f-r[C+0],B=F>b&&x?Number.NaN:kh(F,m,g,b);if(!(B>=0)){r[C+2]=0,kt(s[N]);continue}if(!w){let W=r[C+1];(!t.weighed||!Kt(W,t.weighedSince))&&(t.fade=e.host.envelope(n,W),t.weighed=!0,t.weighedSince=W)}let D=w&&!y?P:jt(n.weight,t.fade,e.parting(n,M));if(r[C+2]=D,(!t.read||!Kt(B,t.readAt))&&(e.readKeyed(n,Dr(B,p,h),t.delta,t.scratch),t.read=!0,t.readAt=B,e.gather(t,t.delta),hY(a,l,v,A)),!(D>0)){kt(s[N]);continue}let j=0;for(let W=0;W<u;W++){let J=a[W],se=J.axes,ke=A[W];if(ke===1){let ae=J.values,ve=M*se;for(let G=0;G<se;G++)ae[ve+G]=Oe(J.op,ae[ve+G],v[j+G],D)}else ke===2&&(e.folding=t,e.rec=s[N]??null,e.arg[0]=D,e.foldInto(J,M,l[W]));j+=se}}}function hY(e,t,n,r){let o=0;for(let i=0;i<e.length;i++){let s=e[i],a=t[i];if(a===void 0)r[i]=0;else if(!s.plain)r[i]=mY(s,a,n,o);else if(r[i]=1,s.scalar)n[o]=a;else{let l=Array.isArray(a)||ArrayBuffer.isView(a)?a:null;for(let u=0;u<s.axes;u++)n[o+u]=l===null?s.rest:l[u]??s.rest}o+=s.axes}}function mY(e,t,n,r){return e.turn>0?(n[r]=Ua(t,e.turn),1):2}var Tm=class{lanes;crowd;row;made;constructor(t,n,r,o=0){this.lanes=t,this.crowd=n,this.row=r,this.made=o}};function Hn(e,t){let n=t.seat;return n!==null&&n.lanes===e?n:null}function V_(e,t,n,r){let o=Hn(e,t);return o!==null&&o.crowd===n&&o.row===r}function yY(e,t){if(e.metCrowd||e.owes(t))return!1;let n=e.met,r=e.metN;if(e.owed.last(n,r))return!0;let o=Number.NEGATIVE_INFINITY;for(let i of e.lanes){let s=i.voice.id;if(s<=o)continue;let a=n.indexOf(s);(a<0||a>=r)&&(o=s)}for(let i of e.crowds)i.size>0&&(o=Math.max(o,i.hot[(i.size-1)*i.stride+7]));for(let i=0;i<r;i++){let s=n[i];if(s<=o||e.byId.get(s).group!==null)return!1}return!0}function z_(e,t,n,r,o){let i=e.per[t*6+1],s=i<0?-1-i:i;e.per[t*6+1]=e.epochs;let a=!1;e.metN=0,e.metCrowd=!1;let l=e.dense;for(let f=l.length-1;f>=0;f--){let p=l[f];if(p.epoch<=s)break;if(p.positionOf(t)>=0)continue;let h=e.host.meet(p.voice,n,r,t);h.reaches&&(p.add(t,h),p.idle&&Yt(e,t,1),e.met[e.metN++]=p.voice.id,a=!0)}let u=i<0?e.host.naming(n):void 0;if(u!==void 0)for(let f of u){let p=e.byId.get(f.id);if(p===void 0){xY(e,f,t,n,s,r)&&(a=!0,e.metCrowd=!0);continue}if(p.epoch<=s||p.positionOf(t)>=0)continue;let h=e.host.meet(f,n,r,t);h.reaches&&(p.add(t,h),p.idle&&Yt(e,t,1),e.met[e.metN++]=f.id,a=!0)}if(!a)return o;let c=e.met;for(let f=1;f<e.metN;f++){let p=c[f],h=f-1;for(;h>=0&&c[h]>p;h--)c[h+1]=c[h];c[h+1]=p}let d=t*6;if(o&&e.per[d+2]===0){let f=gY(e,t);if(f||yY(e,t))return bY(e,t,n,f)||e.owed.owe(t,e.met,e.metN),!0}return e.per[d+0]=e.fills,!1}function gY(e,t){if(e.foldsFill!==e.fills||e.metCrowd||e.owes(t))return!1;let n=e.folds,r=e.metN;if(n.length!==r)return!1;for(let o=0;o<r;o++)if(n[o]!==e.met[o])return!1;return!0}function bY(e,t,n,r){if(e.filling)return!1;let o=e.lately,i=t*6;if(o>=0&&!(e.per[i+3]>o||e.per[i+4]>o))return!1;let s=e.met,a=e.metN;for(let l=0;l<a&&!r;l++){let u=e.byId.get(s[l]),c=u.voice;if(u.ran!==e.fills||u.motion!==void 0||c.keeping||typeof c.spec.weight=="function"||c.sharing&&c.everyone===null)return!1}r||(e.folds=s.slice(0,a),e.foldsFill=e.fills),e.subjects[t]===void 0&&(e.subjects[t]=n,e.holding=!0),e.meeting=!0;try{for(let l=0;l<a;l++){let u=e.byId.get(s[l]),c=u.voice,d=u.positionOf(t);if(!c.sharing){e.one(u,d,t);continue}let f=c.everyone;Ha(c,f,t),e.one(u,d,t),c.keeping||vc(c,f,t,e.cap)}}finally{e.meeting=!1}for(let l=0;l<a;l++)e.byId.get(s[l]).voice.keeping&&(e.foldsFill=-1);return!0}function xY(e,t,n,r,o,i){let s=Hn(e,t);if(s===null)return!1;let a=s.crowd,l=s.row,u=l*a.stride,c=a.hot[u+0];if(a.hot[u+6]<=o||(c&16)!==0)return!1;let d=e.host.meet(t,r,i,n);if(!d.reaches)return!1;let f=l*8;return a.list[l]=n,e.placed.add(n,t.id),a.data[f+0]=d.delay,a.data[f+1]=d.shown,a.data[f+2]=0,a.data[f+3]=0,a.data[f+4]=-1,a.data[f+5]=-1,a.data[f+7]=0,a.records[l]=d,a.deltas[l]=null,a.restale(l,c|16),a.idle&&Yt(e,n,1),!0}function Yt(e,t,n){let r=t*6+2;e.per[r]=e.per[r]+n}var wY=Ha,PY=vc,TY=0;function SY(e){if(e<2)return 1;for(let t=e;;t++){let n=!0;for(let r=2;r*r<=t;r++)if(t%r===0){n=!1;break}if(n)return t}}function AT(e,t,n){qi(e);let r=e.host;e.filling=!0;let o=e.lookups;try{e.fills++,e.owed.begin(e.fills),e.now=t,e.filledAt=t,e.filledVersion=n;let i=e.numbers.size;e.keeps=r.keeps;let s=e.fresh;e.fresh=!1;let a=e.live>0?e.lastDistinct/e.live:1;e.lately=a<1?e.lastFrom:-1;let l=!1;for(let u of e.lanes){if(s){let c=u.line,d=u.list.length;d>=64?K_(e,u):d===1&&u.motion===void 0?u.idle||j_(e,u):(u.idle?a>=c.start:a<c.stop)&&vT(e,u)}u.idle||(l=!0)}for(let u of e.crowds)s&&(u.size>=64?K_(e,u):(u.idle?a>=u.line.start:a<u.line.stop)&&vT(e,u)),u.cursor=0,u.stale&&oL(u),!u.idle&&u.size>0&&(l=!0);if(l){for(let u of e.laned)I_(u,i);for(let u of e.roles)E_(e,u);for(let u of e.lanes)u.idle||(e.crowds.length>0&&(e.arg[6]=Number.NaN,jP(e,u.voice.id)),e.run(u));e.crowds.length>0&&(e.arg[6]=Number.NaN,jP(e,Number.POSITIVE_INFINITY));for(let u of e.crowds)u.idle||(u.bareFill=e.fills,u.bareNow=t)}e.busyFill=l?e.fills:0;for(let u of e.late)e.per[u*6+0]=e.fills;e.holding&&(e.subjects.fill(void 0,0,i),e.holding=!1),e.moved=pe.moved,e.inputs=pe.inputs,e.holds=e.lookups!==o}finally{e.filling=!1,e.late.length=0}}function K_(e,t){let n=t.list,r=t.line,o=e.lastFrom,i=e.lastTo,s=SY(Math.floor(n.length/256)),a=0,l=0;for(let c=e.fills%s;c<n.length;c+=s){let d=n[c];if(d<0)continue;let f=e.per[d*6+3],p=e.per[d*6+4];(f>o&&f<=i||p>o&&p<=i)&&l++,a++}let u=a>0?l/a:1;(t.idle?u>=r.start:u<r.stop)&&vT(e,t)}function vT(e,t){t.idle?RT(e,t):j_(e,t)}function j_(e,t){t.idle=!0;let n=t.list,r=t.data;for(let o=0;o<n.length;o++){let i=n[o];i<0||(Yt(e,i,1),Ft(r,o*8,e.per,i*6,e.fills))}}function RT(e,t){t.idle=!1;for(let n of t.list)n>=0&&Yt(e,n,-1)}function $_(e,t,n){let r=this.arg,o=r[5];if(Number.isNaN(n.probed))return this.late.push(t),!1;let i=this.subjectAt(t);return i===rr?(r[0]=0,!0):(this.host.signal(e,i,n,t),r[0]=jt(r[0],o,e.parts===null?1:this.host.parting(e,i)),!0)}function Y_(e,t){if(e.parts===null)return 1;let n=this.subjectAt(t);return n===rr?1:this.host.parting(e,n)}function q_(e){this.lookups++;let t=this.subjects[e];return t===void 0&&(t=this.numbers.subject(e),this.subjects[e]=t,this.holding=!0),t}function X_(e){let t=e.voice;e.placed=!1,this.arg[6]=Number.NaN,e.read=!1,e.weighed=!1,e.flat=!((t.fade.in??0)>0)&&t.out===null&&t.back===null&&t.owner===null,e.fade=1}function J_(e){let t=e.voice;if(t.state==="pending"||t.state==="done")return;let n=e.group;if(n!==null){n.inline?e===n.members[0]&&F_(this,n):C_(this,e,n);return}if(this.reset(e),e.ran=this.fills,e.motion!==void 0&&!t.keeping){eL(this,e,e.motion);return}if(t.built!==null&&typeof t.spec.weight!="function"){W_(this,e);return}e.elapsedNow=t.elapsedAt(this.now);let r=e.list;if(t.sharing){this.runEveryone(e);return}if(t.bound!==null){dL(this,e,t.bound);return}for(let o=0;o<r.length;o++)if(this.one(e,o,r[o]),t.keeping)return}function Q_(e){let t=e.voice,n=t.everyone,r=e.list,o=this.cap;for(let i=0;i<r.length;i++){let s=r[i];if(wY(t,n,s),this.one(e,i,s),t.keeping)return;PY(t,n,s,o)}}function Z_(e,t,n){let r=this.host,o=e.voice,i=e.elapsedNow,s=this.arg,a=e.data,l=t*8;if(Ft(a,l,this.per,n*6,this.fills),this.lately>=0&&this.unread(n))return!1;let u=a[l+0],c=i-u,d=c>=0?c>o.span?o.hidesPast?Number.NaN:o.freezesAfter?o.span:c:c:o.freezesBefore?0:Number.NaN;if(!(d>=0))return a[l+2]=0,kt(e.records[t]),!1;(!e.placed||!Kt(d,e.placedAt))&&(e.placed=!0,e.placedAt=d,e.phase=Dr(d,o.duration,o.passes),e.pass=Zn(d,o.duration,o.passes),s[6]=++TY,e.mark=s[6]);let f=a[l+1];!e.flat&&(!e.weighed||!Kt(f,e.weighedSince))&&(e.fade=r.envelope(o,f),e.weighed=!0,e.weighedSince=f);let p;if(typeof o.spec.weight=="function"){if(s[1]=d,s[3]=e.pass,s[5]=e.fade,!this.signalled(o,n,e.records[t]))return a[l+2]=0,kt(e.records[t]),!1;p=s[0]}else p=jt(o.weight,e.fade,this.parting(o,n));if(a[l+2]=p,p>0||kt(e.records[t]),this.folding=e,this.rec=e.records[t]??null,o.built!==null){if((!e.read||!Kt(d,e.readAt))&&(this.readKeyed(o,e.phase,e.delta,e.scratch),e.read=!0,e.readAt=d,this.gather(e,e.delta)),typeof o.spec.weight=="function"){let m=e.records[t];m.probed=this.now,m.seeks=o.seeks,m.delta=null}return p>0&&(s[0]=p,this.fold(e,n)),!0}let h=e.records[t];return Number.isNaN(h.probed)&&!this.meeting&&!e.every?(this.late.push(n),!1):(s[1]=d,s[4]=u,s[0]=p,e.motion!==void 0?(mc(this,e,e.motion,t,n,h),!0):(s[2]=e.phase,s[3]=e.pass,this.call(o,e.chans,h,n)))}function eD(e,t,n){let r=this.arg[2],o=this.arg[0],i=e.built,s=i.tracks;for(let a=0;a<s.length;a++){let l=s[a],u=t[a],c=MP(l,RP(l,r,i.duration),void 0);if(c===Vh)continue;if(c===ka){this.foldInto(u,n,Be.a);continue}let d=Be.a,f=Be.b,p=Be.eased;if(u.scalar||!u.plain||!u.straight){this.foldInto(u,n,e.lerps[a](d,f,p));continue}let h=d,m=f,g=u.values,b=n*u.axes,x=u.rest;for(let w=0;w<u.axes;w++){let y=Ct(h[w]??x,m[w]??x,p);g[b+w]=Oe(u.op,g[b+w],y,o)}}}function tD(e,t,n,r){zh(e.built,t,n,void 0,e.lerps,void 0,e.intos,r)}function nD(e,t,n,r){let o=this.arg,i=o[2],s=o[4],a=o[0],l=this.host,u=this.subjectAt(r);if(u===rr)return!1;if(n.probed===this.now&&n.delta!==null&&n.seeks===e.seeks)return a>0&&this.foldDelta(t,r,n.delta),!0;if(vh(e,a))return n.delta=null,n.probed=this.now,n.seeks=e.seeks,e.spec.role!==void 0;let c=pe.kept;l.ready(e,u,n),this.keeps?l.horizon(e,s):pe.horizon=Number.POSITIVE_INFINITY;let d=e.patch.at(i,u,e.setting);return n.delta=d,n.probed=this.now,n.seeks=e.seeks,this.keeps&&l.after(e,u,n),pe.kept!==c&&!e.keeping&&l.kept(e),a>0&&this.foldDelta(t,r,d),!0}var Sm=class{fill=new Int32Array(0);at=new Int32Array(0);lists=[];now=0;begin(t){this.now=t,this.lists.length=0}grow(t){let n=new Int32Array(t);n.set(this.fill),this.fill=n;let r=new Int32Array(t);r.set(this.at),this.at=r}any(){return this.lists.length>0}owes(t){return this.lists.length>0&&this.fill[t]===this.now}owesVoice(t,n){return this.lists[this.at[t]].includes(n)}owe(t,n,r){this.last(n,r)||this.lists.push(n.slice(0,r)),this.fill[t]=this.now,this.at[t]=this.lists.length-1}last(t,n){let r=this.lists[this.lists.length-1];if(r===void 0||r.length!==n)return!1;for(let o=0;o<n;o++)if(r[o]!==t[o])return!1;return!0}};var km=class{one=new Int32Array(0);rest=null;grow(t){let n=new Int32Array(t);n.set(this.one),this.one=n}any(t){return this.one[t]|0}all(t){let n=this.any(t);return n===0?[]:[n,...this.rest?.get(t)??[]]}add(t,n){if(this.one[t]===0){this.one[t]=n;return}this.rest??=new Map;let r=this.rest.get(t);r===void 0?this.rest.set(t,[n]):r.push(n)}remove(t,n){let r=this.rest?.get(t);if(this.one[t]===n)this.one[t]=r===void 0?0:r.pop();else if(r!==void 0){let o=r.indexOf(n);if(o<0)return;r[o]=r[r.length-1],r.pop()}else return;r!==void 0&&r.length===0&&this.rest.delete(t)}};function kY(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function IT(e,t,n){let r=t.list[n];r>=0&&(t.idle&&Yt(e,r,-1),e.placed.remove(r,t.voices[n].id)),t.list[n]=-1,t.records[n]=void 0,t.deltas[n]=null;let o=n*t.stride+0;t.hot[o]=t.hot[o]&-2065;let i=n*8;t.data[i+4]=-1,t.data[i+5]=-1,t.data[i+7]=0}function rD(e,t){let n=0;for(let o of t){if(!e.seats.has(o.id))return!1;n++}let r=0;for(let o of e.seats.values())o.crowd.voices[o.row].state!=="done"&&r++;return r===n}function oD(e,t){let n=new Set(t.map(i=>i.id));for(let i of e.crowds)for(let s=0;s<i.size;s++){let a=i.voices[s];(!n.has(a.id)||a.state==="done")&&aD(e,i,s)}let r=e.crowds,o=new Map(e.seats);for(let i of o.values())i.lanes=null;e.crowds=[],e.seats.clear(),e.overlap=!1;for(let i of t){let s=o.get(i.id);ET(e,i,s?.crowd,s?.row,r)}e.crowds.length===0&&(e.lawsByKey.clear(),e.lastLaw=null)}function ET(e,t,n,r,o){let i=t.slots.map(u=>e.bySlot[u]),s=e.crowds.find(u=>kY(u.chans,i));if(s===void 0){s=new rm(i,i[0].axes);let u=i.map(d=>d.name).join(" "),c=o.find(d=>d.chans.map(f=>f.name).join(" ")===u);c!==void 0&&(s.idle=c.idle);for(let d of e.crowds)d.chans.some(f=>i.includes(f))&&(e.overlap=!0);e.crowds.push(s)}let a=s.size;s.reserve(a+1),n!==void 0&&r!==void 0?iD(n,r,s,a):AY(e,s,a,t),s.hot[a*s.stride+6]===0&&t.state!=="pending"&&(s.hot[a*s.stride+6]=vm(e,t));let l=new Tm(e,s,a,n===void 0?e.probes:0);e.seats.set(t.id,l),t.seat=l,t.laned=!0}function MT(e,t,n,r){let o=n*t.stride;t.hot[o+6]===0&&r.state!=="pending"&&(t.hot[o+6]=vm(e,r)),t.hot[o+0]=t.hot[o+0]|64}function CT(e){for(let t of e.crowds)t.dead>64&&t.dead*4>=t.size&&vY(e,t)}function vY(e,t){let n=t.keys;t.keys=new Oa;let r=0;for(let o=0;o<t.size;o++){let i=t.voices[o],s=Hn(e,i);if(s===null||s.crowd!==t||s.row!==o){t.odd?.delete(o);continue}r!==o?(iD(t,o,t,r,n),t.odd?.delete(o),s.row=r):sD(n,t,r),r++}t.list.length=r,t.voices.length=r,t.records.length=r,t.deltas.length=r,t.motions.length=r,t.eases.length=r,t.laws.length=r,t.dead=0}function OT(e,t,n){let r=t.voices[n];aD(e,t,n),t.list[n]=-1,t.records[n]=void 0,t.deltas[n]=null,t.motions[n]=void 0,t.hot[n*t.stride+0]=0,e.seats.delete(r.id);let o=r.seat;o!==null&&o.lanes===e&&(o.lanes=null,r.seat=null),t.dead++}function NT(e,t,n,r,o){for(let i=0;i<o;i++)n[r+i]=e[t+i]}function iD(e,t,n,r,o=e.keys){e.fix(t),n.list[r]=e.list[t],NT(e.data,t*8,n.data,r*8,8),NT(e.hot,t*e.stride,n.hot,r*n.stride,e.stride),sD(o,n,r),(e.hot[t*e.stride+0]&4)!==0&&(n.stale=!0,n.staleRows.push(r)),NT(e.samples,t*e.axes,n.samples,r*n.axes,e.axes),n.deltas[r]=e.deltas[t]??null,n.records[r]=e.records[t],n.voices[r]=e.voices[t],n.motions[r]=e.motions[t],n.eases[r]=e.eases[t],n.laws[r]=e.laws[t];let i=e.odd?.get(t);i!==void 0&&(n.odd??=new Map,n.odd.set(r,i))}function sD(e,t,n){let r=n*t.stride;(t.hot[r+0]&512)!==0&&(t.hot[r+9]=t.keys.copy(e,t.hot[r+9]))}function AY(e,t,n,r){let o=Ln(r.patch),i=n*t.stride;t.hot.fill(0,i,i+t.stride);let s=r.built===null?-1:t.keys.add(r.built,t.chans);s>=0&&(t.hot[i+9]=s,t.hot[i+11]=r.duration,t.hot[i+10]=r.passes),t.restale(n,64|(o===void 0?0:128)|(o?.ease===void 0?0:1024)|(s>=0?512:0)),t.hot[i+7]=r.id,t.list[n]=-1;let a=n*8;if(t.data.fill(0,a,a+8),t.data[a+4]=-1,t.data[a+5]=-1,t.deltas[n]=null,t.records[n]=void 0,t.voices[n]=r,t.motions[n]=o,o===void 0){t.laws[n]=nL,t.eases[n]=void 0;return}t.laws[n]=RY(e,o),t.eases[n]=o.ease;let l=o.watcher===e?e.byId.get(o.watchId):void 0;if(l!==void 0)for(let u=0;u<l.list.length;u++)l.fix(u);o.watcher=e,o.watchId=r.id}function RY(e,t){let n=e.lastLaw;if(n!==null&&t.hasLaw(n))return n;let r=NY(e,t);return e.lastLaw=r,r}function NY(e,t){let n=t.law(),r=n.join(" "),o=e.lawsByKey.get(r);return o!==void 0?o:(e.lawsByKey.set(r,n),n)}function aD(e,t,n){let r=t.list[n],o=t.records[n];if(r>=0){e.placed.remove(r,t.voices[n].id),t.idle&&Yt(e,r,-1);let a=FT(e,t,n,r);o!==void 0&&a!==void 0&&(o.weight=a),o!==void 0&&t.motions[n]!==void 0&&yc(e,t,n,r,o)}let i=t.motions[n],s=t.voices[n];i!==void 0&&i.watcher===e&&i.watchId===s.id&&(i.watcher=null),s.laned=!1}function FT(e,t,n,r){let o=r*6;if(!(e.per[o+3]>e.per[o+4])||t.list[n]!==r)return;let i=Hn(e,t.voices[n])?.made??0;if(e.per[o+3]>i)return t.data[n*8+(e.per[o+5]===e.fills?2:3)]}function lD(e,t){let n=e.slice(),r=!0;for(;r;){r=!1;for(let s of t)if(!(s.fits&&s.slots.every(a=>n[a])))for(let a of s.slots)n[a]&&(n[a]=!1,r=!0)}let o=new Set,i=e.map(()=>!1);for(let s of t)if(!(!s.fits||!s.slots.every(a=>n[a]))){o.add(s.id);for(let a of s.slots)i[a]=!0}return{channels:i,voices:o}}function Am(e,t){qi(e);let n=e.host;e.qualifiedVersion=t,e.filledVersion=Number.NaN;let r=e.touched.slice();e.touched.length=0;let o=n.voices.filter(h=>h.state!=="done"&&h.holding===null);for(let h of o)h.id>e.known&&(e.known=h.id);let i=n.channels.map(h=>Jn(h)!==void 0),s=o.map(h=>h.slots.length>0&&n.fits(h));uD&&EY(o,s,n.channels);let a=()=>o.map((h,m)=>({id:h.id,fits:s[m],slots:h.slots})),{channels:l,voices:u}=lD(i,a());for(let h=!0;h;){h=!1;let m=new Map;o.forEach((g,b)=>{let x=g.spec.role;if(x===void 0)return;let w=m.get(x);w===void 0?m.set(x,[b]):w.push(b)});for(let g of m.values()){let b=g.filter(x=>u.has(o[x].id)).length;if(!(b===0||b===g.length)){for(let x of g)s[x]=!1;h=!0}}h&&({channels:l,voices:u}=lD(i,a()))}for(let h of e.lanes)u.has(h.voice.id)||cD(e,h);let c=[],d=0;for(let h of o){if(!u.has(h.id))continue;if(Yi(h)){d++;continue}let m=e.byId.get(h.id);m===void 0&&(m=new gc(h),m.made=e.probes),h.laned=!0,m.epoch===0&&h.state!=="pending"&&DT(e,m),c.push(m)}e.lanes=c,e.roles=[];let f=new Map;for(let h of c){h.group=null;let m=h.voice.spec.role;if(m===void 0)continue;let g=f.get(m);g===void 0&&(g={members:[],met:new Float64Array(e.cap),first:new Float64Array(e.cap),sum:new Float64Array(e.cap),values:[],taken:[],contiguous:!1,inline:!1},f.set(m,g),e.roles.push(g)),g.members.push(h),h.group=g}for(let[h,m]of f)m.contiguous=_Y(o,u,h,m.members);e.dense=c.filter(h=>h.voice.named===null&&h.epoch>0).sort((h,m)=>h.epoch-m.epoch),e.whole=c.length+d===o.length,e.byId.clear();for(let h of c)e.byId.set(h.voice.id,h);c.length===0&&d===0&&(e.subjects=[]);let p=o.filter(h=>u.has(h.id)&&Yi(h));if(MY(e,l)&&rD(e,p)){for(let h of c)h.chans=h.voice.slots.map(m=>e.bySlot[m]),h.values=h.chans.map(()=>{});for(let h of e.crowds)for(let m=0;m<h.size;m++){let g=h.voices[m];V_(e,g,h,m)&&g.state==="done"&&OT(e,h,m)}for(let h of r){if(h.state==="done")continue;let m=Hn(e,h);m!==null&&MT(e,m.crowd,m.row,h)}CT(e);return}e.laned=[],e.copier=null,e.bySlot=n.channels.map(()=>{}),l.forEach((h,m)=>{if(!h)return;let g=n.channels[m],b=Jn(g),x=g.rest??Number.NaN,w=typeof x=="number"&&b.axes===1,y=b.folds??b.op,P={name:n.names[m],op:y,plain:y!=="last"&&y!=="own"&&b.turn===void 0,straight:b.folds===void 0,turn:b.turn??0,channel:g,scalar:w,rest:typeof x=="number"?x:x[0],axes:b.axes,values:new Float64Array(e.cap*b.axes),start:typeof x=="number"?[]:x,index:e.laned.length};e.laned.push(P),e.bySlot[m]=P}),e.copies.length=0;for(let h of e.bySlot)e.copies.push(h!==void 0);for(let h of c)h.chans=h.voice.slots.map(m=>e.bySlot[m]),h.values=h.chans.map(()=>{});oD(e,p)}var uD=!0;function LT(e,t){return e.built===null&&e.motion===void 0&&e.slots.every(n=>IY(t[n]))}function IY(e){return Array.isArray(e.rest)&&Jn(e)?.op!=="last"}function EY(e,t,n){let r=new Array(n.length).fill(!1),o=new Array(n.length).fill(!1);e.forEach((i,s)=>{if(!t[s])return;let a=Yi(i);if(LT(i,n)){if(!a)for(let l of i.slots)o[l]&&(r[l]=!0),o[l]=!0}else for(let l of i.slots)r[l]=!0}),e.forEach((i,s)=>{t[s]&&LT(i,n)&&!i.slots.some(a=>r[a])&&(t[s]=!1)})}function MY(e,t){let n=e.bySlot;if(n.length!==t.length)return!1;for(let r=0;r<n.length;r++)if(n[r]!==void 0!==t[r])return!1;return!0}function vm(e,t){let n=++e.epochs;if(t.named===null)return e.wide=n,n;for(let r of t.named.list){let o=e.host.slotOf(r);if(o<0||o>=e.cap)continue;let i=o*6+1,s=e.per[i],a=s<0?-1-s:s;e.per[i]=-1-Math.min(a,n-1)}return n}function _T(e){let t=Bi(e.touched);e.touched=[];let n=0;for(let o=0;o<t.length;o++)(o===0||t[o]!==t[o-1])&&(t[n++]=t[o]);t.length=n;let r=()=>(e.touched=t,!1);for(let o of t){let i=o.id<=e.known;o.id>e.known&&(e.known=o.id);let s=Hn(e,o);if(s!==null){if(o.state==="done"){OT(e,s.crowd,s.row);continue}MT(e,s.crowd,s.row,o);continue}if(o.state==="done"&&!i)continue;let a=e.byId.get(o.id);if(a!==void 0){if(!LY(e,a))return r();continue}if(o.state==="done"||o.spec.role!==void 0)return r();let l=o.slots.some(c=>e.bySlot[c]!==void 0),u=o.slots.length>0&&e.host.fits(o);if(!l&&(!u||uD&&Yi(o)&&LT(o,e.host.channels))){e.whole=!1;continue}if(i||!u||!l||o.slots.some(c=>e.bySlot[c]===void 0))return r();Yi(o)?ET(e,o,void 0,void 0,e.crowds):FY(e,o)}return CT(e),e.lanes.length===0&&e.crowds.every(o=>o.dead===o.size)&&(e.subjects=[]),!0}function DT(e,t){let n=t.voice;t.epoch=vm(e,n),n.named===null&&n.spec.target===void 0&&(t.reserve(e.live,e.cap),CY(e,t)&&OY(e,t))}function CY(e,t){let n=t.voice;return n.sharing&&n.everyone!==null&&t.motion===void 0&&!n.keeping&&typeof n.spec.weight!="function"&&t.list.length===0&&e.lastDistinct>=e.live}function OY(e,t){let n=t.voice.everyone,r=e.numbers,o=Math.min(r.size,e.cap);for(let i=0;i<o;i++)r.has(i)&&(t.add(i,n),t.idle&&Yt(e,i,1));t.every=!0}function FY(e,t){let n=new gc(t);n.made=e.probes,t.laned=!0,t.state!=="pending"&&DT(e,n),n.chans=t.slots.map(r=>e.bySlot[r]),n.values=n.chans.map(()=>{}),e.lanes.push(n),e.byId.set(t.id,n),t.named===null&&n.epoch>0&&e.dense.push(n)}function LY(e,t){let n=t.voice;if(n.state!=="done")return t.epoch===0&&n.state!=="pending"&&(DT(e,t),n.named===null&&e.dense.push(t)),!0;if(t.group!==null)return!1;cD(e,t),e.lanes.splice(e.lanes.indexOf(t),1);let r=e.dense.indexOf(t);return r>=0&&e.dense.splice(r,1),e.byId.delete(n.id),!0}function cD(e,t){t.idle&&RT(e,t);let n=t.voice.state==="done";if(!n||t.motion!==void 0)for(let o=0;o<t.list.length;o++){let i=t.records[o],s=t.list[o],a=n?void 0:e.reported(t,s);i!==void 0&&a!==void 0&&(t.voice.sharing?gm(t.voice,s,a,e.cap):i.weight=a),i!==void 0&&t.motion!==void 0&&yc(e,t,o,s,i)}let r=t.motion;if(r!==void 0&&r.watcher===e&&r.watchId===t.voice.id){for(let o=0;o<t.list.length;o++)t.fix(o);r.watcher=null}t.voice.laned=!1}function _Y(e,t,n,r){for(let s=1;s<r.length;s++)if(r[s].voice.id<=r[s-1].voice.id)return!1;let o=r[0].voice.id,i=r[r.length-1].voice.id;for(let s of e)if(s.id>o&&s.id<i&&t.has(s.id)&&s.spec.role!==n)return!1;return!0}function fD(e,t,n,r){let o=e.lanes,i=n.slot;if(i<0||o.filling||o.host.keeps||e.projecting||o.roles.length>0||o.owed.any()||o.lanes.some(u=>u.voice.bound!==null)||!o.numbers.move(i,r))return!1;for(let u of o.lanes)u.renumber(i,r);let s=o.placed;for(let u of s.all(i)){s.remove(i,u);let c=o.seats.get(u);c===void 0||c.crowd.list[c.row]!==i||(c.crowd.list[c.row]=r,s.add(r,u))}let a=o.per;a.copyWithin(r*6,i*6,(i+1)*6),a[i*6+0]=o.fills,o.unlinked[r]=o.unlinked[i],o.subjects[r]=o.subjects[i],o.subjects[i]=void 0;for(let u of o.laned)u.values.copyWithin(r*u.axes,i*u.axes,(i+1)*u.axes);e.places?.forgot(i),e.places?.number(t,r);let l=o.cap;for(let u of e.general)OP(u,i,r),v_(u,i,r,l),dD(e,u,i,r);for(let u of Bo(e).general)OP(u,i,r);for(let u=n;u!==null;u=u.next)u.voice!==null&&dD(e,u.voice,i,r);return n.slot=r,!0}function dD(e,t,n,r){let o=t.blend?.of;if(!(o===void 0||n>=o.frames.length||o.frames[n]!==e.frame)){if(r>=o.frames.length){let i=Math.max(r+1,o.frames.length*2,64),s=new Float64Array(i),a=new Float64Array(i);s.set(o.frames),a.set(o.values),o.frames=s,o.values=a}o.frames[r]=e.frame,o.values[r]=o.values[n],o.frames[n]=Number.NaN}}var Rc=class{host;static share=A_;pulls={pullRun:y_,writeLater:g_,flush:qi,renumber:fD};numbers;lanes=[];dense=[];byId=new Map;crowds=[];seats=new Map;placed=new km;unlinked=new Float64Array(0);overlap=!1;roles=[];folding=null;meeting=!1;folds=[];foldsFill=-1;rec=null;arg=new Float64Array(8);into=null;intoId=0;lawsByKey=new Map;lastLaw=null;met=[];metN=0;metCrowd=!1;owed=new Sm;laned=[];copier=null;bySlot=[];copies=[];whole=!1;cap=0;epochs=0;wide=0;touched=[];known=0;per=new Float64Array(0);fills=0;busyFill=0;probes=0;subjects=[];holding=!1;holds=!0;lookups=0;filling=!1;late=[];queueSlots=new Int32Array(0);queueRows=new Int32Array(0);queueCounts=new Int32Array(0);queued=0;queuedFor=null;queueFrom=null;keeps=!1;now=Number.NaN;filledAt=Number.NaN;moved=0;inputs=0;frameAt=Number.NaN;frameProbes=0;lastFrom=0;lastTo=0;fresh=!1;distinct=0;lastDistinct=0;live=0;lately=-1;filledVersion=Number.NaN;qualifiedVersion=Number.NaN;constructor(t,n){if(this.host=t,n===void 0){this.numbers=new Dh(this);return}this.numbers=n.numbers,this.numbers.adopt(this),this.live=n.live;let r=this.numbers.size;this.grow(r);let o=this.per;for(let i=0;i<r;i++)o[i*6+0]=Number.NaN,o[i*6+1]=-1}invalidate(){this.qualifiedVersion=Number.NaN,this.filledVersion=Number.NaN}refill(){this.filledVersion=Number.NaN}touch(t){this.touched.push(t),this.filledVersion=Number.NaN}number(t){let n=this.numbers.take(t);return this.live++,this.grow(n+1),this.per[n*6+0]=this.fills,this.per[n*6+1]=-1,this.per[n*6+2]=0,this.per[n*6+3]=0,this.per[n*6+4]=0,this.per[n*6+5]=0,this.filling&&this.late.push(n),n}release(t){this.numbers.release(t)}sought(t){return Number.isNaN(this.per[t*6+0])}renew(t){return this.sought(t)?(this.per[t*6+0]=this.fills,this.filling&&this.late.push(t),!0):!1}part(t,n){let r=this.byId.get(t);if(r!==void 0){if(r.positionOf(n)<0)return;r.idle&&Yt(this,n,-1),r.remove(n);return}let o=this.seats.get(t);o!==void 0&&o.crowd.list[o.row]===n&&IT(this,o.crowd,o.row)}rejoin(t){t<this.cap&&(this.per[t*6+1]=-1)}weightOf(t,n){if(n<0)return;let r=this.byId.get(t);if(r!==void 0)return this.reported(r,n);let o=this.seats.get(t);return o===void 0?void 0:FT(this,o.crowd,o.row,n)}reported(t,n){let r=n*6,o=this.per[r+3];if(!(o>this.per[r+4])||!(o>t.made))return;let i=t.positionOf(n);if(!(i<0))return t.data[i*8+(this.per[r+5]===this.fills?2:3)]}prepare(t,n,r,o){let i=this.host.clock.now;if(!this.filled(i,r)&&this.begin(i,r)===0)return this.general(t);if(t<0)return!1;this.probedThisFrame(t)||this.distinct++;let s=++this.probes,a=this.per,l=t*6,u=a[l+0]<this.busyFill&&a[l+2]===0;return a[l+1]<this.wide&&(u=z_(this,t,n,o,u)),u?(a[l+3]=s,a[l+5]=this.fills,this.holds&&(this.subjects[t]=n,this.holding=!0)):a[l+4]=s,u}filled(t,n){return this.frameAt===t&&this.qualifiedVersion===n&&this.touched.length===0&&!this.filling&&this.current(t,n)}current(t,n){return this.filledAt===t&&this.filledVersion===n&&this.moved===pe.moved&&this.inputs===pe.inputs}begin(t,n){if(t!==this.frameAt&&(this.lastFrom=this.frameProbes,this.lastTo=this.probes,this.lastDistinct=this.distinct,this.distinct=0,this.frameAt=t,this.frameProbes=this.probes,this.fresh=!0),this.filling||(this.qualifiedVersion!==n?!Number.isNaN(this.qualifiedVersion)&&this.touched.length>0&&_T(this)?this.qualifiedVersion=n:Am(this,n):this.touched.length>0&&!_T(this)&&Am(this,n),this.laned.length===0))return 0;if(!this.current(t,n)&&(AT(this,t,n),this.qualifiedVersion!==n)){if(Am(this,n),this.laned.length===0)return 0;AT(this,t,n)}return 1}general(t){return t>=0&&(this.per[t*6+4]=++this.probes),!1}unread(t){let n=this.per,r=t*6,o=this.lately;return n[r+3]>o||n[r+4]>o?!1:(n[r+0]=this.fills,!0)}probedThisFrame(t){let n=this.frameProbes,r=t*6;return this.per[r+3]>n||this.per[r+4]>n}owes(t){return this.owed.owes(t)}owesVoice(t,n){return this.owed.owesVoice(t,n)}paid(t,n,r){let o=this.byId.get(t),i=o===void 0?-1:o.positionOf(n);if(i<0)return;o.data[i*8+2]=r;let s=o.voice.bound;s!==null&&r!==0&&lm(s,n,this.fills)}rests(t){for(let n of this.laned){let r=n.values;if(n.op==="last"){if(!Number.isNaN(r[t*n.axes]))return!1;continue}if(n.scalar){if(!(Math.abs(r[t]-n.rest)<1e-9))return!1;continue}if(n.start.length<n.axes)return!1;let o=t*n.axes;for(let i=0;i<n.axes;i++)if(!(Math.abs(r[o+i]-n.start[i])<1e-9))return!1}return!0}forget(t){this.host.forgot(t),this.live--;for(let r of this.lanes)r.remove(t);let n=this.placed;for(let r=n.any(t);r!==0;r=n.any(t)){let o=this.seats.get(r);o!==void 0&&o.crowd.list[o.row]===t?IT(this,o.crowd,o.row):n.remove(t,r)}t<this.cap&&(this.per[t*6+0]=this.fills),this.subjects[t]=void 0}grow(t){if(t<=this.cap)return;let n=Math.max(t,this.cap*2,64),r=new Float64Array(n*6);r.set(this.per),this.per=r,this.owed.grow(n),this.placed.grow(n);let o=new Float64Array(n);o.set(this.unlinked),this.unlinked=o;for(let i of this.laned){let s=new Float64Array(n*i.axes);s.set(i.values),i.values=s}this.cap=n}stretchChanged(t,n){let r=this.seats.get(t);if(r!==void 0){let s=r.crowd;s.restale(r.row,s.hot[r.row*s.stride+0]);return}let o=this.byId.get(t),i=o===void 0?-1:o.positionOfMotion(n);i>=0&&o.fix(i)}rerecord(t,n){let r=this.byId.get(t);if(r!==void 0)for(let o=0;o<r.list.length;o++){let i=r.list[o],s=this.subjectAt(i);s!==rr&&(r.records[o]=n(s,i))}}reshown(t){let n=this.seats.get(t);if(n!==void 0){let o=n.crowd.records[n.row];o!==void 0&&(n.crowd.data[n.row*8+1]=o.shown)}let r=this.byId.get(t);if(r!==void 0)for(let o=0;o<r.list.length;o++){let i=r.records[o];i!==void 0&&(r.data[o*8+1]=i.shown)}}voiceChanged(t){let n=Hn(this,t);if(n===null)return;let r=n.crowd,o=n.row*r.stride+0;r.hot[o]=r.hot[o]|64}},DY={copy:T_,row:rL,signalled:$_,parting:Y_,subjectAt:q_,reset:X_,run:J_,runEveryone:Q_,one:Z_,foldKeys:eD,readKeyed:tD,call:nD,gather:L_,fold:__,foldDelta:D_,foldRun:B_,foldInto:H_,gate:G_,unplain:U_};for(let[e,t]of Object.entries(DY))Object.defineProperty(Rc.prototype,e,{value:t,writable:!0,configurable:!0});var Nm=class{xy=new Float64Array(0);n=0;cell=Number.NaN;dirty=!0;x0=0;y0=0;size=1;cols=0;rows=0;starts=new Int32Array(1);order=new Int32Array(0);home=new Int32Array(0);strays=[];stray=new Uint8Array(0);found=new Int32Array(64);count=0;put(t,n,r){if(this.xy[2*t]=n,this.xy[2*t+1]=r,this.dirty)return;if(this.cols===0||t>=this.home.length){this.dirty=!0;return}let o=Math.floor((n-this.x0)/this.size),i=Math.floor((r-this.y0)/this.size);(o>=0&&o<this.cols&&i>=0&&i<this.rows?i*this.cols+o:-2)===this.home[t]||this.stray[t]===1||(this.stray[t]=1,this.strays.push(t),this.strays.length>Math.max(32,this.n>>4)&&(this.dirty=!0))}build(){this.dirty=!1;for(let m of this.strays)this.stray[m]=0;this.strays.length=0;let t=this.xy,n=Math.min(this.n,t.length>>1),r=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let m=0;m<n;m++){let g=t[2*m],b=t[2*m+1];g<r&&(r=g),g>i&&(i=g),b<o&&(o=b),b>s&&(s=b)}if(!(i>=r)||!(s>=o)){this.cols=0,this.rows=0;return}let a=Number.isNaN(this.cell)?Math.sqrt(2*Math.max(i-r,1e-9)*Math.max(s-o,1e-9)/n):this.cell,l=4*n+64;(Math.floor((i-r)/a)+1)*(Math.floor((s-o)/a)+1)>l&&(a=Math.max(a,Math.sqrt((i-r)*(s-o)/n),(i-r+s-o)/l));let u=Math.floor((i-r)/a)+1,c=Math.floor((s-o)/a)+1;this.x0=r,this.y0=o,this.size=a,this.cols=u,this.rows=c;let d=u*c;this.starts.length<d+1?this.starts=new Int32Array(d+1):this.starts.fill(0,0,d+1),this.order.length<n&&(this.order=new Int32Array(n)),this.home.length<n&&(this.home=new Int32Array(n),this.stray=new Uint8Array(n));let f=this.starts,p=this.order;for(let m=0;m<n;m++){let g=pD(t,m,r,o,a,u);this.home[m]=g,g>=0&&(f[g+1]=f[g+1]+1)}for(let m=0;m<d;m++)f[m+1]=f[m+1]+f[m];let h=f[d];for(let m=n-1;m>=0;m--){let g=pD(t,m,r,o,a,u);if(g<0)continue;let b=f[g+1]-1;f[g+1]=b,p[b]=m}for(let m=0;m<d;m++)f[m]=f[m+1];f[d]=h}push(t,n){if(n===this.found.length){let r=new Int32Array(this.found.length*2);r.set(this.found),this.found=r}return this.found[n]=t,n+1}query(t,n,r,o){if(this.dirty&&this.build(),this.count=0,this.cols===0||!(r>=0))return 0;let i=this.size,s=Math.max(0,Rm((t-r-this.x0)/i,-1)),a=Math.min(this.cols-1,Rm((t+r-this.x0)/i,1)),l=Math.max(0,Rm((n-r-this.y0)/i,-1)),u=Math.min(this.rows-1,Rm((n+r-this.y0)/i,1)),c=this.xy,d=this.order,f=this.starts,p=this.strays.length>0,h=0;for(let m=l;m<=u&&s<=a;m++){let g=f[m*this.cols+s],b=f[m*this.cols+a+1];for(let x=g;x<b;x++){let w=d[x];if(p&&this.stray[w]===1)continue;let y=c[2*w]-t,P=c[2*w+1]-n;y*y+P*P<=o&&(h=this.push(w,h))}}for(let m of this.strays){let g=c[2*m]-t,b=c[2*m+1]-n;g*g+b*b<=o&&(h=this.push(m,h))}return this.count=h,h}ring(t,n,r){if(this.dirty&&this.build(),this.count=0,this.cols===0||!(r>=0))return 0;let o=this.size,i=r+o,s=r*r,a=i*i,l=Math.max(0,Math.floor((t-i-this.x0)/o)),u=Math.min(this.cols-1,Math.floor((t+i-this.x0)/o)),c=Math.max(0,Math.floor((n-i-this.y0)/o)),d=Math.min(this.rows-1,Math.floor((n+i-this.y0)/o)),f=this.xy,p=0;for(let h=c;h<=d;h++)for(let m=l;m<=u;m++){let g=this.x0+m*o-t,b=this.y0+h*o-n;if(Math.max(g*g,(g+o)**2)+Math.max(b*b,(b+o)**2)<=s)continue;let w=h*this.cols+m;for(let y=this.starts[w];y<this.starts[w+1];y++){let P=this.order[y];if(this.stray[P]===1)continue;let S=f[2*P]-t,v=f[2*P+1]-n,A=S*S+v*v;A>s&&A<=a&&(p=this.push(P,p))}}for(let h of this.strays){let m=f[2*h]-t,g=f[2*h+1]-n,b=m*m+g*g;b>s&&b<=a&&(p=this.push(h,p))}return this.count=p,p}};function pD(e,t,n,r,o,i){let s=e[2*t],a=e[2*t+1];return!(s>=n)||!(a>=r)?-1:Math.floor((s-n)/o)+Math.floor((a-r)/o)*i}function Rm(e,t){let n=Math.floor(e);return t<0?e-n<1e-6?n-1:n:n+1-e<1e-6?n+1:n}var Im=class extends Nm{slotOf;keepRefs;at=new me;slots=new Int32Array(0);placeOf=new Int32Array(0);refs=null;cur=-1;free=[];owned=!0;tokens=[];registry=null;constructor(t,n){super(),this.slotOf=t,this.keepRefs=n,this.refs=n?[]:null}set(t,n,r){let o=t.length;this.at=new me;for(let i=0;i<o;i++)this.at.set(t[i],i);this.slots=new Int32Array(Math.max(o,16)).fill(-1),this.placeOf.fill(-1),this.refs=this.keepRefs?[]:null,this.tokens=[],this.free=[];for(let i=0;i<o;i++){let s=t[i];this.at.get(s)===i&&this.hold(s,i)}this.n=o,this.xy=n,this.owned=!1,this.cell=r,this.dirty=!0}place(t){let n=this.at.get(t);if(n!==void 0)return n;let r=this.free.pop()??this.n++;return this.room(r+1),this.at.set(t,r),this.hold(t,r),this.owned&&this.put(r,Number.NaN,Number.NaN),r}hold(t,n){let r=this.slotOf(t);r>=0&&this.numbered(r,n);let o=typeof t=="object"&&t!==null;if(this.refs!==null&&(this.refs[n]=o?new WeakRef(t):t),!o)return;let i={i:n};this.tokens[n]=i,this.registry??=new FinalizationRegistry(s=>{this.tokens[s.i]===s&&this.release(s.i)}),this.registry.register(t,i,i)}room(t){if(this.slots.length<t){let n=new Int32Array(Math.max(t,this.slots.length*2)).fill(-1);n.set(this.slots),this.slots=n}if(this.owned&&this.xy.length<2*t){let n=new Float64Array(Math.max(2*t,this.xy.length*2,32)).fill(Number.NaN);n.set(this.xy),this.xy=n}}number(t,n){let r=this.at.get(t);r!==void 0&&this.numbered(n,r)}numbered(t,n){if(t>=this.placeOf.length){let r=new Int32Array(Math.max(t+1,this.placeOf.length*2,64)).fill(-1);r.set(this.placeOf),this.placeOf=r}this.placeOf[t]=n,this.slots[n]=t}forgot(t){if(t>=this.placeOf.length)return;let n=this.placeOf[t];n<0||(this.placeOf[t]=-1,this.slots[n]===t&&(this.slots[n]=-1))}drop(t){let n=this.at.get(t);if(n===void 0)return;this.at.delete(t);let r=this.tokens[n];r!==void 0&&this.registry?.unregister(r),this.release(n)}release(t){this.tokens[t]=void 0,this.refs!==null&&(this.refs[t]=void 0);let n=this.slots[t];n>=0&&(this.placeOf[n]=-1),this.slots[t]=-1,this.owned&&this.put(t,Number.NaN,Number.NaN),this.free.push(t)}subjectAt(t){let n=this.refs?.[t],r=n instanceof WeakRef?n.deref():n;return r!==void 0&&this.at.get(r)===t?r:void 0}inside(t,n,r,o){let i=this.at.get(t);if(i===void 0||2*i+1>=this.xy.length)return!1;let s=this.xy[2*i]-n,a=this.xy[2*i+1]-r;return s*s+a*a<=o}};function hD(e,t,n){if(t.length<2*e.length)throw new RangeError(`blits: plot takes two numbers a subject, x then y: ${e.length} subjects need ${2*e.length}, not ${t.length}`);if(n!==void 0&&!(n>0&&n<Number.POSITIVE_INFINITY))throw new RangeError(`blits: plot's cell is a size above 0, not ${n}`);yD(this).set(e,t,n??Number.NaN),this.moved()}function mD(e){return yD(this).place(e)}function yD(e){if(e.places!==null)return e.places;let t=new Im(n=>e.chains.get(n)?.slot??-1,!tc());e.places=t;for(let n of e.cued)n.bound===null&&cm(e,n);return t}function gD(){this.places!==null&&(this.places.dirty=!0),this.lanes?.refill(),this.stir()}function bD(e,t,n){let r=this.places,o=r===null?void 0:r.at.get(e);if(r===null||o===void 0)throw new Error("blits: put takes a subject with an index: place or plot it first");if(2*o+1>=r.xy.length)throw new RangeError(`blits: put's subject is at index ${o}, past the positions plot was given: plot again with room for it`);r.put(o,t,n),this.lanes?.refill(),this.stir()}var Em=class{list=[];head=0;get length(){return this.list.length-this.head}push(t){this.list.push(t)}shed(t,n){let r=this.list,o=this.head;for(;o+1<r.length&&r[o+1].at<=t;)n?.(r[o]),o++;o>=512&&o*2>=r.length&&(r.splice(0,o),o=0),this.head=o}at(t){let n=this.list,r=this.head,o=n.length-1,i;for(;r<=o;){let s=r+o>>1,a=n[s];a.at<=t?(i=a,r=s+1):o=s-1}return i}numbered(t){let n=this.list,r=this.head,o=n.length-1;for(;r<=o;){let i=r+o>>1,s=n[i];if(s.seq===t)return s;s.seq<t?r=i+1:o=i-1}}all(){return this.list.slice(this.head)}set(t){this.list=t,this.head=0}};var Mm=class e{keeps;log;constructor(t,n=[{anchorNow:0,anchorElapsed:0,rate:1,ramp:null,seq:Number.NEGATIVE_INFINITY}]){this.keeps=t,this.log=n}get clock(){return this.log[this.log.length-1]}get waiting(){return Number.isNaN(this.clock.anchorNow)}sync(t){return this.waiting&&(this.log=[{...this.clock,anchorNow:t,anchorElapsed:t}]),this.reading(t)}reading(t){if(this.waiting)return t;let n=this.log,r=n.length-1;for(;r>0&&n[r].anchorNow>t;)r--;return ze(n[r],t)}at(t,n){if(!(t>n)||this.waiting)return this.reading(t);let r=this.clock,o=r.ramp;return(o===null?r.rate<=0:o.to<=0&&t>r.anchorNow+o.over)?Number.POSITIVE_INFINITY:ze(r,t)}timeOf(t){if(this.waiting)return t;let n=this.log,r=0;for(;r+1<n.length&&t>n[r+1].anchorElapsed;)r++;return Cn(n[r],t)}rateAt(t){let n=this.clock;return this.waiting||Number.isNaN(t)?n.ramp===null?n.rate:n.ramp.from:ya(n,t)}stopped(t){let n=this.clock,r=n.ramp;return r===null?n.rate===0:r.to===0&&!this.waiting&&t>=n.anchorNow+r.over}change(t,n,r,o,i){let s=this.clock,a={...s,seq:i};if(Number.isNaN(t)||this.waiting){let u=this.rateAt(Number.NaN);a.ramp=r>0&&n!==u?{from:u,to:n,over:r}:null,a.rate=n,a.anchorNow=Number.NaN,this.log=[a];return}ga(a,t,n,r);let l=this.log;this.keeps&&s.anchorNow<t?l.push(a):l[l.length-1]=a,this.shed(o)}shed(t){let n=this.log,r=0;for(;r+1<n.length&&n[r+1].anchorElapsed<=t;)r++;return r>0?n.splice(0,r):[]}unshed(t){let n=this.log[0].anchorNow,r=t.filter(o=>o.anchorNow<n).sort((o,i)=>o.anchorNow-i.anchorNow);r.length>0&&(this.log=[...r,...this.log])}cut(t){let n=this.log,r=1;for(;r<n.length&&n[r].anchorNow<=t;)r++;n.length=r}until(t){let n=this.log,r=1;for(;r<n.length&&n[r].anchorNow<t;)r++;return new e(this.keeps,n.slice(0,r))}};var Cm=e=>({t:Number.NaN,seq:0,up:null,rank:0,left:null,cut:null,of:e}),xD=Cm(null);function BY(e){let t=e,n=t.up;for(;n!==null;){let r=n.up;if(r===null)return n;t.up=r,t=r,n=t.up}return t}var Nc=class extends me{own;now;make;stamp=Cm(this);first=this.stamp;at=new me;roots=[];kept=0;ready=[];aging=[];top=Number.NaN;constructor(t,n,r){super(),this.own=t,this.now=n,this.make=r}back(t,n,r){let o=this.stamp;r!==null&&(o.left=r,o.cut=n);let i=this.roots,s=o,a=null;for(;i.length>0;){let l=i[i.length-1].deref();if(l!==void 0&&l.t<t)break;let u=i.pop();l!==void 0&&(l.rank>s.rank?(s.up=l,s=l,a=u):(l.up=s,l.rank===s.rank&&s.rank++))}s.t=t,s.seq=n.seq,i.push(a??new WeakRef(s)),i.length>2*this.kept+16&&(this.roots=i.filter(l=>l.deref()!==void 0),this.kept=this.roots.length),this.stamp=this.fresh(),this.top=t}fresh(){if(this.ready.length===0){let t=Math.min(64,Math.max(1,this.aging.length*2));this.ready=this.aging.reverse(),this.aging=[];for(let n=0;n<t;n++)this.aging.push(Cm(this))}return this.ready.pop()??Cm(this)}sure=!0;get(t){return this.from(t,this.own.get(t))}find(t,n){let r=n.restored;return r!==null&&r.of===this&&this.sure?this.from(t,n):this.get(t)}from(t,n){let r=n?.reaches,o=(r?n.restored:this.at.get(t))??this.first,i=this.stamp;if(o===i)return n;r?n.restored=i:this.at.set(t,i);let s=BY(o),a=o.left?.at(t,o.cut),l=a??this.now(t,n,s),u=l&&this.make(l,s,a===void 0);return u===void 0?(this.shed(t),r&&this.at.set(t,i)):u!==n?this.set(t,u):u.reaches||this.at.set(t,i),u}set(t,n){let r=this.own.get(t);if(r===n){n.reaches?n.restored=this.stamp:this.at.set(t,this.stamp);return}r?.reaches&&(r.restored=xD),n.reaches&&n.restored!==null&&(this.sure=!1),this.own.set(t,n),n.reaches?n.restored=this.stamp:this.at.set(t,this.stamp)}delete(t){this.shed(t),this.at.set(t,this.stamp)}shed(t){let n=this.own.get(t);n?.reaches&&(n.restored=xD),this.own.delete(t)}clear(){this.sure=!1,this.own.clear(),this.at.clear()}};function Wa(e,t){if(e.reaches(t))return!1;let n=e.pager;if(n===null)throw new Error(`blits: ${t} is older than this mix's history reaches`);let r=n.loaded;if(r===null||r.t>t){let o=n.last;throw new ic(o?.mix??"",o?.stream??"history",t)}for(let o of[...e.members,...e.dropped.map(i=>i.mix)]){let i=o.name??"";if(o.outs?.missing(r.t,a=>r.records.some(l=>l.stream==="voice"&&l.voice===a&&l.mix===i))!==void 0)throw new ic(i,"voice",t)}return n.loaded=null,HY(e,r.records),e.floor=r.t,!0}function Om(e,t){if(!Number.isInteger(t))throw new RangeError(`blits: a frame is a number \`seq\` read, not ${t}`);let n=e.frames.numbered(t),r=e.pager;if(n===void 0&&r!==null&&t<=e.seq){let o=r.loaded?.records.find(i=>i.stream==="frame"&&i.mix===""&&i.seq===t);if(o!==void 0)Wa(e,o.at),n=e.frames.numbered(t);else if(t<(e.frames.all()[0]?.seq??Number.POSITIVE_INFINITY))throw new Error(`blits: frame ${t} reaches past memory; await prepare with its mix time first`)}if(n===void 0)throw new Error(`blits: frame ${t} is not one this mix's history holds: not played yet, let go, or after a moment a seek went back to`);return Wa(e,n.at),n}function PD(e,t){let n=e.pager;if(n===null)return;n.store.cut(t);let r=n.loaded;r!==null&&(r.records=r.records.filter(o=>o.seq<=t))}function HY(e,t){GY(e,t);let n=new Map;for(let o of[...e.members,...e.dropped.map(i=>i.mix)])n.set(o.name??"",o);let r=new Map;for(let o of[...t].sort((i,s)=>i.seq-s.seq)){let i=n.get(o.mix);if(i===void 0)continue;let s=r.get(i);s===void 0?r.set(i,[o]):s.push(o)}for(let[o,i]of r)UY(o,i)}function GY(e,t){let n=t.filter(a=>a.mix===""&&a.voice===void 0),r=n.filter(a=>a.stream==="pace").map(a=>a.data);r.length>0&&e.pace?.unshed(r);let o=n.filter(a=>a.stream==="frame").map(a=>({seq:a.seq,at:a.at,u:a.data}));e.frames.set(Ic(o,e.frames.all()));let i=new Set(e.announced.map(a=>a.order)),s=n.filter(a=>a.stream==="mark"&&!i.has(a.data.order)).map(a=>a.data);s.length>0&&(e.announced=[...s,...e.announced].sort((a,l)=>a.order-l.order))}function UY(e,t){let n=new Map;for(let s of[...e.cued,...e.gone])n.set(s.id,s);for(let s of t)if(s.stream==="voice"&&s.voice!==void 0&&!n.has(s.voice)){let a=PL(e,s.voice,s.data);n.set(a.id,a),e.gone.push(a),_h(e,a)}let r=t.filter(s=>s.stream==="host");e.hostLog=Ic(r.map(s=>({at:s.at,seq:s.seq,fields:s.data})),e.hostLog);let o=new Map;for(let s of t){if(s.voice===void 0)continue;let a=o.get(s.voice);a===void 0?o.set(s.voice,[s]):a.push(s)}let i=e.keys;for(let[s,a]of o){let l=n.get(s);l!==void 0&&WY(l,a,i)}}function WY(e,t,n){let r=s=>t.filter(a=>a.stream===s);e.log!==null&&(e.log=Ic(r("controls").map(s=>s.data),e.log));let o=r("left");if(o.length>0){let s=[...e.left?.all()??[]];for(let a of o){let l=n.subject(a.subject);if(s.some(p=>p.seq===a.seq&&Object.is(p.subject,l)))continue;let[u,c,d=null,f=null]=a.data;s.push({subject:l,at:a.at,seq:a.seq,sync:c,held:Ui(e,u),ramp:d,parted:f})}s.sort((a,l)=>a.seq-l.seq),e.left=Fn.from(s)}for(let[s,a]of BT(r("snap"))){let l=n.subject(s);for(let[u,c]of wD(e,l,a))u.snaps=Ic(c.map(d=>({at:d.at,seq:d.seq,held:Ui(e,d.data)})),u.snaps??[])}for(let[s,a]of BT(r("input"))){let l=n.subject(s);for(let[u,c]of wD(e,l,a))u.inputs=Ic(c.map(d=>({at:d.at,seq:d.seq,value:d.data})),u.inputs??[])}let i=e.motion;if(i!==void 0){for(let s of r("released"))i.reclaim(n.subject(s.subject),s.at,s.seq,s.data);for(let[s,a]of BT(r("stretch")))i.restretch(n.subject(s),a)}}function BT(e){let t=new Map;for(let n of e){let r=t.get(n.subject);r===void 0?t.set(n.subject,[n]):r.push(n)}return t}function wD(e,t,n){let r=e.left?.of(t)??[],o=[],i=Number.NEGATIVE_INFINITY;for(let a of r)o.push([a.held,n.filter(l=>l.seq>i&&l.seq<=a.seq)]),i=a.seq;let s=e.subjects.get(t);return s?.reaches&&o.push([s,n.filter(a=>a.seq>i)]),o}function Ic(e,t){let n=t[0]?.seq??Number.POSITIVE_INFINITY,r=[];for(let o of e)o.seq<n&&(r.length>0&&r[r.length-1].seq===o.seq?r[r.length-1]=o:r.push(o));return r.length===0?t:[...r,...t]}function VY(e,t,n,r,o,i){let s=r.t,a=n.inputs?.filter(P=>P.at<=s),l=n.snaps;if(l===void 0){let P=i&&n.reaches?Ba(n):Vo(t,n);return P.stepped>s&&(P.stepped=s),TD(P,n,s),P.weight=0,P.inputs=a,P.since<=s||Aa(e,t,P),P}let u=l.length,c=u>0&&l[u-1].at<=s?u-1:u>1&&l[u-2].at<=s?u-2:cT(l,s,!0);if(c<0)return;let d=l[c],{ticks:f,since:p,rebuilt:h,state:m,slot:g,restored:b}=n,x;i&&n.reaches?(x=fT(t,d.held,n,!0),x.slot=g,x.restored=b):x=Vo(t,d.held,!0),x.weight=0,TD(x,n,s),d.at<s&&(x.copied=!0);let w=c+1;if(i)zY(t,l,w);else for(let P=0;P<w;P++)l[P].shared=!0;x.snaps=i?l:l.slice(0,w),x.inputs=a,x.since<=d.at||Aa(e,t,x);let y=i&&f>x.ticks&&p===x.since&&h===x.rebuilt;if(t.patch.step!==void 0&&(d.ahead!==void 0||s-d.at>=o||y)){let P=d.ahead;P===void 0||P.since!==x.since?(P={put:x,sought:s,since:x.since,at:d.at,ticks:x.ticks,state:void 0,leftTicks:0,left:void 0},d.ahead=P):(P.put=x,P.sought=s),y&&(P.leftTicks=f,P.left=m)}return x}function TD(e,t,n){e.restedAt=t.restedAt<=n?t.restedAt:Number.NaN}function zY(e,t,n){for(;t.length>n;){let r=t.pop();r.shared||(r.ahead=void 0,e.spares??=[],e.spares.push(r))}}function KY(e,t){let n=t.owner;n?.holding&&(n.holding.kids--,t.passed&&n.holding.played--);let r=t.motion;r!==void 0&&r.owner===e.owner&&r.ownerId===t.id&&(r.owner=null),t.park()}function jY(e,t,n,r){let o={seq:r,strict:!1},i=t.log,s=Sc(i,o)??i[0];if(i.length=i.indexOf(s)+1,t.take(s),t.reopen(r)&&t.owner?.holding&&t.owner.holding.played--,t.doneAt=Number.POSITIVE_INFINITY,t.doneSeq=Number.POSITIVE_INFINITY,t.parts!==null){for(let[c,d]of t.parts)d.seq>r&&t.parts.delete(c);t.parts.size===0&&(t.parts=null)}if(t.parted!==null){for(let[c,d]of t.parted)d.seq<=r||(t.parted.delete(c),!(d.ramp===void 0||d.ramp.seq>r)&&(t.parts??=new Map,t.parts.set(c,d.ramp)));t.parted.size===0&&(t.parted=null)}t.seen=0,t.restedCount=0,t.early=null,t.holder=null,t.keepOn=null,t.laned=!1,t.unreached=null,t.unreachedBits=null,t.seeks++,t.spares=null;let a=t.left?.all()??[];t.left!==null&&ym(t,t.left.after(o),r),t.left=Fn.from(a.filter(c=>c.seq<=r));let l=Fn.from(a.filter(c=>c.seq>r)),u=t.subjects;if(!(u instanceof Nc)){let c=kc(e.opts.history),d=(p,h,m)=>Nh(t,p,h,m.t,m.seq),f=new Nc(u,d,(p,h,m)=>{let g=VY(e,t,p,h,c,m);return g===void 0||(g.reaches&&t.seen++,Oo(g)&&t.restedCount++,g.since<=f.top||(t.early??=[],t.early.push(g))),g});u=f,t.subjects=u}u.back(n,o,l)}function Va(e,t){if(e.projecting)throw new Error("blits: a projection does not seek");if(!e.history)throw new Error("blits: seeking needs a mix made with history");let r=e.tape;if(r===void 0)throw new Error("blits: seeking needs history.tape, which keeps the calls a seek plays again");if(Number.isNaN(e.now))throw new Error("blits: a mix that has never synced has nothing to seek");let o,i;if(typeof t=="number"){if(o=t,o===Number.POSITIVE_INFINITY)throw new RangeError("blits: a mix seeks to a finite time");if(!(o>=e.born))throw new Error(`blits: ${o} is older than this mix's history reaches`);if(Wa(e,o),o<e.now&&(i=e.frames.at(o),i===void 0))throw new Error(`blits: ${o} is older than this mix's history reaches`)}else{let s=Om(e,t.frame);o=s.at,s.seq!==e.seq&&(i=s)}if(i===void 0){let s=Ma(e,c=>(e.pace===null?c:e.pace.reading(c))<=o),a=e.left,l=a!==null&&a.t===o&&a.u>=e.u&&(e.pace===null?a.u:e.pace.reading(a.u))===o?a.u:$r(e,o),u=Number.isNaN(s)?l:Math.max(s,l);if(!Number.isFinite(u))throw new RangeError(`blits: the mix's rate never reaches ${o}`);if(e.u=u,Number.isNaN(s)||e.now!==o)for(let c of e.members)Yr(c,o)}else{let s=i.at===o?i.u:ji(e,o),a=i.seq;e.left={t:e.now,u:e.u},r.goto(r.depthAt(s)),e.undrop(a),e.announced=e.announced.filter(l=>l.seq<=a),e.frames.set(e.frames.all().filter(l=>l.seq<=a)),e.pacedSeq>a?(e.pace=null,e.pacedSeq=Number.POSITIVE_INFINITY):e.pace?.cut(s),e.u=s,e.now=o;for(let l of e.members)$Y(l,o,a,i.at<o);PD(e,a)}e.tick(o),e.offset=e.last-e.u,e.kept();for(let s of e.members){s.stir();let a=s.bookers;if(a!==null)for(let l of a)l.sought()}}function $Y(e,t,n,r){let o=[...e.cued,...e.gone].sort((c,d)=>c.id-d.id),i=[],s=[],a=new Set;for(let c of o)c.motion!==void 0&&a.add(c.motion);for(let c of o)c.cuedSeq>n?KY(e,c):c.doneSeq<=n?s.push(c):i.push(c);for(let c of i)jY(e,c,t,n);let l={seq:n,strict:!1};for(let c of i)c.state=c.stateAt(t,l),c.begunSeq>n&&(c.begunSeq=Number.POSITIVE_INFINITY);e.cued=i,e.gone=s,e.retired=[];for(let c of i)c.holding!==null&&(c.holding.children=i.filter(d=>d.owner===c),c.holding.back(n));let u=e.lanes;u!==null&&e.lanesOf!==null?e.lanes=new e.lanesOf(Zh(e),u):e.chains=new me,e.owners=i.some(c=>c.holding!==null)?i.filter(c=>c.holding!==null):null,Wo(e),e.parters.clear();for(let c of[...i,...s])(c.parts!==null||c.parted!==null)&&e.parters.add(c);e.relinks++,e.lastPoses=new me,e.restStamps!==null&&(e.restStamps=new me),h_(e);for(let c of[...i,...s]){c.unreached=null,c.unreachedBits=null;let d=c.blend?.of;d!==void 0&&(d.frame=0,d.reads=new me,d.frames=new Float64Array(0),d.values=new Float64Array(0))}e.playing.clear();for(let c of i){let d=c.motion;d!==void 0&&(e.playing.set(d,(e.playing.get(d)??0)+1),e.owner!==null&&(d.owner=e.owner,d.ownerId=c.id))}for(let c of a)u!==null&&c.watcher===u&&(c.watcher=null),c.rewind(n);e.hostLog=e.hostLog.filter(c=>c.seq<=n),e.sent=e.sent.filter(c=>c.timestamp<=t),e.sentTo=t,e.pins=null;for(let c of i)c.state==="pending"&&!Number.isNaN(c.pinned)&&(e.pins??=new Map,e.pins.set(c,c.pinned));e.due.clear();for(let c of i)it(e,c);if(e.stir(),r)Yr(e,t);else{e.frame=st(),e.reducedNow=e.reduced;let c=e.opts.history.ms;e.anchored>0&&e.transport.forgotTo>=t-c&&zr(e)}}var GT=Symbol.for("@msb235/blits/watch/1"),UT=globalThis;function WT(){let e=UT[GT];if(e!==void 0)return e;let t=new Map,n=new Set,r=new WeakMap;return e={refs:t,entries_:r,fns:n,labels:new WeakMap,next:1,counted:0,history:void 0,gone:new FinalizationRegistry(o=>{t.delete(o);for(let i of[...n])i({kind:"gone",id:o})}),entries(){let o=[];for(let i of t.values()){let s=i.deref(),a=s===void 0?void 0:r.get(s);a!==void 0&&o.push(a)}return o},on(o){return n.add(o),()=>{n.delete(o)}}},UT[GT]=e,e}var kD=new WeakSet;function vD(e){let t=UT[GT]?.history;return e.history!==void 0||e.transport!==void 0||t===void 0?{history:e.history,added:!1}:{history:t,added:!0}}function AD(e){kD.add(e)}function RD(e){let t=WT(),n=t.next++,r=e.transport,o={id:n,release:xh,name:e.name,mix:e,get history(){let i=r.history;return i===void 0?void 0:{ms:i.ms,tape:r.tape!==void 0,added:kD.has(r)}},get reach(){return MD(r,!1)},channels:e.names,voice:i=>{let s=e.cued.find(a=>a.handle===i)??e.gone.find(a=>a.handle===i);return s===void 0?void 0:{name:s.spec.name,tags:s.spec.tags??[],within:s.bound?.area}},label:i=>YY(e,i),watch:i=>JY(e,i),subjects:()=>XY(e),read:(i,s=e.now)=>e.project(s).probe(i),hold:()=>eq(r)};t.entries_.set(e,o),t.refs.set(n,new WeakRef(e)),t.gone.register(e,n,e);for(let i of[...t.fns])i({kind:"add",entry:o})}function ND(e){let t=WT(),n=t.entries_.get(e);if(n===void 0||!t.refs.has(n.id))return;t.refs.delete(n.id),t.gone.unregister(e),ID(e);let r=e.transport,o=Ec(r).held,i=s=>t.refs.has(t.entries_.get(s)?.id??-1);o!==null&&!r.members.some(i)&&o.free();for(let s of[...t.fns])s({kind:"gone",id:n.id})}function YY(e,t){return e.opts.labelOf?.(t)??qY(t)}function qY(e){if(typeof e!="object"||e===null)return typeof e=="function"?e.name||"function":String(e);let t=globalThis.Element;if(t!==void 0&&e instanceof t){let i=e.id?`#${e.id}`:"",s=[...e.classList].map(a=>`.${a}`).join("");return`${e.tagName.toLowerCase()}${i}${s}`}let n=e;for(let i of["name","id"]){let s=n[i];if(typeof s=="string"&&s!==""||typeof s=="number")return String(s)}let r=WT(),o=r.labels.get(e);return o===void 0&&(o=`${e.constructor?.name||"Object"} #${++r.counted}`,r.labels.set(e,o)),o}function XY(e){let t=or.get(e),n=new Set(t?.was);for(let r of t?.seen??[])n.add(r);for(let r of e.cued)if(r.state!=="done")for(let o of r.spec.subjects??[])n.add(o);return[...n]}var SD=new WeakMap;function Ec(e){let t=SD.get(e);return t===void 0&&(t={tapped:0,held:null,unsync:null},SD.set(e,t)),t}function Fm(e){let t=Ec(e),n=t.tapped>0||t.held!==null;if(n&&t.unsync===null){let r=Lm(e).sync;t.unsync=Xr(e,"sync",o=>{for(let s of e.members)ED(s);let i=t.held;i===null?r.call(e,o):i.sync(o)})}else!n&&t.unsync!==null&&(t.unsync(),t.unsync=null)}function Xr(e,t,n){let r=e,o=r[t];return r[t]=n,()=>{r[t]=o}}function Lm(e){return Object.getPrototypeOf(e)}var or=new WeakMap;function JY(e,t){let n=or.get(e);if(n===void 0){let r=Lm(e),o=r.probe,i=r.pull,s=r.drain,a=[Xr(e,"probe",(l,u)=>{let c=o.call(e,l,u);return HT(e).probed.push({subject:l,pose:ZY(c)}),or.get(e).seen.add(l),c}),Xr(e,"pull",(l,u)=>{let c=Array.isArray(l)?l:[...l];i.call(e,c,u);let d={};for(let[p,h]of Object.entries(u))h!==void 0&&(d[p]=h.slice());HT(e).pulled.push({subjects:[...c],columns:d});let f=or.get(e).seen;for(let p of c)f.add(p)}),Xr(e,"drain",l=>{let u=s.call(e,l);return u.length>0&&HT(e).sent.push(...u),u})];n={fns:new Set,frame:null,seen:new Set,was:new Set,untap:()=>{for(let l of a)l()}},or.set(e,n),Ec(e.transport).tapped++,Fm(e.transport)}return n.fns.add(t),QY(new WeakRef(e),t)}function QY(e,t){return()=>{let n=e.deref(),r=n===void 0?void 0:or.get(n);n===void 0||r===void 0||!r.fns.delete(t)||r.fns.size>0||ID(n)}}function ID(e){let t=or.get(e);t!==void 0&&(t.untap(),or.delete(e),Ec(e.transport).tapped--,Fm(e.transport))}function HT(e){let t=or.get(e);return t.frame!==null&&t.frame.seq===e.transport.seq||(ED(e),t.was=t.seen,t.seen=new Set,t.frame={seq:e.transport.seq,now:e.now,timestamp:e.timestamp,probed:[],pulled:[],sent:[],voices:e.voices()}),t.frame}function ED(e){let t=or.get(e),n=t?.frame;if(!(t===void 0||n==null)){t.frame=null;for(let r of[...t.fns])r(n)}}function ZY(e){try{return globalThis.structuredClone(e)}catch{return{...e}}}function MD(e,t){let n=e.history;if(n===void 0||t&&e.tape===void 0)return e.now;let r=e.pager!==null?Number.NEGATIVE_INFINITY:e.now-n.ms;return Math.max(e.born,e.floor,r)}function eq(e){let t=Ec(e);if(t.held!==null)throw new Error("blits: that mix is held already; free it first");let n=Lm(e),r=n.ramp,o=n.rebase,i=n.sync,s=n.seek,a=[],l=0,u=!1,c=!1,d=e.last,f=e.last,p=y=>{let P=u;u=!0;try{y()}finally{u=P}},h=y=>{e.replaying||u?y():a.push(y)},m=()=>{e.rebasing&&!Number.isNaN(e.last)&&i.call(e,e.last),i.call(e,d)},g=[],b=e.tape;if(b!==void 0){let y=b.recordEntry;g.push(Xr(b,"recordEntry",(...P)=>{u||b.timestampAt(b.undoDepth())!==void 0||y.apply(b,P)}))}g.push(Xr(e,"ramp",(y,P)=>{if(!(y>=0&&y<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a mix's rate is a finite number, 0 or more, not ${y}`);h(()=>r.call(e,y,P))}),Xr(e,"rebase",()=>h(()=>o.call(e))),Xr(e,"seek",y=>h(()=>s.call(e,y))));for(let y of e.members){let P=Lm(y).seek;g.push(Xr(y,"seek",S=>{e.shared?P.call(y,S):h(()=>P.call(y,S))}))}t.held={sync(y){Number.isNaN(d)?d=y:!Number.isNaN(f)&&y>f&&(d+=(y-f)*l),f=y,m()},free:()=>w.free()},Fm(e),e.woke();let x=()=>{if(c)throw new Error("blits: that hold was freed")},w={get mixes(){return[...e.members]},get now(){return e.now},get reach(){return MD(e,!0)},get rate(){return l},set rate(y){if(x(),!(y>=0&&y<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a hold's rate is a finite number, 0 or more, not ${y}`);l=y},seek(y){x(),p(()=>Va(e,y))},step(y){if(x(),!(y>0))return;if(Number.isNaN(d))throw new Error("blits: a mix that has never synced has nothing to step");let P=$r(e,e.now+y);if(!Number.isFinite(P))throw new RangeError("blits: the mix's own rate is 0, so it never moves");d=Math.max(d,P+e.offset),m();for(let S of e.members)S.stir()},free(){if(!c){c=!0;try{o.call(e);for(let y of a)y()}finally{for(let y of g.reverse())y();t.held=null,Fm(e),e.woke()}}}};return w}var tq=1e3,zo=class{history;shared;members=[];dropped=[];slots=0;holders=new Map;wakeFns=[];woken=!1;now=Number.NaN;seq=0;frames=new Em;u=Number.NaN;offset=0;left=null;born=Number.NaN;floor=Number.NEGATIVE_INFINITY;last=Number.NaN;rebasing=!1;taped=Number.NEGATIVE_INFINITY;pace=null;forgotTo=Number.NEGATIVE_INFINITY;settled=Number.NEGATIVE_INFINITY;settle(){this.now>this.settled&&(this.settled=this.now)}pacedSeq=Number.POSITIVE_INFINITY;ahead=new Map;replaying=!1;announced=[];nextId=1;tape;pager;constructor(t,n){this.history=t,this.shared=n,this.tape=SF(this),this.pager=t?.store===void 0?null:new Ch(t.store)}get projecting(){return this.members.some(t=>t.projecting)}join(t,n=this.slots++){t.slot=n;let r=this.members.findIndex(o=>o.slot>n);r<0?this.members.push(t):this.members.splice(r,0,t),PO(t)}drop(t){let n=t,r=this.members.indexOf(n);if(r<0)throw new Error(`blits: ${n.name??"that mix"} is not on this transport`);this.members.splice(r,1),TO(n),n.dropped=!0,this.history!==void 0&&(this.dropped.push({mix:n,at:this.now,seq:this.seq}),Ot(this,"drop",o=>{let i=o.mix(n);i!==void 0&&o.transport(this).drop(i)}))}undrop(t){let n=this.dropped.filter(r=>r.seq>t);if(n.length!==0){this.dropped=this.dropped.filter(r=>r.seq<=t);for(let r of n)r.mix.dropped=!1,this.join(r.mix,r.mix.slot)}}seek(t){Va(this,t)}prepare(t){return xO(this,t)}announce(t,n){if(n?.score===void 0)throw new Error("blits: a transport announces on a named score, which every mix on it sees");VT(this,t,n,-1,void 0)}marks(t,n){return cF(this,t,n).map(({order:r,...o})=>o)}project(t){return _m(this,t)}get live(){return this.members.some(t=>t.live)}get inert(){return this.members.every(t=>t.inert)}onWake(t){let n=this.wakeFns;return n.push(t),()=>{let r=n.indexOf(t);r>=0&&n.splice(r,1)}}woke(){if(!this.woken){this.woken=!0;for(let t of[...this.wakeFns])t()}}sync(t){let n=this.members;for(let r of n)r.syncing=!0;try{this.syncAt(t)}finally{for(let r of n)r.syncing=!1}}syncAt(t){if(Number.isNaN(t))throw new RangeError("blits: sync was given NaN; it takes the host clock as a number");if(t<this.last&&!this.rebasing)throw new RangeError(`blits: sync went back from ${this.last} to ${t}; the host's clock only goes forward, and seek moves the mix`);this.rebasing&&!Number.isNaN(this.last)&&(this.offset+=t-this.last),this.rebasing=!1,this.last=t;let n=t-this.offset,r=this.pace,o=r===null?n:r.sync(n),i=n!==this.u,s=i&&o===this.now;this.u=n,Number.isNaN(this.born)&&(this.born=o);let a=!1;if(this.tape!==void 0&&i&&(a=Ma(this,c=>c<=n)===n,r=this.pace,o=r===null?n:r.reading(n)),!a){this.tick(o);let c=o!==this.now;for(let d of this.members)(c||i&&r!==null&&AL(d))&&Yr(d,o)}let l=this.history;this.kept();let u=this.keepsFrom();if(this.tape!==void 0&&l!==void 0&&!(u-this.taped<tq)){let c=ji(this,u);c<Number.POSITIVE_INFINITY&&this.tape.prune(c),this.taped=u}if(l!==void 0&&this.dropped.length>0&&(this.dropped=this.dropped.filter(c=>c.at>=u)),this.frames.shed(u),bO(this),this.woken=!1,s)for(let c of this.members)c.frame=st(),c.lanes?.refill();for(let c of this.members){let d=c.bookers;if(d!==null)for(let f of d)f.sync()}}tick(t){let n=++this.seq;this.history!==void 0&&this.frames.push({seq:n,at:t,u:this.u});for(let r of this.members)r.looked=!1}rebase(){this.rebasing=!0,this.settle()}kept(){let t=this.history;t!==void 0&&this.pager===null&&this.now-t.ms>this.floor&&(this.floor=this.now-t.ms)}reaches(t){return this.pager!==null?t>=this.floor:t>=this.floor&&t>=this.now-(this.history?.ms??0)}keepsFrom(){let t=this.history;return t===void 0?Number.POSITIVE_INFINITY:this.pager===null?this.now-t.ms:Number.NEGATIVE_INFINITY}get rate(){return this.pace===null?1:this.pace.rateAt(this.u)}set rate(t){this.ramp(t,0)}ramp(t,n){if(!(t>=0&&t<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a mix's rate is a finite number, 0 or more, not ${t}`);if(this.pace===null){this.pace=new Mm(this.history!==void 0||this.projecting),this.pacedSeq=this.seq;for(let o of this.members)for(let i of o.cued)i.state==="pending"&&!i.placing&&i.owner===null&&i.spec.start!==void 0&&Ho(o,i,i.start)}let r=this.history===void 0?Number.NEGATIVE_INFINITY:this.keepsFrom();this.pace.change(this.u,t,n,r,this.seq);for(let o of this.members)o.stir();Ot(this,"rate",o=>o.transport(this).ramp(t,n))}};function VT(e,t,n,r,o){let i=n.at!==void 0?n.at-e.offset:e.u,s={name:t,score:n.score,tags:n.tags??[],at:i,order:e.nextId++,seq:e.seq,slot:r,mix:o};e.announced.push(s),e.settle(),Ot(e,"announce",a=>{let l=a.transport(e);l.announced.push({...s,seq:l.seq})})}function FD(e,t,n,r,o){let i=e.tape,s=i?.undoDepth()??0;try{for(;;){let a=nq(i,t,r);if(!(a<r))break;if(CD(e,t,n,a),!LD(t))continue;for(let u of t.members)u.anchored>0&&zr(u);let l=rq(t);for(let[u,c]of n){let d=new Ko(c.kit,{...c.opts,transport:l},null);d.slot=c.slot,d.projecting=!0,d.share=c.share,zT(c,d);let f=o.get(u);f===void 0?o.set(u,{at:[c],met:new Set}):f.at.push(c),n.set(u,d)}t=l}CD(e,t,n,r)}finally{i!==void 0&&i.undoDepth()!==s&&i.goto(s)}return t}function LD(e){for(let t of e.members)for(let n of t.cued)if(n.state!=="done"&&(n.patch.step!==void 0||typeof n.spec.weight=="function"))return!0;return!1}function nq(e,t,n){let r=t.now,o=Number.POSITIVE_INFINITY,i=e?.timestampAt(e.undoDepth());if(i!==void 0&&(o=t.pace===null?i:t.pace.reading(i)),!LD(t))return o<n?o:Number.POSITIVE_INFINITY;for(let s of t.members)for(let a of s.cued){if(a.state==="done")continue;for(let u of zi){let c=Xe(s,a,u);c!==void 0&&c>r&&c<o&&(o=c)}let l=a.spec.marks;if(l!==void 0)for(let u of Object.keys(l)){let c=Xe(s,a,u);c!==void 0&&c>r&&c<o&&(o=c)}}for(let s of t.announced){let a=t.pace===null?s.at:t.pace.at(s.at,t.u);a>r&&a<o&&(o=a)}return o<n?o:Number.POSITIVE_INFINITY}function CD(e,t,n,r){let o=e.tape,i=a=>(t.pace===null?a:t.pace.reading(a))<=r,s=o?.timestampAt(o.undoDepth());if(t.u=$r(t,r),s!==void 0&&i(s)){for(let l of t.members)for(let u of l.cued)u.parts!==null&&(u.parts=new Map(u.parts)),u.parted!==null&&(u.parted=new Map(u.parted));let a=Ma(e,i,t,{transport:()=>t,mix:l=>n.get(l)});t.u=Math.max(a,$r(t,r))}if(!(t.now>=r))for(let a of t.members)Yr(a,r)}function rq(e){let t=new zo(void 0,!0);return t.offset=e.offset,t.u=e.u,t.nextId=e.nextId,t.now=e.now,t.pace=e.pace===null?null:e.pace.until(Number.POSITIVE_INFINITY),t.announced=e.announced.map(n=>({...n})),t.ahead=e.ahead,t}function zT(e,t){Mc(e,t),t.cued=e.cued.filter(n=>n.state!=="done").map(n=>{let r={mix:e,voice:n,up:OD.get(n),seen:0,shared:!1,filled:!1},o=n.copy(s=>aq(r,s,t,o),void 0,!0);r.seen=o.seen,r.shared=o.sharing,OD.set(o,r);let i=e.pins?.get(n);return i!==void 0&&Ho(t,o,i),o}),t.waking=e.waking,Ca(t.cued),(e.owners!==null||e.projecting&&t.cued.some(n=>n.holding!==null))&&Sa(t.cued),Wo(t)}function Mc(e,t){t.lastPoses=e.lastPoses,t.wantsPose=e.wantsPose,t.reducedNow=e.reducedNow}function Dm(e,t,n){if(t.sharing){let o=ut(e,n)?.slot??-1,i=e.share;if(!i.sighted(t,o))return;let s=t.everyone;return i.open(t,s,o),s.weight=i.weightAt(t,o),s}let r=t.subjects.get(n);return r!==void 0||t.unreachedBits===null?r:ac(t,ut(e,n)?.slot??-1)?t.unreached:void 0}var OD=new WeakMap;function oq(e,t){return e.seen===t.seen&&!t.filled&&!t.shared&&e.unreached===null&&e.unreachedBits===null}function iq(e,t,n){return e.projecting&&n.reaches&&!t.sharing&&n!==t.unreached}function sq(e){return e.restored=null,Ba(e)}function aq(e,t,n,r){let o=e.mix,i=e.voice,s=e;for(;s.up!==void 0&&oq(s.voice,s.up);)s=s.up;if(s!==e&&Dm(s.mix,s.voice,t)===void 0)return;let a=Dm(o,i,t);if(a===void 0)return;let l=iq(o,i,a)?sq(a):Vo(i,a);return l.reaches&&!(l.since<=o.now)&&(l.since=n.sinceOf(r,l.delay),l.shown=n.shownOf(r,l.since)),l.from=l.stepped,e.filled=!0,l}function lq(e,t){let n=t.patch,r=t.spec;if(n.state!==void 0||n.step!==void 0)return"its patch keeps state";if(t.motion!==void 0)return"it plays a motion";if(t.keeping)return"its patch or its weight keeps state";if(r.from==="current")return"it starts from the pose its subjects had";if(t.written)return"its handle has been written to";if(r.anchor!==void 0)return"an anchor places it";if(t.holding!==null)return"it is an owner";if(t.owner!==null)return"it plays under an owner";if(!(typeof r.weight!="function"&&r.role===void 0&&!((t.fade.in??0)>0)&&!((t.fade.out??0)>0))&&t.slots.some(i=>e.channels[i]?.rest===void 0))return"it writes a channel with no rest at a weight that moves"}function _D(e,t){let n=`blits: reading back to ${t} needs a mix made with history`;if(e.pace!==null)throw new Error(`${n}: the mix's rate has been set`);if(t<e.settled)throw new Error(`${n}: a mix changed or a voice left at ${e.settled}, and without history a mix keeps only how it stands now`);for(let r of e.members)for(let o of r.cued){if(o.state==="done")continue;let i=lq(r,o);if(i!==void 0)throw new Error(`${n}: voice ${o.id} is cued, and ${i}`)}}function DD(e,t,n,r){Mc(e,t),t.backward=!0,t.cued=e.cued.filter(o=>o.state!=="done").map(o=>{let i=o.copy(a=>jT(e,o,a,n,r));i.out!==null&&i.out.at>n&&(i.out=null);let s=e.pins?.get(o);return s!==void 0&&Ho(t,i,s),i}),Ca(t.cued),e.owners!==null&&Sa(t.cued),KT(t,n),Wo(t)}function _m(e,t){let n=e.history!==void 0,r,o;if(typeof t=="number")r=t;else{if(!n)throw new Error("blits: reading a frame back needs a mix made with history");o=Om(e,t.frame),r=o.at}let i=o!==void 0?o.seq===e.seq:Number.isNaN(e.now)||r>=e.now,s=e.pace,a={seq:e.seq,strict:!1},l=i?$r(e,r):ji(e,r);if(!i&&n){o===void 0&&Wa(e,r);let m=o??e.frames.at(r);m!==void 0&&(a={seq:m.seq,strict:m.at===r},m.at===r&&(l=m.u))}else i||_D(e,r);let u=new zo(void 0,!0);u.offset=e.offset,u.u=l,u.nextId=e.nextId,u.now=i?e.now:r,u.pace=s===null||!$t(a,e.pacedSeq)?null:s.until(i?Number.POSITIVE_INFINITY:l),u.announced=(i?e.announced:e.announced.filter(m=>$t(a,m.seq))).map(m=>({...m}));let c=new Map;for(let m of e.members){let g=new Ko(m.kit,{...m.opts,history:void 0,lanes:!1,transport:u},null);g.slot=m.slot,g.projecting=!0,g.share=m.share,g.places=m.places,c.set(m,g),i?zT(m,g):n?uq(m,g,r,a):DD(m,g,r,a)}let d=u,f=null;i&&r!==e.now&&(f=new Map,d=FD(e,u,c,r,f));let p=!i&&n?a:null,h=m=>{pe.live=!1,pe.ahead=d.ahead.size>0?d.ahead:null,pe.back=p;try{return m()}finally{pe.live=!0,pe.ahead=null,pe.back=null}};return{timestamp:r,of(m){let g=m,b=c.get(g);if(b===void 0)throw new Error("blits: that mix is not on this transport");let x=f?.get(g),w=x===void 0?null:y=>{if(!x.met.has(y)){x.met.add(y);for(let P of x.at)P.fold(y)}};return{timestamp:r,probe:(y,P)=>h(()=>(w?.(y),b.fold(y,P))),assess:y=>h(()=>(w?.(y),b.fold(y),cq(b,y)))}}}}function uq(e,t,n,r){Mc(e,t),t.backward=!0;let o=Sc(e.hostLog,{seq:r.seq,strict:!1}),i=e.opts.host,s=o&&typeof i=="object"&&i!==null?Object.assign(Object.create(i),o.fields):void 0;o&&(t.hostThen=o),t.cued=[...e.cued,...e.gone].filter(a=>a.cuedSeq<=r.seq&&!$t(r,a.doneSeq,!0)).sort((a,l)=>a.id-l.id).map(a=>{let l=a.log,u=a.copy(c=>jT(e,a,c,n,r,t,u),Sc(l,r)??l[0]);if(s!==void 0&&(u.setting.host=s),a.parts!==null&&(u.parts=new Map(a.parts)),a.parted!==null&&(u.parted=new Map(a.parted)),a.left!==null&&ym(u,a.left.after(r),r.seq),u.parted!==null)for(let[c,d]of u.parted)d.ramp===void 0||!(n<d.at)||(u.parts??=new Map,u.parts.set(c,d.ramp));return u}),Ca(t.cued),e.owners!==null&&Sa(t.cued,r.seq),KT(t,n,r),Wo(t)}function KT(e,t,n){for(let r of e.cued)r.state=r.stateAt(t,n)}function jT(e,t,n,r,o,i,s){let a=t.left?.at(n,o)??Nh(t,n,Dm(e,t,n),r,o.seq);if(a===void 0)return;let l=a.snaps&&_a(a.snaps,r,!0);if(l){let f=Vo(t,l.held);return i!==void 0&&s!==void 0&&!(f.since<=l.at)&&Aa(i,s,f),f.from=f.stepped,f.replay=a.inputs,f}let u=i===void 0||s===void 0?a.since:i.sinceOf(s,a.delay),c=On(t,a.reaches,a.reaches&&t.patch.state?t.patch.state(n):void 0);c.delay=a.delay,c.since=u,c.shown=i===void 0||s===void 0?a.shown:i.shownOf(s,u);let d=FP(e,t,c,r);return c.rebuilt=t.rebuilds,c.from=c.stepped,c.unknown=t.spec.from==="current"||d,c.replay=a.inputs,c}function cq(e,t){let n={};for(let i of e.names)n[i]="exact";let r={exact:0,stepped:1,held:2};for(let i of e.cued){let s=i.spec.anchor;if(!(s===void 0||i.state==="done"||!(i.state==="pending"&&!Number.isFinite(i.start)||i.state!=="pending"&&i.state!=="fading"&&(s.out!==void 0||s.end!==void 0)&&!Number.isFinite(i.outAt))||!e.aims(i,t)))for(let l of i.slots)n[e.names[l]]="held"}let o=(i,s)=>{if(i.state==="done"||s.weight<=0)return;let a=dq(e,i,s);for(let l of i.slots){let u=e.names[l];r[a]>r[n[u]]&&(n[u]=a)}};for(let i=e.chain(t);i!==null;i=i.next)i.voice!==null&&o(i.voice,i);for(let i of e.sharers)i.everyone!==null&&i.state!=="pending"&&o(i,i.everyone);return n}function dq(e,t,n){let r=t.spec.weight;if(n.unknown)return"held";let o=n.replay!==void 0&&_a(n.replay,e.now,!0)!==void 0;if(typeof r=="function"&&r.input&&!o||t.owner!==null&&VO(t))return"held";let i=t.patch.reads;if(i!==void 0&&i.length>0){let s=e.hostThen?.fields;if(s===void 0||!i.every(a=>a in s))return"held"}if(e.now>(n.from??e.now)){let s=Io(e,t)!==void 0,a=n.kept!==null&&n.kept.size>0&&!o&&e.backward;if(t.patch.step&&!s||a)return"stepped"}return n.copied&&n.kept!==null&&n.kept.size>0&&!o?"stepped":"exact"}var Bm=class{list=[];from=0;push(t,n){this.list.length>=64&&(this.list=this.list.slice(32),this.from+=32),this.from+this.list.length!==n-1&&(this.list=[],this.from=n-1),this.list.push(t)}patch(t,n,r,o,i){if(!(n>=this.from))return;let s=this.list;for(let a=n-this.from;a<s.length;a++){let l=s[a];if(l==null)return;let u=null,c=t;for(;c!==null&&c.voice.id<l.id;)u=c,c=c.next;let d=c!==null&&c.voice===l?c:null,f=r.linkable(l,o,i);if(f===d)continue;let p=d===null?c:d.next;f!==null&&(f.voice=l,f.next=p);let h=f??p;u===null?t=h:u.next=h}return t}};function BD(e){this.restStamps??=new me;let t=this.linked(e),n=this.linkedLaned,r=this.lanes;if(n&&this.restsLaned()){let s=t.slot;if(!r.owes(s))return r.rests(s)}let o=(this.restStamps.get(e)??Number.NaN)-2*this.restsKey();if(o>=0)return o===1;this.restScratch??=this.pose();let i=this.foldWith(e,this.restScratch,t,n,!0);return this.rests(this.bounded.length===0?i:this.clamp(i))}function HD(e){for(let t=0;t<this.names.length;t++){let n=this.channels[t],r=e[this.names[t]];if(n.rest===void 0){if(r!==void 0)return!1}else if(!hc(r,n.rest))return!1}return!0}function GD(){return this.pace?.stopped(this.u)?this.cued.every(e=>e.state==="done"||e.state!=="pending"&&typeof e.spec.weight!="function"&&e.spec.anchor===void 0):this.cued.every(e=>this.still(e,this.now))}function UD(e,t){if(e.state==="done")return!0;if(e.state!=="frozen"&&e.state!=="live"||typeof e.spec.weight=="function"||e.parts!==null)return!1;let n=this.reducedNow?0:e.fade.in??0;if(n>0&&t-this.sinceOf(e,e.latest)<n)return!1;if(e.state==="frozen"||e.holding!==null)return!0;let r=e.motion;if(r===void 0||!(e.elapsedAt(t)>=e.latest))return!1;let o=e.early;if(o!==null){for(let i of o)if(i.since<=t&&!(i.probed>=i.since))return!1}return r.landed()}function WD(){return this.lanes.whole&&this.bounded.length===0}function VD(){return(this.frame!==this.restsFrame||this.version!==this.restsVersion||this.relinks!==this.restsRelinks||this.stirs!==this.restsStirs)&&(this.restsEpoch++,this.restsFrame=this.frame,this.restsVersion=this.version,this.restsRelinks=this.relinks,this.restsStirs=this.stirs),this.restsEpoch}function zD(e){return{n:0,voices:[],helds:[],deltas:[],weights:[],groups:[],names:[],m:0,mVoices:[],mDeltas:[],mWeights:[],mGroups:[],values:new Array(e).fill(void 0),taken:new Float64Array(e),heaviest:new Float64Array(e),met:new Uint8Array(e),touched:[],owned:new Array(e).fill(void 0)}}function fq(e,t,n,r){let o=e.owned[t];o===void 0&&(o=r.slice(),e.owned[t]=o);for(let i=0;i<o.length;i++)o[i]=i<n.length?n[i]:r[i];return o}function KD(e,t){e.touched.length=0;let n=0;for(let o=0;o<e.m;o++)e.mGroups[o]===t&&(n+=e.mWeights[o]);if(n<=0)return 0;let r=e.taken;for(let o=0;o<e.m;o++){if(e.mGroups[o]!==t)continue;let i=e.mWeights[o];if(i<=0)continue;let s=e.mDeltas[o],a=e.mVoices[o].slots;for(let l=0;l<a.length;l++){let u=a[l],c=s[this.names[u]];if(c===void 0)continue;let d=this.channels[u];if(e.met[u]===0){e.met[u]=1,e.touched.push(u),r[u]=i,e.heaviest[u]=i,e.values[u]=this.lerpsInto[u]!==void 0&&d.scale&&Array.isArray(c)?fq(e,u,c,d.rest):Hi(c);continue}let f=r[u]+i;if(r[u]=f,d.kind==="last"){i>=e.heaviest[u]&&(e.heaviest[u]=i,e.values[u]=Hi(c));continue}let p=e.values[u],h=this.lerpsInto[u];e.values[u]=h!==void 0&&p===e.owned[u]?h(p,p,c,i/f):d.lerp(p,c,i/f)}}for(let o=0;o<e.touched.length;o++)e.met[e.touched[o]]=0;return n>1?1:n}function pq(e,t,n){return e===null?!1:n>=t.length||e.voice===null?!0:t[n].id>e.voice.id}function jD(e,t,n,r,o,i,s){let a=this.now,l=this.roleScratch[this.roleDepth];l===void 0&&(l=zD(this.channels.length),this.roleScratch[this.roleDepth]=l),this.roleDepth++;try{l.n=0,l.m=0,l.names.length=0;let u=this.sharers,c=0,d=n;for(;d!==null||c<u.length;){let p=pq(d,u,c),h,m;if(p?(m=d,h=m.voice,d=m.next):(h=u[c++],m=h.state==="pending"?null:h.everyone),h===null||m===null||r&&h.laned&&!this.owedBy(s,h)||h.id===i||h.state==="done")continue;let g=m;p||this.share.open(h,g,n.slot);let b=this.read(h,e,a,o,g);s>=0&&h.laned&&this.lanes.paid(h.id,s,g.weight),p||(c=this.shared(h,n.slot,g,c));let x=h.spec.role;if(b===null){x===void 0&&!(g.weight>0)&&kt(g);continue}let w=-1;if(x!==void 0){w=l.names.indexOf(x);let P=l.m++;if(l.mVoices[P]=h,l.mDeltas[P]=b,l.mWeights[P]=this.w,w>=0){l.mGroups[P]=w;continue}w=l.names.length,l.names.push(x),l.mGroups[P]=w}let y=l.n++;l.voices[y]=h,l.helds[y]=g,l.deltas[y]=b,l.weights[y]=x===void 0?this.w:0,l.groups[y]=w}let f=n.roles;f===null&&(f=new Map,n.roles=f);for(let p=0;p<l.n;p++){let h=l.groups[p];if(h<0){let x=l.weights[p];x>0?this.apply(t,l.voices[p],l.helds[p],l.deltas[p],x):kt(l.helds[p]);continue}let m=this.foldRole(l,h),g=l.names[h];if(!(m>0)){f.get(g)?.fill(2);continue}let b=f.get(g);b===void 0&&(b=new Uint8Array(this.channels.length),f.set(g,b));for(let x=0;x<l.touched.length;x++){let w=l.touched[x],y=l.values[w];l.values[w]=void 0;let P=this.names[w],S=this.channels[w],v=l.taken[w],A=v>1?1:v;if(S.rest!==void 0&&S.scale){t[P]=S.fold?S.fold(t[P],y,A):pc(S,t[P],S.scale(y,A));continue}let N=b[w],M=this.passes(N===0?void 0:N===1,A);b[w]=M?1:2,M&&(t[P]=t[P]===void 0?Hi(y):pc(S,t[P],y))}}return t}finally{for(let u=0;u<l.n;u++)l.voices[u]=null,l.helds[u]=null,l.deltas[u]=null;for(let u=0;u<l.m;u++)l.mVoices[u]=null,l.mDeltas[u]=null;for(let u=0;u<l.touched.length;u++){let c=l.touched[u];l.met[c]=0,l.values[c]=void 0}l.touched.length=0,this.roleDepth--}}function $D(e,t){if(e.frame=st(),t===void 0)for(let n of e.cued)n.motion===void 0&&n.holding===null&&(n.seeks++,n.touches++);else{let n=ut(e,t)??null;for(;n!==null;n=n.next)n.seeks=-1;let r=ut(e,t)?.slot??-1;for(let o of e.sharers)e.share?.restamp(o,r)}e.lanes?.refill(),e.stir()}var hq=1e-6,mq=(e,t)=>Math.abs(e-t)<=1e-6*Math.max(1,Math.abs(e),Math.abs(t));function YD(e,t,n,r={}){if(!(t<=n)||!Number.isFinite(t)||!Number.isFinite(n))throw new RangeError(`blits: a trace runs from a time to one no earlier, not ${t} to ${n}`);let o=r.grid??5;if(!(o>0&&o<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a trace's grid is a finite number of ms above 0, not ${o}`);let i=yq(e,t),s=new Map,a=new Map,l=new Map,u=(c,d)=>{let f=a.get(c);f===void 0&&(f=new Map,a.set(c,f));let p=f.get(d);if(p===void 0){let h=s.get(d);h===void 0&&(h=e.project(d),s.set(d,h)),p=h.probe(c,e.pose()),f.set(d,p)}return p};return{from:t,to:n,of(c,d){let f=d,p=e.slotOf.get(f);if(p===void 0)throw new Error(`blits: the mix has no channel ${f}`);let h=N=>{let M=u(c,N)[f];return typeof M=="number"?M:Number.NaN},m=l.get(c);m===void 0&&(m=gq(e,c,t,n),l.set(c,m));let g=e.scalars[p],b=i&&!m.unknown.has(p)&&!e.bounded.includes(p)&&(g==="sum"||g==="mul"&&(m.writers.get(p)??0)<=1),x=m.bent.get(p),w=(N,M)=>b&&(x===void 0||x.every(([C,F])=>!(C<M&&F>N)));if(t===n)return{at:[t],value:[h(t)],exact:b};let y=[],P=[],S=!0,v=(N,M)=>{let C=y.length;C>0&&y[C-1]===N&&mq(P[C-1],M)?P[C-1]=M:(y.push(N),P.push(M))},A=[t,...m.knots.get(p)??[],n];for(let N=0;N+1<A.length;N++){let M=A[N],C=A[N+1];if(w(M,C)){let B=M+(C-M)/3,D=C-(C-M)/3,j=h(B),W=(h(D)-j)/(D-B);v(M,j-W*(B-M)),v(C,j+W*(C-B));continue}S=!1;let F=Math.min(hq,(C-M)/4);v(M,h(M===t?M:M+F));for(let B=Math.max(0,Math.ceil((M-t)/o));;B++){let D=t+B*o;if(D>=C-F)break;D>M+F&&v(D,h(D))}v(C,h(C===n?C:C-F))}return{at:y,value:P,exact:S}}}}function yq(e,t){let n=e.transport;if(!(t>=e.now))return!1;let r=n.tape;return r===void 0||r.timestampAt(r.undoDepth())===void 0}function gq(e,t,n,r){let o={knots:new Map,bent:new Map,unknown:new Set,writers:new Map};for(let i of e.cued)if(!(i.state==="done"||!e.aims(i,t))&&!xq(e,i,t,n,r,o))for(let s of i.slots)o.unknown.add(s);for(let[i,s]of o.knots)o.knots.set(i,s.sort((a,l)=>a-l).filter((a,l,u)=>l===0||a!==u[l-1]));return o}var bq=4096;function xq(e,t,n,r,o,i){let s=t.spec,a=t.built,l=t.patch;if(l.form!=="keys"||a===null||l.step!==void 0||typeof s.weight=="function"||t.owner!==null||t.holding!==null||t.fitting!==null||t.arc!==null||t.blend!==null||s.anchor!==void 0||s.role!==void 0||s.within!==void 0||s.stepMs!==void 0||s.from!==void 0||t.ramp!==null||!(t.rate>0)||t.out!==null||t.back!==null||t.stalls!==null||t.parts!==null||t.parted!==null||t.left!==null||Number.isFinite(t.outAt)||t.state==="fading"||t.state==="pending"&&e.transport.pace!==null)return!1;let u=[],c=[],d=new Map,f=P=>{P>r&&P<o&&u.push(P)},p=e.reduced,h=t.sharing?void 0:t.subjects.get(n),m=h?.delay??(s.stagger?s.stagger(n):0),g=P=>t.timeAt(P+m),b=p?0:t.fade.in??0;if(b>0){if(h===void 0)return!1;h.shown+b>r&&(c.push([h.shown,h.shown+b]),f(h.shown),f(h.shown+b))}let x=t.duration,w=t.span;f(t.start),f(g(0)),Number.isFinite(w)&&f(g(w));let y=t.endsAt();if(f(y),!t.freezesAfter&&Number.isFinite(y)){let P=p?0:Number.isNaN(t.outOver)?t.fade.out??0:t.outOver,S=Math.max(t.start,y);f(S),P>0&&(c.push([S,S+P]),f(S+P)),s.stagger!==void 0&&c.push([g(w),Number.POSITIVE_INFINITY])}if(x>0){let P=Math.max(0,Math.floor((t.elapsedAt(r)-m)/x)),S=Math.min(Math.ceil(t.passes)-1,Math.floor((t.elapsedAt(o)-m)/x)),v=0;for(let A of a.tracks)v+=A.all.length+1;if((S-P+1)*v>bq)return!1;for(let A=P;A<=S;A++){let N=A*x;f(g(N)),f(g(N+x));for(let M of a.tracks){let C=e.slotOf.get(M.channel);if(M.numbers===null)return!1;let F=M.delay;if(F>=x)continue;F>0&&f(g(N+F));let B=Number.NaN;for(let D of M.all){let j=g(N+F+Math.min(1,Math.max(0,D.at))*(x-F));if(f(j),!Number.isNaN(B)&&!nO(D.ease)){let W=d.get(C);W===void 0?d.set(C,[[B,j]]):W.push([B,j])}B=j}}}}for(let P of t.slots){let S=i.knots.get(P);S===void 0?i.knots.set(P,[...u]):S.push(...u),i.writers.set(P,(i.writers.get(P)??0)+1);let v=[...c,...d.get(P)??[]];if(v.length===0)continue;let A=i.bent.get(P);A===void 0?i.bent.set(P,v):A.push(...v)}return!0}function qD(e,t){let n=this.primed[0],r=this.primed[1],o=this.primed[2],i=e.setting;i.timestamp=n,e.patch.step===void 0&&t.probed<n&&(t.stepped=t.probed),i.dt=this.capped(n-t.stepped),i.elapsed=r,i.pass=o,i.weight=0,i.state=t.state,i.mark=0,e.keepOn=t}function XD(e,t,n){let r=this.now,o=e.setting;o.mark!==n[6]&&wq(o,r,n),e.patch.step===void 0&&t.probed<r&&(t.stepped=t.probed),o.dt=this.capped(r-t.stepped),o.weight=0,o.state=t.state,e.keepOn=t}function wq(e,t,n){e.timestamp=t,e.elapsed=n[1],e.pass=n[3],e.mark=n[6]}function JD(e){let t=this.opts.maxDt;return this.reducedNow?Number.POSITIVE_INFINITY:t!==void 0&&e>t?t:e}function QD(e,t,n){let r=this.opts.history;return r===void 0?Number.POSITIVE_INFINITY:dT(this,e,n-r.ms)-t}function ZD(e,t,n){return ma(e.fade.in??0,e.out,e.ease,this.reducedNow,t,n,e.back,e.stalls)}function eB(e,t){return zO(e,this.now,this.reducedNow,n=>this.ownerBase(n,t))}function tB(e,t){let n=this.now,r=this.held(e,t,-1);if(r.probed===this.frame)return r.phase;let o=pe.kept;r.probed=Number.NaN;let i=this.primed;i[0]=n,i[1]=e.elapsedAt(n),i[2]=0,this.prime(e,r);let s=this.base(e,t,n,r);return pe.kept=o,r.stepped=n,r.probed=this.frame,r.phase=s,s}function nB(e,t,n,r){if(e.owner!==null)return this.weighOwned(e,t,n,r);let o=this.base(e,t,n,r),i=this.envelope(e,n,r.shown);return jt(o,i,e.parts===null?1:this.parting(e,t,n))}function rB(e,t,n,r){let o=this.ownedBy(e,t),i=this.base(e,t,n,r),s=this.envelope(e,n,r.shown)*o;return jt(i,s,e.parts===null?1:this.parting(e,t,n))}function oB(e,t,n,r,o=-1){this.sending.voice=e,this.sending.subject=t;let i=typeof e.spec.weight=="function"?e.spec.weight:null;if(i===null)return e.weight;let s=r.replay&&_a(r.replay,n,!0),a=s?s.value:e.blend===null?i(t,e.setting):this.blended(e,t,r,o);return i.input&&!s&&pm(this,e,t,r,a),a}var Pq={lanes:!0},Ko=class{kit;opts;lanesOf;cued=[];gone=[];goneIx=new jh;scored=new Fh;projecting=!1;backward=!1;moving=!1;looked=!1;hostLog=[];hostThen;lastPoses=new me;transport;slot=-1;dropped=!1;name;frame=st();pins=null;wantsPose=!1;scratch;due=new Ih;retired=[];walkAll=!1;leapt=null;pulled=[];pulledHeads=[];pulledSlots=new Int32Array(0);pulledVersion=Number.NaN;pulledRelinks=-1;pullColumns=null;relinks=0;reducedNow=!1;stirred=!1;asleep=!1;waking=!1;stirs=0;syncing=!1;stirFns=null;stir(){if(this.stirs++,this.moving||this.transport.settle(),this.stirred||(this.stirred=!0,this.syncing))return;let t=this.stirFns;if(t!==null)for(let n of[...t])n();this.transport.woke()}onWake(t){this.stirFns===null&&(this.stirFns=[]);let n=this.stirFns;return n.push(t),()=>{let r=n.indexOf(t);r>=0&&n.splice(r,1)}}chains=new me;version=0;places=null;primed=new Float64Array(3);steps=new Bm;named=new me;parters=new Set;departed=new Xh;strays=new me;strayAll=new Set;playing=new Map;naming=0;general=[];sharers=[];unshared=!1;detours=0;roleVoices=0;roleTags;owner=null;anchored=0;sent=[];sending={voice:null,subject:void 0};send=t=>{let{voice:n,subject:r}=this.sending;n===null||this.projecting||n.setting.timestamp<=this.sentTo||this.sent.push({timestamp:n.setting.timestamp,subject:r,voice:n.id,tags:n.spec.tags??fn,event:t})};sentTo=Number.NEGATIVE_INFINITY;w=0;names;channels;bounded;lerpsInto;scalars;roleScratch=[];roleDepth=0;slotOf=new Map;lanes;share;handles=null;bookers=null;fitting=null;arcing=null;owners=null;keys=null;outs=null;pose;constructor(t,n,r){if(this.kit=t,this.opts=n,this.lanesOf=r,this.names=Object.keys(t),this.channels=this.names.map(i=>t[i]),this.bounded=this.channels.flatMap((i,s)=>i.bounds?[s]:[]),this.lerpsInto=this.channels.map(i=>Ph(i)),this.pose=qL(this.names,this.channels),this.scalars=this.channels.map(i=>B2(i)),this.names.forEach((i,s)=>{this.slotOf.set(i,s)}),r===null&&n.lanes===!0)throw new Error("blits: '@msb235/blits/lean' has no lanes; take mix from '@msb235/blits'");this.share=r?.share??null,this.lanes=r!==null&&(n.lanes??Pq.lanes)?new r(Zh(this)):null,this.name=n.name,this.roleTags=gL(n);let o=n.transport;if(o!==void 0){if(n.history!==void 0)throw new Error("blits: a mix on a transport keeps the history the transport keeps, not its own");this.opts={...n,history:o.history},this.transport=o}else this.transport=new zo(n.history,!1);this.transport.pager!==null&&(this.keys=new Oh(n.keyOf),this.outs=new dm,o!==void 0&&Sq(o,n.name)),this.transport.join(this)}own(t){if(this.transport.shared)throw new Error(`blits: ${this.name??"this mix"} plays on a transport, so ${t} goes to the transport`);return this.transport}get now(){return this.transport.now}set now(t){this.transport.now=t}get u(){return this.transport.u}set u(t){this.transport.u=t}get offset(){return this.transport.offset}set offset(t){this.transport.offset=t}get pace(){return this.transport.pace}set pace(t){this.transport.pace=t}get announced(){return this.transport.announced}set announced(t){this.transport.announced=t}get nextId(){return this.transport.nextId}set nextId(t){this.transport.nextId=t}get timestamp(){return this.transport.last}get seq(){return this.transport.seq}get last(){return this.transport.last}get tape(){return this.transport.tape}get replaying(){return this.transport.replaying}get reduced(){let t=this.opts.reduce;return typeof t=="function"?t():t===!0}get band(){return this.opts.band??O2}cue(t){this.attached();let n=this.opts.engine;if(n!==void 0&&!n.runs.has(t.patch.form))throw new Error(`blits: engine ${n.name} does not run ${t.patch.form} patches`);return yL(this,t)}blend(t,n,r={}){let o=`blend:${this.nextId}`,i=fc(n,t.length-1);return t.map((s,a)=>{let l={...r,patch:s,weight:n,role:o};"patch"in s&&(l.patch=s.patch,s.name!==void 0&&(l.name=s.name),s.tags!==void 0&&(l.tags=s.tags),s.hits!==void 0&&(l.hits=s.hits));let u=this.cue(l),c=this.cued[this.cued.length-1];return c.blend={of:i,i:a},i.members.push(c),u})}owns(t){if(t.loop!==void 0)throw new Error("blits: an owner does not loop: a pass would have to restart its children");return this.cue({...t,patch:Wi})}span(t){if((t.rate??1)<0)throw new Error("blits: a span lays out its children forward from its start, so it is not cued backward");this.fitting=new fm(t);try{let n=this.owns(t);return Dn(this,this.owners?.find(r=>r.handle===n)),n}finally{this.fitting=null}}arc(t){return YL(this,t)}sync(t){this.own("sync").sync(t)}book(t){return EF(this,t)}probe(t,n){this.looked=!0;let r=this.fold(t,n);return this.keep(t,r,n),this.restStamps!==null&&!(this.linkedLaned&&this.restsLaned())&&this.restStamps.set(t,2*this.restsKey()+(this.rests(r)?1:0)),r}pull(t,n){this.looked=!0,p_(this,t,n)}seek(t){if(this.projecting)throw new Error("blits: a projection does not seek");Va(this.own("seek"),t)}prepare(t){return this.own("prepare").prepare(t)}project(t){return _m(this.transport,t).of(this)}trace(t,n,r){return YD(this,t,n,r)}announce(t,n={}){this.attached(),VT(this.transport,t,n,this.slot,this.name)}attached(){if(this.dropped)throw new Error(`blits: ${this.name??"this mix"} was dropped from its transport`)}marks(t,n){return Yh(this,t,n).map(({order:r,...o})=>o)}rebase(){this.own("rebase").rebase()}voices(t){let n=[];for(let r of this.cued)r.state!=="done"&&(t===void 0||r.spec.tags?.includes(t))&&n.push(r.handle);return n}get live(){return this.cued.some(t=>t.state!=="done")}get inert(){if(this.stirred)return!1;let t=this.restful();return t&&!Number.isNaN(this.now)&&(this.asleep=!0),t}get rate(){return this.transport.rate}set rate(t){this.own("rate").ramp(t,0)}ramp(t,n){this.own("ramp").ramp(t,n)}close(){ND(this)}mute(t){for(let n of this.cued)n.written=!0,qr(this,n,{over:t?.over});Ot(this,"mute",n=>n.mix(this)?.mute(t))}touch(t){this.attached(),$D(this,t)}drain(t){let n=this.sent;if(n.length===0)return[];let r=n;if(t===void 0)this.sent=[];else{r=[];let o=[];for(let i of n)(i.tags.includes(t)?r:o).push(i);this.sent=o}return r.sort((o,i)=>o.timestamp-i.timestamp)}folding=new Set;linkedLaned=!1;restStamps=null;restsEpoch=0;restsFrame=Number.NaN;restsVersion=Number.NaN;restsRelinks=-1;restsStirs=-1;restScratch},Tq={fold:KF,folded:jF,linked:$F,foldWith:YF,owedBy:JF,foldRoles:jD,foldDetour:qF,foldSharers:XF,shared:zF,read:a_,contribution:e_,keyed:t_,tick:r_,apply:WF,clamp:VF,passes:UF,isRest:s_,baseFor:o_,slopeFor:i_,prime:qD,primeLaned:XD,capped:JD,horizonFor:QD,weigh:nB,weighOwned:rB,base:oB,envelope:ZD,ownedBy:eB,ownerBase:tB,blended:LF,laneRead:_F,shareKept:DF,parting:VL,chain:aO,relink:lO,linkable:uO,aims:cO,held:JO,unreachedOf:XO,sinceOf:QO,shownOf:ZO,keep:f_,foldRole:KD,atRest:BD,rests:HD,restful:GD,still:UD,restsLaned:WD,restsKey:VD,plot:hD,place:mD,moved:gD,put:bD,around:GF,drop:l_,forgetIn:u_,releaseIn:c_,recordDrop:d_};for(let[e,t]of Object.entries(Tq))Object.defineProperty(Ko.prototype,e,{value:t,writable:!0,configurable:!0});function Sq(e,t){if(t===void 0)throw new Error("blits: a mix on a transport whose history has a store needs a name, which its records are keyed by");if([...e.members,...e.dropped.map(r=>r.mix)].some(r=>r.name===t))throw new Error(`blits: a mix named ${t} is already on this transport, or a seek could bring it back`)}function kq(e,t,n){let{history:r,added:o}=vD(t),i=new Ko(e,o?{...t,history:r}:t,n);return o&&AD(i.transport),RD(i),i}var iB={name:"mixer",runs:new Set(["fn","keys","motion"]),create(e,t){return kq(e,t,Rc)}};function $T(e,t={}){return(t.engine??iB).create(e,t)}function Hm(e,t,n){for(let r=t;r!=null;r=n(r))if(e.has(r))return r;return null}function Cc(e,t){if(e.length<2)return e;let n=new Set(e),r=o=>{let i=t(o);return i!=null&&Hm(n,i,t)!==null};return e.some(r)?e.filter(o=>!r(o)):e}Z();var za={getBounds:e=>et(e),remapBounds:(e,t,n)=>Rt(e,hr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height)),fromBounds:e=>({kind:"rect",x:e.x,y:e.y,width:e.width,height:e.height}),translate:(e,t,n)=>Ag(e,t,n),lerp:(e,t,n)=>{if(e.kind==="rect"&&t.kind==="rect")return{kind:"rect",x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,width:e.width+(t.width-e.width)*n,height:e.height+(t.height-e.height)*n};if(e.kind==="polygon"&&t.kind==="polygon"&&e.coords.length===t.coords.length){let r=$e(e),o=$e(t),i=new Float64Array(r.length);for(let c=0;c<r.length;c++)i[c]=r[c]+(o[c]-r[c])*n;let s=At(e.origin,i),{corners:a,...l}=e,u=ig(e.corners,t.corners,n);return u?{...l,coords:s,corners:u}:{...l,coords:s}}throw new Error("pathPoseDescriptor.lerp: incompatible path shapes")},axes:e=>e.kind==="rect"?{count:4,names:["x","y","width","height"],to:t=>t.kind==="rect"?[t.x,t.y,t.width,t.height]:[],from:t=>({kind:"rect",x:t[0],y:t[1],width:t[2],height:t[3]}),add:(t,n)=>t.kind!=="rect"?t:{kind:"rect",x:t.x+n[0],y:t.y+n[1],width:t.width+n[2],height:t.height+n[3]},write:(t,n,r)=>{t.kind==="rect"&&(n[r]=t.x,n[r+1]=t.y,n[r+2]=t.width,n[r+3]=t.height)}}:{count:e.coords.length,to:t=>t.kind==="polygon"?Array.from($e(t)):[],from:t=>({...e,coords:At(e.origin,t)}),add:(t,n)=>{if(t.kind!=="polygon")return t;let r=Float64Array.from($e(t));for(let o=0;o<r.length;o++)r[o]+=n[o];return{...e,coords:At(e.origin,r)}},write:(t,n,r)=>{if(t.kind!=="polygon")return;let o=$e(t);for(let i=0;i<o.length;i++)n[r+i]=o[i]}},supportsRotation:()=>!1};function ir(e){return!!e&&typeof e=="object"&&"kind"in e&&(e.kind==="polygon"||e.kind==="rect")}function Ka(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"}var jo={getBounds:e=>ir(e)?za.getBounds(e):Mt.getBounds(e),remapBounds:(e,t,n)=>ir(e)?za.remapBounds(e,t,n):Mt.remapBounds(e,t,n),fromBounds:(e,t)=>ir(t)?za.fromBounds(e,t):Mt.fromBounds(e,t),translate:(e,t,n)=>ir(e)?za.translate(e,t,n):Mt.translate(e,t,n),axes:e=>Ka(e)?Mt.axes(e):ir(e)?za.axes(e):null,getRotation:e=>{if(ir(e))return 0;let t=e.rotation;return typeof t=="number"?t:0},supportsRotation:e=>!ir(e),withRotation:(e,t)=>ir(e)?e:{...e,rotation:t}};function sB(e){return t=>pa(e,t)}function aB(e,t){let n=sB(e);return(r,o,i,s)=>{let a=s?.inherited??n(r);return a===void 0?t(r,o,i,s):t(r,o,i,{...s,inherited:a})}}function lB(e,t){let n=sB(e);return(r,o,i,s)=>{let a=s?.inherited??n(r);return t(r,o,i,a===void 0?s:{...s,inherited:a})}}Z();function YT(e,t){switch(e){case"union":return Xf(...t);case"intersect":return bx(...t);case"exclude":return wx(...t);case"subtract":{let n=t.length===2?t[1]:Xf(...t.slice(1));return xx(t[0],n)}}}var qT="kit:booleanOfChildren",Aq=new Set(["union","intersect","subtract","exclude"]);function uB(e){let t=e?.boolean;return typeof t=="string"&&Aq.has(t)?t:"union"}var cB=e=>e.path;function dB(e){cB=e}function Rq(e){if(e.node.kind!=="group")return cB(e);let t=fB(e.children??[]);return t.length<=1?t[0]??null:YT("union",t)}function fB(e){let t=[];for(let n of e){if(n===void 0||n.node.hidden===!0)continue;let r=Rq(n);r!==null&&t.push(r)}return t}function XT(e,t){let n=fB(t);if(n.length===0)return null;let r=uB(e.data);return n.length===1&&r!=="subtract"?n[0]:YT(r,n)}Z();var ja="shape:paint";function Gm(e){return(e.dependsOn?.length??0)>0&&e.derivePath!==void 0}Z();Pe();Pe();Z();Bu.subscribe(Xu);function sr(e,t){if(e===null)return{outset:0,inset:0};let n=gu(e),r=(l,u)=>{switch(e.align??"center"){case"inner":return{outset:u,inset:l};case"outer":return{outset:l+u,inset:0};default:return{outset:l/2+u,inset:l/2}}},o=e.width??1,i=Pi(typeof o=="object"?0:at(o,t??1),e.vertexWidths),s=r(i,n.world);if(typeof o!="object"&&!(n.px>0))return s;let a=r(typeof o=="object"?o.px:0,n.px);return{outset:s.outset,inset:s.inset,outsetPx:a.outset,insetPx:a.inset}}function Nq(e,t){let n=sr(e,t);return n.outset+(n.outsetPx??0)/(t>0?t:1)}function Um(e,t){let n=t?.scale??1,r=t?.screen;if(!r){let d=Nq(e,n);return{x:d,y:d}}let o=sr(e,n),i=o.outsetPx??0;if(i===0)return{x:o.outset,y:o.outset};let[s,a,l,u]=r,c=Math.abs(s*u-a*l);return c>0?{x:o.outset+i*Math.hypot(l,u)/c,y:o.outset+i*Math.hypot(s,a)/c}:{x:o.outset,y:o.outset}}function $a(e,t){let n=t?.vertexColors,r=e[0];if(n===void 0||r?.kind!=="path")return e;let o=4*Rg(r.path),i=r.fill?n("fill",r.vertexColors):void 0,s=r.stroke?n("stroke",r.stroke.vertexColors):void 0,a=i?.length===o&&i!==r.vertexColors,l=s?.length===o&&s!==r.stroke?.vertexColors;return!a&&!l?e:[{...r,...a?{vertexColors:i}:{},...l?{stroke:{...r.stroke,vertexColors:s}}:{}},...e.slice(1)]}function JT(e,t){let n=Re(e.stroke,t?.stroke),r=Ne(e.fill,t?.fill);return n!==null?{fill:r,stroke:n}:{fill:r}}function ZT(e,t,n,r){let{sized:o,spaces:i}=r?Eq(e,t,r):Iq(t,n),s=at(o.width??1,1);if(!(s>0))return null;let a=new QT,l=t.align??"center";if(l!=="inner"){let u=l==="outer"?2:1,c=Vs(o,s),d=Ti(e,{...o,width:s*u,align:"center",vertexWidths:t.vertexWidths?.map(m=>Kl(m,u))},{startInset:pB(c.start,i.start,i.ribbon),endInset:pB(c.end,i.end,i.ribbon),...i.ribbon?{metric:i.ribbon.metric}:{}}),f=d.vertices,p=d.origin?.x??0,h=d.origin?.y??0;for(let m=0;m+1<f.length;m+=2)a.add(f[m]+p,f[m+1]+h,0)}for(let{entry:u,path:c,size:d}of yu(e,o,s,void 0,i)){let f=et(c),p=u.outline?u.outline.width*d/2:0;a.add(f.x,f.y,p),a.add(f.x+f.width,f.y+f.height,p)}return a.bounds()}function Iq(e,t){return{sized:{...e,width:at(e.width??1,t)},spaces:{}}}function Eq(e,t,[n,r,o,i]){let s=new Float32Array([n,r,0,o,i,0,0,0,1]),{cmd:a,spaces:l}=Hu(s,{kind:"path",path:e,stroke:t});return{sized:a.stroke,spaces:l}}function pB(e,t,n){return t?.metric===n?.metric?e:{length:e,metric:t?.metric??null}}var QT=class{x0=1/0;y0=1/0;x1=-1/0;y1=-1/0;add(t,n,r){this.x0=Math.min(this.x0,t-r),this.y0=Math.min(this.y0,n-r),this.x1=Math.max(this.x1,t+r),this.y1=Math.max(this.y1,n+r)}bounds(){return this.x0===1/0?null:{x:this.x0,y:this.y0,width:this.x1-this.x0,height:this.y1-this.y0}}},Mq="shape:drawn";function hB(e,t,n){let r=mB(e);if(!t)return r;let o=Um(t,n);return{x:r.x-o.x,y:r.y-o.y,width:r.width+2*o.x,height:r.height+2*o.y}}function Wm(e,t,n,r,o){let i=mB(t);if(n===null)return i;let s=r?.scale??1,a=r?.screen,l=rt(e,Mq,void 0,()=>({width:NaN,height:NaN,scale:NaN,screen:void 0,box:null}));if(l.width!==t.width||l.height!==t.height||l.scale!==s||!Cq(l.screen,a)){let p={x:0,y:0,width:t.width,height:t.height};l.width=t.width,l.height=t.height,l.scale=s,l.screen=a,l.box=ZT(o(p),n,s,a)}if(l.box===null)return i;let u=Math.min(i.x,t.x+l.box.x),c=Math.min(i.y,t.y+l.box.y),d=Math.max(i.x+i.width,t.x+l.box.x+l.box.width),f=Math.max(i.y+i.height,t.y+l.box.y+l.box.height);return{x:u,y:c,width:d-u,height:f-c}}function Cq(e,t){return e===t?!0:!!e&&!!t&&e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function mB(e){return{x:Math.min(e.x,e.x+e.width),y:Math.min(e.y,e.y+e.height),width:Math.abs(e.width),height:Math.abs(e.height)}}Pe();function yB(e,t,n,r){let o=et(e),i=t&&Vt(t,o),s=n&&Fi(n,o);return{kind:"path",path:e,...i?{fill:i}:{},...i&&r?{vertexColors:r}:{},...s?{stroke:s}:{}}}function e1(e,t){let n=t?.derivedPath,r=Re(e.data?.stroke,t?.inherited?.stroke);return n==null||r===null?null:ZT(n,r,t?.scale??1,t?.screen)}function Oq(e,t,n){let{fill:r,stroke:o}=i2(e,t,n);return yB(e.path,r,o,void 0)}var Vm={id:"kit:derived",matches:Gm,paint:(e,t,n)=>{let r=n?.derivedPath;if(r==null)return[];let o=e.data,i=ch(r);if(i!==void 0)return i.map(l=>Oq(l,o,n?.inherited));let s=Re(o?.stroke,n?.inherited?.stroke),a=Ne(o?.fill,n?.inherited?.fill);return $a([yB(r,a,s,o?.vertexColors)],n)},silhouette:(e,t,n)=>n?.derivedPath??null,drawnBounds:(e,t,n)=>e1(e,n),ink:(e,t,n)=>{let r=e.data,o=Re(r?.stroke,n?.inherited?.stroke);return{filled:Ne(r?.fill,n?.inherited?.fill)!==null,...sr(o,n?.scale)}}};Z();function Lt(e){return e===void 0||Ka(e)}function $o(e,t,n){if(!Ka(e))return null;let r=t?Qs(t,n?.scale??1,n?.leastScale):0,o=Math.min(e.x,e.x+e.width),i=Math.min(e.y,e.y+e.height);return{x:o-r,y:i-r,width:Math.abs(e.width)+2*r,height:Math.abs(e.height)+2*r}}function Fq(e,t){return{x:e.x*t.width,y:e.y*t.height,w:e.width*t.width,h:e.height*t.height}}function Lq(e,t,n){if(n&&n>0)return{width:Math.abs(e.width)*n/(t?.width||1),height:Math.abs(e.height)*n/(t?.height||1)}}var gB={id:"kit:image",snapsToBox:!0,matches:e=>{if(!Lt(e.pose))return!1;let t=e.data?.image?.src;return typeof t=="string"&&t.length>0},paint:(e,t,n)=>{let r=e.data,o=t,i=n?.resolveImage?n.resolveImage(e):ra(r.image.src,Lq(o,r.image.source,n?.pixelScale));if(i)return[{kind:"image",image:i,x:o.x,y:o.y,w:o.width,h:o.height,...r.image.opacity!==void 0?{opacity:r.image.opacity}:{},...r.image.source?{source:Fq(r.image.source,i)}:{},...r.image.flipX?{flipX:!0}:{},...r.image.flipY?{flipY:!0}:{}}];let s=n?.resolveImage?!1:W0(r.image.src)==="error",a=s?"#d08a8a":"#bbbbbb",l=[{kind:"path",path:{kind:"rect",x:o.x,y:o.y,width:o.width,height:o.height},stroke:{paint:{color:a},width:1}}];return s&&l.push({kind:"path",path:ng({x:o.x,y:o.y},{x:o.x+o.width,y:o.y+o.height}),stroke:{paint:{color:a},width:1}}),l},silhouette:(e,t)=>{let n=t;return{kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height}},bounds:(e,t,n)=>$o(t,_q,n)},_q={paint:{color:"#000"},width:1};Z();var bB={cut:{paint:{color:"#e23b3b"},width:1,dash:[6,4]},connector:{paint:{color:"#7ba7c7"},width:2,dash:[4,4]},falloff:{paint:{color:"rgba(52, 120, 246, 0.28)"},width:10,cap:"round",join:"round"},measure:{paint:{color:"#1f8fff"},width:1},lock:{paint:{color:"#d9480f"},width:1.5},target:{paint:{color:"#1f8fff"},width:1.5,dash:[5,3]},insert:{paint:{color:"#1f8fff"},width:3,cap:"round"},refused:{paint:{color:"#ff5d5d"},width:3,cap:"round"}};function t1(e){let t=e?.data?.measure;return!t||typeof t!="object"||!t.start||!t.end?null:t}var Dq=5;function Bq(e,t,n){let r={...bB.measure,width:{px:1}},o=Math.hypot(t.x-e.x,t.y-e.y),i=o>0?-(t.y-e.y)/o:0,s=o>0?(t.x-e.x)/o:1,a=Dq*n,l=c=>({kind:"path",path:Td([{x:c.x-i*a,y:c.y-s*a},{x:c.x+i*a,y:c.y+s*a}]),stroke:r}),u=[l(e),l(t)];return o>0&&u.unshift({kind:"path",path:Td([e,t]),stroke:r}),u}var xB={id:"kit:measure",matches:e=>Lt(e.pose)&&t1(e)!==null,paint:(e,t,n)=>{let r=t1(e);if(!r)return[];let o=globalThis.devicePixelRatio||1;return Bq(r.start,r.end,o/(n?.pixelScale??o))}};Z();Pe();var wB={id:"kit:path",matches:e=>Lt(e.pose)?e.data?.path!=null:!1,paint:(e,t,n)=>n?.derivedPath!=null?Vm.paint(e,t,n):$a(rt(e,ja,t,()=>{let r=e.data,o=Ol(r.path,t),{fill:i,stroke:s}=JT(r,n?.inherited),a=i&&Vt(i,t),l=s&&Fi(s,t);return[{kind:"path",path:o,...a?{fill:a}:{},...a&&r.vertexColors?{vertexColors:r.vertexColors}:{},...l?{stroke:l}:{}}]},n?.inherited),n),silhouette:(e,t,n)=>{if(n?.derivedPath!=null)return n.derivedPath;let r=e.data;return Ol(r.path,t)},ink:(e,t,n)=>{let{fill:r,stroke:o}=JT(e.data,n?.inherited);return{filled:r!==null,...sr(o??null,n?.scale)}},bounds:(e,t,n)=>$o(t,Re(e.data.stroke,n?.inherited?.stroke),n),drawnBounds:(e,t,n)=>{if(n?.derivedPath!=null)return e1(e,n);let r=e.data;return Wm(e,t,Re(r.stroke,n?.inherited?.stroke),n,o=>Ol(r.path,o))}};Pe();var PB={id:"kit:rect-fallback",matches:e=>e.kind!=="group"&&Lt(e.pose),paint:(e,t,n)=>{let r=e.data,o=t,i=Ne(r?.fill,n?.inherited?.fill),s=i&&Vt(i,o);return[{kind:"path",path:{kind:"rect",x:o.x,y:o.y,width:o.width,height:o.height},...s?{fill:s}:{}}]},silhouette:(e,t)=>{let n=t;return{kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height}},bounds:(e,t)=>$o(t,null,void 0)};Z();Pe();var TB={id:"kit:shape",matches:e=>{if(!Lt(e.pose))return!1;let t=e.data?.shape;return t!=null&&Hq.has(t)},paint:(e,t,n)=>$a(rt(e,ja,t,()=>{let r=e.data,o=n1(r,t),i=Ne(r.fill,n?.inherited?.fill),s=i&&Vt(i,t),a=Re(r.stroke,n?.inherited?.stroke),l=a&&Fi(a,t);return[{kind:"path",path:o,...s?{fill:s}:{},...l?{stroke:l}:{}}]},n?.inherited),n),silhouette:(e,t)=>{let n=e.data;return n1(n,t)},ink:(e,t,n)=>{let r=e.data;return{filled:Ne(r.fill,n?.inherited?.fill)!==null,...sr(Re(r.stroke,n?.inherited?.stroke),n?.scale)}},bounds:(e,t,n)=>$o(t,Re(e.data.stroke,n?.inherited?.stroke),n),drawnBounds:(e,t,n)=>{let r=e.data,o=Re(r.stroke,n?.inherited?.stroke);return r.shape==="polygon"||r.shape==="star"?Wm(e,t,o,n,i=>n1(r,i)):hB(t,o,n)}},Hq=new Set(["rect","ellipse","polygon","star"]);function n1(e,t){switch(e.shape){case"ellipse":return Zy(t);case"polygon":{let n=t.x+t.width/2,r=t.y+t.height/2,o=Math.min(t.width,t.height)/2;return eg({x:n,y:r},o,e.sides??6)}case"star":{let n=t.x+t.width/2,r=t.y+t.height/2,o=Math.min(t.width,t.height)/2;return tg({x:n,y:r},o,e.points??5)}default:return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height}}}Z();Pe();function Gq(e,t){return{kind:"group",clip:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height},children:[e]}}function Uq(e,t){let n=Math.max(0,e.padding??0),r=Math.min(n,t.width/2),o=Math.min(n,t.height/2);return{x:t.x+r,y:t.y+o,width:t.width-2*r,height:t.height-2*o}}function r1(e,t,n){return{...Uq(e,t),text:e.text,runs:e.runs,style:e.style,fill:e.fill===rn?Ne(e.fill,n?.fill):e.fill,stroke:Re(e.stroke,n?.stroke)??void 0,verticalAlign:e.verticalAlign}}var o1={id:"kit:text",snapsToBox:!0,matches:e=>Lt(e.pose)?e.data?.text!=null:!1,paint:(e,t,n)=>rt(e,ja,t,()=>{let r=e.data,o=Lw(r1(r,t,n?.inherited)),i=r.overflow==="clip"?Gq(o,t):o,s=Ne(r.background);if(!s)return[i];let a=Vt(s,t);return[{kind:"path",path:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height},...a?{fill:a}:{}},i]},n?.inherited),silhouette:(e,t)=>{let n=e.data;if(Ne(n.background))return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height};let r=kp(r1(n,t)),o=n.overflow==="clip"?Wq(r,t):r;return o.length===0?null:zq(o)},ink:(e,t,n)=>{let r=e.data;return{filled:!0,...sr(Re(r.stroke,n?.inherited?.stroke),n?.scale)}},drawnBounds:(e,t,n)=>{let r=e.data,o=Re(r.stroke,n?.inherited?.stroke);return o?Vq(t,kp(r1(r,t,n?.inherited)),Um(o,n)):null}};function Wq(e,t){let n=[];for(let r of e){let o=Math.max(r.x,t.x),i=Math.max(r.y,t.y),s=Math.min(r.x+r.width,t.x+t.width),a=Math.min(r.y+r.height,t.y+t.height);s>o&&a>i&&n.push({x:o,y:i,width:s-o,height:a-i})}return n}function Vq(e,t,n){if(!(n.x>0||n.y>0))return null;let r=e.x,o=e.y,i=e.x+e.width,s=e.y+e.height;for(let a of t){let l=Math.max(a.x,e.x),u=Math.max(a.y,e.y),c=Math.min(a.x+a.width,e.x+e.width),d=Math.min(a.y+a.height,e.y+e.height);c<=l||d<=u||(r=Math.min(r,l-n.x),o=Math.min(o,u-n.y),i=Math.max(i,c+n.x),s=Math.max(s,d+n.y))}return{x:r,y:o,width:i-r,height:s-o}}function zq(e){let t=new Uint8Array(e.length*6),n=new Float32Array(e.length*10),r=0,o=0;for(let i of e){let{x:s,y:a,width:l,height:u}=i;t[o++]=le,n[r++]=s,n[r++]=a,t[o++]=ce,n[r++]=s+l,n[r++]=a,t[o++]=ce,n[r++]=s+l,n[r++]=a+u,t[o++]=ce,n[r++]=s,n[r++]=a+u,t[o++]=ce,n[r++]=s,n[r++]=a,t[o++]=fe}return{kind:"polygon",commands:t,coords:n,fillRule:"nonzero"}}var Vve=Object.freeze({filled:!0,outset:0,inset:0}),Ya={high:[],normal:[]},SB=!1;function i1(){SB||(SB=!0,Qq())}function Xi(e,t={}){i1();let n=t.priority==="high"?Ya.high:Ya.normal;return n.push(e),Xu(),()=>{let r=n.indexOf(e);r>=0&&n.splice(r,1),Xu()}}var Kq="shape:painter",jq="shape:painter:nonrect",$q="shape:painter:derived",Yq="shape:painter:derived:nonrect",qq="shape:silhouette",Xq="shape:silhouette:text";function Oc(e){let t=Lt(e.pose),n=Gm(e)?t?$q:Yq:t?Kq:jq;return rt(e,n,void 0,()=>Jq(e))}function Jq(e){i1();for(let t of Ya.high)if(t.matches(e))return t;for(let t of Ya.normal)if(t.matches(e))return t}function Fc(e,t,n){let r=()=>{let o=Oc(e)?.silhouette?.(e,t,n)??null;return o&&Cl(o,t)};if(n?.derivedPath!=null)return r();if(Oc(e)===o1){let o=qo(),i=rt(e,Xq,t,()=>({epoch:o,path:r()}));return i.epoch!==o&&(i.epoch=o,i.path=r()),i.path}return rt(e,qq,t,r)}dB(e=>Fc(e.node,e.pose,{derivedPath:e.path}));function zm(e,t,n){return Oc(e)?.ink?.(e,t,n)??null}function kB(){return i1(),[...Ya.high,...Ya.normal]}function Qq(){Xi(o1),Xi(xB),Xi(Vm),Xi(wB),Xi(TB),Xi(gB),Xi(PB)}function Km(e){return`scene:${e}`}function vB(e,t){let{layerVisibility:n,layerOrder:r}=t;return n===void 0&&r===void 0?e:(r?r.map(i=>e.find(s=>Km(s.id)===i)).filter(i=>i!==void 0):e).filter(i=>n?.[Km(i.id)]!==!1)}Z();function jm(e){if(e===null)return r=>r;let t=r=>r===void 0?null:e(r),n=new WeakMap;return(r,o,i)=>{let s=t(i),a=Bw(t(o),s);if(a===null)return r;let l=n.get(r);l===void 0&&n.set(r,l=new Map);let u=l.get(s);return u===void 0&&l.set(s,u=Rt(r,Hw(a))),u}}function AB(e,t){let n=Bw(e,t);return n===null?void 0:q.fromAffine(Hw(n))}var RB=Object.freeze({preserveDrawingBuffer:!0,stencil:!0});Z();Z();Z();function NB(e,t){if(e.length===0)return e;let n=Ce(t);return n?[{kind:"group",transform:q.fromAffine(n),children:e}]:e}var EB=new WeakSet;function $m(e){let t={kind:"group",children:e};return EB.add(t),t}function IB(e){return EB.has(e)}var Zq=[];function Ym(e){if(!e.some(IB))return{under:e,over:Zq};let t=[],n=[];for(let r of e)IB(r)?n.push(...r.children):t.push(r);return{under:t,over:n}}function CB(e,t,n){let{under:r,over:o}=Ym(e),i=MB(r,t,n);return o.length>0?[...i,$m(MB(o,t,n))]:i}function MB(e,t,n){let r=NB(e,t);return n!==1&&r.length>0?[{kind:"group",alpha:n,children:r}]:r}function eX(e,t,n){return Fc(e,t,{derivedPath:n?.()??null})}function qm(e,t,n){return typeof e.clipFromPose=="function"?e.clipFromPose(t):e.clip!=="outline"?null:eX(e,t,n)}Z();Z();function FB(e,t,n,r,o,i,s,a){let l=s&&o.inCopy!==void 0?i(e):null;if(l===null||!l.some(f=>a.copiesOf(f).length>0)){if(!o.hits(e,t,n,r))return!1;let f=l??i(e);for(let p=0;p<f.length;p++)if(!OB(a,o,f[p],e,t,n))return!1;return!0}let u=(f,p)=>OB(a,f,p,e,t,n),c=[...l].reverse(),d=(f,p)=>{if(f===c.length)return p.hits(e,t,n,r);let h=c[f];if(u(p,h)&&d(f+1,p))return!0;for(let m of a.copiesOf(h)){let g=p.inCopy?.(m);if(g!==void 0&&u(g,h)&&d(f+1,g))return!0}return!1};return d(0,o)}function OB(e,t,n,r,o,i){let s=e.clipOf(n);return s===null||t.clipAdmits(e.carry(s,n.layer,r.layer),r,o,i)}var ue=e=>e;function tX(e){return e?.annotation===!0}function Xm(e){let t=new Set;for(let n of e??[])tX(n)&&t.add(n.id);return t}function Lc(e){return e.hidden===!0}function qa(e){let t=Jm(e,"hidden"),n=Jm(e,"locked"),r=n===null?a=>a.locked===!0:a=>a.locked===!0||n.has(a.layer),o=a=>{let l=new Map,u=[];return c=>{if(c===null)return!1;let d=!1,f=null;u.length=0;for(let p=c;p!==null;){let h=l.get(p);if(h!==void 0){d=h;break}let m=e.get(p);if(m===void 0)break;if(u.length>64){if(f??=new Set(u),f.has(p))break;f.add(p)}if(u.push(p),a(m)){d=!0;break}p=m.parent??null}for(let p of u)l.set(p,d);return d}},i=o(Lc),s=o(r);return{hidden(a){let l=typeof a=="string"?e.get(a):a;return l===void 0?!1:t?.has(l.layer)===!0||Lc(l)||i(l.parent??null)},locked(a){let l=typeof a=="string"?e.get(a):a;return l===void 0?!1:r(l)||s(l.parent??null)}}}function LB(e,t,n){let r=null,o=0;for(let i=t;i!==null;){let s=e.get(i);if(s===void 0)return!1;if(++o>64){if(r??=new Set,r.has(i))return!1;r.add(i)}if(n(s))return!0;i=s.parent??null}return!1}function Jm(e,t){let n=null;for(let r of e.layers??[])(t==="locked"?r.locked===!0:r.visible===!1)&&(n??=new Set).add(r.id);return n}function _B(e,t){let n=e.get(t);return n===void 0?!1:Jm(e,"hidden")?.has(n.layer)===!0||LB(e,t,Lc)}function DB(e,t){let n=Jm(e,"locked");return LB(e,t,n===null?r=>r.locked===!0:r=>r.locked===!0||n.has(r.layer))}Z();function HB(e,t){let n=Tt(e.overrides,t),r=Xn(e,t);return r===n.pose?n:{...n,pose:r}}function a1(e,t){return n=>t(HB(e,n))}function GB(e,t){return t===void 0?n=>e.overrides.read(n.id)?.path:n=>{let r=e.overrides.read(n.id)?.path;if(r===void 0)return;let o=HB(e,n);return dh(r,o.pose,t(o))}}function _c(e,t){let n=t?a1(e,t):o=>Xn(e,o);if(!Et(e.composition))return n;let r=bh(e,{getPose:o=>{let i=e.get(ue(o));return i?n(i):void 0},getParent:o=>e.get(ue(o))?.parent??null,definesFrame:o=>{let i=e.get(ue(o));return i===void 0||lt(i)}});return o=>zt(r,o.id,e.composition.compose)}function nX(e,t){let n=UB(t,Et(e.composition));if(n===void 0)return o=>Jw(e,o);let r={at:_c(e,t),local:t?a1(e,t):o=>Xn(e,o),slot:n,shown:GB(e,t),childrenOf:o=>e.childrenOf(o),scene:ha(e),lookup:o=>{let i=e.get(o);return i===void 0?void 0:new s1(Tt(e.overrides,i),r)}};return r.lookup}var s1=class{constructor(t,n){this.ctx=n;this.node=t,this.pose=n.at(t)}ctx;node;pose;get path(){let t=this.ctx.shown(this.node);return t!==void 0?fh(t,this.ctx.local(this.node),this.pose):Fr(this.node,this.ctx.lookup,this.ctx.childrenOf,this.ctx.slot)}get inherited(){return pa(this.ctx.scene,this.node)}get children(){return this.ctx.childrenOf(this.node.id).map(this.ctx.lookup)}};function l1(e,t){return t.dependsOn!==void 0||e.overrides.read(t.id)?.path!==void 0}function Dc(e,t){let n=nX(e,t),r=UB(t,Et(e.composition)),o=a=>e.childrenOf(a),i=a=>Fr(a,n,o,r),s=GB(e,t);return a=>s(a)??i(a)}var BB=new WeakMap;function UB(e,t){let n=t?"world":"local";if(e===void 0)return n==="world"?"kit:derivedPath:world":void 0;let r=BB.get(e);return r===void 0&&(r={},BB.set(e,r)),r[n]??=p2()}function WB(e,t,n){let r=Dc(e,n),o=Et(e.composition)?n?a1(e,n):i=>Xn(e,i):null;return(i,s,a,l)=>{if(!l1(e,i))return t(i,s,a,l);let u=r(i);return u!==null&&o!==null&&e.overrides.read(i.id)?.path===void 0&&(u=rX(u,s,o(i))),t(i,s,a,{...l,derivedPath:u})}}function rX(e,t,n){let r=ui(t);if(r===null)return e;let o=t,i=n,s=Ce({x:o.x,y:o.y,width:o.width,height:o.height,rotation:i?.rotation,transform:i?.transform});return Yu(e,s===null?r:ht(r,s))}mv();function oX(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function u1({reads:e=2}={}){if(!(e>=1)||!Number.isInteger(e))throw new RangeError(`createSettledCache: reads must be a positive integer, got ${e}`);let t,n=0,r=null;return{read(o,i){return(t===void 0||!oX(t,o))&&(t=o.slice(),n=0,r=null),r!==null?r.value:++n<e?null:(r={value:i()},r.value)},clear(){t=void 0,n=0,r=null}}}var iX=[];function Qm(e){return t=>{let n=t.parent??null;if(n===null)return iX;let r=[],o=new Set;for(;n!==null&&!o.has(n);){o.add(n);let i=e.get(ue(n));if(!i)break;r.push(i),n=i.parent??null}return r}}function Zm(e){let t=Dc(e);return n=>{let r=n;return l1(e,r)?t(r):null}}Z();Z();Z();function VB(e){let{x:t,y:n,width:r,height:o}=e;return Bc([t,n,t+r,n,t+r,n+o,t,n+o],{x:t,y:n,width:r,height:o},!0)}function Bc(e,t,n=!1){let r=[],o=[],i=1/0,s=1/0,a=-1/0,l=-1/0;for(let u=0;u+1<e.length;u+=2){let c=e[u],d=e[u+1];r.push({x:c,y:d}),o.push(c,d),c<i&&(i=c),d<s&&(s=d),c>a&&(a=c),d>l&&(l=d)}return r.length===0?null:{verts:r,coords:o,bounds:t??{x:i,y:s,width:a-i,height:l-s},isRect:n}}function zB(e){if(e.length<3)return null;let t=[];for(let n of e)t.push(n.x,n.y);return Bc(t)}function KB(e){return e!==null&&typeof e=="object"&&e.kind==="polygon"}function ey(e,t,n){return KB(t)?rt(e,"aabb",t,()=>n.getBounds(t)):Di(t,n)}function jB(e,t){if(Ce(e)){let n=e;return Cl({kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height},e)}return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height}}function c1(e,t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y)||!Number.isFinite(n.width)||!Number.isFinite(n.height))return!1;let r=e.bounds;if(n.x>=r.x+r.width||n.x+n.width<=r.x||n.y>=r.y+r.height||n.y+n.height<=r.y)return!1;if(t==="centers")return Un(e.coords,n.x+n.width/2,n.y+n.height/2);if(t==="intersect"&&e.isRect&&wd([r.x,r.y,r.x+r.width,r.y+r.height],[n.x,n.y,n.x+n.width,n.y+n.height]))return!0}function $B(e,t,n,r,o,i=()=>!0){let s=c1(e,t,r);if(s!==void 0)return s;let a=e.bounds,l=KB(n);if(t==="enclosed")return l&&!wd([a.x,a.y,a.x+a.width,a.y+a.height],[r.x,r.y,r.x+r.width,r.y+r.height])?!1:vg(e.verts,l?n:o());let u=l?n:o();return i()?u.kind==="rect"&&e.isRect?u.x<a.x+a.width&&u.x+u.width>a.x&&u.y<a.y+a.height&&u.y+u.height>a.y:Fd(e.verts,u):Fd(e.verts,u,{filled:!1})}function Hc(e,t,n){let r=t.x+t.width,o=t.y+t.height;e[0]=Math.min(e[0],Math.min(t.x,r)-n),e[1]=Math.min(e[1],Math.min(t.y,o)-n),e[2]=Math.max(e[2],Math.max(t.x,r)+n),e[3]=Math.max(e[3],Math.max(t.y,o)+n)}function sX(e,t,n,r){let o=ir(t)?et(t):n.getBounds(t),i=n===jo?t:nP(t,n),s=Ce(i);if(!s){Hc(e,o,r);return}let a=o.x-r,l=o.y-r,u=o.x+o.width+r,c=o.y+o.height+r;for(let[d,f]of[[a,l],[u,l],[u,c],[a,c]]){let[p,h]=wn(s,d,f);Hc(e,{x:p,y:h,width:0,height:0},0)}}function aX(e){let t=1e-9*(1+Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])));e[0]-=t,e[1]-=t,e[2]+=t,e[3]+=t}var lX=Object.freeze({scale:1});function YB(e,t,n,r,o,i){let s=zm(e,t,r===void 0?lX:{scale:1,inherited:r}),a=Math.max(0,s?.outset??0);if(i[0]=i[1]=1/0,i[2]=i[3]=-1/0,n)Hc(i,et(n),a);else{let l=_r(o,e);o===jo&&l===o&&Ka(t)&&Ce(t)===null?Hc(i,t,a):(Hc(i,ey(e,t,l),a),sX(i,t,o,a))}return aX(i),Math.max(0,s?.outsetPx??0)}var uX=0;var qB=new WeakMap,cX=.5,d1=class{constructor(t,n,r,o){this.built=t;this.trees=n;this.always=r;this.maxOutsetPx=o;this.layers=[...n.keys()],this.order=t,this.marks=new Uint8Array(t.length),this.found=new Int32Array(Math.max(16,r.length))}built;trees;always;maxOutsetPx;layers;order;remap=null;marks;found;rankBy(t){if(t===this.order)return;if(this.order=t,t===this.built){this.remap=null;return}let n=new Map;for(let o=0;o<t.length;o++)n.set(t[o].id,o);let r=new Int32Array(this.built.length);for(let o=0;o<r.length;o++)r[o]=n.get(this.built[o].id)??-1;this.remap=r}candidates(t){let n=Math.floor(this.order.length*cX),r=0,o=i=>{let s=this.remap===null?i:this.remap[i];if(s<0)return!0;if(r===this.found.length){let a=new Int32Array(r*2);a.set(this.found),this.found=a}return this.found[r++]=s,r<=n};for(let i of this.always)if(!o(i))return null;for(let i=0;i<this.layers.length;i++){let s=t[i],a=this.trees.get(this.layers[i]);if(s===null||a===void 0)continue;let{x:l,y:u,width:c,height:d}=s.box,f=s.pxPerWorld,p=this.maxOutsetPx>0&&f!==void 0?f>0?this.maxOutsetPx/f:1/0:0,h=!1;if(a.queryBox([l-p,u-p,l+c+p,u+d+p],m=>o(m)?!0:(h=!0,!1)),h)return null}return this.readOut(r)}readOut(t){let{order:n,found:r}=this,o=new Array(t);if(t*32<n.length){let a=r.subarray(0,t).sort();for(let l=0;l<t;l++)o[l]=n[a[l]];return o}let i=this.marks.length>=n.length?this.marks:new Uint8Array(n.length);for(let a=0;a<t;a++)i[r[a]]=1;let s=0;for(let a=0;s<t&&a<n.length;a++)i[a]!==0&&(i[a]=0,o[s++]=n[a]);return o}};function dX(e){return e.some(t=>typeof t.copiesFromPose=="function")}function fX(e,t,n){uX++;let r=_c(e),o=Zm(e),i=Qm(e),s=new Map,a=[],l=0;for(let c=0;c<n.length;c++){let d=n[c],f=i(d);if(dX(f)){a.push(c);continue}let p=[0,0,0,0],h;try{let g=Ju(d)?fa(d,f):void 0;h=YB(d,r(d),o(d),g,t,p)}catch{a.push(c);continue}if(!Number.isFinite(h)||!p.every(Number.isFinite)){a.push(c);continue}h>l&&(l=h);let m=s.get(d.layer);m===void 0&&s.set(d.layer,m=[]),m.push([c,p])}let u=new Map;for(let[c,d]of s){let f=_g(2,d);if(f.size!==d.length)for(let[p,h]of d)h[0]<=h[2]&&h[1]<=h[3]||a.push(p);u.set(c,f)}return new d1(n,u,Int32Array.from(a),l)}function pX(e,t){kB();let n=e.getVersion(),r=e.overrides.getGeneration(),o=e.scroll?.getGeneration()??0,i=h2(),s=mu(),a=qB.get(e);a===void 0&&qB.set(e,a=new WeakMap);let l=a.get(t);l===void 0&&a.set(t,l=u1());let u=yh(e.overrides,e.renderOrderNodes()),c=l.read([n,r,o,i,s],()=>fX(e,t,u));return c?.rankBy(u),c}function XB(e,t,n){let r=pX(e,t);if(r===null)return null;let o=[];for(let i of r.layers){let s=n(i);if(s===void 0||s!==null&&Number.isNaN(s.box.x+s.box.y+s.box.width+s.box.height))return null;o.push(s)}return r.candidates(o)}function f1(e,t={}){let n=qa(e),r=typeof e.overrides?.ids=="function",o=w=>e.overrides?Tt(e.overrides,w):w,i=w=>r?yh(e.overrides,w):w.map(o),s=Xm(e.layers),{getPose:a,alphaOf:l,layerIsPainted:u}=t,c=null;if(!l&&r)for(let w of e.overrides.ids()){let y=e.overrides.read(w)?.alpha;y!==void 0&&y<=0&&(c??=new Set).add(w)}let d=l??(r?c?w=>c.has(w)?0:1:void 0:w=>e.overrides.read(ue(w))?.alpha??1),f=_c(e),p=a?w=>a(w.id):w=>f(w),h=w=>e.childrenOf(w),m=w=>{let y=e.get(w);if(y===void 0)return;let P=o(y);return{node:P,pose:p(P),get path(){return Fr(P,m,h)}}},g=a?w=>{let y=w;return y.dependsOn===void 0?null:Fr(y,m,h)}:Zm(e),b=t.camera?ty(e.layers,t.camera):null,x=a||typeof e.getVersion!="function"?void 0:t.index;return{...b?{planeOf:b}:{},...x?{candidates:w=>{let y=XB(e,x.descriptor,w);return y===null?null:i(y)}}:{},order:()=>i(e.renderOrderNodes()),derivedPathOf:g,poseOf:p,parentsOf:Qm(e),...d?{alphaOf:d}:{},isLocked:w=>n.locked(w),isHidden:w=>n.hidden(w),...s.size>0||u?{layerIsPainted:w=>!s.has(w)&&(u===void 0||u(w))}:{}}}function ty(e,t){let n=null;for(let o of e??[])o.parallax&&(n??=new Map).set(o.id,rh(t,o.parallax));if(n===null)return null;let r=n;return o=>r.get(o)??null}function JB(e,t){let n=t.includeGroups??!0,r=t.includeLocked===!0?void 0:e.isLocked,o=[],i=new Map,s=jm(e.planeOf??null),a=b=>{let x=i.get(b.id);if(x!==void 0)return x;let w=qm(b,e.poseOf(b),()=>e.derivedPathOf?.(b));return i.set(b.id,w),w},l=new Map,u=b=>{let x=l.get(b.id);if(x===void 0){let w=b.copiesFromPose;x=(w?w(e.poseOf(b),b)??[]:[]).map(pr).filter(P=>P!==null),l.set(b.id,x)}return x},c=new Map,d=b=>{if(b===void 0||e.planeOf===void 0)return t;let x=c.get(b);if(x===void 0){let w=e.planeOf(b);x=w===null?t:t.inPlane?.(w)??null,c.set(b,x)}return x},f={clipOf:a,copiesOf:u,carry:s},p=b=>e.parentsOf(b),h=e.order(),m=h.some(b=>typeof b.copiesFromPose=="function"),g=(t.broad!==void 0?e.candidates?.(b=>{let x=d(b);return x===null?null:x.broad}):null)??h;for(let b of g){if(!n&&b.kind==="group"||b.pickable===!1||e.isHidden?.(b)===!0||b.layer!==void 0&&e.layerIsPainted?.(b.layer)===!1||e.alphaOf!==void 0&&e.alphaOf(b.id)<=0||r!==void 0&&r(b))continue;let x=d(b.layer);if(x===null)continue;let w=e.poseOf(b),y=e.derivedPathOf?.(b),P=Ju(b)?fa(b,e.parentsOf(b)):void 0;FB(b,w,y,P,x,p,m,f)&&o.push(b.id)}return o}function hX(e,t,n,r){let o={kind:"group",children:e};for(let i=t.length-1;i>=0;i--){let s=t[i];o="copy"in s?{kind:"group",children:[o],transform:q.fromAffine(s.copy)}:{kind:"group",children:[o],clip:r(s.path,s.layer,n)}}return o}function QB(e,t,n,r,o,i){let s=e.getLayers(),a=new Map;for(let h of s)h.visible&&a.set(h.id,[]);let l=null;for(let h of s)h.parallax&&(l??=new Map).set(h.id,_w(n,h.parallax));let u=e.composePose?.bind(e),c=u?e.childFrame?.bind(e):void 0,d=jm(l?ty(s,n):null);function f(h,m,g,b){let x=e.getNode(h);if(!x||Lc(x))return;let w=e.getPose(h),y=u&&g!==null?u(g,w):w,P=r===void 0||x.layer===r?a.get(x.layer):void 0,S=l?.get(x.layer)??n,{under:v,over:A}=Ym(P&&(b||!i?.(x,y,S))?t(x,y,S):[]),N=m,M=null,C=x,F=qm(C,y,()=>o?.(x,y));F&&(M={path:F,layer:x.layer},N=[...m,M]);let B=J=>m.length>0?hX(J,m,x.layer,d):{kind:"group",children:J};P&&P.push(B(v));let D=lt(x)?c?c(h,y):y:g,j=x.consumesChildren===!0?[]:e.getChildren(h);for(let J of j)f(J,N,D,b);let W=typeof C.copiesFromPose=="function"?C.copiesFromPose(y,x):null;for(let J of W??[]){let se=[...m,{copy:J},...M?[M]:[]];for(let ke of j)f(ke,se,D,!0)}P&&A.length>0&&P.push(B(A))}for(let h of e.getChildren(null))f(h,[],null,!1);let p=[];for(let h of s){if(!h.visible||r!==void 0&&h.id!==r)continue;let m=a.get(h.id)??[],g=h.parallax?AB(rh(n,h.parallax),null):void 0;p.push(g?{kind:"group",transform:g,children:m}:{kind:"group",children:m})}return p}var Xa=[{field:"clipFromPose",opKey:"clipKey",jsonKey:"clipFromPoseKey",lost:"clip"},{field:"copiesFromPose",opKey:"copiesKey",jsonKey:"copiesFromPoseKey",lost:"copies"},{field:"derivePath",opKey:"derivePathKey",jsonKey:"derivePathKey",lost:"derived path"},{field:"derivePose",opKey:"derivePoseKey",jsonKey:"derivePoseKey",lost:"derived pose"},{field:"layout",opKey:"layoutKey",jsonKey:"layoutKey",lost:"layout"}];function ny(e,t){return Xa.map(n=>{let r=e[n.field],o=new Map;if(r)for(let[i,s]of Object.entries(r))o.set(s,i);return{spec:n,keyOf:i=>o.get(i),fnOf:i=>r?.[i],read:i=>i[n.field],write:(i,s)=>{i[n.field]=s,t?.(n.field,i)}}})}function Gc(e,t,n,r,o){let i=e.fnOf(n);if(i===void 0){o("scene",`${r}: ${e.spec.opKey} "${n}" not in this scene's registry \u2014 node "${t.id}" restored without its ${e.spec.lost}. Register a function with this key in the registry option to restore it.`);return}e.write(t,i)}function Ji(e,t,n,r){let o={};for(let i of e){let s=i.read(t);if(s===void 0)continue;let a=i.keyOf(s);if(a===void 0){r?.(i);continue}o[i.spec[n]]=a}return o}function ry(e){let t=e,n={};for(let r of Xa){let o=t[r.field];o!==void 0&&(n[r.field]=o)}return n}function ar(e){let t={};return e.pickable!==void 0&&(t.pickable=e.pickable),e.hidden===!0&&(t.hidden=!0),e.locked===!0&&(t.locked=!0),e.units!==void 0&&(t.units=e.units),e.clip!==void 0&&(t.clip=e.clip),e.consumesChildren===!0&&(t.consumesChildren=!0),t}function oy(e){let t=n=>n===null?[...e.roots]:[...e.childrenOf(ue(n))];return{getNode:n=>e.get(ue(n)),getParent:n=>e.get(ue(n))?.parent??null,getChildren:t,getRemovalClosure:n=>[...e.removalClosure(n.map(ue))],setPose:(n,r)=>e.setPose(ue(n),r),setParent:(n,r)=>e.move(ue(n),r==null?null:ue(r)),setChildOrder:(n,r)=>{e.batch("Reorder",()=>{for(let o=0;o<r.length;o++)t(n)[o]!==r[o]&&e.reorder(ue(r[o]),o)})},setData:(n,r)=>e.update(ue(n),{data:r}),setLayer:(n,r)=>e.setLayer(ue(n),r),setDependsOn:(n,r)=>e.setDependsOn(ue(n),Array.isArray(r)?r.map(ue):r),setLayout:(n,r)=>e.setLayout(ue(n),r),setHidden:(n,r)=>e.setHidden(ue(n),r),setLocked:(n,r)=>e.setLocked(ue(n),r),removeNode:n=>e.remove(ue(n)),insertNode:(n,r)=>{e.add({kind:n.kind,layer:n.layer,pose:n.pose,data:n.data,id:n.id,...r!==void 0?{index:r}:{},...n.parent!=null?{parent:n.parent}:{},...n.dependsOn!==void 0?{dependsOn:n.dependsOn}:{},...ar(n),...ry(n)})}}}function ZB(e){return{getPose:t=>Lr(e,e.get(ue(t))),getNodes:()=>[...e.renderOrderNodes()]}}function e3(e,t,n){for(let r of t)r.apply(e)}Z();function n3(e,t){let n=e?.get?.();return{...t?{alphaOf:t}:{},...e?.layerIsPainted?{layerIsPainted:r=>e.layerIsPainted(r)}:{},...n?{camera:n}:{}}}function r3(e,t,n,r=jo,o={}){return i3(e,VB(t),"intersect",n,r,o)}function o3(e,t,n,r,o=jo,i={}){let s=zB(t);return s?i3(e,s,n,r,o,i):[]}function t3(e,t){return t?.kind!=="polygon"||e()?t:{...t,openFill:"none"}}function i3(e,t,n,r,o,i){let s=f1(e,{...r,index:{descriptor:o}});return JB(s,p1(t,n,o,i))}function p1(e,t,n,r){return{includeGroups:r.includeGroups===!0,broad:{box:e.bounds},clipAdmits:(o,i,s,a)=>{let l=_r(n,i);return Od(o,a?et(a):Di(s,l))&&Od(o,e.bounds)},hits:(o,i,s,a)=>{let l=_r(n,o),u=s?et(s):ey(o,i,l),c=c1(e,t,u);if(c!==void 0)return c;let d,f=()=>d??=zm(o,i,{inherited:a})?.filled!==!1;return $B(e,t,t3(f,i),u,()=>t3(f,Fc(o,i,{derivedPath:s})??s??jB(i,u)),f)},inPlane:o=>p1(mX(e,o),t,n,r),inCopy:o=>({...p1(yX(e,o),t,n,r),broad:void 0})}}function mX(e,t){let n=[];for(let r of e.verts){let o=Dw(t,r);n.push(o.x,o.y)}return Bc(n,KC(t,e.bounds),e.isRect)}function yX(e,t){let n=[],r=1/0,o=1/0,i=-1/0,s=-1/0;for(let l of e.verts){let[u,c]=wn(t,l.x,l.y);n.push(u,c),r=Math.min(r,u),o=Math.min(o,c),i=Math.max(i,u),s=Math.max(s,c)}let a=t[1]===0&&t[2]===0||t[0]===0&&t[3]===0;return Bc(n,{x:r,y:o,width:i-r,height:s-o},e.isRect&&a)}function gX(e,t,n,r){return r!==void 0?r(t,n):e.get(t)?.kind==="group"}function s3(e,t,n,r){return gX(e,t,n,r)===!0}function a3(e,t,n){return t==null||!e||e.get(t)===void 0?null:s3(e,t,[],n)?t:null}function l3(e,t,n){let r=a3(e,t,n);if(r===null)return{parent:null,layer:e.layers[0]?.id??"default",local:a=>a};let o=e.get(r),i=e.composition;if(i===void 0||!Et(i))return{parent:o.id,layer:o.layer,local:a=>a};let s=aa(bh(e,{getPose:a=>e.get(a).pose,getParent:a=>e.get(a)?.parent??null,definesFrame:a=>lt(e.get(a)??{})}),o.id,i.compose);return{parent:o.id,layer:o.layer,local:a=>i.decompose(s,a)}}function h1(e,t){return e?.axes?.(t)??Zu(t)}var u3=new WeakMap;function bX(e){let t=u3.get(e);return t||(t=()=>e.commit(),u3.set(e,t)),t}function xX(e,t){let n=t(),r=h1(e,n);if(!r)return null;let{count:o,angles:i}=r,s=()=>{let a=t();if(a!==n){let l=h1(e,a);l&&l.count===o&&(r=l),n=a}return r};return{count:o,angles:i,to:a=>s().to(a),from:a=>s().from(a),add:r.add&&((a,l)=>{let u=s();return u.add?u.add(a,l):u.from(u.to(a).map((c,d)=>c+l[d]))}),write:r.write&&((a,l,u)=>{let c=s();c.write?c.write(a,l,u):c.to(a).forEach((d,f)=>{l[u+f]=d})})}}function wX(e,t,n){let{overrides:r}=e,o=e.id,i=xX(e.descriptor,e.get);if(!i)return null;let s={},a=!1,l=null,u=()=>{a=!1,l?.(),l=null,r.clear(o,s),t?.()},c=aP({get:e.get,set:e.set,axes:i,show(d){if(c.active&&n?.()&&c.stop({commit:!1}),!c.active){u();return}s.pose=d,r.has(o,s)||r.set(o,s),a=!0,n&&l===null&&(l=r.subscribe(()=>{!c.active||!n()||(c.stop({commit:!1}),a&&u())}))},publish:bX(r)});return c}var c3=new WeakMap;function d3(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=e,r=t,o=0;for(let i in n)if(Object.hasOwn(n,i)){if(!Object.hasOwn(r,i)||n[i]!==r[i])return!1;o++}for(let i in r)Object.hasOwn(r,i)&&o--;return o===0}function f3(e,t,n){let r=c3.get(e.overrides);r||(r=new Map,c3.set(e.overrides,r));let o=t,i=e.get(o),s=n??Mt,a=r.get(t),l=!a||a.active||!i||h1(s,Lr(e,i))?.count===a.axisCount;if(a&&l)return a;if(!i)return;let u=Lr(e,i),c,d=!1,f=r,p=null;if(p=wX({id:t,descriptor:s,overrides:e.overrides,get(){let h=e.get(o);return h&&(u=Lr(e,h)),h&&!p?.active&&(c=h.pose),u},set(h){let m=e.get(o);if(m){d=!0;try{d3(m.pose,h)||e.untracked(()=>e.setPose(o,h))}finally{d=!1}c=e.get(o)?.pose}}},()=>{e.get(o)||f.delete(t)},()=>{if(d)return!1;let h=e.get(o);return!!h&&c!==void 0&&!d3(h.pose,c)}),!!p)return r.set(t,p),p}function qt(e){return e.children!==void 0&&e.children.length>0}function Ja(e){return Array.isArray(e)?[...e]:e!==null&&typeof e=="object"?{...e}:e}function p3(e,t){let{scene:n}=e,r=ny(n.registry),o=new Set(t),i=new Set,s=[],a=(p,h)=>{if(h)return e.worldPoseOf(p.id);let m=e.frameAtOrAbove(p.parent);return m!==null&&i.has(m)?p.pose:e.worldPoseOf(p.id)},l=(p,h=!1)=>{if(i.has(p))return;let m=n.get(ue(p));if(m&&(i.add(p),s.push({kind:m.kind,id:m.id,layer:m.layer,parent:m.parent,pose:Ja(a(m,h)),data:Ja(m.data),...m.children!==void 0?{children:[...m.children]}:{},...ar(m),...m.dependsOn!==void 0?{dependsOn:Ja(m.dependsOn)}:{},...ry(m),...Ji(r,m,"jsonKey")}),qt(m)))for(let g of n.childrenOf(ue(p)))l(g)},u=p=>n.get(ue(p))?.parent,c=p=>Hm(o,p,u)!==null,d=new Set,f=p=>{if(d.has(p))return;d.add(p);let h=n.get(ue(p));if(h){for(let m of qu(h))i.has(m)||c(m)||n.get(m)?.hidden!==!0||(f(m),l(m,!0));if(qt(h))for(let m of n.childrenOf(ue(p)))f(m)}};for(let p of Cc(t,u))f(p),l(p,!0);return{items:s}}var PX=e=>typeof e=="function"||typeof e=="object"&&e!==null&&Object.values(e).some(t=>typeof t=="function");function TX(e,t){let n={},r=e.registry;for(let o of Xa){let i=t[o.jsonKey],a=(typeof i=="string"?r[o.field]?.[i]:void 0)??(PX(t[o.field])?t[o.field]:void 0);a!==void 0&&(n[o.field]=a)}return n}function SX(e,t){let n=new Map,r=new Set(e.map(o=>o.id));for(let o=!0;o;){o=!1;for(let i of e){if(n.has(i.id))continue;let s,a=qu(i),l=a.filter(c=>!r.has(c)),u=t.get(i.id);i.parent!==null&&n.has(i.parent)?s={id:i.id,reason:"container-not-pasted"}:l.length>0?s={id:i.id,reason:"dependency-not-copied",missing:l}:a.length>0&&u.derivePath===void 0&&u.derivePose===void 0&&(s={id:i.id,reason:"derivation-not-registered"}),s!==void 0&&(n.set(i.id,s),r.delete(i.id),o=!0)}}return n}function h3(e,t,n,r){let o=t.items;if(o.length===0)return[];let i=new Map(o.map(b=>[b.id,TX(e.scene,b)])),s=SX(o,i);if(r?.onOmit)for(let b of o){let x=s.get(b.id);x&&r.onOmit(x)}let a=s.size===0?o:o.filter(b=>!s.has(b.id)),l=new Map;for(let b of a)l.set(b.id,e.scene.mintId());let u=b=>b.parent===null||!l.has(b.parent),c=new Map(a.map(b=>[b.id,b])),d=b=>{let x=b.parent===null?void 0:c.get(b.parent);for(;x!==void 0;){if(lt(x))return!0;x=x.parent===null?void 0:c.get(x.parent)}return!1},f=n.dx,p=n.dy;if(r?.dropPoint){let b=1/0,x=1/0;for(let w of a){if(!u(w))continue;let y=e.poseBounds(w.pose,w);y.x<b&&(b=y.x),y.y<x&&(x=y.y)}Number.isFinite(b)&&Number.isFinite(x)&&(f=r.dropPoint.x-b,p=r.dropPoint.y-x)}let h=e.landing?.(),m=h?.parent!=null?h:null,g=b=>{if(d(b))return Ja(b.pose);let x=e.translate(Ja(b.pose),f,p,b);return m&&u(b)?m.local(x):x};return a.map(b=>({id:l.get(b.id),kind:b.kind,layer:m&&u(b)?m.layer:b.layer,parent:u(b)?m?.parent??null:l.get(b.parent),pose:g(b),data:Ja(b.data),...ar(b),...b.children!==void 0?{children:b.children.filter(x=>l.has(x)).map(x=>l.get(x))}:{},...b.dependsOn==="children"?{dependsOn:"children"}:qu(b).length>0?{dependsOn:qu(b).map(x=>l.get(x))}:{},...i.get(b.id)}))}function kX(e){let t=Et(e.composition),n=YC(e.composition.compose),r=t?oP(e):void 0,o={getParent:i=>e.get(ue(i))?.parent??null,getPose(i){let s=e.get(ue(i));if(!s)throw new Error(`sceneToAdapter: unknown node "${i}"`);return Xn(e,s)},definesFrame(i){let s=e.get(ue(i));return s===void 0||lt(s)},...r?{childFrame:r}:{}};return{getPose:o.getPose,definesFrame:o.definesFrame,getWorldPose:i=>t?zt(o,i,n):o.getPose(i),worldOfStored(i,s){let a=t?qn(o,o.getParent(i)):null;return a===null?s:n(aa(o,a,n),s)},...t?{composePose:n}:{},...r?{childFrame:r}:{}}}function m3(e,t={}){let n=t.selection,r=n?.getSelection??n?.get??(()=>[]),o=n?.setSelection??n?.set??(()=>{}),i=t.poseDescriptor??jo,s=(f,p)=>Di(f,_r(i,p)),a=(f,p,h,m)=>rP(f,p,h,m===void 0?i:_r(i,m)),l={},u=f=>f?{...l,...n3(f,void 0)}:l,c={scene:e,worldPoseOf:f=>d.getWorldPose(f),frameAtOrAbove:f=>qn(d,f),poseBounds:s,translate:a,...t.pasteInto?{landing:()=>l3(e,t.pasteInto())}:{}},d={...oy(e),getNodes(){let f=qa(e);return e.renderOrderNodes().filter(p=>!f.hidden(p.id))},...kX(e),poseTarget:(f,p)=>f3(e,f,p??i),getLayers:()=>e.layers.map(f=>({id:f.id,visible:f.visible,parallax:f.parallax})),subscribeLayers:f=>e.subscribe(f),getLayout:f=>e.layoutOf(ue(f)),applyOps(f,p){p!==void 0?e.applyBatch(f,p,this):e3(this,f)},getSelection:r,setSelection:o,hitTestArea(f,p){return r3(e,f,u(p),i,{includeGroups:!0})},hitTestLasso(f,p,h){return o3(e,f,p,u(h),i,{includeGroups:!0})},...t.commitInsert?{commitInsert:f=>{let p=t.commitInsert(f);if(!p)return null;let h=t.insertLayer??"default";return{kind:"mark",id:p.id===void 0?e.mintId():ue(p.id),layer:h,pose:p.pose,data:p.data,parent:null}}}:{},snapshotSelection(f){return p3(c,f)},commitPaste(f,p,h){return h3(c,f,p,h)},getPasteOffset(){return{dx:12,dy:12}}};return d}var vX=()=>typeof performance<"u"?performance.now():Date.now();function y3(e,t,n=vX){return(r,o,i,s)=>{if(!e.has(r.id))return t(r,o,i,s);let a=n();return t(r,o,i,{...s,vertexColors:(l,u)=>e.resolve(r.id,l,u,a)})}}Z();Z();function g3(e,t,n){let r=t,o=br(t);return(i,s,a=t)=>{a!==r&&(r=a,o=br(a));let l=e(i,s,a);if(!l)return!1;let u=Ce(s),c=u?q.multiply(o,q.fromAffine(u)):o;return C0(l,c,n)}}function x3(e){let t=typeof window<"u"&&window.devicePixelRatio||1;return Math.max(Math.abs(e.scale.x),Math.abs(e.scale.y))*t}var b3,m1={};function AX(e){let t=x3(e);return(e!==b3||m1.pixelScale!==t)&&(b3=e,m1={pixelScale:t}),m1}function w3(e,t,n,r){let o=e.kind==="group"?void 0:Oc(e),i=!n||r?.pixelScale!==void 0?r:r?{...r,pixelScale:x3(n)}:AX(n),s=o?o.paint(e,t,i):[],a=e.data;if(a?.label&&a.text==null){let l=t,u=Fw(l.x+6,l.y+14,[{text:a.label,fill:{paint:{kind:"solid",color:"rgba(0,0,0,0.7)"}}}],{fontFamily:"sans-serif",fontSize:11});return[...s,e.kind==="group"?$m([u]):u]}return s}function P3(e,t){return(n,r,o,i)=>t(Tt(e,n),r,o,i)}function RX(e,t={}){let{getNode:n,getChildren:r,getPose:o,composePose:i,childFrame:s}=m3(e);return{getLayers:()=>vB(e.layers,t).map(a=>({id:a.id,visible:a.visible,parallax:a.parallax})),getNode:n,getChildren:r,getPose:o,...i?{composePose:i}:{},...s?{childFrame:s}:{}}}function T3(e,t,n,r,o,i,s,a){let l=ha(e),u=WB(e,aB(l,n)),c=s?y3(s,u):u,d=Dc(e),f=w=>d(Tt(e.overrides,w)),p=(w,y,P)=>{let S=e.overrides.read(w.id)?.alpha??1;return CB(c(Tt(e.overrides,w),y,P),y,(o?o(w.id):1)*S)},h=RX(e,i),m=a?{x:0,y:0,width:a.width,height:a.height}:void 0,g=m&&a?.paintBounds?g3(P3(e.overrides,lB(l,a.paintBounds)),t,m):void 0,b=QB(h,p,t,void 0,f,g),x=a&&m?M0(b,br(t),m,a.dpr):b;if(r&&r.length>0)for(let w of r)x.push(w);return[{kind:"group",transform:br(t),children:x}]}Z();function S3(e){let t=new Map,n=new Set,r=i=>{i&&n.add(i.kind??"solid")},o=i=>{for(let s of i)if(s.kind==="group")o(s.children);else if(s.kind==="path")r(s.fill?.paint),r(s.stroke?.paint);else if(s.kind==="text")for(let a of s.runs){let l=`${a.fontFamily}|${a.fontWeight}|${a.fontStyle}`;t.has(l)||t.set(l,{family:a.fontFamily,weight:a.fontWeight,style:a.fontStyle}),r(a.fill?.paint),r(a.stroke?.paint)}};return o(e),{fonts:[...t.values()],paintKinds:[...n]}}function k3(e,t,n){let r=NX(e,t,n);return IX(r),r}function NX(e,t,n){let r=t*4,o=new Uint8ClampedArray(e.length);for(let i=0;i<n;i++)o.set(e.subarray((n-1-i)*r,(n-i)*r),i*r);return o}function IX(e){for(let t=0;t<e.length;t+=4){let n=e[t+3];if(n===0||n===255)continue;let r=255/n;e[t]=e[t]*r,e[t+1]=e[t+1]*r,e[t+2]=e[t+2]*r}}function y1(e){let{sourceRect:t,scale:n}=e;for(let[c,d]of[["sourceRect.width",t.width],["sourceRect.height",t.height]])if(!Number.isFinite(d)||d<=0)throw new Error(`renderSceneToPixels: ${c} must be a positive finite number, got ${d}`);for(let[c,d]of[["scale.x",n.x],["scale.y",n.y]])if(!Number.isFinite(d)||d===0)throw new Error(`renderSceneToPixels: ${c} must be a nonzero finite number, got ${d}`);for(let[c,d]of[["sourceRect.x",t.x],["sourceRect.y",t.y]])if(!Number.isFinite(d))throw new Error(`renderSceneToPixels: ${c} must be a finite number, got ${d}`);let r=Math.max(1,Math.round(t.width*Math.abs(n.x))),o=Math.max(1,Math.round(t.height*Math.abs(n.y))),i={x:n.x<0?t.x+t.width:t.x,y:n.y<0?t.y+t.height:t.y,scale:{x:n.x,y:n.y}},s=e.resolveImage,a=e.drawOne??((c,d,f,p)=>w3(c,d,f,{...p,resolveImage:s})),l=[];e.background!==void 0&&l.push({kind:"path",path:{kind:"rect",x:0,y:0,width:r,height:o},fill:{paint:{kind:"solid",color:e.background}}});let u=e.annotations?void 0:{layerVisibility:Object.fromEntries([...Xm(e.scene.layers)].map(c=>[Km(c),!1]))};return l.push(...T3(e.scene,i,a,void 0,e.alphaFor,u,e.colorOverrides)),e.overlay&&l.push(...e.overlay),{width:r,height:o,view:i,commands:l}}function EX(e,t){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,t);if(typeof document<"u"){let n=document.createElement("canvas");return n.width=e,n.height=t,n}throw new Error("renderSceneToPixels: no canvas source in this environment \u2014 supply `gl` or `createCanvas`")}function g1(e={}){if(e.gl&&e.createCanvas)throw new Error("raster session: `gl` and `createCanvas` are mutually exclusive");let t=null,n=e.gl,r=null,o=!1;function i(s,a){if(e.gl||(t?(t.width<s&&(t.width=s),t.height<a&&(t.height=a)):(t=(e.createCanvas??EX)(s,a),t.width=s,t.height=a,n=t.getContext("webgl2",RB)??void 0)),!n||typeof n.enable!="function")throw new Error("raster session: WebGL2 is unavailable \u2014 supply `gl` or a WebGL2-capable `createCanvas`");if(v3(n))throw new Error("raster session: the WebGL2 context is lost \u2014 dispose this session and open another");let{drawingBufferWidth:l,drawingBufferHeight:u}=n;if(l<s||u<a)throw new Error(`raster session: a ${s} \xD7 ${a} render does not fit the context's ${l} \xD7 ${u} drawing buffer \u2014 lower \`scale\` or render the source rect in tiles`);return n}return{render(s){if(o)throw new Error("raster session: render() on a disposed session");let a=y1(s),{width:l,height:u}=a,c=i(l,u),d={px:s.flattenTolerancePx??.25};if(r?(r.resize({width:l,height:u,dpr:1}),r.setFlattenTolerance(d)):r=new ju({gl:c,width:l,height:u,dpr:1,imageMinification:"mipmap",flattenTolerance:d,bakeBudget:1/0}),r.render(a.commands,br(a.view),{screen:s.screen}),v3(c))throw new Error("raster session: the WebGL2 context was lost during render");let f=new Uint8Array(l*u*4);return c.readPixels(0,0,l,u,c.RGBA,c.UNSIGNED_BYTE,f),{width:l,height:u,data:k3(f,l,u)}},dispose(){o||(o=!0,r?.dispose(),r=null,t&&!e.createCanvas&&n?.getExtension("WEBGL_lose_context")?.loseContext(),t=null,n=void 0)}}}function v3(e){return typeof e.isContextLost=="function"&&e.isContextLost()===!0}function b1(e={}){let{families:t,paintKinds:n}=e;if(e.render||e.commands){let r;try{r=e.render?y1(e.render).commands:[]}catch(i){return Promise.reject(i)}let o=S3([...r,...e.commands??[]]);t??=o.fonts,n??=o.paintKinds.filter(L0)}return Promise.all([Ly(t),_0(n)]).then(()=>{})}async function x1(e){let t=new ImageData(new Uint8ClampedArray(e.data),e.width,e.height);if(typeof OffscreenCanvas<"u"){let o=new OffscreenCanvas(e.width,e.height),i=o.getContext("2d");if(!i)throw new Error("rasterToPng: no 2D context");return i.putImageData(t,0,0),o.convertToBlob({type:"image/png"})}if(typeof document>"u")throw new Error("rasterToPng: no canvas in this environment");let n=document.createElement("canvas");n.width=e.width,n.height=e.height;let r=n.getContext("2d");if(!r)throw new Error("rasterToPng: no 2D context");return r.putImageData(t,0,0),new Promise((o,i)=>{n.toBlob(s=>s?o(s):i(new Error("rasterToPng: encoding failed")),"image/png")})}var Qa=class extends Error{arrivals;constructor(t){let n=[...t.keys()].map(r=>`"${r}"`).join(", ");super(`Scene: ${n} refused the nodes joining it`),this.name="SceneArrivalRefused",this.arrivals=t}};var w1=xt(),mIe=w1.reflection;function A3(e,t){w1.set(e,t)}function iy(e,t){let n=w1.get(e);return n?n(t):null}function R3(e,{compose:t,decompose:n},r,o){let i=n(e,e),s=r(i),a=r(e);if(s===null||a===null)return null;let l=o(i,s,{...s,x:a.x+(a.width-s.width)/2,y:a.y+(a.height-s.height)/2}),u=r(l);if(u===null)return null;let c=!No(l,e);return{upright:l,bounds:u,turned:c,toStrategy:d=>c?t(l,n(e,d)):d,toWorld:d=>c?t(e,n(l,d)):d}}function N3(e){let t=e?.data?.pathEffect;return t&&typeof t=="object"&&typeof t.kind=="string"?t:null}var P1="kit:clipNothing",T1=()=>null;var I3="kit:unionOfChildren";function E3(e,t){let n=[];for(let o of t){if(o===void 0)continue;let i=S1(o.pose);if(i===null)return null;n.push(i)}if(n.length===0)return null;let r=v2(n);return r===null?null:r}function S1(e){if(e===null||typeof e!="object")return null;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"?e:null}function M3(e){return{...e,clipFromPose:{[P1]:T1,...e.clipFromPose},derivePath:{[qT]:XT,...e.derivePath},derivePose:{[I3]:E3,...e.derivePose}}}function F3(e,t){let{undoStack:n,redoStack:r,forks:o,floorId:i,nextEntryId:s}=e,a=0,l=b=>(a+=b.length,b.map(x=>MX(x,t))),u=b=>{let x=l(b);return x.slice(x.lastIndexOf(null)+1)},c=u(n),d=u(r),f=c.length===n.length?i:n[n.length-c.length-1].id,p=new Set([f,...[...c,...d].map(b=>b.id)]),h=[...o].flatMap(([b,x])=>x.map(w=>{let y=l(w),P=y.indexOf(null);return{at:b,entries:P<0?y:y.slice(0,P)}})).filter(b=>b.entries.length>0),m=[];for(let b=!0;b;){b=!1;let x=[];for(let w of h){if(!p.has(w.at)){x.push(w);continue}m.push(w);for(let y of w.entries)p.add(y.id);b=!0}h=x}let g=c.length+d.length+m.reduce((b,x)=>b+x.entries.length,0);return{version:1,undoStack:c,redoStack:d,...m.length>0?{branches:m}:{},...f!==0?{floor:f}:{},nextEntryId:s,droppedEntries:a-g}}function L3(e,t,n){let r=u=>OX(u,t,n),o=e.undoStack.map(r),i=e.redoStack.map(r),s=new Map;for(let u of e.branches??[]){let c=u.entries.map(r),d=s.get(u.at);d?d.push(c):s.set(u.at,[c])}let a=e.nextEntryId,l=[o,i,...[...s.values()].flat()];for(let u of l)for(let c of u)c.id>=a&&(a=c.id+1);return{undoStack:o,redoStack:i,forks:s,floorId:e.floor??0,nextEntryId:a}}function Qi(e){let t=new Set;for(let n of e){if(n.args===null||typeof n.args!="object")continue;let r=n.args;if(typeof r.id=="string")t.add(r.id);else if(r.node!==null&&typeof r.node=="object"){let o=r.node;typeof o.id=="string"&&t.add(o.id)}else if(Array.isArray(r.nodes))for(let o of r.nodes){let i=o!==null&&typeof o=="object"?o.id:void 0;typeof i=="string"&&t.add(i)}}return t}function C3(e){return typeof e.name!="string"?null:{name:e.name,args:e.args}}function MX(e,t){let n=[];for(let o of e.forwardOps){let i=C3(o);if(i===null)return t.log(`serialize: dropping entry id=${e.id} "${e.label}" \u2014 forwardOp without name`),null;n.push(i)}let r=[];for(let o of e.baseOps){let i=C3(o);if(i===null)return t.log(`serialize: dropping entry id=${e.id} "${e.label}" \u2014 baseOp without name`),null;r.push(i)}return{id:e.id,label:e.label,forwardOps:n,baseOps:r,pushes:e.pushes,timestamp:e.timestamp,...e.selectionBefore?{selectionBefore:e.selectionBefore}:{},...e.selectionAfter?{selectionAfter:e.selectionAfter}:{}}}function CX(e,t,n){let r={name:e,args:t,label:n,apply:()=>"noop",invert:()=>r};return r}function O3(e,t,n,r){let o=n?n(e.name,e.args):null;return o!==null?o:(r.log(`restore: unknown op name "${e.name}" \u2014 substituting no-op placeholder`),CX(e.name,e.args,t))}function OX(e,t,n){let r=e.forwardOps.map(i=>O3(i,e.label,t,n)),o=e.baseOps.map(i=>O3(i,e.label,t,n));return{id:e.id,label:e.label,forwardOps:r,baseOps:o,timestamp:e.timestamp??0,pushes:e.pushes??1,touchedIds:Qi(r),...e.selectionBefore?{selectionBefore:[...e.selectionBefore]}:{},...e.selectionAfter?{selectionAfter:[...e.selectionAfter]}:{}}}function _3(e,t){if(e.length===0||t.length===0||e.length!==t.length)return!1;let n=new Map;for(let r of e){let o=r.coalesceKey;if(o===void 0)return!1;n.set(o,(n.get(o)??0)+1)}for(let r of t){let o=r.coalesceKey,i=o===void 0?0:n.get(o)??0;if(!i)return!1;n.set(o,i-1)}return!0}function k1(e){return{id:e.id,label:e.label,timestamp:e.timestamp,pushes:e.pushes,touchedIds:e.touchedIds,...e.selectionBefore?{selectionBefore:e.selectionBefore}:{},...e.selectionAfter?{selectionAfter:e.selectionAfter}:{}}}function lr(e,t=[]){return{kind:e,entries:t.map(n=>({id:n.id,label:n.label,ops:n.forwardOps}))}}function D3(e,t){function n(o){for(let i of o)try{i.apply(e)}catch(s){t.warn(`unwinding a failed step: op "${i.name??"?"}" threw: ${String(s)}`)}}function r(o,i,s){let a=!1,l=0;try{for(;l<o.length;l++){let u=o[l].apply(e);u!==!1&&u!=="noop"?a=!0:s?.push(o[l])}}catch(u){throw l>0&&(n(o.slice(0,l).reverse().map(c=>c.invert())),i&&n(i())),u}return a}return r}function B3(e,t,n){let r=e.forwardOps===e.baseOps;e.forwardOps=[...e.forwardOps,...t],e.baseOps=r?e.forwardOps:[...e.baseOps,...t],e.timestamp=n,e.pushes++;let o=new Set(e.touchedIds);for(let i of Qi(t))o.add(i);e.touchedIds=o}function H3(e){for(let t=0;t<e.length;t++)if(e[t].caused!==void 0)return!0;return!1}var sy=new WeakMap;function G3(e){let t=sy.get(e);if(!t)throw new Error("Journal is not resumable (already committed or cancelled)");t()}function U3(e,t,n,r,o={}){let i=Uc(t,{...o,...n.coalesceWindowMs!==void 0?{coalesceWindowMs:n.coalesceWindowMs}:{}}),s=o.selection,a=0,l=Me();function u(){a++,l.emit()}i.subscribe(u);let c=e.currentEntryId(),d=s?[...s.get()]:void 0,f="active",h={targetId:n.targetId,forkedAtEntryId:c,applyBatch(m,g){if(f!=="active")throw new Error("Journal is not active");i.applyOps(m,g)},undo(){if(f!=="active")throw new Error("Journal is not active");i.undo()},redo(){if(f!=="active")throw new Error("Journal is not active");i.redo()},canUndo(){return i.canUndo()},canRedo(){return i.canRedo()},entries(){return i.entries()},seal(){i.seal()},observe:m=>i.observe(m),beginJournal(m){if(f!=="active")throw new Error("Journal is not active");return i.beginJournal(m)},getVersion:()=>a,subscribe:l.subscribe,commit(m){if(f!=="active")throw new Error("Journal is not active");let{forwardOps:g,baseOps:b}=v1(i).appliedOps();v1(e).record(g,b,m,d?{selectionBefore:d}:void 0),f="closed",sy.delete(h),r?.(),u()},cancel(){if(f!=="active")throw new Error("Journal is not active");i.goto(0),f="closed",sy.delete(h),r?.(),u()},suspend(){if(f!=="active")throw new Error("Journal is not active");f="suspended",r?.(),u()},isActive(){return f==="active"}};return sy.set(h,()=>{if(f!=="suspended")throw new Error("Journal is not suspended");f="active",u()}),h}var W3=new WeakMap;function v1(e){let t=W3.get(e);if(!t)throw new Error("Not a history built by createHistory");return t}var FX={log:()=>{},warn:()=>{}};function Uc(e,t={}){let n=[],r=[],o=null,i=t.coalesceWindowMs??0,s=t.now??(()=>Date.now()),a=Math.max(0,t.historyLimit??1/0),l=t.onEvict,u=t.branching??!1,c=new Map,d=0,f=t.rebuildOp,p=t.selection,h=t.debug??FX,m=1,g=0,b=-1,x=Me(),w=Me();function y(G){g++,G&&w.size>0&&w.emit(typeof G=="function"?G():G),x.emit()}function P(G){if(l)for(let K of G)try{l({id:K.id,label:K.label,forwardOps:K.forwardOps,baseOps:K.baseOps})}catch($){h.warn(`onEvict callback threw for entry id=${K.id} "${K.label}": ${String($)}`)}}function S(G){P(G);for(let K of G){let $=c.get(K.id);if($){c.delete(K.id);for(let ee of $)S(ee)}}}function v(G){for(let K of G){l&&P([K]);let $=c.size>0?c.get(d):void 0;if($!==void 0&&c.delete(d),d=K.id,$!==void 0)for(let ee of $)S(ee)}}function A(){return n[n.length-1]?.id??d}function N(G){if(r.length===0)return;let K=r.splice(0);if(!u)return S(K);let $=c.get(G);$?$.push(K.reverse()):c.set(G,[K.reverse()])}function M(){for(;n.length>a;)v([n.shift()])}let C=D3(e,h);function F(G){return[...G.baseOps].reverse().map(K=>K.invert())}function B(){return p?[...p.get()]:void 0}function D(G){let K=B(),$=G.forwardOps!==G.baseOps;C(F(G),$?()=>G.forwardOps:void 0),K&&(G.selectionAfter=K),p&&G.selectionBefore&&p.set(G.selectionBefore)}function j(G){let K=B(),$=G.forwardOps!==G.baseOps;C(G.forwardOps,$?()=>F(G):void 0),K&&(G.selectionBefore=K),p&&G.selectionAfter&&p.set(G.selectionAfter)}function W(G){let K=[];for(;n.length>G;){let $=n[n.length-1];D($),n.pop(),r.push($),K.push($)}for(;n.length<G&&r.length>0;){let $=r[r.length-1];j($),r.pop(),n.push($),K.push($)}return K}function J(G,K){let $=typeof i=="function"?i():i;return!($>0)||G.coalesceKey!==void 0||g!==b||s()-G.timestamp>$?!1:_3(G.forwardOps,K)}function se(G,K){if(G.length===0)return;let $=B(),ee=[],te=C(G,void 0,ee),he=ee.length===0?G:G.filter(vt=>!(vt.elideNoop&&ee.includes(vt))),be=H3(he)?he.flatMap(vt=>vt.caused?.()??[vt]):he.slice();if(!te){h.warn(`'${K}' batch was a no-op \u2014 every op reported false/'noop'. Skipping the undo entry; consider gating the dispatch upstream to avoid the wasted work.`);return}if(be.length===0)return;let Fe=Qi(be),Se=n[n.length-1];if(Se&&J(Se,be)){if(Se.forwardOps=be,Se.timestamp=s(),Se.pushes++,Fe.size>0){let vt=new Set(Se.touchedIds);for(let Xt of Fe)vt.add(Xt);Se.touchedIds=vt}h.log(`coalesce '${K}' into entry id=${Se.id} (${be.length} ops)`),y(()=>({kind:"coalesce",entries:[{id:Se.id,label:Se.label,ops:be}]})),b=g;return}h.log(`push '${K}' (${be.length} ops)`);let ur=A(),Le={id:m++,forwardOps:be,baseOps:be,label:K,timestamp:s(),pushes:1,touchedIds:Fe,...$?{selectionBefore:$}:{}};n.push(Le),N(ur),M(),y(()=>lr("push",[Le])),b=g}function ke(G,K){B3(G,K,s()),y(()=>({kind:"coalesce",entries:[{id:G.id,label:G.label,ops:K}]})),b=g}function ae(G,K,$,ee={}){if(G.length===0)return;let te=ee.coalesceKey,he=n[n.length-1];if(te!==void 0&&he?.coalesceKey===te&&g===b&&G===K)return ke(he,G);let be=A(),Fe={id:m++,forwardOps:G,baseOps:K,label:$,timestamp:s(),pushes:1,touchedIds:Qi(G),...ee.selectionBefore?{selectionBefore:[...ee.selectionBefore]}:{},...te!==void 0?{coalesceKey:te}:{}};n.push(Fe),N(be),M(),y(()=>lr("push",[Fe])),te!==void 0&&(b=g)}let ve={apply(G,K){se([G],K??G.label??"")},applyOps(G,K){se(G,K)},undo(){n.length!==0&&y(lr("undo",W(n.length-1)))},redo(){r.length!==0&&y(lr("redo",W(n.length+1)))},seal(){b=-1},canUndo:()=>n.length>0,canRedo:()=>r.length>0,undoDepth:()=>n.length,redoDepth:()=>r.length,clear:()=>{let G=n.length>0||r.length>0||c.size>0;n.length=0,r.length=0,c.clear(),d=0,G&&y(lr("clear"))},entries(){return{undo:n.map(k1),redo:[...r].reverse().map(k1)}},goto(G){let K=n.length+r.length;if(G<0||G>K||G===n.length)return;let $=n.length,ee;try{ee=W(G)}catch(te){try{W($)}catch(he){h.warn(`goto: returning to depth ${$} threw: ${String(he)}`)}throw n.length!==$&&y(),te}y(lr("goto",ee))},timestampAt(G){if(!(G<0))return G<n.length?n[G].timestamp:r[r.length-1-(G-n.length)]?.timestamp},depthAt(G){let K=n.length;for(;K>0&&n[K-1].timestamp>G;)K--;if(K<n.length)return K;for(let $=r.length-1;$>=0&&r[$].timestamp<=G;$--)K++;return K},prune(G){let K=0;for(;K<n.length&&n[K].timestamp<G;)K++;if(K===0)return;let $=n.splice(0,K);v($),y(lr("prune",$))},branches(){let G=($,ee)=>{let te=$[0];return{id:te.id,label:te.label,timestamp:te.timestamp,length:$.length,current:ee}},K=(c.get(A())??[]).map($=>G($,!1));return r.length>0&&K.push(G([...r].reverse(),!0)),K.sort(($,ee)=>$.id-ee.id)},switchBranch(G){if(r[r.length-1]?.id===G)return;let K=A(),$=c.get(K)??[],ee=$.findIndex(he=>he[0].id===G);if(ee<0)throw new Error(`No branch ${G} forks from entry ${K}`);let[te]=$.splice(ee,1);r.length>0&&$.push(r.splice(0).reverse()),$.length>0?c.set(K,$):c.delete(K),r.push(...[...te].reverse()),y(lr("branch",te))},getVersion:()=>g,subscribe:x.subscribe,observe:w.subscribe,serialize:()=>F3({undoStack:n,redoStack:r,forks:c,floorId:d,nextEntryId:m},h),recordEntry(G,K,$){ae(G,G,K,$)},allForwardOps(){let G=[];for(let K of n)for(let $ of K.forwardOps)G.push($);return G},currentEntryId:()=>m,beginJournal(G){if(o!==null&&o.isActive())throw new Error("A journal is already active \u2014 commit, cancel, or suspend it first");let K=U3(ve,e,G,()=>{o=null},{coalesceWindowMs:i,now:s,debug:h,...p?{selection:p}:{}});return o=K,K},activeJournal:()=>o?.isActive()?o:null,resumeJournal(G){if(o!==null&&o!==G&&o.isActive())throw new Error("A journal is already active \u2014 commit, cancel, or suspend it first");G3(G),o=G},restore(G){let K=L3(G,f,h);n.splice(0,n.length,...K.undoStack),r.splice(0,r.length,...K.redoStack),c.clear();for(let[$,ee]of K.forks)c.set($,ee);d=K.floorId,m=K.nextEntryId,y(lr("restore"))}};return W3.set(ve,{appliedOps:()=>({forwardOps:n.flatMap(G=>G.forwardOps),baseOps:n.flatMap(G=>G.baseOps)}),record:ae}),ve}function V3(e,t){let n=new Map,r=new Set,o=i=>{r.clear();for(let[s,a]of i){r.add(s);let l=n.get(s);if(l){l.pose=a.pose,l.data=a.data,e.has(s,l)||e.set(s,l);continue}let u={pose:a.pose,data:a.data};n.set(s,u),e.set(s,u)}for(let[s,a]of n)r.has(s)||(n.delete(s),e.clear(s,a));e.commit()};return{set(i){o(LX(i))},show:o,others(){let i=new Map;for(let s of e.ids()){let a=t(s)??[],l=n.get(s);for(let u=a.length-1;u>=0;u--){let c=a[u];if(!(c===l||c.pose===void 0)){i.set(s,c.pose);break}}}return i},drop(){if(n.size!==0){for(let[i,s]of n)e.clear(i,s);n.clear(),e.commit()}}}}function*LX(e){for(let[t,n]of e)yield[t,{pose:n}]}var _X=Object.freeze({}),z3=new WeakMap;function DX(e,t){let n=z3.get(e);n===void 0&&z3.set(e,n=new WeakMap);let r=n.get(t);return r===void 0&&n.set(t,r=o=>t(e(o))),r}var BX={merge:DX,lerp:(e,t,n)=>n<.5?e:t};function K3(e){let t=$T({pose:Th(),alpha:lP(),path:Th(),data:BX}),n=[],r=0,o=i=>{for(;n.length>i;)n.pop().fade({over:0});for(;n.length<i;){let s=n.length;n.push(t.cue({patch:AP(0,(a,l)=>e.get(l)?.[s]??_X,{writes:["pose","alpha","path","data"]})}))}t.sync(r++)};return o(1),{probe:(i,s)=>{t.probe(i,s)},publish:o,drop:i=>{t.drop(i)}}}function $3(){let e=new Map,t=new WeakMap,n=0,r=[],o=0,i=(s,a)=>{for(s>0&&r[s]--,a>0&&(r[a]=(r[a]??0)+1),a>o&&(o=a);o>0&&(r[o]??0)===0;)o--};return{plies:e,claim(s,a){let l=e.get(s);l===void 0&&e.set(s,l=[]);let u=l.indexOf(a);u>=0&&l.splice(u,1);let c=u>=0?void 0:t.get(a);c===void 0&&t.set(a,c=++n);let d=l.length;for(;d>0&&t.get(l[d-1])>c;)d--;l.splice(d,0,a),u<0&&i(l.length-1,l.length)},release(s,a){t.delete(a);let l=e.get(s),u=l?.indexOf(a)??-1;return l===void 0||u<0?!1:(l.splice(u,1),i(l.length+1,l.length),l.length===0&&e.delete(s),!0)},drop(s){let a=e.get(s);return a===void 0?!1:(e.delete(s),i(a.length,0),!0)},dropAll(){e.clear(),r.length=0,o=0},depth:()=>Math.max(o,1)}}var j3=e=>{let t=e;return t!==null&&typeof t=="object"&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"?t:null},A1=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height;function Y3(e,t,n){for(let r=e.length-1;r>=0;r--){let o=e[r];if(o.path===void 0)continue;let i=j3(o.pose),s=j3(t);if(i===null||s===null||A1(i,s))return o.path;let a=n.carried;return a!==void 0&&a.source===o.path&&A1(a.from,i)&&A1(a.to,s)?a.path:(n.carried={source:o.path,from:{...i},to:{...s},path:dh(o.path,i,s)},n.carried.path)}}function R1(e,t){let n=$3(),{plies:r}=n,o=K3(r),i=Me(),s=0,a=new Map;function l(f){let p=e(f);if(p){un(p);let h=w2(p);h&&un(h)}t?.(f)}function u(){s++,o.publish(n.depth()),i.emit()}function c(f){a.delete(f),o.drop(f)}let d={set(f,p){n.claim(f,p),l(f),u()},get(f){return r.get(f)?.at(-1)},read(f){let p=r.get(f);if(p===void 0)return;let h=a.get(f);return h===void 0&&(h={out:{},at:-1},a.set(f,h)),h.at!==s&&(o.probe(f,h.out),h.out.path=Y3(p,h.out.pose,h),h.at=s),h.out},has(f,p){let h=r.get(f);return h!==void 0&&(p===void 0||h.includes(p))},ids(){return[...r.keys()]},clear(f,p){(p===void 0?n.drop(f):n.release(f,p))&&(r.has(f)||c(f),l(f),u())},clearAll(){if(r.size!==0){for(let f of r.keys())c(f),l(f);n.dropAll(),u()}},commit(){for(let f of r.keys())l(f);u()},subscribe:i.subscribe,getGeneration(){return s},hold:()=>V3(d,f=>r.get(f))};return d}function ay(e,t,n){let r={...e.placed?{placed:e.placed}:{}};return{name:"arrange",args:r,label:"Arrange",elideNoop:!0,get coalesceKey(){return r.placed===void 0?void 0:`arrange:${r.placed.map(o=>o.id).sort().join(",")}`},apply(o){r.placed===void 0&&(r.placed=t?.()??[]);let i=n??((s,a)=>o.setPose(s,a));for(let s of r.placed)i(s.id,s.to);return r.placed.length>0?void 0:"noop"},invert(){let o=r.placed??[];return ay({placed:[...o].reverse().map(i=>({id:i.id,from:i.to,to:i.from}))},void 0,n)}}}A3("arrange",e=>ay(e));function q3(e,t,n){let r=new Map;for(let[o,i]of t){let s=i.filter(a=>e.get(a)?.parent===o===n);s.length>0&&e.has(o)&&r.set(o,s)}return r}function X3(e){let{nodes:t}=e,n=null,r=!1,o=null,i=new Map,s=new Set,a=null,l=Me(),u=()=>n??(r?e.layoutPass:null);function c(m=!1){return o!==null||!m&&u()===null?!1:(o=new Map,i=new Map,s=new Set,a=null,!0)}function d(){let m=a;a=null,!(m===null||m.length===0)&&l.emit(m)}function f(){let m=o;o=null;let g=u();if(m===null||g===null)return[];let b=q3(t,m,!0),x=q3(t,i,!1);i=new Map;let w=new Set([...s].filter(S=>t.has(S)));if(b.size===0&&w.size===0)return[];let y=g(b,w,x);if(y===null)throw new Qa(b);let P=[];for(let[S,v]of y){let A=t.get(S);A&&P.push({id:S,from:A.pose,to:v})}return a=P,P}function p(){o=null,a=null}function h(m){return c(!0)?{ops:[...m,ay({},f,e.writePose)],owned:!0}:{ops:m,owned:!1}}return{layoutDeclared:()=>{r=!0},setHandler(m){return n=m,()=>{n===m&&(n=null)}},onReflow:l.subscribe,noteArrival(m,g,b){if(o===null||g===null||g===b)return;s.add(g);let x=o.get(g);x===void 0?o.set(g,[m]):x.includes(m)||x.push(m)},noteDeparture(m,g,b){if(o===null||g===null||g===b||(s.add(g),o.get(g)?.includes(m)))return;let x=i.get(g);x===void 0?i.set(g,[m]):x.includes(m)||x.push(m)},noteChange(m){o!==null&&m!==null&&s.add(m)},bareLayoutEdit:()=>u()!==null&&o===null&&e.recordsBareEdits(),open:c,settle:f,emitReflow:d,abandon:p,runEdit(m,g){let{ops:b,owned:x}=h(m);if(!x)return g(b),!0;try{return g(b),d(),!0}catch(w){if(!(w instanceof Qa))throw w;return!1}finally{p()}}}}function J3(){let e=Me(),t=0,n=0,r=!1;return{notify(){if(t++,n>0){r=!0;return}e.emit()},version:()=>t,subscribe:e.subscribe,deferred(o,i){n++;try{return o()}finally{n--,i?.(),n===0&&r&&(r=!1,e.emit())}},muted(o){let i=r;n++;try{return o()}finally{n--,r=i}}}}function Q3(e,t){return{subscribe:e.subscribe,getVersion:e.version,getContentVersion:()=>e.version()-t.changes()}}function Z3(e){let t=new Map;return{seeOff(n,r,o,i){let s=new Map;for(let u of r){let c=s.get(u.parent);c?c.push(u):s.set(u.parent,[u])}let a=u=>{let c=e(u.id);if(!c)return null;let d=(s.get(u.id)??[]).map(a).filter(f=>f!==null);return{node:c.node,pose:c.pose,children:d}},l=n.map(u=>[u,a(u)]);return()=>{let u=new Set;for(let c of r){let d=i.get(c.id);d&&d.from===void 0&&u.add(c.id),i.delete(c.id)}for(let[c,d]of l)d&&!u.has(c.id)&&t.set(c.id,{id:c.id,parent:c.parent,...d,...o})}},takeBack(n){let r=t.get(n);return t.delete(n),r?.pose},drain(){if(t.size===0)return[];let n=[];for(let r of t.values()){let o=r.parent!==null?t.get(r.parent):void 0;o?o.children.push(r):n.push(r)}return t.clear(),n}}}var HX=()=>{};function eH(e){let t=Me(),n=new Map,r=Z3(e.shown),o=null,i="call",s=0,a=0,l=0,u=0,c=()=>u>0&&l===0;function d(x){return s>0?{origin:x?"undo":"redo"}:a>0?{origin:"layout"}:e.untracked()?{origin:"untracked"}:o!==null?{origin:i,label:o}:{origin:"call"}}function f(x,w,y,P){if(!c())return;let S=n.get(x);S?S.to=y:n.set(x,{id:x,from:w,to:y,...d(P)})}function p(x,w){if(c())for(let y of x)n.set(y.id,{id:y.id,from:r.takeBack(y.id),to:y.pose,...d(w)})}let h=(x,w,y)=>c()?r.seeOff(x,w,d(y),n):HX;function m(x,w,y){w();try{return x()}finally{y()}}let g={"kit:setPose":x=>({...x,apply:w=>{x.apply(w);let y=w;f(y.id,y.from,y.to,!1)},revert:w=>{x.revert(w);let y=w;f(y.id,y.to,y.from,!0)}}),"kit:add":x=>({...x,apply:w=>{x.apply(w),c()&&p([w],!1)},revert:w=>{let y=h([w],[w],!0);x.revert(w),y()}}),"kit:remove":x=>({...x,apply:w=>{let y=w,P=h(y.detached,y.nodes,!1);x.apply(w),P()},revert:w=>{x.revert(w),p(w.nodes,!0)}})};function b(){let x=r.drain();if(n.size===0&&x.length===0)return;let w=[...n.values()].filter(y=>!Zr(y.from,y.to));n.clear(),(w.length>0||x.length>0)&&t.emit(w,x)}return e.changes.subscribe(b),{subscribe(x){let w=t.subscribe(x);u++;let y=!0;return()=>{y&&(y=!1,u--,w())}},labeled(x,w,y){if(o!==null)return y();o=x,i=w;try{return y()}finally{o=null}},replaying:x=>m(x,()=>{s++},()=>{s--}),layout:x=>m(x,()=>{a++},()=>{a--}),quiet:x=>m(x,()=>{l++},()=>{l--}),reporting:x=>(w,y)=>x(w,g[w]?.(y)??y)}}function tH(){let e={batch:0,engine:0,untracked:0,own:0},t=0;return{open:()=>t>0,records:()=>e.engine+e.untracked===0,untracked:()=>e.untracked>0,during(n,r){e[n]++,t++;try{return r()}finally{e[n]--,t--}}}}var nH="kit:setDoc";function N1(e,t,n){n===void 0?e.delete(t):e.set(t,n)}function rH(e){return{toJSON(){return e.size===0?void 0:Object.fromEntries(e)},reset(t){e.clear();for(let[n,r]of Object.entries(t??{}))N1(e,n,r)}}}function oH(e){let{values:t}=e;return e.register(nH,{apply:n=>{let{key:r,to:o}=n;N1(t,r,o)},revert:n=>{let{key:r,from:o}=n;N1(t,r,o)}}),{get:n=>t.get(n),set(n,r){let o=t.get(n);Zr(o,r)||e.record(nH,{key:n,from:o,to:r},"setDoc")},keys:()=>[...t.keys()]}}function ly(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,r)=>ly(n,t[r]));if(Zt(e)&&Zt(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(r=>r in t&&ly(e[r],t[r]))}return!1}function iH(e,t,n){n===void 0?delete e[t]:e[t]=n}var sH={units:"kit:setUnits",clip:"kit:setClip"};function aH(e){for(let n of["units","clip"])e.register(sH[n],{apply:r=>{let{id:o,to:i}=r;iH(e.requireNode(o),n,i)},revert:r=>{let{id:o,from:i}=r;iH(e.requireNode(o),n,i)}});let t=(n,r,o)=>(i,s)=>{let a=e.requireNode(i)[n];e.refuse(i,o),!ly(a,s??void 0)&&e.record(sH[n],{id:i,from:a,to:s??void 0},r)};return{setUnits:t("units","setUnits","set the units of"),setClip:t("clip","setClip","set the clip of")}}function lH(e,t,n){let r=N3({data:e}),o=r?.foundHidden;if(!r||!o||o.length===0)return null;let i=Array.isArray(t)?t:[],s=new Set(o.map(u=>i[u])),a=(Array.isArray(n)?n:[]).flatMap((u,c)=>s.has(u)?[c]:[]);if(a.length===o.length&&a.every((u,c)=>u===o[c]))return null;let l={...r,foundHidden:a};return a.length===0&&delete l.foundHidden,{...e,pathEffect:l}}function uH(e){return{bounds:e?.bounds??(t=>{let n=S1(t);return n===null?null:{x:n.x,y:n.y,width:n.width,height:n.height}}),remap:e?.remap??((t,n,r)=>({...t,...r}))}}function I1(e,t,n,r){let o=e.bounds(n,t),i=e.bounds(r,t);return o===null||i===null?o!==i:o.width!==i.width||o.height!==i.height}var GX=16;function cH(e,t,n,r,o,i=new Map){let s=new Map,a=w=>s.get(w)??Lr(e,e.get(w)),l={getPose:w=>a(w),getParent:w=>e.get(w)?.parent??null,definesFrame:w=>{let y=e.get(w);return y===void 0||lt(y)}},{compose:u,decompose:c}=e.composition,d=w=>zt(l,w,u),f=[...new Set([...n.keys(),...r])],p=new Map,h=(w,y)=>{let P=a(w);No(P,y)||(s.set(w,y),w!==m&&t(w)!==null&&I1(o,w,P,y)&&f.push(w))},m=null,g=w=>{let y=R3(d(w),e.composition,S=>o.bounds(S,w),(S,v,A)=>o.remap(S,v,A,w));if(y===null)return null;let P=e.childrenOf(w).map(S=>({id:S,pose:y.toStrategy(d(S))}));return{...y,container:{id:w,bounds:y.bounds},children:P}},b=(w,y,P)=>{if(P.bounds){let S=e.get(w),v=y.toWorld(o.remap(y.upright,y.container.bounds,P.bounds,w));h(w,la(l,v,S.parent,u,c))}for(let[S,v]of P.poses){let A=S;if(e.get(A)?.parent!==w)continue;let N=o.bounds(d(A),A);h(A,la(l,y.toWorld(v),w,u,c)),x(A,N)}},x=(w,y)=>{let P=o.bounds(d(w),w);if(y===null||P===null)return;let S=P.x-y.x,v=P.y-y.y;if(S===0&&v===0)return;let A=N2({childrenOf:N=>e.childrenOf(N),poses:l,composition:e.composition},w,(N,M)=>{let C=o.bounds(N,M);return C===null?null:o.remap(N,C,{...C,x:C.x+S,y:C.y+v},M)});for(let[N,M]of A)h(N,M)};for(;f.length>0;){let w=f.shift();m=w;let y=(p.get(w)??0)+1;if(p.set(w,y),y>GX)continue;let P=t(w);if(P===null||e.get(w)===void 0)continue;let S=y===1?n.get(w):void 0,v=y===1?i.get(w):void 0,A=!1;if(v!==void 0&&P.depart){let N=g(w);if(N===null)continue;let M=new Set(S??[]),C=N.children.filter(F=>!M.has(F.id));b(w,N,P.depart(N.container,C,new Set(v))),A=!0}if(S!==void 0&&P.arrive){let N=g(w);if(N===null)continue;let M=P.arrive(N.container,N.children,new Set(S));if(M===null)return null;b(w,N,M)}else if(!A||S!==void 0){let N=g(w);if(N===null)continue;b(w,N,{poses:P.childPoses(N.container,N.children)})}}return s}function dH(e){let{layoutFrame:t,layoutField:n,layoutRefs:r}=e,{requireNode:o,descendants:i}=e.store,{refuse:s,refuseLayer:a}=e.locks,{requireLayerIndex:l,assertSubtreeLayer:u}=e.layers,{record:c,edit:d,batch:f}=e.recorder,{noteChange:p,layoutDeclared:h}=e.arrivals;return{update(m,g){let b=o(m);s(m,"update"),c("kit:setData",{id:m,from:b.data,to:g.data},"update")},setPose(m,g){let b=o(m);s(m,"set the pose of");let x=b.layout!==void 0&&I1(t,m,b.pose,g),w=b.parent===null?void 0:o(b.parent),y=w?.layout!==void 0?w.id:null;d("setPose",x||y!==null,()=>{x&&p(m),p(y),c("kit:setPose",{id:m,from:b.pose,to:g},"setPose")})},setLayer(m,g){l(g);let b=o(m);if(s(m,"relayer"),b.layer!==g&&a(g,"move nodes onto"),b.parent!==null){let w=o(b.parent);u(m,g,b.parent,w.layer,"relayer")}if(b.layer===g)return;let x=[m];i(m,x);for(let w of x)s(w,"relayer");x.length===1?c("kit:setLayer",{id:m,from:b.layer,to:g},"setLayer"):f("setLayer",()=>{for(let w of x){let y=o(w);y.layer!==g&&c("kit:setLayer",{id:w,from:y.layer,to:g},"setLayer")}})},setDependsOn(m,g){let b=o(m);if(s(m,"retarget"),f2(b.dependsOn,g))return;let x=lH(b.data,b.dependsOn,g);if(x===null)return void c("kit:setDependsOn",{id:m,from:b.dependsOn,to:g},"setDependsOn");f("setDependsOn",()=>{c("kit:setDependsOn",{id:m,from:b.dependsOn,to:g},"setDependsOn"),c("kit:setData",{id:m,from:b.data,to:x},"setDependsOn")})},setLayout(m,g){let b=o(m);s(m,"set the layout of");let x;if(typeof g=="string"){if(x=n.fnOf(g)??null,x===null)throw new Error(`Scene: no layout "${g}" in this scene's registry`)}else x=g;let w=b.layout??null;if(w===x)return;x!==null&&h();let y=w===null?void 0:n.keyOf(w),P=x===null?void 0:n.keyOf(x),S={id:m,...y!==void 0?{fromKey:y}:{},...P!==void 0?{toKey:P}:{}};r.set(S,{from:w,to:x}),d("setLayout",!0,()=>{p(m),c("kit:setLayout",S,"setLayout")})}}}function fH(e,t){t===void 0?delete e.parallax:e.parallax=t}function pH(e){let{state:t,requireLayerIndex:n,rebuildLayerIndex:r}=e;function o(s,a){e.register(s,a)}o("kit:setLayerVisible",{apply:s=>{t.layers[n(s.layer)].visible=s.to,s.to||e.narrowSelection()},revert:s=>{t.layers[n(s.layer)].visible=s.from}}),o("kit:setLayerLocked",{apply:s=>{t.layers[n(s.layer)].locked=s.to,s.to&&e.narrowSelection()},revert:s=>{t.layers[n(s.layer)].locked=s.from}}),o("kit:setLayerParallax",{apply:s=>{fH(t.layers[n(s.layer)],s.to)},revert:s=>{fH(t.layers[n(s.layer)],s.from)}}),o("kit:addLayer",{apply:s=>{t.layers.splice(s.index,0,{...s.record}),r()},revert:s=>{t.layers.splice(s.index,1),r()}}),o("kit:removeLayer",{apply:s=>{t.layers.splice(s.index,1),r()},revert:s=>{t.layers.splice(s.index,0,{...s.record}),r()}}),o("kit:renameLayer",{apply:s=>{t.layers[n(s.layer)].name=s.to},revert:s=>{t.layers[n(s.layer)].name=s.from}});function i(s,a){let[l]=t.layers.splice(n(s),1);t.layers.splice(a,0,l),r()}o("kit:moveLayer",{apply:s=>i(s.layer,s.to),revert:s=>i(s.layer,s.from)})}function UX(e){let{detach:t,attach:n,invalidateChildDerivedFrom:r,invalidateDependents:o}=e.store;return(i,s,a,l)=>{t(i),n(i,a,l),r(s),o(i),s!==a&&e.narrowSelection()}}function hH(e){let{state:t,requireLayerIndex:n,invalidateOrder:r,fnFields:o}=e,{dependents:i,childDerived:s,invalidateDependents:a,invalidateChildDerivedFrom:l,trackChildDerived:u,retarget:c,requireNode:d,detach:f,attach:p,addedFns:h,restoreNodeFunctions:m}=e.store;function g(y,P){e.register(y,P)}let b=UX(e);g("kit:add",{apply:y=>{if(t.nodes.has(y.id))throw new Error(`Scene: id collision on "${y.id}"`);let P={kind:y.kind,id:y.id,layer:y.layer,pose:y.pose,data:y.data,parent:y.parent};t.nodes.set(y.id,P),p(y.id,y.parent,y.index),y.dependsOn!==void 0&&(P.dependsOn=y.dependsOn),Object.assign(P,ar(y)),e.noteWritten(P),i.add(y.id,y.dependsOn==="children"?[]:y.dependsOn??[]),u(y.id,y.dependsOn);let S=P,v=h.get(y);for(let A of o){let N=v?.get(A);if(N!==void 0){A.write(S,N);continue}let M=y[A.spec.opKey];M!==void 0&&Gc(A,S,M,"kit:add",It)}a(y.id)},revert:y=>{e.clearOverride(y.id),f(y.id),t.nodes.delete(y.id),i.remove(y.id),s.delete(y.id),l(y.parent),a(y.id)}}),g("kit:remove",{apply:y=>{for(let P of y.nodes)e.clearOverride(P.id);for(let P of y.detached)f(P.id);for(let P of y.nodes)t.nodes.delete(P.id),i.remove(P.id),s.delete(P.id);for(let P of y.detached)l(P.parent);e.narrowSelection(new Set(y.nodes.map(P=>P.id)))},revert:y=>{let P=new Map((y.fnKeys??[]).map(S=>[S.id,S]));for(let S of y.nodes){let v=S.children?{...S,children:[...S.children]}:{...S};m(v,P.get(S.id)),t.nodes.set(S.id,v),e.noteWritten(v),i.add(S.id,v.dependsOn==="children"?[]:v.dependsOn??[]),u(S.id,v.dependsOn)}for(let S of y.detached)p(S.id,S.parent,S.index);for(let S of y.detached)l(S.parent)}}),g("kit:setPose",{apply:y=>{d(y.id).pose=y.to,a(y.id)},revert:y=>{d(y.id).pose=y.from,a(y.id)}}),g("kit:setData",{apply:y=>{d(y.id).data=y.to,a(y.id)},revert:y=>{d(y.id).data=y.from,a(y.id)}}),g("kit:setLayer",{apply:y=>{n(y.to),d(y.id).layer=y.to,r(),a(y.id)},revert:y=>{d(y.id).layer=y.from,r(),a(y.id)}}),g("kit:setDependsOn",{apply:y=>{c(y.id,y.to)},revert:y=>{c(y.id,y.from)}});let x=new WeakMap;function w(y,P){let S=d(y.id),v=o.find(C=>C.spec.field==="layout"),A=x.get(y),N=P==="from"?y.fromKey:y.toKey;if(A===void 0&&N!==void 0){delete S.layout,Gc(v,S,N,"kit:setLayout",It);return}let M=A?.[P]??null;M===null?delete S.layout:v.write(S,M)}return g("kit:setLayout",{apply:y=>{w(y,"to")},revert:y=>{w(y,"from")}}),g("kit:move",{apply:y=>b(y.id,y.fromParent,y.toParent,y.toIndex),revert:y=>b(y.id,y.toParent,y.fromParent,y.fromIndex)}),pH(e),{layoutRefs:x}}function mH(e,t,n){n?e[t]=!0:delete e[t]}var yH={hidden:"kit:setHidden",locked:"kit:setLocked"};function gH(e){for(let n of["hidden","locked"])e.register(yH[n],{apply:r=>{let{id:o,to:i}=r,s=e.requireNode(o);mH(s,n,i),e.noteWritten(s),n==="hidden"&&e.invalidateDependents(o),i&&e.narrowSelection()},revert:r=>{let{id:o,from:i}=r,s=e.requireNode(o);mH(s,n,i),e.noteWritten(s),n==="hidden"&&e.invalidateDependents(o)}});let t=(n,r)=>(o,i)=>{let s=e.requireNode(o)[n]===!0;s!==i&&e.record(yH[n],{id:o,from:s,to:i},r)};return{setHidden:t("hidden","setHidden"),setLocked:t("locked","setLocked")}}function bH(e,t){function n(s){e.layers.length=0,e.layerIndex.clear(),t();for(let a of s){if(e.layerIndex.has(a.id))throw new Error(`Scene: duplicate ${a.kind} layer id "${a.id}"`);e.layerIndex.set(a.id,e.layers.length),e.layers.push(a)}}function r(s){let a=e.layerIndex.get(s);if(a===void 0)throw new Error(`Scene: unknown layer "${s}"`);return a}function o(){t(),e.layerIndex.clear();for(let s=0;s<e.layers.length;s++)e.layerIndex.set(e.layers[s].id,s)}function i(s,a,l,u,c="place"){if(r(a)<r(u)){let d=c==="place"?`cannot place node '${s??"<new>"}' on layer '${a}' under parent '${l}' on layer '${u}'`:`cannot setLayer('${s??"<new>"}', '${a}') \u2014 node has parent '${l}' on layer '${u}'`;throw new Error(`Scene: ${d} \u2014 a child may not render below its parent's layer`)}}return{reset:n,requireLayerIndex:r,rebuildLayerIndex:o,assertSubtreeLayer:i}}function WX(e,t,n,r){let o=new Map;for(let i=0;i<t.length;i++)o.set(t[i].id,i);for(let i of e.values()){if(i.parent===null)continue;let s=e.get(i.parent);if(s&&o.get(i.layer)<o.get(s.layer))throw new Error(`Scene: moveLayer("${n}", ${r}) \u2014 a child may not render below its parent's layer`)}}function xH(e){let{layers:t,nodes:n,requireLayerIndex:r,record:o}=e;function i(s,a){let l=t[r(s)];if(l.kind!=="user")throw new Error(`Scene: cannot ${a} system layer "${s}"`);return l}return{setLayerVisible(s,a){let l=t[r(s)];o("kit:setLayerVisible",{layer:s,from:l.visible,to:a},"setLayerVisible")},setLayerLocked(s,a){let l=t[r(s)];o("kit:setLayerLocked",{layer:s,from:l.locked,to:a},"setLayerLocked")},setLayerParallax(s,a){let l=t[r(s)];o("kit:setLayerParallax",{layer:s,from:l.parallax,to:a},"setLayerParallax")},addLayer(s){if(e.layerIndex.has(s.id))throw new Error(`Scene: duplicate layer id "${s.id}"`);let a=Math.max(0,Math.min(s.index??t.length,t.length)),l={kind:"user",id:s.id,name:s.name,visible:s.visible??!0,locked:s.locked??!1,...s.parallax?{parallax:s.parallax}:{},...s.annotation?{annotation:!0}:{}};o("kit:addLayer",{record:l,index:a},"addLayer")},removeLayer(s){let a=i(s,"remove");e.lifted(()=>e.batch("removeLayer",()=>{let l=[];for(let[u,c]of n)c.layer===s&&l.push(u);e.removeMany(l),o("kit:removeLayer",{record:a,index:r(s)},"removeLayer")}))},renameLayer(s,a){let l=i(s,"rename");o("kit:renameLayer",{layer:s,from:l.name,to:a},"renameLayer")},moveLayer(s,a){let l=r(s),u=Math.max(0,Math.min(a,t.length-1));if(l===u)return;let c=[...t],[d]=c.splice(l,1);c.splice(u,0,d),WX(n,c,s,a),o("kit:moveLayer",{layer:s,from:l,to:u},"moveLayer")}}}var Za=class extends Error{};function wH(e){let t=0,n=new WeakMap,r=a=>a===null||e.has(a),o=(a,l)=>{let u=e.get(a);return u===void 0||!qt(u)||u.children.every(c=>l?.has(c)===!0)};function i(a,l,u){switch(a){case"kit:add":{let c=l;return u?e.has(c.id)||!r(c.parent):!e.has(c.id)||!o(c.id)}case"kit:remove":{let c=l;if(!u)return c.nodes.some(f=>e.has(f.id))||!c.detached.every(f=>r(f.parent));let d=new Set(c.nodes.map(f=>f.id));return!c.nodes.every(f=>e.has(f.id)&&o(f.id,d))}case"kit:move":{let c=l;return!e.has(c.id)||!r(u?c.toParent:c.fromParent)}case"kit:setPose":case"kit:setData":case"kit:setLayer":case"kit:setDependsOn":case"kit:setLayout":case"kit:setUnits":case"kit:setClip":return!e.has(l.id);default:return!1}}function s(a,l,u){return t===0||typeof l!="object"||l===null?!1:n.get(l)===!u?n.delete(l):i(a,l,u)?(n.set(l,u),!0):!1}return{during(a){t++;try{return a()}finally{t--}},skips:s}}function VX(e,t,n,r){let o=e.map(a=>{let l=n.requireNode(a);return l.children?{...l,children:[...l.children]}:{...l}}),i=o.filter(a=>a.parent===null||!t.has(a.parent)).map(a=>({id:a.id,parent:a.parent,index:n.siblingsOf(a.parent).indexOf(a.id)})).sort((a,l)=>a.index-l.index),s=o.flatMap(a=>{let l=Ji(r,a,"opKey");return Object.keys(l).length===0?[]:[{id:a.id,...l}]});return{nodes:o,detached:i,...s.length>0?{fnKeys:s}:{}}}function PH(e){let{nodes:t,fnFields:n}=e,{requireNode:r,siblingsOf:o,descendants:i,removalClosure:s,patchNodeFunctions:a}=e.store,{refuse:l,refuseLayer:u}=e.locks,{requireLayerIndex:c,assertSubtreeLayer:d}=e.layers,{record:f,edit:p}=e.recorder,{noteArrival:h,noteDeparture:m,noteChange:g}=e.arrivals;function b(w){let y=w.id??e.generateId();if(t.has(y))throw new Za(`Scene: id collision on "${y}"`);c(w.layer),u(w.layer,"add to");let P=w.parent??null;if(P!==null){let v=r(P);d(w.id,w.layer,P,v.layer),l(P,"add under")}let S={id:y,kind:w.kind,layer:w.layer,pose:w.pose,data:w.data,parent:P,index:w.index??o(P).length};return w.dependsOn!==void 0&&(S.dependsOn=w.dependsOn),Object.assign(S,ar(w),Ji(n,w,"opKey"))}function x(w){if(w.length===0)return;let{ids:y,removing:P}=s(w);for(let A of y)l(A,"remove");let S=VX(y,P,e.store,n),{detached:v}=S;p("remove",v.some(A=>A.parent!==null),()=>{for(let A of v)m(A.id,A.parent,null);f("kit:remove",S,"remove")})}return{construct(w){e.locks.lifted(()=>{for(let y of w){let P=b(y);e.runOp("kit:add",P),a(y,P.id,null)}})},add(w){let y=b(w),P=`add ${w.kind}`;return p(P,y.parent!==null,()=>(h(y.id,y.parent,null),f("kit:add",y,P),a(w,y.id,y),y.id))},remove:w=>x([w]),removalClosure:w=>s(w).ids,removeMany:x,move(w,y,P){let S=r(w);if(l(w,"move"),y!==null){l(y,"move nodes into");let A=r(y);if(d(w,S.layer,y,A.layer),y===w)throw new Error("Scene: cannot parent a node to itself");let N=[];if(i(w,N),N.includes(y))throw new Error("Scene: cannot parent a node to its own descendant")}let v=S.parent;p("move",y!==null||v!==null,()=>{let A=o(v).indexOf(w),N=P??o(y).length;h(w,y,v),m(w,v,y),g(v),f("kit:move",{id:w,fromParent:v,fromIndex:A,toParent:y,toIndex:N},"move")})},reorder(w,y){let P=r(w);l(w,"reorder");let S=P.parent;p("reorder",S!==null,()=>{g(S);let v=o(S).indexOf(w);f("kit:move",{id:w,fromParent:S,fromIndex:v,toParent:S,toIndex:y},"reorder")})}}}function TH(e){let{state:t,store:n,locks:r,layers:o,fnFields:i,recorder:s,arrivals:a}=e,{layoutRefs:l}=hH({state:t,register:e.ops.register,store:n,requireLayerIndex:o.requireLayerIndex,rebuildLayerIndex:o.rebuildLayerIndex,invalidateOrder:e.invalidateOrder,fnFields:i,narrowSelection:e.narrowSelection,clearOverride:e.clearOverride,noteWritten:r.noteWritten}),{construct:u,...c}=PH({nodes:t.nodes,generateId:e.generateId,store:n,locks:r,layers:o,fnFields:i,runOp:e.ops.run,recorder:s,arrivals:a}),d=dH({store:n,locks:r,layers:o,recorder:s,arrivals:a,layoutFrame:e.layoutFrame,layoutField:i.find(g=>g.spec.field==="layout"),layoutRefs:l}),f=xH({layers:t.layers,layerIndex:t.layerIndex,nodes:t.nodes,requireLayerIndex:o.requireLayerIndex,record:s.record,lifted:r.lifted,batch:s.batch,removeMany:c.removeMany}),p=gH({register:e.ops.register,requireNode:n.requireNode,record:s.record,narrowSelection:()=>e.narrowSelection(),invalidateDependents:n.invalidateDependents,noteWritten:r.noteWritten}),h=aH({register:e.ops.register,requireNode:n.requireNode,refuse:r.refuse,record:s.record}),m=oH({values:t.docValues,register:e.ops.register,record:s.record});return{construct:u,methods:{...c,...d,...f,...p,...h,doc:m}}}var zX={log:e=>ih("history",e),warn:e=>It("history",e)};function SH(e,t={}){let n=t.rebuildOp;return Uc(e,{debug:zX,...t,rebuildOp:(r,o)=>n?.(r,o)??iy(r,o)})}function kH(e){let t=null;return{atomically(n,r){let o=t,i=[],s=e.getSelection();t=i;try{let a=n();return o&&!r()&&o.push(...i),a}catch(a){throw t=null,e.lifted(()=>{for(let l=i.length-1;l>=0;l--){let{kind:u,payload:c,reverted:d}=i[l],f=e.registered.get(u);(d?f.apply:f.revert)(c)}}),e.setSelection(s),i.length>0&&e.notify(),a}finally{t=o}},logApplied(n,r,o){t?.push(o===void 0?{kind:n,payload:r}:{kind:n,payload:r,reverted:o})}}}var KX=()=>({added:new Set,removed:new Set,posed:new Set,reparented:new Set,dataChanged:new Set,docChanged:new Set}),jX=e=>({added:new Set(e.added),removed:new Set(e.removed),posed:new Set(e.posed),reparented:new Set(e.reparented),dataChanged:new Set(e.dataChanged),docChanged:new Set(e.docChanged)}),vH={name:"editPass",args:{},elideNoop:!0,apply:()=>"noop",invert:()=>vH};function $X(e,t,n){let r=n;switch(t){case"kit:add":e.added.add(r.id);break;case"kit:remove":for(let o of r.nodes??[])e.removed.add(o.id);break;case"kit:setPose":e.posed.add(r.id);break;case"kit:setData":e.dataChanged.add(r.id);break;case"kit:setDoc":e.docChanged.add(r.key);break;case"kit:move":r.fromParent!==r.toParent&&e.reparented.add(r.id);break;default:break}}function AH(e){let t=[],n=null;function r(){let o=n;if(o===null)return 0;let i=0;try{for(let{pass:s}of[...t]){let a=s(jX(o));if(a===null)continue;let l=e.adapter();for(let u of a)u.apply(l),i++}}finally{n=null}return i}return{add(o,i){let s={pass:o,order:i?.order??0},a=t.findIndex(l=>l.order>s.order);return t.splice(a<0?t.length:a,0,s),()=>{let l=t.indexOf(s);l>=0&&t.splice(l,1)}},any:()=>t.length>0,open(){return n!==null||t.length===0?!1:(n=KX(),!0)},note(o,i){n!==null&&!e.untracked()&&$X(n,o,i)},run:r,abandon(){n=null},op(){return{name:"editPass",args:{},label:"Edit pass",elideNoop:!0,apply:()=>r()>0?void 0:"noop",invert:()=>vH}}}}function YX(e,t,n){let{replay:r,notify:o}=t,i={targetId:e.targetId,forkedAtEntryId:e.forkedAtEntryId,applyBatch(s,a){t.labeled(a,()=>t.runArrivalEdit(s,l=>{t.applying(()=>e.applyBatch(l.map(t.causing),a)),o()}))},undo(){r(()=>e.undo()),o()},redo(){r(()=>e.redo()),o()},canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),entries:()=>e.entries(),seal:()=>e.seal(),observe:s=>e.observe(s),beginJournal:s=>n.wrap(e.beginJournal(s)),getVersion:()=>e.getVersion(),subscribe:s=>e.subscribe(s),commit(s){e.commit(s),n.close(i),o()},cancel(){r(()=>e.cancel()),n.close(i),o()},suspend:()=>e.suspend(),isActive:()=>e.isActive()};return i}function RH(e){let t=new WeakMap,n=[],r={wrap(o){let i=YX(o,e,r);return t.set(i,o),n.push(i),i},close(o){let i=n.indexOf(o);i>=0&&n.splice(i,1)}};return{begin(o){let i=e.activeJournal();return r.wrap(i?(t.get(i)??i).beginJournal(o):e.engine.beginJournal(o))},resume:o=>e.engine.resumeJournal(t.get(o)??o),innermost(){for(let o=n.length-1;o>=0;o--)if(n[o].isActive())return n[o];return null}}}function IH(e){let{engine:t,replay:n,notify:r,refuseUntracked:o,runArrivalEdit:i}=e,s=RH(e);function a(d,f){return d()?(n(f),r(),!0):!1}let l=()=>e.activeJournal()??t,u={undo(){let d=e.activeJournal();return d?d.canUndo()?(d.undo(),!0):!1:a(()=>t.canUndo(),()=>t.undo())},redo(){let d=e.activeJournal();return d?d.canRedo()?(d.redo(),!0):!1:a(()=>t.canRedo(),()=>t.redo())},canUndo:()=>l().canUndo(),canRedo:()=>l().canRedo(),historyEntries(){let{undo:d,redo:f}=t.entries();return[...d,...f].map(p=>({id:String(p.id),label:p.label}))},historyIndex:()=>t.undoDepth(),jumpToHistoryIndex(d){let f=t.undoDepth()+t.redoDepth(),p=Math.max(0,Math.min(f,d));return a(()=>p!==t.undoDepth(),()=>t.goto(p))},serializeHistory:()=>({...t.serialize(),form:4}),restoreHistory(d){if(d.form!==4){It("scene","restoreHistory: snapshot is not in the current recorded form \u2014 dropped");return}t.restore(d),r()}};return{history:{apply(d,f){o("history.apply"),e.labeled(f??d.label??"",()=>i([d],p=>{let h=()=>p.length===1?t.apply(e.causing(d),f):t.applyOps(p.map(e.causing),f??d.label??"");e.applying(h),r()}))},applyOps(d,f){o("history.applyOps"),e.labeled(f,()=>i(d,p=>{e.applying(()=>t.applyOps(p.map(e.causing),f)),r()}))},undo:()=>{u.undo()},redo:()=>{u.redo()},goto:d=>{u.jumpToHistoryIndex(d)},clear(){t.clear(),r()},recordEntry(d,f,p){t.recordEntry(d,f,p),r()},prune(d){t.prune(d),r()},switchBranch(d){t.switchBranch(d),r()},restore:u.restoreHistory,canUndo:u.canUndo,canRedo:u.canRedo,undoDepth:()=>t.undoDepth(),redoDepth:()=>t.redoDepth(),entries:()=>t.entries(),timestampAt:d=>t.timestampAt(d),depthAt:d=>t.depthAt(d),branches:()=>t.branches(),getVersion:()=>t.getVersion(),subscribe:d=>t.subscribe(d),observe:d=>t.observe(d),serialize:u.serializeHistory,allForwardOps:()=>t.allForwardOps(),seal:()=>t.seal(),currentEntryId:()=>t.currentEntryId(),beginJournal:s.begin,resumeJournal:s.resume,activeJournal:()=>e.activeJournal()},methods:u,openJournal:s.innermost}}function EH(e){let t=new Map;function n(s){let a=t.get(s);if(!a)throw new Error(`Scene: no registered op for kind "${s}"`);return a}function r(s,a){let l;if(s.startsWith("kit:")){if(a===null||typeof a!="object")return;let u=a;l=typeof u.id=="string"?u.id:typeof u.layer=="string"?u.layer:void 0}else l=t.get(s)?.coalesceKey?.(a);return l===void 0?void 0:`${s}:${l}`}function o(s,a,l){let u=n(s);if(e.skips(s,a,l))return"noop";(l?u.apply:u.revert)(a),e.applied(s,a,!l)}function i(s,a,l=!0){return n(s),{name:s,args:a,coalesceKey:r(s,a),apply:()=>{if(e.driven())return o(s,a,l);let u;return e.replayAlone(()=>{u=o(s,a,l)}),u},invert:()=>i(s,a,!l)}}return{handlers:t,register:(s,a)=>{t.set(s,a)},run:(s,a)=>n(s).apply(a),op:(s,a)=>i(s,a)}}function Wc(e,t){return{name:e.name,args:e.args,label:e.label,get coalesceKey(){return e.coalesceKey},elideNoop:e.elideNoop,apply:()=>e.apply(t),invert:()=>Wc(e.invert(),t)}}function E1(e,t){return{name:e.name,args:e.args,label:e.label,get coalesceKey(){return e.coalesceKey},elideNoop:e.elideNoop,apply:()=>{let n=t();if(!n)return It("scene",`restored op "${e.name??"?"}" has no history adapter \u2014 skipping (setHistoryAdapter was not wired)`),"noop";try{return e.apply(n())}catch(r){return It("scene",`restored op "${e.name??"?"}" failed against the history adapter \u2014 skipping: ${String(r)}`),"noop"}},invert:()=>E1(e.invert(),t)}}function qX(e,t){let n=t===void 0||e.coalesceKey===void 0?void 0:`${t}>${e.coalesceKey}`;return{name:e.name,args:e.args,coalesceKey:n,apply:e.apply,invert:e.invert}}function MH(e){let t=null,n=e.getActiveJournal;function r(o,i=o){if(o.caused)return o;let s=[i];return{get name(){return o.name},get args(){return o.args},label:o.label,get coalesceKey(){return o.coalesceKey},elideNoop:o.elideNoop,apply(a){let{result:l,ops:u}=e.recorder().capturing(()=>i.apply(a));return u.length>0&&(s=u.map(c=>qX(c,o.coalesceKey))),l},caused:()=>s,invert:()=>i.invert()}}return{rebuild(o,i){let s=e.own(o,i);if(s!==null)return s;let a=iy(o,i);return a===null?null:E1(a,()=>t)},causing:o=>r(o),apply(o,i,s,a){if(e.recorder().joins())return e.recorder().join(i,a);let l=e.openJournal()??n?.()??null;e.driving(()=>{let u=i.map(c=>r(c,Wc(c,a)));l?l.applyBatch(u,s):o.applyOps(u,s)})},setHistoryAdapter(o){t=o},setActiveJournalAccessor(o){n=o},activeJournal:()=>e.openJournal()??n?.()??null}}function CH(e){for(let t=e.length-1;t>=0;t--)try{e[t].invert().apply(void 0)}catch{}}function OH(e){let{notifier:t,mode:n,engine:r,log:o,arrivals:i,passes:s}=e,a=null,l=null;function u(f,p,h=!1){let m=f();if(p)for(let g of i.settle())e.writePose(g.id,g.to);return h&&s.run(),m}function c(f,p,h={}){let m=!n.open();m&&(a={label:f,ops:[],outer:[],entry:{selectionBefore:e.selection(),...h}});let g=m&&i.open(!0),b=m&&s.open();return e.labeled(f,"call",()=>t.deferred(()=>n.during("batch",()=>{if(!m)return p();try{let x=o.atomically(()=>u(p,g,b),()=>(a?.ops.length??0)>0);return g&&i.emitReflow(),x}catch(x){throw CH(a?.outer??[]),a=null,x}}),()=>{if(g&&i.abandon(),b&&s.abandon(),!m||!a)return;let x=a;a=null,x.ops.length>0&&r.recordEntry(x.ops,x.label,x.entry)}))}function d(f,p,h){if(n.records()&&!a&&s.any())return void c(h,()=>d(f,p,h));s.note(f,p),e.labeled(h,"call",()=>{n.records()&&!a?n.during("own",()=>r.applyOps([e.makeOp(f,p)],h)):(e.runOp(f,p),o.logApplied(f,p),n.records()?a.ops.push(e.makeOp(f,p)):n.untracked()||l?.push(e.makeOp(f,p)))}),t.notify()}return{record:d,edit:(f,p,h)=>p&&i.bareLayoutEdit()?c(f,h):h(),batch:c,untracked(f){let p=t.version(),h=i.open(!0);return t.deferred(()=>n.during("untracked",()=>{let m=o.atomically(()=>u(f,h),()=>!1);return h&&i.emitReflow(),m}),()=>{h&&i.abandon(),t.version()!==p&&r.seal()})},joins:()=>n.records()&&a!==null,join(f,p){let h=a,m=h.ops.length,g=[];try{o.atomically(()=>{for(let b of f){let x=h.ops.length,w=b.apply(p);h.ops.length>x||w===!1||w==="noop"||(g.push(Wc(b,p)),h.ops.push(g[g.length-1]))}},()=>!1)}catch(b){throw CH(g),h.ops.length=m,b}h.outer.push(...g)},capturing(f){let p=l,h=[];l=h;try{return{result:f(),ops:h}}finally{l=p}},engineDriven:f=>n.during("engine",()=>t.muted(f))}}function FH(e){let{notifier:t,mode:n,stale:r,lifted:o,selection:i,arrivals:s,config:a,poseWrites:l}=e,{notify:u}=t,c=AH({adapter:e.passAdapter,untracked:n.untracked}),d=(M,C)=>s.runEdit(M,F=>{if(!c.open())return C(F);try{C([...F,c.op()])}finally{c.abandon()}}),f=EH({driven:n.open,replayAlone:M=>{P(M),u()},skips:r.skips,applied:(M,C,F)=>{n.records()||b(M,C,F)}}),p=MH({own:(M,C)=>f.handlers.has(M)?f.op(M,C):null,recorder:()=>x,driving:M=>t.deferred(()=>n.during("engine",()=>g(M,()=>!0))),getActiveJournal:a.getActiveJournal??null,openJournal:()=>N()}),h=SH(void 0,{selection:{get:i.get,set:M=>i.set(M)},...a.coalesceWindowMs!==void 0?{coalesceWindowMs:a.coalesceWindowMs}:{},...a.historyLimit!==void 0?{historyLimit:a.historyLimit}:{},rebuildOp:p.rebuild}),m=kH({registered:f.handlers,lifted:o,getSelection:i.get,setSelection:i.replace,notify:u}),{atomically:g,logApplied:b}=m,x=OH({notifier:t,mode:n,engine:h,runOp:f.run,makeOp:f.op,log:m,arrivals:s,passes:c,selection:i.get,writePose:e.writePose,labeled:l.labeled}),{record:w,engineDriven:y}=x;function P(M){l.replaying(()=>g(()=>o(()=>r.during(()=>y(M))),()=>!0))}function S(M){if(n.untracked())throw new Error(`Scene: cannot ${M} inside untracked() \u2014 it records`)}let{history:v,methods:A,openJournal:N}=IH({engine:h,applying:M=>g(()=>y(M),()=>!0),causing:p.causing,replay:P,notify:u,refuseUntracked:S,runArrivalEdit:d,labeled:(M,C)=>l.labeled(M,"ops",C),activeJournal:p.activeJournal});return{ops:f,recorder:x,clearHistory:()=>h.clear(),methods:{registerOp(M,C){if(M.startsWith("kit:"))throw new Error(`Scene: op kind "${M}" is reserved (kit:* prefix)`);f.register(M,C)},recordOp(M){w(M.kind,M.payload,M.kind)},applyBatch(M,C,F){return S("applyBatch"),l.labeled(C,"ops",()=>d(M,B=>p.apply(h,B,C,F)))},history:v,...A,batch:x.batch,untracked:x.untracked,setActiveJournalAccessor:p.setActiveJournalAccessor,setHistoryAdapter:p.setHistoryAdapter,addEditPass:c.add}}}function LH(e,t){let n=s=>Cc(e(s),t),r=[],o=0,i=Me();return{get:()=>r,legal:n,set(s){r=n(s),o++,i.emit()},narrow(s){let a=s!==void 0&&r.some(l=>s.has(l))?r.filter(l=>!s.has(l)):r;r=n(a)},replace(s){r=s},subscribe:i.subscribe,changes:()=>o}}function _H(e){let t=0,n=!1,r={get layers(){return e.layers},get:i=>e.nodes.get(i)},o=i=>(n||e.layers.some(s=>s.locked))&&DB(r,i);return{isLocked:o,isHidden:i=>_B(r,i),refuse(i,s){if(!(t>0||!o(i)))throw new Error(`Scene: cannot ${s} "${i}" \u2014 it is locked`)},refuseLayer(i,s){if(!(t>0||!e.layers[e.layerIndex.get(i)??-1]?.locked))throw new Error(`Scene: cannot ${s} layer "${i}" \u2014 it is locked`)},reachable(i){if(i.length===0)return i;let s=qa(r);return i.some(a=>s.locked(a)||s.hidden(a))?i.filter(a=>!s.locked(a)&&!s.hidden(a)):i},noteWritten(i){i.locked===!0&&(n=!0)},lifted(i){t++;try{return i()}finally{t--}}}}function DH(e,t,n){let r=d2(),o=new Set;function i(x){if(s(e.nodes.get(x)?.parent??null),r.isEmpty())return;let w=[x];p(x,w);for(let y of w)for(let P of r.transitiveDependentsOf(y)){let S=e.nodes.get(P);S!==void 0&&un(S)}}function s(x){if(o.size===0)return;let w=x;for(;w!==null;){let y=e.nodes.get(w);if(y===void 0)return;if(o.has(w)){un(y);for(let P of r.transitiveDependentsOf(w)){let S=e.nodes.get(P);S!==void 0&&un(S)}}w=y.parent}}function a(x,w){w==="children"?o.add(x):o.delete(x)}function l(x,w){let y=u(x);w===void 0?delete y.dependsOn:y.dependsOn=w,r.add(x,w===void 0||w==="children"?[]:w),a(x,w),un(u(x)),i(x)}function u(x){let w=e.nodes.get(x);if(!w)throw new Za(`Scene: unknown node id "${x}"`);return w}function c(x){if(x===null)return e.roots;let w=u(x);return w.children??=[]}function d(x){let w=u(x),y=c(w.parent),P=y.indexOf(x);if(P<0)throw new Error(`Scene: node "${x}" not found in its parent's children`);return y.splice(P,1),t(),{parent:w.parent,index:P}}function f(x,w,y){let P=c(w),S=Math.max(0,Math.min(y,P.length));P.splice(S,0,x);let v=u(x);v.parent=w,t()}function p(x,w){let y=e.nodes.get(x);if(y?.children)for(let P of y.children)w.push(P),p(P,w)}function h(x){let w=[],y=new Set;function P(S){if(y.has(S))return;y.add(S),w.push(S);let v=[];p(S,v);for(let A of v)y.has(A)||(y.add(A),w.push(A))}for(let S of x)P(S);for(let S=0;S<w.length;S++)for(let v of r.transitiveDependentsOf(w[S]))P(v);return{ids:w,removing:y}}let m=new WeakMap;function g(x,w,y){let P=e.nodes.get(w);if(P===void 0)return;let S=new Map;for(let v of n){let A=x[v.spec.field];A!==void 0&&(v.write(P,A),S.set(v,A))}y&&S.size>0&&m.set(y,S)}function b(x,w){if(!w)return;let y=x;for(let P of n){if(P.read(y)!==void 0)continue;let S=w[P.spec.opKey];S!==void 0&&Gc(P,y,S,"kit:remove",It)}}return{dependents:r,childDerived:o,invalidateDependents:i,invalidateChildDerivedFrom:s,trackChildDerived:a,retarget:l,requireNode:u,siblingsOf:c,detach:d,attach:f,descendants:p,removalClosure:h,addedFns:m,patchNodeFunctions:g,restoreNodeFunctions:b}}function BH(e){function t(){return e.layers.length===1?l():c()}function n(){return e.layers.length===1?u():d()}let r=0,o={gen:0};function i(){r++}let s=[];function a(){return o.gen!==r&&(o={gen:r}),o}function l(){let f=e.layers[0].id,p=[],h=[...e.roots].reverse();for(;h.length>0;){let m=h.pop(),g=e.nodes.get(m);if(g&&(g.layer===f&&p.push(m),qt(g)))for(let b=g.children.length-1;b>=0;b--)h.push(g.children[b])}return p}function u(){let f=e.layers[0].id,p=[],h=[...e.roots].reverse();for(;h.length>0;){let m=h.pop(),g=e.nodes.get(m);if(g&&(g.layer===f&&p.push(g),qt(g)))for(let b=g.children.length-1;b>=0;b--)h.push(g.children[b])}return p}function c(){let f=e.layers.map(()=>[]),p=[...e.roots].reverse();for(;p.length>0;){let m=p.pop(),g=e.nodes.get(m);if(!g)continue;let b=f[e.layerIndex.get(g.layer)??-1];if(b&&b.push(m),qt(g))for(let x=g.children.length-1;x>=0;x--)p.push(g.children[x])}let h=[];for(let m of f)for(let g of m)h.push(g);return h}function d(){let f=e.layers.map(()=>[]),p=[...e.roots].reverse();for(;p.length>0;){let m=p.pop(),g=e.nodes.get(m);if(!g)continue;let b=f[e.layerIndex.get(g.layer)??-1];if(b&&b.push(g),qt(g))for(let x=g.children.length-1;x>=0;x--)p.push(g.children[x])}let h=[];for(let m of f)for(let g of m)h.push(g);return h}return{ids(){let f=a();return f.ids??=t()},nodes(){let f=a();return f.nodes??=n()},nodesOnLayer(f){let p=a(),h=p.byLayer;if(!h){h=new Map;for(let m of p.nodes??=n()){let g=h.get(m.layer);g||h.set(m.layer,g=[]),g.push(m)}p.byLayer=h}return h.get(f)??s},invalidate:i}}function HH(e,t){let n=[],r=[...e].reverse();for(;r.length>0;){let o=t.get(r.pop());if(o&&(n.push(o),qt(o)))for(let i=o.children.length-1;i>=0;i--)r.push(o.children[i])}return n}function M1(e,t){let n=new Map;for(let o of e)o.id!==void 0&&n.set(o.id,o);let r=o=>{let i=new Set,s=o.parent==null?void 0:n.get(o.parent);for(;s!==void 0&&s.id!==void 0&&!i.has(s.id);){if(lt(s))return s;i.add(s.id),s=s.parent==null?void 0:n.get(s.parent)}return null};return e.map(o=>{let i=r(o);return i===null?o:{...o,pose:t.decompose(i.pose,o.pose)}})}function O1(e){let t={id:e.id,visible:e.visible??!0,locked:e.locked??!1,...e.parallax?{parallax:e.parallax}:{},...e.annotation?{annotation:!0}:{}};return e.kind==="user"?{...t,kind:"user",name:e.name??e.id}:{...t,kind:"system"}}function GH(e,t,n){let r=[];for(let i of HH(e.roots,e.nodes)){let s=i.id,a={id:s,kind:i.kind,layer:i.layer,pose:i.pose,data:i.data};i.parent!=null&&(a.parent=i.parent),i.dependsOn==="children"?a.dependsOn="children":i.dependsOn&&i.dependsOn.length>0&&(a.dependsOn=i.dependsOn),i.pickable===!1&&(a.pickable=!1),i.hidden===!0&&(a.hidden=!0),i.locked===!0&&(a.locked=!0),i.units!==void 0&&(a.units=i.units),i.clip!==void 0&&(a.clip=i.clip),i.consumesChildren===!0&&(a.consumesChildren=!0),Object.assign(a,Ji(t,i,"jsonKey",l=>{throw new Error(`Scene.toJSON: node '${s}' has ${l.spec.field} but no matching registry key. The function must be registered via createScene's registry option to round-trip.`)})),r.push(a)}return{version:3,systemLayers:e.layers.map(i=>{let s={id:i.id};return i.visible===!1&&(s.visible=!1),i.locked===!0&&(s.locked=!0),i.parallax&&(s.parallax=i.parallax),i.annotation&&(s.annotation=!0),i.kind==="user"&&(s.kind="user",s.name=i.name),s}),nodes:r,...n?{doc:n}:{}}}function uy(e,t,n={}){let r=XX(e,t,n);return e.version===3?r:M1(r,n.composition??sh)}function XX(e,t,n){let r;if(e.version===1)r=e.nodes.map(o=>({n:o,kind:C1(1,o,n.classifyV1)}));else if(e.version===2||e.version===3)r=e.nodes.map(o=>({n:o,kind:C1(2,o)}));else throw new Error(`Scene: unsupported version ${String(Reflect.get(e,"version"))}; versions 1, 2 and 3 are supported`);return r.map(({n:o,kind:i})=>{let s={id:o.id,kind:i,layer:o.layer,pose:o.pose,data:o.data};o.parent!==void 0&&(s.parent=o.parent),o.pickable!==void 0&&(s.pickable=o.pickable),o.hidden===!0&&(s.hidden=!0),o.locked===!0&&(s.locked=!0),o.units!==void 0&&(s.units=o.units),o.clip!==void 0&&(s.clip=o.clip),o.consumesChildren===!0&&(s.consumesChildren=!0),o.dependsOn!==void 0&&(s.dependsOn=o.dependsOn==="children"?"children":o.dependsOn);let a=o;for(let l of Xa){let u=a[l.jsonKey];if(u===void 0)continue;let c=t[l.field]?.[u];if(!c&&n.unknownKeys==="skip"){n.onSkip?.({id:s.id,field:l.field,key:u});continue}if(!c)throw new Error(`Scene: unknown ${l.field} key '${u}'. Register a function with this key in the registry option.`);s[l.field]=c}return JX(e.version,s)&&(s.clip="outline"),s})}function JX(e,t){return e===1&&t.kind==="group"&&t.clipFromPose===void 0}function C1(e,t,n){return e===2?t.kind:t.kind==="leaf"?"mark":n?n(t):"group"}function UH(e){let t=new WeakMap,n=1;return{get:r=>e.get(r),incarnation(r){let o=e.get(r);if(!o)return;let i=t.get(o);return i===void 0&&(i=n++,t.set(o,i)),i},childrenOf(r){return e.get(r)?.children??[]},ancestorsOf(r){let o=[],i=e.get(r)?.parent??null;for(;i!==null;)o.push(i),i=e.get(i)?.parent??null;return o}}}function WH(e,t,n,r){let o={nodes:new Map,roots:[],layers:[],layerIndex:new Map,docValues:new Map},i=BH(o),s=ny(e,f=>{f==="layout"&&n()}),a=DH(o,i.invalidate,s),l=bH(o,i.invalidate);l.reset(t);let u=_H(o),c=rH(o.docValues);c.reset(r);let d={...UH(o.nodes),renderOrder:i.ids,renderOrderNodes:i.nodes,nodesOnLayer:i.nodesOnLayer,isLocked:f=>u.isLocked(f),isHidden:f=>u.isHidden(f),layoutOf(f){return o.nodes.get(f)?.layout??null},toJSON:()=>GH(o,s,c.toJSON())};return{state:o,order:i,locks:u,stale:wH(o.nodes),fnFields:s,store:a,layers:l,reads:d,docValues:c,reset(f,p){c.reset(p),a.dependents.clear(),a.childDerived.clear(),o.nodes.clear(),o.roots.length=0,l.reset(f)}}}function QX(e,t){let n=e.get(t);return n&&{node:n,pose:Xn(e,n)}}var ZX=0,e9=()=>ue(`n${(ZX++).toString(36)}-${Math.random().toString(36).slice(2,8)}`);function t9(e,t){return()=>{for(let n=0;n<1e3;n++){let r=e();if(!t(r))return r}throw new Error("scene: generateId gave 1000 ids the scene already holds")}}function n9(e,t,n,r){if(t.length===0)throw new Error("Scene: systemLayers must declare at least one layer");let o=M3(e.registry??{}),i=WH(o,t,()=>h.layoutDeclared(),r),{state:s,locks:a,reads:l}=i,u=J3(),c=tH(),d=eH({untracked:c.untracked,changes:u,shown:v=>QX(P,v)}),f=(v,A)=>d.layout(()=>P.setPose(ue(v),A)),p=uH(e.layoutFrame),h=X3({nodes:s.nodes,layoutPass:(v,A,N)=>cH(P,l.layoutOf,v,A,p,N),recordsBareEdits:()=>!c.open(),writePose:f}),m=t9(e.generateId??e9,v=>s.nodes.has(v)),g=LH(a.reachable,v=>s.nodes.get(v)?.parent);g.subscribe(u.notify);let b=R1(v=>s.nodes.get(v),i.store.invalidateDependents),x=R2(),w=FH({notifier:u,mode:c,passAdapter:()=>({...oy(P),...ZB(P)}),stale:i.stale,lifted:a.lifted,selection:g,arrivals:h,writePose:f,poseWrites:d,config:e}),y=TH({state:s,store:i.store,locks:a,layers:i.layers,invalidateOrder:i.order.invalidate,fnFields:i.fnFields,ops:{...w.ops,register:d.reporting(w.ops.register)},recorder:w.recorder,arrivals:h,layoutFrame:p,generateId:m,narrowSelection:g.narrow,clearOverride:b.clear});for(let[v,A]of Object.entries(e.ops??{}))w.ops.register(v,A);let P={get nodes(){return s.nodes},get roots(){return s.roots},get layers(){return s.layers},registry:o,...l,mintId:m,composition:e.composition??sh,...y.methods,...w.methods,unlocked:v=>a.lifted(v),setArrivalHandler:h.setHandler,onReflow:h.onReflow,onPoseWrite:d.subscribe,overrides:b,scroll:x,getSelection:g.get,setSelection:v=>g.set([...v]),loadState(v,A){let N=uy(v,o,{composition:P.composition,...A});if(c.open())throw new Error("Scene: cannot loadState inside another edit \u2014 it replaces the state that edit would revert to");b.clearAll(),x.clearAll(),i.reset(v.systemLayers.map(O1),v.doc),w.clearHistory(),d.quiet(()=>y.construct(N)),g.replace(g.legal(g.get().filter(M=>s.nodes.has(M)))),u.notify()},...Q3(u,g)},S=n(o);return S&&(d.quiet(()=>y.construct(S)),u.notify()),P}function cy(e,t={}){return n9(t,e.systemLayers.map(O1),n=>uy(e,n,t),e.doc)}Z();var VH="__weaselHeadless";function zH(e){return zg(e)}var o9=g1();function KH(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}async function i9(e){let{scene:t,screen:n,format:r,overlay:o,...i}=e,s={...i,scene:cy(zH(t)),...o?{overlay:o}:{},...n?{screen:Float64Array.from(n)}:{}};await b1({render:s});let a=o9.render(s);if(r==="png"){let u=await x1(a);return{width:a.width,height:a.height,base64:KH(new Uint8Array(await u.arrayBuffer()))}}let l=new Uint8Array(a.data.buffer,a.data.byteOffset,a.data.byteLength);return{width:a.width,height:a.height,base64:KH(l)}}var s9={render:i9};globalThis[VH]=s9;})();
431
431
  /*! Bundled license information:
432
432
 
433
433
  polygon-clipping/dist/polygon-clipping.umd.js: