render-tag 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
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:`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)`,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`,unicodeBidi:`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`,lineClamp:0}}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`},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 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`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=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`-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=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(`
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:`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)`,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`,unicodeBidi:`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`,lineClamp:0}}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`},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 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}):!/^[\d.+-]/.test(e)&&e!==`auto`&&e!==`from-font`&&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){let t=e.trim();return t.toLowerCase()===`currentcolor`?``:t}function g(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`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=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=h(n);break;case`-webkit-text-fill-color`:e.webkitTextFillColor=h(n);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`-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=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 _=[[`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`],[`-webkit-text-stroke-width`,`webkitTextStrokeWidth`],[`-webkit-text-stroke-color`,`webkitTextStrokeColor`],[`-webkit-text-fill-color`,`webkitTextFillColor`]];function v(e,t,n){for(let[r,i]of _)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 y(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 b(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`${x(e).toLowerCase()}.`;case`upper-roman`:return`${x(e)}.`;case`lower-alpha`:case`lower-latin`:return`${S(e).toLowerCase()}.`;case`upper-alpha`:case`upper-latin`:return`${S(e)}.`;default:return`${e}.`}}function x(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 S(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 C(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 b(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 b(c,t||`decimal`);c+=s}return b(c,t||`decimal`)}}function w(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 T(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=y(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=[],_=new Set,y=u.byTag.get(i);if(y)for(let e of y)_.add(e),p.push(e);for(let e of a.classes){let t=u.byClass.get(e);if(t)for(let e of t)_.has(e)||(_.add(e),p.push(e))}for(let e of u.universal)_.has(e)||(_.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 S=l[i],T=!1;if(S?.fontSize!==void 0){let e=S.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`&&(g(o,e.property,e.value,t.fontSize,r,t.direction),T=!0);if(e instanceof HTMLElement&&e.style.cssText){let n=w(e.style.cssText);for(let e of n)e.property===`font-size`&&(g(o,e.property,e.value,t.fontSize,r,t.direction),T=!0)}T||(o.fontSize=t.fontSize);let E=o.fontSize;if(S){for(let[e,t]of Object.entries(S)){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`&&(g(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=w(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)g(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`),v(o,t,d),d.has(`text-decoration-color`)||(o.textDecorationColor=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=C(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]);g(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=h(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 h(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
- `}: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`+(e.letterSpacing||``)+`\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=P(n.style);if(t&&e!==t)return!0;t=e}return!1}function j(e,t){e.font=P(t),e.fontKerning=t.fontKerning===`none`?`none`:`normal`}function M(e){return Number.isFinite(e)&&e!==0?`${e}px`:`0px`}var N=new Map;function P(e){let t=`${e.fontStyle}|${e.fontVariantCaps}|${e.fontWeight}|${e.fontSize}|${e.fontFamily}`,n=N.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 N.set(t,i),i}var F=new Map,I=null,L=null,R=null,z=new Set([`disc`,`circle`,`square`]);function ee(e,t,n=!1){let r=`${e}|${t}|${n?`ul-li`:`block`}`,i=F.get(r);if(i!==void 0)return i;let a;n?(L||(L=document.createElement(`ul`),L.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;padding:0;margin:0;border:0;list-style:disc;`,R=document.createElement(`li`),R.style.cssText=`white-space:nowrap;padding:0;margin:0;border:0;`,R.textContent=`Mg`,L.appendChild(R),document.body.appendChild(L)),a=R):(I||(I=document.createElement(`div`),I.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;white-space:nowrap;padding:0;margin:0;border:0;`,I.textContent=`Mg`,document.body.appendChild(I)),a=I),a.style.font=e,a.style.lineHeight=t;let o=a.getBoundingClientRect().height;return F.set(r,o),o}function B(e,t,n=!1){if(t.lineHeight>0)return T?ee(P(t),`${t.lineHeight}px`,n):t.lineHeight;if(T)return ee(P(t),`normal`,n);let{ascent:r,descent:i}=U(e,t);return r+i}function te(e,t,n){let{ascent:r,descent:i}=U(e,t);return(r-i)/2+n/2}function ne(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 V(e){if(e.tagName===`#text`)return!0;let t=e.style.display;return t===`inline`||t===`inline-block`}function re(e){return e.children.length>0&&e.children.every(V)}function ie(e){return!e||e===`transparent`||e===`rgba(0, 0, 0, 0)`}var H=new Map;function U(e,t){let n=P(t),r=H.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 H.set(n,a),a}function ae(e,t,n,r,i,a,o){switch(e){case`super`:return-r*.4;case`sub`:return r*.26;case`text-top`:return-(i-t);case`text-bottom`:return a-n;case`middle`:return-(r*.25)-(n-t)/2;default:{let t=parseFloat(e);return Number.isFinite(t)?e.endsWith(`%`)?-(t/100)*o:-t:0}}}function W(e){return e!==`baseline`&&e!==`top`&&e!==`bottom`&&e!==``}function oe(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 se(e){return!ie(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 ce(e){return!!(e.boxOpen&&e.boxClose&&e.text)}function le(e,t,n){let r=t.words.length-1;for(;r>=0&&(t.words[r].text===``||ce(t.words[r]));)r--;if(r<0)return;let i=t.words[r].style,a=t.words[r].boxStyle;j(e,i),e.letterSpacing=`${i.letterSpacing||0}px`;let o=k(e,`…`),s=()=>{for(;t.words.length>0&&t.words[t.words.length-1].isSpace;){let e=t.words.pop();t.totalWidth-=e.width}};s();let c=e=>!e.isSpace&&e.text!==``&&!e.boxOpen&&!e.boxClose;for(;t.totalWidth+o>n&&t.words.length>0;){let e=t.words[t.words.length-1];if(!c(e)&&!ce(e))break;t.totalWidth-=e.width,t.words.pop(),s()}let l={text:`…`,width:o,style:i,isSpace:!1,boxStyle:a};t.words.push(l),t.totalWidth+=o}function ue(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)&&se(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}let c=e.style.unicodeBidi,l=(c===`bidi-override`||c===`isolate-override`)&&e.style.direction===`rtl`,u=t.length;s&&t.push({text:``,style:e.style,boxStyle:o,boxOpen:e.style});for(let t of e.children)n(t,a?o:r);if(s&&t.push({text:``,style:e.style,boxStyle:o,boxClose:e.style}),l&&t.length>u){let e=t.splice(u);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);return t}function G(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 K;function de(){return K||(typeof Intl<`u`&&Intl.Segmenter?(K=new Intl.Segmenter(void 0,{granularity:`word`}),K):null)}function q(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;q(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]+)/).flatMap(e=>/^[ \t\n\r\f\v]+$/.test(e)?[e]:e.split(/(?<=\?)(?=.)/)),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(G(t)){let i=de();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 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){j(e,r.style),e.letterSpacing=M(r.style.letterSpacing);let t=ne(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=M(r.style.letterSpacing);let t=ne(r.text,r.style.textTransform),i=e=>{let t=n[e];if(!t||t.isSpace||!t.text||t.text===`
6
- `)return;let r=n[e-1];if(!r||r.isSpace||!r.text.trim()||r.boxOpen||r.boxClose)return;let i=[...t.text][0],a=[...r.text][r.text.length-1];J(i)||J(a)||G(t.text)||G(r.text)||(t.noBreakBefore=!0)};if(t.includes(`
5
+ `}:p(r,t,n)}return{tree:p(d,c(),null),cleanup:()=>{o&&o.remove()}}}var E=!0,D,O=[],k=new Map;function A(e,t){let n=e.font+`\0`+(e.letterSpacing||``)+`\0`+t,r=k.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return k.set(n,i),i}function j(e){let t=``;for(let n of e){if(!n.text||n.isSpace)continue;let e=F(n.style);if(t&&e!==t)return!0;t=e}return!1}function M(e,t){e.font=F(t),e.fontKerning=t.fontKerning===`none`?`none`:`normal`}function N(e){return Number.isFinite(e)&&e!==0?`${e}px`:`0px`}var P=new Map;function F(e){let t=`${e.fontStyle}|${e.fontVariantCaps}|${e.fontWeight}|${e.fontSize}|${e.fontFamily}`,n=P.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 P.set(t,i),i}var I=new Map,L=null,R=null,z=null,B=new Set([`disc`,`circle`,`square`]);function ee(e,t,n=!1){let r=`${e}|${t}|${n?`ul-li`:`block`}`,i=I.get(r);if(i!==void 0)return i;let a;n?(R||(R=document.createElement(`ul`),R.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;padding:0;margin:0;border:0;list-style:disc;`,z=document.createElement(`li`),z.style.cssText=`white-space:nowrap;padding:0;margin:0;border:0;`,z.textContent=`Mg`,R.appendChild(z),document.body.appendChild(R)),a=z):(L||(L=document.createElement(`div`),L.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;white-space:nowrap;padding:0;margin:0;border:0;`,L.textContent=`Mg`,document.body.appendChild(L)),a=L),a.style.font=e,a.style.lineHeight=t;let o=a.getBoundingClientRect().height;return I.set(r,o),o}function V(e,t,n=!1){if(t.lineHeight>0)return E?ee(F(t),`${t.lineHeight}px`,n):t.lineHeight;if(E)return ee(F(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 ne(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 H(e){if(e.tagName===`#text`)return!0;let t=e.style.display;return t===`inline`||t===`inline-block`}function re(e){return e.children.length>0&&e.children.every(H)}function ie(e){return!e||e===`transparent`||e===`rgba(0, 0, 0, 0)`}var U=new Map;function W(e,t){let n=F(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 ae(e,t,n,r,i,a,o){switch(e){case`super`:return-r*.4;case`sub`:return r*.26;case`text-top`:return-(i-t);case`text-bottom`:return a-n;case`middle`:return-(r*.25)-(n-t)/2;default:{let t=parseFloat(e);return Number.isFinite(t)?e.endsWith(`%`)?-(t/100)*o:-t:0}}}function G(e){return e!==`baseline`&&e!==`top`&&e!==`bottom`&&e!==``}function oe(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 se(e){return!ie(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 ce(e){return!!(e.boxOpen&&e.boxClose&&e.text)}function le(e,t,n){let r=t.words.length-1;for(;r>=0&&(t.words[r].text===``||ce(t.words[r]));)r--;if(r<0)return;let i=t.words[r].style,a=t.words[r].boxStyle;M(e,i),e.letterSpacing=`${i.letterSpacing||0}px`;let o=A(e,`…`),s=()=>{for(;t.words.length>0&&t.words[t.words.length-1].isSpace;){let e=t.words.pop();t.totalWidth-=e.width}};s();let c=e=>!e.isSpace&&e.text!==``&&!e.boxOpen&&!e.boxClose;for(;t.totalWidth+o>n&&t.words.length>0;){let e=t.words[t.words.length-1];if(!c(e)&&!ce(e))break;t.totalWidth-=e.width,t.words.pop(),s()}let l={text:`…`,width:o,style:i,isSpace:!1,boxStyle:a};t.words.push(l),t.totalWidth+=o}function ue(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||H(e)&&se(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}let c=e.style.unicodeBidi,l=(c===`bidi-override`||c===`isolate-override`)&&e.style.direction===`rtl`,u=t.length;s&&t.push({text:``,style:e.style,boxStyle:o,boxOpen:e.style});for(let t of e.children)n(t,a?o:r);if(s&&t.push({text:``,style:e.style,boxStyle:o,boxClose:e.style}),l&&t.length>u){let e=t.splice(u);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);return t}function K(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 de(){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=A(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:A(e,t),style:n.style,isSpace:i,boxStyle:n.boxStyle})}}else{let a=t.split(/([ \t\n\r\f\v]+)/).flatMap(e=>/^[ \t\n\r\f\v]+$/.test(e)?[e]:e.split(/(?<=\?)(?=.)/)),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(K(t)){let i=de();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=A(e,t);D&&D({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 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){M(e,r.style),e.letterSpacing=N(r.style.letterSpacing);let t=ne(r.text,r.style.textTransform),i=r.style,a=A(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}M(e,r.style),e.letterSpacing=N(r.style.letterSpacing);let t=ne(r.text,r.style.textTransform),i=e=>{let t=n[e];if(!t||t.isSpace||!t.text||t.text===`
6
+ `)return;let r=n[e-1];if(!r||r.isSpace||!r.text.trim()||r.boxOpen||r.boxClose)return;let i=[...t.text][0],a=[...r.text][r.text.length-1];Y(i)||Y(a)||K(t.text)||K(r.text)||(t.noBreakBefore=!0)};if(t.includes(`
7
7
  `)){let a=t.split(`
8
8
  `);for(let t=0;t<a.length;t++)if(t>0&&n.push({text:`
9
- `,width:0,style:r.style,isSpace:!1,boxStyle:r.boxStyle}),a[t]){let o=n.length;q(e,a[t],r,n),i(o)}}else{let a=n.length;q(e,t,r,n),i(a)}}return n}function J(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 Y;function pe(){return Y||(typeof Intl<`u`&&Intl.Segmenter?(Y=new Intl.Segmenter(void 0,{granularity:`grapheme`}),Y):null)}var X=/\p{Extended_Pictographic}/u;function me(e){for(let t of e)if(t.codePointAt(0)>=126976)return!0;return e.includes(`‍`)||e.includes(`️`)?X.test(e):!1}function Z(e,t,n,r){let i=[...t.text].some(J),a=X.test(t.text)&&!!pe(),o=t.width>n&&(t.style.overflowWrap===`break-word`||t.style.wordBreak===`break-all`);if(!i&&!a&&!o)return[t];if(o&&t.style.wordBreak!==`break-all`&&t.style.overflowWrap===`break-word`){let r=t.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/).filter(e=>e.length);if(r.length>1){e.font=P(t.style),e.letterSpacing=M(t.style.letterSpacing);let i=[];for(let a of r){let r=k(e,a);r<=n?i.push({...t,text:a,width:r}):i.push(...Z(e,{...t,text:a,width:r},n,0))}return i}}e.font=P(t.style),e.letterSpacing=M(t.style.letterSpacing);let s=a?pe():null,c=s?[...s.segment(t.text)].map(e=>e.segment):[...t.text],l=[],u=``,d=0;for(let r of c){if(a&&me(r)){u&&(l.push({...t,text:u,width:d}),u=``,d=0),l.push({...t,text:r,width:k(e,r)});continue}if(J(r)){u&&(l.push({...t,text:u,width:d}),u=``,d=0);let n=k(e,r);l.push({...t,text:r,width:n});continue}let i=u+r,s=k(e,i);if(o&&s>n&&u){l.push({...t,text:u,width:d}),u=r,d=k(e,r);continue}u=i,d=s}return u&&l.push({...t,text:u,width:d}),l}var he=/^[,.\;:!?\)\]\}'"»›]+$/;function ge(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=0;r<t.length;r++){let a=t[r],u=B(e,a.style,i);if(a.boxStyle&&a.boxStyle.display===`inline-block`){let e=a.boxStyle;u=Math.max(u,u+e.paddingTop+e.paddingBottom+e.marginTop+e.marginBottom+e.borderTopWidth+e.borderBottomWidth)}if(a.text===`
10
- `){s.words.length===0?(s.lineHeight=u,s.endedByHardBreak=!0,o.push(s),s={words:[],totalWidth:0,lineHeight:0}):(s.endedByHardBreak=!0,f()),p=!0;continue}if(c){s.words.push(a),s.totalWidth+=a.width,s.lineHeight=Math.max(s.lineHeight,u);continue}if(!a.isSpace&&a.text&&!a.noBreakBefore&&!a.boxOpen&&!a.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 o=a.style.overflowWrap===`break-word`||a.style.wordBreak===`break-all`,c=0;for(let e=r;e<=n;e++)c+=t[e].width;let u=[];for(let e=r;e<=n;e++)for(let n of[...t[e].text])u.push({ch:n,style:t[e].style});let d=u.map(e=>e.ch).join(``).split(/(?<=-)(?!\d)|(?<=[^\d]-)/).filter(e=>e.length),m=d.length>1;if(!(s.totalWidth+c<=l())&&(m||o&&c>l())){let t=[],a=0;for(let e of d){let n=[...e].length;t.push(u.slice(a,a+n)),a+=n}let c=(t,n)=>{let r=0;for(;r<t.length;){let a=t[r].style;j(e,a),e.letterSpacing=M(a.letterSpacing);let o=B(e,a,i),c=``,u=0;for(;r<t.length&&t[r].style===a;){let i=t[r].ch,d=k(e,c+i);n&&s.totalWidth+d>l()&&(s.words.length>0||c)?(c&&(s.words.push({text:c,width:u,style:a,isSpace:!1}),s.totalWidth+=u,s.lineHeight=Math.max(s.lineHeight,o)),f(!0),p=!1,c=i,u=k(e,i)):(c+=i,u=d),r++}c&&(s.words.push({text:c,width:u,style:a,isSpace:!1}),s.totalWidth+=u,s.lineHeight=Math.max(s.lineHeight,o),p=!1)}},h=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++;j(e,i),e.letterSpacing=M(i.letterSpacing),n+=k(e,a)}return n};!m&&s.words.length>0&&(f(!0),p=!1);for(let e of t){let t=h(e);s.words.length>0&&s.totalWidth+t>l()&&(f(!0),p=!1),c(e,o&&t>l())}r=n;continue}}}let m=!a.isSpace&&a.text.length>1?Z(e,a,l(),s.totalWidth):[a],h=0;for(let e=r+1;e<t.length;e++){let n=t[e];if(n.isSpace||n.text===`
11
- `)break;let r=!!n.text&&he.test(n.text),i=!n.text&&!!n.boxClose,a=!!n.text&&!!n.noBreakBefore;if(r||i||a){h+=n.width;continue}break}for(let i of m){let a=i===m[m.length-1]?h:0,o=!i.isSpace&&i.text.length>0&&he.test(i.text)&&s.words.length>0&&!s.words[s.words.length-1].isSpace,c=i===m[0]&&i.noBreakBefore&&s.words.length>0&&!s.words[s.words.length-1].isSpace,g=0;if(!i.text&&i.boxOpen){let n=t[r+1];n&&!n.isSpace&&n.text&&(g=(n.text.length>1?Z(e,n,l(),0):[n])[0].width)}let _=0;if(i.isSoftHyphenBreak&&(j(e,i.style),e.letterSpacing=M(i.style.letterSpacing),_=k(e,`-`)),!i.isSpace&&!o&&!c&&s.words.length>0&&s.totalWidth+i.width+_+a+g>l()){let t=s.totalWidth+i.width+_+a+g-l(),r=!0;if(t<1&&!A([...s.words,i])){j(e,i.style);let t=s.words.map(e=>e.text).join(``)+i.text+(i.isSoftHyphenBreak?`-`:``),n=0;for(let e of s.words)e.text||(n+=e.width);i.text||(n+=i.width),k(e,t)+n+a+g<=l()+.02&&(r=!1)}if(r&&i.text.includes(`-`)){let t=i.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/);if(t.length>1){j(e,i.style);let n=``,r=0,a=0,o=l()-s.totalWidth;for(;a<t.length;a++){let i=n+t[a],s=k(e,i);if(s>o)break;n=i,r=s}if(a>0&&a<t.length){s.words.push({...i,text:n,width:r}),s.totalWidth+=r,s.lineHeight=Math.max(s.lineHeight,u),f(!0),p=!1;let o=t.slice(a).join(``),c=k(e,o);s.words.push({...i,text:o,width:c}),s.totalWidth+=c,s.lineHeight=Math.max(s.lineHeight,u);continue}}}if(r){if(E){let e=s.words.map(e=>e.text).join(``);E({type:`line-wrap`,message:`"${i.text}" overflow=${t.toFixed(2)} wrap=true lineWidth=${s.totalWidth.toFixed(2)} pieceWidth=${i.width.toFixed(2)} contentWidth=${n} line="${e}"`,data:{text:i.text,overflow:t,lineWidth:s.totalWidth,pieceWidth:i.width,contentWidth:n,lineText:e}})}f(!0),p=!1}}if(i.isSpace&&s.words.length===0&&(!p||!d))continue;let v=i.width;if(i.isTab){let e=i.width,t=s.totalWidth;v=Math.ceil((t+.1)/e)*e-t,i.width=v}if(s.words.length===0&&v>l()&&!i.isSpace&&i.text.includes(`-`)){let t=i.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/);if(t.length>1){j(e,i.style);let n=t.filter(e=>e).map(t=>({...i,text:t,width:k(e,t)})),r=!0;for(let e of n)r?(r=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u)):s.totalWidth+e.width>l()?(f(!0),p=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u)):(s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u));continue}}s.words.push(i),s.totalWidth+=v,s.lineHeight=Math.max(s.lineHeight,u),i.isSpace||(p=!1)}}return f(),o}function _e(e,t,n,r,i,a=!1){let o=[],s=ue(t);if(s.length===0)return{nodes:o,height:0};let c=fe(e,s),l=t.style.textIndent||0,u=ge(e,c,i,t.style.whiteSpace,a,l),d=t.style.lineClamp;if(d>0&&u.length>d){u.length=d;let t=u[d-1];le(e,t,i-(d===1?l:0)),t.endedByHardBreak=!0}let f=t.style.direction===`rtl`,p=e=>e===`start`?f?`right`:`left`:e===`end`?f?`left`:`right`:e,m=p(t.style.textAlign),h=t.style.textAlignLast||`auto`;h=h===`auto`?t.style.textAlign===`justify`?f?`right`:`left`:m:p(h);let g=r;for(let t=0;t<u.length;t++){let r=u[t];if(r.words.length===0){g+=r.lineHeight;continue}let a=r.lineHeight,s=t===u.length-1,c=t===0,d=s||r.endedByHardBreak?h:m,p=c?l:0,_=i-p,v=0;if(d===`justify`&&r.totalWidth<_){let e=r.words.filter(e=>e.isSpace).length;e>0&&(v=(_-r.totalWidth)/e)}let y=r.totalWidth>_+.5,b=n+p;y?b=f?n+_-r.totalWidth:n+p:d===`center`?b=n+p+(_-r.totalWidth)/2:d===`right`?b=(f?n+_:n+p+_)-r.totalWidth:d===`justify`&&f&&(b=n+_-r.totalWidth);let x=b,S=0,C=0;for(let t of r.words){if(t.text===``||W(t.style.verticalAlign))continue;let{ascent:n,descent:r}=U(e,t.style);n>S&&(S=n),r>C&&(C=r)}if(S===0)for(let t of r.words){if(t.text===``)continue;let{ascent:n,descent:r}=U(e,t.style);S=n,C=r;break}let w=S+C,T=g+(a-w)/2+S,E=r.words.filter(e=>e.text!==``&&!W(e.style.verticalAlign)),O=E.length>0?Math.max(...E.map(e=>e.style.fontSize)):0,A=g,M=g+a;for(let t of r.words){if(t.text===``)continue;let n=t.style.verticalAlign;if(!W(n))continue;if(O===0)break;let{ascent:r,descent:i}=U(e,t.style),o=T+ae(n,r,i,O,S,C,a),s=o-r,c=o+i;s<A&&(A=s),c>M&&(M=c)}let N=M-A,P=(t,n,r)=>{let{ascent:i,descent:a}=U(e,t),s=t.paddingTop+t.borderTopWidth,c=t.paddingBottom+t.borderBottomWidth,l=i+a+s+c,u;u=t.display===`inline-block`?g+t.marginTop:T-i-s,o.push({type:`box`,style:t,x:n,y:u,width:r,height:l,tagName:`span`,children:[]})};if(!f){let e=b,t=e,n,i=!1;for(let a of r.words){if(a.boxOpen&&a.boxClose&&a.text){n&&(i&&P(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;P(r,e+r.marginLeft,r.borderLeftWidth+r.paddingLeft+o+r.paddingRight+r.borderRightWidth),i=!1,e+=a.width;continue}a.boxStyle!==n&&(n&&i&&P(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&&P(n,t,e-t)}let F=r.words.filter(e=>e.text!==``),I=F.length>0&&F.every(e=>oe(e.style,F[0].style));if(f){let t=[],n=null,i=0;for(let e of r.words){if(e.text===``){n&&=(t.push(n),null),i+=e.width;continue}if(e.isSpace&&v>0){n&&=(t.push(n),null),i+=e.width+v;continue}n&&oe(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=b+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&&se(e.boxStyle)){let t=e.boxStyle,n=t.paddingLeft+t.borderLeftWidth,r=t.paddingRight+t.borderRightWidth;P(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:T,width:e.width,style:{...e.style,direction:`rtl`}})}else{let t=r.words.map(e=>e.text).join(``);if(I&&/[\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,F[0].style);let n=k(e,t);o.push({type:`text`,text:t,x:b,y:T,width:n,style:{...F[0].style,direction:`ltr`}})}else for(let t of r.words){if(t.text===``){b+=t.width;continue}if(t.boxOpen&&t.boxClose){let n=t.style,r=b+n.marginLeft+n.borderLeftWidth+n.paddingLeft;o.push({type:`text`,text:t.text,x:r,y:T,width:k(e,t.text),style:t.style}),b+=t.width;continue}let n=T,r=t.style.verticalAlign;if(W(r)){let i=O||t.style.fontSize,{ascent:o,descent:s}=U(e,t.style);n+=ae(r,o,s,i,S,C,a)}let i=t.width+(t.isSpace?v:0);o.push({type:`text`,text:t.text,x:b,y:n,width:i,style:t.style}),b+=i}}let L=d===`justify`&&v>0?_:r.totalWidth;D.push({y:Math.round(T),text:r.words.map(e=>e.text).join(``),bounds:{x,y:A,width:L,height:N}}),g+=N}return{nodes:o,height:g-r}}function ve(e,t){return e>=0&&t>=0?Math.max(e,t):e<0&&t<0?Math.min(e,t):e+t}function Q(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=be(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=ye(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(re(t)){let{nodes:n,height:r}=_e(e,t,v,x,y,t.tagName===`li`&&z.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`&&z.has(a.listStyleType),{nodes:d,height:f}=_e(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=ve(r,l);n+=e}let{box:d,height:f,marginBottomOut:p}=Q(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 ye(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}}function be(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}=Q(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}=Q(e,t,n,l,i);s.push(r),l+=a+o}return{children:s,height:l-r}}function xe(e,t,n){if(!n.listMarker||n.markerHidden)return;let r=n.style,i=n.markerStyle,a=i?{...r,...i}:r;e.font=P(a);let o=B(e,r),s=t.y+r.borderTopWidth+r.paddingTop+te(e,r,o),c=k(e,n.listMarker),l=r.direction===`rtl`,u=z.has(r.listStyleType),d=l?i?.paddingLeft:i?.paddingRight,f,p=s,m=`ltr`,h=t.x+r.borderLeftWidth+r.paddingLeft,g=t.x+t.width;if(u){let{ascent:t}=U(e,a),r=e.measureText(n.listMarker),i=d===void 0?7+t/3:d;f=l?g+i+(r.actualBoundingBoxLeft??0):h-i-(r.actualBoundingBoxRight??c);let o=((r.actualBoundingBoxAscent??0)-(r.actualBoundingBoxDescent??0))/2;p=s-t/3+o}else{let t=d===void 0?k(e,` `):d;l?/\d/.test(n.listMarker)?(m=`rtl`,f=g+t+c):f=g+t:f=h-c-t}t.children.unshift({type:`text`,text:n.listMarker,x:f,y:p,width:c,style:{...a,textDecorationLine:`none`,fontWeight:i?.fontWeight??400,fontStyle:i?.fontStyle??`normal`,direction:m}});let _=m===`rtl`?f-c:f;D.push({y:Math.round(s),text:n.listMarker,bounds:{x:_,y:t.y+r.borderTopWidth+r.paddingTop,width:c,height:o}})}function Se(e,t,n,r=!0,i){T=r,E=i,F.clear(),H.clear(),N.clear(),O.clear(),D=[];let{box:a,height:o}=Q(e,t,0,0,n);Ce(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 Ce(e,t,n){xe(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){Ce(e,n,i),r++;break}r++}}function we(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 Te(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 Ee(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 De(e){return e.webkitTextFillColor&&e.webkitTextFillColor!==`transparent`?e.webkitTextFillColor:e.color}function Oe(e,t){e.strokeStyle=t.webkitTextStrokeColor||t.color,e.lineWidth=t.webkitTextStrokeWidth,e.lineJoin=`round`}function ke(e,t,n){let{style:r}=t;e.save(),e.font=P(r),e.textBaseline=`alphabetic`,e.fontKerning=r.fontKerning===`none`?`none`:`normal`,Number.isFinite(r.letterSpacing)&&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=we(r.textShadow);if(s.length>0){let c=i||!o;for(let o of s)e.save(),e.shadowOffsetX=o.offsetX,e.shadowOffsetY=o.offsetY,e.shadowBlur=o.blur,e.shadowColor=o.color,c&&(e.fillStyle=i&&n?n:De(r),e.fillText(t.text,t.x,t.y)),a&&(Oe(e,r),e.strokeText(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}=U(e,r);e.fillStyle=Ee(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=De(r),e.fillText(t.text,t.x,t.y))},l=()=>{a&&(e.save(),Oe(e,r),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}=U(e,r);e.font=P(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 Ae(e,t){let{style:n}=t;ie(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)Te(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=Ee(e,n.backgroundImage,t.x,t.width,t.y,t.height));for(let n of t.children)je(e,n,i)}function je(e,t,n){t.type===`text`?ke(e,t,n):Ae(e,t)}function Me(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}=Se(f,u,r,s,o),g=i||m;return d(),{layoutRoot:p,height:g,lines:h}}function Ne(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)),je(o,t.layoutRoot),{canvas:a}}function Pe(e){if(e.ctx&&e.canvas)throw TypeError(`render: ctx and canvas are mutually exclusive — provide one or neither`);let t=Me({html:e.html,width:e.width,height:e.height,accuracy:e.accuracy,debug:e.debug}),{canvas:n}=Ne({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=Ne,e.layout=Me,e.render=Pe});
9
+ `,width:0,style:r.style,isSpace:!1,boxStyle:r.boxStyle}),a[t]){let o=n.length;J(e,a[t],r,n),i(o)}}else{let a=n.length;J(e,t,r,n),i(a)}}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}var X;function pe(){return X||(typeof Intl<`u`&&Intl.Segmenter?(X=new Intl.Segmenter(void 0,{granularity:`grapheme`}),X):null)}var me=/\p{Extended_Pictographic}/u;function he(e){for(let t of e)if(t.codePointAt(0)>=126976)return!0;return e.includes(`‍`)||e.includes(`️`)?me.test(e):!1}function Z(e,t,n,r){let i=[...t.text].some(Y),a=me.test(t.text)&&!!pe(),o=t.width>n&&(t.style.overflowWrap===`break-word`||t.style.wordBreak===`break-all`);if(!i&&!a&&!o)return[t];if(o&&t.style.wordBreak!==`break-all`&&t.style.overflowWrap===`break-word`){let r=t.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/).filter(e=>e.length);if(r.length>1){e.font=F(t.style),e.letterSpacing=N(t.style.letterSpacing);let i=[];for(let a of r){let r=A(e,a);r<=n?i.push({...t,text:a,width:r}):i.push(...Z(e,{...t,text:a,width:r},n,0))}return i}}e.font=F(t.style),e.letterSpacing=N(t.style.letterSpacing);let s=a?pe():null,c=s?[...s.segment(t.text)].map(e=>e.segment):[...t.text],l=[],u=``,d=0;for(let r of c){if(a&&he(r)){u&&(l.push({...t,text:u,width:d}),u=``,d=0),l.push({...t,text:r,width:A(e,r)});continue}if(Y(r)){u&&(l.push({...t,text:u,width:d}),u=``,d=0);let n=A(e,r);l.push({...t,text:r,width:n});continue}let i=u+r,s=A(e,i);if(o&&s>n&&u){l.push({...t,text:u,width:d}),u=r,d=A(e,r);continue}u=i,d=s}return u&&l.push({...t,text:u,width:d}),l}var ge=/^[,.\;:!?\)\]\}'"»›]+$/;function _e(e,t,n,r,i=!1,a=0,o){let s=[],c={words:[],totalWidth:0,lineHeight:0},l=r===`nowrap`||r===`pre`,u=()=>n-(s.length===0?a:0),d=r===`pre-wrap`||r===`pre`||r===`pre-line`,f=r===`pre`||r===`pre-wrap`||r===`break-spaces`;function p(t=!1){let i=c.words.length>0;if(!(r===`break-spaces`||f&&!t))for(;c.words.length>0&&c.words[c.words.length-1].isSpace;)c.totalWidth-=c.words[c.words.length-1].width,c.words.pop();if(t&&c.words.length>0){let t=c.words[c.words.length-1];if(t.isSoftHyphenBreak){M(e,t.style);let n=A(e,`-`);c.words.push({text:`-`,width:n,style:t.style,isSpace:!1}),c.totalWidth+=n}}if(c.words.length>0||i&&d){if(D){let e=c.words.map(e=>e.text).join(``);D({type:`line-commit`,message:`Line ${s.length}: "${e}" width=${c.totalWidth.toFixed(2)} / ${n}`,data:{lineIndex:s.length,text:e,totalWidth:c.totalWidth,contentWidth:n}})}s.push(c)}c={words:[],totalWidth:0,lineHeight:0}}let m=!0;for(let r=0;r<t.length;r++){let d=t[r],h=V(e,d.style,i);if(d.boxStyle&&d.boxStyle.display===`inline-block`){let e=d.boxStyle;h=Math.max(h,h+e.paddingTop+e.paddingBottom+e.marginTop+e.marginBottom+e.borderTopWidth+e.borderBottomWidth)}if(d.text===`
10
+ `){c.words.length===0?(c.lineHeight=h,c.endedByHardBreak=!0,s.push(c),c={words:[],totalWidth:0,lineHeight:0}):(c.endedByHardBreak=!0,p()),m=!0;continue}if(l){c.words.push(d),c.totalWidth+=d.width,c.lineHeight=Math.max(c.lineHeight,h);continue}if(!d.isSpace&&d.text&&!d.noBreakBefore&&!d.boxOpen&&!d.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=d.style.overflowWrap===`break-word`||d.style.wordBreak===`break-all`,o=0;for(let e=r;e<=n;e++)o+=t[e].width;let s=[];for(let e=r;e<=n;e++)for(let n of[...t[e].text])s.push({ch:n,style:t[e].style});let l=s.map(e=>e.ch).join(``).split(/(?<=-)(?!\d)|(?<=[^\d]-)/).filter(e=>e.length),f=l.length>1;if(!(c.totalWidth+o<=u())&&(f||a&&o>u())){let t=[],o=0;for(let e of l){let n=[...e].length;t.push(s.slice(o,o+n)),o+=n}let d=(t,n)=>{let r=0;for(;r<t.length;){let a=t[r].style;M(e,a),e.letterSpacing=N(a.letterSpacing);let o=V(e,a,i),s=``,l=0;for(;r<t.length&&t[r].style===a;){let i=t[r].ch,d=A(e,s+i);n&&c.totalWidth+d>u()&&(c.words.length>0||s)?(s&&(c.words.push({text:s,width:l,style:a,isSpace:!1}),c.totalWidth+=l,c.lineHeight=Math.max(c.lineHeight,o)),p(!0),m=!1,s=i,l=A(e,i)):(s+=i,l=d),r++}s&&(c.words.push({text:s,width:l,style:a,isSpace:!1}),c.totalWidth+=l,c.lineHeight=Math.max(c.lineHeight,o),m=!1)}},h=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++;M(e,i),e.letterSpacing=N(i.letterSpacing),n+=A(e,a)}return n};!f&&c.words.length>0&&(p(!0),m=!1);for(let e of t){let t=h(e);c.words.length>0&&c.totalWidth+t>u()&&(p(!0),m=!1),d(e,a&&t>u())}r=n;continue}}}let g=!d.isSpace&&d.text.length>1?Z(e,d,u(),c.totalWidth):[d],_=0;for(let e=r+1;e<t.length;e++){let n=t[e];if(n.isSpace||n.text===`
11
+ `)break;let r=!!n.text&&ge.test(n.text),i=!n.text&&!!n.boxClose,a=!!n.text&&!!n.noBreakBefore;if(r||i||a){_+=n.width;continue}break}for(let i of g){let l=i===g[g.length-1]?_:0,d=!i.isSpace&&i.text.length>0&&ge.test(i.text)&&c.words.length>0&&!c.words[c.words.length-1].isSpace,v=i===g[0]&&i.noBreakBefore&&c.words.length>0&&!c.words[c.words.length-1].isSpace,y=0;if(!i.text&&i.boxOpen){let n=t[r+1];n&&!n.isSpace&&n.text&&(y=(n.text.length>1?Z(e,n,u(),0):[n])[0].width)}let b=0;if(i.isSoftHyphenBreak&&(M(e,i.style),e.letterSpacing=N(i.style.letterSpacing),b=A(e,`-`)),!i.isSpace&&!d&&!v&&c.words.length>0&&c.totalWidth+i.width+b+l+y>u()){let t=c.totalWidth+i.width+b+l+y-u(),r=!0;if(t<1&&!j([...c.words,i])){M(e,i.style);let t=c.words.map(e=>e.text).join(``)+i.text+(i.isSoftHyphenBreak?`-`:``),n=0;for(let e of c.words)e.text||(n+=e.width);i.text||(n+=i.width),A(e,t)+n+l+y<=u()+.02&&(r=!1)}if(r&&i.text.includes(`-`)){let t=i.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/);if(t.length>1){M(e,i.style);let n=``,r=0,a=0,o=u()-c.totalWidth;for(;a<t.length;a++){let i=n+t[a],s=A(e,i);if(s>o)break;n=i,r=s}if(a>0&&a<t.length){c.words.push({...i,text:n,width:r}),c.totalWidth+=r,c.lineHeight=Math.max(c.lineHeight,h),p(!0),m=!1;let o=t.slice(a).join(``),s=A(e,o);c.words.push({...i,text:o,width:s}),c.totalWidth+=s,c.lineHeight=Math.max(c.lineHeight,h);continue}}}if(r){if(D){let e=c.words.map(e=>e.text).join(``);D({type:`line-wrap`,message:`"${i.text}" overflow=${t.toFixed(2)} wrap=true lineWidth=${c.totalWidth.toFixed(2)} pieceWidth=${i.width.toFixed(2)} contentWidth=${n} line="${e}"`,data:{text:i.text,overflow:t,lineWidth:c.totalWidth,pieceWidth:i.width,contentWidth:n,lineText:e}})}p(!0),m=!1}}if(i.isSpace&&c.words.length===0&&(!m||!f))continue;let x=i.width;if(i.isTab){let e=o?.interval||i.width,t=o?.halfSpace??0,n=e-((s.length===0?a:0)+c.totalWidth)%e;n<t&&(n+=e),x=n,i.width=x}if(c.words.length===0&&x>u()&&!i.isSpace&&i.text.includes(`-`)){let t=i.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/);if(t.length>1){M(e,i.style);let n=t.filter(e=>e).map(t=>({...i,text:t,width:A(e,t)})),r=!0;for(let e of n)r?(r=!1,c.words.push(e),c.totalWidth+=e.width,c.lineHeight=Math.max(c.lineHeight,h)):c.totalWidth+e.width>u()?(p(!0),m=!1,c.words.push(e),c.totalWidth+=e.width,c.lineHeight=Math.max(c.lineHeight,h)):(c.words.push(e),c.totalWidth+=e.width,c.lineHeight=Math.max(c.lineHeight,h));continue}}c.words.push(i),c.totalWidth+=x,c.lineHeight=Math.max(c.lineHeight,h),i.isSpace||(m=!1)}}return p(),s}function ve(e,t,n,r,i,a=!1,o){let s=[];if(o&&(o.exhausted||o.remaining<=0))return o.exhausted=!0,{nodes:s,height:0};let c=ue(t);if(c.length===0)return{nodes:s,height:0};let l=fe(e,c),u=t.style.textIndent||0;M(e,t.style);let d=e.letterSpacing;e.letterSpacing=`0px`;let f=A(e,` `);e.letterSpacing=d;let p={interval:(f+(t.style.letterSpacing||0)+(t.style.wordSpacing||0))*8,halfSpace:f/2},m=_e(e,l,i,t.style.whiteSpace,a,u,p),h=o?o.remaining:t.style.lineClamp;if(h>0&&m.length>h){m.length=h;let t=m[h-1];le(e,t,i-(h===1?u:0)),t.endedByHardBreak=!0,o&&(o.remaining=0,o.exhausted=!0)}else o&&(o.remaining-=m.length);let g=t.style.direction===`rtl`,_=e=>e===`start`?g?`right`:`left`:e===`end`?g?`left`:`right`:e,v=_(t.style.textAlign),y=t.style.textAlignLast||`auto`;y=y===`auto`?t.style.textAlign===`justify`?g?`right`:`left`:v:_(y);let b=r;for(let t=0;t<m.length;t++){let r=m[t];if(r.words.length===0){b+=r.lineHeight;continue}let a=r.lineHeight,o=t===m.length-1,c=t===0,l=o||r.endedByHardBreak?y:v,d=c?u:0,f=i-d,p=0;if(l===`justify`&&r.totalWidth<f){let e=r.words.filter(e=>e.isSpace).length;e>0&&(p=(f-r.totalWidth)/e)}let h=r.totalWidth>f+.5,_=n+d;h?_=g?n+f-r.totalWidth:n+d:l===`center`?_=n+d+(f-r.totalWidth)/2:l===`right`?_=(g?n+f:n+d+f)-r.totalWidth:l===`justify`&&g&&(_=n+f-r.totalWidth);let x=_,S=0,C=0;for(let t of r.words){if(t.text===``||G(t.style.verticalAlign))continue;let{ascent:n,descent:r}=W(e,t.style);n>S&&(S=n),r>C&&(C=r)}if(S===0)for(let t of r.words){if(t.text===``)continue;let{ascent:n,descent:r}=W(e,t.style);S=n,C=r;break}let w=S+C,T=b+(a-w)/2+S,E=r.words.filter(e=>e.text!==``&&!G(e.style.verticalAlign)),D=E.length>0?Math.max(...E.map(e=>e.style.fontSize)):0,k=b,j=b+a;for(let t of r.words){if(t.text===``)continue;let n=t.style.verticalAlign;if(!G(n))continue;if(D===0)break;let{ascent:r,descent:i}=W(e,t.style),o=T+ae(n,r,i,D,S,C,a),s=o-r,c=o+i;s<k&&(k=s),c>j&&(j=c)}let N=j-k,P=(t,n,r)=>{let{ascent:i,descent:a}=W(e,t),o=t.paddingTop+t.borderTopWidth,c=t.paddingBottom+t.borderBottomWidth,l=i+a+o+c,u;u=t.display===`inline-block`?b+t.marginTop:T-i-o,s.push({type:`box`,style:t,x:n,y:u,width:r,height:l,tagName:`span`,children:[]})};if(!g){let e=_,t=e,n,i=!1;for(let a of r.words){if(a.boxOpen&&a.boxClose&&a.text){n&&(i&&P(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;P(r,e+r.marginLeft,r.borderLeftWidth+r.paddingLeft+o+r.paddingRight+r.borderRightWidth),i=!1,e+=a.width;continue}a.boxStyle!==n&&(n&&i&&P(n,t,e-t),n=a.boxStyle,t=e,i=!1),a.text&&!a.isSpace&&(i=!0),e+=a.width+(a.isSpace?p:0)}n&&i&&P(n,t,e-t)}let F=r.words.filter(e=>e.text!==``),I=F.length>0&&F.every(e=>oe(e.style,F[0].style));if(g){let t=[],n=null,i=0;for(let e of r.words){if(e.text===``){n&&=(t.push(n),null),i+=e.width;continue}if(e.isSpace&&p>0){n&&=(t.push(n),null),i+=e.width+p;continue}n&&oe(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=_+r.totalWidth;for(let n of t){a-=n.padBefore,M(e,n.style);let t=A(e,n.text);a-=t,n.x=a,n.width=t}for(let e of t)if(e.boxStyle&&se(e.boxStyle)){let t=e.boxStyle,n=t.paddingLeft+t.borderLeftWidth,r=t.paddingRight+t.borderRightWidth;P(t,e.x-n,e.width+n+r)}for(let e of t)s.push({type:`text`,text:e.text,x:e.x+e.width,y:T,width:e.width,style:{...e.style,direction:`rtl`}})}else{let t=r.words.map(e=>e.text).join(``);if(I&&/[\u0590-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(t)&&!r.words.some(e=>e.boxOpen||e.boxClose||e.style.verticalAlign===`super`||e.style.verticalAlign===`sub`)){M(e,F[0].style);let n=A(e,t);s.push({type:`text`,text:t,x:_,y:T,width:n,style:{...F[0].style,direction:`ltr`}})}else for(let t of r.words){if(t.text===``){_+=t.width;continue}if(t.boxOpen&&t.boxClose){let n=t.style,r=_+n.marginLeft+n.borderLeftWidth+n.paddingLeft;s.push({type:`text`,text:t.text,x:r,y:T,width:A(e,t.text),style:t.style}),_+=t.width;continue}let n=T,r=t.style.verticalAlign;if(G(r)){let i=D||t.style.fontSize,{ascent:o,descent:s}=W(e,t.style);n+=ae(r,o,s,i,S,C,a)}let i=t.width+(t.isSpace?p:0);s.push({type:`text`,text:t.text,x:_,y:n,width:i,style:t.style}),_+=i}}let L=l===`justify`&&p>0?f:r.totalWidth;O.push({y:Math.round(T),text:r.words.map(e=>e.text).join(``),bounds:{x,y:k,width:L,height:N}}),b+=N}return{nodes:s,height:b-r}}function ye(e,t){return e>=0&&t>=0?Math.max(e,t):e<0&&t<0?Math.min(e,t):e+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=xe(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=be(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(re(t)){let{nodes:n,height:r}=ve(e,t,y,S,b,t.tagName===`li`&&B.has(o.listStyleType),a);C.children=n,C.height=d+h+r+g+f}else{let n=S,r=0,i=!1,s=t.tagName===`li`||t.tagName===`ul`||t.tagName===`ol`||t.tagName===`dd`||t.tagName===`dt`;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`||H(l)){let s=[l];for(;c+1<t.children.length;){let e=t.children[c+1];if(e.tagName===`#text`||H(e))s.push(e),c++;else break}r>0&&(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`&&B.has(o.listStyleType),{nodes:f,height:p}=ve(e,u,y,n,b,d,a);C.children.push(...f),n+=p,r=0,i=!0;continue}let u=l.style.marginTop;if(!(!i&&h===0&&d===0&&s)){let e=ye(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&&s;l&&r>0&&(c=Math.max(o.marginBottom,r));let u=n-S;return!l&&r>0&&(u+=r),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 be(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}}function xe(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}=Q(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}=Q(e,t,n,l,i);s.push(r),l+=a+o}return{children:s,height:l-r}}function Se(e,t,n){if(!n.listMarker||n.markerHidden)return;let r=n.style,i=n.markerStyle,a=i?{...r,...i}:r;e.font=F(a);let o=V(e,r),s=t.y+r.borderTopWidth+r.paddingTop+te(e,r,o),c=A(e,n.listMarker),l=r.direction===`rtl`,u=B.has(r.listStyleType),d=l?i?.paddingLeft:i?.paddingRight,f,p=s,m=`ltr`,h=t.x+r.borderLeftWidth+r.paddingLeft,g=t.x+t.width;if(u){let{ascent:t}=W(e,a),r=e.measureText(n.listMarker),i=d===void 0?7+t/3:d;f=l?g+i+(r.actualBoundingBoxLeft??0):h-i-(r.actualBoundingBoxRight??c);let o=((r.actualBoundingBoxAscent??0)-(r.actualBoundingBoxDescent??0))/2;p=s-t/3+o}else{let t=d===void 0?A(e,` `):d;l?/\d/.test(n.listMarker)?(m=`rtl`,f=g+t+c):f=g+t:f=h-c-t}t.children.unshift({type:`text`,text:n.listMarker,x:f,y:p,width:c,style:{...a,textDecorationLine:`none`,fontWeight:i?.fontWeight??400,fontStyle:i?.fontStyle??`normal`,direction:m}});let _=m===`rtl`?f-c:f;O.push({y:Math.round(s),text:n.listMarker,bounds:{x:_,y:t.y+r.borderTopWidth+r.paddingTop,width:c,height:o}})}function Ce(e,t,n,r=!0,i){E=r,D=i,I.clear(),U.clear(),P.clear(),k.clear(),O=[];let{box:a,height:o}=Q(e,t,0,0,n);we(e,a,t);let s=O.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 we(e,t,n){Se(e,t,n);let r=0;for(let i of n.children)if(!(i.tagName===`#text`||H(i)))for(;r<t.children.length;){let n=t.children[r];if(n.type===`box`&&n.tagName===i.tagName){we(e,n,i),r++;break}r++}}function Te(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 Ee(e,t){return e[`border${t}Width`]>0&&e[`border${t}Style`]!==`none`}function $(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 De(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 Oe(e){return e.webkitTextFillColor&&e.webkitTextFillColor!==`transparent`?e.webkitTextFillColor:e.color}function ke(e){return Math.max(1,Math.floor(e/10))}function Ae(e,t){e.strokeStyle=t.webkitTextStrokeColor||t.color,e.lineWidth=t.webkitTextStrokeWidth,e.lineJoin=`round`}function je(e,t,n){let{style:r}=t;e.save(),e.font=F(r),e.textBaseline=`alphabetic`,e.fontKerning=r.fontKerning===`none`?`none`:`normal`,Number.isFinite(r.letterSpacing)&&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=Te(r.textShadow);if(s.length>0){let c=i||!o;for(let o of s)e.save(),e.shadowOffsetX=o.offsetX,e.shadowOffsetY=o.offsetY,e.shadowBlur=o.blur,e.shadowColor=o.color,c&&(e.fillStyle=i&&n?n:Oe(r),e.fillText(t.text,t.x,t.y)),a&&(Ae(e,r),e.strokeText(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=De(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=Oe(r),e.fillText(t.text,t.x,t.y))},l=()=>{a&&(e.save(),Ae(e,r),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=ke(d),g=r.direction===`rtl`?t.x-u:t.x;if(r.textDecorationLine!==`none`){let{ascent:n}=W(e,r);if(r.textDecorationLine.includes(`underline`)){let n=d*.105-.2;$(e,g,t.y+n,u,h,m,p)}if(r.textDecorationLine.includes(`line-through`)){let n=-(d*.33);$(e,g,t.y+n,u,h,m,p)}r.textDecorationLine.includes(`overline`)&&$(e,g,Math.floor(t.y-n)-h/2,u,h,m,p)}e.restore()}function Me(e,t){let{style:n}=t;ie(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)Ee(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=De(e,n.backgroundImage,t.x,t.width,t.y,t.height));for(let n of t.children)Ne(e,n,i)}function Ne(e,t,n){t.type===`text`?je(e,t,n):Me(e,t)}function Pe(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}=T(c,l,r),f=document.createElement(`canvas`).getContext(`2d`);f.fontKerning=`normal`;let{root:p,height:m,lines:h}=Ce(f,u,r,s,o),g=i||m;return d(),{layoutRoot:p,height:g,lines:h}}function Fe(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)),Ne(o,t.layoutRoot),{canvas:a}}function Ie(e){if(e.ctx&&e.canvas)throw TypeError(`render: ctx and canvas are mutually exclusive — provide one or neither`);let t=Pe({html:e.html,width:e.width,height:e.height,accuracy:e.accuracy,debug:e.debug}),{canvas:n}=Fe({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=Fe,e.layout=Pe,e.render=Ie});
12
12
  //# sourceMappingURL=render-tag.umd.js.map