msdfgen-ts 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- var MsdfgenTs=(function(gt){"use strict";function bi(e,t,n,s){return e*n+t*s}function Q(e,t,n,s){return e*s-t*n}function Ue(e,t,n){return(1-n)*e+n*t}function ut(e){return+(e>0)-+(e<0)}function jt(e){return 2*+(e>0)-1}function Te(e,t,n,s){if(t===0||Math.abs(n)>1e12*Math.abs(t))return n===0?s===0?-1:0:(e[0]=-s/n,1);const o=n*n-4*t*s;if(o>0){const i=Math.sqrt(o);return e[0]=(-n+i)/(2*t),e[1]=(-n-i)/(2*t),2}else if(o===0)return e[0]=-n/(2*t),1;return 0}function wi(e,t,n,s){const o=t*t,i=1/9*(o-3*n),r=1/54*(t*(2*o-9*n)+27*s),c=r*r,a=i*i*i,l=t*(1/3);if(c<a){let h=r/Math.sqrt(a);h<-1&&(h=-1),h>1&&(h=1),h=Math.acos(h);const f=-2*Math.sqrt(i);return e[0]=f*Math.cos(.3333333333333333*h)-l,e[1]=f*Math.cos(.3333333333333333*(h+2*Math.PI))-l,e[2]=f*Math.cos(.3333333333333333*(h-2*Math.PI))-l,3}else{const h=(r<0?1:-1)*Math.pow(Math.abs(r)+Math.sqrt(c-a),.3333333333333333),f=h===0?0:i/h;return e[0]=h+f-l,h===f||Math.abs(h-f)<1e-12*Math.abs(h+f)?(e[1]=-.5*(h+f)-l,2):1}}function Ai(e,t,n,s,o){if(t!==0){const i=n/t;if(Math.abs(i)<1e6)return wi(e,i,s/t,o/t)}return Te(e,n,s,o)}const ki=24;function fn(e,t,n,s){return((s+e)*s+t)*s+n}function Ui(e,t,n,s,o,i,r){const c=i<0;let a=s-i*(o-s)/(r-i);a>s&&a<o||(a=.5*(s+o));for(let l=0;l<ki;l++){const h=fn(e,t,n,a);if(h===0)return a;h<0===c?s=a:o=a;const f=(3*a+2*e)*a+t;let u=a-h/f;u>s&&u<o||(u=.5*(s+o));const p=u-a;if(a=u,(p<0?-p:p)<=1e-15*(a<0?-a:a))break}return a}function En(e,t,n,s,o,i,r,c,a){return i===0?c[a++]=s:i<0!=r<0&&(c[a++]=Ui(e,t,n,s,o,i,r)),a}function Ti(e,t,n,s,o,i){let r=0;if(e===0){if(t===0)return 0;const u=-n/t;return u>=s&&u<=o&&(i[r++]=u),r}const c=t*t-4*e*n;if(c<0)return 0;const a=Math.sqrt(c),l=-.5*(t+(t<0?-a:a));let h,f;if(l===0)h=0,f=0;else if(h=l/e,f=n/l,h>f){const u=h;h=f,f=u}return h>=s&&h<=o&&(i[r++]=h),f!==h&&f>=s&&f<=o&&(i[r++]=f),r}function Si(e,t,n,s,o,i,r){if(e===0)return Ti(t,n,s,o,i,r);const c=1/e;t*=c,n*=c,s*=c;const a=fn(t,n,s,o),l=fn(t,n,s,i),h=t*t-3*n;let f=0;if(h<=0)f=En(t,n,s,o,i,a,l,r,0);else{const u=Math.sqrt(h)/3,p=-t/3,_=p-u,y=p+u;let g=o,x=a;if(_>o&&_<i){const b=fn(t,n,s,_);f=En(t,n,s,g,_,x,b,r,f),g=_,x=b}if(y>o&&y<i){const b=fn(t,n,s,y);f=En(t,n,s,g,y,x,b,r,f),g=y,x=b}f=En(t,n,s,g,i,x,l,r,f)}return l===0&&(r[f++]=i),f}const J=0,ot=1,Et=2,Se=4,vi=4,K=[0,0,0];class tt{constructor(t,n,s,o,i,r,c,a,l){this.type=t,this.p0x=n,this.p0y=s,this.p1x=o,this.p1y=i,this.p2x=r,this.p2y=c,this.p3x=a,this.p3y=l,this.color=7}endX(){switch(this.type){case J:return this.p1x;case ot:return this.p2x;default:return this.p3x}}endY(){switch(this.type){case J:return this.p1y;case ot:return this.p2y;default:return this.p3y}}point(t,n){const s=t;switch(this.type){case J:{n[0]=this.p0x+s*(this.p1x-this.p0x),n[1]=this.p0y+s*(this.p1y-this.p0y);return}case ot:{const o=this.p0x+s*(this.p1x-this.p0x),i=this.p0y+s*(this.p1y-this.p0y),r=this.p1x+s*(this.p2x-this.p1x),c=this.p1y+s*(this.p2y-this.p1y);n[0]=o+s*(r-o),n[1]=i+s*(c-i);return}default:{const o=this.p0x+s*(this.p1x-this.p0x),i=this.p0y+s*(this.p1y-this.p0y),r=this.p1x+s*(this.p2x-this.p1x),c=this.p1y+s*(this.p2y-this.p1y),a=this.p2x+s*(this.p3x-this.p2x),l=this.p2y+s*(this.p3y-this.p2y),h=o+s*(r-o),f=i+s*(c-i),u=r+s*(a-r),p=c+s*(l-c);n[0]=h+s*(u-h),n[1]=f+s*(p-f);return}}}direction(t,n){const s=t;switch(this.type){case J:{n[0]=this.p1x-this.p0x,n[1]=this.p1y-this.p0y;return}case ot:{const o=this.p1x-this.p0x+s*(this.p2x-this.p1x-(this.p1x-this.p0x)),i=this.p1y-this.p0y+s*(this.p2y-this.p1y-(this.p1y-this.p0y));o!==0||i!==0?(n[0]=o,n[1]=i):(n[0]=this.p2x-this.p0x,n[1]=this.p2y-this.p0y);return}default:{const o=this.p1x-this.p0x,i=this.p1y-this.p0y,r=this.p2x-this.p1x,c=this.p2y-this.p1y,a=this.p3x-this.p2x,l=this.p3y-this.p2y,h=o+s*(r-o)+s*(r+s*(a-r)-(o+s*(r-o))),f=i+s*(c-i)+s*(c+s*(l-c)-(i+s*(c-i)));h!==0||f!==0?(n[0]=h,n[1]=f):s===0?(n[0]=this.p2x-this.p0x,n[1]=this.p2y-this.p0y):s===1?(n[0]=this.p3x-this.p1x,n[1]=this.p3y-this.p1y):(n[0]=h,n[1]=f);return}}}splitInThirds(){const t=[0,0],n=[0,0];switch(this.type){case J:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const s=new tt(J,this.p0x,this.p0y,t[0],t[1],0,0,0,0),o=new tt(J,t[0],t[1],n[0],n[1],0,0,0,0),i=new tt(J,n[0],n[1],this.p1x,this.p1y,0,0,0,0);return s.color=o.color=i.color=this.color,[s,o,i]}case ot:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const s=this.p0x+1/3*(this.p1x-this.p0x),o=this.p0y+1/3*(this.p1y-this.p0y),i=this.p0x+5/9*(this.p1x-this.p0x),r=this.p0y+5/9*(this.p1y-this.p0y),c=this.p1x+4/9*(this.p2x-this.p1x),a=this.p1y+4/9*(this.p2y-this.p1y),l=i+.5*(c-i),h=r+.5*(a-r),f=this.p1x+2/3*(this.p2x-this.p1x),u=this.p1y+2/3*(this.p2y-this.p1y),p=new tt(ot,this.p0x,this.p0y,s,o,t[0],t[1],0,0),_=new tt(ot,t[0],t[1],l,h,n[0],n[1],0,0),y=new tt(ot,n[0],n[1],f,u,this.p2x,this.p2y,0,0);return p.color=_.color=y.color=this.color,[p,_,y]}default:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const s=this.p0x===this.p1x&&this.p0y===this.p1y?this.p0x:this.p0x+1/3*(this.p1x-this.p0x),o=this.p0x===this.p1x&&this.p0y===this.p1y?this.p0y:this.p0y+1/3*(this.p1y-this.p0y),i=this.p0x+1/3*(this.p1x-this.p0x),r=this.p0y+1/3*(this.p1y-this.p0y),c=this.p1x+1/3*(this.p2x-this.p1x),a=this.p1y+1/3*(this.p2y-this.p1y),l=this.p2x+1/3*(this.p3x-this.p2x),h=this.p2y+1/3*(this.p3y-this.p2y),f=i+1/3*(c-i),u=r+1/3*(a-r),p=c+1/3*(l-c),_=a+1/3*(h-a),y=f+2/3*(p-f),g=u+2/3*(_-u),x=this.p0x+2/3*(this.p1x-this.p0x),b=this.p0y+2/3*(this.p1y-this.p0y),M=this.p1x+2/3*(this.p2x-this.p1x),A=this.p1y+2/3*(this.p2y-this.p1y),k=this.p2x+2/3*(this.p3x-this.p2x),T=this.p2y+2/3*(this.p3y-this.p2y),S=x+2/3*(M-x),w=b+2/3*(A-b),m=M+2/3*(k-M),d=A+2/3*(T-A),U=S+1/3*(m-S),C=w+1/3*(d-w),v=this.p2x===this.p3x&&this.p2y===this.p3y?this.p3x:this.p2x+2/3*(this.p3x-this.p2x),I=this.p2x===this.p3x&&this.p2y===this.p3y?this.p3y:this.p2y+2/3*(this.p3y-this.p2y),R=new tt(Et,this.p0x,this.p0y,s,o,f,u,t[0],t[1]),G=new tt(Et,t[0],t[1],y,g,U,C,n[0],n[1]),F=new tt(Et,n[0],n[1],m,d,v,I,this.p3x,this.p3y);return R.color=G.color=F.color=this.color,[R,G,F]}}}signedDistance(t,n,s){switch(this.type){case J:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=t-o,l=n-i,h=r-o,f=c-i,u=h*h+f*f,p=(a*h+l*f)/u,_=p>.5,y=(_?r:o)-t,g=(_?c:i)-n,x=Math.sqrt(y*y+g*g);if(p>0&&p<1){const A=Math.sqrt(h*h+f*f),k=h/A,S=f/A*a-k*l;if(Math.abs(S)<x){s.distance=S,s.dot=0,s.param=p;return}}const b=a*f-l*h;s.distance=jt(b)*x;const M=Math.sqrt(h*h+f*f);s.dot=x===0||M===0?0:Math.abs((h*y+f*g)/(M*x)),s.param=p;return}case ot:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=o-t,f=i-n,u=r-o,p=c-i,_=a-r-u,y=l-c-p,g=_*_+y*y,x=3*(u*_+p*y),b=2*(u*u+p*p)+(h*_+f*y),M=h*u+f*p,A=Si(g,x,b,M,0,1,K);let k=u,T=p;const S=h*h+f*f;let w=jt(k*f-T*h),m=S,d=-(h*k+f*T)/(k*k+T*T);{const C=a-t,v=l-n,I=C*C+v*v;I<m&&(k=a-r,T=l-c,w=jt(k*v-T*C),m=I,d=((t-r)*k+(n-c)*T)/(k*k+T*T))}for(let C=0;C<A;++C){const v=K[C];if(v>0&&v<1){const I=h+2*v*u+v*v*_,R=f+2*v*p+v*v*y,G=I*I+R*R;if(G<=m){const F=u+v*_,X=p+v*y;w=jt(F*R-X*I),m=G,d=v}}}const U=w*Math.sqrt(m);if(d>=0&&d<=1){s.distance=U,s.dot=0,s.param=d;return}if(s.distance=U,s.param=d,d<.5){const C=Math.sqrt(u*u+p*p),v=Math.sqrt(S);s.dot=v===0||C===0?0:Math.abs((u*h+p*f)/(C*v))}else{const C=a-r,v=l-c,I=a-t,R=l-n,G=Math.sqrt(C*C+v*v),F=Math.sqrt(I*I+R*R);s.dot=G===0||F===0?0:Math.abs((C*I+v*R)/(G*F))}return}default:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=this.p3x,f=this.p3y,u=o-t,p=i-n,_=r-o,y=c-i,g=a-r-_,x=l-c-y,b=h-a-(a-r)-g,M=f-l-(l-c)-x;let A=_,k=y;A===0&&k===0&&(A=a-o,k=l-i);const T=Math.sqrt(u*u+p*p);let S=jt(A*p-k*u)*T,w=-(u*A+p*k)/(A*A+k*k);{const m=h-t,d=f-n,U=Math.sqrt(m*m+d*d);if(U<Math.abs(S)){let C=h-a,v=f-l;C===0&&v===0&&(C=h-r,v=f-c),A=C,k=v,S=jt(A*d-k*m)*U,w=((A-m)*A+(k-d)*k)/(A*A+k*k)}}for(let m=0;m<=Se;++m){let d=1/Se*m,U=u+3*d*_+3*d*d*g+d*d*d*b,C=p+3*d*y+3*d*d*x+d*d*d*M,v=3*_+6*d*g+3*d*d*b,I=3*y+6*d*x+3*d*d*M,R=6*g+6*d*b,G=6*x+6*d*M,F=d-(U*v+C*I)/(v*v+I*I+(U*R+C*G));if(F>0&&F<1){let X=vi;do{if(d=F,U=u+3*d*_+3*d*d*g+d*d*d*b,C=p+3*d*y+3*d*d*x+d*d*d*M,v=3*_+6*d*g+3*d*d*b,I=3*y+6*d*x+3*d*d*M,!--X)break;R=6*g+6*d*b,G=6*x+6*d*M,F=d-(U*v+C*I)/(v*v+I*I+(U*R+C*G))}while(F>0&&F<1);const H=Math.sqrt(U*U+C*C);H<Math.abs(S)&&(S=jt(v*C-I*U)*H,w=d)}}if(w>=0&&w<=1){s.distance=S,s.dot=0,s.param=w;return}if(s.distance=S,s.param=w,w<.5){let m=_,d=y;m===0&&d===0&&(m=a-o,d=l-i);const U=Math.sqrt(m*m+d*d);s.dot=T===0||U===0?0:Math.abs((m*u+d*p)/(U*T))}else{let m=h-a,d=f-l;m===0&&d===0&&(m=h-r,d=f-c);const U=h-t,C=f-n,v=Math.sqrt(m*m+d*d),I=Math.sqrt(U*U+C*C);s.dot=v===0||I===0?0:Math.abs((m*U+d*C)/(v*I))}return}}}scanlineIntersections(t,n,s){switch(this.type){case J:{const o=this.p0y,i=this.p1y;if(t>=o&&t<i||t>=i&&t<o){const r=(t-o)/(i-o);return n[0]=Ue(this.p0x,this.p1x,r),s[0]=ut(i-o),1}return 0}case ot:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y;let h=0,f=t>i?1:-1;n[h]=o,i===t&&(i<c||i===c&&i<l?s[h++]=1:f=1);{const u=r-o,p=c-i,_=a-r-u,y=l-c-p,g=Te(K,y,2*p,i-t);if(g>=2&&K[0]>K[1]){const x=K[0];K[0]=K[1],K[1]=x}for(let x=0;x<g&&h<2;++x){const b=K[x];b>=0&&b<=1&&(n[h]=o+2*b*u+b*b*_,f*(p+b*y)>=0&&(s[h++]=f,f=-f))}}return l===t&&(f>0&&h>0&&(--h,f=-1),(l<c||l===c&&l<i)&&h<2&&(n[h]=a,f<0&&(s[h++]=-1,f=1))),f!==(t>=l?1:-1)&&(h>0?--h:(Math.abs(l-t)<Math.abs(i-t)&&(n[h]=a),s[h++]=f)),h}default:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=this.p3x,f=this.p3y;let u=0,p=t>i?1:-1;n[u]=o,i===t&&(i<c||i===c&&(i<l||i===l&&i<f)?s[u++]=1:p=1);{const _=h-3*a+3*r-o,y=f-3*l+3*c-i,g=3*a-6*r+3*o,x=3*l-6*c+3*i,b=3*r-3*o,M=3*c-3*i,A=Ai(K,y,x,M,i-t);if(A>=2){if(K[0]>K[1]){const k=K[0];K[0]=K[1],K[1]=k}if(A>=3&&K[1]>K[2]){const k=K[1];if(K[1]=K[2],K[2]=k,K[0]>K[1]){const T=K[0];K[0]=K[1],K[1]=T}}}for(let k=0;k<A&&u<3;++k){const T=K[k];T>=0&&T<=1&&(n[u]=((_*T+g)*T+b)*T+o,p*((3*y*T+2*x)*T+M)>=0&&(s[u++]=p,p=-p))}}return f===t&&(p>0&&u>0&&(--u,p=-1),(f<l||f===l&&(f<c||f===c&&f<i))&&u<3&&(n[u]=h,p<0&&(s[u++]=-1,p=1))),p!==(t>=f?1:-1)&&(u>0?--u:(Math.abs(f-t)<Math.abs(i-t)&&(n[u]=h),s[u++]=p)),u}}}convertToCubic(){const t=this.p0x+.6666666666666666*(this.p1x-this.p0x),n=this.p0y+2/3*(this.p1y-this.p0y),s=this.p1x+1/3*(this.p2x-this.p1x),o=this.p1y+1/3*(this.p2y-this.p1y),i=new tt(Et,this.p0x,this.p0y,t,n,s,o,this.p2x,this.p2y);return i.color=this.color,i}}class It{constructor(t,n=0){this._view=new DataView(t),this._pos=n}get pos(){return this._pos}seek(t){this._pos=t}skip(t){this._pos+=t}u8(){return this._view.getUint8(this._pos++)}u16(){const t=this._view.getUint16(this._pos,!1);return this._pos+=2,t}i16(){const t=this._view.getInt16(this._pos,!1);return this._pos+=2,t}u32(){const t=this._view.getUint32(this._pos,!1);return this._pos+=4,t}i32(){const t=this._view.getInt32(this._pos,!1);return this._pos+=4,t}f2dot14(){return this.i16()/16384}offset16(){return this.u16()}offset32(){return this.u32()}peekU16(t){return this._view.getUint16(t,!1)}peekU32(t){return this._view.getUint32(t,!1)}peekI16(t){return this._view.getInt16(t,!1)}}function Ci(e,t){const n=new It(e,t);n.skip(2);const s=n.u16();let o=null;for(let r=0;r<s;r++){const c=n.u16(),a=n.u16(),l=n.u32(),h=t+l,f=n.peekU16(h);let u=-1;c===3&&a===10&&f===12?u=5:c===0&&a===6&&f===12?u=4:c===0&&a===4&&f===12?u=3:c===3&&a===1&&f===4?u=2:c===0&&a<=3&&f===4&&(u=1),u>((o==null?void 0:o.priority)??-1)&&(o={priority:u,subtableAbsOffset:h})}if(!o)return()=>0;const i=n.peekU16(o.subtableAbsOffset);return i===12?Ei(e,o.subtableAbsOffset):i===4?Ii(e,o.subtableAbsOffset):()=>0}function Ei(e,t){const n=new It(e,t);n.skip(2),n.skip(2),n.skip(4),n.skip(4);const s=n.u32(),o=new Uint32Array(s),i=new Uint32Array(s),r=new Uint32Array(s);for(let c=0;c<s;c++)o[c]=n.u32(),i[c]=n.u32(),r[c]=n.u32();return c=>{let a=0,l=s-1;for(;a<=l;){const h=a+l>>>1,f=o[h]??0,u=i[h]??0;if(c<f)l=h-1;else if(c>u)a=h+1;else return(r[h]??0)+(c-f)}return 0}}function Ii(e,t){const n=new It(e,t);n.skip(2),n.skip(2),n.skip(2);const o=n.u16()>>>1;n.skip(6);const i=new Uint16Array(o);for(let f=0;f<o;f++)i[f]=n.u16();n.skip(2);const r=new Uint16Array(o);for(let f=0;f<o;f++)r[f]=n.u16();const c=new Int16Array(o);for(let f=0;f<o;f++)c[f]=n.i16();const a=new Int32Array(o),l=new Uint16Array(o);for(let f=0;f<o;f++)a[f]=n.pos,l[f]=n.u16();const h=new DataView(e);return f=>{if(f>65535)return 0;let u=0,p=o-1;for(;u<=p;){const _=u+p>>>1,y=i[_]??0;if(f>y)u=_+1;else if(f<(r[_]??0))p=_-1;else{if((i[_]??0)===65535)return 0;const x=l[_]??0,b=c[_]??0,M=r[_]??0;if(x===0)return f+b&65535;const A=(a[_]??0)+x+(f-M)*2,k=h.getUint16(A,!1);return k===0?0:k+b&65535}}return 0}}function Di(e,t){const n=new It(e,t);n.skip(4),n.skip(4),n.skip(4),n.skip(4),n.skip(2);const s=n.u16();n.skip(16),n.skip(8),n.skip(2),n.skip(2),n.skip(2);const o=n.i16();return{unitsPerEm:s,indexToLocFormat:o}}function Ri(e,t){const n=new It(e,t);n.skip(4);const s=n.i16(),o=n.i16(),i=n.i16();n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(8),n.skip(2);const r=n.u16();return{ascender:s,descender:o,lineGap:i,numberOfHMetrics:r}}function Li(e,t,n,s){const o=new It(e,t),i=[];let r=0;for(let c=0;c<s;c++){const a=o.u16(),l=o.i16();i[c]={advanceWidth:a,lsb:l},r=a}for(let c=s;c<n;c++){const a=o.i16();i[c]={advanceWidth:r,lsb:a}}return i}function Pi(e,t,n,s){const o=new It(e,t),i=n+1,r=[];if(s===0)for(let c=0;c<i;c++)r[c]=o.u16()*2;else for(let c=0;c<i;c++)r[c]=o.u32();return r}function Fi(e,t){const n=new It(e,t);return n.skip(4),{numGlyphs:n.u16()}}const qi=1,Oi=2,Gi=4,Ni=8,ve=16,Ce=32,$i=1,Ee=2,Bi=8,Yi=32,Hi=64,Xi=128;function Ki(e,t,n,s,o){const i=Ie(e,t,n,s,o),r=[];for(const c of i){const a=Wi(c);a.length>0&&r.push(a)}return{contours:r,inverseYAxis:!1}}function Ie(e,t,n,s,o){if(s===0)return[];const i=t+n,r=new It(e,i),c=r.i16();return r.skip(8),c>=0?ji(r,c):zi(e,r,t,o)}function ji(e,t){if(t===0)return[];const n=[];for(let f=0;f<t;f++)n[f]=e.u16();const s=(n[t-1]??0)+1,o=e.u16();e.skip(o);const i=new Uint8Array(s);for(let f=0;f<s;){const u=e.u8();if(i[f++]=u,u&Ni){let p=e.u8();for(;p-- >0;)i[f++]=u}}const r=new Float64Array(s);let c=0;for(let f=0;f<s;f++){const u=i[f]??0;if(u&Oi){const p=e.u8();c+=u&ve?p:-p}else u&ve||(c+=e.i16());r[f]=c}const a=new Float64Array(s);c=0;for(let f=0;f<s;f++){const u=i[f]??0;if(u&Gi){const p=e.u8();c+=u&Ce?p:-p}else u&Ce||(c+=e.i16());a[f]=c}const l=[];let h=0;for(let f=0;f<t;f++){const u=n[f]??0,p=Vi(i,r,a,h,u);p.length>0&&l.push(p),h=u+1}return l}function Vi(e,t,n,s,o){const i=o-s+1;if(i<=0)return[];const r=[];for(let c=0;c<i;c++){const a=e[s+c]??0,l=t[s+c]??0,h=n[s+c]??0;r.push({x:l,y:h,onCurve:(a&qi)!==0})}return r}function Wi(e){const t=e.length;if(t<=0)return[];const n=[];for(let c=0;c<t;c++){const a=e[c],l=e[(c+1)%t];n.push(a),!a.onCurve&&!l.onCurve&&n.push({x:Math.trunc((a.x+l.x)/2),y:Math.trunc((a.y+l.y)/2),onCurve:!0})}const s=n.length;let o=0;if(!n[0].onCurve){for(let c=1;c<s;c++)if(n[c].onCurve){o=c;break}}const i=[];let r=0;for(;r<s;){const c=n[(o+r)%s],a=n[(o+r+1)%s];if(a.onCurve)i.push(new tt(J,c.x,c.y,a.x,a.y,0,0,0,0)),r+=1;else{const l=n[(o+r+2)%s];i.push(new tt(ot,c.x,c.y,a.x,a.y,l.x,l.y,0,0)),r+=2}}return i}function zi(e,t,n,s){const o=[];let i=0;do{i=t.u16();const r=t.u16();let c,a;i&$i?(c=t.i16(),a=t.i16()):(c=t.u8(),a=t.u8(),i&Ee&&(c>127&&(c-=256),a>127&&(a-=256)));let l=0,h=0;i&Ee&&(l=c,h=a);let f=1,u=0,p=0,_=1;i&Bi?f=_=t.f2dot14():i&Hi?(f=t.f2dot14(),_=t.f2dot14()):i&Xi&&(f=t.f2dot14(),u=t.f2dot14(),p=t.f2dot14(),_=t.f2dot14());const y=s(r),g=Zi(y,f,u,p,_,l,h);for(const x of g)o.push(x)}while(i&Yi);return o}function De(e){return e>=0?Math.floor(e+.5):Math.ceil(e-.5)}function Zi(e,t,n,s,o,i,r){if(t===1&&n===0&&s===0&&o===1&&i===0&&r===0)return e;const a=t===1&&n===0&&s===0&&o===1;return e.map(l=>l.map(h=>a?{x:h.x+i,y:h.y+r,onCurve:h.onCurve}:{x:De(t*h.x+n*h.y+i),y:De(s*h.x+o*h.y+r),onCurve:h.onCurve}))}const nn=1,In=2,Qi=4,Dt=8,un=16,L={_cp:new Int32Array(64),_gid:new Uint16Array(64),_gp:new Uint16Array(64),_xa:new Float64Array(64),_xo:new Float64Array(64),_yo:new Float64Array(64),_runEnd:new Int32Array(64),_runScript:new Int32Array(64)};function pn(e,t,n,s){if(e&n&14)return!1;if(e&Dt){if(n&16)return s!==null&&t<s.length&&s[t]!==65535;if(n&65280)return(n&65280)===(e&65280)}return!0}function gs(e,t,n,s){const o=L._gp,i=L._gid;for(let r=e+1;r<t;r++){const c=o[r];if(!(c&nn)&&pn(c,i[r],n,s))return r}return-1}function Re(e){if(L._gid.length>=e)return;let t=L._gid.length;for(;t<e;)t*=2;L._cp=new Int32Array(t),L._gid=new Uint16Array(t),L._gp=new Uint16Array(t),L._xa=new Float64Array(t),L._xo=new Float64Array(t),L._yo=new Float64Array(t),L._runEnd=new Int32Array(t),L._runScript=new Int32Array(t)}let _n=new Uint8Array(64);class Ji{constructor(t,n){this._pairs=[],this._counts=[],this._cross=[];const s=new DataView(t);this._dv=s;const o=s.getUint16(n)===1,i=o?s.getUint32(n+4):s.getUint16(n+2);let r=n+(o?8:4),c=!1,a=!1;for(let l=0;l<i&&r+8<=s.byteLength;l++){let h,f,u,p,_=!1,y;if(o){h=s.getUint32(r);const g=s.getUint8(r+4);f=s.getUint8(r+5),u=!(g&128),p=!!(g&64),_=!!(g&32),y=r+8}else{h=s.getUint16(r+2),f=s.getUint8(r+4);const g=s.getUint8(r+5);u=!!(g&1),p=!!(g&4),y=r+6}if(f===1&&(c=!0),p&&(a=!0),f===0&&u&&!_&&(this._pairs.push(y+8),this._counts.push(s.getUint16(y)),this._cross.push(p)),h<6)break;r+=h}this._hasData=i>0,this._hasMachine=c,this._hasCross=a}_get(t,n,s){const o=this._dv,i=this._pairs[t],r=(n<<16|s)>>>0;let c=0,a=this._counts[t]-1;for(;c<=a;){const l=c+a>>1,h=o.getUint32(i+6*l);if(h<r)c=l+1;else if(h>r)a=l-1;else return o.getInt16(i+6*l+4)}return 0}_apply(t,n){const s=L._gid,o=L._xa,i=L._xo,r=L._yo;let c=!1,a=!1;for(let l=0;l<this._pairs.length;l++){const h=this._cross[l];h&&!c&&(c=!0,_n.length<n&&(_n=new Uint8Array(n*2)),_n.fill(0,t,n));for(let f=t;f<n;){const u=gs(f,n,Dt,null);if(u<0){f++;continue}const p=this._get(l,s[f],s[u]);if(p)if(h)p===-32768?(_n[u]=1,r[u]=0):(r[u]=p,a=!0);else{const _=p/2;o[f]=o[f]+_,o[u]=o[u]+p-_,i[u]=i[u]+p-_}f=u}}if(a)for(let l=t+1;l<n;l++)_n[l]||(r[l]=r[l]+r[l-1])}}const $t=65535,Le=new Uint16Array(0);function tr(e,t){const n=e.getUint16(t+4);if(!n)return new Uint32Array(0);const s=t+n,o=new Uint32Array(e.getUint16(s));for(let i=0;i<o.length;i++)o[i]=e.getUint32(s+2+6*i);return o}function Pe(e,t){const n=e.getUint16(t),s=e.getUint16(t+2);let o=-1;if(n===1){for(let r=0;r<s;r++)o=Math.max(o,e.getUint16(t+4+2*r));const i=new Uint16Array(o+1).fill($t);for(let r=s-1;r>=0;r--)i[e.getUint16(t+4+2*r)]=r;return i}if(n===2){for(let r=0;r<s;r++)o=Math.max(o,e.getUint16(t+6+6*r));const i=new Uint16Array(o+1).fill($t);for(let r=s-1;r>=0;r--){const c=t+4+6*r,a=e.getUint16(c),l=e.getUint16(c+2),h=e.getUint16(c+4);for(let f=a;f<=l;f++)i[f]=h+f-a}return i}return Le}function xs(e,t){const n=e.getUint16(t);if(n===1){const s=e.getUint16(t+2),o=e.getUint16(t+4),i=new Uint16Array(s+o);for(let r=0;r<o;r++)i[s+r]=e.getUint16(t+6+2*r);return i}if(n===2){const s=e.getUint16(t+2);let o=-1;for(let r=0;r<s;r++)o=Math.max(o,e.getUint16(t+6+6*r));const i=new Uint16Array(o+1);for(let r=s-1;r>=0;r--){const c=t+4+6*r,a=e.getUint16(c+2),l=e.getUint16(c+4);for(let h=e.getUint16(c);h<=a;h++)i[h]=l}return i}return Le}class nr{constructor(t,n,s){this._setCache=[];const o=new DataView(t);this._dv=o;const i=o.getUint16(n+2),r=o.getUint16(n+4),c=o.getUint16(n+10),a=i>=2?o.getUint16(n+12):0;if(this._sets=a?n+a:0,!r){this._props=null;return}const l=xs(o,n+r),h=c?xs(o,n+c):new Uint16Array(0),f=new Uint16Array(s);for(let u=0;u<s&&u<l.length;u++)switch(l[u]){case 1:f[u]=In;break;case 2:f[u]=Qi;break;case 3:f[u]=Dt|(h[u]??0)<<8;break}this._props=f}_markSet(t){let n=this._setCache[t];if(!n){const s=this._dv,o=this._sets;n=o&&t<s.getUint16(o+2)?Pe(s,o+s.getUint32(o+4+4*t)):new Uint16Array(0),this._setCache[t]=n}return n}}const Fe="ZyyyZinhArabArmnBengBopoCherCoptCyrlDsrtDevaEthiGeorGothGrekGujrGuruHaniHangHebrHiraKndaKanaKhmrLaooLatnMlymMongMymrOgamItalOryaRunrSinhSyrcTamlTeluThaaThaiTibtCansYiiiTglgHanoBuhdTagbBraiCprtLimbLinbOsmaShawTaleUgarHrktBugiGlagKharSyloTaluTfngXpeoBaliBatkBlisBrahChamCirtCyrsEgydEgyhEgypGeokHansHantHmngHungIndsJavaKaliLatfLatgLepcLinaMandMayaMeroNkooOrkhPermPhagPhnxPlrdRoroSaraSyreSyrjSyrnTengVaiiVispXsuxZxxxZzzzCariJpanLanaLyciLydiOlckRjngSaurSgnwSundMoonMteiArmiAvstCakmKoreKthiManiPhliPhlpPhlvPrtiSamrTavtZmthZsymBamuLisuNkgbSarbBassDuplElbaGranKpelLomaMendMercNarbNbatPalmSindWaraAfakJurcMrooNshuShrdSoraTakrTangWoleHluwKhojTirhAghbMahjAhomHatrModiMultPaucSiddAdlmBhksMarcNewaOsgeHanbJamoZsyeGonmSoyoZanbDogrGongMakaMedfRohgSogdSogoElymHmnpNandWchoChrsDiakKitsYeziCpmnOugrTnsaTotoVithKawiNagmAranGaraGukhKraiOnaoSunuTodrTutgBerfSidtTayoTols",Dn=Fe.length/4,lt=0,Rt=1,Rn=25,sr=8,er=14;function yn(e){return Fe.substring(e*4,e*4+4)}const or=[],ir=[];function Ln(e,t){const n=t?ir:or;let s=n[e];if(s===void 0){try{s=new RegExp(`^\\p{${t?"scx":"sc"}=${yn(e)}}$`,"u")}catch{s=null}n[e]=s}return s}let ds=null;const Pn=[Rn,lt,Rt,sr,er],gn=[[lt],[Rn]],qe=new Map;let Fn=null;const Oe=new Map;function Ms(e){if(e<128)return gn[e>=65&&e<=90||e>=97&&e<=122?1:0];let t;if(e<65536){Fn||(Fn=new Uint16Array(65536));const n=Fn[e];if(n)return gn[n-1];t=Ge(e),Fn[e]=t+1}else t=Oe.get(e),t===void 0&&(t=Ge(e),Oe.set(e,t));return gn[t]}function Ge(e){const t=String.fromCodePoint(e);let n=103;for(let r=0;r<Pn.length+Dn;r++){const c=r<Pn.length?Pn[r]:r-Pn.length,a=Ln(c,!1);if(a&&a.test(t)){n=c;break}}let s=[n];if(!ds){let r="";for(let c=0;c<Dn;c++)Ln(c,!1)&&Ln(c,!0)&&(r+=`${r?"|":""}(?!\\p{sc=${yn(c)}})\\p{scx=${yn(c)}}`);ds=new RegExp(`^(?:${r})$`,"u")}if(ds.test(t)){const r=[];for(let c=0;c<Dn;c++){const a=Ln(c,!0);a&&a.test(t)&&r.push(c)}r.length&&(s=rr(n,r))}const o=s.join(",");let i=qe.get(o);return i===void 0&&(i=gn.length,gn.push(s),qe.set(o,i)),i}function rr(e,t){if(e===t[0])return t;if(e!==Rt&&e!==lt){const n=t.indexOf(e,1);if(n<0){t.push(e);const s=t[0];t[0]=e,t[t.length-1]=s}else t[n]=t[0],t[0]=e;return t}if(e===lt){if(t.length===1)return[lt,t[0]];for(let n=1;n<t.length;n++)if(t[0]===Rn||t[n]<t[0]){const s=t[0];t[0]=t[n],t[n]=s}return t}t.push(t[0]),t[0]=e;for(let n=2;n<t.length;n++)if(t[1]===Rn||t[n]<t[1]){const s=t[1];t[1]=t[n],t[n]=s}return t}const xn=[40,41,91,93,123,125,3898,3899,3900,3901,5787,5788,8261,8262,8317,8318,8333,8334,8968,8969,8970,8971,9001,9002,10088,10089,10090,10091,10092,10093,10094,10095,10096,10097,10098,10099,10100,10101,10181,10182,10214,10215,10216,10217,10218,10219,10220,10221,10222,10223,10627,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10640,10639,10638,10641,10642,10643,10644,10645,10646,10647,10648,10712,10713,10714,10715,10748,10749,11810,11811,11812,11813,11814,11815,11816,11817,11861,11862,11863,11864,11865,11866,11867,11868,12296,12297,12298,12299,12300,12301,12302,12303,12304,12305,12308,12309,12310,12311,12312,12313,12314,12315,65113,65114,65115,65116,65117,65118,65288,65289,65339,65341,65371,65373,65375,65376,65378,65379];let dn=null;function cr(e){if(e<40||e>125&&e<3898)return 0;if(!dn){dn=new Map;for(let t=0;t<xn.length;t+=2)dn.set(xn[t],xn[t+1]),dn.set(xn[t+1],-xn[t])}return dn.get(e)??0}const Ne=32,kt=[],sn=[];let Ft=0,qn=lt;const Bt=[];let en=[],Vt=[];const $e=[];function Be(e){let t=$e[e];return t||($e[e]=t=[e]),t}function ms(){const e=Bt[0];return e===lt?qn:e}function Ye(e,t){let n=Ft;if(n<=0)return;n>kt.length&&(n=kt.length);let s=kt.length-1;for(t?(s--,n--,Ft=1):Ft=0;n>0;s--,n--)sn[s]=e}function ar(){const e=en,t=Bt;if(e.length===0||t.length===0)return!1;if(e.length===1&&t.length===1){const c=e[0];return c<=Rt?!0:t[0]<=Rt?(t[0]=c,!0):t[0]===c}let n=0,s=t[n++];if(e[0]<=Rt)return e.length===2&&s<=Rt&&qn===lt&&(qn=e[1]),!0;if(s<=Rt)return He(Bt,e),!0;let o=e.indexOf(s)>=0;if(n===t.length)return o;let i=0;o||(s=e[i++],o=t.indexOf(s,n)>=0);let r=0;if(o&&(t[r++]=s),i!==e.length)for(;n<t.length;n++)e.indexOf(t[n],i)>=0&&(t[r++]=t[n]);return r>0?(t.length=r,!0):!1}function He(e,t){e.length=t.length;for(let n=0;n<t.length;n++)e[n]=t[n]}function lr(e,t,n,s){if(t===0)return 0;let o=lt,i=0;for(;i<t;i++){const l=Ms(e[i]);if(l.length!==1)break;const h=l[0];if(!(h<=Rt||h===o)){if(o!==lt)break;o=h}}if(i===t)return n[0]=t,s[0]=o,1;kt.length=0,sn.length=0,Ft=0,qn=lt,Bt.length=1,Bt[0]=lt,Vt=Ms(e[0]);let r=1,c=e[0],a=0;for(;Bt.length;){let l=!1;for(;r<=t;){const h=r-1,f=c;en=Vt,r===t?r++:(c=e[r++],Vt=Ms(c),Vt[0]===Rt&&Vt.length>1&&(en[0]===lt&&(en=Vt.slice(1)),Vt=Be(Rt)));const u=cr(f);if(u>0)kt.length===Ne&&(kt.shift(),sn.shift(),Ft===Ne&&Ft--),Ye(ms(),!1),kt.push(f),sn.push(lt),Ft++;else if(u<0){for(let p=kt.length-1;p>=0;p--)if(kt[p]===-u){const _=sn[p];_!==lt&&(en=Be(_));const y=kt.length-1-p;kt.length-=y,sn.length-=y,Ft=Math.max(0,Ft-y);break}}if(!ar()){const p=ms();Ye(p,u>0),n[a]=h,s[a++]=p,He(Bt,en),l=!0;break}}l||(n[a]=t,s[a++]=ms(),Bt.length=0)}return a}const Xe=[];function xt(e){return(e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3))>>>0}const hr="Bengbng2Devadev2Gujrgjr2Gurugur2Kndaknd2Mlymmlm2Oryaory2Tamltml2Telutel2Mymrmym2",fr="HirakanaLaoolao Yiiiyi Nkoonko Vaiivai Zmthmath";function Ke(e,t){for(let n=0;n<e.length;n+=8)if(e.substring(n,n+4)===t)return e.substring(n+4,n+8);return""}function je(e){let t=Xe[e];if(!t){t=[];const n=yn(e),s=Ke(hr,n);s&&(s!=="mym2"&&t.push(xt(s.substring(0,3)+"3")),t.push(xt(s))),t.push(xt(Ke(fr,n)||n.toLowerCase())),Xe[e]=t}return t}const Ve=64,On=64,ur=["abvm","blwm","mark","mkmk","curs","dist","kern"].map(xt),pr=xt("kern"),We=[xt("DFLT"),xt("dflt"),xt("latn")],bs=0,ws=1,Gn=2,Ut=new Uint16Array(0),_r=new Int16Array(0),yr=new Uint32Array(0);class Mn{constructor(t,n,s,o){this._type=t,this._fmt=n,this._off=s,this._cov=o,this._cd1=Ut,this._cd2=Ut,this._cd3=Ut,this._vf1=0,this._vf2=0,this._len1=0,this._len2=0,this._n1=0,this._n2=0,this._simple=!1,this._kx=_r,this._ps=yr,this._sg=Ut}}class gr{constructor(t,n,s){this._props=t,this._set=n,this._subs=s;let o=0;for(const r of s)o=Math.max(o,r._cov.length);const i=new Uint8Array(o);for(const r of s){const c=r._cov;for(let a=0;a<c.length;a++)c[a]!==$t&&(i[a]=1)}this._any=i,this._pairs=s.length>0&&s.every(r=>r._simple)}}class xr{constructor(t,n){this._lookups=t,this._kern=n}}let dt=new DataView(new ArrayBuffer(0)),ze=0,Nn=0,Ze=0,qt=0,Yt=null;const As=new Int32Array(Ve*On);function $n(e,t,n){let s=e;t&1&&(L._xo[n]=L._xo[n]+dt.getInt16(s),s+=2),t&2&&(L._yo[n]=L._yo[n]+dt.getInt16(s),s+=2),t&4&&(L._xa[n]=L._xa[n]+dt.getInt16(s))}function dr(e,t,n){const s=L._gid,o=L._gp,i=L._xa,r=e._any,c=e._subs,a=e._props,l=e._set;for(let h=t;h<n;h++){const f=s[h];if(f>=r.length||!r[f])continue;const u=o[h];if(u&a&14||u&Dt&&!pn(u,f,a,l))continue;let p=h+1;if(p>=n)break;const _=o[p];if((_&(nn|Dt)||_&a&14)&&(p=gs(h,n,a,l),p<0))continue;const y=s[p];for(let g=0;g<c.length;g++){const x=c[g],b=x._cov,M=f<b.length?b[f]:$t;if(M===$t)continue;let A=-1;if(x._fmt===1){if(M>=x._ps.length-1)continue;const k=x._sg;let T=x._ps[M],S=x._ps[M+1]-1;for(;T<=S;){const w=T+S>>1,m=k[w];if(m<y)T=w+1;else if(m>y)S=w-1;else{A=w;break}}}else{const k=f<x._cd1.length?x._cd1[f]:0,T=y<x._cd2.length?x._cd2[y]:0;k<x._n1&&T<x._n2&&(A=k*x._n2+T)}if(!(A<0)){i[h]=i[h]+x._kx[A],h=p-1;break}}}}function Qe(e){let t=0;for(let n=e&255;n;n&=n-1)t++;return t*2}class Mr{constructor(t,n,s){this._lookupCache=[],this._planCache=[],this._covCache=new Map,this._cdCache=new Map;const o=new DataView(t);this._view=o,this._scripts=n+o.getUint16(n+4),this._features=n+o.getUint16(n+6),this._lookupList=n+o.getUint16(n+8),this._gdef=s}_cov(t,n){if(!n)return Ut;let s=this._covCache.get(t+n);return s||(s=Pe(this._view,t+n),this._covCache.set(t+n,s)),s}_cd(t,n){if(!n)return Ut;let s=this._cdCache.get(t+n);return s||(s=xs(this._view,t+n),this._cdCache.set(t+n,s)),s}_script(t){const n=this._view,s=this._scripts;for(let o=0,i=n.getUint16(s);o<i;o++)if(n.getUint32(s+2+6*o)===t)return s+n.getUint16(s+6+6*o);return 0}_plan(t,n){let s=this._planCache[t];if(s)return s;const o=this._view;let i=0;for(let l=0;l<n.length&&!i;l++)i=this._script(n[l]);for(let l=0;l<We.length&&!i;l++)i=this._script(We[l]);const r=[];let c=!1;const a=i?o.getUint16(i):0;if(a){const l=i+a,h=o.getUint16(l+2),f=this._features,u=o.getUint16(f),p=o.getUint16(l+4);for(let _=-1;_<p;_++){const y=_<0?h:o.getUint16(l+6+2*_);if(y>=u)continue;const g=o.getUint32(f+2+6*y);if(_>=0&&ur.indexOf(g)<0)continue;g===pr&&(c=!0);const x=f+o.getUint16(f+6+6*y);for(let b=0,M=o.getUint16(x+2);b<M;b++){const A=o.getUint16(x+4+2*b);r.indexOf(A)<0&&r.push(A)}}}return r.sort((l,h)=>l-h),s=new xr(r,c),this._planCache[t]=s,s}_lookup(t){const n=this._lookupCache[t];if(n)return n;const s=this._view,o=this._lookupList;if(t>=s.getUint16(o))return null;const i=o+s.getUint16(o+2+2*t),r=s.getUint16(i),c=s.getUint16(i+2),a=s.getUint16(i+4);let l=null;c&16&&(l=this._gdef?this._gdef._markSet(s.getUint16(i+6+2*a)):Ut);const h=[];for(let u=0;u<a;u++){let p=i+s.getUint16(i+6+2*u),_=r;_===9&&(_=s.getUint16(p+2),p+=s.getUint32(p+4));const y=this._sub(_,p);y&&h.push(y)}const f=new gr(c,l,h);return this._lookupCache[t]=f,f}_sub(t,n){const s=this._view,o=s.getUint16(n);if(t===1||t===2){if(o!==1&&o!==2)return null;const i=new Mn(t,o,n,this._cov(n,s.getUint16(n+2)));return i._vf1=s.getUint16(n+4),i._len1=Qe(i._vf1),t===2&&(i._vf2=s.getUint16(n+6),i._len2=Qe(i._vf2),o===2&&(i._cd1=this._cd(n,s.getUint16(n+8)),i._cd2=this._cd(n,s.getUint16(n+10)),i._n1=s.getUint16(n+12),i._n2=s.getUint16(n+14)),(i._vf1&15)===4&&i._vf2===0&&this._decodePairs(i)),i}if(t===7){if(o===3)return new Mn(t,o,n,this._cov(n,s.getUint16(n+6)));if(o!==1&&o!==2)return null;const i=new Mn(t,o,n,this._cov(n,s.getUint16(n+2)));return o===2&&(i._cd1=this._cd(n,s.getUint16(n+4))),i}if(t===8){if(o===3){const r=s.getUint16(n+2);return new Mn(t,o,n,this._cov(n,s.getUint16(n+6+2*r)))}if(o!==1&&o!==2)return null;const i=new Mn(t,o,n,this._cov(n,s.getUint16(n+2)));return o===2&&(i._cd1=this._cd(n,s.getUint16(n+4)),i._cd2=this._cd(n,s.getUint16(n+6)),i._cd3=this._cd(n,s.getUint16(n+8))),i}return null}_decodePairs(t){const n=this._view,s=t._off,o=t._len1;if(t._simple=!0,t._fmt===2){const h=t._n1*t._n2,f=new Int16Array(h);for(let u=0;u<h;u++)f[u]=n.getInt16(s+16+u*o);t._kx=f;return}const i=n.getUint16(s+8),r=new Uint32Array(i+1);let c=0;for(let h=0;h<i;h++)r[h]=c,c+=n.getUint16(s+n.getUint16(s+10+2*h));r[i]=c;const a=new Uint16Array(c),l=new Int16Array(c);for(let h=0;h<i;h++){const f=s+n.getUint16(s+10+2*h);for(let u=0,p=r[h+1]-r[h];u<p;u++){const _=f+2+u*(2+o);a[r[h]+u]=n.getUint16(_),l[r[h]+u]=n.getInt16(_+2)}}t._ps=r,t._sg=a,t._kx=l}_position(t,n,s){dt=this._view,ze=n,Nn=s,Ze=Math.max((s-n)*64,16384);const o=t._lookups;for(let i=0;i<o.length;i++){const r=this._lookup(o[i]);if(!r||!r._subs.length)continue;if(qt=r._props,Yt=r._set,r._pairs){dr(r,n,s);continue}const c=L._gp,a=L._gid,l=r._any;for(let h=n;h<s;){const f=a[h];if(f<l.length&&l[f]&&pn(c[h],f,qt,Yt)){const u=this._applyAt(r,h,0);if(u>=0){h=u;continue}}h++}}}_applyAt(t,n,s){const o=t._subs;for(let i=0;i<o.length;i++){const r=this._applySub(o[i],n,s);if(r>=0)return r}return-1}_applySub(t,n,s){const o=L._gid[n],i=t._cov,r=o<i.length?i[o]:$t;if(r===$t)return-1;const c=dt,a=t._off;switch(t._type){case 1:{if(t._fmt===1)$n(a+6,t._vf1,n);else{if(r>=c.getUint16(a+6))return-1;$n(a+8+r*t._len1,t._vf1,n)}return n+1}case 2:{let l=n+1;if(l>=Nn)return-1;const h=L._gp[l];if((h&(nn|Dt)||h&qt&14)&&(l=gs(n,Nn,qt,Yt),l<0))return-1;const f=L._gid[l];if(t._simple){const p=t._kx;if(t._fmt===1){if(r>=t._ps.length-1)return-1;const g=t._sg;let x=t._ps[r],b=t._ps[r+1]-1;for(;x<=b;){const M=x+b>>1,A=g[M];if(A<f)x=M+1;else if(A>f)b=M-1;else return L._xa[n]=L._xa[n]+p[M],l}return-1}const _=o<t._cd1.length?t._cd1[o]:0,y=f<t._cd2.length?t._cd2[f]:0;return _>=t._n1||y>=t._n2?-1:(L._xa[n]=L._xa[n]+p[_*t._n2+y],l)}let u;if(t._fmt===1){if(r>=c.getUint16(a+8))return-1;const p=a+c.getUint16(a+10+2*r),_=2+t._len1+t._len2;let y=0,g=c.getUint16(p)-1;for(u=-1;y<=g;){const x=y+g>>1,b=p+2+x*_,M=c.getUint16(b);if(M<f)y=x+1;else if(M>f)g=x-1;else{u=b+2;break}}if(u<0)return-1}else{const p=o<t._cd1.length?t._cd1[o]:0,_=f<t._cd2.length?t._cd2[f]:0;if(p>=t._n1||_>=t._n2)return-1;u=a+16+(p*t._n2+_)*(t._len1+t._len2)}return t._vf1&&$n(u,t._vf1,n),t._vf2&&$n(u+t._len1,t._vf2,l),t._len2?l+1:l}case 7:return this._context(t,n,o,r,s);case 8:return this._chain(t,n,o,r,s)}return-1}_context(t,n,s,o,i){const r=dt,c=t._off;if(t._fmt===3){const p=r.getUint16(c+2),_=this._input(n,p,Gn,Ut,c+8,c,i);return _<0?-1:(this._apply(c+6+2*p,r.getUint16(c+4),p,i),_)}let a=o,l=c+4,h=bs;if(t._fmt===2&&(a=s<t._cd1.length?t._cd1[s]:0,l=c+6,h=ws),a>=r.getUint16(l))return-1;const f=r.getUint16(l+2+2*a);if(!f)return-1;const u=c+f;for(let p=0,_=r.getUint16(u);p<_;p++){const y=u+r.getUint16(u+2+2*p),g=r.getUint16(y),x=this._input(n,g,h,t._cd1,y+4,0,i);if(!(x<0))return this._apply(y+4+2*Math.max(g-1,0),r.getUint16(y+2),g,i),x}return-1}_chain(t,n,s,o,i){const r=dt,c=t._off;if(t._fmt===3){let p=c+2;const _=r.getUint16(p),y=p+2;p+=2+2*_;const g=r.getUint16(p),x=p+2;p+=2+2*g;const b=r.getUint16(p),M=p+2;p+=2+2*b;const A=this._input(n,g,Gn,Ut,x+2,c,i);return A<0||!this._lookahead(A,b,Gn,Ut,M,c)||!this._backtrack(n,_,Gn,Ut,y,c)?-1:(this._apply(p+2,r.getUint16(p),g,i),A)}let a=o,l=c+4,h=bs;if(t._fmt===2&&(a=s<t._cd2.length?t._cd2[s]:0,l=c+10,h=ws),a>=r.getUint16(l))return-1;const f=r.getUint16(l+2+2*a);if(!f)return-1;const u=c+f;for(let p=0,_=r.getUint16(u);p<_;p++){let y=u+r.getUint16(u+2+2*p);const g=r.getUint16(y),x=y+2;y+=2+2*g;const b=r.getUint16(y),M=y+2;y+=2+2*Math.max(b-1,0);const A=r.getUint16(y),k=y+2;y+=2+2*A;const T=this._input(n,b,h,t._cd2,M,0,i);if(!(T<0)&&this._lookahead(T,A,h,t._cd3,k,0)&&this._backtrack(n,g,h,t._cd1,x,0))return this._apply(y+2,r.getUint16(y),b,i),T}return-1}_matches(t,n,s,o,i){if(t===bs)return i===o;if(t===ws)return(i<n.length?n[i]:0)===o;const r=this._cov(s,o);return i<r.length&&r[i]!==$t}_next(t,n,s,o,i){const r=L._gp,c=L._gid;for(let a=t+1;a<Nn;a++){const l=r[a],h=c[a];if(pn(l,h,qt,Yt)){if(this._matches(n,s,o,i,h))return a;if(!(l&nn))return-1}}return-1}_prev(t,n,s,o,i){const r=L._gp,c=L._gid;for(let a=t-1;a>=ze;a--){const l=r[a],h=c[a];if(pn(l,h,qt,Yt)){if(this._matches(n,s,o,i,h))return a;if(!(l&nn))return-1}}return-1}_input(t,n,s,o,i,r,c){if(n>On)return-1;const a=c*On;As[a]=t;let l=t;for(let h=1;h<n;h++){if(l=this._next(l,s,o,r,dt.getUint16(i+2*(h-1))),l<0)return-1;As[a+h]=l}return l+1}_lookahead(t,n,s,o,i,r){let c=t-1;for(let a=0;a<n;a++)if(c=this._next(c,s,o,r,dt.getUint16(i+2*a)),c<0)return!1;return!0}_backtrack(t,n,s,o,i,r){let c=t;for(let a=0;a<n;a++)if(c=this._prev(c,s,o,r,dt.getUint16(i+2*a)),c<0)return!1;return!0}_apply(t,n,s,o){const i=o*On;for(let r=0;r<n;r++){const c=dt.getUint16(t+4*r);if(c>=s||o+1>=Ve||Ze--<=0)continue;const a=this._lookup(dt.getUint16(t+4*r+2));if(!a)continue;const l=qt,h=Yt;qt=a._props,Yt=a._set,this._applyAt(a,As[i+c],o+1),qt=l,Yt=h}}}function mr(e){if(e<173)return!1;if(e<65536){switch(e>>8){case 0:return e===173;case 3:return e===847;case 6:return e===1564;case 23:return e>=6068&&e<=6069;case 24:return e>=6155&&e<=6159;case 32:return e>=8203&&e<=8207||e>=8234&&e<=8238||e>=8288&&e<=8303;case 254:return e>=65024&&e<=65039||e===65279;case 255:return e>=65520&&e<=65528}return!1}return e>=119155&&e<=119162||e>=917504&&e<=921599}function br(e,t,n){const s=e.metrics.unitsPerEm;switch(t){case 160:return e.advance(n);case 8193:case 8195:case 12288:return s;case 8192:case 8194:return s/2;case 8196:return s/3;case 8197:return s/4;case 8198:return s/6;case 8201:return s/5;case 8202:return s/16;case 8287:return s*4/18;case 8239:return e.advance(n)/2;case 8199:{for(let o=48;o<=57;o++){const i=e.glyphId(o);if(i)return e.advance(i)}return e.advance(n)}case 8200:{const o=e.glyphId(46)||e.glyphId(44);return e.advance(o||n)}}return-1}let ks=null;const Je=new Map;function wr(e){if(e<768)return!1;let t=Je.get(e);return t===void 0&&(ks||(ks=new RegExp("^\\p{Mn}$","u")),t=ks.test(String.fromCodePoint(e)),Je.set(e,t)),t}function Ar(e,t){const n=t.length;Re(n);const s=L._cp,o=L._gid,i=L._gp,r=L._xa,c=L._xo,a=L._yo,l=e._glyphProps(),h=e._advances(),f=h.length?h[h.length-1]:0,u=e.glyphId(32);let p=!1,_=0,y=0;for(let M=0;M<n;M++){let A=t.charCodeAt(M);if(A>=55296&&A<56320&&M+1<n){const m=t.charCodeAt(M+1);m>=56320&&m<57344&&(A=(A-55296<<10)+(m-56320)+65536,M++)}let k=e.glyphId(A),T=-1;!k&&A>=160&&u&&((A===8192||A===8193)&&(k=e.glyphId(A+2)),k||(T=br(e,A,u),T>=0&&(k=u)));const S=A>=173&&mr(A);let w;l?w=k<l.length?l[k]:0:w=!S&&wr(A)?Dt:In,S&&(w|=A===8204?un:un|nn,p=!0),_|=w,s[y]=A,o[y]=k,i[y]=w,r[y]=T>=0?T:k<h.length?h[k]:f,c[y]=0,a[y]=0,y++}const g=lr(s,y,L._runEnd,L._runScript),x=(_&Dt)!==0;let b=0;for(let M=0;M<g;M++){const A=L._runEnd[M];ro(e,b,A,L._runScript[M],x),b=A}if(p)for(let M=0;M<y;M++)i[M]&un&&(r[M]=c[M]=a[M]=0);return y}const Us=0,to=1,Ts=2,kr=3,Ss=4,Bn=Ts|Ss,Ur=Us|Ss,Tr=Ts,no=Us,vs=to,Sr="BengDevaGujrGuruKndaMlymOryaTamlTelu",vr="TibtMongSinhBuhdHanoTglgTagbLimbTaleBugiKharSyloTfngBaliNkooPhagChamKaliLepcRjngSaurSundEgypJavaKthiMteiLanaTavtBatkBrahMandCakmPlrdShrdTakrDuplGranKhojSindMahjManiModiHmngPhlpSiddTirhAhomMultAdlmBhksMarcNewaGonmSoyoZanbDogrGongRohgMakaMedfSogoSogdElymNandHmnpWchoChrsDiakKitsYeziCpmnOugrTnsaTotoVithKawiNagmGaraGukhKraiOnaoSunuTodrTutgBerfSidtTayoTolsJurcPcunSeal",so=xt("DFLT"),eo=xt("latn"),Cr=xt("mymr"),oo=[so,xt("dflt"),eo];function Er(e,t){if(!e)return 0;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>=0)return t[n];for(let n=0;n<3;n++)if(e.indexOf(oo[n])>=0)return oo[n];return 0}function Ir(e,t){const n=t===so||t===eo;return e==="Thai"||e==="Laoo"?Tr:e==="Hang"?Ur:e==="Khmr"?no:e==="Mymr"?n||t===Cr?Bn:vs:Sr.indexOf(e)>=0?n?Bn:(t&255)===51?vs:no:vr.indexOf(e)>=0?n?Bn:vs:Bn}function Dr(e,t){const n=e._shaperCache();let s=n[t];return s<0&&(s=Ir(yn(t),Er(e._gsubScriptTags(),je(t))),n[t]=s),s}function io(e,t,n){const s=L._gp,o=L._xa,i=L._xo;for(let r=e;r<t;r++)s[r]&Dt&&(n&&(i[r]=i[r]-o[r]),o[r]=0)}function ro(e,t,n,s,o){const i=Dr(e,s),r=e._gposTable(),c=e._kernTable(),a=r?r._plan(s,je(s)):null,l=c!==null&&c._hasData&&!(a&&a._kern)&&(i&Ss)!==0,h=!o||l&&c._hasMachine?Us:i&kr,f=!r&&(!l||!c._hasCross);h===to&&io(t,n,f),a&&r._position(a,t,n),l&&c._apply(t,n),h===Ts&&io(t,n,f)}function Rr(e,t,n){Re(2);const s=e._glyphProps(),o=e.advance(t),i=e.advance(n);return L._gid[0]=t,L._gid[1]=n,L._gp[0]=s?t<s.length?s[t]:0:In,L._gp[1]=s?n<s.length?s[n]:0:In,L._xa[0]=o,L._xa[1]=i,L._xo[0]=L._xo[1]=L._yo[0]=L._yo[1]=0,ro(e,0,2,lt,((L._gp[0]|L._gp[1])&Dt)!==0),L._xa[0]+L._xa[1]-o-i}function Lr(e){const t=new It(e);if(t.u32()===1953784678){if(t.skip(4),t.u32()===0)throw new Error("TTC contains no fonts");const o=t.u32();t.seek(o)}else t.seek(0);return Pr(e,t)}function Pr(e,t){t.skip(4);const n=t.u16();t.skip(6);const s=new Map;for(let o=0;o<n;o++){const i=String.fromCharCode(t.u8(),t.u8(),t.u8(),t.u8());t.skip(4);const r=t.u32(),c=t.u32();s.set(i,{offset:r,length:c})}return s}const co=2048,Fr=65536;class qr{constructor(t){this._buffer=t,this._tables=Lr(t);const n=this._tables.get("head"),s=this._tables.get("maxp"),o=this._tables.get("hhea"),i=this._tables.get("hmtx"),r=this._tables.get("loca"),c=this._tables.get("cmap");if(!n)throw new Error("Font missing required `head` table");if(!s)throw new Error("Font missing required `maxp` table");if(!o)throw new Error("Font missing required `hhea` table");if(!i)throw new Error("Font missing required `hmtx` table");if(!r)throw new Error("Font missing required `loca` table");if(!c)throw new Error("Font missing required `cmap` table");this._head=Di(t,n.offset);const a=Fi(t,s.offset);this._hhea=Ri(t,o.offset),this._hmtx=Li(t,i.offset,a.numGlyphs,this._hhea.numberOfHMetrics),this._loca=Pi(t,r.offset,a.numGlyphs,this._head.indexToLocFormat),this._cmap=Ci(t,c.offset),this._cmapCache=null,this._layoutLoaded=!1,this._gdef=null,this._gpos=null,this._kern=null,this._gsubScripts=null,this._shapers=null,this._advanceTable=null,this._pairCache=new Map,this.metrics={unitsPerEm:this._head.unitsPerEm,ascender:this._hhea.ascender,descender:this._hhea.descender,lineGap:this._hhea.lineGap}}glyphId(t){if(t>=co||t<0)return this._cmap(t);let n=this._cmapCache;n||(n=this._cmapCache=new Uint16Array(co));let s=n[t];return s||(n[t]=s=this._cmap(t)+1),s-1}get numGlyphs(){return this._loca.length-1}advance(t){return(this._hmtx[t]??this._hmtx[this._hmtx.length-1]??{advanceWidth:0}).advanceWidth}lsb(t){return(this._hmtx[t]??this._hmtx[this._hmtx.length-1]??{lsb:0}).lsb}kerning(t,n){const s=t<32768&&n<32768?t<<15|n:-1-(t*65536+n),o=this._pairCache.get(s);return o!==void 0?o:this._kerningMiss(s,t,n)}_kerningMiss(t,n,s){const o=Rr(this,n,s);return this._pairCache.size>=Fr&&this._pairCache.clear(),this._pairCache.set(t,o),o}_loadLayout(){if(this._layoutLoaded)return;this._layoutLoaded=!0;const t=this._buffer,n=this._tables.get("GDEF"),s=this._tables.get("GPOS"),o=this._tables.get("kern"),i=this._tables.get("GSUB");n&&(this._gdef=new nr(t,n.offset,this.numGlyphs)),s&&(this._gpos=new Mr(t,s.offset,this._gdef)),o&&(this._kern=new Ji(t,o.offset)),i&&(this._gsubScripts=tr(new DataView(t),i.offset))}_gsubScriptTags(){return this._loadLayout(),this._gsubScripts}_shaperCache(){let t=this._shapers;return t||(t=this._shapers=new Int8Array(Dn).fill(-1)),t}_advances(){let t=this._advanceTable;if(!t){const n=this._hmtx.length;t=new Uint16Array(n);for(let s=0;s<n;s++)t[s]=this._hmtx[s].advanceWidth;this._advanceTable=t}return t}_glyphProps(){return this._loadLayout(),this._gdef?this._gdef._props:null}_gposTable(){return this._loadLayout(),this._gpos}_kernTable(){return this._loadLayout(),this._kern}shape(t){const n=this._tables.get("glyf");if(!n)return{contours:[],inverseYAxis:!1};const s=this._loca,o=s[t]??0,r=(s[t+1]??o)-o;return Ki(this._buffer,n.offset,o,r,c=>this._glyphRaw(c))}_glyphRaw(t){const n=this._tables.get("glyf");if(!n)return[];const s=this._loca,o=s[t]??0,r=(s[t+1]??o)-o;return Ie(this._buffer,n.offset,o,r,c=>this._glyphRaw(c))}}function Yn(e,t){const n=1/t;for(const s of e.contours)for(let o=0;o<s.length;o++){const i=s[o];if(i.p0x*=n,i.p0y*=n,i.p1x*=n,i.p1y*=n,i.p2x*=n,i.p2y*=n,i.p3x*=n,i.p3y*=n,i.type===ot){const r=i.p1x-i.p0x,c=i.p1y-i.p0y,a=i.p2x-i.p1x,l=i.p2y-i.p1y;Q(r,c,a,l)===0&&(s[o]=new tt(J,i.p0x,i.p0y,i.p2x,i.p2y,0,0,0,0))}else if(i.type===Et){const r=i.p2x-i.p1x,c=i.p2y-i.p1y,a=1.5*i.p1x-.5*i.p0x,l=1.5*i.p1y-.5*i.p0y;Q(i.p1x-i.p0x,i.p1y-i.p0y,r,c)===0&&Q(r,c,i.p3x-i.p2x,i.p3y-i.p2y)===0?s[o]=new tt(J,i.p0x,i.p0y,i.p3x,i.p3y,0,0,0,0):a===1.5*i.p2x-.5*i.p3x&&l===1.5*i.p2y-.5*i.p3y&&(s[o]=new tt(ot,i.p0x,i.p0y,a,l,i.p3x,i.p3y,0,0))}}}const ao=1e-6,Or=1.1111111111111112,Gr=new Float64Array(16);function lo(e,t,n){switch(t[n]=e.p0x,t[n+1]=e.p0y,t[n+2]=e.p1x,t[n+3]=e.p1y,e.type){case J:return 1;case ot:return t[n+4]=e.p2x,t[n+5]=e.p2y,2;default:return t[n+4]=e.p2x,t[n+5]=e.p2y,t[n+6]=e.p3x,t[n+7]=e.p3y,3}}function ho(e,t,n){if(n===3){const s=e[t],o=e[t+1],i=e[t+2],r=e[t+3],c=e[t+4],a=e[t+5],l=e[t+6],h=e[t+7];(i===s&&r===o||i===l&&r===h)&&(c===s&&a===o||c===l&&a===h)&&(e[t+2]=l,e[t+3]=h,n=1)}if(n===2){const s=e[t],o=e[t+1],i=e[t+2],r=e[t+3],c=e[t+4],a=e[t+5];(i===s&&r===o||i===c&&r===a)&&(e[t+2]=c,e[t+3]=a,n=1)}return n===1&&e[t]===e[t+2]&&e[t+1]===e[t+3]&&(n=0),n}function Nr(e,t){const n=Gr;let s=lo(e,n,0),o=lo(t,n,8);if(!(s>=1&&s<=3&&o>=1&&o<=3)||n[s*2]!==n[8]||n[s*2+1]!==n[9])return 0;s=ho(n,0,s),o=ho(n,8,o);const i=n[s*2],r=n[s*2+1];let c=0,a=0,l=0,h=0,f=0,u=0,p=0,_=0,y=0,g=0,x=0,b=0;if(s>=1&&(c=n[(s-1)*2]-i,a=n[(s-1)*2+1]-r),s>=2){const H=n[(s-2)*2]-n[(s-1)*2],V=n[(s-2)*2+1]-n[(s-1)*2+1];l=H-c,h=V-a}if(s>=3){const H=n[(s-3)*2]-n[(s-2)*2],V=n[(s-3)*2+1]-n[(s-2)*2+1],et=n[(s-2)*2]-n[(s-1)*2],z=n[(s-2)*2+1]-n[(s-1)*2+1];f=H-et-l,u=V-z-h,l*=3,h*=3}if(o>=1&&(p=n[10]-i,_=n[11]-r),o>=2){const H=n[12]-n[10],V=n[13]-n[11];y=H-p,g=V-_}if(o>=3){const H=n[14]-n[12],V=n[15]-n[13],et=n[12]-n[10],z=n[13]-n[11];x=H-et-y,b=V-z-g,y*=3,g*=3}c*=s,a*=s,p*=o,_*=o;const M=c!==0||a!==0;if(M&&(p!==0||_!==0)){const H=Math.sqrt(c*c+a*a),V=Math.sqrt(p*p+_*_),et=H*Q(c,a,y,g)+V*Q(l,h,p,_);if(et)return ut(et);const z=H*H*Q(c,a,x,b)+H*V*Q(l,h,y,g)+V*V*Q(f,u,p,_);if(z)return ut(z);const Gt=H*Q(l,h,x,b)+V*Q(f,u,y,g);return ut(Gt||Q(f,u,x,b))}let k=1,T=l,S=h,w=f,m=u,d=p,U=_,C=y,v=g,I=x,R=b;if(M&&(T=y,S=g,w=x,m=b,d=c,U=a,C=l,v=h,I=f,R=u,k=-1),d!==0||U!==0){const H=Q(w,m,d,U);if(H)return k*ut(H);const V=Q(T,S,C,v);if(V)return k*ut(V);const et=Q(w,m,C,v);if(et)return k*ut(et);const z=Q(T,S,I,R);return z?k*ut(z):k*ut(Q(w,m,I,R))}const G=Math.sqrt(T*T+S*S),F=Math.sqrt(C*C+v*v),X=Math.sqrt(G)*Q(T,S,I,R)+Math.sqrt(F)*Q(w,m,C,v);return ut(X||Q(w,m,I,R))}function fo(e,t,n,s,o){let i=e[t];if(i.type===ot){const r=i.convertToCubic();e[t]=r,i=r}if(i.type===Et)if(n===0){const r=Math.sqrt((i.p1x-i.p0x)**2+(i.p1y-i.p0y)**2);i.p1x+=r*s,i.p1y+=r*o}else{const r=Math.sqrt((i.p2x-i.p3x)**2+(i.p2y-i.p3y)**2);i.p2x+=r*s,i.p2y+=r*o}}const mn=[0,0],bn=[0,0];function $r(e){for(let t=0;t<e.contours.length;t++){const n=e.contours[t];let s=0;for(let o=0;o<n.length;o++){const i=n[o];(i.p0x!==i.endX()||i.p0y!==i.endY())&&(n[s++]=i)}n.length=s}for(const t of e.contours)if(t.length===1){const[n,s,o]=t[0].splitInThirds();t.length=0,t.push(n,s,o)}else if(t.length>0){const n=t.length;for(let s=0;s<n;s++){const o=(s+n-1)%n,i=t[o],r=t[s];i.direction(1,mn),r.direction(0,bn);const c=Math.sqrt(mn[0]**2+mn[1]**2),a=Math.sqrt(bn[0]**2+bn[1]**2);if(c===0||a===0)continue;const l=mn[0]/c,h=mn[1]/c,f=bn[0]/a,u=bn[1]/a;if(bi(l,h,f,u)<ao-1){const p=ao-1,_=Or*Math.sqrt(1-p*p)/p;let y=f-l,g=u-h;const x=Math.sqrt(y*y+g*g);if(x===0)continue;y=_*y/x,g=_*g/x,Nr(i,r)<0&&(y=-y,g=-g),fo(t,o,1,-g,y),fo(t,s,0,g,-y)}}}}const uo=[0,0,0],po=[0,0,0],_o=[0,0];function yo(e){const t=.5*(Math.sqrt(5)-1),n=e.map(()=>0),s=[];for(let o=0;o<e.length;o++){const i=e[o];if(n[o]||i.length===0)continue;const r=i[0].p0y;let c=r;for(let l=0;l<i.length&&r===c;l++)c=i[l].endY();for(let l=0;l<i.length&&r===c;l++)i[l].point(t,_o),c=_o[1];const a=Ue(r,c,t);for(let l=0;l<e.length;l++)for(const h of e[l]){const f=h.scanlineIntersections(a,uo,po);for(let u=0;u<f;u++)s.push({x:uo[u],dy:po[u],c:l})}s.sort((l,h)=>ut(l.x-h.x));for(let l=1;l<s.length;l++)s[l].x===s[l-1].x&&(s[l].dy=s[l-1].dy=0);for(let l=0;l<s.length;l++){const h=s[l];h.dy&&(n[h.c]+=2*(l&1^(h.dy>0?1:0))-1)}s.length=0}for(let o=0;o<e.length;o++){if(n[o]>=0)continue;const i=e[o].reverse();for(let r=0;r<i.length;r++){const c=i[r];i[r]=c.type===J?new tt(J,c.p1x,c.p1y,c.p0x,c.p0y,0,0,0,0):c.type===ot?new tt(ot,c.p2x,c.p2y,c.p1x,c.p1y,c.p0x,c.p0y,0,0):new tt(Et,c.p3x,c.p3y,c.p2x,c.p2y,c.p1x,c.p1y,c.p0x,c.p0y)}}}const go=1e-5,Cs=1e-6,Br=2e4,Yr=1e5;function Hr(e){return[e.p0x,e.p0y,e.p1x,e.p1y,e.p2x,e.p2y,e.p3x,e.p3y].slice(0,2*e.type+4)}function xo(e){const t=e.length/2-2;return new tt(t,e[0],e[1],e[2],e[3],e[4]??0,e[5]??0,e[6]??0,e[7]??0)}const at=new Float64Array(8),ht=new Float64Array(8),Wt=new Float64Array(8);function Es(e,t,n,s){const o=e.length,i=o/2-1;for(let r=0;r<=i;r++){for(let c=0;c<o;c++)Wt[c]=e[c];for(let c=0,a=o;c<i;c++,a-=2){const l=c<i-r?t:n;for(let h=0;h<a-2;h++)Wt[h]=Wt[h]+l*(Wt[h+2]-Wt[h])}s[2*r]=Wt[0],s[2*r+1]=Wt[1]}}function Xr(e,t,n){return Es(e,t,n,at),Array.from(at.subarray(0,e.length))}let Is=0,Ds=0,Ot=-1,wn=-1,An=0,kn=0,Hn=0,Xn=0;function Kr(e,t){Ot=-1,wn=-1;let n=0;for(let h=0;h<2;h++){const f=h?e.length-2:0;for(let u=0;u<2;u++){const p=u?t.length-2:0;e[f]===t[p]&&e[f+1]===t[p+1]&&(n++,Ot=h,wn=u)}}if(n!==1){Ot=-1;return}const s=Ot?e.length-2:0;An=e[s],kn=e[s+1];let o=0,i=0;for(let h=2;h<e.length&&o===0&&i===0;h+=2){const f=Ot?e.length-2-h:h;o=e[f]-An,i=e[f+1]-kn}let r=0,c=0;for(let h=2;h<t.length&&r===0&&c===0;h+=2){const f=wn?t.length-2-h:h;r=t[f]-An,c=t[f+1]-kn}const a=Math.hypot(o,i),l=Math.hypot(r,c);Hn=o/a-r/l,Xn=i/a-c/l,Math.hypot(Hn,Xn)>1e-9||(Ot=-1)}function jr(e,t){const n=Ot?e-2:0;for(let o=0;o<e;o+=2)if(o!==n&&(at[o]-An)*Hn+(at[o+1]-kn)*Xn<=0)return!1;const s=wn?t-2:0;for(let o=0;o<t;o+=2)if(o!==s&&(ht[o]-An)*Hn+(ht[o+1]-kn)*Xn>=0)return!1;return!0}function Un(e,t,n,s,o,i,r){if(--Is<0||--Ds<0)return;const c=e.length,a=s.length;Es(e,t,n,at),Es(s,o,i,ht);let l=1/0,h=1/0,f=-1/0,u=-1/0;for(let M=0;M<c;M+=2)l=Math.min(l,at[M]),h=Math.min(h,at[M+1]),f=Math.max(f,at[M]),u=Math.max(u,at[M+1]);let p=1/0,_=1/0,y=-1/0,g=-1/0;for(let M=0;M<a;M+=2)p=Math.min(p,ht[M]),_=Math.min(_,ht[M+1]),y=Math.max(y,ht[M]),g=Math.max(g,ht[M+1]);if(l>y||p>f||h>g||_>u||Ot>=0&&(Ot?n===1:t===0)&&(wn?i===1:o===0)&&jr(c,a))return;const x=Math.max(f-l,u-h),b=Math.max(y-p,g-_);if(c===4&&a===4||x<go&&b<go){const M=at[c-2]-at[0],A=at[c-1]-at[1],k=ht[a-2]-ht[0],T=ht[a-1]-ht[1],S=Q(M,A,k,T),w=Q(ht[0]-at[0],ht[1]-at[1],k,T)/S,m=Q(ht[0]-at[0],ht[1]-at[1],M,A)/S;w>=0&&w<=1&&m>=0&&m<=1&&r.push(t+w*(n-t),o+m*(i-o))}else x>b?(Un(e,t,(t+n)/2,s,o,i,r),Un(e,(t+n)/2,n,s,o,i,r)):(Un(e,t,n,s,o,(o+i)/2,r),Un(e,t,n,s,(o+i)/2,i,r))}function Kn(e,t,n){const s=e[2]-e[0],o=e[3]-e[1];return((t-e[0])*s+(n-e[1])*o)/(s*s+o*o)}function Vr(e,t,n){if(e.length!==4||t.length!==4)return!1;const s=e[2]-e[0],o=e[3]-e[1],i=1e-9*Math.hypot(s,o);return Math.abs(Q(s,o,t[0]-e[0],t[1]-e[1]))>i||Math.abs(Q(s,o,t[2]-e[0],t[3]-e[1]))>i?!1:(n.push(Kn(e,t[0],t[1]),0,Kn(e,t[2],t[3]),1),n.push(0,Kn(t,e[0],e[1]),1,Kn(t,e[2],e[3])),!0)}function Wr(e){const t=[];for(let n=e.length-2;n>=0;n-=2)t.push(e[n],e[n+1]);return t}function zr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!(Math.abs(e[n]-t[n])<Cs))return!1;return!0}const Tn=[0,0],zt=[0,0],jn=[0,0,0],Vn=[0,0,0];let on=new Int32Array(8);const Zr=0,Mo=1,Qr=2;function mo(e,t,n,s){let o=0;for(let i=0;i<e.length;i++){if(s<t[4*i+1]-1e-9||s>t[4*i+3]+1e-9)continue;const r=e[i].scanlineIntersections(s,jn,Vn);for(let c=0;c<r;c++)jn[c]<=n&&(o+=Vn[c])}return o!==0}function bo(e,t,n,s,o,i,r){on.fill(0,0,n);for(let a=0;a<e.length;a++){if(r<o[4*a+1]-1e-9||r>o[4*a+3]+1e-9)continue;const l=e[a].scanlineIntersections(r,jn,Vn);for(let h=0;h<l;h++)jn[h]<=i&&(on[t[a]]+=Vn[h])}let c=!1;for(let a=1;a<n&&!c;a++)c=on[a]!==0;return on[0]!==0&&(s===Mo?c:!c)}function Jr(e){const t=Rs([e.contours]);t&&(e.contours=t)}function wo(e,t){const n=Rs([e.contours,...t.length>0?t:[[]]],Mo);n&&(e.contours=n)}function tc(e,t){if(t.length===0)return;const n=Rs([e.contours,...t],Qr);n&&(e.contours=n)}function Rs(e,t=Zr){const n=e.flat(),s=n.flat(),o=s.map(Hr),i=o.length,r=e.length,c=r>1;on.length<r&&(on=new Int32Array(r));const a=new Float64Array(4*i),l=new Int32Array(i),h=new Int32Array(i);let f=0;for(let w=0;w<r;w++)for(const m of e[w]){for(let d=0;d<m.length;d++)l[f+d]=f+(d+1)%m.length,h[f+d]=w;f+=m.length}for(let w=0;w<i;w++){const m=o[w];let d=1/0,U=1/0,C=-1/0,v=-1/0;for(let I=0;I<m.length;I+=2)d=Math.min(d,m[I]),U=Math.min(U,m[I+1]),C=Math.max(C,m[I]),v=Math.max(v,m[I+1]);a[4*w]=d,a[4*w+1]=U,a[4*w+2]=C,a[4*w+3]=v}const u=Array.from({length:i},(w,m)=>m).sort((w,m)=>a[4*w]-a[4*m]),p=o.map(()=>[]),_=new Uint8Array(i);Ds=Yr;for(let w=0;w<i;w++){const m=u[w];for(let d=w+1;d<i;d++){const U=u[d];if(a[4*U]>a[4*m+2])break;if(a[4*m+1]>a[4*U+3]||a[4*U+1]>a[4*m+3])continue;const C=Math.min(m,U),v=Math.max(m,U);l[C]!==v&&l[v]!==C&&(_[C]=_[v]=1);const I=[];if(Is=Br,Vr(o[C],o[v],I)||(Kr(o[C],o[v]),Un(o[C],0,1,o[v],0,1,I)),Is<0||Ds<0)return null;for(let R=0;R<I.length;R+=2)p[C].push(I[R]),p[v].push(I[R+1])}}const y=p.map(w=>{const m=[0];for(const d of w.sort((U,C)=>U-C))d-m[m.length-1]>1e-7&&d<1-1e-7&&m.push(d);return m.push(1),m});let g=!1;const x=[],b=[];let M=0;for(const w of n){const m=M+w.length;let d=!0;for(let I=M;I<m;I++)(_[I]||y[I].length>2)&&(d=!1);let U=!1,C=!1,v=!1;for(let I=M;I<m;I++){const R=y[I];for(let G=1;G<R.length;G++){const F=Xr(o[I],R[G-1],R[G]),X=xo(F);X.point(.5,Tn),X.direction(.5,zt);const H=Math.hypot(zt[0],zt[1]),V=Math.hypot(F[F.length-2]-F[0],F[F.length-1]-F[1]);if(!(H===0||V===0)){if(!d||!U){const et=Math.min(1e-6,V*V/64)/H,z=Tn[0]+zt[1]*et,Gt=Tn[1]-zt[0]*et,_t=Tn[0]-zt[1]*et,Xt=Tn[1]+zt[0]*et;C=c?bo(s,h,r,t,a,z,Gt):mo(s,a,z,Gt),v=c?bo(s,h,r,t,a,_t,Xt):mo(s,a,_t,Xt),U=!0}C===v?h[I]===0&&(g=!0):(x.push(F),b.push(C),h[I]!==0&&(g=!0))}}}M=m}const A=2*b.filter(Boolean).length>=b.length,k=[];for(let w=0;w<x.length;w++){let m=x[w];b[w]!==A&&(m=Wr(m),g=!0);let d=!1;for(let U=0;U<k.length&&!d;U++)d=zr(k[U],m);d?g=!0:k.push(m)}if(!g)return null;const T=new Uint8Array(k.length),S=[];for(let w=0;w<k.length;w++){if(T[w])continue;T[w]=1;const m=[k[w]];for(;;){const d=m[m.length-1],U=d[d.length-2],C=d[d.length-1];if(m.length>1&&Math.hypot(U-m[0][0],C-m[0][1])<Cs){m[0][0]=U,m[0][1]=C;break}let v=-1,I=Cs;for(let R=0;R<k.length;R++){if(T[R])continue;const G=Math.hypot(k[R][0]-U,k[R][1]-C);G<I&&(v=R,I=G)}if(v<0)return null;T[v]=1,k[v][0]=U,k[v][1]=C,m.push(k[v])}S.push(m.map(xo))}return S}const Wn=1,zn=2,nc=3,Zn=4,sc=5,ec=6,Ls=7,pt=[0,0],Zt=[0,0];function oc(e,t){return Math.trunc(3+2.875*e/(t-1)-1.4375+.5)-3}function ic(e,t,n,s,o){return e*n+t*s<=0||Math.abs(e*s-t*n)>o}function rc(e){const t=Number(e.v&1n);return e.v>>=1n,t}function cc(e){const t=Number(e.v%3n);return e.v/=3n,t}function Ao(e){return[ec,sc,nc][cc(e)]}function Sn(e,t){const n=e.v<<1+rc(t);e.v=(n|n>>3)&Ls}function ac(e,t,n){const s=e.v&n;s===Wn||s===zn||s===Zn?e.v=s^Ls:Sn(e,t)}function lc(e,t,n=0n){const s=Math.sin(t),o={v:Ao({v:n})},i={v:n};i.v=n,o.v=Ao(i);const r=[];for(const c of e.contours){if(c.length===0)continue;r.length=0,c[c.length-1].direction(1,pt);const l=Math.sqrt(pt[0]*pt[0]+pt[1]*pt[1]);let h=l>0?pt[0]/l:0,f=l>0?pt[1]/l:0;for(let u=0;u<c.length;u++){const p=c[u];p.direction(0,Zt);const _=Math.sqrt(Zt[0]*Zt[0]+Zt[1]*Zt[1]),y=_>0?Zt[0]/_:0,g=_>0?Zt[1]/_:0;ic(h,f,y,g,s)&&r.push(u),p.direction(1,pt);const x=Math.sqrt(pt[0]*pt[0]+pt[1]*pt[1]);h=x>0?pt[0]/x:0,f=x>0?pt[1]/x:0}if(r.length===0){Sn(o,i);for(const u of c)u.color=o.v}else if(r.length===1){const u=[0,Ls,0];Sn(o,i),u[0]=o.v,Sn(o,i),u[2]=o.v;const p=r[0],_=c.length;if(_>=3)for(let y=0;y<_;y++){const g=oc(y,_);c[(p+y)%_].color=u[1+g]}else if(_>=1){const y=[null,null,null,null,null,null,null],g=c[0].splitInThirds();if(y[0+3*p]=g[0],y[1+3*p]=g[1],y[2+3*p]=g[2],_>=2){const x=c[1].splitInThirds();y[3-3*p]=x[0],y[4-3*p]=x[1],y[5-3*p]=x[2],y[0].color=y[1].color=u[0],y[2].color=y[3].color=u[1],y[4].color=y[5].color=u[2]}else y[0].color=u[0],y[1].color=u[1],y[2].color=u[2];c.length=0;for(const x of y)x!==null&&c.push(x)}}else{const u=r.length;let p=0;const _=r[0],y=c.length;Sn(o,i);const g=o.v;for(let x=0;x<y;x++){const b=(_+x)%y;p+1<u&&r[p+1]===b&&(++p,ac(o,i,p===u-1?g:0)),c[b].color=o.v}}}}const j=Number.MAX_VALUE,q=[0,0],Mt=[0,0];let ko=0,nt=new Float64Array(0),it=new Float64Array(0),N=new Float64Array(0),$=new Float64Array(0),rt=new Int32Array(0),ct=new Float64Array(0),rn=new Float64Array(0),cn=new Float64Array(0),an=new Float64Array(0),Qt=new Int32Array(0);const st=[0,0];let Uo=0,Ps=new Float64Array(0),Fs=new Float64Array(0),qs=new Float64Array(0),Os=new Float64Array(0),Gs=new Float64Array(0),Ns=new Float64Array(0),$s=new Float64Array(0),Bs=new Float64Array(0),Ys=new Float64Array(0),Hs=new Float64Array(0),Xs=new Float64Array(0),Ks=new Float64Array(0),To=0,vn=new Int32Array(0);function hc(e){const t=e.length;if(t===0)return 0;let n=0;if(t===1){e[0].point(0,st);const s=st[0],o=st[1];e[0].point(.3333333333333333,st);const i=st[0],r=st[1];e[0].point(.6666666666666666,st);const c=st[0],a=st[1];n+=s*r-o*i,n+=i*a-r*c,n+=c*o-a*s}else if(t===2){e[0].point(0,st);const s=st[0],o=st[1];e[0].point(.5,st);const i=st[0],r=st[1];e[1].point(0,st);const c=st[0],a=st[1];e[1].point(.5,st);const l=st[0],h=st[1];n+=s*r-o*i,n+=i*a-r*c,n+=c*h-a*l,n+=l*o-h*s}else{const s=e[t-1];let o=s.p0x,i=s.p0y;for(let r=0;r<t;r++){const c=e[r].p0x,a=e[r].p0y;n+=o*a-i*c,o=c,i=a}}return n>0?-1:n<0?1:0}function fc(e,t,n,s,o,i,r){const c=r[e][t];let a=n;if(i<0){c.direction(0,q);const l=Math.sqrt(q[0]*q[0]+q[1]*q[1]);if(l>0){const h=q[0]/l,f=q[1]/l;c.point(0,Mt);const u=s-Mt[0],p=o-Mt[1];if(u*h+p*f<0){const y=u*f-p*h;Math.abs(y)<=Math.abs(a)&&(a=y)}}}if(i>1){c.direction(1,q);const l=Math.sqrt(q[0]*q[0]+q[1]*q[1]);if(l>0){const h=q[0]/l,f=q[1]/l;c.point(1,Mt);const u=s-Mt[0],p=o-Mt[1];if(u*h+p*f>0){const y=u*f-p*h;Math.abs(y)<=Math.abs(a)&&(a=y)}}}return a}function mt(e,t,n,s,o,i,r,c,a){let l=e<0?t:n;if(o>=0){const h=fc(s,o,e,r,c,i,a);Math.abs(h)<Math.abs(l)&&(l=h)}return l}function Tt(e,t,n){return Math.max(Math.min(e,t),Math.min(Math.max(e,t),n))}function uc(e,t,n,s,o,i,r,c){if(c.length!==t*n*3)throw new Error(`generateMSDF: out.length ${c.length} !== ${t*n*3}`);const a=e.contours,l=a.length;if(l===0){c.fill(0);return}const h=s/r;Qt.length<l&&(Qt=new Int32Array(l));for(let p=0;p<l;p++)Qt[p]=hc(a[p]);To<l+1&&(vn=new Int32Array(l+1),To=l+1);let f=0;for(let p=0;p<l;p++)vn[p]=f,f+=a[p].length;vn[l]=f,Uo<f&&(Ps=new Float64Array(f),Fs=new Float64Array(f),qs=new Float64Array(f),Os=new Float64Array(f),Gs=new Float64Array(f),Ns=new Float64Array(f),$s=new Float64Array(f),Bs=new Float64Array(f),Ys=new Float64Array(f),Hs=new Float64Array(f),Xs=new Float64Array(f),Ks=new Float64Array(f),Uo=f);for(let p=0;p<l;p++){const _=a[p],y=_.length,g=vn[p];for(let x=0;x<y;x++){const b=_[x],M=_[(x+y-1)%y],A=_[(x+1)%y],k=g+x;b.point(0,Mt),Ps[k]=Mt[0],Fs[k]=Mt[1],b.point(1,Mt),qs[k]=Mt[0],Os[k]=Mt[1],b.direction(0,q);let T=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const S=T>0?q[0]/T:0,w=T>0?q[1]/T:0;Gs[k]=S,Ns[k]=w,b.direction(1,q),T=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const m=T>0?q[0]/T:0,d=T>0?q[1]/T:0;$s[k]=m,Bs[k]=d,M.direction(1,q),T=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const U=T>0?q[0]/T:0,C=T>0?q[1]/T:0;A.direction(0,q),T=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const v=T>0?q[0]/T:0,I=T>0?q[1]/T:0,R=U+S,G=C+w,F=Math.sqrt(R*R+G*G);Ys[k]=F>0?R/F:0,Hs[k]=F>0?G/F:0;const X=m+v,H=d+I,V=Math.sqrt(X*X+H*H);Xs[k]=V>0?-(X/V):0,Ks[k]=V>0?-(H/V):0}}if(ko<l){const p=l*3;nt=new Float64Array(p),it=new Float64Array(p),N=new Float64Array(p),$=new Float64Array(p),rt=new Int32Array(p),ct=new Float64Array(p),rn=new Float64Array(l),cn=new Float64Array(l),an=new Float64Array(l),ko=l}const u={distance:0,dot:0,param:0};for(let p=0;p<n;p++)for(let _=0;_<t;_++){const y=(_+.5)/s-o,g=(p+.5)/s-i;for(let P=0;P<l;P++){const D=a[P],yt=D.length,E=P*3,B=vn[P];nt[E]=nt[E+1]=nt[E+2]=-j,it[E]=it[E+1]=it[E+2]=0,N[E]=N[E+1]=N[E+2]=-j,$[E]=$[E+1]=$[E+2]=j,rt[E]=rt[E+1]=rt[E+2]=-1,ct[E]=ct[E+1]=ct[E+2]=0;for(let Y=0;Y<yt;Y++){const W=D[Y],ge=W.color,xe=(ge&Wn)!==0,de=(ge&zn)!==0,Me=(ge&Zn)!==0;W.signedDistance(y,g,u);const ys=u.distance,hn=u.dot,me=u.param,Kt=Math.abs(ys);if(xe){const Pt=Math.abs(nt[E]);(Kt<Pt||Kt===Pt&&hn<it[E])&&(nt[E]=ys,it[E]=hn,rt[E]=Y,ct[E]=me)}if(de){const Pt=Math.abs(nt[E+1]);(Kt<Pt||Kt===Pt&&hn<it[E+1])&&(nt[E+1]=ys,it[E+1]=hn,rt[E+1]=Y,ct[E+1]=me)}if(Me){const Pt=Math.abs(nt[E+2]);(Kt<Pt||Kt===Pt&&hn<it[E+2])&&(nt[E+2]=ys,it[E+2]=hn,rt[E+2]=Y,ct[E+2]=me)}const At=B+Y,be=y-Ps[At],we=g-Fs[At],Ae=y-qs[At],ke=g-Os[At],xi=Gs[At],di=Ns[At],Mi=$s[At],mi=Bs[At],Nc=be*Ys[At]+we*Hs[At],$c=Ae*Xs[At]+ke*Ks[At];if(Nc>0&&-(be*xi+we*di)>0){const O=be*di-we*xi;Math.abs(O)<Kt&&(xe&&(O<=0&&O>N[E]?N[E]=O:O>0&&O<$[E]&&($[E]=O)),de&&(O<=0&&O>N[E+1]?N[E+1]=O:O>0&&O<$[E+1]&&($[E+1]=O)),Me&&(O<=0&&O>N[E+2]?N[E+2]=O:O>0&&O<$[E+2]&&($[E+2]=O)))}if($c>0&&Ae*Mi+ke*mi>0){const O=Ae*mi-ke*Mi;Math.abs(O)<Kt&&(xe&&(O<=0&&O>N[E]?N[E]=O:O>0&&O<$[E]&&($[E]=O)),de&&(O<=0&&O>N[E+1]?N[E+1]=O:O>0&&O<$[E+1]&&($[E+1]=O)),Me&&(O<=0&&O>N[E+2]?N[E+2]=O:O>0&&O<$[E+2]&&($[E+2]=O)))}}rn[P]=mt(nt[E],N[E],$[E],P,rt[E],ct[E],y,g,a),cn[P]=mt(nt[E+1],N[E+1],$[E+1],P,rt[E+1],ct[E+1],y,g,a),an[P]=mt(nt[E+2],N[E+2],$[E+2],P,rt[E+2],ct[E+2],y,g,a)}let x=-j,b=0,M=-j,A=j,k=-1,T=-1,S=0,w=-j,m=0,d=-j,U=j,C=-1,v=-1,I=0,R=-j,G=0,F=-j,X=j,H=-1,V=-1,et=0,z=-j,Gt=0,_t=-j,Xt=j,Nt=-1,Yo=-1,Ho=0,as=-j,Xo=0,ne=-j,se=j,Ko=-1,jo=-1,Vo=0,ls=-j,Wo=0,ee=-j,oe=j,zo=-1,Zo=-1,Qo=0,hs=-j,Jo=0,ie=-j,re=j,ti=-1,ni=-1,si=0,fs=-j,ei=0,ce=-j,ae=j,oi=-1,ii=-1,ri=0,us=-j,ci=0,le=-j,he=j,ai=-1,li=-1,hi=0;for(let P=0;P<l;P++){const D=P*3,yt=Qt[P],E=Tt(rn[P],cn[P],an[P]);{const B=nt[D],Y=it[D],W=Math.abs(B);(W<Math.abs(x)||W===Math.abs(x)&&Y<b)&&(x=B,b=Y,k=P,T=rt[D],S=ct[D]),N[D]>M&&(M=N[D]),$[D]<A&&(A=$[D])}{const B=nt[D+1],Y=it[D+1],W=Math.abs(B);(W<Math.abs(w)||W===Math.abs(w)&&Y<m)&&(w=B,m=Y,C=P,v=rt[D+1],I=ct[D+1]),N[D+1]>d&&(d=N[D+1]),$[D+1]<U&&(U=$[D+1])}{const B=nt[D+2],Y=it[D+2],W=Math.abs(B);(W<Math.abs(R)||W===Math.abs(R)&&Y<G)&&(R=B,G=Y,H=P,V=rt[D+2],et=ct[D+2]),N[D+2]>F&&(F=N[D+2]),$[D+2]<X&&(X=$[D+2])}if(yt>0&&E>=0){{const B=nt[D],Y=it[D],W=Math.abs(B);(W<Math.abs(z)||W===Math.abs(z)&&Y<Gt)&&(z=B,Gt=Y,Nt=P,Yo=rt[D],Ho=ct[D]),N[D]>_t&&(_t=N[D]),$[D]<Xt&&(Xt=$[D])}{const B=nt[D+1],Y=it[D+1],W=Math.abs(B);(W<Math.abs(as)||W===Math.abs(as)&&Y<Xo)&&(as=B,Xo=Y,Ko=P,jo=rt[D+1],Vo=ct[D+1]),N[D+1]>ne&&(ne=N[D+1]),$[D+1]<se&&(se=$[D+1])}{const B=nt[D+2],Y=it[D+2],W=Math.abs(B);(W<Math.abs(ls)||W===Math.abs(ls)&&Y<Wo)&&(ls=B,Wo=Y,zo=P,Zo=rt[D+2],Qo=ct[D+2]),N[D+2]>ee&&(ee=N[D+2]),$[D+2]<oe&&(oe=$[D+2])}}if(yt<0&&E<=0){{const B=nt[D],Y=it[D],W=Math.abs(B);(W<Math.abs(hs)||W===Math.abs(hs)&&Y<Jo)&&(hs=B,Jo=Y,ti=P,ni=rt[D],si=ct[D]),N[D]>ie&&(ie=N[D]),$[D]<re&&(re=$[D])}{const B=nt[D+1],Y=it[D+1],W=Math.abs(B);(W<Math.abs(fs)||W===Math.abs(fs)&&Y<ei)&&(fs=B,ei=Y,oi=P,ii=rt[D+1],ri=ct[D+1]),N[D+1]>ce&&(ce=N[D+1]),$[D+1]<ae&&(ae=$[D+1])}{const B=nt[D+2],Y=it[D+2],W=Math.abs(B);(W<Math.abs(us)||W===Math.abs(us)&&Y<ci)&&(us=B,ci=Y,ai=P,li=rt[D+2],hi=ct[D+2]),N[D+2]>le&&(le=N[D+2]),$[D+2]<he&&(he=$[D+2])}}}const fe=mt(x,M,A,k,T,S,y,g,a),ue=mt(w,d,U,C,v,I,y,g,a),pe=mt(R,F,X,H,V,et,y,g,a),Gc=Tt(fe,ue,pe),fi=mt(z,_t,Xt,Nt,Yo,Ho,y,g,a),ui=mt(as,ne,se,Ko,jo,Vo,y,g,a),pi=mt(ls,ee,oe,zo,Zo,Qo,y,g,a),ps=Tt(fi,ui,pi),_i=mt(hs,ie,re,ti,ni,si,y,g,a),yi=mt(fs,ce,ae,oi,ii,ri,y,g,a),gi=mt(us,le,he,ai,li,hi,y,g,a),_s=Tt(_i,yi,gi);let St,vt,Ct,_e=0;if(ps>=0&&Math.abs(ps)<=Math.abs(_s)){St=fi,vt=ui,Ct=pi,_e=1;for(let P=0;P<l;P++)if(Qt[P]>0){const D=rn[P],yt=cn[P],E=an[P],B=Tt(D,yt,E);Math.abs(B)<Math.abs(_s)&&B>Tt(St,vt,Ct)&&(St=D,vt=yt,Ct=E)}}else if(_s<=0&&Math.abs(_s)<Math.abs(ps)){St=_i,vt=yi,Ct=gi,_e=-1;for(let P=0;P<l;P++)if(Qt[P]<0){const D=rn[P],yt=cn[P],E=an[P],B=Tt(D,yt,E);Math.abs(B)<Math.abs(ps)&&B<Tt(St,vt,Ct)&&(St=D,vt=yt,Ct=E)}}else{const P=(p*t+_)*3;c[P+0]=fe*h+.5,c[P+1]=ue*h+.5,c[P+2]=pe*h+.5;continue}for(let P=0;P<l;P++)if(Qt[P]!==_e){const D=rn[P],yt=cn[P],E=an[P],B=Tt(D,yt,E),Y=Tt(St,vt,Ct);B*Y>=0&&Math.abs(B)<Math.abs(Y)&&(St=D,vt=yt,Ct=E)}Tt(St,vt,Ct)===Gc&&(St=fe,vt=ue,Ct=pe);const ye=(p*t+_)*3;c[ye+0]=St*h+.5,c[ye+1]=vt*h+.5,c[ye+2]=Ct*h+.5}}const So=0,pc=1,_c=2,yc=3;function gc(e,t){switch(t){case So:return e!==0;case pc:return(e&1)!==0;case _c:return e>0;case yc:return e<0}return!1}class xc{constructor(){this._intersections=[],this._lastIndex=0}setIntersections(t){if(this._intersections=t,this._lastIndex=0,t.length>0){t.sort((s,o)=>ut(s.x-o.x));let n=0;for(let s=0;s<t.length;s++)n+=t[s].direction,t[s].direction=n}}_moveTo(t){const n=this._intersections.length;if(n===0)return-1;let s=this._lastIndex;if(t<this._intersections[s].x)do{if(s===0)return this._lastIndex=0,-1;--s}while(t<this._intersections[s].x);else for(;s<n-1&&t>=this._intersections[s+1].x;)++s;return this._lastIndex=s,s}sumIntersections(t){const n=this._moveTo(t);return n>=0?this._intersections[n].direction:0}filled(t,n){return gc(this.sumIntersections(t),n)}}const vo=[0,0,0],Co=[0,0,0];function dc(e,t,n){const s=[];for(const o of e.contours)for(const i of o){const r=i.scanlineIntersections(t,vo,Co);for(let c=0;c<r;c++)s.push({x:vo[c],direction:Co[c]})}n.setIntersections(s)}const ln=2,Eo=1,js=1.001,Mc=1.1111111111111112,Qn=.01;function mc(e,t,n,s,o,i,r){if(n===0||s===0)return;const c=new xc,a=new Int8Array(n*s);for(let l=0;l<s;l++){const h=(l+.5)/o-r;dc(t,h,c);for(let f=0;f<n;f++){const u=(f+.5)/o-i,p=c.filled(u,So),_=(l*n+f)*3,y=e[_],g=e[_+1],x=e[_+2],b=ft(y,g,x),M=l*n+f;b===.5?a[M]=0:b>.5!==p?(e[_]=1-y,e[_+1]=1-g,e[_+2]=1-x,a[M]=-1):a[M]=1}}for(let l=0;l<s;l++)for(let h=0;h<n;h++){const f=l*n+h;if(a[f]!==0)continue;let u=0;if(h>0&&(u+=a[f-1]),h<n-1&&(u+=a[f+1]),l>0&&(u+=a[f-n]),l<s-1&&(u+=a[f+n]),u<0){const p=(l*n+h)*3;e[p]=1-e[p],e[p+1]=1-e[p+1],e[p+2]=1-e[p+2]}}}const Vs=[0,0];function bc(e,t,n,s,o,i,r,c){const a=new Uint8Array(n*s);wc(a,t,n,s,o,i,r),Ac(a,e,n,s,o,c),Sc(a,e,n,s,c,Mc),vc(a,e,n,s)}function wc(e,t,n,s,o,i,r){for(const c of t.contours){if(c.length===0)continue;let a=c[c.length-1];for(const l of c){const h=a.color&l.color;if(!(h&h-1)){l.point(0,Vs);const f=o*(Vs[0]+i),u=o*(Vs[1]+r),p=Math.floor(f-.5)|0,_=Math.floor(u-.5)|0,y=p+1,g=_+1;p<n&&_<s&&y>=0&&g>=0&&(p>=0&&_>=0&&(e[_*n+p]|=ln),y<n&&_>=0&&(e[_*n+y]|=ln),p>=0&&g<s&&(e[g*n+p]|=ln),y<n&&g<s&&(e[g*n+y]|=ln))}a=l}}}function Jn(e,t,n){let s=0;for(let o=0;o<3;o++){const i=e[t+o],r=e[n+o],c=i-r;if(c===0)continue;const a=(i-.5)/c;if(a>0&&a<1){const l=1-a,h=l*e[t]+a*e[n],f=l*e[t+1]+a*e[n+1],u=l*e[t+2]+a*e[n+2],p=o===0?h:o===1?f:u;ft(h,f,u)===p&&(s|=o===0?Wn:o===1?zn:Zn)}}return s}function Ht(e,t,n,s,o,i){(i&Wn&&n[s]!==o||i&zn&&n[s+1]!==o||i&Zn&&n[s+2]!==o)&&(e[t]|=ln)}function Ac(e,t,n,s,o,i){const r=js/i,c=js/i,a=js*Math.SQRT2/i;for(let l=0;l<s;l++)for(let h=0;h<n-1;h++){const f=(l*n+h)*3,u=f+3,p=ft(t[f],t[f+1],t[f+2]),_=ft(t[u],t[u+1],t[u+2]);if(Math.abs(p-.5)+Math.abs(_-.5)<r){const y=Jn(t,f,u);Ht(e,l*n+h,t,f,p,y),Ht(e,l*n+h+1,t,u,_,y)}}for(let l=0;l<s-1;l++)for(let h=0;h<n;h++){const f=(l*n+h)*3,u=((l+1)*n+h)*3,p=ft(t[f],t[f+1],t[f+2]),_=ft(t[u],t[u+1],t[u+2]);if(Math.abs(p-.5)+Math.abs(_-.5)<c){const y=Jn(t,f,u);Ht(e,l*n+h,t,f,p,y),Ht(e,(l+1)*n+h,t,u,_,y)}}for(let l=0;l<s-1;l++)for(let h=0;h<n-1;h++){const f=(l*n+h)*3,u=(l*n+h+1)*3,p=((l+1)*n+h)*3,_=((l+1)*n+h+1)*3,y=ft(t[f],t[f+1],t[f+2]),g=ft(t[u],t[u+1],t[u+2]),x=ft(t[p],t[p+1],t[p+2]),b=ft(t[_],t[_+1],t[_+2]);if(Math.abs(y-.5)+Math.abs(b-.5)<a){const M=Jn(t,f,_);Ht(e,l*n+h,t,f,y,M),Ht(e,(l+1)*n+h+1,t,_,b,M)}if(Math.abs(g-.5)+Math.abs(x-.5)<a){const M=Jn(t,u,p);Ht(e,l*n+h+1,t,u,g,M),Ht(e,(l+1)*n+h,t,p,x,M)}}}function kc(e,t,n){const s=t<e?t:e,o=e<t?t:e,i=n<o?n:o;return s<i?i:s}function Uc(e,t,n,s){return ft(e[t]+s*(e[n]-e[t]),e[t+1]+s*(e[n+1]-e[t+1]),e[t+2]+s*(e[n+2]-e[t+2]))}function Ws(e,t,n,s){return kc(Math.fround(s*(s*n[0]+t[0])+e[0]),Math.fround(s*(s*n[1]+t[1])+e[1]),Math.fround(s*(s*n[2]+t[2])+e[2]))}const Jt=[0,0,0],Lt=[0,0,0],zs=[0,0,0],bt=[0,0,0],Io=1,Do=2;function Zs(e,t,n,s,o,i,r,c){if(s>.5&&o>.5&&i<=.5||s<.5&&o<.5&&i>=.5||!c&&Tc(s,o,i)!==i){const a=(n-e)*r,l=(t-n)*r;return i>=s-a&&i<=s+a&&i>=o-l&&i<=o+l?Io:Io|Do}return 0}function Ro(e){return(e&Do)!==0}function Tc(e,t,n){return Math.max(Math.min(e,t),Math.min(Math.max(e,t),n))}function ts(e,t,n,s,o,i){const r=ft(e[n],e[n+1],e[n+2]);if(Math.abs(s-.5)<Math.abs(r-.5))return!1;for(let c=0;c<3;c++){const a=e[t+c]-e[t+(c+1)%3],l=e[n+c]-e[n+(c+1)%3],h=a-l;if(h===0)continue;const f=a/h;if(f>Qn&&f<1-Qn){const u=Uc(e,t,n,f),p=Zs(0,1,f,s,r,u,o,i);if(Ro(p))return!0}}return!1}function Lo(e,t,n,s,o,i,r,c,a){if(!(a>0&&a<1))return 0;const l=a>r?0:a,h=a>r?a:1;bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2];const f=a>r?n:Ws(bt,Jt,Lt,a);bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2];const u=a>r?Ws(bt,Jt,Lt,a):s;return Zs(l,h,r,f,u,c,o,i)}function ns(e,t,n,s,o,i,r,c,a){if(!(r>Qn&&r<1-Qn))return!1;bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2];const l=Ws(bt,Jt,Lt,r);let h=Zs(0,1,r,n,s,l,o,i);return h|=Lo(e,t,n,s,o,i,r,l,c),h|=Lo(e,t,n,s,o,i,r,l,a),Ro(h)}function Qs(e,t,n,s,o,i,r,c,a,l,h,f,u){const p=Math.fround(e[t+l]-e[t+h]),_=Math.fround(Math.fround(e[n+l]-e[n+h])+Math.fround(e[s+l]-e[s+h])),y=Math.fround(e[o+l]-e[o+h]),g=Math.fround(Math.fround(y-_)+p),x=Math.fround(Math.fround(_-p)-p),b=p;if(g===0||Math.abs(x)>1e12*Math.abs(g)){if(x!==0){const A=-b/x;if(ns(e,t,i,r,c,a,A,f,u))return!0}return!1}const M=x*x-4*g*b;if(M>0){const A=Math.sqrt(M),k=(-x+A)/(2*g);if(ns(e,t,i,r,c,a,k,f,u))return!0;const T=(-x-A)/(2*g);if(ns(e,t,i,r,c,a,T,f,u))return!0}else if(M===0){const A=-x/(2*g);if(ns(e,t,i,r,c,a,A,f,u))return!0}return!1}function ss(e,t,n,s,o,i,r,c){const a=ft(e[o],e[o+1],e[o+2]);if(Math.abs(i-.5)<Math.abs(a-.5))return!1;for(let u=0;u<3;u++)zs[u]=Math.fround(Math.fround(e[t+u]-e[n+u])-e[s+u]),Jt[u]=Math.fround(-e[t+u]-zs[u]),Lt[u]=Math.fround(e[o+u]+zs[u]);const l=Lt[0]!==0?-.5*Jt[0]/Lt[0]:-1,h=Lt[1]!==0?-.5*Jt[1]/Lt[1]:-1,f=Lt[2]!==0?-.5*Jt[2]/Lt[2]:-1;return!!(Qs(e,t,n,s,o,i,a,r,c,0,1,l,h)||Qs(e,t,n,s,o,i,a,r,c,1,2,h,f)||Qs(e,t,n,s,o,i,a,r,c,2,0,f,l))}function Sc(e,t,n,s,o,i){const r=i/o,c=i/o,a=i*Math.SQRT2/o;for(let l=0;l<s;l++)for(let h=0;h<n;h++){const f=l*n+h,u=f*3,p=ft(t[u],t[u+1],t[u+2]),_=(e[f]&ln)!==0,y=h>0,g=h<n-1,x=l>0,b=l<s-1,M=y?(f-1)*3:-1,A=g?(f+1)*3:-1,k=x?(f-n)*3:-1,T=b?(f+n)*3:-1;let S=!1;if(y&&ts(t,u,M,p,r,_)&&(S=!0),!S&&x&&ts(t,u,k,p,c,_)&&(S=!0),!S&&g&&ts(t,u,A,p,r,_)&&(S=!0),!S&&b&&ts(t,u,T,p,c,_)&&(S=!0),!S&&y&&x){const w=(f-n-1)*3;ss(t,u,M,k,w,p,a,_)&&(S=!0)}if(!S&&g&&x){const w=(f-n+1)*3;ss(t,u,A,k,w,p,a,_)&&(S=!0)}if(!S&&y&&b){const w=(f+n-1)*3;ss(t,u,M,T,w,p,a,_)&&(S=!0)}if(!S&&g&&b){const w=(f+n+1)*3;ss(t,u,A,T,w,p,a,_)&&(S=!0)}S&&(e[f]|=Eo)}}function vc(e,t,n,s){const o=n*s;for(let i=0;i<o;i++)if(e[i]&Eo){const r=i*3,c=ft(t[r],t[r+1],t[r+2]);t[r]=c,t[r+1]=c,t[r+2]=c}}function ft(e,t,n){return Math.max(Math.min(e,t),Math.min(Math.max(e,t),n))}const Cc=3,Ec=0n,Po=16;function Fo(e,t,n,s=!0){if(s&&Jr(e),e.contours.length===0)return null;const o=es(e),i=t,r=n,c=Math.max(1,Math.ceil((o.maxX-o.minX)*i))+2*r,a=Math.max(1,Math.ceil((o.maxY-o.minY)*i))+2*r,l=r/i-o.minX,h=r/i-o.minY;$r(e),lc(e,Cc,Ec);const f=new Float32Array(c*a*3);return uc(e,c,a,i,l,h,r,f),mc(f,e,c,a,i,l,h),bc(f,e,c,a,i,l,h,r),{msdf:f,w:c,h:a,planeLeft:-l,planeBottom:-h,planeRight:c/i-l,planeTop:a/i-h}}const Js=[0,0];function es(e){let t=1/0,n=1/0,s=-1/0,o=-1/0;for(const i of e.contours)for(const r of i)for(let c=0;c<=Po;c++){r.point(c/Po,Js);const a=Js[0],l=Js[1];a<t&&(t=a),l<n&&(n=l),a>s&&(s=a),l>o&&(o=l)}return{minX:t,minY:n,maxX:s,maxY:o}}function Z(e,t){var n;return(n=new RegExp(`\\s${t}\\s*=\\s*(["'])([\\s\\S]*?)\\1`).exec(e))==null?void 0:n[2]}function os(e,t,n){const s=new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*([^;]+)`,"g"),o=c=>{var a,l;return(l=(a=[...c.matchAll(s)].pop())==null?void 0:a[1])==null?void 0:l.trim()},i=Z(e,"class");let r="";if(i&&n){const c=new Set(i.split(/\s+/));r=n.filter(([a])=>c.has(a)).map(([,a])=>a).join(";")}return o(Z(e,"style")??"")??o(r)??Z(e,t)}function is(e,t){return e===void 0?t:parseFloat(e)/(e.trim().endsWith("%")?100:1)}function tn(e,t){return e===void 0?0:parseFloat(e)*(e.trim().endsWith("%")?t/100:1)}function Ic(e){const{layers:t,width:n}=qo(e);return{shape:{contours:t.flatMap(o=>o.shape.contours),inverseYAxis:!1},width:n}}function qo(e){var k,T;e=e.replace(/<!--[\s\S]*?-->/g,"");const t=((k=/<svg\b[^>]*>/.exec(e))==null?void 0:k[0])??"",n=(Z(t,"viewBox")??`0 0 ${Z(t,"width")} ${Z(t,"height")}`).trim().split(/[\s,]+/).map(parseFloat),[s=0,o=0,i=NaN,r=NaN]=n;if(!(r>0))throw new Error("parseSvg: needs a viewBox or width/height");const c=[i,r],a=[r,0,0,-r,s,o+r],l=[1,0,0,-1,-s,o+r],h=i/r,f=[];i>0&&rs(`M${s} ${o}h${i}v${r}h${-i}z`,l,f),Yn({contours:f},r);const u=new Map,p=/<(linear|radial)Gradient\b([^>]*?)(?:\/>|>([\s\S]*?)<\/\1Gradient>)/g;for(const[,S="",w="",m=""]of e.matchAll(p))u.set(Z(w,"id")??"",[S,w,m]);const _=new Map;for(const[,S="",w=""]of e.matchAll(/<clipPath\b([^>]*?)(?:\/>|>([\s\S]*?)<\/clipPath>)/g))_.set(Z(S,"id")??"",[S,w]);const y=new Map;for(const[,S="",w=""]of e.matchAll(Oo)){const m=Z(w,"id");m!==void 0&&y.set(m,[S,w])}const g=[];for(const[,S=""]of e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/g))for(const[,w="",m=""]of S.matchAll(/([^{}]+)\{([^}]*)\}/g))for(const d of w.split(",")){const U=(T=/^\s*\.([\w-]+)\s*$/.exec(d))==null?void 0:T[1];U&&g.push([U,m])}const x=[],b=[],M=[{m:[1,0,0,1,0,0],fill:"black",rule:"nonzero",fillOpacity:1,opacity:1,clips:[],group:-1}];let A=0;for(const[,S,w="",m="",d]of e.matchAll(/<(\/?)([\w:-]+)([^>]*?)(\/?)>/g)){if(A>0||/^(defs|clipPath|mask|symbol|pattern|marker|style)$/.test(w)){S?A--:d||A++;continue}if(S){M.pop();continue}const U=M[M.length-1],C=_t=>os(m,_t,g),v=is(C("opacity"),1),I=No(w,m,c),R={m:wt(U.m,Cn(Z(m,"transform")??"")),fill:C("fill")??U.fill,rule:C("fill-rule")??U.rule,fillOpacity:is(C("fill-opacity"),U.fillOpacity),opacity:U.opacity*v,clips:U.clips,group:U.group};I===void 0&&v<1&&!d&&(R.group=b.push({members:[],parent:U.group,translucent:!1})-1);const G=_.get(Go(C("clip-path")));if(G&&Z(G[0],"clipPathUnits")!=="objectBoundingBox"&&(R.clips=[...U.clips,Dc(G,y,g,wt(l,R.m),c)]),d||M.push(R),I===void 0||R.fill==="none")continue;const F=[];rs(I,wt(l,R.m),F),R.rule==="evenodd"&&yo(F);const X={contours:F,inverseYAxis:!1};Yn(X,r);const H=u.get(Go(R.fill)),V=wt($o(R.m),a),et=H?Rc(H,u,g,V,I,c):null;for(const _t of R.clips)wo(X,_t);const z=es(X);if(!(z.maxX<=0||z.minX>=h||z.maxY<=0||z.minY>=1||((z.minX<0||z.minY<0||z.maxX>h||z.maxY>1)&&f.length>0&&wo(X,[f]),X.contours.length===0))){if(R.group>=0){const _t=b[R.group];_t.members.push(x.length);const Xt=et?et.stops.some(Nt=>Nt.opacity<1):!1;(v<1||R.fillOpacity<1||Xt)&&(_t.translucent=!0);for(let Nt=_t.parent;Nt>=0;Nt=b[Nt].parent)b[Nt].translucent=!0}x.push({shape:X,color:R.fill,opacity:R.opacity*R.fillOpacity,gradient:et})}}for(const S of b){if(S.translucent||S.members.length<2)continue;const w=S.members.map(m=>es(x[m].shape));for(let m=0;m<S.members.length-1;m++){const d=w[m],U=[];for(let C=m+1;C<S.members.length;C++){const v=w[C];v.minX<d.maxX&&d.minX<v.maxX&&v.minY<d.maxY&&d.minY<v.maxY&&U.push(x[S.members[C]].shape.contours)}tc(x[S.members[m]].shape,U)}}return{layers:x.filter(S=>S.shape.contours.length>0),width:i/r}}const Oo=/<([\w:-]+)\b([^>]*?)\/?>/g;function Go(e){var t;return((t=/url\(\s*['"]?#([^)'"\s]+)/.exec(e??""))==null?void 0:t[1])??""}function Dc([e="",t=""],n,s,o,i){var h;const[r=0,c=1]=i,a=[],l=wt(o,Cn(Z(e,"transform")??""));for(const[,f="",u=""]of t.matchAll(Oo)){let p=[f,u],_=wt(l,Cn(Z(u,"transform")??""));if(f==="use"){const b=n.get(((h=Z(u,"(?:xlink:)?href"))==null?void 0:h.slice(1))??"");if(!b)continue;_=wt(_,[1,0,0,1,tn(Z(u,"x"),r),tn(Z(u,"y"),c)]),_=wt(_,Cn(Z(b[1],"transform")??"")),p=b}const y=No(p[0],p[1],i);if(y===void 0)continue;const g=[];rs(y,_,g),[p[1],u,e].map(b=>os(b,"clip-rule",s)).find(Boolean)==="evenodd"&&yo(g),Yn({contours:g},c),a.push(g)}return a}function No(e,t,[n=0,s=0]){const o=(u,p)=>tn(Z(t,u),p),[i,r,c,a]=[o("x",n),o("y",s),o("width",n),o("height",s)],[l,h,f]=[o("cx",n),o("cy",s),Math.hypot(n,s)/Math.SQRT2];switch(e){case"path":return Z(t,"d")??"";case"polygon":case"polyline":return`M${Z(t,"points")??"0 0"}`;case"circle":case"ellipse":{const[u,p]=e==="circle"?[o("r",f),o("r",f)]:[o("rx",n),o("ry",s)],_=`A${u} ${p} 0 1 0`;return`M${l-u} ${h}${_} ${l+u} ${h}${_} ${l-u} ${h}Z`}case"rect":{const[u,p]=[Z(t,"rx"),Z(t,"ry")],_=Math.min(u===void 0?tn(p,s):tn(u,n),c/2),y=Math.min(p===void 0?tn(u,n):tn(p,s),a/2),g=`A${_} ${y} 0 0 1`;return`M${i+_} ${r}H${i+c-_}${g} ${i+c} ${r+y}V${r+a-y}${g} ${i+c-_} ${r+a}H${i+_}${g} ${i} ${r+a-y}V${r+y}${g} ${i+_} ${r}Z`}default:return}}function Rc(e,t,n,s,o,[i=0,r=0]){var m;const c=[];for(let d=e;d&&!c.includes(d);)c.push(d),d=t.get(((m=Z(d[1]??"","(?:xlink:)?href"))==null?void 0:m.slice(1))??"");const a=d=>c.map(U=>Z(U[1]??"",d)).find(U=>U!==void 0),l=a("gradientUnits")==="userSpaceOnUse",h=(d,U,C)=>{const v=a(d)??U;return parseFloat(v)*(v.trim().endsWith("%")?(l?C:1)/100:1)};let f=Cn(a("gradientTransform")??"");if(!l){const d=[];rs(o,[1,0,0,1,0,0],d);const U=es({contours:d});f=wt([U.maxX-U.minX,0,0,U.maxY-U.minY,U.minX,U.minY],f)}const u=e[0]==="radial",[p,_]=[h("x1","0%",i),h("y1","0%",r)],[y,g]=[h("x2","100%",i)-p,h("y2","0%",r)-_],x=Math.hypot(i,r)/Math.SQRT2,[b,M,A]=[h("cx","50%",i),h("cy","50%",r),h("r","50%",x)],k=y*y+g*g||1,T=u?[1/A,0,0,1/A,-b/A,-M/A]:[y/k,0,g/k,0,-(p*y+_*g)/k,0],w=[...(c.map(d=>d[2]??"").find(d=>/<stop\b/.test(d))??"").matchAll(/<stop\b[^>]*>/g)].map(([d])=>({offset:is(Z(d,"offset"),0),color:os(d,"stop-color",n)??"black",opacity:is(os(d,"stop-opacity",n),1)}));return{radial:u,matrix:wt(T,wt($o(f),s)),stops:w}}function wt(e,t){const[n=0,s=0,o=0,i=0,r=0,c=0]=e,[a=0,l=0,h=0,f=0,u=0,p=0]=t;return[n*a+o*l,s*a+i*l,n*h+o*f,s*h+i*f,n*u+o*p+r,s*u+i*p+c]}function Lc([e=0,t=0,n=0,s=0,o=0,i=0],r,c){return[e*r+n*c+o,t*r+s*c+i]}function $o([e=0,t=0,n=0,s=0,o=0,i=0]){const r=e*s-t*n;return[s/r,-t/r,-n/r,e/r,(n*i-s*o)/r,(t*o-e*i)/r]}function Cn(e){let t=[1,0,0,1,0,0];for(const[,n,s=""]of e.matchAll(/(\w+)\s*\(([^)]*)\)/g)){const[o=0,i,r,c=0,a=0,l=0]=s.trim().split(/[\s,]+/).map(parseFloat),h=o*Math.PI/180,[f,u]=[Math.cos(h),Math.sin(h)],[p,_]=[i??0,r??0];t=wt(t,n==="matrix"?[o,i??0,r??0,c,a,l]:n==="translate"?[1,0,0,1,o,i??0]:n==="scale"?[o,0,0,i??o,0,0]:n==="rotate"?[f,u,-u,f,p-f*p+u*_,_-u*p-f*_]:n==="skewX"?[1,0,Math.tan(h),1,0,0]:[1,Math.tan(h),0,1,0,0])}return t}const te=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y;function rs(e,t,n){let s=0,o=0,i=0,r=0,c=0,a=0,l=0,h="",f="",u=[];const p=()=>{for(;s<e.length&&` \r
2
- ,`.includes(e[s]);)s++},_=()=>{p(),te.lastIndex=s;const b=te.exec(e);if(!b)throw new Error(`parseSvg: expected a number at ${s} in path "${e}"`);return s=te.lastIndex,parseFloat(b[0])},y=()=>(p(),e[s++]==="1"?1:0),g=(b,...M)=>{const A=[o,i,...M],k=[];for(let I=0;I<A.length;I+=2)k.push(...Lc(t,A[I],A[I+1]));const[T=0,S=0,w=0,m=0,d=0,U=0,C=0,v=0]=k;u.push(new tt(b,T,S,w,m,d,U,C,v)),o=M[M.length-2],i=M[M.length-1]},x=()=>{u.length>0&&((o!==r||i!==c)&&g(J,r,c),n.push(u),u=[]),o=r,i=c};for(p();s<e.length;p()){if(/[a-zA-Z]/.test(e[s]))h=e[s++];else if(!h)throw new Error(`parseSvg: expected a command at ${s} in path "${e}"`);const b=h.toUpperCase(),M=h===b?0:o,A=h===b?0:i,k=b==="S"&&"CS".includes(f)||b==="T"&&"QT".includes(f),T=k?2*o-a:o,S=k?2*i-l:i;switch(b){case"M":{const w=M+_(),m=A+_();x(),o=r=w,i=c=m,h=h==="M"?"L":"l";break}case"L":g(J,M+_(),A+_());break;case"H":g(J,M+_(),i);break;case"V":g(J,o,A+_());break;case"C":case"S":{const w=b==="C"?M+_():T,m=b==="C"?A+_():S;a=M+_(),l=A+_(),g(Et,w,m,a,l,M+_(),A+_());break}case"Q":case"T":a=b==="Q"?M+_():T,l=b==="Q"?A+_():S,g(ot,a,l,M+_(),A+_());break;case"A":{const w=_(),m=_(),d=_(),U=y(),C=y();Pc(g,o,i,w,m,d,U,C,M+_(),A+_());break}case"Z":x(),h="";break;default:throw new Error(`parseSvg: unknown path command "${h}"`)}f=b}x()}function Pc(e,t,n,s,o,i,r,c,a,l){if(t===a&&n===l)return;if(s=Math.abs(s),o=Math.abs(o),s===0||o===0)return e(J,a,l);const h=Math.cos(i*Math.PI/180),f=Math.sin(i*Math.PI/180),u=(t-a)/2,p=(n-l)/2,_=h*u+f*p,y=-f*u+h*p,g=_*_/(s*s)+y*y/(o*o);g>1&&(s*=Math.sqrt(g),o*=Math.sqrt(g));const x=s*s*y*y+o*o*_*_,b=(r===c?-1:1)*Math.sqrt(Math.max(0,(s*s*o*o-x)/x)),M=b*s*y/o,A=-b*o*_/s,k=h*M-f*A+(t+a)/2,T=f*M+h*A+(n+l)/2,S=Math.atan2((y-A)/o,(_-M)/s);let w=Math.atan2((-y-A)/o,(-_-M)/s)-S;c&&w<0?w+=2*Math.PI:!c&&w>0&&(w-=2*Math.PI);const m=Math.max(1,Math.ceil(Math.abs(w)/(Math.PI/2)-1e-9)),d=w/m,U=4/3*Math.tan(d/4),C=(I,R)=>k+s*I*h-o*R*f,v=(I,R)=>T+s*I*f+o*R*h;for(let I=0;I<m;I++){const R=Math.cos(S+I*d),G=Math.sin(S+I*d),F=Math.cos(S+(I+1)*d),X=Math.sin(S+(I+1)*d),H=I===m-1;e(Et,C(R-U*G,G+U*R),v(R-U*G,G+U*R),C(F+U*X,X-U*F),v(F+U*X,X-U*F),H?a:C(F,X),H?l:v(F,X))}}function Fc(e){let t=0,n=0;for(const c of e)t+=c.w*c.h,n=Math.max(n,c.w);e.sort((c,a)=>a.h-c.h);const o=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}];let i=0,r=0;for(const c of e)for(let a=o.length-1;a>=0;a--){const l=o[a];if(!(c.w>l.w||c.h>l.h)){if(c.x=l.x,c.y=l.y,r=Math.max(r,c.y+c.h),i=Math.max(i,c.x+c.w),c.w===l.w&&c.h===l.h){const h=o.pop();h&&a<o.length&&(o[a]=h)}else c.h===l.h?(l.x+=c.w,l.w-=c.w):c.w===l.w?(l.y+=c.h,l.h-=c.h):(o.push({x:l.x+c.w,y:l.y,w:l.w-c.w,h:c.h}),l.y+=c.h,l.h-=c.h);break}}return{w:i,h:r,fill:t/(i*r)||0}}const Bo=4,qc={x:0,y:0,w:0,h:0,advance:0,planeLeft:0,planeBottom:0,planeRight:0,planeTop:0};function cs(e){const t=e<0?0:e>1?1:e;return~Math.trunc(255.5-255*t)&255}class Oc{constructor(t,n={}){this._width=0,this._height=0,this._pixels=new Uint8Array(0),this._cache=new Map,this._byGid=[],this._cacheByKey=new Map,this._font=t,this._pxPerEm=n.pixelsPerEm??40,this._pxrange=n.pxrange??4,this._floats=n.float?new Float32Array(0):null,this.pxrangeEm=this._pxrange/this._pxPerEm}get width(){return this._width}get height(){return this._height}get texture(){return this._pixels}get floatTexture(){return this._floats}glyphs(t){const n=this._requireFont();return this.glyphsByIndex(Array.from(t,s=>n.glyphId(s)))}glyph(t){return this.glyphs([t])[0]}glyphsByIndex(t){const n=[];let s=0;for(const o of t){const i=this._cache.get(o);if(i){n.push(i.glyph);continue}const r=this._generateForGlyphId(o);this._cache.set(o,r),this._byGid[o]=r.glyph,n.push(r.glyph),s++}return s>0&&this._repack(),n}glyphByIndex(t){return this.glyphsByIndex([t])[0]}shapes(t){const n=[];let s=0;for(const[o,i]of t){let r=this._cacheByKey.get(o);r||(r=this._generate(i,0),this._cacheByKey.set(o,r),s++),n.push(r.glyph)}return s>0&&this._repack(),n}_requireFont(){if(!this._font)throw new Error("Atlas: no font — this atlas only supports shapes()");return this._font}_generateForGlyphId(t){const n=this._requireFont(),s=n.metrics.unitsPerEm,o=n.shape(t);return Yn(o,s),this._generate(o,n.advance(t)/s)}_generate(t,n){const s=Fo(t,this._pxPerEm,this._pxrange);return{glyph:{x:0,y:0,w:s?s.w:0,h:s?s.h:0,advance:n,planeLeft:s?s.planeLeft:0,planeBottom:s?s.planeBottom:0,planeRight:s?s.planeRight:0,planeTop:s?s.planeTop:0},msdf:s?s.msdf:null}}layout(t){const n=this._requireFont(),s=Ar(n,t),o=L._gid,i=L._gp;let r=0;const c=this._byGid;for(let _=0;_<s;_++){const y=o[_];if(i[_]&un||c[y])continue;const g=this._generateForGlyphId(y);this._cache.set(y,g),c[y]=g.glyph,r++}r>0&&this._repack();const a=L._xa,l=L._xo,h=L._yo,f=n.metrics.unitsPerEm,u=[];let p=0;for(let _=0;_<s;_++){const y=i[_]&un?qc:c[o[_]];u.push({glyph:y,penX:(p+l[_])/f,penY:h[_]/f}),p+=a[_]}return{glyphs:u,widthEm:p/f}}layoutMultiline(t){const n=this._requireFont(),s=n.metrics.unitsPerEm,o=(n.metrics.ascender-n.metrics.descender+n.metrics.lineGap)/s,i=t.split(`
3
- `),r=[];let c=0;for(let a=0;a<i.length;a++){const{glyphs:l,widthEm:h}=this.layout(i[a]),f=-a*o;for(const u of l)r.push({glyph:u.glyph,penX:u.penX,penY:f+u.penY});h>c&&(c=h)}return{glyphs:r,widthEm:c,heightEm:i.length*o}}_repack(){const t=[];for(const o of[this._cache,this._cacheByKey])for(const{glyph:i,msdf:r}of o.values())r&&t.push({w:i.w+1,h:i.h+1,x:0,y:0,glyph:i,msdf:r});const{w:n,h:s}=Fc(t);this._width=n,this._height=s,this._pixels=new Uint8Array(n*s*Bo),this._floats&&(this._floats=new Float32Array(n*s*3));for(const o of t)o.glyph.x=o.x,o.glyph.y=o.y,this._blit(o.msdf,o.x,o.y,o.glyph.w,o.glyph.h)}_blit(t,n,s,o,i){var a;const r=this._width,c=this._pixels;for(let l=0;l<i;l++){const h=s+(i-1-l);(a=this._floats)==null||a.set(t.subarray(l*o*3,(l+1)*o*3),(h*r+n)*3);for(let f=0;f<o;f++){const u=(l*o+f)*3,p=(h*r+(n+f))*Bo;c[p]=cs(t[u]),c[p+1]=cs(t[u+1]),c[p+2]=cs(t[u+2]),c[p+3]=255}}}}return gt.Atlas=Oc,gt.CUBIC=Et,gt.EdgeSegment=tt,gt.Font=qr,gt.LINEAR=J,gt.QUADRATIC=ot,gt.generateShapeMSDF=Fo,gt.parseSvg=Ic,gt.parseSvgLayers=qo,gt.pixelFloatToByte=cs,Object.defineProperty(gt,Symbol.toStringTag,{value:"Module"}),gt})({});
1
+ var MsdfgenTs=(function(gt){"use strict";function Ai(e,t,n,s){return e*n+t*s}function Q(e,t,n,s){return e*s-t*n}function Se(e,t,n){return(1-n)*e+n*t}function pt(e){return+(e>0)-+(e<0)}function jt(e){return 2*+(e>0)-1}function Te(e,t,n,s){if(t===0||Math.abs(n)>1e12*Math.abs(t))return n===0?s===0?-1:0:(e[0]=-s/n,1);const o=n*n-4*t*s;if(o>0){const i=Math.sqrt(o);return e[0]=(-n+i)/(2*t),e[1]=(-n-i)/(2*t),2}else if(o===0)return e[0]=-n/(2*t),1;return 0}function ki(e,t,n,s){const o=t*t,i=1/9*(o-3*n),r=1/54*(t*(2*o-9*n)+27*s),c=r*r,a=i*i*i,l=t*(1/3);if(c<a){let h=r/Math.sqrt(a);h<-1&&(h=-1),h>1&&(h=1),h=Math.acos(h);const f=-2*Math.sqrt(i);return e[0]=f*Math.cos(.3333333333333333*h)-l,e[1]=f*Math.cos(.3333333333333333*(h+2*Math.PI))-l,e[2]=f*Math.cos(.3333333333333333*(h-2*Math.PI))-l,3}else{const h=(r<0?1:-1)*Math.pow(Math.abs(r)+Math.sqrt(c-a),.3333333333333333),f=h===0?0:i/h;return e[0]=h+f-l,h===f||Math.abs(h-f)<1e-12*Math.abs(h+f)?(e[1]=-.5*(h+f)-l,2):1}}function Ui(e,t,n,s,o){if(t!==0){const i=n/t;if(Math.abs(i)<1e6)return ki(e,i,s/t,o/t)}return Te(e,n,s,o)}const Si=24;function fn(e,t,n,s){return((s+e)*s+t)*s+n}function Ti(e,t,n,s,o,i,r){const c=i<0;let a=s-i*(o-s)/(r-i);a>s&&a<o||(a=.5*(s+o));for(let l=0;l<Si;l++){const h=fn(e,t,n,a);if(h===0)return a;h<0===c?s=a:o=a;const f=(3*a+2*e)*a+t;let p=a-h/f;p>s&&p<o||(p=.5*(s+o));const u=p-a;if(a=p,(u<0?-u:u)<=1e-15*(a<0?-a:a))break}return a}function En(e,t,n,s,o,i,r,c,a){return i===0?c[a++]=s:i<0!=r<0&&(c[a++]=Ti(e,t,n,s,o,i,r)),a}function vi(e,t,n,s,o,i){let r=0;if(e===0){if(t===0)return 0;const p=-n/t;return p>=s&&p<=o&&(i[r++]=p),r}const c=t*t-4*e*n;if(c<0)return 0;const a=Math.sqrt(c),l=-.5*(t+(t<0?-a:a));let h,f;if(l===0)h=0,f=0;else if(h=l/e,f=n/l,h>f){const p=h;h=f,f=p}return h>=s&&h<=o&&(i[r++]=h),f!==h&&f>=s&&f<=o&&(i[r++]=f),r}function Ci(e,t,n,s,o,i,r){if(e===0)return vi(t,n,s,o,i,r);const c=1/e;t*=c,n*=c,s*=c;const a=fn(t,n,s,o),l=fn(t,n,s,i),h=t*t-3*n;let f=0;if(h<=0)f=En(t,n,s,o,i,a,l,r,0);else{const p=Math.sqrt(h)/3,u=-t/3,_=u-p,y=u+p;let g=o,x=a;if(_>o&&_<i){const b=fn(t,n,s,_);f=En(t,n,s,g,_,x,b,r,f),g=_,x=b}if(y>o&&y<i){const b=fn(t,n,s,y);f=En(t,n,s,g,y,x,b,r,f),g=y,x=b}f=En(t,n,s,g,i,x,l,r,f)}return l===0&&(r[f++]=i),f}const J=0,ot=1,Et=2,ve=4,Ei=4,K=[0,0,0];class tt{constructor(t,n,s,o,i,r,c,a,l){this.type=t,this.p0x=n,this.p0y=s,this.p1x=o,this.p1y=i,this.p2x=r,this.p2y=c,this.p3x=a,this.p3y=l,this.color=7}endX(){switch(this.type){case J:return this.p1x;case ot:return this.p2x;default:return this.p3x}}endY(){switch(this.type){case J:return this.p1y;case ot:return this.p2y;default:return this.p3y}}point(t,n){const s=t;switch(this.type){case J:{n[0]=this.p0x+s*(this.p1x-this.p0x),n[1]=this.p0y+s*(this.p1y-this.p0y);return}case ot:{const o=this.p0x+s*(this.p1x-this.p0x),i=this.p0y+s*(this.p1y-this.p0y),r=this.p1x+s*(this.p2x-this.p1x),c=this.p1y+s*(this.p2y-this.p1y);n[0]=o+s*(r-o),n[1]=i+s*(c-i);return}default:{const o=this.p0x+s*(this.p1x-this.p0x),i=this.p0y+s*(this.p1y-this.p0y),r=this.p1x+s*(this.p2x-this.p1x),c=this.p1y+s*(this.p2y-this.p1y),a=this.p2x+s*(this.p3x-this.p2x),l=this.p2y+s*(this.p3y-this.p2y),h=o+s*(r-o),f=i+s*(c-i),p=r+s*(a-r),u=c+s*(l-c);n[0]=h+s*(p-h),n[1]=f+s*(u-f);return}}}direction(t,n){const s=t;switch(this.type){case J:{n[0]=this.p1x-this.p0x,n[1]=this.p1y-this.p0y;return}case ot:{const o=this.p1x-this.p0x+s*(this.p2x-this.p1x-(this.p1x-this.p0x)),i=this.p1y-this.p0y+s*(this.p2y-this.p1y-(this.p1y-this.p0y));o!==0||i!==0?(n[0]=o,n[1]=i):(n[0]=this.p2x-this.p0x,n[1]=this.p2y-this.p0y);return}default:{const o=this.p1x-this.p0x,i=this.p1y-this.p0y,r=this.p2x-this.p1x,c=this.p2y-this.p1y,a=this.p3x-this.p2x,l=this.p3y-this.p2y,h=o+s*(r-o)+s*(r+s*(a-r)-(o+s*(r-o))),f=i+s*(c-i)+s*(c+s*(l-c)-(i+s*(c-i)));h!==0||f!==0?(n[0]=h,n[1]=f):s===0?(n[0]=this.p2x-this.p0x,n[1]=this.p2y-this.p0y):s===1?(n[0]=this.p3x-this.p1x,n[1]=this.p3y-this.p1y):(n[0]=h,n[1]=f);return}}}splitInThirds(){const t=[0,0],n=[0,0];switch(this.type){case J:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const s=new tt(J,this.p0x,this.p0y,t[0],t[1],0,0,0,0),o=new tt(J,t[0],t[1],n[0],n[1],0,0,0,0),i=new tt(J,n[0],n[1],this.p1x,this.p1y,0,0,0,0);return s.color=o.color=i.color=this.color,[s,o,i]}case ot:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const s=this.p0x+1/3*(this.p1x-this.p0x),o=this.p0y+1/3*(this.p1y-this.p0y),i=this.p0x+5/9*(this.p1x-this.p0x),r=this.p0y+5/9*(this.p1y-this.p0y),c=this.p1x+4/9*(this.p2x-this.p1x),a=this.p1y+4/9*(this.p2y-this.p1y),l=i+.5*(c-i),h=r+.5*(a-r),f=this.p1x+2/3*(this.p2x-this.p1x),p=this.p1y+2/3*(this.p2y-this.p1y),u=new tt(ot,this.p0x,this.p0y,s,o,t[0],t[1],0,0),_=new tt(ot,t[0],t[1],l,h,n[0],n[1],0,0),y=new tt(ot,n[0],n[1],f,p,this.p2x,this.p2y,0,0);return u.color=_.color=y.color=this.color,[u,_,y]}default:{this.point(.3333333333333333,t),this.point(.6666666666666666,n);const s=this.p0x===this.p1x&&this.p0y===this.p1y?this.p0x:this.p0x+1/3*(this.p1x-this.p0x),o=this.p0x===this.p1x&&this.p0y===this.p1y?this.p0y:this.p0y+1/3*(this.p1y-this.p0y),i=this.p0x+1/3*(this.p1x-this.p0x),r=this.p0y+1/3*(this.p1y-this.p0y),c=this.p1x+1/3*(this.p2x-this.p1x),a=this.p1y+1/3*(this.p2y-this.p1y),l=this.p2x+1/3*(this.p3x-this.p2x),h=this.p2y+1/3*(this.p3y-this.p2y),f=i+1/3*(c-i),p=r+1/3*(a-r),u=c+1/3*(l-c),_=a+1/3*(h-a),y=f+2/3*(u-f),g=p+2/3*(_-p),x=this.p0x+2/3*(this.p1x-this.p0x),b=this.p0y+2/3*(this.p1y-this.p0y),M=this.p1x+2/3*(this.p2x-this.p1x),A=this.p1y+2/3*(this.p2y-this.p1y),k=this.p2x+2/3*(this.p3x-this.p2x),S=this.p2y+2/3*(this.p3y-this.p2y),T=x+2/3*(M-x),w=b+2/3*(A-b),m=M+2/3*(k-M),d=A+2/3*(S-A),U=T+1/3*(m-T),C=w+1/3*(d-w),v=this.p2x===this.p3x&&this.p2y===this.p3y?this.p3x:this.p2x+2/3*(this.p3x-this.p2x),I=this.p2x===this.p3x&&this.p2y===this.p3y?this.p3y:this.p2y+2/3*(this.p3y-this.p2y),R=new tt(Et,this.p0x,this.p0y,s,o,f,p,t[0],t[1]),G=new tt(Et,t[0],t[1],y,g,U,C,n[0],n[1]),F=new tt(Et,n[0],n[1],m,d,v,I,this.p3x,this.p3y);return R.color=G.color=F.color=this.color,[R,G,F]}}}signedDistance(t,n,s){switch(this.type){case J:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=t-o,l=n-i,h=r-o,f=c-i,p=h*h+f*f,u=(a*h+l*f)/p,_=u>.5,y=(_?r:o)-t,g=(_?c:i)-n,x=Math.sqrt(y*y+g*g);if(u>0&&u<1){const A=Math.sqrt(h*h+f*f),k=h/A,T=f/A*a-k*l;if(Math.abs(T)<x){s.distance=T,s.dot=0,s.param=u;return}}const b=a*f-l*h;s.distance=jt(b)*x;const M=Math.sqrt(h*h+f*f);s.dot=x===0||M===0?0:Math.abs((h*y+f*g)/(M*x)),s.param=u;return}case ot:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=o-t,f=i-n,p=r-o,u=c-i,_=a-r-p,y=l-c-u,g=_*_+y*y,x=3*(p*_+u*y),b=2*(p*p+u*u)+(h*_+f*y),M=h*p+f*u,A=Ci(g,x,b,M,0,1,K);let k=p,S=u;const T=h*h+f*f;let w=jt(k*f-S*h),m=T,d=-(h*k+f*S)/(k*k+S*S);{const C=a-t,v=l-n,I=C*C+v*v;I<m&&(k=a-r,S=l-c,w=jt(k*v-S*C),m=I,d=((t-r)*k+(n-c)*S)/(k*k+S*S))}for(let C=0;C<A;++C){const v=K[C];if(v>0&&v<1){const I=h+2*v*p+v*v*_,R=f+2*v*u+v*v*y,G=I*I+R*R;if(G<=m){const F=p+v*_,X=u+v*y;w=jt(F*R-X*I),m=G,d=v}}}const U=w*Math.sqrt(m);if(d>=0&&d<=1){s.distance=U,s.dot=0,s.param=d;return}if(s.distance=U,s.param=d,d<.5){const C=Math.sqrt(p*p+u*u),v=Math.sqrt(T);s.dot=v===0||C===0?0:Math.abs((p*h+u*f)/(C*v))}else{const C=a-r,v=l-c,I=a-t,R=l-n,G=Math.sqrt(C*C+v*v),F=Math.sqrt(I*I+R*R);s.dot=G===0||F===0?0:Math.abs((C*I+v*R)/(G*F))}return}default:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=this.p3x,f=this.p3y,p=o-t,u=i-n,_=r-o,y=c-i,g=a-r-_,x=l-c-y,b=h-a-(a-r)-g,M=f-l-(l-c)-x;let A=_,k=y;A===0&&k===0&&(A=a-o,k=l-i);const S=Math.sqrt(p*p+u*u);let T=jt(A*u-k*p)*S,w=-(p*A+u*k)/(A*A+k*k);{const m=h-t,d=f-n,U=Math.sqrt(m*m+d*d);if(U<Math.abs(T)){let C=h-a,v=f-l;C===0&&v===0&&(C=h-r,v=f-c),A=C,k=v,T=jt(A*d-k*m)*U,w=((A-m)*A+(k-d)*k)/(A*A+k*k)}}for(let m=0;m<=ve;++m){let d=1/ve*m,U=p+3*d*_+3*d*d*g+d*d*d*b,C=u+3*d*y+3*d*d*x+d*d*d*M,v=3*_+6*d*g+3*d*d*b,I=3*y+6*d*x+3*d*d*M,R=6*g+6*d*b,G=6*x+6*d*M,F=d-(U*v+C*I)/(v*v+I*I+(U*R+C*G));if(F>0&&F<1){let X=Ei;do{if(d=F,U=p+3*d*_+3*d*d*g+d*d*d*b,C=u+3*d*y+3*d*d*x+d*d*d*M,v=3*_+6*d*g+3*d*d*b,I=3*y+6*d*x+3*d*d*M,!--X)break;R=6*g+6*d*b,G=6*x+6*d*M,F=d-(U*v+C*I)/(v*v+I*I+(U*R+C*G))}while(F>0&&F<1);const H=Math.sqrt(U*U+C*C);H<Math.abs(T)&&(T=jt(v*C-I*U)*H,w=d)}}if(w>=0&&w<=1){s.distance=T,s.dot=0,s.param=w;return}if(s.distance=T,s.param=w,w<.5){let m=_,d=y;m===0&&d===0&&(m=a-o,d=l-i);const U=Math.sqrt(m*m+d*d);s.dot=S===0||U===0?0:Math.abs((m*p+d*u)/(U*S))}else{let m=h-a,d=f-l;m===0&&d===0&&(m=h-r,d=f-c);const U=h-t,C=f-n,v=Math.sqrt(m*m+d*d),I=Math.sqrt(U*U+C*C);s.dot=v===0||I===0?0:Math.abs((m*U+d*C)/(v*I))}return}}}scanlineIntersections(t,n,s){switch(this.type){case J:{const o=this.p0y,i=this.p1y;if(t>=o&&t<i||t>=i&&t<o){const r=(t-o)/(i-o);return n[0]=Se(this.p0x,this.p1x,r),s[0]=pt(i-o),1}return 0}case ot:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y;let h=0,f=t>i?1:-1;n[h]=o,i===t&&(i<c||i===c&&i<l?s[h++]=1:f=1);{const p=r-o,u=c-i,_=a-r-p,y=l-c-u,g=Te(K,y,2*u,i-t);if(g>=2&&K[0]>K[1]){const x=K[0];K[0]=K[1],K[1]=x}for(let x=0;x<g&&h<2;++x){const b=K[x];b>=0&&b<=1&&(n[h]=o+2*b*p+b*b*_,f*(u+b*y)>=0&&(s[h++]=f,f=-f))}}return l===t&&(f>0&&h>0&&(--h,f=-1),(l<c||l===c&&l<i)&&h<2&&(n[h]=a,f<0&&(s[h++]=-1,f=1))),f!==(t>=l?1:-1)&&(h>0?--h:(Math.abs(l-t)<Math.abs(i-t)&&(n[h]=a),s[h++]=f)),h}default:{const o=this.p0x,i=this.p0y,r=this.p1x,c=this.p1y,a=this.p2x,l=this.p2y,h=this.p3x,f=this.p3y;let p=0,u=t>i?1:-1;n[p]=o,i===t&&(i<c||i===c&&(i<l||i===l&&i<f)?s[p++]=1:u=1);{const _=h-3*a+3*r-o,y=f-3*l+3*c-i,g=3*a-6*r+3*o,x=3*l-6*c+3*i,b=3*r-3*o,M=3*c-3*i,A=Ui(K,y,x,M,i-t);if(A>=2){if(K[0]>K[1]){const k=K[0];K[0]=K[1],K[1]=k}if(A>=3&&K[1]>K[2]){const k=K[1];if(K[1]=K[2],K[2]=k,K[0]>K[1]){const S=K[0];K[0]=K[1],K[1]=S}}}for(let k=0;k<A&&p<3;++k){const S=K[k];S>=0&&S<=1&&(n[p]=((_*S+g)*S+b)*S+o,u*((3*y*S+2*x)*S+M)>=0&&(s[p++]=u,u=-u))}}return f===t&&(u>0&&p>0&&(--p,u=-1),(f<l||f===l&&(f<c||f===c&&f<i))&&p<3&&(n[p]=h,u<0&&(s[p++]=-1,u=1))),u!==(t>=f?1:-1)&&(p>0?--p:(Math.abs(f-t)<Math.abs(i-t)&&(n[p]=h),s[p++]=u)),p}}}convertToCubic(){const t=this.p0x+.6666666666666666*(this.p1x-this.p0x),n=this.p0y+2/3*(this.p1y-this.p0y),s=this.p1x+1/3*(this.p2x-this.p1x),o=this.p1y+1/3*(this.p2y-this.p1y),i=new tt(Et,this.p0x,this.p0y,t,n,s,o,this.p2x,this.p2y);return i.color=this.color,i}}class It{constructor(t,n=0){this._view=new DataView(t),this._pos=n}get pos(){return this._pos}seek(t){this._pos=t}skip(t){this._pos+=t}u8(){return this._view.getUint8(this._pos++)}u16(){const t=this._view.getUint16(this._pos,!1);return this._pos+=2,t}i16(){const t=this._view.getInt16(this._pos,!1);return this._pos+=2,t}u32(){const t=this._view.getUint32(this._pos,!1);return this._pos+=4,t}i32(){const t=this._view.getInt32(this._pos,!1);return this._pos+=4,t}f2dot14(){return this.i16()/16384}offset16(){return this.u16()}offset32(){return this.u32()}peekU16(t){return this._view.getUint16(t,!1)}peekU32(t){return this._view.getUint32(t,!1)}peekI16(t){return this._view.getInt16(t,!1)}}function Ii(e,t){const n=new It(e,t);n.skip(2);const s=n.u16();let o=null;for(let r=0;r<s;r++){const c=n.u16(),a=n.u16(),l=n.u32(),h=t+l,f=n.peekU16(h);let p=-1;c===3&&a===10&&f===12?p=5:c===0&&a===6&&f===12?p=4:c===0&&a===4&&f===12?p=3:c===3&&a===1&&f===4?p=2:c===0&&a<=3&&f===4&&(p=1),p>((o==null?void 0:o.priority)??-1)&&(o={priority:p,subtableAbsOffset:h})}if(!o)return()=>0;const i=n.peekU16(o.subtableAbsOffset);return i===12?Di(e,o.subtableAbsOffset):i===4?Ri(e,o.subtableAbsOffset):()=>0}function Di(e,t){const n=new It(e,t);n.skip(2),n.skip(2),n.skip(4),n.skip(4);const s=n.u32(),o=new Uint32Array(s),i=new Uint32Array(s),r=new Uint32Array(s);for(let c=0;c<s;c++)o[c]=n.u32(),i[c]=n.u32(),r[c]=n.u32();return c=>{let a=0,l=s-1;for(;a<=l;){const h=a+l>>>1,f=o[h]??0,p=i[h]??0;if(c<f)l=h-1;else if(c>p)a=h+1;else return(r[h]??0)+(c-f)}return 0}}function Ri(e,t){const n=new It(e,t);n.skip(2),n.skip(2),n.skip(2);const o=n.u16()>>>1;n.skip(6);const i=new Uint16Array(o);for(let f=0;f<o;f++)i[f]=n.u16();n.skip(2);const r=new Uint16Array(o);for(let f=0;f<o;f++)r[f]=n.u16();const c=new Int16Array(o);for(let f=0;f<o;f++)c[f]=n.i16();const a=new Int32Array(o),l=new Uint16Array(o);for(let f=0;f<o;f++)a[f]=n.pos,l[f]=n.u16();const h=new DataView(e);return f=>{if(f>65535)return 0;let p=0,u=o-1;for(;p<=u;){const _=p+u>>>1,y=i[_]??0;if(f>y)p=_+1;else if(f<(r[_]??0))u=_-1;else{if((i[_]??0)===65535)return 0;const x=l[_]??0,b=c[_]??0,M=r[_]??0;if(x===0)return f+b&65535;const A=(a[_]??0)+x+(f-M)*2,k=h.getUint16(A,!1);return k===0?0:k+b&65535}}return 0}}function Li(e,t){const n=new It(e,t);n.skip(4),n.skip(4),n.skip(4),n.skip(4),n.skip(2);const s=n.u16();n.skip(16),n.skip(8),n.skip(2),n.skip(2),n.skip(2);const o=n.i16();return{unitsPerEm:s,indexToLocFormat:o}}function Pi(e,t){const n=new It(e,t);n.skip(4);const s=n.i16(),o=n.i16(),i=n.i16();n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(2),n.skip(8),n.skip(2);const r=n.u16();return{ascender:s,descender:o,lineGap:i,numberOfHMetrics:r}}function Fi(e,t,n,s){const o=new It(e,t),i=[];let r=0;for(let c=0;c<s;c++){const a=o.u16(),l=o.i16();i[c]={advanceWidth:a,lsb:l},r=a}for(let c=s;c<n;c++){const a=o.i16();i[c]={advanceWidth:r,lsb:a}}return i}function qi(e,t,n,s){const o=new It(e,t),i=n+1,r=[];if(s===0)for(let c=0;c<i;c++)r[c]=o.u16()*2;else for(let c=0;c<i;c++)r[c]=o.u32();return r}function Oi(e,t){const n=new It(e,t);return n.skip(4),{numGlyphs:n.u16()}}const Gi=1,Ni=2,$i=4,Bi=8,Ce=16,Ee=32,Yi=1,Ie=2,Hi=8,Xi=32,Ki=64,ji=128;function Vi(e,t,n,s,o){const i=De(e,t,n,s,o),r=[];for(const c of i){const a=Zi(c);a.length>0&&r.push(a)}return{contours:r,inverseYAxis:!1}}function De(e,t,n,s,o){if(s===0)return[];const i=t+n,r=new It(e,i),c=r.i16();return r.skip(8),c>=0?Wi(r,c):Qi(e,r,t,o)}function Wi(e,t){if(t===0)return[];const n=[];for(let f=0;f<t;f++)n[f]=e.u16();const s=(n[t-1]??0)+1,o=e.u16();e.skip(o);const i=new Uint8Array(s);for(let f=0;f<s;){const p=e.u8();if(i[f++]=p,p&Bi){let u=e.u8();for(;u-- >0;)i[f++]=p}}const r=new Float64Array(s);let c=0;for(let f=0;f<s;f++){const p=i[f]??0;if(p&Ni){const u=e.u8();c+=p&Ce?u:-u}else p&Ce||(c+=e.i16());r[f]=c}const a=new Float64Array(s);c=0;for(let f=0;f<s;f++){const p=i[f]??0;if(p&$i){const u=e.u8();c+=p&Ee?u:-u}else p&Ee||(c+=e.i16());a[f]=c}const l=[];let h=0;for(let f=0;f<t;f++){const p=n[f]??0,u=zi(i,r,a,h,p);u.length>0&&l.push(u),h=p+1}return l}function zi(e,t,n,s,o){const i=o-s+1;if(i<=0)return[];const r=[];for(let c=0;c<i;c++){const a=e[s+c]??0,l=t[s+c]??0,h=n[s+c]??0;r.push({x:l,y:h,onCurve:(a&Gi)!==0})}return r}function Zi(e){const t=e.length;if(t<=0)return[];const n=[];for(let c=0;c<t;c++){const a=e[c],l=e[(c+1)%t];n.push(a),!a.onCurve&&!l.onCurve&&n.push({x:Math.trunc((a.x+l.x)/2),y:Math.trunc((a.y+l.y)/2),onCurve:!0})}const s=n.length;let o=0;if(!n[0].onCurve){for(let c=1;c<s;c++)if(n[c].onCurve){o=c;break}}const i=[];let r=0;for(;r<s;){const c=n[(o+r)%s],a=n[(o+r+1)%s];if(a.onCurve)i.push(new tt(J,c.x,c.y,a.x,a.y,0,0,0,0)),r+=1;else{const l=n[(o+r+2)%s];i.push(new tt(ot,c.x,c.y,a.x,a.y,l.x,l.y,0,0)),r+=2}}return i}function Qi(e,t,n,s){const o=[];let i=0;do{i=t.u16();const r=t.u16();let c,a;i&Yi?(c=t.i16(),a=t.i16()):(c=t.u8(),a=t.u8(),i&Ie&&(c>127&&(c-=256),a>127&&(a-=256)));let l=0,h=0;i&Ie&&(l=c,h=a);let f=1,p=0,u=0,_=1;i&Hi?f=_=t.f2dot14():i&Ki?(f=t.f2dot14(),_=t.f2dot14()):i&ji&&(f=t.f2dot14(),p=t.f2dot14(),u=t.f2dot14(),_=t.f2dot14());const y=s(r),g=Ji(y,f,p,u,_,l,h);for(const x of g)o.push(x)}while(i&Xi);return o}function Re(e){return e>=0?Math.floor(e+.5):Math.ceil(e-.5)}function Ji(e,t,n,s,o,i,r){if(t===1&&n===0&&s===0&&o===1&&i===0&&r===0)return e;const a=t===1&&n===0&&s===0&&o===1;return e.map(l=>l.map(h=>a?{x:h.x+i,y:h.y+r,onCurve:h.onCurve}:{x:Re(t*h.x+n*h.y+i),y:Re(s*h.x+o*h.y+r),onCurve:h.onCurve}))}const nn=1,In=2,tr=4,Dt=8,pn=16,L={_cp:new Int32Array(64),_gid:new Uint16Array(64),_gp:new Uint16Array(64),_xa:new Float64Array(64),_xo:new Float64Array(64),_yo:new Float64Array(64),_runEnd:new Int32Array(64),_runScript:new Int32Array(64)};function un(e,t,n,s){if(e&n&14)return!1;if(e&Dt){if(n&16)return s!==null&&t<s.length&&s[t]!==65535;if(n&65280)return(n&65280)===(e&65280)}return!0}function gs(e,t,n,s){const o=L._gp,i=L._gid;for(let r=e+1;r<t;r++){const c=o[r];if(!(c&nn)&&un(c,i[r],n,s))return r}return-1}function Le(e){if(L._gid.length>=e)return;let t=L._gid.length;for(;t<e;)t*=2;L._cp=new Int32Array(t),L._gid=new Uint16Array(t),L._gp=new Uint16Array(t),L._xa=new Float64Array(t),L._xo=new Float64Array(t),L._yo=new Float64Array(t),L._runEnd=new Int32Array(t),L._runScript=new Int32Array(t)}let _n=new Uint8Array(64);class nr{constructor(t,n){this._pairs=[],this._counts=[],this._cross=[];const s=new DataView(t);this._dv=s;const o=s.getUint16(n)===1,i=o?s.getUint32(n+4):s.getUint16(n+2);let r=n+(o?8:4),c=!1,a=!1;for(let l=0;l<i&&r+8<=s.byteLength;l++){let h,f,p,u,_=!1,y;if(o){h=s.getUint32(r);const g=s.getUint8(r+4);f=s.getUint8(r+5),p=!(g&128),u=!!(g&64),_=!!(g&32),y=r+8}else{h=s.getUint16(r+2),f=s.getUint8(r+4);const g=s.getUint8(r+5);p=!!(g&1),u=!!(g&4),y=r+6}if(f===1&&(c=!0),u&&(a=!0),f===0&&p&&!_&&(this._pairs.push(y+8),this._counts.push(s.getUint16(y)),this._cross.push(u)),h<6)break;r+=h}this._hasData=i>0,this._hasMachine=c,this._hasCross=a}_get(t,n,s){const o=this._dv,i=this._pairs[t],r=(n<<16|s)>>>0;let c=0,a=this._counts[t]-1;for(;c<=a;){const l=c+a>>1,h=o.getUint32(i+6*l);if(h<r)c=l+1;else if(h>r)a=l-1;else return o.getInt16(i+6*l+4)}return 0}_apply(t,n){const s=L._gid,o=L._xa,i=L._xo,r=L._yo;let c=!1,a=!1;for(let l=0;l<this._pairs.length;l++){const h=this._cross[l];h&&!c&&(c=!0,_n.length<n&&(_n=new Uint8Array(n*2)),_n.fill(0,t,n));for(let f=t;f<n;){const p=gs(f,n,Dt,null);if(p<0){f++;continue}const u=this._get(l,s[f],s[p]);if(u)if(h)u===-32768?(_n[p]=1,r[p]=0):(r[p]=u,a=!0);else{const _=u/2;o[f]=o[f]+_,o[p]=o[p]+u-_,i[p]=i[p]+u-_}f=p}}if(a)for(let l=t+1;l<n;l++)_n[l]||(r[l]=r[l]+r[l-1])}}const $t=65535,Pe=new Uint16Array(0);function sr(e,t){const n=e.getUint16(t+4);if(!n)return new Uint32Array(0);const s=t+n,o=new Uint32Array(e.getUint16(s));for(let i=0;i<o.length;i++)o[i]=e.getUint32(s+2+6*i);return o}function Fe(e,t){const n=e.getUint16(t),s=e.getUint16(t+2);let o=-1;if(n===1){for(let r=0;r<s;r++)o=Math.max(o,e.getUint16(t+4+2*r));const i=new Uint16Array(o+1).fill($t);for(let r=s-1;r>=0;r--)i[e.getUint16(t+4+2*r)]=r;return i}if(n===2){for(let r=0;r<s;r++)o=Math.max(o,e.getUint16(t+6+6*r));const i=new Uint16Array(o+1).fill($t);for(let r=s-1;r>=0;r--){const c=t+4+6*r,a=e.getUint16(c),l=e.getUint16(c+2),h=e.getUint16(c+4);for(let f=a;f<=l;f++)i[f]=h+f-a}return i}return Pe}function xs(e,t){const n=e.getUint16(t);if(n===1){const s=e.getUint16(t+2),o=e.getUint16(t+4),i=new Uint16Array(s+o);for(let r=0;r<o;r++)i[s+r]=e.getUint16(t+6+2*r);return i}if(n===2){const s=e.getUint16(t+2);let o=-1;for(let r=0;r<s;r++)o=Math.max(o,e.getUint16(t+6+6*r));const i=new Uint16Array(o+1);for(let r=s-1;r>=0;r--){const c=t+4+6*r,a=e.getUint16(c+2),l=e.getUint16(c+4);for(let h=e.getUint16(c);h<=a;h++)i[h]=l}return i}return Pe}class er{constructor(t,n,s){this._setCache=[];const o=new DataView(t);this._dv=o;const i=o.getUint16(n+2),r=o.getUint16(n+4),c=o.getUint16(n+10),a=i>=2?o.getUint16(n+12):0;if(this._sets=a?n+a:0,!r){this._props=null;return}const l=xs(o,n+r),h=c?xs(o,n+c):new Uint16Array(0),f=new Uint16Array(s);for(let p=0;p<s&&p<l.length;p++)switch(l[p]){case 1:f[p]=In;break;case 2:f[p]=tr;break;case 3:f[p]=Dt|(h[p]??0)<<8;break}this._props=f}_markSet(t){let n=this._setCache[t];if(!n){const s=this._dv,o=this._sets;n=o&&t<s.getUint16(o+2)?Fe(s,o+s.getUint32(o+4+4*t)):new Uint16Array(0),this._setCache[t]=n}return n}}const qe="ZyyyZinhArabArmnBengBopoCherCoptCyrlDsrtDevaEthiGeorGothGrekGujrGuruHaniHangHebrHiraKndaKanaKhmrLaooLatnMlymMongMymrOgamItalOryaRunrSinhSyrcTamlTeluThaaThaiTibtCansYiiiTglgHanoBuhdTagbBraiCprtLimbLinbOsmaShawTaleUgarHrktBugiGlagKharSyloTaluTfngXpeoBaliBatkBlisBrahChamCirtCyrsEgydEgyhEgypGeokHansHantHmngHungIndsJavaKaliLatfLatgLepcLinaMandMayaMeroNkooOrkhPermPhagPhnxPlrdRoroSaraSyreSyrjSyrnTengVaiiVispXsuxZxxxZzzzCariJpanLanaLyciLydiOlckRjngSaurSgnwSundMoonMteiArmiAvstCakmKoreKthiManiPhliPhlpPhlvPrtiSamrTavtZmthZsymBamuLisuNkgbSarbBassDuplElbaGranKpelLomaMendMercNarbNbatPalmSindWaraAfakJurcMrooNshuShrdSoraTakrTangWoleHluwKhojTirhAghbMahjAhomHatrModiMultPaucSiddAdlmBhksMarcNewaOsgeHanbJamoZsyeGonmSoyoZanbDogrGongMakaMedfRohgSogdSogoElymHmnpNandWchoChrsDiakKitsYeziCpmnOugrTnsaTotoVithKawiNagmAranGaraGukhKraiOnaoSunuTodrTutgBerfSidtTayoTols",Dn=qe.length/4,lt=0,Rt=1,Rn=25,or=8,ir=14;function yn(e){return qe.substring(e*4,e*4+4)}const rr=[],cr=[];function Ln(e,t){const n=t?cr:rr;let s=n[e];if(s===void 0){try{s=new RegExp(`^\\p{${t?"scx":"sc"}=${yn(e)}}$`,"u")}catch{s=null}n[e]=s}return s}let ds=null;const Pn=[Rn,lt,Rt,or,ir],gn=[[lt],[Rn]],Oe=new Map;let Fn=null;const Ge=new Map;function Ms(e){if(e<128)return gn[e>=65&&e<=90||e>=97&&e<=122?1:0];let t;if(e<65536){Fn||(Fn=new Uint16Array(65536));const n=Fn[e];if(n)return gn[n-1];t=Ne(e),Fn[e]=t+1}else t=Ge.get(e),t===void 0&&(t=Ne(e),Ge.set(e,t));return gn[t]}function Ne(e){const t=String.fromCodePoint(e);let n=103;for(let r=0;r<Pn.length+Dn;r++){const c=r<Pn.length?Pn[r]:r-Pn.length,a=Ln(c,!1);if(a&&a.test(t)){n=c;break}}let s=[n];if(!ds){let r="";for(let c=0;c<Dn;c++)Ln(c,!1)&&Ln(c,!0)&&(r+=`${r?"|":""}(?!\\p{sc=${yn(c)}})\\p{scx=${yn(c)}}`);ds=new RegExp(`^(?:${r})$`,"u")}if(ds.test(t)){const r=[];for(let c=0;c<Dn;c++){const a=Ln(c,!0);a&&a.test(t)&&r.push(c)}r.length&&(s=ar(n,r))}const o=s.join(",");let i=Oe.get(o);return i===void 0&&(i=gn.length,gn.push(s),Oe.set(o,i)),i}function ar(e,t){if(e===t[0])return t;if(e!==Rt&&e!==lt){const n=t.indexOf(e,1);if(n<0){t.push(e);const s=t[0];t[0]=e,t[t.length-1]=s}else t[n]=t[0],t[0]=e;return t}if(e===lt){if(t.length===1)return[lt,t[0]];for(let n=1;n<t.length;n++)if(t[0]===Rn||t[n]<t[0]){const s=t[0];t[0]=t[n],t[n]=s}return t}t.push(t[0]),t[0]=e;for(let n=2;n<t.length;n++)if(t[1]===Rn||t[n]<t[1]){const s=t[1];t[1]=t[n],t[n]=s}return t}const xn=[40,41,91,93,123,125,3898,3899,3900,3901,5787,5788,8261,8262,8317,8318,8333,8334,8968,8969,8970,8971,9001,9002,10088,10089,10090,10091,10092,10093,10094,10095,10096,10097,10098,10099,10100,10101,10181,10182,10214,10215,10216,10217,10218,10219,10220,10221,10222,10223,10627,10628,10629,10630,10631,10632,10633,10634,10635,10636,10637,10640,10639,10638,10641,10642,10643,10644,10645,10646,10647,10648,10712,10713,10714,10715,10748,10749,11810,11811,11812,11813,11814,11815,11816,11817,11861,11862,11863,11864,11865,11866,11867,11868,12296,12297,12298,12299,12300,12301,12302,12303,12304,12305,12308,12309,12310,12311,12312,12313,12314,12315,65113,65114,65115,65116,65117,65118,65288,65289,65339,65341,65371,65373,65375,65376,65378,65379];let dn=null;function lr(e){if(e<40||e>125&&e<3898)return 0;if(!dn){dn=new Map;for(let t=0;t<xn.length;t+=2)dn.set(xn[t],xn[t+1]),dn.set(xn[t+1],-xn[t])}return dn.get(e)??0}const $e=32,kt=[],sn=[];let Ft=0,qn=lt;const Bt=[];let en=[],Vt=[];const Be=[];function Ye(e){let t=Be[e];return t||(Be[e]=t=[e]),t}function ms(){const e=Bt[0];return e===lt?qn:e}function He(e,t){let n=Ft;if(n<=0)return;n>kt.length&&(n=kt.length);let s=kt.length-1;for(t?(s--,n--,Ft=1):Ft=0;n>0;s--,n--)sn[s]=e}function hr(){const e=en,t=Bt;if(e.length===0||t.length===0)return!1;if(e.length===1&&t.length===1){const c=e[0];return c<=Rt?!0:t[0]<=Rt?(t[0]=c,!0):t[0]===c}let n=0,s=t[n++];if(e[0]<=Rt)return e.length===2&&s<=Rt&&qn===lt&&(qn=e[1]),!0;if(s<=Rt)return Xe(Bt,e),!0;let o=e.indexOf(s)>=0;if(n===t.length)return o;let i=0;o||(s=e[i++],o=t.indexOf(s,n)>=0);let r=0;if(o&&(t[r++]=s),i!==e.length)for(;n<t.length;n++)e.indexOf(t[n],i)>=0&&(t[r++]=t[n]);return r>0?(t.length=r,!0):!1}function Xe(e,t){e.length=t.length;for(let n=0;n<t.length;n++)e[n]=t[n]}function fr(e,t,n,s){if(t===0)return 0;let o=lt,i=0;for(;i<t;i++){const l=Ms(e[i]);if(l.length!==1)break;const h=l[0];if(!(h<=Rt||h===o)){if(o!==lt)break;o=h}}if(i===t)return n[0]=t,s[0]=o,1;kt.length=0,sn.length=0,Ft=0,qn=lt,Bt.length=1,Bt[0]=lt,Vt=Ms(e[0]);let r=1,c=e[0],a=0;for(;Bt.length;){let l=!1;for(;r<=t;){const h=r-1,f=c;en=Vt,r===t?r++:(c=e[r++],Vt=Ms(c),Vt[0]===Rt&&Vt.length>1&&(en[0]===lt&&(en=Vt.slice(1)),Vt=Ye(Rt)));const p=lr(f);if(p>0)kt.length===$e&&(kt.shift(),sn.shift(),Ft===$e&&Ft--),He(ms(),!1),kt.push(f),sn.push(lt),Ft++;else if(p<0){for(let u=kt.length-1;u>=0;u--)if(kt[u]===-p){const _=sn[u];_!==lt&&(en=Ye(_));const y=kt.length-1-u;kt.length-=y,sn.length-=y,Ft=Math.max(0,Ft-y);break}}if(!hr()){const u=ms();He(u,p>0),n[a]=h,s[a++]=u,Xe(Bt,en),l=!0;break}}l||(n[a]=t,s[a++]=ms(),Bt.length=0)}return a}const Ke=[];function xt(e){return(e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3))>>>0}const pr="Bengbng2Devadev2Gujrgjr2Gurugur2Kndaknd2Mlymmlm2Oryaory2Tamltml2Telutel2Mymrmym2",ur="HirakanaLaoolao Yiiiyi Nkoonko Vaiivai Zmthmath";function je(e,t){for(let n=0;n<e.length;n+=8)if(e.substring(n,n+4)===t)return e.substring(n+4,n+8);return""}function Ve(e){let t=Ke[e];if(!t){t=[];const n=yn(e),s=je(pr,n);s&&(s!=="mym2"&&t.push(xt(s.substring(0,3)+"3")),t.push(xt(s))),t.push(xt(je(ur,n)||n.toLowerCase())),Ke[e]=t}return t}const We=64,On=64,_r=["abvm","blwm","mark","mkmk","curs","dist","kern"].map(xt),yr=xt("kern"),ze=[xt("DFLT"),xt("dflt"),xt("latn")],bs=0,ws=1,Gn=2,Ut=new Uint16Array(0),gr=new Int16Array(0),xr=new Uint32Array(0);class Mn{constructor(t,n,s,o){this._type=t,this._fmt=n,this._off=s,this._cov=o,this._cd1=Ut,this._cd2=Ut,this._cd3=Ut,this._vf1=0,this._vf2=0,this._len1=0,this._len2=0,this._n1=0,this._n2=0,this._simple=!1,this._kx=gr,this._ps=xr,this._sg=Ut}}class dr{constructor(t,n,s){this._props=t,this._set=n,this._subs=s;let o=0;for(const r of s)o=Math.max(o,r._cov.length);const i=new Uint8Array(o);for(const r of s){const c=r._cov;for(let a=0;a<c.length;a++)c[a]!==$t&&(i[a]=1)}this._any=i,this._pairs=s.length>0&&s.every(r=>r._simple)}}class Mr{constructor(t,n){this._lookups=t,this._kern=n}}let dt=new DataView(new ArrayBuffer(0)),Ze=0,Nn=0,Qe=0,qt=0,Yt=null;const As=new Int32Array(We*On);function $n(e,t,n){let s=e;t&1&&(L._xo[n]=L._xo[n]+dt.getInt16(s),s+=2),t&2&&(L._yo[n]=L._yo[n]+dt.getInt16(s),s+=2),t&4&&(L._xa[n]=L._xa[n]+dt.getInt16(s))}function mr(e,t,n){const s=L._gid,o=L._gp,i=L._xa,r=e._any,c=e._subs,a=e._props,l=e._set;for(let h=t;h<n;h++){const f=s[h];if(f>=r.length||!r[f])continue;const p=o[h];if(p&a&14||p&Dt&&!un(p,f,a,l))continue;let u=h+1;if(u>=n)break;const _=o[u];if((_&(nn|Dt)||_&a&14)&&(u=gs(h,n,a,l),u<0))continue;const y=s[u];for(let g=0;g<c.length;g++){const x=c[g],b=x._cov,M=f<b.length?b[f]:$t;if(M===$t)continue;let A=-1;if(x._fmt===1){if(M>=x._ps.length-1)continue;const k=x._sg;let S=x._ps[M],T=x._ps[M+1]-1;for(;S<=T;){const w=S+T>>1,m=k[w];if(m<y)S=w+1;else if(m>y)T=w-1;else{A=w;break}}}else{const k=f<x._cd1.length?x._cd1[f]:0,S=y<x._cd2.length?x._cd2[y]:0;k<x._n1&&S<x._n2&&(A=k*x._n2+S)}if(!(A<0)){i[h]=i[h]+x._kx[A],h=u-1;break}}}}function Je(e){let t=0;for(let n=e&255;n;n&=n-1)t++;return t*2}class br{constructor(t,n,s){this._lookupCache=[],this._planCache=[],this._covCache=new Map,this._cdCache=new Map;const o=new DataView(t);this._view=o,this._scripts=n+o.getUint16(n+4),this._features=n+o.getUint16(n+6),this._lookupList=n+o.getUint16(n+8),this._gdef=s}_cov(t,n){if(!n)return Ut;let s=this._covCache.get(t+n);return s||(s=Fe(this._view,t+n),this._covCache.set(t+n,s)),s}_cd(t,n){if(!n)return Ut;let s=this._cdCache.get(t+n);return s||(s=xs(this._view,t+n),this._cdCache.set(t+n,s)),s}_script(t){const n=this._view,s=this._scripts;for(let o=0,i=n.getUint16(s);o<i;o++)if(n.getUint32(s+2+6*o)===t)return s+n.getUint16(s+6+6*o);return 0}_plan(t,n){let s=this._planCache[t];if(s)return s;const o=this._view;let i=0;for(let l=0;l<n.length&&!i;l++)i=this._script(n[l]);for(let l=0;l<ze.length&&!i;l++)i=this._script(ze[l]);const r=[];let c=!1;const a=i?o.getUint16(i):0;if(a){const l=i+a,h=o.getUint16(l+2),f=this._features,p=o.getUint16(f),u=o.getUint16(l+4);for(let _=-1;_<u;_++){const y=_<0?h:o.getUint16(l+6+2*_);if(y>=p)continue;const g=o.getUint32(f+2+6*y);if(_>=0&&_r.indexOf(g)<0)continue;g===yr&&(c=!0);const x=f+o.getUint16(f+6+6*y);for(let b=0,M=o.getUint16(x+2);b<M;b++){const A=o.getUint16(x+4+2*b);r.indexOf(A)<0&&r.push(A)}}}return r.sort((l,h)=>l-h),s=new Mr(r,c),this._planCache[t]=s,s}_lookup(t){const n=this._lookupCache[t];if(n)return n;const s=this._view,o=this._lookupList;if(t>=s.getUint16(o))return null;const i=o+s.getUint16(o+2+2*t),r=s.getUint16(i),c=s.getUint16(i+2),a=s.getUint16(i+4);let l=null;c&16&&(l=this._gdef?this._gdef._markSet(s.getUint16(i+6+2*a)):Ut);const h=[];for(let p=0;p<a;p++){let u=i+s.getUint16(i+6+2*p),_=r;_===9&&(_=s.getUint16(u+2),u+=s.getUint32(u+4));const y=this._sub(_,u);y&&h.push(y)}const f=new dr(c,l,h);return this._lookupCache[t]=f,f}_sub(t,n){const s=this._view,o=s.getUint16(n);if(t===1||t===2){if(o!==1&&o!==2)return null;const i=new Mn(t,o,n,this._cov(n,s.getUint16(n+2)));return i._vf1=s.getUint16(n+4),i._len1=Je(i._vf1),t===2&&(i._vf2=s.getUint16(n+6),i._len2=Je(i._vf2),o===2&&(i._cd1=this._cd(n,s.getUint16(n+8)),i._cd2=this._cd(n,s.getUint16(n+10)),i._n1=s.getUint16(n+12),i._n2=s.getUint16(n+14)),(i._vf1&15)===4&&i._vf2===0&&this._decodePairs(i)),i}if(t===7){if(o===3)return new Mn(t,o,n,this._cov(n,s.getUint16(n+6)));if(o!==1&&o!==2)return null;const i=new Mn(t,o,n,this._cov(n,s.getUint16(n+2)));return o===2&&(i._cd1=this._cd(n,s.getUint16(n+4))),i}if(t===8){if(o===3){const r=s.getUint16(n+2);return new Mn(t,o,n,this._cov(n,s.getUint16(n+6+2*r)))}if(o!==1&&o!==2)return null;const i=new Mn(t,o,n,this._cov(n,s.getUint16(n+2)));return o===2&&(i._cd1=this._cd(n,s.getUint16(n+4)),i._cd2=this._cd(n,s.getUint16(n+6)),i._cd3=this._cd(n,s.getUint16(n+8))),i}return null}_decodePairs(t){const n=this._view,s=t._off,o=t._len1;if(t._simple=!0,t._fmt===2){const h=t._n1*t._n2,f=new Int16Array(h);for(let p=0;p<h;p++)f[p]=n.getInt16(s+16+p*o);t._kx=f;return}const i=n.getUint16(s+8),r=new Uint32Array(i+1);let c=0;for(let h=0;h<i;h++)r[h]=c,c+=n.getUint16(s+n.getUint16(s+10+2*h));r[i]=c;const a=new Uint16Array(c),l=new Int16Array(c);for(let h=0;h<i;h++){const f=s+n.getUint16(s+10+2*h);for(let p=0,u=r[h+1]-r[h];p<u;p++){const _=f+2+p*(2+o);a[r[h]+p]=n.getUint16(_),l[r[h]+p]=n.getInt16(_+2)}}t._ps=r,t._sg=a,t._kx=l}_position(t,n,s){dt=this._view,Ze=n,Nn=s,Qe=Math.max((s-n)*64,16384);const o=t._lookups;for(let i=0;i<o.length;i++){const r=this._lookup(o[i]);if(!r||!r._subs.length)continue;if(qt=r._props,Yt=r._set,r._pairs){mr(r,n,s);continue}const c=L._gp,a=L._gid,l=r._any;for(let h=n;h<s;){const f=a[h];if(f<l.length&&l[f]&&un(c[h],f,qt,Yt)){const p=this._applyAt(r,h,0);if(p>=0){h=p;continue}}h++}}}_applyAt(t,n,s){const o=t._subs;for(let i=0;i<o.length;i++){const r=this._applySub(o[i],n,s);if(r>=0)return r}return-1}_applySub(t,n,s){const o=L._gid[n],i=t._cov,r=o<i.length?i[o]:$t;if(r===$t)return-1;const c=dt,a=t._off;switch(t._type){case 1:{if(t._fmt===1)$n(a+6,t._vf1,n);else{if(r>=c.getUint16(a+6))return-1;$n(a+8+r*t._len1,t._vf1,n)}return n+1}case 2:{let l=n+1;if(l>=Nn)return-1;const h=L._gp[l];if((h&(nn|Dt)||h&qt&14)&&(l=gs(n,Nn,qt,Yt),l<0))return-1;const f=L._gid[l];if(t._simple){const u=t._kx;if(t._fmt===1){if(r>=t._ps.length-1)return-1;const g=t._sg;let x=t._ps[r],b=t._ps[r+1]-1;for(;x<=b;){const M=x+b>>1,A=g[M];if(A<f)x=M+1;else if(A>f)b=M-1;else return L._xa[n]=L._xa[n]+u[M],l}return-1}const _=o<t._cd1.length?t._cd1[o]:0,y=f<t._cd2.length?t._cd2[f]:0;return _>=t._n1||y>=t._n2?-1:(L._xa[n]=L._xa[n]+u[_*t._n2+y],l)}let p;if(t._fmt===1){if(r>=c.getUint16(a+8))return-1;const u=a+c.getUint16(a+10+2*r),_=2+t._len1+t._len2;let y=0,g=c.getUint16(u)-1;for(p=-1;y<=g;){const x=y+g>>1,b=u+2+x*_,M=c.getUint16(b);if(M<f)y=x+1;else if(M>f)g=x-1;else{p=b+2;break}}if(p<0)return-1}else{const u=o<t._cd1.length?t._cd1[o]:0,_=f<t._cd2.length?t._cd2[f]:0;if(u>=t._n1||_>=t._n2)return-1;p=a+16+(u*t._n2+_)*(t._len1+t._len2)}return t._vf1&&$n(p,t._vf1,n),t._vf2&&$n(p+t._len1,t._vf2,l),t._len2?l+1:l}case 7:return this._context(t,n,o,r,s);case 8:return this._chain(t,n,o,r,s)}return-1}_context(t,n,s,o,i){const r=dt,c=t._off;if(t._fmt===3){const u=r.getUint16(c+2),_=this._input(n,u,Gn,Ut,c+8,c,i);return _<0?-1:(this._apply(c+6+2*u,r.getUint16(c+4),u,i),_)}let a=o,l=c+4,h=bs;if(t._fmt===2&&(a=s<t._cd1.length?t._cd1[s]:0,l=c+6,h=ws),a>=r.getUint16(l))return-1;const f=r.getUint16(l+2+2*a);if(!f)return-1;const p=c+f;for(let u=0,_=r.getUint16(p);u<_;u++){const y=p+r.getUint16(p+2+2*u),g=r.getUint16(y),x=this._input(n,g,h,t._cd1,y+4,0,i);if(!(x<0))return this._apply(y+4+2*Math.max(g-1,0),r.getUint16(y+2),g,i),x}return-1}_chain(t,n,s,o,i){const r=dt,c=t._off;if(t._fmt===3){let u=c+2;const _=r.getUint16(u),y=u+2;u+=2+2*_;const g=r.getUint16(u),x=u+2;u+=2+2*g;const b=r.getUint16(u),M=u+2;u+=2+2*b;const A=this._input(n,g,Gn,Ut,x+2,c,i);return A<0||!this._lookahead(A,b,Gn,Ut,M,c)||!this._backtrack(n,_,Gn,Ut,y,c)?-1:(this._apply(u+2,r.getUint16(u),g,i),A)}let a=o,l=c+4,h=bs;if(t._fmt===2&&(a=s<t._cd2.length?t._cd2[s]:0,l=c+10,h=ws),a>=r.getUint16(l))return-1;const f=r.getUint16(l+2+2*a);if(!f)return-1;const p=c+f;for(let u=0,_=r.getUint16(p);u<_;u++){let y=p+r.getUint16(p+2+2*u);const g=r.getUint16(y),x=y+2;y+=2+2*g;const b=r.getUint16(y),M=y+2;y+=2+2*Math.max(b-1,0);const A=r.getUint16(y),k=y+2;y+=2+2*A;const S=this._input(n,b,h,t._cd2,M,0,i);if(!(S<0)&&this._lookahead(S,A,h,t._cd3,k,0)&&this._backtrack(n,g,h,t._cd1,x,0))return this._apply(y+2,r.getUint16(y),b,i),S}return-1}_matches(t,n,s,o,i){if(t===bs)return i===o;if(t===ws)return(i<n.length?n[i]:0)===o;const r=this._cov(s,o);return i<r.length&&r[i]!==$t}_next(t,n,s,o,i){const r=L._gp,c=L._gid;for(let a=t+1;a<Nn;a++){const l=r[a],h=c[a];if(un(l,h,qt,Yt)){if(this._matches(n,s,o,i,h))return a;if(!(l&nn))return-1}}return-1}_prev(t,n,s,o,i){const r=L._gp,c=L._gid;for(let a=t-1;a>=Ze;a--){const l=r[a],h=c[a];if(un(l,h,qt,Yt)){if(this._matches(n,s,o,i,h))return a;if(!(l&nn))return-1}}return-1}_input(t,n,s,o,i,r,c){if(n>On)return-1;const a=c*On;As[a]=t;let l=t;for(let h=1;h<n;h++){if(l=this._next(l,s,o,r,dt.getUint16(i+2*(h-1))),l<0)return-1;As[a+h]=l}return l+1}_lookahead(t,n,s,o,i,r){let c=t-1;for(let a=0;a<n;a++)if(c=this._next(c,s,o,r,dt.getUint16(i+2*a)),c<0)return!1;return!0}_backtrack(t,n,s,o,i,r){let c=t;for(let a=0;a<n;a++)if(c=this._prev(c,s,o,r,dt.getUint16(i+2*a)),c<0)return!1;return!0}_apply(t,n,s,o){const i=o*On;for(let r=0;r<n;r++){const c=dt.getUint16(t+4*r);if(c>=s||o+1>=We||Qe--<=0)continue;const a=this._lookup(dt.getUint16(t+4*r+2));if(!a)continue;const l=qt,h=Yt;qt=a._props,Yt=a._set,this._applyAt(a,As[i+c],o+1),qt=l,Yt=h}}}function wr(e){if(e<173)return!1;if(e<65536){switch(e>>8){case 0:return e===173;case 3:return e===847;case 6:return e===1564;case 23:return e>=6068&&e<=6069;case 24:return e>=6155&&e<=6159;case 32:return e>=8203&&e<=8207||e>=8234&&e<=8238||e>=8288&&e<=8303;case 254:return e>=65024&&e<=65039||e===65279;case 255:return e>=65520&&e<=65528}return!1}return e>=119155&&e<=119162||e>=917504&&e<=921599}function Ar(e,t,n){const s=e.metrics.unitsPerEm;switch(t){case 160:return e.advance(n);case 8193:case 8195:case 12288:return s;case 8192:case 8194:return s/2;case 8196:return s/3;case 8197:return s/4;case 8198:return s/6;case 8201:return s/5;case 8202:return s/16;case 8287:return s*4/18;case 8239:return e.advance(n)/2;case 8199:{for(let o=48;o<=57;o++){const i=e.glyphId(o);if(i)return e.advance(i)}return e.advance(n)}case 8200:{const o=e.glyphId(46)||e.glyphId(44);return e.advance(o||n)}}return-1}let ks=null;const to=new Map;function kr(e){if(e<768)return!1;let t=to.get(e);return t===void 0&&(ks||(ks=new RegExp("^\\p{Mn}$","u")),t=ks.test(String.fromCodePoint(e)),to.set(e,t)),t}function Ur(e,t){const n=t.length;Le(n);const s=L._cp,o=L._gid,i=L._gp,r=L._xa,c=L._xo,a=L._yo,l=e._glyphProps(),h=e._advances(),f=h.length?h[h.length-1]:0,p=e.glyphId(32);let u=!1,_=0,y=0;for(let M=0;M<n;M++){let A=t.charCodeAt(M);if(A>=55296&&A<56320&&M+1<n){const m=t.charCodeAt(M+1);m>=56320&&m<57344&&(A=(A-55296<<10)+(m-56320)+65536,M++)}let k=e.glyphId(A),S=-1;!k&&A>=160&&p&&((A===8192||A===8193)&&(k=e.glyphId(A+2)),k||(S=Ar(e,A,p),S>=0&&(k=p)));const T=A>=173&&wr(A);let w;l?w=k<l.length?l[k]:0:w=!T&&kr(A)?Dt:In,T&&(w|=A===8204?pn:pn|nn,u=!0),_|=w,s[y]=A,o[y]=k,i[y]=w,r[y]=S>=0?S:k<h.length?h[k]:f,c[y]=0,a[y]=0,y++}const g=fr(s,y,L._runEnd,L._runScript),x=(_&Dt)!==0;let b=0;for(let M=0;M<g;M++){const A=L._runEnd[M];co(e,b,A,L._runScript[M],x),b=A}if(u)for(let M=0;M<y;M++)i[M]&pn&&(r[M]=c[M]=a[M]=0);return y}const Us=0,no=1,Ss=2,Sr=3,Ts=4,Bn=Ss|Ts,Tr=Us|Ts,vr=Ss,so=Us,vs=no,Cr="BengDevaGujrGuruKndaMlymOryaTamlTelu",Er="TibtMongSinhBuhdHanoTglgTagbLimbTaleBugiKharSyloTfngBaliNkooPhagChamKaliLepcRjngSaurSundEgypJavaKthiMteiLanaTavtBatkBrahMandCakmPlrdShrdTakrDuplGranKhojSindMahjManiModiHmngPhlpSiddTirhAhomMultAdlmBhksMarcNewaGonmSoyoZanbDogrGongRohgMakaMedfSogoSogdElymNandHmnpWchoChrsDiakKitsYeziCpmnOugrTnsaTotoVithKawiNagmGaraGukhKraiOnaoSunuTodrTutgBerfSidtTayoTolsJurcPcunSeal",eo=xt("DFLT"),oo=xt("latn"),Ir=xt("mymr"),io=[eo,xt("dflt"),oo];function Dr(e,t){if(!e)return 0;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>=0)return t[n];for(let n=0;n<3;n++)if(e.indexOf(io[n])>=0)return io[n];return 0}function Rr(e,t){const n=t===eo||t===oo;return e==="Thai"||e==="Laoo"?vr:e==="Hang"?Tr:e==="Khmr"?so:e==="Mymr"?n||t===Ir?Bn:vs:Cr.indexOf(e)>=0?n?Bn:(t&255)===51?vs:so:Er.indexOf(e)>=0?n?Bn:vs:Bn}function Lr(e,t){const n=e._shaperCache();let s=n[t];return s<0&&(s=Rr(yn(t),Dr(e._gsubScriptTags(),Ve(t))),n[t]=s),s}function ro(e,t,n){const s=L._gp,o=L._xa,i=L._xo;for(let r=e;r<t;r++)s[r]&Dt&&(n&&(i[r]=i[r]-o[r]),o[r]=0)}function co(e,t,n,s,o){const i=Lr(e,s),r=e._gposTable(),c=e._kernTable(),a=r?r._plan(s,Ve(s)):null,l=c!==null&&c._hasData&&!(a&&a._kern)&&(i&Ts)!==0,h=!o||l&&c._hasMachine?Us:i&Sr,f=!r&&(!l||!c._hasCross);h===no&&ro(t,n,f),a&&r._position(a,t,n),l&&c._apply(t,n),h===Ss&&ro(t,n,f)}function Pr(e,t,n){Le(2);const s=e._glyphProps(),o=e.advance(t),i=e.advance(n);return L._gid[0]=t,L._gid[1]=n,L._gp[0]=s?t<s.length?s[t]:0:In,L._gp[1]=s?n<s.length?s[n]:0:In,L._xa[0]=o,L._xa[1]=i,L._xo[0]=L._xo[1]=L._yo[0]=L._yo[1]=0,co(e,0,2,lt,((L._gp[0]|L._gp[1])&Dt)!==0),L._xa[0]+L._xa[1]-o-i}function Fr(e){const t=new It(e);if(t.u32()===1953784678){if(t.skip(4),t.u32()===0)throw new Error("TTC contains no fonts");const o=t.u32();t.seek(o)}else t.seek(0);return qr(e,t)}function qr(e,t){t.skip(4);const n=t.u16();t.skip(6);const s=new Map;for(let o=0;o<n;o++){const i=String.fromCharCode(t.u8(),t.u8(),t.u8(),t.u8());t.skip(4);const r=t.u32(),c=t.u32();s.set(i,{offset:r,length:c})}return s}const ao=2048,Or=65536;class Gr{constructor(t){this._buffer=t,this._tables=Fr(t);const n=this._tables.get("head"),s=this._tables.get("maxp"),o=this._tables.get("hhea"),i=this._tables.get("hmtx"),r=this._tables.get("loca"),c=this._tables.get("cmap");if(!n)throw new Error("Font missing required `head` table");if(!s)throw new Error("Font missing required `maxp` table");if(!o)throw new Error("Font missing required `hhea` table");if(!i)throw new Error("Font missing required `hmtx` table");if(!r)throw new Error("Font missing required `loca` table");if(!c)throw new Error("Font missing required `cmap` table");this._head=Li(t,n.offset);const a=Oi(t,s.offset);this._hhea=Pi(t,o.offset),this._hmtx=Fi(t,i.offset,a.numGlyphs,this._hhea.numberOfHMetrics),this._loca=qi(t,r.offset,a.numGlyphs,this._head.indexToLocFormat),this._cmap=Ii(t,c.offset),this._cmapCache=null,this._layoutLoaded=!1,this._gdef=null,this._gpos=null,this._kern=null,this._gsubScripts=null,this._shapers=null,this._advanceTable=null,this._pairCache=new Map,this.metrics={unitsPerEm:this._head.unitsPerEm,ascender:this._hhea.ascender,descender:this._hhea.descender,lineGap:this._hhea.lineGap}}glyphId(t){if(t>=ao||t<0)return this._cmap(t);let n=this._cmapCache;n||(n=this._cmapCache=new Uint16Array(ao));let s=n[t];return s||(n[t]=s=this._cmap(t)+1),s-1}get numGlyphs(){return this._loca.length-1}advance(t){return(this._hmtx[t]??this._hmtx[this._hmtx.length-1]??{advanceWidth:0}).advanceWidth}lsb(t){return(this._hmtx[t]??this._hmtx[this._hmtx.length-1]??{lsb:0}).lsb}kerning(t,n){const s=t<32768&&n<32768?t<<15|n:-1-(t*65536+n),o=this._pairCache.get(s);return o!==void 0?o:this._kerningMiss(s,t,n)}_kerningMiss(t,n,s){const o=Pr(this,n,s);return this._pairCache.size>=Or&&this._pairCache.clear(),this._pairCache.set(t,o),o}_loadLayout(){if(this._layoutLoaded)return;this._layoutLoaded=!0;const t=this._buffer,n=this._tables.get("GDEF"),s=this._tables.get("GPOS"),o=this._tables.get("kern"),i=this._tables.get("GSUB");n&&(this._gdef=new er(t,n.offset,this.numGlyphs)),s&&(this._gpos=new br(t,s.offset,this._gdef)),o&&(this._kern=new nr(t,o.offset)),i&&(this._gsubScripts=sr(new DataView(t),i.offset))}_gsubScriptTags(){return this._loadLayout(),this._gsubScripts}_shaperCache(){let t=this._shapers;return t||(t=this._shapers=new Int8Array(Dn).fill(-1)),t}_advances(){let t=this._advanceTable;if(!t){const n=this._hmtx.length;t=new Uint16Array(n);for(let s=0;s<n;s++)t[s]=this._hmtx[s].advanceWidth;this._advanceTable=t}return t}_glyphProps(){return this._loadLayout(),this._gdef?this._gdef._props:null}_gposTable(){return this._loadLayout(),this._gpos}_kernTable(){return this._loadLayout(),this._kern}shape(t){const n=this._tables.get("glyf");if(!n)return{contours:[],inverseYAxis:!1};const s=this._loca,o=s[t]??0,r=(s[t+1]??o)-o;return Vi(this._buffer,n.offset,o,r,c=>this._glyphRaw(c))}_glyphRaw(t){const n=this._tables.get("glyf");if(!n)return[];const s=this._loca,o=s[t]??0,r=(s[t+1]??o)-o;return De(this._buffer,n.offset,o,r,c=>this._glyphRaw(c))}}function Yn(e,t){const n=1/t;for(const s of e.contours)for(let o=0;o<s.length;o++){const i=s[o];if(i.p0x*=n,i.p0y*=n,i.p1x*=n,i.p1y*=n,i.p2x*=n,i.p2y*=n,i.p3x*=n,i.p3y*=n,i.type===ot){const r=i.p1x-i.p0x,c=i.p1y-i.p0y,a=i.p2x-i.p1x,l=i.p2y-i.p1y;Q(r,c,a,l)===0&&(s[o]=new tt(J,i.p0x,i.p0y,i.p2x,i.p2y,0,0,0,0))}else if(i.type===Et){const r=i.p2x-i.p1x,c=i.p2y-i.p1y,a=1.5*i.p1x-.5*i.p0x,l=1.5*i.p1y-.5*i.p0y;Q(i.p1x-i.p0x,i.p1y-i.p0y,r,c)===0&&Q(r,c,i.p3x-i.p2x,i.p3y-i.p2y)===0?s[o]=new tt(J,i.p0x,i.p0y,i.p3x,i.p3y,0,0,0,0):a===1.5*i.p2x-.5*i.p3x&&l===1.5*i.p2y-.5*i.p3y&&(s[o]=new tt(ot,i.p0x,i.p0y,a,l,i.p3x,i.p3y,0,0))}}}const lo=1e-6,Nr=1.1111111111111112,$r=new Float64Array(16);function ho(e,t,n){switch(t[n]=e.p0x,t[n+1]=e.p0y,t[n+2]=e.p1x,t[n+3]=e.p1y,e.type){case J:return 1;case ot:return t[n+4]=e.p2x,t[n+5]=e.p2y,2;default:return t[n+4]=e.p2x,t[n+5]=e.p2y,t[n+6]=e.p3x,t[n+7]=e.p3y,3}}function fo(e,t,n){if(n===3){const s=e[t],o=e[t+1],i=e[t+2],r=e[t+3],c=e[t+4],a=e[t+5],l=e[t+6],h=e[t+7];(i===s&&r===o||i===l&&r===h)&&(c===s&&a===o||c===l&&a===h)&&(e[t+2]=l,e[t+3]=h,n=1)}if(n===2){const s=e[t],o=e[t+1],i=e[t+2],r=e[t+3],c=e[t+4],a=e[t+5];(i===s&&r===o||i===c&&r===a)&&(e[t+2]=c,e[t+3]=a,n=1)}return n===1&&e[t]===e[t+2]&&e[t+1]===e[t+3]&&(n=0),n}function Br(e,t){const n=$r;let s=ho(e,n,0),o=ho(t,n,8);if(!(s>=1&&s<=3&&o>=1&&o<=3)||n[s*2]!==n[8]||n[s*2+1]!==n[9])return 0;s=fo(n,0,s),o=fo(n,8,o);const i=n[s*2],r=n[s*2+1];let c=0,a=0,l=0,h=0,f=0,p=0,u=0,_=0,y=0,g=0,x=0,b=0;if(s>=1&&(c=n[(s-1)*2]-i,a=n[(s-1)*2+1]-r),s>=2){const H=n[(s-2)*2]-n[(s-1)*2],V=n[(s-2)*2+1]-n[(s-1)*2+1];l=H-c,h=V-a}if(s>=3){const H=n[(s-3)*2]-n[(s-2)*2],V=n[(s-3)*2+1]-n[(s-2)*2+1],et=n[(s-2)*2]-n[(s-1)*2],z=n[(s-2)*2+1]-n[(s-1)*2+1];f=H-et-l,p=V-z-h,l*=3,h*=3}if(o>=1&&(u=n[10]-i,_=n[11]-r),o>=2){const H=n[12]-n[10],V=n[13]-n[11];y=H-u,g=V-_}if(o>=3){const H=n[14]-n[12],V=n[15]-n[13],et=n[12]-n[10],z=n[13]-n[11];x=H-et-y,b=V-z-g,y*=3,g*=3}c*=s,a*=s,u*=o,_*=o;const M=c!==0||a!==0;if(M&&(u!==0||_!==0)){const H=Math.sqrt(c*c+a*a),V=Math.sqrt(u*u+_*_),et=H*Q(c,a,y,g)+V*Q(l,h,u,_);if(et)return pt(et);const z=H*H*Q(c,a,x,b)+H*V*Q(l,h,y,g)+V*V*Q(f,p,u,_);if(z)return pt(z);const Gt=H*Q(l,h,x,b)+V*Q(f,p,y,g);return pt(Gt||Q(f,p,x,b))}let k=1,S=l,T=h,w=f,m=p,d=u,U=_,C=y,v=g,I=x,R=b;if(M&&(S=y,T=g,w=x,m=b,d=c,U=a,C=l,v=h,I=f,R=p,k=-1),d!==0||U!==0){const H=Q(w,m,d,U);if(H)return k*pt(H);const V=Q(S,T,C,v);if(V)return k*pt(V);const et=Q(w,m,C,v);if(et)return k*pt(et);const z=Q(S,T,I,R);return z?k*pt(z):k*pt(Q(w,m,I,R))}const G=Math.sqrt(S*S+T*T),F=Math.sqrt(C*C+v*v),X=Math.sqrt(G)*Q(S,T,I,R)+Math.sqrt(F)*Q(w,m,C,v);return pt(X||Q(w,m,I,R))}function po(e,t,n,s,o){let i=e[t];if(i.type===ot){const r=i.convertToCubic();e[t]=r,i=r}if(i.type===Et)if(n===0){const r=Math.sqrt((i.p1x-i.p0x)**2+(i.p1y-i.p0y)**2);i.p1x+=r*s,i.p1y+=r*o}else{const r=Math.sqrt((i.p2x-i.p3x)**2+(i.p2y-i.p3y)**2);i.p2x+=r*s,i.p2y+=r*o}}const mn=[0,0],bn=[0,0];function Yr(e){for(let t=0;t<e.contours.length;t++){const n=e.contours[t];let s=0;for(let o=0;o<n.length;o++){const i=n[o];(i.p0x!==i.endX()||i.p0y!==i.endY())&&(n[s++]=i)}n.length=s}for(const t of e.contours)if(t.length===1){const[n,s,o]=t[0].splitInThirds();t.length=0,t.push(n,s,o)}else if(t.length>0){const n=t.length;for(let s=0;s<n;s++){const o=(s+n-1)%n,i=t[o],r=t[s];i.direction(1,mn),r.direction(0,bn);const c=Math.sqrt(mn[0]**2+mn[1]**2),a=Math.sqrt(bn[0]**2+bn[1]**2);if(c===0||a===0)continue;const l=mn[0]/c,h=mn[1]/c,f=bn[0]/a,p=bn[1]/a;if(Ai(l,h,f,p)<lo-1){const u=lo-1,_=Nr*Math.sqrt(1-u*u)/u;let y=f-l,g=p-h;const x=Math.sqrt(y*y+g*g);if(x===0)continue;y=_*y/x,g=_*g/x,Br(i,r)<0&&(y=-y,g=-g),po(t,o,1,-g,y),po(t,s,0,g,-y)}}}}const uo=[0,0,0],_o=[0,0,0],yo=[0,0];function go(e){const t=.5*(Math.sqrt(5)-1),n=e.map(()=>0),s=[];for(let o=0;o<e.length;o++){const i=e[o];if(n[o]||i.length===0)continue;const r=i[0].p0y;let c=r;for(let l=0;l<i.length&&r===c;l++)c=i[l].endY();for(let l=0;l<i.length&&r===c;l++)i[l].point(t,yo),c=yo[1];const a=Se(r,c,t);for(let l=0;l<e.length;l++)for(const h of e[l]){const f=h.scanlineIntersections(a,uo,_o);for(let p=0;p<f;p++)s.push({x:uo[p],dy:_o[p],c:l})}s.sort((l,h)=>pt(l.x-h.x));for(let l=1;l<s.length;l++)s[l].x===s[l-1].x&&(s[l].dy=s[l-1].dy=0);for(let l=0;l<s.length;l++){const h=s[l];h.dy&&(n[h.c]+=2*(l&1^(h.dy>0?1:0))-1)}s.length=0}for(let o=0;o<e.length;o++)n[o]<0&&xo(e[o])}function xo(e){e.reverse();for(let t=0;t<e.length;t++){const n=e[t];e[t]=n.type===J?new tt(J,n.p1x,n.p1y,n.p0x,n.p0y,0,0,0,0):n.type===ot?new tt(ot,n.p2x,n.p2y,n.p1x,n.p1y,n.p0x,n.p0y,0,0):new tt(Et,n.p3x,n.p3y,n.p2x,n.p2y,n.p1x,n.p1y,n.p0x,n.p0y)}}const Cs=[0,0],Hr=[.5-Math.sqrt(.6)/2,.5,.5+Math.sqrt(.6)/2],Xr=[5/18,8/18,5/18];function Kr(e){let t=0;for(const n of e){if(n.type===J){t+=(n.p0x*n.p1y-n.p1x*n.p0y)/2;continue}for(let s=0;s<3;s++){const o=Hr[s],i=1-o;n.point(o,Cs);let r,c;n.type===ot?(r=2*(i*(n.p1x-n.p0x)+o*(n.p2x-n.p1x)),c=2*(i*(n.p1y-n.p0y)+o*(n.p2y-n.p1y))):(r=3*(i*i*(n.p1x-n.p0x)+2*i*o*(n.p2x-n.p1x)+o*o*(n.p3x-n.p2x)),c=3*(i*i*(n.p1y-n.p0y)+2*i*o*(n.p2y-n.p1y)+o*o*(n.p3y-n.p2y))),t+=Xr[s]*(Cs[0]*c-Cs[1]*r)/2}}return t}function jr(e){let t=0;for(const n of e){if(n.length===0)continue;const s=Kr(n);Math.abs(s)>Math.abs(t)&&(t=s)}t>0&&e.forEach(xo)}const Mo=1e-5,Es=1e-6,Vr=2e4,Wr=1e5;function zr(e){return[e.p0x,e.p0y,e.p1x,e.p1y,e.p2x,e.p2y,e.p3x,e.p3y].slice(0,2*e.type+4)}function mo(e){const t=e.length/2-2;return new tt(t,e[0],e[1],e[2],e[3],e[4]??0,e[5]??0,e[6]??0,e[7]??0)}const at=new Float64Array(8),ht=new Float64Array(8),Wt=new Float64Array(8);function Is(e,t,n,s){const o=e.length,i=o/2-1;for(let r=0;r<=i;r++){for(let c=0;c<o;c++)Wt[c]=e[c];for(let c=0,a=o;c<i;c++,a-=2){const l=c<i-r?t:n;for(let h=0;h<a-2;h++)Wt[h]=Wt[h]+l*(Wt[h+2]-Wt[h])}s[2*r]=Wt[0],s[2*r+1]=Wt[1]}}function Zr(e,t,n){return Is(e,t,n,at),Array.from(at.subarray(0,e.length))}let Ds=0,Rs=0,Ot=-1,wn=-1,An=0,kn=0,Hn=0,Xn=0;function Qr(e,t){Ot=-1,wn=-1;let n=0;for(let h=0;h<2;h++){const f=h?e.length-2:0;for(let p=0;p<2;p++){const u=p?t.length-2:0;e[f]===t[u]&&e[f+1]===t[u+1]&&(n++,Ot=h,wn=p)}}if(n!==1){Ot=-1;return}const s=Ot?e.length-2:0;An=e[s],kn=e[s+1];let o=0,i=0;for(let h=2;h<e.length&&o===0&&i===0;h+=2){const f=Ot?e.length-2-h:h;o=e[f]-An,i=e[f+1]-kn}let r=0,c=0;for(let h=2;h<t.length&&r===0&&c===0;h+=2){const f=wn?t.length-2-h:h;r=t[f]-An,c=t[f+1]-kn}const a=Math.hypot(o,i),l=Math.hypot(r,c);Hn=o/a-r/l,Xn=i/a-c/l,Math.hypot(Hn,Xn)>1e-9||(Ot=-1)}function Jr(e,t){const n=Ot?e-2:0;for(let o=0;o<e;o+=2)if(o!==n&&(at[o]-An)*Hn+(at[o+1]-kn)*Xn<=0)return!1;const s=wn?t-2:0;for(let o=0;o<t;o+=2)if(o!==s&&(ht[o]-An)*Hn+(ht[o+1]-kn)*Xn>=0)return!1;return!0}function Un(e,t,n,s,o,i,r){if(--Ds<0||--Rs<0)return;const c=e.length,a=s.length;Is(e,t,n,at),Is(s,o,i,ht);let l=1/0,h=1/0,f=-1/0,p=-1/0;for(let M=0;M<c;M+=2)l=Math.min(l,at[M]),h=Math.min(h,at[M+1]),f=Math.max(f,at[M]),p=Math.max(p,at[M+1]);let u=1/0,_=1/0,y=-1/0,g=-1/0;for(let M=0;M<a;M+=2)u=Math.min(u,ht[M]),_=Math.min(_,ht[M+1]),y=Math.max(y,ht[M]),g=Math.max(g,ht[M+1]);if(l>y||u>f||h>g||_>p||Ot>=0&&(Ot?n===1:t===0)&&(wn?i===1:o===0)&&Jr(c,a))return;const x=Math.max(f-l,p-h),b=Math.max(y-u,g-_);if(c===4&&a===4||x<Mo&&b<Mo){const M=at[c-2]-at[0],A=at[c-1]-at[1],k=ht[a-2]-ht[0],S=ht[a-1]-ht[1],T=Q(M,A,k,S),w=Q(ht[0]-at[0],ht[1]-at[1],k,S)/T,m=Q(ht[0]-at[0],ht[1]-at[1],M,A)/T;w>=0&&w<=1&&m>=0&&m<=1&&r.push(t+w*(n-t),o+m*(i-o))}else x>b?(Un(e,t,(t+n)/2,s,o,i,r),Un(e,(t+n)/2,n,s,o,i,r)):(Un(e,t,n,s,o,(o+i)/2,r),Un(e,t,n,s,(o+i)/2,i,r))}function Kn(e,t,n){const s=e[2]-e[0],o=e[3]-e[1];return((t-e[0])*s+(n-e[1])*o)/(s*s+o*o)}function tc(e,t,n){if(e.length!==4||t.length!==4)return!1;const s=e[2]-e[0],o=e[3]-e[1],i=1e-9*Math.hypot(s,o);return Math.abs(Q(s,o,t[0]-e[0],t[1]-e[1]))>i||Math.abs(Q(s,o,t[2]-e[0],t[3]-e[1]))>i?!1:(n.push(Kn(e,t[0],t[1]),0,Kn(e,t[2],t[3]),1),n.push(0,Kn(t,e[0],e[1]),1,Kn(t,e[2],e[3])),!0)}function nc(e){const t=[];for(let n=e.length-2;n>=0;n-=2)t.push(e[n],e[n+1]);return t}function sc(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!(Math.abs(e[n]-t[n])<Es))return!1;return!0}const Sn=[0,0],zt=[0,0],jn=[0,0,0],Vn=[0,0,0];let on=new Int32Array(8);const ec=0,bo=1,oc=2;function wo(e,t,n,s){let o=0;for(let i=0;i<e.length;i++){if(s<t[4*i+1]-1e-9||s>t[4*i+3]+1e-9)continue;const r=e[i].scanlineIntersections(s,jn,Vn);for(let c=0;c<r;c++)jn[c]<=n&&(o+=Vn[c])}return o!==0}function Ao(e,t,n,s,o,i,r){on.fill(0,0,n);for(let a=0;a<e.length;a++){if(r<o[4*a+1]-1e-9||r>o[4*a+3]+1e-9)continue;const l=e[a].scanlineIntersections(r,jn,Vn);for(let h=0;h<l;h++)jn[h]<=i&&(on[t[a]]+=Vn[h])}let c=!1;for(let a=1;a<n&&!c;a++)c=on[a]!==0;return on[0]!==0&&(s===bo?c:!c)}function ic(e){const t=Ls([e.contours]);t&&(e.contours=t)}function ko(e,t){const n=Ls([e.contours,...t.length>0?t:[[]]],bo);n&&(e.contours=n)}function rc(e,t){if(t.length===0)return;const n=Ls([e.contours,...t],oc);n&&(e.contours=n)}function Ls(e,t=ec){const n=e.flat(),s=n.flat(),o=s.map(zr),i=o.length,r=e.length,c=r>1;on.length<r&&(on=new Int32Array(r));const a=new Float64Array(4*i),l=new Int32Array(i),h=new Int32Array(i);let f=0;for(let w=0;w<r;w++)for(const m of e[w]){for(let d=0;d<m.length;d++)l[f+d]=f+(d+1)%m.length,h[f+d]=w;f+=m.length}for(let w=0;w<i;w++){const m=o[w];let d=1/0,U=1/0,C=-1/0,v=-1/0;for(let I=0;I<m.length;I+=2)d=Math.min(d,m[I]),U=Math.min(U,m[I+1]),C=Math.max(C,m[I]),v=Math.max(v,m[I+1]);a[4*w]=d,a[4*w+1]=U,a[4*w+2]=C,a[4*w+3]=v}const p=Array.from({length:i},(w,m)=>m).sort((w,m)=>a[4*w]-a[4*m]),u=o.map(()=>[]),_=new Uint8Array(i);Rs=Wr;for(let w=0;w<i;w++){const m=p[w];for(let d=w+1;d<i;d++){const U=p[d];if(a[4*U]>a[4*m+2])break;if(a[4*m+1]>a[4*U+3]||a[4*U+1]>a[4*m+3])continue;const C=Math.min(m,U),v=Math.max(m,U);l[C]!==v&&l[v]!==C&&(_[C]=_[v]=1);const I=[];if(Ds=Vr,tc(o[C],o[v],I)||(Qr(o[C],o[v]),Un(o[C],0,1,o[v],0,1,I)),Ds<0||Rs<0)return null;for(let R=0;R<I.length;R+=2)u[C].push(I[R]),u[v].push(I[R+1])}}const y=u.map(w=>{const m=[0];for(const d of w.sort((U,C)=>U-C))d-m[m.length-1]>1e-7&&d<1-1e-7&&m.push(d);return m.push(1),m});let g=!1;const x=[],b=[];let M=0;for(const w of n){const m=M+w.length;let d=!0;for(let I=M;I<m;I++)(_[I]||y[I].length>2)&&(d=!1);let U=!1,C=!1,v=!1;for(let I=M;I<m;I++){const R=y[I];for(let G=1;G<R.length;G++){const F=Zr(o[I],R[G-1],R[G]),X=mo(F);X.point(.5,Sn),X.direction(.5,zt);const H=Math.hypot(zt[0],zt[1]),V=Math.hypot(F[F.length-2]-F[0],F[F.length-1]-F[1]);if(!(H===0||V===0)){if(!d||!U){const et=Math.min(1e-6,V*V/64)/H,z=Sn[0]+zt[1]*et,Gt=Sn[1]-zt[0]*et,_t=Sn[0]-zt[1]*et,Xt=Sn[1]+zt[0]*et;C=c?Ao(s,h,r,t,a,z,Gt):wo(s,a,z,Gt),v=c?Ao(s,h,r,t,a,_t,Xt):wo(s,a,_t,Xt),U=!0}C===v?h[I]===0&&(g=!0):(x.push(F),b.push(C),h[I]!==0&&(g=!0))}}}M=m}const A=2*b.filter(Boolean).length>=b.length,k=[];for(let w=0;w<x.length;w++){let m=x[w];b[w]!==A&&(m=nc(m),g=!0);let d=!1;for(let U=0;U<k.length&&!d;U++)d=sc(k[U],m);d?g=!0:k.push(m)}if(!g)return null;const S=new Uint8Array(k.length),T=[];for(let w=0;w<k.length;w++){if(S[w])continue;S[w]=1;const m=[k[w]];for(;;){const d=m[m.length-1],U=d[d.length-2],C=d[d.length-1];if(m.length>1&&Math.hypot(U-m[0][0],C-m[0][1])<Es){m[0][0]=U,m[0][1]=C;break}let v=-1,I=Es;for(let R=0;R<k.length;R++){if(S[R])continue;const G=Math.hypot(k[R][0]-U,k[R][1]-C);G<I&&(v=R,I=G)}if(v<0)return null;S[v]=1,k[v][0]=U,k[v][1]=C,m.push(k[v])}T.push(m.map(mo))}return T}const Wn=1,zn=2,cc=3,Zn=4,ac=5,lc=6,Ps=7,ut=[0,0],Zt=[0,0];function hc(e,t){return Math.trunc(3+2.875*e/(t-1)-1.4375+.5)-3}function fc(e,t,n,s,o){return e*n+t*s<=0||Math.abs(e*s-t*n)>o}function pc(e){const t=Number(e.v&1n);return e.v>>=1n,t}function uc(e){const t=Number(e.v%3n);return e.v/=3n,t}function Uo(e){return[lc,ac,cc][uc(e)]}function Tn(e,t){const n=e.v<<1+pc(t);e.v=(n|n>>3)&Ps}function _c(e,t,n){const s=e.v&n;s===Wn||s===zn||s===Zn?e.v=s^Ps:Tn(e,t)}function yc(e,t,n=0n){const s=Math.sin(t),o={v:Uo({v:n})},i={v:n};i.v=n,o.v=Uo(i);const r=[];for(const c of e.contours){if(c.length===0)continue;r.length=0,c[c.length-1].direction(1,ut);const l=Math.sqrt(ut[0]*ut[0]+ut[1]*ut[1]);let h=l>0?ut[0]/l:0,f=l>0?ut[1]/l:0;for(let p=0;p<c.length;p++){const u=c[p];u.direction(0,Zt);const _=Math.sqrt(Zt[0]*Zt[0]+Zt[1]*Zt[1]),y=_>0?Zt[0]/_:0,g=_>0?Zt[1]/_:0;fc(h,f,y,g,s)&&r.push(p),u.direction(1,ut);const x=Math.sqrt(ut[0]*ut[0]+ut[1]*ut[1]);h=x>0?ut[0]/x:0,f=x>0?ut[1]/x:0}if(r.length===0){Tn(o,i);for(const p of c)p.color=o.v}else if(r.length===1){const p=[0,Ps,0];Tn(o,i),p[0]=o.v,Tn(o,i),p[2]=o.v;const u=r[0],_=c.length;if(_>=3)for(let y=0;y<_;y++){const g=hc(y,_);c[(u+y)%_].color=p[1+g]}else if(_>=1){const y=[null,null,null,null,null,null,null],g=c[0].splitInThirds();if(y[0+3*u]=g[0],y[1+3*u]=g[1],y[2+3*u]=g[2],_>=2){const x=c[1].splitInThirds();y[3-3*u]=x[0],y[4-3*u]=x[1],y[5-3*u]=x[2],y[0].color=y[1].color=p[0],y[2].color=y[3].color=p[1],y[4].color=y[5].color=p[2]}else y[0].color=p[0],y[1].color=p[1],y[2].color=p[2];c.length=0;for(const x of y)x!==null&&c.push(x)}}else{const p=r.length;let u=0;const _=r[0],y=c.length;Tn(o,i);const g=o.v;for(let x=0;x<y;x++){const b=(_+x)%y;u+1<p&&r[u+1]===b&&(++u,_c(o,i,u===p-1?g:0)),c[b].color=o.v}}}}const j=Number.MAX_VALUE,q=[0,0],Mt=[0,0];let So=0,nt=new Float64Array(0),it=new Float64Array(0),N=new Float64Array(0),$=new Float64Array(0),rt=new Int32Array(0),ct=new Float64Array(0),rn=new Float64Array(0),cn=new Float64Array(0),an=new Float64Array(0),Qt=new Int32Array(0);const st=[0,0];let To=0,Fs=new Float64Array(0),qs=new Float64Array(0),Os=new Float64Array(0),Gs=new Float64Array(0),Ns=new Float64Array(0),$s=new Float64Array(0),Bs=new Float64Array(0),Ys=new Float64Array(0),Hs=new Float64Array(0),Xs=new Float64Array(0),Ks=new Float64Array(0),js=new Float64Array(0),vo=0,vn=new Int32Array(0);function gc(e){const t=e.length;if(t===0)return 0;let n=0;if(t===1){e[0].point(0,st);const s=st[0],o=st[1];e[0].point(.3333333333333333,st);const i=st[0],r=st[1];e[0].point(.6666666666666666,st);const c=st[0],a=st[1];n+=s*r-o*i,n+=i*a-r*c,n+=c*o-a*s}else if(t===2){e[0].point(0,st);const s=st[0],o=st[1];e[0].point(.5,st);const i=st[0],r=st[1];e[1].point(0,st);const c=st[0],a=st[1];e[1].point(.5,st);const l=st[0],h=st[1];n+=s*r-o*i,n+=i*a-r*c,n+=c*h-a*l,n+=l*o-h*s}else{const s=e[t-1];let o=s.p0x,i=s.p0y;for(let r=0;r<t;r++){const c=e[r].p0x,a=e[r].p0y;n+=o*a-i*c,o=c,i=a}}return n>0?-1:n<0?1:0}function xc(e,t,n,s,o,i,r){const c=r[e][t];let a=n;if(i<0){c.direction(0,q);const l=Math.sqrt(q[0]*q[0]+q[1]*q[1]);if(l>0){const h=q[0]/l,f=q[1]/l;c.point(0,Mt);const p=s-Mt[0],u=o-Mt[1];if(p*h+u*f<0){const y=p*f-u*h;Math.abs(y)<=Math.abs(a)&&(a=y)}}}if(i>1){c.direction(1,q);const l=Math.sqrt(q[0]*q[0]+q[1]*q[1]);if(l>0){const h=q[0]/l,f=q[1]/l;c.point(1,Mt);const p=s-Mt[0],u=o-Mt[1];if(p*h+u*f>0){const y=p*f-u*h;Math.abs(y)<=Math.abs(a)&&(a=y)}}}return a}function mt(e,t,n,s,o,i,r,c,a){let l=e<0?t:n;if(o>=0){const h=xc(s,o,e,r,c,i,a);Math.abs(h)<Math.abs(l)&&(l=h)}return l}function St(e,t,n){return Math.max(Math.min(e,t),Math.min(Math.max(e,t),n))}function dc(e,t,n,s,o,i,r,c){if(c.length!==t*n*3)throw new Error(`generateMSDF: out.length ${c.length} !== ${t*n*3}`);const a=e.contours,l=a.length;if(l===0){c.fill(0);return}const h=s/r;Qt.length<l&&(Qt=new Int32Array(l));for(let u=0;u<l;u++)Qt[u]=gc(a[u]);vo<l+1&&(vn=new Int32Array(l+1),vo=l+1);let f=0;for(let u=0;u<l;u++)vn[u]=f,f+=a[u].length;vn[l]=f,To<f&&(Fs=new Float64Array(f),qs=new Float64Array(f),Os=new Float64Array(f),Gs=new Float64Array(f),Ns=new Float64Array(f),$s=new Float64Array(f),Bs=new Float64Array(f),Ys=new Float64Array(f),Hs=new Float64Array(f),Xs=new Float64Array(f),Ks=new Float64Array(f),js=new Float64Array(f),To=f);for(let u=0;u<l;u++){const _=a[u],y=_.length,g=vn[u];for(let x=0;x<y;x++){const b=_[x],M=_[(x+y-1)%y],A=_[(x+1)%y],k=g+x;b.point(0,Mt),Fs[k]=Mt[0],qs[k]=Mt[1],b.point(1,Mt),Os[k]=Mt[0],Gs[k]=Mt[1],b.direction(0,q);let S=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const T=S>0?q[0]/S:0,w=S>0?q[1]/S:0;Ns[k]=T,$s[k]=w,b.direction(1,q),S=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const m=S>0?q[0]/S:0,d=S>0?q[1]/S:0;Bs[k]=m,Ys[k]=d,M.direction(1,q),S=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const U=S>0?q[0]/S:0,C=S>0?q[1]/S:0;A.direction(0,q),S=Math.sqrt(q[0]*q[0]+q[1]*q[1]);const v=S>0?q[0]/S:0,I=S>0?q[1]/S:0,R=U+T,G=C+w,F=Math.sqrt(R*R+G*G);Hs[k]=F>0?R/F:0,Xs[k]=F>0?G/F:0;const X=m+v,H=d+I,V=Math.sqrt(X*X+H*H);Ks[k]=V>0?-(X/V):0,js[k]=V>0?-(H/V):0}}if(So<l){const u=l*3;nt=new Float64Array(u),it=new Float64Array(u),N=new Float64Array(u),$=new Float64Array(u),rt=new Int32Array(u),ct=new Float64Array(u),rn=new Float64Array(l),cn=new Float64Array(l),an=new Float64Array(l),So=l}const p={distance:0,dot:0,param:0};for(let u=0;u<n;u++)for(let _=0;_<t;_++){const y=(_+.5)/s-o,g=(u+.5)/s-i;for(let P=0;P<l;P++){const D=a[P],yt=D.length,E=P*3,B=vn[P];nt[E]=nt[E+1]=nt[E+2]=-j,it[E]=it[E+1]=it[E+2]=0,N[E]=N[E+1]=N[E+2]=-j,$[E]=$[E+1]=$[E+2]=j,rt[E]=rt[E+1]=rt[E+2]=-1,ct[E]=ct[E+1]=ct[E+2]=0;for(let Y=0;Y<yt;Y++){const W=D[Y],xe=W.color,de=(xe&Wn)!==0,Me=(xe&zn)!==0,me=(xe&Zn)!==0;W.signedDistance(y,g,p);const ys=p.distance,hn=p.dot,be=p.param,Kt=Math.abs(ys);if(de){const Pt=Math.abs(nt[E]);(Kt<Pt||Kt===Pt&&hn<it[E])&&(nt[E]=ys,it[E]=hn,rt[E]=Y,ct[E]=be)}if(Me){const Pt=Math.abs(nt[E+1]);(Kt<Pt||Kt===Pt&&hn<it[E+1])&&(nt[E+1]=ys,it[E+1]=hn,rt[E+1]=Y,ct[E+1]=be)}if(me){const Pt=Math.abs(nt[E+2]);(Kt<Pt||Kt===Pt&&hn<it[E+2])&&(nt[E+2]=ys,it[E+2]=hn,rt[E+2]=Y,ct[E+2]=be)}const At=B+Y,we=y-Fs[At],Ae=g-qs[At],ke=y-Os[At],Ue=g-Gs[At],Mi=Ns[At],mi=$s[At],bi=Bs[At],wi=Ys[At],Kc=we*Hs[At]+Ae*Xs[At],jc=ke*Ks[At]+Ue*js[At];if(Kc>0&&-(we*Mi+Ae*mi)>0){const O=we*mi-Ae*Mi;Math.abs(O)<Kt&&(de&&(O<=0&&O>N[E]?N[E]=O:O>0&&O<$[E]&&($[E]=O)),Me&&(O<=0&&O>N[E+1]?N[E+1]=O:O>0&&O<$[E+1]&&($[E+1]=O)),me&&(O<=0&&O>N[E+2]?N[E+2]=O:O>0&&O<$[E+2]&&($[E+2]=O)))}if(jc>0&&ke*bi+Ue*wi>0){const O=ke*wi-Ue*bi;Math.abs(O)<Kt&&(de&&(O<=0&&O>N[E]?N[E]=O:O>0&&O<$[E]&&($[E]=O)),Me&&(O<=0&&O>N[E+1]?N[E+1]=O:O>0&&O<$[E+1]&&($[E+1]=O)),me&&(O<=0&&O>N[E+2]?N[E+2]=O:O>0&&O<$[E+2]&&($[E+2]=O)))}}rn[P]=mt(nt[E],N[E],$[E],P,rt[E],ct[E],y,g,a),cn[P]=mt(nt[E+1],N[E+1],$[E+1],P,rt[E+1],ct[E+1],y,g,a),an[P]=mt(nt[E+2],N[E+2],$[E+2],P,rt[E+2],ct[E+2],y,g,a)}let x=-j,b=0,M=-j,A=j,k=-1,S=-1,T=0,w=-j,m=0,d=-j,U=j,C=-1,v=-1,I=0,R=-j,G=0,F=-j,X=j,H=-1,V=-1,et=0,z=-j,Gt=0,_t=-j,Xt=j,Nt=-1,Xo=-1,Ko=0,as=-j,jo=0,se=-j,ee=j,Vo=-1,Wo=-1,zo=0,ls=-j,Zo=0,oe=-j,ie=j,Qo=-1,Jo=-1,ti=0,hs=-j,ni=0,re=-j,ce=j,si=-1,ei=-1,oi=0,fs=-j,ii=0,ae=-j,le=j,ri=-1,ci=-1,ai=0,ps=-j,li=0,he=-j,fe=j,hi=-1,fi=-1,pi=0;for(let P=0;P<l;P++){const D=P*3,yt=Qt[P],E=St(rn[P],cn[P],an[P]);{const B=nt[D],Y=it[D],W=Math.abs(B);(W<Math.abs(x)||W===Math.abs(x)&&Y<b)&&(x=B,b=Y,k=P,S=rt[D],T=ct[D]),N[D]>M&&(M=N[D]),$[D]<A&&(A=$[D])}{const B=nt[D+1],Y=it[D+1],W=Math.abs(B);(W<Math.abs(w)||W===Math.abs(w)&&Y<m)&&(w=B,m=Y,C=P,v=rt[D+1],I=ct[D+1]),N[D+1]>d&&(d=N[D+1]),$[D+1]<U&&(U=$[D+1])}{const B=nt[D+2],Y=it[D+2],W=Math.abs(B);(W<Math.abs(R)||W===Math.abs(R)&&Y<G)&&(R=B,G=Y,H=P,V=rt[D+2],et=ct[D+2]),N[D+2]>F&&(F=N[D+2]),$[D+2]<X&&(X=$[D+2])}if(yt>0&&E>=0){{const B=nt[D],Y=it[D],W=Math.abs(B);(W<Math.abs(z)||W===Math.abs(z)&&Y<Gt)&&(z=B,Gt=Y,Nt=P,Xo=rt[D],Ko=ct[D]),N[D]>_t&&(_t=N[D]),$[D]<Xt&&(Xt=$[D])}{const B=nt[D+1],Y=it[D+1],W=Math.abs(B);(W<Math.abs(as)||W===Math.abs(as)&&Y<jo)&&(as=B,jo=Y,Vo=P,Wo=rt[D+1],zo=ct[D+1]),N[D+1]>se&&(se=N[D+1]),$[D+1]<ee&&(ee=$[D+1])}{const B=nt[D+2],Y=it[D+2],W=Math.abs(B);(W<Math.abs(ls)||W===Math.abs(ls)&&Y<Zo)&&(ls=B,Zo=Y,Qo=P,Jo=rt[D+2],ti=ct[D+2]),N[D+2]>oe&&(oe=N[D+2]),$[D+2]<ie&&(ie=$[D+2])}}if(yt<0&&E<=0){{const B=nt[D],Y=it[D],W=Math.abs(B);(W<Math.abs(hs)||W===Math.abs(hs)&&Y<ni)&&(hs=B,ni=Y,si=P,ei=rt[D],oi=ct[D]),N[D]>re&&(re=N[D]),$[D]<ce&&(ce=$[D])}{const B=nt[D+1],Y=it[D+1],W=Math.abs(B);(W<Math.abs(fs)||W===Math.abs(fs)&&Y<ii)&&(fs=B,ii=Y,ri=P,ci=rt[D+1],ai=ct[D+1]),N[D+1]>ae&&(ae=N[D+1]),$[D+1]<le&&(le=$[D+1])}{const B=nt[D+2],Y=it[D+2],W=Math.abs(B);(W<Math.abs(ps)||W===Math.abs(ps)&&Y<li)&&(ps=B,li=Y,hi=P,fi=rt[D+2],pi=ct[D+2]),N[D+2]>he&&(he=N[D+2]),$[D+2]<fe&&(fe=$[D+2])}}}const pe=mt(x,M,A,k,S,T,y,g,a),ue=mt(w,d,U,C,v,I,y,g,a),_e=mt(R,F,X,H,V,et,y,g,a),Xc=St(pe,ue,_e),ui=mt(z,_t,Xt,Nt,Xo,Ko,y,g,a),_i=mt(as,se,ee,Vo,Wo,zo,y,g,a),yi=mt(ls,oe,ie,Qo,Jo,ti,y,g,a),us=St(ui,_i,yi),gi=mt(hs,re,ce,si,ei,oi,y,g,a),xi=mt(fs,ae,le,ri,ci,ai,y,g,a),di=mt(ps,he,fe,hi,fi,pi,y,g,a),_s=St(gi,xi,di);let Tt,vt,Ct,ye=0;if(us>=0&&Math.abs(us)<=Math.abs(_s)){Tt=ui,vt=_i,Ct=yi,ye=1;for(let P=0;P<l;P++)if(Qt[P]>0){const D=rn[P],yt=cn[P],E=an[P],B=St(D,yt,E);Math.abs(B)<Math.abs(_s)&&B>St(Tt,vt,Ct)&&(Tt=D,vt=yt,Ct=E)}}else if(_s<=0&&Math.abs(_s)<Math.abs(us)){Tt=gi,vt=xi,Ct=di,ye=-1;for(let P=0;P<l;P++)if(Qt[P]<0){const D=rn[P],yt=cn[P],E=an[P],B=St(D,yt,E);Math.abs(B)<Math.abs(us)&&B<St(Tt,vt,Ct)&&(Tt=D,vt=yt,Ct=E)}}else{const P=(u*t+_)*3;c[P+0]=pe*h+.5,c[P+1]=ue*h+.5,c[P+2]=_e*h+.5;continue}for(let P=0;P<l;P++)if(Qt[P]!==ye){const D=rn[P],yt=cn[P],E=an[P],B=St(D,yt,E),Y=St(Tt,vt,Ct);B*Y>=0&&Math.abs(B)<Math.abs(Y)&&(Tt=D,vt=yt,Ct=E)}St(Tt,vt,Ct)===Xc&&(Tt=pe,vt=ue,Ct=_e);const ge=(u*t+_)*3;c[ge+0]=Tt*h+.5,c[ge+1]=vt*h+.5,c[ge+2]=Ct*h+.5}}const Co=0,Mc=1,mc=2,bc=3;function wc(e,t){switch(t){case Co:return e!==0;case Mc:return(e&1)!==0;case mc:return e>0;case bc:return e<0}return!1}class Ac{constructor(){this._intersections=[],this._lastIndex=0}setIntersections(t){if(this._intersections=t,this._lastIndex=0,t.length>0){t.sort((s,o)=>pt(s.x-o.x));let n=0;for(let s=0;s<t.length;s++)n+=t[s].direction,t[s].direction=n}}_moveTo(t){const n=this._intersections.length;if(n===0)return-1;let s=this._lastIndex;if(t<this._intersections[s].x)do{if(s===0)return this._lastIndex=0,-1;--s}while(t<this._intersections[s].x);else for(;s<n-1&&t>=this._intersections[s+1].x;)++s;return this._lastIndex=s,s}sumIntersections(t){const n=this._moveTo(t);return n>=0?this._intersections[n].direction:0}filled(t,n){return wc(this.sumIntersections(t),n)}}const Eo=[0,0,0],Io=[0,0,0];function kc(e,t,n){const s=[];for(const o of e.contours)for(const i of o){const r=i.scanlineIntersections(t,Eo,Io);for(let c=0;c<r;c++)s.push({x:Eo[c],direction:Io[c]})}n.setIntersections(s)}const ln=2,Do=1,Vs=1.001,Uc=1.1111111111111112,Qn=.01;function Sc(e,t,n,s,o,i,r){if(n===0||s===0)return;const c=new Ac,a=new Int8Array(n*s);for(let l=0;l<s;l++){const h=(l+.5)/o-r;kc(t,h,c);for(let f=0;f<n;f++){const p=(f+.5)/o-i,u=c.filled(p,Co),_=(l*n+f)*3,y=e[_],g=e[_+1],x=e[_+2],b=ft(y,g,x),M=l*n+f;b===.5?a[M]=0:b>.5!==u?(e[_]=1-y,e[_+1]=1-g,e[_+2]=1-x,a[M]=-1):a[M]=1}}for(let l=0;l<s;l++)for(let h=0;h<n;h++){const f=l*n+h;if(a[f]!==0)continue;let p=0;if(h>0&&(p+=a[f-1]),h<n-1&&(p+=a[f+1]),l>0&&(p+=a[f-n]),l<s-1&&(p+=a[f+n]),p<0){const u=(l*n+h)*3;e[u]=1-e[u],e[u+1]=1-e[u+1],e[u+2]=1-e[u+2]}}}const Ws=[0,0];function Tc(e,t,n,s,o,i,r,c){const a=new Uint8Array(n*s);vc(a,t,n,s,o,i,r),Cc(a,e,n,s,o,c),Rc(a,e,n,s,c,Uc),Lc(a,e,n,s)}function vc(e,t,n,s,o,i,r){for(const c of t.contours){if(c.length===0)continue;let a=c[c.length-1];for(const l of c){const h=a.color&l.color;if(!(h&h-1)){l.point(0,Ws);const f=o*(Ws[0]+i),p=o*(Ws[1]+r),u=Math.floor(f-.5)|0,_=Math.floor(p-.5)|0,y=u+1,g=_+1;u<n&&_<s&&y>=0&&g>=0&&(u>=0&&_>=0&&(e[_*n+u]|=ln),y<n&&_>=0&&(e[_*n+y]|=ln),u>=0&&g<s&&(e[g*n+u]|=ln),y<n&&g<s&&(e[g*n+y]|=ln))}a=l}}}function Jn(e,t,n){let s=0;for(let o=0;o<3;o++){const i=e[t+o],r=e[n+o],c=i-r;if(c===0)continue;const a=(i-.5)/c;if(a>0&&a<1){const l=1-a,h=l*e[t]+a*e[n],f=l*e[t+1]+a*e[n+1],p=l*e[t+2]+a*e[n+2],u=o===0?h:o===1?f:p;ft(h,f,p)===u&&(s|=o===0?Wn:o===1?zn:Zn)}}return s}function Ht(e,t,n,s,o,i){(i&Wn&&n[s]!==o||i&zn&&n[s+1]!==o||i&Zn&&n[s+2]!==o)&&(e[t]|=ln)}function Cc(e,t,n,s,o,i){const r=Vs/i,c=Vs/i,a=Vs*Math.SQRT2/i;for(let l=0;l<s;l++)for(let h=0;h<n-1;h++){const f=(l*n+h)*3,p=f+3,u=ft(t[f],t[f+1],t[f+2]),_=ft(t[p],t[p+1],t[p+2]);if(Math.abs(u-.5)+Math.abs(_-.5)<r){const y=Jn(t,f,p);Ht(e,l*n+h,t,f,u,y),Ht(e,l*n+h+1,t,p,_,y)}}for(let l=0;l<s-1;l++)for(let h=0;h<n;h++){const f=(l*n+h)*3,p=((l+1)*n+h)*3,u=ft(t[f],t[f+1],t[f+2]),_=ft(t[p],t[p+1],t[p+2]);if(Math.abs(u-.5)+Math.abs(_-.5)<c){const y=Jn(t,f,p);Ht(e,l*n+h,t,f,u,y),Ht(e,(l+1)*n+h,t,p,_,y)}}for(let l=0;l<s-1;l++)for(let h=0;h<n-1;h++){const f=(l*n+h)*3,p=(l*n+h+1)*3,u=((l+1)*n+h)*3,_=((l+1)*n+h+1)*3,y=ft(t[f],t[f+1],t[f+2]),g=ft(t[p],t[p+1],t[p+2]),x=ft(t[u],t[u+1],t[u+2]),b=ft(t[_],t[_+1],t[_+2]);if(Math.abs(y-.5)+Math.abs(b-.5)<a){const M=Jn(t,f,_);Ht(e,l*n+h,t,f,y,M),Ht(e,(l+1)*n+h+1,t,_,b,M)}if(Math.abs(g-.5)+Math.abs(x-.5)<a){const M=Jn(t,p,u);Ht(e,l*n+h+1,t,p,g,M),Ht(e,(l+1)*n+h,t,u,x,M)}}}function Ec(e,t,n){const s=t<e?t:e,o=e<t?t:e,i=n<o?n:o;return s<i?i:s}function Ic(e,t,n,s){return ft(e[t]+s*(e[n]-e[t]),e[t+1]+s*(e[n+1]-e[t+1]),e[t+2]+s*(e[n+2]-e[t+2]))}function zs(e,t,n,s){return Ec(Math.fround(s*(s*n[0]+t[0])+e[0]),Math.fround(s*(s*n[1]+t[1])+e[1]),Math.fround(s*(s*n[2]+t[2])+e[2]))}const Jt=[0,0,0],Lt=[0,0,0],Zs=[0,0,0],bt=[0,0,0],Ro=1,Lo=2;function Qs(e,t,n,s,o,i,r,c){if(s>.5&&o>.5&&i<=.5||s<.5&&o<.5&&i>=.5||!c&&Dc(s,o,i)!==i){const a=(n-e)*r,l=(t-n)*r;return i>=s-a&&i<=s+a&&i>=o-l&&i<=o+l?Ro:Ro|Lo}return 0}function Po(e){return(e&Lo)!==0}function Dc(e,t,n){return Math.max(Math.min(e,t),Math.min(Math.max(e,t),n))}function ts(e,t,n,s,o,i){const r=ft(e[n],e[n+1],e[n+2]);if(Math.abs(s-.5)<Math.abs(r-.5))return!1;for(let c=0;c<3;c++){const a=e[t+c]-e[t+(c+1)%3],l=e[n+c]-e[n+(c+1)%3],h=a-l;if(h===0)continue;const f=a/h;if(f>Qn&&f<1-Qn){const p=Ic(e,t,n,f),u=Qs(0,1,f,s,r,p,o,i);if(Po(u))return!0}}return!1}function Fo(e,t,n,s,o,i,r,c,a){if(!(a>0&&a<1))return 0;const l=a>r?0:a,h=a>r?a:1;bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2];const f=a>r?n:zs(bt,Jt,Lt,a);bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2];const p=a>r?zs(bt,Jt,Lt,a):s;return Qs(l,h,r,f,p,c,o,i)}function ns(e,t,n,s,o,i,r,c,a){if(!(r>Qn&&r<1-Qn))return!1;bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2];const l=zs(bt,Jt,Lt,r);let h=Qs(0,1,r,n,s,l,o,i);return h|=Fo(e,t,n,s,o,i,r,l,c),h|=Fo(e,t,n,s,o,i,r,l,a),Po(h)}function Js(e,t,n,s,o,i,r,c,a,l,h,f,p){const u=Math.fround(e[t+l]-e[t+h]),_=Math.fround(Math.fround(e[n+l]-e[n+h])+Math.fround(e[s+l]-e[s+h])),y=Math.fround(e[o+l]-e[o+h]),g=Math.fround(Math.fround(y-_)+u),x=Math.fround(Math.fround(_-u)-u),b=u;if(g===0||Math.abs(x)>1e12*Math.abs(g)){if(x!==0){const A=-b/x;if(ns(e,t,i,r,c,a,A,f,p))return!0}return!1}const M=x*x-4*g*b;if(M>0){const A=Math.sqrt(M),k=(-x+A)/(2*g);if(ns(e,t,i,r,c,a,k,f,p))return!0;const S=(-x-A)/(2*g);if(ns(e,t,i,r,c,a,S,f,p))return!0}else if(M===0){const A=-x/(2*g);if(ns(e,t,i,r,c,a,A,f,p))return!0}return!1}function ss(e,t,n,s,o,i,r,c){const a=ft(e[o],e[o+1],e[o+2]);if(Math.abs(i-.5)<Math.abs(a-.5))return!1;for(let p=0;p<3;p++)Zs[p]=Math.fround(Math.fround(e[t+p]-e[n+p])-e[s+p]),Jt[p]=Math.fround(-e[t+p]-Zs[p]),Lt[p]=Math.fround(e[o+p]+Zs[p]);const l=Lt[0]!==0?-.5*Jt[0]/Lt[0]:-1,h=Lt[1]!==0?-.5*Jt[1]/Lt[1]:-1,f=Lt[2]!==0?-.5*Jt[2]/Lt[2]:-1;return!!(Js(e,t,n,s,o,i,a,r,c,0,1,l,h)||Js(e,t,n,s,o,i,a,r,c,1,2,h,f)||Js(e,t,n,s,o,i,a,r,c,2,0,f,l))}function Rc(e,t,n,s,o,i){const r=i/o,c=i/o,a=i*Math.SQRT2/o;for(let l=0;l<s;l++)for(let h=0;h<n;h++){const f=l*n+h,p=f*3,u=ft(t[p],t[p+1],t[p+2]),_=(e[f]&ln)!==0,y=h>0,g=h<n-1,x=l>0,b=l<s-1,M=y?(f-1)*3:-1,A=g?(f+1)*3:-1,k=x?(f-n)*3:-1,S=b?(f+n)*3:-1;let T=!1;if(y&&ts(t,p,M,u,r,_)&&(T=!0),!T&&x&&ts(t,p,k,u,c,_)&&(T=!0),!T&&g&&ts(t,p,A,u,r,_)&&(T=!0),!T&&b&&ts(t,p,S,u,c,_)&&(T=!0),!T&&y&&x){const w=(f-n-1)*3;ss(t,p,M,k,w,u,a,_)&&(T=!0)}if(!T&&g&&x){const w=(f-n+1)*3;ss(t,p,A,k,w,u,a,_)&&(T=!0)}if(!T&&y&&b){const w=(f+n-1)*3;ss(t,p,M,S,w,u,a,_)&&(T=!0)}if(!T&&g&&b){const w=(f+n+1)*3;ss(t,p,A,S,w,u,a,_)&&(T=!0)}T&&(e[f]|=Do)}}function Lc(e,t,n,s){const o=n*s;for(let i=0;i<o;i++)if(e[i]&Do){const r=i*3,c=ft(t[r],t[r+1],t[r+2]);t[r]=c,t[r+1]=c,t[r+2]=c}}function ft(e,t,n){return Math.max(Math.min(e,t),Math.min(Math.max(e,t),n))}const Pc=3,Fc=0n,qo=16;function Oo(e,t,n,s=!0){if(s&&ic(e),e.contours.length===0)return null;const o=es(e),i=t,r=n,c=Math.max(1,Math.ceil((o.maxX-o.minX)*i))+2*r,a=Math.max(1,Math.ceil((o.maxY-o.minY)*i))+2*r,l=r/i-o.minX,h=r/i-o.minY;Yr(e),yc(e,Pc,Fc);const f=new Float32Array(c*a*3);return dc(e,c,a,i,l,h,r,f),Sc(f,e,c,a,i,l,h),Tc(f,e,c,a,i,l,h,r),{msdf:f,w:c,h:a,planeLeft:-l,planeBottom:-h,planeRight:c/i-l,planeTop:a/i-h}}const te=[0,0];function es(e){let t=1/0,n=1/0,s=-1/0,o=-1/0;for(const i of e.contours)for(const r of i)for(let c=0;c<=qo;c++){r.point(c/qo,te);const a=te[0],l=te[1];a<t&&(t=a),l<n&&(n=l),a>s&&(s=a),l>o&&(o=l)}return{minX:t,minY:n,maxX:s,maxY:o}}function Z(e,t){var n;return(n=new RegExp(`\\s${t}\\s*=\\s*(["'])([\\s\\S]*?)\\1`).exec(e))==null?void 0:n[2]}function os(e,t,n){const s=new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*([^;]+)`,"g"),o=c=>{var a,l;return(l=(a=[...c.matchAll(s)].pop())==null?void 0:a[1])==null?void 0:l.trim()},i=Z(e,"class");let r="";if(i&&n){const c=new Set(i.split(/\s+/));r=n.filter(([a])=>c.has(a)).map(([,a])=>a).join(";")}return o(Z(e,"style")??"")??o(r)??Z(e,t)}function is(e,t){return e===void 0?t:parseFloat(e)/(e.trim().endsWith("%")?100:1)}function tn(e,t){return e===void 0?0:parseFloat(e)*(e.trim().endsWith("%")?t/100:1)}function qc(e){const{layers:t,width:n}=Go(e);return{shape:{contours:t.flatMap(o=>(jr(o.shape.contours),o.shape.contours)),inverseYAxis:!1},width:n}}function Go(e){var k,S;e=e.replace(/<!--[\s\S]*?-->/g,"");const t=((k=/<svg\b[^>]*>/.exec(e))==null?void 0:k[0])??"",n=(Z(t,"viewBox")??`0 0 ${Z(t,"width")} ${Z(t,"height")}`).trim().split(/[\s,]+/).map(parseFloat),[s=0,o=0,i=NaN,r=NaN]=n;if(!(r>0))throw new Error("parseSvg: needs a viewBox or width/height");const c=[i,r],a=[r,0,0,-r,s,o+r],l=[1,0,0,-1,-s,o+r],h=i/r,f=[];i>0&&rs(`M${s} ${o}h${i}v${r}h${-i}z`,l,f),Yn({contours:f},r);const p=new Map,u=/<(linear|radial)Gradient\b([^>]*?)(?:\/>|>([\s\S]*?)<\/\1Gradient>)/g;for(const[,T="",w="",m=""]of e.matchAll(u))p.set(Z(w,"id")??"",[T,w,m]);const _=new Map;for(const[,T="",w=""]of e.matchAll(/<clipPath\b([^>]*?)(?:\/>|>([\s\S]*?)<\/clipPath>)/g))_.set(Z(T,"id")??"",[T,w]);const y=new Map;for(const[,T="",w=""]of e.matchAll(No)){const m=Z(w,"id");m!==void 0&&y.set(m,[T,w])}const g=[];for(const[,T=""]of e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/g))for(const[,w="",m=""]of T.matchAll(/([^{}]+)\{([^}]*)\}/g))for(const d of w.split(",")){const U=(S=/^\s*\.([\w-]+)\s*$/.exec(d))==null?void 0:S[1];U&&g.push([U,m])}const x=[],b=[],M=[{m:[1,0,0,1,0,0],fill:"black",rule:"nonzero",fillOpacity:1,opacity:1,clips:[],group:-1}];let A=0;for(const[,T,w="",m="",d]of e.matchAll(/<(\/?)([\w:-]+)([^>]*?)(\/?)>/g)){if(A>0||/^(defs|clipPath|mask|symbol|pattern|marker|style)$/.test(w)){T?A--:d||A++;continue}if(T){M.pop();continue}const U=M[M.length-1],C=_t=>os(m,_t,g),v=is(C("opacity"),1),I=Bo(w,m,c),R={m:wt(U.m,Cn(Z(m,"transform")??"")),fill:C("fill")??U.fill,rule:C("fill-rule")??U.rule,fillOpacity:is(C("fill-opacity"),U.fillOpacity),opacity:U.opacity*v,clips:U.clips,group:U.group};I===void 0&&v<1&&!d&&(R.group=b.push({members:[],parent:U.group,translucent:!1})-1);const G=_.get($o(C("clip-path")));if(G&&Z(G[0],"clipPathUnits")!=="objectBoundingBox"&&(R.clips=[...U.clips,Oc(G,y,g,wt(l,R.m),c)]),d||M.push(R),I===void 0||R.fill==="none")continue;const F=[];rs(I,wt(l,R.m),F),R.rule==="evenodd"&&go(F);const X={contours:F,inverseYAxis:!1};Yn(X,r);const H=p.get($o(R.fill)),V=wt(Yo(R.m),a),et=H?Gc(H,p,g,V,I,c):null;for(const _t of R.clips)ko(X,_t);const z=es(X);if(!(z.maxX<=0||z.minX>=h||z.maxY<=0||z.minY>=1||((z.minX<0||z.minY<0||z.maxX>h||z.maxY>1)&&f.length>0&&ko(X,[f]),X.contours.length===0))){if(R.group>=0){const _t=b[R.group];_t.members.push(x.length);const Xt=et?et.stops.some(Nt=>Nt.opacity<1):!1;(v<1||R.fillOpacity<1||Xt)&&(_t.translucent=!0);for(let Nt=_t.parent;Nt>=0;Nt=b[Nt].parent)b[Nt].translucent=!0}x.push({shape:X,color:R.fill,opacity:R.opacity*R.fillOpacity,gradient:et})}}for(const T of b){if(T.translucent||T.members.length<2)continue;const w=T.members.map(m=>es(x[m].shape));for(let m=0;m<T.members.length-1;m++){const d=w[m],U=[];for(let C=m+1;C<T.members.length;C++){const v=w[C];v.minX<d.maxX&&d.minX<v.maxX&&v.minY<d.maxY&&d.minY<v.maxY&&U.push(x[T.members[C]].shape.contours)}rc(x[T.members[m]].shape,U)}}return{layers:x.filter(T=>T.shape.contours.length>0),width:i/r}}const No=/<([\w:-]+)\b([^>]*?)\/?>/g;function $o(e){var t;return((t=/url\(\s*['"]?#([^)'"\s]+)/.exec(e??""))==null?void 0:t[1])??""}function Oc([e="",t=""],n,s,o,i){var h;const[r=0,c=1]=i,a=[],l=wt(o,Cn(Z(e,"transform")??""));for(const[,f="",p=""]of t.matchAll(No)){let u=[f,p],_=wt(l,Cn(Z(p,"transform")??""));if(f==="use"){const b=n.get(((h=Z(p,"(?:xlink:)?href"))==null?void 0:h.slice(1))??"");if(!b)continue;_=wt(_,[1,0,0,1,tn(Z(p,"x"),r),tn(Z(p,"y"),c)]),_=wt(_,Cn(Z(b[1],"transform")??"")),u=b}const y=Bo(u[0],u[1],i);if(y===void 0)continue;const g=[];rs(y,_,g),[u[1],p,e].map(b=>os(b,"clip-rule",s)).find(Boolean)==="evenodd"&&go(g),Yn({contours:g},c),a.push(g)}return a}function Bo(e,t,[n=0,s=0]){const o=(p,u)=>tn(Z(t,p),u),[i,r,c,a]=[o("x",n),o("y",s),o("width",n),o("height",s)],[l,h,f]=[o("cx",n),o("cy",s),Math.hypot(n,s)/Math.SQRT2];switch(e){case"path":return Z(t,"d")??"";case"polygon":case"polyline":return`M${Z(t,"points")??"0 0"}`;case"circle":case"ellipse":{const[p,u]=e==="circle"?[o("r",f),o("r",f)]:[o("rx",n),o("ry",s)],_=`A${p} ${u} 0 1 0`;return`M${l-p} ${h}${_} ${l+p} ${h}${_} ${l-p} ${h}Z`}case"rect":{const[p,u]=[Z(t,"rx"),Z(t,"ry")],_=Math.min(p===void 0?tn(u,s):tn(p,n),c/2),y=Math.min(u===void 0?tn(p,n):tn(u,s),a/2),g=`A${_} ${y} 0 0 1`;return`M${i+_} ${r}H${i+c-_}${g} ${i+c} ${r+y}V${r+a-y}${g} ${i+c-_} ${r+a}H${i+_}${g} ${i} ${r+a-y}V${r+y}${g} ${i+_} ${r}Z`}default:return}}function Gc(e,t,n,s,o,[i=0,r=0]){var m;const c=[];for(let d=e;d&&!c.includes(d);)c.push(d),d=t.get(((m=Z(d[1]??"","(?:xlink:)?href"))==null?void 0:m.slice(1))??"");const a=d=>c.map(U=>Z(U[1]??"",d)).find(U=>U!==void 0),l=a("gradientUnits")==="userSpaceOnUse",h=(d,U,C)=>{const v=a(d)??U;return parseFloat(v)*(v.trim().endsWith("%")?(l?C:1)/100:1)};let f=Cn(a("gradientTransform")??"");if(!l){const d=[];rs(o,[1,0,0,1,0,0],d);const U=es({contours:d});f=wt([U.maxX-U.minX,0,0,U.maxY-U.minY,U.minX,U.minY],f)}const p=e[0]==="radial",[u,_]=[h("x1","0%",i),h("y1","0%",r)],[y,g]=[h("x2","100%",i)-u,h("y2","0%",r)-_],x=Math.hypot(i,r)/Math.SQRT2,[b,M,A]=[h("cx","50%",i),h("cy","50%",r),h("r","50%",x)],k=y*y+g*g||1,S=p?[1/A,0,0,1/A,-b/A,-M/A]:[y/k,0,g/k,0,-(u*y+_*g)/k,0],w=[...(c.map(d=>d[2]??"").find(d=>/<stop\b/.test(d))??"").matchAll(/<stop\b[^>]*>/g)].map(([d])=>({offset:is(Z(d,"offset"),0),color:os(d,"stop-color",n)??"black",opacity:is(os(d,"stop-opacity",n),1)}));return{radial:p,matrix:wt(S,wt(Yo(f),s)),stops:w}}function wt(e,t){const[n=0,s=0,o=0,i=0,r=0,c=0]=e,[a=0,l=0,h=0,f=0,p=0,u=0]=t;return[n*a+o*l,s*a+i*l,n*h+o*f,s*h+i*f,n*p+o*u+r,s*p+i*u+c]}function Nc([e=0,t=0,n=0,s=0,o=0,i=0],r,c){return[e*r+n*c+o,t*r+s*c+i]}function Yo([e=0,t=0,n=0,s=0,o=0,i=0]){const r=e*s-t*n;return[s/r,-t/r,-n/r,e/r,(n*i-s*o)/r,(t*o-e*i)/r]}function Cn(e){let t=[1,0,0,1,0,0];for(const[,n,s=""]of e.matchAll(/(\w+)\s*\(([^)]*)\)/g)){const[o=0,i,r,c=0,a=0,l=0]=s.trim().split(/[\s,]+/).map(parseFloat),h=o*Math.PI/180,[f,p]=[Math.cos(h),Math.sin(h)],[u,_]=[i??0,r??0];t=wt(t,n==="matrix"?[o,i??0,r??0,c,a,l]:n==="translate"?[1,0,0,1,o,i??0]:n==="scale"?[o,0,0,i??o,0,0]:n==="rotate"?[f,p,-p,f,u-f*u+p*_,_-p*u-f*_]:n==="skewX"?[1,0,Math.tan(h),1,0,0]:[1,Math.tan(h),0,1,0,0])}return t}const ne=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y;function rs(e,t,n){let s=0,o=0,i=0,r=0,c=0,a=0,l=0,h="",f="",p=[];const u=()=>{for(;s<e.length&&` \r
2
+ ,`.includes(e[s]);)s++},_=()=>{u(),ne.lastIndex=s;const b=ne.exec(e);if(!b)throw new Error(`parseSvg: expected a number at ${s} in path "${e}"`);return s=ne.lastIndex,parseFloat(b[0])},y=()=>(u(),e[s++]==="1"?1:0),g=(b,...M)=>{const A=[o,i,...M],k=[];for(let I=0;I<A.length;I+=2)k.push(...Nc(t,A[I],A[I+1]));const[S=0,T=0,w=0,m=0,d=0,U=0,C=0,v=0]=k;p.push(new tt(b,S,T,w,m,d,U,C,v)),o=M[M.length-2],i=M[M.length-1]},x=()=>{p.length>0&&((o!==r||i!==c)&&g(J,r,c),n.push(p),p=[]),o=r,i=c};for(u();s<e.length;u()){if(/[a-zA-Z]/.test(e[s]))h=e[s++];else if(!h)throw new Error(`parseSvg: expected a command at ${s} in path "${e}"`);const b=h.toUpperCase(),M=h===b?0:o,A=h===b?0:i,k=b==="S"&&"CS".includes(f)||b==="T"&&"QT".includes(f),S=k?2*o-a:o,T=k?2*i-l:i;switch(b){case"M":{const w=M+_(),m=A+_();x(),o=r=w,i=c=m,h=h==="M"?"L":"l";break}case"L":g(J,M+_(),A+_());break;case"H":g(J,M+_(),i);break;case"V":g(J,o,A+_());break;case"C":case"S":{const w=b==="C"?M+_():S,m=b==="C"?A+_():T;a=M+_(),l=A+_(),g(Et,w,m,a,l,M+_(),A+_());break}case"Q":case"T":a=b==="Q"?M+_():S,l=b==="Q"?A+_():T,g(ot,a,l,M+_(),A+_());break;case"A":{const w=_(),m=_(),d=_(),U=y(),C=y();$c(g,o,i,w,m,d,U,C,M+_(),A+_());break}case"Z":x(),h="";break;default:throw new Error(`parseSvg: unknown path command "${h}"`)}f=b}x()}function $c(e,t,n,s,o,i,r,c,a,l){if(t===a&&n===l)return;if(s=Math.abs(s),o=Math.abs(o),s===0||o===0)return e(J,a,l);const h=Math.cos(i*Math.PI/180),f=Math.sin(i*Math.PI/180),p=(t-a)/2,u=(n-l)/2,_=h*p+f*u,y=-f*p+h*u,g=_*_/(s*s)+y*y/(o*o);g>1&&(s*=Math.sqrt(g),o*=Math.sqrt(g));const x=s*s*y*y+o*o*_*_,b=(r===c?-1:1)*Math.sqrt(Math.max(0,(s*s*o*o-x)/x)),M=b*s*y/o,A=-b*o*_/s,k=h*M-f*A+(t+a)/2,S=f*M+h*A+(n+l)/2,T=Math.atan2((y-A)/o,(_-M)/s);let w=Math.atan2((-y-A)/o,(-_-M)/s)-T;c&&w<0?w+=2*Math.PI:!c&&w>0&&(w-=2*Math.PI);const m=Math.max(1,Math.ceil(Math.abs(w)/(Math.PI/2)-1e-9)),d=w/m,U=4/3*Math.tan(d/4),C=(I,R)=>k+s*I*h-o*R*f,v=(I,R)=>S+s*I*f+o*R*h;for(let I=0;I<m;I++){const R=Math.cos(T+I*d),G=Math.sin(T+I*d),F=Math.cos(T+(I+1)*d),X=Math.sin(T+(I+1)*d),H=I===m-1;e(Et,C(R-U*G,G+U*R),v(R-U*G,G+U*R),C(F+U*X,X-U*F),v(F+U*X,X-U*F),H?a:C(F,X),H?l:v(F,X))}}function Bc(e){let t=0,n=0;for(const c of e)t+=c.w*c.h,n=Math.max(n,c.w);e.sort((c,a)=>a.h-c.h);const o=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}];let i=0,r=0;for(const c of e)for(let a=o.length-1;a>=0;a--){const l=o[a];if(!(c.w>l.w||c.h>l.h)){if(c.x=l.x,c.y=l.y,r=Math.max(r,c.y+c.h),i=Math.max(i,c.x+c.w),c.w===l.w&&c.h===l.h){const h=o.pop();h&&a<o.length&&(o[a]=h)}else c.h===l.h?(l.x+=c.w,l.w-=c.w):c.w===l.w?(l.y+=c.h,l.h-=c.h):(o.push({x:l.x+c.w,y:l.y,w:l.w-c.w,h:c.h}),l.y+=c.h,l.h-=c.h);break}}return{w:i,h:r,fill:t/(i*r)||0}}const Ho=4,Yc={x:0,y:0,w:0,h:0,advance:0,planeLeft:0,planeBottom:0,planeRight:0,planeTop:0};function cs(e){const t=e<0?0:e>1?1:e;return~Math.trunc(255.5-255*t)&255}class Hc{constructor(t,n={}){this._width=0,this._height=0,this._pixels=new Uint8Array(0),this._cache=new Map,this._byGid=[],this._cacheByKey=new Map,this._font=t,this._pxPerEm=n.pixelsPerEm??40,this._pxrange=n.pxrange??4,this._floats=n.float?new Float32Array(0):null,this.pxrangeEm=this._pxrange/this._pxPerEm}get width(){return this._width}get height(){return this._height}get texture(){return this._pixels}get floatTexture(){return this._floats}glyphs(t){const n=this._requireFont();return this.glyphsByIndex(Array.from(t,s=>n.glyphId(s)))}glyph(t){return this.glyphs([t])[0]}glyphsByIndex(t){const n=[];let s=0;for(const o of t){const i=this._cache.get(o);if(i){n.push(i.glyph);continue}const r=this._generateForGlyphId(o);this._cache.set(o,r),this._byGid[o]=r.glyph,n.push(r.glyph),s++}return s>0&&this._repack(),n}glyphByIndex(t){return this.glyphsByIndex([t])[0]}shapes(t){const n=[];let s=0;for(const[o,i]of t){let r=this._cacheByKey.get(o);r||(r=this._generate(i,0),this._cacheByKey.set(o,r),s++),n.push(r.glyph)}return s>0&&this._repack(),n}_requireFont(){if(!this._font)throw new Error("Atlas: no font — this atlas only supports shapes()");return this._font}_generateForGlyphId(t){const n=this._requireFont(),s=n.metrics.unitsPerEm,o=n.shape(t);return Yn(o,s),this._generate(o,n.advance(t)/s)}_generate(t,n){const s=Oo(t,this._pxPerEm,this._pxrange);return{glyph:{x:0,y:0,w:s?s.w:0,h:s?s.h:0,advance:n,planeLeft:s?s.planeLeft:0,planeBottom:s?s.planeBottom:0,planeRight:s?s.planeRight:0,planeTop:s?s.planeTop:0},msdf:s?s.msdf:null}}layout(t){const n=this._requireFont(),s=Ur(n,t),o=L._gid,i=L._gp;let r=0;const c=this._byGid;for(let _=0;_<s;_++){const y=o[_];if(i[_]&pn||c[y])continue;const g=this._generateForGlyphId(y);this._cache.set(y,g),c[y]=g.glyph,r++}r>0&&this._repack();const a=L._xa,l=L._xo,h=L._yo,f=n.metrics.unitsPerEm,p=[];let u=0;for(let _=0;_<s;_++){const y=i[_]&pn?Yc:c[o[_]];p.push({glyph:y,penX:(u+l[_])/f,penY:h[_]/f}),u+=a[_]}return{glyphs:p,widthEm:u/f}}layoutMultiline(t){const n=this._requireFont(),s=n.metrics.unitsPerEm,o=(n.metrics.ascender-n.metrics.descender+n.metrics.lineGap)/s,i=t.split(`
3
+ `),r=[];let c=0;for(let a=0;a<i.length;a++){const{glyphs:l,widthEm:h}=this.layout(i[a]),f=-a*o;for(const p of l)r.push({glyph:p.glyph,penX:p.penX,penY:f+p.penY});h>c&&(c=h)}return{glyphs:r,widthEm:c,heightEm:i.length*o}}_repack(){const t=[];for(const o of[this._cache,this._cacheByKey])for(const{glyph:i,msdf:r}of o.values())r&&t.push({w:i.w+1,h:i.h+1,x:0,y:0,glyph:i,msdf:r});const{w:n,h:s}=Bc(t);this._width=n,this._height=s,this._pixels=new Uint8Array(n*s*Ho),this._floats&&(this._floats=new Float32Array(n*s*3));for(const o of t)o.glyph.x=o.x,o.glyph.y=o.y,this._blit(o.msdf,o.x,o.y,o.glyph.w,o.glyph.h)}_blit(t,n,s,o,i){var a;const r=this._width,c=this._pixels;for(let l=0;l<i;l++){const h=s+(i-1-l);(a=this._floats)==null||a.set(t.subarray(l*o*3,(l+1)*o*3),(h*r+n)*3);for(let f=0;f<o;f++){const p=(l*o+f)*3,u=(h*r+(n+f))*Ho;c[u]=cs(t[p]),c[u+1]=cs(t[p+1]),c[u+2]=cs(t[p+2]),c[u+3]=255}}}}return gt.Atlas=Hc,gt.CUBIC=Et,gt.EdgeSegment=tt,gt.Font=Gr,gt.LINEAR=J,gt.QUADRATIC=ot,gt.generateShapeMSDF=Oo,gt.parseSvg=qc,gt.parseSvgLayers=Go,gt.pixelFloatToByte=cs,Object.defineProperty(gt,Symbol.toStringTag,{value:"Module"}),gt})({});