@zumer/snapdom 1.9.8 → 1.9.10-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
- (()=>{var De=Object.defineProperty;var Y=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable;var ue=(e,t,r)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,R=(e,t)=>{for(var r in t||(t={}))he.call(t,r)&&ue(e,r,t[r]);if(Y)for(var r of Y(t))ge.call(t,r)&&ue(e,r,t[r]);return e};var oe=(e,t)=>{var r={};for(var l in e)he.call(e,l)&&t.indexOf(l)<0&&(r[l]=e[l]);if(e!=null&&Y)for(var l of Y(e))t.indexOf(l)<0&&ge.call(e,l)&&(r[l]=e[l]);return r};var g=(e,t,r)=>new Promise((l,d)=>{var n=c=>{try{s(r.next(c))}catch(o){d(o)}},a=c=>{try{s(r.throw(c))}catch(o){d(o)}},s=c=>c.done?l(c.value):Promise.resolve(c.value).then(n,a);s((r=r.apply(e,t)).next())});var f={image:new Map,background:new Map,resource:new Map,defaultStyle:new Map,baseStyle:new Map,computedStyle:new WeakMap,font:new Set,snapshot:new WeakMap,snapshotKey:new Map,preStyleMap:new Map,preStyle:new WeakMap,preNodeMap:new Map,reset:Oe};function Oe(){f.computedStyle=new WeakMap,f.snapshot=new WeakMap,f.snapshotKey.clear(),f.preStyleMap.clear(),f.preStyle=new WeakMap,f.preNodeMap.clear()}var je=["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","svg","path","circle","rect","line","g","table","thead","tbody","tr","td","th"];function ye(){for(let e of je)we(e)}function we(e){if(f.defaultStyle.has(e))return f.defaultStyle.get(e);if(new Set(["script","style","meta","link","noscript","template","defs","symbol","title","metadata","desc"]).has(e)){let a={};return f.defaultStyle.set(e,a),a}let r=document.getElementById("snapdom-sandbox");r||(r=document.createElement("div"),r.id="snapdom-sandbox",r.style.position="absolute",r.style.left="-9999px",r.style.top="-9999px",r.style.width="0",r.style.height="0",r.style.overflow="hidden",document.body.appendChild(r));let l=document.createElement(e);l.style.all="initial",r.appendChild(l);let d=getComputedStyle(l),n={};for(let a of d)n[a]=d.getPropertyValue(a);return r.removeChild(l),f.defaultStyle.set(e,n),n}var Ve=new Set(["-webkit-locale"]);function _(e,t,r=!1){let l=[],d=we(t);for(let[n,a]of Object.entries(e))if(!Ve.has(n))if(!r)a&&l.push(`${n}:${a}`);else{let s=d[n];a&&a!==s&&l.push(`${n}:${a}`)}return l.sort().join(";")}function be(e){let t=new Set;return e.nodeType!==Node.ELEMENT_NODE&&e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(e.tagName&&t.add(e.tagName.toLowerCase()),typeof e.querySelectorAll=="function"&&e.querySelectorAll("*").forEach(r=>t.add(r.tagName.toLowerCase())),Array.from(t))}function Se(e){let t=new Map;for(let l of e){let d=f.defaultStyle.get(l);if(!d)continue;let n=Object.entries(d).map(([a,s])=>`${a}:${s};`).sort().join("");t.has(n)||t.set(n,[]),t.get(n).push(l)}let r="";for(let[l,d]of t.entries())r+=`${d.join(",")} { ${l} }
2
- `;return r}function xe(){let e=new Set(f.preStyleMap.values()),t=new Map,r=1;for(let l of e)l.trim()&&t.set(l,`c${r++}`);return t}function W(r){return g(this,arguments,function*(e,t={}){let l=q(e),d=/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(e);if(l){let n=G(l);if(f.background.has(n))return t.skipInline?void 0:`url(${f.background.get(n)})`;{let a=yield P(n,{useProxy:t.useProxy});return f.background.set(n,a),t.skipInline?void 0:`url("${a}")`}}return e})}function D(e,{fast:t=!1}={}){if(t)return e();"requestIdleCallback"in window?requestIdleCallback(e,{timeout:50}):setTimeout(e,1)}function A(e,t=null){if(!(e instanceof Element))return window.getComputedStyle(e,t);let r=f.computedStyle.get(e);if(r||(r=new Map,f.computedStyle.set(e,r)),!r.has(t)){let l=window.getComputedStyle(e,t);r.set(t,l)}return r.get(t)}function Ce(e){let t=e.replace(/^['"]|['"]$/g,"");if(t.startsWith("\\"))try{return String.fromCharCode(parseInt(t.replace("\\",""),16))}catch(r){return t}return t}function q(e){let t=e.match(/url\((['"]?)(.*?)(\1)\)/);if(!t)return null;let r=t[2].trim();return r.startsWith("#")?null:r}function P(e,{timeout:t=3e3,useProxy:r=""}={}){function l(c){try{return new URL(c,window.location.href).origin===window.location.origin?"use-credentials":"anonymous"}catch(o){return"anonymous"}}function d(c){return g(this,null,function*(){let o=i=>fetch(i,{mode:"cors",credentials:l(i)==="use-credentials"?"include":"omit"}).then(p=>p.blob()).then(p=>new Promise((u,m)=>{let h=new FileReader;h.onloadend=()=>{let y=h.result;if(typeof y!="string"||!y.startsWith("data:image/")){m(new Error("Invalid image data URL"));return}u(y)},h.onerror=()=>m(new Error("FileReader error")),h.readAsDataURL(p)}));try{return yield o(c)}catch(i){if(r&&typeof r=="string"){let p=r.replace(/\/$/,"")+G(c);try{return yield o(p)}catch(u){throw new Error("[SnapDOM - fetchImage] CORS restrictions prevented image capture (even via proxy)")}}else throw new Error("[SnapDOM - fetchImage] Fetch fallback failed and no proxy provided")}})}let n=l(e);return f.image.has(e)?Promise.resolve(f.image.get(e)):e.startsWith("data:image/")?(f.image.set(e,e),Promise.resolve(e)):/\.svg(\?.*)?$/i.test(e)?g(null,null,function*(){try{let o=yield(yield fetch(e,{mode:"cors",credentials:n==="use-credentials"?"include":"omit"})).text(),i=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`;return f.image.set(e,i),i}catch(c){return d(e)}}):new Promise((c,o)=>{let i=setTimeout(()=>{o(new Error("[SnapDOM - fetchImage] Image load timed out"))},t),p=new Image;p.crossOrigin=n,p.onload=()=>g(null,null,function*(){clearTimeout(i);try{yield p.decode();let u=document.createElement("canvas");u.width=p.width,u.height=p.height,u.getContext("2d").drawImage(p,0,0,u.width,u.height);let h=u.toDataURL("image/png");f.image.set(e,h),c(h)}catch(u){try{let m=yield d(e);f.image.set(e,m),c(m)}catch(m){o(m)}}}),p.onerror=()=>g(null,null,function*(){clearTimeout(i),console.error(`[SnapDOM - fetchImage] Image failed to load: ${e}`);try{let u=yield d(e);f.image.set(e,u),c(u)}catch(u){o(u)}}),p.src=e})}function ae(e){let t={};for(let r of e)t[r]=e.getPropertyValue(r);return t}function Ee(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function ve(e){if(!e||e==="none")return"";let t=e.replace(/translate[XY]?\([^)]*\)/g,"");return t=t.replace(/matrix\(([^)]+)\)/g,(r,l)=>{let d=l.split(",").map(n=>n.trim());return d.length!==6?`matrix(${l})`:(d[4]="0",d[5]="0",`matrix(${d.join(", ")})`)}),t=t.replace(/matrix3d\(([^)]+)\)/g,(r,l)=>{let d=l.split(",").map(n=>n.trim());return d.length!==16?`matrix3d(${l})`:(d[12]="0",d[13]="0",`matrix3d(${d.join(", ")})`)}),t.trim().replace(/\s{2,}/g," ")}function G(e){if(/%[0-9A-Fa-f]{2}/.test(e))return e;try{return encodeURI(e)}catch(t){return e}}function O(e){let t=[],r=0,l=0;for(let d=0;d<e.length;d++){let n=e[d];n==="("&&r++,n===")"&&r--,n===","&&r===0&&(t.push(e.slice(l,d).trim()),l=d+1)}return t.push(e.slice(l).trim()),t}function _e(e){let t={},r=e.getPropertyValue("visibility");for(let l=0;l<e.length;l++){let d=e[l],n=e.getPropertyValue(d);(d==="background-image"||d==="content")&&n.includes("url(")&&!n.includes("data:")&&(n="none"),t[d]=n}return r==="hidden"&&(t.opacity="0"),t}function X(e,t,r){var c;if(e.tagName==="STYLE")return;f.preStyle.has(e)||f.preStyle.set(e,A(e));let l=f.preStyle.get(e);if(!f.snapshot.has(e)){let o=_e(l);f.snapshot.set(e,o)}let d=f.snapshot.get(e),n=Object.entries(d).sort(([o],[i])=>o.localeCompare(i)).map(([o,i])=>`${o}:${i}`).join(";");if(f.snapshotKey.has(n)){f.preStyleMap.set(t,f.snapshotKey.get(n));return}let a=((c=e.tagName)==null?void 0:c.toLowerCase())||"div",s=_(d,a,r);f.snapshotKey.set(n,s),f.preStyleMap.set(t,s)}function H(e,t,r={},l){var s,c;if(!e)throw new Error("Invalid node");let d=new Set,n=null;if(e.nodeType===Node.TEXT_NODE||e.nodeType!==Node.ELEMENT_NODE)return e.cloneNode(!0);if(e.getAttribute("data-capture")==="exclude"){let o=document.createElement("div"),i=e.getBoundingClientRect();return o.style.cssText=`display:inline-block;width:${i.width}px;height:${i.height}px;visibility:hidden;`,o}if(r.exclude&&Array.isArray(r.exclude))for(let o of r.exclude)try{if((s=e.matches)!=null&&s.call(e,o)){let i=document.createElement("div"),p=e.getBoundingClientRect();return i.style.cssText=`display:inline-block;width:${p.width}px;height:${p.height}px;visibility:hidden;`,i}}catch(i){console.warn(`Invalid selector in exclude option: ${o}`,i)}if(typeof r.filter=="function")try{if(!r.filter(e,l||e)){let o=document.createElement("div"),i=e.getBoundingClientRect();return o.style.cssText=`display:inline-block;width:${i.width}px;height:${i.height}px;visibility:hidden;`,o}}catch(o){console.warn("Error in filter function:",o)}if(e.tagName==="IFRAME"){let o=document.createElement("div");return o.style.cssText=`width:${e.offsetWidth}px;height:${e.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;`,o}if(e.getAttribute("data-capture")==="placeholder"){let o=e.cloneNode(!1);f.preNodeMap.set(o,e),X(e,o,t);let i=document.createElement("div");return i.textContent=e.getAttribute("data-placeholder-text")||"",i.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",o.appendChild(i),o}if(e.tagName==="CANVAS"){let o=e.toDataURL(),i=document.createElement("img");return i.src=o,i.width=e.width,i.height=e.height,f.preNodeMap.set(i,e),X(e,i,t),i}let a;try{a=e.cloneNode(!1),f.preNodeMap.set(a,e)}catch(o){throw console.error("[Snapdom] Failed to clone node:",e,o),o}if(e instanceof HTMLTextAreaElement){a.textContent=e.value,a.value=e.value;let o=e.getBoundingClientRect();return a.style.width=`${o.width}px`,a.style.height=`${o.height}px`,a}if(e instanceof HTMLInputElement&&(a.value=e.value,a.setAttribute("value",e.value),e.checked!==void 0&&(a.checked=e.checked,e.checked&&a.setAttribute("checked",""),e.indeterminate&&(a.indeterminate=e.indeterminate))),e instanceof HTMLSelectElement&&(n=e.value),X(e,a,t),e.shadowRoot)if(Array.from(e.shadowRoot.querySelectorAll("slot")).length>0){for(let i of e.shadowRoot.childNodes)if(i.nodeType===Node.ELEMENT_NODE&&i.tagName==="STYLE"){let p=i.textContent||"";p.trim()&&t&&(f.preStyle||(f.preStyle=new WeakMap),f.preStyle.set(i,p))}}else{let i=document.createDocumentFragment();for(let p of e.shadowRoot.childNodes){if(p.nodeType===Node.ELEMENT_NODE&&p.tagName==="STYLE"){let m=p.textContent||"";m.trim()&&t&&(f.preStyle||(f.preStyle=new WeakMap),f.preStyle.set(p,m));continue}let u=H(p,t,r,l||e);u&&i.appendChild(u)}a.appendChild(i)}if(e.tagName==="SLOT"){let o=((c=e.assignedNodes)==null?void 0:c.call(e,{flatten:!0}))||[],i=o.length>0?o:Array.from(e.childNodes),p=document.createDocumentFragment();for(let u of i){let m=H(u,t,r,l||e);m&&p.appendChild(m)}return p}for(let o of e.childNodes){if(d.has(o))continue;let i=H(o,t,r,l||e);i&&a.appendChild(i)}if(n!==null&&a instanceof HTMLSelectElement){a.value=n;for(let o of a.options)o.value===n?o.setAttribute("selected",""):o.removeAttribute("selected")}return a}var qe=[/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],re=[];function $e(e){let t=Array.isArray(e)?e:[e];for(let r of t)r instanceof RegExp?re.push(r):typeof r=="string"?re.push(new RegExp(r,"i")):console.warn("[snapdom] Ignored invalid iconFont value:",r)}function $(e){let t=typeof e=="string"?e:"",r=[...qe,...re];for(let l of r)if(l instanceof RegExp&&l.test(t))return!0;return!!(/icon/i.test(t)||/glyph/i.test(t)||/symbols/i.test(t)||/feather/i.test(t)||/fontawesome/i.test(t))}function ke(e,t,r,l=32,d="#000"){return g(this,null,function*(){t=t.replace(/^['"]+|['"]+$/g,"");let n=window.devicePixelRatio||1;yield document.fonts.ready;let a=document.createElement("span");a.textContent=e,a.style.position="absolute",a.style.visibility="hidden",a.style.fontFamily=`"${t}"`,a.style.fontWeight=r||"normal",a.style.fontSize=`${l}px`,a.style.lineHeight="1",a.style.whiteSpace="nowrap",a.style.padding="0",a.style.margin="0",document.body.appendChild(a);let s=a.getBoundingClientRect(),c=Math.ceil(s.width),o=Math.ceil(s.height);document.body.removeChild(a);let i=document.createElement("canvas");i.width=c*n,i.height=o*n;let p=i.getContext("2d");return p.scale(n,n),p.font=r?`${r} ${l}px "${t}"`:`${l}px "${t}"`,p.textAlign="left",p.textBaseline="top",p.fillStyle=d,p.fillText(e,0,0),{dataUrl:i.toDataURL(),width:c,height:o}})}function Ie(e){return Array.from(document.styleSheets).some(t=>t.href===e)}function He(e){return new Promise(t=>{if(Ie(e))return t(null);let r=document.createElement("link");r.rel="stylesheet",r.href=e,r.setAttribute("data-snapdom","injected-import"),r.onload=()=>t(r),r.onerror=()=>t(null),document.head.appendChild(r)})}function J(){return g(this,arguments,function*({preCached:e=!1}={}){if(f.resource.has("fonts-embed-css")){if(e){let n=document.createElement("style");n.setAttribute("data-snapdom","embedFonts"),n.textContent=f.resource.get("fonts-embed-css"),document.head.appendChild(n)}return f.resource.get("fonts-embed-css")}let t=/@import\s+url\(["']?([^"')]+)["']?\)/g,r=[];for(let n of document.querySelectorAll("style")){let a=n.textContent||"",s=Array.from(a.matchAll(t));for(let c of s){let o=c[1];$(o)||Ie(o)||r.push(o)}}yield Promise.all(r.map(He));let l=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(n=>n.href),d="";for(let n of l)try{let s=yield(yield fetch(n.href)).text();if($(n.href)||$(s))continue;let c=/url\((["']?)([^"')]+)\1\)/g,o=yield Promise.all(Array.from(s.matchAll(c)).map(p=>g(null,null,function*(){let u=q(p[0]);if(!u)return null;let m=u;if(!m.startsWith("http")&&!m.startsWith("data:")&&(m=new URL(m,n.href).href),$(m))return null;if(f.resource.has(m))return f.font.add(m),{original:p[0],inlined:`url(${f.resource.get(m)})`};if(f.font.has(m))return null;try{let y=yield(yield fetch(m)).blob(),S=yield new Promise(w=>{let b=new FileReader;b.onload=()=>w(b.result),b.readAsDataURL(y)});return f.resource.set(m,S),f.font.add(m),{original:p[0],inlined:`url(${S})`}}catch(h){return console.warn("[snapdom] Failed to fetch font resource:",m),null}}))),i=s;for(let p of o)p&&(i=i.replace(p.original,p.inlined));d+=i+`
3
- `}catch(a){console.warn("[snapdom] Failed to fetch CSS:",n.href)}for(let n of document.styleSheets)try{if(!n.href||l.every(a=>a.href!==n.href)){for(let a of n.cssRules)if(a.type===CSSRule.FONT_FACE_RULE){let s=a.style.getPropertyValue("src"),c=a.style.getPropertyValue("font-family");if(!s||$(c))continue;let o=/url\((["']?)([^"')]+)\1\)/g,i=/local\((["']?)[^)]+?\1\)/g,p=!!s.match(o),u=!!s.match(i);if(!p&&u){d+=`@font-face{font-family:${c};src:${s};font-style:${a.style.getPropertyValue("font-style")||"normal"};font-weight:${a.style.getPropertyValue("font-weight")||"normal"};}`;continue}let m=s,h=Array.from(s.matchAll(o));for(let y of h){let S=y[2].trim();if(!S)continue;let w=S;if(!w.startsWith("http")&&!w.startsWith("data:")&&(w=new URL(w,n.href||location.href).href),!$(w)){if(f.resource.has(w)){f.font.add(w),m=m.replace(y[0],`url(${f.resource.get(w)})`);continue}if(!f.font.has(w))try{let T=yield(yield fetch(w)).blob(),k=yield new Promise(F=>{let I=new FileReader;I.onload=()=>F(I.result),I.readAsDataURL(T)});f.resource.set(w,k),f.font.add(w),m=m.replace(y[0],`url(${k})`)}catch(b){console.warn("[snapdom] Failed to fetch font URL:",w)}}}d+=`@font-face{font-family:${c};src:${m};font-style:${a.style.getPropertyValue("font-style")||"normal"};font-weight:${a.style.getPropertyValue("font-weight")||"normal"};}`}}}catch(a){console.warn("[snapdom] Cannot access stylesheet",n.href,a)}for(let n of document.fonts)if(n.family&&n.status==="loaded"&&n._snapdomSrc){if($(n.family))continue;let a=n._snapdomSrc;if(!a.startsWith("data:")){if(f.resource.has(n._snapdomSrc))a=f.resource.get(n._snapdomSrc),f.font.add(n._snapdomSrc);else if(!f.font.has(n._snapdomSrc))try{let c=yield(yield fetch(n._snapdomSrc)).blob();a=yield new Promise(o=>{let i=new FileReader;i.onload=()=>o(i.result),i.readAsDataURL(c)}),f.resource.set(n._snapdomSrc,a),f.font.add(n._snapdomSrc)}catch(s){console.warn("[snapdom] Failed to fetch dynamic font src:",n._snapdomSrc);continue}}d+=`@font-face{font-family:'${n.family}';src:url(${a});font-style:${n.style||"normal"};font-weight:${n.weight||"normal"};}`}if(d&&(f.resource.set("fonts-embed-css",d),e)){let n=document.createElement("style");n.setAttribute("data-snapdom","embedFonts"),n.textContent=d,document.head.appendChild(n)}return d})}function se(e,t,r){return g(this,null,function*(){var n;if(!(e instanceof Element)||!(t instanceof Element))return;for(let a of["::before","::after","::first-letter"])try{let s=A(e,a);if(!s||typeof s[Symbol.iterator]!="function"||s.content==="none"&&s.backgroundImage==="none"&&s.backgroundColor==="transparent"&&(s.borderStyle==="none"||parseFloat(s.borderWidth)===0)&&(!s.transform||s.transform==="none")&&s.display==="inline")continue;if(a==="::first-letter"){let E=getComputedStyle(e);if(!(s.color!==E.color||s.fontSize!==E.fontSize||s.fontWeight!==E.fontWeight))continue;let L=Array.from(t.childNodes).find(pe=>{var me;return pe.nodeType===Node.TEXT_NODE&&((me=pe.textContent)==null?void 0:me.trim().length)>0});if(!L)continue;let U=L.textContent,ne=U.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u),B=ne==null?void 0:ne[0],Ue=U.slice((B==null?void 0:B.length)||0);if(!B||/[\uD800-\uDFFF]/.test(B))continue;let K=document.createElement("span");K.textContent=B,K.dataset.snapdomPseudo="::first-letter";let Be=ae(s),We=_(Be,"span",r);f.preStyleMap.set(K,We);let fe=document.createTextNode(Ue);t.replaceChild(fe,L),t.insertBefore(K,fe);continue}let o=s.content,i=/counter\s*\(|counters\s*\(/.test(o)?"- ":Ce(o),p=s.backgroundImage,u=s.backgroundColor,m=s.fontFamily,h=parseInt(s.fontSize)||32,y=parseInt(s.fontWeight)||!1,S=s.color||"#000",w=s.display,b=parseFloat(s.width),T=parseFloat(s.height),k=s.borderStyle,F=parseFloat(s.borderWidth),I=s.transform,N=$(m),j=o!=="none"&&i!=="",z=p&&p!=="none",V=u&&u!=="transparent"&&u!=="rgba(0, 0, 0, 0)",Q=w!=="inline"&&(b>0||T>0),Z=k&&k!=="none"&&F>0,M=I&&I!=="none";if(!(j||z||V||Q||Z||M))continue;let C=document.createElement("span");C.dataset.snapdomPseudo=a,C.style.verticalAlign="middle";let ee=ae(s),te=_(ee,"span",r);if(f.preStyleMap.set(C,te),N&&i.length===1){let{dataUrl:E,width:v,height:L}=yield ke(i,m,y,h,S),U=document.createElement("img");U.src=E,U.style=`height:${h}px;width:${v/L*h}px;object-fit:contain;`,C.appendChild(U),t.dataset.snapdomHasIcon="true"}else if(i.startsWith("url(")){let E=q(i);if(E!=null&&E.trim())try{let v=document.createElement("img"),L=yield P(G(E),r);v.src=L,v.style=`width:${h}px;height:auto;object-fit:contain;`,C.appendChild(v)}catch(v){console.error(`[snapdom] Error in pseudo ${a} for`,e,v)}}else!N&&j&&(C.textContent=i);if(z)try{let E=O(p),v=yield Promise.all(E.map(W));C.style.backgroundImage=v.join(", ")}catch(E){console.warn(`[snapdom] Failed to inline background-image for ${a}`,E)}if(V&&(C.style.backgroundColor=u),!(C.childNodes.length>0||((n=C.textContent)==null?void 0:n.trim())!==""||z||V||Q||Z||M))continue;a==="::before"?t.insertBefore(C,t.firstChild):t.appendChild(C)}catch(s){console.warn(`[snapdom] Failed to capture ${a} for`,e,s)}let l=Array.from(e.children),d=Array.from(t.children).filter(a=>!a.dataset.snapdomPseudo);for(let a=0;a<Math.min(l.length,d.length);a++)yield se(l[a],d[a],r)})}function Re(e){if(!e)return;let t=new Set;if(e.querySelectorAll("use").forEach(s=>{let c=s.getAttribute("xlink:href")||s.getAttribute("href");c&&c.startsWith("#")&&t.add(c.slice(1))}),!t.size)return;let r=Array.from(document.querySelectorAll("svg > symbol, svg > defs")),l=r.filter(s=>s.tagName.toLowerCase()==="symbol"),d=r.filter(s=>s.tagName.toLowerCase()==="defs"),n=e.querySelector("svg.inline-defs-container");n||(n=document.createElementNS("http://www.w3.org/2000/svg","svg"),n.setAttribute("aria-hidden","true"),n.setAttribute("style","position: absolute; width: 0; height: 0; overflow: hidden;"),n.classList.add("inline-defs-container"),e.insertBefore(n,e.firstChild));let a=new Set;e.querySelectorAll("symbol[id], defs > *[id]").forEach(s=>{a.add(s.id)}),t.forEach(s=>{if(a.has(s))return;let c=l.find(o=>o.id===s);if(c){n.appendChild(c.cloneNode(!0)),a.add(s);return}for(let o of d){let i=o.querySelector(`#${CSS.escape(s)}`);if(i){let p=n.querySelector("defs");p||(p=document.createElementNS("http://www.w3.org/2000/svg","defs"),n.appendChild(p)),p.appendChild(i.cloneNode(!0)),a.add(s);break}}})}function Ne(d){return g(this,arguments,function*(e,t=!1,r=!1,l={}){var s,c;let n,a="";ze(e);try{Re(e)}catch(o){console.warn("inlineExternal defs or symbol failed:",o)}try{n=H(e,t,l,e)}catch(o){throw console.warn("deepClone failed:",o),o}try{yield se(e,n,t,r,l.useProxy)}catch(o){console.warn("inlinePseudoElements failed:",o)}if(t){let o=xe();a=Array.from(o.entries()).map(([i,p])=>`.${p}{${i}}`).join("");for(let[i,p]of f.preStyleMap.entries()){if(i.tagName==="STYLE")continue;if(i.getRootNode&&i.getRootNode()instanceof ShadowRoot){i.setAttribute("style",p.replace(/;/g,"; "));continue}let u=o.get(p);u&&i.classList.add(u);let m=(s=i.style)==null?void 0:s.backgroundImage,h=(c=i.dataset)==null?void 0:c.snapdomHasIcon;m&&m!=="none"&&(i.style.backgroundImage=m),h&&(i.style.verticalAlign="middle",i.style.display="inline")}}else for(let[o,i]of f.preStyleMap.entries())o.tagName!=="STYLE"&&o.setAttribute("style",i.replace(/;/g,"; "));for(let[o,i]of f.preNodeMap.entries()){let p=i.scrollLeft,u=i.scrollTop;if((p||u)&&o instanceof HTMLElement){o.style.overflow="hidden",o.style.scrollbarWidth="none",o.style.msOverflowStyle="none";let h=document.createElement("div");for(h.style.transform=`translate(${-p}px, ${-u}px)`,h.style.willChange="transform",h.style.display="inline-block",h.style.width="100%";o.firstChild;)h.appendChild(o.firstChild);o.appendChild(h)}}if(e===f.preNodeMap.get(n)){let o=f.preStyle.get(e)||window.getComputedStyle(e);f.preStyle.set(e,o);let i=ve(o.transform);n.style.margin="0",n.style.position="static",n.style.top="auto",n.style.left="auto",n.style.right="auto",n.style.bottom="auto",n.style.zIndex="auto",n.style.float="none",n.style.clear="none",n.style.transform=i||""}for(let[o,i]of f.preNodeMap.entries())i.tagName==="PRE"&&(o.style.marginTop="0",o.style.marginBlockStart="0");return{clone:n,classCSS:a}})}function ze(e){let t=getComputedStyle(e),r=t.outlineStyle,l=t.outlineWidth,d=t.borderStyle,n=t.borderWidth,a=r!=="none"&&parseFloat(l)>0,s=d==="none"||parseFloat(n)===0;a&&s&&(e.style.border=`${l} solid transparent`)}function Ae(r){return g(this,arguments,function*(e,t={}){let l=Array.from(e.querySelectorAll("img")),d=n=>g(null,null,function*(){let a=n.src;try{let s=yield P(a,{useProxy:t.useProxy});n.src=s,n.width||(n.width=n.naturalWidth||100),n.height||(n.height=n.naturalHeight||100)}catch(s){let c=document.createElement("div");c.style=`width: ${n.width||100}px; height: ${n.height||100}px; background: #ccc; display: inline-block; text-align: center; line-height: ${n.height||100}px; color: #666; font-size: 12px;`,c.innerText="img",n.replaceWith(c)}});for(let n=0;n<l.length;n+=4){let a=l.slice(n,n+4).map(d);yield Promise.allSettled(a)}})}function Te(l,d){return g(this,arguments,function*(e,t,r={}){let n=[[e,t]],a=["background-image","mask","mask-image","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source","border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;n.length;){let[s,c]=n.shift(),o=f.preStyle.get(s)||A(s);f.preStyle.has(s)||f.preStyle.set(s,o);let i=(()=>{let h=o.getPropertyValue("border-image"),y=o.getPropertyValue("border-image-source");return h&&h!=="none"||y&&y!=="none"})();for(let h of a){if(["border-image-slice","border-image-width","border-image-outset","border-image-repeat"].includes(h)&&!i)continue;let y=o.getPropertyValue(h);if(!y||y==="none")continue;let S=O(y),w=yield Promise.all(S.map(b=>W(b,r)));w.some(b=>b&&b!=="none"&&!/^url\(undefined/.test(b))&&c.style.setProperty(h,w.join(", "))}let p=o.getPropertyValue("background-color");p&&p!=="transparent"&&p!=="rgba(0, 0, 0, 0)"&&(c.style.backgroundColor=p);let u=Array.from(s.children),m=Array.from(c.children);for(let h=0;h<Math.min(u.length,m.length);h++)n.push([u[h],m[h]])}})}function Me(r){return g(this,arguments,function*(e,t={}){if(!e)throw new Error("Element cannot be null or undefined");f.reset();let{compress:l=!0,embedFonts:d=!1,fast:n=!0,scale:a=1,useProxy:s=""}=t,c,o,i="",p="",u,m;if({clone:c,classCSS:o}=yield Ne(e,l,d,t),yield new Promise(y=>{D(()=>g(null,null,function*(){yield Ae(c,t),y()}),{fast:n})}),yield new Promise(y=>{D(()=>g(null,null,function*(){yield Te(e,c,t),y()}),{fast:n})}),d&&(yield new Promise(y=>{D(()=>g(null,null,function*(){i=yield J(),y()}),{fast:n})})),l){let y=be(c).sort(),S=y.join(",");f.baseStyle.has(S)?p=f.baseStyle.get(S):yield new Promise(w=>{D(()=>{p=Se(y),f.baseStyle.set(S,p),w()},{fast:n})})}yield new Promise(y=>{D(()=>{let S=e.getBoundingClientRect(),w=S.width,b=S.height,T=Number.isFinite(t.width),k=Number.isFinite(t.height),F=typeof a=="number"&&a!==1;if(!F){let M=S.width/S.height;T&&k?(w=t.width,b=t.height):T?(w=t.width,b=w/M):k&&(b=t.height,w=b*M)}if(w=Math.ceil(w),b=Math.ceil(b),c.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),c.style.transformOrigin="top left",!F&&(T||k)){let M=S.width,le=S.height,C=w/M,ee=b/le,te=c.style.transform||"",de=`scale(${C}, ${ee})`;c.style.transform=`${de} ${te}`.trim()}let I="http://www.w3.org/2000/svg",N=document.createElementNS(I,"foreignObject");N.setAttribute("width","100%"),N.setAttribute("height","100%");let j=document.createElement("style");j.textContent=p+i+"svg{overflow:visible;}"+o,N.appendChild(j),N.appendChild(c);let V=new XMLSerializer().serializeToString(N);m=`<svg xmlns="${I}" width="${w}" height="${b}" viewBox="0 0 ${w} ${b}">`+V+"</svg>",u=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(m)}`,y()},{fast:n})});let h=document.getElementById("snapdom-sandbox");return h&&h.style.position==="absolute"&&h.remove(),u})}function Ke(r){return g(this,arguments,function*(e,{scale:t=1}={}){let l=new Image;return l.src=e,yield l.decode(),t!==1&&(l.style.width=`${l.naturalWidth*t}px`,l.style.height=`${l.naturalHeight*t}px`),l})}function Le(l){return g(this,arguments,function*(e,{dpr:t=1,scale:r=1}={}){let d=new Image;d.src=e,d.crossOrigin="anonymous",d.loading="eager",d.decoding="sync";let n=Ee(),a=!1;if(n&&(document.body.appendChild(d),a=!0),yield d.decode(),n&&(yield new Promise(p=>setTimeout(p,100))),d.width===0||d.height===0)throw a&&d.remove(),new Error("Image failed to load or has no dimensions");let s=d.naturalWidth*r,c=d.naturalHeight*r,o=document.createElement("canvas");o.width=Math.ceil(s*t),o.height=Math.ceil(c*t),o.style.width=`${s}px`,o.style.height=`${c}px`;let i=o.getContext("2d");return i.scale(t,t),i.drawImage(d,0,0,s,c),a&&d.remove(),o})}function Pe(n){return g(this,arguments,function*(e,{type:t="svg",scale:r=1,backgroundColor:l="#fff",quality:d}={}){let a={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp"}[t]||"image/png";if(t==="svg"){let c=decodeURIComponent(e.split(",")[1]);return new Blob([c],{type:"image/svg+xml"})}let s=yield ce(e,{dpr:1,scale:r},l);return new Promise(c=>{s.toBlob(o=>c(o),`${a}`,d)})})}function ce(d,n,a){return g(this,arguments,function*(e,{dpr:t=1,scale:r=1},l){let s=yield Le(e,{dpr:t,scale:r});if(!l)return s;let c=document.createElement("canvas");c.width=s.width,c.height=s.height;let o=c.getContext("2d");return o.fillStyle=l,o.fillRect(0,0,c.width,c.height),o.drawImage(s,0,0),c})}function ie(a,s){return g(this,arguments,function*(e,{dpr:t=1,scale:r=1,backgroundColor:l,quality:d},n="png"){let c=["jpg","jpeg","webp"].includes(n)?"#fff":void 0,o=l!=null?l:c,i=yield ce(e,{dpr:t,scale:r},o),p=new Image;return p.src=i.toDataURL(`image/${n}`,d),yield p.decode(),p.style.width=`${i.width/t}px`,p.style.height=`${i.height/t}px`,p})}function Ye(a){return g(this,arguments,function*(e,{dpr:t=1,scale:r=1,backgroundColor:l,format:d="png",filename:n="snapDOM"}={}){if(d==="svg"){let m=yield Pe(e),h=URL.createObjectURL(m),y=document.createElement("a");y.href=h,y.download=`${n}.svg`,y.click(),URL.revokeObjectURL(h);return}let s=["jpg","jpeg","webp"].includes(d)?"#fff":void 0,c=l!=null?l:s,o=yield ce(e,{dpr:t,scale:r},c),i={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp"}[d]||"image/png",p=o.toDataURL(i),u=document.createElement("a");u.href=p,u.download=`${n}.${d}`,u.click()})}function x(r){return g(this,arguments,function*(e,t={}){if(t=R({scale:1},t),!e)throw new Error("Element cannot be null or undefined");return t.iconFonts&&$e(t.iconFonts),yield x.capture(e,t)})}x.capture=(r,...l)=>g(null,[r,...l],function*(e,t={}){var s;let d=yield Me(e,t),n=(s=t.dpr)!=null?s:window.devicePixelRatio||1,a=t.scale||1;return{url:d,options:t,toRaw:()=>d,toImg:(c={})=>Ke(d,R({dpr:n,scale:a},c)),toCanvas:(c={})=>Le(d,R({dpr:n,scale:a},c)),toBlob:(c={})=>Pe(d,R({dpr:n,scale:a},c)),toPng:(c={})=>ie(d,R({dpr:n,scale:a},c),"png"),toJpg:(c={})=>ie(d,R({dpr:n,scale:a},c),"jpeg"),toWebp:(c={})=>ie(d,R({dpr:n,scale:a},c),"webp"),download:(u={})=>{var m=u,{format:c="png",filename:o="snapDOM",backgroundColor:i}=m,p=oe(m,["format","filename","backgroundColor"]);return Ye(d,R({dpr:n,scale:a,format:c,filename:o,backgroundColor:i},p))}}});x.toRaw=(e,t)=>g(null,null,function*(){return(yield x.capture(e,t)).toRaw()});x.toImg=(e,t)=>g(null,null,function*(){return(yield x.capture(e,t)).toImg()});x.toCanvas=(e,t)=>g(null,null,function*(){return(yield x.capture(e,t)).toCanvas()});x.toBlob=(e,t)=>g(null,null,function*(){return(yield x.capture(e,t)).toBlob(t)});x.toPng=(e,t)=>g(null,null,function*(){return(yield x.capture(e,t)).toPng(t)});x.toJpg=(e,t)=>g(null,null,function*(){return(yield x.capture(e,t)).toJpg(t)});x.toWebp=(e,t)=>g(null,null,function*(){return(yield x.capture(e,t)).toWebp(t)});x.download=(r,...l)=>g(null,[r,...l],function*(e,t={}){let o=t,{format:d="png",filename:n="capture",backgroundColor:a}=o,s=oe(o,["format","filename","backgroundColor"]);return yield(yield x.capture(e,s)).download({format:d,filename:n,backgroundColor:a})});function Fe(){return g(this,arguments,function*(e=document,t={}){let{embedFonts:r=!0,reset:l=!1}=t;if(l){f.reset();return}yield document.fonts.ready,ye();let d=[],n=[];e!=null&&e.querySelectorAll&&(d=Array.from(e.querySelectorAll("img[src]")),n=Array.from(e.querySelectorAll("*")));let a=[];for(let s of d){let c=s.src;f.image.has(c)||a.push(P(c,{useProxy:t.useProxy}).then(o=>f.image.set(c,o)).catch(()=>{}))}for(let s of n){let c=A(s).backgroundImage;if(c&&c!=="none"){let o=O(c);for(let i of o)i.startsWith("url(")&&a.push(W(i,t).catch(()=>{}))}}r&&(yield J({preCached:!0})),yield Promise.all(a)})}typeof window!="undefined"&&(window.snapdom=x,window.preCache=Fe);})();
1
+ (()=>{var ke=Object.defineProperty,Fe=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var Le=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable;var ne=(t,e,n)=>e in t?ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,H=(t,e)=>{for(var n in e||(e={}))Le.call(e,n)&&ne(t,n,e[n]);if(ee)for(var n of ee(e))Re.call(e,n)&&ne(t,n,e[n]);return t},X=(t,e)=>Fe(t,ve(e));var C=(t,e,n)=>new Promise((o,r)=>{var s=i=>{try{l(n.next(i))}catch(u){r(u)}},a=i=>{try{l(n.throw(i))}catch(u){r(u)}},l=i=>i.done?o(i.value):Promise.resolve(i.value).then(s,a);l((n=n.apply(t,e)).next())});var m={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 At(t="soft"){switch(t){case"auto":{m.session.styleMap=new Map,m.session.nodeMap=new Map;return}case"soft":{m.session.styleMap=new Map,m.session.nodeMap=new Map,m.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{m.session.styleMap=new Map,m.session.nodeMap=new Map,m.session.styleCache=new WeakMap,m.image.clear(),m.background.clear(),m.resource.clear(),m.font.clear();return}default:{m.session.styleMap=new Map,m.session.nodeMap=new Map,m.session.styleCache=new WeakMap;return}}}function at(t){let e=t.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function Wt(t){if(!t||t==="none")return"";let e=t.replace(/translate[XY]?\([^)]*\)/g,"");return e=e.replace(/matrix\(([^)]+)\)/g,(n,o)=>{let r=o.split(",").map(s=>s.trim());return r.length!==6?`matrix(${o})`:(r[4]="0",r[5]="0",`matrix(${r.join(", ")})`)}),e=e.replace(/matrix3d\(([^)]+)\)/g,(n,o)=>{let r=o.split(",").map(s=>s.trim());return r.length!==16?`matrix3d(${o})`:(r[12]="0",r[13]="0",`matrix3d(${r.join(", ")})`)}),e.trim().replace(/\s{2,}/g," ")}function yt(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch(e){return t}}function Me(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,r=0;function s(a,l,i){if(r>=n)return;let u=Date.now();(o.get(l)||0)>u||(o.set(l,u+e),r++,a==="warn"&&console&&console.warn?console.warn(`${t} ${i}`):console&&console.error&&console.error(`${t} ${i}`))}return{warnOnce(a,l){s("warn",a,l)},errorOnce(a,l){s("error",a,l)},reset(){o.clear(),r=0}}}var oe=Me("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),qt=new Map,$t=new Map;function Ne(t){return/^data:|^blob:|^about:blank$/.test(t)}function Te(t,e){if(!e||Ne(t))return!1;try{let n=typeof location!="undefined"&&location.href?location.href:"http://localhost/",o=new URL(t,n);return typeof location!="undefined"?o.origin!==location.origin:!0}catch(n){return!!e}}function Ie(t,e){if(!e)return t;if(e.includes("{url}"))return e.replace("{url}",encodeURIComponent(t));let n=e.endsWith("?")?"":e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function _e(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 Pe(t,e){var n,o;return[e.as||"blob",(n=e.timeout)!=null?n:3e3,e.useProxy||"",(o=e.errorTTL)!=null?o:8e3,t].join("|")}function D(n){return C(this,arguments,function*(t,e={}){var _,I,R;let o=(_=e.as)!=null?_:"blob",r=(I=e.timeout)!=null?I:3e3,s=e.useProxy||"",a=(R=e.errorTTL)!=null?R:8e3,l=e.headers||{},i=!!e.silent,u=Pe(t,{as:o,timeout:r,useProxy:s,errorTTL:a}),f=$t.get(u);if(f&&f.until>Date.now())return X(H({},f.result),{fromCache:!0});f&&$t.delete(u);let c=qt.get(u);if(c)return c;let h=Te(t,s)?Ie(t,s):t,S=e.credentials;if(!S)try{let W=typeof location!="undefined"&&location.href?location.href:"http://localhost/",P=new URL(t,W);S=typeof location!="undefined"&&P.origin===location.origin?"include":"omit"}catch(W){S="omit"}let $=new AbortController,w=setTimeout(()=>$.abort("timeout"),r),v=C(null,null,function*(){var W,P;try{let F=yield fetch(h,{signal:$.signal,credentials:S,headers:l});if(!F.ok){let z={ok:!1,data:null,status:F.status,url:h,fromCache:!1,reason:"http_error"};if($t.set(u,{until:Date.now()+a,result:z}),!i){let G=`${F.status} ${F.statusText||""}`.trim();oe.warnOnce(`http:${F.status}:${o}:${new URL(t,(W=location==null?void 0:location.href)!=null?W:"http://localhost/").origin}`,`HTTP error ${G} while fetching ${o} ${t}`)}return e.onError&&e.onError(z),z}if(o==="text")return{ok:!0,data:yield F.text(),status:F.status,url:h,fromCache:!1};let q=yield F.blob(),j=q.type||F.headers.get("content-type")||"";return o==="dataURL"?{ok:!0,data:yield _e(q),status:F.status,url:h,fromCache:!1,mime:j}:{ok:!0,data:q,status:F.status,url:h,fromCache:!1,mime:j}}catch(F){let q=F&&typeof F=="object"&&"name"in F&&F.name==="AbortError"?String(F.message||"").includes("timeout")?"timeout":"abort":"network",j={ok:!1,data:null,status:0,url:h,fromCache:!1,reason:q};if($t.set(u,{until:Date.now()+a,result:j}),!i){let z=`${q}:${o}:${new URL(t,(P=location==null?void 0:location.href)!=null?P:"http://localhost/").origin}`,G=q==="timeout"?`Timeout after ${r}ms. Consider increasing timeout or using a proxy for ${t}`:q==="abort"?`Request aborted while fetching ${o} ${t}`:`Network/CORS issue while fetching ${o} ${t}. A proxy may be required`;oe.errorOnce(z,G)}return e.onError&&e.onError(j),j}finally{clearTimeout(w),qt.delete(u)}});return qt.set(u,v),v})}function it(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}function ct(n){return C(this,arguments,function*(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(t)||t.trim()==="none")return t;let r=at(t);if(!r)return t;let s=yt(r);if(m.background.has(s)){let a=m.background.get(s);return a?`url("${a}")`:"none"}try{let a=yield D(s,{as:"dataURL",useProxy:e.useProxy});return a.ok?(m.background.set(s,a.data),`url("${a.data}")`):(m.background.set(s,null),"none")}catch(a){return m.background.set(s,null),"none"}})}var Et=new Set(["meta","script","noscript","title","link","template"]),ht=new Set(["meta","link","style","title","noscript","script","template","svg","g","defs","use","marker","mask","clipPath","pattern","path","polygon","polyline","line","circle","ellipse","rect","filter","lineargradient","radialgradient","stop"]),Ue=["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 Dt(){for(let t of Ue){let e=String(t).toLowerCase();Et.has(e)||ht.has(e)||jt(e)}}function jt(t){if(t=String(t).toLowerCase(),ht.has(t)){let s={};return m.defaultStyle.set(t,s),s}if(m.defaultStyle.has(t))return m.defaultStyle.get(t);let e=document.getElementById("snapdom-sandbox");e||(e=document.createElement("div"),e.id="snapdom-sandbox",e.setAttribute("data-snapdom-sandbox","true"),e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.width="0px",e.style.height="0px",e.style.overflow="hidden",document.body.appendChild(e));let n=document.createElement(t);n.style.all="initial",e.appendChild(n);let o=getComputedStyle(n),r={};for(let s of o){if(re(s))continue;let a=o.getPropertyValue(s);r[s]=a}return e.removeChild(n),m.defaultStyle.set(t,r),r}var Be=/(?:^|-)(animation|transition)(?:-|$)/i,Oe=/^(--|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,We=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 re(t){let e=String(t).toLowerCase();return!!(We.has(e)||Oe.test(e)||Be.test(e))}function pt(t,e){if(e=String(e||"").toLowerCase(),ht.has(e))return"";let n=[],o=jt(e);for(let[r,s]of Object.entries(t)){if(re(r))continue;let a=o[r];s&&s!==a&&n.push(`${r}:${s}`)}return n.sort(),n.join(";")}function zt(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 Vt(t){let e=new Map;for(let o of t){let r=m.defaultStyle.get(o);if(!r)continue;let s=Object.entries(r).map(([a,l])=>`${a}:${l};`).sort().join("");s&&(e.has(s)||e.set(s,[]),e.get(s).push(o))}let n="";for(let[o,r]of e.entries())n+=`${r.join(",")} { ${o} }
2
+ `;return n}function Ht(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 lt(t,e=null){if(!(t instanceof Element))return window.getComputedStyle(t,e);let n=m.computedStyle.get(t);if(n||(n=new Map,m.computedStyle.set(t,n)),!n.has(e)){let o=window.getComputedStyle(t,e);n.set(e,o)}return n.get(e)}function Gt(t){let e=t.replace(/^['"]|['"]$/g,"");if(e.startsWith("\\"))try{return String.fromCharCode(parseInt(e.replace("\\",""),16))}catch(n){return e}return e}function kt(t){let e={};for(let n of t)e[n]=t.getPropertyValue(n);return e}function ft(t){let e=[],n=0,o=0;for(let r=0;r<t.length;r++){let s=t[r];s==="("&&n++,s===")"&&n--,s===","&&n===0&&(e.push(t.slice(o,r).trim()),o=r+1)}return e.push(t.slice(o).trim()),e}function ut(t,{fast:e=!1}={}){if(e)return t();"requestIdleCallback"in window?requestIdleCallback(t,{timeout:50}):setTimeout(t,1)}function tt(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}var se=new WeakMap,ae=new Map,Kt=0;function Ft(){Kt++}var ie=!1;function qe(t=document.documentElement){var e,n;if(!ie){ie=!0;try{new MutationObserver(()=>Ft()).observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch(o){}try{new MutationObserver(()=>Ft()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch(o){}try{let o=document.fonts;o&&((e=o.addEventListener)==null||e.call(o,"loadingdone",Ft),(n=o.ready)==null||n.then(()=>Ft()).catch(()=>{}))}catch(o){}}}function De(t){let e={},n=t.getPropertyValue("visibility");for(let o=0;o<t.length;o++){let r=t[o],s=t.getPropertyValue(r);(r==="background-image"||r==="content")&&s.includes("url(")&&!s.includes("data:")&&(s="none"),e[r]=s}return n==="hidden"&&(e.opacity="0"),e}var ce=new WeakMap;function je(t){let e=ce.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(";"),ce.set(t,e),e)}function ze(t,e=null){let n=se.get(t);if(n&&n.epoch===Kt)return n.snapshot;let o=e||getComputedStyle(t),r=De(o);return se.set(t,{epoch:Kt,snapshot:r}),r}function Ve(t,e){return t&&t.session&&t.persist?t:t&&(t.styleMap||t.styleCache||t.nodeMap)?{session:t,persist:{snapshotKeyCache:ae,defaultStyle:m.defaultStyle,baseStyle:m.baseStyle,image:m.image,resource:m.resource,background:m.background,font:m.font},options:e||{}}:{session:m.session,persist:{snapshotKeyCache:ae,defaultStyle:m.defaultStyle,baseStyle:m.baseStyle,image:m.image,resource:m.resource,background:m.background,font:m.font},options:t||e||{}}}function vt(t,e,n,o){return C(this,null,function*(){var h,S,$;if(t.tagName==="STYLE")return;let r=Ve(n,o);if((r.options&&r.options.cache||"auto")!=="disabled"&&qe(document.documentElement),ht.has((h=t.tagName)==null?void 0:h.toLowerCase())){let w=(S=t.getAttribute)==null?void 0:S.call(t,"style");w&&e.setAttribute("style",w)}let{session:a,persist:l}=r;a.styleCache.has(t)||a.styleCache.set(t,getComputedStyle(t));let i=a.styleCache.get(t),u=ze(t,i),f=je(u),c=l.snapshotKeyCache.get(f);if(!c){let w=(($=t.tagName)==null?void 0:$.toLowerCase())||"div";c=pt(u,w),l.snapshotKeyCache.set(f,c)}a.styleMap.set(e,c)})}function He(t){return t=t.trim(),!t||/\:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(t)?t:`${t}:not([data-sd-slotted])`}function Ge(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?He(o):o;return`:where(${e} ${r})`}).join(", ")}function Ke(t,e){return t?(t=t.replace(/:host\(([^)]+)\)/g,(n,o)=>`:where(${e}:is(${o.trim()}))`),t=t.replace(/:host\b/g,`:where(${e})`),t=t.replace(/:host-context\(([^)]+)\)/g,(n,o)=>`:where(:where(${o.trim()}) ${e})`),t=t.replace(/::slotted\(([^)]+)\)/g,(n,o)=>`:where(${e} ${o.trim()})`),t=t.replace(/(^|})(\s*)([^@}{]+){/g,(n,o,r,s)=>{let a=Ge(s,e,!0);return`${o}${r}${a}{`}),t):""}function Xe(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}function Ye(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(r){}}catch(n){}return e}function Je(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 Ze(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(n){}}function Qe(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 tn(t,e){try{let o=getComputedStyle(t).getPropertyValue(e).trim();if(o)return o}catch(n){}try{let o=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(o)return o}catch(n){}return""}function en(t,e,n){let o=[];for(let r of e){let s=tn(t,r);s&&o.push(`${r}: ${s};`)}return o.length?`${n}{${o.join("")}}
5
+ `:""}function nn(t){t&&(t.nodeType===Node.ELEMENT_NODE&&t.setAttribute("data-sd-slotted",""),t.querySelectorAll&&t.querySelectorAll("*").forEach(e=>e.setAttribute("data-sd-slotted","")))}function wt(t,e,n){var a,l,i,u,f;if(!t)throw new Error("Invalid node");let o=new Set,r=null;if(t.nodeType===Node.ELEMENT_NODE){let c=(t.localName||t.tagName||"").toLowerCase();if(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox")||Et.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"){let c=document.createElement("div"),h=t.getBoundingClientRect();return c.style.cssText=`display:inline-block;width:${h.width}px;height:${h.height}px;visibility:hidden;`,c}if(n.exclude&&Array.isArray(n.exclude))for(let c of n.exclude)try{if((a=t.matches)!=null&&a.call(t,c)){let h=document.createElement("div"),S=t.getBoundingClientRect();return h.style.cssText=`display:inline-block;width:${S.width}px;height:${S.height}px;visibility:hidden;`,h}}catch(h){console.warn(`Invalid selector in exclude option: ${c}`,h)}if(typeof n.filter=="function")try{if(!n.filter(t)){let c=document.createElement("div"),h=t.getBoundingClientRect();return c.style.cssText=`display:inline-block;width:${h.width}px;height:${h.height}px;visibility:hidden;`,c}}catch(c){console.warn("Error in filter function:",c)}if(t.tagName==="IFRAME"){let c=document.createElement("div");return c.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;`,c}if(t.getAttribute("data-capture")==="placeholder"){let c=t.cloneNode(!1);e.nodeMap.set(c,t),vt(t,c,e,n);let h=document.createElement("div");return h.textContent=t.getAttribute("data-placeholder-text")||"",h.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",c.appendChild(h),c}if(t.tagName==="CANVAS"){let c=t.toDataURL(),h=document.createElement("img");return h.src=c,h.width=t.width,h.height=t.height,e.nodeMap.set(h,t),vt(t,h,e,n),h}let s;try{s=t.cloneNode(!1),e.nodeMap.set(s,t),t.tagName==="IMG"&&Ze(t,s)}catch(c){throw console.error("[Snapdom] Failed to clone node:",t,c),c}if(t instanceof HTMLTextAreaElement){s.textContent=t.value,s.value=t.value;let c=t.getBoundingClientRect();return s.style.width=`${c.width}px`,s.style.height=`${c.height}px`,s}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),vt(t,s,e,n),t.shadowRoot){try{let I=t.shadowRoot.querySelectorAll("slot");for(let R of I){let W=[];try{W=((l=R.assignedNodes)==null?void 0:l.call(R,{flatten:!0}))||((i=R.assignedNodes)==null?void 0:i.call(R))||[]}catch(P){W=((u=R.assignedNodes)==null?void 0:u.call(R))||[]}for(let P of W)o.add(P)}}catch(I){}let c=Xe(e),h=`[data-sd="${c}"]`;try{s.setAttribute("data-sd",c)}catch(I){}let S=Ye(t.shadowRoot),$=Ke(S,h),w=Qe(S),v=en(t,w,h);Je(s,v+$,c);let _=document.createDocumentFragment();for(let I of t.shadowRoot.childNodes){if(I.nodeType===Node.ELEMENT_NODE&&I.tagName==="STYLE")continue;let R=wt(I,e,n);R&&_.appendChild(R)}s.appendChild(_)}if(t.tagName==="SLOT"){let c=((f=t.assignedNodes)==null?void 0:f.call(t,{flatten:!0}))||[],h=c.length>0?c:Array.from(t.childNodes),S=document.createDocumentFragment();for(let $ of h){let w=wt($,e,n);w&&(nn(w),S.appendChild(w))}return S}for(let c of t.childNodes){if(o.has(c))continue;let h=wt(c,e,n);h&&s.appendChild(h)}if(r!==null&&s instanceof HTMLSelectElement){s.value=r;for(let c of s.options)c.value===r?c.setAttribute("selected",""):c.removeAttribute("selected")}return s}var on=[/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],Xt=[];function le(t){let e=Array.isArray(t)?t:[t];for(let n of e)n instanceof RegExp?Xt.push(n):typeof n=="string"?Xt.push(new RegExp(n,"i")):console.warn("[snapdom] Ignored invalid iconFont value:",n)}function Y(t){let e=typeof t=="string"?t:"",n=[...on,...Xt];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))}function fe(t,e,n,o=32,r="#000"){return C(this,null,function*(){e=e.replace(/^['"]+|['"]+$/g,"");let s=window.devicePixelRatio||1;yield document.fonts.ready;let a=document.createElement("span");a.textContent=t,a.style.position="absolute",a.style.visibility="hidden",a.style.fontFamily=`"${e}"`,a.style.fontWeight=n||"normal",a.style.fontSize=`${o}px`,a.style.lineHeight="1",a.style.whiteSpace="nowrap",a.style.padding="0",a.style.margin="0",document.body.appendChild(a);let l=a.getBoundingClientRect(),i=Math.ceil(l.width),u=Math.ceil(l.height);document.body.removeChild(a);let f=document.createElement("canvas");f.width=i*s,f.height=u*s;let c=f.getContext("2d");return c.scale(s,s),c.font=n?`${n} ${o}px "${e}"`:`${o}px "${e}"`,c.textAlign="left",c.textBaseline="top",c.fillStyle=r,c.fillText(t,0,0),{dataUrl:f.toDataURL(),width:i,height:u}})}var rn=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]);function Lt(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^['"]+|['"]+$/g,"");if(n&&!rn.has(n.toLowerCase()))return n}return""}function Rt(t){let e=String(t!=null?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 Yt(t){let e=String(t!=null?t:"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function sn(t){let e=String(t!=null?t:"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function an(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let r=Rt(n[1]),s=Rt(n[2]);return{min:Math.min(r,s),max:Math.max(r,s)}}let o=Rt(e);return{min:o,max:o}}function cn(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function ln(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let s=parseFloat(n[1]),a=parseFloat(n[2]);return{min:Math.min(s,a),max:Math.max(s,a)}}let o=e.match(/(\d+(?:\.\d+)?)\s*%/),r=o?parseFloat(o[1]):100;return{min:r,max:r}}function fn(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 a=(n.pathname+n.search).toLowerCase();if(/\bfont(s)?\b/.test(a)||/\.woff2?(\b|$)/.test(a))return!0;for(let l of e){let i=l.toLowerCase().replace(/\s+/g,"+"),u=l.toLowerCase().replace(/\s+/g,"-");if(a.includes(i)||a.includes(u))return!0}return!1}catch(n){return!1}}function un(t){var n;let e=new Set;for(let o of t||[]){let r=(n=String(o).split("__")[0])==null?void 0:n.trim();r&&e.add(r)}return e}function Mt(){return C(this,arguments,function*({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:o=[],useProxy:r=""}={}){var j,z,G,K,nt,ot,rt,gt,B,xt,Ct,Bt,Ot,O,V,J,Q,dt;t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let s=new Map;for(let d of t){let[y,g,x,p]=String(d).split("__");if(!y)continue;let b=s.get(y)||[];b.push({w:parseInt(g,10),s:x,st:parseInt(p,10)}),s.set(y,b)}let a=/@import\s+url\(["']?([^"')]+)["']?\)/g,l=/url\((["']?)([^"')]+)\1\)/g,i=/@font-face[^{}]*\{[^}]*\}/g;function u(d,y,g,x){if(!s.has(d))return!1;let p=s.get(d),b=an(g),A=cn(y),E=ln(x),k=b.min!==b.max,M=b.min,L=T=>A.kind==="normal"&&T==="normal"||A.kind!=="normal"&&(T==="italic"||T==="oblique"),N=!1;for(let T of p){let Z=k?T.w>=b.min&&T.w<=b.max:T.w===M,st=L(Yt(T.s)),mt=T.st>=E.min&&T.st<=E.max;if(Z&&st&&mt){N=!0;break}}if(N)return!0;if(!k)for(let T of p){let Z=L(Yt(T.s)),st=T.st>=E.min&&T.st<=E.max;if(Math.abs(M-T.w)<=300&&Z&&st)return!0}return!1}function f(d){if(!d)return[];let y=[],g=d.split(",").map(x=>x.trim()).filter(Boolean);for(let x of g){let p=x.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!p)continue;let b=p[1],A=p[2],E=k=>{if(!k.includes("?"))return parseInt(k,16);let M=parseInt(k.replace(/\?/g,"0"),16),L=parseInt(k.replace(/\?/g,"F"),16);return[M,L]};if(A){let k=E(b),M=E(A),L=Array.isArray(k)?k[0]:k,N=Array.isArray(M)?M[1]:M;y.push([Math.min(L,N),Math.max(L,N)])}else{let k=E(b);Array.isArray(k)?y.push([k[0],k[1]]):y.push([k,k])}}return y}function c(d,y){if(!y.length||!d||d.size===0)return!0;for(let g of d)for(let[x,p]of y)if(g>=x&&g<=p)return!0;return!1}function h(d,y){let g=[];if(!d)return g;for(let x of d.matchAll(l)){let p=(x[2]||"").trim();if(!(!p||p.startsWith("data:"))){if(!/^https?:/i.test(p))try{p=new URL(p,y||location.href).href}catch(b){}g.push(p)}}return g}function S(d,y){return C(this,null,function*(){var x,p,b,A,E;let g=d;for(let k of d.matchAll(l)){let M=at(k[0]);if(!M)continue;let L=M;if(!L.startsWith("http")&&!L.startsWith("data:"))try{L=new URL(L,y||location.href).href}catch(N){}if(!Y(L)){if((x=m.resource)!=null&&x.has(L)){(p=m.font)==null||p.add(L),g=g.replace(k[0],`url(${m.resource.get(L)})`);continue}if(!((b=m.font)!=null&&b.has(L)))try{let N=yield D(L,{as:"dataURL",useProxy:r,silent:!0});if(N.ok&&typeof N.data=="string"){let T=N.data;(A=m.resource)==null||A.set(L,T),(E=m.font)==null||E.add(L),g=g.replace(k[0],`url(${T})`)}}catch(N){console.warn("[snapDOM] Failed to fetch font resource:",L)}}}return g})}function $(d){if(!d.length)return null;let y=(E,k)=>d.some(([M,L])=>!(L<E||M>k)),g=y(0,255)||y(305,305),x=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":x?"latin-ext":g?"latin":null}function w(d={}){let y=new Set((d.families||[]).map(p=>String(p).toLowerCase())),g=new Set((d.domains||[]).map(p=>String(p).toLowerCase())),x=new Set((d.subsets||[]).map(p=>String(p).toLowerCase()));return(p,b)=>{if(y.size&&y.has(p.family.toLowerCase()))return!0;if(g.size)for(let A of p.srcUrls)try{if(g.has(new URL(A).host.toLowerCase()))return!0}catch(E){}if(x.size){let A=$(b);if(A&&x.has(A))return!0}return!1}}let v=w(n);function _(d){var b,A,E,k,M,L;if(!d)return d;let y=/@font-face[^{}]*\{[^}]*\}/gi,g=new Set,x=[];for(let N of d.match(y)||[]){let T=((b=N.match(/font-family:\s*([^;]+);/i))==null?void 0:b[1])||"",Z=Lt(T),st=(((A=N.match(/font-weight:\s*([^;]+);/i))==null?void 0:A[1])||"400").trim(),mt=(((E=N.match(/font-style:\s*([^;]+);/i))==null?void 0:E[1])||"normal").trim(),Ce=(((k=N.match(/font-stretch:\s*([^;]+);/i))==null?void 0:k[1])||"100%").trim(),Ae=(((M=N.match(/unicode-range:\s*([^;]+);/i))==null?void 0:M[1])||"").trim(),Zt=(((L=N.match(/src\s*:\s*([^;]+);/i))==null?void 0:L[1])||"").trim(),Qt=h(Zt,location.href),$e=Qt.length?Qt.map(Ee=>String(Ee).toLowerCase()).sort().join("|"):Zt.toLowerCase(),te=[String(Z||"").toLowerCase(),st,mt,Ce,Ae.toLowerCase(),$e].join("|");g.has(te)||(g.add(te),x.push(N))}if(x.length===0)return d;let p=0;return d.replace(y,()=>x[p++]||"")}function I(){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()}):"",g=(o||[]).map(p=>`${(p.family||"").toLowerCase()}::${p.weight||"normal"}::${p.style||"normal"}::${p.src||""}`).sort().join("|");return`fonts-embed-css::req=${d}::ex=${y}::lf=${g}::px=${r||""}`}let R=I();if((j=m.resource)!=null&&j.has(R))return m.resource.get(R);let W=un(t),P=[];for(let d of document.querySelectorAll("style")){let y=d.textContent||"";for(let g of y.matchAll(a)){let x=g[1];if(!x||Y(x))continue;!!document.querySelector(`link[rel="stylesheet"][href="${x}"]`)||P.push(x)}}P.length&&(yield Promise.all(P.map(d=>new Promise(y=>{if(document.querySelector(`link[rel="stylesheet"][href="${d}"]`))return y(null);let g=document.createElement("link");g.rel="stylesheet",g.href=d,g.setAttribute("data-snapdom","injected-import"),g.onload=()=>y(g),g.onerror=()=>y(null),document.head.appendChild(g)}))));let F="",q=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(d=>!!d.href);for(let d of q)try{if(Y(d.href))continue;let y="",g=!1;try{g=new URL(d.href,location.href).origin===location.origin}catch(p){}if(!g&&!fn(d.href,W))continue;if(g){let p=Array.from(document.styleSheets).find(b=>b.href===d.href);if(p)try{let b=p.cssRules||[];y=Array.from(b).map(A=>A.cssText).join("")}catch(b){}}if(!y&&(y=(yield D(d.href,{as:"text",useProxy:r})).data,Y(d.href)))continue;let x="";for(let p of y.match(i)||[]){let b=(((z=p.match(/font-family:\s*([^;]+);/i))==null?void 0:z[1])||"").trim(),A=Lt(b);if(!A||Y(A))continue;let E=(((G=p.match(/font-weight:\s*([^;]+);/i))==null?void 0:G[1])||"400").trim(),k=(((K=p.match(/font-style:\s*([^;]+);/i))==null?void 0:K[1])||"normal").trim(),M=(((nt=p.match(/font-stretch:\s*([^;]+);/i))==null?void 0:nt[1])||"100%").trim(),L=(((ot=p.match(/unicode-range:\s*([^;]+);/i))==null?void 0:ot[1])||"").trim(),N=(((rt=p.match(/src\s*:\s*([^;]+);/i))==null?void 0:rt[1])||"").trim(),T=h(N,d.href);if(!u(A,k,E,M))continue;let Z=f(L);if(!c(e,Z))continue;let st={family:A,weightSpec:E,styleSpec:k,stretchSpec:M,unicodeRange:L,srcRaw:N,srcUrls:T,href:d.href};if(n&&v(st,Z))continue;let mt=/url\(/i.test(N)?yield S(p,d.href):p;x+=mt+""}x.trim()&&(F+=x+"")}catch(y){console.warn("[snapdom] Failed to process stylesheet:",d.href)}for(let d of document.styleSheets)try{if(d.href&&q.some(g=>g.href===d.href))continue;let y=d.cssRules||[];for(let g of y){if(g.type!==CSSRule.FONT_FACE_RULE)continue;let x=(g.style.getPropertyValue("font-family")||"").trim(),p=Lt(x);if(!p||Y(p))continue;let b=(g.style.getPropertyValue("font-weight")||"400").trim(),A=(g.style.getPropertyValue("font-style")||"normal").trim(),E=(g.style.getPropertyValue("font-stretch")||"100%").trim(),k=(g.style.getPropertyValue("src")||"").trim(),M=(g.style.getPropertyValue("unicode-range")||"").trim(),L=h(k,d.href||location.href);if(!u(p,A,b,E))continue;let N=f(M);if(!c(e,N))continue;let T={family:p,weightSpec:b,styleSpec:A,stretchSpec:E,unicodeRange:M,srcRaw:k,srcUrls:L,href:d.href||location.href};if(!(n&&v(T,N)))if(/url\(/i.test(k)){let Z=yield S(k,d.href||location.href);F+=`@font-face{font-family:${p};src:${Z};font-style:${A};font-weight:${b};font-stretch:${E};${M?`unicode-range:${M};`:""}}`}else F+=`@font-face{font-family:${p};src:${k};font-style:${A};font-weight:${b};font-stretch:${E};${M?`unicode-range:${M};`:""}}`}}catch(y){}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(Y(y)||!s.has(y)||n!=null&&n.families&&n.families.some(x=>String(x).toLowerCase()===y.toLowerCase()))continue;let g=d._snapdomSrc;if(!String(g).startsWith("data:")){if((gt=m.resource)!=null&&gt.has(d._snapdomSrc))g=m.resource.get(d._snapdomSrc),(B=m.font)==null||B.add(d._snapdomSrc);else if(!((xt=m.font)!=null&&xt.has(d._snapdomSrc)))try{let x=yield D(d._snapdomSrc,{as:"dataURL",useProxy:r,silent:!0});if(x.ok&&typeof x.data=="string")g=x.data,(Ct=m.resource)==null||Ct.set(d._snapdomSrc,g),(Bt=m.font)==null||Bt.add(d._snapdomSrc);else continue}catch(x){console.warn("[snapdom] Failed to fetch dynamic font src:",d._snapdomSrc);continue}}F+=`@font-face{font-family:'${y}';src:url(${g});font-style:${d.style||"normal"};font-weight:${d.weight||"normal"};}`}}catch(d){}for(let d of o){if(!d||typeof d!="object")continue;let y=String(d.family||"").replace(/^['"]+|['"]+$/g,"");if(!y||Y(y)||!s.has(y)||n!=null&&n.families&&n.families.some(E=>String(E).toLowerCase()===y.toLowerCase()))continue;let g=d.weight!=null?String(d.weight):"normal",x=d.style!=null?String(d.style):"normal",p=d.stretchPct!=null?`${d.stretchPct}%`:"100%",b=String(d.src||""),A=b;if(!A.startsWith("data:")){if((Ot=m.resource)!=null&&Ot.has(b))A=m.resource.get(b),(O=m.font)==null||O.add(b);else if(!((V=m.font)!=null&&V.has(b)))try{let E=yield D(b,{as:"dataURL",useProxy:r,silent:!0});if(E.ok&&typeof E.data=="string")A=E.data,(J=m.resource)==null||J.set(b,A),(Q=m.font)==null||Q.add(b);else continue}catch(E){console.warn("[snapdom] Failed to fetch localFonts src:",b);continue}}F+=`@font-face{font-family:'${y}';src:url(${A});font-style:${x};font-weight:${g};font-stretch:${p};}`}return F&&(F=_(F),(dt=m.resource)==null||dt.set(R,F)),F})}function Nt(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),o=a=>{let l=Lt(a.fontFamily);if(!l)return;let i=(u,f,c)=>`${l}__${Rt(u)}__${Yt(f)}__${sn(c)}`;e.add(i(a.fontWeight,a.fontStyle,a.fontStretch))};o(getComputedStyle(t));let r=getComputedStyle(t,"::before");r&&r.content&&r.content!=="none"&&o(r);let s=getComputedStyle(t,"::after");for(s&&s.content&&s.content!=="none"&&o(s);n.nextNode();){let a=n.currentNode,l=getComputedStyle(a);o(l);let i=getComputedStyle(a,"::before");i&&i.content&&i.content!=="none"&&o(i);let u=getComputedStyle(a,"::after");u&&u.content&&u.content!=="none"&&o(u)}return e}function Tt(t){let e=new Set,n=r=>{if(r)for(let s of r)e.add(s.codePointAt(0))},o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;o.nextNode();){let r=o.currentNode;if(r.nodeType===Node.TEXT_NODE)n(r.nodeValue||"");else if(r.nodeType===Node.ELEMENT_NODE){let s=r;for(let a of["::before","::after"]){let l=getComputedStyle(s,a),i=l==null?void 0:l.getPropertyValue("content");if(!(!i||i==="none"))if(/^"/.test(i)||/^'/.test(i))n(i.slice(1,-1));else{let u=i.match(/\\[0-9A-Fa-f]{1,6}/g);if(u)for(let f of u)try{e.add(parseInt(f.slice(1),16))}catch(c){}}}}}return e}function It(t,e=1){return C(this,null,function*(){try{yield document.fonts.ready}catch(r){}let n=Array.from(t||[]).filter(Boolean);if(n.length===0)return;let o=()=>{let r=document.createElement("div");r.style.cssText="position: absolute !important;left: -9999px !important;top: 0 !important;opacity: 0 !important;pointer-events: none !important;contain: layout size style;";for(let s of n){let a=document.createElement("span");a.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",a.style.fontFamily=`"${s}"`,a.style.fontWeight="700",a.style.fontStyle="italic",a.style.fontSize="32px",a.style.lineHeight="1",a.style.whiteSpace="nowrap",a.style.margin="0",a.style.padding="0",r.appendChild(a)}document.body.appendChild(r),r.offsetWidth,document.body.removeChild(r)};for(let r=0;r<Math.max(1,e);r++)o(),yield new Promise(s=>requestAnimationFrame(()=>requestAnimationFrame(s)))})}function Jt(t,e,n,o){return C(this,null,function*(){var a;if(!(t instanceof Element)||!(e instanceof Element))return;for(let l of["::before","::after","::first-letter"])try{let i=lt(t,l);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(l==="::first-letter"){let O=getComputedStyle(t);if(!(i.color!==O.color||i.fontSize!==O.fontSize||i.fontWeight!==O.fontWeight))continue;let J=Array.from(e.childNodes).find(A=>{var E;return A.nodeType===Node.TEXT_NODE&&((E=A.textContent)==null?void 0:E.trim().length)>0});if(!J)continue;let Q=J.textContent,dt=Q.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u),d=dt==null?void 0:dt[0],y=Q.slice((d==null?void 0:d.length)||0);if(!d||/[\uD800-\uDFFF]/.test(d))continue;let g=document.createElement("span");g.textContent=d,g.dataset.snapdomPseudo="::first-letter";let x=kt(i),p=pt(x,"span");n.styleMap.set(g,p);let b=document.createTextNode(y);e.replaceChild(b,J),e.insertBefore(g,b);continue}let f=i.content,c=/counter\s*\(|counters\s*\(/.test(f)?"- ":Gt(f),h=i.backgroundImage,S=i.backgroundColor,$=i.fontFamily,w=parseInt(i.fontSize)||32,v=parseInt(i.fontWeight)||!1,_=i.color||"#000",I=i.display,R=parseFloat(i.width),W=parseFloat(i.height),P=i.borderStyle,F=parseFloat(i.borderWidth),q=i.transform,j=Y($),z=f!=="none"&&c!=="",G=h&&h!=="none",K=S&&S!=="transparent"&&S!=="rgba(0, 0, 0, 0)",nt=I!=="inline"&&(R>0||W>0),ot=P&&P!=="none"&&F>0,rt=q&&q!=="none";if(!(z||G||K||nt||ot||rt))continue;let B=document.createElement("span");B.dataset.snapdomPseudo=l,B.style.verticalAlign="middle";let xt=kt(i),Ct=pt(xt,"span");if(n.styleMap.set(B,Ct),j&&c.length===1){let{dataUrl:O,width:V,height:J}=yield fe(c,$,v,w,_),Q=document.createElement("img");Q.src=O,Q.style=`height:${w}px;width:${V/J*w}px;object-fit:contain;`,B.appendChild(Q),e.dataset.snapdomHasIcon="true"}else if(c.startsWith("url(")){let O=at(c);if(O!=null&&O.trim())try{let V=document.createElement("img"),J=yield D(yt(O),{as:"dataURL",useProxy:o.useProxy});V.src=J.data,V.style=`width:${w}px;height:auto;object-fit:contain;`,B.appendChild(V)}catch(V){console.error(`[snapdom] Error in pseudo ${l} for`,t,V)}}else!j&&z&&(B.textContent=c);if(G)try{let O=ft(h),V=yield Promise.all(O.map(ct));B.style.backgroundImage=V.join(", ")}catch(O){console.warn(`[snapdom] Failed to inline background-image for ${l}`,O)}if(K&&(B.style.backgroundColor=S),!(B.childNodes.length>0||((a=B.textContent)==null?void 0:a.trim())!==""||G||K||nt||ot||rt))continue;l==="::before"?e.insertBefore(B,e.firstChild):e.appendChild(B)}catch(i){console.warn(`[snapdom] Failed to capture ${l} for`,t,i)}let r=Array.from(t.children),s=Array.from(e.children).filter(l=>!l.dataset.snapdomPseudo);for(let l=0;l<Math.min(r.length,s.length);l++)yield Jt(r[l],s[l],n,o)})}function ue(t){if(!t)return;let e=new Set;if(t.querySelectorAll("use").forEach(l=>{let i=l.getAttribute("xlink:href")||l.getAttribute("href");i&&i.startsWith("#")&&e.add(i.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"),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(l=>{a.add(l.id)}),e.forEach(l=>{if(a.has(l))return;let i=o.find(u=>u.id===l);if(i){s.appendChild(i.cloneNode(!0)),a.add(l);return}for(let u of r){let f=u.querySelector(`#${CSS.escape(l)}`);if(f){let c=s.querySelector("defs");c||(c=document.createElementNS("http://www.w3.org/2000/svg","defs"),s.appendChild(c)),c.appendChild(f.cloneNode(!0)),a.add(l);break}}})}function me(n){return C(this,arguments,function*(t,e={}){var i,u;let o={styleMap:m.session.styleMap,styleCache:m.session.styleCache,nodeMap:m.session.nodeMap},r,s="",a="";dn(t);try{ue(t)}catch(f){console.warn("inlineExternal defs or symbol failed:",f)}try{r=wt(t,o,e,t)}catch(f){throw console.warn("deepClone failed:",f),f}try{yield Jt(t,r,o,e)}catch(f){console.warn("inlinePseudoElements failed:",f)}yield gn(r);try{let f=r.querySelectorAll("style[data-sd]");for(let c of f)a+=c.textContent||"",c.remove()}catch(f){}let l=Ht(o.styleMap);s=Array.from(l.entries()).map(([f,c])=>`.${c}{${f}}`).join(""),s=a+s;for(let[f,c]of o.styleMap.entries()){if(f.tagName==="STYLE")continue;if(f.getRootNode&&f.getRootNode()instanceof ShadowRoot){f.setAttribute("style",c.replace(/;/g,"; "));continue}let h=l.get(c);h&&f.classList.add(h);let S=(i=f.style)==null?void 0:i.backgroundImage,$=(u=f.dataset)==null?void 0:u.snapdomHasIcon;S&&S!=="none"&&(f.style.backgroundImage=S),$&&(f.style.verticalAlign="middle",f.style.display="inline")}for(let[f,c]of o.nodeMap.entries()){let h=c.scrollLeft,S=c.scrollTop;if((h||S)&&f instanceof HTMLElement){f.style.overflow="hidden",f.style.scrollbarWidth="none",f.style.msOverflowStyle="none";let w=document.createElement("div");for(w.style.transform=`translate(${-h}px, ${-S}px)`,w.style.willChange="transform",w.style.display="inline-block",w.style.width="100%";f.firstChild;)w.appendChild(f.firstChild);f.appendChild(w)}}if(t===o.nodeMap.get(r)){let f=o.styleCache.get(t)||window.getComputedStyle(t);o.styleCache.set(t,f);let c=Wt(f.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=c||""}for(let[f,c]of o.nodeMap.entries())c.tagName==="PRE"&&(f.style.marginTop="0",f.style.marginBlockStart="0");return{clone:r,classCSS:s,styleCache:o.styleCache}})}function dn(t){let e=getComputedStyle(t),n=e.outlineStyle,o=e.outlineWidth,r=e.borderStyle,s=e.borderWidth,a=n!=="none"&&parseFloat(o)>0,l=r==="none"||parseFloat(s)===0;a&&l&&(t.style.border=`${o} solid transparent`)}var St=new Map;function bt(t){return C(this,null,function*(){var n;if((n=m.resource)!=null&&n.has(t))return m.resource.get(t);if(St.has(t))return St.get(t);let e=C(null,null,function*(){var r;let o=yield D(t,{as:"dataURL",silent:!0});if(!o.ok||typeof o.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);return(r=m.resource)==null||r.set(t,o.data),o.data});St.set(t,e);try{let o=yield e;return St.set(t,o),o}catch(o){throw St.delete(t),o}})}var mn=/\bblob:[^)"'\s]+/g;function de(t){return C(this,null,function*(){if(!t||t.indexOf("blob:")===-1)return t;let e=Array.from(new Set(t.match(mn)||[]));if(e.length===0)return t;let n=t;for(let o of e)try{let r=yield bt(o);n=n.split(o).join(r)}catch(r){}return n})}function _t(t){return typeof t=="string"&&t.startsWith("blob:")}function hn(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 pn(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}function gn(t){return C(this,null,function*(){var a,l;if(!t)return;let e=t.querySelectorAll?t.querySelectorAll("img"):[];for(let i of e)try{let f=i.getAttribute("src")||i.currentSrc||"";if(_t(f)){let h=yield bt(f);i.setAttribute("src",h)}let c=i.getAttribute("srcset");if(c&&c.includes("blob:")){let h=hn(c),S=!1;for(let $ of h)if(_t($.url))try{$.url=yield bt($.url),S=!0}catch(w){}S&&i.setAttribute("srcset",pn(h))}}catch(u){}let n=t.querySelectorAll?t.querySelectorAll("image"):[];for(let i of n)try{let u="http://www.w3.org/1999/xlink",f=i.getAttribute("href")||((a=i.getAttributeNS)==null?void 0:a.call(i,u,"href"));if(_t(f)){let c=yield bt(f);i.setAttribute("href",c),(l=i.removeAttributeNS)==null||l.call(i,u,"href")}}catch(u){}let o=t.querySelectorAll?t.querySelectorAll("[style*='blob:']"):[];for(let i of o)try{let u=i.getAttribute("style");if(u&&u.includes("blob:")){let f=yield de(u);i.setAttribute("style",f)}}catch(u){}let r=t.querySelectorAll?t.querySelectorAll("style"):[];for(let i of r)try{let u=i.textContent||"";u.includes("blob:")&&(i.textContent=yield de(u))}catch(u){}let s=["poster"];for(let i of s){let u=t.querySelectorAll?t.querySelectorAll(`[${i}^='blob:']`):[];for(let f of u)try{let c=f.getAttribute(i);_t(c)&&f.setAttribute(i,yield bt(c))}catch(c){}}})}function he(n){return C(this,arguments,function*(t,e={}){let o=Array.from(t.querySelectorAll("img")),r=s=>C(null,null,function*(){if(!s.getAttribute("src")){let c=s.currentSrc||s.src||"";c&&s.setAttribute("src",c)}s.removeAttribute("srcset"),s.removeAttribute("sizes");let a=s.src||"";if(!a)return;let l=yield D(a,{as:"dataURL",useProxy:e.useProxy});if(l.ok&&typeof l.data=="string"&&l.data.startsWith("data:")){s.src=l.data,s.width||(s.width=s.naturalWidth||100),s.height||(s.height=s.naturalHeight||100);return}let i=s.width||s.naturalWidth||100,u=s.height||s.naturalHeight||100,f=document.createElement("div");f.style.cssText=[`width:${i}px`,`height:${u}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${u}px`,"color:#666","font-size:12px","overflow:hidden"].join(";"),f.textContent="img",s.replaceWith(f)});for(let s=0;s<o.length;s+=4){let a=o.slice(s,s+4).map(r);yield Promise.allSettled(a)}})}function Pt(r,s,a){return C(this,arguments,function*(t,e,n,o={}){let l=[[t,e]],i=["background-image","mask","mask-image","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source","border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;l.length;){let[u,f]=l.shift(),c=n.get(u)||lt(u);n.has(u)||n.set(u,c);let h=(()=>{let w=c.getPropertyValue("border-image"),v=c.getPropertyValue("border-image-source");return w&&w!=="none"||v&&v!=="none"})();for(let w of i){if(["border-image-slice","border-image-width","border-image-outset","border-image-repeat"].includes(w)&&!h)continue;let v=c.getPropertyValue(w);if(!v||v==="none")continue;let _=ft(v),I=yield Promise.all(_.map(R=>ct(R,o)));I.some(R=>R&&R!=="none"&&!/^url\(undefined/.test(R))&&f.style.setProperty(w,I.join(", "))}let S=Array.from(u.children),$=Array.from(f.children);for(let w=0;w<Math.min(S.length,$.length);w++)l.push([S[w],$[w]])}})}function pe(t,e){return C(this,null,function*(){if(!t)throw new Error("Element cannot be null or undefined");At(e.cache);let n=e.fast,o,r,s,a="",l="",i,u;({clone:o,classCSS:r,styleCache:s}=yield me(t,e)),yield new Promise(S=>{ut(()=>C(null,null,function*(){yield he(o,e),S()}),{fast:n})}),yield new Promise(S=>{ut(()=>C(null,null,function*(){yield Pt(t,o,s,e),S()}),{fast:n})}),e.embedFonts&&(yield new Promise(S=>{ut(()=>C(null,null,function*(){let $=Nt(t),w=Tt(t);if(tt){let v=new Set(Array.from($).map(_=>String(_).split("__")[0]).filter(Boolean));yield It(v,2)}a=yield Mt({required:$,usedCodepoints:w,preCached:!1,exclude:e.excludeFonts,useProxy:e.useProxy}),S()}),{fast:n})}));let f=zt(o).sort(),c=f.join(",");m.baseStyle.has(c)?l=m.baseStyle.get(c):yield new Promise(S=>{ut(()=>{l=Vt(f),m.baseStyle.set(c,l),S()},{fast:n})}),yield new Promise(S=>{ut(()=>{let $=t.getBoundingClientRect(),w=$.width,v=$.height,_=Number.isFinite(e.width),I=Number.isFinite(e.height),R=typeof scale=="number"&&scale!==1;if(!R){let K=$.width/$.height;_&&I?(w=e.width,v=e.height):_?(w=e.width,v=w/K):I&&(v=e.height,w=v*K)}if(w=Math.ceil(w),v=Math.ceil(v),o.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),o.style.transformOrigin="top left",!R&&(_||I)){let K=$.width,nt=$.height,ot=w/K,rt=v/nt,gt=o.style.transform||"",B=`scale(${ot}, ${rt})`;o.style.transform=`${B} ${gt}`.trim()}let W="http://www.w3.org/2000/svg",P=document.createElementNS(W,"foreignObject");P.setAttribute("width","100%"),P.setAttribute("height","100%");let F=document.createElement("style");F.textContent=l+a+"svg{overflow:visible;}"+r,P.appendChild(F),P.appendChild(o);let j=new XMLSerializer().serializeToString(P);u=`<svg xmlns="${W}" width="${w}" height="${v}" viewBox="0 0 ${w} ${v}">`+j+"</svg>",i=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(u)}`,S()},{fast:n})});let h=document.getElementById("snapdom-sandbox");return h&&h.style.position==="absolute"&&h.remove(),i})}function yn(t){if(t===!0)return"soft";if(t===!1)return"disabled";if(typeof t=="string"){let e=t.toLowerCase().trim();if(e==="disabled"||e==="full"||e==="auto"||e==="soft")return e}return"soft"}function ge(t={}){var o,r,s,a,l,i,u,f,c,h,S,$,w,v,_;let e=(o=t.format)!=null?o:"png",n=yn(t.cache);return{debug:(r=t.debug)!=null?r:!1,fast:(s=t.fast)!=null?s:!0,scale:(a=t.scale)!=null?a:1,exclude:(l=t.exclude)!=null?l:[],filter:(i=t.filter)!=null?i:null,embedFonts:(u=t.embedFonts)!=null?u:!1,iconFonts:Array.isArray(t.iconFonts)?t.iconFonts:t.iconFonts?[t.iconFonts]:[],localFonts:Array.isArray(t.localFonts)?t.localFonts:[],excludeFonts:(f=t.excludeFonts)!=null?f:void 0,cache:n,useProxy:typeof t.useProxy=="string"?t.useProxy:"",width:(c=t.width)!=null?c:null,height:(h=t.height)!=null?h:null,format:e,type:(S=t.type)!=null?S:"svg",quality:($=t.quality)!=null?$:.92,dpr:(w=t.dpr)!=null?w:window.devicePixelRatio||1,backgroundColor:(v=t.backgroundColor)!=null?v:["jpg","jpeg","webp"].includes(e)?"#ffffff":null,filename:(_=t.filename)!=null?_:"snapDOM"}}function ye(t,e){return C(this,null,function*(){let n=new Image;return n.src=t,yield n.decode(),e.scale!==1&&(n.style.width=`${n.naturalWidth*e.scale}px`,n.style.height=`${n.naturalHeight*e.scale}px`),n})}function et(t,e){return C(this,null,function*(){let n=new Image;n.crossOrigin="anonymous",n.loading="eager",n.decoding="sync",n.src=t;let o=tt(),r=!1;o&&(document.body.appendChild(n),r=!0),yield n.decode(),o&&(yield new Promise(f=>setTimeout(f,100)));let s=n.naturalWidth*e.scale,a=n.naturalHeight*e.scale,l=document.createElement("canvas"),i=e.dpr;l.width=Math.ceil(s*i),l.height=Math.ceil(a*i),l.style.width=`${s}px`,l.style.height=`${a}px`;let u=l.getContext("2d");return u.scale(i,i),u.drawImage(n,0,0,s,a),r&&n.remove(),l})}function Ut(t,e){return C(this,null,function*(){let n=e.type;if(n==="svg"){let s=decodeURIComponent(t.split(",")[1]);return new Blob([s],{type:"image/svg+xml"})}let o=yield et(t,e),r=e.backgroundColor?it(o,e.backgroundColor):o;return new Promise(s=>r.toBlob(a=>s(a),`image/${n}`,e.quality))})}function we(t,e){return C(this,null,function*(){let n=yield et(t,e),o=e.backgroundColor?it(n,e.backgroundColor):n,r=new Image;return r.src=o.toDataURL(`image/${e.format}`,e.quality),yield r.decode(),r.style.width=`${o.width/e.dpr}px`,r.style.height=`${o.height/e.dpr}px`,r})}function Se(t,e){return C(this,null,function*(){if(e.format==="svg"){let s=yield Ut(t,X(H({},e),{type:"svg"})),a=URL.createObjectURL(s),l=document.createElement("a");l.href=a,l.download=e.filename,l.click(),URL.revokeObjectURL(a);return}let n=yield et(t,e),o=e.backgroundColor?it(n,e.backgroundColor):n,r=document.createElement("a");r.href=o.toDataURL(`image/${e.format}`,e.quality),r.download=e.filename,r.click()})}var be=Symbol("snapdom.internal");function U(t,e){return C(this,null,function*(){if(!t)throw new Error("Element cannot be null or undefined");let n=ge(e);return n.iconFonts&&n.iconFonts.length>0&&le(n.iconFonts),U.capture(t,n,be)})}U.capture=(t,e,n)=>C(null,null,function*(){if(n!==be)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");let o=yield pe(t,e),r=a=>H(H({},e),a||{}),s=a=>l=>we(o,r(X(H({},l||{}),{format:a})));return{url:o,toRaw:()=>o,toImg:a=>ye(o,r(a)),toCanvas:a=>et(o,r(a)),toBlob:a=>Ut(o,r(a)),toPng:s("png"),toJpg:s("jpeg"),toWebp:s("webp"),download:a=>Se(o,r(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,X(H({},e),{format:"png"})).then(n=>n.toPng());U.toJpg=(t,e)=>U(t,X(H({},e),{format:"jpeg"})).then(n=>n.toJpg());U.toWebp=(t,e)=>U(t,X(H({},e),{format:"webp"})).then(n=>n.toWebp());U.download=(t,e)=>U(t,e).then(n=>n.download());function xe(){return C(this,arguments,function*(t=document,e={}){var i;let{embedFonts:n=!0,cacheOpt:o="full",useProxy:r=""}=e;At(o);try{yield document.fonts.ready}catch(u){}Dt(),m.session=m.session||{},m.session.styleCache||(m.session.styleCache=new WeakMap);try{yield Pt(t,void 0,m.session.styleCache,{useProxy:r})}catch(u){}let s=[],a=[];try{t!=null&&t.querySelectorAll&&(s=Array.from(t.querySelectorAll("img[src]")),a=Array.from(t.querySelectorAll("*")))}catch(u){}let l=[];for(let u of s){let f=u==null?void 0:u.src;if(f&&!m.image.has(f)){let c=Promise.resolve().then(()=>D(f,{as:"dataURL",useProxy:r})).then(h=>{m.image.set(f,h)}).catch(()=>{});l.push(c)}}for(let u of a){let f="";try{f=lt(u).backgroundImage}catch(c){}if(f&&f!=="none"){let c=ft(f);for(let h of c)if(h.startsWith("url(")){let S=Promise.resolve().then(()=>ct(h,X(H({},e),{useProxy:r}))).catch(()=>{});l.push(S)}}}if(n)try{let u=Nt(t),f=Tt(t);if(typeof tt=="function"?tt():tt){let c=new Set(Array.from(u).map(h=>String(h).split("__")[0]).filter(Boolean));yield It(c,2)}yield Mt({required:u,usedCodepoints:f,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:(i=e.useProxy)!=null?i:r})}catch(u){}yield Promise.allSettled(l)})}typeof window!="undefined"&&(window.snapdom=U,window.preCache=xe);})();
@@ -1,3 +1,5 @@
1
- var l={image:new Map,background:new Map,resource:new Map,defaultStyle:new Map,baseStyle:new Map,computedStyle:new WeakMap,font:new Set,snapshot:new WeakMap,snapshotKey:new Map,preStyleMap:new Map,preStyle:new WeakMap,preNodeMap:new Map,reset:Re};function Re(){l.computedStyle=new WeakMap,l.snapshot=new WeakMap,l.snapshotKey.clear(),l.preStyleMap.clear(),l.preStyle=new WeakMap,l.preNodeMap.clear()}var Ne=["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","svg","path","circle","rect","line","g","table","thead","tbody","tr","td","th"];function ie(){for(let e of Ne)ce(e)}function ce(e){if(l.defaultStyle.has(e))return l.defaultStyle.get(e);if(new Set(["script","style","meta","link","noscript","template","defs","symbol","title","metadata","desc"]).has(e)){let n={};return l.defaultStyle.set(e,n),n}let r=document.getElementById("snapdom-sandbox");r||(r=document.createElement("div"),r.id="snapdom-sandbox",r.style.position="absolute",r.style.left="-9999px",r.style.top="-9999px",r.style.width="0",r.style.height="0",r.style.overflow="hidden",document.body.appendChild(r));let c=document.createElement(e);c.style.all="initial",r.appendChild(c);let s=getComputedStyle(c),o={};for(let n of s)o[n]=s.getPropertyValue(n);return r.removeChild(c),l.defaultStyle.set(e,o),o}var Ae=new Set(["-webkit-locale"]);function D(e,t,r=!1){let c=[],s=ce(t);for(let[o,n]of Object.entries(e))if(!Ae.has(o))if(!r)n&&c.push(`${o}:${n}`);else{let a=s[o];n&&n!==a&&c.push(`${o}:${n}`)}return c.sort().join(";")}function le(e){let t=new Set;return e.nodeType!==Node.ELEMENT_NODE&&e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(e.tagName&&t.add(e.tagName.toLowerCase()),typeof e.querySelectorAll=="function"&&e.querySelectorAll("*").forEach(r=>t.add(r.tagName.toLowerCase())),Array.from(t))}function de(e){let t=new Map;for(let c of e){let s=l.defaultStyle.get(c);if(!s)continue;let o=Object.entries(s).map(([n,a])=>`${n}:${a};`).sort().join("");t.has(o)||t.set(o,[]),t.get(o).push(c)}let r="";for(let[c,s]of t.entries())r+=`${s.join(",")} { ${c} }
2
- `;return r}function fe(){let e=new Set(l.preStyleMap.values()),t=new Map,r=1;for(let c of e)c.trim()&&t.set(c,`c${r++}`);return t}async function P(e,t={}){let r=O(e),c=/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(e);if(r){let s=H(r);if(l.background.has(s))return t.skipInline?void 0:`url(${l.background.get(s)})`;{let o=await M(s,{useProxy:t.useProxy});return l.background.set(s,o),t.skipInline?void 0:`url("${o}")`}}return e}function F(e,{fast:t=!1}={}){if(t)return e();"requestIdleCallback"in window?requestIdleCallback(e,{timeout:50}):setTimeout(e,1)}function I(e,t=null){if(!(e instanceof Element))return window.getComputedStyle(e,t);let r=l.computedStyle.get(e);if(r||(r=new Map,l.computedStyle.set(e,r)),!r.has(t)){let c=window.getComputedStyle(e,t);r.set(t,c)}return r.get(t)}function ue(e){let t=e.replace(/^['"]|['"]$/g,"");if(t.startsWith("\\"))try{return String.fromCharCode(parseInt(t.replace("\\",""),16))}catch{return t}return t}function O(e){let t=e.match(/url\((['"]?)(.*?)(\1)\)/);if(!t)return null;let r=t[2].trim();return r.startsWith("#")?null:r}function M(e,{timeout:t=3e3,useProxy:r=""}={}){function c(i){try{return new URL(i,window.location.href).origin===window.location.origin?"use-credentials":"anonymous"}catch{return"anonymous"}}async function s(i){let d=u=>fetch(u,{mode:"cors",credentials:c(u)==="use-credentials"?"include":"omit"}).then(f=>f.blob()).then(f=>new Promise((m,p)=>{let h=new FileReader;h.onloadend=()=>{let y=h.result;if(typeof y!="string"||!y.startsWith("data:image/")){p(new Error("Invalid image data URL"));return}m(y)},h.onerror=()=>p(new Error("FileReader error")),h.readAsDataURL(f)}));try{return await d(i)}catch{if(r&&typeof r=="string"){let f=r.replace(/\/$/,"")+H(i);try{return await d(f)}catch{throw new Error("[SnapDOM - fetchImage] CORS restrictions prevented image capture (even via proxy)")}}else throw new Error("[SnapDOM - fetchImage] Fetch fallback failed and no proxy provided")}}let o=c(e);return l.image.has(e)?Promise.resolve(l.image.get(e)):e.startsWith("data:image/")?(l.image.set(e,e),Promise.resolve(e)):/\.svg(\?.*)?$/i.test(e)?(async()=>{try{let d=await(await fetch(e,{mode:"cors",credentials:o==="use-credentials"?"include":"omit"})).text(),u=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(d)}`;return l.image.set(e,u),u}catch{return s(e)}})():new Promise((i,d)=>{let u=setTimeout(()=>{d(new Error("[SnapDOM - fetchImage] Image load timed out"))},t),f=new Image;f.crossOrigin=o,f.onload=async()=>{clearTimeout(u);try{await f.decode();let m=document.createElement("canvas");m.width=f.width,m.height=f.height,m.getContext("2d").drawImage(f,0,0,m.width,m.height);let h=m.toDataURL("image/png");l.image.set(e,h),i(h)}catch{try{let m=await s(e);l.image.set(e,m),i(m)}catch(m){d(m)}}},f.onerror=async()=>{clearTimeout(u),console.error(`[SnapDOM - fetchImage] Image failed to load: ${e}`);try{let m=await s(e);l.image.set(e,m),i(m)}catch(m){d(m)}},f.src=e})}function Q(e){let t={};for(let r of e)t[r]=e.getPropertyValue(r);return t}function me(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function pe(e){if(!e||e==="none")return"";let t=e.replace(/translate[XY]?\([^)]*\)/g,"");return t=t.replace(/matrix\(([^)]+)\)/g,(r,c)=>{let s=c.split(",").map(o=>o.trim());return s.length!==6?`matrix(${c})`:(s[4]="0",s[5]="0",`matrix(${s.join(", ")})`)}),t=t.replace(/matrix3d\(([^)]+)\)/g,(r,c)=>{let s=c.split(",").map(o=>o.trim());return s.length!==16?`matrix3d(${c})`:(s[12]="0",s[13]="0",`matrix3d(${s.join(", ")})`)}),t.trim().replace(/\s{2,}/g," ")}function H(e){if(/%[0-9A-Fa-f]{2}/.test(e))return e;try{return encodeURI(e)}catch{return e}}function U(e){let t=[],r=0,c=0;for(let s=0;s<e.length;s++){let o=e[s];o==="("&&r++,o===")"&&r--,o===","&&r===0&&(t.push(e.slice(c,s).trim()),c=s+1)}return t.push(e.slice(c).trim()),t}function Te(e){let t={},r=e.getPropertyValue("visibility");for(let c=0;c<e.length;c++){let s=e[c],o=e.getPropertyValue(s);(s==="background-image"||s==="content")&&o.includes("url(")&&!o.includes("data:")&&(o="none"),t[s]=o}return r==="hidden"&&(t.opacity="0"),t}function z(e,t,r){if(e.tagName==="STYLE")return;l.preStyle.has(e)||l.preStyle.set(e,I(e));let c=l.preStyle.get(e);if(!l.snapshot.has(e)){let i=Te(c);l.snapshot.set(e,i)}let s=l.snapshot.get(e),o=Object.entries(s).sort(([i],[d])=>i.localeCompare(d)).map(([i,d])=>`${i}:${d}`).join(";");if(l.snapshotKey.has(o)){l.preStyleMap.set(t,l.snapshotKey.get(o));return}let n=e.tagName?.toLowerCase()||"div",a=D(s,n,r);l.snapshotKey.set(o,a),l.preStyleMap.set(t,a)}function j(e,t,r={},c){if(!e)throw new Error("Invalid node");let s=new Set,o=null;if(e.nodeType===Node.TEXT_NODE||e.nodeType!==Node.ELEMENT_NODE)return e.cloneNode(!0);if(e.getAttribute("data-capture")==="exclude"){let a=document.createElement("div"),i=e.getBoundingClientRect();return a.style.cssText=`display:inline-block;width:${i.width}px;height:${i.height}px;visibility:hidden;`,a}if(r.exclude&&Array.isArray(r.exclude))for(let a of r.exclude)try{if(e.matches?.(a)){let i=document.createElement("div"),d=e.getBoundingClientRect();return i.style.cssText=`display:inline-block;width:${d.width}px;height:${d.height}px;visibility:hidden;`,i}}catch(i){console.warn(`Invalid selector in exclude option: ${a}`,i)}if(typeof r.filter=="function")try{if(!r.filter(e,c||e)){let a=document.createElement("div"),i=e.getBoundingClientRect();return a.style.cssText=`display:inline-block;width:${i.width}px;height:${i.height}px;visibility:hidden;`,a}}catch(a){console.warn("Error in filter function:",a)}if(e.tagName==="IFRAME"){let a=document.createElement("div");return a.style.cssText=`width:${e.offsetWidth}px;height:${e.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;`,a}if(e.getAttribute("data-capture")==="placeholder"){let a=e.cloneNode(!1);l.preNodeMap.set(a,e),z(e,a,t);let i=document.createElement("div");return i.textContent=e.getAttribute("data-placeholder-text")||"",i.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",a.appendChild(i),a}if(e.tagName==="CANVAS"){let a=e.toDataURL(),i=document.createElement("img");return i.src=a,i.width=e.width,i.height=e.height,l.preNodeMap.set(i,e),z(e,i,t),i}let n;try{n=e.cloneNode(!1),l.preNodeMap.set(n,e)}catch(a){throw console.error("[Snapdom] Failed to clone node:",e,a),a}if(e instanceof HTMLTextAreaElement){n.textContent=e.value,n.value=e.value;let a=e.getBoundingClientRect();return n.style.width=`${a.width}px`,n.style.height=`${a.height}px`,n}if(e instanceof HTMLInputElement&&(n.value=e.value,n.setAttribute("value",e.value),e.checked!==void 0&&(n.checked=e.checked,e.checked&&n.setAttribute("checked",""),e.indeterminate&&(n.indeterminate=e.indeterminate))),e instanceof HTMLSelectElement&&(o=e.value),z(e,n,t),e.shadowRoot)if(Array.from(e.shadowRoot.querySelectorAll("slot")).length>0){for(let i of e.shadowRoot.childNodes)if(i.nodeType===Node.ELEMENT_NODE&&i.tagName==="STYLE"){let d=i.textContent||"";d.trim()&&t&&(l.preStyle||(l.preStyle=new WeakMap),l.preStyle.set(i,d))}}else{let i=document.createDocumentFragment();for(let d of e.shadowRoot.childNodes){if(d.nodeType===Node.ELEMENT_NODE&&d.tagName==="STYLE"){let f=d.textContent||"";f.trim()&&t&&(l.preStyle||(l.preStyle=new WeakMap),l.preStyle.set(d,f));continue}let u=j(d,t,r,c||e);u&&i.appendChild(u)}n.appendChild(i)}if(e.tagName==="SLOT"){let a=e.assignedNodes?.({flatten:!0})||[],i=a.length>0?a:Array.from(e.childNodes),d=document.createDocumentFragment();for(let u of i){let f=j(u,t,r,c||e);f&&d.appendChild(f)}return d}for(let a of e.childNodes){if(s.has(a))continue;let i=j(a,t,r,c||e);i&&n.appendChild(i)}if(o!==null&&n instanceof HTMLSelectElement){n.value=o;for(let a of n.options)a.value===o?a.setAttribute("selected",""):a.removeAttribute("selected")}return n}var Me=[/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],Z=[];function he(e){let t=Array.isArray(e)?e:[e];for(let r of t)r instanceof RegExp?Z.push(r):typeof r=="string"?Z.push(new RegExp(r,"i")):console.warn("[snapdom] Ignored invalid iconFont value:",r)}function k(e){let t=typeof e=="string"?e:"",r=[...Me,...Z];for(let c of r)if(c instanceof RegExp&&c.test(t))return!0;return!!(/icon/i.test(t)||/glyph/i.test(t)||/symbols/i.test(t)||/feather/i.test(t)||/fontawesome/i.test(t))}async function ge(e,t,r,c=32,s="#000"){t=t.replace(/^['"]+|['"]+$/g,"");let o=window.devicePixelRatio||1;await document.fonts.ready;let n=document.createElement("span");n.textContent=e,n.style.position="absolute",n.style.visibility="hidden",n.style.fontFamily=`"${t}"`,n.style.fontWeight=r||"normal",n.style.fontSize=`${c}px`,n.style.lineHeight="1",n.style.whiteSpace="nowrap",n.style.padding="0",n.style.margin="0",document.body.appendChild(n);let a=n.getBoundingClientRect(),i=Math.ceil(a.width),d=Math.ceil(a.height);document.body.removeChild(n);let u=document.createElement("canvas");u.width=i*o,u.height=d*o;let f=u.getContext("2d");return f.scale(o,o),f.font=r?`${r} ${c}px "${t}"`:`${c}px "${t}"`,f.textAlign="left",f.textBaseline="top",f.fillStyle=s,f.fillText(e,0,0),{dataUrl:u.toDataURL(),width:i,height:d}}function ye(e){return Array.from(document.styleSheets).some(t=>t.href===e)}function Le(e){return new Promise(t=>{if(ye(e))return t(null);let r=document.createElement("link");r.rel="stylesheet",r.href=e,r.setAttribute("data-snapdom","injected-import"),r.onload=()=>t(r),r.onerror=()=>t(null),document.head.appendChild(r)})}async function K({preCached:e=!1}={}){if(l.resource.has("fonts-embed-css")){if(e){let o=document.createElement("style");o.setAttribute("data-snapdom","embedFonts"),o.textContent=l.resource.get("fonts-embed-css"),document.head.appendChild(o)}return l.resource.get("fonts-embed-css")}let t=/@import\s+url\(["']?([^"')]+)["']?\)/g,r=[];for(let o of document.querySelectorAll("style")){let n=o.textContent||"",a=Array.from(n.matchAll(t));for(let i of a){let d=i[1];k(d)||ye(d)||r.push(d)}}await Promise.all(r.map(Le));let c=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(o=>o.href),s="";for(let o of c)try{let a=await(await fetch(o.href)).text();if(k(o.href)||k(a))continue;let i=/url\((["']?)([^"')]+)\1\)/g,d=await Promise.all(Array.from(a.matchAll(i)).map(async f=>{let m=O(f[0]);if(!m)return null;let p=m;if(!p.startsWith("http")&&!p.startsWith("data:")&&(p=new URL(p,o.href).href),k(p))return null;if(l.resource.has(p))return l.font.add(p),{original:f[0],inlined:`url(${l.resource.get(p)})`};if(l.font.has(p))return null;try{let y=await(await fetch(p)).blob(),w=await new Promise(g=>{let E=new FileReader;E.onload=()=>g(E.result),E.readAsDataURL(y)});return l.resource.set(p,w),l.font.add(p),{original:f[0],inlined:`url(${w})`}}catch{return console.warn("[snapdom] Failed to fetch font resource:",p),null}})),u=a;for(let f of d)f&&(u=u.replace(f.original,f.inlined));s+=u+`
3
- `}catch{console.warn("[snapdom] Failed to fetch CSS:",o.href)}for(let o of document.styleSheets)try{if(!o.href||c.every(n=>n.href!==o.href)){for(let n of o.cssRules)if(n.type===CSSRule.FONT_FACE_RULE){let a=n.style.getPropertyValue("src"),i=n.style.getPropertyValue("font-family");if(!a||k(i))continue;let d=/url\((["']?)([^"')]+)\1\)/g,u=/local\((["']?)[^)]+?\1\)/g,f=!!a.match(d),m=!!a.match(u);if(!f&&m){s+=`@font-face{font-family:${i};src:${a};font-style:${n.style.getPropertyValue("font-style")||"normal"};font-weight:${n.style.getPropertyValue("font-weight")||"normal"};}`;continue}let p=a,h=Array.from(a.matchAll(d));for(let y of h){let w=y[2].trim();if(!w)continue;let g=w;if(!g.startsWith("http")&&!g.startsWith("data:")&&(g=new URL(g,o.href||location.href).href),!k(g)){if(l.resource.has(g)){l.font.add(g),p=p.replace(y[0],`url(${l.resource.get(g)})`);continue}if(!l.font.has(g))try{let $=await(await fetch(g)).blob(),R=await new Promise(N=>{let x=new FileReader;x.onload=()=>N(x.result),x.readAsDataURL($)});l.resource.set(g,R),l.font.add(g),p=p.replace(y[0],`url(${R})`)}catch{console.warn("[snapdom] Failed to fetch font URL:",g)}}}s+=`@font-face{font-family:${i};src:${p};font-style:${n.style.getPropertyValue("font-style")||"normal"};font-weight:${n.style.getPropertyValue("font-weight")||"normal"};}`}}}catch(n){console.warn("[snapdom] Cannot access stylesheet",o.href,n)}for(let o of document.fonts)if(o.family&&o.status==="loaded"&&o._snapdomSrc){if(k(o.family))continue;let n=o._snapdomSrc;if(!n.startsWith("data:")){if(l.resource.has(o._snapdomSrc))n=l.resource.get(o._snapdomSrc),l.font.add(o._snapdomSrc);else if(!l.font.has(o._snapdomSrc))try{let i=await(await fetch(o._snapdomSrc)).blob();n=await new Promise(d=>{let u=new FileReader;u.onload=()=>d(u.result),u.readAsDataURL(i)}),l.resource.set(o._snapdomSrc,n),l.font.add(o._snapdomSrc)}catch{console.warn("[snapdom] Failed to fetch dynamic font src:",o._snapdomSrc);continue}}s+=`@font-face{font-family:'${o.family}';src:url(${n});font-style:${o.style||"normal"};font-weight:${o.weight||"normal"};}`}if(s&&(l.resource.set("fonts-embed-css",s),e)){let o=document.createElement("style");o.setAttribute("data-snapdom","embedFonts"),o.textContent=s,document.head.appendChild(o)}return s}async function ee(e,t,r){if(!(e instanceof Element)||!(t instanceof Element))return;for(let o of["::before","::after","::first-letter"])try{let n=I(e,o);if(!n||typeof n[Symbol.iterator]!="function"||n.content==="none"&&n.backgroundImage==="none"&&n.backgroundColor==="transparent"&&(n.borderStyle==="none"||parseFloat(n.borderWidth)===0)&&(!n.transform||n.transform==="none")&&n.display==="inline")continue;if(o==="::first-letter"){let C=getComputedStyle(e);if(!(n.color!==C.color||n.fontSize!==C.fontSize||n.fontWeight!==C.fontWeight))continue;let T=Array.from(t.childNodes).find(se=>se.nodeType===Node.TEXT_NODE&&se.textContent?.trim().length>0);if(!T)continue;let L=T.textContent,_=L.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0],ke=L.slice(_?.length||0);if(!_||/[\uD800-\uDFFF]/.test(_))continue;let q=document.createElement("span");q.textContent=_,q.dataset.snapdomPseudo="::first-letter";let $e=Q(n),Ie=D($e,"span",r);l.preStyleMap.set(q,Ie);let ae=document.createTextNode(ke);t.replaceChild(ae,T),t.insertBefore(q,ae);continue}let i=n.content,d=/counter\s*\(|counters\s*\(/.test(i)?"- ":ue(i),u=n.backgroundImage,f=n.backgroundColor,m=n.fontFamily,p=parseInt(n.fontSize)||32,h=parseInt(n.fontWeight)||!1,y=n.color||"#000",w=n.display,g=parseFloat(n.width),E=parseFloat(n.height),$=n.borderStyle,R=parseFloat(n.borderWidth),N=n.transform,x=k(m),B=i!=="none"&&d!=="",V=u&&u!=="none",W=f&&f!=="transparent"&&f!=="rgba(0, 0, 0, 0)",Y=w!=="inline"&&(g>0||E>0),G=$&&$!=="none"&&R>0,A=N&&N!=="none";if(!(B||V||W||Y||G||A))continue;let S=document.createElement("span");S.dataset.snapdomPseudo=o,S.style.verticalAlign="middle";let X=Q(n),J=D(X,"span",r);if(l.preStyleMap.set(S,J),x&&d.length===1){let{dataUrl:C,width:v,height:T}=await ge(d,m,h,p,y),L=document.createElement("img");L.src=C,L.style=`height:${p}px;width:${v/T*p}px;object-fit:contain;`,S.appendChild(L),t.dataset.snapdomHasIcon="true"}else if(d.startsWith("url(")){let C=O(d);if(C?.trim())try{let v=document.createElement("img"),T=await M(H(C),r);v.src=T,v.style=`width:${p}px;height:auto;object-fit:contain;`,S.appendChild(v)}catch(v){console.error(`[snapdom] Error in pseudo ${o} for`,e,v)}}else!x&&B&&(S.textContent=d);if(V)try{let C=U(u),v=await Promise.all(C.map(P));S.style.backgroundImage=v.join(", ")}catch(C){console.warn(`[snapdom] Failed to inline background-image for ${o}`,C)}if(W&&(S.style.backgroundColor=f),!(S.childNodes.length>0||S.textContent?.trim()!==""||V||W||Y||G||A))continue;o==="::before"?t.insertBefore(S,t.firstChild):t.appendChild(S)}catch(n){console.warn(`[snapdom] Failed to capture ${o} for`,e,n)}let c=Array.from(e.children),s=Array.from(t.children).filter(o=>!o.dataset.snapdomPseudo);for(let o=0;o<Math.min(c.length,s.length);o++)await ee(c[o],s[o],r)}function we(e){if(!e)return;let t=new Set;if(e.querySelectorAll("use").forEach(a=>{let i=a.getAttribute("xlink:href")||a.getAttribute("href");i&&i.startsWith("#")&&t.add(i.slice(1))}),!t.size)return;let r=Array.from(document.querySelectorAll("svg > symbol, svg > defs")),c=r.filter(a=>a.tagName.toLowerCase()==="symbol"),s=r.filter(a=>a.tagName.toLowerCase()==="defs"),o=e.querySelector("svg.inline-defs-container");o||(o=document.createElementNS("http://www.w3.org/2000/svg","svg"),o.setAttribute("aria-hidden","true"),o.setAttribute("style","position: absolute; width: 0; height: 0; overflow: hidden;"),o.classList.add("inline-defs-container"),e.insertBefore(o,e.firstChild));let n=new Set;e.querySelectorAll("symbol[id], defs > *[id]").forEach(a=>{n.add(a.id)}),t.forEach(a=>{if(n.has(a))return;let i=c.find(d=>d.id===a);if(i){o.appendChild(i.cloneNode(!0)),n.add(a);return}for(let d of s){let u=d.querySelector(`#${CSS.escape(a)}`);if(u){let f=o.querySelector("defs");f||(f=document.createElementNS("http://www.w3.org/2000/svg","defs"),o.appendChild(f)),f.appendChild(u.cloneNode(!0)),n.add(a);break}}})}async function be(e,t=!1,r=!1,c={}){let s,o="";Pe(e);try{we(e)}catch(n){console.warn("inlineExternal defs or symbol failed:",n)}try{s=j(e,t,c,e)}catch(n){throw console.warn("deepClone failed:",n),n}try{await ee(e,s,t,r,c.useProxy)}catch(n){console.warn("inlinePseudoElements failed:",n)}if(t){let n=fe();o=Array.from(n.entries()).map(([a,i])=>`.${i}{${a}}`).join("");for(let[a,i]of l.preStyleMap.entries()){if(a.tagName==="STYLE")continue;if(a.getRootNode&&a.getRootNode()instanceof ShadowRoot){a.setAttribute("style",i.replace(/;/g,"; "));continue}let d=n.get(i);d&&a.classList.add(d);let u=a.style?.backgroundImage,f=a.dataset?.snapdomHasIcon;u&&u!=="none"&&(a.style.backgroundImage=u),f&&(a.style.verticalAlign="middle",a.style.display="inline")}}else for(let[n,a]of l.preStyleMap.entries())n.tagName!=="STYLE"&&n.setAttribute("style",a.replace(/;/g,"; "));for(let[n,a]of l.preNodeMap.entries()){let i=a.scrollLeft,d=a.scrollTop;if((i||d)&&n instanceof HTMLElement){n.style.overflow="hidden",n.style.scrollbarWidth="none",n.style.msOverflowStyle="none";let f=document.createElement("div");for(f.style.transform=`translate(${-i}px, ${-d}px)`,f.style.willChange="transform",f.style.display="inline-block",f.style.width="100%";n.firstChild;)f.appendChild(n.firstChild);n.appendChild(f)}}if(e===l.preNodeMap.get(s)){let n=l.preStyle.get(e)||window.getComputedStyle(e);l.preStyle.set(e,n);let a=pe(n.transform);s.style.margin="0",s.style.position="static",s.style.top="auto",s.style.left="auto",s.style.right="auto",s.style.bottom="auto",s.style.zIndex="auto",s.style.float="none",s.style.clear="none",s.style.transform=a||""}for(let[n,a]of l.preNodeMap.entries())a.tagName==="PRE"&&(n.style.marginTop="0",n.style.marginBlockStart="0");return{clone:s,classCSS:o}}function Pe(e){let t=getComputedStyle(e),r=t.outlineStyle,c=t.outlineWidth,s=t.borderStyle,o=t.borderWidth,n=r!=="none"&&parseFloat(c)>0,a=s==="none"||parseFloat(o)===0;n&&a&&(e.style.border=`${c} solid transparent`)}async function Se(e,t={}){let r=Array.from(e.querySelectorAll("img")),c=async s=>{let o=s.src;try{let n=await M(o,{useProxy:t.useProxy});s.src=n,s.width||(s.width=s.naturalWidth||100),s.height||(s.height=s.naturalHeight||100)}catch{let n=document.createElement("div");n.style=`width: ${s.width||100}px; height: ${s.height||100}px; background: #ccc; display: inline-block; text-align: center; line-height: ${s.height||100}px; color: #666; font-size: 12px;`,n.innerText="img",s.replaceWith(n)}};for(let s=0;s<r.length;s+=4){let o=r.slice(s,s+4).map(c);await Promise.allSettled(o)}}async function xe(e,t,r={}){let c=[[e,t]],s=["background-image","mask","mask-image","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source","border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;c.length;){let[o,n]=c.shift(),a=l.preStyle.get(o)||I(o);l.preStyle.has(o)||l.preStyle.set(o,a);let i=(()=>{let m=a.getPropertyValue("border-image"),p=a.getPropertyValue("border-image-source");return m&&m!=="none"||p&&p!=="none"})();for(let m of s){if(["border-image-slice","border-image-width","border-image-outset","border-image-repeat"].includes(m)&&!i)continue;let p=a.getPropertyValue(m);if(!p||p==="none")continue;let h=U(p),y=await Promise.all(h.map(w=>P(w,r)));y.some(w=>w&&w!=="none"&&!/^url\(undefined/.test(w))&&n.style.setProperty(m,y.join(", "))}let d=a.getPropertyValue("background-color");d&&d!=="transparent"&&d!=="rgba(0, 0, 0, 0)"&&(n.style.backgroundColor=d);let u=Array.from(o.children),f=Array.from(n.children);for(let m=0;m<Math.min(u.length,f.length);m++)c.push([u[m],f[m]])}}async function Ce(e,t={}){if(!e)throw new Error("Element cannot be null or undefined");l.reset();let{compress:r=!0,embedFonts:c=!1,fast:s=!0,scale:o=1,useProxy:n=""}=t,a,i,d="",u="",f,m;if({clone:a,classCSS:i}=await be(e,r,c,t),await new Promise(h=>{F(async()=>{await Se(a,t),h()},{fast:s})}),await new Promise(h=>{F(async()=>{await xe(e,a,t),h()},{fast:s})}),c&&await new Promise(h=>{F(async()=>{d=await K(),h()},{fast:s})}),r){let h=le(a).sort(),y=h.join(",");l.baseStyle.has(y)?u=l.baseStyle.get(y):await new Promise(w=>{F(()=>{u=de(h),l.baseStyle.set(y,u),w()},{fast:s})})}await new Promise(h=>{F(()=>{let y=e.getBoundingClientRect(),w=y.width,g=y.height,E=Number.isFinite(t.width),$=Number.isFinite(t.height),R=typeof o=="number"&&o!==1;if(!R){let A=y.width/y.height;E&&$?(w=t.width,g=t.height):E?(w=t.width,g=w/A):$&&(g=t.height,w=g*A)}if(w=Math.ceil(w),g=Math.ceil(g),a.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),a.style.transformOrigin="top left",!R&&(E||$)){let A=y.width,oe=y.height,S=w/A,X=g/oe,J=a.style.transform||"",re=`scale(${S}, ${X})`;a.style.transform=`${re} ${J}`.trim()}let N="http://www.w3.org/2000/svg",x=document.createElementNS(N,"foreignObject");x.setAttribute("width","100%"),x.setAttribute("height","100%");let B=document.createElement("style");B.textContent=u+d+"svg{overflow:visible;}"+i,x.appendChild(B),x.appendChild(a);let W=new XMLSerializer().serializeToString(x);m=`<svg xmlns="${N}" width="${w}" height="${g}" viewBox="0 0 ${w} ${g}">`+W+"</svg>",f=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(m)}`,h()},{fast:s})});let p=document.getElementById("snapdom-sandbox");return p&&p.style.position==="absolute"&&p.remove(),f}async function Fe(e,{scale:t=1}={}){let r=new Image;return r.src=e,await r.decode(),t!==1&&(r.style.width=`${r.naturalWidth*t}px`,r.style.height=`${r.naturalHeight*t}px`),r}async function Ee(e,{dpr:t=1,scale:r=1}={}){let c=new Image;c.src=e,c.crossOrigin="anonymous",c.loading="eager",c.decoding="sync";let s=me(),o=!1;if(s&&(document.body.appendChild(c),o=!0),await c.decode(),s&&await new Promise(u=>setTimeout(u,100)),c.width===0||c.height===0)throw o&&c.remove(),new Error("Image failed to load or has no dimensions");let n=c.naturalWidth*r,a=c.naturalHeight*r,i=document.createElement("canvas");i.width=Math.ceil(n*t),i.height=Math.ceil(a*t),i.style.width=`${n}px`,i.style.height=`${a}px`;let d=i.getContext("2d");return d.scale(t,t),d.drawImage(c,0,0,n,a),o&&c.remove(),i}async function ve(e,{type:t="svg",scale:r=1,backgroundColor:c="#fff",quality:s}={}){let o={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp"}[t]||"image/png";if(t==="svg"){let a=decodeURIComponent(e.split(",")[1]);return new Blob([a],{type:"image/svg+xml"})}let n=await ne(e,{dpr:1,scale:r},c);return new Promise(a=>{n.toBlob(i=>a(i),`${o}`,s)})}async function ne(e,{dpr:t=1,scale:r=1},c){let s=await Ee(e,{dpr:t,scale:r});if(!c)return s;let o=document.createElement("canvas");o.width=s.width,o.height=s.height;let n=o.getContext("2d");return n.fillStyle=c,n.fillRect(0,0,o.width,o.height),n.drawImage(s,0,0),o}async function te(e,{dpr:t=1,scale:r=1,backgroundColor:c,quality:s},o="png"){let n=["jpg","jpeg","webp"].includes(o)?"#fff":void 0,i=await ne(e,{dpr:t,scale:r},c??n),d=new Image;return d.src=i.toDataURL(`image/${o}`,s),await d.decode(),d.style.width=`${i.width/t}px`,d.style.height=`${i.height/t}px`,d}async function Ue(e,{dpr:t=1,scale:r=1,backgroundColor:c,format:s="png",filename:o="snapDOM"}={}){if(s==="svg"){let m=await ve(e),p=URL.createObjectURL(m),h=document.createElement("a");h.href=p,h.download=`${o}.svg`,h.click(),URL.revokeObjectURL(p);return}let n=["jpg","jpeg","webp"].includes(s)?"#fff":void 0,i=await ne(e,{dpr:t,scale:r},c??n),d={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp"}[s]||"image/png",u=i.toDataURL(d),f=document.createElement("a");f.href=u,f.download=`${o}.${s}`,f.click()}async function b(e,t={}){if(t={scale:1,...t},!e)throw new Error("Element cannot be null or undefined");return t.iconFonts&&he(t.iconFonts),await b.capture(e,t)}b.capture=async(e,t={})=>{let r=await Ce(e,t),c=t.dpr??(window.devicePixelRatio||1),s=t.scale||1;return{url:r,options:t,toRaw:()=>r,toImg:(o={})=>Fe(r,{dpr:c,scale:s,...o}),toCanvas:(o={})=>Ee(r,{dpr:c,scale:s,...o}),toBlob:(o={})=>ve(r,{dpr:c,scale:s,...o}),toPng:(o={})=>te(r,{dpr:c,scale:s,...o},"png"),toJpg:(o={})=>te(r,{dpr:c,scale:s,...o},"jpeg"),toWebp:(o={})=>te(r,{dpr:c,scale:s,...o},"webp"),download:({format:o="png",filename:n="snapDOM",backgroundColor:a,...i}={})=>Ue(r,{dpr:c,scale:s,format:o,filename:n,backgroundColor:a,...i})}};b.toRaw=async(e,t)=>(await b.capture(e,t)).toRaw();b.toImg=async(e,t)=>(await b.capture(e,t)).toImg();b.toCanvas=async(e,t)=>(await b.capture(e,t)).toCanvas();b.toBlob=async(e,t)=>(await b.capture(e,t)).toBlob(t);b.toPng=async(e,t)=>(await b.capture(e,t)).toPng(t);b.toJpg=async(e,t)=>(await b.capture(e,t)).toJpg(t);b.toWebp=async(e,t)=>(await b.capture(e,t)).toWebp(t);b.download=async(e,t={})=>{let{format:r="png",filename:c="capture",backgroundColor:s,...o}=t;return await(await b.capture(e,o)).download({format:r,filename:c,backgroundColor:s})};async function Be(e=document,t={}){let{embedFonts:r=!0,reset:c=!1}=t;if(c){l.reset();return}await document.fonts.ready,ie();let s=[],o=[];e?.querySelectorAll&&(s=Array.from(e.querySelectorAll("img[src]")),o=Array.from(e.querySelectorAll("*")));let n=[];for(let a of s){let i=a.src;l.image.has(i)||n.push(M(i,{useProxy:t.useProxy}).then(d=>l.image.set(i,d)).catch(()=>{}))}for(let a of o){let i=I(a).backgroundImage;if(i&&i!=="none"){let d=U(i);for(let u of d)u.startsWith("url(")&&n.push(P(u,t).catch(()=>{}))}}r&&await K({preCached:!0}),await Promise.all(n)}export{Be as preCache,b as snapdom};
1
+ var f={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 at(t="soft"){switch(t){case"auto":{f.session.styleMap=new Map,f.session.nodeMap=new Map;return}case"soft":{f.session.styleMap=new Map,f.session.nodeMap=new Map,f.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{f.session.styleMap=new Map,f.session.nodeMap=new Map,f.session.styleCache=new WeakMap,f.image.clear(),f.background.clear(),f.resource.clear(),f.font.clear();return}default:{f.session.styleMap=new Map,f.session.nodeMap=new Map,f.session.styleCache=new WeakMap;return}}}function V(t){let e=t.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function xt(t){if(!t||t==="none")return"";let e=t.replace(/translate[XY]?\([^)]*\)/g,"");return e=e.replace(/matrix\(([^)]+)\)/g,(n,o)=>{let s=o.split(",").map(i=>i.trim());return s.length!==6?`matrix(${o})`:(s[4]="0",s[5]="0",`matrix(${s.join(", ")})`)}),e=e.replace(/matrix3d\(([^)]+)\)/g,(n,o)=>{let s=o.split(",").map(i=>i.trim());return s.length!==16?`matrix3d(${o})`:(s[12]="0",s[13]="0",`matrix3d(${s.join(", ")})`)}),e.trim().replace(/\s{2,}/g," ")}function tt(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function oe(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,s=0;function i(r,a,c){if(s>=n)return;let u=Date.now();(o.get(a)||0)>u||(o.set(a,u+e),s++,r==="warn"&&console&&console.warn?console.warn(`${t} ${c}`):console&&console.error&&console.error(`${t} ${c}`))}return{warnOnce(r,a){i("warn",r,a)},errorOnce(r,a){i("error",r,a)},reset(){o.clear(),s=0}}}var Pt=oe("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),Ct=new Map,it=new Map;function re(t){return/^data:|^blob:|^about:blank$/.test(t)}function se(t,e){if(!e||re(t))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 ae(t,e){if(!e)return t;if(e.includes("{url}"))return e.replace("{url}",encodeURIComponent(t));let n=e.endsWith("?")?"":e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function ie(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 ce(t,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,t].join("|")}async function B(t,e={}){let n=e.as??"blob",o=e.timeout??3e3,s=e.useProxy||"",i=e.errorTTL??8e3,r=e.headers||{},a=!!e.silent,c=ce(t,{as:n,timeout:o,useProxy:s,errorTTL:i}),u=it.get(c);if(u&&u.until>Date.now())return{...u.result,fromCache:!0};u&&it.delete(c);let p=Ct.get(c);if(p)return p;let y=se(t,s)?ae(t,s):t,S=e.credentials;if(!S)try{let b=typeof location<"u"&&location.href?location.href:"http://localhost/",R=new URL(t,b);S=typeof location<"u"&&R.origin===location.origin?"include":"omit"}catch{S="omit"}let E=new AbortController,k=setTimeout(()=>E.abort("timeout"),o),F=(async()=>{try{let b=await fetch(y,{signal:E.signal,credentials:S,headers:r});if(!b.ok){let T={ok:!1,data:null,status:b.status,url:y,fromCache:!1,reason:"http_error"};if(it.set(c,{until:Date.now()+i,result:T}),!a){let W=`${b.status} ${b.statusText||""}`.trim();Pt.warnOnce(`http:${b.status}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${W} while fetching ${n} ${t}`)}return e.onError&&e.onError(T),T}if(n==="text")return{ok:!0,data:await b.text(),status:b.status,url:y,fromCache:!1};let R=await b.blob(),_=R.type||b.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ie(R),status:b.status,url:y,fromCache:!1,mime:_}:{ok:!0,data:R,status:b.status,url:y,fromCache:!1,mime:_}}catch(b){let R=b&&typeof b=="object"&&"name"in b&&b.name==="AbortError"?String(b.message||"").includes("timeout")?"timeout":"abort":"network",_={ok:!1,data:null,status:0,url:y,fromCache:!1,reason:R};if(it.set(c,{until:Date.now()+i,result:_}),!a){let T=`${R}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,W=R==="timeout"?`Timeout after ${o}ms. Consider increasing timeout or using a proxy for ${t}`:R==="abort"?`Request aborted while fetching ${n} ${t}`:`Network/CORS issue while fetching ${n} ${t}. A proxy may be required`;Pt.errorOnce(T,W)}return e.onError&&e.onError(_),_}finally{clearTimeout(k),Ct.delete(c)}})();return Ct.set(c,F),F}function H(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 G(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(t)||t.trim()==="none")return t;let o=V(t);if(!o)return t;let s=tt(o);if(f.background.has(s)){let i=f.background.get(s);return i?`url("${i}")`:"none"}try{let i=await B(s,{as:"dataURL",useProxy:e.useProxy});return i.ok?(f.background.set(s,i.data),`url("${i.data}")`):(f.background.set(s,null),"none")}catch{return f.background.set(s,null),"none"}}var ct=new Set(["meta","script","noscript","title","link","template"]),Z=new Set(["meta","link","style","title","noscript","script","template","svg","g","defs","use","marker","mask","clipPath","pattern","path","polygon","polyline","line","circle","ellipse","rect","filter","lineargradient","radialgradient","stop"]),le=["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 At(){for(let t of le){let e=String(t).toLowerCase();ct.has(e)||Z.has(e)||$t(e)}}function $t(t){if(t=String(t).toLowerCase(),Z.has(t)){let i={};return f.defaultStyle.set(t,i),i}if(f.defaultStyle.has(t))return f.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),s={};for(let i of o){if(Ut(i))continue;let r=o.getPropertyValue(i);s[i]=r}return e.removeChild(n),f.defaultStyle.set(t,s),s}var fe=/(?:^|-)(animation|transition)(?:-|$)/i,ue=/^(--|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,de=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 Ut(t){let e=String(t).toLowerCase();return!!(de.has(e)||ue.test(e)||fe.test(e))}function Q(t,e){if(e=String(e||"").toLowerCase(),Z.has(e))return"";let n=[],o=$t(e);for(let[s,i]of Object.entries(t)){if(Ut(s))continue;let r=o[s];i&&i!==r&&n.push(`${s}:${i}`)}return n.sort(),n.join(";")}function Et(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 kt(t){let e=new Map;for(let o of t){let s=f.defaultStyle.get(o);if(!s)continue;let i=Object.entries(s).map(([r,a])=>`${r}:${a};`).sort().join("");i&&(e.has(i)||e.set(i,[]),e.get(i).push(o))}let n="";for(let[o,s]of e.entries())n+=`${s.join(",")} { ${o} }
2
+ `;return n}function Ft(t){let e=Array.from(new Set(t.values())).filter(Boolean).sort(),n=new Map,o=1;for(let s of e)n.set(s,`c${o++}`);return n}function K(t,e=null){if(!(t instanceof Element))return window.getComputedStyle(t,e);let n=f.computedStyle.get(t);if(n||(n=new Map,f.computedStyle.set(t,n)),!n.has(e)){let o=window.getComputedStyle(t,e);n.set(e,o)}return n.get(e)}function vt(t){let e=t.replace(/^['"]|['"]$/g,"");if(e.startsWith("\\"))try{return String.fromCharCode(parseInt(e.replace("\\",""),16))}catch{return e}return e}function lt(t){let e={};for(let n of t)e[n]=t.getPropertyValue(n);return e}function X(t){let e=[],n=0,o=0;for(let s=0;s<t.length;s++){let i=t[s];i==="("&&n++,i===")"&&n--,i===","&&n===0&&(e.push(t.slice(o,s).trim()),o=s+1)}return e.push(t.slice(o).trim()),e}function Y(t,{fast:e=!1}={}){if(e)return t();"requestIdleCallback"in window?requestIdleCallback(t,{timeout:50}):setTimeout(t,1)}function j(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}var Bt=new WeakMap,Ot=new Map,Lt=0;function ft(){Lt++}var Wt=!1;function me(t=document.documentElement){if(!Wt){Wt=!0;try{new MutationObserver(()=>ft()).observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>ft()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let e=document.fonts;e&&(e.addEventListener?.("loadingdone",ft),e.ready?.then(()=>ft()).catch(()=>{}))}catch{}}}function he(t){let e={},n=t.getPropertyValue("visibility");for(let o=0;o<t.length;o++){let s=t[o],i=t.getPropertyValue(s);(s==="background-image"||s==="content")&&i.includes("url(")&&!i.includes("data:")&&(i="none"),e[s]=i}return n==="hidden"&&(e.opacity="0"),e}var qt=new WeakMap;function pe(t){let e=qt.get(t);return e||(e=Object.entries(t).sort((o,s)=>o[0]<s[0]?-1:o[0]>s[0]?1:0).map(([o,s])=>`${o}:${s}`).join(";"),qt.set(t,e),e)}function ge(t,e=null){let n=Bt.get(t);if(n&&n.epoch===Lt)return n.snapshot;let o=e||getComputedStyle(t),s=he(o);return Bt.set(t,{epoch:Lt,snapshot:s}),s}function ye(t,e){return t&&t.session&&t.persist?t:t&&(t.styleMap||t.styleCache||t.nodeMap)?{session:t,persist:{snapshotKeyCache:Ot,defaultStyle:f.defaultStyle,baseStyle:f.baseStyle,image:f.image,resource:f.resource,background:f.background,font:f.font},options:e||{}}:{session:f.session,persist:{snapshotKeyCache:Ot,defaultStyle:f.defaultStyle,baseStyle:f.baseStyle,image:f.image,resource:f.resource,background:f.background,font:f.font},options:t||e||{}}}async function ut(t,e,n,o){if(t.tagName==="STYLE")return;let s=ye(n,o);if((s.options&&s.options.cache||"auto")!=="disabled"&&me(document.documentElement),Z.has(t.tagName?.toLowerCase())){let S=t.getAttribute?.("style");S&&e.setAttribute("style",S)}let{session:r,persist:a}=s;r.styleCache.has(t)||r.styleCache.set(t,getComputedStyle(t));let c=r.styleCache.get(t),u=ge(t,c),p=pe(u),y=a.snapshotKeyCache.get(p);if(!y){let S=t.tagName?.toLowerCase()||"div";y=Q(u,S),a.snapshotKeyCache.set(p,y)}r.styleMap.set(e,y)}function we(t){return t=t.trim(),!t||/\:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(t)?t:`${t}:not([data-sd-slotted])`}function Se(t,e,n=!0){return t.split(",").map(o=>o.trim()).filter(Boolean).map(o=>{if(o.startsWith(":where(")||o.startsWith("@"))return o;let s=n?we(o):o;return`:where(${e} ${s})`}).join(", ")}function be(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,s,i)=>{let r=Se(i,e,!0);return`${o}${s}${r}{`}),t):""}function xe(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}function Ce(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 s of o.cssRules)e+=s.cssText+`
4
+ `}catch{}}catch{}return e}function Ae(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 $e(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 Ee(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 ke(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 Fe(t,e,n){let o=[];for(let s of e){let i=ke(t,s);i&&o.push(`${s}: ${i};`)}return o.length?`${n}{${o.join("")}}
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","")))}function et(t,e,n){if(!t)throw new Error("Invalid node");let o=new Set,s=null;if(t.nodeType===Node.ELEMENT_NODE){let r=(t.localName||t.tagName||"").toLowerCase();if(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox")||ct.has(r))return null}if(t.nodeType===Node.TEXT_NODE||t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if(t.getAttribute("data-capture")==="exclude"){let r=document.createElement("div"),a=t.getBoundingClientRect();return r.style.cssText=`display:inline-block;width:${a.width}px;height:${a.height}px;visibility:hidden;`,r}if(n.exclude&&Array.isArray(n.exclude))for(let r of n.exclude)try{if(t.matches?.(r)){let a=document.createElement("div"),c=t.getBoundingClientRect();return a.style.cssText=`display:inline-block;width:${c.width}px;height:${c.height}px;visibility:hidden;`,a}}catch(a){console.warn(`Invalid selector in exclude option: ${r}`,a)}if(typeof n.filter=="function")try{if(!n.filter(t)){let r=document.createElement("div"),a=t.getBoundingClientRect();return r.style.cssText=`display:inline-block;width:${a.width}px;height:${a.height}px;visibility:hidden;`,r}}catch(r){console.warn("Error in filter function:",r)}if(t.tagName==="IFRAME"){let r=document.createElement("div");return r.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;`,r}if(t.getAttribute("data-capture")==="placeholder"){let r=t.cloneNode(!1);e.nodeMap.set(r,t),ut(t,r,e,n);let a=document.createElement("div");return a.textContent=t.getAttribute("data-placeholder-text")||"",a.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",r.appendChild(a),r}if(t.tagName==="CANVAS"){let r=t.toDataURL(),a=document.createElement("img");return a.src=r,a.width=t.width,a.height=t.height,e.nodeMap.set(a,t),ut(t,a,e,n),a}let i;try{i=t.cloneNode(!1),e.nodeMap.set(i,t),t.tagName==="IMG"&&$e(t,i)}catch(r){throw console.error("[Snapdom] Failed to clone node:",t,r),r}if(t instanceof HTMLTextAreaElement){i.textContent=t.value,i.value=t.value;let r=t.getBoundingClientRect();return i.style.width=`${r.width}px`,i.style.height=`${r.height}px`,i}if(t instanceof HTMLInputElement&&(i.value=t.value,i.setAttribute("value",t.value),t.checked!==void 0&&(i.checked=t.checked,t.checked&&i.setAttribute("checked",""),t.indeterminate&&(i.indeterminate=t.indeterminate))),t instanceof HTMLSelectElement&&(s=t.value),ut(t,i,e,n),t.shadowRoot){try{let E=t.shadowRoot.querySelectorAll("slot");for(let k of E){let F=[];try{F=k.assignedNodes?.({flatten:!0})||k.assignedNodes?.()||[]}catch{F=k.assignedNodes?.()||[]}for(let b of F)o.add(b)}}catch{}let r=xe(e),a=`[data-sd="${r}"]`;try{i.setAttribute("data-sd",r)}catch{}let c=Ce(t.shadowRoot),u=be(c,a),p=Ee(c),y=Fe(t,p,a);Ae(i,y+u,r);let S=document.createDocumentFragment();for(let E of t.shadowRoot.childNodes){if(E.nodeType===Node.ELEMENT_NODE&&E.tagName==="STYLE")continue;let k=et(E,e,n);k&&S.appendChild(k)}i.appendChild(S)}if(t.tagName==="SLOT"){let r=t.assignedNodes?.({flatten:!0})||[],a=r.length>0?r:Array.from(t.childNodes),c=document.createDocumentFragment();for(let u of a){let p=et(u,e,n);p&&(ve(p),c.appendChild(p))}return c}for(let r of t.childNodes){if(o.has(r))continue;let a=et(r,e,n);a&&i.appendChild(a)}if(s!==null&&i instanceof HTMLSelectElement){i.value=s;for(let r of i.options)r.value===s?r.setAttribute("selected",""):r.removeAttribute("selected")}return i}var Le=[/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],Rt=[];function Dt(t){let e=Array.isArray(t)?t:[t];for(let n of e)n instanceof RegExp?Rt.push(n):typeof n=="string"?Rt.push(new RegExp(n,"i")):console.warn("[snapdom] Ignored invalid iconFont value:",n)}function D(t){let e=typeof t=="string"?t:"",n=[...Le,...Rt];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 jt(t,e,n,o=32,s="#000"){e=e.replace(/^['"]+|['"]+$/g,"");let i=window.devicePixelRatio||1;await document.fonts.ready;let r=document.createElement("span");r.textContent=t,r.style.position="absolute",r.style.visibility="hidden",r.style.fontFamily=`"${e}"`,r.style.fontWeight=n||"normal",r.style.fontSize=`${o}px`,r.style.lineHeight="1",r.style.whiteSpace="nowrap",r.style.padding="0",r.style.margin="0",document.body.appendChild(r);let a=r.getBoundingClientRect(),c=Math.ceil(a.width),u=Math.ceil(a.height);document.body.removeChild(r);let p=document.createElement("canvas");p.width=c*i,p.height=u*i;let y=p.getContext("2d");return y.scale(i,i),y.font=n?`${n} ${o}px "${e}"`:`${o}px "${e}"`,y.textAlign="left",y.textBaseline="top",y.fillStyle=s,y.fillText(t,0,0),{dataUrl:p.toDataURL(),width:c,height:u}}var Re=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]);function dt(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^['"]+|['"]+$/g,"");if(n&&!Re.has(n.toLowerCase()))return n}return""}function mt(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 Mt(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function Me(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function Ne(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let s=mt(n[1]),i=mt(n[2]);return{min:Math.min(s,i),max:Math.max(s,i)}}let o=mt(e);return{min:o,max:o}}function Te(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function Ie(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let i=parseFloat(n[1]),r=parseFloat(n[2]);return{min:Math.min(i,r),max:Math.max(i,r)}}let o=e.match(/(\d+(?:\.\d+)?)\s*%/),s=o?parseFloat(o[1]):100;return{min:s,max:s}}function _e(t,e){if(!t)return!1;try{let n=new URL(t,location.href);if(n.origin===location.origin)return!0;let s=n.host.toLowerCase();if(["fonts.googleapis.com","fonts.gstatic.com","use.typekit.net","p.typekit.net","kit.fontawesome.com","use.fontawesome.com"].some(a=>s.endsWith(a)))return!0;let r=(n.pathname+n.search).toLowerCase();if(/\bfont(s)?\b/.test(r)||/\.woff2?(\b|$)/.test(r))return!0;for(let a of e){let c=a.toLowerCase().replace(/\s+/g,"+"),u=a.toLowerCase().replace(/\s+/g,"-");if(r.includes(c)||r.includes(u))return!0}return!1}catch{return!1}}function Pe(t){let e=new Set;for(let n of t||[]){let o=String(n).split("__")[0]?.trim();o&&e.add(o)}return e}async function ht({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:o=[],useProxy:s=""}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let i=new Map;for(let l of t){let[m,h,w,d]=String(l).split("__");if(!m)continue;let g=i.get(m)||[];g.push({w:parseInt(h,10),s:w,st:parseInt(d,10)}),i.set(m,g)}let r=/@import\s+url\(["']?([^"')]+)["']?\)/g,a=/url\((["']?)([^"')]+)\1\)/g,c=/@font-face[^{}]*\{[^}]*\}/g;function u(l,m,h,w){if(!i.has(l))return!1;let d=i.get(l),g=Ne(h),C=Te(m),x=Ie(w),$=g.min!==g.max,v=g.min,N=A=>C.kind==="normal"&&A==="normal"||C.kind!=="normal"&&(A==="italic"||A==="oblique"),P=!1;for(let A of d){let L=$?A.w>=g.min&&A.w<=g.max:A.w===v,U=N(Mt(A.s)),O=A.st>=x.min&&A.st<=x.max;if(L&&U&&O){P=!0;break}}if(P)return!0;if(!$)for(let A of d){let L=N(Mt(A.s)),U=A.st>=x.min&&A.st<=x.max;if(Math.abs(v-A.w)<=300&&L&&U)return!0}return!1}function p(l){if(!l)return[];let m=[],h=l.split(",").map(w=>w.trim()).filter(Boolean);for(let w of h){let d=w.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!d)continue;let g=d[1],C=d[2],x=$=>{if(!$.includes("?"))return parseInt($,16);let v=parseInt($.replace(/\?/g,"0"),16),N=parseInt($.replace(/\?/g,"F"),16);return[v,N]};if(C){let $=x(g),v=x(C),N=Array.isArray($)?$[0]:$,P=Array.isArray(v)?v[1]:v;m.push([Math.min(N,P),Math.max(N,P)])}else{let $=x(g);Array.isArray($)?m.push([$[0],$[1]]):m.push([$,$])}}return m}function y(l,m){if(!m.length||!l||l.size===0)return!0;for(let h of l)for(let[w,d]of m)if(h>=w&&h<=d)return!0;return!1}function S(l,m){let h=[];if(!l)return h;for(let w of l.matchAll(a)){let d=(w[2]||"").trim();if(!(!d||d.startsWith("data:"))){if(!/^https?:/i.test(d))try{d=new URL(d,m||location.href).href}catch{}h.push(d)}}return h}async function E(l,m){let h=l;for(let w of l.matchAll(a)){let d=V(w[0]);if(!d)continue;let g=d;if(!g.startsWith("http")&&!g.startsWith("data:"))try{g=new URL(g,m||location.href).href}catch{}if(!D(g)){if(f.resource?.has(g)){f.font?.add(g),h=h.replace(w[0],`url(${f.resource.get(g)})`);continue}if(!f.font?.has(g))try{let C=await B(g,{as:"dataURL",useProxy:s,silent:!0});if(C.ok&&typeof C.data=="string"){let x=C.data;f.resource?.set(g,x),f.font?.add(g),h=h.replace(w[0],`url(${x})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",g)}}}return h}function k(l){if(!l.length)return null;let m=(x,$)=>l.some(([v,N])=>!(N<x||v>$)),h=m(0,255)||m(305,305),w=m(256,591)||m(7680,7935),d=m(880,1023),g=m(1024,1279);return m(7840,7929)||m(258,259)||m(416,417)||m(431,432)?"vietnamese":g?"cyrillic":d?"greek":w?"latin-ext":h?"latin":null}function F(l={}){let m=new Set((l.families||[]).map(d=>String(d).toLowerCase())),h=new Set((l.domains||[]).map(d=>String(d).toLowerCase())),w=new Set((l.subsets||[]).map(d=>String(d).toLowerCase()));return(d,g)=>{if(m.size&&m.has(d.family.toLowerCase()))return!0;if(h.size)for(let C of d.srcUrls)try{if(h.has(new URL(C).host.toLowerCase()))return!0}catch{}if(w.size){let C=k(g);if(C&&w.has(C))return!0}return!1}}let b=F(n);function R(l){if(!l)return l;let m=/@font-face[^{}]*\{[^}]*\}/gi,h=new Set,w=[];for(let g of l.match(m)||[]){let C=g.match(/font-family:\s*([^;]+);/i)?.[1]||"",x=dt(C),$=(g.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),v=(g.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),N=(g.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),P=(g.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),A=(g.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),L=S(A,location.href),U=L.length?L.map(Tt=>String(Tt).toLowerCase()).sort().join("|"):A.toLowerCase(),O=[String(x||"").toLowerCase(),$,v,N,P.toLowerCase(),U].join("|");h.has(O)||(h.add(O),w.push(g))}if(w.length===0)return l;let d=0;return l.replace(m,()=>w[d++]||"")}function _(){let l=Array.from(t||[]).sort().join("|"),m=n?JSON.stringify({families:(n.families||[]).map(d=>String(d).toLowerCase()).sort(),domains:(n.domains||[]).map(d=>String(d).toLowerCase()).sort(),subsets:(n.subsets||[]).map(d=>String(d).toLowerCase()).sort()}):"",h=(o||[]).map(d=>`${(d.family||"").toLowerCase()}::${d.weight||"normal"}::${d.style||"normal"}::${d.src||""}`).sort().join("|");return`fonts-embed-css::req=${l}::ex=${m}::lf=${h}::px=${s||""}`}let T=_();if(f.resource?.has(T))return f.resource.get(T);let W=Pe(t),q=[];for(let l of document.querySelectorAll("style")){let m=l.textContent||"";for(let h of m.matchAll(r)){let w=h[1];if(!w||D(w))continue;!!document.querySelector(`link[rel="stylesheet"][href="${w}"]`)||q.push(w)}}q.length&&await Promise.all(q.map(l=>new Promise(m=>{if(document.querySelector(`link[rel="stylesheet"][href="${l}"]`))return m(null);let h=document.createElement("link");h.rel="stylesheet",h.href=l,h.setAttribute("data-snapdom","injected-import"),h.onload=()=>m(h),h.onerror=()=>m(null),document.head.appendChild(h)})));let I="",J=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(l=>!!l.href);for(let l of J)try{if(D(l.href))continue;let m="",h=!1;try{h=new URL(l.href,location.href).origin===location.origin}catch{}if(!h&&!_e(l.href,W))continue;if(h){let d=Array.from(document.styleSheets).find(g=>g.href===l.href);if(d)try{let g=d.cssRules||[];m=Array.from(g).map(C=>C.cssText).join("")}catch{}}if(!m&&(m=(await B(l.href,{as:"text",useProxy:s})).data,D(l.href)))continue;let w="";for(let d of m.match(c)||[]){let g=(d.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),C=dt(g);if(!C||D(C))continue;let x=(d.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),$=(d.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),v=(d.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),N=(d.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),P=(d.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),A=S(P,l.href);if(!u(C,$,x,v))continue;let L=p(N);if(!y(e,L))continue;let U={family:C,weightSpec:x,styleSpec:$,stretchSpec:v,unicodeRange:N,srcRaw:P,srcUrls:A,href:l.href};if(n&&b(U,L))continue;let O=/url\(/i.test(P)?await E(d,l.href):d;w+=O+""}w.trim()&&(I+=w+"")}catch{console.warn("[snapdom] Failed to process stylesheet:",l.href)}for(let l of document.styleSheets)try{if(l.href&&J.some(h=>h.href===l.href))continue;let m=l.cssRules||[];for(let h of m){if(h.type!==CSSRule.FONT_FACE_RULE)continue;let w=(h.style.getPropertyValue("font-family")||"").trim(),d=dt(w);if(!d||D(d))continue;let g=(h.style.getPropertyValue("font-weight")||"400").trim(),C=(h.style.getPropertyValue("font-style")||"normal").trim(),x=(h.style.getPropertyValue("font-stretch")||"100%").trim(),$=(h.style.getPropertyValue("src")||"").trim(),v=(h.style.getPropertyValue("unicode-range")||"").trim(),N=S($,l.href||location.href);if(!u(d,C,g,x))continue;let P=p(v);if(!y(e,P))continue;let A={family:d,weightSpec:g,styleSpec:C,stretchSpec:x,unicodeRange:v,srcRaw:$,srcUrls:N,href:l.href||location.href};if(!(n&&b(A,P)))if(/url\(/i.test($)){let L=await E($,l.href||location.href);I+=`@font-face{font-family:${d};src:${L};font-style:${C};font-weight:${g};font-stretch:${x};${v?`unicode-range:${v};`:""}}`}else I+=`@font-face{font-family:${d};src:${$};font-style:${C};font-weight:${g};font-stretch:${x};${v?`unicode-range:${v};`:""}}`}}catch{}try{for(let l of document.fonts||[]){if(!l||!l.family||l.status!=="loaded"||!l._snapdomSrc)continue;let m=String(l.family).replace(/^['"]+|['"]+$/g,"");if(D(m)||!i.has(m)||n?.families&&n.families.some(w=>String(w).toLowerCase()===m.toLowerCase()))continue;let h=l._snapdomSrc;if(!String(h).startsWith("data:")){if(f.resource?.has(l._snapdomSrc))h=f.resource.get(l._snapdomSrc),f.font?.add(l._snapdomSrc);else if(!f.font?.has(l._snapdomSrc))try{let w=await B(l._snapdomSrc,{as:"dataURL",useProxy:s,silent:!0});if(w.ok&&typeof w.data=="string")h=w.data,f.resource?.set(l._snapdomSrc,h),f.font?.add(l._snapdomSrc);else continue}catch{console.warn("[snapdom] Failed to fetch dynamic font src:",l._snapdomSrc);continue}}I+=`@font-face{font-family:'${m}';src:url(${h});font-style:${l.style||"normal"};font-weight:${l.weight||"normal"};}`}}catch{}for(let l of o){if(!l||typeof l!="object")continue;let m=String(l.family||"").replace(/^['"]+|['"]+$/g,"");if(!m||D(m)||!i.has(m)||n?.families&&n.families.some(x=>String(x).toLowerCase()===m.toLowerCase()))continue;let h=l.weight!=null?String(l.weight):"normal",w=l.style!=null?String(l.style):"normal",d=l.stretchPct!=null?`${l.stretchPct}%`:"100%",g=String(l.src||""),C=g;if(!C.startsWith("data:")){if(f.resource?.has(g))C=f.resource.get(g),f.font?.add(g);else if(!f.font?.has(g))try{let x=await B(g,{as:"dataURL",useProxy:s,silent:!0});if(x.ok&&typeof x.data=="string")C=x.data,f.resource?.set(g,C),f.font?.add(g);else continue}catch{console.warn("[snapdom] Failed to fetch localFonts src:",g);continue}}I+=`@font-face{font-family:'${m}';src:url(${C});font-style:${w};font-weight:${h};font-stretch:${d};}`}return I&&(I=R(I),f.resource?.set(T,I)),I}function pt(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),o=r=>{let a=dt(r.fontFamily);if(!a)return;let c=(u,p,y)=>`${a}__${mt(u)}__${Mt(p)}__${Me(y)}`;e.add(c(r.fontWeight,r.fontStyle,r.fontStretch))};o(getComputedStyle(t));let s=getComputedStyle(t,"::before");s&&s.content&&s.content!=="none"&&o(s);let i=getComputedStyle(t,"::after");for(i&&i.content&&i.content!=="none"&&o(i);n.nextNode();){let r=n.currentNode,a=getComputedStyle(r);o(a);let c=getComputedStyle(r,"::before");c&&c.content&&c.content!=="none"&&o(c);let u=getComputedStyle(r,"::after");u&&u.content&&u.content!=="none"&&o(u)}return e}function gt(t){let e=new Set,n=s=>{if(s)for(let i of s)e.add(i.codePointAt(0))},o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;o.nextNode();){let s=o.currentNode;if(s.nodeType===Node.TEXT_NODE)n(s.nodeValue||"");else if(s.nodeType===Node.ELEMENT_NODE){let i=s;for(let r of["::before","::after"]){let c=getComputedStyle(i,r)?.getPropertyValue("content");if(!(!c||c==="none"))if(/^"/.test(c)||/^'/.test(c))n(c.slice(1,-1));else{let u=c.match(/\\[0-9A-Fa-f]{1,6}/g);if(u)for(let p of u)try{e.add(parseInt(p.slice(1),16))}catch{}}}}}return e}async function yt(t,e=1){try{await document.fonts.ready}catch{}let n=Array.from(t||[]).filter(Boolean);if(n.length===0)return;let o=()=>{let s=document.createElement("div");s.style.cssText="position: absolute !important;left: -9999px !important;top: 0 !important;opacity: 0 !important;pointer-events: none !important;contain: layout size style;";for(let i of n){let r=document.createElement("span");r.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",r.style.fontFamily=`"${i}"`,r.style.fontWeight="700",r.style.fontStyle="italic",r.style.fontSize="32px",r.style.lineHeight="1",r.style.whiteSpace="nowrap",r.style.margin="0",r.style.padding="0",s.appendChild(r)}document.body.appendChild(s),s.offsetWidth,document.body.removeChild(s)};for(let s=0;s<Math.max(1,e);s++)o(),await new Promise(i=>requestAnimationFrame(()=>requestAnimationFrame(i)))}async function Nt(t,e,n,o){if(!(t instanceof Element)||!(e instanceof Element))return;for(let r of["::before","::after","::first-letter"])try{let a=K(t,r);if(!a||typeof a[Symbol.iterator]!="function"||a.content==="none"&&a.backgroundImage==="none"&&a.backgroundColor==="transparent"&&(a.borderStyle==="none"||parseFloat(a.borderWidth)===0)&&(!a.transform||a.transform==="none")&&a.display==="inline")continue;if(r==="::first-letter"){let A=getComputedStyle(t);if(!(a.color!==A.color||a.fontSize!==A.fontSize||a.fontWeight!==A.fontWeight))continue;let U=Array.from(e.childNodes).find(_t=>_t.nodeType===Node.TEXT_NODE&&_t.textContent?.trim().length>0);if(!U)continue;let O=U.textContent,rt=O.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0],te=O.slice(rt?.length||0);if(!rt||/[\uD800-\uDFFF]/.test(rt))continue;let st=document.createElement("span");st.textContent=rt,st.dataset.snapdomPseudo="::first-letter";let ee=lt(a),ne=Q(ee,"span");n.styleMap.set(st,ne);let It=document.createTextNode(te);e.replaceChild(It,U),e.insertBefore(st,It);continue}let u=a.content,p=/counter\s*\(|counters\s*\(/.test(u)?"- ":vt(u),y=a.backgroundImage,S=a.backgroundColor,E=a.fontFamily,k=parseInt(a.fontSize)||32,F=parseInt(a.fontWeight)||!1,b=a.color||"#000",R=a.display,_=parseFloat(a.width),T=parseFloat(a.height),W=a.borderStyle,q=parseFloat(a.borderWidth),I=a.transform,J=D(E),l=u!=="none"&&p!=="",m=y&&y!=="none",h=S&&S!=="transparent"&&S!=="rgba(0, 0, 0, 0)",w=R!=="inline"&&(_>0||T>0),d=W&&W!=="none"&&q>0,g=I&&I!=="none";if(!(l||m||h||w||d||g))continue;let x=document.createElement("span");x.dataset.snapdomPseudo=r,x.style.verticalAlign="middle";let $=lt(a),v=Q($,"span");if(n.styleMap.set(x,v),J&&p.length===1){let{dataUrl:A,width:L,height:U}=await jt(p,E,F,k,b),O=document.createElement("img");O.src=A,O.style=`height:${k}px;width:${L/U*k}px;object-fit:contain;`,x.appendChild(O),e.dataset.snapdomHasIcon="true"}else if(p.startsWith("url(")){let A=V(p);if(A?.trim())try{let L=document.createElement("img"),U=await B(tt(A),{as:"dataURL",useProxy:o.useProxy});L.src=U.data,L.style=`width:${k}px;height:auto;object-fit:contain;`,x.appendChild(L)}catch(L){console.error(`[snapdom] Error in pseudo ${r} for`,t,L)}}else!J&&l&&(x.textContent=p);if(m)try{let A=X(y),L=await Promise.all(A.map(G));x.style.backgroundImage=L.join(", ")}catch(A){console.warn(`[snapdom] Failed to inline background-image for ${r}`,A)}if(h&&(x.style.backgroundColor=S),!(x.childNodes.length>0||x.textContent?.trim()!==""||m||h||w||d||g))continue;r==="::before"?e.insertBefore(x,e.firstChild):e.appendChild(x)}catch(a){console.warn(`[snapdom] Failed to capture ${r} for`,t,a)}let s=Array.from(t.children),i=Array.from(e.children).filter(r=>!r.dataset.snapdomPseudo);for(let r=0;r<Math.min(s.length,i.length);r++)await Nt(s[r],i[r],n,o)}function zt(t){if(!t)return;let e=new Set;if(t.querySelectorAll("use").forEach(a=>{let c=a.getAttribute("xlink:href")||a.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(a=>a.tagName.toLowerCase()==="symbol"),s=n.filter(a=>a.tagName.toLowerCase()==="defs"),i=t.querySelector("svg.inline-defs-container");i||(i=document.createElementNS("http://www.w3.org/2000/svg","svg"),i.setAttribute("aria-hidden","true"),i.setAttribute("style","position: absolute; width: 0; height: 0; overflow: hidden;"),i.classList.add("inline-defs-container"),t.insertBefore(i,t.firstChild));let r=new Set;t.querySelectorAll("symbol[id], defs > *[id]").forEach(a=>{r.add(a.id)}),e.forEach(a=>{if(r.has(a))return;let c=o.find(u=>u.id===a);if(c){i.appendChild(c.cloneNode(!0)),r.add(a);return}for(let u of s){let p=u.querySelector(`#${CSS.escape(a)}`);if(p){let y=i.querySelector("defs");y||(y=document.createElementNS("http://www.w3.org/2000/svg","defs"),i.appendChild(y)),y.appendChild(p.cloneNode(!0)),r.add(a);break}}})}async function Ht(t,e={}){let n={styleMap:f.session.styleMap,styleCache:f.session.styleCache,nodeMap:f.session.nodeMap},o,s="",i="";Ue(t);try{zt(t)}catch(a){console.warn("inlineExternal defs or symbol failed:",a)}try{o=et(t,n,e,t)}catch(a){throw console.warn("deepClone failed:",a),a}try{await Nt(t,o,n,e)}catch(a){console.warn("inlinePseudoElements failed:",a)}await qe(o);try{let a=o.querySelectorAll("style[data-sd]");for(let c of a)i+=c.textContent||"",c.remove()}catch{}let r=Ft(n.styleMap);s=Array.from(r.entries()).map(([a,c])=>`.${c}{${a}}`).join(""),s=i+s;for(let[a,c]of n.styleMap.entries()){if(a.tagName==="STYLE")continue;if(a.getRootNode&&a.getRootNode()instanceof ShadowRoot){a.setAttribute("style",c.replace(/;/g,"; "));continue}let u=r.get(c);u&&a.classList.add(u);let p=a.style?.backgroundImage,y=a.dataset?.snapdomHasIcon;p&&p!=="none"&&(a.style.backgroundImage=p),y&&(a.style.verticalAlign="middle",a.style.display="inline")}for(let[a,c]of n.nodeMap.entries()){let u=c.scrollLeft,p=c.scrollTop;if((u||p)&&a instanceof HTMLElement){a.style.overflow="hidden",a.style.scrollbarWidth="none",a.style.msOverflowStyle="none";let S=document.createElement("div");for(S.style.transform=`translate(${-u}px, ${-p}px)`,S.style.willChange="transform",S.style.display="inline-block",S.style.width="100%";a.firstChild;)S.appendChild(a.firstChild);a.appendChild(S)}}if(t===n.nodeMap.get(o)){let a=n.styleCache.get(t)||window.getComputedStyle(t);n.styleCache.set(t,a);let c=xt(a.transform);o.style.margin="0",o.style.position="static",o.style.top="auto",o.style.left="auto",o.style.right="auto",o.style.bottom="auto",o.style.zIndex="auto",o.style.float="none",o.style.clear="none",o.style.transform=c||""}for(let[a,c]of n.nodeMap.entries())c.tagName==="PRE"&&(a.style.marginTop="0",a.style.marginBlockStart="0");return{clone:o,classCSS:s,styleCache:n.styleCache}}function Ue(t){let e=getComputedStyle(t),n=e.outlineStyle,o=e.outlineWidth,s=e.borderStyle,i=e.borderWidth,r=n!=="none"&&parseFloat(o)>0,a=s==="none"||parseFloat(i)===0;r&&a&&(t.style.border=`${o} solid transparent`)}var nt=new Map;async function ot(t){if(f.resource?.has(t))return f.resource.get(t);if(nt.has(t))return nt.get(t);let e=(async()=>{let n=await B(t,{as:"dataURL",silent:!0});if(!n.ok||typeof n.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);return f.resource?.set(t,n.data),n.data})();nt.set(t,e);try{let n=await e;return nt.set(t,n),n}catch(n){throw nt.delete(t),n}}var Be=/\bblob:[^)"'\s]+/g;async function Vt(t){if(!t||t.indexOf("blob:")===-1)return t;let e=Array.from(new Set(t.match(Be)||[]));if(e.length===0)return t;let n=t;for(let o of e)try{let s=await ot(o);n=n.split(o).join(s)}catch{}return n}function wt(t){return typeof t=="string"&&t.startsWith("blob:")}function Oe(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 We(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}async function qe(t){if(!t)return;let e=t.querySelectorAll?t.querySelectorAll("img"):[];for(let r of e)try{let c=r.getAttribute("src")||r.currentSrc||"";if(wt(c)){let p=await ot(c);r.setAttribute("src",p)}let u=r.getAttribute("srcset");if(u&&u.includes("blob:")){let p=Oe(u),y=!1;for(let S of p)if(wt(S.url))try{S.url=await ot(S.url),y=!0}catch{}y&&r.setAttribute("srcset",We(p))}}catch{}let n=t.querySelectorAll?t.querySelectorAll("image"):[];for(let r of n)try{let a="http://www.w3.org/1999/xlink",c=r.getAttribute("href")||r.getAttributeNS?.(a,"href");if(wt(c)){let u=await ot(c);r.setAttribute("href",u),r.removeAttributeNS?.(a,"href")}}catch{}let o=t.querySelectorAll?t.querySelectorAll("[style*='blob:']"):[];for(let r of o)try{let a=r.getAttribute("style");if(a&&a.includes("blob:")){let c=await Vt(a);r.setAttribute("style",c)}}catch{}let s=t.querySelectorAll?t.querySelectorAll("style"):[];for(let r of s)try{let a=r.textContent||"";a.includes("blob:")&&(r.textContent=await Vt(a))}catch{}let i=["poster"];for(let r of i){let a=t.querySelectorAll?t.querySelectorAll(`[${r}^='blob:']`):[];for(let c of a)try{let u=c.getAttribute(r);wt(u)&&c.setAttribute(r,await ot(u))}catch{}}}async function Gt(t,e={}){let n=Array.from(t.querySelectorAll("img")),o=async s=>{if(!s.getAttribute("src")){let p=s.currentSrc||s.src||"";p&&s.setAttribute("src",p)}s.removeAttribute("srcset"),s.removeAttribute("sizes");let i=s.src||"";if(!i)return;let r=await B(i,{as:"dataURL",useProxy:e.useProxy});if(r.ok&&typeof r.data=="string"&&r.data.startsWith("data:")){s.src=r.data,s.width||(s.width=s.naturalWidth||100),s.height||(s.height=s.naturalHeight||100);return}let a=s.width||s.naturalWidth||100,c=s.height||s.naturalHeight||100,u=document.createElement("div");u.style.cssText=[`width:${a}px`,`height:${c}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${c}px`,"color:#666","font-size:12px","overflow:hidden"].join(";"),u.textContent="img",s.replaceWith(u)};for(let s=0;s<n.length;s+=4){let i=n.slice(s,s+4).map(o);await Promise.allSettled(i)}}async function St(t,e,n,o={}){let s=[[t,e]],i=["background-image","mask","mask-image","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source","border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;s.length;){let[r,a]=s.shift(),c=n.get(r)||K(r);n.has(r)||n.set(r,c);let u=(()=>{let S=c.getPropertyValue("border-image"),E=c.getPropertyValue("border-image-source");return S&&S!=="none"||E&&E!=="none"})();for(let S of i){if(["border-image-slice","border-image-width","border-image-outset","border-image-repeat"].includes(S)&&!u)continue;let E=c.getPropertyValue(S);if(!E||E==="none")continue;let k=X(E),F=await Promise.all(k.map(b=>G(b,o)));F.some(b=>b&&b!=="none"&&!/^url\(undefined/.test(b))&&a.style.setProperty(S,F.join(", "))}let p=Array.from(r.children),y=Array.from(a.children);for(let S=0;S<Math.min(p.length,y.length);S++)s.push([p[S],y[S]])}}async function Kt(t,e){if(!t)throw new Error("Element cannot be null or undefined");at(e.cache);let n=e.fast,o,s,i,r="",a="",c,u;({clone:o,classCSS:s,styleCache:i}=await Ht(t,e)),await new Promise(E=>{Y(async()=>{await Gt(o,e),E()},{fast:n})}),await new Promise(E=>{Y(async()=>{await St(t,o,i,e),E()},{fast:n})}),e.embedFonts&&await new Promise(E=>{Y(async()=>{let k=pt(t),F=gt(t);if(j){let b=new Set(Array.from(k).map(R=>String(R).split("__")[0]).filter(Boolean));await yt(b,2)}r=await ht({required:k,usedCodepoints:F,preCached:!1,exclude:e.excludeFonts,useProxy:e.useProxy}),E()},{fast:n})});let p=Et(o).sort(),y=p.join(",");f.baseStyle.has(y)?a=f.baseStyle.get(y):await new Promise(E=>{Y(()=>{a=kt(p),f.baseStyle.set(y,a),E()},{fast:n})}),await new Promise(E=>{Y(()=>{let k=t.getBoundingClientRect(),F=k.width,b=k.height,R=Number.isFinite(e.width),_=Number.isFinite(e.height),T=typeof scale=="number"&&scale!==1;if(!T){let w=k.width/k.height;R&&_?(F=e.width,b=e.height):R?(F=e.width,b=F/w):_&&(b=e.height,F=b*w)}if(F=Math.ceil(F),b=Math.ceil(b),o.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),o.style.transformOrigin="top left",!T&&(R||_)){let w=k.width,d=k.height,g=F/w,C=b/d,x=o.style.transform||"",$=`scale(${g}, ${C})`;o.style.transform=`${$} ${x}`.trim()}let W="http://www.w3.org/2000/svg",q=document.createElementNS(W,"foreignObject");q.setAttribute("width","100%"),q.setAttribute("height","100%");let I=document.createElement("style");I.textContent=a+r+"svg{overflow:visible;}"+s,q.appendChild(I),q.appendChild(o);let l=new XMLSerializer().serializeToString(q);u=`<svg xmlns="${W}" width="${F}" height="${b}" viewBox="0 0 ${F} ${b}">`+l+"</svg>",c=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(u)}`,E()},{fast:n})});let S=document.getElementById("snapdom-sandbox");return S&&S.style.position==="absolute"&&S.remove(),c}function De(t){if(t===!0)return"soft";if(t===!1)return"disabled";if(typeof t=="string"){let e=t.toLowerCase().trim();if(e==="disabled"||e==="full"||e==="auto"||e==="soft")return e}return"soft"}function Xt(t={}){let e=t.format??"png",n=De(t.cache);return{debug:t.debug??!1,fast:t.fast??!0,scale:t.scale??1,exclude:t.exclude??[],filter:t.filter??null,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,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 Yt(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 z(t,e){let n=new Image;n.crossOrigin="anonymous",n.loading="eager",n.decoding="sync",n.src=t;let o=j(),s=!1;o&&(document.body.appendChild(n),s=!0),await n.decode(),o&&await new Promise(p=>setTimeout(p,100));let i=n.naturalWidth*e.scale,r=n.naturalHeight*e.scale,a=document.createElement("canvas"),c=e.dpr;a.width=Math.ceil(i*c),a.height=Math.ceil(r*c),a.style.width=`${i}px`,a.style.height=`${r}px`;let u=a.getContext("2d");return u.scale(c,c),u.drawImage(n,0,0,i,r),s&&n.remove(),a}async function bt(t,e){let n=e.type;if(n==="svg"){let i=decodeURIComponent(t.split(",")[1]);return new Blob([i],{type:"image/svg+xml"})}let o=await z(t,e),s=e.backgroundColor?H(o,e.backgroundColor):o;return new Promise(i=>s.toBlob(r=>i(r),`image/${n}`,e.quality))}async function Jt(t,e){let n=await z(t,e),o=e.backgroundColor?H(n,e.backgroundColor):n,s=new Image;return s.src=o.toDataURL(`image/${e.format}`,e.quality),await s.decode(),s.style.width=`${o.width/e.dpr}px`,s.style.height=`${o.height/e.dpr}px`,s}async function Zt(t,e){if(e.format==="svg"){let i=await bt(t,{...e,type:"svg"}),r=URL.createObjectURL(i),a=document.createElement("a");a.href=r,a.download=e.filename,a.click(),URL.revokeObjectURL(r);return}let n=await z(t,e),o=e.backgroundColor?H(n,e.backgroundColor):n,s=document.createElement("a");s.href=o.toDataURL(`image/${e.format}`,e.quality),s.download=e.filename,s.click()}var Qt=Symbol("snapdom.internal");async function M(t,e){if(!t)throw new Error("Element cannot be null or undefined");let n=Xt(e);return n.iconFonts&&n.iconFonts.length>0&&Dt(n.iconFonts),M.capture(t,n,Qt)}M.capture=async(t,e,n)=>{if(n!==Qt)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");let o=await Kt(t,e),s=r=>({...e,...r||{}}),i=r=>a=>Jt(o,s({...a||{},format:r}));return{url:o,toRaw:()=>o,toImg:r=>Yt(o,s(r)),toCanvas:r=>z(o,s(r)),toBlob:r=>bt(o,s(r)),toPng:i("png"),toJpg:i("jpeg"),toWebp:i("webp"),download:r=>Zt(o,s(r))}};M.toRaw=(t,e)=>M(t,e).then(n=>n.toRaw());M.toImg=(t,e)=>M(t,e).then(n=>n.toImg());M.toCanvas=(t,e)=>M(t,e).then(n=>n.toCanvas());M.toBlob=(t,e)=>M(t,e).then(n=>n.toBlob());M.toPng=(t,e)=>M(t,{...e,format:"png"}).then(n=>n.toPng());M.toJpg=(t,e)=>M(t,{...e,format:"jpeg"}).then(n=>n.toJpg());M.toWebp=(t,e)=>M(t,{...e,format:"webp"}).then(n=>n.toWebp());M.download=(t,e)=>M(t,e).then(n=>n.download());async function je(t=document,e={}){let{embedFonts:n=!0,cacheOpt:o="full",useProxy:s=""}=e;at(o);try{await document.fonts.ready}catch{}At(),f.session=f.session||{},f.session.styleCache||(f.session.styleCache=new WeakMap);try{await St(t,void 0,f.session.styleCache,{useProxy:s})}catch{}let i=[],r=[];try{t?.querySelectorAll&&(i=Array.from(t.querySelectorAll("img[src]")),r=Array.from(t.querySelectorAll("*")))}catch{}let a=[];for(let c of i){let u=c?.src;if(u&&!f.image.has(u)){let p=Promise.resolve().then(()=>B(u,{as:"dataURL",useProxy:s})).then(y=>{f.image.set(u,y)}).catch(()=>{});a.push(p)}}for(let c of r){let u="";try{u=K(c).backgroundImage}catch{}if(u&&u!=="none"){let p=X(u);for(let y of p)if(y.startsWith("url(")){let S=Promise.resolve().then(()=>G(y,{...e,useProxy:s})).catch(()=>{});a.push(S)}}}if(n)try{let c=pt(t),u=gt(t);if(typeof j=="function"?j():j){let p=new Set(Array.from(c).map(y=>String(y).split("__")[0]).filter(Boolean));await yt(p,2)}await ht({required:c,usedCodepoints:u,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??s})}catch{}await Promise.allSettled(a)}export{je as preCache,M as snapdom};