@zumer/snapdom 1.9.12-dev.2 → 1.9.12-dev.4
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 +664 -185
- package/dist/snapdom.min.js +5 -5
- package/dist/snapdom.min.mjs +5 -5
- package/dist/snapdom.mjs +658 -181
- package/package.json +1 -1
- package/types/snapdom.d.ts +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(a=>a.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(a=>a.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 tn(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,r=0;function a(s,l,c){if(r>=n)return;let i=Date.now();(o.get(l)||0)>i||(o.set(l,i+e),r++,s==="warn"&&console&&console.warn?console.warn(`${t} ${c}`):console&&console.error&&console.error(`${t} ${c}`))}return{warnOnce(s,l){a("warn",s,l)},errorOnce(s,l){a("error",s,l)},reset(){o.clear(),r=0}}}var ke=tn("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),te=new Map,Pt=new Map;function en(t){return/^data:|^blob:|^about:blank$/i.test(t)}function nn(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),a=new URL(t,n);if(a.origin===r.origin)return!0;let s=a.searchParams;if(s&&(s.has("url")||s.has("target")))return!0}catch{}return!1}function on(t,e){if(!e||en(t)||nn(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 rn(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 sn(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||"",a=e.errorTTL??8e3,s=e.headers||{},l=!!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[,p="",M=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],E=/;base64/i.test(p)?atob(M):decodeURIComponent(M),W=new Uint8Array([...E].map(B=>B.charCodeAt(0))),z=new Blob([W],{type:(p||"").split(";")[0]||""});return{ok:!0,data:z,status:200,url:t,fromCache:!1,mime:z.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let p=await fetch(t);if(!p.ok)return{ok:!1,data:null,status:p.status,url:t,fromCache:!1,reason:"http_error"};let M=await p.blob(),k=M.type||p.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await Me(M),status:p.status,url:t,fromCache:!1,mime:k}:n==="text"?{ok:!0,data:await M.text(),status:p.status,url:t,fromCache:!1,mime:k}:{ok:!0,data:M,status:p.status,url:t,fromCache:!1,mime:k}}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 c=sn(t,{as:n,timeout:o,useProxy:r,errorTTL:a}),i=Pt.get(c);if(i&&i.until>Date.now())return{...i.result,fromCache:!0};i&&Pt.delete(c);let u=te.get(c);if(u)return u;let f=on(t,r)?rn(t,r):t,m=e.credentials;if(!m)try{let p=typeof location<"u"&&location.href?location.href:"http://localhost/",M=new URL(t,p);m=typeof location<"u"&&M.origin===location.origin?"include":"omit"}catch{m="omit"}let x=new AbortController,C=setTimeout(()=>x.abort("timeout"),o),S=(async()=>{try{let p=await fetch(f,{signal:x.signal,credentials:m,headers:s});if(!p.ok){let E={ok:!1,data:null,status:p.status,url:f,fromCache:!1,reason:"http_error"};if(a>0&&Pt.set(c,{until:Date.now()+a,result:E}),!l){let W=`${p.status} ${p.statusText||""}`.trim();ke.warnOnce(`http:${p.status}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${W} while fetching ${n} ${t}`)}return e.onError&&e.onError(E),E}if(n==="text")return{ok:!0,data:await p.text(),status:p.status,url:f,fromCache:!1};let M=await p.blob(),k=M.type||p.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await Me(M),status:p.status,url:f,fromCache:!1,mime:k}:{ok:!0,data:M,status:p.status,url:f,fromCache:!1,mime:k}}catch(p){let M=p&&typeof p=="object"&&"name"in p&&p.name==="AbortError"?String(p.message||"").includes("timeout")?"timeout":"abort":"network",k={ok:!1,data:null,status:0,url:f,fromCache:!1,reason:M};if(!/^blob:/i.test(t)&&a>0&&Pt.set(c,{until:Date.now()+a,result:k}),!l){let E=`${M}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,W=M==="timeout"?`Timeout after ${o}ms. Consider increasing timeout or using a proxy for ${t}`:M==="abort"?`Request aborted while fetching ${n} ${t}`:`Network/CORS issue while fetching ${n} ${t}. A proxy may be required`;ke.errorOnce(E,W)}return e.onError&&e.onError(k),k}finally{clearTimeout(C),te.delete(c)}})();return te.set(c,S),S}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 a=h.background.get(r);return a?`url("${a}")`:"none"}try{let a=await V(r,{as:"dataURL",useProxy:e.useProxy});return a.ok?(h.background.set(r,a.data),`url("${a.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"]),an=["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 an){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 a={};return h.defaultStyle.set(t,a),a}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 a of o){if(Ae(a))continue;let s=o.getPropertyValue(a);r[a]=s}return e.removeChild(n),h.defaultStyle.set(t,r),r}var cn=/(?:^|-)(animation|transition)(?:-|$)/i,ln=/^(--|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,un=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!!(un.has(e)||ln.test(e)||cn.test(e))}function $t(t,e){if(e=String(e||"").toLowerCase(),At.has(e))return"";let n=[],o=ne(e);for(let[r,a]of Object.entries(t)){if(Ae(r))continue;let s=o[r];a&&a!==s&&n.push(`${r}:${a}`)}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 a=Object.entries(r).map(([s,l])=>`${s}:${l};`).sort().join("");a&&(e.has(a)||e.set(a,[]),e.get(a).push(o))}let n="";for(let[o,r]of e.entries())n+=`${r.join(",")} { ${o} }
|
|
2
|
+
`;return n}function se(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 a=t[r];a==="("&&n++,a===")"&&n--,a===","&&n===0&&(e.push(t.slice(o,r).trim()),o=r+1)}return e.push(t.slice(o).trim()),e}function at(t,{fast:e=!1}={}){if(e)return t();"requestIdleCallback"in window?requestIdleCallback(t,{timeout:50}):setTimeout(t,1)}function X(){let t=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"",e=/^((?!chrome|android).)*safari/i.test(t),n=/AppleWebKit/i.test(t)&&/Mobile/i.test(t)&&!/Safari/i.test(t),o=/(MicroMessenger|wxwork|WeCom|WindowsWechat|MacWechat)/i.test(t);return e||n||o}var $e=new WeakMap,ae=new Map,ie=0;function Et(){ie++}var Ee=!1;function fn(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 dn(t,e={}){let n={},o=t.getPropertyValue("visibility");for(let r=0;r<t.length;r++){let a=t[r],s=t.getPropertyValue(a);(a==="background-image"||a==="content")&&s.includes("url(")&&!s.includes("data:")&&(s="none"),n[a]=s}if(e.embedFonts){let r=["font-feature-settings","font-variation-settings","font-kerning","font-variant","font-variant-ligatures","font-optical-sizing"];for(let a of r)if(!n[a])try{let s=t.getPropertyValue(a);s&&(n[a]=s)}catch{}}return o==="hidden"&&(n.opacity="0"),n}var Fe=new WeakMap;function mn(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 hn(t,e=null,n={}){let o=$e.get(t);if(o&&o.epoch===ie)return o.snapshot;let r=e||getComputedStyle(t),a=dn(r,n);return xn(t,r,a),$e.set(t,{epoch:ie,snapshot:a}),a}function pn(t,e){return t&&t.session&&t.persist?t:t&&(t.styleMap||t.styleCache||t.nodeMap)?{session:t,persist:{snapshotKeyCache:ae,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:ae,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=pn(n,o),a=r.options&&r.options.cache||"auto";if(a!=="disabled"&&fn(document.documentElement),a==="disabled"&&!r.session.__bumpedForDisabled&&(Et(),ae.clear(),r.session.__bumpedForDisabled=!0),At.has(t.tagName?.toLowerCase())){let m=t.getAttribute?.("style");m&&e.setAttribute("style",m)}let{session:s,persist:l}=r;s.styleCache.has(t)||s.styleCache.set(t,getComputedStyle(t));let c=s.styleCache.get(t),i=hn(t,c,r.options),u=mn(i),f=l.snapshotKeyCache.get(u);if(!f){let m=t.tagName?.toLowerCase()||"div";f=$t(i,m),l.snapshotKeyCache.set(u,f)}s.styleMap.set(e,f)}function gn(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof HTMLIFrameElement||t instanceof SVGElement||t instanceof HTMLObjectElement||t instanceof HTMLEmbedElement}function yn(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 wn(t){let e=t.parentElement;if(!e)return!1;let n=getComputedStyle(e).display||"";return n.includes("flex")||n.includes("grid")}function bn(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 a=parseFloat(e.paddingTop)||0,s=parseFloat(e.paddingBottom)||0;return r>a+s}function xn(t,e,n){if(t instanceof HTMLElement&&t.style&&t.style.height)return;let o=e.display||"";if(o.includes("flex")||o.includes("grid")||gn(t))return;let r=e.position;r==="absolute"||r==="fixed"||r==="sticky"||e.transform==="none"&&(yn(e)||wn(t)||bn(t,e)&&(delete n.height,delete n["block-size"]))}function ce(t,e,n){return Promise.all(t.map(o=>new Promise(r=>{function a(){at(s=>{(s&&typeof s.timeRemaining=="function"?s.timeRemaining()>0:!0)?e(o,r):a()},{fast:n})}a()})))}function Sn(t){return t=t.trim(),!t||/\:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(t)?t:`${t}:not([data-sd-slotted])`}function Cn(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?Sn(o):o;return`:where(${e} ${r})`}).join(", ")}function kn(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,a)=>{let s=Cn(a,e,!0);return`${o}${r}${s}{`}),t):""}function Mn(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}function An(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 $n(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 En(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 Fn(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 vn(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 Nn(t,e,n){let o=[];for(let r of e){let a=vn(t,r);a&&o.push(`${r}: ${a};`)}return o.length?`${n}{${o.join("")}}
|
|
5
|
+
`:""}function Ln(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 Rn(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(a=>setTimeout(a,0)),o=n(),r++;return o&&(o.body||o.documentElement)?o:null}function In(t){let e=t.getBoundingClientRect(),n=0,o=0,r=0,a=0;try{let c=getComputedStyle(t);n=parseFloat(c.borderLeftWidth)||0,o=parseFloat(c.borderRightWidth)||0,r=parseFloat(c.borderTopWidth)||0,a=parseFloat(c.borderBottomWidth)||0}catch{}let s=Math.max(0,Math.round(e.width-(n+o))),l=Math.max(0,Math.round(e.height-(r+a)));return{contentWidth:s,contentHeight:l,rect:e}}function Tn(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 Wn(t,e,n){let o=await Rn(t,3);if(!o)throw new Error("iframe document not accessible/ready");let{contentWidth:r,contentHeight:a,rect:s}=In(t),l=n?.snap;if(!l||typeof l.toPng!="function")throw new Error("snapdom.toPng not available in iframe or window");let c={...n,scale:1},i=Tn(o,r,a),u;try{u=await l.toPng(o.documentElement,c)}finally{i()}u.style.display="block",u.style.width=`${r}px`,u.style.height=`${a}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(s.width)}px`),f.style.height||(f.style.height=`${Math.round(s.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,a=null;if(t.nodeType===Node.ELEMENT_NODE){let i=(t.localName||t.tagName||"").toLowerCase();if(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox")||Ut.has(i))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 i=document.createElement("div"),u=t.getBoundingClientRect();return i.style.cssText=`display:inline-block;width:${u.width}px;height:${u.height}px;visibility:hidden;`,i}else if(n.excludeMode==="remove")return null}if(n.exclude&&Array.isArray(n.exclude))for(let i of n.exclude)try{if(t.matches?.(i)){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: ${i}`,u)}if(typeof n.filter=="function")try{if(!n.filter(t)){if(n.filterMode==="hide"){let i=document.createElement("div"),u=t.getBoundingClientRect();return i.style.cssText=`display:inline-block;width:${u.width}px;height:${u.height}px;visibility:hidden;`,i}else if(n.filterMode==="remove")return null}}catch(i){console.warn("Error in filter function:",i)}if(t.tagName==="IFRAME"){let i=!1;try{i=!!(t.contentDocument||t.contentWindow?.document)}catch{i=!1}if(i)try{return await Wn(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 i=t.cloneNode(!1);e.nodeMap.set(i,t),bt(t,i,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;",i.appendChild(u),i}if(t.tagName==="CANVAS"){let i=t.toDataURL(),u=document.createElement("img");return u.src=i,u.width=t.width,u.height=t.height,e.nodeMap.set(u,t),bt(t,u,e,n),u}let s;try{if(s=t.cloneNode(!1),e.nodeMap.set(s,t),t.tagName==="IMG"){En(t,s);try{let i=t.getBoundingClientRect(),u=Math.round(i.width||0),f=Math.round(i.height||0);if(!u||!f){let m=window.getComputedStyle(t),x=parseFloat(m.width)||0,C=parseFloat(m.height)||0,S=parseInt(t.getAttribute("width")||"",10)||0,p=parseInt(t.getAttribute("height")||"",10)||0,M=t.width||t.naturalWidth||0,k=t.height||t.naturalHeight||0;u=Math.round(u||x||S||M||0),f=Math.round(f||C||p||k||0)}u&&(s.dataset.snapdomWidth=String(u)),f&&(s.dataset.snapdomHeight=String(f))}catch{}}}catch(i){throw console.error("[Snapdom] Failed to clone node:",t,i),i}if(t instanceof HTMLTextAreaElement){let i=t.getBoundingClientRect();s.style.width=`${i.width}px`,s.style.height=`${i.height}px`}if(t instanceof HTMLInputElement&&(s.value=t.value,s.setAttribute("value",t.value),t.checked!==void 0&&(s.checked=t.checked,t.checked&&s.setAttribute("checked",""),t.indeterminate&&(s.indeterminate=t.indeterminate))),t instanceof HTMLSelectElement&&(r=t.value),t instanceof HTMLTextAreaElement&&(a=t.value),bt(t,s,e,n),t.shadowRoot){let p=function(k,E){if(k.nodeType===Node.ELEMENT_NODE&&k.tagName==="STYLE")return E(null);Ft(k,e,n).then(W=>{E(W||null)}).catch(W=>{E(null)})};try{let k=t.shadowRoot.querySelectorAll("slot");for(let E of k){let W=[];try{W=E.assignedNodes?.({flatten:!0})||E.assignedNodes?.()||[]}catch{W=E.assignedNodes?.()||[]}for(let z of W)o.add(z)}}catch{}let i=Mn(e),u=`[data-sd="${i}"]`;try{s.setAttribute("data-sd",i)}catch{}let f=An(t.shadowRoot),m=kn(f,u),x=Fn(f),C=Nn(t,x,u);$n(s,C+m,i);let S=document.createDocumentFragment(),M=await ce(Array.from(t.shadowRoot.childNodes),p,n.fast);S.append(...M.filter(k=>!!k)),s.appendChild(S)}if(t.tagName==="SLOT"){let m=function(C,S){Ft(C,e,n).then(p=>{p&&Ln(p),S(p||null)}).catch(p=>{S(null)})},i=t.assignedNodes?.({flatten:!0})||[],u=i.length>0?i:Array.from(t.childNodes),f=document.createDocumentFragment(),x=await ce(Array.from(u),m,n.fast);return f.append(...x.filter(C=>!!C)),f}function l(i,u){if(o.has(i))return u(null);Ft(i,e,n).then(f=>{u(f||null)}).catch(f=>{u(null)})}let c=await ce(Array.from(t.childNodes),l,n.fast);if(s.append(...c.filter(i=>!!i)),r!==null&&s instanceof HTMLSelectElement){s.value=r;for(let i of s.options)i.value===r?i.setAttribute("selected",""):i.removeAttribute("selected")}return a!==null&&s instanceof HTMLTextAreaElement&&(s.textContent=a),s}var _n=[/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=[..._n,...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 Ne(t,e,n,o=32,r="#000"){e=e.replace(/^['"]+|['"]+$/g,"");let a=window.devicePixelRatio||1;await document.fonts.ready;let s=document.createElement("span");s.textContent=t,s.style.position="absolute",s.style.visibility="hidden",s.style.fontFamily=`"${e}"`,s.style.fontWeight=n||"normal",s.style.fontSize=`${o}px`,s.style.lineHeight="1",s.style.whiteSpace="nowrap",s.style.padding="0",s.style.margin="0",document.body.appendChild(s);let l=s.getBoundingClientRect(),c=Math.ceil(l.width),i=Math.ceil(l.height);document.body.removeChild(s);let u=document.createElement("canvas");u.width=c*a,u.height=i*a;let f=u.getContext("2d");return f.scale(a,a),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:c,height:i}}var Pn=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&&!Pn.has(n.toLowerCase()))return n}return""}function Ht(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 Un(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function Bn(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let r=Ht(n[1]),a=Ht(n[2]);return{min:Math.min(r,a),max:Math.max(r,a)}}let o=Ht(e);return{min:o,max:o}}function On(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function Hn(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let a=parseFloat(n[1]),s=parseFloat(n[2]);return{min:Math.min(a,s),max:Math.max(a,s)}}let o=e.match(/(\d+(?:\.\d+)?)\s*%/),r=o?parseFloat(o[1]):100;return{min:r,max:r}}function Dn(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(l=>r.endsWith(l)))return!0;let s=(n.pathname+n.search).toLowerCase();if(/\bfont(s)?\b/.test(s)||/\.woff2?(\b|$)/.test(s))return!0;for(let l of e){let c=l.toLowerCase().replace(/\s+/g,"+"),i=l.toLowerCase().replace(/\s+/g,"-");if(s.includes(c)||s.includes(i))return!0}return!1}catch{return!1}}function qn(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 Dt({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 a=new Map;for(let d of t){let[b,w,A,g]=String(d).split("__");if(!b)continue;let y=a.get(b)||[];y.push({w:parseInt(w,10),s:A,st:parseInt(g,10)}),a.set(b,y)}let s=/@import\s+url\(["']?([^"')]+)["']?\)/g,l=/url\((["']?)([^"')]+)\1\)/g,c=/@font-face[^{}]*\{[^}]*\}/g;function i(d,b,w,A){if(!a.has(d))return!1;let g=a.get(d),y=Bn(w),F=On(b),v=Hn(A),$=y.min!==y.max,R=y.min,P=T=>F.kind==="normal"&&T==="normal"||F.kind!=="normal"&&(T==="italic"||T==="oblique"),q=!1;for(let T of g){let N=$?T.w>=y.min&&T.w<=y.max:T.w===R,I=P(ue(T.s)),U=T.st>=v.min&&T.st<=v.max;if(N&&I&&U){q=!0;break}}if(q)return!0;if(!$)for(let T of g){let N=P(ue(T.s)),I=T.st>=v.min&&T.st<=v.max;if(Math.abs(R-T.w)<=300&&N&&I)return!0}return!1}function u(d){if(!d)return[];let b=[],w=d.split(",").map(A=>A.trim()).filter(Boolean);for(let A of w){let g=A.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!g)continue;let y=g[1],F=g[2],v=$=>{if(!$.includes("?"))return parseInt($,16);let R=parseInt($.replace(/\?/g,"0"),16),P=parseInt($.replace(/\?/g,"F"),16);return[R,P]};if(F){let $=v(y),R=v(F),P=Array.isArray($)?$[0]:$,q=Array.isArray(R)?R[1]:R;b.push([Math.min(P,q),Math.max(P,q)])}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[A,g]of b)if(w>=A&&w<=g)return!0;return!1}function m(d,b){let w=[];if(!d)return w;for(let A of d.matchAll(l)){let g=(A[2]||"").trim();if(!(!g||g.startsWith("data:"))){if(!/^https?:/i.test(g))try{g=new URL(g,b||location.href).href}catch{}w.push(g)}}return w}async function x(d,b){let w=d;for(let A of d.matchAll(l)){let g=ht(A[0]);if(!g)continue;let y=g;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(A[0],`url(${h.resource.get(y)})`);continue}if(!h.font?.has(y))try{let F=await V(y,{as:"dataURL",useProxy:r,silent:!0});if(F.ok&&typeof F.data=="string"){let v=F.data;h.resource?.set(y,v),h.font?.add(y),w=w.replace(A[0],`url(${v})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",y)}}}return w}function C(d){if(!d.length)return null;let b=(v,$)=>d.some(([R,P])=>!(P<v||R>$)),w=b(0,255)||b(305,305),A=b(256,591)||b(7680,7935),g=b(880,1023),y=b(1024,1279);return b(7840,7929)||b(258,259)||b(416,417)||b(431,432)?"vietnamese":y?"cyrillic":g?"greek":A?"latin-ext":w?"latin":null}function S(d={}){let b=new Set((d.families||[]).map(g=>String(g).toLowerCase())),w=new Set((d.domains||[]).map(g=>String(g).toLowerCase())),A=new Set((d.subsets||[]).map(g=>String(g).toLowerCase()));return(g,y)=>{if(b.size&&b.has(g.family.toLowerCase()))return!0;if(w.size)for(let F of g.srcUrls)try{if(w.has(new URL(F).host.toLowerCase()))return!0}catch{}if(A.size){let F=C(y);if(F&&A.has(F))return!0}return!1}}let p=S(n);function M(d){if(!d)return d;let b=/@font-face[^{}]*\{[^}]*\}/gi,w=new Set,A=[];for(let y of d.match(b)||[]){let F=y.match(/font-family:\s*([^;]+);/i)?.[1]||"",v=Ot(F),$=(y.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),R=(y.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),P=(y.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),q=(y.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),T=(y.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),N=m(T,location.href),I=N.length?N.map(j=>String(j).toLowerCase()).sort().join("|"):T.toLowerCase(),U=[String(v||"").toLowerCase(),$,R,P,q.toLowerCase(),I].join("|");w.has(U)||(w.add(U),A.push(y))}if(A.length===0)return d;let g=0;return d.replace(b,()=>A[g++]||"")}function k(){let d=Array.from(t||[]).sort().join("|"),b=n?JSON.stringify({families:(n.families||[]).map(g=>String(g).toLowerCase()).sort(),domains:(n.domains||[]).map(g=>String(g).toLowerCase()).sort(),subsets:(n.subsets||[]).map(g=>String(g).toLowerCase()).sort()}):"",w=(o||[]).map(g=>`${(g.family||"").toLowerCase()}::${g.weight||"normal"}::${g.style||"normal"}::${g.src||""}`).sort().join("|");return`fonts-embed-css::req=${d}::ex=${b}::lf=${w}::px=${r||""}`}let E=k();if(h.resource?.has(E))return h.resource.get(E);let W=qn(t),z=[];for(let d of document.querySelectorAll("style")){let b=d.textContent||"";for(let w of b.matchAll(s)){let A=w[1];if(!A||et(A))continue;!!document.querySelector(`link[rel="stylesheet"][href="${A}"]`)||z.push(A)}}z.length&&await Promise.all(z.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 B="",L=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(d=>!!d.href);for(let d of L)try{if(et(d.href))continue;let b="",w=!1;try{w=new URL(d.href,location.href).origin===location.origin}catch{}if(!w&&!Dn(d.href,W))continue;if(w){let g=Array.from(document.styleSheets).find(y=>y.href===d.href);if(g)try{let y=g.cssRules||[];b=Array.from(y).map(F=>F.cssText).join("")}catch{}}if(!b&&(b=(await V(d.href,{as:"text",useProxy:r})).data,et(d.href)))continue;let A="";for(let g of b.match(c)||[]){let y=(g.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),F=Ot(y);if(!F||et(F))continue;let v=(g.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),$=(g.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),R=(g.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),P=(g.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),q=(g.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),T=m(q,d.href);if(!i(F,$,v,R))continue;let N=u(P);if(!f(e,N))continue;let I={family:F,weightSpec:v,styleSpec:$,stretchSpec:R,unicodeRange:P,srcRaw:q,srcUrls:T,href:d.href};if(n&&p(I,N))continue;let U=/url\(/i.test(q)?await x(g,d.href):g;A+=U+""}A.trim()&&(B+=A+"")}catch{console.warn("[snapdom] Failed to process stylesheet:",d.href)}for(let d of document.styleSheets)try{if(d.href&&L.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 A=(w.style.getPropertyValue("font-family")||"").trim(),g=Ot(A);if(!g||et(g))continue;let y=(w.style.getPropertyValue("font-weight")||"400").trim(),F=(w.style.getPropertyValue("font-style")||"normal").trim(),v=(w.style.getPropertyValue("font-stretch")||"100%").trim(),$=(w.style.getPropertyValue("src")||"").trim(),R=(w.style.getPropertyValue("unicode-range")||"").trim(),P=m($,d.href||location.href);if(!i(g,F,y,v))continue;let q=u(R);if(!f(e,q))continue;let T={family:g,weightSpec:y,styleSpec:F,stretchSpec:v,unicodeRange:R,srcRaw:$,srcUrls:P,href:d.href||location.href};if(!(n&&p(T,q)))if(/url\(/i.test($)){let N=await x($,d.href||location.href);B+=`@font-face{font-family:${g};src:${N};font-style:${F};font-weight:${y};font-stretch:${v};${R?`unicode-range:${R};`:""}}`}else B+=`@font-face{font-family:${g};src:${$};font-style:${F};font-weight:${y};font-stretch:${v};${R?`unicode-range:${R};`:""}}`}}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)||!a.has(b)||n?.families&&n.families.some(A=>String(A).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 A=await V(d._snapdomSrc,{as:"dataURL",useProxy:r,silent:!0});if(A.ok&&typeof A.data=="string")w=A.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}}B+=`@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)||!a.has(b)||n?.families&&n.families.some(v=>String(v).toLowerCase()===b.toLowerCase()))continue;let w=d.weight!=null?String(d.weight):"normal",A=d.style!=null?String(d.style):"normal",g=d.stretchPct!=null?`${d.stretchPct}%`:"100%",y=String(d.src||""),F=y;if(!F.startsWith("data:")){if(h.resource?.has(y))F=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")F=v.data,h.resource?.set(y,F),h.font?.add(y);else continue}catch{console.warn("[snapdom] Failed to fetch localFonts src:",y);continue}}B+=`@font-face{font-family:'${b}';src:url(${F});font-style:${A};font-weight:${w};font-stretch:${g};}`}return B&&(B=M(B),h.resource?.set(E,B)),B}function qt(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),o=s=>{let l=Ot(s.fontFamily);if(!l)return;let c=(i,u,f)=>`${l}__${Ht(i)}__${ue(u)}__${Un(f)}`;e.add(c(s.fontWeight,s.fontStyle,s.fontStretch))};o(getComputedStyle(t));let r=getComputedStyle(t,"::before");r&&r.content&&r.content!=="none"&&o(r);let a=getComputedStyle(t,"::after");for(a&&a.content&&a.content!=="none"&&o(a);n.nextNode();){let s=n.currentNode,l=getComputedStyle(s);o(l);let c=getComputedStyle(s,"::before");c&&c.content&&c.content!=="none"&&o(c);let i=getComputedStyle(s,"::after");i&&i.content&&i.content!=="none"&&o(i)}return e}function jt(t){let e=new Set,n=r=>{if(r)for(let a of r)e.add(a.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 a=r;for(let s of["::before","::after"]){let c=getComputedStyle(a,s)?.getPropertyValue("content");if(!(!c||c==="none"))if(/^"/.test(c)||/^'/.test(c))n(c.slice(1,-1));else{let i=c.match(/\\[0-9A-Fa-f]{1,6}/g);if(i)for(let u of i)try{e.add(parseInt(u.slice(1),16))}catch{}}}}}return e}async function zt(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 a of n){let s=document.createElement("span");s.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",s.style.fontFamily=`"${a}"`,s.style.fontWeight="700",s.style.fontStyle="italic",s.style.fontSize="32px",s.style.lineHeight="1",s.style.whiteSpace="nowrap",s.style.margin="0",s.style.padding="0",r.appendChild(s)}document.body.appendChild(r),r.offsetWidth,document.body.removeChild(r)};for(let r=0;r<Math.max(1,e);r++)o(),await new Promise(a=>requestAnimationFrame(()=>requestAnimationFrame(a)))}function Te(t){return/\bcounter\s*\(|\bcounters\s*\(/.test(t||"")}function jn(t){return(t||"").replace(/"([^"]*)"/g,"$1")}function Le(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[a,s]of n)for(;o>=a;)r+=s,o-=a;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 Le(t,!1);case"upper-alpha":return Le(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=i=>i&&i.tagName==="LI",r=i=>{let u=0,f=i?.parentElement;if(!f)return 0;for(let m of f.children){if(m===i)break;m.tagName==="LI"&&u++}return u},a=i=>{let u=new Map;for(let[f,m]of i)u.set(f,m.slice());return u},s=(i,u,f)=>{let m=a(i),x;try{x=f.style?.counterReset||getComputedStyle(f).counterReset}catch{}if(x&&x!=="none")for(let S of x.split(",")){let p=S.trim().split(/\s+/),M=p[0],k=Number.isFinite(Number(p[1]))?Number(p[1]):0;if(!M)continue;let E=u.get(M);if(E&&E.length){let W=E.slice();W.push(k),m.set(M,W)}else m.set(M,[k])}let C;try{C=f.style?.counterIncrement||getComputedStyle(f).counterIncrement}catch{}if(C&&C!=="none")for(let S of C.split(",")){let p=S.trim().split(/\s+/),M=p[0],k=Number.isFinite(Number(p[1]))?Number(p[1]):1;if(!M)continue;let E=m.get(M)||[];E.length===0&&E.push(0),E[E.length-1]+=k,m.set(M,E)}try{if(getComputedStyle(f).display==="list-item"&&o(f)){let p=f.parentElement,M=1;if(p&&p.tagName==="OL"){let E=p.getAttribute("start"),W=Number.isFinite(Number(E))?Number(E):1,z=r(f),B=f.getAttribute("value");M=Number.isFinite(Number(B))?Number(B):W+z}else M=1+r(f);let k=m.get("list-item")||[];k.length===0&&k.push(0),k[k.length-1]=M,m.set("list-item",k)}}catch{}return m},l=(i,u,f)=>{let m=s(f,u,i);e.set(i,m);let x=m;for(let C of i.children)x=l(C,m,x);return m},c=new Map;return l(n,c,c),{get(i,u){let f=e.get(i)?.get(u);return f&&f.length?f[f.length-1]:0},getStack(i,u){let f=e.get(i)?.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,(a,s,l)=>{let c=String(l).split(",").map(i=>i.trim());if(s==="counter"){let i=c[0]?.replace(/^["']|["']$/g,""),u=(c[1]||"decimal").toLowerCase(),f=n.get(e,i);return Ie(f,u)}else{let i=c[0]?.replace(/^["']|["']$/g,""),u=c[1]?.replace(/^["']|["']$/g,"")??"",f=(c[2]||"decimal").toLowerCase(),m=n.getStack(e,i);return m.length?m.map(C=>Ie(C,f)).join(u):""}});return jn(r)}catch{return"- "}}var vt=null,Nt=new WeakMap;function zn(t){return(t||"").replace(/"([^"]*)"/g,"$1")}function Vn(t){if(!t)return"";let e=[],n=/"([^"]*)"/g,o;for(;o=n.exec(t);)e.push(o[1]);return e.length?e.join(""):zn(t)}function fe(t,e){let n=t.parentElement,o=n?Nt.get(n):null;return o?{get(r,a){let s=e.get(r,a),l=o.get(a);return typeof l=="number"?Math.max(s,l):s},getStack(r,a){let s=e.getStack(r,a);if(!s.length)return s;let l=o.get(a);if(typeof l=="number"){let c=s.slice();return c[c.length-1]=Math.max(c[c.length-1],l),c}return s}}:e}function de(t,e,n){let o=new Map;function r(c){let i=[];if(!c||c==="none")return i;for(let u of String(c).split(",")){let f=u.trim().split(/\s+/),m=f[0],x=Number.isFinite(Number(f[1]))?Number(f[1]):void 0;m&&i.push({name:m,num:x})}return i}let a=r(e?.counterReset),s=r(e?.counterIncrement);function l(c){if(o.has(c))return o.get(c).slice();let i=n.getStack(t,c);i=i.length?i.slice():[];let u=a.find(m=>m.name===c);if(u){let m=Number.isFinite(u.num)?u.num:0;i=i.length?[...i,m]:[m]}let f=s.find(m=>m.name===c);if(f){let m=Number.isFinite(f.num)?f.num:1;i.length===0&&(i=[0]),i[i.length-1]+=m}return o.set(c,i.slice()),i}return{get(c,i){let u=l(i);return u.length?u[u.length-1]:0},getStack(c,i){return l(i)},__incs:s}}function Xn(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 a=fe(t,n),s=de(t,o,a),l=Te(r)?_e(r,t,s):r;return{text:Vn(l),incs:s.__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 s of["::before","::after","::first-letter"])try{let l=yt(t,s);if(!l||typeof l[Symbol.iterator]!="function"||l.content==="none"&&l.backgroundImage==="none"&&l.backgroundColor==="transparent"&&(l.borderStyle==="none"||parseFloat(l.borderWidth)===0)&&(!l.transform||l.transform==="none")&&l.display==="inline")continue;if(s==="::first-letter"){let N=getComputedStyle(t);if(!(l.color!==N.color||l.fontSize!==N.fontSize||l.fontWeight!==N.fontWeight))continue;let U=Array.from(e.childNodes).find(Q=>Q.nodeType===Node.TEXT_NODE&&Q.textContent?.trim().length>0);if(!U)continue;let j=U.textContent,rt=j.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0],It=j.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(l),Tt=$t(Kt,"span");n.styleMap.set(xt,Tt);let J=document.createTextNode(It);e.replaceChild(J,U),e.insertBefore(xt,J);continue}let i=l.content,{text:u,incs:f}=Xn(t,s,vt),m=l.backgroundImage,x=l.backgroundColor,C=l.fontFamily,S=parseInt(l.fontSize)||32,p=parseInt(l.fontWeight)||!1,M=l.color||"#000",k=l.display,E=parseFloat(l.width),W=parseFloat(l.height),z=l.borderStyle,B=parseFloat(l.borderWidth),L=l.transform,d=et(C),b=i!=="none"&&u!=="",w=m&&m!=="none",A=x&&x!=="transparent"&&x!=="rgba(0, 0, 0, 0)",g=k!=="inline"&&(E>0||W>0),y=z&&z!=="none"&&B>0,F=L&&L!=="none";if(!(b||w||A||y||F)){if(f&&f.length&&t.parentElement){let N=Nt.get(t.parentElement)||new Map;for(let{name:I,num:U}of f){if(!I)continue;let j=fe(t,vt),rt=de(t,getComputedStyle(t,s),j).get(t,I);N.set(I,rt)}Nt.set(t.parentElement,N)}continue}let $=document.createElement("span");$.dataset.snapdomPseudo=s,$.style.verticalAlign="middle",$.style.pointerEvents="none";let R=Bt(l),P=$t(R,"span");if(n.styleMap.set($,P),d&&u&&u.length===1){let{dataUrl:N,width:I,height:U}=await Ne(u,C,p,S,M),j=document.createElement("img");j.src=N,j.style=`height:${S}px;width:${I/U*S}px;object-fit:contain;`,$.appendChild(j),e.dataset.snapdomHasIcon="true"}else if(u&&u.startsWith("url(")){let N=ht(u);if(N?.trim())try{let I=document.createElement("img"),U=await V(ut(N),{as:"dataURL",useProxy:o.useProxy});I.src=U.data,I.style=`width:${S}px;height:auto;object-fit:contain;`,$.appendChild(I)}catch(I){console.error(`[snapdom] Error in pseudo ${s} for`,t,I)}}else!d&&b&&($.textContent=u);if($.style.background="none","mask"in $.style&&($.style.mask="none"),w)try{let N=wt(m),I=await Promise.all(N.map(gt));$.style.backgroundImage=I.join(", ")}catch(N){console.warn(`[snapdom] Failed to inline background-image for ${s}`,N)}A&&($.style.backgroundColor=x);let T=$.childNodes.length>0||$.textContent?.trim()!==""||w||A||y||F;if(f&&f.length&&t.parentElement){let N=Nt.get(t.parentElement)||new Map,I=fe(t,vt),U=de(t,getComputedStyle(t,s),I);for(let{name:j}of f){if(!j)continue;let it=U.get(t,j);N.set(j,it)}Nt.set(t.parentElement,N)}if(!T)continue;s==="::before"?e.insertBefore($,e.firstChild):e.appendChild($)}catch(l){console.warn(`[snapdom] Failed to capture ${s} for`,t,l)}let r=Array.from(t.children),a=Array.from(e.children).filter(s=>!s.dataset.snapdomPseudo);for(let s=0;s<Math.min(r.length,a.length);s++)await me(r[s],a[s],n,o)}function Pe(t){if(!t)return;let e=new Set;if(t.querySelectorAll("use").forEach(l=>{let c=l.getAttribute("xlink:href")||l.getAttribute("href");c&&c.startsWith("#")&&e.add(c.slice(1))}),!e.size)return;let n=Array.from(document.querySelectorAll("svg > symbol, svg > defs")),o=n.filter(l=>l.tagName.toLowerCase()==="symbol"),r=n.filter(l=>l.tagName.toLowerCase()==="defs"),a=t.querySelector("svg.inline-defs-container");a||(a=document.createElementNS("http://www.w3.org/2000/svg","svg"),a.setAttribute("aria-hidden","true"),a.setAttribute("style","position: absolute; width: 0; height: 0; overflow: hidden;"),a.classList.add("inline-defs-container"),t.insertBefore(a,t.firstChild));let s=new Set;t.querySelectorAll("symbol[id], defs > *[id]").forEach(l=>{s.add(l.id)}),e.forEach(l=>{if(s.has(l))return;let c=o.find(i=>i.id===l);if(c){a.appendChild(c.cloneNode(!0)),s.add(l);return}for(let i of r){let u=i.querySelector(`#${CSS.escape(l)}`);if(u){let f=a.querySelector("defs");f||(f=document.createElementNS("http://www.w3.org/2000/svg","defs"),a.appendChild(f)),f.appendChild(u.cloneNode(!0)),s.add(l);break}}})}function Be(t,e){if(!t||!e)return;let n=t.scrollTop||0;if(!n)return;getComputedStyle(e).position==="static"&&(e.style.position="relative");let o=t.getBoundingClientRect(),r=t.clientHeight,a="data-snap-ph",s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;s.nextNode();){let l=s.currentNode,c=getComputedStyle(l),i=c.position;if(i!=="sticky"&&i!=="-webkit-sticky")continue;let u=Ue(c.top),f=Ue(c.bottom);if(u==null&&f==null)continue;let m=Yn(l,t),x=Gn(e,m,a);if(!x)continue;let C=l.getBoundingClientRect(),S=C.width,p=C.height,M=C.left-o.left;if(!(S>0&&p>0)||!Number.isFinite(M))continue;let k=u!=null?u+n:n+(r-p-f);if(!Number.isFinite(k))continue;let E=Number.parseInt(c.zIndex,10),W=Number.isFinite(E),z=W?Math.max(E,1)+1:2,B=W?E-1:0,L=x.cloneNode(!1);L.setAttribute(a,"1"),L.style.position="sticky",L.style.left=`${M}px`,L.style.top=`${k}px`,L.style.width=`${S}px`,L.style.height=`${p}px`,L.style.visibility="hidden",L.style.zIndex=String(B),L.style.overflow="hidden",L.style.background="transparent",L.style.boxShadow="none",L.style.filter="none",x.parentElement?.insertBefore(L,x),x.style.position="absolute",x.style.left=`${M}px`,x.style.top=`${k}px`,x.style.bottom="auto",x.style.zIndex=String(z),x.style.pointerEvents="none"}}function Ue(t){if(!t||t==="auto")return null;let e=Number.parseFloat(t);return Number.isFinite(e)?e:null}function Yn(t,e){let n=[];for(let o=t;o&&o!==e;){let r=o.parentElement;if(!r)break;n.push(Array.prototype.indexOf.call(r.children,o)),o=r}return n.reverse()}function Gn(t,e,n){let o=t;for(let r=0;r<e.length;r++)if(o=Kn(o,n)[e[r]],!o)return null;return o instanceof HTMLElement?o:null}function Kn(t,e){let n=[],o=t.children;for(let r=0;r<o.length;r++){let a=o[r];a.hasAttribute(e)||n.push(a)}return n}async function He(t,e={}){let n={styleMap:h.session.styleMap,styleCache:h.session.styleCache,nodeMap:h.session.nodeMap},o,r="",a="";Jn(t);try{Pe(t)}catch(c){console.warn("inlineExternal defs or symbol failed:",c)}try{o=await Ft(t,n,e,t)}catch(c){throw console.warn("deepClone failed:",c),c}try{await me(t,o,n,e)}catch(c){console.warn("inlinePseudoElements failed:",c)}await eo(o);try{let c=o.querySelectorAll("style[data-sd]");for(let i of c)a+=i.textContent||"",i.remove()}catch{}let s=se(n.styleMap);r=Array.from(s.entries()).map(([c,i])=>`.${i}{${c}}`).join(""),r=a+r;for(let[c,i]of n.styleMap.entries()){if(c.tagName==="STYLE")continue;if(c.getRootNode&&c.getRootNode()instanceof ShadowRoot){c.setAttribute("style",i.replace(/;/g,"; "));continue}let u=s.get(i);u&&c.classList.add(u);let f=c.style?.backgroundImage,m=c.dataset?.snapdomHasIcon;f&&f!=="none"&&(c.style.backgroundImage=f),m&&(c.style.verticalAlign="middle",c.style.display="inline")}for(let[c,i]of n.nodeMap.entries()){let u=i.scrollLeft,f=i.scrollTop;if((u||f)&&c instanceof HTMLElement){c.style.overflow="hidden",c.style.scrollbarWidth="none",c.style.msOverflowStyle="none";let x=document.createElement("div");for(x.style.transform=`translate(${-u}px, ${-f}px)`,x.style.willChange="transform",x.style.display="inline-block",x.style.width="100%";c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x)}}let l=o instanceof HTMLElement&&o.firstElementChild instanceof HTMLElement?o.firstElementChild:o;if(Be(t,l),t===n.nodeMap.get(o)){let c=n.styleCache.get(t)||window.getComputedStyle(t);n.styleCache.set(t,c);let i=Zt(c.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=i||""}for(let[c,i]of n.nodeMap.entries())i.tagName==="PRE"&&(c.style.marginTop="0",c.style.marginBlockStart="0");return{clone:o,classCSS:r,styleCache:n.styleCache}}function Jn(t){let e=getComputedStyle(t),n=e.outlineStyle,o=e.outlineWidth,r=e.borderStyle,a=e.borderWidth,s=n!=="none"&&parseFloat(o)>0,l=r==="none"||parseFloat(a)===0;s&&l&&(t.style.border=`${o} solid transparent`)}var Lt=new Map;async function Rt(t){if(h.resource?.has(t))return h.resource.get(t);if(Lt.has(t))return Lt.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})();Lt.set(t,e);try{let n=await e;return Lt.set(t,n),n}catch(n){throw Lt.delete(t),n}}var Qn=/\bblob:[^)"'\s]+/g;async function Oe(t){if(!t||t.indexOf("blob:")===-1)return t;let e=Array.from(new Set(t.match(Qn)||[]));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 Vt(t){return typeof t=="string"&&t.startsWith("blob:")}function Zn(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 to(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}async function eo(t){if(!t)return;let e=t.querySelectorAll?t.querySelectorAll("img"):[];for(let s of e)try{let c=s.getAttribute("src")||s.currentSrc||"";if(Vt(c)){let u=await Rt(c);s.setAttribute("src",u)}let i=s.getAttribute("srcset");if(i&&i.includes("blob:")){let u=Zn(i),f=!1;for(let m of u)if(Vt(m.url))try{m.url=await Rt(m.url),f=!0}catch{}f&&s.setAttribute("srcset",to(u))}}catch{}let n=t.querySelectorAll?t.querySelectorAll("image"):[];for(let s of n)try{let l="http://www.w3.org/1999/xlink",c=s.getAttribute("href")||s.getAttributeNS?.(l,"href");if(Vt(c)){let i=await Rt(c);s.setAttribute("href",i),s.removeAttributeNS?.(l,"href")}}catch{}let o=t.querySelectorAll?t.querySelectorAll("[style*='blob:']"):[];for(let s of o)try{let l=s.getAttribute("style");if(l&&l.includes("blob:")){let c=await Oe(l);s.setAttribute("style",c)}}catch{}let r=t.querySelectorAll?t.querySelectorAll("style"):[];for(let s of r)try{let l=s.textContent||"";l.includes("blob:")&&(s.textContent=await Oe(l))}catch{}let a=["poster"];for(let s of a){let l=t.querySelectorAll?t.querySelectorAll(`[${s}^='blob:']`):[];for(let c of l)try{let i=c.getAttribute(s);Vt(i)&&c.setAttribute(s,await Rt(i))}catch{}}}async function De(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 a=r.src||"";if(!a)return;let s=await V(a,{as:"dataURL",useProxy:e.useProxy});if(s.ok&&typeof s.data=="string"&&s.data.startsWith("data:")){r.src=s.data,r.width||(r.width=r.naturalWidth||100),r.height||(r.height=r.naturalHeight||100);return}let{fallbackURL:l}=e||{};if(l)try{let u=parseInt(r.dataset?.snapdomWidth||"",10)||0,f=parseInt(r.dataset?.snapdomHeight||"",10)||0,m=parseInt(r.getAttribute("width")||"",10)||0,x=parseInt(r.getAttribute("height")||"",10)||0,C=parseFloat(r.style?.width||"")||0,S=parseFloat(r.style?.height||"")||0,p=u||C||m||r.width||void 0,M=f||S||x||r.height||void 0,k=typeof l=="function"?await l({width:p,height:M,src:a,element:r}):l;if(k){let E=await V(k,{as:"dataURL",useProxy:e.useProxy});r.src=E.data,!r.width&&p&&(r.width=p),!r.height&&M&&(r.height=M),r.width||(r.width=r.naturalWidth||100),r.height||(r.height=r.naturalHeight||100);return}}catch{}let c=r.width||r.naturalWidth||100,i=r.height||r.naturalHeight||100;if(e.placeholders!==!1){let u=document.createElement("div");u.style.cssText=[`width:${c}px`,`height:${i}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${i}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:${c}px;height:${i}px;visibility:hidden;`,r.replaceWith(u)}};for(let r=0;r<n.length;r+=4){let a=n.slice(r,r+4).map(o);await Promise.allSettled(a)}}async function Xt(t,e,n,o={}){let r=[[t,e]],a=["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"],s=["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"],l=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;r.length;){let[c,i]=r.shift(),u=n.get(c)||yt(c);n.has(c)||n.set(c,u);let f=(()=>{let C=u.getPropertyValue("border-image"),S=u.getPropertyValue("border-image-source");return C&&C!=="none"||S&&S!=="none"})();for(let C of a){let S=u.getPropertyValue(C);if(!S||S==="none")continue;let p=wt(S),M=await Promise.all(p.map(k=>gt(k,o)));M.some(k=>k&&k!=="none"&&!/^url\(undefined/.test(k))&&i.style.setProperty(C,M.join(", "))}for(let C of s){let S=u.getPropertyValue(C);!S||S==="initial"||i.style.setProperty(C,S)}if(f)for(let C of l){let S=u.getPropertyValue(C);!S||S==="initial"||i.style.setProperty(C,S)}let m=Array.from(c.children),x=Array.from(i.children);for(let C=0;C<Math.min(m.length,x.length);C++)r.push([m[C],x[C]])}}function qe(t){if(!t)return()=>{};let e=no(t);if(e<=0)return()=>{};if(!so(t))return()=>{};let n=getComputedStyle(t),o=Math.round(oo(n)*e+ro(n)),r=t.textContent??"",a=r;if(t.scrollHeight<=o+.5)return()=>{};let s=0,l=r.length,c=-1;for(;s<=l;){let i=s+l>>1;t.textContent=r.slice(0,i)+"\u2026",t.scrollHeight<=o+.5?(c=i,s=i+1):l=i-1}return t.textContent=(c>=0?r.slice(0,c):"")+"\u2026",()=>{t.textContent=a}}function no(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 oo(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 ro(t){return(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)}function so(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,a,s="",l="",c,i,u=qe(t);try{({clone:o,classCSS:r,styleCache:a}=await He(t,e))}finally{u()}await new Promise(C=>{at(async()=>{await De(o,e),C()},{fast:n})}),await new Promise(C=>{at(async()=>{await Xt(t,o,a,e),C()},{fast:n})}),e.embedFonts&&await new Promise(C=>{at(async()=>{let S=qt(t),p=jt(t);if(X()){let M=new Set(Array.from(S).map(k=>String(k).split("__")[0]).filter(Boolean));await zt(M,2)}s=await Dt({required:S,usedCodepoints:p,preCached:!1,exclude:e.excludeFonts,useProxy:e.useProxy}),C()},{fast:n})});let f=oe(o).sort(),m=f.join(",");h.baseStyle.has(m)?l=h.baseStyle.get(m):await new Promise(C=>{at(()=>{l=re(f),h.baseStyle.set(m,l),C()},{fast:n})}),await new Promise(C=>{at(()=>{let S=getComputedStyle(t);function p(D){let _=`${D.filter||""} ${D.webkitFilter||""}`.trim();if(!_||_==="none")return{bleed:{top:0,right:0,bottom:0,left:0},has:!1};let O=_.match(/drop-shadow\((?:[^()]|\([^()]*\))*\)/gi)||[],G=0,K=0,Z=0,Y=0,ct=!1;for(let Ct of O){ct=!0;let dt=Ct.match(/-?\d+(?:\.\d+)?px/gi)?.map(lt=>parseFloat(lt))||[],[st=0,tt=0,mt=0]=dt,nt=Math.abs(st)+mt,ot=Math.abs(tt)+mt;K=Math.max(K,nt+Math.max(st,0)),Y=Math.max(Y,nt+Math.max(-st,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 M(D){let _=D.boxShadow||"";if(!_||_==="none")return{top:0,right:0,bottom:0,left:0};let O=_.split(/\),(?=(?:[^()]*\([^()]*\))*[^()]*$)/).map(ct=>ct.trim()),G=0,K=0,Z=0,Y=0;for(let ct of O){let Ct=ct.match(/-?\d+(\.\d+)?px/g)?.map(lt=>parseFloat(lt))||[];if(Ct.length<2)continue;let[dt,st,tt=0,mt=0]=Ct,nt=Math.abs(dt)+tt+mt,ot=Math.abs(st)+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(st,0)),G=Math.max(G,ot+Math.max(-st,0))}return{top:Math.ceil(G),right:Math.ceil(K),bottom:Math.ceil(Z),left:Math.ceil(Y)}}function k(D){let _=(D.filter||"").match(/blur\(\s*([0-9.]+)px\s*\)/),O=_?Math.ceil(parseFloat(_[1])||0):0;return{top:O,right:O,bottom:O,left:O}}function E(D){if((D.outlineStyle||"none")==="none")return{top:0,right:0,bottom:0,left:0};let _=Math.ceil(parseFloat(D.outlineWidth||"0")||0);return{top:_,right:_,bottom:_,left:_}}function W(D,_,O,G,K){let Z=O.a,Y=O.b,ct=O.c,Ct=O.d,dt=O.e||0,st=O.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+st,[Se,Ce]}let mt=[tt(0,0),tt(D,0),tt(0,_),tt(D,_)],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 z(D){return co(D)}let B=t.getBoundingClientRect(),L=Math.max(1,Math.ceil(t.offsetWidth||parseFloat(S.width)||B.width||1)),d=Math.max(1,Math.ceil(t.offsetHeight||parseFloat(S.height)||B.height||1)),b=(D,_=NaN)=>{let O=typeof D=="string"?parseFloat(D):D;return Number.isFinite(O)?O:_},w=b(e.width),A=b(e.height),g=L,y=d,F=Number.isFinite(w),v=Number.isFinite(A),$=d>0?L/d:1;F&&v?(g=Math.max(1,Math.ceil(w)),y=Math.max(1,Math.ceil(A))):F?(g=Math.max(1,Math.ceil(w)),y=Math.max(1,Math.ceil(g/($||1)))):v?(y=Math.max(1,Math.ceil(A)),g=Math.max(1,Math.ceil(y*($||1)))):(g=L,y=d);let R=0,P=0,q=L,T=d;if(z(t)){let D=S.transform&&S.transform!=="none"?S.transform:"",_=io(t),O=fo({baseTransform:D,rotate:_.rotate||"0deg",scale:_.scale,translate:_.translate}),{ox:G,oy:K}=lo(S,L,d),Z=O.is2D?O:new DOMMatrix(O.toString()),Y=W(L,d,Z,G,K);R=Y.minX,P=Y.minY,q=Y.maxX,T=Y.maxY}let N=M(S),I=k(S),U=E(S),j=p(S),it={top:N.top+I.top+U.top+j.bleed.top,right:N.right+I.right+U.right+j.bleed.right,bottom:N.bottom+I.bottom+U.bottom+j.bleed.bottom,left:N.left+I.left+U.left+j.bleed.left};R-=it.left,P-=it.top,q+=it.right,T+=it.bottom;let rt=Math.max(1,Math.ceil(q-R)),It=Math.max(1,Math.ceil(T-P)),xt=Math.max(1,Math.round(rt*(F||v?g/L:1))),Kt=Math.max(1,Math.round(It*(v||F?y/d:1))),Tt="http://www.w3.org/2000/svg",J=X()?1:0,Q=document.createElementNS(Tt,"foreignObject"),Ge=Math.floor(R),Ke=Math.floor(P);Q.setAttribute("x",String(-(Ge-J))),Q.setAttribute("y",String(-(Ke-J))),Q.setAttribute("width",String(Math.ceil(L+J*2))),Q.setAttribute("height",String(Math.ceil(d+J*2))),Q.style.overflow="visible";let ye=document.createElement("style");ye.textContent=l+s+"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=`${L}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 Je=new XMLSerializer().serializeToString(Q),Jt=rt+J*2,Qt=It+J*2,we=F||v;e.meta={w0:L,h0:d,vbW:Jt,vbH:Qt,targetW:g,targetH:y};let Qe=X()&&we?Jt:xt+J*2,Ze=X()&&we?Qt:Kt+J*2;i=`<svg xmlns="${Tt}" width="${Qe}" height="${Ze}" viewBox="0 0 ${Jt} ${Qt}">`+Je+"</svg>",c=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`,C()},{fast:n})});let x=document.getElementById("snapdom-sandbox");return x&&x.style.position==="absolute"&&x.remove(),c}function ao(t){let e=getComputedStyle(t).transform;if(!e||e==="none")return new DOMMatrix;try{return new DOMMatrix(e)}catch{return new WebKitCSSMatrix(e)}}function io(t){let e={rotate:"0deg",scale:null,translate:null},n=typeof t.computedStyleMap=="function"?t.computedStyleMap():null;if(n){let r=c=>{try{return typeof n.has=="function"&&!n.has(c)||typeof n.get!="function"?null:n.get(c)}catch{return null}},a=r("rotate");if(a)if(a.angle){let c=a.angle;e.rotate=c.unit==="rad"?c.value*180/Math.PI+"deg":c.value+c.unit}else a.unit?e.rotate=a.unit==="rad"?a.value*180/Math.PI+"deg":a.value+a.unit:e.rotate=String(a);else{let c=getComputedStyle(t);e.rotate=c.rotate&&c.rotate!=="none"?c.rotate:"0deg"}let s=r("scale");if(s){let c="x"in s&&s.x?.value!=null?s.x.value:Array.isArray(s)?s[0]?.value:Number(s)||1,i="y"in s&&s.y?.value!=null?s.y.value:Array.isArray(s)?s[1]?.value:c;e.scale=`${c} ${i}`}else{let c=getComputedStyle(t);e.scale=c.scale&&c.scale!=="none"?c.scale:null}let l=r("translate");if(l){let c="x"in l&&"value"in l.x?l.x.value:Array.isArray(l)?l[0]?.value:0,i="y"in l&&"value"in l.y?l.y.value:Array.isArray(l)?l[1]?.value:0,u="x"in l&&l.x?.unit?l.x.unit:"px",f="y"in l&&l.y?.unit?l.y.unit:"px";e.translate=`${c}${u} ${i}${f}`}else{let c=getComputedStyle(t);e.translate=c.translate&&c.translate!=="none"?c.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 co(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",a=e.scale&&e.scale!=="none"&&e.scale!=="1",s=e.translate&&e.translate!=="none"&&e.translate!=="0px 0px";return!!(r||a||s)}function lo(t,e,n){let o=(t.transformOrigin||"0 0").trim().split(/\s+/),[r,a]=[o[0]||"0",o[1]||"0"],s=(l,c)=>{let i=l.toLowerCase();return i==="left"||i==="top"?0:i==="center"?c/2:i==="right"||i==="bottom"?c:i.endsWith("px")?parseFloat(i)||0:i.endsWith("%")?(parseFloat(i)||0)*c/100:/^-?\d+(\.\d+)?$/.test(i)&&parseFloat(i)||0};return{ox:s(r,e),oy:s(a,n)}}var he=null;function uo(){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 fo(t){let e=uo(),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=ao(n);return e.removeChild(n),o}function mo(t){if(typeof t=="string"){let e=t.toLowerCase().trim();if(e==="disabled"||e==="full"||e==="auto"||e==="soft")return e}return"soft"}function je(t={}){let e=t.format??"png",n=mo(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 ho(t){return typeof t=="string"&&/^data:image\/svg\+xml/i.test(t)}function po(t){let e=t.indexOf(",");return e>=0?decodeURIComponent(t.slice(e+1)):""}function go(t){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}function yo(t){let e=[],n="",o=0;for(let r=0;r<t.length;r++){let a=t[r];a==="("&&o++,a===")"&&(o=Math.max(0,o-1)),a===";"&&o===0?(e.push(n),n=""):n+=a}return n.trim()&&e.push(n),e.map(r=>r.trim()).filter(Boolean)}function wo(t){let e=[],n="",o=0;for(let a=0;a<t.length;a++){let s=t[a];s==="("&&o++,s===")"&&(o=Math.max(0,o-1)),s===","&&o===0?(e.push(n.trim()),n=""):n+=s}n.trim()&&e.push(n.trim());let r=[];for(let a of e){if(/\binset\b/i.test(a))continue;let s=a.match(/-?\d+(?:\.\d+)?px/gi)||[],[l="0px",c="0px",i="0px"]=s,u=a.replace(/-?\d+(?:\.\d+)?px/gi,"").replace(/\binset\b/ig,"").trim().replace(/\s{2,}/g," "),f=!!u&&u!==",";r.push(`drop-shadow(${l} ${c} ${i}${f?` ${u}`:""})`)}return r.join(" ")}function ze(t){let e=yo(t),n=null,o=null,r=null,a=[];for(let l of e){let c=l.indexOf(":");if(c<0)continue;let i=l.slice(0,c).trim().toLowerCase(),u=l.slice(c+1).trim();i==="box-shadow"?r=u:i==="filter"?n=u:i==="-webkit-filter"?o=u:a.push([i,u])}if(r){let l=wo(r);l&&(n=n?`${n} ${l}`:l,o=o?`${o} ${l}`:l)}let s=[...a];return n&&s.push(["filter",n]),o&&s.push(["-webkit-filter",o]),s.map(([l,c])=>`${l}:${c}`).join(";")}function bo(t){return t.replace(/([^{}]+)\{([^}]*)\}/g,(e,n,o)=>`${n}{${ze(o)}}`)}function xo(t){return t=t.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi,(e,n)=>e.replace(n,bo(n))),t=t.replace(/style=(['"])([\s\S]*?)\1/gi,(e,n,o)=>`style=${n}${ze(o)}${n}`),t}function So(t){if(!X()||!ho(t))return t;try{let e=po(t),n=xo(e);return go(n)}catch{return t}}async function ft(t,e){let{width:n,height:o,scale:r=1,dpr:a=1,meta:s={}}=e;t=So(t);let l=new Image;l.loading="eager",l.decoding="sync",l.crossOrigin="anonymous",l.src=t,await l.decode();let c=l.naturalWidth,i=l.naturalHeight,u=Number.isFinite(s.w0)?s.w0:c,f=Number.isFinite(s.h0)?s.h0:i,m,x,C=Number.isFinite(n),S=Number.isFinite(o);if(C&&S)m=Math.max(1,n),x=Math.max(1,o);else if(C){let k=n/Math.max(1,u);m=n,x=Math.round(f*k)}else if(S){let k=o/Math.max(1,f);x=o,m=Math.round(u*k)}else m=c,x=i;m=Math.round(m*r),x=Math.round(x*r);let p=document.createElement("canvas");p.width=Math.ceil(m*a),p.height=Math.ceil(x*a),p.style.width=`${m}px`,p.style.height=`${x}px`;let M=p.getContext("2d");return a!==1&&M.scale(a,a),M.drawImage(l,0,0,m,x),p}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 Ve(t,e){let{scale:n=1,width:o,height:r,meta:a={}}=e,s=Number.isFinite(o),l=Number.isFinite(r),c=Number.isFinite(n)&&n!==1||s||l;if(X()&&c)return await Yt(t,{...e,format:"png",quality:1,meta:a});let i=new Image;if(i.decoding="sync",i.loading="eager",i.src=t,await i.decode(),s&&l)i.style.width=`${o}px`,i.style.height=`${r}px`;else if(s){let u=Number.isFinite(a.w0)?a.w0:i.naturalWidth,f=Number.isFinite(a.h0)?a.h0:i.naturalHeight,m=o/Math.max(1,u);i.style.width=`${o}px`,i.style.height=`${Math.round(f*m)}px`}else if(l){let u=Number.isFinite(a.w0)?a.w0:i.naturalWidth,f=Number.isFinite(a.h0)?a.h0:i.naturalHeight,m=r/Math.max(1,f);i.style.height=`${r}px`,i.style.width=`${Math.round(u*m)}px`}else n!==1&&(i.style.width=`${Math.round(i.naturalWidth*n)}px`,i.style.height=`${Math.round(i.naturalHeight*n)}px`);return i}async function Gt(t,e){let n=e.type;if(n==="svg"){let a=decodeURIComponent(t.split(",")[1]);return new Blob([a],{type:"image/svg+xml"})}let o=await ft(t,e),r=e.backgroundColor?pt(o,e.backgroundColor):o;return new Promise(a=>r.toBlob(s=>a(s),`image/${n}`,e.quality))}async function Xe(t,e){if(e.dpr=1,e.format==="svg"){let a=await Gt(t,{...e,type:"svg"}),s=URL.createObjectURL(a),l=document.createElement("a");l.href=s,l.download=e.filename,l.click(),URL.revokeObjectURL(s);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 Ye=Symbol("snapdom.internal"),ge=!1;async function H(t,e){if(!t)throw new Error("Element cannot be null or undefined");let n=je(e);if(X()&&(n.embedFonts===!0||ko(t)))for(let o=0;o<3;o++)try{await Co(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)=>H.toPng(o,r),toImg:(o,r)=>H.toImg(o,r)}),H.capture(t,n,Ye)}H.capture=async(t,e,n)=>{if(n!==Ye)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");let o=await pe(t,e),r=s=>({...e,...s||{}}),a=s=>l=>{let c=r({...l||{},format:s}),i=s==="jpeg"||s==="jpg",u=c.backgroundColor==null||c.backgroundColor==="transparent";return i&&u&&(c.backgroundColor="#ffffff"),Yt(o,c)};return{url:o,toRaw:()=>o,toImg:s=>Ve(o,r(s)),toCanvas:s=>ft(o,r(s)),toBlob:s=>Gt(o,r(s)),toPng:a("png"),toJpg:a("jpeg"),toWebp:a("webp"),download:s=>Xe(o,r(s))}};H.toRaw=(t,e)=>H(t,e).then(n=>n.toRaw());H.toImg=(t,e)=>H(t,e).then(n=>n.toImg());H.toCanvas=(t,e)=>H(t,e).then(n=>n.toCanvas());H.toBlob=(t,e)=>H(t,e).then(n=>n.toBlob());H.toPng=(t,e)=>H(t,{...e,format:"png"}).then(n=>n.toPng());H.toJpg=(t,e)=>H(t,{...e,format:"jpeg"}).then(n=>n.toJpg());H.toWebp=(t,e)=>H(t,{...e,format:"webp"}).then(n=>n.toWebp());H.download=(t,e)=>H(t,e).then(n=>n.download());async function Co(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 a=new Image;a.decoding="sync",a.loading="eager",a.style.position="fixed",a.style.left=0,a.style.top=0,a.style.width="10px",a.style.height="10px",a.style.opacity="0.01",a.style.transform="translateZ(10px)",a.style.willChange="transform,opacity;",a.src=o;let s=async()=>{await new Promise(l=>setTimeout(l,100)),a&&a.parentNode&&a.parentNode.removeChild(a),ge=!0,r()};document.body.appendChild(a),s()})}function ko(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",a=o.maskImage&&o.maskImage!=="none"||o.webkitMaskImage&&o.webkitMaskImage!=="none";if(r||a)return!0}return!1}async function Mo(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 a=[],s=[];try{t?.querySelectorAll&&(a=Array.from(t.querySelectorAll("img[src]")),s=Array.from(t.querySelectorAll("*")))}catch{}let l=[];for(let c of a){let i=c?.currentSrc||c?.src;if(i&&!h.image.has(i)){let u=Promise.resolve().then(async()=>{let f=await V(i,{as:"dataURL",useProxy:o});f?.ok&&typeof f.data=="string"&&h.image.set(i,f.data)}).catch(()=>{});l.push(u)}}for(let c of s){let i="";try{i=yt(c).backgroundImage}catch{}if(i&&i!=="none"){let u=wt(i);for(let f of u)if(f.startsWith("url(")){let m=Promise.resolve().then(()=>gt(f,{...e,useProxy:o})).catch(()=>{});l.push(m)}}}if(n)try{let c=qt(t),i=jt(t);if(typeof X=="function"?X():!!X){let f=new Set(Array.from(c).map(m=>String(m).split("__")[0]).filter(Boolean));await zt(f,2)}await Dt({required:c,usedCodepoints:i,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??o})}catch{}await Promise.allSettled(l)}export{Mo as preCache,H as snapdom};
|