render-tag 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/lib/css-resolver.d.ts +16 -0
- package/lib/css-resolver.d.ts.map +1 -1
- package/lib/css-resolver.js +56 -3
- package/lib/css-resolver.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -32
- package/lib/index.js.map +1 -1
- package/lib/layout.d.ts +6 -1
- package/lib/layout.d.ts.map +1 -1
- package/lib/layout.js +99 -29
- package/lib/layout.js.map +1 -1
- package/lib/path/glyph-layout.d.ts +71 -0
- package/lib/path/glyph-layout.d.ts.map +1 -0
- package/lib/path/glyph-layout.js +155 -0
- package/lib/path/glyph-layout.js.map +1 -0
- package/lib/path/grapheme.d.ts +2 -0
- package/lib/path/grapheme.d.ts.map +1 -0
- package/lib/path/grapheme.js +39 -0
- package/lib/path/grapheme.js.map +1 -0
- package/lib/path/index.d.ts +96 -0
- package/lib/path/index.d.ts.map +1 -0
- package/lib/path/index.js +145 -0
- package/lib/path/index.js.map +1 -0
- package/lib/path/svg-path.d.ts +68 -0
- package/lib/path/svg-path.d.ts.map +1 -0
- package/lib/path/svg-path.js +393 -0
- package/lib/path/svg-path.js.map +1 -0
- package/lib/render-tag.umd.js +5 -5
- package/lib/render-tag.umd.js.map +1 -1
- package/lib/render.d.ts.map +1 -1
- package/lib/render.js +32 -22
- package/lib/render.js.map +1 -1
- package/lib/types.d.ts +13 -0
- package/lib/types.d.ts.map +1 -1
- package/package.json +5 -1
package/lib/render-tag.umd.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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`});function t(e){let t=new DOMParser().parseFromString(e,`text/html`),n=t.querySelectorAll(`style`),r=``;for(let e of n)r+=e.textContent+`
|
|
2
|
-
`,e.remove();let i=document.createDocumentFragment();for(;t.body.firstChild;)i.appendChild(document.adoptNode(t.body.firstChild));return{fragment:i,css:r}}function n(e){let t=[],n=[];e=e.replace(/\/\*[\s\S]*?\*\//g,``);let r=0;for(;r<e.length;){for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length)break;if(e[r]===`@`){let t=r,i=0;for(;r<e.length;){if(e[r]===`{`&&i++,e[r]===`}`&&(i--,i<=0)){r++;break}r++}let a=e.slice(t,r);a.startsWith(`@font-face`)&&n.push(a);continue}let i=r;for(;r<e.length&&e[r]!==`{`;)r++;if(r>=e.length)break;let a=e.slice(i,r).trim();r++;let o=r;for(;r<e.length&&e[r]!==`}`;)r++;let s=e.slice(o,r).trim();if(r++,!a)continue;let c=a.split(`,`).map(e=>e.trim()).filter(Boolean),l=[];for(let e of s.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&&l.push({property:n,value:r})}c.length>0&&l.length>0&&t.push({selectors:c,declarations:l})}return{rules:t,fontFaceRules:n}}function r(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 i(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 a(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 o(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=[],a=[],o=e.trim().split(/\s+/);for(let e=0;e<o.length;e++)o[e]===`>`?a.push(`>`):(n.length>a.length+1&&a.push(` `),n.push(o[e]));for(;a.length<n.length-1;)a.push(` `);if(n.length===0)return null;let s=n.map(i),c=s[s.length-1],l=c.tag;return{parts:s,combinators:a,rightmost:c,rightmostIsRoot:l===`html`||l===`body`,spec:r(e),pseudoElement:t}}function s(e,t){if(e.rightmostIsRoot){if(t.parent!==null)return!1}else if(!a(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(a(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(a(r,n)){n=n.parent,e=!0;break}n=n.parent}if(!e)return!1}}return!0}function c(){return{fontFamily:`sans-serif`,fontSize:16,fontWeight:400,fontStyle:`normal`,color:`rgb(0, 0, 0)`,textAlign:`start`,textAlignLast:`auto`,textIndent:0,textTransform:`none`,textDecorationLine:`none`,textDecorationStyle:`solid`,textDecorationColor:`rgb(0, 0, 0)`,textShadow:`none`,webkitTextStrokeWidth:0,webkitTextStrokeColor:``,webkitTextFillColor:``,webkitBackgroundClip:``,backgroundImage:`none`,letterSpacing:0,wordSpacing:0,fontKerning:`auto`,lineHeight:0,verticalAlign:`baseline`,whiteSpace:`normal`,wordBreak:`normal`,overflowWrap:`normal`,direction:`ltr`,display:`block`,width:0,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`,flexDirection:`row`,gap:0,flexGrow:0,listStyleType:`disc`}}var l={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`},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 u(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 d(e){if(e===`bold`)return 700;if(e===`normal`)return 400;let t=parseInt(e,10);return isNaN(t)?400:t}function f(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=t.trim().split(/\s+/),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===`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`}];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=[],s=[];for(let e of r)i.includes(e)?s.push(e):a.includes(e)?o.push({property:`text-decoration-style`,value:e}):e.startsWith(`#`)&&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=t.trim().split(/\s+/),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().split(/\s+/),n=parseFloat(e[0]);return isNaN(n)?[]:[{property:`flex-grow`,value:String(n)}]}return e===`border-collapse`||e===`border-spacing`?[]:[{property:e,value:t}]}function p(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=d(n);break;case`font-style`:e.fontStyle=n.trim();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=u(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-shadow`:e.textShadow=n.trim();break;case`-webkit-text-stroke-width`:e.webkitTextStrokeWidth=u(n,o,i);break;case`-webkit-text-stroke-color`:e.webkitTextStrokeColor=n.trim();break;case`-webkit-text-fill-color`:e.webkitTextFillColor=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:u(n,o,i);break;case`word-spacing`:e.wordSpacing=n.trim()===`normal`?0:u(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{let n=parseFloat(t);isNaN(n)||(e.lineHeight=n*o,e._lineHeightMultiplier=n)}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`display`:e.display=n.trim();break;case`width`:{let t=n.trim();t===`100%`?e.width=i:t!==`auto`&&(e.width=u(t,o,i));break}case`min-height`:e.minHeight=u(n,o,i);break;case`padding-top`:e.paddingTop=u(n,o,i);break;case`padding-right`:e.paddingRight=u(n,o,i);break;case`padding-bottom`:e.paddingBottom=u(n,o,i);break;case`padding-left`:e.paddingLeft=u(n,o,i);break;case`margin-top`:e.marginTop=u(n,o,i);break;case`margin-right`:e.marginRight=u(n,o,i);break;case`margin-bottom`:e.marginBottom=u(n,o,i);break;case`margin-left`:e.marginLeft=u(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=u(n,o,i):e.paddingLeft=u(n,o,i);break;case`padding-inline-end`:a===`rtl`?e.paddingLeft=u(n,o,i):e.paddingRight=u(n,o,i);break;case`margin-inline-start`:a===`rtl`?e.marginRight=u(n,o,i):e.marginLeft=u(n,o,i);break;case`margin-inline-end`:a===`rtl`?e.marginLeft=u(n,o,i):e.marginRight=u(n,o,i);break;case`border-top-width`:e.borderTopWidth=u(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=u(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=u(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=u(n,o,i);break;case`border-left-color`:e.borderLeftColor=n.trim();break;case`border-left-style`:e.borderLeftStyle=n.trim();break;case`flex-direction`:e.flexDirection=n.trim();break;case`gap`:e.gap=u(n,o,i);break;case`flex-grow`:e.flexGrow=parseFloat(n)||0;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`border-radius`:case`border-top-left-radius`:case`border-top-right-radius`:case`border-bottom-left-radius`:case`border-bottom-right-radius`: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 m=[[`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`]];function h(e,t,n){for(let[r,i]of m)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 e[i]=t[i]}function g(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=f(t.property,r);for(let t of i)e.push({property:t.property,value:t.value,important:n})}for(let s of a.selectors){let a=o(s);if(!a)continue;let c={selector:a,declarations:e,orderBase:i++},l=a.rightmost;if(l.tag&&!a.rightmostIsRoot){let e=t.get(l.tag);e?e.push(c):t.set(l.tag,[c])}if(l.classes.length>0){let e=l.classes[0],t=n.get(e);t?t.push(c):n.set(e,[c])}!l.tag&&l.classes.length===0&&r.push(c),a.rightmostIsRoot&&r.push(c)}}return{byTag:t,byClass:n,universal:r}}function _(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`${v(e).toLowerCase()}.`;case`upper-roman`:return`${v(e)}.`;case`lower-alpha`:case`lower-latin`:return`${y(e).toLowerCase()}.`;case`upper-alpha`:case`upper-latin`:return`${y(e)}.`;default:return`${e}.`}}function v(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 y(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 b(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 _(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 _(c,t||`decimal`);c+=s}return _(c,t||`decimal`)}}function x(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 S(e,t,r){let{rules:i,fontFaceRules:a}=n(t),o=null;a.length>0&&(o=document.createElement(`style`),o.textContent=a.join(`
|
|
3
|
-
`),document.head.appendChild(o));let u=
|
|
2
|
+
`,e.remove();let i=document.createDocumentFragment();for(;t.body.firstChild;)i.appendChild(document.adoptNode(t.body.firstChild));return{fragment:i,css:r}}function n(e){let t=[],n=[];e=e.replace(/\/\*[\s\S]*?\*\//g,``);let r=0;for(;r<e.length;){for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length)break;if(e[r]===`@`){let t=r,i=0;for(;r<e.length;){if(e[r]===`{`&&i++,e[r]===`}`&&(i--,i<=0)){r++;break}r++}let a=e.slice(t,r);a.startsWith(`@font-face`)&&n.push(a);continue}let i=r;for(;r<e.length&&e[r]!==`{`;)r++;if(r>=e.length)break;let a=e.slice(i,r).trim();r++;let o=r;for(;r<e.length&&e[r]!==`}`;)r++;let s=e.slice(o,r).trim();if(r++,!a)continue;let c=a.split(`,`).map(e=>e.trim()).filter(Boolean),l=[];for(let e of s.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&&l.push({property:n,value:r})}c.length>0&&l.length>0&&t.push({selectors:c,declarations:l})}return{rules:t,fontFaceRules:n}}function r(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 i(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 a(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 o(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=[],a=[],o=e.trim().split(/\s+/);for(let e=0;e<o.length;e++)o[e]===`>`?a.push(`>`):(n.length>a.length+1&&a.push(` `),n.push(o[e]));for(;a.length<n.length-1;)a.push(` `);if(n.length===0)return null;let s=n.map(i),c=s[s.length-1],l=c.tag;return{parts:s,combinators:a,rightmost:c,rightmostIsRoot:l===`html`||l===`body`,spec:r(e),pseudoElement:t}}function s(e,t){if(e.rightmostIsRoot){if(t.parent!==null)return!1}else if(!a(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(a(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(a(r,n)){n=n.parent,e=!0;break}n=n.parent}if(!e)return!1}}return!0}function c(){return{fontFamily:`sans-serif`,fontSize:16,fontWeight:400,fontStyle:`normal`,color:`rgb(0, 0, 0)`,textAlign:`start`,textAlignLast:`auto`,textIndent:0,textTransform:`none`,textDecorationLine:`none`,textDecorationStyle:`solid`,textDecorationColor:`rgb(0, 0, 0)`,textShadow:`none`,webkitTextStrokeWidth:0,webkitTextStrokeColor:``,webkitTextFillColor:``,paintOrder:`normal`,webkitBackgroundClip:``,backgroundImage:`none`,letterSpacing:0,wordSpacing:0,fontKerning:`auto`,lineHeight:0,verticalAlign:`baseline`,whiteSpace:`normal`,wordBreak:`normal`,overflowWrap:`normal`,direction:`ltr`,display:`block`,width:0,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`,flexDirection:`row`,gap:0,flexGrow:0,listStyleType:`disc`}}var l={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`},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 u(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 d(e){if(e===`bold`)return 700;if(e===`normal`)return 400;let t=parseInt(e,10);return isNaN(t)?400:t}function f(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 p(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 m(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=t.trim().split(/\s+/),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===`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`}];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=[],s=[];for(let e of r)i.includes(e)?s.push(e):a.includes(e)?o.push({property:`text-decoration-style`,value:e}):e.startsWith(`#`)&&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=p(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().split(/\s+/),n=parseFloat(e[0]);return isNaN(n)?[]:[{property:`flex-grow`,value:String(n)}]}return e===`border-collapse`||e===`border-spacing`?[]:[{property:e,value:t}]}function h(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=d(n);break;case`font-style`:e.fontStyle=n.trim();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=u(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-shadow`:e.textShadow=n.trim();break;case`-webkit-text-stroke-width`:e.webkitTextStrokeWidth=u(n,o,i);break;case`-webkit-text-stroke-color`:e.webkitTextStrokeColor=n.trim();break;case`-webkit-text-fill-color`:e.webkitTextFillColor=n.trim();break;case`paint-order`:e.paintOrder=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:u(n,o,i);break;case`word-spacing`:e.wordSpacing=n.trim()===`normal`?0:u(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{let n=parseFloat(t);isNaN(n)||(e.lineHeight=n*o,e._lineHeightMultiplier=n)}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`display`:e.display=n.trim();break;case`width`:{let t=n.trim();t===`100%`?e.width=i:t!==`auto`&&(e.width=u(t,o,i));break}case`min-height`:e.minHeight=u(n,o,i);break;case`padding-top`:e.paddingTop=u(n,o,i);break;case`padding-right`:e.paddingRight=u(n,o,i);break;case`padding-bottom`:e.paddingBottom=u(n,o,i);break;case`padding-left`:e.paddingLeft=u(n,o,i);break;case`margin-top`:e.marginTop=u(n,o,i);break;case`margin-right`:e.marginRight=u(n,o,i);break;case`margin-bottom`:e.marginBottom=u(n,o,i);break;case`margin-left`:e.marginLeft=u(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=u(n,o,i):e.paddingLeft=u(n,o,i);break;case`padding-inline-end`:a===`rtl`?e.paddingLeft=u(n,o,i):e.paddingRight=u(n,o,i);break;case`margin-inline-start`:a===`rtl`?e.marginRight=u(n,o,i):e.marginLeft=u(n,o,i);break;case`margin-inline-end`:a===`rtl`?e.marginLeft=u(n,o,i):e.marginRight=u(n,o,i);break;case`border-top-width`:e.borderTopWidth=u(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=u(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=u(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=u(n,o,i);break;case`border-left-color`:e.borderLeftColor=n.trim();break;case`border-left-style`:e.borderLeftStyle=n.trim();break;case`flex-direction`:e.flexDirection=n.trim();break;case`gap`:e.gap=u(n,o,i);break;case`flex-grow`:e.flexGrow=parseFloat(n)||0;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`border-radius`:case`border-top-left-radius`:case`border-top-right-radius`:case`border-bottom-left-radius`:case`border-bottom-right-radius`: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 g=[[`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`],[`paint-order`,`paintOrder`]];function _(e,t,n){for(let[r,i]of g)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 e[i]=t[i]}function v(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=m(t.property,r);for(let t of i)e.push({property:t.property,value:t.value,important:n})}for(let s of a.selectors){let a=o(s);if(!a)continue;let c={selector:a,declarations:e,orderBase:i++},l=a.rightmost;if(l.tag&&!a.rightmostIsRoot){let e=t.get(l.tag);e?e.push(c):t.set(l.tag,[c])}if(l.classes.length>0){let e=l.classes[0],t=n.get(e);t?t.push(c):n.set(e,[c])}!l.tag&&l.classes.length===0&&r.push(c),a.rightmostIsRoot&&r.push(c)}}return{byTag:t,byClass:n,universal:r}}function y(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`${b(e).toLowerCase()}.`;case`upper-roman`:return`${b(e)}.`;case`lower-alpha`:case`lower-latin`:return`${x(e).toLowerCase()}.`;case`upper-alpha`:case`upper-latin`:return`${x(e)}.`;default:return`${e}.`}}function b(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 x(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 S(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 y(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 y(c,t||`decimal`);c+=s}return y(c,t||`decimal`)}}function C(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 w(e,t,r){let{rules:i,fontFaceRules:a}=n(t),o=null;a.length>0&&(o=document.createElement(`style`),o.textContent=a.join(`
|
|
3
|
+
`),document.head.appendChild(o));let u=v(i),d=document.createElement(`div`);d.appendChild(e);function f(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 p(e,t,n){let i=e.tagName.toLowerCase(),a=f(e,n),o=c(),d=new Set,p=[],v=new Set,y=u.byTag.get(i);if(y)for(let e of y)v.add(e),p.push(e);for(let e of a.classes){let t=u.byClass.get(e);if(t)for(let e of t)v.has(e)||(v.add(e),p.push(e))}for(let e of u.universal)v.has(e)||(v.add(e),p.push(e));let b=[],x=[];for(let e of p)if(s(e.selector,a)){let t=e.selector.pseudoElement===`marker`?x:b;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 w=l[i],T=!1;if(w?.fontSize!==void 0){let e=w.fontSize;e<10?o.fontSize=e*t.fontSize:o.fontSize=e,T=!0,d.add(`font-size`)}b.length>1&&b.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 b)e.property===`font-size`&&(h(o,e.property,e.value,t.fontSize,r,t.direction),T=!0);if(e instanceof HTMLElement&&e.style.cssText){let n=C(e.style.cssText);for(let e of n)e.property===`font-size`&&(h(o,e.property,e.value,t.fontSize,r,t.direction),T=!0)}T||(o.fontSize=t.fontSize);let E=o.fontSize;if(w){for(let[e,t]of Object.entries(w)){if(e===`fontSize`)continue;o[e]=t;let n=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());d.add(n)}o.marginTop<0&&(o.marginTop=Math.abs(o.marginTop)*E),o.marginBottom<0&&(o.marginBottom=Math.abs(o.marginBottom)*E),(i===`ul`||i===`ol`)&&(t.direction===`rtl`?(o.paddingRight=40,d.add(`padding-right`)):(o.paddingLeft=40,d.add(`padding-left`)))}let D=t.direction,O={"word-wrap":`overflow-wrap`};for(let e of b)e.property!==`font-size`&&(h(o,e.property,e.value,E,r,D),d.add(O[e.property]||e.property));let k=e instanceof HTMLElement&&!!e.style.width;if(e instanceof HTMLElement&&e.style.cssText){let t=C(e.style.cssText);for(let e of t){if(e.property===`font-size`){d.add(`font-size`);continue}let t=m(e.property,e.value);for(let e of t)h(o,e.property,e.value,E,r,D),d.add(O[e.property]||e.property)}}k||(o.width=0);let A=e.getAttribute(`dir`);A&&(o.direction=A,d.add(`direction`)),d.add(`font-size`),_(o,t,d),d.has(`text-decoration-color`)||(o.textDecorationColor=o.color),d.has(`-webkit-text-stroke-color`)?o.webkitTextStrokeColor===`currentColor`&&(o.webkitTextStrokeColor=o.color):(o.webkitTextStrokeColor===``||o.webkitTextStrokeColor===`currentColor`)&&(o.webkitTextStrokeColor=o.color);for(let e of[`Top`,`Right`,`Bottom`,`Left`]){let t=`border${e}Color`,n=`border-${e.toLowerCase()}-color`;d.has(n)?o[t]===`currentColor`&&(o[t]=o.color):o[t]=o.color}let j=new Set(o.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`&&j.add(e);j.size>0&&(o.textDecorationLine=[...j].join(` `));let M=S(e,o.listStyleType),N,P=!1;if(i===`li`&&x.length>0){x.length>1&&x.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={...o},n=new Set;for(let i of x){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]);h(t,i.property,i.value,E,r,D),e.forEach((e,r)=>{t[e]!==a[r]&&n.add(e)})}if(n.size>0){N={};for(let e of n)N[e]=t[e]}}let F=[];for(let t of e.childNodes){let e=g(t,o,a);e&&F.push(e)}return{element:e,tagName:i,style:o,children:F,textContent:null,listMarker:M,markerStyle:N,markerHidden:P||void 0}}function g(e,t,n){if(e.nodeType===Node.TEXT_NODE){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!==Node.ELEMENT_NODE)return e?.nodeType===Node.TEXT_NODE;let t=l[e.tagName.toLowerCase()]?.display||`block`;return t===`inline`||t===`inline-block`};if(i&&a&&!o(i)&&!o(a)&&!(r===`pre`||r===`pre-wrap`||r===`pre-line`)||r!==`pre`&&r!==`pre-wrap`&&r!==`pre-line`&&n.includes(`
|
|
4
4
|
`))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!==Node.ELEMENT_NODE)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:`
|
|
5
|
-
`}:
|
|
5
|
+
`}:p(r,t,n)}return{tree:p(d,c(),null),cleanup:()=>{o&&o.remove()}}}var T=!0,E,D=[],O=new Map;function k(e,t){let n=e.font+`\0`+t,r=O.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return O.set(n,i),i}function A(e){let t=``;for(let n of e){if(!n.text||n.isSpace)continue;let e=N(n.style);if(t&&e!==t)return!0;t=e}return!1}function j(e,t){e.font=N(t),e.fontKerning=t.fontKerning===`none`?`none`:`normal`}var M=new Map;function N(e){let t=`${e.fontStyle}|${e.fontWeight}|${e.fontSize}|${e.fontFamily}`,n=M.get(t);if(n)return n;let r=[];e.fontStyle!==`normal`&&r.push(e.fontStyle),e.fontWeight!==400&&r.push(String(e.fontWeight)),r.push(`${e.fontSize}px`),r.push(e.fontFamily);let i=r.join(` `);return M.set(t,i),i}var P=new Map,F=null,I=null,L=null,R=new Set([`disc`,`circle`,`square`]);function ee(e,t,n=!1){let r=`${e}|${t}|${n?`ul-li`:`block`}`,i=P.get(r);if(i!==void 0)return i;let a;n?(I||(I=document.createElement(`ul`),I.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;padding:0;margin:0;border:0;list-style:disc;`,L=document.createElement(`li`),L.style.cssText=`white-space:nowrap;padding:0;margin:0;border:0;`,L.textContent=`Mg`,I.appendChild(L),document.body.appendChild(I)),a=L):(F||(F=document.createElement(`div`),F.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;white-space:nowrap;padding:0;margin:0;border:0;`,F.textContent=`Mg`,document.body.appendChild(F)),a=F),a.style.font=e,a.style.lineHeight=t;let o=a.getBoundingClientRect().height;return P.set(r,o),o}function z(e,t,n=!1){if(t.lineHeight>0)return T?ee(N(t),`${t.lineHeight}px`,n):t.lineHeight;if(T)return ee(N(t),`normal`,n);let{ascent:r,descent:i}=W(e,t);return r+i}function te(e,t,n){let{ascent:r,descent:i}=W(e,t);return(r-i)/2+n/2}function B(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+n.toUpperCase());default:return e}}function V(e){if(e.tagName===`#text`)return!0;let t=e.style.display;return t===`inline`||t===`inline-block`}function ne(e){return e.children.length>0&&e.children.every(V)}function H(e){return!e||e===`transparent`||e===`rgba(0, 0, 0, 0)`}var U=new Map;function W(e,t){let n=N(t),r=U.get(n);if(r)return r;e.font=n;let i=e.measureText(`M`),a={ascent:i.fontBoundingBoxAscent??i.actualBoundingBoxAscent,descent:i.fontBoundingBoxDescent??i.actualBoundingBoxDescent};return U.set(n,a),a}function G(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&&e.backgroundColor===t.backgroundColor}function K(e){return!H(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 re(e){let t=[];function n(e,r){if(e.tagName===`#text`&&e.textContent){t.push({text:e.textContent,style:e.style,boxStyle:r});return}let i=e.style.display===`inline-block`,a=i||V(e)&&K(e.style),o=a?e.style:r,s=a&&(e.style.paddingLeft>0||e.style.paddingRight>0||e.style.borderLeftWidth>0||e.style.borderRightWidth>0);if(i){let n=e.element?.textContent||``;t.push({text:n,style:e.style,boxStyle:o,boxOpen:e.style,boxClose:e.style});return}s&&t.push({text:``,style:e.style,boxStyle:o,boxOpen:e.style});for(let t of e.children)n(t,a?o:r);s&&t.push({text:``,style:e.style,boxStyle:o,boxClose:e.style})}for(let t of e.children)n(t);return t}function ie(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 q;function ae(){return q||(typeof Intl<`u`&&Intl.Segmenter?(q=new Intl.Segmenter(void 0,{granularity:`word`}),q):null)}function J(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;J(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)/),a=k(e,` `)*8;for(let t of i){if(t===``)continue;if(t===` `){r.push({text:` `,width:a,style:n.style,isSpace:!0,isTab:!0,boxStyle:n.boxStyle});continue}let i=/^ +$/.test(t);r.push({text:t,width:k(e,t),style:n.style,isSpace:i,boxStyle:n.boxStyle})}}else{let a=t.split(/([ \t\n\r\f\v]+)/),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,isSpace:!0,boxStyle:n.boxStyle});continue}if(ie(t)){let i=ae();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,isSpace:!1,boxStyle:n.boxStyle})}continue}}let i=s;o+=t,s=e.measureText(o).width;let a=s-i,c=k(e,t);E&&E({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,isSpace:!1,boxStyle:n.boxStyle})}i&&(i.cumText=o,i.cumWidth=s)}}function oe(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){j(e,r.style),e.letterSpacing=r.style.letterSpacing>0?`${r.style.letterSpacing}px`:`0px`;let t=B(r.text,r.style.textTransform),i=r.style,a=k(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,isSpace:!1,boxStyle:r.boxStyle,boxOpen:r.boxOpen,boxClose:r.boxClose});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}j(e,r.style),e.letterSpacing=r.style.letterSpacing>0?`${r.style.letterSpacing}px`:`0px`;let t=B(r.text,r.style.textTransform);if(t.includes(`
|
|
6
6
|
`)){let i=t.split(`
|
|
7
7
|
`);for(let t=0;t<i.length;t++)t>0&&n.push({text:`
|
|
8
|
-
`,width:0,style:r.style,isSpace:!1,boxStyle:r.boxStyle}),i[t]&&
|
|
9
|
-
`){s.words.length===0?(s.lineHeight=t,s.endedByHardBreak=!0,o.push(s),s={words:[],totalWidth:0,lineHeight:0}):(s.endedByHardBreak=!0,f()),p=!0;continue}if(c){s.words.push(r),s.totalWidth+=r.width,s.lineHeight=Math.max(s.lineHeight,t);continue}let a=!r.isSpace&&r.text.length>1?oe(e,r,l(),s.totalWidth):[r];for(let r of a){let i=!r.isSpace&&r.text.length>0&&/^[,.\;:!?\)\]\}'"»›]+$/.test(r.text)&&s.words.length>0&&!s.words[s.words.length-1].isSpace;if(!r.isSpace&&!i&&s.words.length>0&&s.totalWidth+r.width>l()){let i=s.totalWidth+r.width-l(),a=!0;if(i<1&&!D([...s.words,r])&&(O(e,r.style),E(e,s.words.map(e=>e.text).join(``)+r.text)<=l()+.1&&(a=!1)),a&&r.text.includes(`-`)){let n=r.text.split(/(?<=-)/);if(n.length>1){O(e,r.style);let i=``,a=0,o=0,c=l()-s.totalWidth;for(;o<n.length;o++){let t=i+n[o],r=E(e,t);if(r>c)break;i=t,a=r}if(o>0&&o<n.length){s.words.push({...r,text:i,width:a}),s.totalWidth+=a,s.lineHeight=Math.max(s.lineHeight,t),f(!0),p=!1;let c=n.slice(o).join(``),l=E(e,c);s.words.push({...r,text:c,width:l}),s.totalWidth+=l,s.lineHeight=Math.max(s.lineHeight,t);continue}}}if(a){if(w){let e=s.words.map(e=>e.text).join(``);w({type:`line-wrap`,message:`"${r.text}" overflow=${i.toFixed(2)} wrap=true lineWidth=${s.totalWidth.toFixed(2)} pieceWidth=${r.width.toFixed(2)} contentWidth=${n} line="${e}"`,data:{text:r.text,overflow:i,lineWidth:s.totalWidth,pieceWidth:r.width,contentWidth:n,lineText:e}})}f(!0),p=!1}}if(r.isSpace&&s.words.length===0&&(!p||!d))continue;let a=r.width;if(r.isTab){let e=r.width,t=s.totalWidth;a=Math.ceil((t+.1)/e)*e-t,r.width=a}if(s.words.length===0&&a>l()&&!r.isSpace&&r.text.includes(`-`)){let n=r.text.split(/(?<=-)/);if(n.length>1){O(e,r.style);let i=n.filter(e=>e).map(t=>({...r,text:t,width:E(e,t)})),a=!0;for(let e of i)a?(a=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,t)):s.totalWidth+e.width>l()?(f(!0),p=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,t)):(s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,t));continue}}s.words.push(r),s.totalWidth+=a,s.lineHeight=Math.max(s.lineHeight,t),r.isSpace||(p=!1)}}return f(),o}function J(e,t,n,r,i,a=!1){let o=[],s=ne(t);if(s.length===0)return{nodes:o,height:0};let c=ae(e,s),l=t.style.textIndent||0,u=se(e,c,i,t.style.whiteSpace,a,l),d=t.style.direction===`rtl`,f=e=>e===`start`?d?`right`:`left`:e===`end`?d?`left`:`right`:e,p=f(t.style.textAlign),m=t.style.textAlignLast||`auto`;m=m===`auto`?t.style.textAlign===`justify`?d?`right`:`left`:p:f(m);let h=r;for(let t=0;t<u.length;t++){let r=u[t];if(r.words.length===0){h+=r.lineHeight;continue}let a=r.lineHeight,s=t===u.length-1,c=t===0,f=s||r.endedByHardBreak?m:p,g=c?l:0,_=i-g,v=0;if(f===`justify`&&r.totalWidth<_){let e=r.words.filter(e=>e.isSpace).length;e>0&&(v=(_-r.totalWidth)/e)}let y=n+g;f===`center`?y=n+g+(_-r.totalWidth)/2:(f===`right`||f!==`justify`&&d||d)&&(y=n+g+_-r.totalWidth);let b=0,x=0;for(let t of r.words){if(t.text===``)continue;let n=t.style.verticalAlign;if(n===`super`||n===`sub`)continue;let{ascent:r,descent:i}=H(e,t.style);r>b&&(b=r),i>x&&(x=i)}if(b===0)for(let t of r.words){if(t.text===``)continue;let{ascent:n,descent:r}=H(e,t.style);b=n,x=r;break}let S=b+x,C=h+(a-S)/2+b,w=r.words.filter(e=>e.text!==``&&e.style.verticalAlign!==`super`&&e.style.verticalAlign!==`sub`),T=w.length>0?Math.max(...w.map(e=>e.style.fontSize)):0,D=a;{let t=h,n=h+a;for(let i of r.words){if(i.text===``)continue;let r=i.style.verticalAlign;if(r!==`super`&&r!==`sub`)continue;if(T===0)break;let{ascent:a,descent:o}=H(e,i.style),s=C;r===`super`?s-=T*.4:s+=T*.26;let c=s-a,l=s+o;c<t&&(t=c),l>n&&(n=l)}D=n-t}let k=(t,n,r)=>{let{ascent:i,descent:a}=H(e,t),s=t.paddingTop+t.borderTopWidth,c=t.paddingBottom+t.borderBottomWidth,l=i+a+s+c,u;u=t.display===`inline-block`?h+t.marginTop:C-i-s,o.push({type:`box`,style:t,x:n,y:u,width:r,height:l,tagName:`span`,children:[]})};if(!d){let e=y,t=e,n,i=!1;for(let a of r.words){if(a.boxOpen&&a.boxClose&&a.text){n&&(i&&k(n,t,e-t),n=void 0,i=!1);let r=a.style,o=a.width-r.marginLeft-r.borderLeftWidth-r.paddingLeft-r.paddingRight-r.borderRightWidth-r.marginRight;k(r,e+r.marginLeft,r.borderLeftWidth+r.paddingLeft+o+r.paddingRight+r.borderRightWidth),i=!1,e+=a.width;continue}a.boxStyle!==n&&(n&&i&&k(n,t,e-t),n=a.boxStyle,t=e,i=!1),a.text&&!a.isSpace&&(i=!0),e+=a.width+(a.isSpace?v:0)}n&&i&&k(n,t,e-t)}let A=r.words.filter(e=>e.text!==``),j=A.length>0&&A.every(e=>U(e.style,A[0].style));if(d){let t=[],n=null,i=0;for(let e of r.words){if(e.text===``){n&&=(t.push(n),null),i+=e.width;continue}n&&U(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,x:0,padBefore:i},i=0)}n&&t.push(n);let a=y+r.totalWidth;for(let n of t){a-=n.padBefore,O(e,n.style);let t=E(e,n.text);a-=t,n.x=a,n.width=t}for(let e of t)if(e.boxStyle&&W(e.boxStyle)){let t=e.boxStyle,n=t.paddingLeft+t.borderLeftWidth,r=t.paddingRight+t.borderRightWidth;k(t,e.x-n,e.width+n+r)}for(let e of t)o.push({type:`text`,text:e.text,x:e.x+e.width,y:C,width:e.width,style:{...e.style,direction:`rtl`}})}else{let t=r.words.map(e=>e.text).join(``);if(j&&/[\u0590-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(t)&&!r.words.some(e=>e.boxOpen||e.boxClose||e.style.verticalAlign===`super`||e.style.verticalAlign===`sub`)){O(e,A[0].style);let n=E(e,t);o.push({type:`text`,text:t,x:y,y:C,width:n,style:A[0].style})}else for(let t of r.words){if(t.text===``){y+=t.width;continue}if(t.boxOpen&&t.boxClose){let n=t.style,r=y+n.marginLeft+n.borderLeftWidth+n.paddingLeft;o.push({type:`text`,text:t.text,x:r,y:C,width:E(e,t.text),style:t.style}),y+=t.width;continue}let n=C,r=t.style.verticalAlign;if(r===`super`||r===`sub`){let e=T||t.style.fontSize;r===`super`?n-=e*.4:n+=e*.26}let i=t.width+(t.isSpace?v:0);o.push({type:`text`,text:t.text,x:y,y:n,width:i,style:t.style}),y+=i}}h+=D}return{nodes:o,height:h-r}}function ce(e,t){return e>=0&&t>=0?Math.max(e,t):e<0&&t<0?Math.min(e,t):e+t}function Y(e,t,n,r,i){let a=t.style,o=a.marginLeft,s=a.marginRight,c=a.borderLeftWidth,l=a.borderRightWidth,u=a.borderTopWidth,d=a.borderBottomWidth,f=a.paddingLeft,p=a.paddingRight,m=a.paddingTop,h=a.paddingBottom,g=n+o,_=a.width>0?a.width:i-o-s,v=g+c+f,y=Math.max(0,_-c-l-f-p),b=r,x=b+u+m,S={type:`box`,style:a,x:g,y:b,width:_,height:0,tagName:t.tagName,children:[],listMarker:t.listMarker};if(a.display===`flex`){let n=ue(e,t,v,x,y);return S.children=n.children,S.height=u+m+n.height+h+d,{box:S,height:S.height,marginBottomOut:a.marginBottom}}if(a.display===`table`){let n=le(e,t,v,x,y);return S.children=n.children,S.height=u+m+n.height+h+d,{box:S,height:S.height,marginBottomOut:a.marginBottom}}if(t.children.length===0)return S.height=u+m+h+d,a.minHeight>0&&(S.height=Math.max(S.height,a.minHeight)),{box:S,height:S.height,marginBottomOut:a.marginBottom};if(te(t)){let{nodes:n,height:r}=J(e,t,v,x,y,t.tagName===`li`&&F.has(a.listStyleType));S.children=n,S.height=u+m+r+h+d}else{let n=x,r=0,i=!1,o=t.tagName===`li`||t.tagName===`ul`||t.tagName===`ol`||t.tagName===`dd`||t.tagName===`dt`;for(let s=0;s<t.children.length;s++){let c=t.children[s];if(c.tagName===`#text`||z(c)){let o=[c];for(;s+1<t.children.length;){let e=t.children[s+1];if(e.tagName===`#text`||z(e))o.push(e),s++;else break}r>0&&(n+=r,r=0);let l={element:null,tagName:`div`,style:{...t.style,display:`block`,marginTop:0,marginBottom:0,paddingTop:0,paddingBottom:0,borderTopWidth:0,borderBottomWidth:0},children:o,textContent:null},u=t.tagName===`li`&&F.has(a.listStyleType),{nodes:d,height:f}=J(e,l,v,n,y,u);S.children.push(...d),n+=f,r=0,i=!0;continue}let l=c.style.marginTop;if(!(!i&&m===0&&u===0&&o)){let e=ce(r,l);n+=e}let{box:d,height:f,marginBottomOut:p}=Y(e,c,v,n,y);S.children.push(d),n+=f,r=p,i=!0}let s=a.marginBottom,c=h===0&&d===0&&o;c&&r>0&&(s=Math.max(a.marginBottom,r));let l=n-x;return!c&&r>0&&(l+=r),S.height=u+m+l+h+d,a.minHeight>0&&(S.height=Math.max(S.height,a.minHeight)),{box:S,height:S.height,marginBottomOut:s}}return a.minHeight>0&&(S.height=Math.max(S.height,a.minHeight)),{box:S,height:S.height,marginBottomOut:a.marginBottom}}function le(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}=Y(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}}function ue(e,t,n,r,i){let a=t.style,o=a.gap,s=[],c=t.children.filter(e=>e.tagName!==`#text`||e.textContent?.trim());if(c.length===0)return{children:s,height:0};if(a.flexDirection===`row`||a.flexDirection===``){let t=o*(c.length-1),a=c.reduce((e,t)=>e+(t.style.flexGrow||0),0),l=(i-t)/(a||c.length),u=n,d=0;for(let t of c){if(t.tagName===`#text`)continue;let n=l*(t.style.flexGrow||(a===0?1:0)),{box:i,height:c}=Y(e,t,u,r,n);s.push(i),d=Math.max(d,c),u+=n+o}return{children:s,height:d}}let l=r;for(let t of c){if(t.tagName===`#text`)continue;let{box:r,height:a}=Y(e,t,n,l,i);s.push(r),l+=a+o}return{children:s,height:l-r}}function de(e,t,n){if(!n.listMarker||n.markerHidden)return;let r=n.style,i=n.markerStyle,a=i?{...r,...i}:r;e.font=A(a);let o=L(e,r),s=t.y+r.borderTopWidth+r.paddingTop+ee(e,r,o),c=E(e,n.listMarker),l=r.direction===`rtl`,u=l?i?.paddingLeft:i?.paddingRight,d=u===void 0?a.fontSize*.15:u,f,p=`ltr`;if(l){let e=t.x+t.width;/\d/.test(n.listMarker)?(p=`rtl`,f=e+d+c):f=e+d}else f=t.x+r.borderLeftWidth+r.paddingLeft-c-d;t.children.unshift({type:`text`,text:n.listMarker,x:f,y:s,width:c,style:{...a,textDecorationLine:`none`,fontWeight:i?.fontWeight??400,fontStyle:i?.fontStyle??`normal`,direction:p}})}function fe(e,t,n,r=!0,i){C=r,w=i,j.clear(),V.clear(),k.clear(),T.clear();let{box:a,height:o}=Y(e,t,0,0,n);return X(e,a,t),{root:a,height:o}}function X(e,t,n){de(e,t,n);let r=0;for(let i of n.children)if(!(i.tagName===`#text`||z(i)))for(;r<t.children.length;){let n=t.children[r];if(n.type===`box`&&n.tagName===i.tagName){X(e,n,i),r++;break}r++}}function pe(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 me(e,t){return e[`border${t}Width`]>0&&e[`border${t}Style`]!==`none`}function Z(e,t,n,r,i,a,o){if(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 Q(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 he(e,t,n){let{style:r}=t;e.save(),e.font=A(r),e.textBaseline=`alphabetic`,e.fontKerning=r.fontKerning===`none`?`none`:`normal`,r.letterSpacing>0&&(e.letterSpacing=`${r.letterSpacing}px`),r.wordSpacing&&(e.wordSpacing=`${r.wordSpacing}px`),r.direction===`rtl`&&(e.direction=`rtl`,e.textAlign=`right`);let i=r.webkitBackgroundClip===`text`&&r.backgroundImage&&r.backgroundImage!==`none`,a=r.webkitTextStrokeWidth>0,o=r.webkitTextFillColor===`transparent`||r.color===`transparent`,s=pe(r.textShadow);if(s.length>0)for(let n of s)e.save(),e.shadowOffsetX=n.offsetX,e.shadowOffsetY=n.offsetY,e.shadowBlur=n.blur,e.shadowColor=n.color,e.fillStyle=r.color,e.fillText(t.text,t.x,t.y),e.restore();if(i){if(e.save(),n)e.fillStyle=n;else{let{ascent:n,descent:i}=H(e,r);e.fillStyle=Q(e,r.backgroundImage,t.x,t.width,t.y-n,n+i)||r.color}e.fillText(t.text,t.x,t.y),e.restore()}else (!o||!a)&&(e.fillStyle=r.webkitTextFillColor&&r.webkitTextFillColor!==`transparent`?r.webkitTextFillColor:r.color,e.fillText(t.text,t.x,t.y));a&&(e.save(),e.strokeStyle=r.webkitTextStrokeColor||r.color,e.lineWidth=r.webkitTextStrokeWidth,e.lineJoin=`round`,e.strokeText(t.text,t.x,t.y),e.restore());let c=t.width,l=r.fontSize,u=r.textDecorationColor||r.color,d=r.textDecorationStyle||`solid`,f=Math.max(1,l/15),p=r.direction===`rtl`?t.x-c:t.x;if(r.textDecorationLine!==`none`){let{ascent:n}=H(e,r);e.font=A(r);let i=e.measureText(`x`).actualBoundingBoxAscent;if(r.textDecorationLine.includes(`underline`)){let n=l*.1;Z(e,p,t.y+n,c,f,d,u)}if(r.textDecorationLine.includes(`line-through`)){let n=-(i*.5);Z(e,p,t.y+n,c,f,d,u)}r.textDecorationLine.includes(`overline`)&&Z(e,p,t.y-n,c,f,d,u)}e.restore()}function ge(e,t){let{style:n}=t;B(n.backgroundColor)||(e.fillStyle=n.backgroundColor,e.fillRect(t.x,t.y,t.width,t.height));let r=[[`Top`,t.x,t.y+n.borderTopWidth/2,t.x+t.width,t.y+n.borderTopWidth/2],[`Right`,t.x+t.width-n.borderRightWidth/2,t.y,t.x+t.width-n.borderRightWidth/2,t.y+t.height],[`Bottom`,t.x,t.y+t.height-n.borderBottomWidth/2,t.x+t.width,t.y+t.height-n.borderBottomWidth/2],[`Left`,t.x+n.borderLeftWidth/2,t.y,t.x+n.borderLeftWidth/2,t.y+t.height]];for(let[t,i,a,o,s]of r)me(n,t)&&(e.strokeStyle=n[`border${t}Color`],e.lineWidth=n[`border${t}Width`],e.beginPath(),e.moveTo(i,a),e.lineTo(o,s),e.stroke());let i=null;n.webkitBackgroundClip===`text`&&n.backgroundImage&&n.backgroundImage!==`none`&&(i=Q(e,n.backgroundImage,t.x,t.width,t.y,t.height));for(let n of t.children)$(e,n,i)}function $(e,t,n){t.type===`text`?he(e,t,n):ge(e,t)}function _e(e){let t=[];function n(e){if(e.type===`text`&&e.text.trim()&&t.push({y:e.y,fontSize:e.style.fontSize,text:e.text}),e.type===`box`)for(let t of e.children)n(t)}n(e),t.sort((e,t)=>e.y-t.y);let r=[],i=0;for(let e of t){let t=r[r.length-1],n=Math.max(i,e.fontSize)*.5;t&&Math.abs(e.y-t.y)<n?(t.text+=e.text,i=Math.max(i,e.fontSize)):(r.push({y:Math.round(e.y),text:e.text}),i=e.fontSize)}return r}function ve(e){let{html:n,width:r,height:i,accuracy:a=`performance`,debug:o}=e;if(!r||r<=0||Number.isNaN(r))throw TypeError(`layout: width must be a positive number, got ${r}`);let s=a===`balanced`,{fragment:c,css:l}=t(n),{tree:u,cleanup:d}=S(c,l,r),f=document.createElement(`canvas`).getContext(`2d`);f.fontKerning=`normal`;let{root:p,height:m}=fe(f,u,r,s,o),h=i||m,g=_e(p);return d(),{layoutRoot:p,height:h,lines:g}}function ye(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;return e.ctx?(o=e.ctx,a=e.ctx.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)),$(o,t.layoutRoot),{canvas:a}}function be(e){if(e.ctx&&e.canvas)throw TypeError(`render: ctx and canvas are mutually exclusive — provide one or neither`);let t=ve({html:e.html,width:e.width,height:e.height,accuracy:e.accuracy,debug:e.debug}),{canvas:n}=ye({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=ye,e.layout=ve,e.render=be});
|
|
8
|
+
`,width:0,style:r.style,isSpace:!1,boxStyle:r.boxStyle}),i[t]&&J(e,i[t],r,n)}else J(e,t,r,n)}return n}function Y(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}function se(e,t,n,r){let i=[...t.text].some(Y),a=t.width>n&&(t.style.overflowWrap===`break-word`||t.style.wordBreak===`break-all`);if(!i&&!a)return[t];e.font=N(t.style);let o=[...t.text],s=[],c=``,l=0;for(let r of o){if(Y(r)){c&&(s.push({...t,text:c,width:l}),c=``,l=0);let n=k(e,r);s.push({...t,text:r,width:n});continue}let i=c+r,o=k(e,i);if(a&&o>n&&c){s.push({...t,text:c,width:l}),c=r,l=k(e,r);continue}c=i,l=o}return c&&s.push({...t,text:c,width:l}),s}function ce(e,t,n,r,i=!1,a=0){let o=[],s={words:[],totalWidth:0,lineHeight:0},c=r===`nowrap`||r===`pre`,l=()=>n-(o.length===0?a:0),u=r===`pre-wrap`||r===`pre`||r===`pre-line`,d=r===`pre`||r===`pre-wrap`||r===`break-spaces`;function f(t=!1){let i=s.words.length>0;if(!(r===`break-spaces`||d&&!t))for(;s.words.length>0&&s.words[s.words.length-1].isSpace;)s.totalWidth-=s.words[s.words.length-1].width,s.words.pop();if(t&&s.words.length>0){let t=s.words[s.words.length-1];if(t.isSoftHyphenBreak){j(e,t.style);let n=k(e,`-`);s.words.push({text:`-`,width:n,style:t.style,isSpace:!1}),s.totalWidth+=n}}if(s.words.length>0||i&&u){if(E){let e=s.words.map(e=>e.text).join(``);E({type:`line-commit`,message:`Line ${o.length}: "${e}" width=${s.totalWidth.toFixed(2)} / ${n}`,data:{lineIndex:o.length,text:e,totalWidth:s.totalWidth,contentWidth:n}})}o.push(s)}s={words:[],totalWidth:0,lineHeight:0}}let p=!0;for(let r of t){let t=z(e,r.style,i);if(r.boxStyle&&r.boxStyle.display===`inline-block`){let e=r.boxStyle;t=Math.max(t,t+e.paddingTop+e.paddingBottom+e.marginTop+e.marginBottom+e.borderTopWidth+e.borderBottomWidth)}if(r.text===`
|
|
9
|
+
`){s.words.length===0?(s.lineHeight=t,s.endedByHardBreak=!0,o.push(s),s={words:[],totalWidth:0,lineHeight:0}):(s.endedByHardBreak=!0,f()),p=!0;continue}if(c){s.words.push(r),s.totalWidth+=r.width,s.lineHeight=Math.max(s.lineHeight,t);continue}let a=!r.isSpace&&r.text.length>1?se(e,r,l(),s.totalWidth):[r];for(let r of a){let i=!r.isSpace&&r.text.length>0&&/^[,.\;:!?\)\]\}'"»›]+$/.test(r.text)&&s.words.length>0&&!s.words[s.words.length-1].isSpace;if(!r.isSpace&&!i&&s.words.length>0&&s.totalWidth+r.width>l()){let i=s.totalWidth+r.width-l(),a=!0;if(i<1&&!A([...s.words,r])&&(j(e,r.style),k(e,s.words.map(e=>e.text).join(``)+r.text)<=l()+.1&&(a=!1)),a&&r.text.includes(`-`)){let n=r.text.split(/(?<=-)/);if(n.length>1){j(e,r.style);let i=``,a=0,o=0,c=l()-s.totalWidth;for(;o<n.length;o++){let t=i+n[o],r=k(e,t);if(r>c)break;i=t,a=r}if(o>0&&o<n.length){s.words.push({...r,text:i,width:a}),s.totalWidth+=a,s.lineHeight=Math.max(s.lineHeight,t),f(!0),p=!1;let c=n.slice(o).join(``),l=k(e,c);s.words.push({...r,text:c,width:l}),s.totalWidth+=l,s.lineHeight=Math.max(s.lineHeight,t);continue}}}if(a){if(E){let e=s.words.map(e=>e.text).join(``);E({type:`line-wrap`,message:`"${r.text}" overflow=${i.toFixed(2)} wrap=true lineWidth=${s.totalWidth.toFixed(2)} pieceWidth=${r.width.toFixed(2)} contentWidth=${n} line="${e}"`,data:{text:r.text,overflow:i,lineWidth:s.totalWidth,pieceWidth:r.width,contentWidth:n,lineText:e}})}f(!0),p=!1}}if(r.isSpace&&s.words.length===0&&(!p||!d))continue;let a=r.width;if(r.isTab){let e=r.width,t=s.totalWidth;a=Math.ceil((t+.1)/e)*e-t,r.width=a}if(s.words.length===0&&a>l()&&!r.isSpace&&r.text.includes(`-`)){let n=r.text.split(/(?<=-)/);if(n.length>1){j(e,r.style);let i=n.filter(e=>e).map(t=>({...r,text:t,width:k(e,t)})),a=!0;for(let e of i)a?(a=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,t)):s.totalWidth+e.width>l()?(f(!0),p=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,t)):(s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,t));continue}}s.words.push(r),s.totalWidth+=a,s.lineHeight=Math.max(s.lineHeight,t),r.isSpace||(p=!1)}}return f(),o}function X(e,t,n,r,i,a=!1){let o=[],s=re(t);if(s.length===0)return{nodes:o,height:0};let c=oe(e,s),l=t.style.textIndent||0,u=ce(e,c,i,t.style.whiteSpace,a,l),d=t.style.direction===`rtl`,f=e=>e===`start`?d?`right`:`left`:e===`end`?d?`left`:`right`:e,p=f(t.style.textAlign),m=t.style.textAlignLast||`auto`;m=m===`auto`?t.style.textAlign===`justify`?d?`right`:`left`:p:f(m);let h=r;for(let t=0;t<u.length;t++){let r=u[t];if(r.words.length===0){h+=r.lineHeight;continue}let a=r.lineHeight,s=t===u.length-1,c=t===0,f=s||r.endedByHardBreak?m:p,g=c?l:0,_=i-g,v=0;if(f===`justify`&&r.totalWidth<_){let e=r.words.filter(e=>e.isSpace).length;e>0&&(v=(_-r.totalWidth)/e)}let y=n+g;f===`center`?y=n+g+(_-r.totalWidth)/2:(f===`right`||f!==`justify`&&d||d)&&(y=n+g+_-r.totalWidth);let b=y,x=0,S=0;for(let t of r.words){if(t.text===``)continue;let n=t.style.verticalAlign;if(n===`super`||n===`sub`)continue;let{ascent:r,descent:i}=W(e,t.style);r>x&&(x=r),i>S&&(S=i)}if(x===0)for(let t of r.words){if(t.text===``)continue;let{ascent:n,descent:r}=W(e,t.style);x=n,S=r;break}let C=x+S,w=h+(a-C)/2+x,T=r.words.filter(e=>e.text!==``&&e.style.verticalAlign!==`super`&&e.style.verticalAlign!==`sub`),E=T.length>0?Math.max(...T.map(e=>e.style.fontSize)):0,O=h,A=h+a;for(let t of r.words){if(t.text===``)continue;let n=t.style.verticalAlign;if(n!==`super`&&n!==`sub`)continue;if(E===0)break;let{ascent:r,descent:i}=W(e,t.style),a=w;n===`super`?a-=E*.4:a+=E*.26;let o=a-r,s=a+i;o<O&&(O=o),s>A&&(A=s)}let M=A-O,N=(t,n,r)=>{let{ascent:i,descent:a}=W(e,t),s=t.paddingTop+t.borderTopWidth,c=t.paddingBottom+t.borderBottomWidth,l=i+a+s+c,u;u=t.display===`inline-block`?h+t.marginTop:w-i-s,o.push({type:`box`,style:t,x:n,y:u,width:r,height:l,tagName:`span`,children:[]})};if(!d){let e=y,t=e,n,i=!1;for(let a of r.words){if(a.boxOpen&&a.boxClose&&a.text){n&&(i&&N(n,t,e-t),n=void 0,i=!1);let r=a.style,o=a.width-r.marginLeft-r.borderLeftWidth-r.paddingLeft-r.paddingRight-r.borderRightWidth-r.marginRight;N(r,e+r.marginLeft,r.borderLeftWidth+r.paddingLeft+o+r.paddingRight+r.borderRightWidth),i=!1,e+=a.width;continue}a.boxStyle!==n&&(n&&i&&N(n,t,e-t),n=a.boxStyle,t=e,i=!1),a.text&&!a.isSpace&&(i=!0),e+=a.width+(a.isSpace?v:0)}n&&i&&N(n,t,e-t)}let P=r.words.filter(e=>e.text!==``),F=P.length>0&&P.every(e=>G(e.style,P[0].style));if(d){let t=[],n=null,i=0;for(let e of r.words){if(e.text===``){n&&=(t.push(n),null),i+=e.width;continue}n&&G(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,x:0,padBefore:i},i=0)}n&&t.push(n);let a=y+r.totalWidth;for(let n of t){a-=n.padBefore,j(e,n.style);let t=k(e,n.text);a-=t,n.x=a,n.width=t}for(let e of t)if(e.boxStyle&&K(e.boxStyle)){let t=e.boxStyle,n=t.paddingLeft+t.borderLeftWidth,r=t.paddingRight+t.borderRightWidth;N(t,e.x-n,e.width+n+r)}for(let e of t)o.push({type:`text`,text:e.text,x:e.x+e.width,y:w,width:e.width,style:{...e.style,direction:`rtl`}})}else{let t=r.words.map(e=>e.text).join(``);if(F&&/[\u0590-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(t)&&!r.words.some(e=>e.boxOpen||e.boxClose||e.style.verticalAlign===`super`||e.style.verticalAlign===`sub`)){j(e,P[0].style);let n=k(e,t);o.push({type:`text`,text:t,x:y,y:w,width:n,style:P[0].style})}else for(let t of r.words){if(t.text===``){y+=t.width;continue}if(t.boxOpen&&t.boxClose){let n=t.style,r=y+n.marginLeft+n.borderLeftWidth+n.paddingLeft;o.push({type:`text`,text:t.text,x:r,y:w,width:k(e,t.text),style:t.style}),y+=t.width;continue}let n=w,r=t.style.verticalAlign;if(r===`super`||r===`sub`){let e=E||t.style.fontSize;r===`super`?n-=e*.4:n+=e*.26}let i=t.width+(t.isSpace?v:0);o.push({type:`text`,text:t.text,x:y,y:n,width:i,style:t.style}),y+=i}}let I=f===`justify`&&v>0?_:r.totalWidth;D.push({y:Math.round(w),text:r.words.map(e=>e.text).join(``),bounds:{x:b,y:O,width:I,height:M}}),h+=M}return{nodes:o,height:h-r}}function le(e,t){return e>=0&&t>=0?Math.max(e,t):e<0&&t<0?Math.min(e,t):e+t}function Z(e,t,n,r,i){let a=t.style,o=a.marginLeft,s=a.marginRight,c=a.borderLeftWidth,l=a.borderRightWidth,u=a.borderTopWidth,d=a.borderBottomWidth,f=a.paddingLeft,p=a.paddingRight,m=a.paddingTop,h=a.paddingBottom,g=n+o,_=a.width>0?a.width:i-o-s,v=g+c+f,y=Math.max(0,_-c-l-f-p),b=r,x=b+u+m,S={type:`box`,style:a,x:g,y:b,width:_,height:0,tagName:t.tagName,children:[],listMarker:t.listMarker};if(a.display===`flex`){let n=de(e,t,v,x,y);return S.children=n.children,S.height=u+m+n.height+h+d,{box:S,height:S.height,marginBottomOut:a.marginBottom}}if(a.display===`table`){let n=ue(e,t,v,x,y);return S.children=n.children,S.height=u+m+n.height+h+d,{box:S,height:S.height,marginBottomOut:a.marginBottom}}if(t.children.length===0)return S.height=u+m+h+d,a.minHeight>0&&(S.height=Math.max(S.height,a.minHeight)),{box:S,height:S.height,marginBottomOut:a.marginBottom};if(ne(t)){let{nodes:n,height:r}=X(e,t,v,x,y,t.tagName===`li`&&R.has(a.listStyleType));S.children=n,S.height=u+m+r+h+d}else{let n=x,r=0,i=!1,o=t.tagName===`li`||t.tagName===`ul`||t.tagName===`ol`||t.tagName===`dd`||t.tagName===`dt`;for(let s=0;s<t.children.length;s++){let c=t.children[s];if(c.tagName===`#text`||V(c)){let o=[c];for(;s+1<t.children.length;){let e=t.children[s+1];if(e.tagName===`#text`||V(e))o.push(e),s++;else break}r>0&&(n+=r,r=0);let l={element:null,tagName:`div`,style:{...t.style,display:`block`,marginTop:0,marginBottom:0,paddingTop:0,paddingBottom:0,borderTopWidth:0,borderBottomWidth:0},children:o,textContent:null},u=t.tagName===`li`&&R.has(a.listStyleType),{nodes:d,height:f}=X(e,l,v,n,y,u);S.children.push(...d),n+=f,r=0,i=!0;continue}let l=c.style.marginTop;if(!(!i&&m===0&&u===0&&o)){let e=le(r,l);n+=e}let{box:d,height:f,marginBottomOut:p}=Z(e,c,v,n,y);S.children.push(d),n+=f,r=p,i=!0}let s=a.marginBottom,c=h===0&&d===0&&o;c&&r>0&&(s=Math.max(a.marginBottom,r));let l=n-x;return!c&&r>0&&(l+=r),S.height=u+m+l+h+d,a.minHeight>0&&(S.height=Math.max(S.height,a.minHeight)),{box:S,height:S.height,marginBottomOut:s}}return a.minHeight>0&&(S.height=Math.max(S.height,a.minHeight)),{box:S,height:S.height,marginBottomOut:a.marginBottom}}function ue(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}}function de(e,t,n,r,i){let a=t.style,o=a.gap,s=[],c=t.children.filter(e=>e.tagName!==`#text`||e.textContent?.trim());if(c.length===0)return{children:s,height:0};if(a.flexDirection===`row`||a.flexDirection===``){let t=o*(c.length-1),a=c.reduce((e,t)=>e+(t.style.flexGrow||0),0),l=(i-t)/(a||c.length),u=n,d=0;for(let t of c){if(t.tagName===`#text`)continue;let n=l*(t.style.flexGrow||(a===0?1:0)),{box:i,height:c}=Z(e,t,u,r,n);s.push(i),d=Math.max(d,c),u+=n+o}return{children:s,height:d}}let l=r;for(let t of c){if(t.tagName===`#text`)continue;let{box:r,height:a}=Z(e,t,n,l,i);s.push(r),l+=a+o}return{children:s,height:l-r}}function fe(e,t,n){if(!n.listMarker||n.markerHidden)return;let r=n.style,i=n.markerStyle,a=i?{...r,...i}:r;e.font=N(a);let o=z(e,r),s=t.y+r.borderTopWidth+r.paddingTop+te(e,r,o),c=k(e,n.listMarker),l=r.direction===`rtl`,u=l?i?.paddingLeft:i?.paddingRight,d=u===void 0?a.fontSize*.15:u,f,p=`ltr`;if(l){let e=t.x+t.width;/\d/.test(n.listMarker)?(p=`rtl`,f=e+d+c):f=e+d}else f=t.x+r.borderLeftWidth+r.paddingLeft-c-d;t.children.unshift({type:`text`,text:n.listMarker,x:f,y:s,width:c,style:{...a,textDecorationLine:`none`,fontWeight:i?.fontWeight??400,fontStyle:i?.fontStyle??`normal`,direction:p}});let m=l&&/\d/.test(n.listMarker)?f-c:f;D.push({y:Math.round(s),text:n.listMarker,bounds:{x:m,y:t.y+r.borderTopWidth+r.paddingTop,width:c,height:o}})}function pe(e,t,n,r=!0,i){T=r,E=i,P.clear(),U.clear(),M.clear(),O.clear(),D=[];let{box:a,height:o}=Z(e,t,0,0,n);Q(e,a,t);let s=D.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=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 Q(e,t,n){fe(e,t,n);let r=0;for(let i of n.children)if(!(i.tagName===`#text`||V(i)))for(;r<t.children.length;){let n=t.children[r];if(n.type===`box`&&n.tagName===i.tagName){Q(e,n,i),r++;break}r++}}function me(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 he(e,t){return e[`border${t}Width`]>0&&e[`border${t}Style`]!==`none`}function $(e,t,n,r,i,a,o){if(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 ge(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 _e(e,t,n){let{style:r}=t;e.save(),e.font=N(r),e.textBaseline=`alphabetic`,e.fontKerning=r.fontKerning===`none`?`none`:`normal`,r.letterSpacing>0&&(e.letterSpacing=`${r.letterSpacing}px`),r.wordSpacing&&(e.wordSpacing=`${r.wordSpacing}px`),r.direction===`rtl`&&(e.direction=`rtl`,e.textAlign=`right`);let i=r.webkitBackgroundClip===`text`&&r.backgroundImage&&r.backgroundImage!==`none`,a=r.webkitTextStrokeWidth>0,o=r.webkitTextFillColor===`transparent`||r.color===`transparent`,s=me(r.textShadow);if(s.length>0)for(let n of s)e.save(),e.shadowOffsetX=n.offsetX,e.shadowOffsetY=n.offsetY,e.shadowBlur=n.blur,e.shadowColor=n.color,e.fillStyle=r.color,e.fillText(t.text,t.x,t.y),e.restore();let c=()=>{if(i){if(e.save(),n)e.fillStyle=n;else{let{ascent:n,descent:i}=W(e,r);e.fillStyle=ge(e,r.backgroundImage,t.x,t.width,t.y-n,n+i)||r.color}e.fillText(t.text,t.x,t.y),e.restore()}else (!o||!a)&&(e.fillStyle=r.webkitTextFillColor&&r.webkitTextFillColor!==`transparent`?r.webkitTextFillColor:r.color,e.fillText(t.text,t.x,t.y))},l=()=>{a&&(e.save(),e.strokeStyle=r.webkitTextStrokeColor||r.color,e.lineWidth=r.webkitTextStrokeWidth,e.lineJoin=`round`,e.strokeText(t.text,t.x,t.y),e.restore())};f(r.paintOrder)?(l(),c()):(c(),l());let u=t.width,d=r.fontSize,p=r.textDecorationColor||r.color,m=r.textDecorationStyle||`solid`,h=Math.max(1,d/15),g=r.direction===`rtl`?t.x-u:t.x;if(r.textDecorationLine!==`none`){let{ascent:n}=W(e,r);e.font=N(r);let i=e.measureText(`x`).actualBoundingBoxAscent;if(r.textDecorationLine.includes(`underline`)){let n=d*.1;$(e,g,t.y+n,u,h,m,p)}if(r.textDecorationLine.includes(`line-through`)){let n=-(i*.5);$(e,g,t.y+n,u,h,m,p)}r.textDecorationLine.includes(`overline`)&&$(e,g,t.y-n,u,h,m,p)}e.restore()}function ve(e,t){let{style:n}=t;H(n.backgroundColor)||(e.fillStyle=n.backgroundColor,e.fillRect(t.x,t.y,t.width,t.height));let r=[[`Top`,t.x,t.y+n.borderTopWidth/2,t.x+t.width,t.y+n.borderTopWidth/2],[`Right`,t.x+t.width-n.borderRightWidth/2,t.y,t.x+t.width-n.borderRightWidth/2,t.y+t.height],[`Bottom`,t.x,t.y+t.height-n.borderBottomWidth/2,t.x+t.width,t.y+t.height-n.borderBottomWidth/2],[`Left`,t.x+n.borderLeftWidth/2,t.y,t.x+n.borderLeftWidth/2,t.y+t.height]];for(let[t,i,a,o,s]of r)he(n,t)&&(e.strokeStyle=n[`border${t}Color`],e.lineWidth=n[`border${t}Width`],e.beginPath(),e.moveTo(i,a),e.lineTo(o,s),e.stroke());let i=null;n.webkitBackgroundClip===`text`&&n.backgroundImage&&n.backgroundImage!==`none`&&(i=ge(e,n.backgroundImage,t.x,t.width,t.y,t.height));for(let n of t.children)ye(e,n,i)}function ye(e,t,n){t.type===`text`?_e(e,t,n):ve(e,t)}function be(e){let{html:n,width:r,height:i,accuracy:a=`performance`,debug:o}=e;if(!r||r<=0||Number.isNaN(r))throw TypeError(`layout: width must be a positive number, got ${r}`);let s=a===`balanced`,{fragment:c,css:l}=t(n),{tree:u,cleanup:d}=w(c,l,r),f=document.createElement(`canvas`).getContext(`2d`);f.fontKerning=`normal`;let{root:p,height:m,lines:h}=pe(f,u,r,s,o),g=i||m;return d(),{layoutRoot:p,height:g,lines:h}}function xe(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;return e.ctx?(o=e.ctx,a=e.ctx.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)),ye(o,t.layoutRoot),{canvas:a}}function Se(e){if(e.ctx&&e.canvas)throw TypeError(`render: ctx and canvas are mutually exclusive — provide one or neither`);let t=be({html:e.html,width:e.width,height:e.height,accuracy:e.accuracy,debug:e.debug}),{canvas:n}=xe({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=xe,e.layout=be,e.render=Se});
|
|
10
10
|
//# sourceMappingURL=render-tag.umd.js.map
|