html2canvas-pro 2.6.1 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/html2canvas-pro.cjs +440 -404
- package/dist/html2canvas-pro.cjs.map +1 -1
- package/dist/html2canvas-pro.esm.js +440 -404
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +440 -404
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +6 -6
- package/dist/types/core/performance-monitor.d.ts +5 -4
- package/dist/types/css/index.d.ts +4 -0
- package/dist/types/css/property-descriptors/contain.d.ts +7 -0
- package/dist/types/css/property-descriptors/will-change.d.ts +7 -0
- package/dist/types/render/canvas/canvas-renderer.d.ts +15 -0
- package/dist/types/render/matrix.d.ts +43 -0
- package/package.json +15 -15
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* html2canvas-pro 2.6.
|
|
2
|
+
* html2canvas-pro 2.6.2 <https://yorickshan.github.io/html2canvas-pro/>
|
|
3
3
|
* Copyright (c) 2024-present yorickshan and html2canvas-pro contributors
|
|
4
4
|
* Released under MIT License
|
|
5
5
|
*/
|
|
6
|
-
(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.html2canvas={}))})(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var t=class e{window;cspNonce;cache;constructor(e={}){let t=e.window||(typeof window<`u`?window:void 0);if(!t)throw Error(`Window object is required but not available`);this.window=t,this.cspNonce=e.cspNonce,this.cache=e.cache}static fromElement(t,n={}){let r=t.ownerDocument;if(!r)throw Error(`Element is not attached to a document`);let i=r.defaultView;if(!i)throw Error(`Document is not attached to a window`);return new e({window:i,...n})}clone(t={}){return new e({window:t.window||this.window,cspNonce:t.cspNonce??this.cspNonce,cache:t.cache??this.cache})}},n=class{config;constructor(e={}){this.config={maxImageTimeout:3e5,allowDataUrls:!0,...e}}validateUrl(e,t=`general`){if(!e||typeof e!=`string`)return{valid:!1,error:`URL must be a non-empty string`};if(e.startsWith(`data:`))return this.config.allowDataUrls?{valid:!0,sanitized:e}:{valid:!1,error:`Data URLs are not allowed`};if(e.startsWith(`blob:`))return{valid:!0,sanitized:e};try{let n=new URL(e);if(![`http:`,`https:`].includes(n.protocol))return{valid:!1,error:`Protocol ${n.protocol} is not allowed. Only http and https are permitted.`};if(t===`proxy`&&this.config.allowedProxyDomains&&this.config.allowedProxyDomains.length>0){let e=n.hostname.toLowerCase();if(!this.config.allowedProxyDomains.some(t=>{let n=t.toLowerCase();return e===n||e.endsWith(`.`+n)}))return{valid:!1,error:`Proxy domain ${n.hostname} is not in the allowed list`}}if(t===`proxy`){if(!this.config.allowLocalhostProxy){let e=n.hostname.toLowerCase();if(e===`localhost`||e===`127.0.0.1`||e===`::1`)return{valid:!1,error:`Localhost is not allowed for proxy URLs`};if(this.isPrivateIP(e))return{valid:!1,error:`Private IP addresses are not allowed for proxy URLs`};if(e.startsWith(`169.254.`)||e.startsWith(`fe80:`))return{valid:!1,error:`Link-local addresses are not allowed for proxy URLs`}}return{valid:!0,sanitized:e}}return{valid:!0,sanitized:e}}catch(e){return{valid:!1,error:`Invalid URL format: ${e instanceof Error?e.message:`Unknown error`}`}}}isPrivateIP(e){return[/^0\./,/^10\./,/^100\.(6[4-9]|[7-9][0-9]|1[0-1][0-9]|12[0-7])\./,/^127\./,/^169\.254\./,/^172\.(1[6-9]|2[0-9]|3[0-1])\./,/^192\.0\.0\./,/^192\.0\.2\./,/^192\.168\./,/^198\.(1[8-9])\./,/^198\.51\.100\./,/^203\.0\.113\./,/^2(2[4-9]|3[0-9])\./,/^24[0-9]\./,/^255\.255\.255\.255$/].some(t=>t.test(e))?!0:e.includes(`:`)?this.isPrivateIPv6(e):!1}isPrivateIPv6(e){let t=e.toLowerCase().trim().replace(/^\[|\]$/g,``),n=t.split(`%`)[0]??t;if(/^(0:){7}1$/.test(n)||n===`::1`||/^(0:){7}0$/.test(n)||n===`::`)return!0;let r=this.expandIPv6(n);if(!r)return this.isPrivateIPv6Prefix(n);let i=parseInt(r.substring(0,2),16);if(i>=252&&i<=253)return!0;if(i===254){let e=parseInt(r.substring(2,4),16);if(e>=128&&e<=191)return!0}return i===255}expandIPv6(e){try{if(e.includes(`::`)){let t=e.split(`::`);if(t.length>2)return null;let n=t[0]?t[0].split(`:`):[],r=t[1]?t[1].split(`:`):[],i=8-n.length-r.length;if(i<0)return null;let a=Array(i).fill(`0000`);return[...n,...a,...r].map(e=>e.padStart(4,`0`)).join(`:`)}{let t=e.split(`:`);return t.length===8?t.map(e=>e.padStart(4,`0`)).join(`:`):null}}catch{return null}}isPrivateIPv6Prefix(e){return!!(/^fc[0-9a-f]{0,2}:?/i.test(e)||/^fd[0-9a-f]{0,2}:?/i.test(e)||/^fe[89ab][0-9a-f]:?/i.test(e)||/^ff[0-9a-f]{0,2}:?/i.test(e))}validateCspNonce(e){return!e||typeof e!=`string`?{valid:!1,error:`CSP nonce must be a non-empty string`}:e.length<16?{valid:!1,error:`CSP nonce is too short (minimum 16 characters recommended)`}:/^[A-Za-z0-9+/=_-]+$/.test(e)?{valid:!0,sanitized:e}:{valid:!1,error:`CSP nonce contains invalid characters`}}validateBackgroundColor(e){return e===null?{valid:!0,sanitized:null}:typeof e!=`string`||e.length===0?{valid:!1,error:`backgroundColor must be a CSS color string or null`}:/[^a-zA-Z0-9%(),.#\s/-]/.test(e)?{valid:!1,error:`backgroundColor contains characters that cannot appear in a CSS color: ${e}`}:{valid:!0,sanitized:e}}validateImageTimeout(e){return typeof e!=`number`||isNaN(e)?{valid:!1,error:`Image timeout must be a number`}:e<0?{valid:!1,error:`Image timeout cannot be negative`}:this.config.maxImageTimeout&&e>this.config.maxImageTimeout?{valid:!1,error:`Image timeout ${e}ms exceeds maximum allowed ${this.config.maxImageTimeout}ms`}:{valid:!0,sanitized:e}}validateDimensions(e,t){if(typeof e!=`number`||typeof t!=`number`)return{valid:!1,error:`Dimensions must be numbers`};if(isNaN(e)||isNaN(t))return{valid:!1,error:`Dimensions cannot be NaN`};if(e<=0||t<=0)return{valid:!1,error:`Dimensions must be positive`};let n=32767;return e>n||t>n?{valid:!1,error:`Dimensions exceed maximum allowed (${n}px)`}:{valid:!0,sanitized:{width:e,height:t}}}validateScale(e){return typeof e!=`number`||isNaN(e)?{valid:!1,error:`Scale must be a number`}:e<=0?{valid:!1,error:`Scale must be positive`}:e>10?{valid:!1,error:`Scale factor too large (maximum 10x)`}:{valid:!0,sanitized:e}}validateElement(e){if(!e)return{valid:!1,error:`Element is required`};if(typeof e!=`object`)return{valid:!1,error:`Element must be an object`};let t=e;return typeof HTMLElement<`u`&&e instanceof HTMLElement?e.ownerDocument?{valid:!0}:{valid:!1,error:`Element must be attached to a document`}:t.ownerDocument?t.ownerDocument.defaultView?{valid:!0}:{valid:!1,error:`Document must be attached to a window (ownerDocument.defaultView required)`}:{valid:!1,error:`Element must be attached to a document (ownerDocument required)`}}validateOptions(e){let t=[],n=e.proxy;if(n!=null&&typeof n==`string`&&n.length>0){let e=this.validateUrl(n,`proxy`);e.valid||t.push(`Proxy: ${e.error}`)}if(e.imageTimeout!==void 0){let n=this.validateImageTimeout(e.imageTimeout);n.valid||t.push(`Image timeout: ${n.error}`)}if(e.width!==void 0||e.height!==void 0){let n=e.width??800,r=e.height??600,i=this.validateDimensions(n,r);i.valid||t.push(`Dimensions: ${i.error}`)}if(e.scale!==void 0){let n=this.validateScale(e.scale);n.valid||t.push(`Scale: ${n.error}`)}if(e.cspNonce!==void 0){let n=this.validateCspNonce(e.cspNonce);n.valid||t.push(`CSP nonce: ${n.error}`)}if(e.backgroundColor!==void 0){let n=this.validateBackgroundColor(e.backgroundColor);n.valid||t.push(`backgroundColor: ${n.error}`)}if(this.config.customValidator){let n=this.config.customValidator(e,`options`);n.valid||t.push(`Custom validation: ${n.error}`)}return t.length>0?{valid:!1,error:t.join(`; `)}:{valid:!0}}};function r(e={}){return new n({allowDataUrls:!0,maxImageTimeout:3e5,...e})}var i=class{context;activeMetrics=/* @__PURE__ */ new Map;completedMetrics=[];enabled;getTime;constructor(e,t=!0){this.context=e,this.enabled=t,this.getTime=typeof performance<`u`&&typeof performance.now==`function`?()=>performance.now():()=>Date.now()}start(e,t){this.enabled&&(this.activeMetrics.has(e)&&this.context?.logger.warn(`Performance metric '${e}' already started. Overwriting.`),this.activeMetrics.set(e,{name:e,startTime:this.getTime(),metadata:t}))}end(e){if(!this.enabled)return;let t=this.activeMetrics.get(e);if(!t)this.context?.logger.warn(`Performance metric '${e}' not found. Was start() called?`);else return t.endTime=this.getTime(),t.duration=t.endTime-t.startTime,this.completedMetrics.push(t),this.activeMetrics.delete(e),this.context?.logger.debug(`⏱️ ${e}: ${t.duration.toFixed(2)}ms`,t.metadata),t}measure(e,t,n){this.start(e,n);try{let n=t();return this.end(e),n}catch(t){throw this.end(e),t}}async measureAsync(e,t,n){this.start(e,n);try{let n=await t();return this.end(e),n}catch(t){throw this.end(e),t}}getMetrics(){return[...this.completedMetrics]}getMetric(e){return this.completedMetrics.find(t=>t.name===e)}getSummary(){let e=this.completedMetrics.reduce((e,t)=>e+(t.duration||0),0),t=this.completedMetrics.map(t=>({name:t.name,duration:t.duration||0,percentage:e>0?((t.duration||0)/e*100).toFixed(1)+`%`:`0%`}));return{totalDuration:e,metrics:this.getMetrics(),breakdown:t}}logSummary(){if(!this.enabled||this.completedMetrics.length===0||!this.context)return;let e=this.getSummary();this.context.logger.info(`\n📊 Performance Summary (Total: ${e.totalDuration.toFixed(2)}ms):`),e.breakdown.sort((e,t)=>t.duration-e.duration).forEach(e=>{this.context.logger.info(` ${e.name.padEnd(20)} ${e.duration.toFixed(2).padStart(8)}ms ${e.percentage.padStart(6)}`)})}clear(){this.activeMetrics.clear(),this.completedMetrics.splice(0)}isEnabled(){return this.enabled}getActiveMetrics(){return Array.from(this.activeMetrics.keys())}},a=class e{left;top;width;height;constructor(e,t,n,r){this.left=e,this.top=t,this.width=n,this.height=r}add(t,n,r,i){return new e(this.left+t,this.top+n,this.width+r,this.height+i)}static fromClientRect(t,n){return new e(n.left+t.windowBounds.left,n.top+t.windowBounds.top,n.width,n.height)}static fromDOMRectList(t,n){let r=Array.from(n),i=r.find(e=>e.width!==0);return i||=r.find(e=>e.height!==0),!i&&r.length>0&&(i=r[0]),i?new e(i.left+t.windowBounds.left,i.top+t.windowBounds.top,i.width,i.height):e.EMPTY}static EMPTY=new e(0,0,0,0)};let o=(e,t)=>a.fromClientRect(e,t.getBoundingClientRect()),s=e=>{let t=e.body,n=e.documentElement;if(!t||!n)throw Error(`Unable to get document size`);return new a(0,0,Math.max(Math.max(t.scrollWidth,n.scrollWidth),Math.max(t.offsetWidth,n.offsetWidth),Math.max(t.clientWidth,n.clientWidth)),Math.max(Math.max(t.scrollHeight,n.scrollHeight),Math.max(t.offsetHeight,n.offsetHeight),Math.max(t.clientHeight,n.clientHeight)))},c=(e,t)=>{let n=e[t];if(n===void 0)throw Error(`Missing element at index ${t}`);return n},l=65533,u=e=>e>=48&&e<=57,d=e=>e>=55296&&e<=57343,f=e=>u(e)||e>=65&&e<=70||e>=97&&e<=102,p=e=>e>=97&&e<=122,m=e=>e>=65&&e<=90,h=e=>p(e)||m(e),g=e=>e>=128,_=e=>e===10||e===9||e===32,v=e=>h(e)||g(e)||e===95,y=e=>v(e)||u(e)||e===45,b=e=>e>=0&&e<=8||e===11||e>=14&&e<=31||e===127,x=(e,t)=>e===92&&t!==10,S=(e,t,n)=>e===45?v(t)||x(t,n):!!(v(e)||e===92&&x(e,t)),C=(e,t,n)=>e===43||e===45?u(t)?!0:t===46&&u(n):u(e===46?t:e),w=e=>{let t=0,n=1;(e[t]===43||e[t]===45)&&(e[t]===45&&(n=-1),t++);let r=[];for(;u(e[t]??NaN);)r.push(c(e,t)),t++;let i=r.length?parseInt(String.fromCodePoint(...r),10):0;e[t]===46&&t++;let a=[];for(;u(e[t]??NaN);)a.push(c(e,t)),t++;let o=a.length,s=o?parseInt(String.fromCodePoint(...a),10):0;(e[t]===69||e[t]===101)&&t++;let l=1;(e[t]===43||e[t]===45)&&(e[t]===45&&(l=-1),t++);let d=[];for(;u(e[t]??NaN);)d.push(c(e,t)),t++;let f=d.length?parseInt(String.fromCodePoint(...d),10):0;return n*(i+s*10**-o)*10**(l*f)},ee={type:2},te={type:3},ne={type:4},re={type:13},ie={type:8},ae={type:21},oe={type:9},se={type:10},ce={type:11},le={type:12},ue={type:14},de={type:23},fe={type:1},pe={type:25},me={type:24},he={type:26},ge={type:27},_e={type:28},ve={type:29},ye={type:31},be={type:32};var xe=class e{static _pool=[];static MAX_POOL_SIZE=40;static get(){return e._pool.pop()||new e}static release(t){e._pool.length<e.MAX_POOL_SIZE&&(t._reset(),e._pool.push(t))}_value;_cursor;constructor(){this._value=[],this._cursor=0}_reset(){this._value=[],this._cursor=0}write(e){this._cursor>0&&(this._value=this._value.slice(this._cursor),this._cursor=0),this._value=this._value.concat([...e].map(e=>e.codePointAt(0)))}read(){let e=[],t=this.consumeToken();for(;t!==be;)e.push(t),t=this.consumeToken();return e}consumeToken(){let e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:{let e=this.peekCodePoint(0),t=this.peekCodePoint(1),n=this.peekCodePoint(2);if(y(e)||x(t,n)){let r=S(e,t,n)?2:1;return{type:5,value:this.consumeName(),flags:r}}break}case 36:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),re;break;case 39:return this.consumeStringToken(39);case 40:return ee;case 41:return te;case 42:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),ue;break;case 43:if(C(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return ne;case 45:{let t=e,n=this.peekCodePoint(0),r=this.peekCodePoint(1);if(C(t,n,r))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(S(t,n,r))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(n===45&&r===62)return this.consumeCodePoint(),this.consumeCodePoint(),me;break}case 46:if(C(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(this.peekCodePoint(0)===42)for(this.consumeCodePoint();;){let e=this.consumeCodePoint();if(e===42&&(e=this.consumeCodePoint(),e===47)||e===-1)return this.consumeToken()}break;case 58:return he;case 59:return ge;case 60:if(this.peekCodePoint(0)===33&&this.peekCodePoint(1)===45&&this.peekCodePoint(2)===45)return this.consumeCodePoint(),this.consumeCodePoint(),this.consumeCodePoint(),pe;break;case 64:{let e=this.peekCodePoint(0),t=this.peekCodePoint(1),n=this.peekCodePoint(2);if(S(e,t,n))return{type:7,value:this.consumeName()};break}case 91:return _e;case 92:if(x(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return ve;case 94:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),ie;break;case 123:return ce;case 125:return le;case 117:case 85:{let t=this.peekCodePoint(0),n=this.peekCodePoint(1);return t===43&&(f(n)||n===63)?(this.consumeCodePoint(),this.consumeUnicodeRangeToken()):(this.reconsumeCodePoint(e),this.consumeIdentLikeToken())}case 124:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),oe;if(this.peekCodePoint(0)===124)return this.consumeCodePoint(),ae;break;case 126:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),se;break;case-1:return be}return _(e)?(this.consumeWhiteSpace(),ye):u(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):v(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:String.fromCodePoint(e)}}consumeCodePoint(){let e=this._value[this._cursor];return e===void 0?-1:(this._cursor++,e)}reconsumeCodePoint(e){this._cursor>0&&this._value[this._cursor-1]===e?this._cursor--:this._value.splice(this._cursor,0,e)}peekCodePoint(e){let t=this._value[this._cursor+e];return t===void 0?-1:t}consumeUnicodeRangeToken(){let e=[],t=this.consumeCodePoint();for(;f(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();let n=!1;for(;t===63&&e.length<6;)e.push(t),t=this.consumeCodePoint(),n=!0;if(n)return{type:30,start:parseInt(String.fromCodePoint(...e.map(e=>e===63?48:e)),16),end:parseInt(String.fromCodePoint(...e.map(e=>e===63?70:e)),16)};let r=parseInt(String.fromCodePoint(...e),16);if(t===45&&f(this.peekCodePoint(0))){t=this.consumeCodePoint();let e=[];for(;f(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();return{type:30,start:r,end:parseInt(String.fromCodePoint(...e),16)}}return{type:30,start:r,end:r}}consumeIdentLikeToken(){let e=this.consumeName();return e.toLowerCase()===`url`&&this.peekCodePoint(0)===40?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===40?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}}consumeUrlToken(){let e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===-1)return{type:22,value:``};let t=this.peekCodePoint(0);if(t===39||t===34){let e=this.consumeStringToken(this.consumeCodePoint());return e.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===-1||this.peekCodePoint(0)===41)?(this.consumeCodePoint(),{type:22,value:e.value}):(this.consumeBadUrlRemnants(),de)}for(;;){let t=this.consumeCodePoint();if(t===-1||t===41)return{type:22,value:String.fromCodePoint(...e)};if(_(t))return this.consumeWhiteSpace(),this.peekCodePoint(0)===-1||this.peekCodePoint(0)===41?(this.consumeCodePoint(),{type:22,value:String.fromCodePoint(...e)}):(this.consumeBadUrlRemnants(),de);if(t===34||t===39||t===40||b(t))return this.consumeBadUrlRemnants(),de;if(t===92){if(x(t,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),de}else e.push(t)}}consumeWhiteSpace(){for(;_(this.peekCodePoint(0));)this.consumeCodePoint()}consumeBadUrlRemnants(){for(;;){let e=this.consumeCodePoint();if(e===41||e===-1)return;x(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}}consumeStringSlice(e){let t=``,n=this._cursor+e,r=this._cursor;for(;r<n;){let e=Math.min(n,r+5e4);t+=String.fromCodePoint(...this._value.slice(r,e)),r=e}return this._cursor=n+1,t}consumeStringToken(e){let t=``,n=0;do{let r=this._value[this._cursor+n];if(r===-1||r===void 0||r===e)return t+=this.consumeStringSlice(n),{type:0,value:t};if(r===10)return this._cursor+=n,fe;if(r===92){let e=this._value[this._cursor+n+1];e!==-1&&e!==void 0&&(e===10?(t+=this.consumeStringSlice(n),n=-1,this._cursor++):x(r,e)&&(t+=this.consumeStringSlice(n),t+=String.fromCodePoint(this.consumeEscapedCodePoint()),n=-1))}n++}while(1)}consumeNumber(){let e=[],t=4,n=this.peekCodePoint(0);for((n===43||n===45)&&e.push(this.consumeCodePoint());u(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0);let r=this.peekCodePoint(1);if(n===46&&u(r))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;u(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0),r=this.peekCodePoint(1);let i=this.peekCodePoint(2);if((n===69||n===101)&&((r===43||r===45)&&u(i)||u(r)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;u(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[w(e),t]}consumeNumericToken(){let[e,t]=this.consumeNumber(),n=this.peekCodePoint(0),r=this.peekCodePoint(1),i=this.peekCodePoint(2);return S(n,r,i)?{type:15,number:e,flags:t,unit:this.consumeName()}:n===37?(this.consumeCodePoint(),{type:16,number:e,flags:t}):{type:17,number:e,flags:t}}consumeEscapedCodePoint(){let e=this.consumeCodePoint();if(f(e)){let t=String.fromCodePoint(e);for(;f(this.peekCodePoint(0))&&t.length<6;)t+=String.fromCodePoint(this.consumeCodePoint());_(this.peekCodePoint(0))&&this.consumeCodePoint();let n=parseInt(t,16);return n===0||d(n)||n>1114111?l:n}return e===-1?l:e}consumeName(){let e=``;for(;;){let t=this.consumeCodePoint();if(y(t))e+=String.fromCodePoint(t);else if(x(t,this.peekCodePoint(0)))e+=String.fromCodePoint(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}}},Se=class e{_tokens;constructor(e){this._tokens=e}static create(t){let n=new xe;return n.write(t),new e(n.read())}static parseValue(t){return e.create(t).parseComponentValue()}static parseValues(t){return e.create(t).parseComponentValues()}parseComponentValue(){let e=this.consumeToken();for(;e.type===31;)e=this.consumeToken();if(e.type===32)throw SyntaxError(`Error parsing CSS component value, unexpected EOF`);this.reconsumeToken(e);let t=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return t;throw SyntaxError(`Error parsing CSS component value, multiple values found when expecting only one`)}parseComponentValues(){let e=[];for(;;){let t=this.consumeComponentValue();if(t.type===32)return e;e.push(t)}}consumeComponentValue(){let e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e}consumeSimpleBlock(e){let t={type:e,values:[]},n=this.consumeToken();for(;;){if(n.type===32||Ee(n,e))return t;this.reconsumeToken(n),t.values.push(this.consumeComponentValue()),n=this.consumeToken()}}consumeFunction(e){let t={name:e.value,values:[],type:18};for(;;){let e=this.consumeToken();if(e.type===32||e.type===3)return t;this.reconsumeToken(e),t.values.push(this.consumeComponentValue())}}consumeToken(){let e=this._tokens.shift();return e===void 0?be:e}reconsumeToken(e){this._tokens.unshift(e)}};let T=e=>e.type===15,E=e=>e.type===17,D=e=>e.type===20,Ce=e=>e.type===0,we=(e,t)=>D(e)&&e.value===t,Te=e=>e.type!==31,O=e=>e.type!==31&&e.type!==4,k=e=>{let t=[],n=[];return e.forEach(e=>{e.type===4?n.length&&(t.push(n),n=[]):e.type!==31&&n.push(e)}),n.length&&t.push(n),t},Ee=(e,t)=>t===11&&e.type===12||t===28&&e.type===29||t===2&&e.type===3,De=/(\d+(?:\.\d+)?|[+\-*/()])/g,Oe=e=>{let t=e.match(De);if(!t)return NaN;let n=[],r=[],i={"+":1,"-":1,"*":2,"/":2};for(let e of t)if(/^\d+(?:\.\d+)?$/.test(e))n.push(parseFloat(e));else if(e===`(`)r.push(e);else if(e===`)`){for(;r.length&&r[r.length-1]!==`(`;)n.push(r.pop());if(!r.length)return NaN;r.pop()}else{for(;r.length&&(i[c(r,r.length-1)]??0)>=(i[e]??0);)n.push(r.pop());r.push(e)}for(;r.length;){let e=r.pop();if(e===`(`)return NaN;n.push(e)}let a=[];for(let e of n)if(typeof e==`number`)a.push(e);else{let t=a.pop(),n=a.pop();if(n===void 0||t===void 0)return NaN;switch(e){case`+`:a.push(n+t);break;case`-`:a.push(n-t);break;case`*`:a.push(n*t);break;case`/`:a.push(t===0?NaN:n/t);break;default:return NaN}}return a.length===1?a[0]??NaN:NaN},A=(e,t,n)=>Math.min(Math.max(e,t),n),j=(e,t)=>[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]],ke=e=>j([3.2409699419045226,-1.537383177570094,-.4986107602930034,-.9692436362808796,1.8759675015077202,.04155505740717559,.05563007969699366,-.20397695888897652,1.0569715142428786],e),Ae=e=>j([.41239079926595934,.357584339383878,.1804807884018343,.21263900587151027,.715168678767756,.07219231536073371,.01933081871559182,.11919477979462598,.9505321522496607],e),je=e=>{let[t,n,r]=e,i=e=>{let t=e<0?-1:1,n=Math.abs(e);return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e};return[i(t),i(n),i(r)]},Me=e=>{let[t,n,r]=e,i=e=>{let t=e<0?-1:1,n=Math.abs(e);return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4};return[i(t),i(n),i(r)]},Ne=e=>{let[t,n,r]=je(ke([e[0],e[1],e[2]]));return[t,n,r,e[3]]},Pe=e=>{let[t,n,r]=ke([e[0],e[1],e[2]]);return[A(Math.round(t*255),0,255),A(Math.round(n*255),0,255),A(Math.round(r*255),0,255),e[3]]},Fe=e=>e.type===17||e.type===15,M=e=>e.type===16||Fe(e)||Ie(e),Ie=e=>e.type===17&&e._calcPercentage!==void 0,Le=e=>e.type===18&&e.name===`calc`,Re=e=>{let t=Be(e,0);if(!t)return null;let n=Be(e,100);if(!n)return null;let r=t.number,i=n.number-r;return i===0?t:{type:17,number:r,flags:4,_calcPercentage:i,_calcPixelOffset:r}},ze=e=>Le(e)?Re(e):M(e)?e:null,Be=(e,t=0)=>{let n=e=>{let r=``;for(let i of e)if(i.type!==31){if(i.type===18){if(i.name===`calc`){let e=n(i.values);if(e===null)return null;r+=`(${e})`}else return null}else if(i.type===17)r+=i.number.toString();else if(i.type===15)i.unit===`px`?r+=i.number.toString():i.unit===`rem`||i.unit===`em`?r+=(i.number*16).toString():r+=i.number.toString();else if(i.type===16)r+=(i.number/100*t).toString();else if(i.type===6){let e=i.value;e===`+`||e===`-`||e===`*`||e===`/`?r+=` ${e} `:e===`(`?r+=`(`:e===`)`&&(r+=`)`)}}return r};try{let t=n(e.values);if(t===null||t.trim()===``)return null;let r=Oe(t);if(typeof r==`number`&&!isNaN(r))return{type:17,number:r,flags:4}}catch{return null}return null},Ve=e=>e.length>1?[c(e,0),c(e,1)]:[c(e,0)],N={type:17,number:0,flags:4},P={type:16,number:50,flags:4},F={type:16,number:100,flags:4},He=(e,t,n)=>{let[r,i]=e;return[I(r,t),I(i===void 0?r:i,n)]},I=(e,t)=>{if(Ie(e))return e._calcPercentage/100*t+e._calcPixelOffset;if(e.type===16)return e.number/100*t;if(T(e))switch(e.unit){case`rem`:case`em`:return 16*e.number;default:return e.number}return e.number},Ue=`grad`,We=`turn`,Ge={name:`angle`,parse:(e,t)=>{if(t.type===15)switch(t.unit){case`deg`:return Math.PI*t.number/180;case Ue:return Math.PI/200*t.number;case`rad`:return t.number;case We:return Math.PI*2*t.number}throw Error(`Unsupported angle type`)}},Ke=e=>!(e.type!==15||e.unit!==`deg`&&e.unit!==Ue&&e.unit!==`rad`&&e.unit!==We),qe=e=>{switch(e.filter(D).map(e=>e.value).join(` `)){case`to bottom right`:case`to right bottom`:case`left top`:case`top left`:return[N,N];case`to top`:case`bottom`:return L(0);case`to bottom left`:case`to left bottom`:case`right top`:case`top right`:return[N,F];case`to right`:case`left`:return L(90);case`to top left`:case`to left top`:case`right bottom`:case`bottom right`:return[F,F];case`to bottom`:case`top`:return L(180);case`to top right`:case`to right top`:case`left bottom`:case`bottom left`:return[F,N];case`to left`:case`right`:return L(270)}return 0},L=e=>Math.PI*e/180,R=e=>!(255&e),z=e=>{let t=255&e,n=255&e>>8,r=255&e>>16,i=255&e>>24;return t<255?`rgba(${i},${r},${n},${t/255})`:`rgb(${i},${r},${n})`},Je=(e,t,n,r)=>(e<<24|t<<16|n<<8|Math.round(r*255))>>>0,B=(e,t)=>{if(e.type===17)return e.number;if(e.type===16){let n=t===3?1:255;return t===3?e.number/100*n:Math.round(e.number/100*n)}return 0},Ye=e=>{let t=e[0];return(t&&t.type===20?t.value:`unknown`)===`from`},Xe=e=>Je(A(Math.round(e[0]*255),0,255),A(Math.round(e[1]*255),0,255),A(Math.round(e[2]*255),0,255),A(e[3],0,1)),Ze=e=>{let[t,n,r,i]=e,a=je([t,n,r]);return Je(A(Math.round(a[0]*255),0,255),A(Math.round(a[1]*255),0,255),A(Math.round(a[2]*255),0,255),i)},Qe=e=>{let t=ke([e[0],e[1],e[2]]);return Ze([t[0],t[1],t[2],e[3]])},$e=(e,t)=>{if(Ye(t.filter(O)))throw Error(`Relative color not supported for lab()`);let[n,r,i,a]=st(t),o=et(t)?n*100:n,s=je(ke(ht([o,r,i])));return Je(A(Math.round(s[0]*255),0,255),A(Math.round(s[1]*255),0,255),A(Math.round(s[2]*255),0,255),a)},et=e=>{let t=e.filter(O)[0];return t!==void 0&&t.type===16},tt=(e,t)=>{if(Ye(t.filter(O)))throw Error(`Relative color not supported for oklab()`);let[n,r,i,a]=st(t),o=je(ke(mt([n,r,i])));return Je(A(Math.round(o[0]*255),0,255),A(Math.round(o[1]*255),0,255),A(Math.round(o[2]*255),0,255),a)},nt=(e,t)=>{if(Ye(t.filter(O)))throw Error(`Relative color not supported for oklch()`);let[n,r,i,a]=ct(t),o=je(ke(mt(pt([n,r,i]))));return Je(A(Math.round(o[0]*255),0,255),A(Math.round(o[1]*255),0,255),A(Math.round(o[2]*255),0,255),a)},rt=(e,t)=>{if(Ye(t.filter(O)))throw Error(`Relative color not supported for lch()`);let[n,r,i,a]=ot(t),o=je(ke(ht(pt([n,r,i]))));return Je(A(Math.round(o[0]*255),0,255),A(Math.round(o[1]*255),0,255),A(Math.round(o[2]*255),0,255),a)},it=(e,t)=>{let n=t.filter(O),r=n[0],i=n[1],a=n[2],o=n[3],s=o!==void 0&&o.type===6&&o.value===`/`?n[4]:n[3];return[r?(r.type===17?L(r.number):Ge.parse(e,r))/(Math.PI*2):0,i!==void 0&&M(i)?i.number/100:0,a!==void 0&&M(a)?a.number/100:0,s!==void 0&&M(s)?I(s,1):1]},at=(e,t)=>{if(Ye(t))throw Error(`Relative color not supported for hsl()`);let[n,r,i,a]=it(e,t),o=ft([n,r,i]);return Je(o[0]*255,o[1]*255,o[2]*255,a)},ot=e=>{let t=e.filter(O),n=t[0],r=t[1],i=t[2],a=t[4];return[n!==void 0&&M(n)?n.number:0,r!==void 0&&M(r)?r.number:0,i!==void 0&&(E(i)||T(i))?i.number:0,a!==void 0&&M(a)?I(a,1):1]},st=e=>{let t=e.filter(O),n=t[0],r=t[1],i=t[2],a=t[4];return[n===void 0?0:n.type===16?n.number/100:E(n)?n.number:0,r===void 0?0:r.type===16?r.number/100:E(r)?r.number:0,i!==void 0&&(E(i)||T(i))?i.number:0,a!==void 0&&M(a)?I(a,1):1]},ct=e=>{let t=e.filter(O),n=t[0],r=t[1],i=t[2],a=t[4];return[n===void 0?0:n.type===16?n.number/100:E(n)?n.number:0,r===void 0?0:r.type===16?r.number/100:E(r)?r.number:0,i!==void 0&&(E(i)||T(i))?i.number:0,a!==void 0&&M(a)?I(a,1):1]},lt=e=>j([1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371],e),ut=e=>j([.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124],e),dt=(e,t,n)=>(n<0&&(n+=1),n>=1&&--n,n<1/6?(t-e)*n*6+e:n<1/2?t:n<2/3?(t-e)*6*(2/3-n)+e:e),ft=([e,t,n])=>{if(t===0)return[n,n,n];let r=n<=.5?n*(t+1):n+t-n*t,i=n*2-r;return[dt(i,r,e+1/3),dt(i,r,e),dt(i,r,e-1/3)]},pt=([e,t,n])=>(t<0&&(t=0),isNaN(n)&&(n=0),[e,t*Math.cos(n*Math.PI/180),t*Math.sin(n*Math.PI/180)]),mt=e=>{let t=j([1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],e),n=[t[0]**3,t[1]**3,t[2]**3];return j([1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],n)},ht=e=>{let t=(e[0]+16)/116,n=e[1]/500+t,r=t-e[2]/200,i=24389/27,a=24/116,o=[(n>a?n**3:(116*n-16)/i)*.3457/.3585,e[0]>8?t**3:e[0]/i,(r>a?r**3:(116*r-16)/i)*.2958/.3585];return ut([o[0],o[1],o[2]])},gt=(e,t)=>{let n=t.filter(O);if(n.length===3||n.length===4){let e=B(c(n,0),0),t=B(c(n,1),1),r=B(c(n,2),2),i=n.length===4?B(c(n,3),3):1,a=Me([e/255,t/255,r/255]),[o,s,l]=Ae([a[0],a[1],a[2]]);return[o,s,l,i]}return[0,0,0,1]},_t=(e,t)=>{let[n,r,i,a]=it(e,t),o=Me(ft([n,r,i])),[s,c,l]=Ae([o[0],o[1],o[2]]);return[s,c,l,a]},vt=(e,t)=>{let[n,r,i,a]=st(t),[o,s,c]=ht([n,r,i]);return[o,s,c,a]},yt=(e,t)=>{let[n,r,i,a]=ot(t),[o,s,c]=ht(pt([n,r,i]));return[o,s,c,a]},bt=(e,t)=>{let[n,r,i,a]=ct(t),[o,s,c]=mt(pt([n,r,i]));return[o,s,c,a]},xt=(e,t)=>{let[n,r,i,a]=st(t),[o,s,c]=mt([n,r,i]);return[o,s,c,a]},St=e=>ut([e[0],e[1],e[2]]),Ct=e=>e,wt=e=>{let[t,n,r]=lt([e[0],e[2],e[3]]);return[t,n,r,e[3]]},Tt=e=>Qe([e[0],e[1],e[2],e[3]]),Et=e=>{let t=St([e[0],e[1],e[2]]);return Qe([t[0],t[1],t[2],e[3]])},Dt=e=>j([.4865709486482162,.26566769316909306,.1982172852343625,.2289745640697488,.6917385218365064,.079286914093745,0,.04511338185890264,1.043944368900976],e),Ot=e=>j([2.493496911941425,-.9313836179191239,-.40271078445071684,-.8294889695615747,1.7626640603183463,.023624685841943577,.03584583024378447,-.07617238926804182,.9568845240076872],e),kt=e=>{let t=e=>{let t=e<0?-1:1;return e*t<=.04045?e/12.92:t*((e+.055)/1.055)**2.4||0};return[t(e[0]),t(e[1]),t(e[2])]},At=e=>je(e),jt=e=>{let t=kt([e[0],e[1],e[2]]);return Dt([t[0],t[1],t[2]])},Mt=e=>{let[t,n,r]=At(Ot([e[0],e[1],e[2]]));return[t,n,r,e[3]]},Nt=e=>{let t=jt([e[0],e[1],e[2]]);return Qe([t[0],t[1],t[2],e[3]])},Pt=e=>j([2.0415879038107465,-.5650069742788596,-.34473135077832956,-.9692436362808795,1.8759675015077202,.04155505740717557,.013444280632031142,-.11836239223101838,1.0151749943912054],e),Ft=e=>j([.5766690429101305,.1855582379065463,.1882286462349947,.29734497525053605,.6273635662554661,.0752914584939978,.02703136138641234,.07068885253582723,.9913375368376388],e),It=e=>{let t=e.map(e=>(e<0?-1:1)*Math.abs(e)**(563/256));return[t[0]??0,t[1]??0,t[2]??0]},Lt=e=>{let t=e.map(e=>(e<0?-1:1)*Math.abs(e)**(256/563));return[t[0]??0,t[1]??0,t[2]??0]},Rt=e=>{let[t,n,r]=Lt(Pt([e[0],e[1],e[2]]));return[t,n,r,e[3]]},zt=e=>{let t=ke(Ft(It([e[0],e[1],e[2]])));return Ze([t[0],t[1],t[2],e[3]])},Bt=e=>j([.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602],e),Vt=e=>j([1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],e),Ht=e=>{let[t,n,r]=e,i=e=>e<16/512?e/16:e**1.8;return[i(t),i(n),i(r)]},Ut=e=>{let[t,n,r]=e,i=e=>e>1/512?e**(1/1.8):e*16;return[i(t),i(n),i(r)]},Wt=e=>{let t=Ht([e[0],e[1],e[2]]);return ut(Bt([t[0],t[1],t[2]]))},Gt=e=>{let[t,n,r]=Ut(Vt(lt([e[0],e[1],e[2]])));return[t,n,r,e[3]]},Kt=e=>{let t=Wt([e[0],e[1],e[2]]);return Qe([t[0],t[1],t[2],e[3]])},qt=1.09929682680944,Jt=.018053968510807,Yt=e=>{let t=e=>e<Jt*4.5?e/4.5:((e+qt-1)/qt)**(1/.45);return[t(e[0]),t(e[1]),t(e[2])]},Xt=e=>{let t=e=>e>=Jt?qt*e**.45-.09929682680944008:4.5*e;return[t(e[0]),t(e[1]),t(e[2])]},Zt=e=>j([.6369580483012914,.14461690358620832,.1688809751641721,.2627002120112671,.6779980715188708,.05930171646986196,0,.028072693049087428,1.060985057710791],e),Qt=e=>j([1.716651187971268,-.355670783776392,-.25336628137366,-.666684351832489,1.616481236634939,.0157685458139111,.017639857445311,-.042770613257809,.942103121235474],e),$t=e=>{let t=Yt([e[0],e[1],e[2]]);return Zt([t[0],t[1],t[2]])},en=e=>{let[t,n,r]=Xt(Qt([e[0],e[1],e[2]]));return[t,n,r,e[3]]},tn=e=>{let t=$t([e[0],e[1],e[2]]);return Qe([t[0],t[1],t[2],e[3]])},nn={lch:2,oklch:2,hsl:0},rn=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],an=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],on=e=>{let t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=t*(a*l-o*c)-n*(i*l-o*s)+r*(i*c-a*s);return[(a*l-o*c)/u,(r*c-n*l)/u,(n*o-r*a)/u,(o*s-i*l)/u,(t*l-r*s)/u,(r*i-t*o)/u,(i*c-a*s)/u,(n*s-t*c)/u,(t*a-n*i)/u]},sn=on(rn),cn=on(an),ln=24389/27,un=24/116,dn=un*un*un,fn=e=>[(255&e>>24)/255,(255&e>>16)/255,(255&e>>8)/255],pn=e=>{let[t,n,r]=lt([e[0],e[1],e[2]]),i=t/.9642956764295677,a=n,o=r/.8251046025104602,s=i>dn?Math.cbrt(i):(ln*i+16)/116,c=a>dn?Math.cbrt(a):(ln*a+16)/116,l=o>dn?Math.cbrt(o):(ln*o+16)/116;return[116*c-16,500*(s-c),200*(c-l)]},mn=e=>{let t=j(sn,e),n=[Math.cbrt(t[0]),Math.cbrt(t[1]),Math.cbrt(t[2])];return j(cn,n)},hn=e=>{let t=Math.hypot(e[1],e[2]),n=Math.atan2(e[2],e[1])*180/Math.PI;return[e[0],t,(n+360)%360]},gn=e=>{let t=e[0],n=e[1],r=e[2],i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2;if(i===a)return[0,0,o];let s=i-a,c=o>.5?s/(2-i-a):s/(i+a),l;return l=i===t?((n-r)/s+(n<r?6:0))/6:i===n?((r-t)/s+2)/6:((t-n)/s+4)/6,[l,c,o]},_n=(e,t)=>{let n=(255&e)/255,r=fn(e),i=Me(r),a=Ae(i),o;switch(t){case`srgb`:o=r;break;case`srgb-linear`:o=i;break;case`xyz`:case`xyz-d65`:o=a;break;case`xyz-d50`:o=lt(a);break;case`lab`:o=pn(a);break;case`oklab`:o=mn(a);break;case`lch`:o=hn(pn(a));break;case`oklch`:o=hn(mn(a));break;case`hsl`:o=[gn(r)[0]*360,gn(r)[1],gn(r)[2]]}return[o[0],o[1],o[2],n]},vn=(e,t)=>{let n=e[0],r=e[1],i=e[2],a=e[3];switch(t){case`srgb`:return Xe([n,r,i,a]);case`srgb-linear`:return Ze([n,r,i,a]);case`xyz`:case`xyz-d65`:return Qe([n,r,i,a]);case`xyz-d50`:return Qe([...ut([n,r,i]),a]);case`lab`:return yn(ht([n,r,i]),a);case`oklab`:return yn(mt([n,r,i]),a);case`lch`:return yn(ht(pt([n,r,i])),a);case`oklch`:return yn(mt(pt([n,r,i])),a);case`hsl`:{let e=ft([n/360,r,i]);return Xe([e[0],e[1],e[2],a])}}},yn=(e,t)=>{let n=je(ke(e));return Xe([n[0],n[1],n[2],t])},bn=(e,t,n,r,i=`shorter`)=>{let a=n+r;if(a===0)return e;let o=((t-e)%360+360)%360;switch(i){case`shorter`:o>180&&(o-=360);break;case`longer`:o<180&&(o-=360);break;case`increasing`:break;case`decreasing`:o>0&&(o-=360)}return e+r/a*o},xn=(e,t)=>{let n,r=null;for(let e of t)if(e.type!==31&&e.type!==4){if(e.type===16)r=e.number;else if(D(e)&&e.value===`none`)r===null&&(r=0);else if(n===void 0)n=e;else throw Error(`Unexpected token in color-mix() component`)}if(n===void 0)throw Error(`color-mix() component is missing a color`);let i=n;return{color:V.parse(e,i),percentage:r}},Sn=[`srgb`,`srgb-linear`,`lab`,`oklab`,`lch`,`oklch`,`hsl`,`xyz`,`xyz-d50`,`xyz-d65`],Cn=(e,t,n,r,i,a)=>{let o=nn[i],s=[e[0]*e[3],e[1]*e[3],e[2]*e[3],e[3]],l=[t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]],u=n*s[3]+r*l[3];if(u<=0)return[0,0,0,0];let d=[0,0,0,u];for(let e=0;e<3;e++)e!==o&&(d[e]=(n*c(s,e)+r*c(l,e))/u);if(o!==void 0){let i=c(e,o),s=c(t,o);e[1]===0&&(i=s),t[1]===0&&(s=i),d[o]=bn(i,s,n,r,a)}return d},wn=(e,t)=>{let n=[[]];for(let e of t)e.type===4?n.push([]):n[n.length-1].push(e);let r=n.map(e=>e.filter(e=>e.type!==31));if(r.length!==3)throw Error(`color-mix() requires exactly two color components`);let i=r[0],a=i?i[0]:void 0,o=a!==void 0&&D(a)&&a.value===`in`;if(!i||i.length<2||!o)throw Error("color-mix() requires an interpolation space after `in`");let s=i[1];if(!s||!D(s))throw Error(`color-mix() space must be an identifier`);let c=s.value;if(Sn.indexOf(c)===-1)throw Error(`Unsupported color-mix() interpolation space "${c}"`);let l=`shorter`,u=i.slice(2);if(u.length>0){let e=u[0],t=u[1];if(!e||!t||!D(e)||!D(t)||t.value!==`hue`)throw Error(`Unsupported color-mix() hue method syntax`);if([`shorter`,`longer`,`increasing`,`decreasing`].indexOf(e.value)===-1)throw Error(`Unsupported color-mix() hue method "${e.value}"`);l=e.value}let d=r[1],f=r[2];if(!d||!f)throw Error(`color-mix() requires exactly two color components`);let p=xn(e,d),m=xn(e,f),h=p.percentage,g=m.percentage;if(h===null&&g===null)h=50,g=50;else if(h===null)h=100-(g??0);else if(g===null)g=100-h;else{let e=h+g;e>0&&(h=h/e*100,g=g/e*100)}let _=(h??0)/100,v=(g??0)/100,y=Cn(_n(p.color,c),_n(m.color,c),_,v,c,l);return vn(y,c)},Tn=(e,t)=>{try{return wn(e,t)}catch(t){return e.logger.warn(`Unsupported color-mix() value: ${t instanceof Error?t.message:t}`),0}},V={name:`color`,parse:(e,t)=>{if(t.type===18){let n=Mn[t.name];if(n===void 0)throw Error(`Attempting to parse an unsupported color function "${t.name}"`);return n(e,t.values)}if(t.type===5){let[e,n,r,i]=En(t);return Je(e,n,r,i)}if(t.type===20){let e=Pn[t.value.toUpperCase()];if(e!==void 0)return e}return 0}},En=e=>{if(e.value.length===3){let t=e.value.substring(0,1),n=e.value.substring(1,2),r=e.value.substring(2,3);return[parseInt(t+t,16),parseInt(n+n,16),parseInt(r+r,16),1]}if(e.value.length===4){let t=e.value.substring(0,1),n=e.value.substring(1,2),r=e.value.substring(2,3),i=e.value.substring(3,4);return[parseInt(t+t,16),parseInt(n+n,16),parseInt(r+r,16),parseInt(i+i,16)/255]}if(e.value.length===6){let t=e.value.substring(0,2),n=e.value.substring(2,4),r=e.value.substring(4,6);return[parseInt(t,16),parseInt(n,16),parseInt(r,16),1]}if(e.value.length===8){let t=e.value.substring(0,2),n=e.value.substring(2,4),r=e.value.substring(4,6),i=e.value.substring(6,8);return[parseInt(t,16),parseInt(n,16),parseInt(r,16),parseInt(i,16)/255]}return[0,0,0,1]},Dn=(e,t)=>{let n=t.filter(O);if(Ye(n))throw Error(`Relative color not supported for rgb()`);if(n.length===3||n.length===4){let e=B(c(n,0),0),t=B(c(n,1),1),r=B(c(n,2),2),i=n.length===4?B(c(n,3),3):1;return Je(e,t,r,i)}if(n.length===5){let e=c(n,3);if(e.type===6&&e.value===`/`){let e=B(c(n,0),0),t=B(c(n,1),1),r=B(c(n,2),2),i=B(c(n,4),3);return Je(e,t,r,i)}}return 0},On=(e,t)=>{let n=t.filter(O),r=n[0],i=r&&r.type===20?r.value:`unknown`;if(Ye(n)){let t=(e,t)=>{if(E(t))return t.number;let n=e=>e===`r`||e===`x`?0:e===`g`||e===`y`?1:2;if(D(t)){let r=n(t.value);return c(e,r)}let r=e=>{let t=e.filter(O),n=`(`;for(let e of t)n+=e.type===18&&e.name===`calc`?r(e.values):E(e)?e.number:e.type===6||D(e)?e.value:``;return n+=`)`,n};if(t.type===18){let n=t.values.filter(O);if(t.name===`calc`){let t=r(n).replace(/r|x/,e[0].toString()).replace(/g|y/,e[1].toString()).replace(/b|z/,e[2].toString());return Oe(t)}}return null},r=c(n,1),i=r.type===18?r.name:D(r)||r.type===5?`rgb`:`unknown`,a=c(n,2),o=D(a)?a.value:`unknown`,s=r.type===18?r.values:D(r)?[r]:[];if(D(r)){if(Pn[r.value.toUpperCase()]===void 0)throw Error(`Attempting to use unknown color in relative color 'from'`);{let t=Nn(e,r.value),n=255&t,i=255&t>>8,a=255&t>>16;s=[{type:17,number:255&t>>24,flags:1},{type:17,number:a,flags:1},{type:17,number:i,flags:1},{type:17,number:n>1?n/255:n,flags:1}]}}else if(r.type===5){let[e,t,n,i]=En(r);s=[{type:17,number:e,flags:1},{type:17,number:t,flags:1},{type:17,number:n,flags:1},{type:17,number:i>1?i/255:i,flags:1}]}if(s.length===0)throw Error(`Attempting to use unknown color in relative color 'from'`);if(o===`unknown`)throw Error(`Attempting to use unknown colorspace in relative color 'to'`);let l=An[i],u=jn[o],d=kn[o];if(l===void 0)throw Error(`Attempting to parse an unsupported color space "${i}" for color() function`);if(u===void 0)throw Error(`Attempting to parse an unsupported color space "${o}" for color() function`);let f=u(l(e,s)),p=t(f,c(n,3)),m=t(f,c(n,4)),h=t(f,c(n,5)),g=n[6],_=n[7],v=g!==void 0&&g.type===6&&g.value===`/`&&_!==void 0&&E(_)?_.number:1;if(p===null||m===null||h===null)throw Error(`Invalid relative color in color() function`);if(d===void 0)throw Error(`Attempting to parse an unsupported color space "${o}" for color() function`);return d([p,m,h,v])}{let e=i,t=kn[e];if(t===void 0)throw Error(`Attempting to parse an unsupported color space "${e}" for color() function`);let r=c(n,1),a=c(n,2),o=c(n,3),s=n[4],l=n[5];return t([E(r)?r.number:0,E(a)?a.number:0,E(o)?o.number:0,s!==void 0&&s.type===6&&s.value===`/`&&l!==void 0&&E(l)?l.number:1])}},kn={srgb:Xe,"srgb-linear":Ze,"display-p3":Nt,"a98-rgb":zt,"prophoto-rgb":Kt,xyz:Tt,"xyz-d50":Et,"xyz-d65":Tt,rec2020:tn},An={rgb:gt,hsl:_t,lab:vt,lch:yt,oklab:xt,oklch:bt},jn={srgb:Ne,"srgb-linear":Pe,"display-p3":Mt,"a98-rgb":Rt,"prophoto-rgb":Gt,xyz:Ct,"xyz-d50":wt,"xyz-d65":Ct,rec2020:en},Mn={hsl:at,hsla:at,rgb:Dn,rgba:Dn,lch:rt,oklch:nt,oklab:tt,lab:$e,color:On,"color-mix":Tn},Nn=(e,t)=>V.parse(e,Se.create(t).parseComponentValue()),Pn={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Fn=e=>e.nodeType===Node.ELEMENT_NODE,In=e=>e.nodeType===Node.TEXT_NODE,Ln=e=>typeof e.className==`object`,Rn=e=>Fn(e)&&e.style!==void 0&&!Ln(e),zn=e=>e.tagName===`INPUT`,Bn=e=>e.tagName===`HTML`,Vn=e=>e.tagName===`svg`,Hn=e=>e.tagName===`BODY`,Un=e=>e.tagName===`CANVAS`,Wn=e=>e.tagName===`VIDEO`,Gn=e=>e.tagName===`IMG`,Kn=e=>e.tagName===`IFRAME`,qn=e=>e.tagName===`STYLE`,Jn=e=>e.tagName===`SCRIPT`,Yn=e=>e.tagName===`TEXTAREA`,Xn=e=>e.tagName===`SELECT`,Zn=e=>e.tagName===`SLOT`,Qn=e=>e.tagName===`LI`,$n=e=>e.tagName===`OL`,er=e=>!Ln(e)&&e.tagName.indexOf(`-`)>0,tr=/* @__PURE__ */ new Set([`IMG`,`VIDEO`,`AUDIO`,`CANVAS`,`IFRAME`,`INPUT`,`TEXTAREA`,`SELECT`,`BR`,`HR`,`META`,`LINK`,`BASE`,`COL`,`SOURCE`,`TRACK`,`WBR`,`AREA`,`PARAM`,`EMBED`,`OBJECT`]),nr=e=>!Ln(e)&&!tr.has(e.tagName),rr={name:`list-style-type`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`disc`:return 0;case`circle`:return 1;case`square`:return 2;case`decimal`:return 3;case`cjk-decimal`:return 4;case`decimal-leading-zero`:return 5;case`lower-roman`:return 6;case`upper-roman`:return 7;case`lower-greek`:return 8;case`lower-alpha`:return 9;case`upper-alpha`:return 10;case`arabic-indic`:return 11;case`armenian`:return 12;case`bengali`:return 13;case`cambodian`:return 14;case`cjk-earthly-branch`:return 15;case`cjk-heavenly-stem`:return 16;case`cjk-ideographic`:return 17;case`devanagari`:return 18;case`ethiopic-numeric`:return 19;case`georgian`:return 20;case`gujarati`:return 21;case`gurmukhi`:return 22;case`hebrew`:return 52;case`hiragana`:return 23;case`hiragana-iroha`:return 24;case`japanese-formal`:return 25;case`japanese-informal`:return 26;case`kannada`:return 27;case`katakana`:return 28;case`katakana-iroha`:return 29;case`khmer`:return 30;case`korean-hangul-formal`:return 31;case`korean-hanja-formal`:return 32;case`korean-hanja-informal`:return 33;case`lao`:return 34;case`lower-armenian`:return 35;case`malayalam`:return 36;case`mongolian`:return 37;case`myanmar`:return 38;case`oriya`:return 39;case`persian`:return 40;case`simp-chinese-formal`:return 41;case`simp-chinese-informal`:return 42;case`tamil`:return 43;case`telugu`:return 44;case`thai`:return 45;case`tibetan`:return 46;case`trad-chinese-formal`:return 47;case`trad-chinese-informal`:return 48;case`upper-armenian`:return 49;case`disclosure-open`:return 50;case`disclosure-closed`:return 51;default:return-1}}},H=(e,t)=>(e&t)!==0;var ir=class{counters={};getCounterValue(e){let t=this.counters[e];return t&&t.length?c(t,t.length-1):1}getCounterValues(e){return this.counters[e]||[]}pop(e){e.forEach(e=>this.counters[e]?.pop())}parse(e){let t=e.counterIncrement,n=e.counterReset,r=!0;t!==null&&t.forEach(e=>{let t=this.counters[e.counter];if(t&&e.increment!==0){r=!1,t.length||t.push(1);let n=Math.max(0,t.length-1);t[n]=(t[n]??0)+e.increment}});let i=[];return r&&n.forEach(e=>{let t=this.counters[e.counter];i.push(e.counter),t||=this.counters[e.counter]=[],t.push(e.reset)}),i}};let ar={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:[`M`,`CM`,`D`,`CD`,`C`,`XC`,`L`,`XL`,`X`,`IX`,`V`,`IV`,`I`]},or={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:/* @__PURE__ */ `Ք.Փ.Ւ.Ց.Ր.Տ.Վ.Ս.Ռ.Ջ.Պ.Չ.Ո.Շ.Ն.Յ.Մ.Ճ.Ղ.Ձ.Հ.Կ.Ծ.Խ.Լ.Ի.Ժ.Թ.Ը.Է.Զ.Ե.Դ.Գ.Բ.Ա`.split(`.`)},sr={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:/* @__PURE__ */ `י׳.ט׳.ח׳.ז׳.ו׳.ה׳.ד׳.ג׳.ב׳.א׳.ת.ש.ר.ק.צ.פ.ע.ס.נ.מ.ל.כ.יט.יח.יז.טז.טו.י.ט.ח.ז.ו.ה.ד.ג.ב.א`.split(`.`)},cr={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:/* @__PURE__ */ `ჵ.ჰ.ჯ.ჴ.ხ.ჭ.წ.ძ.ც.ჩ.შ.ყ.ღ.ქ.ფ.ჳ.ტ.ს.რ.ჟ.პ.ო.ჲ.ნ.მ.ლ.კ.ი.თ.ჱ.ზ.ვ.ე.დ.გ.ბ.ა`.split(`.`)},lr=(e,t,n,r,i,a)=>e<t||e>n?_r(e,i,a.length>0):r.integers.reduce((t,n,i)=>{for(;e>=n;)e-=n,t+=r.values[i];return t},``)+a,ur=(e,t,n,r)=>{let i=``;do n||e--,i=r(e)+i,e/=t;while(e*t>=t);return i},U=(e,t,n,r,i)=>{let a=n-t+1;return(e<0?`-`:``)+(ur(Math.abs(e),a,r,e=>String.fromCodePoint(Math.floor(e%a)+t))+i)},dr=(e,t,n=`. `)=>{let r=t.length;return ur(Math.abs(e),r,!1,e=>String(t[Math.floor(e%r)]))+n},fr=(e,t,n,r,i,a)=>{if(e<-9999||e>9999)return _r(e,4,i.length>0);let o=Math.abs(e),s=i;if(o===0)return t[0]+s;for(let r=0;o>0&&r<=4;r++){let i=o%10;i===0&&H(a,1)&&s!==``?s=t[i]+s:i>1||i===1&&r===0||i===1&&r===1&&H(a,2)||i===1&&r===1&&H(a,4)&&e>100||i===1&&r>1&&H(a,8)?s=(t[i]??``)+(r>0?n[r-1]??``:``)+s:i===1&&r>0&&(s=(n[r-1]??``)+s),o=Math.floor(o/10)}return(e<0?r:``)+s},pr=`十百千萬`,mr=`拾佰仟萬`,hr=`マイナス`,gr=`마이너스`,_r=(e,t,n)=>{let r=n?`. `:``,i=n?`、`:``,a=n?`, `:``,o=n?` `:``;switch(t){case 0:return`•`+o;case 1:return`◦`+o;case 2:return`◾`+o;case 5:let t=U(e,48,57,!0,r);return t.length<4?`0${t}`:t;case 4:return dr(e,`〇一二三四五六七八九`,i);case 6:return lr(e,1,3999,ar,3,r).toLowerCase();case 7:return lr(e,1,3999,ar,3,r);case 8:return U(e,945,969,!1,r);case 9:return U(e,97,122,!1,r);case 10:return U(e,65,90,!1,r);case 11:return U(e,1632,1641,!0,r);case 12:case 49:return lr(e,1,9999,or,3,r);case 35:return lr(e,1,9999,or,3,r).toLowerCase();case 13:return U(e,2534,2543,!0,r);case 14:case 30:return U(e,6112,6121,!0,r);case 15:return dr(e,`子丑寅卯辰巳午未申酉戌亥`,i);case 16:return dr(e,`甲乙丙丁戊己庚辛壬癸`,i);case 17:case 48:return fr(e,`零一二三四五六七八九`,pr,`負`,i,14);case 47:return fr(e,`零壹貳參肆伍陸柒捌玖`,mr,`負`,i,15);case 42:return fr(e,`零一二三四五六七八九`,pr,`负`,i,14);case 41:return fr(e,`零壹贰叁肆伍陆柒捌玖`,mr,`负`,i,15);case 26:return fr(e,`〇一二三四五六七八九`,`十百千万`,hr,i,0);case 25:return fr(e,`零壱弐参四伍六七八九`,`拾百千万`,hr,i,7);case 31:return fr(e,`영일이삼사오육칠팔구`,`십백천만`,gr,a,7);case 33:return fr(e,`零一二三四五六七八九`,`十百千萬`,gr,a,0);case 32:return fr(e,`零壹貳參四五六七八九`,`拾百千`,gr,a,7);case 18:return U(e,2406,2415,!0,r);case 20:return lr(e,1,19999,cr,3,r);case 21:return U(e,2790,2799,!0,r);case 22:return U(e,2662,2671,!0,r);case 52:return lr(e,1,10999,sr,3,r);case 23:return dr(e,`あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん`);case 24:return dr(e,`いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす`);case 27:return U(e,3302,3311,!0,r);case 28:return dr(e,`アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン`,i);case 29:return dr(e,`イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス`,i);case 34:return U(e,3792,3801,!0,r);case 37:return U(e,6160,6169,!0,r);case 38:return U(e,4160,4169,!0,r);case 39:return U(e,2918,2927,!0,r);case 40:return U(e,1776,1785,!0,r);case 43:return U(e,3046,3055,!0,r);case 44:return U(e,3174,3183,!0,r);case 45:return U(e,3664,3673,!0,r);case 46:return U(e,3872,3881,!0,r);default:return U(e,48,57,!0,r)}},vr={name:`display`,initialValue:`inline-block`,prefix:!1,type:1,parse:(e,t)=>t.filter(D).reduce((e,t)=>e|yr(t.value),0)},yr=e=>{switch(e){case`block`:case`-webkit-box`:return 2;case`inline`:return 4;case`run-in`:return 8;case`flow`:return 16;case`flow-root`:return 32;case`table`:return 64;case`flex`:case`-webkit-flex`:return 128;case`grid`:case`-ms-grid`:return 256;case`ruby`:return 512;case`subgrid`:return 1024;case`list-item`:return 2048;case`table-row-group`:return 4096;case`table-header-group`:return 8192;case`table-footer-group`:return 16384;case`table-row`:return 32768;case`table-cell`:return 65536;case`table-column-group`:return 131072;case`table-column`:return 262144;case`table-caption`:return 524288;case`ruby-base`:return 1048576;case`ruby-text`:return 2097152;case`ruby-base-container`:return 4194304;case`ruby-text-container`:return 8388608;case`contents`:return 16777216;case`inline-block`:return 33554432;case`inline-list-item`:return 67108864;case`inline-table`:return 134217728;case`inline-flex`:return 268435456;case`inline-grid`:return 536870912}return 0},br={name:`float`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`left`:return 1;case`right`:return 2;case`inline-start`:return 3;case`inline-end`:return 4}return 0}},xr={name:`overflow`,initialValue:`visible`,prefix:!1,type:1,parse:(e,t)=>t.filter(D).map(e=>{switch(e.value){case`hidden`:return 1;case`scroll`:return 2;case`clip`:return 3;case`auto`:return 4;default:return 0}})},Sr={name:`text-decoration-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},Cr={name:`text-decoration-line`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>t.filter(D).map(e=>{switch(e.value){case`underline`:return 1;case`overline`:return 2;case`line-through`:return 3;case`none`:return 4}return 0}).filter(e=>e!==0)},wr={name:`content`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>{if(t.length===0)return[];let n=t[0];return n&&n.type===20&&n.value===`none`?[]:t}},Tr={name:`quotes`,initialValue:`none`,prefix:!0,type:1,parse:(e,t)=>{if(t.length===0)return null;let n=t[0];if(n&&n.type===20&&n.value===`none`)return null;let r=[],i=t.filter(Ce);if(i.length%2!=0)return null;for(let e=0;e<i.length;e+=2){let t=c(i,e).value,n=c(i,e+1).value;r.push({open:t,close:n})}return r}},Er=(e,t,n)=>{if(!e)return``;let r=e[Math.min(t,e.length-1)];return r?n?r.open:r.close:``},Dr=(e,t)=>{let n=[],r=e.filter(Te);for(let e=0;e<r.length;e++){let i=r[e],a=r[e+1];if(i&&i.type===20){let e=a&&E(a)?a.number:t;n.push([i.value,e])}}return n},Or={name:`counter-increment`,initialValue:`none`,prefix:!0,type:1,parse:(e,t)=>{if(t.length===0)return null;let n=t[0];return n&&n.type===20&&n.value===`none`?null:Dr(t,1).map(([e,t])=>({counter:e,increment:t}))}},kr={name:`counter-reset`,initialValue:`none`,prefix:!0,type:1,parse:(e,t)=>t.length===0?[]:Dr(t,0).filter(([e])=>e!==`none`).map(([e,t])=>({counter:e,reset:t}))},Ar={name:`background-clip`,initialValue:`border-box`,prefix:!1,type:1,parse:(e,t)=>t.map(e=>{if(D(e))switch(e.value){case`padding-box`:return 1;case`content-box`:return 2;case`text`:return 3}return 0})},jr={name:`background-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},Mr=(e,t)=>{let n=V.parse(e,c(t,0)),r=t[1];return r&&M(r)?{color:n,stop:r}:{color:n,stop:null}},W=(e,t)=>{let n=e.map(e=>({color:e.color,stop:e.stop})),r=c(n,0),i=c(n,n.length-1);r.stop===null&&(r.stop=N),i.stop===null&&(i.stop=F);let a=[],o=0;for(let e=0;e<n.length;e++){let r=c(n,e).stop;if(r!==null){let e=I(r,t);e>o?a.push(e):a.push(o),o=e}else a.push(null)}let s=null;for(let e=0;e<a.length;e++){let t=c(a,e);if(t===null)s===null&&(s=e);else if(s!==null){let n=e-s,r=(t-a[s-1])/(n+1);for(let e=1;e<=n;e++)a[s+e-1]=r*e;s=null}}return n.map(({color:e},n)=>({color:e,stop:Math.max(Math.min(1,a[n]/t),0)}))},Nr=(e,t,n)=>{let r=t/2,i=n/2,a=I(e[0],t)-r,o=i-I(e[1],n);return(Math.atan2(o,a)+Math.PI*2)%(Math.PI*2)},Pr=(e,t,n)=>{let r=typeof e==`number`?e:Nr(e,t,n),i=Math.abs(t*Math.sin(r))+Math.abs(n*Math.cos(r)),a=t/2,o=n/2,s=i/2,c=Math.sin(r-Math.PI/2)*s,l=Math.cos(r-Math.PI/2)*s;return[i,a-l,a+l,o-c,o+c]},G=(e,t)=>Math.sqrt(e*e+t*t),Fr=(e,t,n,r,i)=>[[0,0],[0,t],[e,0],[e,t]].reduce((e,t)=>{let[a,o]=t,s=G(n-a,r-o);return(i?s<e.optimumDistance:s>e.optimumDistance)?{optimumCorner:t,optimumDistance:s}:e},{optimumDistance:i?1/0:-1/0,optimumCorner:null}).optimumCorner,Ir=(e,t,n,r,i)=>{let a=0,o=0;switch(e.size){case 0:e.shape===0?a=o=Math.min(Math.abs(t),Math.abs(t-r),Math.abs(n),Math.abs(n-i)):e.shape===1&&(a=Math.min(Math.abs(t),Math.abs(t-r)),o=Math.min(Math.abs(n),Math.abs(n-i)));break;case 2:if(e.shape===0)a=o=Math.min(G(t,n),G(t,n-i),G(t-r,n),G(t-r,n-i));else if(e.shape===1){let e=Math.min(Math.abs(n),Math.abs(n-i))/Math.min(Math.abs(t),Math.abs(t-r)),[s,c]=Fr(r,i,t,n,!0);a=G(s-t,(c-n)/e),o=e*a}break;case 1:e.shape===0?a=o=Math.max(Math.abs(t),Math.abs(t-r),Math.abs(n),Math.abs(n-i)):e.shape===1&&(a=Math.max(Math.abs(t),Math.abs(t-r)),o=Math.max(Math.abs(n),Math.abs(n-i)));break;case 3:if(e.shape===0)a=o=Math.max(G(t,n),G(t,n-i),G(t-r,n),G(t-r,n-i));else if(e.shape===1){let e=Math.max(Math.abs(n),Math.abs(n-i))/Math.max(Math.abs(t),Math.abs(t-r)),[s,c]=Fr(r,i,t,n,!1);a=G(s-t,(c-n)/e),o=e*a}}if(Array.isArray(e.size)){let t=e.size;a=I(c(t,0),r),o=t.length===2?I(c(t,1),i):a}return[a,o]},Lr=(e,t)=>{let n=L(180),r=[];return k(t).forEach((t,i)=>{if(i===0){let r=t[0];if(r&&r.type===20&&r.value===`to`){n=qe(t);return}if(r&&Ke(r)){n=Ge.parse(e,r);return}}let a=Mr(e,t);r.push(a)}),{angle:n,stops:r,type:1}},Rr=(e,t)=>{let n=L(180),r=[];return k(t).forEach((t,i)=>{if(i===0){let r=t[0];if(r&&r.type===20&&[`top`,`left`,`right`,`bottom`].indexOf(r.value)!==-1){n=qe(t);return}if(r&&Ke(r)){n=(Ge.parse(e,r)+L(270))%L(360);return}}let a=Mr(e,t);r.push(a)}),{angle:n,stops:r,type:1}},zr=(e,t)=>{let n=L(180),r=[],i=1;return k(t).forEach((t,n)=>{let a=t[0];if(a){if(n===0){if(D(a)&&a.value===`linear`){i=1;return}if(D(a)&&a.value===`radial`){i=2;return}}if(a.type===18){if(a.name===`from`){let t=V.parse(e,c(a.values,0));r.push({stop:N,color:t})}else if(a.name===`to`){let t=V.parse(e,c(a.values,0));r.push({stop:F,color:t})}else if(a.name===`color-stop`){let t=a.values.filter(O);if(t.length===2){let n=V.parse(e,c(t,1)),i=c(t,0);E(i)&&r.push({stop:{type:16,number:i.number*100,flags:i.flags},color:n})}}}}}),i===1?{angle:(n+L(180))%L(360),stops:r,type:i}:{size:3,shape:0,stops:r,position:[],type:i}},Br=`closest-side`,Vr=`farthest-side`,Hr=`closest-corner`,Ur=`farthest-corner`,Wr=`circle`,Gr=`ellipse`,Kr=`cover`,qr=`contain`,Jr=(e,t)=>{let n=1,r=3,i=[],a=[];return k(t).forEach((t,o)=>{let s=!0;if(o===0){let e=!1;s=t.reduce((t,i)=>{if(e){if(D(i))switch(i.value){case`center`:return a.push(P),t;case`top`:case`left`:return a.push(N),t;case`right`:case`bottom`:return a.push(F),t}else(M(i)||Fe(i))&&a.push(i)}else if(D(i))switch(i.value){case Wr:return n=0,!1;case Gr:return n=1,!1;case`at`:return e=!0,!1;case Br:return r=0,!1;case Kr:case Vr:return r=1,!1;case qr:case Hr:return r=2,!1;case Ur:return r=3,!1}else if(Fe(i)||M(i))return Array.isArray(r)||(r=[]),r.push(i),!1;return t},s)}if(s){let n=Mr(e,t);i.push(n)}}),{size:r,shape:n,stops:i,position:a,type:2}},Yr=(e,t)=>{let n=1,r=3,i=[],a=[];return k(t).forEach((t,o)=>{let s=!0;if(o===0?s=t.reduce((e,t)=>{if(D(t))switch(t.value){case`center`:return a.push(P),!1;case`top`:case`left`:return a.push(N),!1;case`right`:case`bottom`:return a.push(F),!1}else if(M(t)||Fe(t))return a.push(t),!1;return e},s):o===1&&(s=t.reduce((e,t)=>{if(D(t))switch(t.value){case Wr:return n=0,!1;case Gr:return n=1,!1;case qr:case Br:return r=0,!1;case Vr:return r=1,!1;case Hr:return r=2,!1;case Kr:case Ur:return r=3,!1}else if(Fe(t)||M(t))return Array.isArray(r)||(r=[]),r.push(t),!1;return e},s)),s){let n=Mr(e,t);i.push(n)}}),{size:r,shape:n,stops:i,position:a,type:2}},Xr=(e,t)=>({...Lr(e,t),type:3}),Zr=(e,t)=>({...Jr(e,t),type:4}),Qr=(e,t)=>{let n=0,r=[],i=[];return k(t).forEach((t,a)=>{let o=!0;if(a===0){let i=!1,a=!1;o=t.reduce((t,o)=>{if(D(o))switch(o.value){case`from`:return i=!0,a=!1,!1;case`at`:return i=!1,a=!0,!1;case`center`:return r.push(P),t;case`top`:case`left`:return r.push(N),t;case`right`:case`bottom`:return r.push(F),t}return i?(n=Ge.parse(e,o),!1):(a&&M(o)&&r.push(o),t)},!0)}o&&t.length>0&&i.push(Mr(e,t))}),{type:5,angle:n,position:r,stops:i}},$r=(e,t)=>({...Qr(e,t),type:6}),ei=e=>e&&(T(e)&&(e.unit===`dppx`||e.unit===`x`)||E(e))?e.number:1,ti=(e,t)=>{let n=k(t),r=e.config.window.devicePixelRatio||1,i=[];for(let e of n){let t=e.find(e=>e.type===22||e.type===18);if(!t)continue;let n=e.find(e=>T(e)||E(e));i.push({imageToken:t,resolution:ei(n)})}if(i.length===0)throw Error(`image-set() requires at least one image candidate`);let a=i.filter(e=>e.resolution>=r).sort((e,t)=>e.resolution-t.resolution),o=c(a.length>0?a:i.slice().sort((e,t)=>t.resolution-e.resolution),0);return ci.parse(e,o.imageToken)},ni=e=>e.type===1,ri=e=>e.type===2,ii=e=>e.type===3,ai=e=>e.type===4,oi=e=>e.type===5,si=e=>e.type===6,ci={name:`image`,parse:(e,t)=>{if(t.type===22){let n={url:t.value,type:0};return e.cache.addImage(t.value),n}if(t.type===18){let n=ui[t.name];if(n===void 0)throw Error(`Attempting to parse an unsupported image function "${t.name}"`);return n(e,t.values)}throw Error(`Unsupported image type ${t.type}`)}};function li(e){return(e.type!==20||e.value!==`none`)&&(e.type!==18||!!ui[e.name])}let ui={"linear-gradient":Lr,"-moz-linear-gradient":Rr,"-ms-linear-gradient":Rr,"-o-linear-gradient":Rr,"-webkit-linear-gradient":Rr,"radial-gradient":Jr,"-moz-radial-gradient":Yr,"-ms-radial-gradient":Yr,"-o-radial-gradient":Yr,"-webkit-radial-gradient":Yr,"-webkit-gradient":zr,"repeating-linear-gradient":Xr,"-webkit-repeating-linear-gradient":Xr,"-moz-repeating-linear-gradient":Xr,"-ms-repeating-linear-gradient":Xr,"-o-repeating-linear-gradient":Xr,"repeating-radial-gradient":Zr,"-webkit-repeating-radial-gradient":Zr,"-moz-repeating-radial-gradient":Zr,"conic-gradient":Qr,"-webkit-conic-gradient":Qr,"-moz-conic-gradient":Qr,"repeating-conic-gradient":$r,"-webkit-repeating-conic-gradient":$r,"-moz-repeating-conic-gradient":$r,"image-set":ti,"-webkit-image-set":ti},di={name:`background-image`,initialValue:`none`,type:1,prefix:!1,skipCache:!0,parse:(e,t)=>{if(t.length===0)return[];let n=t[0];return n&&n.type===20&&n.value===`none`?[]:t.filter(e=>O(e)&&li(e)).map(t=>ci.parse(e,t))}},fi={name:`background-origin`,initialValue:`border-box`,prefix:!1,type:1,parse:(e,t)=>t.map(e=>{if(D(e))switch(e.value){case`padding-box`:return 1;case`content-box`:return 2}return 0})},pi={name:`background-position`,initialValue:`0% 0%`,type:1,prefix:!1,parse:(e,t)=>k(t).map(e=>e.map(ze).filter(e=>e!==null)).map(Ve)},mi={name:`background-repeat`,initialValue:`repeat`,prefix:!1,type:1,parse:(e,t)=>k(t).map(e=>e.filter(D).map(e=>e.value).join(` `)).map(hi)},hi=e=>{switch(e){case`no-repeat`:return 1;case`repeat-x`:case`repeat no-repeat`:return 2;case`repeat-y`:case`no-repeat repeat`:return 3;default:return 0}},gi={name:`background-size`,initialValue:`0`,prefix:!1,type:1,parse:(e,t)=>k(t).map(e=>e.map(e=>_i(e)?e:ze(e)).filter(e=>e!==null))},_i=e=>D(e)||M(e),vi=e=>({name:`border-${e}-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`}),yi=vi(`top`),bi=vi(`right`),xi=vi(`bottom`),Si=vi(`left`),Ci=e=>({name:`border-${e}-radius`,initialValue:`0 0`,prefix:!1,type:1,parse:(e,t)=>Ve(t.filter(M))}),wi=Ci(`top-left`),Ti=Ci(`top-right`),Ei=Ci(`bottom-right`),Di=Ci(`bottom-left`),Oi=e=>({name:`border-${e}-style`,initialValue:`solid`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`none`:return 0;case`dashed`:return 2;case`dotted`:return 3;case`double`:return 4}return 1}}),ki=Oi(`top`),Ai=Oi(`right`),ji=Oi(`bottom`),Mi=Oi(`left`),Ni=e=>({name:`border-${e}-width`,initialValue:`0`,type:0,prefix:!1,parse:(e,t)=>T(t)?t.number:0}),Pi=Ni(`top`),Fi=Ni(`right`),Ii=Ni(`bottom`),Li=Ni(`left`),Ri={type:0},zi=e=>{let[t]=e;return t?D(t)?t.value===`farthest-side`?`farthest-side`:`closest-side`:M(t)?t:`closest-side`:`closest-side`},Bi=e=>{let t=null,n=null;for(let r of e)if(D(r))switch(r.value){case`left`:t=N;break;case`right`:t=F;break;case`top`:n=N;break;case`bottom`:n=F;break;case`center`:t===null?t=P:n===null&&(n=P)}else M(r)&&(t===null?t=r:n===null&&(n=r));return{cx:t??P,cy:n??P}},Vi=e=>{let t=[];for(let n of e)if(n.type!==31){if(D(n)&&n.value===`round`)break;M(n)&&t.push(n)}let n=t[0]??N,r=t[1]??n;return{type:1,top:n,right:r,bottom:t[2]??n,left:t[3]??r}},Hi=e=>{let t=e.filter(Te),n=t.findIndex(e=>we(e,`at`)),r=n===-1?t:t.slice(0,n),i=n===-1?[]:t.slice(n+1);return{type:2,radius:zi(r),...Bi(i)}},Ui=e=>{let t=e.filter(Te),n=t.findIndex(e=>we(e,`at`)),r=n===-1?t:t.slice(0,n),i=n===-1?[]:t.slice(n+1);return{type:3,rx:zi(r.slice(0,1)),ry:zi(r.slice(1,2)),...Bi(i)}},Wi=e=>{let t=k(e),n=[];for(let e of t){if(e.length===1&&e[0]&&D(e[0]))continue;let t=e.filter(M);t.length>=2&&n.push([c(t,0),c(t,1)])}return{type:4,points:n}},Gi=e=>{let t=e.find(e=>e.type===0);return t?{type:5,d:t.value}:Ri},Ki=e=>{let t=[];for(let n of e)if(n.type!==31){if(D(n)&&n.value===`round`)break;M(n)&&t.push(n)}return t.length<4?Ri:{type:6,x:c(t,0),y:c(t,1),width:c(t,2),height:c(t,3)}},qi=e=>{let t=[];for(let n of e)if(n.type!==31){if(D(n)){if(n.value===`round`)break;if(n.value===`auto`){t.push(`auto`);continue}return Ri}M(n)&&t.push(n)}if(t.length!==4)return Ri;let n=(e,t)=>e===`auto`?t===`top`||t===`left`?N:F:e;return{type:1,top:n(c(t,0),`top`),right:n(c(t,1),`right`),bottom:n(c(t,2),`bottom`),left:n(c(t,3),`left`)}},Ji={name:`clip-path`,initialValue:`none`,prefix:!1,type:0,parse:(e,t)=>{if(D(t)&&t.value===`none`)return Ri;if(t.type===18)switch(t.name){case`inset`:return Vi(t.values);case`circle`:return Hi(t.values);case`ellipse`:return Ui(t.values);case`polygon`:return Wi(t.values);case`path`:return Gi(t.values);case`xywh`:return Ki(t.values);case`rect`:return qi(t.values)}return Ri}},Yi={name:`color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},Xi={name:`direction`,initialValue:`ltr`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`rtl`:return 1;default:return 0}}},Zi={name:`font-family`,initialValue:``,prefix:!1,type:1,parse:(e,t)=>{let n=[],r=[],i=[],a=!1;return t.forEach(e=>{switch(e.type){case 20:n.push(e.value);break;case 0:a=!0,n.push(e.value);break;case 17:n.push(e.number.toString());break;case 4:r.push(n.join(` `)),i.push(a),a=!1,n.length=0}}),n.length&&(r.push(n.join(` `)),i.push(a)),r.map((e,t)=>i[t]||e.indexOf(` `)!==-1?`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\a `).replace(/\r/g,`\\d `).replace(/\f/g,`\\c `)}'`:e)}},Qi={name:`font-size`,initialValue:`0`,prefix:!1,type:3,format:`length`},$i={name:`letter-spacing`,initialValue:`0`,prefix:!1,type:0,parse:(e,t)=>t.type===20&&t.value===`normal`?0:t.type===17||t.type===15?t.number:0},ea={name:`line-break`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`strict`:return`strict`;default:return`normal`}}},ta={name:`line-height`,initialValue:`normal`,prefix:!1,type:4},na=(e,t)=>D(e)&&e.value===`normal`?1.2*t:e.type===17?t*e.number:M(e)?I(e,t):t,ra={name:`list-style-image`,initialValue:`none`,type:0,prefix:!1,skipCache:!0,parse:(e,t)=>t.type===20&&t.value===`none`||!li(t)?null:ci.parse(e,t)},ia={name:`list-style-position`,initialValue:`outside`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`inside`:return 0;default:return 1}}},aa=e=>({name:`margin-${e}`,initialValue:`0`,prefix:!1,type:4}),oa=aa(`top`),sa=aa(`right`),ca=aa(`bottom`),la=aa(`left`),ua={name:`overflow-wrap`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`break-word`:return`break-word`;default:return`normal`}}},da=e=>({name:`padding-${e}`,initialValue:`0`,prefix:!1,type:3,format:`length-percentage`}),fa=da(`top`),pa=da(`right`),ma=da(`bottom`),ha=da(`left`),ga={name:`text-align`,initialValue:`left`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`right`:return 2;case`center`:case`justify`:return 1;default:return 0}}},_a={name:`position`,initialValue:`static`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`relative`:return 1;case`absolute`:return 2;case`fixed`:return 3;case`sticky`:return 4}return 0}},va={name:`text-shadow`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>t.length===1&&we(c(t,0),`none`)?[]:k(t).map(t=>{let n={color:0,offsetX:N,offsetY:N,blur:N},r=0;for(let i=0;i<t.length;i++){let a=t[i];a&&(Fe(a)?(r===0?n.offsetX=a:r===1?n.offsetY=a:n.blur=a,r++):n.color=V.parse(e,a))}return n})},ya={name:`text-transform`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`uppercase`:return 2;case`lowercase`:return 1;case`capitalize`:return 3}return 0}},ba={name:`transform`,initialValue:`none`,prefix:!0,type:0,parse:(e,t)=>{if(t.type===20&&t.value===`none`)return null;if(t.type===18){let n=xa[t.name];if(n===void 0)throw Error(`Attempting to parse an unsupported transform function "${t.name}"`);return n(e,t.values)}return null}},xa={matrix:(e,t)=>{let n=t.filter(e=>e.type===17).map(e=>e.number);return n.length===6?n:null},matrix3d:(e,t)=>{let n=t.filter(e=>e.type===17).map(e=>e.number);return n.length===16?[c(n,0),c(n,1),c(n,4),c(n,5),c(n,12),c(n,13)]:null},rotate:(e,t)=>{if(t.length!==1)return null;let n=c(t,0),r=0;if(n.type===17&&n.number===0)r=0;else if(n.type===15)r=Ge.parse(e,n);else return null;let i=Math.cos(r),a=Math.sin(r);return[i,a,-a,i,0,0]}},Sa={type:16,number:50,flags:4},Ca=[Sa,Sa],wa={name:`transform-origin`,initialValue:`50% 50%`,prefix:!0,type:1,parse:(e,t)=>{let n=t.filter(M);return n.length===2?[c(n,0),c(n,1)]:Ca}},Ta={name:`rotate`,initialValue:`none`,prefix:!1,type:0,parse:(e,t)=>t.type===20&&t.value===`none`?null:t.type===17&&t.number===0?0:t.type===15?Ge.parse(e,t)*180/Math.PI:null},Ea={name:`visibility`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`hidden`:return 1;case`collapse`:return 2;default:return 0}}},Da={name:`word-break`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`break-all`:return`break-all`;case`keep-all`:return`keep-all`;default:return`normal`}}},Oa={name:`white-space`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`pre`:return`pre`;case`nowrap`:return`nowrap`;case`pre-wrap`:return`pre-wrap`;case`pre-line`:return`pre-line`;default:return`normal`}}},ka=e=>e!==0,Aa=e=>e===3||e===4,ja={name:`writing-mode`,initialValue:`horizontal-tb`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`vertical-rl`:return 1;case`vertical-lr`:return 2;case`sideways-rl`:return 3;case`sideways-lr`:return 4;default:return 0}}},Ma={name:`z-index`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>{if(t.type===20)return{auto:!0,order:0};if(E(t))return{auto:!1,order:t.number};throw Error(`Invalid z-index number parsed`)}},Na={name:`time`,parse:(e,t)=>{if(t.type===15)switch(t.unit.toLowerCase()){case`s`:return 1e3*t.number;case`ms`:return t.number}throw Error(`Unsupported time type`)}},Pa={name:`opacity`,initialValue:`1`,type:0,prefix:!1,parse:(e,t)=>E(t)?t.number:1},Fa={name:`text-decoration-style`,initialValue:`solid`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`double`:return 1;case`dotted`:return 2;case`dashed`:return 3;case`wavy`:return 4;default:return 0}}},Ia={name:`text-decoration-thickness`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>{if(D(t))switch(t.value){case`auto`:return`auto`;case`from-font`:return`from-font`}return T(t)?t.number:`auto`}},La={name:`text-underline-offset`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>D(t)&&t.value===`auto`?`auto`:T(t)?t.number:`auto`},Ra={name:`font-weight`,initialValue:`normal`,type:0,prefix:!1,parse:(e,t)=>{if(E(t))return t.number;if(D(t))switch(t.value){case`bold`:return 700;default:return 400}return 400}},za={name:`font-variant`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>t.filter(D).map(e=>e.value)},Ba={name:`font-style`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`oblique`:return`oblique`;case`italic`:return`italic`;default:return`normal`}}},Va={name:`duration`,initialValue:`0s`,prefix:!1,type:1,parse:(e,t)=>t.filter(T).map(t=>Na.parse(e,t))},Ha={name:`box-shadow`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>t.length===1&&we(c(t,0),`none`)?[]:k(t).map(t=>{let n={color:255,offsetX:N,offsetY:N,blur:N,spread:N,inset:!1},r=0;for(let i=0;i<t.length;i++){let a=t[i];a&&(we(a,`inset`)?n.inset=!0:Fe(a)?(r===0?n.offsetX=a:r===1?n.offsetY=a:r===2?n.blur=a:n.spread=a,r++):n.color=V.parse(e,a))}return n})},Ua={name:`paint-order`,initialValue:`normal`,prefix:!1,type:1,parse:(e,t)=>{let n=[0,1,2],r=[];return t.filter(D).forEach(e=>{switch(e.value){case`stroke`:r.push(1);break;case`fill`:r.push(0);break;case`markers`:r.push(2)}}),n.forEach(e=>{r.indexOf(e)===-1&&r.push(e)}),r}},Wa={name:`-webkit-text-stroke-color`,initialValue:`currentcolor`,prefix:!1,type:3,format:`color`},Ga={name:`-webkit-text-stroke-width`,initialValue:`0`,type:0,prefix:!1,parse:(e,t)=>T(t)?t.number:0},Ka={name:`-webkit-line-clamp`,initialValue:`none`,prefix:!0,type:0,parse:(e,t)=>t.type===20&&t.value===`none`?0:t.type===17?Math.max(0,Math.floor(t.number)):0},qa={name:`object-fit`,initialValue:`fill`,prefix:!1,type:1,parse:(e,t)=>t.filter(D).reduce((e,t)=>e|Ja(t.value),0)},Ja=e=>{switch(e){case`contain`:return 2;case`cover`:return 4;case`none`:return 8;case`scale-down`:return 16}return 0},Ya={name:`text-overflow`,initialValue:`clip`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`ellipsis`:return 1;default:return 0}}},Xa={name:`image-rendering`,initialValue:`auto`,prefix:!1,type:2,parse:(e,t)=>{switch(t.toLowerCase()){case`crisp-edges`:case`-webkit-crisp-edges`:case`-moz-crisp-edges`:return 1;case`pixelated`:case`-webkit-optimize-contrast`:return 2;case`smooth`:case`high-quality`:return 3;default:return 0}}},K={NORMAL:`normal`,MULTIPLY:`multiply`,SCREEN:`screen`,OVERLAY:`overlay`,DARKEN:`darken`,LIGHTEN:`lighten`,COLOR_DODGE:`color-dodge`,COLOR_BURN:`color-burn`,HARD_LIGHT:`hard-light`,SOFT_LIGHT:`soft-light`,DIFFERENCE:`difference`,EXCLUSION:`exclusion`,HUE:`hue`,SATURATION:`saturation`,COLOR:`color`,LUMINOSITY:`luminosity`},Za=new Set(Object.values(K)),Qa={name:`mix-blend-mode`,initialValue:`normal`,type:2,prefix:!1,parse:(e,t)=>Za.has(t)?t:K.NORMAL},$a={name:`filter`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>{if(t.length===1){let e=c(t,0);if(e.type===20&&e.value===`none`)return null}let n=[];for(let e of t)if(e.type===22)n.push(`url("${e.value}")`);else if(e.type===18){let t=e,r=eo(t.values);switch(t.name){case`blur`:n.push(`blur(${r})`);break;case`brightness`:case`contrast`:case`invert`:case`opacity`:case`saturate`:case`sepia`:n.push(`${t.name}(${r})`);break;case`grayscale`:n.push(`grayscale(${r})`);break;case`hue-rotate`:n.push(`hue-rotate(${r})`);break;case`drop-shadow`:n.push(`drop-shadow(${r})`);break;default:n.push(`${t.name}(${r})`)}}return n.length>0?n.join(` `):null}},eo=e=>{let t=[];for(let n of e)n.type===31?t.push(` `):n.type===18?t.push(`${n.name}(${eo(n.values)})`):n.type===4?t.push(`,`):n.type===6?t.push(n.value):n.type===15?t.push(`${n.number}${n.unit}`):n.type===17?t.push(`${n.number}`):n.type===16?t.push(`${n.number}%`):n.type===20?t.push(n.value):n.type===5&&t.push(`#${n.value}`);return t.join(``).trim()},to={name:`font-variant-ligatures`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`none`:return 1;case`common-ligatures`:return 2;case`no-common-ligatures`:return 3;case`discretionary-ligatures`:return 4;case`no-discretionary-ligatures`:return 5;case`historical-ligatures`:return 6;case`no-historical-ligatures`:return 7;case`contextual`:return 8;case`no-contextual`:return 9;default:return 0}}},no={name:`zoom`,initialValue:`1`,type:0,prefix:!1,parse:(e,t)=>t.type===16?Math.max(0,t.number/100):t.type===17?Math.max(0,t.number):1},ro={name:`object-position`,initialValue:`50% 50%`,prefix:!1,type:1,parse:(e,t)=>{let n=[],r=0;for(;r<t.length&&n.length<2;){let e=t[r];if(!e)break;if(D(e))switch(e.value){case`left`:case`top`:n.push(N);break;case`center`:n.push(P);break;case`right`:case`bottom`:n.push(F)}else M(e)&&n.push(e);r++}for(;n.length<2;)n.push(P);return[c(n,0),c(n,1)]}},io=new Set(Object.values({NORMAL:`normal`,MULTIPLY:`multiply`,SCREEN:`screen`,OVERLAY:`overlay`,DARKEN:`darken`,LIGHTEN:`lighten`,COLOR_DODGE:`color-dodge`,COLOR_BURN:`color-burn`,HARD_LIGHT:`hard-light`,SOFT_LIGHT:`soft-light`,DIFFERENCE:`difference`,EXCLUSION:`exclusion`,HUE:`hue`,SATURATION:`saturation`,COLOR:`color`,LUMINOSITY:`luminosity`})),ao={name:`background-blend-mode`,initialValue:`normal`,prefix:!1,type:1,parse:(e,t)=>{let n=[],r=t.filter(O);for(let e of r)D(e)&&io.has(e.value)&&n.push(e.value);return n.length>0?n:[`normal`]}},oo={name:`border-image-source`,initialValue:`none`,prefix:!1,type:1,skipCache:!0,parse:(e,t)=>{if(t.length===0)return null;let n=t.filter(e=>O(e)&&li(e));return n.length===0?null:ci.parse(e,c(n,0))}},so=e=>{let t=[...e];if(t.length===1){let e=c(t,0);t.push(e,e,e)}else t.length===2?t.push(c(t,0),c(t,1)):t.length===3&&t.push(c(t,1));return[c(t,0),c(t,1),c(t,2),c(t,3)]},co={name:`border-image-slice`,initialValue:`100%`,prefix:!1,type:1,parse:(e,t)=>{let n=t.filter(Te),r=[],i=!1,a=`percent`;for(let e of n)D(e)&&e.value===`fill`?i=!0:e.type===17?(r.push(e.number),a=`number`):e.type===16&&(r.push(e.number),a=`percent`);let[o,s,c,l]=so(r.length>0?r:[100]);return{top:o,right:s,bottom:c,left:l,fill:i,unit:a}}},lo=e=>{switch(e){case`repeat`:return 1;case`round`:return 2;case`space`:return 3;default:return 0}},uo={name:`border-image-repeat`,initialValue:`stretch`,prefix:!1,type:1,parse:(e,t)=>{let n=t.filter(Te),r=[];for(let e of n)D(e)&&r.push(lo(e.value));let i=r[0]??0;return{horizontal:i,vertical:r[1]??i}}},fo={name:`box-decoration-break`,initialValue:`slice`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`clone`:return 1;default:return 0}}},po={name:`accent-color`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>D(t)&&t.value===`auto`?null:V.parse(e,t)},mo={name:`-webkit-text-fill-color`,initialValue:`currentcolor`,prefix:!0,type:0,parse:(e,t)=>D(t)&&t.value===`currentcolor`?null:V.parse(e,t)},ho={name:`isolation`,initialValue:`auto`,prefix:!1,type:2,parse:(e,t)=>+(t===`isolate`)},go={name:`outline-style`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`solid`:return 2;case`dashed`:return 3;case`dotted`:return 4;case`double`:return 5;case`auto`:return 1;default:return 0}}},_o={name:`outline-color`,initialValue:`currentcolor`,prefix:!1,type:0,parse:(e,t)=>D(t)&&(t.value===`currentcolor`||t.value===`invert`)?null:V.parse(e,t)},vo={name:`outline-width`,initialValue:`medium`,prefix:!1,type:0,parse:Pi.parse},yo={name:`outline-offset`,initialValue:`0px`,prefix:!1,type:0,parse:(e,t)=>T(t)||E(t)?t.number:0},bo={name:`backdrop-filter`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>$a.parse(e,t)},xo={name:`mask-image`,initialValue:`none`,prefix:!1,type:1,skipCache:!0,parse:di.parse},So={name:`mask-position`,initialValue:`0%`,prefix:!1,type:1,parse:pi.parse},Co={name:`mask-repeat`,initialValue:`repeat`,prefix:!1,type:1,parse:mi.parse},wo={name:`mask-size`,initialValue:`auto`,prefix:!1,type:1,parse:gi.parse},To=[`dot`,`circle`,`double-circle`,`triangle`,`sesame`],Eo={name:`text-emphasis-style`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>{let n=t.filter(Te);if(n.length===0)return null;let r=c(n,0);if(r.type===0)return r.value;if(D(r)){if(r.value===`none`)return null;if(r.value!==`filled`&&r.value!==`open`&&To.indexOf(r.value)===-1)return r.value}let i=!0,a=`circle`;for(let e of n)D(e)&&(e.value===`filled`?i=!0:e.value===`open`?i=!1:To.indexOf(e.value)!==-1&&(a=e.value));return{fill:i,shape:a}}},Do={name:`text-emphasis-color`,initialValue:`currentcolor`,prefix:!1,type:0,parse:(e,t)=>D(t)&&t.value===`currentcolor`?null:V.parse(e,t)},Oo={name:`text-emphasis-position`,initialValue:`over right`,prefix:!1,type:1,parse:(e,t)=>{let n=!0,r=!0;for(let e of t)if(D(e))switch(e.value){case`over`:n=!0;break;case`under`:n=!1;break;case`right`:r=!0;break;case`left`:r=!1}return{over:n,right:r}}},ko=e=>{let t=[...e];if(t.length===1){let e=c(t,0);t.push(e,e,e)}else t.length===2?t.push(c(t,0),c(t,1)):t.length===3&&t.push(c(t,1));return[c(t,0),c(t,1),c(t,2),c(t,3)]},Ao=e=>D(e)&&e.value===`auto`?{kind:`auto`}:e.type===17?{kind:`number`,value:e.number}:e.type===15&&e.unit===`px`?{kind:`length`,value:e.number}:e.type===16?{kind:`percentage`,value:e.number}:null,jo=e=>{let t=[];for(let n of e){if(n.type===31)continue;let e=Ao(n);if(!e)return null;t.push(e)}return t.length===0||t.length>4?null:ko(t)},Mo={name:`border-image-width`,initialValue:`auto`,prefix:!1,type:1,parse:(e,t)=>{let n=jo(t),r={kind:`auto`};return n?{top:n[0],right:n[1],bottom:n[2],left:n[3]}:{top:r,right:r,bottom:r,left:r}}},No={name:`border-image-outset`,initialValue:`0px`,prefix:!1,type:1,parse:(e,t)=>{let n=jo(t),r={kind:`length`,value:0};return n?{top:n[0],right:n[1],bottom:n[2],left:n[3]}:{top:r,right:r,bottom:r,left:r}}},Po={name:`-webkit-box-reflect`,initialValue:`none`,prefix:!0,type:1,skipCache:!0,parse:(e,t)=>{let n=null,r=0,i=null;for(let a of t)if(a.type!==31){if(n===null&&D(a)){if(a.value===`below`||a.value===`above`||a.value===`left`||a.value===`right`){n=a.value;continue}if(a.value===`none`)return null}r===0&&T(a)&&a.unit===`px`?r=a.number:i===null&&li(a)&&(i=ci.parse(e,a))}return n===null?null:{direction:n,offset:r,mask:i}}},Fo={name:`translate`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>{let n=[];for(let e of t)M(e)&&n.push(e);return n.length===0?null:[c(n,0),n.length>1?c(n,1):N]}},Io={name:`scale`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>{let n=[];for(let e of t)E(e)&&n.push(e.number);return n.length===0?null:[c(n,0),n.length>1?c(n,1):c(n,0)]}},Lo=6e4,Ro=[[`animationDuration`,Va,`animationDuration`],[`backgroundClip`,Ar,`backgroundClip`],[`backgroundColor`,jr,`backgroundColor`],[`backgroundImage`,di,`backgroundImage`],[`backgroundOrigin`,fi,`backgroundOrigin`],[`backgroundPosition`,pi,`backgroundPosition`],[`backgroundRepeat`,mi,`backgroundRepeat`],[`backgroundSize`,gi,`backgroundSize`],[`borderTopColor`,yi,`borderTopColor`],[`borderRightColor`,bi,`borderRightColor`],[`borderBottomColor`,xi,`borderBottomColor`],[`borderLeftColor`,Si,`borderLeftColor`],[`borderTopLeftRadius`,wi,`borderTopLeftRadius`],[`borderTopRightRadius`,Ti,`borderTopRightRadius`],[`borderBottomRightRadius`,Ei,`borderBottomRightRadius`],[`borderBottomLeftRadius`,Di,`borderBottomLeftRadius`],[`borderTopStyle`,ki,`borderTopStyle`],[`borderRightStyle`,Ai,`borderRightStyle`],[`borderBottomStyle`,ji,`borderBottomStyle`],[`borderLeftStyle`,Mi,`borderLeftStyle`],[`borderTopWidth`,Pi,`borderTopWidth`],[`borderRightWidth`,Fi,`borderRightWidth`],[`borderBottomWidth`,Ii,`borderBottomWidth`],[`borderLeftWidth`,Li,`borderLeftWidth`],[`boxShadow`,Ha,`boxShadow`],[`clipPath`,Ji,`clipPath`],[`color`,Yi,`color`],[`direction`,Xi,`direction`],[`display`,vr,`display`],[`fontFamily`,Zi,`fontFamily`],[`fontSize`,Qi,`fontSize`],[`fontStyle`,Ba,`fontStyle`],[`fontVariant`,za,`fontVariant`],[`fontWeight`,Ra,`fontWeight`],[`letterSpacing`,$i,`letterSpacing`],[`lineBreak`,ea,`lineBreak`],[`lineHeight`,ta,`lineHeight`],[`listStyleImage`,ra,`listStyleImage`],[`listStylePosition`,ia,`listStylePosition`],[`listStyleType`,rr,`listStyleType`],[`marginTop`,oa,`marginTop`],[`marginRight`,sa,`marginRight`],[`marginBottom`,ca,`marginBottom`],[`marginLeft`,la,`marginLeft`],[`opacity`,Pa,`opacity`],[`overflowWrap`,ua,`overflowWrap`],[`paddingTop`,fa,`paddingTop`],[`paddingRight`,pa,`paddingRight`],[`paddingBottom`,ma,`paddingBottom`],[`paddingLeft`,ha,`paddingLeft`],[`paintOrder`,Ua,`paintOrder`],[`position`,_a,`position`],[`textAlign`,ga,`textAlign`],[`textDecorationStyle`,Fa,`textDecorationStyle`],[`textDecorationThickness`,Ia,`textDecorationThickness`],[`textUnderlineOffset`,La,`textUnderlineOffset`],[`textShadow`,va,`textShadow`],[`textTransform`,ya,`textTransform`],[`textOverflow`,Ya,`textOverflow`],[`transform`,ba,`transform`],[`transformOrigin`,wa,`transformOrigin`],[`rotate`,Ta,`rotate`],[`translate`,Fo,`translate`],[`scale`,Io,`scale`],[`visibility`,Ea,`visibility`],[`webkitTextStrokeColor`,Wa,`webkitTextStrokeColor`],[`webkitTextStrokeWidth`,Ga,`webkitTextStrokeWidth`],[`webkitLineClamp`,Ka,`webkitLineClamp`],[`wordBreak`,Da,`wordBreak`],[`whiteSpace`,Oa,`whiteSpace`],[`writingMode`,ja,`writingMode`],[`zIndex`,Ma,`zIndex`],[`objectFit`,qa,`objectFit`],[`imageRendering`,Xa,`imageRendering`],[`mixBlendMode`,Qa,`mixBlendMode`],[`filter`,$a,`filter`],[`fontVariantLigatures`,to,`fontVariantLigatures`],[`zoom`,no,`zoom`],[`objectPosition`,ro,`objectPosition`],[`backgroundBlendMode`,ao,`backgroundBlendMode`],[`borderImageSource`,oo,`borderImageSource`],[`borderImageSlice`,co,`borderImageSlice`],[`borderImageRepeat`,uo,`borderImageRepeat`],[`boxDecorationBreak`,fo,`boxDecorationBreak`],[`accentColor`,po,`accentColor`],[`webkitTextFillColor`,mo,`webkitTextFillColor`],[`isolation`,ho,`isolation`],[`outlineColor`,_o,`outlineColor`],[`outlineStyle`,go,`outlineStyle`],[`outlineWidth`,vo,`outlineWidth`],[`outlineOffset`,yo,`outlineOffset`],[`backdropFilter`,bo,`backdropFilter`],[`maskImage`,xo,`maskImage`],[`maskPosition`,So,`maskPosition`],[`maskRepeat`,Co,`maskRepeat`],[`maskSize`,wo,`maskSize`],[`textEmphasisStyle`,Eo,`textEmphasisStyle`],[`textEmphasisColor`,Do,`textEmphasisColor`],[`textEmphasisPosition`,Oo,`textEmphasisPosition`],[`borderImageWidth`,Mo,`borderImageWidth`],[`borderImageOutset`,No,`borderImageOutset`],[`webkitBoxReflect`,Po,`webkitBoxReflect`]],zo=/* @__PURE__ */ new Map,Bo=(e,t,n)=>{let r=n==null?t.initialValue:n.toString();r.trim()===``&&(r=t.initialValue);let i=zo.get(t);if(i){let e=i.get(r);if(e!==void 0)return i.delete(r),i.set(r,e),e}let a=xe.get();a.write(r);let o=new Se(a.read());xe.release(a);let s=(()=>{switch(t.type){case 2:{let n=o.parseComponentValue();return t.parse(e,D(n)?n.value:t.initialValue)}case 0:return t.parse(e,o.parseComponentValue());case 1:return t.parse(e,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(t.format){case`angle`:return Ge.parse(e,o.parseComponentValue());case`color`:return V.parse(e,o.parseComponentValue());case`image`:return ci.parse(e,o.parseComponentValue());case`length`:{let e=o.parseComponentValue();return Fe(e)?e:N}case`length-percentage`:{let e=o.parseComponentValue();return M(e)?e:N}case`time`:return Na.parse(e,o.parseComponentValue())}}})();if(i||(i=/* @__PURE__ */ new Map,zo.set(t,i)),!(t.skipCache||t.type===3&&t.format===`image`)){if(i.size>=200){let e=i.keys().next().value;e!==void 0&&i.delete(e)}i.set(r,s)}return s};var Vo=class{styles;constructor(e){this.styles=e}get topColor(){return this.styles.borderTopColor}get rightColor(){return this.styles.borderRightColor}get bottomColor(){return this.styles.borderBottomColor}get leftColor(){return this.styles.borderLeftColor}get topStyle(){return this.styles.borderTopStyle}get rightStyle(){return this.styles.borderRightStyle}get bottomStyle(){return this.styles.borderBottomStyle}get leftStyle(){return this.styles.borderLeftStyle}get topWidth(){return this.styles.borderTopWidth}get rightWidth(){return this.styles.borderRightWidth}get bottomWidth(){return this.styles.borderBottomWidth}get leftWidth(){return this.styles.borderLeftWidth}get topLeftRadius(){return this.styles.borderTopLeftRadius}get topRightRadius(){return this.styles.borderTopRightRadius}get bottomRightRadius(){return this.styles.borderBottomRightRadius}get bottomLeftRadius(){return this.styles.borderBottomLeftRadius}get imageSource(){return this.styles.borderImageSource}get imageSlice(){return this.styles.borderImageSlice}get imageRepeat(){return this.styles.borderImageRepeat}get boxShadow(){return this.styles.boxShadow}},Ho=class{styles;constructor(e){this.styles=e}get color(){return this.styles.backgroundColor}get image(){return this.styles.backgroundImage}get clip(){return this.styles.backgroundClip}get origin(){return this.styles.backgroundOrigin}get position(){return this.styles.backgroundPosition}get repeat(){return this.styles.backgroundRepeat}get size(){return this.styles.backgroundSize}get blendMode(){return this.styles.backgroundBlendMode}},Uo=class{styles;constructor(e){this.styles=e}get family(){return this.styles.fontFamily}get size(){return this.styles.fontSize}get style(){return this.styles.fontStyle}get variant(){return this.styles.fontVariant}get weight(){return this.styles.fontWeight}get ligatures(){return this.styles.fontVariantLigatures}get color(){return this.styles.color}get letterSpacing(){return this.styles.letterSpacing}get lineHeight(){return this.styles.lineHeight}get textAlign(){return this.styles.textAlign}get textTransform(){return this.styles.textTransform}get textOverflow(){return this.styles.textOverflow}get textShadow(){return this.styles.textShadow}get textDecorationColor(){return this.styles.textDecorationColor}get textDecorationLine(){return this.styles.textDecorationLine}get textDecorationStyle(){return this.styles.textDecorationStyle}get textDecorationThickness(){return this.styles.textDecorationThickness}get textUnderlineOffset(){return this.styles.textUnderlineOffset}get wordBreak(){return this.styles.wordBreak}get lineBreak(){return this.styles.lineBreak}get overflowWrap(){return this.styles.overflowWrap}get writingMode(){return this.styles.writingMode}get direction(){return this.styles.direction}get webkitTextStrokeColor(){return this.styles.webkitTextStrokeColor}get webkitTextStrokeWidth(){return this.styles.webkitTextStrokeWidth}get webkitLineClamp(){return this.styles.webkitLineClamp}get paintOrder(){return this.styles.paintOrder}},Wo=class{styles;constructor(e){this.styles=e}get display(){return this.styles.display}get position(){return this.styles.position}get float(){return this.styles.float}get zIndex(){return this.styles.zIndex}get marginTop(){return this.styles.marginTop}get marginRight(){return this.styles.marginRight}get marginBottom(){return this.styles.marginBottom}get marginLeft(){return this.styles.marginLeft}get paddingTop(){return this.styles.paddingTop}get paddingRight(){return this.styles.paddingRight}get paddingBottom(){return this.styles.paddingBottom}get paddingLeft(){return this.styles.paddingLeft}get overflowX(){return this.styles.overflowX}get overflowY(){return this.styles.overflowY}get opacity(){return this.styles.opacity}get visibility(){return this.styles.visibility}get transform(){return this.styles.transform}get transformOrigin(){return this.styles.transformOrigin}get rotate(){return this.styles.rotate}get zoom(){return this.styles.zoom}get clipPath(){return this.styles.clipPath}get mixBlendMode(){return this.styles.mixBlendMode}get filter(){return this.styles.filter}get imageRendering(){return this.styles.imageRendering}get objectFit(){return this.styles.objectFit}get objectPosition(){return this.styles.objectPosition}get boxDecorationBreak(){return this.styles.boxDecorationBreak}get listStyleImage(){return this.styles.listStyleImage}get listStylePosition(){return this.styles.listStylePosition}get listStyleType(){return this.styles.listStyleType}get animationDuration(){return this.styles.animationDuration}isVisible(){return this.styles.isVisible()}isTransparent(){return this.styles.isTransparent()}isTransformed(){return this.styles.isTransformed()}isPositioned(){return this.styles.isPositioned()}isPositionedWithZIndex(){return this.styles.isPositionedWithZIndex()}isFloating(){return this.styles.isFloating()}isInlineLevel(){return this.styles.isInlineLevel()}},Go=class{animationDuration;backgroundClip;backgroundColor;backgroundImage;backgroundOrigin;backgroundPosition;backgroundRepeat;backgroundSize;borderTopColor;borderRightColor;borderBottomColor;borderLeftColor;borderTopLeftRadius;borderTopRightRadius;borderBottomRightRadius;borderBottomLeftRadius;borderTopStyle;borderRightStyle;borderBottomStyle;borderLeftStyle;borderTopWidth;borderRightWidth;borderBottomWidth;borderLeftWidth;boxShadow;clipPath;color;direction;display;float;fontFamily;fontSize;fontStyle;fontVariant;fontWeight;letterSpacing;lineBreak;lineHeight;listStyleImage;listStylePosition;listStyleType;marginTop;marginRight;marginBottom;marginLeft;opacity;overflowX;overflowY;overflowWrap;paddingTop;paddingRight;paddingBottom;paddingLeft;paintOrder;position;textAlign;textDecorationColor;textDecorationLine;textDecorationStyle;textDecorationThickness;textUnderlineOffset;textShadow;textTransform;textOverflow;transform;transformOrigin;rotate;translate;scale;visibility;webkitTextStrokeColor;webkitTextStrokeWidth;webkitLineClamp;wordBreak;whiteSpace;writingMode;zIndex;objectFit;imageRendering;mixBlendMode;filter;fontVariantLigatures;zoom;objectPosition;backgroundBlendMode;borderImageSource;borderImageSlice;borderImageRepeat;boxDecorationBreak;accentColor;webkitTextFillColor;isolation;outlineColor;outlineStyle;outlineWidth;outlineOffset;backdropFilter;maskImage;maskPosition;maskRepeat;maskSize;textEmphasisStyle;textEmphasisColor;textEmphasisPosition;borderImageWidth;borderImageOutset;webkitBoxReflect;_border;_background;_font;_layout;get border(){return this._border??=new Vo(this)}get background(){return this._background??=new Ho(this)}get font(){return this._font??=new Uo(this)}get layout(){return this._layout??=new Wo(this)}constructor(e,t){if(t.display===`none`){this.display=0;for(let[t,n]of Ro)t!==`display`&&(this[t]=Bo(e,n,void 0));Object.assign(this,Ko(e,null))}else{for(let[n,r,i]of Ro)this[n]=Bo(e,r,t[i]);Object.assign(this,Ko(e,t))}}isVisible(){return this.display>0&&this.opacity>0&&this.visibility===0}isTransparent(){return R(this.backgroundColor)}isTransformed(){return this.transform!==null||this.rotate!==null||this.translate!==null||this.scale!==null}isPositioned(){return this.position!==0}isPositionedWithZIndex(){return this.isPositioned()&&!this.zIndex.auto}isFloating(){return this.float!==0}isInlineLevel(){return H(this.display,4)||H(this.display,33554432)||H(this.display,268435456)||H(this.display,536870912)||H(this.display,67108864)||H(this.display,134217728)}};let Ko=(e,t)=>{let n=(e,n)=>{if(t)return t[e]??n},r=Bo(e,xr,n(`overflow`));return{float:Bo(e,br,n(`cssFloat`)),textDecorationColor:Bo(e,Sr,n(`textDecorationColor`,n(`color`))),textDecorationLine:Bo(e,Cr,n(`textDecorationLine`,n(`textDecoration`))),overflowX:r[0],overflowY:r[+(r.length>1)]}};var qo=class{content;quotes;constructor(e,t){this.content=Bo(e,wr,t.content),this.quotes=Bo(e,Tr,t.quotes)}},Jo=class{counterIncrement;counterReset;constructor(e,t){this.counterIncrement=Bo(e,Or,t.counterIncrement),this.counterReset=Bo(e,kr,t.counterReset)}};let Yo=e=>{if(typeof e.getAttribute!=`function`)return 0;switch(e.getAttribute(`data-html2canvas-debug`)){case`all`:return 1;case`clone`:return 2;case`parse`:return 3;case`render`:return 4;default:return 0}},Xo=(e,t)=>{let n=Yo(e);return n===1||t===n},Zo=e=>{let t=``;for(let n of e)try{let e=n.cssRules;for(let n=0;n<e.length;n++){let r=e[n];r&&typeof r.cssText==`string`&&(t+=r.cssText)}}catch{}return t},Qo=(e,t,n)=>{let r=Zo(t);if(!r)return null;let i=e.createElement(`style`);return i.textContent=r,n&&(i.nonce=n),i};var $o=class{cloneNodeFn;options;context;constructor(e,t,n){this.cloneNodeFn=e,this.options=t,this.context=n}appendChildNode(e,t,n){this.safeAppendClonedChild(e,t,n)}cloneChildNodes(e,t,n){e.shadowRoot&&t.shadowRoot?(this.cloneShadowDOMChildren(e.shadowRoot,t.shadowRoot,n),this.cloneLightDOMChildren(e,t,n)):e.shadowRoot&&!t.shadowRoot?this.cloneShadowDOMAsLightDOM(e.shadowRoot,t,n):this.cloneLightDOMChildren(e,t,n)}shouldCloneChild(e){return!Fn(e)||!Jn(e)&&!e.hasAttribute(`data-html2canvas-ignore`)&&(typeof this.options.ignoreElements!=`function`||!this.options.ignoreElements(e))}shouldCloneStyleElement(e){return!this.options.copyStyles||!Fn(e)||!qn(e)}safeAppendClonedChild(e,t,n){this.shouldCloneChild(t)&&this.shouldCloneStyleElement(t)&&e.appendChild(this.cloneNodeFn(t,n))}cloneAssignedNodes(e,t,n){e.forEach(e=>{this.safeAppendClonedChild(t,e,n)})}cloneSlotFallbackContent(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)this.safeAppendClonedChild(t,r,n)}cloneSlotElement(e,t,n){if(!Zn(e))return;let r=e;if(typeof r.assignedNodes!=`function`){this.context.logger.warn(`HTMLSlotElement.assignedNodes is not available`,e),this.cloneSlotFallbackContent(e,t,n);return}let i=r.assignedNodes();!i||!Array.isArray(i)?(this.context.logger.warn(`assignedNodes() did not return a valid array`,e),this.cloneSlotFallbackContent(e,t,n)):i.length>0?this.cloneAssignedNodes(i,t,n):this.cloneSlotFallbackContent(e,t,n)}cloneShadowDOMChildren(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)Fn(r)&&Zn(r)?this.cloneSlotElement(r,t,n):this.safeAppendClonedChild(t,r,n);this.appendAdoptedStyleSheets(e,t,n)}cloneLightDOMChildren(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)this.appendChildNode(t,r,n)}cloneSlotElementAsLightDOM(e,t,n){if(!Zn(e))return;let r=e;if(typeof r.assignedNodes!=`function`){for(let r=e.firstChild;r;r=r.nextSibling)this.appendChildNode(t,r,n);return}let i=r.assignedNodes();if(i&&Array.isArray(i)&&i.length>0)i.forEach(e=>this.appendChildNode(t,e,n));else for(let r=e.firstChild;r;r=r.nextSibling)this.appendChildNode(t,r,n)}cloneShadowDOMAsLightDOM(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)Fn(r)&&Zn(r)?this.cloneSlotElementAsLightDOM(r,t,n):this.appendChildNode(t,r,n);this.appendAdoptedStyleSheets(e,t,n)}appendAdoptedStyleSheets(e,t,n){if(n)return;let r=e.adoptedStyleSheets;if(!r||r.length===0)return;let i=`host`in t?t.host.ownerDocument:t.ownerDocument;if(!i)return;let a=Qo(i,r,this.options.cspNonce);a&&t.appendChild(a)}};let es=[`all`,`d`,`content`],ts=(e,t)=>{let n=[];for(let t=e.length-1;t>=0;t--){let r=e.item(t);if(es.indexOf(r)===-1&&!r.startsWith(`--`)){let t=e.getPropertyValue(r);if(t){let i=e.getPropertyPriority(r);n.push(i?`${r}:${t} !${i}`:`${r}:${t}`)}}}return n.length>0&&(t.style.cssText=n.join(`;`)+`;`),t},ns=`___html2canvas___pseudoelement_before`,rs=`___html2canvas___pseudoelement_after`,is=`{
|
|
6
|
+
(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.html2canvas={}))})(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var t=class e{window;cspNonce;cache;constructor(e={}){let t=e.window||(typeof window<`u`?window:void 0);if(!t)throw Error(`Window object is required but not available`);this.window=t,this.cspNonce=e.cspNonce,this.cache=e.cache}static fromElement(t,n={}){let r=t.ownerDocument;if(!r)throw Error(`Element is not attached to a document`);let i=r.defaultView;if(!i)throw Error(`Document is not attached to a window`);return new e({window:i,...n})}clone(t={}){return new e({window:t.window||this.window,cspNonce:t.cspNonce??this.cspNonce,cache:t.cache??this.cache})}},n=class{config;constructor(e={}){this.config={maxImageTimeout:3e5,allowDataUrls:!0,...e}}validateUrl(e,t=`general`){if(!e||typeof e!=`string`)return{valid:!1,error:`URL must be a non-empty string`};if(e.startsWith(`data:`))return this.config.allowDataUrls?{valid:!0,sanitized:e}:{valid:!1,error:`Data URLs are not allowed`};if(e.startsWith(`blob:`))return{valid:!0,sanitized:e};try{let n=new URL(e);if(![`http:`,`https:`].includes(n.protocol))return{valid:!1,error:`Protocol ${n.protocol} is not allowed. Only http and https are permitted.`};if(t===`proxy`&&this.config.allowedProxyDomains&&this.config.allowedProxyDomains.length>0){let e=n.hostname.toLowerCase();if(!this.config.allowedProxyDomains.some(t=>{let n=t.toLowerCase();return e===n||e.endsWith(`.`+n)}))return{valid:!1,error:`Proxy domain ${n.hostname} is not in the allowed list`}}if(t===`proxy`){if(!this.config.allowLocalhostProxy){let e=n.hostname.toLowerCase();if(e===`localhost`||e===`127.0.0.1`||e===`::1`)return{valid:!1,error:`Localhost is not allowed for proxy URLs`};if(this.isPrivateIP(e))return{valid:!1,error:`Private IP addresses are not allowed for proxy URLs`};if(e.startsWith(`169.254.`)||e.startsWith(`fe80:`))return{valid:!1,error:`Link-local addresses are not allowed for proxy URLs`}}return{valid:!0,sanitized:e}}return{valid:!0,sanitized:e}}catch(e){return{valid:!1,error:`Invalid URL format: ${e instanceof Error?e.message:`Unknown error`}`}}}isPrivateIP(e){return[/^0\./,/^10\./,/^100\.(6[4-9]|[7-9][0-9]|1[0-1][0-9]|12[0-7])\./,/^127\./,/^169\.254\./,/^172\.(1[6-9]|2[0-9]|3[0-1])\./,/^192\.0\.0\./,/^192\.0\.2\./,/^192\.168\./,/^198\.(1[8-9])\./,/^198\.51\.100\./,/^203\.0\.113\./,/^2(2[4-9]|3[0-9])\./,/^24[0-9]\./,/^255\.255\.255\.255$/].some(t=>t.test(e))?!0:e.includes(`:`)?this.isPrivateIPv6(e):!1}isPrivateIPv6(e){let t=e.toLowerCase().trim().replace(/^\[|\]$/g,``),n=t.split(`%`)[0]??t;if(/^(0:){7}1$/.test(n)||n===`::1`||/^(0:){7}0$/.test(n)||n===`::`)return!0;let r=this.expandIPv6(n);if(!r)return this.isPrivateIPv6Prefix(n);let i=parseInt(r.substring(0,2),16);if(i>=252&&i<=253)return!0;if(i===254){let e=parseInt(r.substring(2,4),16);if(e>=128&&e<=191)return!0}return i===255}expandIPv6(e){try{if(e.includes(`::`)){let t=e.split(`::`);if(t.length>2)return null;let n=t[0]?t[0].split(`:`):[],r=t[1]?t[1].split(`:`):[],i=8-n.length-r.length;if(i<0)return null;let a=Array(i).fill(`0000`);return[...n,...a,...r].map(e=>e.padStart(4,`0`)).join(`:`)}{let t=e.split(`:`);return t.length===8?t.map(e=>e.padStart(4,`0`)).join(`:`):null}}catch{return null}}isPrivateIPv6Prefix(e){return!!(/^fc[0-9a-f]{0,2}:?/i.test(e)||/^fd[0-9a-f]{0,2}:?/i.test(e)||/^fe[89ab][0-9a-f]:?/i.test(e)||/^ff[0-9a-f]{0,2}:?/i.test(e))}validateCspNonce(e){return!e||typeof e!=`string`?{valid:!1,error:`CSP nonce must be a non-empty string`}:e.length<16?{valid:!1,error:`CSP nonce is too short (minimum 16 characters recommended)`}:/^[A-Za-z0-9+/=_-]+$/.test(e)?{valid:!0,sanitized:e}:{valid:!1,error:`CSP nonce contains invalid characters`}}validateBackgroundColor(e){return e===null?{valid:!0,sanitized:null}:typeof e!=`string`||e.length===0?{valid:!1,error:`backgroundColor must be a CSS color string or null`}:/[^a-zA-Z0-9%(),.#\s/-]/.test(e)?{valid:!1,error:`backgroundColor contains characters that cannot appear in a CSS color: ${e}`}:{valid:!0,sanitized:e}}validateImageTimeout(e){return typeof e!=`number`||isNaN(e)?{valid:!1,error:`Image timeout must be a number`}:e<0?{valid:!1,error:`Image timeout cannot be negative`}:this.config.maxImageTimeout&&e>this.config.maxImageTimeout?{valid:!1,error:`Image timeout ${e}ms exceeds maximum allowed ${this.config.maxImageTimeout}ms`}:{valid:!0,sanitized:e}}validateDimensions(e,t){if(typeof e!=`number`||typeof t!=`number`)return{valid:!1,error:`Dimensions must be numbers`};if(isNaN(e)||isNaN(t))return{valid:!1,error:`Dimensions cannot be NaN`};if(e<=0||t<=0)return{valid:!1,error:`Dimensions must be positive`};let n=32767;return e>n||t>n?{valid:!1,error:`Dimensions exceed maximum allowed (${n}px)`}:{valid:!0,sanitized:{width:e,height:t}}}validateScale(e){return typeof e!=`number`||isNaN(e)?{valid:!1,error:`Scale must be a number`}:e<=0?{valid:!1,error:`Scale must be positive`}:e>10?{valid:!1,error:`Scale factor too large (maximum 10x)`}:{valid:!0,sanitized:e}}validateElement(e){if(!e)return{valid:!1,error:`Element is required`};if(typeof e!=`object`)return{valid:!1,error:`Element must be an object`};let t=e;return typeof HTMLElement<`u`&&e instanceof HTMLElement?e.ownerDocument?{valid:!0}:{valid:!1,error:`Element must be attached to a document`}:t.ownerDocument?t.ownerDocument.defaultView?{valid:!0}:{valid:!1,error:`Document must be attached to a window (ownerDocument.defaultView required)`}:{valid:!1,error:`Element must be attached to a document (ownerDocument required)`}}validateOptions(e){let t=[],n=e.proxy;if(n!=null&&typeof n==`string`&&n.length>0){let e=this.validateUrl(n,`proxy`);e.valid||t.push(`Proxy: ${e.error}`)}if(e.imageTimeout!==void 0){let n=this.validateImageTimeout(e.imageTimeout);n.valid||t.push(`Image timeout: ${n.error}`)}if(e.width!==void 0||e.height!==void 0){let n=e.width??800,r=e.height??600,i=this.validateDimensions(n,r);i.valid||t.push(`Dimensions: ${i.error}`)}if(e.scale!==void 0){let n=this.validateScale(e.scale);n.valid||t.push(`Scale: ${n.error}`)}if(e.cspNonce!==void 0){let n=this.validateCspNonce(e.cspNonce);n.valid||t.push(`CSP nonce: ${n.error}`)}if(e.backgroundColor!==void 0){let n=this.validateBackgroundColor(e.backgroundColor);n.valid||t.push(`backgroundColor: ${n.error}`)}if(this.config.customValidator){let n=this.config.customValidator(e,`options`);n.valid||t.push(`Custom validation: ${n.error}`)}return t.length>0?{valid:!1,error:t.join(`; `)}:{valid:!0}}};function r(e={}){return new n({allowDataUrls:!0,maxImageTimeout:3e5,...e})}var i=class{logger;activeMetrics=/* @__PURE__ */ new Map;completedMetrics=[];enabled;getTime;constructor(e,t=!0){this.logger=e,this.enabled=t,this.getTime=typeof performance<`u`&&typeof performance.now==`function`?()=>performance.now():()=>Date.now()}start(e,t){this.enabled&&(this.activeMetrics.has(e)&&this.logger?.warn(`Performance metric '${e}' already started. Overwriting.`),this.activeMetrics.set(e,{name:e,startTime:this.getTime(),metadata:t}))}end(e){if(!this.enabled)return;let t=this.activeMetrics.get(e);if(!t)this.logger?.warn(`Performance metric '${e}' not found. Was start() called?`);else return t.endTime=this.getTime(),t.duration=t.endTime-t.startTime,this.completedMetrics.push(t),this.activeMetrics.delete(e),this.logger?.debug(`⏱️ ${e}: ${t.duration.toFixed(2)}ms`,t.metadata),t}measure(e,t,n){this.start(e,n);try{let n=t();return this.end(e),n}catch(t){throw this.end(e),t}}async measureAsync(e,t,n){this.start(e,n);try{let n=await t();return this.end(e),n}catch(t){throw this.end(e),t}}getMetrics(){return[...this.completedMetrics]}getMetric(e){return this.completedMetrics.find(t=>t.name===e)}getSummary(){let e=this.completedMetrics.reduce((e,t)=>e+(t.duration||0),0),t=this.completedMetrics.map(t=>({name:t.name,duration:t.duration||0,percentage:e>0?((t.duration||0)/e*100).toFixed(1)+`%`:`0%`}));return{totalDuration:e,metrics:this.getMetrics(),breakdown:t}}logSummary(){if(!this.enabled||this.completedMetrics.length===0||!this.logger)return;let e=this.logger,t=this.getSummary();e.info(`\n📊 Performance Summary (Total: ${t.totalDuration.toFixed(2)}ms):`),t.breakdown.sort((e,t)=>t.duration-e.duration).forEach(t=>{e.info(` ${t.name.padEnd(20)} ${t.duration.toFixed(2).padStart(8)}ms ${t.percentage.padStart(6)}`)})}clear(){this.activeMetrics.clear(),this.completedMetrics.splice(0)}isEnabled(){return this.enabled}getActiveMetrics(){return Array.from(this.activeMetrics.keys())}},a=class e{left;top;width;height;constructor(e,t,n,r){this.left=e,this.top=t,this.width=n,this.height=r}add(t,n,r,i){return new e(this.left+t,this.top+n,this.width+r,this.height+i)}static fromClientRect(t,n){return new e(n.left+t.windowBounds.left,n.top+t.windowBounds.top,n.width,n.height)}static fromDOMRectList(t,n){let r=Array.from(n),i=r.find(e=>e.width!==0);return i||=r.find(e=>e.height!==0),!i&&r.length>0&&(i=r[0]),i?new e(i.left+t.windowBounds.left,i.top+t.windowBounds.top,i.width,i.height):e.EMPTY}static EMPTY=new e(0,0,0,0)};let o=(e,t)=>a.fromClientRect(e,t.getBoundingClientRect()),s=e=>{let t=e.body,n=e.documentElement;if(!t||!n)throw Error(`Unable to get document size`);return new a(0,0,Math.max(Math.max(t.scrollWidth,n.scrollWidth),Math.max(t.offsetWidth,n.offsetWidth),Math.max(t.clientWidth,n.clientWidth)),Math.max(Math.max(t.scrollHeight,n.scrollHeight),Math.max(t.offsetHeight,n.offsetHeight),Math.max(t.clientHeight,n.clientHeight)))},c=(e,t)=>{let n=e[t];if(n===void 0)throw Error(`Missing element at index ${t}`);return n},l=65533,u=e=>e>=48&&e<=57,d=e=>e>=55296&&e<=57343,f=e=>u(e)||e>=65&&e<=70||e>=97&&e<=102,p=e=>e>=97&&e<=122,m=e=>e>=65&&e<=90,h=e=>p(e)||m(e),g=e=>e>=128,_=e=>e===10||e===9||e===32,v=e=>h(e)||g(e)||e===95,y=e=>v(e)||u(e)||e===45,b=e=>e>=0&&e<=8||e===11||e>=14&&e<=31||e===127,x=(e,t)=>e===92&&t!==10,S=(e,t,n)=>e===45?v(t)||x(t,n):!!(v(e)||e===92&&x(e,t)),C=(e,t,n)=>e===43||e===45?u(t)?!0:t===46&&u(n):u(e===46?t:e),w=e=>{let t=0,n=1;(e[t]===43||e[t]===45)&&(e[t]===45&&(n=-1),t++);let r=[];for(;u(e[t]??NaN);)r.push(c(e,t)),t++;let i=r.length?parseInt(String.fromCodePoint(...r),10):0;e[t]===46&&t++;let a=[];for(;u(e[t]??NaN);)a.push(c(e,t)),t++;let o=a.length,s=o?parseInt(String.fromCodePoint(...a),10):0;(e[t]===69||e[t]===101)&&t++;let l=1;(e[t]===43||e[t]===45)&&(e[t]===45&&(l=-1),t++);let d=[];for(;u(e[t]??NaN);)d.push(c(e,t)),t++;let f=d.length?parseInt(String.fromCodePoint(...d),10):0;return n*(i+s*10**-o)*10**(l*f)},ee={type:2},te={type:3},ne={type:4},re={type:13},ie={type:8},ae={type:21},oe={type:9},se={type:10},ce={type:11},le={type:12},ue={type:14},de={type:23},fe={type:1},pe={type:25},me={type:24},he={type:26},ge={type:27},_e={type:28},ve={type:29},ye={type:31},be={type:32};var xe=class e{static _pool=[];static MAX_POOL_SIZE=40;static get(){return e._pool.pop()||new e}static release(t){e._pool.length<e.MAX_POOL_SIZE&&(t._reset(),e._pool.push(t))}_value;_cursor;constructor(){this._value=[],this._cursor=0}_reset(){this._value=[],this._cursor=0}write(e){this._cursor>0&&(this._value=this._value.slice(this._cursor),this._cursor=0),this._value=this._value.concat([...e].map(e=>e.codePointAt(0)))}read(){let e=[],t=this.consumeToken();for(;t!==be;)e.push(t),t=this.consumeToken();return e}consumeToken(){let e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:{let e=this.peekCodePoint(0),t=this.peekCodePoint(1),n=this.peekCodePoint(2);if(y(e)||x(t,n)){let r=S(e,t,n)?2:1;return{type:5,value:this.consumeName(),flags:r}}break}case 36:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),re;break;case 39:return this.consumeStringToken(39);case 40:return ee;case 41:return te;case 42:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),ue;break;case 43:if(C(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return ne;case 45:{let t=e,n=this.peekCodePoint(0),r=this.peekCodePoint(1);if(C(t,n,r))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(S(t,n,r))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(n===45&&r===62)return this.consumeCodePoint(),this.consumeCodePoint(),me;break}case 46:if(C(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(this.peekCodePoint(0)===42)for(this.consumeCodePoint();;){let e=this.consumeCodePoint();if(e===42&&(e=this.consumeCodePoint(),e===47)||e===-1)return this.consumeToken()}break;case 58:return he;case 59:return ge;case 60:if(this.peekCodePoint(0)===33&&this.peekCodePoint(1)===45&&this.peekCodePoint(2)===45)return this.consumeCodePoint(),this.consumeCodePoint(),this.consumeCodePoint(),pe;break;case 64:{let e=this.peekCodePoint(0),t=this.peekCodePoint(1),n=this.peekCodePoint(2);if(S(e,t,n))return{type:7,value:this.consumeName()};break}case 91:return _e;case 92:if(x(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return ve;case 94:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),ie;break;case 123:return ce;case 125:return le;case 117:case 85:{let t=this.peekCodePoint(0),n=this.peekCodePoint(1);return t===43&&(f(n)||n===63)?(this.consumeCodePoint(),this.consumeUnicodeRangeToken()):(this.reconsumeCodePoint(e),this.consumeIdentLikeToken())}case 124:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),oe;if(this.peekCodePoint(0)===124)return this.consumeCodePoint(),ae;break;case 126:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),se;break;case-1:return be}return _(e)?(this.consumeWhiteSpace(),ye):u(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):v(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:String.fromCodePoint(e)}}consumeCodePoint(){let e=this._value[this._cursor];return e===void 0?-1:(this._cursor++,e)}reconsumeCodePoint(e){this._cursor>0&&this._value[this._cursor-1]===e?this._cursor--:this._value.splice(this._cursor,0,e)}peekCodePoint(e){let t=this._value[this._cursor+e];return t===void 0?-1:t}consumeUnicodeRangeToken(){let e=[],t=this.consumeCodePoint();for(;f(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();let n=!1;for(;t===63&&e.length<6;)e.push(t),t=this.consumeCodePoint(),n=!0;if(n)return{type:30,start:parseInt(String.fromCodePoint(...e.map(e=>e===63?48:e)),16),end:parseInt(String.fromCodePoint(...e.map(e=>e===63?70:e)),16)};let r=parseInt(String.fromCodePoint(...e),16);if(t===45&&f(this.peekCodePoint(0))){t=this.consumeCodePoint();let e=[];for(;f(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();return{type:30,start:r,end:parseInt(String.fromCodePoint(...e),16)}}return{type:30,start:r,end:r}}consumeIdentLikeToken(){let e=this.consumeName();return e.toLowerCase()===`url`&&this.peekCodePoint(0)===40?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===40?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}}consumeUrlToken(){let e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===-1)return{type:22,value:``};let t=this.peekCodePoint(0);if(t===39||t===34){let e=this.consumeStringToken(this.consumeCodePoint());return e.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===-1||this.peekCodePoint(0)===41)?(this.consumeCodePoint(),{type:22,value:e.value}):(this.consumeBadUrlRemnants(),de)}for(;;){let t=this.consumeCodePoint();if(t===-1||t===41)return{type:22,value:String.fromCodePoint(...e)};if(_(t))return this.consumeWhiteSpace(),this.peekCodePoint(0)===-1||this.peekCodePoint(0)===41?(this.consumeCodePoint(),{type:22,value:String.fromCodePoint(...e)}):(this.consumeBadUrlRemnants(),de);if(t===34||t===39||t===40||b(t))return this.consumeBadUrlRemnants(),de;if(t===92){if(x(t,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),de}else e.push(t)}}consumeWhiteSpace(){for(;_(this.peekCodePoint(0));)this.consumeCodePoint()}consumeBadUrlRemnants(){for(;;){let e=this.consumeCodePoint();if(e===41||e===-1)return;x(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}}consumeStringSlice(e){let t=``,n=this._cursor+e,r=this._cursor;for(;r<n;){let e=Math.min(n,r+5e4);t+=String.fromCodePoint(...this._value.slice(r,e)),r=e}return this._cursor=n+1,t}consumeStringToken(e){let t=``,n=0;do{let r=this._value[this._cursor+n];if(r===-1||r===void 0||r===e)return t+=this.consumeStringSlice(n),{type:0,value:t};if(r===10)return this._cursor+=n,fe;if(r===92){let e=this._value[this._cursor+n+1];e!==-1&&e!==void 0&&(e===10?(t+=this.consumeStringSlice(n),n=-1,this._cursor++):x(r,e)&&(t+=this.consumeStringSlice(n),t+=String.fromCodePoint(this.consumeEscapedCodePoint()),n=-1))}n++}while(1)}consumeNumber(){let e=[],t=4,n=this.peekCodePoint(0);for((n===43||n===45)&&e.push(this.consumeCodePoint());u(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0);let r=this.peekCodePoint(1);if(n===46&&u(r))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;u(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0),r=this.peekCodePoint(1);let i=this.peekCodePoint(2);if((n===69||n===101)&&((r===43||r===45)&&u(i)||u(r)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;u(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[w(e),t]}consumeNumericToken(){let[e,t]=this.consumeNumber(),n=this.peekCodePoint(0),r=this.peekCodePoint(1),i=this.peekCodePoint(2);return S(n,r,i)?{type:15,number:e,flags:t,unit:this.consumeName()}:n===37?(this.consumeCodePoint(),{type:16,number:e,flags:t}):{type:17,number:e,flags:t}}consumeEscapedCodePoint(){let e=this.consumeCodePoint();if(f(e)){let t=String.fromCodePoint(e);for(;f(this.peekCodePoint(0))&&t.length<6;)t+=String.fromCodePoint(this.consumeCodePoint());_(this.peekCodePoint(0))&&this.consumeCodePoint();let n=parseInt(t,16);return n===0||d(n)||n>1114111?l:n}return e===-1?l:e}consumeName(){let e=``;for(;;){let t=this.consumeCodePoint();if(y(t))e+=String.fromCodePoint(t);else if(x(t,this.peekCodePoint(0)))e+=String.fromCodePoint(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}}},Se=class e{_tokens;constructor(e){this._tokens=e}static create(t){let n=new xe;return n.write(t),new e(n.read())}static parseValue(t){return e.create(t).parseComponentValue()}static parseValues(t){return e.create(t).parseComponentValues()}parseComponentValue(){let e=this.consumeToken();for(;e.type===31;)e=this.consumeToken();if(e.type===32)throw SyntaxError(`Error parsing CSS component value, unexpected EOF`);this.reconsumeToken(e);let t=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return t;throw SyntaxError(`Error parsing CSS component value, multiple values found when expecting only one`)}parseComponentValues(){let e=[];for(;;){let t=this.consumeComponentValue();if(t.type===32)return e;e.push(t)}}consumeComponentValue(){let e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e}consumeSimpleBlock(e){let t={type:e,values:[]},n=this.consumeToken();for(;;){if(n.type===32||Ee(n,e))return t;this.reconsumeToken(n),t.values.push(this.consumeComponentValue()),n=this.consumeToken()}}consumeFunction(e){let t={name:e.value,values:[],type:18};for(;;){let e=this.consumeToken();if(e.type===32||e.type===3)return t;this.reconsumeToken(e),t.values.push(this.consumeComponentValue())}}consumeToken(){let e=this._tokens.shift();return e===void 0?be:e}reconsumeToken(e){this._tokens.unshift(e)}};let T=e=>e.type===15,E=e=>e.type===17,D=e=>e.type===20,Ce=e=>e.type===0,we=(e,t)=>D(e)&&e.value===t,Te=e=>e.type!==31,O=e=>e.type!==31&&e.type!==4,k=e=>{let t=[],n=[];return e.forEach(e=>{e.type===4?n.length&&(t.push(n),n=[]):e.type!==31&&n.push(e)}),n.length&&t.push(n),t},Ee=(e,t)=>t===11&&e.type===12||t===28&&e.type===29||t===2&&e.type===3,De=/(\d+(?:\.\d+)?|[+\-*/()])/g,Oe=e=>{let t=e.match(De);if(!t)return NaN;let n=[],r=[],i={"+":1,"-":1,"*":2,"/":2};for(let e of t)if(/^\d+(?:\.\d+)?$/.test(e))n.push(parseFloat(e));else if(e===`(`)r.push(e);else if(e===`)`){for(;r.length&&r[r.length-1]!==`(`;)n.push(r.pop());if(!r.length)return NaN;r.pop()}else{for(;r.length&&(i[c(r,r.length-1)]??0)>=(i[e]??0);)n.push(r.pop());r.push(e)}for(;r.length;){let e=r.pop();if(e===`(`)return NaN;n.push(e)}let a=[];for(let e of n)if(typeof e==`number`)a.push(e);else{let t=a.pop(),n=a.pop();if(n===void 0||t===void 0)return NaN;switch(e){case`+`:a.push(n+t);break;case`-`:a.push(n-t);break;case`*`:a.push(n*t);break;case`/`:a.push(t===0?NaN:n/t);break;default:return NaN}}return a.length===1?a[0]??NaN:NaN},A=(e,t,n)=>Math.min(Math.max(e,t),n),j=(e,t)=>[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]],ke=e=>j([3.2409699419045226,-1.537383177570094,-.4986107602930034,-.9692436362808796,1.8759675015077202,.04155505740717559,.05563007969699366,-.20397695888897652,1.0569715142428786],e),Ae=e=>j([.41239079926595934,.357584339383878,.1804807884018343,.21263900587151027,.715168678767756,.07219231536073371,.01933081871559182,.11919477979462598,.9505321522496607],e),je=e=>{let[t,n,r]=e,i=e=>{let t=e<0?-1:1,n=Math.abs(e);return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e};return[i(t),i(n),i(r)]},Me=e=>{let[t,n,r]=e,i=e=>{let t=e<0?-1:1,n=Math.abs(e);return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4};return[i(t),i(n),i(r)]},Ne=e=>{let[t,n,r]=je(ke([e[0],e[1],e[2]]));return[t,n,r,e[3]]},Pe=e=>{let[t,n,r]=ke([e[0],e[1],e[2]]);return[A(Math.round(t*255),0,255),A(Math.round(n*255),0,255),A(Math.round(r*255),0,255),e[3]]},Fe=e=>e.type===17||e.type===15,M=e=>e.type===16||Fe(e)||Ie(e),Ie=e=>e.type===17&&e._calcPercentage!==void 0,Le=e=>e.type===18&&e.name===`calc`,Re=e=>{let t=Be(e,0);if(!t)return null;let n=Be(e,100);if(!n)return null;let r=t.number,i=n.number-r;return i===0?t:{type:17,number:r,flags:4,_calcPercentage:i,_calcPixelOffset:r}},ze=e=>Le(e)?Re(e):M(e)?e:null,Be=(e,t=0)=>{let n=e=>{let r=``;for(let i of e)if(i.type!==31){if(i.type===18){if(i.name===`calc`){let e=n(i.values);if(e===null)return null;r+=`(${e})`}else return null}else if(i.type===17)r+=i.number.toString();else if(i.type===15)i.unit===`px`?r+=i.number.toString():i.unit===`rem`||i.unit===`em`?r+=(i.number*16).toString():r+=i.number.toString();else if(i.type===16)r+=(i.number/100*t).toString();else if(i.type===6){let e=i.value;e===`+`||e===`-`||e===`*`||e===`/`?r+=` ${e} `:e===`(`?r+=`(`:e===`)`&&(r+=`)`)}}return r};try{let t=n(e.values);if(t===null||t.trim()===``)return null;let r=Oe(t);if(typeof r==`number`&&!isNaN(r))return{type:17,number:r,flags:4}}catch{return null}return null},Ve=e=>e.length>1?[c(e,0),c(e,1)]:[c(e,0)],N={type:17,number:0,flags:4},P={type:16,number:50,flags:4},F={type:16,number:100,flags:4},He=(e,t,n)=>{let[r,i]=e;return[I(r,t),I(i===void 0?r:i,n)]},I=(e,t)=>{if(Ie(e))return e._calcPercentage/100*t+e._calcPixelOffset;if(e.type===16)return e.number/100*t;if(T(e))switch(e.unit){case`rem`:case`em`:return 16*e.number;default:return e.number}return e.number},Ue=`grad`,We=`turn`,Ge={name:`angle`,parse:(e,t)=>{if(t.type===15)switch(t.unit){case`deg`:return Math.PI*t.number/180;case Ue:return Math.PI/200*t.number;case`rad`:return t.number;case We:return Math.PI*2*t.number}throw Error(`Unsupported angle type`)}},Ke=e=>!(e.type!==15||e.unit!==`deg`&&e.unit!==Ue&&e.unit!==`rad`&&e.unit!==We),qe=e=>{switch(e.filter(D).map(e=>e.value).join(` `)){case`to bottom right`:case`to right bottom`:case`left top`:case`top left`:return[N,N];case`to top`:case`bottom`:return L(0);case`to bottom left`:case`to left bottom`:case`right top`:case`top right`:return[N,F];case`to right`:case`left`:return L(90);case`to top left`:case`to left top`:case`right bottom`:case`bottom right`:return[F,F];case`to bottom`:case`top`:return L(180);case`to top right`:case`to right top`:case`left bottom`:case`bottom left`:return[F,N];case`to left`:case`right`:return L(270)}return 0},L=e=>Math.PI*e/180,R=e=>!(255&e),z=e=>{let t=255&e,n=255&e>>8,r=255&e>>16,i=255&e>>24;return t<255?`rgba(${i},${r},${n},${t/255})`:`rgb(${i},${r},${n})`},Je=(e,t,n,r)=>(e<<24|t<<16|n<<8|Math.round(r*255))>>>0,B=(e,t)=>{if(e.type===17)return e.number;if(e.type===16){let n=t===3?1:255;return t===3?e.number/100*n:Math.round(e.number/100*n)}return 0},Ye=e=>{let t=e[0];return(t&&t.type===20?t.value:`unknown`)===`from`},Xe=e=>Je(A(Math.round(e[0]*255),0,255),A(Math.round(e[1]*255),0,255),A(Math.round(e[2]*255),0,255),A(e[3],0,1)),Ze=e=>{let[t,n,r,i]=e,a=je([t,n,r]);return Je(A(Math.round(a[0]*255),0,255),A(Math.round(a[1]*255),0,255),A(Math.round(a[2]*255),0,255),i)},Qe=e=>{let t=ke([e[0],e[1],e[2]]);return Ze([t[0],t[1],t[2],e[3]])},$e=(e,t)=>{if(Ye(t.filter(O)))throw Error(`Relative color not supported for lab()`);let[n,r,i,a]=st(t),o=et(t)?n*100:n,s=je(ke(ht([o,r,i])));return Je(A(Math.round(s[0]*255),0,255),A(Math.round(s[1]*255),0,255),A(Math.round(s[2]*255),0,255),a)},et=e=>{let t=e.filter(O)[0];return t!==void 0&&t.type===16},tt=(e,t)=>{if(Ye(t.filter(O)))throw Error(`Relative color not supported for oklab()`);let[n,r,i,a]=st(t),o=je(ke(mt([n,r,i])));return Je(A(Math.round(o[0]*255),0,255),A(Math.round(o[1]*255),0,255),A(Math.round(o[2]*255),0,255),a)},nt=(e,t)=>{if(Ye(t.filter(O)))throw Error(`Relative color not supported for oklch()`);let[n,r,i,a]=ct(t),o=je(ke(mt(pt([n,r,i]))));return Je(A(Math.round(o[0]*255),0,255),A(Math.round(o[1]*255),0,255),A(Math.round(o[2]*255),0,255),a)},rt=(e,t)=>{if(Ye(t.filter(O)))throw Error(`Relative color not supported for lch()`);let[n,r,i,a]=ot(t),o=je(ke(ht(pt([n,r,i]))));return Je(A(Math.round(o[0]*255),0,255),A(Math.round(o[1]*255),0,255),A(Math.round(o[2]*255),0,255),a)},it=(e,t)=>{let n=t.filter(O),r=n[0],i=n[1],a=n[2],o=n[3],s=o!==void 0&&o.type===6&&o.value===`/`?n[4]:n[3];return[r?(r.type===17?L(r.number):Ge.parse(e,r))/(Math.PI*2):0,i!==void 0&&M(i)?i.number/100:0,a!==void 0&&M(a)?a.number/100:0,s!==void 0&&M(s)?I(s,1):1]},at=(e,t)=>{if(Ye(t))throw Error(`Relative color not supported for hsl()`);let[n,r,i,a]=it(e,t),o=ft([n,r,i]);return Je(o[0]*255,o[1]*255,o[2]*255,a)},ot=e=>{let t=e.filter(O),n=t[0],r=t[1],i=t[2],a=t[4];return[n!==void 0&&M(n)?n.number:0,r!==void 0&&M(r)?r.number:0,i!==void 0&&(E(i)||T(i))?i.number:0,a!==void 0&&M(a)?I(a,1):1]},st=e=>{let t=e.filter(O),n=t[0],r=t[1],i=t[2],a=t[4];return[n===void 0?0:n.type===16?n.number/100:E(n)?n.number:0,r===void 0?0:r.type===16?r.number/100:E(r)?r.number:0,i!==void 0&&(E(i)||T(i))?i.number:0,a!==void 0&&M(a)?I(a,1):1]},ct=e=>{let t=e.filter(O),n=t[0],r=t[1],i=t[2],a=t[4];return[n===void 0?0:n.type===16?n.number/100:E(n)?n.number:0,r===void 0?0:r.type===16?r.number/100:E(r)?r.number:0,i!==void 0&&(E(i)||T(i))?i.number:0,a!==void 0&&M(a)?I(a,1):1]},lt=e=>j([1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371],e),ut=e=>j([.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124],e),dt=(e,t,n)=>(n<0&&(n+=1),n>=1&&--n,n<1/6?(t-e)*n*6+e:n<1/2?t:n<2/3?(t-e)*6*(2/3-n)+e:e),ft=([e,t,n])=>{if(t===0)return[n,n,n];let r=n<=.5?n*(t+1):n+t-n*t,i=n*2-r;return[dt(i,r,e+1/3),dt(i,r,e),dt(i,r,e-1/3)]},pt=([e,t,n])=>(t<0&&(t=0),isNaN(n)&&(n=0),[e,t*Math.cos(n*Math.PI/180),t*Math.sin(n*Math.PI/180)]),mt=e=>{let t=j([1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],e),n=[t[0]**3,t[1]**3,t[2]**3];return j([1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],n)},ht=e=>{let t=(e[0]+16)/116,n=e[1]/500+t,r=t-e[2]/200,i=24389/27,a=24/116,o=[(n>a?n**3:(116*n-16)/i)*.3457/.3585,e[0]>8?t**3:e[0]/i,(r>a?r**3:(116*r-16)/i)*.2958/.3585];return ut([o[0],o[1],o[2]])},gt=(e,t)=>{let n=t.filter(O);if(n.length===3||n.length===4){let e=B(c(n,0),0),t=B(c(n,1),1),r=B(c(n,2),2),i=n.length===4?B(c(n,3),3):1,a=Me([e/255,t/255,r/255]),[o,s,l]=Ae([a[0],a[1],a[2]]);return[o,s,l,i]}return[0,0,0,1]},_t=(e,t)=>{let[n,r,i,a]=it(e,t),o=Me(ft([n,r,i])),[s,c,l]=Ae([o[0],o[1],o[2]]);return[s,c,l,a]},vt=(e,t)=>{let[n,r,i,a]=st(t),[o,s,c]=ht([n,r,i]);return[o,s,c,a]},yt=(e,t)=>{let[n,r,i,a]=ot(t),[o,s,c]=ht(pt([n,r,i]));return[o,s,c,a]},bt=(e,t)=>{let[n,r,i,a]=ct(t),[o,s,c]=mt(pt([n,r,i]));return[o,s,c,a]},xt=(e,t)=>{let[n,r,i,a]=st(t),[o,s,c]=mt([n,r,i]);return[o,s,c,a]},St=e=>ut([e[0],e[1],e[2]]),Ct=e=>e,wt=e=>{let[t,n,r]=lt([e[0],e[2],e[3]]);return[t,n,r,e[3]]},Tt=e=>Qe([e[0],e[1],e[2],e[3]]),Et=e=>{let t=St([e[0],e[1],e[2]]);return Qe([t[0],t[1],t[2],e[3]])},Dt=e=>j([.4865709486482162,.26566769316909306,.1982172852343625,.2289745640697488,.6917385218365064,.079286914093745,0,.04511338185890264,1.043944368900976],e),Ot=e=>j([2.493496911941425,-.9313836179191239,-.40271078445071684,-.8294889695615747,1.7626640603183463,.023624685841943577,.03584583024378447,-.07617238926804182,.9568845240076872],e),kt=e=>{let t=e=>{let t=e<0?-1:1;return e*t<=.04045?e/12.92:t*((e+.055)/1.055)**2.4||0};return[t(e[0]),t(e[1]),t(e[2])]},At=e=>je(e),jt=e=>{let t=kt([e[0],e[1],e[2]]);return Dt([t[0],t[1],t[2]])},Mt=e=>{let[t,n,r]=At(Ot([e[0],e[1],e[2]]));return[t,n,r,e[3]]},Nt=e=>{let t=jt([e[0],e[1],e[2]]);return Qe([t[0],t[1],t[2],e[3]])},Pt=e=>j([2.0415879038107465,-.5650069742788596,-.34473135077832956,-.9692436362808795,1.8759675015077202,.04155505740717557,.013444280632031142,-.11836239223101838,1.0151749943912054],e),Ft=e=>j([.5766690429101305,.1855582379065463,.1882286462349947,.29734497525053605,.6273635662554661,.0752914584939978,.02703136138641234,.07068885253582723,.9913375368376388],e),It=e=>{let t=e.map(e=>(e<0?-1:1)*Math.abs(e)**(563/256));return[t[0]??0,t[1]??0,t[2]??0]},Lt=e=>{let t=e.map(e=>(e<0?-1:1)*Math.abs(e)**(256/563));return[t[0]??0,t[1]??0,t[2]??0]},Rt=e=>{let[t,n,r]=Lt(Pt([e[0],e[1],e[2]]));return[t,n,r,e[3]]},zt=e=>{let t=ke(Ft(It([e[0],e[1],e[2]])));return Ze([t[0],t[1],t[2],e[3]])},Bt=e=>j([.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602],e),Vt=e=>j([1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],e),Ht=e=>{let[t,n,r]=e,i=e=>e<16/512?e/16:e**1.8;return[i(t),i(n),i(r)]},Ut=e=>{let[t,n,r]=e,i=e=>e>1/512?e**(1/1.8):e*16;return[i(t),i(n),i(r)]},Wt=e=>{let t=Ht([e[0],e[1],e[2]]);return ut(Bt([t[0],t[1],t[2]]))},Gt=e=>{let[t,n,r]=Ut(Vt(lt([e[0],e[1],e[2]])));return[t,n,r,e[3]]},Kt=e=>{let t=Wt([e[0],e[1],e[2]]);return Qe([t[0],t[1],t[2],e[3]])},qt=1.09929682680944,Jt=.018053968510807,Yt=e=>{let t=e=>e<Jt*4.5?e/4.5:((e+qt-1)/qt)**(1/.45);return[t(e[0]),t(e[1]),t(e[2])]},Xt=e=>{let t=e=>e>=Jt?qt*e**.45-.09929682680944008:4.5*e;return[t(e[0]),t(e[1]),t(e[2])]},Zt=e=>j([.6369580483012914,.14461690358620832,.1688809751641721,.2627002120112671,.6779980715188708,.05930171646986196,0,.028072693049087428,1.060985057710791],e),Qt=e=>j([1.716651187971268,-.355670783776392,-.25336628137366,-.666684351832489,1.616481236634939,.0157685458139111,.017639857445311,-.042770613257809,.942103121235474],e),$t=e=>{let t=Yt([e[0],e[1],e[2]]);return Zt([t[0],t[1],t[2]])},en=e=>{let[t,n,r]=Xt(Qt([e[0],e[1],e[2]]));return[t,n,r,e[3]]},tn=e=>{let t=$t([e[0],e[1],e[2]]);return Qe([t[0],t[1],t[2],e[3]])},nn={lch:2,oklch:2,hsl:0},rn=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],an=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],on=e=>{let t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=t*(a*l-o*c)-n*(i*l-o*s)+r*(i*c-a*s);return[(a*l-o*c)/u,(r*c-n*l)/u,(n*o-r*a)/u,(o*s-i*l)/u,(t*l-r*s)/u,(r*i-t*o)/u,(i*c-a*s)/u,(n*s-t*c)/u,(t*a-n*i)/u]},sn=on(rn),cn=on(an),ln=24389/27,un=24/116,dn=un*un*un,fn=e=>[(255&e>>24)/255,(255&e>>16)/255,(255&e>>8)/255],pn=e=>{let[t,n,r]=lt([e[0],e[1],e[2]]),i=t/.9642956764295677,a=n,o=r/.8251046025104602,s=i>dn?Math.cbrt(i):(ln*i+16)/116,c=a>dn?Math.cbrt(a):(ln*a+16)/116,l=o>dn?Math.cbrt(o):(ln*o+16)/116;return[116*c-16,500*(s-c),200*(c-l)]},mn=e=>{let t=j(sn,e),n=[Math.cbrt(t[0]),Math.cbrt(t[1]),Math.cbrt(t[2])];return j(cn,n)},hn=e=>{let t=Math.hypot(e[1],e[2]),n=Math.atan2(e[2],e[1])*180/Math.PI;return[e[0],t,(n+360)%360]},gn=e=>{let t=e[0],n=e[1],r=e[2],i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2;if(i===a)return[0,0,o];let s=i-a,c=o>.5?s/(2-i-a):s/(i+a),l;return l=i===t?((n-r)/s+(n<r?6:0))/6:i===n?((r-t)/s+2)/6:((t-n)/s+4)/6,[l,c,o]},_n=(e,t)=>{let n=(255&e)/255,r=fn(e),i=Me(r),a=Ae(i),o;switch(t){case`srgb`:o=r;break;case`srgb-linear`:o=i;break;case`xyz`:case`xyz-d65`:o=a;break;case`xyz-d50`:o=lt(a);break;case`lab`:o=pn(a);break;case`oklab`:o=mn(a);break;case`lch`:o=hn(pn(a));break;case`oklch`:o=hn(mn(a));break;case`hsl`:o=[gn(r)[0]*360,gn(r)[1],gn(r)[2]]}return[o[0],o[1],o[2],n]},vn=(e,t)=>{let n=e[0],r=e[1],i=e[2],a=e[3];switch(t){case`srgb`:return Xe([n,r,i,a]);case`srgb-linear`:return Ze([n,r,i,a]);case`xyz`:case`xyz-d65`:return Qe([n,r,i,a]);case`xyz-d50`:return Qe([...ut([n,r,i]),a]);case`lab`:return yn(ht([n,r,i]),a);case`oklab`:return yn(mt([n,r,i]),a);case`lch`:return yn(ht(pt([n,r,i])),a);case`oklch`:return yn(mt(pt([n,r,i])),a);case`hsl`:{let e=ft([n/360,r,i]);return Xe([e[0],e[1],e[2],a])}}},yn=(e,t)=>{let n=je(ke(e));return Xe([n[0],n[1],n[2],t])},bn=(e,t,n,r,i=`shorter`)=>{let a=n+r;if(a===0)return e;let o=((t-e)%360+360)%360;switch(i){case`shorter`:o>180&&(o-=360);break;case`longer`:o<180&&(o-=360);break;case`increasing`:break;case`decreasing`:o>0&&(o-=360)}return e+r/a*o},xn=(e,t)=>{let n,r=null;for(let e of t)if(e.type!==31&&e.type!==4){if(e.type===16)r=e.number;else if(D(e)&&e.value===`none`)r===null&&(r=0);else if(n===void 0)n=e;else throw Error(`Unexpected token in color-mix() component`)}if(n===void 0)throw Error(`color-mix() component is missing a color`);let i=n;return{color:V.parse(e,i),percentage:r}},Sn=[`srgb`,`srgb-linear`,`lab`,`oklab`,`lch`,`oklch`,`hsl`,`xyz`,`xyz-d50`,`xyz-d65`],Cn=(e,t,n,r,i,a)=>{let o=nn[i],s=[e[0]*e[3],e[1]*e[3],e[2]*e[3],e[3]],l=[t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]],u=n*s[3]+r*l[3];if(u<=0)return[0,0,0,0];let d=[0,0,0,u];for(let e=0;e<3;e++)e!==o&&(d[e]=(n*c(s,e)+r*c(l,e))/u);if(o!==void 0){let i=c(e,o),s=c(t,o);e[1]===0&&(i=s),t[1]===0&&(s=i),d[o]=bn(i,s,n,r,a)}return d},wn=(e,t)=>{let n=[[]];for(let e of t)e.type===4?n.push([]):n[n.length-1].push(e);let r=n.map(e=>e.filter(e=>e.type!==31));if(r.length!==3)throw Error(`color-mix() requires exactly two color components`);let i=r[0],a=i?i[0]:void 0,o=a!==void 0&&D(a)&&a.value===`in`;if(!i||i.length<2||!o)throw Error("color-mix() requires an interpolation space after `in`");let s=i[1];if(!s||!D(s))throw Error(`color-mix() space must be an identifier`);let c=s.value;if(Sn.indexOf(c)===-1)throw Error(`Unsupported color-mix() interpolation space "${c}"`);let l=`shorter`,u=i.slice(2);if(u.length>0){let e=u[0],t=u[1];if(!e||!t||!D(e)||!D(t)||t.value!==`hue`)throw Error(`Unsupported color-mix() hue method syntax`);if([`shorter`,`longer`,`increasing`,`decreasing`].indexOf(e.value)===-1)throw Error(`Unsupported color-mix() hue method "${e.value}"`);l=e.value}let d=r[1],f=r[2];if(!d||!f)throw Error(`color-mix() requires exactly two color components`);let p=xn(e,d),m=xn(e,f),h=p.percentage,g=m.percentage;if(h===null&&g===null)h=50,g=50;else if(h===null)h=100-(g??0);else if(g===null)g=100-h;else{let e=h+g;e>0&&(h=h/e*100,g=g/e*100)}let _=(h??0)/100,v=(g??0)/100,y=Cn(_n(p.color,c),_n(m.color,c),_,v,c,l);return vn(y,c)},Tn=(e,t)=>{try{return wn(e,t)}catch(t){return e.logger.warn(`Unsupported color-mix() value: ${t instanceof Error?t.message:t}`),0}},V={name:`color`,parse:(e,t)=>{if(t.type===18){let n=Mn[t.name];if(n===void 0)throw Error(`Attempting to parse an unsupported color function "${t.name}"`);return n(e,t.values)}if(t.type===5){let[e,n,r,i]=En(t);return Je(e,n,r,i)}if(t.type===20){let e=Pn[t.value.toUpperCase()];if(e!==void 0)return e}return 0}},En=e=>{if(e.value.length===3){let t=e.value.substring(0,1),n=e.value.substring(1,2),r=e.value.substring(2,3);return[parseInt(t+t,16),parseInt(n+n,16),parseInt(r+r,16),1]}if(e.value.length===4){let t=e.value.substring(0,1),n=e.value.substring(1,2),r=e.value.substring(2,3),i=e.value.substring(3,4);return[parseInt(t+t,16),parseInt(n+n,16),parseInt(r+r,16),parseInt(i+i,16)/255]}if(e.value.length===6){let t=e.value.substring(0,2),n=e.value.substring(2,4),r=e.value.substring(4,6);return[parseInt(t,16),parseInt(n,16),parseInt(r,16),1]}if(e.value.length===8){let t=e.value.substring(0,2),n=e.value.substring(2,4),r=e.value.substring(4,6),i=e.value.substring(6,8);return[parseInt(t,16),parseInt(n,16),parseInt(r,16),parseInt(i,16)/255]}return[0,0,0,1]},Dn=(e,t)=>{let n=t.filter(O);if(Ye(n))throw Error(`Relative color not supported for rgb()`);if(n.length===3||n.length===4){let e=B(c(n,0),0),t=B(c(n,1),1),r=B(c(n,2),2),i=n.length===4?B(c(n,3),3):1;return Je(e,t,r,i)}if(n.length===5){let e=c(n,3);if(e.type===6&&e.value===`/`){let e=B(c(n,0),0),t=B(c(n,1),1),r=B(c(n,2),2),i=B(c(n,4),3);return Je(e,t,r,i)}}return 0},On=(e,t)=>{let n=t.filter(O),r=n[0],i=r&&r.type===20?r.value:`unknown`;if(Ye(n)){let t=(e,t)=>{if(E(t))return t.number;let n=e=>e===`r`||e===`x`?0:e===`g`||e===`y`?1:2;if(D(t)){let r=n(t.value);return c(e,r)}let r=e=>{let t=e.filter(O),n=`(`;for(let e of t)n+=e.type===18&&e.name===`calc`?r(e.values):E(e)?e.number:e.type===6||D(e)?e.value:``;return n+=`)`,n};if(t.type===18){let n=t.values.filter(O);if(t.name===`calc`){let t=r(n).replace(/r|x/,e[0].toString()).replace(/g|y/,e[1].toString()).replace(/b|z/,e[2].toString());return Oe(t)}}return null},r=c(n,1),i=r.type===18?r.name:D(r)||r.type===5?`rgb`:`unknown`,a=c(n,2),o=D(a)?a.value:`unknown`,s=r.type===18?r.values:D(r)?[r]:[];if(D(r)){if(Pn[r.value.toUpperCase()]===void 0)throw Error(`Attempting to use unknown color in relative color 'from'`);{let t=Nn(e,r.value),n=255&t,i=255&t>>8,a=255&t>>16;s=[{type:17,number:255&t>>24,flags:1},{type:17,number:a,flags:1},{type:17,number:i,flags:1},{type:17,number:n>1?n/255:n,flags:1}]}}else if(r.type===5){let[e,t,n,i]=En(r);s=[{type:17,number:e,flags:1},{type:17,number:t,flags:1},{type:17,number:n,flags:1},{type:17,number:i>1?i/255:i,flags:1}]}if(s.length===0)throw Error(`Attempting to use unknown color in relative color 'from'`);if(o===`unknown`)throw Error(`Attempting to use unknown colorspace in relative color 'to'`);let l=An[i],u=jn[o],d=kn[o];if(l===void 0)throw Error(`Attempting to parse an unsupported color space "${i}" for color() function`);if(u===void 0)throw Error(`Attempting to parse an unsupported color space "${o}" for color() function`);let f=u(l(e,s)),p=t(f,c(n,3)),m=t(f,c(n,4)),h=t(f,c(n,5)),g=n[6],_=n[7],v=g!==void 0&&g.type===6&&g.value===`/`&&_!==void 0&&E(_)?_.number:1;if(p===null||m===null||h===null)throw Error(`Invalid relative color in color() function`);if(d===void 0)throw Error(`Attempting to parse an unsupported color space "${o}" for color() function`);return d([p,m,h,v])}{let e=i,t=kn[e];if(t===void 0)throw Error(`Attempting to parse an unsupported color space "${e}" for color() function`);let r=c(n,1),a=c(n,2),o=c(n,3),s=n[4],l=n[5];return t([E(r)?r.number:0,E(a)?a.number:0,E(o)?o.number:0,s!==void 0&&s.type===6&&s.value===`/`&&l!==void 0&&E(l)?l.number:1])}},kn={srgb:Xe,"srgb-linear":Ze,"display-p3":Nt,"a98-rgb":zt,"prophoto-rgb":Kt,xyz:Tt,"xyz-d50":Et,"xyz-d65":Tt,rec2020:tn},An={rgb:gt,hsl:_t,lab:vt,lch:yt,oklab:xt,oklch:bt},jn={srgb:Ne,"srgb-linear":Pe,"display-p3":Mt,"a98-rgb":Rt,"prophoto-rgb":Gt,xyz:Ct,"xyz-d50":wt,"xyz-d65":Ct,rec2020:en},Mn={hsl:at,hsla:at,rgb:Dn,rgba:Dn,lch:rt,oklch:nt,oklab:tt,lab:$e,color:On,"color-mix":Tn},Nn=(e,t)=>V.parse(e,Se.create(t).parseComponentValue()),Pn={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Fn=e=>e.nodeType===Node.ELEMENT_NODE,In=e=>e.nodeType===Node.TEXT_NODE,Ln=e=>typeof e.className==`object`,Rn=e=>Fn(e)&&e.style!==void 0&&!Ln(e),zn=e=>e.tagName===`INPUT`,Bn=e=>e.tagName===`HTML`,Vn=e=>e.tagName===`svg`,Hn=e=>e.tagName===`BODY`,Un=e=>e.tagName===`CANVAS`,Wn=e=>e.tagName===`VIDEO`,Gn=e=>e.tagName===`IMG`,Kn=e=>e.tagName===`IFRAME`,qn=e=>e.tagName===`STYLE`,Jn=e=>e.tagName===`SCRIPT`,Yn=e=>e.tagName===`TEXTAREA`,Xn=e=>e.tagName===`SELECT`,Zn=e=>e.tagName===`SLOT`,Qn=e=>e.tagName===`LI`,$n=e=>e.tagName===`OL`,er=e=>!Ln(e)&&e.tagName.indexOf(`-`)>0,tr=/* @__PURE__ */ new Set([`IMG`,`VIDEO`,`AUDIO`,`CANVAS`,`IFRAME`,`INPUT`,`TEXTAREA`,`SELECT`,`BR`,`HR`,`META`,`LINK`,`BASE`,`COL`,`SOURCE`,`TRACK`,`WBR`,`AREA`,`PARAM`,`EMBED`,`OBJECT`]),nr=e=>!Ln(e)&&!tr.has(e.tagName),rr={name:`list-style-type`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`disc`:return 0;case`circle`:return 1;case`square`:return 2;case`decimal`:return 3;case`cjk-decimal`:return 4;case`decimal-leading-zero`:return 5;case`lower-roman`:return 6;case`upper-roman`:return 7;case`lower-greek`:return 8;case`lower-alpha`:return 9;case`upper-alpha`:return 10;case`arabic-indic`:return 11;case`armenian`:return 12;case`bengali`:return 13;case`cambodian`:return 14;case`cjk-earthly-branch`:return 15;case`cjk-heavenly-stem`:return 16;case`cjk-ideographic`:return 17;case`devanagari`:return 18;case`ethiopic-numeric`:return 19;case`georgian`:return 20;case`gujarati`:return 21;case`gurmukhi`:return 22;case`hebrew`:return 52;case`hiragana`:return 23;case`hiragana-iroha`:return 24;case`japanese-formal`:return 25;case`japanese-informal`:return 26;case`kannada`:return 27;case`katakana`:return 28;case`katakana-iroha`:return 29;case`khmer`:return 30;case`korean-hangul-formal`:return 31;case`korean-hanja-formal`:return 32;case`korean-hanja-informal`:return 33;case`lao`:return 34;case`lower-armenian`:return 35;case`malayalam`:return 36;case`mongolian`:return 37;case`myanmar`:return 38;case`oriya`:return 39;case`persian`:return 40;case`simp-chinese-formal`:return 41;case`simp-chinese-informal`:return 42;case`tamil`:return 43;case`telugu`:return 44;case`thai`:return 45;case`tibetan`:return 46;case`trad-chinese-formal`:return 47;case`trad-chinese-informal`:return 48;case`upper-armenian`:return 49;case`disclosure-open`:return 50;case`disclosure-closed`:return 51;default:return-1}}},H=(e,t)=>(e&t)!==0;var ir=class{counters={};getCounterValue(e){let t=this.counters[e];return t&&t.length?c(t,t.length-1):1}getCounterValues(e){return this.counters[e]||[]}pop(e){e.forEach(e=>this.counters[e]?.pop())}parse(e){let t=e.counterIncrement,n=e.counterReset,r=!0;t!==null&&t.forEach(e=>{let t=this.counters[e.counter];if(t&&e.increment!==0){r=!1,t.length||t.push(1);let n=Math.max(0,t.length-1);t[n]=(t[n]??0)+e.increment}});let i=[];return r&&n.forEach(e=>{let t=this.counters[e.counter];i.push(e.counter),t||=this.counters[e.counter]=[],t.push(e.reset)}),i}};let ar={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:[`M`,`CM`,`D`,`CD`,`C`,`XC`,`L`,`XL`,`X`,`IX`,`V`,`IV`,`I`]},or={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:/* @__PURE__ */ `Ք.Փ.Ւ.Ց.Ր.Տ.Վ.Ս.Ռ.Ջ.Պ.Չ.Ո.Շ.Ն.Յ.Մ.Ճ.Ղ.Ձ.Հ.Կ.Ծ.Խ.Լ.Ի.Ժ.Թ.Ը.Է.Զ.Ե.Դ.Գ.Բ.Ա`.split(`.`)},sr={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:/* @__PURE__ */ `י׳.ט׳.ח׳.ז׳.ו׳.ה׳.ד׳.ג׳.ב׳.א׳.ת.ש.ר.ק.צ.פ.ע.ס.נ.מ.ל.כ.יט.יח.יז.טז.טו.י.ט.ח.ז.ו.ה.ד.ג.ב.א`.split(`.`)},cr={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:/* @__PURE__ */ `ჵ.ჰ.ჯ.ჴ.ხ.ჭ.წ.ძ.ც.ჩ.შ.ყ.ღ.ქ.ფ.ჳ.ტ.ს.რ.ჟ.პ.ო.ჲ.ნ.მ.ლ.კ.ი.თ.ჱ.ზ.ვ.ე.დ.გ.ბ.ა`.split(`.`)},lr=(e,t,n,r,i,a)=>e<t||e>n?_r(e,i,a.length>0):r.integers.reduce((t,n,i)=>{for(;e>=n;)e-=n,t+=r.values[i];return t},``)+a,ur=(e,t,n,r)=>{let i=``;do n||e--,i=r(e)+i,e/=t;while(e*t>=t);return i},U=(e,t,n,r,i)=>{let a=n-t+1;return(e<0?`-`:``)+(ur(Math.abs(e),a,r,e=>String.fromCodePoint(Math.floor(e%a)+t))+i)},dr=(e,t,n=`. `)=>{let r=t.length;return ur(Math.abs(e),r,!1,e=>String(t[Math.floor(e%r)]))+n},fr=(e,t,n,r,i,a)=>{if(e<-9999||e>9999)return _r(e,4,i.length>0);let o=Math.abs(e),s=i;if(o===0)return t[0]+s;for(let r=0;o>0&&r<=4;r++){let i=o%10;i===0&&H(a,1)&&s!==``?s=t[i]+s:i>1||i===1&&r===0||i===1&&r===1&&H(a,2)||i===1&&r===1&&H(a,4)&&e>100||i===1&&r>1&&H(a,8)?s=(t[i]??``)+(r>0?n[r-1]??``:``)+s:i===1&&r>0&&(s=(n[r-1]??``)+s),o=Math.floor(o/10)}return(e<0?r:``)+s},pr=`十百千萬`,mr=`拾佰仟萬`,hr=`マイナス`,gr=`마이너스`,_r=(e,t,n)=>{let r=n?`. `:``,i=n?`、`:``,a=n?`, `:``,o=n?` `:``;switch(t){case 0:return`•`+o;case 1:return`◦`+o;case 2:return`◾`+o;case 5:let t=U(e,48,57,!0,r);return t.length<4?`0${t}`:t;case 4:return dr(e,`〇一二三四五六七八九`,i);case 6:return lr(e,1,3999,ar,3,r).toLowerCase();case 7:return lr(e,1,3999,ar,3,r);case 8:return U(e,945,969,!1,r);case 9:return U(e,97,122,!1,r);case 10:return U(e,65,90,!1,r);case 11:return U(e,1632,1641,!0,r);case 12:case 49:return lr(e,1,9999,or,3,r);case 35:return lr(e,1,9999,or,3,r).toLowerCase();case 13:return U(e,2534,2543,!0,r);case 14:case 30:return U(e,6112,6121,!0,r);case 15:return dr(e,`子丑寅卯辰巳午未申酉戌亥`,i);case 16:return dr(e,`甲乙丙丁戊己庚辛壬癸`,i);case 17:case 48:return fr(e,`零一二三四五六七八九`,pr,`負`,i,14);case 47:return fr(e,`零壹貳參肆伍陸柒捌玖`,mr,`負`,i,15);case 42:return fr(e,`零一二三四五六七八九`,pr,`负`,i,14);case 41:return fr(e,`零壹贰叁肆伍陆柒捌玖`,mr,`负`,i,15);case 26:return fr(e,`〇一二三四五六七八九`,`十百千万`,hr,i,0);case 25:return fr(e,`零壱弐参四伍六七八九`,`拾百千万`,hr,i,7);case 31:return fr(e,`영일이삼사오육칠팔구`,`십백천만`,gr,a,7);case 33:return fr(e,`零一二三四五六七八九`,`十百千萬`,gr,a,0);case 32:return fr(e,`零壹貳參四五六七八九`,`拾百千`,gr,a,7);case 18:return U(e,2406,2415,!0,r);case 20:return lr(e,1,19999,cr,3,r);case 21:return U(e,2790,2799,!0,r);case 22:return U(e,2662,2671,!0,r);case 52:return lr(e,1,10999,sr,3,r);case 23:return dr(e,`あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん`);case 24:return dr(e,`いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす`);case 27:return U(e,3302,3311,!0,r);case 28:return dr(e,`アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン`,i);case 29:return dr(e,`イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス`,i);case 34:return U(e,3792,3801,!0,r);case 37:return U(e,6160,6169,!0,r);case 38:return U(e,4160,4169,!0,r);case 39:return U(e,2918,2927,!0,r);case 40:return U(e,1776,1785,!0,r);case 43:return U(e,3046,3055,!0,r);case 44:return U(e,3174,3183,!0,r);case 45:return U(e,3664,3673,!0,r);case 46:return U(e,3872,3881,!0,r);default:return U(e,48,57,!0,r)}},vr={name:`display`,initialValue:`inline-block`,prefix:!1,type:1,parse:(e,t)=>t.filter(D).reduce((e,t)=>e|yr(t.value),0)},yr=e=>{switch(e){case`block`:case`-webkit-box`:return 2;case`inline`:return 4;case`run-in`:return 8;case`flow`:return 16;case`flow-root`:return 32;case`table`:return 64;case`flex`:case`-webkit-flex`:return 128;case`grid`:case`-ms-grid`:return 256;case`ruby`:return 512;case`subgrid`:return 1024;case`list-item`:return 2048;case`table-row-group`:return 4096;case`table-header-group`:return 8192;case`table-footer-group`:return 16384;case`table-row`:return 32768;case`table-cell`:return 65536;case`table-column-group`:return 131072;case`table-column`:return 262144;case`table-caption`:return 524288;case`ruby-base`:return 1048576;case`ruby-text`:return 2097152;case`ruby-base-container`:return 4194304;case`ruby-text-container`:return 8388608;case`contents`:return 16777216;case`inline-block`:return 33554432;case`inline-list-item`:return 67108864;case`inline-table`:return 134217728;case`inline-flex`:return 268435456;case`inline-grid`:return 536870912}return 0},br={name:`float`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`left`:return 1;case`right`:return 2;case`inline-start`:return 3;case`inline-end`:return 4}return 0}},xr={name:`overflow`,initialValue:`visible`,prefix:!1,type:1,parse:(e,t)=>t.filter(D).map(e=>{switch(e.value){case`hidden`:return 1;case`scroll`:return 2;case`clip`:return 3;case`auto`:return 4;default:return 0}})},Sr={name:`text-decoration-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},Cr={name:`text-decoration-line`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>t.filter(D).map(e=>{switch(e.value){case`underline`:return 1;case`overline`:return 2;case`line-through`:return 3;case`none`:return 4}return 0}).filter(e=>e!==0)},wr={name:`content`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>{if(t.length===0)return[];let n=t[0];return n&&n.type===20&&n.value===`none`?[]:t}},Tr={name:`quotes`,initialValue:`none`,prefix:!0,type:1,parse:(e,t)=>{if(t.length===0)return null;let n=t[0];if(n&&n.type===20&&n.value===`none`)return null;let r=[],i=t.filter(Ce);if(i.length%2!=0)return null;for(let e=0;e<i.length;e+=2){let t=c(i,e).value,n=c(i,e+1).value;r.push({open:t,close:n})}return r}},Er=(e,t,n)=>{if(!e)return``;let r=e[Math.min(t,e.length-1)];return r?n?r.open:r.close:``},Dr=(e,t)=>{let n=[],r=e.filter(Te);for(let e=0;e<r.length;e++){let i=r[e],a=r[e+1];if(i&&i.type===20){let e=a&&E(a)?a.number:t;n.push([i.value,e])}}return n},Or={name:`counter-increment`,initialValue:`none`,prefix:!0,type:1,parse:(e,t)=>{if(t.length===0)return null;let n=t[0];return n&&n.type===20&&n.value===`none`?null:Dr(t,1).map(([e,t])=>({counter:e,increment:t}))}},kr={name:`counter-reset`,initialValue:`none`,prefix:!0,type:1,parse:(e,t)=>t.length===0?[]:Dr(t,0).filter(([e])=>e!==`none`).map(([e,t])=>({counter:e,reset:t}))},Ar={name:`background-clip`,initialValue:`border-box`,prefix:!1,type:1,parse:(e,t)=>t.map(e=>{if(D(e))switch(e.value){case`padding-box`:return 1;case`content-box`:return 2;case`text`:return 3}return 0})},jr={name:`background-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},Mr=(e,t)=>{let n=V.parse(e,c(t,0)),r=t[1];return r&&M(r)?{color:n,stop:r}:{color:n,stop:null}},W=(e,t)=>{let n=e.map(e=>({color:e.color,stop:e.stop})),r=c(n,0),i=c(n,n.length-1);r.stop===null&&(r.stop=N),i.stop===null&&(i.stop=F);let a=[],o=0;for(let e=0;e<n.length;e++){let r=c(n,e).stop;if(r!==null){let e=I(r,t);e>o?a.push(e):a.push(o),o=e}else a.push(null)}let s=null;for(let e=0;e<a.length;e++){let t=c(a,e);if(t===null)s===null&&(s=e);else if(s!==null){let n=e-s,r=(t-a[s-1])/(n+1);for(let e=1;e<=n;e++)a[s+e-1]=r*e;s=null}}return n.map(({color:e},n)=>({color:e,stop:Math.max(Math.min(1,a[n]/t),0)}))},Nr=(e,t,n)=>{let r=t/2,i=n/2,a=I(e[0],t)-r,o=i-I(e[1],n);return(Math.atan2(o,a)+Math.PI*2)%(Math.PI*2)},Pr=(e,t,n)=>{let r=typeof e==`number`?e:Nr(e,t,n),i=Math.abs(t*Math.sin(r))+Math.abs(n*Math.cos(r)),a=t/2,o=n/2,s=i/2,c=Math.sin(r-Math.PI/2)*s,l=Math.cos(r-Math.PI/2)*s;return[i,a-l,a+l,o-c,o+c]},G=(e,t)=>Math.sqrt(e*e+t*t),Fr=(e,t,n,r,i)=>[[0,0],[0,t],[e,0],[e,t]].reduce((e,t)=>{let[a,o]=t,s=G(n-a,r-o);return(i?s<e.optimumDistance:s>e.optimumDistance)?{optimumCorner:t,optimumDistance:s}:e},{optimumDistance:i?1/0:-1/0,optimumCorner:null}).optimumCorner,Ir=(e,t,n,r,i)=>{let a=0,o=0;switch(e.size){case 0:e.shape===0?a=o=Math.min(Math.abs(t),Math.abs(t-r),Math.abs(n),Math.abs(n-i)):e.shape===1&&(a=Math.min(Math.abs(t),Math.abs(t-r)),o=Math.min(Math.abs(n),Math.abs(n-i)));break;case 2:if(e.shape===0)a=o=Math.min(G(t,n),G(t,n-i),G(t-r,n),G(t-r,n-i));else if(e.shape===1){let e=Math.min(Math.abs(n),Math.abs(n-i))/Math.min(Math.abs(t),Math.abs(t-r)),[s,c]=Fr(r,i,t,n,!0);a=G(s-t,(c-n)/e),o=e*a}break;case 1:e.shape===0?a=o=Math.max(Math.abs(t),Math.abs(t-r),Math.abs(n),Math.abs(n-i)):e.shape===1&&(a=Math.max(Math.abs(t),Math.abs(t-r)),o=Math.max(Math.abs(n),Math.abs(n-i)));break;case 3:if(e.shape===0)a=o=Math.max(G(t,n),G(t,n-i),G(t-r,n),G(t-r,n-i));else if(e.shape===1){let e=Math.max(Math.abs(n),Math.abs(n-i))/Math.max(Math.abs(t),Math.abs(t-r)),[s,c]=Fr(r,i,t,n,!1);a=G(s-t,(c-n)/e),o=e*a}}if(Array.isArray(e.size)){let t=e.size;a=I(c(t,0),r),o=t.length===2?I(c(t,1),i):a}return[a,o]},Lr=(e,t)=>{let n=L(180),r=[];return k(t).forEach((t,i)=>{if(i===0){let r=t[0];if(r&&r.type===20&&r.value===`to`){n=qe(t);return}if(r&&Ke(r)){n=Ge.parse(e,r);return}}let a=Mr(e,t);r.push(a)}),{angle:n,stops:r,type:1}},Rr=(e,t)=>{let n=L(180),r=[];return k(t).forEach((t,i)=>{if(i===0){let r=t[0];if(r&&r.type===20&&[`top`,`left`,`right`,`bottom`].indexOf(r.value)!==-1){n=qe(t);return}if(r&&Ke(r)){n=(Ge.parse(e,r)+L(270))%L(360);return}}let a=Mr(e,t);r.push(a)}),{angle:n,stops:r,type:1}},zr=(e,t)=>{let n=L(180),r=[],i=1;return k(t).forEach((t,n)=>{let a=t[0];if(a){if(n===0){if(D(a)&&a.value===`linear`){i=1;return}if(D(a)&&a.value===`radial`){i=2;return}}if(a.type===18){if(a.name===`from`){let t=V.parse(e,c(a.values,0));r.push({stop:N,color:t})}else if(a.name===`to`){let t=V.parse(e,c(a.values,0));r.push({stop:F,color:t})}else if(a.name===`color-stop`){let t=a.values.filter(O);if(t.length===2){let n=V.parse(e,c(t,1)),i=c(t,0);E(i)&&r.push({stop:{type:16,number:i.number*100,flags:i.flags},color:n})}}}}}),i===1?{angle:(n+L(180))%L(360),stops:r,type:i}:{size:3,shape:0,stops:r,position:[],type:i}},Br=`closest-side`,Vr=`farthest-side`,Hr=`closest-corner`,Ur=`farthest-corner`,Wr=`circle`,Gr=`ellipse`,Kr=`cover`,qr=`contain`,Jr=(e,t)=>{let n=1,r=3,i=[],a=[];return k(t).forEach((t,o)=>{let s=!0;if(o===0){let e=!1;s=t.reduce((t,i)=>{if(e){if(D(i))switch(i.value){case`center`:return a.push(P),t;case`top`:case`left`:return a.push(N),t;case`right`:case`bottom`:return a.push(F),t}else(M(i)||Fe(i))&&a.push(i)}else if(D(i))switch(i.value){case Wr:return n=0,!1;case Gr:return n=1,!1;case`at`:return e=!0,!1;case Br:return r=0,!1;case Kr:case Vr:return r=1,!1;case qr:case Hr:return r=2,!1;case Ur:return r=3,!1}else if(Fe(i)||M(i))return Array.isArray(r)||(r=[]),r.push(i),!1;return t},s)}if(s){let n=Mr(e,t);i.push(n)}}),{size:r,shape:n,stops:i,position:a,type:2}},Yr=(e,t)=>{let n=1,r=3,i=[],a=[];return k(t).forEach((t,o)=>{let s=!0;if(o===0?s=t.reduce((e,t)=>{if(D(t))switch(t.value){case`center`:return a.push(P),!1;case`top`:case`left`:return a.push(N),!1;case`right`:case`bottom`:return a.push(F),!1}else if(M(t)||Fe(t))return a.push(t),!1;return e},s):o===1&&(s=t.reduce((e,t)=>{if(D(t))switch(t.value){case Wr:return n=0,!1;case Gr:return n=1,!1;case qr:case Br:return r=0,!1;case Vr:return r=1,!1;case Hr:return r=2,!1;case Kr:case Ur:return r=3,!1}else if(Fe(t)||M(t))return Array.isArray(r)||(r=[]),r.push(t),!1;return e},s)),s){let n=Mr(e,t);i.push(n)}}),{size:r,shape:n,stops:i,position:a,type:2}},Xr=(e,t)=>({...Lr(e,t),type:3}),Zr=(e,t)=>({...Jr(e,t),type:4}),Qr=(e,t)=>{let n=0,r=[],i=[];return k(t).forEach((t,a)=>{let o=!0;if(a===0){let i=!1,a=!1;o=t.reduce((t,o)=>{if(D(o))switch(o.value){case`from`:return i=!0,a=!1,!1;case`at`:return i=!1,a=!0,!1;case`center`:return r.push(P),t;case`top`:case`left`:return r.push(N),t;case`right`:case`bottom`:return r.push(F),t}return i?(n=Ge.parse(e,o),!1):(a&&M(o)&&r.push(o),t)},!0)}o&&t.length>0&&i.push(Mr(e,t))}),{type:5,angle:n,position:r,stops:i}},$r=(e,t)=>({...Qr(e,t),type:6}),ei=e=>e&&(T(e)&&(e.unit===`dppx`||e.unit===`x`)||E(e))?e.number:1,ti=(e,t)=>{let n=k(t),r=e.config.window.devicePixelRatio||1,i=[];for(let e of n){let t=e.find(e=>e.type===22||e.type===18);if(!t)continue;let n=e.find(e=>T(e)||E(e));i.push({imageToken:t,resolution:ei(n)})}if(i.length===0)throw Error(`image-set() requires at least one image candidate`);let a=i.filter(e=>e.resolution>=r).sort((e,t)=>e.resolution-t.resolution),o=c(a.length>0?a:i.slice().sort((e,t)=>t.resolution-e.resolution),0);return ci.parse(e,o.imageToken)},ni=e=>e.type===1,ri=e=>e.type===2,ii=e=>e.type===3,ai=e=>e.type===4,oi=e=>e.type===5,si=e=>e.type===6,ci={name:`image`,parse:(e,t)=>{if(t.type===22){let n={url:t.value,type:0};return e.cache.addImage(t.value),n}if(t.type===18){let n=ui[t.name];if(n===void 0)throw Error(`Attempting to parse an unsupported image function "${t.name}"`);return n(e,t.values)}throw Error(`Unsupported image type ${t.type}`)}};function li(e){return(e.type!==20||e.value!==`none`)&&(e.type!==18||!!ui[e.name])}let ui={"linear-gradient":Lr,"-moz-linear-gradient":Rr,"-ms-linear-gradient":Rr,"-o-linear-gradient":Rr,"-webkit-linear-gradient":Rr,"radial-gradient":Jr,"-moz-radial-gradient":Yr,"-ms-radial-gradient":Yr,"-o-radial-gradient":Yr,"-webkit-radial-gradient":Yr,"-webkit-gradient":zr,"repeating-linear-gradient":Xr,"-webkit-repeating-linear-gradient":Xr,"-moz-repeating-linear-gradient":Xr,"-ms-repeating-linear-gradient":Xr,"-o-repeating-linear-gradient":Xr,"repeating-radial-gradient":Zr,"-webkit-repeating-radial-gradient":Zr,"-moz-repeating-radial-gradient":Zr,"conic-gradient":Qr,"-webkit-conic-gradient":Qr,"-moz-conic-gradient":Qr,"repeating-conic-gradient":$r,"-webkit-repeating-conic-gradient":$r,"-moz-repeating-conic-gradient":$r,"image-set":ti,"-webkit-image-set":ti},di={name:`background-image`,initialValue:`none`,type:1,prefix:!1,skipCache:!0,parse:(e,t)=>{if(t.length===0)return[];let n=t[0];return n&&n.type===20&&n.value===`none`?[]:t.filter(e=>O(e)&&li(e)).map(t=>ci.parse(e,t))}},fi={name:`background-origin`,initialValue:`border-box`,prefix:!1,type:1,parse:(e,t)=>t.map(e=>{if(D(e))switch(e.value){case`padding-box`:return 1;case`content-box`:return 2}return 0})},pi={name:`background-position`,initialValue:`0% 0%`,type:1,prefix:!1,parse:(e,t)=>k(t).map(e=>e.map(ze).filter(e=>e!==null)).map(Ve)},mi={name:`background-repeat`,initialValue:`repeat`,prefix:!1,type:1,parse:(e,t)=>k(t).map(e=>e.filter(D).map(e=>e.value).join(` `)).map(hi)},hi=e=>{switch(e){case`no-repeat`:return 1;case`repeat-x`:case`repeat no-repeat`:return 2;case`repeat-y`:case`no-repeat repeat`:return 3;default:return 0}},gi={name:`background-size`,initialValue:`0`,prefix:!1,type:1,parse:(e,t)=>k(t).map(e=>e.map(e=>_i(e)?e:ze(e)).filter(e=>e!==null))},_i=e=>D(e)||M(e),vi=e=>({name:`border-${e}-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`}),yi=vi(`top`),bi=vi(`right`),xi=vi(`bottom`),Si=vi(`left`),Ci=e=>({name:`border-${e}-radius`,initialValue:`0 0`,prefix:!1,type:1,parse:(e,t)=>Ve(t.filter(M))}),wi=Ci(`top-left`),Ti=Ci(`top-right`),Ei=Ci(`bottom-right`),Di=Ci(`bottom-left`),Oi=e=>({name:`border-${e}-style`,initialValue:`solid`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`none`:return 0;case`dashed`:return 2;case`dotted`:return 3;case`double`:return 4}return 1}}),ki=Oi(`top`),Ai=Oi(`right`),ji=Oi(`bottom`),Mi=Oi(`left`),Ni=e=>({name:`border-${e}-width`,initialValue:`0`,type:0,prefix:!1,parse:(e,t)=>T(t)?t.number:0}),Pi=Ni(`top`),Fi=Ni(`right`),Ii=Ni(`bottom`),Li=Ni(`left`),Ri={type:0},zi=e=>{let[t]=e;return t?D(t)?t.value===`farthest-side`?`farthest-side`:`closest-side`:M(t)?t:`closest-side`:`closest-side`},Bi=e=>{let t=null,n=null;for(let r of e)if(D(r))switch(r.value){case`left`:t=N;break;case`right`:t=F;break;case`top`:n=N;break;case`bottom`:n=F;break;case`center`:t===null?t=P:n===null&&(n=P)}else M(r)&&(t===null?t=r:n===null&&(n=r));return{cx:t??P,cy:n??P}},Vi=e=>{let t=[];for(let n of e)if(n.type!==31){if(D(n)&&n.value===`round`)break;M(n)&&t.push(n)}let n=t[0]??N,r=t[1]??n;return{type:1,top:n,right:r,bottom:t[2]??n,left:t[3]??r}},Hi=e=>{let t=e.filter(Te),n=t.findIndex(e=>we(e,`at`)),r=n===-1?t:t.slice(0,n),i=n===-1?[]:t.slice(n+1);return{type:2,radius:zi(r),...Bi(i)}},Ui=e=>{let t=e.filter(Te),n=t.findIndex(e=>we(e,`at`)),r=n===-1?t:t.slice(0,n),i=n===-1?[]:t.slice(n+1);return{type:3,rx:zi(r.slice(0,1)),ry:zi(r.slice(1,2)),...Bi(i)}},Wi=e=>{let t=k(e),n=[];for(let e of t){if(e.length===1&&e[0]&&D(e[0]))continue;let t=e.filter(M);t.length>=2&&n.push([c(t,0),c(t,1)])}return{type:4,points:n}},Gi=e=>{let t=e.find(e=>e.type===0);return t?{type:5,d:t.value}:Ri},Ki=e=>{let t=[];for(let n of e)if(n.type!==31){if(D(n)&&n.value===`round`)break;M(n)&&t.push(n)}return t.length<4?Ri:{type:6,x:c(t,0),y:c(t,1),width:c(t,2),height:c(t,3)}},qi=e=>{let t=[];for(let n of e)if(n.type!==31){if(D(n)){if(n.value===`round`)break;if(n.value===`auto`){t.push(`auto`);continue}return Ri}M(n)&&t.push(n)}if(t.length!==4)return Ri;let n=(e,t)=>e===`auto`?t===`top`||t===`left`?N:F:e;return{type:1,top:n(c(t,0),`top`),right:n(c(t,1),`right`),bottom:n(c(t,2),`bottom`),left:n(c(t,3),`left`)}},Ji={name:`clip-path`,initialValue:`none`,prefix:!1,type:0,parse:(e,t)=>{if(D(t)&&t.value===`none`)return Ri;if(t.type===18)switch(t.name){case`inset`:return Vi(t.values);case`circle`:return Hi(t.values);case`ellipse`:return Ui(t.values);case`polygon`:return Wi(t.values);case`path`:return Gi(t.values);case`xywh`:return Ki(t.values);case`rect`:return qi(t.values)}return Ri}},Yi={name:`color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},Xi={name:`direction`,initialValue:`ltr`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`rtl`:return 1;default:return 0}}},Zi={name:`font-family`,initialValue:``,prefix:!1,type:1,parse:(e,t)=>{let n=[],r=[],i=[],a=!1;return t.forEach(e=>{switch(e.type){case 20:n.push(e.value);break;case 0:a=!0,n.push(e.value);break;case 17:n.push(e.number.toString());break;case 4:r.push(n.join(` `)),i.push(a),a=!1,n.length=0}}),n.length&&(r.push(n.join(` `)),i.push(a)),r.map((e,t)=>i[t]||e.indexOf(` `)!==-1?`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\a `).replace(/\r/g,`\\d `).replace(/\f/g,`\\c `)}'`:e)}},Qi={name:`font-size`,initialValue:`0`,prefix:!1,type:3,format:`length`},$i={name:`letter-spacing`,initialValue:`0`,prefix:!1,type:0,parse:(e,t)=>t.type===20&&t.value===`normal`?0:t.type===17||t.type===15?t.number:0},ea={name:`line-break`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`strict`:return`strict`;default:return`normal`}}},ta={name:`line-height`,initialValue:`normal`,prefix:!1,type:4},na=(e,t)=>D(e)&&e.value===`normal`?1.2*t:e.type===17?t*e.number:M(e)?I(e,t):t,ra={name:`list-style-image`,initialValue:`none`,type:0,prefix:!1,skipCache:!0,parse:(e,t)=>t.type===20&&t.value===`none`||!li(t)?null:ci.parse(e,t)},ia={name:`list-style-position`,initialValue:`outside`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`inside`:return 0;default:return 1}}},aa=e=>({name:`margin-${e}`,initialValue:`0`,prefix:!1,type:4}),oa=aa(`top`),sa=aa(`right`),ca=aa(`bottom`),la=aa(`left`),ua={name:`overflow-wrap`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`break-word`:return`break-word`;default:return`normal`}}},da=e=>({name:`padding-${e}`,initialValue:`0`,prefix:!1,type:3,format:`length-percentage`}),fa=da(`top`),pa=da(`right`),ma=da(`bottom`),ha=da(`left`),ga={name:`text-align`,initialValue:`left`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`right`:return 2;case`center`:case`justify`:return 1;default:return 0}}},_a={name:`position`,initialValue:`static`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`relative`:return 1;case`absolute`:return 2;case`fixed`:return 3;case`sticky`:return 4}return 0}},va={name:`text-shadow`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>t.length===1&&we(c(t,0),`none`)?[]:k(t).map(t=>{let n={color:0,offsetX:N,offsetY:N,blur:N},r=0;for(let i=0;i<t.length;i++){let a=t[i];a&&(Fe(a)?(r===0?n.offsetX=a:r===1?n.offsetY=a:n.blur=a,r++):n.color=V.parse(e,a))}return n})},ya={name:`text-transform`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`uppercase`:return 2;case`lowercase`:return 1;case`capitalize`:return 3}return 0}},ba={name:`transform`,initialValue:`none`,prefix:!0,type:0,parse:(e,t)=>{if(t.type===20&&t.value===`none`)return null;if(t.type===18){let n=xa[t.name];if(n===void 0)throw Error(`Attempting to parse an unsupported transform function "${t.name}"`);return n(e,t.values)}return null}},xa={matrix:(e,t)=>{let n=t.filter(e=>e.type===17).map(e=>e.number);return n.length===6?n:null},matrix3d:(e,t)=>{let n=t.filter(e=>e.type===17).map(e=>e.number);return n.length===16?[c(n,0),c(n,1),c(n,4),c(n,5),c(n,12),c(n,13)]:null},rotate:(e,t)=>{if(t.length!==1)return null;let n=c(t,0),r=0;if(n.type===17&&n.number===0)r=0;else if(n.type===15)r=Ge.parse(e,n);else return null;let i=Math.cos(r),a=Math.sin(r);return[i,a,-a,i,0,0]}},Sa={type:16,number:50,flags:4},Ca=[Sa,Sa],wa={name:`transform-origin`,initialValue:`50% 50%`,prefix:!0,type:1,parse:(e,t)=>{let n=t.filter(M);return n.length===2?[c(n,0),c(n,1)]:Ca}},Ta={name:`rotate`,initialValue:`none`,prefix:!1,type:0,parse:(e,t)=>t.type===20&&t.value===`none`?null:t.type===17&&t.number===0?0:t.type===15?Ge.parse(e,t)*180/Math.PI:null},Ea={name:`visibility`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`hidden`:return 1;case`collapse`:return 2;default:return 0}}},Da={name:`word-break`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`break-all`:return`break-all`;case`keep-all`:return`keep-all`;default:return`normal`}}},Oa={name:`white-space`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`pre`:return`pre`;case`nowrap`:return`nowrap`;case`pre-wrap`:return`pre-wrap`;case`pre-line`:return`pre-line`;default:return`normal`}}},ka=e=>e!==0,Aa=e=>e===3||e===4,ja={name:`writing-mode`,initialValue:`horizontal-tb`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`vertical-rl`:return 1;case`vertical-lr`:return 2;case`sideways-rl`:return 3;case`sideways-lr`:return 4;default:return 0}}},Ma={name:`z-index`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>{if(t.type===20)return{auto:!0,order:0};if(E(t))return{auto:!1,order:t.number};throw Error(`Invalid z-index number parsed`)}},Na={name:`time`,parse:(e,t)=>{if(t.type===15)switch(t.unit.toLowerCase()){case`s`:return 1e3*t.number;case`ms`:return t.number}throw Error(`Unsupported time type`)}},Pa={name:`opacity`,initialValue:`1`,type:0,prefix:!1,parse:(e,t)=>E(t)?t.number:1},Fa={name:`text-decoration-style`,initialValue:`solid`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`double`:return 1;case`dotted`:return 2;case`dashed`:return 3;case`wavy`:return 4;default:return 0}}},Ia={name:`text-decoration-thickness`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>{if(D(t))switch(t.value){case`auto`:return`auto`;case`from-font`:return`from-font`}return T(t)?t.number:`auto`}},La={name:`text-underline-offset`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>D(t)&&t.value===`auto`?`auto`:T(t)?t.number:`auto`},Ra={name:`font-weight`,initialValue:`normal`,type:0,prefix:!1,parse:(e,t)=>{if(E(t))return t.number;if(D(t))switch(t.value){case`bold`:return 700;default:return 400}return 400}},za={name:`font-variant`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>t.filter(D).map(e=>e.value)},Ba={name:`font-style`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`oblique`:return`oblique`;case`italic`:return`italic`;default:return`normal`}}},Va={name:`duration`,initialValue:`0s`,prefix:!1,type:1,parse:(e,t)=>t.filter(T).map(t=>Na.parse(e,t))},Ha={name:`box-shadow`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>t.length===1&&we(c(t,0),`none`)?[]:k(t).map(t=>{let n={color:255,offsetX:N,offsetY:N,blur:N,spread:N,inset:!1},r=0;for(let i=0;i<t.length;i++){let a=t[i];a&&(we(a,`inset`)?n.inset=!0:Fe(a)?(r===0?n.offsetX=a:r===1?n.offsetY=a:r===2?n.blur=a:n.spread=a,r++):n.color=V.parse(e,a))}return n})},Ua={name:`paint-order`,initialValue:`normal`,prefix:!1,type:1,parse:(e,t)=>{let n=[0,1,2],r=[];return t.filter(D).forEach(e=>{switch(e.value){case`stroke`:r.push(1);break;case`fill`:r.push(0);break;case`markers`:r.push(2)}}),n.forEach(e=>{r.indexOf(e)===-1&&r.push(e)}),r}},Wa={name:`-webkit-text-stroke-color`,initialValue:`currentcolor`,prefix:!1,type:3,format:`color`},Ga={name:`-webkit-text-stroke-width`,initialValue:`0`,type:0,prefix:!1,parse:(e,t)=>T(t)?t.number:0},Ka={name:`-webkit-line-clamp`,initialValue:`none`,prefix:!0,type:0,parse:(e,t)=>t.type===20&&t.value===`none`?0:t.type===17?Math.max(0,Math.floor(t.number)):0},qa={name:`object-fit`,initialValue:`fill`,prefix:!1,type:1,parse:(e,t)=>t.filter(D).reduce((e,t)=>e|Ja(t.value),0)},Ja=e=>{switch(e){case`contain`:return 2;case`cover`:return 4;case`none`:return 8;case`scale-down`:return 16}return 0},Ya={name:`text-overflow`,initialValue:`clip`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`ellipsis`:return 1;default:return 0}}},Xa={name:`image-rendering`,initialValue:`auto`,prefix:!1,type:2,parse:(e,t)=>{switch(t.toLowerCase()){case`crisp-edges`:case`-webkit-crisp-edges`:case`-moz-crisp-edges`:return 1;case`pixelated`:case`-webkit-optimize-contrast`:return 2;case`smooth`:case`high-quality`:return 3;default:return 0}}},K={NORMAL:`normal`,MULTIPLY:`multiply`,SCREEN:`screen`,OVERLAY:`overlay`,DARKEN:`darken`,LIGHTEN:`lighten`,COLOR_DODGE:`color-dodge`,COLOR_BURN:`color-burn`,HARD_LIGHT:`hard-light`,SOFT_LIGHT:`soft-light`,DIFFERENCE:`difference`,EXCLUSION:`exclusion`,HUE:`hue`,SATURATION:`saturation`,COLOR:`color`,LUMINOSITY:`luminosity`},Za=new Set(Object.values(K)),Qa={name:`mix-blend-mode`,initialValue:`normal`,type:2,prefix:!1,parse:(e,t)=>Za.has(t)?t:K.NORMAL},$a={name:`filter`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>{if(t.length===1){let e=c(t,0);if(e.type===20&&e.value===`none`)return null}let n=[];for(let e of t)if(e.type===22)n.push(`url("${e.value}")`);else if(e.type===18){let t=e,r=eo(t.values);switch(t.name){case`blur`:n.push(`blur(${r})`);break;case`brightness`:case`contrast`:case`invert`:case`opacity`:case`saturate`:case`sepia`:n.push(`${t.name}(${r})`);break;case`grayscale`:n.push(`grayscale(${r})`);break;case`hue-rotate`:n.push(`hue-rotate(${r})`);break;case`drop-shadow`:n.push(`drop-shadow(${r})`);break;default:n.push(`${t.name}(${r})`)}}return n.length>0?n.join(` `):null}},eo=e=>{let t=[];for(let n of e)n.type===31?t.push(` `):n.type===18?t.push(`${n.name}(${eo(n.values)})`):n.type===4?t.push(`,`):n.type===6?t.push(n.value):n.type===15?t.push(`${n.number}${n.unit}`):n.type===17?t.push(`${n.number}`):n.type===16?t.push(`${n.number}%`):n.type===20?t.push(n.value):n.type===5&&t.push(`#${n.value}`);return t.join(``).trim()},to={name:`font-variant-ligatures`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`none`:return 1;case`common-ligatures`:return 2;case`no-common-ligatures`:return 3;case`discretionary-ligatures`:return 4;case`no-discretionary-ligatures`:return 5;case`historical-ligatures`:return 6;case`no-historical-ligatures`:return 7;case`contextual`:return 8;case`no-contextual`:return 9;default:return 0}}},no={name:`zoom`,initialValue:`1`,type:0,prefix:!1,parse:(e,t)=>t.type===16?Math.max(0,t.number/100):t.type===17?Math.max(0,t.number):1},ro={name:`object-position`,initialValue:`50% 50%`,prefix:!1,type:1,parse:(e,t)=>{let n=[],r=0;for(;r<t.length&&n.length<2;){let e=t[r];if(!e)break;if(D(e))switch(e.value){case`left`:case`top`:n.push(N);break;case`center`:n.push(P);break;case`right`:case`bottom`:n.push(F)}else M(e)&&n.push(e);r++}for(;n.length<2;)n.push(P);return[c(n,0),c(n,1)]}},io=new Set(Object.values({NORMAL:`normal`,MULTIPLY:`multiply`,SCREEN:`screen`,OVERLAY:`overlay`,DARKEN:`darken`,LIGHTEN:`lighten`,COLOR_DODGE:`color-dodge`,COLOR_BURN:`color-burn`,HARD_LIGHT:`hard-light`,SOFT_LIGHT:`soft-light`,DIFFERENCE:`difference`,EXCLUSION:`exclusion`,HUE:`hue`,SATURATION:`saturation`,COLOR:`color`,LUMINOSITY:`luminosity`})),ao={name:`background-blend-mode`,initialValue:`normal`,prefix:!1,type:1,parse:(e,t)=>{let n=[],r=t.filter(O);for(let e of r)D(e)&&io.has(e.value)&&n.push(e.value);return n.length>0?n:[`normal`]}},oo={name:`border-image-source`,initialValue:`none`,prefix:!1,type:1,skipCache:!0,parse:(e,t)=>{if(t.length===0)return null;let n=t.filter(e=>O(e)&&li(e));return n.length===0?null:ci.parse(e,c(n,0))}},so=e=>{let t=[...e];if(t.length===1){let e=c(t,0);t.push(e,e,e)}else t.length===2?t.push(c(t,0),c(t,1)):t.length===3&&t.push(c(t,1));return[c(t,0),c(t,1),c(t,2),c(t,3)]},co={name:`border-image-slice`,initialValue:`100%`,prefix:!1,type:1,parse:(e,t)=>{let n=t.filter(Te),r=[],i=!1,a=`percent`;for(let e of n)D(e)&&e.value===`fill`?i=!0:e.type===17?(r.push(e.number),a=`number`):e.type===16&&(r.push(e.number),a=`percent`);let[o,s,c,l]=so(r.length>0?r:[100]);return{top:o,right:s,bottom:c,left:l,fill:i,unit:a}}},lo=e=>{switch(e){case`repeat`:return 1;case`round`:return 2;case`space`:return 3;default:return 0}},uo={name:`border-image-repeat`,initialValue:`stretch`,prefix:!1,type:1,parse:(e,t)=>{let n=t.filter(Te),r=[];for(let e of n)D(e)&&r.push(lo(e.value));let i=r[0]??0;return{horizontal:i,vertical:r[1]??i}}},fo={name:`box-decoration-break`,initialValue:`slice`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`clone`:return 1;default:return 0}}},po={name:`accent-color`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>D(t)&&t.value===`auto`?null:V.parse(e,t)},mo={name:`-webkit-text-fill-color`,initialValue:`currentcolor`,prefix:!0,type:0,parse:(e,t)=>D(t)&&t.value===`currentcolor`?null:V.parse(e,t)},ho={name:`isolation`,initialValue:`auto`,prefix:!1,type:2,parse:(e,t)=>+(t===`isolate`)},go=/* @__PURE__ */ new Set([`transform`,`translate`,`rotate`,`scale`,`opacity`,`filter`,`backdrop-filter`,`mix-blend-mode`,`isolation`,`clip-path`,`mask`,`mask-image`,`mask-border`,`perspective`,`contain`,`offset-path`,`offset-distance`,`offset-rotate`,`top`,`left`,`bottom`,`right`,`z-index`]),_o={name:`will-change`,initialValue:`auto`,prefix:!1,type:1,parse:(e,t)=>+!!t.some(e=>D(e)&&go.has(e.value))},vo={name:`contain`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>+!!/\b(paint|strict|content)\b/.test(t)},yo={name:`outline-style`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`solid`:return 2;case`dashed`:return 3;case`dotted`:return 4;case`double`:return 5;case`auto`:return 1;default:return 0}}},bo={name:`outline-color`,initialValue:`currentcolor`,prefix:!1,type:0,parse:(e,t)=>D(t)&&(t.value===`currentcolor`||t.value===`invert`)?null:V.parse(e,t)},xo={name:`outline-width`,initialValue:`medium`,prefix:!1,type:0,parse:Pi.parse},So={name:`outline-offset`,initialValue:`0px`,prefix:!1,type:0,parse:(e,t)=>T(t)||E(t)?t.number:0},Co={name:`backdrop-filter`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>$a.parse(e,t)},wo={name:`mask-image`,initialValue:`none`,prefix:!1,type:1,skipCache:!0,parse:di.parse},To={name:`mask-position`,initialValue:`0%`,prefix:!1,type:1,parse:pi.parse},Eo={name:`mask-repeat`,initialValue:`repeat`,prefix:!1,type:1,parse:mi.parse},Do={name:`mask-size`,initialValue:`auto`,prefix:!1,type:1,parse:gi.parse},Oo=[`dot`,`circle`,`double-circle`,`triangle`,`sesame`],ko={name:`text-emphasis-style`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>{let n=t.filter(Te);if(n.length===0)return null;let r=c(n,0);if(r.type===0)return r.value;if(D(r)){if(r.value===`none`)return null;if(r.value!==`filled`&&r.value!==`open`&&Oo.indexOf(r.value)===-1)return r.value}let i=!0,a=`circle`;for(let e of n)D(e)&&(e.value===`filled`?i=!0:e.value===`open`?i=!1:Oo.indexOf(e.value)!==-1&&(a=e.value));return{fill:i,shape:a}}},Ao={name:`text-emphasis-color`,initialValue:`currentcolor`,prefix:!1,type:0,parse:(e,t)=>D(t)&&t.value===`currentcolor`?null:V.parse(e,t)},jo={name:`text-emphasis-position`,initialValue:`over right`,prefix:!1,type:1,parse:(e,t)=>{let n=!0,r=!0;for(let e of t)if(D(e))switch(e.value){case`over`:n=!0;break;case`under`:n=!1;break;case`right`:r=!0;break;case`left`:r=!1}return{over:n,right:r}}},Mo=e=>{let t=[...e];if(t.length===1){let e=c(t,0);t.push(e,e,e)}else t.length===2?t.push(c(t,0),c(t,1)):t.length===3&&t.push(c(t,1));return[c(t,0),c(t,1),c(t,2),c(t,3)]},No=e=>D(e)&&e.value===`auto`?{kind:`auto`}:e.type===17?{kind:`number`,value:e.number}:e.type===15&&e.unit===`px`?{kind:`length`,value:e.number}:e.type===16?{kind:`percentage`,value:e.number}:null,Po=e=>{let t=[];for(let n of e){if(n.type===31)continue;let e=No(n);if(!e)return null;t.push(e)}return t.length===0||t.length>4?null:Mo(t)},Fo={name:`border-image-width`,initialValue:`auto`,prefix:!1,type:1,parse:(e,t)=>{let n=Po(t),r={kind:`auto`};return n?{top:n[0],right:n[1],bottom:n[2],left:n[3]}:{top:r,right:r,bottom:r,left:r}}},Io={name:`border-image-outset`,initialValue:`0px`,prefix:!1,type:1,parse:(e,t)=>{let n=Po(t),r={kind:`length`,value:0};return n?{top:n[0],right:n[1],bottom:n[2],left:n[3]}:{top:r,right:r,bottom:r,left:r}}},Lo={name:`-webkit-box-reflect`,initialValue:`none`,prefix:!0,type:1,skipCache:!0,parse:(e,t)=>{let n=null,r=0,i=null;for(let a of t)if(a.type!==31){if(n===null&&D(a)){if(a.value===`below`||a.value===`above`||a.value===`left`||a.value===`right`){n=a.value;continue}if(a.value===`none`)return null}r===0&&T(a)&&a.unit===`px`?r=a.number:i===null&&li(a)&&(i=ci.parse(e,a))}return n===null?null:{direction:n,offset:r,mask:i}}},Ro={name:`translate`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>{let n=[];for(let e of t)M(e)&&n.push(e);return n.length===0?null:[c(n,0),n.length>1?c(n,1):N]}},zo={name:`scale`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>{let n=[];for(let e of t)E(e)&&n.push(e.number);return n.length===0?null:[c(n,0),n.length>1?c(n,1):c(n,0)]}},Bo=6e4,Vo=[[`animationDuration`,Va,`animationDuration`],[`backgroundClip`,Ar,`backgroundClip`],[`backgroundColor`,jr,`backgroundColor`],[`backgroundImage`,di,`backgroundImage`],[`backgroundOrigin`,fi,`backgroundOrigin`],[`backgroundPosition`,pi,`backgroundPosition`],[`backgroundRepeat`,mi,`backgroundRepeat`],[`backgroundSize`,gi,`backgroundSize`],[`borderTopColor`,yi,`borderTopColor`],[`borderRightColor`,bi,`borderRightColor`],[`borderBottomColor`,xi,`borderBottomColor`],[`borderLeftColor`,Si,`borderLeftColor`],[`borderTopLeftRadius`,wi,`borderTopLeftRadius`],[`borderTopRightRadius`,Ti,`borderTopRightRadius`],[`borderBottomRightRadius`,Ei,`borderBottomRightRadius`],[`borderBottomLeftRadius`,Di,`borderBottomLeftRadius`],[`borderTopStyle`,ki,`borderTopStyle`],[`borderRightStyle`,Ai,`borderRightStyle`],[`borderBottomStyle`,ji,`borderBottomStyle`],[`borderLeftStyle`,Mi,`borderLeftStyle`],[`borderTopWidth`,Pi,`borderTopWidth`],[`borderRightWidth`,Fi,`borderRightWidth`],[`borderBottomWidth`,Ii,`borderBottomWidth`],[`borderLeftWidth`,Li,`borderLeftWidth`],[`boxShadow`,Ha,`boxShadow`],[`clipPath`,Ji,`clipPath`],[`color`,Yi,`color`],[`direction`,Xi,`direction`],[`display`,vr,`display`],[`fontFamily`,Zi,`fontFamily`],[`fontSize`,Qi,`fontSize`],[`fontStyle`,Ba,`fontStyle`],[`fontVariant`,za,`fontVariant`],[`fontWeight`,Ra,`fontWeight`],[`letterSpacing`,$i,`letterSpacing`],[`lineBreak`,ea,`lineBreak`],[`lineHeight`,ta,`lineHeight`],[`listStyleImage`,ra,`listStyleImage`],[`listStylePosition`,ia,`listStylePosition`],[`listStyleType`,rr,`listStyleType`],[`marginTop`,oa,`marginTop`],[`marginRight`,sa,`marginRight`],[`marginBottom`,ca,`marginBottom`],[`marginLeft`,la,`marginLeft`],[`opacity`,Pa,`opacity`],[`overflowWrap`,ua,`overflowWrap`],[`paddingTop`,fa,`paddingTop`],[`paddingRight`,pa,`paddingRight`],[`paddingBottom`,ma,`paddingBottom`],[`paddingLeft`,ha,`paddingLeft`],[`paintOrder`,Ua,`paintOrder`],[`position`,_a,`position`],[`textAlign`,ga,`textAlign`],[`textDecorationStyle`,Fa,`textDecorationStyle`],[`textDecorationThickness`,Ia,`textDecorationThickness`],[`textUnderlineOffset`,La,`textUnderlineOffset`],[`textShadow`,va,`textShadow`],[`textTransform`,ya,`textTransform`],[`textOverflow`,Ya,`textOverflow`],[`transform`,ba,`transform`],[`transformOrigin`,wa,`transformOrigin`],[`rotate`,Ta,`rotate`],[`translate`,Ro,`translate`],[`scale`,zo,`scale`],[`visibility`,Ea,`visibility`],[`webkitTextStrokeColor`,Wa,`webkitTextStrokeColor`],[`webkitTextStrokeWidth`,Ga,`webkitTextStrokeWidth`],[`webkitLineClamp`,Ka,`webkitLineClamp`],[`wordBreak`,Da,`wordBreak`],[`whiteSpace`,Oa,`whiteSpace`],[`writingMode`,ja,`writingMode`],[`zIndex`,Ma,`zIndex`],[`objectFit`,qa,`objectFit`],[`imageRendering`,Xa,`imageRendering`],[`mixBlendMode`,Qa,`mixBlendMode`],[`filter`,$a,`filter`],[`fontVariantLigatures`,to,`fontVariantLigatures`],[`zoom`,no,`zoom`],[`objectPosition`,ro,`objectPosition`],[`backgroundBlendMode`,ao,`backgroundBlendMode`],[`borderImageSource`,oo,`borderImageSource`],[`borderImageSlice`,co,`borderImageSlice`],[`borderImageRepeat`,uo,`borderImageRepeat`],[`boxDecorationBreak`,fo,`boxDecorationBreak`],[`accentColor`,po,`accentColor`],[`webkitTextFillColor`,mo,`webkitTextFillColor`],[`isolation`,ho,`isolation`],[`willChange`,_o,`will-change`],[`contain`,vo,`contain`],[`outlineColor`,bo,`outlineColor`],[`outlineStyle`,yo,`outlineStyle`],[`outlineWidth`,xo,`outlineWidth`],[`outlineOffset`,So,`outlineOffset`],[`backdropFilter`,Co,`backdropFilter`],[`maskImage`,wo,`maskImage`],[`maskPosition`,To,`maskPosition`],[`maskRepeat`,Eo,`maskRepeat`],[`maskSize`,Do,`maskSize`],[`textEmphasisStyle`,ko,`textEmphasisStyle`],[`textEmphasisColor`,Ao,`textEmphasisColor`],[`textEmphasisPosition`,jo,`textEmphasisPosition`],[`borderImageWidth`,Fo,`borderImageWidth`],[`borderImageOutset`,Io,`borderImageOutset`],[`webkitBoxReflect`,Lo,`webkitBoxReflect`]],Ho=/* @__PURE__ */ new Map,Uo=(e,t,n)=>{let r=n==null?t.initialValue:n.toString();r.trim()===``&&(r=t.initialValue);let i=Ho.get(t);if(i){let e=i.get(r);if(e!==void 0)return i.delete(r),i.set(r,e),e}let a=xe.get();a.write(r);let o=new Se(a.read());xe.release(a);let s=(()=>{switch(t.type){case 2:{let n=o.parseComponentValue();return t.parse(e,D(n)?n.value:t.initialValue)}case 0:return t.parse(e,o.parseComponentValue());case 1:return t.parse(e,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(t.format){case`angle`:return Ge.parse(e,o.parseComponentValue());case`color`:return V.parse(e,o.parseComponentValue());case`image`:return ci.parse(e,o.parseComponentValue());case`length`:{let e=o.parseComponentValue();return Fe(e)?e:N}case`length-percentage`:{let e=o.parseComponentValue();return M(e)?e:N}case`time`:return Na.parse(e,o.parseComponentValue())}}})();if(i||(i=/* @__PURE__ */ new Map,Ho.set(t,i)),!(t.skipCache||t.type===3&&t.format===`image`)){if(i.size>=200){let e=i.keys().next().value;e!==void 0&&i.delete(e)}i.set(r,s)}return s};var Wo=class{styles;constructor(e){this.styles=e}get topColor(){return this.styles.borderTopColor}get rightColor(){return this.styles.borderRightColor}get bottomColor(){return this.styles.borderBottomColor}get leftColor(){return this.styles.borderLeftColor}get topStyle(){return this.styles.borderTopStyle}get rightStyle(){return this.styles.borderRightStyle}get bottomStyle(){return this.styles.borderBottomStyle}get leftStyle(){return this.styles.borderLeftStyle}get topWidth(){return this.styles.borderTopWidth}get rightWidth(){return this.styles.borderRightWidth}get bottomWidth(){return this.styles.borderBottomWidth}get leftWidth(){return this.styles.borderLeftWidth}get topLeftRadius(){return this.styles.borderTopLeftRadius}get topRightRadius(){return this.styles.borderTopRightRadius}get bottomRightRadius(){return this.styles.borderBottomRightRadius}get bottomLeftRadius(){return this.styles.borderBottomLeftRadius}get imageSource(){return this.styles.borderImageSource}get imageSlice(){return this.styles.borderImageSlice}get imageRepeat(){return this.styles.borderImageRepeat}get boxShadow(){return this.styles.boxShadow}},Go=class{styles;constructor(e){this.styles=e}get color(){return this.styles.backgroundColor}get image(){return this.styles.backgroundImage}get clip(){return this.styles.backgroundClip}get origin(){return this.styles.backgroundOrigin}get position(){return this.styles.backgroundPosition}get repeat(){return this.styles.backgroundRepeat}get size(){return this.styles.backgroundSize}get blendMode(){return this.styles.backgroundBlendMode}},Ko=class{styles;constructor(e){this.styles=e}get family(){return this.styles.fontFamily}get size(){return this.styles.fontSize}get style(){return this.styles.fontStyle}get variant(){return this.styles.fontVariant}get weight(){return this.styles.fontWeight}get ligatures(){return this.styles.fontVariantLigatures}get color(){return this.styles.color}get letterSpacing(){return this.styles.letterSpacing}get lineHeight(){return this.styles.lineHeight}get textAlign(){return this.styles.textAlign}get textTransform(){return this.styles.textTransform}get textOverflow(){return this.styles.textOverflow}get textShadow(){return this.styles.textShadow}get textDecorationColor(){return this.styles.textDecorationColor}get textDecorationLine(){return this.styles.textDecorationLine}get textDecorationStyle(){return this.styles.textDecorationStyle}get textDecorationThickness(){return this.styles.textDecorationThickness}get textUnderlineOffset(){return this.styles.textUnderlineOffset}get wordBreak(){return this.styles.wordBreak}get lineBreak(){return this.styles.lineBreak}get overflowWrap(){return this.styles.overflowWrap}get writingMode(){return this.styles.writingMode}get direction(){return this.styles.direction}get webkitTextStrokeColor(){return this.styles.webkitTextStrokeColor}get webkitTextStrokeWidth(){return this.styles.webkitTextStrokeWidth}get webkitLineClamp(){return this.styles.webkitLineClamp}get paintOrder(){return this.styles.paintOrder}},qo=class{styles;constructor(e){this.styles=e}get display(){return this.styles.display}get position(){return this.styles.position}get float(){return this.styles.float}get zIndex(){return this.styles.zIndex}get marginTop(){return this.styles.marginTop}get marginRight(){return this.styles.marginRight}get marginBottom(){return this.styles.marginBottom}get marginLeft(){return this.styles.marginLeft}get paddingTop(){return this.styles.paddingTop}get paddingRight(){return this.styles.paddingRight}get paddingBottom(){return this.styles.paddingBottom}get paddingLeft(){return this.styles.paddingLeft}get overflowX(){return this.styles.overflowX}get overflowY(){return this.styles.overflowY}get opacity(){return this.styles.opacity}get visibility(){return this.styles.visibility}get transform(){return this.styles.transform}get transformOrigin(){return this.styles.transformOrigin}get rotate(){return this.styles.rotate}get zoom(){return this.styles.zoom}get clipPath(){return this.styles.clipPath}get mixBlendMode(){return this.styles.mixBlendMode}get filter(){return this.styles.filter}get imageRendering(){return this.styles.imageRendering}get objectFit(){return this.styles.objectFit}get objectPosition(){return this.styles.objectPosition}get boxDecorationBreak(){return this.styles.boxDecorationBreak}get listStyleImage(){return this.styles.listStyleImage}get listStylePosition(){return this.styles.listStylePosition}get listStyleType(){return this.styles.listStyleType}get animationDuration(){return this.styles.animationDuration}isVisible(){return this.styles.isVisible()}isTransparent(){return this.styles.isTransparent()}isTransformed(){return this.styles.isTransformed()}isPositioned(){return this.styles.isPositioned()}isPositionedWithZIndex(){return this.styles.isPositionedWithZIndex()}isFloating(){return this.styles.isFloating()}isInlineLevel(){return this.styles.isInlineLevel()}},Jo=class{animationDuration;backgroundClip;backgroundColor;backgroundImage;backgroundOrigin;backgroundPosition;backgroundRepeat;backgroundSize;borderTopColor;borderRightColor;borderBottomColor;borderLeftColor;borderTopLeftRadius;borderTopRightRadius;borderBottomRightRadius;borderBottomLeftRadius;borderTopStyle;borderRightStyle;borderBottomStyle;borderLeftStyle;borderTopWidth;borderRightWidth;borderBottomWidth;borderLeftWidth;boxShadow;clipPath;color;direction;display;float;fontFamily;fontSize;fontStyle;fontVariant;fontWeight;letterSpacing;lineBreak;lineHeight;listStyleImage;listStylePosition;listStyleType;marginTop;marginRight;marginBottom;marginLeft;opacity;overflowX;overflowY;overflowWrap;paddingTop;paddingRight;paddingBottom;paddingLeft;paintOrder;position;textAlign;textDecorationColor;textDecorationLine;textDecorationStyle;textDecorationThickness;textUnderlineOffset;textShadow;textTransform;textOverflow;transform;transformOrigin;rotate;translate;scale;visibility;webkitTextStrokeColor;webkitTextStrokeWidth;webkitLineClamp;wordBreak;whiteSpace;writingMode;zIndex;objectFit;imageRendering;mixBlendMode;filter;fontVariantLigatures;zoom;objectPosition;backgroundBlendMode;borderImageSource;borderImageSlice;borderImageRepeat;boxDecorationBreak;accentColor;webkitTextFillColor;isolation;willChange;contain;outlineColor;outlineStyle;outlineWidth;outlineOffset;backdropFilter;maskImage;maskPosition;maskRepeat;maskSize;textEmphasisStyle;textEmphasisColor;textEmphasisPosition;borderImageWidth;borderImageOutset;webkitBoxReflect;_border;_background;_font;_layout;get border(){return this._border??=new Wo(this)}get background(){return this._background??=new Go(this)}get font(){return this._font??=new Ko(this)}get layout(){return this._layout??=new qo(this)}constructor(e,t){if(t.display===`none`){this.display=0;for(let[t,n]of Vo)t!==`display`&&(this[t]=Uo(e,n,void 0));Object.assign(this,Yo(e,null))}else{for(let[n,r,i]of Vo)this[n]=Uo(e,r,t[i]);Object.assign(this,Yo(e,t))}}isVisible(){return this.display>0&&this.opacity>0&&this.visibility===0}isTransparent(){return R(this.backgroundColor)}isTransformed(){return this.transform!==null||this.rotate!==null||this.translate!==null||this.scale!==null}isPositioned(){return this.position!==0}isPositionedWithZIndex(){return this.isPositioned()&&!this.zIndex.auto}isFloating(){return this.float!==0}isInlineLevel(){return H(this.display,4)||H(this.display,33554432)||H(this.display,268435456)||H(this.display,536870912)||H(this.display,67108864)||H(this.display,134217728)}};let Yo=(e,t)=>{let n=(e,n)=>{if(t)return t[e]??n},r=Uo(e,xr,n(`overflow`));return{float:Uo(e,br,n(`cssFloat`)),textDecorationColor:Uo(e,Sr,n(`textDecorationColor`,n(`color`))),textDecorationLine:Uo(e,Cr,n(`textDecorationLine`,n(`textDecoration`))),overflowX:r[0],overflowY:r[+(r.length>1)]}};var Xo=class{content;quotes;constructor(e,t){this.content=Uo(e,wr,t.content),this.quotes=Uo(e,Tr,t.quotes)}},Zo=class{counterIncrement;counterReset;constructor(e,t){this.counterIncrement=Uo(e,Or,t.counterIncrement),this.counterReset=Uo(e,kr,t.counterReset)}};let Qo=e=>{if(typeof e.getAttribute!=`function`)return 0;switch(e.getAttribute(`data-html2canvas-debug`)){case`all`:return 1;case`clone`:return 2;case`parse`:return 3;case`render`:return 4;default:return 0}},$o=(e,t)=>{let n=Qo(e);return n===1||t===n},es=e=>{let t=``;for(let n of e)try{let e=n.cssRules;for(let n=0;n<e.length;n++){let r=e[n];r&&typeof r.cssText==`string`&&(t+=r.cssText)}}catch{}return t},ts=(e,t,n)=>{let r=es(t);if(!r)return null;let i=e.createElement(`style`);return i.textContent=r,n&&(i.nonce=n),i};var ns=class{cloneNodeFn;options;context;constructor(e,t,n){this.cloneNodeFn=e,this.options=t,this.context=n}appendChildNode(e,t,n){this.safeAppendClonedChild(e,t,n)}cloneChildNodes(e,t,n){e.shadowRoot&&t.shadowRoot?(this.cloneShadowDOMChildren(e.shadowRoot,t.shadowRoot,n),this.cloneLightDOMChildren(e,t,n)):e.shadowRoot&&!t.shadowRoot?this.cloneShadowDOMAsLightDOM(e.shadowRoot,t,n):this.cloneLightDOMChildren(e,t,n)}shouldCloneChild(e){return!Fn(e)||!Jn(e)&&!e.hasAttribute(`data-html2canvas-ignore`)&&(typeof this.options.ignoreElements!=`function`||!this.options.ignoreElements(e))}shouldCloneStyleElement(e){return!this.options.copyStyles||!Fn(e)||!qn(e)}safeAppendClonedChild(e,t,n){this.shouldCloneChild(t)&&this.shouldCloneStyleElement(t)&&e.appendChild(this.cloneNodeFn(t,n))}cloneAssignedNodes(e,t,n){e.forEach(e=>{this.safeAppendClonedChild(t,e,n)})}cloneSlotFallbackContent(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)this.safeAppendClonedChild(t,r,n)}cloneSlotElement(e,t,n){if(!Zn(e))return;let r=e;if(typeof r.assignedNodes!=`function`){this.context.logger.warn(`HTMLSlotElement.assignedNodes is not available`,e),this.cloneSlotFallbackContent(e,t,n);return}let i=r.assignedNodes();!i||!Array.isArray(i)?(this.context.logger.warn(`assignedNodes() did not return a valid array`,e),this.cloneSlotFallbackContent(e,t,n)):i.length>0?this.cloneAssignedNodes(i,t,n):this.cloneSlotFallbackContent(e,t,n)}cloneShadowDOMChildren(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)Fn(r)&&Zn(r)?this.cloneSlotElement(r,t,n):this.safeAppendClonedChild(t,r,n);this.appendAdoptedStyleSheets(e,t,n)}cloneLightDOMChildren(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)this.appendChildNode(t,r,n)}cloneSlotElementAsLightDOM(e,t,n){if(!Zn(e))return;let r=e;if(typeof r.assignedNodes!=`function`){for(let r=e.firstChild;r;r=r.nextSibling)this.appendChildNode(t,r,n);return}let i=r.assignedNodes();if(i&&Array.isArray(i)&&i.length>0)i.forEach(e=>this.appendChildNode(t,e,n));else for(let r=e.firstChild;r;r=r.nextSibling)this.appendChildNode(t,r,n)}cloneShadowDOMAsLightDOM(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)Fn(r)&&Zn(r)?this.cloneSlotElementAsLightDOM(r,t,n):this.appendChildNode(t,r,n);this.appendAdoptedStyleSheets(e,t,n)}appendAdoptedStyleSheets(e,t,n){if(n)return;let r=e.adoptedStyleSheets;if(!r||r.length===0)return;let i=`host`in t?t.host.ownerDocument:t.ownerDocument;if(!i)return;let a=ts(i,r,this.options.cspNonce);a&&t.appendChild(a)}};let rs=[`all`,`d`,`content`],is=(e,t)=>{let n=[];for(let t=e.length-1;t>=0;t--){let r=e.item(t);if(rs.indexOf(r)===-1&&!r.startsWith(`--`)){let t=e.getPropertyValue(r);if(t){let i=e.getPropertyPriority(r);n.push(i?`${r}:${t} !${i}`:`${r}:${t}`)}}}return n.length>0&&(t.style.cssText=n.join(`;`)+`;`),t},as=`___html2canvas___pseudoelement_before`,os=`___html2canvas___pseudoelement_after`,ss=`{
|
|
7
7
|
content: "" !important;
|
|
8
8
|
display: none !important;
|
|
9
|
-
}`,
|
|
10
|
-
.${rs}:after${is}`,t)},os=(e,t,n)=>{let r=e.ownerDocument;if(r){let i=r.createElement(`style`);i.textContent=t,n&&(i.nonce=n),e.appendChild(i)}};var ss=class{context;counters;quoteDepth=0;constructor(e,t){this.context=e,this.counters=t}resolvePseudoContent(e,t,n,r){if(!n)return;let i=n.content,a=t.ownerDocument;if(!a||!i||i===`none`||i===`-moz-alt-content`||n.display===`none`)return;this.counters.parse(new Jo(this.context,n));let o=new qo(this.context,n),s=a.createElement(`html2canvaspseudoelement`);ts(n,s),o.content.forEach(t=>{if(t.type===0)s.appendChild(a.createTextNode(t.value));else if(t.type===22){let e=a.createElement(`img`);e.src=t.value,e.style.opacity=`1`,s.appendChild(e)}else if(t.type===18){if(t.name===`attr`){let n=t.values.filter(D);n.length&&n[0]&&s.appendChild(a.createTextNode(e.getAttribute(n[0].value)||``))}else if(t.name===`counter`){let[e,n]=t.values.filter(O);if(e&&D(e)){let t=this.counters.getCounterValue(e.value),r=n&&D(n)?rr.parse(this.context,n.value):3;s.appendChild(a.createTextNode(_r(t,r,!1)))}}else if(t.name===`counters`){let[e,n,r]=t.values.filter(O);if(e&&D(e)){let t=this.counters.getCounterValues(e.value),i=r&&D(r)?rr.parse(this.context,r.value):3,o=n&&n.type===0?n.value:``,c=t.map(e=>_r(e,i,!1)).join(o);s.appendChild(a.createTextNode(c))}}}else if(t.type===20)switch(t.value){case`open-quote`:s.appendChild(a.createTextNode(Er(o.quotes,this.quoteDepth++,!0)));break;case`close-quote`:{let e=this.quoteDepth>0;this.quoteDepth=Math.max(0,this.quoteDepth-1),e&&s.appendChild(a.createTextNode(Er(o.quotes,this.quoteDepth,!1)));break}default:s.appendChild(a.createTextNode(t.value))}}),s.className=`${ns} ${rs}`;let c=r===0?` ${ns}`:` ${rs}`;return Ln(t)?t.className.baseValue+=c:t.className+=c,s}};let q=e=>{if(e?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`)},cs=/* @__PURE__ */ new WeakMap,ls=e=>{let t=e&&e.trustedTypes;if(!t)return null;if(cs.has(t))return cs.get(t)??null;let n=null;try{n=t.getPolicy?.(`html2canvas-pro`)??t.createPolicy(`html2canvas-pro`,{createHTML:e=>e})}catch{n=null}return cs.set(t,n),n},us=(e,t,n)=>{let r=e.createElement(`iframe`);r.className=`html2canvas-container`,r.style.visibility=`hidden`,r.style.position=`fixed`,r.style.left=`-10000px`,r.style.top=`0px`,r.width=t.width.toString(),r.height=t.height.toString();let i=[[`width`,`${t.width}px`],[`height`,`${t.height}px`],[`min-width`,`0px`],[`max-width`,`none`],[`min-height`,`0px`],[`max-height`,`none`],[`box-sizing`,`content-box`],[`padding`,`0px`],[`border`,`0`]];for(let[e,t]of i)r.style.setProperty(e,t,`important`);return r.scrolling=`no`,r.setAttribute(`data-html2canvas-ignore`,`true`),(n||e.body).appendChild(r),r},ds=e=>new Promise(t=>{e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}),fs=e=>Promise.all([].slice.call(e.images,0).map(ds)),ps=(e,t=0)=>{if(!e||t>ms)return!0;let n;try{n=e.cssRules}catch{return!0}if(!n)return!0;for(let e=0;e<n.length;e++){let r=n[e];if(!r||!(`styleSheet`in r))continue;let i=r.styleSheet;if(!i||!ps(i,t+1))return!1}return!0},ms=32,hs=(e,t)=>{let n=e.querySelectorAll(`link`);for(let e=0;e<n.length;e++){let r=n[e];r&&t.push(r)}let r=(e.ownerDocument??e).createTreeWalker(e,NodeFilter.SHOW_ELEMENT),i=r.nextNode();for(;i;){let e=i.shadowRoot;e&&hs(e,t),i=r.nextNode()}},gs=(e,t,n,r=1e4)=>{if(n?.aborted)return Promise.resolve();let i=[],a=[];hs(e,a);for(let e of a){if(e.sheet)continue;let a=(e.getAttribute(`rel`)??``).trim().toLowerCase().split(/\s+/);a.includes(`stylesheet`)&&!a.includes(`alternate`)&&!e.disabled&&e.getAttribute(`href`)&&i.push(new Promise(i=>{let a=e.href,o=()=>{e.removeEventListener(`load`,o),e.removeEventListener(`error`,o),n?.removeEventListener(`abort`,s),clearInterval(l),i()},s=()=>o();if(e.sheet){i();return}e.addEventListener(`load`,o),e.addEventListener(`error`,o),n?.addEventListener(`abort`,s,{once:!0});let c=0,l=setInterval(()=>{c+=50,e.sheet?o():c>=r&&(t?.warn(`Stylesheet ${a} did not finish loading within ${r/1e3}s; continuing with a possibly unstyled clone`),o())},50)}))}let o=e.getElementsByTagName(`style`);for(let e=0;e<o.length;e++){let n=o[e],a=n?.sheet;a&&n?.textContent?.includes(`@import`)&&(ps(a)||i.push(new Promise(e=>{let i=0,a=setInterval(()=>{i+=50;let o=n.sheet;(o&&ps(o)||i>=r)&&(i>=r&&!ps(o??null)&&t?.warn(`@import chain in an inline <style> did not finish loading within ${r/1e3}s; continuing with a possibly unstyled clone`),clearInterval(a),e())},50)})))}return i.length===0?Promise.resolve():Promise.all(i).then(()=>void 0)},_s=(e,t,n)=>new Promise((r,i)=>{let a=e.contentWindow;if(!a)return i(`No window assigned for iframe`);let o=a.document,s,c=setTimeout(()=>{s&&clearInterval(s),i(/* @__PURE__ */ Error(`Cloned iframe did not fire its load event within ${Lo}ms`))},Lo),l=()=>{s&&clearInterval(s),clearTimeout(c),i(new DOMException(`The operation was aborted.`,`AbortError`))};a.onload=e.onload=()=>{a.onload=e.onload=null;let i=0;s=setInterval(()=>{i++,n?.aborted?l():o.body.childNodes.length>0&&o.readyState===`complete`?(clearInterval(s),s=void 0,clearTimeout(c),r(e)):i>=600&&(clearInterval(s),s=void 0,t?.warn(`Cloned iframe did not become ready within 30 seconds; continuing with a possibly incomplete document`),r(e))},50)},n&&(n.aborted?l():n.addEventListener(`abort`,l,{once:!0}))}),vs=e=>e.replace(/[<>&"'`\\]|[\u0000-\u001f\u007f]/g,``),ys=e=>{let t=``;return e&&(t+=`<!DOCTYPE `,e.name&&(t+=vs(e.name)),e.internalSubset&&(t+=` `+vs(e.internalSubset)),e.publicId?(t+=` PUBLIC "`+vs(e.publicId)+`"`,e.systemId&&(t+=` "`+vs(e.systemId)+`"`)):e.systemId&&(t+=` SYSTEM "`+vs(e.systemId)+`"`),t+=`>`),t},bs=(e,t,n)=>{e&&e.defaultView&&(t!==e.defaultView.pageXOffset||n!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,n)},xs=([e,t,n])=>{e.scrollLeft=t,e.scrollTop=n},Ss=(e,t)=>{let n=e.ownerDocument.createElement(`base`);n.href=t;let r=e.getElementsByTagName(`head`).item(0);r?.insertBefore(n,r?.firstChild??null)},Cs=(e,t,n,r)=>{let i=us(t,n,r.container);if(!i.contentWindow)throw Error(`Unable to find iframe window`);let a=t.defaultView.pageXOffset,o=t.defaultView.pageYOffset,s=i.contentWindow,c=s.document,l=_s(i,e.logger,r.signal).then(async()=>{r.scrolledElements.forEach(xs),s&&s.scrollTo(n.left,n.top);let t=r.onclone,a=r.clonedReferenceElement;if(a===void 0)throw Error(`Error finding the ${r.referenceElementName} in the cloned document`);return q(r.signal),await p,q(r.signal),c.fonts&&c.fonts.ready&&await c.fonts.ready,q(r.signal),/(AppleWebKit)/g.test(navigator.userAgent)&&(await fs(c),q(r.signal)),typeof t==`function`&&await Promise.resolve().then(()=>t(c,a)),s.scrollTo(n.left,n.top),/AppleWebKit/g.test(navigator.userAgent)&&(s.scrollY!==n.top||s.scrollX!==n.left)&&(e.logger.warn(`Unable to restore scroll position for cloned document`),e.adjustWindowBounds(s.scrollX-n.left,s.scrollY-n.top)),i}),u=t.baseURI;c.open();let d=ys(t.doctype)+`<html></html>`;try{let e=ls(t.defaultView),n=e?e.createHTML(d):d;c.write(n)}catch{c.write(d)}bs(t,a,o),c.close();let f=c.adoptNode(r.documentElement);Ss(f,u),c.replaceChild(f,c.documentElement);let p=gs(c,e.logger,r.signal);return l.catch(e=>{throw i.parentNode?.removeChild(i),e})},ws=e=>{let t=e;for(;t;){if(t.parentNode&&t.parentNode.host)return t.parentNode;let e=t.getRootNode();if(e&&e!==t.ownerDocument&&e.host)return e;t=t.parentNode}return null};var Ts=class{context;options;scrolledElements;referenceElement;clonedReferenceElement;documentElement;counters;pseudoContents;slotCloner;constructor(e,t,n){if(this.context=e,this.options=n,this.scrolledElements=[],this.referenceElement=t,this.counters=new ir,this.pseudoContents=new ss(e,this.counters),this.slotCloner=new $o((e,t)=>this.cloneNode(e,t),{ignoreElements:n.ignoreElements,copyStyles:n.copyStyles??!0,cspNonce:n.cspNonce},e),!t.ownerDocument)throw Error(`Cloned element does not have an owner document`);if(!this.options.iframeContainer){let e=ws(t);e&&(this.options.iframeContainer=e)}this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1),this.appendDocumentAdoptedStyles(t.ownerDocument),this.appendPseudoHideStyles()}appendDocumentAdoptedStyles(e){if(this.options.copyStyles)return;let t=e.adoptedStyleSheets;if(!t||t.length===0)return;let n=this.documentElement.getElementsByTagName(`head`).item(0);if(!n)return;let r=Qo(this.documentElement.ownerDocument??e,t,this.options.cspNonce);r&&n.appendChild(r)}appendPseudoHideStyles(){let e=this.documentElement.getElementsByTagName(`head`).item(0);as(e??this.documentElement,this.options.cspNonce)}toIFrame(e,t){return Cs(this.context,e,t,{documentElement:this.documentElement,clonedReferenceElement:this.clonedReferenceElement,referenceElementName:this.referenceElement.nodeName,scrolledElements:this.scrolledElements,onclone:this.options.onclone,container:this.options.iframeContainer,signal:this.options.signal})}createElementClone(e){if(Xo(e,2))debugger;if(Un(e))return this.createCanvasClone(e);if(Wn(e))return this.createVideoClone(e);if(qn(e))return this.createStyleClone(e);let t=e.cloneNode(!1);return Gn(t)&&(Gn(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=``),t.loading===`lazy`&&(t.loading=`eager`)),er(t)&&!Ln(t)?this.createCustomElementClone(e,t):t}createCustomElementClone(e,t){let n=document.createElement(`div`);n.className=t.className,ts(t.style,n);let r=t.attributes;for(let e=0;e<r.length;e++){let t=r.item(e);t&&t.name!==`class`&&t.name!==`style`&&n.setAttribute(t.name,t.value)}if(e.shadowRoot)try{n.attachShadow({mode:`open`})}catch(e){this.context.logger.error(`Failed to attach shadow root to custom element clone:`,e)}return n}createStyleClone(e){try{let t=e.sheet;if(t&&t.cssRules){let n=[].slice.call(t.cssRules,0).reduce((e,t)=>t&&typeof t.cssText==`string`?e+t.cssText:e,``),r=e.cloneNode(!1);return r.textContent=n,this.options.cspNonce&&(r.nonce=this.options.cspNonce),r}}catch(e){if(this.context.logger.error(`Unable to access cssRules property`,e),e.name!==`SecurityError`)throw e}let t=e.cloneNode(!1);return this.options.cspNonce&&(t.nonce=this.options.cspNonce),t}createCanvasClone(e){if(this.options.inlineImages&&e.ownerDocument){let t=e.ownerDocument.createElement(`img`);try{return t.src=e.toDataURL(),t}catch{this.context.logger.info(`Unable to inline canvas contents, canvas is tainted`,e)}}let t=e.cloneNode(!1);try{t.width=e.width,t.height=e.height;let n=e.getContext(`2d`),r=t.getContext(`2d`,{willReadFrequently:!0});if(r){if(!this.options.allowTaint&&n)r.putImageData(n.getImageData(0,0,e.width,e.height),0,0);else{let t=e.getContext(`webgl2`)??e.getContext(`webgl`);t&&t.getContextAttributes()?.preserveDrawingBuffer===!1&&this.context.logger.warn(`Unable to clone WebGL context as it has preserveDrawingBuffer=false`,e),r.drawImage(e,0,0)}}return t}catch{this.context.logger.info(`Unable to clone canvas as it is tainted`,e)}return t}createVideoClone(e){let t=e.ownerDocument.createElement(`canvas`);t.width=e.offsetWidth,t.height=e.offsetHeight;let n=t.getContext(`2d`);try{return n&&(n.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||n.getImageData(0,0,t.width,t.height)),t}catch{this.context.logger.info(`Unable to clone video as it is tainted`,e)}let r=e.ownerDocument.createElement(`canvas`);return r.width=e.offsetWidth,r.height=e.offsetHeight,r}appendChildNode(e,t,n){this.slotCloner.appendChildNode(e,t,n)}cloneChildNodes(e,t,n){this.slotCloner.cloneChildNodes(e,t,n)}cloneNode(e,t){if(In(e))return(e.ownerDocument??document).createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);let n=e.ownerDocument.defaultView;if(n&&Fn(e)&&(Rn(e)||Ln(e))){let r=this.createElementClone(e);r.style.transitionProperty=`none`;let i=n.getComputedStyle(e),a=nr(e);this.referenceElement===e&&Rn(r)&&(this.clonedReferenceElement=r);let o=this.counters.parse(new Jo(this.context,i));if(a){let t=n.getComputedStyle(e,`:before`),i=this.pseudoContents.resolvePseudoContent(e,r,t,0);i&&r.insertBefore(i,r.firstChild)}if(er(e)&&(t=!0),Wn(e)||this.cloneChildNodes(e,r,t),a){let t=n.getComputedStyle(e,`:after`),i=this.pseudoContents.resolvePseudoContent(e,r,t,1);i&&r.appendChild(i)}return this.counters.pop(o),(i&&(this.options.copyStyles||Ln(e))&&!Kn(e)||t)&&ts(i,r),(e.scrollTop!==0||e.scrollLeft!==0)&&this.scrolledElements.push([r,e.scrollLeft,e.scrollTop]),(Yn(e)||Xn(e))&&(Yn(r)||Xn(r))&&(r.value=e.value),r}return e.cloneNode(!1)}static destroy(e){return e.parentNode?(e.parentNode.removeChild(e),!0):!1}},Es=class{static normalizeElement(e,t){let n={};if(!Rn(e)&&!Ln(e))return n;t.animationDuration.some(e=>e>0)&&(n.animationDuration=e.style.animationDuration,e.style.animationDuration=`0s`),t.transform!==null&&(n.transform=e.style.transform,e.style.transform=`translate(0, 0)`);let r=!1;return t.rotate!==null&&(n.rotate=e.style.rotate,e.style.rotate=`0deg`,r=!0),t.translate!==null&&(n.translate=e.style.translate,e.style.translate=`0px`,r=!0),t.scale!==null&&(n.scale=e.style.scale,e.style.scale=`1`,r=!0),r&&n.transform===void 0&&(n.transform=e.style.transform,e.style.transform=`translate(0, 0)`),n}static restoreElement(e,t){(Rn(e)||Ln(e))&&(t.animationDuration!==void 0&&(e.style.animationDuration=t.animationDuration),t.transform!==void 0&&(e.style.transform=t.transform),t.rotate!==void 0&&(e.style.rotate=t.rotate),t.translate!==void 0&&(e.style.translate=t.translate),t.scale!==void 0&&(e.style.scale=t.scale))}};let Ds={x:`-10%`,y:`-10%`,width:`120%`,height:`120%`},Os=[`color-interpolation-filters`,`flood-color`,`flood-opacity`,`lighting-color`],ks=/^(["']?)(#[^"'\s()]+)\1$/,As=/url\(\s*([^)]*?)\s*\)/g,js=e=>{let t=ks.exec(e.trim());return t?t[2]:null};function Ms(e,t,n){if(!t||t.indexOf(`url(`)===-1)return;let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Set;for(let a of t.matchAll(As)){let t=js(a[1]);if(!t||i.has(t))continue;i.add(t);let o=Ns(e.ownerDocument,t,n);o&&r.set(t,o)}return r}function Ns(e,t,n){let r=e.getElementById(t.slice(1));if(!r||r.namespaceURI!==`http://www.w3.org/2000/svg`||r.localName!==`filter`||!Fs(r))return null;let i=Is(r,n);if(!i)return null;let a=r.cloneNode(!0);Ls(r,a),a.removeAttribute(`id`),a.setAttribute(`filterUnits`,`userSpaceOnUse`),Object.keys(i).forEach(e=>a.setAttribute(e,String(i[e])));let o=Math.max(0,-i.x,-i.y,i.x+i.width-n.width,i.y+i.height-n.height);return{element:a,region:i,outset:Math.ceil(o)}}let Ps=e=>e.hasAttribute(`href`)||e.hasAttributeNS(`http://www.w3.org/1999/xlink`,`href`);function Fs(e){if(e.getAttribute(`primitiveUnits`)===`objectBoundingBox`||Ps(e))return!1;for(let t of Array.from(e.querySelectorAll(`*`))){if(t.localName===`feImage`||Ps(t))return!1;for(let e of[`x`,`y`,`width`,`height`])if((t.getAttribute(e)??``).indexOf(`%`)!==-1)return!1}return!0}function Is(e,t){let n=e.getAttribute(`filterUnits`)!==`userSpaceOnUse`,r=(t,r)=>{let i=(e.getAttribute(t)??(n?Ds[t]:``)).trim();if(i===``)return null;let a=i.endsWith(`%`),o=Number(a?i.slice(0,-1):i.replace(/px$/,``));return Number.isFinite(o)?n?(a?o/100:o)*r:a?null:o:null},i=r(`x`,t.width),a=r(`y`,t.height),o=r(`width`,t.width),s=r(`height`,t.height);return i===null||a===null||o===null||s===null||o<=0||s<=0?null:{x:i,y:a,width:o,height:s}}function Ls(e,t){let n=e.ownerDocument.defaultView;if(!n)return;let r=[e,...Array.from(e.querySelectorAll(`*`))],i=[t,...Array.from(t.querySelectorAll(`*`))];r.forEach((e,t)=>{let r=n.getComputedStyle(e);for(let e of Os){let n=r.getPropertyValue(e);n&&i[t]?.setAttribute(e,n)}})}var Rs=class{context;styles;textNodes=[];elements=[];bounds;legendBounds;filterReferences;createsStackingContext=!1;createsRealStackingContext=!1;isListOwner=!1;debugRender=!1;originalStyles;originalElement;constructor(e,t,n={}){if(this.context=e,Xo(t,3))debugger;if(this.styles=new Go(e,e.config.window.getComputedStyle(t,null)),n.normalizeDom!==!1&&(Rn(t)||Ln(t))&&(this.originalStyles=Es.normalizeElement(t,this.styles),this.originalElement=t),this.bounds=o(this.context,t),t.tagName===`FIELDSET`){let e=t.querySelector(`:scope > legend`);if(e){let t=o(this.context,e);this.legendBounds=t;let n=t.top+t.height/2-this.styles.borderTopWidth/2;this.bounds=new a(this.bounds.left,n,this.bounds.width,this.bounds.height-(n-this.bounds.top))}}this.filterReferences=Ms(t,this.styles.filter,this.bounds),Xo(t,4)&&(this.debugRender=!0)}restore(){this.originalStyles&&this.originalElement&&(Es.restoreElement(this.originalElement,this.originalStyles),this.originalStyles=void 0,this.originalElement=void 0)}restoreTree(){this.restore();for(let e of this.elements)e.restoreTree()}};let zs=e=>{if(e.createRange){let t=e.createRange();if(t.getBoundingClientRect){let n=e.createElement(`boundtest`);n.style.height=`123px`,n.style.display=`block`,e.body.appendChild(n),t.selectNode(n);let r=t.getBoundingClientRect(),i=Math.round(r.height);if(e.body.removeChild(n),i===123)return!0}}return!1},Bs=()=>new Image().crossOrigin!==void 0,Vs=e=>{let t=new Image,n=e.createElement(`canvas`),r=n.getContext(`2d`);if(!r)return!1;t.src=`data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>`;try{r.drawImage(t,0,0),n.toDataURL()}catch{return!1}return!0},Hs=(e,t,n,r,i)=>{let a=`http://www.w3.org/2000/svg`,o=document.createElementNS(a,`svg`),s=document.createElementNS(a,`foreignObject`);return o.setAttributeNS(null,`width`,e.toString()),o.setAttributeNS(null,`height`,t.toString()),s.setAttributeNS(null,`width`,`100%`),s.setAttributeNS(null,`height`,`100%`),s.setAttributeNS(null,`x`,n.toString()),s.setAttributeNS(null,`y`,r.toString()),s.setAttributeNS(null,`externalResourcesRequired`,`true`),o.appendChild(s),s.appendChild(i),o},Us=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=n,r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(e))}`}),Ws={get SUPPORT_RANGE_BOUNDS(){"use strict";let e=zs(document);return Object.defineProperty(Ws,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_SVG_DRAWING(){"use strict";let e=Vs(document);return Object.defineProperty(Ws,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){"use strict";let e=Bs();return Object.defineProperty(Ws,"SUPPORT_CORS_IMAGES",{value:e}),e}};var Gs=class{text;bounds;constructor(e,t){this.text=e,this.bounds=t}};let Ks=(e,t,n,r)=>{let i=$s(t,n),o=[],s=0;return i.forEach(t=>{if(n.textDecorationLine.length||t.trim().length>0){if(Ws.SUPPORT_RANGE_BOUNDS){let n=Js(r,s,t.length).getClientRects();if(n.length>1){let n=Zs(t),i=0;n.forEach(t=>{o.push(new Gs(t,a.fromDOMRectList(e,Js(r,i+s,t.length).getClientRects()))),i+=t.length})}else o.push(new Gs(t,a.fromDOMRectList(e,n)))}else{let n=r.splitText(t.length);o.push(new Gs(t,qs(e,r))),r=n}}else Ws.SUPPORT_RANGE_BOUNDS||(r=r.splitText(t.length));s+=t.length}),o},qs=(e,t)=>{let n=t.ownerDocument;if(n){let r=n.createElement(`html2canvaswrapper`);r.appendChild(t.cloneNode(!0));let i=t.parentNode;if(i){i.replaceChild(r,t);let n=o(e,r);return r.firstChild&&i.replaceChild(r.firstChild,r),n}}return a.EMPTY},Js=(e,t,n)=>{let r=e.ownerDocument;if(!r)throw Error(`Node has no owner document`);let i=r.createRange();return i.setStart(e,t),i.setEnd(e,t+n),i},Ys=/* @__PURE__ */ new Map,Xs=e=>{let t=Ys.get(e);return t||(t=new Intl.Segmenter(void 0,{granularity:e}),Ys.set(e,t)),t},Zs=e=>Array.from(Xs(`grapheme`).segment(e),e=>e.segment),Qs=e=>Array.from(Xs(`word`).segment(e),e=>e.segment),$s=(e,t)=>ka(t.writingMode)?Zs(e):t.letterSpacing===0?Qs(e):Zs(e);var ec=class{text;textBounds;constructor(e,t,n){this.text=tc(t.data,n.textTransform),this.text.length!==t.data.length&&(t.data=this.text),this.textBounds=Ks(e,this.text,n,t)}};let tc=(e,t)=>{switch(t){case 1:return e.toLowerCase();case 3:return e.replace(nc,rc);case 2:return e.toUpperCase();default:return e}},nc=/(^|\s|:|-|\(|\))([a-z])/g,rc=(e,t,n)=>e.length>0?t+n.toUpperCase():e;var ic=class extends Rs{src;intrinsicWidth;intrinsicHeight;constructor(e,t,n={}){super(e,t,n),this.src=t.currentSrc||t.src,this.intrinsicWidth=t.naturalWidth,this.intrinsicHeight=t.naturalHeight,this.context.cache.addImage(this.src)}},ac=class extends Rs{canvas;intrinsicWidth;intrinsicHeight;constructor(e,t,n={}){super(e,t,n),this.canvas=t,this.intrinsicWidth=t.width,this.intrinsicHeight=t.height}};let oc=[`position`,`inset`,`top`,`right`,`bottom`,`left`,`inset-inline`,`inset-inline-start`,`inset-inline-end`,`inset-block`,`inset-block-start`,`inset-block-end`,`margin`,`margin-top`,`margin-right`,`margin-bottom`,`margin-left`,`margin-inline`,`margin-inline-start`,`margin-inline-end`,`margin-block`,`margin-block-start`,`margin-block-end`],sc=(e,t)=>{let n=t.getAttribute(`style`);oc.forEach(e=>t.style.removeProperty(e));let r=e.serializeToString(t);return n===null?t.removeAttribute(`style`):t.setAttribute(`style`,n),r};var cc=class extends Rs{svg;intrinsicWidth;intrinsicHeight;constructor(e,t,n={}){super(e,t,n);let r=new XMLSerializer,i=o(e,t);t.setAttribute(`width`,`${i.width}px`),t.setAttribute(`height`,`${i.height}px`),this.svg=`data:image/svg+xml,${encodeURIComponent(sc(r,t))}`,this.intrinsicWidth=t.width.baseVal.value,this.intrinsicHeight=t.height.baseVal.value,this.context.cache.addImage(this.svg)}},lc=class extends Rs{value;constructor(e,t,n={}){super(e,t,n),this.value=t.value}},uc=class extends Rs{start;reversed;constructor(e,t,n={}){super(e,t,n),this.start=t.start,this.reversed=typeof t.reversed==`boolean`&&t.reversed===!0}};let dc=[{type:15,flags:0,unit:`px`,number:3}],fc=[{type:16,flags:0,number:50}],pc=e=>e.width>e.height?new a(e.left+(e.width-e.height)/2,e.top,e.height,e.height):e.width<e.height?new a(e.left,e.top+(e.height-e.width)/2,e.width,e.width):e,mc=e=>{let t=e.type===`password`?Array(e.value.length+1).join(`•`):e.value;return t.length===0?e.placeholder||``:t},hc=e=>e.value.length===0&&!!e.placeholder;var gc=class extends Rs{type;checked;value;isPlaceholder;constructor(e,t,n={}){switch(super(e,t,n),this.type=t.type.toLowerCase(),this.checked=t.checked,this.value=mc(t),this.isPlaceholder=hc(t),(this.type===`checkbox`||this.type===`radio`)&&(this.styles.backgroundColor=3739148031,this.styles.borderTopColor=this.styles.borderRightColor=this.styles.borderBottomColor=this.styles.borderLeftColor=2779096575,this.styles.borderTopWidth=this.styles.borderRightWidth=this.styles.borderBottomWidth=this.styles.borderLeftWidth=1,this.styles.borderTopStyle=this.styles.borderRightStyle=this.styles.borderBottomStyle=this.styles.borderLeftStyle=1,this.styles.backgroundClip=[0],this.styles.backgroundOrigin=[0],this.bounds=pc(this.bounds)),this.type){case`checkbox`:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=dc;break;case`radio`:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=fc}}},_c=class extends Rs{value;constructor(e,t,n={}){super(e,t,n);let r=t.options[t.selectedIndex||0];this.value=r&&r.text||``}},vc=class extends Rs{value;constructor(e,t,n={}){super(e,t,n),this.value=t.value}},yc=class extends Rs{src;width;height;tree;backgroundColor;parseTreeFn;constructor(e,t,n,r={}){super(e,t,r),this.src=t.src,this.width=parseInt(t.width,10)||0,this.height=parseInt(t.height,10)||0,this.backgroundColor=this.styles.backgroundColor,this.parseTreeFn=n;try{let n=t.contentWindow,r=n?.document;if(n&&r&&r.documentElement&&this.parseTreeFn){this.tree=this.parseTreeFn(e,r.documentElement);let t=Nn(e,n.getComputedStyle(r.documentElement).backgroundColor),i=r.body?Nn(e,n.getComputedStyle(r.body).backgroundColor):0;this.backgroundColor=R(t)?R(i)?this.styles.backgroundColor:i:t}}catch(e){let t=e instanceof Error?e:Error(String(e));this.context.logger.warn(`Unable to render iframe content${this.src?` from ${this.src}`:``}: ${t.message}`),this.context.onError?.(t)}}};let bc=[`OL`,`UL`,`MENU`],xc=(e,t,n,r,i=1,a={})=>{for(let o=t.firstChild,s;o;o=s)s=o.nextSibling,Sc(e,o,n,r,i,a)},Sc=(e,t,n,r,i=1,o={})=>{if(In(t)&&t.data.length>0){let r=new ec(e,t,n.styles);if(i!==1){let e=n.bounds.left,t=n.bounds.top;r.textBounds=r.textBounds.map(n=>new Gs(n.text,new a(e+(n.bounds.left-e)/i,t+(n.bounds.top-t)/i,n.bounds.width/i,n.bounds.height/i)))}n.textNodes.push(r)}else if(Fn(t)){if(Zn(t)&&t.assignedNodes)t.assignedNodes().forEach(t=>Sc(e,t,n,r,i,o));else{let s=Cc(e,t,o),c=s.styles.zoom||1;if(c!==1&&(s.bounds=new a(s.bounds.left,s.bounds.top,s.bounds.width/c,s.bounds.height/c)),s.styles.isVisible()){Tc(t,s,r)?s.createsRealStackingContext=!0:Ec(s.styles)&&(s.createsStackingContext=!0),bc.indexOf(t.tagName)!==-1&&(s.isListOwner=!0),n.elements.push(s);let a=i*(s.styles.zoom||1);t.shadowRoot?xc(e,t.shadowRoot,s,r,a,o):!Yn(t)&&!Vn(t)&&!Xn(t)&&xc(e,t,s,r,a,o)}}}},Cc=(e,t,n={})=>Gn(t)?new ic(e,t,n):Un(t)?new ac(e,t,n):Vn(t)?new cc(e,t,n):Qn(t)?new lc(e,t,n):$n(t)?new uc(e,t,n):zn(t)?new gc(e,t,n):Xn(t)?new _c(e,t,n):Yn(t)?new vc(e,t,n):Kn(t)?new yc(e,t,(e,t)=>wc(e,t,n),n):new Rs(e,t,n),wc=(e,t,n={})=>{let r=Cc(e,t,n);return r.createsRealStackingContext=!0,xc(e,t,r,r,1,n),r},Tc=(e,t,n)=>t.styles.isPositionedWithZIndex()||t.styles.opacity<1||!!t.styles.filter||!!t.styles.backdropFilter||t.styles.maskImage.length>0||!!t.styles.webkitBoxReflect||t.styles.isolation===1||t.styles.isTransformed()||Hn(e)&&n.styles.isTransparent(),Ec=e=>e.isPositioned()||e.isFloating()||e.mixBlendMode!==K.NORMAL?!0:H(e.display,268435456)||H(e.display,33554432)||H(e.display,536870912)||H(e.display,134217728),Dc=(e,t)=>e.length===t.length&&e.some((e,n)=>e===t[n]),Oc=(e,t,n,r,i)=>e.map((e,a)=>{switch(a){case 0:return e.add(t,n);case 1:return e.add(t+r,n);case 2:return e.add(t+r,n+i);case 3:return e.add(t,n+i)}return e});var J=class e{type;x;y;constructor(e,t){this.type=0,this.x=e,this.y=t}add(t,n){return new e(this.x+t,this.y+n)}};let kc=(e,t,n)=>new J(e.x+(t.x-e.x)*n,e.y+(t.y-e.y)*n);var Ac=class e{type;start;startControl;endControl;end;constructor(e,t,n,r){this.type=1,this.start=e,this.startControl=t,this.endControl=n,this.end=r}subdivide(t,n){let r=kc(this.start,this.startControl,t),i=kc(this.startControl,this.endControl,t),a=kc(this.endControl,this.end,t),o=kc(r,i,t),s=kc(i,a,t),c=kc(o,s,t);return n?new e(this.start,r,o,c):new e(c,s,a,this.end)}add(t,n){return new e(this.start.add(t,n),this.startControl.add(t,n),this.endControl.add(t,n),this.end.add(t,n))}reverse(){return new e(this.end,this.endControl,this.startControl,this.start)}};let Y=e=>e.type===1;var jc=class{topLeftBorderDoubleOuterBox;topRightBorderDoubleOuterBox;bottomRightBorderDoubleOuterBox;bottomLeftBorderDoubleOuterBox;topLeftBorderDoubleInnerBox;topRightBorderDoubleInnerBox;bottomRightBorderDoubleInnerBox;bottomLeftBorderDoubleInnerBox;topLeftBorderStroke;topRightBorderStroke;bottomRightBorderStroke;bottomLeftBorderStroke;topLeftBorderBox;topRightBorderBox;bottomRightBorderBox;bottomLeftBorderBox;topLeftPaddingBox;topRightPaddingBox;bottomRightPaddingBox;bottomLeftPaddingBox;topLeftContentBox;topRightContentBox;bottomRightContentBox;bottomLeftContentBox;constructor(e){let t=e.styles,n=e.bounds,[r,i]=He(t.borderTopLeftRadius,n.width,n.height),[a,o]=He(t.borderTopRightRadius,n.width,n.height),[s,c]=He(t.borderBottomRightRadius,n.width,n.height),[l,u]=He(t.borderBottomLeftRadius,n.width,n.height),d=[];d.push((r+a)/n.width),d.push((l+s)/n.width),d.push((i+u)/n.height),d.push((o+c)/n.height);let f=Math.max(...d);f>1&&(r/=f,i/=f,a/=f,o/=f,s/=f,c/=f,l/=f,u/=f);let p=n.width-a,m=n.height-c,h=n.width-s,g=n.height-u,_=t.borderTopWidth,v=t.borderRightWidth,y=t.borderBottomWidth,b=t.borderLeftWidth,x=I(t.paddingTop,e.bounds.width),S=I(t.paddingRight,e.bounds.width),C=I(t.paddingBottom,e.bounds.width),w=I(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||i>0?X(n.left+b/3,n.top+_/3,r-b/3,i-_/3,0):new J(n.left+b/3,n.top+_/3),this.topRightBorderDoubleOuterBox=a>0||o>0?X(n.left+p,n.top+_/3,a-v/3,o-_/3,1):new J(n.left+n.width-v/3,n.top+_/3),this.bottomRightBorderDoubleOuterBox=s>0||c>0?X(n.left+h,n.top+m,s-v/3,c-y/3,2):new J(n.left+n.width-v/3,n.top+n.height-y/3),this.bottomLeftBorderDoubleOuterBox=l>0||u>0?X(n.left+b/3,n.top+g,l-b/3,u-y/3,3):new J(n.left+b/3,n.top+n.height-y/3),this.topLeftBorderDoubleInnerBox=r>0||i>0?X(n.left+b*2/3,n.top+_*2/3,r-b*2/3,i-_*2/3,0):new J(n.left+b*2/3,n.top+_*2/3),this.topRightBorderDoubleInnerBox=a>0||o>0?X(n.left+p,n.top+_*2/3,a-v*2/3,o-_*2/3,1):new J(n.left+n.width-v*2/3,n.top+_*2/3),this.bottomRightBorderDoubleInnerBox=s>0||c>0?X(n.left+h,n.top+m,s-v*2/3,c-y*2/3,2):new J(n.left+n.width-v*2/3,n.top+n.height-y*2/3),this.bottomLeftBorderDoubleInnerBox=l>0||u>0?X(n.left+b*2/3,n.top+g,l-b*2/3,u-y*2/3,3):new J(n.left+b*2/3,n.top+n.height-y*2/3),this.topLeftBorderStroke=r>0||i>0?X(n.left+b/2,n.top+_/2,r-b/2,i-_/2,0):new J(n.left+b/2,n.top+_/2),this.topRightBorderStroke=a>0||o>0?X(n.left+p,n.top+_/2,a-v/2,o-_/2,1):new J(n.left+n.width-v/2,n.top+_/2),this.bottomRightBorderStroke=s>0||c>0?X(n.left+h,n.top+m,s-v/2,c-y/2,2):new J(n.left+n.width-v/2,n.top+n.height-y/2),this.bottomLeftBorderStroke=l>0||u>0?X(n.left+b/2,n.top+g,l-b/2,u-y/2,3):new J(n.left+b/2,n.top+n.height-y/2),this.topLeftBorderBox=r>0||i>0?X(n.left,n.top,r,i,0):new J(n.left,n.top),this.topRightBorderBox=a>0||o>0?X(n.left+p,n.top,a,o,1):new J(n.left+n.width,n.top),this.bottomRightBorderBox=s>0||c>0?X(n.left+h,n.top+m,s,c,2):new J(n.left+n.width,n.top+n.height),this.bottomLeftBorderBox=l>0||u>0?X(n.left,n.top+g,l,u,3):new J(n.left,n.top+n.height),this.topLeftPaddingBox=r>0||i>0?X(n.left+b,n.top+_,Math.max(0,r-b),Math.max(0,i-_),0):new J(n.left+b,n.top+_),this.topRightPaddingBox=a>0||o>0?X(n.left+Math.min(p,n.width-v),n.top+_,p>n.width+v?0:Math.max(0,a-v),Math.max(0,o-_),1):new J(n.left+n.width-v,n.top+_),this.bottomRightPaddingBox=s>0||c>0?X(n.left+Math.min(h,n.width-b),n.top+Math.min(m,n.height-y),Math.max(0,s-v),Math.max(0,c-y),2):new J(n.left+n.width-v,n.top+n.height-y),this.bottomLeftPaddingBox=l>0||u>0?X(n.left+b,n.top+Math.min(g,n.height-y),Math.max(0,l-b),Math.max(0,u-y),3):new J(n.left+b,n.top+n.height-y),this.topLeftContentBox=r>0||i>0?X(n.left+b+w,n.top+_+x,Math.max(0,r-(b+w)),Math.max(0,i-(_+x)),0):new J(n.left+b+w,n.top+_+x),this.topRightContentBox=a>0||o>0?X(n.left+Math.min(p,n.width+b+w),n.top+_+x,p>n.width+b+w?0:a-b+w,o-(_+x),1):new J(n.left+n.width-(v+S),n.top+_+x),this.bottomRightContentBox=s>0||c>0?X(n.left+Math.min(h,n.width-(b+w)),n.top+Math.min(m,n.height+_+x),Math.max(0,s-(v+S)),c-(y+C),2):new J(n.left+n.width-(v+S),n.top+n.height-(y+C)),this.bottomLeftContentBox=l>0||u>0?X(n.left+b+w,n.top+g,Math.max(0,l-(b+w)),u-(y+C),3):new J(n.left+b+w,n.top+n.height-(y+C))}};let X=(e,t,n,r,i)=>{let a=4*((Math.sqrt(2)-1)/3),o=n*a,s=r*a,c=e+n,l=t+r;switch(i){case 0:return new Ac(new J(e,l),new J(e,l-s),new J(c-o,t),new J(c,t));case 1:return new Ac(new J(e,t),new J(e+o,t),new J(c,l-s),new J(c,l));case 2:return new Ac(new J(c,t),new J(c,t+s),new J(e+o,l),new J(e,l));default:return new Ac(new J(c,l),new J(c-o,l),new J(e,t+s),new J(e,t))}},Mc=e=>[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox],Nc=e=>[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox],Pc=e=>[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox];var Fc=class{offsetX;offsetY;matrix;type=0;target=6;constructor(e,t,n){this.offsetX=e,this.offsetY=t,this.matrix=n}},Ic=class{path;target;type=1;constructor(e,t){this.path=e,this.target=t}},Lc=class{opacity;type=2;target=6;constructor(e){this.opacity=e}},Rc=class{applyClip;type=3;target=6;constructor(e){this.applyClip=e}};let zc={[K.NORMAL]:`source-over`,[K.MULTIPLY]:`multiply`,[K.SCREEN]:`screen`,[K.OVERLAY]:`overlay`,[K.DARKEN]:`darken`,[K.LIGHTEN]:`lighten`,[K.COLOR_DODGE]:`color-dodge`,[K.COLOR_BURN]:`color-burn`,[K.HARD_LIGHT]:`hard-light`,[K.SOFT_LIGHT]:`soft-light`,[K.DIFFERENCE]:`difference`,[K.EXCLUSION]:`exclusion`,[K.HUE]:`hue`,[K.SATURATION]:`saturation`,[K.COLOR]:`color`,[K.LUMINOSITY]:`luminosity`};var Bc=class{mixBlendMode;type=4;target=6;compositeOperation;constructor(e){this.mixBlendMode=e,this.compositeOperation=zc[e]}},Vc=class e{type=5;target=6;safeFilterString;shadow;constructor(t){let n=e.parseDropShadow(t);this.shadow=n.shadow,this.safeFilterString=n.safeFilterString}static parseDropShadow(t){if(!t)return{safeFilterString:``};let n=e.findDropShadows(t);if(n.length===0)return{safeFilterString:t};let r=e.parseDropShadowBody(c(n,0).body),i=``,a=0;for(let e of n)i+=t.slice(a,e.start),a=e.end;return i+=t.slice(a),{shadow:r,safeFilterString:i.replace(/\s+/g,` `).trim()}}static findDropShadows(e){let t=[],n=/drop-shadow\(/gi,r;for(;(r=n.exec(e))!==null;){let n=r.index+12-1,i=r.index,a=1,o=n+1;for(;o<e.length&&a>0;){let t=e[o]??``;t===`(`?a++:t===`)`&&a--,o++}if(a!==0)break;let s=e.slice(n+1,o-1);t.push({body:s,start:i,end:o})}return t}static parseDropShadowBody(t){let n=e.tokenizeFilterArgs(t.trim()),r=[],i;for(let t of n)e.isCSSLength(t)?r.push(parseFloat(t)):t&&(i=t);if(!(r.length<2||r.length>3))return{offsetX:c(r,0),offsetY:c(r,1),blur:r.length>2?c(r,2):0,color:i??`rgba(0,0,0,1)`}}static tokenizeFilterArgs(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i++){let a=e[i]??``;a===`(`?(r++,n+=a):a===`)`?(r--,n+=a):/\s/.test(a)?r>0?n+=a:n&&=(t.push(n),``):n+=a}return n&&t.push(n),t}static isCSSLength(e){return/^-?[\d.]+(px|em|rem|pt|cm|mm|in|pc|ex|ch|vw|vh|vmin|vmax|%)?$/i.test(e)}};let Hc=e=>e.type===0,Uc=e=>e.type===1,Wc=e=>e.type===2,Gc=e=>e.type===3,Kc=e=>e.type===4,qc=e=>e.type===5;var Jc=class{element;negativeZIndex;zeroOrAutoZIndexOrTransformedOrOpacity;positiveZIndex;nonPositionedFloats;nonPositionedInlineLevel;inlineLevel;nonInlineLevel;constructor(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}},Yc=class{container;parent;effects=[];curves;listValue;plainEffectsCache=null;constructor(e,t){if(this.container=e,this.parent=t,this.curves=new jc(this.container),this.container.styles.opacity<1&&this.effects.push(new Lc(this.container.styles.opacity)),this.container.styles.translate!==null){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+I(e[0],this.container.bounds.width),n=this.container.bounds.top+I(e[1],this.container.bounds.height),[r,i]=this.container.styles.translate,a=I(r,this.container.bounds.width),o=I(i,this.container.bounds.height);this.effects.push(new Fc(t,n,[1,0,0,1,a,o]))}if(this.container.styles.rotate!==null){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+I(e[0],this.container.bounds.width),n=this.container.bounds.top+I(e[1],this.container.bounds.height),r=this.container.styles.rotate*Math.PI/180,i=Math.cos(r),a=Math.sin(r),o=[i,a,-a,i,0,0];this.effects.push(new Fc(t,n,o))}if(this.container.styles.scale!==null){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+I(e[0],this.container.bounds.width),n=this.container.bounds.top+I(e[1],this.container.bounds.height),[r,i]=this.container.styles.scale;this.effects.push(new Fc(t,n,[r,0,0,i,0,0]))}if(this.container.styles.transform!==null){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+I(e[0],this.container.bounds.width),n=this.container.bounds.top+I(e[1],this.container.bounds.height),r=this.container.styles.transform;this.effects.push(new Fc(t,n,r))}if(Xc(this.container.styles)){let e=Mc(this.curves),t=Pc(this.curves);Dc(e,t)?this.effects.push(new Ic(e,6)):(this.effects.push(new Ic(e,2)),this.effects.push(new Ic(t,4)))}if(this.container.styles.clipPath.type!==0){let e=Qc(this.container.styles.clipPath,this.container.bounds);e&&this.effects.push(e)}if(this.container.styles.mixBlendMode!==K.NORMAL&&this.effects.push(new Bc(this.container.styles.mixBlendMode)),this.container.styles.filter!==null&&this.effects.push(new Vc(this.container.styles.filter)),this.container.styles.zoom!==1){let e=this.container.bounds.left,t=this.container.bounds.top,n=this.container.styles.zoom,r=[n,0,0,n,0,0];this.effects.push(new Fc(e,t,r))}}getEffects(e,t){if(!t){let t=this.plainEffectsCache;t||(t=/* @__PURE__ */ new Map,this.plainEffectsCache=t);let n=t.get(e);return n||(n=this.computeEffects(e),t.set(e,n)),n}return this.computeEffects(e,t)}computeEffects(e,t){let n=[2,3].indexOf(this.container.styles.position)===-1,r=this===t?null:this.parent,i=e=>e.effects.filter(n=>e!==t||!qc(n)&&!Wc(n)&&!Kc(n)),a=i(this);for(;r;){let e=i(r).filter(e=>!Uc(e));if(n||r.container.styles.position!==0||!r.parent){if(n=[2,3].indexOf(r.container.styles.position)===-1,Xc(r.container.styles)){let e=Mc(r.curves),t=Pc(r.curves);Dc(e,t)||a.unshift(new Ic(t,6))}a.unshift(...e)}else a.unshift(...e);r=r===t?null:r.parent}return a.filter(t=>H(t.target,e))}};let Xc=e=>e.overflowX!==0||e.overflowY!==0,Zc=(e,t,n,r,i)=>e===`closest-side`?Math.min(t-n,r-t):e===`farthest-side`?Math.max(t-n,r-t):I(e,i),Qc=(e,t)=>{let{left:n,top:r,width:i,height:a}=t;switch(e.type){case 1:{let t=I(e.left,i),o=I(e.top,a),s=n+t,c=r+o,l=Math.max(0,i-t-I(e.right,i)),u=Math.max(0,a-o-I(e.bottom,a));return new Rc(e=>{e.beginPath(),e.rect(s,c,l,u),e.clip()})}case 2:{let t=n+I(e.cx,i),o=r+I(e.cy,a),s;return s=e.radius===`closest-side`?Math.min(t-n,o-r,n+i-t,r+a-o):e.radius===`farthest-side`?Math.max(t-n,o-r,n+i-t,r+a-o):I(e.radius,Math.sqrt(i*i+a*a)/Math.SQRT2),new Rc(e=>{e.beginPath(),e.arc(t,o,Math.max(0,s),0,Math.PI*2),e.clip()})}case 3:{let t=n+I(e.cx,i),o=r+I(e.cy,a),s=Zc(e.rx,t,n,n+i,i),c=Zc(e.ry,o,r,r+a,a);return new Rc(e=>{e.beginPath(),e.ellipse(t,o,Math.max(0,s),Math.max(0,c),0,0,Math.PI*2),e.clip()})}case 4:{let t=e.points.map(([e,t])=>[n+I(e,i),r+I(t,a)]);return new Rc(e=>{if(e.beginPath(),t.length>0){e.moveTo(c(c(t,0),0),c(c(t,0),1));for(let n=1;n<t.length;n++)e.lineTo(c(c(t,n),0),c(c(t,n),1));e.closePath()}e.clip()})}case 5:{let{d:t}=e,i=null;return new Rc(e=>{try{i||=new Path2D(t);let a=e.getTransform();e.translate(n,r),e.clip(i),e.setTransform(a)}catch{}})}case 6:{let t=n+I(e.x,i),o=r+I(e.y,a),s=Math.max(0,I(e.width,i)),c=Math.max(0,I(e.height,a));return new Rc(e=>{e.beginPath(),e.rect(t,o,s,c),e.clip()})}case 0:return null;default:return null}},$c=(e,t,n,r)=>{e.container.elements.forEach(i=>{let a=i.createsRealStackingContext,o=i.createsStackingContext,s=new Yc(i,e);H(i.styles.display,2048)&&r.push(s);let c=i.isListOwner?[]:r;if(a||o){let e=a||i.styles.isPositioned()?n:t,r=new Jc(s);if(a||i.styles.isPositioned()||i.styles.opacity<1||i.styles.isTransformed()){let t=i.styles.zIndex.order;if(t<0){let n=0;e.negativeZIndex.some((e,r)=>t>=e.element.container.styles.zIndex.order?(n=r+1,!1):n>0),e.negativeZIndex.splice(n,0,r)}else if(t>0){let n=0;e.positiveZIndex.some((e,r)=>t>=e.element.container.styles.zIndex.order?(n=r+1,!1):n>0),e.positiveZIndex.splice(n,0,r)}else e.zeroOrAutoZIndexOrTransformedOrOpacity.push(r)}else i.styles.isFloating()?e.nonPositionedFloats.push(r):e.nonPositionedInlineLevel.push(r);$c(s,r,a?r:n,c)}else i.styles.isInlineLevel()?t.inlineLevel.push(s):t.nonInlineLevel.push(s),$c(s,t,n,c);i.isListOwner&&el(i,c)})},el=(e,t)=>{let n=e instanceof uc?e.start:1,r=e instanceof uc&&e.reversed;for(let e=0;e<t.length;e++){let i=c(t,e);i.container instanceof lc&&typeof i.container.value==`number`&&i.container.value!==0&&(n=i.container.value),i.listValue=_r(n,i.container.styles.listStyleType,!0),n+=r?-1:1}},tl=e=>{let t=new Yc(e,null),n=new Jc(t),r=[];return $c(t,n,n,r),el(t.container,r),n},nl=e=>Math.min(1,Math.max(0,e)),rl=e=>{let t=c(e,0),n=c(e,e.length-1);if(n.stop-t.stop<1e-6)return null;let r=Math.max(n.stop-t.stop,.01),i=[],a=Math.ceil(1/r);for(let n=0;n<a;n++)for(let a of e){let e=n*r+(a.stop-t.stop);if(e>1)break;i.push({stop:e,color:z(a.color)})}let o=i[i.length-1];return(!o||o.stop<1)&&i.push({stop:1,color:z(n.color)}),i},il=e=>e.map(e=>({stop:nl(e.stop),color:z(e.color)})),al=(e,t,n,r,i=!1)=>{let a=W(r,t),o=c(a,a.length-1),s=z(o.color),l=e.createElement(`canvas`);l.width=Math.max(1,Math.ceil(t*2)),l.height=Math.max(1,Math.ceil(n*2));let u=l.getContext(`2d`);if(!u)return null;let d;if(i){let e=rl(a);if(!e)return u.fillStyle=s,u.fillRect(0,0,l.width,l.height),{canvas:l,lastColor:s,rx:t,ry:n};d=e}else d=il(a);let f=u.createRadialGradient(t,t,0,t,t,t);return d.forEach(e=>f.addColorStop(nl(e.stop),e.color)),u.fillStyle=f,t!==n&&u.scale(1,n/t),u.fillRect(0,0,t*2,t*2),{canvas:l,lastColor:s,rx:t,ry:n}},ol=e=>{let t=e.bounds,n=e.styles;return t.add(n.borderLeftWidth,n.borderTopWidth,-(n.borderRightWidth+n.borderLeftWidth),-(n.borderTopWidth+n.borderBottomWidth))},sl=e=>{let t=e.styles,n=e.bounds,r=I(t.paddingLeft,n.width),i=I(t.paddingRight,n.width),a=I(t.paddingTop,n.width),o=I(t.paddingBottom,n.width);return n.add(r+t.borderLeftWidth,a+t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth+r+i),-(t.borderTopWidth+t.borderBottomWidth+a+o))},cl=(e,t)=>e===0?t.bounds:e===2?sl(t):ol(t),ll=(e,t)=>e===0?t.bounds:e===2?sl(t):ol(t),ul=(e,t,n)=>{let r=cl(ml(e.styles.backgroundOrigin,t),e),i=ll(ml(e.styles.backgroundClip,t),e),a=pl(ml(e.styles.backgroundSize,t),n,r),[o,s]=a,c=He(ml(e.styles.backgroundPosition,t),r.width-o,r.height-s),l=hl(ml(e.styles.backgroundRepeat,t),c,a,r,i),u=Math.round(r.left+c[0]),d=Math.round(r.top+c[1]);return o=Math.max(1,o),s=Math.max(1,s),[l,u,d,o,s]},dl=e=>D(e)&&e.value===`auto`,fl=e=>typeof e==`number`,pl=(e,[t,n,r],i)=>{let[a,o]=e;if(!a)return[0,0];if(M(a)&&o&&M(o))return[I(a,i.width),I(o,i.height)];let s=fl(r);if(D(a)&&(a.value===`contain`||a.value===`cover`))return fl(r)?i.width/i.height<r==(a.value===`cover`)?[i.height*r,i.height]:[i.width,i.width/r]:[i.width,i.height];let c=fl(t),l=fl(n),u=c||l;if(dl(a)&&(!o||dl(o)))return c&&l?[t,n]:!s&&!u?[i.width,i.height]:u&&s?[c?t:n*r,l?n:t/r]:[c?t:i.width,l?n:i.height];if(s){let e=0,t=0;return M(a)?e=I(a,i.width):o&&M(o)&&(t=I(o,i.height)),dl(a)?e=t*r:(!o||dl(o))&&(t=e/r),[e,t]}let d=null,f=null;if(M(a)?d=I(a,i.width):o&&M(o)&&(f=I(o,i.height)),d!==null&&(!o||dl(o))&&(f=c&&l?d/t*n:i.height),f!==null&&dl(a)&&(d=c&&l?f/n*t:i.width),d!==null&&f!==null)return[d,f];throw Error(`Unable to calculate background-size for element`)},ml=(e,t)=>{let n=e[t];return n===void 0?c(e,0):n},hl=(e,[t,n],[r,i],a,o)=>{switch(e){case 2:return[new J(Math.round(a.left),Math.round(a.top+n)),new J(Math.round(a.left+a.width),Math.round(a.top+n)),new J(Math.round(a.left+a.width),Math.round(i+a.top+n)),new J(Math.round(a.left),Math.round(i+a.top+n))];case 3:return[new J(Math.round(a.left+t),Math.round(a.top)),new J(Math.round(a.left+t+r),Math.round(a.top)),new J(Math.round(a.left+t+r),Math.round(a.height+a.top)),new J(Math.round(a.left+t),Math.round(a.height+a.top))];case 1:return[new J(Math.round(a.left+t),Math.round(a.top+n)),new J(Math.round(a.left+t+r),Math.round(a.top+n)),new J(Math.round(a.left+t+r),Math.round(a.top+n+i)),new J(Math.round(a.left+t),Math.round(a.top+n+i))];default:return[new J(Math.round(o.left),Math.round(o.top)),new J(Math.round(o.left+o.width),Math.round(o.top)),new J(Math.round(o.left+o.width),Math.round(o.height+o.top)),new J(Math.round(o.left),Math.round(o.height+o.top))]}};var Z=class extends Error{};let Q=e=>{e.width=e.height=0},gl=[`brightness`,`contrast`,`grayscale`,`hue-rotate`,`invert`,`opacity`,`saturate`,`sepia`],_l=/* @__PURE__ */ new Map,vl={functions:[]};function yl(e){if(!e||e===`none`)return vl;let t=_l.get(e);if(t!==void 0)return _l.delete(e),_l.set(e,t),t;let n=bl(e);if(_l.size>=256){let e=_l.keys().next().value;e!==void 0&&_l.delete(e)}return _l.set(e,n),n}let bl=e=>{let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===` `||r===`
|
|
11
|
-
`||r===` `){n++;continue}let i=e.indexOf(`(`,n);if(i===-1)return null;let a=e.slice(n,i).trim();if(!/^[a-zA-Z-]+$/.test(a))return null;let o=xl(e,i);if(o===-1)return null;let s=Cl(a,e.slice(i+1,o).trim());if(!s)return null;t.push(s),n=o+1}return{functions:t}},xl=(e,t)=>{let n=1;for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r}return-1},Sl=/^-?\d+(?:\.\d+)?px$/,Cl=(e,t)=>{if(e===`blur`){if(t===`0`)return{kind:`blur`,value:0};if(!Sl.test(t))return null;let e=Number.parseFloat(t);return e<0?null:{kind:`blur`,value:e}}if(e===`drop-shadow`)return Tl(t);if(gl.indexOf(e)!==-1){let n=e;if(n===`hue-rotate`){let e=El(t);return e===null?null:{kind:`unitless`,name:n,value:e}}let r=t.trim(),i=r.endsWith(`%`),a=i?r.slice(0,-1):r;return/^-?\d+(?:\.\d+)?$/.test(a)?{kind:`unitless`,name:n,value:Number.parseFloat(a)*(i?1/100:1)}:null}if(e===`url`){let e=js(t);return e?{kind:`url`,ref:e}:null}return null},wl=e=>{let t=[],n=0,r=``;for(let i of e)i===`(`?n++:i===`)`&&n--,i===` `&&n===0?(r&&t.push(r),r=``):r+=i;return r&&t.push(r),t},Tl=e=>{let t=wl(e),n=t.filter(e=>Sl.test(e)).map(e=>Number.parseFloat(e));if(n.length<2||n.length>3)return null;let r=t.filter(e=>!Sl.test(e));return t.length-r.length===n.length?{kind:`drop-shadow`,x:n[0],y:n[1],blur:n[2]??0,color:r.join(` `)||`rgba(0, 0, 0, 0)`}:null},El=e=>{let t=e.trim();if(t===`0`)return 0;let n=Number.parseFloat(t);return Number.isNaN(n)?null:t.endsWith(`deg`)?n:t.endsWith(`grad`)?n*.9:t.endsWith(`rad`)?n*180/Math.PI:t.endsWith(`turn`)?n*360:null},Dl=(e,t)=>e.functions.map(e=>{switch(e.kind){case`blur`:return`blur(${e.value*t}px)`;case`drop-shadow`:return`drop-shadow(${e.x*t}px ${e.y*t}px ${e.blur*t}px ${e.color})`;case`unitless`:return e.name===`hue-rotate`?`hue-rotate(${e.value}deg)`:`${e.name}(${e.value})`;case`url`:return`url("${e.ref}")`}}).join(` `);function Ol(e,t){let n=0,r=0,i=0;for(let a of e.functions)a.kind===`blur`?n+=a.value:a.kind===`drop-shadow`?(n+=a.blur,r=Math.max(r,Math.abs(a.x),Math.abs(a.y))):a.kind===`url`&&(i+=t?.get(a.ref)?.outset??0);return Math.ceil(3*n+r+i)}function kl(e){let t=(e.ownerDocument??document).createElement(`canvas`);return t.width=e.width,t.height=e.height,t}let Al=(e,t)=>new Promise((n,r)=>{let i=e=>{clearTimeout(o),t?.removeEventListener(`abort`,a),e?r(e):n()},a=()=>i(new DOMException(`The operation was aborted.`,`AbortError`)),o=setTimeout(()=>i(new Z(`Filter surface image decode timed out`)),1e4);t?.addEventListener(`abort`,a,{once:!0}),t?.aborted?a():e.decode().then(()=>i(),()=>i(new Z(`Filter surface image decode failed`)))}),jl=/* @__PURE__ */ new WeakMap;function Ml(e=document){let t=jl.get(e);if(t!==void 0)return t;let n=e.createElement(`canvas`),r=e.createElement(`canvas`),i=!1;try{n.width=n.height=r.width=r.height=32;let e=n.getContext(`2d`),t=r.getContext(`2d`);if(e&&t&&`filter`in t){e.fillStyle=`#fff`,e.fillRect(8,8,8,8),t.filter=`blur(2px)`,t.drawImage(n,0,0);let r=(t.getImageData(6,12,1,1).data[3]??0)>0;t.clearRect(0,0,32,32),t.filter=`drop-shadow(12px 0px 0px rgba(255, 0, 0, 0.5))`,t.drawImage(n,0,0);let a=t.getImageData(24,12,1,1).data;i=r&&(a[0]??0)>240&&(a[1]??0)<10&&(a[3]??0)>=126&&(a[3]??0)<=129}}catch{}finally{Q(n),Q(r)}return jl.set(e,i),i}function Nl(e,t,n,r,i){let a,o,s=!1;try{q(i),a=kl(e);let c=a.getContext(`2d`);if(!c||!(`filter`in c)||(c.filter=Dl(t,r),c.filter===`none`||c.filter===``))return null;c.drawImage(e,0,0),q(i),o=kl(e);let l=o.getContext(`2d`);return l?(l.globalAlpha=n,l.drawImage(a,0,0),q(i),s=!0,o):null}catch{return q(i),null}finally{a&&Q(a),o&&!s&&Q(o)}}let Pl=e=>{let t=0,n=0;for(let r of e.functions)if(r.kind===`blur`)t++;else if(r.kind===`drop-shadow`)n++;else return!1;return t>1||n>1?!1:t>0&&n>0?e.functions.findIndex(e=>e.kind===`blur`)<e.functions.findIndex(e=>e.kind===`drop-shadow`):!0};async function Fl(e,t,n,r,i,a){if(q(i),t.functions.some(e=>e.kind===`url`))return Il(e,t,n,r,i,a);if(t.functions.length>0&&Ml(e.ownerDocument??document)){let a=Nl(e,t,n,r,i);if(a)return a}if(!Pl(t))throw new Z(`Filter chain requires native canvas filters`);return Hl(e,t,n,r,i)}async function Il(e,t,n,r,i,a){let o=[];for(let e of t.functions){if(e.kind===`url`){let t=a?.references?.get(e.ref);if(!t)throw new Z(`Filter reference ${e.ref} cannot be resolved`);o.push(t);continue}let t=o[o.length-1];Array.isArray(t)?t.push(e):o.push([e])}let s=a?.origin??{x:0,y:0},c=o[o.length-1],l=Array.isArray(c),u=e;try{for(let t of o){let a=Array.isArray(t)?await Fl(u,{functions:t},t===c?n:1,r,i):await Vl(u,t,s,r,i);u!==e&&Q(u),u=a}if(l||n===1){let t=u;return u=e,t}return Ll(u,n)}finally{u!==e&&Q(u)}}function Ll(e,t){let n=kl(e),r=n.getContext(`2d`);if(!r)throw Q(n),new Z(`Filter surface canvas is unavailable`);r.globalAlpha=t;try{return r.drawImage(e,0,0),n}catch{throw Q(n),new Z(`Filter surface image cannot be drawn`)}}function Rl(e,t,n={}){let r=e.createElementNS(`http://www.w3.org/2000/svg`,t);return Object.entries(n).forEach(([e,t])=>r.setAttribute(e,String(t))),r}function zl(e){try{let t=e.toDataURL(`image/png`);if(t===`data:,`)throw Error(`Canvas size is unsupported`);return t}catch{throw new Z(`Filter surface pixels cannot be serialized`)}}async function Bl(e,t,n,r){let i=(t.ownerDocument??document).defaultView,a=i?.Image?new i.Image:new Image,o;try{a.src=`data:image/svg+xml,${encodeURIComponent(new XMLSerializer().serializeToString(e))}`,await Al(a,r),q(r),o=kl(t);let i=o.getContext(`2d`);if(!i)throw new Z(`Filter surface canvas is unavailable`);return i.globalAlpha=n,i.drawImage(a,0,0),o}catch(e){throw o&&Q(o),r?.aborted&&q(r),e instanceof Z?e:new Z(`Filter surface image cannot be drawn`)}finally{a.removeAttribute(`src`)}}async function Vl(e,t,n,r,i){q(i);let a=e.ownerDocument??document,o=e.width/r,s=e.height/r,c=Rl(a,`svg`,{width:e.width,height:e.height,viewBox:`0 0 ${o} ${s}`}),l=Rl(a,`defs`),u=a.importNode(t.element,!0);u.setAttribute(`id`,`composited-reference`),l.appendChild(u),c.appendChild(l);let d=Rl(a,`g`,{transform:`translate(${n.x} ${n.y})`});return d.appendChild(Rl(a,`image`,{x:-n.x,y:-n.y,width:o,height:s,href:zl(e),filter:`url(#composited-reference)`})),c.appendChild(d),Bl(c,e,1,i)}async function Hl(e,t,n,r,i){q(i);let a=t.functions.find(e=>e.kind===`blur`),o=t.functions.find(e=>e.kind===`drop-shadow`),s=a&&a.kind===`blur`?a.value:0,c=o&&o.kind===`drop-shadow`?{x:o.x,y:o.y,blur:o.blur,color:o.color}:void 0;if(!s&&!c)return Ll(e,n);let l=e.ownerDocument??document,u=(e,t={})=>Rl(l,e,t),d=u(`svg`,{width:e.width,height:e.height,viewBox:`0 0 ${e.width} ${e.height}`}),f=u(`defs`),p=u(`filter`,{id:`composited-filter`,filterUnits:`userSpaceOnUse`,x:0,y:0,width:e.width,height:e.height,"color-interpolation-filters":`sRGB`});if(s&&p.appendChild(u(`feGaussianBlur`,{stdDeviation:s*r,result:`blurred-source`})),c){p.appendChild(u(`feGaussianBlur`,{in:s?`blurred-source`:`SourceAlpha`,stdDeviation:c.blur*r})),p.appendChild(u(`feOffset`,{dx:c.x*r,dy:c.y*r,result:`offset-shadow`})),p.appendChild(u(`feFlood`,{"flood-color":c.color})),p.appendChild(u(`feComposite`,{in2:`offset-shadow`,operator:`in`}));let e=u(`feMerge`);e.appendChild(u(`feMergeNode`)),e.appendChild(u(`feMergeNode`,{in:s?`blurred-source`:`SourceGraphic`})),p.appendChild(e)}return f.appendChild(p),d.appendChild(f),d.appendChild(u(`image`,{width:e.width,height:e.height,href:zl(e),filter:`url(#composited-filter)`})),Bl(d,e,n,i)}function Ul(e,t,n){let r=t*n*4;return!Number.isFinite(r)||t<=0||n<=0||t>8192||n>8192||e.pixels+r>16777216?0:(e.pixels+=r,r)}let Wl=(e,t)=>e.add(-t,-t,t*2,t*2),Gl=(e,t)=>new a(Math.min(e.left,t.left),Math.min(e.top,t.top),Math.max(e.left+e.width,t.left+t.width)-Math.min(e.left,t.left),Math.max(e.top+e.height,t.top+t.height)-Math.min(e.top,t.top));function Kl(e){let t=e.styles,n=e.bounds;for(let r of t.boxShadow)if(!r.inset){let t=Math.max(0,r.spread.number)+3*r.blur.number;n=Gl(n,Wl(e.bounds.add(r.offsetX.number,r.offsetY.number,0,0),t))}for(let r of e.textNodes)for(let i of r.textBounds){let r=Wl(i.bounds,2*I(t.fontSize,e.bounds.height)+t.webkitTextStrokeWidth);n=Gl(n,r);for(let e of t.textShadow)n=Gl(n,Wl(r.add(e.offsetX.number,e.offsetY.number,0,0),3*e.blur.number))}for(let t of e.elements)t.styles.isVisible()&&(n=Gl(n,Kl(t)));let r=yl(t.filter);return Wl(n,r?Ol(r,e.filterReferences):0)}function ql(e,t,n,r){let i=Wl(t,n),o=Math.floor(Math.max(e.left,i.left)*r)/r,s=Math.floor(Math.max(e.top,i.top)*r)/r,c=Math.ceil(Math.min(e.left+e.width,i.left+i.width)*r)/r,l=Math.ceil(Math.min(e.top+e.height,i.top+i.height)*r)/r;return new a(o,s,Math.max(0,c-o),Math.max(0,l-s))}var Jl=class{ctx;constructor(e){this.ctx=e}render(e,t){this.ctx.fillStyle=z(t.textDecorationColor??t.color);let n=1;typeof t.textDecorationThickness==`number`?n=t.textDecorationThickness:t.textDecorationThickness===`from-font`&&(n=Math.max(1,Math.floor(t.fontSize.number*.05)));let r=0;typeof t.textUnderlineOffset==`number`&&(r=t.textUnderlineOffset);let i=t.textDecorationStyle;t.textDecorationLine.forEach(t=>{let a=0;switch(t){case 1:a=e.top+e.height-n+r;break;case 2:a=e.top;break;case 3:a=e.top+(e.height/2-n/2);break;default:return}this.draw(e.left,a,e.width,n,i)})}draw(e,t,n,r,i){switch(i){case 0:this.ctx.fillRect(e,t,n,r);break;case 1:{let i=Math.max(1,r);this.ctx.fillRect(e,t,n,r),this.ctx.fillRect(e,t+r+i,n,r);break}case 2:this.drawPattern(e,t,n,r,[r,r*2]);break;case 3:this.drawPattern(e,t,n,r,[r*3,r*2]);break;case 4:this.drawWavy(e,t,n,r);break;default:this.ctx.fillRect(e,t,n,r)}}drawPattern(e,t,n,r,i){this.ctx.save(),this.ctx.beginPath(),this.ctx.setLineDash(i),this.ctx.lineWidth=r,this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.moveTo(e,t+r/2),this.ctx.lineTo(e+n,t+r/2),this.ctx.stroke(),this.ctx.restore()}drawWavy(e,t,n,r){this.ctx.save(),this.ctx.beginPath(),this.ctx.lineWidth=r,this.ctx.strokeStyle=this.ctx.fillStyle;let i=r*2,a=r*4,o=e;for(this.ctx.moveTo(o,t+r/2);o<e+n;){let s=Math.min(o+a/2,e+n);if(this.ctx.quadraticCurveTo(o+a/4,t+r/2-i,s,t+r/2),o=s,o<e+n){let s=Math.min(o+a/2,e+n);this.ctx.quadraticCurveTo(o+a/4,t+r/2+i,s,t+r/2),o=s}}this.ctx.stroke(),this.ctx.restore()}};let Yl=e=>e!==void 0&&!Number.isNaN(e),Xl=(e,t)=>{let n=e.measureText(`Mg`),r=n;return{baseline:Yl(r.fontBoundingBoxAscent)?r.fontBoundingBoxAscent:Yl(n.actualBoundingBoxAscent)?n.actualBoundingBoxAscent:t,height:Yl(r.fontBoundingBoxAscent)&&Yl(r.fontBoundingBoxDescent)?r.fontBoundingBoxAscent+r.fontBoundingBoxDescent:Yl(n.actualBoundingBoxAscent)&&Yl(n.actualBoundingBoxDescent)?n.actualBoundingBoxAscent+n.actualBoundingBoxDescent:t}},Zl=(e,t)=>Xl(e,t).baseline,Ql=/[\u2E80-\u2FFF\u3000-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFFEF]/,$l=e=>Ql.test(e),eu=()=>typeof navigator>`u`?!1:navigator.userAgentData!==void 0||(typeof window<`u`?window:void 0)?.chrome!==void 0,tu=()=>eu()?`miter`:`round`;var nu=class{ctx;options;decorationRenderer;baselineCache=/* @__PURE__ */ new Map;glyphWidthCache=null;constructor(e){this.ctx=e.ctx,this.options=e.options,this.decorationRenderer=new Jl(e.ctx)}cachedMeasureText(e,t){let n=this.glyphWidthCache;n||(n=/* @__PURE__ */ new Map,this.glyphWidthCache=n);let r=e+t,i=n.get(r);return i===void 0&&(i=this.ctx.measureText(e).width,n.set(r,i)),i}iterateLettersWithLetterSpacing(e,t,n,r,i){if(ka(r)){this.iterateVerticalGlyphs(e,t,n,r,i);return}let a=Zs(e.text),o=e.bounds.top+n,s=this.ctx.font,c=e.bounds.left;for(let e of a)i(e,c,o),c+=this.cachedMeasureText(e,s)+t}iterateVerticalGlyphs(e,t,n,r,i){let a=Zs(e.text),o=this.ctx.font,s=r===4?-Math.PI/2:Math.PI/2,c=e.bounds.top;for(let l=0;l<a.length;){let u=a[l];if(!(Aa(r)||!$l(u)&&u.trim().length>0)){let r=this.ctx.textBaseline;$l(u)&&(this.ctx.textBaseline=`ideographic`),i(u,e.bounds.left,c+n),this.ctx.textBaseline=r,c+=this.cachedMeasureText(u,o)+t,l++;continue}let d=l;for(;l<a.length;){let e=a[l];if(!Aa(r)&&!$l(e)&&e.trim().length===0)break;if(Aa(r)||!$l(e)&&e.trim().length>0)l++;else break}this.ctx.save(),this.ctx.translate(e.bounds.left+n,c),this.ctx.rotate(s);let f=0;for(let e=d;e<l;e++){let n=a[e];i(n,0,f),f+=this.cachedMeasureText(n,o)+t}this.ctx.restore(),c+=f}}renderTextWithLetterSpacing(e,t,n,r=0){this.renderFillText(e,t,n,r)}canRenderWholeText(e,t){return e===0&&!ka(t)}renderFillText(e,t,n,r){this.canRenderWholeText(t,r)?this.ctx.fillText(e.text,e.bounds.left,e.bounds.top+n):this.iterateLettersWithLetterSpacing(e,t,n,r,(e,t,n)=>{this.ctx.fillText(e,t,n)})}renderStrokeText(e,t,n,r){this.canRenderWholeText(t,r)?this.ctx.strokeText(e.text,e.bounds.left,e.bounds.top+n):this.iterateLettersWithLetterSpacing(e,t,n,r,(e,t,n)=>{this.ctx.strokeText(e,t,n)})}renderTextStrokeWithStyle(e,t,n){t.webkitTextStrokeWidth&&e.text.trim().length&&(this.ctx.strokeStyle=z(t.webkitTextStrokeColor),this.ctx.lineWidth=t.webkitTextStrokeWidth,this.ctx.lineJoin=tu(),this.renderStrokeText(e,t.letterSpacing,n,t.writingMode),this.ctx.strokeStyle=``,this.ctx.lineWidth=0,this.ctx.lineJoin=`miter`)}renderTextFillWithShadows(e,t,n){this.ctx.fillStyle=this.resolveFillColor(t),this.renderTextWithLetterSpacing(e,t.letterSpacing,n,t.writingMode);let r=t.textShadow;r.length&&e.text.trim().length&&(r.slice(0).reverse().forEach(r=>{this.ctx.shadowColor=z(r.color),this.ctx.shadowOffsetX=r.offsetX.number*this.options.scale,this.ctx.shadowOffsetY=r.offsetY.number*this.options.scale,this.ctx.shadowBlur=r.blur.number*this.options.scale,this.renderTextWithLetterSpacing(e,t.letterSpacing,n,t.writingMode)}),this.ctx.shadowColor=``,this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0)}renderTextBoundWithPaintOrder(e,t,n,r){n.forEach(n=>{switch(n){case 0:this.ctx.fillStyle=this.resolveFillColor(t),this.renderTextWithLetterSpacing(e,t.letterSpacing,r,t.writingMode);break;case 1:this.renderTextStrokeWithStyle(e,t,r)}})}renderTextDecoration(e,t){this.decorationRenderer.render(e,t)}truncateTextWithEllipsis(e,t,n){let r=this.ctx.measureText(`…`).width,i=Zs(e);if(n===0){let e=e=>this.ctx.measureText(i.slice(0,e).join(``)).width+r<=t,n=0,a=i.length;for(;n<a;){let t=n+a+1>>1;e(t)?n=t:a=t-1}return i.slice(0,n).join(``)+`…`}{let e=this.ctx.font,a=r,o=[];for(let r of i){let i=this.cachedMeasureText(r,e);if(a+i>t)break;o.push(r),a+=i+n}return o.join(``)+`…`}}createFontStyle(e){let t=e.fontVariant.filter(e=>e===`normal`||e===`small-caps`).join(``),n=e.fontFamily.join(`, `),r=T(e.fontSize)?`${e.fontSize.number}${e.fontSize.unit}`:`${e.fontSize.number}px`;return[[e.fontStyle,t,e.fontWeight,r,n].join(` `),n,r]}resolveFillColor(e){return z(e.webkitTextFillColor??e.color)}renderLineClampedText(e,t,n,r,i){let a=na(t.lineHeight,t.fontSize.number),o=[],s=[],l=c(e.textBounds,0).bounds.top;e.textBounds.forEach(e=>{Math.abs(e.bounds.top-l)>=a*.5?(s.length>0&&o.push(s),s=[e],l=e.bounds.top):s.push(e)}),s.length>0&&o.push(s);let u=t.webkitLineClamp;if(o.length<=u)return!1;for(let e=0;e<u-1;e++)c(o,e).forEach(e=>this.renderTextBoundWithPaintOrder(e,t,n,r));let d=o[u-1];if(d?.length&&i){let e=d.map(e=>e.text).join(``),a=c(d,0),o=i.width-(a.bounds.left-i.left),s=new Gs(this.truncateTextWithEllipsis(e,o,t.letterSpacing),a.bounds);for(let e of n)e===0?(this.ctx.fillStyle=this.resolveFillColor(t),this.renderTextWithLetterSpacing(s,t.letterSpacing,r,t.writingMode)):e===1&&this.renderTextStrokeWithStyle(s,t,r)}return!0}renderEllipsisText(e,t,n,r,i){let a=na(t.lineHeight,t.fontSize.number),o=c(e.textBounds,0).bounds.top;if(!e.textBounds.every(e=>Math.abs(e.bounds.top-o)<a*.5))return!1;let s=e.textBounds.map(e=>e.text).join(``).replace(/\s+/g,` `).trim();if(this.ctx.measureText(s).width<=i.width+1)return!1;let l=new Gs(this.truncateTextWithEllipsis(s,i.width,t.letterSpacing),c(e.textBounds,0).bounds);for(let e of n)e===0?this.renderTextFillWithShadows(l,t,r):e===1&&this.renderTextStrokeWithStyle(l,t,r);return!0}measureBaselineCached(e,t){let n=this.baselineCache.get(e);return n===void 0&&(n=Zl(this.ctx,t),this.baselineCache.size>=64&&this.baselineCache.clear(),this.baselineCache.set(e,n)),n}async renderTextNode(e,t,n){this.glyphWidthCache=null;let[r]=this.createFontStyle(t);this.ctx.font=r??``,this.ctx.direction=t.direction===1?`rtl`:`ltr`,this.ctx.textAlign=`left`,this.ctx.textBaseline=`alphabetic`;let i=t.paintOrder,a=this.measureBaselineCached(r??``,t.fontSize.number);t.webkitLineClamp>0&&t.display&34&&t.overflowY===1&&e.textBounds.length>0&&this.renderLineClampedText(e,t,i,a,n)||t.textOverflow===1&&n&&t.overflowX===1&&e.textBounds.length>0&&this.renderEllipsisText(e,t,i,a,n)||(e.textBounds.forEach(e=>{i.forEach(n=>{n===0?(this.renderTextFillWithShadows(e,t,a),t.textDecorationLine.length&&this.renderTextDecoration(e.bounds,t)):n===1&&this.renderTextStrokeWithStyle(e,t,a)})}),t.textEmphasisStyle&&this.renderTextEmphasis(e,t,a))}renderTextEmphasis(e,t,n){if(ka(t.writingMode))return;let r=t.textEmphasisStyle;if(!r)return;let i=t.fontSize.number,a=i*.5,o=z(t.textEmphasisColor??t.color),s=t.textEmphasisPosition,c=(e,t)=>{if(typeof r==`string`){let n=this.ctx.font;this.ctx.font=n.replace(/^\S+/,`${a}px`),this.ctx.textAlign=`center`,this.ctx.fillText(r,e,t+a/3),this.ctx.font=n,this.ctx.textAlign=`left`;return}let{fill:n,shape:i}=r,o=a*(i===`dot`?.3:i===`sesame`?.26:.34);this.ctx.beginPath(),i===`sesame`?this.ctx.ellipse(e,t,o*1.3,o*.8,Math.PI/4,0,Math.PI*2):i===`triangle`?(this.ctx.moveTo(e,t-o),this.ctx.lineTo(e+o*1.1,t+o*.8),this.ctx.lineTo(e-o*1.1,t+o*.8),this.ctx.closePath()):this.ctx.arc(e,t,o,0,Math.PI*2),n?i===`double-circle`?(this.ctx.lineWidth=o*.7,this.ctx.stroke(),this.ctx.beginPath(),this.ctx.arc(e,t,o*.4,0,Math.PI*2),this.ctx.lineWidth=o*.35,this.ctx.stroke()):this.ctx.fill():(this.ctx.lineWidth=Math.max(1,o*.35),this.ctx.stroke(),i===`double-circle`&&(this.ctx.beginPath(),this.ctx.arc(e,t,o*.5,0,Math.PI*2),this.ctx.stroke()))},l=this.ctx.font;for(let r of e.textBounds){let e=r.bounds.top+n,u=s.over?e-i-a*.4:e+a*.9,d=r.bounds.left;for(let e of Zs(r.text)){let n=this.cachedMeasureText(e,l);this.ctx.save();try{this.ctx.fillStyle=o,this.ctx.strokeStyle=o,this.ctx.lineWidth=1,c(d+n/2+t.letterSpacing/2,u)}finally{this.ctx.restore()}d+=n+t.letterSpacing}}}};let ru=(e,t)=>{t.forEach((t,n)=>{let r=Y(t)?t.start:t;n===0?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y),Y(t)&&e.bezierCurveTo(t.startControl.x,t.startControl.y,t.endControl.x,t.endControl.y,t.end.x,t.end.y)})},iu=(e,t)=>{e.beginPath(),ru(e,t),e.closePath()};var au=class{maxSize;_map;constructor(e){this.maxSize=e,this._map=/* @__PURE__ */ new Map}get(e){if(!this._map.has(e))return;let t=this._map.get(e);return this._map.delete(e),this._map.set(e,t),t}set(e,t){if(this._map.has(e))this._map.delete(e);else if(this._map.size>=this.maxSize){let e=this._map.keys().next().value;e!==void 0&&this._map.delete(e)}this._map.set(e,t)}get size(){return this._map.size}clear(){this._map.clear()}},ou=class{ctx;context;canvas;patternCache=new au(50);constructor(e){this.ctx=e.ctx,this.context=e.context,this.canvas=e.canvas}async renderBackgroundImage(e){let t=e.styles.backgroundImage.length-1,n=e.styles.backgroundBlendMode,r=0;for(let i of e.styles.backgroundImage.slice(0).reverse()){if(r>0){let e=n[r]??n[0]??`normal`;e!==`normal`&&(this.ctx.save(),this.ctx.globalCompositeOperation=e)}i.type===0?await this.renderBackgroundURLImage(e,i,t):ni(i)?this.renderLinearGradient(e,i,t):ii(i)?this.renderRepeatingLinearGradient(e,i,t):ri(i)?this.renderRadialGradient(e,i,t):ai(i)?this.renderRepeatingRadialGradient(e,i,t):oi(i)?this.renderConicGradient(e,i,t):si(i)&&this.renderRepeatingConicGradient(e,i,t),r>0&&(n[r]??n[0]??`normal`)!==`normal`&&this.ctx.restore(),t--,r++}}async renderBackgroundURLImage(e,t,n){let r,i=t.url;try{r=await this.context.cache.match(i)}catch{this.context.logger.error(`Error loading background-image ${i}`)}if(r){let t=isNaN(r.width)||r.width===0?1:r.width,a=isNaN(r.height)||r.height===0?1:r.height,[o,s,c,l,u]=ul(e,n,[t,a,t/a]),d=ml(e.styles.backgroundRepeat,n),f=d===1?`no-repeat`:d===2?`repeat-x`:d===3?`repeat-y`:`repeat`,p=`${i}|${Math.round(l)}x${Math.round(u)}|${e.styles.imageRendering}|${f}`,m=this.patternCache.get(p);if(!m){let t=this.resizeImage(r,l,u,e.styles.imageRendering);m=this.ctx.createPattern(t,f),this.patternCache.set(p,m)}this.renderRepeat(o,m,s,c)}}renderRepeatingLinearGradient(e,t,n){let[r,i,a,o,s]=ul(e,n,[null,null,null]),[l,u,d,f,p]=Pr(t.angle,o,s),m=i+u,h=i+d,g=a+f,_=a+p,v=W(t.stops,l||1),y=rl(v),b=this.ctx.createLinearGradient(m,g,h,_);if(y)y.forEach(e=>b.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color));else{let e=z(c(v,v.length-1).color);b.addColorStop(0,e),b.addColorStop(1,e)}this.path(r),this.ctx.fillStyle=b,this.ctx.fill()}renderLinearGradient(e,t,n){let[r,i,a,o,s]=ul(e,n,[null,null,null]),[c,l,u,d,f]=Pr(t.angle,o,s),p=`lg|${t.angle}|${Math.round(o)}x${Math.round(s)}|${JSON.stringify(t.stops)}`,m=this.patternCache.get(p);if(!m){let e=(this.canvas.ownerDocument??document).createElement(`canvas`);e.width=o,e.height=s;let n=e.getContext(`2d`);if(!n)return;let r=n.createLinearGradient(l,d,u,f);W(t.stops,c||1).forEach(e=>r.addColorStop(e.stop,z(e.color))),n.fillStyle=r,n.fillRect(0,0,o,s),o>0&&s>0&&(m=this.ctx.createPattern(e,`repeat`),this.patternCache.set(p,m))}m&&this.renderRepeat(r,m,i,a)}renderRadialGradient(e,t,n){let[r,i,a,o,s]=ul(e,n,[null,null,null]),l=t.position.length===0?[P]:t.position,u=I(c(l,0),o),d=I(c(l,l.length-1),s),[f,p]=Ir(t,u,d,o,s);if((f===0||p===0)&&(f=Math.max(f,.01),p=Math.max(p,.01)),f>0&&p>0){let e=`rg|${Math.round(u)}x${Math.round(d)}|${Math.round(f)}x${Math.round(p)}|${JSON.stringify(t.stops)}`,n=W(t.stops,f),o=z(c(n,n.length-1).color),s=this.patternCache.get(e);if(!s){let n=this.canvas.ownerDocument??document,r=al(n,f,p,t.stops,!1);if(!r)return;s=this.ctx.createPattern(r.canvas,`no-repeat`),this.patternCache.set(e,s)}this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=o,this.ctx.fill(),this.ctx.translate(i+u-f,a+d-p),this.ctx.fillStyle=s,this.ctx.fillRect(0,0,f*2,p*2),this.ctx.restore()}}renderRepeatingRadialGradient(e,t,n){let[r,i,a,o,s]=ul(e,n,[null,null,null]),l=t.position.length===0?[P]:t.position,u=I(c(l,0),o),d=I(c(l,l.length-1),s),[f,p]=Ir(t,u,d,o,s);if((f===0||p===0)&&(f=Math.max(f,.01),p=Math.max(p,.01)),!(f>0&&p>0))return;let m=`rrg|${Math.round(u)}x${Math.round(d)}|${Math.round(f)}x${Math.round(p)}|${JSON.stringify(t.stops)}`,h=this.patternCache.get(m);if(!h){let e=this.canvas.ownerDocument??document,n=al(e,f,p,t.stops,!0);if(!n)return;h=this.ctx.createPattern(n.canvas,`no-repeat`),this.patternCache.set(m,h)}h&&(this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.translate(i+u-f,a+d-p),this.ctx.fillStyle=h,this.ctx.fillRect(0,0,f*2,p*2),this.ctx.restore())}renderConicGradient(e,t,n){let[r,i,a,o,s]=ul(e,n,[null,null,null]),l=t.position.length===0?[P]:t.position,u=i+I(c(l,0),o),d=a+I(c(l,l.length-1),s),f=this.ctx.createConicGradient(t.angle-Math.PI/2,u,d);W(t.stops,1).forEach(e=>{f.addColorStop(Math.min(1,Math.max(0,e.stop)),z(e.color))}),this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=f,this.ctx.fill(),this.ctx.restore()}renderRepeatingConicGradient(e,t,n){let[r,i,a,o,s]=ul(e,n,[null,null,null]),l=t.position.length===0?[P]:t.position,u=i+I(c(l,0),o),d=a+I(c(l,l.length-1),s),f=W(t.stops,1),p=c(f,0),m=c(f,f.length-1),h=Math.max(m.stop-p.stop,.01);if(m.stop-p.stop<1e-6){let e=this.ctx.createConicGradient(t.angle-Math.PI/2,u,d);e.addColorStop(0,z(m.color)),e.addColorStop(1,z(m.color)),this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=e,this.ctx.fill(),this.ctx.restore();return}let g=[],_=Math.ceil(1/h);for(let e=0;e<_;e++)for(let t of f){let n=e*h+(t.stop-p.stop);if(n>1)break;g.push({stop:n,color:z(t.color)})}let v=c(g,g.length-1);v&&v.stop<1&&g.push({stop:1,color:v.color});let y=this.ctx.createConicGradient(t.angle-Math.PI/2,u,d);g.forEach(e=>{y.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color)}),this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=y,this.ctx.fill(),this.ctx.restore()}renderRepeat(e,t,n,r){this.path(e),this.ctx.fillStyle=t,this.ctx.translate(n,r),this.ctx.fill(),this.ctx.translate(-n,-r)}resizeImage(e,t,n,r){let i=(this.canvas.ownerDocument??document).createElement(`canvas`);i.width=Math.max(1,t),i.height=Math.max(1,n);let a=i.getContext(`2d`);return a?(r===2||r===1?(this.context.logger.debug(`Disabling image smoothing for background image due to CSS image-rendering`),a.imageSmoothingEnabled=!1):r===3?(this.context.logger.debug(`Enabling image smoothing for background image due to CSS image-rendering: smooth`),a.imageSmoothingEnabled=!0):a.imageSmoothingEnabled=this.ctx.imageSmoothingEnabled,this.ctx.imageSmoothingQuality&&(a.imageSmoothingQuality=this.ctx.imageSmoothingQuality),a.drawImage(e,0,0,e.width,e.height,0,0,t,n),i):e}path(e){iu(this.ctx,e)}};let su=(e,t)=>{switch(t){case 0:return $(e.topLeftBorderBox,e.topLeftPaddingBox,e.topRightBorderBox,e.topRightPaddingBox);case 1:return $(e.topRightBorderBox,e.topRightPaddingBox,e.bottomRightBorderBox,e.bottomRightPaddingBox);case 2:return $(e.bottomRightBorderBox,e.bottomRightPaddingBox,e.bottomLeftBorderBox,e.bottomLeftPaddingBox);default:return $(e.bottomLeftBorderBox,e.bottomLeftPaddingBox,e.topLeftBorderBox,e.topLeftPaddingBox)}},cu=(e,t)=>{switch(t){case 0:return $(e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox,e.topRightBorderBox,e.topRightBorderDoubleOuterBox);case 1:return $(e.topRightBorderBox,e.topRightBorderDoubleOuterBox,e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox);case 2:return $(e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox,e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox);default:return $(e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox,e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox)}},lu=(e,t)=>{switch(t){case 0:return $(e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox,e.topRightBorderDoubleInnerBox,e.topRightPaddingBox);case 1:return $(e.topRightBorderDoubleInnerBox,e.topRightPaddingBox,e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox);case 2:return $(e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox,e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox);default:return $(e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox,e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox)}},uu=(e,t)=>{switch(t){case 0:return du(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return du(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return du(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return du(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}},du=(e,t)=>{let n=[];return Y(e)?n.push(e.subdivide(.5,!1)):n.push(e),Y(t)?n.push(t.subdivide(.5,!0)):n.push(t),n},$=(e,t,n,r)=>{let i=[];return Y(e)?i.push(e.subdivide(.5,!1)):i.push(e),Y(n)?i.push(n.subdivide(.5,!0)):i.push(n),Y(r)?i.push(r.subdivide(.5,!0).reverse()):i.push(r),Y(t)?i.push(t.subdivide(.5,!1).reverse()):i.push(t),i};var fu=class{ctx;pathCallbacks;constructor(e,t){this.ctx=e.ctx,this.pathCallbacks=t}async renderSolidBorder(e,t,n){this.pathCallbacks.path(su(n,t)),this.ctx.fillStyle=z(e),this.ctx.fill()}async renderDoubleBorder(e,t,n,r){if(t<3){await this.renderSolidBorder(e,n,r);return}let i=cu(r,n);this.pathCallbacks.path(i),this.ctx.fillStyle=z(e),this.ctx.fill();let a=lu(r,n);this.pathCallbacks.path(a),this.ctx.fill()}async renderDashedDottedBorder(e,t,n,r,i){this.ctx.save();let a=uu(r,n),o=su(r,n);i===2&&(this.pathCallbacks.path(o),this.ctx.clip());let s,l,u,d;Y(c(o,0))?(s=c(o,0).start.x,l=c(o,0).start.y):(s=c(o,0).x,l=c(o,0).y),Y(c(o,1))?(u=c(o,1).end.x,d=c(o,1).end.y):(u=c(o,1).x,d=c(o,1).y);let f;f=Math.abs(n===0||n===2?s-u:l-d),this.ctx.beginPath(),i===3?this.pathCallbacks.formatPath(a):this.pathCallbacks.formatPath(o.slice(0,2));let p=t<3?t*3:t*2,m=t<3?t*2:t;i===3&&(p=t,m=t);let h=!0;if(f<=p*2)h=!1;else if(f<=p*2+m){let e=f/(2*p+m);p*=e,m*=e}else{let e=Math.floor((f+m)/(p+m)),t=(f-e*p)/(e-1),n=(f-(e+1)*p)/e;m=n<=0||Math.abs(m-t)<Math.abs(m-n)?t:n}if(h&&(i===3?this.ctx.setLineDash([0,p+m]):this.ctx.setLineDash([p,m])),i===3?(this.ctx.lineCap=`round`,this.ctx.lineWidth=t):this.ctx.lineWidth=t*2+1.1,this.ctx.strokeStyle=z(e),this.ctx.stroke(),this.ctx.setLineDash([]),i===2){if(Y(c(o,0))){let e=c(o,3),t=c(o,0);this.ctx.beginPath(),this.pathCallbacks.formatPath([new J(e.end.x,e.end.y),new J(t.start.x,t.start.y)]),this.ctx.stroke()}if(Y(c(o,1))){let e=c(o,1),t=c(o,2);this.ctx.beginPath(),this.pathCallbacks.formatPath([new J(e.end.x,e.end.y),new J(t.start.x,t.start.y)]),this.ctx.stroke()}}this.ctx.restore()}};let pu=(e,t,n)=>{let r=e?[e.top,e.right,e.bottom,e.left]:null;return[0,1,2,3].map(e=>{let i=r?r[e]:null,a=t[e]??0;return!i||i.kind===`auto`?a:i.kind===`number`?a*(i.value??1):i.kind===`length`?i.value??0:(i.value??0)/100*(e===0||e===2?n.height:n.width)})},mu=(e,t)=>{let n=e?[e.top,e.right,e.bottom,e.left]:null,r=e=>{let r=n?n[e]:null;return r?r.kind===`number`?(t[e]??0)*(r.value??0):r.value??0:0};return{top:r(0),right:r(1),bottom:r(2),left:r(3)}};var hu=class{ctx;constructor(e){this.ctx=e}renderBorderImage(e,t,n,r,i,a,o,s,c={top:0,right:0,bottom:0,left:0}){e=e.add(-c.left,-c.top,c.left+c.right,c.top+c.bottom);let l=t.naturalWidth||t.width,u=t.naturalHeight||t.height;if(l<=0||u<=0)return;let d=Math.min(n.unit===`percent`?n.top/100*u:Math.min(n.top,u),u),f=Math.min(n.unit===`percent`?n.right/100*l:Math.min(n.right,l),l),p=Math.min(n.unit===`percent`?n.bottom/100*u:Math.min(n.bottom,u),u),m=Math.min(n.unit===`percent`?n.left/100*l:Math.min(n.left,l),l),{left:h,top:g,width:_,height:v}=e;if(_<=0||v<=0)return;let y=Math.min(i,v),b=Math.min(a,_),x=Math.min(o,v-y),S=Math.min(s,_-b);this.drawRegion(t,0,0,m,d,h,g,S,y),this.drawRegion(t,l-f,0,f,d,h+_-b,g,b,y),this.drawRegion(t,l-f,u-p,f,p,h+_-b,g+v-x,b,x),this.drawRegion(t,0,u-p,m,p,h,g+v-x,S,x);let C=[{sx:m,sy:0,sw:l-m-f,sh:d,dx:h+S,dy:g,dw:_-S-b,dh:y,repeat:r.horizontal,horizontal:!0},{sx:l-f,sy:d,sw:f,sh:u-d-p,dx:h+_-b,dy:g+y,dw:b,dh:v-y-x,repeat:r.vertical,horizontal:!1},{sx:m,sy:u-p,sw:l-m-f,sh:p,dx:h+S,dy:g+v-x,dw:_-S-b,dh:x,repeat:r.horizontal,horizontal:!0},{sx:0,sy:d,sw:m,sh:u-d-p,dx:h,dy:g+y,dw:S,dh:v-y-x,repeat:r.vertical,horizontal:!1}];for(let e of C)e.sw<=0||e.sh<=0||e.dw<=0||e.dh<=0||(e.repeat===0?this.ctx.drawImage(t,e.sx,e.sy,e.sw,e.sh,e.dx,e.dy,e.dw,e.dh):(e.repeat===1||e.repeat===2)&&this.drawRepeatedEdge(t,e,e.horizontal,e.repeat===2));n.fill&&this.drawCenterRegion(t,{sx:m,sy:d,sw:l-m-f,sh:u-d-p},{dx:h+S,dy:g+y,dw:_-S-b,dh:v-y-x},r)}drawRegion(e,t,n,r,i,a,o,s,c){r>0&&i>0&&s>0&&c>0&&this.ctx.drawImage(e,t,n,r,i,a,o,s,c)}drawRepeatedEdge(e,t,n,r){let i=n?t.sw:t.sh,a=n?t.dw:t.dh;if(i<=0||a<=0)return;let o,s;r?(s=Math.max(1,Math.round(a/i)),o=a/s):(o=i,s=Math.ceil(a/o)),this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(t.dx,t.dy,t.dw,t.dh),this.ctx.clip();for(let r=0;r<s;r++){let i=r*o;n?this.ctx.drawImage(e,t.sx,t.sy,t.sw,t.sh,t.dx+i,t.dy,o,t.dh):this.ctx.drawImage(e,t.sx,t.sy,t.sw,t.sh,t.dx,t.dy+i,t.dw,o)}this.ctx.restore()}drawCenterRegion(e,t,n,r){if(t.sw<=0||t.sh<=0||n.dw<=0||n.dh<=0)return;let i=(e,t,n)=>{if(e===0)return{size:n,count:1};if(e===2){let e=Math.max(1,Math.round(n/t));return{size:n/e,count:e}}return{size:t,count:Math.max(1,Math.ceil(n/t))}},a=i(r.horizontal,t.sw,n.dw),o=i(r.vertical,t.sh,n.dh);this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(n.dx,n.dy,n.dw,n.dh),this.ctx.clip();for(let r=0;r<o.count;r++)for(let i=0;i<a.count;i++)this.ctx.drawImage(e,t.sx,t.sy,t.sw,t.sh,n.dx+i*a.size,n.dy+r*o.size,a.size,o.size);this.ctx.restore()}};let gu=/blur\((\d+(?:\.\d+)?)px\)/gi,_u=(e,t)=>t===1?e:e.replace(gu,(e,n)=>`blur(${parseFloat(n)*t}px)`);var vu=class{ctx;pathCallback;scale;activeEffects=[];didSave=!1;saveAtDepth=-1;constructor(e,t){this.ctx=e.ctx,this.pathCallback=t,this.scale=e.scale??1}applyEffects(e){for(;this.activeEffects.length;)this.popEffect();this.didSave=!1,this.saveAtDepth=-1;let t=e=>Hc(e)||Uc(e)||Gc(e),n=e.reduceRight((e,n,r)=>e===-1?t(n)?r:-1:e,-1);for(let r=0;r<e.length;r++){let i=c(e,r);t(i)&&(this.didSave||=(this.ctx.save(),!0),r===n&&(this.saveAtDepth=this.activeEffects.length)),this.applyEffect(i)}}applyEffect(e){Hc(e)?(this.ctx.translate(e.offsetX,e.offsetY),this.ctx.transform(e.matrix[0],e.matrix[1],e.matrix[2],e.matrix[3],e.matrix[4],e.matrix[5]),this.ctx.translate(-e.offsetX,-e.offsetY)):Uc(e)?(this.pathCallback.path(e.path),this.ctx.clip()):Gc(e)?e.applyClip(this.ctx):Wc(e)?this.ctx.globalAlpha*=e.opacity:Kc(e)?this.ctx.globalCompositeOperation=e.compositeOperation:qc(e)&&(this.ctx.filter=_u(e.safeFilterString,this.scale)||`none`,e.shadow&&(this.ctx.shadowOffsetX=e.shadow.offsetX*this.scale,this.ctx.shadowOffsetY=e.shadow.offsetY*this.scale,this.ctx.shadowBlur=e.shadow.blur*this.scale,this.ctx.shadowColor=e.shadow.color)),this.activeEffects.push(e)}popEffect(){this.activeEffects.length!==0&&(this.didSave&&this.activeEffects.length-1===this.saveAtDepth&&(this.ctx.restore(),this.didSave=!1,this.saveAtDepth=-1),this.activeEffects.pop(),!this.didSave&&this.activeEffects.length===0&&(this.ctx.globalAlpha=1,this.ctx.globalCompositeOperation=`source-over`,this.ctx.filter=`none`,this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0,this.ctx.shadowColor=`rgba(0, 0, 0, 0)`))}getActiveEffectCount(){return this.activeEffects.length}hasActiveEffects(){return this.activeEffects.length>0}};let yu=(e,t)=>e.length===0?void 0:e[t%e.length]??e[0],bu=(e,t,n,r)=>{let i=e?e[0]:void 0,a=e&&e.length>1?c(e,1):void 0,o=e=>e!==void 0&&D(e)?e.value:null,s=(e,t,n)=>e===void 0||D(e)?null:M(e)?I(e,t):n,l=o(i);if(l===`contain`||l===`cover`){let e=l===`contain`?Math.min(t.width/n,t.height/r):Math.max(t.width/n,t.height/r);return{width:n*e,height:r*e}}let u=s(i,t.width,n),d=s(a,t.height,r);return u===null&&d===null?(u=n,d=r):u===null?u=n/r*d:d===null&&(d=r/n*u),{width:u,height:d}},xu=(e,t,n,r,i)=>{let a=t.naturalWidth||t.width||i.width,o=t.naturalHeight||t.height||i.height,{width:s,height:l}=bu(yu(n.maskSize,r),i,a,o),u=yu(n.maskPosition,r)??[],d=i.left+I(c(u,0),i.width-s),f=i.top+I(c(u,u.length-1),i.height-l),p=yu(n.maskRepeat,r)??0,m=p===0||p===2,h=p===0||p===3,g=m?Math.ceil((d-i.left)/s):0,_=h?Math.ceil((f-i.top)/l):0,v=m?Math.ceil((i.left+i.width-d)/s):0,y=h?Math.ceil((i.top+i.height-f)/l):0;for(let n=-_;n<=y;n++)for(let r=-g;r<=v;r++)e.drawImage(t,d+r*s,f+n*l,s,l)},Su=(e,t,n)=>{let{width:r,height:i}=n,a=t.position.length===0?[P]:t.position,o=I(c(a,0),r),s=I(c(a,a.length-1),i),[l,u]=Ir(t,o,s,r,i);l=Math.max(l,.01),u=Math.max(u,.01);let d=e.canvas.ownerDocument??document,f=al(d,l,u,t.stops,ai(t));f&&(e.fillStyle=f.lastColor,e.fillRect(n.left,n.top,n.width,n.height),e.drawImage(f.canvas,n.left+o-l,n.top+s-u,l*2,u*2),Q(f.canvas))},Cu=(e,t,n)=>{let{width:r,height:i}=n;if(r<=0||i<=0)return;if(ri(t)||ai(t)){Su(e,t,n);return}let a=null;if(t.type===1||t.type===3){let o=t,[s,l,u,d,f]=Pr(o.angle||0,r,i),p=W(o.stops,s||1);if(t.type===3){let t=rl(p);if(!t){e.fillStyle=z(c(p,p.length-1).color),e.fillRect(n.left,n.top,r,i);return}a=e.createLinearGradient(n.left+l,n.top+d,n.left+u,n.top+f),t.forEach(e=>a.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color))}else a=e.createLinearGradient(n.left+l,n.top+d,n.left+u,n.top+f),il(p).forEach(e=>a.addColorStop(e.stop,e.color))}else if(t.type===5||t.type===6){let o=t,s=W(o.stops,1),l=t.type===6;if(l&&!rl(s)){e.fillStyle=z(c(s,s.length-1).color),e.fillRect(n.left,n.top,r,i);return}a=e.createConicGradient(o.angle-Math.PI/2,n.left+r/2,n.top+i/2),((l?rl(s):null)??il(s)).forEach(e=>a.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color))}a&&(e.fillStyle=a,e.fillRect(n.left,n.top,r,i))},wu=async(e,t,n,r,i)=>{for(let a=0;a<t.length;a++){let o=c(t,a);if(o.type===0){let t=await i(o.url);t&&xu(e,t,n,a,r)}else Cu(e,o,r)}},Tu=(e,t,n,r,i)=>{let a=0,o=0,s=e,c=t,l=n.left,u=n.top,d=n.width,f=n.height,p=d/f,m=s/c,h=i?I(i[0],1):.5,g=i?I(i[1],1):.5;if(r===2)m>p?(f=d/m,u+=(n.height-f)*g):(d=f*m,l+=(n.width-d)*h);else if(r===4)m>p?(s=c*p,a+=(e-s)*h):(c=s/p,o+=(t-c)*g);else if(r===8)s>d?(a+=(s-d)*h,s=d):(l+=(d-s)*h,d=s),c>f?(o+=(c-f)*g,c=f):(u+=(f-c)*g,f=c);else if(r===16){let e=m>p?d:f*m,t=m>p?d/m:f,r=Math.min(s,d),i=Math.min(c,f);e*t<r*i?m>p?(f=d/m,u+=(n.height-f)*g):(d=f*m,l+=(n.width-d)*h):(s>d?(a+=(s-d)*h,s=d):(l+=(d-s)*h,d=s),c>f?(o+=(c-f)*g,c=f):(u+=(f-c)*g,f=c))}return{sx:a,sy:o,sw:s,sh:c,dx:l,dy:u,dw:d,dh:f}};async function Eu(e,t,n,r,i,a,o,s){if(i instanceof ic)try{let n=await t.cache.match(i.src),r=e.imageSmoothingEnabled;o.imageRendering===2||o.imageRendering===1?e.imageSmoothingEnabled=!1:o.imageRendering===3&&(e.imageSmoothingEnabled=!0),s(i,a,n),e.imageSmoothingEnabled=r}catch{t.logger.error(`Error loading image ${i.src}`)}if(i instanceof ac&&s(i,a,i.canvas),i instanceof cc)try{s(i,a,await t.cache.match(i.svg))}catch{t.logger.error(`Error loading svg ${i.svg.substring(0,255)}`)}if(i instanceof yc&&i.tree){let a=await r(t,{scale:n.scale,backgroundColor:i.backgroundColor,x:0,y:0,width:i.width,height:i.height}).render(i.tree);i.width&&i.height&&e.drawImage(a,0,0,i.width,i.height,i.bounds.left,i.bounds.top,i.bounds.width,i.bounds.height)}}function Du(e,t,n,r,i){if(r instanceof gc){let t=Math.min(r.bounds.width,r.bounds.height);r.type===`checkbox`&&r.checked?(e.save(),n([new J(r.bounds.left+t*.39363,r.bounds.top+t*.79),new J(r.bounds.left+t*.16,r.bounds.top+t*.5549),new J(r.bounds.left+t*.27347,r.bounds.top+t*.44071),new J(r.bounds.left+t*.39694,r.bounds.top+t*.5649),new J(r.bounds.left+t*.72983,r.bounds.top+t*.23),new J(r.bounds.left+t*.84,r.bounds.top+t*.34085),new J(r.bounds.left+t*.39363,r.bounds.top+t*.79)]),e.fillStyle=z(r.styles.accentColor??7733247),e.fill(),e.restore()):r.type===`radio`&&r.checked&&(e.save(),e.beginPath(),e.arc(r.bounds.left+t/2,r.bounds.top+t/2,t/4,0,Math.PI*2,!0),e.fillStyle=z(r.styles.accentColor??7733247),e.fill(),e.restore())}if(ju(r)&&r.value.length){let[o]=t.createFontStyle(i);e.font=o??``;let s=I(i.fontSize,0),{baseline:c,height:l}=Xl(e,s);e.fillStyle=r instanceof gc&&r.isPlaceholder?z(1970632191):z(i.color),e.textBaseline=`alphabetic`,e.textAlign=Mu(r.styles.textAlign);let u=sl(r),d=r instanceof gc?Ou(u,ol(r),l):u,f=0;switch(r.styles.textAlign){case 1:f+=u.width/2;break;case 2:f+=u.width}let p=0;r instanceof gc&&(p=(u.height-l)/2);let m=u.add(f,p,0,0);e.save(),n([new J(d.left,d.top),new J(d.left+d.width,d.top),new J(d.left+d.width,d.top+d.height),new J(d.left,d.top+d.height)]),e.clip();let h=ku(e,r.value,u.width,i.whiteSpace===`pre`||i.whiteSpace===`nowrap`),g=na(i.lineHeight,s);h.forEach((n,r)=>{let o=m.left,s=e.measureText(n).width;switch(i.textAlign){case 1:o+=(u.width-s)/2;break;case 2:o+=u.width-s}let l=new a(o,m.top+r*g,0,0);t.renderTextWithLetterSpacing(new Gs(n,l),i.letterSpacing,c,i.writingMode)}),e.restore(),e.textBaseline=`alphabetic`,e.textAlign=`left`}}let Ou=(e,t,n)=>e.height<n?new a(e.left,t.top,e.width,t.height):e,ku=(e,t,n,r)=>{let i=[],a=t.split(`
|
|
12
|
-
`);for(let t of a){if(r){i.push(t);continue}let a=t.split(/(\s+)/),o=``;for(let t of a){let r=o+t;e.measureText(r).width<=n||o===``?o=r:(i.push(o),o=t)}i.push(o)}return i};async function Au(e,t,n,r,i,o){if(H(i.styles.display,2048)){if(i.styles.listStyleImage!==null){let n=i.styles.listStyleImage;if(n.type===0){let r=n.url;try{let n=await t.cache.match(r),a=I(o.fontSize,0),s=n?.naturalWidth||n.width,c=n?.naturalHeight||n.height;if(s<=0||c<=0)return;let l=Math.min(a/s,a/c),u=s*l,d=c*l,f=i.bounds.top+I(i.styles.paddingTop,i.bounds.width)+na(o.lineHeight,o.fontSize.number)/2;e.drawImage(n,i.bounds.left-(u+10),f-d/2,u,d)}catch{t.logger.error(`Error loading list-style-image ${r}`)}}}else if(r.listValue&&i.styles.listStyleType!==-1){let t=i.styles.listStyleType;if(t===0||t===1||t===2){let n=o.fontSize.number*.45,r=i.bounds.left-n*.9,a=i.bounds.top+I(i.styles.paddingTop,i.bounds.width)+na(o.lineHeight,o.fontSize.number)/2;e.save(),e.fillStyle=z(o.color),e.beginPath(),t===2?e.rect(r-n/2,a-n/2,n,n):(e.arc(r,a,n/2,0,Math.PI*2),t===1&&(e.strokeStyle=z(o.color),e.lineWidth=n*.18)),t===1?e.stroke():e.fill(),e.restore()}else{let[t]=n.createFontStyle(o);e.font=t??``,e.fillStyle=z(o.color),e.textBaseline=`middle`,e.textAlign=`right`;let s=new a(i.bounds.left,i.bounds.top+I(i.styles.paddingTop,i.bounds.width),i.bounds.width,na(o.lineHeight,o.fontSize.number)/2+1);n.renderTextWithLetterSpacing(new Gs(r.listValue,s),o.letterSpacing,na(o.lineHeight,o.fontSize.number)/2+2,o.writingMode),e.textBaseline=`bottom`,e.textAlign=`left`}}}}let ju=e=>e instanceof vc||e instanceof _c||e instanceof gc&&e.type!==`radio`&&e.type!==`checkbox`,Mu=e=>{switch(e){case 1:return`center`;case 2:return`right`;default:return`left`}},Nu=(e,t)=>{let n=t>e?t*(1+(e/t-1)**3):t;return Math.max(0,e+n)},Pu=(e,t)=>{if(t===0)return e;let n=e.map((e,t)=>Y(e)?{x:t%2==0?e.start.x:e.end.x,y:t%2==0?e.end.y:e.start.y,rx:Math.abs(e.end.x-e.start.x),ry:Math.abs(e.end.y-e.start.y)}:{x:e.x,y:e.y,rx:0,ry:0}),r=c(n,1).x-c(n,0).x+2*t,i=c(n,3).y-c(n,0).y+2*t;if(r<=0||i<=0)return[];let a=n.map(e=>({x:Nu(e.rx,t),y:Nu(e.ry,t)})),o=(e,t)=>t>0?e/t:1,s=Math.min(1,o(r,c(a,0).x+c(a,1).x),o(r,c(a,3).x+c(a,2).x),o(i,c(a,0).y+c(a,3).y),o(i,c(a,1).y+c(a,2).y));return e.map((e,r)=>{let i=c(n,r),o=i.x+(r===1||r===2?t:-t),l=i.y+(r>=2?t:-t);if(!Y(e))return new J(o,l);let u=c(a,r).x*s,d=c(a,r).y*s;if(!u||!d)return new J(o,l);let f=u/i.rx,p=d/i.ry,m=e=>new J(o+(e.x-i.x)*f,l+(e.y-i.y)*p);return new Ac(m(e.start),m(e.startControl),m(e.endControl),m(e.end))})},Fu=(e,t,n)=>{let{a:r,b:i,c:o,d:s,e:c,f:l}=e;if(![r,i,o,s,c,l,t,n].every(Number.isFinite))return null;let u=r*s-i*o;if(!Number.isFinite(u)||u===0)return null;let d=(e,t)=>({x:(s*(e-c)-o*(t-l))/u,y:(-i*(e-c)+r*(t-l))/u}),f=[d(0,0),d(t,0),d(t,n),d(0,n)];if(!f.every(e=>Number.isFinite(e.x)&&Number.isFinite(e.y)))return null;let p=Math.min(...f.map(e=>e.x)),m=Math.min(...f.map(e=>e.y)),h=Math.max(...f.map(e=>e.x)),g=Math.max(...f.map(e=>e.y)),_=r*r+i*i,v=o*o+s*s,y=r*o+i*s,b=Math.sqrt((_+v+Math.hypot(_-v,2*y))/2);if(!Number.isFinite(b)||b<=0)return null;let x=1e-10*Math.max(_,v);return{matrix:e,viewport:new a(p,m,h-p,g-m),scale:b,uniform:Math.abs(_-v)<=x&&Math.abs(y)<=x}},Iu=(e,t,n)=>{e.beginPath(),e.rect(t.left,t.top,t.width,t.height),n.length&&(ru(e,n),e.closePath())},Lu=(e,t)=>{let n=t.spread.number,r=ol(e.container);return r.width-2*n<=0||r.height-2*n<=0?[]:Pu(Pc(e.curves),-n)},Ru=async(e,t,n,r,i,a)=>{let o=ol(t.container),s=n.blur.number/2,c=Math.ceil(3*s)+2,l=n.spread.number,u=ql((n.inset?o:t.container.bounds.add(n.offsetX.number-l,n.offsetY.number-l,2*l,2*l)).add(-c,-c,2*c,2*c),a.viewport,c,a.scale);if(!u.width||!u.height)return!0;let d=Math.ceil(u.width*a.scale),f=Math.ceil(u.height*a.scale),p=Ul(i,d,f);if(!p)return!1;let m,h;try{m=e.canvas.ownerDocument.createElement(`canvas`),m.width=d,m.height=f;let i=m.getContext(`2d`);if(!i)return!1;i.scale(a.scale,a.scale),i.translate(-u.left,-u.top);let o=n.inset?Lu(t,n):Pu(Mc(t.curves),l),c=Oc(o,n.offsetX.number,n.offsetY.number,0,0);n.inset?Iu(i,u,c):iu(i,c),i.fillStyle=z(n.color),i.fill(n.inset?`evenodd`:`nonzero`),h=await Fl(m,{functions:[{kind:`blur`,value:s}]},1,a.scale,r.signal),e.save();try{n.inset?(iu(e,Pc(t.curves)),e.clip()):(Iu(e,a.viewport,Mc(t.curves)),e.clip(`evenodd`)),e.drawImage(h,u.left,u.top,h.width/a.scale,h.height/a.scale)}finally{e.restore()}return!0}catch(e){if(!(e instanceof Z))throw e;return!1}finally{h&&h!==m&&Q(h),m&&Q(m),i.pixels-=p}},zu=async(e,t,n,r,i)=>{if(r.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);if(R(n.color))return;let a=n.spread.number;if(!n.inset&&(t.container.bounds.width+2*a<=0||t.container.bounds.height+2*a<=0))return;let o=typeof e.getTransform==`function`,s=o?e.getTransform():{a:r.scale,b:0,c:0,d:r.scale,e:-r.x*r.scale,f:-r.y*r.scale},c=Fu(s,e.canvas.width,e.canvas.height);if(!c)return;let{viewport:l}=c;if(n.blur.number>0&&(n.inset||!c.uniform)&&await Ru(e,t,n,r,i,c))return;let u=ol(t.container);e.save();try{if(n.inset&&n.blur.number===0){iu(e,Pc(t.curves)),e.clip(),Iu(e,u,Oc(Lu(t,n),n.offsetX.number,n.offsetY.number,0,0)),e.fillStyle=z(n.color),e.fill(`evenodd`);return}let r=Math.ceil(n.blur.number*2+Math.abs(a)+Math.abs(n.offsetX.number)+Math.abs(n.offsetY.number))+2,i=n.inset?u.add(-r,-r,2*r,2*r):t.container.bounds.add(-a,-a,2*a,2*a),{a:d,b:f,c:p,d:m,e:h,f:g}=s,_=i.left+i.width,v=i.top+i.height,y=Math.max(d*i.left+p*i.top+h,d*_+p*i.top+h,d*_+p*v+h,d*i.left+p*v+h),b=Math.max(1e4,y+r*c.scale+2);n.inset?(iu(e,Pc(t.curves)),e.clip()):(Iu(e,l,Mc(t.curves)),e.clip(`evenodd`)),o?e.setTransform(d,f,p,m,h-b,g):e.translate(-b/d,0),n.inset?Iu(e,i,Lu(t,n)):iu(e,Pu(Mc(t.curves),a)),o?e.setTransform(d,f,p,m,h,g):e.translate(b/d,0),e.shadowOffsetX=b+d*n.offsetX.number+p*n.offsetY.number,e.shadowOffsetY=f*n.offsetX.number+m*n.offsetY.number,e.shadowBlur=n.blur.number*c.scale,e.shadowColor=z(n.color),e.fillStyle=`rgb(0, 0, 0)`,e.fill(n.inset?`evenodd`:`nonzero`)}finally{e.restore()}};var Bu=class{ctx;context;scale;createFontStyle;constructor(e){this.ctx=e.ctx,this.context=e.context,this.scale=e.scale,this.createFontStyle=e.createFontStyle}async render(e){let t=e.container,n=t.styles,r=t.bounds,i=this.scale;if(r.width<=0||r.height<=0)return;let a=this.ctx.canvas.ownerDocument??document,o=Math.ceil(r.width),s=Math.ceil(r.height),c=Math.ceil(r.width*i),l=Math.ceil(r.height*i),u=this.createLayer(a,c,l);if(!u)return;let d=null,f=null,p=null;try{u.ctx.scale(i,i);let[m]=this.createFontStyle(n);u.ctx.font=m??``,u.ctx.textBaseline=`alphabetic`,u.ctx.textAlign=`left`,u.ctx.direction=n.direction===1?`rtl`:`ltr`;let h=Zl(u.ctx,n.fontSize.number),g=new ou({ctx:u.ctx,context:this.context,canvas:u.canvas,options:{width:o,height:s,scale:1}});R(n.backgroundColor)||(u.ctx.fillStyle=z(n.backgroundColor),u.ctx.fillRect(0,0,o,s)),u.ctx.save(),u.ctx.translate(-r.left,-r.top),await g.renderBackgroundImage(t),u.ctx.restore();let _={bounds:r,baseline:h,letterSpacing:n.letterSpacing,writingMode:n.writingMode};if(d=this.createGlyphLayer(a,c,l,u.ctx),!d)return;let v=!!n.webkitTextStrokeWidth;v&&(d.ctx.strokeStyle=z(n.webkitTextStrokeColor),d.ctx.lineWidth=n.webkitTextStrokeWidth,d.ctx.lineJoin=tu());for(let e of t.textNodes)for(let t of e.textBounds)this.drawGlyphs(d,t,_,(e,t,n,r)=>{e.fillText(t,n,r),v&&e.strokeText(t,n,r)});if(u.ctx.globalCompositeOperation=`destination-in`,u.ctx.drawImage(d.canvas,0,0,o,s),p=this.renderShadowSilhouettes(e,a,c,l,u.ctx,n,_),p){if(f=this.createLayer(a,c,l),!f)return;for(let e of p)f.ctx.drawImage(e,0,0);f.ctx.drawImage(u.canvas,0,0),this.ctx.drawImage(f.canvas,r.left,r.top,r.width,r.height)}else this.ctx.drawImage(u.canvas,r.left,r.top,r.width,r.height)}finally{Q(u.canvas),d&&Q(d.canvas),f&&Q(f.canvas),p&&p.forEach(Q)}}createLayer(e,t,n){let r=e.createElement(`canvas`);r.width=t,r.height=n;let i=r.getContext(`2d`);return i?{canvas:r,ctx:i}:null}createGlyphLayer(e,t,n,r){let i=this.createLayer(e,t,n);return i?(i.ctx.scale(this.scale,this.scale),i.ctx.font=r.font,i.ctx.textBaseline=r.textBaseline,i.ctx.textAlign=r.textAlign,i.ctx.direction=r.direction,i.ctx.fillStyle=`#000`,i):null}drawGlyphs(e,t,n,r){let i=t.bounds.left-n.bounds.left,a=t.bounds.top-n.bounds.top+n.baseline,{letterSpacing:o,writingMode:s}=n;if(o<=0||ka(s)){r(e.ctx,t.text,i,a);return}let c=i;for(let n of Zs(t.text))r(e.ctx,n,c,a),c+=e.ctx.measureText(n).width+o}renderShadowSilhouettes(e,t,n,r,i,a,o){let s=a.textShadow;if(!s.length)return null;let l=[];for(let a=s.length-1;a>=0;a--){let u=c(s,a),d=this.createGlyphLayer(t,n,r,i);if(d){d.ctx.shadowColor=z(u.color),d.ctx.shadowOffsetX=u.offsetX.number*this.scale,d.ctx.shadowOffsetY=u.offsetY.number*this.scale,d.ctx.shadowBlur=u.blur.number*this.scale,d.ctx.fillStyle=z(u.color);for(let t of e.container.textNodes)for(let e of t.textBounds)this.drawGlyphs(d,e,o,(e,t,n,r)=>{e.fillText(t,n,r)});l.push(d.canvas)}}return l.length?l:null}},Vu=class e{surfaceRoot;surfaceBudget;canvas;ctx;context;options;backgroundRenderer;borderRenderer;borderImageRenderer;effectsRenderer;textRenderer;textClipRenderer;legacySubtree=!1;constructor(e,t,n,r={pixels:0}){this.surfaceRoot=n,this.surfaceBudget=r,this.context=e,this.options=t,this.canvas=t.canvas?t.canvas:e.resourceDocument.createElement(`canvas`);let i=this.canvas.getContext(`2d`);if(!i)throw t.canvas||Q(this.canvas),n?new Z(`Filter surface canvas is unavailable`):Error(`Failed to get 2D rendering context from canvas`);this.ctx=i,t.canvas||(this.canvas.width=Math.floor(t.width*t.scale),this.canvas.height=Math.floor(t.height*t.scale),this.canvas.style.width=`${t.width}px`,this.canvas.style.height=`${t.height}px`),this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-t.x,-t.y),this.ctx.textBaseline=`bottom`,t.imageSmoothing!==void 0&&(this.ctx.imageSmoothingEnabled=t.imageSmoothing),t.imageSmoothingQuality&&(this.ctx.imageSmoothingQuality=t.imageSmoothingQuality),this.backgroundRenderer=new ou({ctx:this.ctx,context:this.context,canvas:this.canvas,options:{width:t.width,height:t.height,scale:t.scale}}),this.borderRenderer=new fu({ctx:this.ctx},{path:e=>this.path(e),formatPath:e=>this.formatPath(e)}),this.borderImageRenderer=new hu(this.ctx),this.effectsRenderer=new vu({ctx:this.ctx,scale:t.scale},{path:e=>this.path(e)}),this.textRenderer=new nu({ctx:this.ctx,options:{scale:t.scale}}),this.textClipRenderer=new Bu({ctx:this.ctx,context:this.context,scale:t.scale,createFontStyle:e=>this.textRenderer.createFontStyle(e)}),this.context.logger.debug(`Canvas renderer initialized (${t.width}x${t.height}) with scale ${t.scale}`)}async renderStack(e){let t=e.element.container.styles;if(t.isVisible()){let n=yl(t.filter),r=n!==null&&n.functions.length>0,i=t.maskImage.length>0,a=t.webkitBoxReflect,o=t.mixBlendMode!==K.NORMAL;if(e.element!==this.surfaceRoot&&!this.legacySubtree&&(i||a||o||n!==null&&(r||t.opacity<1))&&this.canComposite(e.element)){if(!await this.renderCompositedStack(e,n,i,a,o)){this.legacySubtree=!0;try{await this.renderStackContent(e)}finally{this.legacySubtree=!1}}return}await this.renderStackContent(e)}}canComposite(e){let t=e=>{let t=e.styles;return!t.isTransformed()&&t.zoom===1&&t.clipPath.type===0&&!H(t.display,2048)&&yl(t.filter)!==null},n=e=>t(e)&&e.elements.every(n),r=e.parent;for(;r&&r!==this.surfaceRoot;){if(!t(r.container))return!1;r=r.parent}return n(e.container)}async renderCompositedStack(t,n,r,i,o=!1){let s=this.options.signal;if(s?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let c=t.element.container,l=ql(Kl(c),new a(this.options.x,this.options.y,this.options.width,this.options.height),n?Ol(n,c.filterReferences):0,this.options.scale);if(!l.width||!l.height)return!0;let u=Ul(this.surfaceBudget,Math.ceil(l.width*this.options.scale),Math.ceil(l.height*this.options.scale));if(!u)return this.context.logger.info(`Filter surface budget exceeded; using the existing renderer`),!1;let d={...this.options,canvas:void 0,backgroundColor:null,x:l.left,y:l.top,width:l.width,height:l.height},f,p;try{f=new e(this.context,d,t.element,this.surfaceBudget),await f.renderStackContent(t),f.effectsRenderer.applyEffects([]),n&&(p=await Fl(f.canvas,n,c.styles.opacity,d.scale,s,{references:c.filterReferences,origin:{x:c.bounds.left-l.left,y:c.bounds.top-l.top}}));let a=p??f.canvas;if(r&&await this.applyMask(a,t.element.container.styles,l),s?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let u=t.element.effects,m=t.element.getEffects(4,this.surfaceRoot).filter(e=>!u.includes(e)||!qc(e)&&!Wc(e)&&!Kc(e)&&!Uc(e));return this.effectsRenderer.applyEffects(m),o?(this.ctx.save(),this.ctx.globalCompositeOperation=t.element.container.styles.mixBlendMode,this.ctx.drawImage(a,d.x,d.y,a.width/d.scale,a.height/d.scale),this.ctx.restore()):this.ctx.drawImage(a,d.x,d.y,a.width/d.scale,a.height/d.scale),i&&await this.drawReflection(a,t.element.container.bounds,l,i),!0}catch(e){if(!(e instanceof Z))throw e;return this.context.logger.info(`${e.message}; using the existing renderer`),!1}finally{f&&Q(f.canvas),p&&Q(p),this.surfaceBudget.pixels-=u}}async applyMask(e,t,n){let r=e.getContext(`2d`);if(!r)return;let i=this.context.resourceDocument.createElement(`canvas`);i.width=e.width,i.height=e.height;let a=i.getContext(`2d`);if(!a)Q(i);else{a.scale(this.options.scale,this.options.scale),a.translate(-n.left,-n.top);try{await wu(a,t.maskImage,t,{left:n.left,top:n.top,width:n.width,height:n.height},async e=>await this.context.cache.match(e))}catch(e){this.context.logger.error(`Error rendering mask-image: ${e instanceof Error?e.message:e}`),Q(i);return}r.save();try{r.setTransform(1,0,0,1,0,0),r.globalCompositeOperation=`destination-in`,r.drawImage(i,0,0)}finally{r.restore(),Q(i)}}}async drawReflection(e,t,n,r){let i=this.options.scale,a=Math.ceil(t.width*i),o=Math.ceil(t.height*i);if(a<=0||o<=0)return;let s=Ul(this.surfaceBudget,a,o);if(!s)return;let c,l;try{c=this.context.resourceDocument.createElement(`canvas`),c.width=a,c.height=o;let s=c.getContext(`2d`);if(!s)return;let u=Math.round((t.left-n.left)*i),d=Math.round((t.top-n.top)*i),f=r.direction===`left`||r.direction===`right`;s.save();try{f?(s.translate(a,0),s.scale(-1,1)):(s.translate(0,o),s.scale(1,-1)),s.drawImage(e,-u,-d)}finally{s.restore()}if(r.mask){l=this.context.resourceDocument.createElement(`canvas`),l.width=a,l.height=o;let e=l.getContext(`2d`);if(e){e.scale(i,i),await wu(e,[r.mask],{maskPosition:[],maskRepeat:[],maskSize:[]},{left:0,top:0,width:t.width,height:t.height},async e=>await this.context.cache.match(e)),s.save();try{f?(s.translate(a,0),s.scale(-1,1)):(s.translate(0,o),s.scale(1,-1)),s.globalCompositeOperation=`destination-in`,s.drawImage(l,0,0,a,o)}finally{s.restore()}}}let p=r.offset,m=t.left,h=t.top;r.direction===`below`?h=t.top+t.height+p:r.direction===`above`?h=t.top-t.height-p:m=r.direction===`right`?t.left+t.width+p:t.left-t.width-p,this.ctx.save();try{this.ctx.filter=`none`,this.ctx.drawImage(c,m,h,t.width,t.height)}finally{this.ctx.restore()}}finally{c&&Q(c),l&&Q(l),this.surfaceBudget.pixels-=s}}async renderNode(e){if(e.container.debugRender)debugger;e.container.styles.isVisible()&&(await this.renderNodeBackgroundAndBorders(e),await this.renderNodeContent(e))}renderReplacedElement(e,t,n){let r=n.naturalWidth||e.intrinsicWidth,i=n.naturalHeight||e.intrinsicHeight;if(n&&r>0&&i>0){let a=sl(e),o=Pc(t);this.path(o),this.ctx.save(),this.ctx.clip();let{sx:s,sy:c,sw:l,sh:u,dx:d,dy:f,dw:p,dh:m}=Tu(r,i,a,e.styles.objectFit,e.styles.objectPosition);this.ctx.drawImage(n,s,c,l,u,d,f,p,m),this.ctx.restore()}}async renderNodeContent(t){this.effectsRenderer.applyEffects(t.getEffects(4,this.surfaceRoot));let n=t.container,r=t.curves,i=n.styles,a=sl(n);for(let e of n.textNodes)await this.textRenderer.renderTextNode(e,i,a);await Eu(this.ctx,this.context,{scale:this.options.scale,backgroundColor:this.options.backgroundColor,x:this.options.x,y:this.options.y,width:this.options.width,height:this.options.height},(t,n)=>new e(t,n),n,r,i,(e,t,n)=>this.renderReplacedElement(e,t,n)),Du(this.ctx,this.textRenderer,this.path.bind(this),n,i),await Au(this.ctx,this.context,this.textRenderer,t,n,i)}async renderStackContent(e){if(e.element.container.debugRender)debugger;let t=this.options.signal;await this.renderNodeBackgroundAndBorders(e.element);for(let n of e.negativeZIndex){if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderStack(n)}if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderNodeContent(e.element);for(let t of e.nonInlineLevel)await this.renderNode(t);for(let n of e.nonPositionedFloats){if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderStack(n)}for(let n of e.nonPositionedInlineLevel){if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderStack(n)}for(let t of e.inlineLevel)await this.renderNode(t);for(let n of e.zeroOrAutoZIndexOrTransformedOrOpacity){if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderStack(n)}for(let n of e.positiveZIndex){if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderStack(n)}}path(e){iu(this.ctx,e)}formatPath(e){ru(this.ctx,e)}async renderSurfaceBoxShadow(e,t){let n=t.spread.number,r=t.blur.number/2,i=Math.ceil(3*r)+1,o=e.container.bounds.add(-n,-n,2*n,2*n);if(o.width<=0||o.height<=0)return;let s=this.options.scale,c=ql(o.add(-i,-i,2*i,2*i),new a(this.options.x-t.offsetX.number,this.options.y-t.offsetY.number,this.options.width,this.options.height),i,s);if(!c.width||!c.height)return;let l=Math.ceil(c.width*s),u=Math.ceil(c.height*s),d=Ul(this.surfaceBudget,l,u);if(!d)throw new Z(`Box shadow surface budget exceeded`);let f,p;try{f=this.context.resourceDocument.createElement(`canvas`),f.width=l,f.height=u;let i=f.getContext(`2d`);if(!i)throw new Z(`Box shadow surface canvas is unavailable`);i.scale(s,s),i.translate(-c.left,-c.top),iu(i,Oc(Mc(e.curves),-n,-n,2*n,2*n)),i.fillStyle=z(t.color),i.fill(),p=await Fl(f,{functions:[{kind:`blur`,value:r}]},1,s,this.options.signal),this.ctx.save();try{this.ctx.beginPath(),this.ctx.rect(this.options.x,this.options.y,this.options.width,this.options.height),ru(this.ctx,Mc(e.curves)),this.ctx.closePath(),this.ctx.clip(`evenodd`),this.ctx.drawImage(p,c.left+t.offsetX.number,c.top+t.offsetY.number,p.width/s,p.height/s)}finally{this.ctx.restore()}}finally{f&&Q(f),p&&Q(p),this.surfaceBudget.pixels-=d}}async renderNodeBackgroundAndBorders(e){this.effectsRenderer.applyEffects(e.getEffects(2,this.surfaceRoot)),!this.surfaceRoot&&e.container.styles.backdropFilter&&await this.renderBackdropFilter(e);let t=e.container.styles,n=!R(t.backgroundColor)||t.backgroundImage.length,r=Uu(t),i=[{style:t.borderTopStyle,color:t.borderTopColor,width:t.borderTopWidth},{style:t.borderRightStyle,color:t.borderRightColor,width:t.borderRightWidth},{style:t.borderBottomStyle,color:t.borderBottomColor,width:t.borderBottomWidth},{style:t.borderLeftStyle,color:t.borderLeftColor,width:t.borderLeftWidth}],a=ml(t.backgroundClip,0),o=Hu(a,e.curves);if(n||t.boxShadow.length){r&&e.container.textNodes.length>0?await this.textClipRenderer.render(e):(this.ctx.save(),this.path(o),this.ctx.clip(),R(t.backgroundColor)||(this.ctx.fillStyle=z(t.backgroundColor),this.ctx.fill()),await this.backgroundRenderer.renderBackgroundImage(e.container),this.ctx.restore());for(let n of t.boxShadow.slice(0).reverse())this.surfaceRoot&&!n.inset?await this.renderSurfaceBoxShadow(e,n):await zu(this.ctx,e,n,this.options,this.surfaceBudget)}if(t.borderImageSource){let n=t.borderImageSource,r=e.container.bounds,i=[Math.max(0,t.borderTopWidth),Math.max(0,t.borderRightWidth),Math.max(0,t.borderBottomWidth),Math.max(0,t.borderLeftWidth)],a=null;if(n.type===0){let e=n.url;try{a=await this.context.cache.match(e)??null}catch{this.context.logger.error(`Error loading border-image ${e}`)}}else a=this.rasterizeGradientSource(n,r);if(a){let e=mu(t.borderImageOutset,i),n=r.add(-e.left,-e.top,e.left+e.right,e.top+e.bottom),o=pu(t.borderImageWidth,i,n);this.borderImageRenderer.renderBorderImage(r,a,t.borderImageSlice,t.borderImageRepeat,o[0],o[1],o[2],o[3],e)}return}let s=0;for(let t of i){if(t.style!==0&&!R(t.color)&&t.width>0){let n=async()=>{t.style===2?await this.borderRenderer.renderDashedDottedBorder(t.color,t.width,s,e.curves,2):t.style===3?await this.borderRenderer.renderDashedDottedBorder(t.color,t.width,s,e.curves,3):t.style===4?await this.borderRenderer.renderDoubleBorder(t.color,t.width,s,e.curves):await this.borderRenderer.renderSolidBorder(t.color,s,e.curves)},r=e.container.legendBounds;if(s===0&&r){let t=e.container.bounds,i=r.left-t.left,a=r.left+r.width-t.left;i>0&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(t.left,t.top,i,t.height),this.ctx.clip(),await n(),this.ctx.restore());let o=t.left+a,s=t.width-a;s>0&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(o,t.top,s,t.height),this.ctx.clip(),await n(),this.ctx.restore())}else await n()}s++}this.renderOutline(e)}renderOutline(e){let t=e.container.styles;if(t.outlineStyle===0||t.outlineStyle===1)return;let n=Math.max(0,t.outlineWidth);if(n<=0)return;let r=t.outlineColor??t.color;if(R(r))return;let i=Math.max(0,t.outlineOffset)+n/2,a=Oc(Mc(e.curves),-i,-i,2*i,2*i);this.ctx.save();try{this.ctx.strokeStyle=z(r),this.ctx.lineWidth=n,t.outlineStyle===3?this.ctx.setLineDash([n*3,n*3]):t.outlineStyle===4&&this.ctx.setLineDash([n,n*2]),this.path(a),this.ctx.stroke()}finally{this.ctx.restore()}}rasterizeGradientSource(e,t){let n=Math.max(1,Math.ceil(t.width)),r=Math.max(1,Math.ceil(t.height)),i=(this.ctx.canvas.ownerDocument??document).createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return null;if(e.type===1||e.type===3){let t=e,[o,s,l,u,d]=Pr(t.angle,n,r),f=W(t.stops,o||n),p=e.type===3,m=p?rl(f):null,h=a.createLinearGradient(s,l,u,d);if(m)m.forEach(e=>{h.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color)});else if(p){let e=z(c(f,f.length-1).color);h.addColorStop(0,e),h.addColorStop(1,e)}else il(f).forEach(e=>{h.addColorStop(e.stop,e.color)});return a.fillStyle=h,a.fillRect(0,0,n,r),i}if(e.type===2||e.type===4){let t=e,o=t.position.length===0?[P]:t.position,s=I(c(o,0),n),l=I(c(o,o.length-1),r),[u,d]=Ir(t,s,l,n,r);if(u<=0||d<=0)return null;let f=this.ctx.canvas.ownerDocument??document,p=al(f,u,d,t.stops,e.type===4);return p?(a.fillStyle=p.lastColor,a.fillRect(0,0,n,r),a.drawImage(p.canvas,s-u,l-d,u*2,d*2),Q(p.canvas),i):null}if(e.type===5||e.type===6){let t=e,o=I(c(t.position,0),n),s=I(c(t.position,1),r),l=a.createConicGradient(t.angle-Math.PI/2,o,s),u;if(e.type===6){let e=W(t.stops,1),n=c(e,0),r=c(e,e.length-1),i=Math.max(r.stop-n.stop,.01);u=[];let a=Math.ceil(1/i);for(let t=0;t<a;t++)for(let r of e){let e=t*i+(r.stop-n.stop);if(e>1)break;u.push({stop:e,color:z(r.color)})}let o=c(u,u.length-1);o&&o.stop<1&&u.push({stop:1,color:o.color})}else u=W(t.stops,Math.max(n,r)).map(e=>({stop:e.stop,color:z(e.color)}));return u.forEach(e=>{l.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color)}),a.fillStyle=l,a.fillRect(0,0,n,r),i}return this.context.logger.warn(`Unsupported border-image source; only URL and gradient images are supported`),null}async renderBackdropFilter(e){let t=yl(e.container.styles.backdropFilter);if(!t||t.functions.length===0)return;let n=e.container.bounds;if(n.width<=0||n.height<=0)return;let r=this.options.scale,i=Math.ceil(n.width*r),a=Math.ceil(n.height*r);if(i<=0||a<=0)return;let o=Ul(this.surfaceBudget,i,a);if(!o)return;let s,c;try{s=this.context.resourceDocument.createElement(`canvas`),s.width=i,s.height=a;let e=s.getContext(`2d`);if(!e)return;let o=Math.round((n.left-this.options.x)*r),l=Math.round((n.top-this.options.y)*r);e.drawImage(this.canvas,o,l,i,a,0,0,i,a);try{c=await Fl(s,t,1,r,this.options.signal)}catch(e){if(e instanceof Z){this.context.logger.info(`${e.message}; rendering without the backdrop effect`);return}throw e}if(this.options.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);this.ctx.save();try{this.ctx.filter=`none`,this.ctx.drawImage(c,n.left,n.top,n.width,n.height)}finally{this.ctx.restore()}}finally{s&&Q(s),c&&Q(c),this.surfaceBudget.pixels-=o}}async render(e){try{this.options.backgroundColor&&(this.ctx.fillStyle=z(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height));let t=tl(e);return await this.renderStack(t),this.effectsRenderer.applyEffects([]),this.canvas}catch(e){throw this.options.canvas||Q(this.canvas),e}}};let Hu=(e,t)=>{switch(e){case 0:return Mc(t);case 2:return Nc(t);default:return Pc(t)}},Uu=e=>e.backgroundClip.some(e=>e===3);var Wu=class{canvas;ctx;options;context;constructor(e,t){this.context=e,this.options=t,this.canvas=t.canvas?t.canvas:e.resourceDocument.createElement(`canvas`);let n=this.canvas.getContext(`2d`);if(!n)throw Error(`Failed to get 2D rendering context from canvas`);this.ctx=n,this.canvas.width=Math.floor(t.width*t.scale),this.canvas.height=Math.floor(t.height*t.scale),this.canvas.style.width=`${t.width}px`,this.canvas.style.height=`${t.height}px`,this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-t.x,-t.y),this.context.logger.debug(`EXPERIMENTAL ForeignObject renderer initialized (${t.width}x${t.height} at ${t.x},${t.y}) with scale ${t.scale}`)}async render(e){if(this.options.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=Ku(e),n=Hs(this.options.width,this.options.height,0,0,e),r=Us(n);t();try{let e=await r;if(this.options.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);return this.options.backgroundColor&&(this.ctx.fillStyle=z(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),this.ctx.drawImage(e,this.options.x,this.options.y,this.options.width,this.options.height),this.canvas}catch(e){throw this.options.canvas||Q(this.canvas),e}}};let Gu=[`marginTop`,`marginRight`,`marginBottom`,`marginLeft`,`top`,`right`,`bottom`,`left`],Ku=e=>{let t=e.style,n=Gu.map(e=>[e,t[e]]);for(let e of Gu)t[e]=e.startsWith(`margin`)?`0px`:`auto`;return()=>{for(let[e,r]of n)t[e]=r}};var qu=class{id;enabled;start;constructor({id:e,enabled:t}){this.id=e,this.enabled=t,this.start=Date.now()}debug(...e){this.enabled&&(typeof window<`u`&&window.console&&typeof console.debug==`function`?console.debug(this.id,`${this.getTime()}ms`,...e):this.info(...e))}getTime(){return Date.now()-this.start}info(...e){this.enabled&&typeof window<`u`&&window.console&&typeof console.info==`function`&&console.info(this.id,`${this.getTime()}ms`,...e)}warn(...e){this.enabled&&(typeof window<`u`&&window.console&&typeof console.warn==`function`?console.warn(this.id,`${this.getTime()}ms`,...e):this.info(...e))}error(...e){this.enabled&&(typeof window<`u`&&window.console&&typeof console.error==`function`?console.error(this.id,`${this.getTime()}ms`,...e):this.info(...e))}},Ju=class{context;_options;_cache=/* @__PURE__ */ new Map;maxSize;_pendingOperations=/* @__PURE__ */ new Map;_deferMode=!1;_collectedUrls=/* @__PURE__ */ new Set;_evictionSuspendCount=0;get _evictionEnabled(){return this._evictionSuspendCount===0}constructor(e,t){if(this.context=e,this._options=t,this.maxSize=t.maxCacheSize??100,this.maxSize<1)throw Error(`Cache maxSize must be at least 1`);this.maxSize>1e4&&this.context.logger.warn(`Cache maxSize ${this.maxSize} is very large and may cause memory issues. Consider using a smaller value (recommended: 100-1000).`)}startDefer(){this._deferMode=!0,this._evictionSuspendCount++}async preloadAll(e=10,t,n){this._deferMode=!1;let r=Array.from(this._collectedUrls);this._collectedUrls.clear();try{if(r.length===0)return;let i=Math.max(1,Math.min(e,100));this.context.logger.debug(`Preloading ${r.length} image(s) with concurrency ${i}`);let a=0,o=n?new Promise((e,t)=>{let r=()=>t(new DOMException(`The operation was aborted.`,`AbortError`));n.aborted?r():n.addEventListener(`abort`,r,{once:!0})}):null;o?.catch(()=>void 0),t?.(0,r.length);for(let e=0;e<r.length;e+=i){q(n);let s=r.slice(e,e+i);s.map(e=>this._addImageWithPending(e));let c=Promise.allSettled(s.map(e=>this._cache.get(e)?.value??Promise.resolve()));await(o?Promise.race([c,o]):c),a+=s.length,t?.(a,r.length)}}finally{this._evictionSuspendCount=Math.max(0,this._evictionSuspendCount-1)}}addImage(e){if(this._deferMode)return!this.has(e)&&(td(e)||Qu(e))&&this._collectedUrls.add(e),Promise.resolve();let t=this._pendingOperations.get(e);if(t)return t;if(this.has(e)){let t=this._cache.get(e);return this._cache.delete(e),this._cache.set(e,t),Promise.resolve()}return td(e)||Qu(e)?this._addImageWithPending(e):Promise.resolve()}_addImageWithPending(e){let t=this._pendingOperations.get(e);if(t)return t;let n=this._addImageInternal(e);return this._pendingOperations.set(e,n),n.finally(()=>{this._pendingOperations.delete(e)}),n}async _addImageInternal(e){let t=this._options.imageTimeout??15e3,n=this.withTimeout(this.loadImage(e),t,`Timed out (${t}ms) loading image`);n.catch(t=>{let n=t instanceof Error?t.message:String(t),r=`Failed to load image ${e.substring(0,256)}: ${n}`;this.context.logger.error(r),this.context.onError?.(Error(r))}),this.set(e,n)}withTimeout(e,t,n){if(t<=0)return e;let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(n)),t)});return Promise.race([e,i]).finally(()=>{r!==void 0&&clearTimeout(r)})}match(e){let t=this._cache.get(e);if(t)return this._cache.delete(e),this._cache.set(e,t),t.value}set(e,t){if(this._cache.has(e))this._cache.delete(e);else if(this._evictionEnabled&&this._cache.size>=this.maxSize){let e=this._cache.keys().next().value;e!==void 0&&(this._cache.delete(e),this.context.logger.debug(`Cache: Evicted LRU entry: ${e}`))}this._cache.set(e,{value:t})}size(){return this._cache.size}getMaxSize(){return this.maxSize}clear(){this._cache.clear()}async loadImage(e){let t=this.context.originChecker,n=e=>t.isSameOrigin(e),r=typeof this._options.customIsSameOrigin==`function`?await this._options.customIsSameOrigin(e,n):n(e),i=!r&&this._options.allowTaint===!1&&!$u(e)&&!td(e)&&typeof this._options.proxy!=`string`,a=!$u(e)&&(this._options.useCORS===!0||i)&&Ws.SUPPORT_CORS_IMAGES&&!r,o=!$u(e)&&!r&&!td(e)&&typeof this._options.proxy==`string`&&!a;if(!r&&this._options.allowTaint===!1&&!$u(e)&&!td(e)&&!o&&!a)return;let s=e;o&&(s=await this.proxy(s)),this.context.logger.debug(`Added image ${e.substring(0,256)}`);let c=this.context.config.window.Image??Image;return await new Promise((e,t)=>{let n=new c;n.onload=()=>e(n),n.onerror=t,(ed(s)||a)&&(n.crossOrigin=`anonymous`),n.src=s,n.complete===!0&&(typeof n.decode==`function`?n.decode().then(()=>e(n),()=>t(/* @__PURE__ */ Error(`Failed to decode image ${s.substring(0,256)}`))):setTimeout(()=>e(n),500))})}has(e){return this._cache.has(e)}keys(){return Promise.resolve(Array.from(this._cache.keys()))}proxy(e){let t=this._options.proxy;if(!t)throw Error(`No proxy defined`);let n=e.substring(0,256);return new Promise((r,i)=>{let a=new XMLHttpRequest;a.onload=()=>{if(a.status===200){let e=new FileReader;e.addEventListener(`load`,()=>r(e.result),!1),e.addEventListener(`error`,e=>i(e),!1),e.readAsDataURL(a.response)}else i(`Failed to proxy resource ${n} with status code ${a.status}`)},a.onerror=i;let o=t.indexOf(`?`)>-1?`&`:`?`;if(a.open(`GET`,`${t}${o}url=${encodeURIComponent(e)}&responseType=blob`),a.responseType=`blob`,this._options.imageTimeout){let e=this._options.imageTimeout;a.timeout=e,a.ontimeout=()=>i(`Timed out (${e}ms) proxying ${n}`)}a.send()})}};let Yu=/^data:image\/svg\+xml/i,Xu=/^data:image\/.*;base64,/i,Zu=/^data:image\/.*/i,Qu=e=>Ws.SUPPORT_SVG_DRAWING||!nd(e),$u=e=>Zu.test(e),ed=e=>Xu.test(e),td=e=>e.substring(0,4)===`blob`,nd=e=>e.slice(-3).toLowerCase()===`svg`||Yu.test(e);var rd=class{baseUri;origin;constructor(e){if(!e||!e.document)throw Error(`Valid window object required for OriginChecker`);if(!e.location||!e.location.href)throw Error(`Window object must have valid location`);this.baseUri=e.location.href,this.origin=this.getOrigin(e.location.href)}getOrigin(e){try{return new URL(e,this.baseUri).origin}catch{return``}}isSameOrigin(e){return this.getOrigin(e)===this.origin}getContextOrigin(){return this.origin}},id=class e{static instanceCount=1;instanceName=`#${e.instanceCount++}`;logger;cache;originChecker;config;onError;_windowBounds;constructor(e,t,n){this.config=n,this.logger=new qu({id:this.instanceName,enabled:e.logging}),this.originChecker=new rd(n.window),this.cache=e.cache??n.cache??new Ju(this,e),this.onError=e.onError,this._windowBounds=t}get windowBounds(){return this._windowBounds}get resourceDocument(){return this.config.window.document||(typeof document<`u`?document:void 0)}adjustWindowBounds(e,t){this._windowBounds=this._windowBounds.add(e,t,0,0)}};let ad=e=>{[`scale`,`width`,`height`,`imageTimeout`,`x`,`y`,`windowWidth`,`windowHeight`,`scrollX`,`scrollY`].forEach(t=>{let n=e[t];if(n!=null&&typeof n!=`number`){let r=Number(n);Number.isNaN(r)||(e[t]=r)}})},od=e=>({allowTaint:e.allowTaint??!1,imageTimeout:e.imageTimeout??15e3,proxy:e.proxy,useCORS:e.useCORS??!1,customIsSameOrigin:e.customIsSameOrigin,maxCacheSize:e.maxCacheSize}),sd=(e,t,n)=>({logging:e.logging??!0,cache:e.cache??t.cache,...n}),cd=(e,t)=>{let n=t;return{windowWidth:e.windowWidth??n.innerWidth??800,windowHeight:e.windowHeight??n.innerHeight??600,scrollX:e.scrollX??n.pageXOffset??0,scrollY:e.scrollY??n.pageYOffset??0}},ld=(e,t,n)=>({allowTaint:e.allowTaint??!1,onclone:e.onclone,ignoreElements:e.ignoreElements,iframeContainer:e.iframeContainer,inlineImages:n,copyStyles:n,cspNonce:e.cspNonce??t.cspNonce,signal:e.signal}),ud=(e,t,n,r,i,a,o)=>({canvas:e.canvas,backgroundColor:t,signal:e.signal,scale:e.scale??o??1,x:(e.x??0)+n,y:(e.y??0)+r,width:e.width??Math.ceil(i),height:e.height??Math.ceil(a),imageSmoothing:e.imageSmoothing,imageSmoothingQuality:e.imageSmoothingQuality}),dd=(e,t,n)=>{let r=t.ownerDocument,i=r.documentElement?Nn(e,getComputedStyle(r.documentElement).backgroundColor):0,a=r.body?Nn(e,getComputedStyle(r.body).backgroundColor):0,o=typeof n==`string`?Nn(e,n):n===null?0:4294967295;return t===r.documentElement?R(i)?R(a)?o:a:i:o},fd=(e,t,n,r)=>{if(e)try{e(n,r)}catch(e){t.logger.error(`onProgress callback failed: ${e instanceof Error?e.message:String(e)}`)}},pd=async(e,t,n)=>{if(ad(t),!t.skipValidation){let n=t.validator||r(),i=n.validateElement(e);if(!i.valid)throw Error(i.error);let a=n.validateOptions(t);if(!a.valid)throw Error(`Invalid options: ${a.error}`)}if(!e||typeof e!=`object`)throw Error(`Invalid element provided as first argument`);let c=e.ownerDocument;if(!c)throw Error(`Element is not attached to a Document`);let l=c.defaultView;if(!l)throw Error(`Document is not attached to a Window`);let u=od(t),d=sd(t,n,u),f=cd(t,l),p=new a(f.scrollX,f.scrollY,f.windowWidth,f.windowHeight),m=new id(d,p,n),h=t.enablePerformanceMonitoring??t.logging??!1,g=new i(m,h);g.start(`total`,{width:f.windowWidth,height:f.windowHeight});let _=t.signal;q(_);let v=t.foreignObjectRendering??!1,y=ld(t,n,v);m.logger.debug(`Starting document clone with size ${p.width}x${p.height} scrolled to ${-p.left},${-p.top}`),fd(t.onProgress,m,`clone`,10),g.start(`clone`);let b=new Ts(m,e,y),x=b.clonedReferenceElement;if(!x)throw Error(`Unable to find element in cloned iframe`);let S,C,w;try{S=await b.toIFrame(c,p),g.end(`clone`),fd(t.onProgress,m,`clone`,30),q(_);let{width:e,height:n,left:r,top:i}=Hn(x)||Bn(x)?s(x.ownerDocument):o(m,x),a=dd(m,x,t.backgroundColor),u=ud(t,a,r,i,e,n,l.devicePixelRatio??1);v?(m.logger.debug(`Document cloned, using foreign object rendering`),g.start(`render-foreignobject`),C=await new Wu(m,u).render(x),g.end(`render-foreignobject`)):(m.logger.debug(`Document cloned, element located at ${r},${i} with size ${e}x${n} using computed rendering`),m.logger.debug(`Starting DOM parsing`),g.start(`parse`),q(_),m.cache.startDefer(),w=wc(m,x,{normalizeDom:t.normalizeDom}),g.end(`parse`),fd(t.onProgress,m,`parse`,50),g.start(`preload`),await m.cache.preloadAll(10,(e,n)=>{fd(t.onProgress,m,`preload`,50+Math.round(e/n*10))},_),g.end(`preload`),fd(t.onProgress,m,`layout`,60),a===w.styles.backgroundColor&&(w.styles.backgroundColor=0),m.logger.debug(`Starting renderer for element at ${u.x},${u.y} with size ${u.width}x${u.height}`),g.start(`render`),q(_),C=await new Vu(m,u).render(w),g.end(`render`)),fd(t.onProgress,m,`render`,90)}finally{g.start(`cleanup`);try{w&&w.restoreTree()}finally{S&&(t.removeContainer??!0)&&Ts.destroy(S),g.end(`cleanup`)}}return g.end(`total`),m.logger.debug(`Finished rendering`),h&&g.logSummary(),fd(t.onProgress,m,`render`,100),C},md=(e,n={},r)=>{let i=r||t.fromElement(e,{cspNonce:n.cspNonce,cache:n.cache});return pd(e,n,i)};e.Html2CanvasConfig=t,e.PerformanceMonitor=i,e.Validator=n,e.createDefaultValidator=r,e.default=md,e.html2canvas=md}),typeof window<`u`&&window.html2canvas&&window.html2canvas.default&&(window.html2canvasExports=window.html2canvas,window.html2canvas=window.html2canvas.default);
|
|
9
|
+
}`,cs=(e,t)=>{ls(e,`.${as}:before${ss}
|
|
10
|
+
.${os}:after${ss}`,t)},ls=(e,t,n)=>{let r=e.ownerDocument;if(r){let i=r.createElement(`style`);i.textContent=t,n&&(i.nonce=n),e.appendChild(i)}};var us=class{context;counters;quoteDepth=0;constructor(e,t){this.context=e,this.counters=t}resolvePseudoContent(e,t,n,r){if(!n)return;let i=n.content,a=t.ownerDocument;if(!a||!i||i===`none`||i===`-moz-alt-content`||n.display===`none`)return;this.counters.parse(new Zo(this.context,n));let o=new Xo(this.context,n),s=a.createElement(`html2canvaspseudoelement`);is(n,s),o.content.forEach(t=>{if(t.type===0)s.appendChild(a.createTextNode(t.value));else if(t.type===22){let e=a.createElement(`img`);e.src=t.value,e.style.opacity=`1`,s.appendChild(e)}else if(t.type===18){if(t.name===`attr`){let n=t.values.filter(D);n.length&&n[0]&&s.appendChild(a.createTextNode(e.getAttribute(n[0].value)||``))}else if(t.name===`counter`){let[e,n]=t.values.filter(O);if(e&&D(e)){let t=this.counters.getCounterValue(e.value),r=n&&D(n)?rr.parse(this.context,n.value):3;s.appendChild(a.createTextNode(_r(t,r,!1)))}}else if(t.name===`counters`){let[e,n,r]=t.values.filter(O);if(e&&D(e)){let t=this.counters.getCounterValues(e.value),i=r&&D(r)?rr.parse(this.context,r.value):3,o=n&&n.type===0?n.value:``,c=t.map(e=>_r(e,i,!1)).join(o);s.appendChild(a.createTextNode(c))}}}else if(t.type===20)switch(t.value){case`open-quote`:s.appendChild(a.createTextNode(Er(o.quotes,this.quoteDepth++,!0)));break;case`close-quote`:{let e=this.quoteDepth>0;this.quoteDepth=Math.max(0,this.quoteDepth-1),e&&s.appendChild(a.createTextNode(Er(o.quotes,this.quoteDepth,!1)));break}default:s.appendChild(a.createTextNode(t.value))}}),s.className=`${as} ${os}`;let c=r===0?` ${as}`:` ${os}`;return Ln(t)?t.className.baseValue+=c:t.className+=c,s}};let q=e=>{if(e?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`)},ds=/* @__PURE__ */ new WeakMap,fs=e=>{let t=e&&e.trustedTypes;if(!t)return null;if(ds.has(t))return ds.get(t)??null;let n=null;try{n=t.getPolicy?.(`html2canvas-pro`)??t.createPolicy(`html2canvas-pro`,{createHTML:e=>e})}catch{n=null}return ds.set(t,n),n},ps=(e,t,n)=>{let r=e.createElement(`iframe`);r.className=`html2canvas-container`,r.style.visibility=`hidden`,r.style.position=`fixed`,r.style.left=`-10000px`,r.style.top=`0px`,r.width=t.width.toString(),r.height=t.height.toString();let i=[[`width`,`${t.width}px`],[`height`,`${t.height}px`],[`min-width`,`0px`],[`max-width`,`none`],[`min-height`,`0px`],[`max-height`,`none`],[`box-sizing`,`content-box`],[`padding`,`0px`],[`border`,`0`]];for(let[e,t]of i)r.style.setProperty(e,t,`important`);return r.scrolling=`no`,r.setAttribute(`data-html2canvas-ignore`,`true`),(n||e.body).appendChild(r),r},ms=e=>new Promise(t=>{e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}),hs=e=>Promise.all([].slice.call(e.images,0).map(ms)),gs=(e,t=0)=>{if(!e||t>_s)return!0;let n;try{n=e.cssRules}catch{return!0}if(!n)return!0;for(let e=0;e<n.length;e++){let r=n[e];if(!r||!(`styleSheet`in r))continue;let i=r.styleSheet;if(!i||!gs(i,t+1))return!1}return!0},_s=32,vs=(e,t)=>{let n=e.querySelectorAll(`link`);for(let e=0;e<n.length;e++){let r=n[e];r&&t.push(r)}let r=(e.ownerDocument??e).createTreeWalker(e,NodeFilter.SHOW_ELEMENT),i=r.nextNode();for(;i;){let e=i.shadowRoot;e&&vs(e,t),i=r.nextNode()}},ys=(e,t,n,r=1e4)=>{if(n?.aborted)return Promise.resolve();let i=[],a=[];vs(e,a);for(let e of a){if(e.sheet)continue;let a=(e.getAttribute(`rel`)??``).trim().toLowerCase().split(/\s+/);a.includes(`stylesheet`)&&!a.includes(`alternate`)&&!e.disabled&&e.getAttribute(`href`)&&i.push(new Promise(i=>{let a=e.href,o=()=>{e.removeEventListener(`load`,o),e.removeEventListener(`error`,o),n?.removeEventListener(`abort`,s),clearInterval(l),i()},s=()=>o();if(e.sheet){i();return}e.addEventListener(`load`,o),e.addEventListener(`error`,o),n?.addEventListener(`abort`,s,{once:!0});let c=0,l=setInterval(()=>{c+=50,e.sheet?o():c>=r&&(t?.warn(`Stylesheet ${a} did not finish loading within ${r/1e3}s; continuing with a possibly unstyled clone`),o())},50)}))}let o=e.getElementsByTagName(`style`);for(let e=0;e<o.length;e++){let a=o[e],s=a?.sheet;s&&a?.textContent?.includes(`@import`)&&(gs(s)||i.push(new Promise(e=>{let i=0,o=setInterval(()=>{if(n?.aborted){clearInterval(o),e();return}i+=50;let s=a.sheet;(s&&gs(s)||i>=r)&&(i>=r&&!gs(s??null)&&t?.warn(`@import chain in an inline <style> did not finish loading within ${r/1e3}s; continuing with a possibly unstyled clone`),clearInterval(o),e())},50)})))}return i.length===0?Promise.resolve():Promise.all(i).then(()=>void 0)},bs=(e,t,n)=>new Promise((r,i)=>{let a=e.contentWindow;if(!a)return i(`No window assigned for iframe`);let o=a.document,s,c=setTimeout(()=>{s&&clearInterval(s),i(/* @__PURE__ */ Error(`Cloned iframe did not fire its load event within ${Bo}ms`))},Bo),l=()=>{s&&clearInterval(s),clearTimeout(c),i(new DOMException(`The operation was aborted.`,`AbortError`))};a.onload=e.onload=()=>{a.onload=e.onload=null;let i=0;s=setInterval(()=>{i++,n?.aborted?l():o.body.childNodes.length>0&&o.readyState===`complete`?(clearInterval(s),s=void 0,clearTimeout(c),r(e)):i>=600&&(clearInterval(s),s=void 0,t?.warn(`Cloned iframe did not become ready within 30 seconds; continuing with a possibly incomplete document`),r(e))},50)},n&&(n.aborted?l():n.addEventListener(`abort`,l,{once:!0}))}),xs=e=>e.replace(/[<>&"'`\\]|[\u0000-\u001f\u007f]/g,``),Ss=e=>{let t=``;return e&&(t+=`<!DOCTYPE `,e.name&&(t+=xs(e.name)),e.internalSubset&&(t+=` `+xs(e.internalSubset)),e.publicId?(t+=` PUBLIC "`+xs(e.publicId)+`"`,e.systemId&&(t+=` "`+xs(e.systemId)+`"`)):e.systemId&&(t+=` SYSTEM "`+xs(e.systemId)+`"`),t+=`>`),t},Cs=(e,t,n)=>{e&&e.defaultView&&(t!==e.defaultView.pageXOffset||n!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,n)},ws=([e,t,n])=>{e.scrollLeft=t,e.scrollTop=n},Ts=(e,t)=>{let n=e.ownerDocument.createElement(`base`);n.href=t;let r=e.getElementsByTagName(`head`).item(0);r?.insertBefore(n,r?.firstChild??null)},Es=(e,t,n,r)=>{let i=ps(t,n,r.container);if(!i.contentWindow)throw Error(`Unable to find iframe window`);let a=t.defaultView.pageXOffset,o=t.defaultView.pageYOffset,s=i.contentWindow,c=s.document,l=bs(i,e.logger,r.signal).then(async()=>{r.scrolledElements.forEach(ws),s&&s.scrollTo(n.left,n.top);let t=r.onclone,a=r.clonedReferenceElement;if(a===void 0)throw Error(`Error finding the ${r.referenceElementName} in the cloned document`);return q(r.signal),await p,q(r.signal),c.fonts&&c.fonts.ready&&await c.fonts.ready,q(r.signal),/(AppleWebKit)/g.test(navigator.userAgent)&&(await hs(c),q(r.signal)),typeof t==`function`&&await Promise.resolve().then(()=>t(c,a)),s.scrollTo(n.left,n.top),/AppleWebKit/g.test(navigator.userAgent)&&(s.scrollY!==n.top||s.scrollX!==n.left)&&(e.logger.warn(`Unable to restore scroll position for cloned document`),e.adjustWindowBounds(s.scrollX-n.left,s.scrollY-n.top)),i}),u=t.baseURI;c.open();let d=Ss(t.doctype)+`<html></html>`;try{let e=fs(t.defaultView),n=e?e.createHTML(d):d;c.write(n)}catch{c.write(d)}Cs(t,a,o),c.close();let f=c.adoptNode(r.documentElement);Ts(f,u),c.replaceChild(f,c.documentElement);let p=ys(c,e.logger,r.signal);return l.catch(e=>{throw i.parentNode?.removeChild(i),e})},Ds=e=>{let t=e;for(;t;){if(t.parentNode&&t.parentNode.host)return t.parentNode;let e=t.getRootNode();if(e&&e!==t.ownerDocument&&e.host)return e;t=t.parentNode}return null};var Os=class{context;options;scrolledElements;referenceElement;clonedReferenceElement;documentElement;counters;pseudoContents;slotCloner;constructor(e,t,n){if(this.context=e,this.options=n,this.scrolledElements=[],this.referenceElement=t,this.counters=new ir,this.pseudoContents=new us(e,this.counters),this.slotCloner=new ns((e,t)=>this.cloneNode(e,t),{ignoreElements:n.ignoreElements,copyStyles:n.copyStyles??!0,cspNonce:n.cspNonce},e),!t.ownerDocument)throw Error(`Cloned element does not have an owner document`);if(!this.options.iframeContainer){let e=Ds(t);e&&(this.options.iframeContainer=e)}this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1),this.appendDocumentAdoptedStyles(t.ownerDocument),this.appendPseudoHideStyles()}appendDocumentAdoptedStyles(e){if(this.options.copyStyles)return;let t=e.adoptedStyleSheets;if(!t||t.length===0)return;let n=this.documentElement.getElementsByTagName(`head`).item(0);if(!n)return;let r=ts(this.documentElement.ownerDocument??e,t,this.options.cspNonce);r&&n.appendChild(r)}appendPseudoHideStyles(){let e=this.documentElement.getElementsByTagName(`head`).item(0);cs(e??this.documentElement,this.options.cspNonce)}toIFrame(e,t){return Es(this.context,e,t,{documentElement:this.documentElement,clonedReferenceElement:this.clonedReferenceElement,referenceElementName:this.referenceElement.nodeName,scrolledElements:this.scrolledElements,onclone:this.options.onclone,container:this.options.iframeContainer,signal:this.options.signal})}createElementClone(e){if($o(e,2),Un(e))return this.createCanvasClone(e);if(Wn(e))return this.createVideoClone(e);if(qn(e))return this.createStyleClone(e);let t=e.cloneNode(!1);return Gn(t)&&(Gn(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=``),t.loading===`lazy`&&(t.loading=`eager`)),er(t)&&!Ln(t)?this.createCustomElementClone(e,t):t}createCustomElementClone(e,t){let n=document.createElement(`div`);n.className=t.className,is(t.style,n);let r=t.attributes;for(let e=0;e<r.length;e++){let t=r.item(e);t&&t.name!==`class`&&t.name!==`style`&&n.setAttribute(t.name,t.value)}if(e.shadowRoot)try{n.attachShadow({mode:`open`})}catch(e){this.context.logger.error(`Failed to attach shadow root to custom element clone:`,e)}return n}createStyleClone(e){try{let t=e.sheet;if(t&&t.cssRules){let n=[].slice.call(t.cssRules,0).reduce((e,t)=>t&&typeof t.cssText==`string`?e+t.cssText:e,``),r=e.cloneNode(!1);return r.textContent=n,this.options.cspNonce&&(r.nonce=this.options.cspNonce),r}}catch(e){if(this.context.logger.error(`Unable to access cssRules property`,e),e.name!==`SecurityError`)throw e}let t=e.cloneNode(!1);return this.options.cspNonce&&(t.nonce=this.options.cspNonce),t}createCanvasClone(e){if(this.options.inlineImages&&e.ownerDocument){let t=e.ownerDocument.createElement(`img`);try{return t.src=e.toDataURL(),t}catch{this.context.logger.info(`Unable to inline canvas contents, canvas is tainted`,e)}}let t=e.cloneNode(!1);try{t.width=e.width,t.height=e.height;let n=e.getContext(`2d`),r=t.getContext(`2d`,{willReadFrequently:!0});if(r){if(!this.options.allowTaint&&n)r.putImageData(n.getImageData(0,0,e.width,e.height),0,0);else{let t=e.getContext(`webgl2`)??e.getContext(`webgl`);t&&t.getContextAttributes()?.preserveDrawingBuffer===!1&&this.context.logger.warn(`Unable to clone WebGL context as it has preserveDrawingBuffer=false`,e),r.drawImage(e,0,0)}}return t}catch{this.context.logger.info(`Unable to clone canvas as it is tainted`,e)}return t}createVideoClone(e){let t=e.ownerDocument.createElement(`canvas`);t.width=e.offsetWidth,t.height=e.offsetHeight;let n=t.getContext(`2d`);try{return n&&(n.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||n.getImageData(0,0,t.width,t.height)),t}catch{this.context.logger.info(`Unable to clone video as it is tainted`,e)}let r=e.ownerDocument.createElement(`canvas`);return r.width=e.offsetWidth,r.height=e.offsetHeight,r}appendChildNode(e,t,n){this.slotCloner.appendChildNode(e,t,n)}cloneChildNodes(e,t,n){this.slotCloner.cloneChildNodes(e,t,n)}cloneNode(e,t){if(In(e))return(e.ownerDocument??document).createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);let n=e.ownerDocument.defaultView;if(n&&Fn(e)&&(Rn(e)||Ln(e))){let r=this.createElementClone(e);r.style.transitionProperty=`none`;let i=n.getComputedStyle(e),a=nr(e);this.referenceElement===e&&Rn(r)&&(this.clonedReferenceElement=r);let o=this.counters.parse(new Zo(this.context,i));if(a){let t=n.getComputedStyle(e,`:before`),i=this.pseudoContents.resolvePseudoContent(e,r,t,0);i&&r.insertBefore(i,r.firstChild)}if(er(e)&&(t=!0),Wn(e)||this.cloneChildNodes(e,r,t),a){let t=n.getComputedStyle(e,`:after`),i=this.pseudoContents.resolvePseudoContent(e,r,t,1);i&&r.appendChild(i)}return this.counters.pop(o),(i&&(this.options.copyStyles||Ln(e))&&!Kn(e)||t)&&is(i,r),(e.scrollTop!==0||e.scrollLeft!==0)&&this.scrolledElements.push([r,e.scrollLeft,e.scrollTop]),(Yn(e)||Xn(e))&&(Yn(r)||Xn(r))&&(r.value=e.value),r}return e.cloneNode(!1)}static destroy(e){return e.parentNode?(e.parentNode.removeChild(e),!0):!1}},ks=class{static normalizeElement(e,t){let n={};if(!Rn(e)&&!Ln(e))return n;t.animationDuration.some(e=>e>0)&&(n.animationDuration=e.style.animationDuration,e.style.animationDuration=`0s`),t.transform!==null&&(n.transform=e.style.transform,e.style.transform=`translate(0, 0)`);let r=!1;return t.rotate!==null&&(n.rotate=e.style.rotate,e.style.rotate=`0deg`,r=!0),t.translate!==null&&(n.translate=e.style.translate,e.style.translate=`0px`,r=!0),t.scale!==null&&(n.scale=e.style.scale,e.style.scale=`1`,r=!0),r&&n.transform===void 0&&(n.transform=e.style.transform,e.style.transform=`translate(0, 0)`),n}static restoreElement(e,t){(Rn(e)||Ln(e))&&(t.animationDuration!==void 0&&(e.style.animationDuration=t.animationDuration),t.transform!==void 0&&(e.style.transform=t.transform),t.rotate!==void 0&&(e.style.rotate=t.rotate),t.translate!==void 0&&(e.style.translate=t.translate),t.scale!==void 0&&(e.style.scale=t.scale))}};let As={x:`-10%`,y:`-10%`,width:`120%`,height:`120%`},js=[`color-interpolation-filters`,`flood-color`,`flood-opacity`,`lighting-color`],Ms=/^(["']?)(#[^"'\s()]+)\1$/,Ns=/url\(\s*([^)]*?)\s*\)/g,Ps=e=>{let t=Ms.exec(e.trim());return t?t[2]:null};function Fs(e,t,n){if(!t||t.indexOf(`url(`)===-1)return;let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Set;for(let a of t.matchAll(Ns)){let t=Ps(a[1]);if(!t||i.has(t))continue;i.add(t);let o=Is(e.ownerDocument,t,n);o&&r.set(t,o)}return r}function Is(e,t,n){let r=e.getElementById(t.slice(1));if(!r||r.namespaceURI!==`http://www.w3.org/2000/svg`||r.localName!==`filter`||!Rs(r))return null;let i=zs(r,n);if(!i)return null;let a=r.cloneNode(!0);Bs(r,a),a.removeAttribute(`id`),a.setAttribute(`filterUnits`,`userSpaceOnUse`),Object.keys(i).forEach(e=>a.setAttribute(e,String(i[e])));let o=Math.max(0,-i.x,-i.y,i.x+i.width-n.width,i.y+i.height-n.height);return{element:a,region:i,outset:Math.ceil(o)}}let Ls=e=>e.hasAttribute(`href`)||e.hasAttributeNS(`http://www.w3.org/1999/xlink`,`href`);function Rs(e){if(e.getAttribute(`primitiveUnits`)===`objectBoundingBox`||Ls(e))return!1;for(let t of Array.from(e.querySelectorAll(`*`))){if(t.localName===`feImage`||Ls(t))return!1;for(let e of[`x`,`y`,`width`,`height`])if((t.getAttribute(e)??``).indexOf(`%`)!==-1)return!1}return!0}function zs(e,t){let n=e.getAttribute(`filterUnits`)!==`userSpaceOnUse`,r=(t,r)=>{let i=(e.getAttribute(t)??(n?As[t]:``)).trim();if(i===``)return null;let a=i.endsWith(`%`),o=Number(a?i.slice(0,-1):i.replace(/px$/,``));return Number.isFinite(o)?n?(a?o/100:o)*r:a?null:o:null},i=r(`x`,t.width),a=r(`y`,t.height),o=r(`width`,t.width),s=r(`height`,t.height);return i===null||a===null||o===null||s===null||o<=0||s<=0?null:{x:i,y:a,width:o,height:s}}function Bs(e,t){let n=e.ownerDocument.defaultView;if(!n)return;let r=[e,...Array.from(e.querySelectorAll(`*`))],i=[t,...Array.from(t.querySelectorAll(`*`))];r.forEach((e,t)=>{let r=n.getComputedStyle(e);for(let e of js){let n=r.getPropertyValue(e);n&&i[t]?.setAttribute(e,n)}})}var Vs=class{context;styles;textNodes=[];elements=[];bounds;legendBounds;filterReferences;createsStackingContext=!1;createsRealStackingContext=!1;isListOwner=!1;debugRender=!1;originalStyles;originalElement;constructor(e,t,n={}){if(this.context=e,$o(t,3),this.styles=new Jo(e,e.config.window.getComputedStyle(t,null)),n.normalizeDom!==!1&&(Rn(t)||Ln(t))&&(this.originalStyles=ks.normalizeElement(t,this.styles),this.originalElement=t),this.bounds=o(this.context,t),t.tagName===`FIELDSET`){let e=t.querySelector(`:scope > legend`);if(e){let t=o(this.context,e);this.legendBounds=t;let n=t.top+t.height/2-this.styles.borderTopWidth/2;this.bounds=new a(this.bounds.left,n,this.bounds.width,this.bounds.height-(n-this.bounds.top))}}this.filterReferences=Fs(t,this.styles.filter,this.bounds),$o(t,4)&&(this.debugRender=!0)}restore(){this.originalStyles&&this.originalElement&&(ks.restoreElement(this.originalElement,this.originalStyles),this.originalStyles=void 0,this.originalElement=void 0)}restoreTree(){this.restore();for(let e of this.elements)e.restoreTree()}};let Hs=e=>{if(e.createRange){let t=e.createRange();if(t.getBoundingClientRect){let n=e.createElement(`boundtest`);n.style.height=`123px`,n.style.display=`block`,e.body.appendChild(n),t.selectNode(n);let r=t.getBoundingClientRect(),i=Math.round(r.height);if(e.body.removeChild(n),i===123)return!0}}return!1},Us=()=>new Image().crossOrigin!==void 0,Ws=e=>{let t=new Image,n=e.createElement(`canvas`),r=n.getContext(`2d`);if(!r)return!1;t.src=`data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>`;try{r.drawImage(t,0,0),n.toDataURL()}catch{return!1}return!0},Gs=(e,t,n,r,i)=>{let a=`http://www.w3.org/2000/svg`,o=document.createElementNS(a,`svg`),s=document.createElementNS(a,`foreignObject`);return o.setAttributeNS(null,`width`,e.toString()),o.setAttributeNS(null,`height`,t.toString()),s.setAttributeNS(null,`width`,`100%`),s.setAttributeNS(null,`height`,`100%`),s.setAttributeNS(null,`x`,n.toString()),s.setAttributeNS(null,`y`,r.toString()),s.setAttributeNS(null,`externalResourcesRequired`,`true`),o.appendChild(s),s.appendChild(i),o},Ks=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=n,r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(e))}`}),qs={get SUPPORT_RANGE_BOUNDS(){"use strict";let e=Hs(document);return Object.defineProperty(qs,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_SVG_DRAWING(){"use strict";let e=Ws(document);return Object.defineProperty(qs,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){"use strict";let e=Us();return Object.defineProperty(qs,"SUPPORT_CORS_IMAGES",{value:e}),e}};var Js=class{text;bounds;constructor(e,t){this.text=e,this.bounds=t}};let Ys=(e,t,n,r)=>{let i=nc(t,n),o=[],s=0;return i.forEach(t=>{if(n.textDecorationLine.length||t.trim().length>0){if(qs.SUPPORT_RANGE_BOUNDS){let n=Zs(r,s,t.length).getClientRects();if(n.length>1){let n=ec(t),i=0;n.forEach(t=>{o.push(new Js(t,a.fromDOMRectList(e,Zs(r,i+s,t.length).getClientRects()))),i+=t.length})}else o.push(new Js(t,a.fromDOMRectList(e,n)))}else{let n=r.splitText(t.length);o.push(new Js(t,Xs(e,r))),r=n}}else qs.SUPPORT_RANGE_BOUNDS||(r=r.splitText(t.length));s+=t.length}),o},Xs=(e,t)=>{let n=t.ownerDocument;if(n){let r=n.createElement(`html2canvaswrapper`);r.appendChild(t.cloneNode(!0));let i=t.parentNode;if(i){i.replaceChild(r,t);let n=o(e,r);return r.firstChild&&i.replaceChild(r.firstChild,r),n}}return a.EMPTY},Zs=(e,t,n)=>{let r=e.ownerDocument;if(!r)throw Error(`Node has no owner document`);let i=r.createRange();return i.setStart(e,t),i.setEnd(e,t+n),i},Qs=/* @__PURE__ */ new Map,$s=e=>{let t=Qs.get(e);return t||(t=new Intl.Segmenter(void 0,{granularity:e}),Qs.set(e,t)),t},ec=e=>Array.from($s(`grapheme`).segment(e),e=>e.segment),tc=e=>Array.from($s(`word`).segment(e),e=>e.segment),nc=(e,t)=>ka(t.writingMode)?ec(e):t.letterSpacing===0?tc(e):ec(e);var rc=class{text;textBounds;constructor(e,t,n){this.text=ic(t.data,n.textTransform),this.text.length!==t.data.length&&(t.data=this.text),this.textBounds=Ys(e,this.text,n,t)}};let ic=(e,t)=>{switch(t){case 1:return e.toLowerCase();case 3:return e.replace(ac,oc);case 2:return e.toUpperCase();default:return e}},ac=/(^|\s|:|-|\(|\))([a-z])/g,oc=(e,t,n)=>e.length>0?t+n.toUpperCase():e;var sc=class extends Vs{src;intrinsicWidth;intrinsicHeight;constructor(e,t,n={}){super(e,t,n),this.src=t.currentSrc||t.src,this.intrinsicWidth=t.naturalWidth,this.intrinsicHeight=t.naturalHeight,this.context.cache.addImage(this.src)}},cc=class extends Vs{canvas;intrinsicWidth;intrinsicHeight;constructor(e,t,n={}){super(e,t,n),this.canvas=t,this.intrinsicWidth=t.width,this.intrinsicHeight=t.height}};let lc=[`position`,`inset`,`top`,`right`,`bottom`,`left`,`inset-inline`,`inset-inline-start`,`inset-inline-end`,`inset-block`,`inset-block-start`,`inset-block-end`,`margin`,`margin-top`,`margin-right`,`margin-bottom`,`margin-left`,`margin-inline`,`margin-inline-start`,`margin-inline-end`,`margin-block`,`margin-block-start`,`margin-block-end`],uc=(e,t)=>{let n=t.getAttribute(`style`);lc.forEach(e=>t.style.removeProperty(e));let r=e.serializeToString(t);return n===null?t.removeAttribute(`style`):t.setAttribute(`style`,n),r};var dc=class extends Vs{svg;intrinsicWidth;intrinsicHeight;constructor(e,t,n={}){super(e,t,n);let r=new XMLSerializer,i=o(e,t);t.setAttribute(`width`,`${i.width}px`),t.setAttribute(`height`,`${i.height}px`),this.svg=`data:image/svg+xml,${encodeURIComponent(uc(r,t))}`,this.intrinsicWidth=t.width.baseVal.value,this.intrinsicHeight=t.height.baseVal.value,this.context.cache.addImage(this.svg)}},fc=class extends Vs{value;constructor(e,t,n={}){super(e,t,n),this.value=t.value}},pc=class extends Vs{start;reversed;constructor(e,t,n={}){super(e,t,n),this.start=t.start,this.reversed=typeof t.reversed==`boolean`&&t.reversed===!0}};let mc=[{type:15,flags:0,unit:`px`,number:3}],hc=[{type:16,flags:0,number:50}],gc=e=>e.width>e.height?new a(e.left+(e.width-e.height)/2,e.top,e.height,e.height):e.width<e.height?new a(e.left,e.top+(e.height-e.width)/2,e.width,e.width):e,_c=e=>{let t=e.type===`password`?Array(e.value.length+1).join(`•`):e.value;return t.length===0?e.placeholder||``:t},vc=e=>e.value.length===0&&!!e.placeholder;var yc=class extends Vs{type;checked;value;isPlaceholder;constructor(e,t,n={}){switch(super(e,t,n),this.type=t.type.toLowerCase(),this.checked=t.checked,this.value=_c(t),this.isPlaceholder=vc(t),(this.type===`checkbox`||this.type===`radio`)&&(this.styles.backgroundColor=3739148031,this.styles.borderTopColor=this.styles.borderRightColor=this.styles.borderBottomColor=this.styles.borderLeftColor=2779096575,this.styles.borderTopWidth=this.styles.borderRightWidth=this.styles.borderBottomWidth=this.styles.borderLeftWidth=1,this.styles.borderTopStyle=this.styles.borderRightStyle=this.styles.borderBottomStyle=this.styles.borderLeftStyle=1,this.styles.backgroundClip=[0],this.styles.backgroundOrigin=[0],this.bounds=gc(this.bounds)),this.type){case`checkbox`:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=mc;break;case`radio`:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=hc}}},bc=class extends Vs{value;constructor(e,t,n={}){super(e,t,n);let r=t.options[t.selectedIndex||0];this.value=r&&r.text||``}},xc=class extends Vs{value;constructor(e,t,n={}){super(e,t,n),this.value=t.value}},Sc=class extends Vs{src;width;height;tree;backgroundColor;parseTreeFn;constructor(e,t,n,r={}){super(e,t,r),this.src=t.src,this.width=parseInt(t.width,10)||0,this.height=parseInt(t.height,10)||0,this.backgroundColor=this.styles.backgroundColor,this.parseTreeFn=n;try{let n=t.contentWindow,r=n?.document;if(n&&r&&r.documentElement&&this.parseTreeFn){this.tree=this.parseTreeFn(e,r.documentElement);let t=Nn(e,n.getComputedStyle(r.documentElement).backgroundColor),i=r.body?Nn(e,n.getComputedStyle(r.body).backgroundColor):0;this.backgroundColor=R(t)?R(i)?this.styles.backgroundColor:i:t}}catch(e){let t=e instanceof Error?e:Error(String(e));this.context.logger.warn(`Unable to render iframe content${this.src?` from ${this.src}`:``}: ${t.message}`),this.context.onError?.(t)}}};let Cc=[`OL`,`UL`,`MENU`],wc=(e,t,n,r,i=1,a={})=>{for(let o=t.firstChild,s;o;o=s)s=o.nextSibling,Tc(e,o,n,r,i,a)},Tc=(e,t,n,r,i=1,o={})=>{if(In(t)&&t.data.length>0){let r=new rc(e,t,n.styles);if(i!==1){let e=n.bounds.left,t=n.bounds.top;r.textBounds=r.textBounds.map(n=>new Js(n.text,new a(e+(n.bounds.left-e)/i,t+(n.bounds.top-t)/i,n.bounds.width/i,n.bounds.height/i)))}n.textNodes.push(r)}else if(Fn(t)){if(Zn(t)&&t.assignedNodes)t.assignedNodes().forEach(t=>Tc(e,t,n,r,i,o));else{let s=Ec(e,t,o),c=s.styles.zoom||1;if(c!==1&&(s.bounds=new a(s.bounds.left,s.bounds.top,s.bounds.width/c,s.bounds.height/c)),s.styles.isVisible()){Oc(t,s,r)?s.createsRealStackingContext=!0:kc(s.styles)&&(s.createsStackingContext=!0),Cc.indexOf(t.tagName)!==-1&&(s.isListOwner=!0),n.elements.push(s);let a=i*(s.styles.zoom||1);t.shadowRoot?wc(e,t.shadowRoot,s,r,a,o):Yn(t)||Vn(t)||Xn(t)||wc(e,t,s,r,a,o)}}}},Ec=(e,t,n={})=>Gn(t)?new sc(e,t,n):Un(t)?new cc(e,t,n):Vn(t)?new dc(e,t,n):Qn(t)?new fc(e,t,n):$n(t)?new pc(e,t,n):zn(t)?new yc(e,t,n):Xn(t)?new bc(e,t,n):Yn(t)?new xc(e,t,n):Kn(t)?new Sc(e,t,(e,t)=>Dc(e,t,n),n):new Vs(e,t,n),Dc=(e,t,n={})=>{let r=Ec(e,t,n);return r.createsRealStackingContext=!0,wc(e,t,r,r,1,n),r},Oc=(e,t,n)=>t.styles.isPositionedWithZIndex()||t.styles.opacity<1||!!t.styles.filter||!!t.styles.backdropFilter||t.styles.maskImage.length>0||!!t.styles.webkitBoxReflect||t.styles.isolation===1||t.styles.willChange===1||t.styles.contain===1||t.styles.isTransformed()||Hn(e)&&n.styles.isTransparent(),kc=e=>e.isPositioned()||e.isFloating()||e.mixBlendMode!==K.NORMAL?!0:H(e.display,268435456)||H(e.display,33554432)||H(e.display,536870912)||H(e.display,134217728),Ac=(e,t)=>e.length===t.length&&e.some((e,n)=>e===t[n]),jc=(e,t,n,r,i)=>e.map((e,a)=>{switch(a){case 0:return e.add(t,n);case 1:return e.add(t+r,n);case 2:return e.add(t+r,n+i);case 3:return e.add(t,n+i)}return e});var J=class e{type;x;y;constructor(e,t){this.type=0,this.x=e,this.y=t}add(t,n){return new e(this.x+t,this.y+n)}};let Mc=(e,t,n)=>new J(e.x+(t.x-e.x)*n,e.y+(t.y-e.y)*n);var Nc=class e{type;start;startControl;endControl;end;constructor(e,t,n,r){this.type=1,this.start=e,this.startControl=t,this.endControl=n,this.end=r}subdivide(t,n){let r=Mc(this.start,this.startControl,t),i=Mc(this.startControl,this.endControl,t),a=Mc(this.endControl,this.end,t),o=Mc(r,i,t),s=Mc(i,a,t),c=Mc(o,s,t);return n?new e(this.start,r,o,c):new e(c,s,a,this.end)}add(t,n){return new e(this.start.add(t,n),this.startControl.add(t,n),this.endControl.add(t,n),this.end.add(t,n))}reverse(){return new e(this.end,this.endControl,this.startControl,this.start)}};let Y=e=>e.type===1;var Pc=class{topLeftBorderDoubleOuterBox;topRightBorderDoubleOuterBox;bottomRightBorderDoubleOuterBox;bottomLeftBorderDoubleOuterBox;topLeftBorderDoubleInnerBox;topRightBorderDoubleInnerBox;bottomRightBorderDoubleInnerBox;bottomLeftBorderDoubleInnerBox;topLeftBorderStroke;topRightBorderStroke;bottomRightBorderStroke;bottomLeftBorderStroke;topLeftBorderBox;topRightBorderBox;bottomRightBorderBox;bottomLeftBorderBox;topLeftPaddingBox;topRightPaddingBox;bottomRightPaddingBox;bottomLeftPaddingBox;topLeftContentBox;topRightContentBox;bottomRightContentBox;bottomLeftContentBox;constructor(e){let t=e.styles,n=e.bounds,[r,i]=He(t.borderTopLeftRadius,n.width,n.height),[a,o]=He(t.borderTopRightRadius,n.width,n.height),[s,c]=He(t.borderBottomRightRadius,n.width,n.height),[l,u]=He(t.borderBottomLeftRadius,n.width,n.height),d=[];d.push((r+a)/n.width),d.push((l+s)/n.width),d.push((i+u)/n.height),d.push((o+c)/n.height);let f=Math.max(...d);f>1&&(r/=f,i/=f,a/=f,o/=f,s/=f,c/=f,l/=f,u/=f);let p=n.width-a,m=n.height-c,h=n.width-s,g=n.height-u,_=t.borderTopWidth,v=t.borderRightWidth,y=t.borderBottomWidth,b=t.borderLeftWidth,x=I(t.paddingTop,e.bounds.width),S=I(t.paddingRight,e.bounds.width),C=I(t.paddingBottom,e.bounds.width),w=I(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||i>0?X(n.left+b/3,n.top+_/3,r-b/3,i-_/3,0):new J(n.left+b/3,n.top+_/3),this.topRightBorderDoubleOuterBox=a>0||o>0?X(n.left+p,n.top+_/3,a-v/3,o-_/3,1):new J(n.left+n.width-v/3,n.top+_/3),this.bottomRightBorderDoubleOuterBox=s>0||c>0?X(n.left+h,n.top+m,s-v/3,c-y/3,2):new J(n.left+n.width-v/3,n.top+n.height-y/3),this.bottomLeftBorderDoubleOuterBox=l>0||u>0?X(n.left+b/3,n.top+g,l-b/3,u-y/3,3):new J(n.left+b/3,n.top+n.height-y/3),this.topLeftBorderDoubleInnerBox=r>0||i>0?X(n.left+b*2/3,n.top+_*2/3,r-b*2/3,i-_*2/3,0):new J(n.left+b*2/3,n.top+_*2/3),this.topRightBorderDoubleInnerBox=a>0||o>0?X(n.left+p,n.top+_*2/3,a-v*2/3,o-_*2/3,1):new J(n.left+n.width-v*2/3,n.top+_*2/3),this.bottomRightBorderDoubleInnerBox=s>0||c>0?X(n.left+h,n.top+m,s-v*2/3,c-y*2/3,2):new J(n.left+n.width-v*2/3,n.top+n.height-y*2/3),this.bottomLeftBorderDoubleInnerBox=l>0||u>0?X(n.left+b*2/3,n.top+g,l-b*2/3,u-y*2/3,3):new J(n.left+b*2/3,n.top+n.height-y*2/3),this.topLeftBorderStroke=r>0||i>0?X(n.left+b/2,n.top+_/2,r-b/2,i-_/2,0):new J(n.left+b/2,n.top+_/2),this.topRightBorderStroke=a>0||o>0?X(n.left+p,n.top+_/2,a-v/2,o-_/2,1):new J(n.left+n.width-v/2,n.top+_/2),this.bottomRightBorderStroke=s>0||c>0?X(n.left+h,n.top+m,s-v/2,c-y/2,2):new J(n.left+n.width-v/2,n.top+n.height-y/2),this.bottomLeftBorderStroke=l>0||u>0?X(n.left+b/2,n.top+g,l-b/2,u-y/2,3):new J(n.left+b/2,n.top+n.height-y/2),this.topLeftBorderBox=r>0||i>0?X(n.left,n.top,r,i,0):new J(n.left,n.top),this.topRightBorderBox=a>0||o>0?X(n.left+p,n.top,a,o,1):new J(n.left+n.width,n.top),this.bottomRightBorderBox=s>0||c>0?X(n.left+h,n.top+m,s,c,2):new J(n.left+n.width,n.top+n.height),this.bottomLeftBorderBox=l>0||u>0?X(n.left,n.top+g,l,u,3):new J(n.left,n.top+n.height),this.topLeftPaddingBox=r>0||i>0?X(n.left+b,n.top+_,Math.max(0,r-b),Math.max(0,i-_),0):new J(n.left+b,n.top+_),this.topRightPaddingBox=a>0||o>0?X(n.left+Math.min(p,n.width-v),n.top+_,p>n.width+v?0:Math.max(0,a-v),Math.max(0,o-_),1):new J(n.left+n.width-v,n.top+_),this.bottomRightPaddingBox=s>0||c>0?X(n.left+Math.min(h,n.width-b),n.top+Math.min(m,n.height-y),Math.max(0,s-v),Math.max(0,c-y),2):new J(n.left+n.width-v,n.top+n.height-y),this.bottomLeftPaddingBox=l>0||u>0?X(n.left+b,n.top+Math.min(g,n.height-y),Math.max(0,l-b),Math.max(0,u-y),3):new J(n.left+b,n.top+n.height-y),this.topLeftContentBox=r>0||i>0?X(n.left+b+w,n.top+_+x,Math.max(0,r-(b+w)),Math.max(0,i-(_+x)),0):new J(n.left+b+w,n.top+_+x),this.topRightContentBox=a>0||o>0?X(n.left+Math.min(p,n.width+b+w),n.top+_+x,p>n.width+b+w?0:a-b+w,o-(_+x),1):new J(n.left+n.width-(v+S),n.top+_+x),this.bottomRightContentBox=s>0||c>0?X(n.left+Math.min(h,n.width-(b+w)),n.top+Math.min(m,n.height+_+x),Math.max(0,s-(v+S)),c-(y+C),2):new J(n.left+n.width-(v+S),n.top+n.height-(y+C)),this.bottomLeftContentBox=l>0||u>0?X(n.left+b+w,n.top+g,Math.max(0,l-(b+w)),u-(y+C),3):new J(n.left+b+w,n.top+n.height-(y+C))}};let X=(e,t,n,r,i)=>{let a=4*((Math.sqrt(2)-1)/3),o=n*a,s=r*a,c=e+n,l=t+r;switch(i){case 0:return new Nc(new J(e,l),new J(e,l-s),new J(c-o,t),new J(c,t));case 1:return new Nc(new J(e,t),new J(e+o,t),new J(c,l-s),new J(c,l));case 2:return new Nc(new J(c,t),new J(c,t+s),new J(e+o,l),new J(e,l));default:return new Nc(new J(c,l),new J(c-o,l),new J(e,t+s),new J(e,t))}},Fc=e=>[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox],Ic=e=>[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox],Lc=e=>[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox];var Rc=class{offsetX;offsetY;matrix;type=0;target=6;constructor(e,t,n){this.offsetX=e,this.offsetY=t,this.matrix=n}},zc=class{path;target;type=1;constructor(e,t){this.path=e,this.target=t}},Bc=class{opacity;type=2;target=6;constructor(e){this.opacity=e}},Vc=class{applyClip;type=3;target=6;constructor(e){this.applyClip=e}};let Hc={[K.NORMAL]:`source-over`,[K.MULTIPLY]:`multiply`,[K.SCREEN]:`screen`,[K.OVERLAY]:`overlay`,[K.DARKEN]:`darken`,[K.LIGHTEN]:`lighten`,[K.COLOR_DODGE]:`color-dodge`,[K.COLOR_BURN]:`color-burn`,[K.HARD_LIGHT]:`hard-light`,[K.SOFT_LIGHT]:`soft-light`,[K.DIFFERENCE]:`difference`,[K.EXCLUSION]:`exclusion`,[K.HUE]:`hue`,[K.SATURATION]:`saturation`,[K.COLOR]:`color`,[K.LUMINOSITY]:`luminosity`};var Uc=class{mixBlendMode;type=4;target=6;compositeOperation;constructor(e){this.mixBlendMode=e,this.compositeOperation=Hc[e]}},Wc=class e{type=5;target=6;safeFilterString;shadow;constructor(t){let n=e.parseDropShadow(t);this.shadow=n.shadow,this.safeFilterString=n.safeFilterString}static parseDropShadow(t){if(!t)return{safeFilterString:``};let n=e.findDropShadows(t);if(n.length===0)return{safeFilterString:t};let r=e.parseDropShadowBody(c(n,0).body),i=``,a=0;for(let e of n)i+=t.slice(a,e.start),a=e.end;return i+=t.slice(a),{shadow:r,safeFilterString:i.replace(/\s+/g,` `).trim()}}static findDropShadows(e){let t=[],n=/drop-shadow\(/gi,r;for(;(r=n.exec(e))!==null;){let n=r.index+12-1,i=r.index,a=1,o=n+1;for(;o<e.length&&a>0;){let t=e[o]??``;t===`(`?a++:t===`)`&&a--,o++}if(a!==0)break;let s=e.slice(n+1,o-1);t.push({body:s,start:i,end:o})}return t}static parseDropShadowBody(t){let n=e.tokenizeFilterArgs(t.trim()),r=[],i;for(let t of n)e.isCSSLength(t)?r.push(parseFloat(t)):t&&(i=t);if(!(r.length<2||r.length>3))return{offsetX:c(r,0),offsetY:c(r,1),blur:r.length>2?c(r,2):0,color:i??`rgba(0,0,0,1)`}}static tokenizeFilterArgs(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i++){let a=e[i]??``;a===`(`?(r++,n+=a):a===`)`?(r--,n+=a):/\s/.test(a)?r>0?n+=a:n&&=(t.push(n),``):n+=a}return n&&t.push(n),t}static isCSSLength(e){return/^-?[\d.]+(px|em|rem|pt|cm|mm|in|pc|ex|ch|vw|vh|vmin|vmax|%)?$/i.test(e)}};let Gc=e=>e.type===0,Kc=e=>e.type===1,qc=e=>e.type===2,Jc=e=>e.type===3,Yc=e=>e.type===4,Xc=e=>e.type===5;var Zc=class{element;negativeZIndex;zeroOrAutoZIndexOrTransformedOrOpacity;positiveZIndex;nonPositionedFloats;nonPositionedInlineLevel;inlineLevel;nonInlineLevel;constructor(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}},Qc=class{container;parent;effects=[];curves;listValue;plainEffectsCache=null;constructor(e,t){if(this.container=e,this.parent=t,this.curves=new Pc(this.container),this.container.styles.opacity<1&&this.effects.push(new Bc(this.container.styles.opacity)),this.container.styles.translate!==null){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+I(e[0],this.container.bounds.width),n=this.container.bounds.top+I(e[1],this.container.bounds.height),[r,i]=this.container.styles.translate,a=I(r,this.container.bounds.width),o=I(i,this.container.bounds.height);this.effects.push(new Rc(t,n,[1,0,0,1,a,o]))}if(this.container.styles.rotate!==null){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+I(e[0],this.container.bounds.width),n=this.container.bounds.top+I(e[1],this.container.bounds.height),r=this.container.styles.rotate*Math.PI/180,i=Math.cos(r),a=Math.sin(r),o=[i,a,-a,i,0,0];this.effects.push(new Rc(t,n,o))}if(this.container.styles.scale!==null){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+I(e[0],this.container.bounds.width),n=this.container.bounds.top+I(e[1],this.container.bounds.height),[r,i]=this.container.styles.scale;this.effects.push(new Rc(t,n,[r,0,0,i,0,0]))}if(this.container.styles.transform!==null){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+I(e[0],this.container.bounds.width),n=this.container.bounds.top+I(e[1],this.container.bounds.height),r=this.container.styles.transform;this.effects.push(new Rc(t,n,r))}if($c(this.container.styles)){let e=Fc(this.curves),t=Lc(this.curves);Ac(e,t)?this.effects.push(new zc(e,6)):(this.effects.push(new zc(e,2)),this.effects.push(new zc(t,4)))}if(this.container.styles.clipPath.type!==0){let e=tl(this.container.styles.clipPath,this.container.bounds);e&&this.effects.push(e)}if(this.container.styles.mixBlendMode!==K.NORMAL&&this.effects.push(new Uc(this.container.styles.mixBlendMode)),this.container.styles.filter!==null&&this.effects.push(new Wc(this.container.styles.filter)),this.container.styles.zoom!==1){let e=this.container.bounds.left,t=this.container.bounds.top,n=this.container.styles.zoom,r=[n,0,0,n,0,0];this.effects.push(new Rc(e,t,r))}}getEffects(e,t){if(!t){let t=this.plainEffectsCache;t||(t=/* @__PURE__ */ new Map,this.plainEffectsCache=t);let n=t.get(e);return n||(n=this.computeEffects(e),t.set(e,n)),n}return this.computeEffects(e,t)}computeEffects(e,t){let n=[2,3].indexOf(this.container.styles.position)===-1,r=this===t?null:this.parent,i=e=>e.effects.filter(n=>e!==t||!Xc(n)&&!qc(n)&&!Yc(n)),a=i(this);for(;r;){let e=i(r).filter(e=>!Kc(e));if(n||r.container.styles.position!==0||!r.parent){if(n=[2,3].indexOf(r.container.styles.position)===-1,$c(r.container.styles)){let e=Fc(r.curves),t=Lc(r.curves);Ac(e,t)||a.unshift(new zc(t,6))}a.unshift(...e)}else a.unshift(...e);r=r===t?null:r.parent}return a.filter(t=>H(t.target,e))}};let $c=e=>e.overflowX!==0||e.overflowY!==0,el=(e,t,n,r,i)=>e===`closest-side`?Math.min(t-n,r-t):e===`farthest-side`?Math.max(t-n,r-t):I(e,i),tl=(e,t)=>{let{left:n,top:r,width:i,height:a}=t;switch(e.type){case 1:{let t=I(e.left,i),o=I(e.top,a),s=n+t,c=r+o,l=Math.max(0,i-t-I(e.right,i)),u=Math.max(0,a-o-I(e.bottom,a));return new Vc(e=>{e.beginPath(),e.rect(s,c,l,u),e.clip()})}case 2:{let t=n+I(e.cx,i),o=r+I(e.cy,a),s;return s=e.radius===`closest-side`?Math.min(t-n,o-r,n+i-t,r+a-o):e.radius===`farthest-side`?Math.max(t-n,o-r,n+i-t,r+a-o):I(e.radius,Math.sqrt(i*i+a*a)/Math.SQRT2),new Vc(e=>{e.beginPath(),e.arc(t,o,Math.max(0,s),0,Math.PI*2),e.clip()})}case 3:{let t=n+I(e.cx,i),o=r+I(e.cy,a),s=el(e.rx,t,n,n+i,i),c=el(e.ry,o,r,r+a,a);return new Vc(e=>{e.beginPath(),e.ellipse(t,o,Math.max(0,s),Math.max(0,c),0,0,Math.PI*2),e.clip()})}case 4:{let t=e.points.map(([e,t])=>[n+I(e,i),r+I(t,a)]);return new Vc(e=>{if(e.beginPath(),t.length>0){e.moveTo(c(c(t,0),0),c(c(t,0),1));for(let n=1;n<t.length;n++)e.lineTo(c(c(t,n),0),c(c(t,n),1));e.closePath()}e.clip()})}case 5:{let{d:t}=e,i=null;return new Vc(e=>{try{i||=new Path2D(t);let a=e.getTransform();e.translate(n,r),e.clip(i),e.setTransform(a)}catch{}})}case 6:{let t=n+I(e.x,i),o=r+I(e.y,a),s=Math.max(0,I(e.width,i)),c=Math.max(0,I(e.height,a));return new Vc(e=>{e.beginPath(),e.rect(t,o,s,c),e.clip()})}case 0:return null;default:return null}},nl=(e,t,n,r)=>{e.container.elements.forEach(i=>{let a=i.createsRealStackingContext,o=i.createsStackingContext,s=new Qc(i,e);H(i.styles.display,2048)&&r.push(s);let c=i.isListOwner?[]:r;if(a||o){let e=a||i.styles.isPositioned()?n:t,r=new Zc(s);if(a||i.styles.isPositioned()||i.styles.opacity<1||i.styles.isTransformed()){let t=i.styles.zIndex.order;if(t<0){let n=0;e.negativeZIndex.some((e,r)=>t>=e.element.container.styles.zIndex.order?(n=r+1,!1):n>0),e.negativeZIndex.splice(n,0,r)}else if(t>0){let n=0;e.positiveZIndex.some((e,r)=>t>=e.element.container.styles.zIndex.order?(n=r+1,!1):n>0),e.positiveZIndex.splice(n,0,r)}else e.zeroOrAutoZIndexOrTransformedOrOpacity.push(r)}else i.styles.isFloating()?e.nonPositionedFloats.push(r):e.nonPositionedInlineLevel.push(r);nl(s,r,a?r:n,c)}else i.styles.isInlineLevel()?t.inlineLevel.push(s):t.nonInlineLevel.push(s),nl(s,t,n,c);i.isListOwner&&rl(i,c)})},rl=(e,t)=>{let n=e instanceof pc?e.start:1,r=e instanceof pc&&e.reversed;for(let e=0;e<t.length;e++){let i=c(t,e);i.container instanceof fc&&typeof i.container.value==`number`&&i.container.value!==0&&(n=i.container.value),i.listValue=_r(n,i.container.styles.listStyleType,!0),n+=r?-1:1}},il=e=>{let t=new Qc(e,null),n=new Zc(t),r=[];return nl(t,n,n,r),rl(t.container,r),n},al=e=>Math.min(1,Math.max(0,e)),ol=e=>{let t=c(e,0),n=c(e,e.length-1);if(n.stop-t.stop<1e-6)return null;let r=Math.max(n.stop-t.stop,.01),i=[],a=Math.ceil(1/r);for(let n=0;n<a;n++)for(let a of e){let e=n*r+(a.stop-t.stop);if(e>1)break;i.push({stop:e,color:z(a.color)})}let o=i[i.length-1];return(!o||o.stop<1)&&i.push({stop:1,color:z(n.color)}),i},sl=e=>e.map(e=>({stop:al(e.stop),color:z(e.color)})),cl=(e,t,n,r,i=!1)=>{let a=W(r,t),o=c(a,a.length-1),s=z(o.color),l=e.createElement(`canvas`);l.width=Math.max(1,Math.ceil(t*2)),l.height=Math.max(1,Math.ceil(n*2));let u=l.getContext(`2d`);if(!u)return null;let d;if(i){let e=ol(a);if(!e)return u.fillStyle=s,u.fillRect(0,0,l.width,l.height),{canvas:l,lastColor:s,rx:t,ry:n};d=e}else d=sl(a);let f=u.createRadialGradient(t,t,0,t,t,t);return d.forEach(e=>f.addColorStop(al(e.stop),e.color)),u.fillStyle=f,t!==n&&u.scale(1,n/t),u.fillRect(0,0,t*2,t*2),{canvas:l,lastColor:s,rx:t,ry:n}},ll=e=>{let t=e.bounds,n=e.styles;return t.add(n.borderLeftWidth,n.borderTopWidth,-(n.borderRightWidth+n.borderLeftWidth),-(n.borderTopWidth+n.borderBottomWidth))},ul=e=>{let t=e.styles,n=e.bounds,r=I(t.paddingLeft,n.width),i=I(t.paddingRight,n.width),a=I(t.paddingTop,n.width),o=I(t.paddingBottom,n.width);return n.add(r+t.borderLeftWidth,a+t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth+r+i),-(t.borderTopWidth+t.borderBottomWidth+a+o))},dl=(e,t)=>e===0?t.bounds:e===2?ul(t):ll(t),fl=(e,t)=>e===0?t.bounds:e===2?ul(t):ll(t),pl=(e,t,n)=>{let r=dl(_l(e.styles.backgroundOrigin,t),e),i=fl(_l(e.styles.backgroundClip,t),e),a=gl(_l(e.styles.backgroundSize,t),n,r),[o,s]=a,c=He(_l(e.styles.backgroundPosition,t),r.width-o,r.height-s),l=vl(_l(e.styles.backgroundRepeat,t),c,a,r,i),u=Math.round(r.left+c[0]),d=Math.round(r.top+c[1]);return o=Math.max(1,o),s=Math.max(1,s),[l,u,d,o,s]},ml=e=>D(e)&&e.value===`auto`,hl=e=>typeof e==`number`,gl=(e,[t,n,r],i)=>{let[a,o]=e;if(!a)return[0,0];if(M(a)&&o&&M(o))return[I(a,i.width),I(o,i.height)];let s=hl(r);if(D(a)&&(a.value===`contain`||a.value===`cover`))return hl(r)?i.width/i.height<r==(a.value===`cover`)?[i.height*r,i.height]:[i.width,i.width/r]:[i.width,i.height];let c=hl(t),l=hl(n),u=c||l;if(ml(a)&&(!o||ml(o)))return c&&l?[t,n]:!s&&!u?[i.width,i.height]:u&&s?[c?t:n*r,l?n:t/r]:[c?t:i.width,l?n:i.height];if(s){let e=0,t=0;return M(a)?e=I(a,i.width):o&&M(o)&&(t=I(o,i.height)),ml(a)?e=t*r:(!o||ml(o))&&(t=e/r),[e,t]}let d=null,f=null;if(M(a)?d=I(a,i.width):o&&M(o)&&(f=I(o,i.height)),d!==null&&(!o||ml(o))&&(f=c&&l?d/t*n:i.height),f!==null&&ml(a)&&(d=c&&l?f/n*t:i.width),d!==null&&f!==null)return[d,f];throw Error(`Unable to calculate background-size for element`)},_l=(e,t)=>{let n=e[t];return n===void 0?c(e,0):n},vl=(e,[t,n],[r,i],a,o)=>{switch(e){case 2:return[new J(Math.round(a.left),Math.round(a.top+n)),new J(Math.round(a.left+a.width),Math.round(a.top+n)),new J(Math.round(a.left+a.width),Math.round(i+a.top+n)),new J(Math.round(a.left),Math.round(i+a.top+n))];case 3:return[new J(Math.round(a.left+t),Math.round(a.top)),new J(Math.round(a.left+t+r),Math.round(a.top)),new J(Math.round(a.left+t+r),Math.round(a.height+a.top)),new J(Math.round(a.left+t),Math.round(a.height+a.top))];case 1:return[new J(Math.round(a.left+t),Math.round(a.top+n)),new J(Math.round(a.left+t+r),Math.round(a.top+n)),new J(Math.round(a.left+t+r),Math.round(a.top+n+i)),new J(Math.round(a.left+t),Math.round(a.top+n+i))];default:return[new J(Math.round(o.left),Math.round(o.top)),new J(Math.round(o.left+o.width),Math.round(o.top)),new J(Math.round(o.left+o.width),Math.round(o.height+o.top)),new J(Math.round(o.left),Math.round(o.height+o.top))]}};var Z=class extends Error{};let Q=e=>{e.width=e.height=0},yl=[`brightness`,`contrast`,`grayscale`,`hue-rotate`,`invert`,`opacity`,`saturate`,`sepia`],bl=/* @__PURE__ */ new Map,xl={functions:[]};function Sl(e){if(!e||e===`none`)return xl;let t=bl.get(e);if(t!==void 0)return bl.delete(e),bl.set(e,t),t;let n=Cl(e);if(bl.size>=256){let e=bl.keys().next().value;e!==void 0&&bl.delete(e)}return bl.set(e,n),n}let Cl=e=>{let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===` `||r===`
|
|
11
|
+
`||r===` `){n++;continue}let i=e.indexOf(`(`,n);if(i===-1)return null;let a=e.slice(n,i).trim();if(!/^[a-zA-Z-]+$/.test(a))return null;let o=wl(e,i);if(o===-1)return null;let s=El(a,e.slice(i+1,o).trim());if(!s)return null;t.push(s),n=o+1}return{functions:t}},wl=(e,t)=>{let n=1;for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r}return-1},Tl=/^-?\d+(?:\.\d+)?px$/,El=(e,t)=>{if(e===`blur`){if(t===`0`)return{kind:`blur`,value:0};if(!Tl.test(t))return null;let e=Number.parseFloat(t);return e<0?null:{kind:`blur`,value:e}}if(e===`drop-shadow`)return Ol(t);if(yl.indexOf(e)!==-1){let n=e;if(n===`hue-rotate`){let e=kl(t);return e===null?null:{kind:`unitless`,name:n,value:e}}let r=t.trim(),i=r.endsWith(`%`),a=i?r.slice(0,-1):r;return/^-?\d+(?:\.\d+)?$/.test(a)?{kind:`unitless`,name:n,value:Number.parseFloat(a)*(i?1/100:1)}:null}if(e===`url`){let e=Ps(t);return e?{kind:`url`,ref:e}:null}return null},Dl=e=>{let t=[],n=0,r=``;for(let i of e)i===`(`?n++:i===`)`&&n--,i===` `&&n===0?(r&&t.push(r),r=``):r+=i;return r&&t.push(r),t},Ol=e=>{let t=Dl(e),n=t.filter(e=>Tl.test(e)).map(e=>Number.parseFloat(e));if(n.length<2||n.length>3)return null;let r=t.filter(e=>!Tl.test(e));return t.length-r.length===n.length?{kind:`drop-shadow`,x:n[0],y:n[1],blur:n[2]??0,color:r.join(` `)||`rgba(0, 0, 0, 0)`}:null},kl=e=>{let t=e.trim();if(t===`0`)return 0;let n=Number.parseFloat(t);return Number.isNaN(n)?null:t.endsWith(`deg`)?n:t.endsWith(`grad`)?n*.9:t.endsWith(`rad`)?n*180/Math.PI:t.endsWith(`turn`)?n*360:null},Al=(e,t)=>e.functions.map(e=>{switch(e.kind){case`blur`:return`blur(${e.value*t}px)`;case`drop-shadow`:return`drop-shadow(${e.x*t}px ${e.y*t}px ${e.blur*t}px ${e.color})`;case`unitless`:return e.name===`hue-rotate`?`hue-rotate(${e.value}deg)`:`${e.name}(${e.value})`;case`url`:return`url("${e.ref}")`}}).join(` `);function jl(e,t){let n=0,r=0,i=0;for(let a of e.functions)a.kind===`blur`?n+=a.value:a.kind===`drop-shadow`?(n+=a.blur,r=Math.max(r,Math.abs(a.x),Math.abs(a.y))):a.kind===`url`&&(i+=t?.get(a.ref)?.outset??0);return Math.ceil(3*n+r+i)}function Ml(e){let t=(e.ownerDocument??document).createElement(`canvas`);return t.width=e.width,t.height=e.height,t}let Nl=(e,t)=>new Promise((n,r)=>{let i=e=>{clearTimeout(o),t?.removeEventListener(`abort`,a),e?r(e):n()},a=()=>i(new DOMException(`The operation was aborted.`,`AbortError`)),o=setTimeout(()=>i(new Z(`Filter surface image decode timed out`)),1e4);t?.addEventListener(`abort`,a,{once:!0}),t?.aborted?a():e.decode().then(()=>i(),()=>i(new Z(`Filter surface image decode failed`)))}),Pl=/* @__PURE__ */ new WeakMap;function Fl(e=document){let t=Pl.get(e);if(t!==void 0)return t;let n=e.createElement(`canvas`),r=e.createElement(`canvas`),i=!1;try{n.width=n.height=r.width=r.height=32;let e=n.getContext(`2d`),t=r.getContext(`2d`);if(e&&t&&`filter`in t){e.fillStyle=`#fff`,e.fillRect(8,8,8,8),t.filter=`blur(2px)`,t.drawImage(n,0,0);let r=(t.getImageData(6,12,1,1).data[3]??0)>0;t.clearRect(0,0,32,32),t.filter=`drop-shadow(12px 0px 0px rgba(255, 0, 0, 0.5))`,t.drawImage(n,0,0);let a=t.getImageData(24,12,1,1).data;i=r&&(a[0]??0)>240&&(a[1]??0)<10&&(a[3]??0)>=126&&(a[3]??0)<=129}}catch{}finally{Q(n),Q(r)}return Pl.set(e,i),i}function Il(e,t,n,r,i){let a,o,s=!1;try{q(i),a=Ml(e);let c=a.getContext(`2d`);if(!c||!(`filter`in c)||(c.filter=Al(t,r),c.filter===`none`||c.filter===``))return null;c.drawImage(e,0,0),q(i),o=Ml(e);let l=o.getContext(`2d`);return l?(l.globalAlpha=n,l.drawImage(a,0,0),q(i),s=!0,o):null}catch{return q(i),null}finally{a&&Q(a),o&&!s&&Q(o)}}let Ll=e=>{let t=0,n=0;for(let r of e.functions)if(r.kind===`blur`)t++;else if(r.kind===`drop-shadow`)n++;else return!1;return t>1||n>1?!1:t>0&&n>0?e.functions.findIndex(e=>e.kind===`blur`)<e.functions.findIndex(e=>e.kind===`drop-shadow`):!0};async function Rl(e,t,n,r,i,a){if(q(i),t.functions.some(e=>e.kind===`url`))return zl(e,t,n,r,i,a);if(t.functions.length>0&&Fl(e.ownerDocument??document)){let a=Il(e,t,n,r,i);if(a)return a}if(!Ll(t))throw new Z(`Filter chain requires native canvas filters`);return Gl(e,t,n,r,i)}async function zl(e,t,n,r,i,a){let o=[];for(let e of t.functions){if(e.kind===`url`){let t=a?.references?.get(e.ref);if(!t)throw new Z(`Filter reference ${e.ref} cannot be resolved`);o.push(t);continue}let t=o[o.length-1];Array.isArray(t)?t.push(e):o.push([e])}let s=a?.origin??{x:0,y:0},c=o[o.length-1],l=Array.isArray(c),u=e;try{for(let t of o){let a=Array.isArray(t)?await Rl(u,{functions:t},t===c?n:1,r,i):await Wl(u,t,s,r,i);u!==e&&Q(u),u=a}if(l||n===1){let t=u;return u=e,t}return Bl(u,n)}finally{u!==e&&Q(u)}}function Bl(e,t){let n=Ml(e),r=n.getContext(`2d`);if(!r)throw Q(n),new Z(`Filter surface canvas is unavailable`);r.globalAlpha=t;try{return r.drawImage(e,0,0),n}catch{throw Q(n),new Z(`Filter surface image cannot be drawn`)}}function Vl(e,t,n={}){let r=e.createElementNS(`http://www.w3.org/2000/svg`,t);return Object.entries(n).forEach(([e,t])=>r.setAttribute(e,String(t))),r}function Hl(e){try{let t=e.toDataURL(`image/png`);if(t===`data:,`)throw Error(`Canvas size is unsupported`);return t}catch{throw new Z(`Filter surface pixels cannot be serialized`)}}async function Ul(e,t,n,r){let i=(t.ownerDocument??document).defaultView,a=i?.Image?new i.Image:new Image,o;try{a.src=`data:image/svg+xml,${encodeURIComponent(new XMLSerializer().serializeToString(e))}`,await Nl(a,r),q(r),o=Ml(t);let i=o.getContext(`2d`);if(!i)throw new Z(`Filter surface canvas is unavailable`);return i.globalAlpha=n,i.drawImage(a,0,0),o}catch(e){throw o&&Q(o),r?.aborted&&q(r),e instanceof Z?e:new Z(`Filter surface image cannot be drawn`)}finally{a.removeAttribute(`src`)}}async function Wl(e,t,n,r,i){q(i);let a=e.ownerDocument??document,o=e.width/r,s=e.height/r,c=Vl(a,`svg`,{width:e.width,height:e.height,viewBox:`0 0 ${o} ${s}`}),l=Vl(a,`defs`),u=a.importNode(t.element,!0);u.setAttribute(`id`,`composited-reference`),l.appendChild(u),c.appendChild(l);let d=Vl(a,`g`,{transform:`translate(${n.x} ${n.y})`});return d.appendChild(Vl(a,`image`,{x:-n.x,y:-n.y,width:o,height:s,href:Hl(e),filter:`url(#composited-reference)`})),c.appendChild(d),Ul(c,e,1,i)}async function Gl(e,t,n,r,i){q(i);let a=t.functions.find(e=>e.kind===`blur`),o=t.functions.find(e=>e.kind===`drop-shadow`),s=a&&a.kind===`blur`?a.value:0,c=o&&o.kind===`drop-shadow`?{x:o.x,y:o.y,blur:o.blur,color:o.color}:void 0;if(!s&&!c)return Bl(e,n);let l=e.ownerDocument??document,u=(e,t={})=>Vl(l,e,t),d=u(`svg`,{width:e.width,height:e.height,viewBox:`0 0 ${e.width} ${e.height}`}),f=u(`defs`),p=u(`filter`,{id:`composited-filter`,filterUnits:`userSpaceOnUse`,x:0,y:0,width:e.width,height:e.height,"color-interpolation-filters":`sRGB`});if(s&&p.appendChild(u(`feGaussianBlur`,{stdDeviation:s*r,result:`blurred-source`})),c){p.appendChild(u(`feGaussianBlur`,{in:s?`blurred-source`:`SourceAlpha`,stdDeviation:c.blur*r})),p.appendChild(u(`feOffset`,{dx:c.x*r,dy:c.y*r,result:`offset-shadow`})),p.appendChild(u(`feFlood`,{"flood-color":c.color})),p.appendChild(u(`feComposite`,{in2:`offset-shadow`,operator:`in`}));let e=u(`feMerge`);e.appendChild(u(`feMergeNode`)),e.appendChild(u(`feMergeNode`,{in:s?`blurred-source`:`SourceGraphic`})),p.appendChild(e)}return f.appendChild(p),d.appendChild(f),d.appendChild(u(`image`,{width:e.width,height:e.height,href:Hl(e),filter:`url(#composited-filter)`})),Ul(d,e,n,i)}function Kl(e,t,n){let r=t*n*4;return!Number.isFinite(r)||t<=0||n<=0||t>8192||n>8192||e.pixels+r>16777216?0:(e.pixels+=r,r)}let ql=(e,t)=>e.add(-t,-t,t*2,t*2),Jl=(e,t)=>new a(Math.min(e.left,t.left),Math.min(e.top,t.top),Math.max(e.left+e.width,t.left+t.width)-Math.min(e.left,t.left),Math.max(e.top+e.height,t.top+t.height)-Math.min(e.top,t.top));function Yl(e){let t=e.styles,n=e.bounds;for(let r of t.boxShadow)if(!r.inset){let t=Math.max(0,r.spread.number)+3*r.blur.number;n=Jl(n,ql(e.bounds.add(r.offsetX.number,r.offsetY.number,0,0),t))}for(let r of e.textNodes)for(let i of r.textBounds){let r=ql(i.bounds,2*I(t.fontSize,e.bounds.height)+t.webkitTextStrokeWidth);n=Jl(n,r);for(let e of t.textShadow)n=Jl(n,ql(r.add(e.offsetX.number,e.offsetY.number,0,0),3*e.blur.number))}for(let t of e.elements)t.styles.isVisible()&&(n=Jl(n,Yl(t)));let r=Sl(t.filter);return ql(n,r?jl(r,e.filterReferences):0)}function Xl(e,t,n,r){let i=ql(t,n),o=Math.floor(Math.max(e.left,i.left)*r)/r,s=Math.floor(Math.max(e.top,i.top)*r)/r,c=Math.ceil(Math.min(e.left+e.width,i.left+i.width)*r)/r,l=Math.ceil(Math.min(e.top+e.height,i.top+i.height)*r)/r;return new a(o,s,Math.max(0,c-o),Math.max(0,l-s))}let Zl=[1,0,0,1,0,0],Ql=e=>e[0]===1&&e[1]===0&&e[2]===0&&e[3]===1&&e[4]===0&&e[5]===0,$l=(e,t)=>[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]],eu=(e,t,n)=>[e[0]*t+e[2]*n+e[4],e[1]*t+e[3]*n+e[5]],tu=(e,t)=>{let n=[eu(e,t.left,t.top),eu(e,t.left+t.width,t.top),eu(e,t.left,t.top+t.height),eu(e,t.left+t.width,t.top+t.height)],r=Math.min(...n.map(e=>e[0])),i=Math.max(...n.map(e=>e[0])),o=Math.min(...n.map(e=>e[1])),s=Math.max(...n.map(e=>e[1]));return new a(r,o,i-r,s-o)},nu=e=>{let t=e[0]*e[3]-e[1]*e[2];if(!Number.isFinite(t)||t===0)return null;let n=1/t;return[e[3]*n,-e[1]*n,-e[2]*n,e[0]*n,(e[2]*e[5]-e[3]*e[4])*n,(e[1]*e[4]-e[0]*e[5])*n]},ru=(e,t)=>{let n=nu(e);return n?tu(n,t):null};var iu=class{ctx;constructor(e){this.ctx=e}render(e,t){this.ctx.fillStyle=z(t.textDecorationColor??t.color);let n=1;typeof t.textDecorationThickness==`number`?n=t.textDecorationThickness:t.textDecorationThickness===`from-font`&&(n=Math.max(1,Math.floor(t.fontSize.number*.05)));let r=0;typeof t.textUnderlineOffset==`number`&&(r=t.textUnderlineOffset);let i=t.textDecorationStyle;t.textDecorationLine.forEach(t=>{let a=0;switch(t){case 1:a=e.top+e.height-n+r;break;case 2:a=e.top;break;case 3:a=e.top+(e.height/2-n/2);break;default:return}this.draw(e.left,a,e.width,n,i)})}draw(e,t,n,r,i){switch(i){case 0:this.ctx.fillRect(e,t,n,r);break;case 1:{let i=Math.max(1,r);this.ctx.fillRect(e,t,n,r),this.ctx.fillRect(e,t+r+i,n,r);break}case 2:this.drawPattern(e,t,n,r,[r,r*2]);break;case 3:this.drawPattern(e,t,n,r,[r*3,r*2]);break;case 4:this.drawWavy(e,t,n,r);break;default:this.ctx.fillRect(e,t,n,r)}}drawPattern(e,t,n,r,i){this.ctx.save(),this.ctx.beginPath(),this.ctx.setLineDash(i),this.ctx.lineWidth=r,this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.moveTo(e,t+r/2),this.ctx.lineTo(e+n,t+r/2),this.ctx.stroke(),this.ctx.restore()}drawWavy(e,t,n,r){this.ctx.save(),this.ctx.beginPath(),this.ctx.lineWidth=r,this.ctx.strokeStyle=this.ctx.fillStyle;let i=r*2,a=r*4,o=e;for(this.ctx.moveTo(o,t+r/2);o<e+n;){let s=Math.min(o+a/2,e+n);if(this.ctx.quadraticCurveTo(o+a/4,t+r/2-i,s,t+r/2),o=s,o<e+n){let s=Math.min(o+a/2,e+n);this.ctx.quadraticCurveTo(o+a/4,t+r/2+i,s,t+r/2),o=s}}this.ctx.stroke(),this.ctx.restore()}};let au=e=>e!==void 0&&!Number.isNaN(e),ou=(e,t)=>{let n=e.measureText(`Mg`),r=n;return{baseline:au(r.fontBoundingBoxAscent)?r.fontBoundingBoxAscent:au(n.actualBoundingBoxAscent)?n.actualBoundingBoxAscent:t,height:au(r.fontBoundingBoxAscent)&&au(r.fontBoundingBoxDescent)?r.fontBoundingBoxAscent+r.fontBoundingBoxDescent:au(n.actualBoundingBoxAscent)&&au(n.actualBoundingBoxDescent)?n.actualBoundingBoxAscent+n.actualBoundingBoxDescent:t}},su=(e,t)=>ou(e,t).baseline,cu=/[\u2E80-\u2FFF\u3000-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFFEF]/,lu=e=>cu.test(e),uu=()=>typeof navigator>`u`?!1:navigator.userAgentData!==void 0||(typeof window<`u`?window:void 0)?.chrome!==void 0,du=()=>uu()?`miter`:`round`;var fu=class{ctx;options;decorationRenderer;baselineCache=/* @__PURE__ */ new Map;glyphWidthCache=null;constructor(e){this.ctx=e.ctx,this.options=e.options,this.decorationRenderer=new iu(e.ctx)}cachedMeasureText(e,t){let n=this.glyphWidthCache;n||(n=/* @__PURE__ */ new Map,this.glyphWidthCache=n);let r=e+t,i=n.get(r);return i===void 0&&(i=this.ctx.measureText(e).width,n.set(r,i)),i}iterateLettersWithLetterSpacing(e,t,n,r,i){if(ka(r)){this.iterateVerticalGlyphs(e,t,n,r,i);return}let a=ec(e.text),o=e.bounds.top+n,s=this.ctx.font,c=e.bounds.left;for(let e of a)i(e,c,o),c+=this.cachedMeasureText(e,s)+t}iterateVerticalGlyphs(e,t,n,r,i){let a=ec(e.text),o=this.ctx.font,s=r===4?-Math.PI/2:Math.PI/2,c=e.bounds.top;for(let l=0;l<a.length;){let u=a[l];if(!(Aa(r)||!lu(u)&&u.trim().length>0)){let r=this.ctx.textBaseline;lu(u)&&(this.ctx.textBaseline=`ideographic`),i(u,e.bounds.left,c+n),this.ctx.textBaseline=r,c+=this.cachedMeasureText(u,o)+t,l++;continue}let d=l;for(;l<a.length;){let e=a[l];if(!Aa(r)&&!lu(e)&&e.trim().length===0)break;if(Aa(r)||!lu(e)&&e.trim().length>0)l++;else break}this.ctx.save(),this.ctx.translate(e.bounds.left+n,c),this.ctx.rotate(s);let f=0;for(let e=d;e<l;e++){let n=a[e];i(n,0,f),f+=this.cachedMeasureText(n,o)+t}this.ctx.restore(),c+=f}}renderTextWithLetterSpacing(e,t,n,r=0){this.renderFillText(e,t,n,r)}canRenderWholeText(e,t){return e===0&&!ka(t)}renderFillText(e,t,n,r){this.canRenderWholeText(t,r)?this.ctx.fillText(e.text,e.bounds.left,e.bounds.top+n):this.iterateLettersWithLetterSpacing(e,t,n,r,(e,t,n)=>{this.ctx.fillText(e,t,n)})}renderStrokeText(e,t,n,r){this.canRenderWholeText(t,r)?this.ctx.strokeText(e.text,e.bounds.left,e.bounds.top+n):this.iterateLettersWithLetterSpacing(e,t,n,r,(e,t,n)=>{this.ctx.strokeText(e,t,n)})}renderTextStrokeWithStyle(e,t,n){t.webkitTextStrokeWidth&&e.text.trim().length&&(this.ctx.strokeStyle=z(t.webkitTextStrokeColor),this.ctx.lineWidth=t.webkitTextStrokeWidth,this.ctx.lineJoin=du(),this.renderStrokeText(e,t.letterSpacing,n,t.writingMode),this.ctx.strokeStyle=``,this.ctx.lineWidth=0,this.ctx.lineJoin=`miter`)}renderTextFillWithShadows(e,t,n){this.ctx.fillStyle=this.resolveFillColor(t),this.renderTextWithLetterSpacing(e,t.letterSpacing,n,t.writingMode);let r=t.textShadow;r.length&&e.text.trim().length&&(r.slice(0).reverse().forEach(r=>{this.ctx.shadowColor=z(r.color),this.ctx.shadowOffsetX=r.offsetX.number*this.options.scale,this.ctx.shadowOffsetY=r.offsetY.number*this.options.scale,this.ctx.shadowBlur=r.blur.number*this.options.scale,this.renderTextWithLetterSpacing(e,t.letterSpacing,n,t.writingMode)}),this.ctx.shadowColor=``,this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0)}renderTextBoundWithPaintOrder(e,t,n,r){n.forEach(n=>{switch(n){case 0:this.ctx.fillStyle=this.resolveFillColor(t),this.renderTextWithLetterSpacing(e,t.letterSpacing,r,t.writingMode);break;case 1:this.renderTextStrokeWithStyle(e,t,r)}})}renderTextDecoration(e,t){this.decorationRenderer.render(e,t)}truncateTextWithEllipsis(e,t,n){let r=this.ctx.measureText(`…`).width,i=ec(e);if(n===0){let e=e=>this.ctx.measureText(i.slice(0,e).join(``)).width+r<=t,n=0,a=i.length;for(;n<a;){let t=n+a+1>>1;e(t)?n=t:a=t-1}return i.slice(0,n).join(``)+`…`}{let e=this.ctx.font,a=r,o=[];for(let r of i){let i=this.cachedMeasureText(r,e);if(a+i>t)break;o.push(r),a+=i+n}return o.join(``)+`…`}}createFontStyle(e){let t=e.fontVariant.filter(e=>e===`normal`||e===`small-caps`).join(``),n=e.fontFamily.join(`, `),r=T(e.fontSize)?`${e.fontSize.number}${e.fontSize.unit}`:`${e.fontSize.number}px`;return[[e.fontStyle,t,e.fontWeight,r,n].join(` `),n,r]}resolveFillColor(e){return z(e.webkitTextFillColor??e.color)}renderLineClampedText(e,t,n,r,i){let a=na(t.lineHeight,t.fontSize.number),o=[],s=[],l=c(e.textBounds,0).bounds.top;e.textBounds.forEach(e=>{Math.abs(e.bounds.top-l)>=a*.5?(s.length>0&&o.push(s),s=[e],l=e.bounds.top):s.push(e)}),s.length>0&&o.push(s);let u=t.webkitLineClamp;if(o.length<=u)return!1;for(let e=0;e<u-1;e++)c(o,e).forEach(e=>this.renderTextBoundWithPaintOrder(e,t,n,r));let d=o[u-1];if(d?.length&&i){let e=d.map(e=>e.text).join(``),a=c(d,0),o=i.width-(a.bounds.left-i.left),s=new Js(this.truncateTextWithEllipsis(e,o,t.letterSpacing),a.bounds);for(let e of n)e===0?(this.ctx.fillStyle=this.resolveFillColor(t),this.renderTextWithLetterSpacing(s,t.letterSpacing,r,t.writingMode)):e===1&&this.renderTextStrokeWithStyle(s,t,r)}return!0}renderEllipsisText(e,t,n,r,i){let a=na(t.lineHeight,t.fontSize.number),o=c(e.textBounds,0).bounds.top;if(!e.textBounds.every(e=>Math.abs(e.bounds.top-o)<a*.5))return!1;let s=e.textBounds.map(e=>e.text).join(``).replace(/\s+/g,` `).trim();if(this.ctx.measureText(s).width<=i.width+1)return!1;let l=new Js(this.truncateTextWithEllipsis(s,i.width,t.letterSpacing),c(e.textBounds,0).bounds);for(let e of n)e===0?this.renderTextFillWithShadows(l,t,r):e===1&&this.renderTextStrokeWithStyle(l,t,r);return!0}measureBaselineCached(e,t){let n=this.baselineCache.get(e);return n===void 0&&(n=su(this.ctx,t),this.baselineCache.size>=64&&this.baselineCache.clear(),this.baselineCache.set(e,n)),n}async renderTextNode(e,t,n){this.glyphWidthCache=null;let[r]=this.createFontStyle(t);this.ctx.font=r??``,this.ctx.direction=t.direction===1?`rtl`:`ltr`,this.ctx.textAlign=`left`,this.ctx.textBaseline=`alphabetic`;let i=t.paintOrder,a=this.measureBaselineCached(r??``,t.fontSize.number);t.webkitLineClamp>0&&t.display&34&&t.overflowY===1&&e.textBounds.length>0&&this.renderLineClampedText(e,t,i,a,n)||t.textOverflow===1&&n&&t.overflowX===1&&e.textBounds.length>0&&this.renderEllipsisText(e,t,i,a,n)||(e.textBounds.forEach(e=>{i.forEach(n=>{n===0?(this.renderTextFillWithShadows(e,t,a),t.textDecorationLine.length&&this.renderTextDecoration(e.bounds,t)):n===1&&this.renderTextStrokeWithStyle(e,t,a)})}),t.textEmphasisStyle&&this.renderTextEmphasis(e,t,a))}renderTextEmphasis(e,t,n){if(ka(t.writingMode))return;let r=t.textEmphasisStyle;if(!r)return;let i=t.fontSize.number,a=i*.5,o=z(t.textEmphasisColor??t.color),s=t.textEmphasisPosition,c=(e,t)=>{if(typeof r==`string`){let n=this.ctx.font;this.ctx.font=n.replace(/^\S+/,`${a}px`),this.ctx.textAlign=`center`,this.ctx.fillText(r,e,t+a/3),this.ctx.font=n,this.ctx.textAlign=`left`;return}let{fill:n,shape:i}=r,o=a*(i===`dot`?.3:i===`sesame`?.26:.34);this.ctx.beginPath(),i===`sesame`?this.ctx.ellipse(e,t,o*1.3,o*.8,Math.PI/4,0,Math.PI*2):i===`triangle`?(this.ctx.moveTo(e,t-o),this.ctx.lineTo(e+o*1.1,t+o*.8),this.ctx.lineTo(e-o*1.1,t+o*.8),this.ctx.closePath()):this.ctx.arc(e,t,o,0,Math.PI*2),n?i===`double-circle`?(this.ctx.lineWidth=o*.7,this.ctx.stroke(),this.ctx.beginPath(),this.ctx.arc(e,t,o*.4,0,Math.PI*2),this.ctx.lineWidth=o*.35,this.ctx.stroke()):this.ctx.fill():(this.ctx.lineWidth=Math.max(1,o*.35),this.ctx.stroke(),i===`double-circle`&&(this.ctx.beginPath(),this.ctx.arc(e,t,o*.5,0,Math.PI*2),this.ctx.stroke()))},l=this.ctx.font;for(let r of e.textBounds){let e=r.bounds.top+n,u=s.over?e-i-a*.4:e+a*.9,d=r.bounds.left;for(let e of ec(r.text)){let n=this.cachedMeasureText(e,l);this.ctx.save();try{this.ctx.fillStyle=o,this.ctx.strokeStyle=o,this.ctx.lineWidth=1,c(d+n/2+t.letterSpacing/2,u)}finally{this.ctx.restore()}d+=n+t.letterSpacing}}}};let pu=(e,t)=>{t.forEach((t,n)=>{let r=Y(t)?t.start:t;n===0?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y),Y(t)&&e.bezierCurveTo(t.startControl.x,t.startControl.y,t.endControl.x,t.endControl.y,t.end.x,t.end.y)})},mu=(e,t)=>{e.beginPath(),pu(e,t),e.closePath()};var hu=class{maxSize;_map;constructor(e){this.maxSize=e,this._map=/* @__PURE__ */ new Map}get(e){if(!this._map.has(e))return;let t=this._map.get(e);return this._map.delete(e),this._map.set(e,t),t}set(e,t){if(this._map.has(e))this._map.delete(e);else if(this._map.size>=this.maxSize){let e=this._map.keys().next().value;e!==void 0&&this._map.delete(e)}this._map.set(e,t)}get size(){return this._map.size}clear(){this._map.clear()}},gu=class{ctx;context;canvas;patternCache=new hu(50);constructor(e){this.ctx=e.ctx,this.context=e.context,this.canvas=e.canvas}async renderBackgroundImage(e){let t=e.styles.backgroundImage.length-1,n=e.styles.backgroundBlendMode,r=0;for(let i of e.styles.backgroundImage.slice(0).reverse()){if(r>0){let e=n[r]??n[0]??`normal`;e!==`normal`&&(this.ctx.save(),this.ctx.globalCompositeOperation=e)}i.type===0?await this.renderBackgroundURLImage(e,i,t):ni(i)?this.renderLinearGradient(e,i,t):ii(i)?this.renderRepeatingLinearGradient(e,i,t):ri(i)?this.renderRadialGradient(e,i,t):ai(i)?this.renderRepeatingRadialGradient(e,i,t):oi(i)?this.renderConicGradient(e,i,t):si(i)&&this.renderRepeatingConicGradient(e,i,t),r>0&&(n[r]??n[0]??`normal`)!==`normal`&&this.ctx.restore(),t--,r++}}async renderBackgroundURLImage(e,t,n){let r,i=t.url;try{r=await this.context.cache.match(i)}catch{this.context.logger.error(`Error loading background-image ${i}`)}if(r){let t=isNaN(r.width)||r.width===0?1:r.width,a=isNaN(r.height)||r.height===0?1:r.height,[o,s,c,l,u]=pl(e,n,[t,a,t/a]),d=_l(e.styles.backgroundRepeat,n),f=d===1?`no-repeat`:d===2?`repeat-x`:d===3?`repeat-y`:`repeat`,p=`${i}|${Math.round(l)}x${Math.round(u)}|${e.styles.imageRendering}|${f}`,m=this.patternCache.get(p);if(!m){let t=this.resizeImage(r,l,u,e.styles.imageRendering);m=this.ctx.createPattern(t,f),this.patternCache.set(p,m)}this.renderRepeat(o,m,s,c)}}renderRepeatingLinearGradient(e,t,n){let[r,i,a,o,s]=pl(e,n,[null,null,null]),[l,u,d,f,p]=Pr(t.angle,o,s),m=i+u,h=i+d,g=a+f,_=a+p,v=W(t.stops,l||1),y=ol(v),b=this.ctx.createLinearGradient(m,g,h,_);if(y)y.forEach(e=>b.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color));else{let e=z(c(v,v.length-1).color);b.addColorStop(0,e),b.addColorStop(1,e)}this.path(r),this.ctx.fillStyle=b,this.ctx.fill()}renderLinearGradient(e,t,n){let[r,i,a,o,s]=pl(e,n,[null,null,null]),[c,l,u,d,f]=Pr(t.angle,o,s),p=`lg|${t.angle}|${Math.round(o)}x${Math.round(s)}|${JSON.stringify(t.stops)}`,m=this.patternCache.get(p);if(!m){let e=(this.canvas.ownerDocument??document).createElement(`canvas`);e.width=o,e.height=s;let n=e.getContext(`2d`);if(!n)return;let r=n.createLinearGradient(l,d,u,f);W(t.stops,c||1).forEach(e=>r.addColorStop(e.stop,z(e.color))),n.fillStyle=r,n.fillRect(0,0,o,s),o>0&&s>0&&(m=this.ctx.createPattern(e,`repeat`),this.patternCache.set(p,m))}m&&this.renderRepeat(r,m,i,a)}renderRadialGradient(e,t,n){let[r,i,a,o,s]=pl(e,n,[null,null,null]),l=t.position.length===0?[P]:t.position,u=I(c(l,0),o),d=I(c(l,l.length-1),s),[f,p]=Ir(t,u,d,o,s);if((f===0||p===0)&&(f=Math.max(f,.01),p=Math.max(p,.01)),f>0&&p>0){let e=`rg|${Math.round(u)}x${Math.round(d)}|${Math.round(f)}x${Math.round(p)}|${JSON.stringify(t.stops)}`,n=W(t.stops,f),o=z(c(n,n.length-1).color),s=this.patternCache.get(e);if(!s){let n=this.canvas.ownerDocument??document,r=cl(n,f,p,t.stops,!1);if(!r)return;s=this.ctx.createPattern(r.canvas,`no-repeat`),this.patternCache.set(e,s)}this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=o,this.ctx.fill(),this.ctx.translate(i+u-f,a+d-p),this.ctx.fillStyle=s,this.ctx.fillRect(0,0,f*2,p*2),this.ctx.restore()}}renderRepeatingRadialGradient(e,t,n){let[r,i,a,o,s]=pl(e,n,[null,null,null]),l=t.position.length===0?[P]:t.position,u=I(c(l,0),o),d=I(c(l,l.length-1),s),[f,p]=Ir(t,u,d,o,s);if((f===0||p===0)&&(f=Math.max(f,.01),p=Math.max(p,.01)),!(f>0&&p>0))return;let m=`rrg|${Math.round(u)}x${Math.round(d)}|${Math.round(f)}x${Math.round(p)}|${JSON.stringify(t.stops)}`,h=this.patternCache.get(m);if(!h){let e=this.canvas.ownerDocument??document,n=cl(e,f,p,t.stops,!0);if(!n)return;h=this.ctx.createPattern(n.canvas,`no-repeat`),this.patternCache.set(m,h)}h&&(this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.translate(i+u-f,a+d-p),this.ctx.fillStyle=h,this.ctx.fillRect(0,0,f*2,p*2),this.ctx.restore())}renderConicGradient(e,t,n){let[r,i,a,o,s]=pl(e,n,[null,null,null]),l=t.position.length===0?[P]:t.position,u=i+I(c(l,0),o),d=a+I(c(l,l.length-1),s),f=this.ctx.createConicGradient(t.angle-Math.PI/2,u,d);W(t.stops,1).forEach(e=>{f.addColorStop(Math.min(1,Math.max(0,e.stop)),z(e.color))}),this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=f,this.ctx.fill(),this.ctx.restore()}renderRepeatingConicGradient(e,t,n){let[r,i,a,o,s]=pl(e,n,[null,null,null]),l=t.position.length===0?[P]:t.position,u=i+I(c(l,0),o),d=a+I(c(l,l.length-1),s),f=W(t.stops,1),p=c(f,0),m=c(f,f.length-1),h=Math.max(m.stop-p.stop,.01);if(m.stop-p.stop<1e-6){let e=this.ctx.createConicGradient(t.angle-Math.PI/2,u,d);e.addColorStop(0,z(m.color)),e.addColorStop(1,z(m.color)),this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=e,this.ctx.fill(),this.ctx.restore();return}let g=[],_=Math.ceil(1/h);for(let e=0;e<_;e++)for(let t of f){let n=e*h+(t.stop-p.stop);if(n>1)break;g.push({stop:n,color:z(t.color)})}let v=c(g,g.length-1);v&&v.stop<1&&g.push({stop:1,color:v.color});let y=this.ctx.createConicGradient(t.angle-Math.PI/2,u,d);g.forEach(e=>{y.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color)}),this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=y,this.ctx.fill(),this.ctx.restore()}renderRepeat(e,t,n,r){this.path(e),this.ctx.fillStyle=t,this.ctx.translate(n,r),this.ctx.fill(),this.ctx.translate(-n,-r)}resizeImage(e,t,n,r){let i=(this.canvas.ownerDocument??document).createElement(`canvas`);i.width=Math.max(1,t),i.height=Math.max(1,n);let a=i.getContext(`2d`);return a?(r===2||r===1?(this.context.logger.debug(`Disabling image smoothing for background image due to CSS image-rendering`),a.imageSmoothingEnabled=!1):r===3?(this.context.logger.debug(`Enabling image smoothing for background image due to CSS image-rendering: smooth`),a.imageSmoothingEnabled=!0):a.imageSmoothingEnabled=this.ctx.imageSmoothingEnabled,this.ctx.imageSmoothingQuality&&(a.imageSmoothingQuality=this.ctx.imageSmoothingQuality),a.drawImage(e,0,0,e.width,e.height,0,0,t,n),i):e}path(e){mu(this.ctx,e)}};let _u=(e,t)=>{switch(t){case 0:return $(e.topLeftBorderBox,e.topLeftPaddingBox,e.topRightBorderBox,e.topRightPaddingBox);case 1:return $(e.topRightBorderBox,e.topRightPaddingBox,e.bottomRightBorderBox,e.bottomRightPaddingBox);case 2:return $(e.bottomRightBorderBox,e.bottomRightPaddingBox,e.bottomLeftBorderBox,e.bottomLeftPaddingBox);default:return $(e.bottomLeftBorderBox,e.bottomLeftPaddingBox,e.topLeftBorderBox,e.topLeftPaddingBox)}},vu=(e,t)=>{switch(t){case 0:return $(e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox,e.topRightBorderBox,e.topRightBorderDoubleOuterBox);case 1:return $(e.topRightBorderBox,e.topRightBorderDoubleOuterBox,e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox);case 2:return $(e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox,e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox);default:return $(e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox,e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox)}},yu=(e,t)=>{switch(t){case 0:return $(e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox,e.topRightBorderDoubleInnerBox,e.topRightPaddingBox);case 1:return $(e.topRightBorderDoubleInnerBox,e.topRightPaddingBox,e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox);case 2:return $(e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox,e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox);default:return $(e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox,e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox)}},bu=(e,t)=>{switch(t){case 0:return xu(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return xu(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return xu(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return xu(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}},xu=(e,t)=>{let n=[];return Y(e)?n.push(e.subdivide(.5,!1)):n.push(e),Y(t)?n.push(t.subdivide(.5,!0)):n.push(t),n},$=(e,t,n,r)=>{let i=[];return Y(e)?i.push(e.subdivide(.5,!1)):i.push(e),Y(n)?i.push(n.subdivide(.5,!0)):i.push(n),Y(r)?i.push(r.subdivide(.5,!0).reverse()):i.push(r),Y(t)?i.push(t.subdivide(.5,!1).reverse()):i.push(t),i};var Su=class{ctx;pathCallbacks;constructor(e,t){this.ctx=e.ctx,this.pathCallbacks=t}async renderSolidBorder(e,t,n){this.pathCallbacks.path(_u(n,t)),this.ctx.fillStyle=z(e),this.ctx.fill()}async renderDoubleBorder(e,t,n,r){if(t<3){await this.renderSolidBorder(e,n,r);return}let i=vu(r,n);this.pathCallbacks.path(i),this.ctx.fillStyle=z(e),this.ctx.fill();let a=yu(r,n);this.pathCallbacks.path(a),this.ctx.fill()}async renderDashedDottedBorder(e,t,n,r,i){this.ctx.save();let a=bu(r,n),o=_u(r,n);i===2&&(this.pathCallbacks.path(o),this.ctx.clip());let s,l,u,d;Y(c(o,0))?(s=c(o,0).start.x,l=c(o,0).start.y):(s=c(o,0).x,l=c(o,0).y),Y(c(o,1))?(u=c(o,1).end.x,d=c(o,1).end.y):(u=c(o,1).x,d=c(o,1).y);let f;f=Math.abs(n===0||n===2?s-u:l-d),this.ctx.beginPath(),i===3?this.pathCallbacks.formatPath(a):this.pathCallbacks.formatPath(o.slice(0,2));let p=t<3?t*3:t*2,m=t<3?t*2:t;i===3&&(p=t,m=t);let h=!0;if(f<=p*2)h=!1;else if(f<=p*2+m){let e=f/(2*p+m);p*=e,m*=e}else{let e=Math.floor((f+m)/(p+m)),t=(f-e*p)/(e-1),n=(f-(e+1)*p)/e;m=n<=0||Math.abs(m-t)<Math.abs(m-n)?t:n}if(h&&(i===3?this.ctx.setLineDash([0,p+m]):this.ctx.setLineDash([p,m])),i===3?(this.ctx.lineCap=`round`,this.ctx.lineWidth=t):this.ctx.lineWidth=t*2+1.1,this.ctx.strokeStyle=z(e),this.ctx.stroke(),this.ctx.setLineDash([]),i===2){if(Y(c(o,0))){let e=c(o,3),t=c(o,0);this.ctx.beginPath(),this.pathCallbacks.formatPath([new J(e.end.x,e.end.y),new J(t.start.x,t.start.y)]),this.ctx.stroke()}if(Y(c(o,1))){let e=c(o,1),t=c(o,2);this.ctx.beginPath(),this.pathCallbacks.formatPath([new J(e.end.x,e.end.y),new J(t.start.x,t.start.y)]),this.ctx.stroke()}}this.ctx.restore()}};let Cu=(e,t,n)=>{let r=e?[e.top,e.right,e.bottom,e.left]:null;return[0,1,2,3].map(e=>{let i=r?r[e]:null,a=t[e]??0;return!i||i.kind===`auto`?a:i.kind===`number`?a*(i.value??1):i.kind===`length`?i.value??0:(i.value??0)/100*(e===0||e===2?n.height:n.width)})},wu=(e,t)=>{let n=e?[e.top,e.right,e.bottom,e.left]:null,r=e=>{let r=n?n[e]:null;return r?r.kind===`number`?(t[e]??0)*(r.value??0):r.value??0:0};return{top:r(0),right:r(1),bottom:r(2),left:r(3)}};var Tu=class{ctx;constructor(e){this.ctx=e}renderBorderImage(e,t,n,r,i,a,o,s,c={top:0,right:0,bottom:0,left:0}){e=e.add(-c.left,-c.top,c.left+c.right,c.top+c.bottom);let l=t.naturalWidth||t.width,u=t.naturalHeight||t.height;if(l<=0||u<=0)return;let d=Math.min(n.unit===`percent`?n.top/100*u:Math.min(n.top,u),u),f=Math.min(n.unit===`percent`?n.right/100*l:Math.min(n.right,l),l),p=Math.min(n.unit===`percent`?n.bottom/100*u:Math.min(n.bottom,u),u),m=Math.min(n.unit===`percent`?n.left/100*l:Math.min(n.left,l),l),{left:h,top:g,width:_,height:v}=e;if(_<=0||v<=0)return;let y=Math.min(i,v),b=Math.min(a,_),x=Math.min(o,v-y),S=Math.min(s,_-b);this.drawRegion(t,0,0,m,d,h,g,S,y),this.drawRegion(t,l-f,0,f,d,h+_-b,g,b,y),this.drawRegion(t,l-f,u-p,f,p,h+_-b,g+v-x,b,x),this.drawRegion(t,0,u-p,m,p,h,g+v-x,S,x);let C=[{sx:m,sy:0,sw:l-m-f,sh:d,dx:h+S,dy:g,dw:_-S-b,dh:y,repeat:r.horizontal,horizontal:!0},{sx:l-f,sy:d,sw:f,sh:u-d-p,dx:h+_-b,dy:g+y,dw:b,dh:v-y-x,repeat:r.vertical,horizontal:!1},{sx:m,sy:u-p,sw:l-m-f,sh:p,dx:h+S,dy:g+v-x,dw:_-S-b,dh:x,repeat:r.horizontal,horizontal:!0},{sx:0,sy:d,sw:m,sh:u-d-p,dx:h,dy:g+y,dw:S,dh:v-y-x,repeat:r.vertical,horizontal:!1}];for(let e of C)e.sw<=0||e.sh<=0||e.dw<=0||e.dh<=0||(e.repeat===0?this.ctx.drawImage(t,e.sx,e.sy,e.sw,e.sh,e.dx,e.dy,e.dw,e.dh):(e.repeat===1||e.repeat===2)&&this.drawRepeatedEdge(t,e,e.horizontal,e.repeat===2));n.fill&&this.drawCenterRegion(t,{sx:m,sy:d,sw:l-m-f,sh:u-d-p},{dx:h+S,dy:g+y,dw:_-S-b,dh:v-y-x},r)}drawRegion(e,t,n,r,i,a,o,s,c){r>0&&i>0&&s>0&&c>0&&this.ctx.drawImage(e,t,n,r,i,a,o,s,c)}drawRepeatedEdge(e,t,n,r){let i=n?t.sw:t.sh,a=n?t.dw:t.dh;if(i<=0||a<=0)return;let o,s;r?(s=Math.max(1,Math.round(a/i)),o=a/s):(o=i,s=Math.ceil(a/o)),this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(t.dx,t.dy,t.dw,t.dh),this.ctx.clip();for(let r=0;r<s;r++){let i=r*o;n?this.ctx.drawImage(e,t.sx,t.sy,t.sw,t.sh,t.dx+i,t.dy,o,t.dh):this.ctx.drawImage(e,t.sx,t.sy,t.sw,t.sh,t.dx,t.dy+i,t.dw,o)}this.ctx.restore()}drawCenterRegion(e,t,n,r){if(t.sw<=0||t.sh<=0||n.dw<=0||n.dh<=0)return;let i=(e,t,n)=>{if(e===0)return{size:n,count:1};if(e===2){let e=Math.max(1,Math.round(n/t));return{size:n/e,count:e}}return{size:t,count:Math.max(1,Math.ceil(n/t))}},a=i(r.horizontal,t.sw,n.dw),o=i(r.vertical,t.sh,n.dh);this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(n.dx,n.dy,n.dw,n.dh),this.ctx.clip();for(let r=0;r<o.count;r++)for(let i=0;i<a.count;i++)this.ctx.drawImage(e,t.sx,t.sy,t.sw,t.sh,n.dx+i*a.size,n.dy+r*o.size,a.size,o.size);this.ctx.restore()}};let Eu=/blur\((\d+(?:\.\d+)?)px\)/gi,Du=(e,t)=>t===1?e:e.replace(Eu,(e,n)=>`blur(${parseFloat(n)*t}px)`);var Ou=class{ctx;pathCallback;scale;activeEffects=[];didSave=!1;saveAtDepth=-1;constructor(e,t){this.ctx=e.ctx,this.pathCallback=t,this.scale=e.scale??1}applyEffects(e){for(;this.activeEffects.length;)this.popEffect();this.didSave=!1,this.saveAtDepth=-1;let t=e=>Gc(e)||Kc(e)||Jc(e),n=e.reduceRight((e,n,r)=>e===-1?t(n)?r:-1:e,-1);for(let r=0;r<e.length;r++){let i=c(e,r);t(i)&&(this.didSave||=(this.ctx.save(),!0),r===n&&(this.saveAtDepth=this.activeEffects.length)),this.applyEffect(i)}}applyEffect(e){Gc(e)?(this.ctx.translate(e.offsetX,e.offsetY),this.ctx.transform(e.matrix[0],e.matrix[1],e.matrix[2],e.matrix[3],e.matrix[4],e.matrix[5]),this.ctx.translate(-e.offsetX,-e.offsetY)):Kc(e)?(this.pathCallback.path(e.path),this.ctx.clip()):Jc(e)?e.applyClip(this.ctx):qc(e)?this.ctx.globalAlpha*=e.opacity:Yc(e)?this.ctx.globalCompositeOperation=e.compositeOperation:Xc(e)&&(this.ctx.filter=Du(e.safeFilterString,this.scale)||`none`,e.shadow&&(this.ctx.shadowOffsetX=e.shadow.offsetX*this.scale,this.ctx.shadowOffsetY=e.shadow.offsetY*this.scale,this.ctx.shadowBlur=e.shadow.blur*this.scale,this.ctx.shadowColor=e.shadow.color)),this.activeEffects.push(e)}popEffect(){this.activeEffects.length!==0&&(this.didSave&&this.activeEffects.length-1===this.saveAtDepth&&(this.ctx.restore(),this.didSave=!1,this.saveAtDepth=-1),this.activeEffects.pop(),!this.didSave&&this.activeEffects.length===0&&(this.ctx.globalAlpha=1,this.ctx.globalCompositeOperation=`source-over`,this.ctx.filter=`none`,this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0,this.ctx.shadowColor=`rgba(0, 0, 0, 0)`))}getActiveEffectCount(){return this.activeEffects.length}hasActiveEffects(){return this.activeEffects.length>0}};let ku=(e,t)=>e.length===0?void 0:e[t%e.length]??e[0],Au=(e,t,n,r)=>{let i=e?e[0]:void 0,a=e&&e.length>1?c(e,1):void 0,o=e=>e!==void 0&&D(e)?e.value:null,s=(e,t,n)=>e===void 0||D(e)?null:M(e)?I(e,t):n,l=o(i);if(l===`contain`||l===`cover`){let e=l===`contain`?Math.min(t.width/n,t.height/r):Math.max(t.width/n,t.height/r);return{width:n*e,height:r*e}}let u=s(i,t.width,n),d=s(a,t.height,r);return u===null&&d===null?(u=n,d=r):u===null?u=n/r*d:d===null&&(d=r/n*u),{width:u,height:d}},ju=(e,t,n,r,i)=>{let a=t.naturalWidth||t.width||i.width,o=t.naturalHeight||t.height||i.height,{width:s,height:l}=Au(ku(n.maskSize,r),i,a,o),u=ku(n.maskPosition,r)??[],d=i.left+I(c(u,0),i.width-s),f=i.top+I(c(u,u.length-1),i.height-l),p=ku(n.maskRepeat,r)??0,m=p===0||p===2,h=p===0||p===3,g=m?Math.ceil((d-i.left)/s):0,_=h?Math.ceil((f-i.top)/l):0,v=m?Math.ceil((i.left+i.width-d)/s):0,y=h?Math.ceil((i.top+i.height-f)/l):0;for(let n=-_;n<=y;n++)for(let r=-g;r<=v;r++)e.drawImage(t,d+r*s,f+n*l,s,l)},Mu=(e,t,n)=>{let{width:r,height:i}=n,a=t.position.length===0?[P]:t.position,o=I(c(a,0),r),s=I(c(a,a.length-1),i),[l,u]=Ir(t,o,s,r,i);l=Math.max(l,.01),u=Math.max(u,.01);let d=e.canvas.ownerDocument??document,f=cl(d,l,u,t.stops,ai(t));f&&(e.fillStyle=f.lastColor,e.fillRect(n.left,n.top,n.width,n.height),e.drawImage(f.canvas,n.left+o-l,n.top+s-u,l*2,u*2),Q(f.canvas))},Nu=(e,t,n)=>{let{width:r,height:i}=n;if(r<=0||i<=0)return;if(ri(t)||ai(t)){Mu(e,t,n);return}let a=null;if(t.type===1||t.type===3){let o=t,[s,l,u,d,f]=Pr(o.angle||0,r,i),p=W(o.stops,s||1);if(t.type===3){let t=ol(p);if(!t){e.fillStyle=z(c(p,p.length-1).color),e.fillRect(n.left,n.top,r,i);return}a=e.createLinearGradient(n.left+l,n.top+d,n.left+u,n.top+f),t.forEach(e=>a.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color))}else a=e.createLinearGradient(n.left+l,n.top+d,n.left+u,n.top+f),sl(p).forEach(e=>a.addColorStop(e.stop,e.color))}else if(t.type===5||t.type===6){let o=t,s=W(o.stops,1),l=t.type===6;if(l&&!ol(s)){e.fillStyle=z(c(s,s.length-1).color),e.fillRect(n.left,n.top,r,i);return}a=e.createConicGradient(o.angle-Math.PI/2,n.left+r/2,n.top+i/2),((l?ol(s):null)??sl(s)).forEach(e=>a.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color))}a&&(e.fillStyle=a,e.fillRect(n.left,n.top,r,i))},Pu=async(e,t,n,r,i)=>{for(let a=0;a<t.length;a++){let o=c(t,a);if(o.type===0){let t=await i(o.url);t&&ju(e,t,n,a,r)}else Nu(e,o,r)}},Fu=(e,t,n,r,i)=>{let a=0,o=0,s=e,c=t,l=n.left,u=n.top,d=n.width,f=n.height,p=d/f,m=s/c,h=i?I(i[0],1):.5,g=i?I(i[1],1):.5;if(r===2)m>p?(f=d/m,u+=(n.height-f)*g):(d=f*m,l+=(n.width-d)*h);else if(r===4)m>p?(s=c*p,a+=(e-s)*h):(c=s/p,o+=(t-c)*g);else if(r===8)s>d?(a+=(s-d)*h,s=d):(l+=(d-s)*h,d=s),c>f?(o+=(c-f)*g,c=f):(u+=(f-c)*g,f=c);else if(r===16){let e=m>p?d:f*m,t=m>p?d/m:f,r=Math.min(s,d),i=Math.min(c,f);e*t<r*i?m>p?(f=d/m,u+=(n.height-f)*g):(d=f*m,l+=(n.width-d)*h):(s>d?(a+=(s-d)*h,s=d):(l+=(d-s)*h,d=s),c>f?(o+=(c-f)*g,c=f):(u+=(f-c)*g,f=c))}return{sx:a,sy:o,sw:s,sh:c,dx:l,dy:u,dw:d,dh:f}};async function Iu(e,t,n,r,i,a,o,s){if(i instanceof sc)try{let n=await t.cache.match(i.src),r=e.imageSmoothingEnabled;o.imageRendering===2||o.imageRendering===1?e.imageSmoothingEnabled=!1:o.imageRendering===3&&(e.imageSmoothingEnabled=!0),s(i,a,n),e.imageSmoothingEnabled=r}catch{t.logger.error(`Error loading image ${i.src}`)}if(i instanceof cc&&s(i,a,i.canvas),i instanceof dc)try{s(i,a,await t.cache.match(i.svg))}catch{t.logger.error(`Error loading svg ${i.svg.substring(0,255)}`)}if(i instanceof Sc&&i.tree){let a=await r(t,{scale:n.scale,backgroundColor:i.backgroundColor,x:0,y:0,width:i.width,height:i.height}).render(i.tree);i.width&&i.height&&e.drawImage(a,0,0,i.width,i.height,i.bounds.left,i.bounds.top,i.bounds.width,i.bounds.height)}}function Lu(e,t,n,r,i){if(r instanceof yc){let t=Math.min(r.bounds.width,r.bounds.height);r.type===`checkbox`&&r.checked?(e.save(),n([new J(r.bounds.left+t*.39363,r.bounds.top+t*.79),new J(r.bounds.left+t*.16,r.bounds.top+t*.5549),new J(r.bounds.left+t*.27347,r.bounds.top+t*.44071),new J(r.bounds.left+t*.39694,r.bounds.top+t*.5649),new J(r.bounds.left+t*.72983,r.bounds.top+t*.23),new J(r.bounds.left+t*.84,r.bounds.top+t*.34085),new J(r.bounds.left+t*.39363,r.bounds.top+t*.79)]),e.fillStyle=z(r.styles.accentColor??7733247),e.fill(),e.restore()):r.type===`radio`&&r.checked&&(e.save(),e.beginPath(),e.arc(r.bounds.left+t/2,r.bounds.top+t/2,t/4,0,Math.PI*2,!0),e.fillStyle=z(r.styles.accentColor??7733247),e.fill(),e.restore())}if(Vu(r)&&r.value.length){let[o]=t.createFontStyle(i);e.font=o??``;let s=I(i.fontSize,0),{baseline:c,height:l}=ou(e,s);e.fillStyle=r instanceof yc&&r.isPlaceholder?z(1970632191):z(i.color),e.textBaseline=`alphabetic`,e.textAlign=Hu(r.styles.textAlign);let u=ul(r),d=r instanceof yc?Ru(u,ll(r),l):u,f=0;switch(r.styles.textAlign){case 1:f+=u.width/2;break;case 2:f+=u.width}let p=0;r instanceof yc&&(p=(u.height-l)/2);let m=u.add(f,p,0,0);e.save(),n([new J(d.left,d.top),new J(d.left+d.width,d.top),new J(d.left+d.width,d.top+d.height),new J(d.left,d.top+d.height)]),e.clip();let h=zu(e,r.value,u.width,i.whiteSpace===`pre`||i.whiteSpace===`nowrap`),g=na(i.lineHeight,s);h.forEach((n,r)=>{let o=m.left,s=e.measureText(n).width;switch(i.textAlign){case 1:o+=(u.width-s)/2;break;case 2:o+=u.width-s}let l=new a(o,m.top+r*g,0,0);t.renderTextWithLetterSpacing(new Js(n,l),i.letterSpacing,c,i.writingMode)}),e.restore(),e.textBaseline=`alphabetic`,e.textAlign=`left`}}let Ru=(e,t,n)=>e.height<n?new a(e.left,t.top,e.width,t.height):e,zu=(e,t,n,r)=>{let i=[],a=t.split(`
|
|
12
|
+
`);for(let t of a){if(r){i.push(t);continue}let a=t.split(/(\s+)/),o=``;for(let t of a){let r=o+t;e.measureText(r).width<=n||o===``?o=r:(i.push(o),o=t)}i.push(o)}return i};async function Bu(e,t,n,r,i,o){if(H(i.styles.display,2048)){if(i.styles.listStyleImage!==null){let n=i.styles.listStyleImage;if(n.type===0){let r=n.url;try{let n=await t.cache.match(r),a=I(o.fontSize,0),s=n?.naturalWidth||n.width,c=n?.naturalHeight||n.height;if(s<=0||c<=0)return;let l=Math.min(a/s,a/c),u=s*l,d=c*l,f=i.bounds.top+I(i.styles.paddingTop,i.bounds.width)+na(o.lineHeight,o.fontSize.number)/2;e.drawImage(n,i.bounds.left-(u+10),f-d/2,u,d)}catch{t.logger.error(`Error loading list-style-image ${r}`)}}}else if(r.listValue&&i.styles.listStyleType!==-1){let t=i.styles.listStyleType;if(t===0||t===1||t===2){let n=o.fontSize.number*.45,r=i.bounds.left-n*.9,a=i.bounds.top+I(i.styles.paddingTop,i.bounds.width)+na(o.lineHeight,o.fontSize.number)/2;e.save(),e.fillStyle=z(o.color),e.beginPath(),t===2?e.rect(r-n/2,a-n/2,n,n):(e.arc(r,a,n/2,0,Math.PI*2),t===1&&(e.strokeStyle=z(o.color),e.lineWidth=n*.18)),t===1?e.stroke():e.fill(),e.restore()}else{let[t]=n.createFontStyle(o);e.font=t??``,e.fillStyle=z(o.color),e.textBaseline=`middle`,e.textAlign=`right`;let s=new a(i.bounds.left,i.bounds.top+I(i.styles.paddingTop,i.bounds.width),i.bounds.width,na(o.lineHeight,o.fontSize.number)/2+1);n.renderTextWithLetterSpacing(new Js(r.listValue,s),o.letterSpacing,na(o.lineHeight,o.fontSize.number)/2+2,o.writingMode),e.textBaseline=`bottom`,e.textAlign=`left`}}}}let Vu=e=>e instanceof xc||e instanceof bc||e instanceof yc&&e.type!==`radio`&&e.type!==`checkbox`,Hu=e=>{switch(e){case 1:return`center`;case 2:return`right`;default:return`left`}},Uu=(e,t)=>{let n=t>e?t*(1+(e/t-1)**3):t;return Math.max(0,e+n)},Wu=(e,t)=>{if(t===0)return e;let n=e.map((e,t)=>Y(e)?{x:t%2==0?e.start.x:e.end.x,y:t%2==0?e.end.y:e.start.y,rx:Math.abs(e.end.x-e.start.x),ry:Math.abs(e.end.y-e.start.y)}:{x:e.x,y:e.y,rx:0,ry:0}),r=c(n,1).x-c(n,0).x+2*t,i=c(n,3).y-c(n,0).y+2*t;if(r<=0||i<=0)return[];let a=n.map(e=>({x:Uu(e.rx,t),y:Uu(e.ry,t)})),o=(e,t)=>t>0?e/t:1,s=Math.min(1,o(r,c(a,0).x+c(a,1).x),o(r,c(a,3).x+c(a,2).x),o(i,c(a,0).y+c(a,3).y),o(i,c(a,1).y+c(a,2).y));return e.map((e,r)=>{let i=c(n,r),o=i.x+(r===1||r===2?t:-t),l=i.y+(r>=2?t:-t);if(!Y(e))return new J(o,l);let u=c(a,r).x*s,d=c(a,r).y*s;if(!u||!d)return new J(o,l);let f=u/i.rx,p=d/i.ry,m=e=>new J(o+(e.x-i.x)*f,l+(e.y-i.y)*p);return new Nc(m(e.start),m(e.startControl),m(e.endControl),m(e.end))})},Gu=(e,t,n)=>{let{a:r,b:i,c:o,d:s,e:c,f:l}=e;if(![r,i,o,s,c,l,t,n].every(Number.isFinite))return null;let u=r*s-i*o;if(!Number.isFinite(u)||u===0)return null;let d=(e,t)=>({x:(s*(e-c)-o*(t-l))/u,y:(-i*(e-c)+r*(t-l))/u}),f=[d(0,0),d(t,0),d(t,n),d(0,n)];if(!f.every(e=>Number.isFinite(e.x)&&Number.isFinite(e.y)))return null;let p=Math.min(...f.map(e=>e.x)),m=Math.min(...f.map(e=>e.y)),h=Math.max(...f.map(e=>e.x)),g=Math.max(...f.map(e=>e.y)),_=r*r+i*i,v=o*o+s*s,y=r*o+i*s,b=Math.sqrt((_+v+Math.hypot(_-v,2*y))/2);if(!Number.isFinite(b)||b<=0)return null;let x=1e-10*Math.max(_,v);return{matrix:e,viewport:new a(p,m,h-p,g-m),scale:b,uniform:Math.abs(_-v)<=x&&Math.abs(y)<=x}},Ku=(e,t,n)=>{e.beginPath(),e.rect(t.left,t.top,t.width,t.height),n.length&&(pu(e,n),e.closePath())},qu=(e,t)=>{let n=t.spread.number,r=ll(e.container);return r.width-2*n<=0||r.height-2*n<=0?[]:Wu(Lc(e.curves),-n)},Ju=async(e,t,n,r,i,a)=>{let o=ll(t.container),s=n.blur.number/2,c=Math.ceil(3*s)+2,l=n.spread.number,u=Xl((n.inset?o:t.container.bounds.add(n.offsetX.number-l,n.offsetY.number-l,2*l,2*l)).add(-c,-c,2*c,2*c),a.viewport,c,a.scale);if(!u.width||!u.height)return!0;let d=Math.ceil(u.width*a.scale),f=Math.ceil(u.height*a.scale),p=Kl(i,d,f);if(!p)return!1;let m,h;try{m=e.canvas.ownerDocument.createElement(`canvas`),m.width=d,m.height=f;let i=m.getContext(`2d`);if(!i)return!1;i.scale(a.scale,a.scale),i.translate(-u.left,-u.top);let o=n.inset?qu(t,n):Wu(Fc(t.curves),l),c=jc(o,n.offsetX.number,n.offsetY.number,0,0);n.inset?Ku(i,u,c):mu(i,c),i.fillStyle=z(n.color),i.fill(n.inset?`evenodd`:`nonzero`),h=await Rl(m,{functions:[{kind:`blur`,value:s}]},1,a.scale,r.signal),e.save();try{n.inset?(mu(e,Lc(t.curves)),e.clip()):(Ku(e,a.viewport,Fc(t.curves)),e.clip(`evenodd`)),e.drawImage(h,u.left,u.top,h.width/a.scale,h.height/a.scale)}finally{e.restore()}return!0}catch(e){if(!(e instanceof Z))throw e;return!1}finally{h&&h!==m&&Q(h),m&&Q(m),i.pixels-=p}},Yu=async(e,t,n,r,i)=>{if(r.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);if(R(n.color))return;let a=n.spread.number;if(!n.inset&&(t.container.bounds.width+2*a<=0||t.container.bounds.height+2*a<=0))return;let o=typeof e.getTransform==`function`,s=o?e.getTransform():{a:r.scale,b:0,c:0,d:r.scale,e:-r.x*r.scale,f:-r.y*r.scale},c=Gu(s,e.canvas.width,e.canvas.height);if(!c)return;let{viewport:l}=c;if(n.blur.number>0&&(n.inset||!c.uniform)&&await Ju(e,t,n,r,i,c))return;let u=ll(t.container);e.save();try{if(n.inset&&n.blur.number===0){mu(e,Lc(t.curves)),e.clip(),Ku(e,u,jc(qu(t,n),n.offsetX.number,n.offsetY.number,0,0)),e.fillStyle=z(n.color),e.fill(`evenodd`);return}let r=Math.ceil(n.blur.number*2+Math.abs(a)+Math.abs(n.offsetX.number)+Math.abs(n.offsetY.number))+2,i=n.inset?u.add(-r,-r,2*r,2*r):t.container.bounds.add(-a,-a,2*a,2*a),{a:d,b:f,c:p,d:m,e:h,f:g}=s,_=i.left+i.width,v=i.top+i.height,y=Math.max(d*i.left+p*i.top+h,d*_+p*i.top+h,d*_+p*v+h,d*i.left+p*v+h),b=Math.max(1e4,y+r*c.scale+2);n.inset?(mu(e,Lc(t.curves)),e.clip()):(Ku(e,l,Fc(t.curves)),e.clip(`evenodd`)),o?e.setTransform(d,f,p,m,h-b,g):e.translate(-b/d,0),n.inset?Ku(e,i,qu(t,n)):mu(e,Wu(Fc(t.curves),a)),o?e.setTransform(d,f,p,m,h,g):e.translate(b/d,0),e.shadowOffsetX=b+d*n.offsetX.number+p*n.offsetY.number,e.shadowOffsetY=f*n.offsetX.number+m*n.offsetY.number,e.shadowBlur=n.blur.number*c.scale,e.shadowColor=z(n.color),e.fillStyle=`rgb(0, 0, 0)`,e.fill(n.inset?`evenodd`:`nonzero`)}finally{e.restore()}};var Xu=class{ctx;context;scale;createFontStyle;constructor(e){this.ctx=e.ctx,this.context=e.context,this.scale=e.scale,this.createFontStyle=e.createFontStyle}async render(e){let t=e.container,n=t.styles,r=t.bounds,i=this.scale;if(r.width<=0||r.height<=0)return;let a=this.ctx.canvas.ownerDocument??document,o=Math.ceil(r.width),s=Math.ceil(r.height),c=Math.ceil(r.width*i),l=Math.ceil(r.height*i),u=this.createLayer(a,c,l);if(!u)return;let d=null,f=null,p=null;try{u.ctx.scale(i,i);let[m]=this.createFontStyle(n);u.ctx.font=m??``,u.ctx.textBaseline=`alphabetic`,u.ctx.textAlign=`left`,u.ctx.direction=n.direction===1?`rtl`:`ltr`;let h=su(u.ctx,n.fontSize.number),g=new gu({ctx:u.ctx,context:this.context,canvas:u.canvas,options:{width:o,height:s,scale:1}});R(n.backgroundColor)||(u.ctx.fillStyle=z(n.backgroundColor),u.ctx.fillRect(0,0,o,s)),u.ctx.save(),u.ctx.translate(-r.left,-r.top),await g.renderBackgroundImage(t),u.ctx.restore();let _={bounds:r,baseline:h,letterSpacing:n.letterSpacing,writingMode:n.writingMode};if(d=this.createGlyphLayer(a,c,l,u.ctx),!d)return;let v=!!n.webkitTextStrokeWidth;v&&(d.ctx.strokeStyle=z(n.webkitTextStrokeColor),d.ctx.lineWidth=n.webkitTextStrokeWidth,d.ctx.lineJoin=du());for(let e of t.textNodes)for(let t of e.textBounds)this.drawGlyphs(d,t,_,(e,t,n,r)=>{e.fillText(t,n,r),v&&e.strokeText(t,n,r)});if(u.ctx.globalCompositeOperation=`destination-in`,u.ctx.drawImage(d.canvas,0,0,o,s),p=this.renderShadowSilhouettes(e,a,c,l,u.ctx,n,_),p){if(f=this.createLayer(a,c,l),!f)return;for(let e of p)f.ctx.drawImage(e,0,0);f.ctx.drawImage(u.canvas,0,0),this.ctx.drawImage(f.canvas,r.left,r.top,r.width,r.height)}else this.ctx.drawImage(u.canvas,r.left,r.top,r.width,r.height)}finally{Q(u.canvas),d&&Q(d.canvas),f&&Q(f.canvas),p&&p.forEach(Q)}}createLayer(e,t,n){let r=e.createElement(`canvas`);r.width=t,r.height=n;let i=r.getContext(`2d`);return i?{canvas:r,ctx:i}:null}createGlyphLayer(e,t,n,r){let i=this.createLayer(e,t,n);return i?(i.ctx.scale(this.scale,this.scale),i.ctx.font=r.font,i.ctx.textBaseline=r.textBaseline,i.ctx.textAlign=r.textAlign,i.ctx.direction=r.direction,i.ctx.fillStyle=`#000`,i):null}drawGlyphs(e,t,n,r){let i=t.bounds.left-n.bounds.left,a=t.bounds.top-n.bounds.top+n.baseline,{letterSpacing:o,writingMode:s}=n;if(o<=0||ka(s)){r(e.ctx,t.text,i,a);return}let c=i;for(let n of ec(t.text))r(e.ctx,n,c,a),c+=e.ctx.measureText(n).width+o}renderShadowSilhouettes(e,t,n,r,i,a,o){let s=a.textShadow;if(!s.length)return null;let l=[];for(let a=s.length-1;a>=0;a--){let u=c(s,a),d=this.createGlyphLayer(t,n,r,i);if(d){d.ctx.shadowColor=z(u.color),d.ctx.shadowOffsetX=u.offsetX.number*this.scale,d.ctx.shadowOffsetY=u.offsetY.number*this.scale,d.ctx.shadowBlur=u.blur.number*this.scale,d.ctx.fillStyle=z(u.color);for(let t of e.container.textNodes)for(let e of t.textBounds)this.drawGlyphs(d,e,o,(e,t,n,r)=>{e.fillText(t,n,r)});l.push(d.canvas)}}return l.length?l:null}},Zu=class e{surfaceRoot;surfaceBudget;canvas;ctx;context;options;backgroundRenderer;borderRenderer;borderImageRenderer;effectsRenderer;textRenderer;textClipRenderer;legacySubtree=!1;constructor(e,t,n,r={pixels:0}){this.surfaceRoot=n,this.surfaceBudget=r,this.context=e,this.options=t,this.canvas=t.canvas?t.canvas:e.resourceDocument.createElement(`canvas`);let i=this.canvas.getContext(`2d`);if(!i)throw t.canvas||Q(this.canvas),n?new Z(`Filter surface canvas is unavailable`):Error(`Failed to get 2D rendering context from canvas`);this.ctx=i,t.canvas||(this.canvas.width=Math.floor(t.width*t.scale),this.canvas.height=Math.floor(t.height*t.scale),this.canvas.style.width=`${t.width}px`,this.canvas.style.height=`${t.height}px`),this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-t.x,-t.y),this.ctx.textBaseline=`bottom`,t.imageSmoothing!==void 0&&(this.ctx.imageSmoothingEnabled=t.imageSmoothing),t.imageSmoothingQuality&&(this.ctx.imageSmoothingQuality=t.imageSmoothingQuality),this.backgroundRenderer=new gu({ctx:this.ctx,context:this.context,canvas:this.canvas,options:{width:t.width,height:t.height,scale:t.scale}}),this.borderRenderer=new Su({ctx:this.ctx},{path:e=>this.path(e),formatPath:e=>this.formatPath(e)}),this.borderImageRenderer=new Tu(this.ctx),this.effectsRenderer=new Ou({ctx:this.ctx,scale:t.scale},{path:e=>this.path(e)}),this.textRenderer=new fu({ctx:this.ctx,options:{scale:t.scale}}),this.textClipRenderer=new Xu({ctx:this.ctx,context:this.context,scale:t.scale,createFontStyle:e=>this.textRenderer.createFontStyle(e)}),this.context.logger.debug(`Canvas renderer initialized (${t.width}x${t.height}) with scale ${t.scale}`)}async renderStack(e){let t=e.element.container.styles;if(t.isVisible()){let n=Sl(t.filter),r=n!==null&&n.functions.length>0,i=t.maskImage.length>0,a=t.webkitBoxReflect,o=t.mixBlendMode!==K.NORMAL,s=a&&!Ql(this.ancestorTransform(e.element));if(s&&this.context.logger.warn(`-webkit-box-reflect under an ancestor transform is not supported; the reflection is skipped for this subtree`),e.element!==this.surfaceRoot&&!this.legacySubtree&&!s&&(i||a||o||n!==null&&(r||t.opacity<1))&&this.canComposite(e.element)){if(!await this.renderCompositedStack(e,n,i,a,o)){this.legacySubtree=!0;try{await this.renderStackContent(e)}finally{this.legacySubtree=!1}}return}await this.renderStackContent(e)}}canComposite(e){let t=e=>{let t=e.styles;return t.clipPath.type===0&&!H(t.display,2048)&&Sl(t.filter)!==null},n=e=>t(e)&&e.elements.every(n),r=e.parent;for(;r&&r!==this.surfaceRoot;){if(!t(r.container))return!1;r=r.parent}return n(e.container)}ancestorTransform(e){let t=[],n=e;for(;n&&n!==this.surfaceRoot;){for(let e of n.effects)Gc(e)&&t.push(e);n=n.parent}if(t.length===0)return Zl;let r=Zl;for(let e=t.length-1;e>=0;e--){let n=c(t,e),i=$l($l([1,0,0,1,n.offsetX,n.offsetY],n.matrix),[1,0,0,1,-n.offsetX,-n.offsetY]);r=$l(r,i)}return r}async renderCompositedStack(t,n,r,i,o=!1){let s=this.options.signal;if(s?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let c=t.element.container,l=this.ancestorTransform(t.element),u=t.element.effects.filter(Gc),d=l;for(let e of u)d=$l(d,$l($l([1,0,0,1,e.offsetX,e.offsetY],e.matrix),[1,0,0,1,-e.offsetX,-e.offsetY]));let f=Yl(c),p=Xl(Ql(d)?f:tu(d,f),new a(this.options.x,this.options.y,this.options.width,this.options.height),n?jl(n,c.filterReferences):0,this.options.scale);if(!p.width||!p.height)return!0;let m=Kl(this.surfaceBudget,Math.ceil(p.width*this.options.scale),Math.ceil(p.height*this.options.scale));if(!m)return this.context.logger.warn(`Filter surface budget exceeded; mask/filter/blend effects are dropped for this subtree`),!1;let h=Ql(l)||!r?p:ru(l,p)??p,g={...this.options,canvas:void 0,backgroundColor:null,x:h.left,y:h.top,width:h.width,height:h.height},_,v;try{_=new e(this.context,g,t.element,this.surfaceBudget),await _.renderStackContent(t),_.effectsRenderer.applyEffects([]),n&&(v=await Rl(_.canvas,n,c.styles.opacity,g.scale,s,{references:c.filterReferences,origin:{x:c.bounds.left-h.left,y:c.bounds.top-h.top}}));let a=v??_.canvas;if(r&&await this.applyMask(a,t.element.container.styles,h,c.bounds,u),s?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let l=t.element.effects,d=t.element.getEffects(4,this.surfaceRoot).filter(e=>!l.includes(e)||!Xc(e)&&!qc(e)&&!Yc(e)&&!Kc(e)&&!Gc(e));return this.effectsRenderer.applyEffects(d),o?(this.ctx.save(),this.ctx.globalCompositeOperation=t.element.container.styles.mixBlendMode,this.ctx.drawImage(a,g.x,g.y,a.width/g.scale,a.height/g.scale),this.ctx.restore()):this.ctx.drawImage(a,g.x,g.y,a.width/g.scale,a.height/g.scale),i&&await this.drawReflection(a,t.element.container.bounds,p,i),!0}catch(e){if(!(e instanceof Z))throw e;return this.context.logger.info(`${e.message}; using the existing renderer`),!1}finally{_&&Q(_.canvas),v&&Q(v),this.surfaceBudget.pixels-=m}}async applyMask(e,t,n,r,i){let a=e.getContext(`2d`);if(!a)return;let o=this.context.resourceDocument.createElement(`canvas`);o.width=e.width,o.height=e.height;let s=o.getContext(`2d`);if(!s){Q(o);return}s.scale(this.options.scale,this.options.scale),s.translate(-n.left,-n.top);for(let e=i.length-1;e>=0;e--){let t=c(i,e);s.translate(t.offsetX,t.offsetY),s.transform(...t.matrix),s.translate(-t.offsetX,-t.offsetY)}let l={left:r.left,top:r.top,width:r.width,height:r.height};try{await Pu(s,t.maskImage,t,l,async e=>await this.context.cache.match(e))}catch(e){this.context.logger.error(`Error rendering mask-image: ${e instanceof Error?e.message:e}`),Q(o);return}a.save();try{a.setTransform(1,0,0,1,0,0),a.globalCompositeOperation=`destination-in`,a.drawImage(o,0,0)}finally{a.restore(),Q(o)}}async drawReflection(e,t,n,r){let i=this.options.scale,a=Math.ceil(t.width*i),o=Math.ceil(t.height*i);if(a<=0||o<=0)return;let s=Kl(this.surfaceBudget,a,o);if(!s)return;let c,l;try{c=this.context.resourceDocument.createElement(`canvas`),c.width=a,c.height=o;let s=c.getContext(`2d`);if(!s)return;let u=Math.round((t.left-n.left)*i),d=Math.round((t.top-n.top)*i),f=r.direction===`left`||r.direction===`right`;s.save();try{f?(s.translate(a,0),s.scale(-1,1)):(s.translate(0,o),s.scale(1,-1)),s.drawImage(e,-u,-d)}finally{s.restore()}if(r.mask){l=this.context.resourceDocument.createElement(`canvas`),l.width=a,l.height=o;let e=l.getContext(`2d`);if(e){e.scale(i,i),await Pu(e,[r.mask],{maskPosition:[],maskRepeat:[],maskSize:[]},{left:0,top:0,width:t.width,height:t.height},async e=>await this.context.cache.match(e)),s.save();try{f?(s.translate(a,0),s.scale(-1,1)):(s.translate(0,o),s.scale(1,-1)),s.globalCompositeOperation=`destination-in`,s.drawImage(l,0,0,a,o)}finally{s.restore()}}}let p=r.offset,m=t.left,h=t.top;r.direction===`below`?h=t.top+t.height+p:r.direction===`above`?h=t.top-t.height-p:m=r.direction===`right`?t.left+t.width+p:t.left-t.width-p,this.ctx.save();try{this.ctx.filter=`none`,this.ctx.drawImage(c,m,h,t.width,t.height)}finally{this.ctx.restore()}}finally{c&&Q(c),l&&Q(l),this.surfaceBudget.pixels-=s}}async renderNode(e){e.container.debugRender,e.container.styles.isVisible()&&(await this.renderNodeBackgroundAndBorders(e),await this.renderNodeContent(e))}renderReplacedElement(e,t,n){let r=n.naturalWidth||e.intrinsicWidth,i=n.naturalHeight||e.intrinsicHeight;if(n&&r>0&&i>0){let a=ul(e),o=Lc(t);this.path(o),this.ctx.save(),this.ctx.clip();let{sx:s,sy:c,sw:l,sh:u,dx:d,dy:f,dw:p,dh:m}=Fu(r,i,a,e.styles.objectFit,e.styles.objectPosition);this.ctx.drawImage(n,s,c,l,u,d,f,p,m),this.ctx.restore()}}async renderNodeContent(t){this.effectsRenderer.applyEffects(t.getEffects(4,this.surfaceRoot));let n=t.container,r=t.curves,i=n.styles,a=ul(n);for(let e of n.textNodes)await this.textRenderer.renderTextNode(e,i,a);await Iu(this.ctx,this.context,{scale:this.options.scale,backgroundColor:this.options.backgroundColor,x:this.options.x,y:this.options.y,width:this.options.width,height:this.options.height},(t,n)=>new e(t,n,void 0,this.surfaceBudget),n,r,i,(e,t,n)=>this.renderReplacedElement(e,t,n)),Lu(this.ctx,this.textRenderer,this.path.bind(this),n,i),await Bu(this.ctx,this.context,this.textRenderer,t,n,i)}async renderStackContent(e){e.element.container.debugRender;let t=this.options.signal;await this.renderNodeBackgroundAndBorders(e.element);for(let n of e.negativeZIndex){if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderStack(n)}if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderNodeContent(e.element);for(let t of e.nonInlineLevel)await this.renderNode(t);for(let n of e.nonPositionedFloats){if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderStack(n)}for(let n of e.nonPositionedInlineLevel){if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderStack(n)}for(let t of e.inlineLevel)await this.renderNode(t);for(let n of e.zeroOrAutoZIndexOrTransformedOrOpacity){if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderStack(n)}for(let n of e.positiveZIndex){if(t?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);await this.renderStack(n)}}path(e){mu(this.ctx,e)}formatPath(e){pu(this.ctx,e)}async renderSurfaceBoxShadow(e,t){let n=t.spread.number,r=t.blur.number/2,i=Math.ceil(3*r)+1,o=e.container.bounds.add(-n,-n,2*n,2*n);if(o.width<=0||o.height<=0)return;let s=this.options.scale,c=Xl(o.add(-i,-i,2*i,2*i),new a(this.options.x-t.offsetX.number,this.options.y-t.offsetY.number,this.options.width,this.options.height),i,s);if(!c.width||!c.height)return;let l=Math.ceil(c.width*s),u=Math.ceil(c.height*s),d=Kl(this.surfaceBudget,l,u);if(!d)throw new Z(`Box shadow surface budget exceeded`);let f,p;try{f=this.context.resourceDocument.createElement(`canvas`),f.width=l,f.height=u;let i=f.getContext(`2d`);if(!i)throw new Z(`Box shadow surface canvas is unavailable`);i.scale(s,s),i.translate(-c.left,-c.top),mu(i,jc(Fc(e.curves),-n,-n,2*n,2*n)),i.fillStyle=z(t.color),i.fill(),p=await Rl(f,{functions:[{kind:`blur`,value:r}]},1,s,this.options.signal),this.ctx.save();try{this.ctx.beginPath(),this.ctx.rect(this.options.x,this.options.y,this.options.width,this.options.height),pu(this.ctx,Fc(e.curves)),this.ctx.closePath(),this.ctx.clip(`evenodd`),this.ctx.drawImage(p,c.left+t.offsetX.number,c.top+t.offsetY.number,p.width/s,p.height/s)}finally{this.ctx.restore()}}finally{f&&Q(f),p&&Q(p),this.surfaceBudget.pixels-=d}}async renderNodeBackgroundAndBorders(e){this.effectsRenderer.applyEffects(e.getEffects(2,this.surfaceRoot)),!this.surfaceRoot&&e.container.styles.backdropFilter&&await this.renderBackdropFilter(e);let t=e.container.styles,n=!R(t.backgroundColor)||t.backgroundImage.length,r=$u(t),i=[{style:t.borderTopStyle,color:t.borderTopColor,width:t.borderTopWidth},{style:t.borderRightStyle,color:t.borderRightColor,width:t.borderRightWidth},{style:t.borderBottomStyle,color:t.borderBottomColor,width:t.borderBottomWidth},{style:t.borderLeftStyle,color:t.borderLeftColor,width:t.borderLeftWidth}],a=_l(t.backgroundClip,0),o=Qu(a,e.curves);if(n||t.boxShadow.length){r&&e.container.textNodes.length>0?await this.textClipRenderer.render(e):(this.ctx.save(),this.path(o),this.ctx.clip(),R(t.backgroundColor)||(this.ctx.fillStyle=z(t.backgroundColor),this.ctx.fill()),await this.backgroundRenderer.renderBackgroundImage(e.container),this.ctx.restore());for(let n of t.boxShadow.slice(0).reverse())this.surfaceRoot&&!n.inset?await this.renderSurfaceBoxShadow(e,n):await Yu(this.ctx,e,n,this.options,this.surfaceBudget)}if(t.borderImageSource){let n=t.borderImageSource,r=e.container.bounds,i=[Math.max(0,t.borderTopWidth),Math.max(0,t.borderRightWidth),Math.max(0,t.borderBottomWidth),Math.max(0,t.borderLeftWidth)],a=null;if(n.type===0){let e=n.url;try{a=await this.context.cache.match(e)??null}catch{this.context.logger.error(`Error loading border-image ${e}`)}}else a=this.rasterizeGradientSource(n,r);if(a){let e=wu(t.borderImageOutset,i),n=r.add(-e.left,-e.top,e.left+e.right,e.top+e.bottom),o=Cu(t.borderImageWidth,i,n);this.borderImageRenderer.renderBorderImage(r,a,t.borderImageSlice,t.borderImageRepeat,o[0],o[1],o[2],o[3],e)}return}let s=0;for(let t of i){if(t.style!==0&&!R(t.color)&&t.width>0){let n=async()=>{t.style===2?await this.borderRenderer.renderDashedDottedBorder(t.color,t.width,s,e.curves,2):t.style===3?await this.borderRenderer.renderDashedDottedBorder(t.color,t.width,s,e.curves,3):t.style===4?await this.borderRenderer.renderDoubleBorder(t.color,t.width,s,e.curves):await this.borderRenderer.renderSolidBorder(t.color,s,e.curves)},r=e.container.legendBounds;if(s===0&&r){let t=e.container.bounds,i=r.left-t.left,a=r.left+r.width-t.left;i>0&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(t.left,t.top,i,t.height),this.ctx.clip(),await n(),this.ctx.restore());let o=t.left+a,s=t.width-a;s>0&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(o,t.top,s,t.height),this.ctx.clip(),await n(),this.ctx.restore())}else await n()}s++}this.renderOutline(e)}renderOutline(e){let t=e.container.styles;if(t.outlineStyle===0||t.outlineStyle===1)return;let n=Math.max(0,t.outlineWidth);if(n<=0)return;let r=t.outlineColor??t.color;if(R(r))return;let i=Math.max(0,t.outlineOffset)+n/2,a=jc(Fc(e.curves),-i,-i,2*i,2*i);this.ctx.save();try{this.ctx.strokeStyle=z(r),this.ctx.lineWidth=n,t.outlineStyle===3?this.ctx.setLineDash([n*3,n*3]):t.outlineStyle===4&&this.ctx.setLineDash([n,n*2]),this.path(a),this.ctx.stroke()}finally{this.ctx.restore()}}rasterizeGradientSource(e,t){let n=Math.max(1,Math.ceil(t.width)),r=Math.max(1,Math.ceil(t.height)),i=(this.ctx.canvas.ownerDocument??document).createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return null;if(e.type===1||e.type===3){let t=e,[o,s,l,u,d]=Pr(t.angle,n,r),f=W(t.stops,o||n),p=e.type===3,m=p?ol(f):null,h=a.createLinearGradient(s,l,u,d);if(m)m.forEach(e=>{h.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color)});else if(p){let e=z(c(f,f.length-1).color);h.addColorStop(0,e),h.addColorStop(1,e)}else sl(f).forEach(e=>{h.addColorStop(e.stop,e.color)});return a.fillStyle=h,a.fillRect(0,0,n,r),i}if(e.type===2||e.type===4){let t=e,o=t.position.length===0?[P]:t.position,s=I(c(o,0),n),l=I(c(o,o.length-1),r),[u,d]=Ir(t,s,l,n,r);if(u<=0||d<=0)return null;let f=this.ctx.canvas.ownerDocument??document,p=cl(f,u,d,t.stops,e.type===4);return p?(a.fillStyle=p.lastColor,a.fillRect(0,0,n,r),a.drawImage(p.canvas,s-u,l-d,u*2,d*2),Q(p.canvas),i):null}if(e.type===5||e.type===6){let t=e,o=I(c(t.position,0),n),s=I(c(t.position,1),r),l=a.createConicGradient(t.angle-Math.PI/2,o,s),u;if(e.type===6){let e=W(t.stops,1),n=c(e,0),r=c(e,e.length-1),i=Math.max(r.stop-n.stop,.01);u=[];let a=Math.ceil(1/i);for(let t=0;t<a;t++)for(let r of e){let e=t*i+(r.stop-n.stop);if(e>1)break;u.push({stop:e,color:z(r.color)})}let o=c(u,u.length-1);o&&o.stop<1&&u.push({stop:1,color:o.color})}else u=W(t.stops,Math.max(n,r)).map(e=>({stop:e.stop,color:z(e.color)}));return u.forEach(e=>{l.addColorStop(Math.min(1,Math.max(0,e.stop)),e.color)}),a.fillStyle=l,a.fillRect(0,0,n,r),i}return this.context.logger.warn(`Unsupported border-image source; only URL and gradient images are supported`),null}async renderBackdropFilter(e){let t=Sl(e.container.styles.backdropFilter);if(!t||t.functions.length===0)return;let n=e.container.bounds;if(n.width<=0||n.height<=0)return;let r=this.options.scale,i=Math.ceil(n.width*r),a=Math.ceil(n.height*r);if(i<=0||a<=0)return;let o=Kl(this.surfaceBudget,i,a);if(!o)return;let s,c;try{s=this.context.resourceDocument.createElement(`canvas`),s.width=i,s.height=a;let e=s.getContext(`2d`);if(!e)return;let o=Math.round((n.left-this.options.x)*r),l=Math.round((n.top-this.options.y)*r);e.drawImage(this.canvas,o,l,i,a,0,0,i,a);try{c=await Rl(s,t,1,r,this.options.signal)}catch(e){if(e instanceof Z){this.context.logger.info(`${e.message}; rendering without the backdrop effect`);return}throw e}if(this.options.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);this.ctx.save();try{this.ctx.filter=`none`,this.ctx.drawImage(c,n.left,n.top,n.width,n.height)}finally{this.ctx.restore()}}finally{s&&Q(s),c&&Q(c),this.surfaceBudget.pixels-=o}}async render(e){try{this.options.backgroundColor&&(this.ctx.fillStyle=z(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height));let t=il(e);return await this.renderStack(t),this.effectsRenderer.applyEffects([]),this.canvas}catch(e){throw this.options.canvas||Q(this.canvas),e}}};let Qu=(e,t)=>{switch(e){case 0:return Fc(t);case 2:return Ic(t);default:return Lc(t)}},$u=e=>e.backgroundClip.some(e=>e===3);var ed=class{canvas;ctx;options;context;constructor(e,t){this.context=e,this.options=t,this.canvas=t.canvas?t.canvas:e.resourceDocument.createElement(`canvas`);let n=this.canvas.getContext(`2d`);if(!n)throw Error(`Failed to get 2D rendering context from canvas`);this.ctx=n,this.canvas.width=Math.floor(t.width*t.scale),this.canvas.height=Math.floor(t.height*t.scale),this.canvas.style.width=`${t.width}px`,this.canvas.style.height=`${t.height}px`,this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-t.x,-t.y),this.context.logger.debug(`EXPERIMENTAL ForeignObject renderer initialized (${t.width}x${t.height} at ${t.x},${t.y}) with scale ${t.scale}`)}async render(e){if(this.options.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=nd(e),n=Gs(this.options.width,this.options.height,0,0,e),r=Ks(n);t();try{let e=await r;if(this.options.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);return this.options.backgroundColor&&(this.ctx.fillStyle=z(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),this.ctx.drawImage(e,this.options.x,this.options.y,this.options.width,this.options.height),this.canvas}catch(e){throw this.options.canvas||Q(this.canvas),e}}};let td=[`marginTop`,`marginRight`,`marginBottom`,`marginLeft`,`top`,`right`,`bottom`,`left`],nd=e=>{let t=e.style,n=td.map(e=>[e,t[e]]);for(let e of td)t[e]=e.startsWith(`margin`)?`0px`:`auto`;return()=>{for(let[e,r]of n)t[e]=r}};var rd=class{id;enabled;start;constructor({id:e,enabled:t}){this.id=e,this.enabled=t,this.start=Date.now()}debug(...e){this.enabled&&(typeof window<`u`&&window.console&&typeof console.debug==`function`?console.debug(this.id,`${this.getTime()}ms`,...e):this.info(...e))}getTime(){return Date.now()-this.start}info(...e){this.enabled&&typeof window<`u`&&window.console&&typeof console.info==`function`&&console.info(this.id,`${this.getTime()}ms`,...e)}warn(...e){this.enabled&&(typeof window<`u`&&window.console&&typeof console.warn==`function`?console.warn(this.id,`${this.getTime()}ms`,...e):this.info(...e))}error(...e){this.enabled&&(typeof window<`u`&&window.console&&typeof console.error==`function`?console.error(this.id,`${this.getTime()}ms`,...e):this.info(...e))}},id=class{context;_options;_cache=/* @__PURE__ */ new Map;maxSize;_pendingOperations=/* @__PURE__ */ new Map;_deferMode=!1;_collectedUrls=/* @__PURE__ */ new Set;_evictionSuspendCount=0;get _evictionEnabled(){return this._evictionSuspendCount===0}constructor(e,t){if(this.context=e,this._options=t,this.maxSize=t.maxCacheSize??100,this.maxSize<1)throw Error(`Cache maxSize must be at least 1`);this.maxSize>1e4&&this.context.logger.warn(`Cache maxSize ${this.maxSize} is very large and may cause memory issues. Consider using a smaller value (recommended: 100-1000).`)}startDefer(){this._deferMode=!0,this._evictionSuspendCount++}async preloadAll(e=10,t,n){this._deferMode=!1;let r=Array.from(this._collectedUrls);this._collectedUrls.clear();try{if(r.length===0)return;let i=Math.max(1,Math.min(e,100));this.context.logger.debug(`Preloading ${r.length} image(s) with concurrency ${i}`);let a=0,o=n?new Promise((e,t)=>{let r=()=>t(new DOMException(`The operation was aborted.`,`AbortError`));n.aborted?r():n.addEventListener(`abort`,r,{once:!0})}):null;o?.catch(()=>void 0),t?.(0,r.length);for(let e=0;e<r.length;e+=i){q(n);let s=r.slice(e,e+i);s.map(e=>this._addImageWithPending(e));let c=Promise.allSettled(s.map(e=>this._cache.get(e)?.value??Promise.resolve()));await(o?Promise.race([c,o]):c),a+=s.length,t?.(a,r.length)}}finally{this._evictionSuspendCount=Math.max(0,this._evictionSuspendCount-1)}}addImage(e){if(this._deferMode)return!this.has(e)&&(dd(e)||cd(e))&&this._collectedUrls.add(e),Promise.resolve();let t=this._pendingOperations.get(e);if(t)return t;if(this.has(e)){let t=this._cache.get(e);return this._cache.delete(e),this._cache.set(e,t),Promise.resolve()}return dd(e)||cd(e)?this._addImageWithPending(e):Promise.resolve()}_addImageWithPending(e){let t=this._pendingOperations.get(e);if(t)return t;let n=this._addImageInternal(e);return this._pendingOperations.set(e,n),n.finally(()=>{this._pendingOperations.delete(e)}),n}async _addImageInternal(e){let t=this._options.imageTimeout??15e3,n=this.withTimeout(this.loadImage(e),t,`Timed out (${t}ms) loading image`);n.catch(t=>{let n=t instanceof Error?t.message:String(t),r=`Failed to load image ${e.substring(0,256)}: ${n}`;this.context.logger.error(r),this.context.onError?.(Error(r))}),this.set(e,n)}withTimeout(e,t,n){if(t<=0)return e;let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(n)),t)});return Promise.race([e,i]).finally(()=>{r!==void 0&&clearTimeout(r)})}match(e){let t=this._cache.get(e);if(t)return this._cache.delete(e),this._cache.set(e,t),t.value}set(e,t){if(this._cache.has(e))this._cache.delete(e);else if(this._evictionEnabled&&this._cache.size>=this.maxSize){let e=this._cache.keys().next().value;e!==void 0&&(this._cache.delete(e),this.context.logger.debug(`Cache: Evicted LRU entry: ${e}`))}this._cache.set(e,{value:t})}size(){return this._cache.size}getMaxSize(){return this.maxSize}clear(){this._cache.clear()}async loadImage(e){let t=this.context.originChecker,n=e=>t.isSameOrigin(e),r=typeof this._options.customIsSameOrigin==`function`?await this._options.customIsSameOrigin(e,n):n(e),i=!r&&this._options.allowTaint===!1&&!ld(e)&&!dd(e)&&typeof this._options.proxy!=`string`,a=!ld(e)&&(this._options.useCORS===!0||i)&&qs.SUPPORT_CORS_IMAGES&&!r,o=!ld(e)&&!r&&!dd(e)&&typeof this._options.proxy==`string`&&!a;if(!r&&this._options.allowTaint===!1&&!ld(e)&&!dd(e)&&!o&&!a)return;let s=e;o&&(s=await this.proxy(s)),this.context.logger.debug(`Added image ${e.substring(0,256)}`);let c=this.context.config.window.Image??Image;return await new Promise((e,t)=>{let n=new c;n.onload=()=>e(n),n.onerror=t,(ud(s)||a)&&(n.crossOrigin=`anonymous`),n.src=s,n.complete===!0&&(typeof n.decode==`function`?n.decode().then(()=>e(n),()=>t(/* @__PURE__ */ Error(`Failed to decode image ${s.substring(0,256)}`))):setTimeout(()=>e(n),500))})}has(e){return this._cache.has(e)}keys(){return Promise.resolve(Array.from(this._cache.keys()))}proxy(e){let t=this._options.proxy;if(!t)throw Error(`No proxy defined`);let n=e.substring(0,256);return new Promise((r,i)=>{let a=new XMLHttpRequest;a.onload=()=>{if(a.status===200){let e=new FileReader;e.addEventListener(`load`,()=>r(e.result),!1),e.addEventListener(`error`,e=>i(e),!1),e.readAsDataURL(a.response)}else i(`Failed to proxy resource ${n} with status code ${a.status}`)},a.onerror=i;let o=t.indexOf(`?`)>-1?`&`:`?`;if(a.open(`GET`,`${t}${o}url=${encodeURIComponent(e)}&responseType=blob`),a.responseType=`blob`,this._options.imageTimeout){let e=this._options.imageTimeout;a.timeout=e,a.ontimeout=()=>i(`Timed out (${e}ms) proxying ${n}`)}a.send()})}};let ad=/^data:image\/svg\+xml/i,od=/^data:image\/.*;base64,/i,sd=/^data:image\/.*/i,cd=e=>qs.SUPPORT_SVG_DRAWING||!fd(e),ld=e=>sd.test(e),ud=e=>od.test(e),dd=e=>e.substring(0,4)===`blob`,fd=e=>e.slice(-3).toLowerCase()===`svg`||ad.test(e);var pd=class{baseUri;origin;constructor(e){if(!e||!e.document)throw Error(`Valid window object required for OriginChecker`);if(!e.location||!e.location.href)throw Error(`Window object must have valid location`);this.baseUri=e.location.href,this.origin=this.getOrigin(e.location.href)}getOrigin(e){try{return new URL(e,this.baseUri).origin}catch{return``}}isSameOrigin(e){return this.getOrigin(e)===this.origin}getContextOrigin(){return this.origin}},md=class e{static instanceCount=1;instanceName=`#${e.instanceCount++}`;logger;cache;originChecker;config;onError;_windowBounds;constructor(e,t,n){this.config=n,this.logger=new rd({id:this.instanceName,enabled:e.logging}),this.originChecker=new pd(n.window),this.cache=e.cache??n.cache??new id(this,e),this.onError=e.onError,this._windowBounds=t}get windowBounds(){return this._windowBounds}get resourceDocument(){return this.config.window.document||(typeof document<`u`?document:void 0)}adjustWindowBounds(e,t){this._windowBounds=this._windowBounds.add(e,t,0,0)}};let hd=e=>{[`scale`,`width`,`height`,`imageTimeout`,`x`,`y`,`windowWidth`,`windowHeight`,`scrollX`,`scrollY`].forEach(t=>{let n=e[t];if(n!=null&&typeof n!=`number`){let r=Number(n);Number.isNaN(r)||(e[t]=r)}})},gd=e=>({allowTaint:e.allowTaint??!1,imageTimeout:e.imageTimeout??15e3,proxy:e.proxy,useCORS:e.useCORS??!1,customIsSameOrigin:e.customIsSameOrigin,maxCacheSize:e.maxCacheSize}),_d=(e,t,n)=>({logging:e.logging??!0,cache:e.cache??t.cache,...n}),vd=(e,t)=>{let n=t;return{windowWidth:e.windowWidth??n.innerWidth??800,windowHeight:e.windowHeight??n.innerHeight??600,scrollX:e.scrollX??n.pageXOffset??0,scrollY:e.scrollY??n.pageYOffset??0}},yd=(e,t,n)=>({allowTaint:e.allowTaint??!1,onclone:e.onclone,ignoreElements:e.ignoreElements,iframeContainer:e.iframeContainer,inlineImages:n,copyStyles:n,cspNonce:e.cspNonce??t.cspNonce,signal:e.signal}),bd=(e,t,n,r,i,a,o)=>({canvas:e.canvas,backgroundColor:t,signal:e.signal,scale:e.scale??o??1,x:(e.x??0)+n,y:(e.y??0)+r,width:e.width??Math.ceil(i),height:e.height??Math.ceil(a),imageSmoothing:e.imageSmoothing,imageSmoothingQuality:e.imageSmoothingQuality}),xd=(e,t,n)=>{let r=t.ownerDocument,i=r.documentElement?Nn(e,getComputedStyle(r.documentElement).backgroundColor):0,a=r.body?Nn(e,getComputedStyle(r.body).backgroundColor):0,o=typeof n==`string`?Nn(e,n):n===null?0:4294967295;return t===r.documentElement?R(i)?R(a)?o:a:i:o},Sd=(e,t,n,r)=>{if(e)try{e(n,r)}catch(e){t.logger.error(`onProgress callback failed: ${e instanceof Error?e.message:String(e)}`)}},Cd=async(e,t,n)=>{if(hd(t),!t.skipValidation){let n=t.validator||r(),i=n.validateElement(e);if(!i.valid)throw Error(i.error);let a=n.validateOptions(t);if(!a.valid)throw Error(`Invalid options: ${a.error}`)}if(!e||typeof e!=`object`)throw Error(`Invalid element provided as first argument`);let c=e.ownerDocument;if(!c)throw Error(`Element is not attached to a Document`);let l=c.defaultView;if(!l)throw Error(`Document is not attached to a Window`);let u=gd(t),d=_d(t,n,u),f=vd(t,l),p=new a(f.scrollX,f.scrollY,f.windowWidth,f.windowHeight),m=new md(d,p,n),h=t.enablePerformanceMonitoring??t.logging??!1,g=new i(m.logger,h);g.start(`total`,{width:f.windowWidth,height:f.windowHeight});let _=t.signal;q(_);let v=t.foreignObjectRendering??!1,y=yd(t,n,v);m.logger.debug(`Starting document clone with size ${p.width}x${p.height} scrolled to ${-p.left},${-p.top}`),Sd(t.onProgress,m,`clone`,10),g.start(`clone`);let b=new Os(m,e,y),x=b.clonedReferenceElement;if(!x)throw Error(`Unable to find element in cloned iframe`);let S,C,w;try{S=await b.toIFrame(c,p),g.end(`clone`),Sd(t.onProgress,m,`clone`,30),q(_);let{width:e,height:n,left:r,top:i}=Hn(x)||Bn(x)?s(x.ownerDocument):o(m,x),a=xd(m,x,t.backgroundColor),u=bd(t,a,r,i,e,n,l.devicePixelRatio??1);v?(m.logger.debug(`Document cloned, using foreign object rendering`),g.start(`render-foreignobject`),C=await new ed(m,u).render(x),g.end(`render-foreignobject`)):(m.logger.debug(`Document cloned, element located at ${r},${i} with size ${e}x${n} using computed rendering`),m.logger.debug(`Starting DOM parsing`),g.start(`parse`),q(_),m.cache.startDefer(),w=Dc(m,x,{normalizeDom:t.normalizeDom}),g.end(`parse`),Sd(t.onProgress,m,`parse`,50),g.start(`preload`),await m.cache.preloadAll(10,(e,n)=>{Sd(t.onProgress,m,`preload`,50+Math.round(e/n*10))},_),g.end(`preload`),Sd(t.onProgress,m,`layout`,60),a===w.styles.backgroundColor&&(w.styles.backgroundColor=0),m.logger.debug(`Starting renderer for element at ${u.x},${u.y} with size ${u.width}x${u.height}`),g.start(`render`),q(_),C=await new Zu(m,u).render(w),g.end(`render`)),Sd(t.onProgress,m,`render`,90)}finally{g.start(`cleanup`);try{w&&w.restoreTree()}finally{S&&(t.removeContainer??!0)&&Os.destroy(S),g.end(`cleanup`)}}return g.end(`total`),m.logger.debug(`Finished rendering`),h&&g.logSummary(),Sd(t.onProgress,m,`render`,100),C},wd=(e,n={},r)=>{let i=r||t.fromElement(e,{cspNonce:n.cspNonce,cache:n.cache});return Cd(e,n,i)};e.Html2CanvasConfig=t,e.PerformanceMonitor=i,e.Validator=n,e.createDefaultValidator=r,e.default=wd,e.html2canvas=wd}),typeof window<`u`&&window.html2canvas&&window.html2canvas.default&&(window.html2canvasExports=window.html2canvas,window.html2canvas=window.html2canvas.default);
|