modern-text 2.0.6 → 2.0.8

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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const modernPath2d = require('modern-path2d');
4
- const deformation = require('../shared/modern-text.B2xfrqDc.cjs');
4
+ const deformation = require('../shared/modern-text.DQWdaYoZ.cjs');
5
5
  const curves = require('../shared/modern-text.MC5bIC9E.cjs');
6
6
  require('modern-idoc');
7
7
 
@@ -1,5 +1,5 @@
1
1
  import { Vector2 } from 'modern-path2d';
2
- import { d as defineDeformation } from '../shared/modern-text.JF1ny7A-.mjs';
2
+ import { d as defineDeformation } from '../shared/modern-text.K8BlyK2j.mjs';
3
3
  import { H as HeartCurve, R as RectangularCurve, E as EllipseCurve, C as CircleCurve, P as PolygonCurve } from '../shared/modern-text.fT17R5HY.mjs';
4
4
  import 'modern-idoc';
5
5
 
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const Text = require('./shared/modern-text.BMeLbf5d.cjs');
4
- const deformation = require('./shared/modern-text.B2xfrqDc.cjs');
3
+ const Text = require('./shared/modern-text.CKFvdNej.cjs');
4
+ const deformation = require('./shared/modern-text.DQWdaYoZ.cjs');
5
5
  const curves = require('./shared/modern-text.MC5bIC9E.cjs');
6
6
  require('modern-font');
