// ==UserScript== // @name ChatGPT 分享长图 · 本地版 // @namespace local.chatgpt.share-image // @version 1.0.12 // @description 单条回答一键复制图片,也可多选对话生成高清 PNG 长图;本地处理。 // @match https://chatgpt.com/* // @match https://chat.openai.com/* // @run-at document-idle // @grant GM_registerMenuCommand // @grant GM_xmlhttpRequest // @connect * // @noframes // ==/UserScript== /* Bundled html2canvas-pro license: MIT License Copyright (c) 2024-present yorickshan and html2canvas-pro contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ (function(){ const module={exports:{}}; const exports=module.exports; /*! * html2canvas-pro 2.5.0 * Copyright (c) 2024-present yorickshan and html2canvas-pro contributors * Released under MIT License */ (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{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{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,requiresRuntimeCheck:!0}}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`}}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(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{constructor(e,t=!0){this.context=e,this.activeMetrics=/* @__PURE__ */ new Map,this.completedMetrics=[],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?`);return}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{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{this.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)))};for(var c=function(e){for(var t=[],n=0,r=e.length;n=55296&&i<=56319&&n>10)+55296,o%1024+56320)),(i+1===n||r.length>16384)&&(a+=String.fromCharCode.apply(String,r),r.length=0)}return a},u=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,d=typeof Uint8Array>`u`?[]:/* @__PURE__ */ new Uint8Array(256),f=0;f`u`?[]:/* @__PURE__ */ new Uint8Array(256),h=0;h>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},_=function(e){for(var t=e.length,n=[],r=0;r>y,C=(1<>y)+32,ne=65536>>b,re=(1<=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>y],t=(t<>y)],t=(t<>b),t=this.index[t],t+=e>>y&re,t=this.index[t],t=(t<`u`?[]:/* @__PURE__ */ new Uint8Array(256),ue=0;uefe?(i.push(!0),o-=fe):i.push(!1),[`normal`,`auto`,`loose`].indexOf(t)!==-1&&[8208,8211,12316,12448].indexOf(e)!==-1)return r.push(a),n.push(De);if(o===ge||o===Se){if(a===0)return r.push(a),n.push(Be);var s=n[a-1];return ct.indexOf(s)===-1?(r.push(r[a-1]),n.push(s)):(r.push(a),n.push(Be))}if(r.push(a),o===Ve)return n.push(t===`strict`?Me:qe);if(o===Qe||o===ze)return n.push(Be);if(o===$e)return e>=131072&&e<=196605||e>=196608&&e<=262141?n.push(qe):n.push(Be);n.push(o)}),[r,n,i]},ft=function(e,t,n,r){var i=r[n];if(Array.isArray(e)?e.indexOf(i)!==-1:e===i)for(var a=n;a<=r.length;){a++;var o=r[a];if(o===t)return!0;if(o!==xe)break}if(i===xe)for(var a=n;a>0;){a--;var s=r[a];if(Array.isArray(e)?e.indexOf(s)!==-1:e===s)for(var c=n;c<=r.length;){c++;var o=r[c];if(o===t)return!0;if(o!==xe)break}if(s!==xe)break}return!1},pt=function(e,t){for(var n=e;n>=0;){var r=t[n];if(r===xe)n--;else return r}return 0},mt=function(e,t,n,r,i){if(n[r]===0)return T;var a=r-1;if(Array.isArray(i)&&i[a]===!0)return T;var o=a-1,s=a+1,c=t[a],l=o>=0?t[o]:0,u=t[s];if(c===me&&u===he)return T;if(at.indexOf(c)!==-1)return tt;if(at.indexOf(u)!==-1||ot.indexOf(u)!==-1)return T;if(pt(a,t)===ye)return nt;if(rt.get(e[a])===Se||(c===He||c===Ue)&&rt.get(e[s])===Se||c===ve||u===ve||c===be||[xe,we,Ee].indexOf(c)===-1&&u===be||[Oe,ke,Ae,Fe,Re].indexOf(u)!==-1||pt(a,t)===Ne||ft(Pe,Ne,a,t)||ft([Oe,ke],Me,a,t)||ft(Ce,Ce,a,t))return T;if(c===xe)return nt;if(c===Pe||u===Pe)return T;if(u===De||c===De)return nt;if([we,Ee,Me].indexOf(u)!==-1||c===Te||l===Ke&&ut.indexOf(c)!==-1||c===Re&&u===Ke||u===je||it.indexOf(u)!==-1&&c===w||it.indexOf(c)!==-1&&u===w||c===Le&&[qe,He,Ue].indexOf(u)!==-1||[qe,He,Ue].indexOf(c)!==-1&&u===Ie||it.indexOf(c)!==-1&&st.indexOf(u)!==-1||st.indexOf(c)!==-1&&it.indexOf(u)!==-1||[Le,Ie].indexOf(c)!==-1&&(u===w||[Ne,Ee].indexOf(u)!==-1&&t[s+1]===w)||[Ne,Ee].indexOf(c)!==-1&&u===w||c===w&&[w,Re,Fe].indexOf(u)!==-1)return T;if([w,Re,Fe,Oe,ke].indexOf(u)!==-1)for(var d=a;d>=0;){var f=t[d];if(f===w)return T;if([Re,Fe].indexOf(f)!==-1)d--;else break}if([Le,Ie].indexOf(u)!==-1)for(var d=[Oe,ke].indexOf(c)===-1?a:o;d>=0;){var f=t[d];if(f===w)return T;if([Re,Fe].indexOf(f)!==-1)d--;else break}if(Je===c&&[Je,Ye,We,Ge].indexOf(u)!==-1||[Ye,We].indexOf(c)!==-1&&[Ye,Xe].indexOf(u)!==-1||[Xe,Ge].indexOf(c)!==-1&&u===Xe||lt.indexOf(c)!==-1&&[je,Ie].indexOf(u)!==-1||lt.indexOf(u)!==-1&&c===Le||it.indexOf(c)!==-1&&it.indexOf(u)!==-1||c===Fe&&it.indexOf(u)!==-1||it.concat(w).indexOf(c)!==-1&&u===Ne&&et.indexOf(e[s])===-1||it.concat(w).indexOf(u)!==-1&&c===ke)return T;if(c===Ze&&u===Ze){for(var p=n[a],m=1;p>0&&(p--,t[p]===Ze);)m++;if(m%2!=0)return T}return c===He&&u===Ue?T:nt},ht=function(e,t){t||={lineBreak:`normal`,wordBreak:`normal`};var n=dt(e,t.lineBreak),r=n[0],i=n[1],a=n[2];(t.wordBreak===`break-all`||t.wordBreak===`break-word`)&&(i=i.map(function(e){return[w,Be,Qe].indexOf(e)===-1?e:qe}));var o=t.wordBreak===`keep-all`?a.map(function(t,n){return t&&e[n]>=19968&&e[n]<=40959}):void 0;return[r,i,o]},gt=function(){function e(e,t,n,r){this.codePoints=e,this.required=t===tt,this.start=n,this.end=r}return e.prototype.slice=function(){return l.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),_t=function(e,t){var n=c(e),r=ht(n,t),i=r[0],a=r[1],o=r[2],s=n.length,l=0,u=0;return{next:function(){if(u>=s)return{done:!0,value:null};for(var e=T;u{let n=e[t];if(n===void 0)throw Error(`Missing element at index ${t}`);return n},vt=65533,D=e=>e>=48&&e<=57,yt=e=>e>=55296&&e<=57343,bt=e=>D(e)||e>=65&&e<=70||e>=97&&e<=102,xt=e=>e>=97&&e<=122,St=e=>e>=65&&e<=90,Ct=e=>xt(e)||St(e),wt=e=>e>=128,Tt=e=>e===10||e===9||e===32,Et=e=>Ct(e)||wt(e)||e===95,Dt=e=>Et(e)||D(e)||e===45,Ot=e=>e>=0&&e<=8||e===11||e>=14&&e<=31||e===127,kt=(e,t)=>e===92&&t!==10,At=(e,t,n)=>e===45?Et(t)||kt(t,n):!!(Et(e)||e===92&&kt(e,t)),jt=(e,t,n)=>e===43||e===45?D(t)?!0:t===46&&D(n):D(e===46?t:e),Mt=e=>{let t=0,n=1;(e[t]===43||e[t]===45)&&(e[t]===45&&(n=-1),t++);let r=[];for(;D(e[t]??NaN);)r.push(E(e,t)),t++;let i=r.length?parseInt(l(...r),10):0;e[t]===46&&t++;let a=[];for(;D(e[t]??NaN);)a.push(E(e,t)),t++;let o=a.length,s=o?parseInt(l(...a),10):0;(e[t]===69||e[t]===101)&&t++;let c=1;(e[t]===43||e[t]===45)&&(e[t]===45&&(c=-1),t++);let u=[];for(;D(e[t]??NaN);)u.push(E(e,t)),t++;let d=u.length?parseInt(l(...u),10):0;return n*(i+s*10**-o)*10**(c*d)},Nt={type:2},Pt={type:3},Ft={type:4},It={type:13},Lt={type:8},Rt={type:21},zt={type:9},Bt={type:10},Vt={type:11},Ht={type:12},Ut={type:14},Wt={type:23},Gt={type:1},Kt={type:25},qt={type:24},Jt={type:26},Yt={type:27},Xt={type:28},Zt={type:29},Qt={type:31},$t={type:32};var en=class e{static{this._pool=[]}static{this.MAX_POOL_SIZE=40}static get(){return e._pool.pop()||new e}static release(t){e._pool.length=this._value.length)return-1;let t=this._value[e];return t===void 0?-1:t}consumeUnicodeRangeToken(){let e=[],t=this.consumeCodePoint();for(;bt(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(l(...e.map(e=>e===63?48:e)),16),end:parseInt(l(...e.map(e=>e===63?70:e)),16)};let r=parseInt(l(...e),16);if(t===45&&bt(this.peekCodePoint(0))){t=this.consumeCodePoint();let e=[];for(;bt(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();return{type:30,start:r,end:parseInt(l(...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(),Wt)}for(;;){let t=this.consumeCodePoint();if(t===-1||t===41)return{type:22,value:l(...e)};if(Tt(t))return this.consumeWhiteSpace(),this.peekCodePoint(0)===-1||this.peekCodePoint(0)===41?(this.consumeCodePoint(),{type:22,value:l(...e)}):(this.consumeBadUrlRemnants(),Wt);if(t===34||t===39||t===40||Ot(t))return this.consumeBadUrlRemnants(),Wt;if(t===92){if(kt(t,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),Wt}else e.push(t)}}consumeWhiteSpace(){for(;Tt(this.peekCodePoint(0));)this.consumeCodePoint()}consumeBadUrlRemnants(){for(;;){let e=this.consumeCodePoint();if(e===41||e===-1)return;kt(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}}consumeStringSlice(e){let t=``;for(;e>0;){let n=Math.min(5e4,e);t+=l(...this._value.splice(0,n)),e-=n}return this._value.shift(),t}consumeStringToken(e){let t=``,n=0;do{let r=this._value[n];if(r===-1||r===void 0||r===e)return t+=this.consumeStringSlice(n),{type:0,value:t};if(r===10)return this._value.splice(0,n),Gt;if(r===92){let e=this._value[n+1];e!==-1&&e!==void 0&&(e===10?(t+=this.consumeStringSlice(n),n=-1,this._value.shift()):kt(r,e)&&(t+=this.consumeStringSlice(n),t+=l(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());D(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0);let r=this.peekCodePoint(1);if(n===46&&D(r))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;D(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)&&D(i)||D(r)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;D(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Mt(e),t]}consumeNumericToken(){let[e,t]=this.consumeNumber(),n=this.peekCodePoint(0),r=this.peekCodePoint(1),i=this.peekCodePoint(2);return At(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(bt(e)){let t=l(e);for(;bt(this.peekCodePoint(0))&&t.length<6;)t+=l(this.consumeCodePoint());Tt(this.peekCodePoint(0))&&this.consumeCodePoint();let n=parseInt(t,16);return n===0||yt(n)||n>1114111?vt:n}return e===-1?vt:e}consumeName(){let e=``;for(;;){let t=this.consumeCodePoint();if(Dt(t))e+=l(t);else if(kt(t,this.peekCodePoint(0)))e+=l(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}}},tn=class e{constructor(e){this._tokens=e}static create(t){let n=new en;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||on(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?$t:e}reconsumeToken(e){this._tokens.unshift(e)}};let O=e=>e.type===15,k=e=>e.type===17,A=e=>e.type===20,nn=e=>e.type===0,rn=(e,t)=>A(e)&&e.value===t,an=e=>e.type!==31,j=e=>e.type!==31&&e.type!==4,M=e=>{let t=[],n=[];return e.forEach(e=>{if(e.type===4){n.length&&(t.push(n),n=[]);return}e.type!==31&&n.push(e)}),n.length&&t.push(n),t},on=(e,t)=>t===11&&e.type===12||t===28&&e.type===29||t===2&&e.type===3,sn=/(\d+(?:\.\d+)?|[+\-*/()])/g,cn=e=>{let t=e.match(sn);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[E(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},N=(e,t,n)=>Math.min(Math.max(e,t),n),P=(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]],ln=e=>P([3.2409699419045226,-1.537383177570094,-.4986107602930034,-.9692436362808796,1.8759675015077202,.04155505740717559,.05563007969699366,-.20397695888897652,1.0569715142428786],e),un=e=>P([.41239079926595934,.357584339383878,.1804807884018343,.21263900587151027,.715168678767756,.07219231536073371,.01933081871559182,.11919477979462598,.9505321522496607],e),dn=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)]},fn=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)]},pn=e=>{let[t,n,r]=dn(ln([e[0],e[1],e[2]]));return[t,n,r,e[3]]},mn=e=>{let[t,n,r]=ln([e[0],e[1],e[2]]);return[N(Math.round(t*255),0,255),N(Math.round(n*255),0,255),N(Math.round(r*255),0,255),e[3]]},hn=e=>e.type===17||e.type===15,F=e=>e.type===16||hn(e)||gn(e),gn=e=>e.type===17&&e._calcPercentage!==void 0,_n=e=>e.type===18&&e.name===`calc`,vn=e=>{let t=bn(e,0);if(!t)return null;let n=bn(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}},yn=e=>_n(e)?vn(e):F(e)?e:null,bn=(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=cn(t);if(typeof r==`number`&&!isNaN(r))return{type:17,number:r,flags:4}}catch{return null}return null},xn=e=>e.length>1?[E(e,0),E(e,1)]:[E(e,0)],I={type:17,number:0,flags:4},L={type:16,number:50,flags:4},R={type:16,number:100,flags:4},Sn=(e,t,n)=>{let[r,i]=e;return[z(r,t),z(i===void 0?r:i,n)]},z=(e,t)=>{if(gn(e))return e._calcPercentage/100*t+e._calcPixelOffset;if(e.type===16)return e.number/100*t;if(O(e))switch(e.unit){case`rem`:case`em`:return 16*e.number;default:return e.number}return e.number},Cn=`grad`,wn=`turn`,Tn={name:`angle`,parse:(e,t)=>{if(t.type===15)switch(t.unit){case`deg`:return Math.PI*t.number/180;case Cn:return Math.PI/200*t.number;case`rad`:return t.number;case wn:return Math.PI*2*t.number}throw Error(`Unsupported angle type`)}},En=e=>!(e.type!==15||e.unit!==`deg`&&e.unit!==Cn&&e.unit!==`rad`&&e.unit!==wn),Dn=e=>{switch(e.filter(A).map(e=>e.value).join(` `)){case`to bottom right`:case`to right bottom`:case`left top`:case`top left`:return[I,I];case`to top`:case`bottom`:return B(0);case`to bottom left`:case`to left bottom`:case`right top`:case`top right`:return[I,R];case`to right`:case`left`:return B(90);case`to top left`:case`to left top`:case`right bottom`:case`bottom right`:return[R,R];case`to bottom`:case`top`:return B(180);case`to top right`:case`to right top`:case`left bottom`:case`bottom left`:return[R,I];case`to left`:case`right`:return B(270)}return 0},B=e=>Math.PI*e/180,On=e=>!(255&e),V=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})`},kn=(e,t,n,r)=>(e<<24|t<<16|n<<8|Math.round(r*255)<<0)>>>0,H=(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},An=e=>{let t=e[0];return(t&&t.type===20?t.value:`unknown`)===`from`},jn=e=>kn(N(Math.round(e[0]*255),0,255),N(Math.round(e[1]*255),0,255),N(Math.round(e[2]*255),0,255),N(e[3],0,1)),Mn=e=>{let[t,n,r,i]=e,a=dn([t,n,r]);return kn(N(Math.round(a[0]*255),0,255),N(Math.round(a[1]*255),0,255),N(Math.round(a[2]*255),0,255),i)},Nn=e=>{let t=ln([e[0],e[1],e[2]]);return Mn([t[0],t[1],t[2],e[3]])},Pn=(e,t)=>{if(An(t.filter(j)))throw Error(`Relative color not supported for lab()`);let[n,r,i,a]=Vn(t),o=dn(ln(Yn([n,r,i])));return kn(N(Math.round(o[0]*255),0,255),N(Math.round(o[1]*255),0,255),N(Math.round(o[2]*255),0,255),a)},Fn=(e,t)=>{if(An(t.filter(j)))throw Error(`Relative color not supported for oklab()`);let[n,r,i,a]=Vn(t),o=dn(ln(Jn([n,r,i])));return kn(N(Math.round(o[0]*255),0,255),N(Math.round(o[1]*255),0,255),N(Math.round(o[2]*255),0,255),a)},In=(e,t)=>{if(An(t.filter(j)))throw Error(`Relative color not supported for oklch()`);let[n,r,i,a]=Hn(t),o=dn(ln(Jn(qn([n,r,i]))));return kn(N(Math.round(o[0]*255),0,255),N(Math.round(o[1]*255),0,255),N(Math.round(o[2]*255),0,255),a)},Ln=(e,t)=>{if(An(t.filter(j)))throw Error(`Relative color not supported for lch()`);let[n,r,i,a]=Bn(t),o=dn(ln(Yn(qn([n,r,i]))));return kn(N(Math.round(o[0]*255),0,255),N(Math.round(o[1]*255),0,255),N(Math.round(o[2]*255),0,255),a)},Rn=(e,t)=>{let n=t.filter(j),r=n[0],i=n[1],a=n[2],o=n[3];return[r?(r.type===17?B(r.number):Tn.parse(e,r))/(Math.PI*2):0,i!==void 0&&F(i)?i.number/100:0,a!==void 0&&F(a)?a.number/100:0,o!==void 0&&F(o)?z(o,1):1]},zn=(e,t)=>{if(An(t))throw Error(`Relative color not supported for hsl()`);let[n,r,i,a]=Rn(e,t),o=Kn([n,r,i]);return kn(o[0]*255,o[1]*255,o[2]*255,r===0?1:a)},Bn=e=>{let t=e.filter(j),n=t[0],r=t[1],i=t[2],a=t[4];return[n!==void 0&&F(n)?n.number:0,r!==void 0&&F(r)?r.number:0,i!==void 0&&(k(i)||O(i))?i.number:0,a!==void 0&&F(a)?z(a,1):1]},Vn=e=>{let t=e.filter(j),n=t[0],r=t[1],i=t[2],a=t[4];return[n===void 0?0:n.type===16?n.number/100:k(n)?n.number:0,r===void 0?0:r.type===16?r.number/100:k(r)?r.number:0,i!==void 0&&(k(i)||O(i))?i.number:0,a!==void 0&&F(a)?z(a,1):1]},Hn=e=>{let t=e.filter(j),n=t[0],r=t[1],i=t[2],a=t[4];return[n===void 0?0:n.type===16?n.number/100:k(n)?n.number:0,r===void 0?0:r.type===16?r.number/100:k(r)?r.number:0,i!==void 0&&(k(i)||O(i))?i.number:0,a!==void 0&&F(a)?z(a,1):1]},Un=e=>P([1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371],e),Wn=e=>P([.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124],e),Gn=(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),Kn=([e,t,n])=>{if(t===0)return[n*255,n*255,n*255];let r=n<=.5?n*(t+1):n+t-n*t,i=n*2-r;return[Gn(i,r,e+1/3),Gn(i,r,e),Gn(i,r,e-1/3)]},qn=([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)]),Jn=e=>{let t=P([1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],e),n=[t[0]**3,t[1]**3,t[2]**3];return P([1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],n)},Yn=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 Wn([o[0],o[1],o[2]])},Xn=(e,t)=>{let n=t.filter(j);if(n.length===3||n.length===4){let e=H(E(n,0),0),t=H(E(n,1),1),r=H(E(n,2),2),i=n.length===4?H(E(n,3),3):1,a=fn([e/255,t/255,r/255]),[o,s,c]=un([a[0],a[1],a[2]]);return[o,s,c,i]}return[0,0,0,1]},Zn=(e,t)=>{let[n,r,i,a]=Rn(e,t),o=fn(Kn([n,r,i])),[s,c,l]=un([o[0],o[1],o[2]]);return[s,c,l,a]},Qn=(e,t)=>{let[n,r,i,a]=Vn(t),[o,s,c]=Yn([n,r,i]);return[o,s,c,a]},$n=(e,t)=>{let[n,r,i,a]=Bn(t),[o,s,c]=Yn(qn([n,r,i]));return[o,s,c,a]},er=(e,t)=>{let[n,r,i,a]=Hn(t),[o,s,c]=Jn(qn([n,r,i]));return[o,s,c,a]},tr=(e,t)=>{let[n,r,i,a]=Vn(t),[o,s,c]=Jn([n,r,i]);return[o,s,c,a]},nr=e=>Wn([e[0],e[1],e[2]]),rr=e=>e,ir=e=>{let[t,n,r]=Un([e[0],e[2],e[3]]);return[t,n,r,e[3]]},ar=e=>Nn([e[0],e[1],e[2],e[3]]),or=e=>{let t=nr([e[0],e[1],e[2]]);return Nn([t[0],t[1],t[2],e[3]])},sr=e=>P([.4865709486482162,.26566769316909306,.1982172852343625,.2289745640697488,.6917385218365064,.079286914093745,0,.04511338185890264,1.043944368900976],e),cr=e=>P([2.493496911941425,-.9313836179191239,-.40271078445071684,-.8294889695615747,1.7626640603183463,.023624685841943577,.03584583024378447,-.07617238926804182,.9568845240076872],e),lr=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])]},ur=e=>dn(e),dr=e=>{let t=lr([e[0],e[1],e[2]]);return sr([t[0],t[1],t[2]])},fr=e=>{let[t,n,r]=ur(cr([e[0],e[1],e[2]]));return[t,n,r,e[3]]},pr=e=>{let t=dr([e[0],e[1],e[2]]);return Nn([t[0],t[1],t[2],e[3]])},mr=e=>P([2.0415879038107465,-.5650069742788596,-.34473135077832956,-.9692436362808795,1.8759675015077202,.04155505740717557,.013444280632031142,-.11836239223101838,1.0151749943912054],e),hr=e=>P([.5766690429101305,.1855582379065463,.1882286462349947,.29734497525053605,.6273635662554661,.0752914584939978,.02703136138641234,.07068885253582723,.9913375368376388],e),gr=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]},_r=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]},vr=e=>{let[t,n,r]=_r(mr([e[0],e[1],e[2]]));return[t,n,r,e[3]]},yr=e=>{let t=ln(hr(gr([e[0],e[1],e[2]])));return Mn([t[0],t[1],t[2],e[3]])},br=e=>P([.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602],e),xr=e=>P([1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],e),Sr=e=>{let[t,n,r]=e,i=e=>e<16/512?e/16:e**1.8;return[i(t),i(n),i(r)]},Cr=e=>{let[t,n,r]=e,i=e=>e>1/512?e**(1/1.8):e*16;return[i(t),i(n),i(r)]},wr=e=>{let t=Sr([e[0],e[1],e[2]]);return Wn(br([t[0],t[1],t[2]]))},Tr=e=>{let[t,n,r]=Cr(xr(Un([e[0],e[1],e[2]])));return[t,n,r,e[3]]},Er=e=>{let t=wr([e[0],e[1],e[2]]);return Nn([t[0],t[1],t[2],e[3]])},Dr=1.09929682680944,Or=.018053968510807,kr=e=>{let t=e=>e{let t=e=>e>=Or?Dr*e**.45-.09929682680944008:4.5*e;return[t(e[0]),t(e[1]),t(e[2])]},jr=e=>P([.6369580483012914,.14461690358620832,.1688809751641721,.2627002120112671,.6779980715188708,.05930171646986196,0,.028072693049087428,1.060985057710791],e),Mr=e=>P([1.716651187971268,-.355670783776392,-.25336628137366,-.666684351832489,1.616481236634939,.0157685458139111,.017639857445311,-.042770613257809,.942103121235474],e),Nr=e=>{let t=kr([e[0],e[1],e[2]]);return jr([t[0],t[1],t[2]])},Pr=e=>{let[t,n,r]=Ar(Mr([e[0],e[1],e[2]]));return[t,n,r,e[3]]},Fr=e=>{let t=Nr([e[0],e[1],e[2]]);return Nn([t[0],t[1],t[2],e[3]])},U={name:`color`,parse:(e,t)=>{if(t.type===18){let n=Hr[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]=Ir(t);return kn(e,n,r,i)}if(t.type===20){let e=Wr[t.value.toUpperCase()];if(e!==void 0)return e}return 0}},Ir=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]},Lr=(e,t)=>{let n=t.filter(j);if(An(n))throw Error(`Relative color not supported for rgb()`);if(n.length===3||n.length===4){let e=H(E(n,0),0),t=H(E(n,1),1),r=H(E(n,2),2),i=n.length===4?H(E(n,3),3):1;return kn(e,t,r,i)}if(n.length===5){let e=E(n,3);if(e.type===6&&e.value===`/`){let e=H(E(n,0),0),t=H(E(n,1),1),r=H(E(n,2),2),i=H(E(n,4),3);return kn(e,t,r,i)}}return 0},Rr=(e,t)=>{let n=t.filter(j),r=n[0],i=r&&r.type===20?r.value:`unknown`;if(An(n)){let t=(e,t)=>{if(k(t))return t.number;let n=e=>e===`r`||e===`x`?0:e===`g`||e===`y`?1:2;if(A(t)){let r=n(t.value);return E(e,r)}let r=e=>{let t=e.filter(j),n=`(`;for(let e of t)n+=e.type===18&&e.name===`calc`?r(e.values):k(e)?e.number:e.type===6||A(e)?e.value:``;return n+=`)`,n};if(t.type===18){let n=t.values.filter(j);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 cn(t)}}return null},r=E(n,1),i=r.type===18?r.name:A(r)||r.type===5?`rgb`:`unknown`,a=E(n,2),o=A(a)?a.value:`unknown`,s=r.type===18?r.values:A(r)?[r]:[];if(A(r)){if(Wr[r.value.toUpperCase()]===void 0)throw Error(`Attempting to use unknown color in relative color 'from'`);{let t=Ur(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]=Ir(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 c=Br[i],l=Vr[o],u=zr[o];if(c===void 0)throw Error(`Attempting to parse an unsupported color space "${i}" for color() function`);if(l===void 0)throw Error(`Attempting to parse an unsupported color space "${o}" for color() function`);let d=l(c(e,s)),f=t(d,E(n,3)),p=t(d,E(n,4)),m=t(d,E(n,5)),h=n[6],g=n[7],_=h!==void 0&&h.type===6&&h.value===`/`&&g!==void 0&&k(g)?g.number:1;if(f===null||p===null||m===null)throw Error(`Invalid relative color in color() function`);if(u===void 0)throw Error(`Attempting to parse an unsupported color space "${o}" for color() function`);return u([f,p,m,_])}{let e=i,t=zr[e];if(t===void 0)throw Error(`Attempting to parse an unsupported color space "${e}" for color() function`);let r=E(n,1),a=E(n,2),o=E(n,3),s=n[4],c=n[5];return t([k(r)?r.number:0,k(a)?a.number:0,k(o)?o.number:0,s!==void 0&&s.type===6&&s.value===`/`&&c!==void 0&&k(c)?c.number:1])}},zr={srgb:jn,"srgb-linear":Mn,"display-p3":pr,"a98-rgb":yr,"prophoto-rgb":Er,xyz:ar,"xyz-d50":or,"xyz-d65":ar,rec2020:Fr},Br={rgb:Xn,hsl:Zn,lab:Qn,lch:$n,oklab:tr,oklch:er},Vr={srgb:pn,"srgb-linear":mn,"display-p3":fr,"a98-rgb":vr,"prophoto-rgb":Tr,xyz:rr,"xyz-d50":ir,"xyz-d65":rr,rec2020:Pr},Hr={hsl:zn,hsla:zn,rgb:Lr,rgba:Lr,lch:Ln,oklch:In,oklab:Fn,lab:Pn,color:Rr},Ur=(e,t)=>U.parse(e,tn.create(t).parseComponentValue()),Wr={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},Gr=e=>e.nodeType===Node.ELEMENT_NODE,Kr=e=>e.nodeType===Node.TEXT_NODE,qr=e=>typeof e.className==`object`,Jr=e=>Gr(e)&&e.style!==void 0&&!qr(e),Yr=e=>e.tagName===`INPUT`,Xr=e=>e.tagName===`HTML`,Zr=e=>e.tagName===`svg`,Qr=e=>e.tagName===`BODY`,$r=e=>e.tagName===`CANVAS`,ei=e=>e.tagName===`VIDEO`,ti=e=>e.tagName===`IMG`,ni=e=>e.tagName===`IFRAME`,ri=e=>e.tagName===`STYLE`,ii=e=>e.tagName===`SCRIPT`,ai=e=>e.tagName===`TEXTAREA`,oi=e=>e.tagName===`SELECT`,si=e=>e.tagName===`SLOT`,ci=e=>e.tagName===`LI`,li=e=>e.tagName===`OL`,ui=e=>!qr(e)&&e.tagName.indexOf(`-`)>0,di=/* @__PURE__ */ new Set([`IMG`,`VIDEO`,`AUDIO`,`CANVAS`,`IFRAME`,`INPUT`,`TEXTAREA`,`SELECT`,`BR`,`HR`,`META`,`LINK`,`BASE`,`COL`,`SOURCE`,`TRACK`,`WBR`,`AREA`,`PARAM`,`EMBED`,`OBJECT`]),fi=e=>!qr(e)&&!di.has(e.tagName),pi={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}}},W=(e,t)=>(e&t)!==0;var mi=class{constructor(){this.counters={}}getCounterValue(e){let t=this.counters[e];return t&&t.length?E(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 hi={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`]},gi={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(`.`)},_i={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(`.`)},vi={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(`.`)},yi=(e,t,n,r,i,a)=>en?Di(e,i,a.length>0):r.integers.reduce((t,n,i)=>{for(;e>=n;)e-=n,t+=r.values[i];return t},``)+a,bi=(e,t,n,r)=>{let i=``;do n||e--,i=r(e)+i,e/=t;while(e*t>=t);return i},G=(e,t,n,r,i)=>{let a=n-t+1;return(e<0?`-`:``)+(bi(Math.abs(e),a,r,e=>l(Math.floor(e%a)+t))+i)},xi=(e,t,n=`. `)=>{let r=t.length;return bi(Math.abs(e),r,!1,e=>String(t[Math.floor(e%r)]))+n},Si=(e,t,n,r,i,a)=>{if(e<-9999||e>9999)return Di(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&&W(a,1)&&s!==``?s=t[i]+s:i>1||i===1&&r===0||i===1&&r===1&&W(a,2)||i===1&&r===1&&W(a,4)&&e>100||i===1&&r>1&&W(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},Ci=`十百千萬`,wi=`拾佰仟萬`,Ti=`マイナス`,Ei=`마이너스`,Di=(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=G(e,48,57,!0,r);return t.length<4?`0${t}`:t;case 4:return xi(e,`〇一二三四五六七八九`,i);case 6:return yi(e,1,3999,hi,3,r).toLowerCase();case 7:return yi(e,1,3999,hi,3,r);case 8:return G(e,945,969,!1,r);case 9:return G(e,97,122,!1,r);case 10:return G(e,65,90,!1,r);case 11:return G(e,1632,1641,!0,r);case 12:case 49:return yi(e,1,9999,gi,3,r);case 35:return yi(e,1,9999,gi,3,r).toLowerCase();case 13:return G(e,2534,2543,!0,r);case 14:case 30:return G(e,6112,6121,!0,r);case 15:return xi(e,`子丑寅卯辰巳午未申酉戌亥`,i);case 16:return xi(e,`甲乙丙丁戊己庚辛壬癸`,i);case 17:case 48:return Si(e,`零一二三四五六七八九`,Ci,`負`,i,14);case 47:return Si(e,`零壹貳參肆伍陸柒捌玖`,wi,`負`,i,15);case 42:return Si(e,`零一二三四五六七八九`,Ci,`负`,i,14);case 41:return Si(e,`零壹贰叁肆伍陆柒捌玖`,wi,`负`,i,15);case 26:return Si(e,`〇一二三四五六七八九`,`十百千万`,Ti,i,0);case 25:return Si(e,`零壱弐参四伍六七八九`,`拾百千万`,Ti,i,7);case 31:return Si(e,`영일이삼사오육칠팔구`,`십백천만`,Ei,a,7);case 33:return Si(e,`零一二三四五六七八九`,`十百千萬`,Ei,a,0);case 32:return Si(e,`零壹貳參四五六七八九`,`拾百千`,Ei,a,7);case 18:return G(e,2406,2415,!0,r);case 20:return yi(e,1,19999,vi,3,r);case 21:return G(e,2790,2799,!0,r);case 22:return G(e,2662,2671,!0,r);case 52:return yi(e,1,10999,_i,3,r);case 23:return xi(e,`あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん`);case 24:return xi(e,`いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす`);case 27:return G(e,3302,3311,!0,r);case 28:return xi(e,`アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン`,i);case 29:return xi(e,`イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス`,i);case 34:return G(e,3792,3801,!0,r);case 37:return G(e,6160,6169,!0,r);case 38:return G(e,4160,4169,!0,r);case 39:return G(e,2918,2927,!0,r);case 40:return G(e,1776,1785,!0,r);case 43:return G(e,3046,3055,!0,r);case 44:return G(e,3174,3183,!0,r);case 45:return G(e,3664,3673,!0,r);case 46:return G(e,3872,3881,!0,r);default:return G(e,48,57,!0,r)}},Oi={name:`display`,initialValue:`inline-block`,prefix:!1,type:1,parse:(e,t)=>t.filter(A).reduce((e,t)=>e|ki(t.value),0)},ki=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},Ai={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}},ji={name:`overflow`,initialValue:`visible`,prefix:!1,type:1,parse:(e,t)=>t.filter(A).map(e=>{switch(e.value){case`hidden`:return 1;case`scroll`:return 2;case`clip`:return 3;case`auto`:return 4;default:return 0}})},Mi={name:`text-decoration-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},Ni={name:`text-decoration-line`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>t.filter(A).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)},Pi={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}},Fi={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(nn);if(i.length%2!=0)return null;for(let e=0;e{if(!e)return``;let r=e[Math.min(t,e.length-1)];return r?n?r.open:r.close:``},Li=(e,t)=>{let n=[],r=e.filter(an);for(let e=0;e{if(t.length===0)return null;let n=t[0];return n&&n.type===20&&n.value===`none`?null:Li(t,1).map(([e,t])=>({counter:e,increment:t}))}},zi={name:`counter-reset`,initialValue:`none`,prefix:!0,type:1,parse:(e,t)=>t.length===0?[]:Li(t,0).filter(([e])=>e!==`none`).map(([e,t])=>({counter:e,reset:t}))},Bi={name:`background-clip`,initialValue:`border-box`,prefix:!1,type:1,parse:(e,t)=>t.map(e=>{if(A(e))switch(e.value){case`padding-box`:return 1;case`content-box`:return 2;case`text`:return 3}return 0})},Vi={name:`background-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},Hi=(e,t)=>{let n=U.parse(e,E(t,0)),r=t[1];return r&&F(r)?{color:n,stop:r}:{color:n,stop:null}},Ui=(e,t)=>{let n=e.map(e=>({color:e.color,stop:e.stop})),r=E(n,0),i=E(n,n.length-1);r.stop===null&&(r.stop=I),i.stop===null&&(i.stop=R);let a=[],o=0;for(let e=0;eo?a.push(e):a.push(o),o=e}else a.push(null)}let s=null;for(let e=0;e({color:e,stop:Math.max(Math.min(1,a[n]/t),0)}))},Wi=(e,t,n)=>{let r=t/2,i=n/2,a=z(e[0],t)-r,o=i-z(e[1],n);return(Math.atan2(o,a)+Math.PI*2)%(Math.PI*2)},Gi=(e,t,n)=>{let r=typeof e==`number`?e:Wi(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]},Ki=(e,t)=>Math.sqrt(e*e+t*t),qi=(e,t,n,r,i)=>[[0,0],[0,t],[e,0],[e,t]].reduce((e,t)=>{let[a,o]=t,s=Ki(n-a,r-o);return(i?se.optimumDistance)?{optimumCorner:t,optimumDistance:s}:e},{optimumDistance:i?1/0:-1/0,optimumCorner:null}).optimumCorner,Ji=(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(Ki(t,n),Ki(t,n-i),Ki(t-r,n),Ki(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]=qi(r,i,t,n,!0);a=Ki(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(Ki(t,n),Ki(t,n-i),Ki(t-r,n),Ki(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]=qi(r,i,t,n,!1);a=Ki(s-t,(c-n)/e),o=e*a}}if(Array.isArray(e.size)){let t=e.size;a=z(E(t,0),r),o=t.length===2?z(E(t,1),i):a}return[a,o]},Yi=(e,t)=>{let n=B(180),r=[];return M(t).forEach((t,i)=>{if(i===0){let r=t[0];if(r&&r.type===20&&r.value===`to`){n=Dn(t);return}if(r&&En(r)){n=Tn.parse(e,r);return}}let a=Hi(e,t);r.push(a)}),{angle:n,stops:r,type:1}},Xi=(e,t)=>{let n=B(180),r=[];return M(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=Dn(t);return}if(r&&En(r)){n=(Tn.parse(e,r)+B(270))%B(360);return}}let a=Hi(e,t);r.push(a)}),{angle:n,stops:r,type:1}},Zi=(e,t)=>{let n=B(180),r=[],i=1;return M(t).forEach((t,n)=>{let a=t[0];if(a){if(n===0){if(A(a)&&a.value===`linear`){i=1;return}if(A(a)&&a.value===`radial`){i=2;return}}if(a.type===18){if(a.name===`from`){let t=U.parse(e,E(a.values,0));r.push({stop:I,color:t})}else if(a.name===`to`){let t=U.parse(e,E(a.values,0));r.push({stop:R,color:t})}else if(a.name===`color-stop`){let t=a.values.filter(j);if(t.length===2){let n=U.parse(e,E(t,1)),i=E(t,0);k(i)&&r.push({stop:{type:16,number:i.number*100,flags:i.flags},color:n})}}}}}),i===1?{angle:(n+B(180))%B(360),stops:r,type:i}:{size:3,shape:0,stops:r,position:[],type:i}},Qi=`closest-side`,$i=`farthest-side`,ea=`closest-corner`,ta=`farthest-corner`,na=`circle`,ra=`ellipse`,ia=`cover`,aa=`contain`,oa=(e,t)=>{let n=0,r=3,i=[],a=[];return M(t).forEach((t,o)=>{let s=!0;if(o===0){let e=!1;s=t.reduce((t,i)=>{if(e){if(A(i))switch(i.value){case`center`:return a.push(L),t;case`top`:case`left`:return a.push(I),t;case`right`:case`bottom`:return a.push(R),t}else(F(i)||hn(i))&&a.push(i)}else if(A(i))switch(i.value){case na:return n=0,!1;case ra:return n=1,!1;case`at`:return e=!0,!1;case Qi:return r=0,!1;case ia:case $i:return r=1,!1;case aa:case ea:return r=2,!1;case ta:return r=3,!1}else if(hn(i)||F(i))return Array.isArray(r)||(r=[]),r.push(i),!1;return t},s)}if(s){let n=Hi(e,t);i.push(n)}}),{size:r,shape:n,stops:i,position:a,type:2}},sa=(e,t)=>{let n=0,r=3,i=[],a=[];return M(t).forEach((t,o)=>{let s=!0;if(o===0?s=t.reduce((e,t)=>{if(A(t))switch(t.value){case`center`:return a.push(L),!1;case`top`:case`left`:return a.push(I),!1;case`right`:case`bottom`:return a.push(R),!1}else if(F(t)||hn(t))return a.push(t),!1;return e},s):o===1&&(s=t.reduce((e,t)=>{if(A(t))switch(t.value){case na:return n=0,!1;case ra:return n=1,!1;case aa:case Qi:return r=0,!1;case $i:return r=1,!1;case ea:return r=2,!1;case ia:case ta:return r=3,!1}else if(hn(t)||F(t))return Array.isArray(r)||(r=[]),r.push(t),!1;return e},s)),s){let n=Hi(e,t);i.push(n)}}),{size:r,shape:n,stops:i,position:a,type:2}},ca=(e,t)=>({...Yi(e,t),type:3}),la=(e,t)=>({...oa(e,t),type:4}),ua=(e,t)=>{let n=0,r=[],i=[];return M(t).forEach((t,a)=>{let o=!0;if(a===0){let i=!1,a=!1;o=t.reduce((t,o)=>{if(A(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(L),t;case`top`:case`left`:return r.push(I),t;case`right`:case`bottom`:return r.push(R),t}return i?(n=Tn.parse(e,o),!1):(a&&F(o)&&r.push(o),t)},!0)}o&&t.length>0&&i.push(Hi(e,t))}),{type:5,angle:n,position:r,stops:i}},da=e=>e&&(O(e)&&(e.unit===`dppx`||e.unit===`x`)||k(e))?e.number:1,fa=(e,t)=>{let n=M(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=>O(e)||k(e));i.push({imageToken:t,resolution:da(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=E(a.length>0?a:i.slice().sort((e,t)=>t.resolution-e.resolution),0);return va.parse(e,o.imageToken)},pa=e=>e.type===1,ma=e=>e.type===2,ha=e=>e.type===3,ga=e=>e.type===4,_a=e=>e.type===5,va={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=ba[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 ya(e){return(e.type!==20||e.value!==`none`)&&(e.type!==18||!!ba[e.name])}let ba={"linear-gradient":Yi,"-moz-linear-gradient":Xi,"-ms-linear-gradient":Xi,"-o-linear-gradient":Xi,"-webkit-linear-gradient":Xi,"radial-gradient":oa,"-moz-radial-gradient":sa,"-ms-radial-gradient":sa,"-o-radial-gradient":sa,"-webkit-radial-gradient":sa,"-webkit-gradient":Zi,"repeating-linear-gradient":ca,"-webkit-repeating-linear-gradient":ca,"-moz-repeating-linear-gradient":ca,"-ms-repeating-linear-gradient":ca,"-o-repeating-linear-gradient":ca,"repeating-radial-gradient":la,"-webkit-repeating-radial-gradient":la,"-moz-repeating-radial-gradient":la,"conic-gradient":ua,"-webkit-conic-gradient":ua,"-moz-conic-gradient":ua,"image-set":fa,"-webkit-image-set":fa},xa={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=>j(e)&&ya(e)).map(t=>va.parse(e,t))}},Sa={name:`background-origin`,initialValue:`border-box`,prefix:!1,type:1,parse:(e,t)=>t.map(e=>{if(A(e))switch(e.value){case`padding-box`:return 1;case`content-box`:return 2}return 0})},Ca={name:`background-position`,initialValue:`0% 0%`,type:1,prefix:!1,parse:(e,t)=>M(t).map(e=>e.map(yn).filter(e=>e!==null)).map(xn)},wa={name:`background-repeat`,initialValue:`repeat`,prefix:!1,type:1,parse:(e,t)=>M(t).map(e=>e.filter(A).map(e=>e.value).join(` `)).map(Ta)},Ta=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}},Ea={name:`background-size`,initialValue:`0`,prefix:!1,type:1,parse:(e,t)=>M(t).map(e=>e.map(e=>Da(e)?e:yn(e)).filter(e=>e!==null))},Da=e=>A(e)||F(e),Oa=e=>({name:`border-${e}-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`}),ka=Oa(`top`),Aa=Oa(`right`),ja=Oa(`bottom`),Ma=Oa(`left`),Na=e=>({name:`border-${e}-radius`,initialValue:`0 0`,prefix:!1,type:1,parse:(e,t)=>xn(t.filter(F))}),Pa=Na(`top-left`),Fa=Na(`top-right`),Ia=Na(`bottom-right`),La=Na(`bottom-left`),Ra=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}}),za=Ra(`top`),Ba=Ra(`right`),Va=Ra(`bottom`),Ha=Ra(`left`),Ua=e=>({name:`border-${e}-width`,initialValue:`0`,type:0,prefix:!1,parse:(e,t)=>O(t)?t.number:0}),Wa=Ua(`top`),Ga=Ua(`right`),Ka=Ua(`bottom`),qa=Ua(`left`),Ja={type:0},Ya=e=>{let[t]=e;return t?A(t)?t.value===`farthest-side`?`farthest-side`:`closest-side`:F(t)?t:`closest-side`:`closest-side`},Xa=e=>{let t=null,n=null;for(let r of e)if(A(r))switch(r.value){case`left`:t=I;break;case`right`:t=R;break;case`top`:n=I;break;case`bottom`:n=R;break;case`center`:t===null?t=L:n===null&&(n=L)}else F(r)&&(t===null?t=r:n===null&&(n=r));return{cx:t??L,cy:n??L}},Za=e=>{let t=[];for(let n of e)if(n.type!==31){if(A(n)&&n.value===`round`)break;F(n)&&t.push(n)}let n=t[0]??I,r=t[1]??n;return{type:1,top:n,right:r,bottom:t[2]??n,left:t[3]??r}},Qa=e=>{let t=e.filter(an),n=t.findIndex(e=>rn(e,`at`)),r=n===-1?t:t.slice(0,n),i=n===-1?[]:t.slice(n+1);return{type:2,radius:Ya(r),...Xa(i)}},$a=e=>{let t=e.filter(an),n=t.findIndex(e=>rn(e,`at`)),r=n===-1?t:t.slice(0,n),i=n===-1?[]:t.slice(n+1);return{type:3,rx:Ya(r.slice(0,1)),ry:Ya(r.slice(1,2)),...Xa(i)}},eo=e=>{let t=M(e),n=[];for(let e of t){if(e.length===1&&e[0]&&A(e[0]))continue;let t=e.filter(F);t.length>=2&&n.push([E(t,0),E(t,1)])}return{type:4,points:n}},to=e=>{let t=e.find(e=>e.type===0);return t?{type:5,d:t.value}:Ja},no=e=>{let t=[];for(let n of e)if(n.type!==31){if(A(n)&&n.value===`round`)break;F(n)&&t.push(n)}return t.length<4?Ja:{type:6,x:E(t,0),y:E(t,1),width:E(t,2),height:E(t,3)}},ro=e=>{let t=[];for(let n of e)if(n.type!==31){if(A(n)){if(n.value===`round`)break;if(n.value===`auto`){t.push(`auto`);continue}return Ja}F(n)&&t.push(n)}if(t.length!==4)return Ja;let n=(e,t)=>e===`auto`?t===`top`||t===`left`?I:R:e;return{type:1,top:n(E(t,0),`top`),right:n(E(t,1),`right`),bottom:n(E(t,2),`bottom`),left:n(E(t,3),`left`)}},io={name:`clip-path`,initialValue:`none`,prefix:!1,type:0,parse:(e,t)=>{if(A(t)&&t.value===`none`)return Ja;if(t.type===18)switch(t.name){case`inset`:return Za(t.values);case`circle`:return Qa(t.values);case`ellipse`:return $a(t.values);case`polygon`:return eo(t.values);case`path`:return to(t.values);case`xywh`:return no(t.values);case`rect`:return ro(t.values)}return Ja}},ao={name:`color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},oo={name:`direction`,initialValue:`ltr`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`rtl`:return 1;default:return 0}}},so={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)}},co={name:`font-size`,initialValue:`0`,prefix:!1,type:3,format:`length`},lo={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},uo={name:`line-break`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`strict`:return`strict`;default:return`normal`}}},fo={name:`line-height`,initialValue:`normal`,prefix:!1,type:4},po=(e,t)=>A(e)&&e.value===`normal`?1.2*t:e.type===17?t*e.number:F(e)?z(e,t):t,mo={name:`list-style-image`,initialValue:`none`,type:0,prefix:!1,skipCache:!0,parse:(e,t)=>t.type===20&&t.value===`none`?null:va.parse(e,t)},ho={name:`list-style-position`,initialValue:`outside`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`inside`:return 0;default:return 1}}},go=e=>({name:`margin-${e}`,initialValue:`0`,prefix:!1,type:4}),_o=go(`top`),vo=go(`right`),yo=go(`bottom`),bo=go(`left`),xo={name:`overflow-wrap`,initialValue:`normal`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`break-word`:return`break-word`;default:return`normal`}}},So=e=>({name:`padding-${e}`,initialValue:`0`,prefix:!1,type:3,format:`length-percentage`}),Co=So(`top`),wo=So(`right`),To=So(`bottom`),Eo=So(`left`),Do={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}}},Oo={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}},ko={name:`text-shadow`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>t.length===1&&rn(E(t,0),`none`)?[]:M(t).map(t=>{let n={color:0,offsetX:I,offsetY:I,blur:I},r=0;for(let i=0;i{switch(t){case`uppercase`:return 2;case`lowercase`:return 1;case`capitalize`:return 3}return 0}},jo={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=Mo[t.name];if(n===void 0)throw Error(`Attempting to parse an unsupported transform function "${t.name}"`);return n(e,t.values)}return null}},Mo={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?[E(n,0),E(n,1),E(n,4),E(n,5),E(n,12),E(n,13)]:null},rotate:(e,t)=>{if(t.length!==1)return null;let n=E(t,0),r=0;if(n.type===17&&n.number===0)r=0;else if(n.type===15)r=Tn.parse(e,n);else return null;let i=Math.cos(r),a=Math.sin(r);return[i,a,-a,i,0,0]}},No={type:16,number:50,flags:4},Po=[No,No],Fo={name:`transform-origin`,initialValue:`50% 50%`,prefix:!0,type:1,parse:(e,t)=>{let n=t.filter(F);return n.length===2?[E(n,0),E(n,1)]:Po}},Io={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?Tn.parse(e,t)*180/Math.PI:null},Lo={name:`visibility`,initialValue:`none`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`hidden`:return 1;case`collapse`:return 2;default:return 0}}},Ro={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`}}},zo={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`}}},Bo=e=>e!==0,Vo=e=>e===3||e===4,Ho={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}}},Uo={name:`z-index`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>{if(t.type===20)return{auto:!0,order:0};if(k(t))return{auto:!1,order:t.number};throw Error(`Invalid z-index number parsed`)}},Wo={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`)}},Go={name:`opacity`,initialValue:`1`,type:0,prefix:!1,parse:(e,t)=>k(t)?t.number:1},Ko={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}}},qo={name:`text-decoration-thickness`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>{if(A(t))switch(t.value){case`auto`:return`auto`;case`from-font`:return`from-font`}return O(t)?t.number:`auto`}},Jo={name:`text-underline-offset`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>A(t)&&t.value===`auto`?`auto`:O(t)?t.number:`auto`},Yo={name:`font-weight`,initialValue:`normal`,type:0,prefix:!1,parse:(e,t)=>{if(k(t))return t.number;if(A(t))switch(t.value){case`bold`:return 700;default:return 400}return 400}},Xo={name:`font-variant`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>t.filter(A).map(e=>e.value)},Zo={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`}}},Qo={name:`duration`,initialValue:`0s`,prefix:!1,type:1,parse:(e,t)=>t.filter(O).map(t=>Wo.parse(e,t))},$o={name:`box-shadow`,initialValue:`none`,type:1,prefix:!1,parse:(e,t)=>t.length===1&&rn(E(t,0),`none`)?[]:M(t).map(t=>{let n={color:255,offsetX:I,offsetY:I,blur:I,spread:I,inset:!1},r=0;for(let i=0;i{let n=[0,1,2],r=[];return t.filter(A).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}},ts={name:`-webkit-text-stroke-color`,initialValue:`currentcolor`,prefix:!1,type:3,format:`color`},ns={name:`-webkit-text-stroke-width`,initialValue:`0`,type:0,prefix:!1,parse:(e,t)=>O(t)?t.number:0},rs={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},is={name:`object-fit`,initialValue:`fill`,prefix:!1,type:1,parse:(e,t)=>t.filter(A).reduce((e,t)=>e|as(t.value),0)},as=e=>{switch(e){case`contain`:return 2;case`cover`:return 4;case`none`:return 8;case`scale-down`:return 16}return 0},os={name:`text-overflow`,initialValue:`clip`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`ellipsis`:return 1;default:return 0}}},ss={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`},cs=new Set(Object.values(K)),ls={name:`mix-blend-mode`,initialValue:`normal`,type:2,prefix:!1,parse:(e,t)=>cs.has(t)?t:K.NORMAL},us={name:`filter`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>{if(t.length===1){let e=E(t,0);if(e.type===20&&e.value===`none`)return null}let n=[];for(let e of t)if(e.type===18){let t=e,r=ds(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})`)}}return n.length>0?n.join(` `):null}},ds=e=>{let t=[];for(let n of e){if(n.type===31){t.push(` `);continue}n.type===18?t.push(`${n.name}(${ds(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()},fs={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}}},ps={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},ms={name:`object-position`,initialValue:`50% 50%`,prefix:!1,type:1,parse:(e,t)=>{let n=[],r=0;for(;r{let n=[],r=t.filter(j);for(let e of r)A(e)&&hs.has(e.value)&&n.push(e.value);return n.length>0?n:[`normal`]}},_s={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=>j(e)&&ya(e));return n.length===0?null:va.parse(e,E(n,0))}},vs=e=>{let t=[...e];if(t.length===1){let e=E(t,0);t.push(e,e,e)}else t.length===2?t.push(E(t,0),E(t,1)):t.length===3&&t.push(E(t,1));return[E(t,0),E(t,1),E(t,2),E(t,3)]},ys={name:`border-image-slice`,initialValue:`100%`,prefix:!1,type:1,parse:(e,t)=>{let n=t.filter(an),r=[],i=!1,a=`percent`;for(let e of n){if(A(e)&&e.value===`fill`){i=!0;continue}e.type===17?(r.push(e.number),a=`number`):e.type===16&&(r.push(e.number),a=`percent`)}let[o,s,c,l]=vs(r.length>0?r:[100]);return{top:o,right:s,bottom:c,left:l,fill:i,unit:a}}},bs=e=>{switch(e){case`repeat`:return 1;case`round`:return 2;case`space`:return 3;default:return 0}},xs={name:`border-image-repeat`,initialValue:`stretch`,prefix:!1,type:1,parse:(e,t)=>{let n=t.filter(an),r=[];for(let e of n)A(e)&&r.push(bs(e.value));let i=r[0]??0;return{horizontal:i,vertical:r[1]??i}}},Ss={name:`box-decoration-break`,initialValue:`slice`,prefix:!1,type:2,parse:(e,t)=>{switch(t){case`clone`:return 1;default:return 0}}},Cs={name:`accent-color`,initialValue:`auto`,prefix:!1,type:0,parse:(e,t)=>A(t)&&t.value===`auto`?null:U.parse(e,t)},ws={name:`-webkit-text-fill-color`,initialValue:`currentcolor`,prefix:!0,type:0,parse:(e,t)=>A(t)&&t.value===`currentcolor`?null:U.parse(e,t)},Ts={name:`isolation`,initialValue:`auto`,prefix:!1,type:2,parse:(e,t)=>+(t===`isolate`)},Es={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}}},Ds={name:`outline-color`,initialValue:`currentcolor`,prefix:!1,type:0,parse:(e,t)=>A(t)&&(t.value===`currentcolor`||t.value===`invert`)?null:U.parse(e,t)},Os={name:`outline-width`,initialValue:`medium`,prefix:!1,type:0,parse:Wa.parse},ks={name:`outline-offset`,initialValue:`0px`,prefix:!1,type:0,parse:(e,t)=>O(t)||k(t)?t.number:0},As={name:`backdrop-filter`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>us.parse(e,t)},js={name:`mask-image`,initialValue:`none`,prefix:!1,type:1,skipCache:!0,parse:xa.parse},Ms={name:`mask-position`,initialValue:`0%`,prefix:!1,type:1,parse:Ca.parse},Ns={name:`mask-repeat`,initialValue:`repeat`,prefix:!1,type:1,parse:wa.parse},Ps={name:`mask-size`,initialValue:`auto`,prefix:!1,type:1,parse:Ea.parse},Fs=[`dot`,`circle`,`double-circle`,`triangle`,`sesame`],Is={name:`text-emphasis-style`,initialValue:`none`,prefix:!1,type:1,parse:(e,t)=>{let n=t.filter(an);if(n.length===0)return null;let r=E(n,0);if(r.type===0)return r.value;if(A(r)){if(r.value===`none`)return null;if(r.value!==`filled`&&r.value!==`open`&&Fs.indexOf(r.value)===-1)return r.value}let i=!0,a=`circle`;for(let e of n)A(e)&&(e.value===`filled`?i=!0:e.value===`open`?i=!1:Fs.indexOf(e.value)!==-1&&(a=e.value));return{fill:i,shape:a}}},Ls={name:`text-emphasis-color`,initialValue:`currentcolor`,prefix:!1,type:0,parse:(e,t)=>A(t)&&t.value===`currentcolor`?null:U.parse(e,t)},Rs={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(A(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}}},zs=e=>{let t=[...e];if(t.length===1){let e=E(t,0);t.push(e,e,e)}else t.length===2?t.push(E(t,0),E(t,1)):t.length===3&&t.push(E(t,1));return[E(t,0),E(t,1),E(t,2),E(t,3)]},Bs=e=>A(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,Vs=e=>{let t=[];for(let n of e){if(n.type===31)continue;let e=Bs(n);if(!e)return null;t.push(e)}return t.length===0||t.length>4?null:zs(t)},Hs=[[`animationDuration`,Qo,`animationDuration`],[`backgroundClip`,Bi,`backgroundClip`],[`backgroundColor`,Vi,`backgroundColor`],[`backgroundImage`,xa,`backgroundImage`],[`backgroundOrigin`,Sa,`backgroundOrigin`],[`backgroundPosition`,Ca,`backgroundPosition`],[`backgroundRepeat`,wa,`backgroundRepeat`],[`backgroundSize`,Ea,`backgroundSize`],[`borderTopColor`,ka,`borderTopColor`],[`borderRightColor`,Aa,`borderRightColor`],[`borderBottomColor`,ja,`borderBottomColor`],[`borderLeftColor`,Ma,`borderLeftColor`],[`borderTopLeftRadius`,Pa,`borderTopLeftRadius`],[`borderTopRightRadius`,Fa,`borderTopRightRadius`],[`borderBottomRightRadius`,Ia,`borderBottomRightRadius`],[`borderBottomLeftRadius`,La,`borderBottomLeftRadius`],[`borderTopStyle`,za,`borderTopStyle`],[`borderRightStyle`,Ba,`borderRightStyle`],[`borderBottomStyle`,Va,`borderBottomStyle`],[`borderLeftStyle`,Ha,`borderLeftStyle`],[`borderTopWidth`,Wa,`borderTopWidth`],[`borderRightWidth`,Ga,`borderRightWidth`],[`borderBottomWidth`,Ka,`borderBottomWidth`],[`borderLeftWidth`,qa,`borderLeftWidth`],[`boxShadow`,$o,`boxShadow`],[`clipPath`,io,`clipPath`],[`color`,ao,`color`],[`direction`,oo,`direction`],[`display`,Oi,`display`],[`fontFamily`,so,`fontFamily`],[`fontSize`,co,`fontSize`],[`fontStyle`,Zo,`fontStyle`],[`fontVariant`,Xo,`fontVariant`],[`fontWeight`,Yo,`fontWeight`],[`letterSpacing`,lo,`letterSpacing`],[`lineBreak`,uo,`lineBreak`],[`lineHeight`,fo,`lineHeight`],[`listStyleImage`,mo,`listStyleImage`],[`listStylePosition`,ho,`listStylePosition`],[`listStyleType`,pi,`listStyleType`],[`marginTop`,_o,`marginTop`],[`marginRight`,vo,`marginRight`],[`marginBottom`,yo,`marginBottom`],[`marginLeft`,bo,`marginLeft`],[`opacity`,Go,`opacity`],[`overflowWrap`,xo,`overflowWrap`],[`paddingTop`,Co,`paddingTop`],[`paddingRight`,wo,`paddingRight`],[`paddingBottom`,To,`paddingBottom`],[`paddingLeft`,Eo,`paddingLeft`],[`paintOrder`,es,`paintOrder`],[`position`,Oo,`position`],[`textAlign`,Do,`textAlign`],[`textDecorationStyle`,Ko,`textDecorationStyle`],[`textDecorationThickness`,qo,`textDecorationThickness`],[`textUnderlineOffset`,Jo,`textUnderlineOffset`],[`textShadow`,ko,`textShadow`],[`textTransform`,Ao,`textTransform`],[`textOverflow`,os,`textOverflow`],[`transform`,jo,`transform`],[`transformOrigin`,Fo,`transformOrigin`],[`rotate`,Io,`rotate`],[`visibility`,Lo,`visibility`],[`webkitTextStrokeColor`,ts,`webkitTextStrokeColor`],[`webkitTextStrokeWidth`,ns,`webkitTextStrokeWidth`],[`webkitLineClamp`,rs,`webkitLineClamp`],[`wordBreak`,Ro,`wordBreak`],[`whiteSpace`,zo,`whiteSpace`],[`writingMode`,Ho,`writingMode`],[`zIndex`,Uo,`zIndex`],[`objectFit`,is,`objectFit`],[`imageRendering`,ss,`imageRendering`],[`mixBlendMode`,ls,`mixBlendMode`],[`filter`,us,`filter`],[`fontVariantLigatures`,fs,`fontVariantLigatures`],[`zoom`,ps,`zoom`],[`objectPosition`,ms,`objectPosition`],[`backgroundBlendMode`,gs,`backgroundBlendMode`],[`borderImageSource`,_s,`borderImageSource`],[`borderImageSlice`,ys,`borderImageSlice`],[`borderImageRepeat`,xs,`borderImageRepeat`],[`boxDecorationBreak`,Ss,`boxDecorationBreak`],[`accentColor`,Cs,`accentColor`],[`webkitTextFillColor`,ws,`webkitTextFillColor`],[`isolation`,Ts,`isolation`],[`outlineColor`,Ds,`outlineColor`],[`outlineStyle`,Es,`outlineStyle`],[`outlineWidth`,Os,`outlineWidth`],[`outlineOffset`,ks,`outlineOffset`],[`backdropFilter`,As,`backdropFilter`],[`maskImage`,js,`maskImage`],[`maskPosition`,Ms,`maskPosition`],[`maskRepeat`,Ns,`maskRepeat`],[`maskSize`,Ps,`maskSize`],[`textEmphasisStyle`,Is,`textEmphasisStyle`],[`textEmphasisColor`,Ls,`textEmphasisColor`],[`textEmphasisPosition`,Rs,`textEmphasisPosition`],[`borderImageWidth`,{name:`border-image-width`,initialValue:`auto`,prefix:!1,type:1,parse:(e,t)=>{let n=Vs(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}}},`borderImageWidth`],[`borderImageOutset`,{name:`border-image-outset`,initialValue:`0px`,prefix:!1,type:1,parse:(e,t)=>{let n=Vs(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}}},`borderImageOutset`],[`webkitBoxReflect`,{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&&A(a)){if(a.value===`below`||a.value===`above`||a.value===`left`||a.value===`right`){n=a.value;continue}if(a.value===`none`)return null}if(r===0&&O(a)&&a.unit===`px`){r=a.number;continue}if(i===null&&ya(a)){i=va.parse(e,a);continue}}return n===null?null:{direction:n,offset:r,mask:i}}},`webkitBoxReflect`]],Us=/* @__PURE__ */ new Map,Ws=(e,t,n)=>{let r=n==null?t.initialValue:n.toString();r.trim()===``&&(r=t.initialValue);let i=Us.get(t);if(i){let e=i.get(r);if(e!==void 0)return i.delete(r),i.set(r,e),e}let a=en.get();a.write(r);let o=new tn(a.read());en.release(a);let s=(()=>{switch(t.type){case 2:{let n=o.parseComponentValue();return t.parse(e,A(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 Tn.parse(e,o.parseComponentValue());case`color`:return U.parse(e,o.parseComponentValue());case`image`:return va.parse(e,o.parseComponentValue());case`length`:{let e=o.parseComponentValue();return hn(e)?e:I}case`length-percentage`:{let e=o.parseComponentValue();return F(e)?e:I}case`time`:return Wo.parse(e,o.parseComponentValue())}}})();if(i||(i=/* @__PURE__ */ new Map,Us.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 Gs=class{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}},Ks=class{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}},qs=class{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}},Js=class{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()}},Ys=class{get border(){return this._border??=new Gs(this)}get background(){return this._background??=new Ks(this)}get font(){return this._font??=new qs(this)}get layout(){return this._layout??=new Js(this)}constructor(e,t){if(t.display===`none`){this.display=0;for(let[t,n]of Hs)t!==`display`&&(this[t]=Ws(e,n,void 0));Object.assign(this,Xs(e,null));return}for(let[n,r,i]of Hs)this[n]=Ws(e,r,t[i]);Object.assign(this,Xs(e,t))}isVisible(){return this.display>0&&this.opacity>0&&this.visibility===0}isTransparent(){return On(this.backgroundColor)}isTransformed(){return this.transform!==null||this.rotate!==null}isPositioned(){return this.position!==0}isPositionedWithZIndex(){return this.isPositioned()&&!this.zIndex.auto}isFloating(){return this.float!==0}isInlineLevel(){return W(this.display,4)||W(this.display,33554432)||W(this.display,268435456)||W(this.display,536870912)||W(this.display,67108864)||W(this.display,134217728)}};let Xs=(e,t)=>{let n=(e,n)=>{if(t)return t[e]??n},r=Ws(e,ji,n(`overflow`));return{float:Ws(e,Ai,n(`cssFloat`)),textDecorationColor:Ws(e,Mi,n(`textDecorationColor`,n(`color`))),textDecorationLine:Ws(e,Ni,n(`textDecorationLine`,n(`textDecoration`))),overflowX:r[0],overflowY:r[+(r.length>1)]}};var Zs=class{constructor(e,t){this.content=Ws(e,Pi,t.content),this.quotes=Ws(e,Fi,t.quotes)}},Qs=class{constructor(e,t){this.counterIncrement=Ws(e,Ri,t.counterIncrement),this.counterReset=Ws(e,zi,t.counterReset)}};let $s=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}},ec=(e,t)=>{let n=$s(e);return n===1||t===n};var tc=class{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!Gr(e)||!ii(e)&&!e.hasAttribute(`data-html2canvas-ignore`)&&(typeof this.options.ignoreElements!=`function`||!this.options.ignoreElements(e))}shouldCloneStyleElement(e){return!this.options.copyStyles||!Gr(e)||!ri(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(!si(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();if(!i||!Array.isArray(i)){this.context.logger.warn(`assignedNodes() did not return a valid array`,e),this.cloneSlotFallbackContent(e,t,n);return}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)Gr(r)&&si(r)?this.cloneSlotElement(r,t,n):this.safeAppendClonedChild(t,r,n)}cloneLightDOMChildren(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)this.appendChildNode(t,r,n)}cloneSlotElementAsLightDOM(e,t,n){if(!si(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)Gr(r)&&si(r)?this.cloneSlotElementAsLightDOM(r,t,n):this.appendChildNode(t,r,n)}};let nc=[`all`,`d`,`content`],rc=(e,t)=>{let n=[];for(let t=e.length-1;t>=0;t--){let r=e.item(t);if(nc.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},ic=`___html2canvas___pseudoelement_before`,ac=`___html2canvas___pseudoelement_after`,oc=`{ content: "" !important; display: none !important; }`,sc=(e,t)=>{cc(e,`.${ic}:before${oc} .${ac}:after${oc}`,t)},cc=(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 lc=class{constructor(e,t){this.context=e,this.counters=t,this.quoteDepth=0}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 Qs(this.context,n));let o=new Zs(this.context,n),s=a.createElement(`html2canvaspseudoelement`);rc(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(A);n.length&&n[0]&&s.appendChild(a.createTextNode(e.getAttribute(n[0].value)||``))}else if(t.name===`counter`){let[e,n]=t.values.filter(j);if(e&&A(e)){let t=this.counters.getCounterValue(e.value),r=n&&A(n)?pi.parse(this.context,n.value):3;s.appendChild(a.createTextNode(Di(t,r,!1)))}}else if(t.name===`counters`){let[e,n,r]=t.values.filter(j);if(e&&A(e)){let t=this.counters.getCounterValues(e.value),i=r&&A(r)?pi.parse(this.context,r.value):3,o=n&&n.type===0?n.value:``,c=t.map(e=>Di(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(Ii(o.quotes,this.quoteDepth++,!0)));break;case`close-quote`:s.appendChild(a.createTextNode(Ii(o.quotes,--this.quoteDepth,!1)));break;default:s.appendChild(a.createTextNode(t.value))}}),s.className=`${ic} ${ac}`;let c=r===0?` ${ic}`:` ${ac}`;return qr(t)?t.className.baseValue+=c:t.className+=c,s}};let uc=(e,t,n)=>{let r=e.createElement(`iframe`);return r.className=`html2canvas-container`,r.style.visibility=`hidden`,r.style.position=`fixed`,r.style.left=`-10000px`,r.style.top=`0px`,r.style.border=`0`,r.width=t.width.toString(),r.height=t.height.toString(),r.scrolling=`no`,r.setAttribute(`data-html2canvas-ignore`,`true`),(n||e.body).appendChild(r),r},dc=e=>new Promise(t=>{if(e.complete){t();return}if(!e.src){t();return}e.onload=t,e.onerror=t}),fc=e=>Promise.all([].slice.call(e.images,0).map(dc)),pc=e=>new Promise((t,n)=>{let r=e.contentWindow;if(!r)return n(`No window assigned for iframe`);let i=r.document;r.onload=e.onload=()=>{r.onload=e.onload=null;let n=0,a=setInterval(()=>{n++,(i.body.childNodes.length>0&&i.readyState===`complete`||n>=600)&&(clearInterval(a),t(e))},50)}}),mc=e=>{let t=``;return e&&(t+=`/g,`>`)),e.publicId?(t+=` PUBLIC "`+e.publicId.replace(/"/g,`"`)+`"`,e.systemId&&(t+=` "`+e.systemId.replace(/"/g,`"`)+`"`)):e.systemId&&(t+=` SYSTEM "`+e.systemId.replace(/"/g,`"`)+`"`),t+=`>`),t},hc=(e,t,n)=>{e&&e.defaultView&&(t!==e.defaultView.pageXOffset||n!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,n)},gc=([e,t,n])=>{e.scrollLeft=t,e.scrollTop=n},_c=(e,t)=>{let n=e.ownerDocument.createElement(`base`);n.href=t;let r=e.getElementsByTagName(`head`).item(0);r?.insertBefore(n,r?.firstChild??null)},vc=(e,t,n,r)=>{let i=uc(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=pc(i).then(async()=>{r.scrolledElements.forEach(gc),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 c.fonts&&c.fonts.ready&&await c.fonts.ready,/(AppleWebKit)/g.test(navigator.userAgent)&&await fc(c),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=mc(document.doctype)+``;try{let e=t.defaultView,n=e&&e.trustedTypes,r=n?.getPolicy?.(`html2canvas-pro`);!r&&n&&(r=n.createPolicy(`html2canvas-pro`,{createHTML:e=>e}));let i=r?r.createHTML(d):d;c.write(i)}catch{c.write(d)}hc(t,a,o),c.close();let f=c.adoptNode(r.documentElement);return _c(f,u),c.replaceChild(f,c.documentElement),l},yc=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};for(var bc=class{constructor(e,t,n){if(this.context=e,this.options=n,this.scrolledElements=[],this.referenceElement=t,this.counters=new mi,this.pseudoContents=new lc(e,this.counters),this.slotCloner=new tc((e,t)=>this.cloneNode(e,t),{ignoreElements:n.ignoreElements,copyStyles:n.copyStyles??!0},e),!t.ownerDocument)throw Error(`Cloned element does not have an owner document`);if(!this.options.iframeContainer){let e=yc(t);e&&(this.options.iframeContainer=e)}this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}toIFrame(e,t){return vc(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})}createElementClone(e){if(ec(e,2))debugger;if($r(e))return this.createCanvasClone(e);if(ei(e))return this.createVideoClone(e);if(ri(e))return this.createStyleClone(e);let t=e.cloneNode(!1);return ti(t)&&(ti(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=``),t.loading===`lazy`&&(t.loading=`eager`)),ui(t)&&!qr(t)?this.createCustomElementClone(e,t):t}createCustomElementClone(e,t){let n=document.createElement(`div`);n.className=t.className,rc(t.style,n);let r=t.attributes;for(let e=0;et&&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(Kr(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);let n=e.ownerDocument.defaultView;if(n&&Gr(e)&&(Jr(e)||qr(e))){let r=this.createElementClone(e);r.style.transitionProperty=`none`;let i=n.getComputedStyle(e),a=fi(e);this.referenceElement===e&&Jr(r)&&(this.clonedReferenceElement=r),Qr(r)&&sc(r,this.options.cspNonce);let o=this.counters.parse(new Qs(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);let a=n.getComputedStyle(e,`:after`),o=this.pseudoContents.resolvePseudoContent(e,r,a,1);o&&r.appendChild(o)}return ui(e)&&(t=!0),ei(e)||this.cloneChildNodes(e,r,t),this.counters.pop(o),(i&&(this.options.copyStyles||qr(e))&&!ni(e)||t)&&rc(i,r),(e.scrollTop!==0||e.scrollLeft!==0)&&this.scrolledElements.push([r,e.scrollLeft,e.scrollTop]),(ai(e)||oi(e))&&(ai(r)||oi(r))&&(r.value=e.value),r}return e.cloneNode(!1)}static destroy(e){return e.parentNode?(e.parentNode.removeChild(e),!0):!1}},xc=class{static normalizeElement(e,t){let n={};return Jr(e)?(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)`),t.rotate!==null&&(n.rotate=e.style.rotate,e.style.rotate=`0deg`,n.transform===void 0&&(n.transform=e.style.transform,e.style.transform=`translate(0, 0)`)),n):n}static restoreElement(e,t){Jr(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))}},Sc=class{constructor(e,t,n={}){if(this.context=e,this.textNodes=[],this.elements=[],this.createsStackingContext=!1,this.createsRealStackingContext=!1,this.isListOwner=!1,this.debugRender=!1,ec(t,3))debugger;if(this.styles=new Ys(e,e.config.window.getComputedStyle(t,null)),n.normalizeDom!==!1&&Jr(t)&&(this.originalStyles=xc.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))}}ec(t,4)&&(this.debugRender=!0)}restore(){this.originalStyles&&this.originalElement&&(xc.restoreElement(this.originalElement,this.originalStyles),this.originalStyles=void 0,this.originalElement=void 0)}restoreTree(){this.restore();for(let e of this.elements)e.restoreTree()}},Cc=`AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACA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wU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAX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UBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAA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ADgAOAA4ADgAOAA4AAAAAAAAAAAA=`,wc=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Tc=typeof Uint8Array>`u`?[]:/* @__PURE__ */ new Uint8Array(256),Ec=0;Ec>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},Oc=function(e){for(var t=e.length,n=[],r=0;r>Ac,Fc=(1<>Ac)+32,Lc=65536>>jc,Rc=(1<=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>Ac],t=(t<>Ac)],t=(t<>jc),t=this.index[t],t+=e>>Ac&Rc,t=this.index[t],t=(t<`u`?[]:/* @__PURE__ */ new Uint8Array(256),Gc=0;Gc=55296&&i<=56319&&n>10)+55296,o%1024+56320)),(i+1===n||r.length>16384)&&(a+=String.fromCharCode.apply(String,r),r.length=0)}return a},cl=Vc(Cc),ll=`×`,ul=`÷`,dl=function(e){return cl.get(e)},fl=function(e,t,n){var r=n-2,i=t[r],a=t[n-1],o=t[n];if(a===qc&&o===Jc)return ll;if(a===qc||a===Jc||a===Yc||o===qc||o===Jc||o===Yc)return ul;if(a===Qc&&[Qc,$c,tl,nl].indexOf(o)!==-1||(a===tl||a===$c)&&(o===$c||o===el)||(a===nl||a===el)&&o===el||o===rl||o===Xc||o===Zc||a===Kc)return ll;if(a===rl&&o===il){for(;i===Xc;)i=t[--r];if(i===il)return ll}if(a===al&&o===al){for(var s=0;i===al;)s++,i=t[--r];if(s%2==0)return ll}return ul},pl=function(e){var t=ol(e),n=t.length,r=0,i=0,a=t.map(dl);return{next:function(){if(r>=n)return{done:!0,value:null};for(var e=ll;r{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},gl=e=>{let t=e.createElement(`boundtest`);t.style.width=`50px`,t.style.display=`block`,t.style.fontSize=`12px`,t.style.letterSpacing=`0px`,t.style.wordSpacing=`0px`,e.body.appendChild(t);let n=e.createRange();t.innerHTML=typeof``.repeat==`function`?`👨`.repeat(10):``;let r=t.firstChild,i=c(r.data).map(e=>l(e)),a=0,o={},s=i.every((e,t)=>{n.setStart(r,a),n.setEnd(r,a+e.length);let i=n.getBoundingClientRect();a+=e.length;let s=i.x>o.x||i.y>o.y;return o=i,t===0||s});return e.body.removeChild(t),s},_l=()=>new Image().crossOrigin!==void 0,vl=()=>typeof new XMLHttpRequest().responseType==`string`,yl=e=>{let t=new Image,n=e.createElement(`canvas`),r=n.getContext(`2d`);if(!r)return!1;t.src=`data:image/svg+xml,`;try{r.drawImage(t,0,0),n.toDataURL()}catch{return!1}return!0},bl=e=>e[0]===0&&e[1]===255&&e[2]===0&&e[3]===255,xl=e=>{let t=e.createElement(`canvas`);t.width=100,t.height=100;let n=t.getContext(`2d`);if(!n)return Promise.reject(/* @__PURE__ */ Error(`Failed to get 2D rendering context`));n.fillStyle=`rgb(0, 255, 0)`,n.fillRect(0,0,100,100);let r=new Image,i=t.toDataURL();r.src=i;let a=Sl(100,100,0,0,r);return n.fillStyle=`red`,n.fillRect(0,0,100,100),Cl(a).then(t=>{n.drawImage(t,0,0);let r=n.getImageData(0,0,100,100).data;n.fillStyle=`red`,n.fillRect(0,0,100,100);let a=e.createElement(`div`);return a.style.backgroundImage=`url(${i})`,a.style.height=`100px`,bl(r)?Cl(Sl(100,100,0,0,a)):Promise.reject(/* @__PURE__ */ Error(`ForeignObject rendering not supported`))}).then(e=>(n.drawImage(e,0,0),bl(n.getImageData(0,0,100,100).data))).catch(()=>!1)},Sl=(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},Cl=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))}`}),q={get SUPPORT_RANGE_BOUNDS(){"use strict";let e=hl(document);return Object.defineProperty(q,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_WORD_BREAKING(){"use strict";let e=q.SUPPORT_RANGE_BOUNDS&&gl(document);return Object.defineProperty(q,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){"use strict";let e=yl(document);return Object.defineProperty(q,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){"use strict";let e=typeof Array.from==`function`&&typeof window.fetch==`function`?xl(document):Promise.resolve(!1);return Object.defineProperty(q,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){"use strict";let e=_l();return Object.defineProperty(q,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){"use strict";let e=vl();return Object.defineProperty(q,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){"use strict";let e=`withCredentials`in new XMLHttpRequest;return Object.defineProperty(q,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){"use strict";let e=!!(typeof Intl<`u`&&Intl.Segmenter);return Object.defineProperty(q,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}};var wl=class{constructor(e,t){this.text=e,this.bounds=t}};let Tl=(e,t,n,r)=>{let i=Ml(t,n),o=[],s=0;return i.forEach(t=>{if(n.textDecorationLine.length||t.trim().length>0){if(q.SUPPORT_RANGE_BOUNDS){let n=Dl(r,s,t.length).getClientRects();if(n.length>1){let n=Al(t),i=0;n.forEach(t=>{o.push(new wl(t,a.fromDOMRectList(e,Dl(r,i+s,t.length).getClientRects()))),i+=t.length})}else o.push(new wl(t,a.fromDOMRectList(e,n)))}else{let n=r.splitText(t.length);o.push(new wl(t,El(e,r))),r=n}}else q.SUPPORT_RANGE_BOUNDS||(r=r.splitText(t.length));s+=t.length}),o},El=(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},Dl=(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},Ol=/* @__PURE__ */ new Map,kl=e=>{let t=Ol.get(e);if(!t){let n=Intl.Segmenter;t=new n(void 0,{granularity:e}),Ol.set(e,t)}return t},Al=e=>q.SUPPORT_NATIVE_TEXT_SEGMENTATION?Array.from(kl(`grapheme`).segment(e)).map(e=>e.segment):ml(e),jl=(e,t)=>q.SUPPORT_NATIVE_TEXT_SEGMENTATION?Array.from(kl(`word`).segment(e)).map(e=>e.segment):Pl(e,t),Ml=(e,t)=>Bo(t.writingMode)?Al(e):t.letterSpacing===0?jl(e,t):Al(e),Nl=[32,160,4961,65792,65793,4153,4241],Pl=(e,t)=>{let n=_t(e,{lineBreak:t.lineBreak,wordBreak:t.overflowWrap===`break-word`?`break-word`:t.wordBreak}),r=[],i;for(;!(i=n.next()).done;)if(i.value){let e=c(i.value.slice()),t=``;e.forEach(e=>{Nl.indexOf(e)===-1?t+=l(e):(t.length&&r.push(t),r.push(l(e)),t=``)}),t.length&&r.push(t)}return r};var Fl=class{constructor(e,t,n){this.text=Il(t.data,n.textTransform),this.text.length!==t.data.length&&(t.data=this.text),this.textBounds=Tl(e,this.text,n,t)}};let Il=(e,t)=>{switch(t){case 1:return e.toLowerCase();case 3:return e.replace(Ll,Rl);case 2:return e.toUpperCase();default:return e}},Ll=/(^|\s|:|-|\(|\))([a-z])/g,Rl=(e,t,n)=>e.length>0?t+n.toUpperCase():e;var zl=class extends Sc{constructor(e,t){super(e,t),this.src=t.currentSrc||t.src,this.intrinsicWidth=t.naturalWidth,this.intrinsicHeight=t.naturalHeight,this.context.cache.addImage(this.src)}},Bl=class extends Sc{constructor(e,t){super(e,t),this.canvas=t,this.intrinsicWidth=t.width,this.intrinsicHeight=t.height}};let Vl=[`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`],Hl=(e,t)=>{let n=t.getAttribute(`style`);Vl.forEach(e=>t.style.removeProperty(e));let r=e.serializeToString(t);return n===null?t.removeAttribute(`style`):t.setAttribute(`style`,n),r};var Ul=class extends Sc{constructor(e,t){super(e,t);let n=new XMLSerializer,r=o(e,t);t.setAttribute(`width`,`${r.width}px`),t.setAttribute(`height`,`${r.height}px`),this.svg=`data:image/svg+xml,${encodeURIComponent(Hl(n,t))}`,this.intrinsicWidth=t.width.baseVal.value,this.intrinsicHeight=t.height.baseVal.value,this.context.cache.addImage(this.svg)}},Wl=class extends Sc{constructor(e,t){super(e,t),this.value=t.value}},Gl=class extends Sc{constructor(e,t){super(e,t),this.start=t.start,this.reversed=typeof t.reversed==`boolean`&&t.reversed===!0}};let Kl=[{type:15,flags:0,unit:`px`,number:3}],ql=[{type:16,flags:0,number:50}],Jl=e=>e.width>e.height?new a(e.left+(e.width-e.height)/2,e.top,e.height,e.height):e.width{let t=e.type===`password`?Array(e.value.length+1).join(`•`):e.value;return t.length===0?e.placeholder||``:t},Xl=e=>e.value.length===0&&!!e.placeholder;var Zl=class extends Sc{constructor(e,t){switch(super(e,t),this.type=t.type.toLowerCase(),this.checked=t.checked,this.value=Yl(t),this.isPlaceholder=Xl(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=Jl(this.bounds)),this.type){case`checkbox`:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=Kl;break;case`radio`:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=ql}}},Ql=class extends Sc{constructor(e,t){super(e,t);let n=t.options[t.selectedIndex||0];this.value=n&&n.text||``}},$l=class extends Sc{constructor(e,t){super(e,t),this.value=t.value}},eu=class extends Sc{constructor(e,t,n){super(e,t),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{if(t.contentWindow&&t.contentWindow.document&&t.contentWindow.document.documentElement&&this.parseTreeFn){this.tree=this.parseTreeFn(e,t.contentWindow.document.documentElement);let n=t.contentWindow.document.documentElement?Ur(e,getComputedStyle(t.contentWindow.document.documentElement).backgroundColor):0,r=t.contentWindow.document.body?Ur(e,getComputedStyle(t.contentWindow.document.body).backgroundColor):0;this.backgroundColor=On(n)?On(r)?this.styles.backgroundColor:r:n}}catch{}}};let tu=[`OL`,`UL`,`MENU`],nu=(e,t,n,r)=>{for(let i=t.firstChild,a;i;i=a)a=i.nextSibling,ru(e,i,n,r)},ru=(e,t,n,r)=>{if(Kr(t)&&t.data.length>0)n.textNodes.push(new Fl(e,t,n.styles));else if(Gr(t)){if(si(t)&&t.assignedNodes)t.assignedNodes().forEach(t=>ru(e,t,n,r));else{let i=iu(e,t);i.styles.isVisible()&&(ou(t,i,r)?i.createsRealStackingContext=!0:su(i.styles)&&(i.createsStackingContext=!0),tu.indexOf(t.tagName)!==-1&&(i.isListOwner=!0),n.elements.push(i),t.shadowRoot?nu(e,t.shadowRoot,i,r):!ai(t)&&!Zr(t)&&!oi(t)&&nu(e,t,i,r))}}},iu=(e,t)=>ti(t)?new zl(e,t):$r(t)?new Bl(e,t):Zr(t)?new Ul(e,t):ci(t)?new Wl(e,t):li(t)?new Gl(e,t):Yr(t)?new Zl(e,t):oi(t)?new Ql(e,t):ai(t)?new $l(e,t):ni(t)?new eu(e,t,au):new Sc(e,t),au=(e,t)=>{let n=iu(e,t);return n.createsRealStackingContext=!0,nu(e,t,n,n),n},ou=(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()||Qr(e)&&n.styles.isTransparent(),su=e=>e.isPositioned()||e.isFloating()?!0:W(e.display,268435456)||W(e.display,33554432)||W(e.display,536870912)||W(e.display,134217728),cu=(e,t)=>e.length===t.length&&e.some((e,n)=>e===t[n]),lu=(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{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 uu=(e,t,n)=>new J(e.x+(t.x-e.x)*n,e.y+(t.y-e.y)*n);var du=class e{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=uu(this.start,this.startControl,t),i=uu(this.startControl,this.endControl,t),a=uu(this.endControl,this.end,t),o=uu(r,i,t),s=uu(i,a,t),c=uu(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 fu=class{constructor(e){let t=e.styles,n=e.bounds,[r,i]=Sn(t.borderTopLeftRadius,n.width,n.height),[a,o]=Sn(t.borderTopRightRadius,n.width,n.height),[s,c]=Sn(t.borderBottomRightRadius,n.width,n.height),[l,u]=Sn(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=z(t.paddingTop,e.bounds.width),S=z(t.paddingRight,e.bounds.width),ee=z(t.paddingBottom,e.bounds.width),C=z(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=r>0||i>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=r>0||i>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=r>0||i>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+C,n.top+_+x,Math.max(0,r-(b+C)),Math.max(0,i-(_+x)),0):new J(n.left+b+C,n.top+_+x),this.topRightContentBox=a>0||o>0?X(n.left+Math.min(p,n.width+b+C),n.top+_+x,p>n.width+b+C?0:a-b+C,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+C)),n.top+Math.min(m,n.height+_+x),Math.max(0,s-(v+S)),c-(y+ee),2):new J(n.left+n.width-(v+S),n.top+n.height-(y+ee)),this.bottomLeftContentBox=l>0||u>0?X(n.left+b+C,n.top+g,Math.max(0,l-(b+C)),u-(y+ee),3):new J(n.left+b+C,n.top+n.height-(y+ee))}};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 du(new J(e,l),new J(e,l-s),new J(c-o,t),new J(c,t));case 1:return new du(new J(e,t),new J(e+o,t),new J(c,l-s),new J(c,l));case 2:return new du(new J(c,t),new J(c,t+s),new J(e+o,l),new J(e,l));default:return new du(new J(c,l),new J(c-o,l),new J(e,t+s),new J(e,t))}},pu=e=>[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox],mu=e=>[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox],hu=e=>[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox];var gu=class{constructor(e,t,n){this.offsetX=e,this.offsetY=t,this.matrix=n,this.type=0,this.target=6}},_u=class{constructor(e,t){this.path=e,this.target=t,this.type=1}},vu=class{constructor(e){this.opacity=e,this.type=2,this.target=6}},yu=class{constructor(e){this.applyClip=e,this.type=3,this.target=6}};let bu={[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 xu=class{constructor(e){this.mixBlendMode=e,this.type=4,this.target=6,this.compositeOperation=bu[e]}},Su=class e{constructor(t){this.type=5,this.target=6;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(E(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(;o0;){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:E(r,0),offsetY:E(r,1),blur:r.length>2?E(r,2):0,color:i??`rgba(0,0,0,1)`}}static tokenizeFilterArgs(e){let t=[],n=``,r=0;for(let i=0;i0?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 Cu=e=>e.type===0,wu=e=>e.type===1,Tu=e=>e.type===2,Eu=e=>e.type===3,Du=e=>e.type===4,Ou=e=>e.type===5;var ku=class{constructor(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}},Au=class{constructor(e,t){if(this.container=e,this.parent=t,this.effects=[],this.plainEffectsCache=null,this.curves=new fu(this.container),this.container.styles.opacity<1&&this.effects.push(new vu(this.container.styles.opacity)),this.container.styles.rotate!==null){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+z(e[0],this.container.bounds.width),n=this.container.bounds.top+z(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 gu(t,n,o))}if(this.container.styles.transform!==null){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+z(e[0],this.container.bounds.width),n=this.container.bounds.top+z(e[1],this.container.bounds.height),r=this.container.styles.transform;this.effects.push(new gu(t,n,r))}if(ju(this.container.styles)){let e=pu(this.curves),t=hu(this.curves);cu(e,t)?this.effects.push(new _u(e,6)):(this.effects.push(new _u(e,2)),this.effects.push(new _u(t,4)))}if(this.container.styles.clipPath.type!==0){let e=Nu(this.container.styles.clipPath,this.container.bounds);e&&this.effects.push(e)}if(this.container.styles.mixBlendMode!==K.NORMAL&&this.effects.push(new xu(this.container.styles.mixBlendMode)),this.container.styles.filter!==null&&this.effects.push(new Su(this.container.styles.filter)),this.container.styles.zoom!==1){let e=this.container.styles.transformOrigin,t=this.container.bounds.left+z(e[0],this.container.bounds.width),n=this.container.bounds.top+z(e[1],this.container.bounds.height),r=this.container.styles.zoom,i=[r,0,0,r,0,0];this.effects.push(new gu(t,n,i))}}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||!Ou(n)&&!Tu(n)),a=i(this);for(;r;){let e=i(r).filter(e=>!wu(e));if(n||r.container.styles.position!==0||!r.parent){if(n=[2,3].indexOf(r.container.styles.position)===-1,ju(r.container.styles)){let e=pu(r.curves),t=hu(r.curves);cu(e,t)||a.unshift(new _u(t,6))}a.unshift(...e)}else a.unshift(...e);r=r===t?null:r.parent}return a.filter(t=>W(t.target,e))}};let ju=e=>e.overflowX!==0||e.overflowY!==0,Mu=(e,t,n,r,i)=>e===`closest-side`?Math.min(t-n,r-t):e===`farthest-side`?Math.max(t-n,r-t):z(e,i),Nu=(e,t)=>{let{left:n,top:r,width:i,height:a}=t;switch(e.type){case 1:{let t=z(e.left,i),o=z(e.top,a),s=n+t,c=r+o,l=Math.max(0,i-t-z(e.right,i)),u=Math.max(0,a-o-z(e.bottom,a));return new yu(e=>{e.beginPath(),e.rect(s,c,l,u),e.clip()})}case 2:{let t=n+z(e.cx,i),o=r+z(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):z(e.radius,Math.sqrt(i*i+a*a)/Math.SQRT2),new yu(e=>{e.beginPath(),e.arc(t,o,Math.max(0,s),0,Math.PI*2),e.clip()})}case 3:{let t=n+z(e.cx,i),o=r+z(e.cy,a),s=Mu(e.rx,t,n,n+i,i),c=Mu(e.ry,o,r,r+a,a);return new yu(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+z(e,i),r+z(t,a)]);return new yu(e=>{if(e.beginPath(),t.length>0){e.moveTo(E(E(t,0),0),E(E(t,0),1));for(let n=1;n{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+z(e.x,i),o=r+z(e.y,a),s=Math.max(0,z(e.width,i)),c=Math.max(0,z(e.height,a));return new yu(e=>{e.beginPath(),e.rect(t,o,s,c),e.clip()})}case 0:return null;default:return null}},Pu=(e,t,n,r)=>{e.container.elements.forEach(i=>{let a=i.createsRealStackingContext,o=i.createsStackingContext,s=new Au(i,e);W(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 ku(s);if(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):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);Pu(s,r,a?r:n,c)}else i.styles.isInlineLevel()?t.inlineLevel.push(s):t.nonInlineLevel.push(s),Pu(s,t,n,c);i.isListOwner&&Fu(i,c)})},Fu=(e,t)=>{let n=e instanceof Gl?e.start:1,r=e instanceof Gl&&e.reversed;for(let e=0;e{let t=new Au(e,null),n=new ku(t),r=[];return Pu(t,n,n,r),Fu(t.container,r),n},Lu=e=>{let t=e.bounds,n=e.styles;return t.add(n.borderLeftWidth,n.borderTopWidth,-(n.borderRightWidth+n.borderLeftWidth),-(n.borderTopWidth+n.borderBottomWidth))},Ru=e=>{let t=e.styles,n=e.bounds,r=z(t.paddingLeft,n.width),i=z(t.paddingRight,n.width),a=z(t.paddingTop,n.width),o=z(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))},zu=(e,t)=>e===0?t.bounds:e===2?Ru(t):Lu(t),Bu=(e,t)=>e===0?t.bounds:e===2?Ru(t):Lu(t),Vu=(e,t,n)=>{let r=zu(Gu(e.styles.backgroundOrigin,t),e),i=Bu(Gu(e.styles.backgroundClip,t),e),a=Wu(Gu(e.styles.backgroundSize,t),n,r),[o,s]=a,c=Sn(Gu(e.styles.backgroundPosition,t),r.width-o,r.height-s),l=Ku(Gu(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]},Hu=e=>A(e)&&e.value===`auto`,Uu=e=>typeof e==`number`,Wu=(e,[t,n,r],i)=>{let[a,o]=e;if(!a)return[0,0];if(F(a)&&o&&F(o))return[z(a,i.width),z(o,i.height)];let s=Uu(r);if(A(a)&&(a.value===`contain`||a.value===`cover`))return Uu(r)?i.width/i.height{let n=e[t];return n===void 0?E(e,0):n},Ku=(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))]}},Z=e=>{if(e?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`)};var Q=class extends Error{};let $=e=>{e.width=e.height=0},qu=/* @__PURE__ */ new Map;function Ju(e){if(!e||e===`none`)return{blur:0};let t=qu.get(e);if(t!==void 0)return qu.delete(e),qu.set(e,t),t;let n=Yu(e);if(qu.size>=256){let e=qu.keys().next().value;e!==void 0&&qu.delete(e)}return qu.set(e,n),n}function Yu(e){let t=new Su(e),n=e.match(/drop-shadow\(/g)||[];if(n.length>1||n.length===1&&!t.shadow)return null;let r=t.safeFilterString.match(/^blur\((\d+(?:\.\d+)?)px\)$/);return t.safeFilterString&&!r||r&&n.length&&e.indexOf(`blur(`)>e.indexOf(`drop-shadow(`)?null:{blur:r?Number(r[1]):0,shadow:t.shadow?{x:t.shadow.offsetX,y:t.shadow.offsetY,blur:t.shadow.blur,color:t.shadow.color}:void 0}}function Xu(e){return Math.ceil(3*(e.blur+(e.shadow?.blur??0))+Math.max(Math.abs(e.shadow?.x??0),Math.abs(e.shadow?.y??0)))}function Zu(e){let t=document.createElement(`canvas`);return t.width=e.width,t.height=e.height,t}let Qu=(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 Q(`Filter surface image decode timed out`)),1e4);t?.addEventListener(`abort`,a,{once:!0}),t?.aborted?a():e.decode().then(()=>i(),()=>i(new Q(`Filter surface image decode failed`)))}),$u=/* @__PURE__ */ new WeakMap;function ed(e=document){let t=$u.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{$(n),$(r)}return $u.set(e,i),i}function td(e,{blur:t,shadow:n},r,i,a){let o,s,c=!1;try{Z(a),o=Zu(e);let l=o.getContext(`2d`);if(!l||!(`filter`in l))return null;let u=[];if(t&&u.push(`blur(${t*i}px)`),n&&u.push(`drop-shadow(${n.x*i}px ${n.y*i}px ${n.blur*i}px ${n.color})`),l.filter=u.join(` `),l.filter===`none`)return null;l.drawImage(e,0,0),Z(a),s=Zu(e);let d=s.getContext(`2d`);return d?(d.globalAlpha=r,d.drawImage(o,0,0),Z(a),c=!0,s):null}catch{return Z(a),null}finally{o&&$(o),s&&!c&&$(s)}}async function nd(e,t,n,r,i){if(Z(i),(t.blur||t.shadow)&&ed()){let a=td(e,t,n,r,i);if(a)return a}return rd(e,t,n,r,i)}async function rd(e,{blur:t,shadow:n},r,i,a){if(Z(a),!t&&!n){let t=Zu(e),n=t.getContext(`2d`);if(!n)throw $(t),new Q(`Filter surface canvas is unavailable`);n.globalAlpha=r;try{return n.drawImage(e,0,0),t}catch{throw $(t),new Q(`Filter surface image cannot be drawn`)}}let o=(e,t={})=>{let n=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.entries(t).forEach(([e,t])=>n.setAttribute(e,String(t))),n},s=o(`svg`,{width:e.width,height:e.height,viewBox:`0 0 ${e.width} ${e.height}`}),c=o(`defs`),l=o(`filter`,{id:`composited-filter`,filterUnits:`userSpaceOnUse`,x:0,y:0,width:e.width,height:e.height,"color-interpolation-filters":`sRGB`});if(t&&l.appendChild(o(`feGaussianBlur`,{stdDeviation:t*i,result:`blurred-source`})),n){l.appendChild(o(`feGaussianBlur`,{in:t?`blurred-source`:`SourceAlpha`,stdDeviation:n.blur*i})),l.appendChild(o(`feOffset`,{dx:n.x*i,dy:n.y*i,result:`offset-shadow`})),l.appendChild(o(`feFlood`,{"flood-color":n.color})),l.appendChild(o(`feComposite`,{in2:`offset-shadow`,operator:`in`}));let e=o(`feMerge`);e.appendChild(o(`feMergeNode`)),e.appendChild(o(`feMergeNode`,{in:t?`blurred-source`:`SourceGraphic`})),l.appendChild(e)}c.appendChild(l),s.appendChild(c);let u;try{if(u=e.toDataURL(`image/png`),u===`data:,`)throw Error(`Canvas size is unsupported`)}catch{throw new Q(`Filter surface pixels cannot be serialized`)}s.appendChild(o(`image`,{width:e.width,height:e.height,href:u,filter:`url(#composited-filter)`}));let d=new Image,f;try{d.src=`data:image/svg+xml,${encodeURIComponent(new XMLSerializer().serializeToString(s))}`,await Qu(d,a),Z(a),f=Zu(e);let t=f.getContext(`2d`);if(!t)throw new Q(`Filter surface canvas is unavailable`);return t.globalAlpha=r,t.drawImage(d,0,0),f}catch(e){throw f&&$(f),a?.aborted&&Z(a),e instanceof Q?e:new Q(`Filter surface image cannot be drawn`)}finally{d.removeAttribute(`src`)}}function id(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 ad=(e,t)=>e.add(-t,-t,t*2,t*2),od=(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 sd(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=od(n,ad(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=ad(i.bounds,2*z(t.fontSize,e.bounds.height)+t.webkitTextStrokeWidth);n=od(n,r);for(let e of t.textShadow)n=od(n,ad(r.add(e.offsetX.number,e.offsetY.number,0,0),3*e.blur.number))}for(let t of e.elements)t.styles.isVisible()&&(n=od(n,sd(t)));let r=Ju(t.filter);return ad(n,r?Xu(r):0)}function cd(e,t,n,r){let i=ad(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 ld=class{constructor(e){this.ctx=e}render(e,t){this.ctx.fillStyle=V(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);oe!==void 0&&!Number.isNaN(e),dd=(e,t)=>{let n=e.measureText(`Mg`),r=n;return{baseline:ud(r.fontBoundingBoxAscent)?r.fontBoundingBoxAscent:ud(n.actualBoundingBoxAscent)?n.actualBoundingBoxAscent:t,height:ud(r.fontBoundingBoxAscent)&&ud(r.fontBoundingBoxDescent)?r.fontBoundingBoxAscent+r.fontBoundingBoxDescent:ud(n.actualBoundingBoxAscent)&&ud(n.actualBoundingBoxDescent)?n.actualBoundingBoxAscent+n.actualBoundingBoxDescent:t}},fd=(e,t)=>dd(e,t).baseline,pd=[`-apple-system`,`system-ui`],md=/[\u2E80-\u2FFF\u3000-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFFEF]/,hd=e=>md.test(e),gd=()=>{if(typeof navigator>`u`)return null;let e=navigator.userAgent,t=/iPhone|iPad|iPod/.test(e),n=/Macintosh/.test(e)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1;if(!t&&!n)return null;for(let t of[/(?:iPhone|CPU(?:\siPhone)?)\sOS\s(\d+)[\._](\d+)/,/Version\/(\d+)\.(\d+)/]){let n=e.match(t);if(n&&n[1])return parseInt(n[1],10)}return null},_d=e=>{let t=gd();return t!==null&&t>=15&&t<17?e.map(e=>pd.indexOf(e)===-1?e:`-apple-system, "Helvetica Neue", Arial, sans-serif`):e},vd=()=>(typeof window<`u`?window:void 0)?.chrome?`miter`:`round`;var yd=class{constructor(e){this.baselineCache=/* @__PURE__ */ new Map,this.glyphWidthCache=null,this.ctx=e.ctx,this.options=e.options,this.decorationRenderer=new ld(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(Bo(r)){this.iterateVerticalGlyphs(e,t,n,r,i);return}let a=Al(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=Al(e.text),o=this.ctx.font,s=r===4?-Math.PI/2:Math.PI/2,c=e.bounds.top;for(let l=0;l0)){let r=this.ctx.textBaseline;hd(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(;l0)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{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=V(t.webkitTextStrokeColor),this.ctx.lineWidth=t.webkitTextStrokeWidth,this.ctx.lineJoin=vd(),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=V(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.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=Al(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>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=_d(e.fontFamily).join(`, `),r=O(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 V(e.webkitTextFillColor??e.color)}renderLineClampedText(e,t,n,r,i){let a=t.fontSize.number*1.5,o=[],s=[],c=E(e.textBounds,0).bounds.top;e.textBounds.forEach(e=>{Math.abs(e.bounds.top-c)>=a*.5?(s.length>0&&o.push(s),s=[e],c=e.bounds.top):s.push(e)}),s.length>0&&o.push(s);let l=t.webkitLineClamp;if(o.length<=l)return!1;for(let e=0;ethis.renderTextBoundWithPaintOrder(e,t,n,r));let u=o[l-1];if(u?.length&&i){let e=u.map(e=>e.text).join(``),a=E(u,0),o=i.width-(a.bounds.left-i.left),s=new wl(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=t.fontSize.number*1.5,o=E(e.textBounds,0).bounds.top;if(!e.textBounds.every(e=>Math.abs(e.bounds.top-o)e.text).join(``).replace(/\s+/g,` `).trim();if(this.ctx.measureText(s).width<=i.width+1)return!1;let c=new wl(this.truncateTextWithEllipsis(s,i.width,t.letterSpacing),E(e.textBounds,0).bounds);for(let e of n)e===0?this.renderTextFillWithShadows(c,t,r):e===1&&this.renderTextStrokeWithStyle(c,t,r);return!0}measureBaselineCached(e,t){let n=this.baselineCache.get(e);return n===void 0&&(n=fd(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&2&&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(Bo(t.writingMode))return;let r=t.textEmphasisStyle;if(!r)return;let i=t.fontSize.number,a=i*.5,o=V(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 Al(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 bd=(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)})},xd=(e,t)=>{e.beginPath(),bd(e,t),e.closePath()};var Sd=class{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()}},Cd=class{constructor(e){this.patternCache=new Sd(50),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):pa(i)?this.renderLinearGradient(e,i,t):ha(i)?this.renderRepeatingLinearGradient(e,i,t):ma(i)?this.renderRadialGradient(e,i,t):ga(i)?this.renderRepeatingRadialGradient(e,i,t):_a(i)&&this.renderConicGradient(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(e){this.context.logger.error(`Error loading background-image ${i}`),this.context.onError?.(e instanceof Error?e:Error(String(e)))}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]=Vu(e,n,[t,a,t/a]),d=Gu(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]=Vu(e,n,[null,null,null]),[c,l,u,d,f]=Gi(t.angle,o,s),p=Ui(t.stops,c||1),m=E(p,p.length-1),h=E(p,0),g=m.stop-h.stop,_=g*(c||1);if(_<=0){this.renderLinearGradient(e,t,n);return}let v=u-l,y=f-d,b=_/(Math.sqrt(v*v+y*y)||1),x=l,S=d,ee=l+v*b,C=d+y*b,te=this.canvas.ownerDocument??document,ne=`rlg|${t.angle}|${Math.round(_)}|${JSON.stringify(t.stops)}`,re=this.patternCache.get(ne);if(!re){let e=te.createElement(`canvas`),t=Math.max(1,Math.ceil(_));e.width=t,e.height=t;let n=e.getContext(`2d`);if(!n)return;let r=n.createLinearGradient(x-i,S-a,ee-i,C-a);p.forEach(e=>{r.addColorStop((e.stop-h.stop)/g,V(e.color))}),n.fillStyle=r,n.fillRect(0,0,t,t),t>0&&(re=this.ctx.createPattern(e,`repeat`),this.patternCache.set(ne,re))}re&&this.renderRepeat(r,re,i,a)}renderLinearGradient(e,t,n){let[r,i,a,o,s]=Vu(e,n,[null,null,null]),[c,l,u,d,f]=Gi(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);Ui(t.stops,c||1).forEach(e=>r.addColorStop(e.stop,V(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]=Vu(e,n,[null,null,null]),c=t.position.length===0?[L]:t.position,l=z(E(c,0),o),u=z(E(c,c.length-1),s),[d,f]=Ji(t,l,u,o,s);if((d===0||f===0)&&(d=Math.max(d,.01),f=Math.max(f,.01)),d>0&&f>0){let e=`rg|${Math.round(l)}x${Math.round(u)}|${Math.round(d)}x${Math.round(f)}|${JSON.stringify(t.stops)}`,n=Ui(t.stops,d*2),o=n[n.length-1],s=this.patternCache.get(e);if(!s){let t=(this.canvas.ownerDocument??document).createElement(`canvas`);t.width=Math.ceil(d*2),t.height=Math.ceil(f*2);let r=t.getContext(`2d`);if(r){let i=r.createRadialGradient(d,d,0,d,d,d);n.forEach(e=>i.addColorStop(e.stop,V(e.color))),r.fillStyle=i,d!==f&&r.scale(1,f/d),r.fillRect(0,0,d*2,d*2),s=this.ctx.createPattern(t,`no-repeat`),this.patternCache.set(e,s)}}s&&(this.path(r),this.ctx.save(),this.ctx.clip(),o&&(this.ctx.fillStyle=V(o.color),this.ctx.fill()),this.ctx.translate(i+l-d,a+u-f),this.ctx.fillStyle=s,this.ctx.fillRect(0,0,d*2,f*2),this.ctx.restore())}}renderRepeatingRadialGradient(e,t,n){let[r,i,a,o,s]=Vu(e,n,[null,null,null]),c=t.position.length===0?[L]:t.position,l=z(E(c,0),o),u=z(E(c,c.length-1),s),[d,f]=Ji(t,l,u,o,s);if((d===0||f===0)&&(d=Math.max(d,.01),f=Math.max(f,.01)),!(d>0&&f>0))return;let p=Ui(t.stops,d*2),m=E(p,0),h=E(p,p.length-1),g=Math.max(h.stop-m.stop,.01),_=[],v=Math.ceil(.5/g);for(let e=0;e1)break;_.push({stop:n,color:V(t.color)})}_.push({stop:1,color:V(h.color)});let y=`rrg|${Math.round(l)}x${Math.round(u)}|${Math.round(d)}x${Math.round(f)}|${_.length}|${JSON.stringify(t.stops)}`,b=this.patternCache.get(y);if(!b){let e=(this.canvas.ownerDocument??document).createElement(`canvas`);e.width=Math.ceil(d*2),e.height=Math.ceil(f*2);let t=e.getContext(`2d`);if(t){let n=t.createRadialGradient(d,d,0,d,d,d);_.forEach(e=>n.addColorStop(e.stop,e.color)),t.fillStyle=n,d!==f&&t.scale(1,f/d),t.fillRect(0,0,d*2,f*2),b=this.ctx.createPattern(e,`no-repeat`),this.patternCache.set(y,b)}}b&&(this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.translate(i+l-d,a+u-f),this.ctx.fillStyle=b,this.ctx.fillRect(0,0,d*2,f*2),this.ctx.restore())}renderConicGradient(e,t,n){let[r,i,a,o,s]=Vu(e,n,[null,null,null]),c=t.position.length===0?[L]:t.position,l=i+z(E(c,0),o),u=a+z(E(c,c.length-1),s),d=this.ctx.createConicGradient(t.angle-Math.PI/2,l,u);Ui(t.stops,1).forEach(e=>{d.addColorStop(Math.min(1,Math.max(0,e.stop)),V(e.color))}),this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=d,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){xd(this.ctx,e)}};let wd=(e,t)=>{switch(t){case 0:return kd(e.topLeftBorderBox,e.topLeftPaddingBox,e.topRightBorderBox,e.topRightPaddingBox);case 1:return kd(e.topRightBorderBox,e.topRightPaddingBox,e.bottomRightBorderBox,e.bottomRightPaddingBox);case 2:return kd(e.bottomRightBorderBox,e.bottomRightPaddingBox,e.bottomLeftBorderBox,e.bottomLeftPaddingBox);default:return kd(e.bottomLeftBorderBox,e.bottomLeftPaddingBox,e.topLeftBorderBox,e.topLeftPaddingBox)}},Td=(e,t)=>{switch(t){case 0:return kd(e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox,e.topRightBorderBox,e.topRightBorderDoubleOuterBox);case 1:return kd(e.topRightBorderBox,e.topRightBorderDoubleOuterBox,e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox);case 2:return kd(e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox,e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox);default:return kd(e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox,e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox)}},Ed=(e,t)=>{switch(t){case 0:return kd(e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox,e.topRightBorderDoubleInnerBox,e.topRightPaddingBox);case 1:return kd(e.topRightBorderDoubleInnerBox,e.topRightPaddingBox,e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox);case 2:return kd(e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox,e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox);default:return kd(e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox,e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox)}},Dd=(e,t)=>{switch(t){case 0:return Od(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return Od(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return Od(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return Od(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}},Od=(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},kd=(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 Ad=class{constructor(e,t){this.ctx=e.ctx,this.pathCallbacks=t}async renderSolidBorder(e,t,n){this.pathCallbacks.path(wd(n,t)),this.ctx.fillStyle=V(e),this.ctx.fill()}async renderDoubleBorder(e,t,n,r){if(t<3){await this.renderSolidBorder(e,n,r);return}let i=Td(r,n);this.pathCallbacks.path(i),this.ctx.fillStyle=V(e),this.ctx.fill();let a=Ed(r,n);this.pathCallbacks.path(a),this.ctx.fill()}async renderDashedDottedBorder(e,t,n,r,i){this.ctx.save();let a=Dd(r,n),o=wd(r,n);i===2&&(this.pathCallbacks.path(o),this.ctx.clip());let s,c,l,u;Y(E(o,0))?(s=E(o,0).start.x,c=E(o,0).start.y):(s=E(o,0).x,c=E(o,0).y),Y(E(o,1))?(l=E(o,1).end.x,u=E(o,1).end.y):(l=E(o,1).x,u=E(o,1).y);let d;d=Math.abs(n===0||n===2?s-l:c-u),this.ctx.beginPath(),i===3?this.pathCallbacks.formatPath(a):this.pathCallbacks.formatPath(o.slice(0,2));let f=t<3?t*3:t*2,p=t<3?t*2:t;i===3&&(f=t,p=t);let m=!0;if(d<=f*2)m=!1;else if(d<=f*2+p){let e=d/(2*f+p);f*=e,p*=e}else{let e=Math.floor((d+p)/(f+p)),t=(d-e*f)/(e-1),n=(d-(e+1)*f)/e;p=n<=0||Math.abs(p-t){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)})},Md=(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 Nd=class{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 ee=[{sx:m,sy:0,sw:l-m-f,sh:d,dx:h+S,dy:g,dw:_-S-b,dh:y,repeat:r.horizontal},{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},{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},{sx:0,sy:d,sw:m,sh:u-d-p,dx:h,dy:g+y,dw:S,dh:v-y-x,repeat:r.vertical}];for(let e of ee){if(e.sw<=0||e.sh<=0||e.dw<=0||e.dh<=0)continue;let n=e.dw>=e.dh;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,n,e.repeat===2)}if(n.fill){let e=m,n=d,r=l-m-f,i=u-d-p,a=h+S,o=g+y,s=_-S-b,c=v-y-x;this.drawRegion(t,e,n,r,i,a,o,s,c)}}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;rCu(e)||wu(e)||Eu(e),n=e.reduceRight((e,n,r)=>e===-1?t(n)?r:-1:e,-1);for(let r=0;r0}};let Fd=(e,t)=>e.length===0?void 0:e[t%e.length]??e[0],Id=(e,t,n,r)=>{let i=e?e[0]:void 0,a=e&&e.length>1?E(e,1):void 0,o=e=>e!==void 0&&A(e)?e.value:null,s=(e,t,n)=>e===void 0||A(e)?null:F(e)?z(e,t):n,c=o(i);if(c===`contain`||c===`cover`){let e=c===`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 l=s(i,t.width,n),u=s(a,t.height,r);return l===null&&u===null?(l=n,u=r):l===null?l=n/r*u:u===null&&(u=r/n*l),{width:l,height:u}},Ld=(e,t,n,r,i)=>{let a=t.naturalWidth||t.width||i.width,o=t.naturalHeight||t.height||i.height,{width:s,height:c}=Id(Fd(n.maskSize,r),i,a,o),l=Fd(n.maskPosition,r)??[],u=i.left+z(E(l,0),i.width-s),d=i.top+z(E(l,l.length-1),i.height-c),f=Fd(n.maskRepeat,r)??0,p=f===0||f===2,m=f===0||f===3,h=p?Math.ceil((u-i.left)/s):0,g=m?Math.ceil((d-i.top)/c):0,_=p?Math.ceil((i.left+i.width-u)/s):0,v=m?Math.ceil((i.top+i.height-d)/c):0;for(let n=-g;n<=v;n++)for(let r=-h;r<=_;r++)e.drawImage(t,u+r*s,d+n*c,s,c)},Rd=(e,t,n)=>{let{width:r,height:i}=n,a=t.position.length===0?[L]:t.position,o=z(E(a,0),r),s=z(E(a,a.length-1),i),[c,l]=Ji(t,o,s,r,i);c=Math.max(c,.01),l=Math.max(l,.01);let u=document.createElement(`canvas`);u.width=Math.ceil(c*2),u.height=Math.ceil(l*2);let d=u.getContext(`2d`);if(!d)return;let f=d.createRadialGradient(c,c,0,c,c,c);Ui(t.stops,c*2).forEach(e=>f.addColorStop(Math.min(1,Math.max(0,e.stop)),V(e.color))),d.fillStyle=f,c!==l&&d.scale(1,l/c),d.fillRect(0,0,c*2,l*2),e.drawImage(u,n.left+o-c,n.top+s-l,c*2,l*2)},zd=(e,t,n)=>{let{width:r,height:i}=n;if(r<=0||i<=0)return;if(ma(t)||ga(t)){Rd(e,t,n);return}let a=null;if(t.type===1||t.type===3){let n=t,[o,s,c,l,u]=Gi(n.angle||0,r,i);a=e.createLinearGradient(s,c,l,u),Ui(n.stops,o||1).forEach(e=>a.addColorStop(Math.min(1,Math.max(0,e.stop)),V(e.color)))}else if(_a(t)){let o=t;a=e.createConicGradient(o.angle-Math.PI/2,n.left+r/2,n.top+i/2),Ui(o.stops,1).forEach(e=>a.addColorStop(Math.min(1,Math.max(0,e.stop)),V(e.color)))}a&&(e.fillStyle=a,e.fillRect(n.left,n.top,r,i))},Bd=async(e,t,n,r,i)=>{for(let a=0;a{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?z(i[0],1):.5,g=i?z(i[1],1):.5;return r===2?m>p?(f=d/m,u+=(n.height-f)*g):(d=f*m,l+=(n.width-d)*h):r===4?m>p?(s=c*p,a+=(e-s)*h):(c=s/p,o+=(t-c)*g):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)):r===16&&((m>p?d:f*m)<(s>d?s:d)?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))),{sx:a,sy:o,sw:s,sh:c,dx:l,dy:u,dw:d,dh:f}};async function Hd(e,t,n,r,i,a,o,s){if(i instanceof zl)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(e){t.logger.error(`Error loading image ${i.src}`),t.onError?.(e instanceof Error?e:Error(String(e)))}if(i instanceof Bl&&s(i,a,i.canvas),i instanceof Ul)try{s(i,a,await t.cache.match(i.svg))}catch(e){t.logger.error(`Error loading svg ${i.svg.substring(0,255)}`),t.onError?.(e instanceof Error?e:Error(String(e)))}if(i instanceof eu&&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 Ud(e,t,n,r,i){if(r instanceof Zl){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=V(r.styles.accentColor??707406591),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=V(r.styles.accentColor??707406591),e.fill(),e.restore())}if(qd(r)&&r.value.length){let[o]=t.createFontStyle(i);e.font=o??``;let s=z(i.fontSize,0),{baseline:c,height:l}=dd(e,s);e.fillStyle=r instanceof Zl&&r.isPlaceholder?V(1970632191):V(i.color),e.textBaseline=`alphabetic`,e.textAlign=Jd(r.styles.textAlign);let u=Ru(r),d=r instanceof Zl?Wd(u,Lu(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 Zl&&(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=Gd(e,r.value,u.width,i.whiteSpace===`pre`||i.whiteSpace===`nowrap`),g=po(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 wl(n,l),i.letterSpacing,c,i.writingMode)}),e.restore(),e.textBaseline=`alphabetic`,e.textAlign=`left`}}let Wd=(e,t,n)=>e.height{let i=[],a=t.split(` `);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 Kd(e,t,n,r,i,o){if(W(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);e.drawImage(n,i.bounds.left-(n.width+10),i.bounds.top)}catch(e){t.logger.error(`Error loading list-style-image ${r}`),t.onError?.(e instanceof Error?e:Error(String(e)))}}}else if(r.listValue&&i.styles.listStyleType!==-1){let[t]=n.createFontStyle(o);e.font=t??``,e.fillStyle=V(o.color),e.textBaseline=`middle`,e.textAlign=`right`;let s=new a(i.bounds.left,i.bounds.top+z(i.styles.paddingTop,i.bounds.width),i.bounds.width,po(o.lineHeight,o.fontSize.number)/2+1);n.renderTextWithLetterSpacing(new wl(r.listValue,s),o.letterSpacing,po(o.lineHeight,o.fontSize.number)/2+2,o.writingMode),e.textBaseline=`bottom`,e.textAlign=`left`}}}let qd=e=>e instanceof $l||e instanceof Ql||e instanceof Zl&&e.type!==`radio`&&e.type!==`checkbox`,Jd=e=>{switch(e){case 1:return`center`;case 2:return`right`;default:return`left`}},Yd=(e,t)=>{let n=t>e?t*(1+(e/t-1)**3):t;return Math.max(0,e+n)},Xd=(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=E(n,1).x-E(n,0).x+2*t,i=E(n,3).y-E(n,0).y+2*t;if(r<=0||i<=0)return[];let a=n.map(e=>({x:Yd(e.rx,t),y:Yd(e.ry,t)})),o=(e,t)=>t>0?e/t:1,s=Math.min(1,o(r,E(a,0).x+E(a,1).x),o(r,E(a,3).x+E(a,2).x),o(i,E(a,0).y+E(a,3).y),o(i,E(a,1).y+E(a,2).y));return e.map((e,r)=>{let i=E(n,r),o=i.x+(r===1||r===2?t:-t),c=i.y+(r>=2?t:-t);if(!Y(e))return new J(o,c);let l=E(a,r).x*s,u=E(a,r).y*s;if(!l||!u)return new J(o,c);let d=l/i.rx,f=u/i.ry,p=e=>new J(o+(e.x-i.x)*d,c+(e.y-i.y)*f);return new du(p(e.start),p(e.startControl),p(e.endControl),p(e.end))})},Zd=(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}},Qd=(e,t,n)=>{e.beginPath(),e.rect(t.left,t.top,t.width,t.height),n.length&&(bd(e,n),e.closePath())},$d=(e,t)=>{let n=t.spread.number,r=Lu(e.container);return r.width-2*n<=0||r.height-2*n<=0?[]:Xd(hu(e.curves),-n)},ef=async(e,t,n,r,i,a)=>{let o=Lu(t.container),s=n.blur.number/2,c=Math.ceil(3*s)+2,l=n.spread.number,u=cd((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=id(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?$d(t,n):Xd(pu(t.curves),l),c=lu(o,n.offsetX.number,n.offsetY.number,0,0);n.inset?Qd(i,u,c):xd(i,c),i.fillStyle=V(n.color),i.fill(n.inset?`evenodd`:`nonzero`),h=await nd(m,{blur:s},1,a.scale,r.signal),e.save();try{n.inset?(xd(e,hu(t.curves)),e.clip()):(Qd(e,a.viewport,pu(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 Q))throw e;return!1}finally{h&&h!==m&&$(h),m&&$(m),i.pixels-=p}},tf=async(e,t,n,r,i)=>{if(r.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);if(On(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=Zd(s,e.canvas.width,e.canvas.height);if(!c)return;let{viewport:l}=c;if(n.blur.number>0&&(n.inset||!c.uniform)&&await ef(e,t,n,r,i,c))return;let u=Lu(t.container);e.save();try{if(n.inset&&n.blur.number===0){xd(e,hu(t.curves)),e.clip(),Qd(e,u,lu($d(t,n),n.offsetX.number,n.offsetY.number,0,0)),e.fillStyle=V(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?(xd(e,hu(t.curves)),e.clip()):(Qd(e,l,pu(t.curves)),e.clip(`evenodd`)),o?e.setTransform(d,f,p,m,h-b,g):e.translate(-b/d,0),n.inset?Qd(e,i,$d(t,n)):xd(e,Xd(pu(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=V(n.color),e.fillStyle=`rgb(0, 0, 0)`,e.fill(n.inset?`evenodd`:`nonzero`)}finally{e.restore()}};var nf=class{constructor(e){this.ctx=e.ctx,this.context=e.context,this.createFontStyle=e.createFontStyle}async render(e){let t=e.container,n=t.styles,r=t.bounds;if(r.width<=0||r.height<=0)return;let i=this.ctx.canvas.ownerDocument??document,a=i.createElement(`canvas`),o=Math.ceil(r.width),s=Math.ceil(r.height);a.width=o,a.height=s;let c=a.getContext(`2d`);if(!c)return;let[l]=this.createFontStyle(n);c.font=l??``,c.textBaseline=`alphabetic`,c.textAlign=`left`,c.direction=n.direction===1?`rtl`:`ltr`;let u=fd(c,n.fontSize.number),d=new Cd({ctx:c,context:this.context,canvas:a,options:{width:o,height:s,scale:1}});On(n.backgroundColor)||(c.fillStyle=V(n.backgroundColor),c.fillRect(0,0,o,s)),c.save(),c.translate(-r.left,-r.top),await d.renderBackgroundImage(t),c.restore();let f=i.createElement(`canvas`);f.width=o,f.height=s;let p=f.getContext(`2d`);if(!p)return;p.font=c.font,p.textBaseline=c.textBaseline,p.textAlign=c.textAlign,p.direction=c.direction,p.fillStyle=`#000`;let m=n.writingMode,h=n.letterSpacing;for(let e of t.textNodes)for(let t of e.textBounds){let e=t.bounds.left-r.left,n=t.bounds.top-r.top+u;h>0?this.renderTextMaskWithLetterSpacing(p,t,h,e,n,m):p.fillText(t.text,e,n)}c.globalCompositeOperation=`destination-in`,c.drawImage(f,0,0),this.ctx.drawImage(a,r.left,r.top)}renderTextMaskWithLetterSpacing(e,t,n,r,i,a){let o=Al(t.text),s=r;for(let c of o){if(Bo(a)){e.fillText(t.text,r,i);return}e.fillText(c,s,i),s+=e.measureText(c).width+n}}},rf=class e{constructor(e,t,n,r={pixels:0}){this.surfaceRoot=n,this.surfaceBudget=r,this.legacySubtree=!1,this.context=e,this.options=t,this.canvas=t.canvas?t.canvas:document.createElement(`canvas`);let i=this.canvas.getContext(`2d`);if(!i)throw t.canvas||$(this.canvas),n?new Q(`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 Cd({ctx:this.ctx,context:this.context,canvas:this.canvas,options:{width:t.width,height:t.height,scale:t.scale}}),this.borderRenderer=new Ad({ctx:this.ctx},{path:e=>this.path(e),formatPath:e=>this.formatPath(e)}),this.borderImageRenderer=new Nd(this.ctx),this.effectsRenderer=new Pd({ctx:this.ctx},{path:e=>this.path(e)}),this.textRenderer=new yd({ctx:this.ctx,options:{scale:t.scale}}),this.textClipRenderer=new nf({ctx:this.ctx,context:this.context,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=Ju(t.filter),r=t.maskImage.length>0,i=t.webkitBoxReflect;if(e.element!==this.surfaceRoot&&!this.legacySubtree&&(r||i||n&&(t.filter||t.opacity<1))&&this.canComposite(e.element)){if(!await this.renderCompositedStack(e,n,r,i)){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.mixBlendMode===K.NORMAL&&t.clipPath.type===0&&!W(t.display,2048)&&Ju(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){let o=this.options.signal;if(o?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let s=cd(sd(t.element.container),new a(this.options.x,this.options.y,this.options.width,this.options.height),n?Xu(n):0,this.options.scale);if(!s.width||!s.height)return!0;let c=id(this.surfaceBudget,Math.ceil(s.width*this.options.scale),Math.ceil(s.height*this.options.scale));if(!c)return this.context.logger.info(`Filter surface budget exceeded; using the existing renderer`),!1;let l={...this.options,canvas:void 0,backgroundColor:null,x:s.left,y:s.top,width:s.width,height:s.height},u,d;try{u=new e(this.context,l,t.element,this.surfaceBudget),await u.renderStackContent(t),u.effectsRenderer.applyEffects([]),n&&(d=await nd(u.canvas,n,t.element.container.styles.opacity,l.scale,o));let a=d??u.canvas;if(r&&await this.applyMask(a,t.element.container.styles,s),o?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let c=t.element.effects,f=t.element.getEffects(4,this.surfaceRoot).filter(e=>!c.includes(e)||!Ou(e)&&!Tu(e)&&!wu(e));return this.effectsRenderer.applyEffects(f),this.ctx.drawImage(a,l.x,l.y,a.width/l.scale,a.height/l.scale),i&&await this.drawReflection(a,t.element.container.bounds,s,i),!0}catch(e){if(!(e instanceof Q))throw e;return this.context.logger.info(`${e.message}; using the existing renderer`),!1}finally{u&&$(u.canvas),d&&$(d),this.surfaceBudget.pixels-=c}}async applyMask(e,t,n){let r=e.getContext(`2d`);if(!r)return;let i=document.createElement(`canvas`);i.width=e.width,i.height=e.height;let a=i.getContext(`2d`);if(a){a.scale(this.options.scale,this.options.scale),a.translate(-n.left,-n.top);try{await Bd(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}`);return}r.save();try{r.setTransform(1,0,0,1,0,0),r.globalCompositeOperation=`destination-in`,r.drawImage(i,0,0)}finally{r.restore()}}}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=id(this.surfaceBudget,a,o);if(!s)return;let c,l;try{c=document.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=document.createElement(`canvas`),l.width=a,l.height=o;let e=l.getContext(`2d`);if(e){await Bd(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)}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&&$(c),l&&$(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=Ru(e),o=hu(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}=Vd(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=Ru(n);for(let e of n.textNodes)await this.textRenderer.renderTextNode(e,i,a);await Hd(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)),Ud(this.ctx,this.textRenderer,this.path.bind(this),n,i),await Kd(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)}}mask(e){this.ctx.beginPath();let t=this.options.x,n=this.options.y;this.ctx.moveTo(t,n),this.ctx.lineTo(t+this.options.width,n),this.ctx.lineTo(t+this.options.width,n+this.options.height),this.ctx.lineTo(t,n+this.options.height),this.ctx.lineTo(t,n),this.formatPath(e.slice(0).reverse()),this.ctx.closePath()}path(e){xd(this.ctx,e)}formatPath(e){bd(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=cd(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=id(this.surfaceBudget,l,u);if(!d)throw new Q(`Box shadow surface budget exceeded`);let f,p;try{f=document.createElement(`canvas`),f.width=l,f.height=u;let i=f.getContext(`2d`);if(!i)throw new Q(`Box shadow surface canvas is unavailable`);i.scale(s,s),i.translate(-c.left,-c.top),xd(i,lu(pu(e.curves),-n,-n,2*n,2*n)),i.fillStyle=V(t.color),i.fill(),p=await nd(f,{blur: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),bd(this.ctx,pu(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&&$(f),p&&$(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=!On(t.backgroundColor)||t.backgroundImage.length,r=of(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=Gu(t.backgroundClip,0),o=af(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(),On(t.backgroundColor)||(this.ctx.fillStyle=V(t.backgroundColor),this.ctx.fill()),await this.backgroundRenderer.renderBackgroundImage(e.container),this.ctx.restore());for(let n of t.boxShadow.slice(0).reverse()){if(this.surfaceRoot&&!n.inset){await this.renderSurfaceBoxShadow(e,n);continue}await tf(this.ctx,e,n,this.options,this.surfaceBudget)}}if(t.borderImageSource){let n=t.borderImageSource;if(n.type===0){let r=n.url;try{let n=await this.context.cache.match(r);if(n){let 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=Md(t.borderImageOutset,i),o=r.add(-a.left,-a.top,a.left+a.right,a.top+a.bottom),s=jd(t.borderImageWidth,i,o);this.borderImageRenderer.renderBorderImage(r,n,t.borderImageSlice,t.borderImageRepeat,s[0],s[1],s[2],s[3],a)}}catch{this.context.logger.error(`Error loading border-image ${r}`)}}return}let s=0;for(let t of i){if(t.style!==0&&!On(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(On(r))return;let i=Math.max(0,t.outlineOffset)+n/2,a=lu(pu(e.curves),-i,-i,2*i,2*i);this.ctx.save();try{this.ctx.strokeStyle=V(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()}}async renderBackdropFilter(e){let t=Ju(e.container.styles.backdropFilter);if(!t||!t.blur&&!t.shadow)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=id(this.surfaceBudget,i,a);if(!o)return;let s,c;try{s=document.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);if(e.drawImage(this.canvas,o,l,i,a,0,0,i,a),c=await nd(s,t,1,r,this.options.signal),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&&$(s),c&&$(c),this.surfaceBudget.pixels-=o}}async render(e){try{this.options.backgroundColor&&(this.ctx.fillStyle=V(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height));let t=Iu(e);return await this.renderStack(t),this.effectsRenderer.applyEffects([]),this.canvas}catch(e){throw this.options.canvas||$(this.canvas),e}}};let af=(e,t)=>{switch(e){case 0:return pu(t);case 2:return mu(t);default:return hu(t)}},of=e=>e.backgroundClip.some(e=>e===3);var sf=class{constructor(e,t){this.context=e,this.options=t,this.canvas=t.canvas?t.canvas:document.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=Sl(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,e),n=await Cl(t);return this.options.backgroundColor&&(this.ctx.fillStyle=V(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(n,-this.options.x*this.options.scale,-this.options.y*this.options.scale),this.canvas}},cf=class{static{this.instances={}}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))}},lf=class{constructor(e,t){if(this.context=e,this._options=t,this._cache=/* @__PURE__ */ new Map,this._pendingOperations=/* @__PURE__ */ new Map,this._deferMode=!1,this._collectedUrls=/* @__PURE__ */ new Set,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}async preloadAll(e=10,t){this._deferMode=!1;let n=Array.from(this._collectedUrls);if(this._collectedUrls.clear(),n.length===0)return;let r=Math.max(1,Math.min(e,100));this.context.logger.debug(`Preloading ${n.length} image(s) with concurrency ${r}`);let i=0;t?.(0,n.length);for(let e=0;ethis._addImageWithPending(e));await Promise.allSettled(o),i+=a.length,t?.(i,n.length)}}addImage(e){if(this._deferMode)return!this.has(e)&&(gf(e)||pf(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 gf(e)||pf(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=>{this.context.logger.error(`Failed to load image ${e}: ${t instanceof Error?t.message:`Unknown error`}`)}),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._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&&!mf(e)&&!gf(e)&&typeof this._options.proxy!=`string`,a=!mf(e)&&(this._options.useCORS===!0||i)&&q.SUPPORT_CORS_IMAGES&&!r,o=!mf(e)&&!r&&!gf(e)&&typeof this._options.proxy==`string`&&q.SUPPORT_CORS_XHR&&!a;if(!r&&this._options.allowTaint===!1&&!mf(e)&&!gf(e)&&!o&&!a)return;let s=e;return o&&(s=await this.proxy(s)),this.context.logger.debug(`Added image ${e.substring(0,256)}`),await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=t,(hf(s)||a)&&(n.crossOrigin=`anonymous`),n.src=s,n.complete===!0&&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=q.SUPPORT_RESPONSE_TYPE?`blob`:`text`,o=new XMLHttpRequest;o.onload=()=>{if(o.status===200){if(a===`text`)r(o.response);else{let e=new FileReader;e.addEventListener(`load`,()=>r(e.result),!1),e.addEventListener(`error`,e=>i(e),!1),e.readAsDataURL(o.response)}}else i(`Failed to proxy resource ${n} with status code ${o.status}`)},o.onerror=i;let s=t.indexOf(`?`)>-1?`&`:`?`;if(o.open(`GET`,`${t}${s}url=${encodeURIComponent(e)}&responseType=${a}`),a!==`text`&&o instanceof XMLHttpRequest&&(o.responseType=a),this._options.imageTimeout){let e=this._options.imageTimeout;o.timeout=e,o.ontimeout=()=>i(`Timed out (${e}ms) proxying ${n}`)}o.send()})}};let uf=/^data:image\/svg\+xml/i,df=/^data:image\/.*;base64,/i,ff=/^data:image\/.*/i,pf=e=>q.SUPPORT_SVG_DRAWING||!_f(e),mf=e=>ff.test(e),hf=e=>df.test(e),gf=e=>e.substring(0,4)===`blob`,_f=e=>e.slice(-3).toLowerCase()===`svg`||uf.test(e);var vf=class{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.link=e.document.createElement(`a`),this.origin=this.getOrigin(e.location.href)}getOrigin(e){return this.link.href=e,this.link.href=this.link.href,this.link.protocol+this.link.hostname+this.link.port}isSameOrigin(e){return this.getOrigin(e)===this.origin}getContextOrigin(){return this.origin}},yf=class e{static{this.instanceCount=1}constructor(t,n,r){this.instanceName=`#${e.instanceCount++}`,this.config=r,this.logger=new cf({id:this.instanceName,enabled:t.logging}),this.originChecker=new vf(r.window),this.cache=t.cache??r.cache??new lf(this,t),this.onError=t.onError,this._windowBounds=n}get windowBounds(){return this._windowBounds}adjustWindowBounds(e,t){this._windowBounds=this._windowBounds.add(e,t,0,0)}};let bf=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)}})},xf=e=>({allowTaint:e.allowTaint??!1,imageTimeout:e.imageTimeout??15e3,proxy:e.proxy,useCORS:e.useCORS??!1,customIsSameOrigin:e.customIsSameOrigin,maxCacheSize:e.maxCacheSize}),Sf=(e,t,n)=>({logging:e.logging??!0,cache:e.cache??t.cache,...n}),Cf=(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}},wf=(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}),Tf=(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}),Ef=(e,t,n)=>{let r=t.ownerDocument,i=r.documentElement?Ur(e,getComputedStyle(r.documentElement).backgroundColor):0,a=r.body?Ur(e,getComputedStyle(r.body).backgroundColor):0,o=typeof n==`string`?Ur(e,n):n===null?0:4294967295;return t===r.documentElement?On(i)?On(a)?o:a:i:o},Df=(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)}`)}},Of=async(e,t,n)=>{if(bf(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=xf(t),d=Sf(t,n,u),f=Cf(t,l),p=new a(f.scrollX,f.scrollY,f.windowWidth,f.windowHeight),m=new yf(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;Z(_);let v=t.foreignObjectRendering??!1,y=wf(t,n,v);m.logger.debug(`Starting document clone with size ${p.width}x${p.height} scrolled to ${-p.left},${-p.top}`),Df(t.onProgress,m,`clone`,10),g.start(`clone`);let b=new bc(m,e,y),x=b.clonedReferenceElement;if(!x)throw Error(`Unable to find element in cloned iframe`);let S=await b.toIFrame(c,p);g.end(`clone`),Df(t.onProgress,m,`clone`,30),_?.aborted&&((t.removeContainer??!0)&&bc.destroy(S),Z(_));let{width:ee,height:C,left:te,top:ne}=Qr(x)||Xr(x)?s(x.ownerDocument):o(m,x),re=Ef(m,x,t.backgroundColor),ie=Tf(t,re,te,ne,ee,C,l.devicePixelRatio??1),ae,oe;try{v?(m.logger.debug(`Document cloned, using foreign object rendering`),g.start(`render-foreignobject`),ae=await new sf(m,ie).render(x),g.end(`render-foreignobject`)):(m.logger.debug(`Document cloned, element located at ${te},${ne} with size ${ee}x${C} using computed rendering`),m.logger.debug(`Starting DOM parsing`),g.start(`parse`),Z(_),m.cache.startDefer(),oe=au(m,x),g.end(`parse`),Df(t.onProgress,m,`parse`,50),g.start(`preload`),await m.cache.preloadAll(10,(e,n)=>{Df(t.onProgress,m,`preload`,50+Math.round(e/n*10))}),g.end(`preload`),Df(t.onProgress,m,`layout`,60),re===oe.styles.backgroundColor&&(oe.styles.backgroundColor=0),m.logger.debug(`Starting renderer for element at ${ie.x},${ie.y} with size ${ie.width}x${ie.height}`),g.start(`render`),Z(_),ae=await new rf(m,ie).render(oe),g.end(`render`)),Df(t.onProgress,m,`render`,90)}finally{g.start(`cleanup`);try{oe&&oe.restoreTree()}finally{(t.removeContainer??!0)&&bc.destroy(S),g.end(`cleanup`)}}return g.end(`total`),m.logger.debug(`Finished rendering`),h&&g.logSummary(),Df(t.onProgress,m,`render`,100),ae},kf=(e,n={},r)=>{let i=r||t.fromElement(e,{cspNonce:n.cspNonce,cache:n.cache});return Of(e,n,i)};e.Html2CanvasConfig=t,e.PerformanceMonitor=i,e.Validator=n,e.createDefaultValidator=r,e.default=kf,e.html2canvas=kf}); const renderCanvas=module.exports.default || module.exports.html2canvas || module.exports; /* Local ChatGPT conversation capture. No conversation API, telemetry or uploads. */ (() => { 'use strict'; if (document.getElementById('gpt-share-local')) return; const wait = ms => new Promise(resolve => setTimeout(resolve, ms)); const host = document.createElement('div'); host.id = 'gpt-share-local'; host.style.cssText = 'position:fixed;inset:0;z-index:2147483600;pointer-events:none;'; const ui = host.attachShadow({ mode: 'open' }); document.body.append(host); ui.innerHTML = `
`; const $ = id => ui.getElementById(id); let records = [], selected = new Set(), outputs = [], busy = false, stop = false, sourceURL = ''; let lastFocus = null; const nodeKeys = new WeakMap(); const nodeRoles = new WeakMap(); let snapshots = new WeakMap(); let nodeCounter = 0; let toastTimer; function toast(text, retry = false, duration = 4500) { clearTimeout(toastTimer); $('toast').replaceChildren(document.createTextNode(text)); $('toast').style.display = 'block'; if (retry) { const copy = document.createElement('button'); copy.textContent = '重试复制'; copy.onclick = async () => { try { await navigator.clipboard.write([new ClipboardItem({'image/png':outputs[0].blob})]); toast('图片已复制,可以直接粘贴。'); clearOutputs(); } catch { toast('复制失败,可保存 PNG 后发送。', true, 0); } }; const saveButton = document.createElement('button'); saveButton.textContent = '保存 PNG'; saveButton.onclick = () => save(0); $('toast').append(copy, saveButton); } if (duration) toastTimer = setTimeout(() => { $('toast').style.display = 'none'; }, duration); } function status(text, error = false) { $('status').textContent = text; $('status').classList.toggle('error', error); } function setBusy(value, scanning = false) { busy = value; for (const id of ['generate','reload','all','none','ai','title','theme','length']) $(id).disabled = value; document.querySelectorAll('[data-gpt-share-single]').forEach(button => { button.disabled = value; }); $('cancel').style.display = value && scanning ? 'block' : 'none'; } function messages() { const main = document.querySelector('main') || document.body; const found = [...main.querySelectorAll('[data-message-author-role="user"], [data-message-author-role="assistant"]')] .filter(el => !el.parentElement?.closest('[data-message-author-role]') && !host.contains(el)); for (const node of found) nodeRoles.set(node, node.getAttribute('data-message-author-role')); const unitSelector = '[data-content-search-unit-key], [data-chatgpt-search-unit-key]'; const add = (node, role) => { if (!node || host.contains(node) || found.some(existing => existing === node || existing.contains(node) || node.contains(existing))) return; nodeRoles.set(node, role); found.push(node); }; // Current web renderer: user bubbles and assistant headings live in search units. for (const bubble of main.querySelectorAll('[data-user-message-bubble]')) add(bubble.closest(unitSelector) || bubble, 'user'); for (const marker of main.querySelectorAll('[data-conversation-role="assistant"]')) add(marker.closest(unitSelector) || marker.parentElement, 'assistant'); // Virtualization can leave a partial message without its heading in the DOM. for (const unit of main.querySelectorAll(unitSelector)) { const label = unit.getAttribute('data-content-search-unit-key') || unit.getAttribute('data-chatgpt-search-unit-key') || ''; const role = /:user$/.test(label) ? 'user' : /:assistant$/.test(label) ? 'assistant' : null; if (role && unit.querySelector('[data-user-message-bubble], [data-markdown-text-style], [class*="MarkdownRoot-"]')) add(unit, role); } return found.sort((a,b) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1); } const roleOf = node => nodeRoles.get(node) || node.getAttribute('data-message-author-role'); function keyOf(node) { const turn = node.closest('[data-testid^="conversation-turn-"]'); const role = roleOf(node); const unit = node.closest('[data-content-search-unit-key], [data-chatgpt-search-unit-key]'); const content = node.matches('[data-chatgpt-selection-message-id]') ? node : node.querySelector('[data-chatgpt-selection-message-id]'); const userTurn = role === 'user' ? node.closest('[data-turn-key]')?.getAttribute('data-turn-key') : null; const searchIds = node.closest('[data-chatgpt-search-message-ids]')?.getAttribute('data-chatgpt-search-message-ids'); const id = node.getAttribute('data-message-id') || content?.getAttribute('data-chatgpt-selection-message-id') || userTurn || searchIds?.trim().split(/\s+/)[0]; if (id) return `${role}:${id}`; if (turn) return `${turn.getAttribute('data-testid')}:${role}:${[...turn.querySelectorAll('[data-message-author-role]')].indexOf(node)}`; if (unit) return `${role}:${unit.getAttribute('data-content-search-unit-key') || unit.getAttribute('data-chatgpt-search-unit-key')}`; if (!nodeKeys.has(node)) nodeKeys.set(node, `node:${++nodeCounter}`); return nodeKeys.get(node); } const mathProps = ['display','position','top','left','right','bottom','width','height','min-width','vertical-align','font-family','font-size','font-style','font-weight','line-height','letter-spacing','margin-left','margin-right','margin-top','margin-bottom','padding-left','padding-right','border-top-width','border-top-style','border-bottom-width','border-bottom-style','transform','transform-origin','text-align','white-space']; const citationSelector = '[data-testid*="citation"], [data-testid*="source-pill"], [data-testid*="source-chip"], [data-citation-id], [data-type="citation"], .citation-link, [class*="Citation"], [class*="citation"]'; function decorativeImage(img) { const url = img.currentSrc || img.src || ''; if (/\/(?:favicon(?:s)?(?:[/.?]|$)|s2\/favicons)|[?&](?:isFavicon|favicon)=/i.test(url)) return true; const rect = img.getBoundingClientRect(); // A citation container can also include a genuine large illustration. if (img.closest(citationSelector) && !(rect.width > 48 && rect.height > 48 || !rect.width && img.naturalWidth > 64 && img.naturalHeight > 64)) return true; return rect.width > 0 && rect.height > 0 && rect.width <= 32 && rect.height <= 32 && (img.getAttribute('role') === 'presentation' || img.alt === '' || img.naturalWidth <= 64 && img.naturalHeight <= 64); } function sourceBadges(node) { const badges = new Set(); const hasBodyImage = el => [...el.querySelectorAll('img')].some(img => !decorativeImage(img)); node.querySelectorAll(citationSelector).forEach(el => { if (el.tagName !== 'IMG' && !hasBodyImage(el)) badges.add(el); }); // Some ChatGPT source pills have only a popover marker and a favicon, // without any citation attributes. Identify the compact control as a whole. node.querySelectorAll('img').forEach(img => { if (!decorativeImage(img)) return; for (let el = img.parentElement; el && el !== node; el = el.parentElement) { if (el.matches('p,li,blockquote,pre,figure')) break; const control = el.matches('a,button,[role="button"],span[data-state],span.inline-flex[class*="rounded"]'); if (control && el.textContent.trim().length <= 160 && !hasBodyImage(el)) { badges.add(el); break; } } }); return badges; } function rasterImage(loaded) { const canvas = document.createElement('canvas'); const factor = Math.min(1, 1600 / loaded.naturalWidth, 2400 / loaded.naturalHeight); canvas.width = Math.max(1, Math.round(loaded.naturalWidth * factor)); canvas.height = Math.max(1, Math.round(loaded.naturalHeight * factor)); canvas.getContext('2d').drawImage(loaded, 0, 0, canvas.width, canvas.height); const data = canvas.toDataURL('image/png'); canvas.width = 1; canvas.height = 1; return data; } const appearanceProps = ['display','visibility','box-sizing','flex-direction','flex-wrap','flex-grow','flex-shrink','flex-basis','justify-content','justify-items','justify-self','align-items','align-self','align-content','order','grid-column','grid-row','grid-auto-flow','column-gap','row-gap','padding-top','padding-right','padding-bottom','padding-left','margin-top','margin-right','margin-bottom','margin-left','border-top','border-right','border-bottom','border-left','border-radius','border-collapse','border-spacing','background-color','background-image','background-size','background-position','background-repeat','box-shadow','opacity','color','font-family','font-size','font-weight','font-style','line-height','letter-spacing','text-align','text-decoration','text-transform','white-space','vertical-align','list-style-type','list-style-position','word-break','overflow-wrap','object-fit','object-position']; function preserveAppearance(el, copy, root = false, css = getComputedStyle(el)) { for (const p of appearanceProps) copy.style.setProperty(p, css.getPropertyValue(p)); for (const p of ['column-count','column-rule','grid-auto-rows','grid-auto-columns']) copy.style.setProperty(p, css.getPropertyValue(p)); // Resolve source grid tracks into proportions so wide cards fit the PNG width. for (const p of ['grid-template-columns','grid-template-rows']) { const tracks = css.getPropertyValue(p); if (p.endsWith('columns') && /^(?:[\d.]+px\s*)+$/.test(tracks)) { copy.style.setProperty(p, tracks.replace(/([\d.]+)px/g, 'minmax(0,$1fr)')); } else if (!p.endsWith('rows') || tracks === 'none') copy.style.setProperty(p, tracks); } copy.style.maxWidth = '100%'; copy.style.minWidth = '0'; copy.style.boxSizing = 'border-box'; // Keep content responsive without copying the viewport's fixed pixel widths. const rect = el.getBoundingClientRect(), parent = el.parentElement; const parentCSS = parent && getComputedStyle(parent), parentRect = parent?.getBoundingClientRect(); const parentWidth = parentRect && parentRect.width - parseFloat(parentCSS.paddingLeft || 0) - parseFloat(parentCSS.paddingRight || 0); if (root) { copy.style.width = '100%'; copy.style.margin = '0'; } else if (!/^(inline|contents)/.test(css.display) && !/^(table-row|table-cell)/.test(css.display) && !/flex|grid/.test(parentCSS?.display || '') && rect.width > 0 && parentWidth > 0 && rect.width < parentWidth * .95) { copy.style.width = `${Math.min(100, rect.width / parentWidth * 100)}%`; } if (el.tagName === 'TABLE') { copy.style.width = '100%'; copy.style.tableLayout = 'fixed'; } if (/^(PRE|CODE)$/.test(el.tagName)) { copy.style.whiteSpace = 'pre-wrap'; copy.style.overflowWrap = 'anywhere'; } if (css.position === 'absolute') { copy.style.position = 'absolute'; for (const p of ['top','right','bottom','left','z-index']) copy.style.setProperty(p, css.getPropertyValue(p)); // Absolute offsets refer to the positioned ancestor, not necessarily the parent. const containing = el.offsetParent; if (containing?.getBoundingClientRect().width > 0) { for (const p of ['left','right']) if (css.getPropertyValue(p).endsWith('px')) copy.style.setProperty(p, `${parseFloat(css.getPropertyValue(p)) / containing.clientWidth * 100}%`); copy.style.width = `${Math.min(100, rect.width / containing.clientWidth * 100)}%`; } copy.style.minHeight = rect.height > 0 ? `${rect.height}px` : css.height; } else if (css.position === 'relative') copy.style.position = 'relative'; // Only all-positioned diagrams lack intrinsic height. A floating helper in // normal prose must never freeze that prose to its old viewport height. const positions = [...el.children].map(child => getComputedStyle(child)); const hasText = [...el.childNodes].some(child => child.nodeType === Node.TEXT_NODE && child.textContent.trim()); const hasFlow = hasText || positions.some(style => style.display !== 'none' && !['absolute','fixed'].includes(style.position)); if (!root && !hasFlow && (positions.some(style => style.position === 'absolute') || !el.children.length)) { copy.style.height = rect.height > 0 ? `${rect.height}px` : css.height; } } function preservePseudo(el, copy) { if (el.namespaceURI !== 'http://www.w3.org/1999/xhtml') return; for (const which of ['::before','::after']) { const css = getComputedStyle(el, which), content = css.content; if (css.display === 'none' || !content || /^(none|normal)$/.test(content)) continue; // Materialize generated text/dots/lines; skip external generated images. if (!/^"(?:[^"\\]|\\.)*"$/.test(content)) continue; const pseudo = document.createElement('span'); pseudo.dataset.gptSharePseudo = which.slice(2); try { pseudo.textContent = JSON.parse(content); } catch { pseudo.textContent = content.slice(1,-1); } preserveAppearance(el, pseudo, false, css); pseudo.style.width = css.width; pseudo.style.height = css.height; pseudo.style.minHeight = css.minHeight; for (const p of ['position','top','right','bottom','left','transform','transform-origin','z-index']) pseudo.style.setProperty(p, css.getPropertyValue(p)); if (which === '::before') copy.prepend(pseudo); else copy.append(pseudo); } } function sourceLabel(el) { const text = el.textContent.replace(/\s+/g,' ').trim(); if (!text) return document.createTextNode(''); const badge = document.createElement('span'); badge.dataset.gptShareSource = ''; badge.textContent = text; badge.style.cssText = 'display:inline-block;vertical-align:middle;box-sizing:border-box;max-width:180px;padding:1px 7px;margin:0 3px;border-radius:10px;background:#f0f2f4;color:#5d6771;font:11px/18px Arial,"PingFang SC",sans-serif;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:left'; return badge; } function cardBackground(el) { for (let current = el; current; current = current.parentElement) { const bg = getComputedStyle(current).backgroundColor; if (bg !== 'transparent' && !/rgba\([^)]*,\s*0\)$/.test(bg)) return bg; } return '#fff'; } function exportSVG(svg, presentation) { const copy = svg.cloneNode(true); const originals = [svg, ...svg.querySelectorAll('*')]; const clones = [copy, ...copy.querySelectorAll('*')]; originals.forEach((el,i) => { const c = clones[i], css = getComputedStyle(el); for (const attr of [...c.attributes]) { if (/^on/i.test(attr.name) || /(?:href)$/i.test(attr.name) && !attr.value.startsWith('#')) c.removeAttribute(attr.name); } for (const p of ['color','fill','fill-opacity','fill-rule','stroke','stroke-width','stroke-linecap','stroke-linejoin','stroke-dasharray','stroke-opacity','opacity','font-family','font-size','font-weight']) c.style.setProperty(p, css.getPropertyValue(p)); }); copy.querySelectorAll('script,style,foreignObject,iframe,image').forEach(el => el.remove()); copy.setAttribute('xmlns','http://www.w3.org/2000/svg'); const rect = svg.getBoundingClientRect(); const width = rect.width || Number(svg.getAttribute('width')) || 24; const height = rect.height || Number(svg.getAttribute('height')) || 24; if (!copy.hasAttribute('viewBox')) copy.setAttribute('viewBox',`0 0 ${width} ${height}`); // Rasterize SVG at export resolution while retaining its CSS display size. copy.setAttribute('width',width * 2); copy.setAttribute('height',height * 2); copy.style.width = `${width * 2}px`; copy.style.height = `${height * 2}px`; const img = document.createElement('img'); img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(copy))}`; img.alt = svg.getAttribute('aria-label') || ''; img.style.cssText = presentation; img.style.width = `${width}px`; img.style.height = 'auto'; img.style.maxWidth = '100%'; img.style.verticalAlign = 'middle'; img.style.flexShrink = '0'; return img; } function cleanMessage(node) { const copy = node.cloneNode(true); const original = [node, ...node.querySelectorAll('*')]; const cloned = [copy, ...copy.querySelectorAll('*')]; const badges = sourceBadges(node); original.forEach((el, i) => { const c = cloned[i]; if (c !== copy && !copy.contains(c)) return; if (badges.has(el)) { c.replaceWith(sourceLabel(el)); return; } c.removeAttribute('id'); for (const attr of [...c.attributes]) if (/^on/i.test(attr.name)) c.removeAttribute(attr.name); c.removeAttribute('style'); preserveAppearance(el, c, el === node); if (el.tagName.toLowerCase() === 'svg' && !el.closest('.katex')) { c.replaceWith(exportSVG(el, c.style.cssText)); return; } if (el.closest('.katex')) { const css = getComputedStyle(el); for (const p of mathProps) c.style.setProperty(p, css.getPropertyValue(p)); } if (el.tagName === 'CANVAS') { try { const img = document.createElement('img'); img.src = el.toDataURL(); img.style.cssText = c.style.cssText; img.style.width = `${el.getBoundingClientRect().width}px`; img.style.height = 'auto'; c.replaceWith(img); } catch { c.replaceWith(document.createTextNode('[画布无法读取]')); } } if (el.tagName === 'IMG') { if (decorativeImage(el)) { c.remove(); return; } c.src = el.currentSrc || el.src || el.getAttribute('data-src') || ''; // Capture an already loaded, origin-clean image without requesting it again. if (el.complete && el.naturalWidth) { try { c.src = rasterImage(el); } catch { /* use the image loader below */ } } for (const attr of ['srcset','loading','width','height','crossorigin','referrerpolicy']) c.removeAttribute(attr); const rect = el.getBoundingClientRect(); c.style.width = rect.width > 0 ? `${rect.width}px` : 'auto'; c.style.height = 'auto'; } // Image cards may mark the visible image aria-hidden because the button labels it. const hasImage = el.tagName === 'IMG' || el.querySelector('img'); if (el.hidden || el.getAttribute('aria-hidden') === 'true' && !hasImage && !el.closest('.katex')) c.remove(); if (copy.contains(c)) preservePseudo(el, c); }); // Retain the source palette together, even when the outer card uses a different theme. copy.style.backgroundColor = cardBackground(node); copy.dataset.gptShareAppearance = ''; copy.querySelectorAll('script,style,iframe,video,audio,form,input,textarea,select,.turn-action-controls,.sr-only,.katex-mathml').forEach(el => el.remove()); // sources can override an embedded data URL inside the export frame. copy.querySelectorAll('picture source').forEach(el => el.remove()); copy.querySelectorAll('button').forEach(el => { // Image cards are buttons too: unwrap them, preserving their actual content. if (el.querySelector('img,p,table') || el.textContent.trim().length > 80) el.replaceWith(...el.childNodes); else el.remove(); }); copy.querySelectorAll('svg').forEach(el => { if (!el.closest('.katex')) el.remove(); }); copy.querySelectorAll('a').forEach(el => { if (/^javascript:/i.test(el.getAttribute('href') || '')) el.removeAttribute('href'); }); // Code headers (language/copy controls) are outside and should not become paragraphs. copy.querySelectorAll('pre').forEach(pre => { const code = pre.querySelector('code'); if (code) pre.replaceChildren(code); }); if (roleOf(node) === 'user') copy.setAttribute('data-message-author-role','user'); return copy; } function collect(prepend = false) { const nodes = messages(); const keys = nodes.map(keyOf); let inserted = 0; nodes.forEach((node, i) => { const key = keys[i], role = roleOf(node); const raw = node.innerHTML; const old = records.findIndex(r => r.key === key); const cached = snapshots.get(node); if (old >= 0 && cached?.key === key && cached.raw === raw) return; const copy = cleanMessage(node); const record = { key, role, copy, text: copy.textContent.trim() || (copy.querySelector('img') ? '[图片]' : '') }; if (!record.text) return; snapshots.set(node, {key,raw}); if (old >= 0) { records[old] = record; return; } const next = keys.slice(i + 1).map(k => records.findIndex(r => r.key === k)).find(index => index >= 0); const prev = i ? records.findIndex(r => r.key === keys[i - 1]) : -1; records.splice(next !== undefined ? next : prev >= 0 ? prev + 1 : prepend ? inserted : records.length, 0, record); selected.add(key); inserted++; }); } function scroller() { const node = messages()[0]; for (let el = node?.parentElement; el && el !== document.body; el = el.parentElement) { if (el.scrollHeight > el.clientHeight + 20 && /(auto|scroll)/.test(getComputedStyle(el).overflowY)) return el; } return document.scrollingElement; } function assertSource() { if (location.href !== sourceURL) throw new Error('对话页面已经切换,请在新对话中重新读取。'); } async function scan() { if (busy) return; sourceURL = location.href; stop = false; records = []; snapshots = new WeakMap(); selected.clear(); clearOutputs(); showSelection(); setBusy(true, true); const scroll = scroller(), oldTop = scroll.scrollTop; const reversed = getComputedStyle(scroll).flexDirection === 'column-reverse'; const extent = () => Math.max(0, scroll.scrollHeight - scroll.clientHeight); const readTop = () => reversed ? extent() + scroll.scrollTop : scroll.scrollTop; const setTop = value => { scroll.scrollTop = reversed ? value - extent() : value; }; const oldBehavior = scroll.style.scrollBehavior, oldSnap = scroll.style.scrollSnapType; scroll.style.scrollBehavior = 'auto'; scroll.style.scrollSnapType = 'none'; let complete = false; const started = Date.now(); try { collect(); let topStable = 0, lastFirst = ''; // Revisit the top until both the position and oldest loaded turn stop changing. for (let i = 0; i < 20 && topStable < 3; i++) { assertSource(); if (stop) break; setTop(0); await wait(240); collect(true); const first = messages()[0]; const firstKey = first ? keyOf(first) : ''; topStable = readTop() <= 2 && firstKey === lastFirst ? topStable + 1 : 0; lastFirst = firstKey; } if (topStable < 3 && !stop) throw new Error('历史消息仍在加载,暂时无法确认已读到开头,请稍后重新读取。'); let bottomStable = 0, lastSignature = ''; for (let i = 0; i < 600 && !stop; i++) { assertSource(); collect(); status(`正在读取对话… 已找到 ${records.length} 条消息。\n页面会自动滚动,读取后恢复原位置。`); const bottom = extent(); const signature = `${scroll.scrollHeight}:${records.length}:${messages().at(-1) ? keyOf(messages().at(-1)) : ''}`; if (readTop() >= bottom - 3) { bottomStable = signature === lastSignature ? bottomStable + 1 : 0; if (bottomStable >= 3) { complete = true; break; } } else bottomStable = 0; lastSignature = signature; setTop(Math.min(bottom, readTop() + Math.max(240, scroll.clientHeight * .7))); await wait(180); if (Date.now() - started > 90000) break; } if (!records.length) throw new Error('没有识别到对话。请打开一段 ChatGPT 对话,等回答结束后重试。'); if (sourceURL === location.href) { renderList(); status(complete ? `已读取 ${records.length} 条消息。可全选,或只勾选要分享的内容。` : `读取已停止,目前找到 ${records.length} 条消息。尚未确认整段完整,可重新读取。`, !complete); } } catch (error) { renderList(); status(error.message, true); } finally { if (sourceURL === location.href) scroll.scrollTop = oldTop; scroll.style.scrollBehavior = oldBehavior; scroll.style.scrollSnapType = oldSnap; setBusy(false); updateCount(); } } function updateCount() { $('count').textContent = `${selected.size} / ${records.length} 条`; } function renderList() { $('list').replaceChildren(); records.forEach((record, i) => { const label = document.createElement('label'); label.className = 'row'; const checkbox = document.createElement('input'); checkbox.type = 'checkbox'; checkbox.checked = selected.has(record.key); checkbox.addEventListener('change', () => { checkbox.checked ? selected.add(record.key) : selected.delete(record.key); updateCount(); }); const span = document.createElement('span'), title = document.createElement('b'), text = document.createElement('small'); title.textContent = `${i + 1} · ${record.role === 'user' ? '你' : 'ChatGPT'}`; text.textContent = record.text.slice(0, 220); span.append(title, text); label.append(checkbox, span); $('list').append(label); }); updateCount(); } function clearOutputs() { for (const out of outputs) URL.revokeObjectURL(out.url); outputs = []; $('previews').replaceChildren(); } function showSelection() { $('list').style.display = 'block'; $('previews').style.display = 'none'; $('back').hidden = true; $('generate').hidden = false; ui.querySelector('.options').style.display = 'grid'; ui.querySelector('.tools').style.display = 'flex'; } function makeFrame(dark) { const frame = document.createElement('iframe'); frame.setAttribute('sandbox', 'allow-same-origin'); frame.setAttribute('aria-hidden', 'true'); frame.dataset.html2canvasIgnore = 'true'; frame.style.cssText = 'position:fixed;left:-10000px;top:0;width:760px;height:1000px;border:0;pointer-events:none;'; document.body.append(frame); const d = frame.contentDocument; const bg = dark ? '#17221d' : '#ffffff', fg = dark ? '#e2ebe5' : '#20312a'; d.open(); d.write(''); d.close(); const style = d.createElement('style'); style.textContent = `*{box-sizing:border-box}html,body{margin:0;padding:0;background:${bg};color:${fg};font-family:Arial,"PingFang SC","Microsoft YaHei",sans-serif;font-size:18px;line-height:1.75}#sheet{width:760px;padding:32px 38px 24px;background:${bg};overflow:hidden} h1{font-size:27px;line-height:1.45;margin:0 0 9px;overflow-wrap:anywhere}.meta,.foot{font-size:12px;color:${dark?'#9bab9f':'#76837b'}}.head{margin-bottom:24px;border-bottom:1px solid ${dark?'#34483b':'#e0e9e3'};padding-bottom:20px}.msg{padding:20px 24px;margin:16px 0;border:1px solid ${dark?'#34483b':'#e0e9e3'};border-radius:14px;overflow:hidden;background:${bg};break-inside:avoid}.msg.user{background:${dark?'#253c2d':'#f1f6f2'}}.role{font-size:12px;line-height:1.5;color:${dark?'#b1c4b6':'#52745c'};font-weight:700;margin-bottom:12px}.content{overflow-wrap:anywhere}.content div{max-height:none;overflow:visible}.content p{margin:0 0 14px}.content p:last-child{margin-bottom:0}.content h1,.content h2,.content h3,.content h4{font-weight:700;margin:22px 0 12px;line-height:1.5}.content h1{font-size:26px}.content h2{font-size:23px}.content h3{font-size:21px}.content ul,.content ol{padding-left:25px;margin:12px 0}.content li{margin:5px 0}.content blockquote{margin:16px 0;padding:4px 0 4px 16px;border-left:3px solid #83a28a;color:${dark?'#b6c7bc':'#586d60'}}.content a{color:${dark?'#98d8b6':'#236b4b'};text-decoration:underline}.content pre{background:${dark?'#111a15':'#f4f6f4'};border-radius:9px;padding:16px;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;font-size:14px;line-height:1.6;margin:16px 0}.content code{font-family:Menlo,Consolas,monospace;font-size:15px;white-space:pre-wrap}.content pre code{font-size:inherit}.content table{width:100%;border-collapse:collapse;table-layout:fixed;font-size:15px;margin:16px 0}.content td,.content th{border:1px solid ${dark?'#425347':'#dce5de'};padding:9px;overflow-wrap:anywhere}.content th{background:${dark?'#25382b':'#edf3ee'}}.content img{display:block;max-width:100%;max-height:1800px;height:auto;margin:12px 0;object-fit:contain}.content hr{border:0;border-top:1px solid ${dark?'#34483b':'#dfe7e1'};margin:20px 0}.content [data-message-author-role=user],.content .whitespace-pre-wrap{white-space:pre-wrap}.foot{padding-top:16px;margin-top:18px;border-top:1px solid ${dark?'#34483b':'#e0e9e3'}}.gap{font-size:12px;text-align:center;color:${dark?'#9bab9f':'#76837b'};margin:10px 0}.placeholder{padding:16px;border:1px dashed #83998a;border-radius:8px;font-size:13px}.katex-mathml{display:none}.katex{font-size:1.1em!important}.katex-display{display:block;text-align:center;margin:16px 0;overflow:hidden}`; d.head.append(style); const sheet = d.createElement('div'); sheet.id = 'sheet'; d.body.append(sheet); // Reuse the fonts the site has already loaded, including KaTeX's math fonts. for (const face of document.fonts) { try { d.fonts.add(face); } catch { /* fallback to system fonts */ } } return { frame, d, sheet, bg }; } async function embedImages(sheet) { let failed = 0; const pending = new Map(); const embed = url => { if (!pending.has(url)) pending.set(url, embedImage(url)); return pending.get(url); }; await Promise.all([...sheet.querySelectorAll('img')].map(async img => { const url = img.src; try { img.src = await embed(url); await img.decode(); } catch { failed++; const placeholder = sheet.ownerDocument.createElement('div'); placeholder.className = 'placeholder'; placeholder.textContent = `[图片无法嵌入${img.alt ? `:${img.alt}` : ',原站未允许读取'}]`; img.replaceWith(placeholder); } })); await Promise.all([...sheet.querySelectorAll('[style]')].map(async el => { const bg = el.style.backgroundImage; if (!bg.includes('url(')) return; const urls = [...bg.matchAll(/url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)/g)]; let embedded = bg; try { for (const match of urls) embedded = embedded.replace(match[0], `url("${await embed((match[1] || match[2] || match[3]).trim())}")`); el.style.backgroundImage = embedded; } catch { failed++; el.style.backgroundImage = 'none'; } })); return failed; } async function loadImage(url, cors = false) { const loaded = new Image(); if (cors) loaded.crossOrigin = 'anonymous'; await new Promise((resolve, reject) => { const timer = setTimeout(() => { loaded.src = ''; reject(new Error('图片读取超时')); }, 8000); loaded.onload = () => { clearTimeout(timer); resolve(); }; loaded.onerror = () => { clearTimeout(timer); reject(new Error('图片读取失败')); }; loaded.src = url; }); if (!loaded.naturalWidth || !loaded.naturalHeight) throw new Error('图片为空'); return loaded; } function requestImageBlob(url) { return new Promise((resolve, reject) => { if (typeof GM_xmlhttpRequest !== 'function') { reject(new Error('请更新油猴脚本以启用跨域配图读取')); return; } // Only retrieve an image URL already present in this reply. No page text or cookies are sent. GM_xmlhttpRequest({method:'GET', url, anonymous:true, responseType:'blob', timeout:12000, onload: response => { if (response.status < 200 || response.status >= 300 || !response.response || response.response.size > 25000000) { reject(new Error('图片响应无效')); return; } resolve(response.response); }, onerror: () => reject(new Error('图片请求失败')), ontimeout: () => reject(new Error('图片请求超时')), onabort: () => reject(new Error('图片请求已取消')) }); }); } async function embedImage(url) { const parsed = new URL(url, location.href); if (!['https:','http:','data:','blob:'].includes(parsed.protocol)) throw new Error('不支持的图片地址'); try { return rasterImage(await loadImage(url, /^https?:/.test(parsed.protocol))); } catch (error) { if (!/^https?:/.test(parsed.protocol)) throw error; // Same-origin protected attachments can use the existing site session. let blob; if (parsed.origin === location.origin) { const controller = new AbortController(), timer = setTimeout(() => controller.abort(), 10000); try { const response = await fetch(url, {credentials:'same-origin', signal:controller.signal}); if (!response.ok) throw new Error('图片请求失败'); blob = await response.blob(); if (blob.size > 25000000) throw new Error('图片过大'); } finally { clearTimeout(timer); } } else blob = await requestImageBlob(url); const objectURL = URL.createObjectURL(blob); try { return rasterImage(await loadImage(objectURL)); } finally { URL.revokeObjectURL(objectURL); } } } // Split at message/block/line boundaries; never allocate an unbounded canvas. function cutsFor(sheet, maxHeight) { const height = Math.ceil(sheet.getBoundingClientRect().height); const candidates = new Set([0, height]); const occupied = []; const rootTop = sheet.getBoundingClientRect().top; sheet.querySelectorAll('.msg,p,li,pre,tr,blockquote,h1,h2,h3,.gap').forEach(el => { const rect = el.getBoundingClientRect(); candidates.add(Math.floor(rect.top - rootTop)); candidates.add(Math.ceil(rect.bottom - rootTop)); }); const walker = sheet.ownerDocument.createTreeWalker(sheet, NodeFilter.SHOW_TEXT); while (walker.nextNode()) { const node = walker.currentNode; if (!node.textContent.trim() || node.parentElement.closest('.katex')) continue; const range = sheet.ownerDocument.createRange(); range.selectNodeContents(node); for (const r of range.getClientRects()) { if (r.width < 1 || r.height < 1) continue; occupied.push([r.top-rootTop,r.bottom-rootTop]); candidates.add(Math.ceil(r.bottom - rootTop + 2)); } } sheet.querySelectorAll('img,.katex').forEach(el => { const r=el.getBoundingClientRect(); occupied.push([r.top-rootTop,r.bottom-rootTop]); }); const sorted = [...candidates].filter(x => x >= 0 && x <= height && !occupied.some(([top,bottom])=>x>top && x a-b); const cuts = [0]; while (cuts.at(-1) + maxHeight < height) { const start = cuts.at(-1), ceiling = start + maxHeight; const match = sorted.filter(x => x > start + maxHeight * .5 && x <= ceiling).at(-1); cuts.push(match || ceiling); } cuts.push(height); return cuts; } function fitExportHeight(sheet) { // Once images and fonts settle, grow fixed diagram boxes if narrower text // has overflowed them. Work inside out so parent/footer layout stays valid. const candidates = [...sheet.querySelectorAll('[data-gpt-share-appearance], [data-gpt-share-appearance] *')].reverse(); for (const el of candidates) { if (!el.style.height || !el.children.length || el.closest('.katex') || el.hasAttribute('data-gpt-share-source')) continue; if (el.scrollHeight > el.clientHeight + 1) el.style.height = `${Math.ceil(el.scrollHeight + el.offsetHeight - el.clientHeight)}px`; } } async function generate(direct = false) { // DOM onclick handlers pass an event; only an explicit true requests silent copying. direct = direct === true; if (busy && !direct) return; try { assertSource(); } catch (e) { if (direct) throw e; status(e.message, true); return; } const chosen = records.filter(r => selected.has(r.key)); if (!chosen.length) { status('请至少勾选一条消息。', true); return; } if (document.querySelector('button[data-testid="stop-button"]')) { status('回答还在生成,请等它结束后重新读取。', true); return; } setBusy(true); clearOutputs(); let capture; try { status('正在排版和生成图片…'); capture = makeFrame($('theme').value === 'dark'); const {d, sheet, bg} = capture; const header = d.createElement('div'); header.className = 'head'; if ($('title').value.trim()) { const h = d.createElement('h1'); h.textContent = $('title').value.trim(); header.append(h); } const meta = d.createElement('div'); meta.className = 'meta'; meta.textContent = `ChatGPT 对话 · ${chosen.length} 条消息`; header.append(meta); sheet.append(header); let previousIndex = -1; for (const record of chosen) { const index = records.indexOf(record); if (previousIndex >= 0 && index > previousIndex + 1) { const gap = d.createElement('div'); gap.className = 'gap'; gap.textContent = `已省略 ${index-previousIndex-1} 条消息`; sheet.append(gap); } const msg = d.createElement('div'); msg.className = `msg ${record.role}`; const role = d.createElement('div'); role.className = 'role'; role.textContent = record.role === 'user' ? '你' : 'ChatGPT'; const body = d.createElement('div'); body.className = 'content'; body.append(d.importNode(record.copy, true)); msg.append(role, body); sheet.append(msg); previousIndex = index; } const foot = d.createElement('div'); foot.className = 'foot'; foot.textContent = 'ChatGPT · 对话分享'; sheet.append(foot); const failedImages = await embedImages(sheet); await d.fonts.ready; await wait(100); fitExportHeight(sheet); const height = Math.ceil(sheet.scrollHeight); if (direct && height > 32000) throw new Error('这条回答过长,请用“分享为图片”分图保存。'); const cuts = direct ? [0, height] : cutsFor(sheet, Number($('length').value)); const scale = direct ? Math.min(2, 32760 / height, Math.sqrt(48000000 / (760 * height))) : 2; if (cuts.length > 41) throw new Error('所选内容超过 40 张图片,请减少选择后分批导出。'); for (let i = 0; i < cuts.length - 1; i++) { assertSource(); status(`正在生成第 ${i+1} / ${cuts.length-1} 张图片…`); const canvas = await renderCanvas(sheet, { backgroundColor: bg, scale, width: 760, height: cuts[i+1]-cuts[i], x: 0, y: cuts[i], scrollX: 0, scrollY: 0, windowWidth: 760, windowHeight: 1000, useCORS: true, logging: false, imageTimeout: 8000 }); const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png')); canvas.width = 1; canvas.height = 1; if (!blob) throw new Error('图片生成失败,请减少消息数量后重试。'); outputs.push({blob, url:URL.createObjectURL(blob)}); } if (direct) return {blob: outputs[0].blob, failedImages}; showPreviews(); status(`已生成 ${outputs.length} 张高清图片。${failedImages ? `\n${failedImages} 张原图因无法读取已用提示框标明。` : ''}`); } catch (error) { clearOutputs(); if (direct) throw error; showSelection(); status(`生成失败:${error.message}`, true); } finally { capture?.frame.remove(); if (!direct) setBusy(false); } } function filename(index) { const name = ($('title').value || 'ChatGPT对话').replace(/[\\/:*?"<>|\x00-\x1f]/g, '_').slice(0, 70); return `${name}-${String(index+1).padStart(2,'0')}.png`; } function save(index) { const a = document.createElement('a'); a.href = outputs[index].url; a.download = filename(index); document.body.append(a); a.click(); a.remove(); } async function copyImage(index) { try { if (!navigator.clipboard?.write || !globalThis.ClipboardItem) throw new Error('当前浏览器不允许复制图片'); await navigator.clipboard.write([new ClipboardItem({'image/png':outputs[index].blob})]); status(`第 ${index+1} 张图片已复制,可以粘贴给朋友。`); } catch { status('浏览器没有允许复制。可点击“保存 PNG”,或右键预览图片复制。', true); } } function showPreviews() { $('list').style.display = 'none'; $('previews').style.display = 'block'; $('back').hidden = false; $('generate').hidden = true; ui.querySelector('.options').style.display = 'none'; ui.querySelector('.tools').style.display = 'none'; outputs.forEach((out, i) => { const item = document.createElement('div'); item.className = 'preview'; const actions = document.createElement('div'); actions.className = 'actions'; const saveButton = document.createElement('button'); saveButton.textContent = `保存 PNG · ${i+1}/${outputs.length}`; saveButton.onclick = () => save(i); const copyButton = document.createElement('button'); copyButton.textContent = '复制图片'; copyButton.onclick = () => copyImage(i); const image = document.createElement('img'); image.src = out.url; image.alt = `对话分享图片 ${i+1}`; actions.append(saveButton, copyButton); item.append(actions, image); $('previews').append(item); }); } function showPanel() { lastFocus = document.activeElement; $('veil').style.display = 'block'; $('panel').style.display = 'flex'; $('launch').hidden = true; $('title').value = document.title.replace(/\s*[-–|]\s*ChatGPT\s*$/i, '').replace(/^ChatGPT$/i, ''); $('close').focus(); } async function open() { if (busy) return; clearTimeout(toastTimer); $('toast').style.display = 'none'; showPanel(); await scan(); } async function openSingle(node) { if (busy || !node.isConnected) return; const copy = cleanMessage(node); const text = copy.textContent.trim() || (copy.querySelector('img') ? '[图片]' : ''); if (!text) return; sourceURL = location.href; stop = false; const key = keyOf(node); records = [{key, role: roleOf(node), copy, text}]; selected = new Set([key]); clearOutputs(); renderList(); $('title').value = document.title.replace(/\s*[-–|]\s*ChatGPT\s*$/i, '').replace(/^ChatGPT$/i, ''); if (document.querySelector('button[data-testid="stop-button"]')) { toast('回答还在生成,请等它结束后再复制。'); return; } if (!navigator.clipboard?.write || !globalThis.ClipboardItem) { toast('浏览器不支持复制图片,请用“分享为图片”保存。'); return; } setBusy(true); toast('正在生成并复制图片…', false, 0); // Start clipboard.write in the click gesture; resolve its PNG after rendering. const rendering = Promise.resolve().then(() => generate(true)); const png = rendering.then(result => result.blob); png.catch(() => {}); let writing; try { writing = navigator.clipboard.write([new ClipboardItem({'image/png': png})]); } catch (error) { writing = Promise.reject(error); } const [rendered, copied] = await Promise.allSettled([rendering, writing]); setBusy(false); if (rendered.status === 'rejected' || !rendered.value) { toast(`生成失败:${rendered.reason?.message || '请稍后重试。'}`, false, 7000); clearOutputs(); } else if (copied.status === 'rejected') { toast('图片已生成,但浏览器未允许复制。', true, 0); } else { toast(`图片已复制,可以直接粘贴。${rendered.value.failedImages ? `(${rendered.value.failedImages} 张原图无法读取,已标明。)` : ''}`); clearOutputs(); } } function close() { if (busy) { stop = true; status('正在停止读取…'); return; } $('veil').style.display = 'none'; $('panel').style.display = 'none'; $('launch').hidden = false; clearOutputs(); records = []; selected.clear(); lastFocus?.focus(); } $('launch').onclick = open; $('close').onclick = close; $('veil').onclick = close; $('reload').onclick = scan; $('cancel').onclick = () => { stop = true; }; $('all').onclick = () => { selected = new Set(records.map(r=>r.key)); renderList(); }; $('none').onclick = () => { selected.clear(); renderList(); }; $('ai').onclick = () => { selected = new Set(records.filter(r=>r.role==='assistant').map(r=>r.key)); renderList(); }; $('generate').onclick = generate; $('back').onclick = () => { showSelection(); status(`已读取 ${records.length} 条消息。`); }; ui.addEventListener('keydown', event => { if (event.key === 'Escape') close(); if (event.key !== 'Tab' || $('panel').style.display !== 'flex') return; const controls = [...$('panel').querySelectorAll('button,input,select')].filter(el => !el.disabled && !el.hidden && el.getClientRects().length); const first = controls[0], last = controls.at(-1); if (event.shiftKey && ui.activeElement === first) { event.preventDefault(); last.focus(); } else if (!event.shiftKey && ui.activeElement === last) { event.preventDefault(); first.focus(); } }); if (typeof GM_registerMenuCommand === 'function') GM_registerMenuCommand('分享当前对话为图片', open); const singleStyle = document.createElement('style'); singleStyle.id = 'gpt-share-single-style'; singleStyle.textContent = ` button[data-gpt-share-single]{display:inline-flex;align-items:center;justify-content:center;gap:5px;flex-shrink:0;width:32px;height:32px;min-width:32px;padding:6px;border:0;border-radius:8px;background:transparent;color:inherit;opacity:.65;cursor:pointer;font:500 12px/20px system-ui,-apple-system,"PingFang SC",sans-serif;vertical-align:middle} button[data-gpt-share-single]:hover{opacity:1;background:color-mix(in srgb,currentColor 8%,transparent)} button[data-gpt-share-single]:focus-visible{opacity:1;outline:2px solid #23845e;outline-offset:2px} button[data-gpt-share-single] svg{width:18px;height:18px;flex-shrink:0} `; document.head.append(singleStyle); const singleButtons = new WeakMap(); function actionBar(node) { // The current renderer puts the footer beside the message search unit. for (let scope = node, i = 0; scope && scope.tagName !== 'MAIN' && i < 8; scope = scope.parentElement, i++) { if (scope.querySelectorAll('[data-conversation-role="assistant"], [data-message-author-role="assistant"]').length > 1) break; const copy = scope.querySelector('[data-testid="copy-turn-action-button"]'); if (copy) return copy.parentElement; const bars = [...scope.querySelectorAll('.turn-action-controls')]; const controls = bars.find(bar => bar.querySelector('button[aria-label="复制"], button[aria-label="Copy"], button[aria-label="更多操作"], button[aria-label="More actions"]')) || bars.find(bar => !bar.querySelector('button[aria-label="复制消息"], button[aria-label="Copy message"], button[aria-label="编辑消息"], button[aria-label="Edit message"]')); if (controls) return controls; } // Older layouts without native action markers still get a footer button. return node; } function addSingleButtons() { for (const node of messages()) { if (roleOf(node) !== 'assistant') continue; const bar = actionBar(node); const existing = singleButtons.get(node); if (existing?.isConnected && existing.parentElement === bar) continue; existing?.remove(); const button = document.createElement('button'); button.type = 'button'; button.dataset.gptShareSingle = ''; button.title = '将这条回答复制为图片'; button.setAttribute('aria-label', '将这条回答复制为图片'); button.disabled = busy; button.innerHTML = ''; button.addEventListener('click', event => { event.preventDefault(); event.stopPropagation(); openSingle(node); }); singleButtons.set(node, button); bar.append(button); } } let singleTimer; const owned = node => node.nodeType === Node.ELEMENT_NODE && (node === host || node === singleStyle || node.matches('[data-gpt-share-single]')); new MutationObserver(changes => { if (!changes.some(change => !host.contains(change.target) && !change.target.closest?.('[data-gpt-share-single]') && [...change.addedNodes, ...change.removedNodes].some(node => !owned(node)))) return; clearTimeout(singleTimer); singleTimer = setTimeout(addSingleButtons, 150); }).observe(document.body, {childList:true, subtree:true}); addSingleButtons(); })(); })();