modern-text 0.1.21 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class E{constructor(t=0,n=0,o=0,u=0){this.x=t,this.y=n,this.width=o,this.height=u}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}static from(...t){const n=t[0],o=t.slice(1).reduce((u,s)=>(u.x=Math.min(u.x,s.x),u.y=Math.min(u.y,s.y),u.right=Math.max(u.right,s.right),u.bottom=Math.max(u.bottom,s.bottom),u),{x:n.x,y:n.y,right:n.right,bottom:n.bottom});return new E(o.x,o.y,o.right-o.x,o.bottom-o.y)}rotate90deg(){const{width:t,height:n}=this;this.width=n,this.height=t}translate(t,n){return this.x+=t,this.y+=n,this}clone(){return new E(this.x,this.y,this.width,this.height)}toArray(){return[this.x,this.y,this.width,this.height]}}function P(r,t){switch(r.shadowColor=t.shadowColor||"rgba(0, 0, 0, 0)",r.shadowOffsetX=t.shadowOffsetX||0,r.shadowOffsetY=t.shadowOffsetY||0,r.shadowBlur=t.shadowBlur||0,r.strokeStyle=t.textStrokeColor||"#000",r.lineWidth=t.textStrokeWidth||0,r.fillStyle=t.color||"#000",r.textAlign=t.textAlign||"start",r.fontKerning=t.fontKerning||"normal",t.verticalAlign){case"top":case"middle":case"bottom":r.textBaseline=t.verticalAlign;break;case"baseline":default:r.textBaseline="alphabetic";break}r.font=[t.fontStyle||"normal",t.fontWeight||"normal",`${t.fontSize||14}px`,t.fontFamily||"sans-serif"].join(" "),r.letterSpacing=`${t.letterSpacing||0}px`}const U="OffscreenCanvas"in globalThis;let Y;function N(){return Y??(Y=U?new OffscreenCanvas(1,1):document.createElement("canvas"))}function $(r,t){const n=N().getContext("2d");P(n,{...t,textAlign:"center",verticalAlign:"baseline"});const{width:o,actualBoundingBoxAscent:u,actualBoundingBoxDescent:s,actualBoundingBoxLeft:i,actualBoundingBoxRight:B,fontBoundingBoxAscent:d,fontBoundingBoxDescent:D}=n.measureText(r),g=t.fontSize*t.lineHeight,f=d+D;return{width:o,height:t.fontSize,typoAscent:d,typoDescent:D,typoHeight:f,lineHeight:g,glyphLeft:i,glyphRight:B,glyphAscent:u,glyphDescent:s,glyphWidth:i+B,glyphHeight:u+s,baseline:(g-f)/2+d,centerX:o/2}}function I(r,t){const n=document.createDocumentFragment(),o=document.createElement("div");o.style.position="absolute",o.style.visibility="hidden",o.setAttribute("aria-hidden","true"),o.style.fontFamily=t.fontFamily,o.style.fontSize=`${t.fontSize}px`,o.style.lineHeight=String(t.lineHeight),o.style.whiteSpace="nowrap",o.style.writingMode=t.writingMode;const u=document.createElement("span");u.textContent=/\s/.test(r)?"&nbsp;":r,o.appendChild(u),n.appendChild(o),document.body.appendChild(n);const s={leading:u.offsetHeight-t.fontSize};return document.body.removeChild(o),s}const K=/[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\u{328A}-\u{32B0}\u{32B1}-\u{32BF}\u{32C0}-\u{32FE}\u{32FF}\u{3300}-\u{3357}\u{3358}-\u{337A}\u{337B}-\u{337F}\u{3380}-\u{33FF}\u{3400}-\u{4DBF}\u{4DC0}-\u{4DFF}\u{4E00}-\u{9FFF}\u{A000}-\u{A014}\u{A015}\u{A016}-\u{A48C}\u{A48D}-\u{A48F}\u{A490}-\u{A4C6}\u{A4C7}-\u{A4CF}\u{A960}-\u{A97C}\u{A97D}-\u{A97F}\u{AC00}-\u{D7A3}\u{D7A4}-\u{D7AF}\u{D7B0}-\u{D7C6}\u{D7C7}-\u{D7CA}\u{D7CB}-\u{D7FB}\u{D7FC}-\u{D7FF}\u{E000}-\u{F8FF}\u{F900}-\u{FA6D}\u{FA6E}-\u{FA6F}\u{FA70}-\u{FAD9}\u{FADA}-\u{FAFF}\u{FE10}-\u{FE16}\u{FE17}\u{FE18}\u{FE19}\u{FE1A}-\u{FE1F}\u{FE30}\u{FE31}-\u{FE32}\u{FE33}-\u{FE34}\u{FE35}\u{FE36}\u{FE37}\u{FE38}\u{FE39}\u{FE3A}\u{FE3B}\u{FE3C}\u{FE3D}\u{FE3E}\u{FE3F}\u{FE40}\u{FE41}\u{FE42}\u{FE43}\u{FE44}\u{FE45}-\u{FE46}\u{FE47}\u{FE48}\u{FE50}-\u{FE52}\u{FE53}\u{FE54}-\u{FE57}\u{FE5F}-\u{FE61}\u{FE62}\u{FE67}\u{FE68}\u{FE69}\u{FE6A}-\u{FE6B}\u{FE6C}-\u{FE6F}\u{FF01}\u{FF02}-\u{FF03}\u{FF04}\u{FF05}-\u{FF07}\u{FF0A}\u{FF0B}\u{FF0C}\u{FF0E}\u{FF0F}\u{FF10}-\u{FF19}\u{FF1F}\u{FF20}\u{FF21}-\u{FF3A}\u{FF3C}\u{FF3E}\u{FF40}\u{FF41}-\u{FF5A}\u{FFE0}-\u{FFE1}\u{FFE2}\u{FFE4}\u{FFE5}-\u{FFE6}\u{FFE7}\u{FFF0}-\u{FFF8}\u{FFFC}-\u{FFFD}\u{10980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\u{1B2FC}-\u{1B2FF}\u{1CF00}-\u{1CF2D}\u{1CF2E}-\u{1CF2F}\u{1CF30}-\u{1CF46}\u{1CF47}-\u{1CF4F}\u{1CF50}-\u{1CFC3}\u{1CFC4}-\u{1CFCF}\u{1D000}-\u{1D0F5}\u{1D0F6}-\u{1D0FF}\u{1D100}-\u{1D126}\u{1D127}-\u{1D128}\u{1D129}-\u{1D164}\u{1D165}-\u{1D166}\u{1D167}-\u{1D169}\u{1D16A}-\u{1D16C}\u{1D16D}-\u{1D172}\u{1D173}-\u{1D17A}\u{1D17B}-\u{1D182}\u{1D183}-\u{1D184}\u{1D185}-\u{1D18B}\u{1D18C}-\u{1D1A9}\u{1D1AA}-\u{1D1AD}\u{1D1AE}-\u{1D1EA}\u{1D1EB}-\u{1D1FF}\u{1D2E0}-\u{1D2F3}\u{1D2F4}-\u{1D2FF}\u{1D300}-\u{1D356}\u{1D357}-\u{1D35F}\u{1D360}-\u{1D378}\u{1D379}-\u{1D37F}\u{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}-\u{1FA5F}\u{1FA60}-\u{1FA6D}\u{1FA6E}-\u{1FA6F}\u{1FA70}-\u{1FA74}\u{1FA75}-\u{1FA77}\u{1FA78}-\u{1FA7C}\u{1FA7D}-\u{1FA7F}\u{1FA80}-\u{1FA86}\u{1FA87}-\u{1FA8F}\u{1FA90}-\u{1FAAC}\u{1FAAD}-\u{1FAAF}\u{1FAB0}-\u{1FABA}\u{1FABB}-\u{1FABF}\u{1FAC0}-\u{1FAC5}\u{1FAC6}-\u{1FACF}\u{1FAD0}-\u{1FAD9}\u{1FADA}-\u{1FADF}\u{1FAE0}-\u{1FAE7}\u{1FAE8}-\u{1FAEF}\u{1FAF0}-\u{1FAF6}\u{1FAF7}-\u{1FAFF}\u{20000}-\u{2A6DF}\u{2A6E0}-\u{2A6FF}\u{2A700}-\u{2B738}\u{2B739}-\u{2B73F}\u{2B740}-\u{2B81D}\u{2B81E}-\u{2B81F}\u{2B820}-\u{2CEA1}\u{2CEA2}-\u{2CEAF}\u{2CEB0}-\u{2EBE0}\u{2EBE1}-\u{2F7FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u,R=/[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u,_=/[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u,j=/[\r\n]/;class W{constructor(t,n){this.content=t,this.parent=n,this.contentBox=new E,this.glyphBox=new E,this.baseline=0,this.verticalOrientation="U",this.isPunctuation=!1,this.isEOL=!1,this.update()}get computedStyle(){return this.parent.computedStyle}update(){switch(this.computedStyle.textOrientation){case"upright":this.verticalOrientation="U";break;case"sideways-right":case"sideways":this.verticalOrientation="R";break;case"mixed":default:this.verticalOrientation=K.test(this.content)?R.test(this.content)?"Tu":"U":R.test(this.content)?"Tr":"R";break}return this.isPunctuation=_.test(this.content),this.isEOL=j.test(this.content),this}measure(){const t=this.computedStyle,{width:n,height:o,glyphAscent:u,glyphLeft:s,glyphWidth:i,glyphHeight:B,lineHeight:d,baseline:D,centerX:g}=$(this.content,{...t,letterSpacing:0});switch(this.contentBox.width=n,this.contentBox.height=o,this.glyphBox.width=i,this.glyphBox.height=B,this.baseline=D,t.writingMode){case"vertical-lr":case"vertical-rl":{const f=t.fontSize*t.lineHeight;switch(this.verticalOrientation){case"Tr":case"R":this.contentBox.rotate90deg(),this.glyphBox.rotate90deg(),this.contentBox.x=(f-o)/2,this.glyphBox.x=(f-B)/2;break;case"U":{const{leading:h}=I(this.content,{...t,letterSpacing:0});this.contentBox.x=(f-n)/2,this.contentBox.y=h,this.glyphBox.x=(f-i)/2,this.glyphBox.y=0;break}case"Tu":this.contentBox.x=(f-n)/2,this.contentBox.y=0,this.glyphBox.x=this.contentBox.x+g-s,this.glyphBox.y=o-B;break}break}case"horizontal-tb":this.contentBox.x=0,this.contentBox.y=(d-o)/2,this.glyphBox.x=g-s,this.glyphBox.y=D-u;break}return this}clone(){const t=new W(this.content,this.parent);return t.contentBox=this.contentBox.clone(),t.glyphBox=this.glyphBox.clone(),t}}class T{constructor(t,n,o){this.content=t,this.style=n,this.parent=o,this.contentBox=new E,this.inlineBox=new E,this.glyphBox=new E,this.centerX=0,this.baseline=0,this.update()}update(){var o;this.computedStyle={...(o=this.parent)==null?void 0:o.computedStyle,...this.style};const t=this.computedStyle;this.computedContent=t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content;const n=[];for(const u of this.computedContent)n.push(new W(u,this));return this.characters=n,this}measure(){var n;const t=this.computedStyle;switch(t.writingMode){case"vertical-lr":case"vertical-rl":{let o=0;const u={left:0,right:0},s={left:0,right:0};this.characters.forEach((i,B)=>{i.update().measure(),u.left=Math.min(u.left,i.contentBox.left),u.right=Math.max(u.right,i.contentBox.right),s.left=Math.min(s.left,i.glyphBox.left),s.right=Math.max(s.right,i.glyphBox.right),o+=i.contentBox.y+i.contentBox.height,B!==this.characters.length-1&&(o+=t.letterSpacing)}),this.inlineBox.width=t.fontSize*t.lineHeight,this.inlineBox.height=o,this.contentBox.width=u.right-u.left,this.contentBox.height=o,this.glyphBox.width=s.right-s.left,this.glyphBox.height=o,this.baseline=((n=this.characters[0])==null?void 0:n.baseline)??0,this.centerX=o/2,this.contentBox.x=u.left,this.glyphBox.x=s.left;break}case"horizontal-tb":{let o=0;const u={top:0,bottom:0},s={top:0,bottom:0};this.characters.forEach((B,d)=>{B.update().measure(),u.top=Math.min(u.top,B.contentBox.top),u.bottom=Math.max(u.bottom,B.contentBox.bottom),s.top=Math.min(s.top,B.glyphBox.top),s.bottom=Math.max(s.bottom,B.glyphBox.bottom),o+=B.contentBox.x+B.contentBox.width,d!==this.characters.length-1&&(o+=t.letterSpacing)}),this.inlineBox.width=o,this.inlineBox.height=t.fontSize*t.lineHeight,this.contentBox.width=o,this.contentBox.height=u.bottom-u.top,this.glyphBox.width=o,this.glyphBox.height=s.bottom-s.top,this.centerX=o/2,this.inlineBox.x=0,this.inlineBox.y=0;const i=this.characters[0];i&&(this.baseline=i.baseline,this.contentBox.x=i.contentBox.x,this.glyphBox.x=i.glyphBox.x),this.contentBox.y=u.top,this.glyphBox.y=s.top;break}}return this}clone(t){return new T(t??this.content,this.style,this.parent)}}class v{constructor(t,n){this.style=t,this.parent=n,this.contentBox=new E,this.lineBox=new E,this.glyphBox=new E,this.baseline=0,this.xHeight=0,this.fragments=[],this.update()}update(){this.computedStyle={...this.parent,...this.style}}addFragment(t,n){return this.fragments.push(new T(t,n,this)),this}clone(t){const n=new v(this.style,this.parent);return n.contentBox=this.contentBox.clone(),n.lineBox=this.lineBox.clone(),n.glyphBox=this.glyphBox.clone(),n.baseline=this.baseline,n.xHeight=this.xHeight,n.fragments=t??this.fragments.map(o=>o.clone()),n}}function G(r,t){const n=[];if(typeof r=="string")n.push(new v(void 0,t).addFragment(r));else{r=Array.isArray(r)?r:[r];for(const o of r)if(typeof o=="string")n.push(new v(void 0,t).addFragment(o));else if(Array.isArray(o)){const u=new v(void 0,t);o.forEach(s=>{if(typeof s=="string")u.addFragment(s);else{const{content:i,...B}=s;u.addFragment(i,B)}}),n.push(u)}else if("fragments"in o){const{fragments:u,...s}=o,i=new v(s,t);u.forEach(B=>{const{content:d,...D}=B;i.addFragment(d,D)}),n.push(i)}else if("content"in o){const{content:u,...s}=o;n.push(new v(s,t).addFragment(u))}}return n}function V(r,t,n){var B;const o=[],u=r.slice();let s,i;for(;s=u.shift();){const d=s.fragments.slice();let D=0;const g=[];for(;i=d.shift();){const f=i.computedStyle;let h="",S=!1,k=0;const e=new T("",i.style,i.parent);for(const A of i.characters){if(e.content+=A.content,(B=i.characters[++k])!=null&&B.isPunctuation)continue;let y,m;switch(f.writingMode){case"vertical-lr":case"vertical-rl":y=n,m=e.update().measure().contentBox.height;break;case"horizontal-tb":default:y=t,m=e.update().measure().contentBox.width;break}if(m+=f.letterSpacing,A.isEOL||y&&D+m>y){let a=A.isEOL?h.length+1:h.length;!D&&!a&&(h+=e.computedContent,a+=e.computedContent.length),h.length&&g.push(i.clone(h)),g.length&&(o.push(s.clone(g.slice())),g.length=0);const l=i.computedContent.substring(a);(l.length||d.length)&&u.unshift(s.clone((l.length?[i.clone(l)]:[]).concat(d.slice()))),d.length=0,S=!0;break}else D+=m;h+=e.computedContent,e.content=""}S||g.push(i.clone())}g.length&&o.push(s.clone(g))}return o}const X={width:0,height:0,color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",fontSize:14,fontWeight:"normal",fontFamily:"sans-serif",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",verticalAlign:"baseline",textTransform:"none",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",lineHeight:1,letterSpacing:0,shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,writingMode:"horizontal-tb",textOrientation:"mixed"};function q(r){return{...X,...r}}function L(r){const{content:t,effects:n=[{}]}=r,{width:o,height:u,...s}=q(r.style);let i=G(t,s);i=V(i,o,u);let B=0,d=0;i.forEach(e=>{let A=null;e.fragments.forEach(F=>{F.update().measure(),(!A||A.contentBox.height<F.contentBox.height)&&(A=F)});const{glyphHeight:y,baseline:m}=$("x",(A??e).computedStyle);e.xHeight=y,e.baseline=m;const a=e.computedStyle;let l=B,c=d,x=0;e.fragments.forEach((F,p)=>{const C=F.computedStyle;switch(a.writingMode){case"vertical-rl":case"vertical-lr":{p||(c=0),F.inlineBox.translate(l,c),F.contentBox.translate(l,c),F.glyphBox.translate(l,c);let b=c;F.characters.forEach((w,O)=>{const z=w.contentBox.y+w.contentBox.height;w.contentBox.translate(l,b),w.glyphBox.translate(l,b),b+=z,O!==F.characters.length-1&&(b+=C.letterSpacing)}),c+=F.inlineBox.height,p===e.fragments.length-1&&(l+=F.inlineBox.width);break}case"horizontal-tb":{p||(l=0),F.inlineBox.translate(l,c),F.contentBox.translate(l,c),F.glyphBox.translate(l,c);let b=l;F.characters.forEach((w,O)=>{const z=w.contentBox.x+w.contentBox.width;w.contentBox.translate(b,c),w.glyphBox.translate(b,c),b+=z,O!==F.characters.length-1&&(b+=C.letterSpacing)}),l+=F.inlineBox.width,x=Math.max(x,F.inlineBox.height),p===e.fragments.length-1&&(c+=x);break}}}),B=l,d=c,e.lineBox=E.from(...e.fragments.map(F=>F.inlineBox))});const D=E.from(...i.map(e=>e.lineBox),new E(0,0,o,u)),{width:g,height:f}=D;i.forEach(e=>{let A=0;const y=0,m=e.computedStyle;switch(m.writingMode){case"vertical-rl":A+=g-(e.lineBox.x*2+e.lineBox.width);case"vertical-lr":e.lineBox.height=Math.max(e.lineBox.height,f);break;case"horizontal-tb":e.lineBox.width=Math.max(e.lineBox.width,g);break}e.contentBox=E.from(...e.fragments.map(a=>a.contentBox)),e.glyphBox=E.from(...e.fragments.map(a=>a.glyphBox)),e.fragments.forEach(a=>{let l=A,c=y;const x=a.computedStyle;switch(m.writingMode){case"vertical-rl":case"vertical-lr":{switch(x.textAlign){case"end":case"right":c+=f-e.contentBox.height;break;case"center":c+=(f-e.contentBox.height)/2;break}a.characters.forEach(F=>{let p=l;const C=c;switch(x.verticalAlign){case"top":case"middle":case"bottom":case"sub":case"super":case"text-top":case"text-bottom":case"baseline":default:p+=e.baseline-F.baseline;break}F.contentBox.translate(p,C),F.glyphBox.translate(p,C)});break}case"horizontal-tb":{switch(x.textAlign){case"end":case"right":l=g-e.contentBox.width;break;case"center":l=(g-e.contentBox.width)/2;break}switch(x.verticalAlign){case"top":c=e.lineBox.y-a.inlineBox.y;break;case"middle":c=a.inlineBox.y-(e.baseline-e.xHeight/2-a.inlineBox.height/2);break;case"bottom":c=e.lineBox.bottom-a.inlineBox.bottom;break;case"sub":c=e.lineBox.y+e.baseline-a.glyphBox.bottom;break;case"super":c=e.lineBox.y+e.baseline-a.glyphBox.y;break;case"text-top":c=e.glyphBox.y-a.inlineBox.y;break;case"text-bottom":c=e.glyphBox.bottom-a.inlineBox.bottom;break;case"baseline":default:a.inlineBox.height<e.lineBox.height&&(c=e.baseline-a.baseline);break}a.characters.forEach(F=>{F.contentBox.translate(l,c),F.glyphBox.translate(l,c)});break}}a.inlineBox.translate(l,c),a.contentBox.translate(l,c),a.glyphBox.translate(l,c)}),e.lineBox=E.from(e.lineBox,...e.fragments.map(a=>a.inlineBox)),e.contentBox=E.from(...e.fragments.map(a=>a.contentBox)),e.glyphBox=E.from(...e.fragments.map(a=>a.glyphBox))});const h=E.from(...i.map(e=>e.contentBox)),S=E.from(...i.map(e=>e.glyphBox)),k=[];return i.forEach(e=>{e.fragments.forEach(A=>{const y=A.computedStyle;n.forEach(m=>{const a={...y,...m},{textStrokeWidth:l=0,offsetX:c=0,offsetY:x=0}=a;if(l||c||x){const{x:F,y:p,width:C,height:b}=A.contentBox;k.push(new E(Math.min(F,F+c-l/2),Math.min(p,p+x-l/2),Math.max(C,C+c+l),Math.max(b,b+x+l)))}})})}),{box:D,contentBox:h,glyphBox:S,paragraphs:i,viewBox:E.from(D,S,...k)}}function H(r,t,n){if(typeof t=="string"&&t.startsWith("linear-gradient")){const{x0:o,y0:u,x1:s,y1:i,stops:B}=J(t,n.left,n.top,n.width,n.height),d=r.createLinearGradient(o,u,s,i);return B.forEach(D=>d.addColorStop(D.offset,D.color)),d}return t}function J(r,t,n,o,u){var S;const s=((S=r.match(/linear-gradient\((.+)\)$/))==null?void 0:S[1])??"",i=s.split(",")[0],B=i.includes("deg")?i:"0deg",d=s.replace(B,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi),g=(Number(B.replace("deg",""))||0)*Math.PI/180,f=o*Math.sin(g),h=u*Math.cos(g);return{x0:t+o/2-f,y0:n+u/2+h,x1:t+o/2+f,y1:n+u/2-h,stops:Array.from(d).map(k=>{let e=k[2];return e.startsWith("(")?e=e.split(",").length>3?`rgba${e}`:`rgb${e}`:e=`#${e}`,{offset:Number(k[3].replace("%",""))/100,color:e}})}}function M(r,t,n){n!=null&&n.color&&(n.color=H(r,n.color,t)),n!=null&&n.backgroundColor&&(n.backgroundColor=H(r,n.backgroundColor,t)),n!=null&&n.textStrokeColor&&(n.textStrokeColor=H(r,n.textStrokeColor,t))}function Q(r){const{view:t=document.createElement("canvas"),style:n,effects:o=[],pixelRatio:u=1}=r,s=o.length>0?o:[{}],{viewBox:i,paragraphs:B}=L(r),{x:d,y:D,width:g,height:f}=i,h=t.getContext("2d");t.style.width=`${g}px`,t.style.height=`${f}px`,t.dataset.viewbox=`${d} ${D} ${g} ${f}`,t.dataset.pixelRatio=String(u),t.width=Math.max(1,Math.floor(g*u)),t.height=Math.max(1,Math.floor(f*u)),h.scale(u,u);const S=(e,A,y,m,a)=>{h.fillStyle=e,h.fillRect(-i.x+A,-i.y+y,m,a)},k={...n};return M(h,new E(0,0,g,f),k),B.forEach(e=>{M(h,e.contentBox,e.computedStyle),e.fragments.forEach(A=>{M(h,A.contentBox,A.computedStyle)})}),s.forEach(e=>{const A={...e};M(h,new E(0,0,g,f),A);const y={...k,...A};y!=null&&y.backgroundColor&&S(y.backgroundColor,0,0,t.width,t.height),B.forEach(m=>{var a;(a=m.style)!=null&&a.backgroundColor&&S(m.computedStyle.backgroundColor,...m.lineBox.toArray()),m.fragments.forEach(l=>{var c;(c=l.style)!=null&&c.backgroundColor&&S(l.computedStyle.backgroundColor,...l.inlineBox.toArray())})}),B.forEach(m=>{m.fragments.forEach(a=>{const l=-i.x+(A.offsetX??0),c=-i.y+(A.offsetY??0),x={...a.computedStyle,...A};switch(P(h,{...x,fontSize:x.fontSize*u,letterSpacing:x.letterSpacing*u,textStrokeWidth:x.textStrokeWidth*u,shadowOffsetX:x.shadowOffsetX*u,shadowOffsetY:x.shadowOffsetY*u,shadowBlur:x.shadowBlur*u,textAlign:"left"}),x.writingMode){case"vertical-rl":case"vertical-lr":{a.characters.forEach(F=>{h.setTransform(1,0,0,1,0,0);let p=0,C=0;switch(F.verticalOrientation){case"Tr":case"R":{h.rotate(Math.PI/2),h.textBaseline="alphabetic",C=-(l+a.inlineBox.x+a.inlineBox.width-F.baseline),p=c+F.contentBox.y;break}case"Tu":h.textBaseline="top",p=l+F.contentBox.x+F.contentBox.right-F.glyphBox.right,C=c+F.contentBox.y+F.contentBox.y-F.glyphBox.y;break;case"U":p=l+F.contentBox.x,C=c+F.contentBox.y,h.textBaseline="top";break}h.fillText(F.content,p*u,C*u),x.textStrokeWidth&&h.strokeText(F.content,p*u,C*u)});break}case"horizontal-tb":{const F=l+a.contentBox.x,p=c+a.contentBox.y,C=c+a.inlineBox.y+a.baseline,{width:b,height:w}=a.contentBox;switch(h.textBaseline="alphabetic",h.setTransform(1,0,0,1,0,0),h.fillText(a.computedContent,F*u,C*u),x.textStrokeWidth&&h.strokeText(a.computedContent,F*u,C*u),h.scale(u,u),x.textDecoration){case"underline":h.strokeStyle=h.fillStyle,h.lineWidth=x.fontSize/15,h.beginPath(),h.moveTo(F,p+w),h.lineTo(F+b,p+w),h.stroke();break;case"line-through":h.strokeStyle=h.fillStyle,h.lineWidth=x.fontSize/15,h.beginPath(),h.moveTo(F,p+w/2),h.lineTo(F+b,p+w/2),h.stroke();break}break}}})})}),t}exports.defaultTextStyles=X;exports.measureText=L;exports.renderText=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class E{constructor(t=0,u=0,o=0,e=0){this.x=t,this.y=u,this.width=o,this.height=e}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}static from(...t){const u=t[0],o=t.slice(1).reduce((e,s)=>(e.x=Math.min(e.x,s.x),e.y=Math.min(e.y,s.y),e.right=Math.max(e.right,s.right),e.bottom=Math.max(e.bottom,s.bottom),e),{x:u.x,y:u.y,right:u.right,bottom:u.bottom});return new E(o.x,o.y,o.right-o.x,o.bottom-o.y)}rotate90deg(){const{width:t,height:u}=this;this.width=u,this.height=t}translate(t,u){return this.x+=t,this.y+=u,this}clone(){return new E(this.x,this.y,this.width,this.height)}toArray(){return[this.x,this.y,this.width,this.height]}}function R(F,t){switch(F.shadowColor=t.shadowColor||"rgba(0, 0, 0, 0)",F.shadowOffsetX=t.shadowOffsetX||0,F.shadowOffsetY=t.shadowOffsetY||0,F.shadowBlur=t.shadowBlur||0,F.strokeStyle=t.textStrokeColor||"#000",F.lineWidth=t.textStrokeWidth||0,F.fillStyle=t.color||"#000",F.textAlign=t.textAlign||"start",F.fontKerning=t.fontKerning||"normal",t.verticalAlign){case"top":case"middle":case"bottom":F.textBaseline=t.verticalAlign;break;case"baseline":default:F.textBaseline="alphabetic";break}F.font=[t.fontStyle||"normal",t.fontWeight||"normal",`${t.fontSize||14}px`,t.fontFamily||"sans-serif"].join(" "),F.letterSpacing=`${t.letterSpacing||0}px`}const L="OffscreenCanvas"in globalThis;let U;function Y(){return U??(U=L?new OffscreenCanvas(1,1):document.createElement("canvas"))}function P(F,t){const u=Y().getContext("2d");R(u,{...t,textAlign:"center",verticalAlign:"baseline"});const{width:o,actualBoundingBoxAscent:e,actualBoundingBoxDescent:s,actualBoundingBoxLeft:i,actualBoundingBoxRight:B,fontBoundingBoxAscent:f,fontBoundingBoxDescent:m}=u.measureText(F),g=t.fontSize*t.lineHeight,d=f+m;return{width:o,height:t.fontSize,typoAscent:f,typoDescent:m,typoHeight:d,lineHeight:g,glyphLeft:i,glyphRight:B,glyphAscent:e,glyphDescent:s,glyphWidth:i+B,glyphHeight:e+s,baseline:(g-d)/2+f,centerX:o/2}}function N(F,t){const u=document.createDocumentFragment(),o=document.createElement("div");o.style.position="absolute",o.style.visibility="hidden",o.setAttribute("aria-hidden","true"),o.style.fontFamily=t.fontFamily,o.style.fontSize=`${t.fontSize}px`,o.style.lineHeight=String(t.lineHeight),o.style.whiteSpace="nowrap",o.style.writingMode=t.writingMode;const e=document.createElement("span");e.textContent=/\s/.test(F)?"&nbsp;":F,o.appendChild(e),u.appendChild(o),document.body.appendChild(u);const s={leading:e.offsetHeight-t.fontSize};return document.body.removeChild(o),s}const I=/[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\u{328A}-\u{32B0}\u{32B1}-\u{32BF}\u{32C0}-\u{32FE}\u{32FF}\u{3300}-\u{3357}\u{3358}-\u{337A}\u{337B}-\u{337F}\u{3380}-\u{33FF}\u{3400}-\u{4DBF}\u{4DC0}-\u{4DFF}\u{4E00}-\u{9FFF}\u{A000}-\u{A014}\u{A015}\u{A016}-\u{A48C}\u{A48D}-\u{A48F}\u{A490}-\u{A4C6}\u{A4C7}-\u{A4CF}\u{A960}-\u{A97C}\u{A97D}-\u{A97F}\u{AC00}-\u{D7A3}\u{D7A4}-\u{D7AF}\u{D7B0}-\u{D7C6}\u{D7C7}-\u{D7CA}\u{D7CB}-\u{D7FB}\u{D7FC}-\u{D7FF}\u{E000}-\u{F8FF}\u{F900}-\u{FA6D}\u{FA6E}-\u{FA6F}\u{FA70}-\u{FAD9}\u{FADA}-\u{FAFF}\u{FE10}-\u{FE16}\u{FE17}\u{FE18}\u{FE19}\u{FE1A}-\u{FE1F}\u{FE30}\u{FE31}-\u{FE32}\u{FE33}-\u{FE34}\u{FE35}\u{FE36}\u{FE37}\u{FE38}\u{FE39}\u{FE3A}\u{FE3B}\u{FE3C}\u{FE3D}\u{FE3E}\u{FE3F}\u{FE40}\u{FE41}\u{FE42}\u{FE43}\u{FE44}\u{FE45}-\u{FE46}\u{FE47}\u{FE48}\u{FE50}-\u{FE52}\u{FE53}\u{FE54}-\u{FE57}\u{FE5F}-\u{FE61}\u{FE62}\u{FE67}\u{FE68}\u{FE69}\u{FE6A}-\u{FE6B}\u{FE6C}-\u{FE6F}\u{FF01}\u{FF02}-\u{FF03}\u{FF04}\u{FF05}-\u{FF07}\u{FF0A}\u{FF0B}\u{FF0C}\u{FF0E}\u{FF0F}\u{FF10}-\u{FF19}\u{FF1F}\u{FF20}\u{FF21}-\u{FF3A}\u{FF3C}\u{FF3E}\u{FF40}\u{FF41}-\u{FF5A}\u{FFE0}-\u{FFE1}\u{FFE2}\u{FFE4}\u{FFE5}-\u{FFE6}\u{FFE7}\u{FFF0}-\u{FFF8}\u{FFFC}-\u{FFFD}\u{10980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\u{1B2FC}-\u{1B2FF}\u{1CF00}-\u{1CF2D}\u{1CF2E}-\u{1CF2F}\u{1CF30}-\u{1CF46}\u{1CF47}-\u{1CF4F}\u{1CF50}-\u{1CFC3}\u{1CFC4}-\u{1CFCF}\u{1D000}-\u{1D0F5}\u{1D0F6}-\u{1D0FF}\u{1D100}-\u{1D126}\u{1D127}-\u{1D128}\u{1D129}-\u{1D164}\u{1D165}-\u{1D166}\u{1D167}-\u{1D169}\u{1D16A}-\u{1D16C}\u{1D16D}-\u{1D172}\u{1D173}-\u{1D17A}\u{1D17B}-\u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F}\u{1F6F0}-\u{1F6FC}\u{1F6FD}-\u{1F6FF}\u{1F700}-\u{1F773}\u{1F774}-\u{1F77F}\u{1F780}-\u{1F7D8}\u{1F7D9}-\u{1F7DF}\u{1F7E0}-\u{1F7EB}\u{1F7EC}-\u{1F7EF}\u{1F7F0}\u{1F7F1}-\u{1F7FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA53}\u{1FA54}-\u{1FA5F}\u{1FA60}-\u{1FA6D}\u{1FA6E}-\u{1FA6F}\u{1FA70}-\u{1FA74}\u{1FA75}-\u{1FA77}\u{1FA78}-\u{1FA7C}\u{1FA7D}-\u{1FA7F}\u{1FA80}-\u{1FA86}\u{1FA87}-\u{1FA8F}\u{1FA90}-\u{1FAAC}\u{1FAAD}-\u{1FAAF}\u{1FAB0}-\u{1FABA}\u{1FABB}-\u{1FABF}\u{1FAC0}-\u{1FAC5}\u{1FAC6}-\u{1FACF}\u{1FAD0}-\u{1FAD9}\u{1FADA}-\u{1FADF}\u{1FAE0}-\u{1FAE7}\u{1FAE8}-\u{1FAEF}\u{1FAF0}-\u{1FAF6}\u{1FAF7}-\u{1FAFF}\u{20000}-\u{2A6DF}\u{2A6E0}-\u{2A6FF}\u{2A700}-\u{2B738}\u{2B739}-\u{2B73F}\u{2B740}-\u{2B81D}\u{2B81E}-\u{2B81F}\u{2B820}-\u{2CEA1}\u{2CEA2}-\u{2CEAF}\u{2CEB0}-\u{2EBE0}\u{2EBE1}-\u{2F7FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u,W=/[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u,K=/[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u,_=/[\r\n]/;class H{constructor(t,u){this.content=t,this.parent=u,this.contentBox=new E,this.glyphBox=new E,this.baseline=0,this.verticalOrientation="U",this.isPunctuation=!1,this.isEOL=!1,this.update()}get computedStyle(){return this.parent.computedStyle}update(){switch(this.computedStyle.textOrientation){case"upright":this.verticalOrientation="U";break;case"sideways-right":case"sideways":this.verticalOrientation="R";break;case"mixed":default:this.verticalOrientation=I.test(this.content)?W.test(this.content)?"Tu":"U":W.test(this.content)?"Tr":"R";break}return this.isPunctuation=K.test(this.content),this.isEOL=_.test(this.content),this}measure(){const t=this.computedStyle,{width:u,height:o,glyphAscent:e,glyphLeft:s,glyphWidth:i,glyphHeight:B,lineHeight:f,baseline:m,centerX:g}=P(this.content,{...t,letterSpacing:0});switch(this.contentBox.width=u,this.contentBox.height=o,this.glyphBox.width=i,this.glyphBox.height=B,this.baseline=m,t.writingMode){case"vertical-lr":case"vertical-rl":{const d=t.fontSize*t.lineHeight;switch(this.verticalOrientation){case"Tr":case"R":this.contentBox.rotate90deg(),this.glyphBox.rotate90deg(),this.contentBox.x=(d-o)/2,this.glyphBox.x=(d-B)/2;break;case"U":{const{leading:r}=N(this.content,{...t,letterSpacing:0});this.contentBox.x=(d-u)/2,this.contentBox.y=r,this.glyphBox.x=(d-i)/2,this.glyphBox.y=0;break}case"Tu":this.contentBox.x=(d-u)/2,this.contentBox.y=0,this.glyphBox.x=this.contentBox.x+g-s,this.glyphBox.y=o-B;break}this.contentBox.height+=t.letterSpacing;break}case"horizontal-tb":this.contentBox.x=0,this.contentBox.y=(f-o)/2,this.contentBox.width+=t.letterSpacing,this.glyphBox.x=g-s,this.glyphBox.y=m-e;break}return this}clone(){const t=new H(this.content,this.parent);return t.contentBox=this.contentBox.clone(),t.glyphBox=this.glyphBox.clone(),t}}function z(F){if(!F)return F;const t={};for(const u in F)F[u]!==""&&F[u]!==void 0&&(t[u]=F[u]);return t}class T{constructor(t,u,o){this.content=t,this.style=u,this.parent=o,this.contentBox=new E,this.inlineBox=new E,this.glyphBox=new E,this.centerX=0,this.baseline=0,this.update()}update(){var o;this.computedStyle={...(o=this.parent)==null?void 0:o.computedStyle,...z(this.style)};const t=this.computedStyle;this.computedContent=t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content;const u=[];for(const e of this.computedContent)u.push(new H(e,this));return this.characters=u,this}measure(){var u;const t=this.computedStyle;switch(t.writingMode){case"vertical-lr":case"vertical-rl":{let o=0;const e={left:0,right:0},s={left:0,right:0};this.characters.forEach(i=>{i.update().measure(),e.left=Math.min(e.left,i.contentBox.left),e.right=Math.max(e.right,i.contentBox.right),s.left=Math.min(s.left,i.glyphBox.left),s.right=Math.max(s.right,i.glyphBox.right),o+=i.contentBox.y+i.contentBox.height}),this.inlineBox.width=t.fontSize*t.lineHeight,this.inlineBox.height=o,this.contentBox.width=e.right-e.left,this.contentBox.height=o,this.glyphBox.width=s.right-s.left,this.glyphBox.height=o,this.baseline=((u=this.characters[0])==null?void 0:u.baseline)??0,this.centerX=o/2,this.contentBox.x=e.left,this.glyphBox.x=s.left;break}case"horizontal-tb":{let o=0;const e={top:0,bottom:0},s={top:0,bottom:0};this.characters.forEach(B=>{B.update().measure(),e.top=Math.min(e.top,B.contentBox.top),e.bottom=Math.max(e.bottom,B.contentBox.bottom),s.top=Math.min(s.top,B.glyphBox.top),s.bottom=Math.max(s.bottom,B.glyphBox.bottom),o+=B.contentBox.x+B.contentBox.width}),this.inlineBox.width=o,this.inlineBox.height=t.fontSize*t.lineHeight,this.contentBox.width=o,this.contentBox.height=e.bottom-e.top,this.glyphBox.width=o,this.glyphBox.height=s.bottom-s.top,this.centerX=o/2,this.inlineBox.x=0,this.inlineBox.y=0;const i=this.characters[0];i&&(this.baseline=i.baseline,this.contentBox.x=i.contentBox.x,this.glyphBox.x=i.glyphBox.x),this.contentBox.y=e.top,this.glyphBox.y=s.top;break}}return this}clone(t){return new T(t??this.content,this.style,this.parent)}}class v{constructor(t,u){this.style=t,this.parent=u,this.contentBox=new E,this.lineBox=new E,this.glyphBox=new E,this.baseline=0,this.xHeight=0,this.fragments=[],this.update()}update(){this.computedStyle={...z(this.parent),...z(this.style)}}addFragment(t,u){return this.fragments.push(new T(t,u,this)),this}clone(t){const u=new v(this.style,this.parent);return u.contentBox=this.contentBox.clone(),u.lineBox=this.lineBox.clone(),u.glyphBox=this.glyphBox.clone(),u.baseline=this.baseline,u.xHeight=this.xHeight,u.fragments=t??this.fragments.map(o=>o.clone()),u}}function j(F,t){const u=[];if(typeof F=="string")u.push(new v(void 0,t).addFragment(F));else{F=Array.isArray(F)?F:[F];for(const o of F)if(typeof o=="string")u.push(new v(void 0,t).addFragment(o));else if(Array.isArray(o)){const e=new v(void 0,t);o.forEach(s=>{if(typeof s=="string")e.addFragment(s);else{const{content:i,...B}=s;e.addFragment(i,B)}}),u.push(e)}else if("fragments"in o){const{fragments:e,...s}=o,i=new v(s,t);e.forEach(B=>{const{content:f,...m}=B;i.addFragment(f,m)}),u.push(i)}else if("content"in o){const{content:e,...s}=o;u.push(new v(s,t).addFragment(e))}}return u}function G(F,t,u){var B;const o=[],e=F.slice();let s,i;for(;s=e.shift();){const f=s.fragments.slice();let m=0;const g=[];for(;i=f.shift();){const d=i.computedStyle;let r="",w=!1,S=0;const n=new T("",i.style,i.parent);for(const A of i.characters){if(n.content+=A.content,(B=i.characters[++S])!=null&&B.isPunctuation)continue;let C,y;switch(d.writingMode){case"vertical-lr":case"vertical-rl":C=u,y=n.update().measure().contentBox.height;break;case"horizontal-tb":default:C=t,y=n.update().measure().contentBox.width;break}if(A.isEOL||C&&m+y>C){let a=A.isEOL?r.length+1:r.length;!m&&!a&&(r+=n.computedContent,a+=n.computedContent.length),r.length&&g.push(i.clone(r)),g.length&&(o.push(s.clone(g.slice())),g.length=0);const l=i.computedContent.substring(a);(l.length||f.length)&&e.unshift(s.clone((l.length?[i.clone(l)]:[]).concat(f.slice()))),f.length=0,w=!0;break}else m+=y;r+=n.computedContent,n.content=""}w||g.push(i.clone())}g.length&&o.push(s.clone(g))}return o}const $={width:0,height:0,color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",fontSize:14,fontWeight:"normal",fontFamily:"sans-serif",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",verticalAlign:"baseline",textTransform:"none",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",lineHeight:1,letterSpacing:0,shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,writingMode:"horizontal-tb",textOrientation:"mixed"};function V(F){return{...$,...F}}function X(F){const{content:t,effects:u=[{}]}=F,{width:o,height:e,...s}=V(F.style);let i=j(t,s);i=G(i,o,e);let B=0,f=0;i.forEach(n=>{let A=null;n.fragments.forEach(h=>{h.update().measure(),(!A||A.contentBox.height<h.contentBox.height)&&(A=h)});const{glyphHeight:C,baseline:y}=P("x",(A??n).computedStyle);n.xHeight=C,n.baseline=y;const a=n.computedStyle;let l=B,c=f,x=0;n.fragments.forEach((h,p)=>{switch(a.writingMode){case"vertical-rl":case"vertical-lr":{p||(c=0),h.inlineBox.translate(l,c),h.contentBox.translate(l,c),h.glyphBox.translate(l,c);let D=c;h.characters.forEach(b=>{const k=b.contentBox.y+b.contentBox.height;b.contentBox.translate(l,D),b.glyphBox.translate(l,D),D+=k}),c+=h.inlineBox.height,p===n.fragments.length-1&&(l+=h.inlineBox.width);break}case"horizontal-tb":{p||(l=0),h.inlineBox.translate(l,c),h.contentBox.translate(l,c),h.glyphBox.translate(l,c);let D=l;h.characters.forEach(b=>{const k=b.contentBox.x+b.contentBox.width;b.contentBox.translate(D,c),b.glyphBox.translate(D,c),D+=k}),l+=h.inlineBox.width,x=Math.max(x,h.inlineBox.height),p===n.fragments.length-1&&(c+=x);break}}}),B=l,f=c,n.lineBox=E.from(...n.fragments.map(h=>h.inlineBox))});const m=E.from(...i.map(n=>n.lineBox),new E(0,0,o,e)),{width:g,height:d}=m;i.forEach(n=>{let A=0;const C=0,y=n.computedStyle;switch(y.writingMode){case"vertical-rl":A+=g-(n.lineBox.x*2+n.lineBox.width);case"vertical-lr":n.lineBox.height=Math.max(n.lineBox.height,d);break;case"horizontal-tb":n.lineBox.width=Math.max(n.lineBox.width,g);break}n.contentBox=E.from(...n.fragments.map(a=>a.contentBox)),n.glyphBox=E.from(...n.fragments.map(a=>a.glyphBox)),n.fragments.forEach(a=>{let l=A,c=C;const x=a.computedStyle;switch(y.writingMode){case"vertical-rl":case"vertical-lr":{switch(x.textAlign){case"end":case"right":c+=d-n.contentBox.height;break;case"center":c+=(d-n.contentBox.height)/2;break}a.characters.forEach(h=>{let p=l;const D=c;switch(x.verticalAlign){case"top":case"middle":case"bottom":case"sub":case"super":case"text-top":case"text-bottom":case"baseline":default:p+=n.baseline-h.baseline;break}h.contentBox.translate(p,D),h.glyphBox.translate(p,D)});break}case"horizontal-tb":{switch(x.textAlign){case"end":case"right":l=g-n.contentBox.width;break;case"center":l=(g-n.contentBox.width)/2;break}switch(x.verticalAlign){case"top":c=n.lineBox.y-a.inlineBox.y;break;case"middle":c=a.inlineBox.y-(n.baseline-n.xHeight/2-a.inlineBox.height/2);break;case"bottom":c=n.lineBox.bottom-a.inlineBox.bottom;break;case"sub":c=n.lineBox.y+n.baseline-a.glyphBox.bottom;break;case"super":c=n.lineBox.y+n.baseline-a.glyphBox.y;break;case"text-top":c=n.glyphBox.y-a.inlineBox.y;break;case"text-bottom":c=n.glyphBox.bottom-a.inlineBox.bottom;break;case"baseline":default:a.inlineBox.height<n.lineBox.height&&(c=n.baseline-a.baseline);break}a.characters.forEach(h=>{h.contentBox.translate(l,c),h.glyphBox.translate(l,c)});break}}a.inlineBox.translate(l,c),a.contentBox.translate(l,c),a.glyphBox.translate(l,c)}),n.lineBox=E.from(n.lineBox,...n.fragments.map(a=>a.inlineBox)),n.contentBox=E.from(...n.fragments.map(a=>a.contentBox)),n.glyphBox=E.from(...n.fragments.map(a=>a.glyphBox))});const r=E.from(...i.map(n=>n.contentBox)),w=E.from(...i.map(n=>n.glyphBox)),S=[];return i.forEach(n=>{n.fragments.forEach(A=>{const C=A.computedStyle;u.forEach(y=>{const a={...C,...y},{textStrokeWidth:l=0,offsetX:c=0,offsetY:x=0}=a;if(l||c||x){const{x:h,y:p,width:D,height:b}=A.contentBox;S.push(new E(Math.min(h,h+c-l/2),Math.min(p,p+x-l/2),Math.max(D,D+c+l),Math.max(b,b+x+l)))}})})}),{box:m,contentBox:r,glyphBox:w,paragraphs:i,viewBox:E.from(m,w,...S)}}function O(F,t,u){if(typeof t=="string"&&t.startsWith("linear-gradient")){const{x0:o,y0:e,x1:s,y1:i,stops:B}=q(t,u.left,u.top,u.width,u.height),f=F.createLinearGradient(o,e,s,i);return B.forEach(m=>f.addColorStop(m.offset,m.color)),f}return t}function q(F,t,u,o,e){var w;const s=((w=F.match(/linear-gradient\((.+)\)$/))==null?void 0:w[1])??"",i=s.split(",")[0],B=i.includes("deg")?i:"0deg",f=s.replace(B,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi),g=(Number(B.replace("deg",""))||0)*Math.PI/180,d=o*Math.sin(g),r=e*Math.cos(g);return{x0:t+o/2-d,y0:u+e/2+r,x1:t+o/2+d,y1:u+e/2-r,stops:Array.from(f).map(S=>{let n=S[2];return n.startsWith("(")?n=n.split(",").length>3?`rgba${n}`:`rgb${n}`:n=`#${n}`,{offset:Number(S[3].replace("%",""))/100,color:n}})}}function M(F,t,u){u!=null&&u.color&&(u.color=O(F,u.color,t)),u!=null&&u.backgroundColor&&(u.backgroundColor=O(F,u.backgroundColor,t)),u!=null&&u.textStrokeColor&&(u.textStrokeColor=O(F,u.textStrokeColor,t))}function J(F){const{view:t=document.createElement("canvas"),style:u,effects:o=[],pixelRatio:e=1}=F,s=o.length>0?o:[{}],{viewBox:i,paragraphs:B}=X(F),{x:f,y:m,width:g,height:d}=i,r=t.getContext("2d");t.style.width=`${g}px`,t.style.height=`${d}px`,t.dataset.viewbox=`${f} ${m} ${g} ${d}`,t.dataset.pixelRatio=String(e),t.width=Math.max(1,Math.floor(g*e)),t.height=Math.max(1,Math.floor(d*e)),r.scale(e,e);const w=(n,A,C,y,a)=>{r.fillStyle=n,r.fillRect(-i.x+A,-i.y+C,y,a)},S={...u};return M(r,new E(0,0,g,d),S),B.forEach(n=>{M(r,n.contentBox,n.computedStyle),n.fragments.forEach(A=>{M(r,A.contentBox,A.computedStyle)})}),s.forEach(n=>{const A={...n};M(r,new E(0,0,g,d),A);const C={...S,...A};C!=null&&C.backgroundColor&&w(C.backgroundColor,0,0,t.width,t.height),B.forEach(y=>{var a;(a=y.style)!=null&&a.backgroundColor&&w(y.computedStyle.backgroundColor,...y.lineBox.toArray()),y.fragments.forEach(l=>{var c;(c=l.style)!=null&&c.backgroundColor&&w(l.computedStyle.backgroundColor,...l.inlineBox.toArray())})}),B.forEach(y=>{y.fragments.forEach(a=>{const l=-i.x+(A.offsetX??0),c=-i.y+(A.offsetY??0),x={...a.computedStyle,...A};switch(R(r,{...x,fontSize:x.fontSize*e,letterSpacing:x.letterSpacing*e,textStrokeWidth:x.textStrokeWidth*e,shadowOffsetX:x.shadowOffsetX*e,shadowOffsetY:x.shadowOffsetY*e,shadowBlur:x.shadowBlur*e,textAlign:"left"}),x.writingMode){case"vertical-rl":case"vertical-lr":{a.characters.forEach(h=>{r.setTransform(1,0,0,1,0,0);let p=0,D=0;switch(h.verticalOrientation){case"Tr":case"R":{r.rotate(Math.PI/2),r.textBaseline="alphabetic",D=-(l+a.inlineBox.x+a.inlineBox.width-h.baseline),p=c+h.contentBox.y;break}case"Tu":r.textBaseline="top",p=l+h.contentBox.x+h.contentBox.right-h.glyphBox.right,D=c+h.contentBox.y+h.contentBox.y-h.glyphBox.y;break;case"U":p=l+h.contentBox.x,D=c+h.contentBox.y,r.textBaseline="top";break}r.fillText(h.content,p*e,D*e),x.textStrokeWidth&&r.strokeText(h.content,p*e,D*e)});break}case"horizontal-tb":{const h=l+a.contentBox.x,p=c+a.contentBox.y,D=c+a.inlineBox.y+a.baseline,{width:b,height:k}=a.contentBox;switch(r.textBaseline="alphabetic",r.setTransform(1,0,0,1,0,0),r.fillText(a.computedContent,h*e,D*e),x.textStrokeWidth&&r.strokeText(a.computedContent,h*e,D*e),r.scale(e,e),x.textDecoration){case"underline":r.strokeStyle=r.fillStyle,r.lineWidth=x.fontSize/15,r.beginPath(),r.moveTo(h,p+k),r.lineTo(h+b,p+k),r.stroke();break;case"line-through":r.strokeStyle=r.fillStyle,r.lineWidth=x.fontSize/15,r.beginPath(),r.moveTo(h,p+k/2),r.lineTo(h+b,p+k/2),r.stroke();break}break}}})})}),t}exports.defaultTextStyles=$;exports.measureText=X;exports.renderText=J;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (function(v,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(v=typeof globalThis<"u"?globalThis:v||self,g(v.modernText={}))})(this,function(v){"use strict";class g{constructor(t=0,n=0,o=0,u=0){this.x=t,this.y=n,this.width=o,this.height=u}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}static from(...t){const n=t[0],o=t.slice(1).reduce((u,s)=>(u.x=Math.min(u.x,s.x),u.y=Math.min(u.y,s.y),u.right=Math.max(u.right,s.right),u.bottom=Math.max(u.bottom,s.bottom),u),{x:n.x,y:n.y,right:n.right,bottom:n.bottom});return new g(o.x,o.y,o.right-o.x,o.bottom-o.y)}rotate90deg(){const{width:t,height:n}=this;this.width=n,this.height=t}translate(t,n){return this.x+=t,this.y+=n,this}clone(){return new g(this.x,this.y,this.width,this.height)}toArray(){return[this.x,this.y,this.width,this.height]}}function P(r,t){switch(r.shadowColor=t.shadowColor||"rgba(0, 0, 0, 0)",r.shadowOffsetX=t.shadowOffsetX||0,r.shadowOffsetY=t.shadowOffsetY||0,r.shadowBlur=t.shadowBlur||0,r.strokeStyle=t.textStrokeColor||"#000",r.lineWidth=t.textStrokeWidth||0,r.fillStyle=t.color||"#000",r.textAlign=t.textAlign||"start",r.fontKerning=t.fontKerning||"normal",t.verticalAlign){case"top":case"middle":case"bottom":r.textBaseline=t.verticalAlign;break;case"baseline":default:r.textBaseline="alphabetic";break}r.font=[t.fontStyle||"normal",t.fontWeight||"normal",`${t.fontSize||14}px`,t.fontFamily||"sans-serif"].join(" "),r.letterSpacing=`${t.letterSpacing||0}px`}const Y="OffscreenCanvas"in globalThis;let N;function j(){return N??(N=Y?new OffscreenCanvas(1,1):document.createElement("canvas"))}function $(r,t){const n=j().getContext("2d");P(n,{...t,textAlign:"center",verticalAlign:"baseline"});const{width:o,actualBoundingBoxAscent:u,actualBoundingBoxDescent:s,actualBoundingBoxLeft:i,actualBoundingBoxRight:B,fontBoundingBoxAscent:E,fontBoundingBoxDescent:D}=n.measureText(r),x=t.fontSize*t.lineHeight,f=E+D;return{width:o,height:t.fontSize,typoAscent:E,typoDescent:D,typoHeight:f,lineHeight:x,glyphLeft:i,glyphRight:B,glyphAscent:u,glyphDescent:s,glyphWidth:i+B,glyphHeight:u+s,baseline:(x-f)/2+E,centerX:o/2}}function I(r,t){const n=document.createDocumentFragment(),o=document.createElement("div");o.style.position="absolute",o.style.visibility="hidden",o.setAttribute("aria-hidden","true"),o.style.fontFamily=t.fontFamily,o.style.fontSize=`${t.fontSize}px`,o.style.lineHeight=String(t.lineHeight),o.style.whiteSpace="nowrap",o.style.writingMode=t.writingMode;const u=document.createElement("span");u.textContent=/\s/.test(r)?"&nbsp;":r,o.appendChild(u),n.appendChild(o),document.body.appendChild(n);const s={leading:u.offsetHeight-t.fontSize};return document.body.removeChild(o),s}const K=/[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\u{328A}-\u{32B0}\u{32B1}-\u{32BF}\u{32C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980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\u{1B2FC}-\u{1B2FF}\u{1CF00}-\u{1CF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FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u,X=/[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u,_=/[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u,G=/[\r\n]/;class z{constructor(t,n){this.content=t,this.parent=n,this.contentBox=new g,this.glyphBox=new g,this.baseline=0,this.verticalOrientation="U",this.isPunctuation=!1,this.isEOL=!1,this.update()}get computedStyle(){return this.parent.computedStyle}update(){switch(this.computedStyle.textOrientation){case"upright":this.verticalOrientation="U";break;case"sideways-right":case"sideways":this.verticalOrientation="R";break;case"mixed":default:this.verticalOrientation=K.test(this.content)?X.test(this.content)?"Tu":"U":X.test(this.content)?"Tr":"R";break}return this.isPunctuation=_.test(this.content),this.isEOL=G.test(this.content),this}measure(){const t=this.computedStyle,{width:n,height:o,glyphAscent:u,glyphLeft:s,glyphWidth:i,glyphHeight:B,lineHeight:E,baseline:D,centerX:x}=$(this.content,{...t,letterSpacing:0});switch(this.contentBox.width=n,this.contentBox.height=o,this.glyphBox.width=i,this.glyphBox.height=B,this.baseline=D,t.writingMode){case"vertical-lr":case"vertical-rl":{const f=t.fontSize*t.lineHeight;switch(this.verticalOrientation){case"Tr":case"R":this.contentBox.rotate90deg(),this.glyphBox.rotate90deg(),this.contentBox.x=(f-o)/2,this.glyphBox.x=(f-B)/2;break;case"U":{const{leading:h}=I(this.content,{...t,letterSpacing:0});this.contentBox.x=(f-n)/2,this.contentBox.y=h,this.glyphBox.x=(f-i)/2,this.glyphBox.y=0;break}case"Tu":this.contentBox.x=(f-n)/2,this.contentBox.y=0,this.glyphBox.x=this.contentBox.x+x-s,this.glyphBox.y=o-B;break}break}case"horizontal-tb":this.contentBox.x=0,this.contentBox.y=(E-o)/2,this.glyphBox.x=x-s,this.glyphBox.y=D-u;break}return this}clone(){const t=new z(this.content,this.parent);return t.contentBox=this.contentBox.clone(),t.glyphBox=this.glyphBox.clone(),t}}class T{constructor(t,n,o){this.content=t,this.style=n,this.parent=o,this.contentBox=new g,this.inlineBox=new g,this.glyphBox=new g,this.centerX=0,this.baseline=0,this.update()}update(){var o;this.computedStyle={...(o=this.parent)==null?void 0:o.computedStyle,...this.style};const t=this.computedStyle;this.computedContent=t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content;const n=[];for(const u of this.computedContent)n.push(new z(u,this));return this.characters=n,this}measure(){var n;const t=this.computedStyle;switch(t.writingMode){case"vertical-lr":case"vertical-rl":{let o=0;const u={left:0,right:0},s={left:0,right:0};this.characters.forEach((i,B)=>{i.update().measure(),u.left=Math.min(u.left,i.contentBox.left),u.right=Math.max(u.right,i.contentBox.right),s.left=Math.min(s.left,i.glyphBox.left),s.right=Math.max(s.right,i.glyphBox.right),o+=i.contentBox.y+i.contentBox.height,B!==this.characters.length-1&&(o+=t.letterSpacing)}),this.inlineBox.width=t.fontSize*t.lineHeight,this.inlineBox.height=o,this.contentBox.width=u.right-u.left,this.contentBox.height=o,this.glyphBox.width=s.right-s.left,this.glyphBox.height=o,this.baseline=((n=this.characters[0])==null?void 0:n.baseline)??0,this.centerX=o/2,this.contentBox.x=u.left,this.glyphBox.x=s.left;break}case"horizontal-tb":{let o=0;const u={top:0,bottom:0},s={top:0,bottom:0};this.characters.forEach((B,E)=>{B.update().measure(),u.top=Math.min(u.top,B.contentBox.top),u.bottom=Math.max(u.bottom,B.contentBox.bottom),s.top=Math.min(s.top,B.glyphBox.top),s.bottom=Math.max(s.bottom,B.glyphBox.bottom),o+=B.contentBox.x+B.contentBox.width,E!==this.characters.length-1&&(o+=t.letterSpacing)}),this.inlineBox.width=o,this.inlineBox.height=t.fontSize*t.lineHeight,this.contentBox.width=o,this.contentBox.height=u.bottom-u.top,this.glyphBox.width=o,this.glyphBox.height=s.bottom-s.top,this.centerX=o/2,this.inlineBox.x=0,this.inlineBox.y=0;const i=this.characters[0];i&&(this.baseline=i.baseline,this.contentBox.x=i.contentBox.x,this.glyphBox.x=i.glyphBox.x),this.contentBox.y=u.top,this.glyphBox.y=s.top;break}}return this}clone(t){return new T(t??this.content,this.style,this.parent)}}class M{constructor(t,n){this.style=t,this.parent=n,this.contentBox=new g,this.lineBox=new g,this.glyphBox=new g,this.baseline=0,this.xHeight=0,this.fragments=[],this.update()}update(){this.computedStyle={...this.parent,...this.style}}addFragment(t,n){return this.fragments.push(new T(t,n,this)),this}clone(t){const n=new M(this.style,this.parent);return n.contentBox=this.contentBox.clone(),n.lineBox=this.lineBox.clone(),n.glyphBox=this.glyphBox.clone(),n.baseline=this.baseline,n.xHeight=this.xHeight,n.fragments=t??this.fragments.map(o=>o.clone()),n}}function V(r,t){const n=[];if(typeof r=="string")n.push(new M(void 0,t).addFragment(r));else{r=Array.isArray(r)?r:[r];for(const o of r)if(typeof o=="string")n.push(new M(void 0,t).addFragment(o));else if(Array.isArray(o)){const u=new M(void 0,t);o.forEach(s=>{if(typeof s=="string")u.addFragment(s);else{const{content:i,...B}=s;u.addFragment(i,B)}}),n.push(u)}else if("fragments"in o){const{fragments:u,...s}=o,i=new M(s,t);u.forEach(B=>{const{content:E,...D}=B;i.addFragment(E,D)}),n.push(i)}else if("content"in o){const{content:u,...s}=o;n.push(new M(s,t).addFragment(u))}}return n}function q(r,t,n){var B;const o=[],u=r.slice();let s,i;for(;s=u.shift();){const E=s.fragments.slice();let D=0;const x=[];for(;i=E.shift();){const f=i.computedStyle;let h="",S=!1,k=0;const e=new T("",i.style,i.parent);for(const d of i.characters){if(e.content+=d.content,(B=i.characters[++k])!=null&&B.isPunctuation)continue;let y,m;switch(f.writingMode){case"vertical-lr":case"vertical-rl":y=n,m=e.update().measure().contentBox.height;break;case"horizontal-tb":default:y=t,m=e.update().measure().contentBox.width;break}if(m+=f.letterSpacing,d.isEOL||y&&D+m>y){let a=d.isEOL?h.length+1:h.length;!D&&!a&&(h+=e.computedContent,a+=e.computedContent.length),h.length&&x.push(i.clone(h)),x.length&&(o.push(s.clone(x.slice())),x.length=0);const l=i.computedContent.substring(a);(l.length||E.length)&&u.unshift(s.clone((l.length?[i.clone(l)]:[]).concat(E.slice()))),E.length=0,S=!0;break}else D+=m;h+=e.computedContent,e.content=""}S||x.push(i.clone())}x.length&&o.push(s.clone(x))}return o}const L={width:0,height:0,color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",fontSize:14,fontWeight:"normal",fontFamily:"sans-serif",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",verticalAlign:"baseline",textTransform:"none",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",lineHeight:1,letterSpacing:0,shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,writingMode:"horizontal-tb",textOrientation:"mixed"};function J(r){return{...L,...r}}function U(r){const{content:t,effects:n=[{}]}=r,{width:o,height:u,...s}=J(r.style);let i=V(t,s);i=q(i,o,u);let B=0,E=0;i.forEach(e=>{let d=null;e.fragments.forEach(F=>{F.update().measure(),(!d||d.contentBox.height<F.contentBox.height)&&(d=F)});const{glyphHeight:y,baseline:m}=$("x",(d??e).computedStyle);e.xHeight=y,e.baseline=m;const a=e.computedStyle;let l=B,c=E,A=0;e.fragments.forEach((F,p)=>{const C=F.computedStyle;switch(a.writingMode){case"vertical-rl":case"vertical-lr":{p||(c=0),F.inlineBox.translate(l,c),F.contentBox.translate(l,c),F.glyphBox.translate(l,c);let b=c;F.characters.forEach((w,W)=>{const R=w.contentBox.y+w.contentBox.height;w.contentBox.translate(l,b),w.glyphBox.translate(l,b),b+=R,W!==F.characters.length-1&&(b+=C.letterSpacing)}),c+=F.inlineBox.height,p===e.fragments.length-1&&(l+=F.inlineBox.width);break}case"horizontal-tb":{p||(l=0),F.inlineBox.translate(l,c),F.contentBox.translate(l,c),F.glyphBox.translate(l,c);let b=l;F.characters.forEach((w,W)=>{const R=w.contentBox.x+w.contentBox.width;w.contentBox.translate(b,c),w.glyphBox.translate(b,c),b+=R,W!==F.characters.length-1&&(b+=C.letterSpacing)}),l+=F.inlineBox.width,A=Math.max(A,F.inlineBox.height),p===e.fragments.length-1&&(c+=A);break}}}),B=l,E=c,e.lineBox=g.from(...e.fragments.map(F=>F.inlineBox))});const D=g.from(...i.map(e=>e.lineBox),new g(0,0,o,u)),{width:x,height:f}=D;i.forEach(e=>{let d=0;const y=0,m=e.computedStyle;switch(m.writingMode){case"vertical-rl":d+=x-(e.lineBox.x*2+e.lineBox.width);case"vertical-lr":e.lineBox.height=Math.max(e.lineBox.height,f);break;case"horizontal-tb":e.lineBox.width=Math.max(e.lineBox.width,x);break}e.contentBox=g.from(...e.fragments.map(a=>a.contentBox)),e.glyphBox=g.from(...e.fragments.map(a=>a.glyphBox)),e.fragments.forEach(a=>{let l=d,c=y;const A=a.computedStyle;switch(m.writingMode){case"vertical-rl":case"vertical-lr":{switch(A.textAlign){case"end":case"right":c+=f-e.contentBox.height;break;case"center":c+=(f-e.contentBox.height)/2;break}a.characters.forEach(F=>{let p=l;const C=c;switch(A.verticalAlign){case"top":case"middle":case"bottom":case"sub":case"super":case"text-top":case"text-bottom":case"baseline":default:p+=e.baseline-F.baseline;break}F.contentBox.translate(p,C),F.glyphBox.translate(p,C)});break}case"horizontal-tb":{switch(A.textAlign){case"end":case"right":l=x-e.contentBox.width;break;case"center":l=(x-e.contentBox.width)/2;break}switch(A.verticalAlign){case"top":c=e.lineBox.y-a.inlineBox.y;break;case"middle":c=a.inlineBox.y-(e.baseline-e.xHeight/2-a.inlineBox.height/2);break;case"bottom":c=e.lineBox.bottom-a.inlineBox.bottom;break;case"sub":c=e.lineBox.y+e.baseline-a.glyphBox.bottom;break;case"super":c=e.lineBox.y+e.baseline-a.glyphBox.y;break;case"text-top":c=e.glyphBox.y-a.inlineBox.y;break;case"text-bottom":c=e.glyphBox.bottom-a.inlineBox.bottom;break;case"baseline":default:a.inlineBox.height<e.lineBox.height&&(c=e.baseline-a.baseline);break}a.characters.forEach(F=>{F.contentBox.translate(l,c),F.glyphBox.translate(l,c)});break}}a.inlineBox.translate(l,c),a.contentBox.translate(l,c),a.glyphBox.translate(l,c)}),e.lineBox=g.from(e.lineBox,...e.fragments.map(a=>a.inlineBox)),e.contentBox=g.from(...e.fragments.map(a=>a.contentBox)),e.glyphBox=g.from(...e.fragments.map(a=>a.glyphBox))});const h=g.from(...i.map(e=>e.contentBox)),S=g.from(...i.map(e=>e.glyphBox)),k=[];return i.forEach(e=>{e.fragments.forEach(d=>{const y=d.computedStyle;n.forEach(m=>{const a={...y,...m},{textStrokeWidth:l=0,offsetX:c=0,offsetY:A=0}=a;if(l||c||A){const{x:F,y:p,width:C,height:b}=d.contentBox;k.push(new g(Math.min(F,F+c-l/2),Math.min(p,p+A-l/2),Math.max(C,C+c+l),Math.max(b,b+A+l)))}})})}),{box:D,contentBox:h,glyphBox:S,paragraphs:i,viewBox:g.from(D,S,...k)}}function H(r,t,n){if(typeof t=="string"&&t.startsWith("linear-gradient")){const{x0:o,y0:u,x1:s,y1:i,stops:B}=Q(t,n.left,n.top,n.width,n.height),E=r.createLinearGradient(o,u,s,i);return B.forEach(D=>E.addColorStop(D.offset,D.color)),E}return t}function Q(r,t,n,o,u){var S;const s=((S=r.match(/linear-gradient\((.+)\)$/))==null?void 0:S[1])??"",i=s.split(",")[0],B=i.includes("deg")?i:"0deg",E=s.replace(B,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi),x=(Number(B.replace("deg",""))||0)*Math.PI/180,f=o*Math.sin(x),h=u*Math.cos(x);return{x0:t+o/2-f,y0:n+u/2+h,x1:t+o/2+f,y1:n+u/2-h,stops:Array.from(E).map(k=>{let e=k[2];return e.startsWith("(")?e=e.split(",").length>3?`rgba${e}`:`rgb${e}`:e=`#${e}`,{offset:Number(k[3].replace("%",""))/100,color:e}})}}function O(r,t,n){n!=null&&n.color&&(n.color=H(r,n.color,t)),n!=null&&n.backgroundColor&&(n.backgroundColor=H(r,n.backgroundColor,t)),n!=null&&n.textStrokeColor&&(n.textStrokeColor=H(r,n.textStrokeColor,t))}function Z(r){const{view:t=document.createElement("canvas"),style:n,effects:o=[],pixelRatio:u=1}=r,s=o.length>0?o:[{}],{viewBox:i,paragraphs:B}=U(r),{x:E,y:D,width:x,height:f}=i,h=t.getContext("2d");t.style.width=`${x}px`,t.style.height=`${f}px`,t.dataset.viewbox=`${E} ${D} ${x} ${f}`,t.dataset.pixelRatio=String(u),t.width=Math.max(1,Math.floor(x*u)),t.height=Math.max(1,Math.floor(f*u)),h.scale(u,u);const S=(e,d,y,m,a)=>{h.fillStyle=e,h.fillRect(-i.x+d,-i.y+y,m,a)},k={...n};return O(h,new g(0,0,x,f),k),B.forEach(e=>{O(h,e.contentBox,e.computedStyle),e.fragments.forEach(d=>{O(h,d.contentBox,d.computedStyle)})}),s.forEach(e=>{const d={...e};O(h,new g(0,0,x,f),d);const y={...k,...d};y!=null&&y.backgroundColor&&S(y.backgroundColor,0,0,t.width,t.height),B.forEach(m=>{var a;(a=m.style)!=null&&a.backgroundColor&&S(m.computedStyle.backgroundColor,...m.lineBox.toArray()),m.fragments.forEach(l=>{var c;(c=l.style)!=null&&c.backgroundColor&&S(l.computedStyle.backgroundColor,...l.inlineBox.toArray())})}),B.forEach(m=>{m.fragments.forEach(a=>{const l=-i.x+(d.offsetX??0),c=-i.y+(d.offsetY??0),A={...a.computedStyle,...d};switch(P(h,{...A,fontSize:A.fontSize*u,letterSpacing:A.letterSpacing*u,textStrokeWidth:A.textStrokeWidth*u,shadowOffsetX:A.shadowOffsetX*u,shadowOffsetY:A.shadowOffsetY*u,shadowBlur:A.shadowBlur*u,textAlign:"left"}),A.writingMode){case"vertical-rl":case"vertical-lr":{a.characters.forEach(F=>{h.setTransform(1,0,0,1,0,0);let p=0,C=0;switch(F.verticalOrientation){case"Tr":case"R":{h.rotate(Math.PI/2),h.textBaseline="alphabetic",C=-(l+a.inlineBox.x+a.inlineBox.width-F.baseline),p=c+F.contentBox.y;break}case"Tu":h.textBaseline="top",p=l+F.contentBox.x+F.contentBox.right-F.glyphBox.right,C=c+F.contentBox.y+F.contentBox.y-F.glyphBox.y;break;case"U":p=l+F.contentBox.x,C=c+F.contentBox.y,h.textBaseline="top";break}h.fillText(F.content,p*u,C*u),A.textStrokeWidth&&h.strokeText(F.content,p*u,C*u)});break}case"horizontal-tb":{const F=l+a.contentBox.x,p=c+a.contentBox.y,C=c+a.inlineBox.y+a.baseline,{width:b,height:w}=a.contentBox;switch(h.textBaseline="alphabetic",h.setTransform(1,0,0,1,0,0),h.fillText(a.computedContent,F*u,C*u),A.textStrokeWidth&&h.strokeText(a.computedContent,F*u,C*u),h.scale(u,u),A.textDecoration){case"underline":h.strokeStyle=h.fillStyle,h.lineWidth=A.fontSize/15,h.beginPath(),h.moveTo(F,p+w),h.lineTo(F+b,p+w),h.stroke();break;case"line-through":h.strokeStyle=h.fillStyle,h.lineWidth=A.fontSize/15,h.beginPath(),h.moveTo(F,p+w/2),h.lineTo(F+b,p+w/2),h.stroke();break}break}}})})}),t}v.defaultTextStyles=L,v.measureText=U,v.renderText=Z,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
1
+ (function(k,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(k=typeof globalThis<"u"?globalThis:k||self,g(k.modernText={}))})(this,function(k){"use strict";class g{constructor(t=0,u=0,o=0,e=0){this.x=t,this.y=u,this.width=o,this.height=e}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}static from(...t){const u=t[0],o=t.slice(1).reduce((e,s)=>(e.x=Math.min(e.x,s.x),e.y=Math.min(e.y,s.y),e.right=Math.max(e.right,s.right),e.bottom=Math.max(e.bottom,s.bottom),e),{x:u.x,y:u.y,right:u.right,bottom:u.bottom});return new g(o.x,o.y,o.right-o.x,o.bottom-o.y)}rotate90deg(){const{width:t,height:u}=this;this.width=u,this.height=t}translate(t,u){return this.x+=t,this.y+=u,this}clone(){return new g(this.x,this.y,this.width,this.height)}toArray(){return[this.x,this.y,this.width,this.height]}}function R(F,t){switch(F.shadowColor=t.shadowColor||"rgba(0, 0, 0, 0)",F.shadowOffsetX=t.shadowOffsetX||0,F.shadowOffsetY=t.shadowOffsetY||0,F.shadowBlur=t.shadowBlur||0,F.strokeStyle=t.textStrokeColor||"#000",F.lineWidth=t.textStrokeWidth||0,F.fillStyle=t.color||"#000",F.textAlign=t.textAlign||"start",F.fontKerning=t.fontKerning||"normal",t.verticalAlign){case"top":case"middle":case"bottom":F.textBaseline=t.verticalAlign;break;case"baseline":default:F.textBaseline="alphabetic";break}F.font=[t.fontStyle||"normal",t.fontWeight||"normal",`${t.fontSize||14}px`,t.fontFamily||"sans-serif"].join(" "),F.letterSpacing=`${t.letterSpacing||0}px`}const U="OffscreenCanvas"in globalThis;let Y;function N(){return Y??(Y=U?new OffscreenCanvas(1,1):document.createElement("canvas"))}function P(F,t){const u=N().getContext("2d");R(u,{...t,textAlign:"center",verticalAlign:"baseline"});const{width:o,actualBoundingBoxAscent:e,actualBoundingBoxDescent:s,actualBoundingBoxLeft:i,actualBoundingBoxRight:B,fontBoundingBoxAscent:E,fontBoundingBoxDescent:m}=u.measureText(F),x=t.fontSize*t.lineHeight,f=E+m;return{width:o,height:t.fontSize,typoAscent:E,typoDescent:m,typoHeight:f,lineHeight:x,glyphLeft:i,glyphRight:B,glyphAscent:e,glyphDescent:s,glyphWidth:i+B,glyphHeight:e+s,baseline:(x-f)/2+E,centerX:o/2}}function j(F,t){const u=document.createDocumentFragment(),o=document.createElement("div");o.style.position="absolute",o.style.visibility="hidden",o.setAttribute("aria-hidden","true"),o.style.fontFamily=t.fontFamily,o.style.fontSize=`${t.fontSize}px`,o.style.lineHeight=String(t.lineHeight),o.style.whiteSpace="nowrap",o.style.writingMode=t.writingMode;const e=document.createElement("span");e.textContent=/\s/.test(F)?"&nbsp;":F,o.appendChild(e),u.appendChild(o),document.body.appendChild(u);const s={leading:e.offsetHeight-t.fontSize};return document.body.removeChild(o),s}const I=/[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\u{328A}-\u{32B0}\u{32B1}-\u{32BF}\u{32C0}-\u{32FE}\u{32FF}\u{3300}-\u{3357}\u{3358}-\u{337A}\u{337B}-\u{337F}\u{3380}-\u{33FF}\u{3400}-\u{4DBF}\u{4DC0}-\u{4DFF}\u{4E00}-\u{9FFF}\u{A000}-\u{A014}\u{A015}\u{A016}-\u{A48C}\u{A48D}-\u{A48F}\u{A490}-\u{A4C6}\u{A4C7}-\u{A4CF}\u{A960}-\u{A97C}\u{A97D}-\u{A97F}\u{AC00}-\u{D7A3}\u{D7A4}-\u{D7AF}\u{D7B0}-\u{D7C6}\u{D7C7}-\u{D7CA}\u{D7CB}-\u{D7FB}\u{D7FC}-\u{D7FF}\u{E000}-\u{F8FF}\u{F900}-\u{FA6D}\u{FA6E}-\u{FA6F}\u{FA70}-\u{FAD9}\u{FADA}-\u{FAFF}\u{FE10}-\u{FE16}\u{FE17}\u{FE18}\u{FE19}\u{FE1A}-\u{FE1F}\u{FE30}\u{FE31}-\u{FE32}\u{FE33}-\u{FE34}\u{FE35}\u{FE36}\u{FE37}\u{FE38}\u{FE39}\u{FE3A}\u{FE3B}\u{FE3C}\u{FE3D}\u{FE3E}\u{FE3F}\u{FE40}\u{FE41}\u{FE42}\u{FE43}\u{FE44}\u{FE45}-\u{FE46}\u{FE47}\u{FE48}\u{FE50}-\u{FE52}\u{FE53}\u{FE54}-\u{FE57}\u{FE5F}-\u{FE61}\u{FE62}\u{FE67}\u{FE68}\u{FE69}\u{FE6A}-\u{FE6B}\u{FE6C}-\u{FE6F}\u{FF01}\u{FF02}-\u{FF03}\u{FF04}\u{FF05}-\u{FF07}\u{FF0A}\u{FF0B}\u{FF0C}\u{FF0E}\u{FF0F}\u{FF10}-\u{FF19}\u{FF1F}\u{FF20}\u{FF21}-\u{FF3A}\u{FF3C}\u{FF3E}\u{FF40}\u{FF41}-\u{FF5A}\u{FFE0}-\u{FFE1}\u{FFE2}\u{FFE4}\u{FFE5}-\u{FFE6}\u{FFE7}\u{FFF0}-\u{FFF8}\u{FFFC}-\u{FFFD}\u{10980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\u{1B2FC}-\u{1B2FF}\u{1CF00}-\u{1CF2D}\u{1CF2E}-\u{1CF2F}\u{1CF30}-\u{1CF46}\u{1CF47}-\u{1CF4F}\u{1CF50}-\u{1CFC3}\u{1CFC4}-\u{1CFCF}\u{1D000}-\u{1D0F5}\u{1D0F6}-\u{1D0FF}\u{1D100}-\u{1D126}\u{1D127}-\u{1D128}\u{1D129}-\u{1D164}\u{1D165}-\u{1D166}\u{1D167}-\u{1D169}\u{1D16A}-\u{1D16C}\u{1D16D}-\u{1D172}\u{1D173}-\u{1D17A}\u{1D17B}-\u{1D182}\u{1D183}-\u{1D184}\u{1D185}-\u{1D18B}\u{1D18C}-\u{1D1A9}\u{1D1AA}-\u{1D1AD}\u{1D1AE}-\u{1D1EA}\u{1D1EB}-\u{1D1FF}\u{1D2E0}-\u{1D2F3}\u{1D2F4}-\u{1D2FF}\u{1D300}-\u{1D356}\u{1D357}-\u{1D35F}\u{1D360}-\u{1D378}\u{1D379}-\u{1D37F}\u{1D800}-\u{1D9FF}\u{1DA00}-\u{1DA36}\u{1DA37}-\u{1DA3A}\u{1DA3B}-\u{1DA6C}\u{1DA6D}-\u{1DA74}\u{1DA75}\u{1DA76}-\u{1DA83}\u{1DA84}\u{1DA85}-\u{1DA86}\u{1DA87}-\u{1DA8B}\u{1DA8C}-\u{1DA9A}\u{1DA9B}-\u{1DA9F}\u{1DAA0}\u{1DAA1}-\u{1DAAF}\u{1F000}-\u{1F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0}-\u{1FAC5}\u{1FAC6}-\u{1FACF}\u{1FAD0}-\u{1FAD9}\u{1FADA}-\u{1FADF}\u{1FAE0}-\u{1FAE7}\u{1FAE8}-\u{1FAEF}\u{1FAF0}-\u{1FAF6}\u{1FAF7}-\u{1FAFF}\u{20000}-\u{2A6DF}\u{2A6E0}-\u{2A6FF}\u{2A700}-\u{2B738}\u{2B739}-\u{2B73F}\u{2B740}-\u{2B81D}\u{2B81E}-\u{2B81F}\u{2B820}-\u{2CEA1}\u{2CEA2}-\u{2CEAF}\u{2CEB0}-\u{2EBE0}\u{2EBE1}-\u{2F7FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u,$=/[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u,K=/[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u,_=/[\r\n]/;class z{constructor(t,u){this.content=t,this.parent=u,this.contentBox=new g,this.glyphBox=new g,this.baseline=0,this.verticalOrientation="U",this.isPunctuation=!1,this.isEOL=!1,this.update()}get computedStyle(){return this.parent.computedStyle}update(){switch(this.computedStyle.textOrientation){case"upright":this.verticalOrientation="U";break;case"sideways-right":case"sideways":this.verticalOrientation="R";break;case"mixed":default:this.verticalOrientation=I.test(this.content)?$.test(this.content)?"Tu":"U":$.test(this.content)?"Tr":"R";break}return this.isPunctuation=K.test(this.content),this.isEOL=_.test(this.content),this}measure(){const t=this.computedStyle,{width:u,height:o,glyphAscent:e,glyphLeft:s,glyphWidth:i,glyphHeight:B,lineHeight:E,baseline:m,centerX:x}=P(this.content,{...t,letterSpacing:0});switch(this.contentBox.width=u,this.contentBox.height=o,this.glyphBox.width=i,this.glyphBox.height=B,this.baseline=m,t.writingMode){case"vertical-lr":case"vertical-rl":{const f=t.fontSize*t.lineHeight;switch(this.verticalOrientation){case"Tr":case"R":this.contentBox.rotate90deg(),this.glyphBox.rotate90deg(),this.contentBox.x=(f-o)/2,this.glyphBox.x=(f-B)/2;break;case"U":{const{leading:r}=j(this.content,{...t,letterSpacing:0});this.contentBox.x=(f-u)/2,this.contentBox.y=r,this.glyphBox.x=(f-i)/2,this.glyphBox.y=0;break}case"Tu":this.contentBox.x=(f-u)/2,this.contentBox.y=0,this.glyphBox.x=this.contentBox.x+x-s,this.glyphBox.y=o-B;break}this.contentBox.height+=t.letterSpacing;break}case"horizontal-tb":this.contentBox.x=0,this.contentBox.y=(E-o)/2,this.contentBox.width+=t.letterSpacing,this.glyphBox.x=x-s,this.glyphBox.y=m-e;break}return this}clone(){const t=new z(this.content,this.parent);return t.contentBox=this.contentBox.clone(),t.glyphBox=this.glyphBox.clone(),t}}function H(F){if(!F)return F;const t={};for(const u in F)F[u]!==""&&F[u]!==void 0&&(t[u]=F[u]);return t}class T{constructor(t,u,o){this.content=t,this.style=u,this.parent=o,this.contentBox=new g,this.inlineBox=new g,this.glyphBox=new g,this.centerX=0,this.baseline=0,this.update()}update(){var o;this.computedStyle={...(o=this.parent)==null?void 0:o.computedStyle,...H(this.style)};const t=this.computedStyle;this.computedContent=t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content;const u=[];for(const e of this.computedContent)u.push(new z(e,this));return this.characters=u,this}measure(){var u;const t=this.computedStyle;switch(t.writingMode){case"vertical-lr":case"vertical-rl":{let o=0;const e={left:0,right:0},s={left:0,right:0};this.characters.forEach(i=>{i.update().measure(),e.left=Math.min(e.left,i.contentBox.left),e.right=Math.max(e.right,i.contentBox.right),s.left=Math.min(s.left,i.glyphBox.left),s.right=Math.max(s.right,i.glyphBox.right),o+=i.contentBox.y+i.contentBox.height}),this.inlineBox.width=t.fontSize*t.lineHeight,this.inlineBox.height=o,this.contentBox.width=e.right-e.left,this.contentBox.height=o,this.glyphBox.width=s.right-s.left,this.glyphBox.height=o,this.baseline=((u=this.characters[0])==null?void 0:u.baseline)??0,this.centerX=o/2,this.contentBox.x=e.left,this.glyphBox.x=s.left;break}case"horizontal-tb":{let o=0;const e={top:0,bottom:0},s={top:0,bottom:0};this.characters.forEach(B=>{B.update().measure(),e.top=Math.min(e.top,B.contentBox.top),e.bottom=Math.max(e.bottom,B.contentBox.bottom),s.top=Math.min(s.top,B.glyphBox.top),s.bottom=Math.max(s.bottom,B.glyphBox.bottom),o+=B.contentBox.x+B.contentBox.width}),this.inlineBox.width=o,this.inlineBox.height=t.fontSize*t.lineHeight,this.contentBox.width=o,this.contentBox.height=e.bottom-e.top,this.glyphBox.width=o,this.glyphBox.height=s.bottom-s.top,this.centerX=o/2,this.inlineBox.x=0,this.inlineBox.y=0;const i=this.characters[0];i&&(this.baseline=i.baseline,this.contentBox.x=i.contentBox.x,this.glyphBox.x=i.glyphBox.x),this.contentBox.y=e.top,this.glyphBox.y=s.top;break}}return this}clone(t){return new T(t??this.content,this.style,this.parent)}}class M{constructor(t,u){this.style=t,this.parent=u,this.contentBox=new g,this.lineBox=new g,this.glyphBox=new g,this.baseline=0,this.xHeight=0,this.fragments=[],this.update()}update(){this.computedStyle={...H(this.parent),...H(this.style)}}addFragment(t,u){return this.fragments.push(new T(t,u,this)),this}clone(t){const u=new M(this.style,this.parent);return u.contentBox=this.contentBox.clone(),u.lineBox=this.lineBox.clone(),u.glyphBox=this.glyphBox.clone(),u.baseline=this.baseline,u.xHeight=this.xHeight,u.fragments=t??this.fragments.map(o=>o.clone()),u}}function G(F,t){const u=[];if(typeof F=="string")u.push(new M(void 0,t).addFragment(F));else{F=Array.isArray(F)?F:[F];for(const o of F)if(typeof o=="string")u.push(new M(void 0,t).addFragment(o));else if(Array.isArray(o)){const e=new M(void 0,t);o.forEach(s=>{if(typeof s=="string")e.addFragment(s);else{const{content:i,...B}=s;e.addFragment(i,B)}}),u.push(e)}else if("fragments"in o){const{fragments:e,...s}=o,i=new M(s,t);e.forEach(B=>{const{content:E,...m}=B;i.addFragment(E,m)}),u.push(i)}else if("content"in o){const{content:e,...s}=o;u.push(new M(s,t).addFragment(e))}}return u}function V(F,t,u){var B;const o=[],e=F.slice();let s,i;for(;s=e.shift();){const E=s.fragments.slice();let m=0;const x=[];for(;i=E.shift();){const f=i.computedStyle;let r="",w=!1,S=0;const n=new T("",i.style,i.parent);for(const d of i.characters){if(n.content+=d.content,(B=i.characters[++S])!=null&&B.isPunctuation)continue;let C,y;switch(f.writingMode){case"vertical-lr":case"vertical-rl":C=u,y=n.update().measure().contentBox.height;break;case"horizontal-tb":default:C=t,y=n.update().measure().contentBox.width;break}if(d.isEOL||C&&m+y>C){let a=d.isEOL?r.length+1:r.length;!m&&!a&&(r+=n.computedContent,a+=n.computedContent.length),r.length&&x.push(i.clone(r)),x.length&&(o.push(s.clone(x.slice())),x.length=0);const l=i.computedContent.substring(a);(l.length||E.length)&&e.unshift(s.clone((l.length?[i.clone(l)]:[]).concat(E.slice()))),E.length=0,w=!0;break}else m+=y;r+=n.computedContent,n.content=""}w||x.push(i.clone())}x.length&&o.push(s.clone(x))}return o}const X={width:0,height:0,color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",fontSize:14,fontWeight:"normal",fontFamily:"sans-serif",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",verticalAlign:"baseline",textTransform:"none",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",lineHeight:1,letterSpacing:0,shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,writingMode:"horizontal-tb",textOrientation:"mixed"};function q(F){return{...X,...F}}function L(F){const{content:t,effects:u=[{}]}=F,{width:o,height:e,...s}=q(F.style);let i=G(t,s);i=V(i,o,e);let B=0,E=0;i.forEach(n=>{let d=null;n.fragments.forEach(h=>{h.update().measure(),(!d||d.contentBox.height<h.contentBox.height)&&(d=h)});const{glyphHeight:C,baseline:y}=P("x",(d??n).computedStyle);n.xHeight=C,n.baseline=y;const a=n.computedStyle;let l=B,c=E,A=0;n.fragments.forEach((h,p)=>{switch(a.writingMode){case"vertical-rl":case"vertical-lr":{p||(c=0),h.inlineBox.translate(l,c),h.contentBox.translate(l,c),h.glyphBox.translate(l,c);let D=c;h.characters.forEach(b=>{const v=b.contentBox.y+b.contentBox.height;b.contentBox.translate(l,D),b.glyphBox.translate(l,D),D+=v}),c+=h.inlineBox.height,p===n.fragments.length-1&&(l+=h.inlineBox.width);break}case"horizontal-tb":{p||(l=0),h.inlineBox.translate(l,c),h.contentBox.translate(l,c),h.glyphBox.translate(l,c);let D=l;h.characters.forEach(b=>{const v=b.contentBox.x+b.contentBox.width;b.contentBox.translate(D,c),b.glyphBox.translate(D,c),D+=v}),l+=h.inlineBox.width,A=Math.max(A,h.inlineBox.height),p===n.fragments.length-1&&(c+=A);break}}}),B=l,E=c,n.lineBox=g.from(...n.fragments.map(h=>h.inlineBox))});const m=g.from(...i.map(n=>n.lineBox),new g(0,0,o,e)),{width:x,height:f}=m;i.forEach(n=>{let d=0;const C=0,y=n.computedStyle;switch(y.writingMode){case"vertical-rl":d+=x-(n.lineBox.x*2+n.lineBox.width);case"vertical-lr":n.lineBox.height=Math.max(n.lineBox.height,f);break;case"horizontal-tb":n.lineBox.width=Math.max(n.lineBox.width,x);break}n.contentBox=g.from(...n.fragments.map(a=>a.contentBox)),n.glyphBox=g.from(...n.fragments.map(a=>a.glyphBox)),n.fragments.forEach(a=>{let l=d,c=C;const A=a.computedStyle;switch(y.writingMode){case"vertical-rl":case"vertical-lr":{switch(A.textAlign){case"end":case"right":c+=f-n.contentBox.height;break;case"center":c+=(f-n.contentBox.height)/2;break}a.characters.forEach(h=>{let p=l;const D=c;switch(A.verticalAlign){case"top":case"middle":case"bottom":case"sub":case"super":case"text-top":case"text-bottom":case"baseline":default:p+=n.baseline-h.baseline;break}h.contentBox.translate(p,D),h.glyphBox.translate(p,D)});break}case"horizontal-tb":{switch(A.textAlign){case"end":case"right":l=x-n.contentBox.width;break;case"center":l=(x-n.contentBox.width)/2;break}switch(A.verticalAlign){case"top":c=n.lineBox.y-a.inlineBox.y;break;case"middle":c=a.inlineBox.y-(n.baseline-n.xHeight/2-a.inlineBox.height/2);break;case"bottom":c=n.lineBox.bottom-a.inlineBox.bottom;break;case"sub":c=n.lineBox.y+n.baseline-a.glyphBox.bottom;break;case"super":c=n.lineBox.y+n.baseline-a.glyphBox.y;break;case"text-top":c=n.glyphBox.y-a.inlineBox.y;break;case"text-bottom":c=n.glyphBox.bottom-a.inlineBox.bottom;break;case"baseline":default:a.inlineBox.height<n.lineBox.height&&(c=n.baseline-a.baseline);break}a.characters.forEach(h=>{h.contentBox.translate(l,c),h.glyphBox.translate(l,c)});break}}a.inlineBox.translate(l,c),a.contentBox.translate(l,c),a.glyphBox.translate(l,c)}),n.lineBox=g.from(n.lineBox,...n.fragments.map(a=>a.inlineBox)),n.contentBox=g.from(...n.fragments.map(a=>a.contentBox)),n.glyphBox=g.from(...n.fragments.map(a=>a.glyphBox))});const r=g.from(...i.map(n=>n.contentBox)),w=g.from(...i.map(n=>n.glyphBox)),S=[];return i.forEach(n=>{n.fragments.forEach(d=>{const C=d.computedStyle;u.forEach(y=>{const a={...C,...y},{textStrokeWidth:l=0,offsetX:c=0,offsetY:A=0}=a;if(l||c||A){const{x:h,y:p,width:D,height:b}=d.contentBox;S.push(new g(Math.min(h,h+c-l/2),Math.min(p,p+A-l/2),Math.max(D,D+c+l),Math.max(b,b+A+l)))}})})}),{box:m,contentBox:r,glyphBox:w,paragraphs:i,viewBox:g.from(m,w,...S)}}function W(F,t,u){if(typeof t=="string"&&t.startsWith("linear-gradient")){const{x0:o,y0:e,x1:s,y1:i,stops:B}=J(t,u.left,u.top,u.width,u.height),E=F.createLinearGradient(o,e,s,i);return B.forEach(m=>E.addColorStop(m.offset,m.color)),E}return t}function J(F,t,u,o,e){var w;const s=((w=F.match(/linear-gradient\((.+)\)$/))==null?void 0:w[1])??"",i=s.split(",")[0],B=i.includes("deg")?i:"0deg",E=s.replace(B,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi),x=(Number(B.replace("deg",""))||0)*Math.PI/180,f=o*Math.sin(x),r=e*Math.cos(x);return{x0:t+o/2-f,y0:u+e/2+r,x1:t+o/2+f,y1:u+e/2-r,stops:Array.from(E).map(S=>{let n=S[2];return n.startsWith("(")?n=n.split(",").length>3?`rgba${n}`:`rgb${n}`:n=`#${n}`,{offset:Number(S[3].replace("%",""))/100,color:n}})}}function O(F,t,u){u!=null&&u.color&&(u.color=W(F,u.color,t)),u!=null&&u.backgroundColor&&(u.backgroundColor=W(F,u.backgroundColor,t)),u!=null&&u.textStrokeColor&&(u.textStrokeColor=W(F,u.textStrokeColor,t))}function Q(F){const{view:t=document.createElement("canvas"),style:u,effects:o=[],pixelRatio:e=1}=F,s=o.length>0?o:[{}],{viewBox:i,paragraphs:B}=L(F),{x:E,y:m,width:x,height:f}=i,r=t.getContext("2d");t.style.width=`${x}px`,t.style.height=`${f}px`,t.dataset.viewbox=`${E} ${m} ${x} ${f}`,t.dataset.pixelRatio=String(e),t.width=Math.max(1,Math.floor(x*e)),t.height=Math.max(1,Math.floor(f*e)),r.scale(e,e);const w=(n,d,C,y,a)=>{r.fillStyle=n,r.fillRect(-i.x+d,-i.y+C,y,a)},S={...u};return O(r,new g(0,0,x,f),S),B.forEach(n=>{O(r,n.contentBox,n.computedStyle),n.fragments.forEach(d=>{O(r,d.contentBox,d.computedStyle)})}),s.forEach(n=>{const d={...n};O(r,new g(0,0,x,f),d);const C={...S,...d};C!=null&&C.backgroundColor&&w(C.backgroundColor,0,0,t.width,t.height),B.forEach(y=>{var a;(a=y.style)!=null&&a.backgroundColor&&w(y.computedStyle.backgroundColor,...y.lineBox.toArray()),y.fragments.forEach(l=>{var c;(c=l.style)!=null&&c.backgroundColor&&w(l.computedStyle.backgroundColor,...l.inlineBox.toArray())})}),B.forEach(y=>{y.fragments.forEach(a=>{const l=-i.x+(d.offsetX??0),c=-i.y+(d.offsetY??0),A={...a.computedStyle,...d};switch(R(r,{...A,fontSize:A.fontSize*e,letterSpacing:A.letterSpacing*e,textStrokeWidth:A.textStrokeWidth*e,shadowOffsetX:A.shadowOffsetX*e,shadowOffsetY:A.shadowOffsetY*e,shadowBlur:A.shadowBlur*e,textAlign:"left"}),A.writingMode){case"vertical-rl":case"vertical-lr":{a.characters.forEach(h=>{r.setTransform(1,0,0,1,0,0);let p=0,D=0;switch(h.verticalOrientation){case"Tr":case"R":{r.rotate(Math.PI/2),r.textBaseline="alphabetic",D=-(l+a.inlineBox.x+a.inlineBox.width-h.baseline),p=c+h.contentBox.y;break}case"Tu":r.textBaseline="top",p=l+h.contentBox.x+h.contentBox.right-h.glyphBox.right,D=c+h.contentBox.y+h.contentBox.y-h.glyphBox.y;break;case"U":p=l+h.contentBox.x,D=c+h.contentBox.y,r.textBaseline="top";break}r.fillText(h.content,p*e,D*e),A.textStrokeWidth&&r.strokeText(h.content,p*e,D*e)});break}case"horizontal-tb":{const h=l+a.contentBox.x,p=c+a.contentBox.y,D=c+a.inlineBox.y+a.baseline,{width:b,height:v}=a.contentBox;switch(r.textBaseline="alphabetic",r.setTransform(1,0,0,1,0,0),r.fillText(a.computedContent,h*e,D*e),A.textStrokeWidth&&r.strokeText(a.computedContent,h*e,D*e),r.scale(e,e),A.textDecoration){case"underline":r.strokeStyle=r.fillStyle,r.lineWidth=A.fontSize/15,r.beginPath(),r.moveTo(h,p+v),r.lineTo(h+b,p+v),r.stroke();break;case"line-through":r.strokeStyle=r.fillStyle,r.lineWidth=A.fontSize/15,r.beginPath(),r.moveTo(h,p+v/2),r.lineTo(h+b,p+v/2),r.stroke();break}break}}})})}),t}k.defaultTextStyles=X,k.measureText=L,k.renderText=Q,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  class E {
2
- constructor(t = 0, n = 0, o = 0, u = 0) {
3
- this.x = t, this.y = n, this.width = o, this.height = u;
2
+ constructor(t = 0, u = 0, o = 0, e = 0) {
3
+ this.x = t, this.y = u, this.width = o, this.height = e;
4
4
  }
5
5
  get left() {
6
6
  return this.x;
@@ -15,7 +15,7 @@ class E {
15
15
  return this.y + this.height;
16
16
  }
17
17
  static from(...t) {
18
- const n = t[0], o = t.slice(1).reduce((u, s) => (u.x = Math.min(u.x, s.x), u.y = Math.min(u.y, s.y), u.right = Math.max(u.right, s.right), u.bottom = Math.max(u.bottom, s.bottom), u), { x: n.x, y: n.y, right: n.right, bottom: n.bottom });
18
+ const u = t[0], o = t.slice(1).reduce((e, s) => (e.x = Math.min(e.x, s.x), e.y = Math.min(e.y, s.y), e.right = Math.max(e.right, s.right), e.bottom = Math.max(e.bottom, s.bottom), e), { x: u.x, y: u.y, right: u.right, bottom: u.bottom });
19
19
  return new E(
20
20
  o.x,
21
21
  o.y,
@@ -24,11 +24,11 @@ class E {
24
24
  );
25
25
  }
26
26
  rotate90deg() {
27
- const { width: t, height: n } = this;
28
- this.width = n, this.height = t;
27
+ const { width: t, height: u } = this;
28
+ this.width = u, this.height = t;
29
29
  }
30
- translate(t, n) {
31
- return this.x += t, this.y += n, this;
30
+ translate(t, u) {
31
+ return this.x += t, this.y += u, this;
32
32
  }
33
33
  clone() {
34
34
  return new E(
@@ -42,77 +42,77 @@ class E {
42
42
  return [this.x, this.y, this.width, this.height];
43
43
  }
44
44
  }
45
- function P(r, t) {
46
- switch (r.shadowColor = t.shadowColor || "rgba(0, 0, 0, 0)", r.shadowOffsetX = t.shadowOffsetX || 0, r.shadowOffsetY = t.shadowOffsetY || 0, r.shadowBlur = t.shadowBlur || 0, r.strokeStyle = t.textStrokeColor || "#000", r.lineWidth = t.textStrokeWidth || 0, r.fillStyle = t.color || "#000", r.textAlign = t.textAlign || "start", r.fontKerning = t.fontKerning || "normal", t.verticalAlign) {
45
+ function R(F, t) {
46
+ switch (F.shadowColor = t.shadowColor || "rgba(0, 0, 0, 0)", F.shadowOffsetX = t.shadowOffsetX || 0, F.shadowOffsetY = t.shadowOffsetY || 0, F.shadowBlur = t.shadowBlur || 0, F.strokeStyle = t.textStrokeColor || "#000", F.lineWidth = t.textStrokeWidth || 0, F.fillStyle = t.color || "#000", F.textAlign = t.textAlign || "start", F.fontKerning = t.fontKerning || "normal", t.verticalAlign) {
47
47
  case "top":
48
48
  case "middle":
49
49
  case "bottom":
50
- r.textBaseline = t.verticalAlign;
50
+ F.textBaseline = t.verticalAlign;
51
51
  break;
52
52
  case "baseline":
53
53
  default:
54
- r.textBaseline = "alphabetic";
54
+ F.textBaseline = "alphabetic";
55
55
  break;
56
56
  }
57
- r.font = [
57
+ F.font = [
58
58
  t.fontStyle || "normal",
59
59
  t.fontWeight || "normal",
60
60
  `${t.fontSize || 14}px`,
61
61
  t.fontFamily || "sans-serif"
62
- ].join(" "), r.letterSpacing = `${t.letterSpacing || 0}px`;
62
+ ].join(" "), F.letterSpacing = `${t.letterSpacing || 0}px`;
63
63
  }
64
- const X = "OffscreenCanvas" in globalThis;
65
- let L;
66
- function U() {
67
- return L ?? (L = X ? new OffscreenCanvas(1, 1) : document.createElement("canvas"));
64
+ const $ = "OffscreenCanvas" in globalThis;
65
+ let X;
66
+ function L() {
67
+ return X ?? (X = $ ? new OffscreenCanvas(1, 1) : document.createElement("canvas"));
68
68
  }
69
- function $(r, t) {
70
- const n = U().getContext("2d");
71
- P(n, {
69
+ function P(F, t) {
70
+ const u = L().getContext("2d");
71
+ R(u, {
72
72
  ...t,
73
73
  textAlign: "center",
74
74
  verticalAlign: "baseline"
75
75
  });
76
76
  const {
77
77
  width: o,
78
- actualBoundingBoxAscent: u,
78
+ actualBoundingBoxAscent: e,
79
79
  actualBoundingBoxDescent: s,
80
80
  actualBoundingBoxLeft: i,
81
81
  actualBoundingBoxRight: B,
82
- fontBoundingBoxAscent: d,
83
- fontBoundingBoxDescent: D
84
- } = n.measureText(r), g = t.fontSize * t.lineHeight, f = d + D;
82
+ fontBoundingBoxAscent: f,
83
+ fontBoundingBoxDescent: m
84
+ } = u.measureText(F), g = t.fontSize * t.lineHeight, d = f + m;
85
85
  return {
86
86
  width: o,
87
87
  height: t.fontSize,
88
- typoAscent: d,
89
- typoDescent: D,
90
- typoHeight: f,
88
+ typoAscent: f,
89
+ typoDescent: m,
90
+ typoHeight: d,
91
91
  lineHeight: g,
92
92
  glyphLeft: i,
93
93
  glyphRight: B,
94
- glyphAscent: u,
94
+ glyphAscent: e,
95
95
  glyphDescent: s,
96
96
  glyphWidth: i + B,
97
- glyphHeight: u + s,
98
- baseline: (g - f) / 2 + d,
97
+ glyphHeight: e + s,
98
+ baseline: (g - d) / 2 + f,
99
99
  centerX: o / 2
100
100
  };
101
101
  }
102
- function Y(r, t) {
103
- const n = document.createDocumentFragment(), o = document.createElement("div");
102
+ function U(F, t) {
103
+ const u = document.createDocumentFragment(), o = document.createElement("div");
104
104
  o.style.position = "absolute", o.style.visibility = "hidden", o.setAttribute("aria-hidden", "true"), o.style.fontFamily = t.fontFamily, o.style.fontSize = `${t.fontSize}px`, o.style.lineHeight = String(t.lineHeight), o.style.whiteSpace = "nowrap", o.style.writingMode = t.writingMode;
105
- const u = document.createElement("span");
106
- u.textContent = /\s/.test(r) ? "&nbsp;" : r, o.appendChild(u), n.appendChild(o), document.body.appendChild(n);
105
+ const e = document.createElement("span");
106
+ e.textContent = /\s/.test(F) ? "&nbsp;" : F, o.appendChild(e), u.appendChild(o), document.body.appendChild(u);
107
107
  const s = {
108
- leading: u.offsetHeight - t.fontSize
108
+ leading: e.offsetHeight - t.fontSize
109
109
  };
110
110
  return document.body.removeChild(o), s;
111
111
  }
112
- const N = /[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\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F0}-\u{FFF8}\u{FFFC}-\u{FFFD}\u{10980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\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{2CEB0}-\u{2EBE0}\u{2EBE1}-\u{2F7FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u, R = /[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u, I = /[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u, K = /[\r\n]/;
113
- class W {
114
- constructor(t, n) {
115
- this.content = t, this.parent = n, this.contentBox = new E(), this.glyphBox = new E(), this.baseline = 0, this.verticalOrientation = "U", this.isPunctuation = !1, this.isEOL = !1, this.update();
112
+ const Y = /[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\u{328A}-\u{32B0}\u{32B1}-\u{32BF}\u{32C0}-\u{32FE}\u{32FF}\u{3300}-\u{3357}\u{3358}-\u{337A}\u{337B}-\u{337F}\u{3380}-\u{33FF}\u{3400}-\u{4DBF}\u{4DC0}-\u{4DFF}\u{4E00}-\u{9FFF}\u{A000}-\u{A014}\u{A015}\u{A016}-\u{A48C}\u{A48D}-\u{A48F}\u{A490}-\u{A4C6}\u{A4C7}-\u{A4CF}\u{A960}-\u{A97C}\u{A97D}-\u{A97F}\u{AC00}-\u{D7A3}\u{D7A4}-\u{D7AF}\u{D7B0}-\u{D7C6}\u{D7C7}-\u{D7CA}\u{D7CB}-\u{D7FB}\u{D7FC}-\u{D7FF}\u{E000}-\u{F8FF}\u{F900}-\u{FA6D}\u{FA6E}-\u{FA6F}\u{FA70}-\u{FAD9}\u{FADA}-\u{FAFF}\u{FE10}-\u{FE16}\u{FE17}\u{FE18}\u{FE19}\u{FE1A}-\u{FE1F}\u{FE30}\u{FE31}-\u{FE32}\u{FE33}-\u{FE34}\u{FE35}\u{FE36}\u{FE37}\u{FE38}\u{FE39}\u{FE3A}\u{FE3B}\u{FE3C}\u{FE3D}\u{FE3E}\u{FE3F}\u{FE40}\u{FE41}\u{FE42}\u{FE43}\u{FE44}\u{FE45}-\u{FE46}\u{FE47}\u{FE48}\u{FE50}-\u{FE52}\u{FE53}\u{FE54}-\u{FE57}\u{FE5F}-\u{FE61}\u{FE62}\u{FE67}\u{FE68}\u{FE69}\u{FE6A}-\u{FE6B}\u{FE6C}-\u{FE6F}\u{FF01}\u{FF02}-\u{FF03}\u{FF04}\u{FF05}-\u{FF07}\u{FF0A}\u{FF0B}\u{FF0C}\u{FF0E}\u{FF0F}\u{FF10}-\u{FF19}\u{FF1F}\u{FF20}\u{FF21}-\u{FF3A}\u{FF3C}\u{FF3E}\u{FF40}\u{FF41}-\u{FF5A}\u{FFE0}-\u{FFE1}\u{FFE2}\u{FFE4}\u{FFE5}-\u{FFE6}\u{FFE7}\u{FFF0}-\u{FFF8}\u{FFFC}-\u{FFFD}\u{10980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\u{1B2FC}-\u{1B2FF}\u{1CF00}-\u{1CF2D}\u{1CF2E}-\u{1CF2F}\u{1CF30}-\u{1CF46}\u{1CF47}-\u{1CF4F}\u{1CF50}-\u{1CFC3}\u{1CFC4}-\u{1CFCF}\u{1D000}-\u{1D0F5}\u{1D0F6}-\u{1D0FF}\u{1D100}-\u{1D126}\u{1D127}-\u{1D128}\u{1D129}-\u{1D164}\u{1D165}-\u{1D166}\u{1D167}-\u{1D169}\u{1D16A}-\u{1D16C}\u{1D16D}-\u{1D172}\u{1D173}-\u{1D17A}\u{1D17B}-\u{1D182}\u{1D183}-\u{1D184}\u{1D185}-\u{1D18B}\u{1D18C}-\u{1D1A9}\u{1D1AA}-\u{1D1AD}\u{1D1AE}-\u{1D1EA}\u{1D1EB}-\u{1D1FF}\u{1D2E0}-\u{1D2F3}\u{1D2F4}-\u{1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}\u{1F7F0}\u{1F7F1}-\u{1F7FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA53}\u{1FA54}-\u{1FA5F}\u{1FA60}-\u{1FA6D}\u{1FA6E}-\u{1FA6F}\u{1FA70}-\u{1FA74}\u{1FA75}-\u{1FA77}\u{1FA78}-\u{1FA7C}\u{1FA7D}-\u{1FA7F}\u{1FA80}-\u{1FA86}\u{1FA87}-\u{1FA8F}\u{1FA90}-\u{1FAAC}\u{1FAAD}-\u{1FAAF}\u{1FAB0}-\u{1FABA}\u{1FABB}-\u{1FABF}\u{1FAC0}-\u{1FAC5}\u{1FAC6}-\u{1FACF}\u{1FAD0}-\u{1FAD9}\u{1FADA}-\u{1FADF}\u{1FAE0}-\u{1FAE7}\u{1FAE8}-\u{1FAEF}\u{1FAF0}-\u{1FAF6}\u{1FAF7}-\u{1FAFF}\u{20000}-\u{2A6DF}\u{2A6E0}-\u{2A6FF}\u{2A700}-\u{2B738}\u{2B739}-\u{2B73F}\u{2B740}-\u{2B81D}\u{2B81E}-\u{2B81F}\u{2B820}-\u{2CEA1}\u{2CEA2}-\u{2CEAF}\u{2CEB0}-\u{2EBE0}\u{2EBE1}-\u{2F7FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u, W = /[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u, N = /[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u, I = /[\r\n]/;
113
+ class H {
114
+ constructor(t, u) {
115
+ this.content = t, this.parent = u, this.contentBox = new E(), this.glyphBox = new E(), this.baseline = 0, this.verticalOrientation = "U", this.isPunctuation = !1, this.isEOL = !1, this.update();
116
116
  }
117
117
  get computedStyle() {
118
118
  return this.parent.computedStyle;
@@ -128,98 +128,107 @@ class W {
128
128
  break;
129
129
  case "mixed":
130
130
  default:
131
- this.verticalOrientation = N.test(this.content) ? R.test(this.content) ? "Tu" : "U" : R.test(this.content) ? "Tr" : "R";
131
+ this.verticalOrientation = Y.test(this.content) ? W.test(this.content) ? "Tu" : "U" : W.test(this.content) ? "Tr" : "R";
132
132
  break;
133
133
  }
134
- return this.isPunctuation = I.test(this.content), this.isEOL = K.test(this.content), this;
134
+ return this.isPunctuation = N.test(this.content), this.isEOL = I.test(this.content), this;
135
135
  }
136
136
  measure() {
137
137
  const t = this.computedStyle, {
138
- width: n,
138
+ width: u,
139
139
  height: o,
140
- glyphAscent: u,
140
+ glyphAscent: e,
141
141
  glyphLeft: s,
142
142
  glyphWidth: i,
143
143
  glyphHeight: B,
144
- lineHeight: d,
145
- baseline: D,
144
+ lineHeight: f,
145
+ baseline: m,
146
146
  centerX: g
147
- } = $(this.content, {
147
+ } = P(this.content, {
148
148
  ...t,
149
149
  letterSpacing: 0
150
150
  });
151
- switch (this.contentBox.width = n, this.contentBox.height = o, this.glyphBox.width = i, this.glyphBox.height = B, this.baseline = D, t.writingMode) {
151
+ switch (this.contentBox.width = u, this.contentBox.height = o, this.glyphBox.width = i, this.glyphBox.height = B, this.baseline = m, t.writingMode) {
152
152
  case "vertical-lr":
153
153
  case "vertical-rl": {
154
- const f = t.fontSize * t.lineHeight;
154
+ const d = t.fontSize * t.lineHeight;
155
155
  switch (this.verticalOrientation) {
156
156
  case "Tr":
157
157
  case "R":
158
- this.contentBox.rotate90deg(), this.glyphBox.rotate90deg(), this.contentBox.x = (f - o) / 2, this.glyphBox.x = (f - B) / 2;
158
+ this.contentBox.rotate90deg(), this.glyphBox.rotate90deg(), this.contentBox.x = (d - o) / 2, this.glyphBox.x = (d - B) / 2;
159
159
  break;
160
160
  case "U": {
161
- const { leading: h } = Y(this.content, {
161
+ const { leading: r } = U(this.content, {
162
162
  ...t,
163
163
  letterSpacing: 0
164
164
  });
165
- this.contentBox.x = (f - n) / 2, this.contentBox.y = h, this.glyphBox.x = (f - i) / 2, this.glyphBox.y = 0;
165
+ this.contentBox.x = (d - u) / 2, this.contentBox.y = r, this.glyphBox.x = (d - i) / 2, this.glyphBox.y = 0;
166
166
  break;
167
167
  }
168
168
  case "Tu":
169
- this.contentBox.x = (f - n) / 2, this.contentBox.y = 0, this.glyphBox.x = this.contentBox.x + g - s, this.glyphBox.y = o - B;
169
+ this.contentBox.x = (d - u) / 2, this.contentBox.y = 0, this.glyphBox.x = this.contentBox.x + g - s, this.glyphBox.y = o - B;
170
170
  break;
171
171
  }
172
+ this.contentBox.height += t.letterSpacing;
172
173
  break;
173
174
  }
174
175
  case "horizontal-tb":
175
- this.contentBox.x = 0, this.contentBox.y = (d - o) / 2, this.glyphBox.x = g - s, this.glyphBox.y = D - u;
176
+ this.contentBox.x = 0, this.contentBox.y = (f - o) / 2, this.contentBox.width += t.letterSpacing, this.glyphBox.x = g - s, this.glyphBox.y = m - e;
176
177
  break;
177
178
  }
178
179
  return this;
179
180
  }
180
181
  clone() {
181
- const t = new W(this.content, this.parent);
182
+ const t = new H(this.content, this.parent);
182
183
  return t.contentBox = this.contentBox.clone(), t.glyphBox = this.glyphBox.clone(), t;
183
184
  }
184
185
  }
186
+ function z(F) {
187
+ if (!F)
188
+ return F;
189
+ const t = {};
190
+ for (const u in F)
191
+ F[u] !== "" && F[u] !== void 0 && (t[u] = F[u]);
192
+ return t;
193
+ }
185
194
  class T {
186
- constructor(t, n, o) {
187
- this.content = t, this.style = n, this.parent = o, this.contentBox = new E(), this.inlineBox = new E(), this.glyphBox = new E(), this.centerX = 0, this.baseline = 0, this.update();
195
+ constructor(t, u, o) {
196
+ this.content = t, this.style = u, this.parent = o, this.contentBox = new E(), this.inlineBox = new E(), this.glyphBox = new E(), this.centerX = 0, this.baseline = 0, this.update();
188
197
  }
189
198
  update() {
190
199
  var o;
191
200
  this.computedStyle = {
192
201
  ...(o = this.parent) == null ? void 0 : o.computedStyle,
193
- ...this.style
202
+ ...z(this.style)
194
203
  };
195
204
  const t = this.computedStyle;
196
205
  this.computedContent = t.textTransform === "uppercase" ? this.content.toUpperCase() : t.textTransform === "lowercase" ? this.content.toLowerCase() : this.content;
197
- const n = [];
198
- for (const u of this.computedContent)
199
- n.push(new W(u, this));
200
- return this.characters = n, this;
206
+ const u = [];
207
+ for (const e of this.computedContent)
208
+ u.push(new H(e, this));
209
+ return this.characters = u, this;
201
210
  }
202
211
  measure() {
203
- var n;
212
+ var u;
204
213
  const t = this.computedStyle;
205
214
  switch (t.writingMode) {
206
215
  case "vertical-lr":
207
216
  case "vertical-rl": {
208
217
  let o = 0;
209
- const u = { left: 0, right: 0 }, s = { left: 0, right: 0 };
210
- this.characters.forEach((i, B) => {
211
- i.update().measure(), u.left = Math.min(u.left, i.contentBox.left), u.right = Math.max(u.right, i.contentBox.right), s.left = Math.min(s.left, i.glyphBox.left), s.right = Math.max(s.right, i.glyphBox.right), o += i.contentBox.y + i.contentBox.height, B !== this.characters.length - 1 && (o += t.letterSpacing);
212
- }), this.inlineBox.width = t.fontSize * t.lineHeight, this.inlineBox.height = o, this.contentBox.width = u.right - u.left, this.contentBox.height = o, this.glyphBox.width = s.right - s.left, this.glyphBox.height = o, this.baseline = ((n = this.characters[0]) == null ? void 0 : n.baseline) ?? 0, this.centerX = o / 2, this.contentBox.x = u.left, this.glyphBox.x = s.left;
218
+ const e = { left: 0, right: 0 }, s = { left: 0, right: 0 };
219
+ this.characters.forEach((i) => {
220
+ i.update().measure(), e.left = Math.min(e.left, i.contentBox.left), e.right = Math.max(e.right, i.contentBox.right), s.left = Math.min(s.left, i.glyphBox.left), s.right = Math.max(s.right, i.glyphBox.right), o += i.contentBox.y + i.contentBox.height;
221
+ }), this.inlineBox.width = t.fontSize * t.lineHeight, this.inlineBox.height = o, this.contentBox.width = e.right - e.left, this.contentBox.height = o, this.glyphBox.width = s.right - s.left, this.glyphBox.height = o, this.baseline = ((u = this.characters[0]) == null ? void 0 : u.baseline) ?? 0, this.centerX = o / 2, this.contentBox.x = e.left, this.glyphBox.x = s.left;
213
222
  break;
214
223
  }
215
224
  case "horizontal-tb": {
216
225
  let o = 0;
217
- const u = { top: 0, bottom: 0 }, s = { top: 0, bottom: 0 };
218
- this.characters.forEach((B, d) => {
219
- B.update().measure(), u.top = Math.min(u.top, B.contentBox.top), u.bottom = Math.max(u.bottom, B.contentBox.bottom), s.top = Math.min(s.top, B.glyphBox.top), s.bottom = Math.max(s.bottom, B.glyphBox.bottom), o += B.contentBox.x + B.contentBox.width, d !== this.characters.length - 1 && (o += t.letterSpacing);
220
- }), this.inlineBox.width = o, this.inlineBox.height = t.fontSize * t.lineHeight, this.contentBox.width = o, this.contentBox.height = u.bottom - u.top, this.glyphBox.width = o, this.glyphBox.height = s.bottom - s.top, this.centerX = o / 2, this.inlineBox.x = 0, this.inlineBox.y = 0;
226
+ const e = { top: 0, bottom: 0 }, s = { top: 0, bottom: 0 };
227
+ this.characters.forEach((B) => {
228
+ B.update().measure(), e.top = Math.min(e.top, B.contentBox.top), e.bottom = Math.max(e.bottom, B.contentBox.bottom), s.top = Math.min(s.top, B.glyphBox.top), s.bottom = Math.max(s.bottom, B.glyphBox.bottom), o += B.contentBox.x + B.contentBox.width;
229
+ }), this.inlineBox.width = o, this.inlineBox.height = t.fontSize * t.lineHeight, this.contentBox.width = o, this.contentBox.height = e.bottom - e.top, this.glyphBox.width = o, this.glyphBox.height = s.bottom - s.top, this.centerX = o / 2, this.inlineBox.x = 0, this.inlineBox.y = 0;
221
230
  const i = this.characters[0];
222
- i && (this.baseline = i.baseline, this.contentBox.x = i.contentBox.x, this.glyphBox.x = i.glyphBox.x), this.contentBox.y = u.top, this.glyphBox.y = s.top;
231
+ i && (this.baseline = i.baseline, this.contentBox.x = i.contentBox.x, this.glyphBox.x = i.glyphBox.x), this.contentBox.y = e.top, this.glyphBox.y = s.top;
223
232
  break;
224
233
  }
225
234
  }
@@ -234,102 +243,102 @@ class T {
234
243
  }
235
244
  }
236
245
  class v {
237
- constructor(t, n) {
238
- this.style = t, this.parent = n, this.contentBox = new E(), this.lineBox = new E(), this.glyphBox = new E(), this.baseline = 0, this.xHeight = 0, this.fragments = [], this.update();
246
+ constructor(t, u) {
247
+ this.style = t, this.parent = u, this.contentBox = new E(), this.lineBox = new E(), this.glyphBox = new E(), this.baseline = 0, this.xHeight = 0, this.fragments = [], this.update();
239
248
  }
240
249
  update() {
241
250
  this.computedStyle = {
242
- ...this.parent,
243
- ...this.style
251
+ ...z(this.parent),
252
+ ...z(this.style)
244
253
  };
245
254
  }
246
- addFragment(t, n) {
247
- return this.fragments.push(new T(t, n, this)), this;
255
+ addFragment(t, u) {
256
+ return this.fragments.push(new T(t, u, this)), this;
248
257
  }
249
258
  clone(t) {
250
- const n = new v(this.style, this.parent);
251
- return n.contentBox = this.contentBox.clone(), n.lineBox = this.lineBox.clone(), n.glyphBox = this.glyphBox.clone(), n.baseline = this.baseline, n.xHeight = this.xHeight, n.fragments = t ?? this.fragments.map((o) => o.clone()), n;
259
+ const u = new v(this.style, this.parent);
260
+ return u.contentBox = this.contentBox.clone(), u.lineBox = this.lineBox.clone(), u.glyphBox = this.glyphBox.clone(), u.baseline = this.baseline, u.xHeight = this.xHeight, u.fragments = t ?? this.fragments.map((o) => o.clone()), u;
252
261
  }
253
262
  }
254
- function _(r, t) {
255
- const n = [];
256
- if (typeof r == "string")
257
- n.push(new v(void 0, t).addFragment(r));
263
+ function K(F, t) {
264
+ const u = [];
265
+ if (typeof F == "string")
266
+ u.push(new v(void 0, t).addFragment(F));
258
267
  else {
259
- r = Array.isArray(r) ? r : [r];
260
- for (const o of r)
268
+ F = Array.isArray(F) ? F : [F];
269
+ for (const o of F)
261
270
  if (typeof o == "string")
262
- n.push(new v(void 0, t).addFragment(o));
271
+ u.push(new v(void 0, t).addFragment(o));
263
272
  else if (Array.isArray(o)) {
264
- const u = new v(void 0, t);
273
+ const e = new v(void 0, t);
265
274
  o.forEach((s) => {
266
275
  if (typeof s == "string")
267
- u.addFragment(s);
276
+ e.addFragment(s);
268
277
  else {
269
278
  const { content: i, ...B } = s;
270
- u.addFragment(i, B);
279
+ e.addFragment(i, B);
271
280
  }
272
- }), n.push(u);
281
+ }), u.push(e);
273
282
  } else if ("fragments" in o) {
274
- const { fragments: u, ...s } = o, i = new v(s, t);
275
- u.forEach((B) => {
276
- const { content: d, ...D } = B;
277
- i.addFragment(d, D);
278
- }), n.push(i);
283
+ const { fragments: e, ...s } = o, i = new v(s, t);
284
+ e.forEach((B) => {
285
+ const { content: f, ...m } = B;
286
+ i.addFragment(f, m);
287
+ }), u.push(i);
279
288
  } else if ("content" in o) {
280
- const { content: u, ...s } = o;
281
- n.push(new v(s, t).addFragment(u));
289
+ const { content: e, ...s } = o;
290
+ u.push(new v(s, t).addFragment(e));
282
291
  }
283
292
  }
284
- return n;
293
+ return u;
285
294
  }
286
- function G(r, t, n) {
295
+ function _(F, t, u) {
287
296
  var B;
288
- const o = [], u = r.slice();
297
+ const o = [], e = F.slice();
289
298
  let s, i;
290
- for (; s = u.shift(); ) {
291
- const d = s.fragments.slice();
292
- let D = 0;
299
+ for (; s = e.shift(); ) {
300
+ const f = s.fragments.slice();
301
+ let m = 0;
293
302
  const g = [];
294
- for (; i = d.shift(); ) {
295
- const f = i.computedStyle;
296
- let h = "", S = !1, k = 0;
297
- const e = new T("", i.style, i.parent);
303
+ for (; i = f.shift(); ) {
304
+ const d = i.computedStyle;
305
+ let r = "", w = !1, S = 0;
306
+ const n = new T("", i.style, i.parent);
298
307
  for (const A of i.characters) {
299
- if (e.content += A.content, (B = i.characters[++k]) != null && B.isPunctuation)
308
+ if (n.content += A.content, (B = i.characters[++S]) != null && B.isPunctuation)
300
309
  continue;
301
- let y, m;
302
- switch (f.writingMode) {
310
+ let C, y;
311
+ switch (d.writingMode) {
303
312
  case "vertical-lr":
304
313
  case "vertical-rl":
305
- y = n, m = e.update().measure().contentBox.height;
314
+ C = u, y = n.update().measure().contentBox.height;
306
315
  break;
307
316
  case "horizontal-tb":
308
317
  default:
309
- y = t, m = e.update().measure().contentBox.width;
318
+ C = t, y = n.update().measure().contentBox.width;
310
319
  break;
311
320
  }
312
- if (m += f.letterSpacing, A.isEOL || y && D + m > y) {
313
- let a = A.isEOL ? h.length + 1 : h.length;
314
- !D && !a && (h += e.computedContent, a += e.computedContent.length), h.length && g.push(i.clone(h)), g.length && (o.push(s.clone(g.slice())), g.length = 0);
321
+ if (A.isEOL || C && m + y > C) {
322
+ let a = A.isEOL ? r.length + 1 : r.length;
323
+ !m && !a && (r += n.computedContent, a += n.computedContent.length), r.length && g.push(i.clone(r)), g.length && (o.push(s.clone(g.slice())), g.length = 0);
315
324
  const l = i.computedContent.substring(a);
316
- (l.length || d.length) && u.unshift(
325
+ (l.length || f.length) && e.unshift(
317
326
  s.clone(
318
- (l.length ? [i.clone(l)] : []).concat(d.slice())
327
+ (l.length ? [i.clone(l)] : []).concat(f.slice())
319
328
  )
320
- ), d.length = 0, S = !0;
329
+ ), f.length = 0, w = !0;
321
330
  break;
322
331
  } else
323
- D += m;
324
- h += e.computedContent, e.content = "";
332
+ m += y;
333
+ r += n.computedContent, n.content = "";
325
334
  }
326
- S || g.push(i.clone());
335
+ w || g.push(i.clone());
327
336
  }
328
337
  g.length && o.push(s.clone(g));
329
338
  }
330
339
  return o;
331
340
  }
332
- const j = {
341
+ const G = {
333
342
  width: 0,
334
343
  height: 0,
335
344
  color: "#000",
@@ -355,89 +364,88 @@ const j = {
355
364
  writingMode: "horizontal-tb",
356
365
  textOrientation: "mixed"
357
366
  };
358
- function V(r) {
367
+ function j(F) {
359
368
  return {
360
- ...j,
361
- ...r
369
+ ...G,
370
+ ...F
362
371
  };
363
372
  }
364
- function q(r) {
365
- const { content: t, effects: n = [{}] } = r, { width: o, height: u, ...s } = V(r.style);
366
- let i = _(t, s);
367
- i = G(i, o, u);
368
- let B = 0, d = 0;
369
- i.forEach((e) => {
373
+ function V(F) {
374
+ const { content: t, effects: u = [{}] } = F, { width: o, height: e, ...s } = j(F.style);
375
+ let i = K(t, s);
376
+ i = _(i, o, e);
377
+ let B = 0, f = 0;
378
+ i.forEach((n) => {
370
379
  let A = null;
371
- e.fragments.forEach((F) => {
372
- F.update().measure(), (!A || A.contentBox.height < F.contentBox.height) && (A = F);
380
+ n.fragments.forEach((h) => {
381
+ h.update().measure(), (!A || A.contentBox.height < h.contentBox.height) && (A = h);
373
382
  });
374
383
  const {
375
- glyphHeight: y,
376
- baseline: m
377
- } = $("x", (A ?? e).computedStyle);
378
- e.xHeight = y, e.baseline = m;
379
- const a = e.computedStyle;
380
- let l = B, c = d, x = 0;
381
- e.fragments.forEach((F, p) => {
382
- const C = F.computedStyle;
384
+ glyphHeight: C,
385
+ baseline: y
386
+ } = P("x", (A ?? n).computedStyle);
387
+ n.xHeight = C, n.baseline = y;
388
+ const a = n.computedStyle;
389
+ let l = B, c = f, x = 0;
390
+ n.fragments.forEach((h, p) => {
383
391
  switch (a.writingMode) {
384
392
  case "vertical-rl":
385
393
  case "vertical-lr": {
386
- p || (c = 0), F.inlineBox.translate(l, c), F.contentBox.translate(l, c), F.glyphBox.translate(l, c);
387
- let b = c;
388
- F.characters.forEach((w, O) => {
389
- const z = w.contentBox.y + w.contentBox.height;
390
- w.contentBox.translate(l, b), w.glyphBox.translate(l, b), b += z, O !== F.characters.length - 1 && (b += C.letterSpacing);
391
- }), c += F.inlineBox.height, p === e.fragments.length - 1 && (l += F.inlineBox.width);
394
+ p || (c = 0), h.inlineBox.translate(l, c), h.contentBox.translate(l, c), h.glyphBox.translate(l, c);
395
+ let D = c;
396
+ h.characters.forEach((b) => {
397
+ const k = b.contentBox.y + b.contentBox.height;
398
+ b.contentBox.translate(l, D), b.glyphBox.translate(l, D), D += k;
399
+ }), c += h.inlineBox.height, p === n.fragments.length - 1 && (l += h.inlineBox.width);
392
400
  break;
393
401
  }
394
402
  case "horizontal-tb": {
395
- p || (l = 0), F.inlineBox.translate(l, c), F.contentBox.translate(l, c), F.glyphBox.translate(l, c);
396
- let b = l;
397
- F.characters.forEach((w, O) => {
398
- const z = w.contentBox.x + w.contentBox.width;
399
- w.contentBox.translate(b, c), w.glyphBox.translate(b, c), b += z, O !== F.characters.length - 1 && (b += C.letterSpacing);
400
- }), l += F.inlineBox.width, x = Math.max(x, F.inlineBox.height), p === e.fragments.length - 1 && (c += x);
403
+ p || (l = 0), h.inlineBox.translate(l, c), h.contentBox.translate(l, c), h.glyphBox.translate(l, c);
404
+ let D = l;
405
+ h.characters.forEach((b) => {
406
+ const k = b.contentBox.x + b.contentBox.width;
407
+ b.contentBox.translate(D, c), b.glyphBox.translate(D, c), D += k;
408
+ }), l += h.inlineBox.width, x = Math.max(x, h.inlineBox.height), p === n.fragments.length - 1 && (c += x);
401
409
  break;
402
410
  }
403
411
  }
404
- }), B = l, d = c, e.lineBox = E.from(...e.fragments.map((F) => F.inlineBox));
412
+ }), B = l, f = c, n.lineBox = E.from(...n.fragments.map((h) => h.inlineBox));
405
413
  });
406
- const D = E.from(
407
- ...i.map((e) => e.lineBox),
408
- new E(0, 0, o, u)
409
- ), { width: g, height: f } = D;
410
- i.forEach((e) => {
414
+ const m = E.from(
415
+ ...i.map((n) => n.lineBox),
416
+ new E(0, 0, o, e)
417
+ ), { width: g, height: d } = m;
418
+ i.forEach((n) => {
411
419
  let A = 0;
412
- const y = 0, m = e.computedStyle;
413
- switch (m.writingMode) {
420
+ const C = 0, y = n.computedStyle;
421
+ switch (y.writingMode) {
414
422
  case "vertical-rl":
415
- A += g - (e.lineBox.x * 2 + e.lineBox.width);
423
+ A += g - (n.lineBox.x * 2 + n.lineBox.width);
416
424
  case "vertical-lr":
417
- e.lineBox.height = Math.max(e.lineBox.height, f);
425
+ n.lineBox.height = Math.max(n.lineBox.height, d);
418
426
  break;
419
427
  case "horizontal-tb":
420
- e.lineBox.width = Math.max(e.lineBox.width, g);
428
+ n.lineBox.width = Math.max(n.lineBox.width, g);
421
429
  break;
422
430
  }
423
- e.contentBox = E.from(...e.fragments.map((a) => a.contentBox)), e.glyphBox = E.from(...e.fragments.map((a) => a.glyphBox)), e.fragments.forEach((a) => {
424
- let l = A, c = y;
431
+ n.contentBox = E.from(...n.fragments.map((a) => a.contentBox)), n.glyphBox = E.from(...n.fragments.map((a) => a.glyphBox)), n.fragments.forEach((a) => {
432
+ let l = A, c = C;
425
433
  const x = a.computedStyle;
426
- switch (m.writingMode) {
434
+ switch (y.writingMode) {
427
435
  case "vertical-rl":
428
436
  case "vertical-lr": {
429
437
  switch (x.textAlign) {
430
438
  case "end":
431
439
  case "right":
432
- c += f - e.contentBox.height;
440
+ c += d - n.contentBox.height;
433
441
  break;
434
442
  case "center":
435
- c += (f - e.contentBox.height) / 2;
443
+ c += (d - n.contentBox.height) / 2;
436
444
  break;
437
445
  }
438
- a.characters.forEach((F) => {
446
+ a.characters.forEach((h) => {
439
447
  let p = l;
440
- const C = c;
448
+ const D = c;
441
449
  switch (x.verticalAlign) {
442
450
  case "top":
443
451
  case "middle":
@@ -448,10 +456,10 @@ function q(r) {
448
456
  case "text-bottom":
449
457
  case "baseline":
450
458
  default:
451
- p += e.baseline - F.baseline;
459
+ p += n.baseline - h.baseline;
452
460
  break;
453
461
  }
454
- F.contentBox.translate(p, C), F.glyphBox.translate(p, C);
462
+ h.contentBox.translate(p, D), h.glyphBox.translate(p, D);
455
463
  });
456
464
  break;
457
465
  }
@@ -459,168 +467,168 @@ function q(r) {
459
467
  switch (x.textAlign) {
460
468
  case "end":
461
469
  case "right":
462
- l = g - e.contentBox.width;
470
+ l = g - n.contentBox.width;
463
471
  break;
464
472
  case "center":
465
- l = (g - e.contentBox.width) / 2;
473
+ l = (g - n.contentBox.width) / 2;
466
474
  break;
467
475
  }
468
476
  switch (x.verticalAlign) {
469
477
  case "top":
470
- c = e.lineBox.y - a.inlineBox.y;
478
+ c = n.lineBox.y - a.inlineBox.y;
471
479
  break;
472
480
  case "middle":
473
- c = a.inlineBox.y - (e.baseline - e.xHeight / 2 - a.inlineBox.height / 2);
481
+ c = a.inlineBox.y - (n.baseline - n.xHeight / 2 - a.inlineBox.height / 2);
474
482
  break;
475
483
  case "bottom":
476
- c = e.lineBox.bottom - a.inlineBox.bottom;
484
+ c = n.lineBox.bottom - a.inlineBox.bottom;
477
485
  break;
478
486
  case "sub":
479
- c = e.lineBox.y + e.baseline - a.glyphBox.bottom;
487
+ c = n.lineBox.y + n.baseline - a.glyphBox.bottom;
480
488
  break;
481
489
  case "super":
482
- c = e.lineBox.y + e.baseline - a.glyphBox.y;
490
+ c = n.lineBox.y + n.baseline - a.glyphBox.y;
483
491
  break;
484
492
  case "text-top":
485
- c = e.glyphBox.y - a.inlineBox.y;
493
+ c = n.glyphBox.y - a.inlineBox.y;
486
494
  break;
487
495
  case "text-bottom":
488
- c = e.glyphBox.bottom - a.inlineBox.bottom;
496
+ c = n.glyphBox.bottom - a.inlineBox.bottom;
489
497
  break;
490
498
  case "baseline":
491
499
  default:
492
- a.inlineBox.height < e.lineBox.height && (c = e.baseline - a.baseline);
500
+ a.inlineBox.height < n.lineBox.height && (c = n.baseline - a.baseline);
493
501
  break;
494
502
  }
495
- a.characters.forEach((F) => {
496
- F.contentBox.translate(l, c), F.glyphBox.translate(l, c);
503
+ a.characters.forEach((h) => {
504
+ h.contentBox.translate(l, c), h.glyphBox.translate(l, c);
497
505
  });
498
506
  break;
499
507
  }
500
508
  }
501
509
  a.inlineBox.translate(l, c), a.contentBox.translate(l, c), a.glyphBox.translate(l, c);
502
- }), e.lineBox = E.from(e.lineBox, ...e.fragments.map((a) => a.inlineBox)), e.contentBox = E.from(...e.fragments.map((a) => a.contentBox)), e.glyphBox = E.from(...e.fragments.map((a) => a.glyphBox));
510
+ }), n.lineBox = E.from(n.lineBox, ...n.fragments.map((a) => a.inlineBox)), n.contentBox = E.from(...n.fragments.map((a) => a.contentBox)), n.glyphBox = E.from(...n.fragments.map((a) => a.glyphBox));
503
511
  });
504
- const h = E.from(...i.map((e) => e.contentBox)), S = E.from(...i.map((e) => e.glyphBox)), k = [];
505
- return i.forEach((e) => {
506
- e.fragments.forEach((A) => {
507
- const y = A.computedStyle;
508
- n.forEach((m) => {
509
- const a = { ...y, ...m }, { textStrokeWidth: l = 0, offsetX: c = 0, offsetY: x = 0 } = a;
512
+ const r = E.from(...i.map((n) => n.contentBox)), w = E.from(...i.map((n) => n.glyphBox)), S = [];
513
+ return i.forEach((n) => {
514
+ n.fragments.forEach((A) => {
515
+ const C = A.computedStyle;
516
+ u.forEach((y) => {
517
+ const a = { ...C, ...y }, { textStrokeWidth: l = 0, offsetX: c = 0, offsetY: x = 0 } = a;
510
518
  if (l || c || x) {
511
- const { x: F, y: p, width: C, height: b } = A.contentBox;
512
- k.push(new E(
513
- Math.min(F, F + c - l / 2),
519
+ const { x: h, y: p, width: D, height: b } = A.contentBox;
520
+ S.push(new E(
521
+ Math.min(h, h + c - l / 2),
514
522
  Math.min(p, p + x - l / 2),
515
- Math.max(C, C + c + l),
523
+ Math.max(D, D + c + l),
516
524
  Math.max(b, b + x + l)
517
525
  ));
518
526
  }
519
527
  });
520
528
  });
521
529
  }), {
522
- box: D,
523
- contentBox: h,
524
- glyphBox: S,
530
+ box: m,
531
+ contentBox: r,
532
+ glyphBox: w,
525
533
  paragraphs: i,
526
- viewBox: E.from(D, S, ...k)
534
+ viewBox: E.from(m, w, ...S)
527
535
  };
528
536
  }
529
- function H(r, t, n) {
537
+ function O(F, t, u) {
530
538
  if (typeof t == "string" && t.startsWith("linear-gradient")) {
531
- const { x0: o, y0: u, x1: s, y1: i, stops: B } = J(t, n.left, n.top, n.width, n.height), d = r.createLinearGradient(o, u, s, i);
532
- return B.forEach((D) => d.addColorStop(D.offset, D.color)), d;
539
+ const { x0: o, y0: e, x1: s, y1: i, stops: B } = q(t, u.left, u.top, u.width, u.height), f = F.createLinearGradient(o, e, s, i);
540
+ return B.forEach((m) => f.addColorStop(m.offset, m.color)), f;
533
541
  }
534
542
  return t;
535
543
  }
536
- function J(r, t, n, o, u) {
537
- var S;
538
- const s = ((S = r.match(/linear-gradient\((.+)\)$/)) == null ? void 0 : S[1]) ?? "", i = s.split(",")[0], B = i.includes("deg") ? i : "0deg", d = s.replace(B, "").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi), g = (Number(B.replace("deg", "")) || 0) * Math.PI / 180, f = o * Math.sin(g), h = u * Math.cos(g);
544
+ function q(F, t, u, o, e) {
545
+ var w;
546
+ const s = ((w = F.match(/linear-gradient\((.+)\)$/)) == null ? void 0 : w[1]) ?? "", i = s.split(",")[0], B = i.includes("deg") ? i : "0deg", f = s.replace(B, "").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi), g = (Number(B.replace("deg", "")) || 0) * Math.PI / 180, d = o * Math.sin(g), r = e * Math.cos(g);
539
547
  return {
540
- x0: t + o / 2 - f,
541
- y0: n + u / 2 + h,
542
- x1: t + o / 2 + f,
543
- y1: n + u / 2 - h,
544
- stops: Array.from(d).map((k) => {
545
- let e = k[2];
546
- return e.startsWith("(") ? e = e.split(",").length > 3 ? `rgba${e}` : `rgb${e}` : e = `#${e}`, {
547
- offset: Number(k[3].replace("%", "")) / 100,
548
- color: e
548
+ x0: t + o / 2 - d,
549
+ y0: u + e / 2 + r,
550
+ x1: t + o / 2 + d,
551
+ y1: u + e / 2 - r,
552
+ stops: Array.from(f).map((S) => {
553
+ let n = S[2];
554
+ return n.startsWith("(") ? n = n.split(",").length > 3 ? `rgba${n}` : `rgb${n}` : n = `#${n}`, {
555
+ offset: Number(S[3].replace("%", "")) / 100,
556
+ color: n
549
557
  };
550
558
  })
551
559
  };
552
560
  }
553
- function M(r, t, n) {
554
- n != null && n.color && (n.color = H(r, n.color, t)), n != null && n.backgroundColor && (n.backgroundColor = H(r, n.backgroundColor, t)), n != null && n.textStrokeColor && (n.textStrokeColor = H(r, n.textStrokeColor, t));
561
+ function M(F, t, u) {
562
+ u != null && u.color && (u.color = O(F, u.color, t)), u != null && u.backgroundColor && (u.backgroundColor = O(F, u.backgroundColor, t)), u != null && u.textStrokeColor && (u.textStrokeColor = O(F, u.textStrokeColor, t));
555
563
  }
556
- function Q(r) {
564
+ function J(F) {
557
565
  const {
558
566
  view: t = document.createElement("canvas"),
559
- style: n,
567
+ style: u,
560
568
  effects: o = [],
561
- pixelRatio: u = 1
562
- } = r, s = o.length > 0 ? o : [{}], { viewBox: i, paragraphs: B } = q(r), { x: d, y: D, width: g, height: f } = i, h = t.getContext("2d");
563
- t.style.width = `${g}px`, t.style.height = `${f}px`, t.dataset.viewbox = `${d} ${D} ${g} ${f}`, t.dataset.pixelRatio = String(u), t.width = Math.max(1, Math.floor(g * u)), t.height = Math.max(1, Math.floor(f * u)), h.scale(u, u);
564
- const S = (e, A, y, m, a) => {
565
- h.fillStyle = e, h.fillRect(-i.x + A, -i.y + y, m, a);
566
- }, k = { ...n };
567
- return M(h, new E(0, 0, g, f), k), B.forEach((e) => {
568
- M(h, e.contentBox, e.computedStyle), e.fragments.forEach((A) => {
569
- M(h, A.contentBox, A.computedStyle);
569
+ pixelRatio: e = 1
570
+ } = F, s = o.length > 0 ? o : [{}], { viewBox: i, paragraphs: B } = V(F), { x: f, y: m, width: g, height: d } = i, r = t.getContext("2d");
571
+ t.style.width = `${g}px`, t.style.height = `${d}px`, t.dataset.viewbox = `${f} ${m} ${g} ${d}`, t.dataset.pixelRatio = String(e), t.width = Math.max(1, Math.floor(g * e)), t.height = Math.max(1, Math.floor(d * e)), r.scale(e, e);
572
+ const w = (n, A, C, y, a) => {
573
+ r.fillStyle = n, r.fillRect(-i.x + A, -i.y + C, y, a);
574
+ }, S = { ...u };
575
+ return M(r, new E(0, 0, g, d), S), B.forEach((n) => {
576
+ M(r, n.contentBox, n.computedStyle), n.fragments.forEach((A) => {
577
+ M(r, A.contentBox, A.computedStyle);
570
578
  });
571
- }), s.forEach((e) => {
572
- const A = { ...e };
573
- M(h, new E(0, 0, g, f), A);
574
- const y = { ...k, ...A };
575
- y != null && y.backgroundColor && S(y.backgroundColor, 0, 0, t.width, t.height), B.forEach((m) => {
579
+ }), s.forEach((n) => {
580
+ const A = { ...n };
581
+ M(r, new E(0, 0, g, d), A);
582
+ const C = { ...S, ...A };
583
+ C != null && C.backgroundColor && w(C.backgroundColor, 0, 0, t.width, t.height), B.forEach((y) => {
576
584
  var a;
577
- (a = m.style) != null && a.backgroundColor && S(m.computedStyle.backgroundColor, ...m.lineBox.toArray()), m.fragments.forEach((l) => {
585
+ (a = y.style) != null && a.backgroundColor && w(y.computedStyle.backgroundColor, ...y.lineBox.toArray()), y.fragments.forEach((l) => {
578
586
  var c;
579
- (c = l.style) != null && c.backgroundColor && S(l.computedStyle.backgroundColor, ...l.inlineBox.toArray());
587
+ (c = l.style) != null && c.backgroundColor && w(l.computedStyle.backgroundColor, ...l.inlineBox.toArray());
580
588
  });
581
- }), B.forEach((m) => {
582
- m.fragments.forEach((a) => {
589
+ }), B.forEach((y) => {
590
+ y.fragments.forEach((a) => {
583
591
  const l = -i.x + (A.offsetX ?? 0), c = -i.y + (A.offsetY ?? 0), x = { ...a.computedStyle, ...A };
584
- switch (P(h, {
592
+ switch (R(r, {
585
593
  ...x,
586
- fontSize: x.fontSize * u,
587
- letterSpacing: x.letterSpacing * u,
588
- textStrokeWidth: x.textStrokeWidth * u,
589
- shadowOffsetX: x.shadowOffsetX * u,
590
- shadowOffsetY: x.shadowOffsetY * u,
591
- shadowBlur: x.shadowBlur * u,
594
+ fontSize: x.fontSize * e,
595
+ letterSpacing: x.letterSpacing * e,
596
+ textStrokeWidth: x.textStrokeWidth * e,
597
+ shadowOffsetX: x.shadowOffsetX * e,
598
+ shadowOffsetY: x.shadowOffsetY * e,
599
+ shadowBlur: x.shadowBlur * e,
592
600
  textAlign: "left"
593
601
  }), x.writingMode) {
594
602
  case "vertical-rl":
595
603
  case "vertical-lr": {
596
- a.characters.forEach((F) => {
597
- h.setTransform(1, 0, 0, 1, 0, 0);
598
- let p = 0, C = 0;
599
- switch (F.verticalOrientation) {
604
+ a.characters.forEach((h) => {
605
+ r.setTransform(1, 0, 0, 1, 0, 0);
606
+ let p = 0, D = 0;
607
+ switch (h.verticalOrientation) {
600
608
  case "Tr":
601
609
  case "R": {
602
- h.rotate(Math.PI / 2), h.textBaseline = "alphabetic", C = -(l + a.inlineBox.x + a.inlineBox.width - F.baseline), p = c + F.contentBox.y;
610
+ r.rotate(Math.PI / 2), r.textBaseline = "alphabetic", D = -(l + a.inlineBox.x + a.inlineBox.width - h.baseline), p = c + h.contentBox.y;
603
611
  break;
604
612
  }
605
613
  case "Tu":
606
- h.textBaseline = "top", p = l + F.contentBox.x + F.contentBox.right - F.glyphBox.right, C = c + F.contentBox.y + F.contentBox.y - F.glyphBox.y;
614
+ r.textBaseline = "top", p = l + h.contentBox.x + h.contentBox.right - h.glyphBox.right, D = c + h.contentBox.y + h.contentBox.y - h.glyphBox.y;
607
615
  break;
608
616
  case "U":
609
- p = l + F.contentBox.x, C = c + F.contentBox.y, h.textBaseline = "top";
617
+ p = l + h.contentBox.x, D = c + h.contentBox.y, r.textBaseline = "top";
610
618
  break;
611
619
  }
612
- h.fillText(F.content, p * u, C * u), x.textStrokeWidth && h.strokeText(F.content, p * u, C * u);
620
+ r.fillText(h.content, p * e, D * e), x.textStrokeWidth && r.strokeText(h.content, p * e, D * e);
613
621
  });
614
622
  break;
615
623
  }
616
624
  case "horizontal-tb": {
617
- const F = l + a.contentBox.x, p = c + a.contentBox.y, C = c + a.inlineBox.y + a.baseline, { width: b, height: w } = a.contentBox;
618
- switch (h.textBaseline = "alphabetic", h.setTransform(1, 0, 0, 1, 0, 0), h.fillText(a.computedContent, F * u, C * u), x.textStrokeWidth && h.strokeText(a.computedContent, F * u, C * u), h.scale(u, u), x.textDecoration) {
625
+ const h = l + a.contentBox.x, p = c + a.contentBox.y, D = c + a.inlineBox.y + a.baseline, { width: b, height: k } = a.contentBox;
626
+ switch (r.textBaseline = "alphabetic", r.setTransform(1, 0, 0, 1, 0, 0), r.fillText(a.computedContent, h * e, D * e), x.textStrokeWidth && r.strokeText(a.computedContent, h * e, D * e), r.scale(e, e), x.textDecoration) {
619
627
  case "underline":
620
- h.strokeStyle = h.fillStyle, h.lineWidth = x.fontSize / 15, h.beginPath(), h.moveTo(F, p + w), h.lineTo(F + b, p + w), h.stroke();
628
+ r.strokeStyle = r.fillStyle, r.lineWidth = x.fontSize / 15, r.beginPath(), r.moveTo(h, p + k), r.lineTo(h + b, p + k), r.stroke();
621
629
  break;
622
630
  case "line-through":
623
- h.strokeStyle = h.fillStyle, h.lineWidth = x.fontSize / 15, h.beginPath(), h.moveTo(F, p + w / 2), h.lineTo(F + b, p + w / 2), h.stroke();
631
+ r.strokeStyle = r.fillStyle, r.lineWidth = x.fontSize / 15, r.beginPath(), r.moveTo(h, p + k / 2), r.lineTo(h + b, p + k / 2), r.stroke();
624
632
  break;
625
633
  }
626
634
  break;
@@ -631,7 +639,7 @@ function Q(r) {
631
639
  }), t;
632
640
  }
633
641
  export {
634
- j as defaultTextStyles,
635
- q as measureText,
636
- Q as renderText
642
+ G as defaultTextStyles,
643
+ V as measureText,
644
+ J as renderText
637
645
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "modern-text",
3
3
  "type": "module",
4
- "version": "0.1.21",
5
- "packageManager": "pnpm@8.14.1",
4
+ "version": "0.1.23",
5
+ "packageManager": "pnpm@9.2.0",
6
6
  "description": "Measure and render text in a way that describes the DOM.",
7
7
  "author": "wxm",
8
8
  "license": "MIT",
@@ -0,0 +1 @@
1
+ export declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;