@weasel-js/headless 1.15.1 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/page.global.js
CHANGED
|
@@ -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 dG=Object.create;var Oy=Object.defineProperty;var fG=Object.getOwnPropertyDescriptor;var pG=Object.getOwnPropertyNames;var hG=Object.getPrototypeOf,mG=Object.prototype.hasOwnProperty;var J=(e,t)=>()=>(e&&(t=e(e=0)),t);var yG=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),gG=(e,t)=>{for(var n in t)Oy(e,n,{get:t[n],enumerable:!0})},bG=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pG(t))!mG.call(e,o)&&o!==n&&Oy(e,o,{get:()=>t[o],enumerable:!(r=fG(t,o))||r.enumerable});return e};var xG=(e,t,n)=>(n=e!=null?dG(hG(e)):{},bG(t||!e||!e.__esModule?Oy(n,"default",{value:e,enumerable:!0}):n,e));function ys(e){return e<0?0:e>1?1:e}function pr(e,t,n){return e+(t-e)*n}function gs(e){return e>0?1:e<0?-1:0}var kl=J(()=>{"use strict"});var eee,Un,sU,hg=J(()=>{"use strict";eee=Math.PI*2,Un=Math.PI/180,sU=180/Math.PI});function Fd(e,t){return[1,0,0,1,e,t]}function vl(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 hr(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 mr(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 ao(e,t,n){return ht(Fd(e,t),ht(vl(n),Fd(-e,-t)))}function mg(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 bs=J(()=>{"use strict"});function Ld(e,t){return t[0]>=e[0]&&t[1]>=e[1]&&t[2]<=e[2]&&t[3]<=e[3]}function Al(e,t,n,r){return Float64Array.of(e,t,e+n,t,e+n,t+r,e,t+r)}function yg(e,t){return e[0]<=t[2]&&t[0]<=e[2]&&e[1]<=t[3]&&t[1]<=e[3]}var Rl=J(()=>{"use strict"});function aU(){let e=[];for(let{code:t,coords:n}of Object.values(ii))e[t]=n;return e}function lo(e){return Rk[e]}function Oe(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!==se&&c!==fe;if(d&&(s=o,a=i),l=c!==fe,n(c,r,o,i,u,d)===!1)return;let f=lo(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===se&&(s=o,a=i)):c===fe&&(o=s,i=a)}}var ii,se,ae,be,we,fe,Rk,Ye=J(()=>{"use strict";ii={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}},se=ii.M.code,ae=ii.L.code,be=ii.C.code,we=ii.Q.code,fe=ii.Z.code,Rk=aU()});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 uo(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 Nk(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 gg(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 Nk(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 Nk(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 co(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,y=c+(f-c)*l,b=d+(p-d)*l,x=f+(h-f)*l,w=m+(b-m)*l,g=y+(x-y)*l;return[[e,t,u,c,m,y,w,g],[w,g,b,x,p,h,s,a]]}function Ik(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=J(()=>{"use strict"});function Ek(e,t){if(!(t>0))return 0;let n=e/t;return n<0?0:n>1?1:n}var Mk=J(()=>{"use strict"});function lU(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function Gt(e,t){return Math.sqrt(lU(e,t))}function si(e,t,n){return{x:pr(e.x,t.x,n),y:pr(e.y,t.y,n)}}function bg(e,t,n,r,o,i){let s=o-n,a=i-r;return Ek((e-n)*s+(t-r)*a,s*s+a*a)}function uU(e,t,n,r,o,i){let s=bg(e,t,n,r,o,i),a=e-(s===1?o:pr(n,o,s)),l=t-(s===1?i:pr(r,i,s));return a*a+l*l}function Tn(e,t,n,r,o,i){return Math.sqrt(uU(e,t,n,r,o,i))}var ai=J(()=>{"use strict";Mk();kl()});function Nl(e,t,n,r,o,i){let s=bg(e,t,n,r,o,i),a=s===1?o:pr(n,o,s),l=s===1?i:pr(r,i,s);return{x:a,y:l,t:s,dist:Math.sqrt((e-a)*(e-a)+(t-l)*(t-l))}}function li(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),y=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<=fo;S++)b.push(y(S/fo));let x=0,w=b[0];for(let S=0;S<=fo;S++){let v=b[S],A=S>0?b[S-1]:1/0,N=S<fo?b[S+1]:1/0;if(!(v<=A&&v<=N))continue;let M=Math.max(0,(S-1)/fo),C=Math.min(1,(S+1)/fo),F=S/fo;for(let W=0;W<cU;W++){let Q=F*F,le=c*Q*F+f*Q+h*F+n-e,ke=d*Q*F+p*Q+m*F+r-t,ue=3*c*Q+2*f*F+h,ve=3*d*Q+2*p*F+m,G=6*c*F+2*f,j=6*d*F+2*p,$=le*ue+ke*ve,ee=ue*ue+ve*ve+le*G+ke*j;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<Ck||C-M<Ck)break}let D=y(F),[B,K]=D<=v?[F,D]:[S/fo,v];K<w&&(w=K,x=B)}let[g,P]=Ve(n,r,o,i,s,a,l,u,x);return{x:g,y:P,t:x,dist:Math.hypot(g-e,P-t)}}function Ok(e,t,n,r,o,i,s,a){let[l,u,c,d]=uo(n,r,o,i,s,a);return li(e,t,n,r,l,u,c,d,s,a)}var fo,cU,Ck,_d=J(()=>{"use strict";Pn();ai();kl();fo=32,cU=40,Ck=1e-14});function Il(e,t,n){let r=e.length/t-1,o=1-n,i=0;for(let s=0;s<t;s++){let a=e[t+s]-e[s],l=r===1?a:r===2?2*(o*a+n*(e[2*t+s]-e[t+s])):3*(o*o*a+2*o*n*(e[2*t+s]-e[t+s])+n*n*(e[3*t+s]-e[2*t+s]));i+=l*l}return Math.sqrt(i)}function Dd(e,t,n,r,o,i){let s=(n+r)/2,a=(r-n)/2,l=0;for(let u=0;u<o.length;u++)l+=i[u]*Il(e,t,s+o[u]*a);return l*a}function Tg(e,t,n,r,o,i,s){let a=(n+r)/2,l=Dd(e,t,n,a,wg,Pg),u=Dd(e,t,a,r,wg,Pg);return s>=20||!(Math.abs(l+u-o)>i)?l+u:Tg(e,t,n,a,l,i,s+1)+Tg(e,t,a,r,u,i,s+1)}function Sg(e,t){let n=0;for(let r=t;r<e.length;r+=t){let o=0;for(let i=0;i<t;i++)o+=(e[r+i]-e[r-t+i])**2;n+=Math.sqrt(o)}return n}function Fk(e){for(let t=0;t<e.length;t++)if(!Number.isFinite(e[t]))return!1;return!0}function gU(e,t,n,r){let o=e.length/t-1,i=[],s=a=>{a>n&&a<r&&i.push(a)};for(let a=0;a<t;a++){let l=e[t+a]-e[a],u=e[2*t+a]-e[t+a];if(o===2){l!==u&&s(l/(l-u));continue}let c=e[3*t+a]-e[2*t+a],d=l-2*u+c,f=2*(u-l),p=l;if(Math.abs(d)<=1e-12*(Math.abs(f)+Math.abs(p))){f!==0&&s(-p/f);continue}let h=f*f-4*d*p;if(h<0)continue;let m=-(f+Math.sign(f||1)*Math.sqrt(h))/2;s(m/d),m!==0&&s(p/m)}return i.sort((a,l)=>a-l),i.filter((a,l)=>l===0||a!==i[l-1])}function xg(e,t,n,r,o,i){if(!(r>n))return 0;let s=Dd(e,t,n,r,wg,Pg);return!i&&!(Math.abs(s-Dd(e,t,n,r,dU,fU))>pU*o)?s:Tg(e,t,n,r,s,yU*o,0)}function po(e,t,n=0,r=1){if(!Fk(e))return NaN;if(e.length===2*t)return Il(e,t,0)*(r-n);let o=Sg(e,t);return Bd(e,t,n,r,o,kg(e,t))}function bU(e,t,n){let r=e.length/t-1,o=0;for(let i=0;i<t;i++){let s=e[2*t+i]-2*e[t+i]+e[i],a=r===2?2*s:6*((1-n)*s+n*(e[3*t+i]-2*e[2*t+i]+e[t+i]));o+=a*a}return Math.sqrt(o)}function kg(e,t){return gU(e,t,0,1).map(n=>{let r=bU(e,t,n);return{t:n,width:r>0?Il(e,t,n)/r:1/0}})}function xU(e,t){let n=[];for(let r of e)r.width<hU*t&&n.push(r.t);return n}function Bd(e,t,n,r,o,i,s=8){let a=(r-n)/s,l=s-1,u=0,c=xU(i,a);if(c.length===0){for(let p=0;p<s;p++)u+=xg(e,t,n+p*a,p===l?r:n+(p+1)*a,o,!1);return u}let d=p=>c.some(h=>Math.abs(h-p)<=mU*a),f=0;for(;f<c.length&&c[f]<=n;)f++;for(let p=0;p<s;p++){let h=n+p*a,m=p===l?r:h+a,y=h;for(;f<c.length&&c[f]<m;)u+=xg(e,t,y,c[f],o,!0),y=c[f++];u+=xg(e,t,y,m,o,d(y)||d(m))}return u}function Lk(e,t,n,r=po(e,t)){if(n<=0||!(r>0)||!Number.isFinite(r))return 0;if(n>=r)return 1;if(e.length===2*t)return n/r;let o=Sg(e,t),i=kg(e,t),s=0,a=1,l=n/r;for(let u=0;u<30;u++){let c=Bd(e,t,0,l,o,i)-n;if(Math.abs(c)<1e-10*r)break;c>0?a=l:s=l;let d=Il(e,t,l),f=d>0?l-c/d:NaN;f>s&&f<a||(f=(s+a)/2),l=f}return l}function _k(e,t){let n=Sg(e,t),r=Fk(e)?kg(e,t):[],o=new Float64Array(yr+1);for(let i=0;i<yr;i++)o[i+1]=o[i]+Bd(e,t,i/yr,(i+1)/yr,n,r,1);return{s:o,size:n,dips:r}}function Dk(e,t,n,r){let{s:o}=n,i=o[yr];if(r<=0||!(i>0)||!Number.isFinite(i))return 0;if(r>=i)return 1;let s=0,a=yr-1;for(;s<a;){let p=s+a+1>>1;o[p]<=r?s=p:a=p-1}let l=s/yr,u=l,c=(s+1)/yr,d=o[s+1]-o[s],f=d>0?l+(r-o[s])/d/yr:l;for(let p=0;p<30;p++){let h=o[s]+Bd(e,t,l,f,n.size,n.dips,1)-r;if(Math.abs(h)<1e-10*i)break;h>0?c=f:u=f;let m=Il(e,t,f),y=m>0?f-h/m:NaN;y>u&&y<c||(y=(u+c)/2),f=y}return f}var wg,Pg,dU,fU,pU,hU,mU,yU,yr,El=J(()=>{"use strict";wg=[-.9602898564975363,-.7966664774136267,-.525532409916329,-.1834346424956498,.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],Pg=[.1012285362903763,.2223810344533745,.3137066458778873,.362683783378362,.362683783378362,.3137066458778873,.2223810344533745,.1012285362903763],dU=[-.8611363115940526,-.3399810435848563,.3399810435848563,.8611363115940526],fU=[.3478548451374538,.6521451548625461,.6521451548625461,.3478548451374538],pU=1e-9,hU=1,mU=.05,yU=1e-13;yr=16});function Bk(e,t,n){let r=e.length/t-1,o=1-n,i=r===1?[o,n]:r===2?[o*o,2*o*n,n*n]:[o*o*o,3*o*o*n,3*o*n*n,n*n*n],s=[0,0,0];for(let a=0;a<t;a++){let l=0;for(let u=0;u<=r;u++)l+=i[u]*e[u*t+a];s[a]=l}return s}function Ml(e,t,n,r){let o=Math.floor(e.length/n),i=r*n,s=(r+1)%o*n,a=[];for(let l=0;l<n;l++)a.push(e[i+l]);if(t)for(let l=0;l<t.length;l++)a.push(t[l]);for(let l=0;l<n;l++)a.push(e[s+l]);return a}var vg=J(()=>{"use strict"});function Gd(e,t,n){let r=new Float64Array(e.length+1),o=[],i=0;e.forEach((l,u)=>{let c=wU(l,t,i);o.push(c),i=c[c.length-1],r[u+1]=i});let s=PU(e,t,o,n??null),a={dim:t,runs:e,total:i,runStart:r,segments:s.segments};return a[Hk]={cum:o,...s,arcs:e.map(()=>[])},a}function Gk(e,t,n){let r=e.runs[t].controls?.[n];if(!r||r.length===0)return null;let o=Cl(e).arcs[t],i=o[n];if(!i){let s=Ml(e.runs[t].points,r,e.dim,n);o[n]=i={coords:s,lookup:_k(s,e.dim)}}return i}function Cl(e){let t=e[Hk];if(!t)throw new Error("LengthTable: not built by lengthTable(); build one with it rather than by hand");return t}function Ud(e,t){if(Number.isNaN(t))return NaN;let{bpAnchor:n,bpLength:r}=Cl(e),o=n.length;if(o===0)return 0;if(t<=n[0])return r[0];if(t>=n[o-1])return r[o-1];let i=0,s=o-1;for(;s-i>1;){let u=i+s>>1;n[u]<=t?i=u:s=u}let a=n[s]-n[i],l=a>0?(t-n[i])/a:1;return r[i]+l*(r[s]-r[i])}function Ag(e,t){if(Number.isNaN(t))return NaN;let n=e.runs.length,r=Math.min(Math.max(t,0),n),o=Math.floor(r);return o>=n?e.total:e.runStart[o]+(r-o)*(e.runStart[o+1]-e.runStart[o])}function Rg(e,t){if(Number.isNaN(t))return NaN;let n=Math.min(Math.max(t,0),1);if(e.segments<=0)return n*e.total;let{runAnchor:r}=Cl(e),o=n*e.segments;for(let i=0;i<r.length/2;i++){let s=r[i*2],a=r[i*2+1]-s;if(a>0&&o<=a)return Ud(e,s+o);o-=Math.max(a,0)}return e.total}function wU(e,t,n){let r=e.points,o=Math.floor(r.length/t),i=Hd(e,o),s=new Float64Array(Math.max(o+(i?1:0),1));s[0]=n;for(let a=1;a<s.length;a++){let l=e.controls?.[a-1];if(l&&l.length>0){let f=po(Ml(r,l,t,a-1),t);s[a]=s[a-1]+(Number.isFinite(f)?f:0);continue}let u=(a-1)*t,c=a%o*t,d=0;for(let f=0;f<t;f++)d+=(r[c+f]-r[u+f])**2;s[a]=s[a-1]+Math.sqrt(d)}return s}function PU(e,t,n,r){let o=[],i=[],s=new Float64Array(e.length*2),a=0,l=0;return e.forEach((u,c)=>{let d=Math.floor(u.points.length/t),f=n[c],p=TU(u,d,f,l);l+=d;let h=SU(p,r,Hd(u,d));if(h.ids.length===0)return;let m=h.ids[0],y=h.ids[h.ids.length-1];Hd(u,d)&&(y+=1,h.ids.push(y),h.lens.push(f[f.length-1])),s[c*2]=m,s[c*2+1]=y,a+=y-m,o.push(...h.ids),i.push(...h.lens)}),{bpAnchor:Float64Array.from(o),bpLength:Float64Array.from(i),runAnchor:s,segments:a}}function TU(e,t,n,r){let o=[],i=[],{anchorA:s,anchorB:a}=e;if(!s||!a){for(let u=0;u<t;u++)o.push(r+u),i.push(n[u]);return{ids:o,lens:i}}for(let u=0;u<t;u++)s[u]===a[u]&&(o.push(s[u]),i.push(n[u]));let l=Uk(e,t);return l!==void 0&&(o.push(l),i.push(n[t])),{ids:o,lens:i}}function Ol(e,t=2){return Uk(e,Math.floor(e.points.length/t))}function Uk(e,t){let{anchorA:n,anchorB:r}=e;if(Hd(e,t))return e.closeAnchor!==void 0?e.closeAnchor:n&&r&&n[t-1]!==r[t-1]?r[t-1]:void 0}function SU(e,t,n){let r=[],o=[],i=0,s=0,a=()=>{r.length>o.length&&o.push((i+s)/2)};for(let l=0;l<e.ids.length;l++){let u=t?t[e.ids[l]]??e.ids[l]:e.ids[l],c=e.lens[l];if(!(n&&r.length>0&&u===r[0])){if(r.length>0&&u===r[r.length-1]){s=c;continue}a(),r.push(u),i=c,s=c}}return a(),{ids:r,lens:o}}var Hk,Hd,Wd=J(()=>{"use strict";El();vg();Hk=Symbol("lengthTable.internals");Hd=(e,t)=>e.closed&&(t>=2||t===1&&(e.controls?.[0]?.length??0)>0)});function qe(e){return e.origin?Wk(e,Float64Array.from(e.coords)):e.coords}function Wk(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>=Vk)||!Number.isFinite(i)))return{x:Math.round((t+r)/2),y:Math.round((n+o)/2)}}function Ng(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,qe(l)),a),a+=l.coords.length;return{kind:"polygon",commands:o,coords:i,fillRule:"nonzero",...r?{origin:r}:{}}}var wee,Vk,rn=J(()=>{"use strict";wee=Object.freeze({x:0,y:0});Vk=16384});function Kk(e,t,n,r){return{kind:"rect",x:e,y:t,width:n,height:r}}function Vd(e){let t=new De,n=e[0];if(!n)return Kk(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 Ig(e,t={}){if(e.length===0)return{kind:"polygon",commands:new Uint8Array,coords:new Float32Array,fillRule:t.fillRule??"nonzero"};let n=new De;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 Eg(e){let t=e.x+e.width/2,n=e.y+e.height/2,r=e.width/2,o=e.height/2,i=r*zk,s=o*zk,a=new De;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 Mg(e,t,n,r=0){let o=new De;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 Cg(e,t,n=5,r=t/2,o=0){let i=new De,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 Og(e,t){let n=new De;return n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.build()}var De,zk,gr=J(()=>{"use strict";Ye();rn();De=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(se),this.push(t,n),this}lineTo(t,n){return this.cmds.push(ae),this.push(t,n),this}curveTo(t,n,r,o,i,s){return this.cmds.push(be),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}}:{}}}};zk=.5522847498307936});function Fg(e,t){let n=e.corners?.[t];return n&&n.radius>0?n:null}function zd(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 ui(e){if(e.corners===void 0)return e;let{corners:t,...n}=e;return n}function Lg(e,t){return!e.corners||t===1?e:{...e,corners:e.corners.map(n=>n?{shape:n.shape,radius:n.radius*t}:null)}}function _g(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 Fl=J(()=>{"use strict"});function jk(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 $k=J(()=>{"use strict";Pn()});function qk(e,t,n,r={}){let{cp1:o,cp2:i}=kU(e,t,n,r.passes??4,r.params);return{cp1:o,cp2:i}}function kU(e,t,n,r,o){let i=e.length,s=e[0],a=e[i-1],l=o?[...o]:vU(e);if(l===null)return{cp1:{...s},cp2:{...a},end:a,ts:e.map(()=>0)};let u=Yk(e,l,s,a,t,n);for(let c=0;c<r;c++)AU(e,l,s,a,u),u=Yk(e,l,s,a,t,n);return u}function vU(e){let t=e.length,n=new Array(t);n[0]=0;let r=0;for(let o=1;o<t;o++)r+=Gt(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 Yk(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 y=t[m],b=1-y,x=b*b*b,w=3*b*b*y,g=3*b*y*y,P=y*y*y,S=w*o.x,v=w*o.y,A=g*i.x,N=g*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-(g+P)*r.x,C=e[m].y-(x+w)*n.y-(g+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=Gt(n,r)/3:(p=(u*c-l*d)/f,h=(a*d-l*c)/f,(p<1e-6||h<1e-6)&&(p=h=Gt(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 AU(e,t,n,r,o){for(let i=1;i<e.length-1;i++)t[i]=RU(e[i],t[i],e[0],o.cp1,o.cp2,e[e.length-1])}function RU(e,t,n,r,o,i){let s=1-t,{x:a,y:l}=jk(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,y=u*u+c*c+p*d+h*f;if(Math.abs(y)<1e-12)return t;let b=t-m/y;return b<0?0:b>1?1:b}var Xk=J(()=>{"use strict";$k();ai()});function tv(e){return typeof e=="number"?e:NU[e]}function IU(e){let t=2**Math.abs(e);return 1-.5**(1/t)<nv/4?1/0:t}function Ll(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 Qk(e,t){let n=Ll(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 EU(e,t,n,r,[o,i,s]){let a=f=>{let p=Ll(e,f);return li(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<jd;f++){let p=a(t+(n-t)*(f/jd));p>l&&(l=p,u=f)}let c=t+(n-t)*((u-1)/jd),d=t+(n-t)*((u+1)/jd);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 Dg(e,t,n,r,o,i){let s=Ll(e,t),a=Ll(e,n),l=[],u=[];for(let m=0;m<=12;m++)l.push(Ll(e,t+(n-t)*(m/12))),u.push(m/12);let c=Qk(e,n),{cp1:d,cp2:f}=qk(l,Qk(e,t),{x:-c.x,y:-c.y},{params:u}),p=[d,f,a];if(o>=10||EU(e,t,n,s,p)<=r){i.push(p);return}let h=(t+n)/2;Dg(e,t,h,r,o+1,i),Dg(e,h,n,r,o+1,i)}function MU(e,t){if(e===2)return[[{x:Jk,y:1},{x:1,y:Jk},{x:1,y:0}]];let n=`${e}:${t}`,r=$d.get(n);return r||(r=[],Dg(e,0,2,t,0,r),$d.size>256&&$d.clear(),$d.set(n,r)),r}function CU(e,t){let n=Zk(e.end,t),r=Zk(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 ev(e){return{x:e.start.x+e.end.x-e.outer.x,y:e.start.y+e.end.y-e.outer.y}}function rv(e,t,n=nv){if(e===0)return[{kind:"line",to:t.end}];let r=IU(e);if(r===1/0)return[{kind:"line",to:e>0?t.outer:ev(t)},{kind:"line",to:t.end}];let o=CU(t,e>0?ev(t):t.outer);return MU(r,n).map(([i,s,a])=>({kind:"cubic",c1:o(i),c2:o(s),to:o(a)}))}var NU,nv,Jk,Zk,jd,$d,ov=J(()=>{"use strict";Xk();_d();NU={square:1/0,squircle:2,round:1,bevel:0,scoop:-1,notch:-1/0};nv=.001,Jk=4/3*Math.tan(Math.PI/8);Zk=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),jd=32;$d=new Map});function _l(e){let{commands:t}=e,n=qe(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 Oe(t,n,(c,d,f,p,h,m)=>{if(m)return a=!0,!1;let y=b=>({x:n[d+b],y:n[d+b+1]});switch(c){case se:o&&r.push(o),o={anchors:[y(0)],segs:[],closed:!1,first:i++,sources:[s++]};break;case ae:u(y(0),sv(l(),y(0)));break;case be:u(y(4),{line:!1,p0:l(),c1:y(0),c2:y(2),p3:y(4)});break;case we:{let b=l(),x=y(0),w=y(2),g={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:g,c2:P,p3:w});break}case fe:o&&OU(o,()=>i--),o&&r.push(o),o=null;break}}),a?null:(o&&r.push(o),r)}function OU(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(sv(o,r))}function Yd(e){if(e.line)return Math.hypot(e.p3.x-e.p0.x,e.p3.y-e.p0.y);let t=iv.get(e);return t===void 0&&iv.set(e,t=po(av(e),2)),t}function Bg(e,t){let n=Yd(e);return n>0?e.line?Math.min(1,Math.max(0,t/n)):Lk(av(e),2,t,n):0}function Dl(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 xs(e,t){let n=Math.hypot(e,t);return n>1e-12?{x:e/n,y:t/n}:null}function Bl(e,t){let{p0:n,c1:r,c2:o,p3:i}=e;if(e.line)return xs(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=xs(a,l);return u||(t<.5?xs(o.x-n.x,o.y-n.y)??xs(i.x-n.x,i.y-n.y):xs(i.x-r.x,i.y-r.y)??xs(i.x-n.x,i.y-n.y))}function lv(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=[...co(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=[...co(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 sv,iv,av,Hg=J(()=>{"use strict";Ye();Pn();rn();El();sv=(e,t)=>({line:!0,p0:e,c1:e,c2:t,p3:t});iv=new WeakMap,av=({p0:e,c1:t,c2:n,p3:r})=>[e.x,e.y,t.x,t.y,n.x,n.y,r.x,r.y]});function dv(e,t){let n=t.anchors.length,r=t.segs.map(Yd),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=Bl(l,1),d=Bl(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<uv||f>Math.PI-uv)return null;let p=d.x-c.x,h=d.y-c.y,m=Math.hypot(p,h),y=(Math.PI-f)/2,b=Fg(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:y},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 ho(e){if(e.corners===void 0)return{path:e,anchorSources:null};let t=cv.get(e);if(t)return t;let n=zd(e)?FU(e):{path:ui(e),anchorSources:null};return cv.set(e,n),n}function ze(e){return e.kind!=="polygon"?e:ho(e).path}function Hl(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 FU(e){let t=_l(e);if(!t)return{path:ui(e),anchorSources:null};let n=new Gg;e.origin&&n.b.setOrigin(e.origin.x,e.origin.y);for(let i of t)LU(n,i,dv(e,i));let{commands:r,coords:o}=n.b.build();return{path:{...ui(e),commands:r,coords:o},anchorSources:Uint32Array.from(n.sources)}}function fv(e,t,n){let r=e.segs[n],o=Yd(r),i=Bg(r,t[n]?.trim??0),s=Bg(r,o-(t[(n+1)%e.anchors.length]?.trim??0));return[i,Math.max(i,s)]}function pv(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=Dl(a,n[r][1]),u=Dl(s,n[o][0]),c=_U({x:i.frame.x,y:i.frame.y},l,Bl(a,n[r][1]),u,Bl(s,n[o][0]));return{cut:i,start:l,end:u,pieces:rv(tv(i.spec.shape),c)}}function qd(e){if(!zd(e))return[];let t=[];for(let n of _l(e)??[]){let r=dv(e,n),o=n.segs.map((i,s)=>fv(n,r,s));n.segs.forEach((i,s)=>{let a=pv(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 LU(e,t,n){let r=t.anchors.length,o=t.segs.map((s,a)=>fv(t,n,a)),i=t.closed&&t.segs.length>0?Dl(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=Dl(s,u);e.lineTo(p.x,p.y)}else{let[p,h,m]=lv(s,l,u);e.curveTo(p.x,p.y,h.x,h.y,m.x,m.y)}let d=pv(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 _U(e,t,n,r,o){let i=n&&o?DU(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 DU(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 uv,cv,Gg,Rt=J(()=>{"use strict";gr();Fl();ov();Hg();uv=.001;cv=new WeakMap;Gg=class{b=new De;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 Jd(e){return e>0?e:BU}function jg(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 hv(e,t,n,r,o,i,s,a){return jg(e,t,n,r,o,i)&&Number.isFinite(s)&&Number.isFinite(a)}function mv(e,t,n,r,o,i,s,a,l,u){let c=Ug(n-e,r-t,o-n,i-r)+Ug(o-n,i-r,s-o,a-i);return o===n&&i===r&&(c+=Ug(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 Ug(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 mo(e,t,n,r,o,i,s,a,l,u){if(!hv(e,t,n,r,o,i,s,a)){u.push(s,a);return}Wg(e,t,n,r,o,i,s,a,Jd(l),u,0)}function Wg(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>=Xd){u.push(s,a);return}let p=(e+n)*.5,h=(t+r)*.5,m=(n+o)*.5,y=(r+i)*.5,b=(o+s)*.5,x=(i+a)*.5,w=(p+m)*.5,g=(h+y)*.5,P=(m+b)*.5,S=(y+x)*.5,v=(w+P)*.5,A=(g+S)*.5;Wg(e,t,p,h,w,g,v,A,l,u,c+1),Wg(v,A,P,S,b,x,s,a,l,u,c+1)}function $g(e,t,n,r,o,i,s,a){if(!jg(e,t,n,r,o,i)){a.push(o,i);return}Vg(e,t,n,r,o,i,Jd(s),a,0)}function Vg(e,t,n,r,o,i,s,a,l){if(Tn(n,r,e,t,o,i)<=s||l>=Xd){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;Vg(e,t,c,d,h,m,s,a,l+1),Vg(h,m,f,p,o,i,s,a,l+1)}function Gl(e,t,n,r,o,i,s,a,l,u,c,d=0){return hv(e,t,n,r,o,i,s,a)?zg(e,t,n,r,o,i,s,a,Jd(l),d,u,c,0,0):(u.push(s,a),c.push(0),0)}function zg(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||mv(e,t,n,r,o,i,s,a,u,l))||p>=Xd){let D=c.length>=2?c[c.length-2]:e,B=c.length>=2?c[c.length-1]:t,K=Math.hypot(s-D,a-B);return f+=K,c.push(s,a),d.push(f),f}let b=(e+n)*.5,x=(t+r)*.5,w=(n+o)*.5,g=(r+i)*.5,P=(o+s)*.5,S=(i+a)*.5,v=(b+w)*.5,A=(x+g)*.5,N=(w+P)*.5,M=(g+S)*.5,C=(v+N)*.5,F=(A+M)*.5;return f=zg(e,t,b,x,v,A,C,F,l,u,c,d,f,p+1),f=zg(C,F,N,M,P,S,s,a,l,u,c,d,f,p+1),f}function Ul(e,t,n,r,o,i,s,a,l,u=0){return jg(e,t,n,r,o,i)?Kg(e,t,n,r,o,i,Jd(s),u,a,l,0,0):(a.push(o,i),l.push(0),0)}function Kg(e,t,n,r,o,i,s,a,l,u,c,d){if(Tn(n,r,e,t,o,i)<=s&&(a===0||mv(e,t,n,r,o,i,o,i,a,s))||d>=Xd){let g=l.length>=2?l[l.length-2]:e,P=l.length>=2?l[l.length-1]:t,S=Math.hypot(o-g,i-P);return c+=S,l.push(o,i),u.push(c),c}let h=(e+n)*.5,m=(t+r)*.5,y=(n+o)*.5,b=(r+i)*.5,x=(h+y)*.5,w=(m+b)*.5;return c=Kg(e,t,h,m,x,w,s,a,l,u,c,d+1),c=Kg(x,w,y,b,o,i,s,a,l,u,c,d+1),c}var mt,BU,Xd,ci=J(()=>{"use strict";ai();mt=.5,BU=1e-6,Xd=16});function br(e,t={}){return e.kind==="rect"?[HU(e)]:GU(ze(e),t)}function HU(e){let{x:t,y:n,width:r,height:o}=e;return{points:Array.from(Al(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 GU(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,h=0,m=()=>{a=[],l=[],u=[],c=[];let x={points:a,closed:!1};return i.push(x),x},y=x=>{!a||!l||!u||!c||(x.anchorA=new Uint32Array(l),x.anchorB=new Uint32Array(u),x.anchorT=new Float32Array(c),p!==void 0&&(x.closeAnchor=p),p=void 0)},b=(x,w,g,P)=>{for(let v=0;v<w.length;v++)l.push(f),u.push(P),c.push(g>0?w[v]/g:0);let S=x+w.length-1;l[S]=P,u[S]=P,c[S]=0};return Oe(r,o,(x,w,g,P,S,v)=>{switch(v&&(d&&y(d),d=m(),a.push(g,P),l.push(h),u.push(h),c.push(0),f=h),x){case se:case ae:{x===se&&(d&&y(d),d=m(),h=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=Ul(g,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 be:{let A=s,N=a.length/2,M=[],C=Gl(g,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,a&&l&&u&&c&&(p=UU(a,l,u,c)??p));break}default:throw new Error(`extractPolylines: unknown command code ${x}`)}}),d&&y(d),i}function UU(e,t,n,r){let o=e.length/2;if(o<2||e[0]!==e[(o-1)*2]||e[1]!==e[(o-1)*2+1])return;let i=t[o-1]===n[o-1]?t[o-1]:void 0;return e.length-=2,t.length-=1,n.length-=1,r.length-=1,i}var Yg=J(()=>{"use strict";Ye();Rt();Rl();ci()});function Wl(e){let t=yv.get(e);if(t)return t;let n;if(e.kind==="rect")n=Gd(br(e),2);else{let{path:r,anchorSources:o}=ho(e),i=WU(r);n=Gd(br(r).map(s=>VU(s,i)),2,o)}return yv.set(e,n),n}function WU(e){let t=[],{commands:n,coords:r}=e;return Oe(n,r,(o,i)=>{o===se||o===ae?t.push(null):o===we?t.push([r[i],r[i+1]]):o===be&&t.push([r[i],r[i+1],r[i+2],r[i+3]])}),t}function VU(e,t){let n=e.points.length/2,{anchorA:r,anchorB:o}=e,i=[],s=[];for(let c=0;c<n;c++)r&&o&&r[c]!==o[c]||(i.push(e.points[c*2],e.points[c*2+1]),s.push(r?r[c]:c));let a=s.slice(1).map(c=>t[c]??null),l=Ol(e);e.closed&&n>=2&&a.push(l===void 0?null:t[l]??null);let u=Uint32Array.from(s);return{points:i,closed:e.closed,anchorA:u,anchorB:u.slice(),anchorT:new Float32Array(s.length),...l!==void 0?{closeAnchor:l}:{},controls:a}}var yv,gv=J(()=>{"use strict";Ye();Rt();Yg();Wd();yv=new WeakMap});function qg(e){let t=ze(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=qe(t),o=[],i=0;for(let s=0;s<n.length;s++){let a=n[s];a===se?(o.push(`M${Ze(r[i])} ${Ze(r[i+1])}`),i+=2):a===ae?(o.push(`L${Ze(r[i])} ${Ze(r[i+1])}`),i+=2):a===be?(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,bv=J(()=>{"use strict";Ye();Rt();rn();Ze=e=>Number.isFinite(e)?String(Math.round(e*1e6)/1e6):"0"});function Wn(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 xr(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 wr(e,t,n,r,o,i,s,a){let l=gs((s-o)*(t-i)-(a-i)*(e-o)),u=gs((s-o)*(r-i)-(a-i)*(n-o)),c=gs((n-e)*(i-t)-(r-t)*(o-e)),d=gs((n-e)*(a-t)-(r-t)*(s-e));return l!==u&&c!==d}var Vl=J(()=>{"use strict";kl()});function Xg(e,t){let n=Math.max(t.from,0),r=Math.min(t.to,e.total);if(!(n<r))return null;let o=xv(e,n,!0),i=xv(e,r,!1);return o&&i?{from:o,to:i}:null}function xv(e,t,n){let{cum:r}=Cl(e);for(let o=0;o<r.length;o++){let i=r[o],s=i[i.length-1];if(!(i.length<2||!(s>i[0])||(n?t>=s:t>s)))for(let a=0;a<i.length-1;a++){let l=i[a+1]-i[a];if(!(!(l>0)||(n?t>=i[a+1]:t>i[a+1])))return{run:o,segment:a,t:zU(e,o,a,t-i[a],l)}}}return null}function zU(e,t,n,r,o){let i=Gk(e,t,n);return i?Dk(i.coords,e.dim,i.lookup,r):Math.min(Math.max(r/o,0),1)}var wv=J(()=>{"use strict";El();Wd()});function Jg(){return Pv}function kn(e){return(e.openFill??Pv)==="close"}var Pv,di=J(()=>{"use strict";Pv="close"});function et(e){if(e.kind==="rect")return e;let{commands:t,coords:n}=ze(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 Oe(t,n,(u,c,d,f)=>{switch(u){case se:case ae:{l(n[c],n[c+1]);break}case be:{let[p,h,m,y]=gg(d,f,n[c],n[c+1],n[c+2],n[c+3],n[c+4],n[c+5]);l(p,h),l(m,y);break}case we:{let p=n[c+2],h=n[c+3],[m,y,b,x]=uo(d,f,n[c],n[c+1],p,h),[w,g,P,S]=gg(d,f,m,y,b,x,p,h);l(w,g),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 Qg=J(()=>{"use strict";Pn();Ye();Rt()});function Sv(e){let t=Tv.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;Oe(n,r,(h,m)=>{if(h===fe){a>1&&f&&c===l&&d===u&&(o[o.length-1]=s,i--),a=0;return}let y=lo(h);c=r[m+y-2],d=r[m+y-1],f=h===be||h===we,(h===se||a===0)&&(s=i,l=c,u=d,a=0),a++,o.push(i++)});let p=Int32Array.from(o);return Tv.set(e,p),p}var Tv,kv=J(()=>{"use strict";Ye();Tv=new WeakMap});function KU(e){return e.kind!=="polygon"?[]:qd(e).map(({anchor:t,spec:n,start:r,end:o,pieces:i})=>({anchor:t,spec:n,start:r,end:o,pieces:i}))}function tb(e,t,n=Rv){let r=e.flatMap(KU);return r.length===0?t:JU(t,r,n)}function Zg(e,t,n){let r=t.start;for(let o of t.pieces){if((o.kind==="line"?Nl(e.x,e.y,r.x,r.y,o.to.x,o.to.y).dist:li(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 ws(e,t,n,r){let o=si(e.p0,e.c1,t),i=si(e.c1,e.c2,t),s=si(e.c2,e.p3,t),a=si(o,i,n),l=si(i,s,n);return si(a,l,r)}function vv(e,t,n,r){let o=l=>ws(e,l,l,l),i=l=>{let u=ws(e,l,l,0),c=ws(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)*Gt(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 Gt(o(a),t)<=r?a:null}function jU(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?vv(e,t,0,r):0,a=n?vv(e,n,1,r):1;return s===null||a===null?null:{line:!1,p0:o,c1:ws(e,s,s,a),c2:ws(e,s,a,a),p3:i}}function Av(e,t,n,r,o){return Gt(e,n)<=o?!0:t.line&&Zg(e,r,o)&&Nl(n.x,n.y,t.p0.x,t.p0.y,t.p3.x,t.p3.y).dist<=o}function $U(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(Av(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&&!Zg(ws(c,.5,.5,.5),t,n))break;if(Av(u,e.segs[a%r],s,t,n))return{from:o,to:a%r,trace:t};if(!Zg(u,t,n))break}return null}function eb(e,t){let n=[];for(let r=e.from;;r=(r+1)%t)if(n.push(r),r===e.to)return n}function YU(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 eb(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 y=eb(m,o).length;p+=y,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,y=i.has((h+1)%o)?l[(p+1)%l.length].at:void 0,b=jU(e.segs[h],m,y,r);if(!b)return null;d.push(b)}return{nodes:l,segs:d,closed:e.closed,folded:[...t]}}function qU(e,t){let n=new De;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={...ui(t),commands:o,coords:i},a=Sv(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 XU(e,t,n){let r=new Set(n.map(o=>o.trace));for(let o of qd(e))for(let i of r){if(Gt(o.anchor,i.anchor)>t)continue;(Gt(o.start,i.start)<=t&&Gt(o.end,i.end)<=t||Gt(o.start,i.end)<=t&&Gt(o.end,i.start)<=t)&&r.delete(i)}return r}function JU(e,t,n=Rv){let r=_l(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 y=$U(c,m,n);if(!y)continue;let b=eb(y,c.anchors.length);b.some(x=>f.has(x))||(b.forEach(x=>f.add(x)),d.push(y))}let p=c.anchors.map((m,y)=>e.corners?.[c.first+y]??null),h=d.length>0?YU(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,y)=>({at:m,spec:p[y]})),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=qU(s,e),u=XU(l,n,a);if(u.size===0)return l;u.forEach(c=>o.add(c))}return e}var Rv,Nv=J(()=>{"use strict";_d();gr();kv();Hg();Fl();Rt();ai();Rv=.001});function QU(e,t){let n=ze(e),{commands:r}=n,o=qe(n),i=[],s=[],a=[];return Oe(r,o,(l,u,c,d,f,p)=>{switch(p&&(a=[c,d]),l){case se:a.length>=2&&s.push(a),a=[o[u],o[u+1]];break;case ae:a.push(o[u],o[u+1]);break;case be:mo(c,d,o[u],o[u+1],o[u+2],o[u+3],o[u+4],o[u+5],t,a);break;case we:$g(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 Qd(e,t){let n=QU(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 nb(e,t){return Qd(e,t).closed}var Iv=J(()=>{"use strict";Ye();ci();di();Rt();rn()});function rb(e,t,n,r){let o=e.points,i=o.length/2,s=ZU(e,i);if(s.length<2)return{length:0,x:o[0]??0,y:o[1]??0};let a=Math.min(Math.max(Math.floor(t),0),s.length-2),l=Math.min(Math.max(n,0),1),u=s[a],c=s[a+1],d=r?.controls?.[a],f=d&&d.length>0?Ml([o[u*2],o[u*2+1],o[c%i*2],o[c%i*2+1]],d,2,0):null,p,h;f?[p,h]=Bk(f,2,l):(p=Cv(o[u*2],o[c%i*2],l),h=Cv(o[u*2+1],o[c%i*2+1],l));let{chord:m,u:y}=!f&&c-u===1?{chord:u,u:l}:e6(e,i,u,c,p,h,f?t6(f,l):l),b=0;for(let x=0;x<m;x++)b+=Mv(o,i,x);return{length:b+y*Mv(o,i,m),x:p,y:h}}function ZU(e,t){let{anchorA:n,anchorB:r}=e,o=[];for(let i=0;i<t;i++)(!n||!r||n[i]===r[i])&&o.push(i);return e.closed&&t>=2&&o.push(t),o}function e6(e,t,n,r,o,i,s){let a=e.anchorT,l=f=>f>=r?1:f<=n?0:a?a[f]:(f-n)/(r-n),u=n;for(;u<r-1&&l(u+1)<=s;)u++;let c=Ev(e.points,t,u,o,i),d=c<0?-1:c>1?1:0;for(;d!==0&&u+d>=n&&u+d<r&&(d<0?c<0:c>1);)u+=d,c=Ev(e.points,t,u,o,i);return{chord:u,u:Math.min(Math.max(c,0),1)}}function Ev(e,t,n,r,o){let i=e[n*2],s=e[n*2+1],a=(n+1)%t,l=e[a*2]-i,u=e[a*2+1]-s,c=l*l+u*u;return c>0?((r-i)*l+(o-s)*u)/c:0}function Mv(e,t,n){let r=(n+1)%t;return Math.hypot(e[r*2]-e[n*2],e[r*2+1]-e[n*2+1])}function t6(e,t){let n=po(e,2);return n>0?po(e,2,0,t)/n:t}var Cv,Ov=J(()=>{"use strict";vg();El();Cv=(e,t,n)=>e+(t-e)*n});function Fv(e){let t=(e.a+e.d)/2,n=(e.a-e.d)/2,r=(e.b+e.c)/2,o=(e.b-e.c)/2,i=Math.hypot(t,o),s=Math.hypot(n,r),a=(Math.atan2(o,t)+Math.atan2(r,n))/2;return{s1:i+s,s2:Math.abs(i-s),phi:a}}function Lv(e){return e.s1-e.s2<=1e-9*e.s1}var _v=J(()=>{"use strict"});function ob(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 nb(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 Zd(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 Ps(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 n6(e,t){if(e.length===0||t.length===0)return!1;if(Wn(Ps(e),t[0].x,t[0].y)||Wn(Ps(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(wr(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y))return!0}}return!1}function Bv(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 r6(e,t){let n=t.x,r=t.y,o=t.x+t.width,i=t.y+t.height;return Bv(e,(s,a,l,u)=>wr(s,a,l,u,n,r,o,r)||wr(s,a,l,u,o,r,o,i)||wr(s,a,l,u,o,i,n,i)||wr(s,a,l,u,n,i,n,r))}function Hv(e,t){return t.length===0?!1:Bv(e,(n,r,o,i)=>{for(let s=0;s<t.length;s++){let a=t[s],l=t[(s+1)%t.length];if(wr(n,r,o,i,a.x,a.y,l.x,l.y))return!0}return!1})}function o6(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(wr(o,i,s,a,u.x,u.y,c.x,c.y))return!0}}return!1}function i6(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 Dv(e,t){for(let n of e)for(let r=0;r<n.length;r+=2)if(Wn(t,n[r],n[r+1]))return!0;return!1}function ef(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=nb(e,n);if(r.length===0)return!1;for(let o of Zd(t))if(ob(e,o.x,o.y,n))return!0;return i6(r,t)?!0:r6(r,t)}function ib(e,t,n={}){if(e.length<3)return!1;let r;if(t.kind==="rect")r=[Ps(Zd(t))];else{let{closed:i,open:s}=Qd(t,n);r=[...i,...s]}if(r.length===0)return!1;let o=Ps(e);for(let i of r)for(let s=0;s<i.length;s+=2)if(!Wn(o,i[s],i[s+1]))return!1;return!Hv(r,e)}function tf(e,t,n={}){if(e.length<3)return!1;let r=n.filled!==!1;if(t.kind==="rect"&&r)return n6(Zd(t),e);let{closed:o,open:i}=t.kind==="rect"?{closed:[Ps(Zd(t))],open:[]}:Qd(t,n),s=Ps(e);return Dv(o,s)||Dv(i,s)||Hv(o,e)||o6(i,e)?!0:r&&o.length>0&&ob(t,e[0].x,e[0].y,n)}var Gv=J(()=>{"use strict";Vl();Iv()});function Nt(e,t,n={}){let[r,o,i,s,a,l]=t;if(e.kind==="rect"){if(Math.abs(o)<Uv&&Math.abs(i)<Uv){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 De().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 Wv(u,t,n)}return Wv(e,t,n)}function Wv(e,t,n){let r=Lg(e,Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]))),o=e.origin;if(o===void 0){let d=mg(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(mg(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 Uv,zl=J(()=>{"use strict";bs();gr();Fl();rn();Uv=1e-9});function sb(e,t,n){return e.kind==="rect"?{kind:"rect",x:e.x+t,y:e.y+n,width:e.width,height:e.height}:s6(e,t,n)}function s6(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 Oe(i,s,(a,l)=>{for(let u=0,c=lo(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 Vv=J(()=>{"use strict";Ye()});function ab(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===se||o===ae||o===be||o===we)&&n++}return n}var zv=J(()=>{"use strict";Ye()});function nf(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 Oe(t,n,(f,p,h,m)=>{if(f===se){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===ae){u=n[p],c=n[p+1],i+=h*c-u*m;return}let y=f===be,b=n[p],x=n[p+1],w=n[p+2],g=n[p+3],P=y?n[p+4]:w,S=y?n[p+5]:g;for(let v=0;v<3;v++){let A=a6[v],N=1-A,M,C,F,D;y?(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*g+A*A*A*S,F=3*(N*N*(b-h)+2*N*A*(w-b)+A*A*(P-w)),D=3*(N*N*(x-m)+2*N*A*(g-x)+A*A*(S-g))):(M=N*N*h+2*N*A*b+A*A*w,C=N*N*m+2*N*A*x+A*A*g,F=2*(N*(b-h)+A*(w-b)),D=2*(N*(x-m)+A*(g-x))),i+=l6[v]*(M*D-C*F)}u=P,c=S}),d(!1),o/2}var a6,l6,lb=J(()=>{"use strict";Ye();di();a6=[.5-Math.sqrt(15)/10,.5,.5+Math.sqrt(15)/10],l6=[5/18,8/18,5/18]});function jv(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 u6(e){let t=[],n=0;for(;n<e.length;)if(jv(e,n)){let r=n+1;for(;r<e.length&&!jv(e,r);)r++;let o=e.slice(n+1,r),i=e[n];t.push({cmd:i,args:i==="A"||i==="a"?d6(o):c6(o)}),n=r}else n++;return t}function c6(e){let t=[],n;for(Kv.lastIndex=0;(n=Kv.exec(e))!==null;){let r=Number(n[0]);Number.isFinite(r)&&t.push(r)}return t}function d6(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}ub.lastIndex=n;let i=ub.exec(e);if(!i)return t;t.push(Number(i[0])),n=ub.lastIndex}return t}function fi(e,t){let n=u6(e),r=new De().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=f6[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;p6(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 p6(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;h6(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 h6(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*Un,d=Math.cos(c),f=Math.sin(c),p=(e-n)/2,h=(t-r)/2,m=d*p+f*h,y=-f*p+d*h,b=o*o,x=i*i,w=m*m,g=y*y,P=w/b+g/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*g-x*w,M=b*g+x*w,C=A*Math.sqrt(Math.max(0,N/M)),F=C*(S*y)/v,D=C*-(v*m)/S,B=d*F-f*D+(e+n)/2,K=f*F+d*D+(t+r)/2,W=(te,he,xe,Le)=>{let Se=te*xe+he*Le,cr=Math.sqrt((te*te+he*he)*(xe*xe+Le*Le)),_e=Math.acos(Math.max(-1,Math.min(1,Se/cr)));return te*Le-he*xe<0&&(_e=-_e),_e},Q=W(1,0,(m-F)/S,(y-D)/v),le=W((m-F)/S,(y-D)/v,(-m-F)/S,(-y-D)/v);!l&&le>0?le-=2*Math.PI:l&&le<0&&(le+=2*Math.PI);let ke=Math.max(1,Math.ceil(Math.abs(le)/(Math.PI/2))),ue=le/ke,ve=4/3*Math.tan(ue/4),G=e,j=t,$=-Math.sin(Q)*S,ee=Math.cos(Q)*v;for(let te=1;te<=ke;te++){let he=Q+te*ue,xe=Math.cos(he),Le=Math.sin(he),Se=d*(xe*S)-f*(Le*v)+B,cr=f*(xe*S)+d*(Le*v)+K,_e=-Le*S,vt=xe*v,Qt=G+d*(ve*$)-f*(ve*ee),od=j+f*(ve*$)+d*(ve*ee),Cy=Se-d*(ve*_e)+f*(ve*vt),id=cr-f*(ve*_e)-d*(ve*vt);u.curveTo(Qt,od,Cy,id,Se,cr),G=Se,j=cr,$=_e,ee=vt}}var Kv,ub,f6,$v=J(()=>{"use strict";gr();hg();Kv=/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g,ub=/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/y;f6={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 pi(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=ze(e),{commands:a}=s,l=qe(s);Oe(a,l,(c,d,f,p,h,m)=>{switch(m&&(n={segs:[],closed:!1},r=f,o=p),c){case se:i(!1,f,p),n={segs:[],closed:!1},r=l[d],o=l[d+1];break;case ae:{let y=l[d],b=l[d+1];(y!==f||b!==p)&&n.segs.push(Ue(f,p,y,b));break}case we:{let[y,b,x,w]=uo(f,p,l[d],l[d+1],l[d+2],l[d+3]);n.segs.push({c:[f,p,y,b,x,w,l[d+2],l[d+3]],line:!1});break}case be: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 cb(e,t="nonzero"){let n=new De().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 Ts(e,t){let[n,r]=co(...e.c,t);return[{c:[...n],line:e.line},{c:[...r],line:e.line}]}var rf=J(()=>{"use strict";Pn();Ye();gr();Rt();rn()});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 jl(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 Yv(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]=Ik(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]=co(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 Ss(e,t,n,r,o){if(n-t<=0)return null;let i=e;t>0&&(i=Yv(i,t)[1]);let s=(n-t)/(1-t);return s<1&&(i=Yv(i,s)[0]),i=i.slice(),i[0]=r,i[i.length-1]=o,i}function m6(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 Xv(e){return xr(m6(e))}function Jv(e,t,n){return e.map(r=>n.x*(r.y-t.y)-n.y*(r.x-t.x))}function Kl(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 Qv(e,t){let n=i=>i>0?1:i<0?-1:t?1:0,r=[0,...y6(e),1],o=[];for(let i=0;i+1<r.length;i++){let s=r[i],a=r[i+1],l=n(Kl(e,s)),u=n(Kl(e,a));if(l===0&&i>0){let c=n(Kl(e,s-1e-7)),d=n(Kl(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(Kl(e,d))===l?s=d:a=d}o.push({t:(s+a)/2,before:l,after:u})}}return o}function y6(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 qv,hi=J(()=>{"use strict";Pn();Vl();qv=e=>e.map(t=>t.slice().reverse()).reverse()});function eA(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 tA(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 nA(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 rA(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 x6(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=jl(e,n),c=jl(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 db(e,t){if(e.length===2&&t.length===2){let i=rA(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]=x6(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)<Zv&&Math.abs(u.tb-s)<Zv)||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<b6;){let[i,s,a]=o.pop(),l=eA(i.pts),u=eA(s.pts);if(l[0]>u[2]+ks||u[0]>l[2]+ks||l[1]>u[3]+ks||u[1]>l[3]+ks)continue;let c=tA(i.pts),d=tA(s.pts);if(c<=ks&&d<=ks||a>=g6){let f=rA(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]=nA(i);o.push([f,s,a+1],[p,s,a+1])}else{let[f,p]=nA(s);o.push([i,f,a+1],[i,p,a+1])}}return n.sort((i,s)=>i.ta-s.ta)}var ks,g6,Zv,b6,oA=J(()=>{"use strict";hi();ks=1e-4,g6=48,Zv=1e-7,b6=16});function iA(e){let t=e.kind==="rect"||kn(e);return w6(e).filter(n=>n.closed||t).map(n=>n.segs)}function w6(e,t=!0){let n=ze(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,y)=>[m,h[(y+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=qe(n),u=0;for(let c of n.commands)if(c===se)a(!1),i=s={x:l[u],y:l[u+1]},u+=2;else if(c===ae){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===be){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 sA(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 aA=J(()=>{"use strict";Ye();di();Rt();rn()});function Vn(e,t){let n=new e.constructor(t);return n.set(e),n}function fb(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 of,lA=J(()=>{"use strict";of=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=Vn(this.nodeBox,t*n),this.left=Vn(this.left,t),this.right=Vn(this.right,t),this.parent=Vn(this.parent,t),this.leafCount=Vn(this.leafCount,t),this.leafItems=Vn(this.leafItems,t*4),this.count=Vn(this.count,t),this.nodeCap=t}growItems(t){this.itemBox=Vn(this.itemBox,t*2*this.dim),this.itemCentroid2=Vn(this.itemCentroid2,t*this.dim),this.itemLeaf=Vn(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){fb(o,i,o,this.left[t]*r,n),fb(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++)fb(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 sf(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 P6(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 uA(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 pb(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(uA(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(uA(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 cA(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 dA(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(cA(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(cA(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 af(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 fA(e,t,n,r,o,i){if(e.root===-1)return;let s=e.dim,a=2*s,l=af(e.nodeBox,e.root*a,s,n,r,i);if(l<0)return;let u=t.take();try{let c=sf(u,0,l,e.root);for(;c>0;){let d=u.heapT[0],f=u.heapId[0];if(P6(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],g=af(e.itemBox,w*a,s,n,r,i);g>=0&&(c=sf(u,c,g,-w-1))}continue}let p=e.left[f],h=e.right[f],m=af(e.nodeBox,p*a,s,n,r,i);m>=0&&(c=sf(u,c,m,p));let y=af(e.nodeBox,h*a,s,n,r,i);y>=0&&(c=sf(u,c,y,h))}}finally{u.release()}}var lf,pA=J(()=>{"use strict";lf=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 hA(e){return 2*Math.ceil(Math.log2(Math.max(e,2)))}function S6(e){let t=0;for(;e>4;e=Math.ceil(e/2))t++;return t}function hb(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 yb(e,t){if(!Number.isInteger(e)||e<1)throw new RangeError(`createBvh: dim must be a positive integer, got ${e}`);let n=new mb(e);return t&&(n.load(t),n.rebuild()),n}var T6,mb,mA=J(()=>{"use strict";lA();pA();T6=.7;mb=class{dim;tree;items=new Map;scratch=new lf;peakSize=0;constructor(t){this.dim=t,this.tree=new of(t)}get size(){return this.items.size}load(t){for(let[n,r]of t){if(!hb(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(!hb(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||!hb(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){pb(this.tree,this.scratch,t,0,this.dim,n)}queryPoint(t,n){pb(this.tree,this.scratch,t,0,0,n)}raycast(t,n,r,o=1/0){fA(this.tree,this.scratch,t,n,r,o)}queryHalfSpaces(t,n){dA(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>hA(this.items.size)&&this.rebalance(n.itemLeaf[t],o)}rebalance(t,n){let r=this.tree,o=hA(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+S6(r.count[a])>o)){if(r.count[s]>T6*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 yA(e,t){let n=[],r=[];for(let{segs:i,closed:s}of e){n.push(se),r.push(i[0][0].x,i[0][0].y);for(let a of i){n.push(a.length===2?ae:a.length===3?we:be);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 gA=J(()=>{"use strict";Ye();rn()});function bb(e,t,n={}){let r=new De;if(!(t>0))return r.build();let o=nf(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 pi(e)){let a=s.segs.filter(c=>!_6(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])),H6(r,A6(a,i))}return r.build()}function A6(e,t){let n=e.map(r=>({pieces:gb(r,t,0),join:[]}));for(let r=0;r<e.length;r++){let o=(r+1)%e.length,i=PA(e[r].c),s=wA(e[o].c),a=[e[o].c[0],e[o].c[1]];n[r].join=R6(n[r],n[o],a,i,s,t)}return n}function R6(e,t,n,r,o,i){let s=B6(e.pieces.at(-1)),a=D6(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 N6(e,t,s);if(!d)return E6(e,t)?[]:[Ue(s[0],s[1],n[0],n[1]),Ue(n[0],n[1],a[0],a[1])];let f=uf(r,i.sigma),p=uf(o,i.sigma);if(i.join==="round")return O6(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),y=[n[0]+(f[0]+p[0])*m,n[1]+(f[1]+p[1])*m];return I6(e,t,y)}function N6(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 I6(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 E6(e,t){let n=e.pieces.at(-1),r=t.pieces[0];if(n===r)return!1;let o=M6(n.c,r.c);if(o===null)return!1;let i=o[0]>=1?n:Ts(n,o[0])[0],s=o[1]<=0?r:Ts(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 M6(e,t){let n=bA(e),r=bA(t),o=null,i=1/0;for(let s=0;s<As;s++)for(let a=0;a<As;a++){let l=C6(n[s],n[s+1],r[a],r[a+1]);if(l===null)continue;let u=(s+l[0])/As,c=(a+l[1])/As;u<=1e-9||c>=1-1e-9||1-u+c>=i||(i=1-u+c,o=[u,c])}return o}function bA(e){let t=[];for(let n=0;n<=As;n++)t.push(Ve(...e,n/As));return t}function C6(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 O6(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 gb(e,t,n){let r=e.c,o=uf(wA(r),t.sigma),i=uf(PA(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*xA(r,0)),l=Math.max(0,1+t.sigma*s*xA(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>=k6||F6(r,p.c,t)<=t.tol)return[p];let[h,m]=Ts(e,.5);return[...gb(h,t,n+1),...gb(m,t,n+1)]}function F6(e,t,n){let r=0;for(let o of v6){let[i,s]=L6(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 L6(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 xA(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 wA(e){return Rs(e[2]-e[0],e[3]-e[1])??Rs(e[4]-e[0],e[5]-e[1])??Rs(e[6]-e[0],e[7]-e[1])??[1,0]}function PA(e){return Rs(e[6]-e[4],e[7]-e[5])??Rs(e[6]-e[2],e[7]-e[3])??Rs(e[6]-e[0],e[7]-e[1])??[1,0]}function Rs(e,t){let n=Math.hypot(e,t);return n<1e-12?null:[e/n,t/n]}function uf(e,t){return[t*e[1],-t*e[0]]}function _6(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 H6(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 k6,v6,As,D6,B6,TA=J(()=>{"use strict";Pn();gr();rf();lb();k6=6,v6=[.2,.35,.5,.65,.8];As=32;D6=e=>[e.c[0],e.c[1]],B6=e=>[e.c[6],e.c[7]]});function RA(e){let t=e.map(o=>G6(o)),n=t.map(U6),r=[];for(let o=0;o<e.length;o++)for(let i=o+1;i<e.length;i++){if(!yg(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=W6(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:V6(e[o].c,e[i].c,d);vA(f)&&vA(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 G6(e){if(e.line)return[[e.c[0],e.c[1]],[e.c[6],e.c[7]]];let t=[];for(let n=0;n<=SA;n++)t.push(Ve(...e.c,n/SA));return t}function U6(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 W6(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 V6(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=AA(e,o),c=AA(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 AA(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 SA,kA,vA,NA=J(()=>{"use strict";Rl();Pn();SA=16,kA=1e-7;vA=e=>e<kA||e>1-kA});function wb(e,t={}){let n=t.tolerance??.01,r=pi(e).filter(d=>d.segs.length>0),o=r.flatMap(d=>IA(d.segs,n*.001)),i=nf(e)<0,s=o.map(()=>[]);for(let d of RA(o)){let f=z6(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=$6(o,n/4),l=[],u=!1;o.forEach((d,f)=>{let p=K6(d,s[f]);p.length>1&&(u=!0);for(let h of p){let m=Y6(h,a,n);m===null?u=!0:m===i?l.push(h):(u=!0,l.push(j6(h)))}});let c=new De;if(!u){for(let d of r)MA(c,IA(d.segs,n*.001));return c.build()}for(let d of q6(l))MA(c,d);return c.build()}function IA(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]=xb(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 z6(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 K6(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]=Ts(o,(a.t-i)/(1-i));r.push(xb(l,s,a.p)),o=u,i=a.t,s=a.p}return r.push(xb(o,s,[e.c[6],e.c[7]])),r}function xb(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 j6(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 $6(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]):mo(...o,t,r);return r.length>0&&n.push(r),n}function EA(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 Y6(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=EA(t,o+u,i+c)!==0,f=EA(t,o-u,i-c)!==0;return d===f?null:d}function q6(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 MA(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 CA=J(()=>{"use strict";Pn();ci();gr();rf();NA();lb()});function Ns(e,t,n,r,o,i){return new Float64Array([e,t,0,n,r,0,o,i,1])}function X6(){return Ns(1,0,0,1,0,0)}function Pb(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 Ns(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 J6(e,t,n){let r=Ns(1,0,0,1,t,n);return Pb(e,r)}function Q6(e,t,n){let r=Ns(t,0,0,n,0,0);return Pb(e,r)}function OA(e){return[e[0],e[1],e[3],e[4],e[6],e[7]]}function FA(e){return Ns(e[0],e[1],e[2],e[3],e[4],e[5])}function Z6(e){let t=hr(OA(e));return t&&FA(t)}function eW(e){return Float32Array.from(e)}function tW(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 nW(e,t){return Ns(2/e,0,0,-2/t,-1,1)}function rW(e){return Math.sqrt(Math.abs(e[0]*e[4]-e[1]*e[3]))}function oW(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,LA=J(()=>{"use strict";bs();q={identity:X6,toAffine:OA,fromAffine:FA,multiply:Pb,translated:J6,scaled:Q6,invert:Z6,toUniform:eW,apply:tW,screenToClip:nW,meanScaleOf:rW,minScaleOf:oW}});function Pr(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 _A=J(()=>{"use strict"});function Tb(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 DA(e,t,n,r){return e.kind==="rect"?sW(e.x,e.y,e.width,e.height,t,n,r):iW(e,t,n,r)}function iW(e,t,n,r){let o=Math.cos(r),i=Math.sin(r);if(e.origin)return Nt(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 Oe(s,a,(u,c)=>{for(let d=0,f=lo(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 sW(e,t,n,r,o,i,s){let a=Math.cos(s),l=Math.sin(s),u=(g,P)=>{let S=g-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),[y,b]=u(e,t+r),x=new Uint8Array([se,ae,ae,ae,fe]),w=new Float32Array([c,d,f,p,h,m,y,b]);return{kind:"polygon",commands:x,coords:w,fillRule:"nonzero"}}var BA=J(()=>{"use strict";Ye();zl()});function zn(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 Re(e){let t=e;if(!t||t.x==null||t.y==null||t.width==null||t.height==null)return null;let n=zn(t);if(!t.rotation&&!n)return null;let r=t.x+t.width/2,o=t.y+t.height/2;if(!n)return ao(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(ao(r,o,t.rotation),u):u}function mi(e){if(!zn(e)){let n=Tb(e);return n&&ao(n.cx,n.cy,-n.rotation)}let t=Re(e);return t&&hr(t)}function Is(e,t){if(zn(t)){let r=Re(t);if(!r)return e;let[o,i,s,a]=r,l=Lv(Fv({a:o,b:i,c:s,d:a}));return Nt(e.kind==="polygon"&&!l?ze(e):e,r)}let n=Tb(t);return n?DA(e,n.cx,n.cy,n.rotation):e}var HA=J(()=>{"use strict";bs();Rt();zl();_v();BA()});function $l(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=mr(n.x,n.y,n.width,n.height,t.x,t.y,t.width,t.height);return Nt(e,r)}var GA=J(()=>{"use strict";bs();Qg();zl()});function UA(e){if(e===null||typeof e!="object")return;let{__ta:t,data:n}=e;if(!(typeof t!="string"||!Object.hasOwn(Yl,t)||!Array.isArray(n)))return Yl[t].from(n)}function Sb(e,t){let n=t(e);if(n!==void 0)return n;if(Array.isArray(e))return e.map(o=>Sb(o,t));if(!lW(e))return e;let r={};for(let o of Object.keys(e))r[o]=Sb(e[o],t);return r}function kb(e){return Sb(e,UA)}var Yl,nre,aW,lW,WA=J(()=>{"use strict";Yl={i8:Int8Array,u8:Uint8Array,u8c:Uint8ClampedArray,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array},nre=new Map(Object.keys(Yl).map(e=>[Yl[e].name,e])),aW=e=>Object.prototype.toString.call(e).slice(8,-1);lW=e=>aW(e)==="Object"});var Z=J(()=>{"use strict";kl();hg();bs();Rl();Ye();ci();Vl();Wd();wv();gv();di();gr();Qg();rn();Rt();Fl();Vv();zl();$v();bv();rf();TA();CA();Gv();zv();LA();_A();HA();GA();WA()});function Ut(e){return e!=null&&(e.kind===void 0||e.kind==="solid")}var Gb=J(()=>{"use strict"});function Tr(e){return e===void 0?"":`trim(${DR(e.start??0)},${DR(e.end??1)},${e.pace??"length"})`}function DR(e){return typeof e=="number"?String(e):"length"in e?`l${e.length}`:"anchor"in e?`a${e.anchor}`:`s${e.subpath}`}var BR=J(()=>{"use strict"});function Ie(e,t=null){return e===It?t:e?.paint==null?null:e}function Ne(e,t=null){return e===It?t:e?.paint==null?null:e}var It,Ub=J(()=>{"use strict";It="inherit"});function Af(e){return Array.isArray(e)?`[${e.map(Af).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)}:${Af(e[n])}`).join(",")}}`}function bo(e){if(e==null)return"none";if(Ut(e))return`solid:${e.color}:${e.opacity??1}`;let t=HR.get(e);return t===void 0&&(t=Af(e),HR.set(e,t)),t}function Rf(e){return Ie(e)!==null}function Sr(e){let t=Ne(e);if(t===null)return!1;let n=t.width??1;return(typeof n=="number"?n:n.px)>0}function ru(e){if(!Sr(e))return"none";let t=GR.get(e);if(t===void 0){let{paint:n,width:r,join:o,cap:i,miterLimit:s,align:a,dash:l,...u}=e;t=Af({...u,width:r??1,join:o??"miter",cap:i??"butt",miterLimit:s??4,align:a??"center",dash:l??[]}),GR.set(e,t)}return`${t}|${bo(e.paint)}`}var HR,GR,UR=J(()=>{"use strict";Gb();Ub();HR=new WeakMap,GR=new WeakMap});function ou(e){return e!==void 0&&NW.has(e)}function Wb(e){return ou(e.kind)}function Vb(e){return e.kind==="image"}function Nf(e){return e.kind==="texture"||e.kind==="image"||ou(e.kind)}function If(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 zb(e){let{units:t,origin:n,transform:r,opacity:o,...i}=e;return i}var WR,NW,VR=J(()=>{"use strict";WR=["hatch","crosshatch","dots","chunks"],NW=new Set(WR)});function Ef(e,t){let n=t/2;return typeof e=="number"?Kb(e)?{left:e/2,right:e/2}:{left:n,right:n}:e==null||typeof e!="object"?{left:n,right:n}:{left:Kb(e.left)?e.left:n,right:Kb(e.right)?e.right:n}}function iu(e,t){return typeof e=="number"?e*t:{left:e.left*t,right:e.right*t}}function jb(e,t){let n=e/2;if(t)for(let r of t){let{left:o,right:i}=Ef(r,e);n=Math.max(n,o,i)}return n}var Kb,zR=J(()=>{"use strict";Kb=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0});function Wt(e,t){return typeof e=="number"?e:!Number.isFinite(t)||t===0?e.px:e.px/t}function $b(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 Mf(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>KR)return"solid"}return e}var KR,jR=J(()=>{"use strict";KR=1e5});function $R(e){if(!IW.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 IW,YR=J(()=>{"use strict";IW=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i});function qR(e){let t=e%Yb;return t>Math.PI?t-Yb:t<-Math.PI?t+Yb:t}var Yb,XR=J(()=>{"use strict";Yb=Math.PI*2});function Xb(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 Cf(e,t,n){return EW(qb[e&255],qb[t&255],qb[n&255])}function EW(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 su(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 JR(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 MW(e,t,n){let[r,o,i]=su(e,t,n);if(JR(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]=su(e,t*u,n*u),JR(r,o,i)?s=u:a=u}return[r,o,i]=su(e,t*s,n*s),[r,o,i]}function QR(e,t,n){let[r,o,i]=MW(e,t,n);return[Xb(r),Xb(o),Xb(i)]}function CW(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 ZR(e,t,n){let r=Math.hypot(t,n),o=Math.atan2(n,t);return[e,r,o]}function Qb(e,t,n){return[e,t*Math.cos(n),t*Math.sin(n)]}function OW(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=qR(d-c);return[r+(s-r)*n,o+(a-o)*n,c+f*n]}function eN(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=Cf(on(e[a]),on(e[a+1]),on(e[a+2])),u=Cf(on(t[a]),on(t[a+1]),on(t[a+2])),c=ZR(l[0],l[1],l[2]),d=ZR(u[0],u[1],u[2]),f=OW(c,d,n),p=Qb(f[0],f[1],f[2]),[h,m,y]=QR(p[0],p[1],p[2]);o[a]=Bs(h),o[a+1]=Bs(m),o[a+2]=Bs(y),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=Cf(on(e[a]),on(e[a+1]),on(e[a+2])),u=Cf(on(t[a]),on(t[a+1]),on(t[a+2])),c=CW(l,u,n),[d,f,p]=QR(c[0],c[1],c[2]);o[a]=Bs(d),o[a+1]=Bs(f),o[a+2]=Bs(p),o[a+3]=e[a+3]+(t[a+3]-e[a+3])*n}return o}function Zb(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 tN(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[Jb(o,r,i+1/3),Jb(o,r,i),Jb(o,r,i-1/3)]}function Jb(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 qb,on,Bs,ex=J(()=>{"use strict";XR();qb=(()=>{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)));Bs=e=>e/255});function nN(e){let t=Of.get(e);if(t!==void 0)return t;let n=LW(e);return Of.size>=FW&&Of.clear(),Of.set(e,n),n}function LW(e){let t=e.trim();if(t.startsWith("#"))return DW(t);let n=t.toLowerCase(),r=WW[n];if(r!==void 0)return r;if(n.startsWith("rgb")){let o=BW(n);if(o)return o}if(n.startsWith("hsl")){let o=HW(n);if(o)return o}if(n.startsWith("color(")){let o=GW(n);if(o)return o}if(n.startsWith("ok")){let o=UW(n);if(o)return o}throw new Error(`parseColor: unrecognized color "${e}"`)}function $n(e){let t=Ff.get(e);if(t)return t;Ff.size>=_W&&Ff.clear();let r=nN(e);return Ff.set(e,r),r}function DW(e){let t=$R(e);if(!t)throw new Error(`parseColor: invalid hex "${e}"`);return[t[0]/255,t[1]/255,t[2]/255,t[3]/255]}function wi(e,t){return!e.startsWith(t+"(")||!e.endsWith(")")?null:e.slice(t.length+1,-1).trim()}function _f(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 Lf(e,t){if(e.endsWith("%")){let r=Number(e.slice(0,-1));return Number.isFinite(r)?jn(r/100):null}let n=Number(e);return Number.isFinite(n)?jn(n/t):null}function Df(e){if(e===null)return 1;if(e.endsWith("%")){let n=Number(e.slice(0,-1));return Number.isFinite(n)?jn(n/100):1}let t=Number(e);return Number.isFinite(t)?jn(t):1}function BW(e){let t=wi(e,"rgba")??wi(e,"rgb");if(t===null)return null;let n=_f(t);if(!n)return null;let r=Lf(n.rgb[0],255),o=Lf(n.rgb[1],255),i=Lf(n.rgb[2],255);return r===null||o===null||i===null?null:[r,o,i,Df(n.alpha)]}function HW(e){let t=wi(e,"hsla")??wi(e,"hsl");if(t===null)return null;let n=_f(t);if(!n)return null;let r=rN(n.rgb[0]),o=tx(n.rgb[1]),i=tx(n.rgb[2]);if(r===null||o===null||i===null)return null;let[s,a,l]=tN(r,o,i);return[s,a,l,Df(n.alpha)]}function GW(e){let t=wi(e,"color"),n=t?.match(/^(srgb-linear|srgb)\s+/);if(!t||!n||t.includes(","))return null;let r=_f(t.slice(n[0].length));if(!r)return null;let o=r.rgb.map(l=>Lf(l,1));if(o.some(l=>l===null))return null;let[i,s,a]=n[1]==="srgb"?o:o.map(l=>Zb(l));return[jn(i),jn(s),jn(a),Df(r.alpha)]}function UW(e){let t=wi(e,"oklch"),n=t??wi(e,"oklab");if(n===null||n.includes(","))return null;let r=_f(n);if(!r)return null;let o=tx(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=rN(r.rgb[2]);if(d===null)return null;[,s,a]=Qb(o,i,d*(Math.PI/180))}else if(!Number.isFinite(a))return null;let[l,u,c]=su(o,s,a).map(d=>jn(Zb(d)));return[l,u,c,Df(r.alpha)]}function rN(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 tx(e){if(e.endsWith("%")){let n=Number(e.slice(0,-1));return Number.isFinite(n)?jn(n/100):null}let t=Number(e);return Number.isFinite(t)?jn(t):null}function jn(e){return e<0?0:e>1?1:e}var Of,FW,_W,Ff,WW,nx=J(()=>{"use strict";ex();YR();Of=new Map,FW=1024;_W=1024,Ff=new Map;WW=(()=>{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 rx(e){return[...e].sort((t,n)=>t.offset-n.offset).map(t=>({offset:t.offset,rgba:$n(t.color)}))}function ox(e,t,n="rgb"){if(e.length===0)return zW;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]=eN(s.rgba,a.rgba,u,n);return[c,d,f,p]}return o.rgba}var zW,oN=J(()=>{"use strict";nx();ex();zW=[0,0,0,0]});var Pe=J(()=>{"use strict";Gb();BR();UR();Ub();VR();zR();jR();nx();oN()});var _I=yG((Yx,qx)=>{"use strict";(function(e,t){typeof Yx=="object"&&typeof qx<"u"?qx.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.polygonClipping=t())})(Yx,(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,y=(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 g{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 g,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 D=(3+16*v)*v,B=(2+12*v)*v,K=(9+64*v)*v*v,W=F(4),Q=F(8),le=F(12),ke=F(16),ue=F(4);function ve(O,T,k,R,E,I,H){let _,V,U,X,L,z,Y,ie,re,ge,de,Me,ct,$e,dt,ft,Zt,pt,hn=O-E,mn=k-E,yn=T-I,gn=R-I;$e=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-($e-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,Zt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Zt,L=dt-de,W[0]=dt-(de+L)+(L-Zt),Me=$e+de,L=Me-$e,ct=$e-(Me-L)+(de-L),de=ct-ft,L=ct-de,W[1]=ct-(de+L)+(L-ft),pt=Me+de,L=pt-Me,W[2]=Me-(pt-L)+(de-L),W[3]=pt;let dr=C(4,W),ul=B*H;if(dr>=ul||-dr>=ul||(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)||(ul=K*H+N*Math.abs(dr),dr+=hn*X+gn*_-(yn*U+mn*V),dr>=ul||-dr>=ul))return dr;$e=_*gn,z=A*_,Y=z-(z-_),ie=_-Y,z=A*gn,re=z-(z-gn),ge=gn-re,dt=ie*ge-($e-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,Zt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Zt,L=dt-de,ue[0]=dt-(de+L)+(L-Zt),Me=$e+de,L=Me-$e,ct=$e-(Me-L)+(de-L),de=ct-ft,L=ct-de,ue[1]=ct-(de+L)+(L-ft),pt=Me+de,L=pt-Me,ue[2]=Me-(pt-L)+(de-L),ue[3]=pt;let lG=M(4,W,4,ue,Q);$e=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-($e-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,Zt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Zt,L=dt-de,ue[0]=dt-(de+L)+(L-Zt),Me=$e+de,L=Me-$e,ct=$e-(Me-L)+(de-L),de=ct-ft,L=ct-de,ue[1]=ct-(de+L)+(L-ft),pt=Me+de,L=pt-Me,ue[2]=Me-(pt-L)+(de-L),ue[3]=pt;let uG=M(lG,Q,4,ue,le);$e=_*X,z=A*_,Y=z-(z-_),ie=_-Y,z=A*X,re=z-(z-X),ge=X-re,dt=ie*ge-($e-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,Zt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Zt,L=dt-de,ue[0]=dt-(de+L)+(L-Zt),Me=$e+de,L=Me-$e,ct=$e-(Me-L)+(de-L),de=ct-ft,L=ct-de,ue[1]=ct-(de+L)+(L-ft),pt=Me+de,L=pt-Me,ue[2]=Me-(pt-L)+(de-L),ue[3]=pt;let cG=M(uG,le,4,ue,ke);return ke[cG-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)>=D*U?V:-ve(O,T,k,R,E,I,U)}let j=(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 j(E,R)/te(E)/te(R)},xe=(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)},Le=(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)},cr=(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 Le(k,R,O.y);if(R.y===0)return Le(O,T,k.y);let E=j(T,R);if(E==0)return null;let I={x:k.x-O.x,y:k.y-O.y},H=j(I,T)/E,_=j(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 _e{static compare(T,k){let R=_e.comparePoints(T.point,k.point);return R!==0?R:(T.point!==k.point&&T.link(k),T.isLeft!==k.isLeft?T.isLeft?1:-1:Qt.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:xe(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 Qt{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,_=_e.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 _e(E,!0),U=new _e(I,!1);return new Qt(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=y(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=cr(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 _e(T,!0),I=new _e(T,!1),H=this.rightSE;this.replaceRightSE(I),k.push(I),k.push(E);let _=new Qt(E,H,this.rings.slice(),this.windings.slice());return _e.comparePoints(_.leftSE.point,_.rightSE.point)>0&&_.swapEvents(),_e.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=Qt.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 od{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(Qt.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(Qt.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 Cy{constructor(T,k){if(!Array.isArray(T))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new od(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 od(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 id{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 Cy(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 sd{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 sd(ge.reverse()));continue}L.push({index:U.length,point:_.point});let ie=_.getLeftmostComparator(H);V=z.sort(ie)[0].otherSE;break}k.push(new sd(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];_e.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 gS{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 rG{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 gS(I));else{let H=I.enclosingRing();H.poly||k.push(new gS(H)),H.poly.addInterior(I)}}return k}}class oG{constructor(T){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt.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=_e.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 bS=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,iG=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class sG{run(T,k,R){pn.type=T,S.reset();let E=[new id(k,!0)];for(let L=0,z=R.length;L<z;L++)E.push(new id(R[L],!1));if(pn.numMultiPolys=E.length,pn.type==="difference"){let L=E[0],z=1;for(;z<E.length;)y(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(y(Y.bbox,E[ie].bbox)===null)return[]}let I=new l(_e.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>bS)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}let H=new oG(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>bS)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(H.segments.length>iG)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=sd.factory(H.segments);return new rG(U).getGeom()}}let pn=new sG;var aG={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 aG}))});function cl(){let e=[];return{onRelease(t){e?e.push(t):t()},release(){let t=e;e=null;for(let n of t??[])n()}}}var ad=class extends Error{constructor(n,r){super(`shader ${n} failure: ${r}`);this.stage=n;this.log=r;this.name="ShaderCompileError"}stage;log},ld=0,to=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,ld,"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 ad("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 ad(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 xS=`#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
|
-
`,
|
|
13
|
+
`,wS=`#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
|
-
`,
|
|
25
|
+
`,PS=`#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
|
-
`,
|
|
38
|
+
`,TS=`#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(${
|
|
52
|
+
`,Fy=["u_proj","u_model","u_origin","u_color","u_alpha","u_colorMatrix","u_colorBias"],SS=["a_position"],kS=["a_position","a_vertexColor"];var dl=e=>typeof e=="number"&&Number.isFinite(e);function vS(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(!dl(t.ascent)||!dl(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||!dl(u[i])||!dl(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(!dl(i)||i<=0)throw new Error(`parseBmFont: malformed faceMetrics.${o}`);n[o]=i}}return Object.keys(n).length>0?n:void 0}function ei(e){return e.outlineFace?.faceMetrics??e.entry?.font.faceMetrics}function AS(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=vS(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 as={family:"",weight:NaN,style:"",key:""};function ls(e,t,n){return as.family===e&&as.weight===t&&as.style===n||(as={family:e,weight:t,style:n,key:`${e}|${t}|${n}`}),as.key}var RS=new Map;function no(e,t){let n=RS.get(t);n===void 0&&RS.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 Ce(){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=Ce(),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 en(){try{return!1}catch{return!0}}function us(e){return e===Object.prototype||e===null||Object.getPrototypeOf(e)===null}function tn(e){return typeof e=="object"&&e!==null&&us(Object.getPrototypeOf(e))}function ro(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)=>ro(o,t[i],n));if(!tn(e)||!tn(t))return!1;if(n.undefinedAsAbsent)return[...new Set([...Object.keys(e),...Object.keys(t)])].every(o=>ro(e[o],t[o],n));let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(o=>Object.hasOwn(t,o)&&ro(e[o],t[o],n))}function ud(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 NS=Ce(),Ly=0;function ti(){return Ly}var IS=0;function fl(){return IS}function bn(){Ly++,IS++,NS.emit()}function ES(){Ly++,NS.emit()}var wG="substitute",PG=null;function cs(){return wG}function pl(){return PG}var _y=new Set;function oo(e){return _y.has(e)?!1:(_y.add(e),!0)}function MS(e){return _y.has(e)}var hl=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}},cd=new hl({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)}),dd=new hl({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)}),ml=new hl({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 CS(e,t,n,r,o,i){cd.blit(e,t,n,r,o,i)}function OS(e,t,n,r,o,i){dd.blit(e,t,n,r,o,i)}function FS(e,t,n,r,o,i){ml.blit(e,t,n,r,o,i)}function LS(){cd.clear(),dd.clear(),ml.clear()}function _S(){ml.clear()}function fd(e){return cd.textureId(e)}function pd(e){return dd.textureId(e)}function hd(e){return ml.textureId(e)}function md(e,t){return cd.sync(e,t)}function yd(e,t){return dd.sync(e,t)}function gd(e,t){return ml.sync(e,t)}var bd=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 DS(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 BS(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];DS(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];DS(r,o,i,s,t);for(let l=0;l<t;l++)e[a*t+l]=o[l]}}function HS(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}BS(s,t,n,u,c,d,f),BS(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]),y=Math.round(255-255*(m/r+o));p[h]=y<0?0:y>255?255:y}return p}var ds=8,VS=.5,ri=16,ni=()=>({packer:new bd(1024,4),settled:!0,reclaimScheduled:!1}),Gy=ni(),Uy=ni(),yl=ni(),Gn=[],Dy=!1,By=ri,Hy=0,zS=()=>{},Wy=()=>{},GS=new Set;function KS(e){zS=e}function jS(e){Wy=e}function fs(e,t,n=!1){if(Hy++,t.width===0||t.height===0){e.page=0;return}By>0?(By--,YS(e,t,n)):(Gn.push({char:e,raster:t,sharp:n}),qS())}function $S(e){Gn=Gn.filter(t=>!e.has(t.char))}function YS(e,t,n){let r="rgba"in t,o=n?yl:r?Uy:Gy,i=o.packer.alloc(t.width,t.height);if(!i){TG(o,t,n?kG:SG);return}if(r&&n)FS(i.page,i.x,i.y,t.width,t.height,t.rgba);else if(r)OS(i.page,i.x,i.y,t.width,t.height,t.rgba);else{let s=HS(t.alpha,t.width,t.height,ds,VS);CS(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 TG(e,t,n){if(!e.packer.fits(t.width,t.height))US("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===yl)return;US(`weasel DynamicGlyphAtlas: more glyphs are in use at once than its pages hold (${4} \xD7 ${1024}\xB2); the rest will not render.`)}}function US(e){GS.has(e)||(GS.add(e),console.warn(e))}function SG(){Gy={...ni(),settled:!1},Uy={...ni(),settled:!1},yl={...ni(),settled:!1},Gn=[],LS(),zS(),Wy(),bn()}function kG(){yl={...ni(),settled:!1},Gn=Gn.filter(e=>!e.sharp),_S(),Wy(),bn()}function qS(){Dy||(Dy=!0,setTimeout(vG,0))}function vG(){Dy=!1;let e=0;for(;Gn.length>0&&e<ri;){let t=Gn.shift();t.char.page===-1&&(YS(t.char,t.raster,t.sharp),e++)}Gn.length>0&&qS(),ES()}function xd(e=ri){By=e,Hy===0&&Gn.length===0&&(Gy.settled=!0,Uy.settled=!0,yl.settled=!0),Hy=0}function Vy(e){return e.trim().replace(/^(["'])(.*)\1$/,"$2").toLowerCase()}function XS(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 JS(e){return/[,"']/.test(e)?e:AG.has(e.trim().toLowerCase())?e.trim():JSON.stringify(e)}var AG=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]);var Ge=48,nn=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 NG=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)<NG&&(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 wd=1e3;function EG(e,t,n,r=Ge){return`${t==="italic"?"italic ":""}${e} ${r}px ${JS(n)}`}function QS(){let e;if(typeof OffscreenCanvas<"u")e=new OffscreenCanvas(Ge*3,Ge*3);else if(typeof document<"u")e=document.createElement("canvas"),e.width=Ge*3,e.height=Ge*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=Ge){t.font=EG(i,s,o,a),t.textBaseline="alphabetic",t.textAlign="left"}function r(o,i,s,a,l=Ge){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,y=p+h;if(m<=0||y<=0)return{data:new Uint8ClampedArray(0),width:0,height:0,left:0,top:0,advance:c};let b=m+2*nn,x=y+2*nn;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,nn+d,nn+p),{data:t.getImageData(0,0,b,x).data,width:b,height:x,left:-(d+nn),top:p+nn,advance:c}}return{faceMetrics(o,i,s){n(o,i,s,wd);let a=t.measureText("Hg"),l=Ge/wd;return{ascent:(a.fontBoundingBoxAscent??wd*.8)*l,descent:(a.fontBoundingBoxDescent??wd*.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*Ge),d=Math.floor(s*Ge),f=Math.ceil(a*Ge)-c+2*nn,p=Math.ceil(l*Ge)-d+2*nn;(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(Ge,0,0,Ge,nn-c,nn-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 y=0;y<m.length;y++)m[y]=h[y*4+3];return{width:f,height:p,alpha:m,left:c-nn,top:nn-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 zy=3,Ky=new WeakMap,Pd=0;jS(()=>{Pd++});function ZS(e,t,n){Ky.set(e,{raster:n,base:t,levels:[],generation:Pd})}function jy(e){return e.generation!==Pd&&(e.levels=[],e.generation=Pd),e.levels}function ek(e){let t=Ky.get(e);return t?jy(t).flatMap(n=>n?[n.glyph]:[]):[]}function MG(e,t){let n=jy(e),r=n[t];if(r!==void 0)return r;let o=2**t,i=e.raster(Ge*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&&fs(s.glyph,i,!0),s}function Td(e,t){let n=Ky.get(e);if(!n||!(t>1))return null;let r=Math.min(zy,Math.ceil(Math.log2(t)));MG(n,r);let o=jy(n);for(let i=r;i>0;i--){let s=o[i];if(s&&s.glyph.page>=0)return s}return null}var Sd=new Set,kd=new Set,vd=new Map,$y=null,CG=null;function tk(e){e.font.charMap.clear(),e.font.chars.length=0,e.clusters.clear(),e.shaped.clear()}KS(()=>{for(let e of vd.values())tk(e)});function nk(){return $y||($y=QS()),$y}function Ad(e){return Sd.has(e)?!kd.has(e)||cs()==="canvas":!1}function rk(e){Sd.has(e)&&!kd.has(e)||(Sd.add(e),kd.add(e))}function Yy(e){return Sd.has(e)&&!kd.has(e)}function Rd(e,t,n){let r=`${e}|${t}|${n}`,o=vd.get(r);if(o)return o;let i=nk(),s={info:{face:e,size:Ge},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),fs(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&&(fs(h,p),ZS(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&&fs(m,h),m}};return ok(c),vd.set(r,c),CG??=XS(OG),c}function ok(e){let{font:t}=e,n=nk().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/Ge,descent:n.descent/Ge},tk(e)}function OG(e){let t=e&&new Set(e.map(Vy)),n=new Set,r=0;for(let o of vd.values())if(!(t&&!o.family.split(",").some(i=>t.has(Vy(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 ek(i))n.add(s)}ok(o),r++}r!==0&&($S(n),bn())}var fr=xt(),FG=fr.reflection;function oi(e,t,n){return`${e}|${t}|${n}`}function LG(e){return{weight:e.weight??400,style:e.style??"normal"}}function qy(e,t=400,n="normal"){return fr.has(oi(e,t,n))}function Xy(e,t=400,n="normal"){return fr.get(oi(e,t,n))?.status??null}function _G(e){let t="",n=0;for(let r=1;r<e.length;r++){let o=e[r];o!=="M"&&o!=="m"||(t+=ik(e.slice(n,r)),n=r)}return t+ik(e.slice(n))}function ik(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 Jy(e,t,n,r){let o=fr.get(oi(e,t,n));if(!o)return null;if(o.status==="idle")return Zy(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:_G(a)}catch(a){ak(`glyph|${oi(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 gl(e,t,n){let r=fr.get(oi(e,t,n));return r?r.status==="idle"?(Zy(r),null):r.status==="ready"?r.face:null:null}async function Qy(e,t={}){let{weight:n,style:r}=LG(t),o=fr.get(oi(e,n,r));return o?(await Zy(o),o.status):null}function Zy(e){return e.load??=DG(e),e.load}async function DG(e){e.status="loading",fr.bump();try{let t=await GG(e.source);HG(e,t),e.face=await e.parser(t),e.status="ready",fr.bump(),bn()}catch(t){e.status="failed",fr.bump(),bn(),ak(`load|${oi(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 BG=null;function HG(e,t){try{BG?.(e,t)}catch{}}async function GG(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 sk=new Set;function ak(e,t){sk.has(e)||(sk.add(e),console.warn(t))}function io(e,t,n,r,o,i){return{entry:e,resolved:{family:t,weight:n,style:r},synthetic:{bold:o,italic:i},source:"atlas"}}var lk=new WeakMap;function uk(e,t,n,r){let o=lk.get(e);if(o!==void 0&&o.resolved.family===t&&o.resolved.weight===n&&o.resolved.style===r)return o;let i=io(e,t,n,r,!1,!1);return Object.freeze(i.resolved),Object.freeze(i.synthetic),lk.set(e,Object.freeze(i)),i}var Ht=xt(),WG=Ht.reflection;function VG(e){return{weight:e.weight??400,style:e.style??"normal"}}var bl=new Map,so=new Map,ps=new Map,tg=new Set;function xl(e,t=400,n="normal"){return Ht.get(e)?.get(no(t,n))??null}function fk(e,t,n,r){let o=`${e}|${t}`,i=so.get(o);if(i)return i;let s=zG(e,t,n,r);so.set(o,s);let a=()=>{so.get(o)===s&&so.delete(o)};s.then(a,a);let l=ps.get(e)?.get(t);if(l){let u=ps.get(e);u.delete(t),u.size===0&&ps.delete(e),l.settle(s)}return s}async function zG(e,t,n,r){let[o,i]=t.split("|"),s={},a=bl.get(e)??new Set;bl.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=AS(c),p=await createImageBitmap(d);Ht.set(e,new Map(Ht.get(e)).set(t,{font:f,bitmap:p})),ck(e,s),bn()}catch(l){throw ck(e,s),bn(),new Error(`weasel registerFont("${e}" ${o}/${i}): ${l instanceof Error?l.message:String(l)}`)}}function pk(e,t,n){let r=ps.get(e);if(!r)return;let o=no(t,n),i=r.has(o)?[o]:[...r.keys()];for(let s of i){let{metricsUrl:a,atlasUrl:l}=r.get(s);fk(e,s,a,l).catch(()=>{})}}function ng(e){let t=[];for(let n of e??[...tg]){if(typeof n!="string"){let{weight:r,style:o}=VG(n);t.push(...mk(n.family,r,o));continue}if(!tg.has(n))return Promise.reject(new Error(`weasel warmFonts: "${n}" was never registered.`));for(let[r,{metricsUrl:o,atlasUrl:i}]of[...ps.get(n)??[]])fk(n,r,o,i);t.push(...hk(n))}return Promise.all(t).then(()=>{})}function hk(e){return[...so].filter(([t])=>t.startsWith(`${e}|`)).map(([,t])=>t)}function mk(e,t,n){let r=[],o=qy(e,t,n);o&&r.push(Qy(e,{weight:t,style:n}));let i=no(t,n);if(Ht.get(e)?.has(i))return r;pk(e,t,n);let s=so.get(`${e}|${i}`);if(s)return[...r,s];if(Ht.has(e)||hs(e))return[...r,...hk(e)];if(o||Yy(e)||cs()!=="substitute")return r;let a=pl()??yk();return a!==null&&a!==e?[...r,...mk(a,t,n)]:r}function hs(e){return bl.has(e)||ps.has(e)}function ck(e,t){let n=bl.get(e);n?.delete(t)&&n.size===0&&bl.delete(e)}function Id(e,t=400,n="normal"){if(hs(e))return!0;let r=Xy(e,t,n==="italic"?"italic":"normal");return r==="idle"||r==="loading"}function rg(e,t,n,r){let o=xl(e,t,n);return o?(r.upload(ls(e,t,n),o.bitmap),!0):!1}function dk(e,t,n,r=!1){if(Yy(e))return{entry:null,dynamicFace:Rd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"};let o=gl(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(Id(e,t,n))return Nd(e,t,n);let i=cs();if(i==="canvas")return rk(e),{entry:null,dynamicFace:Rd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"};if(i==="substitute"){let s=pl()??yk();if(s!==null&&s!==e){if(Ht.has(s)||Ad(s)||hs(s)){let a=gk(s,t,n,!0,!1);if(a.entry!==null||a.dynamicFace!==void 0)return r||KG(e,t,n,s),{...a,substituted:{requested:e,resolved:s}};if(hs(s))return Nd(e,t,n)}r||jG(e,t,n,s)}else s===e&&!r&&(Ht.has(e)?$G(e,t,n):YG(e,t,n))}return{entry:null,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"atlas"}}function yk(){for(let e of tg)if(Ht.has(e)||hs(e))return e;return null}function Nd(e,t,n){return{entry:null,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"atlas"}}function KG(e,t,n,r){if(!oo(`substituted|${e}|${t}|${n}`))return;let o=Ht.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 jG(e,t,n,r){if(!oo(`unusable-default|${e}|${t}|${n}`))return;let o=pl()===r?"set via setDefaultFontFamily":"the first registered family, since setDefaultFontFamily was never called",i=Ht.has(r)||Ad(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(!oo(`self-unusable-default|${e}|${t}|${n}`))return;let r=pl()===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 YG(e,t,n){oo(`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 eg(e){return e>=600?"bold":"regular"}function xn(e,t,n){return gk(e,t,n,!1,!0)}function Ed(e,t,n){if(cs()==="none")return null;try{return{entry:null,dynamicFace:Rd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"}}catch{return null}}function gk(e,t,n,r,o){pk(e,t,n);let i=no(t,n);if(so.size>0&&so.has(`${e}|${i}`)&&!Ht.get(e)?.has(i))return Nd(e,t,n);let s=Ht.get(e);if(!s||s.size===0)return hs(e)?Nd(e,t,n):dk(e,t,n,r);let a=s.get(i);if(a)return o?uk(a,e,t,n):io(a,e,t,n,!1,!1);let l=eg(t),u=null;for(let[h,m]of s){let[y,b]=h.split("|"),x=Number(y);if(b!==n||eg(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 io(u.entry,e,u.weight,n,!1,!1);let c=s.get(no(400,n));if(c)return io(c,e,400,n,t>=600,!1);let d=s.get(no(t,"normal"));if(d)return io(d,e,t,"normal",!1,n==="italic");let f=null;for(let[h,m]of s){let[y,b]=h.split("|"),x=Number(y);if(b!=="normal"||eg(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 io(f.entry,e,f.weight,"normal",!1,n==="italic");let p=s.get(no(400,"normal"));return p?io(p,e,400,"normal",t>=600,n==="italic"):dk(e,t,n,r)}var qG=[[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 bk(e){return qG.some(([t,n])=>e>=t&&e<=n)}function ig(e){return e.xadvance>0||e.width>0||e.page<0||bk(e.id)}function wk(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 XG(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 JG(e){return wk(e.font,t=>{let n=e.requestGlyph(t);return ig(n)?n.xadvance:null})}var xk=new WeakMap;function og(e,t){let n=xk.get(e);return n||(n=t(e),xk.set(e,n)),n}function ms(e){if(e.outlineFace)return og(e.outlineFace,XG);if(e.entry)return og(e.entry.font,t=>wk(t,n=>t.charMap.get(n)?.xadvance??null));if(e.dynamicFace)return og(e.dynamicFace,JG)}var QG=/\p{Emoji_Presentation}|\p{Extended_Pictographic}\uFE0F|\uFE0F\u20E3/u;function Pk(e){return e.length===1&&e.charCodeAt(0)<8986?!1:QG.test(e)&&!e.includes("\uFE0E")}function Tk(e,t){if(!oo(`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 ZG=["unusable-default","self-unusable-default","unregistered-default"];function sg(e,t,n){if(Id(e,t,n))return;let r=`${e}|${t}|${n}`;ZG.some(o=>MS(`${o}|${r}`))||oo(`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 wl(e,t,n){let r=ms(e);if(!r)return null;if(e.outlineFace){let a=r.advanceOf(t);return a===null?null:Sk(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&&!ig(s)?null:Sk(n,e,r,s.xadvance,i,s)}function Sk(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 Pl(e,t,n,r,o,i=!0,s){let a=wl(e,o,s);if(a)return a;let l=Ed(t,n,r),u=l&&wl(l,o,s);return u||(i&&Tk(e.resolved.family,o),null)}function ag(e,t,n,r,o){if(!Pk(o))return null;let i=e.dynamicFace?e:Ed(t,n,r),s=i?.dynamicFace,a=i&&ms(i),l=s?.requestCluster(o);return!i||!s||!a||!l?null:{resolved:i,metrics:a,advance:l.xadvance,font:s.font,glyph:l}}var lg=1,ug=2,kk=.2,eU=.3,Cd=1;function cg(e,t,n){return .5*(e[0]/t+e[1]/n)>kk*.9}var tU=`
|
|
53
|
+
float area = smoothstep(${kk.toFixed(2)}, ${eU.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
|
-
}`,
|
|
65
|
+
}`,nU=`
|
|
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
|
-
`,
|
|
70
|
+
`,rU=`
|
|
71
71
|
vec2 dcx = dFdx(cell);
|
|
72
72
|
vec2 dcy = dFdy(cell);
|
|
73
|
-
vec2 margin = ${
|
|
73
|
+
vec2 margin = ${Cd.toFixed(1)} * vec2(length(vec2(dcx.x, dcy.x)), length(vec2(dcx.y, dcy.y)));`;function vk(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?
|
|
81
|
+
${e?nU:""}
|
|
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?
|
|
84
|
+
vec2 dv = dFdy(uv);${e?rU:""}
|
|
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?
|
|
89
|
+
float coverage = smoothstep(threshold - aaW, threshold + aaW, field)${e?" * glyphInCell(cell, margin)":""};${e?tU:""}
|
|
90
90
|
return coverage;
|
|
91
91
|
}
|
|
92
|
-
`}var
|
|
92
|
+
`}var Sl=vk(!0),dg=vk(!1),Ak=4,oU=[1024/ds,1024/ds];function fg(e,t,n,r){if(e==="canvas")return oU;let o=xl(t,n,r)?.font;if(!o)return;let i=o.distanceRange??Ak,s=o.common.scaleW/i,a=o.common.scaleH/i;return(Md[0]!==s||Md[1]!==a)&&(Md=[s,a]),Md}var Md=[NaN,NaN],Tl=.08;function pg(e,t,n,r){if(e==="canvas")return Tl*ds/Ge;let o=xl(t,n,r)?.font;if(o)return Tl*(o.distanceRange??Ak)/o.info.size}var Od=`
|
|
93
93
|
vec3 straightRgb(vec4 premultiplied) {
|
|
94
94
|
return premultiplied.rgb / max(premultiplied.a, 0.0001);
|
|
95
95
|
}
|
|
96
|
-
`;
|
|
97
|
-
uniform ivec4 u_hullPlanes[${
|
|
96
|
+
`;Z();var yo=8,Ms=64,df=16,vn=df,VA=2**24,Ab=16384,ff=32768,Es=Ab,vb=ff;function $A(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 zA=new WeakMap;function Rb(e,t,n){let r=zA.get(e);if(r!==void 0&&dW(r.m,t)&&fW(r.map,n))return r.hull;let o=pW(e,t,n);return zA.set(e,{m:Float64Array.of(t[0],t[1],t[3],t[4],t[6],t[7]),map:n,hull:o}),o}var KA=new WeakMap;function YA(e,t,n){if(n.bx!==0||n.ay!==0)return null;let r=Rb(e,t,n);if(r===null)return null;let o=KA.get(r);return o===void 0&&(o={rect:cW(r.path),hull:r},KA.set(r,o)),o}function cW(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 dW(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 fW(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 pW(e,t,n){let r=Ib(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)<VA&&Math.abs(d)<VA))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;xr(o)<0&&Eb(o);let i=Mb(o),s=bW(i.length>=6?i:o,n);return i.length<6?{set:qA,path:s}:i.length/2>yo||!Cb(i)?null:{set:gW(i,n),path:s}}var qA={planes:Int32Array.of(0,0,-1,cf(0,0)),count:1},hW={planes:Int32Array.of(0,0,0,cf(0,0)),count:1};function Nb(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 qA;continue}let s=mW(n,i[0],i[1]);s<0?n.push(i[0],i[1],i[2],i[3]):jA(i,0)>jA(n,s)&&n.splice(s,4,i[0],i[1],i[2],i[3])}return n.length===0?hW:n.length/4>yo?null:{planes:Int32Array.from(n),count:n.length/4}}function mW(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 jA(e,t){let n=e[t],r=e[t+1],o=e[t+3],i=o%vb-Es,s=Math.floor(o/vb)-Es,a=e[t+2]-vn*(n*i+r*s);return Math.ceil(-a/yW(Math.abs(n),Math.abs(r)))}function yW(e,t){for(;t!==0;)[e,t]=[t,e%t];return e}function Ib(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]!==se||t[t.length-1]!==fe)return null;for(let i=1;i<t.length-1;i++)if(t[i]!==ae)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 Eb(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 XA(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 Mb(e){let t=[],n=e.length;for(let r=0;r<n;r+=2)XA(e,(r-2+n)%n,r,(r+2)%n)!==0&&t.push(e[r],e[r+1]);return t}function Cb(e){let t=e.length,n=0,r=0;for(let o=0;o<t;o+=2){if(XA(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 cf(e,t){return e+Es+(t+Es)*vb}function gW(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),y=Math.round((l+h*c)/vn),b;Math.abs(m)<Es&&Math.abs(y)<Es?b=[d,f,d*(vn*m-a)+f*(vn*y-l)-p,cf(m,y)]:b=[0,0,d*(o-a)+f*(i-l)>=p?0:-1,cf(0,0)],r.set(b,s*4)}return{planes:r,count:n}}function bW(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 Ig(r)}var JA=(2**30).toFixed(1),QA=`
|
|
97
|
+
uniform ivec4 u_hullPlanes[${Ms}];
|
|
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 < ${
|
|
102
|
+
for (int k = 0; k < ${yo}; k++) {
|
|
103
103
|
if (k >= v_hullCount) break;
|
|
104
104
|
ivec4 p = u_hullPlanes[v_hullStart + k];
|
|
105
|
-
ivec2 origin = ivec2(p.w % ${
|
|
106
|
-
ivec2 d = (pixel - origin) * ${
|
|
105
|
+
ivec2 origin = ivec2(p.w % ${ff}, p.w / ${ff}) - ${Ab};
|
|
106
|
+
ivec2 d = (pixel - origin) * ${df} + ${df/2};
|
|
107
107
|
float estimate = float(p.x) * float(d.x) + float(p.y) * float(d.y) + float(p.z);
|
|
108
|
-
if (estimate < -${
|
|
109
|
-
if (estimate < ${
|
|
108
|
+
if (estimate < -${JA}) return 0.0;
|
|
109
|
+
if (estimate < ${JA}) {
|
|
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
|
|
116
|
+
`;var ZA=[0,2,6,4],pf=`
|
|
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
|
|
122
|
-
`)}function
|
|
123
|
-
layout(location = ${
|
|
124
|
-
layout(location = ${
|
|
125
|
-
layout(location = ${
|
|
126
|
-
layout(location = ${
|
|
127
|
-
layout(location = ${
|
|
121
|
+
`;var yt=16,eR=0,Cs=yt-1,Kn=8,tR=8,Ob=yt*tR,nR=Ob*Kn,yi=0,rR=3,hf=4,Os=5,xW=(1/(2*Math.PI)).toFixed(10);function gi(e,t){return e+yt*t}function go(e,t){return e+Ob*t}function oR(e,t,n){return e+nR*(1+t*yo+n-1)}var Fb={a_position:0,a_vertexColor:1,a_uv:2,a_post:3,a_texSlot:4},ql=Fb;function mf(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}) {`,mf(e,o-1,n,`${r} `),`${r}} else {`,mf(o,t,n,`${r} `),`${r}}`].join(`
|
|
122
|
+
`)}function iR(e){return`#version 300 es
|
|
123
|
+
layout(location = ${ql.a_position}) in vec2 a_position;
|
|
124
|
+
layout(location = ${ql.a_vertexColor}) in vec4 a_vertexColor;
|
|
125
|
+
layout(location = ${ql.a_uv}) in vec2 a_uv;
|
|
126
|
+
layout(location = ${ql.a_post}) in float a_post;
|
|
127
|
+
layout(location = ${ql.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;${
|
|
138
|
+
out vec2 v_cell;${pf}`:""}
|
|
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 % ${
|
|
150
|
-
v_paintMode = float((packed / ${
|
|
151
|
-
v_matrix = (packed / ${
|
|
152
|
-
int hull = packed / ${
|
|
153
|
-
v_hullStart = hull == 0 ? 0 : (hull - 1) / ${
|
|
154
|
-
v_hullCount = hull == 0 ? 0 : (hull - 1) % ${
|
|
149
|
+
v_texSlot = packed % ${yt};
|
|
150
|
+
v_paintMode = float((packed / ${yt}) % ${tR});
|
|
151
|
+
v_matrix = (packed / ${Ob}) % ${Kn};
|
|
152
|
+
int hull = packed / ${nR};
|
|
153
|
+
v_hullStart = hull == 0 ? 0 : (hull - 1) / ${yo};
|
|
154
|
+
v_hullCount = hull == 0 ? 0 : (hull - 1) % ${yo} + 1;${e?wW:""}
|
|
155
155
|
}
|
|
156
|
-
`}var
|
|
156
|
+
`}var wW=`
|
|
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;`,
|
|
160
|
+
v_post = cell.z;`,Xl=iR(!1),sR=iR(!0),PW=`vec4 glyphTap(vec2 uv) {
|
|
161
161
|
int slot = v_texSlot;
|
|
162
|
-
${
|
|
162
|
+
${mf(1,yt-1,"textureLod(%s, uv, 0.0)")}
|
|
163
163
|
return vec4(0.0);
|
|
164
|
-
}`;function
|
|
164
|
+
}`;function Jl(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[${
|
|
174
|
+
uniform sampler2D u_samplers[${yt}];
|
|
175
175
|
uniform vec4 u_color;
|
|
176
176
|
uniform float u_alpha[${e}];
|
|
177
|
-
uniform vec2 u_fieldScale[${
|
|
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
|
-
${
|
|
183
|
+
${mf(0,yt-1,"texture(%s, uv)")}
|
|
184
184
|
// Never reached: every slot returns above.
|
|
185
185
|
return vec4(0.0);
|
|
186
186
|
}
|
|
187
|
-
${n?
|
|
188
|
-
${n?
|
|
189
|
-
${
|
|
190
|
-
${t?
|
|
187
|
+
${n?PW:""}
|
|
188
|
+
${n?Sl:dg}
|
|
189
|
+
${Od}
|
|
190
|
+
${t?QA:""}
|
|
191
191
|
void main() {
|
|
192
|
-
float isGrad = step(2.5, v_paintMode) * step(v_paintMode, ${
|
|
192
|
+
float isGrad = step(2.5, v_paintMode) * step(v_paintMode, ${hf+.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 > ${
|
|
208
|
-
? fract(atan(v_uv.y, v_uv.x) * ${
|
|
207
|
+
float t = v_paintMode > ${hf-.5}
|
|
208
|
+
? fract(atan(v_uv.y, v_uv.x) * ${xW})
|
|
209
209
|
: length(v_uv);
|
|
210
|
-
texel = texture(u_samplers[${
|
|
210
|
+
texel = texture(u_samplers[${Cs}], 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(${
|
|
215
|
+
texel.rgb = mix(texel.rgb, straightRgb(texel), step(${Os-.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
|
|
229
|
+
`}var aR=Jl(1),lR=Jl(Kn),uR=Jl(1,!0),cR=Jl(Kn,!0);function dR(e,t){return Jl(e?Kn:1,t,!0)}var Ql=["u_proj","u_model","u_samplers","u_color","u_alpha","u_fieldScale","u_colorMatrix","u_colorBias"],yf=[...Ql,"u_hullPlanes"],Fs=["a_position","a_vertexColor","a_uv","a_post","a_texSlot"];var fR=`#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
|
-
`,
|
|
243
|
+
`,Lb=`
|
|
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
|
-
`,
|
|
278
|
+
`,pR=`#version 300 es
|
|
279
279
|
precision highp float;
|
|
280
280
|
in vec2 v_world;
|
|
281
|
-
${
|
|
281
|
+
${Lb}
|
|
282
282
|
out vec4 outColor;
|
|
283
283
|
void main() {
|
|
284
284
|
outColor = shadePaint(v_world);
|
|
285
285
|
}
|
|
286
|
-
`,
|
|
286
|
+
`,gf=["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"],hR=["a_position"];var mR=`#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
|
-
|
|
300
|
+
`,_b=`
|
|
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
|
-
${
|
|
307
|
+
${Od}
|
|
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
|
-
`,
|
|
315
|
+
`,yR=`#version 300 es
|
|
316
316
|
precision highp float;
|
|
317
317
|
in vec2 v_world;
|
|
318
|
-
${
|
|
318
|
+
${_b}
|
|
319
319
|
out vec4 outColor;
|
|
320
320
|
void main() {
|
|
321
321
|
outColor = shadePaint(v_world);
|
|
322
322
|
}
|
|
323
|
-
`,
|
|
324
|
-
layout(location = ${
|
|
325
|
-
layout(location = ${
|
|
326
|
-
layout(location = ${
|
|
327
|
-
layout(location = ${
|
|
323
|
+
`,bf=["u_proj","u_model","u_origin","u_worldInv","u_sampler","u_tileSize","u_opacity","u_alpha","u_colorMatrix","u_colorBias"],gR=["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 to(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}},bR={vert:xS,frag:wS,uniforms:Fy,attributes:SS},xR={vert:PS,frag:TS,uniforms:Fy,attributes:kS},wR={vert:fR,frag:pR,uniforms:gf,attributes:hR},TW={vert:Xl,frag:lR,uniforms:Ql,attributes:Fs},SW={vert:Xl,frag:uR,uniforms:yf,attributes:Fs},kW={vert:Xl,frag:cR,uniforms:yf,attributes:Fs},PR={vert:mR,frag:yR,uniforms:bf,attributes:gR};function Db(e){let t=new to(e,Xl,aR);return t.lookupUniforms(Ql),t.lookupAttributes(Fs),t}var xf=class{hulls;cuts=!0;matrices;hull;matricesHull;area;constructor(t){this.hulls=t.getParameter(t.SAMPLES)===0,this.matrices=new An(t,TW),this.hull=new An(t,SW),this.matricesHull=new An(t,kW),this.area=[!1,!0].flatMap(n=>[!1,!0].map(r=>new An(t,{vert:sR,frag:dR(r,n),uniforms:n?yf:Ql,attributes:Fs})))}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 wf=Fb,TR=`#version 300 es
|
|
324
|
+
layout(location = ${wf.a_position}) in vec2 a_position;
|
|
325
|
+
layout(location = ${wf.a_uv}) in vec2 a_uv;
|
|
326
|
+
layout(location = ${wf.a_post}) in float a_post;
|
|
327
|
+
layout(location = ${wf.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
|
-
${
|
|
335
|
+
${pf}
|
|
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) / ${
|
|
342
|
+
v_glyphMode = float(int(a_texSlot + 0.5) / ${yt});
|
|
343
343
|
v_cell = glyphCellOf(a_post).xy;
|
|
344
344
|
}
|
|
345
|
-
`;function
|
|
345
|
+
`;function Bb(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
|
-
${
|
|
358
|
+
${Sl}
|
|
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
|
|
364
|
+
`}var vW=`
|
|
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
|
+
`,SR=Bb(_b),kR=Bb(Lb),vR=Bb(vW),Hb=["u_atlas","u_synthBold","u_fieldScale"],AR=e=>e!=="u_origin",RR=[...bf.filter(AR),...Hb],NR=[...gf.filter(AR),...Hb],IR=["u_proj","u_model","u_worldInv","u_sampler",...Hb],ER=["a_position","a_uv","a_post","a_texSlot"];var Pf=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,MR(t)),i=Math.max(r?.height??0,MR(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 MR(e){let t=64;for(;t<e;)t*=2;return t}var Zl=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(ld),n.vertexAttribPointer(ld,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 eu(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 AW(e,t){e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t)}var tu=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,AW)}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),eu(i,n),i.bindTexture(i.TEXTURE_2D,null)}return this.registered.set(t,n),this.ensure(t,n,r,eu)}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 Ls=xt(),xi=Ls.reflection;var bi=[];function Tf(e,t){let n={prefix:e,owner:t};return bi.push(n),()=>{let r=bi.indexOf(n);r!==-1&&bi.splice(r,1)}}function CR(e){return OR(e)!==void 0}function OR(e){for(let t=0;t<bi.length;t++)if(e.startsWith(bi[t].prefix))return bi[t].owner}function _s(e){let t=bi.length>0?OR(e):void 0,n=Ls.get(e);return n?t?.touched?(t.touched(e),Ls.get(e)??null):n:t?(t.revive(e),Ls.get(e)??null):null}function Sf(e,t,n){return Ls.set(e,n?{source:t,size:n}:{source:t}),{id:e}}function kf(e){return Ls.delete(e.id)}var FR=4096,nu=new Set;function vf(e){for(let t of nu)t.release(e)}function LR(e){for(let t of nu)if(t.drewInLatestFrame(e))return!0;return!1}function _R(){let e=1/0;for(let t of nu)e=Math.min(e,t.maxTextureSide);return Number.isFinite(e)?e:FR}var Ds=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:FR,this.finalizer=new FinalizationRegistry(o=>{this.textures.delete(o)&&this.pendingDeletes.push(o)}),nu.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,nu.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),eu(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]=RW(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 RW(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 Pi=256,KW=16,jW=1024;function $W(e,t="rgb"){let n=new Uint8ClampedArray(Pi*4);if(e.length===0)return n;let r=rx(e);for(let o=0;o<Pi;o++){let[i,s,a,l]=ox(r,o/(Pi-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 iN(e,t){return`${t}|${JSON.stringify(e)}`}var au=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=iN(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,$W(t,n)),this.rowByKey.set(r,i),i}wouldReshape(t,n="rgb"){return this.rowByKey.size===0?!1:!this.rowByKey.has(iN(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<jW)return this.resize(this.rows===0?KW: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(Pi*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,Pi,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*Pi*4),r.bindTexture(r.TEXTURE_2D,this.texture),r.texSubImage2D(r.TEXTURE_2D,0,0,t,Pi,1,r.RGBA,r.UNSIGNED_BYTE,n),r.bindTexture(r.TEXTURE_2D,null)}};Z();Z();function sN(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 aN(e,t,n,r,o){return[ys(e[0]*t+e[1]*n+e[2]*r+e[3]*o+e[4]),ys(e[5]*t+e[6]*n+e[7]*r+e[8]*o+e[9]),ys(e[10]*t+e[11]*n+e[12]*r+e[13]*o+e[14]),ys(e[15]*t+e[16]*n+e[17]*r+e[18]*o+e[19])]}var Vt=new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),Bf=class{transformStack=[q.identity()];alphaStack=[1];colorMatrixStack=[Vt];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?sN(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(Vt),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 lN=mt;function uN(e,t){if(typeof e=="number")return e;let n=e?.px??lN,[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 cN(e,t){return typeof e=="number"?e:{px:(e?.px??lN)/t}}Z();var cu=new Set,ix=!1;function Vf(e,t,n=2){let r=t&&t.length,o=r?t[0]*n:e.length;cu.size&&cu.clear();let i=hN(e,0,o,n,!0),s=[];if(!i||i.next===i.prev)return s;let a=0,l=0,u=0;if(r&&(i=QW(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 sx(i,s,a,l,u),s}function hN(e,t,n,r,o){let i=null;if(o===dV(e,t,n,r)>0)for(let s=t;s<n;s+=r)i=pN(s/r|0,e[s],e[s+1],i);else for(let s=n-r;s>=t;s-=r)i=pN(s/r|0,e[s],e[s+1],i);return i&&du(i,i.next)&&(pu(i),i=i.next),i}function Si(e,t=e){let n=t===e,r=e,o;do o=!1,r!==r.next&&(cu.size===0||!cu.has(r))&&(du(r,r.next)||Xe(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),ix=!0,pu(r),r=r.prev,o=!0):(n||r!==t)&&(r=r.next,o=!n);while(o||r!==t);return t}function sx(e,t,n,r,o){o&&iV(e,n,r,o);let i=e,s=!1;for(;e.prev!==e.next;){let a=e.prev,l=e.next;if(Xe(a,e,l)<0&&(o?qW(e,n,r,o):YW(e))){t.push(a.i,e.i,l.i),pu(e),e=l,i=l;continue}if(e=l,e===i){if(ix=!1,e=Si(e),ix){i=e;continue}if(!s){e=XW(e,t),i=e,s=!0;continue}JW(e,t,n,r,o);break}}}function YW(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)&&Wf(o,a,i,l,s,u,h.x,h.y)&&Xe(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function qW(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),y=Math.max(c,d,f),b=cx(p,h,t,n,r),x=cx(m,y,t,n,r),w=e.prevZ;for(;w&&w.z>=b;){if(w.x>=p&&w.x<=m&&w.y>=h&&w.y<=y&&w!==s&&!(a===w.x&&c===w.y)&&Wf(a,c,l,d,u,f,w.x,w.y)&&Xe(w.prev,w,w.next)>=0)return!1;w=w.prevZ}let g=e.nextZ;for(;g&&g.z<=x;){if(g.x>=p&&g.x<=m&&g.y>=h&&g.y<=y&&g!==s&&!(a===g.x&&c===g.y)&&Wf(a,c,l,d,u,f,g.x,g.y)&&Xe(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function XW(e,t){let n=e,r=!1;do{let o=n.prev,i=n.next.next;gN(o,n,n.next,i,!1)&&fu(o,i)&&fu(i,o)&&(t.push(o.i,n.i,i.i),pu(n),pu(n.next),n=e=i,r=!0),n=n.next}while(n!==e);return r?Si(n):n}function JW(e,t,n,r,o){let i=e;do{let s=i.next.next;for(;s!==i.prev;){if(i.i!==s.i&&lV(i,s)){let a=bN(i,s);i=Si(i,i.next),a=Si(a,a.next),sx(i,t,n,r,o),sx(a,t,n,r,o);return}s=s.next}i=i.next}while(i!==e)}var ax=!1;function QW(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=hN(e,a,l,r,!1);u===u.next&&cu.add(u),o.push(aV(u))}o.sort(ZW),tV(e.length/r,t.length),yN(n,n),ax=!0;for(let i=0;i<o.length;i++)n=eV(o[i],n);return ax=!1,Si(n)}function ZW(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 eV(e,t){let n=rV(e,t);if(!n)return t;let r=bN(n,e),o=r.next;return yN(n,o.next),Si(r,r.next),Si(n,n.next)}var mN=16,We=new Float64Array(0),Uf=0,lx=[],ux=[];function tV(e,t){let n=Math.ceil((e+2*t)/mN)+t+2;We.length<n*4&&(We=new Float64Array(n*4)),Uf=0}function yN(e,t){let n=e;do{let r=Uf++;lx[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<mN&&n!==t);ux[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 nV(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 dN(e){let t=ux[e];for(;t.prev.next!==t;)t=t.next;return ux[e]=t,t}function fN(e){let t=lx[e];for(;t.prev.next!==t;)t=t.next;return lx[e]=t,t}function rV(e,t){let n=t,r=e.x,o=e.y,i=-1/0,s;if(du(e,n))return n;for(let f=0,p=0;f<Uf;f++,p+=4){if(o<We[p+1]||o>We[p+3]||We[p]>r||We[p+2]<=i)continue;let h=dN(f);n=fN(f);do{if(n.prev.next===n){if(du(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<Uf;f++,p+=4){if(We[p+2]<a||We[p]>r||We[p+3]<u||We[p+1]>c)continue;let h=dN(f);n=fN(f);do{if(n.prev.next===n&&r>=n.x&&n.x>=a&&r!==n.x&&Wf(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);(fu(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&&oV(s,n)))&&(s=n,d=m)}n=n.next}while(n!==h)}return s}function oV(e,t){return Xe(e.prev,e,t.prev)<0&&Xe(t.next,e,e.next)<0}var zt=[],Hs=[],Ti=new Uint32Array(0),lu=new Uint32Array(0),uu=new Uint32Array(256);function iV(e,t,n,r){let o=e,i=0;do o.z=cx(o.x,o.y,t,n,r),zt[i++]=o,o=o.next;while(o!==e);sV(i);let s=null;for(let a=0;a<i;a++){let l=zt[a];l.prevZ=s,s&&(s.nextZ=l),s=l}s.nextZ=null,zt.fill(null,0,i),Hs.fill(null,0,i)}function sV(e){if(e<=32){for(let t=1;t<e;t++){let n=zt[t],r=n.z,o=t-1;for(;o>=0&&zt[o].z>r;)zt[o+1]=zt[o],o--;zt[o+1]=n}return}Ti.length<e&&(Ti=new Uint32Array(e),lu=new Uint32Array(e),Hs=new Array(e));for(let t=0;t<e;t++)Ti[t]=zt[t].z;Hf(e,zt,Ti,Hs,lu,0),Hf(e,Hs,lu,zt,Ti,8),Hf(e,zt,Ti,Hs,lu,16),Hf(e,Hs,lu,zt,Ti,24)}function Hf(e,t,n,r,o,i){uu.fill(0);for(let a=0;a<e;a++)uu[n[a]>>>i&255]++;let s=0;for(let a=0;a<256;a++){let l=uu[a];uu[a]=s,s+=l}for(let a=0;a<e;a++){let l=n[a],u=uu[l>>>i&255]++;r[u]=t[a],o[u]=l}}function cx(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 aV(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 Wf(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 lV(e,t){let n=du(e,t)&&Xe(e.prev,e,e.next)>0&&Xe(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||fu(e,t)&&fu(t,e)&&(Xe(e.prev,e,t.prev)!==0||Xe(e,t.prev,t)!==0))&&!uV(e,t)&&(n||cV(e,t))}function Xe(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function du(e,t){return e.x===t.x&&e.y===t.y}function gN(e,t,n,r,o=!0){let i=Xe(e,t,n),s=Xe(e,t,r),a=Xe(n,r,e),l=Xe(n,r,t);return(i>0&&s<0||i<0&&s>0)&&(a>0&&l<0||a<0&&l>0)?!0:o?!!(i===0&&Gf(e,n,t)||s===0&&Gf(e,r,t)||a===0&&Gf(n,e,r)||l===0&&Gf(n,t,r)):!1}function Gf(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 uV(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&&gN(s,a,e,t))return!0;s=a}while(s!==e);return!1}function fu(e,t){return Xe(e.prev,e,e.next)<0?Xe(e,t,e.next)>=0&&Xe(e,e.prev,t)>=0:Xe(e,t,e.prev)<0||Xe(e,e.next,t)<0}function cV(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 bN(e,t){let n=dx(e.i,e.x,e.y),r=dx(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 pN(e,t,n,r){let o=dx(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 pu(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),ax&&nV(e.prev,e.next)}function dx(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function dV(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}Ye();Rt();rn();Rl();di();ci();var fx=new Uint8Array(new Uint16Array([1]).buffer)[0]===1?0:1,fV=2**-19;function px(e,t,n){let r=pV(e,t),o=new Uint32Array(r.buffer);for(let i=0;i<t;i++){let s=o[i*2+fx],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)*fV+1e-300;for(let h=i+1;h<t&&!(r[h]>p);h++){let m=o[h*2+fx],y=m*4,b=e[y],x=e[y+1],w=e[y+2],g=e[y+3];if(Math.max(u,d)<Math.min(x,g)||Math.max(x,g)<Math.min(u,d))continue;let P=hV(l,u,c,d,b,x,w,g);if(P&&n(s,m,P[0],P[1]))return}}}function pV(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+fx]=o;return n.sort()}function hV(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,y=(p*u-h*l)/f,b=1e-9,x=1-1e-9;return m<=b||m>=x||y<=b||y>=x?null:[m,y]}var ki=e=>`${e.x},${e.y}`;function hx(e,t=!1){return!t&&!gV(e)?null:wN(e,n=>n!==0).contours}var mV=2**20;function xN(e){let t=yV(e),n=Math.floor((mV/t-t)/2);if(!(n>=0))return null;let r=wN(e,o=>(o&1)!==0,n);return r!==null&&r.complete?r.contours:null}function wN(e,t,n=1/0){let r=bV(e),o=PV(r);if(!xV(r,n))return null;wV(r,o),TV(r,o);let i=kV(r,t),{loops:s,complete:a}=AV(i);return{contours:NV(s),complete:a}}function yV(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 gV(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 px(o,i,()=>s=!0),s}function bV(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 xV(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 px(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,...SV(l,s)};return l.cuts.push({s,node:u}),e[i].cuts.push({s:a,node:u}),!1}),r<=t}function wV(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)||(zf(i,l.from,t),zf(i,l.to,t),zf(l,i.from,t),zf(l,i.to,t))}}}function PV(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 TV(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 zf(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 SV(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 kV(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(vV(e,d,f)),l=[],u=new Set,c=(d,f)=>{let p=`${ki(d)}>${ki(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],y=m.x-h.x,b=m.y-h.y,x=Math.hypot(y,b);if(x===0)continue;let w=(h.x+m.x)/2,g=(h.y+m.y)/2,P=-b/x*s,S=y/x*s,v=a(w+P,g+S),A=a(w-P,g-S);v&&!A?c(h,m):A&&!v&&c(m,h)}}return l}function vV(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 AV(e){let t=new Map;for(let i of e){let s=ki(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=ki(i.from),l=i;for(;ki(l.to)!==a;){let u=RV(l,(t.get(ki(l.to))??[]).filter(c=>!n.has(c)));if(!u)break;n.add(u),s.push(u.from),l=u}ki(l.to)!==a?o=!1:s.length>=3&&r.push(s)}return{loops:r,complete:o}}function RV(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 NV(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}Vl();ai();function vi(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:xr(t,a,u),parent:-1,winding:0}}),i=o.map(a=>MV(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(IV(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 IV(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(!EV(e,t,s,a,o))return Wn(e,s,a,t.start,t.end)}return!1}function EV(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 MV(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]}ai();function TN(e){if(OV(e))return null;let t=vi(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 CV(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],y=t[p*2+1],b=t[h*2],x=t[h*2+1];m===b&&y===x||(o.set([m,y,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 OV(e){let t=CV(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(FV(t,f,m,l))return!0}}return!1}function FV(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=LV(e,t,n);return p==="e-to"?PN(a-i,l-s,d-u,f-c)||Gs(i,s,u,c,d,f,r):p==="f-to"?PN(d-u,f-c,a-i,l-s)||Gs(u,c,i,s,a,l,r):Gs(i,s,u,c,d,f,r)||Gs(a,l,u,c,d,f,r)||Gs(u,c,i,s,a,l,r)||Gs(d,f,i,s,a,l,r)||_V(i,s,a,l,u,c,d,f)}function LV(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 PN(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 Gs(e,t,n,r,o,i,s){return Tn(e,t,n,r,o,i)<=s}function _V(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 mu(e,t={}){if(e.kind==="rect")return DV(e);let n=GV(ze(e),t);return e.origin?{...n,origin:e.origin}:n}function DV(e){let t=Al(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 BV(e,t){let n=new Set,r=HV(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 HV(e,t,n){let{commands:r,coords:o}=e,i=[],s=[],a=[],l=[],u=[],c=-1,d=-1,f=0,p=(h,m,y,b)=>{for(let w=0;w<m.length;w++)s.push(d),a.push(b),l.push(y>0?m[w]/y:0);let x=h+m.length-1;s[x]=b,a[x]=b,l[x]=0};return Oe(r,o,(h,m,y,b,x,w)=>{if(w){let g=Math.max(c,0);u.push(i.length/2),i.push(y,b),s.push(g),a.push(g),l.push(0),d=g}switch(h){case se:case ae:{h===se&&(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 g=f,P=[],S=s.length,v=Ul(y,b,o[m],o[m+1],o[m+2],o[m+3],t,i,P);p(S,P,v,g),d=g,f++;break}case be:{let g=f,P=[],S=s.length,v=Gl(y,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,g),d=g,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 GV(e,t){let n=t.flattenTolerance??mt,r=BV(e,n);if(e.fillRule==="evenodd"){let a=TN(r);if(a)return hu(r,a);let l=xN(r);if(l)return hu(l,vi(l));let{coords:u,contourStarts:c,anchorA:d,anchorB:f,anchorT:p}=r;return UV(u,c,d,f,p)}let o=hx(r);if(o)return hu(o,vi(o));let i=vi(r);if(i.every(a=>Math.abs(a.winding)<=1))return hu(r,i);let s=hx(r,!0);return hu(s,vi(s))}function hu(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=Vf(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)??[],y=u.length/2,b=[],x=[0];for(let g=t[h].start;g<t[h].end;g++)b.push(n[g*2],n[g*2+1]),c.push(o[g]),d.push(i[g]),f.push(s[g]);for(let g of m){x.push(b.length/2);for(let P=t[g].start;P<t[g].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=Vf(b,x.length>1?x.slice(1):void 0);for(let g of b)u.push(g);for(let g of w)p.push(g+y)}return{vertices:new Float32Array(u),indices:new Uint32Array(p),anchorA:new Uint32Array(c),anchorB:new Uint32Array(d),anchorT:new Float32Array(f)}}function UV(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)}}Yg();function yu(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 vN=1e-9;function SN(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>vN?(a-d)/f:0,h=e.points[(c-1)*2],m=e.points[(c-1)*2+1],y=e.points[c*2],b=e.points[c*2+1],[x,w,g]=yu(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+(y-h)*p,y:m+(b-m)*p,a:x,b:w,t:g,w:P,o:S,next:c}}var WV=4*2**-23;function kN(e,t,n){let r=e.points[n*2],o=e.points[n*2+1];return Math.hypot(t.x-r,t.y-o)<=WV*Math.max(1,Math.abs(r),Math.abs(o))}function Us(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 C=1;C<i;C++){let F=e.points[C*2]-e.points[(C-1)*2],D=e.points[C*2+1]-e.points[(C-1)*2+1];d[C]=d[C-1]+Math.hypot(F,D)}let f=d[i-1],p=r,h=f-o;if(h-p<=vN)return null;let m=SN(e,d,s,a,l,u,c,p,!0),y=SN(e,d,s,a,l,u,c,h,!1),b=y.next-m.next,x=b>0&&kN(e,m,m.next),w=b>0&&kN(e,y,y.next-1)&&b+(x?0:1)>=2,g=[],P=[],S=[],v=[],A=u?[]:void 0,N=c?[]:void 0,M=C=>{g.push(C.x,C.y),P.push(C.a),S.push(C.b),v.push(C.t),A&&A.push(C.w),N&&N.push(C.o)};x||M(m);for(let C=m.next;C<y.next;C++)g.push(e.points[C*2],e.points[C*2+1]),P.push(s[C]),S.push(a[C]),v.push(l[C]),A&&A.push(u[C]),N&&N.push(c[C]);return w||M(y),{points:g,closed:!1,anchorA:new Uint32Array(P),anchorB:new Uint32Array(S),anchorT:new Float32Array(v),...A?{widths:new Float32Array(A)}:{},...N?{offsets:new Float32Array(N)}:{}}}Ov();var VV=4,AN=new WeakMap;function RN(e,t=mt){let n=Jg(),r=AN.get(e);r===void 0&&AN.set(e,r=new Map);let o=r.get(t);if(o!==void 0&&o.openFill===n)return o.mesh;let i=mu(e,{flattenTolerance:t});return o===void 0&&r.size>=VV&&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 mx(e){return typeof e=="string"?zV[e]:e}function Yn(e){if(e===void 0)return!1;let{source:t,destination:n}=mx(e);return t!=="one"||n!=="one-minus-source-alpha"}function EN(e){let{destination:t}=mx(e);return t==="one"||t==="one-minus-source-alpha"}var NN=new WeakMap;function yx(e){let t=NN.get(e);if(t!==void 0)return t;let n=e.some(r=>r.kind==="group"&&(Yn(r.composite)||yx(r.children)));return NN.set(e,n),n}function IN(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 gx(e,t){let{source:n,destination:r}=mx(t);e.blendFunc(IN(e,n),IN(e,r))}Z();function Be(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=Ai(t);n.enable(n.STENCIL_TEST),n.stencilFunc(n.EQUAL,r,r),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)}function Ai(e){return e===0?0:(1<<e+1)-1&254}function bx(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),Be(e,t,e.gl.UNSIGNED_INT);let r=Ai(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 xx(e){let t=e.gl;t.stencilMask(1),t.clear(t.STENCIL_BUFFER_BIT),t.disable(t.STENCIL_TEST)}Z();Pe();var MN=new WeakMap,CN=new WeakMap;function Yf(e,t){let n=MN.get(e);n||(n=new WeakMap,MN.set(e,n));let r=n.get(t);return r||(r={},n.set(t,r)),r}function kr(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 wx(e,t,n,r,o,i){let s=t.uniform("u_color");if(s===void 0)return;let a=Yf(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 qf(e,t,n){let r=t.uniform("u_alpha");if(r===void 0)return;let o=Yf(e,t);o.alpha!==n&&(e.gl.uniform1f(r,n),o.alpha=n)}function gu(e){if(e.projection)return e.projection;let t=CN.get(e);return t||(t=q.toUniform(q.screenToClip(e.widthCss,e.heightCss)),CN.set(e,t)),t}var jf=new Float32Array(16);function Rn(e,t,n=e.state.colorMatrix){let r=e.gl,o=Yf(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++)jf[l*4+a]=n[a*5+l];kr(o.colorMatrix,jf)||(r.uniformMatrix4fv(i,!1,jf),o.colorMatrix=Float32Array.from(jf))}let s=t.uniform("u_colorBias");if(s!==void 0){let a=[n[4],n[9],n[14],n[19]];kr(o.colorBias,a)||(r.uniform4f(s,a[0],a[1],a[2],a[3]),o.colorBias=Float32Array.from(a))}}var ON=65536;function Xf(e){let t=e.meshOrigin;return t?q.translated(e.state.transform,t.x,t.y):e.state.transform}function Jf(e,t,n){let r=e.meshOrigin;if(t===r)return n();e.meshOrigin=t;try{return n()}finally{e.meshOrigin=r}}var Ws=new Float32Array(9),$f=new Float32Array(9);function nt(e,t,n=Xf(e),r=gu(e)){let o=e.gl,i=Yf(e,t);$f.set(r),kr(i.proj,$f)||(o.uniformMatrix3fv(t.uniform("u_proj"),!1,$f),i.proj=Float32Array.from($f)),Ws.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)>=ON||Math.abs(c)>=ON){let d=n[0],f=n[1],p=n[3],h=n[4],m=d*h-f*p,y=Math.fround((p*c-h*u)/m),b=Math.fround((f*u-d*c)/m);Number.isFinite(y)&&Number.isFinite(b)&&(a=y,l=b,Ws[6]=d*a+p*l+u,Ws[7]=f*a+h*l+c)}(i.originX!==a||i.originY!==l)&&(o.uniform2f(s,a,l),i.originX=a,i.originY=l)}kr(i.model,Ws)||(o.uniformMatrix3fv(t.uniform("u_model"),!1,Ws),i.model=Float32Array.from(Ws))}function Vs(e,t,n,r){let[o,i,s,a]=$n(n);wx(e,t,o,i,s,a*(r??1)),qf(e,t,e.state.alpha)}var FN=new Set;function _N(e,t){FN.has(e)||(FN.add(e),en()&&console.warn(t))}function Px(e,t){_N(`${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 KV(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=_s(i.id);if(!s){en()&&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(en())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(en())throw new TypeError(`weasel setUniform: array length ${i.length} not supported`)}return}if(typeof n=="number"){e.uniform1f(t,n);return}}var jV={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 $V(e){return Array.isArray(e)||e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint32Array}function YV(e,t,n,r){let o=jV[n.type];if(!o){en()&&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(en())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 Tx(e,t,n,r,o,i){for(let[s,a]of Object.entries(r)){let l=t.uniformArray(s);if(l&&$V(a)){YV(e,s,l,a);continue}let u=t.uniform(s);if(u===void 0){Px(n,s);continue}KV(e,u,a,o,i)}}function DN(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){_N(`${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(gu(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)),qV(n,a,e.state.transform,t.bounds),Tx(n,a,t.program.id,t.uniforms,s,{value:1}),wt(e),Be(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 qV(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)>=LN||Math.abs(d)>=LN)&&(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 LN=8192;Z();Z();function HN(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 GN(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 UN=16,XV=8,JV=new Float64Array(0);function WN(e,t,n){if(e===null&&t.length===0)return null;let r=JV;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 BN=new WeakMap;function VN(e,t){let n=BN.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=QV(e,t);return BN.set(e,{m:Float64Array.of(t[0],t[1],t[3],t[4],t[6],t[7]),planes:r}),r}function QV(e,t){let n=Ib(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 kx(r,XV)}function kx(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;xr(n)<0&&Eb(n);let r=Mb(n);if(r.length<6||r.length/2>t||!Cb(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 vr(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 Qf(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 vx(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=ZV(c,f,n,h,m,p%2===0?1:-1,d)}else{let h=(p-l)*3;f=bu(c,f,n,a[h],a[h+1],a[h+2],d)}c=d,d=d===o?i:o}return f}function ZV(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]=zN(e,l*n,c*n),h=(o-e[f+r])/(e[p+r]-e[f+r]);KN(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 bu(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]=zN(e,l*n,d),m=r*e[p]+o*e[p+1]+i,y=r*e[h]+o*e[h+1]+i;KN(e,p,h,m/(m-y),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 Sx=[0,0];function zN(e,t,n){let r=e[n]<e[t]||e[n]===e[t]&&e[n+1]<e[t+1];return Sx[0]=r?n:t,Sx[1]=r?t:n,Sx}function KN(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 zs(e){return uN(e.flattenTolerance,e.state.transform)}function Zf(e,t){return RN(t,zs(e))}function Ax(e,t){return e.meshCache.handleFor(t)}function xu(e,t){return Ax(e,Zf(e,t))}Z();function ep(e){return e===Vt||kr(Vt,e)}var wu={enabled:!0};function Pu(e){return wu.enabled||ep(e.state.colorMatrix)}function Rx(e,t,n,r,o){let i=e.state.colorMatrix,s=e.state.alpha;if(ep(i))return[t,n,r,o*s];if(!wu.enabled)return[t,n,r,o];let a=aN(i,t,n,r,o);return a[3]*=s,a}function tp(e,t,n,r,o,i){return ep(e.state.colorMatrix)?(i[0]=t,i[1]=n,i[2]=r,i[3]=o*e.state.alpha,i):Rx(e,t,n,r,o)}var jN=[1,1,1,1],ez=[0,6,12,18];function tz(e){let t=e.state.colorMatrix,n=e.state.alpha;if(ep(t))return n===1?jN:[1,1,1,n];if(!wu.enabled)return null;for(let r=0;r<20;r++){let o=t[r];if(ez.includes(r)?o<0||o>1:o!==0)return null}return[t[0],t[6],t[12],t[18]*n]}function Ks(e,t){let n=tz(e);if(n!==null)return{colorMatrix:Vt,alpha:1,tint:n,slot:0};let r=e.state.colorMatrix,o=e.state.alpha;return t?{colorMatrix:r,alpha:o,tint:jN,slot:0}:{colorMatrix:r,alpha:1,tint:[1,1,1,o],slot:0}}function Nx(e,t,n){for(let r=0;r<e.length;r++){let o=e[r];if(o.alpha===n&&(o.colorMatrix===t||kr(o.colorMatrix,t)))return r}return e.length<(wu.enabled?Kn:1)?e.length:-1}var $N=new Float32Array(16*Kn),YN=new Float32Array(4*Kn),qN=new Float32Array(Kn),XN=new WeakMap;function nz(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&&!kr(r.colorMatrix,o.colorMatrix))return!1}return!0}function JN(e,t,n){let r=XN.get(e);r||(r=new WeakMap,XN.set(e,r));let o=r.get(t);if(o!==void 0&&nz(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++)$N[16*a+c*4+u]=l[u*5+c];YN[4*a+u]=l[u*5+4]}qN[a]=n[a].alpha}let s=e.gl;s.uniformMatrix4fv(t.uniform("u_colorMatrix"),!1,$N.subarray(0,16*i)),s.uniform4fv(t.uniform("u_colorBias"),YN.subarray(0,4*i)),s.uniform1fv(t.uniform("u_alpha"),qN.subarray(0,i)),r.set(t,n.slice())}var js=q.identity(),rz=new Int32Array(Array.from({length:yt},(e,t)=>t)),Ix=new Float32Array(2*yt),QN=new Int32Array(4*Ms);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,js),wx(e,a,1,1,1,1),JN(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),Ix[2*(u+1)]=c.fieldScale[0],Ix[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(Cs),r.uniform1iv(a.uniform("u_samplers"),rz),r.uniform2fv(a.uniform("u_fieldScale"),Ix),i&&oz(r,a,n),wt(e,n.clipDepth),Be(e,l,e.gl.UNSIGNED_INT),r.activeTexture(r.TEXTURE0),r.bindVertexArray(null),t.reset(),e.batchState=void 0}function oz(e,t,n){for(let{set:r,start:o}of n.hulls)QN.set(r.planes,4*o);e.uniform4iv(t.uniform("u_hullPlanes"),QN,0,4*n.hullPlanes)}function Su(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.");sz(e,t,n)}var iz=q.identity();function sz(e,t,n){let r=HN(t,n),o=r===null?null:Ex(e),i=o===null?null:YA(t,n,o),s=i?i.rect:r,a=np(e),l=e.clipStack[e.clipStack.length-1],u=l===void 0?null:l.uncutHulls,c=s===null?lz(e,t,n):null,d=c&&(a?Nb(a,c.set):c.set),f=s===null&&c===null?az(e,t,n):null;if(s!==null){let p=i?i.hull:null,h=p?ZN(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=ZN(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{Cx(e);let p=e.clipDepth+1;oI(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})}rI(e)}function az(e,t,n){if(!eI(e))return null;let r=VN(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<=UN?r:null}function ZN(e,t){return e===!1?!1:(e?Nb(e,t):t)??!1}function Ex(e){return!e.batchVariants?.hulls||e.renderTarget||e.projection||e.deviceWidth===void 0||e.deviceHeight===void 0?null:$A(gu(e),e.fragOrigin??[0,0],e.deviceWidth,e.deviceHeight)}function eI(e){return e.batchVariants?.cuts!==!1&&Ex(e)===null}function lz(e,t,n){let r=Ex(e);return r===null?null:Rb(t,n,r)}function np(e){if(e.uncutHulls!==void 0)return e.uncutHulls;let t=e.clipStack;return t.length===0?null:t[t.length-1].hulls}function Mx(e){let t=e.clipStack.pop();t.depth>0&&(uz(e,tI(t),t.depth-1,nI(t)),e.clipDepth=t.depth-1),rI(e)}function tI(e){return e.hull?e.hull.path:e.path}function nI(e){return e.hull?iz:e.transform}function Cx(e){for(let t of e.clipStack){if(t.depth!==0)continue;let n=e.clipDepth+1;oI(e,tI(t),n,nI(t)),t.depth=n,e.clipDepth=n}}function rI(e){let t=null,n=[];for(let r of e.clipStack)r.rect&&(t=t?GN(t,r.rect):r.rect),r.planes&&n.push(r.planes);e.drawBatch.clip=WN(t,n,eI(e))}function Ox(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 xo(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):(Cx(e),e.uncut=!0,t)}function wo(e,t){e.drawBatch.clip=t,e.uncut=!1,e.uncutHulls=void 0}function sn(e,t,n,r){let o=xo(e);r(e,t,n),wo(e,o)}function an(e){ye(e),e.clipStack.length>0&&Cx(e)}function Tu(e,t,n){let r=e.gl,o=xu(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),Be(e,o.indexCount,e.gl.UNSIGNED_INT),r.bindVertexArray(null)}function oI(e,t,n,r=e.state.transform){ye(e);let o=e.gl,i=Ai(n-1),s=1<<n,a=i|s;o.enable(o.STENCIL_TEST),o.colorMask(!1,!1,!1,!1),xu(e,t).requiresStencil?(o.stencilMask(1),o.stencilFunc(o.ALWAYS,0,1),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),Tu(e,t,r),o.stencilMask(s),o.stencilFunc(o.EQUAL,a|1,i|1),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),Tu(e,t,r),o.stencilMask(1),o.stencilFunc(o.ALWAYS,0,1),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),Tu(e,t,r)):(o.stencilMask(s),o.stencilFunc(o.EQUAL,a,i),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),Tu(e,t,r)),o.colorMask(!0,!0,!0,!0),o.stencilMask(255)}function uz(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=Ai(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),Tu(e,t,r),o.colorMask(!0,!0,!0,!0),o.stencilMask(255)}var rp=xt(),Cae=rp.reflection;function Nn(e){return rp.get(e)??null}function op(e,t,n){if(rp.has(e)&&!en())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 rp.set(e,{vert:t,frag:n}),{id:e}}var iI=`#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
|
|
378
|
+
`;var sI=`#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 Fx="weasel:effect-composite";function ip(){return Nn(Fx)||op(Fx,iI,sI),Fx}function $s(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 aI(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 Lx(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 sp(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 lI(e,t,n,r=Ri(e)){let o=Mf(t,r);return o==="solid"?[...e]:o==="non-finite"?[]:e.flatMap((i,s)=>cz(i,o,n?.[s]??0))}function Ri(e){return e.reduce((t,n)=>t+uI(n),0)}function uI(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 cz(e,t,n=0){let r=Mf(t,uI(e));if(r==="solid")return[e];if(r==="non-finite")return[];let o=[],i=e.points.length/2,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=P=>({x:e.points[P*2],y:e.points[P*2+1],a:s[P],b:a[P],t:l[P],w:u?u[P]:0,o:c?c[P]:0}),f=0,p=r[0],h=!0;if(n>0){let P=n%(r.reduce((S,v)=>S+v,0)*(r.length%2+1));for(;P>=r[f];)P-=r[f],f=(f+1)%r.length,h=!h;p=r[f]-P}let m=h?aI(d(0),!!u,!!c):null,y=P=>{m&&m.pts.length>=4&&o.push(sp(m)),f=(f+1)%r.length,p=r[f],h=!h,m=h?aI(P,!!u,!!c):null},b=e.points[0],x=e.points[1],w=e.closed?i:i-1;for(let P=0;P<w;P++){let S=d(P),v=d((P+1)%i),A=Math.hypot(v.x-b,v.y-x);if(A<=1e-9){h&&m&&Lx(m,v);continue}let N=A,M=0;for(;N>1e-9;)if(N<=p)h&&m&&Lx(m,v),p-=N,b=v.x,x=v.y,N=0,p<=1e-9&&y(v);else{M+=p;let C=M/A,[F,D,B]=yu(S.a,S.b,S.t,v.a,v.b,v.t,C),K={x:S.x+(v.x-S.x)*C,y:S.y+(v.y-S.y)*C,a:F,b:D,t:B,w:S.w+(v.w-S.w)*C,o:S.o+(v.o-S.o)*C};h&&m&&Lx(m,K),b=K.x,x=K.y,N=Math.hypot(v.x-b,v.y-x),y(K)}}let g=m;return g&&g.pts.length>=4&&dz(e,g,o),o}function dz(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]=fz(sp(t),n[0]):e.closed&&n.length===0&&i(t.pts[0],t.pts[1])?n.push(sp({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(sp(t))}function fz(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 pz(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 cI(e,t,n){let r=e.points.length/2;if(r<2)return;let o=e.points,i=pz(t),s=e.closed?r:r-1,a=[];for(let g=0;g<s;g++){let P=(g+1)%r,S=o[P*2]-o[g*2],v=o[P*2+1]-o[g*2+1],A=Math.hypot(S,v);a.push(A>0?i(S/A,v/A):NaN)}for(let g=0;g<s;g++)Number.isNaN(a[g])&&(a[g]=g>0?a[g-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=[],y=[],b=[],x=[],w=(g,P)=>{p.push(o[g*2],o[g*2+1]),h.push(l?l[g]:0),m.push(u?u[g]:0),y.push(c?c[g]:0),b.push((d?d[g]:n)*P),f&&x.push(f[g]*P)};w(0,a[0]);for(let g=1;g<r;g++)w(g,a[g-1]),g<s&&w(g,a[g]);e.closed&&w(0,a[s-1]),e.points=p,e.anchorA=Uint32Array.from(h),e.anchorB=Uint32Array.from(m),e.anchorT=Float32Array.from(y),e.widths=Float32Array.from(b),f&&(e.offsets=Float32Array.from(x))}function dI(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=Ef(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=hz(e,h,r));let m=i[h],y=s[h],b=a[h],[x,w]=p(m);if(m!==y){let[g,P]=p(y);x+=(g-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 Ni(e,t){return 2*jb(e,t)}function fI(e,t,n,r,o){t&&dI(e,t,r,o),n&&cI(e,n,r)}function hz(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 ap(e,t,n){let r=e??mt,o=Ni(t,n);return o/2>r?{flattenTolerance:e,offset:o/2}:{flattenTolerance:e}}function ku(e){return e===void 0?"":`${Po(e.metric)}@${e.pxPerUnit}`}var pI=1e-9;function vu(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)<pI&&Math.abs(c-f)<pI?{scale:i,metric:null}:{scale:i,metric:{p:c,q:d,r:f}}}function Po(e){return e===void 0?"":`${e.p},${e.q},${e.r}`}function Au(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 Ru(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 lp(e,t){return e===t?!0:e!==null&&t!==null&&e.p===t.p&&e.q===t.q&&e.r===t.r}function _x(e,t,n){return Math.hypot(e.r*t-e.q*n,e.p*n-e.q*t)}function Dx(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 up(e){return e.q===0}function Bx(e,t){return up(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 hI=(e,t)=>e===void 0?{length:0,metric:t}:typeof e=="number"?{length:e,metric:t}:e;function Ii(e,t,n,r,o){let i=hI(r,n),s=hI(o,n),a=e,l=t,u=c=>{a===null||lp(l,c)||(l!==null&&Ru(a,l),c!==null&&Au(a,c),l=c)};if(i.length>0||s.length>0)if(lp(i.metric,s.metric))u(i.metric),a=Us(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=Us(a,f?c:0,f?0:c));return u(n),a}Z();Z();Z();function gI(e,t){let{start:n=0,end:r=1,pace:o="length"}=t??{},i=mI(e,n,o),s=mI(e,r,o);return Number.isNaN(i)||Number.isNaN(s)||i>=s?null:{from:i,to:s}}function mI(e,t,n){return typeof t=="number"?n==="anchor"?Rg(e,t):yI(e,t*e.total):"length"in t?yI(e,t.length):"anchor"in t?Ud(e,t.anchor):Ag(e,t.subpath)}var yI=(e,t)=>Number.isNaN(t)?NaN:Math.min(Math.max(t,0),e.total);function bI(e,t){let n=Wl(e),r=gI(n,t);return r&&Xg(n,r)}var Hx=1e-9;function Gx(e,t,n){let r=[];for(let o=Math.max(t.from.run,0);o<=Math.min(t.to.run,e.length-1);o++){let i=e[o],s=m=>rb(i,m.segment,m.t,n?.[o]),a=o===t.from.run?s(t.from):null,l=o===t.to.run?s(t.to):null,u=Ri([i]),c=a?.length??0,d=l?.length??u;if(d-c<=Hx)continue;if(i.closed&&c<=Hx&&u-d<=Hx){r.push({polyline:i,fromClosed:!0,dashPhase:0});continue}let f=i.closed?mz(i):i,p=Us(f,c,u-d);if(!p)continue;let h=c;if(p!==f){let m=p.points,y=m.length-2;if(a&&c>0){let b=(x,w)=>y>=2?Math.hypot(m[2]-x,m[3]-w):0;h=Math.max(0,c+b(m[0],m[1])-b(a.x,a.y)),[m[0],m[1]]=[a.x,a.y]}l&&u-d>0&&([m[y],m[y+1]]=[l.x,l.y])}r.push({polyline:p,fromClosed:i.closed,dashPhase:h})}return r}function cp(e,t,n){let r=bI(t,n);if(!r)return null;let{runs:o}=Wl(t);return{span:r,runs:o,windowed:Gx(e,r,o)}}function mz(e){let t=e.points.length/2,{anchorA:n,anchorB:r,anchorT:o,widths:i,offsets:s}=e,a=Ol(e)??n?.[0]??0,l=(u,c)=>{let d=new u.constructor(t+1);return d.set(u),d[t]=c,d};return{points:[...e.points,e.points[0],e.points[1]],closed:!1,anchorA:l(n??new Uint32Array(t),a),anchorB:l(r??new Uint32Array(t),a),anchorT:l(o??new Float32Array(t),0),...i?{widths:l(i,i[0])}:{},...s?{offsets:l(s,s[0])}:{}}}var Ux=e=>({...e,points:e.points.slice()}),xI=e=>e?Ri([e]):0,wI=e=>e===void 0||typeof e=="number"||e.metric===null,PI=e=>e===void 0?0:typeof e=="number"?e:e.length;function TI(e,t,n,r,o,i){let s=t?.windowed??[],a=n===null&&wI(r)&&wI(o),l=i?a?yz(e,PI(r),PI(o)):Ri(e.flatMap(f=>Ii(Ux(f),null,n,r,o)??[])):void 0,u=s.map(f=>!i||f.dashPhase<=0||a?f.dashPhase:gz(e,t.runs,f,t.span.from,n,r)),c=[],d=[];return s.forEach(({polyline:f,fromClosed:p},h)=>{let m=Ii(f,null,n,p?void 0:r,p?void 0:o);m!==null&&(c.push(m),d.push(u[h]))}),{runs:c,phases:d,dashLength:l}}function yz(e,t,n){let r=Math.max(0,t)+Math.max(0,n),o=0;for(let i of e){let s=Ri([i]);o+=i.closed||r<=0?s:Math.max(0,s-r)}return o}function gz(e,t,n,r,o,i){let s=e[r.run],a=n.fromClosed?void 0:i,l=Ii(Ux(s),null,o,a,void 0),u={from:{...r,run:0},to:{run:0,segment:1/0,t:1}},[c]=Gx([s],u,t&&[t[r.run]]),d=c?Ii(Ux(c.polyline),null,o,a,void 0):null;return Math.max(0,xI(l)-xI(d))}Z();var bz=10*Un;function Vx(e,t,n,r,o,i,s,a,l,u,c,d,f,p,h){let m=r?1:-1,y=(e.bx-e.ax)/e.len*m,b=(e.by-e.ay)/e.len*m,x=(o+i)/2,w=(o-i)/2,g=(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=g+y*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(g,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)/bz)),F=M/C,D=t;for(let B=1;B<C;B++){let K=N+B*F,W=g+Math.cos(K)*x,Q=P+Math.sin(K)*x,le=a.length/2;a.push(W,Q),u.push(f),c.push(p),d.push(h),r?l.push(D,le,A):l.push(D,A,le),D=le}r?l.push(D,n,A):l.push(D,A,n)}}function zx(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 SI(e,t,n,r,o,i,s,a,l,u,c,d,f,p,h,m=-1){let y=e[n],b=e[(n+1)%e.length],x=t[n],w=t[(n+1)%e.length],g=y.bx-y.ax,P=y.by-y.ay,S=b.bx-b.ax,v=b.by-b.ay,A=g*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,D=d[F],B=f[D],K=p[D],W=h[D],Q=N?[y.negA,y.negB]:[y.posA,y.posB],le=N?[b.negA,b.negB]:[b.posA,b.posB],ke=Q[1],ue=Math.max(...Q)/Math.max(1e-9,Math.min(...Q)),ve=Math.max(...le)/Math.max(1e-9,Math.min(...le)),G=ue>i||ve>i;if(r==="bevel"||G){Wx(y,M,C,N,s,a,l,u,c,B,K,W,m);return}if(r==="miter"){let j=s[M*2],$=s[M*2+1],ee=s[C*2],te=s[C*2+1],he=Pz(j,$,g,P,ee,te,-S,-v);if(!he){Wx(y,M,C,N,s,a,l,u,c,B,K,W,m);return}if(Math.hypot(he[0]-y.bx,he[1]-y.by)>o*ke){Wx(y,M,C,N,s,a,l,u,c,B,K,W,m);return}let Le=s.length/2;s.push(he[0],he[1]),l.push(B),u.push(K),c.push(W);let Se=m>=0?m:Kx(y,s,l,u,c,B,K,W);N?(a.push(M,Le,C),a.push(M,C,Se)):(a.push(M,C,Le),a.push(M,Se,C));return}if(r==="round"){wz(y,M,C,N,s,a,l,u,c,B,K,W,m);return}}var xz=10*Un;function wz(e,t,n,r,o,i,s,a,l,u,c,d,f){let p=e.bx,h=e.by,m=f>=0?f:Kx(e,o,s,a,l,u,c,d),y=o[t*2]-p,b=o[t*2+1]-h,x=o[n*2]-p,w=o[n*2+1]-h,g=Math.hypot(y,b),P=Math.hypot(x,w),S=Math.atan2(b,y),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)/xz)),M=A/N,C=t;for(let F=1;F<N;F++){let D=S+F*M,B=g+(P-g)*F/N;o.push(p+Math.cos(D)*B,h+Math.sin(D)*B);let K=o.length/2-1;s.push(u),a.push(c),l.push(d),r?i.push(C,m,K):i.push(C,K,m),C=K}r?i.push(C,m,n):i.push(C,n,m)}function Wx(e,t,n,r,o,i,s,a,l,u,c,d,f){let p=f>=0?f:Kx(e,o,s,a,l,u,c,d);r?i.push(t,p,n):i.push(t,n,p)}function Kx(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 Pz(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 kI(e,t,n,r){let o=e.length,i=n?o:o-1,s=[];for(let l=0;l<i;l++)s.push(Tz(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 Tz(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],y=r[(u+2+a)*2],b=r[(u+2+a)*2+1],x=f-c,w=p-d,g=y-h,P=b-m,S=x*P-w*g;if(S===0)return null;let v=h-c,A=m-d,N=(v*P-A*g)/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 Sz={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 Wt(e,t)}function Ei(e,t,n={}){let r=at(t.width??1,1);if(r<=0)return Sz;let o=t.join??"miter",i=t.cap??"butt",s=t.align??"center",a=t.miterLimit??vz,l=t.varyingWidthJoinThreshold??Az,u=n.metric,c=u&&e.kind==="rect"?Bx(e,u):null,d=c??e;d.kind==="rect"&&s!=="center"&&(d={kind:"rect",...$b(d,s,r)});let f=d.kind==="polygon"?ho(d):null;f&&(d=f.path);let p=t.vertexWidths&&t.vertexWidths.length>0?t.vertexWidths:null,h=p&&f?.anchorSources?Hl(p,f.anchorSources,1):p,m=br(d,ap(n.flattenTolerance,r,h??void 0)),y=u?c?(F,D)=>_x(u,F,D):(F,D)=>Dx(u,F,D):void 0,b=[],x=[],w=[],g=[],P=[],S=u??null,v=c?S:null;for(let F of m)fI(F,h,t.nib,r,y);let A,N,M;if(t.trim!==void 0){if(v)for(let F of m)Ru(F,v);({runs:A,phases:N,dashLength:M}=TI(m,cp(m,e,t.trim),S,n.startInset,n.endInset,t.dash!==void 0))}else A=m.flatMap(F=>Ii(F,v,S,n.startInset,n.endInset)??[]);for(let F of lI(A,t.dash,N,M))kz(F,r,o,i,a,l,b,x,w,g,P);let C=new Float32Array(b);return u&&Nu(C,u),{vertices:C,indices:new Uint32Array(x),anchorA:new Uint32Array(w),anchorB:new Uint32Array(g),anchorT:new Float32Array(P),...e.kind==="polygon"&&e.origin?{origin:e.origin}:{}}}function kz(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),y=e.anchorB??new Uint32Array(p),b=e.anchorT??new Float32Array(p),x=e.widths,w=e.offsets,g=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 D=zx(f[F*2],f[F*2+1],f[(F+1)*2],f[(F+1)*2+1],g(F),P(F),g(F+1),P(F+1));D&&(S.push(D),v.push(F))}let A=-1;if(e.closed&&S.length>=1){let F=S[S.length-1],D=S[0],B=zx(F.bx,F.by,D.ax,D.ay,g(p-1),P(p-1),g(0),P(0));B&&(S.push(B),A=p-1,v.push(A))}if(S.length===0)return;let N=[];for(let F=0;F<S.length;F++){let D=S[F],B=v[F],K=F===S.length-1&&e.closed&&A>=0?0:B+1,W=s.length/2;N.push(W);let{nxUnit:Q,nyUnit:le}=D;s.push(D.ax+Q*D.posA,D.ay+le*D.posA),l.push(m[B]),u.push(y[B]),c.push(b[B]),s.push(D.ax-Q*D.negA,D.ay-le*D.negA),l.push(m[B]),u.push(y[B]),c.push(b[B]),s.push(D.bx+Q*D.posB,D.by+le*D.posB),l.push(m[K]),u.push(y[K]),c.push(b[K]),s.push(D.bx-Q*D.negB,D.by-le*D.negB),l.push(m[K]),u.push(y[K]),c.push(b[K]),a.push(W,W+1,W+2,W+1,W+3,W+2)}let M=e.closed?S.length:S.length-1,C=kI(S,N,e.closed,s);for(let F=0;F<M;F++)SI(S,N,F,n,o,i,s,a,l,u,c,v,m,y,b,C[F]);if(!e.closed&&r!=="butt"){let F=S[0],D=N[0];Vx(F,D+0,D+1,!1,F.posA,F.negA,r,s,a,l,u,c,m[0],y[0],b[0]);let B=S[S.length-1],K=N[S.length-1],W=v[S.length-1]+1;Vx(B,K+2,K+3,!0,B.posB,B.negB,r,s,a,l,u,c,m[W],y[W],b[W])}}var vz=4,Az=1.5;Z();function Ys(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?se:ae,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 Ar(e,t,n=!0){return Ys(t,[e,n])}function NI(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 vI(e,t,n){return Ar(NI(e,t),n)}var dp=e=>[[e,-2,e,2],!1],jx=[[[-4,0,0,-2.5],!1],[[-4,0,0,2.5],!1]],AI=2,RI=e=>[[NI(e,AI),!0],[[e+AI,0,0,0],!1]],Iu={reads:[],fill:"none",outline:{width:1}},II=[{id:"arrow",reads:[],inset:3,path:({size:e})=>Ar([0,0,-3,-1.5,-3,1.5],e)},{id:"arrow-open",reads:[],inset:0,fill:"none",outline:{width:1},path:({size:e})=>Ar([-2.867,-2.007,0,0,-2.867,2.007],e,!1)},{id:"arrow-concave",reads:[],inset:3,path:({size:e})=>Ar([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})=>Ar([0,0,-4,-2,-4,2],e)},{id:"diamond",reads:[],inset:4,path:({size:e})=>Ar([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})=>Ar([0,0,-2,-1.2,-4,0,-2,1.2],e)},{id:"circle",reads:[],inset:2,path:({size:e})=>vI(-1,1,e)},{id:"square",reads:[],inset:2,path:({size:e})=>Ar([0,-1,0,1,-2,1,-2,-1],e)},{id:"bar",reads:[],inset:0,fill:"none",outline:{width:1},path:({size:e})=>Ar([0,-1.5,0,1.5],e,!1)},{id:"dot",reads:[],inset:0,path:({size:e})=>vI(0,1.2,e)},{id:"crow-one",...Iu,inset:0,path:({size:e})=>Ys(e,dp(-2),dp(-4),[[-4,0,0,0],!1])},{id:"crow-many",...Iu,inset:0,path:({size:e})=>Ys(e,...jx)},{id:"crow-zero-one",...Iu,inset:7.5,path:({size:e})=>Ys(e,dp(-2),...RI(-5.5))},{id:"crow-one-many",...Iu,inset:0,path:({size:e})=>Ys(e,...jx,dp(-5.5))},{id:"crow-zero-many",...Iu,inset:9.5,path:({size:e})=>Ys(e,...jx,...RI(-7.5))}];var fp=xt();function Rz(){for(let e of II)fp.push(e.id,e,{source:"kit"})}Rz();var Nz=fp.reflection;function Eu(){return fp.getVersion()}function To(e){return e===void 0?void 0:fp.get(e)}Pe();function qs(e,t,n=1){return typeof e=="string"||e.size===void 0?t:Wt(e.size,n)}function Mi(e){return typeof e=="string"?e:e.key}function $x(e,t,n=1){if(e===void 0)return 0;let r=To(Mi(e));return r===void 0?0:(r.inset??0)*qs(e,t,n)}function Xs(e,t){return{start:$x(e.markerStart,t),end:$x(e.markerEnd,t)}}function Js(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 EI(e,t,n){for(let r=t+1;r<n;r++)if(Js(e,t,r))return r;return-1}function MI(e,t){for(let n=t-1;n>=0;n--)if(Js(e,n,t))return n;return-1}function CI(e,t,n=e.closed){let r=[],o=e.points.length/2;if(o<2)return r;if(t.start&&!n){let i=EI(e,0,o),s=i>=0?Js(e,0,i):null;s&&r.push({x:e.points[0],y:e.points[1],angle:Math.atan2(-s.y,-s.x),role:"start"})}if(t.mid){let i=e.anchorA,s=e.anchorB,a=e.anchorT;if(i&&s&&a)for(let l=1;l<o-1;l++){if(i[l]!==s[l]||a[l]!==0)continue;let u=MI(e,l),c=EI(e,l,o);if(u<0||c<0)continue;let d=Js(e,u,l),f=Js(e,l,c),p=d.x+f.x,h=d.y+f.y;Math.hypot(p,h)<1e-9&&(p=d.x,h=d.y),r.push({x:e.points[l*2],y:e.points[l*2+1],angle:Math.atan2(h,p),role:"mid"})}}if(t.end&&!n){let i=o-1,s=MI(e,i),a=s>=0?Js(e,s,i):null;a&&r.push({x:e.points[i*2],y:e.points[i*2+1],angle:Math.atan2(a.y,a.x),role:"end"})}return r}Z();function Iz(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 Mu(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{polyline:u,fromClosed:c}of Ez(e,t,n,r))for(let[d,f]of s){let p=d?{...u,points:u.points.slice()}:u;d&&Au(p,d.metric);for(let h of CI(p,f,c)){let m=i[h.role];if(m===void 0)continue;let y=To(Mi(m));if(y===void 0)continue;let b=qs(m,n),x=y.orient===void 0||y.orient==="auto"?h.angle:y.orient,w=Iz(y.path({size:b,stroke:t}),{...h,angle:x},l);d&&Nu(w.coords,d.metric),a.push(d?{entry:y,size:b,path:w,space:d}:{entry:y,size:b,path:w})}}return a}function Ez(e,t,n,r){let o=br(e,ap(r,n,t.vertexWidths));return t.trim===void 0?o.map(i=>({polyline:i,fromClosed:i.closed})):cp(o,e,t.trim)?.windowed??[]}function pp(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 Mz=64,OI=new WeakMap,FI=new WeakMap;function LI(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 Cz(e,t){let n=pp(e,t);if(n===null){let i=FI.get(e);i===void 0&&FI.set(e,i=new WeakMap);let s=i.get(t);return s===void 0&&i.set(t,s=LI(e,t)),s}let r=OI.get(e);r===void 0&&OI.set(e,r=new Map);let o=r.get(n);return o===void 0&&(r.size>=Mz&&r.clear(),r.set(n,o=LI(e,t))),o}function Cu(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=To(Mi(r));if(o===void 0)continue;let i=typeof r=="string"||r.size===void 0?n:r.size,s=Cz(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 Ou=xG(_I(),1);Ye();Pn();ci();di();Rt();rn();function DI(e,t={}){let n=ze(e);if(n.kind==="rect"){let{x:m,y,width:b,height:x}=n;return[[[[m,y],[m+b,y],[m+b,y+x],[m,y+x],[m,y]]]]}let r=t.tolerance??mt,o=[],i=null,s=0,a=0,l=0,u=0,c=0,{commands:d}=n,f=qe(n),p=kn(n),h=(m=p)=>{if(m||(i=null),!i||i.length===0)return;let y=i[0],b=i[i.length-1];(y[0]!==b[0]||y[1]!==b[1])&&i.push([y[0],y[1]]),i.length>=4&&o.push(i),i=null};for(let m=0;m<d.length;m++){let y=d[m];switch(y){case se:{h(),s=f[c],a=f[c+1],l=s,u=a,i=[[s,a]],c+=2;break}case ae:{i??=[[s,a]],s=f[c],a=f[c+1],i.push([s,a]),c+=2;break}case be:{let b=f[c],x=f[c+1],w=f[c+2],g=f[c+3],P=f[c+4],S=f[c+5],v=[];mo(s,a,b,x,w,g,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],g=f[c+3],[P,S,v,A]=uo(s,a,b,x,w,g),N=[];mo(s,a,P,S,v,A,w,g,r,N),i??=[[s,a]];for(let M=0;M<N.length;M+=2)i.push([N[M],N[M+1]]);s=w,a=g,c+=4;break}case fe:{h(!0),s=l,a=u;break}default:throw new Error(`pathToMultiPolygon: unknown command ${y}`)}}return h(),o.length===0?[]:Dz(o,n.fillRule)}function Oz(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 Fz(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 Lz(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 _z(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)])Lz(e,n[s][0],n[s][1])&&i++;return i>=2}function Dz(e,t){let n=e.length;if(n===1)return[[e[0]]];let r=e.map(Fz),o=e.map(u=>Oz(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||!_z(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 Xx(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++]=se,o[s++]=u[0][0],o[s++]=u[0][1];for(let d=1;d<c;d++)r[i++]=ae,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}:{}}}Ye();Rt();hi();aA();gA();oA();hi();_d();hi();function hp(e,t){return e.length===2?Nl(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y):e.length===3?Ok(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y):li(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 BI=[.25,.5,.75];function HI(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=hp(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=hp(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;BI.every(d=>hp(t,tt(e,l.ta+(u.ta-l.ta)*d)).dist<=n)&&(i=[l,u])}return i}function Bz(e,t,n){return!(e.from===t.from&&e.to===t.to)&&!(e.from===t.to&&e.to===t.from)?!1:BI.every(o=>hp(t.seg,tt(e.seg,o)).dist<=n)}function GI(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=>Bz(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 Hz=16,mp=1e-9,Jx=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 Gz(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 Uz=(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 Wz(e){if(e.length<4)return!1;let t=tt(e,.5),n=Ss(e,0,.5,e[0],t),r=Ss(e,.5,1,t,e[3]);return!n||!r?!1:db(n,r).some(o=>o.ta<1-1e-6||o.tb>1e-6)}function UI(e,t){let n=Gz(e);if(n.some(a=>Wz(a.seg)))return null;let r=new Jx(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=HI(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=db(l.seg,c.seg);if(f.length>=Hz)return null;let p=Uz(l,c);for(let h of f){if(p&&(h.ta>1-mp&&h.tb<mp||h.ta<mp&&h.tb>1-mp))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],y=h.t===0&&m.t===1?u.slice():Ss(u,h.t,m.t,r.points[h.v],r.points[m.v]);y&&(y[0]=r.points[h.v],y[y.length-1]=r.points[m.v],s.push({seg:y,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:GI(s,t),points:r.points}}hi();function zI(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 Vz={x:1,y:0};function WI(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 Qv(Jv(s,e,Vz),!0))tt(s,a.t).x>e.x&&(n+=a.after>0?1:-1)}return n}var VI=(e,t)=>t==="evenodd"?(e&1)!==0:e!==0,KI=e=>({...e,seg:e.seg.slice().reverse(),from:e.to,to:e.from,reversed:!0});function zz(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 jI(e,t,n){let r=[];for(let o of e){let i=(o.t0+o.t1)/2,s=tt(o.source,i),a=jl(o.source,i),l=Math.hypot(a.x,a.y);if(l===0){let y=o.seg[0],b=o.seg[o.seg.length-1];if(a={x:b.x-y.x,y:b.y-y.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=zz(o,t.length),h=new Array(t.length),m=new Array(t.length);for(let y=0;y<t.length;y++){let b=WI(d,t[y]),x=WI(f,t[y]);if(Math.abs(b-x)!==Math.abs(p[y]))return null;h[y]=VI(b,t[y].fillRule),m[y]=VI(x,t[y].fillRule)}r.push({edge:o,inL:h,inR:m})}return r}hi();var Zx=Math.PI*2,Qx=1e-7;function Kz(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 jz=e=>e.slice().reverse();function $z(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 $I=e=>Math.atan2(e.y,e.x);function Yz(e,t){let n=(e-t)%Zx;return n<=0?n+Zx:n}function YI(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 qz(e,t){let n=t[e.to];if(!n||n.length===0)return-1;if(n.length===1)return n[0].key;let r=jz(e.seg),o=l=>{let u=$I(l(r));return n.map(c=>Yz(u,$I(l(c.seg))))},i=l=>{let u=l.slice().sort((c,d)=>c-d);return u[0]<Qx||u[u.length-1]>Zx-Qx||u[1]-u[0]<Qx},s=o(Kz);if(i(s)){let l=.001*Math.min(YI(e.seg),...n.map(u=>YI(u.seg)));if(s=o(u=>$z(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 qI(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():Ss(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 Xz(e){let t=[];for(let n of e){let r=t.length>0?qI(t[t.length-1],n):null;r?t[t.length-1]=r:t.push(n)}for(;t.length>1;){let n=qI(t[t.length-1],t[0]);if(!n)break;t.pop(),t[0]=n}return t.map(n=>n.seg)}function XI(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=qz(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(Xz([...l.slice(c),...l.slice(0,c)].map(d=>e[d])))}return s}var Jz=4096;function Qz(e){let t=ze(e);return t.kind==="polygon"&&t.commands.some(n=>n===be||n===we)}function Zz(e){return e.length<2?e:e[e.length-1].length===2?e.slice(0,-1):e}function e7(e){if(!e.some(Qz))return null;let t=e.map(a=>iA(a)),n=t.reduce((a,l)=>a+l.reduce((u,c)=>u+c.length,0),0);if(n===0||n>Jz)return null;let r=sA(t.flat())||1,o=UI(t,r*1e-6);if(!o)return null;let i=t.map((a,l)=>{let u=e[l];return zI(a,u.kind==="polygon"?u.fillRule:"nonzero")}),s=jI(o.edges,i,r*1e-7);return s?{edges:s,vertexCount:o.points.length,clockwise:t.map(r7)}:null}function t7(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,KI(i)))}let o=new Map;for(let[i,s]of n){let a=XI(s,e.vertexCount);if(!a)return null;o.set(i,a)}return o}function n7(e,t){let n=t?e.map(o7):e;return yA(n.map(r=>({segs:Zz(r),closed:!0})),"nonzero")}function JI(e,t){let n=e7(e);if(!n)return null;let r=t7(n,o=>t(o)?0:-1);return r?n7(r.get(0)??[],n.clockwise[0]):null}function r7(e){let t=0;for(let n of e){let r=Xv(n);Math.abs(r)>Math.abs(t)&&(t=r)}return t<0}function o7(e){let t=qv(e);return[t[t.length-1],...t.slice(0,-1)]}Nv();function i7(e,t){return tb(t,Xx(e))}function yp(e,t,n){if(e.length===0)return Xx([]);let r=JI(e,t);if(r)return tb(e,r);let[o,...i]=e.map(s=>DI(s));return i7(n(o,...i),e)}var s7=e=>e.includes(!0),a7=e=>!e.includes(!1),l7=e=>e[0]&&!e[1],u7=e=>e.filter(Boolean).length%2===1;function gp(...e){return yp(e,s7,Ou.default.union)}function e0(...e){return yp(e,a7,Ou.default.intersection)}function t0(e,t){return yp([e,t],l7,Ou.default.difference)}function n0(...e){return yp(e,u7,Ou.default.xor)}Z();function QI(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 r0(e,t,n){if(!(t>0))return 0;let r=(Math.floor(e/t)+1)*t-e;return r<n?r+t:r}function ZI(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+=r0(s,c,d),a=u+1}return l(t),s}function i0(e,t){return e==="start"||e==="justify"?t==="rtl"?"right":"left":e==="end"?t==="rtl"?"left":"right":e}var eE={kind:"solid",color:"#000"};function o0(e){return Ut(e)?e.color:"#000"}var tE="",nE="";function rE(e){return e!==tE&&(nE=`color-mix(in srgb, ${e} 25%, transparent)`,tE=e),nE}var Ee={fontSize:16,fontFamily:"sans-serif",fontWeight:400,fontStyle:"normal",align:"left",direction:"auto",lineHeight:1.2,tabSize:8,wrap:!1,fill:null,caretColor:o0(eE),selectionBackground:rE(o0(eE)),selectionColor:null,letterSpacing:0,underline:!1,strikethrough:!1,overline:!1,textTransform:"none",fontVariantCaps:"normal"};function s0(e,t,n=1){return!e&&Ie(t?.fill)===null&&(t?.stroke??void 0)===void 0?Ee:xp({...Ee},e,t,n)}function xp(e,t,n,r=1){let o=t??c7,i=Ie(n?.fill),s=n?.stroke??void 0,a=o.caretColor??o0(i?.paint??null),l;o.selectionBackground==="none"?l=null:o.selectionBackground!=null?l=o.selectionBackground:l=rE(a),e.fontSize=Wt(o.fontSize??Ee.fontSize,r),e.fontFamily=o.fontFamily??Ee.fontFamily,e.fontWeight=o.fontWeight??Ee.fontWeight,e.fontStyle=o.fontStyle??Ee.fontStyle,e.align=o.align??Ee.align,e.direction=o.direction??Ee.direction,e.lineHeight=o.lineHeight??Ee.lineHeight,e.tabSize=o.tabSize??Ee.tabSize,e.wrap=o.wrap??Ee.wrap,e.fill=i,e.caretColor=a,e.selectionBackground=l,e.selectionColor=o.selectionColor??null,e.letterSpacing=Wt(o.letterSpacing??Ee.letterSpacing,r),e.underline=o.underline??Ee.underline,e.strikethrough=o.strikethrough??Ee.strikethrough,e.overline=o.overline??Ee.overline,e.textTransform=o.textTransform??Ee.textTransform,e.fontVariantCaps=o.fontVariantCaps??Ee.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 c7=Object.freeze({});Pe();var d7=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 f7(e,t){let n=e.codePointAt(0);return n>=8064&&n<=8111?String.fromCodePoint(n|8):d7.get(n)??e.toLocaleUpperCase(t)}function a0(e){if(e)try{return Intl.getCanonicalLocales(e)[0]}catch{return}}var p7=/[\p{L}\p{N}][\p{L}\p{N}\p{M}\p{Pc}'’]*/gu;function h7(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(p7))t.add(n.index);return t}function oE(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 iE(e,t,n=[]){if(t.every(b=>b==="none"))return e.map(b=>({text:b}));let r=e.map((b,x)=>a0(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!==""&&oE(e,l,i),d=u!==""&&oE(e,u,s),f=t.includes("capitalize")?h7(a):null,p=[],h=0,m=0,y=0;for(let b=0;b<e.length;b++){let x=e[b],w=t[b]??"none",g=r[b],P=g===o,S="",v=[],A=[],N=!1,M=0;for(let C of x){let F=i(C),D=s(C),B=C;w==="uppercase"?B=c&&P?l.slice(m,m+F.length):i(C,g):w==="lowercase"?B=d&&P?u.slice(y,y+D.length):s(C,g):w==="capitalize"&&f.has(h+M)&&i(C,g)!==C&&(B=f7(C,g)),m+=F.length,y+=D.length,B.length!==C.length&&(N=!0),S+=B;for(let K=0;K<B.length;K++)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 m7=.7;function y7(e){let t=e?.xHeight,n=e?.capHeight;return t===void 0||n===void 0||t>=n?m7:t/n}function sE(e,t,n){return y7(ei(xn(e,t,n)))}function aE(e,t,n){let r=a0(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 y=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(y),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 uE=null;function cE(){return uE}var lE=new WeakMap;function l0(e){let{family:t,weight:n,style:r}=e.resolved,o=e.outlineFace??(e.source==="outline"?void 0:gl(t,n,r==="italic"?"italic":"normal"));if(!o)return null;let i=lE.get(o);return i===void 0&&(i=o.embedding?.()??null,lE.set(o,i)),i}function g7(e){return l0(e)?.sfnt??null}function dE(e,t,n,r,o=uE){if(o===null)return!1;let i=g7(xn(e,t,n));return i!==null&&o.hasFeature(i,r)}var b7=Object.freeze(["smcp"]),wp=Object.freeze({super:Object.freeze({size:.583,shift:.333}),sub:Object.freeze({size:.583,shift:-.333})}),fE=new WeakMap;function pE(e){if(!e||!e.superscript&&!e.subscript)return wp;let t=fE.get(e);return t||(t=Object.freeze({super:e.superscript??wp.super,sub:e.subscript??wp.sub}),fE.set(e,t)),t}function hE(e,t,n){return pE(ei(xn(e,t,n)))}function mE(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 yE(e,t){return{fontFamily:e.fontFamily??t.fontFamily,fontWeight:e.fontWeight??(e.bold?700:mE(t.fontWeight)),fontStyle:e.italic?"italic":t.fontStyle}}function Fu(e,t,n=1){return u0(new Array(e.length),e,t,n)}function u0(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?iE(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}=yE(a,n),h=c?hE(d,f,p)[c]:void 0,m=a.baselineShift??h?.shift??0,y=a.fontScale??h?.size??1,b=a.fontSize===void 0&&y!==1,x=a.fontSize!==void 0?Wt(a.fontSize,r):n.fontSize*y,w,g,P=(a.fontVariantCaps??n.fontVariantCaps)==="small-caps";if(P&&dE(d,f,p,"smcp"))g=b7;else if(P){let W=aE(l,u,a.lang??n.lang);if(l=W.text,u=W.srcMap,W.small){let Q=x*sE(d,f,p);w=W.small.map(le=>le?Q:x)}}let S=a.lang??n.lang,v=a.fill!==void 0?a.fill:n.fill,A=a.letterSpacing!==void 0?Wt(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,D=a.rotate&&Number.isFinite(a.rotate)?a.rotate:void 0,B=e[s];if(B!==void 0&&B.srcMap!==void 0==(u!==void 0)&&B.sizeMap!==void 0==(w!==void 0)&&B.stroke!==void 0==(F!==void 0)&&B.strutSize!==void 0===b&&B.rotate!==void 0==(D!==void 0)&&B.fontFeatures!==void 0==(g!==void 0)&&B.lang!==void 0==!!S){B.text=l,B.fontFamily=d,B.fontSize=x,B.fontWeight=f,B.fontStyle=p,B.fill=v,B.letterSpacing=A,B.underline=N,B.strikethrough=M,B.overline=C,B.baselineShift=m*n.fontSize,u&&(B.srcMap=u),w&&(B.sizeMap=w),F!==void 0&&(B.stroke=F),b&&(B.strutSize=n.fontSize),D!==void 0&&(B.rotate=D),g&&(B.fontFeatures=g),S&&(B.lang=S);continue}let K={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&&(K.srcMap=u),w&&(K.sizeMap=w),F!==void 0&&(K.stroke=F),b&&(K.strutSize=n.fontSize),D!==void 0&&(K.rotate=D),g&&(K.fontFeatures=g),S&&(K.lang=S),e[s]=K}return e}var gE=["underline","strikethrough","overline"],Pp=Object.freeze({underline:Object.freeze({offset:.1,thickness:.05}),strikethrough:Object.freeze({offset:-.3,thickness:.05}),overline:Object.freeze({offset:-.9,thickness:.05})}),bE=new WeakMap;function x7(e){if(!e)return Pp;let t=bE.get(e);if(!t){let n=e.underline??Pp.underline;t=Object.freeze({underline:n,strikethrough:e.strikethrough??Pp.strikethrough,overline:Object.freeze({offset:Pp.overline.offset,thickness:n.thickness})}),bE.set(e,t)}return t}function w7(e,t,n,r){let o=x7(r)[e],i=t+n*o.offset;return{y0:i,y1:i+n*o.thickness}}function xE(e,t,n){let r=[],o=null,i=()=>{let s=o;if(o=null,!(!s||s.x1<=s.x0))for(let a of gE){if(!s.style[a])continue;let{y0:l,y1:u}=w7(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&&gE.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 PE(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 P7(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 T7=1024,wE=[];function S7(e){let t=wE[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<=T7&&(wE[e]=n),n}function TE(e,t,n){return e===null||n===0?S7(n):k7(e,t,n)}function k7(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:P7([...i],n,s=>r[s]%2===1),levels:r}}var d0={};gG(d0,{AK:()=>c5,AL:()=>Z7,AP:()=>d5,AS:()=>f5,B2:()=>B7,BA:()=>_7,BB:()=>D7,BK:()=>A7,CB:()=>G7,CL:()=>U7,CLASS_MASK:()=>g5,CM:()=>O7,CP:()=>W7,CR:()=>R7,EAST_ASIAN:()=>b5,EB:()=>n5,EM:()=>r5,EX:()=>V7,GL:()=>L7,H2:()=>o5,H3:()=>i5,HL:()=>e5,HY:()=>H7,ID:()=>t5,IN:()=>z7,IS:()=>Y7,JL:()=>s5,JT:()=>l5,JV:()=>a5,LF:()=>N7,NL:()=>I7,NS:()=>K7,NU:()=>q7,OP:()=>j7,PICTOGRAPHIC_CN:()=>x5,PO:()=>X7,PR:()=>J7,QU:()=>$7,QU_PF:()=>y5,QU_PI:()=>m5,RI:()=>u5,SP:()=>E7,SY:()=>Q7,UNICODE_VERSION:()=>v7,VF:()=>p5,VI:()=>h5,WJ:()=>F7,ZW:()=>M7,ZWJ:()=>C7,lineBreakPropsOf:()=>T5});var v7="16.0.0",A7=0,R7=1,N7=2,I7=3,E7=4,M7=5,C7=6,O7=7,F7=8,L7=9,_7=10,D7=11,B7=12,H7=13,G7=14,U7=15,W7=16,V7=17,z7=18,K7=19,j7=20,$7=21,Y7=22,q7=23,X7=24,J7=25,Q7=26,Z7=27,e5=28,t5=29,n5=30,r5=31,o5=32,i5=33,s5=34,a5=35,l5=36,u5=37,c5=38,d5=39,f5=40,p5=41,h5=42,m5=43,y5=44,g5=63,b5=64,x5=128,SE="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+,-./:;<=>?@[]^_{|}~",w5=[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],kE=2787,vE="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",c0=null,AE=null,RE=null;function P5(){let e=new Uint8Array(65536),t=new Int32Array(kE),n=new Uint8Array(kE),r=new Uint8Array(128);for(let a=0;a<SE.length;a++)r[SE.charCodeAt(a)]=w5[a];let o=0,i=0,s=0;for(let a=0;a<vE.length;a++){let l=vE.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}}c0=e,AE=t,RE=n}function T5(e){if(c0===null&&P5(),e<65536)return c0[e];if(e>1114111)return 27;let t=AE,n=0,r=t.length-1;for(;n<r;){let o=n+r+1>>1;t[o]<=e?n=o:r=o-1}return RE[n]}var{lineBreakPropsOf:v0,CLASS_MASK:A0,EAST_ASIAN:S5,PICTOGRAPHIC_CN:k5,BK:v5,CR:_E,LF:DE,NL:A5,SP:Nr,ZW:ea,ZWJ:g0,CM:NE,WJ:f0,GL:Lu,BA:p0,BB:R5,B2:IE,HY:_u,CB:h0,CL:Tp,CP:Du,EX:EE,IN:N5,NS:ME,OP:Sp,QU:b0,IS:So,NU:ln,PO:Qs,PR:Zs,SY:Bu,AL:R0,HL:Rp,ID:I5,EB:BE,EM:HE,H2:x0,H3:w0,JL:P0,JV:Np,JT:Ip,RI:m0,AK:kp,AP:E5,AS:y0,VF:CE,VI:OE,QU_PI:T0,QU_PF:S0}=d0,ne=0,Hu=1,GE=2,M5=8208,vp=9676,Ap=e=>e===b0||e===T0||e===S0,Ci=e=>e===v5||e===_E||e===DE||e===A5;function Oi(e){return Ci(v0(e)&A0)}var Rr=e=>e===R0||e===Rp,FE=e=>e===P0||e===Np||e===Ip||e===x0||e===w0,LE=e=>e===I5||e===BE||e===HE,N0=e=>({cls:new Uint8Array(e),ea:new Uint8Array(e),pict:new Uint8Array(e),cp:new Int32Array(e),start:new Int32Array(e)}),UE=65536,En=N0(64);function C5(e){return En.cls.length<e&&(En=N0(Math.min(UE,Math.max(e,En.cls.length*2)))),En}var WE=[],k0=WE,Ae=En.cls,In=En.ea,Gu=En.pict,vo=En.cp,Uu=En.start,ko=0;function VE(e){return I0(e,new Uint8Array(e.length+1))}function I0(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]=GE;let r=n<=UE?C5(n):N0(n);k0=e,{cls:Ae,ea:In,pict:Gu,cp:vo,start:Uu}=r;let o=0;for(let i=0;i<n;i++){let s=v0(e[i]),a=s&A0;if((a===NE||a===g0)&&o>0){let l=Ae[o-1];if(!Ci(l)&&l!==Nr&&l!==ea)continue}a===NE||a===g0?(Ae[o]=R0,In[o]=0,Gu[o]=0):(Ae[o]=a,In[o]=s&S5?1:0,Gu[o]=s&k5?1:0),vo[o]=e[i],Uu[o]=i,o++}ko=o;for(let i=1;i<ko;i++)t[Uu[i]]=L5(i);return k0=WE,r!==En&&({cls:Ae,ea:In,pict:Gu,cp:vo,start:Uu}=En),t}var O5=e=>(v0(k0[Uu[e]-1])&A0)===g0;function F5(e){for(;e>=0&&Ae[e]===Nr;)e--;return e}function L5(e){let t=e-1,n=Ae[t],r=Ae[e];if(n===_E&&r===DE)return ne;if(Ci(n))return GE;if(Ci(r)||r===Nr||r===ea)return ne;let o=F5(t);if(o>=0&&Ae[o]===ea)return Hu;if(O5(e)||n===f0||r===f0||n===Lu||r===Lu&&n!==Nr&&n!==p0&&n!==_u||r===Tp||r===Du||r===EE||r===Bu)return ne;let i=o>=0?Ae[o]:-1;if(i===Sp)return ne;if(i===T0){let l=o-1;if(l<0)return ne;let u=Ae[l];if(Ci(u)||u===Sp||Ap(u)||u===Lu||u===Nr||u===ea)return ne}if(r===S0){if(e+1>=ko)return ne;let l=Ae[e+1];if(l===Nr||l===Lu||l===f0||l===Tp||Ap(l)||l===Du||l===EE||l===So||l===Bu||Ci(l)||l===ea)return ne}if(n===Nr&&r===So&&e+1<ko&&Ae[e+1]===ln)return Hu;if(r===So||(i===Tp||i===Du)&&r===ME||i===IE&&r===IE)return ne;if(n===Nr)return Hu;if(r===b0||r===S0||n===b0||n===T0||Ap(r)&&(!In[t]||e+1>=ko||!In[e+1])||Ap(n)&&(!In[e]||t===0||!In[t-1]))return ne;if(n===h0||r===h0)return Hu;if((n===_u||vo[t]===M5)&&r===R0){if(t===0)return ne;let l=Ae[t-1];if(Ci(l)||l===Nr||l===ea||l===h0||l===Lu)return ne}if(r===p0||r===_u||r===ME||n===R5||t>0&&Ae[t-1]===Rp&&(n===_u||n===p0&&!In[t])&&r!==Rp||n===Bu&&r===Rp||r===N5||Rr(n)&&r===ln||n===ln&&Rr(r)||n===Zs&&LE(r)||LE(n)&&r===Qs||(n===Zs||n===Qs)&&Rr(r)||Rr(n)&&(r===Zs||r===Qs))return ne;if(r===Qs||r===Zs){let l=n===Tp||n===Du?t-1:t;for(;l>=0&&(Ae[l]===Bu||Ae[l]===So);)l--;if(l>=0&&Ae[l]===ln)return ne}if(n===Qs||n===Zs){if(r===ln)return ne;if(r===Sp&&e+1<ko){let l=Ae[e+1];if(l===ln||l===So&&e+2<ko&&Ae[e+2]===ln)return ne}}if((n===_u||n===So)&&r===ln)return ne;if(r===ln){let l=t;for(;l>=0&&(Ae[l]===Bu||Ae[l]===So);)l--;if(l>=0&&Ae[l]===ln)return ne}if(n===P0&&(r===P0||r===Np||r===x0||r===w0)||(n===Np||n===x0)&&(r===Np||r===Ip)||(n===Ip||n===w0)&&r===Ip||FE(n)&&r===Qs||n===Zs&&FE(r)||Rr(n)&&Rr(r))return ne;let s=n===kp||n===y0||vo[t]===vp,a=r===kp||r===y0||vo[e]===vp;if(n===E5&&a||s&&(r===CE||r===OE)||n===OE&&t>0&&(Ae[t-1]===kp||Ae[t-1]===y0||vo[t-1]===vp)&&(r===kp||vo[e]===vp)||s&&a&&e+1<ko&&Ae[e+1]===CE||n===So&&Rr(r)||(Rr(n)||n===ln)&&r===Sp&&!In[e]||n===Du&&!In[t]&&(Rr(r)||r===ln))return ne;if(n===m0&&r===m0){let l=t;for(;l>=0&&Ae[l]===m0;)l--;if((t-l)%2===1)return ne}return r===HE&&(n===BE||Gu[t])?ne:Hu}var _5=null;function KE(){return _5}function jE(e){return e%2===1?"rtl":"ltr"}var D5=[[1424,1535],[1536,1983],[2144,2303],[64285,65023],[65136,65279],[67584,69631],[124928,126975]],B5=[[1536,1541],[1632,1644],[1757,1757],[1776,1785],[2274,2274],[68912,68921],[69216,69246]],H5=[[1548,1548],[64830,64831],[65279,65279]];function E0(e,t){for(let n=0;n<e.length;n++)if(t>=e[n][0]&&t<=e[n][1])return!0;return!1}var zE=!1;function $E(e,t="weasel layoutRuns"){if(!zE)for(let n=0;n<e.length;n++){let r=e[n];if(!(!E0(D5,r)||E0(B5,r)||E0(H5,r))){zE=!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 Wu=[.5];function Fi(e){if(e>65536)return new Array(e).fill(.5);for(;Wu.length<e;)Wu=Wu.concat(Wu);return Wu.slice(0,e)}var G5=1<<18,YE=new Map,qE=new Map,M0=0;function XE(e,t){let n=e.get(t);if(n===void 0||n.n===0)return;M0-=t;let r=n.items[--n.n];return n.items[n.n]=void 0,r}function JE(e,t){let n=t.length;if(n===0||M0+n>G5)return;let r=e.get(n);r===void 0&&e.set(n,r={items:[],n:0}),r.items[r.n++]=t,M0+=n}function Vu(e){return XE(YE,e)??Fi(e)}function C0(e){return XE(qE,e)??new Array(e)}function Ep(e){JE(YE,e)}function QE(e){JE(qE,e)}function gt(e,t){for(;e.length>t;)e.pop()}var Ir=13,O0=0,Mp=1,ZE=2,eM=3,tM=4,nM=5,rM=6,F0=7,oM=8,L0=9,iM=10,sM=11,aM=12,_0=1,lM=2,Cp=5,U5=[],W5=[],D0=[],V5=1024,z5=0,Op=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=Vu(t*Ir),this.ref=C0(t*Cp)}static take(t){let n=D0.pop();return n===void 0?n=new e(t):(n.num=Vu(t*Ir),n.ref=C0(t*Cp)),n.stamp=++z5,n}recycle(){Ep(this.num);let{ref:t}=this;for(let n=0;n<t.length;n++)t[n]=void 0;QE(t),this.num=U5,this.ref=W5,gt(this.paintings,0),this.owners=0,this.listed=!1,this.pinned=!1,D0.length<V5&&D0.push(this)}set(t,n,r,o,i,s){let a=t*Ir,l=t*Cp,{num:u,ref:c}=this;u[a+O0]=o,u[a+Mp]=i,u[a+ZE]=n.advance,u[a+eM]=n.fontSize,u[a+tM]=s,u[a+nM]=n.srcIndex,u[a+rM]=n.srcEnd,u[a+F0]=n.cp,u[a+oM]=r,u[a+iM]=n.run,u[a+aM]=n.rotate,u[a+L0]=(n.drawsInk?_0:0)|(n.clusterEnd?lM: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*Ir+Mp]+=n}setVisual(t,n,r){this.num[(t+n)*Ir+sM]=r}visual(t,n){return this.num[(t+n)*Ir+sM]}glyph(t,n,r){let o=t+n,i=o*Ir,s=o*Cp,{num:a,ref:l}=this;return r.run=a[i+iM],r.cell=n,r.cp=a[i+F0],r.fontSize=a[i+eM],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+O0],r.baselineY=a[i+tM],r.advance=a[i+ZE],r.step=a[i+Mp],r.rotate=a[i+aM],r}drawsInk(t,n){return(this.num[(t+n)*Ir+L0]&_0)!==0}cell(t,n){let r=(t+n)*Ir,{num:o}=this,i=o[r+L0];return{srcIndex:o[r+nM],srcEnd:o[r+rM],cp:o[r+F0],x:o[r+O0],advance:o[r+Mp],level:o[r+oM],drawsInk:(i&_0)!==0,clusterEnd:(i&lM)!==0}}};function B0(){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:Fp("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:Fp("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),B0());return n})}};function Fp(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 H0,K5=/[\r\u0300-\uffff]/;function j5(){return H0===void 0&&(H0=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null),H0}function _p(e,t){let n=t??[],r=0;if(K5.test(e)){let o=j5();if(o)r=$5(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 Lp=e=>e<768&&e!==13;function $5(e,t,n){let r=t.length,o=null,i=0,s=0;for(;s<r;){if(Lp(t.charCodeAt(s))&&(s+1===r||Lp(t.charCodeAt(s+1)))){n[i++]=++s;continue}let a=s+1;for(;;){for(;a<r&&!Lp(t.charCodeAt(a));)a++;if(a===r||(a++,a===r||Lp(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 dM=Object.freeze({d:null,key:"",glyphs:Object.freeze([]),rtl:!1,text:""}),uM=Object.freeze({cluster:dM,advance:0}),Y5=new WeakMap,q5=new WeakMap,cM=e=>String(Math.round(e*1e5)/1e5);function fM(e,t,n){if(n===null)return null;let r=l0(t);if(r===null)return null;let o=r.sfnt,i=n.shape(o,e.text,e.fontFeatures,e.lang),s=t.source==="outline"?Y5:q5,a=s.get(i);if(a)return a;let l=t.source==="outline"?null:u=>r.glyphIndexOf(u);return a=X5(n,o,e.text,i,l),s.set(i,a),a}function X5(e,t,n,r,o){let i=new Array(n.length),s=_p(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(!Z5(r,l,c)&&!(o&&J5(r[l],c-l,n,u,d,o))){let p=Q5(r,l,c),h=p/(f+1),m=r[l].rtl?h-p:0;i[u]=eK(e,t,r,l,c,n.slice(u,d),m,h);let y=h===0?uM:{cluster:dM,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?y:uM}}l=c}return i}function J5(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 Q5(e,t,n){let r=0;for(let o=t;o<n;o++)r+=e[o].advance;return r}function Z5(e,t,n){for(let r=t;r<n;r++)if(e[r].gid===0)return!0;return!1}function eK(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?"":`@${cM(h)},${cM(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 tK=/^[\p{Mn}\p{Me}]$/u;function mM(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=ms(d);if(!f){sg(c.fontFamily,c.fontWeight,c.fontStyle),l+=c.srcMap?.length??c.text.length,a=void 0;continue}let p=l,h=c.srcMap,m=_p(c.text,rK),y=fM(c,d,o),b=0,x=0,w=null,g=0,P=c.text;for(;g<P.length;){let S=P.codePointAt(g),v=S>65535?2:1,A=y?.[g],N=c.sizeMap?c.sizeMap[g]:c.fontSize;g===x&&(w=ag(d,c.fontFamily,c.fontWeight,c.fontStyle,c.text.slice(g,m[b])));let M=g+v===m[b];M&&(x=m[b++]);let C=M?c.letterSpacing:0,F=h?p+h.starts[g]:p+g,D=h?p+h.ends[g]:p+g+v;g+=v,l=h?p+h.length:D;let B=nK(S),K=a&&!B?a.metrics.kernOf(a.cp,S)*(a.fontSize/a.metrics.size):0,W=iK(n,s,u,c,S,N,F,D,M,d,f);if(w)M&&(W.tracking=C,hM(W,w)),i[s++]=W,a=void 0;else if(Oi(S))i[s++]=W,a=void 0;else if(S===9||S===32){let Q=f.advanceOf(32),le=Q!==null?Q*(N/f.size):N*.25;if(S===9)i[s++]={...W,tab:{stop:t*(le+c.letterSpacing),min:le/2}},a=void 0;else{let ke=wl(d,32,pM);W.font=ke?.font??null,W.glyph=ke?.glyph??null,W.advance=le,W.tracking=C,W.kerningBefore=K,a=W,i[s++]=a}}else if(A!==void 0)W.tracking=C,i[s++]=sK(W,A),a=void 0;else{let Q=Pl(d,c.fontFamily,c.fontWeight,c.fontStyle,S,!0,pM);Q&&(W.kerningBefore=K,W.tracking=C,hM(W,Q)),i[s++]=W,B||(a=W)}}}return i.length=s,i}function nK(e){return e>=768&&tK.test(String.fromCodePoint(e))}var rK=[],pM={resolved:null,metrics:null,advance:0,font:null,glyph:null},oK=4096;function iK(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<oK&&(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 hM(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 sK(e,t){return e.shaped=t.cluster,e.advance=t.advance*e.fontSize,e.drawsInk=t.cluster.d!==null,e}function yM(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=aK(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=Pl(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 aK(e,t){if(e.resolved.source==="outline")return{...e,shaped:null};let n=Pl(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 Bp=e=>e===32||e===9;var Dp=new Uint8Array(64),G0=!1,lK=65536;function gM(e,t,n,r){let o=e.length;if(!Number.isFinite(t.maxWidth))U0(e,t,n,r,null);else if(G0||o>=lK)U0(e,t,n,r,VE(e));else{Dp.length<o+1&&(Dp=new Uint8Array(Math.max(o+1,Dp.length*2))),G0=!0;try{U0(e,t,n,r,I0(e,Dp))}finally{G0=!1}}}function U0(e,t,n,r,o){let i=e.length,s=0,a=0;for(;a<i;){let l=e[a];if(Oi(l)){r(s,a,!1),a+=l===13&&e[a+1]===10?2:1,s=a;continue}if(Bp(l)){a++;continue}let u=a+1,c=a+1;for(;u<i&&!Oi(e[u])&&(!o||o[u]===ne);)Bp(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 bM(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 wM=[],Ku=wM,Li=Fi(64),V0=[],zu=[],z0=0,xM=[],uK=64;function PM(e,t){return Ku[e].advance+Ku[e].tracking+Li[t]-Li[e+1]}var cK=e=>Ku[e].tab;function dK(e,t){return ZI(e,t,V0,cK,PM)}function fK(e,t,n){let r=z0++,o=xM[r];o===void 0&&(o={start:0,entries:[],width:.5,height:.5,ascent:.5,wrapped:!1,srcEnd:0,end:0},r<uK&&(xM[r]=o)),o.start=e,o.end=t,o.wrapped=n,o.width=0,o.height=0,o.ascent=0,o.srcEnd=0,zu[r]=o}function TM(e,t,n){let{lineHeight:r}=n;Li.length<e.length+1&&(Li=Fi(e.length+1)),Li[0]=0;let o=0;z0=0;for(let i=0;i<e.length;i++){let s=e[i];Li[i+1]=Li[i]+s.kerningBefore+s.advance+s.tracking,s.tab&&(V0[o++]=i)}V0.length=o,Ku=e,gM(t,n,o===0?PM:dK,fK),Ku=wM,zu.length=z0;for(let i=0;i<zu.length;i++){let s=zu[i];if(s.start===s.end){let l=e[s.end];s.height=l.lineSize*r,s.ascent=bM(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=r0(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,bM(u,r))}a.length=s.end-s.start,s.srcEnd=e[s.end-1].srcEnd}return zu}function pK(e){let t=0;for(let n=e.length-1;n>=0&&Bp(e[n].cp);n--){let r=e[n];t+=r.kerningBefore+r.advance+r.tracking}return t}function hK(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 mK(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 yK=new Set,W0={box:null,inkWidth:.5};function SM(e,t,n,r,o,i,s,a){let{alignWidth:l,justify:u}=o,{entries:c}=e,d=pK(c),f=e.width-d,p=l-f,h=u&&e.wrapped&&Number.isFinite(l)&&p>0?hK(c):yK,m=h.size>0?p/h.size:0,y=m*h.size,b=y>0?0:mK(r,l,f),w=d>0&&n.levels[c.length-1]%2===1?b-d:b,g=t+e.ascent,P=w,S=-1,v=-1,A=0,{visual:N}=n;for(let D=0;D<N.length;D++){let B=N[D],K=c[B],W=S<0?0:B===S+1?K.kerningBefore:S===B+1?c[S].kerningBefore:0;W!==0&&i.widen(s+(v>=0?v:S),W),P+=W,S=B;let Q=K.advance+K.tracking+(h.has(B)?m:0);Q!==0&&(v=B),i.set(s+B,K,n.levels[B],P,Q,g-K.baselineShift),i.setVisual(s,A++,B),P+=Q}let M=w+e.width+y,C=t+e.height,F=i.boxes[a];return W0.box=F!==void 0?F.refill(w,t,M,C,g,e.srcEnd,y>0,s,c.length):i.boxes[a]=new Pt(w,t,M,C,g,e.srcEnd,y>0,i,s,c.length),W0.inkWidth=f+y,W0}function K0(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,Hp(t,e),t.lineHeight=e.lineHeight,t.align=e.align,t.justify=e.justify===!0||e.align==="justify",t.bidi=j0(e),t.shaper=ju(e),t.direction=e.direction??"auto",t.tabSize=e.tabSize??8,t}function Hp(e,t){t.alignWidth===void 0?e.alignWidth=t.maxWidth:e.alignWidth=t.alignWidth}function j0(e){return e.bidi??KE()}function ju(e){return e.shaper??cE()}var gK=[],bK=[],kM=[],xK=K0({maxWidth:0,lineHeight:0,align:"left"}),wK={maxWidth:.5,alignWidth:.5,lineHeight:.5,justify:!1},PK=e=>Oi(kM[e]);function TK(e,t,n,r){return yM(t,n,o=>e.mirror(o),r)}function vM(e,t){let{maxWidth:n,alignWidth:r,lineHeight:o,align:i,justify:s,bidi:a,shaper:l,direction:u,tabSize:c}=K0(t,xK),d=mM(e,c,gK,bK,l),f=kM;f.length=d.length;for(let S=0;S<d.length;S++)f[S]=d[S].cp;let p=a?PE(a,f,PK,u):null;a||$E(f);let h=wK;h.maxWidth=n,h.alignWidth=r,h.lineHeight=o,h.justify=s;let m=TM(d,f,h),y=0;for(let S=0;S<m.length;S++)y+=m[S].entries.length;let b=m.length>0?Op.take(y):null,x=b!==null?b.boxes:[],w=0,g=0,P=0;for(let S=0;S<m.length;S++){let v=m[S],A=TE(p,v.start,v.entries.length);a&&(v.entries=TK(a,v.entries,A.levels,e));let N=u!=="auto"?u:jE(v.entries.length>0?p?.baseLevel(v.start)??0:0),M=SM(v,w,A,i0(i,N),h,b,P,S);P+=v.entries.length,g=Math.max(g,M.inkWidth),w+=v.height}return x.length=m.length,b===null?{lines:x,bounds:{width:g,height:w}}:(b.bounds.width=g,b.bounds.height=w,b.laid??={lines:x,bounds:b.bounds})}Pe();Pe();var Er=11;function AM(e){let{font:t,glyph:n}=e;return t!==null&&n!==null&&n.width!==0&&n.page>=0}function $0(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 Y0=new WeakSet,RM={quads:Fp("quads",e=>{Y0.add(e);let t=e.quadData,n=[];for(let r=0,o=0;r<t.length;r+=Er,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 EM(e,t){return t==="outline"&&Sr(e.stroke)?e.stroke:void 0}function NM(e,t){return`${bo(e.fill?.paint)}|${ru(EM(e,t))}`}function X0(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(Je.group!==null&&Je.run===t.run&&Je.source===n&&Je.page===a&&Je.family===r&&Je.weight===o&&Je.style===i&&Je.bold===s.bold&&Je.italic===s.italic)return Je.group;let l=e[t.run],u=null,c=null;for(let d=0;d<Ao.length;d++){let f=Ao[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??=NM(l,n),f.paint??=NM(e[f.run],n),f.paint!==c))){u=p;break}}if(u===null){let d=EM(l,n);u=d===void 0&&n!=="color"?q0.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:ta,glyphs:[]},RM),d&&(u.stroke=d),n==="color"&&(u.colorGlyphs=[]));let f=Ao.length,p=IM[f];p===void 0?(p={group:u,run:t.run,paint:c},f<kK&&(IM[f]=p)):(p.group=u,p.run=t.run,p.paint=c),Ao.push(p)}return Je.group=u,Je.run=t.run,Je.family=r,Je.weight=o,Je.style=i,Je.bold=s.bold,Je.italic=s.italic,Je.source=n,Je.page=a,u}var ta=[],q0=[],SK=1024;function MM(e){q0.length>=SK||e.stroke!==void 0||e.colorGlyphs!==void 0||Y0.has(e)||(e.quadData=ta,gt(e.glyphs,0),q0.push(e))}var Ao=[],IM=[],kK=64,Je={group:null,run:-1,family:"",weight:0,style:"normal",bold:!1,italic:!1,source:"atlas",page:0};function CM(e){for(let t=0;t<Ao.length;t++)e.push(Ao[t].group),Ao[t].group=null;gt(Ao,0),Je.group=null}Pe();Z();var OM=5e-4,FM=4096,Gp=new Map,Up=new Map;function LM(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=pg(t,n,r,o);return i===void 0||!(i>0)?null:{growth:i,join:t==="atlas"?"miter":"round"}}function vK(e,t,n){let r=LM(n);if(r===null)return e;let o=`${r.growth}|${r.join}|${t}`,i=Gp.get(o);return i||(i=wb(bb(e,r.growth,{join:r.join,tolerance:OM}),{tolerance:OM}),Gp.size>=FM&&Gp.clear(),Gp.set(o,i),i)}function _M(e,t){let n=LM(t);if(n===null)return null;let r=`bold:${n.growth}:${n.join}`,o=`${r}|${e}`,i=Up.get(o);return i===void 0&&(i=qg(vK(fi(e),e,t)),Up.size>=FM&&Up.clear(),Up.set(o,i)),{d:i,tag:r}}function DM(e,t,n,r=!1){let o=e.resolved.source==="outline";if(!o&&!r&&(n===void 0||t.fontSize<n&&!Sr(t.stroke)))return null;let i=AK(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=_M(i,e.resolved);return c&&{d:c.d,key:`${u}|${c.tag}`}}function AK(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:Jy(t,n,r,e.cp)}function RK(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 NK(e){let t=e.map(n=>ei(xn(n.fontFamily,n.fontWeight,n.fontStyle)));return n=>t[n]}var IK=e=>e.underline||e.strikethrough||e.overline;function EK(e){return t=>Rf(e[t].fill)?bo(e[t].fill.paint):null}var MK=B0(),$u=[],BM=16384;function J0(e,t,n,r){let{groups:o,decorations:i}=r;gt(o,0),gt(i,0);let s=t.some(IK)?NK(t):null,a=s&&EK(t),l=0,{lines:u}=e;for(let h=0;h<u.length;h++)l+=Pt.count(u[h]);let c=l*Er;c<=BM&&$u.length<c&&($u=Fi(c));let d=c<=BM?$u:Fi(c),f=null,p=0;for(let h=0;h<u.length;h++){let m=u[h],y=Pt.columns(m),b=y!==null?Pt.start(m):0,x=Pt.count(m),w=s&&xE(t,s,a);for(let g=0;g<x;g++){let P=y!==null?y.visual(b,g):-1,S=y!==null?y.glyph(b,P,MK):m.glyphs[g];w?.add(S);let v=t[S.run],A=y!==null?y.drawsInk(b,P):m.cells[S.cell].drawsInk,N=A?DM(S,v,n.outlineMinSize):null,M=S;if(A&&N===null&&S.shaped){let D=RK(S);D?M=D:N=DM(S,v,n.outlineMinSize,!0)}if(!Rf(v.fill)&&!(N!==null&&Sr(v.stroke)))continue;if(N!==null){let D={...N,x:S.x,baselineY:S.baselineY,scale:S.fontSize};S.rotate&&(D.rotate=S.rotate),X0(t,S,"outline").glyphs.push(D);continue}if(!AM(M))continue;let C=X0(t,M,M.glyph.color?"color":M.resolved.source);f===null&&(f=C,C.quadData=d);let F=C.quadData;F===ta&&(C.quadData=F=[]),C===f?($0(M,F,p),p+=Er):$0(M,F,F.length),C.colorGlyphs?.push(M.glyph)}if(w)for(let g of w.end()){let{run:P,...S}=g;i.push({...S,fill:t[P].fill})}}if(f!==null&&d!==$u)d.length=p;else if(f!==null){let h=Vu(p);for(let m=0;m<p;m++)h[m]=$u[m];f.quadData=h}return CM(o),r}var Q0=new WeakMap,CK=[];function Z0(e){return Q0.get(e)}function Wp(e){let t=Q0.get(e);return t===void 0&&(t=CK.pop()??{generation:-1,variants:[],painting:null,paintedOn:null,paintedStamp:0,paintMin:void 0,listed:null},Q0.set(e,t)),t}var OK=32,Vp=new WeakMap;function FK(e){return e.lines.length>0?Pt.columns(e.lines[0])?.stamp??0:0}function LK(e){let t=e.lines.length>0?Pt.columns(e.lines[0]):null;if(t!==null)return t.paintings;let n=Vp.get(e);return n===void 0&&Vp.set(e,n=[]),n}var tw=[],_K=1024;function HM(e,t,n,r,o,i){let s=tw.pop();return s===void 0?{generation:r,key:o,bucket:i,runs:o===null?t:null,painted:J0(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,J0(e,t,n,s.painted),s)}function DK(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 GM(e,t){let n=`${t}`;for(let r of e)n+=`|${r.underline?1:0}${r.strikethrough?1:0}${r.overline?1:0}${bo(r.fill?.paint)}|${ru(r.stroke)}`;return n}function UM(e){return e.key===null&&(e.key=GM(e.runs,e.bucket),e.runs=null),e.key}function nw(e,t,n={},r="keep"){let o=ti(),i=n.outlineMinSize,s=Z0(t),a=FK(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 ew(l,r);let c=DK(t,i);if(u&&l.bucket===c)return s.paintMin=i,ew(l,r);let d=LK(e),f=null;if(d.length>0){let h=GM(t,c);for(let m=0;m<d.length;m++){let y=d[m];if(!(y.bucket!==c||UM(y)!==h)){d.splice(m,1),y.generation===o&&(f=y);break}}f??=HM(e,t,n,o,h,c)}else f=HM(e,t,n,o,null,c);d.length>=OK&&d.shift(),d.push(f);let p=s??Wp(t);return p.painting!==null&&p.painting!==f&&WM(p.painting,t),p.paintedOn=e,p.paintedStamp=a,p.painting=f,p.paintMin=i,ew(f,r)}function WM(e,t){e.runs===t&&UM(e)}function ew(e,t){return t==="keep"&&(e.pinned=!0),e.painted}function VM(e){let t=e.lines.length>0?Pt.columns(e.lines[0]):null,n;if(t!==null)n=t.paintings;else{if(n=Vp.get(e),n===void 0)return;Vp.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=ta,MM(a)}gt(i,0),gt(o.painted.decorations,0),o.runs=null,o.key=null,tw.length<_K&&tw.push(o)}gt(n,0)}var JM=8,QM=64,Mr=[],zM=-1,KM=0,Mn=(e,t)=>e===t||e!==e&&t!==t;function ZM(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===ju(t)}var oa=e=>e.lines.length>0?Pt.columns(e.lines[0]):null;function jM(e,t){if(t==="keep"){let n=oa(e);n!==null&&(n.pinned=!0)}return e}function e2(e){let t=oa(e);t===null||t.owners>0||t.listed||t.pinned||(VM(e),t.recycle())}var ow=[],BK=1024;function $M(e){for(let t=0;t<e.length;t++){let n=e[t],r=oa(n.laid);r!==null&&(r.owners--,e2(n.laid)),n.laid=HK,ow.length<BK&&ow.push(n)}gt(e,0)}var HK={lines:[],bounds:{width:0,height:0}};function iw(e,t,n,r){return e.maxWidth=t.maxWidth,Hp(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=ju(t),e.laid=r,e}function GK(e,t,n){let r=ow.pop();if(r!==void 0)return iw(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:ju(e),laid:n};return Hp(o,e),o}function ra(e,t){return Math.imul(e^t,16777619)}function na(e,t){return ra(e,t===(t|0)?t:Math.round(t*4096))}function rw(e,t){e=ra(e,t.length);for(let n=0;n<t.length;n++)e=ra(e,t.charCodeAt(n));return e}function UK(e){let t=ra(2166136261,e.length);for(let n=0;n<e.length;n++){let r=e[n];t=rw(t,r.text),t=rw(t,r.fontFamily),t=na(t,r.fontSize),t=na(t,r.fontWeight),t=ra(t,r.fontStyle==="italic"?1:0),t=na(t,r.letterSpacing),t=na(t,r.baselineShift),t=na(t,r.rotate??0),t=na(t,r.strutSize??-1),t=ra(t,r.fontFeatures?.length??0),t=rw(t,r.lang??"")}return t&1073741823}var YM=[];function qM(e,t){return e===t||e!==void 0&&t!==void 0&&ud(e,t,Mn)}var WK=(e,t)=>ud(e??YM,t??YM);function VK(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)||!qM(r.sizeMap,o.sizeMap)||!WK(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||!qM(i.starts,s.starts)))return!1}return!0}function Yu(e,t,n="keep"){let r=fl(),o=j0(t),i=Wp(e);if(i.generation!==r)i.generation=r,$M(i.variants);else{let u=i.variants;for(let c=0;c<u.length;c++){let d=u[c];if(ZM(d,t,o)){for(let f=c;f>0;f--)u[f]=u[f-1];return u[0]=d,jM(d.laid,n)}}}let s=zK(e,t,o,r,i),a=i.variants;a.length>=JM&&$M(a),a.unshift(GK(t,o,s));let l=oa(s);return l!==null&&l.owners++,jM(s,n)}function zK(e,t,n,r,o){if(zM!==r){for(let d of Mr)XM(d),d.runs=KK;Mr=[],zM=r}let i=UK(e),s=0;for(let d=0;d<Mr.length;d++){let f=Mr[d];if(f.hash===i&&ZM(f,t,n)&&VK(f.runs,e))return f.used=++KM,f.laid;f.used<Mr[s].used&&(s=d)}let a=Mr.length>=QM;a&&XM(Mr[s]);let l=vM(e,t),u=a?iw(Mr[s],t,n,l):jK(t,n,l);u.hash=i,u.runs=e,u.used=++KM,o.listed=u;let c=oa(l);return c!==null&&(c.listed=!0),a||Mr.push(u),l}var KK=[];function jK(e,t,n){return iw({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 XM(e){let t=oa(e.laid);t!==null&&(t.listed=!1,e2(e.laid))}function qu(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 zp(e,t=1){let n=s0(e.style,{fill:e.fill,stroke:e.stroke},t),r=e.runs&&e.runs.length>0?e.runs:e.text;return{style:n,runs:Fu(QI(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 sw(e,t=1){let{runs:n,opts:r}=zp(e,t),o=Yu(n,r);return{laid:o,x:e.x,y:e.y+qu(e.verticalAlign,e.height,o.bounds.height)}}function Kp(e,t={}){let n=t.padding??0,{laid:r,x:o,y:i}=sw(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}Z();function Ro(e){if(!e)return $K;let t=e*Un;return[Math.cos(t),Math.sin(t)]}var $K=[1,0];var No={maxWidth:0,alignWidth:void 0,lineHeight:0,align:"left",direction:"auto",tabSize:0,justify:void 0},jp={laid:null,dx:0,dy:0};function $p(e){let t=e.style;No.maxWidth=e.maxWidth??1/0,No.alignWidth=e.width,No.lineHeight=t.lineHeight??Ee.lineHeight,No.align=e.align??t.align??Ee.align,No.direction=e.direction??t.direction??Ee.direction,No.tabSize=t.tabSize??Ee.tabSize,No.justify=e.justify;let n=Yu(e.runs,No,"read");return jp.laid=n,jp.dx=e.x,jp.dy=e.y+qu(e.verticalAlign,e.height,n.bounds.height),jp}var Yp={side:.5,above:1.5,below:1};function t2(e,t){let{laid:n,dx:r,dy:o}=$p(e),i=q.meanScaleOf(t),s=q.minScaleOf(t),a=e.runs.map(f=>f.stroke?ia(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,y=-Yp.side*h-m,b=p.advance+Yp.side*h+m,x=-Yp.above*h-m,w=Yp.below*h+m,[g,P]=Ro(p.rotate);for(let S=0;S<4;S++){let v=S===0||S===3?y:b,A=S<2?x:w,N=p.x+v*g-A*P,M=p.baselineY+v*P+A*g;N<l&&(l=N),N>c&&(c=N),M<u&&(u=M),M>d&&(d=M)}}return l===1/0?null:_i(l+r,u+o,c+r,d+o,t)}var YK=4,Di={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Bi={minX:-1/0,minY:-1/0,maxX:1/0,maxY:1/0};function lw(e,t,n){let r=Di;for(let o of e)if(r=JK(r,uw(o,t,n)),r===Bi)break;return r}function uw(e,t,n){switch(e.kind){case"group":{let r=e.transform?q.multiply(t,e.transform):t,o=lw(e.children,r,n);return e.effects&&e.effects.length>0&&(o=XK(o,$s(e.effects)/n)),e.clip?cw(o,qp(e.clip,void 0,r)):o}case"path":case"image":case"sprites":return dw(e,t)??Bi;case"text":return t2(e,t)??Di;case"shader":return qK(e)??Bi}}function qK(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 XK(e,t){return e===Di||e===Bi||t===0?e:Number.isFinite(t)?{minX:e.minX-t,minY:e.minY-t,maxX:e.maxX+t,maxY:e.maxY+t}:Bi}function JK(e,t){return e===Di||t===Bi?t:t===Di||e===Bi?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 cw(e,t){if(!t||e===Di)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?Di:n}function dw(e,t){switch(e.kind){case"path":return qp(e.path,e.stroke,t);case"image":return _i(e.x,e.y,e.x+e.w,e.y+e.h,t);case"sprites":return ZK(e.sprites,t)}}function qp(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?QK(t,n):0;return _i(r-a,o-a,i+a,s+a,n)}function QK(e,t){return ia(e,q.meanScaleOf(t),q.minScaleOf(t))}function ia(e,t,n=t){let r=n>0?n:t,o=at(e.width??1,typeof e.width=="object"?r:t),i=Ni(o,e.vertexWidths),s=Math.max(e.miterLimit??YK,Math.SQRT2),a=Cu(e);return Math.max(Math.abs(i)*s,a.world,Wt({px:a.px},r))}function ZK(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:_i(n,r,o,i,t)}function _i(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 Cr=1;function pw(e,t,n,r){return n2(e,t,r2(n),r)}function n2(e,t,n,r){let o=null;for(let i=0;i<e.length;i++){let s=e[i],a=ej(s,t,n,r);if(a===s){o?.push(s);continue}o??=e.slice(0,i),a&&o.push(a)}return o??e}function ej(e,t,n,r){switch(e.kind){case"group":{if(Yn(e.composite))return e;if(e.effects&&e.effects.length>0)return fw(uw(e,t,r),n)?null:e;let o=e.transform?q.multiply(t,e.transform):t,i=n2(e.children,o,n,r);return i===e.children?e:i.length===0?null:{...e,children:i}}case"path":case"image":case"sprites":return fw(dw(e,t),n)?null:e;default:return e}}function hw(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 fw(_i(r,i,o,s,t),r2(n))}function r2(e){return{minX:e.x-Cr,minY:e.y-Cr,maxX:e.x+e.width+Cr,maxY:e.y+e.height+Cr}}function fw(e,t){return e!==null&&(e.maxX<t.minX||e.minX>t.maxX||e.maxY<t.minY||e.minY>t.maxY)}function Xu(e,t,n,r){let o=lw(e,t,r);for(let i of n)o=cw(o,qp(i.path,void 0,i.transform));return tj(o,r)}function tj(e,t){let n=Math.floor((e.minX-Cr)*t),r=Math.floor((e.minY-Cr)*t),o=Math.ceil((e.maxX+Cr)*t),i=Math.ceil((e.maxY+Cr)*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 Hi(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 sa(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 mw(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&&Tx(l,t,a??"effect",i,e.textureCache,{value:1}),Be(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 Xp(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),mw(e,t,n,r.width,r.height,void 0,o),l?l.restore?l.restore():i.viewport(0,0,s,a):e.restoreTargetRect?.()}function Jp(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 Ju(e,t,n){return e.x>=0&&e.y>=0&&e.x+e.width<=t&&e.y+e.height<=n}var Qp=64;function nj(e,t,n,r,o,i,s){let a=e.effects&&e.effects.length>0?$s(e.effects):0;if(!Number.isFinite(a))return{x:0,y:0,width:r,height:o};if(Yn(e.composite)&&!EN(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=Xu([{...e,clip:void 0}],t,[],i),d=Hi(c,u);if(d.width===0||d.height===0)return null;let f=Math.min(s,Math.ceil(d.width/Qp)*Qp),p=Math.min(s,Math.ceil(d.height/Qp)*Qp),h=Ju(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 o2(e,t,n,r,o,i){let s=e.gl,a=e.renderTarget??null,l=r/e.widthCss,u=nj(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),y=e.state.pushIsolated({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix});e.clipDepth=0,e.clipStack=[],e.drawBatch.clip=null;let b=Ju(u,r,o);e.projection=b?void 0:Jp(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 g of t.children)i(e,g);ye(e),s.disable(s.BLEND),s.disable(s.STENCIL_TEST);for(let g of t.effects??[]){let P=e.ensureProgram?.(g.program.id)??null;if(!P){Px(g.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),mw(e,P,m.texture,u.width,u.height,g.uniforms,void 0,g.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,sa(e,r,o,h);let w=e.ensureProgram?.(ip())??null;if(w){wt(e);let g=Yn(t.composite);g&&gx(s,t.composite),Xp(e,w,m.texture,u,y),g&&gx(s,"source-over")}n.release(m)}var rj=new WeakMap,oj=new WeakMap;function yw(e,t){let n=t?rj:oj,r=n.get(e);if(r!==void 0)return r;let o=e.every(i=>ij(i,t));return n.set(e,o),o}function ij(e,t){switch(e.kind){case"group":return e.effects&&e.effects.length>0&&!Number.isFinite($s(e.effects))?!1:yw(e.children,t);case"path":return Zp(e.fill?.paint,t)&&Zp(e.stroke?.paint,t);case"text":return e.runs.every(n=>Zp(n.fill?.paint,t,!0)&&Zp(n.stroke?.paint,t,!0));case"image":case"sprites":return!0;case"shader":return!1}}function Zp(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 sj={alpha:1,colorMatrix:Vt},i2=new WeakSet;function s2(e,t,n,r){let o=e.retained,i=e.deviceWidth,s=e.deviceHeight;if(!o||!i||!s)return!1;if(e.renderTarget!=null&&i2.has(e.renderTarget)||Yn(t.composite)||yx(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:g,transform:P})=>({path:g,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&&yw(f,e.viewMatrix!==void 0),m=o.lookup(l,i,s,c,d,h?p:void 0),y;if(m.kind==="through")return e.state.pop(),!1;if(m.kind==="kept")y=m.pixels;else{let g=c.window??m.window,P=Xu(f,e.state.transform,u,p),S=o.reserve(l,i,s,Hi(P,g),d,h?{box:P,window:g}:void 0);if(!S)return e.state.pop(),!1;ye(e),S.fbo&&aj(e,f,u,S.fbo,S,r),y=S.commit(c)}e.state.pop();let{texture:b,rect:x}=y;if(!b)return!0;ye(e);let w=e.ensureProgram?.(ip())??null;return w&&(wt(e,0),Xp(e,w,b,x,sj)),!0}function aj(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,y=s.isEnabled(s.SCISSOR_TEST),b=a/e.widthCss,x=Ju(u,a,l);e.projection=x?void 0:Jp(u,b);let w=c.length>1?t.map(g=>Xu([g],e.state.transform,[],b)):null;for(let g of c){let P=g.y+g.height,S=()=>{x?s.viewport(-g.x,P-l,a,l):s.viewport(u.x-g.x,P-u.y-u.height,u.width,u.height),s.scissor(0,0,g.width,g.height),s.enable(s.SCISSOR_TEST)},v={fbo:r,restore:S,fragOrigin:[-g.x,P-l],window:g};i2.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)Su(e,A.path,A.transform);for(let A=0;A<t.length;A++)(!w||lj(w[A],g))&&i(e,t[A]);ye(e),o.resolve(g)}e.clipDepth=f,e.clipStack=p,e.drawBatch.clip=h,e.projection=m,e.renderTarget=d,sa(e,a,l,y)}function lj(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 aa=xt(),Zu=aa.reflection;function l2(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)&&op(t,n.vert,n.frag)}return aa.push(e.id,e)}function Gi(e){let t=e??"solid",n=aa.get(t);return!n&&Qu.has(t)&&u2(t).catch(()=>{}),n}var Qu=new Map,a2=new Map;function u2(e){let t=a2.get(e);if(t)return t;let r=Qu.get(e)().then(o=>{if(o.id!==e)throw new Error(`weasel: the loader for paint kind "${e}" resolved to "${o.id}".`);aa.has(e)||l2(o)}).catch(o=>{throw console.error(`weasel: paint kind "${e}" failed to load:`,o),o});return a2.set(e,r),r}function gw(e){return aa.has(e)||Qu.has(e)}function bw(e){let t=e??[...Qu.keys()],n=[];for(let r of t)if(!aa.has(r)){if(!Qu.has(r))return Promise.reject(new Error(`weasel warmPaintKinds: "${r}" is neither registered nor loadable.`));n.push(u2(r))}return Promise.all(n).then(()=>{})}Pe();var xw=8,uj=1/8;function eh(e,t){if(!(e>0)||!(t>0)||!Number.isFinite(t))return t;let n=Math.ceil(Math.LN2/(2*Math.log1p(uj/e)));return 2**(Math.round(Math.log2(t)*n)/n)}var c2=new WeakMap;function cj(e,t,n){let r=at(e.width??1,1),o=Xs(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,Po(i),Po(n.start?.metric),Po(n.end?.metric),Tr(e.trim)].join("|")}function th(e,t,n,r={}){let o=c2.get(e);o===void 0&&(o=new Map,c2.set(e,o));let i=cj(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=Xs(t,a),u=Ei(e,t,{flattenTolerance:n,startInset:d2(l.start,r.start,r.ribbon),endInset:d2(l.end,r.end,r.ribbon),metric:r.ribbon?.metric});return s===void 0&&o.size>=xw&&o.clear(),o.set(i,{mesh:u,vertexWidths:t.vertexWidths}),u}function d2(e,t,n){return t?.metric===n?.metric?e:{length:e,metric:t?.metric??null}}var dj={};function ec(e,t,n={}){let r=n.quantize===!1?(m,y)=>y:eh,o=t.stroke,{markerStart:i,markerMid:s,markerEnd:a}=o;if(typeof o.width!="object"&&!la(i)&&!la(s)&&!la(a))return{cmd:t,spaces:dj};let l={...o},{scale:u,metric:c}=vu(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(y=>y/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 la(i)&&(l.markerStart=ww(i,u,r)),la(s)&&(l.markerMid=ww(s,u,r)),la(a)&&(l.markerEnd=ww(a,u,r)),{cmd:{...t,stroke:l},spaces:h}}function la(e){return typeof e=="object"&&typeof e.size=="object"}function ww(e,t,n){return{...e,size:qs(e,0,n(e.size.px,t))}}Pe();Z();Pe();function f2(e,t){if(!hj(e))return Gi(e.kind)?.inPoseFrame?.(e,t)??e;if(fj(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(!pj(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 fj(e){return Nf(e)&&e.units==="bounds"}function pj(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 hj(e){let t=e.kind??"solid";return t==="solid"||Nf(e)||t==="linear-gradient"||t==="radial-gradient"||t==="conic-gradient"}Pe();function p2(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 mj=4096*4096,yj=4,gj=300,bj=150,xj=256*1024*1024,Et=new Map,h2=xj,Tw=0,m2=0,wj=Ce(),nh=new Map;function Sw(e){return/^data:image\/svg\+xml[;,]/i.test(e)?!0:/^(data|blob):/i.test(e)?!1:/\.svgz?$/i.test(e.replace(/[?#].*$/,""))}function Pj(){if(typeof Image>"u"||typeof createImageBitmap>"u")throw new Error("weasel imageCache: no DOM image loader in this environment")}async function g2(e){let t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}function Tj(e){let t=nh.get(e);return t||(t=g2(e),nh.set(e,t),t.catch(()=>nh.delete(e))),t}async function Sj(e,t){let n=await Tj(e),r=t?.width??(n.naturalWidth||gj),o=t?.height??(n.naturalHeight||bj),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 kj=async(e,t)=>(Pj(),Sw(e)?Sj(e,t):createImageBitmap(await g2(e))),b2=kj;function Pw(){wj.emit()}var y2=e=>e?e.width*e.height*4:0;function x2(e){let t=0;for(let n of Et.values())t+=y2(n.bitmap);if(t>h2){let n=[...Et].filter(([r,o])=>r!==e&&o.bitmap!==void 0&&o.readAt<=m2&&!LR(o.bitmap));n.sort((r,o)=>r[1].readAt-o[1].readAt);for(let[r,o]of n){if(t<=h2)break;t-=y2(o.bitmap),T2(r)}}m2=Tw}function vj(e){let t={status:"loading",readAt:++Tw};Et.set(e,t),b2(e).then(n=>{Et.get(e)===t&&(Et.set(e,{status:"ready",bitmap:n,readAt:t.readAt,...Sw(e)?{vector:{natural:{width:n.width,height:n.height},scale:1,failed:new Set,floor:0}}:{}}),x2(e),Pw())},()=>{Et.get(e)===t&&(Et.set(e,{status:"error",readAt:t.readAt}),Pw())})}function Aj(e,t){let n=Math.max(t.width/e.width,t.height/e.height);if(!(n>0)||!Number.isFinite(n))return;let r=_R(),o=Math.min(r/e.width,r/e.height,Math.sqrt(mj/(e.width*e.height)));return Math.min(2**Math.ceil(Math.log2(n)),o)}function Rj(e,t,n,r){if(n.pending!==void 0)return;let o=Aj(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*yj>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))};b2(e,a).then(l=>{if(Et.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&&vf(u),x2(e),Pw()},()=>{Et.get(e)===t&&(n.pending=void 0,n.failed.add(s))})}function ca(e,t){if(e.startsWith(w2))return ua.get(e)?.deref();let n=Et.get(e);if(!n){vj(e);return}return n.readAt=++Tw,t&&n.vector&&Rj(e,n,n.vector,t),n.bitmap}var w2="weasel-bitmap:",ua=new Map,Nj=new WeakMap;var Ij=new FinalizationRegistry(e=>{ua.get(e)?.deref()===void 0&&ua.delete(e)});function P2(e){let t=Et.get(e);if(t?.vector)return t.vector.natural;let n=t?.bitmap??ua.get(e)?.deref();return n?{width:n.width,height:n.height}:void 0}function kw(e){return e.startsWith(w2)?ca(e)===void 0?"idle":"ready":Et.get(e)?.status??"idle"}function T2(e){let t=ua.get(e)?.deref();ua.delete(e),t!==void 0&&(Nj.delete(t),Ij.unregister(t),vf(t));let n=Et.get(e);Et.delete(e),nh.delete(e),n?.bitmap&&vf(n.bitmap)}var vw="image:";function k2(e){return{id:vw+e.src}}function S2(e){let t=e.slice(vw.length),n=ca(t),r=xi.get(e)?.source;n!==r&&(n?Sf(e,n,P2(t)):kf({id:e}))}Tf(vw,{revive:S2,touched:S2});function Aw(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 Ej(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 A2(e){let t=Aw(e),{color:n}=e;switch(e.kind){case"hatch":{let r=e.lineWidth??1;return{size:t,shapes:v2(t,r,n)}}case"crosshatch":{let r=e.lineWidth??.8;return{size:t,shapes:[...v2(t,r,n),...Mj(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=Ej(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 v2(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 Mj(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 R2(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 Cj=256,Rw="pattern:",Or=new Map;function Oj(e){let t=e,n={};for(let r of Object.keys(t).sort())n[r]=t[r];return Rw+JSON.stringify(n)}function Fj(e){let t=zb(e),n=Oj(t),r=Or.get(n);return r!==void 0?(N2(n),r):I2(n,t)}function N2(e){let t=Or.get(e);t!==void 0&&(Or.delete(e),Or.set(e,t))}function I2(e,t){let n=ou(t.kind)?p2({size:Aw(t),draw:o=>R2(o,A2(t))}):null,r=n?Sf(e,n):null;for(Or.delete(e),Or.set(e,r);Or.size>Cj;)Lj(Or.keys().next().value);return r}function Lj(e){Or.delete(e);let t=xi.get(e)?.source;kf({id:e}),t&&"close"in t&&t.close()}function _j(e){let t;try{t=JSON.parse(e.slice(Rw.length))}catch{return}typeof t!="object"||t===null||!("kind"in t)||I2(e,t)}Tf(Rw,{revive:_j,touched:N2});function E2(e){if(Vb(e)){let{width:n,height:r}=e;return{kind:"texture",texture:k2(e),...n!==void 0?{width:n}:{},...r!==void 0?{height:r}:{},...If(e)}}if(!Wb(e))return e;let t=Fj(e);return t?{kind:"texture",texture:t,...If(e)}:null}function Ui(e,t){return E2(f2(e,t))}function Kt(e,t){if(e.paint==null)return null;let n=Ui(e.paint,t);return n===null?null:n===e.paint?e:{...e,paint:n}}function Wi(e,t){if(e.paint==null)return null;let n=Ui(e.paint,t);return n===null?null:n===e.paint?e:{...e,paint:n}}function M2(e,t,n,r){let o=e??n;if(o!=="none")return o==="line"?t.paint:Ui(o,et(r))??void 0}function Nw(e,t){let n=[];for(let{entry:r,path:o,size:i,space:s}of e){let a=M2(r.fill,t,"line",o),l=r.outline?r.outline.width*i:0,u=r.outline?{paint:M2(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 C2=new WeakMap,O2=new WeakMap,Iw=e=>e===void 0?"":typeof e=="string"?e:`${e.key}@${String(e.size??"")}`;function Dj(e){let t="";for(let n of[e.markerStart,e.markerMid,e.markerEnd]){let r=n===void 0?void 0:To(Mi(n));if(r===void 0){t+="/";continue}let o=pp(r,e);if(o===null)return null;t+=`${o}/`}return t}function Bj(e,t,n){if(n!==null){let i=C2.get(e);return i===void 0&&C2.set(e,i=new Map),i}let r=O2.get(e);r===void 0&&O2.set(e,r=new WeakMap);let o=r.get(t);return o===void 0&&r.set(t,o=new Map),o}function F2(e,t,n,r,o,i={}){if(n.markerStart===void 0&&n.markerMid===void 0&&n.markerEnd===void 0)return[];let s=Dj(n),a=Bj(e,t,s),l=[r,o??"",Eu(),Iw(n.markerStart),Iw(n.markerMid),Iw(n.markerEnd),s??"",ku(i.start),ku(i.mid),ku(i.end),Tr(n.trim)].join("|"),u=a.get(l);if(u===void 0){let c=Mu(e,n,r,o,i);u={heads:c,paint:n.paint,cmds:Nw(c,n)},a.size>=xw&&a.clear(),a.set(l,u)}else u.paint!==n.paint&&(u.paint=n.paint,u.cmds=Nw(u.heads,n));return u.cmds}Z();var L2=new WeakMap;function Ew(e,t,n){let r=L2.get(e);r===void 0&&(r=new WeakMap,L2.set(e,r));let o=r.get(t);return o===void 0&&(o=Hl(e,t,n),r.set(t,o)),o}function _2(e){if(e.path.kind!=="polygon")return e;let{path:t,anchorSources:n}=ho(e.path);if(t===e.path)return e;let r={...e,path:t};if(n&&e.vertexColors&&(r.vertexColors=Ew(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:Ew(o,n,4)}:{},...i?{vertexWidths:Ew(i,n,1)}:{}}}return r}var Hj=65536;function B2(e,t,n,r=Hj){let o=Vj(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(Wj(o,d,f/3+1,a,l),!(n?Gj(d,o,l,i,s):Uj(d,o,l,i,s)))return null}return{vertices:new Float32Array(i.verts),indices:new Uint32Array(i.idx),...e.origin?{origin:e.origin}:{}}}function Gj(e,t,n,r,o){for(let i of n){if(--o.left<0)return!1;let s=H2(e,3,t.planes,i);if(s===Ow)continue;if(s===0)return Cw(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]=Mw(a,l,t.planes,(i*3+u)*3,1)}Cw(a,l,r)}return!0}function Uj(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=H2(l,u,t.planes,s);if(c===Ow){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,y]=Mw(d,f,t.planes,h,-1);y>=3&&a.push([m,y]),[d,f]=Mw(d,f,t.planes,h,1)}}if(i=a,i.length===0)return!0}for(let[s,a]of i)Cw(s,a,r);return!0}var Ow=-1;function H2(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 Ow;a<t&&(o|=1<<i)}return o}var rh={buf:new Float32Array(16)};function Mw(e,t,n,r,o){rh.buf.length<(t+1)*2&&(rh.buf=new Float32Array((t+1)*4));let i=bu(e,t,2,o*n[r],o*n[r+1],o*n[r+2],rh.buf);return[rh.buf.slice(0,i*2),i]}function Cw(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 Wj(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 y=c;y<=d;y++)for(let b of u.cells[m*u.cols+y])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 D2=new WeakMap;function Vj(e,t){let n=D2.get(e);if(n!==void 0&&n.origin===t)return n.tris;let r=zj(e,t);return D2.set(e,{origin:t,tris:r}),r}function zj(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++)Kj(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:jj(a,u)}}function Kj(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 jj(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 y=h;y<=m;y++)for(let b=f;b<=p;b++)c[y*l+b].push(d)}return{x0:n,y0:r,cell:a,cols:l,rows:u,cells:c}}var $j=512,G2=new WeakMap;function W2(e,t,n){let r=G2.get(e);if(r!==void 0&&r.fill===t&&r.inner===n)return r.mesh;let o=t.requiresStencil?null:Yj(e,t,n);return G2.set(e,{fill:t,inner:n,mesh:o}),o}function Yj(e,t,n){let r=qj(t,e.origin);return r===null?B2(e,t,n):Xj(e,r,n)}function qj(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:kx(i,$j)}var Fr={a:new Float32Array(0),b:new Float32Array(0)};function Xj(e,t,n){let r=t.length/3;Fr.a.length<(r+4)*2&&(Fr.a=new Float32Array((r+4)*2),Fr.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||Fw(u,3,s,a);continue}if(n)Fw(Fr.a,U2(u,l,l.length,t,-1),s,a);else for(let f=0;f<l.length;f++)Fw(Fr.a,U2(u,l,f,t,l[f]),s,a)}return{vertices:new Float32Array(s),indices:new Uint32Array(a),...e.origin?{origin:e.origin}:{}}}function U2(e,t,n,r,o){let i=Fr.a,s=Fr.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=bu(i,a,2,c*r[u],c*r[u+1],c*r[u+2],s);let d=i;i=s,s=d}return i!==Fr.a&&Fr.a.set(i.subarray(0,a*2)),a}function Fw(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 Lw(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 Dw(e)}function _w(e){return e.ramps?Cs:Dw(e)<0?-1:Cs}function Lr(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 Dw(e)}function Dw(e){return e.textures.length+(e.ramps?1:0)+1<yt?e.textures.length+1:-1}function Io(e,t,n,r){return t.clipDepth===Ox(e)&&Nx(t.matrices,n,r)>=0&&Jj(t,np(e))}function Jj(e,t){return t===null||V2(e,t)!==void 0?!0:e.hullPlanes+t.count<=Ms}function V2(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 Eo(e){return e.batchState??={clipDepth:Ox(e),matrices:[],textures:[],ramps:!1,hullPlanes:0,areaGlyphs:!1},e.batchState}function Mo(e,t,n){let r=np(e);if(r===null)return n;let o=V2(t,r);return o===void 0&&(o={set:r,start:t.hullPlanes},(t.hulls??=[]).push(o),t.hullPlanes+=r.count),oR(n,o.start,r.count)}function Co(e,t,n){let r=Nx(e.matrices,t,n);return r===e.matrices.length&&e.matrices.push({colorMatrix:t,alpha:n}),r}Z();Z();Z();function oh(e,t,n){let r=n??Qj,o=hr([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 Qj=[1,0,0,1];var Zj=[0,0];function z2(e,t){let n=_s(t.texture.id);if(!n)return;let r=Vi(e,t.units),o=r&&oh(r,t.origin??{x:0,y:0},t.transform);if(!o)return null;let i=q.multiply(o,e.state.transform),[s,a]=Bw(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 Bw(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 K2(e,t,n){let r=Ks(e,!1),o=e.batchState;o!==void 0&&(!Io(e,o,r.colorMatrix,r.alpha)||Lr(o,t.id)<0||Lr(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=Eo(e),s=Lr(i,t.id);return s>i.textures.length&&(i.textures.push({kind:"atlas",id:t.id,fieldScale:Zj}),s=i.textures.length),r.slot=Mo(e,i,go(s,Co(i,r.colorMatrix,r.alpha))),r}function j2(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 Hw(e,t,n){let{slot:r,tint:o}=K2(e,n,4);e.drawBatch.pushGradientRect(t.x,t.y,t.width,t.height,e.state.transform,j2(n.uv,t.x,t.y),n.opacity*o[3],r,Os,o[0],o[1],o[2],1)||sn(e,t,n,Hw)}function Gw(e,t,n){let{slot:r,tint:o}=K2(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,j2(n.uv,i.x,i.y),n.opacity*o[3],r,Os,o[0],o[1],o[2],1)||sn(e,t,n,Gw)}function tc(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 z2(e,t);if(r!=="linear-gradient"&&r!=="radial-gradient"&&r!=="conic-gradient")return;let o=t,i=e$(e,o.units);return i?o.kind==="linear-gradient"?Uw(o,yi,t$(i,o)):o.kind==="radial-gradient"?Uw(o,rR,n$(i,o)):Uw(o,hf,r$(i,o)):null}function Uw(e,t,n){return{kind:"ramp",stops:e.stops,space:e.interpolate??"rgb",opacity:e.opacity,mode:t,uv:n}}function e$(e,t){let n=Vi(e,t);return n&&q.multiply(n,e.state.transform)}function t$(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 n$(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 r$(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 Ww(e,t){return e.mode===yi?{uv:{...e.uv,v0:t},post:1}:{uv:e.uv,post:t}}function Vi(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 Vw(e,t,n){let r=Vi(e,t);return!r||!n||n.x===0&&n.y===0?r:q.multiply(q.translated(q.identity(),-n.x,-n.y),r)}function $2(e,t){let n=Vi(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 o$=96,i$=1024,Y2={maxVertices:o$,maxVerticesInRun:i$};function zw(e,t){if(t.requiresStencil)return!1;let n=e.drawBatch.length>0?Y2.maxVerticesInRun:Y2.maxVertices;return t.vertices.length>>1<=n}function ih(e,t){let n=Pu(e);return sh(e,t,n?Vt:e.state.colorMatrix,n?1:e.state.alpha)}function sh(e,t,n,r){let o=e.batchState;o!==void 0&&!Io(e,o,n,r)&&ye(e),e.drawBatch.wouldOverflow(t)&&ye(e);let i=Eo(e),s=Co(i,n,r);return gi(Mo(e,i,go(eR,s)),yi)}function Kw(e,t,n,r){let o=Ks(e,!1),i=e.batchState;i!==void 0&&(!Io(e,i,o.colorMatrix,o.alpha)||Lw(i,t,n,r)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let s=Eo(e),a=Lw(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=Mo(e,s,go(a,Co(s,o.colorMatrix,o.alpha))),o}function nc(e,t,n,r){let o=Pu(e),i=o?Vt:e.state.colorMatrix,s=o?1:e.state.alpha,a=e.batchState;a!==void 0&&(!Io(e,a,i,s)||Lr(a,t)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let l=Eo(e),u=Lr(l,t);return u>l.textures.length&&(l.textures.push({kind:"atlas",id:t,fieldScale:n}),u=l.textures.length),r&&(l.areaGlyphs=!0),Mo(e,l,go(u,Co(l,i,s)))}function q2(e,t,n,r){e.gradRamps.wouldReshape(t,n)&&ye(e);let o=Ks(e,!0),i=e.batchState;i!==void 0&&(!Io(e,i,o.colorMatrix,o.alpha)||_w(i)<0)&&ye(e),e.drawBatch.wouldOverflow(r)&&ye(e);let s=Eo(e),a=_w(s);return s.ramps=!0,{slot:Mo(e,s,go(a,Co(s,o.colorMatrix,o.alpha))),tint:o.tint,rowV:e.gradRamps.rowV(e.gradRamps.upload(t,n))}}function da(e){let[t,n,r,o]=$n(e.color);return[t,n,r,o*(e.opacity??1)]}var s$=[0,0,0,0];function X2(e,t){let n=$n(t.color);return tp(e,n[0],n[1],n[2],n[3]*(t.opacity??1),s$)}function jw(e,t,n){let r=ih(e,4);e.drawBatch.pushRect(t.x,t.y,t.width,t.height,e.state.transform,X2(e,n),r)||sn(e,t,n,jw)}function J2(e,t,n){let r=ih(e,t.vertices.length>>1),[o,i,s,a]=X2(e,n);e.drawBatch.pushMesh(t,e.state.transform,o,i,s,a,r)||sn(e,t,n,J2)}function $w(e,t,n){let{slot:r,tint:o,rowV:i}=q2(e,n.stops,n.space,4),{uv:s,post:a}=Ww(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,$w)}function Q2(e,t,n){let{slot:r,tint:o,rowV:i}=q2(e,n.stops,n.space,t.vertices.length>>1),{uv:s,post:a}=Ww(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,Q2)}function rc(e,t,n){return n!==void 0&&zw(e,t)?(n.kind==="ramp"?Q2(e,t,n):n.kind==="pattern"?Gw(e,t,n):J2(e,t,n),!0):(an(e),!1)}var a$=[0,0];function Yw(e,t){let n=Ks(e,!1),r=e.batchState;r!==void 0&&(!Io(e,r,n.colorMatrix,n.alpha)||Lr(r,t)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let o=Eo(e),i=Lr(o,t);return i>o.textures.length&&(o.textures.push({kind:"atlas",id:t,fieldScale:a$}),i=o.textures.length),n.slot=Mo(e,o,go(i,Co(o,n.colorMatrix,n.alpha))),n}Z();function ah(e){let t=Z2.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)=>Vw(e,r,o),spaceToDevice:r=>$2(e,r),get maxTextureSize(){return e.imageCache.maxTextureSide},resources:e.paintResources??l$(e.gl),bindRamp:(r,o,i)=>{let s=e.gradRamps.upload(r,i);return e.gradRamps.bind(o),e.gradRamps.rowV(s)}};return Z2.set(e,n),n}var Z2=new WeakMap,eC=new WeakMap;function l$(e){let t=eC.get(e);return t||(t=cl(),eC.set(e,t)),t}function lh(e,t,n,r){let o=n.texture,i=_s(o.id);if(!i)return en()&&!CR(o.id)&&console.warn(`weasel: pattern TextureHandle "${o.id}" not registered`),null;let s=Vi(e,n.units);if(!s)return null;let a=oh(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]=Bw(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),qf(e,t,e.state.alpha),t}function uh(e,t,n,r){let o=Vw(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)),qf(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 tC(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 dh(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,tC(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 fh(e,{vbo:t,location:n}){n!==void 0&&e.disableVertexAttribArray(n),e.deleteBuffer(t)}var ch=new Float32Array(256);function u$(e,t,n,r){for(let s=0;s<n*4;s++)t[s]*=r[s&3];if(!Pu(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 ph(e){return e.kind===void 0||e.kind==="solid"?e:{color:"#ffffff",opacity:e.opacity}}function nC(e,t,n){let r=t.vertices.length>>1;ch.length<r*4&&(ch=new Float32Array(Math.max(r*4,ch.length*2)));let o=tC(n.perAnchor,t,ch),s=u$(e,o,r,da(n.paint))?sh(e,r,Vt,1):sh(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,nC)}function qw(e,t,n,r){let o=t.vertices.length>>1;return(t.anchorA!==void 0||n.length>=o*4)&&zw(e,t)?(nC(e,t,{perAnchor:n,paint:r}),!0):(an(e),!1)}function Xw(e,t){let n=_2(t);n.fill?.paint&&c$(e,n,n.fill.paint),n.stroke?.paint&&y$(e,n)}function c$(e,t,n){let r=n.kind===void 0||n.kind==="solid",o=!!(t.vertexColors&&t.vertexColors.length>0),i=n,s=tc(e,n,o);if(s===null)return;if(s!==void 0&&t.path.kind==="rect"){s.kind==="ramp"?$w(e,t.path,s):s.kind==="pattern"?Hw(e,t.path,s):jw(e,t.path,s);return}let a=Zf(e,t.path);if(r&&o?qw(e,a,t.vertexColors,i):rc(e,a,s))return;let u=Ax(e,a);Jf(e,a.origin,()=>{r&&o?d$(e,t,i,u):u.requiresStencil?m$(e,n,u):hh(e,n,u)})}function d$(e,t,n,r){let o=e.gl,i=e.pathFillVColor;o.useProgram(i.handle),o.bindVertexArray(r.vao),nt(e,i),Vs(e,i,n.color,n.opacity),Rn(e,i);let s=dh(o,i,t.vertexColors,r);r.requiresStencil?(bx(e,r.indexCount),Be(e,r.indexCount,e.gl.UNSIGNED_INT),xx(e)):(wt(e),Be(e,r.indexCount,e.gl.UNSIGNED_INT)),fh(o,s),o.bindVertexArray(null)}function Jw(e,t){let n=t.kind??"solid";if(n==="solid")return f$(e,t);if(n==="texture")return p$(e,t);if(n==="linear-gradient"||n==="radial-gradient"||n==="conic-gradient")return h$(e,t);let r=Gi(n)?.bind;return r?r(ah(e),t):null}function hh(e,t,n){if(!Jw(e,t))return;let o=e.gl;o.bindVertexArray(n.vao),wt(e),Be(e,n.indexCount,e.gl.UNSIGNED_INT),o.bindVertexArray(null)}function f$(e,t){let n=e.pathFill;return e.gl.useProgram(n.handle),nt(e,n),Vs(e,n,t.color,t.opacity),Rn(e,n),n}function p$(e,t){return lh(e,e.patternFill,t,Xf(e))}function h$(e,t){return uh(e,e.gradFill,t,Xf(e))}function m$(e,t,n){let r=e.gl;r.useProgram(e.pathFill.handle),r.bindVertexArray(n.vao),nt(e,e.pathFill),bx(e,n.indexCount),Jw(e,t)&&Be(e,n.indexCount,e.gl.UNSIGNED_INT),xx(e),r.bindVertexArray(null)}function y$(e,t){let{cmd:n,spaces:r}=ec(e.state.transform,t),o=n.stroke,i=o.align??"center",s=r.ribbon?.metric,a=n.path.kind==="polygon"||s!==void 0&&!up(s),l=a&&i!=="center"?b$(e,n,i,r):null;l!==null?oC(e,n,l):a&&i!=="center"?(an(e),Jf(e,n.path.kind==="polygon"?n.path.origin:void 0,()=>P$(e,n,i,r))):g$(e,n,r);let u=at(o.width??1,1),c=F2(n.path,t.stroke,o,u,zs(e),r);for(let d of c)Xw(e,d)}function g$(e,t,n){oC(e,t,th(t.path,t.stroke,zs(e),n))}function b$(e,t,n,r){if(t.stroke.vertexColors&&t.stroke.vertexColors.length>0||e.batchVariants?.cuts===!1)return null;let o=th(t.path,iC(t.stroke),zs(e),r);return W2(o,Zf(e,t.path),n==="inner")}function oC(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=tc(e,o,i);s===null||(i?qw(e,n,r.vertexColors,ph(o)):rc(e,n,s))||Jf(e,n.origin,()=>x$(e,r,n,i))}function x$(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){hh(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=ph(o);Vs(e,u,c.color,c.opacity),Rn(e,u);let d=dh(l,u,t.vertexColors,a);wt(e),Be(e,a.indexCount,e.gl.UNSIGNED_INT),fh(l,d),l.bindVertexArray(null);return}l.useProgram(e.pathFill.handle),l.bindVertexArray(a.vao),nt(e,e.pathFill),Vs(e,e.pathFill,s.color,s.opacity),Rn(e,e.pathFill),wt(e),Be(e,a.indexCount,e.gl.UNSIGNED_INT),l.bindVertexArray(null)}var rC=new WeakMap;function w$(e){let t=rC.get(e);return t===void 0&&(t=e.map(n=>iu(n,2)),rC.set(e,t)),t}function iC(e){return{...e,width:at(e.width??1,1)*2,...e.vertexWidths?{vertexWidths:w$(e.vertexWidths)}:{},align:"center"}}function P$(e,t,n,r){let o=t.stroke,i=o.paint,s=iC(o),a=!!(o.vertexColors&&o.vertexColors.length>0),l=xu(e,t.path),u=th(t.path,s,zs(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),Be(e,l.indexCount,e.gl.UNSIGNED_INT);let p=Ai(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 y=ph(i);Vs(e,f,y.color,y.opacity),Rn(e,f)}else h=Jw(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?dh(d,h,o.vertexColors,c):null;Be(e,c.indexCount,e.gl.UNSIGNED_INT),d.stencilMask(1),d.clear(d.STENCIL_BUFFER_BIT),d.disable(d.STENCIL_TEST),m&&fh(d,m),d.bindVertexArray(null)}Pe();Pe();Z();var Qw=1/4096,T$=2048,mh=new Map;function sC(e,t){let n=mh.get(e);if(n!==void 0)return n;mh.size>=T$&&(mh=new Map);let r=mu(fi(t),{flattenTolerance:Qw});return mh.set(e,r),r}Z();var S$=2048,aC=1/1024,yh=new Map;function lC(e){return Math.round(e/aC)*aC}function Zw(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(","),Po(o)].join("|"),s=yh.get(i);if(s!==void 0)return s.indices.length===0?null:s;yh.size>=S$&&(yh=new Map);let a=Ei(fi(t),{...r,width:n},{flattenTolerance:Qw,metric:o});return yh.set(i,a),a.indices.length===0?null:a}function uC(e,t,n){return eP(e,t,n,r=>sC(r.key,r.d))}function cC(e,t,n,r){if(!Sr(e.stroke))return null;let{trim:o,...i}=e.stroke,s=i.width??1;if(typeof s=="object"){let a=dC(e),[l,u,c,d]=[r[0],r[1],r[3],r[4]];return eP(e,t,n,f=>{if(!(f.scale>0))return null;let p=f.scale,[h,m]=Ro(f.rotate),y=[h*p,m*p],b=[-(h*a+m)*p,(h-m*a)*p],x=vu(l*y[0]+c*y[1],u*y[0]+d*y[1],l*b[0]+c*b[1],u*b[0]+d*b[1]),w=eh(s.px,x.scale);if(!(w>0))return null;let g=i.dash?.map(P=>P/w);return Zw(f.key,f.d,s.px/w,{...i,dash:g},x.metric??void 0)})}return eP(e,t,n,a=>a.scale>0?Zw(a.key,a.d,lC(s/a.scale),{...i,dash:i.dash?.map(l=>l/a.scale)}):null)}var dC=e=>e.synthetic.italic?Math.tan(.2094):0;function eP(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=dC(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:y,scale:b}=h,[x,w]=Ro(h.rotate);for(let g=0;g<p.vertices.length;g+=2){let P=p.vertices[g],S=p.vertices[g+1],v=(P-S*a)*b,A=S*b;l[c++]=m+t+v*x-A*w,l[c++]=y+n+v*w+A*x}for(let g=0;g<p.indices.length;g++)u[d++]=f+p.indices[g];f+=p.vertices.length/2}return{vertices:l,indices:u}}function fC(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]=Ro(p),y=e[t+9]+n;for(let b=0;b<8;b+=2){let x=i[b]-y,w=i[b+1]-c;i[b]=y+x*h-w*m,i[b+1]=c+x*m+w*h}}var fa=new Array(11).fill(0);function gh(e,t,n,r,o,i,s,a){let l=a.xy;fC(e,t,n,r,o,l),pC(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++)fa[b]=e[t+b];fa[0]-=p,fa[2]+=p,fa[1]-=h,fa[3]+=h;let m=(u[2]-u[0])*p/d,y=(u[3]-u[1])*h/f;u[0]-=m,u[2]+=m,u[1]-=y,u[3]+=y,fC(fa,0,n,r,o,l),pC(i,l)}function pC(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 bh(e){let t=Math.hypot(e[0],e[1]),n=Math.hypot(e[3],e[4]);return Math.sqrt(t*n)||1}function hC(e,t,n,r){let o=t.fill?.paint;if(o===void 0||t.quads.length===0||!yd(e.textureCache,t.page))return;let i=Ut(o)?da(o)[3]:1,s=pd(t.page),a=e.drawBatch,l=e.state.transform,u=e.deviceWidth&&e.widthCss?e.deviceWidth/e.widthCss:1,c=bh(l)*u,d=s,{slot:f,tint:p}=Yw(e,d),h=()=>{({slot:f,tint:p}=Yw(e,d))};for(let m of t.quads){let y=k$(e,m,c),b=y?.quad??m,x=y?.atlasId??s;x!==d&&(d=x,h()),a.wouldOverflow(4)&&(ye(e),h());let w,g=b.rotate?q.multiply(l,q.fromAffine(ao(b.penX+n,b.baselineY+r,b.rotate*Un))):l;for(;!a.pushQuad(b.x0+n,b.y0+r,b.x1-b.x0,b.y1-b.y0,g,b.u0,b.v0,b.u1,b.v1,i*p[3],f,p[0],p[1],p[2]);)w=xo(e),h();w!==void 0&&(wo(e,w),h())}}function k$(e,t,n){let r=t.colorGlyph;if(!r||r.width===0)return null;let o=(t.x1-t.x0)/r.width,i=Td(r,o*n);if(!i||!gd(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:hd(s.page)}}var mC={vertices:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])};function yC(e,t,n){let r=e.paintScratch,o=Gi(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,y=f/i,b=p/i,x=new Float32Array([y,0,0,0,b,0,h,m,1]),w=new Float32Array([2/y,0,0,0,2/b,0,-1-2*h/y,-1-2*m/b,1]),g=ah(e),P={...g,alpha:e.state.alpha,maxTextureSize:g.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(mC).vao),Be(e,mC.indices.length,S.UNSIGNED_INT),S.bindVertexArray(null)),S.enable(S.BLEND),sa(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 gC(e,t,n){let r=e.gl;return r.useProgram(t.handle),nt(e,t,js),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 xh=48,bC={outlineMinSize:void 0};function wC(e,t){let n=e.textOutlineMinScreenSize??xh,r=Number.isFinite(n)?n/bh(e.state.transform):void 0,{laid:o,dx:i,dy:s}=$p(t);bC.outlineMinSize=r;let{groups:a,decorations:l}=nw(o,t.runs,bC,"read");if(!(a.length===0&&l.length===0)){for(let u of a)u.source==="outline"?v$(e,u,i,s):u.source==="color"?hC(e,u,i,s):N$(e,u,i,s);A$(e,l,i,s)}}function v$(e,t,n,r){let o=t.fill?.paint;if(o!==void 0){let a=uC(t,n,r);a&&rP(e,o,a)}let i=t.stroke?.paint;if(!i)return;let s=cC(t,n,r,e.state.transform);s&&rP(e,i,s)}function rP(e,t,n){let r=tc(e,t,!1);r!==null&&(rc(e,n,r)||hh(e,t,e.meshCache.uploadTransient(n)))}function A$(e,t,n,r){for(let o of t){let i=o.fill.paint;if(i===void 0)continue;if(TC(i)!==null){rP(e,i,R$(o.x0+n,o.y0+r,o.x1+n,o.y1+r));continue}let[s,a,l,u]=Ut(i)?da(i):[0,0,0,1],c;for(;;){let d=ih(e,4),f=Rx(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=xo(e)}c!==void 0&&wo(e,c)}}function R$(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 PC(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 cg(r,i,s)?Cd/o:0}function N$(e,t,n,r){if(t.source==="canvas"){if(!md(e.textureCache,t.page))return}else if(!rg(t.family,t.weight,t.style,e.textureCache))return;if(t.quadData.length===0)return;let o=t.source==="canvas"?fd(t.page):ls(t.family,t.weight,t.style),i=t.source==="canvas"?ug:lg,s=fg(t.source==="canvas"?"canvas":"atlas",t.family,t.weight,t.style);if(!s)return;let a=t.synthetic.bold?Tl:0,l=t.synthetic.italic?Math.tan(.2094):0,u=t.fill?.paint;if(u===void 0)return;let c=TC(u);if(c!==null){C$(e,t,n,r,c,o,i,a,l,s);return}let d=Ut(u)?$n(u.color):I$,f=Ut(u)?u.opacity??1:1,p=e.drawBatch,h=e.state.transform,m=PC(e,t.quadData,h,s),y=m>0,b=nc(e,o,s,y),x=tp(e,d[0],d[1],d[2],d[3]*f,E$),w=t.quadData;for(let g=0;g<w.length;g+=Er){p.wouldOverflow(4)&&(ye(e),b=nc(e,o,s,y));let P;for(;!p.pushGlyph(w,g,n,r,l,h,x,b,i,a,m);)P=xo(e),b=nc(e,o,s,y);P!==void 0&&(wo(e,P),b=nc(e,o,s,y))}}var I$=[0,0,0,1],E$=[0,0,0,0];function TC(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 nP=1,M$=[1,1,1,1];function C$(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=PC(e,t.quadData,f,u),h;if(o==="pattern")h=lh(e,c,d,js);else if(o==="gradient")h=uh(e,c,d,js);else{let w=yC(e,d,O$(t,n,r,l,f,p));h=w&&gC(e,c,w)}if(!h)return;let m=e.gl;e.textureCache.bind(i,nP),m.uniform1i(c.uniform("u_atlas"),nP),m.uniform1f(c.uniform("u_synthBold"),a),m.uniform2f(c.uniform("u_fieldScale"),u[0],u[1]),wt(e);let y=e.drawBatch,b=y.clip;y.clip=null;let x=t.quadData;for(let w=0;w<x.length;w+=Er)y.wouldOverflow(4)&&xC(e),y.pushGlyph(x,w,n,r,l,f,M$,nP,s,0,p);xC(e),y.clip=b,m.activeTexture(m.TEXTURE0),m.bindVertexArray(null)}function xC(e){let t=e.drawBatch;t.length!==0&&(Be(e,t.uploadAndBind(),e.gl.UNSIGNED_INT),t.reset())}function O$(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+=Er){gh(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 F$=2;function L$(e){let t=e.state.transform,n=e.deviceWidth&&e.widthCss?e.deviceWidth/e.widthCss:1,r=(F$*n)**2;return[r*(t[0]*t[0]+t[1]*t[1]),r*(t[3]*t[3]+t[4]*t[4])]}var _$=(e,t,n,r,o)=>t*t>=e[0]*r*r||n*n>=e[1]*o*o,D$=(e,t)=>!t||t.x<=0&&t.y<=0&&t.x+t.w>=e.width&&t.y+t.h>=e.height;function oP(e,t){e.imageCache.upload(t.image,t.image);let n=D$(t.image,t.source);n&&e.imageCache.lacksMipmaps(t.image)&&_$(L$(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}=Kw(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,oP)}function SC(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=()=>Kw(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],y=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+y)/c,(m+b)/d,n[p+8]*a[3],s,a[0],a[1],a[2]);)x=xo(e),{slot:s,tint:a}=i();x!==void 0&&(wo(e,x),{slot:s,tint:a}=i())}}function zi(e,t){switch(t.kind){case"group":return B$(e,t);case"path":return Xw(e,t);case"text":return wC(e,t);case"image":return oP(e,t);case"sprites":return SC(e,t);case"shader":return an(e),DN(e,t)}}function kC(e){return e.isolate===!0||Yn(e.composite)||e.effects!==void 0&&e.effects.length>0}function B$(e,t){if(!(t.retain!==void 0&&s2(e,t,kC(t),zi))){if(kC(t)&&e.effectTargets&&e.deviceWidth&&e.deviceHeight){if(t.clip){e.state.push({transform:t.transform});try{Su(e,t.clip)}finally{e.state.pop()}}o2(e,t,e.effectTargets,e.deviceWidth,e.deviceHeight,zi),t.clip&&Mx(e);return}if(e.state.push({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix}),t.clip)try{Su(e,t.clip)}catch(n){throw e.state.pop(),n}for(let n of t.children)zi(e,n);t.clip&&Mx(e),e.state.pop()}}var qn=10,oe=qn,H$=256,G$=384,iP=32;function Oo(e,t){let n=e;for(;n<t;)n*=2;return n}var wh=class{verts=new Float32Array(H$*oe);idx=new Uint32Array(G$);nVerts=0;nIdx=0;pureRects=!0;clip=null;polyIn=new Float32Array(iP*oe);polyOut=new Float32Array(iP*oe);polyTmp=new Float32Array(iP*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(Oo(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(Oo(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(vr(r,o[i],o[i+1])&&vr(r,o[i+oe],o[i+oe+1])&&vr(r,o[i+2*oe],o[i+2*oe+1])&&vr(r,o[i+3*oe],o[i+3*oe+1])||(this.nVerts=t,this.nIdx=n,Qf(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(vx(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=vr(r,o[u],o[u+1]);if(i)return!0;let s=this.nIdx,a=Qf(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(Oo(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(vr(t,i[n*oe],i[n*oe+1])&&vr(t,i[r*oe],i[r*oe+1])&&vr(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),!Qf(t,s,0,3,oe)&&this.appendFan(vx(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 U$=32768;var sP={xy:new Array(8).fill(0),uv:[0,0,0,0]},W$=[0,0,0,0],oc=.5,ic=.5,V$={ux:0,uy:0,u0:oc,vx:0,vy:0,v0:ic},z$=64,_r=[{vertices:16,indices:24},{vertices:1024,indices:3072}],K$=_r[_r.length-1].vertices,vC=4;function j$(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 sc=class extends wh{gl;aPos;aColor;aUv;aPost;aSlot;rings=_r.map(()=>new Array(z$).fill(void 0));nextInRing=_r.map(()=>0);largeRing=new Array(vC).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>U$}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*qn,p=i[0],h=i[1],m=i[3],y=i[4],b=i[6],x=i[7],w=t+r,g=n+o,P=p*t+m*n+b,S=h*t+y*n+x,v=p*w+m*n+b,A=h*w+y*n+x,N=p*w+m*g+b,M=h*w+y*g+x,C=p*t+m*g+b,F=h*t+y*g+x;return f=this.writeVertex(f,P,S,l,u,c,d,oc,ic,1,a),f=this.writeVertex(f,v,A,l,u,c,d,oc,ic,1,a),f=this.writeVertex(f,N,M,l,u,c,d,oc,ic,1,a),this.writeVertex(f,C,F,l,u,c,d,oc,ic,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*qn,y=i[0],b=i[1],x=i[3],w=i[4],g=i[6],P=i[7],S=t+r,v=n+o,A=y*t+x*n+g,N=b*t+w*n+P,M=y*S+x*n+g,C=b*S+w*n+P,F=y*S+x*v+g,D=b*S+w*v+P,B=y*t+x*v+g,K=b*t+w*v+P,W=gi(d,Os);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,D,f,p,h,1,l,u,c,W),this.writeVertex(m,B,K,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*qn;gh(t,n,r,o,i,s,d,sP);let p=sP.xy,h=sP.uv,m=a[0],y=a[1],b=a[2],x=a[3],w=gi(l,u),g=d>0?ZA:W$;return f=this.writeVertex(f,p[0],p[1],m,y,b,x,h[0],h[1],c+g[0],w),f=this.writeVertex(f,p[2],p[3],m,y,b,x,h[2],h[1],c+g[1],w),f=this.writeVertex(f,p[4],p[5],m,y,b,x,h[2],h[3],c+g[2],w),this.writeVertex(f,p[6],p[7],m,y,b,x,h[0],h[3],c+g[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*qn,m=i[0],y=i[1],b=i[3],x=i[4],w=i[6],g=i[7],P=t+r,S=n+o,v=gi(l,u),A=(N,M)=>{let C=h;return h=this.writeVertex(C,m*N+b*M+w,y*N+x*M+g,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,y=this.nVerts*qn,b=n[0],x=n[1],w=n[3],g=n[4],P=n[6],S=n[7],v=gi(i,s),A=t.origin?.x??0,N=t.origin?.y??0;for(let D=0;D<h;D++){let B=f[D*2]+A,K=f[D*2+1]+N;if(m[y++]=b*B+w*K+P,m[y++]=x*B+g*K+S,d===void 0)m[y++]=a,m[y++]=l,m[y++]=u,m[y++]=c;else{let W=D*4;m[y++]=a*d[W],m[y++]=l*d[W+1],m[y++]=u*d[W+2],m[y++]=c*d[W+3]}m[y++]=r.ux*B+r.uy*K+r.u0,m[y++]=r.vx*B+r.vy*K+r.v0,m[y++]=o,m[y++]=v}let M=this.nVerts,C=this.idx,F=this.nIdx;for(let D=0;D<p.length;D++)C[F++]=M+p[D];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,V$,1,a,yi,r,o,i,s,l)}uploadAndBind(){let t=this.gl,n=_r.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*qn),!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,j$(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(_r[t].vertices,_r[t].indices);return n[r]=i,i}nextLargeSlot(){let t=this.gl,n=this.nextLarge;this.nextLarge=(n+1)%vC;let r=this.largeRing[n];return r?(this.nVerts>r.vertexCapacity&&(r.vertexCapacity=Oo(r.vertexCapacity,this.nVerts),t.bindBuffer(t.ARRAY_BUFFER,r.vbo),t.bufferData(t.ARRAY_BUFFER,r.vertexCapacity*qn*4,t.DYNAMIC_DRAW)),this.nIdx>r.indexCapacity&&(r.indexCapacity=Oo(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(Oo(K$,this.nVerts),Oo(_r[_r.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=qn*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 AC=`#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
|
+
`,RC=["a_position","a_uv"],NC=["u_bounds","u_view","u_proj","u_screenToLocal","u_worldOrigin"],IC=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),EC=new Uint16Array([0,1,2,0,2,3]);var Ph=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 OC(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 FC(e,t){return e.children===t.children&&e.alpha===t.alpha&&pa(e.transform,t.transform)&&pa(e.colorMatrix,t.colorMatrix)&&aP(e.viewMatrix,t.viewMatrix)&&aP(e.screenMatrix,t.screenMatrix)&&q$(e.clips,t.clips)&&e.isolate===t.isolate&&_C(e.effects,t.effects)&&DC(e.window,t.window)}function LC(e,t){if(e.children!==t.children||e.alpha!==t.alpha||e.isolate!==t.isolate||!pa(e.colorMatrix,t.colorMatrix)||!aP(e.screenMatrix,t.screenMatrix)||!_C(e.effects,t.effects)||e.clips.length!==t.clips.length||!DC(e.window,t.window))return null;let n=MC(e.transform,t.transform);if(!n)return null;let r=(o,i)=>{if(o===void 0||i===void 0)return o===i;let s=MC(o,i);return s!==null&&CC(s[0],n[0])&&CC(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 MC(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 CC(e,t){return Math.abs(e-t)<=1e-6*Math.max(1,Math.abs(e),Math.abs(t))}function _C(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||!$$(r.uniforms,o.uniforms))return!1}return!0}function $$(e,t){if(e===t)return!0;let n=Object.keys(e??{});return n.length!==Object.keys(t??{}).length?!1:n.every(r=>Y$(e[r],t?.[r]))}function Y$(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:pa(e,t)}function aP(e,t){return e===void 0?t===void 0:t!==void 0&&pa(e,t)}function DC(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 q$(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].path!==t[n].path||!pa(e[n].transform,t[n].transform))return!1;return!0}function pa(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 BC(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 HC(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 UC(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 WC(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 VC(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=X$(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 X$(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 zC=1e-4,KC=1/8,J$=1024,Th=class{gl;budget;samples;surfaces=new Map;scratches=new Map;width=0;height=0;frame=0;stamp=[];tile=J$;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)||!BC(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(FC(l.key,o))return l.frame=this.frame,l.seen=u,this.composited++,{kind:"kept",pixels:lP(l,0,0)};let d=LC(l.key,o),f=s!==void 0&&l.reach!==null,p=Math.round(n*KC),h=Math.round(r*KC),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 y=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),g=Math.round(x),P=Math.abs(b-w)<=zC&&Math.abs(x-g)<=zC;return P&&Q$(l.reach,w,g,n,r)?(this.composited++,{kind:"kept",pixels:lP(l,w,g)}):(!P||y)&&!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,Hi(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,y=h.rect;return{fbo:m?.fbo??null,rect:y,tiles:m?Z$(y,this.tile):[],resolve:b=>{!m||!h.gl||VC(this.gl,m,h.gl,b.width,b.height,b.x-y.x,y.y+y.height-b.y-b.height)},commit:b=>(h.key=OC(b),h.stamp=this.stamp,h.reach=s?{box:{...s.box},window:{...s.window}}:null,h.seen=[b.transform[6],b.transform[7]],lP(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()+uP(n)-(r?uP(r.rect):0)<=this.budget}keptBytes(){let t=0;for(let n of this.surfaces.values())t+=uP(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=UC(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=HC(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&&WC(this.gl,n),this.scratches.delete(t)}};function lP(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 Q$(e,t,n,r,o){let i=Hi(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 Z$(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 uP(e){return e.width*e.height*4}function cP(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 dP=new Set(["lowp","mediump","highp","precise","invariant","centroid","flat","smooth","noperspective"]),fP=/^[A-Za-z_]\w*$/,jC=16;function pP(e){return[...qC(e).names]}function hP(e){return qC(e).arrays}function qC(e){let{code:t,defines:n}=e8(e),r=$C(t),o=new Map,i=new Map,s=new Set,a=new Map,l=(y,b)=>{if(b>jC)return null;let x=null;for(let w of n.get(y)??[]){let g=YC($C(w),P=>l(P,b+1));g!==null&&(x===null||g>x)&&(x=g)}return x??o.get(y)??null},u=(y,b)=>YC(r.slice(y,b),x=>l(x,0)),c=y=>{let b=0;for(let x=y;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=y=>{if(r[y]!=="[")return[void 0,y];let b=c(y);return[u(y+1,b),b+1]},f=(y,b)=>{let x=[];for(;y<r.length&&r[y]!==";"&&r[y]!=="}";){let w=r[y],[g,P]=d(y+1);for(y=P,fP.test(w)&&x.push({name:w,size:g===void 0?b:g});y<r.length&&r[y]!==","&&r[y]!==";"&&r[y]!=="}";)y=r[y]==="("||r[y]==="["||r[y]==="{"?c(y)+1:y+1;r[y]===","&&y++}return[x,y]},p=y=>{let b=y+1,x=r[b]!=="{"?r[b++]:void 0,w=[];if(r[b]!=="{")return[w,b];let g=c(b);for(b++;b<g;){for(;dP.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,g+1]},h=(y,b,x,w)=>{if(w>jC)return;if(x!==null){if(typeof b=="string"&&!i.has(b)){let P=a.get(y);(!P||x>P.size)&&a.set(y,{type:b,size:x})}for(let P=0;P<x;P++)h(`${y}[${P}]`,b,null,w+1);return}let g=typeof b=="string"?i.get(b):b;if(!g){s.add(y);return}for(let P of g)h(`${y}.${P.name}`,P.type,P.size,w+1)},m=0;for(let y=0;y<r.length;y++){let b=r[y];if(b==="{")m++;else if(b==="}")m--;else if(b==="struct")y=p(y)[1]-1;else if(m===0&&b==="const"){let x=y+1;for(;dP.has(r[x]);)x++;if((r[x]==="int"||r[x]==="uint")&&fP.test(r[x+1]??"")&&r[x+2]==="="){let w=x+3;for(;w<r.length&&r[w]!==";";)w++;let g=u(x+3,w),P=o.get(r[x+1]);g!==null&&(P===void 0||g>P)&&o.set(r[x+1],g)}}else if(m===0&&b==="uniform"){let x=y+1;for(;dP.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++;y=x;continue}else w=r[x++];let[g,P]=d(x),[S,v]=f(P,g);for(let A of S)A.size!==null&&h(A.name,w,A.size??null,0);y=v}}return{names:s,arrays:a}}function e8(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)&<(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=
|
|
426
|
+
`),defines:r}}function $C(e){return e.match(/[A-Za-z_]\w*|\d[\w.]*|\S/g)??[]}function t8(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 YC(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:t8(a)??(fP.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 n8(e,t){return[...NC,...pP(e),...pP(t)]}function mP(e,t){let n=t.vert===""?AC:t.vert,r=new to(e,n,t.frag);return r.lookupUniforms(n8(n,t.frag)),r.lookupUniformArrays(new Map([...hP(n),...hP(t.frag)])),r.lookupAttributes(RC),r}var JC={composited:0,redrawn:0,declined:0,bytes:0};function Sh(){return typeof performance<"u"?performance.now():Date.now()}var r8={pattern:[SR,RR],gradient:[kR,NR],texture:[vR,IR]},ac=class{gl;stats={drawCalls:0,ms:0,spans:[],retained:JC};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 Bf;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=cl();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 Ph(this.gl),this.retained=new Th(this.gl,t.retainBudget??402653184),this.paintScratch=new Pf(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??ri,this.textOutlineMinScreenSize=t.textOutlineMinScreenSize??xh,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,bR),this.pathFillVColor=new An(this.gl,xR),this.gradFill=new An(this.gl,wR),this.patternFill=new An(this.gl,PR),this.batchVariants=new xf(this.gl),this.batchFill=Db(this.gl),this.meshCache=new Zl(this.gl),this.textureCache=new tu(this.gl),this.imageCache=new Ds(this.gl,this.imageMinification),this.gradRamps=new au(this.gl),this.uploadQuadGeometry(),this.drawBatch=new sc(this.gl,this.batchFill),this.whiteTexture=cP(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,IC,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.quadIbo),t.bufferData(t.ELEMENT_ARRAY_BUFFER,EC,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,mP(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,mP(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]=r8[t],i=new to(this.gl,TR,r);return i.lookupUniforms(o),i.lookupAttributes(ER),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=cl();for(let t of this.lazyPrograms())t.abandon();this.batchFill=Db(this.gl),this.glyphPaintPrograms.clear(),this.meshCache=new Zl(this.gl),this.textureCache=new tu(this.gl),this.imageCache.abandon(),this.imageCache=new Ds(this.gl,this.imageMinification),this.gradRamps=new au(this.gl),this.uploadQuadGeometry(),this.drawBatch=new sc(this.gl,this.batchFill),this.whiteTexture=cP(this.gl);for(let t of this.programRegistry.keys()){let n=Nn(t);if(n)try{this.programRegistry.set(t,mP(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=Sh(),i={drawCalls:0},s=[];this.stats={drawCalls:0,ms:0,spans:s,retained:JC};let a=this.gl;this.meshCache.drainPendingDeletes(),this.imageCache.beginFrame(),this.textureCache.sweep(xi),this.refreshPrograms(),this.retained.beginFrame([ti(),xi.getVersion(),Zu.getVersion(),this.programEpoch,this.flattenTolerance,this.widthCss,this.heightCss,this.dpr]),xd(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:cN(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??[],y=0;for(let x=0;x<m.length;x++){let w=m[x];for(;y<w.start;y++)zi(h,t[y]);let g=i.drawCalls,P=Sh();for(;y<w.end;y++)zi(h,t[y]);x===m.length-1&&y>=t.length&&ye(h),s.push({id:w.id,drawCalls:i.drawCalls-g,ms:Sh()-P})}for(;y<t.length;y++)zi(h,t[y]);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=Sh()-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 Ds(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 o8={...Ee};function yP(e,t,n,r,o,i,s,a,l,u=1){let c=xp(o8,r,a,u);return{kind:"text",x:e,y:t,runs:Fu(n,c,u),align:c.align,direction:c.direction,justify:c.align==="justify",maxWidth:o,style:r??{},height:i,verticalAlign:s,width:l}}function gP(e,t=1){let{runs:n,opts:r}=zp(e,t);return{kind:"text",x:e.x,y:e.y,runs:i8(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 i8(e,t){return e.every(n=>QC(n.fill?.paint)&&QC(n.stroke?.paint))?e:e.map(n=>{let r=n.fill&&Kt(n.fill,t),o=n.stroke?.paint&&Ui(n.stroke.paint,t);return{...n,fill:r,stroke:n.stroke&&{...n.stroke,paint:o||void 0}}})}function QC(e){return e==null||Ut(e)}function ZC(e){return typeof e=="number"?{x:e,y:e}:e}function bP(e,t){let n=ZC(t.pan),r=ZC(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 kh(e,t){let n=bP(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 xP(e,t){return{x:t.x*e.scale.x+e.offset.x,y:t.y*e.scale.y+e.offset.y}}function s8(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 tO(e,t){return{...t,...s8(t,n=>xP(e,n))}}function wP(e,t){if(e===t)return null;let n=e??eO,r=t??eO,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 eO={scale:{x:1,y:1},offset:{x:0,y:0}};function PP(e){return[e.scale.x,0,0,e.scale.y,e.offset.x,e.offset.y]}var a8=["weasel.debug","weaseldraw.debug"],TP=null;function l8(){let e={all:!1,set:new Set};if(typeof localStorage>"u")return e;try{for(let t of a8){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 u8(){return TP===null&&(TP=l8()),TP}function vh(e){let t=u8();return t.all?!0:e===void 0?t.set.size>0:t.set.has(e)}function Ah(e,...t){vh(e)&&console.debug(`[${e}]`,...t)}function Mt(e,...t){vh(e)&&console.warn(`[${e}]`,...t)}Z();function Ct(e){return e.closure!=="identity"}function jt(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 ha(e,t,n){return rO(e,t,jt(e,t,n))}function rO(e,t,n){return e.childFrame===void 0||!(e.definesFrame?.(t)??!0)?n:e.childFrame(t,n)}function ma(e,t,n,r,o){let i=Xn(e,n);return i===null?t:o(ha(e,i,r),t)}function Xn(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 nO=new WeakMap;function oO(e){let t=nO.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 nO.set(e,r),r}function iO(e,t,n){return{...e,x:e.x+t,y:e.y+n}}function SP(e,t){return t===0&&e.rotation===void 0?e:{...e,rotation:t}}function sO(e,t,n){let[r,o,i,s]=ht(vl(-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=SP({...e},t);return a?delete l.transform:l.transform=[r,o,i,s],l}function aO(e,t,n){return{...e,x:t-e.width/2,y:n-e.height/2}}var lO=[1,0,0,1,0,0];function uO(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 c8(e,t){let n=e.rotation??0,r=zn(e)&&Re(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,Re(t)??lO);return sO(aO(t,s,a),(t.rotation??0)+n,l)}let[o,i]=uO(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 SP({...t,x:o-t.width/2,y:i-t.height/2},(t.rotation??0)+n)}function d8(e,t){let n=e.rotation??0,r=zn(e)&&mi(e);if(r){let[s,a]=wn(r,t.x+t.width/2,t.y+t.height/2),l=ht(r,Re(t)??lO);return sO(aO(t,s-e.x,a-e.y),(t.rotation??0)-n,l)}let[o,i]=uO(e.x+e.width/2,e.y+e.height/2,-n,t.x+t.width/2,t.y+t.height/2);return SP({...t,x:o-e.x-t.width/2,y:i-e.y-t.height/2},(t.rotation??0)-n)}function f8(e,t){return iO(e,-t.x,-t.y)}function p8(e,t){let n=Re(e);if(!n)return f8(e,t);let[r,o,i,s]=n;return iO(e,-(r*t.x+i*t.y),-(o*t.x+s*t.y))}var Rh={compose:c8,decompose:d8,closure:"rigid",scroll:p8};var ya=!1;function cO(){ya=!0}function dO(e){let t=ya;ya=!1;try{return{value:e(),fonts:ya}}finally{ya=t||ya}}function kP(){return fl()}var fO=4;function vP(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Nh(e,t=fO){if(t<=0)return e;if(Array.isArray(e))return e.map(n=>Nh(n,t-1));if(vP(e))return e.slice();if(tn(e)){let n={...e};for(let r in n){let o=n[r];typeof o=="object"&&o!==null&&(n[r]=Nh(o,t-1))}return n}return e}function Fo(e,t,n=fO){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(us(r)){if(!us(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(!Fo(l,u,n-1))return!1}for(let a in i)if(--s<0)return!1;return!0}if(Array.isArray(e)||vP(e)){let o=e;if(!(Array.isArray(t)||vP(t)))return!1;let i=t;if(o.length!==i.length)return!1;for(let s=0;s<o.length;s++)if(!Fo(o[s],i[s],n-1))return!1;return!0}return!1}function lc(){return{nodes:[],poses:[],data:[],layers:[],paths:[],children:[],faces:null}}var AP=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]=lc();return pO(n,t)}};function pO(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:Nh(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 AP(n,e,r)))}function Ih(e,t,n){let r=pO(e,t),o=kP(),{value:i,fonts:s}=dO(()=>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!==kP())return!1;for(let r=0;r<t.length;r++)if(!hO(e,r,n(t[r])))return!1;return e.faces!==null&&cO(),!0}function hO(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||!Fo(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)=>hO(o,a,s))}Z();Z();Pe();function mO(e,t,n){return{fill:Ie(e.fill,Ie(t?.fill,n?.fill)),stroke:Ne(e.stroke,Ne(t?.stroke,n?.stroke))}}var yO=new WeakMap;function gO(e){if(e.length===0)return null;let t=e.length===1?e[0].path:h8(e.map(r=>r.path)),n=t===e[0].path?{...t}:t;return yO.set(n,e),n}function Mh(e){return e==null?void 0:yO.get(e)}function h8(e){return Ng(e.map(t=>t.kind==="rect"?cb(pi(t)):t))}function xO(e,t,n,r,o){if(e===void 0||!Ct(e))return null;let i={getPose:a=>r(a),getParent:a=>n(a)?.parent??null,definesFrame:a=>o(a)},s=Xn(i,t.parent??null);return(a,l)=>{let u=Xn(i,n(a)?.parent??null);if(u===s)return l;let c=u===null?l:e.compose(jt(i,u,e.compose),l);return s===null?c:e.decompose(jt(i,s,e.compose),c)}}function ga(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 Ch(e,t,n){return!ga(t)||!ga(n)||t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height?e:uc(e,mr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height))}function wO(e,t,n){if(!ga(t)||!ga(n))return e;let r=mi(t),o=Re(n),i=mr(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)),uc(e,i)}function Oh(e,t,n){if(!ga(t)||!ga(n))return e;let r=Re(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=mr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height);return uc(e,r===null?i:ht(r,i))}function uc(e,t){let n=t.join(","),r=bO.get(e);if(r?.key===n)return r.path;let o=Mh(e),i=o===void 0?Nt(e,t):gO(o.map(s=>({...s,path:Nt(s.path,t)})));return bO.set(e,{key:n,path:i}),i}var bO=new WeakMap;var Fh=Object.freeze([]);var cc=e=>Array.isArray(e?.dependsOn)?e.dependsOn:Fh;function Lh(e,t){let n=e.dependsOn;return n===void 0?Fh:n==="children"?t(e.id):n}function PO(){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?Fh:[...o]},transitiveDependentsOf(r){let o=e.get(r);if(o===void 0)return Fh;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 TO(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 SO(){return new WeakMap}var ba=new WeakMap,Dr=0;function rt(e,t,n,r,o){if(typeof t!="string")return m8(e,t,n,r,o);let i=ba.get(e);i===void 0?(i={generation:Dr,slots:new Map,drops:0},ba.set(e,i)):i.generation!==Dr&&(i.generation=Dr,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 m8(e,t,n,r,o){let i=t,s=e.data,a=ba.get(e)?.drops??0,l=i.get(e);if(l!==void 0&&l.generation===Dr&&l.pose===n&&l.data===s&&l.also===o&&(n===void 0||l.drops===a))return l.value;let u=r(),c=ba.get(e)?.drops??0;return l!==void 0?(l.pose=n,l.data=s,l.also=o,l.value=u,l.generation=Dr,l.drops=c):i.set(e,{pose:n,data:s,also:o,value:u,generation:Dr,drops:c}),u}function dc(){Dr++}function kO(){return Dr}function un(e){let t=ba.get(e);if(t===void 0){ba.set(e,{generation:Dr,slots:new Map,drops:1});return}t.drops++;for(let[n,r]of t.slots)r.pose!==void 0&&t.slots.delete(n)}var y8="kit:derivedPath",RP=new Set,NP=0;function Br(e,t,n,r=y8){let o=e.derivePath;if(o===void 0)return null;let i=Lh(e,n);if(i.length===0)return null;if(RP.has(e.id))return NP++,null;RP.add(e.id);let s=NP;try{let a=!1,l=rt(e,r,e.pose,()=>(a=!0,vO(e,o,i.map(t),{...lc(),path:null})));return!a&&!Eh(l,i,t)&&vO(e,o,i.map(t),l),NP!==s&&un(e),l.path}finally{RP.delete(e.id)}}function vO(e,t,n,r){return r.path=Ih(r,n,o=>t(e,o)),r}Pe();function fc(e){let t=e.data;return t?.fill===It||t?.stroke===It}var AO=new WeakMap;function xa(e,t){let n=e.data,r=n?.fill===It,o=n?.stroke===It,i=null,s=null;for(let u of t){if(!r&&!o)break;let c=u.data;r&&c?.fill!==It&&(i=Ie(c?.fill),r=!1),o&&c?.stroke!==It&&(s=Ne(c?.stroke),o=!1)}let a=AO.get(e);if(a!==void 0&&a.fill===i&&a.stroke===s)return a;let l={fill:i,stroke:s};return AO.set(e,l),l}function wa(e,t){if(fc(t))return xa(t,RO(n=>e.get(n),t))}function*RO(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 pc=()=>{throw new Error("documentOf: the document reading holds no overrides; write them to the scene")},g8=Object.freeze({set:pc,get:()=>{},read:e=>{},has:()=>!1,ids:()=>[],clear:pc,clearAll:pc,commit:pc,subscribe:()=>()=>{},getGeneration:()=>0,hold:()=>pc()});function _h(e){return e.overrides===g8}var IO=Symbol("weasel.shownData"),IP=new WeakMap;function Tt(e,t){if(IO in t)return t;let n=e.read(t.id)?.data;if(n===void 0)return t;let r=IP.get(t);if(r!==void 0&&r.data===n&&r.stored===t.data)return r.shown;let o=b8(t,n(t.data));return IP.set(t,{stored:t.data,data:n,shown:o}),o}function b8(e,t){return{...e,data:t,[IO]:!0}}function EO(e){return IP.get(e)?.shown}function Pa(e){return{get:t=>{let n=e.get(t);return n===void 0?void 0:Tt(e.overrides,n)}}}var NO=new WeakMap;function Dh(e,t){let n=e.getGeneration(),r=NO.get(e);return(r===void 0||r.at!==n)&&(r={at:n,any:e.ids().some(o=>e.read(o)?.data!==void 0)},NO.set(e,r)),r.any?t.map(o=>Tt(e,o)):t}var x8={effective:"kit:derivedPose",document:"kit:derivedPose:document"},w8={effective:void 0,document:"kit:derivedPath:document"},EP=new Set,MP=0;function CO(e){return _h(e)?"document":"effective"}function OO(e,t,n){let r=FO(e,t,n),o=r.derivePose;if(o===void 0)return null;let i=Lh(r,e.childrenOf);if(i.length===0)return null;if(EP.has(r.id))return MP++,null;EP.add(r.id);let s=MP;try{let a=FP(e,r,n),l=!1,u=rt(r,x8[n],r.pose,()=>(l=!0,MO(r,o,i.map(a),{...lc(),value:null})));return!l&&!Eh(u,i,a)&&MO(r,o,i.map(a),u),MP!==s&&un(r),u.value}finally{EP.delete(r.id)}}function MO(e,t,n,r){return r.value=Ih(r,n,o=>t(e,o)),r}function OP(e,t,n){let r=CO(e);return n===void 0?LP(e,t,r):FP(e,n,r)(t)}function FP(e,t,n){let r=i=>LP(e,i,n);if(t.dependsOn==="children")return r;let o=xO(e.composition,t,i=>e.get(i),i=>_P(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 Bh(s,a)}}var Bh=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:wO(t,this.dep.pose,this.pose)}get inherited(){return this.dep.inherited}};function LP(e,t,n){let r=e.get(t);if(r!==void 0)return new CP(e,r,n)}var CP=class{constructor(t,n,r){this.source=t;this.reading=r;let o=FO(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??OO(t,o,r)??o.pose}source;reading;node;pose;shown;posed;get path(){if(this.shown!==void 0)return Oh(this.shown,this.pose,this.pose);let{source:t,reading:n}=this;return Br(this.posed,FP(t,this.posed,n),r=>t.childrenOf(r),w8[n])}get inherited(){let{source:t,reading:n}=this;return wa(n==="effective"?Pa(t):t,this.posed)}get children(){let{source:t,reading:n}=this,r=t.composition,o=r&&Ct(r)&<(this.posed)?r.compose:null;return t.childrenOf(this.posed.id).map(i=>{let s=LP(t,i,n);return s===void 0||o===null?s:new Bh(s,o(this.pose,s.pose))})}};function FO(e,t,n){return n==="effective"?Tt(e.overrides,t):t}function _P(e,t,n){if(n==="effective"){let r=e.overrides.read(t.id)?.pose;if(r!==void 0)return r}return OO(e,t,n)??t.pose}function Hr(e,t){return _P(e,t,"document")}function Jn(e,t){return _P(e,t,CO(e))}function lt(e){return!P8(e)}function P8(e){return e.dependsOn==="children"&&e.derivePose!==void 0}Z();Z();function DP(e){let t=Re(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 LO(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=DP(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 Gr(e,t){return e.forNode?.(t)??e}var Ot={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})},T8={getBounds:Ot.getBounds,remapBounds:Ot.remapBounds,translate:Ot.translate,lerp:Ot.lerp,axes:Ot.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 Ki(e,t){return DP(BP(e,t))}function BP(e,t){let n=t.getBounds(e),r=t.getRotation?.(e)??n.rotation??0,o=zn(e)??zn(n);return!r&&!o?n:{...n,...r?{rotation:r}:{},...o?{transform:o}:{}}}function HP(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 DO(){let e=new Map,t=Ce(),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 _O=new WeakMap;function S8(e,t,n){if(typeof t!="object"||t===null)return e(t,n);let r=_O.get(e);r===void 0&&_O.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 GP(e){let t=e.scroll,n=e.composition?.scroll;if(!(t===void 0||n===void 0)&&!(e.overrides!==void 0&&_h(e)))return(r,o)=>{let i=t.get(r);return i===void 0?o:S8(n,o,i)}}function Hh(e,t){let n=GP(e);return n===void 0?t:{...t,childFrame:n}}function BO(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=Xn(o,d);if(f===null||!s.has(f)){let p=n(jt(o,c,i.compose),c);p!==null&&a.set(c,ma(o,p,d,i.compose,i.decompose))}l(c)}};return l(t),a}function HO(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 k8(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 hc(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(!tn(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},...k8(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 v8=new WeakMap,UP=new Float64Array(16),GO=(e,t,n)=>1-e*(1-(1-t)*n);function A8(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*GO(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-GO(f[h],r?r[o+h]:0,d?d[h]:1))}}}function WP(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)&&A8(e,t,n,a?a.store.cover:null,a?a.row*r:0)}function UO(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 R8(e){let t=e.get();if(e.live===0)return t;let{axes:n}=e;if(!n.add||e.holds||e.dimmed){let i=UO(e,t);return WP(e,i,0),n.from(i)}let r=n.count;UP.length<r&&(UP=new Float64Array(r));let o=UP;return o.fill(0,0,r),WP(e,o,0),n.add(t,o)}function N8(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?UO(e,r):o.to(r);for(let a=0;a<s.length;a++)t[n+a]=s[a]}i&&WP(e,t,n)}function VP(e){let t=e.axes??hc(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:()=>R8(n),readInto:(o,i=0)=>N8(n,o,i),axisCount:t.count,axes:t,axisIndexes:o=>HO(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 v8.set(r,n),r}var Gh="0.16.1";function Uh(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 VO={on:Number.MIN_VALUE,off:0},Ft=(e,t,n)=>e+(t-e)*n,I8=Ft,E8=Uh("lerp-into@1");function Wh(e){return E8.get(e)}var M8=(e,t)=>e+t,WO=(e,t)=>e*t,zO=(e,t)=>e*t,KO=(e,t)=>1+(e-1)*t,C8=(e,t)=>e>t?e:t,jO=Uh("numeric@1");function Qn(e){return jO.get(e)}var O8=Uh("width@1");function $O(e){let t=e.rest;return Array.isArray(t)?t.length:O8.get(e)??1}function Fe(e,t,n,r){return e==="sum"?M8(t,WO(n,r)):e==="mul"?zO(t,KO(n,r)):e==="max"?C8(t,WO(n,r)):+n}function YO(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 F8=(e,t)=>t===void 0?e:`${e}[${t[0]}, ${t[1]}]`;function zP(e){let t={kind:F8("mul",e?.bounds),bounds:e?.bounds,rest:1,merge:zO,scale:KO,lerp:I8};return jO.set(t,{op:"mul",axes:1}),t}function Vh(e){return{kind:e?.lerp?void 0:"last",merge:(t,n)=>n,lerp:e?.lerp??((t,n,r)=>r<.5?t:n)}}function Zn(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 qO(e){let t=e??!1;return t===!0?Number.POSITIVE_INFINITY:t===!1?1:t}var XO=(e,t,n)=>Number.isFinite(n)&&e>=t*n;function Ur(e,t,n){return t>0?XO(e,t,n)?1:e%t/t:0}function er(e,t,n){return t>0?XO(e,t,n)?n-1:Math.floor(e/t):0}function zh(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 Ta(e,t,n,r,o,i,s=null,a=null){let l=1;if(e>0&&!r&&(l*=zh(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 $t(e,t){return e===t?e!==0||1/e===1/t:Number.isNaN(e)&&Number.isNaN(t)}function Wr(e){return e<0?0:e>1?1:e}function Yt(e,t,n){return Wr(e*(t*n))}function jh(e,t){return!(t>0)&&e.out?.rest!==!0}function Ke(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 mc(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 JO(e,t){if(!(t>0))return 0;let n=e%t;return(n<0?n+t:n)/t}function Sa(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 KP(e,t){let n=Sa(e,t);e.anchorElapsed=Ke(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 ka(e,t,n,r){KP(e,t);let o=Sa(e,t);e.ramp=r>0&&n!==o?{from:o,to:n,over:r}:null,e.rate=n}function Lo(e,t){let n=t.spec.stepMs??e.opts.stepMs;return n!==void 0&&n>0&&!e.reducedNow?n:void 0}var L8=!1,va={u:Number.NaN,ease:void 0,left:0};function Vr(e,t,n){return Math.max(0,e-t)/n}function _o(e,t){return(t!==va.u||e!==va.ease)&&(va.u=t,va.ease=e,va.left=t>=1?0:1-e(t)),va.left}function Do(e,t,n){return n===0?t:t+(e-t)*n}function QO(e,t,n,r,o,i,s,a,l,u){let c=_o(e,n),d=0;if(L8&&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]=Do(p,h,c),u[f]=-(p-h)*d}return c===0}var ZO=0,eF=1,tF=2;var _8=4,D8=5,ot={y:0,dy:0},St={e:0,e2:0,cos:0,sin:0},B8={form:Number.NaN,k1:Number.NaN,k2:Number.NaN,k3:Number.NaN,t:Number.NaN};function H8(e,t){let n=e[0],r=e[2],o=e[3],i=e[4],s=B8;if(!($t(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 ZO:{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 eF:{let a=e[3];St.e=Math.exp(-a*t);return}case tF:{St.e=Math.exp(e[2]*t),St.e2=Math.exp(e[3]*t);return}default:St.e=Math.exp(-t/e[2])}}function G8(e,t,n,r){let o=e[0];o===ZO?U8(e,t,n):o===eF?W8(e,t,n,r):o===tF?V8(e,t,n):nF(e,t)}function U8(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 W8(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 V8(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 nF(e,t){let n=e[2],r=St.e;ot.y=t*r,ot.dy=-t/n*r}function z8(e,t,n,r,o){let i=e[2],s=t-n,a=t+r*i-n;if(a===0){nF(e,s);return}let l=e[3];if(s*a>0){let h=Math.exp(-l*o),m=r+l*s,y=h*(s+m*o);ot.y=y,ot.dy=h*m-l*y;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 rF(e,t,n,r,o,i,s,a,l,u,c,d,f,p){if(e[0]===_8)return QO(t,n,Vr(d,r,o),o,i,s,u,c,f,p);let h=Math.max(0,d-r)/1e3,m=e[1],y=m>0;H8(e,h);for(let b=0;b<n;b++){let x=u[c+b];e[0]===D8?z8(e,i[s+b],x,a[l+b],h):G8(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)&&(y=!1)}if(y)for(let b=0;b<n;b++)f[b]=u[c+b],p[b]=0;return y}var oF=1e-4,zr=[0,0];function jP(e,t,n,r){let o=t<oF?n:e,s=(r<oF?e:n)-o;s>Math.PI?s-=2*Math.PI:s<-Math.PI&&(s+=2*Math.PI),zr[0]=o,zr[1]=s}function iF(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,y=s>0?u:p,b=s>0?c:h,x=Math.sqrt(p*p+h*h),w=Math.sqrt(y*y+b*b);jP(Math.atan2(h,p),x,Math.atan2(b,y),w),o[0]=f,o[1]=x,o[2]=zr[0],o[3]=i,o[4]=m,o[5]=w,o[6]=zr[0]+zr[1],o[7]=s}var Vbe=new Float64Array(8),zbe=new Float64Array(4),Kbe=new Float64Array(4),jbe=new Float64Array(4),$be=new Float64Array(4);function yc(){try{return!0}catch{return!1}}var sF=new WeakSet;function tr(e,t){sF.has(e)||yc()||(sF.add(e),console.warn(`blits: ${t}`))}var Aa=Ft,$8=Array.from({length:256},(e,t)=>{let n=t/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),Y8=$8.map((e,t)=>{let n=(t-.5)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),aF=4096,exe=Array.from({length:aF+1},(e,t)=>{let n=0;for(;n<255&&t/aF>=Y8[n+1];)n++;return n});var $h=256,txe=new Int32Array($h).fill(-1),nxe=new Float64Array($h),rxe=new Float64Array($h),oxe=new Float64Array($h);var cF=new Float64Array(8);function q8(e,t,n){let r=cF;iF(e,0,t,0,r);let o=Aa(r[3],r[7],n),i=Aa(r[1],r[5],n),s=r[2]+zr[1]*n;return[Aa(r[0],r[4],n)*o,i*Math.cos(s)*o,i*Math.sin(s)*o,o]}var X8=1e-9;function lF(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<X8?0:(e[3]??0)*i:l,t[n+2]=Math.atan2(a,s),t[n+3]=o}function uF(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 J8(e,t,n){if(n===0)return uF(e,1,Zn(5,0));if(n===1)return uF(t,1,Zn(5,0));let r=cF;lF(e,r,0),lF(t,r,4);let o=r[3]>0?0:4,i=r[7]>0?4:0,s=r[o+1],a=r[i+1];jP(r[o+2],s,r[i+2],a);let l=Aa(r[3],r[7],n),u=Aa(s,a,n)*l,c=zr[0]+zr[1]*n;return[Aa(r[o],r[i],n)*l,Math.cos(c)*u,Math.sin(c)*u,u,l]}function $P(e){let t=e.lerp;return t===q8||t===J8}var ixe=Zn(5,0);var qP=e=>e;function fF(e){return e===void 0||e===qP}function gc(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,y=1;for(h=p;y-m>1e-7;)c(h)<p?m=h:y=h,h=(m+y)/2;return f(h)}}var Q8={linear:qP,ease:gc(.25,.1,.25,1),"ease-in":gc(.42,0,1,1),"ease-out":gc(0,0,.58,1),"ease-in-out":gc(.42,0,.58,1)},dF=new WeakMap,YP=new WeakMap([[qP,1]]);function Z8(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 pF(e){let t=YP.get(e);if(t!==void 0)return t;let n=1e-6,r=e(n);return r>.001?Number.POSITIVE_INFINITY:r/n}function Bo(e){if(typeof e=="function")return e;if(typeof e=="string"){let r=Q8[e];if(!r)throw new Error(`blits: no easing named ${e}`);return r}let t=dF.get(e);if(t)return t;let n;if("bezier"in e)n=gc(...e.bezier),YP.set(n,Z8(...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},YP.set(n,o?Number.POSITIVE_INFINITY:0)}return dF.set(e,n),n}function hF(e,t){return e==="queue"?1:e==="together"?0:t}function eY(e,t){return{rate:t.map(()=>1),skip:t.map(()=>!1),share:hF(e.order,e.share),allow:0}}function JP(e,t,n){let r=hF(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 nr=(e,t,n)=>JP(e,t,n).length<=e.left+n.allow+1e-9;function XP(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 tY(e,t,n){if(!nr(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(XP(1,s,l=>nr(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=XP(1,r,s=>!nr(e,t,o(s)));return nr(e,t,o(i))?o(i):o(Math.max(1,i-1e-9))}function nY(){return(e,t,n)=>{if(nr(e,t,n)||!t.some(i=>i.overlap))return n;let r=i=>({...n,share:i}),o=XP(0,n.share,i=>nr(e,t,r(n.share-i)));return r(n.share-o)}}function rY(){return(e,t,n)=>{let r=n;for(let o=t.length-1;o>=0&&!nr(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 oY(...e){return(t,n,r)=>{let o=r;for(let i of e){if(nr(t,n,o))break;o=i(t,n,o)}return o}}var mF=oY(nY(),rY()),Yh={weak:0,strong:1,required:2};function yF(e,t,n,r){let o=n(e,t,tY(e,t,eY(e,t)));return nr(e,t,o)||Yh[e.priority]===0||r==="overrun"?{plan:o,fell:!nr(e,t,o)&&Yh[e.priority]>0}:(o={...o,skip:t.map((i,s)=>o.skip[s]||Yh[i.priority]<Yh[e.priority])},{plan:o,fell:!0})}var Ho=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 iY(){return On(null,!1,void 0)}function gF(e){let t=this.chains.get(e);return t!==void 0&&t.version===this.version?t:this.relink(e,t)}function bF(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=sY(this,e,r,t??null));let s=i??iY();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 sY(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 xF(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 wF(e,t){return PF(e,t,this.now)}function PF(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 qh(e,t,n,r,o){return n!==void 0&&!n.reaches&&PF(e,t,r,o)?void 0:n}function Kr(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&&bc(e,r)}e.relinks++}function bc(e,t){t.version=Number.NaN;let n=++e.relinks;t.slot>=0&&e.lanes!==null&&(e.lanes.unlinked[t.slot]=n)}function QP(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 TF(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 Xh=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 aY(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=aY(e,t);r!==Number.POSITIVE_INFINITY&&e.due.push(Number.isNaN(r)?Number.NEGATIVE_INFINITY:r,t,n)}function SF(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?ji(r):i===r.length?r:lY(r,i)}function lY(e,t){let n=ji(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 uY=8;function ji(e){if(e.length>uY)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=ZP(e,2);for(let n=0;n<Jh;n++)eT[n]=void 0;return Jh=0,t===cn?structuredClone(e):t}var eT=[],Jh=0;function cY(e){for(let t=0;t<Jh;t++)if(eT[t]===e)return!0;return!1}function ZP(e,t){if(typeof e=="symbol"||typeof e=="function")return cn;if(typeof e!="object"||e===null)return e;if(t===0||cY(e))return cn;if(eT[Jh++]=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=ZP(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=ZP(e[o],t-1);if(i===cn)return cn;r[o]=i}return r}function Ra(e){return typeof e!="object"||e===null?e:Array.isArray(e)?[...e]:ArrayBuffer.isView(e)?e.slice():vF(e)?bt(e):e}function $i(e){return Array.isArray(e)?[...e]:e}function kF(e){return Array.isArray(e)||ArrayBuffer.isView(e)||vF(e)}function vF(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function qt(e,t,n=!1){return t<e.seq||t===e.seq&&(!e.strict||n)}var AF=new WeakMap,tT=new Map,me=class{weak=AF;strong=tT;oneKey=Na;oneValue=void 0;get(t){return typeof t=="object"&&t!==null?this.weak.get(t):nT(this.oneKey,t)?this.oneValue:this.strong.get(t)}set(t,n){if(typeof t=="object"&&t!==null){this.weak===AF&&(this.weak=new WeakMap),this.weak.set(t,n);return}if(this.strong===tT&&(this.oneKey===Na||nT(this.oneKey,t))){this.oneKey=t,this.oneValue=n;return}this.strong===tT&&(this.strong=new Map),this.oneKey!==Na&&(this.strong.set(this.oneKey,this.oneValue),this.oneKey=Na,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):nT(this.oneKey,t)?(this.oneKey=Na,this.oneValue=void 0):this.strong.delete(t)}clear(){this.oneKey=Na,this.oneValue=void 0,this.strong.clear()}},xc=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)}},Na=Symbol("none"),nT=(e,t)=>e===t||Object.is(e,t),Qh=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(!qt(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())!qt(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 Yi(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:Ho(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,Yi(e,i.held)])),t.inputs!==void 0&&(o.inputs=t.inputs.map(i=>({...i}))),o}function qi(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:qi(e,a)}))),t.inputs!==void 0&&(o.inputs=t.inputs),o}var wc=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"}},Zh=class{store;loaded=null;last=null;constructor(t){this.store=t}},em=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 rr(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)}RF(e.transport,u,s)}function RF(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 NF(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&&RF(e,r,n)}async function IF(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 tm=class{cued=null;by=new Map;gone=null;goneBy=new Map;versions=new Map;held=new Set};function nm(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 EF(e,t){return e.transport.holders.get(t)??DF}function rT(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 MF(e){for(let t of e.cued)t.spec.score!==void 0&&nm(e,t.spec.score);for(let t of e.gone)t.spec.score!==void 0&&nm(e,t.spec.score)}function CF(e){for(let t of[...e.scored.held])rT(e,t)}function Ia(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 OF(e,t){return e.scored.versions.get(t)??0}function FF(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 LF(e,t){let n=e.scored;if(n.cued!==e.cued){n.by=new Map;for(let r of e.cued)FF(n.by,r);n.cued=e.cued}return n.by.get(t)??dY}var dY=new Set;function _F(e,t){let n=e.scored;if(n.gone!==e.gone){n.goneBy=new Map;for(let r of e.gone)BF(n.goneBy,r);n.gone=e.gone}return n.goneBy.get(t)??DF}var DF=[];function BF(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 rm(e,t){t.spec.score!==void 0&&nm(e,t.spec.score);let n=e.scored;n.gone===e.gone&&BF(n.goneBy,t)}function oT(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 HF(e,t){Ia(e,t),t.spec.score!==void 0&&nm(e,t.spec.score);let n=e.scored;n.cued===e.cued&&FF(n.by,t)}function GF(e,t){for(let r of t)Ia(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 or=Symbol("absent"),UF=Symbol("unit"),om=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?UF: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 or;if(n!==UF){if(n instanceof WeakRef){let r=n.deref();return r===void 0?or: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 fY=(e,t)=>e.seq===void 0||Number.isNaN(e.seq)||qt(t,e.seq,e.early===!0);function pY(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 im(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||fY(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=pY(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 hY=e=>typeof e=="number"?[e]:[...e];var VF=Symbol.for(`@msb235/blits/motions@${Gh}`),WF=new Map,iT=class{motions;writes;constructor(t,n){this.motions=n;let r=WF.get(t);r===void 0&&(r=Object.freeze([t]),WF.set(t,r)),this.writes=r}form="motion";duration=0;get motion(){return this.motions.spec()}get[VF](){return this.motions}at(t,n,r){let o=this.motions,i=pe.back;if(i!==null){let a=im(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:hY(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 iT?e.motions:e[VF]}var sm=class{list;set;delays=null;latest=0;soonest=0;constructor(t,n){if(Array.isArray(t)&&mY(t)){this.list=t.slice(),this.set=null,n&&(this.delays=zF(this.list,n)),[this.latest,this.soonest]=KF(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=zF(this.list,n)),[this.latest,this.soonest]=KF(this.delays)}get size(){return this.list.length}has(t){return this.set===null?this.list.includes(t):this.set.has(t)}};function zF(e,t){let n=new Map;for(let r of e)n.set(r,t(r));return n}function KF(e){let t=0,n=0;for(let r of e?.values()??[])r>t&&(t=r),r<n&&(n=r);return[t,n]}function mY(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 yY=256;function Go(e,t,n=!1){let r=e.clocks;if(r!==null&&r.length>=yY)return;let o=e.holding!==null||e.spec.stagger!==void 0?Number.POSITIVE_INFINITY:0;if(r!==null&&jF(r,0)>=o&&jF(r,$F(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 jF(e,t){let n=Number.NEGATIVE_INFINITY;for(let r=t;r<e.length;r++){let o=e[r],i=Ke(o,o.until);i>n&&(n=i)}return n}function $F(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 gY(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 am(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($F(e),gY(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:am(e.owner,o,n)}function Uo(e){return e.owner===null?e.start:am(e.owner,e.start,!1)}var Xi=Object.freeze({form:"fn",duration:0,writes:[],at:()=>({})}),Wo=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?Ke(e,n):Number.NEGATIVE_INFINITY}function YF(e,t,n){let r=Te(t,n);return r===Number.NEGATIVE_INFINITY?r:Ke(e,r)}function Vo(e,t){let n=e.backs?mc(e,t):Cn(e,t);return e.owner===null?n:Vo(e.owner,n)}function lm(e){let t=!1;for(let n=e.owner;n!==null;n=n.owner)n.backs&&(t=!t);return t}function qF(e,t){let n=e.holding;n.children.push(t),n.kids++}function XF(e,t){let n=e.owner,r=n.holding,o=r.children.indexOf(e);return o>=0&&r.children.splice(o,1),!jr(n,t)&&n.state!=="done"?n:null}function jr(e,t){for(let n of e.holding.children)if(!n.quietAt(t))return!0;return!1}function JF(e,t,n){let r=e.holding;++r.played===r.kids&&e.play(!0,t,n)}function Ji(e,t){for(let n of e.holding.children)t(n),n.holding!==null&&Ji(n,t)}function QF(e){for(let t=e.owner;t!==null;t=t.owner)if(typeof t.spec.weight=="function")return!0;return!1}function ZF(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 sT(e,t,n,r){let o=typeof e.spec.weight=="function"?r(e):e.weight,i=Uo(e),s=e.freezesBefore&&e.opened<i?e.opened:i;return Wr(o*Ta(e.fade.in??0,e.out,e.ease,n,t,s,e.back,e.stalls))}function eL(e,t,n,r){let o=1,i=e;for(let s=e.owner;s!==null;i=s,s=s.owner)o*=sT(s,t,n,r),s.arc!==null&&(o*=tL(s,i,t,n));return o}function Ea(e,t){let n=new Map;for(let r of e)if(n.set(r.id,r),r.holding!==null){let o=new Wo;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 lT(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 bY=(e,t,n)=>e+(t-e)*n;function aT(e,t,n){if(typeof e=="number"&&typeof t=="number")return bY(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]=aT(e[o],t[o],n);return r}return n<.5?e:t}function xY(e,t,n,r){let o=r.ease===void 0?void 0:Bo(r.ease),i=[];for(let s of t){let a=r.easeBy?.(s),l=a===void 0?o:Bo(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:Bo(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===Ft)&&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 cm=0,Ma=1,wY=2,He={a:void 0,b:void 0,u:0,eased:0,first:!1,len:0,ease:void 0};function uT(e,t,n){return cT(e.delay,t,n)}function cT(e,t,n){return e===0||n===0?t:e>=n?t>=1?1:0:Math.max(0,(t*n-e)/(n-e))}function dT(e,t,n,r,o){return r===0?-2:o<=e[t]?-1:o>=e[t+(r-1)*n]?r:rL(e,t,n,1,r-1,o)}function rL(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 fT(e,t,n){return(e-t)/(n-t)}function pT(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=dT(e.ats,0,1,c,t),r===-2)return cm;if(r===-1||r===c)return He.a=i[r===-1?0:c-1].value,Ma}else{let c=i.length+1;if(t<=0)return He.a=n,Ma;let d=i[i.length-1];if(d===void 0||t>=d.at)return He.a=d===void 0?n:d.value,Ma;e.tailAts??=i.map(f=>f.at),r=rL(e.tailAts,-1,1,1,c-1,t)}let s=i[r-o],a=r-1<o?0:i[r-1-o].at,l=fT(t,a,s.at),u=s.ease?s.ease(l):l;return He.a=r-1<o?n:i[r-1-o].value,He.b=s.value,He.u=l,He.eased=u,He.first=r-1<o,He.len=s.at-a,He.ease=s.ease,wY}function PY(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 TY(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===Ft||e.lerp!==void 0))return PY(l,t);let u=pT(e,t,n);if(u===cm)return;if(u===Ma)return He.a;let c=He.a,d=He.b,f=He.u,p=He.eased,h=He.first,m=He.len,y=He.ease,b;if(s!==void 0)b=s(a,c,d,p),um.wrote=b;else{let g=e.lerp??r;b=g?g(c,d,p):aT(c,d,p)}if(o===void 0||!h)return b;let x=y?pF(y):1;if(x===Number.POSITIVE_INFINITY)return b;let w=(g,P,S)=>(g*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 g=b===um.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):aT(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"){g[v]=A;continue}let M=c[v],C=d[v];if(typeof M!="number"||typeof C!="number"){let[F,D]=P??S();M=F?.[v],C=D?.[v]}g[v]=typeof M=="number"&&typeof C=="number"?A+w(N,M,C):A}return g}return b}var um={wrote:void 0};function oL(e,t){return e.tracks.map((n,r)=>{let o=t[r];return n.lerp===void 0||n.lerp===o.lerp?Wh(o):void 0})}function dm(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];um.wrote=void 0;let p=TY(c,uT(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===um.wrote&&(a[u]=p),p!==void 0?n[c.channel]=p:n[c.channel]!==void 0&&(n[c.channel]=void 0)}return n}var nL=new WeakMap;function iL(e){let t=nL.get(e);return t===void 0&&(t=xY(e.keys,e.writes,e.duration,e),nL.set(e,t)),t}function hT(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 fm=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=hT(this.voice)),this.kept}};function Pc(e,t){let n=e.named?.delays?.get(t);return n!==void 0?n:e.spec.stagger?e.spec.stagger(t):0}function Tc(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 $r(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 mT(e,t,n){Tc(e,t)&&($r(e,n,!0),$r(e,t,!1))}function sL(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 aL(e,t,n,r=null){if(e.sharing){let d=this.share.everyoneOf(this,e);if(d!==null)return d}if(Tc(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?$r(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=Pc(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=yT(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),gT(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 yT(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=Lo(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 lL(e,t){let n=e.patch;return am(e,t,n.state!==void 0||n.step!==void 0||e.keeping)}function uL(e,t){let n=Uo(e),r=t<n?n:t;return e.freezesBefore&&e.opened<r?e.opened:r}function cL(e,t,n){return!(t.since<=n)||e.motion!==void 0&&!(t.probed>=t.since)}function gT(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)cL(e,i,n)&&(r[o++]=i);r.length=o}r.push(t)}function Ca(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),Kr(e,t)}function Oa(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)Oa(e,t,i),cL(t,i,n)&&(r[o++]=i);r.length=o,o===0&&(t.early=null),e.lanes?.reshown(t.id)}var pm=class{of=null;count=0;general=[];named=new me;latest=Number.NEGATIVE_INFINITY;slack=0};function SY(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 dL(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 zo(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++)SY(t,n[r]);return t.count=n.length,t}function fL(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 bT(e,t){let n=zo(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)}dL(n,s),fL(e,s),e.gone=i,oT(e,r,s),n.of=i,n.count=i.length}function pL(e,t){let n=zo(e);if(!Number.isFinite(n.slack)){bT(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),dL(n,l),fL(e,l),oT(e,r,l),n.count=r.length}var hL=[];function xT(e,t){return e>=0&&(t>0?e<t:Number.isFinite(e))}function mL(e,t){for(let n of e)if(!xT(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 hm=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=kY(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??hL))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,g]of d.booked){if(g.time<=t)continue;let P=this.timeOfHit(u,c,Math.floor(w/p),w%p,f);this.stands(g,P)||(g.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 y=Math.max(d.seenTo,u.elapsedAt(l));if(!(y<=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(y/b)):0;w<=x;w++)for(let g=0;g<p;g++){let P=w*b+c[g].at;if(!(P>d.seenTo&&P<=m))continue;let S=w*p+g;if(d.booked.has(S))continue;let v=this.timeOfHit(u,c,w,g,f);if(v===void 0||!Number.isFinite(v))continue;let A={timestamp:v,voice:u.id,hit:g,pass:w,event:c[g].event,score:u.spec.score,name:u.spec.name,tags:u.spec.tags??hL,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 kY(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 Qi=["start","in","coast","out","end"];function bL(e,t){for(let n of Object.keys(e)){if(Qi.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(!xT(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 wT(e,t){return(e.pace===null?t:e.pace.timeOf(t))+e.offset}function xL(e,t){return e.pace===null?t:e.pace.reading(t)}function mm(e,t,n){let r=SL(e,t,n);for(let o of TL(e.transport,t,n))(o.score!==void 0||o.slot===e.slot)&&r.push(o.listed);return PL(r)}function wL(e,t,n){let r=[];for(let o of e.members)r.push(...SL(o,t,n));for(let o of TL(e,t,n))r.push(o.listed);return PL(r)}function PL(e){return e.sort((t,n)=>t.timestamp-n.timestamp||t.order-n.order)}function TL(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 SL(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 Qi)yL(e,s,l,r,o,i);let a=s.spec.marks;if(a!==void 0)for(let l of Object.keys(a))yL(e,s,l,r,o,i)}return i}function yL(e,t,n,r,o,i){let s=Qe(e,t,n),a=s===void 0?s:wT(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 Qe(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 vL(t,r,n);if(n==="in")return r+(t.fade.in??0);if(n==="coast")return AY(e,t,r);if(n!=="out"&&n!=="end")return vY(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=kL(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 gL=1e-9;function vY(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-gL));else if(i<s-gL)return;if(l>=t.passes)return;let u=t.timeAt(l*a+i);if(!Number.isFinite(u))return;let c=Qe(e,t,"end");return c!==void 0&&u>=c?void 0:Math.max(n,u)}function AY(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=kL(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 kL(e,t,n){if(t.length===0)return;let r=Number.NEGATIVE_INFINITY;for(let o of t){let i=Qe(e,o,n);if(i===void 0)return;i>r&&(r=i)}return r}var ym=class{start=void 0;in=void 0;coast=void 0;out=void 0;end=void 0};Object.setPrototypeOf(ym.prototype,null);var gm=class{scopes=new Map;all=new Set;add(t,n){if(n.owner?.state==="done")return;let r=new ym;for(let a=0;a<Qi.length;a++){let l=Qi[a];r[l]=Qe(t,n,l)}let o=n.spec.marks;if(o!==void 0)for(let a of Object.keys(o))r[a]=Qe(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 AL(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 Sc(e,t){return t.owner===null?e.now:Te(t.owner,e.now)}function _n(e){return e.owner===null?e.start:Vo(e.owner,e.start)}function Zi(e,t){return e.pace===null?t:e.pace.at(t,e.u)}function Ko(e,t,n){e.pins??=new Map,e.pins.set(t,n),t.pinned=n}function NL(e){let t=e.pins;for(let[n,r]of t)n.state!=="pending"?t.delete(n):_a(e,n,Zi(e,r))}function _a(e,t,n){return n===t.start?!1:(t.start=n,t.anchorNow=n,t.clocks=null,t.seeks++,dn(e,t,e.now),je(e,t),!0)}function IL(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(g=>a(u,g));if("any"in c)return c.any.flatMap(g=>a(u,g));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 y=i.filter(g=>g!==u&&g.spec.score===h&&(m||g.owner===u.owner&&g.slot===u.slot)&&(p.name===void 0||g.spec.name===p.name)&&(p.tag===void 0||(g.spec.tags??fn).includes(p.tag))&&(p.writes===void 0||g.writes.includes(p.writes))),b=p.resolver??"last",x=y.length>1&&(b==="first"||b==="last")?[y.reduce((g,P)=>(b==="last"?P.id>g.id:P.id<g.id)?P:g)]:y,w=f==="out"||f==="end"?"out":"start";return x.map(g=>({voice:g,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 Yr(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:La(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,Vo(a,s)-l);Number.isFinite(u)&&_a(e,r,u)&&(n=!0)}}if(r.state!=="fading"&&!r.outSet){let i=o.out??o.end,s=i===void 0?void 0:La(e,i,r);if(s!==void 0){let a=r.owner===null?s:Vo(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&&tr(r,`${r.spec.name??`voice ${r.id}`}'s placement ends before it starts, so it plays as an instant`))),(u!==r.outAt||!$t(c,r.outOver))&&(r.outAt=u,r.outOver=c,je(e,r),n=!0)}}}}if(!n)break}EL(e)}function La(e,t,n,r){let o=n.owner;if(typeof t=="number")return o===null?Zi(e,t-n.offset):t;if("all"in t){let c=Number.NEGATIVE_INFINITY;for(let d of t.all){let f=RL(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:Sc(e,n),d=Number.POSITIVE_INFINITY,f=!1;for(let p of t.any){let h=RL(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=RY(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 RL(e,t,n,r){let o=La(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 Fa=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 RY(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 Fa(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?EF(e,i):e.transport.members:[e],p=r.owner?.id??-1,h=new Fa(a,l);for(let m=0;m<f.length;m++){let y=f[m],b=!1;for(let v of y.departed.all)AL(v,o,i,s,p)&&(h.take(v.id,v.marks[n]),b=!0);if(i===void 0||y.projecting||e.projecting){for(let v of[...y.gone,...y.cued])c(v)&&u.take(v.id,Qe(y,v,n));continue}let x=LF(y,i),w=_F(y,i);if(x.size===0&&w.length===0&&!b){d&&(rT(y,i),m--);continue}if(a==="next"){for(let v of x)c(v)&&u.take(v.id,Qe(y,v,n));for(let v of w)c(v)&&u.take(v.id,Qe(y,v,n));continue}let g=NY(y,w,t,n,r,a),P=OF(y,i),S=y.reduced;if(g.live===null||g.liveOf!==y.cued||g.liveVersion!==P||g.liveReduced!==S){let v=new Fa(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,Qe(y,N,n)));g.live=v,g.liveOf=A?y.cued:null,g.liveVersion=P,g.liveReduced=S}for(u.merge(g.live);g.seen<w.length;g.seen++){let v=w[g.seen];c(v)&&(v.owner===null?g.pick.take(v.id,Qe(y,v,n)):g.owned.push(v))}u.merge(g.pick);for(let v of g.owned)u.take(v.id,Qe(y,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:Zi(e,m.at));return(u.any?u:h).answer()}function NY(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 Fa(i,Number.NEGATIVE_INFINITY),owned:[],live:null,liveOf:null,liveVersion:-1,liveReduced:!1},s.set(e,a)),a}function TT(e){if(!Number.isFinite(e))throw new RangeError(`blits: a voice's rate is a finite number, not ${e}`)}function ST(e){if(Number.isNaN(e))throw new RangeError("blits: a voice\u2019s weight is a number, not NaN")}var qr=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){ST(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){TT(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);Go(r,o),ka(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);Go(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&&PT(o.patch,"to","a spring or a tween").to(t,n,r)}push(t,n,r){let o=this.#t;o!==null&&PT(o.patch,"push","a spring or a glide").push(t,n,r)}set(t,n,r){let o=this.#t;o!==null&&PT(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 PT(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 IY=new WeakSet,ML=e=>IY.has(e);function kc(e,t,n){let r=n===0?0:Math.abs(e*n-t);return r>=1?0:1-r}var xm={transport:e=>e,mix:e=>e},vc=xm,bm;function Da(e){throw new Error(`blits: the tape holds ${e}, which a read ahead cannot play; seek there to see it`)}var CL={apply(){},invert:()=>CL};function OL(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 Xr(e){return e.tape!==void 0&&!e.replaying&&!e.projecting}function Lt(e,t,n){let r=e.tape;if(r===void 0||!Xr(e))return;let o={label:t,apply(){if(vc===xm)n(vc);else try{n(vc)}catch(i){bm??={error:i}}},invert:()=>CL};r.recordEntry([o],t)}function es(e,t){return e.pace===null?t:e.pace.timeOf(t)}function Jr(e,t){let n=es(e,t);return e.u>n?e.u:n}function Ba(e,t,n=e,r=xm){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)Qr(u,l);n.tick(n.now)}e.replaying=!0,vc=r;try{o.redo()}finally{e.replaying=!1,vc=xm}if(bm!==void 0){let{error:l}=bm;throw bm=void 0,l}}}finally{n.u=i}}function FL(e,t,n){let r=e.strays.get(n);r===void 0?e.strays.set(n,[t]):r.includes(t)||r.push(t)}function LL(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)FL(e,n,o)}function _L(e){return{frame(t,n){let r=e.deref(),o=r===void 0?void 0:jo(r,t);return r===void 0||o===void 0?Number.NaN:DL(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&&Xr(i)&&EY(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||rr(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=jo(r,t);return o===void 0||(o.motion!==void 0&&o.named!==null&&!o.named.has(n)&&FL(r,o.motion,n),o.parted?.has(n)!==!0)?Number.NaN:(vT(r,o,n),kT(r,o,Pc(o,n)))}}}function EY(e,t,n,r,o){Lt(e,"motion",i=>{let s=i.mix(e);if(s===void 0)return;if(s!==e)return MY(s,t,n,r,o);((jo(e,t)??e.gone.find(l=>l.id===t))?.motion??n).change(r,{...o})})}function MY(e,t,n,r,o){let i=r,s=jo(e,t),a=o.at;if(s!==void 0){let p=s.parted?.has(i)===!0;if(p&&vT(e,s,i),a===void 0){let h=DL(e,s,i),m=p?kT(e,s,Pc(s,i)):h;Number.isNaN(h)?Number.isNaN(m)||(a=m):a=h}}a===void 0&&Da("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 jo(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 DL(e,t,n){let r=t.subjects.get(n);return r===void 0||!r.reaches?Number.NaN:kT(e,t,r.delay)}function kT(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 GL(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=>wT(e,o),readingAt:o=>xL(e,o-e.offset),endOf:o=>Qe(e,o,"end"),marks:(o,i)=>mm(e,o,i),unhook:o=>{let i=(e.bookers??[]).filter(s=>s!==o);e.bookers=i.length===0?null:i}},r=new hm(n,t);return e.bookers=[...e.bookers??[],r],r}function wm(e){return{get voices(){return e.cued},channels:e.channels,names:e.names,clock:e,fits:t=>CY(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)$r(n,t,!1),n.sighted!==null&&e.share?.unsight(n,t);for(let n of zo(e).general)$r(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&&ts(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)=>Pm(e,t,n,r),kept:t=>ts(e,t)}}function ns(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 CY(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&&QF(t))return!1;let o=n.weight;if(typeof o=="function"&&o.input&&(e.opts.history?.inputs||!ML(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||ns(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 BL={exact:0,stepped:1,held:2};function HL(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||Lo(e,t)!==void 0&&e.opts.maxDt===void 0?"exact":"stepped"}function ts(e,t){t.keeping||(t.keeping=!0,t.sharing&&e.share?.unshare(e,t,!0,e.sending.subject),e.lanes?.invalidate())}function Ac(e,t){return e.handles??=OY(e),new qr(t,e.handles)}function OY(e){return{nowFor:t=>{if(Number.isNaN(e.now))return t.start;let n=Sc(e,t);return Number.isFinite(n)?n:t.start},changed:t=>{e.frame=st(),dn(e,t,e.now),t.holding!==null&&Ji(t,n=>dn(e,n,e.now)),je(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=HL(e,t,n);return t.holding!==null&&Ji(t,i=>{i.seeks++,n&&i.rebuilds++;let s=HL(e,i,n);BL[s]>BL[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?UL(e,t,n.subject,n.over):typeof n?.at=="number"?VL(e,t,n.at,n.over):Zr(e,t,n??{})},rise:(t,n)=>WL(e,t,n??{}),release:t=>zL(e,t),weightOf:(t,n)=>{if(t.state==="done")return 0;if(t.holding!==null)return sT(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:()=>Xr(e),record:(t,n,r)=>Lt(e,n,o=>{let i=o.mix(e);if(i===e)r(t);else if(i!==void 0){let s=jo(i,t.id);s!==void 0&&r(Ac(i,s))}})}}function Rc(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 Ha(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=Rc(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 KL(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 kc(o.value,i,o.stops);if(a=o.reads.get(t),a?.frame===s)return kc(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),kc(u,i,o.stops)}function jL(e,t){let{of:n,i:r}=e.blend;return t<n.frames.length&&n.frames[t]===this.frame?kc(n.values[t],r,n.stops):Number.NaN}function $L(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),ts(this,o)}}var YL=new WeakMap,qL=e=>typeof e=="function"?YL.get(e):void 0;function XL(e,t={}){if(typeof e!="object"||e===null)throw new TypeError("blits: around takes a circle, { x, y, r }");let n=Bo(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 YL.set(r,e),r}var FY=Ra;function LY(e,t){let n=new Uint8Array(t);return e.bands=n,n}function Ic(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)=>Ic(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 kt(e){e?.bands&&e.bands.fill(2)}function JL(e,t){let{on:n,off:r}=this.band;return t>=n?!0:t<=r?!1:e??t>=n}function QL(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]=Fe(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??LY(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?$i(u):Nc(d,e[l],u))}}function ZL(e){for(let t of this.bounded){let n=this.names[t];e[n]=_Y(this.channels[t],e[n])}return e}function _Y(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 e_(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 t_(e,t,n=!1,r){let o=this.folded(e,t,n,r);return this.bounded.length===0?o:this.clamp(o)}function n_(e,t,n=!1,r){let o=this.linked(e);return this.foldWith(e,t??this.pose(),o,this.linkedLaned,n,r)}function r_(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 o_(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):FY(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 i_(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 s_(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 a_(e,t){return e>=0&&this.lanes.owesVoice(e,t.id)}var Tm=5,Sm=new Map,l_=new WeakMap,u_=0,DY=0;function BY(e){if(e===void 0)return 0;let t=l_.get(e);return t===void 0&&(t=++DY,l_.set(e,t)),t}var AT=e=>Object.is(e,-0)?"-0":String(e);function HY(e){let t=AT(e.duration);for(let r of e.tracks){if(r===void 0)return++u_;t+=`|${AT(r.delay)}`;for(let o of r.all)t+=`,${AT(o.at)}:${BY(o.ease)}`}let n=Sm.get(t);return n===void 0&&(Sm.size>=4096&&Sm.clear(),n=++u_,Sm.set(t,n)),n}var Ga=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(!GY(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]=HY(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,y=s[c],b=c+2;c=b+y*m;let x=l[f];if(x===-2)continue;let w=p.values,g=o*h;if(x===-1||x===y){let A=b+(x===-1?0:y-1)*m+1;for(let N=0;N<h;N++)w[g+N]=Fe(p.op,w[g+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=Ft(s[S+1+A],s[P+1+A],v);w[g+A]=Fe(p.op,w[g+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=cT(o[a+1],n,i),p=a+2;a=p+d*c;let h=dT(o,p,c,d,f);if(this.found[u]=h,h>=0&&h<d){let m=p+h*c,y=fT(f,o[m-c],o[m]),b=this.eases[s+h];this.easedAt[u]=b?b(y):y}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 GY(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 c_(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,y=typeof r.spec.weight=="function",b=e.probes!==c,x=Wr(r.weight),w=e.arg,g=n.n,P=l.op;if(g>0&&(t.axes!==g&&(t.axes=g,t.samples=new Float64Array(0)),s.length*g>t.samples.length)){let B=new Float64Array(Math.max(s.length,t.samples.length/g*2,4)*g);B.set(t.samples),t.samples=B}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&&!y&&n.watcher===e&&n.watchId===r.id,M=g===l.axes&&l.plain,C=Number.NaN,F=Number.NaN,D=0;for(let B=0;B<s.length;B++){if(y&&r.keeping)return;let K=s[B],W=B*8,Q=K*6;if(_t(o,W,i,Q,u),d>=0&&e.unread(K)){Ua(t,B);continue}let le=o[W+0],ke=p-le;if(!(ke>=0)){Ua(t,B),o[W+2]=0;continue}if(!h){let ee=o[W+1];(!t.weighed||!$t(ee,t.weighedSince))&&(t.fade=e.host.envelope(r,ee),t.weighed=!0,t.weighedSince=ee)}let ue;if(y){if(w[1]=ke,w[3]=er(ke,r.duration,r.passes),w[5]=t.fade,!e.signalled(r,K,a[B])){o[W+2]=0;continue}ue=w[0]}else if(m)ue=Yt(r.weight,t.fade,e.parting(r,K));else if(h)ue=x;else{let ee=t.fade,te=r.weight;(ee!==C||te!==F||ee===0||te===0)&&(C=ee,F=te,D=Yt(te,ee,1)),ue=D}if(o[W+2]=ue,o[W+7]===0){if(Number.isNaN(a[B].probed)){Ua(t,B),e.late.push(K);continue}o[W+7]=1}let ve=o[W+4],G=-1,j=!1;if(ve>=0){G=5+ve*n.stride;let ee=n.runs[G+1];(ee&6)!==0&&(G=-1),j=(ee&1)!==0}if(G<0||b&&(i[Q+3]>c||i[Q+4]>c)){w[1]=ke,w[4]=le,w[0]=ue,Ec(e,t,n,B,K,a[B]);continue}let $=n.runs;if(N&&M&&j===l.scalar){if(o[W+5]!==-2&&(o[W+5]=-2,t.deltas[B]=null),ue<=0)continue;let ee=_o(A,Vr(ke,$[G],$[G+2])),te=l.values,he=K*g,xe=G+3,Le=xe+2*g;for(let Se=0;Se<g;Se++)te[he+Se]=Fe(P,te[he+Se],Do($[xe+Se],$[Le+Se],ee),ue);continue}if(A!==void 0){let ee=_o(A,Vr(ke,$[G],$[G+2])),te=G+3,he=te+2*g;for(let xe=0;xe<g;xe++)v[xe]=Do($[te+xe],$[he+xe],ee)}else n.sampleBare(ve,ke,v,n.vs);for(let ee=0;ee<g;ee++)S[B*g+ee]=v[ee];if(t.deltas[B]!==null&&(t.deltas[B]=null),o[W+5]=u,o[W+6]=f,!(ue<=0))if(M&&j===l.scalar){let ee=l.values,te=K*g;for(let he=0;he<g;he++)ee[te+he]=Fe(P,ee[te+he],v[he],ue)}else w[0]=ue,e.foldInto(l,K,n.value(ve,v))}N&&(t.bareFill=u,t.bareElapsed=p,t.bareSeeks=f)}function Ec(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(Mc(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 y=e.subjectAt(o);if(y===or)return;h=n.slot(y),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 UY(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 Mc(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]??UY(t,n),o.probed=e.now,o.seeks=t.data[i+6])}var f_=new Float64Array(0);function RT(e){return(e&2043)===1211}var km=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=Rm.other;cursor=0;dead=0;stale=!1;staleRows=[];xs;vs;delta={};keys=new Ga;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){Am(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 NT(e,t){if(!e.overlap){for(let n of e.crowds)!n.idle&&n.cursor<n.size&&d_(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;d_(e,n,o)}}function d_(e,t,n){let r=t.list,o=t.hot,i=t.cursor;for(;i=m_(e,t,i,n),!(i>=r.length||o[i*t.stride+7]>=n);)i=WY(e,t,i,n);t.cursor=i}function WY(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,y=t.xs,b=t.vs,x=t.samples,w=n;for(;w<u.length;w++){let g=w*s;if(i[g+7]>=r)break;let P=i[g+0];if(w>n&&RT(P))break;if(o[w*8+5]===-2&&Am(t,w),(P&64)!==0&&(P=VY(t,w)),(P&1)===0||(P&16)===0)continue;let S=u[w],v=w*8,A=S*6;if(_t(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],D=(M?vm(i,g,m):C.elapsedAt(m))-N;if((P&256)!==0&&(D=D>=0?D>C.span?C.hidesPast?Number.NaN:C.freezesAfter?C.span:D:D:C.freezesBefore?0:Number.NaN),!(D>=0)){o[v+2]=0;continue}let B;if(M)B=i[g+4];else if(typeof C.spec.weight=="function"){let W=e.host.envelope(C,o[v+1]);if(l[1]=D,l[3]=er(D,C.duration,C.passes),l[5]=W,!e.signalled(C,S,t.records[w])){o[v+2]=0;continue}B=l[0]}else B=Yt(C.weight,e.host.envelope(C,o[v+1]),e.parting(C,S));if(o[v+2]=B,(P&512)!==0){B>0&&t.keys.fold(i[g+9],Ur(D,i[g+11],i[g+10]),t.chans,S,B);continue}if(l[1]=D,l[4]=N,l[0]=B,(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 K=o[v+4];if(K<0||(P&8)===0||h&&(a[A+3]>p||a[A+4]>p)){let W=t.motions[w];Ec(e,t,W,w,S,t.records[w]),K<0&&t.restale(w,i[g+0]);continue}rF(t.laws[w],t.eases[w],d,i[g+9],i[g+10],i,g+11,i,g+11+d,i,g+11+2*d,D,y,b);for(let W=0;W<d;W++)x[w*d+W]=y[W];t.deltas[w]!==null&&(t.deltas[w]=null),o[v+5]=f,o[v+6]=i[g+5],!(B<=0)&&((P&32)!==0?e.foldRun(c,S,y):e.foldInto(c,S,t.motions[w].value(K,y)))}return w}function p_(e,t,n,r){let o=this.arg,i=o[1],s=n.duration;if(o[2]=Ur(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]=er(i,s,n.passes),this.call(n,e.chans,a,r)}function VY(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]=Wr(n.weight),e.hot[r+5]=n.seeks,e.hot[r+0]=o,o}function h_(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&&zY(e,i,a)}}function zY(e,t,n){Am(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 vm(e,t,n){return e[t+2]+(n-e[t+1])*e[t+3]}function m_(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,y=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||!RT(w))break;let g=n*8,P=(w&2048)!==0;if(!P&&(o[g+4]<0||o[g+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=vm(i,x,m)-o[g+0],!(N>=0)))break;_t(o,g,a,v,d);let M=i[x+4];if(o[g+2]=M,P||(o[g+5]!==-2&&(o[g+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,D=x+11,B=D+2*c;if(A){for(let Q=0;Q<c;Q++)C[F+Q]=Fe(y,C[F+Q],i[B+Q],M);continue}let K=Vr(N,i[x+9],i[x+10]),W=_o(t.eases[n],K);K>=1&&i[x+3]>0&&(i[x+8]=m);for(let Q=0;Q<c;Q++)C[F+Q]=Fe(y,C[F+Q],Do(i[D+Q],i[B+Q],W),M)}return n}function Am(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=vm(o,i,e.bareNow)-r[n+0],l=_o(e.eases[t],Vr(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]=Do(o[u+d],o[c+d],l);r[n+5]=e.bareFill,r[n+6]=o[i+5]}function Ua(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=_o(o.ease,Vr(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]=Do(i[c+f],i[d+f],u);r[n+5]=e.bareFill,r[n+6]=e.bareSeeks}function _t(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 Rm={keys:{stop:.15,start:.25},other:{stop:.6,start:.8}},Cc=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){Ua(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?Rm.keys:Rm.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,Nm=4,IT=class{mix;voice;area;finder;hitAt=new Float64Array(0);marks=0;markedIn=Number.NaN;missed=new Int32Array(Nm);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=KY(r)?r:null,this.checks=!yc(),this.vets=this.checks&&this.finder!==null}},KY=e=>typeof e.find=="function";function y_(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 Mm(e,t){let n=t.spec,r=qL(n.weight),o=n.within??(r!==void 0&&e.places!==null?r:void 0);o!==void 0&&(t.bound=new IT(e,t,o),o===r&&(t.bound.checks=!1))}function g_(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;b_(e,r.found,r.ring(e.x,e.y,e.r))}}}function ET(e){let t=e.mix.places;g_(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&&jY(e,r,o,t.n),e.checks&&e.frames%Em===0&&e.checkedAt!==e.frames&&(e.checkedAt=e.frames,b_(e,e.missed,$Y(e,t,o))),o}function jY(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;tr(s,`${s.spec.name??`voice ${s.id}`}'s within finder found index ${i}, which place never handed out: it is skipped`);return}}function b_(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/Nm)),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,tr(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 $Y(e,t,n){let r=x_(e,t,n),o=t.n,i=e.hitAt,s=o===0?0:e.frames/Em*Nm%o,a=0;for(let l=0;l<o&&a<Nm;l++){let u=(s+l)%o;i[u]!==r&&t.subjectAt(u)!==void 0&&(e.missed[a++]=u)}return a}function x_(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 YY(e){if(e.markedIn===e.mix.frame)return e.marks;let t=ET(e);return e.markedIn===e.mix.frame?e.marks:x_(e,e.mix.places,t)}function w_(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=YY(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 g_(t,e),r.inside(n,t.x,t.y,t.r2)}function Im(e,t,n){t>=e.litAt.length&&MT(e,t+1),e.litAt[t]!==n&&(e.litAt[t]=n,e.lit.push(t))}function MT(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 P_(e,t,n){let r=n.mix.places,o=ET(n),i=e.fills;MT(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)){Im(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 y=m*8;_t(d,y,f,h*6,i),d[y+2]!==0&&(d[y+2]=0,kt(t.records[m])),d[y+3]!==0&&Im(n,h,i)}}function CT(e,t){let n=t.mix.places,r=ET(t),o=e.fills;MT(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 OT=(e,t,n)=>e.inAt[t]===n;function FT(e,t,n,r){let o=t.data,i=n*8;_t(o,i,e.per,r*6,e.fills),o[i+2]!==0&&(o[i+2]=0,kt(t.records[n]))}function $o(e){e.detours=e.roleVoices+e.sharers.length+(e.unshared?1:0)}function LT(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 T_(e,t){t.holding!==null&&(e.owners??=[],e.owners.push(t)),QP(e,t),LT(e,t,1),$o(e)}function S_(e,t){t.named!==null&&TF(e,t),t.holding!==null&&e.owners!==null&&(e.owners=e.owners.filter(n=>n!==t)),LT(e,t,-1),$o(e)}function Yo(e){e.named=new me,e.naming=0,e.general=[],e.sharers=[],e.roleVoices=0,e.anchored=0;for(let t of e.cued)QP(e,t),LT(e,t,1);$o(e),e.steps.push(null,++e.version)}function A_(e,t){let n=_T(e,t),r=n.patch;if(DT(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:eq(e,n.owner);o&&IL(e,n,o,i),n.hits!==void 0&&mL(n.hits,r.duration),n.marks!==void 0&&bL(n.marks,r.duration),y_(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?Zi(e,n.start-e.offset):Number.isNaN(e.now)?0:e.asleep?Number.POSITIVE_INFINITY:e.now,u=new Wa(e.nextId++,n,r,n.fade??qY,a,l,e.slotOf,e.channels,e.opts.host,e.send,i);u.offset=e.offset,r===Xi&&e.fitting!==null&&(u.fitting=e.fitting),r===Xi&&e.arcing!==null&&(u.arc=e.arcing,u.hold=e.arcing.hold),i?.fitting&&I_(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),Mm(e,u),N_(e,u);let c=Ac(e,u);return u.handle=c,Xr(e)&&XY(e,c),c}var qY=Object.freeze({});function XY(e,t){Lt(e,"cue",n=>{let r=qr.voiceOf(t)??ZY(t),o=n.mix(e);o===e?k_(e,r):o!==void 0&&k_(o,QY(o,r))})}function JY(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&&!kF(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 _T(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`);tr(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 R_(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 tr(e,"the mix option loci is renamed roles; make the mix with roles"),n}function DT(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&&TT(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"&&ST(t.weight),JY(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,$P(s)):$P(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 k_(e,t){let n=t.owner;!n?.fitting&&(n===null?e.now:Te(n,e.now))>=t.start&&(t.state="live"),N_(e,t)}var v_=new WeakMap;function QY(e,t){let n=t.copy(()=>{});if(t.owner!==null){let r=jo(e,t.owner.id);(r===void 0||r.holding===null)&&Da("a cue under an owner that has left"),n.owner=r}if(n.holding!==null&&(n.holding=new Wo),n.blend!==null){let r=v_.get(e);r===void 0&&(r=new Map,v_.set(e,r));let o=n.blend.of,i=r.get(o);i===void 0&&(i=Rc(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 ZY(e){throw new Error(`blits: voice ${e.id} is paged out, and the seek that plays its cue again did not load it`)}function N_(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&&qF(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"&&Ko(e,t,t.pinned),s!==void 0&&!e.projecting&&(e.playing.set(s,(e.playing.get(s)??0)+1),e.owner??=_L(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),HF(e,t),t.sharing=e.share?.shares(e,t)===!0,T_(e,t),Kr(e,t),e.stir(),n.from==="current"&&(e.wantsPose=!0),o&&(Yr(e),!Number.isNaN(e.now)&&t.state==="pending"&&Sc(e,t)>=t.start&&Ca(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 eq(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 Cm=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 tq(e){return e.spec.as!==void 0&&e.owner===null&&e.holding===null&&e.blend===null&&e.answers===null&&e.fitting===null}function E_(e,t,n){if(!tq(t))return!1;let r=e.keys,o=nq(t,r);rr(e,"voice",t.id,void 0,[{at:t.doneAt,seq:t.doneSeq}],()=>o,n);let i=t.handle;return qr.page(i,{weight:t.weight,played:t.settled.played===!0}),e.outs.add(t.id,t.doneAt,i),e.parters.delete(t),!0}function nq(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,Yi(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,Yi(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 M_(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=_T(e,{...r(n.as),as:n.as});DT(e,o);let i=new Wa(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),qi(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:qi(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=Ac(e,i):(qr.rehome(l,i),i.handle=l),i}var rq=0;function st(){return++rq}function __(e){return e.stirred||e.anchored>0||e.pins!==null&&e.pins.size>0}function Qr(e,t){e.moving=!0;try{oq(e,t)}finally{e.moving=!1}}function oq(e,t){e.now=t,e.looked=!1,e.unshared&&(e.unshared=!1,$o(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&&uq(e,t),e.pins!==null&&e.pins.size>0&&NL(e),e.anchored>0&&Yr(e),e.announced.length>0){let i=e.opts.history===void 0?t:e.transport.keepsFrom();e.announced=e.announced.filter(s=>Zi(e,s.at)>=i)}let n=e.projecting||e.walkAll?e.cued:SF(e,t),r=null;for(let i of n)i.state!=="done"&&Oc(e,i,t,i.owner!==null&&i.owner.fitting!==null)&&(r??=[],r.push(i));let o=e.leapt===null&&r===null?null:iq(e,r,t);e.leapt=null,o===null?D_(e,r,t):sq(e,o,r,t),e.sharers.length>0&&!e.projecting&&e.share?.outgrow(e),e.stirred=!1,e.asleep=!1,e.retired.length>0&&hq(e),yq(e)}function D_(e,t,n){t!==null&&aq(e,t,n),e.owners!==null&&(G_(e,n),U_(e,n))}function iq(e,t,n){let r=null;if(e.leapt!==null)for(let o of e.leapt)r=C_(o,n,r);if(t!==null)for(let o of t)r=C_(o.owner,n,r);return r}function C_(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 sq(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=Ke(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){Yr(e);for(let i of t)Ji(i,s=>{s.state==="pending"&&s.spec.anchor!==void 0&&s.owner?.fitting===null&&Oc(e,s,r)})}D_(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),Ji(i,s=>{s.state!=="done"&&(dn(e,s,r),it(e,s))});e.lanes?.refill()}function Oc(e,t,n,r=!1){Number.isNaN(t.opened)&&(t.opened=n),(t.earlier!==null||t.later!==null)&>(e,t,n);let o=t.owner===null?n:Te(t.owner,n);if(r&&H_(t,o,n))return!0;if(t.state==="pending"&&B_(t,o,n)&&Ca(e,t,n),(t.state==="live"||t.state==="frozen")&&t.outAt<=n&&!(t.state==="live"&&!t.freezesAfter&&!t.freezesBefore&&t.endsAt()<t.outAt)&&Zr(e,t,{over:Number.isNaN(t.outOver)?void 0:t.outOver},Math.max(Uo(t),t.outAt)),t.state!=="pending"){t.turns&&cq(e,t,n),t.state==="live"&&t.out!==null&&!t.quietAt(n)&&zT(e,t,n);let s=Math.sign(t.rateAt(o))*(t.owner===null?1:HT(t.owner,n)),a=o===Number.NEGATIVE_INFINITY?o:Ke(t,o),l=s<0,u=!t.beginless&&a<=t.soonest,c=t.holding!==null&&jr(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":Zr(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&&WT(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?VT(e,t,s+a):Bn(e,t,s+a))}return e.projecting||it(e,t),!1}function B_(e,t,n){return t>e.start||t===e.start&&(e.owner===null||HT(e.owner,n)>=0)}function BT(e,t,n){return(t.earlier!==null||t.later!==null)&>(e,t,n),H_(t,Te(t.owner,n),n)}function H_(e,t,n){if(e.state==="pending")return B_(e,t,n);if(e.state!=="live")return!1;let r=e.out;if(e.fitting!==null)return r===null&&UT(e,n);if(!Number.isFinite(e.span)||r!==null&&!(r.stays===!0&&r.back===!0))return!1;let o=t===Number.NEGATIVE_INFINITY?t:Ke(e,t),i=r===null?e.span+e.latest:e.soonest;return o>i||o===i&&HT(e,n)>0}function aq(e,t,n){let r=t.length===1?t[0]:null;if(r!==null&&r.state==="pending"&&r.holding===null&&(Ca(e,r,n),!BT(e,r,n))){Oc(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)||!BT(e,u,n))continue;let c=u.state==="pending"?_n(u):u.fitting!==null?lq(u):u.out!==null?u.reaches(u.soonest):u.endsAt();(s===void 0||c<a||c===a&&F_(u)<F_(s))&&(s=u,a=c)}if(s===void 0)break;if(s.state==="pending")Ca(e,s,n),s.holding!==null&&O_(e,s,n,o,i);else if(s.out!==null)zT(e,s,n);else{i.push(s),s.fitting!==null?Fc(e,s,a):Oc(e,s,n);for(let l=s.owner;l?.fitting;l=l.owner)O_(e,l,n,o,i)}}ji(o);for(let s=0;s<o.length;s++){let a=o[s];!i.includes(a)&&a.state!=="done"&&Oc(e,a,n)}}function lq(e){return e.timeAt(e.fitting.budget)}function O_(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)&&BT(e,a,n)&&r.push(a)}}function F_(e){return(e.state==="pending"||e.out!==null?2**40:0)+e.id}function uq(e,t){e.waking=!1;for(let n of e.cued){if(!n.waking||(n.waking=!1,n.state!=="pending"))continue;_a(e,n,t);let r=n.first;r!==null&&(r.start=t,r.anchorNow=t),e.projecting||it(e,n)}}function HT(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 cq(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||(Go(t,o),t.anchorElapsed=Ke(t,o),t.ramp={from:0,to:r.to,over:t.anchorNow+r.over-o},t.anchorNow=o,je(e,t))}var dq=8,fq=32,pq=4;function hq(e){let t=e.retired;e.retired=[];let n=e.cued,r=null;if((t.length<=dq||t.length*fq<=n.length)&&!e.projecting){ji(t),r=[];for(let i=0;i<t.length;i++){let s=t[i],a=s===t[i-1]?-1:mq(n,s);if(a<0){r=null;break}r.push(a)}}let o=!1;if(r!==null){for(let i of t)o=L_(e,i)||o;if(r.length<=pq)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=L_(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")),$o(e))}function mq(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 L_(e,t){return GF(e,[t]),e.opts.history?(e.gone.push(t),rm(e,t)):(e.parters.delete(t),e.departed.add(e,t)),LL(e,t),Kr(e,t),S_(e,t),t.named===null}function yq(e){let t=e.opts.history;if(t&&e.gone.length>0)if(e.transport.pager!==null){let n=e.now-t.ms;bT(e,r=>r.reachedTo>=n||!E_(e,r,n))}else pL(e,e.transport.keepsFrom())}var Om=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??mF,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 I_(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 gq(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 GT(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={...KT(t),prev:t.later},W_(t,i),t.earlier=i.prev,o=!0;for(let i=t.later;i!==null&&r>=i.anchorNow;i=t.later)t.earlier={...KT(t),prev:t.earlier},W_(t,i),t.later=i.prev,o=!0;o&&(e.frame=st(),dn(e,t,n),je(e,t),e.lanes?.refill())}function KT(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 W_(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 bq(e,t){if(Number.isNaN(t))return 0;let n=V_(e,t);return Number.isFinite(n)?Math.max(0,n):0}function V_(e,t){let n=e.owner===null?t:V_(e.owner,t);return n===Number.NEGATIVE_INFINITY||e.state==="pending"&&!(n>=e.start)?Number.NEGATIVE_INFINITY:Ke(e,n)}function Lc(e,t){return e.state!=="pending"||e.start<t}function xq(e,t,n){return Lc(e,n)?Math.max(0,Ke(e,t)):0}function z_(e,t,n){let r=e.fitting!==null?e.fitting.end:e.arc!==null?Dc(e):e.span;return Math.max(0,r-xq(e,t,n))}function Dn(e,t,n=e.now){let r=t.fitting;if(e.projecting||t.state==="done")return;let o=bq(t,n);if(gq(t,o))return;let i=n<e.now?o:Number.NEGATIVE_INFINITY,{kids:s,floors:a,waiting:l}=wq(e,t,o,i),u=s.map((P,S)=>{let v=P.spec;return{floor:a[S],natural:z_(P,o,i)/(v.rate??1),state:Lc(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}=yF(c,u,r.fit,r.spill),{at:p,length:h}=JP(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(Lc(P,i))(A||P.rate!==v||P.ramp!==null)&&(P.earlier={...KT(P),skipped:N,prev:P.earlier},P.later=null),A&&(Go(P,o),P.rebase(o),P.anchorElapsed=P.span,P.seeks++,M=!0),(P.rate!==v||P.ramp!==null)&&(Go(P,o),ka(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),je(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),je(e,P));s.length>0&&e.lanes?.refill();let m=o+h,y=Number.isFinite(r.budget)?Math.max(0,m-r.budget):0,b=y<1e-6,x=Number.isFinite(r.budget)&&b?r.budget:m,w=r.report,g={budget:r.budget,length:m,over:b?0:y,skipped:d.skip.filter((P,S)=>P&&s[S]?.holding===null).length,fell:f};r.report=g,x!==r.end?(r.end=x,je(e,t),t.owner?.fitting&&Dn(e,t.owner,n)):(g.length!==w.length||g.over!==w.over||g.skipped!==w.skipped||g.fell!==w.fell)&&je(e,t)}function wq(e,t,n,r){let o=(t.holding?.children??[]).filter(c=>c.state!=="done"&&c.state!=="frozen"&&c.out===null&&z_(c,n,r)>0),i=o.filter(c=>Lc(c,r)),s=i.map(()=>{}),a=[],l=o.filter(c=>!Lc(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:La(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 EL(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=La(e,o,r,Number.NEGATIVE_INFINITY)??Number.NaN;return!Object.is(i,r.floorSeen)})&&Dn(e,t)}}function _c(e,t){let n=e.fitting;return n!==null&&Number.isFinite(n.budget)&&Te(e,t)<n.budget}function G_(e,t){let n=e.owners??[];for(let r=n.length-1;r>=0;r--){let o=n[r];o.out?.stays!==!0&&UT(o,t)&&Fc(e,o,o.timeAt(o.fitting.budget))}}function UT(e,t){let n=e.fitting;return n===null||e.state==="done"||!Number.isFinite(n.budget)?!1:!jr(e,t)&&Te(e,t)>=n.budget}var fn=Object.freeze([]),Pq=()=>{},K_=new WeakMap;function Tq(e,t,n){if(e.length!==1)return j_(e,t,n);let r=K_.get(t);r===void 0&&(r=new Map,K_.set(t,r));let o=e[0],i=r.get(o);return i===void 0&&(i=j_(e,t,n),r.set(o,i)),i}function j_(e,t,n){let r=e.map(o=>t.get(o));return{slots:r,lerps:r.map(o=>n[o].lerp)}}var Wa=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&&JF(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 Wo)}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===Xi?new Wo:null;let f=Tq(r.writes,a,l);this.slots=f.slots,this.named=n.subjects?new sm(n.subjects,n.stagger):null,this.latest=this.named?.latest??0,this.soonest=this.named?.soonest??0,this.built=r.form==="keys"&&r.keys?iL(r):null,this.lerps=f.lerps,this.intos=this.built?oL(this.built,this.slots.map(y=>l[y])):void 0,this.ease=o.ease===void 0?void 0:Bo(o.ease),this.passes=qO(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 fm(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?Ke(this,t):YF(this,this.owner,t)}timeAt(t){let n=Cn(this,t);return this.owner===null?n:Vo(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&&lm(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?mc(this,t):Cn(this,t);return this.owner===null?n:Vo(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&&qt(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!jr(this,t)&&!_c(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&&lm(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=mc(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&&lm(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 Qh(t),i.setting={...this.setting,keep:hT(o),send:Pq},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 Sa(this,t)}rebase(t){KP(this,t)}};function $_(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)||tr(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 Va(e,t,n){return e[jT(e,t,n)]}function jT(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 Bc(e,t){let n=0,r=e.length-1,o;for(;n<=r;){let i=n+r>>1,s=e[i];qt(t,s.seq,s.sync)?(o=s,n=i+1):r=i-1}return o}function Y_(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(!Y_(e[o],t[o]))return!1;return!0}function $T(e,t,n){let r=t.log,o=r===null?void 0:Va(r,n,!0);return Ke(o??t,t.owner===null?n:Sq(e,t.owner,n))}function Sq(e,t,n){return $T(e,t,n)}function je(e,t){Ia(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&&rr(e,"controls",t.id,void 0,n.splice(0,o),kq,r)}var kq=e=>({...e}),vq=Object.freeze([]);function q_(e,t){let n=X_(e,t);return n===0?vq:e.splice(0,n)}function X_(e,t){let n=0;for(;n+1<e.length&&e[n+1].at<=t;)n++;return n}function za(e,t){let n=e.patch;return n.clone?n.clone(t):bt(t)}function qo(e,t,n=!1){let r=J_(t);return Ka({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:za(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 J_(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 YT(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:za(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=J_(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,Ka(n)}function Ka(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 Q_(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&&Y_(r.fields,s))return;n.push({at:t,seq:o,fields:s});let a=t-e.opts.history.ms;rr(e,"host",void 0,void 0,q_(n,a),l=>l.fields,a)}function Fm(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=q_(s,l);u.length>0&&rr(e,"input",t.id,e.keys?.key(n),u,c=>c.value,l)}function Hc(e){return e.every??200}function Aq(e,t,n,r){let o=t.spares?.pop()??r;return o===void 0?{at:e.now,seq:e.transport.seq,held:qo(t,n)}:(o.at=e.now,o.seq=e.transport.seq,YT(t,n,o.held),o)}function Pm(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<Hc(o))return;let a=e.now-o.ms,l=X_(i,a),u;l>0&&(e.transport.pager!==null&&rr(e,"snap",t.id,e.keys?.key(n),i.slice(0,l),c=>Yi(t,c.held),a),u=Rq(i,l),l===1?i.shift():i.splice(0,l)),i.push(Aq(e,t,r,u))}function Rq(e,t){for(let n=0;n<t;n++){let r=e[n];if(!r.shared)return r.ahead=void 0,r}}function Lm(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=>rr(e,"left",t.id,a.key(l.subject),[l],u=>[Yi(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 _m(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 UL(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){WT(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 Z_(e,t,n){let r=e.parts?.get(t);if(r===void 0)return 1;let o=this.reducedNow,i=Ta(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=zh(s,l,e.ease,n,a,e.stalls);return u>0?i*(zh(s,l,e.ease,n,a,e.stalls,r.at)/u):i}function WT(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),eD(e,t,n);let i=t.motion;i!==void 0&&tD(e,i,t)&&i.release(n,..._m(e))}function vT(e,t,n){if(t.parted?.has(n)!==!0)return;t.subjects.get(n)===void 0&&qT(e,t,n),eD(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 qT(e,t,n){let r=t.subjects.get(n);r!==void 0||t.parted?.has(n)!==!0?Lm(e,t,n,r):Lm(e,t,n,t.unreached??e.unreachedOf(t,e.now))}function Dm(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 eD(e,t,n){let r=ut(e,n);r!==void 0&&r.slot>=0&&($r(t,r.slot,!1),e.share?.unsight(t,r.slot));let o=t.subjects.get(n);o!==void 0&&(Lm(e,t,n,o),t.subjects.delete(n),o.reaches&&t.seen--,Ho(o)&&t.restedCount--,t.holder===o&&(t.holder=null)),r!==void 0&&(bc(e,r),t.laned&&r.slot>=0&&e.lanes?.part(t.id,r.slot),e.lanes?.refill())}function Zr(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&&Kr(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),je(e,t),n.at==="rest"||n.back||i?e.lanes?.invalidate():e.lanes?.refill(),o===0&&n.at!=="rest"&&(n.stays?VT(e,t,t.out.at):Bn(e,t,t.out.at))}function VT(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;jr(r,o)||_c(r,n)?r.fitting!==null&&!t.skipped&&Dn(e,r,n):Fc(e,r,n)}function Fc(e,t,n){t.owner!==null&&t.state==="live"&&e.opts.history!==void 0?Zr(e,t,{over:0,stays:!0},n):Bn(e,t,n)}function WL(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,je(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&&Kr(e,t),je(e,t),l?e.lanes?.invalidate():e.lanes?.refill()}function VL(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){Zr(e,t,{over:r},Math.max(Uo(t),n)),e.stir();return}t.outAt=n,t.outOver=r??Number.NaN,t.outSet=!0,je(e,t)}function zT(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,je(e,t),e.lanes?.refill()}function tD(e,t,n){return t.owner===e.owner&&t.ownerId===n.id}function Nq(e,t){t.owner.holding.left(t.passed?Qe(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&&tD(e,r,t)&&(r.owner=null),t.state="done",Ia(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;Nq(e,t);let s=XF(t,o);s!==null&&!_c(s,t.doneAt)?Bn(e,s,t.doneAt):i.fitting!==null&&i.state!=="done"&&!t.skipped&&Dn(e,i,t.doneAt)}}var Iq=["enter","active","exit"],JT=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 rD(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 nD(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 tL(e,t,n,r){let o=e.arc,i=Te(e,n);if(!(i>=0))return 0;let s=rD(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=nD(u[0],u[1],a,l,i);if(c<=0)return 0;let d=0;for(let f of s)f!==null&&(d+=nD(f[0],f[1],a,l,i));return d>1?c/d:c}function Eq(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 XT=e=>e===void 0?void 0:Array.isArray(e)?e:[e];function oD(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=[XT(n),XT(r),XT(o)],u=l.map(m=>m===void 0?0:Eq(m));for(let m of[0,2])if(!Number.isFinite(u[m]))throw new Error(`blits: an arc's ${Iq[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 JT(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,y)=>{for(let b of m??[]){let{duration:x,...w}=b,g={...w,owner:p,start:h[y],freeze:"both"};y===1&&i!==void 0&&b.loop===void 0&&(g.loop=!0),e.cue(g),e.cued[e.cued.length-1].part=y}}),p}function zL(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"&&_a(e,s,i);Mq(e,t)}}function Mq(e,t){je(e,t),t.owner?.fitting&&Dn(e,t.owner),e.lanes?.refill()}function U_(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),Bn(e,n,l);continue}let s=rD(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 vL(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 iD(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 sD(e,t,n,r,o){let i,s=pe.back;if(s!==null)i=(im(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:Zn(u,0);for(let f=0;f<u;f++)d[f]=a[f];return l[t]=d,l}var aD=Ra;function lD(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 Cq(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 uD(e,t,n){return e<0?JO(e,t):Ur(e,t,n)}var Oq=Object.freeze({});function cD(e,t,n,r){if(r.weight=0,!r.reaches)return null;let o=e.bound!==null&&r.replay===void 0&&!w_(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&&Ho(r))return null;r.rebuilt!==e.rebuilds?lD(this,e,t,n,r):r.seeks!==e.seeks&&Cq(this,e,r)&&(lD(this,e,t,n,r),gT(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=er(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&&Fm(this,e,t,r,0),pe.kept!==h&&!e.keeping&&ts(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 y=pe.kept,b=this.opts.history;if(b?.inputs&&e.patch.reads!==void 0&&!this.projecting&&Q_(this,n),e.motion!==void 0&&(pe.horizon=this.horizonFor(e,r.delay,n)),e.patch.step&&r.probed!==n){let g=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(g))S&&QT(e,r);else{r.stepped<r.since&&(r.stepped=r.since,p.dt=this.capped(n-r.since));let v=Lo(this,e);v!==void 0&&S&&Fq(this,e,t,r,P,v,g),S&&QT(e,r),v!==void 0?this.tick(e,t,r,v,g):(u===0?n!==r.stepped:g>r.stepped)&&(u!==0&&(p.dt=this.capped(g-r.stepped)),e.patch.step(r.state,p.dt,t,p),r.stepped=g)}}let x=null,w=!1;if(jh(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=uD(l,c,e.passes),x=this.keyed(e,t,r);else if(e.motion!==void 0)x=sD(e.motion,e.patch.writes[0],t,p,r);else{let g=uD(l,c,e.passes);x=e.patch.at(g,t,p),e.unchecked&&$_(e,x)}return r.delta=x,r.probed=n,r.seeks=e.seeks,b!==void 0&&Pm(this,e,t,r),pe.kept!==y&&!e.keeping&&ts(this,e),x===null?w?(this.w=m,Oq):null:e.out?.rest&&this.isRest(x)?(r.weight=0,r.restedAt=n,e.restedCount++,null):(this.w=m,x)}function dD(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=dm(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 fD(e,t,n){return Math.floor((n-e.since)/t+1e-9)}function Fq(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=fD(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=za(t,l.state),t.setting.state=r.state,r.ticks=l.ticks);let h=p?l.at:a.at;!(d<s)||d-h<Hc(e.opts.history)||(QT(t,r),e.tick(t,n,r,i,d),l.state=za(t,r.state),l.ticks=r.ticks,l.at=d)}function QT(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=za(e,t.state),e.setting.state=t.state)}function pD(e,t,n,r,o){let i=this.now,s=e.setting,a=s.dt,l=n.ticks,u=fD(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 hD(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]=aD(s):a!==void 0&&(r[o]=aD(a))}return r}function mD(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 yD(e){for(let t of Object.keys(e)){if(e[t]===void 0)continue;let n=this.kit[t];if(n.rest===void 0||!Ic(e[t],n.rest))return!1}return!0}function gD(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=er(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 bD(e){this.frame=st();let t=ut(this,e);t!==void 0&&bc(this,t);let n=this.chains.get(e)?.slot??-1;n>=0&&this.lanes!==null&&this.lanes.release(n),this.projecting&&!(this.lastPoses instanceof xc)&&(this.lastPoses=new xc(this.lastPoses)),this.projecting||this.places?.drop(e),this.lastPoses.delete(e),this.restStamps?.delete(e),this.chains.delete(e),this.stir();let r=_m(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=zo(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);Xr(this)&&this.recordDrop(e)}function xD(e,t,n){qT(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 wD(e,t,n){this.projecting?e.holds(t)&&Da("a drop of a subject a motion patch holds"):e.release(t,n[0],n[1],n[2],n[3])}function PD(e){Lt(this,"drop",t=>t.mix(this)?.drop(e))}var Lq=Symbol("unread");function ZT(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 _q(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 TD(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]=Ra(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 SD(e,t,n){let r=Bq(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(Lq);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,y=m?Number.POSITIVE_INFINITY:h&&e.pulledVersion===f?e.pulledRelinks:-1;try{Dq(e,l,r,h,m,y,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 Dq(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 y=t[m],b=-1;if(r)if(o&&c[m]===y)b=f[m];else{let S=d[m],v=c[m]===y&&S!==void 0&&S.version===p?S:e.chain(y);c[m]=y,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,y,v,A)){for(let N=c.indexOf(y);N>=0;N=c.indexOf(y,N+1))f[N]=A;b=A}f[m]=b}let x=r&&a?.prepare(b,y,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,g=e.foldWith(y,u,w,x,!1),P=e.bounded.length===0?g:e.clamp(g);e.keep(y,P,u);for(let S of n)_q(S,P[S.key],m)}}function Bq(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=$O(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&&ZT(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 kD(e){e.pulled=[],e.pulledHeads=[],e.pulledSlots=new Int32Array(0),e.pulledVersion=Number.NaN,e.pulledRelinks=-1}function AD(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,y=e.unlinked,b=e.holds,x=e.owed.any(),w=o===Number.POSITIVE_INFINITY;ND(e,s,t),ID(e,e.queued+n.length-i);let g=i,P=-1,S=i;for(;g<n.length;g++){let v=n[g];if(r[g]!==v)break;let A=t[g],N=A*6;if(A<0||!w&&!(y[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+(g-S)&&(P>=0&&t1(e,P,S,g-S),P=A,S=g)}return P>=0&&t1(e,P,S,g-S),g>i&&b&&(e.holding=!0),g}function RD(e,t,n,r,o){ND(e,n,o),t1(e,t,r,1)}function ND(e,t,n){t===e.queuedFor&&n===e.queueFrom||(rs(e),e.queuedFor=t,e.queueFrom=n)}var vD=16;function t1(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<vD&&(a<0||s<vD)){e.queueSlots[i]=-1,e.queueCounts[i]=s+r;return}}}ID(e,o+1),e.queueSlots[o]=t,e.queueRows[o]=n,e.queueCounts[o]=r,e.queued=o+1}function ID(e,t){if(t<=e.queueSlots.length)return;let n=Math.max(64,t,e.queueSlots.length*2);e.queueSlots=e1(e.queueSlots,n),e.queueRows=e1(e.queueRows,n),e.queueCounts=e1(e.queueCounts,n)}function e1(e,t){let n=new Int32Array(t);return n.set(e),n}function rs(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?Hq(e,o,t):Uq(e,o,i.values,t),o.bounds!==void 0)for(let s=0;s<t;s++)ZT(o.out,e.queueRows[s]*o.axes,e.queueCounts[s]*o.axes,o.bounds)}}}function Hq(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 Gq=256;function Uq(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],y=m+s[c];if(l===1)for(let b=m;b<y;b++)a[b]=n[u[b]];else for(let b=m;b<y;b++){let x=b*l,w=u[b]*l;for(let g=0;g<l;g++)a[x+g]=n[w+g]}continue}let f=i[c]*l,p=d*l,h=s[c]*l;if(h>Gq)a.set(n.subarray(p,p+h),f);else for(let m=0;m<h;m++)a[f+m]=n[p+m]}}function CD(e,t){this.copier===null&&(this.copier=Wq(this.laned)),this.copier(t,e)}function OD(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 ED=new Map,MD=!1;function Wq(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=ED.get(n);if(r===void 0&&!MD){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
|
+
};`),ED.set(n,r)}catch{MD=!0}}return r===void 0?(o,i)=>Vq(e,o,i):r(e,OD)}function Vq(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=OD(o,n,s);a!==s&&(t[o.name]=a)}}}function zq(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 Kq=60;function jq(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>=Kq&&o1(e,r)}}function $q(e,t){if(t.everyone!==null)return t.everyone;let n=e.sinceOf(t,0);if(!(n<=e.now))return o1(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 n1(e,t){let n=e.sighted,r=t>>>5;return n!==null&&t>=0&&r<n.length&&(n[r]&1<<(t&31))!==0}function FD(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 r1(e,t){let n=e.weights;return n!==null&&t>=0&&t<n.length?n[t]:0}function Bm(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 ja(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 Gc(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 Yq(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 LD(e,t,n,r){if(n1(e,t)){let a=e.seen;FD(e,n,r),e.seen=a}let o=r1(e,t);(o!==0||e.weights!==null&&n<e.weights.length)&&Bm(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}Hm(e,t)}function Hm(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 o1(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||n1(t,s))?(s>=0&&Hm(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,$o(e),e.lanes?.refill()}function qq(e,t,n){t.weight=r1(e,n),ja(e,t,n),Hm(e,n)}var _D={shares:zq,outgrow:jq,everyoneOf:$q,sighted:n1,sight:FD,weightAt:r1,weighAt:Bm,open:ja,shut:Gc,restamp:Yq,unsight:Hm,unshare:o1,inherit:qq};function Ya(e,t){return e-t*Math.round(e/t)}var $a=Zn(4,0),i1=Zn(4,0);function s1(e,t,n,r){let o=r.length===n?r:Zn(n,0);for(let i=0;i<n;i++)o[i]=e[t+i];return o}function Gm(e,t,n,r,o){if(e.turn>0){t[n]=t[n]+Ya(r,e.turn)*o;return}let i=e.axes;$a=s1(t,n,i,$a);let s=e.channel.fold($a,r,o);for(let a=0;a<i;a++)t[n+a]=s[a]}function DD(e,t,n,r,o,i){if(e.turn>0){Gm(e,t,n,r[o],i);return}i1=s1(r,o,e.axes,i1),Gm(e,t,n,i1,i)}function BD(e,t,n,r,o,i){if(e.turn>0){let l=t[n],u=r;t[n]=o===0?u:l+Ya(u-l,e.turn)*i;return}let s=e.axes,a=r;(o!==0||a.length!==s)&&($a=s1(t,n,s,$a),a=e.channel.lerp($a,r,i));for(let l=0;l<s;l++)t[n+l]=a[l]}function HD(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 Uc(e,t){if(e.length>=t)return e;let n=new Float64Array(t);return n.set(e),n}function GD(e,t){let n=e.cap;t.met.length<n&&(t.met=Uc(t.met,n),t.first=Uc(t.first,n),t.sum=Uc(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]=Uc(o,n*s)),i!==void 0&&(t.taken[r]=Uc(i,n))}if(t.inline=Xq(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&&CT(e,s);let a=e.fills;for(let l=0;l<i.length;l++){let u=i[l];if(s!==null&&!OT(s,u,a)){FT(e,r,l,u);continue}if(e.one(r,l,u)&&(Wm(e,t,u),t.sum[u]=t.sum[u]+r.data[l*8+2]),o.keeping)break}}}finally{e.into=null}}}function Wm(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 Um(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){UD(e,t,n,r,i);return}let l=o[0];Wm(e,t,r);let u=a[r],c=u+l;s[r]=u===0?i:Ft(s[r],i,l/c),a[r]=c}function UD(e,t,n,r,o){let i=e.arg[0];Wm(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)BD(n,a,r*n.axes,o,u,d);else if(n.scalar)a[r]=u===0?o:Ft(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:Ft(a[p+h],m,d)}}l[r]=c}function WD(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&&VD(e,n,a)}}function VD(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){DD(a,u,c,l,c,s);continue}for(let d=0;d<a.axes;d++)u[c+d]=Fe(a.op,u[c+d],l[c+d],s)}}function Xq(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 zD(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&&CT(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&&!OT(d,a,o)){FT(e,c,s,a);continue}r[6]=c.mark,e.one(c,s,a)&&(Wm(e,t,a),l+=c.data[s*8+2])}l>0&&VD(e,t,a)}}finally{e.into=null}}function KD(e,t){let n=e.chans;for(let r=0;r<n.length;r++)e.values[r]=t[n[r].name]}function jD(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]=Fe(i.op,l[t],s,o[0])}else o[7]=s,Um(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]=Fe(i.op,l[t],s,o[0])}else o[7]=s,Um(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]=Fe(i.op,l[t],s,o[0])}else o[7]=s,Um(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]=Fe(i.op,u[t],a,o[0])}else o[7]=a,Um(this,l,i,t)}else this.foldInto(i,t,a)}}function YD(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]=Fe(e.op,o[i+s],n[s],r)}function qD(e,t,n){if(n===void 0)return;if(this.into!==null){UD(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]=Fe(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]=Fe(e.op,o[i+a],l,r)}}function XD(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 JD(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]+Ya(n,e.turn)*r:Gm(e,o,t*e.axes,n,r),!1}function QD(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,y=n.freezesAfter,b=n.span,x=n.hidesPast,w=t.flat,g=n.parts!==null,P=Wr(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(_t(r,C,o,M*6,c),d>=0&&e.unread(M))continue;let F=f-r[C+0],D=F>b&&x?Number.NaN:Kh(F,m,y,b);if(!(D>=0)){r[C+2]=0,kt(s[N]);continue}if(!w){let W=r[C+1];(!t.weighed||!$t(W,t.weighedSince))&&(t.fade=e.host.envelope(n,W),t.weighed=!0,t.weighedSince=W)}let B=w&&!g?P:Yt(n.weight,t.fade,e.parting(n,M));if(r[C+2]=B,(!t.read||!$t(D,t.readAt))&&(e.readKeyed(n,Ur(D,p,h),t.delta,t.scratch),t.read=!0,t.readAt=D,e.gather(t,t.delta),Jq(a,l,v,A)),!(B>0)){kt(s[N]);continue}let K=0;for(let W=0;W<u;W++){let Q=a[W],le=Q.axes,ke=A[W];if(ke===1){let ue=Q.values,ve=M*le;for(let G=0;G<le;G++)ue[ve+G]=Fe(Q.op,ue[ve+G],v[K+G],B)}else ke===2&&(e.folding=t,e.rec=s[N]??null,e.arg[0]=B,e.foldInto(Q,M,l[W]));K+=le}}}function Jq(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]=Qq(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 Qq(e,t,n,r){return e.turn>0?(n[r]=Ya(t,e.turn),1):2}var Vm=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 ZD(e,t,n,r){let o=Hn(e,t);return o!==null&&o.crowd===n&&o.row===r}function Zq(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 eB(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&&Xt(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){nX(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&&Xt(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=eX(e,t);if(f||Zq(e,t))return tX(e,t,n,f)||e.owed.owe(t,e.met,e.metN),!0}return e.per[d+0]=e.fills,!1}function eX(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 tX(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;ja(c,f,t),e.one(u,d,t),c.keeping||Gc(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 nX(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&&Xt(e,n,1),!0}function Xt(e,t,n){let r=t*6+2;e.per[r]=e.per[r]+n}var rX=ja,oX=Gc,iX=0;function sX(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 l1(e,t,n){rs(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?tB(e,u):d===1&&u.motion===void 0?u.idle||nB(e,u):(u.idle?a>=c.start:a<c.stop)&&a1(e,u)}u.idle||(l=!0)}for(let u of e.crowds)s&&(u.size>=64?tB(e,u):(u.idle?a>=u.line.start:a<u.line.stop)&&a1(e,u)),u.cursor=0,u.stale&&h_(u),!u.idle&&u.size>0&&(l=!0);if(l){for(let u of e.laned)HD(u,i);for(let u of e.roles)GD(e,u);for(let u of e.lanes)u.idle||(e.crowds.length>0&&(e.arg[6]=Number.NaN,NT(e,u.voice.id)),e.run(u));e.crowds.length>0&&(e.arg[6]=Number.NaN,NT(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 tB(e,t){let n=t.list,r=t.line,o=e.lastFrom,i=e.lastTo,s=sX(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)&&a1(e,t)}function a1(e,t){t.idle?u1(e,t):nB(e,t)}function nB(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||(Xt(e,i,1),_t(r,o*8,e.per,i*6,e.fills))}}function u1(e,t){t.idle=!1;for(let n of t.list)n>=0&&Xt(e,n,-1)}function rB(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===or?(r[0]=0,!0):(this.host.signal(e,i,n,t),r[0]=Yt(r[0],o,e.parts===null?1:this.host.parting(e,i)),!0)}function oB(e,t){if(e.parts===null)return 1;let n=this.subjectAt(t);return n===or?1:this.host.parting(e,n)}function iB(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 sB(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 aB(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]&&zD(this,n):WD(this,e,n);return}if(this.reset(e),e.ran=this.fills,e.motion!==void 0&&!t.keeping){c_(this,e,e.motion);return}if(t.built!==null&&typeof t.spec.weight!="function"){QD(this,e);return}e.elapsedNow=t.elapsedAt(this.now);let r=e.list;if(t.sharing){this.runEveryone(e);return}if(t.bound!==null){P_(this,e,t.bound);return}for(let o=0;o<r.length;o++)if(this.one(e,o,r[o]),t.keeping)return}function lB(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(rX(t,n,s),this.one(e,i,s),t.keeping)return;oX(t,n,s,o)}}function uB(e,t,n){let r=this.host,o=e.voice,i=e.elapsedNow,s=this.arg,a=e.data,l=t*8;if(_t(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||!$t(d,e.placedAt))&&(e.placed=!0,e.placedAt=d,e.phase=Ur(d,o.duration,o.passes),e.pass=er(d,o.duration,o.passes),s[6]=++iX,e.mark=s[6]);let f=a[l+1];!e.flat&&(!e.weighed||!$t(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=Yt(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||!$t(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?(Ec(this,e,e.motion,t,n,h),!0):(s[2]=e.phase,s[3]=e.pass,this.call(o,e.chans,h,n)))}function cB(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=pT(l,uT(l,r,i.duration),void 0);if(c===cm)continue;if(c===Ma){this.foldInto(u,n,He.a);continue}let d=He.a,f=He.b,p=He.eased;if(u.scalar||!u.plain||!u.straight){this.foldInto(u,n,e.lerps[a](d,f,p));continue}let h=d,m=f,y=u.values,b=n*u.axes,x=u.rest;for(let w=0;w<u.axes;w++){let g=Ft(h[w]??x,m[w]??x,p);y[b+w]=Fe(u.op,y[b+w],g,o)}}}function dB(e,t,n,r){dm(e.built,t,n,void 0,e.lerps,void 0,e.intos,r)}function fB(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===or)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(jh(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 zm=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 aX(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 d1(e,t,n){let r=t.list[n];r>=0&&(t.idle&&Xt(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 pB(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 hB(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")&&gB(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);f1(e,i,s?.crowd,s?.row,r)}e.crowds.length===0&&(e.lawsByKey.clear(),e.lastLaw=null)}function f1(e,t,n,r,o){let i=t.slots.map(u=>e.bySlot[u]),s=e.crowds.find(u=>aX(u.chans,i));if(s===void 0){s=new km(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?mB(n,r,s,a):uX(e,s,a,t),s.hot[a*s.stride+6]===0&&t.state!=="pending"&&(s.hot[a*s.stride+6]=jm(e,t));let l=new Vm(e,s,a,n===void 0?e.probes:0);e.seats.set(t.id,l),t.seat=l,t.laned=!0}function p1(e,t,n,r){let o=n*t.stride;t.hot[o+6]===0&&r.state!=="pending"&&(t.hot[o+6]=jm(e,r)),t.hot[o+0]=t.hot[o+0]|64}function h1(e){for(let t of e.crowds)t.dead>64&&t.dead*4>=t.size&&lX(e,t)}function lX(e,t){let n=t.keys;t.keys=new Ga;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?(mB(t,o,t,r,n),t.odd?.delete(o),s.row=r):yB(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 m1(e,t,n){let r=t.voices[n];gB(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 c1(e,t,n,r,o){for(let i=0;i<o;i++)n[r+i]=e[t+i]}function mB(e,t,n,r,o=e.keys){e.fix(t),n.list[r]=e.list[t],c1(e.data,t*8,n.data,r*8,8),c1(e.hot,t*e.stride,n.hot,r*n.stride,e.stride),yB(o,n,r),(e.hot[t*e.stride+0]&4)!==0&&(n.stale=!0,n.staleRows.push(r)),c1(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 yB(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 uX(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]=f_,t.eases[n]=void 0;return}t.laws[n]=cX(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 cX(e,t){let n=e.lastLaw;if(n!==null&&t.hasLaw(n))return n;let r=dX(e,t);return e.lastLaw=r,r}function dX(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 gB(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&&Xt(e,r,-1);let a=y1(e,t,n,r);o!==void 0&&a!==void 0&&(o.weight=a),o!==void 0&&t.motions[n]!==void 0&&Mc(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 y1(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 bB(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 $m(e,t){rs(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));xB&&pX(o,s,n.channels);let a=()=>o.map((h,m)=>({id:h.id,fits:s[m],slots:h.slots})),{channels:l,voices:u}=bB(i,a());for(let h=!0;h;){h=!1;let m=new Map;o.forEach((y,b)=>{let x=y.spec.role;if(x===void 0)return;let w=m.get(x);w===void 0?m.set(x,[b]):w.push(b)});for(let y of m.values()){let b=y.filter(x=>u.has(o[x].id)).length;if(!(b===0||b===y.length)){for(let x of y)s[x]=!1;h=!0}}h&&({channels:l,voices:u}=bB(i,a()))}for(let h of e.lanes)u.has(h.voice.id)||wB(e,h);let c=[],d=0;for(let h of o){if(!u.has(h.id))continue;if(ns(h)){d++;continue}let m=e.byId.get(h.id);m===void 0&&(m=new Cc(h),m.made=e.probes),h.laned=!0,m.epoch===0&&h.state!=="pending"&&x1(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 y=f.get(m);y===void 0&&(y={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,y),e.roles.push(y)),y.members.push(h),h.group=y}for(let[h,m]of f)m.contiguous=xX(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)&&ns(h));if(hX(e,l)&&pB(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 y=h.voices[m];ZD(e,y,h,m)&&y.state==="done"&&m1(e,h,m)}for(let h of r){if(h.state==="done")continue;let m=Hn(e,h);m!==null&&p1(e,m.crowd,m.row,h)}h1(e);return}e.laned=[],e.copier=null,e.bySlot=n.channels.map(()=>{}),l.forEach((h,m)=>{if(!h)return;let y=n.channels[m],b=Qn(y),x=y.rest??Number.NaN,w=typeof x=="number"&&b.axes===1,g=b.folds??b.op,P={name:n.names[m],op:g,plain:g!=="last"&&g!=="own"&&b.turn===void 0,straight:b.folds===void 0,turn:b.turn??0,channel:y,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(()=>{});hB(e,p)}var xB=!0;function g1(e,t){return e.built===null&&e.motion===void 0&&e.slots.every(n=>fX(t[n]))}function fX(e){return Array.isArray(e.rest)&&Qn(e)?.op!=="last"}function pX(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=ns(i);if(g1(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]&&g1(i,n)&&!i.slots.some(a=>r[a])&&(t[s]=!1)})}function hX(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 jm(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 b1(e){let t=ji(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"){m1(e,s.crowd,s.row);continue}p1(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(!bX(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||xB&&ns(o)&&g1(o,e.host.channels))){e.whole=!1;continue}if(i||!u||!l||o.slots.some(c=>e.bySlot[c]===void 0))return r();ns(o)?f1(e,o,void 0,void 0,e.crowds):gX(e,o)}return h1(e),e.lanes.length===0&&e.crowds.every(o=>o.dead===o.size)&&(e.subjects=[]),!0}function x1(e,t){let n=t.voice;t.epoch=jm(e,n),n.named===null&&n.spec.target===void 0&&(t.reserve(e.live,e.cap),mX(e,t)&&yX(e,t))}function mX(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 yX(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&&Xt(e,i,1));t.every=!0}function gX(e,t){let n=new Cc(t);n.made=e.probes,t.laned=!0,t.state!=="pending"&&x1(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 bX(e,t){let n=t.voice;if(n.state!=="done")return t.epoch===0&&n.state!=="pending"&&(x1(e,t),n.named===null&&e.dense.push(t)),!0;if(t.group!==null)return!1;wB(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 wB(e,t){t.idle&&u1(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?Bm(t.voice,s,a,e.cap):i.weight=a),i!==void 0&&t.motion!==void 0&&Mc(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 xX(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 TB(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)mT(u,i,r),LD(u,i,r,l),PB(e,u,i,r);for(let u of zo(e).general)mT(u,i,r);for(let u=n;u!==null;u=u.next)u.voice!==null&&PB(e,u.voice,i,r);return n.slot=r,!0}function PB(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 Wc=class{host;static share=_D;pulls={pullRun:AD,writeLater:RD,flush:rs,renumber:TB};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 zm;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 om(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&&Xt(this,n,-1),r.remove(n);return}let o=this.seats.get(t);o!==void 0&&o.crowd.list[o.row]===n&&d1(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:y1(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=eB(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&&b1(this)?this.qualifiedVersion=n:$m(this,n):this.touched.length>0&&!b1(this)&&$m(this,n),this.laned.length===0))return 0;if(!this.current(t,n)&&(l1(this,t,n),this.qualifiedVersion!==n)){if($m(this,n),this.laned.length===0)return 0;l1(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&&Im(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?d1(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!==or&&(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}},wX={copy:CD,row:p_,signalled:rB,parting:oB,subjectAt:iB,reset:sB,run:aB,runEveryone:lB,one:uB,foldKeys:cB,readKeyed:dB,call:fB,gather:KD,fold:jD,foldDelta:$D,foldRun:YD,foldInto:qD,gate:XD,unplain:JD};for(let[e,t]of Object.entries(wX))Object.defineProperty(Wc.prototype,e,{value:t,writable:!0,configurable:!0});var qm=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 y=t[2*m],b=t[2*m+1];y<r&&(r=y),y>i&&(i=y),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 y=SB(t,m,r,o,a,u);this.home[m]=y,y>=0&&(f[y+1]=f[y+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 y=SB(t,m,r,o,a,u);if(y<0)continue;let b=f[y+1]-1;f[y+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,Ym((t-r-this.x0)/i,-1)),a=Math.min(this.cols-1,Ym((t+r-this.x0)/i,1)),l=Math.max(0,Ym((n-r-this.y0)/i,-1)),u=Math.min(this.rows-1,Ym((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 y=f[m*this.cols+s],b=f[m*this.cols+a+1];for(let x=y;x<b;x++){let w=d[x];if(p&&this.stray[w]===1)continue;let g=c[2*w]-t,P=c[2*w+1]-n;g*g+P*P<=o&&(h=this.push(w,h))}}for(let m of this.strays){let y=c[2*m]-t,b=c[2*m+1]-n;y*y+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 y=this.x0+m*o-t,b=this.y0+h*o-n;if(Math.max(y*y,(y+o)**2)+Math.max(b*b,(b+o)**2)<=s)continue;let w=h*this.cols+m;for(let g=this.starts[w];g<this.starts[w+1];g++){let P=this.order[g];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,y=f[2*h+1]-n,b=m*m+y*y;b>s&&b<=a&&(p=this.push(h,p))}return this.count=p,p}};function SB(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 Ym(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 Xm=class extends qm{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 kB(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}`);AB(this).set(e,t,n??Number.NaN),this.moved()}function vB(e){return AB(this).place(e)}function AB(e){if(e.places!==null)return e.places;let t=new Xm(n=>e.chains.get(n)?.slot??-1,!yc());e.places=t;for(let n of e.cued)n.bound===null&&Mm(e,n);return t}function RB(){this.places!==null&&(this.places.dirty=!0),this.lanes?.refill(),this.stir()}function NB(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 Jm=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 Qm=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 Ke(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:Ke(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:Sa(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}ka(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 Zm=e=>({t:Number.NaN,seq:0,up:null,rank:0,left:null,cut:null,of:e}),IB=Zm(null);function PX(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 Vc=class extends me{own;now;make;stamp=Zm(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(Zm(this))}return this.ready.pop()??Zm(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=PX(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=IB),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=IB),this.own.delete(t)}clear(){this.sure=!1,this.own.clear(),this.at.clear()}};function qa(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 wc(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 wc(i,"voice",t)}return n.loaded=null,TX(e,r.records),e.floor=r.t,!0}function ey(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)qa(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 qa(e,n.at),n}function MB(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 TX(e,t){SX(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)kX(o,i)}function SX(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(zc(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 kX(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=M_(e,s.voice,s.data);n.set(a.id,a),e.gone.push(a),rm(e,a)}let r=t.filter(s=>s.stream==="host");e.hostLog=zc(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&&vX(l,a,i)}}function vX(e,t,n){let r=s=>t.filter(a=>a.stream===s);e.log!==null&&(e.log=zc(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:qi(e,u),ramp:d,parted:f})}s.sort((a,l)=>a.seq-l.seq),e.left=Fn.from(s)}for(let[s,a]of w1(r("snap"))){let l=n.subject(s);for(let[u,c]of EB(e,l,a))u.snaps=zc(c.map(d=>({at:d.at,seq:d.seq,held:qi(e,d.data)})),u.snaps??[])}for(let[s,a]of w1(r("input"))){let l=n.subject(s);for(let[u,c]of EB(e,l,a))u.inputs=zc(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 w1(r("stretch")))i.restretch(n.subject(s),a)}}function w1(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 EB(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 zc(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 AX(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?Ka(n):qo(t,n);return P.stepped>s&&(P.stepped=s),CB(P,n,s),P.weight=0,P.inputs=a,P.since<=s||Oa(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:jT(l,s,!0);if(c<0)return;let d=l[c],{ticks:f,since:p,rebuilt:h,state:m,slot:y,restored:b}=n,x;i&&n.reaches?(x=YT(t,d.held,n,!0),x.slot=y,x.restored=b):x=qo(t,d.held,!0),x.weight=0,CB(x,n,s),d.at<s&&(x.copied=!0);let w=c+1;if(i)RX(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||Oa(e,t,x);let g=i&&f>x.ticks&&p===x.since&&h===x.rebuilt;if(t.patch.step!==void 0&&(d.ahead!==void 0||s-d.at>=o||g)){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),g&&(P.leftTicks=f,P.left=m)}return x}function CB(e,t,n){e.restedAt=t.restedAt<=n?t.restedAt:Number.NaN}function RX(e,t,n){for(;t.length>n;){let r=t.pop();r.shared||(r.ahead=void 0,e.spares??=[],e.spares.push(r))}}function NX(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 IX(e,t,n,r){let o={seq:r,strict:!1},i=t.log,s=Bc(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&&Dm(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 Vc)){let c=Hc(e.opts.history),d=(p,h,m)=>qh(t,p,h,m.t,m.seq),f=new Vc(u,d,(p,h,m)=>{let y=AX(e,t,p,h,c,m);return y===void 0||(y.reaches&&t.seen++,Ho(y)&&t.restedCount++,y.since<=f.top||(t.early??=[],t.early.push(y))),y});u=f,t.subjects=u}u.back(n,o,l)}function Xa(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(qa(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=ey(e,t.frame);o=s.at,s.seq!==e.seq&&(i=s)}if(i===void 0){let s=Ba(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:Jr(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)Qr(c,o)}else{let s=i.at===o?i.u:es(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)EX(l,o,a,i.at<o);MB(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 EX(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?NX(e,c):c.doneSeq<=n?s.push(c):i.push(c);for(let c of i)IX(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(wm(e),u):e.chains=new me,e.owners=i.some(c=>c.holding!==null)?i.filter(c=>c.holding!==null):null,Yo(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),kD(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)Qr(e,t);else{e.frame=st(),e.reducedNow=e.reduced;let c=e.opts.history.ms;e.anchored>0&&e.transport.forgotTo>=t-c&&Yr(e)}}var T1=Symbol.for("@msb235/blits/watch/1"),S1=globalThis;function k1(){let e=S1[T1];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)}}},S1[T1]=e,e}var FB=new WeakSet;function LB(e){let t=S1[T1]?.history;return e.history!==void 0||e.transport!==void 0||t===void 0?{history:e.history,added:!1}:{history:t,added:!0}}function _B(e){FB.add(e)}function DB(e){let t=k1(),n=t.next++,r=e.transport,o={id:n,release:Gh,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:FB.has(r)}},get reach(){return UB(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=>MX(e,i),watch:i=>FX(e,i),subjects:()=>OX(e),read:(i,s=e.now)=>e.project(s).probe(i),hold:()=>DX(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 BB(e){let t=k1(),n=t.entries_.get(e);if(n===void 0||!t.refs.has(n.id))return;t.refs.delete(n.id),t.gone.unregister(e),HB(e);let r=e.transport,o=Kc(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 MX(e,t){return e.opts.labelOf?.(t)??CX(t)}function CX(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=k1(),o=r.labels.get(e);return o===void 0&&(o=`${e.constructor?.name||"Object"} #${++r.counted}`,r.labels.set(e,o)),o}function OX(e){let t=ir.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 OB=new WeakMap;function Kc(e){let t=OB.get(e);return t===void 0&&(t={tapped:0,held:null,unsync:null},OB.set(e,t)),t}function ty(e){let t=Kc(e),n=t.tapped>0||t.held!==null;if(n&&t.unsync===null){let r=ny(e).sync;t.unsync=eo(e,"sync",o=>{for(let s of e.members)GB(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 eo(e,t,n){let r=e,o=r[t];return r[t]=n,()=>{r[t]=o}}function ny(e){return Object.getPrototypeOf(e)}var ir=new WeakMap;function FX(e,t){let n=ir.get(e);if(n===void 0){let r=ny(e),o=r.probe,i=r.pull,s=r.drain,a=[eo(e,"probe",(l,u)=>{let c=o.call(e,l,u);return P1(e).probed.push({subject:l,pose:_X(c)}),ir.get(e).seen.add(l),c}),eo(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());P1(e).pulled.push({subjects:[...c],columns:d});let f=ir.get(e).seen;for(let p of c)f.add(p)}),eo(e,"drain",l=>{let u=s.call(e,l);return u.length>0&&P1(e).sent.push(...u),u})];n={fns:new Set,frame:null,seen:new Set,was:new Set,untap:()=>{for(let l of a)l()}},ir.set(e,n),Kc(e.transport).tapped++,ty(e.transport)}return n.fns.add(t),LX(new WeakRef(e),t)}function LX(e,t){return()=>{let n=e.deref(),r=n===void 0?void 0:ir.get(n);n===void 0||r===void 0||!r.fns.delete(t)||r.fns.size>0||HB(n)}}function HB(e){let t=ir.get(e);t!==void 0&&(t.untap(),ir.delete(e),Kc(e.transport).tapped--,ty(e.transport))}function P1(e){let t=ir.get(e);return t.frame!==null&&t.frame.seq===e.transport.seq||(GB(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 GB(e){let t=ir.get(e),n=t?.frame;if(!(t===void 0||n==null)){t.frame=null;for(let r of[...t.fns])r(n)}}function _X(e){try{return globalThis.structuredClone(e)}catch{return{...e}}}function UB(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 DX(e){let t=Kc(e);if(t.held!==null)throw new Error("blits: that mix is held already; free it first");let n=ny(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=g=>{let P=u;u=!0;try{g()}finally{u=P}},h=g=>{e.replaying||u?g():a.push(g)},m=()=>{e.rebasing&&!Number.isNaN(e.last)&&i.call(e,e.last),i.call(e,d)},y=[],b=e.tape;if(b!==void 0){let g=b.recordEntry;y.push(eo(b,"recordEntry",(...P)=>{u||b.timestampAt(b.undoDepth())!==void 0||g.apply(b,P)}))}y.push(eo(e,"ramp",(g,P)=>{if(!(g>=0&&g<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a mix's rate is a finite number, 0 or more, not ${g}`);h(()=>r.call(e,g,P))}),eo(e,"rebase",()=>h(()=>o.call(e))),eo(e,"seek",g=>h(()=>s.call(e,g))));for(let g of e.members){let P=ny(g).seek;y.push(eo(g,"seek",S=>{e.shared?P.call(g,S):h(()=>P.call(g,S))}))}t.held={sync(g){Number.isNaN(d)?d=g:!Number.isNaN(f)&&g>f&&(d+=(g-f)*l),f=g,m()},free:()=>w.free()},ty(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 UB(e,!0)},get rate(){return l},set rate(g){if(x(),!(g>=0&&g<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a hold's rate is a finite number, 0 or more, not ${g}`);l=g},seek(g){x(),p(()=>Xa(e,g))},step(g){if(x(),!(g>0))return;if(Number.isNaN(d))throw new Error("blits: a mix that has never synced has nothing to step");let P=Jr(e,e.now+g);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 g of a)g()}finally{for(let g of y.reverse())g();t.held=null,ty(e),e.woke()}}}};return w}var BX=1e3,Xo=class{history;shared;members=[];dropped=[];slots=0;holders=new Map;wakeFns=[];woken=!1;now=Number.NaN;seq=0;frames=new Jm;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=OL(this),this.pager=t?.store===void 0?null:new Zh(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),MF(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),CF(n),n.dropped=!0,this.history!==void 0&&(this.dropped.push({mix:n,at:this.now,seq:this.seq}),Lt(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){Xa(this,t)}prepare(t){return IF(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");v1(this,t,n,-1,void 0)}marks(t,n){return wL(this,t,n).map(({order:r,...o})=>o)}project(t){return ry(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=Ba(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&&__(d))&&Qr(d,o)}let l=this.history;this.kept();let u=this.keepsFrom();if(this.tape!==void 0&&l!==void 0&&!(u-this.taped<BX)){let c=es(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),NF(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 Qm(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&&Ko(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();Lt(this,"rate",o=>o.transport(this).ramp(t,n))}};function v1(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(),Lt(e,"announce",a=>{let l=a.transport(e);l.announced.push({...s,seq:l.seq})})}function zB(e,t,n,r,o){let i=e.tape,s=i?.undoDepth()??0;try{for(;;){let a=HX(i,t,r);if(!(a<r))break;if(WB(e,t,n,a),!KB(t))continue;for(let u of t.members)u.anchored>0&&Yr(u);let l=GX(t);for(let[u,c]of n){let d=new Jo(c.kit,{...c.opts,transport:l},null);d.slot=c.slot,d.projecting=!0,d.share=c.share,A1(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}WB(e,t,n,r)}finally{i!==void 0&&i.undoDepth()!==s&&i.goto(s)}return t}function KB(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 HX(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)),!KB(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 Qi){let c=Qe(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=Qe(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 WB(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=Jr(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=Ba(e,i,t,{transport:()=>t,mix:l=>n.get(l)});t.u=Math.max(a,Jr(t,r))}if(!(t.now>=r))for(let a of t.members)Qr(a,r)}function GX(e){let t=new Xo(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 A1(e,t){jc(e,t),t.cued=e.cued.filter(n=>n.state!=="done").map(n=>{let r={mix:e,voice:n,up:VB.get(n),seen:0,shared:!1,filled:!1},o=n.copy(s=>zX(r,s,t,o),void 0,!0);r.seen=o.seen,r.shared=o.sharing,VB.set(o,r);let i=e.pins?.get(n);return i!==void 0&&Ko(t,o,i),o}),t.waking=e.waking,Ha(t.cued),(e.owners!==null||e.projecting&&t.cued.some(n=>n.holding!==null))&&Ea(t.cued),Yo(t)}function jc(e,t){t.lastPoses=e.lastPoses,t.wantsPose=e.wantsPose,t.reducedNow=e.reducedNow}function oy(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:Tc(t,ut(e,n)?.slot??-1)?t.unreached:void 0}var VB=new WeakMap;function UX(e,t){return e.seen===t.seen&&!t.filled&&!t.shared&&e.unreached===null&&e.unreachedBits===null}function WX(e,t,n){return e.projecting&&n.reaches&&!t.sharing&&n!==t.unreached}function VX(e){return e.restored=null,Ka(e)}function zX(e,t,n,r){let o=e.mix,i=e.voice,s=e;for(;s.up!==void 0&&UX(s.voice,s.up);)s=s.up;if(s!==e&&oy(s.mix,s.voice,t)===void 0)return;let a=oy(o,i,t);if(a===void 0)return;let l=WX(o,i,a)?VX(a):qo(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 KX(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 jB(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=KX(r,o);if(i!==void 0)throw new Error(`${n}: voice ${o.id} is cued, and ${i}`)}}function $B(e,t,n,r){jc(e,t),t.backward=!0,t.cued=e.cued.filter(o=>o.state!=="done").map(o=>{let i=o.copy(a=>N1(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&&Ko(t,i,s),i}),Ha(t.cued),e.owners!==null&&Ea(t.cued),R1(t,n),Yo(t)}function ry(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=ey(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?Jr(e,r):es(e,r);if(!i&&n){o===void 0&&qa(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||jB(e,r);let u=new Xo(void 0,!0);u.offset=e.offset,u.u=l,u.nextId=e.nextId,u.now=i?e.now:r,u.pace=s===null||!qt(a,e.pacedSeq)?null:s.until(i?Number.POSITIVE_INFINITY:l),u.announced=(i?e.announced:e.announced.filter(m=>qt(a,m.seq))).map(m=>({...m}));let c=new Map;for(let m of e.members){let y=new Jo(m.kit,{...m.opts,history:void 0,lanes:!1,transport:u},null);y.slot=m.slot,y.projecting=!0,y.share=m.share,y.places=m.places,c.set(m,y),i?A1(m,y):n?jX(m,y,r,a):$B(m,y,r,a)}let d=u,f=null;i&&r!==e.now&&(f=new Map,d=zB(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 y=m,b=c.get(y);if(b===void 0)throw new Error("blits: that mix is not on this transport");let x=f?.get(y),w=x===void 0?null:g=>{if(!x.met.has(g)){x.met.add(g);for(let P of x.at)P.fold(g)}};return{timestamp:r,probe:(g,P)=>h(()=>(w?.(g),b.fold(g,P))),assess:g=>h(()=>(w?.(g),b.fold(g),$X(b,g)))}}}}function jX(e,t,n,r){jc(e,t),t.backward=!0;let o=Bc(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&&!qt(r,a.doneSeq,!0)).sort((a,l)=>a.id-l.id).map(a=>{let l=a.log,u=a.copy(c=>N1(e,a,c,n,r,t,u),Bc(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&&Dm(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}),Ha(t.cued),e.owners!==null&&Ea(t.cued,r.seq),R1(t,n,r),Yo(t)}function R1(e,t,n){for(let r of e.cued)r.state=r.stateAt(t,n)}function N1(e,t,n,r,o,i,s){let a=t.left?.at(n,o)??qh(t,n,oy(e,t,n),r,o.seq);if(a===void 0)return;let l=a.snaps&&Va(a.snaps,r,!0);if(l){let f=qo(t,l.held);return i!==void 0&&s!==void 0&&!(f.since<=l.at)&&Oa(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=yT(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 $X(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=YX(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 YX(e,t,n){let r=t.spec.weight;if(n.unknown)return"held";let o=n.replay!==void 0&&Va(n.replay,e.now,!0)!==void 0;if(typeof r=="function"&&r.input&&!o||t.owner!==null&&ZF(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=Lo(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 iy=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 YB(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 qB(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(!Ic(r,n.rest))return!1}return!0}function XB(){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 JB(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 QB(){return this.lanes.whole&&this.bounded.length===0}function ZB(){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 e3(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 qX(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 t3(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)?qX(e,u,c,d.rest):$i(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]=$i(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 XX(e,t,n){return e===null?!1:n>=t.length||e.voice===null?!0:t[n].id>e.voice.id}function n3(e,t,n,r,o,i,s){let a=this.now,l=this.roleScratch[this.roleDepth];l===void 0&&(l=e3(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=XX(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 y=m;p||this.share.open(h,y,n.slot);let b=this.read(h,e,a,o,y);s>=0&&h.laned&&this.lanes.paid(h.id,s,y.weight),p||(c=this.shared(h,n.slot,y,c));let x=h.spec.role;if(b===null){x===void 0&&!(y.weight>0)&&kt(y);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 g=l.n++;l.voices[g]=h,l.helds[g]=y,l.deltas[g]=b,l.weights[g]=x===void 0?this.w:0,l.groups[g]=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),y=l.names[h];if(!(m>0)){f.get(y)?.fill(2);continue}let b=f.get(y);b===void 0&&(b=new Uint8Array(this.channels.length),f.set(y,b));for(let x=0;x<l.touched.length;x++){let w=l.touched[x],g=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],g,A):Nc(S,t[P],S.scale(g,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?$i(g):Nc(S,t[P],g))}}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 r3(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 JX=1e-6,QX=(e,t)=>Math.abs(e-t)<=1e-6*Math.max(1,Math.abs(e),Math.abs(t));function o3(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=ZX(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=e9(e,c,t,n),l.set(c,m));let y=e.scalars[p],b=i&&!m.unknown.has(p)&&!e.bounded.includes(p)&&(y==="sum"||y==="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 g=[],P=[],S=!0,v=(N,M)=>{let C=g.length;C>0&&g[C-1]===N&&QX(P[C-1],M)?P[C-1]=M:(g.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 D=M+(C-M)/3,B=C-(C-M)/3,K=h(D),W=(h(B)-K)/(B-D);v(M,K-W*(D-M)),v(C,K+W*(C-D));continue}S=!1;let F=Math.min(JX,(C-M)/4);v(M,h(M===t?M:M+F));for(let D=Math.max(0,Math.ceil((M-t)/o));;D++){let B=t+D*o;if(B>=C-F)break;B>M+F&&v(B,h(B))}v(C,h(C===n?C:C-F))}return{at:g,value:P,exact:S}}}}function ZX(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 e9(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))&&!n9(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 t9=4096;function n9(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),y=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(y(0)),Number.isFinite(w)&&f(y(w));let g=t.endsAt();if(f(g),!t.freezesAfter&&Number.isFinite(g)){let P=p?0:Number.isNaN(t.outOver)?t.fade.out??0:t.outOver,S=Math.max(t.start,g);f(S),P>0&&(c.push([S,S+P]),f(S+P)),s.stagger!==void 0&&c.push([y(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>t9)return!1;for(let A=P;A<=S;A++){let N=A*x;f(y(N)),f(y(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(y(N+F));let D=Number.NaN;for(let B of M.all){let K=y(N+F+Math.min(1,Math.max(0,B.at))*(x-F));if(f(K),!Number.isNaN(D)&&!fF(B.ease)){let W=d.get(C);W===void 0?d.set(C,[[D,K]]):W.push([D,K])}D=K}}}}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 i3(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 s3(e,t,n){let r=this.now,o=e.setting;o.mark!==n[6]&&r9(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 r9(e,t,n){e.timestamp=t,e.elapsed=n[1],e.pass=n[3],e.mark=n[6]}function a3(e){let t=this.opts.maxDt;return this.reducedNow?Number.POSITIVE_INFINITY:t!==void 0&&e>t?t:e}function l3(e,t,n){let r=this.opts.history;return r===void 0?Number.POSITIVE_INFINITY:$T(this,e,n-r.ms)-t}function u3(e,t,n){return Ta(e.fade.in??0,e.out,e.ease,this.reducedNow,t,n,e.back,e.stalls)}function c3(e,t){return eL(e,this.now,this.reducedNow,n=>this.ownerBase(n,t))}function d3(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 f3(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 Yt(o,i,e.parts===null?1:this.parting(e,t,n))}function p3(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 Yt(i,s,e.parts===null?1:this.parting(e,t,n))}function h3(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&&Va(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&&Fm(this,e,t,r,a),a}var o9={lanes:!0},Jo=class{kit;opts;lanesOf;cued=[];gone=[];goneIx=new pm;scored=new tm;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 Xh;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 iy;named=new me;parters=new Set;departed=new gm;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=>Wh(i)),this.pose=iD(this.names,this.channels),this.scalars=this.channels.map(i=>YO(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??o9.lanes)?new r(wm(this)):null,this.name=n.name,this.roleTags=R_(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 Xo(n.history,!1);this.transport.pager!==null&&(this.keys=new em(n.keyOf),this.outs=new Cm,o!==void 0&&s9(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??VO}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 A_(this,t)}blend(t,n,r={}){let o=`blend:${this.nextId}`,i=Rc(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:Xi})}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 Om(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 oD(this,t)}sync(t){this.own("sync").sync(t)}book(t){return GL(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,SD(this,t,n)}seek(t){if(this.projecting)throw new Error("blits: a projection does not seek");Xa(this.own("seek"),t)}prepare(t){return this.own("prepare").prepare(t)}project(t){return ry(this.transport,t).of(this)}trace(t,n,r){return o3(this,t,n,r)}announce(t,n={}){this.attached(),v1(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 mm(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(){BB(this)}mute(t){for(let n of this.cued)n.written=!0,Zr(this,n,{over:t?.over});Lt(this,"mute",n=>n.mix(this)?.mute(t))}touch(t){this.attached(),r3(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},i9={fold:t_,folded:n_,linked:r_,foldWith:o_,owedBy:a_,foldRoles:n3,foldDetour:i_,foldSharers:s_,shared:e_,read:gD,contribution:cD,keyed:dD,tick:pD,apply:QL,clamp:ZL,passes:JL,isRest:yD,baseFor:hD,slopeFor:mD,prime:i3,primeLaned:s3,capped:a3,horizonFor:l3,weigh:f3,weighOwned:p3,base:h3,envelope:u3,ownedBy:c3,ownerBase:d3,blended:KL,laneRead:jL,shareKept:$L,parting:Z_,chain:gF,relink:bF,linkable:xF,aims:wF,held:aL,unreachedOf:sL,sinceOf:lL,shownOf:uL,keep:TD,foldRole:t3,atRest:YB,rests:qB,restful:XB,still:JB,restsLaned:QB,restsKey:ZB,plot:kB,place:vB,moved:RB,put:NB,around:XL,drop:bD,forgetIn:xD,releaseIn:wD,recordDrop:PD};for(let[e,t]of Object.entries(i9))Object.defineProperty(Jo.prototype,e,{value:t,writable:!0,configurable:!0});function s9(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 a9(e,t,n){let{history:r,added:o}=LB(t),i=new Jo(e,o?{...t,history:r}:t,n);return o&&_B(i.transport),DB(i),i}var m3={name:"mixer",runs:new Set(["fn","keys","motion"]),create(e,t){return a9(e,t,Wc)}};function I1(e,t={}){return(t.engine??m3).create(e,t)}function sy(e,t,n){for(let r=t;r!=null;r=n(r))if(e.has(r))return r;return null}function $c(e,t){if(e.length<2)return e;let n=new Set(e),r=o=>{let i=t(o);return i!=null&&sy(n,i,t)!==null};return e.some(r)?e.filter(o=>!r(o)):e}Z();var Ja={getBounds:e=>et(e),remapBounds:(e,t,n)=>Nt(e,mr(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)=>sb(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=qe(e),o=qe(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=_g(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(qe(t)):[],from:t=>({...e,coords:At(e.origin,t)}),add:(t,n)=>{if(t.kind!=="polygon")return t;let r=Float64Array.from(qe(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=qe(t);for(let i=0;i<o.length;i++)n[r+i]=o[i]}},supportsRotation:()=>!1};function sr(e){return!!e&&typeof e=="object"&&"kind"in e&&(e.kind==="polygon"||e.kind==="rect")}function Qa(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 Qo={getBounds:e=>sr(e)?Ja.getBounds(e):Ot.getBounds(e),remapBounds:(e,t,n)=>sr(e)?Ja.remapBounds(e,t,n):Ot.remapBounds(e,t,n),fromBounds:(e,t)=>sr(t)?Ja.fromBounds(e,t):Ot.fromBounds(e,t),translate:(e,t,n)=>sr(e)?Ja.translate(e,t,n):Ot.translate(e,t,n),axes:e=>Qa(e)?Ot.axes(e):sr(e)?Ja.axes(e):null,getRotation:e=>{if(sr(e))return 0;let t=e.rotation;return typeof t=="number"?t:0},supportsRotation:e=>!sr(e),withRotation:(e,t)=>sr(e)?e:{...e,rotation:t}};function y3(e){return t=>wa(e,t)}function g3(e,t){let n=y3(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 b3(e,t){let n=y3(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 E1(e,t){switch(e){case"union":return gp(...t);case"intersect":return e0(...t);case"exclude":return n0(...t);case"subtract":{let n=t.length===2?t[1]:gp(...t.slice(1));return t0(t[0],n)}}}var M1="kit:booleanOfChildren",u9=new Set(["union","intersect","subtract","exclude"]);function x3(e){let t=e?.boolean;return typeof t=="string"&&u9.has(t)?t:"union"}var w3=e=>e.path;function P3(e){w3=e}function c9(e){if(e.node.kind!=="group")return w3(e);let t=T3(e.children??[]);return t.length<=1?t[0]??null:E1("union",t)}function T3(e){let t=[];for(let n of e){if(n===void 0||n.node.hidden===!0)continue;let r=c9(n);r!==null&&t.push(r)}return t}function C1(e,t){let n=T3(t);if(n.length===0)return null;let r=x3(e.data);return n.length===1&&r!=="subtract"?n[0]:E1(r,n)}Z();var Za="shape:paint";function ay(e){return(e.dependsOn?.length??0)>0&&e.derivePath!==void 0}Z();Pe();Pe();Z();Zu.subscribe(dc);function ar(e,t){if(e===null)return{outset:0,inset:0};let n=Cu(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=Ni(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 el(e){return e?.trim===void 0?{}:{trim:e.trim}}function d9(e,t){let n=ar(e,t);return n.outset+(n.outsetPx??0)/(t>0?t:1)}function ly(e,t){let n=t?.scale??1,r=t?.screen;if(!r){let d=d9(e,n);return{x:d,y:d}}let o=ar(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 tl(e,t){let n=t?.vertexColors,r=e[0];if(n===void 0||r?.kind!=="path")return e;let o=4*ab(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 O1(e,t){let n=t?.trim;if(n===void 0||e.kind!=="path"||!e.stroke)return e;let r=e.stroke.trim,o=n(r);if(o===r||Tr(o)===Tr(r))return e;let{trim:i,...s}=e.stroke;return{...e,stroke:o===void 0?s:{...s,trim:o}}}function nl(e,t){let n=e[0];if(t?.trim===void 0||n===void 0)return e;let r=O1(n,t);return r===n?e:[r,...e.slice(1)]}function F1(e,t){let n=Ne(e.stroke,t?.stroke),r=Ie(e.fill,t?.fill);return n!==null?{fill:r,stroke:n}:{fill:r}}function _1(e,t,n,r){let{sized:o,spaces:i}=r?p9(e,t,r):f9(t,n),s=at(o.width??1,1);if(!(s>0))return null;let a=new L1,l=t.align??"center";if(l!=="inner"){let u=l==="outer"?2:1,c=Xs(o,s),d=Ei(e,{...o,width:s*u,align:"center",vertexWidths:t.vertexWidths?.map(m=>iu(m,u))},{startInset:S3(c.start,i.start,i.ribbon),endInset:S3(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 Mu(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 f9(e,t){return{sized:{...e,width:at(e.width??1,t)},spaces:{}}}function p9(e,t,[n,r,o,i]){let s=new Float32Array([n,r,0,o,i,0,0,0,1]),{cmd:a,spaces:l}=ec(s,{kind:"path",path:e,stroke:t});return{sized:a.stroke,spaces:l}}function S3(e,t,n){return t?.metric===n?.metric?e:{length:e,metric:t?.metric??null}}var L1=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}}},h9="shape:drawn";function k3(e,t,n){let r=v3(e);if(!t)return r;let o=ly(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 uy(e,t,n,r,o){let i=v3(t);if(n===null)return i;let s=r?.scale??1,a=r?.screen,l=rt(e,h9,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||!m9(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=_1(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 m9(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 v3(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 A3(e,t,n,r){let o=et(e),i=t&&Kt(t,o),s=n&&Wi(n,o);return{kind:"path",path:e,...i?{fill:i}:{},...i&&r?{vertexColors:r}:{},...s?{stroke:s}:{}}}function D1(e,t){let n=t?.derivedPath,r=Ne(e.data?.stroke,t?.inherited?.stroke);return n==null||r===null?null:_1(n,r,t?.scale??1,t?.screen)}function y9(e,t,n){let{fill:r,stroke:o}=mO(e,t,n);return A3(e.path,r,o,void 0)}var cy={id:"kit:derived",matches:ay,paint:(e,t,n)=>{let r=n?.derivedPath;if(r==null)return[];let o=e.data,i=Mh(r);if(i!==void 0)return i.map(l=>{let u=y9(l,o,n?.inherited);return l.stroke===It?O1(u,n):u});let s=Ne(o?.stroke,n?.inherited?.stroke),a=Ie(o?.fill,n?.inherited?.fill);return nl(tl([A3(r,a,s,o?.vertexColors)],n),n)},silhouette:(e,t,n)=>n?.derivedPath??null,drawnBounds:(e,t,n)=>D1(e,n),ink:(e,t,n)=>{let r=e.data,o=Ne(r?.stroke,n?.inherited?.stroke);return{filled:Ie(r?.fill,n?.inherited?.fill)!==null,...ar(o,n?.scale),...el(o)}}};Z();function Dt(e){return e===void 0||Qa(e)}function Zo(e,t,n){if(!Qa(e))return null;let r=t?ia(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 g9(e,t){return{x:e.x*t.width,y:e.y*t.height,w:e.width*t.width,h:e.height*t.height}}function b9(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 R3={id:"kit:image",snapsToBox:!0,matches:e=>{if(!Dt(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):ca(r.image.src,b9(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:g9(r.image.source,i)}:{},...r.image.flipX?{flipX:!0}:{},...r.image.flipY?{flipY:!0}:{}}];let s=n?.resolveImage?!1:kw(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:Og({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)=>Zo(t,x9,n)},x9={paint:{color:"#000"},width:1};Z();var N3={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 B1(e){let t=e?.data?.measure;return!t||typeof t!="object"||!t.start||!t.end?null:t}var w9=5;function P9(e,t,n){let r={...N3.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=w9*n,l=c=>({kind:"path",path:Vd([{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:Vd([e,t]),stroke:r}),u}var I3={id:"kit:measure",matches:e=>Dt(e.pose)&&B1(e)!==null,paint:(e,t,n)=>{let r=B1(e);if(!r)return[];let o=globalThis.devicePixelRatio||1;return P9(r.start,r.end,o/(n?.pixelScale??o))}};Z();Pe();var E3={id:"kit:path",matches:e=>Dt(e.pose)?e.data?.path!=null:!1,paint:(e,t,n)=>n?.derivedPath!=null?cy.paint(e,t,n):nl(tl(rt(e,Za,t,()=>{let r=e.data,o=$l(r.path,t),{fill:i,stroke:s}=F1(r,n?.inherited),a=i&&Kt(i,t),l=s&&Wi(s,t);return[{kind:"path",path:o,...a?{fill:a}:{},...a&&r.vertexColors?{vertexColors:r.vertexColors}:{},...l?{stroke:l}:{}}]},n?.inherited),n),n),silhouette:(e,t,n)=>{if(n?.derivedPath!=null)return n.derivedPath;let r=e.data;return $l(r.path,t)},ink:(e,t,n)=>{let{fill:r,stroke:o}=F1(e.data,n?.inherited);return{filled:r!==null,...ar(o??null,n?.scale),...el(o??null)}},bounds:(e,t,n)=>Zo(t,Ne(e.data.stroke,n?.inherited?.stroke),n),drawnBounds:(e,t,n)=>{if(n?.derivedPath!=null)return D1(e,n);let r=e.data;return uy(e,t,Ne(r.stroke,n?.inherited?.stroke),n,o=>$l(r.path,o))}};Pe();var M3={id:"kit:rect-fallback",matches:e=>e.kind!=="group"&&Dt(e.pose),paint:(e,t,n)=>{let r=e.data,o=t,i=Ie(r?.fill,n?.inherited?.fill),s=i&&Kt(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)=>Zo(t,null,void 0)};Z();Pe();var C3={id:"kit:shape",matches:e=>{if(!Dt(e.pose))return!1;let t=e.data?.shape;return t!=null&&T9.has(t)},paint:(e,t,n)=>nl(tl(rt(e,Za,t,()=>{let r=e.data,o=H1(r,t),i=Ie(r.fill,n?.inherited?.fill),s=i&&Kt(i,t),a=Ne(r.stroke,n?.inherited?.stroke),l=a&&Wi(a,t);return[{kind:"path",path:o,...s?{fill:s}:{},...l?{stroke:l}:{}}]},n?.inherited),n),n),silhouette:(e,t)=>{let n=e.data;return H1(n,t)},ink:(e,t,n)=>{let r=e.data,o=Ne(r.stroke,n?.inherited?.stroke);return{filled:Ie(r.fill,n?.inherited?.fill)!==null,...ar(o,n?.scale),...el(o)}},bounds:(e,t,n)=>Zo(t,Ne(e.data.stroke,n?.inherited?.stroke),n),drawnBounds:(e,t,n)=>{let r=e.data,o=Ne(r.stroke,n?.inherited?.stroke);return r.shape==="polygon"||r.shape==="star"?uy(e,t,o,n,i=>H1(r,i)):k3(t,o,n)}},T9=new Set(["rect","ellipse","polygon","star"]);function H1(e,t){switch(e.shape){case"ellipse":return Eg(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 Mg({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 Cg({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 S9(e,t){return{kind:"group",clip:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height},children:[e]}}function k9(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 G1(e,t,n){return{...k9(e,t),text:e.text,runs:e.runs,style:e.style,fill:e.fill===It?Ie(e.fill,n?.fill):e.fill,stroke:Ne(e.stroke,n?.stroke)??void 0,verticalAlign:e.verticalAlign}}var U1={id:"kit:text",snapsToBox:!0,matches:e=>Dt(e.pose)?e.data?.text!=null:!1,paint:(e,t,n)=>rt(e,Za,t,()=>{let r=e.data,o=gP(G1(r,t,n?.inherited)),i=r.overflow==="clip"?S9(o,t):o,s=Ie(r.background);if(!s)return[i];let a=Kt(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(Ie(n.background))return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height};let r=Kp(G1(n,t)),o=n.overflow==="clip"?v9(r,t):r;return o.length===0?null:R9(o)},ink:(e,t,n)=>{let r=e.data;return{filled:!0,...ar(Ne(r.stroke,n?.inherited?.stroke),n?.scale)}},drawnBounds:(e,t,n)=>{let r=e.data,o=Ne(r.stroke,n?.inherited?.stroke);return o?A9(t,Kp(G1(r,t,n?.inherited)),ly(o,n)):null}};function v9(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 A9(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 R9(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++]=se,n[r++]=s,n[r++]=a,t[o++]=ae,n[r++]=s+l,n[r++]=a,t[o++]=ae,n[r++]=s+l,n[r++]=a+u,t[o++]=ae,n[r++]=s,n[r++]=a+u,t[o++]=ae,n[r++]=s,n[r++]=a,t[o++]=fe}return{kind:"polygon",commands:t,coords:n,fillRule:"nonzero"}}var MNe=Object.freeze({filled:!0,outset:0,inset:0}),rl={high:[],normal:[]},O3=!1;function W1(){O3||(O3=!0,_9())}function os(e,t={}){W1();let n=t.priority==="high"?rl.high:rl.normal;return n.push(e),dc(),()=>{let r=n.indexOf(e);r>=0&&n.splice(r,1),dc()}}var N9="shape:painter",I9="shape:painter:nonrect",E9="shape:painter:derived",M9="shape:painter:derived:nonrect",C9="shape:silhouette",O9="shape:silhouette:text";function Yc(e){let t=Dt(e.pose),n=ay(e)?t?E9:M9:t?N9:I9;return rt(e,n,void 0,()=>F9(e))}function F9(e){W1();for(let t of rl.high)if(t.matches(e))return t;for(let t of rl.normal)if(t.matches(e))return t}function qc(e,t,n){let r=()=>{let o=L9(e,t,n);return o&&Is(o,t)};if(n?.derivedPath!=null)return r();if(Yc(e)===U1){let o=ti(),i=rt(e,O9,t,()=>({epoch:o,path:r()}));return i.epoch!==o&&(i.epoch=o,i.path=r()),i.path}return rt(e,C9,t,r)}function L9(e,t,n){return Yc(e)?.silhouette?.(e,t,n)??null}P3(e=>qc(e.node,e.pose,{derivedPath:e.path}));function dy(e,t,n){return Yc(e)?.ink?.(e,t,n)??null}function F3(){return W1(),[...rl.high,...rl.normal]}function _9(){os(U1),os(I3),os(cy),os(E3),os(C3),os(R3),os(M3)}function fy(e){return`scene:${e}`}function L3(e,t){let{layerVisibility:n,layerOrder:r}=t;return n===void 0&&r===void 0?e:(r?r.map(i=>e.find(s=>fy(s.id)===i)).filter(i=>i!==void 0):e).filter(i=>n?.[fy(i.id)]!==!1)}Z();function py(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=wP(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=Nt(r,PP(a))),u}}function _3(e,t){let n=wP(e,t);return n===null?void 0:q.fromAffine(PP(n))}var D3=Object.freeze({preserveDrawingBuffer:!0,stencil:!0});Z();Z();Z();function B3(e,t){if(e.length===0)return e;let n=Re(t);return n?[{kind:"group",transform:q.fromAffine(n),children:e}]:e}var G3=new WeakSet;function hy(e){let t={kind:"group",children:e};return G3.add(t),t}function H3(e){return G3.has(e)}var D9=[];function my(e){if(!e.some(H3))return{under:e,over:D9};let t=[],n=[];for(let r of e)H3(r)?n.push(...r.children):t.push(r);return{under:t,over:n}}function W3(e,t,n){let{under:r,over:o}=my(e),i=U3(r,t,n);return o.length>0?[...i,hy(U3(o,t,n))]:i}function U3(e,t,n){let r=B3(e,t);return n!==1&&r.length>0?[{kind:"group",alpha:n,children:r}]:r}function B9(e,t,n){return qc(e,t,{derivedPath:n?.()??null})}function yy(e,t,n){return typeof e.clipFromPose=="function"?e.clipFromPose(t):e.clip!=="outline"?null:B9(e,t,n)}Z();Z();function z3(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(!V3(a,o,f[p],e,t,n))return!1;return!0}let u=(f,p)=>V3(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 y=p.inCopy?.(m);if(y!==void 0&&u(y,h)&&d(f+1,y))return!0}return!1};return d(0,o)}function V3(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 ce=e=>e;function H9(e){return e?.annotation===!0}function gy(e){let t=new Set;for(let n of e??[])H9(n)&&t.add(n.id);return t}function Xc(e){return e.hidden===!0}function ol(e){let t=by(e,"hidden"),n=by(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(Xc),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||Xc(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 K3(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 by(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 j3(e,t){let n=e.get(t);return n===void 0?!1:by(e,"hidden")?.has(n.layer)===!0||K3(e,t,Xc)}function $3(e,t){let n=by(e,"locked");return K3(e,t,n===null?r=>r.locked===!0:r=>r.locked===!0||n.has(r.layer))}Z();function q3(e,t){let n=Tt(e.overrides,t),r=Jn(e,t);return r===n.pose?n:{...n,pose:r}}function z1(e,t){return n=>t(q3(e,n))}function X3(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=q3(e,n);return Ch(r,o.pose,t(o))}}function Jc(e,t){let n=t?z1(e,t):o=>Jn(e,o);if(!Ct(e.composition))return n;let r=Hh(e,{getPose:o=>{let i=e.get(ce(o));return i?n(i):void 0},getParent:o=>e.get(ce(o))?.parent??null,definesFrame:o=>{let i=e.get(ce(o));return i===void 0||lt(i)}});return o=>jt(r,o.id,e.composition.compose)}function G9(e,t){let n=J3(t,Ct(e.composition));if(n===void 0)return o=>OP(e,o);let r={at:Jc(e,t),local:t?z1(e,t):o=>Jn(e,o),slot:n,shown:X3(e,t),childrenOf:o=>e.childrenOf(o),scene:Pa(e),lookup:o=>{let i=e.get(o);return i===void 0?void 0:new V1(Tt(e.overrides,i),r)}};return r.lookup}var V1=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?Oh(t,this.ctx.local(this.node),this.pose):Br(this.node,this.ctx.lookup,this.ctx.childrenOf,this.ctx.slot)}get inherited(){return wa(this.ctx.scene,this.node)}get children(){return this.ctx.childrenOf(this.node.id).map(this.ctx.lookup)}};function K1(e,t){return t.dependsOn!==void 0||e.overrides.read(t.id)?.path!==void 0}function Qc(e,t){let n=G9(e,t),r=J3(t,Ct(e.composition)),o=a=>e.childrenOf(a),i=a=>Br(a,n,o,r),s=X3(e,t);return a=>s(a)??i(a)}var Y3=new WeakMap;function J3(e,t){let n=t?"world":"local";if(e===void 0)return n==="world"?"kit:derivedPath:world":void 0;let r=Y3.get(e);return r===void 0&&(r={},Y3.set(e,r)),r[n]??=SO()}function Q3(e,t,n){let r=Qc(e,n),o=Ct(e.composition)?n?z1(e,n):i=>Jn(e,i):null;return(i,s,a,l)=>{if(!K1(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=U9(u,s,o(i))),t(i,s,a,{...l,derivedPath:u})}}function U9(e,t,n){let r=mi(t);if(r===null)return e;let o=t,i=n,s=Re({x:o.x,y:o.y,width:o.width,height:o.height,rotation:i?.rotation,transform:i?.transform});return uc(e,s===null?r:ht(r,s))}mA();function W9(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 j1({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||!W9(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 V9=[];function xy(e){return t=>{let n=t.parent??null;if(n===null)return V9;let r=[],o=new Set;for(;n!==null&&!o.has(n);){o.add(n);let i=e.get(ce(n));if(!i)break;r.push(i),n=i.parent??null}return r}}function wy(e){let t=Qc(e);return n=>{let r=n;return K1(e,r)?t(r):null}}Z();Z();Z();function Z3(e){let{x:t,y:n,width:r,height:o}=e;return Zc([t,n,t+r,n,t+r,n+o,t,n+o],{x:t,y:n,width:r,height:o},!0)}function Zc(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 eH(e){if(e.length<3)return null;let t=[];for(let n of e)t.push(n.x,n.y);return Zc(t)}function tH(e){return e!==null&&typeof e=="object"&&e.kind==="polygon"}function Py(e,t,n){return tH(t)?rt(e,"aabb",t,()=>n.getBounds(t)):Ki(t,n)}function nH(e,t){if(Re(e)){let n=e;return Is({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 $1(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 Wn(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 rH(e,t,n,r,o,i=()=>!0){let s=$1(e,t,r);if(s!==void 0)return s;let a=e.bounds,l=tH(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:ib(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:tf(e.verts,u):tf(e.verts,u,{filled:!1})}function ed(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 z9(e,t,n,r){let o=sr(t)?et(t):n.getBounds(t),i=n===Qo?t:BP(t,n),s=Re(i);if(!s){ed(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);ed(e,{x:p,y:h,width:0,height:0},0)}}function K9(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 j9=Object.freeze({scale:1});function oH(e,t,n,r,o,i){let s=dy(e,t,r===void 0?j9:{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)ed(i,et(n),a);else{let l=Gr(o,e);o===Qo&&l===o&&Qa(t)&&Re(t)===null?ed(i,t,a):(ed(i,Py(e,t,l),a),z9(i,t,o,a))}return K9(i),Math.max(0,s?.outsetPx??0)}var $9=0;var iH=new WeakMap,Y9=.5,Y1=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*Y9),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 q9(e){return e.some(t=>typeof t.copiesFromPose=="function")}function X9(e,t,n){$9++;let r=Jc(e),o=wy(e),i=xy(e),s=new Map,a=[],l=0;for(let c=0;c<n.length;c++){let d=n[c],f=i(d);if(q9(f)){a.push(c);continue}let p=[0,0,0,0],h;try{let y=fc(d)?xa(d,f):void 0;h=oH(d,r(d),o(d),y,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=yb(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 Y1(n,u,Int32Array.from(a),l)}function J9(e,t){F3();let n=e.getVersion(),r=e.overrides.getGeneration(),o=e.scroll?.getGeneration()??0,i=kO(),s=Eu(),a=iH.get(e);a===void 0&&iH.set(e,a=new WeakMap);let l=a.get(t);l===void 0&&a.set(t,l=j1());let u=Dh(e.overrides,e.renderOrderNodes()),c=l.read([n,r,o,i,s],()=>X9(e,t,u));return c?.rankBy(u),c}function sH(e,t,n){let r=J9(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 q1(e,t={}){let n=ol(e),r=typeof e.overrides?.ids=="function",o=w=>e.overrides?Tt(e.overrides,w):w,i=w=>r?Dh(e.overrides,w):w.map(o),s=gy(e.layers),{getPose:a,alphaOf:l,layerIsPainted:u}=t,c=null;if(!l&&r)for(let w of e.overrides.ids()){let g=e.overrides.read(w)?.alpha;g!==void 0&&g<=0&&(c??=new Set).add(w)}let d=l??(r?c?w=>c.has(w)?0:1:void 0:w=>e.overrides.read(ce(w))?.alpha??1),f=Jc(e),p=a?w=>a(w.id):w=>f(w),h=w=>e.childrenOf(w),m=w=>{let g=e.get(w);if(g===void 0)return;let P=o(g);return{node:P,pose:p(P),get path(){return Br(P,m,h)}}},y=a?w=>{let g=w;return g.dependsOn===void 0?null:Br(g,m,h)}:wy(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 g=sH(e,x.descriptor,w);return g===null?null:i(g)}}:{},order:()=>i(e.renderOrderNodes()),derivedPathOf:y,poseOf:p,parentsOf:xy(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,kh(t,o.parallax));if(n===null)return null;let r=n;return o=>r.get(o)??null}function aH(e,t){let n=t.includeGroups??!0,r=t.includeLocked===!0?void 0:e.isLocked,o=[],i=new Map,s=py(e.planeOf??null),a=b=>{let x=i.get(b.id);if(x!==void 0)return x;let w=yy(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(hr).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"),y=(t.broad!==void 0?e.candidates?.(b=>{let x=d(b);return x===null?null:x.broad}):null)??h;for(let b of y){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),g=e.derivedPathOf?.(b),P=fc(b)?xa(b,e.parentsOf(b)):void 0;z3(b,w,g,P,x,p,m,f)&&o.push(b.id)}return o}function Q9(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 lH(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,bP(n,h.parallax));let u=e.composePose?.bind(e),c=u?e.childFrame?.bind(e):void 0,d=py(l?Ty(s,n):null);function f(h,m,y,b){let x=e.getNode(h);if(!x||Xc(x))return;let w=e.getPose(h),g=u&&y!==null?u(y,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}=my(P&&(b||!i?.(x,g,S))?t(x,g,S):[]),N=m,M=null,C=x,F=yy(C,g,()=>o?.(x,g));F&&(M={path:F,layer:x.layer},N=[...m,M]);let D=Q=>m.length>0?Q9(Q,m,x.layer,d):{kind:"group",children:Q};P&&P.push(D(v));let B=lt(x)?c?c(h,g):g:y,K=x.consumesChildren===!0?[]:e.getChildren(h);for(let Q of K)f(Q,N,B,b);let W=typeof C.copiesFromPose=="function"?C.copiesFromPose(g,x):null;for(let Q of W??[]){let le=[...m,{copy:Q},...M?[M]:[]];for(let ke of K)f(ke,le,B,!0)}P&&A.length>0&&P.push(D(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)??[],y=h.parallax?_3(kh(n,h.parallax),null):void 0;p.push(y?{kind:"group",transform:y,children:m}:{kind:"group",children:m})}return p}var il=[{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 Sy(e,t){return il.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 td(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 is(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 ky(e){let t=e,n={};for(let r of il){let o=t[r.field];o!==void 0&&(n[r.field]=o)}return n}function lr(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 vy(e){let t=n=>n===null?[...e.roots]:[...e.childrenOf(ce(n))];return{getNode:n=>e.get(ce(n)),getParent:n=>e.get(ce(n))?.parent??null,getChildren:t,getRemovalClosure:n=>[...e.removalClosure(n.map(ce))],setPose:(n,r)=>e.setPose(ce(n),r),setParent:(n,r)=>e.move(ce(n),r==null?null:ce(r)),setChildOrder:(n,r)=>{e.batch("Reorder",()=>{for(let o=0;o<r.length;o++)t(n)[o]!==r[o]&&e.reorder(ce(r[o]),o)})},setData:(n,r)=>e.update(ce(n),{data:r}),setLayer:(n,r)=>e.setLayer(ce(n),r),setDependsOn:(n,r)=>e.setDependsOn(ce(n),Array.isArray(r)?r.map(ce):r),setLayout:(n,r)=>e.setLayout(ce(n),r),setHidden:(n,r)=>e.setHidden(ce(n),r),setLocked:(n,r)=>e.setLocked(ce(n),r),removeNode:n=>e.remove(ce(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}:{},...lr(n),...ky(n)})}}}function uH(e){return{getPose:t=>Hr(e,e.get(ce(t))),getNodes:()=>[...e.renderOrderNodes()]}}function cH(e,t,n){for(let r of t)r.apply(e)}Z();function fH(e,t){let n=e?.get?.();return{...t?{alphaOf:t}:{},...e?.layerIsPainted?{layerIsPainted:r=>e.layerIsPainted(r)}:{},...n?{camera:n}:{}}}function pH(e,t,n,r=Qo,o={}){return mH(e,Z3(t),"intersect",n,r,o)}function hH(e,t,n,r,o=Qo,i={}){let s=eH(t);return s?mH(e,s,n,r,o,i):[]}function dH(e,t){return t?.kind!=="polygon"||e()?t:{...t,openFill:"none"}}function mH(e,t,n,r,o,i){let s=q1(e,{...r,index:{descriptor:o}});return aH(s,X1(t,n,o,i))}function X1(e,t,n,r){return{includeGroups:r.includeGroups===!0,broad:{box:e.bounds},clipAdmits:(o,i,s,a)=>{let l=Gr(n,i);return ef(o,a?et(a):Ki(s,l))&&ef(o,e.bounds)},hits:(o,i,s,a)=>{let l=Gr(n,o),u=s?et(s):Py(o,i,l),c=$1(e,t,u);if(c!==void 0)return c;let d,f=()=>d??=dy(o,i,{inherited:a})?.filled!==!1;return rH(e,t,dH(f,i),u,()=>dH(f,qc(o,i,{derivedPath:s})??s??nH(i,u)),f)},inPlane:o=>X1(Z9(e,o),t,n,r),inCopy:o=>({...X1(eJ(e,o),t,n,r),broad:void 0})}}function Z9(e,t){let n=[];for(let r of e.verts){let o=xP(t,r);n.push(o.x,o.y)}return Zc(n,tO(t,e.bounds),e.isRect)}function eJ(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 Zc(n,{x:r,y:o,width:i-r,height:s-o},e.isRect&&a)}function tJ(e,t,n,r){return r!==void 0?r(t,n):e.get(t)?.kind==="group"}function yH(e,t,n,r){return tJ(e,t,n,r)===!0}function gH(e,t,n){return t==null||!e||e.get(t)===void 0?null:yH(e,t,[],n)?t:null}function bH(e,t,n){let r=gH(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||!Ct(i))return{parent:o.id,layer:o.layer,local:a=>a};let s=ha(Hh(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 J1(e,t){return e?.axes?.(t)??hc(t)}var xH=new WeakMap;function nJ(e){let t=xH.get(e);return t||(t=()=>e.commit(),xH.set(e,t)),t}function rJ(e,t){let n=t(),r=J1(e,n);if(!r)return null;let{count:o,angles:i}=r,s=()=>{let a=t();if(a!==n){let l=J1(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 oJ(e,t,n){let{overrides:r}=e,o=e.id,i=rJ(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=VP({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:nJ(r)});return c}var wH=new WeakMap;function PH(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 TH(e,t,n){let r=wH.get(e.overrides);r||(r=new Map,wH.set(e.overrides,r));let o=t,i=e.get(o),s=n??Ot,a=r.get(t),l=!a||a.active||!i||J1(s,Hr(e,i))?.count===a.axisCount;if(a&&l)return a;if(!i)return;let u=Hr(e,i),c,d=!1,f=r,p=null;if(p=oJ({id:t,descriptor:s,overrides:e.overrides,get(){let h=e.get(o);return h&&(u=Hr(e,h)),h&&!p?.active&&(c=h.pose),u},set(h){let m=e.get(o);if(m){d=!0;try{PH(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&&!PH(h.pose,c)}),!!p)return r.set(t,p),p}function Jt(e){return e.children!==void 0&&e.children.length>0}function sl(e){return Array.isArray(e)?[...e]:e!==null&&typeof e=="object"?{...e}:e}function SH(e,t){let{scene:n}=e,r=Sy(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(ce(p));if(m&&(i.add(p),s.push({kind:m.kind,id:m.id,layer:m.layer,parent:m.parent,pose:sl(a(m,h)),data:sl(m.data),...m.children!==void 0?{children:[...m.children]}:{},...lr(m),...m.dependsOn!==void 0?{dependsOn:sl(m.dependsOn)}:{},...ky(m),...is(r,m,"jsonKey")}),Jt(m)))for(let y of n.childrenOf(ce(p)))l(y)},u=p=>n.get(ce(p))?.parent,c=p=>sy(o,p,u)!==null,d=new Set,f=p=>{if(d.has(p))return;d.add(p);let h=n.get(ce(p));if(h){for(let m of cc(h))i.has(m)||c(m)||n.get(m)?.hidden!==!0||(f(m),l(m,!0));if(Jt(h))for(let m of n.childrenOf(ce(p)))f(m)}};for(let p of $c(t,u))f(p),l(p,!0);return{items:s}}var iJ=e=>typeof e=="function"||typeof e=="object"&&e!==null&&Object.values(e).some(t=>typeof t=="function");function sJ(e,t){let n={},r=e.registry;for(let o of il){let i=t[o.jsonKey],a=(typeof i=="string"?r[o.field]?.[i]:void 0)??(iJ(t[o.field])?t[o.field]:void 0);a!==void 0&&(n[o.field]=a)}return n}function aJ(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=cc(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 kH(e,t,n,r){let o=t.items;if(o.length===0)return[];let i=new Map(o.map(b=>[b.id,sJ(e.scene,b)])),s=aJ(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 g=e.poseBounds(w.pose,w);g.x<b&&(b=g.x),g.y<x&&(x=g.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,y=b=>{if(d(b))return sl(b.pose);let x=e.translate(sl(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:y(b),data:sl(b.data),...lr(b),...b.children!==void 0?{children:b.children.filter(x=>l.has(x)).map(x=>l.get(x))}:{},...b.dependsOn==="children"?{dependsOn:"children"}:cc(b).length>0?{dependsOn:cc(b).map(x=>l.get(x))}:{},...i.get(b.id)}))}function lJ(e){let t=Ct(e.composition),n=oO(e.composition.compose),r=t?GP(e):void 0,o={getParent:i=>e.get(ce(i))?.parent??null,getPose(i){let s=e.get(ce(i));if(!s)throw new Error(`sceneToAdapter: unknown node "${i}"`);return Jn(e,s)},definesFrame(i){let s=e.get(ce(i));return s===void 0||lt(s)},...r?{childFrame:r}:{}};return{getPose:o.getPose,definesFrame:o.definesFrame,getWorldPose:i=>t?jt(o,i,n):o.getPose(i),worldOfStored(i,s){let a=t?Xn(o,o.getParent(i)):null;return a===null?s:n(ha(o,a,n),s)},...t?{composePose:n}:{},...r?{childFrame:r}:{}}}function vH(e,t={}){let n=t.selection,r=n?.getSelection??n?.get??(()=>[]),o=n?.setSelection??n?.set??(()=>{}),i=t.poseDescriptor??Qo,s=(f,p)=>Ki(f,Gr(i,p)),a=(f,p,h,m)=>HP(f,p,h,m===void 0?i:Gr(i,m)),l={},u=f=>f?{...l,...fH(f,void 0)}:l,c={scene:e,worldPoseOf:f=>d.getWorldPose(f),frameAtOrAbove:f=>Xn(d,f),poseBounds:s,translate:a,...t.pasteInto?{landing:()=>bH(e,t.pasteInto())}:{}},d={...vy(e),getNodes(){let f=ol(e);return e.renderOrderNodes().filter(p=>!f.hidden(p.id))},...lJ(e),poseTarget:(f,p)=>TH(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(ce(f)),applyOps(f,p){p!==void 0?e.applyBatch(f,p,this):cH(this,f)},getSelection:r,setSelection:o,hitTestArea(f,p){return pH(e,f,u(p),i,{includeGroups:!0})},hitTestLasso(f,p,h){return hH(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():ce(p.id),layer:h,pose:p.pose,data:p.data,parent:null}}}:{},snapshotSelection(f){return SH(c,f)},commitPaste(f,p,h){return kH(c,f,p,h)},getPasteOffset(){return{dx:12,dy:12}}};return d}function AH(e,t){return t===void 0||t.start===void 0&&t.end===void 0?e:{...e,...t.start!==void 0?{start:t.start}:{},...t.end!==void 0?{end:t.end}:{}}}var uJ=()=>typeof performance<"u"?performance.now():Date.now();function RH(e,t,n=uJ){let r=e?.colorOverrides,o=e?.trimOverrides;return!r&&!o?t:(i,s,a,l)=>{let u=r?.has(i.id)===!0,c=o?.has(i.id)===!0;if(!u&&!c)return t(i,s,a,l);let d={...l};if(u){let f=n();d.vertexColors=(p,h)=>r.resolve(i.id,p,h,f)}if(c){let f=o.resolve(i.id);d.trim=p=>AH(p,f)}return t(i,s,a,d)}}Z();Z();function NH(e,t,n){let r=t,o=Pr(t);return(i,s,a=t)=>{a!==r&&(r=a,o=Pr(a));let l=e(i,s,a);if(!l)return!1;let u=Re(s),c=u?q.multiply(o,q.fromAffine(u)):o;return hw(l,c,n)}}function EH(e){let t=typeof window<"u"&&window.devicePixelRatio||1;return Math.max(Math.abs(e.scale.x),Math.abs(e.scale.y))*t}var IH,Q1={};function cJ(e){let t=EH(e);return(e!==IH||Q1.pixelScale!==t)&&(IH=e,Q1={pixelScale:t}),Q1}function MH(e,t,n,r){let o=e.kind==="group"?void 0:Yc(e),i=!n||r?.pixelScale!==void 0?r:r?{...r,pixelScale:EH(n)}:cJ(n),s=o?o.paint(e,t,i):[],a=e.data;if(a?.label&&a.text==null){let l=t,u=yP(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"?hy([u]):u]}return s}function CH(e,t){return(n,r,o,i)=>t(Tt(e,n),r,o,i)}function dJ(e,t={}){let{getNode:n,getChildren:r,getPose:o,composePose:i,childFrame:s}=vH(e);return{getLayers:()=>L3(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 OH(e,t,n,r,o,i,s,a){let l=Pa(e),u=Q3(e,g3(l,n)),c=RH(s,u),d=Qc(e),f=w=>d(Tt(e.overrides,w)),p=(w,g,P)=>{let S=e.overrides.read(w.id)?.alpha??1;return W3(c(Tt(e.overrides,w),g,P),g,(o?o(w.id):1)*S)},h=dJ(e,i),m=a?{x:0,y:0,width:a.width,height:a.height}:void 0,y=m&&a?.paintBounds?NH(CH(e.overrides,b3(l,a.paintBounds)),t,m):void 0,b=lH(h,p,t,void 0,f,y),x=a&&m?pw(b,Pr(t),m,a.dpr):b;if(r&&r.length>0)for(let w of r)x.push(w);return[{kind:"group",transform:Pr(t),children:x}]}Z();function FH(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 LH(e,t,n){let r=fJ(e,t,n);return pJ(r),r}function fJ(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 pJ(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 Z1(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)=>MH(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([...gy(e.scene.layers)].map(c=>[fy(c),!1]))};return l.push(...OH(e.scene,i,a,void 0,e.alphaFor,u,e)),e.overlay&&l.push(...e.overlay),{width:r,height:o,view:i,commands:l}}function hJ(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 eS(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??hJ)(s,a),t.width=s,t.height=a,n=t.getContext("webgl2",D3)??void 0)),!n||typeof n.enable!="function")throw new Error("raster session: WebGL2 is unavailable \u2014 supply `gl` or a WebGL2-capable `createCanvas`");if(_H(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=Z1(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 ac({gl:c,width:l,height:u,dpr:1,imageMinification:"mipmap",flattenTolerance:d,bakeBudget:1/0}),r.render(a.commands,Pr(a.view),{screen:s.screen}),_H(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:LH(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 _H(e){return typeof e.isContextLost=="function"&&e.isContextLost()===!0}function tS(e={}){let{families:t,paintKinds:n}=e;if(e.render||e.commands){let r;try{r=e.render?Z1(e.render).commands:[]}catch(i){return Promise.reject(i)}let o=FH([...r,...e.commands??[]]);t??=o.fonts,n??=o.paintKinds.filter(gw)}return Promise.all([ng(t),bw(n)]).then(()=>{})}async function nS(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 al=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 rS=xt(),i2e=rS.reflection;function DH(e,t){rS.set(e,t)}function Ay(e,t){let n=rS.get(e);return n?n(t):null}function BH(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=!Fo(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 HH(e){let t=e?.data?.pathEffect;return t&&typeof t=="object"&&typeof t.kind=="string"?t:null}var oS="kit:clipNothing",iS=()=>null;var GH="kit:unionOfChildren";function UH(e,t){let n=[];for(let o of t){if(o===void 0)continue;let i=sS(o.pose);if(i===null)return null;n.push(i)}if(n.length===0)return null;let r=LO(n);return r===null?null:r}function sS(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 WH(e){return{...e,clipFromPose:{[oS]:iS,...e.clipFromPose},derivePath:{[M1]:C1,...e.derivePath},derivePose:{[GH]:UH,...e.derivePose}}}function KH(e,t){let{undoStack:n,redoStack:r,forks:o,floorId:i,nextEntryId:s}=e,a=0,l=b=>(a+=b.length,b.map(x=>mJ(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 g=l(w),P=g.indexOf(null);return{at:b,entries:P<0?g:g.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 g of w.entries)p.add(g.id);b=!0}h=x}let y=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-y}}function jH(e,t,n){let r=u=>gJ(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 ss(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 VH(e){return typeof e.name!="string"?null:{name:e.name,args:e.args}}function mJ(e,t){let n=[];for(let o of e.forwardOps){let i=VH(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=VH(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 yJ(e,t,n){let r={name:e,args:t,label:n,apply:()=>"noop",invert:()=>r};return r}function zH(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`),yJ(e.name,e.args,t))}function gJ(e,t,n){let r=e.forwardOps.map(i=>zH(i,e.label,t,n)),o=e.baseOps.map(i=>zH(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:ss(r),...e.selectionBefore?{selectionBefore:[...e.selectionBefore]}:{},...e.selectionAfter?{selectionAfter:[...e.selectionAfter]}:{}}}function $H(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 aS(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 ur(e,t=[]){return{kind:e,entries:t.map(n=>({id:n.id,label:n.label,ops:n.forwardOps}))}}function YH(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 qH(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 ss(t))o.add(i);e.touchedIds=o}function XH(e){for(let t=0;t<e.length;t++)if(e[t].caused!==void 0)return!0;return!1}var Ry=new WeakMap;function JH(e){let t=Ry.get(e);if(!t)throw new Error("Journal is not resumable (already committed or cancelled)");t()}function QH(e,t,n,r,o={}){let i=nd(t,{...o,...n.coalesceWindowMs!==void 0?{coalesceWindowMs:n.coalesceWindowMs}:{}}),s=o.selection,a=0,l=Ce();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,y){if(f!=="active")throw new Error("Journal is not active");i.applyOps(m,y)},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:y,baseOps:b}=lS(i).appliedOps();lS(e).record(y,b,m,d?{selectionBefore:d}:void 0),f="closed",Ry.delete(h),r?.(),u()},cancel(){if(f!=="active")throw new Error("Journal is not active");i.goto(0),f="closed",Ry.delete(h),r?.(),u()},suspend(){if(f!=="active")throw new Error("Journal is not active");f="suspended",r?.(),u()},isActive(){return f==="active"}};return Ry.set(h,()=>{if(f!=="suspended")throw new Error("Journal is not suspended");f="active",u()}),h}var ZH=new WeakMap;function lS(e){let t=ZH.get(e);if(!t)throw new Error("Not a history built by createHistory");return t}var bJ={log:()=>{},warn:()=>{}};function nd(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??bJ,m=1,y=0,b=-1,x=Ce(),w=Ce();function g(G){y++,G&&w.size>0&&w.emit(typeof G=="function"?G():G),x.emit()}function P(G){if(l)for(let j of G)try{l({id:j.id,label:j.label,forwardOps:j.forwardOps,baseOps:j.baseOps})}catch($){h.warn(`onEvict callback threw for entry id=${j.id} "${j.label}": ${String($)}`)}}function S(G){P(G);for(let j of G){let $=c.get(j.id);if($){c.delete(j.id);for(let ee of $)S(ee)}}}function v(G){for(let j of G){l&&P([j]);let $=c.size>0?c.get(d):void 0;if($!==void 0&&c.delete(d),d=j.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 j=r.splice(0);if(!u)return S(j);let $=c.get(G);$?$.push(j.reverse()):c.set(G,[j.reverse()])}function M(){for(;n.length>a;)v([n.shift()])}let C=YH(e,h);function F(G){return[...G.baseOps].reverse().map(j=>j.invert())}function D(){return p?[...p.get()]:void 0}function B(G){let j=D(),$=G.forwardOps!==G.baseOps;C(F(G),$?()=>G.forwardOps:void 0),j&&(G.selectionAfter=j),p&&G.selectionBefore&&p.set(G.selectionBefore)}function K(G){let j=D(),$=G.forwardOps!==G.baseOps;C(G.forwardOps,$?()=>F(G):void 0),j&&(G.selectionBefore=j),p&&G.selectionAfter&&p.set(G.selectionAfter)}function W(G){let j=[];for(;n.length>G;){let $=n[n.length-1];B($),n.pop(),r.push($),j.push($)}for(;n.length<G&&r.length>0;){let $=r[r.length-1];K($),r.pop(),n.push($),j.push($)}return j}function Q(G,j){let $=typeof i=="function"?i():i;return!($>0)||G.coalesceKey!==void 0||y!==b||s()-G.timestamp>$?!1:$H(G.forwardOps,j)}function le(G,j){if(G.length===0)return;let $=D(),ee=[],te=C(G,void 0,ee),he=ee.length===0?G:G.filter(vt=>!(vt.elideNoop&&ee.includes(vt))),xe=XH(he)?he.flatMap(vt=>vt.caused?.()??[vt]):he.slice();if(!te){h.warn(`'${j}' 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(xe.length===0)return;let Le=ss(xe),Se=n[n.length-1];if(Se&&Q(Se,xe)){if(Se.forwardOps=xe,Se.timestamp=s(),Se.pushes++,Le.size>0){let vt=new Set(Se.touchedIds);for(let Qt of Le)vt.add(Qt);Se.touchedIds=vt}h.log(`coalesce '${j}' into entry id=${Se.id} (${xe.length} ops)`),g(()=>({kind:"coalesce",entries:[{id:Se.id,label:Se.label,ops:xe}]})),b=y;return}h.log(`push '${j}' (${xe.length} ops)`);let cr=A(),_e={id:m++,forwardOps:xe,baseOps:xe,label:j,timestamp:s(),pushes:1,touchedIds:Le,...$?{selectionBefore:$}:{}};n.push(_e),N(cr),M(),g(()=>ur("push",[_e])),b=y}function ke(G,j){qH(G,j,s()),g(()=>({kind:"coalesce",entries:[{id:G.id,label:G.label,ops:j}]})),b=y}function ue(G,j,$,ee={}){if(G.length===0)return;let te=ee.coalesceKey,he=n[n.length-1];if(te!==void 0&&he?.coalesceKey===te&&y===b&&G===j)return ke(he,G);let xe=A(),Le={id:m++,forwardOps:G,baseOps:j,label:$,timestamp:s(),pushes:1,touchedIds:ss(G),...ee.selectionBefore?{selectionBefore:[...ee.selectionBefore]}:{},...te!==void 0?{coalesceKey:te}:{}};n.push(Le),N(xe),M(),g(()=>ur("push",[Le])),te!==void 0&&(b=y)}let ve={apply(G,j){le([G],j??G.label??"")},applyOps(G,j){le(G,j)},undo(){n.length!==0&&g(ur("undo",W(n.length-1)))},redo(){r.length!==0&&g(ur("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&&g(ur("clear"))},entries(){return{undo:n.map(aS),redo:[...r].reverse().map(aS)}},goto(G){let j=n.length+r.length;if(G<0||G>j||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!==$&&g(),te}g(ur("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 j=n.length;for(;j>0&&n[j-1].timestamp>G;)j--;if(j<n.length)return j;for(let $=r.length-1;$>=0&&r[$].timestamp<=G;$--)j++;return j},prune(G){let j=0;for(;j<n.length&&n[j].timestamp<G;)j++;if(j===0)return;let $=n.splice(0,j);v($),g(ur("prune",$))},branches(){let G=($,ee)=>{let te=$[0];return{id:te.id,label:te.label,timestamp:te.timestamp,length:$.length,current:ee}},j=(c.get(A())??[]).map($=>G($,!1));return r.length>0&&j.push(G([...r].reverse(),!0)),j.sort(($,ee)=>$.id-ee.id)},switchBranch(G){if(r[r.length-1]?.id===G)return;let j=A(),$=c.get(j)??[],ee=$.findIndex(he=>he[0].id===G);if(ee<0)throw new Error(`No branch ${G} forks from entry ${j}`);let[te]=$.splice(ee,1);r.length>0&&$.push(r.splice(0).reverse()),$.length>0?c.set(j,$):c.delete(j),r.push(...[...te].reverse()),g(ur("branch",te))},getVersion:()=>y,subscribe:x.subscribe,observe:w.subscribe,serialize:()=>KH({undoStack:n,redoStack:r,forks:c,floorId:d,nextEntryId:m},h),recordEntry(G,j,$){ue(G,G,j,$)},allForwardOps(){let G=[];for(let j of n)for(let $ of j.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 j=QH(ve,e,G,()=>{o=null},{coalesceWindowMs:i,now:s,debug:h,...p?{selection:p}:{}});return o=j,j},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");JH(G),o=G},restore(G){let j=jH(G,f,h);n.splice(0,n.length,...j.undoStack),r.splice(0,r.length,...j.redoStack),c.clear();for(let[$,ee]of j.forks)c.set($,ee);d=j.floorId,m=j.nextEntryId,g(ur("restore"))}};return ZH.set(ve,{appliedOps:()=>({forwardOps:n.flatMap(G=>G.forwardOps),baseOps:n.flatMap(G=>G.baseOps)}),record:ue}),ve}function e4(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(xJ(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*xJ(e){for(let[t,n]of e)yield[t,{pose:n}]}var wJ=Object.freeze({}),t4=new WeakMap;function PJ(e,t){let n=t4.get(e);n===void 0&&t4.set(e,n=new WeakMap);let r=n.get(t);return r===void 0&&n.set(t,r=o=>t(e(o))),r}var TJ={merge:PJ,lerp:(e,t,n)=>n<.5?e:t};function n4(e){let t=I1({pose:Vh(),alpha:zP(),path:Vh(),data:TJ}),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:lT(0,(a,l)=>e.get(l)?.[s]??wJ,{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 o4(){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 r4=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},uS=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height;function i4(e,t,n){for(let r=e.length-1;r>=0;r--){let o=e[r];if(o.path===void 0)continue;let i=r4(o.pose),s=r4(t);if(i===null||s===null||uS(i,s))return o.path;let a=n.carried;return a!==void 0&&a.source===o.path&&uS(a.from,i)&&uS(a.to,s)?a.path:(n.carried={source:o.path,from:{...i},to:{...s},path:Ch(o.path,i,s)},n.carried.path)}}function cS(e,t){let n=o4(),{plies:r}=n,o=n4(r),i=Ce(),s=0,a=new Map;function l(f){let p=e(f);if(p){un(p);let h=EO(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=i4(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:()=>e4(d,f=>r.get(f))};return d}function Ny(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 Ny({placed:[...o].reverse().map(i=>({id:i.id,from:i.to,to:i.from}))},void 0,n)}}}DH("arrange",e=>Ny(e));function s4(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 a4(e){let{nodes:t}=e,n=null,r=!1,o=null,i=new Map,s=new Set,a=null,l=Ce(),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 y=u();if(m===null||y===null)return[];let b=s4(t,m,!0),x=s4(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 g=y(b,w,x);if(g===null)throw new al(b);let P=[];for(let[S,v]of g){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,Ny({},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,y,b){if(o===null||y===null||y===b)return;s.add(y);let x=o.get(y);x===void 0?o.set(y,[m]):x.includes(m)||x.push(m)},noteDeparture(m,y,b){if(o===null||y===null||y===b||(s.add(y),o.get(y)?.includes(m)))return;let x=i.get(y);x===void 0?i.set(y,[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,y){let{ops:b,owned:x}=h(m);if(!x)return y(b),!0;try{return y(b),d(),!0}catch(w){if(!(w instanceof al))throw w;return!1}finally{p()}}}}function l4(){let e=Ce(),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 u4(e,t){return{subscribe:e.subscribe,getVersion:e.version,getContentVersion:()=>e.version()-t.changes()}}function c4(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 SJ=()=>{};function d4(e){let t=Ce(),n=new Map,r=c4(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,g,P){if(!c())return;let S=n.get(x);S?S.to=g:n.set(x,{id:x,from:w,to:g,...d(P)})}function p(x,w){if(c())for(let g of x)n.set(g.id,{id:g.id,from:r.takeBack(g.id),to:g.pose,...d(w)})}let h=(x,w,g)=>c()?r.seeOff(x,w,d(g),n):SJ;function m(x,w,g){w();try{return x()}finally{g()}}let y={"kit:setPose":x=>({...x,apply:w=>{x.apply(w);let g=w;f(g.id,g.from,g.to,!1)},revert:w=>{x.revert(w);let g=w;f(g.id,g.to,g.from,!0)}}),"kit:add":x=>({...x,apply:w=>{x.apply(w),c()&&p([w],!1)},revert:w=>{let g=h([w],[w],!0);x.revert(w),g()}}),"kit:remove":x=>({...x,apply:w=>{let g=w,P=h(g.detached,g.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(g=>!ro(g.from,g.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 g=!0;return()=>{g&&(g=!1,u--,w())}},labeled(x,w,g){if(o!==null)return g();o=x,i=w;try{return g()}finally{o=null}},replaying:x=>m(x,()=>{s++},()=>{s--}),layout:x=>m(x,()=>{a++},()=>{a--}),quiet:x=>m(x,()=>{l++},()=>{l--}),reporting:x=>(w,g)=>x(w,y[w]?.(g)??g)}}function f4(){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 p4="kit:setDoc";function dS(e,t,n){n===void 0?e.delete(t):e.set(t,n)}function h4(e){return{toJSON(){return e.size===0?void 0:Object.fromEntries(e)},reset(t){e.clear();for(let[n,r]of Object.entries(t??{}))dS(e,n,r)}}}function m4(e){let{values:t}=e;return e.register(p4,{apply:n=>{let{key:r,to:o}=n;dS(t,r,o)},revert:n=>{let{key:r,from:o}=n;dS(t,r,o)}}),{get:n=>t.get(n),set(n,r){let o=t.get(n);ro(o,r)||e.record(p4,{key:n,from:o,to:r},"setDoc")},keys:()=>[...t.keys()]}}function Iy(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)=>Iy(n,t[r]));if(tn(e)&&tn(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(r=>r in t&&Iy(e[r],t[r]))}return!1}function y4(e,t,n){n===void 0?delete e[t]:e[t]=n}var g4={units:"kit:setUnits",clip:"kit:setClip"};function b4(e){for(let n of["units","clip"])e.register(g4[n],{apply:r=>{let{id:o,to:i}=r;y4(e.requireNode(o),n,i)},revert:r=>{let{id:o,from:i}=r;y4(e.requireNode(o),n,i)}});let t=(n,r,o)=>(i,s)=>{let a=e.requireNode(i)[n];e.refuse(i,o),!Iy(a,s??void 0)&&e.record(g4[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 x4(e,t,n){let r=HH({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 w4(e){return{bounds:e?.bounds??(t=>{let n=sS(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 fS(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 kJ=16;function P4(e,t,n,r,o,i=new Map){let s=new Map,a=w=>s.get(w)??Hr(e,e.get(w)),l={getPose:w=>a(w),getParent:w=>e.get(w)?.parent??null,definesFrame:w=>{let g=e.get(w);return g===void 0||lt(g)}},{compose:u,decompose:c}=e.composition,d=w=>jt(l,w,u),f=[...new Set([...n.keys(),...r])],p=new Map,h=(w,g)=>{let P=a(w);Fo(P,g)||(s.set(w,g),w!==m&&t(w)!==null&&fS(o,w,P,g)&&f.push(w))},m=null,y=w=>{let g=BH(d(w),e.composition,S=>o.bounds(S,w),(S,v,A)=>o.remap(S,v,A,w));if(g===null)return null;let P=e.childrenOf(w).map(S=>({id:S,pose:g.toStrategy(d(S))}));return{...g,container:{id:w,bounds:g.bounds},children:P}},b=(w,g,P)=>{if(P.bounds){let S=e.get(w),v=g.toWorld(o.remap(g.upright,g.container.bounds,P.bounds,w));h(w,ma(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,ma(l,g.toWorld(v),w,u,c)),x(A,N)}},x=(w,g)=>{let P=o.bounds(d(w),w);if(g===null||P===null)return;let S=P.x-g.x,v=P.y-g.y;if(S===0&&v===0)return;let A=BO({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 g=(p.get(w)??0)+1;if(p.set(w,g),g>kJ)continue;let P=t(w);if(P===null||e.get(w)===void 0)continue;let S=g===1?n.get(w):void 0,v=g===1?i.get(w):void 0,A=!1;if(v!==void 0&&P.depart){let N=y(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=y(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=y(w);if(N===null)continue;b(w,N,{poses:P.childPoses(N.container,N.children)})}}return s}function T4(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,y){let b=o(m);s(m,"update"),c("kit:setData",{id:m,from:b.data,to:y.data},"update")},setPose(m,y){let b=o(m);s(m,"set the pose of");let x=b.layout!==void 0&&fS(t,m,b.pose,y),w=b.parent===null?void 0:o(b.parent),g=w?.layout!==void 0?w.id:null;d("setPose",x||g!==null,()=>{x&&p(m),p(g),c("kit:setPose",{id:m,from:b.pose,to:y},"setPose")})},setLayer(m,y){l(y);let b=o(m);if(s(m,"relayer"),b.layer!==y&&a(y,"move nodes onto"),b.parent!==null){let w=o(b.parent);u(m,y,b.parent,w.layer,"relayer")}if(b.layer===y)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:y},"setLayer"):f("setLayer",()=>{for(let w of x){let g=o(w);g.layer!==y&&c("kit:setLayer",{id:w,from:g.layer,to:y},"setLayer")}})},setDependsOn(m,y){let b=o(m);if(s(m,"retarget"),TO(b.dependsOn,y))return;let x=x4(b.data,b.dependsOn,y);if(x===null)return void c("kit:setDependsOn",{id:m,from:b.dependsOn,to:y},"setDependsOn");f("setDependsOn",()=>{c("kit:setDependsOn",{id:m,from:b.dependsOn,to:y},"setDependsOn"),c("kit:setData",{id:m,from:b.data,to:x},"setDependsOn")})},setLayout(m,y){let b=o(m);s(m,"set the layout of");let x;if(typeof y=="string"){if(x=n.fnOf(y)??null,x===null)throw new Error(`Scene: no layout "${y}" in this scene's registry`)}else x=y;let w=b.layout??null;if(w===x)return;x!==null&&h();let g=w===null?void 0:n.keyOf(w),P=x===null?void 0:n.keyOf(x),S={id:m,...g!==void 0?{fromKey:g}:{},...P!==void 0?{toKey:P}:{}};r.set(S,{from:w,to:x}),d("setLayout",!0,()=>{p(m),c("kit:setLayout",S,"setLayout")})}}}function S4(e,t){t===void 0?delete e.parallax:e.parallax=t}function k4(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=>{S4(t.layers[n(s.layer)],s.to)},revert:s=>{S4(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 vJ(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 v4(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 y(g,P){e.register(g,P)}let b=vJ(e);y("kit:add",{apply:g=>{if(t.nodes.has(g.id))throw new Error(`Scene: id collision on "${g.id}"`);let P={kind:g.kind,id:g.id,layer:g.layer,pose:g.pose,data:g.data,parent:g.parent};t.nodes.set(g.id,P),p(g.id,g.parent,g.index),g.dependsOn!==void 0&&(P.dependsOn=g.dependsOn),Object.assign(P,lr(g)),e.noteWritten(P),i.add(g.id,g.dependsOn==="children"?[]:g.dependsOn??[]),u(g.id,g.dependsOn);let S=P,v=h.get(g);for(let A of o){let N=v?.get(A);if(N!==void 0){A.write(S,N);continue}let M=g[A.spec.opKey];M!==void 0&&td(A,S,M,"kit:add",Mt)}a(g.id)},revert:g=>{e.clearOverride(g.id),f(g.id),t.nodes.delete(g.id),i.remove(g.id),s.delete(g.id),l(g.parent),a(g.id)}}),y("kit:remove",{apply:g=>{for(let P of g.nodes)e.clearOverride(P.id);for(let P of g.detached)f(P.id);for(let P of g.nodes)t.nodes.delete(P.id),i.remove(P.id),s.delete(P.id);for(let P of g.detached)l(P.parent);e.narrowSelection(new Set(g.nodes.map(P=>P.id)))},revert:g=>{let P=new Map((g.fnKeys??[]).map(S=>[S.id,S]));for(let S of g.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 g.detached)p(S.id,S.parent,S.index);for(let S of g.detached)l(S.parent)}}),y("kit:setPose",{apply:g=>{d(g.id).pose=g.to,a(g.id)},revert:g=>{d(g.id).pose=g.from,a(g.id)}}),y("kit:setData",{apply:g=>{d(g.id).data=g.to,a(g.id)},revert:g=>{d(g.id).data=g.from,a(g.id)}}),y("kit:setLayer",{apply:g=>{n(g.to),d(g.id).layer=g.to,r(),a(g.id)},revert:g=>{d(g.id).layer=g.from,r(),a(g.id)}}),y("kit:setDependsOn",{apply:g=>{c(g.id,g.to)},revert:g=>{c(g.id,g.from)}});let x=new WeakMap;function w(g,P){let S=d(g.id),v=o.find(C=>C.spec.field==="layout"),A=x.get(g),N=P==="from"?g.fromKey:g.toKey;if(A===void 0&&N!==void 0){delete S.layout,td(v,S,N,"kit:setLayout",Mt);return}let M=A?.[P]??null;M===null?delete S.layout:v.write(S,M)}return y("kit:setLayout",{apply:g=>{w(g,"to")},revert:g=>{w(g,"from")}}),y("kit:move",{apply:g=>b(g.id,g.fromParent,g.toParent,g.toIndex),revert:g=>b(g.id,g.toParent,g.fromParent,g.fromIndex)}),k4(e),{layoutRefs:x}}function A4(e,t,n){n?e[t]=!0:delete e[t]}var R4={hidden:"kit:setHidden",locked:"kit:setLocked"};function N4(e){for(let n of["hidden","locked"])e.register(R4[n],{apply:r=>{let{id:o,to:i}=r,s=e.requireNode(o);A4(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);A4(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(R4[n],{id:o,from:s,to:i},r)};return{setHidden:t("hidden","setHidden"),setLocked:t("locked","setLocked")}}function I4(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 AJ(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 E4(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),AJ(n,c,s,a),o("kit:moveLayer",{layer:s,from:l,to:u},"moveLayer")}}}var ll=class extends Error{};function M4(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||!Jt(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 RJ(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=is(r,a,"opKey");return Object.keys(l).length===0?[]:[{id:a.id,...l}]});return{nodes:o,detached:i,...s.length>0?{fnKeys:s}:{}}}function C4(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:y}=e.arrivals;function b(w){let g=w.id??e.generateId();if(t.has(g))throw new ll(`Scene: id collision on "${g}"`);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:g,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,lr(w),is(n,w,"opKey"))}function x(w){if(w.length===0)return;let{ids:g,removing:P}=s(w);for(let A of g)l(A,"remove");let S=RJ(g,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 g of w){let P=b(g);e.runOp("kit:add",P),a(g,P.id,null)}})},add(w){let g=b(w),P=`add ${w.kind}`;return p(P,g.parent!==null,()=>(h(g.id,g.parent,null),f("kit:add",g,P),a(w,g.id,g),g.id))},remove:w=>x([w]),removalClosure:w=>s(w).ids,removeMany:x,move(w,g,P){let S=r(w);if(l(w,"move"),g!==null){l(g,"move nodes into");let A=r(g);if(d(w,S.layer,g,A.layer),g===w)throw new Error("Scene: cannot parent a node to itself");let N=[];if(i(w,N),N.includes(g))throw new Error("Scene: cannot parent a node to its own descendant")}let v=S.parent;p("move",g!==null||v!==null,()=>{let A=o(v).indexOf(w),N=P??o(g).length;h(w,g,v),m(w,v,g),y(v),f("kit:move",{id:w,fromParent:v,fromIndex:A,toParent:g,toIndex:N},"move")})},reorder(w,g){let P=r(w);l(w,"reorder");let S=P.parent;p("reorder",S!==null,()=>{y(S);let v=o(S).indexOf(w);f("kit:move",{id:w,fromParent:S,fromIndex:v,toParent:S,toIndex:g},"reorder")})}}}function O4(e){let{state:t,store:n,locks:r,layers:o,fnFields:i,recorder:s,arrivals:a}=e,{layoutRefs:l}=v4({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}=C4({nodes:t.nodes,generateId:e.generateId,store:n,locks:r,layers:o,fnFields:i,runOp:e.ops.run,recorder:s,arrivals:a}),d=T4({store:n,locks:r,layers:o,recorder:s,arrivals:a,layoutFrame:e.layoutFrame,layoutField:i.find(y=>y.spec.field==="layout"),layoutRefs:l}),f=E4({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=N4({register:e.ops.register,requireNode:n.requireNode,record:s.record,narrowSelection:()=>e.narrowSelection(),invalidateDependents:n.invalidateDependents,noteWritten:r.noteWritten}),h=b4({register:e.ops.register,requireNode:n.requireNode,refuse:r.refuse,record:s.record}),m=m4({values:t.docValues,register:e.ops.register,record:s.record});return{construct:u,methods:{...c,...d,...f,...p,...h,doc:m}}}var NJ={log:e=>Ah("history",e),warn:e=>Mt("history",e)};function F4(e,t={}){let n=t.rebuildOp;return nd(e,{debug:NJ,...t,rebuildOp:(r,o)=>n?.(r,o)??Ay(r,o)})}function L4(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 IJ=()=>({added:new Set,removed:new Set,posed:new Set,reparented:new Set,dataChanged:new Set,docChanged:new Set}),EJ=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)}),_4={name:"editPass",args:{},elideNoop:!0,apply:()=>"noop",invert:()=>_4};function MJ(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 D4(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(EJ(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=IJ(),!0)},note(o,i){n!==null&&!e.untracked()&&MJ(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:()=>_4}}}}function CJ(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 B4(e){let t=new WeakMap,n=[],r={wrap(o){let i=CJ(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 G4(e){let{engine:t,replay:n,notify:r,refuseUntracked:o,runArrivalEdit:i}=e,s=B4(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){Mt("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 U4(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 rd(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:()=>rd(e.invert(),t)}}function pS(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 Mt("scene",`restored op "${e.name??"?"}" has no history adapter \u2014 skipping (setHistoryAdapter was not wired)`),"noop";try{return e.apply(n())}catch(r){return Mt("scene",`restored op "${e.name??"?"}" failed against the history adapter \u2014 skipping: ${String(r)}`),"noop"}},invert:()=>pS(e.invert(),t)}}function OJ(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 W4(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=>OJ(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=Ay(o,i);return a===null?null:pS(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,rd(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 V4(e){for(let t=e.length-1;t>=0;t--)try{e[t].invert().apply(void 0)}catch{}}function z4(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 y of i.settle())e.writePose(y.id,y.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 y=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,y,b),()=>(a?.ops.length??0)>0);return y&&i.emitReflow(),x}catch(x){throw V4(a?.outer??[]),a=null,x}}),()=>{if(y&&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,y=[];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"||(y.push(rd(b,p)),h.ops.push(y[y.length-1]))}},()=>!1)}catch(b){throw V4(y),h.ops.length=m,b}h.outer.push(...y)},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 K4(e){let{notifier:t,mode:n,stale:r,lifted:o,selection:i,arrivals:s,config:a,poseWrites:l}=e,{notify:u}=t,c=D4({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=U4({driven:n.open,replayAlone:M=>{P(M),u()},skips:r.skips,applied:(M,C,F)=>{n.records()||b(M,C,F)}}),p=W4({own:(M,C)=>f.handlers.has(M)?f.op(M,C):null,recorder:()=>x,driving:M=>t.deferred(()=>n.during("engine",()=>y(M,()=>!0))),getActiveJournal:a.getActiveJournal??null,openJournal:()=>N()}),h=F4(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=L4({registered:f.handlers,lifted:o,getSelection:i.get,setSelection:i.replace,notify:u}),{atomically:y,logApplied:b}=m,x=z4({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:g}=x;function P(M){l.replaying(()=>y(()=>o(()=>r.during(()=>g(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}=G4({engine:h,applying:M=>y(()=>g(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,D=>p.apply(h,D,C,F)))},history:v,...A,batch:x.batch,untracked:x.untracked,setActiveJournalAccessor:p.setActiveJournalAccessor,setHistoryAdapter:p.setHistoryAdapter,addEditPass:c.add}}}function j4(e,t){let n=s=>$c(e(s),t),r=[],o=0,i=Ce();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 $4(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))&&$3(r,i);return{isLocked:o,isHidden:i=>j3(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=ol(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 Y4(e,t,n){let r=PO(),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 g of w)for(let P of r.transitiveDependentsOf(g)){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 g=e.nodes.get(w);if(g===void 0)return;if(o.has(w)){un(g);for(let P of r.transitiveDependentsOf(w)){let S=e.nodes.get(P);S!==void 0&&un(S)}}w=g.parent}}function a(x,w){w==="children"?o.add(x):o.delete(x)}function l(x,w){let g=u(x);w===void 0?delete g.dependsOn:g.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 ll(`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),g=c(w.parent),P=g.indexOf(x);if(P<0)throw new Error(`Scene: node "${x}" not found in its parent's children`);return g.splice(P,1),t(),{parent:w.parent,index:P}}function f(x,w,g){let P=c(w),S=Math.max(0,Math.min(g,P.length));P.splice(S,0,x);let v=u(x);v.parent=w,t()}function p(x,w){let g=e.nodes.get(x);if(g?.children)for(let P of g.children)w.push(P),p(P,w)}function h(x){let w=[],g=new Set;function P(S){if(g.has(S))return;g.add(S),w.push(S);let v=[];p(S,v);for(let A of v)g.has(A)||(g.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:g}}let m=new WeakMap;function y(x,w,g){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))}g&&S.size>0&&m.set(g,S)}function b(x,w){if(!w)return;let g=x;for(let P of n){if(P.read(g)!==void 0)continue;let S=w[P.spec.opKey];S!==void 0&&td(P,g,S,"kit:remove",Mt)}}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:y,restoreNodeFunctions:b}}function q4(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(),y=e.nodes.get(m);if(y&&(y.layer===f&&p.push(m),Jt(y)))for(let b=y.children.length-1;b>=0;b--)h.push(y.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(),y=e.nodes.get(m);if(y&&(y.layer===f&&p.push(y),Jt(y)))for(let b=y.children.length-1;b>=0;b--)h.push(y.children[b])}return p}function c(){let f=e.layers.map(()=>[]),p=[...e.roots].reverse();for(;p.length>0;){let m=p.pop(),y=e.nodes.get(m);if(!y)continue;let b=f[e.layerIndex.get(y.layer)??-1];if(b&&b.push(m),Jt(y))for(let x=y.children.length-1;x>=0;x--)p.push(y.children[x])}let h=[];for(let m of f)for(let y of m)h.push(y);return h}function d(){let f=e.layers.map(()=>[]),p=[...e.roots].reverse();for(;p.length>0;){let m=p.pop(),y=e.nodes.get(m);if(!y)continue;let b=f[e.layerIndex.get(y.layer)??-1];if(b&&b.push(y),Jt(y))for(let x=y.children.length-1;x>=0;x--)p.push(y.children[x])}let h=[];for(let m of f)for(let y of m)h.push(y);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 y=h.get(m.layer);y||h.set(m.layer,y=[]),y.push(m)}p.byLayer=h}return h.get(f)??s},invalidate:i}}function X4(e,t){let n=[],r=[...e].reverse();for(;r.length>0;){let o=t.get(r.pop());if(o&&(n.push(o),Jt(o)))for(let i=o.children.length-1;i>=0;i--)r.push(o.children[i])}return n}function hS(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 yS(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 J4(e,t,n){let r=[];for(let i of X4(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,is(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=FJ(e,t,n);return e.version===3?r:hS(r,n.composition??Rh)}function FJ(e,t,n){let r;if(e.version===1)r=e.nodes.map(o=>({n:o,kind:mS(1,o,n.classifyV1)}));else if(e.version===2||e.version===3)r=e.nodes.map(o=>({n:o,kind:mS(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 il){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 LJ(e.version,s)&&(s.clip="outline"),s})}function LJ(e,t){return e===1&&t.kind==="group"&&t.clipFromPose===void 0}function mS(e,t,n){return e===2?t.kind:t.kind==="leaf"?"mark":n?n(t):"group"}function Q4(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 Z4(e,t,n,r){let o={nodes:new Map,roots:[],layers:[],layerIndex:new Map,docValues:new Map},i=q4(o),s=Sy(e,f=>{f==="layout"&&n()}),a=Y4(o,i.invalidate,s),l=I4(o,i.invalidate);l.reset(t);let u=$4(o),c=h4(o.docValues);c.reset(r);let d={...Q4(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:()=>J4(o,s,c.toJSON())};return{state:o,order:i,locks:u,stale:M4(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 _J(e,t){let n=e.get(t);return n&&{node:n,pose:Jn(e,n)}}var DJ=0,BJ=()=>ce(`n${(DJ++).toString(36)}-${Math.random().toString(36).slice(2,8)}`);function HJ(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 GJ(e,t,n,r){if(t.length===0)throw new Error("Scene: systemLayers must declare at least one layer");let o=WH(e.registry??{}),i=Z4(o,t,()=>h.layoutDeclared(),r),{state:s,locks:a,reads:l}=i,u=l4(),c=f4(),d=d4({untracked:c.untracked,changes:u,shown:v=>_J(P,v)}),f=(v,A)=>d.layout(()=>P.setPose(ce(v),A)),p=w4(e.layoutFrame),h=a4({nodes:s.nodes,layoutPass:(v,A,N)=>P4(P,l.layoutOf,v,A,p,N),recordsBareEdits:()=>!c.open(),writePose:f}),m=HJ(e.generateId??BJ,v=>s.nodes.has(v)),y=j4(a.reachable,v=>s.nodes.get(v)?.parent);y.subscribe(u.notify);let b=cS(v=>s.nodes.get(v),i.store.invalidateDependents),x=DO(),w=K4({notifier:u,mode:c,passAdapter:()=>({...vy(P),...uH(P)}),stale:i.stale,lifted:a.lifted,selection:y,arrivals:h,writePose:f,poseWrites:d,config:e}),g=O4({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:y.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??Rh,...g.methods,...w.methods,unlocked:v=>a.lifted(v),setArrivalHandler:h.setHandler,onReflow:h.onReflow,onPoseWrite:d.subscribe,overrides:b,scroll:x,getSelection:y.get,setSelection:v=>y.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(yS),v.doc),w.clearHistory(),d.quiet(()=>g.construct(N)),y.replace(y.legal(y.get().filter(M=>s.nodes.has(M)))),u.notify()},...u4(u,y)},S=n(o);return S&&(d.quiet(()=>g.construct(S)),u.notify()),P}function My(e,t={}){return GJ(t,e.systemLayers.map(yS),n=>Ey(e,n,t),e.doc)}Z();var eG="__weaselHeadless";function tG(e){return kb(e)}var WJ=eS();function nG(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 VJ(e){let{scene:t,screen:n,format:r,overlay:o,...i}=e,s={...i,scene:My(tG(t)),...o?{overlay:o}:{},...n?{screen:Float64Array.from(n)}:{}};await tS({render:s});let a=WJ.render(s);if(r==="png"){let u=await nS(a);return{width:a.width,height:a.height,base64:nG(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:nG(l)}}var zJ={render:VJ};globalThis[eG]=zJ;})();
|
|
431
431
|
/*! Bundled license information:
|
|
432
432
|
|
|
433
433
|
polygon-clipping/dist/polygon-clipping.umd.js:
|