@zumer/snapdom 1.9.12-dev.2 → 1.9.12-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/snapdom.js +556 -182
- package/dist/snapdom.min.js +5 -5
- package/dist/snapdom.min.mjs +5 -5
- package/dist/snapdom.mjs +551 -178
- package/package.json +1 -1
package/dist/snapdom.min.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
`;return n}function
|
|
3
|
-
`});let n=t.adoptedStyleSheets||[];for(let
|
|
4
|
-
`}catch{}}catch{}return e}function
|
|
5
|
-
`:""}function Ve(t){t&&(t.nodeType===Node.ELEMENT_NODE&&t.setAttribute("data-sd-slotted",""),t.querySelectorAll&&t.querySelectorAll("*").forEach(e=>e.setAttribute("data-sd-slotted","")))}async function Xe(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},r=n(),o=0;for(;o<e&&(!r||!r.body&&!r.documentElement);)await new Promise(s=>setTimeout(s,0)),r=n(),o++;return r&&(r.body||r.documentElement)?r:null}function Ge(t){let e=t.getBoundingClientRect(),n=0,r=0,o=0,s=0;try{let f=getComputedStyle(t);n=parseFloat(f.borderLeftWidth)||0,r=parseFloat(f.borderRightWidth)||0,o=parseFloat(f.borderTopWidth)||0,s=parseFloat(f.borderBottomWidth)||0}catch{}let a=Math.max(0,Math.round(e.width-(n+r))),i=Math.max(0,Math.round(e.height-(o+s)));return{contentWidth:a,contentHeight:i,rect:e}}function Ke(t,e,n){let r=t.createElement("style");return r.setAttribute("data-sd-iframe-pin",""),r.textContent=`html, body {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(t.head||t.documentElement).appendChild(r),()=>{try{r.remove()}catch{}}}async function Ye(t,e,n){let r=await Xe(t,3);if(!r)throw new Error("iframe document not accessible/ready");let{contentWidth:o,contentHeight:s,rect:a}=Ge(t),i=n?.snap;if(!i||typeof i.toPng!="function")throw new Error("snapdom.toPng not available in iframe or window");let f={...n,scale:1},c=Ke(r,o,s),l;try{l=await i.toPng(r.documentElement,f)}finally{c()}l.style.display="block",l.style.width=`${o}px`,l.style.height=`${s}px`;let u=document.createElement("div");return e.nodeMap.set(u,t),nt(t,u,e,n),u.style.overflow="hidden",u.style.display="block",u.style.width||(u.style.width=`${Math.round(a.width)}px`),u.style.height||(u.style.height=`${Math.round(a.height)}px`),u.appendChild(l),u}async function it(t,e,n){if(!t)throw new Error("Invalid node");let r=new Set,o=null,s=null;if(t.nodeType===Node.ELEMENT_NODE){let c=(t.localName||t.tagName||"").toLowerCase();if(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox")||dt.has(c))return null}if(t.nodeType===Node.TEXT_NODE||t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if(t.getAttribute("data-capture")==="exclude"){if(n.excludeMode==="hide"){let c=document.createElement("div"),l=t.getBoundingClientRect();return c.style.cssText=`display:inline-block;width:${l.width}px;height:${l.height}px;visibility:hidden;`,c}else if(n.excludeMode==="remove")return null}if(n.exclude&&Array.isArray(n.exclude))for(let c of n.exclude)try{if(t.matches?.(c)){if(n.excludeMode==="hide"){let l=document.createElement("div"),u=t.getBoundingClientRect();return l.style.cssText=`display:inline-block;width:${u.width}px;height:${u.height}px;visibility:hidden;`,l}else if(n.excludeMode==="remove")return null}}catch(l){console.warn(`Invalid selector in exclude option: ${c}`,l)}if(typeof n.filter=="function")try{if(!n.filter(t)){if(n.filterMode==="hide"){let c=document.createElement("div"),l=t.getBoundingClientRect();return c.style.cssText=`display:inline-block;width:${l.width}px;height:${l.height}px;visibility:hidden;`,c}else if(n.filterMode==="remove")return null}}catch(c){console.warn("Error in filter function:",c)}if(t.tagName==="IFRAME"){let c=!1;try{c=!!(t.contentDocument||t.contentWindow?.document)}catch{c=!1}if(c)try{return await Ye(t,e,n)}catch(l){console.warn("[SnapDOM] iframe rasterization failed, fallback:",l)}if(n.placeholders){let l=document.createElement("div");return l.style.cssText=`width:${t.offsetWidth}px;height:${t.offsetHeight}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`,nt(t,l,e,n),l}else{let l=t.getBoundingClientRect(),u=document.createElement("div");return u.style.cssText=`display:inline-block;width:${l.width}px;height:${l.height}px;visibility:hidden;`,nt(t,u,e,n),u}}if(t.getAttribute("data-capture")==="placeholder"){let c=t.cloneNode(!1);e.nodeMap.set(c,t),nt(t,c,e,n);let l=document.createElement("div");return l.textContent=t.getAttribute("data-placeholder-text")||"",l.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",c.appendChild(l),c}if(t.tagName==="CANVAS"){let c=t.toDataURL(),l=document.createElement("img");return l.src=c,l.width=t.width,l.height=t.height,e.nodeMap.set(l,t),nt(t,l,e,n),l}let a;try{if(a=t.cloneNode(!1),e.nodeMap.set(a,t),t.tagName==="IMG"){He(t,a);try{let c=t.getBoundingClientRect(),l=Math.round(c.width||0),u=Math.round(c.height||0);if(!l||!u){let g=window.getComputedStyle(t),L=parseFloat(g.width)||0,x=parseFloat(g.height)||0,A=parseInt(t.getAttribute("width")||"",10)||0,h=parseInt(t.getAttribute("height")||"",10)||0,S=t.width||t.naturalWidth||0,C=t.height||t.naturalHeight||0;l=Math.round(l||L||A||S||0),u=Math.round(u||x||h||C||0)}l&&(a.dataset.snapdomWidth=String(l)),u&&(a.dataset.snapdomHeight=String(u))}catch{}}}catch(c){throw console.error("[Snapdom] Failed to clone node:",t,c),c}if(t instanceof HTMLTextAreaElement){let c=t.getBoundingClientRect();a.style.width=`${c.width}px`,a.style.height=`${c.height}px`}if(t instanceof HTMLInputElement&&(a.value=t.value,a.setAttribute("value",t.value),t.checked!==void 0&&(a.checked=t.checked,t.checked&&a.setAttribute("checked",""),t.indeterminate&&(a.indeterminate=t.indeterminate))),t instanceof HTMLSelectElement&&(o=t.value),t instanceof HTMLTextAreaElement&&(s=t.value),nt(t,a,e,n),t.shadowRoot){let h=function(C,E){if(C.nodeType===Node.ELEMENT_NODE&&C.tagName==="STYLE")return E(null);it(C,e,n).then(N=>{E(N||null)}).catch(N=>{E(null)})};try{let C=t.shadowRoot.querySelectorAll("slot");for(let E of C){let N=[];try{N=E.assignedNodes?.({flatten:!0})||E.assignedNodes?.()||[]}catch{N=E.assignedNodes?.()||[]}for(let W of N)r.add(W)}}catch{}let c=Be(e),l=`[data-sd="${c}"]`;try{a.setAttribute("data-sd",c)}catch{}let u=Oe(t.shadowRoot),g=We(u,l),L=qe(u),x=ze(t,L,l);De(a,x+g,c);let A=document.createDocumentFragment(),S=await Pt(Array.from(t.shadowRoot.childNodes),h,n.fast);A.append(...S.filter(C=>!!C)),a.appendChild(A)}if(t.tagName==="SLOT"){let g=function(x,A){it(x,e,n).then(h=>{h&&Ve(h),A(h||null)}).catch(h=>{A(null)})},c=t.assignedNodes?.({flatten:!0})||[],l=c.length>0?c:Array.from(t.childNodes),u=document.createDocumentFragment(),L=await Pt(Array.from(l),g,n.fast);return u.append(...L.filter(x=>!!x)),u}function i(c,l){if(r.has(c))return l(null);it(c,e,n).then(u=>{l(u||null)}).catch(u=>{l(null)})}let f=await Pt(Array.from(t.childNodes),i,n.fast);if(a.append(...f.filter(c=>!!c)),o!==null&&a instanceof HTMLSelectElement){a.value=o;for(let c of a.options)c.value===o?c.setAttribute("selected",""):c.removeAttribute("selected")}return s!==null&&a instanceof HTMLTextAreaElement&&(a.textContent=s),a}var Je=[/font\s*awesome/i,/material\s*icons/i,/ionicons/i,/glyphicons/i,/feather/i,/bootstrap\s*icons/i,/remix\s*icons/i,/heroicons/i,/layui/i,/lucide/i],Ut=[];function Yt(t){let e=Array.isArray(t)?t:[t];for(let n of e)n instanceof RegExp?Ut.push(n):typeof n=="string"?Ut.push(new RegExp(n,"i")):console.warn("[snapdom] Ignored invalid iconFont value:",n)}function j(t){let e=typeof t=="string"?t:"",n=[...Je,...Ut];for(let r of n)if(r instanceof RegExp&&r.test(e))return!0;return!!(/icon/i.test(e)||/glyph/i.test(e)||/symbols/i.test(e)||/feather/i.test(e)||/fontawesome/i.test(e))}async function Jt(t,e,n,r=32,o="#000"){e=e.replace(/^['"]+|['"]+$/g,"");let s=window.devicePixelRatio||1;await document.fonts.ready;let a=document.createElement("span");a.textContent=t,a.style.position="absolute",a.style.visibility="hidden",a.style.fontFamily=`"${e}"`,a.style.fontWeight=n||"normal",a.style.fontSize=`${r}px`,a.style.lineHeight="1",a.style.whiteSpace="nowrap",a.style.padding="0",a.style.margin="0",document.body.appendChild(a);let i=a.getBoundingClientRect(),f=Math.ceil(i.width),c=Math.ceil(i.height);document.body.removeChild(a);let l=document.createElement("canvas");l.width=f*s,l.height=c*s;let u=l.getContext("2d");return u.scale(s,s),u.font=n?`${n} ${r}px "${e}"`:`${r}px "${e}"`,u.textAlign="left",u.textBaseline="top",u.fillStyle=o,u.fillText(t,0,0),{dataUrl:l.toDataURL(),width:f,height:c}}var Qe=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]);function ht(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^['"]+|['"]+$/g,"");if(n&&!Qe.has(n.toLowerCase()))return n}return""}function pt(t){let e=String(t??"400").trim().toLowerCase();if(e==="normal")return 400;if(e==="bold")return 700;let n=parseInt(e,10);return Number.isFinite(n)?Math.min(900,Math.max(100,n)):400}function Wt(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function Ze(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function tn(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let o=pt(n[1]),s=pt(n[2]);return{min:Math.min(o,s),max:Math.max(o,s)}}let r=pt(e);return{min:r,max:r}}function en(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function nn(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let s=parseFloat(n[1]),a=parseFloat(n[2]);return{min:Math.min(s,a),max:Math.max(s,a)}}let r=e.match(/(\d+(?:\.\d+)?)\s*%/),o=r?parseFloat(r[1]):100;return{min:o,max:o}}function rn(t,e){if(!t)return!1;try{let n=new URL(t,location.href);if(n.origin===location.origin)return!0;let o=n.host.toLowerCase();if(["fonts.googleapis.com","fonts.gstatic.com","use.typekit.net","p.typekit.net","kit.fontawesome.com","use.fontawesome.com"].some(i=>o.endsWith(i)))return!0;let a=(n.pathname+n.search).toLowerCase();if(/\bfont(s)?\b/.test(a)||/\.woff2?(\b|$)/.test(a))return!0;for(let i of e){let f=i.toLowerCase().replace(/\s+/g,"+"),c=i.toLowerCase().replace(/\s+/g,"-");if(a.includes(f)||a.includes(c))return!0}return!1}catch{return!1}}function on(t){let e=new Set;for(let n of t||[]){let r=String(n).split("__")[0]?.trim();r&&e.add(r)}return e}async function gt({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:r=[],useProxy:o=""}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let s=new Map;for(let d of t){let[y,w,k,p]=String(d).split("__");if(!y)continue;let b=s.get(y)||[];b.push({w:parseInt(w,10),s:k,st:parseInt(p,10)}),s.set(y,b)}let a=/@import\s+url\(["']?([^"')]+)["']?\)/g,i=/url\((["']?)([^"')]+)\1\)/g,f=/@font-face[^{}]*\{[^}]*\}/g;function c(d,y,w,k){if(!s.has(d))return!1;let p=s.get(d),b=tn(w),F=en(y),M=nn(k),$=b.min!==b.max,R=b.min,T=v=>F.kind==="normal"&&v==="normal"||F.kind!=="normal"&&(v==="italic"||v==="oblique"),P=!1;for(let v of p){let I=$?v.w>=b.min&&v.w<=b.max:v.w===R,O=T(Wt(v.s)),H=v.st>=M.min&&v.st<=M.max;if(I&&O&&H){P=!0;break}}if(P)return!0;if(!$)for(let v of p){let I=T(Wt(v.s)),O=v.st>=M.min&&v.st<=M.max;if(Math.abs(R-v.w)<=300&&I&&O)return!0}return!1}function l(d){if(!d)return[];let y=[],w=d.split(",").map(k=>k.trim()).filter(Boolean);for(let k of w){let p=k.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!p)continue;let b=p[1],F=p[2],M=$=>{if(!$.includes("?"))return parseInt($,16);let R=parseInt($.replace(/\?/g,"0"),16),T=parseInt($.replace(/\?/g,"F"),16);return[R,T]};if(F){let $=M(b),R=M(F),T=Array.isArray($)?$[0]:$,P=Array.isArray(R)?R[1]:R;y.push([Math.min(T,P),Math.max(T,P)])}else{let $=M(b);Array.isArray($)?y.push([$[0],$[1]]):y.push([$,$])}}return y}function u(d,y){if(!y.length||!d||d.size===0)return!0;for(let w of d)for(let[k,p]of y)if(w>=k&&w<=p)return!0;return!1}function g(d,y){let w=[];if(!d)return w;for(let k of d.matchAll(i)){let p=(k[2]||"").trim();if(!(!p||p.startsWith("data:"))){if(!/^https?:/i.test(p))try{p=new URL(p,y||location.href).href}catch{}w.push(p)}}return w}async function L(d,y){let w=d;for(let k of d.matchAll(i)){let p=J(k[0]);if(!p)continue;let b=p;if(!b.startsWith("http")&&!b.startsWith("data:"))try{b=new URL(b,y||location.href).href}catch{}if(!j(b)){if(m.resource?.has(b)){m.font?.add(b),w=w.replace(k[0],`url(${m.resource.get(b)})`);continue}if(!m.font?.has(b))try{let F=await D(b,{as:"dataURL",useProxy:o,silent:!0});if(F.ok&&typeof F.data=="string"){let M=F.data;m.resource?.set(b,M),m.font?.add(b),w=w.replace(k[0],`url(${M})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",b)}}}return w}function x(d){if(!d.length)return null;let y=(M,$)=>d.some(([R,T])=>!(T<M||R>$)),w=y(0,255)||y(305,305),k=y(256,591)||y(7680,7935),p=y(880,1023),b=y(1024,1279);return y(7840,7929)||y(258,259)||y(416,417)||y(431,432)?"vietnamese":b?"cyrillic":p?"greek":k?"latin-ext":w?"latin":null}function A(d={}){let y=new Set((d.families||[]).map(p=>String(p).toLowerCase())),w=new Set((d.domains||[]).map(p=>String(p).toLowerCase())),k=new Set((d.subsets||[]).map(p=>String(p).toLowerCase()));return(p,b)=>{if(y.size&&y.has(p.family.toLowerCase()))return!0;if(w.size)for(let F of p.srcUrls)try{if(w.has(new URL(F).host.toLowerCase()))return!0}catch{}if(k.size){let F=x(b);if(F&&k.has(F))return!0}return!1}}let h=A(n);function S(d){if(!d)return d;let y=/@font-face[^{}]*\{[^}]*\}/gi,w=new Set,k=[];for(let b of d.match(y)||[]){let F=b.match(/font-family:\s*([^;]+);/i)?.[1]||"",M=ht(F),$=(b.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),R=(b.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),T=(b.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),P=(b.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),v=(b.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),I=g(v,location.href),O=I.length?I.map(kt=>String(kt).toLowerCase()).sort().join("|"):v.toLowerCase(),H=[String(M||"").toLowerCase(),$,R,T,P.toLowerCase(),O].join("|");w.has(H)||(w.add(H),k.push(b))}if(k.length===0)return d;let p=0;return d.replace(y,()=>k[p++]||"")}function C(){let d=Array.from(t||[]).sort().join("|"),y=n?JSON.stringify({families:(n.families||[]).map(p=>String(p).toLowerCase()).sort(),domains:(n.domains||[]).map(p=>String(p).toLowerCase()).sort(),subsets:(n.subsets||[]).map(p=>String(p).toLowerCase()).sort()}):"",w=(r||[]).map(p=>`${(p.family||"").toLowerCase()}::${p.weight||"normal"}::${p.style||"normal"}::${p.src||""}`).sort().join("|");return`fonts-embed-css::req=${d}::ex=${y}::lf=${w}::px=${o||""}`}let E=C();if(m.resource?.has(E))return m.resource.get(E);let N=on(t),W=[];for(let d of document.querySelectorAll("style")){let y=d.textContent||"";for(let w of y.matchAll(a)){let k=w[1];if(!k||j(k))continue;!!document.querySelector(`link[rel="stylesheet"][href="${k}"]`)||W.push(k)}}W.length&&await Promise.all(W.map(d=>new Promise(y=>{if(document.querySelector(`link[rel="stylesheet"][href="${d}"]`))return y(null);let w=document.createElement("link");w.rel="stylesheet",w.href=d,w.setAttribute("data-snapdom","injected-import"),w.onload=()=>y(w),w.onerror=()=>y(null),document.head.appendChild(w)})));let _="",z=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(d=>!!d.href);for(let d of z)try{if(j(d.href))continue;let y="",w=!1;try{w=new URL(d.href,location.href).origin===location.origin}catch{}if(!w&&!rn(d.href,N))continue;if(w){let p=Array.from(document.styleSheets).find(b=>b.href===d.href);if(p)try{let b=p.cssRules||[];y=Array.from(b).map(F=>F.cssText).join("")}catch{}}if(!y&&(y=(await D(d.href,{as:"text",useProxy:o})).data,j(d.href)))continue;let k="";for(let p of y.match(f)||[]){let b=(p.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),F=ht(b);if(!F||j(F))continue;let M=(p.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),$=(p.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),R=(p.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),T=(p.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),P=(p.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),v=g(P,d.href);if(!c(F,$,M,R))continue;let I=l(T);if(!u(e,I))continue;let O={family:F,weightSpec:M,styleSpec:$,stretchSpec:R,unicodeRange:T,srcRaw:P,srcUrls:v,href:d.href};if(n&&h(O,I))continue;let H=/url\(/i.test(P)?await L(p,d.href):p;k+=H+""}k.trim()&&(_+=k+"")}catch{console.warn("[snapdom] Failed to process stylesheet:",d.href)}for(let d of document.styleSheets)try{if(d.href&&z.some(w=>w.href===d.href))continue;let y=d.cssRules||[];for(let w of y){if(w.type!==CSSRule.FONT_FACE_RULE)continue;let k=(w.style.getPropertyValue("font-family")||"").trim(),p=ht(k);if(!p||j(p))continue;let b=(w.style.getPropertyValue("font-weight")||"400").trim(),F=(w.style.getPropertyValue("font-style")||"normal").trim(),M=(w.style.getPropertyValue("font-stretch")||"100%").trim(),$=(w.style.getPropertyValue("src")||"").trim(),R=(w.style.getPropertyValue("unicode-range")||"").trim(),T=g($,d.href||location.href);if(!c(p,F,b,M))continue;let P=l(R);if(!u(e,P))continue;let v={family:p,weightSpec:b,styleSpec:F,stretchSpec:M,unicodeRange:R,srcRaw:$,srcUrls:T,href:d.href||location.href};if(!(n&&h(v,P)))if(/url\(/i.test($)){let I=await L($,d.href||location.href);_+=`@font-face{font-family:${p};src:${I};font-style:${F};font-weight:${b};font-stretch:${M};${R?`unicode-range:${R};`:""}}`}else _+=`@font-face{font-family:${p};src:${$};font-style:${F};font-weight:${b};font-stretch:${M};${R?`unicode-range:${R};`:""}}`}}catch{}try{for(let d of document.fonts||[]){if(!d||!d.family||d.status!=="loaded"||!d._snapdomSrc)continue;let y=String(d.family).replace(/^['"]+|['"]+$/g,"");if(j(y)||!s.has(y)||n?.families&&n.families.some(k=>String(k).toLowerCase()===y.toLowerCase()))continue;let w=d._snapdomSrc;if(!String(w).startsWith("data:")){if(m.resource?.has(d._snapdomSrc))w=m.resource.get(d._snapdomSrc),m.font?.add(d._snapdomSrc);else if(!m.font?.has(d._snapdomSrc))try{let k=await D(d._snapdomSrc,{as:"dataURL",useProxy:o,silent:!0});if(k.ok&&typeof k.data=="string")w=k.data,m.resource?.set(d._snapdomSrc,w),m.font?.add(d._snapdomSrc);else continue}catch{console.warn("[snapdom] Failed to fetch dynamic font src:",d._snapdomSrc);continue}}_+=`@font-face{font-family:'${y}';src:url(${w});font-style:${d.style||"normal"};font-weight:${d.weight||"normal"};}`}}catch{}for(let d of r){if(!d||typeof d!="object")continue;let y=String(d.family||"").replace(/^['"]+|['"]+$/g,"");if(!y||j(y)||!s.has(y)||n?.families&&n.families.some(M=>String(M).toLowerCase()===y.toLowerCase()))continue;let w=d.weight!=null?String(d.weight):"normal",k=d.style!=null?String(d.style):"normal",p=d.stretchPct!=null?`${d.stretchPct}%`:"100%",b=String(d.src||""),F=b;if(!F.startsWith("data:")){if(m.resource?.has(b))F=m.resource.get(b),m.font?.add(b);else if(!m.font?.has(b))try{let M=await D(b,{as:"dataURL",useProxy:o,silent:!0});if(M.ok&&typeof M.data=="string")F=M.data,m.resource?.set(b,F),m.font?.add(b);else continue}catch{console.warn("[snapdom] Failed to fetch localFonts src:",b);continue}}_+=`@font-face{font-family:'${y}';src:url(${F});font-style:${k};font-weight:${w};font-stretch:${p};}`}return _&&(_=S(_),m.resource?.set(E,_)),_}function yt(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),r=a=>{let i=ht(a.fontFamily);if(!i)return;let f=(c,l,u)=>`${i}__${pt(c)}__${Wt(l)}__${Ze(u)}`;e.add(f(a.fontWeight,a.fontStyle,a.fontStretch))};r(getComputedStyle(t));let o=getComputedStyle(t,"::before");o&&o.content&&o.content!=="none"&&r(o);let s=getComputedStyle(t,"::after");for(s&&s.content&&s.content!=="none"&&r(s);n.nextNode();){let a=n.currentNode,i=getComputedStyle(a);r(i);let f=getComputedStyle(a,"::before");f&&f.content&&f.content!=="none"&&r(f);let c=getComputedStyle(a,"::after");c&&c.content&&c.content!=="none"&&r(c)}return e}function wt(t){let e=new Set,n=o=>{if(o)for(let s of o)e.add(s.codePointAt(0))},r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;r.nextNode();){let o=r.currentNode;if(o.nodeType===Node.TEXT_NODE)n(o.nodeValue||"");else if(o.nodeType===Node.ELEMENT_NODE){let s=o;for(let a of["::before","::after"]){let f=getComputedStyle(s,a)?.getPropertyValue("content");if(!(!f||f==="none"))if(/^"/.test(f)||/^'/.test(f))n(f.slice(1,-1));else{let c=f.match(/\\[0-9A-Fa-f]{1,6}/g);if(c)for(let l of c)try{e.add(parseInt(l.slice(1),16))}catch{}}}}}return e}async function bt(t,e=2){try{await document.fonts.ready}catch{}let n=Array.from(t||[]).filter(Boolean);if(n.length===0)return;let r=()=>{let o=document.createElement("div");o.style.cssText="position: absolute !important;left: -9999px !important;top: 0 !important;opacity: 0 !important;pointer-events: none !important;contain: layout size style;";for(let s of n){let a=document.createElement("span");a.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",a.style.fontFamily=`"${s}"`,a.style.fontWeight="700",a.style.fontStyle="italic",a.style.fontSize="32px",a.style.lineHeight="1",a.style.whiteSpace="nowrap",a.style.margin="0",a.style.padding="0",o.appendChild(a)}document.body.appendChild(o),o.offsetWidth,document.body.removeChild(o)};for(let o=0;o<Math.max(1,e);o++)r(),await new Promise(s=>requestAnimationFrame(()=>requestAnimationFrame(s)))}function ee(t){return/\bcounter\s*\(|\bcounters\s*\(/.test(t||"")}function an(t){return(t||"").replace(/"([^"]*)"/g,"$1")}function Qt(t,e=!1){let n="",r=Math.max(1,t);for(;r>0;)r--,n=String.fromCharCode(97+r%26)+n,r=Math.floor(r/26);return e?n.toUpperCase():n}function Zt(t,e=!0){let n=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],r=Math.max(1,Math.min(3999,t)),o="";for(let[s,a]of n)for(;r>=s;)o+=a,r-=s;return e?o:o.toLowerCase()}function te(t,e){switch((e||"decimal").toLowerCase()){case"decimal":return String(Math.max(0,t));case"decimal-leading-zero":return(t<10?"0":"")+String(Math.max(0,t));case"lower-alpha":return Qt(t,!1);case"upper-alpha":return Qt(t,!0);case"lower-roman":return Zt(t,!1);case"upper-roman":return Zt(t,!0);default:return String(Math.max(0,t))}}function ne(t){let e=new WeakMap,n=t instanceof Document?t.documentElement:t,r=c=>c&&c.tagName==="LI",o=c=>{let l=0,u=c?.parentElement;if(!u)return 0;for(let g of u.children){if(g===c)break;g.tagName==="LI"&&l++}return l},s=c=>{let l=new Map;for(let[u,g]of c)l.set(u,g.slice());return l},a=(c,l,u)=>{let g=s(c),L;try{L=u.style?.counterReset||getComputedStyle(u).counterReset}catch{}if(L&&L!=="none")for(let A of L.split(",")){let h=A.trim().split(/\s+/),S=h[0],C=Number.isFinite(Number(h[1]))?Number(h[1]):0;if(!S)continue;let E=l.get(S);if(E&&E.length){let N=E.slice();N.push(C),g.set(S,N)}else g.set(S,[C])}let x;try{x=u.style?.counterIncrement||getComputedStyle(u).counterIncrement}catch{}if(x&&x!=="none")for(let A of x.split(",")){let h=A.trim().split(/\s+/),S=h[0],C=Number.isFinite(Number(h[1]))?Number(h[1]):1;if(!S)continue;let E=g.get(S)||[];E.length===0&&E.push(0),E[E.length-1]+=C,g.set(S,E)}try{if(getComputedStyle(u).display==="list-item"&&r(u)){let h=u.parentElement,S=1;if(h&&h.tagName==="OL"){let E=h.getAttribute("start"),N=Number.isFinite(Number(E))?Number(E):1,W=o(u),_=u.getAttribute("value");S=Number.isFinite(Number(_))?Number(_):N+W}else S=1+o(u);let C=g.get("list-item")||[];C.length===0&&C.push(0),C[C.length-1]=S,g.set("list-item",C)}}catch{}return g},i=(c,l,u)=>{let g=a(u,l,c);e.set(c,g);let L=g;for(let x of c.children)L=i(x,g,L);return g},f=new Map;return i(n,f,f),{get(c,l){let u=e.get(c)?.get(l);return u&&u.length?u[u.length-1]:0},getStack(c,l){let u=e.get(c)?.get(l);return u?u.slice():[]}}}function re(t,e,n){if(!t||t==="none")return t;try{let r=/\b(counter|counters)\s*\(([^)]+)\)/g,o=t.replace(r,(s,a,i)=>{let f=String(i).split(",").map(c=>c.trim());if(a==="counter"){let c=f[0]?.replace(/^["']|["']$/g,""),l=(f[1]||"decimal").toLowerCase(),u=n.get(e,c);return te(u,l)}else{let c=f[0]?.replace(/^["']|["']$/g,""),l=f[1]?.replace(/^["']|["']$/g,"")??"",u=(f[2]||"decimal").toLowerCase(),g=n.getStack(e,c);return g.length?g.map(x=>te(x,u)).join(l):""}});return an(o)}catch{return"- "}}var oe=null;async function Bt(t,e,n,r){if(!(t instanceof Element)||!(e instanceof Element))return;for(let a of["::before","::after","::first-letter"])try{let i=tt(t,a);if(!i||typeof i[Symbol.iterator]!="function"||i.content==="none"&&i.backgroundImage==="none"&&i.backgroundColor==="transparent"&&(i.borderStyle==="none"||parseFloat(i.borderWidth)===0)&&(!i.transform||i.transform==="none")&&i.display==="inline")continue;if(a==="::first-letter"){let v=getComputedStyle(t);if(!(i.color!==v.color||i.fontSize!==v.fontSize||i.fontWeight!==v.fontWeight))continue;let O=Array.from(e.childNodes).find(qt=>qt.nodeType===Node.TEXT_NODE&&qt.textContent?.trim().length>0);if(!O)continue;let H=O.textContent,at=H.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0],B=H.slice(at?.length||0);if(!at||/[\uD800-\uDFFF]/.test(at))continue;let q=document.createElement("span");q.textContent=at,q.dataset.snapdomPseudo="::first-letter";let At=mt(i),Et=ot(At,"span");n.styleMap.set(q,Et);let Y=document.createTextNode(B);e.replaceChild(Y,O),e.insertBefore(q,Y);continue}let c=i.content,l=Tt(c);ee(c)&&(oe=ne(t.ownerDocument||document),l=re(l,t,oe));let u=i.backgroundImage,g=i.backgroundColor,L=i.fontFamily,x=parseInt(i.fontSize)||32,A=parseInt(i.fontWeight)||!1,h=i.color||"#000",S=i.display,C=parseFloat(i.width),E=parseFloat(i.height),N=i.borderStyle,W=parseFloat(i.borderWidth),_=i.transform,z=j(L),d=c!=="none"&&l!=="",y=u&&u!=="none",w=g&&g!=="transparent"&&g!=="rgba(0, 0, 0, 0)",k=S!=="inline"&&(C>0||E>0),p=N&&N!=="none"&&W>0,b=_&&_!=="none";if(!(d||y||w||k||p||b))continue;let M=document.createElement("span");M.dataset.snapdomPseudo=a,M.style.verticalAlign="middle";let $=mt(i),R=ot($,"span");if(n.styleMap.set(M,R),z&&l.length===1){let{dataUrl:v,width:I,height:O}=await Jt(l,L,A,x,h),H=document.createElement("img");H.src=v,H.style=`height:${x}px;width:${I/O*x}px;object-fit:contain;`,M.appendChild(H),e.dataset.snapdomHasIcon="true"}else if(l.startsWith("url(")){let v=J(l);if(v?.trim())try{let I=document.createElement("img"),O=await D(G(v),{as:"dataURL",useProxy:r.useProxy});I.src=O.data,I.style=`width:${x}px;height:auto;object-fit:contain;`,M.appendChild(I)}catch(I){console.error(`[snapdom] Error in pseudo ${a} for`,t,I)}}else!z&&d&&(M.textContent=l);if(y)try{let v=et(u),I=await Promise.all(v.map(Z));M.style.backgroundImage=I.join(", ")}catch(v){console.warn(`[snapdom] Failed to inline background-image for ${a}`,v)}if(w&&(M.style.backgroundColor=g),!(M.childNodes.length>0||M.textContent?.trim()!==""||y||w||k||p||b))continue;a==="::before"?e.insertBefore(M,e.firstChild):e.appendChild(M)}catch(i){console.warn(`[snapdom] Failed to capture ${a} for`,t,i)}let o=Array.from(t.children),s=Array.from(e.children).filter(a=>!a.dataset.snapdomPseudo);for(let a=0;a<Math.min(o.length,s.length);a++)await Bt(o[a],s[a],n,r)}function ae(t){if(!t)return;let e=new Set;if(t.querySelectorAll("use").forEach(i=>{let f=i.getAttribute("xlink:href")||i.getAttribute("href");f&&f.startsWith("#")&&e.add(f.slice(1))}),!e.size)return;let n=Array.from(document.querySelectorAll("svg > symbol, svg > defs")),r=n.filter(i=>i.tagName.toLowerCase()==="symbol"),o=n.filter(i=>i.tagName.toLowerCase()==="defs"),s=t.querySelector("svg.inline-defs-container");s||(s=document.createElementNS("http://www.w3.org/2000/svg","svg"),s.setAttribute("aria-hidden","true"),s.setAttribute("style","position: absolute; width: 0; height: 0; overflow: hidden;"),s.classList.add("inline-defs-container"),t.insertBefore(s,t.firstChild));let a=new Set;t.querySelectorAll("symbol[id], defs > *[id]").forEach(i=>{a.add(i.id)}),e.forEach(i=>{if(a.has(i))return;let f=r.find(c=>c.id===i);if(f){s.appendChild(f.cloneNode(!0)),a.add(i);return}for(let c of o){let l=c.querySelector(`#${CSS.escape(i)}`);if(l){let u=s.querySelector("defs");u||(u=document.createElementNS("http://www.w3.org/2000/svg","defs"),s.appendChild(u)),u.appendChild(l.cloneNode(!0)),a.add(i);break}}})}async function ie(t,e={}){let n={styleMap:m.session.styleMap,styleCache:m.session.styleCache,nodeMap:m.session.nodeMap},r,o="",s="";sn(t);try{ae(t)}catch(i){console.warn("inlineExternal defs or symbol failed:",i)}try{r=await it(t,n,e,t)}catch(i){throw console.warn("deepClone failed:",i),i}try{await Bt(t,r,n,e)}catch(i){console.warn("inlinePseudoElements failed:",i)}await un(r);try{let i=r.querySelectorAll("style[data-sd]");for(let f of i)s+=f.textContent||"",f.remove()}catch{}let a=Nt(n.styleMap);o=Array.from(a.entries()).map(([i,f])=>`.${f}{${i}}`).join(""),o=s+o;for(let[i,f]of n.styleMap.entries()){if(i.tagName==="STYLE")continue;if(i.getRootNode&&i.getRootNode()instanceof ShadowRoot){i.setAttribute("style",f.replace(/;/g,"; "));continue}let c=a.get(f);c&&i.classList.add(c);let l=i.style?.backgroundImage,u=i.dataset?.snapdomHasIcon;l&&l!=="none"&&(i.style.backgroundImage=l),u&&(i.style.verticalAlign="middle",i.style.display="inline")}for(let[i,f]of n.nodeMap.entries()){let c=f.scrollLeft,l=f.scrollTop;if((c||l)&&i instanceof HTMLElement){i.style.overflow="hidden",i.style.scrollbarWidth="none",i.style.msOverflowStyle="none";let g=document.createElement("div");for(g.style.transform=`translate(${-c}px, ${-l}px)`,g.style.willChange="transform",g.style.display="inline-block",g.style.width="100%";i.firstChild;)g.appendChild(i.firstChild);i.appendChild(g)}}if(t===n.nodeMap.get(r)){let i=n.styleCache.get(t)||window.getComputedStyle(t);n.styleCache.set(t,i);let f=Mt(i.transform);r.style.margin="0",r.style.position="static",r.style.top="auto",r.style.left="auto",r.style.right="auto",r.style.bottom="auto",r.style.zIndex="auto",r.style.float="none",r.style.clear="none",r.style.transform=f||""}for(let[i,f]of n.nodeMap.entries())f.tagName==="PRE"&&(i.style.marginTop="0",i.style.marginBlockStart="0");return{clone:r,classCSS:o,styleCache:n.styleCache}}function sn(t){let e=getComputedStyle(t),n=e.outlineStyle,r=e.outlineWidth,o=e.borderStyle,s=e.borderWidth,a=n!=="none"&&parseFloat(r)>0,i=o==="none"||parseFloat(s)===0;a&&i&&(t.style.border=`${r} solid transparent`)}var ct=new Map;async function lt(t){if(m.resource?.has(t))return m.resource.get(t);if(ct.has(t))return ct.get(t);let e=(async()=>{let n=await D(t,{as:"dataURL",silent:!0});if(!n.ok||typeof n.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);return m.resource?.set(t,n.data),n.data})();ct.set(t,e);try{let n=await e;return ct.set(t,n),n}catch(n){throw ct.delete(t),n}}var cn=/\bblob:[^)"'\s]+/g;async function se(t){if(!t||t.indexOf("blob:")===-1)return t;let e=Array.from(new Set(t.match(cn)||[]));if(e.length===0)return t;let n=t;for(let r of e)try{let o=await lt(r);n=n.split(r).join(o)}catch{}return n}function St(t){return typeof t=="string"&&t.startsWith("blob:")}function ln(t){return(t||"").split(",").map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.match(/^(\S+)(\s+.+)?$/);return n?{url:n[1],desc:n[2]||""}:null}).filter(Boolean)}function fn(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}async function un(t){if(!t)return;let e=t.querySelectorAll?t.querySelectorAll("img"):[];for(let a of e)try{let f=a.getAttribute("src")||a.currentSrc||"";if(St(f)){let l=await lt(f);a.setAttribute("src",l)}let c=a.getAttribute("srcset");if(c&&c.includes("blob:")){let l=ln(c),u=!1;for(let g of l)if(St(g.url))try{g.url=await lt(g.url),u=!0}catch{}u&&a.setAttribute("srcset",fn(l))}}catch{}let n=t.querySelectorAll?t.querySelectorAll("image"):[];for(let a of n)try{let i="http://www.w3.org/1999/xlink",f=a.getAttribute("href")||a.getAttributeNS?.(i,"href");if(St(f)){let c=await lt(f);a.setAttribute("href",c),a.removeAttributeNS?.(i,"href")}}catch{}let r=t.querySelectorAll?t.querySelectorAll("[style*='blob:']"):[];for(let a of r)try{let i=a.getAttribute("style");if(i&&i.includes("blob:")){let f=await se(i);a.setAttribute("style",f)}}catch{}let o=t.querySelectorAll?t.querySelectorAll("style"):[];for(let a of o)try{let i=a.textContent||"";i.includes("blob:")&&(a.textContent=await se(i))}catch{}let s=["poster"];for(let a of s){let i=t.querySelectorAll?t.querySelectorAll(`[${a}^='blob:']`):[];for(let f of i)try{let c=f.getAttribute(a);St(c)&&f.setAttribute(a,await lt(c))}catch{}}}async function ce(t,e={}){let n=Array.from(t.querySelectorAll("img")),r=async o=>{if(!o.getAttribute("src")){let l=o.currentSrc||o.src||"";l&&o.setAttribute("src",l)}o.removeAttribute("srcset"),o.removeAttribute("sizes");let s=o.src||"";if(!s)return;let a=await D(s,{as:"dataURL",useProxy:e.useProxy});if(a.ok&&typeof a.data=="string"&&a.data.startsWith("data:")){o.src=a.data,o.width||(o.width=o.naturalWidth||100),o.height||(o.height=o.naturalHeight||100);return}let{fallbackURL:i}=e||{};if(i)try{let l=parseInt(o.dataset?.snapdomWidth||"",10)||0,u=parseInt(o.dataset?.snapdomHeight||"",10)||0,g=parseInt(o.getAttribute("width")||"",10)||0,L=parseInt(o.getAttribute("height")||"",10)||0,x=parseFloat(o.style?.width||"")||0,A=parseFloat(o.style?.height||"")||0,h=l||x||g||o.width||void 0,S=u||A||L||o.height||void 0,C=typeof i=="function"?await i({width:h,height:S,src:s,element:o}):i;if(C){let E=await D(C,{as:"dataURL",useProxy:e.useProxy});o.src=E.data,!o.width&&h&&(o.width=h),!o.height&&S&&(o.height=S),o.width||(o.width=o.naturalWidth||100),o.height||(o.height=o.naturalHeight||100);return}}catch{}let f=o.width||o.naturalWidth||100,c=o.height||o.naturalHeight||100;if(e.placeholders!==!1){let l=document.createElement("div");l.style.cssText=[`width:${f}px`,`height:${c}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${c}px`,"color:#666","font-size:12px","overflow:hidden"].join(";"),l.textContent="img",o.replaceWith(l)}else{let l=document.createElement("div");l.style.cssText=`display:inline-block;width:${f}px;height:${c}px;visibility:hidden;`,o.replaceWith(l)}};for(let o=0;o<n.length;o+=4){let s=n.slice(o,o+4).map(r);await Promise.allSettled(s)}}async function xt(t,e,n,r={}){let o=[[t,e]],s=["background-image","mask","mask-image","-webkit-mask","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source"],a=["mask-position","mask-size","mask-repeat","-webkit-mask-position","-webkit-mask-size","-webkit-mask-repeat","mask-origin","mask-clip","-webkit-mask-origin","-webkit-mask-clip","-webkit-mask-position-x","-webkit-mask-position-y"],i=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;o.length;){let[f,c]=o.shift(),l=n.get(f)||tt(f);n.has(f)||n.set(f,l);let u=(()=>{let x=l.getPropertyValue("border-image"),A=l.getPropertyValue("border-image-source");return x&&x!=="none"||A&&A!=="none"})();for(let x of s){let A=l.getPropertyValue(x);if(!A||A==="none")continue;let h=et(A),S=await Promise.all(h.map(C=>Z(C,r)));S.some(C=>C&&C!=="none"&&!/^url\(undefined/.test(C))&&c.style.setProperty(x,S.join(", "))}for(let x of a){let A=l.getPropertyValue(x);!A||A==="initial"||c.style.setProperty(x,A)}if(u)for(let x of i){let A=l.getPropertyValue(x);!A||A==="initial"||c.style.setProperty(x,A)}let g=Array.from(f.children),L=Array.from(c.children);for(let x=0;x<Math.min(g.length,L.length);x++)o.push([g[x],L[x]])}}function le(t){if(!t)return()=>{};let e=dn(t);if(e<=0)return()=>{};if(!pn(t))return()=>{};let n=getComputedStyle(t),r=Math.round(mn(n)*e+hn(n)),o=t.textContent??"",s=o;if(t.scrollHeight<=r+.5)return()=>{};let a=0,i=o.length,f=-1;for(;a<=i;){let c=a+i>>1;t.textContent=o.slice(0,c)+"\u2026",t.scrollHeight<=r+.5?(f=c,a=c+1):i=c-1}return t.textContent=(f>=0?o.slice(0,f):"")+"\u2026",()=>{t.textContent=s}}function dn(t){let e=getComputedStyle(t),n=e.getPropertyValue("-webkit-line-clamp")||e.getPropertyValue("line-clamp");n=(n||"").trim();let r=parseInt(n,10);return Number.isFinite(r)&&r>0?r:0}function mn(t){let e=(t.lineHeight||"").trim(),n=parseFloat(t.fontSize)||16;return!e||e==="normal"?Math.round(n*1.2):e.endsWith("px")?parseFloat(e):/^\d+(\.\d+)?$/.test(e)?Math.round(parseFloat(e)*n):e.endsWith("%")?Math.round(parseFloat(e)/100*n):Math.round(n*1.2)}function hn(t){return(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)}function pn(t){return t.childElementCount>0?!1:Array.from(t.childNodes).some(e=>e.nodeType===Node.TEXT_NODE)}async function Dt(t,e){if(!t)throw new Error("Element cannot be null or undefined");ft(e.cache);let n=e.fast,r,o,s,a="",i="",f,c,l=le(t);try{({clone:r,classCSS:o,styleCache:s}=await ie(t,e))}finally{l()}await new Promise(x=>{V(async()=>{await ce(r,e),x()},{fast:n})}),await new Promise(x=>{V(async()=>{await xt(t,r,s,e),x()},{fast:n})}),e.embedFonts&&await new Promise(x=>{V(async()=>{let A=yt(t),h=wt(t);if(X){let S=new Set(Array.from(A).map(C=>String(C).split("__")[0]).filter(Boolean));await bt(S,2)}a=await gt({required:A,usedCodepoints:h,preCached:!1,exclude:e.excludeFonts,useProxy:e.useProxy}),x()},{fast:n})});let u=Lt(r).sort(),g=u.join(",");m.baseStyle.has(g)?i=m.baseStyle.get(g):await new Promise(x=>{V(()=>{i=Rt(u),m.baseStyle.set(g,i),x()},{fast:n})}),await new Promise(x=>{V(()=>{let A=t.getBoundingClientRect(),h=Number(A.width)||0,S=Number(A.height)||0,C=Number.isFinite(e.width),E=Number.isFinite(e.height),N=e.scale??1,W=typeof N=="number"&&N!==1;if(!W){let B=S>0?h/S:1;C&&E?(h=Number(e.width),S=Number(e.height)):C?(h=Number(e.width),S=h/(B||1)):E&&(S=Number(e.height),h=S*(B||1))}h=Math.max(1,Math.ceil(Number.isFinite(h)?h:1)),S=Math.max(1,Math.ceil(Number.isFinite(S)?S:1));let _=getComputedStyle(t),z=_.transform&&_.transform!=="none"?_.transform:"",d=wn(t),y,w,k,p,b=0,F=0;if(bn(t)){let B=Cn({baseTransform:z,rotate:d.rotate||"0deg",scale:d.scale,translate:d.translate}),q=B.e??B.m41??0,At=B.f??B.m42??0;b=-q,F=-At;let Et=B.is2D?fe(B):fe(new DOMMatrix(B.toString())),Y=yn(h,S,Et);y=Math.max(1,Math.ceil(Y.width)),w=Math.max(1,Math.ceil(Y.height)),k=-Y.minX,p=-Y.minY}else{let B=t.getBoundingClientRect(),q=Sn(B,{top:0,right:0,bottom:0,left:0});y=Math.max(1,q.width),w=Math.max(1,q.height),k=-(q.x-Math.floor(B.left)),p=-(q.y-Math.floor(B.top))}let M="http://www.w3.org/2000/svg",$=document.createElementNS(M,"foreignObject");$.setAttribute("width","100%"),$.setAttribute("height","100%"),$.setAttribute("x",String(k)),$.setAttribute("y",String(p)),$.style.overflow="visible";let R=document.createElement("style");R.textContent=i+a+"svg{overflow:visible;} foreignObject{overflow:visible;}"+o,$.appendChild(R);let T=document.createElement("div");T.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),T.style.width=`${h}px`,T.style.height=`${S}px`,T.style.overflow="visible",T.style.transformOrigin="0 0";let P=[];if((b||F)&&P.push(`translate(${b}px, ${F}px)`),!W&&(C||E)){let B=A.width?h/A.width:1,q=A.height?S/A.height:1;P.push(`scale(${B}, ${q})`)}else W&&P.push(`scale(${N})`);P.length&&(T.style.transform=P.join(" ")),r.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),r.style.transformOrigin="0 0",r.style.position="static",r.style.left="0",r.style.top="0",z&&(r.style.transform=z),r.style.rotate=d.rotate||"0deg",r.style.scale=d.scale||"1",r.style.translate=d.translate||"0 0",T.appendChild(r),$.appendChild(T);let I=new XMLSerializer().serializeToString($);c=`<svg xmlns="${M}" width="${!W&&(C||E)?h:y}" height="${!W&&(E||C)?S:w}" viewBox="0 0 ${y} ${w}">`+I+"</svg>",f=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(c)}`,x()},{fast:n})});let L=document.getElementById("snapdom-sandbox");return L&&L.style.position==="absolute"&&L.remove(),f}function gn(t){let e=getComputedStyle(t).transform;if(!e||e==="none")return new DOMMatrix;try{return new DOMMatrix(e)}catch{return new WebKitCSSMatrix(e)}}function fe(t){return new DOMMatrix([t.a,t.b,t.c,t.d,0,0])}function yn(t,e,n){let o=[{x:0,y:0},{x:t,y:0},{x:0,y:e},{x:t,y:e}].map(c=>({x:n.a*c.x+n.c*c.y,y:n.b*c.x+n.d*c.y})),s=Math.min(...o.map(c=>c.x)),a=Math.max(...o.map(c=>c.x)),i=Math.min(...o.map(c=>c.y)),f=Math.max(...o.map(c=>c.y));return{minX:s,minY:i,width:a-s,height:f-i}}function wn(t){let e={rotate:"0deg",scale:null,translate:null},n=typeof t.computedStyleMap=="function"?t.computedStyleMap():null;if(n){let o=f=>{try{return typeof n.has=="function"&&!n.has(f)||typeof n.get!="function"?null:n.get(f)}catch{return null}},s=o("rotate");if(s){let f=s.angle??s;f&&typeof f=="object"&&"unit"in f?e.rotate=f.unit==="rad"?f.value*180/Math.PI+"deg":f.value+f.unit:e.rotate=String(s)}let a=o("scale");if(a&&a.length){let f=a[0]?.value??1,c=a[1]?.value??f;e.scale=`${f} ${c}`}let i=o("translate");if(i&&i.length){let f=i[0]?.value??0,c=i[1]?.value??0,l=i[0]?.unit??"px",u=i[1]?.unit??"px";e.translate=`${f}${l} ${c}${u}`}return e}let r=getComputedStyle(t);return e.rotate=r.rotate&&r.rotate!=="none"?r.rotate:"0deg",e.scale=r.scale&&r.scale!=="none"?r.scale:null,e.translate=r.translate&&r.translate!=="none"?r.translate:null,e}function bn(t){let e=getComputedStyle(t).transform||"none";return!(e==="none"||e==="matrix(1, 0, 0, 1, 0, 0)"||/^matrix\(\s*1\s*,\s*0\s*,\s*0\s*,\s*1\s*,/i.test(e))}function Sn(t,e){let n=Math.floor(t.left-e.left),r=Math.floor(t.top-e.top),o=Math.ceil(t.width+e.left+e.right),s=Math.ceil(t.height+e.top+e.bottom);return{x:n,y:r,width:o,height:s}}var Ot=null;function xn(){if(Ot)return Ot;let t=document.createElement("div");return t.id="snapdom-measure-slot",t.setAttribute("aria-hidden","true"),Object.assign(t.style,{position:"absolute",left:"-99999px",top:"0px",width:"0px",height:"0px",overflow:"hidden",opacity:"0",pointerEvents:"none",contain:"size layout style"}),document.documentElement.appendChild(t),Ot=t,t}function Cn(t){let e=xn(),n=document.createElement("div");n.style.transformOrigin="0 0",t.baseTransform&&(n.style.transform=t.baseTransform),t.rotate&&(n.style.rotate=t.rotate),t.scale&&(n.style.scale=t.scale),t.translate&&(n.style.translate=t.translate),e.appendChild(n);let r=gn(n);return e.removeChild(n),r}function kn(t){if(typeof t=="string"){let e=t.toLowerCase().trim();if(e==="disabled"||e==="full"||e==="auto"||e==="soft")return e}return"soft"}function ue(t={}){let e=t.format??"png",n=kn(t.cache);return{debug:t.debug??!1,fast:t.fast??!0,scale:t.scale??1,exclude:t.exclude??[],excludeMode:t.excludeMode??"hide",filter:t.filter??null,filterMode:t.filterMode??"hide",placeholders:t.placeholders!==!1,embedFonts:t.embedFonts??!1,iconFonts:Array.isArray(t.iconFonts)?t.iconFonts:t.iconFonts?[t.iconFonts]:[],localFonts:Array.isArray(t.localFonts)?t.localFonts:[],excludeFonts:t.excludeFonts??void 0,fallbackURL:t.fallbackURL??void 0,cache:n,useProxy:typeof t.useProxy=="string"?t.useProxy:"",width:t.width??null,height:t.height??null,format:e,type:t.type??"svg",quality:t.quality??.92,dpr:t.dpr??(window.devicePixelRatio||1),backgroundColor:t.backgroundColor??(["jpg","jpeg","webp"].includes(e)?"#ffffff":null),filename:t.filename??"snapDOM"}}async function de(t,e){let n=new Image;return n.src=t,await n.decode(),e.scale!==1&&(n.style.width=`${n.naturalWidth*e.scale}px`,n.style.height=`${n.naturalHeight*e.scale}px`),n}async function K(t,e){let{scale:n,dpr:r}=e,o=new Image;o.crossOrigin="anonymous",o.loading="eager",o.decoding="sync",o.src=t,await o.decode();let s=o.naturalWidth*n,a=o.naturalHeight*n,i=document.createElement("canvas");i.width=Math.ceil(s*r),i.height=Math.ceil(a*r),i.style.width=`${s}px`,i.style.height=`${a}px`;let f=i.getContext("2d");return r!==1&&f.scale(r,r),f.drawImage(o,0,0,s,a),i}async function Ct(t,e){let n=e.type;if(n==="svg"){let s=decodeURIComponent(t.split(",")[1]);return new Blob([s],{type:"image/svg+xml"})}let r=await K(t,e),o=e.backgroundColor?Q(r,e.backgroundColor):r;return new Promise(s=>o.toBlob(a=>s(a),`image/${n}`,e.quality))}async function me(t,e){let n=await K(t,e),r=e.backgroundColor?Q(n,e.backgroundColor):n,o=new Image;return o.src=r.toDataURL(`image/${e.format}`,e.quality),await o.decode(),o.style.width=`${r.width/e.dpr}px`,o.style.height=`${r.height/e.dpr}px`,o}async function he(t,e){if(e.dpr=1,e.format==="svg"){let s=await Ct(t,{...e,type:"svg"}),a=URL.createObjectURL(s),i=document.createElement("a");i.href=a,i.download=e.filename,i.click(),URL.revokeObjectURL(a);return}let n=await K(t,e),r=e.backgroundColor?Q(n,e.backgroundColor):n,o=document.createElement("a");o.href=r.toDataURL(`image/${e.format}`,e.quality),o.download=e.filename,o.click()}var pe=Symbol("snapdom.internal"),Ht=!1;async function U(t,e){if(!t)throw new Error("Element cannot be null or undefined");if(X())for(let r=0;r<3;r++)try{await An(t,e),console.log("Iteraci\xF3n n\xFAmero:",r),Ht=!1}catch{}let n=ue(e);return n.iconFonts&&n.iconFonts.length>0&&Yt(n.iconFonts),n.snap||(n.snap={toPng:(r,o)=>U.toPng(r,o),toImg:(r,o)=>U.toImg(r,o)}),U.capture(t,n,pe)}U.capture=async(t,e,n)=>{if(n!==pe)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");let r=await Dt(t,e),o=a=>({...e,...a||{}}),s=a=>i=>{let f=o({...i||{},format:a}),c=a==="jpeg"||a==="jpg",l=f.backgroundColor==null||f.backgroundColor==="transparent";return c&&l&&(f.backgroundColor="#ffffff"),me(r,f)};return{url:r,toRaw:()=>r,toImg:a=>de(r,o(a)),toCanvas:a=>K(r,o(a)),toBlob:a=>Ct(r,o(a)),toPng:s("png"),toJpg:s("jpeg"),toWebp:s("webp"),download:a=>he(r,o(a))}};U.toRaw=(t,e)=>U(t,e).then(n=>n.toRaw());U.toImg=(t,e)=>U(t,e).then(n=>n.toImg());U.toCanvas=(t,e)=>U(t,e).then(n=>n.toCanvas());U.toBlob=(t,e)=>U(t,e).then(n=>n.toBlob());U.toPng=(t,e)=>U(t,{...e,format:"png"}).then(n=>n.toPng());U.toJpg=(t,e)=>U(t,{...e,format:"jpeg"}).then(n=>n.toJpg());U.toWebp=(t,e)=>U(t,{...e,format:"webp"}).then(n=>n.toWebp());U.download=(t,e)=>U(t,e).then(n=>n.download());async function An(t,e){if(Ht)return;let n={...e,fast:!0,embedFonts:!0,scale:.2},r;try{r=await Dt(t,n)}catch{return}await new Promise(o=>{let s=new Image;s.decoding="sync",s.loading="eager",s.style.position="fixed",s.style.left=0,s.style.top=0,s.style.width="10px",s.style.height="10px",s.style.opacity="0.01",s.style.transform="translateZ(10px)",s.style.willChange="transform,opacity;",s.src=r;let a=async()=>{await new Promise(i=>setTimeout(i,100)),s&&s.parentNode&&s.parentNode.removeChild(s),Ht=!0,o()};document.body.appendChild(s),a()})}async function En(t=document,e={}){let{embedFonts:n=!0,useProxy:r=""}=e,o=e.cache??e.cacheOpt??"full";ft(o);try{await document.fonts?.ready}catch{}try{Ft()}catch{}m.session=m.session||{},m.session.styleCache||(m.session.styleCache=new WeakMap),m.image=m.image||new Map;try{await xt(t,void 0,m.session.styleCache,{useProxy:r})}catch{}let s=[],a=[];try{t?.querySelectorAll&&(s=Array.from(t.querySelectorAll("img[src]")),a=Array.from(t.querySelectorAll("*")))}catch{}let i=[];for(let f of s){let c=f?.currentSrc||f?.src;if(c&&!m.image.has(c)){let l=Promise.resolve().then(async()=>{let u=await D(c,{as:"dataURL",useProxy:r});u?.ok&&typeof u.data=="string"&&m.image.set(c,u.data)}).catch(()=>{});i.push(l)}}for(let f of a){let c="";try{c=tt(f).backgroundImage}catch{}if(c&&c!=="none"){let l=et(c);for(let u of l)if(u.startsWith("url(")){let g=Promise.resolve().then(()=>Z(u,{...e,useProxy:r})).catch(()=>{});i.push(g)}}}if(n)try{let f=yt(t),c=wt(t);if(typeof X=="function"?X():!!X){let u=new Set(Array.from(f).map(g=>String(g).split("__")[0]).filter(Boolean));await bt(u,2)}await gt({required:f,usedCodepoints:c,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??r})}catch{}await Promise.allSettled(i)}export{En as preCache,U as snapdom};
|
|
1
|
+
var h={image:new Map,background:new Map,resource:new Map,defaultStyle:new Map,baseStyle:new Map,computedStyle:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}};function _t(t="soft"){switch(t){case"auto":{h.session.styleMap=new Map,h.session.nodeMap=new Map;return}case"soft":{h.session.styleMap=new Map,h.session.nodeMap=new Map,h.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{h.session.styleMap=new Map,h.session.nodeMap=new Map,h.session.styleCache=new WeakMap,h.computedStyle=new WeakMap,h.baseStyle=new Map,h.defaultStyle=new Map,h.image=new Map,h.background=new Map,h.resource=new Map,h.font=new Set;return}default:{h.session.styleMap=new Map,h.session.nodeMap=new Map,h.session.styleCache=new WeakMap;return}}}function ht(t){let e=t.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function Zt(t){if(!t||t==="none")return"";let e=t.replace(/translate[XY]?\([^)]*\)/g,"");return e=e.replace(/matrix\(([^)]+)\)/g,(n,o)=>{let r=o.split(",").map(s=>s.trim());return r.length!==6?`matrix(${o})`:(r[4]="0",r[5]="0",`matrix(${r.join(", ")})`)}),e=e.replace(/matrix3d\(([^)]+)\)/g,(n,o)=>{let r=o.split(",").map(s=>s.trim());return r.length!==16?`matrix3d(${o})`:(r[12]="0",r[13]="0",`matrix3d(${r.join(", ")})`)}),e.trim().replace(/\s{2,}/g," ")}function ut(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function Qe(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,r=0;function s(a,i,l){if(r>=n)return;let c=Date.now();(o.get(i)||0)>c||(o.set(i,c+e),r++,a==="warn"&&console&&console.warn?console.warn(`${t} ${l}`):console&&console.error&&console.error(`${t} ${l}`))}return{warnOnce(a,i){s("warn",a,i)},errorOnce(a,i){s("error",a,i)},reset(){o.clear(),r=0}}}var ke=Qe("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),te=new Map,Pt=new Map;function Ze(t){return/^data:|^blob:|^about:blank$/i.test(t)}function tn(t,e){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=e.includes("{url}")?e.split("{url}")[0]:e,r=new URL(o||".",n),s=new URL(t,n);if(s.origin===r.origin)return!0;let a=s.searchParams;if(a&&(a.has("url")||a.has("target")))return!0}catch{}return!1}function en(t,e){if(!e||Ze(t)||tn(t,e))return!1;try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=new URL(t,n);return typeof location<"u"?o.origin!==location.origin:!0}catch{return!!e}}function nn(t,e){if(!e)return t;if(e.includes("{url}"))return e.replace("{urlRaw}",ut(t)).replace("{url}",encodeURIComponent(t));if(/[?&]url=?$/.test(e))return`${e}${encodeURIComponent(t)}`;if(e.endsWith("?"))return`${e}url=${encodeURIComponent(t)}`;if(e.endsWith("/"))return`${e}${ut(t)}`;let n=e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function Me(t){return new Promise((e,n)=>{let o=new FileReader;o.onload=()=>e(String(o.result||"")),o.onerror=()=>n(new Error("read_failed")),o.readAsDataURL(t)})}function on(t,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,t].join("|")}async function V(t,e={}){let n=e.as??"blob",o=e.timeout??3e3,r=e.useProxy||"",s=e.errorTTL??8e3,a=e.headers||{},i=!!e.silent;if(/^data:/i.test(t))try{if(n==="text")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1};if(n==="dataURL")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1,mime:String(t).slice(5).split(";")[0]||""};let[,g="",k=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],F=/;base64/i.test(g)?atob(k):decodeURIComponent(k),W=new Uint8Array([...F].map(O=>O.charCodeAt(0))),X=new Blob([W],{type:(g||"").split(";")[0]||""});return{ok:!0,data:X,status:200,url:t,fromCache:!1,mime:X.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let g=await fetch(t);if(!g.ok)return{ok:!1,data:null,status:g.status,url:t,fromCache:!1,reason:"http_error"};let k=await g.blob(),C=k.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await Me(k),status:g.status,url:t,fromCache:!1,mime:C}:n==="text"?{ok:!0,data:await k.text(),status:g.status,url:t,fromCache:!1,mime:C}:{ok:!0,data:k,status:g.status,url:t,fromCache:!1,mime:C}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(t))return n==="dataURL"?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:t,fromCache:!1,mime:"image/png"}:{ok:!0,data:n==="text"?"":new Blob([]),status:200,url:t,fromCache:!1};let l=on(t,{as:n,timeout:o,useProxy:r,errorTTL:s}),c=Pt.get(l);if(c&&c.until>Date.now())return{...c.result,fromCache:!0};c&&Pt.delete(l);let u=te.get(l);if(u)return u;let f=en(t,r)?nn(t,r):t,m=e.credentials;if(!m)try{let g=typeof location<"u"&&location.href?location.href:"http://localhost/",k=new URL(t,g);m=typeof location<"u"&&k.origin===location.origin?"include":"omit"}catch{m="omit"}let A=new AbortController,S=setTimeout(()=>A.abort("timeout"),o),x=(async()=>{try{let g=await fetch(f,{signal:A.signal,credentials:m,headers:a});if(!g.ok){let F={ok:!1,data:null,status:g.status,url:f,fromCache:!1,reason:"http_error"};if(s>0&&Pt.set(l,{until:Date.now()+s,result:F}),!i){let W=`${g.status} ${g.statusText||""}`.trim();ke.warnOnce(`http:${g.status}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${W} while fetching ${n} ${t}`)}return e.onError&&e.onError(F),F}if(n==="text")return{ok:!0,data:await g.text(),status:g.status,url:f,fromCache:!1};let k=await g.blob(),C=k.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await Me(k),status:g.status,url:f,fromCache:!1,mime:C}:{ok:!0,data:k,status:g.status,url:f,fromCache:!1,mime:C}}catch(g){let k=g&&typeof g=="object"&&"name"in g&&g.name==="AbortError"?String(g.message||"").includes("timeout")?"timeout":"abort":"network",C={ok:!1,data:null,status:0,url:f,fromCache:!1,reason:k};if(!/^blob:/i.test(t)&&s>0&&Pt.set(l,{until:Date.now()+s,result:C}),!i){let F=`${k}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,W=k==="timeout"?`Timeout after ${o}ms. Consider increasing timeout or using a proxy for ${t}`:k==="abort"?`Request aborted while fetching ${n} ${t}`:`Network/CORS issue while fetching ${n} ${t}. A proxy may be required`;ke.errorOnce(F,W)}return e.onError&&e.onError(C),C}finally{clearTimeout(S),te.delete(l)}})();return te.set(l,x),x}function pt(t,e){if(!e||!t.width||!t.height)return t;let n=document.createElement("canvas");n.width=t.width,n.height=t.height;let o=n.getContext("2d");return o.fillStyle=e,o.fillRect(0,0,n.width,n.height),o.drawImage(t,0,0),n}async function gt(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(t)||t.trim()==="none")return t;let o=ht(t);if(!o)return t;let r=ut(o);if(h.background.has(r)){let s=h.background.get(r);return s?`url("${s}")`:"none"}try{let s=await V(r,{as:"dataURL",useProxy:e.useProxy});return s.ok?(h.background.set(r,s.data),`url("${s.data}")`):(h.background.set(r,null),"none")}catch{return h.background.set(r,null),"none"}}var Ut=new Set(["meta","script","noscript","title","link","template"]),At=new Set(["meta","link","style","title","noscript","script","template","g","defs","use","marker","mask","clipPath","pattern","path","polygon","polyline","line","circle","ellipse","rect","filter","lineargradient","radialgradient","stop"]),rn=["div","span","p","a","img","ul","li","button","input","select","textarea","label","section","article","header","footer","nav","main","aside","h1","h2","h3","h4","h5","h6","table","thead","tbody","tr","td","th"];function ee(){for(let t of rn){let e=String(t).toLowerCase();Ut.has(e)||At.has(e)||ne(e)}}function ne(t){if(t=String(t).toLowerCase(),At.has(t)){let s={};return h.defaultStyle.set(t,s),s}if(h.defaultStyle.has(t))return h.defaultStyle.get(t);let e=document.getElementById("snapdom-sandbox");e||(e=document.createElement("div"),e.id="snapdom-sandbox",e.setAttribute("data-snapdom-sandbox","true"),e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.width="0px",e.style.height="0px",e.style.overflow="hidden",document.body.appendChild(e));let n=document.createElement(t);n.style.all="initial",e.appendChild(n);let o=getComputedStyle(n),r={};for(let s of o){if(Ae(s))continue;let a=o.getPropertyValue(s);r[s]=a}return e.removeChild(n),h.defaultStyle.set(t,r),r}var an=/(?:^|-)(animation|transition)(?:-|$)/i,sn=/^(--|view-timeline|scroll-timeline|animation-trigger|offset-|position-try|app-region|interactivity|overlay|view-transition|-webkit-locale|-webkit-user-(?:drag|modify)|-webkit-tap-highlight-color|-webkit-text-security)$/i,cn=new Set(["cursor","pointer-events","touch-action","user-select","print-color-adjust","speak","reading-flow","reading-order","anchor-name","anchor-scope","container-name","container-type","timeline-scope"]);function Ae(t){let e=String(t).toLowerCase();return!!(cn.has(e)||sn.test(e)||an.test(e))}function $t(t,e){if(e=String(e||"").toLowerCase(),At.has(e))return"";let n=[],o=ne(e);for(let[r,s]of Object.entries(t)){if(Ae(r))continue;let a=o[r];s&&s!==a&&n.push(`${r}:${s}`)}return n.sort(),n.join(";")}function oe(t){let e=new Set;return t.nodeType!==Node.ELEMENT_NODE&&t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(t.tagName&&e.add(t.tagName.toLowerCase()),typeof t.querySelectorAll=="function"&&t.querySelectorAll("*").forEach(n=>e.add(n.tagName.toLowerCase())),Array.from(e))}function re(t){let e=new Map;for(let o of t){let r=h.defaultStyle.get(o);if(!r)continue;let s=Object.entries(r).map(([a,i])=>`${a}:${i};`).sort().join("");s&&(e.has(s)||e.set(s,[]),e.get(s).push(o))}let n="";for(let[o,r]of e.entries())n+=`${r.join(",")} { ${o} }
|
|
2
|
+
`;return n}function ae(t){let e=Array.from(new Set(t.values())).filter(Boolean).sort(),n=new Map,o=1;for(let r of e)n.set(r,`c${o++}`);return n}function yt(t,e=null){if(!(t instanceof Element))return window.getComputedStyle(t,e);let n=h.computedStyle.get(t);if(n||(n=new Map,h.computedStyle.set(t,n)),!n.has(e)){let o=window.getComputedStyle(t,e);n.set(e,o)}return n.get(e)}function Bt(t){let e={};for(let n of t)e[n]=t.getPropertyValue(n);return e}function wt(t){let e=[],n=0,o=0;for(let r=0;r<t.length;r++){let s=t[r];s==="("&&n++,s===")"&&n--,s===","&&n===0&&(e.push(t.slice(o,r).trim()),o=r+1)}return e.push(t.slice(o).trim()),e}function st(t,{fast:e=!1}={}){if(e)return t();"requestIdleCallback"in window?requestIdleCallback(t,{timeout:50}):setTimeout(t,1)}function z(){let t=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"",e=/^((?!chrome|android).)*safari/i.test(t),n=/(MicroMessenger|wxwork|WeCom|WindowsWechat|MacWechat)/i.test(t);return e||n}var $e=new WeakMap,se=new Map,ie=0;function Et(){ie++}var Ee=!1;function ln(t=document.documentElement){if(!Ee){Ee=!0;try{new MutationObserver(()=>Et()).observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>Et()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let e=document.fonts;e&&(e.addEventListener?.("loadingdone",Et),e.ready?.then(()=>Et()).catch(()=>{}))}catch{}}}function un(t,e={}){let n={},o=t.getPropertyValue("visibility");for(let r=0;r<t.length;r++){let s=t[r],a=t.getPropertyValue(s);(s==="background-image"||s==="content")&&a.includes("url(")&&!a.includes("data:")&&(a="none"),n[s]=a}if(e.embedFonts){let r=["font-feature-settings","font-variation-settings","font-kerning","font-variant","font-variant-ligatures","font-optical-sizing"];for(let s of r)if(!n[s])try{let a=t.getPropertyValue(s);a&&(n[s]=a)}catch{}}return o==="hidden"&&(n.opacity="0"),n}var Fe=new WeakMap;function fn(t){let e=Fe.get(t);return e||(e=Object.entries(t).sort((o,r)=>o[0]<r[0]?-1:o[0]>r[0]?1:0).map(([o,r])=>`${o}:${r}`).join(";"),Fe.set(t,e),e)}function dn(t,e=null,n={}){let o=$e.get(t);if(o&&o.epoch===ie)return o.snapshot;let r=e||getComputedStyle(t),s=un(r,n);return wn(t,r,s),$e.set(t,{epoch:ie,snapshot:s}),s}function mn(t,e){return t&&t.session&&t.persist?t:t&&(t.styleMap||t.styleCache||t.nodeMap)?{session:t,persist:{snapshotKeyCache:se,defaultStyle:h.defaultStyle,baseStyle:h.baseStyle,image:h.image,resource:h.resource,background:h.background,font:h.font},options:e||{}}:{session:h.session,persist:{snapshotKeyCache:se,defaultStyle:h.defaultStyle,baseStyle:h.baseStyle,image:h.image,resource:h.resource,background:h.background,font:h.font},options:t||e||{}}}async function bt(t,e,n,o){if(t.tagName==="STYLE")return;let r=mn(n,o),s=r.options&&r.options.cache||"auto";if(s!=="disabled"&&ln(document.documentElement),s==="disabled"&&!r.session.__bumpedForDisabled&&(Et(),se.clear(),r.session.__bumpedForDisabled=!0),At.has(t.tagName?.toLowerCase())){let m=t.getAttribute?.("style");m&&e.setAttribute("style",m)}let{session:a,persist:i}=r;a.styleCache.has(t)||a.styleCache.set(t,getComputedStyle(t));let l=a.styleCache.get(t),c=dn(t,l,r.options),u=fn(c),f=i.snapshotKeyCache.get(u);if(!f){let m=t.tagName?.toLowerCase()||"div";f=$t(c,m),i.snapshotKeyCache.set(u,f)}a.styleMap.set(e,f)}function hn(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof HTMLIFrameElement||t instanceof SVGElement||t instanceof HTMLObjectElement||t instanceof HTMLEmbedElement}function pn(t){return t.backgroundImage&&t.backgroundImage!=="none"||t.backgroundColor&&t.backgroundColor!=="rgba(0, 0, 0, 0)"&&t.backgroundColor!=="transparent"||(parseFloat(t.borderTopWidth)||0)>0||(parseFloat(t.borderBottomWidth)||0)>0||(parseFloat(t.paddingTop)||0)>0||(parseFloat(t.paddingBottom)||0)>0?!0:(t.overflowBlock||t.overflowY||"visible")!=="visible"}function gn(t){let e=t.parentElement;if(!e)return!1;let n=getComputedStyle(e).display||"";return n.includes("flex")||n.includes("grid")}function yn(t,e){if(t.textContent&&/\S/.test(t.textContent))return!0;let n=t.firstElementChild,o=t.lastElementChild;if(n&&n.tagName==="BR"||o&&o.tagName==="BR")return!0;let r=t.scrollHeight;if(r===0)return!1;let s=parseFloat(e.paddingTop)||0,a=parseFloat(e.paddingBottom)||0;return r>s+a}function wn(t,e,n){if(t instanceof HTMLElement&&t.style&&t.style.height)return;let o=e.display||"";if(o.includes("flex")||o.includes("grid")||hn(t))return;let r=e.position;r==="absolute"||r==="fixed"||r==="sticky"||e.transform==="none"&&(pn(e)||gn(t)||yn(t,e)&&(delete n.height,delete n["block-size"]))}function ce(t,e,n){return Promise.all(t.map(o=>new Promise(r=>{function s(){st(a=>{(a&&typeof a.timeRemaining=="function"?a.timeRemaining()>0:!0)?e(o,r):s()},{fast:n})}s()})))}function bn(t){return t=t.trim(),!t||/\:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(t)?t:`${t}:not([data-sd-slotted])`}function xn(t,e,n=!0){return t.split(",").map(o=>o.trim()).filter(Boolean).map(o=>{if(o.startsWith(":where(")||o.startsWith("@"))return o;let r=n?bn(o):o;return`:where(${e} ${r})`}).join(", ")}function Sn(t,e){return t?(t=t.replace(/:host\(([^)]+)\)/g,(n,o)=>`:where(${e}:is(${o.trim()}))`),t=t.replace(/:host\b/g,`:where(${e})`),t=t.replace(/:host-context\(([^)]+)\)/g,(n,o)=>`:where(:where(${o.trim()}) ${e})`),t=t.replace(/::slotted\(([^)]+)\)/g,(n,o)=>`:where(${e} ${o.trim()})`),t=t.replace(/(^|})(\s*)([^@}{]+){/g,(n,o,r,s)=>{let a=xn(s,e,!0);return`${o}${r}${a}{`}),t):""}function Cn(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}function kn(t){let e="";try{t.querySelectorAll("style").forEach(o=>{e+=(o.textContent||"")+`
|
|
3
|
+
`});let n=t.adoptedStyleSheets||[];for(let o of n)try{if(o&&o.cssRules)for(let r of o.cssRules)e+=r.cssText+`
|
|
4
|
+
`}catch{}}catch{}return e}function Mn(t,e,n){if(!e)return;let o=document.createElement("style");o.setAttribute("data-sd",n),o.textContent=e,t.insertBefore(o,t.firstChild||null)}function An(t,e){try{let n=t.currentSrc||t.src||"";if(!n)return;e.setAttribute("src",n),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}function $n(t){let e=new Set;if(!t)return e;let n=/var\(\s*(--[A-Za-z0-9_-]+)\b/g,o;for(;o=n.exec(t);)e.add(o[1]);return e}function En(t,e){try{let o=getComputedStyle(t).getPropertyValue(e).trim();if(o)return o}catch{}try{let o=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(o)return o}catch{}return""}function Fn(t,e,n){let o=[];for(let r of e){let s=En(t,r);s&&o.push(`${r}: ${s};`)}return o.length?`${n}{${o.join("")}}
|
|
5
|
+
`:""}function vn(t){t&&(t.nodeType===Node.ELEMENT_NODE&&t.setAttribute("data-sd-slotted",""),t.querySelectorAll&&t.querySelectorAll("*").forEach(e=>e.setAttribute("data-sd-slotted","")))}async function Ln(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},o=n(),r=0;for(;r<e&&(!o||!o.body&&!o.documentElement);)await new Promise(s=>setTimeout(s,0)),o=n(),r++;return o&&(o.body||o.documentElement)?o:null}function Nn(t){let e=t.getBoundingClientRect(),n=0,o=0,r=0,s=0;try{let l=getComputedStyle(t);n=parseFloat(l.borderLeftWidth)||0,o=parseFloat(l.borderRightWidth)||0,r=parseFloat(l.borderTopWidth)||0,s=parseFloat(l.borderBottomWidth)||0}catch{}let a=Math.max(0,Math.round(e.width-(n+o))),i=Math.max(0,Math.round(e.height-(r+s)));return{contentWidth:a,contentHeight:i,rect:e}}function Rn(t,e,n){let o=t.createElement("style");return o.setAttribute("data-sd-iframe-pin",""),o.textContent=`html, body {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(t.head||t.documentElement).appendChild(o),()=>{try{o.remove()}catch{}}}async function In(t,e,n){let o=await Ln(t,3);if(!o)throw new Error("iframe document not accessible/ready");let{contentWidth:r,contentHeight:s,rect:a}=Nn(t),i=n?.snap;if(!i||typeof i.toPng!="function")throw new Error("snapdom.toPng not available in iframe or window");let l={...n,scale:1},c=Rn(o,r,s),u;try{u=await i.toPng(o.documentElement,l)}finally{c()}u.style.display="block",u.style.width=`${r}px`,u.style.height=`${s}px`;let f=document.createElement("div");return e.nodeMap.set(f,t),bt(t,f,e,n),f.style.overflow="hidden",f.style.display="block",f.style.width||(f.style.width=`${Math.round(a.width)}px`),f.style.height||(f.style.height=`${Math.round(a.height)}px`),f.appendChild(u),f}async function Ft(t,e,n){if(!t)throw new Error("Invalid node");let o=new Set,r=null,s=null;if(t.nodeType===Node.ELEMENT_NODE){let c=(t.localName||t.tagName||"").toLowerCase();if(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox")||Ut.has(c))return null}if(t.nodeType===Node.TEXT_NODE||t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if(t.getAttribute("data-capture")==="exclude"){if(n.excludeMode==="hide"){let c=document.createElement("div"),u=t.getBoundingClientRect();return c.style.cssText=`display:inline-block;width:${u.width}px;height:${u.height}px;visibility:hidden;`,c}else if(n.excludeMode==="remove")return null}if(n.exclude&&Array.isArray(n.exclude))for(let c of n.exclude)try{if(t.matches?.(c)){if(n.excludeMode==="hide"){let u=document.createElement("div"),f=t.getBoundingClientRect();return u.style.cssText=`display:inline-block;width:${f.width}px;height:${f.height}px;visibility:hidden;`,u}else if(n.excludeMode==="remove")return null}}catch(u){console.warn(`Invalid selector in exclude option: ${c}`,u)}if(typeof n.filter=="function")try{if(!n.filter(t)){if(n.filterMode==="hide"){let c=document.createElement("div"),u=t.getBoundingClientRect();return c.style.cssText=`display:inline-block;width:${u.width}px;height:${u.height}px;visibility:hidden;`,c}else if(n.filterMode==="remove")return null}}catch(c){console.warn("Error in filter function:",c)}if(t.tagName==="IFRAME"){let c=!1;try{c=!!(t.contentDocument||t.contentWindow?.document)}catch{c=!1}if(c)try{return await In(t,e,n)}catch(u){console.warn("[SnapDOM] iframe rasterization failed, fallback:",u)}if(n.placeholders){let u=document.createElement("div");return u.style.cssText=`width:${t.offsetWidth}px;height:${t.offsetHeight}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`,bt(t,u,e,n),u}else{let u=t.getBoundingClientRect(),f=document.createElement("div");return f.style.cssText=`display:inline-block;width:${u.width}px;height:${u.height}px;visibility:hidden;`,bt(t,f,e,n),f}}if(t.getAttribute("data-capture")==="placeholder"){let c=t.cloneNode(!1);e.nodeMap.set(c,t),bt(t,c,e,n);let u=document.createElement("div");return u.textContent=t.getAttribute("data-placeholder-text")||"",u.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",c.appendChild(u),c}if(t.tagName==="CANVAS"){let c=t.toDataURL(),u=document.createElement("img");return u.src=c,u.width=t.width,u.height=t.height,e.nodeMap.set(u,t),bt(t,u,e,n),u}let a;try{if(a=t.cloneNode(!1),e.nodeMap.set(a,t),t.tagName==="IMG"){An(t,a);try{let c=t.getBoundingClientRect(),u=Math.round(c.width||0),f=Math.round(c.height||0);if(!u||!f){let m=window.getComputedStyle(t),A=parseFloat(m.width)||0,S=parseFloat(m.height)||0,x=parseInt(t.getAttribute("width")||"",10)||0,g=parseInt(t.getAttribute("height")||"",10)||0,k=t.width||t.naturalWidth||0,C=t.height||t.naturalHeight||0;u=Math.round(u||A||x||k||0),f=Math.round(f||S||g||C||0)}u&&(a.dataset.snapdomWidth=String(u)),f&&(a.dataset.snapdomHeight=String(f))}catch{}}}catch(c){throw console.error("[Snapdom] Failed to clone node:",t,c),c}if(t instanceof HTMLTextAreaElement){let c=t.getBoundingClientRect();a.style.width=`${c.width}px`,a.style.height=`${c.height}px`}if(t instanceof HTMLInputElement&&(a.value=t.value,a.setAttribute("value",t.value),t.checked!==void 0&&(a.checked=t.checked,t.checked&&a.setAttribute("checked",""),t.indeterminate&&(a.indeterminate=t.indeterminate))),t instanceof HTMLSelectElement&&(r=t.value),t instanceof HTMLTextAreaElement&&(s=t.value),bt(t,a,e,n),t.shadowRoot){let g=function(C,F){if(C.nodeType===Node.ELEMENT_NODE&&C.tagName==="STYLE")return F(null);Ft(C,e,n).then(W=>{F(W||null)}).catch(W=>{F(null)})};try{let C=t.shadowRoot.querySelectorAll("slot");for(let F of C){let W=[];try{W=F.assignedNodes?.({flatten:!0})||F.assignedNodes?.()||[]}catch{W=F.assignedNodes?.()||[]}for(let X of W)o.add(X)}}catch{}let c=Cn(e),u=`[data-sd="${c}"]`;try{a.setAttribute("data-sd",c)}catch{}let f=kn(t.shadowRoot),m=Sn(f,u),A=$n(f),S=Fn(t,A,u);Mn(a,S+m,c);let x=document.createDocumentFragment(),k=await ce(Array.from(t.shadowRoot.childNodes),g,n.fast);x.append(...k.filter(C=>!!C)),a.appendChild(x)}if(t.tagName==="SLOT"){let m=function(S,x){Ft(S,e,n).then(g=>{g&&vn(g),x(g||null)}).catch(g=>{x(null)})},c=t.assignedNodes?.({flatten:!0})||[],u=c.length>0?c:Array.from(t.childNodes),f=document.createDocumentFragment(),A=await ce(Array.from(u),m,n.fast);return f.append(...A.filter(S=>!!S)),f}function i(c,u){if(o.has(c))return u(null);Ft(c,e,n).then(f=>{u(f||null)}).catch(f=>{u(null)})}let l=await ce(Array.from(t.childNodes),i,n.fast);if(a.append(...l.filter(c=>!!c)),r!==null&&a instanceof HTMLSelectElement){a.value=r;for(let c of a.options)c.value===r?c.setAttribute("selected",""):c.removeAttribute("selected")}return s!==null&&a instanceof HTMLTextAreaElement&&(a.textContent=s),a}var Tn=[/font\s*awesome/i,/material\s*icons/i,/ionicons/i,/glyphicons/i,/feather/i,/bootstrap\s*icons/i,/remix\s*icons/i,/heroicons/i,/layui/i,/lucide/i],le=[];function ve(t){let e=Array.isArray(t)?t:[t];for(let n of e)n instanceof RegExp?le.push(n):typeof n=="string"?le.push(new RegExp(n,"i")):console.warn("[snapdom] Ignored invalid iconFont value:",n)}function et(t){let e=typeof t=="string"?t:"",n=[...Tn,...le];for(let o of n)if(o instanceof RegExp&&o.test(e))return!0;return!!(/icon/i.test(e)||/glyph/i.test(e)||/symbols/i.test(e)||/feather/i.test(e)||/fontawesome/i.test(e))}async function Le(t,e,n,o=32,r="#000"){e=e.replace(/^['"]+|['"]+$/g,"");let s=window.devicePixelRatio||1;await document.fonts.ready;let a=document.createElement("span");a.textContent=t,a.style.position="absolute",a.style.visibility="hidden",a.style.fontFamily=`"${e}"`,a.style.fontWeight=n||"normal",a.style.fontSize=`${o}px`,a.style.lineHeight="1",a.style.whiteSpace="nowrap",a.style.padding="0",a.style.margin="0",document.body.appendChild(a);let i=a.getBoundingClientRect(),l=Math.ceil(i.width),c=Math.ceil(i.height);document.body.removeChild(a);let u=document.createElement("canvas");u.width=l*s,u.height=c*s;let f=u.getContext("2d");return f.scale(s,s),f.font=n?`${n} ${o}px "${e}"`:`${o}px "${e}"`,f.textAlign="left",f.textBaseline="top",f.fillStyle=r,f.fillText(t,0,0),{dataUrl:u.toDataURL(),width:l,height:c}}var Wn=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]);function Ot(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^['"]+|['"]+$/g,"");if(n&&!Wn.has(n.toLowerCase()))return n}return""}function Dt(t){let e=String(t??"400").trim().toLowerCase();if(e==="normal")return 400;if(e==="bold")return 700;let n=parseInt(e,10);return Number.isFinite(n)?Math.min(900,Math.max(100,n)):400}function ue(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function _n(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function Pn(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let r=Dt(n[1]),s=Dt(n[2]);return{min:Math.min(r,s),max:Math.max(r,s)}}let o=Dt(e);return{min:o,max:o}}function Un(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function Bn(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let s=parseFloat(n[1]),a=parseFloat(n[2]);return{min:Math.min(s,a),max:Math.max(s,a)}}let o=e.match(/(\d+(?:\.\d+)?)\s*%/),r=o?parseFloat(o[1]):100;return{min:r,max:r}}function On(t,e){if(!t)return!1;try{let n=new URL(t,location.href);if(n.origin===location.origin)return!0;let r=n.host.toLowerCase();if(["fonts.googleapis.com","fonts.gstatic.com","use.typekit.net","p.typekit.net","kit.fontawesome.com","use.fontawesome.com"].some(i=>r.endsWith(i)))return!0;let a=(n.pathname+n.search).toLowerCase();if(/\bfont(s)?\b/.test(a)||/\.woff2?(\b|$)/.test(a))return!0;for(let i of e){let l=i.toLowerCase().replace(/\s+/g,"+"),c=i.toLowerCase().replace(/\s+/g,"-");if(a.includes(l)||a.includes(c))return!0}return!1}catch{return!1}}function Dn(t){let e=new Set;for(let n of t||[]){let o=String(n).split("__")[0]?.trim();o&&e.add(o)}return e}async function Ht({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:o=[],useProxy:r=""}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let s=new Map;for(let d of t){let[b,w,M,p]=String(d).split("__");if(!b)continue;let y=s.get(b)||[];y.push({w:parseInt(w,10),s:M,st:parseInt(p,10)}),s.set(b,y)}let a=/@import\s+url\(["']?([^"')]+)["']?\)/g,i=/url\((["']?)([^"')]+)\1\)/g,l=/@font-face[^{}]*\{[^}]*\}/g;function c(d,b,w,M){if(!s.has(d))return!1;let p=s.get(d),y=Pn(w),E=Un(b),v=Bn(M),$=y.min!==y.max,N=y.min,_=I=>E.kind==="normal"&&I==="normal"||E.kind!=="normal"&&(I==="italic"||I==="oblique"),H=!1;for(let I of p){let L=$?I.w>=y.min&&I.w<=y.max:I.w===N,R=_(ue(I.s)),P=I.st>=v.min&&I.st<=v.max;if(L&&R&&P){H=!0;break}}if(H)return!0;if(!$)for(let I of p){let L=_(ue(I.s)),R=I.st>=v.min&&I.st<=v.max;if(Math.abs(N-I.w)<=300&&L&&R)return!0}return!1}function u(d){if(!d)return[];let b=[],w=d.split(",").map(M=>M.trim()).filter(Boolean);for(let M of w){let p=M.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!p)continue;let y=p[1],E=p[2],v=$=>{if(!$.includes("?"))return parseInt($,16);let N=parseInt($.replace(/\?/g,"0"),16),_=parseInt($.replace(/\?/g,"F"),16);return[N,_]};if(E){let $=v(y),N=v(E),_=Array.isArray($)?$[0]:$,H=Array.isArray(N)?N[1]:N;b.push([Math.min(_,H),Math.max(_,H)])}else{let $=v(y);Array.isArray($)?b.push([$[0],$[1]]):b.push([$,$])}}return b}function f(d,b){if(!b.length||!d||d.size===0)return!0;for(let w of d)for(let[M,p]of b)if(w>=M&&w<=p)return!0;return!1}function m(d,b){let w=[];if(!d)return w;for(let M of d.matchAll(i)){let p=(M[2]||"").trim();if(!(!p||p.startsWith("data:"))){if(!/^https?:/i.test(p))try{p=new URL(p,b||location.href).href}catch{}w.push(p)}}return w}async function A(d,b){let w=d;for(let M of d.matchAll(i)){let p=ht(M[0]);if(!p)continue;let y=p;if(!y.startsWith("http")&&!y.startsWith("data:"))try{y=new URL(y,b||location.href).href}catch{}if(!et(y)){if(h.resource?.has(y)){h.font?.add(y),w=w.replace(M[0],`url(${h.resource.get(y)})`);continue}if(!h.font?.has(y))try{let E=await V(y,{as:"dataURL",useProxy:r,silent:!0});if(E.ok&&typeof E.data=="string"){let v=E.data;h.resource?.set(y,v),h.font?.add(y),w=w.replace(M[0],`url(${v})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",y)}}}return w}function S(d){if(!d.length)return null;let b=(v,$)=>d.some(([N,_])=>!(_<v||N>$)),w=b(0,255)||b(305,305),M=b(256,591)||b(7680,7935),p=b(880,1023),y=b(1024,1279);return b(7840,7929)||b(258,259)||b(416,417)||b(431,432)?"vietnamese":y?"cyrillic":p?"greek":M?"latin-ext":w?"latin":null}function x(d={}){let b=new Set((d.families||[]).map(p=>String(p).toLowerCase())),w=new Set((d.domains||[]).map(p=>String(p).toLowerCase())),M=new Set((d.subsets||[]).map(p=>String(p).toLowerCase()));return(p,y)=>{if(b.size&&b.has(p.family.toLowerCase()))return!0;if(w.size)for(let E of p.srcUrls)try{if(w.has(new URL(E).host.toLowerCase()))return!0}catch{}if(M.size){let E=S(y);if(E&&M.has(E))return!0}return!1}}let g=x(n);function k(d){if(!d)return d;let b=/@font-face[^{}]*\{[^}]*\}/gi,w=new Set,M=[];for(let y of d.match(b)||[]){let E=y.match(/font-family:\s*([^;]+);/i)?.[1]||"",v=Ot(E),$=(y.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),N=(y.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),_=(y.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),H=(y.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),I=(y.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),L=m(I,location.href),R=L.length?L.map(q=>String(q).toLowerCase()).sort().join("|"):I.toLowerCase(),P=[String(v||"").toLowerCase(),$,N,_,H.toLowerCase(),R].join("|");w.has(P)||(w.add(P),M.push(y))}if(M.length===0)return d;let p=0;return d.replace(b,()=>M[p++]||"")}function C(){let d=Array.from(t||[]).sort().join("|"),b=n?JSON.stringify({families:(n.families||[]).map(p=>String(p).toLowerCase()).sort(),domains:(n.domains||[]).map(p=>String(p).toLowerCase()).sort(),subsets:(n.subsets||[]).map(p=>String(p).toLowerCase()).sort()}):"",w=(o||[]).map(p=>`${(p.family||"").toLowerCase()}::${p.weight||"normal"}::${p.style||"normal"}::${p.src||""}`).sort().join("|");return`fonts-embed-css::req=${d}::ex=${b}::lf=${w}::px=${r||""}`}let F=C();if(h.resource?.has(F))return h.resource.get(F);let W=Dn(t),X=[];for(let d of document.querySelectorAll("style")){let b=d.textContent||"";for(let w of b.matchAll(a)){let M=w[1];if(!M||et(M))continue;!!document.querySelector(`link[rel="stylesheet"][href="${M}"]`)||X.push(M)}}X.length&&await Promise.all(X.map(d=>new Promise(b=>{if(document.querySelector(`link[rel="stylesheet"][href="${d}"]`))return b(null);let w=document.createElement("link");w.rel="stylesheet",w.href=d,w.setAttribute("data-snapdom","injected-import"),w.onload=()=>b(w),w.onerror=()=>b(null),document.head.appendChild(w)})));let O="",j=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(d=>!!d.href);for(let d of j)try{if(et(d.href))continue;let b="",w=!1;try{w=new URL(d.href,location.href).origin===location.origin}catch{}if(!w&&!On(d.href,W))continue;if(w){let p=Array.from(document.styleSheets).find(y=>y.href===d.href);if(p)try{let y=p.cssRules||[];b=Array.from(y).map(E=>E.cssText).join("")}catch{}}if(!b&&(b=(await V(d.href,{as:"text",useProxy:r})).data,et(d.href)))continue;let M="";for(let p of b.match(l)||[]){let y=(p.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),E=Ot(y);if(!E||et(E))continue;let v=(p.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),$=(p.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),N=(p.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),_=(p.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),H=(p.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),I=m(H,d.href);if(!c(E,$,v,N))continue;let L=u(_);if(!f(e,L))continue;let R={family:E,weightSpec:v,styleSpec:$,stretchSpec:N,unicodeRange:_,srcRaw:H,srcUrls:I,href:d.href};if(n&&g(R,L))continue;let P=/url\(/i.test(H)?await A(p,d.href):p;M+=P+""}M.trim()&&(O+=M+"")}catch{console.warn("[snapdom] Failed to process stylesheet:",d.href)}for(let d of document.styleSheets)try{if(d.href&&j.some(w=>w.href===d.href))continue;let b=d.cssRules||[];for(let w of b){if(w.type!==CSSRule.FONT_FACE_RULE)continue;let M=(w.style.getPropertyValue("font-family")||"").trim(),p=Ot(M);if(!p||et(p))continue;let y=(w.style.getPropertyValue("font-weight")||"400").trim(),E=(w.style.getPropertyValue("font-style")||"normal").trim(),v=(w.style.getPropertyValue("font-stretch")||"100%").trim(),$=(w.style.getPropertyValue("src")||"").trim(),N=(w.style.getPropertyValue("unicode-range")||"").trim(),_=m($,d.href||location.href);if(!c(p,E,y,v))continue;let H=u(N);if(!f(e,H))continue;let I={family:p,weightSpec:y,styleSpec:E,stretchSpec:v,unicodeRange:N,srcRaw:$,srcUrls:_,href:d.href||location.href};if(!(n&&g(I,H)))if(/url\(/i.test($)){let L=await A($,d.href||location.href);O+=`@font-face{font-family:${p};src:${L};font-style:${E};font-weight:${y};font-stretch:${v};${N?`unicode-range:${N};`:""}}`}else O+=`@font-face{font-family:${p};src:${$};font-style:${E};font-weight:${y};font-stretch:${v};${N?`unicode-range:${N};`:""}}`}}catch{}try{for(let d of document.fonts||[]){if(!d||!d.family||d.status!=="loaded"||!d._snapdomSrc)continue;let b=String(d.family).replace(/^['"]+|['"]+$/g,"");if(et(b)||!s.has(b)||n?.families&&n.families.some(M=>String(M).toLowerCase()===b.toLowerCase()))continue;let w=d._snapdomSrc;if(!String(w).startsWith("data:")){if(h.resource?.has(d._snapdomSrc))w=h.resource.get(d._snapdomSrc),h.font?.add(d._snapdomSrc);else if(!h.font?.has(d._snapdomSrc))try{let M=await V(d._snapdomSrc,{as:"dataURL",useProxy:r,silent:!0});if(M.ok&&typeof M.data=="string")w=M.data,h.resource?.set(d._snapdomSrc,w),h.font?.add(d._snapdomSrc);else continue}catch{console.warn("[snapdom] Failed to fetch dynamic font src:",d._snapdomSrc);continue}}O+=`@font-face{font-family:'${b}';src:url(${w});font-style:${d.style||"normal"};font-weight:${d.weight||"normal"};}`}}catch{}for(let d of o){if(!d||typeof d!="object")continue;let b=String(d.family||"").replace(/^['"]+|['"]+$/g,"");if(!b||et(b)||!s.has(b)||n?.families&&n.families.some(v=>String(v).toLowerCase()===b.toLowerCase()))continue;let w=d.weight!=null?String(d.weight):"normal",M=d.style!=null?String(d.style):"normal",p=d.stretchPct!=null?`${d.stretchPct}%`:"100%",y=String(d.src||""),E=y;if(!E.startsWith("data:")){if(h.resource?.has(y))E=h.resource.get(y),h.font?.add(y);else if(!h.font?.has(y))try{let v=await V(y,{as:"dataURL",useProxy:r,silent:!0});if(v.ok&&typeof v.data=="string")E=v.data,h.resource?.set(y,E),h.font?.add(y);else continue}catch{console.warn("[snapdom] Failed to fetch localFonts src:",y);continue}}O+=`@font-face{font-family:'${b}';src:url(${E});font-style:${M};font-weight:${w};font-stretch:${p};}`}return O&&(O=k(O),h.resource?.set(F,O)),O}function qt(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),o=a=>{let i=Ot(a.fontFamily);if(!i)return;let l=(c,u,f)=>`${i}__${Dt(c)}__${ue(u)}__${_n(f)}`;e.add(l(a.fontWeight,a.fontStyle,a.fontStretch))};o(getComputedStyle(t));let r=getComputedStyle(t,"::before");r&&r.content&&r.content!=="none"&&o(r);let s=getComputedStyle(t,"::after");for(s&&s.content&&s.content!=="none"&&o(s);n.nextNode();){let a=n.currentNode,i=getComputedStyle(a);o(i);let l=getComputedStyle(a,"::before");l&&l.content&&l.content!=="none"&&o(l);let c=getComputedStyle(a,"::after");c&&c.content&&c.content!=="none"&&o(c)}return e}function jt(t){let e=new Set,n=r=>{if(r)for(let s of r)e.add(s.codePointAt(0))},o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;o.nextNode();){let r=o.currentNode;if(r.nodeType===Node.TEXT_NODE)n(r.nodeValue||"");else if(r.nodeType===Node.ELEMENT_NODE){let s=r;for(let a of["::before","::after"]){let l=getComputedStyle(s,a)?.getPropertyValue("content");if(!(!l||l==="none"))if(/^"/.test(l)||/^'/.test(l))n(l.slice(1,-1));else{let c=l.match(/\\[0-9A-Fa-f]{1,6}/g);if(c)for(let u of c)try{e.add(parseInt(u.slice(1),16))}catch{}}}}}return e}async function Vt(t,e=2){try{await document.fonts.ready}catch{}let n=Array.from(t||[]).filter(Boolean);if(n.length===0)return;let o=()=>{let r=document.createElement("div");r.style.cssText="position: absolute !important;left: -9999px !important;top: 0 !important;opacity: 0 !important;pointer-events: none !important;contain: layout size style;";for(let s of n){let a=document.createElement("span");a.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",a.style.fontFamily=`"${s}"`,a.style.fontWeight="700",a.style.fontStyle="italic",a.style.fontSize="32px",a.style.lineHeight="1",a.style.whiteSpace="nowrap",a.style.margin="0",a.style.padding="0",r.appendChild(a)}document.body.appendChild(r),r.offsetWidth,document.body.removeChild(r)};for(let r=0;r<Math.max(1,e);r++)o(),await new Promise(s=>requestAnimationFrame(()=>requestAnimationFrame(s)))}function Te(t){return/\bcounter\s*\(|\bcounters\s*\(/.test(t||"")}function Hn(t){return(t||"").replace(/"([^"]*)"/g,"$1")}function Ne(t,e=!1){let n="",o=Math.max(1,t);for(;o>0;)o--,n=String.fromCharCode(97+o%26)+n,o=Math.floor(o/26);return e?n.toUpperCase():n}function Re(t,e=!0){let n=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],o=Math.max(1,Math.min(3999,t)),r="";for(let[s,a]of n)for(;o>=s;)r+=a,o-=s;return e?r:r.toLowerCase()}function Ie(t,e){switch((e||"decimal").toLowerCase()){case"decimal":return String(Math.max(0,t));case"decimal-leading-zero":return(t<10?"0":"")+String(Math.max(0,t));case"lower-alpha":return Ne(t,!1);case"upper-alpha":return Ne(t,!0);case"lower-roman":return Re(t,!1);case"upper-roman":return Re(t,!0);default:return String(Math.max(0,t))}}function We(t){let e=new WeakMap,n=t instanceof Document?t.documentElement:t,o=c=>c&&c.tagName==="LI",r=c=>{let u=0,f=c?.parentElement;if(!f)return 0;for(let m of f.children){if(m===c)break;m.tagName==="LI"&&u++}return u},s=c=>{let u=new Map;for(let[f,m]of c)u.set(f,m.slice());return u},a=(c,u,f)=>{let m=s(c),A;try{A=f.style?.counterReset||getComputedStyle(f).counterReset}catch{}if(A&&A!=="none")for(let x of A.split(",")){let g=x.trim().split(/\s+/),k=g[0],C=Number.isFinite(Number(g[1]))?Number(g[1]):0;if(!k)continue;let F=u.get(k);if(F&&F.length){let W=F.slice();W.push(C),m.set(k,W)}else m.set(k,[C])}let S;try{S=f.style?.counterIncrement||getComputedStyle(f).counterIncrement}catch{}if(S&&S!=="none")for(let x of S.split(",")){let g=x.trim().split(/\s+/),k=g[0],C=Number.isFinite(Number(g[1]))?Number(g[1]):1;if(!k)continue;let F=m.get(k)||[];F.length===0&&F.push(0),F[F.length-1]+=C,m.set(k,F)}try{if(getComputedStyle(f).display==="list-item"&&o(f)){let g=f.parentElement,k=1;if(g&&g.tagName==="OL"){let F=g.getAttribute("start"),W=Number.isFinite(Number(F))?Number(F):1,X=r(f),O=f.getAttribute("value");k=Number.isFinite(Number(O))?Number(O):W+X}else k=1+r(f);let C=m.get("list-item")||[];C.length===0&&C.push(0),C[C.length-1]=k,m.set("list-item",C)}}catch{}return m},i=(c,u,f)=>{let m=a(f,u,c);e.set(c,m);let A=m;for(let S of c.children)A=i(S,m,A);return m},l=new Map;return i(n,l,l),{get(c,u){let f=e.get(c)?.get(u);return f&&f.length?f[f.length-1]:0},getStack(c,u){let f=e.get(c)?.get(u);return f?f.slice():[]}}}function _e(t,e,n){if(!t||t==="none")return t;try{let o=/\b(counter|counters)\s*\(([^)]+)\)/g,r=t.replace(o,(s,a,i)=>{let l=String(i).split(",").map(c=>c.trim());if(a==="counter"){let c=l[0]?.replace(/^["']|["']$/g,""),u=(l[1]||"decimal").toLowerCase(),f=n.get(e,c);return Ie(f,u)}else{let c=l[0]?.replace(/^["']|["']$/g,""),u=l[1]?.replace(/^["']|["']$/g,"")??"",f=(l[2]||"decimal").toLowerCase(),m=n.getStack(e,c);return m.length?m.map(S=>Ie(S,f)).join(u):""}});return Hn(r)}catch{return"- "}}var vt=null,Lt=new WeakMap;function qn(t){return(t||"").replace(/"([^"]*)"/g,"$1")}function jn(t){if(!t)return"";let e=[],n=/"([^"]*)"/g,o;for(;o=n.exec(t);)e.push(o[1]);return e.length?e.join(""):qn(t)}function fe(t,e){let n=t.parentElement,o=n?Lt.get(n):null;return o?{get(r,s){let a=e.get(r,s),i=o.get(s);return typeof i=="number"?Math.max(a,i):a},getStack(r,s){let a=e.getStack(r,s);if(!a.length)return a;let i=o.get(s);if(typeof i=="number"){let l=a.slice();return l[l.length-1]=Math.max(l[l.length-1],i),l}return a}}:e}function de(t,e,n){let o=new Map;function r(l){let c=[];if(!l||l==="none")return c;for(let u of String(l).split(",")){let f=u.trim().split(/\s+/),m=f[0],A=Number.isFinite(Number(f[1]))?Number(f[1]):void 0;m&&c.push({name:m,num:A})}return c}let s=r(e?.counterReset),a=r(e?.counterIncrement);function i(l){if(o.has(l))return o.get(l).slice();let c=n.getStack(t,l);c=c.length?c.slice():[];let u=s.find(m=>m.name===l);if(u){let m=Number.isFinite(u.num)?u.num:0;c=c.length?[...c,m]:[m]}let f=a.find(m=>m.name===l);if(f){let m=Number.isFinite(f.num)?f.num:1;c.length===0&&(c=[0]),c[c.length-1]+=m}return o.set(l,c.slice()),c}return{get(l,c){let u=i(c);return u.length?u[u.length-1]:0},getStack(l,c){return i(c)},__incs:a}}function Vn(t,e,n){let o;try{o=getComputedStyle(t,e)}catch{}let r=o?.content;if(!r||r==="none"||r==="normal")return{text:"",incs:[]};let s=fe(t,n),a=de(t,o,s),i=Te(r)?_e(r,t,a):r;return{text:jn(i),incs:a.__incs||[]}}async function me(t,e,n,o){if(!(t instanceof Element)||!(e instanceof Element))return;if(!vt)try{vt=We(t.ownerDocument||document)}catch{}for(let a of["::before","::after","::first-letter"])try{let i=yt(t,a);if(!i||typeof i[Symbol.iterator]!="function"||i.content==="none"&&i.backgroundImage==="none"&&i.backgroundColor==="transparent"&&(i.borderStyle==="none"||parseFloat(i.borderWidth)===0)&&(!i.transform||i.transform==="none")&&i.display==="inline")continue;if(a==="::first-letter"){let L=getComputedStyle(t);if(!(i.color!==L.color||i.fontSize!==L.fontSize||i.fontWeight!==L.fontWeight))continue;let P=Array.from(e.childNodes).find(Q=>Q.nodeType===Node.TEXT_NODE&&Q.textContent?.trim().length>0);if(!P)continue;let q=P.textContent,rt=q.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0],It=q.slice(rt?.length||0);if(!rt||/[\uD800-\uDFFF]/.test(rt))continue;let xt=document.createElement("span");xt.textContent=rt,xt.dataset.snapdomPseudo="::first-letter";let Kt=Bt(i),Tt=$t(Kt,"span");n.styleMap.set(xt,Tt);let J=document.createTextNode(It);e.replaceChild(J,P),e.insertBefore(xt,J);continue}let c=i.content,{text:u,incs:f}=Vn(t,a,vt),m=i.backgroundImage,A=i.backgroundColor,S=i.fontFamily,x=parseInt(i.fontSize)||32,g=parseInt(i.fontWeight)||!1,k=i.color||"#000",C=i.display,F=parseFloat(i.width),W=parseFloat(i.height),X=i.borderStyle,O=parseFloat(i.borderWidth),j=i.transform,d=et(S),b=c!=="none"&&u!=="",w=m&&m!=="none",M=A&&A!=="transparent"&&A!=="rgba(0, 0, 0, 0)",p=C!=="inline"&&(F>0||W>0),y=X&&X!=="none"&&O>0,E=j&&j!=="none";if(!(b||w||M||p||y||E)){if(f&&f.length&&t.parentElement){let L=Lt.get(t.parentElement)||new Map;for(let{name:R,num:P}of f){if(!R)continue;let q=fe(t,vt),rt=de(t,getComputedStyle(t,a),q).get(t,R);L.set(R,rt)}Lt.set(t.parentElement,L)}continue}let $=document.createElement("span");$.dataset.snapdomPseudo=a,$.style.verticalAlign="middle";let N=Bt(i),_=$t(N,"span");if(n.styleMap.set($,_),d&&u&&u.length===1){let{dataUrl:L,width:R,height:P}=await Le(u,S,g,x,k),q=document.createElement("img");q.src=L,q.style=`height:${x}px;width:${R/P*x}px;object-fit:contain;`,$.appendChild(q),e.dataset.snapdomHasIcon="true"}else if(u&&u.startsWith("url(")){let L=ht(u);if(L?.trim())try{let R=document.createElement("img"),P=await V(ut(L),{as:"dataURL",useProxy:o.useProxy});R.src=P.data,R.style=`width:${x}px;height:auto;object-fit:contain;`,$.appendChild(R)}catch(R){console.error(`[snapdom] Error in pseudo ${a} for`,t,R)}}else!d&&b&&($.textContent=u);if(w)try{let L=wt(m),R=await Promise.all(L.map(gt));$.style.backgroundImage=R.join(", ")}catch(L){console.warn(`[snapdom] Failed to inline background-image for ${a}`,L)}M&&($.style.backgroundColor=A);let I=$.childNodes.length>0||$.textContent?.trim()!==""||w||M||p||y||E;if(f&&f.length&&t.parentElement){let L=Lt.get(t.parentElement)||new Map,R=fe(t,vt),P=de(t,getComputedStyle(t,a),R);for(let{name:q}of f){if(!q)continue;let it=P.get(t,q);L.set(q,it)}Lt.set(t.parentElement,L)}if(!I)continue;a==="::before"?e.insertBefore($,e.firstChild):e.appendChild($)}catch(i){console.warn(`[snapdom] Failed to capture ${a} for`,t,i)}let r=Array.from(t.children),s=Array.from(e.children).filter(a=>!a.dataset.snapdomPseudo);for(let a=0;a<Math.min(r.length,s.length);a++)await me(r[a],s[a],n,o)}function Pe(t){if(!t)return;let e=new Set;if(t.querySelectorAll("use").forEach(i=>{let l=i.getAttribute("xlink:href")||i.getAttribute("href");l&&l.startsWith("#")&&e.add(l.slice(1))}),!e.size)return;let n=Array.from(document.querySelectorAll("svg > symbol, svg > defs")),o=n.filter(i=>i.tagName.toLowerCase()==="symbol"),r=n.filter(i=>i.tagName.toLowerCase()==="defs"),s=t.querySelector("svg.inline-defs-container");s||(s=document.createElementNS("http://www.w3.org/2000/svg","svg"),s.setAttribute("aria-hidden","true"),s.setAttribute("style","position: absolute; width: 0; height: 0; overflow: hidden;"),s.classList.add("inline-defs-container"),t.insertBefore(s,t.firstChild));let a=new Set;t.querySelectorAll("symbol[id], defs > *[id]").forEach(i=>{a.add(i.id)}),e.forEach(i=>{if(a.has(i))return;let l=o.find(c=>c.id===i);if(l){s.appendChild(l.cloneNode(!0)),a.add(i);return}for(let c of r){let u=c.querySelector(`#${CSS.escape(i)}`);if(u){let f=s.querySelector("defs");f||(f=document.createElementNS("http://www.w3.org/2000/svg","defs"),s.appendChild(f)),f.appendChild(u.cloneNode(!0)),a.add(i);break}}})}async function Be(t,e={}){let n={styleMap:h.session.styleMap,styleCache:h.session.styleCache,nodeMap:h.session.nodeMap},o,r="",s="";zn(t);try{Pe(t)}catch(i){console.warn("inlineExternal defs or symbol failed:",i)}try{o=await Ft(t,n,e,t)}catch(i){throw console.warn("deepClone failed:",i),i}try{await me(t,o,n,e)}catch(i){console.warn("inlinePseudoElements failed:",i)}await Kn(o);try{let i=o.querySelectorAll("style[data-sd]");for(let l of i)s+=l.textContent||"",l.remove()}catch{}let a=ae(n.styleMap);r=Array.from(a.entries()).map(([i,l])=>`.${l}{${i}}`).join(""),r=s+r;for(let[i,l]of n.styleMap.entries()){if(i.tagName==="STYLE")continue;if(i.getRootNode&&i.getRootNode()instanceof ShadowRoot){i.setAttribute("style",l.replace(/;/g,"; "));continue}let c=a.get(l);c&&i.classList.add(c);let u=i.style?.backgroundImage,f=i.dataset?.snapdomHasIcon;u&&u!=="none"&&(i.style.backgroundImage=u),f&&(i.style.verticalAlign="middle",i.style.display="inline")}for(let[i,l]of n.nodeMap.entries()){let c=l.scrollLeft,u=l.scrollTop;if((c||u)&&i instanceof HTMLElement){i.style.overflow="hidden",i.style.scrollbarWidth="none",i.style.msOverflowStyle="none";let m=document.createElement("div");for(m.style.transform=`translate(${-c}px, ${-u}px)`,m.style.willChange="transform",m.style.display="inline-block",m.style.width="100%";i.firstChild;)m.appendChild(i.firstChild);i.appendChild(m)}}if(t===n.nodeMap.get(o)){let i=n.styleCache.get(t)||window.getComputedStyle(t);n.styleCache.set(t,i);let l=Zt(i.transform);o.style.margin="0",o.style.top="auto",o.style.left="auto",o.style.right="auto",o.style.bottom="auto",o.style.animation="none",o.style.transition="none",o.style.willChange="auto",o.style.float="none",o.style.clear="none",o.style.transform=l||""}for(let[i,l]of n.nodeMap.entries())l.tagName==="PRE"&&(i.style.marginTop="0",i.style.marginBlockStart="0");return{clone:o,classCSS:r,styleCache:n.styleCache}}function zn(t){let e=getComputedStyle(t),n=e.outlineStyle,o=e.outlineWidth,r=e.borderStyle,s=e.borderWidth,a=n!=="none"&&parseFloat(o)>0,i=r==="none"||parseFloat(s)===0;a&&i&&(t.style.border=`${o} solid transparent`)}var Nt=new Map;async function Rt(t){if(h.resource?.has(t))return h.resource.get(t);if(Nt.has(t))return Nt.get(t);let e=(async()=>{let n=await V(t,{as:"dataURL",silent:!0});if(!n.ok||typeof n.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);return h.resource?.set(t,n.data),n.data})();Nt.set(t,e);try{let n=await e;return Nt.set(t,n),n}catch(n){throw Nt.delete(t),n}}var Xn=/\bblob:[^)"'\s]+/g;async function Ue(t){if(!t||t.indexOf("blob:")===-1)return t;let e=Array.from(new Set(t.match(Xn)||[]));if(e.length===0)return t;let n=t;for(let o of e)try{let r=await Rt(o);n=n.split(o).join(r)}catch{}return n}function zt(t){return typeof t=="string"&&t.startsWith("blob:")}function Yn(t){return(t||"").split(",").map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.match(/^(\S+)(\s+.+)?$/);return n?{url:n[1],desc:n[2]||""}:null}).filter(Boolean)}function Gn(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}async function Kn(t){if(!t)return;let e=t.querySelectorAll?t.querySelectorAll("img"):[];for(let a of e)try{let l=a.getAttribute("src")||a.currentSrc||"";if(zt(l)){let u=await Rt(l);a.setAttribute("src",u)}let c=a.getAttribute("srcset");if(c&&c.includes("blob:")){let u=Yn(c),f=!1;for(let m of u)if(zt(m.url))try{m.url=await Rt(m.url),f=!0}catch{}f&&a.setAttribute("srcset",Gn(u))}}catch{}let n=t.querySelectorAll?t.querySelectorAll("image"):[];for(let a of n)try{let i="http://www.w3.org/1999/xlink",l=a.getAttribute("href")||a.getAttributeNS?.(i,"href");if(zt(l)){let c=await Rt(l);a.setAttribute("href",c),a.removeAttributeNS?.(i,"href")}}catch{}let o=t.querySelectorAll?t.querySelectorAll("[style*='blob:']"):[];for(let a of o)try{let i=a.getAttribute("style");if(i&&i.includes("blob:")){let l=await Ue(i);a.setAttribute("style",l)}}catch{}let r=t.querySelectorAll?t.querySelectorAll("style"):[];for(let a of r)try{let i=a.textContent||"";i.includes("blob:")&&(a.textContent=await Ue(i))}catch{}let s=["poster"];for(let a of s){let i=t.querySelectorAll?t.querySelectorAll(`[${a}^='blob:']`):[];for(let l of i)try{let c=l.getAttribute(a);zt(c)&&l.setAttribute(a,await Rt(c))}catch{}}}async function Oe(t,e={}){let n=Array.from(t.querySelectorAll("img")),o=async r=>{if(!r.getAttribute("src")){let u=r.currentSrc||r.src||"";u&&r.setAttribute("src",u)}r.removeAttribute("srcset"),r.removeAttribute("sizes");let s=r.src||"";if(!s)return;let a=await V(s,{as:"dataURL",useProxy:e.useProxy});if(a.ok&&typeof a.data=="string"&&a.data.startsWith("data:")){r.src=a.data,r.width||(r.width=r.naturalWidth||100),r.height||(r.height=r.naturalHeight||100);return}let{fallbackURL:i}=e||{};if(i)try{let u=parseInt(r.dataset?.snapdomWidth||"",10)||0,f=parseInt(r.dataset?.snapdomHeight||"",10)||0,m=parseInt(r.getAttribute("width")||"",10)||0,A=parseInt(r.getAttribute("height")||"",10)||0,S=parseFloat(r.style?.width||"")||0,x=parseFloat(r.style?.height||"")||0,g=u||S||m||r.width||void 0,k=f||x||A||r.height||void 0,C=typeof i=="function"?await i({width:g,height:k,src:s,element:r}):i;if(C){let F=await V(C,{as:"dataURL",useProxy:e.useProxy});r.src=F.data,!r.width&&g&&(r.width=g),!r.height&&k&&(r.height=k),r.width||(r.width=r.naturalWidth||100),r.height||(r.height=r.naturalHeight||100);return}}catch{}let l=r.width||r.naturalWidth||100,c=r.height||r.naturalHeight||100;if(e.placeholders!==!1){let u=document.createElement("div");u.style.cssText=[`width:${l}px`,`height:${c}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${c}px`,"color:#666","font-size:12px","overflow:hidden"].join(";"),u.textContent="img",r.replaceWith(u)}else{let u=document.createElement("div");u.style.cssText=`display:inline-block;width:${l}px;height:${c}px;visibility:hidden;`,r.replaceWith(u)}};for(let r=0;r<n.length;r+=4){let s=n.slice(r,r+4).map(o);await Promise.allSettled(s)}}async function Xt(t,e,n,o={}){let r=[[t,e]],s=["background-image","mask","mask-image","-webkit-mask","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source"],a=["mask-position","mask-size","mask-repeat","-webkit-mask-position","-webkit-mask-size","-webkit-mask-repeat","mask-origin","mask-clip","-webkit-mask-origin","-webkit-mask-clip","-webkit-mask-position-x","-webkit-mask-position-y"],i=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;r.length;){let[l,c]=r.shift(),u=n.get(l)||yt(l);n.has(l)||n.set(l,u);let f=(()=>{let S=u.getPropertyValue("border-image"),x=u.getPropertyValue("border-image-source");return S&&S!=="none"||x&&x!=="none"})();for(let S of s){let x=u.getPropertyValue(S);if(!x||x==="none")continue;let g=wt(x),k=await Promise.all(g.map(C=>gt(C,o)));k.some(C=>C&&C!=="none"&&!/^url\(undefined/.test(C))&&c.style.setProperty(S,k.join(", "))}for(let S of a){let x=u.getPropertyValue(S);!x||x==="initial"||c.style.setProperty(S,x)}if(f)for(let S of i){let x=u.getPropertyValue(S);!x||x==="initial"||c.style.setProperty(S,x)}let m=Array.from(l.children),A=Array.from(c.children);for(let S=0;S<Math.min(m.length,A.length);S++)r.push([m[S],A[S]])}}function De(t){if(!t)return()=>{};let e=Jn(t);if(e<=0)return()=>{};if(!to(t))return()=>{};let n=getComputedStyle(t),o=Math.round(Qn(n)*e+Zn(n)),r=t.textContent??"",s=r;if(t.scrollHeight<=o+.5)return()=>{};let a=0,i=r.length,l=-1;for(;a<=i;){let c=a+i>>1;t.textContent=r.slice(0,c)+"\u2026",t.scrollHeight<=o+.5?(l=c,a=c+1):i=c-1}return t.textContent=(l>=0?r.slice(0,l):"")+"\u2026",()=>{t.textContent=s}}function Jn(t){let e=getComputedStyle(t),n=e.getPropertyValue("-webkit-line-clamp")||e.getPropertyValue("line-clamp");n=(n||"").trim();let o=parseInt(n,10);return Number.isFinite(o)&&o>0?o:0}function Qn(t){let e=(t.lineHeight||"").trim(),n=parseFloat(t.fontSize)||16;return!e||e==="normal"?Math.round(n*1.2):e.endsWith("px")?parseFloat(e):/^\d+(\.\d+)?$/.test(e)?Math.round(parseFloat(e)*n):e.endsWith("%")?Math.round(parseFloat(e)/100*n):Math.round(n*1.2)}function Zn(t){return(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)}function to(t){return t.childElementCount>0?!1:Array.from(t.childNodes).some(e=>e.nodeType===Node.TEXT_NODE)}async function pe(t,e){if(!t)throw new Error("Element cannot be null or undefined");_t(e.cache);let n=e.fast,o,r,s,a="",i="",l,c,u=De(t);try{({clone:o,classCSS:r,styleCache:s}=await Be(t,e))}finally{u()}await new Promise(S=>{st(async()=>{await Oe(o,e),S()},{fast:n})}),await new Promise(S=>{st(async()=>{await Xt(t,o,s,e),S()},{fast:n})}),e.embedFonts&&await new Promise(S=>{st(async()=>{let x=qt(t),g=jt(t);if(z()){let k=new Set(Array.from(x).map(C=>String(C).split("__")[0]).filter(Boolean));await Vt(k,2)}a=await Ht({required:x,usedCodepoints:g,preCached:!1,exclude:e.excludeFonts,useProxy:e.useProxy}),S()},{fast:n})});let f=oe(o).sort(),m=f.join(",");h.baseStyle.has(m)?i=h.baseStyle.get(m):await new Promise(S=>{st(()=>{i=re(f),h.baseStyle.set(m,i),S()},{fast:n})}),await new Promise(S=>{st(()=>{let x=getComputedStyle(t);function g(D){let T=`${D.filter||""} ${D.webkitFilter||""}`.trim();if(!T||T==="none")return{bleed:{top:0,right:0,bottom:0,left:0},has:!1};let U=T.match(/drop-shadow\((?:[^()]|\([^()]*\))*\)/gi)||[],G=0,K=0,Z=0,Y=0,ct=!1;for(let Ct of U){ct=!0;let dt=Ct.match(/-?\d+(?:\.\d+)?px/gi)?.map(lt=>parseFloat(lt))||[],[at=0,tt=0,mt=0]=dt,nt=Math.abs(at)+mt,ot=Math.abs(tt)+mt;K=Math.max(K,nt+Math.max(at,0)),Y=Math.max(Y,nt+Math.max(-at,0)),Z=Math.max(Z,ot+Math.max(tt,0)),G=Math.max(G,ot+Math.max(-tt,0))}return{bleed:{top:Math.ceil(G),right:Math.ceil(K),bottom:Math.ceil(Z),left:Math.ceil(Y)},has:ct}}function k(D){let T=D.boxShadow||"";if(!T||T==="none")return{top:0,right:0,bottom:0,left:0};let U=T.split(/\),(?=(?:[^()]*\([^()]*\))*[^()]*$)/).map(ct=>ct.trim()),G=0,K=0,Z=0,Y=0;for(let ct of U){let Ct=ct.match(/-?\d+(\.\d+)?px/g)?.map(lt=>parseFloat(lt))||[];if(Ct.length<2)continue;let[dt,at,tt=0,mt=0]=Ct,nt=Math.abs(dt)+tt+mt,ot=Math.abs(at)+tt+mt;K=Math.max(K,nt+Math.max(dt,0)),Y=Math.max(Y,nt+Math.max(-dt,0)),Z=Math.max(Z,ot+Math.max(at,0)),G=Math.max(G,ot+Math.max(-at,0))}return{top:Math.ceil(G),right:Math.ceil(K),bottom:Math.ceil(Z),left:Math.ceil(Y)}}function C(D){let T=(D.filter||"").match(/blur\(\s*([0-9.]+)px\s*\)/),U=T?Math.ceil(parseFloat(T[1])||0):0;return{top:U,right:U,bottom:U,left:U}}function F(D){if((D.outlineStyle||"none")==="none")return{top:0,right:0,bottom:0,left:0};let T=Math.ceil(parseFloat(D.outlineWidth||"0")||0);return{top:T,right:T,bottom:T,left:T}}function W(D,T,U,G,K){let Z=U.a,Y=U.b,ct=U.c,Ct=U.d,dt=U.e||0,at=U.f||0;function tt(kt,Mt){let be=kt-G,xe=Mt-K,Se=Z*be+ct*xe,Ce=Y*be+Ct*xe;return Se+=G+dt,Ce+=K+at,[Se,Ce]}let mt=[tt(0,0),tt(D,0),tt(0,T),tt(D,T)],nt=1/0,ot=1/0,lt=-1/0,Wt=-1/0;for(let[kt,Mt]of mt)kt<nt&&(nt=kt),Mt<ot&&(ot=Mt),kt>lt&&(lt=kt),Mt>Wt&&(Wt=Mt);return{minX:nt,minY:ot,maxX:lt,maxY:Wt,width:lt-nt,height:Wt-ot}}function X(D){return oo(D)}let O=t.getBoundingClientRect(),j=Math.max(1,Math.ceil(t.offsetWidth||parseFloat(x.width)||O.width||1)),d=Math.max(1,Math.ceil(t.offsetHeight||parseFloat(x.height)||O.height||1)),b=(D,T=NaN)=>{let U=typeof D=="string"?parseFloat(D):D;return Number.isFinite(U)?U:T},w=b(e.width),M=b(e.height),p=j,y=d,E=Number.isFinite(w),v=Number.isFinite(M),$=d>0?j/d:1;E&&v?(p=Math.max(1,Math.ceil(w)),y=Math.max(1,Math.ceil(M))):E?(p=Math.max(1,Math.ceil(w)),y=Math.max(1,Math.ceil(p/($||1)))):v?(y=Math.max(1,Math.ceil(M)),p=Math.max(1,Math.ceil(y*($||1)))):(p=j,y=d);let N=0,_=0,H=j,I=d;if(X(t)){let D=x.transform&&x.transform!=="none"?x.transform:"",T=no(t),U=so({baseTransform:D,rotate:T.rotate||"0deg",scale:T.scale,translate:T.translate}),{ox:G,oy:K}=ro(x,j,d),Z=U.is2D?U:new DOMMatrix(U.toString()),Y=W(j,d,Z,G,K);N=Y.minX,_=Y.minY,H=Y.maxX,I=Y.maxY}let L=k(x),R=C(x),P=F(x),q=g(x),it={top:L.top+R.top+P.top+q.bleed.top,right:L.right+R.right+P.right+q.bleed.right,bottom:L.bottom+R.bottom+P.bottom+q.bleed.bottom,left:L.left+R.left+P.left+q.bleed.left};N-=it.left,_-=it.top,H+=it.right,I+=it.bottom;let rt=Math.max(1,Math.ceil(H-N)),It=Math.max(1,Math.ceil(I-_)),xt=Math.max(1,Math.round(rt*(E||v?p/j:1))),Kt=Math.max(1,Math.round(It*(v||E?y/d:1))),Tt="http://www.w3.org/2000/svg",J=z()?1:0,Q=document.createElementNS(Tt,"foreignObject"),Xe=Math.floor(N),Ye=Math.floor(_);Q.setAttribute("x",String(-(Xe-J))),Q.setAttribute("y",String(-(Ye-J))),Q.setAttribute("width",String(Math.ceil(j+J*2))),Q.setAttribute("height",String(Math.ceil(d+J*2))),Q.style.overflow="visible";let ye=document.createElement("style");ye.textContent=i+a+"svg{overflow:visible;} foreignObject{overflow:visible;}"+r,Q.appendChild(ye);let St=document.createElement("div");St.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),St.style.width=`${j}px`,St.style.height=`${d}px`,St.style.overflow="visible",o.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),St.appendChild(o),Q.appendChild(St);let Ge=new XMLSerializer().serializeToString(Q),Jt=rt+J*2,Qt=It+J*2,we=E||v;e.meta={w0:j,h0:d,vbW:Jt,vbH:Qt,targetW:p,targetH:y};let Ke=z()&&we?Jt:xt+J*2,Je=z()&&we?Qt:Kt+J*2;c=`<svg xmlns="${Tt}" width="${Ke}" height="${Je}" viewBox="0 0 ${Jt} ${Qt}">`+Ge+"</svg>",l=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(c)}`,S()},{fast:n})});let A=document.getElementById("snapdom-sandbox");return A&&A.style.position==="absolute"&&A.remove(),l}function eo(t){let e=getComputedStyle(t).transform;if(!e||e==="none")return new DOMMatrix;try{return new DOMMatrix(e)}catch{return new WebKitCSSMatrix(e)}}function no(t){let e={rotate:"0deg",scale:null,translate:null},n=typeof t.computedStyleMap=="function"?t.computedStyleMap():null;if(n){let r=l=>{try{return typeof n.has=="function"&&!n.has(l)||typeof n.get!="function"?null:n.get(l)}catch{return null}},s=r("rotate");if(s)if(s.angle){let l=s.angle;e.rotate=l.unit==="rad"?l.value*180/Math.PI+"deg":l.value+l.unit}else s.unit?e.rotate=s.unit==="rad"?s.value*180/Math.PI+"deg":s.value+s.unit:e.rotate=String(s);else{let l=getComputedStyle(t);e.rotate=l.rotate&&l.rotate!=="none"?l.rotate:"0deg"}let a=r("scale");if(a){let l="x"in a&&a.x?.value!=null?a.x.value:Array.isArray(a)?a[0]?.value:Number(a)||1,c="y"in a&&a.y?.value!=null?a.y.value:Array.isArray(a)?a[1]?.value:l;e.scale=`${l} ${c}`}else{let l=getComputedStyle(t);e.scale=l.scale&&l.scale!=="none"?l.scale:null}let i=r("translate");if(i){let l="x"in i&&"value"in i.x?i.x.value:Array.isArray(i)?i[0]?.value:0,c="y"in i&&"value"in i.y?i.y.value:Array.isArray(i)?i[1]?.value:0,u="x"in i&&i.x?.unit?i.x.unit:"px",f="y"in i&&i.y?.unit?i.y.unit:"px";e.translate=`${l}${u} ${c}${f}`}else{let l=getComputedStyle(t);e.translate=l.translate&&l.translate!=="none"?l.translate:null}return e}let o=getComputedStyle(t);return e.rotate=o.rotate&&o.rotate!=="none"?o.rotate:"0deg",e.scale=o.scale&&o.scale!=="none"?o.scale:null,e.translate=o.translate&&o.translate!=="none"?o.translate:null,e}function oo(t){let e=getComputedStyle(t),n=e.transform||"none";if(n!=="none"&&!/^matrix\(\s*1\s*,\s*0\s*,\s*0\s*,\s*1\s*,\s*0\s*,\s*0\s*\)$/i.test(n))return!0;let r=e.rotate&&e.rotate!=="none"&&e.rotate!=="0deg",s=e.scale&&e.scale!=="none"&&e.scale!=="1",a=e.translate&&e.translate!=="none"&&e.translate!=="0px 0px";return!!(r||s||a)}function ro(t,e,n){let o=(t.transformOrigin||"0 0").trim().split(/\s+/),[r,s]=[o[0]||"0",o[1]||"0"],a=(i,l)=>{let c=i.toLowerCase();return c==="left"||c==="top"?0:c==="center"?l/2:c==="right"||c==="bottom"?l:c.endsWith("px")?parseFloat(c)||0:c.endsWith("%")?(parseFloat(c)||0)*l/100:/^-?\d+(\.\d+)?$/.test(c)&&parseFloat(c)||0};return{ox:a(r,e),oy:a(s,n)}}var he=null;function ao(){if(he)return he;let t=document.createElement("div");return t.id="snapdom-measure-slot",t.setAttribute("aria-hidden","true"),Object.assign(t.style,{position:"absolute",left:"-99999px",top:"0px",width:"0px",height:"0px",overflow:"hidden",opacity:"0",pointerEvents:"none",contain:"size layout style"}),document.documentElement.appendChild(t),he=t,t}function so(t){let e=ao(),n=document.createElement("div");n.style.transformOrigin="0 0",t.baseTransform&&(n.style.transform=t.baseTransform),t.rotate&&(n.style.rotate=t.rotate),t.scale&&(n.style.scale=t.scale),t.translate&&(n.style.translate=t.translate),e.appendChild(n);let o=eo(n);return e.removeChild(n),o}function io(t){if(typeof t=="string"){let e=t.toLowerCase().trim();if(e==="disabled"||e==="full"||e==="auto"||e==="soft")return e}return"soft"}function He(t={}){let e=t.format??"png",n=io(t.cache);return{debug:t.debug??!1,fast:t.fast??!0,scale:t.scale??1,exclude:t.exclude??[],excludeMode:t.excludeMode??"hide",filter:t.filter??null,filterMode:t.filterMode??"hide",placeholders:t.placeholders!==!1,embedFonts:t.embedFonts??!1,iconFonts:Array.isArray(t.iconFonts)?t.iconFonts:t.iconFonts?[t.iconFonts]:[],localFonts:Array.isArray(t.localFonts)?t.localFonts:[],excludeFonts:t.excludeFonts??void 0,fallbackURL:t.fallbackURL??void 0,cache:n,useProxy:typeof t.useProxy=="string"?t.useProxy:"",width:t.width??null,height:t.height??null,format:e,type:t.type??"svg",quality:t.quality??.92,dpr:t.dpr??(window.devicePixelRatio||1),backgroundColor:t.backgroundColor??(["jpg","jpeg","webp"].includes(e)?"#ffffff":null),filename:t.filename??"snapDOM"}}function co(t){return typeof t=="string"&&/^data:image\/svg\+xml/i.test(t)}function lo(t){let e=t.indexOf(",");return e>=0?decodeURIComponent(t.slice(e+1)):""}function uo(t){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}function fo(t){let e=[],n="",o=0;for(let r=0;r<t.length;r++){let s=t[r];s==="("&&o++,s===")"&&(o=Math.max(0,o-1)),s===";"&&o===0?(e.push(n),n=""):n+=s}return n.trim()&&e.push(n),e.map(r=>r.trim()).filter(Boolean)}function mo(t){let e=[],n="",o=0;for(let s=0;s<t.length;s++){let a=t[s];a==="("&&o++,a===")"&&(o=Math.max(0,o-1)),a===","&&o===0?(e.push(n.trim()),n=""):n+=a}n.trim()&&e.push(n.trim());let r=[];for(let s of e){if(/\binset\b/i.test(s))continue;let a=s.match(/-?\d+(?:\.\d+)?px/gi)||[],[i="0px",l="0px",c="0px"]=a,u=s.replace(/-?\d+(?:\.\d+)?px/gi,"").replace(/\binset\b/ig,"").trim().replace(/\s{2,}/g," "),f=!!u&&u!==",";r.push(`drop-shadow(${i} ${l} ${c}${f?` ${u}`:""})`)}return r.join(" ")}function qe(t){let e=fo(t),n=null,o=null,r=null,s=[];for(let i of e){let l=i.indexOf(":");if(l<0)continue;let c=i.slice(0,l).trim().toLowerCase(),u=i.slice(l+1).trim();c==="box-shadow"?r=u:c==="filter"?n=u:c==="-webkit-filter"?o=u:s.push([c,u])}if(r){let i=mo(r);i&&(n=n?`${n} ${i}`:i,o=o?`${o} ${i}`:i)}let a=[...s];return n&&a.push(["filter",n]),o&&a.push(["-webkit-filter",o]),a.map(([i,l])=>`${i}:${l}`).join(";")}function ho(t){return t.replace(/([^{}]+)\{([^}]*)\}/g,(e,n,o)=>`${n}{${qe(o)}}`)}function po(t){return t=t.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi,(e,n)=>e.replace(n,ho(n))),t=t.replace(/style=(['"])([\s\S]*?)\1/gi,(e,n,o)=>`style=${n}${qe(o)}${n}`),t}function go(t){if(!z()||!co(t))return t;try{let e=lo(t),n=po(e);return uo(n)}catch{return t}}async function ft(t,e){let{width:n,height:o,scale:r=1,dpr:s=1,meta:a={}}=e;t=go(t);let i=new Image;i.loading="eager",i.decoding="sync",i.crossOrigin="anonymous",i.src=t,await i.decode();let l=i.naturalWidth,c=i.naturalHeight,u=Number.isFinite(a.w0)?a.w0:l,f=Number.isFinite(a.h0)?a.h0:c,m,A,S=Number.isFinite(n),x=Number.isFinite(o);if(S&&x)m=Math.max(1,n),A=Math.max(1,o);else if(S){let C=n/Math.max(1,u);m=n,A=Math.round(f*C)}else if(x){let C=o/Math.max(1,f);A=o,m=Math.round(u*C)}else m=l,A=c;m=Math.round(m*r),A=Math.round(A*r);let g=document.createElement("canvas");g.width=Math.ceil(m*s),g.height=Math.ceil(A*s),g.style.width=`${m}px`,g.style.height=`${A}px`;let k=g.getContext("2d");return s!==1&&k.scale(s,s),k.drawImage(i,0,0,m,A),g}async function Yt(t,e){let n=await ft(t,e),o=e.backgroundColor?pt(n,e.backgroundColor):n,r=new Image;return r.src=o.toDataURL(`image/${e.format}`,e.quality),await r.decode(),r.style.width=`${o.width/e.dpr}px`,r.style.height=`${o.height/e.dpr}px`,r}async function je(t,e){let{scale:n=1,width:o,height:r,meta:s={}}=e,a=Number.isFinite(o),i=Number.isFinite(r),l=Number.isFinite(n)&&n!==1||a||i;if(z()&&l)return await Yt(t,{...e,format:"png",quality:1,meta:s});let c=new Image;if(c.decoding="sync",c.loading="eager",c.src=t,await c.decode(),a&&i)c.style.width=`${o}px`,c.style.height=`${r}px`;else if(a){let u=Number.isFinite(s.w0)?s.w0:c.naturalWidth,f=Number.isFinite(s.h0)?s.h0:c.naturalHeight,m=o/Math.max(1,u);c.style.width=`${o}px`,c.style.height=`${Math.round(f*m)}px`}else if(i){let u=Number.isFinite(s.w0)?s.w0:c.naturalWidth,f=Number.isFinite(s.h0)?s.h0:c.naturalHeight,m=r/Math.max(1,f);c.style.height=`${r}px`,c.style.width=`${Math.round(u*m)}px`}else n!==1&&(c.style.width=`${Math.round(c.naturalWidth*n)}px`,c.style.height=`${Math.round(c.naturalHeight*n)}px`);return c}async function Gt(t,e){let n=e.type;if(n==="svg"){let s=decodeURIComponent(t.split(",")[1]);return new Blob([s],{type:"image/svg+xml"})}let o=await ft(t,e),r=e.backgroundColor?pt(o,e.backgroundColor):o;return new Promise(s=>r.toBlob(a=>s(a),`image/${n}`,e.quality))}async function Ve(t,e){if(e.dpr=1,e.format==="svg"){let s=await Gt(t,{...e,type:"svg"}),a=URL.createObjectURL(s),i=document.createElement("a");i.href=a,i.download=e.filename,i.click(),URL.revokeObjectURL(a);return}let n=await ft(t,e),o=e.backgroundColor?pt(n,e.backgroundColor):n,r=document.createElement("a");r.href=o.toDataURL(`image/${e.format}`,e.quality),r.download=e.filename,r.click()}var ze=Symbol("snapdom.internal"),ge=!1;async function B(t,e){if(!t)throw new Error("Element cannot be null or undefined");let n=He(e);if(z()&&(n.embedFonts===!0||wo(t)))for(let o=0;o<3;o++)try{await yo(t,e),console.log("Iteraci\xF3n n\xFAmero:",o),ge=!1}catch{}return n.iconFonts&&n.iconFonts.length>0&&ve(n.iconFonts),n.snap||(n.snap={toPng:(o,r)=>B.toPng(o,r),toImg:(o,r)=>B.toImg(o,r)}),B.capture(t,n,ze)}B.capture=async(t,e,n)=>{if(n!==ze)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");let o=await pe(t,e),r=a=>({...e,...a||{}}),s=a=>i=>{let l=r({...i||{},format:a}),c=a==="jpeg"||a==="jpg",u=l.backgroundColor==null||l.backgroundColor==="transparent";return c&&u&&(l.backgroundColor="#ffffff"),Yt(o,l)};return{url:o,toRaw:()=>o,toImg:a=>je(o,r(a)),toCanvas:a=>ft(o,r(a)),toBlob:a=>Gt(o,r(a)),toPng:s("png"),toJpg:s("jpeg"),toWebp:s("webp"),download:a=>Ve(o,r(a))}};B.toRaw=(t,e)=>B(t,e).then(n=>n.toRaw());B.toImg=(t,e)=>B(t,e).then(n=>n.toImg());B.toCanvas=(t,e)=>B(t,e).then(n=>n.toCanvas());B.toBlob=(t,e)=>B(t,e).then(n=>n.toBlob());B.toPng=(t,e)=>B(t,{...e,format:"png"}).then(n=>n.toPng());B.toJpg=(t,e)=>B(t,{...e,format:"jpeg"}).then(n=>n.toJpg());B.toWebp=(t,e)=>B(t,{...e,format:"webp"}).then(n=>n.toWebp());B.download=(t,e)=>B(t,e).then(n=>n.download());async function yo(t,e){if(ge)return;let n={...e,fast:!0,embedFonts:!0,scale:.2},o;try{o=await pe(t,n)}catch{return}await new Promise(r=>{let s=new Image;s.decoding="sync",s.loading="eager",s.style.position="fixed",s.style.left=0,s.style.top=0,s.style.width="10px",s.style.height="10px",s.style.opacity="0.01",s.style.transform="translateZ(10px)",s.style.willChange="transform,opacity;",s.src=o;let a=async()=>{await new Promise(i=>setTimeout(i,100)),s&&s.parentNode&&s.parentNode.removeChild(s),ge=!0,r()};document.body.appendChild(s),a()})}function wo(t){let e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){let n=e.currentNode,o=getComputedStyle(n),r=o.backgroundImage&&o.backgroundImage!=="none",s=o.maskImage&&o.maskImage!=="none"||o.webkitMaskImage&&o.webkitMaskImage!=="none";if(r||s)return!0}return!1}async function bo(t=document,e={}){let{embedFonts:n=!0,useProxy:o=""}=e,r=e.cache??e.cacheOpt??"full";_t(r);try{await document.fonts?.ready}catch{}try{ee()}catch{}h.session=h.session||{},h.session.styleCache||(h.session.styleCache=new WeakMap),h.image=h.image||new Map;try{await Xt(t,void 0,h.session.styleCache,{useProxy:o})}catch{}let s=[],a=[];try{t?.querySelectorAll&&(s=Array.from(t.querySelectorAll("img[src]")),a=Array.from(t.querySelectorAll("*")))}catch{}let i=[];for(let l of s){let c=l?.currentSrc||l?.src;if(c&&!h.image.has(c)){let u=Promise.resolve().then(async()=>{let f=await V(c,{as:"dataURL",useProxy:o});f?.ok&&typeof f.data=="string"&&h.image.set(c,f.data)}).catch(()=>{});i.push(u)}}for(let l of a){let c="";try{c=yt(l).backgroundImage}catch{}if(c&&c!=="none"){let u=wt(c);for(let f of u)if(f.startsWith("url(")){let m=Promise.resolve().then(()=>gt(f,{...e,useProxy:o})).catch(()=>{});i.push(m)}}}if(n)try{let l=qt(t),c=jt(t);if(typeof z=="function"?z():!!z){let f=new Set(Array.from(l).map(m=>String(m).split("__")[0]).filter(Boolean));await Vt(f,2)}await Ht({required:l,usedCodepoints:c,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??o})}catch{}await Promise.allSettled(i)}export{bo as preCache,B as snapdom};
|