@zumer/snapdom 1.9.10-dev.0 → 1.9.10-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/snapdom.js +56 -31
- package/dist/snapdom.min.js +3 -3
- package/dist/snapdom.min.mjs +5 -5
- package/dist/snapdom.mjs +56 -31
- package/package.json +1 -1
package/dist/snapdom.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
3
|
* snapdom
|
|
4
|
-
* v.1.9.10-dev.
|
|
4
|
+
* v.1.9.10-dev.1
|
|
5
5
|
* Author Juan Martin Muda
|
|
6
6
|
* License MIT
|
|
7
7
|
**/
|
|
@@ -344,7 +344,6 @@
|
|
|
344
344
|
"script",
|
|
345
345
|
"template",
|
|
346
346
|
// SVG whole namespace (safe for LeaderLine/presentation attrs)
|
|
347
|
-
"svg",
|
|
348
347
|
"g",
|
|
349
348
|
"defs",
|
|
350
349
|
"use",
|
|
@@ -884,9 +883,18 @@
|
|
|
884
883
|
}
|
|
885
884
|
}
|
|
886
885
|
if (node.tagName === "IFRAME") {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
886
|
+
if (options.placeholders) {
|
|
887
|
+
const fallback = document.createElement("div");
|
|
888
|
+
fallback.style.cssText = `width:${node.offsetWidth}px;height:${node.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;`;
|
|
889
|
+
inlineAllStyles(node, fallback, sessionCache, options);
|
|
890
|
+
return fallback;
|
|
891
|
+
} else {
|
|
892
|
+
const rect = node.getBoundingClientRect();
|
|
893
|
+
const spacer = document.createElement("div");
|
|
894
|
+
spacer.style.cssText = `display:inline-block;width:${rect.width}px;height:${rect.height}px;visibility:hidden;`;
|
|
895
|
+
inlineAllStyles(node, spacer, sessionCache, options);
|
|
896
|
+
return spacer;
|
|
897
|
+
}
|
|
890
898
|
}
|
|
891
899
|
if (node.getAttribute("data-capture") === "placeholder") {
|
|
892
900
|
const clone2 = node.cloneNode(false);
|
|
@@ -925,7 +933,6 @@
|
|
|
925
933
|
const rect = node.getBoundingClientRect();
|
|
926
934
|
clone.style.width = `${rect.width}px`;
|
|
927
935
|
clone.style.height = `${rect.height}px`;
|
|
928
|
-
return clone;
|
|
929
936
|
}
|
|
930
937
|
if (node instanceof HTMLInputElement) {
|
|
931
938
|
clone.value = node.value;
|
|
@@ -2142,20 +2149,26 @@
|
|
|
2142
2149
|
}
|
|
2143
2150
|
const w = img.width || img.naturalWidth || 100;
|
|
2144
2151
|
const h = img.height || img.naturalHeight || 100;
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2152
|
+
if (options.placeholders !== false) {
|
|
2153
|
+
const fallback = document.createElement("div");
|
|
2154
|
+
fallback.style.cssText = [
|
|
2155
|
+
`width:${w}px`,
|
|
2156
|
+
`height:${h}px`,
|
|
2157
|
+
"background:#ccc",
|
|
2158
|
+
"display:inline-block",
|
|
2159
|
+
"text-align:center",
|
|
2160
|
+
`line-height:${h}px`,
|
|
2161
|
+
"color:#666",
|
|
2162
|
+
"font-size:12px",
|
|
2163
|
+
"overflow:hidden"
|
|
2164
|
+
].join(";");
|
|
2165
|
+
fallback.textContent = "img";
|
|
2166
|
+
img.replaceWith(fallback);
|
|
2167
|
+
} else {
|
|
2168
|
+
const spacer = document.createElement("div");
|
|
2169
|
+
spacer.style.cssText = `display:inline-block;width:${w}px;height:${h}px;visibility:hidden;`;
|
|
2170
|
+
img.replaceWith(spacer);
|
|
2171
|
+
}
|
|
2159
2172
|
});
|
|
2160
2173
|
for (let i = 0; i < imgs.length; i += 4) {
|
|
2161
2174
|
const group = imgs.slice(i, i + 4).map(processImg);
|
|
@@ -2351,6 +2364,8 @@
|
|
|
2351
2364
|
// DOM filters
|
|
2352
2365
|
exclude: (_e = options.exclude) != null ? _e : [],
|
|
2353
2366
|
filter: (_f = options.filter) != null ? _f : null,
|
|
2367
|
+
placeholders: options.placeholders !== false,
|
|
2368
|
+
// default true
|
|
2354
2369
|
// Fuentes
|
|
2355
2370
|
embedFonts: (_g = options.embedFonts) != null ? _g : false,
|
|
2356
2371
|
iconFonts: Array.isArray(options.iconFonts) ? options.iconFonts : options.iconFonts ? [options.iconFonts] : [],
|
|
@@ -2392,31 +2407,41 @@
|
|
|
2392
2407
|
// src/exporters/toCanvas.js
|
|
2393
2408
|
function toCanvas(url, options) {
|
|
2394
2409
|
return __async(this, null, function* () {
|
|
2410
|
+
const { scale: scale2, dpr } = options;
|
|
2411
|
+
const safari = isSafari();
|
|
2395
2412
|
const img = new Image();
|
|
2396
2413
|
img.crossOrigin = "anonymous";
|
|
2397
2414
|
img.loading = "eager";
|
|
2398
2415
|
img.decoding = "sync";
|
|
2399
2416
|
img.src = url;
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2417
|
+
let tempSlot = null;
|
|
2418
|
+
if (safari) {
|
|
2419
|
+
tempSlot = document.createElement("div");
|
|
2420
|
+
tempSlot.setAttribute("aria-hidden", "true");
|
|
2421
|
+
tempSlot.style.cssText = "position:absolute;left:-99999px;top:0;width:0;height:0;overflow:hidden;opacity:0;pointer-events:none;contain:size layout style;";
|
|
2422
|
+
document.body.appendChild(tempSlot);
|
|
2423
|
+
tempSlot.appendChild(img);
|
|
2405
2424
|
}
|
|
2406
2425
|
yield img.decode();
|
|
2407
|
-
if (
|
|
2408
|
-
|
|
2409
|
-
|
|
2426
|
+
if (safari) {
|
|
2427
|
+
yield new Promise((r) => setTimeout(r, 100));
|
|
2428
|
+
}
|
|
2429
|
+
const width = img.naturalWidth * scale2;
|
|
2430
|
+
const height = img.naturalHeight * scale2;
|
|
2410
2431
|
const canvas = document.createElement("canvas");
|
|
2411
|
-
const dpr = options.dpr;
|
|
2412
2432
|
canvas.width = Math.ceil(width * dpr);
|
|
2413
2433
|
canvas.height = Math.ceil(height * dpr);
|
|
2414
2434
|
canvas.style.width = `${width}px`;
|
|
2415
2435
|
canvas.style.height = `${height}px`;
|
|
2416
2436
|
const ctx = canvas.getContext("2d");
|
|
2417
|
-
ctx.scale(dpr, dpr);
|
|
2437
|
+
if (dpr !== 1) ctx.scale(dpr, dpr);
|
|
2418
2438
|
ctx.drawImage(img, 0, 0, width, height);
|
|
2419
|
-
if (
|
|
2439
|
+
if (tempSlot && tempSlot.parentNode) {
|
|
2440
|
+
try {
|
|
2441
|
+
tempSlot.parentNode.removeChild(tempSlot);
|
|
2442
|
+
} catch (e) {
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2420
2445
|
return canvas;
|
|
2421
2446
|
});
|
|
2422
2447
|
}
|
package/dist/snapdom.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(()=>{var ke=Object.defineProperty,
|
|
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
|
|
1
|
+
(()=>{var ke=Object.defineProperty,ve=Object.defineProperties;var Fe=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)=>ve(t,Fe(e));var C=(t,e,n)=>new Promise((o,r)=>{var s=c=>{try{f(n.next(c))}catch(u){r(u)}},a=c=>{try{f(n.throw(c))}catch(u){r(u)}},f=c=>c.done?o(c.value):Promise.resolve(c.value).then(s,a);f((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 wt(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch(e){return t}}function Ne(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,r=0;function s(a,f,c){if(r>=n)return;let u=Date.now();(o.get(f)||0)>u||(o.set(f,u+e),r++,a==="warn"&&console&&console.warn?console.warn(`${t} ${c}`):console&&console.error&&console.error(`${t} ${c}`))}return{warnOnce(a,f){s("warn",a,f)},errorOnce(a,f){s("error",a,f)},reset(){o.clear(),r=0}}}var oe=Ne("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),qt=new Map,Et=new Map;function Me(t){return/^data:|^blob:|^about:blank$/.test(t)}function Te(t,e){if(!e||Me(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,f=e.headers||{},c=!!e.silent,u=Pe(t,{as:o,timeout:r,useProxy:s,errorTTL:a}),l=Et.get(u);if(l&&l.until>Date.now())return X(H({},l.result),{fromCache:!0});l&&Et.delete(u);let i=qt.get(u);if(i)return i;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 A=new AbortController,w=setTimeout(()=>A.abort("timeout"),r),F=C(null,null,function*(){var W,P;try{let v=yield fetch(h,{signal:A.signal,credentials:S,headers:f});if(!v.ok){let z={ok:!1,data:null,status:v.status,url:h,fromCache:!1,reason:"http_error"};if(Et.set(u,{until:Date.now()+a,result:z}),!c){let G=`${v.status} ${v.statusText||""}`.trim();oe.warnOnce(`http:${v.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 v.text(),status:v.status,url:h,fromCache:!1};let q=yield v.blob(),j=q.type||v.headers.get("content-type")||"";return o==="dataURL"?{ok:!0,data:yield _e(q),status:v.status,url:h,fromCache:!1,mime:j}:{ok:!0,data:q,status:v.status,url:h,fromCache:!1,mime:j}}catch(v){let q=v&&typeof v=="object"&&"name"in v&&v.name==="AbortError"?String(v.message||"").includes("timeout")?"timeout":"abort":"network",j={ok:!1,data:null,status:0,url:h,fromCache:!1,reason:q};if(Et.set(u,{until:Date.now()+a,result:j}),!c){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,F),F})}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=wt(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 kt=new Set(["meta","script","noscript","title","link","template"]),ht=new Set(["meta","link","style","title","noscript","script","template","g","defs","use","marker","mask","clipPath","pattern","path","polygon","polyline","line","circle","ellipse","rect","filter","lineargradient","radialgradient","stop"]),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();kt.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,f])=>`${a}:${f};`).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 vt(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 gt(t,e,n,o){return C(this,null,function*(){var h,S,A;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:f}=r;a.styleCache.has(t)||a.styleCache.set(t,getComputedStyle(t));let c=a.styleCache.get(t),u=ze(t,c),l=je(u),i=f.snapshotKeyCache.get(l);if(!i){let w=((A=t.tagName)==null?void 0:A.toLowerCase())||"div";i=pt(u,w),f.snapshotKeyCache.set(l,i)}a.styleMap.set(e,i)})}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
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
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&>.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);})();
|
|
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 St(t,e,n){var a,f,c,u,l;if(!t)throw new Error("Invalid node");let o=new Set,r=null;if(t.nodeType===Node.ELEMENT_NODE){let i=(t.localName||t.tagName||"").toLowerCase();if(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox")||kt.has(i))return null}if(t.nodeType===Node.TEXT_NODE||t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if(t.getAttribute("data-capture")==="exclude"){let i=document.createElement("div"),h=t.getBoundingClientRect();return i.style.cssText=`display:inline-block;width:${h.width}px;height:${h.height}px;visibility:hidden;`,i}if(n.exclude&&Array.isArray(n.exclude))for(let i of n.exclude)try{if((a=t.matches)!=null&&a.call(t,i)){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: ${i}`,h)}if(typeof n.filter=="function")try{if(!n.filter(t)){let i=document.createElement("div"),h=t.getBoundingClientRect();return i.style.cssText=`display:inline-block;width:${h.width}px;height:${h.height}px;visibility:hidden;`,i}}catch(i){console.warn("Error in filter function:",i)}if(t.tagName==="IFRAME")if(n.placeholders){let i=document.createElement("div");return i.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;`,gt(t,i,e,n),i}else{let i=t.getBoundingClientRect(),h=document.createElement("div");return h.style.cssText=`display:inline-block;width:${i.width}px;height:${i.height}px;visibility:hidden;`,gt(t,h,e,n),h}if(t.getAttribute("data-capture")==="placeholder"){let i=t.cloneNode(!1);e.nodeMap.set(i,t),gt(t,i,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;",i.appendChild(h),i}if(t.tagName==="CANVAS"){let i=t.toDataURL(),h=document.createElement("img");return h.src=i,h.width=t.width,h.height=t.height,e.nodeMap.set(h,t),gt(t,h,e,n),h}let s;try{s=t.cloneNode(!1),e.nodeMap.set(s,t),t.tagName==="IMG"&&Ze(t,s)}catch(i){throw console.error("[Snapdom] Failed to clone node:",t,i),i}if(t instanceof HTMLTextAreaElement){s.textContent=t.value,s.value=t.value;let i=t.getBoundingClientRect();s.style.width=`${i.width}px`,s.style.height=`${i.height}px`}if(t instanceof HTMLInputElement&&(s.value=t.value,s.setAttribute("value",t.value),t.checked!==void 0&&(s.checked=t.checked,t.checked&&s.setAttribute("checked",""),t.indeterminate&&(s.indeterminate=t.indeterminate))),t instanceof HTMLSelectElement&&(r=t.value),gt(t,s,e,n),t.shadowRoot){try{let I=t.shadowRoot.querySelectorAll("slot");for(let R of I){let W=[];try{W=((f=R.assignedNodes)==null?void 0:f.call(R,{flatten:!0}))||((c=R.assignedNodes)==null?void 0:c.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 i=Xe(e),h=`[data-sd="${i}"]`;try{s.setAttribute("data-sd",i)}catch(I){}let S=Ye(t.shadowRoot),A=Ke(S,h),w=Qe(S),F=en(t,w,h);Je(s,F+A,i);let _=document.createDocumentFragment();for(let I of t.shadowRoot.childNodes){if(I.nodeType===Node.ELEMENT_NODE&&I.tagName==="STYLE")continue;let R=St(I,e,n);R&&_.appendChild(R)}s.appendChild(_)}if(t.tagName==="SLOT"){let i=((l=t.assignedNodes)==null?void 0:l.call(t,{flatten:!0}))||[],h=i.length>0?i:Array.from(t.childNodes),S=document.createDocumentFragment();for(let A of h){let w=St(A,e,n);w&&(nn(w),S.appendChild(w))}return S}for(let i of t.childNodes){if(o.has(i))continue;let h=St(i,e,n);h&&s.appendChild(h)}if(r!==null&&s instanceof HTMLSelectElement){s.value=r;for(let i of s.options)i.value===r?i.setAttribute("selected",""):i.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 f=a.getBoundingClientRect(),c=Math.ceil(f.width),u=Math.ceil(f.height);document.body.removeChild(a);let l=document.createElement("canvas");l.width=c*s,l.height=u*s;let i=l.getContext("2d");return i.scale(s,s),i.font=n?`${n} ${o}px "${e}"`:`${o}px "${e}"`,i.textAlign="left",i.textBaseline="top",i.fillStyle=r,i.fillText(t,0,0),{dataUrl:l.toDataURL(),width:c,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(f=>r.endsWith(f)))return!0;let a=(n.pathname+n.search).toLowerCase();if(/\bfont(s)?\b/.test(a)||/\.woff2?(\b|$)/.test(a))return!0;for(let f of e){let c=f.toLowerCase().replace(/\s+/g,"+"),u=f.toLowerCase().replace(/\s+/g,"-");if(a.includes(c)||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 Nt(){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,yt,B,Ct,$t,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,f=/url\((["']?)([^"')]+)\1\)/g,c=/@font-face[^{}]*\{[^}]*\}/g;function u(d,y,g,x){if(!s.has(d))return!1;let p=s.get(d),b=an(g),$=cn(y),E=ln(x),k=b.min!==b.max,N=b.min,L=T=>$.kind==="normal"&&T==="normal"||$.kind!=="normal"&&(T==="italic"||T==="oblique"),M=!1;for(let T of p){let Z=k?T.w>=b.min&&T.w<=b.max:T.w===N,st=L(Yt(T.s)),mt=T.st>=E.min&&T.st<=E.max;if(Z&&st&&mt){M=!0;break}}if(M)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(N-T.w)<=300&&Z&&st)return!0}return!1}function l(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],$=p[2],E=k=>{if(!k.includes("?"))return parseInt(k,16);let N=parseInt(k.replace(/\?/g,"0"),16),L=parseInt(k.replace(/\?/g,"F"),16);return[N,L]};if($){let k=E(b),N=E($),L=Array.isArray(k)?k[0]:k,M=Array.isArray(N)?N[1]:N;y.push([Math.min(L,M),Math.max(L,M)])}else{let k=E(b);Array.isArray(k)?y.push([k[0],k[1]]):y.push([k,k])}}return y}function i(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(f)){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,$,E;let g=d;for(let k of d.matchAll(f)){let N=at(k[0]);if(!N)continue;let L=N;if(!L.startsWith("http")&&!L.startsWith("data:"))try{L=new URL(L,y||location.href).href}catch(M){}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 M=yield D(L,{as:"dataURL",useProxy:r,silent:!0});if(M.ok&&typeof M.data=="string"){let T=M.data;($=m.resource)==null||$.set(L,T),(E=m.font)==null||E.add(L),g=g.replace(k[0],`url(${T})`)}}catch(M){console.warn("[snapDOM] Failed to fetch font resource:",L)}}}return g})}function A(d){if(!d.length)return null;let y=(E,k)=>d.some(([N,L])=>!(L<E||N>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 $ of p.srcUrls)try{if(g.has(new URL($).host.toLowerCase()))return!0}catch(E){}if(x.size){let $=A(b);if($&&x.has($))return!0}return!1}}let F=w(n);function _(d){var b,$,E,k,N,L;if(!d)return d;let y=/@font-face[^{}]*\{[^}]*\}/gi,g=new Set,x=[];for(let M of d.match(y)||[]){let T=((b=M.match(/font-family:\s*([^;]+);/i))==null?void 0:b[1])||"",Z=Lt(T),st=((($=M.match(/font-weight:\s*([^;]+);/i))==null?void 0:$[1])||"400").trim(),mt=(((E=M.match(/font-style:\s*([^;]+);/i))==null?void 0:E[1])||"normal").trim(),Ce=(((k=M.match(/font-stretch:\s*([^;]+);/i))==null?void 0:k[1])||"100%").trim(),$e=(((N=M.match(/unicode-range:\s*([^;]+);/i))==null?void 0:N[1])||"").trim(),Zt=(((L=M.match(/src\s*:\s*([^;]+);/i))==null?void 0:L[1])||"").trim(),Qt=h(Zt,location.href),Ae=Qt.length?Qt.map(Ee=>String(Ee).toLowerCase()).sort().join("|"):Zt.toLowerCase(),te=[String(Z||"").toLowerCase(),st,mt,Ce,$e.toLowerCase(),Ae].join("|");g.has(te)||(g.add(te),x.push(M))}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 v="",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($=>$.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(c)||[]){let b=(((z=p.match(/font-family:\s*([^;]+);/i))==null?void 0:z[1])||"").trim(),$=Lt(b);if(!$||Y($))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(),N=(((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(),M=(((rt=p.match(/src\s*:\s*([^;]+);/i))==null?void 0:rt[1])||"").trim(),T=h(M,d.href);if(!u($,k,E,N))continue;let Z=l(L);if(!i(e,Z))continue;let st={family:$,weightSpec:E,styleSpec:k,stretchSpec:N,unicodeRange:L,srcRaw:M,srcUrls:T,href:d.href};if(n&&F(st,Z))continue;let mt=/url\(/i.test(M)?yield S(p,d.href):p;x+=mt+""}x.trim()&&(v+=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(),$=(g.style.getPropertyValue("font-style")||"normal").trim(),E=(g.style.getPropertyValue("font-stretch")||"100%").trim(),k=(g.style.getPropertyValue("src")||"").trim(),N=(g.style.getPropertyValue("unicode-range")||"").trim(),L=h(k,d.href||location.href);if(!u(p,$,b,E))continue;let M=l(N);if(!i(e,M))continue;let T={family:p,weightSpec:b,styleSpec:$,stretchSpec:E,unicodeRange:N,srcRaw:k,srcUrls:L,href:d.href||location.href};if(!(n&&F(T,M)))if(/url\(/i.test(k)){let Z=yield S(k,d.href||location.href);v+=`@font-face{font-family:${p};src:${Z};font-style:${$};font-weight:${b};font-stretch:${E};${N?`unicode-range:${N};`:""}}`}else v+=`@font-face{font-family:${p};src:${k};font-style:${$};font-weight:${b};font-stretch:${E};${N?`unicode-range:${N};`:""}}`}}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((yt=m.resource)!=null&&yt.has(d._snapdomSrc))g=m.resource.get(d._snapdomSrc),(B=m.font)==null||B.add(d._snapdomSrc);else if(!((Ct=m.font)!=null&&Ct.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,($t=m.resource)==null||$t.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}}v+=`@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||""),$=b;if(!$.startsWith("data:")){if((Ot=m.resource)!=null&&Ot.has(b))$=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")$=E.data,(J=m.resource)==null||J.set(b,$),(Q=m.font)==null||Q.add(b);else continue}catch(E){console.warn("[snapdom] Failed to fetch localFonts src:",b);continue}}v+=`@font-face{font-family:'${y}';src:url(${$});font-style:${x};font-weight:${g};font-stretch:${p};}`}return v&&(v=_(v),(dt=m.resource)==null||dt.set(R,v)),v})}function Mt(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),o=a=>{let f=Lt(a.fontFamily);if(!f)return;let c=(u,l,i)=>`${f}__${Rt(u)}__${Yt(l)}__${sn(i)}`;e.add(c(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,f=getComputedStyle(a);o(f);let c=getComputedStyle(a,"::before");c&&c.content&&c.content!=="none"&&o(c);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 f=getComputedStyle(s,a),c=f==null?void 0:f.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 l of u)try{e.add(parseInt(l.slice(1),16))}catch(i){}}}}}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 f of["::before","::after","::first-letter"])try{let c=lt(t,f);if(!c||typeof c[Symbol.iterator]!="function"||c.content==="none"&&c.backgroundImage==="none"&&c.backgroundColor==="transparent"&&(c.borderStyle==="none"||parseFloat(c.borderWidth)===0)&&(!c.transform||c.transform==="none")&&c.display==="inline")continue;if(f==="::first-letter"){let O=getComputedStyle(t);if(!(c.color!==O.color||c.fontSize!==O.fontSize||c.fontWeight!==O.fontWeight))continue;let J=Array.from(e.childNodes).find($=>{var E;return $.nodeType===Node.TEXT_NODE&&((E=$.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=vt(c),p=pt(x,"span");n.styleMap.set(g,p);let b=document.createTextNode(y);e.replaceChild(b,J),e.insertBefore(g,b);continue}let l=c.content,i=/counter\s*\(|counters\s*\(/.test(l)?"- ":Gt(l),h=c.backgroundImage,S=c.backgroundColor,A=c.fontFamily,w=parseInt(c.fontSize)||32,F=parseInt(c.fontWeight)||!1,_=c.color||"#000",I=c.display,R=parseFloat(c.width),W=parseFloat(c.height),P=c.borderStyle,v=parseFloat(c.borderWidth),q=c.transform,j=Y(A),z=l!=="none"&&i!=="",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"&&v>0,rt=q&&q!=="none";if(!(z||G||K||nt||ot||rt))continue;let B=document.createElement("span");B.dataset.snapdomPseudo=f,B.style.verticalAlign="middle";let Ct=vt(c),$t=pt(Ct,"span");if(n.styleMap.set(B,$t),j&&i.length===1){let{dataUrl:O,width:V,height:J}=yield fe(i,A,F,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(i.startsWith("url(")){let O=at(i);if(O!=null&&O.trim())try{let V=document.createElement("img"),J=yield D(wt(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 ${f} for`,t,V)}}else!j&&z&&(B.textContent=i);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 ${f}`,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;f==="::before"?e.insertBefore(B,e.firstChild):e.appendChild(B)}catch(c){console.warn(`[snapdom] Failed to capture ${f} for`,t,c)}let r=Array.from(t.children),s=Array.from(e.children).filter(f=>!f.dataset.snapdomPseudo);for(let f=0;f<Math.min(r.length,s.length);f++)yield Jt(r[f],s[f],n,o)})}function ue(t){if(!t)return;let e=new Set;if(t.querySelectorAll("use").forEach(f=>{let c=f.getAttribute("xlink:href")||f.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(f=>f.tagName.toLowerCase()==="symbol"),r=n.filter(f=>f.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(f=>{a.add(f.id)}),e.forEach(f=>{if(a.has(f))return;let c=o.find(u=>u.id===f);if(c){s.appendChild(c.cloneNode(!0)),a.add(f);return}for(let u of r){let l=u.querySelector(`#${CSS.escape(f)}`);if(l){let i=s.querySelector("defs");i||(i=document.createElementNS("http://www.w3.org/2000/svg","defs"),s.appendChild(i)),i.appendChild(l.cloneNode(!0)),a.add(f);break}}})}function me(n){return C(this,arguments,function*(t,e={}){var c,u;let o={styleMap:m.session.styleMap,styleCache:m.session.styleCache,nodeMap:m.session.nodeMap},r,s="",a="";dn(t);try{ue(t)}catch(l){console.warn("inlineExternal defs or symbol failed:",l)}try{r=St(t,o,e,t)}catch(l){throw console.warn("deepClone failed:",l),l}try{yield Jt(t,r,o,e)}catch(l){console.warn("inlinePseudoElements failed:",l)}yield gn(r);try{let l=r.querySelectorAll("style[data-sd]");for(let i of l)a+=i.textContent||"",i.remove()}catch(l){}let f=Ht(o.styleMap);s=Array.from(f.entries()).map(([l,i])=>`.${i}{${l}}`).join(""),s=a+s;for(let[l,i]of o.styleMap.entries()){if(l.tagName==="STYLE")continue;if(l.getRootNode&&l.getRootNode()instanceof ShadowRoot){l.setAttribute("style",i.replace(/;/g,"; "));continue}let h=f.get(i);h&&l.classList.add(h);let S=(c=l.style)==null?void 0:c.backgroundImage,A=(u=l.dataset)==null?void 0:u.snapdomHasIcon;S&&S!=="none"&&(l.style.backgroundImage=S),A&&(l.style.verticalAlign="middle",l.style.display="inline")}for(let[l,i]of o.nodeMap.entries()){let h=i.scrollLeft,S=i.scrollTop;if((h||S)&&l instanceof HTMLElement){l.style.overflow="hidden",l.style.scrollbarWidth="none",l.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%";l.firstChild;)w.appendChild(l.firstChild);l.appendChild(w)}}if(t===o.nodeMap.get(r)){let l=o.styleCache.get(t)||window.getComputedStyle(t);o.styleCache.set(t,l);let i=Wt(l.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=i||""}for(let[l,i]of o.nodeMap.entries())i.tagName==="PRE"&&(l.style.marginTop="0",l.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,f=r==="none"||parseFloat(s)===0;a&&f&&(t.style.border=`${o} solid transparent`)}var bt=new Map;function xt(t){return C(this,null,function*(){var n;if((n=m.resource)!=null&&n.has(t))return m.resource.get(t);if(bt.has(t))return bt.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});bt.set(t,e);try{let o=yield e;return bt.set(t,o),o}catch(o){throw bt.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 xt(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,f;if(!t)return;let e=t.querySelectorAll?t.querySelectorAll("img"):[];for(let c of e)try{let l=c.getAttribute("src")||c.currentSrc||"";if(_t(l)){let h=yield xt(l);c.setAttribute("src",h)}let i=c.getAttribute("srcset");if(i&&i.includes("blob:")){let h=hn(i),S=!1;for(let A of h)if(_t(A.url))try{A.url=yield xt(A.url),S=!0}catch(w){}S&&c.setAttribute("srcset",pn(h))}}catch(u){}let n=t.querySelectorAll?t.querySelectorAll("image"):[];for(let c of n)try{let u="http://www.w3.org/1999/xlink",l=c.getAttribute("href")||((a=c.getAttributeNS)==null?void 0:a.call(c,u,"href"));if(_t(l)){let i=yield xt(l);c.setAttribute("href",i),(f=c.removeAttributeNS)==null||f.call(c,u,"href")}}catch(u){}let o=t.querySelectorAll?t.querySelectorAll("[style*='blob:']"):[];for(let c of o)try{let u=c.getAttribute("style");if(u&&u.includes("blob:")){let l=yield de(u);c.setAttribute("style",l)}}catch(u){}let r=t.querySelectorAll?t.querySelectorAll("style"):[];for(let c of r)try{let u=c.textContent||"";u.includes("blob:")&&(c.textContent=yield de(u))}catch(u){}let s=["poster"];for(let c of s){let u=t.querySelectorAll?t.querySelectorAll(`[${c}^='blob:']`):[];for(let l of u)try{let i=l.getAttribute(c);_t(i)&&l.setAttribute(c,yield xt(i))}catch(i){}}})}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 l=s.currentSrc||s.src||"";l&&s.setAttribute("src",l)}s.removeAttribute("srcset"),s.removeAttribute("sizes");let a=s.src||"";if(!a)return;let f=yield D(a,{as:"dataURL",useProxy:e.useProxy});if(f.ok&&typeof f.data=="string"&&f.data.startsWith("data:")){s.src=f.data,s.width||(s.width=s.naturalWidth||100),s.height||(s.height=s.naturalHeight||100);return}let c=s.width||s.naturalWidth||100,u=s.height||s.naturalHeight||100;if(e.placeholders!==!1){let l=document.createElement("div");l.style.cssText=[`width:${c}px`,`height:${u}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${u}px`,"color:#666","font-size:12px","overflow:hidden"].join(";"),l.textContent="img",s.replaceWith(l)}else{let l=document.createElement("div");l.style.cssText=`display:inline-block;width:${c}px;height:${u}px;visibility:hidden;`,s.replaceWith(l)}});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 f=[[t,e]],c=["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(;f.length;){let[u,l]=f.shift(),i=n.get(u)||lt(u);n.has(u)||n.set(u,i);let h=(()=>{let w=i.getPropertyValue("border-image"),F=i.getPropertyValue("border-image-source");return w&&w!=="none"||F&&F!=="none"})();for(let w of c){if(["border-image-slice","border-image-width","border-image-outset","border-image-repeat"].includes(w)&&!h)continue;let F=i.getPropertyValue(w);if(!F||F==="none")continue;let _=ft(F),I=yield Promise.all(_.map(R=>ct(R,o)));I.some(R=>R&&R!=="none"&&!/^url\(undefined/.test(R))&&l.style.setProperty(w,I.join(", "))}let S=Array.from(u.children),A=Array.from(l.children);for(let w=0;w<Math.min(S.length,A.length);w++)f.push([S[w],A[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="",f="",c,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 A=Mt(t),w=Tt(t);if(tt){let F=new Set(Array.from(A).map(_=>String(_).split("__")[0]).filter(Boolean));yield It(F,2)}a=yield Nt({required:A,usedCodepoints:w,preCached:!1,exclude:e.excludeFonts,useProxy:e.useProxy}),S()}),{fast:n})}));let l=zt(o).sort(),i=l.join(",");m.baseStyle.has(i)?f=m.baseStyle.get(i):yield new Promise(S=>{ut(()=>{f=Vt(l),m.baseStyle.set(i,f),S()},{fast:n})}),yield new Promise(S=>{ut(()=>{let A=t.getBoundingClientRect(),w=A.width,F=A.height,_=Number.isFinite(e.width),I=Number.isFinite(e.height),R=typeof scale=="number"&&scale!==1;if(!R){let K=A.width/A.height;_&&I?(w=e.width,F=e.height):_?(w=e.width,F=w/K):I&&(F=e.height,w=F*K)}if(w=Math.ceil(w),F=Math.ceil(F),o.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),o.style.transformOrigin="top left",!R&&(_||I)){let K=A.width,nt=A.height,ot=w/K,rt=F/nt,yt=o.style.transform||"",B=`scale(${ot}, ${rt})`;o.style.transform=`${B} ${yt}`.trim()}let W="http://www.w3.org/2000/svg",P=document.createElementNS(W,"foreignObject");P.setAttribute("width","100%"),P.setAttribute("height","100%");let v=document.createElement("style");v.textContent=f+a+"svg{overflow:visible;}"+r,P.appendChild(v),P.appendChild(o);let j=new XMLSerializer().serializeToString(P);u=`<svg xmlns="${W}" width="${w}" height="${F}" viewBox="0 0 ${w} ${F}">`+j+"</svg>",c=`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(),c})}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,f,c,u,l,i,h,S,A,w,F,_;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:(f=t.exclude)!=null?f:[],filter:(c=t.filter)!=null?c:null,placeholders:t.placeholders!==!1,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:(l=t.excludeFonts)!=null?l:void 0,cache:n,useProxy:typeof t.useProxy=="string"?t.useProxy:"",width:(i=t.width)!=null?i:null,height:(h=t.height)!=null?h:null,format:e,type:(S=t.type)!=null?S:"svg",quality:(A=t.quality)!=null?A:.92,dpr:(w=t.dpr)!=null?w:window.devicePixelRatio||1,backgroundColor:(F=t.backgroundColor)!=null?F:["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{scale:n,dpr:o}=e,r=tt(),s=new Image;s.crossOrigin="anonymous",s.loading="eager",s.decoding="sync",s.src=t;let a=null;r&&(a=document.createElement("div"),a.setAttribute("aria-hidden","true"),a.style.cssText="position:absolute;left:-99999px;top:0;width:0;height:0;overflow:hidden;opacity:0;pointer-events:none;contain:size layout style;",document.body.appendChild(a),a.appendChild(s)),yield s.decode(),r&&(yield new Promise(i=>setTimeout(i,100)));let f=s.naturalWidth*n,c=s.naturalHeight*n,u=document.createElement("canvas");u.width=Math.ceil(f*o),u.height=Math.ceil(c*o),u.style.width=`${f}px`,u.style.height=`${c}px`;let l=u.getContext("2d");if(o!==1&&l.scale(o,o),l.drawImage(s,0,0,f,c),a&&a.parentNode)try{a.parentNode.removeChild(a)}catch(i){}return u})}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),f=document.createElement("a");f.href=a,f.download=e.filename,f.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=>f=>we(o,r(X(H({},f||{}),{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 c;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 f=[];for(let u of s){let l=u==null?void 0:u.src;if(l&&!m.image.has(l)){let i=Promise.resolve().then(()=>D(l,{as:"dataURL",useProxy:r})).then(h=>{m.image.set(l,h)}).catch(()=>{});f.push(i)}}for(let u of a){let l="";try{l=lt(u).backgroundImage}catch(i){}if(l&&l!=="none"){let i=ft(l);for(let h of i)if(h.startsWith("url(")){let S=Promise.resolve().then(()=>ct(h,X(H({},e),{useProxy:r}))).catch(()=>{});f.push(S)}}}if(n)try{let u=Mt(t),l=Tt(t);if(typeof tt=="function"?tt():tt){let i=new Set(Array.from(u).map(h=>String(h).split("__")[0]).filter(Boolean));yield It(i,2)}yield Nt({required:u,usedCodepoints:l,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:(c=e.useProxy)!=null?c:r})}catch(u){}yield Promise.allSettled(f)})}typeof window!="undefined"&&(window.snapdom=U,window.preCache=xe);})();
|
package/dist/snapdom.min.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
`;return n}function
|
|
3
|
-
`});let n=t.adoptedStyleSheets||[];for(let
|
|
4
|
-
`}catch{}}catch{}return e}function
|
|
5
|
-
`:""}function ve(t){t&&(t.nodeType===Node.ELEMENT_NODE&&t.setAttribute("data-sd-slotted",""),t.querySelectorAll&&t.querySelectorAll("*").forEach(e=>e.setAttribute("data-sd-slotted","")))}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};
|
|
1
|
+
var u={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 it(t="soft"){switch(t){case"auto":{u.session.styleMap=new Map,u.session.nodeMap=new Map;return}case"soft":{u.session.styleMap=new Map,u.session.nodeMap=new Map,u.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{u.session.styleMap=new Map,u.session.nodeMap=new Map,u.session.styleCache=new WeakMap,u.image.clear(),u.background.clear(),u.resource.clear(),u.font.clear();return}default:{u.session.styleMap=new Map,u.session.nodeMap=new Map,u.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,r)=>{let s=r.split(",").map(i=>i.trim());return s.length!==6?`matrix(${r})`:(s[4]="0",s[5]="0",`matrix(${s.join(", ")})`)}),e=e.replace(/matrix3d\(([^)]+)\)/g,(n,r)=>{let s=r.split(",").map(i=>i.trim());return s.length!==16?`matrix3d(${r})`:(s[12]="0",s[13]="0",`matrix3d(${s.join(", ")})`)}),e.trim().replace(/\s{2,}/g," ")}function et(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 r=new Map,s=0;function i(o,a,c){if(s>=n)return;let f=Date.now();(r.get(a)||0)>f||(r.set(a,f+e),s++,o==="warn"&&console&&console.warn?console.warn(`${t} ${c}`):console&&console.error&&console.error(`${t} ${c}`))}return{warnOnce(o,a){i("warn",o,a)},errorOnce(o,a){i("error",o,a)},reset(){r.clear(),s=0}}}var Pt=oe("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),Ct=new Map,ct=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/",r=new URL(t,n);return typeof location<"u"?r.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 r=new FileReader;r.onload=()=>e(String(r.result||"")),r.onerror=()=>n(new Error("read_failed")),r.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",r=e.timeout??3e3,s=e.useProxy||"",i=e.errorTTL??8e3,o=e.headers||{},a=!!e.silent,c=ce(t,{as:n,timeout:r,useProxy:s,errorTTL:i}),f=ct.get(c);if(f&&f.until>Date.now())return{...f.result,fromCache:!0};f&&ct.delete(c);let g=Ct.get(c);if(g)return g;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"),r),v=(async()=>{try{let b=await fetch(y,{signal:E.signal,credentials:S,headers:o});if(!b.ok){let T={ok:!1,data:null,status:b.status,url:y,fromCache:!1,reason:"http_error"};if(ct.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(ct.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 ${r}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,v),v}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 r=n.getContext("2d");return r.fillStyle=e,r.fillRect(0,0,n.width,n.height),r.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 r=V(t);if(!r)return t;let s=et(r);if(u.background.has(s)){let i=u.background.get(s);return i?`url("${i}")`:"none"}try{let i=await B(s,{as:"dataURL",useProxy:e.useProxy});return i.ok?(u.background.set(s,i.data),`url("${i.data}")`):(u.background.set(s,null),"none")}catch{return u.background.set(s,null),"none"}}var lt=new Set(["meta","script","noscript","title","link","template"]),Z=new Set(["meta","link","style","title","noscript","script","template","g","defs","use","marker","mask","clipPath","pattern","path","polygon","polyline","line","circle","ellipse","rect","filter","lineargradient","radialgradient","stop"]),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 $t(){for(let t of le){let e=String(t).toLowerCase();lt.has(e)||Z.has(e)||At(e)}}function At(t){if(t=String(t).toLowerCase(),Z.has(t)){let i={};return u.defaultStyle.set(t,i),i}if(u.defaultStyle.has(t))return u.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 r=getComputedStyle(n),s={};for(let i of r){if(Ut(i))continue;let o=r.getPropertyValue(i);s[i]=o}return e.removeChild(n),u.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=[],r=At(e);for(let[s,i]of Object.entries(t)){if(Ut(s))continue;let o=r[s];i&&i!==o&&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 r of t){let s=u.defaultStyle.get(r);if(!s)continue;let i=Object.entries(s).map(([o,a])=>`${o}:${a};`).sort().join("");i&&(e.has(i)||e.set(i,[]),e.get(i).push(r))}let n="";for(let[r,s]of e.entries())n+=`${s.join(",")} { ${r} }
|
|
2
|
+
`;return n}function vt(t){let e=Array.from(new Set(t.values())).filter(Boolean).sort(),n=new Map,r=1;for(let s of e)n.set(s,`c${r++}`);return n}function K(t,e=null){if(!(t instanceof Element))return window.getComputedStyle(t,e);let n=u.computedStyle.get(t);if(n||(n=new Map,u.computedStyle.set(t,n)),!n.has(e)){let r=window.getComputedStyle(t,e);n.set(e,r)}return n.get(e)}function Ft(t){let e=t.replace(/^['"]|['"]$/g,"");if(e.startsWith("\\"))try{return String.fromCharCode(parseInt(e.replace("\\",""),16))}catch{return e}return e}function ft(t){let e={};for(let n of t)e[n]=t.getPropertyValue(n);return e}function X(t){let e=[],n=0,r=0;for(let s=0;s<t.length;s++){let i=t[s];i==="("&&n++,i===")"&&n--,i===","&&n===0&&(e.push(t.slice(r,s).trim()),r=s+1)}return e.push(t.slice(r).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 ut(){Lt++}var Wt=!1;function me(t=document.documentElement){if(!Wt){Wt=!0;try{new MutationObserver(()=>ut()).observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>ut()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let e=document.fonts;e&&(e.addEventListener?.("loadingdone",ut),e.ready?.then(()=>ut()).catch(()=>{}))}catch{}}}function he(t){let e={},n=t.getPropertyValue("visibility");for(let r=0;r<t.length;r++){let s=t[r],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((r,s)=>r[0]<s[0]?-1:r[0]>s[0]?1:0).map(([r,s])=>`${r}:${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 r=e||getComputedStyle(t),s=he(r);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:u.defaultStyle,baseStyle:u.baseStyle,image:u.image,resource:u.resource,background:u.background,font:u.font},options:e||{}}:{session:u.session,persist:{snapshotKeyCache:Ot,defaultStyle:u.defaultStyle,baseStyle:u.baseStyle,image:u.image,resource:u.resource,background:u.background,font:u.font},options:t||e||{}}}async function tt(t,e,n,r){if(t.tagName==="STYLE")return;let s=ye(n,r);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:o,persist:a}=s;o.styleCache.has(t)||o.styleCache.set(t,getComputedStyle(t));let c=o.styleCache.get(t),f=ge(t,c),g=pe(f),y=a.snapshotKeyCache.get(g);if(!y){let S=t.tagName?.toLowerCase()||"div";y=Q(f,S),a.snapshotKeyCache.set(g,y)}o.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(r=>r.trim()).filter(Boolean).map(r=>{if(r.startsWith(":where(")||r.startsWith("@"))return r;let s=n?we(r):r;return`:where(${e} ${s})`}).join(", ")}function be(t,e){return t?(t=t.replace(/:host\(([^)]+)\)/g,(n,r)=>`:where(${e}:is(${r.trim()}))`),t=t.replace(/:host\b/g,`:where(${e})`),t=t.replace(/:host-context\(([^)]+)\)/g,(n,r)=>`:where(:where(${r.trim()}) ${e})`),t=t.replace(/::slotted\(([^)]+)\)/g,(n,r)=>`:where(${e} ${r.trim()})`),t=t.replace(/(^|})(\s*)([^@}{]+){/g,(n,r,s,i)=>{let o=Se(i,e,!0);return`${r}${s}${o}{`}),t):""}function xe(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}function Ce(t){let e="";try{t.querySelectorAll("style").forEach(r=>{e+=(r.textContent||"")+`
|
|
3
|
+
`});let n=t.adoptedStyleSheets||[];for(let r of n)try{if(r&&r.cssRules)for(let s of r.cssRules)e+=s.cssText+`
|
|
4
|
+
`}catch{}}catch{}return e}function $e(t,e,n){if(!e)return;let r=document.createElement("style");r.setAttribute("data-sd",n),r.textContent=e,t.insertBefore(r,t.firstChild||null)}function Ae(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,r;for(;r=n.exec(t);)e.add(r[1]);return e}function ke(t,e){try{let r=getComputedStyle(t).getPropertyValue(e).trim();if(r)return r}catch{}try{let r=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(r)return r}catch{}return""}function ve(t,e,n){let r=[];for(let s of e){let i=ke(t,s);i&&r.push(`${s}: ${i};`)}return r.length?`${n}{${r.join("")}}
|
|
5
|
+
`:""}function Fe(t){t&&(t.nodeType===Node.ELEMENT_NODE&&t.setAttribute("data-sd-slotted",""),t.querySelectorAll&&t.querySelectorAll("*").forEach(e=>e.setAttribute("data-sd-slotted","")))}function nt(t,e,n){if(!t)throw new Error("Invalid node");let r=new Set,s=null;if(t.nodeType===Node.ELEMENT_NODE){let o=(t.localName||t.tagName||"").toLowerCase();if(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox")||lt.has(o))return null}if(t.nodeType===Node.TEXT_NODE||t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if(t.getAttribute("data-capture")==="exclude"){let o=document.createElement("div"),a=t.getBoundingClientRect();return o.style.cssText=`display:inline-block;width:${a.width}px;height:${a.height}px;visibility:hidden;`,o}if(n.exclude&&Array.isArray(n.exclude))for(let o of n.exclude)try{if(t.matches?.(o)){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: ${o}`,a)}if(typeof n.filter=="function")try{if(!n.filter(t)){let o=document.createElement("div"),a=t.getBoundingClientRect();return o.style.cssText=`display:inline-block;width:${a.width}px;height:${a.height}px;visibility:hidden;`,o}}catch(o){console.warn("Error in filter function:",o)}if(t.tagName==="IFRAME")if(n.placeholders){let o=document.createElement("div");return o.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;`,tt(t,o,e,n),o}else{let o=t.getBoundingClientRect(),a=document.createElement("div");return a.style.cssText=`display:inline-block;width:${o.width}px;height:${o.height}px;visibility:hidden;`,tt(t,a,e,n),a}if(t.getAttribute("data-capture")==="placeholder"){let o=t.cloneNode(!1);e.nodeMap.set(o,t),tt(t,o,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;",o.appendChild(a),o}if(t.tagName==="CANVAS"){let o=t.toDataURL(),a=document.createElement("img");return a.src=o,a.width=t.width,a.height=t.height,e.nodeMap.set(a,t),tt(t,a,e,n),a}let i;try{i=t.cloneNode(!1),e.nodeMap.set(i,t),t.tagName==="IMG"&&Ae(t,i)}catch(o){throw console.error("[Snapdom] Failed to clone node:",t,o),o}if(t instanceof HTMLTextAreaElement){i.textContent=t.value,i.value=t.value;let o=t.getBoundingClientRect();i.style.width=`${o.width}px`,i.style.height=`${o.height}px`}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),tt(t,i,e,n),t.shadowRoot){try{let E=t.shadowRoot.querySelectorAll("slot");for(let k of E){let v=[];try{v=k.assignedNodes?.({flatten:!0})||k.assignedNodes?.()||[]}catch{v=k.assignedNodes?.()||[]}for(let b of v)r.add(b)}}catch{}let o=xe(e),a=`[data-sd="${o}"]`;try{i.setAttribute("data-sd",o)}catch{}let c=Ce(t.shadowRoot),f=be(c,a),g=Ee(c),y=ve(t,g,a);$e(i,y+f,o);let S=document.createDocumentFragment();for(let E of t.shadowRoot.childNodes){if(E.nodeType===Node.ELEMENT_NODE&&E.tagName==="STYLE")continue;let k=nt(E,e,n);k&&S.appendChild(k)}i.appendChild(S)}if(t.tagName==="SLOT"){let o=t.assignedNodes?.({flatten:!0})||[],a=o.length>0?o:Array.from(t.childNodes),c=document.createDocumentFragment();for(let f of a){let g=nt(f,e,n);g&&(Fe(g),c.appendChild(g))}return c}for(let o of t.childNodes){if(r.has(o))continue;let a=nt(o,e,n);a&&i.appendChild(a)}if(s!==null&&i instanceof HTMLSelectElement){i.value=s;for(let o of i.options)o.value===s?o.setAttribute("selected",""):o.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 r of n)if(r instanceof RegExp&&r.test(e))return!0;return!!(/icon/i.test(e)||/glyph/i.test(e)||/symbols/i.test(e)||/feather/i.test(e)||/fontawesome/i.test(e))}async function jt(t,e,n,r=32,s="#000"){e=e.replace(/^['"]+|['"]+$/g,"");let i=window.devicePixelRatio||1;await document.fonts.ready;let o=document.createElement("span");o.textContent=t,o.style.position="absolute",o.style.visibility="hidden",o.style.fontFamily=`"${e}"`,o.style.fontWeight=n||"normal",o.style.fontSize=`${r}px`,o.style.lineHeight="1",o.style.whiteSpace="nowrap",o.style.padding="0",o.style.margin="0",document.body.appendChild(o);let a=o.getBoundingClientRect(),c=Math.ceil(a.width),f=Math.ceil(a.height);document.body.removeChild(o);let g=document.createElement("canvas");g.width=c*i,g.height=f*i;let y=g.getContext("2d");return y.scale(i,i),y.font=n?`${n} ${r}px "${e}"`:`${r}px "${e}"`,y.textAlign="left",y.textBaseline="top",y.fillStyle=s,y.fillText(t,0,0),{dataUrl:g.toDataURL(),width:c,height:f}}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 Nt(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function Ne(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function Me(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 r=mt(e);return{min:r,max:r}}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]),o=parseFloat(n[2]);return{min:Math.min(i,o),max:Math.max(i,o)}}let r=e.match(/(\d+(?:\.\d+)?)\s*%/),s=r?parseFloat(r[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 o=(n.pathname+n.search).toLowerCase();if(/\bfont(s)?\b/.test(o)||/\.woff2?(\b|$)/.test(o))return!0;for(let a of e){let c=a.toLowerCase().replace(/\s+/g,"+"),f=a.toLowerCase().replace(/\s+/g,"-");if(o.includes(c)||o.includes(f))return!0}return!1}catch{return!1}}function Pe(t){let e=new Set;for(let n of t||[]){let r=String(n).split("__")[0]?.trim();r&&e.add(r)}return e}async function ht({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:r=[],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 p=i.get(m)||[];p.push({w:parseInt(h,10),s:w,st:parseInt(d,10)}),i.set(m,p)}let o=/@import\s+url\(["']?([^"')]+)["']?\)/g,a=/url\((["']?)([^"')]+)\1\)/g,c=/@font-face[^{}]*\{[^}]*\}/g;function f(l,m,h,w){if(!i.has(l))return!1;let d=i.get(l),p=Me(h),C=Te(m),x=Ie(w),A=p.min!==p.max,F=p.min,M=$=>C.kind==="normal"&&$==="normal"||C.kind!=="normal"&&($==="italic"||$==="oblique"),P=!1;for(let $ of d){let L=A?$.w>=p.min&&$.w<=p.max:$.w===F,U=M(Nt($.s)),O=$.st>=x.min&&$.st<=x.max;if(L&&U&&O){P=!0;break}}if(P)return!0;if(!A)for(let $ of d){let L=M(Nt($.s)),U=$.st>=x.min&&$.st<=x.max;if(Math.abs(F-$.w)<=300&&L&&U)return!0}return!1}function g(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 p=d[1],C=d[2],x=A=>{if(!A.includes("?"))return parseInt(A,16);let F=parseInt(A.replace(/\?/g,"0"),16),M=parseInt(A.replace(/\?/g,"F"),16);return[F,M]};if(C){let A=x(p),F=x(C),M=Array.isArray(A)?A[0]:A,P=Array.isArray(F)?F[1]:F;m.push([Math.min(M,P),Math.max(M,P)])}else{let A=x(p);Array.isArray(A)?m.push([A[0],A[1]]):m.push([A,A])}}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 p=d;if(!p.startsWith("http")&&!p.startsWith("data:"))try{p=new URL(p,m||location.href).href}catch{}if(!D(p)){if(u.resource?.has(p)){u.font?.add(p),h=h.replace(w[0],`url(${u.resource.get(p)})`);continue}if(!u.font?.has(p))try{let C=await B(p,{as:"dataURL",useProxy:s,silent:!0});if(C.ok&&typeof C.data=="string"){let x=C.data;u.resource?.set(p,x),u.font?.add(p),h=h.replace(w[0],`url(${x})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",p)}}}return h}function k(l){if(!l.length)return null;let m=(x,A)=>l.some(([F,M])=>!(M<x||F>A)),h=m(0,255)||m(305,305),w=m(256,591)||m(7680,7935),d=m(880,1023),p=m(1024,1279);return m(7840,7929)||m(258,259)||m(416,417)||m(431,432)?"vietnamese":p?"cyrillic":d?"greek":w?"latin-ext":h?"latin":null}function v(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,p)=>{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(p);if(C&&w.has(C))return!0}return!1}}let b=v(n);function R(l){if(!l)return l;let m=/@font-face[^{}]*\{[^}]*\}/gi,h=new Set,w=[];for(let p of l.match(m)||[]){let C=p.match(/font-family:\s*([^;]+);/i)?.[1]||"",x=dt(C),A=(p.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),F=(p.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),M=(p.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),P=(p.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),$=(p.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),L=S($,location.href),U=L.length?L.map(Tt=>String(Tt).toLowerCase()).sort().join("|"):$.toLowerCase(),O=[String(x||"").toLowerCase(),A,F,M,P.toLowerCase(),U].join("|");h.has(O)||(h.add(O),w.push(p))}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=(r||[]).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(u.resource?.has(T))return u.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(o)){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(p=>p.href===l.href);if(d)try{let p=d.cssRules||[];m=Array.from(p).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 p=(d.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),C=dt(p);if(!C||D(C))continue;let x=(d.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),A=(d.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),F=(d.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),M=(d.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),P=(d.match(/src\s*:\s*([^;]+);/i)?.[1]||"").trim(),$=S(P,l.href);if(!f(C,A,x,F))continue;let L=g(M);if(!y(e,L))continue;let U={family:C,weightSpec:x,styleSpec:A,stretchSpec:F,unicodeRange:M,srcRaw:P,srcUrls:$,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 p=(h.style.getPropertyValue("font-weight")||"400").trim(),C=(h.style.getPropertyValue("font-style")||"normal").trim(),x=(h.style.getPropertyValue("font-stretch")||"100%").trim(),A=(h.style.getPropertyValue("src")||"").trim(),F=(h.style.getPropertyValue("unicode-range")||"").trim(),M=S(A,l.href||location.href);if(!f(d,C,p,x))continue;let P=g(F);if(!y(e,P))continue;let $={family:d,weightSpec:p,styleSpec:C,stretchSpec:x,unicodeRange:F,srcRaw:A,srcUrls:M,href:l.href||location.href};if(!(n&&b($,P)))if(/url\(/i.test(A)){let L=await E(A,l.href||location.href);I+=`@font-face{font-family:${d};src:${L};font-style:${C};font-weight:${p};font-stretch:${x};${F?`unicode-range:${F};`:""}}`}else I+=`@font-face{font-family:${d};src:${A};font-style:${C};font-weight:${p};font-stretch:${x};${F?`unicode-range:${F};`:""}}`}}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(u.resource?.has(l._snapdomSrc))h=u.resource.get(l._snapdomSrc),u.font?.add(l._snapdomSrc);else if(!u.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,u.resource?.set(l._snapdomSrc,h),u.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 r){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%",p=String(l.src||""),C=p;if(!C.startsWith("data:")){if(u.resource?.has(p))C=u.resource.get(p),u.font?.add(p);else if(!u.font?.has(p))try{let x=await B(p,{as:"dataURL",useProxy:s,silent:!0});if(x.ok&&typeof x.data=="string")C=x.data,u.resource?.set(p,C),u.font?.add(p);else continue}catch{console.warn("[snapdom] Failed to fetch localFonts src:",p);continue}}I+=`@font-face{font-family:'${m}';src:url(${C});font-style:${w};font-weight:${h};font-stretch:${d};}`}return I&&(I=R(I),u.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),r=o=>{let a=dt(o.fontFamily);if(!a)return;let c=(f,g,y)=>`${a}__${mt(f)}__${Nt(g)}__${Ne(y)}`;e.add(c(o.fontWeight,o.fontStyle,o.fontStretch))};r(getComputedStyle(t));let s=getComputedStyle(t,"::before");s&&s.content&&s.content!=="none"&&r(s);let i=getComputedStyle(t,"::after");for(i&&i.content&&i.content!=="none"&&r(i);n.nextNode();){let o=n.currentNode,a=getComputedStyle(o);r(a);let c=getComputedStyle(o,"::before");c&&c.content&&c.content!=="none"&&r(c);let f=getComputedStyle(o,"::after");f&&f.content&&f.content!=="none"&&r(f)}return e}function gt(t){let e=new Set,n=s=>{if(s)for(let i of s)e.add(i.codePointAt(0))},r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;r.nextNode();){let s=r.currentNode;if(s.nodeType===Node.TEXT_NODE)n(s.nodeValue||"");else if(s.nodeType===Node.ELEMENT_NODE){let i=s;for(let o of["::before","::after"]){let c=getComputedStyle(i,o)?.getPropertyValue("content");if(!(!c||c==="none"))if(/^"/.test(c)||/^'/.test(c))n(c.slice(1,-1));else{let f=c.match(/\\[0-9A-Fa-f]{1,6}/g);if(f)for(let g of f)try{e.add(parseInt(g.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 r=()=>{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 o=document.createElement("span");o.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",o.style.fontFamily=`"${i}"`,o.style.fontWeight="700",o.style.fontStyle="italic",o.style.fontSize="32px",o.style.lineHeight="1",o.style.whiteSpace="nowrap",o.style.margin="0",o.style.padding="0",s.appendChild(o)}document.body.appendChild(s),s.offsetWidth,document.body.removeChild(s)};for(let s=0;s<Math.max(1,e);s++)r(),await new Promise(i=>requestAnimationFrame(()=>requestAnimationFrame(i)))}async function Mt(t,e,n,r){if(!(t instanceof Element)||!(e instanceof Element))return;for(let o of["::before","::after","::first-letter"])try{let a=K(t,o);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(o==="::first-letter"){let $=getComputedStyle(t);if(!(a.color!==$.color||a.fontSize!==$.fontSize||a.fontWeight!==$.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,st=O.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0],te=O.slice(st?.length||0);if(!st||/[\uD800-\uDFFF]/.test(st))continue;let at=document.createElement("span");at.textContent=st,at.dataset.snapdomPseudo="::first-letter";let ee=ft(a),ne=Q(ee,"span");n.styleMap.set(at,ne);let It=document.createTextNode(te);e.replaceChild(It,U),e.insertBefore(at,It);continue}let f=a.content,g=/counter\s*\(|counters\s*\(/.test(f)?"- ":Ft(f),y=a.backgroundImage,S=a.backgroundColor,E=a.fontFamily,k=parseInt(a.fontSize)||32,v=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=f!=="none"&&g!=="",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,p=I&&I!=="none";if(!(l||m||h||w||d||p))continue;let x=document.createElement("span");x.dataset.snapdomPseudo=o,x.style.verticalAlign="middle";let A=ft(a),F=Q(A,"span");if(n.styleMap.set(x,F),J&&g.length===1){let{dataUrl:$,width:L,height:U}=await jt(g,E,v,k,b),O=document.createElement("img");O.src=$,O.style=`height:${k}px;width:${L/U*k}px;object-fit:contain;`,x.appendChild(O),e.dataset.snapdomHasIcon="true"}else if(g.startsWith("url(")){let $=V(g);if($?.trim())try{let L=document.createElement("img"),U=await B(et($),{as:"dataURL",useProxy:r.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 ${o} for`,t,L)}}else!J&&l&&(x.textContent=g);if(m)try{let $=X(y),L=await Promise.all($.map(G));x.style.backgroundImage=L.join(", ")}catch($){console.warn(`[snapdom] Failed to inline background-image for ${o}`,$)}if(h&&(x.style.backgroundColor=S),!(x.childNodes.length>0||x.textContent?.trim()!==""||m||h||w||d||p))continue;o==="::before"?e.insertBefore(x,e.firstChild):e.appendChild(x)}catch(a){console.warn(`[snapdom] Failed to capture ${o} for`,t,a)}let s=Array.from(t.children),i=Array.from(e.children).filter(o=>!o.dataset.snapdomPseudo);for(let o=0;o<Math.min(s.length,i.length);o++)await Mt(s[o],i[o],n,r)}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")),r=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 o=new Set;t.querySelectorAll("symbol[id], defs > *[id]").forEach(a=>{o.add(a.id)}),e.forEach(a=>{if(o.has(a))return;let c=r.find(f=>f.id===a);if(c){i.appendChild(c.cloneNode(!0)),o.add(a);return}for(let f of s){let g=f.querySelector(`#${CSS.escape(a)}`);if(g){let y=i.querySelector("defs");y||(y=document.createElementNS("http://www.w3.org/2000/svg","defs"),i.appendChild(y)),y.appendChild(g.cloneNode(!0)),o.add(a);break}}})}async function Ht(t,e={}){let n={styleMap:u.session.styleMap,styleCache:u.session.styleCache,nodeMap:u.session.nodeMap},r,s="",i="";Ue(t);try{zt(t)}catch(a){console.warn("inlineExternal defs or symbol failed:",a)}try{r=nt(t,n,e,t)}catch(a){throw console.warn("deepClone failed:",a),a}try{await Mt(t,r,n,e)}catch(a){console.warn("inlinePseudoElements failed:",a)}await qe(r);try{let a=r.querySelectorAll("style[data-sd]");for(let c of a)i+=c.textContent||"",c.remove()}catch{}let o=vt(n.styleMap);s=Array.from(o.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 f=o.get(c);f&&a.classList.add(f);let g=a.style?.backgroundImage,y=a.dataset?.snapdomHasIcon;g&&g!=="none"&&(a.style.backgroundImage=g),y&&(a.style.verticalAlign="middle",a.style.display="inline")}for(let[a,c]of n.nodeMap.entries()){let f=c.scrollLeft,g=c.scrollTop;if((f||g)&&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(${-f}px, ${-g}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(r)){let a=n.styleCache.get(t)||window.getComputedStyle(t);n.styleCache.set(t,a);let c=xt(a.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[a,c]of n.nodeMap.entries())c.tagName==="PRE"&&(a.style.marginTop="0",a.style.marginBlockStart="0");return{clone:r,classCSS:s,styleCache:n.styleCache}}function Ue(t){let e=getComputedStyle(t),n=e.outlineStyle,r=e.outlineWidth,s=e.borderStyle,i=e.borderWidth,o=n!=="none"&&parseFloat(r)>0,a=s==="none"||parseFloat(i)===0;o&&a&&(t.style.border=`${r} solid transparent`)}var ot=new Map;async function rt(t){if(u.resource?.has(t))return u.resource.get(t);if(ot.has(t))return ot.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 u.resource?.set(t,n.data),n.data})();ot.set(t,e);try{let n=await e;return ot.set(t,n),n}catch(n){throw ot.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 r of e)try{let s=await rt(r);n=n.split(r).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 o of e)try{let c=o.getAttribute("src")||o.currentSrc||"";if(wt(c)){let g=await rt(c);o.setAttribute("src",g)}let f=o.getAttribute("srcset");if(f&&f.includes("blob:")){let g=Oe(f),y=!1;for(let S of g)if(wt(S.url))try{S.url=await rt(S.url),y=!0}catch{}y&&o.setAttribute("srcset",We(g))}}catch{}let n=t.querySelectorAll?t.querySelectorAll("image"):[];for(let o of n)try{let a="http://www.w3.org/1999/xlink",c=o.getAttribute("href")||o.getAttributeNS?.(a,"href");if(wt(c)){let f=await rt(c);o.setAttribute("href",f),o.removeAttributeNS?.(a,"href")}}catch{}let r=t.querySelectorAll?t.querySelectorAll("[style*='blob:']"):[];for(let o of r)try{let a=o.getAttribute("style");if(a&&a.includes("blob:")){let c=await Vt(a);o.setAttribute("style",c)}}catch{}let s=t.querySelectorAll?t.querySelectorAll("style"):[];for(let o of s)try{let a=o.textContent||"";a.includes("blob:")&&(o.textContent=await Vt(a))}catch{}let i=["poster"];for(let o of i){let a=t.querySelectorAll?t.querySelectorAll(`[${o}^='blob:']`):[];for(let c of a)try{let f=c.getAttribute(o);wt(f)&&c.setAttribute(o,await rt(f))}catch{}}}async function Gt(t,e={}){let n=Array.from(t.querySelectorAll("img")),r=async s=>{if(!s.getAttribute("src")){let f=s.currentSrc||s.src||"";f&&s.setAttribute("src",f)}s.removeAttribute("srcset"),s.removeAttribute("sizes");let i=s.src||"";if(!i)return;let o=await B(i,{as:"dataURL",useProxy:e.useProxy});if(o.ok&&typeof o.data=="string"&&o.data.startsWith("data:")){s.src=o.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;if(e.placeholders!==!1){let f=document.createElement("div");f.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(";"),f.textContent="img",s.replaceWith(f)}else{let f=document.createElement("div");f.style.cssText=`display:inline-block;width:${a}px;height:${c}px;visibility:hidden;`,s.replaceWith(f)}};for(let s=0;s<n.length;s+=4){let i=n.slice(s,s+4).map(r);await Promise.allSettled(i)}}async function St(t,e,n,r={}){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[o,a]=s.shift(),c=n.get(o)||K(o);n.has(o)||n.set(o,c);let f=(()=>{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)&&!f)continue;let E=c.getPropertyValue(S);if(!E||E==="none")continue;let k=X(E),v=await Promise.all(k.map(b=>G(b,r)));v.some(b=>b&&b!=="none"&&!/^url\(undefined/.test(b))&&a.style.setProperty(S,v.join(", "))}let g=Array.from(o.children),y=Array.from(a.children);for(let S=0;S<Math.min(g.length,y.length);S++)s.push([g[S],y[S]])}}async function Kt(t,e){if(!t)throw new Error("Element cannot be null or undefined");it(e.cache);let n=e.fast,r,s,i,o="",a="",c,f;({clone:r,classCSS:s,styleCache:i}=await Ht(t,e)),await new Promise(E=>{Y(async()=>{await Gt(r,e),E()},{fast:n})}),await new Promise(E=>{Y(async()=>{await St(t,r,i,e),E()},{fast:n})}),e.embedFonts&&await new Promise(E=>{Y(async()=>{let k=pt(t),v=gt(t);if(j){let b=new Set(Array.from(k).map(R=>String(R).split("__")[0]).filter(Boolean));await yt(b,2)}o=await ht({required:k,usedCodepoints:v,preCached:!1,exclude:e.excludeFonts,useProxy:e.useProxy}),E()},{fast:n})});let g=Et(r).sort(),y=g.join(",");u.baseStyle.has(y)?a=u.baseStyle.get(y):await new Promise(E=>{Y(()=>{a=kt(g),u.baseStyle.set(y,a),E()},{fast:n})}),await new Promise(E=>{Y(()=>{let k=t.getBoundingClientRect(),v=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&&_?(v=e.width,b=e.height):R?(v=e.width,b=v/w):_&&(b=e.height,v=b*w)}if(v=Math.ceil(v),b=Math.ceil(b),r.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),r.style.transformOrigin="top left",!T&&(R||_)){let w=k.width,d=k.height,p=v/w,C=b/d,x=r.style.transform||"",A=`scale(${p}, ${C})`;r.style.transform=`${A} ${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+o+"svg{overflow:visible;}"+s,q.appendChild(I),q.appendChild(r);let l=new XMLSerializer().serializeToString(q);f=`<svg xmlns="${W}" width="${v}" height="${b}" viewBox="0 0 ${v} ${b}">`+l+"</svg>",c=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f)}`,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,placeholders:t.placeholders!==!1,embedFonts:t.embedFonts??!1,iconFonts:Array.isArray(t.iconFonts)?t.iconFonts:t.iconFonts?[t.iconFonts]:[],localFonts:Array.isArray(t.localFonts)?t.localFonts:[],excludeFonts:t.excludeFonts??void 0,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{scale:n,dpr:r}=e,s=j(),i=new Image;i.crossOrigin="anonymous",i.loading="eager",i.decoding="sync",i.src=t;let o=null;s&&(o=document.createElement("div"),o.setAttribute("aria-hidden","true"),o.style.cssText="position:absolute;left:-99999px;top:0;width:0;height:0;overflow:hidden;opacity:0;pointer-events:none;contain:size layout style;",document.body.appendChild(o),o.appendChild(i)),await i.decode(),s&&await new Promise(y=>setTimeout(y,100));let a=i.naturalWidth*n,c=i.naturalHeight*n,f=document.createElement("canvas");f.width=Math.ceil(a*r),f.height=Math.ceil(c*r),f.style.width=`${a}px`,f.style.height=`${c}px`;let g=f.getContext("2d");if(r!==1&&g.scale(r,r),g.drawImage(i,0,0,a,c),o&&o.parentNode)try{o.parentNode.removeChild(o)}catch{}return f}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 r=await z(t,e),s=e.backgroundColor?H(r,e.backgroundColor):r;return new Promise(i=>s.toBlob(o=>i(o),`image/${n}`,e.quality))}async function Jt(t,e){let n=await z(t,e),r=e.backgroundColor?H(n,e.backgroundColor):n,s=new Image;return s.src=r.toDataURL(`image/${e.format}`,e.quality),await s.decode(),s.style.width=`${r.width/e.dpr}px`,s.style.height=`${r.height/e.dpr}px`,s}async function Zt(t,e){if(e.format==="svg"){let i=await bt(t,{...e,type:"svg"}),o=URL.createObjectURL(i),a=document.createElement("a");a.href=o,a.download=e.filename,a.click(),URL.revokeObjectURL(o);return}let n=await z(t,e),r=e.backgroundColor?H(n,e.backgroundColor):n,s=document.createElement("a");s.href=r.toDataURL(`image/${e.format}`,e.quality),s.download=e.filename,s.click()}var Qt=Symbol("snapdom.internal");async function N(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),N.capture(t,n,Qt)}N.capture=async(t,e,n)=>{if(n!==Qt)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");let r=await Kt(t,e),s=o=>({...e,...o||{}}),i=o=>a=>Jt(r,s({...a||{},format:o}));return{url:r,toRaw:()=>r,toImg:o=>Yt(r,s(o)),toCanvas:o=>z(r,s(o)),toBlob:o=>bt(r,s(o)),toPng:i("png"),toJpg:i("jpeg"),toWebp:i("webp"),download:o=>Zt(r,s(o))}};N.toRaw=(t,e)=>N(t,e).then(n=>n.toRaw());N.toImg=(t,e)=>N(t,e).then(n=>n.toImg());N.toCanvas=(t,e)=>N(t,e).then(n=>n.toCanvas());N.toBlob=(t,e)=>N(t,e).then(n=>n.toBlob());N.toPng=(t,e)=>N(t,{...e,format:"png"}).then(n=>n.toPng());N.toJpg=(t,e)=>N(t,{...e,format:"jpeg"}).then(n=>n.toJpg());N.toWebp=(t,e)=>N(t,{...e,format:"webp"}).then(n=>n.toWebp());N.download=(t,e)=>N(t,e).then(n=>n.download());async function je(t=document,e={}){let{embedFonts:n=!0,cacheOpt:r="full",useProxy:s=""}=e;it(r);try{await document.fonts.ready}catch{}$t(),u.session=u.session||{},u.session.styleCache||(u.session.styleCache=new WeakMap);try{await St(t,void 0,u.session.styleCache,{useProxy:s})}catch{}let i=[],o=[];try{t?.querySelectorAll&&(i=Array.from(t.querySelectorAll("img[src]")),o=Array.from(t.querySelectorAll("*")))}catch{}let a=[];for(let c of i){let f=c?.src;if(f&&!u.image.has(f)){let g=Promise.resolve().then(()=>B(f,{as:"dataURL",useProxy:s})).then(y=>{u.image.set(f,y)}).catch(()=>{});a.push(g)}}for(let c of o){let f="";try{f=K(c).backgroundImage}catch{}if(f&&f!=="none"){let g=X(f);for(let y of g)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),f=gt(t);if(typeof j=="function"?j():j){let g=new Set(Array.from(c).map(y=>String(y).split("__")[0]).filter(Boolean));await yt(g,2)}await ht({required:c,usedCodepoints:f,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??s})}catch{}await Promise.allSettled(a)}export{je as preCache,N as snapdom};
|
package/dist/snapdom.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
3
|
* snapdom
|
|
4
|
-
* v.1.9.10-dev.
|
|
4
|
+
* v.1.9.10-dev.1
|
|
5
5
|
* Author Juan Martin Muda
|
|
6
6
|
* License MIT
|
|
7
7
|
**/
|
|
@@ -297,7 +297,6 @@ var NO_DEFAULTS_TAGS = /* @__PURE__ */ new Set([
|
|
|
297
297
|
"script",
|
|
298
298
|
"template",
|
|
299
299
|
// SVG whole namespace (safe for LeaderLine/presentation attrs)
|
|
300
|
-
"svg",
|
|
301
300
|
"g",
|
|
302
301
|
"defs",
|
|
303
302
|
"use",
|
|
@@ -832,9 +831,18 @@ function deepClone(node, sessionCache, options) {
|
|
|
832
831
|
}
|
|
833
832
|
}
|
|
834
833
|
if (node.tagName === "IFRAME") {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
834
|
+
if (options.placeholders) {
|
|
835
|
+
const fallback = document.createElement("div");
|
|
836
|
+
fallback.style.cssText = `width:${node.offsetWidth}px;height:${node.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;`;
|
|
837
|
+
inlineAllStyles(node, fallback, sessionCache, options);
|
|
838
|
+
return fallback;
|
|
839
|
+
} else {
|
|
840
|
+
const rect = node.getBoundingClientRect();
|
|
841
|
+
const spacer = document.createElement("div");
|
|
842
|
+
spacer.style.cssText = `display:inline-block;width:${rect.width}px;height:${rect.height}px;visibility:hidden;`;
|
|
843
|
+
inlineAllStyles(node, spacer, sessionCache, options);
|
|
844
|
+
return spacer;
|
|
845
|
+
}
|
|
838
846
|
}
|
|
839
847
|
if (node.getAttribute("data-capture") === "placeholder") {
|
|
840
848
|
const clone2 = node.cloneNode(false);
|
|
@@ -873,7 +881,6 @@ function deepClone(node, sessionCache, options) {
|
|
|
873
881
|
const rect = node.getBoundingClientRect();
|
|
874
882
|
clone.style.width = `${rect.width}px`;
|
|
875
883
|
clone.style.height = `${rect.height}px`;
|
|
876
|
-
return clone;
|
|
877
884
|
}
|
|
878
885
|
if (node instanceof HTMLInputElement) {
|
|
879
886
|
clone.value = node.value;
|
|
@@ -2059,20 +2066,26 @@ async function inlineImages(clone, options = {}) {
|
|
|
2059
2066
|
}
|
|
2060
2067
|
const w = img.width || img.naturalWidth || 100;
|
|
2061
2068
|
const h = img.height || img.naturalHeight || 100;
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2069
|
+
if (options.placeholders !== false) {
|
|
2070
|
+
const fallback = document.createElement("div");
|
|
2071
|
+
fallback.style.cssText = [
|
|
2072
|
+
`width:${w}px`,
|
|
2073
|
+
`height:${h}px`,
|
|
2074
|
+
"background:#ccc",
|
|
2075
|
+
"display:inline-block",
|
|
2076
|
+
"text-align:center",
|
|
2077
|
+
`line-height:${h}px`,
|
|
2078
|
+
"color:#666",
|
|
2079
|
+
"font-size:12px",
|
|
2080
|
+
"overflow:hidden"
|
|
2081
|
+
].join(";");
|
|
2082
|
+
fallback.textContent = "img";
|
|
2083
|
+
img.replaceWith(fallback);
|
|
2084
|
+
} else {
|
|
2085
|
+
const spacer = document.createElement("div");
|
|
2086
|
+
spacer.style.cssText = `display:inline-block;width:${w}px;height:${h}px;visibility:hidden;`;
|
|
2087
|
+
img.replaceWith(spacer);
|
|
2088
|
+
}
|
|
2076
2089
|
};
|
|
2077
2090
|
for (let i = 0; i < imgs.length; i += 4) {
|
|
2078
2091
|
const group = imgs.slice(i, i + 4).map(processImg);
|
|
@@ -2262,6 +2275,8 @@ function createContext(options = {}) {
|
|
|
2262
2275
|
// DOM filters
|
|
2263
2276
|
exclude: options.exclude ?? [],
|
|
2264
2277
|
filter: options.filter ?? null,
|
|
2278
|
+
placeholders: options.placeholders !== false,
|
|
2279
|
+
// default true
|
|
2265
2280
|
// Fuentes
|
|
2266
2281
|
embedFonts: options.embedFonts ?? false,
|
|
2267
2282
|
iconFonts: Array.isArray(options.iconFonts) ? options.iconFonts : options.iconFonts ? [options.iconFonts] : [],
|
|
@@ -2300,31 +2315,41 @@ async function toImg(url, options) {
|
|
|
2300
2315
|
|
|
2301
2316
|
// src/exporters/toCanvas.js
|
|
2302
2317
|
async function toCanvas(url, options) {
|
|
2318
|
+
const { scale: scale2, dpr } = options;
|
|
2319
|
+
const safari = isSafari();
|
|
2303
2320
|
const img = new Image();
|
|
2304
2321
|
img.crossOrigin = "anonymous";
|
|
2305
2322
|
img.loading = "eager";
|
|
2306
2323
|
img.decoding = "sync";
|
|
2307
2324
|
img.src = url;
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2325
|
+
let tempSlot = null;
|
|
2326
|
+
if (safari) {
|
|
2327
|
+
tempSlot = document.createElement("div");
|
|
2328
|
+
tempSlot.setAttribute("aria-hidden", "true");
|
|
2329
|
+
tempSlot.style.cssText = "position:absolute;left:-99999px;top:0;width:0;height:0;overflow:hidden;opacity:0;pointer-events:none;contain:size layout style;";
|
|
2330
|
+
document.body.appendChild(tempSlot);
|
|
2331
|
+
tempSlot.appendChild(img);
|
|
2313
2332
|
}
|
|
2314
2333
|
await img.decode();
|
|
2315
|
-
if (
|
|
2316
|
-
|
|
2317
|
-
|
|
2334
|
+
if (safari) {
|
|
2335
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
2336
|
+
}
|
|
2337
|
+
const width = img.naturalWidth * scale2;
|
|
2338
|
+
const height = img.naturalHeight * scale2;
|
|
2318
2339
|
const canvas = document.createElement("canvas");
|
|
2319
|
-
const dpr = options.dpr;
|
|
2320
2340
|
canvas.width = Math.ceil(width * dpr);
|
|
2321
2341
|
canvas.height = Math.ceil(height * dpr);
|
|
2322
2342
|
canvas.style.width = `${width}px`;
|
|
2323
2343
|
canvas.style.height = `${height}px`;
|
|
2324
2344
|
const ctx = canvas.getContext("2d");
|
|
2325
|
-
ctx.scale(dpr, dpr);
|
|
2345
|
+
if (dpr !== 1) ctx.scale(dpr, dpr);
|
|
2326
2346
|
ctx.drawImage(img, 0, 0, width, height);
|
|
2327
|
-
if (
|
|
2347
|
+
if (tempSlot && tempSlot.parentNode) {
|
|
2348
|
+
try {
|
|
2349
|
+
tempSlot.parentNode.removeChild(tempSlot);
|
|
2350
|
+
} catch {
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2328
2353
|
return canvas;
|
|
2329
2354
|
}
|
|
2330
2355
|
|
package/package.json
CHANGED