7
7
  require('modern-idoc');
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ ${this.paths.map(e=>e.toSvgPathString()).join(``)}
30
30
  </svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),`image/svg+xml`).documentElement}toCanvas(e={}){let{pixelRatio:t=2,...n}=e,{left:r,top:i,width:a,height:o}=this.getBoundingBox(),s=document.createElement(`canvas`);s.width=a*t,s.height=o*t,s.style.width=`${a}px`,s.style.height=`${o}px`;let c=s.getContext(`2d`);return c&&(c.scale(t,t),c.translate(-r,-i),this.paths.forEach(e=>{e.drawTo(c,n)})),s}};function Kr(){let e=new Map;async function t(t){if(!e.has(t)){e.set(t,``);try{e.set(t,await fetch(t).then(e=>e.text()))}catch(n){console.warn(n),e.delete(t)}}}function n(e){return e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`blob://`)}return{loaded:e,needsLoad:n,load:t}}function qr(e){let t=new Map;function n(n){let r=t.get(n);if(!r){let i=e.needsLoad(n)?e.loaded.get(n):n;if(i){let e=tr(i);r={dom:e,pathSet:br(e)},t.set(n,r)}else{let e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);e.setAttribute(`width`,`0`),e.setAttribute(`height`,`0`),e.setAttribute(`viewBox`,`0 0 0 0`),r={dom:e,pathSet:new Gr}}}return r}return{parsed:t,parse:n}}function Jr(e,t){let{transform:n,transformOrigin:r}=t,{fontSize:i,lineBox:a}=e,{left:o,top:s,width:c,height:l}=a,{x:u,y:d}=Yr(r??`center`,o,s,c,l),f=new Un;return n&&(f.translate(u,d),f.prependCssTransform(n,{width:i,height:i}),f.translate(-u,-d)),f}function Yr(e,t,n,r,i){let a={left:0,center:.5,right:1},o={top:0,center:.5,bottom:1},s=e.trim().split(/\s+/),c=s[0]??`center`,l=s[1]??`center`,u;u=c in a?t+a[c]*r:c.endsWith(`%`)?t+Number.parseFloat(c)/100*r:t+Number.parseFloat(c);let d;return d=l in o?n+o[l]*i:l.endsWith(`%`)?n+Number.parseFloat(l)/100*i:n+Number.parseFloat(l),{x:u,y:d}}function Xr(e,t){return typeof e==`number`?e:e.endsWith(`%`)?(e=e.substring(0,e.length-1),Math.ceil(Number(e)/100*t.total)):e.endsWith(`rem`)?(e=e.substring(0,e.length-3),Number(e)*t.fontSize):e.endsWith(`em`)?(e=e.substring(0,e.length-2),Number(e)*t.fontSize):Number(e)}function Zr(e){return O(e)?{}:e}function Qr(e,t){let n=Object.keys(e),r=Object.keys(t);return Array.from(new Set([...n,...r])).every(n=>$r(e[n],t[n]))}function $r(e,t){let n=typeof e;return n===typeof t?n&&n===`object`?Qr(e,t):e===t:!1}var ei=class{text;context;pixelRatio=window?.devicePixelRatio||1;constructor(e,t){this.text=e,this.context=t}_setupView=()=>{let e=this.pixelRatio,t=this.context,{left:n,top:r,width:i,height:a}=this.text.boundingBox,o=t.canvas;o.dataset.viewBox=String(`${n} ${r} ${i} ${a}`),o.dataset.pixelRatio=String(e);let s=i,c=a;o.width=Math.max(1,Math.ceil(s*e)),o.height=Math.max(1,Math.ceil(c*e)),o.style.width=`${s}px`,o.style.height=`${c}px`,t.clearRect(0,0,o.width,o.height),t.scale(e,e),t.translate(-n,-r)};_setupColors=()=>{this.uploadColor(this.text.glyphBox,{style:this.text.computedStyle,fill:this.text.computedFill,outline:this.text.computedOutline}),this.text.paragraphs.forEach(e=>{this.uploadColor(e.lineBox,{style:e.computedStyle,fill:e.computedFill,outline:e.computedOutline}),e.fragments.forEach(e=>{this.uploadColor(e.inlineBox,{style:e.computedStyle,fill:e.computedFill,outline:e.computedOutline})})})};setup=()=>(this._setupView(),this._setupColors(),this);_parseColor=(e,t)=>{if(typeof e==`string`&&ye(e)&&(e=be(e)[0]),typeof e==`object`&&`type`in e)switch(e.type){case`linear-gradient`:{let{left:n,top:r,width:i,height:a}=t,{angle:o=0,stops:s}=e;if(![n,r,i,a,o].every(Number.isFinite))return s?.find(e=>e?.color)?.color??`transparent`;let c=n+i/2,l=r+a/2,u=(o+90)*Math.PI/180,d=Math.sin(u),f=-Math.cos(u),p=Math.abs(i*Math.sin(u))+Math.abs(a*Math.cos(u)),m=c-p/2*d,h=l-p/2*f,g=c+p/2*d,_=l+p/2*f,v=this.context.createLinearGradient(m,h,g,_);for(let e of s){let t=Number.isFinite(e.offset)?Math.min(1,Math.max(0,e.offset)):0;try{v.addColorStop(t,e.color)}catch{}}return v}case`radial-gradient`:break}return e};_uploadedStyles=[`color`,`backgroundColor`,`textStrokeColor`];uploadColor=(e,t)=>{let{style:n,fill:r,outline:i}=t;n&&this._uploadedStyles.forEach(t=>{n[t]=this._parseColor(n[t],e)}),r?.enabled&&r.linearGradient&&(r._linearGradient=this._parseColor({type:`linear-gradient`,...r.linearGradient},e)),i?.enabled&&i.linearGradient&&(i._linearGradient=this._parseColor({type:`linear-gradient`,...i.linearGradient},e))};_mergePathStyle(e,t){let n=e.style,r=t.stroke??n.stroke,i=t.strokeWidth?t.strokeWidth:n.strokeWidth;return{...j(n),...j(t),stroke:i===void 0||i>0?r:void 0,strokeLinecap:t.strokeLinecap??n.strokeLinecap??`round`,strokeLinejoin:t.strokeLinejoin??n.strokeLinejoin??`round`,strokeWidth:i}}drawPath=(e,t={})=>{let{clipRect:n,...r}=t,i=this.context;i.save(),i.beginPath(),n&&(i.rect(n.left,n.top,n.width,n.height),i.clip(),i.beginPath()),e.drawTo(i,this._mergePathStyle(e,r)),i.restore()};effectToPathStyle(e){let t=this.text.computedStyle.fontSize,n={};return e.fill?.enabled&&(n={...n,fill:e.fill.color}),e.outline?.enabled&&(n={...n,stroke:e.outline.color,strokeWidth:(e.outline.width??0)*t}),e.shadow?.enabled&&(n={...n,shadowOffsetX:(e.shadow.offsetX??0)*t,shadowOffsetY:(e.shadow.offsetY??0)*t,shadowBlur:(e.shadow.blur??0)*t,shadowColor:e.shadow.color}),n}transformEffect(e){let{a:t,b:n,c:r,d:i,tx:a,ty:o}=Jr(this.text,e);this.context.transform(t,n,r,i,a,o)}_shadowCanvas;_shadowCtx;drawWithShadow=(e,t)=>{let n=this.context,r=n.canvas;this._shadowCanvas||(this._shadowCanvas=document.createElement(`canvas`),this._shadowCtx=this._shadowCanvas.getContext(`2d`));let i=this._shadowCanvas,a=this._shadowCtx;if(!a){t();return}i.width<r.width&&(i.width=r.width),i.height<r.height&&(i.height=r.height),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,r.width,r.height);let o=n.getTransform();a.setTransform(o.a,o.b,o.c,o.d,o.e,o.f);let s=this.context;this.context=a;try{t()}finally{this.context=s}let c=this.text.computedStyle.fontSize,l=this.pixelRatio;n.save(),n.setTransform(1,0,0,1,0,0),n.shadowOffsetX=(e.offsetX??0)*c*l,n.shadowOffsetY=(e.offsetY??0)*c*l,n.shadowBlur=(e.blur??0)*c*l,n.shadowColor=e.color,n.drawImage(i,0,0,r.width,r.height,0,0,r.width,r.height),n.restore()};drawCharacter=(e,t={})=>{let n=this.context,{computedStyle:r,path:i,glyphBox:a,isVertical:o,content:s,inlineBox:c,baseline:l,computedFill:u,computedOutline:d}=e,f=u?.enabled?u:void 0,p=d?.enabled?d:void 0,m=this.effectToPathStyle(t),h={strokeLinecap:p?.lineCap,strokeLinejoin:p?.lineJoin,...r,...m,fill:m.fill??f?._linearGradient??f?.color??r.color,strokeWidth:m.strokeWidth??p?.width??r.textStrokeWidth,stroke:m.stroke??p?._linearGradient??p?.color??r.textStrokeColor};a?this.drawPath(i,h):(n.save(),n.beginPath(),qt(n,this._mergePathStyle(i,h)),n.font=`${r.fontSize}px ${r.fontFamily||this.text.defaultFamily}`,o?(n.textBaseline=`middle`,n.fillText(s,c.left,c.top+c.height/2)):(n.textBaseline=`alphabetic`,n.fillText(s,c.left,c.top+l)),n.restore())}},ti={},ni=(function(e,t,n,r,i){var a=new Worker(ti[t]||(ti[t]=URL.createObjectURL(new Blob([e+`;addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})`],{type:`text/javascript`}))));return a.onmessage=function(e){var t=e.data,n=t.$e$;if(n){var r=Error(n[0]);r.code=n[1],r.stack=n[2],i(r,null)}else i(null,t)},a.postMessage(n,r),a}),ri=Uint8Array,ii=Uint16Array,ai=Int32Array,oi=new ri([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]),si=new ri([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]),ci=new ri([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),li=function(e,t){for(var n=new ii(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new ai(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},ui=li(oi,2),di=ui.b,fi=ui.r;di[28]=258,fi[258]=28;for(var pi=li(si,0),mi=pi.b,hi=pi.r,gi=new ii(32768),q=0;q<32768;++q){var _i=(q&43690)>>1|(q&21845)<<1;_i=(_i&52428)>>2|(_i&13107)<<2,_i=(_i&61680)>>4|(_i&3855)<<4,gi[q]=((_i&65280)>>8|(_i&255)<<8)>>1}for(var vi=(function(e,t,n){for(var r=e.length,i=0,a=new ii(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new ii(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new ii(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[gi[d]>>c]=l}else for(s=new ii(r),i=0;i<r;++i)e[i]&&(s[i]=gi[o[e[i]-1]++]>>15-e[i]);return s}),yi=new ri(288),q=0;q<144;++q)yi[q]=8;for(var q=144;q<256;++q)yi[q]=9;for(var q=256;q<280;++q)yi[q]=7;for(var q=280;q<288;++q)yi[q]=8;for(var bi=new ri(32),q=0;q<32;++q)bi[q]=5;var xi=vi(yi,9,0),Si=vi(yi,9,1),Ci=vi(bi,5,0),wi=vi(bi,5,1),Ti=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Ei=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Di=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Oi=function(e){return(e+7)/8|0},ki=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new ri(e.subarray(t,n))},Ai=[`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`],ji=function(e,t,n){var r=Error(t||Ai[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,ji),!n)throw r;return r},Mi=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new ri(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new ri(i*3));var l=function(e){var t=n.length;if(e>t){var r=new ri(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=Ei(e,d,1);var v=Ei(e,d+1,3);if(d+=3,!v){var y=Oi(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&ji(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}else if(v==1)p=Si,m=wi,h=9,g=5;else if(v==2){var S=Ei(e,d,31)+257,C=Ei(e,d+10,15)+4,w=S+Ei(e,d+5,31)+1;d+=14;for(var T=new ri(w),E=new ri(19),D=0;D<C;++D)E[ci[D]]=Ei(e,d+D*3,7);d+=C*3;for(var O=Ti(E),k=(1<<O)-1,A=vi(E,O,1),D=0;D<w;){var j=A[Ei(e,d,k)];d+=j&15;var y=j>>4;if(y<16)T[D++]=y;else{var M=0,N=0;for(y==16?(N=3+Ei(e,d,3),d+=2,M=T[D-1]):y==17?(N=3+Ei(e,d,7),d+=3):y==18&&(N=11+Ei(e,d,127),d+=7);N--;)T[D++]=M}}var P=T.subarray(0,S),F=T.subarray(S);h=Ti(P),g=Ti(F),p=vi(P,h,1),m=vi(F,g,1)}else ji(1);if(d>_){c&&ji(0);break}}s&&l(f+131072);for(var I=(1<<h)-1,L=(1<<g)-1,R=d;;R=d){var M=p[Di(e,d)&I],z=M>>4;if(d+=M&15,d>_){c&&ji(0);break}if(M||ji(2),z<256)n[f++]=z;else if(z==256){R=d,p=null;break}else{var B=z-254;if(z>264){var D=z-257,V=oi[D];B=Ei(e,d,(1<<V)-1)+di[D],d+=V}var ee=m[Di(e,d)&L],te=ee>>4;ee||ji(3),d+=ee&15;var F=mi[te];if(te>3){var V=si[te];F+=Di(e,d)&(1<<V)-1,d+=V}if(d>_){c&&ji(0);break}s&&l(f+131072);var ne=f+B;if(f<F){var re=a-F,ie=Math.min(F,ne);for(re+f<0&&ji(3);f<ie;++f)n[f]=r[re+f]}for(;f<ne;++f)n[f]=n[f-F]}}t.l=p,t.p=R,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?ki(n,0,f):n.subarray(0,f)},Ni=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},Pi=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},Fi=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:Hi,l:0};if(i==1){var o=new ri(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<i;++r)a[r].s>f&&(f=a[r].s);var p=new ii(f+1),m=Ii(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var v=a[r].s;if(p[v]>t)h+=_-(1<<m-p[v]),p[v]=t;else break}for(h>>=g;h>0;){var y=a[r].s;p[y]<t?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new ri(p),l:m}},Ii=function(e,t,n){return e.s==-1?Math.max(Ii(e.l,t,n+1),Ii(e.r,t,n+1)):t[e.s]=n},Li=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new ii(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},Ri=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},zi=function(e,t,n){var r=n.length,i=Oi(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},Bi=function(e,t,n,r,i,a,o,s,c,l,u){Ni(t,u++,n),++i[256];for(var d=Fi(i,15),f=d.t,p=d.l,m=Fi(a,15),h=m.t,g=m.l,_=Li(f),v=_.c,y=_.n,b=Li(h),x=b.c,S=b.n,C=new ii(19),w=0;w<v.length;++w)++C[v[w]&31];for(var w=0;w<x.length;++w)++C[x[w]&31];for(var T=Fi(C,7),E=T.t,D=T.l,O=19;O>4&&!E[ci[O-1]];--O);var k=l+5<<3,A=Ri(i,yi)+Ri(a,bi)+o,j=Ri(i,f)+Ri(a,h)+o+14+3*O+Ri(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&k<=A&&k<=j)return zi(t,u,e.subarray(c,c+l));var M,N,P,F;if(Ni(t,u,1+(j<A)),u+=2,j<A){M=vi(f,p,0),N=f,P=vi(h,g,0),F=h;var I=vi(E,D,0);Ni(t,u,y-257),Ni(t,u+5,S-1),Ni(t,u+10,O-4),u+=14;for(var w=0;w<O;++w)Ni(t,u+3*w,E[ci[w]]);u+=3*O;for(var L=[v,x],R=0;R<2;++R)for(var z=L[R],w=0;w<z.length;++w){var B=z[w]&31;Ni(t,u,I[B]),u+=E[B],B>15&&(Ni(t,u,z[w]>>5&127),u+=z[w]>>12)}}else M=xi,N=yi,P=Ci,F=bi;for(var w=0;w<s;++w){var V=r[w];if(V>255){var B=V>>18&31;Pi(t,u,M[B+257]),u+=N[B+257],B>7&&(Ni(t,u,V>>23&31),u+=oi[B]);var ee=V&31;Pi(t,u,P[ee]),u+=F[ee],ee>3&&(Pi(t,u,V>>5&8191),u+=si[ee])}else Pi(t,u,M[V]),u+=N[V]}return Pi(t,u,M[256]),u+N[256]},Vi=new ai([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Hi=new ri(0),Ui=function(e,t,n,r,i,a){var o=a.z||e.length,s=new ri(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=Vi[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new ii(32768),g=a.h||new ii(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new ai(25e3),x=new ii(288),S=new ii(32),C=0,w=0,T=a.i||0,E=0,D=a.w||0,O=0;T+2<o;++T){var k=y(T),A=T&32767,j=g[k];if(h[A]=j,g[k]=A,D<=T){var M=o-T;if((C>7e3||E>24576)&&(M>423||!l)){u=Bi(e,c,0,b,x,S,w,E,O,T-O,u),E=C=w=0,O=T;for(var N=0;N<286;++N)x[N]=0;for(var N=0;N<30;++N)S[N]=0}var P=2,F=0,I=p,L=A-j&32767;if(M>2&&k==y(T-L))for(var R=Math.min(f,M)-1,z=Math.min(32767,T),B=Math.min(258,M);L<=z&&--I&&A!=j;){if(e[T+P]==e[T+P-L]){for(var V=0;V<B&&e[T+V]==e[T+V-L];++V);if(V>P){if(P=V,F=L,V>R)break;for(var ee=Math.min(L,V-2),te=0,N=0;N<ee;++N){var ne=T-L+N&32767,re=ne-h[ne]&32767;re>te&&(te=re,j=ne)}}}A=j,j=h[A],L+=A-j&32767}if(F){b[E++]=268435456|fi[P]<<18|hi[F];var ie=fi[P]&31,ae=hi[F]&31;w+=oi[ie]+si[ae],++x[257+ie],++S[ae],D=T+P,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,D);T<o;++T)b[E++]=e[T],++x[e[T]];u=Bi(e,c,l,b,x,S,w,E,O,T-O,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=D)}else{for(var T=a.w||0;T<o+l;T+=65535){var oe=T+65535;oe>=o&&(c[u/8|0]=l,oe=o),u=zi(c,u+1,e.subarray(T,oe))}a.i=o}return ki(s,0,r+Oi(u)+i)},Wi=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,a=n.length|0,o=0;o!=a;){for(var s=Math.min(o+2655,a);o<s;++o)i+=r+=n[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}e=r,t=i},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},Gi=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new ri(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return Ui(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},Ki=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},qi=function(e,t,n){for(var r=e(),i=e.toString(),a=i.slice(i.indexOf(`[`)+1,i.lastIndexOf(`]`)).replace(/\s+/g,``).split(`,`),o=0;o<r.length;++o){var s=r[o],c=a[o];if(typeof s==`function`){t+=`;`+c+`=`;var l=s.toString();if(s.prototype)if(l.indexOf(`[native code]`)!=-1){var u=l.indexOf(` `,8)+1;t+=l.slice(u,l.indexOf(`(`,u))}else for(var d in t+=l,s.prototype)t+=`;`+c+`.prototype.`+d+`=`+s.prototype[d].toString();else t+=l}else n[c]=s}return t},Ji=[],Yi=function(e){var t=[];for(var n in e)e[n].buffer&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t},Xi=function(e,t,n,r){if(!Ji[n]){for(var i=``,a={},o=e.length-1,s=0;s<o;++s)i=qi(e[s],i,a);Ji[n]={c:qi(e[o],i,a),e:a}}var c=Ki({},Ji[n].e);return ni(Ji[n].c+`;onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=`+t.toString()+`}`,n,c,Yi(c),r)},Zi=function(){return[ri,ii,ai,oi,si,ci,di,mi,Si,wi,gi,Ai,vi,Ti,Ei,Di,Oi,ki,ji,Mi,ca,ta,na]},Qi=function(){return[ri,ii,ai,oi,si,ci,fi,hi,xi,yi,Ci,bi,gi,Vi,Hi,vi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Oi,ki,Ui,Gi,sa,ta]},$i=function(){return[aa,ia,Wi]},ea=function(){return[oa]},ta=function(e){return postMessage(e,[e.buffer])},na=function(e){return e&&{out:e.size&&new ri(e.size),dictionary:e.dictionary}},ra=function(e,t,n,r,i,a){var o=Xi(n,r,i,function(e,t){o.terminate(),a(e,t)});return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},ia=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},aa=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var i=Wi();i.p(t.dictionary),ia(e,2,i.d())}},oa=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&ji(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&ji(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function sa(e,t){return Gi(e,t||{},0,0)}function ca(e,t){return Mi(e,{i:2},t&&t.out,t&&t.dictionary)}function la(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&ji(7),ra(e,t,[Qi,$i,function(){return[ua]}],function(e){return ta(ua(e.data[0],e.data[1]))},4,n)}function ua(e,t){t||={};var n=Wi();n.p(e);var r=Gi(e,t,t.dictionary?6:2,4);return aa(r,t),ia(r,r.length-4,n.d()),r}function da(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&ji(7),ra(e,t,[Zi,ea,function(){return[fa]}],function(e){return ta(fa(e.data[0],na(e.data[1])))},5,n)}function fa(e,t){return Mi(e.subarray(oa(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var pa=typeof TextDecoder<`u`&&new TextDecoder;try{pa.decode(Hi,{stream:!0})}catch{}var ma=`modern-font`;function ha(e,t){if(!e)throw Error(`[${ma}] ${t}`)}function ga(e){if(`buffer`in e){let t=e.buffer;return e.byteOffset>0||e.byteLength<e.buffer.byteLength?t.slice(e.byteOffset,e.byteOffset+e.byteLength):t}else return e}function _a(e){return`buffer`in e?new DataView(e.buffer,e.byteOffset,e.byteLength):new DataView(e)}function va(e){let t=``;for(let n=0,r=e.length,i;n<r;n++)i=e.charCodeAt(n),i!==0&&(t+=String.fromCharCode(i));return t}function ya(e){e=va(e);let t=[];for(let n=0,r=e.length,i;n<r;n++)i=e.charCodeAt(n),t.push(i>>8),t.push(i&255);return t}function ba(e){return new TextDecoder().decode(Uint8Array.from(e))}function xa(e){let t=``;for(let n=0,r=e.length;n<r;n+=2)t+=String.fromCharCode((e[n]<<8)+e[n+1]);return t}var Sa={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1},Ca=class extends DataView{constructor(e,t,n,r){super(ga(e),t,n),this.littleEndian=r}cursor=0;readInt8=e=>this.read(`int8`,e);readInt16=(e,t)=>this.read(`int16`,e,t);readInt32=(e,t)=>this.read(`int32`,e,t);readUint8=e=>this.read(`uint8`,e);readUint16=(e,t)=>this.read(`uint16`,e,t);readUint32=(e,t)=>this.read(`uint32`,e,t);readFloat32=(e,t)=>this.read(`float32`,e,t);readFloat64=(e,t)=>this.read(`float64`,e,t);writeInt8=(e,t)=>this.write(`int8`,e,t);writeInt16=(e,t,n)=>this.write(`int16`,e,t,n);writeInt32=(e,t,n)=>this.write(`int32`,e,t,n);writeUint8=(e,t)=>this.write(`uint8`,e,t);writeUint16=(e,t,n)=>this.write(`uint16`,e,t,n);writeUint32=(e,t,n)=>this.write(`uint32`,e,t,n);writeFloat32=(e,t,n)=>this.write(`float32`,e,t,n);writeFloat64=(e,t,n)=>this.write(`float64`,e,t,n);readColumn(e){if(e.size){let t=Array.from({length:e.size},(t,n)=>this.read(e.type,e.offset+n));switch(e.type){case`char`:return t.join(``);default:return t}}else return this.read(e.type,e.offset)}writeColumn(e,t){e.size?Array.from({length:e.size},(n,r)=>{this.write(e.type,t[r],e.offset+r)}):this.write(e.type,t,e.offset)}read(e,t=this.cursor,n=this.littleEndian){let r;switch(e){case`int8`:r=this.getInt8(t);break;case`int16`:r=this.getInt16(t,n);break;case`int32`:r=this.getInt32(t,n);break;case`uint8`:r=this.getUint8(t);break;case`uint16`:r=this.getUint16(t,n);break;case`uint32`:r=this.getUint32(t,n);break;case`float32`:r=this.getFloat32(t,n);break;case`float64`:r=this.getFloat64(t,n);break;case`fixed`:r=this.readFixed(t,n);break;case`longDateTime`:r=this.readLongDateTime(t,n);break;case`char`:r=this.readChar(t);break}return this.cursor+=Sa[e],r}readUint24(e=this.cursor){let[t,n,r]=this.readBytes(e,3);return(t<<16)+(n<<8)+r}readBytes(e,t){t??(t=e,e=this.cursor);let n=[];for(let r=0;r<t;++r)n.push(this.getUint8(e+r));return this.cursor=e+t,n}readString(e,t){let n=this.readBytes(e,t),r=``;for(let e=0,t=n.length;e<t;e++)r+=String.fromCharCode(n[e]);return r}readFixed(e,t){let n=this.readInt32(e,t)/65536;return Math.ceil(n*1e5)/1e5}readLongDateTime(e=this.cursor,t){let n=this.readUint32(e+4,t),r=new Date;return r.setTime(n*1e3+-20775456e5),r}readChar(e){return this.readString(e,1)}write(e,t,n=this.cursor,r=this.littleEndian){switch(e){case`int8`:this.setInt8(n,t);break;case`int16`:this.setInt16(n,t,r);break;case`int32`:this.setInt32(n,t,r);break;case`uint8`:this.setUint8(n,t);break;case`uint16`:this.setUint16(n,t,r);break;case`uint32`:this.setUint32(n,t,r);break;case`float32`:this.setFloat32(n,t,r);break;case`float64`:this.setFloat64(n,t,r);break;case`char`:this.writeChar(t,n);break;case`fixed`:this.writeFixed(t,n);break;case`longDateTime`:this.writeLongDateTime(t,n);break}return this.cursor+=Sa[e],this}writeString(e=``,t=this.cursor){let n=e.replace(/[^\x00-\xFF]/g,`11`).length;this.seek(t);for(let t=0,n=e.length,r;t<n;++t)r=e.charCodeAt(t)||0,r>127?this.writeUint16(r):this.writeUint8(r);return this.cursor+=n,this}writeChar(e,t){return this.writeString(e,t)}writeFixed(e,t){return this.writeInt32(Math.round(e*65536),t),this}writeLongDateTime(e,t=this.cursor){let n=-20775456e5;e=e===void 0?n:typeof e.getTime==`function`?e.getTime():/^\d+$/.test(e)?+e:Date.parse(e);let r=Math.round((e-n)/1e3);return this.writeUint32(0,t),this.writeUint32(r,t+4),this}writeBytes(e,t=this.cursor){let n;if(Array.isArray(e)){n=e.length;for(let r=0;r<n;++r)this.setUint8(t+r,e[r])}else{let r=_a(e);n=r.byteLength;for(let e=0;e<n;++e)this.setUint8(t+e,r.getUint8(e))}return this.cursor=t+n,this}seek(e){return this.cursor=e,this}},wa=new WeakMap;function J(e){let t=typeof e==`object`?e:{type:e},{size:n=1,type:r}=t;return(e,i)=>{if(typeof i!=`string`)return;let a=wa.get(e);a||(a={columns:[],byteLength:0},wa.set(e,a));let o={...t,name:i,byteLength:n*Sa[r],offset:t.offset??a.columns.reduce((e,t)=>e+t.byteLength,0)};a.columns.push(o),a.byteLength=a.columns.reduce((e,t)=>e+Sa[t.type]*(t.size??1),0),Object.defineProperty(e.constructor.prototype,i,{get(){return this.view.readColumn(o)},set(e){this.view.writeColumn(o,e)},configurable:!0,enumerable:!0})}}var Ta=class{view;constructor(e,t,n,r){this.view=new Ca(e,t,n,r)}},Ea=class extends Ta{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)}},Da=Object.defineProperty,Oa=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&Da(t,n,i),i},ka=class e extends Ea{format=`EmbeddedOpenType`;mimeType=`application/vnd.ms-fontobject`;static from(t){let n=t.sfnt,r=n.name.names,i=ya(r.fontFamily||``),a=i.length,o=ya(r.fontSubFamily||``),s=o.length,c=ya(r.version||``),l=c.length,u=ya(r.fullName||``),d=u.length,f=86+a+4+s+4+l+4+d+2+t.view.byteLength,p=new e(new ArrayBuffer(f),0,f,!0);p.EOTSize=p.view.byteLength,p.FontDataSize=t.view.byteLength,p.Version=131073,p.Flags=0,p.Charset=1,p.MagicNumber=20556,p.Padding1=0,p.CheckSumAdjustment=n.head.checkSumAdjustment;let m=n.os2;return m&&(p.FontPANOSE=m.fontPANOSE,p.Italic=m.fsSelection,p.Weight=m.usWeightClass,p.fsType=m.fsType,p.UnicodeRange=m.ulUnicodeRange,p.CodePageRange=m.version>0?m.ulCodePageRange:[]),p.view.seek(82),p.view.writeUint16(a),p.view.writeBytes(i),p.view.writeUint16(0),p.view.writeUint16(s),p.view.writeBytes(o),p.view.writeUint16(0),p.view.writeUint16(l),p.view.writeBytes(c),p.view.writeUint16(0),p.view.writeUint16(d),p.view.writeBytes(u),p.view.writeUint16(0),p.view.writeUint16(0),p.view.writeBytes(t.view),p}};Oa([J(`uint32`)],ka.prototype,`EOTSize`),Oa([J(`uint32`)],ka.prototype,`FontDataSize`),Oa([J(`uint32`)],ka.prototype,`Version`),Oa([J(`uint32`)],ka.prototype,`Flags`),Oa([J({type:`uint8`,size:10})],ka.prototype,`FontPANOSE`),Oa([J(`uint8`)],ka.prototype,`Charset`),Oa([J(`uint8`)],ka.prototype,`Italic`),Oa([J(`uint32`)],ka.prototype,`Weight`),Oa([J(`uint16`)],ka.prototype,`fsType`),Oa([J(`uint16`)],ka.prototype,`MagicNumber`),Oa([J({type:`uint32`,size:4})],ka.prototype,`UnicodeRange`),Oa([J({type:`uint8`,size:8})],ka.prototype,`CodePageRange`),Oa([J(`uint32`)],ka.prototype,`CheckSumAdjustment`),Oa([J({type:`uint8`,size:16})],ka.prototype,`Reserved`),Oa([J(`uint16`)],ka.prototype,`Padding1`);var Aa=Object.defineProperty,ja=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&Aa(t,n,i),i},Ma=class extends Ta{constructor(e,t){super(e,t,16)}};ja([J({type:`char`,size:4})],Ma.prototype,`tag`),ja([J(`uint32`)],Ma.prototype,`checkSum`),ja([J(`uint32`)],Ma.prototype,`offset`),ja([J(`uint32`)],Ma.prototype,`length`);var Na=`................................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`.split(`.`),Pa=`................................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`.split(`.`),Fa=class{index;name;isComposite=!1;components=[];pathCommands=[];constructor(e){let 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 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,r={},i){let a=1/(i?.unitsPerEm??1e3)*n,{xScale:o=a,yScale:s=a}=r,c=this.pathCommands,l=[];for(let n=0,r=c.length;n<r;n+=1){let r=c[n];r.type===`M`?l.push({type:`M`,x:e+r.x*o,y:t+-r.y*s}):r.type===`L`?l.push({type:`L`,x:e+r.x*o,y:t+-r.y*s}):r.type===`Q`?l.push({type:`Q`,x1:e+r.x1*o,y1:t+-r.y1*s,x:e+r.x*o,y:t+-r.y*s}):r.type===`C`?l.push({type:`C`,x1:e+r.x1*o,y1:t+-r.y1*s,x2:e+r.x2*o,y2:t+-r.y2*s,x:e+r.x*o,y:t+-r.y*s}):r.type===`Z`&&l.push({type:`Z`})}return l}getPathData(e=0,t=0,n=72,r={},i,a=2){return Ia(this.getPathCommands(e,t,n,r,i),a)}};function Ia(e,t=2){let n=e=>String(Number(e.toFixed(t))),r=``;for(let t=0;t<e.length;t++){let i=e[t];switch(i.type){case`M`:r+=`M${n(i.x)} ${n(i.y)}`;break;case`L`:r+=`L${n(i.x)} ${n(i.y)}`;break;case`Q`:r+=`Q${n(i.x1)} ${n(i.y1)} ${n(i.x)} ${n(i.y)}`;break;case`C`:r+=`C${n(i.x1)} ${n(i.y1)} ${n(i.x2)} ${n(i.y2)} ${n(i.x)} ${n(i.y)}`;break;case`Z`:r+=`Z`;break}}return r}var La=class extends Fa{parse(e,t,n){let r=this,{nominalWidthX:i,defaultWidthX:a,gsubrsBias:o,subrsBias:s}=e,c=e.topDict.paintType,l=this.index,u,d,f,p,m=[],h=[],g=0,_=!1,v=!1,y=a,b=0,x=0;function S(e,t){m.push({type:`L`,x:e,y:t})}function C(e,t,n,r,i,a){m.push({type:`C`,x1:e,y1:t,x2:n,y2:r,x:i,y:a})}function w(e,t){v&&c!==2&&T(),v=!0,m.push({type:`M`,x:e,y:t})}function T(){m.push({type:`Z`})}function E(e){m.push(...e)}function D(){h.length%2!=0&&!_&&(y=h.shift()+i),g+=h.length>>1,h.length=0,_=!0}function O(t){let a,m,k,A,j,M,N,P,F,I,L,R,z=0;for(;z<t.length;){let B=t[z++];switch(B){case 1:D();break;case 3:D();break;case 4:h.length>1&&!_&&(y=h.shift()+i,_=!0),x+=h.pop(),w(b,x);break;case 5:for(;h.length>0;)b+=h.shift(),x+=h.shift(),S(b,x);break;case 6:for(;h.length>0&&(b+=h.shift(),S(b,x),h.length!==0);)x+=h.shift(),S(b,x);break;case 7:for(;h.length>0&&(x+=h.shift(),S(b,x),h.length!==0);)b+=h.shift(),S(b,x);break;case 8:for(;h.length>0;)u=b+h.shift(),d=x+h.shift(),f=u+h.shift(),p=d+h.shift(),b=f+h.shift(),x=p+h.shift(),C(u,d,f,p,b,x);break;case 10:j=h.pop()+s,M=e.subrs[j],M&&O(M);break;case 11:return;case 12:switch(B=t[z],z+=1,B){case 35:u=b+h.shift(),d=x+h.shift(),f=u+h.shift(),p=d+h.shift(),N=f+h.shift(),P=p+h.shift(),F=N+h.shift(),I=P+h.shift(),L=F+h.shift(),R=I+h.shift(),b=L+h.shift(),x=R+h.shift(),h.shift(),C(u,d,f,p,N,P),C(F,I,L,R,b,x);break;case 34:u=b+h.shift(),d=x,f=u+h.shift(),p=d+h.shift(),N=f+h.shift(),P=p,F=N+h.shift(),I=p,L=F+h.shift(),R=x,b=L+h.shift(),C(u,d,f,p,N,P),C(F,I,L,R,b,x);break;case 36:u=b+h.shift(),d=x+h.shift(),f=u+h.shift(),p=d+h.shift(),N=f+h.shift(),P=p,F=N+h.shift(),I=p,L=F+h.shift(),R=I+h.shift(),b=L+h.shift(),C(u,d,f,p,N,P),C(F,I,L,R,b,x);break;case 37:u=b+h.shift(),d=x+h.shift(),f=u+h.shift(),p=d+h.shift(),N=f+h.shift(),P=p+h.shift(),F=N+h.shift(),I=P+h.shift(),L=F+h.shift(),R=I+h.shift(),Math.abs(L-b)>Math.abs(R-x)?b=L+h.shift():x=R+h.shift(),C(u,d,f,p,N,P),C(F,I,L,R,b,x);break;default:console.warn(`Glyph ${l}: unknown operator ${1200+B}`),h.length=0}break;case 14:if(h.length>=4){let t=Na[h.pop()],i=Na[h.pop()],a=h.pop(),o=h.pop();if(t&&i){r.isComposite=!0,r.components=[];let s=e.charset.indexOf(t),c=e.charset.indexOf(i);r.components.push({glyphIndex:c,dx:0,dy:0}),r.components.push({glyphIndex:s,dx:o,dy:a}),E(n.get(c).pathCommands);let l=JSON.parse(JSON.stringify(n.get(s).pathCommands));for(let e=0;e<l.length;e+=1){let t=l[e];t.type!==`Z`&&(t.x+=o,t.y+=a),(t.type===`Q`||t.type===`C`)&&(t.x1+=o,t.y1+=a),t.type===`C`&&(t.x2+=o,t.y2+=a)}E(l)}}else h.length>0&&!_&&(y=h.shift()+i,_=!0);v&&c!==2&&(T(),v=!1);break;case 18:D();break;case 19:case 20:D(),z+=g+7>>3;break;case 21:h.length>2&&!_&&(y=h.shift()+i,_=!0),x+=h.pop(),b+=h.pop(),w(b,x);break;case 22:h.length>1&&!_&&(y=h.shift()+i,_=!0),b+=h.pop(),w(b,x);break;case 23:D();break;case 24:for(;h.length>2;)u=b+h.shift(),d=x+h.shift(),f=u+h.shift(),p=d+h.shift(),b=f+h.shift(),x=p+h.shift(),C(u,d,f,p,b,x);b+=h.shift(),x+=h.shift(),S(b,x);break;case 25:for(;h.length>6;)b+=h.shift(),x+=h.shift(),S(b,x);u=b+h.shift(),d=x+h.shift(),f=u+h.shift(),p=d+h.shift(),b=f+h.shift(),x=p+h.shift(),C(u,d,f,p,b,x);break;case 26:for(h.length%2&&(b+=h.shift());h.length>0;)u=b,d=x+h.shift(),f=u+h.shift(),p=d+h.shift(),b=f,x=p+h.shift(),C(u,d,f,p,b,x);break;case 27:for(h.length%2&&(x+=h.shift());h.length>0;)u=b+h.shift(),d=x,f=u+h.shift(),p=d+h.shift(),b=f+h.shift(),x=p,C(u,d,f,p,b,x);break;case 28:a=t[z],m=t[z+1],h.push((a<<24|m<<16)>>16),z+=2;break;case 29:j=h.pop()+o,M=e.gsubrs[j],M&&O(M);break;case 30:for(;h.length>0&&(u=b,d=x+h.shift(),f=u+h.shift(),p=d+h.shift(),b=f+h.shift(),x=p+(h.length===1?h.shift():0),C(u,d,f,p,b,x),h.length!==0);)u=b+h.shift(),d=x,f=u+h.shift(),p=d+h.shift(),x=p+h.shift(),b=f+(h.length===1?h.shift():0),C(u,d,f,p,b,x);break;case 31:for(;h.length>0&&(u=b+h.shift(),d=x,f=u+h.shift(),p=d+h.shift(),x=p+h.shift(),b=f+(h.length===1?h.shift():0),C(u,d,f,p,b,x),h.length!==0);)u=b,d=x+h.shift(),f=u+h.shift(),p=d+h.shift(),b=f+h.shift(),x=p+(h.length===1?h.shift():0),C(u,d,f,p,b,x);break;default:B<32?console.warn(`Glyph ${l}: unknown operator ${B}`):B<247?h.push(B-139):B<251?(a=t[z],z+=1,h.push((B-247)*256+a+108)):B<255?(a=t[z],z+=1,h.push(-(B-251)*256-a-108)):(a=t[z],m=t[z+1],k=t[z+2],A=t[z+3],z+=4,h.push((a<<24|m<<16|k<<8|A)/65536))}}}O(t),this.pathCommands=m,_&&(this.advanceWidth=y)}},Ra=class{constructor(e){this._sfnt=e}_items=[];get(e){let t=this._items[e],n;if(t)n=t;else{n=this._get(e);let t=this._sfnt.hmtx.metrics[e];t&&(n.advanceWidth=n.advanceWidth||t.advanceWidth,n.leftSideBearing=n.leftSideBearing||t.leftSideBearing);let r=this._sfnt.vmtx?.metrics[e];r&&(n.advanceHeight=n.advanceHeight||r.advanceHeight,n.topSideBearing=n.topSideBearing||r.topSideBearing);let i=this._sfnt.cmap.glyphIndexToUnicodesMap.get(e);if(i&&(n.unicode??=i[0],n.unicodes??=i),n.name==null){let t=this._sfnt.post?.getGlyphName(e);t&&(n.name=t)}this._items[e]=n}return n}},za=class extends Ra{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(e){let t=this._sfnt.cff,n=new La({index:e});return n.parse(t,t.charStringsIndex.get(e),this),n.name=t.charset[e],n}},Ba=Object.defineProperty,Va=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&Ba(t,n,i),i},Ha=class extends Ta{_offsets;get offsets(){return this._offsets??=this.readOffsets()}_objects;get objects(){return this._objects??=this.readObjects()}constructor(e,t,n,r){super(e,t,n,r),this._init()}_init(){let e=this.view,t=this.count,n=this.offsetSize;this.objectOffset=(t+1)*n+2,this.endOffset=e.byteOffset+this.objectOffset+this.offsets[t]}readOffsets(){let e=this.view,t=this.count,n=this.offsetSize;e.seek(3);let r=[];for(let e=0,i=t+1;e<i;e++){let e=this.view,t=0;for(let r=0;r<n;r++)t<<=8,t+=e.readUint8();r.push(t)}return r}readObjects(){let e=[];for(let t=0,n=this.count;t<n;t++)e.push(this.get(t));return e}get(e){let t=this.offsets,n=this.objectOffset,r=n+t[e],i=n+t[e+1]-r;return this._isString?this.view.readString(r,i):this.view.readBytes(r,i)}};Va([J(`uint16`)],Ha.prototype,`count`),Va([J(`uint8`)],Ha.prototype,`offsetSize`);var Ua=class extends Ha{_isString=!1},Wa=class extends Ha{_isString=!0},Ga=`.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`.split(`,`),Ka=`.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`.split(`,`),qa=`.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`.split(`,`),Ja=`.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`.split(`,`);function Ya(e,t){return t<=390?Ga[t]:e[t-391]}function Y(e,t=`number`,n){return(r,i)=>{if(typeof i!=`string`)return;let a={type:t,operator:e,default:n};Object.defineProperty(r.constructor.prototype,i,{get(){return this._getProp(a)},set(e){this._setProp(a,e)},configurable:!0,enumerable:!0})}}var Xa=class extends Ta{_dict;get dict(){return this._dict??=this._readDict()}_stringIndex;setStringIndex(e){return this._stringIndex=e,this}_readFloatOperand(){let e=this.view,t=``,n=[`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`.`,`E`,`E-`,null,`-`];for(;;){let r=e.readUint8(),i=r>>4,a=r&15;if(i===15||(t+=n[i],a===15))break;t+=n[a]}return Number.parseFloat(t)}_readOperand(e){let t=this.view,n,r,i,a;if(e===28)return n=t.readUint8(),r=t.readUint8(),n<<8|r;if(e===29)return n=t.readUint8(),r=t.readUint8(),i=t.readUint8(),a=t.readUint8(),n<<24|r<<16|i<<8|a;if(e===30)return this._readFloatOperand();if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return n=t.readUint8(),(e-247)*256+n+108;if(e>=251&&e<=254)return n=t.readUint8(),-(e-251)*256-n-108;throw Error(`invalid b0 ${e}, at: ${t.cursor}`)}_readDict(){let e=this.view;e.seek(0);let t=[],n=e.cursor+e.byteLength,r={};for(;e.cursor<n;){let n=e.readUint8();n<=21?(n===12&&(n=1200+e.readUint8()),r[n]=t,t=[]):t.push(this._readOperand(n))}return r}_getProp(e){let t=this.dict[e.operator];switch(e.type){case`number`:return t?t[0]:e.default??0;case`string`:return t?Ya(this._stringIndex?.objects??[],t[0]):e.default;case`number[]`:return t??e.default}return t??e.default}_setProp(e,t){}},Za=Object.defineProperty,Qa=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&Za(t,n,i),i},$a=class extends Xa{};Qa([Y(19)],$a.prototype,`subrs`),Qa([Y(20)],$a.prototype,`defaultWidthX`),Qa([Y(21)],$a.prototype,`nominalWidthX`);var eo=Object.defineProperty,X=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&eo(t,n,i),i},Z=class extends Xa{};X([Y(0,`string`)],Z.prototype,`version`),X([Y(1,`string`)],Z.prototype,`notice`),X([Y(1200,`string`)],Z.prototype,`copyright`),X([Y(2,`string`)],Z.prototype,`fullName`),X([Y(3,`string`)],Z.prototype,`familyName`),X([Y(4,`string`)],Z.prototype,`weight`),X([Y(1201)],Z.prototype,`isFixedPitch`),X([Y(1202)],Z.prototype,`italicAngle`),X([Y(1203,`number`,-100)],Z.prototype,`underlinePosition`),X([Y(1204,`number`,50)],Z.prototype,`underlineThickness`),X([Y(1205)],Z.prototype,`paintType`),X([Y(1206,`number`,2)],Z.prototype,`charstringType`),X([Y(1207,`number[]`,[.001,0,0,.001,0,0])],Z.prototype,`fontMatrix`),X([Y(13)],Z.prototype,`uniqueId`),X([Y(5,`number[]`,[0,0,0,0])],Z.prototype,`fontBBox`),X([Y(1208)],Z.prototype,`strokeWidth`),X([Y(14)],Z.prototype,`xuid`),X([Y(15)],Z.prototype,`charset`),X([Y(16)],Z.prototype,`encoding`),X([Y(17)],Z.prototype,`charStrings`),X([Y(18,`number[]`,[0,0])],Z.prototype,`private`);function to(e,t=e){return n=>{no.tableDefinitions.set(e,{tag:e,prop:t,class:n}),Object.defineProperty(no.prototype,t,{get(){return this.get(e)},set(t){return this.set(e,t)},configurable:!0,enumerable:!0})}}var no=class e{static tableDefinitions=new Map;tables=new Map;tableViews=new Map;_viewLoaders=new Map;get tableTags(){return[...new Set([...this.tableViews.keys(),...this._viewLoaders.keys()])]}hasTable(e){return this.tableViews.has(e)||this._viewLoaders.has(e)}getTableView(e){let t=this.tableViews.get(e);if(!t){let n=this._viewLoaders.get(e);n&&(t=n(),this.tableViews.set(e,t),this._viewLoaders.delete(e))}return t}get hasGlyf(){return this.hasTable(`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}get defaultAdvanceHeight(){return this.ascender+Math.abs(this.descender)}charToGlyphIndex(e){let t=this.cmap.unicodeToGlyphIndexMap.get(e.codePointAt(0));if(t===void 0&&!this.hasGlyf){let{encoding:n,charset:r}=this.cff;t=r.indexOf(n[e.codePointAt(0)])}return t??0}charToGlyph(e){return this.glyphs.get(this.charToGlyphIndex(e))}getSubstituteGlyphIndex(e,t){return this.gsub?.getSingleSubstitutions(t).get(e)??e}applyLigatures(e,t=`liga`){let n=this.gsub?.getLigatures(t);if(!n||!n.size)return e.slice();let r=[];for(let t=0;t<e.length;){let i=n.get(e[t]),a=!1;if(i)for(let n of i){let i=n.components.length,o=!0;for(let r=0;r<i;r++)if(e[t+1+r]!==n.components[r]){o=!1;break}if(o){r.push(n.ligatureGlyph),t+=i+1,a=!0;break}}a||(r.push(e[t]),t++)}return r}textToGlyphIndexes(e){let t=[];for(let n of e)t.push(this.charToGlyphIndex(n));return t}textToGlyphs(e){let t=this.glyphs,n=this.textToGlyphIndexes(e),r=n.length,i=Array.from({length:r}),a=t.get(0);for(let e=0;e<r;e+=1)i[e]=t.get(n[e])||a;return i}getPathCommands(e,t,n,r,i){let a=[];return this.forEachGlyph(e,t,n,r,i,(e,t,n,r,i)=>{a.push(...e.getPathCommands(t,n,r,i,this))}),a}getPathData(e,t,n,r,i,a=2){return Ia(this.getPathCommands(e,t,n,r,i),a)}getKerningValue(e,t){return(this.gpos?.getKerningValue(e,t)??0)||(this.kern?.getKerningValue(e,t)??0)}getAdvanceWidth(e,t,n){return this.forEachGlyph(e,0,0,t,n,()=>{})}getAdvanceHeight(e,t=72,n={}){let r=1/this.unitsPerEm*t,i=this.defaultAdvanceHeight,a=this.textToGlyphs(e),o=0;for(let e=0;e<a.length;e+=1)o+=(a[e].advanceHeight||i)*r,n.letterSpacing?o+=n.letterSpacing*t:n.tracking&&(o+=n.tracking/1e3*t);return o}forEachGlyph(e,t=0,n=0,r=72,i={},a){let o=1/this.unitsPerEm*r,s=this.textToGlyphs(e);for(let e=0;e<s.length;e+=1){let c=s[e];a.call(this,c,t,n,r,i),c.advanceWidth&&(t+=c.advanceWidth*o),i.letterSpacing?t+=i.letterSpacing*r:i.tracking&&(t+=i.tracking/1e3*r)}return t}constructor(e,t){e&&(e instanceof Map?e:new Map(Object.entries(e))).forEach((e,t)=>this.tableViews.set(t,e)),t?.forEach((e,t)=>this._viewLoaders.set(t,e))}clone(){let t=new Map;return this.tableTags.forEach(e=>{let n=this.getTableView(e);t.set(e,new DataView(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)))}),new e(t)}delete(t){let n=e.tableDefinitions.get(t);return n?(this.tableViews.delete(t),this._viewLoaders.delete(t),this.tables.delete(n.prop),this):this}set(t,n){let r=e.tableDefinitions.get(t);return r&&this.tables.set(r.prop,n),this.tableViews.set(t,n.view),this._viewLoaders.delete(t),this}get(t){let n=e.tableDefinitions.get(t);if(!n)return;let r=this.tables.get(n.prop);if(!r){let e=n.class;if(e){let i=this.getTableView(t);if(!i)return;r=new e(i.buffer,i.byteOffset,i.byteLength).setSFNT(this),this.tables.set(n.prop,r)}}return r}},ro=class extends Ta{setSFNT(e){return this._sfnt=e,this}getSFNT(){return this._sfnt}},io=Object.defineProperty,ao=Object.getOwnPropertyDescriptor,oo=(e,t,n,r)=>{for(var i=r>1?void 0:r?ao(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&io(t,n,i),i},so=class extends ro{_glyphs;get glyphs(){return this._glyphs??=new za(this._sfnt)}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}privateDict;subrsIndex;get defaultWidthX(){return this.privateDict?.defaultWidthX??0}get nominalWidthX(){return this.privateDict?.nominalWidthX??0}get subrs(){return this.subrsIndex?.objects??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}constructor(e,t,n,r){super(e,t,n,r),this._init()}_init(){let{buffer:e,byteOffset:t}=this.view,n=t+4;this.nameIndex=new Wa(e,n),this.topDictIndex=new Ua(e,this.nameIndex.endOffset),this.stringIndex=new Wa(e,this.topDictIndex.endOffset),this.globalSubrIndex=new Ua(e,this.stringIndex.endOffset),this.topDict=new Z(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);let r=this.topDict.private[0],i=this.topDict.private[1];r&&(this.privateDict=new $a(e,t+i,r).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new Ua(e,t+i+this.privateDict.subrs))),this.charStringsIndex=new Ua(e,t+this.topDict.charStrings);let a=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=Ka:this.topDict.charset===1?this.charset=qa:this.topDict.charset===2?this.charset=Ja:this.charset=this._readCharset(t+this.topDict.charset,a,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=Na:this.topDict.encoding===1?this.encoding=Pa:this.encoding=this._readEncoding(t+this.topDict.encoding)}_readCharset(e,t,n){let r=this.view;r.seek(e);let i,a,o;--t;let s=[`.notdef`],c=r.readUint8();if(c===0)for(i=0;i<t;i+=1)a=r.readUint16(),s.push(Ya(n,a));else if(c===1)for(;s.length<=t;)for(a=r.readUint16(),o=r.readUint8(),i=0;i<=o;i+=1)s.push(Ya(n,a)),a+=1;else if(c===2)for(;s.length<=t;)for(a=r.readUint16(),o=r.readUint16(),i=0;i<=o;i+=1)s.push(Ya(n,a)),a+=1;else throw Error(`Unknown charset format ${c}`);return s}_readEncoding(e){let t=this.view;t.seek(e);let n,r,i={},a=t.readUint8();if(a===0){let e=t.readUint8();for(n=0;n<e;n+=1)r=t.readUint8(),i[r]=n}else if(a===1){let e=t.readUint8();for(r=1,n=0;n<e;n+=1){let e=t.readUint8(),n=t.readUint8();for(let t=e;t<=e+n;t+=1)i[t]=r,r+=1}}else console.warn(`unknown encoding format:${a}`);return i}blankGlyphsExcept(e){let t=this.charStringsIndex.offsets,n=t.length-1,r=this.topDict.charStrings+this.charStringsIndex.objectOffset;for(let i=0;i<n;i++){if(e.has(i))continue;let n=r+t[i+1];for(let e=r+t[i];e<n;e++)this.view.setUint8(e,14)}return this}_calcSubroutineBias(e){let t;return t=e.length<1240?107:e.length<33900?1131:32768,t}};oo([J(`uint8`)],so.prototype,`majorVersion`,2),oo([J(`uint8`)],so.prototype,`minorVersion`,2),oo([J(`uint8`)],so.prototype,`headerSize`,2),oo([J(`uint8`)],so.prototype,`offsetSize`,2),so=oo([to(`CFF `,`cff`)],so);var co=Object.defineProperty,lo=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&co(t,n,i),i},uo=class e extends Ta{constructor(e=new ArrayBuffer(262),t){super(e,t,262)}static from(t){let n=new e;return n.format=0,n.length=n.view.byteLength,n.language=0,t.forEach((e,t)=>{t<256&&e<256&&n.view.writeUint8(e,6+t)}),n}getUnicodeToGlyphIndexMap(){let e=new Map;return this.glyphIndexArray.forEach((t,n)=>{e.set(n,t)}),e}};lo([J(`uint16`)],uo.prototype,`format`),lo([J(`uint16`)],uo.prototype,`length`),lo([J(`uint16`)],uo.prototype,`language`),lo([J({type:`uint8`,size:256})],uo.prototype,`glyphIndexArray`);var fo=uo,po=Object.defineProperty,mo=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&po(t,n,i),i},ho=class extends Ta{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(){let e=this.maxSubHeaderKey;return this.view.seek(518),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(){let e=518+this.maxSubHeaderKey*8;this.view.seek(e);let t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(e){let t=new Map,n=this.subHeaderKeys,r=this.maxSubHeaderKey,i=this.subHeaders,a=this.glyphIndexArray,o=n.findIndex(e=>e===r),s=0;for(let r=0;r<256;r++)if(n[r]===0)r>=o||r<i[0].firstCode||r>=i[0].firstCode+i[0].entryCount||i[0].idRangeOffset+(r-i[0].firstCode)>=a.length?s=0:(s=a[i[0].idRangeOffset+(r-i[0].firstCode)],s!==0&&(s+=i[0].idDelta)),s!==0&&s<e&&t.set(r,s);else{let o=n[r];for(let n=0,c=i[o].entryCount;n<c;n++)if(i[o].idRangeOffset+n>=a.length?s=0:(s=a[i[o].idRangeOffset+n],s!==0&&(s+=i[o].idDelta)),s!==0&&s<e){let e=(r<<8|n+i[o].firstCode)&65535;t.set(e,s)}}return t}};mo([J(`uint16`)],ho.prototype,`format`),mo([J(`uint16`)],ho.prototype,`length`),mo([J(`uint16`)],ho.prototype,`language`);function go(e){return e>32767?e-65536:e<-32767?e+65536:e}function _o(e,t){let n,r=[],i={};return e.forEach((e,a)=>{t&&a>t||((!n||a!==n.unicode+1||e!==n.glyphIndex+1)&&(n?(i.end=n.unicode,r.push(i),i={start:a,startId:e,delta:go(e-a)}):(i.start=Number(a),i.startId=e,i.delta=go(e-a))),n={unicode:a,glyphIndex:e})}),n&&(i.end=n.unicode,r.push(i)),r}var vo=Object.defineProperty,yo=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&vo(t,n,i),i},bo=class e extends Ta{get endCode(){let e=this.segCountX2;return this.view.seek(14),Array.from({length:e/2},()=>this.view.readUint16())}set endCode(e){this.view.seek(14),e.forEach(e=>this.view.writeUint16(e))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(e){this.view.writeUint16(e,14+this.segCountX2)}get startCode(){let e=this.segCountX2;return this.view.seek(14+e+2),Array.from({length:e/2},()=>this.view.readUint16())}set startCode(e){this.view.seek(14+this.segCountX2+2),e.forEach(e=>this.view.writeUint16(e))}get idDelta(){let e=this.segCountX2;return this.view.seek(14+e+2+e),Array.from({length:e/2},()=>this.view.readUint16())}set idDelta(e){let t=this.segCountX2;this.view.seek(14+t+2+t),e.forEach(e=>this.view.writeUint16(e))}get idRangeOffsetCursor(){let e=this.segCountX2;return 14+e+2+e*2}get idRangeOffset(){let e=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:e/2},()=>this.view.readUint16())}set idRangeOffset(e){this.view.seek(this.idRangeOffsetCursor),e.forEach(e=>this.view.writeUint16(e))}get glyphIndexArrayCursor(){let e=this.segCountX2;return 14+e+2+e*3}get glyphIndexArray(){let e=this.glyphIndexArrayCursor;this.view.seek(e);let t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}static from(t){let n=_o(t,65535),r=n.length+1,i=Math.floor(Math.log(r)/Math.LN2),a=2*2**i,o=new e(new ArrayBuffer(24+n.length*8));return o.format=4,o.length=o.view.byteLength,o.language=0,o.segCountX2=r*2,o.searchRange=a,o.entrySelector=i,o.rangeShift=2*r-a,o.endCode=[...n.map(e=>e.end),65535],o.reservedPad=0,o.startCode=[...n.map(e=>e.start),65535],o.idDelta=[...n.map(e=>e.delta),1],o.idRangeOffset=Array.from({length:r},()=>0),o}getUnicodeToGlyphIndexMap(){let e=new Map,t=this.segCountX2/2,n=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,r=this.startCode,i=this.endCode,a=this.idRangeOffset,o=this.idDelta,s=this.glyphIndexArray;for(let c=0;c<t;++c)for(let t=r[c],l=i[c];t<=l;++t)if(a[c]===0)e.set(t,(t+o[c])%65536);else{let i=s[c+a[c]/2+(t-r[c])-n];i===0?e.set(t,0):e.set(t,(i+o[c])%65536)}return e.delete(65535),e}};yo([J(`uint16`)],bo.prototype,`format`),yo([J(`uint16`)],bo.prototype,`length`),yo([J(`uint16`)],bo.prototype,`language`),yo([J(`uint16`)],bo.prototype,`segCountX2`),yo([J(`uint16`)],bo.prototype,`searchRange`),yo([J(`uint16`)],bo.prototype,`entrySelector`),yo([J(`uint16`)],bo.prototype,`rangeShift`);var xo=bo,So=Object.defineProperty,Co=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&So(t,n,i),i},wo=class extends Ta{get glyphIndexArray(){let e=this.entryCount;return Array.from({length:e},(e,t)=>this.view.readUint16(10+t*2))}getUnicodeToGlyphIndexMap(){let e=this.glyphIndexArray,t=this.firstCode,n=new Map;return e.forEach((e,r)=>{n.set(t+r,e)}),n}};Co([J(`uint16`)],wo.prototype,`format`),Co([J(`uint16`)],wo.prototype,`length`),Co([J(`uint16`)],wo.prototype,`language`),Co([J(`uint16`)],wo.prototype,`firstCode`),Co([J(`uint16`)],wo.prototype,`entryCount`);var To=Object.defineProperty,Eo=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&To(t,n,i),i},Do=class e extends Ta{get groups(){let e=this.nGroups;return this.view.seek(16),Array.from({length:e},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(t){let n=_o(t),r=new e(new ArrayBuffer(16+n.length*12));return r.format=12,r.reserved=0,r.length=r.view.byteLength,r.language=0,r.nGroups=n.length,n.forEach(e=>{r.view.writeUint32(e.start),r.view.writeUint32(e.end),r.view.writeUint32(e.startId)}),r}getUnicodeToGlyphIndexMap(){let e=new Map,t=this.groups;for(let n=0,r=t.length;n<r;n++){let r=t[n],i=r.startGlyphCode,a=r.startCharCode,o=r.endCharCode;for(;a<=o;)e.set(a++,i++)}return e}};Eo([J(`uint16`)],Do.prototype,`format`),Eo([J(`uint16`)],Do.prototype,`reserved`),Eo([J(`uint32`)],Do.prototype,`length`),Eo([J(`uint32`)],Do.prototype,`language`),Eo([J(`uint32`)],Do.prototype,`nGroups`);var Oo=Do,ko=Object.defineProperty,Ao=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&ko(t,n,i),i},jo=class extends Ta{getVarSelectorRecords(){let e=this.numVarSelectorRecords;return this.view.seek(10),Array.from({length:e},()=>{let e={varSelector:this.view.readUint24(),defaultUVSOffset:this.view.readUint32(),unicodeValueRanges:[],nonDefaultUVSOffset:this.view.readUint32(),uVSMappings:[]};if(e.defaultUVSOffset){this.view.seek(e.defaultUVSOffset);let t=this.view.readUint32();e.unicodeValueRanges=Array.from({length:t},()=>({startUnicodeValue:this.view.readUint24(),additionalCount:this.view.readUint8()}))}if(e.nonDefaultUVSOffset){this.view.seek(e.nonDefaultUVSOffset);let t=this.view.readUint32();e.uVSMappings=Array.from({length:t},()=>({unicodeValue:this.view.readUint24(),glyphID:this.view.readUint16()}))}return e})}getUnicodeToGlyphIndexMap(){let e=new Map,t=this.getVarSelectorRecords();for(let n=0,r=t.length;n<r;n++){let{uVSMappings:r}=t[n];r.forEach(t=>{e.set(t.unicodeValue,t.glyphID)})}return e}};Ao([J(`uint16`)],jo.prototype,`format`),Ao([J(`uint32`)],jo.prototype,`length`),Ao([J(`uint32`)],jo.prototype,`numVarSelectorRecords`);var Mo=Object.defineProperty,No=Object.getOwnPropertyDescriptor,Po=(e,t,n,r)=>{for(var i=r>1?void 0:r?No(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Mo(t,n,i),i},Fo=class extends ro{static from(e){let t=Array.from(e.keys()).some(e=>e>65535),n=xo.from(e),r=fo.from(e),i=t?Oo.from(e):void 0,a=4+(i?32:24),o=a+n.view.byteLength,s=o+r.view.byteLength,c=[{platformID:0,platformSpecificID:3,offset:a},{platformID:1,platformSpecificID:0,offset:o},{platformID:3,platformSpecificID:1,offset:a},i&&{platformID:3,platformSpecificID:10,offset:s}].filter(Boolean),l=new Fo(new ArrayBuffer(4+8*c.length+n.view.byteLength+r.view.byteLength+(i?.view.byteLength??0)));return l.numberSubtables=c.length,l.view.seek(4),c.forEach(e=>{l.view.writeUint16(e.platformID),l.view.writeUint16(e.platformSpecificID),l.view.writeUint32(e.offset)}),l.view.writeBytes(n.view,a),l.view.writeBytes(r.view,o),i&&l.view.writeBytes(i.view,s),l}_unicodeToGlyphIndexMap;get unicodeToGlyphIndexMap(){return this._unicodeToGlyphIndexMap??=this.readunicodeToGlyphIndexMap()}_glyphIndexToUnicodesMap;get glyphIndexToUnicodesMap(){if(!this._glyphIndexToUnicodesMap){let e=new Map,t=this.unicodeToGlyphIndexMap,n=Array.from(t.keys());for(let r=0,i=n.length;r<i;r++){let i=n[r],a=t.get(i);e.has(a)?e.get(a).push(i):e.set(a,[i])}this._glyphIndexToUnicodesMap=e}return this._glyphIndexToUnicodesMap}readSubtables(){let e=this.numberSubtables;return this.view.seek(4),Array.from({length:e},()=>({platformID:this.view.readUint16(),platformSpecificID:this.view.readUint16(),offset:this.view.readUint32()})).map(e=>{this.view.seek(e.offset);let t=this.view.readUint16(),n;switch(t){case 0:n=new fo(this.view.buffer,this.view.byteOffset+e.offset);break;case 2:n=new ho(this.view.buffer,this.view.byteOffset+e.offset,this.view.readUint16());break;case 4:n=new xo(this.view.buffer,this.view.byteOffset+e.offset,this.view.readUint16());break;case 6:n=new wo(this.view.buffer,this.view.byteOffset+e.offset,this.view.readUint16());break;case 12:n=new Oo(this.view.buffer,this.view.byteOffset+e.offset,this.view.readUint32(e.offset+4));break;default:n=new jo(this.view.buffer,this.view.byteOffset+e.offset,this.view.readUint32());break}return{...e,format:t,view:n}})}readunicodeToGlyphIndexMap(){let e=this.readSubtables(),t=e.find(e=>e.format===0)?.view,n=e.find(e=>e.platformID===3&&e.platformSpecificID===3&&e.format===2)?.view,r=e.find(e=>e.platformID===3&&e.platformSpecificID===1&&e.format===4)?.view,i=e.find(e=>e.platformID===3&&e.platformSpecificID===10&&e.format===12)?.view,a=e.find(e=>e.platformID===0&&e.platformSpecificID===5&&e.format===14)?.view;return new Map([...t?.getUnicodeToGlyphIndexMap()??[],...n?.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs)??[],...r?.getUnicodeToGlyphIndexMap()??[],...i?.getUnicodeToGlyphIndexMap()??[],...a?.getUnicodeToGlyphIndexMap()??[]])}};Po([J(`uint16`)],Fo.prototype,`version`,2),Po([J(`uint16`)],Fo.prototype,`numberSubtables`,2),Fo=Po([to(`cmap`)],Fo);var Io=class extends Fa{_parseContours(e){let t=[],n=[];for(let r=0;r<e.length;r+=1){let i=e[r];n.push(i),i.lastPointOfContour&&(t.push(n),n=[])}return ha(n.length===0,`There are still points left in the current contour.`),t}_transformPoints(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r],a={x:t.xScale*i.x+t.scale10*i.y+t.dx,y:t.scale01*i.x+t.yScale*i.y+t.dy,onCurve:i.onCurve,lastPointOfContour:i.lastPointOfContour};n.push(a)}return n}_parseGlyphCoordinate(e,t,n,r,i){let a;return(t&r)>0?(a=e.view.readUint8(),(t&i)===0&&(a=-a),a=n+a):a=(t&i)>0?n:n+e.view.readInt16(),a}parse(e,t,n){e.view.seek(t);let r=this.numberOfContours=e.view.readInt16();if(this.xMin=e.view.readInt16(),this.yMin=e.view.readInt16(),this.xMax=e.view.readInt16(),this.yMax=e.view.readInt16(),r>0){let t=this.endPointIndices=[];for(let n=0;n<r;n++)t.push(e.view.readUint16());let n=this.instructionLength=e.view.readUint16();ha(n<5e3,`Bad instructionLength:${n}`);let i=this.instructions=[];for(let t=0;t<n;++t)i.push(e.view.readUint8());let a=e.view.byteOffset,o=t[t.length-1]+1;ha(o<2e4,`Bad numberOfCoordinates:${a}`);let s=[],c,l=0;for(;l<o;)if(c=e.view.readUint8(),s.push(c),l++,c&8&&l<o){let t=e.view.readUint8();for(let e=0;e<t;e++)s.push(c),l++}if(ha(s.length===o,`Bad flags length: ${s.length}, numberOfCoordinates: ${o}`),t.length>0){let n=[],r;if(o>0){for(let e=0;e<o;e+=1)c=s[e],r={},r.onCurve=!!(c&1),r.lastPointOfContour=t.includes(e),n.push(r);let i=0;for(let t=0;t<o;t+=1)c=s[t],r=n[t],r.x=this._parseGlyphCoordinate(e,c,i,2,16),i=r.x;let a=0;for(let t=0;t<o;t+=1)c=s[t],r=n[t],r.y=this._parseGlyphCoordinate(e,c,a,4,32),a=r.y}this.points=n}else this.points=[]}else if(r===0)this.points=[];else{this.isComposite=!0,this.points=[],this.components=[];let t,n=!0;for(;n;){t=e.view.readUint16();let r={glyphIndex:e.view.readUint16(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(t&1)>0?(t&2)>0?(r.dx=e.view.readInt16(),r.dy=e.view.readInt16()):r.matchedPoints=[e.view.readUint16(),e.view.readUint16()]:(t&2)>0?(r.dx=e.view.readInt8(),r.dy=e.view.readInt8()):r.matchedPoints=[e.view.readUint8(),e.view.readUint8()],(t&8)>0?r.xScale=r.yScale=e.view.readInt16()/16384:(t&64)>0?(r.xScale=e.view.readInt16()/16384,r.yScale=e.view.readInt16()/16384):(t&128)>0&&(r.xScale=e.view.readInt16()/16384,r.scale01=e.view.readInt16()/16384,r.scale10=e.view.readInt16()/16384,r.yScale=e.view.readInt16()/16384),this.components.push(r),n=!!(t&32)}if(t&256){this.instructionLength=e.view.readUint16(),this.instructions=[];for(let t=0;t<this.instructionLength;t+=1)this.instructions.push(e.view.readUint8())}}if(this.isComposite)for(let e=0;e<this.components.length;e+=1){let t=this.components[e],r=n.get(t.glyphIndex);if(r.getPathCommands(),r.points){let e;if(t.matchedPoints===void 0)e=this._transformPoints(r.points,t);else{ha(t.matchedPoints[0]>this.points.length-1||t.matchedPoints[1]>r.points.length-1,`Matched points out of range in ${this.name}`);let n=this.points[t.matchedPoints[0]],i=r.points[t.matchedPoints[1]],a={xScale:t.xScale,scale01:t.scale01,scale10:t.scale10,yScale:t.yScale,dx:0,dy:0};i=this._transformPoints([i],a)[0],a.dx=n.x-i.x,a.dy=n.y-i.y,e=this._transformPoints(r.points,a)}this.points=this.points.concat(e)}}let i=[],a=this._parseContours(this.points);for(let e=0,t=a.length;e<t;++e){let t=a[e],n=t[t.length-1],r=t[0];n.onCurve?i.push({type:`M`,x:n.x,y:n.y}):r.onCurve?i.push({type:`M`,x:r.x,y:r.y}):i.push({type:`M`,x:(n.x+r.x)*.5,y:(n.y+r.y)*.5});for(let e=0,a=t.length;e<a;++e)if(n=r,r=t[(e+1)%a],n.onCurve)i.push({type:`L`,x:n.x,y:n.y});else{let e=r;r.onCurve||(e={x:(n.x+r.x)*.5,y:(n.y+r.y)*.5}),i.push({type:`Q`,x1:n.x,y1:n.y,x:e.x,y:e.y})}i.push({type:`Z`})}this.pathCommands=i}},Lo=class extends Ra{get length(){return this._sfnt.loca.locations.length}_get(e){let t=this._sfnt.loca.locations,n=t[e],r=new Io({index:e});return n!==t[e+1]&&r.parse(this._sfnt.glyf,n,this),r}},Ro=Object.getOwnPropertyDescriptor,zo=(e,t,n,r)=>{for(var i=r>1?void 0:r?Ro(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},Bo=class extends ro{static from(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Bo(new ArrayBuffer(t));return e.forEach(e=>{n.view.writeBytes(e)}),n}_glyphs;get glyphs(){return this._glyphs??=new Lo(this._sfnt)}};Bo=zo([to(`glyf`)],Bo);function Vo(e,t){return String.fromCharCode(e.getUint8(t),e.getUint8(t+1),e.getUint8(t+2),e.getUint8(t+3))}function Ho(e,t,n){if(!t)return[];let r=e.getUint16(t,!1),i=new Set;for(let a=0;a<r;a++){let r=t+2+a*6;if(Vo(e,r)!==n)continue;let o=t+e.getUint16(r+4,!1),s=e.getUint16(o+2,!1);for(let t=0;t<s;t++)i.add(e.getUint16(o+4+t*2,!1))}return[...i]}function Uo(e,t,n){if(!t||n>=e.getUint16(t,!1))return;let r=t+e.getUint16(t+2+n*2,!1),i=e.getUint16(r+4,!1),a=[];for(let t=0;t<i;t++)a.push(r+e.getUint16(r+6+t*2,!1));return{lookupType:e.getUint16(r,!1),lookupFlag:e.getUint16(r+2,!1),subtableOffsets:a}}function Wo(e,t){let n=e.getUint16(t,!1),r=[];if(n===1){let n=e.getUint16(t+2,!1);for(let i=0;i<n;i++)r.push(e.getUint16(t+4+i*2,!1))}else if(n===2){let n=e.getUint16(t+2,!1);for(let i=0;i<n;i++){let n=t+4+i*6,a=e.getUint16(n,!1),o=e.getUint16(n+2,!1),s=e.getUint16(n+4,!1);for(let e=a;e<=o;e++)r[s++]=e}}return r}function Go(e,t){let n=new Map,r=e.getUint16(t,!1);if(r===1){let r=e.getUint16(t+2,!1),i=e.getUint16(t+4,!1);for(let a=0;a<i;a++)n.set(r+a,e.getUint16(t+6+a*2,!1))}else if(r===2){let r=e.getUint16(t+2,!1);for(let i=0;i<r;i++){let r=t+4+i*6,a=e.getUint16(r,!1),o=e.getUint16(r+2,!1),s=e.getUint16(r+4,!1);for(let e=a;e<=o;e++)n.set(e,s)}}return n}function Ko(e){let t=e,n=0;for(;t;)n+=t&1,t>>=1;return n*2}function qo(e,t,n){if(!(n&4))return 0;let r=t;return n&1&&(r+=2),n&2&&(r+=2),e.getInt16(r,!1)}var Jo=Object.defineProperty,Yo=Object.getOwnPropertyDescriptor,Xo=(e,t,n,r)=>{for(var i=r>1?void 0:r?Yo(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Jo(t,n,i),i},Zo=class extends ro{_format1Pairs;_classSubtables;getKerningValue(e,t){this._ensureKerning();let n=this._format1Pairs.get(e*65536+t);if(n!==void 0)return n;for(let n of this._classSubtables){if(!n.coverage.has(e))continue;let r=n.classDef1.get(e)??0,i=n.classDef2.get(t)??0,a=n.class1RecordsOffset+(r*n.class2Count+i)*n.recordSize,o=qo(this.view,a,n.valueFormat1);if(o)return o}return 0}_ensureKerning(){this._format1Pairs||(this._format1Pairs=new Map,this._classSubtables=[],Ho(this.view,this.featureListOffset,`kern`).forEach(e=>{let t=Uo(this.view,this.lookupListOffset,e);t?.subtableOffsets.forEach(e=>this._collectPairPos(e,t.lookupType))}))}_collectPairPos(e,t){let n=this.view;if(t===9){let t=n.readUint16(e+2),r=n.readUint32(e+4);this._collectPairPos(e+r,t);return}if(t!==2)return;let r=n.readUint16(e),i=Wo(n,e+n.readUint16(e+2)),a=n.readUint16(e+4),o=n.readUint16(e+6);if(r===1){let t=n.readUint16(e+8),r=2+Ko(a)+Ko(o);for(let o=0;o<t&&o<i.length;o++){let t=i[o],s=e+n.readUint16(e+10+o*2),c=n.readUint16(s),l=s+2;for(let e=0;e<c;e++){let e=n.readUint16(l),i=qo(n,l+2,a);i&&this._format1Pairs.set(t*65536+e,i),l+=r}}}else r===2&&this._classSubtables.push({coverage:new Set(i),classDef1:Go(n,e+n.readUint16(e+8)),classDef2:Go(n,e+n.readUint16(e+10)),class2Count:n.readUint16(e+14),class1RecordsOffset:e+16,recordSize:Ko(a)+Ko(o),valueFormat1:a})}};Xo([J(`uint16`)],Zo.prototype,`majorVersion`,2),Xo([J(`uint16`)],Zo.prototype,`minorVersion`,2),Xo([J(`uint16`)],Zo.prototype,`scriptListOffset`,2),Xo([J(`uint16`)],Zo.prototype,`featureListOffset`,2),Xo([J(`uint16`)],Zo.prototype,`lookupListOffset`,2),Zo=Xo([to(`GPOS`,`gpos`)],Zo);var Qo=Object.defineProperty,$o=Object.getOwnPropertyDescriptor,es=(e,t,n,r)=>{for(var i=r>1?void 0:r?$o(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Qo(t,n,i),i},ts=class extends ro{_singleSubstitutions;_ligatures;getSingleSubstitutions(e){let t=this._singleSubstitutions??=new Map,n=t.get(e);return n||(n=new Map,this._featureLookupIndices(e).forEach(e=>{let t=this.readLookup(e);t?.subtableOffsets.forEach(e=>{this._collectSingleSubstitutions(e,t.lookupType,n)})}),t.set(e,n)),n}getLigatures(e){let t=this._ligatures??=new Map,n=t.get(e);return n||(n=new Map,this._featureLookupIndices(e).forEach(e=>{let t=this.readLookup(e);t?.subtableOffsets.forEach(e=>{this._collectLigatures(e,t.lookupType,n)})}),t.set(e,n)),n}_collectLigatures(e,t,n){let r=this.view;if(t===7){let t=r.readUint16(e+2),i=r.readUint32(e+4);this._collectLigatures(e+i,t,n);return}if(t!==4)return;let i=this._readCoverage(e+r.readUint16(e+2)),a=r.readUint16(e+4);for(let t=0;t<a&&t<i.length;t++){let a=i[t],o=e+r.readUint16(e+6+t*2),s=r.readUint16(o),c=n.get(a)??[];for(let e=0;e<s;e++){let t=o+r.readUint16(o+2+e*2),n=r.readUint16(t),i=r.readUint16(t+2),a=[];for(let e=0;e<i-1;e++)a.push(r.readUint16(t+4+e*2));c.push({components:a,ligatureGlyph:n})}n.has(a)||n.set(a,c)}}readLookup(e){let t=this.lookupListOffset;if(!t)return;let n=this.view;if(e>=n.readUint16(t))return;let r=t+n.readUint16(t+2+e*2),i=n.readUint16(r+4),a=[];for(let e=0;e<i;e++)a.push(r+n.readUint16(r+6+e*2));return{lookupType:n.readUint16(r),lookupFlag:n.readUint16(r+2),subtableOffsets:a}}_featureLookupIndices(e){let t=this.featureListOffset;if(!t)return[];let n=this.view,r=n.readUint16(t),i=new Set;for(let a=0;a<r;a++){let r=t+2+a*6;if(n.readString(r,4)!==e)continue;let o=t+n.readUint16(r+4),s=n.readUint16(o+2);for(let e=0;e<s;e++)i.add(n.readUint16(o+4+e*2))}return Array.from(i)}_collectSingleSubstitutions(e,t,n){let r=this.view;if(t===7){let t=r.readUint16(e+2),i=r.readUint32(e+4);this._collectSingleSubstitutions(e+i,t,n);return}if(t!==1)return;let i=r.readUint16(e),a=this._readCoverage(e+r.readUint16(e+2));if(i===1){let t=r.readInt16(e+4);a.forEach(e=>{n.set(e,e+t&65535)})}else if(i===2){let t=r.readUint16(e+4);for(let i=0;i<t&&i<a.length;i++)n.set(a[i],r.readUint16(e+6+i*2))}}_readCoverage(e){let t=this.view,n=t.readUint16(e),r=[];if(n===1){let n=t.readUint16(e+2);for(let i=0;i<n;i++)r.push(t.readUint16(e+4+i*2))}else if(n===2){let n=t.readUint16(e+2);for(let i=0;i<n;i++){let n=e+4+i*6,a=t.readUint16(n),o=t.readUint16(n+2),s=t.readUint16(n+4);for(let e=a;e<=o;e++)r[s++]=e}}return r}};es([J(`uint16`)],ts.prototype,`majorVersion`,2),es([J(`uint16`)],ts.prototype,`minorVersion`,2),es([J(`uint16`)],ts.prototype,`scriptListOffset`,2),es([J(`uint16`)],ts.prototype,`featureListOffset`,2),es([J(`uint16`)],ts.prototype,`lookupListOffset`,2),ts=es([to(`GSUB`,`gsub`)],ts);var ns=Object.defineProperty,rs=Object.getOwnPropertyDescriptor,is=(e,t,n,r)=>{for(var i=r>1?void 0:r?rs(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ns(t,n,i),i},as=class extends ro{constructor(e=new ArrayBuffer(54),t){super(e,t,Math.min(54,e.byteLength-(t??0)))}};is([J(`fixed`)],as.prototype,`version`,2),is([J(`fixed`)],as.prototype,`fontRevision`,2),is([J(`uint32`)],as.prototype,`checkSumAdjustment`,2),is([J(`uint32`)],as.prototype,`magickNumber`,2),is([J(`uint16`)],as.prototype,`flags`,2),is([J(`uint16`)],as.prototype,`unitsPerEm`,2),is([J({type:`longDateTime`})],as.prototype,`created`,2),is([J({type:`longDateTime`})],as.prototype,`modified`,2),is([J(`int16`)],as.prototype,`xMin`,2),is([J(`int16`)],as.prototype,`yMin`,2),is([J(`int16`)],as.prototype,`xMax`,2),is([J(`int16`)],as.prototype,`yMax`,2),is([J(`uint16`)],as.prototype,`macStyle`,2),is([J(`uint16`)],as.prototype,`lowestRecPPEM`,2),is([J(`int16`)],as.prototype,`fontDirectionHint`,2),is([J(`int16`)],as.prototype,`indexToLocFormat`,2),is([J(`int16`)],as.prototype,`glyphDataFormat`,2),as=is([to(`head`)],as);var os=Object.defineProperty,ss=Object.getOwnPropertyDescriptor,cs=(e,t,n,r)=>{for(var i=r>1?void 0:r?ss(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&os(t,n,i),i},ls=class extends ro{constructor(e=new ArrayBuffer(36),t){super(e,t,Math.min(36,e.byteLength-(t??0)))}};cs([J(`fixed`)],ls.prototype,`version`,2),cs([J(`int16`)],ls.prototype,`ascent`,2),cs([J(`int16`)],ls.prototype,`descent`,2),cs([J(`int16`)],ls.prototype,`lineGap`,2),cs([J(`uint16`)],ls.prototype,`advanceWidthMax`,2),cs([J(`int16`)],ls.prototype,`minLeftSideBearing`,2),cs([J(`int16`)],ls.prototype,`minRightSideBearing`,2),cs([J(`int16`)],ls.prototype,`xMaxExtent`,2),cs([J(`int16`)],ls.prototype,`caretSlopeRise`,2),cs([J(`int16`)],ls.prototype,`caretSlopeRun`,2),cs([J(`int16`)],ls.prototype,`caretOffset`,2),cs([J({type:`int16`,size:4})],ls.prototype,`reserved`,2),cs([J(`int16`)],ls.prototype,`metricDataFormat`,2),cs([J(`uint16`)],ls.prototype,`numOfLongHorMetrics`,2),ls=cs([to(`hhea`)],ls);var us=Object.getOwnPropertyDescriptor,ds=(e,t,n,r)=>{for(var i=r>1?void 0:r?us(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},fs=class extends ro{static from(e){let t=e.length*4,n=new fs(new ArrayBuffer(t));return e.forEach(e=>{n.view.writeUint16(e.advanceWidth),n.view.writeUint16(e.leftSideBearing)}),n}_metrics;get metrics(){return this._metrics??=this.readMetrics()}readMetrics(){let e=this._sfnt.maxp.numGlyphs,t=this._sfnt.hhea.numOfLongHorMetrics,n=0,r=this.view;return r.seek(0),Array.from({length:e}).map((e,i)=>(i<t&&(n=r.readUint16()),{advanceWidth:n,leftSideBearing:r.readUint16()}))}};fs=ds([to(`hmtx`)],fs);var ps=Object.getOwnPropertyDescriptor,ms=(e,t,n,r)=>{for(var i=r>1?void 0:r?ps(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},hs=class extends ro{_pairs;get pairs(){return this._pairs??=this._readPairs()}getKerningValue(e,t){return this.pairs.get(e*65536+t)??0}_readPairs(){let e=this.view,t=new Map;if(e.byteLength<4||e.readUint16(0)!==0)return t;let n=e.readUint16(2),r=4;for(let i=0;i<n&&r+6<=e.byteLength;i++){let n=e.readUint16(r+2),i=e.readUint16(r+4),a=i>>8,o=(i&1)!=0;if(a===0&&o){let n=e.readUint16(r+6),i=r+14;for(let r=0;r<n;r++){let n=e.readUint16(i),r=e.readUint16(i+2),a=e.readInt16(i+4);t.set(n*65536+r,a),i+=6}}if(n<=0)break;r+=n}return t}};hs=ms([to(`kern`,`kern`)],hs);var gs=Object.getOwnPropertyDescriptor,_s=(e,t,n,r)=>{for(var i=r>1?void 0:r?gs(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},vs=class extends ro{static from(e,t=1){let n=e.length*(t?4:2),r=new vs(new ArrayBuffer(n));return e.forEach(e=>{t?r.view.writeUint32(e):r.view.writeUint16(e/2)}),r}_locations;get locations(){return this._locations??=this.readLocations()}readLocations(){let e=this._sfnt.maxp.numGlyphs,t=this._sfnt.head.indexToLocFormat,n=this.view;return n.seek(0),Array.from({length:e}).map(()=>t?n.readUint32():n.readUint16()*2)}};vs=_s([to(`loca`)],vs);var ys=Object.defineProperty,bs=Object.getOwnPropertyDescriptor,xs=(e,t,n,r)=>{for(var i=r>1?void 0:r?bs(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ys(t,n,i),i},Ss=class extends ro{constructor(e=new ArrayBuffer(32),t){super(e,t,Math.min(32,e.byteLength-(t??0)))}};xs([J(`fixed`)],Ss.prototype,`version`,2),xs([J(`uint16`)],Ss.prototype,`numGlyphs`,2),xs([J(`uint16`)],Ss.prototype,`maxPoints`,2),xs([J(`uint16`)],Ss.prototype,`maxContours`,2),xs([J(`uint16`)],Ss.prototype,`maxComponentPoints`,2),xs([J(`uint16`)],Ss.prototype,`maxComponentContours`,2),xs([J(`uint16`)],Ss.prototype,`maxZones`,2),xs([J(`uint16`)],Ss.prototype,`maxTwilightPoints`,2),xs([J(`uint16`)],Ss.prototype,`maxStorage`,2),xs([J(`uint16`)],Ss.prototype,`maxFunctionDefs`,2),xs([J(`uint16`)],Ss.prototype,`maxInstructionDefs`,2),xs([J(`uint16`)],Ss.prototype,`maxStackElements`,2),xs([J(`uint16`)],Ss.prototype,`maxSizeOfInstructions`,2),xs([J(`uint16`)],Ss.prototype,`maxComponentElements`,2),xs([J(`uint16`)],Ss.prototype,`maxComponentDepth`,2),Ss=xs([to(`maxp`)],Ss);var Cs=Object.defineProperty,ws=Object.getOwnPropertyDescriptor,Ts=(e,t,n,r)=>{for(var i=r>1?void 0:r?ws(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Cs(t,n,i),i},Es={0:`copyright`,1:`fontFamily`,2:`fontSubFamily`,3:`uniqueSubFamily`,4:`fullName`,5:`version`,6:`postScriptName`,7:`tradeMark`,8:`manufacturer`,9:`designer`,10:`description`,11:`urlOfFontVendor`,12:`urlOfFontDesigner`,13:`licence`,14:`urlOfLicence`,16:`preferredFamily`,17:`preferredSubFamily`,18:`compatibleFull`,19:`sampleText`},Ds={Macintosh:1,Microsoft:3},Os={Default:0},ks={UCS2:1},As=class extends ro{_names;get names(){return this._names??=this.readNames()}readNames(){let e=this.count;this.view.seek(6);let t=[];for(let n=0;n<e;++n)t.push({platform:this.view.readUint16(),encoding:this.view.readUint16(),language:this.view.readUint16(),nameId:this.view.readUint16(),length:this.view.readUint16(),offset:this.view.readUint16()});let n=this.stringOffset;for(let r=0;r<e;++r){let e=t[r];e.name=this.view.readBytes(n+e.offset,e.length)}let r=Ds.Macintosh,i=Os.Default,a=0;t.some(e=>e.platform===Ds.Microsoft&&e.encoding===ks.UCS2&&e.language===1033)&&(r=Ds.Microsoft,i=ks.UCS2,a=1033);let o={};for(let n=0;n<e;++n){let e=t[n];e.platform===r&&e.encoding===i&&e.language===a&&Es[e.nameId]&&(o[Es[e.nameId]]=a===0?ba(e.name):xa(e.name))}return o}};Ts([J(`uint16`)],As.prototype,`format`,2),Ts([J(`uint16`)],As.prototype,`count`,2),Ts([J(`uint16`)],As.prototype,`stringOffset`,2),As=Ts([to(`name`)],As);var js=Object.defineProperty,Ms=Object.getOwnPropertyDescriptor,Q=(e,t,n,r)=>{for(var i=r>1?void 0:r?Ms(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&js(t,n,i),i},$=class extends ro{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};Q([J(`uint16`)],$.prototype,`version`,2),Q([J(`int16`)],$.prototype,`xAvgCharWidth`,2),Q([J(`uint16`)],$.prototype,`usWeightClass`,2),Q([J(`uint16`)],$.prototype,`usWidthClass`,2),Q([J(`uint16`)],$.prototype,`fsType`,2),Q([J(`uint16`)],$.prototype,`ySubscriptXSize`,2),Q([J(`uint16`)],$.prototype,`ySubscriptYSize`,2),Q([J(`uint16`)],$.prototype,`ySubscriptXOffset`,2),Q([J(`uint16`)],$.prototype,`ySubscriptYOffset`,2),Q([J(`uint16`)],$.prototype,`ySuperscriptXSize`,2),Q([J(`uint16`)],$.prototype,`ySuperscriptYSize`,2),Q([J(`uint16`)],$.prototype,`ySuperscriptXOffset`,2),Q([J(`uint16`)],$.prototype,`ySuperscriptYOffset`,2),Q([J(`uint16`)],$.prototype,`yStrikeoutSize`,2),Q([J(`uint16`)],$.prototype,`yStrikeoutPosition`,2),Q([J(`uint16`)],$.prototype,`sFamilyClass`,2),Q([J({type:`uint8`})],$.prototype,`bFamilyType`,2),Q([J({type:`uint8`})],$.prototype,`bSerifStyle`,2),Q([J({type:`uint8`})],$.prototype,`bWeight`,2),Q([J({type:`uint8`})],$.prototype,`bProportion`,2),Q([J({type:`uint8`})],$.prototype,`bContrast`,2),Q([J({type:`uint8`})],$.prototype,`bStrokeVariation`,2),Q([J({type:`uint8`})],$.prototype,`bArmStyle`,2),Q([J({type:`uint8`})],$.prototype,`bLetterform`,2),Q([J({type:`uint8`})],$.prototype,`bMidline`,2),Q([J({type:`uint8`})],$.prototype,`bXHeight`,2),Q([J({type:`uint32`,size:4})],$.prototype,`ulUnicodeRange`,2),Q([J({type:`char`,size:4})],$.prototype,`achVendID`,2),Q([J(`uint16`)],$.prototype,`fsSelection`,2),Q([J(`uint16`)],$.prototype,`usFirstCharIndex`,2),Q([J(`uint16`)],$.prototype,`usLastCharIndex`,2),Q([J(`int16`)],$.prototype,`sTypoAscender`,2),Q([J(`int16`)],$.prototype,`sTypoDescender`,2),Q([J(`int16`)],$.prototype,`sTypoLineGap`,2),Q([J(`uint16`)],$.prototype,`usWinAscent`,2),Q([J(`uint16`)],$.prototype,`usWinDescent`,2),Q([J({offset:78,type:`uint32`,size:2})],$.prototype,`ulCodePageRange`,2),Q([J({offset:86,type:`int16`})],$.prototype,`sxHeight`,2),Q([J(`int16`)],$.prototype,`sCapHeight`,2),Q([J(`uint16`)],$.prototype,`usDefaultChar`,2),Q([J(`uint16`)],$.prototype,`usBreakChar`,2),Q([J(`uint16`)],$.prototype,`usMaxContext`,2),$=Q([to(`OS/2`,`os2`)],$);var Ns=`.notdef,.null,nonmarkingreturn,space,exclam,quotedbl,numbersign,dollar,percent,ampersand,quotesingle,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,grave,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,Adieresis,Aring,Ccedilla,Eacute,Ntilde,Odieresis,Udieresis,aacute,agrave,acircumflex,adieresis,atilde,aring,ccedilla,eacute,egrave,ecircumflex,edieresis,iacute,igrave,icircumflex,idieresis,ntilde,oacute,ograve,ocircumflex,odieresis,otilde,uacute,ugrave,ucircumflex,udieresis,dagger,degree,cent,sterling,section,bullet,paragraph,germandbls,registered,copyright,trademark,acute,dieresis,notequal,AE,Oslash,infinity,plusminus,lessequal,greaterequal,yen,mu,partialdiff,summation,product,pi,integral,ordfeminine,ordmasculine,Omega,ae,oslash,questiondown,exclamdown,logicalnot,radical,florin,approxequal,Delta,guillemotleft,guillemotright,ellipsis,nonbreakingspace,Agrave,Atilde,Otilde,OE,oe,endash,emdash,quotedblleft,quotedblright,quoteleft,quoteright,divide,lozenge,ydieresis,Ydieresis,fraction,currency,guilsinglleft,guilsinglright,fi,fl,daggerdbl,periodcentered,quotesinglbase,quotedblbase,perthousand,Acircumflex,Ecircumflex,Aacute,Edieresis,Egrave,Iacute,Icircumflex,Idieresis,Igrave,Oacute,Ocircumflex,apple,Ograve,Uacute,Ucircumflex,Ugrave,dotlessi,circumflex,tilde,macron,breve,dotaccent,ring,cedilla,hungarumlaut,ogonek,caron,Lslash,lslash,Scaron,scaron,Zcaron,zcaron,brokenbar,Eth,eth,Yacute,yacute,Thorn,thorn,minus,multiply,onesuperior,twosuperior,threesuperior,onehalf,onequarter,threequarters,franc,Gbreve,gbreve,Idotaccent,Scedilla,scedilla,Cacute,cacute,Ccaron,ccaron,dcroat`.split(`,`),Ps=Object.defineProperty,Fs=Object.getOwnPropertyDescriptor,Is=(e,t,n,r)=>{for(var i=r>1?void 0:r?Fs(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ps(t,n,i),i},Ls=class extends ro{_glyphNames;get glyphNames(){return this._glyphNames??=this._readGlyphNames()}getGlyphName(e){return this.glyphNames[e]}_readGlyphNames(){let e=this.format;if(e===1)return Ns.slice();if(e!==2)return[];let t=this.view,n=t.readUint16(32),r=[];for(let e=0;e<n;e++)r.push(t.readUint16(34+e*2));let i=[],a=34+n*2,o=t.byteLength;for(;a<o;){let e=t.readUint8(a);a+=1,i.push(t.readString(a,e)),a+=e}return r.map(e=>e<258?Ns[e]:i[e-258]??``)}constructor(e=new ArrayBuffer(32),t,n){super(e,t,n)}};Is([J(`fixed`)],Ls.prototype,`format`,2),Is([J(`fixed`)],Ls.prototype,`italicAngle`,2),Is([J(`int16`)],Ls.prototype,`underlinePosition`,2),Is([J(`int16`)],Ls.prototype,`underlineThickness`,2),Is([J(`uint32`)],Ls.prototype,`isFixedPitch`,2),Is([J(`uint32`)],Ls.prototype,`minMemType42`,2),Is([J(`uint32`)],Ls.prototype,`maxMemType42`,2),Is([J(`uint32`)],Ls.prototype,`minMemType1`,2),Is([J(`uint32`)],Ls.prototype,`maxMemType1`,2),Ls=Is([to(`post`)],Ls);var Rs=Object.defineProperty,zs=Object.getOwnPropertyDescriptor,Bs=(e,t,n,r)=>{for(var i=r>1?void 0:r?zs(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Rs(t,n,i),i},Vs=class extends ro{constructor(e=new ArrayBuffer(36),t){super(e,t,Math.min(36,e.byteLength-(t??0)))}};Bs([J(`fixed`)],Vs.prototype,`version`,2),Bs([J(`int16`)],Vs.prototype,`vertTypoAscender`,2),Bs([J(`int16`)],Vs.prototype,`vertTypoDescender`,2),Bs([J(`int16`)],Vs.prototype,`vertTypoLineGap`,2),Bs([J(`int16`)],Vs.prototype,`advanceHeightMax`,2),Bs([J(`int16`)],Vs.prototype,`minTopSideBearing`,2),Bs([J(`int16`)],Vs.prototype,`minBottomSideBearing`,2),Bs([J(`int16`)],Vs.prototype,`yMaxExtent`,2),Bs([J(`int16`)],Vs.prototype,`caretSlopeRise`,2),Bs([J(`int16`)],Vs.prototype,`caretSlopeRun`,2),Bs([J(`int16`)],Vs.prototype,`caretOffset`,2),Bs([J({type:`int16`,size:4})],Vs.prototype,`reserved`,2),Bs([J(`int16`)],Vs.prototype,`metricDataFormat`,2),Bs([J(`int16`)],Vs.prototype,`numOfLongVerMetrics`,2),Vs=Bs([to(`vhea`)],Vs);var Hs=Object.getOwnPropertyDescriptor,Us=(e,t,n,r)=>{for(var i=r>1?void 0:r?Hs(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},Ws=class extends ro{static from(e){let t=e.length*4,n=new Ws(new ArrayBuffer(t));return e.forEach(e=>{n.view.writeUint16(e.advanceHeight),n.view.writeInt16(e.topSideBearing)}),n}_metrics;get metrics(){return this._metrics??=this.readMetrics()}readMetrics(){let e=this._sfnt.maxp.numGlyphs,t=this._sfnt.vhea?.numOfLongVerMetrics??0,n=this.view;n.seek(0);let r=0;return Array.from({length:e}).map((e,i)=>(i<t&&(r=n.readUint16()),{advanceHeight:r,topSideBearing:n.readInt16()}))}};Ws=Us([to(`vmtx`)],Ws);var Gs=Object.defineProperty,Ks=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&Gs(t,n,i),i},qs=class extends Ea{format=`TrueType`;mimeType=`font/ttf`;_sfnt;get sfnt(){return this._sfnt||=this.createSFNT(),this._sfnt}static signature=new Set([65536,1953658213,1954115633]);static is(e){return typeof e==`number`?this.signature.has(e):this.signature.has(_a(e).getUint32(0))}static checksum(e){let t=_a(e),n=t.byteLength,r=Math.floor(n/4),i=0;for(let e=0;e<r;e++)i+=t.getUint32(e*4,!1);let a=n-r*4;if(a>0){let e=0,n=r*4;for(let r=0;r<4;r++)e=e*256+(r<a?t.getUint8(n+r):0);i+=e}return i%4294967296}static from(e){let t=e=>e+3&-4,n=e.tableTags,r=n.map(t=>e.getTableView(t)),i=n.length,a=r.reduce((e,n)=>e+t(n.byteLength),0),o=new this(new ArrayBuffer(12+i*16+a));o.scalerType=65536,o.numTables=i;let s=Math.floor(Math.log2(i));o.searchRange=2**s*16,o.entrySelector=s,o.rangeShift=i*16-o.searchRange;let c=12+i*16,l=o.getDirectories();n.forEach((e,n)=>{let i=r[n],a=l[n];a.tag=e,a.checkSum=this.checksum(i),a.offset=c,a.length=i.byteLength,o.view.writeBytes(i,c),c+=t(a.length)});let u=l.find(e=>e.tag===`head`);if(u){let e=u.offset+8;o.view.writeUint32(0,e),o.view.writeUint32(2981146554-this.checksum(o.view)>>>0,e)}return o}getDirectories(){let e=this.view.byteOffset+12;return Array.from({length:this.numTables},()=>{let t=new Ma(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new no(this.getDirectories().reduce((e,t)=>(e[t.tag]=new DataView(this.view.buffer,this.view.byteOffset+t.offset,t.length),e),{}))}};Ks([J(`uint32`)],qs.prototype,`scalerType`),Ks([J(`uint16`)],qs.prototype,`numTables`),Ks([J(`uint16`)],qs.prototype,`searchRange`),Ks([J(`uint16`)],qs.prototype,`entrySelector`),Ks([J(`uint16`)],qs.prototype,`rangeShift`);var Js=class extends qs{format=`OpenType`;mimeType=`font/otf`;static signature=new Set([1330926671]);static from(e){return super.from(e)}},Ys=class{static signature=1953784678;static is(e){let t=_a(e);return t.byteLength>=12&&t.getUint32(0,!1)===this.signature}view;numFonts;constructor(e){this.view=_a(e),this.numFonts=this.view.getUint32(8,!1)}get sfnts(){return Array.from({length:this.numFonts},(e,t)=>this._readSFNT(this.view.getUint32(12+t*4,!1)))}get fonts(){return this.sfnts.map(e=>e.hasTable(`CFF `)?Js.from(e):qs.from(e))}_readSFNT(e){let t=this.view,n=t.byteOffset,r=t.getUint16(e+4,!1),i=new Map;for(let a=0;a<r;a++){let r=e+12+a*16,o=String.fromCharCode(t.getUint8(r),t.getUint8(r+1),t.getUint8(r+2),t.getUint8(r+3)),s=t.getUint32(r+8,!1),c=t.getUint32(r+12,!1);i.set(o,new DataView(t.buffer,n+s,c))}return new no(i)}},Xs=Object.defineProperty,Zs=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&Xs(t,n,i),i},Qs=class extends Ta{constructor(e,t){super(e,t,20)}};Zs([J({type:`char`,size:4})],Qs.prototype,`tag`),Zs([J(`uint32`)],Qs.prototype,`offset`),Zs([J(`uint32`)],Qs.prototype,`compLength`),Zs([J(`uint32`)],Qs.prototype,`origLength`),Zs([J(`uint32`)],Qs.prototype,`origChecksum`);var $s=Object.defineProperty,ec=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&$s(t,n,i),i};function tc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function nc(e){return new Promise((t,n)=>{la(e,(e,r)=>e?n(e):t(r))})}function rc(e){return new Promise((t,n)=>{da(e,(e,r)=>e?n(e):t(r))})}var ic=class e extends Ea{format=`WOFF`;mimeType=`font/woff`;get subfontFormat(){return qs.is(this.flavor)?`TrueType`:Js.is(this.flavor)?`OpenType`:`Open`}_sfnt;get sfnt(){return this._sfnt||=this.createSFNT(),this._sfnt}static signature=new Set([2001684038]);static is(e){return typeof e==`number`?this.signature.has(e):this.signature.has(_a(e).getUint32(0))}static checkSum(e){let t=_a(e),n=t.byteLength,r=Math.floor(n/4),i=0,a=0;for(;a<r;)i+=t.getUint32(4*a++,!1);let o=n-r*4;if(o){let e=r*4;for(;o>0;)i+=t.getUint8(e)<<o*8,e++,o--}return i%4294967296}static _pickTable(e,t,n){return{tag:e,view:n.byteLength<t.byteLength?n:t,rawView:t}}static from(e,t=new ArrayBuffer(0)){let n=e.tableTags.map(t=>{let n=e.getTableView(t);return this._pickTable(t,n,_a(ua(tc(n))))});return this._assemble(n,t)}static async fromAsync(e,t=new ArrayBuffer(0)){let n=await Promise.all(e.tableTags.map(async t=>{let n=e.getTableView(t);return this._pickTable(t,n,_a(await nc(tc(n))))}));return this._assemble(n,t)}static _assemble(t,n){let r=e=>e+3&-4,i=t.length,a=t.reduce((e,t)=>e+r(t.view.byteLength),0),o=new e(new ArrayBuffer(44+20*i+a+n.byteLength));o.signature=2001684038,o.flavor=65536,o.length=o.view.byteLength,o.numTables=i,o.totalSFNTSize=12+16*i+t.reduce((e,t)=>e+r(t.rawView.byteLength),0);let s=44+i*20,c=0,l=o.getDirectories();return t.forEach(t=>{let n=l[c++];n.tag=t.tag,n.offset=s,n.compLength=t.view.byteLength,n.origChecksum=e.checkSum(t.rawView),n.origLength=t.rawView.byteLength,o.view.writeBytes(t.view,s),s+=r(n.compLength)}),o.view.writeBytes(n),o}getDirectories(){let e=44;return Array.from({length:this.numTables},()=>{let t=new Qs(this.view.buffer,e);return e+=t.view.byteLength,t})}_decodeTable(e,t,n){if(t>=n)return new DataView(this.view.buffer,e,t);let r=fa(new Uint8Array(this.view.buffer.slice(e,e+t)));return new DataView(r.buffer,r.byteOffset,r.byteLength)}createSFNT(){let e=new Map;return this.getDirectories().forEach(t=>{let n=t.tag,r=this.view.byteOffset+t.offset,i=t.compLength,a=t.origLength;e.set(n,()=>this._decodeTable(r,i,a))}),new no(void 0,e)}async createSFNTAsync(){let e=await Promise.all(this.getDirectories().map(async e=>{let t=e.tag,n=this.view.byteOffset+e.offset,r=e.compLength,i=e.origLength,a;if(r>=i)a=new DataView(this.view.buffer,n,r);else{let e=await rc(new Uint8Array(this.view.buffer.slice(n,n+r)));a=new DataView(e.buffer,e.byteOffset,e.byteLength)}return[t,a]}));return new no(new Map(e))}};ec([J(`uint32`)],ic.prototype,`signature`),ec([J(`uint32`)],ic.prototype,`flavor`),ec([J(`uint32`)],ic.prototype,`length`),ec([J(`uint16`)],ic.prototype,`numTables`),ec([J(`uint16`)],ic.prototype,`reserved`),ec([J(`uint32`)],ic.prototype,`totalSFNTSize`),ec([J(`uint16`)],ic.prototype,`majorVersion`),ec([J(`uint16`)],ic.prototype,`minorVersion`),ec([J(`uint32`)],ic.prototype,`metaOffset`),ec([J(`uint32`)],ic.prototype,`metaLength`),ec([J(`uint32`)],ic.prototype,`metaOrigLength`),ec([J(`uint32`)],ic.prototype,`privOffset`),ec([J(`uint32`)],ic.prototype,`privLength`);var ac=ic;function oc(e,t=!0){if(qs.is(e))return new qs(e);if(Js.is(e))return new Js(e);if(ac.is(e))return new ac(e);if(Ys.is(e)){let t=new Ys(e).fonts;if(t.length)return t[0]}if(t)throw Error(`Failed to parseFont`)}function sc(e,t=!0){let n=oc(e,!1);if(n)return n;if(t)throw Error(`Failed to parseFont`)}var cc=new class e{static defaultRequestInit={cache:`force-cache`};fallbackFont;loading=new Map;loaded=new Map;familyToUrl=new Map;setFallbackFont(e){this.fallbackFont=e}async loadFallbackFont(e,t={}){this.fallbackFont=await this.load(e,t)}_createRequest(t,n){let r=new AbortController;return{url:t,when:fetch(t,{...e.defaultRequestInit,...n,signal:r.signal}).then(e=>e.arrayBuffer()),cancel:()=>r.abort()}}async injectFontFace(e,t){if(!document.fonts.check(`14px "${e}"`)){let n=new FontFace(e,t);await n.load(),document.fonts.add(n)}}injectStyleTag(e,t){let n=CSS.escape(e);if(!document.querySelector(`style[data-family="${n}"]`)){let n=document.createElement(`style`);n.type=`text/css`,n.dataset.family=e,n.appendChild(document.createTextNode(`@font-face {
31
31
  font-family: "${e}";
32
32
  src: url(${t});
33
- }`)),document.head.appendChild(n)}return this}_parseUrls(e){let t=[...new Set([...e.split(`,`),e])];return[...new Set(t.map(e=>this.familyToUrl.get(e.trim())??this.familyToUrl.get(e)??e))]}get(e){let t;return e&&(t=this._parseUrls(e).reduce((e,t)=>e||this.loaded.get(t),void 0)),t??this.fallbackFont}set(e,t){return this.familyToUrl.set(e,t.src),this.loaded.set(t.src,t),this}delete(e){return this._parseUrls(e).forEach(e=>{this.familyToUrl.delete(e),this.loaded.delete(e)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}_parseFamilies(e){return e?(Array.isArray(e)?e:[e]).flatMap(e=>e.split(`,`).map(e=>e.trim())):[]}async load(e,t={}){let{cancelOther:n,injectStyleTag:r=!1,injectFontFace:i=!1,...a}=t,o,s;typeof e==`string`?o=e:{src:o,family:s}=e;let c=this._parseFamilies(s);if(this.loaded.has(o))return n&&(this.loading.forEach(e=>e.cancel()),this.loading.clear()),u(this.loaded.get(o));let l=this.loading.get(o);return l||(l=this._createRequest(o,a),this.loading.set(o,l)),n&&this.loading.forEach((e,t)=>{e!==l&&(e.cancel(),this.loading.delete(t))}),l.when.then(e=>{let n;return this.loaded.has(o)?n=u(this.loaded.get(o)):(n=d(e),t.noAdd||this.loaded.set(o,n)),Promise.all(Array.from(n.familySet,async t=>{if(this.familyToUrl.set(t,o),typeof document<`u`&&(i&&await this.injectFontFace(t,e),r&&this.injectStyleTag(t,o),i||r))return await document.fonts.load(`14px "${t}"`)})).then(()=>n)}).catch(e=>{if(e instanceof DOMException&&e.message===`The user aborted a request.`)return d();throw e}).finally(()=>{this.loading.delete(o)});function u(e){return c.forEach(t=>{e.familySet.add(t)}),e}function d(e=new ArrayBuffer(0)){let t;function n(){return t||=e.byteLength?sc(e,!1):void 0,t}function r(){let e=n();if(e instanceof qs||e instanceof ac)return e.sfnt}return{src:o,family:s,buffer:e,familySet:new Set(c),getFont:n,getSFNT:r}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values(),e=>e.when))}},lc=new Set([`©`,`®`,`÷`]),uc=new Set([`—`,`…`,`“`,`”`,`﹏`,`﹋`,`﹌`,`‘`,`’`,`˜`]),dc={1:`italic`,32:`bold`},fc={1:`italic`,2:`bold`},pc={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5},mc=class{content;index;parent;path=new Wr().setMeta(this);lineBox=new W;inlineBox=new W;glyphBox;advanceWidth=0;advanceHeight=0;underlinePosition=0;underlineThickness=0;strikeoutPosition=0;strikeoutSize=0;ascender=0;descender=0;typoAscender=0;typoDescender=0;typoLineGap=0;winAscent=0;winDescent=0;xHeight=0;capHeight=0;baseline=0;centerDiviation=0;fontStyle;get compatibleGlyphBox(){let e=this.computedStyle.fontSize*.8;return this.glyphBox??(this.isVertical?new W(this.lineBox.left+this.lineBox.width/2-e/2,this.lineBox.top,e,this.lineBox.height):new W(this.lineBox.left,this.lineBox.top+this.lineBox.height/2-e/2,this.lineBox.width,e))}get center(){return this.compatibleGlyphBox.center}get computedFill(){return this.parent.computedFill}get computedOutline(){return this.parent.computedOutline}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes(`vertical`)}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}constructor(e,t,n){this.content=e,this.index=t,this.parent=n}_getFontSFNT(e){let t=this.computedStyle.fontFamily,n=e??cc,r=(t?n.get(t):n.fallbackFont)?.getSFNT();return r?.textToGlyphIndexes(this.content).includes(0)&&(r=n.fallbackFont?.getSFNT()),r}updateGlyph(e=this._getFontSFNT()){if(!e)return this;let{hhea:t,os2:n,post:r,head:i}=e,a=i.unitsPerEm,o=t.ascent,s=t.descent,{content:c,computedStyle:l}=this,{fontSize:u}=l,d=a/u,f=e.getAdvanceWidth(c,u),p=(o+Math.abs(s))/d,m=o/d;return this.advanceWidth=f,this.advanceHeight=p,this.underlinePosition=(o-r.underlinePosition)/d,this.underlineThickness=r.underlineThickness/d,this.strikeoutPosition=(o-n.yStrikeoutPosition)/d,this.strikeoutSize=n.yStrikeoutSize/d,this.ascender=o/d,this.descender=s/d,this.typoAscender=n.sTypoAscender/d,this.typoDescender=n.sTypoDescender/d,this.typoLineGap=n.sTypoLineGap/d,this.winAscent=n.usWinAscent/d,this.winDescent=n.usWinDescent/d,this.xHeight=n.version>1?n.sxHeight/d:0,this.capHeight=n.version>1?n.sCapHeight/d:0,this.baseline=m,this.centerDiviation=p/2-m,this.fontStyle=dc[n.fsSelection]??fc[i.macStyle],this}measureGlyph(e){return this.updateGlyph(this._getFontSFNT(e))}update(e){let t=this._getFontSFNT(e);if(!t)return this;this.updateGlyph(t);let{isVertical:n,content:r,computedStyle:i,baseline:a,inlineBox:o,ascender:s,descender:c,typoAscender:l,fontStyle:u,advanceWidth:d,advanceHeight:f}=this,{left:p,top:m}=o,h=i.fontStyle===`italic`&&u!==`italic`,g=p,_=m+a,v,y=new Wr().setMeta(this);if(n&&(g+=(f-d)/2,Math.abs(d-f)>.1&&(_-=(s-l)/(s+Math.abs(c))*f),v=void 0),n&&!lc.has(r)&&(r.codePointAt(0)<=256||uc.has(r))){y.addCommands(t.getPathCommands(r,g,m+a-(f-d)/2,i.fontSize));let e={y:m-(f-d)/2+f/2,x:g+d/2};h&&this._italic(y,{x:e.x,y:m-(f-d)/2+a}),y.rotate(Math.PI/2,e)}else v===void 0?(y.addCommands(t.getPathCommands(r,g,_,i.fontSize)),h&&this._italic(y,n?{x:g+f/2,y:_}:void 0)):(y.addCommands(t.glyphs.get(v).getPathCommands(g,_,i.fontSize)),h&&this._italic(y,n?{x:g+d/2,y:m+l/(s+Math.abs(c))*f}:void 0));let b=i.fontWeight??400;return b in pc&&(b===700||b===`bold`)&&u!==`bold`&&y.bold(pc[b]*i.fontSize*.05),y.style=j({fill:i.color,fillRule:`nonzero`,stroke:i.textStrokeWidth?i.textStrokeColor:void 0,strokeWidth:i.textStrokeWidth?i.textStrokeWidth*i.fontSize*.03:void 0}),this.path=y,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(e,t){e.skew(-.24,0,t||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(e,t,n){if(this.path.curves[0]?.curves.length)return this.path.getMinMax(e,t,n)}getGlyphBoundingBox(e){let t=this.getGlyphMinMax(void 0,void 0,e);if(!t)return;let{min:n,max:r}=t;return new W(n.x,n.y,r.x-n.x,r.y-n.y)}},hc=class{content;style;fill;outline;index;parent;inlineBox=new W;get computedContent(){let e=this.computedStyle;return e.textTransform===`uppercase`?this.content.toUpperCase():e.textTransform===`lowercase`?this.content.toLowerCase():this.content}constructor(e,t={},n,r,i,a){this.content=e,this.style=t,this.fill=n,this.outline=r,this.index=i,this.parent=a,this.update().initCharacters()}update(){this.computedStyle={...this.parent.computedStyle,...j(this.style)};let e=this.fill??this.parent.computedFill;this.computedFill=e?j(e):void 0;let t=this.outline??this.parent.computedOutline;return this.computedOutline=t?j(t):void 0,this}initCharacters(){let e=[],t=0;for(let n of this.computedContent)e.push(new mc(n,t++,this));return this.characters=e,this}},gc=class{style;index;parent;lineBox=new W;fragments=[];fill;outline;constructor(e,t,n){this.style=e,this.index=t,this.parent=n,this.update()}update(){this.computedStyle={...j(this.parent.computedStyle),...j(this.style)};let e=this.fill??this.parent.computedFill;this.computedFill=e?j(e):void 0;let t=this.outline??this.parent.computedOutline;return this.computedOutline=t?j(t):void 0,this}};function _c(e){return e}var vc;function yc(){if(vc?.isConnected)return vc;let e=document.createElement(`div`);return e.dataset.modernText=`measurer`,Object.assign(e.style,{position:`fixed`,left:`0`,top:`0`,visibility:`hidden`,pointerEvents:`none`}),document.body.appendChild(e),vc=e,e}var bc=class e{static notZeroStyles=new Set([`width`,`height`]);static pxStyles=new Set([`width`,`height`,`fontSize`,`letterSpacing`,`textStrokeWidth`,`textIndent`,`shadowOffsetX`,`shadowOffsetY`,`shadowBlur`,`margin`,`marginLeft`,`marginTop`,`marginRight`,`marginBottom`,`padding`,`paddingLeft`,`paddingTop`,`paddingRight`,`paddingBottom`]);_styleCache=new WeakMap;_mountedDom;_mountedSignature;_toDomStyle(t){let n=this._styleCache.get(t);if(n)return n;let r={},{notZeroStyles:i,pxStyles:a}=e;for(let e in t){let n=t[e];i.has(e)&&n===0||(r[e]=typeof n==`number`&&a.has(e)?`${n}px`:n)}return this._styleCache.set(t,r),r}_resolveRootStyles(e){let t={...e},n=e.writingMode.includes(`horizontal`);switch(e.textAlign){case`start`:case`left`:t.justifyContent=`flex-start`;break;case`center`:t.justifyContent=`center`;break;case`end`:case`right`:t.justifyContent=`flex-end`;break}switch(e.verticalAlign){case`top`:t.alignItems=`flex-start`;break;case`middle`:t.alignItems=`center`;break;case`bottom`:t.alignItems=`flex-end`;break}let r=!!(t.justifyContent||t.alignItems);return{section:{...this._toDomStyle({...t,boxSizing:t.boxSizing??`border-box`,display:t.display??(r?`inline-flex`:void 0),width:t.width??`max-content`,height:t.height??`max-content`}),whiteSpace:`pre-wrap`,wordBreak:`break-all`},ul:{verticalAlign:`inherit`,listStyleType:`inherit`,padding:`0`,margin:`0`,width:r&&n?`100%`:void 0,height:r&&!n?`100%`:void 0}}}_applyRootStyle(e,t,n){let r=this._resolveRootStyles(n);e.removeAttribute(`style`),Object.assign(e.style,r.section),t.removeAttribute(`style`),Object.assign(t.style,r.ul)}_applyLiStyle(e,t){e.removeAttribute(`style`),e.style.verticalAlign=`inherit`,Object.assign(e.style,this._toDomStyle(t.style))}_applySpanStyle(e,t){e.removeAttribute(`style`),e.style.verticalAlign=`inherit`,Object.assign(e.style,this._toDomStyle(t.style))}_applyFragmentContent(e,t){let n=e.firstChild;n?n.data!==t.content&&(n.data=t.content):e.appendChild(document.createTextNode(t.content))}_hide(e){e.style.visibility=`hidden`}_signature(e){let t=`${e.length}`;for(let n=0;n<e.length;n++)t+=`:${e[n].fragments.length}`;return t}createDom(e,t){let n=document.createElement(`section`),r=document.createElement(`ul`);return this._applyRootStyle(n,r,t),e.forEach(e=>{let t=document.createElement(`li`);this._applyLiStyle(t,e),e.fragments.forEach(e=>{let n=document.createElement(`span`);this._applySpanStyle(n,e),this._applyFragmentContent(n,e),t.appendChild(n)}),r.appendChild(t)}),n.appendChild(r),n}_patchDom(e,t,n,r){let i=e.firstChild;this._applyRootStyle(e,i,n),r&&this._hide(e);let a=i.children;for(let e=0;e<t.length;e++){let n=a[e];this._applyLiStyle(n,t[e]);let r=t[e].fragments,i=n.children;for(let e=0;e<r.length;e++){let t=i[e];this._applySpanStyle(t,r[e]),this._applyFragmentContent(t,r[e])}}}measureDomText(e){let t=e.data??``,n=[];if(!t.length)return n;let r=document.createRange(),i=0;for(;i<t.length;){let a=t.codePointAt(i),o=i+(a>65535?2:1);r.setStart(e,i),r.setEnd(e,o);let s=r.getClientRects?.(),c;s&&s.length?(c=s[s.length-1],s.length>1&&c.width<2&&(c=s[s.length-2])):c=r.getBoundingClientRect(),c&&c.width+c.height!==0&&n.push({content:t.slice(i,o),top:c.top,left:c.left,width:c.width,height:c.height}),i=o}return n}measureDom(e){let t=[],n=[],r=[];return e.querySelectorAll(`li`).forEach((e,i)=>{let a=e.getBoundingClientRect();t.push({paragraphIndex:i,left:a.x,top:a.y,width:a.width,height:a.height}),e.querySelectorAll(`:scope > *`).forEach((e,t)=>{let a=e.getBoundingClientRect();n.push({paragraphIndex:i,fragmentIndex:t,left:a.x,top:a.y,width:a.width,height:a.height});let o=0,s=e=>{this.measureDomText(e).forEach(e=>{r.push({...e,newParagraphIndex:-1,paragraphIndex:i,fragmentIndex:t,characterIndex:o++,textWidth:-1,textHeight:-1})})};!e.children.length&&e.firstChild instanceof window.Text?s(e.firstChild):e.querySelectorAll(`:scope > *`).forEach(e=>{e.firstChild instanceof window.Text&&s(e.firstChild)})})}),{paragraphs:t,fragments:n,characters:r}}measureParagraphDom(e,t){let n=t.getBoundingClientRect(),r=this.measureDom(t);r.paragraphs.forEach(t=>{let r=e[t.paragraphIndex].lineBox;r.left=t.left-n.left,r.top=t.top-n.top,r.width=t.width,r.height=t.height}),r.fragments.forEach(t=>{let r=e[t.paragraphIndex].fragments[t.fragmentIndex].inlineBox;r.left=t.left-n.left,r.top=t.top-n.top,r.width=t.width,r.height=t.height});let i=[];return r.characters.forEach(t=>{let{paragraphIndex:r,fragmentIndex:a,characterIndex:o}=t,s=t.left-n.left,c=t.top-n.top;i.push({...t,newParagraphIndex:r,left:s,top:c});let{fontHeight:l,isVertical:u,inlineBox:d,lineBox:f}=e[r].fragments[a].characters[o];d.left=s,d.top=c,d.width=t.width,d.height=t.height,u?(f.left=s+(t.width-l)/2,f.top=c,f.width=l,f.height=t.height):(f.left=s,f.top=c+(t.height-l)/2,f.width=t.width,f.height=l)}),{paragraphs:e,boundingBox:new W(0,0,n.width,n.height)}}measure(e,t,n){return this.measureParagraphDom(e,n??this._mount(e,t))}_mount(e,t){let n=this._signature(e);if(this._mountedDom?.isConnected&&this._mountedSignature===n)return this._patchDom(this._mountedDom,e,t,!0),this._mountedDom;this._unmount();let r=this.createDom(e,t);return this._hide(r),yc().appendChild(r),this._mountedDom=r,this._mountedSignature=n,r}_unmount(){this._mountedDom?.parentNode?.removeChild(this._mountedDom),this._mountedDom=void 0,this._mountedSignature=void 0}dispose(){this._unmount()}};function xc(e,t,n){return e[`${t}${n}`]??e[t]??0}var Sc=class{measure(e,t,n,r){let i=r??cc;for(let t of e)for(let e of t.fragments)for(let t of e.characters)t.measureGlyph(i);return t.writingMode.includes(`vertical`)?this._measureVertical(e,t):this._measureHorizontal(e,t)}_rootPadding(e){return{top:xc(e,`padding`,`Top`),right:xc(e,`padding`,`Right`),bottom:xc(e,`padding`,`Bottom`),left:xc(e,`padding`,`Left`)}}_measureHorizontal(e,t){let n=this._rootPadding(t),r=typeof t.width==`number`,i=r?t.width-n.left-n.right:1/0,a=n.top,o=n.left;for(let t of e){let e=t.computedStyle,r=t.style,s=xc(r,`margin`,`Top`),c=xc(r,`margin`,`Bottom`),l=xc(r,`margin`,`Left`),u=xc(r,`margin`,`Right`),d=xc(r,`padding`,`Top`),f=xc(r,`padding`,`Bottom`),p=xc(r,`padding`,`Left`),m=xc(r,`padding`,`Right`),h=n.left+l+p,g=i===1/0?1/0:i-l-u-p-m;a+=s+d;let _=a,v=h,y=this._breakLines(t,g),b=e.textAlign,x=e.textIndent??0;for(let t=0;t<y.length;t++){let n=y[t],r=t===0?x:0,i=e.fontSize*e.lineHeight,o=0;for(let e of n)e.fontHeight>i&&(i=e.fontHeight),o+=this._advance(e);let s=h+r;if(g!==1/0){let e=g-r-o;b===`center`?s+=e/2:(b===`end`||b===`right`)&&(s+=e)}for(let e of n){let t=e.advanceWidth,n=e.advanceHeight,r=e.fontHeight;e.inlineBox.left=s,e.inlineBox.top=a+(i-n)/2,e.inlineBox.width=t,e.inlineBox.height=n,e.lineBox.left=s,e.lineBox.top=e.inlineBox.top+(n-r)/2,e.lineBox.width=t,e.lineBox.height=r,s+=this._advance(e)}s>v&&(v=s),a+=i}v>o&&(o=v);for(let e of t.fragments)this._unionInto(e.inlineBox,e.characters.map(e=>e.inlineBox));t.lineBox.left=h,t.lineBox.top=_,t.lineBox.width=g===1/0?v-h:g,t.lineBox.height=a-_,a+=f+c}let s=a+n.bottom,c=r?t.width:o+n.right,l=typeof t.height==`number`?t.height:s;if(typeof t.height==`number`){let n=l-s,r=t.verticalAlign,i=r===`middle`?n/2:r===`bottom`?n:0;i&&this._shiftAll(e,i)}return{paragraphs:e,boundingBox:new W(0,0,c,l)}}_measureVertical(e,t){let n=this._rootPadding(t),r=typeof t.height==`number`,i=r?t.height-n.top-n.bottom:1/0,a=[];for(let t of e){let e=t.computedStyle.fontSize*t.computedStyle.lineHeight;for(let n of this._breakLines(t,i)){let t=e;for(let e of n)e.fontHeight>t&&(t=e.fontHeight);a.push({chars:n,thickness:t})}}let o=a.reduce((e,t)=>e+t.thickness,0),s=typeof t.width==`number`,c=s?Math.max(t.width-n.left-n.right,o):o,l=n.left+c,u=n.top;for(let e of a){l-=e.thickness;let t=l,r=n.top;for(let n of e.chars){let i=n.advanceWidth,a=n.advanceHeight,o=n.fontHeight;n.inlineBox.top=r,n.inlineBox.height=i,n.inlineBox.width=a,n.inlineBox.left=t+(e.thickness-a)/2,n.lineBox.left=n.inlineBox.left+(a-o)/2,n.lineBox.top=r,n.lineBox.width=o,n.lineBox.height=i,r+=this._advance(n)}r>u&&(u=r)}for(let t of e){for(let e of t.fragments)this._unionInto(e.inlineBox,e.characters.map(e=>e.inlineBox));this._unionInto(t.lineBox,t.fragments.flatMap(e=>e.characters.map(e=>e.inlineBox)))}return{paragraphs:e,boundingBox:new W(0,0,s?t.width:c+n.left+n.right,r?t.height:u+n.bottom)}}_advance(e){return e.advanceWidth+(e.computedStyle.letterSpacing??0)}_breakLines(e,t){let n=[],r=[],i=0,a=()=>{n.push(r),r=[],i=0};for(let n of e.fragments)for(let e of n.characters){if(e.content===`
34
- `||e.content===`\r`){a();continue}t!==1/0&&r.length>0&&i+e.advanceWidth>t&&a(),r.push(e),i+=this._advance(e)}return a(),n}_unionInto(e,t){let n=t.filter(e=>e.width!==0||e.height!==0);if(!n.length)return;let r=W.from(...n);e.left=r.left,e.top=r.top,e.width=r.width,e.height=r.height}_shiftAll(e,t){for(let n of e){n.lineBox.top+=t;for(let e of n.fragments){e.inlineBox.top+=t;for(let n of e.characters)n.inlineBox.top+=t,n.lineBox.top+=t}}}dispose(){}};function Cc(){let e=new Gr,t=Kr(),n=qr(t);return{name:`background`,pathSet:e,context:{loader:t,parser:n},load:async e=>{let{backgroundImage:n}=e.computedStyle;n&&t.needsLoad(n)&&await t.load(n)},update:t=>{e.paths.length=0;let{computedStyle:r,lineBox:i,isVertical:a}=t,{backgroundImage:o,backgroundSize:s,backgroundColormap:c}=r;if(O(o))return;let{pathSet:l}=n.parse(o),u=l.getBoundingBox(!0)??new W,d,f,p,m;a?{x:f,y:d,width:m,height:p}=i:{x:d,y:f,width:p,height:m}=i;let h=Zr(c??`none`),g=l.paths.map(e=>{let t=e.clone();return t.style.fill&&t.style.fill in h&&(t.style.fill=h[t.style.fill]),t.style.stroke&&t.style.stroke in h&&(t.style.stroke=h[t.style.stroke]),t}),_,v;if(s===`rigid`){_=t.fontSize*5/u.width,v=_;let e=new U;e.x=u.width-p/_,e.y=u.height-m/v,g.forEach(t=>{t.applyTransform(t=>{let n=t.x>u.left+u.width/2,r=t.y>u.top+u.height/2;n&&(t.x-=e.x),r&&(t.y-=e.y)})})}else _=p/u.width,v=m/u.height;let y=new Un;y.translate(-u.x,-u.y),y.scale(_,v),a&&(y.translate(-p/2,-m/2),y.rotate(Math.PI/2),y.translate(m/2,p/2)),y.translate(d,f),g.forEach(e=>{e.applyTransform(y)}),e.paths.push(...g)},renderOrder:-2,render:t=>{let{text:n,context:r}=t,{lineBox:i,computedStyle:a}=n;O(a.backgroundColor)||(r.fillStyle=a.backgroundColor,r.fillRect(...i.array)),e.paths.forEach(e=>{if(t.drawPath(e),n.debug){let t=new Gr([e]).getBoundingBox();t&&r.strokeRect(t.x,t.y,t.width,t.height)}}),n.paragraphs.forEach(e=>{let{lineBox:t,style:n}=e;O(n.backgroundColor)||(r.fillStyle=n.backgroundColor,r.fillRect(...t.array)),e.fragments.forEach(e=>{let{inlineBox:t,style:n}=e;O(n.backgroundColor)||(r.fillStyle=n.backgroundColor,r.fillRect(...t.array))})})}}}function wc(e,t){let{x:n,y:r}=t;if(e instanceof zr){let{p1:t,cp:i,p2:a}=e,o=n!==void 0&&Math.abs(Math.sign(t.x-n)+Math.sign(i.x-n)+Math.sign(a.x-n))===1,s=r!==void 0&&Math.abs(Math.sign(t.y-r)+Math.sign(i.y-r)+Math.sign(a.y-r))===1,c,l,u,d;if(o&&(c=t.x-2*i.x+a.x,l=2*(-t.x+i.x),u=t.x-n),s&&(c=t.y-2*i.y+a.y,l=2*(-t.y+i.y),u=t.y-r),(o||s)&&(d=l*l-4*c*u,d>0)){let e=Math.sqrt(d),n=[(-l+e)/2/c,(-l-e)/2/c].find(e=>e>0&&e<1);if(n){let e=U.lerp(t,i,n),r=U.lerp(i,a,n),o=U.lerp(e,r,n);return[new zr(t,e,o),new zr(o.clone(),r,a)]}}}else if(e instanceof Ir){let{p1:t,cp1:i,cp2:a,p2:o}=e,{min:s,max:c}=e.getMinMax(),l=n!==void 0&&(s.x-n)*(c.x-n)<0,u=r!==void 0&&(s.y-r)*(c.y-r)<0;if(l||u){n=.5*t.x+.5*i.x,r=.5*t.y+.5*i.y;let e=new U(n,r);n=.25*t.x+.5*i.x+.25*a.x,r=.25*t.y+.5*i.y+.25*a.y;let s=new U(n,r);n=.125*t.x+.375*i.x+.375*a.x+.125*o.x,r=.125*t.y+.375*i.y+.375*a.y+.125*o.y;let c=new U(n,r);n=.25*i.x+.5*a.x+.25*o.x,r=.25*i.y+.5*a.y+.25*o.y;let l=new U(n,r);n=.5*a.x+.5*o.x,r=.5*a.y+.5*o.y;let u=new U(n,r);return[new Ir(t,e,s,c),new Ir(c.clone(),l,u,o)]}}else if(e instanceof Pr){let{p1:t,p2:i}=e,a=n!==void 0&&(t.x-n)*(i.x-n)<0,o=r!==void 0&&(t.y-r)*(i.y-r)<0;if(a&&(r=t.y+(i.y-t.y)/(i.x-t.x)*(n-t.x)),o&&(n=t.x+(i.x-t.x)/(i.y-t.y)*(r-t.y)),a||o)return[new Pr(t,new U(n,r)),new Pr(new U(n,r),i)]}return[e]}var Tc=class{get boundingBox(){return this.text.lineBox}get paragraphs(){return this.text.paragraphs}get isHorizontal(){return this.text.computedStyle.writingMode.startsWith(`horizontal`)}get baseWidth(){return this.isHorizontal?this.boundingBox.width:this.boundingBox.height}get baseHeight(){return this.isHorizontal?this.boundingBox.height:this.boundingBox.width}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(e=>e.characters))}constructor({text:e,intensities:t=[],maxFontSize:n=100}){this.text=e,this.intensities=t.map(e=>e/100),this.lineHeight=n}_breakLine(){let e=!this.isHorizontal,{left:t,top:n,bottom:r,right:i}=this.boundingBox,a=.5*(t+i),o=.5*(n+r);this.characters.forEach(t=>{t.glyphBox&&t.path.curves.forEach(t=>{t.curves=t.curves.flatMap(t=>wc(t,e?{y:o}:{x:a}))})})}_makeTheJointSmooth(){this.characters.forEach(e=>{e.glyphBox&&e.path.getFlatCurves().forEach(e=>{if(e instanceof zr&&e.isFromLine){let{p1:t,cp:n,p2:r}=e;n.x=2*n.x-.5*(t.x+r.x),n.y=2*n.y-.5*(t.y+r.y)}})})}_lineToQuadraticBezier(){this.characters.forEach(e=>{e.glyphBox&&e.path.curves.forEach(e=>{e.curves=e.curves.map(e=>{if(e instanceof Pr&&e.getLength()>5){let{p1:t,p2:n}=e,r=new zr(t.clone(),new U(.5*(t.x+n.x),.5*(t.y+n.y)),n.clone());return r.isFromLine=!0,r}return e})})})}_transform(e,t,n){let r=this.text.plugins.get(`highlight`),i=n?.(),a=0,o=this.characters.filter(e=>e.glyphBox).length;this.paragraphs.forEach((n,s)=>{n.fragments.forEach((n,c)=>{n.characters.forEach((n,l)=>{if(!n.glyphBox)return;let u=t?.({paragraphIndex:s,fragmentIndex:c,characterIndex:l,character:n},i);if(n.path.getControlPointRefs().forEach(t=>{let[n,r]=e(t,u);t.set(n,r)}),t&&r?.pathSet?.paths){let t=r.pathSet.paths.length/o,n=a*t;for(let i=0;i<t;i++)r?.pathSet?.paths[n+i]?.getControlPointRefs().forEach(t=>{let[n,r]=e(t,u);t.set(n,r)});a++}})})}),this.paragraphs.forEach(e=>{e.fragments.forEach(e=>{e.characters.forEach(e=>{e.glyphBox=e.getGlyphBoundingBox(),e.glyphBox&&(e.inlineBox=e.glyphBox)})})}),t||r?.pathSet?.paths?.forEach(t=>{t.getControlPointRefs().forEach(t=>{let[n,r]=e(t);t.set(n,r)})})}},Ec=class extends Tc{preset;constructor(e,t){super(e),this.preset=t}deform(){Math.hypot(...this.intensities)&&(this._lineToQuadraticBezier(),this._bend(),this._makeTheJointSmooth())}_bend(){let{boundingBox:e,baseWidth:t,baseHeight:n,preset:r}=this,i=this.lineHeight*2/Math.sin(this.intensities[0]*Math.PI*.5),a=r.vertical===void 0||r.vertical===`auto`?!this.isHorizontal:r.vertical,{left:o,top:s,width:c,height:l}=e,u=(a?l:c)/2/i,d={x:o+c/2,y:s+l/2},f,p={x:d.x,y:d.y};a?(f=0,p.x-=n/2/Math.tan(u)+Math.sign(u)*c/2):(f=1.5*Math.PI,p.y+=t/2/Math.tan(u)+Math.sign(u)*l/2);let m=r.transform({lineHeight:i,size:u,center:d,centerDist:p,centerDistAngle:f,width:c,height:l,isHorizontal:this.isHorizontal});this._transform(m)}},Dc=class{arcLengthDivisions=200;_cacheArcLengths;_needsUpdate=!1;getPointAt(e,t=new U){return this.getPoint(this.getUToTMapping(e),t)}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;let t=[0],n=this.getPoint(0),r=0;for(let i=1;i<=e;i++){let a=this.getPoint(i/e);r+=a.distanceTo(n),t.push(r),n=a}return this._cacheArcLengths=t,t}getUToTMapping(e,t){let n=this.getLengths(),r=n.length,i=t===void 0?e*n[r-1]:t,a=0,o=r-1,s=0;for(;a<=o;){s=Math.floor(a+(o-a)/2);let e=n[s]-i;if(e<0)a=s+1;else if(e>0)o=s-1;else{o=s;break}}if(s=o,n[s]===i)return s/(r-1);let c=n[s],l=n[s+1]-c,u=(i-c)/l;return(s+u)/(r-1)}getTangent(e,t=new U){let n=1e-4,r=Math.max(0,e-n),i=Math.min(1,e+n);return t.copyFrom(this.getPoint(i).sub(this.getPoint(r)).normalize())}getNormal(e,t=new U){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}},Oc=class extends Dc{curveT=0;getPoint(e,t=new U){return this.getCurve(e).getPoint(this.curveT,t)}getPointAt(e,t=new U){return this.getPoint(e,t)}getTangent(e,t=new U){return this.getCurve(e).getTangent(this.curveT,t)}getNormal(e,t=new U){return this.getCurve(e).getNormal(this.curveT,t)}},kc=class extends Dc{start;end;constructor(e,t){super(),this.start=e,this.end=t}getPoint(e,t=new U){return e===1?t.copyFrom(this.end):t.copyFrom(this.end).sub(this.start).scale(e).add(this.start),t}getPointAt(e,t=new U){return this.getPoint(e,t)}getTangent(e,t=new U){return t.subVectors(this.end,this.start).normalize()}},Ac=class extends Dc{center;radius;start;end;constructor(e,t,n=0,r=Math.PI*2){super(),this.center=e,this.radius=t,this.start=n,this.end=r}getPoint(e,t=new U){return t.copyFrom(this.center).add(this.getNormal(e).scale(this.radius))}getTangent(e,t=new U){let{x:n,y:r}=this.getNormal(e);return t.set(-r,n)}getNormal(e,t=new U){let{start:n,end:r}=this,i=e*(r-n)+n-.5*Math.PI;return t.set(Math.cos(i),Math.sin(i))}},jc=class extends Dc{center;radiusX;radiusY;rotation;startAngle;endAngle;clockwise;constructor(e=new U,t=1,n=1,r=0,i=0,a=Math.PI*2,o=!1){super(),this.center=e,this.radiusX=t,this.radiusY=n,this.rotation=r,this.startAngle=i,this.endAngle=a,this.clockwise=o}getPoint(e,t=new U){let n=Math.PI*2,r=this.endAngle-this.startAngle,i=Math.abs(r)<2**-52;for(;r<0;)r+=n;for(;r>n;)r-=n;r<2**-52&&(r=i?0:n),this.clockwise&&!i&&(r=r===n?-n:r-n);let a=this.startAngle+e*r,o=this.center.x+this.radiusX*Math.cos(a),s=this.center.y+this.radiusY*Math.sin(a);if(this.rotation!==0){let e=Math.cos(this.rotation),t=Math.sin(this.rotation),n=o-this.center.x,r=s-this.center.y;o=n*e-r*t+this.center.x,s=n*t+r*e+this.center.y}return t.set(o,s)}},Mc=class extends Oc{center;size;start;end;curves=[];constructor(e,t,n=0,r=1){super(),this.center=e,this.size=t,this.start=n,this.end=r,this.update()}update(){let{x:e,y:t}=this.center,n=new U(e+.5*this.size,t-.5*this.size),r=new U(e-.5*this.size,t-.5*this.size),i=new U(e,t+.5*this.size),a=new Ac(n,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),o=new Ac(r,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),s=new Ac(i,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),c=new U(e,t+this.size),l=new U(e+this.size,t),u=U.lerp(l,c,.75),d=new U(e-this.size,t),f=U.lerp(d,c,.75),p=new kc(l,u),m=new kc(f,d);return this.curves=[a,p,s,m,o],this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1),t*=9*Math.PI/8+1.5;let n=.5*Math.PI,r;return t<n?(r=0,this.curveT=t/n):t<n+.75?(r=1,this.curveT=(t-n)/.75):t<5*Math.PI/8+.75?(r=2,this.curveT=(t-n-.75)/(Math.PI/8)):t<5*Math.PI/8+1.5?(r=3,this.curveT=(t-5*Math.PI/8-.75)/.75):(r=4,this.curveT=(t-5*Math.PI/8-1.5)/n),this.curves[r]}},Nc=class extends Oc{center;radius;number;start;end;curves=[];points=[];constructor(e,t=0,n=0,r=0,i=1){super(),this.center=e,this.radius=t,this.number=n,this.start=r,this.end=i,this.update()}update(){for(let e=0;e<this.number;e++){let t=e*2*Math.PI/this.number;t-=.5*Math.PI,this.points.push(new U(this.radius*Math.cos(t),this.radius*Math.sin(t)).add(this.center))}for(let e=0;e<this.number;e++)this.curves.push(new kc(this.points[e],this.points[(e+1)%this.number]));return this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1);let n=t*this.number,r=Math.floor(n);return this.curveT=n-r,this.curves[r]}},Pc=class extends Oc{center;rx;aspectRatio;start;end;curves=[];constructor(e,t,n=1,r=0,i=1){super(),this.center=e,this.rx=t,this.aspectRatio=n,this.start=r,this.end=i,this.update()}update(){let{x:e,y:t}=this.center,n=this.rx,r=this.rx/this.aspectRatio,i=[new U(e-n,t-r),new U(e+n,t-r),new U(e+n,t+r),new U(e-n,t+r)];for(let e=0;e<4;e++)this.curves.push(new kc(i[e].clone(),i[(e+1)%4].clone()));return this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1),t*=(1+this.aspectRatio)*2;let n;return t<this.aspectRatio?(n=0,this.curveT=t/this.aspectRatio):t<this.aspectRatio+1?(n=1,this.curveT=t-this.aspectRatio):t<2*this.aspectRatio+1?(n=2,this.curveT=(t-this.aspectRatio-1)/this.aspectRatio):(n=3,this.curveT=t-2*this.aspectRatio-1),this.curves[n]}},Fc=class extends Tc{preset;constructor(e,t){super(e),this.preset=t}deform(){if(!Math.hypot(...this.intensities))return;let{preset:e}=this;e.breakLine&&this._breakLine(),e.lineToQuad&&this._lineToQuadraticBezier();let[t,n]=this.intensities,r=this._createFFDControlPoints(e.hBlocks,e.vBlocks);e.build(r,{a:t,b:n,baseWidth:this.baseWidth,baseHeight:this.baseHeight,lineHeight:this.lineHeight,adjust:(e,t,n)=>this._adjustControlPoints(e,{x:t,y:n})}),e.bezier?(this._calculateForBezierFFD(r,e.hBlocks,e.vBlocks),this._makeTheJointSmooth()):this._calculateForLinearFFD(r,e.hBlocks,e.vBlocks)}_calculateForFFD(e,t,n,r){let{left:i,top:a,right:o,width:s,height:c}=this.boundingBox;this._transform(this.isHorizontal?o=>{let l=(o.x-i)/s,u=(o.y-a)/c,[d,f]=[0,0];for(let i=0;i<n+2;i++){let a=e(n,i,l);for(let n=0;n<r+2;n++){let o=e(r,n,u),s=t[i*(r+2)+n];d+=a*o*s.x,f+=a*o*s.y}}return[d,f]}:i=>{let l=(o-i.x)/s,u=(i.y-a)/c,[d,f]=[0,0];for(let i=0;i<n+2;i++){let a=e(n,i,u);for(let n=0;n<r+2;n++){let o=e(r,n,l),s=t[i*(r+2)+n];d+=a*o*s.x,f+=a*o*s.y}}return[d,f]})}_createFFDControlPoints(e,t){let{left:n,top:r,right:i,width:a,height:o}=this.boundingBox,s=[];if(this.isHorizontal){let i=a/(e+1),c=o/(t+1);for(let a=0;a<e+2;a++)for(let e=0;e<t+2;e++)s.push(new U(n+a*i,r+e*c))}else{let n=a/(t+1),c=o/(e+1);for(let a=0;a<e+2;a++)for(let e=0;e<t+2;e++)s.push(new U(i-e*n,r+a*c))}return s}_adjustControlPoints(e,t){this.isHorizontal?(e.x+=t.x,e.y+=t.y):(e.x-=t.y,e.y+=t.x)}_factorialForFFD(e){let t=1;for(let n=2;n<=e;n++)t*=n;return t}_combineForFFD(e,t){return this._factorialForFFD(e)/this._factorialForFFD(e-t)/this._factorialForFFD(t)}_calculateForBezierFFD(e,t,n){this._calculateForFFD((e,t,n)=>this._combineForFFD(e+1,t)*(1-n)**(e+1-t)*n**t,e,t,n)}_linearBasis(e,t,n){let r=t<n*e?t+1-n*e:n*e-t+1;return Math.max(0,r)}_calculateForLinearFFD(e,t,n){this._calculateForFFD((e,t,n)=>this._linearBasis(e+1,t,n),e,t,n)}},Ic=class extends Tc{preset;constructor(e,t){super(e),this.preset=t}_context(){return{intensities:this.intensities,baseWidth:this.baseWidth,lineHeight:this.lineHeight,isHorizontal:this.isHorizontal,boundingBox:this.boundingBox}}deform(){if(!Math.hypot(...this.intensities))return;let{preset:e}=this,t=this._context();if(e.engine===`offset`)this._transform(e.point,e.perChar?n=>e.perChar(t,n):void 0);else{let n=e.followTangent??!0,{funcPerChar:r,funcPerPoint:i}=this._getPerCharAndPointFunc(n);this._transform(i,r,()=>{let{width:n,height:r,left:i,top:a}=this.boundingBox;return{width:n,height:r,left:i,top:a,curve:e.makeCurve(t),isHorizontal:this.isHorizontal,needExpandAlongNormal:e.expandAlongNormal??!1}})}}_getPerCharAndPointFunc(e=!1){let t,n;return e?(n=this._resetPointPos,t=this._calculateNewCenter):(n=this._resetPointPosWithoutRotate,t=this._calculateNewCenterWithoutRotate),{funcPerPoint:n,funcPerChar:t}}_calculateNewCenter({character:e},t){let{width:n,height:r,left:i,top:a,curve:o,isHorizontal:s,needExpandAlongNormal:c=!1}=t,{center:l,centerDiviation:u}=e,d=s?(l.x-i)/n:(l.y-a)/r,f=s?new U(0,l.y-a):new U(l.x-i,0);if(c){let e=o.getNormal(d);f.x+=e.x*-u,f.y+=e.y*-u}let p=o.getPointAt(d).add(f),m=o.getTangent(d);return{cos:m.x,sin:m.y,newCenter:p,center:l}}_calculateNewCenterWithoutRotate({character:e},t){let{width:n,height:r,left:i,top:a,curve:o,isHorizontal:s}=t,{center:c}=e,l=s?(c.x-i)/n:(c.y-a)/r,u=s?new U(0,c.y-a):new U(c.x-i,0);return{newCenter:o.getPointAt(l).add(u),center:c}}_resetPointPos(e,t){let{cos:n=1,sin:r=0,center:i,newCenter:a}=t,o=e.x-i.x,s=e.y-i.y;return[a.x+o*n-s*r,a.y+o*r+s*n]}_resetPointPosWithoutRotate(e,t){let{center:n,newCenter:r}=t;return[e.x-n.x+r.x,e.y-n.y+r.y]}},Lc=new Map;function Rc(e,t){Lc.set(e,t)}function zc(e){Lc.delete(e)}function Bc(){return[...Lc.keys()]}function Vc(){return _c({name:`deformation`,updateOrder:2,update:e=>{let t=e.deformation,n=t?.type;if(O(n)||!n)return;let r=Lc.get(n);if(!r)return;let i={text:e,intensities:t.intensities??r.defaultIntensities,maxFontSize:t.maxFontSize},a;switch(r.engine){case`ffd`:a=new Fc(i,r);break;case`bend`:a=new Ec(i,r);break;case`curve`:case`offset`:a=new Ic(i,r);break}a.deform();let o=e.getGlyphBox();e.rawGlyphBox=o,e.glyphBox=o,e.lineBox=o}})}function Hc(e){let{highlight:t,highlightImage:n,highlightReferImage:r,highlightColormap:i,highlightLine:a,highlightSize:o,highlightThickness:s}=e;return{image:t?.image??n??`none`,referImage:t?.referImage??r??`none`,colormap:t?.colormap??i??`none`,line:t?.line??a??`none`,size:t?.size??o??`cover`,thickness:t?.thickness??s??`100%`}}function Uc(){let e=new Gr,t=[],n=Kr(),r=qr(n);return _c({name:`highlight`,pathSet:e,context:{clipRects:t,loader:n,parser:r},load:async e=>{let t=new Set;e.forEachCharacter(e=>{let{computedStyle:r}=e,{image:i,referImage:a}=Hc(r);i&&n.needsLoad(i)&&t.add(i),a&&n.needsLoad(a)&&t.add(a)}),await Promise.all(Array.from(t).map(e=>n.load(e)))},update:n=>{t.length=0,e.paths.length=0;let i=[],a,o;n.forEachCharacter(e=>{let{computedStyle:t}=e,n=Hc(t),{image:r,colormap:s,line:c,size:l,thickness:u}=n;if(O(r))a?.length&&(a=[],i.push(a));else{let{inlineBox:n,isVertical:d}=e,{fontSize:f}=t;(!o||$r(o.image,r)&&$r(o.colormap,s)&&$r(o.line,c)&&$r(o.size,l)&&$r(o.thickness,u))&&a?.length&&(d?a[0].inlineBox.left===n.left:a[0].inlineBox.top===n.top)&&a[0].fontSize===f?a.push(e):(a=[],a.push(e),i.push(a))}o=n}),i=i.filter(e=>e.length);for(let n=0;n<i.length;n++){let a=i[n],o=a[0],s=W.from(...a.map(e=>e.compatibleGlyphBox));if(!s.height||!s.width)continue;let{computedStyle:c,isVertical:l,inlineBox:u,compatibleGlyphBox:d,strikeoutPosition:f,underlinePosition:p}=o,{fontSize:m}=c,{image:h,referImage:g,colormap:_,line:v,size:y,thickness:b}=Hc(c),x=Xr(b,{fontSize:m,total:s.width})/s.width,S=Zr(_),{pathSet:C,dom:w}=r.parse(h),T=C.getBoundingBox(!0)??new W,E=m/T.width*2,D=new W().copy(s);l&&(D.width=s.height,D.height=s.width,D.left=s.left+s.width);let k=Math.floor(D.width),A=k;y!==`cover`&&(A=Xr(y,{fontSize:m,total:s.width})||k,D.width=A);let j=!O(g)&&O(v);if(j)T.copy(r.parse(g).pathSet.getBoundingBox(!0)??new W);else{let e;if(O(v))if(T.width/T.height>4){e=`underline`;let t=w.getAttribute(`viewBox`);if(t){let[n,r,i,a]=t.split(` `).map(e=>Number(e)),o=r+a/2;e=T.y<o&&T.y+T.height>o?`line-through`:T.y+T.height<o?`overline`:`underline`}}else e=`outline`;else e=v;switch(e){case`outline`:{let e=D.width*.2,t=D.height*.2;l?(D.x-=t/2,D.y-=e/2,D.x-=D.height):(D.x-=e/2,D.y-=t/2),D.width+=e,D.height+=t;break}case`overline`:D.height=T.height*E,l?D.x=u.left+u.width:D.y=u.top;break;case`line-through`:D.height=T.height*E,l?D.x=u.left+u.width-f+D.height/2:D.y=u.top+f-D.height/2;break;case`underline`:D.height=T.height*E,l?D.x=d.left+d.width-p:D.y=u.top+p;break}}let M=new Un;if(M.translate(-T.x,-T.y),M.scale(D.width/T.width,D.height/T.height),l){let e=D.width/2,t=D.height/2;j||M.translate(-e,-t),M.rotate(Math.PI/2),j||M.translate(t,e)}M.translate(D.x,D.y);for(let n=0;n<Math.ceil(k/A);n++){let r=M.clone();l?r.translate(0,n*D.width):r.translate(n*D.width,0),C.paths.forEach(n=>{let i=n.clone().applyTransform(r);i.style.strokeWidth&&(i.style.strokeWidth*=E*x),i.style.strokeMiterlimit&&(i.style.strokeMiterlimit*=E),i.style.strokeDashoffset&&(i.style.strokeDashoffset*=E),i.style.strokeDasharray&&(i.style.strokeDasharray=i.style.strokeDasharray.map(e=>e*E)),i.style.fill&&i.style.fill in S&&(i.style.fill=S[i.style.fill]),i.style.stroke&&i.style.stroke in S&&(i.style.stroke=S[i.style.stroke]),e.paths.push(i),k!==A&&(l?t[e.paths.length-1]=new W(s.left-s.width*2,s.top,s.width*4,s.height):t[e.paths.length-1]=new W(s.left,s.top-s.height*2,s.width,s.height*4))})}}},renderOrder:-1,getBoundingBox:()=>{let n=[];return e.paths.forEach((e,r)=>{let i=t[r],a=e.getBoundingBox();if(i){let e=Math.max(a.x,i.x),t=Math.max(a.y,i.y),n=Math.min(a.right,i.right),r=Math.min(a.bottom,i.bottom);a=new W(e,t,n-e,r-t)}n.push(a)}),n.length?W.from(...n):void 0},render:n=>{let{text:r,context:i}=n;e.paths.forEach((e,a)=>{if(n.drawPath(e,{clipRect:t[a]}),r.debug){let t=new Gr([e]).getBoundingBox();t&&i.strokeRect(t.x,t.y,t.width,t.height)}})}})}function Wc(e,t){return`<svg width="${e*2}" height="${e*2}" xmlns="http://www.w3.org/2000/svg">
33
+ }`)),document.head.appendChild(n)}return this}_parseUrls(e){let t=[...new Set([...e.split(`,`),e])];return[...new Set(t.map(e=>this.familyToUrl.get(e.trim())??this.familyToUrl.get(e)??e))]}get(e){let t;return e&&(t=this._parseUrls(e).reduce((e,t)=>e||this.loaded.get(t),void 0)),t??this.fallbackFont}set(e,t){return this.familyToUrl.set(e,t.src),this.loaded.set(t.src,t),this}delete(e){return this._parseUrls(e).forEach(e=>{this.familyToUrl.delete(e),this.loaded.delete(e)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}_parseFamilies(e){return e?(Array.isArray(e)?e:[e]).flatMap(e=>e.split(`,`).map(e=>e.trim())):[]}async load(e,t={}){let{cancelOther:n,injectStyleTag:r=!1,injectFontFace:i=!1,...a}=t,o,s;typeof e==`string`?o=e:{src:o,family:s}=e;let c=this._parseFamilies(s);if(this.loaded.has(o))return n&&(this.loading.forEach(e=>e.cancel()),this.loading.clear()),u(this.loaded.get(o));let l=this.loading.get(o);return l||(l=this._createRequest(o,a),this.loading.set(o,l)),n&&this.loading.forEach((e,t)=>{e!==l&&(e.cancel(),this.loading.delete(t))}),l.when.then(e=>{let n;return this.loaded.has(o)?n=u(this.loaded.get(o)):(n=d(e),t.noAdd||this.loaded.set(o,n)),Promise.all(Array.from(n.familySet,async t=>{if(this.familyToUrl.set(t,o),typeof document<`u`&&(i&&await this.injectFontFace(t,e),r&&this.injectStyleTag(t,o),i||r))return await document.fonts.load(`14px "${t}"`)})).then(()=>n)}).catch(e=>{if(e instanceof DOMException&&e.message===`The user aborted a request.`)return d();throw e}).finally(()=>{this.loading.delete(o)});function u(e){return c.forEach(t=>{e.familySet.add(t)}),e}function d(e=new ArrayBuffer(0)){let t;function n(){return t||=e.byteLength?sc(e,!1):void 0,t}function r(){let e=n();if(e instanceof qs||e instanceof ac)return e.sfnt}return{src:o,family:s,buffer:e,familySet:new Set(c),getFont:n,getSFNT:r}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values(),e=>e.when))}},lc=new Set([`©`,`®`,`÷`]),uc=new Set([`—`,`…`,`“`,`”`,`﹏`,`﹋`,`﹌`,`‘`,`’`,`˜`]),dc={1:`italic`,32:`bold`},fc={1:`italic`,2:`bold`},pc={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5},mc=class{content;index;parent;path=new Wr().setMeta(this);lineBox=new W;inlineBox=new W;glyphBox;advanceWidth=0;advanceHeight=0;underlinePosition=0;underlineThickness=0;strikeoutPosition=0;strikeoutSize=0;ascender=0;descender=0;typoAscender=0;typoDescender=0;typoLineGap=0;winAscent=0;winDescent=0;xHeight=0;capHeight=0;baseline=0;centerDiviation=0;fontStyle;get compatibleGlyphBox(){let e=this.computedStyle.fontSize*.8;return this.glyphBox??(this.isVertical?new W(this.lineBox.left+this.lineBox.width/2-e/2,this.lineBox.top,e,this.lineBox.height):new W(this.lineBox.left,this.lineBox.top+this.lineBox.height/2-e/2,this.lineBox.width,e))}get center(){return this.compatibleGlyphBox.center}get computedFill(){return this.parent.computedFill}get computedOutline(){return this.parent.computedOutline}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes(`vertical`)}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}constructor(e,t,n){this.content=e,this.index=t,this.parent=n}_getFontSFNT(e){let t=this.computedStyle.fontFamily,n=e??cc,r=(t?n.get(t):n.fallbackFont)?.getSFNT();return r?.textToGlyphIndexes(this.content).includes(0)&&(r=n.fallbackFont?.getSFNT()),r}updateGlyph(e=this._getFontSFNT()){if(!e)return this;let{hhea:t,os2:n,post:r,head:i}=e,a=i.unitsPerEm,o=t.ascent,s=t.descent,{content:c,computedStyle:l}=this,{fontSize:u}=l,d=a/u,f=e.getAdvanceWidth(c,u),p=(o+Math.abs(s))/d,m=o/d;return this.advanceWidth=f,this.advanceHeight=p,this.underlinePosition=(o-r.underlinePosition)/d,this.underlineThickness=r.underlineThickness/d,this.strikeoutPosition=(o-n.yStrikeoutPosition)/d,this.strikeoutSize=n.yStrikeoutSize/d,this.ascender=o/d,this.descender=s/d,this.typoAscender=n.sTypoAscender/d,this.typoDescender=n.sTypoDescender/d,this.typoLineGap=n.sTypoLineGap/d,this.winAscent=n.usWinAscent/d,this.winDescent=n.usWinDescent/d,this.xHeight=n.version>1?n.sxHeight/d:0,this.capHeight=n.version>1?n.sCapHeight/d:0,this.baseline=m,this.centerDiviation=p/2-m,this.fontStyle=dc[n.fsSelection]??fc[i.macStyle],this}measureGlyph(e){return this.updateGlyph(this._getFontSFNT(e))}update(e){let t=this._getFontSFNT(e);if(!t)return this;this.updateGlyph(t);let{isVertical:n,content:r,computedStyle:i,baseline:a,inlineBox:o,ascender:s,descender:c,typoAscender:l,fontStyle:u,advanceWidth:d,advanceHeight:f}=this,{left:p,top:m}=o,h=i.fontStyle===`italic`&&u!==`italic`,g=p,_=m+a,v,y=new Wr().setMeta(this);if(n&&(g+=(f-d)/2,Math.abs(d-f)>.1&&(_-=(s-l)/(s+Math.abs(c))*f),v=void 0),n&&!lc.has(r)&&(r.codePointAt(0)<=256||uc.has(r))){y.addCommands(t.getPathCommands(r,g,m+a-(f-d)/2,i.fontSize));let e={y:m-(f-d)/2+f/2,x:g+d/2};h&&this._italic(y,{x:e.x,y:m-(f-d)/2+a}),y.rotate(Math.PI/2,e)}else v===void 0?(y.addCommands(t.getPathCommands(r,g,_,i.fontSize)),h&&this._italic(y,n?{x:g+f/2,y:_}:void 0)):(y.addCommands(t.glyphs.get(v).getPathCommands(g,_,i.fontSize)),h&&this._italic(y,n?{x:g+d/2,y:m+l/(s+Math.abs(c))*f}:void 0));let b=i.fontWeight??400;return b in pc&&(b===700||b===`bold`)&&u!==`bold`&&y.bold(pc[b]*i.fontSize*.05),y.style=j({fill:i.color,fillRule:`nonzero`,stroke:i.textStrokeWidth?i.textStrokeColor:void 0,strokeWidth:i.textStrokeWidth?i.textStrokeWidth*i.fontSize*.03:void 0}),this.path=y,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(e,t){e.skew(-.24,0,t||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(e,t,n){if(this.path.curves[0]?.curves.length)return this.path.getMinMax(e,t,n)}getGlyphBoundingBox(e){let t=this.getGlyphMinMax(void 0,void 0,e);if(!t)return;let{min:n,max:r}=t;return new W(n.x,n.y,r.x-n.x,r.y-n.y)}},hc=class{content;style;fill;outline;index;parent;inlineBox=new W;get computedContent(){let e=this.computedStyle;return e.textTransform===`uppercase`?this.content.toUpperCase():e.textTransform===`lowercase`?this.content.toLowerCase():this.content}constructor(e,t={},n,r,i,a){this.content=e,this.style=t,this.fill=n,this.outline=r,this.index=i,this.parent=a,this.update().initCharacters()}update(){this.computedStyle={...this.parent.computedStyle,...j(this.style)};let e=this.fill??this.parent.computedFill;this.computedFill=e?j(e):void 0;let t=this.outline??this.parent.computedOutline;return this.computedOutline=t?j(t):void 0,this}initCharacters(){let e=[],t=0;for(let n of this.computedContent)e.push(new mc(n,t++,this));return this.characters=e,this}},gc=class{style;index;parent;lineBox=new W;fragments=[];fill;outline;constructor(e,t,n){this.style=e,this.index=t,this.parent=n,this.update()}update(){this.computedStyle={...j(this.parent.computedStyle),...j(this.style)};let e=this.fill??this.parent.computedFill;this.computedFill=e?j(e):void 0;let t=this.outline??this.parent.computedOutline;return this.computedOutline=t?j(t):void 0,this}};function _c(e){return e}var vc;function yc(){if(vc?.isConnected)return vc;let e=document.createElement(`div`);return e.dataset.modernText=`measurer`,Object.assign(e.style,{position:`fixed`,left:`0`,top:`0`,visibility:`hidden`,pointerEvents:`none`}),document.body.appendChild(e),vc=e,e}var bc=class e{static notZeroStyles=new Set([`width`,`height`]);static pxStyles=new Set([`width`,`height`,`fontSize`,`letterSpacing`,`textStrokeWidth`,`textIndent`,`shadowOffsetX`,`shadowOffsetY`,`shadowBlur`,`margin`,`marginLeft`,`marginTop`,`marginRight`,`marginBottom`,`padding`,`paddingLeft`,`paddingTop`,`paddingRight`,`paddingBottom`]);_styleCache=new WeakMap;_mountedDom;_mountedSignature;_toDomStyle(t){let n=this._styleCache.get(t);if(n)return n;let r={},{notZeroStyles:i,pxStyles:a}=e;for(let e in t){let n=t[e];i.has(e)&&n===0||(r[e]=typeof n==`number`&&a.has(e)?`${n}px`:n)}return this._styleCache.set(t,r),r}_resolveRootStyles(e){let t={...e},n=e.writingMode.includes(`horizontal`);switch(e.textAlign){case`start`:case`left`:t.justifyContent=`flex-start`;break;case`center`:t.justifyContent=`center`;break;case`end`:case`right`:t.justifyContent=`flex-end`;break}switch(e.verticalAlign){case`top`:t.alignItems=`flex-start`;break;case`middle`:t.alignItems=`center`;break;case`bottom`:t.alignItems=`flex-end`;break}let r=!!(t.justifyContent||t.alignItems);return{section:{...this._toDomStyle({...t,boxSizing:t.boxSizing??`border-box`,display:t.display??(r?`inline-flex`:void 0),width:t.width??`max-content`,height:t.height??`max-content`}),whiteSpace:`pre-wrap`,wordBreak:`break-all`},ul:{verticalAlign:`inherit`,listStyleType:`inherit`,padding:`0`,margin:`0`,width:r&&n?`100%`:void 0,height:r&&!n?`100%`:void 0}}}_applyRootStyle(e,t,n){let r=this._resolveRootStyles(n);e.removeAttribute(`style`),Object.assign(e.style,r.section),t.removeAttribute(`style`),Object.assign(t.style,r.ul)}_applyLiStyle(e,t){e.removeAttribute(`style`),e.style.verticalAlign=`inherit`,Object.assign(e.style,this._toDomStyle(t.style))}_applySpanStyle(e,t){e.removeAttribute(`style`),e.style.verticalAlign=`inherit`,Object.assign(e.style,this._toDomStyle(t.style))}_applyFragmentContent(e,t){let n=e.firstChild;n?n.data!==t.content&&(n.data=t.content):e.appendChild(document.createTextNode(t.content))}_hide(e){e.style.visibility=`hidden`}_signature(e){let t=`${e.length}`;for(let n=0;n<e.length;n++)t+=`:${e[n].fragments.length}`;return t}createDom(e,t){let n=document.createElement(`section`),r=document.createElement(`ul`);return this._applyRootStyle(n,r,t),e.forEach(e=>{let t=document.createElement(`li`);this._applyLiStyle(t,e),e.fragments.forEach(e=>{let n=document.createElement(`span`);this._applySpanStyle(n,e),this._applyFragmentContent(n,e),t.appendChild(n)}),r.appendChild(t)}),n.appendChild(r),n}_patchDom(e,t,n,r){let i=e.firstChild;this._applyRootStyle(e,i,n),r&&this._hide(e);let a=i.children;for(let e=0;e<t.length;e++){let n=a[e];this._applyLiStyle(n,t[e]);let r=t[e].fragments,i=n.children;for(let e=0;e<r.length;e++){let t=i[e];this._applySpanStyle(t,r[e]),this._applyFragmentContent(t,r[e])}}}measureDomText(e){let t=e.data??``,n=[];if(!t.length)return n;let r=document.createRange(),i=0;for(;i<t.length;){let a=t.codePointAt(i),o=i+(a>65535?2:1);r.setStart(e,i),r.setEnd(e,o);let s=r.getClientRects?.(),c;s&&s.length?(c=s[s.length-1],s.length>1&&c.width<2&&(c=s[s.length-2])):c=r.getBoundingClientRect(),c&&c.width+c.height!==0&&n.push({content:t.slice(i,o),top:c.top,left:c.left,width:c.width,height:c.height}),i=o}return n}measureDom(e){let t=[],n=[],r=[];return e.querySelectorAll(`li`).forEach((e,i)=>{let a=e.getBoundingClientRect();t.push({paragraphIndex:i,left:a.x,top:a.y,width:a.width,height:a.height}),e.querySelectorAll(`:scope > *`).forEach((e,t)=>{let a=e.getBoundingClientRect();n.push({paragraphIndex:i,fragmentIndex:t,left:a.x,top:a.y,width:a.width,height:a.height});let o=0,s=e=>{this.measureDomText(e).forEach(e=>{r.push({...e,newParagraphIndex:-1,paragraphIndex:i,fragmentIndex:t,characterIndex:o++,textWidth:-1,textHeight:-1})})};!e.children.length&&e.firstChild instanceof window.Text?s(e.firstChild):e.querySelectorAll(`:scope > *`).forEach(e=>{e.firstChild instanceof window.Text&&s(e.firstChild)})})}),{paragraphs:t,fragments:n,characters:r}}measureParagraphDom(e,t){let n=t.getBoundingClientRect(),r=this.measureDom(t);r.paragraphs.forEach(t=>{let r=e[t.paragraphIndex].lineBox;r.left=t.left-n.left,r.top=t.top-n.top,r.width=t.width,r.height=t.height}),r.fragments.forEach(t=>{let r=e[t.paragraphIndex].fragments[t.fragmentIndex].inlineBox;r.left=t.left-n.left,r.top=t.top-n.top,r.width=t.width,r.height=t.height});let i=[];return r.characters.forEach(t=>{let{paragraphIndex:r,fragmentIndex:a,characterIndex:o}=t,s=t.left-n.left,c=t.top-n.top;i.push({...t,newParagraphIndex:r,left:s,top:c});let{fontHeight:l,isVertical:u,inlineBox:d,lineBox:f}=e[r].fragments[a].characters[o];d.left=s,d.top=c,d.width=t.width,d.height=t.height,u?(f.left=s+(t.width-l)/2,f.top=c,f.width=l,f.height=t.height):(f.left=s,f.top=c+(t.height-l)/2,f.width=t.width,f.height=l)}),{paragraphs:e,boundingBox:new W(0,0,n.width,n.height)}}measure(e,t,n){return this.measureParagraphDom(e,n??this._mount(e,t))}_mount(e,t){let n=this._signature(e);if(this._mountedDom?.isConnected&&this._mountedSignature===n)return this._patchDom(this._mountedDom,e,t,!0),this._mountedDom;this._unmount();let r=this.createDom(e,t);return this._hide(r),yc().appendChild(r),this._mountedDom=r,this._mountedSignature=n,r}_unmount(){this._mountedDom?.parentNode?.removeChild(this._mountedDom),this._mountedDom=void 0,this._mountedSignature=void 0}dispose(){this._unmount()}};function xc(e,t,n){return e[`${t}${n}`]??e[t]??0}var Sc=class{measure(e,t,n,r){let i=r??cc;for(let t of e)for(let e of t.fragments)for(let t of e.characters)t.measureGlyph(i);return t.writingMode.includes(`vertical`)?this._measureVertical(e,t):this._measureHorizontal(e,t)}_rootPadding(e){return{top:xc(e,`padding`,`Top`),right:xc(e,`padding`,`Right`),bottom:xc(e,`padding`,`Bottom`),left:xc(e,`padding`,`Left`)}}_measureHorizontal(e,t){let n=this._rootPadding(t),r=typeof t.width==`number`,i=t.textWrap===`nowrap`,a=r&&!i?t.width-n.left-n.right:1/0,o=n.top,s=n.left;for(let t of e){let e=t.computedStyle,r=t.style,i=xc(r,`margin`,`Top`),c=xc(r,`margin`,`Bottom`),l=xc(r,`margin`,`Left`),u=xc(r,`margin`,`Right`),d=xc(r,`padding`,`Top`),f=xc(r,`padding`,`Bottom`),p=xc(r,`padding`,`Left`),m=xc(r,`padding`,`Right`),h=n.left+l+p,g=a===1/0?1/0:a-l-u-p-m;o+=i+d;let _=o,v=h,y=this._breakLines(t,g),b=e.textAlign,x=e.textIndent??0;for(let t=0;t<y.length;t++){let n=y[t],r=t===0?x:0,i=e.fontSize*e.lineHeight,a=0;for(let e of n)e.fontHeight>i&&(i=e.fontHeight),a+=this._advance(e);let s=h+r;if(g!==1/0){let e=g-r-a;b===`center`?s+=e/2:(b===`end`||b===`right`)&&(s+=e)}for(let e of n){let t=e.advanceWidth,n=e.advanceHeight,r=e.fontHeight;e.inlineBox.left=s,e.inlineBox.top=o+(i-n)/2,e.inlineBox.width=t,e.inlineBox.height=n,e.lineBox.left=s,e.lineBox.top=e.inlineBox.top+(n-r)/2,e.lineBox.width=t,e.lineBox.height=r,s+=this._advance(e)}s>v&&(v=s),o+=i}v>s&&(s=v);for(let e of t.fragments)this._unionInto(e.inlineBox,e.characters.map(e=>e.inlineBox));t.lineBox.left=h,t.lineBox.top=_,t.lineBox.width=g===1/0?v-h:g,t.lineBox.height=o-_,o+=f+c}let c=o+n.bottom,l=r?t.width:s+n.right,u=typeof t.height==`number`?t.height:c;if(typeof t.height==`number`){let n=u-c,r=t.verticalAlign,i=r===`middle`?n/2:r===`bottom`?n:0;i&&this._shiftAll(e,i)}return{paragraphs:e,boundingBox:new W(0,0,l,u)}}_measureVertical(e,t){let n=this._rootPadding(t),r=typeof t.height==`number`,i=t.textWrap===`nowrap`,a=r&&!i?t.height-n.top-n.bottom:1/0,o=[];for(let t of e){let e=t.computedStyle.fontSize*t.computedStyle.lineHeight;for(let n of this._breakLines(t,a)){let t=e;for(let e of n)e.fontHeight>t&&(t=e.fontHeight);o.push({chars:n,thickness:t})}}let s=o.reduce((e,t)=>e+t.thickness,0),c=typeof t.width==`number`,l=c?Math.max(t.width-n.left-n.right,s):s,u=n.left+l,d=n.top;for(let e of o){u-=e.thickness;let t=u,r=n.top;for(let n of e.chars){let i=n.advanceWidth,a=n.advanceHeight,o=n.fontHeight;n.inlineBox.top=r,n.inlineBox.height=i,n.inlineBox.width=a,n.inlineBox.left=t+(e.thickness-a)/2,n.lineBox.left=n.inlineBox.left+(a-o)/2,n.lineBox.top=r,n.lineBox.width=o,n.lineBox.height=i,r+=this._advance(n)}r>d&&(d=r)}for(let t of e){for(let e of t.fragments)this._unionInto(e.inlineBox,e.characters.map(e=>e.inlineBox));this._unionInto(t.lineBox,t.fragments.flatMap(e=>e.characters.map(e=>e.inlineBox)))}return{paragraphs:e,boundingBox:new W(0,0,c?t.width:l+n.left+n.right,r?t.height:d+n.bottom)}}_advance(e){return e.advanceWidth+(e.computedStyle.letterSpacing??0)}_breakLines(e,t){let n=[],r=[],i=0,a=()=>{n.push(r),r=[],i=0};for(let n of e.fragments)for(let e of n.characters){if(e.content===`
34
+ `||e.content===`\r`){a();continue}t!==1/0&&r.length>0&&i+e.advanceWidth>t&&a(),r.push(e),i+=this._advance(e)}return a(),n}_unionInto(e,t){let n=t.filter(e=>e.width!==0||e.height!==0);if(!n.length)return;let r=W.from(...n);e.left=r.left,e.top=r.top,e.width=r.width,e.height=r.height}_shiftAll(e,t){for(let n of e){n.lineBox.top+=t;for(let e of n.fragments){e.inlineBox.top+=t;for(let n of e.characters)n.inlineBox.top+=t,n.lineBox.top+=t}}}dispose(){}};function Cc(){let e=new Gr,t=Kr(),n=qr(t);return{name:`background`,pathSet:e,context:{loader:t,parser:n},load:async e=>{let{backgroundImage:n}=e.computedStyle;n&&t.needsLoad(n)&&await t.load(n)},update:t=>{e.paths.length=0;let{computedStyle:r,lineBox:i,isVertical:a}=t,{backgroundImage:o,backgroundSize:s,backgroundColormap:c}=r;if(O(o))return;let{pathSet:l}=n.parse(o),u=l.getBoundingBox(!0)??new W,d,f,p,m;a?{x:f,y:d,width:m,height:p}=i:{x:d,y:f,width:p,height:m}=i;let h=Zr(c??`none`),g=l.paths.map(e=>{let t=e.clone();return t.style.fill&&t.style.fill in h&&(t.style.fill=h[t.style.fill]),t.style.stroke&&t.style.stroke in h&&(t.style.stroke=h[t.style.stroke]),t}),_,v;if(s===`rigid`){_=t.fontSize*5/u.width,v=_;let e=new U;e.x=u.width-p/_,e.y=u.height-m/v,g.forEach(t=>{t.applyTransform(t=>{let n=t.x>u.left+u.width/2,r=t.y>u.top+u.height/2;n&&(t.x-=e.x),r&&(t.y-=e.y)})})}else _=p/u.width,v=m/u.height;let y=new Un;y.translate(-u.x,-u.y),y.scale(_,v),a&&(y.translate(-p/2,-m/2),y.rotate(Math.PI/2),y.translate(m/2,p/2)),y.translate(d,f),g.forEach(e=>{e.applyTransform(y)}),e.paths.push(...g)},renderOrder:-2,render:t=>{let{text:n,context:r}=t,{lineBox:i,computedStyle:a}=n;O(a.backgroundColor)||(r.fillStyle=a.backgroundColor,r.fillRect(...i.array)),e.paths.forEach(e=>{if(t.drawPath(e),n.debug){let t=new Gr([e]).getBoundingBox();t&&r.strokeRect(t.x,t.y,t.width,t.height)}}),n.paragraphs.forEach(e=>{let{lineBox:t,style:n}=e;O(n.backgroundColor)||(r.fillStyle=n.backgroundColor,r.fillRect(...t.array)),e.fragments.forEach(e=>{let{inlineBox:t,style:n}=e;O(n.backgroundColor)||(r.fillStyle=n.backgroundColor,r.fillRect(...t.array))})})}}}function wc(e,t){let{x:n,y:r}=t;if(e instanceof zr){let{p1:t,cp:i,p2:a}=e,o=n!==void 0&&Math.abs(Math.sign(t.x-n)+Math.sign(i.x-n)+Math.sign(a.x-n))===1,s=r!==void 0&&Math.abs(Math.sign(t.y-r)+Math.sign(i.y-r)+Math.sign(a.y-r))===1,c,l,u,d;if(o&&(c=t.x-2*i.x+a.x,l=2*(-t.x+i.x),u=t.x-n),s&&(c=t.y-2*i.y+a.y,l=2*(-t.y+i.y),u=t.y-r),(o||s)&&(d=l*l-4*c*u,d>0)){let e=Math.sqrt(d),n=[(-l+e)/2/c,(-l-e)/2/c].find(e=>e>0&&e<1);if(n){let e=U.lerp(t,i,n),r=U.lerp(i,a,n),o=U.lerp(e,r,n);return[new zr(t,e,o),new zr(o.clone(),r,a)]}}}else if(e instanceof Ir){let{p1:t,cp1:i,cp2:a,p2:o}=e,{min:s,max:c}=e.getMinMax(),l=n!==void 0&&(s.x-n)*(c.x-n)<0,u=r!==void 0&&(s.y-r)*(c.y-r)<0;if(l||u){n=.5*t.x+.5*i.x,r=.5*t.y+.5*i.y;let e=new U(n,r);n=.25*t.x+.5*i.x+.25*a.x,r=.25*t.y+.5*i.y+.25*a.y;let s=new U(n,r);n=.125*t.x+.375*i.x+.375*a.x+.125*o.x,r=.125*t.y+.375*i.y+.375*a.y+.125*o.y;let c=new U(n,r);n=.25*i.x+.5*a.x+.25*o.x,r=.25*i.y+.5*a.y+.25*o.y;let l=new U(n,r);n=.5*a.x+.5*o.x,r=.5*a.y+.5*o.y;let u=new U(n,r);return[new Ir(t,e,s,c),new Ir(c.clone(),l,u,o)]}}else if(e instanceof Pr){let{p1:t,p2:i}=e,a=n!==void 0&&(t.x-n)*(i.x-n)<0,o=r!==void 0&&(t.y-r)*(i.y-r)<0;if(a&&(r=t.y+(i.y-t.y)/(i.x-t.x)*(n-t.x)),o&&(n=t.x+(i.x-t.x)/(i.y-t.y)*(r-t.y)),a||o)return[new Pr(t,new U(n,r)),new Pr(new U(n,r),i)]}return[e]}var Tc=class{get boundingBox(){return this.text.lineBox}get paragraphs(){return this.text.paragraphs}get isHorizontal(){return this.text.computedStyle.writingMode.startsWith(`horizontal`)}get baseWidth(){return this.isHorizontal?this.boundingBox.width:this.boundingBox.height}get baseHeight(){return this.isHorizontal?this.boundingBox.height:this.boundingBox.width}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(e=>e.characters))}constructor({text:e,intensities:t=[],maxFontSize:n=100}){this.text=e,this.intensities=t.map(e=>e/100),this.lineHeight=n}_breakLine(){let e=!this.isHorizontal,{left:t,top:n,bottom:r,right:i}=this.boundingBox,a=.5*(t+i),o=.5*(n+r);this.characters.forEach(t=>{t.glyphBox&&t.path.curves.forEach(t=>{t.curves=t.curves.flatMap(t=>wc(t,e?{y:o}:{x:a}))})})}_makeTheJointSmooth(){this.characters.forEach(e=>{e.glyphBox&&e.path.getFlatCurves().forEach(e=>{if(e instanceof zr&&e.isFromLine){let{p1:t,cp:n,p2:r}=e;n.x=2*n.x-.5*(t.x+r.x),n.y=2*n.y-.5*(t.y+r.y)}})})}_lineToQuadraticBezier(){this.characters.forEach(e=>{e.glyphBox&&e.path.curves.forEach(e=>{e.curves=e.curves.map(e=>{if(e instanceof Pr&&e.getLength()>5){let{p1:t,p2:n}=e,r=new zr(t.clone(),new U(.5*(t.x+n.x),.5*(t.y+n.y)),n.clone());return r.isFromLine=!0,r}return e})})})}_transform(e,t,n){let r=this.text.plugins.get(`highlight`),i=n?.(),a=0,o=this.characters.filter(e=>e.glyphBox).length;this.paragraphs.forEach((n,s)=>{n.fragments.forEach((n,c)=>{n.characters.forEach((n,l)=>{if(!n.glyphBox)return;let u=t?.({paragraphIndex:s,fragmentIndex:c,characterIndex:l,character:n},i);if(n.path.getControlPointRefs().forEach(t=>{let[n,r]=e(t,u);t.set(n,r)}),t&&r?.pathSet?.paths){let t=r.pathSet.paths.length/o,n=a*t;for(let i=0;i<t;i++)r?.pathSet?.paths[n+i]?.getControlPointRefs().forEach(t=>{let[n,r]=e(t,u);t.set(n,r)});a++}})})}),this.paragraphs.forEach(e=>{e.fragments.forEach(e=>{e.characters.forEach(e=>{e.glyphBox=e.getGlyphBoundingBox(),e.glyphBox&&(e.inlineBox=e.glyphBox)})})}),t||r?.pathSet?.paths?.forEach(t=>{t.getControlPointRefs().forEach(t=>{let[n,r]=e(t);t.set(n,r)})})}},Ec=class extends Tc{preset;constructor(e,t){super(e),this.preset=t}deform(){Math.hypot(...this.intensities)&&(this._lineToQuadraticBezier(),this._bend(),this._makeTheJointSmooth())}_bend(){let{boundingBox:e,baseWidth:t,baseHeight:n,preset:r}=this,i=this.lineHeight*2/Math.sin(this.intensities[0]*Math.PI*.5),a=r.vertical===void 0||r.vertical===`auto`?!this.isHorizontal:r.vertical,{left:o,top:s,width:c,height:l}=e,u=(a?l:c)/2/i,d={x:o+c/2,y:s+l/2},f,p={x:d.x,y:d.y};a?(f=0,p.x-=n/2/Math.tan(u)+Math.sign(u)*c/2):(f=1.5*Math.PI,p.y+=t/2/Math.tan(u)+Math.sign(u)*l/2);let m=r.transform({lineHeight:i,size:u,center:d,centerDist:p,centerDistAngle:f,width:c,height:l,isHorizontal:this.isHorizontal});this._transform(m)}},Dc=class{arcLengthDivisions=200;_cacheArcLengths;_needsUpdate=!1;getPointAt(e,t=new U){return this.getPoint(this.getUToTMapping(e),t)}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;let t=[0],n=this.getPoint(0),r=0;for(let i=1;i<=e;i++){let a=this.getPoint(i/e);r+=a.distanceTo(n),t.push(r),n=a}return this._cacheArcLengths=t,t}getUToTMapping(e,t){let n=this.getLengths(),r=n.length,i=t===void 0?e*n[r-1]:t,a=0,o=r-1,s=0;for(;a<=o;){s=Math.floor(a+(o-a)/2);let e=n[s]-i;if(e<0)a=s+1;else if(e>0)o=s-1;else{o=s;break}}if(s=o,n[s]===i)return s/(r-1);let c=n[s],l=n[s+1]-c,u=(i-c)/l;return(s+u)/(r-1)}getTangent(e,t=new U){let n=1e-4,r=Math.max(0,e-n),i=Math.min(1,e+n);return t.copyFrom(this.getPoint(i).sub(this.getPoint(r)).normalize())}getNormal(e,t=new U){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}},Oc=class extends Dc{curveT=0;getPoint(e,t=new U){return this.getCurve(e).getPoint(this.curveT,t)}getPointAt(e,t=new U){return this.getPoint(e,t)}getTangent(e,t=new U){return this.getCurve(e).getTangent(this.curveT,t)}getNormal(e,t=new U){return this.getCurve(e).getNormal(this.curveT,t)}},kc=class extends Dc{start;end;constructor(e,t){super(),this.start=e,this.end=t}getPoint(e,t=new U){return e===1?t.copyFrom(this.end):t.copyFrom(this.end).sub(this.start).scale(e).add(this.start),t}getPointAt(e,t=new U){return this.getPoint(e,t)}getTangent(e,t=new U){return t.subVectors(this.end,this.start).normalize()}},Ac=class extends Dc{center;radius;start;end;constructor(e,t,n=0,r=Math.PI*2){super(),this.center=e,this.radius=t,this.start=n,this.end=r}getPoint(e,t=new U){return t.copyFrom(this.center).add(this.getNormal(e).scale(this.radius))}getTangent(e,t=new U){let{x:n,y:r}=this.getNormal(e);return t.set(-r,n)}getNormal(e,t=new U){let{start:n,end:r}=this,i=e*(r-n)+n-.5*Math.PI;return t.set(Math.cos(i),Math.sin(i))}},jc=class extends Dc{center;radiusX;radiusY;rotation;startAngle;endAngle;clockwise;constructor(e=new U,t=1,n=1,r=0,i=0,a=Math.PI*2,o=!1){super(),this.center=e,this.radiusX=t,this.radiusY=n,this.rotation=r,this.startAngle=i,this.endAngle=a,this.clockwise=o}getPoint(e,t=new U){let n=Math.PI*2,r=this.endAngle-this.startAngle,i=Math.abs(r)<2**-52;for(;r<0;)r+=n;for(;r>n;)r-=n;r<2**-52&&(r=i?0:n),this.clockwise&&!i&&(r=r===n?-n:r-n);let a=this.startAngle+e*r,o=this.center.x+this.radiusX*Math.cos(a),s=this.center.y+this.radiusY*Math.sin(a);if(this.rotation!==0){let e=Math.cos(this.rotation),t=Math.sin(this.rotation),n=o-this.center.x,r=s-this.center.y;o=n*e-r*t+this.center.x,s=n*t+r*e+this.center.y}return t.set(o,s)}},Mc=class extends Oc{center;size;start;end;curves=[];constructor(e,t,n=0,r=1){super(),this.center=e,this.size=t,this.start=n,this.end=r,this.update()}update(){let{x:e,y:t}=this.center,n=new U(e+.5*this.size,t-.5*this.size),r=new U(e-.5*this.size,t-.5*this.size),i=new U(e,t+.5*this.size),a=new Ac(n,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),o=new Ac(r,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),s=new Ac(i,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),c=new U(e,t+this.size),l=new U(e+this.size,t),u=U.lerp(l,c,.75),d=new U(e-this.size,t),f=U.lerp(d,c,.75),p=new kc(l,u),m=new kc(f,d);return this.curves=[a,p,s,m,o],this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1),t*=9*Math.PI/8+1.5;let n=.5*Math.PI,r;return t<n?(r=0,this.curveT=t/n):t<n+.75?(r=1,this.curveT=(t-n)/.75):t<5*Math.PI/8+.75?(r=2,this.curveT=(t-n-.75)/(Math.PI/8)):t<5*Math.PI/8+1.5?(r=3,this.curveT=(t-5*Math.PI/8-.75)/.75):(r=4,this.curveT=(t-5*Math.PI/8-1.5)/n),this.curves[r]}},Nc=class extends Oc{center;radius;number;start;end;curves=[];points=[];constructor(e,t=0,n=0,r=0,i=1){super(),this.center=e,this.radius=t,this.number=n,this.start=r,this.end=i,this.update()}update(){for(let e=0;e<this.number;e++){let t=e*2*Math.PI/this.number;t-=.5*Math.PI,this.points.push(new U(this.radius*Math.cos(t),this.radius*Math.sin(t)).add(this.center))}for(let e=0;e<this.number;e++)this.curves.push(new kc(this.points[e],this.points[(e+1)%this.number]));return this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1);let n=t*this.number,r=Math.floor(n);return this.curveT=n-r,this.curves[r]}},Pc=class extends Oc{center;rx;aspectRatio;start;end;curves=[];constructor(e,t,n=1,r=0,i=1){super(),this.center=e,this.rx=t,this.aspectRatio=n,this.start=r,this.end=i,this.update()}update(){let{x:e,y:t}=this.center,n=this.rx,r=this.rx/this.aspectRatio,i=[new U(e-n,t-r),new U(e+n,t-r),new U(e+n,t+r),new U(e-n,t+r)];for(let e=0;e<4;e++)this.curves.push(new kc(i[e].clone(),i[(e+1)%4].clone()));return this}getCurve(e){let t=(e*(this.end-this.start)+this.start)%1;t<0&&(t+=1),t*=(1+this.aspectRatio)*2;let n;return t<this.aspectRatio?(n=0,this.curveT=t/this.aspectRatio):t<this.aspectRatio+1?(n=1,this.curveT=t-this.aspectRatio):t<2*this.aspectRatio+1?(n=2,this.curveT=(t-this.aspectRatio-1)/this.aspectRatio):(n=3,this.curveT=t-2*this.aspectRatio-1),this.curves[n]}},Fc=class extends Tc{preset;constructor(e,t){super(e),this.preset=t}deform(){if(!Math.hypot(...this.intensities))return;let{preset:e}=this;e.breakLine&&this._breakLine(),e.lineToQuad&&this._lineToQuadraticBezier();let[t,n]=this.intensities,r=this._createFFDControlPoints(e.hBlocks,e.vBlocks);e.build(r,{a:t,b:n,baseWidth:this.baseWidth,baseHeight:this.baseHeight,lineHeight:this.lineHeight,adjust:(e,t,n)=>this._adjustControlPoints(e,{x:t,y:n})}),e.bezier?(this._calculateForBezierFFD(r,e.hBlocks,e.vBlocks),this._makeTheJointSmooth()):this._calculateForLinearFFD(r,e.hBlocks,e.vBlocks)}_calculateForFFD(e,t,n,r){let{left:i,top:a,right:o,width:s,height:c}=this.boundingBox;this._transform(this.isHorizontal?o=>{let l=(o.x-i)/s,u=(o.y-a)/c,[d,f]=[0,0];for(let i=0;i<n+2;i++){let a=e(n,i,l);for(let n=0;n<r+2;n++){let o=e(r,n,u),s=t[i*(r+2)+n];d+=a*o*s.x,f+=a*o*s.y}}return[d,f]}:i=>{let l=(o-i.x)/s,u=(i.y-a)/c,[d,f]=[0,0];for(let i=0;i<n+2;i++){let a=e(n,i,u);for(let n=0;n<r+2;n++){let o=e(r,n,l),s=t[i*(r+2)+n];d+=a*o*s.x,f+=a*o*s.y}}return[d,f]})}_createFFDControlPoints(e,t){let{left:n,top:r,right:i,width:a,height:o}=this.boundingBox,s=[];if(this.isHorizontal){let i=a/(e+1),c=o/(t+1);for(let a=0;a<e+2;a++)for(let e=0;e<t+2;e++)s.push(new U(n+a*i,r+e*c))}else{let n=a/(t+1),c=o/(e+1);for(let a=0;a<e+2;a++)for(let e=0;e<t+2;e++)s.push(new U(i-e*n,r+a*c))}return s}_adjustControlPoints(e,t){this.isHorizontal?(e.x+=t.x,e.y+=t.y):(e.x-=t.y,e.y+=t.x)}_factorialForFFD(e){let t=1;for(let n=2;n<=e;n++)t*=n;return t}_combineForFFD(e,t){return this._factorialForFFD(e)/this._factorialForFFD(e-t)/this._factorialForFFD(t)}_calculateForBezierFFD(e,t,n){this._calculateForFFD((e,t,n)=>this._combineForFFD(e+1,t)*(1-n)**(e+1-t)*n**t,e,t,n)}_linearBasis(e,t,n){let r=t<n*e?t+1-n*e:n*e-t+1;return Math.max(0,r)}_calculateForLinearFFD(e,t,n){this._calculateForFFD((e,t,n)=>this._linearBasis(e+1,t,n),e,t,n)}},Ic=class extends Tc{preset;constructor(e,t){super(e),this.preset=t}_context(){return{intensities:this.intensities,baseWidth:this.baseWidth,lineHeight:this.lineHeight,isHorizontal:this.isHorizontal,boundingBox:this.boundingBox}}deform(){if(!Math.hypot(...this.intensities))return;let{preset:e}=this,t=this._context();if(e.engine===`offset`)this._transform(e.point,e.perChar?n=>e.perChar(t,n):void 0);else{let n=e.followTangent??!0,{funcPerChar:r,funcPerPoint:i}=this._getPerCharAndPointFunc(n);this._transform(i,r,()=>{let{width:n,height:r,left:i,top:a}=this.boundingBox;return{width:n,height:r,left:i,top:a,curve:e.makeCurve(t),isHorizontal:this.isHorizontal,needExpandAlongNormal:e.expandAlongNormal??!1}})}}_getPerCharAndPointFunc(e=!1){let t,n;return e?(n=this._resetPointPos,t=this._calculateNewCenter):(n=this._resetPointPosWithoutRotate,t=this._calculateNewCenterWithoutRotate),{funcPerPoint:n,funcPerChar:t}}_calculateNewCenter({character:e},t){let{width:n,height:r,left:i,top:a,curve:o,isHorizontal:s,needExpandAlongNormal:c=!1}=t,{center:l,centerDiviation:u}=e,d=s?(l.x-i)/n:(l.y-a)/r,f=s?new U(0,l.y-a):new U(l.x-i,0);if(c){let e=o.getNormal(d);f.x+=e.x*-u,f.y+=e.y*-u}let p=o.getPointAt(d).add(f),m=o.getTangent(d);return{cos:m.x,sin:m.y,newCenter:p,center:l}}_calculateNewCenterWithoutRotate({character:e},t){let{width:n,height:r,left:i,top:a,curve:o,isHorizontal:s}=t,{center:c}=e,l=s?(c.x-i)/n:(c.y-a)/r,u=s?new U(0,c.y-a):new U(c.x-i,0);return{newCenter:o.getPointAt(l).add(u),center:c}}_resetPointPos(e,t){let{cos:n=1,sin:r=0,center:i,newCenter:a}=t,o=e.x-i.x,s=e.y-i.y;return[a.x+o*n-s*r,a.y+o*r+s*n]}_resetPointPosWithoutRotate(e,t){let{center:n,newCenter:r}=t;return[e.x-n.x+r.x,e.y-n.y+r.y]}},Lc=new Map;function Rc(e,t){Lc.set(e,t)}function zc(e){Lc.delete(e)}function Bc(){return[...Lc.keys()]}function Vc(){return _c({name:`deformation`,updateOrder:2,update:e=>{let t=e.deformation,n=t?.type;if(O(n)||!n)return;let r=Lc.get(n);if(!r)return;let i={text:e,intensities:t.intensities??r.defaultIntensities,maxFontSize:t.maxFontSize},a;switch(r.engine){case`ffd`:a=new Fc(i,r);break;case`bend`:a=new Ec(i,r);break;case`curve`:case`offset`:a=new Ic(i,r);break}a.deform();let o=e.getGlyphBox(),s=o.left,c=o.top;if(s||c){let t=e.plugins.get(`highlight`);for(let t of e.characters)t.glyphBox&&(t.path.getControlPointRefs().forEach(e=>{e.set(e.x-s,e.y-c)}),t.glyphBox=t.getGlyphBoundingBox(),t.glyphBox&&(t.inlineBox=t.glyphBox));t?.pathSet?.paths?.forEach(e=>{e.getControlPointRefs().forEach(e=>{e.set(e.x-s,e.y-c)})}),o=e.getGlyphBox()}e.rawGlyphBox=o,e.glyphBox=o,e.lineBox=o}})}function Hc(e){let{highlight:t,highlightImage:n,highlightReferImage:r,highlightColormap:i,highlightLine:a,highlightSize:o,highlightThickness:s}=e;return{image:t?.image??n??`none`,referImage:t?.referImage??r??`none`,colormap:t?.colormap??i??`none`,line:t?.line??a??`none`,size:t?.size??o??`cover`,thickness:t?.thickness??s??`100%`}}function Uc(){let e=new Gr,t=[],n=Kr(),r=qr(n);return _c({name:`highlight`,pathSet:e,context:{clipRects:t,loader:n,parser:r},load:async e=>{let t=new Set;e.forEachCharacter(e=>{let{computedStyle:r}=e,{image:i,referImage:a}=Hc(r);i&&n.needsLoad(i)&&t.add(i),a&&n.needsLoad(a)&&t.add(a)}),await Promise.all(Array.from(t).map(e=>n.load(e)))},update:n=>{t.length=0,e.paths.length=0;let i=[],a,o;n.forEachCharacter(e=>{let{computedStyle:t}=e,n=Hc(t),{image:r,colormap:s,line:c,size:l,thickness:u}=n;if(O(r))a?.length&&(a=[],i.push(a));else{let{inlineBox:n,isVertical:d}=e,{fontSize:f}=t;(!o||$r(o.image,r)&&$r(o.colormap,s)&&$r(o.line,c)&&$r(o.size,l)&&$r(o.thickness,u))&&a?.length&&(d?a[0].inlineBox.left===n.left:a[0].inlineBox.top===n.top)&&a[0].fontSize===f?a.push(e):(a=[],a.push(e),i.push(a))}o=n}),i=i.filter(e=>e.length);for(let n=0;n<i.length;n++){let a=i[n],o=a[0],s=W.from(...a.map(e=>e.compatibleGlyphBox));if(!s.height||!s.width)continue;let{computedStyle:c,isVertical:l,inlineBox:u,compatibleGlyphBox:d,strikeoutPosition:f,underlinePosition:p}=o,{fontSize:m}=c,{image:h,referImage:g,colormap:_,line:v,size:y,thickness:b}=Hc(c),x=Xr(b,{fontSize:m,total:s.width})/s.width,S=Zr(_),{pathSet:C,dom:w}=r.parse(h),T=C.getBoundingBox(!0)??new W,E=m/T.width*2,D=new W().copy(s);l&&(D.width=s.height,D.height=s.width,D.left=s.left+s.width);let k=Math.floor(D.width),A=k;y!==`cover`&&(A=Xr(y,{fontSize:m,total:s.width})||k,D.width=A);let j=!O(g)&&O(v);if(j)T.copy(r.parse(g).pathSet.getBoundingBox(!0)??new W);else{let e;if(O(v))if(T.width/T.height>4){e=`underline`;let t=w.getAttribute(`viewBox`);if(t){let[n,r,i,a]=t.split(` `).map(e=>Number(e)),o=r+a/2;e=T.y<o&&T.y+T.height>o?`line-through`:T.y+T.height<o?`overline`:`underline`}}else e=`outline`;else e=v;switch(e){case`outline`:{let e=D.width*.2,t=D.height*.2;l?(D.x-=t/2,D.y-=e/2,D.x-=D.height):(D.x-=e/2,D.y-=t/2),D.width+=e,D.height+=t;break}case`overline`:D.height=T.height*E,l?D.x=u.left+u.width:D.y=u.top;break;case`line-through`:D.height=T.height*E,l?D.x=u.left+u.width-f+D.height/2:D.y=u.top+f-D.height/2;break;case`underline`:D.height=T.height*E,l?D.x=d.left+d.width-p:D.y=u.top+p;break}}let M=new Un;if(M.translate(-T.x,-T.y),M.scale(D.width/T.width,D.height/T.height),l){let e=D.width/2,t=D.height/2;j||M.translate(-e,-t),M.rotate(Math.PI/2),j||M.translate(t,e)}M.translate(D.x,D.y);for(let n=0;n<Math.ceil(k/A);n++){let r=M.clone();l?r.translate(0,n*D.width):r.translate(n*D.width,0),C.paths.forEach(n=>{let i=n.clone().applyTransform(r);i.style.strokeWidth&&(i.style.strokeWidth*=E*x),i.style.strokeMiterlimit&&(i.style.strokeMiterlimit*=E),i.style.strokeDashoffset&&(i.style.strokeDashoffset*=E),i.style.strokeDasharray&&(i.style.strokeDasharray=i.style.strokeDasharray.map(e=>e*E)),i.style.fill&&i.style.fill in S&&(i.style.fill=S[i.style.fill]),i.style.stroke&&i.style.stroke in S&&(i.style.stroke=S[i.style.stroke]),e.paths.push(i),k!==A&&(l?t[e.paths.length-1]=new W(s.left-s.width*2,s.top,s.width*4,s.height):t[e.paths.length-1]=new W(s.left,s.top-s.height*2,s.width,s.height*4))})}}},renderOrder:-1,getBoundingBox:()=>{let n=[];return e.paths.forEach((e,r)=>{let i=t[r],a=e.getBoundingBox();if(i){let e=Math.max(a.x,i.x),t=Math.max(a.y,i.y),n=Math.min(a.right,i.right),r=Math.min(a.bottom,i.bottom);a=new W(e,t,n-e,r-t)}n.push(a)}),n.length?W.from(...n):void 0},render:n=>{let{text:r,context:i}=n;e.paths.forEach((e,a)=>{if(n.drawPath(e,{clipRect:t[a]}),r.debug){let t=new Gr([e]).getBoundingBox();t&&i.strokeRect(t.x,t.y,t.width,t.height)}})}})}function Wc(e,t){return`<svg width="${e*2}" height="${e*2}" xmlns="http://www.w3.org/2000/svg">
35
35
  <circle cx="${e}" cy="${e}" r="${e}" fill="${t}" />
36
36
  </svg>`}function Gc(){let e=new Gr;return _c({name:`listStyle`,pathSet:e,update:t=>{e.paths.length=0;let{paragraphs:n,isVertical:r,fontSize:i}=t,a=i*.45;n.forEach(t=>{let{computedStyle:n}=t,{color:o,listStyleImage:s,listStyleColormap:c,listStyleSize:l,listStyleType:u}=n,d=Zr(c),f=l,p;if(!O(s))p=s;else if(!O(u)){let e=i*.38/2;switch(f=f===`cover`?e*2:f,u){case`disc`:p=Wc(e,String(o));break}}if(!p)return;let m=br(p),h=m.getBoundingBox()??new W,g=t.fragments[0]?.characters[0];if(!g)return;let{inlineBox:_}=g,v=f===`cover`?1:Xr(f,{total:i,fontSize:i})/i,y=new Un;if(r){let e=i/h.height*v;y.translate(-h.left,-h.top).rotate(-Math.PI/2).scale(e,e).translate(_.left+(_.width-h.height*e)/2,_.top-a)}else{let e=i/h.height*v;y.translate(-h.left,-h.top).scale(e,e).translate(_.left-h.width*e-a,_.top+(_.height-h.height*e)/2)}e.paths.push(...m.paths.map(e=>{let t=e.clone();return t.applyTransform(y),t.style.fill&&t.style.fill in d&&(t.style.fill=d[t.style.fill]),t.style.stroke&&t.style.stroke in d&&(t.style.stroke=d[t.style.stroke]),t}))})}})}function Kc(){return{name:`outline`}}function qc(){let e=new Gr;return _c({name:`render`,pathSet:e,update:t=>{e.paths.length=0;let{paragraphs:n}=t;n.forEach(t=>{t.fragments.forEach(t=>{t.characters.forEach(t=>{e.paths.push(t.path)})})})},getBoundingBox:e=>{let{characters:t,computedEffects:n,fontSize:r}=e,i=[];return n.forEach(n=>{let a=Jr(e,n);t.forEach(e=>{if(!e.glyphBox)return;let t=e.glyphBox.clone(),o=a.apply({x:t.left,y:t.top}),s=a.apply({x:t.right,y:t.top}),c=a.apply({x:t.right,y:t.bottom}),l=a.apply({x:t.left,y:t.bottom}),u=Math.min(o.x,s.x,c.x,l.x),d=Math.min(o.y,s.y,c.y,l.y),f=Math.max(o.x,s.x,c.x,l.x),p=Math.max(o.y,s.y,c.y,l.y);if(t.left=u,t.top=d,t.width=f-u,t.height=p-d,n.shadow?.enabled){let e=(n.shadow.offsetX??0)*r,i=(n.shadow.offsetY??0)*r,a=(n.shadow.blur??0)*r,o=t.left+Math.min(0,e-a),s=t.top+Math.min(0,i-a),c=t.left+t.width+Math.max(0,e+a),l=t.top+t.height+Math.max(0,i+a);t.left=o,t.top=s,t.width=c-o,t.height=l-s}if(n.outline?.enabled){let e=Math.max(.1,n.outline.width??0);t.left-=e,t.top-=e,t.width+=e*2,t.height+=e*2}i.push(t)})}),i.length?W.from(...i):void 0},render:e=>{let{text:t,context:n}=e,{paragraphs:r,glyphBox:i,computedEffects:a}=t;r.length&&(a.length?a.forEach(r=>{if(e.uploadColor(i,r),n.save(),e.transformEffect(r),r.shadow?.enabled){let n={...r,shadow:{...r.shadow,enabled:!1}};e.drawWithShadow(r.shadow,()=>{t.forEachCharacter(t=>{e.drawCharacter(t,n)})})}else t.forEachCharacter(t=>{e.drawCharacter(t,r)});n.restore()}):r.forEach(t=>{t.fragments.forEach(t=>{t.characters.forEach(t=>{e.drawCharacter(t)})})}),t.debug&&r.forEach(e=>{n.strokeRect(e.lineBox.x,e.lineBox.y,e.lineBox.width,e.lineBox.height)}))}})}function Jc(){let e=new Gr;return _c({name:`textDecoration`,pathSet:e,update:t=>{e.paths.length=0;let n=[],r,i;t.forEachCharacter(e=>{let{computedStyle:t,isVertical:a,inlineBox:o,underlinePosition:s,underlineThickness:c,strikeoutPosition:l,strikeoutSize:u}=e,{color:d,textDecoration:f,writingMode:p}=t;if(O(f))i=void 0;else{let m=!1;if(i?.textDecoration===f&&i?.writingMode===p&&i?.color===d&&(a?r[0].inlineBox.left===o.left:r[0].inlineBox.top===o.top))switch(f){case`underline`:r[0].underlinePosition===s&&r[0].underlineThickness===c&&(m=!0);break;case`line-through`:r[0].strikeoutPosition===l&&r[0].strikeoutSize===u&&(m=!0);break}m?r.push(e):(r=[],r.push(e),n.push(r)),i=t}}),n.forEach(t=>{let{computedStyle:n,isVertical:r,underlinePosition:i,underlineThickness:a,strikeoutPosition:o,strikeoutSize:s}=t[0],{color:c,textDecoration:l}=n,{left:u,top:d,width:f,height:p}=W.from(...t.map(e=>e.inlineBox)),m=r?u+f:d,h=r?-1:1,g=0;switch(l){case`overline`:g=a*2;break;case`underline`:m+=h*i,g=a*2;break;case`line-through`:m+=h*o,g=s*2;break}m-=g;let _;_=r?new Wr([{type:`M`,x:m,y:d},{type:`L`,x:m,y:d+p},{type:`L`,x:m+g,y:d+p},{type:`L`,x:m+g,y:d},{type:`Z`}],{fill:c}):new Wr([{type:`M`,x:u,y:m},{type:`L`,x:u+f,y:m},{type:`L`,x:u+f,y:m+g},{type:`L`,x:u,y:m+g},{type:`Z`}],{fill:c}),e.paths.push(_)})},render:t=>{let{text:n,context:r}=t,{computedEffects:i}=n;i.length?i.forEach(n=>{r.save(),t.transformEffect(n),e.paths.forEach(e=>{t.drawPath(e,t.effectToPathStyle(n))}),r.restore()}):e.paths.forEach(e=>{t.drawPath(e)})}})}function Yc(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function Xc(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var Zc,Qc=rt(),$c=class extends oe{needsUpdate=!0;computedStyle={...Qc};computedFill;computedOutline;computedEffects=[];inlineBox=new W;lineBox=new W;rawGlyphBox=new W;glyphBox=new W;pathBox=new W;boundingBox=new W;measurer=new bc;plugins=new Map;pathSets=[];_paragraphs=[];_cachedCharacters;_pluginsByUpdateOrder=[];_pluginsByRenderOrder=[];_renderer;_rendererCtx;get paragraphs(){return this._paragraphs}set paragraphs(e){this._paragraphs=e,this._cachedCharacters=void 0}get fontSize(){return this.computedStyle.fontSize}get defaultFamily(){return this.fonts?.fallbackFont?.familySet.values().next().value??`sans-serif`}get isVertical(){return this.computedStyle.writingMode.includes(`vertical`)}get characters(){if(this._cachedCharacters)return this._cachedCharacters;let e=[],t=this._paragraphs;for(let n=0;n<t.length;n++){let r=t[n].fragments;for(let t=0;t<r.length;t++){let n=r[t].characters;for(let t=0;t<n.length;t++)e.push(n[t])}}return this._cachedCharacters=e,e}constructor(e={}){super(),this.set(e)}set(e={}){let{content:t,effects:n,style:r,measureDom:i,fonts:a,fill:o,outline:s,deformation:c}=ft(e);if(e.measurer&&typeof e.measurer!=`string`)this.measurer=e.measurer;else{let t=e.measurer??`font`;this.measurer=t===`font`?new Sc:new bc}this.debug=e.debug??!1,this.content=t,this.effects=n,this.style=r,this.measureDom=i,this.fonts=a,this.fill=o,this.outline=s,this.deformation=c,this.use(Cc()).use(Kc()).use(Gc()).use(Jc()).use(Uc()).use(qc()).use(Vc()),(e.plugins??[]).forEach(e=>{this.use(e)}),this._update()}use(e){return this.plugins.set(e.name,e),this._resortPlugins(),this}_resortPlugins(){this._pluginsByUpdateOrder=[...this.plugins.values()].sort((e,t)=>(e.updateOrder??0)-(t.updateOrder??0)),this._pluginsByRenderOrder=[...this.plugins.values()].sort((e,t)=>(e.renderOrder??0)-(t.renderOrder??0))}forEachCharacter(e){let t=this._paragraphs;for(let n=0;n<t.length;n++){let r=t[n].fragments;for(let t=0;t<r.length;t++){let i=r[t].characters;for(let r=0;r<i.length;r++)e(i[r],{paragraphIndex:n,fragmentIndex:t,characterIndex:r})}}return this}async load(){this._update(),await Promise.all([this._decodeFonts(),...Array.from(this.plugins.values()).map(e=>e.load?.(this))])}async _decodeFonts(){let e=this.fonts??cc,t=new Set;for(let n of this.characters){let r=n.computedStyle.fontFamily;r&&t.add(e.get(r))}t.add(e.fallbackFont),await Promise.all(Array.from(t,async e=>{let t=e?.getFont();t&&typeof t.createSFNTAsync==`function`&&!t._sfnt&&(t._sfnt=await t.createSFNTAsync())}))}_normalizeComputedStyle(e){let t=e;for(let e in Qc){let n=Qc[e];if(typeof n!=`number`)continue;let r=t[e];if(typeof r==`number`)Number.isFinite(r)||(t[e]=n);else{let i=Number.parseFloat(r);t[e]=Number.isFinite(i)?i:n}}return e}_update(){this.computedStyle=this._normalizeComputedStyle({...Qc,...this.style}),this.computedFill=this.fill?{...this.fill}:void 0,this.computedOutline=this.outline?{...this.outline}:void 0,this.computedEffects=this.effects?.map(e=>e)??[];let e=[];return this.content.forEach((t,n)=>{let{fragments:r,fill:i,outline:a,...o}=t,s=new gc(o,n,this);s.fill=i,s.outline=a,r.forEach((e,t)=>{let{content:n,fill:r,outline:i,...a}=e;n!==void 0&&s.fragments.push(new hc(n,a,r,i,t,s))}),e.push(s)}),this.paragraphs=e,this}createDom(){if(this._update(),!this.measurer.createDom)throw Error(`current measurer does not support createDom()`);return this.measurer.createDom(this.paragraphs,this.computedStyle)}measure(e=this.measureDom){let t={paragraphs:this.paragraphs,inlineBox:this.inlineBox,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this._update();let n=this.measurer.measure(this.paragraphs,this.computedStyle,e,this.fonts);this.paragraphs=n.paragraphs,this.lineBox=n.boundingBox;let r=this.characters;for(let e=0;e<r.length;e++)r[e].update(this.fonts);let i=this.getGlyphBox();this.rawGlyphBox=i,this.glyphBox=i;let a=this._pluginsByUpdateOrder;for(let e=0;e<a.length;e++)a[e].update?.(this);let o=this._pluginsByRenderOrder;this.pathSets.length=0;for(let e=0;e<o.length;e++){let t=o[e];t.pathSet?.paths.length&&this.pathSets.push(t.pathSet)}this._updateInlineBox()._updatePathBox()._updateBoundingBox();for(let e in t){let r=this[e];this[e]=t[e],n[e]=r}return this.emit(`measure`,{text:this,result:n}),n}getGlyphBox(){let e=U.MAX,t=U.MIN,n=this.characters;for(let r=0;r<n.length;r++){let i=n[r];if(i.getGlyphMinMax(e,t))continue;let{left:a,top:o,width:s,height:c}=i.inlineBox,l=new U(a,o),u=new U(a+s,o+c);e.clampMin(l,u),t.clampMax(l,u)}return e.x===-(2**53-1)||e.y===-(2**53-1)||t.x===2**53-1||t.y===2**53-1?new W(0,0,0,0):new W(e.x,e.y,t.x-e.x,t.y-e.y)}_updateInlineBox(){let e=[],t=this._paragraphs;for(let n=0;n<t.length;n++){let r=t[n].fragments;for(let t=0;t<r.length;t++)e.push(r[t].inlineBox)}return this.inlineBox=W.from(...e),this}_updatePathBox(){let e=[this.glyphBox];for(let t of this.plugins.values()){let n=t.getBoundingBox?t.getBoundingBox(this):t.pathSet?.getBoundingBox();n&&e.push(n)}return this.pathBox=W.from(...e),this}_updateBoundingBox(){return this.boundingBox=W.from(this.rawGlyphBox,this.lineBox,this.pathBox),this}requestUpdate(){return this.needsUpdate=!0,this}update(e=this.measureDom){return this.needsUpdate=!1,Object.assign(this,this.measure(e)),this.emit(`update`,{text:this}),this}_getRenderer(e){return(!this._renderer||this._rendererCtx!==e)&&(this._renderer=new ei(this,e),this._rendererCtx=e),this._renderer}render(e){let{view:t,pixelRatio:n=2}=e,r=t.getContext(`2d`);if(!r)return;this.needsUpdate&&this.update();let i=this._getRenderer(r);i.pixelRatio=n,i.setup();let a=this._pluginsByRenderOrder;for(let e=0;e<a.length;e++){let t=a[e];if(t.render)t.render(i);else if(t.pathSet){let e=t.pathSet.paths;for(let t=0;t<e.length;t++)i.drawPath(e[t])}}this.emit(`render`,{text:this,view:t,pixelRatio:n}),e.onContext?.(r)}dispose(){this.measurer.dispose?.(),this._renderer=void 0,this._rendererCtx=void 0}toString(){return this.content.flatMap(e=>e.fragments.map(e=>e.content)).join(``)}};Xc([ae({internal:!0}),Yc(`design:type`,Boolean)],$c.prototype,`debug`,void 0),Xc([ae(),Yc(`design:type`,Object)],$c.prototype,`content`,void 0),Xc([ae(),Yc(`design:type`,Object)],$c.prototype,`style`,void 0),Xc([ae(),Yc(`design:type`,Object)],$c.prototype,`effects`,void 0),Xc([ae(),Yc(`design:type`,Object)],$c.prototype,`fill`,void 0),Xc([ae(),Yc(`design:type`,Object)],$c.prototype,`outline`,void 0),Xc([ae(),Yc(`design:type`,Object)],$c.prototype,`deformation`,void 0),Xc([ae({internal:!0}),Yc(`design:type`,typeof(Zc=typeof HTMLElement<`u`&&HTMLElement)==`function`?Zc:Object)],$c.prototype,`measureDom`,void 0),Xc([ae({internal:!0}),Yc(`design:type`,Object)],$c.prototype,`fonts`,void 0);function el(e,t){let n=new $c(e);return t?n.load().then(()=>n.measure()):n.measure()}function tl(e,t){let n=new $c(e);return t?n.load().then(()=>n.render(e)):n.render(e)}e.Canvas2DRenderer=ei,e.Character=mc,e.CircleCurve=Ac,e.DomMeasurer=bc,e.EllipseCurve=jc,e.FontMeasurer=Sc,e.Fragment=hc,e.HeartCurve=Mc,e.Paragraph=gc,e.PolygonCurve=Nc,e.RectangularCurve=Pc,e.Text=$c,e.backgroundPlugin=Cc,e.createSvgLoader=Kr,e.createSvgParser=qr,e.defineDeformation=Rc,e.definePlugin=_c,e.deformationPlugin=Vc,e.getDeformationNames=Bc,e.getEffectTransform2D=Jr,e.getHighlightStyle=Hc,e.highlightPlugin=Uc,e.isEqualObject=Qr,e.isEqualValue=$r,e.listStylePlugin=Gc,e.measureText=el,e.outlinePlugin=Kc,e.parseColormap=Zr,e.parseTransformOrigin=Yr,e.parseValueNumber=Xr,e.removeDeformation=zc,e.renderPlugin=qc,e.renderText=tl,e.textDecorationPlugin=Jc,e.textDefaultStyle=Qc});
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { T as Text } from './shared/modern-text.C0KJgvwC.mjs';
2
- export { C as Canvas2DRenderer, a as Character, D as DomMeasurer, F as FontMeasurer, b as Fragment, P as Paragraph, c as backgroundPlugin, d as createSvgLoader, e as createSvgParser, g as getEffectTransform2D, f as getHighlightStyle, h as highlightPlugin, i as isEqualObject, j as isEqualValue, l as listStylePlugin, o as outlinePlugin, p as parseColormap, k as parseTransformOrigin, m as parseValueNumber, r as renderPlugin, t as textDecorationPlugin, n as textDefaultStyle } from './shared/modern-text.C0KJgvwC.mjs';
3
- export { d as defineDeformation, a as definePlugin, b as deformationPlugin, g as getDeformationNames, r as removeDeformation } from './shared/modern-text.JF1ny7A-.mjs';
1
+ import { T as Text } from './shared/modern-text.rc-b3qK8.mjs';
2
+ export { C as Canvas2DRenderer, a as Character, D as DomMeasurer, F as FontMeasurer, b as Fragment, P as Paragraph, c as backgroundPlugin, d as createSvgLoader, e as createSvgParser, g as getEffectTransform2D, f as getHighlightStyle, h as highlightPlugin, i as isEqualObject, j as isEqualValue, l as listStylePlugin, o as outlinePlugin, p as parseColormap, k as parseTransformOrigin, m as parseValueNumber, r as renderPlugin, t as textDecorationPlugin, n as textDefaultStyle } from './shared/modern-text.rc-b3qK8.mjs';
3
+ export { d as defineDeformation, a as definePlugin, b as deformationPlugin, g as getDeformationNames, r as removeDeformation } from './shared/modern-text.K8BlyK2j.mjs';
4
4
  export { C as CircleCurve, E as EllipseCurve, H as HeartCurve, P as PolygonCurve, R as RectangularCurve } from './shared/modern-text.fT17R5HY.mjs';
5
5
  import 'modern-font';
6
6
  import 'modern-idoc';
@@ -3,7 +3,7 @@
3
3
  const modernFont = require('modern-font');
4
4
  const modernIdoc = require('modern-idoc');
5
5
  const modernPath2d = require('modern-path2d');
6
- const deformation = require('./modern-text.B2xfrqDc.cjs');
6
+ const deformation = require('./modern-text.DQWdaYoZ.cjs');
7
7
 
8
8
  function createSvgLoader() {
9
9
  const loaded = /* @__PURE__ */ new Map();
@@ -1114,7 +1114,8 @@ class FontMeasurer {
1114
1114
  _measureHorizontal(paragraphs, rootStyle) {
1115
1115
  const rootPad = this._rootPadding(rootStyle);
1116
1116
  const hasWidth = typeof rootStyle.width === "number";
1117
- const availWidth = hasWidth ? rootStyle.width - rootPad.left - rootPad.right : Infinity;
1117
+ const noWrap = rootStyle.textWrap === "nowrap";
1118
+ const availWidth = hasWidth && !noWrap ? rootStyle.width - rootPad.left - rootPad.right : Infinity;
1118
1119
  let y = rootPad.top;
1119
1120
  let maxRight = rootPad.left;
1120
1121
  for (const paragraph of paragraphs) {
@@ -1217,7 +1218,8 @@ class FontMeasurer {
1217
1218
  _measureVertical(paragraphs, rootStyle) {
1218
1219
  const rootPad = this._rootPadding(rootStyle);
1219
1220
  const hasHeight = typeof rootStyle.height === "number";
1220
- const availHeight = hasHeight ? rootStyle.height - rootPad.top - rootPad.bottom : Infinity;
1221
+ const noWrap = rootStyle.textWrap === "nowrap";
1222
+ const availHeight = hasHeight && !noWrap ? rootStyle.height - rootPad.top - rootPad.bottom : Infinity;
1221
1223
  const columns = [];
1222
1224
  for (const paragraph of paragraphs) {
1223
1225
  const strut = paragraph.computedStyle.fontSize * paragraph.computedStyle.lineHeight;
@@ -541,7 +541,30 @@ function deformationPlugin() {
541
541
  break;
542
542
  }
543
543
  deformer.deform();
544
- const box = text.getGlyphBox();
544
+ let box = text.getGlyphBox();
545
+ const dx = box.left;
546
+ const dy = box.top;
547
+ if (dx || dy) {
548
+ const highlight = text.plugins.get("highlight");
549
+ for (const character of text.characters) {
550
+ if (!character.glyphBox) {
551
+ continue;
552
+ }
553
+ character.path.getControlPointRefs().forEach((point) => {
554
+ point.set(point.x - dx, point.y - dy);
555
+ });
556
+ character.glyphBox = character.getGlyphBoundingBox();
557
+ if (character.glyphBox) {
558
+ character.inlineBox = character.glyphBox;
559
+ }
560
+ }
561
+ highlight?.pathSet?.paths?.forEach((path) => {
562
+ path.getControlPointRefs().forEach((point) => {
563
+ point.set(point.x - dx, point.y - dy);
564
+ });
565
+ });
566
+ box = text.getGlyphBox();
567
+ }
545
568
  text.rawGlyphBox = box;
546
569
  text.glyphBox = box;
547
570
  text.lineBox = box;
@@ -539,7 +539,30 @@ function deformationPlugin() {
539
539
  break;
540
540
  }
541
541
  deformer.deform();
542
- const box = text.getGlyphBox();
542
+ let box = text.getGlyphBox();
543
+ const dx = box.left;
544
+ const dy = box.top;
545
+ if (dx || dy) {
546
+ const highlight = text.plugins.get("highlight");
547
+ for (const character of text.characters) {
548
+ if (!character.glyphBox) {
549
+ continue;
550
+ }
551
+ character.path.getControlPointRefs().forEach((point) => {
552
+ point.set(point.x - dx, point.y - dy);
553
+ });
554
+ character.glyphBox = character.getGlyphBoundingBox();
555
+ if (character.glyphBox) {
556
+ character.inlineBox = character.glyphBox;
557
+ }
558
+ }
559
+ highlight?.pathSet?.paths?.forEach((path) => {
560
+ path.getControlPointRefs().forEach((point) => {
561
+ point.set(point.x - dx, point.y - dy);
562
+ });
563
+ });
564
+ box = text.getGlyphBox();
565
+ }
543
566
  text.rawGlyphBox = box;
544
567
  text.glyphBox = box;
545
568
  text.lineBox = box;
@@ -1,7 +1,7 @@
1
1
  import { fonts } from 'modern-font';
2
2
  import { isNone, isGradient, normalizeGradient, clearUndef, Reactivable, normalizeText, getDefaultStyle, property } from 'modern-idoc';
3
3
  import { svgToDom, svgToPath2DSet, Path2DSet, Transform2D, setCanvasContext, Path2D, BoundingBox, Vector2 } from 'modern-path2d';
4
- import { a as definePlugin, b as deformationPlugin } from './modern-text.JF1ny7A-.mjs';
4
+ import { a as definePlugin, b as deformationPlugin } from './modern-text.K8BlyK2j.mjs';
5
5
 
6
6
  function createSvgLoader() {
7
7
  const loaded = /* @__PURE__ */ new Map();
@@ -1112,7 +1112,8 @@ class FontMeasurer {
1112
1112
  _measureHorizontal(paragraphs, rootStyle) {
1113
1113
  const rootPad = this._rootPadding(rootStyle);
1114
1114
  const hasWidth = typeof rootStyle.width === "number";
1115
- const availWidth = hasWidth ? rootStyle.width - rootPad.left - rootPad.right : Infinity;
1115
+ const noWrap = rootStyle.textWrap === "nowrap";
1116
+ const availWidth = hasWidth && !noWrap ? rootStyle.width - rootPad.left - rootPad.right : Infinity;
1116
1117
  let y = rootPad.top;
1117
1118
  let maxRight = rootPad.left;
1118
1119
  for (const paragraph of paragraphs) {
@@ -1215,7 +1216,8 @@ class FontMeasurer {
1215
1216
  _measureVertical(paragraphs, rootStyle) {
1216
1217
  const rootPad = this._rootPadding(rootStyle);
1217
1218
  const hasHeight = typeof rootStyle.height === "number";
1218
- const availHeight = hasHeight ? rootStyle.height - rootPad.top - rootPad.bottom : Infinity;
1219
+ const noWrap = rootStyle.textWrap === "nowrap";
1220
+ const availHeight = hasHeight && !noWrap ? rootStyle.height - rootPad.top - rootPad.bottom : Infinity;
1219
1221
  const columns = [];
1220
1222
  for (const paragraph of paragraphs) {
1221
1223
  const strut = paragraph.computedStyle.fontSize * paragraph.computedStyle.lineHeight;
@@ -2,10 +2,10 @@
2
2
 
3
3
  const diff = require('diff');
4
4
  const modernIdoc = require('modern-idoc');
5
- const Text = require('../shared/modern-text.BMeLbf5d.cjs');
5
+ const Text = require('../shared/modern-text.CKFvdNej.cjs');
6
6
  require('modern-font');
7
7
  require('modern-path2d');
8
- require('../shared/modern-text.B2xfrqDc.cjs');
8
+ require('../shared/modern-text.DQWdaYoZ.cjs');
9
9
 
10
10
  var __defProp = Object.defineProperty;
11
11
  var __decorateClass = (decorators, target, key, kind) => {
@@ -1,9 +1,9 @@
1
1
  import { diffChars } from 'diff';
2
2
  import { isCRLF, textContentToString, normalizeCRLF, normalizeTextContent, property } from 'modern-idoc';
3
- import { T as Text } from '../shared/modern-text.C0KJgvwC.mjs';
3
+ import { T as Text } from '../shared/modern-text.rc-b3qK8.mjs';
4
4
  import 'modern-font';
5
5
  import 'modern-path2d';
6
- import '../shared/modern-text.JF1ny7A-.mjs';
6
+ import '../shared/modern-text.K8BlyK2j.mjs';
7
7
 
8
8
  var __defProp = Object.defineProperty;
9
9
  var __decorateClass = (decorators, target, key, kind) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-text",
3
3
  "type": "module",
4
- "version": "2.0.6",
4
+ "version": "2.0.8",
5
5
  "packageManager": "pnpm@10.18.1",
6
6
  "description": "Measure and render text in a way that describes the DOM.",
7
7
  "author": "wxm",