render-tag 0.1.35 → 0.1.36
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/README.md +60 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/path/index.d.ts +5 -4
- package/lib/path/index.d.ts.map +1 -1
- package/lib/path/index.js +62 -38
- package/lib/path/index.js.map +1 -1
- package/lib/render-tag.umd.js +6 -6
- package/lib/render-tag.umd.js.map +1 -1
- package/lib/render.d.ts +5 -6
- package/lib/render.d.ts.map +1 -1
- package/lib/render.js +176 -126
- package/lib/render.js.map +1 -1
- package/lib/shadow.d.ts +32 -0
- package/lib/shadow.d.ts.map +1 -0
- package/lib/shadow.js +190 -0
- package/lib/shadow.js.map +1 -0
- package/lib/types.d.ts +14 -2
- package/lib/types.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/render-tag.umd.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.RenderTag={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=null,n=null;function r(e){t=e,e===null&&(n=null)}function i(e){let t=typeof document<`u`,n=typeof OffscreenCanvas<`u`;if(t&&(e||!n))return document.createElement(`canvas`).getContext(`2d`);if(n)return new OffscreenCanvas(1,1).getContext(`2d`);throw Error(`render-tag: no canvas available for text measurement. In a non-browser environment, pass config.ctx (a 2D context).`)}function a(){if(t)return t;if(typeof DOMParser<`u`)return n||=new DOMParser,n;throw Error(`render-tag: no DOM parser available. In a non-browser environment, inject one via setDOMParser(new DOMParser()) using a DOM library such as linkedom or jsdom.`)}function o(e){let t=a().parseFromString(`<!DOCTYPE html><html><head></head><body>${e}</body></html>`,`text/html`),n=t.querySelectorAll(`style`),r=``;for(let e of n)r+=e.textContent+`
|
|
2
|
-
`,e.remove();t.body.normalize();let i=t.createDocumentFragment();for(;t.body.firstChild;)i.appendChild(t.body.firstChild);return{fragment:i,css:r}}var s=1,c=3;function l(e){let t=[];e=e.replace(/\/\*[\s\S]*?\*\//g,``);let n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;if(e[n]===`@`){let t=0;for(;n<e.length;){if(e[n]===`{`&&t++,e[n]===`}`&&(t--,t<=0)){n++;break}n++}continue}let r=n;for(;n<e.length&&e[n]!==`{`;)n++;if(n>=e.length)break;let i=e.slice(r,n).trim();n++;let a=n;for(;n<e.length&&e[n]!==`}`;)n++;let o=e.slice(a,n).trim();if(n++,!i)continue;let s=i.split(`,`).map(e=>e.trim()).filter(Boolean),c=[];for(let e of o.split(`;`)){let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t).trim().toLowerCase(),r=e.slice(t+1).trim();n&&r&&c.push({property:n,value:r})}s.length>0&&c.length>0&&t.push({selectors:s,declarations:c})}return t}function u(e){let t=e.replace(/::[\w-]+/g,``).split(/\s*>\s*|\s+/),n=0,r=0,i=0;for(let e of t){let t=e.match(/#[\w-]+/g);t&&(n+=t.length);let a=e.match(/\.[\w-]+/g);a&&(r+=a.length);let o=e.replace(/[#.][\w-]+/g,``).replace(/:[\w-]+/g,``).trim();o&&o!==`*`&&i++}return[n,r,i]}function d(e){let t=e.match(/\.[\w-]+/g)||[],n=e.replace(/\.[\w-]+/g,``).replace(/:[\w-]+/g,``).trim();return{tag:n&&n!==`*`?n:``,classes:t.map(e=>e.slice(1))}}function f(e,t){if(e.tag&&e.tag!==t.tagName)return!1;for(let n of e.classes)if(!t.classes.has(n))return!1;return!0}function p(e){let t;if(e.includes(`::`)){if(e.replace(/::marker\b/g,``).includes(`::`))return null;if(/::marker\b/.test(e))t=`marker`,e=e.replace(/(^|[\s>])::marker\b/g,`$1*`),e=e.replace(/::marker\b/g,``);else return null}if(/:(?:nth-|hover|focus|active|visited|first-child|last-child)/.test(e))return null;let n=[],r=[],i=e.trim().split(/\s+/);for(let e=0;e<i.length;e++)i[e]===`>`?r.push(`>`):(n.length>r.length+1&&r.push(` `),n.push(i[e]));for(;r.length<n.length-1;)r.push(` `);if(n.length===0)return null;let a=n.map(d),o=a[a.length-1],s=o.tag;return{parts:a,combinators:r,rightmost:o,rightmostIsRoot:s===`html`||s===`body`,spec:u(e),pseudoElement:t}}function m(e,t){if(e.rightmostIsRoot){if(t.parent!==null)return!1}else if(!f(e.rightmost,t))return!1;if(e.parts.length===1)return!0;let n=t.parent;for(let t=e.parts.length-2;t>=0;t--){if(!n)return!1;let r=e.parts[t];if(e.combinators[t]===`>`)if(n.parent===null&&(r.tag===`html`||r.tag===`body`))n=n.parent;else if(f(r,n))n=n.parent;else return!1;else{let e=!1;for(;n;){if(n.parent===null&&(r.tag===`html`||r.tag===`body`)){n=n.parent,e=!0;break}if(f(r,n)){n=n.parent,e=!0;break}n=n.parent}if(!e)return!1}}return!0}function h(){return{fontFamily:`serif`,fontSize:16,fontWeight:400,fontStyle:`normal`,fontVariantCaps:`normal`,color:`rgb(0, 0, 0)`,textAlign:`start`,textAlignLast:`auto`,textIndent:0,textTransform:`none`,textDecorationLine:`none`,textDecorationStyle:`solid`,textDecorationColor:`rgb(0, 0, 0)`,textDecorations:[],textUnderlineOffset:null,textDecorationThickness:null,textShadow:`none`,webkitTextStrokeWidth:0,webkitTextStrokeColor:``,webkitTextStrokeImage:`none`,webkitTextFillColor:``,paintOrder:`normal`,strokeLinejoin:`round`,webkitBackgroundClip:``,backgroundImage:`none`,letterSpacing:0,wordSpacing:0,fontKerning:`auto`,lineHeight:0,verticalAlign:`baseline`,whiteSpace:`normal`,wordBreak:`normal`,overflowWrap:`normal`,unicodeBidi:`normal`,direction:`ltr`,display:`block`,width:0,minWidth:null,minHeight:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0,backgroundColor:`rgba(0, 0, 0, 0)`,borderTopWidth:0,borderTopColor:`rgb(0, 0, 0)`,borderTopStyle:`none`,borderRightWidth:0,borderRightColor:`rgb(0, 0, 0)`,borderRightStyle:`none`,borderBottomWidth:0,borderBottomColor:`rgb(0, 0, 0)`,borderBottomStyle:`none`,borderLeftWidth:0,borderLeftColor:`rgb(0, 0, 0)`,borderLeftStyle:`none`,borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,flexDirection:`row`,gap:0,flexGrow:0,flexShrink:1,flexBasis:null,listStyleType:`disc`,lineClamp:0}}var g={span:{display:`inline`},a:{display:`inline`},strong:{display:`inline`,fontWeight:700},b:{display:`inline`,fontWeight:700},em:{display:`inline`,fontStyle:`italic`},i:{display:`inline`,fontStyle:`italic`},u:{display:`inline`,textDecorationLine:`underline`},s:{display:`inline`,textDecorationLine:`line-through`},strike:{display:`inline`,textDecorationLine:`line-through`},del:{display:`inline`,textDecorationLine:`line-through`},sub:{display:`inline`,verticalAlign:`sub`,fontSize:.83},sup:{display:`inline`,verticalAlign:`super`,fontSize:.83},code:{display:`inline`,fontFamily:`monospace`},cite:{display:`inline`,fontStyle:`italic`},bdo:{display:`inline`,unicodeBidi:`bidi-override`},bdi:{display:`inline`,unicodeBidi:`isolate`},p:{display:`block`,marginTop:-1,marginBottom:-1},div:{display:`block`},h1:{display:`block`,fontSize:2,fontWeight:700,marginTop:-.67,marginBottom:-.67},h2:{display:`block`,fontSize:1.5,fontWeight:700,marginTop:-.83,marginBottom:-.83},h3:{display:`block`,fontSize:1.17,fontWeight:700,marginTop:-1,marginBottom:-1},h4:{display:`block`,fontSize:1,fontWeight:700,marginTop:-1.33,marginBottom:-1.33},h5:{display:`block`,fontSize:.83,fontWeight:700,marginTop:-1.67,marginBottom:-1.67},h6:{display:`block`,fontSize:.67,fontWeight:700,marginTop:-2.33,marginBottom:-2.33},ul:{display:`block`,listStyleType:`disc`,marginTop:-1,marginBottom:-1},ol:{display:`block`,listStyleType:`decimal`,marginTop:-1,marginBottom:-1},li:{display:`list-item`},blockquote:{display:`block`,marginTop:-1,marginBottom:-1,marginLeft:40,marginRight:40},pre:{display:`block`,whiteSpace:`pre`,fontFamily:`monospace`,marginTop:-1,marginBottom:-1},table:{display:`table`},tr:{display:`table-row`},td:{display:`table-cell`},th:{display:`table-cell`,fontWeight:700},br:{display:`inline`},hr:{display:`block`,borderTopWidth:1,borderTopStyle:`solid`,borderTopColor:`gray`,marginTop:-.5,marginBottom:-.5}};function _(e,t,n){if(!e||e===`normal`||e===`auto`||e===`none`)return 0;let r=e.trim();if(r.endsWith(`em`)){let e=parseFloat(r);return isNaN(e)?0:e*t}if(r.endsWith(`%`)){let e=parseFloat(r);return isNaN(e)?0:e/100*n}if(r.endsWith(`px`)){let e=parseFloat(r);return isNaN(e)?0:e}let i=parseFloat(r);return isNaN(i)?0:i}function v(e){if(e===`bold`)return 700;if(e===`normal`)return 400;let t=parseInt(e,10);return isNaN(t)?400:t}function y(e){let t=e.trim().toLowerCase();if(!t||t===`normal`)return!1;let n=t.split(/\s+/).filter(e=>e===`fill`||e===`stroke`),r=n.indexOf(`stroke`),i=n.indexOf(`fill`);return r===-1?!1:i===-1?!0:r<i}function b(e,t,n){return[{property:`flex-grow`,value:e},{property:`flex-shrink`,value:t},{property:`flex-basis`,value:n}]}function x(e){let t=[],n=0,r=``;for(let i=0;i<e.length;i++){let a=e[i];a===`(`?(n++,r+=a):a===`)`?(n=Math.max(0,n-1),r+=a):n===0&&/\s/.test(a)?r&&=(t.push(r),``):r+=a}return r&&t.push(r),t}function S(e,t){if(e===`margin`||e===`padding`){let n=t.trim().split(/\s+/),r,i,a,o;return n.length===1?r=i=a=o=n[0]:n.length===2?(r=a=n[0],i=o=n[1]):n.length===3?(r=n[0],i=o=n[1],a=n[2]):(r=n[0],i=n[1],a=n[2],o=n[3]),[{property:`${e}-top`,value:r},{property:`${e}-right`,value:i},{property:`${e}-bottom`,value:a},{property:`${e}-left`,value:o}]}if(e===`border`||e===`border-top`||e===`border-right`||e===`border-bottom`||e===`border-left`){let n=x(t.trim()),r=[`solid`,`dashed`,`dotted`,`double`,`none`,`hidden`],i=n.find(e=>e.endsWith(`px`)||/^\d/.test(e))||`0`,a=n.find(e=>r.includes(e))||`none`,o=n.find(e=>!e.endsWith(`px`)&&!/^\d/.test(e)&&!r.includes(e))||`currentColor`,s=[],c=e===`border`?[`top`,`right`,`bottom`,`left`]:[e.replace(`border-`,``)];for(let e of c)s.push({property:`border-${e}-width`,value:i}),s.push({property:`border-${e}-style`,value:a}),s.push({property:`border-${e}-color`,value:o});return s}if(e===`border-radius`){let[e,n=e,r=e,i=n]=t.split(`/`)[0].trim().split(/\s+/);return[{property:`border-top-left-radius`,value:e},{property:`border-top-right-radius`,value:n},{property:`border-bottom-right-radius`,value:r},{property:`border-bottom-left-radius`,value:i}]}if(e===`list-style`)return t===`none`?[{property:`list-style-type`,value:`none`}]:[{property:`list-style-type`,value:t}];if(e===`text-decoration`){let e=t.trim();if(e===`inherit`||e===`none`)return[{property:`text-decoration-line`,value:`none`},{property:`text-decoration-thickness`,value:`auto`}];let n=``,r=e.replace(/\b(rgba?\([^)]*\)|hsla?\([^)]*\))/i,e=>(n=e,``)).split(/\s+/).filter(Boolean),i=[`underline`,`overline`,`line-through`],a=[`solid`,`double`,`dotted`,`dashed`,`wavy`],o=[{property:`text-decoration-thickness`,value:`auto`}],s=[];for(let e of r)i.includes(e)?s.push(e):a.includes(e)?o.push({property:`text-decoration-style`,value:e}):/^[\d.+-]/.test(e)||e===`auto`||e===`from-font`?o.push({property:`text-decoration-thickness`,value:e}):o.push({property:`text-decoration-color`,value:e});return n&&o.push({property:`text-decoration-color`,value:n}),s.length>0&&o.unshift({property:`text-decoration-line`,value:s.join(` `)}),o}if(e===`-webkit-text-stroke`){let e=x(t.trim()),n=e.find(e=>e.endsWith(`px`)||/^\d/.test(e))||`0`,r=e.find(e=>!e.endsWith(`px`)&&!/^\d/.test(e))||`currentColor`;return[{property:`-webkit-text-stroke-width`,value:n},{property:`-webkit-text-stroke-color`,value:r}]}if(e===`flex`){let e=t.trim().toLowerCase();if(e===`none`)return b(`0`,`0`,`auto`);if(e===`auto`)return b(`1`,`1`,`auto`);if(e===`initial`)return b(`0`,`1`,`auto`);let n=[],r=``;for(let e of t.trim().split(/\s+/))!r&&n.length<2&&/^\d*\.?\d+$/.test(e)?n.push(e):r=e;return n.length===0&&!r?[]:b(n[0]??`1`,n[1]??`1`,r||(n.length>0?`0`:`auto`))}return e===`border-collapse`||e===`border-spacing`?[]:[{property:e,value:t}]}function C(e,t){let n=e.trim();if(n.endsWith(`%`)){let e=parseFloat(n);return e>0?{pct:e}:0}return Math.max(0,_(n,t,0))}function w(e){let t=e.trim();return t.toLowerCase()===`currentcolor`?``:t}function T(e,t,n,r,i,a){let o=e.fontSize||r;switch(t){case`font-family`:e.fontFamily=n.trim();break;case`font-size`:{let t=n.trim();t.endsWith(`em`)?e.fontSize=parseFloat(t)*r:t.endsWith(`%`)?e.fontSize=parseFloat(t)/100*r:e.fontSize=parseFloat(t)||r;break}case`font-weight`:e.fontWeight=v(n);break;case`font-style`:e.fontStyle=n.trim();break;case`font-variant`:case`font-variant-caps`:e.fontVariantCaps=/\bsmall-caps\b/.test(n)?`small-caps`:`normal`;break;case`color`:e.color=n.trim();break;case`text-align`:e.textAlign=n.trim();break;case`text-align-last`:e.textAlignLast=n.trim();break;case`text-indent`:e.textIndent=_(n,o,i);break;case`text-transform`:e.textTransform=n.trim();break;case`text-decoration-line`:e.textDecorationLine=n.trim();break;case`text-decoration`:break;case`text-decoration-style`:e.textDecorationStyle=n.trim();break;case`text-decoration-color`:e.textDecorationColor=n.trim();break;case`text-underline-offset`:{let t=n.trim();if(t===`auto`)e._underlineOffsetPct=void 0,e.textUnderlineOffset=null;else if(!isNaN(parseFloat(t)))if(t.endsWith(`%`)){let n=parseFloat(t);e.textUnderlineOffset=n/100*o,e._underlineOffsetPct=n}else e._underlineOffsetPct=void 0,e.textUnderlineOffset=_(t,o,i);break}case`text-decoration-thickness`:{let t=n.trim();t===`auto`||t===`from-font`?e.textDecorationThickness=null:isNaN(parseFloat(t))||(t.endsWith(`%`)?e.textDecorationThickness=parseFloat(t)/100*o:e.textDecorationThickness=_(t,o,i));break}case`text-shadow`:e.textShadow=n.trim();break;case`-webkit-text-stroke-width`:e.webkitTextStrokeWidth=_(n,o,i);break;case`-webkit-text-stroke-color`:e.webkitTextStrokeColor=w(n);break;case`--rt-text-stroke-image`:e.webkitTextStrokeImage=n.trim();break;case`-webkit-text-fill-color`:e.webkitTextFillColor=w(n);break;case`paint-order`:e.paintOrder=n.trim();break;case`stroke-linejoin`:e.strokeLinejoin=n.trim();break;case`-webkit-background-clip`:case`background-clip`:e.webkitBackgroundClip=n.trim();break;case`background-image`:e.backgroundImage=n.trim();break;case`letter-spacing`:e.letterSpacing=n.trim()===`normal`?0:_(n,o,i);break;case`word-spacing`:e.wordSpacing=n.trim()===`normal`?0:_(n,o,i);break;case`font-kerning`:e.fontKerning=n.trim();break;case`line-height`:{let t=n.trim();if(t===`normal`)e.lineHeight=0;else if(t.endsWith(`px`))e.lineHeight=parseFloat(t)||0;else if(t.endsWith(`em`))e.lineHeight=parseFloat(t)*o;else if(t.endsWith(`%`)){let n=parseFloat(t);isNaN(n)||(e.lineHeight=n/100*o)}else{let n=parseFloat(t);isNaN(n)||(e.lineHeight=n*o,e._lineHeightMultiplier=n)}break}case`-webkit-line-clamp`:case`line-clamp`:{let t=n.trim().toLowerCase();if(t===`none`||t===`auto`)e.lineClamp=0;else{let n=parseInt(t,10);e.lineClamp=Number.isFinite(n)&&n>0?n:0}break}case`vertical-align`:e.verticalAlign=n.trim();break;case`white-space`:e.whiteSpace=n.trim();break;case`word-break`:e.wordBreak=n.trim();break;case`overflow-wrap`:case`word-wrap`:e.overflowWrap=n.trim();break;case`direction`:e.direction=n.trim();break;case`unicode-bidi`:e.unicodeBidi=n.trim();break;case`display`:e.display=n.trim();break;case`width`:{let t=n.trim();t===`100%`?e.width=i:t!==`auto`&&(e.width=_(t,o,i));break}case`min-width`:{let t=n.trim();e.minWidth=t===`auto`?null:_(t,o,i);break}case`min-height`:e.minHeight=_(n,o,i);break;case`padding-top`:e.paddingTop=_(n,o,i);break;case`padding-right`:e.paddingRight=_(n,o,i);break;case`padding-bottom`:e.paddingBottom=_(n,o,i);break;case`padding-left`:e.paddingLeft=_(n,o,i);break;case`margin-top`:e.marginTop=_(n,o,i);break;case`margin-right`:e.marginRight=_(n,o,i);break;case`margin-bottom`:e.marginBottom=_(n,o,i);break;case`margin-left`:e.marginLeft=_(n,o,i);break;case`background-color`:e.backgroundColor=n.trim();break;case`background`:{let t=n.trim();t.includes(`gradient(`)?e.backgroundImage=t:(t.startsWith(`#`)||t.startsWith(`rgb`)||t.startsWith(`hsl`)||[`transparent`,`none`,`inherit`].includes(t)||/^[a-z]+$/.test(t))&&(e.backgroundColor=t);break}case`padding-inline-start`:a===`rtl`?e.paddingRight=_(n,o,i):e.paddingLeft=_(n,o,i);break;case`padding-inline-end`:a===`rtl`?e.paddingLeft=_(n,o,i):e.paddingRight=_(n,o,i);break;case`margin-inline-start`:a===`rtl`?e.marginRight=_(n,o,i):e.marginLeft=_(n,o,i);break;case`margin-inline-end`:a===`rtl`?e.marginLeft=_(n,o,i):e.marginRight=_(n,o,i);break;case`border-top-width`:e.borderTopWidth=_(n,o,i);break;case`border-top-color`:e.borderTopColor=n.trim();break;case`border-top-style`:e.borderTopStyle=n.trim();break;case`border-right-width`:e.borderRightWidth=_(n,o,i);break;case`border-right-color`:e.borderRightColor=n.trim();break;case`border-right-style`:e.borderRightStyle=n.trim();break;case`border-bottom-width`:e.borderBottomWidth=_(n,o,i);break;case`border-bottom-color`:e.borderBottomColor=n.trim();break;case`border-bottom-style`:e.borderBottomStyle=n.trim();break;case`border-left-width`:e.borderLeftWidth=_(n,o,i);break;case`border-left-color`:e.borderLeftColor=n.trim();break;case`border-left-style`:e.borderLeftStyle=n.trim();break;case`border-top-left-radius`:e.borderTopLeftRadius=C(n,o);break;case`border-top-right-radius`:e.borderTopRightRadius=C(n,o);break;case`border-bottom-right-radius`:e.borderBottomRightRadius=C(n,o);break;case`border-bottom-left-radius`:e.borderBottomLeftRadius=C(n,o);break;case`flex-direction`:e.flexDirection=n.trim();break;case`gap`:e.gap=_(n,o,i);break;case`flex-grow`:e.flexGrow=parseFloat(n)||0;break;case`flex-shrink`:{let t=parseFloat(n);e.flexShrink=Number.isFinite(t)&&t>=0?t:1;break}case`flex-basis`:{let t=n.trim();e.flexBasis=t===`auto`||t===`content`?null:_(t,o,i);break}case`list-style-type`:e.listStyleType=n.trim();break;case`position`:case`top`:case`left`:case`right`:case`bottom`:case`inset-inline-start`:case`inset-inline-end`:case`content`:case`counter-reset`:case`counter-increment`:case`cursor`:case`opacity`:case`overflow`:case`box-sizing`:case`outline`:case`transition`:case`transform`:case`font-stretch`:case`font-display`:case`src`:case`unicode-range`:break}}var E=[[`font-family`,`fontFamily`],[`font-size`,`fontSize`],[`font-weight`,`fontWeight`],[`font-style`,`fontStyle`],[`color`,`color`],[`text-align`,`textAlign`],[`text-align-last`,`textAlignLast`],[`text-indent`,`textIndent`],[`text-transform`,`textTransform`],[`white-space`,`whiteSpace`],[`word-break`,`wordBreak`],[`overflow-wrap`,`overflowWrap`],[`direction`,`direction`],[`letter-spacing`,`letterSpacing`],[`word-spacing`,`wordSpacing`],[`line-height`,`lineHeight`],[`text-shadow`,`textShadow`],[`font-kerning`,`fontKerning`],[`list-style-type`,`listStyleType`],[`vertical-align`,`verticalAlign`],[`text-underline-offset`,`textUnderlineOffset`],[`paint-order`,`paintOrder`],[`stroke-linejoin`,`strokeLinejoin`],[`-webkit-text-stroke-width`,`webkitTextStrokeWidth`],[`-webkit-text-stroke-color`,`webkitTextStrokeColor`],[`-webkit-text-fill-color`,`webkitTextFillColor`]];function ee(e,t,n){for(let[r,i]of E)if(e[i]===`inherit`)e[i]=t[i];else if(!n.has(r))if(i===`lineHeight`){let n=t._lineHeightMultiplier;n===void 0?e.lineHeight=t.lineHeight:(e.lineHeight=n*e.fontSize,e._lineHeightMultiplier=n)}else if(i===`textUnderlineOffset`){let n=t._underlineOffsetPct;n===void 0?e.textUnderlineOffset=t.textUnderlineOffset:(e.textUnderlineOffset=n/100*e.fontSize,e._underlineOffsetPct=n)}else e[i]=t[i]}function D(e){let t=new Map,n=new Map,r=[],i=0;for(let a of e){let e=[];for(let t of a.declarations){let n=t.value.includes(`!important`),r=n?t.value.replace(/\s*!important\s*/g,``).trim():t.value,i=S(t.property,r);for(let t of i)e.push({property:t.property,value:t.value,important:n})}for(let o of a.selectors){let a=p(o);if(!a)continue;let s={selector:a,declarations:e,orderBase:i++},c=a.rightmost;if(c.tag&&!a.rightmostIsRoot){let e=t.get(c.tag);e?e.push(s):t.set(c.tag,[s])}if(c.classes.length>0){let e=c.classes[0],t=n.get(e);t?t.push(s):n.set(e,[s])}!c.tag&&c.classes.length===0&&r.push(s),a.rightmostIsRoot&&r.push(s)}}return{byTag:t,byClass:n,universal:r}}function O(e,t){switch(t){case`disc`:return`•`;case`circle`:return`○`;case`square`:return`■`;case`none`:return``;case`decimal-leading-zero`:return`${e<10&&e>=0?`0`+e:e}.`;case`lower-roman`:return`${k(e).toLowerCase()}.`;case`upper-roman`:return`${k(e)}.`;case`lower-alpha`:case`lower-latin`:return`${A(e).toLowerCase()}.`;case`upper-alpha`:case`upper-latin`:return`${A(e)}.`;default:return`${e}.`}}function k(e){if(e<1||e>3999)return`${e}`;let t=[[1e3,`M`],[900,`CM`],[500,`D`],[400,`CD`],[100,`C`],[90,`XC`],[50,`L`],[40,`XL`],[10,`X`],[9,`IX`],[5,`V`],[4,`IV`],[1,`I`]],n=``;for(let[r,i]of t)for(;e>=r;)n+=i,e-=r;return n}function A(e){if(e<1)return`${e}`;let t=``;for(;e>0;){let n=(e-1)%26;t=String.fromCharCode(65+n)+t,e=Math.floor((e-1)/26)}return t}function j(e,t){if(e.tagName.toLowerCase()!==`li`)return;if(t===`none`)return``;let n=e.parentElement,r=n?.tagName.toLowerCase();if(t===`disc`||t===`circle`||t===`square`)return O(0,t);if(r===`ol`||r===`ul`||!n){let r=n?Array.from(n.children).filter(e=>e.tagName.toLowerCase()===`li`):[e],i=n?.getAttribute(`start`),a=n?.hasAttribute(`reversed`)??!1,o=i?parseInt(i,10):a?r.length:1,s=a?-1:1,c=o;for(let n of r){let r=n.getAttribute(`value`);if(r){let e=parseInt(r,10);Number.isNaN(e)||(c=e)}if(n===e)return O(c,t||`decimal`);c+=s}return O(c,t||`decimal`)}}function M(e){let t=e.style;return t&&typeof t.cssText==`string`?t:null}function N(e){let t=[];for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e===-1)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();r&&i&&t.push({property:r,value:i})}return t}function te(e,t,n){let r=D(l(t)),i=e.ownerDocument.createElement(`div`);i.appendChild(e);function a(e,t){let n=new Set,r=e.getAttribute(`class`);if(r)for(let e of r.split(/\s+/))e&&n.add(e);return{tagName:e.tagName.toLowerCase(),classes:n,parent:t,el:e}}function o(e,t,i){let o=e.tagName.toLowerCase(),s=a(e,i),c=h(),l=new Set,d=[],f=new Set,p=r.byTag.get(o);if(p)for(let e of p)f.add(e),d.push(e);for(let e of s.classes){let t=r.byClass.get(e);if(t)for(let e of t)f.has(e)||(f.add(e),d.push(e))}for(let e of r.universal)f.has(e)||(f.add(e),d.push(e));let _=[],v=[];for(let e of d)if(m(e.selector,s)){let t=e.selector.pseudoElement===`marker`?v:_;for(let n of e.declarations)t.push({property:n.property,value:n.value,specificity:e.selector.spec,order:e.orderBase,important:n.important})}let y=g[o],b=!1;if(y?.fontSize!==void 0){let e=y.fontSize;e<10?c.fontSize=e*t.fontSize:c.fontSize=e,b=!0,l.add(`font-size`)}_.length>1&&_.sort((e,t)=>{if(e.important!==t.important)return e.important?1:-1;let n=e.specificity,r=t.specificity;return n[0]===r[0]?n[1]===r[1]?n[2]===r[2]?e.order-t.order:n[2]-r[2]:n[1]-r[1]:n[0]-r[0]});for(let e of _)e.property===`font-size`&&(T(c,e.property,e.value,t.fontSize,n,t.direction),b=!0);let x=M(e);if(x&&x.cssText){let e=N(x.cssText);for(let r of e)r.property===`font-size`&&(T(c,r.property,r.value,t.fontSize,n,t.direction),b=!0)}b||(c.fontSize=t.fontSize);let C=c.fontSize;if(y){for(let[e,t]of Object.entries(y)){if(e===`fontSize`)continue;c[e]=t;let n=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());l.add(n)}c.marginTop<0&&(c.marginTop=Math.abs(c.marginTop)*C),c.marginBottom<0&&(c.marginBottom=Math.abs(c.marginBottom)*C),(o===`ul`||o===`ol`)&&(t.direction===`rtl`?(c.paddingRight=40,l.add(`padding-right`)):(c.paddingLeft=40,l.add(`padding-left`)))}let w=t.direction,E={"word-wrap":`overflow-wrap`};for(let e of _)e.property!==`font-size`&&(T(c,e.property,e.value,C,n,w),l.add(E[e.property]||e.property));let D=!!x?.width;if(x&&x.cssText){let e=N(x.cssText);for(let t of e){if(t.property===`font-size`){l.add(`font-size`);continue}let e=S(t.property,t.value);for(let t of e)T(c,t.property,t.value,C,n,w),l.add(E[t.property]||t.property)}}D||(c.width=0);let O=e.getAttribute(`dir`);O&&(c.direction=O,l.add(`direction`)),l.add(`font-size`),ee(c,t,l),l.has(`text-decoration-color`)?c.textDecorationColor===`currentColor`&&(c.textDecorationColor=c.color):c.textDecorationColor=c.webkitTextFillColor||c.color;for(let e of[`Top`,`Right`,`Bottom`,`Left`]){let t=`border${e}Color`,n=`border-${e.toLowerCase()}-color`;l.has(n)?c[t]===`currentColor`&&(c[t]=c.color):c[t]=c.color}let k=[];if(c.textDecorationLine&&c.textDecorationLine!==`none`)for(let e of c.textDecorationLine.split(/\s+/))e&&e!==`none`&&k.push({line:e,color:c.textDecorationColor,style:c.textDecorationStyle,declarer:c});c.textDecorations=t.textDecorations.length?[...t.textDecorations,...k]:k;let A=new Set(c.textDecorationLine.split(/\s+/).filter(e=>e&&e!==`none`));if(t.textDecorationLine&&t.textDecorationLine!==`none`)for(let e of t.textDecorationLine.split(/\s+/))e&&e!==`none`&&A.add(e);A.size>0&&(c.textDecorationLine=[...A].join(` `));let te=j(e,c.listStyleType),P,F=!1;if(o===`li`&&v.length>0){v.length>1&&v.sort((e,t)=>{if(e.important!==t.important)return e.important?1:-1;let n=e.specificity,r=t.specificity;return n[0]===r[0]?n[1]===r[1]?n[2]===r[2]?e.order-t.order:n[2]-r[2]:n[1]-r[1]:n[0]-r[0]});let e=[`paddingLeft`,`paddingRight`,`fontSize`,`fontFamily`,`fontWeight`,`fontStyle`,`color`,`letterSpacing`],t={...c},r=new Set;for(let i of v){if(i.property===`content`){let e=i.value.trim().toLowerCase();(e===`none`||e===`""`||e===`''`||e===`normal`)&&(F=e===`none`||e===`""`||e===`''`);continue}let a=e.map(e=>t[e]);T(t,i.property,i.value,C,n,w),e.forEach((e,n)=>{t[e]!==a[n]&&r.add(e)})}if(r.size>0){P={};for(let e of r)P[e]=t[e]}}let I=[];for(let t of e.childNodes){let e=u(t,c,s);e&&I.push(e)}return{element:e,tagName:o,style:c,children:I,textContent:null,listMarker:te,markerStyle:P,markerHidden:F||void 0}}function u(e,t,n){if(e.nodeType===c){let n=e.textContent;if(!n)return null;if(n.trim()===``&&!n.includes(`\xA0`)){let r=t.whiteSpace,i=e.previousSibling,a=e.nextSibling,o=e=>{if(!e||e.nodeType!==s)return e?.nodeType===c;let t=g[e.tagName.toLowerCase()]?.display||`block`;return t===`inline`||t===`inline-block`},l=o(i),u=o(a);if(i&&a&&!l&&!u&&!(r===`pre`||r===`pre-wrap`||r===`pre-line`)||r!==`pre`&&r!==`pre-wrap`&&r!==`pre-line`&&n.includes(`
|
|
2
|
+
`,e.remove();t.body.normalize();let i=t.createDocumentFragment();for(;t.body.firstChild;)i.appendChild(t.body.firstChild);return{fragment:i,css:r}}var s=1,c=3;function l(e){let t=[];e=e.replace(/\/\*[\s\S]*?\*\//g,``);let n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;if(e[n]===`@`){let t=0;for(;n<e.length;){if(e[n]===`{`&&t++,e[n]===`}`&&(t--,t<=0)){n++;break}n++}continue}let r=n;for(;n<e.length&&e[n]!==`{`;)n++;if(n>=e.length)break;let i=e.slice(r,n).trim();n++;let a=n;for(;n<e.length&&e[n]!==`}`;)n++;let o=e.slice(a,n).trim();if(n++,!i)continue;let s=i.split(`,`).map(e=>e.trim()).filter(Boolean),c=[];for(let e of o.split(`;`)){let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t).trim().toLowerCase(),r=e.slice(t+1).trim();n&&r&&c.push({property:n,value:r})}s.length>0&&c.length>0&&t.push({selectors:s,declarations:c})}return t}function u(e){let t=e.replace(/::[\w-]+/g,``).split(/\s*>\s*|\s+/),n=0,r=0,i=0;for(let e of t){let t=e.match(/#[\w-]+/g);t&&(n+=t.length);let a=e.match(/\.[\w-]+/g);a&&(r+=a.length);let o=e.replace(/[#.][\w-]+/g,``).replace(/:[\w-]+/g,``).trim();o&&o!==`*`&&i++}return[n,r,i]}function d(e){let t=e.match(/\.[\w-]+/g)||[],n=e.replace(/\.[\w-]+/g,``).replace(/:[\w-]+/g,``).trim();return{tag:n&&n!==`*`?n:``,classes:t.map(e=>e.slice(1))}}function f(e,t){if(e.tag&&e.tag!==t.tagName)return!1;for(let n of e.classes)if(!t.classes.has(n))return!1;return!0}function p(e){let t;if(e.includes(`::`)){if(e.replace(/::marker\b/g,``).includes(`::`))return null;if(/::marker\b/.test(e))t=`marker`,e=e.replace(/(^|[\s>])::marker\b/g,`$1*`),e=e.replace(/::marker\b/g,``);else return null}if(/:(?:nth-|hover|focus|active|visited|first-child|last-child)/.test(e))return null;let n=[],r=[],i=e.trim().split(/\s+/);for(let e=0;e<i.length;e++)i[e]===`>`?r.push(`>`):(n.length>r.length+1&&r.push(` `),n.push(i[e]));for(;r.length<n.length-1;)r.push(` `);if(n.length===0)return null;let a=n.map(d),o=a[a.length-1],s=o.tag;return{parts:a,combinators:r,rightmost:o,rightmostIsRoot:s===`html`||s===`body`,spec:u(e),pseudoElement:t}}function m(e,t){if(e.rightmostIsRoot){if(t.parent!==null)return!1}else if(!f(e.rightmost,t))return!1;if(e.parts.length===1)return!0;let n=t.parent;for(let t=e.parts.length-2;t>=0;t--){if(!n)return!1;let r=e.parts[t];if(e.combinators[t]===`>`)if(n.parent===null&&(r.tag===`html`||r.tag===`body`))n=n.parent;else if(f(r,n))n=n.parent;else return!1;else{let e=!1;for(;n;){if(n.parent===null&&(r.tag===`html`||r.tag===`body`)){n=n.parent,e=!0;break}if(f(r,n)){n=n.parent,e=!0;break}n=n.parent}if(!e)return!1}}return!0}function h(){return{fontFamily:`serif`,fontSize:16,fontWeight:400,fontStyle:`normal`,fontVariantCaps:`normal`,color:`rgb(0, 0, 0)`,textAlign:`start`,textAlignLast:`auto`,textIndent:0,textTransform:`none`,textDecorationLine:`none`,textDecorationStyle:`solid`,textDecorationColor:`rgb(0, 0, 0)`,textDecorations:[],textUnderlineOffset:null,textDecorationThickness:null,textShadow:`none`,webkitTextStrokeWidth:0,webkitTextStrokeColor:``,webkitTextStrokeImage:`none`,webkitTextFillColor:``,paintOrder:`normal`,strokeLinejoin:`round`,webkitBackgroundClip:``,backgroundImage:`none`,letterSpacing:0,wordSpacing:0,fontKerning:`auto`,lineHeight:0,verticalAlign:`baseline`,whiteSpace:`normal`,wordBreak:`normal`,overflowWrap:`normal`,unicodeBidi:`normal`,direction:`ltr`,display:`block`,width:0,minWidth:null,minHeight:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0,backgroundColor:`rgba(0, 0, 0, 0)`,borderTopWidth:0,borderTopColor:`rgb(0, 0, 0)`,borderTopStyle:`none`,borderRightWidth:0,borderRightColor:`rgb(0, 0, 0)`,borderRightStyle:`none`,borderBottomWidth:0,borderBottomColor:`rgb(0, 0, 0)`,borderBottomStyle:`none`,borderLeftWidth:0,borderLeftColor:`rgb(0, 0, 0)`,borderLeftStyle:`none`,borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,flexDirection:`row`,gap:0,flexGrow:0,flexShrink:1,flexBasis:null,listStyleType:`disc`,lineClamp:0}}var g={span:{display:`inline`},a:{display:`inline`},strong:{display:`inline`,fontWeight:700},b:{display:`inline`,fontWeight:700},em:{display:`inline`,fontStyle:`italic`},i:{display:`inline`,fontStyle:`italic`},u:{display:`inline`,textDecorationLine:`underline`},s:{display:`inline`,textDecorationLine:`line-through`},strike:{display:`inline`,textDecorationLine:`line-through`},del:{display:`inline`,textDecorationLine:`line-through`},sub:{display:`inline`,verticalAlign:`sub`,fontSize:.83},sup:{display:`inline`,verticalAlign:`super`,fontSize:.83},code:{display:`inline`,fontFamily:`monospace`},cite:{display:`inline`,fontStyle:`italic`},bdo:{display:`inline`,unicodeBidi:`bidi-override`},bdi:{display:`inline`,unicodeBidi:`isolate`},p:{display:`block`,marginTop:-1,marginBottom:-1},div:{display:`block`},h1:{display:`block`,fontSize:2,fontWeight:700,marginTop:-.67,marginBottom:-.67},h2:{display:`block`,fontSize:1.5,fontWeight:700,marginTop:-.83,marginBottom:-.83},h3:{display:`block`,fontSize:1.17,fontWeight:700,marginTop:-1,marginBottom:-1},h4:{display:`block`,fontSize:1,fontWeight:700,marginTop:-1.33,marginBottom:-1.33},h5:{display:`block`,fontSize:.83,fontWeight:700,marginTop:-1.67,marginBottom:-1.67},h6:{display:`block`,fontSize:.67,fontWeight:700,marginTop:-2.33,marginBottom:-2.33},ul:{display:`block`,listStyleType:`disc`,marginTop:-1,marginBottom:-1},ol:{display:`block`,listStyleType:`decimal`,marginTop:-1,marginBottom:-1},li:{display:`list-item`},blockquote:{display:`block`,marginTop:-1,marginBottom:-1,marginLeft:40,marginRight:40},pre:{display:`block`,whiteSpace:`pre`,fontFamily:`monospace`,marginTop:-1,marginBottom:-1},table:{display:`table`},tr:{display:`table-row`},td:{display:`table-cell`},th:{display:`table-cell`,fontWeight:700},br:{display:`inline`},hr:{display:`block`,borderTopWidth:1,borderTopStyle:`solid`,borderTopColor:`gray`,marginTop:-.5,marginBottom:-.5}};function _(e,t,n){if(!e||e===`normal`||e===`auto`||e===`none`)return 0;let r=e.trim();if(r.endsWith(`em`)){let e=parseFloat(r);return isNaN(e)?0:e*t}if(r.endsWith(`%`)){let e=parseFloat(r);return isNaN(e)?0:e/100*n}if(r.endsWith(`px`)){let e=parseFloat(r);return isNaN(e)?0:e}let i=parseFloat(r);return isNaN(i)?0:i}function v(e){if(e===`bold`)return 700;if(e===`normal`)return 400;let t=parseInt(e,10);return isNaN(t)?400:t}function y(e){let t=e.trim().toLowerCase();if(!t||t===`normal`)return!1;let n=t.split(/\s+/).filter(e=>e===`fill`||e===`stroke`),r=n.indexOf(`stroke`),i=n.indexOf(`fill`);return r===-1?!1:i===-1?!0:r<i}function b(e,t,n){return[{property:`flex-grow`,value:e},{property:`flex-shrink`,value:t},{property:`flex-basis`,value:n}]}function x(e){let t=[],n=0,r=``;for(let i=0;i<e.length;i++){let a=e[i];a===`(`?(n++,r+=a):a===`)`?(n=Math.max(0,n-1),r+=a):n===0&&/\s/.test(a)?r&&=(t.push(r),``):r+=a}return r&&t.push(r),t}function S(e,t){if(e===`margin`||e===`padding`){let n=t.trim().split(/\s+/),r,i,a,o;return n.length===1?r=i=a=o=n[0]:n.length===2?(r=a=n[0],i=o=n[1]):n.length===3?(r=n[0],i=o=n[1],a=n[2]):(r=n[0],i=n[1],a=n[2],o=n[3]),[{property:`${e}-top`,value:r},{property:`${e}-right`,value:i},{property:`${e}-bottom`,value:a},{property:`${e}-left`,value:o}]}if(e===`border`||e===`border-top`||e===`border-right`||e===`border-bottom`||e===`border-left`){let n=x(t.trim()),r=[`solid`,`dashed`,`dotted`,`double`,`none`,`hidden`],i=n.find(e=>e.endsWith(`px`)||/^\d/.test(e))||`0`,a=n.find(e=>r.includes(e))||`none`,o=n.find(e=>!e.endsWith(`px`)&&!/^\d/.test(e)&&!r.includes(e))||`currentColor`,s=[],c=e===`border`?[`top`,`right`,`bottom`,`left`]:[e.replace(`border-`,``)];for(let e of c)s.push({property:`border-${e}-width`,value:i}),s.push({property:`border-${e}-style`,value:a}),s.push({property:`border-${e}-color`,value:o});return s}if(e===`border-radius`){let[e,n=e,r=e,i=n]=t.split(`/`)[0].trim().split(/\s+/);return[{property:`border-top-left-radius`,value:e},{property:`border-top-right-radius`,value:n},{property:`border-bottom-right-radius`,value:r},{property:`border-bottom-left-radius`,value:i}]}if(e===`list-style`)return t===`none`?[{property:`list-style-type`,value:`none`}]:[{property:`list-style-type`,value:t}];if(e===`text-decoration`){let e=t.trim();if(e===`inherit`||e===`none`)return[{property:`text-decoration-line`,value:`none`},{property:`text-decoration-thickness`,value:`auto`}];let n=``,r=e.replace(/\b(rgba?\([^)]*\)|hsla?\([^)]*\))/i,e=>(n=e,``)).split(/\s+/).filter(Boolean),i=[`underline`,`overline`,`line-through`],a=[`solid`,`double`,`dotted`,`dashed`,`wavy`],o=[{property:`text-decoration-thickness`,value:`auto`}],s=[];for(let e of r)i.includes(e)?s.push(e):a.includes(e)?o.push({property:`text-decoration-style`,value:e}):/^[\d.+-]/.test(e)||e===`auto`||e===`from-font`?o.push({property:`text-decoration-thickness`,value:e}):o.push({property:`text-decoration-color`,value:e});return n&&o.push({property:`text-decoration-color`,value:n}),s.length>0&&o.unshift({property:`text-decoration-line`,value:s.join(` `)}),o}if(e===`-webkit-text-stroke`){let e=x(t.trim()),n=e.find(e=>e.endsWith(`px`)||/^\d/.test(e))||`0`,r=e.find(e=>!e.endsWith(`px`)&&!/^\d/.test(e))||`currentColor`;return[{property:`-webkit-text-stroke-width`,value:n},{property:`-webkit-text-stroke-color`,value:r}]}if(e===`flex`){let e=t.trim().toLowerCase();if(e===`none`)return b(`0`,`0`,`auto`);if(e===`auto`)return b(`1`,`1`,`auto`);if(e===`initial`)return b(`0`,`1`,`auto`);let n=[],r=``;for(let e of t.trim().split(/\s+/))!r&&n.length<2&&/^\d*\.?\d+$/.test(e)?n.push(e):r=e;return n.length===0&&!r?[]:b(n[0]??`1`,n[1]??`1`,r||(n.length>0?`0`:`auto`))}return e===`border-collapse`||e===`border-spacing`?[]:[{property:e,value:t}]}function C(e,t){let n=e.trim();if(n.endsWith(`%`)){let e=parseFloat(n);return e>0?{pct:e}:0}return Math.max(0,_(n,t,0))}function w(e){let t=e.trim();return t.toLowerCase()===`currentcolor`?``:t}function T(e,t,n,r,i,a){let o=e.fontSize||r;switch(t){case`font-family`:e.fontFamily=n.trim();break;case`font-size`:{let t=n.trim();t.endsWith(`em`)?e.fontSize=parseFloat(t)*r:t.endsWith(`%`)?e.fontSize=parseFloat(t)/100*r:e.fontSize=parseFloat(t)||r;break}case`font-weight`:e.fontWeight=v(n);break;case`font-style`:e.fontStyle=n.trim();break;case`font-variant`:case`font-variant-caps`:e.fontVariantCaps=/\bsmall-caps\b/.test(n)?`small-caps`:`normal`;break;case`color`:e.color=n.trim();break;case`text-align`:e.textAlign=n.trim();break;case`text-align-last`:e.textAlignLast=n.trim();break;case`text-indent`:e.textIndent=_(n,o,i);break;case`text-transform`:e.textTransform=n.trim();break;case`text-decoration-line`:e.textDecorationLine=n.trim();break;case`text-decoration`:break;case`text-decoration-style`:e.textDecorationStyle=n.trim();break;case`text-decoration-color`:e.textDecorationColor=n.trim();break;case`text-underline-offset`:{let t=n.trim();if(t===`auto`)e._underlineOffsetPct=void 0,e.textUnderlineOffset=null;else if(!isNaN(parseFloat(t)))if(t.endsWith(`%`)){let n=parseFloat(t);e.textUnderlineOffset=n/100*o,e._underlineOffsetPct=n}else e._underlineOffsetPct=void 0,e.textUnderlineOffset=_(t,o,i);break}case`text-decoration-thickness`:{let t=n.trim();t===`auto`||t===`from-font`?e.textDecorationThickness=null:isNaN(parseFloat(t))||(t.endsWith(`%`)?e.textDecorationThickness=parseFloat(t)/100*o:e.textDecorationThickness=_(t,o,i));break}case`text-shadow`:e.textShadow=n.trim();break;case`-webkit-text-stroke-width`:e.webkitTextStrokeWidth=_(n,o,i);break;case`-webkit-text-stroke-color`:e.webkitTextStrokeColor=w(n);break;case`--rt-text-stroke-image`:e.webkitTextStrokeImage=n.trim();break;case`-webkit-text-fill-color`:e.webkitTextFillColor=w(n);break;case`paint-order`:e.paintOrder=n.trim();break;case`stroke-linejoin`:e.strokeLinejoin=n.trim();break;case`-webkit-background-clip`:case`background-clip`:e.webkitBackgroundClip=n.trim();break;case`background-image`:e.backgroundImage=n.trim();break;case`letter-spacing`:e.letterSpacing=n.trim()===`normal`?0:_(n,o,i);break;case`word-spacing`:e.wordSpacing=n.trim()===`normal`?0:_(n,o,i);break;case`font-kerning`:e.fontKerning=n.trim();break;case`line-height`:{let t=n.trim();if(t===`normal`)e.lineHeight=0;else if(t.endsWith(`px`))e.lineHeight=parseFloat(t)||0;else if(t.endsWith(`em`))e.lineHeight=parseFloat(t)*o;else if(t.endsWith(`%`)){let n=parseFloat(t);isNaN(n)||(e.lineHeight=n/100*o)}else{let n=parseFloat(t);isNaN(n)||(e.lineHeight=n*o,e._lineHeightMultiplier=n)}break}case`-webkit-line-clamp`:case`line-clamp`:{let t=n.trim().toLowerCase();if(t===`none`||t===`auto`)e.lineClamp=0;else{let n=parseInt(t,10);e.lineClamp=Number.isFinite(n)&&n>0?n:0}break}case`vertical-align`:e.verticalAlign=n.trim();break;case`white-space`:e.whiteSpace=n.trim();break;case`word-break`:e.wordBreak=n.trim();break;case`overflow-wrap`:case`word-wrap`:e.overflowWrap=n.trim();break;case`direction`:e.direction=n.trim();break;case`unicode-bidi`:e.unicodeBidi=n.trim();break;case`display`:e.display=n.trim();break;case`width`:{let t=n.trim();t===`100%`?e.width=i:t!==`auto`&&(e.width=_(t,o,i));break}case`min-width`:{let t=n.trim();e.minWidth=t===`auto`?null:_(t,o,i);break}case`min-height`:e.minHeight=_(n,o,i);break;case`padding-top`:e.paddingTop=_(n,o,i);break;case`padding-right`:e.paddingRight=_(n,o,i);break;case`padding-bottom`:e.paddingBottom=_(n,o,i);break;case`padding-left`:e.paddingLeft=_(n,o,i);break;case`margin-top`:e.marginTop=_(n,o,i);break;case`margin-right`:e.marginRight=_(n,o,i);break;case`margin-bottom`:e.marginBottom=_(n,o,i);break;case`margin-left`:e.marginLeft=_(n,o,i);break;case`background-color`:e.backgroundColor=n.trim();break;case`background`:{let t=n.trim();t.includes(`gradient(`)?e.backgroundImage=t:(t.startsWith(`#`)||t.startsWith(`rgb`)||t.startsWith(`hsl`)||[`transparent`,`none`,`inherit`].includes(t)||/^[a-z]+$/.test(t))&&(e.backgroundColor=t);break}case`padding-inline-start`:a===`rtl`?e.paddingRight=_(n,o,i):e.paddingLeft=_(n,o,i);break;case`padding-inline-end`:a===`rtl`?e.paddingLeft=_(n,o,i):e.paddingRight=_(n,o,i);break;case`margin-inline-start`:a===`rtl`?e.marginRight=_(n,o,i):e.marginLeft=_(n,o,i);break;case`margin-inline-end`:a===`rtl`?e.marginLeft=_(n,o,i):e.marginRight=_(n,o,i);break;case`border-top-width`:e.borderTopWidth=_(n,o,i);break;case`border-top-color`:e.borderTopColor=n.trim();break;case`border-top-style`:e.borderTopStyle=n.trim();break;case`border-right-width`:e.borderRightWidth=_(n,o,i);break;case`border-right-color`:e.borderRightColor=n.trim();break;case`border-right-style`:e.borderRightStyle=n.trim();break;case`border-bottom-width`:e.borderBottomWidth=_(n,o,i);break;case`border-bottom-color`:e.borderBottomColor=n.trim();break;case`border-bottom-style`:e.borderBottomStyle=n.trim();break;case`border-left-width`:e.borderLeftWidth=_(n,o,i);break;case`border-left-color`:e.borderLeftColor=n.trim();break;case`border-left-style`:e.borderLeftStyle=n.trim();break;case`border-top-left-radius`:e.borderTopLeftRadius=C(n,o);break;case`border-top-right-radius`:e.borderTopRightRadius=C(n,o);break;case`border-bottom-right-radius`:e.borderBottomRightRadius=C(n,o);break;case`border-bottom-left-radius`:e.borderBottomLeftRadius=C(n,o);break;case`flex-direction`:e.flexDirection=n.trim();break;case`gap`:e.gap=_(n,o,i);break;case`flex-grow`:e.flexGrow=parseFloat(n)||0;break;case`flex-shrink`:{let t=parseFloat(n);e.flexShrink=Number.isFinite(t)&&t>=0?t:1;break}case`flex-basis`:{let t=n.trim();e.flexBasis=t===`auto`||t===`content`?null:_(t,o,i);break}case`list-style-type`:e.listStyleType=n.trim();break;case`position`:case`top`:case`left`:case`right`:case`bottom`:case`inset-inline-start`:case`inset-inline-end`:case`content`:case`counter-reset`:case`counter-increment`:case`cursor`:case`opacity`:case`overflow`:case`box-sizing`:case`outline`:case`transition`:case`transform`:case`font-stretch`:case`font-display`:case`src`:case`unicode-range`:break}}var ee=[[`font-family`,`fontFamily`],[`font-size`,`fontSize`],[`font-weight`,`fontWeight`],[`font-style`,`fontStyle`],[`color`,`color`],[`text-align`,`textAlign`],[`text-align-last`,`textAlignLast`],[`text-indent`,`textIndent`],[`text-transform`,`textTransform`],[`white-space`,`whiteSpace`],[`word-break`,`wordBreak`],[`overflow-wrap`,`overflowWrap`],[`direction`,`direction`],[`letter-spacing`,`letterSpacing`],[`word-spacing`,`wordSpacing`],[`line-height`,`lineHeight`],[`text-shadow`,`textShadow`],[`font-kerning`,`fontKerning`],[`list-style-type`,`listStyleType`],[`vertical-align`,`verticalAlign`],[`text-underline-offset`,`textUnderlineOffset`],[`paint-order`,`paintOrder`],[`stroke-linejoin`,`strokeLinejoin`],[`-webkit-text-stroke-width`,`webkitTextStrokeWidth`],[`-webkit-text-stroke-color`,`webkitTextStrokeColor`],[`-webkit-text-fill-color`,`webkitTextFillColor`]];function te(e,t,n){for(let[r,i]of ee)if(e[i]===`inherit`)e[i]=t[i];else if(!n.has(r))if(i===`lineHeight`){let n=t._lineHeightMultiplier;n===void 0?e.lineHeight=t.lineHeight:(e.lineHeight=n*e.fontSize,e._lineHeightMultiplier=n)}else if(i===`textUnderlineOffset`){let n=t._underlineOffsetPct;n===void 0?e.textUnderlineOffset=t.textUnderlineOffset:(e.textUnderlineOffset=n/100*e.fontSize,e._underlineOffsetPct=n)}else e[i]=t[i]}function E(e){let t=new Map,n=new Map,r=[],i=0;for(let a of e){let e=[];for(let t of a.declarations){let n=t.value.includes(`!important`),r=n?t.value.replace(/\s*!important\s*/g,``).trim():t.value,i=S(t.property,r);for(let t of i)e.push({property:t.property,value:t.value,important:n})}for(let o of a.selectors){let a=p(o);if(!a)continue;let s={selector:a,declarations:e,orderBase:i++},c=a.rightmost;if(c.tag&&!a.rightmostIsRoot){let e=t.get(c.tag);e?e.push(s):t.set(c.tag,[s])}if(c.classes.length>0){let e=c.classes[0],t=n.get(e);t?t.push(s):n.set(e,[s])}!c.tag&&c.classes.length===0&&r.push(s),a.rightmostIsRoot&&r.push(s)}}return{byTag:t,byClass:n,universal:r}}function D(e,t){switch(t){case`disc`:return`•`;case`circle`:return`○`;case`square`:return`■`;case`none`:return``;case`decimal-leading-zero`:return`${e<10&&e>=0?`0`+e:e}.`;case`lower-roman`:return`${O(e).toLowerCase()}.`;case`upper-roman`:return`${O(e)}.`;case`lower-alpha`:case`lower-latin`:return`${k(e).toLowerCase()}.`;case`upper-alpha`:case`upper-latin`:return`${k(e)}.`;default:return`${e}.`}}function O(e){if(e<1||e>3999)return`${e}`;let t=[[1e3,`M`],[900,`CM`],[500,`D`],[400,`CD`],[100,`C`],[90,`XC`],[50,`L`],[40,`XL`],[10,`X`],[9,`IX`],[5,`V`],[4,`IV`],[1,`I`]],n=``;for(let[r,i]of t)for(;e>=r;)n+=i,e-=r;return n}function k(e){if(e<1)return`${e}`;let t=``;for(;e>0;){let n=(e-1)%26;t=String.fromCharCode(65+n)+t,e=Math.floor((e-1)/26)}return t}function A(e,t){if(e.tagName.toLowerCase()!==`li`)return;if(t===`none`)return``;let n=e.parentElement,r=n?.tagName.toLowerCase();if(t===`disc`||t===`circle`||t===`square`)return D(0,t);if(r===`ol`||r===`ul`||!n){let r=n?Array.from(n.children).filter(e=>e.tagName.toLowerCase()===`li`):[e],i=n?.getAttribute(`start`),a=n?.hasAttribute(`reversed`)??!1,o=i?parseInt(i,10):a?r.length:1,s=a?-1:1,c=o;for(let n of r){let r=n.getAttribute(`value`);if(r){let e=parseInt(r,10);Number.isNaN(e)||(c=e)}if(n===e)return D(c,t||`decimal`);c+=s}return D(c,t||`decimal`)}}function j(e){let t=e.style;return t&&typeof t.cssText==`string`?t:null}function M(e){let t=[];for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e===-1)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();r&&i&&t.push({property:r,value:i})}return t}function ne(e,t,n){let r=E(l(t)),i=e.ownerDocument.createElement(`div`);i.appendChild(e);function a(e,t){let n=new Set,r=e.getAttribute(`class`);if(r)for(let e of r.split(/\s+/))e&&n.add(e);return{tagName:e.tagName.toLowerCase(),classes:n,parent:t,el:e}}function o(e,t,i){let o=e.tagName.toLowerCase(),s=a(e,i),c=h(),l=new Set,d=[],f=new Set,p=r.byTag.get(o);if(p)for(let e of p)f.add(e),d.push(e);for(let e of s.classes){let t=r.byClass.get(e);if(t)for(let e of t)f.has(e)||(f.add(e),d.push(e))}for(let e of r.universal)f.has(e)||(f.add(e),d.push(e));let _=[],v=[];for(let e of d)if(m(e.selector,s)){let t=e.selector.pseudoElement===`marker`?v:_;for(let n of e.declarations)t.push({property:n.property,value:n.value,specificity:e.selector.spec,order:e.orderBase,important:n.important})}let y=g[o],b=!1;if(y?.fontSize!==void 0){let e=y.fontSize;e<10?c.fontSize=e*t.fontSize:c.fontSize=e,b=!0,l.add(`font-size`)}_.length>1&&_.sort((e,t)=>{if(e.important!==t.important)return e.important?1:-1;let n=e.specificity,r=t.specificity;return n[0]===r[0]?n[1]===r[1]?n[2]===r[2]?e.order-t.order:n[2]-r[2]:n[1]-r[1]:n[0]-r[0]});for(let e of _)e.property===`font-size`&&(T(c,e.property,e.value,t.fontSize,n,t.direction),b=!0);let x=j(e);if(x&&x.cssText){let e=M(x.cssText);for(let r of e)r.property===`font-size`&&(T(c,r.property,r.value,t.fontSize,n,t.direction),b=!0)}b||(c.fontSize=t.fontSize);let C=c.fontSize;if(y){for(let[e,t]of Object.entries(y)){if(e===`fontSize`)continue;c[e]=t;let n=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());l.add(n)}c.marginTop<0&&(c.marginTop=Math.abs(c.marginTop)*C),c.marginBottom<0&&(c.marginBottom=Math.abs(c.marginBottom)*C),(o===`ul`||o===`ol`)&&(t.direction===`rtl`?(c.paddingRight=40,l.add(`padding-right`)):(c.paddingLeft=40,l.add(`padding-left`)))}let w=t.direction,ee={"word-wrap":`overflow-wrap`};for(let e of _)e.property!==`font-size`&&(T(c,e.property,e.value,C,n,w),l.add(ee[e.property]||e.property));let E=!!x?.width;if(x&&x.cssText){let e=M(x.cssText);for(let t of e){if(t.property===`font-size`){l.add(`font-size`);continue}let e=S(t.property,t.value);for(let t of e)T(c,t.property,t.value,C,n,w),l.add(ee[t.property]||t.property)}}E||(c.width=0);let D=e.getAttribute(`dir`);D&&(c.direction=D,l.add(`direction`)),l.add(`font-size`),te(c,t,l),l.has(`text-decoration-color`)?c.textDecorationColor===`currentColor`&&(c.textDecorationColor=c.color):c.textDecorationColor=c.webkitTextFillColor||c.color;for(let e of[`Top`,`Right`,`Bottom`,`Left`]){let t=`border${e}Color`,n=`border-${e.toLowerCase()}-color`;l.has(n)?c[t]===`currentColor`&&(c[t]=c.color):c[t]=c.color}let O=[];if(c.textDecorationLine&&c.textDecorationLine!==`none`)for(let e of c.textDecorationLine.split(/\s+/))e&&e!==`none`&&O.push({line:e,color:c.textDecorationColor,style:c.textDecorationStyle,declarer:c});c.textDecorations=t.textDecorations.length?[...t.textDecorations,...O]:O;let k=new Set(c.textDecorationLine.split(/\s+/).filter(e=>e&&e!==`none`));if(t.textDecorationLine&&t.textDecorationLine!==`none`)for(let e of t.textDecorationLine.split(/\s+/))e&&e!==`none`&&k.add(e);k.size>0&&(c.textDecorationLine=[...k].join(` `));let ne=A(e,c.listStyleType),N,P=!1;if(o===`li`&&v.length>0){v.length>1&&v.sort((e,t)=>{if(e.important!==t.important)return e.important?1:-1;let n=e.specificity,r=t.specificity;return n[0]===r[0]?n[1]===r[1]?n[2]===r[2]?e.order-t.order:n[2]-r[2]:n[1]-r[1]:n[0]-r[0]});let e=[`paddingLeft`,`paddingRight`,`fontSize`,`fontFamily`,`fontWeight`,`fontStyle`,`color`,`letterSpacing`],t={...c},r=new Set;for(let i of v){if(i.property===`content`){let e=i.value.trim().toLowerCase();(e===`none`||e===`""`||e===`''`||e===`normal`)&&(P=e===`none`||e===`""`||e===`''`);continue}let a=e.map(e=>t[e]);T(t,i.property,i.value,C,n,w),e.forEach((e,n)=>{t[e]!==a[n]&&r.add(e)})}if(r.size>0){N={};for(let e of r)N[e]=t[e]}}let F=[];for(let t of e.childNodes){let e=u(t,c,s);e&&F.push(e)}return{element:e,tagName:o,style:c,children:F,textContent:null,listMarker:ne,markerStyle:N,markerHidden:P||void 0}}function u(e,t,n){if(e.nodeType===c){let n=e.textContent;if(!n)return null;if(n.trim()===``&&!n.includes(`\xA0`)){let r=t.whiteSpace,i=e.previousSibling,a=e.nextSibling,o=e=>{if(!e||e.nodeType!==s)return e?.nodeType===c;let t=g[e.tagName.toLowerCase()]?.display||`block`;return t===`inline`||t===`inline-block`},l=o(i),u=o(a);if(i&&a&&!l&&!u&&!(r===`pre`||r===`pre-wrap`||r===`pre-line`)||r!==`pre`&&r!==`pre-wrap`&&r!==`pre-line`&&n.includes(`
|
|
3
3
|
`)&&!(l&&u))return null}let r={...t},i=t.whiteSpace,a=n;return i!==`pre`&&i!==`pre-wrap`&&i!==`pre-line`&&i!==`break-spaces`&&(a=n.replace(/[\n\r]/g,` `)),{element:null,tagName:`#text`,style:r,children:[],textContent:a}}if(e.nodeType!==s)return null;let r=e,i=r.tagName.toLowerCase();return i===`style`||i===`script`?null:i===`br`?{element:null,tagName:`#text`,style:{...t},children:[],textContent:`
|
|
4
|
-
`}:o(r,t,n)}return o(i,h(),null)}var P=!0,F,I=[],ne=new Map,re=new Map,ie=new Map;function L(e,t){let n=e.font+`\0`+(e.letterSpacing||``)+`\0`+t,r=ie.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return ie.set(n,i),i}function ae(e){let t=``;for(let n of e){if(!n.text||n.isSpace)continue;let e=`${B(n.style)}|${z(n.style.letterSpacing)}|${oe(n.style)}`;if(t&&e!==t)return!0;t=e}return!1}function R(e,t){e.font=B(t),e.fontKerning=oe(t)}function oe(e){return e.fontKerning===`none`?`none`:`normal`}function z(e){return Number.isFinite(e)&&e!==0?`${e}px`:`0px`}var se=new Map;function B(e){let t=`${e.fontStyle}|${e.fontVariantCaps}|${e.fontWeight}|${e.fontSize}|${e.fontFamily}`,n=se.get(t);if(n)return n;let r=[];e.fontStyle!==`normal`&&r.push(e.fontStyle),e.fontVariantCaps===`small-caps`&&r.push(`small-caps`),e.fontWeight!==400&&r.push(String(e.fontWeight)),r.push(`${e.fontSize}px`),r.push(e.fontFamily);let i=r.join(` `);return se.set(t,i),i}var ce=new Map,V=null,H=null,U=null,le=new Set([`disc`,`circle`,`square`]);function ue(e,t,n=!1){let r=`${e}|${t}|${n?`ul-li`:`block`}`,i=ce.get(r);if(i!==void 0)return i;if(typeof document>`u`||!document.body)throw Error(`render-tag: accuracy 'balanced' requires a browser DOM for line-height probes; use the default 'performance' mode in non-browser environments.`);let a;n?(H||(H=document.createElement(`ul`),H.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;padding:0;margin:0;border:0;list-style:disc;`,U=document.createElement(`li`),U.style.cssText=`white-space:nowrap;padding:0;margin:0;border:0;`,U.textContent=`Mg`,H.appendChild(U),document.body.appendChild(H)),a=U):(V||(V=document.createElement(`div`),V.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;white-space:nowrap;padding:0;margin:0;border:0;`,V.textContent=`Mg`,document.body.appendChild(V)),a=V),a.style.font=e,a.style.lineHeight=t;let o=a.getBoundingClientRect().height;return ce.set(r,o),o}function W(e,t,n=!1){if(t.lineHeight>0)return P?ue(B(t),`${t.lineHeight}px`,n):t.lineHeight;if(P)return ue(B(t),`normal`,n);let{ascent:r,descent:i}=Y(e,t);return r+i}var G=typeof navigator>`u`?``:navigator.userAgent,de=/\bGecko\/\d/.test(G),fe=/AppleWebKit/.test(G)&&!/Chrome\/\d/.test(G)&&!/\bjsdom\//.test(G),pe=!de&&!fe,me=!de&&!fe,he=!de;function ge(e,t,n){let r=(e-(t+n))/2+t;return me?Math.floor(r):r}function _e(e,t){R(e,t);let n=e.letterSpacing;e.letterSpacing=`0px`;let r=L(e,` `);return e.letterSpacing=n,{interval:(r+(t.letterSpacing||0)+(t.wordSpacing||0))*8,halfSpace:r/2}}function ve(e){return{top:e.marginTop+e.borderTopWidth+e.paddingTop,bottom:e.paddingBottom+e.borderBottomWidth+e.marginBottom}}function K(e,t,n=!1){let{ascent:r,descent:i}=Y(e,t),a=W(e,t,n),o=ge(a,r,i);return{ascent:o,descent:a-o}}function ye(e,t){switch(t){case`uppercase`:return e.toUpperCase();case`lowercase`:return e.toLowerCase();case`capitalize`:return e.replace(/(^|[\s\p{P}])(\p{L})/gu,(e,t,n)=>t===`'`||t===`’`?e:t+n.toUpperCase());default:return e}}function q(e){if(e.tagName===`#text`)return!0;let t=e.style.display;return t===`inline`||t===`inline-block`}function be(e){return e.children.length>0&&e.children.every(q)}function J(e){return!e||e===`transparent`||e===`rgba(0, 0, 0, 0)`}var xe=new Map;function Y(e,t){let n=B(t),r=xe.get(n);if(r)return r;let i=e.font;e.font=n;let a=e.measureText(`M`);e.font=i;let o={ascent:a.fontBoundingBoxAscent??a.actualBoundingBoxAscent,descent:a.fontBoundingBoxDescent??a.actualBoundingBoxDescent};return xe.set(n,o),o}function X(e,t,n,r,i){switch(e){case`super`:return he?-(r.fontSize/3+1):-r.fontSize*.34;case`sub`:return he?r.fontSize/5+1:r.fontSize*.2;case`text-top`:return K(t,n,i).ascent-Y(t,r).ascent;case`text-bottom`:return Y(t,r).descent-K(t,n,i).descent;case`middle`:{let{ascent:e,descent:i}=Y(t,n);return-(r.fontSize*.25)-(i-e)/2}default:{let r=parseFloat(e);return Number.isFinite(r)?e.endsWith(`%`)?-(r/100)*W(t,n,i):-r:0}}}function Se(e){return e!==`baseline`&&e!==`top`&&e!==`bottom`&&e!==``}function Ce(e,t){if(e===t)return!0;let n=e.declarer,r=t.declarer;return n.fontSize===r.fontSize&&n.fontFamily===r.fontFamily&&n.fontWeight===r.fontWeight&&n.fontStyle===r.fontStyle&&n.fontVariantCaps===r.fontVariantCaps&&n.verticalAlign===r.verticalAlign&&n.textUnderlineOffset===r.textUnderlineOffset&&n.textDecorationThickness===r.textDecorationThickness}function we(e,t){let n=e.textDecorations,r=t.textDecorations;if(n===r)return!0;if(!n||!r||n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e].line!==r[e].line||n[e].color!==r[e].color||n[e].style!==r[e].style||!Ce(n[e],r[e]))return!1;return!0}function Te(e,t){return e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontStyle===t.fontStyle&&e.color===t.color&&e.textDecorationLine===t.textDecorationLine&&we(e,t)&&e.backgroundColor===t.backgroundColor}function Ee(e){return!J(e.backgroundColor)||e.borderTopWidth>0&&e.borderTopStyle!==`none`||e.borderRightWidth>0&&e.borderRightStyle!==`none`||e.borderBottomWidth>0&&e.borderBottomStyle!==`none`||e.borderLeftWidth>0&&e.borderLeftStyle!==`none`}function De(e){return e.webkitBackgroundClip===`text`&&(!!e.backgroundImage&&e.backgroundImage!==`none`||!J(e.backgroundColor))}function Oe(e){return!!(e.boxOpen&&e.boxClose&&e.text)}function ke(e,t,n){let r=t.words.length-1;for(;r>=0&&(t.words[r].text===``||Oe(t.words[r]));)r--;if(r<0)return;let i=t.words[r].style,a=t.words[r].boxStyle,o=t.words[r].parentStyle;R(e,i),e.letterSpacing=`${i.letterSpacing||0}px`;let s=L(e,`…`),c=()=>{for(;t.words.length>0&&t.words[t.words.length-1].isSpace;){let e=t.words.pop();t.totalWidth-=e.width}};c();let l=e=>!e.isSpace&&e.text!==``&&!e.boxOpen&&!e.boxClose;for(;t.totalWidth+s>n&&t.words.length>0;){let e=t.words[t.words.length-1];if(!l(e)&&!Oe(e))break;t.totalWidth-=e.width,t.words.pop(),c()}let u={text:`…`,width:s,style:i,parentStyle:o,isSpace:!1,boxStyle:a};t.words.push(u),t.totalWidth+=s}function Ae(e){let t=[];function n(e,r,i,a,o){if(e.tagName===`#text`&&e.textContent){t.push({text:e.textContent,style:e.style,parentStyle:o,boxStyle:r,clipStyle:i,strokeImageStyle:a});return}let s=e.style.display===`inline-block`,c=s||q(e)&&Ee(e.style),l=c?e.style:r,u=q(e)&&De(e.style)?e.style:i,d=q(e)&&e.style.webkitTextStrokeImage&&e.style.webkitTextStrokeImage!==`none`?e.style:a,f=c&&(e.style.paddingLeft>0||e.style.paddingRight>0||e.style.borderLeftWidth>0||e.style.borderRightWidth>0);if(s){let n=e.element?.textContent||``;t.push({text:n,style:e.style,parentStyle:o,boxStyle:l,clipStyle:u,strokeImageStyle:d,boxOpen:e.style,boxClose:e.style,inlineBlock:e});return}let p=e.style.unicodeBidi,m=(p===`bidi-override`||p===`isolate-override`)&&e.style.direction===`rtl`,h=t.length;f&&t.push({text:``,style:e.style,boxStyle:l,boxOpen:e.style});for(let t of e.children)n(t,c?l:r,u,d,t.tagName===`#text`?o:e.style);if(f&&t.push({text:``,style:e.style,boxStyle:l,boxClose:e.style}),m&&t.length>h){let e=t.splice(h);for(let t of e)t.text&&(t.text=[...t.text].reverse().join(``),t.style={...t.style,direction:`ltr`});e.reverse(),t.push(...e)}}for(let t of e.children)n(t,void 0,void 0,void 0,e.style);return t}function je(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n>=3584&&n<=3711||n>=3712&&n<=3839||n>=4096&&n<=4255||n>=6016&&n<=6143)return!0;n>65535&&t++}return!1}var Me;function Ne(){return Me||(typeof Intl<`u`&&Intl.Segmenter?(Me=new Intl.Segmenter(void 0,{granularity:`word`}),Me):null)}function Pe(e,t,n,r,i){if(t.includes(``)||t.includes(``)){let a=t.split(/(\u200B|\u00AD)/),o=i??{cumText:``,cumWidth:0},s=!1;for(let t of a){if(t===``){s=!0;continue}if(t===``||t===``){s=!1;continue}let i=r.length;Pe(e,t,n,r,o),s&&i>0&&(r[i-1].isSoftHyphenBreak=!0),s=!1}s&&r.length>0&&(r[r.length-1].isSoftHyphenBreak=!0);return}if(n.style.whiteSpace===`pre`||n.style.whiteSpace===`pre-wrap`||n.style.whiteSpace===`break-spaces`){let i=t.split(/( +|\t)/).flatMap(e=>/^( +|\t)$/.test(e)?[e]:He(e)),a=L(e,` `)*8;for(let t of i){if(t===``)continue;if(t===` `){r.push({text:` `,width:a,style:n.style,parentStyle:n.parentStyle,isSpace:!0,isTab:!0,boxStyle:n.boxStyle,clipStyle:n.clipStyle,strokeImageStyle:n.strokeImageStyle});continue}let i=/^ +$/.test(t);r.push({text:t,width:L(e,t),style:n.style,parentStyle:n.parentStyle,isSpace:i,boxStyle:n.boxStyle,clipStyle:n.clipStyle,strokeImageStyle:n.strokeImageStyle})}}else{let a=t.split(/([ \t\n\r\f\v]+)/).flatMap(e=>/^[ \t\n\r\f\v]+$/.test(e)?[e]:e.split(/(?<=\?)(?=.)|(?<=[-|\u2013\u2014])(?=\u00A0)/)).flatMap(e=>/^[ \t\n\r\f\v]+$/.test(e)?[e]:He(e)),o=i?.cumText??``,s=i?.cumWidth??0;for(let t of a){if(t===``)continue;if(/^[ \t\n\r\f\v]+$/.test(t)){let t=s;o+=` `,s=e.measureText(o).width;let i=s-t+(n.style.wordSpacing||0);r.push({text:` `,width:i,style:n.style,parentStyle:n.parentStyle,isSpace:!0,boxStyle:n.boxStyle,clipStyle:n.clipStyle,strokeImageStyle:n.strokeImageStyle});continue}if(je(t)){let i=Ne();if(i){for(let a of i.segment(t)){let t=a.segment,i=s;o+=t,s=e.measureText(o).width,r.push({text:t,width:s-i,style:n.style,parentStyle:n.parentStyle,isSpace:!1,boxStyle:n.boxStyle,clipStyle:n.clipStyle,strokeImageStyle:n.strokeImageStyle})}continue}}let i=s;o+=t,s=e.measureText(o).width;let a=s-i,c=L(e,t);F&&F({type:`measure-word`,message:`"${t}" delta=${a.toFixed(2)} direct=${c.toFixed(2)} diff=${(a-c).toFixed(2)} cumText="${o}"`,data:{text:t,deltaWidth:a,directWidth:c,cumWidth:s,prevCum:i,font:n.style.fontFamily,fontSize:n.style.fontSize}}),r.push({text:t,width:a,style:n.style,parentStyle:n.parentStyle,isSpace:!1,boxStyle:n.boxStyle,clipStyle:n.clipStyle,strokeImageStyle:n.strokeImageStyle})}i&&(i.cumText=o,i.cumWidth=s)}}function Fe(e,t){let n=[];for(let r of t){if(r.text===``&&!r.boxOpen&&!r.boxClose){let e=r.style.display===`inline-block`&&(r.style.marginLeft||r.style.marginRight)||0;e>0&&n.push({text:``,width:e,style:r.style,isSpace:!1,boxStyle:r.boxStyle});continue}if(r.boxOpen&&r.boxClose&&r.text){R(e,r.style),e.letterSpacing=z(r.style.letterSpacing);let t=ye(r.text,r.style.textTransform),i=r.style,a=L(e,t),o=i.marginLeft+i.borderLeftWidth+i.paddingLeft+a+i.paddingRight+i.borderRightWidth+i.marginRight;n.push({text:t,width:o,style:r.style,parentStyle:r.parentStyle,isSpace:!1,boxStyle:r.boxStyle,boxOpen:r.boxOpen,boxClose:r.boxClose,clipStyle:r.clipStyle,strokeImageStyle:r.strokeImageStyle,inlineBlock:r.inlineBlock});continue}if(r.boxOpen){let e=r.boxOpen.paddingLeft+r.boxOpen.borderLeftWidth;e>0&&n.push({text:``,width:e,style:r.style,isSpace:!1,boxStyle:r.boxStyle,boxOpen:r.boxOpen});continue}if(r.boxClose){let e=r.boxClose.paddingRight+r.boxClose.borderRightWidth;e>0&&n.push({text:``,width:e,style:r.style,isSpace:!1,boxStyle:r.boxStyle,boxClose:r.boxClose});continue}R(e,r.style),e.letterSpacing=z(r.style.letterSpacing);let t=ye(r.text,r.style.textTransform),i=e=>{let t=n[e];if(!t||t.isSpace||!t.text||t.text===`
|
|
5
|
-
`)return;let r=n[e-1];if(!r||r.isSpace||!r.text.trim()||r.boxOpen||r.boxClose)return;let i=
|
|
4
|
+
`}:o(r,t,n)}return o(i,h(),null)}var N=!0,P,F=[],re=new Map,ie=new Map,ae=new Map;function I(e,t){let n=e.font+`\0`+(e.letterSpacing||``)+`\0`+t,r=ae.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return ae.set(n,i),i}function oe(e){let t=``;for(let n of e){if(!n.text||n.isSpace)continue;let e=`${z(n.style)}|${R(n.style.letterSpacing)}|${se(n.style)}`;if(t&&e!==t)return!0;t=e}return!1}function L(e,t){e.font=z(t),e.fontKerning=se(t)}function se(e){return e.fontKerning===`none`?`none`:`normal`}function R(e){return Number.isFinite(e)&&e!==0?`${e}px`:`0px`}var ce=new Map;function z(e){let t=`${e.fontStyle}|${e.fontVariantCaps}|${e.fontWeight}|${e.fontSize}|${e.fontFamily}`,n=ce.get(t);if(n)return n;let r=[];e.fontStyle!==`normal`&&r.push(e.fontStyle),e.fontVariantCaps===`small-caps`&&r.push(`small-caps`),e.fontWeight!==400&&r.push(String(e.fontWeight)),r.push(`${e.fontSize}px`),r.push(e.fontFamily);let i=r.join(` `);return ce.set(t,i),i}var le=new Map,B=null,V=null,H=null,ue=new Set([`disc`,`circle`,`square`]);function de(e,t,n=!1){let r=`${e}|${t}|${n?`ul-li`:`block`}`,i=le.get(r);if(i!==void 0)return i;if(typeof document>`u`||!document.body)throw Error(`render-tag: accuracy 'balanced' requires a browser DOM for line-height probes; use the default 'performance' mode in non-browser environments.`);let a;n?(V||(V=document.createElement(`ul`),V.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;padding:0;margin:0;border:0;list-style:disc;`,H=document.createElement(`li`),H.style.cssText=`white-space:nowrap;padding:0;margin:0;border:0;`,H.textContent=`Mg`,V.appendChild(H),document.body.appendChild(V)),a=H):(B||(B=document.createElement(`div`),B.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;white-space:nowrap;padding:0;margin:0;border:0;`,B.textContent=`Mg`,document.body.appendChild(B)),a=B),a.style.font=e,a.style.lineHeight=t;let o=a.getBoundingClientRect().height;return le.set(r,o),o}function U(e,t,n=!1){if(t.lineHeight>0)return N?de(z(t),`${t.lineHeight}px`,n):t.lineHeight;if(N)return de(z(t),`normal`,n);let{ascent:r,descent:i}=J(e,t);return r+i}var W=typeof navigator>`u`?``:navigator.userAgent,fe=/\bGecko\/\d/.test(W),pe=/AppleWebKit/.test(W)&&!/Chrome\/\d/.test(W)&&!/\bjsdom\//.test(W),me=!fe&&!pe,he=!fe&&!pe,ge=!fe;function _e(e,t,n){let r=(e-(t+n))/2+t;return he?Math.floor(r):r}function ve(e,t){L(e,t);let n=e.letterSpacing;e.letterSpacing=`0px`;let r=I(e,` `);return e.letterSpacing=n,{interval:(r+(t.letterSpacing||0)+(t.wordSpacing||0))*8,halfSpace:r/2}}function ye(e){return{top:e.marginTop+e.borderTopWidth+e.paddingTop,bottom:e.paddingBottom+e.borderBottomWidth+e.marginBottom}}function G(e,t,n=!1){let{ascent:r,descent:i}=J(e,t),a=U(e,t,n),o=_e(a,r,i);return{ascent:o,descent:a-o}}function be(e,t){switch(t){case`uppercase`:return e.toUpperCase();case`lowercase`:return e.toLowerCase();case`capitalize`:return e.replace(/(^|[\s\p{P}])(\p{L})/gu,(e,t,n)=>t===`'`||t===`’`?e:t+n.toUpperCase());default:return e}}function K(e){if(e.tagName===`#text`)return!0;let t=e.style.display;return t===`inline`||t===`inline-block`}function xe(e){return e.children.length>0&&e.children.every(K)}function q(e){return!e||e===`transparent`||e===`rgba(0, 0, 0, 0)`}var Se=new Map;function J(e,t){let n=z(t),r=Se.get(n);if(r)return r;let i=e.font;e.font=n;let a=e.measureText(`M`);e.font=i;let o={ascent:a.fontBoundingBoxAscent??a.actualBoundingBoxAscent,descent:a.fontBoundingBoxDescent??a.actualBoundingBoxDescent};return Se.set(n,o),o}function Y(e,t,n,r,i){switch(e){case`super`:return ge?-(r.fontSize/3+1):-r.fontSize*.34;case`sub`:return ge?r.fontSize/5+1:r.fontSize*.2;case`text-top`:return G(t,n,i).ascent-J(t,r).ascent;case`text-bottom`:return J(t,r).descent-G(t,n,i).descent;case`middle`:{let{ascent:e,descent:i}=J(t,n);return-(r.fontSize*.25)-(i-e)/2}default:{let r=parseFloat(e);return Number.isFinite(r)?e.endsWith(`%`)?-(r/100)*U(t,n,i):-r:0}}}function Ce(e){return e!==`baseline`&&e!==`top`&&e!==`bottom`&&e!==``}function we(e,t){if(e===t)return!0;let n=e.declarer,r=t.declarer;return n.fontSize===r.fontSize&&n.fontFamily===r.fontFamily&&n.fontWeight===r.fontWeight&&n.fontStyle===r.fontStyle&&n.fontVariantCaps===r.fontVariantCaps&&n.verticalAlign===r.verticalAlign&&n.textUnderlineOffset===r.textUnderlineOffset&&n.textDecorationThickness===r.textDecorationThickness}function Te(e,t){let n=e.textDecorations,r=t.textDecorations;if(n===r)return!0;if(!n||!r||n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e].line!==r[e].line||n[e].color!==r[e].color||n[e].style!==r[e].style||!we(n[e],r[e]))return!1;return!0}function Ee(e,t){return e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontStyle===t.fontStyle&&e.color===t.color&&e.textDecorationLine===t.textDecorationLine&&Te(e,t)&&e.backgroundColor===t.backgroundColor}function De(e){return!q(e.backgroundColor)||e.borderTopWidth>0&&e.borderTopStyle!==`none`||e.borderRightWidth>0&&e.borderRightStyle!==`none`||e.borderBottomWidth>0&&e.borderBottomStyle!==`none`||e.borderLeftWidth>0&&e.borderLeftStyle!==`none`}function Oe(e){return e.webkitBackgroundClip===`text`&&(!!e.backgroundImage&&e.backgroundImage!==`none`||!q(e.backgroundColor))}function ke(e){return!!(e.boxOpen&&e.boxClose&&e.text)}function Ae(e,t,n){let r=t.words.length-1;for(;r>=0&&(t.words[r].text===``||ke(t.words[r]));)r--;if(r<0)return;let i=t.words[r].style,a=t.words[r].boxStyle,o=t.words[r].parentStyle;L(e,i),e.letterSpacing=`${i.letterSpacing||0}px`;let s=I(e,`…`),c=()=>{for(;t.words.length>0&&t.words[t.words.length-1].isSpace;){let e=t.words.pop();t.totalWidth-=e.width}};c();let l=e=>!e.isSpace&&e.text!==``&&!e.boxOpen&&!e.boxClose;for(;t.totalWidth+s>n&&t.words.length>0;){let e=t.words[t.words.length-1];if(!l(e)&&!ke(e))break;t.totalWidth-=e.width,t.words.pop(),c()}let u={text:`…`,width:s,style:i,parentStyle:o,isSpace:!1,boxStyle:a};t.words.push(u),t.totalWidth+=s}function je(e){let t=[];function n(e,r,i,a,o){if(e.tagName===`#text`&&e.textContent){t.push({text:e.textContent,style:e.style,parentStyle:o,boxStyle:r,clipStyle:i,strokeImageStyle:a});return}let s=e.style.display===`inline-block`,c=s||K(e)&&De(e.style),l=c?e.style:r,u=K(e)&&Oe(e.style)?e.style:i,d=K(e)&&e.style.webkitTextStrokeImage&&e.style.webkitTextStrokeImage!==`none`?e.style:a,f=c&&(e.style.paddingLeft>0||e.style.paddingRight>0||e.style.borderLeftWidth>0||e.style.borderRightWidth>0);if(s){let n=e.element?.textContent||``;t.push({text:n,style:e.style,parentStyle:o,boxStyle:l,clipStyle:u,strokeImageStyle:d,boxOpen:e.style,boxClose:e.style,inlineBlock:e});return}let p=e.style.unicodeBidi,m=(p===`bidi-override`||p===`isolate-override`)&&e.style.direction===`rtl`,h=t.length;f&&t.push({text:``,style:e.style,boxStyle:l,boxOpen:e.style});for(let t of e.children)n(t,c?l:r,u,d,t.tagName===`#text`?o:e.style);if(f&&t.push({text:``,style:e.style,boxStyle:l,boxClose:e.style}),m&&t.length>h){let e=t.splice(h);for(let t of e)t.text&&(t.text=[...t.text].reverse().join(``),t.style={...t.style,direction:`ltr`});e.reverse(),t.push(...e)}}for(let t of e.children)n(t,void 0,void 0,void 0,e.style);return t}function Me(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n>=3584&&n<=3711||n>=3712&&n<=3839||n>=4096&&n<=4255||n>=6016&&n<=6143)return!0;n>65535&&t++}return!1}var Ne;function Pe(){return Ne||(typeof Intl<`u`&&Intl.Segmenter?(Ne=new Intl.Segmenter(void 0,{granularity:`word`}),Ne):null)}function Fe(e,t,n,r,i){if(t.includes(``)||t.includes(``)){let a=t.split(/(\u200B|\u00AD)/),o=i??{cumText:``,cumWidth:0},s=!1;for(let t of a){if(t===``){s=!0;continue}if(t===``||t===``){s=!1;continue}let i=r.length;Fe(e,t,n,r,o),s&&i>0&&(r[i-1].isSoftHyphenBreak=!0),s=!1}s&&r.length>0&&(r[r.length-1].isSoftHyphenBreak=!0);return}if(n.style.whiteSpace===`pre`||n.style.whiteSpace===`pre-wrap`||n.style.whiteSpace===`break-spaces`){let i=t.split(/( +|\t)/).flatMap(e=>/^( +|\t)$/.test(e)?[e]:Ue(e)),a=I(e,` `)*8;for(let t of i){if(t===``)continue;if(t===` `){r.push({text:` `,width:a,style:n.style,parentStyle:n.parentStyle,isSpace:!0,isTab:!0,boxStyle:n.boxStyle,clipStyle:n.clipStyle,strokeImageStyle:n.strokeImageStyle});continue}let i=/^ +$/.test(t);r.push({text:t,width:I(e,t),style:n.style,parentStyle:n.parentStyle,isSpace:i,boxStyle:n.boxStyle,clipStyle:n.clipStyle,strokeImageStyle:n.strokeImageStyle})}}else{let a=t.split(/([ \t\n\r\f\v]+)/).flatMap(e=>/^[ \t\n\r\f\v]+$/.test(e)?[e]:e.split(/(?<=\?)(?=.)|(?<=[-|\u2013\u2014])(?=\u00A0)/)).flatMap(e=>/^[ \t\n\r\f\v]+$/.test(e)?[e]:Ue(e)),o=i?.cumText??``,s=i?.cumWidth??0;for(let t of a){if(t===``)continue;if(/^[ \t\n\r\f\v]+$/.test(t)){let t=s;o+=` `,s=e.measureText(o).width;let i=s-t+(n.style.wordSpacing||0);r.push({text:` `,width:i,style:n.style,parentStyle:n.parentStyle,isSpace:!0,boxStyle:n.boxStyle,clipStyle:n.clipStyle,strokeImageStyle:n.strokeImageStyle});continue}if(Me(t)){let i=Pe();if(i){for(let a of i.segment(t)){let t=a.segment,i=s;o+=t,s=e.measureText(o).width,r.push({text:t,width:s-i,style:n.style,parentStyle:n.parentStyle,isSpace:!1,boxStyle:n.boxStyle,clipStyle:n.clipStyle,strokeImageStyle:n.strokeImageStyle})}continue}}let i=s;o+=t,s=e.measureText(o).width;let a=s-i,c=I(e,t);P&&P({type:`measure-word`,message:`"${t}" delta=${a.toFixed(2)} direct=${c.toFixed(2)} diff=${(a-c).toFixed(2)} cumText="${o}"`,data:{text:t,deltaWidth:a,directWidth:c,cumWidth:s,prevCum:i,font:n.style.fontFamily,fontSize:n.style.fontSize}}),r.push({text:t,width:a,style:n.style,parentStyle:n.parentStyle,isSpace:!1,boxStyle:n.boxStyle,clipStyle:n.clipStyle,strokeImageStyle:n.strokeImageStyle})}i&&(i.cumText=o,i.cumWidth=s)}}function Ie(e,t){let n=[];for(let r of t){if(r.text===``&&!r.boxOpen&&!r.boxClose){let e=r.style.display===`inline-block`&&(r.style.marginLeft||r.style.marginRight)||0;e>0&&n.push({text:``,width:e,style:r.style,isSpace:!1,boxStyle:r.boxStyle});continue}if(r.boxOpen&&r.boxClose&&r.text){L(e,r.style),e.letterSpacing=R(r.style.letterSpacing);let t=be(r.text,r.style.textTransform),i=r.style,a=I(e,t),o=i.marginLeft+i.borderLeftWidth+i.paddingLeft+a+i.paddingRight+i.borderRightWidth+i.marginRight;n.push({text:t,width:o,style:r.style,parentStyle:r.parentStyle,isSpace:!1,boxStyle:r.boxStyle,boxOpen:r.boxOpen,boxClose:r.boxClose,clipStyle:r.clipStyle,strokeImageStyle:r.strokeImageStyle,inlineBlock:r.inlineBlock});continue}if(r.boxOpen){let e=r.boxOpen.paddingLeft+r.boxOpen.borderLeftWidth;e>0&&n.push({text:``,width:e,style:r.style,isSpace:!1,boxStyle:r.boxStyle,boxOpen:r.boxOpen});continue}if(r.boxClose){let e=r.boxClose.paddingRight+r.boxClose.borderRightWidth;e>0&&n.push({text:``,width:e,style:r.style,isSpace:!1,boxStyle:r.boxStyle,boxClose:r.boxClose});continue}L(e,r.style),e.letterSpacing=R(r.style.letterSpacing);let t=be(r.text,r.style.textTransform),i=e=>{let t=n[e];if(!t||t.isSpace||!t.text||t.text===`
|
|
5
|
+
`)return;let r=n[e-1];if(!r||r.isSpace||!r.text.trim()||r.boxOpen||r.boxClose)return;let i=ze(t.text)[0],a=ze(r.text),o=a[a.length-1];X(i)||X(o)||He(i)||He(o)||Me(t.text)||Me(r.text)||(t.noBreakBefore=!0)};if(t.includes(`
|
|
6
6
|
`)){let a=t.split(`
|
|
7
7
|
`);for(let t=0;t<a.length;t++)if(t>0&&n.push({text:`
|
|
8
|
-
`,width:0,style:r.style,isSpace:!1,boxStyle:r.boxStyle}),a[t]){let o=n.length;
|
|
9
|
-
`)break;let i=!!t.text&&
|
|
10
|
-
`){u.words.length===0?(u.lineHeight=Math.max(u.lineHeight,p),u.endedByHardBreak=!0,c.push(u),u=l()):(u.endedByHardBreak=!0,h()),g=!0;continue}if(d){u.words.push(s),u.totalWidth+=s.width,u.lineHeight=Math.max(u.lineHeight,p);continue}if(!s.isSpace&&s.text&&!s.noBreakBefore&&!s.boxOpen&&!s.boxClose){let n=r;for(;n+1<t.length;){let e=t[n+1];if(!e.text||e.isSpace||e.boxOpen||e.boxClose||!e.noBreakBefore)break;n++}if(n>r){let a=s.style.overflowWrap===`break-word`||s.style.wordBreak===`break-all`,o=0;for(let e=r;e<=n;e++)o+=t[e].width;let c=[];for(let e=r;e<=n;e++)for(let n of[...t[e].text])c.push({ch:n,style:t[e].style,parentStyle:t[e].parentStyle,clipStyle:t[e].clipStyle,strokeImageStyle:t[e].strokeImageStyle});let l=He(c.map(e=>e.ch).join(``)),d=l.length>1;if(!(u.totalWidth+o<=f())&&(d||a&&o>f())){let t=[],o=0;for(let e of l){let n=[...e].length;t.push(c.slice(o,o+n)),o+=n}let s=(t,n)=>{let r=0;for(;r<t.length;){let a=t[r].style,o=t[r].clipStyle,s=t[r].strokeImageStyle,c=t[r].parentStyle;R(e,a),e.letterSpacing=z(a.letterSpacing);let l=W(e,a,i),d=``,p=0;for(;r<t.length&&t[r].style===a;){let i=t[r].ch,m=L(e,d+i);n&&u.totalWidth+m>f()&&(u.words.length>0||d)?(d&&(u.words.push({text:d,width:p,style:a,isSpace:!1,parentStyle:c,clipStyle:o,strokeImageStyle:s}),u.totalWidth+=p,u.lineHeight=Math.max(u.lineHeight,l)),h(!0),g=!1,d=i,p=L(e,i)):(d+=i,p=m),r++}d&&(u.words.push({text:d,width:p,style:a,isSpace:!1,parentStyle:c,clipStyle:o,strokeImageStyle:s}),u.totalWidth+=p,u.lineHeight=Math.max(u.lineHeight,l),g=!1)}},p=t=>{let n=0,r=0;for(;r<t.length;){let i=t[r].style,a=``;for(;r<t.length&&t[r].style===i;)a+=t[r].ch,r++;R(e,i),e.letterSpacing=z(i.letterSpacing),n+=L(e,a)}return n};!d&&u.words.length>0&&(h(!0),g=!1);for(let e of t){let t=p(e);u.words.length>0&&u.totalWidth+t>f()&&(h(!0),g=!1),s(e,a&&t>f())}r=n;continue}}}let _=!s.isSpace&&s.text.length>1?Ue(e,s,f(),u.totalWidth):{pieces:[s],emergency:!1},v=_.pieces;_.emergency&&u.words.some(e=>!e.isSpace)&&(h(!0),g=!1);let y=Ke(t,r+1);for(let i=0;i<v.length;i++){let s=v[i],l=i===v.length-1,d=l?y:0;for(let e=i+1;e<v.length;e++){let t=v[e];if(!t.text||!We.test(t.text))break;d+=t.width,e===v.length-1&&(d+=y)}let _=!s.isSpace&&s.text.length>0&&We.test(s.text)&&u.words.length>0&&!u.words[u.words.length-1].isSpace,b=u.words.length>0&&!u.words[u.words.length-1].isSpace&&(s===v[0]&&s.noBreakBefore||!s.text&&!!s.boxClose),x=0,S=Ge.test(s.text);if(S&&!l)x=v[i+1].width;else if(!s.text&&s.boxOpen||S&&y===0){let n=r+1;for(;n<t.length&&!t[n].text&&t[n].boxOpen;)x+=t[n].width,n++;let i=t[n];if(i&&!i.isSpace&&i.text){let r=i.text.length>1?Ue(e,i,f(),0).pieces:[i];x+=r[0].width,r.length===1&&(x+=Ke(t,n+1))}}let C=0;s.isSoftHyphenBreak&&(R(e,s.style),e.letterSpacing=z(s.style.letterSpacing),C=L(e,`-`));let w=u.totalWidth+s.width+C+d+x;if(!s.isSpace&&!_&&!b&&u.words.length>0&&w>f()){let t=w-f(),r=!0;if(t<1&&!u.words.some(e=>e.isTab)&&!ae([...u.words,s])){R(e,s.style);let t=u.words.map(e=>e.text).join(``)+s.text+(s.isSoftHyphenBreak?`-`:``),n=0;for(let e of u.words)e.text?e.isSpace&&(n+=e.style.wordSpacing):n+=e.width;s.text?s.isSpace&&(n+=s.style.wordSpacing):n+=s.width,L(e,t)+n+d+x<=f()+.02&&(r=!1)}if(r){if(F){let e=u.words.map(e=>e.text).join(``);F({type:`line-wrap`,message:`"${s.text}" overflow=${t.toFixed(2)} wrap=true lineWidth=${u.totalWidth.toFixed(2)} pieceWidth=${s.width.toFixed(2)} contentWidth=${n} line="${e}"`,data:{text:s.text,overflow:t,lineWidth:u.totalWidth,pieceWidth:s.width,contentWidth:n,lineText:e}})}h(!0),g=!1}}if(s.isSpace&&u.words.length===0&&(!g||!m))continue;let T=s.width;if(s.isTab){let e=o?.interval||s.width,t=o?.halfSpace??0,n=e-((c.length===0?a:0)+u.totalWidth)%e;n<t&&(n+=e),T=n,s.width=T}u.words.push(s),u.totalWidth+=T,u.lineHeight=Math.max(u.lineHeight,p),s.isSpace||(g=!1)}}return h(),c}function Je(e,t,n,r){for(let i of t){let t=i.inlineBlock;if(!t)continue;let a=t.style,o=$(a),s=ot(a),c=Math.max(0,i.width-o-s),l=Math.max(0,n-o-s),u=a.width>0?Math.max(0,a.width-s):Math.min(c,Math.max(st(e,t),l));a.minWidth!==null&&(u=Math.max(u,Math.max(0,a.minWidth-s)));let d=Ye(e,t,0,0,u,r),f=d.height||W(e,a,r),p=d.lines.at(-1)?.y??K(e,a,r).ascent,m=ve(a),h=m.top+p,g=m.top+f+m.bottom;i.width=o+s+u,i.inlineBlockLayout={nodes:d.nodes,lines:d.lines,contentWidth:u,contentHeight:f,baselineOffset:h,marginBoxHeight:g}}}function Ye(e,t,n,r,i,a=!1,o){let s=[],c=[],l=new Map,u=new Map;if(o&&(o.exhausted||o.remaining<=0))return o.exhausted=!0,{nodes:s,height:0,lines:c};let d=Ae(t);if(d.length===0)return{nodes:s,height:0,lines:c};let f=Fe(e,d);Je(e,f,i,a);let p=t.style.textIndent||0,m=_e(e,t.style),h=W(e,t.style,a),g=qe(e,f,i,t.style.whiteSpace,a,p,m,h),_=o?o.remaining:t.style.lineClamp;if(_>0&&g.length>_){g.length=_;let t=g[_-1];ke(e,t,i-(_===1?p:0)),t.endedByHardBreak=!0,o&&(o.remaining=0,o.exhausted=!0)}else o&&(o.remaining-=g.length);let v=t.style.direction===`rtl`,y=e=>e===`start`?v?`right`:`left`:e===`end`?v?`left`:`right`:e,b=y(t.style.textAlign),x=t.style.textAlignLast||`auto`;x=x===`auto`?t.style.textAlign===`justify`?v?`right`:`left`:b:y(x);let S=t.style,C=r;for(let r=0;r<g.length;r++){let o=g[r];if(o.words.length===0){C+=o.lineHeight;continue}let d=r===g.length-1,f=r===0,m=d||o.endedByHardBreak?x:b,h=f?p:0,_=i-h,y=0;if(m===`justify`&&o.totalWidth<_){let e=o.words.filter(e=>e.isSpace).length;e>0&&(y=(_-o.totalWidth)/e)}let w=o.totalWidth>_+.5,T=n+h;w?T=v?n+_-o.totalWidth:n+h:m===`center`?T=n+h+(_-o.totalWidth)/2:m===`right`?T=(v?n+_:n+h+_)-o.totalWidth:m===`justify`&&v&&(T=n+_-o.totalWidth);let E=T,ee=K(e,t.style,a),D=ee.ascent,O=ee.descent,k=(e,t)=>{e.ascent-t>D&&(D=e.ascent-t),e.descent+t>O&&(O=e.descent+t)};for(let t of o.words){if(t.text===``)continue;t.parentStyle&&k(K(e,t.parentStyle,a),X(t.parentStyle.verticalAlign,e,t.parentStyle,S,a));let n=K(e,t.style,a),r=t.boxStyle?.display===`inline-block`?t.boxStyle:null;if(t.inlineBlockLayout){let e=t.inlineBlockLayout;n.ascent=e.baselineOffset,n.descent=e.marginBoxHeight-e.baselineOffset}else if(r){let e=ve(r);n.ascent+=e.top,n.descent+=e.bottom}k(n,r?0:X(t.style.verticalAlign,e,t.style,t.parentStyle??S,a))}let A=D+O,j=C+D,M=(t,n,r,i)=>{let{ascent:o,descent:c}=t.display===`inline-block`?K(e,t,a):Y(e,t),l=t.paddingTop+t.borderTopWidth,u=t.paddingBottom+t.borderBottomWidth,d=o+c+l+u,f=j;if(i&&t.display!==`inline-block`){let t=i.style.verticalAlign;Se(t)&&(f+=X(t,e,i.style,i.parentStyle??S,a))}let p=f-o-l;s.push({type:`box`,style:t,x:n,y:p,width:r,height:d,tagName:`span`,children:[]})};if(!v){let e=T,t=e,n,r;for(let i of o.words){if(i.boxOpen&&i.boxClose&&i.text){n&&(r&&M(n,t,e-t,r),n=void 0,r=void 0);let a=i.style,o=e+a.marginLeft;if(i.inlineBlockLayout){let e=i.inlineBlockLayout;s.push({type:`box`,style:a,x:o,y:j-e.baselineOffset+a.marginTop,width:a.borderLeftWidth+a.paddingLeft+e.contentWidth+a.paddingRight+a.borderRightWidth,height:a.borderTopWidth+a.paddingTop+e.contentHeight+a.paddingBottom+a.borderBottomWidth,tagName:`span`,children:[]})}else{let e=i.width-$(a)-ot(a);M(a,o,a.borderLeftWidth+a.paddingLeft+e+a.paddingRight+a.borderRightWidth,i)}r=void 0,e+=i.width;continue}i.boxStyle!==n&&(n&&r&&M(n,t,e-t,r),n=i.boxStyle,t=e,r=void 0),i.text&&!i.isSpace&&(r??=i),e+=i.width+(i.isSpace?y:0)}n&&r&&M(n,t,e-t,r)}let N=o.words.filter(e=>e.text!==``),te=N.length>0&&N.every(e=>Te(e.style,N[0].style));if(v){let t=[],n=null,r=0;for(let e of o.words){if(e.text===``){n&&=(t.push(n),null),r+=e.width;continue}if(e.isSpace&&y>0){n&&=(t.push(n),null),r+=e.width+y;continue}n&&Te(n.style,e.style)?(n.text+=e.text,n.width+=e.width):(n&&t.push(n),n={text:e.text,style:e.style,width:e.width,boxStyle:e.boxStyle,clipStyle:e.clipStyle,strokeImageStyle:e.strokeImageStyle,x:0,padBefore:r},r=0)}n&&t.push(n);let i=T+o.totalWidth;for(let n of t){i-=n.padBefore,R(e,n.style);let t=L(e,n.text);i-=t,n.x=i,n.width=t}for(let e of t)if(e.boxStyle&&Ee(e.boxStyle)){let t=e.boxStyle,n=t.paddingLeft+t.borderLeftWidth,r=t.paddingRight+t.borderRightWidth;M(t,e.x-n,e.width+n+r)}for(let e of t){let t={type:`text`,text:e.text,x:e.x+e.width,y:j,width:e.width,style:{...e.style,direction:`rtl`}};s.push(t),e.clipStyle&&l.set(t,e.clipStyle),e.strokeImageStyle&&u.set(t,e.strokeImageStyle)}}else{let t=o.words.map(e=>e.text).join(``);if(te&&/[\u0590-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(t)&&!o.words.some(e=>e.boxOpen||e.boxClose||e.style.verticalAlign===`super`||e.style.verticalAlign===`sub`)){R(e,N[0].style);let n=L(e,t),r={type:`text`,text:t,x:T,y:j,width:n,style:{...N[0].style,direction:`ltr`}};s.push(r),N[0].clipStyle&&l.set(r,N[0].clipStyle),N[0].strokeImageStyle&&u.set(r,N[0].strokeImageStyle)}else for(let t of o.words){if(t.text===``){T+=t.width;continue}if(t.boxOpen&&t.boxClose){let n=t.style,r=T+n.marginLeft+n.borderLeftWidth+n.paddingLeft;if(t.inlineBlockLayout){let e=t.inlineBlockLayout,i=j-e.baselineOffset+n.marginTop+n.borderTopWidth+n.paddingTop,a=e=>{if(e.x+=r,e.y+=i,e.type===`text`)e.lineBaselineY!==void 0&&(e.lineBaselineY+=i),e.clip&&(e.clip.x+=r,e.clip.y+=i),e.strokeImage&&(e.strokeImage.x+=r,e.strokeImage.y+=i);else for(let t of e.children)a(t)};for(let t of e.nodes)a(t),s.push(t);for(let t of e.lines.slice(0,-1)){let e={y:Math.round(t.y+i),text:t.text,bounds:{x:t.bounds.x+r,y:t.bounds.y+i,width:t.bounds.width,height:t.bounds.height}};c.push(e)}T+=t.width;continue}let i={type:`text`,text:t.text,x:r,y:j,width:L(e,t.text),style:t.style};s.push(i),t.clipStyle&&l.set(i,t.clipStyle),t.strokeImageStyle&&u.set(i,t.strokeImageStyle),T+=t.width;continue}let n=j,r=t.style.verticalAlign;Se(r)&&(n+=X(r,e,t.style,t.parentStyle??S,a));let i=t.width+(t.isSpace?y:0),o={type:`text`,text:t.text,x:T,y:n,width:i,style:t.style,...n===j?{}:{lineBaselineY:j}};s.push(o),t.clipStyle&&l.set(o,t.clipStyle),t.strokeImageStyle&&u.set(o,t.strokeImageStyle),T+=i}}let P=m===`justify`&&y>0?_:o.totalWidth,F={y:Math.round(j),text:o.words.map(e=>e.inlineBlockLayout?.lines.at(-1)?.text??e.text).join(``),bounds:{x:E,y:C,width:P,height:A}};c.push(F),C+=A}return Xe(e,s,l,(e,t,n)=>{e.clip={image:t.backgroundImage&&t.backgroundImage!==`none`?t.backgroundImage:void 0,color:J(t.backgroundColor)?void 0:t.backgroundColor,...n}}),Xe(e,s,u,(e,t,n)=>{e.strokeImage={image:t.webkitTextStrokeImage,...n}}),{nodes:s,height:C-r,lines:c}}function Xe(e,t,n,r){if(n.size===0)return;let i=e=>e.style.direction===`rtl`?{left:e.x-e.width,right:e.x}:{left:e.x,right:e.x+e.width};for(let a=0;a<t.length;){let o=t[a],s=o.type===`text`?n.get(o):void 0;if(!s){a++;continue}let c=a,l=1/0,u=-1/0;for(;c<t.length;){let e=t[c];if(e.type!==`text`||n.get(e)!==s||e.y!==o.y)break;let r=i(e);r.left<l&&(l=r.left),r.right>u&&(u=r.right),c++}let{ascent:d,descent:f}=Y(e,s),p={x:l,y:o.y-d,width:u-l,height:d+f};for(let e=a;e<c;e++)r(t[e],s,p);a=c}}function Ze(e,t){return e>=0&&t>=0?Math.max(e,t):e<0&&t<0?Math.min(e,t):e+t}function Qe(e){let t=e.style.display;return t===`block`||t===`list-item`||t===`flex`||t===`table`||t===`table-row`||t===`table-cell`||t===`table-row-group`||t===`table-header-group`||t===`table-footer-group`}function $e(e){let t=e.style.display;return(t===`block`||t===`list-item`)&&(e.tagName===`li`||e.tagName===`ul`||e.tagName===`ol`||e.tagName===`dd`||e.tagName===`dt`)}function et(e){let t=e.style.marginTop;if(!$e(e)||e.style.paddingTop!==0||e.style.borderTopWidth!==0)return t;let n=e.children[0];return n&&Qe(n)?Ze(t,et(n)):t}function Q(e,t,n,r,i,a){let o=t.style;!a&&o.lineClamp>0&&(a={remaining:o.lineClamp,exhausted:!1});let s=o.marginLeft,c=o.marginRight,l=o.borderLeftWidth,u=o.borderRightWidth,d=o.borderTopWidth,f=o.borderBottomWidth,p=o.paddingLeft,m=o.paddingRight,h=o.paddingTop,g=o.paddingBottom,_=n+s,v=o.width>0?o.width:i-s-c,y=_+l+p,b=Math.max(0,v-l-u-p-m),x=r,S=x+d+h,C={type:`box`,style:o,x:_,y:x,width:v,height:0,tagName:t.tagName,children:[],listMarker:t.listMarker};if(o.display===`flex`){let n=ht(e,t,y,S,b);return C.children=n.children,C.height=d+h+n.height+g+f,{box:C,height:C.height,marginBottomOut:o.marginBottom}}if(o.display===`table`){let n=tt(e,t,y,S,b);return C.children=n.children,C.height=d+h+n.height+g+f,{box:C,height:C.height,marginBottomOut:o.marginBottom}}if(t.children.length===0)return C.height=d+h+g+f,o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:o.marginBottom};if(be(t)){let{nodes:n,height:r,lines:i}=Ye(e,t,y,S,b,t.tagName===`li`&&le.has(o.listStyleType),a);I.push(...i),C.children=n,C.height=d+h+r+g+f}else{let n=S,r=0,i=!1,s=$e(t);for(let c=0;c<t.children.length;c++){let l=t.children[c];if(a&&(a.exhausted||a.remaining<=0)){a.exhausted=!0,r=0;break}if(l.tagName===`#text`||q(l)){let s=[l];for(;c+1<t.children.length;){let e=t.children[c+1];if(e.tagName===`#text`||q(e))s.push(e),c++;else break}n+=r,r=0;let u={element:null,tagName:`div`,style:{...t.style,display:`block`,marginTop:0,marginBottom:0,paddingTop:0,paddingBottom:0,borderTopWidth:0,borderBottomWidth:0},children:s,textContent:null},d=t.tagName===`li`&&le.has(o.listStyleType),{nodes:f,height:p,lines:m}=Ye(e,u,y,n,b,d,a);I.push(...m),C.children.push(...f),n+=p,r=0,i=!0;continue}let u=et(l);if(!(!i&&h===0&&d===0&&s)){let e=Ze(r,u);n+=e}let{box:f,height:p,marginBottomOut:m}=Q(e,l,y,n,b,a);C.children.push(f),n+=p,r=a?.exhausted?0:m,i=!0}let c=o.marginBottom,l=g===0&&f===0&&o.minHeight===0&&s;l&&(c=Ze(o.marginBottom,r));let u=n-S;return l||(u+=r),u=Math.max(0,u),C.height=d+h+u+g+f,o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:c}}return o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:o.marginBottom}}function tt(e,t,n,r,i){let a=[],o=[];for(let e of t.children)if(e.tagName===`tr`)o.push(e);else if([`thead`,`tbody`,`tfoot`].includes(e.tagName))for(let t of e.children)t.tagName===`tr`&&o.push(t);if(o.length===0)return{children:a,height:0};let s=Math.max(...o.map(e=>e.children.filter(e=>e.tagName===`td`||e.tagName===`th`).length));if(s===0)return{children:a,height:0};let c=i/s,l=r;for(let t of o){let r=t.children.filter(e=>e.tagName===`td`||e.tagName===`th`),i=0,o=[];for(let t=0;t<r.length;t++){let a=r[t],{box:s,height:u}=Q(e,a,n+t*c,l,c);o.push(s),i=Math.max(i,u)}for(let e of o)e.height=i,a.push(e);l+=i}return{children:a,height:l-r}}var nt=new WeakMap;function rt(e){let t=nt.get(e);return t||(t={element:null,tagName:`div`,style:{...e.style,display:`block`},children:[e],textContent:null},nt.set(e,t)),t}function it(e){return e.children.filter(e=>e.tagName!==`#text`||e.textContent?.trim()).map(e=>e.tagName===`#text`?rt(e):e)}function at(e){return e.flexDirection===`row`||e.flexDirection===``}function ot(e){return e.borderLeftWidth+e.paddingLeft+e.paddingRight+e.borderRightWidth}function $(e){return e.marginLeft+e.marginRight}function st(e,t){return qe(e,Fe(e,Ae(t)).map(e=>e.style.overflowWrap===`break-word`&&e.style.wordBreak!==`break-all`?{...e,style:{...e.style,overflowWrap:`normal`}}:e),0,t.style.whiteSpace).reduce((e,t)=>Math.max(e,t.totalWidth),0)}function ct(e,t){let n=ne.get(t);if(n!==void 0)return n;let r=lt(e,t);return ne.set(t,r),r}function lt(e,t){let n=$(t.style),r=ot(t.style);if(t.style.minWidth!==null)return n+Math.max(r,t.style.minWidth);let i=0;if(be(t))i=st(e,t);else if(t.style.display===`flex`&&at(t.style)){let n=it(t);i=n.reduce((t,n)=>t+ct(e,n),0)+t.style.gap*Math.max(0,n.length-1)}else for(let n of t.children)n.tagName!==`#text`&&(i=Math.max(i,ct(e,n)));let a=r+i;return t.style.width>0&&(a=Math.min(a,t.style.width)),n+a}function ut(e,t){return qe(e,Fe(e,Ae(t)),1/0,t.style.whiteSpace).reduce((e,t)=>Math.max(e,t.totalWidth),0)}function dt(e,t){let n=re.get(t);if(n!==void 0)return n;let r=ft(e,t);return re.set(t,r),r}function ft(e,t){let n=$(t.style);if(t.style.width>0)return n+t.style.width;let r=0;if(be(t))r=ut(e,t);else if(t.style.display===`flex`&&at(t.style)){let n=it(t);r=n.reduce((t,n)=>t+dt(e,n),0)+t.style.gap*Math.max(0,n.length-1)}else for(let n of t.children)n.tagName!==`#text`&&(r=Math.max(r,dt(e,n)));return n+ot(t.style)+r}function pt(e,t){return t.style.flexBasis===null?dt(e,t):$(t.style)+t.style.flexBasis}function mt(e,t,n,r){let i=t.map((e,t)=>Math.max(e,n[t])),a=i.reduce((e,t)=>e+t,0)<r,o=t=>a?e[t].flexGrow:e[t].flexShrink,s=i.map((e,n)=>o(n)===0||!a&&t[n]<e);for(;;){let o=i.map((e,t)=>t).filter(e=>!s[e]);if(o.length===0)break;let c=r-i.reduce((e,n,r)=>e+(s[r]?n:t[r]),0),l=o.map(n=>a?e[n].flexGrow:e[n].flexShrink*t[n]),u=l.reduce((e,t)=>e+t,0);if(u<=0)break;o.forEach((e,n)=>{i[e]=t[e]+c*l[n]/u});let d=o.filter(e=>i[e]<n[e]);if(d.length===0)break;for(let e of d)i[e]=n[e],s[e]=!0}return i}function ht(e,t,n,r,i){let a=t.style,o=a.gap,s=[],c=it(t);if(c.length===0)return{children:s,height:0};if(at(a)){let t=o*(c.length-1),a=Math.max(0,i-t),l=mt(c.map(e=>e.style),c.map(t=>pt(e,t)),c.map(t=>ct(e,t)),a),u=n,d=0;for(let t=0;t<c.length;t++){let n=c[t],i=l[t],{box:a,height:f}=Q(e,n,u,r,i);s.push(a),d=Math.max(d,f),u+=i+o}return{children:s,height:d}}let l=r;for(let t of c){let{box:r,height:a}=Q(e,t,n,l,i);s.push(r),l+=a+o}return{children:s,height:l-r}}function gt(e,t,n){if(!n.listMarker||n.markerHidden)return;let r=n.style,i=n.markerStyle,a=i?{...r,...i}:r;e.font=B(a);let o=K(e,r),s=t.y+r.borderTopWidth+r.paddingTop+o.ascent,c=L(e,n.listMarker),l=r.direction===`rtl`,u=le.has(r.listStyleType),d=l?i?.paddingLeft:i?.paddingRight,f,p=s,m=`ltr`,h=a,g=c,_=t.x+r.borderLeftWidth+r.paddingLeft,v=t.x+t.width;if(u){let{ascent:t}=Y(e,a),r=e.measureText(n.listMarker),i=t/3,o=d===void 0?7+i:d,u=(r.actualBoundingBoxAscent??0)+(r.actualBoundingBoxDescent??0),m=u>0?i/u:1,y=(r.actualBoundingBoxRight??c)*m,b=(r.actualBoundingBoxLeft??0)*m,x=((r.actualBoundingBoxAscent??0)-(r.actualBoundingBoxDescent??0))/2*m;f=l?v+o+b:_-o-y,p=s-i+x,h={...a,fontSize:a.fontSize*m},g=c*m}else{let t=d===void 0?L(e,` `):d;l?/\d/.test(n.listMarker)?(m=`rtl`,f=v+t+c):f=v+t:f=_-c-t}t.children.unshift({type:`text`,text:n.listMarker,x:f,y:p,width:g,style:{...h,textDecorationLine:`none`,textDecorations:[],fontWeight:i?.fontWeight??400,fontStyle:i?.fontStyle??`normal`,direction:m}});let y=m===`rtl`?f-g:f;I.push({y:Math.round(s),text:n.listMarker,bounds:{x:y,y:t.y+r.borderTopWidth+r.paddingTop,width:g,height:o.ascent+o.descent}})}function _t(e,t,n,r=!0,i){P=r,F=i,ce.clear(),xe.clear(),se.clear(),ie.clear(),ne.clear(),re.clear(),I=[];let{box:a,height:o}=Q(e,t,0,0,n);vt(e,a,t);let s=I.slice().sort((e,t)=>e.y-t.y||e.bounds.x-t.bounds.x),c=[];for(let e of s){let t=c[c.length-1],n=Math.min(t?.bounds.height??1/0,e.bounds.height)*.5;if(t&&Math.abs(e.y-t.y)<n){let n=t.text.length>0&&e.text.length>0&&!/\s$/.test(t.text)&&!/^\s/.test(e.text);t.text+=(n?` `:``)+e.text,t.y=Math.max(t.y,e.y);let r=Math.min(t.bounds.x,e.bounds.x),i=Math.min(t.bounds.y,e.bounds.y),a=Math.max(t.bounds.x+t.bounds.width,e.bounds.x+e.bounds.width),o=Math.max(t.bounds.y+t.bounds.height,e.bounds.y+e.bounds.height);t.bounds={x:r,y:i,width:a-r,height:o-i}}else c.push({y:e.y,text:e.text,bounds:{...e.bounds}})}return{root:a,height:o,lines:c}}function vt(e,t,n){gt(e,t,n);let r=0;for(let i of n.children)if(!(i.tagName===`#text`||q(i)))for(;r<t.children.length;){let n=t.children[r];if(n.type===`box`&&n.tagName===i.tagName){vt(e,n,i),r++;break}r++}}function yt(e){if(!e||e===`none`)return[];let t=[],n=e.split(/,(?![^(]*\))/);for(let e of n){let n=e.trim(),r=n.match(/(rgb[a]?\([^)]+\)|#[0-9a-fA-F]+|\b[a-z]+\b)(?:\s|$)/i),i=n.match(/-?[\d.]+px/g);if(i&&i.length>=2){let e=i.map(e=>parseFloat(e));t.push({offsetX:e[0],offsetY:e[1],blur:e[2]||0,color:r?r[1]:`rgba(0,0,0,1)`})}}return t}function bt(e,t){return e[`border${t}Width`]>0&&e[`border${t}Style`]!==`none`}function xt(e,t,n){let{borderTopLeftRadius:r,borderTopRightRadius:i,borderBottomRightRadius:a,borderBottomLeftRadius:o}=e;if(r===0&&i===0&&a===0&&o===0)return null;let s=[r,i,a,o].map(e=>{if(typeof e==`number`)return{x:e,y:e};let r=e.pct/100;return{x:r*t,y:r*n}}),[c,l,u,d]=s,f=1;for(let[e,r]of[[t,c.x+l.x],[t,d.x+u.x],[n,c.y+d.y],[n,l.y+u.y]])r>e&&(f=Math.min(f,e/r));return s.map(e=>({x:e.x*f,y:e.y*f}))}function St(e,t,n,r,i,a,o){if(n=Math.round(n-i/2)+i/2,e.save(),e.strokeStyle=o,e.lineWidth=i,a===`double`){let a=Math.max(i,2);e.lineWidth=Math.max(.5,i*.5),e.beginPath(),e.moveTo(t,n-a/2),e.lineTo(t+r,n-a/2),e.moveTo(t,n+a/2),e.lineTo(t+r,n+a/2),e.stroke()}else if(a===`wavy`){let a=Math.max(1.5,i),o=a*4;e.beginPath(),e.moveTo(t,n);for(let i=t;i<t+r;i+=o)e.quadraticCurveTo(i+o/4,n-a,i+o/2,n),e.quadraticCurveTo(i+o*3/4,n+a,i+o,n);e.stroke()}else a===`dotted`?e.setLineDash([i,i*2]):a===`dashed`&&e.setLineDash([i*3,i*2]),e.beginPath(),e.moveTo(t,n),e.lineTo(t+r,n),e.stroke();e.setLineDash([]),e.restore()}function Ct(e,t,n,r,i,a){let o=t.indexOf(`linear-gradient(`);if(o===-1)return null;let s=0,c=-1;for(let e=o+16;e<t.length;e++)if(t[e]===`(`)s++;else if(t[e]===`)`){if(s===0){c=e;break}s--}if(c===-1)return null;let l=t.slice(o+16,c),u=[];s=0;let d=0,f=l;for(let e=0;e<f.length;e++)f[e]===`(`?s++:f[e]===`)`?s--:f[e]===`,`&&s===0&&(u.push(f.slice(d,e).trim()),d=e+1);u.push(f.slice(d).trim());let p=180,m=0,h=u[0];h.endsWith(`deg`)?(p=parseFloat(h),m=1):h===`to right`?(p=90,m=1):h===`to left`?(p=270,m=1):h===`to bottom`?(p=180,m=1):h===`to top`&&(p=0,m=1);let g=(p-90)*Math.PI/180,_=n+r/2,v=i+a/2,y=Math.abs(r*Math.cos(g))+Math.abs(a*Math.sin(g)),b=Math.cos(g)*y/2,x=Math.sin(g)*y/2,S=e.createLinearGradient(_-b,v-x,_+b,v+x),C=u.slice(m);for(let e=0;e<C.length;e++){let t=C[e].trim(),n=t,r=e/Math.max(1,C.length-1),i=t.match(/\s+([\d.]+%)\s*$/);i&&(r=parseFloat(i[1])/100,n=t.slice(0,t.length-i[0].length).trim());try{S.addColorStop(r,n)}catch{}}return S}function wt(e){return e.webkitTextFillColor&&e.webkitTextFillColor!==`transparent`?e.webkitTextFillColor:e.color}function Tt(e){return Math.max(1,Math.floor(e/10))}function Et(e){let t=e.declarer.textDecorationThickness;return t===null?Tt(e.declarer.fontSize):t<=0?0:Math.max(1,Math.round(t))}function Dt(e,t){let n=e.declarer.textUnderlineOffset;return n===null?e.declarer.textDecorationThickness===null?null:Math.ceil(t/2)+t/2:n+t/2}function Ot(e,t,n){e.strokeStyle=n||t.webkitTextStrokeColor||t.color,e.lineWidth=t.webkitTextStrokeWidth;let r=t.strokeLinejoin;e.lineJoin=r===`miter`||r===`bevel`?r:`round`}function kt(e,t,n,r){let{style:i}=t;e.save(),e.font=B(i),e.textBaseline=`alphabetic`,e.fontKerning=i.fontKerning===`none`?`none`:`normal`,Number.isFinite(i.letterSpacing)&&i.letterSpacing!==0&&(e.letterSpacing=`${i.letterSpacing}px`),i.wordSpacing&&(e.wordSpacing=`${i.wordSpacing}px`),i.direction===`rtl`&&(e.direction=`rtl`,e.textAlign=`right`);let a=De(i),o=i.webkitTextStrokeWidth>0,s=i.webkitTextFillColor===`transparent`||i.color===`transparent`,c=t.clip?(t.clip.image?Ct(e,t.clip.image,t.clip.x,t.clip.width,t.clip.y,t.clip.height):null)??t.clip.color??null:null,l=a||(n!=null||c!=null)&&s,u=c??n??null,d=(t.strokeImage?Ct(e,t.strokeImage.image,t.strokeImage.x,t.strokeImage.width,t.strokeImage.y,t.strokeImage.height):null)??r??null,f=yt(i.textShadow);if(f.length>0){let n=l||!s;for(let r of f)e.save(),e.shadowOffsetX=r.offsetX,e.shadowOffsetY=r.offsetY,e.shadowBlur=r.blur,e.shadowColor=r.color,n&&(e.fillStyle=l&&u?u:wt(i),e.fillText(t.text,t.x,t.y)),o&&(Ot(e,i,d),e.strokeText(t.text,t.x,t.y)),e.restore()}let p=()=>{l?(e.save(),e.fillStyle=u||i.color,e.fillText(t.text,t.x,t.y),e.restore()):s||(e.fillStyle=wt(i),e.fillText(t.text,t.x,t.y))},m=()=>{o&&(e.save(),Ot(e,i,d),e.strokeText(t.text,t.x,t.y),e.restore())};y(i.paintOrder)?(m(),p()):(p(),m());let h=t.width,g=i.direction===`rtl`?t.x-h:t.x;if(i.textDecorations.length>0)for(let n of i.textDecorations){let r=Et(n);if(r<=0)continue;let a=n.color;if(J(n.color))if(u)a=u;else continue;let o=n.style||`solid`,s=i.webkitTextStrokeWidth>0?i.webkitTextStrokeWidth:0,c=d||i.webkitTextStrokeColor||i.color,l=t=>{let n=typeof c==`string`&&J(c);if(s>0&&!n){St(e,g,t,h,r+s,o,c);let n=r-s;n>0&&St(e,g,t,h,n,o,a)}else St(e,g,t,h,r,o,a)};if(n.line===`underline`){let e=t.lineBaselineY!==void 0&&!Se(n.declarer.verticalAlign)?t.lineBaselineY:t.y,i=Dt(n,r);l(i===null?e+n.declarer.fontSize*.105-.2:e+i)}else if(n.line===`line-through`)l(t.y-i.fontSize*.33);else if(n.line===`overline`){let{ascent:n}=Y(e,i);l(Math.floor(t.y-n)-r/2)}}e.restore()}var At=/^[\p{Script=Latin}\p{Script=Cyrillic}\p{Script=Greek}\p{Mark}\p{Number}\p{Punctuation}\p{Separator}]+$/u;function jt(e){let{style:t}=e;return t.direction===`ltr`&&t.textAlign!==`justify`&&t.textDecorations.length===0&&t.textShadow===`none`&&t.webkitTextStrokeWidth===0&&!e.clip&&!e.strokeImage&&At.test(e.text)}function Mt(e,t,n=null,r=null){let{style:i}=t,a=xt(i,t.width,t.height);if(!J(i.backgroundColor)&&i.webkitBackgroundClip!==`text`&&(e.fillStyle=i.backgroundColor,a?(e.beginPath(),e.roundRect(t.x,t.y,t.width,t.height,a),e.fill()):e.fillRect(t.x,t.y,t.width,t.height)),a!==null&&bt(i,`Top`)&&[`Right`,`Bottom`,`Left`].every(e=>i[`border${e}Width`]===i.borderTopWidth&&i[`border${e}Style`]===i.borderTopStyle&&i[`border${e}Color`]===i.borderTopColor)){let n=i.borderTopWidth;e.strokeStyle=i.borderTopColor,e.lineWidth=n,e.beginPath(),e.roundRect(t.x+n/2,t.y+n/2,t.width-n,t.height-n,a.map(e=>({x:Math.max(0,e.x-n/2),y:Math.max(0,e.y-n/2)}))),e.stroke()}else{let n=[[`Top`,t.x,t.y+i.borderTopWidth/2,t.x+t.width,t.y+i.borderTopWidth/2],[`Right`,t.x+t.width-i.borderRightWidth/2,t.y,t.x+t.width-i.borderRightWidth/2,t.y+t.height],[`Bottom`,t.x,t.y+t.height-i.borderBottomWidth/2,t.x+t.width,t.y+t.height-i.borderBottomWidth/2],[`Left`,t.x+i.borderLeftWidth/2,t.y,t.x+i.borderLeftWidth/2,t.y+t.height]];for(let[t,r,a,o,s]of n)bt(i,t)&&(e.strokeStyle=i[`border${t}Color`],e.lineWidth=i[`border${t}Width`],e.beginPath(),e.moveTo(r,a),e.lineTo(o,s),e.stroke())}if(De(i)){let r=i.backgroundImage&&i.backgroundImage!==`none`?Ct(e,i.backgroundImage,t.x,t.width,t.y,t.height):null,a=J(i.backgroundColor)?null:i.backgroundColor;n=r??a??n}i.webkitTextStrokeImage&&i.webkitTextStrokeImage!==`none`&&(r=Ct(e,i.webkitTextStrokeImage,t.x,t.width,t.y,t.height));let o=pe&&t.children.every(e=>e.type===`text`&&jt(e))?t.children:null;if(!o){for(let i of t.children)Nt(e,i,n,r);return}for(let t=0;t<o.length;t++){let i=o[t],a=i.text,s=i.width;for(;t+1<o.length&&o[t+1].style===i.style&&o[t+1].y===i.y&&Math.abs(o[t+1].x-(i.x+s))<=.01;)a+=o[t+1].text,s+=o[t+1].width,t++;kt(e,{...i,text:a,width:s},n,r)}}function Nt(e,t,n,r){t.type===`text`?kt(e,t,n,r):Mt(e,t,n,r)}var Pt=null;function Ft(e){let{html:t,width:n,height:r,accuracy:a=`performance`,debug:s}=e;if(!n||n<=0||Number.isNaN(n))throw TypeError(`layout: width must be a positive number, got ${n}`);let c=a===`balanced`,{fragment:l,css:u}=o(t),d=te(l,u,n),f=e.ctx??(Pt??=i(!0));f.fontKerning=`normal`;let{root:p,height:m,lines:h}=_t(f,d,n,c,s);return{layoutRoot:p,height:r||m,lines:h}}function It(e){let{layout:t,width:n,pixelRatio:r=globalThis.devicePixelRatio??1}=e;if(e.ctx&&e.canvas)throw TypeError(`drawLayout: ctx and canvas are mutually exclusive — provide one or neither`);let i=t.height,a,o;if(e.ctx)o=e.ctx,a=e.ctx.canvas;else{if(!e.canvas&&typeof document>`u`)throw Error(`render-tag: drawLayout cannot create a canvas in a non-browser environment — pass ctx or canvas.`);a=e.canvas??document.createElement(`canvas`),a.width=Math.ceil(n*r),a.height=Math.ceil(i*r),`style`in a&&(a.style.width=`${n}px`,a.style.height=`${i}px`),o=a.getContext(`2d`),o.scale(r,r)}return Nt(o,t.layoutRoot),{canvas:a}}function Lt(e){if(e.ctx&&e.canvas)throw TypeError(`render: ctx and canvas are mutually exclusive — provide one or neither`);let t=Ft({html:e.html,width:e.width,height:e.height,accuracy:e.accuracy,debug:e.debug,ctx:e.ctx}),{canvas:n}=It({layout:t,width:e.width,ctx:e.ctx,canvas:e.canvas,pixelRatio:e.pixelRatio});return{canvas:n,height:t.height,layoutRoot:t.layoutRoot,lines:t.lines}}e.drawLayout=It,e.getFontMetrics=Y,e.layout=Ft,e.lineBaselineOffset=ge,e.render=Lt,e.setDOMParser=r,e.tabStopMetrics=_e});
|
|
8
|
+
`,width:0,style:r.style,isSpace:!1,boxStyle:r.boxStyle}),a[t]){let o=n.length;Fe(e,a[t],r,n),i(o)}}else{let a=n.length;Fe(e,t,r,n),i(a)}}return n}function X(e){let t=e.codePointAt(0)||0;return t>=19968&&t<=40959||t>=13312&&t<=19903||t>=12288&&t<=12351||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=44032&&t<=55215||t>=65280&&t<=65519||t>=131072&&t<=173791}var Le;function Re(){return Le||(typeof Intl<`u`&&Intl.Segmenter?(Le=new Intl.Segmenter(void 0,{granularity:`grapheme`}),Le):null)}function ze(e){let t=Re();return t?[...t.segment(e)].map(e=>e.segment):[...e]}var Be=/\p{Extended_Pictographic}/u,Ve=/[\u{1F000}-\u{10FFFF}\u200D\uFE0F]/u;function He(e){for(let t of e)if(t.codePointAt(0)>=126976)return!0;return e.includes(``)||e.includes(`️`)?Be.test(e):!1}function Ue(e){return e.split(/(?<=[^]-)/).filter(Boolean)}function We(e,t,n,r){let i=[...t.text].some(X),a=!!Re()&&Ve.test(t.text)&&ze(t.text).some(He),o=t.width>n&&(t.style.overflowWrap===`break-word`||t.style.wordBreak===`break-all`);if(!i&&!a&&!o)return{pieces:[t],emergency:!1};let s=o&&!i&&!a&&t.style.wordBreak!==`break-all`;e.font=z(t.style),e.letterSpacing=R(t.style.letterSpacing);let c=a?ze(t.text):[...t.text],l=[],u=``,d=0,f=``,p=0,m=0;for(let r of c){let i=f+r,s=I(e,i),c=s-p;if(a&&He(r)){u&&(l.push({...t,text:u,width:d}),u=``,d=0),l.push({...t,text:r,width:c}),m=s,f=i,p=s;continue}if(X(r)){u&&(l.push({...t,text:u,width:d}),u=``,d=0),l.push({...t,text:r,width:c}),m=s,f=i,p=s;continue}let h=u+r,g=s-m;if(o&&g>n&&u){l.push({...t,text:u,width:d}),u=r,d=c,m=p,f=i,p=s;continue}u=h,d=g,f=i,p=s}return u&&l.push({...t,text:u,width:d}),{pieces:l,emergency:s}}var Ge=/^[,.\;:!?\)\]\}'"»›」』】〕〉》”、。・!),:;?၊-၏។-៖៘-៚]+$/,Ke=/^[\(\[\{«‹“‘「『【〔〈《(]+$/;function qe(e,t){let n=0;for(let r=t;r<e.length;r++){let t=e[r];if(t.isSpace||t.text===`
|
|
9
|
+
`)break;let i=!!t.text&&Ge.test(t.text),a=!t.text&&!!t.boxClose,o=!!t.text&&!!t.noBreakBefore;if(!i&&!a&&!o)break;n+=t.width}return n}function Je(e,t,n,r,i=!1,a=0,o,s=0){let c=[],l=()=>({words:[],totalWidth:0,lineHeight:s}),u=l(),d=r===`nowrap`||r===`pre`,f=()=>n-(c.length===0?a:0),p=r===`pre-wrap`||r===`pre`||r===`pre-line`,m=r===`pre`||r===`pre-wrap`||r===`break-spaces`;function h(t=!1){let i=u.words.length>0;if(!(r===`break-spaces`||m&&!t))for(;u.words.length>0&&u.words[u.words.length-1].isSpace;)u.totalWidth-=u.words[u.words.length-1].width,u.words.pop();if(t&&u.words.length>0){let t=u.words[u.words.length-1];if(t.isSoftHyphenBreak){L(e,t.style);let n=I(e,`-`);u.words.push({text:`-`,width:n,style:t.style,parentStyle:t.parentStyle,isSpace:!1,clipStyle:t.clipStyle,strokeImageStyle:t.strokeImageStyle}),u.totalWidth+=n}}if(u.words.length>0||i&&p){if(P){let e=u.words.map(e=>e.text).join(``);P({type:`line-commit`,message:`Line ${c.length}: "${e}" width=${u.totalWidth.toFixed(2)} / ${n}`,data:{lineIndex:c.length,text:e,totalWidth:u.totalWidth,contentWidth:n}})}c.push(u)}u=l()}let g=!0;for(let r=0;r<t.length;r++){let s=t[r],p=U(e,s.style,i);if(s.inlineBlockLayout)p=Math.max(p,s.inlineBlockLayout.marginBoxHeight);else if(s.boxStyle&&s.boxStyle.display===`inline-block`){let e=ye(s.boxStyle);p+=Math.max(0,e.top+e.bottom)}if(s.text===`
|
|
10
|
+
`){u.words.length===0?(u.lineHeight=Math.max(u.lineHeight,p),u.endedByHardBreak=!0,c.push(u),u=l()):(u.endedByHardBreak=!0,h()),g=!0;continue}if(d){u.words.push(s),u.totalWidth+=s.width,u.lineHeight=Math.max(u.lineHeight,p);continue}if(!s.isSpace&&s.text&&!s.noBreakBefore&&!s.boxOpen&&!s.boxClose){let n=r;for(;n+1<t.length;){let e=t[n+1];if(!e.text||e.isSpace||e.boxOpen||e.boxClose||!e.noBreakBefore)break;n++}if(n>r){let a=s.style.overflowWrap===`break-word`||s.style.wordBreak===`break-all`,o=0;for(let e=r;e<=n;e++)o+=t[e].width;let c=[];for(let e=r;e<=n;e++)for(let n of[...t[e].text])c.push({ch:n,style:t[e].style,parentStyle:t[e].parentStyle,clipStyle:t[e].clipStyle,strokeImageStyle:t[e].strokeImageStyle});let l=Ue(c.map(e=>e.ch).join(``)),d=l.length>1;if(!(u.totalWidth+o<=f())&&(d||a&&o>f())){let t=[],o=0;for(let e of l){let n=[...e].length;t.push(c.slice(o,o+n)),o+=n}let s=(t,n)=>{let r=0;for(;r<t.length;){let a=t[r].style,o=t[r].clipStyle,s=t[r].strokeImageStyle,c=t[r].parentStyle;L(e,a),e.letterSpacing=R(a.letterSpacing);let l=U(e,a,i),d=``,p=0;for(;r<t.length&&t[r].style===a;){let i=t[r].ch,m=I(e,d+i);n&&u.totalWidth+m>f()&&(u.words.length>0||d)?(d&&(u.words.push({text:d,width:p,style:a,isSpace:!1,parentStyle:c,clipStyle:o,strokeImageStyle:s}),u.totalWidth+=p,u.lineHeight=Math.max(u.lineHeight,l)),h(!0),g=!1,d=i,p=I(e,i)):(d+=i,p=m),r++}d&&(u.words.push({text:d,width:p,style:a,isSpace:!1,parentStyle:c,clipStyle:o,strokeImageStyle:s}),u.totalWidth+=p,u.lineHeight=Math.max(u.lineHeight,l),g=!1)}},p=t=>{let n=0,r=0;for(;r<t.length;){let i=t[r].style,a=``;for(;r<t.length&&t[r].style===i;)a+=t[r].ch,r++;L(e,i),e.letterSpacing=R(i.letterSpacing),n+=I(e,a)}return n};!d&&u.words.length>0&&(h(!0),g=!1);for(let e of t){let t=p(e);u.words.length>0&&u.totalWidth+t>f()&&(h(!0),g=!1),s(e,a&&t>f())}r=n;continue}}}let _=!s.isSpace&&s.text.length>1?We(e,s,f(),u.totalWidth):{pieces:[s],emergency:!1},v=_.pieces;_.emergency&&u.words.some(e=>!e.isSpace)&&(h(!0),g=!1);let y=qe(t,r+1);for(let i=0;i<v.length;i++){let s=v[i],l=i===v.length-1,d=l?y:0;for(let e=i+1;e<v.length;e++){let t=v[e];if(!t.text||!Ge.test(t.text))break;d+=t.width,e===v.length-1&&(d+=y)}let _=!s.isSpace&&s.text.length>0&&Ge.test(s.text)&&u.words.length>0&&!u.words[u.words.length-1].isSpace,b=u.words.length>0&&!u.words[u.words.length-1].isSpace&&(s===v[0]&&s.noBreakBefore||!s.text&&!!s.boxClose),x=0,S=Ke.test(s.text);if(S&&!l)x=v[i+1].width;else if(!s.text&&s.boxOpen||S&&y===0){let n=r+1;for(;n<t.length&&!t[n].text&&t[n].boxOpen;)x+=t[n].width,n++;let i=t[n];if(i&&!i.isSpace&&i.text){let r=i.text.length>1?We(e,i,f(),0).pieces:[i];x+=r[0].width,r.length===1&&(x+=qe(t,n+1))}}let C=0;s.isSoftHyphenBreak&&(L(e,s.style),e.letterSpacing=R(s.style.letterSpacing),C=I(e,`-`));let w=u.totalWidth+s.width+C+d+x;if(!s.isSpace&&!_&&!b&&u.words.length>0&&w>f()){let t=w-f(),r=!0;if(t<1&&!u.words.some(e=>e.isTab)&&!oe([...u.words,s])){L(e,s.style);let t=u.words.map(e=>e.text).join(``)+s.text+(s.isSoftHyphenBreak?`-`:``),n=0;for(let e of u.words)e.text?e.isSpace&&(n+=e.style.wordSpacing):n+=e.width;s.text?s.isSpace&&(n+=s.style.wordSpacing):n+=s.width,I(e,t)+n+d+x<=f()+.02&&(r=!1)}if(r){if(P){let e=u.words.map(e=>e.text).join(``);P({type:`line-wrap`,message:`"${s.text}" overflow=${t.toFixed(2)} wrap=true lineWidth=${u.totalWidth.toFixed(2)} pieceWidth=${s.width.toFixed(2)} contentWidth=${n} line="${e}"`,data:{text:s.text,overflow:t,lineWidth:u.totalWidth,pieceWidth:s.width,contentWidth:n,lineText:e}})}h(!0),g=!1}}if(s.isSpace&&u.words.length===0&&(!g||!m))continue;let T=s.width;if(s.isTab){let e=o?.interval||s.width,t=o?.halfSpace??0,n=e-((c.length===0?a:0)+u.totalWidth)%e;n<t&&(n+=e),T=n,s.width=T}u.words.push(s),u.totalWidth+=T,u.lineHeight=Math.max(u.lineHeight,p),s.isSpace||(g=!1)}}return h(),c}function Ye(e,t,n,r){for(let i of t){let t=i.inlineBlock;if(!t)continue;let a=t.style,o=Q(a),s=st(a),c=Math.max(0,i.width-o-s),l=Math.max(0,n-o-s),u=a.width>0?Math.max(0,a.width-s):Math.min(c,Math.max(ct(e,t),l));a.minWidth!==null&&(u=Math.max(u,Math.max(0,a.minWidth-s)));let d=Xe(e,t,0,0,u,r),f=d.height||U(e,a,r),p=d.lines.at(-1)?.y??G(e,a,r).ascent,m=ye(a),h=m.top+p,g=m.top+f+m.bottom;i.width=o+s+u,i.inlineBlockLayout={nodes:d.nodes,lines:d.lines,contentWidth:u,contentHeight:f,baselineOffset:h,marginBoxHeight:g}}}function Xe(e,t,n,r,i,a=!1,o){let s=[],c=[],l=new Map,u=new Map;if(o&&(o.exhausted||o.remaining<=0))return o.exhausted=!0,{nodes:s,height:0,lines:c};let d=je(t);if(d.length===0)return{nodes:s,height:0,lines:c};let f=Ie(e,d);Ye(e,f,i,a);let p=t.style.textIndent||0,m=ve(e,t.style),h=U(e,t.style,a),g=Je(e,f,i,t.style.whiteSpace,a,p,m,h),_=o?o.remaining:t.style.lineClamp;if(_>0&&g.length>_){g.length=_;let t=g[_-1];Ae(e,t,i-(_===1?p:0)),t.endedByHardBreak=!0,o&&(o.remaining=0,o.exhausted=!0)}else o&&(o.remaining-=g.length);let v=t.style.direction===`rtl`,y=e=>e===`start`?v?`right`:`left`:e===`end`?v?`left`:`right`:e,b=y(t.style.textAlign),x=t.style.textAlignLast||`auto`;x=x===`auto`?t.style.textAlign===`justify`?v?`right`:`left`:b:y(x);let S=t.style,C=r;for(let r=0;r<g.length;r++){let o=g[r];if(o.words.length===0){C+=o.lineHeight;continue}let d=r===g.length-1,f=r===0,m=d||o.endedByHardBreak?x:b,h=f?p:0,_=i-h,y=0;if(m===`justify`&&o.totalWidth<_){let e=o.words.filter(e=>e.isSpace).length;e>0&&(y=(_-o.totalWidth)/e)}let w=o.totalWidth>_+.5,T=n+h;w?T=v?n+_-o.totalWidth:n+h:m===`center`?T=n+h+(_-o.totalWidth)/2:m===`right`?T=(v?n+_:n+h+_)-o.totalWidth:m===`justify`&&v&&(T=n+_-o.totalWidth);let ee=T,te=G(e,t.style,a),E=te.ascent,D=te.descent,O=(e,t)=>{e.ascent-t>E&&(E=e.ascent-t),e.descent+t>D&&(D=e.descent+t)};for(let t of o.words){if(t.text===``)continue;t.parentStyle&&O(G(e,t.parentStyle,a),Y(t.parentStyle.verticalAlign,e,t.parentStyle,S,a));let n=G(e,t.style,a),r=t.boxStyle?.display===`inline-block`?t.boxStyle:null;if(t.inlineBlockLayout){let e=t.inlineBlockLayout;n.ascent=e.baselineOffset,n.descent=e.marginBoxHeight-e.baselineOffset}else if(r){let e=ye(r);n.ascent+=e.top,n.descent+=e.bottom}O(n,r?0:Y(t.style.verticalAlign,e,t.style,t.parentStyle??S,a))}let k=E+D,A=C+E,j=(t,n,r,i)=>{let{ascent:o,descent:c}=t.display===`inline-block`?G(e,t,a):J(e,t),l=t.paddingTop+t.borderTopWidth,u=t.paddingBottom+t.borderBottomWidth,d=o+c+l+u,f=A;if(i&&t.display!==`inline-block`){let t=i.style.verticalAlign;Ce(t)&&(f+=Y(t,e,i.style,i.parentStyle??S,a))}let p=f-o-l;s.push({type:`box`,style:t,x:n,y:p,width:r,height:d,tagName:`span`,children:[]})};if(!v){let e=T,t=e,n,r;for(let i of o.words){if(i.boxOpen&&i.boxClose&&i.text){n&&(r&&j(n,t,e-t,r),n=void 0,r=void 0);let a=i.style,o=e+a.marginLeft;if(i.inlineBlockLayout){let e=i.inlineBlockLayout;s.push({type:`box`,style:a,x:o,y:A-e.baselineOffset+a.marginTop,width:a.borderLeftWidth+a.paddingLeft+e.contentWidth+a.paddingRight+a.borderRightWidth,height:a.borderTopWidth+a.paddingTop+e.contentHeight+a.paddingBottom+a.borderBottomWidth,tagName:`span`,children:[]})}else{let e=i.width-Q(a)-st(a);j(a,o,a.borderLeftWidth+a.paddingLeft+e+a.paddingRight+a.borderRightWidth,i)}r=void 0,e+=i.width;continue}i.boxStyle!==n&&(n&&r&&j(n,t,e-t,r),n=i.boxStyle,t=e,r=void 0),i.text&&!i.isSpace&&(r??=i),e+=i.width+(i.isSpace?y:0)}n&&r&&j(n,t,e-t,r)}let M=o.words.filter(e=>e.text!==``),ne=M.length>0&&M.every(e=>Ee(e.style,M[0].style));if(v){let t=[],n=null,r=0;for(let e of o.words){if(e.text===``){n&&=(t.push(n),null),r+=e.width;continue}if(e.isSpace&&y>0){n&&=(t.push(n),null),r+=e.width+y;continue}n&&Ee(n.style,e.style)?(n.text+=e.text,n.width+=e.width):(n&&t.push(n),n={text:e.text,style:e.style,width:e.width,boxStyle:e.boxStyle,clipStyle:e.clipStyle,strokeImageStyle:e.strokeImageStyle,x:0,padBefore:r},r=0)}n&&t.push(n);let i=T+o.totalWidth;for(let n of t){i-=n.padBefore,L(e,n.style);let t=I(e,n.text);i-=t,n.x=i,n.width=t}for(let e of t)if(e.boxStyle&&De(e.boxStyle)){let t=e.boxStyle,n=t.paddingLeft+t.borderLeftWidth,r=t.paddingRight+t.borderRightWidth;j(t,e.x-n,e.width+n+r)}for(let e of t){let t={type:`text`,text:e.text,x:e.x+e.width,y:A,width:e.width,style:{...e.style,direction:`rtl`}};s.push(t),e.clipStyle&&l.set(t,e.clipStyle),e.strokeImageStyle&&u.set(t,e.strokeImageStyle)}}else{let t=o.words.map(e=>e.text).join(``);if(ne&&/[\u0590-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(t)&&!o.words.some(e=>e.boxOpen||e.boxClose||e.style.verticalAlign===`super`||e.style.verticalAlign===`sub`)){L(e,M[0].style);let n=I(e,t),r={type:`text`,text:t,x:T,y:A,width:n,style:{...M[0].style,direction:`ltr`}};s.push(r),M[0].clipStyle&&l.set(r,M[0].clipStyle),M[0].strokeImageStyle&&u.set(r,M[0].strokeImageStyle)}else for(let t of o.words){if(t.text===``){T+=t.width;continue}if(t.boxOpen&&t.boxClose){let n=t.style,r=T+n.marginLeft+n.borderLeftWidth+n.paddingLeft;if(t.inlineBlockLayout){let e=t.inlineBlockLayout,i=A-e.baselineOffset+n.marginTop+n.borderTopWidth+n.paddingTop,a=e=>{if(e.x+=r,e.y+=i,e.type===`text`)e.lineBaselineY!==void 0&&(e.lineBaselineY+=i),e.clip&&(e.clip.x+=r,e.clip.y+=i),e.strokeImage&&(e.strokeImage.x+=r,e.strokeImage.y+=i);else for(let t of e.children)a(t)};for(let t of e.nodes)a(t),s.push(t);for(let t of e.lines.slice(0,-1)){let e={y:Math.round(t.y+i),text:t.text,bounds:{x:t.bounds.x+r,y:t.bounds.y+i,width:t.bounds.width,height:t.bounds.height}};c.push(e)}T+=t.width;continue}let i={type:`text`,text:t.text,x:r,y:A,width:I(e,t.text),style:t.style};s.push(i),t.clipStyle&&l.set(i,t.clipStyle),t.strokeImageStyle&&u.set(i,t.strokeImageStyle),T+=t.width;continue}let n=A,r=t.style.verticalAlign;Ce(r)&&(n+=Y(r,e,t.style,t.parentStyle??S,a));let i=t.width+(t.isSpace?y:0),o={type:`text`,text:t.text,x:T,y:n,width:i,style:t.style,...n===A?{}:{lineBaselineY:A}};s.push(o),t.clipStyle&&l.set(o,t.clipStyle),t.strokeImageStyle&&u.set(o,t.strokeImageStyle),T+=i}}let N=m===`justify`&&y>0?_:o.totalWidth,P={y:Math.round(A),text:o.words.map(e=>e.inlineBlockLayout?.lines.at(-1)?.text??e.text).join(``),bounds:{x:ee,y:C,width:N,height:k}};c.push(P),C+=k}return Ze(e,s,l,(e,t,n)=>{e.clip={image:t.backgroundImage&&t.backgroundImage!==`none`?t.backgroundImage:void 0,color:q(t.backgroundColor)?void 0:t.backgroundColor,...n}}),Ze(e,s,u,(e,t,n)=>{e.strokeImage={image:t.webkitTextStrokeImage,...n}}),{nodes:s,height:C-r,lines:c}}function Ze(e,t,n,r){if(n.size===0)return;let i=e=>e.style.direction===`rtl`?{left:e.x-e.width,right:e.x}:{left:e.x,right:e.x+e.width};for(let a=0;a<t.length;){let o=t[a],s=o.type===`text`?n.get(o):void 0;if(!s){a++;continue}let c=a,l=1/0,u=-1/0;for(;c<t.length;){let e=t[c];if(e.type!==`text`||n.get(e)!==s||e.y!==o.y)break;let r=i(e);r.left<l&&(l=r.left),r.right>u&&(u=r.right),c++}let{ascent:d,descent:f}=J(e,s),p={x:l,y:o.y-d,width:u-l,height:d+f};for(let e=a;e<c;e++)r(t[e],s,p);a=c}}function Qe(e,t){return e>=0&&t>=0?Math.max(e,t):e<0&&t<0?Math.min(e,t):e+t}function $e(e){let t=e.style.display;return t===`block`||t===`list-item`||t===`flex`||t===`table`||t===`table-row`||t===`table-cell`||t===`table-row-group`||t===`table-header-group`||t===`table-footer-group`}function et(e){let t=e.style.display;return(t===`block`||t===`list-item`)&&(e.tagName===`li`||e.tagName===`ul`||e.tagName===`ol`||e.tagName===`dd`||e.tagName===`dt`)}function tt(e){let t=e.style.marginTop;if(!et(e)||e.style.paddingTop!==0||e.style.borderTopWidth!==0)return t;let n=e.children[0];return n&&$e(n)?Qe(t,tt(n)):t}function Z(e,t,n,r,i,a){let o=t.style;!a&&o.lineClamp>0&&(a={remaining:o.lineClamp,exhausted:!1});let s=o.marginLeft,c=o.marginRight,l=o.borderLeftWidth,u=o.borderRightWidth,d=o.borderTopWidth,f=o.borderBottomWidth,p=o.paddingLeft,m=o.paddingRight,h=o.paddingTop,g=o.paddingBottom,_=n+s,v=o.width>0?o.width:i-s-c,y=_+l+p,b=Math.max(0,v-l-u-p-m),x=r,S=x+d+h,C={type:`box`,style:o,x:_,y:x,width:v,height:0,tagName:t.tagName,children:[],listMarker:t.listMarker};if(o.display===`flex`){let n=gt(e,t,y,S,b);return C.children=n.children,C.height=d+h+n.height+g+f,{box:C,height:C.height,marginBottomOut:o.marginBottom}}if(o.display===`table`){let n=nt(e,t,y,S,b);return C.children=n.children,C.height=d+h+n.height+g+f,{box:C,height:C.height,marginBottomOut:o.marginBottom}}if(t.children.length===0)return C.height=d+h+g+f,o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:o.marginBottom};if(xe(t)){let{nodes:n,height:r,lines:i}=Xe(e,t,y,S,b,t.tagName===`li`&&ue.has(o.listStyleType),a);F.push(...i),C.children=n,C.height=d+h+r+g+f}else{let n=S,r=0,i=!1,s=et(t);for(let c=0;c<t.children.length;c++){let l=t.children[c];if(a&&(a.exhausted||a.remaining<=0)){a.exhausted=!0,r=0;break}if(l.tagName===`#text`||K(l)){let s=[l];for(;c+1<t.children.length;){let e=t.children[c+1];if(e.tagName===`#text`||K(e))s.push(e),c++;else break}n+=r,r=0;let u={element:null,tagName:`div`,style:{...t.style,display:`block`,marginTop:0,marginBottom:0,paddingTop:0,paddingBottom:0,borderTopWidth:0,borderBottomWidth:0},children:s,textContent:null},d=t.tagName===`li`&&ue.has(o.listStyleType),{nodes:f,height:p,lines:m}=Xe(e,u,y,n,b,d,a);F.push(...m),C.children.push(...f),n+=p,r=0,i=!0;continue}let u=tt(l);if(!(!i&&h===0&&d===0&&s)){let e=Qe(r,u);n+=e}let{box:f,height:p,marginBottomOut:m}=Z(e,l,y,n,b,a);C.children.push(f),n+=p,r=a?.exhausted?0:m,i=!0}let c=o.marginBottom,l=g===0&&f===0&&o.minHeight===0&&s;l&&(c=Qe(o.marginBottom,r));let u=n-S;return l||(u+=r),u=Math.max(0,u),C.height=d+h+u+g+f,o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:c}}return o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:o.marginBottom}}function nt(e,t,n,r,i){let a=[],o=[];for(let e of t.children)if(e.tagName===`tr`)o.push(e);else if([`thead`,`tbody`,`tfoot`].includes(e.tagName))for(let t of e.children)t.tagName===`tr`&&o.push(t);if(o.length===0)return{children:a,height:0};let s=Math.max(...o.map(e=>e.children.filter(e=>e.tagName===`td`||e.tagName===`th`).length));if(s===0)return{children:a,height:0};let c=i/s,l=r;for(let t of o){let r=t.children.filter(e=>e.tagName===`td`||e.tagName===`th`),i=0,o=[];for(let t=0;t<r.length;t++){let a=r[t],{box:s,height:u}=Z(e,a,n+t*c,l,c);o.push(s),i=Math.max(i,u)}for(let e of o)e.height=i,a.push(e);l+=i}return{children:a,height:l-r}}var rt=new WeakMap;function it(e){let t=rt.get(e);return t||(t={element:null,tagName:`div`,style:{...e.style,display:`block`},children:[e],textContent:null},rt.set(e,t)),t}function at(e){return e.children.filter(e=>e.tagName!==`#text`||e.textContent?.trim()).map(e=>e.tagName===`#text`?it(e):e)}function ot(e){return e.flexDirection===`row`||e.flexDirection===``}function st(e){return e.borderLeftWidth+e.paddingLeft+e.paddingRight+e.borderRightWidth}function Q(e){return e.marginLeft+e.marginRight}function ct(e,t){return Je(e,Ie(e,je(t)).map(e=>e.style.overflowWrap===`break-word`&&e.style.wordBreak!==`break-all`?{...e,style:{...e.style,overflowWrap:`normal`}}:e),0,t.style.whiteSpace).reduce((e,t)=>Math.max(e,t.totalWidth),0)}function lt(e,t){let n=re.get(t);if(n!==void 0)return n;let r=ut(e,t);return re.set(t,r),r}function ut(e,t){let n=Q(t.style),r=st(t.style);if(t.style.minWidth!==null)return n+Math.max(r,t.style.minWidth);let i=0;if(xe(t))i=ct(e,t);else if(t.style.display===`flex`&&ot(t.style)){let n=at(t);i=n.reduce((t,n)=>t+lt(e,n),0)+t.style.gap*Math.max(0,n.length-1)}else for(let n of t.children)n.tagName!==`#text`&&(i=Math.max(i,lt(e,n)));let a=r+i;return t.style.width>0&&(a=Math.min(a,t.style.width)),n+a}function dt(e,t){return Je(e,Ie(e,je(t)),1/0,t.style.whiteSpace).reduce((e,t)=>Math.max(e,t.totalWidth),0)}function ft(e,t){let n=ie.get(t);if(n!==void 0)return n;let r=pt(e,t);return ie.set(t,r),r}function pt(e,t){let n=Q(t.style);if(t.style.width>0)return n+t.style.width;let r=0;if(xe(t))r=dt(e,t);else if(t.style.display===`flex`&&ot(t.style)){let n=at(t);r=n.reduce((t,n)=>t+ft(e,n),0)+t.style.gap*Math.max(0,n.length-1)}else for(let n of t.children)n.tagName!==`#text`&&(r=Math.max(r,ft(e,n)));return n+st(t.style)+r}function mt(e,t){return t.style.flexBasis===null?ft(e,t):Q(t.style)+t.style.flexBasis}function ht(e,t,n,r){let i=t.map((e,t)=>Math.max(e,n[t])),a=i.reduce((e,t)=>e+t,0)<r,o=t=>a?e[t].flexGrow:e[t].flexShrink,s=i.map((e,n)=>o(n)===0||!a&&t[n]<e);for(;;){let o=i.map((e,t)=>t).filter(e=>!s[e]);if(o.length===0)break;let c=r-i.reduce((e,n,r)=>e+(s[r]?n:t[r]),0),l=o.map(n=>a?e[n].flexGrow:e[n].flexShrink*t[n]),u=l.reduce((e,t)=>e+t,0);if(u<=0)break;o.forEach((e,n)=>{i[e]=t[e]+c*l[n]/u});let d=o.filter(e=>i[e]<n[e]);if(d.length===0)break;for(let e of d)i[e]=n[e],s[e]=!0}return i}function gt(e,t,n,r,i){let a=t.style,o=a.gap,s=[],c=at(t);if(c.length===0)return{children:s,height:0};if(ot(a)){let t=o*(c.length-1),a=Math.max(0,i-t),l=ht(c.map(e=>e.style),c.map(t=>mt(e,t)),c.map(t=>lt(e,t)),a),u=n,d=0;for(let t=0;t<c.length;t++){let n=c[t],i=l[t],{box:a,height:f}=Z(e,n,u,r,i);s.push(a),d=Math.max(d,f),u+=i+o}return{children:s,height:d}}let l=r;for(let t of c){let{box:r,height:a}=Z(e,t,n,l,i);s.push(r),l+=a+o}return{children:s,height:l-r}}function _t(e,t,n){if(!n.listMarker||n.markerHidden)return;let r=n.style,i=n.markerStyle,a=i?{...r,...i}:r;e.font=z(a);let o=G(e,r),s=t.y+r.borderTopWidth+r.paddingTop+o.ascent,c=I(e,n.listMarker),l=r.direction===`rtl`,u=ue.has(r.listStyleType),d=l?i?.paddingLeft:i?.paddingRight,f,p=s,m=`ltr`,h=a,g=c,_=t.x+r.borderLeftWidth+r.paddingLeft,v=t.x+t.width;if(u){let{ascent:t}=J(e,a),r=e.measureText(n.listMarker),i=t/3,o=d===void 0?7+i:d,u=(r.actualBoundingBoxAscent??0)+(r.actualBoundingBoxDescent??0),m=u>0?i/u:1,y=(r.actualBoundingBoxRight??c)*m,b=(r.actualBoundingBoxLeft??0)*m,x=((r.actualBoundingBoxAscent??0)-(r.actualBoundingBoxDescent??0))/2*m;f=l?v+o+b:_-o-y,p=s-i+x,h={...a,fontSize:a.fontSize*m},g=c*m}else{let t=d===void 0?I(e,` `):d;l?/\d/.test(n.listMarker)?(m=`rtl`,f=v+t+c):f=v+t:f=_-c-t}t.children.unshift({type:`text`,text:n.listMarker,x:f,y:p,width:g,style:{...h,textDecorationLine:`none`,textDecorations:[],fontWeight:i?.fontWeight??400,fontStyle:i?.fontStyle??`normal`,direction:m}});let y=m===`rtl`?f-g:f;F.push({y:Math.round(s),text:n.listMarker,bounds:{x:y,y:t.y+r.borderTopWidth+r.paddingTop,width:g,height:o.ascent+o.descent}})}function vt(e,t,n,r=!0,i){N=r,P=i,le.clear(),Se.clear(),ce.clear(),ae.clear(),re.clear(),ie.clear(),F=[];let{box:a,height:o}=Z(e,t,0,0,n);yt(e,a,t);let s=F.slice().sort((e,t)=>e.y-t.y||e.bounds.x-t.bounds.x),c=[];for(let e of s){let t=c[c.length-1],n=Math.min(t?.bounds.height??1/0,e.bounds.height)*.5;if(t&&Math.abs(e.y-t.y)<n){let n=t.text.length>0&&e.text.length>0&&!/\s$/.test(t.text)&&!/^\s/.test(e.text);t.text+=(n?` `:``)+e.text,t.y=Math.max(t.y,e.y);let r=Math.min(t.bounds.x,e.bounds.x),i=Math.min(t.bounds.y,e.bounds.y),a=Math.max(t.bounds.x+t.bounds.width,e.bounds.x+e.bounds.width),o=Math.max(t.bounds.y+t.bounds.height,e.bounds.y+e.bounds.height);t.bounds={x:r,y:i,width:a-r,height:o-i}}else c.push({y:e.y,text:e.text,bounds:{...e.bounds}})}return{root:a,height:o,lines:c}}function yt(e,t,n){_t(e,t,n);let r=0;for(let i of n.children)if(!(i.tagName===`#text`||K(i)))for(;r<t.children.length;){let n=t.children[r];if(n.type===`box`&&n.tagName===i.tagName){yt(e,n,i),r++;break}r++}}function bt(e,t){let n=e.shadowColor;e.shadowColor=`transparent`;try{t(e)}finally{e.shadowColor=n}}function xt(e){if(typeof e.getTransform!=`function`||typeof e.setTransform!=`function`||typeof e.drawImage!=`function`)throw Error(`render-tag: shadows require a Canvas 2D context with getTransform, setTransform and drawImage. For vector adapters, set renderShadows: false and paint shadows separately.`)}function $(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-r}}function St(e,t){let n=[],r=[];for(let i of[e.x,e.x+e.width])for(let a of[e.y,e.y+e.height])n.push(t.a*i+t.c*a+t.e),r.push(t.b*i+t.d*a+t.f);return{x:Math.min(...n),y:Math.min(...r),width:Math.max(...n)-Math.min(...n),height:Math.max(...r)-Math.min(...r)}}function Ct(e,t,n,r,i,a,o=!1){let s=e.measureText(t),c=n.webkitTextStrokeWidth/2*(n.strokeLinejoin===`miter`?e.miterLimit:1),l=2+c;for(let e of n.textDecorations){let t=e.declarer.textDecorationThickness??Math.max(1,e.declarer.fontSize/15);l=Math.max(l,2+c+Math.abs(e.declarer.textUnderlineOffset??e.declarer.fontSize*.2)+t*4)}let u=Math.min(o?-a:0,-(s.actualBoundingBoxLeft||0)),d=Math.max(o?0:a,s.actualBoundingBoxRight||0),f=Math.max(n.fontSize,s.actualBoundingBoxAscent||0),p=Math.max(n.fontSize*.5,s.actualBoundingBoxDescent||0);return{x:r+u-l,y:i-f-l,width:d-u+l*2,height:f+p+l*2}}function wt(e,t){let n=e;for(let r of t){let t=Math.ceil(r.blur*2)+2;n=$(n,{x:e.x+r.offsetX-t,y:e.y+r.offsetY-t,width:e.width+t*2,height:e.height+t*2})}return n}function Tt(e,t,n,r){let i;if(r)i=r(t,n);else if(e.canvas.ownerDocument)i=e.canvas.ownerDocument.createElement(`canvas`);else if(typeof OffscreenCanvas<`u`)i=new OffscreenCanvas(t,n);else if(typeof document<`u`)i=document.createElement(`canvas`);else throw Error(`render-tag: shadows require a scratch canvas — provide createCanvas in non-browser environments.`);return i.width=t,i.height=n,i}function Et(e,t,n,r,i){let a=St(t,n),o=Math.floor(a.x)-1,s=Math.floor(a.y)-1,c=Tt(e,Math.max(1,Math.ceil(a.x+a.width)-o+1),Math.max(1,Math.ceil(a.y+a.height)-s+1),i),l=c.getContext(`2d`);if(!l)throw Error(`render-tag: createCanvas must provide a 2D canvas.`);for(let t of[`font`,`fontKerning`,`fontStretch`,`fontVariantCaps`,`textRendering`,`letterSpacing`,`wordSpacing`,`textAlign`,`textBaseline`,`direction`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`lineDashOffset`,`fillStyle`,`strokeStyle`,`imageSmoothingEnabled`,`imageSmoothingQuality`])t in e&&(l[t]=e[t]);return l.setLineDash(e.getLineDash()),l.setTransform(n.a,n.b,n.c,n.d,n.e-o,n.f-s),r(l),{canvas:c,x:o,y:s}}function Dt(e,t,n,r,i){let a=Math.ceil(n*2)+2,o=Tt(e,t.width+a*2,t.height+a*2,i),s=o.getContext(`2d`);if(!s)throw Error(`render-tag: createCanvas must provide a 2D canvas.`);let c=o.width+t.width;return s.shadowColor=r,s.shadowBlur=n,s.shadowOffsetX=c,s.drawImage(t,a-c,a),{canvas:o,pad:a}}function Ot(e,t,n,r){let i=e.shadowColor;if(!(i&&i!==`transparent`&&i!==`rgba(0, 0, 0, 0)`&&i!==`#00000000`&&(e.shadowBlur>0||e.shadowOffsetX!==0||e.shadowOffsetY!==0))){n(e);return}xt(e);let a=Et(e,t(),e.getTransform(),n,r),o=Dt(e,a.canvas,e.shadowBlur,i,r);e.save();try{e.setTransform(1,0,0,1,0,0),e.shadowColor=`transparent`,e.drawImage(o.canvas,a.x-o.pad+e.shadowOffsetX,a.y-o.pad+e.shadowOffsetY)}finally{e.restore(),e.shadowColor=i}bt(e,n)}function kt(e,t,n,r,i){if(!n.length)return;xt(e);let a=e.getTransform(),o=a.a*a.a+a.b*a.b+a.c*a.c+a.d*a.d,s=a.a*a.d-a.b*a.c,c=Math.abs(a.a*a.a+a.b*a.b-a.c*a.c-a.d*a.d)<1e-8&&Math.abs(a.a*a.c+a.b*a.d)<1e-8,l=c?Math.hypot(a.a,a.b):Math.max(1,Math.sqrt((o+Math.sqrt(Math.max(0,o*o-4*s*s)))/2));if(l===0)return;let u=Et(e,t,c?a:{a:l,b:0,c:0,d:l,e:0,f:0},r,i);e.save();try{c&&e.setTransform(1,0,0,1,0,0);for(let t=n.length-1;t>=0;t--){let r=n[t],{canvas:o,pad:s}=Dt(e,u.canvas,r.blur*l,r.color,i);c?e.drawImage(o,u.x-s+a.a*r.offsetX+a.c*r.offsetY,u.y-s+a.b*r.offsetX+a.d*r.offsetY):e.drawImage(o,(u.x-s)/l+r.offsetX,(u.y-s)/l+r.offsetY,o.width/l,o.height/l)}}finally{e.restore()}}function At(e,t=`black`){if(!e||e===`none`)return[];let n=[];for(let r of e.split(/,(?![^(]*\))/)){let e=r.trim().match(/[^\s(]+\([^)]*\)|[^\s]+/g)??[],i=[],a=t;for(let n of e)/^[+-]?(?:\d*\.)?\d+(?:px)?$/.test(n)?i.push(parseFloat(n)):a=n.toLowerCase()===`currentcolor`?t:n;i.length<2||i.length>3||(i[2]??0)<0||n.push({offsetX:i[0],offsetY:i[1],blur:i[2]??0,color:a})}return n}function jt(e,t){return e[`border${t}Width`]>0&&e[`border${t}Style`]!==`none`}function Mt(e,t,n){let{borderTopLeftRadius:r,borderTopRightRadius:i,borderBottomRightRadius:a,borderBottomLeftRadius:o}=e;if(r===0&&i===0&&a===0&&o===0)return null;let s=[r,i,a,o].map(e=>{if(typeof e==`number`)return{x:e,y:e};let r=e.pct/100;return{x:r*t,y:r*n}}),[c,l,u,d]=s,f=1;for(let[e,r]of[[t,c.x+l.x],[t,d.x+u.x],[n,c.y+d.y],[n,l.y+u.y]])r>e&&(f=Math.min(f,e/r));return s.map(e=>({x:e.x*f,y:e.y*f}))}function Nt(e,t,n,r,i,a,o){if(n=Math.round(n-i/2)+i/2,e.save(),e.strokeStyle=o,e.lineWidth=i,a===`double`){let a=Math.max(i,2);e.lineWidth=Math.max(.5,i*.5),e.beginPath(),e.moveTo(t,n-a/2),e.lineTo(t+r,n-a/2),e.moveTo(t,n+a/2),e.lineTo(t+r,n+a/2),e.stroke()}else if(a===`wavy`){let a=Math.max(1.5,i),o=a*4;e.beginPath(),e.moveTo(t,n);for(let i=t;i<t+r;i+=o)e.quadraticCurveTo(i+o/4,n-a,i+o/2,n),e.quadraticCurveTo(i+o*3/4,n+a,i+o,n);e.stroke()}else a===`dotted`?e.setLineDash([i,i*2]):a===`dashed`&&e.setLineDash([i*3,i*2]),e.beginPath(),e.moveTo(t,n),e.lineTo(t+r,n),e.stroke();e.setLineDash([]),e.restore()}function Pt(e,t,n,r,i,a){let o=t.indexOf(`linear-gradient(`);if(o===-1)return null;let s=0,c=-1;for(let e=o+16;e<t.length;e++)if(t[e]===`(`)s++;else if(t[e]===`)`){if(s===0){c=e;break}s--}if(c===-1)return null;let l=t.slice(o+16,c),u=[];s=0;let d=0,f=l;for(let e=0;e<f.length;e++)f[e]===`(`?s++:f[e]===`)`?s--:f[e]===`,`&&s===0&&(u.push(f.slice(d,e).trim()),d=e+1);u.push(f.slice(d).trim());let p=180,m=0,h=u[0];h.endsWith(`deg`)?(p=parseFloat(h),m=1):h===`to right`?(p=90,m=1):h===`to left`?(p=270,m=1):h===`to bottom`?(p=180,m=1):h===`to top`&&(p=0,m=1);let g=(p-90)*Math.PI/180,_=n+r/2,v=i+a/2,y=Math.abs(r*Math.cos(g))+Math.abs(a*Math.sin(g)),b=Math.cos(g)*y/2,x=Math.sin(g)*y/2,S=e.createLinearGradient(_-b,v-x,_+b,v+x),C=u.slice(m);for(let e=0;e<C.length;e++){let t=C[e].trim(),n=t,r=e/Math.max(1,C.length-1),i=t.match(/\s+([\d.]+%)\s*$/);i&&(r=parseFloat(i[1])/100,n=t.slice(0,t.length-i[0].length).trim());try{S.addColorStop(r,n)}catch{}}return S}function Ft(e){return e.webkitTextFillColor&&e.webkitTextFillColor!==`transparent`?e.webkitTextFillColor:e.color}function It(e){return Math.max(1,Math.floor(e/10))}function Lt(e){let t=e.declarer.textDecorationThickness;return t===null?It(e.declarer.fontSize):t<=0?0:Math.max(1,Math.round(t))}function Rt(e,t){let n=e.declarer.textUnderlineOffset;return n===null?e.declarer.textDecorationThickness===null?null:Math.ceil(t/2)+t/2:n+t/2}function zt(e,t,n){e.strokeStyle=n||t.webkitTextStrokeColor||t.color,e.lineWidth=t.webkitTextStrokeWidth;let r=t.strokeLinejoin;e.lineJoin=r===`miter`||r===`bevel`?r:`round`}function Bt(e,t){e.font=z(t),e.textBaseline=`alphabetic`,e.fontKerning=t.fontKerning===`none`?`none`:`normal`,Number.isFinite(t.letterSpacing)&&t.letterSpacing!==0&&(e.letterSpacing=`${t.letterSpacing}px`),t.wordSpacing&&(e.wordSpacing=`${t.wordSpacing}px`),t.direction===`rtl`&&(e.direction=`rtl`,e.textAlign=`right`)}function Vt(e,t,n,r){let{style:i}=t;e.save(),Bt(e,i);let a=Oe(i),o=i.webkitTextStrokeWidth>0,s=i.webkitTextFillColor===`transparent`||i.color===`transparent`,c=t.clip?(t.clip.image?Pt(e,t.clip.image,t.clip.x,t.clip.width,t.clip.y,t.clip.height):null)??t.clip.color??null:null,l=a||(n!=null||c!=null)&&s,u=c??n??null,d=(t.strokeImage?Pt(e,t.strokeImage.image,t.strokeImage.x,t.strokeImage.width,t.strokeImage.y,t.strokeImage.height):null)??r??null,f=()=>{l?(e.save(),e.fillStyle=u||i.color,e.fillText(t.text,t.x,t.y),e.restore()):s||(e.fillStyle=Ft(i),e.fillText(t.text,t.x,t.y))},p=()=>{o&&(e.save(),zt(e,i,d),e.strokeText(t.text,t.x,t.y),e.restore())};y(i.paintOrder)?(p(),f()):(f(),p());let m=t.width,h=i.direction===`rtl`?t.x-m:t.x;if(i.textDecorations.length>0)for(let n of i.textDecorations){let r=Lt(n);if(r<=0)continue;let a=n.color;if(q(n.color))if(u)a=u;else continue;let o=n.style||`solid`,s=i.webkitTextStrokeWidth>0?i.webkitTextStrokeWidth:0,c=d||i.webkitTextStrokeColor||i.color,l=t=>{let n=typeof c==`string`&&q(c);if(s>0&&!n){Nt(e,h,t,m,r+s,o,c);let n=r-s;n>0&&Nt(e,h,t,m,n,o,a)}else Nt(e,h,t,m,r,o,a)};if(n.line===`underline`){let e=t.lineBaselineY!==void 0&&!Ce(n.declarer.verticalAlign)?t.lineBaselineY:t.y,i=Rt(n,r);l(i===null?e+n.declarer.fontSize*.105-.2:e+i)}else if(n.line===`line-through`)l(t.y-i.fontSize*.33);else if(n.line===`overline`){let{ascent:n}=J(e,i);l(Math.floor(t.y-n)-r/2)}}e.restore()}var Ht=/^[\p{Script=Latin}\p{Script=Cyrillic}\p{Script=Greek}\p{Mark}\p{Number}\p{Punctuation}\p{Separator}]+$/u;function Ut(e){let{style:t}=e;return t.direction===`ltr`&&t.textAlign!==`justify`&&t.textDecorations.length===0&&t.textShadow===`none`&&t.webkitTextStrokeWidth===0&&!e.clip&&!e.strokeImage&&Ht.test(e.text)}function Wt(e,t,n=!1){let r=!n&&me&&e.children.every(e=>e.type===`text`&&Ut(e))?e.children:null;if(!r){e.children.forEach(e=>t(e,e));return}for(let e=0;e<r.length;e++){let n=r[e],i=n.text,a=n.width;for(;e+1<r.length&&r[e+1].style===n.style&&r[e+1].y===n.y&&Math.abs(r[e+1].x-(n.x+a))<=.01;)i+=r[e+1].text,a+=r[++e].width;t({...n,text:i,width:a},n)}}function Gt(e,t,n=null,r=null,i){let{style:a}=t;if(!i?.runs){let n=Mt(a,t.width,t.height);if(!q(a.backgroundColor)&&a.webkitBackgroundClip!==`text`&&(e.fillStyle=a.backgroundColor,n?(e.beginPath(),e.roundRect(t.x,t.y,t.width,t.height,n),e.fill()):e.fillRect(t.x,t.y,t.width,t.height)),n!==null&&jt(a,`Top`)&&[`Right`,`Bottom`,`Left`].every(e=>a[`border${e}Width`]===a.borderTopWidth&&a[`border${e}Style`]===a.borderTopStyle&&a[`border${e}Color`]===a.borderTopColor)){let r=a.borderTopWidth;e.strokeStyle=a.borderTopColor,e.lineWidth=r,e.beginPath(),e.roundRect(t.x+r/2,t.y+r/2,t.width-r,t.height-r,n.map(e=>({x:Math.max(0,e.x-r/2),y:Math.max(0,e.y-r/2)}))),e.stroke()}else{let n=[[`Top`,t.x,t.y+a.borderTopWidth/2,t.x+t.width,t.y+a.borderTopWidth/2],[`Right`,t.x+t.width-a.borderRightWidth/2,t.y,t.x+t.width-a.borderRightWidth/2,t.y+t.height],[`Bottom`,t.x,t.y+t.height-a.borderBottomWidth/2,t.x+t.width,t.y+t.height-a.borderBottomWidth/2],[`Left`,t.x+a.borderLeftWidth/2,t.y,t.x+a.borderLeftWidth/2,t.y+t.height]];for(let[t,r,i,o,s]of n)jt(a,t)&&(e.strokeStyle=a[`border${t}Color`],e.lineWidth=a[`border${t}Width`],e.beginPath(),e.moveTo(r,i),e.lineTo(o,s),e.stroke())}}if(Oe(a)){let r=a.backgroundImage&&a.backgroundImage!==`none`?Pt(e,a.backgroundImage,t.x,t.width,t.y,t.height):null,i=q(a.backgroundColor)?null:a.backgroundColor;n=r??i??n}a.webkitTextStrokeImage&&a.webkitTextStrokeImage!==`none`&&(r=Pt(e,a.webkitTextStrokeImage,t.x,t.width,t.y,t.height)),Wt(t,(t,a)=>{Kt(e,t,n,r,i,a)},!!i?.runs)}function Kt(e,t,n,r,i,a=t){t.type===`text`?(!i?.runs||i.runs.has(t))&&(i?.beforeText?.(e,a),Vt(e,t,n,r)):Gt(e,t,n,r,i)}function qt(e,t,n={}){if(n.renderShadows===!1){bt(e,e=>Kt(e,t));return}let{createCanvas:r}=n,i=new Map,a,o=e=>{if(e.type===`box`){let t=e.style;(!q(t.backgroundColor)&&t.webkitBackgroundClip!==`text`||[`Top`,`Right`,`Bottom`,`Left`].some(e=>jt(t,e)))&&(a=void 0),e.children.forEach(o);return}a??=e;let t=At(e.style.textShadow,e.style.color);if(!t.length)return;let n=i.get(a);n||(n=new Map,i.set(a,n));let r=JSON.stringify(t),s=n.get(r);s||(s={runs:new Set,shadows:t},n.set(r,s)),s.runs.add(e)};o(t);let s=t=>{if(t.type===`box`){let e={x:t.x,y:t.y,width:t.width,height:t.height};return Wt(t,t=>{e=$(e,s(t))}),e}e.save(),Bt(e,t.style);let n=Ct(e,t.text,t.style,t.x,t.y,t.width,t.style.direction===`rtl`);return e.restore(),t.lineBaselineY!==void 0&&(n=$(n,{...n,y:n.y+t.lineBaselineY-t.y})),n};Ot(e,()=>{let e=s(t);for(let t of i.values())for(let n of t.values()){let t=[...n.runs].map(s).reduce($);e=$(e,wt(t,n.shadows))}return e},e=>{Kt(e,t,null,null,{beforeText:(e,n)=>{for(let a of i.get(n)?.values()??[])kt(e,[...a.runs].map(s).reduce($),a.shadows,e=>Kt(e,t,null,null,{runs:a.runs}),r)}})},r)}var Jt=null;function Yt(e){let{html:t,width:n,height:r,accuracy:a=`performance`,debug:s}=e;if(!n||n<=0||Number.isNaN(n))throw TypeError(`layout: width must be a positive number, got ${n}`);let c=a===`balanced`,{fragment:l,css:u}=o(t),d=ne(l,u,n),f=e.ctx??(Jt??=i(!0));f.fontKerning=`normal`;let{root:p,height:m,lines:h}=vt(f,d,n,c,s);return{layoutRoot:p,height:r||m,lines:h}}function Xt(e){let{layout:t,width:n,pixelRatio:r=globalThis.devicePixelRatio??1}=e;if(e.ctx&&e.canvas)throw TypeError(`drawLayout: ctx and canvas are mutually exclusive — provide one or neither`);let i=t.height,a,o;if(e.ctx)o=e.ctx,a=e.ctx.canvas;else{if(!e.canvas&&typeof document>`u`)throw Error(`render-tag: drawLayout cannot create a canvas in a non-browser environment — pass ctx or canvas.`);a=e.canvas??document.createElement(`canvas`),a.width=Math.ceil(n*r),a.height=Math.ceil(i*r),`style`in a&&(a.style.width=`${n}px`,a.style.height=`${i}px`),o=a.getContext(`2d`),o.scale(r,r)}return qt(o,t.layoutRoot,e),{canvas:a}}function Zt(e){if(e.ctx&&e.canvas)throw TypeError(`render: ctx and canvas are mutually exclusive — provide one or neither`);let t=Yt({html:e.html,width:e.width,height:e.height,accuracy:e.accuracy,debug:e.debug,ctx:e.ctx}),{canvas:n}=Xt({layout:t,width:e.width,ctx:e.ctx,canvas:e.canvas,pixelRatio:e.pixelRatio,createCanvas:e.createCanvas,renderShadows:e.renderShadows});return{canvas:n,height:t.height,layoutRoot:t.layoutRoot,lines:t.lines}}e.drawLayout=Xt,e.getFontMetrics=J,e.layout=Yt,e.lineBaselineOffset=_e,e.render=Zt,e.setDOMParser=r,e.tabStopMetrics=ve});
|
|
11
11
|
//# sourceMappingURL=render-tag.umd.js.map
|