modern-text
Version:
Measure and render text in a way that describes the DOM.
1 lines • 212 kB
JavaScript
(function(W,ft){typeof exports=="object"&&typeof module<"u"?ft(exports):typeof define=="function"&&define.amd?define(["exports"],ft):(W=typeof globalThis<"u"?globalThis:W||self,ft(W.modernText={}))})(this,function(W){"use strict";var Sa=Object.defineProperty;var Ba=(W,ft,jt)=>ft in W?Sa(W,ft,{enumerable:!0,configurable:!0,writable:!0,value:jt}):W[ft]=jt;var E=(W,ft,jt)=>Ba(W,typeof ft!="symbol"?ft+"":ft,jt);var se;function ft(r,e,t){if(typeof e=="string"&&e.startsWith("linear-gradient")){const{x0:n,y0:i,x1:s,y1:o,stops:u}=Xr(e,t.left,t.top,t.width,t.height),a=r.createLinearGradient(n,i,s,o);return u.forEach(l=>a.addColorStop(l.offset,l.color)),a}return e}function jt(r,e,t){r!=null&&r.color&&(r.color=ft(t,r.color,e)),r!=null&&r.backgroundColor&&(r.backgroundColor=ft(t,r.backgroundColor,e)),r!=null&&r.textStrokeColor&&(r.textStrokeColor=ft(t,r.textStrokeColor,e))}function Xr(r,e,t,n,i){var d;const s=((d=r.match(/linear-gradient\((.+)\)$/))==null?void 0:d[1])??"",o=s.split(",")[0],u=o.includes("deg")?o:"0deg",a=s.replace(u,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),h=(Number(u.replace("deg",""))||0)*Math.PI/180,c=n*Math.sin(h),f=i*Math.cos(h);return{x0:e+n/2-c,y0:t+i/2+f,x1:e+n/2+c,y1:t+i/2-f,stops:Array.from(a).map(p=>{let g=p[2];return g.startsWith("(")?g=g.split(",").length>3?`rgba${g}`:`rgb${g}`:g=`#${g}`,{offset:Number(p[3].replace("%",""))/100,color:g}})}}function oe(r){const{ctx:e,path:t,fontSize:n,clipRect:i}=r;e.save(),e.beginPath();const s=t.style,o={...s,fill:r.color??s.fill,stroke:r.textStrokeColor??s.stroke,strokeWidth:r.textStrokeWidth?r.textStrokeWidth*n:s.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",shadowOffsetX:(r.shadowOffsetX??0)*n,shadowOffsetY:(r.shadowOffsetY??0)*n,shadowBlur:(r.shadowBlur??0)*n,shadowColor:r.shadowColor};i&&(e.rect(i.left,i.top,i.width,i.height),e.clip(),e.beginPath()),t.drawTo(e,o),e.restore()}function Di(r,e,t){const{left:n,top:i,width:s,height:o}=t,u=r.canvas;u.dataset.viewBox=`${n} ${i} ${s} ${o}`,u.dataset.pixelRatio=String(e);const a=s,l=o;u.width=Math.max(1,Math.ceil(a*e)),u.height=Math.max(1,Math.ceil(l*e)),u.style.width=`${a}px`,u.style.height=`${l}px`,r.clearRect(0,0,u.width,u.height),r.scale(e,e),r.translate(-n,-i)}function gi(r,e){const{paragraphs:t,computedStyle:n,glyphBox:i}=e;jt(n,i,r),t.forEach(s=>{jt(s.computedStyle,s.lineBox,r),s.fragments.forEach(o=>{jt(o.computedStyle,o.inlineBox,r)})})}var pt=Uint8Array,Tt=Uint16Array,An=Int32Array,Xe=new pt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ze=new pt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Pn=new pt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),yi=function(r,e){for(var t=new Tt(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new An(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)i[s]=s-t[n]<<5|n;return{b:t,r:i}},mi=yi(Xe,2),xi=mi.b,Tn=mi.r;xi[28]=258,Tn[258]=28;for(var vi=yi(Ze,0),Zr=vi.b,Fi=vi.r,kn=new Tt(32768),Q=0;Q<32768;++Q){var Jt=(Q&43690)>>1|(Q&21845)<<1;Jt=(Jt&52428)>>2|(Jt&13107)<<2,Jt=(Jt&61680)>>4|(Jt&3855)<<4,kn[Q]=((Jt&65280)>>8|(Jt&255)<<8)>>1}for(var Gt=function(r,e,t){for(var n=r.length,i=0,s=new Tt(e);i<n;++i)r[i]&&++s[r[i]-1];var o=new Tt(e);for(i=1;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;var u;if(t){u=new Tt(1<<e);var a=15-e;for(i=0;i<n;++i)if(r[i])for(var l=i<<4|r[i],h=e-r[i],c=o[r[i]-1]++<<h,f=c|(1<<h)-1;c<=f;++c)u[kn[c]>>a]=l}else for(u=new Tt(n),i=0;i<n;++i)r[i]&&(u[i]=kn[o[r[i]-1]++]>>15-r[i]);return u},te=new pt(288),Q=0;Q<144;++Q)te[Q]=8;for(var Q=144;Q<256;++Q)te[Q]=9;for(var Q=256;Q<280;++Q)te[Q]=7;for(var Q=280;Q<288;++Q)te[Q]=8;for(var Se=new pt(32),Q=0;Q<32;++Q)Se[Q]=5;var Yr=Gt(te,9,0),Kr=Gt(te,9,1),Qr=Gt(Se,5,0),Jr=Gt(Se,5,1),_n=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},$t=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},In=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},On=function(r){return(r+7)/8|0},wi=function(r,e,t){return(t==null||t>r.length)&&(t=r.length),new pt(r.subarray(e,t))},ts=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ut=function(r,e,t){var n=new Error(e||ts[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,Ut),!t)throw n;return n},es=function(r,e,t,n){var i=r.length,s=0;if(!i||e.f&&!e.l)return t||new pt(0);var o=!t,u=o||e.i!=2,a=e.i;o&&(t=new pt(i*3));var l=function(St){var At=t.length;if(St>At){var ct=new pt(Math.max(At*2,St));ct.set(t),t=ct}},h=e.f||0,c=e.p||0,f=e.b||0,d=e.l,p=e.d,g=e.m,D=e.n,S=i*8;do{if(!d){h=$t(r,c,1);var C=$t(r,c+1,3);if(c+=3,C)if(C==1)d=Kr,p=Jr,g=9,D=5;else if(C==2){var F=$t(r,c,31)+257,w=$t(r,c+10,15)+4,v=F+$t(r,c+5,31)+1;c+=14;for(var O=new pt(v),j=new pt(19),_=0;_<w;++_)j[Pn[_]]=$t(r,c+_*3,7);c+=w*3;for(var L=_n(j),z=(1<<L)-1,I=Gt(j,L,1),_=0;_<v;){var P=I[$t(r,c,z)];c+=P&15;var x=P>>4;if(x<16)O[_++]=x;else{var X=0,T=0;for(x==16?(T=3+$t(r,c,3),c+=2,X=O[_-1]):x==17?(T=3+$t(r,c,7),c+=3):x==18&&(T=11+$t(r,c,127),c+=7);T--;)O[_++]=X}}var U=O.subarray(0,F),R=O.subarray(F);g=_n(U),D=_n(R),d=Gt(U,g,1),p=Gt(R,D,1)}else Ut(1);else{var x=On(c)+4,b=r[x-4]|r[x-3]<<8,m=x+b;if(m>i){a&&Ut(0);break}u&&l(f+b),t.set(r.subarray(x,m),f),e.b=f+=b,e.p=c=m*8,e.f=h;continue}if(c>S){a&&Ut(0);break}}u&&l(f+131072);for(var k=(1<<g)-1,N=(1<<D)-1,M=c;;M=c){var X=d[In(r,c)&k],B=X>>4;if(c+=X&15,c>S){a&&Ut(0);break}if(X||Ut(2),B<256)t[f++]=B;else if(B==256){M=c,d=null;break}else{var $=B-254;if(B>264){var _=B-257,V=Xe[_];$=$t(r,c,(1<<V)-1)+xi[_],c+=V}var H=p[In(r,c)&N],Y=H>>4;H||Ut(3),c+=H&15;var R=Zr[Y];if(Y>3){var V=Ze[Y];R+=In(r,c)&(1<<V)-1,c+=V}if(c>S){a&&Ut(0);break}u&&l(f+131072);var nt=f+$;if(f<R){var Zt=s-R,Ot=Math.min(R,nt);for(Zt+f<0&&Ut(3);f<Ot;++f)t[f]=n[Zt+f]}for(;f<nt;++f)t[f]=t[f-R]}}e.l=d,e.p=M,e.b=f,e.f=h,d&&(h=1,e.m=g,e.d=p,e.n=D)}while(!h);return f!=t.length&&o?wi(t,0,f):t.subarray(0,f)},Yt=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8},Be=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8,r[n+2]|=t>>16},Ln=function(r,e){for(var t=[],n=0;n<r.length;++n)r[n]&&t.push({s:n,f:r[n]});var i=t.length,s=t.slice();if(!i)return{t:Si,l:0};if(i==1){var o=new pt(t[0].s+1);return o[t[0].s]=1,{t:o,l:1}}t.sort(function(m,F){return m.f-F.f}),t.push({s:-1,f:25001});var u=t[0],a=t[1],l=0,h=1,c=2;for(t[0]={s:-1,f:u.f+a.f,l:u,r:a};h!=i-1;)u=t[t[l].f<t[c].f?l++:c++],a=t[l!=h&&t[l].f<t[c].f?l++:c++],t[h++]={s:-1,f:u.f+a.f,l:u,r:a};for(var f=s[0].s,n=1;n<i;++n)s[n].s>f&&(f=s[n].s);var d=new Tt(f+1),p=$n(t[h-1],d,0);if(p>e){var n=0,g=0,D=p-e,S=1<<D;for(s.sort(function(F,w){return d[w.s]-d[F.s]||F.f-w.f});n<i;++n){var C=s[n].s;if(d[C]>e)g+=S-(1<<p-d[C]),d[C]=e;else break}for(g>>=D;g>0;){var x=s[n].s;d[x]<e?g-=1<<e-d[x]++-1:++n}for(;n>=0&&g;--n){var b=s[n].s;d[b]==e&&(--d[b],++g)}p=e}return{t:new pt(d),l:p}},$n=function(r,e,t){return r.s==-1?Math.max($n(r.l,e,t+1),$n(r.r,e,t+1)):e[r.s]=t},Ci=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new Tt(++e),n=0,i=r[0],s=1,o=function(a){t[n++]=a},u=1;u<=e;++u)if(r[u]==i&&u!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=r[u]}return{c:t.subarray(0,n),n:e}},Me=function(r,e){for(var t=0,n=0;n<e.length;++n)t+=r[n]*e[n];return t},bi=function(r,e,t){var n=t.length,i=On(e+2);r[i]=n&255,r[i+1]=n>>8,r[i+2]=r[i]^255,r[i+3]=r[i+1]^255;for(var s=0;s<n;++s)r[i+s+4]=t[s];return(i+4+n)*8},Ei=function(r,e,t,n,i,s,o,u,a,l,h){Yt(e,h++,t),++i[256];for(var c=Ln(i,15),f=c.t,d=c.l,p=Ln(s,15),g=p.t,D=p.l,S=Ci(f),C=S.c,x=S.n,b=Ci(g),m=b.c,F=b.n,w=new Tt(19),v=0;v<C.length;++v)++w[C[v]&31];for(var v=0;v<m.length;++v)++w[m[v]&31];for(var O=Ln(w,7),j=O.t,_=O.l,L=19;L>4&&!j[Pn[L-1]];--L);var z=l+5<<3,I=Me(i,te)+Me(s,Se)+o,P=Me(i,f)+Me(s,g)+o+14+3*L+Me(w,j)+2*w[16]+3*w[17]+7*w[18];if(a>=0&&z<=I&&z<=P)return bi(e,h,r.subarray(a,a+l));var X,T,U,R;if(Yt(e,h,1+(P<I)),h+=2,P<I){X=Gt(f,d,0),T=f,U=Gt(g,D,0),R=g;var k=Gt(j,_,0);Yt(e,h,x-257),Yt(e,h+5,F-1),Yt(e,h+10,L-4),h+=14;for(var v=0;v<L;++v)Yt(e,h+3*v,j[Pn[v]]);h+=3*L;for(var N=[C,m],M=0;M<2;++M)for(var B=N[M],v=0;v<B.length;++v){var $=B[v]&31;Yt(e,h,k[$]),h+=j[$],$>15&&(Yt(e,h,B[v]>>5&127),h+=B[v]>>12)}}else X=Yr,T=te,U=Qr,R=Se;for(var v=0;v<u;++v){var V=n[v];if(V>255){var $=V>>18&31;Be(e,h,X[$+257]),h+=T[$+257],$>7&&(Yt(e,h,V>>23&31),h+=Xe[$]);var H=V&31;Be(e,h,U[H]),h+=R[H],H>3&&(Be(e,h,V>>5&8191),h+=Ze[H])}else Be(e,h,X[V]),h+=T[V]}return Be(e,h,X[256]),h+T[256]},ns=new An([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Si=new pt(0),is=function(r,e,t,n,i,s){var o=s.z||r.length,u=new pt(n+o+5*(1+Math.ceil(o/7e3))+i),a=u.subarray(n,u.length-i),l=s.l,h=(s.r||0)&7;if(e){h&&(a[0]=s.r>>3);for(var c=ns[e-1],f=c>>13,d=c&8191,p=(1<<t)-1,g=s.p||new Tt(32768),D=s.h||new Tt(p+1),S=Math.ceil(t/3),C=2*S,x=function(Pt){return(r[Pt]^r[Pt+1]<<S^r[Pt+2]<<C)&p},b=new An(25e3),m=new Tt(288),F=new Tt(32),w=0,v=0,O=s.i||0,j=0,_=s.w||0,L=0;O+2<o;++O){var z=x(O),I=O&32767,P=D[z];if(g[I]=P,D[z]=I,_<=O){var X=o-O;if((w>7e3||j>24576)&&(X>423||!l)){h=Ei(r,a,0,b,m,F,v,j,L,O-L,h),j=w=v=0,L=O;for(var T=0;T<286;++T)m[T]=0;for(var T=0;T<30;++T)F[T]=0}var U=2,R=0,k=d,N=I-P&32767;if(X>2&&z==x(O-N))for(var M=Math.min(f,X)-1,B=Math.min(32767,O),$=Math.min(258,X);N<=B&&--k&&I!=P;){if(r[O+U]==r[O+U-N]){for(var V=0;V<$&&r[O+V]==r[O+V-N];++V);if(V>U){if(U=V,R=N,V>M)break;for(var H=Math.min(N,V-2),Y=0,T=0;T<H;++T){var nt=O-N+T&32767,Zt=g[nt],Ot=nt-Zt&32767;Ot>Y&&(Y=Ot,P=nt)}}}I=P,P=g[I],N+=I-P&32767}if(R){b[j++]=268435456|Tn[U]<<18|Fi[R];var St=Tn[U]&31,At=Fi[R]&31;v+=Xe[St]+Ze[At],++m[257+St],++F[At],_=O+U,++w}else b[j++]=r[O],++m[r[O]]}}for(O=Math.max(O,_);O<o;++O)b[j++]=r[O],++m[r[O]];h=Ei(r,a,l,b,m,F,v,j,L,O-L,h),l||(s.r=h&7|a[h/8|0]<<3,h-=7,s.h=D,s.p=g,s.i=O,s.w=_)}else{for(var O=s.w||0;O<o+l;O+=65535){var ct=O+65535;ct>=o&&(a[h/8|0]=l,ct=o),h=bi(a,h+1,r.subarray(O,ct))}s.i=o}return wi(u,0,n+On(h)+i)},Bi=function(){var r=1,e=0;return{p:function(t){for(var n=r,i=e,s=t.length|0,o=0;o!=s;){for(var u=Math.min(o+2655,s);o<u;++o)i+=n+=t[o];n=(n&65535)+15*(n>>16),i=(i&65535)+15*(i>>16)}r=n,e=i},d:function(){return r%=65521,e%=65521,(r&255)<<24|(r&65280)<<8|(e&255)<<8|e>>8}}},rs=function(r,e,t,n,i){if(!i&&(i={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),o=new pt(s.length+r.length);o.set(s),o.set(r,s.length),r=o,i.w=s.length}return is(r,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+e.mem,t,n,i)},Mi=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8},ss=function(r,e){var t=e.level,n=t==0?0:t<6?1:t==9?3:2;if(r[0]=120,r[1]=n<<6|(e.dictionary&&32),r[1]|=31-(r[0]<<8|r[1])%31,e.dictionary){var i=Bi();i.p(e.dictionary),Mi(r,2,i.d())}},os=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&Ut(6,"invalid zlib data"),(r[1]>>5&1)==1&&Ut(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function us(r,e){e||(e={});var t=Bi();t.p(r);var n=rs(r,e,e.dictionary?6:2,4);return ss(n,e),Mi(n,n.length-4,t.d()),n}function as(r,e){return es(r.subarray(os(r),-4),{i:2},e,e)}var ls=typeof TextDecoder<"u"&&new TextDecoder,hs=0;try{ls.decode(Si,{stream:!0}),hs=1}catch{}const cs="modern-font";function Ae(r,e){if(!r)throw new Error(`[${cs}] ${e}`)}function fs(r){if("buffer"in r){const e=r.buffer;return r.byteOffset>0||r.byteLength<r.buffer.byteLength?e.slice(r.byteOffset,r.byteOffset+r.byteLength):e}else return r}function de(r){return"buffer"in r?new DataView(r.buffer,r.byteOffset,r.byteLength):new DataView(r)}function ps(r){let e="";for(let t=0,n=r.length,i;t<n;t++)i=r.charCodeAt(t),i!==0&&(e+=String.fromCharCode(i));return e}function Ye(r){r=ps(r);const e=[];for(let t=0,n=r.length,i;t<n;t++)i=r.charCodeAt(t),e.push(i>>8),e.push(i&255);return e}function ds(r){let e="";for(let t=0,n=r.length;t<n;t++)r[t]<127?e+=String.fromCharCode(r[t]):e+=`%${(256+r[t]).toString(16).slice(1)}`;return unescape(e)}function Ds(r){let e="";for(let t=0,n=r.length;t<n;t+=2)e+=String.fromCharCode((r[t]<<8)+r[t+1]);return e}var gs=Object.defineProperty,dt=(r,e,t,n)=>{for(var i=void 0,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(e,t,i)||i);return i&&gs(e,t,i),i};const Ke={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Dt(){return function(r,e){Object.defineProperty(r.constructor.prototype,e,{get(){if(typeof e=="string"){if(e.startsWith("read"))return(...t)=>this.read(e.substring(4).toLowerCase(),...t);if(e.startsWith("write"))return(...t)=>this.write(e.substring(5).toLowerCase(),...t)}},configurable:!0,enumerable:!0})}}class at extends DataView{constructor(t,n,i,s){super(fs(t),n,i);E(this,"cursor",0);this.littleEndian=s}readColumn(t){if(t.size){const n=Array.from({length:t.size},(i,s)=>this.read(t.type,t.offset+s));switch(t.type){case"char":return n.join("");default:return n}}else return this.read(t.type,t.offset)}writeColumn(t,n){t.size?Array.from({length:t.size},(i,s)=>{this.write(t.type,n[s],t.offset+s)}):this.write(t.type,n,t.offset)}read(t,n=this.cursor,i=this.littleEndian){var l;switch(t){case"char":return this.readChar(n);case"fixed":return this.readFixed(n,i);case"longDateTime":return this.readLongDateTime(n,i)}const s=`get${t.replace(/^\S/,h=>h.toUpperCase())}`,o=this,u=(l=o[s])==null?void 0:l.bind(o),a=u==null?void 0:u(n,i);return this.cursor+=Ke[t],a}readUint24(t=this.cursor){const[n,i,s]=this.readBytes(t,3);return(n<<16)+(i<<8)+s}readBytes(t,n){n==null&&(n=t,t=this.cursor);const i=[];for(let s=0;s<n;++s)i.push(this.getUint8(t+s));return this.cursor=t+n,i}readString(t,n){const i=this.readBytes(t,n);let s="";for(let o=0,u=i.length;o<u;o++)s+=String.fromCharCode(i[o]);return s}readFixed(t,n){const i=this.readInt32(t,n)/65536;return Math.ceil(i*1e5)/1e5}readLongDateTime(t=this.cursor,n){const i=this.readUint32(t+4,n),s=new Date;return s.setTime(i*1e3+-20775456e5),s}readChar(t){return this.readString(t,1)}write(t,n,i=this.cursor,s=this.littleEndian){var h;switch(t){case"char":return this.writeChar(n,i);case"fixed":return this.writeFixed(n,i);case"longDateTime":return this.writeLongDateTime(n,i)}const o=`set${t.replace(/^\S/,c=>c.toUpperCase())}`,u=this,a=(h=u[o])==null?void 0:h.bind(u),l=a==null?void 0:a(i,n,s);return this.cursor+=Ke[t.toLowerCase()],l}writeString(t="",n=this.cursor){const i=t.replace(/[^\x00-\xFF]/g,"11").length;this.seek(n);for(let s=0,o=t.length,u;s<o;++s)u=t.charCodeAt(s)||0,u>127?this.writeUint16(u):this.writeUint8(u);return this.cursor+=i,this}writeChar(t,n){return this.writeString(t,n)}writeFixed(t,n){return this.writeInt32(Math.round(t*65536),n),this}writeLongDateTime(t,n=this.cursor){typeof t>"u"?t=-20775456e5:typeof t.getTime=="function"?t=t.getTime():/^\d+$/.test(t)?t=+t:t=Date.parse(t);const s=Math.round((t- -20775456e5)/1e3);return this.writeUint32(0,n),this.writeUint32(s,n+4),this}writeBytes(t,n=this.cursor){let i;if(Array.isArray(t)){i=t.length;for(let s=0;s<i;++s)this.setUint8(n+s,t[s])}else{const s=de(t);i=s.byteLength;for(let o=0;o<i;++o)this.setUint8(n+o,s.getUint8(o))}return this.cursor=n+i,this}seek(t){return this.cursor=t,this}}dt([Dt()],at.prototype,"readInt8"),dt([Dt()],at.prototype,"readInt16"),dt([Dt()],at.prototype,"readInt32"),dt([Dt()],at.prototype,"readUint8"),dt([Dt()],at.prototype,"readUint16"),dt([Dt()],at.prototype,"readUint32"),dt([Dt()],at.prototype,"readFloat32"),dt([Dt()],at.prototype,"readFloat64"),dt([Dt()],at.prototype,"writeInt8"),dt([Dt()],at.prototype,"writeInt16"),dt([Dt()],at.prototype,"writeInt32"),dt([Dt()],at.prototype,"writeUint8"),dt([Dt()],at.prototype,"writeUint16"),dt([Dt()],at.prototype,"writeUint32"),dt([Dt()],at.prototype,"writeFloat32"),dt([Dt()],at.prototype,"writeFloat64");const Ai=new WeakMap;function y(r){const e=typeof r=="object"?r:{type:r},{size:t=1,type:n}=e;return(i,s)=>{if(typeof s!="string")return;let o=Ai.get(i);o||(o={columns:[],byteLength:0},Ai.set(i,o));const u={...e,name:s,byteLength:t*Ke[n],offset:e.offset??o.columns.reduce((a,l)=>a+l.byteLength,0)};o.columns.push(u),o.byteLength=o.columns.reduce((a,l)=>a+Ke[l.type]*(l.size??1),0),Object.defineProperty(i.constructor.prototype,s,{get(){return this.view.readColumn(u)},set(a){this.view.writeColumn(u,a)},configurable:!0,enumerable:!0})}}class _t{constructor(e,t,n,i){E(this,"view");this.view=new at(e,t,n,i)}}class Un extends _t{get buffer(){return this.view.buffer}toBuffer(){return this.view.buffer.slice(this.view.byteOffset,this.view.byteOffset+this.view.byteLength)}toBlob(){return new Blob([new Uint8Array(this.view.buffer,this.view.byteOffset,this.view.byteLength)],{type:this.mimeType})}toFontFace(e){return new FontFace(e,this.view.buffer)}}var ys=Object.defineProperty,Ft=(r,e,t,n)=>{for(var i=void 0,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(e,t,i)||i);return i&&ys(e,t,i),i};const wt=class Gr extends Un{constructor(){super(...arguments);E(this,"format","EmbeddedOpenType");E(this,"mimeType","application/vnd.ms-fontobject")}static from(t){const n=t.sfnt,s=n.name.names,o=Ye(s.fontFamily||""),u=o.length,a=Ye(s.fontStyle||""),l=a.length,h=Ye(s.version||""),c=h.length,f=Ye(s.fullName||""),d=f.length,p=86+u+4+l+4+c+4+d+2+t.view.byteLength,g=new Gr(new ArrayBuffer(p),0,p,!0);g.EOTSize=g.view.byteLength,g.FontDataSize=t.view.byteLength,g.Version=131073,g.Flags=0,g.Charset=1,g.MagicNumber=20556,g.Padding1=0,g.CheckSumAdjustment=n.head.checkSumAdjustment;const D=n.os2;return D&&(g.FontPANOSE=D.fontPANOSE,g.Italic=D.fsSelection,g.Weight=D.usWeightClass,g.fsType=D.fsType,g.UnicodeRange=D.ulUnicodeRange,g.CodePageRange=D.ulCodePageRange),g.view.writeUint16(u),g.view.writeBytes(o),g.view.writeUint16(0),g.view.writeUint16(l),g.view.writeBytes(a),g.view.writeUint16(0),g.view.writeUint16(c),g.view.writeBytes(h),g.view.writeUint16(0),g.view.writeUint16(d),g.view.writeBytes(f),g.view.writeUint16(0),g.view.writeUint16(0),g.view.writeBytes(t.view),g}};Ft([y("uint32")],wt.prototype,"EOTSize"),Ft([y("uint32")],wt.prototype,"FontDataSize"),Ft([y("uint32")],wt.prototype,"Version"),Ft([y("uint32")],wt.prototype,"Flags"),Ft([y({type:"uint8",size:10})],wt.prototype,"FontPANOSE"),Ft([y("uint8")],wt.prototype,"Charset"),Ft([y("uint8")],wt.prototype,"Italic"),Ft([y("uint32")],wt.prototype,"Weight"),Ft([y("uint16")],wt.prototype,"fsType"),Ft([y("uint16")],wt.prototype,"MagicNumber"),Ft([y({type:"uint8",size:16})],wt.prototype,"UnicodeRange"),Ft([y({type:"uint8",size:8})],wt.prototype,"CodePageRange"),Ft([y("uint32")],wt.prototype,"CheckSumAdjustment"),Ft([y({type:"uint8",size:16})],wt.prototype,"Reserved"),Ft([y("uint16")],wt.prototype,"Padding1");var ms=Object.defineProperty,Qe=(r,e,t,n)=>{for(var i=void 0,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(e,t,i)||i);return i&&ms(e,t,i),i};class Pe extends _t{constructor(e,t){super(e,t,16)}}Qe([y({type:"char",size:4})],Pe.prototype,"tag"),Qe([y("uint32")],Pe.prototype,"checkSum"),Qe([y("uint32")],Pe.prototype,"offset"),Qe([y("uint32")],Pe.prototype,"length");const Vn=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],xs=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"];class Pi{constructor(e){E(this,"index");E(this,"name");E(this,"isComposite",!1);E(this,"components",[]);E(this,"pathCommands",[]);const t={...e};if(this.index=t.index??0,t.name===".notdef"?t.unicode=void 0:t.name===".null"&&(t.unicode=0),t.unicode===0&&t.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=t.name??null,t.unicode&&(this.unicode=t.unicode),t.unicodes?this.unicodes=t.unicodes:t.unicode&&(this.unicodes=[t.unicode])}getPathCommands(e=0,t=0,n=72,i={},s){const o=1/((s==null?void 0:s.unitsPerEm)??1e3)*n,{xScale:u=o,yScale:a=o}=i,l=this.pathCommands,h=[];for(let c=0,f=l.length;c<f;c+=1){const d=l[c];d.type==="M"?h.push({type:"M",x:e+d.x*u,y:t+-d.y*a}):d.type==="L"?h.push({type:"L",x:e+d.x*u,y:t+-d.y*a}):d.type==="Q"?h.push({type:"Q",x1:e+d.x1*u,y1:t+-d.y1*a,x:e+d.x*u,y:t+-d.y*a}):d.type==="C"?h.push({type:"C",x1:e+d.x1*u,y1:t+-d.y1*a,x2:e+d.x2*u,y2:t+-d.y2*a,x:e+d.x*u,y:t+-d.y*a}):d.type==="Z"&&h.push({type:"Z"})}return h}}class vs extends Pi{parse(e,t,n){const i=this,{nominalWidthX:s,defaultWidthX:o,gsubrsBias:u,subrsBias:a}=e,l=e.topDict.paintType,h=this.index;let c,f,d,p;const g=[],D=[];let S=0,C=!1,x=!1,b=o,m=0,F=0;function w(I,P){g.push({type:"L",x:I,y:P})}function v(I,P,X,T,U,R){g.push({type:"C",x1:I,y1:P,x2:X,y2:T,x:U,y:R})}function O(I,P){x&&l!==2&&j(),x=!0,g.push({type:"M",x:I,y:P})}function j(){g.push({type:"Z"})}function _(I){g.push(...I)}function L(){D.length%2!==0&&!C&&(b=D.shift()+s),S+=D.length>>1,D.length=0,C=!0}function z(I){let P,X,T,U,R,k,N,M,B,$,V,H,Y=0;for(;Y<I.length;){let nt=I[Y++];switch(nt){case 1:L();break;case 3:L();break;case 4:D.length>1&&!C&&(b=D.shift()+s,C=!0),F+=D.pop(),O(m,F);break;case 5:for(;D.length>0;)m+=D.shift(),F+=D.shift(),w(m,F);break;case 6:for(;D.length>0&&(m+=D.shift(),w(m,F),D.length!==0);)F+=D.shift(),w(m,F);break;case 7:for(;D.length>0&&(F+=D.shift(),w(m,F),D.length!==0);)m+=D.shift(),w(m,F);break;case 8:for(;D.length>0;)c=m+D.shift(),f=F+D.shift(),d=c+D.shift(),p=f+D.shift(),m=d+D.shift(),F=p+D.shift(),v(c,f,d,p,m,F);break;case 10:R=D.pop()+a,k=e.subrs[R],k&&z(k);break;case 11:return;case 12:switch(nt=I[Y],Y+=1,nt){case 35:c=m+D.shift(),f=F+D.shift(),d=c+D.shift(),p=f+D.shift(),N=d+D.shift(),M=p+D.shift(),B=N+D.shift(),$=M+D.shift(),V=B+D.shift(),H=$+D.shift(),m=V+D.shift(),F=H+D.shift(),D.shift(),v(c,f,d,p,N,M),v(B,$,V,H,m,F);break;case 34:c=m+D.shift(),f=F,d=c+D.shift(),p=f+D.shift(),N=d+D.shift(),M=p,B=N+D.shift(),$=p,V=B+D.shift(),H=F,m=V+D.shift(),v(c,f,d,p,N,M),v(B,$,V,H,m,F);break;case 36:c=m+D.shift(),f=F+D.shift(),d=c+D.shift(),p=f+D.shift(),N=d+D.shift(),M=p,B=N+D.shift(),$=p,V=B+D.shift(),H=$+D.shift(),m=V+D.shift(),v(c,f,d,p,N,M),v(B,$,V,H,m,F);break;case 37:c=m+D.shift(),f=F+D.shift(),d=c+D.shift(),p=f+D.shift(),N=d+D.shift(),M=p+D.shift(),B=N+D.shift(),$=M+D.shift(),V=B+D.shift(),H=$+D.shift(),Math.abs(V-m)>Math.abs(H-F)?m=V+D.shift():F=H+D.shift(),v(c,f,d,p,N,M),v(B,$,V,H,m,F);break;default:console.warn(`Glyph ${h}: unknown operator ${1200+nt}`),D.length=0}break;case 14:if(D.length>=4){const Zt=Vn[D.pop()],Ot=Vn[D.pop()],St=D.pop(),At=D.pop();if(Zt&&Ot){i.isComposite=!0,i.components=[];const ct=e.charset.indexOf(Zt),Pt=e.charset.indexOf(Ot);i.components.push({glyphIndex:Pt,dx:0,dy:0}),i.components.push({glyphIndex:ct,dx:At,dy:St}),_(n.get(Pt).pathCommands);const Nt=JSON.parse(JSON.stringify(n.get(ct).pathCommands));for(let Rt=0;Rt<Nt.length;Rt+=1){const Lt=Nt[Rt];Lt.type!=="Z"&&(Lt.x+=At,Lt.y+=St),(Lt.type==="Q"||Lt.type==="C")&&(Lt.x1+=At,Lt.y1+=St),Lt.type==="C"&&(Lt.x2+=At,Lt.y2+=St)}_(Nt)}}else D.length>0&&!C&&(b=D.shift()+s,C=!0);x&&l!==2&&(j(),x=!1);break;case 18:L();break;case 19:case 20:L(),Y+=S+7>>3;break;case 21:D.length>2&&!C&&(b=D.shift()+s,C=!0),F+=D.pop(),m+=D.pop(),O(m,F);break;case 22:D.length>1&&!C&&(b=D.shift()+s,C=!0),m+=D.pop(),O(m,F);break;case 23:L();break;case 24:for(;D.length>2;)c=m+D.shift(),f=F+D.shift(),d=c+D.shift(),p=f+D.shift(),m=d+D.shift(),F=p+D.shift(),v(c,f,d,p,m,F);m+=D.shift(),F+=D.shift(),w(m,F);break;case 25:for(;D.length>6;)m+=D.shift(),F+=D.shift(),w(m,F);c=m+D.shift(),f=F+D.shift(),d=c+D.shift(),p=f+D.shift(),m=d+D.shift(),F=p+D.shift(),v(c,f,d,p,m,F);break;case 26:for(D.length%2&&(m+=D.shift());D.length>0;)c=m,f=F+D.shift(),d=c+D.shift(),p=f+D.shift(),m=d,F=p+D.shift(),v(c,f,d,p,m,F);break;case 27:for(D.length%2&&(F+=D.shift());D.length>0;)c=m+D.shift(),f=F,d=c+D.shift(),p=f+D.shift(),m=d+D.shift(),F=p,v(c,f,d,p,m,F);break;case 28:P=I[Y],X=I[Y+1],D.push((P<<24|X<<16)>>16),Y+=2;break;case 29:R=D.pop()+u,k=e.gsubrs[R],k&&z(k);break;case 30:for(;D.length>0&&(c=m,f=F+D.shift(),d=c+D.shift(),p=f+D.shift(),m=d+D.shift(),F=p+(D.length===1?D.shift():0),v(c,f,d,p,m,F),D.length!==0);)c=m+D.shift(),f=F,d=c+D.shift(),p=f+D.shift(),F=p+D.shift(),m=d+(D.length===1?D.shift():0),v(c,f,d,p,m,F);break;case 31:for(;D.length>0&&(c=m+D.shift(),f=F,d=c+D.shift(),p=f+D.shift(),F=p+D.shift(),m=d+(D.length===1?D.shift():0),v(c,f,d,p,m,F),D.length!==0);)c=m,f=F+D.shift(),d=c+D.shift(),p=f+D.shift(),m=d+D.shift(),F=p+(D.length===1?D.shift():0),v(c,f,d,p,m,F);break;default:nt<32?console.warn(`Glyph ${h}: unknown operator ${nt}`):nt<247?D.push(nt-139):nt<251?(P=I[Y],Y+=1,D.push((nt-247)*256+P+108)):nt<255?(P=I[Y],Y+=1,D.push(-(nt-251)*256-P-108)):(P=I[Y],X=I[Y+1],T=I[Y+2],U=I[Y+3],Y+=4,D.push((P<<24|X<<16|T<<8|U)/65536))}}}z(t),this.pathCommands=g,C&&(this.advanceWidth=b)}}class Ti{constructor(e){E(this,"_items",[]);this._sfnt=e}get(e){const t=this._items[e];let n;if(t)n=t;else{n=this._get(e);const i=this._sfnt.hmtx.metrics[e];i&&(n.advanceWidth=n.advanceWidth||i.advanceWidth,n.leftSideBearing=n.leftSideBearing||i.leftSideBearing);const s=this._sfnt.cmap.glyphIndexToUnicodesMap.get(e);s&&(n.unicode??(n.unicode=s[0]),n.unicodes??(n.unicodes=s)),this._items[e]=n}return n}}class Fs extends Ti{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(e){const t=this._sfnt.cff,n=new vs({index:e});return n.parse(t,t.charStringsIndex.get(e),this),n.name=t.charset[e],n}}var ws=Object.defineProperty,ki=(r,e,t,n)=>{for(var i=void 0,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(e,t,i)||i);return i&&ws(e,t,i),i};class Je extends _t{constructor(t,n,i,s){super(t,n,i,s);E(this,"_offsets");E(this,"_objects");this._init()}get offsets(){return this._offsets??(this._offsets=this.readOffsets())}get objects(){return this._objects??(this._objects=this.readObjects())}_init(){const t=this.view,n=this.count,i=this.offsetSize;this.objectOffset=(n+1)*i+2,this.endOffset=t.byteOffset+this.objectOffset+this.offsets[n]}readOffsets(){const t=this.view,n=this.count,i=this.offsetSize;t.seek(3);const s=[];for(let o=0,u=n+1;o<u;o++){const a=this.view;let l=0;for(let h=0;h<i;h++)l<<=8,l+=a.readUint8();s.push(l)}return s}readObjects(){const t=[];for(let n=0,i=this.count;n<i;n++)t.push(this.get(n));return t}get(t){const n=this.offsets,i=this.objectOffset,s=i+n[t],u=i+n[t+1]-s;return this._isString?this.view.readString(s,u):this.view.readBytes(s,u)}}ki([y("uint16")],Je.prototype,"count"),ki([y("uint8")],Je.prototype,"offsetSize");class tn extends Je{constructor(){super(...arguments);E(this,"_isString",!1)}}class _i extends Je{constructor(){super(...arguments);E(this,"_isString",!0)}}const Cs=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],bs=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],Es=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Ss=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"];function en(r,e){return e<=390?Cs[e]:r[e-391]}function J(r,e="number",t){return(n,i)=>{if(typeof i!="string")return;const s={type:e,operator:r,default:t??e==="number"?0:void 0};Object.defineProperty(n.constructor.prototype,i,{get(){return this._getProp(s)},set(o){this._setProp(s,o)},configurable:!0,enumerable:!0})}}class Ii extends _t{constructor(){super(...arguments);E(this,"_dict");E(this,"_stringIndex")}get dict(){return this._dict??(this._dict=this._readDict())}setStringIndex(t){return this._stringIndex=t,this}_readFloatOperand(){const t=this.view;let n="";const i=15,s=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const o=t.readUint8(),u=o>>4,a=o&15;if(u===i||(n+=s[u],a===i))break;n+=s[a]}return Number.parseFloat(n)}_readOperand(t){const n=this.view;let i,s,o,u;if(t===28)return i=n.readUint8(),s=n.readUint8(),i<<8|s;if(t===29)return i=n.readUint8(),s=n.readUint8(),o=n.readUint8(),u=n.readUint8(),i<<24|s<<16|o<<8|u;if(t===30)return this._readFloatOperand();if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return i=n.readUint8(),(t-247)*256+i+108;if(t>=251&&t<=254)return i=n.readUint8(),-(t-251)*256-i-108;throw new Error(`invalid b0 ${t}, at: ${n.cursor}`)}_readDict(){const t=this.view;t.seek(0);let n=[];const i=t.cursor+t.byteLength,s={};for(;t.cursor<i;){let o=t.readUint8();o<=21?(o===12&&(o=1200+t.readUint8()),s[o]=n,n=[]):n.push(this._readOperand(o))}return s}_getProp(t){var i;const n=this.dict[t.operator]??t.default;switch(t.type){case"number":return n[0];case"string":return en(((i=this._stringIndex)==null?void 0:i.objects)??[],n[0]);case"number[]":return n}return n}_setProp(t,n){}}var Bs=Object.defineProperty,zn=(r,e,t,n)=>{for(var i=void 0,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(e,t,i)||i);return i&&Bs(e,t,i),i};class nn extends Ii{}zn([J(19)],nn.prototype,"subrs"),zn([J(20)],nn.prototype,"defaultWidthX"),zn([J(21)],nn.prototype,"nominalWidthX");var Ms=Object.defineProperty,it=(r,e,t,n)=>{for(var i=void 0,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(e,t,i)||i);return i&&Ms(e,t,i),i};class et extends Ii{}it([J(0,"string")],et.prototype,"version"),it([J(1,"string")],et.prototype,"notice"),it([J(1200,"string")],et.prototype,"copyright"),it([J(2,"string")],et.prototype,"fullName"),it([J(3,"string")],et.prototype,"familyName"),it([J(4,"string")],et.prototype,"weight"),it([J(1201)],et.prototype,"isFixedPitch"),it([J(1202)],et.prototype,"italicAngle"),it([J(1203,"number",-100)],et.prototype,"underlinePosition"),it([J(1204,"number",50)],et.prototype,"underlineThickness"),it([J(1205)],et.prototype,"paintType"),it([J(1206,"number",2)],et.prototype,"charstringType"),it([J(1207,"number[]",[.001,0,0,.001,0,0])],et.prototype,"fontMatrix"),it([J(13)],et.prototype,"uniqueId"),it([J(5,"number[]",[0,0,0,0])],et.prototype,"fontBBox"),it([J(1208)],et.prototype,"strokeWidth"),it([J(14)],et.prototype,"xuid"),it([J(15)],et.prototype,"charset"),it([J(16)],et.prototype,"encoding"),it([J(17)],et.prototype,"charStrings"),it([J(18,"number[]",[0,0])],et.prototype,"private");function gt(r,e=r){return t=>{De.tableDefinitions.set(r,{tag:r,prop:e,class:t}),Object.defineProperty(De.prototype,e,{get(){return this.get(r)},set(n){return this.set(r,n)},configurable:!0,enumerable:!0})}}const pe=class pe{constructor(e){E(this,"tables",new Map);E(this,"tableViews",new Map);(e instanceof Map?e:new Map(Object.entries(e))).forEach((n,i)=>{this.tableViews.set(i,new DataView(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)))})}get hasGlyf(){return this.tableViews.has("glyf")}get names(){return this.name.names}get unitsPerEm(){return this.head.unitsPerEm}get ascender(){return this.hhea.ascent}get descender(){return this.hhea.descent}get createdTimestamp(){return this.head.created}get modifiedTimestamp(){return this.head.modified}get numGlyphs(){return this.maxp.numGlyphs}get unicodes(){return this.cmap.glyphIndexToUnicodesMap}get glyphs(){return this.hasGlyf?this.glyf.glyphs:this.cff.glyphs}charToGlyphIndex(e){let t=this.cmap.unicodeToGlyphIndexMap.get(e.codePointAt(0));if(t===void 0&&!this.hasGlyf){const{encoding:n,charset:i}=this.cff;t=i.indexOf(n[e.codePointAt(0)])}return t??0}charToGlyph(e){return this.glyphs.get(this.charToGlyphIndex(e))}textToGlyphIndexes(e){const t=[];for(const n of e)t.push(this.charToGlyphIndex(n));return t}textToGlyphs(e){const t=this.glyphs,n=this.textToGlyphIndexes(e),i=n.length,s=Array.from({length:i}),o=t.get(0);for(let u=0;u<i;u+=1)s[u]=t.get(n[u])||o;return s}getPathCommands(e,t,n,i,s){const o=[];return this.forEachGlyph(e,t,n,i,s,(u,a,l,h,c)=>{o.push(...u.getPathCommands(a,l,h,c,this))}),o}getAdvanceWidth(e,t,n){return this.forEachGlyph(e,0,0,t,n,()=>{})}forEachGlyph(e,t=0,n=0,i=72,s={},o){const u=1/this.unitsPerEm*i,a=this.textToGlyphs(e);for(let l=0;l<a.length;l+=1){const h=a[l];o.call(this,h,t,n,i,s),h.advanceWidth&&(t+=h.advanceWidth*u),s.letterSpacing?t+=s.letterSpacing*i:s.tracking&&(t+=s.tracking/1e3*i)}return t}clone(){return new pe(this.tableViews)}delete(e){const t=pe.tableDefinitions.get(e);return t?(this.tableViews.delete(e),this.tables.delete(t.prop),this):this}set(e,t){const n=pe.tableDefinitions.get(e);return n&&this.tables.set(n.prop,t),this.tableViews.set(e,t.view),this}get(e){const t=pe.tableDefinitions.get(e);if(!t)return;let n=this.tables.get(t.prop);if(!n){const i=t.class;if(i){const s=this.tableViews.get(e);if(!s)return;n=new i(s.buffer,s.byteOffset,s.byteLength).setSFNT(this),this.tables.set(t.prop,n)}}return n}};E(pe,"tableDefinitions",new Map);let De=pe;class yt extends _t{setSFNT(e){return this._sfnt=e,this}getSFNT(){return this._sfnt}}var As=Object.defineProperty,Ps=Object.getOwnPropertyDescriptor,Te=(r,e,t,n)=>{for(var i=n>1?void 0:n?Ps(e,t):e,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&As(e,t,i),i};let ge=class extends yt{constructor(e,t,n,i){super(e,t,n,i);E(this,"_glyphs");E(this,"privateDict");E(this,"subrsIndex");this._init()}get glyphs(){return this._glyphs??(this._glyphs=new Fs(this._sfnt))}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}get defaultWidthX(){var e;return((e=this.privateDict)==null?void 0:e.defaultWidthX)??0}get nominalWidthX(){var e;return((e=this.privateDict)==null?void 0:e.nominalWidthX)??0}get subrs(){var e;return((e=this.subrsIndex)==null?void 0:e.objects)??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}_init(){const e=this.view,{buffer:t,byteOffset:n}=e,i=n+4;this.nameIndex=new _i(t,i),this.topDictIndex=new tn(t,this.nameIndex.endOffset),this.stringIndex=new _i(t,this.topDictIndex.endOffset),this.globalSubrIndex=new tn(t,this.stringIndex.endOffset),this.topDict=new et(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);const s=this.topDict.private[0],o=this.topDict.private[1];s&&(this.privateDict=new nn(t,n+o,s).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new tn(t,n+o+this.privateDict.subrs))),this.charStringsIndex=new tn(t,n+this.topDict.charStrings);const u=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=bs:this.topDict.charset===1?this.charset=Es:this.topDict.charset===2?this.charset=Ss:this.charset=this._readCharset(n+this.topDict.charset,u,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=Vn:this.topDict.encoding===1?this.encoding=xs:this.encoding=this._readEncoding(n+this.topDict.encoding)}_readCharset(e,t,n){const i=this.view;i.seek(e);let s,o,u;t-=1;const a=[".notdef"],l=i.readUint8();if(l===0)for(s=0;s<t;s+=1)o=i.readUint16(),a.push(en(n,o));else if(l===1)for(;a.length<=t;)for(o=i.readUint16(),u=i.readUint8(),s=0;s<=u;s+=1)a.push(en(n,o)),o+=1;else if(l===2)for(;a.length<=t;)for(o=i.readUint16(),u=i.readUint16(),s=0;s<=u;s+=1)a.push(en(n,o)),o+=1;else throw new Error(`Unknown charset format ${l}`);return a}_readEncoding(e){const t=this.view;t.seek(e);let n,i;const s={},o=t.readUint8();if(o===0){const u=t.readUint8();for(n=0;n<u;n+=1)i=t.readUint8(),s[i]=n}else if(o===1){const u=t.readUint8();for(i=1,n=0;n<u;n+=1){const a=t.readUint8(),l=t.readUint8();for(let h=a;h<=a+l;h+=1)s[h]=i,i+=1}}else console.warn(`unknown encoding format:${o}`);return s}_calcSubroutineBias(e){let t;return e.length<1240?t=107:e.length<33900?t=1131:t=32768,t}};Te([y("uint8")],ge.prototype,"majorVersion",2),Te([y("uint8")],ge.prototype,"minorVersion",2),Te([y("uint8")],ge.prototype,"headerSize",2),Te([y("uint8")],ge.prototype,"offsetSize",2),ge=Te([gt("CFF ","cff")],ge);var Ts=Object.defineProperty,rn=(r,e,t,n)=>{for(var i=void 0,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(e,t,i)||i);return i&&Ts(e,t,i),i};const ke=class qr extends _t{constructor(e=new ArrayBuffer(262),t){super(e,t,262)}static from(e){const t=new qr;return t.format=0,t.length=t.view.byteLength,t.language=0,e.forEach((n,i)=>{i<256&&n<256&&t.view.writeUint8(n,6+i)}),t}getUnicodeToGlyphIndexMap(){const e=new Map;return this.glyphIndexArray.forEach((t,n)=>{e.set(n,t)}),e}};rn([y("uint16")],ke.prototype,"format"),rn([y("uint16")],ke.prototype,"length"),rn([y("uint16")],ke.prototype,"language"),rn([y({type:"uint8",size:256})],ke.prototype,"glyphIndexArray");let Oi=ke;var ks=Object.defineProperty,Nn=(r,e,t,n)=>{for(var i=void 0,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(e,t,i)||i);return i&&ks(e,t,i),i};class sn extends _t{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((e,t)=>Math.max(e,t),0)}get subHeaders(){const e=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:e},(t,n)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(e-n)*8-2)/2}))}get glyphIndexArray(){const e=this.maxSubHeaderKey,t=6+256*2+e*8;this.view.seek(t);const n=(this.view.byteLength-t)/2;return Array.from(