(() => { var De = Object.defineProperty; var K = Object.getOwnPropertySymbols; var ue = Object.prototype.hasOwnProperty, me = Object.prototype.propertyIsEnumerable; var pe = (e, t, a) => t in e ? De(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a, U = (e, t) => { for (var a in t || (t = {})) ue.call(t, a) && pe(e, a, t[a]); if (K) for (var a of K(t)) me.call(t, a) && pe(e, a, t[a]); return e }; var he = (e, t) => { var a = {}; for (var c in e) ue.call(e, c) && t.indexOf(c) < 0 && (a[c] = e[c]); if (e != null && K) for (var c of K(e)) t.indexOf(c) < 0 && me.call(e, c) && (a[c] = e[c]); return a }; var h = (e, t, a) => new Promise((c, s) => { var n = o => { try { l(a.next(o)) } catch (r) { s(r) } }, i = o => { try { l(a.throw(o)) } catch (r) { s(r) } }, l = o => o.done ? c(o.value) : Promise.resolve(o.value).then(n, i); l((a = a.apply(e, t)).next()) }); var f = { image: new Map, background: new Map, resource: new Map, defaultStyle: new Map, baseStyle: new Map, computedStyle: new WeakMap, font: new Set, snapshot: new WeakMap, snapshotKey: new Map, preStyleMap: new Map, preStyle: new WeakMap, preNodeMap: new Map, reset: je }; function je() { f.computedStyle = new WeakMap, f.snapshot = new WeakMap, f.snapshotKey.clear(), f.preStyleMap.clear(), f.preStyle = new WeakMap, f.preNodeMap.clear() } var We = ["div", "span", "p", "a", "img", "ul", "li", "button", "input", "select", "textarea", "label", "section", "article", "header", "footer", "nav", "main", "aside", "h1", "h2", "h3", "h4", "h5", "h6", "svg", "path", "circle", "rect", "line", "g", "table", "thead", "tbody", "tr", "td", "th"]; function ge() { for (let e of We) ye(e) } function ye(e) { if (f.defaultStyle.has(e)) return f.defaultStyle.get(e); if (new Set(["script", "style", "meta", "link", "noscript", "template"]).has(e)) { let i = {}; return f.defaultStyle.set(e, i), i } let a = document.getElementById("snapdom-sandbox"); a || (a = document.createElement("div"), a.id = "snapdom-sandbox", a.style.position = "absolute", a.style.left = "-9999px", a.style.top = "-9999px", a.style.width = "0", a.style.height = "0", a.style.overflow = "hidden", document.body.appendChild(a)); let c = document.createElement(e); c.style.all = "initial", a.appendChild(c); let s = getComputedStyle(c), n = {}; for (let i of s) n[i] = s.getPropertyValue(i); return a.removeChild(c), f.defaultStyle.set(e, n), n } function O(e, t, a = !1) { let c = [], s = ye(t); for (let [n, i] of Object.entries(e)) if (!a) i && c.push(`${n}:${i}`); else { let l = s[n]; i && i !== l && c.push(`${n}:${i}`) } return c.sort().join(";") } function we(e) { let t = new Set; return e.nodeType !== Node.ELEMENT_NODE && e.nodeType !== Node.DOCUMENT_FRAGMENT_NODE ? [] : (e.tagName && t.add(e.tagName.toLowerCase()), typeof e.querySelectorAll == "function" && e.querySelectorAll("*").forEach(a => t.add(a.tagName.toLowerCase())), Array.from(t)) } function xe(e) { let t = new Map; for (let c of e) { let s = f.defaultStyle.get(c); if (!s) continue; let n = Object.entries(s).map(([i, l]) => `${i}:${l};`).sort().join(""); t.has(n) || t.set(n, []), t.get(n).push(c) } let a = ""; for (let [c, s] of t.entries()) a += `${s.join(",")} { ${c} } `; return a } function Se() { let e = new Set(f.preStyleMap.values()), t = new Map, a = 1; for (let c of e) t.set(c, `c${a++}`); return t } function B(a) { return h(this, arguments, function* (e, t = {}) { let c = _(e), s = /^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(e); if (c) { let n = Y(c); if (f.background.has(n)) return t.skipInline ? void 0 : `url(${f.background.get(n)})`; { let i = yield P(n, { useProxy: t.useProxy }); return f.background.set(n, i), t.skipInline ? void 0 : `url("${i}")` } } return e }) } function D(e, { fast: t = !1 } = {}) { if (t) return e(); "requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 50 }) : setTimeout(e, 1) } function N(e, t = null) { if (!(e instanceof Element)) return window.getComputedStyle(e, t); let a = f.computedStyle.get(e); if (a || (a = new Map, f.computedStyle.set(e, a)), !a.has(t)) { let c = window.getComputedStyle(e, t); a.set(t, c) } return a.get(t) } function be(e) { let t = e.replace(/^['"]|['"]$/g, ""); if (t.startsWith("\\")) try { return String.fromCharCode(parseInt(t.replace("\\", ""), 16)) } catch (a) { return t } return t } function _(e) { let t = e.match(/url\((['"]?)(.*?)(\1)\)/); if (!t) return null; let a = t[2].trim(); return a.startsWith("#") ? null : a } function P(e, { timeout: t = 3e3, useProxy: a = "" } = {}) { function c(o) { try { return new URL(o, window.location.href).origin === window.location.origin ? "use-credentials" : "anonymous" } catch (r) { return "anonymous" } } function s(o) { return h(this, null, function* () { let r = d => fetch(d, { mode: "cors", credentials: c(d) === "use-credentials" ? "include" : "omit" }).then(p => p.blob()).then(p => new Promise((m, u) => { let y = new FileReader; y.onloadend = () => { let w = y.result; if (typeof w != "string" || !w.startsWith("data:image/")) { u(new Error("Invalid image data URL")); return } m(w) }, y.onerror = () => u(new Error("FileReader error")), y.readAsDataURL(p) })); try { return yield r(o) } catch (d) { if (a && typeof a == "string") { let p = a.replace(/\/$/, "") + Y(o); try { return yield r(p) } catch (m) { throw new Error("[SnapDOM - fetchImage] CORS restrictions prevented image capture (even via proxy)") } } else throw new Error("[SnapDOM - fetchImage] Fetch fallback failed and no proxy provided") } }) } let n = c(e); return f.image.has(e) ? Promise.resolve(f.image.get(e)) : e.startsWith("data:image/") ? (f.image.set(e, e), Promise.resolve(e)) : /\.svg(\?.*)?$/i.test(e) ? h(null, null, function* () { try { let r = yield (yield fetch(e, { mode: "cors", credentials: n === "use-credentials" ? "include" : "omit" })).text(), d = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`; return f.image.set(e, d), d } catch (o) { return s(e) } }) : new Promise((o, r) => { let d = setTimeout(() => { r(new Error("[SnapDOM - fetchImage] Image load timed out")) }, t), p = new Image; p.crossOrigin = n, p.onload = () => h(null, null, function* () { clearTimeout(d); try { yield p.decode(); let m = document.createElement("canvas"); m.width = p.width, m.height = p.height, m.getContext("2d").drawImage(p, 0, 0, m.width, m.height); let y = m.toDataURL("image/png"); f.image.set(e, y), o(y) } catch (m) { try { let u = yield s(e); f.image.set(e, u), o(u) } catch (u) { r(u) } } }), p.onerror = () => h(null, null, function* () { clearTimeout(d), console.error(`[SnapDOM - fetchImage] Image failed to load: ${e}`); try { let m = yield s(e); f.image.set(e, m), o(m) } catch (m) { r(m) } }), p.src = e }) } function oe(e) { let t = {}; for (let a of e) t[a] = e.getPropertyValue(a); return t } function Ce() { return /^((?!chrome|android).)*safari/i.test(navigator.userAgent) } function Ee(e) { if (!e || e === "none") return ""; let t = e.replace(/translate[XY]?\([^)]*\)/g, ""); return t = t.replace(/matrix\(([^)]+)\)/g, (a, c) => { let s = c.split(",").map(n => n.trim()); return s.length !== 6 ? `matrix(${c})` : (s[4] = "0", s[5] = "0", `matrix(${s.join(", ")})`) }), t = t.replace(/matrix3d\(([^)]+)\)/g, (a, c) => { let s = c.split(",").map(n => n.trim()); return s.length !== 16 ? `matrix3d(${c})` : (s[12] = "0", s[13] = "0", `matrix3d(${s.join(", ")})`) }), t.trim().replace(/\s{2,}/g, " ") } function Y(e) { if (/%[0-9A-Fa-f]{2}/.test(e)) return e; try { return encodeURI(e) } catch (t) { return e } } function j(e) { let t = [], a = 0, c = 0; for (let s = 0; s < e.length; s++) { let n = e[s]; n === "(" && a++, n === ")" && a--, n === "," && a === 0 && (t.push(e.slice(c, s).trim()), c = s + 1) } return t.push(e.slice(c).trim()), t } function Ve(e) { let t = {}; for (let a = 0; a < e.length; a++) { let c = e[a], s = e.getPropertyValue(c); (c === "background-image" || c === "content") && s.includes("url(") && !s.includes("data:") && (s = "none"), t[c] = s } return t } function X(e, t, a) { var o; if (e.tagName === "STYLE") return; f.preStyle.has(e) || f.preStyle.set(e, N(e)); let c = f.preStyle.get(e); if (!f.snapshot.has(e)) { let r = Ve(c); f.snapshot.set(e, r) } let s = f.snapshot.get(e), n = Object.entries(s).sort(([r], [d]) => r.localeCompare(d)).map(([r, d]) => `${r}:${d}`).join(";"); if (f.snapshotKey.has(n)) { f.preStyleMap.set(t, f.snapshotKey.get(n)); return } let i = ((o = e.tagName) == null ? void 0 : o.toLowerCase()) || "div", l = O(s, i, a); f.snapshotKey.set(n, l), f.preStyleMap.set(t, l) } function q(e, t, a = {}, c) { var l, o; if (!e) throw new Error("Invalid node"); let s = new Set, n = null; if (e.nodeType === Node.TEXT_NODE || e.nodeType !== Node.ELEMENT_NODE) return e.cloneNode(!0); if (e.getAttribute("data-capture") === "exclude") { let r = document.createElement("div"), d = e.getBoundingClientRect(); return r.style.cssText = `display:inline-block;width:${d.width}px;height:${d.height}px;visibility:hidden;`, r } if (a.exclude && Array.isArray(a.exclude)) for (let r of a.exclude) try { if ((l = e.matches) != null && l.call(e, r)) { let d = document.createElement("div"), p = e.getBoundingClientRect(); return d.style.cssText = `display:inline-block;width:${p.width}px;height:${p.height}px;visibility:hidden;`, d } } catch (d) { console.warn(`Invalid selector in exclude option: ${r}`, d) } if (typeof a.filter == "function") try { if (!a.filter(e, c || e)) { let r = document.createElement("div"), d = e.getBoundingClientRect(); return r.style.cssText = `display:inline-block;width:${d.width}px;height:${d.height}px;visibility:hidden;`, r } } catch (r) { console.warn("Error in filter function:", r) } if (e.tagName === "IFRAME") { let r = document.createElement("div"); return r.style.cssText = `width:${e.offsetWidth}px;height:${e.offsetHeight}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`, r } if (e.getAttribute("data-capture") === "placeholder") { let r = e.cloneNode(!1); f.preNodeMap.set(r, e), X(e, r, t); let d = document.createElement("div"); return d.textContent = e.getAttribute("data-placeholder-text") || "", d.style.cssText = "color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;", r.appendChild(d), r } if (e.tagName === "CANVAS") { let r = e.toDataURL(), d = document.createElement("img"); return d.src = r, d.width = e.width, d.height = e.height, f.preNodeMap.set(d, e), X(e, d, t), d } let i; try { i = e.cloneNode(!1), f.preNodeMap.set(i, e) } catch (r) { throw console.error("[Snapdom] Failed to clone node:", e, r), r } if (e instanceof HTMLTextAreaElement) { i.textContent = e.value, i.value = e.value; let r = e.getBoundingClientRect(); return i.style.width = `${r.width}px`, i.style.height = `${r.height}px`, i } if (e instanceof HTMLInputElement && (i.value = e.value, i.setAttribute("value", e.value), e.checked !== void 0 && (i.checked = e.checked, e.checked && i.setAttribute("checked", ""), e.indeterminate && (i.indeterminate = e.indeterminate))), e instanceof HTMLSelectElement && (n = e.value), X(e, i, t), e.shadowRoot) if (Array.from(e.shadowRoot.querySelectorAll("slot")).length > 0) { for (let d of e.shadowRoot.childNodes) if (d.nodeType === Node.ELEMENT_NODE && d.tagName === "STYLE") { let p = d.textContent || ""; p.trim() && t && (f.preStyle || (f.preStyle = new WeakMap), f.preStyle.set(d, p)) } } else { let d = document.createDocumentFragment(); for (let p of e.shadowRoot.childNodes) { if (p.nodeType === Node.ELEMENT_NODE && p.tagName === "STYLE") { let u = p.textContent || ""; u.trim() && t && (f.preStyle || (f.preStyle = new WeakMap), f.preStyle.set(p, u)); continue } let m = q(p, t, a, c || e); m && d.appendChild(m) } i.appendChild(d) } if (e.tagName === "SLOT") { let r = ((o = e.assignedNodes) == null ? void 0 : o.call(e, { flatten: !0 })) || [], d = r.length > 0 ? r : Array.from(e.childNodes), p = document.createDocumentFragment(); for (let m of d) { let u = q(m, t, a, c || e); u && p.appendChild(u) } return p } for (let r of e.childNodes) { if (s.has(r)) continue; let d = q(r, t, a, c || e); d && i.appendChild(d) } if (n !== null && i instanceof HTMLSelectElement) { i.value = n; for (let r of i.options) r.value === n ? r.setAttribute("selected", "") : r.removeAttribute("selected") } return i } var Oe = [/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], ae = []; function ve(e) { let t = Array.isArray(e) ? e : [e]; for (let a of t) a instanceof RegExp ? ae.push(a) : typeof a == "string" ? ae.push(new RegExp(a, "i")) : console.warn("[snapdom] Ignored invalid iconFont value:", a) } function $(e) { let t = typeof e == "string" ? e : "", a = [...Oe, ...ae]; for (let c of a) if (c instanceof RegExp && c.test(t)) return !0; return !!(/icon/i.test(t) || /glyph/i.test(t) || /symbols/i.test(t) || /feather/i.test(t) || /fontawesome/i.test(t)) } function $e(e, t, a, c = 32, s = "#000") { return h(this, null, function* () { t = t.replace(/^['"]+|['"]+$/g, ""); let n = window.devicePixelRatio || 1, l = document.createElement("canvas").getContext("2d"); l.font = a ? `${a} ${c}px "${t}"` : `${c}px "${t}"`; let o = l.measureText(e), r = o.actualBoundingBoxAscent || c * .8, d = o.actualBoundingBoxDescent || c * .2, p = r + d, m = o.width, u = document.createElement("canvas"); u.width = Math.ceil(m * n), u.height = Math.ceil(p * n); let y = u.getContext("2d"); return y.scale(n, n), y.font = l.font, y.textAlign = "left", y.textBaseline = "alphabetic", y.fillStyle = s, y.fillText(e, 0, r), u.toDataURL() }) } function ke(e) { return Array.from(document.styleSheets).some(t => t.href === e) } function _e(e) { return new Promise(t => { if (ke(e)) return t(null); let a = document.createElement("link"); a.rel = "stylesheet", a.href = e, a.setAttribute("data-snapdom", "injected-import"), a.onload = () => t(a), a.onerror = () => t(null), document.head.appendChild(a) }) } function G() { return h(this, arguments, function* ({ preCached: e = !1 } = {}) { if (f.resource.has("fonts-embed-css")) { if (e) { let n = document.createElement("style"); n.setAttribute("data-snapdom", "embedFonts"), n.textContent = f.resource.get("fonts-embed-css"), document.head.appendChild(n) } return f.resource.get("fonts-embed-css") } let t = /@import\s+url\(["']?([^"')]+)["']?\)/g, a = []; for (let n of document.querySelectorAll("style")) { let i = n.textContent || "", l = Array.from(i.matchAll(t)); for (let o of l) { let r = o[1]; $(r) || ke(r) || a.push(r) } } yield Promise.all(a.map(_e)); let c = Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(n => n.href), s = ""; for (let n of c) try { let l = yield (yield fetch(n.href)).text(); if ($(n.href) || $(l)) continue; let o = /url\((["']?)([^"')]+)\1\)/g, r = yield Promise.all(Array.from(l.matchAll(o)).map(p => h(null, null, function* () { let m = _(p[0]); if (!m) return null; let u = m; if (!u.startsWith("http") && !u.startsWith("data:") && (u = new URL(u, n.href).href), $(u)) return null; if (f.resource.has(u)) return f.font.add(u), { original: p[0], inlined: `url(${f.resource.get(u)})` }; if (f.font.has(u)) return null; try { let w = yield (yield fetch(u)).blob(), x = yield new Promise(g => { let b = new FileReader; b.onload = () => g(b.result), b.readAsDataURL(w) }); return f.resource.set(u, x), f.font.add(u), { original: p[0], inlined: `url(${x})` } } catch (y) { return console.warn("[snapdom] Failed to fetch font resource:", u), null } }))), d = l; for (let p of r) p && (d = d.replace(p.original, p.inlined)); s += d + ` `} catch (i) { console.warn("[snapdom] Failed to fetch CSS:", n.href) } for (let n of document.styleSheets) try { if (!n.href || c.every(i => i.href !== n.href)) { for (let i of n.cssRules) if (i.type === CSSRule.FONT_FACE_RULE) { let l = i.style.getPropertyValue("src"), o = i.style.getPropertyValue("font-family"); if (!l || $(o)) continue; let r = /url\((["']?)([^"')]+)\1\)/g, d = /local\((["']?)[^)]+?\1\)/g, p = !!l.match(r), m = !!l.match(d); if (!p && m) { s += `@font-face{font-family:${o};src:${l};font-style:${i.style.getPropertyValue("font-style") || "normal"};font-weight:${i.style.getPropertyValue("font-weight") || "normal"};}`; continue } let u = l, y = Array.from(l.matchAll(r)); for (let w of y) { let x = w[2].trim(); if (!x) continue; let g = x; if (!g.startsWith("http") && !g.startsWith("data:") && (g = new URL(g, n.href || location.href).href), !$(g)) { if (f.resource.has(g)) { f.font.add(g), u = u.replace(w[0], `url(${f.resource.get(g)})`); continue } if (!f.font.has(g)) try { let I = yield (yield fetch(g)).blob(), k = yield new Promise(T => { let C = new FileReader; C.onload = () => T(C.result), C.readAsDataURL(I) }); f.resource.set(g, k), f.font.add(g), u = u.replace(w[0], `url(${k})`) } catch (b) { console.warn("[snapdom] Failed to fetch font URL:", g) } } } s += `@font-face{font-family:${o};src:${u};font-style:${i.style.getPropertyValue("font-style") || "normal"};font-weight:${i.style.getPropertyValue("font-weight") || "normal"};}` } } } catch (i) { console.warn("[snapdom] Cannot access stylesheet", n.href, i) } for (let n of document.fonts) if (n.family && n.status === "loaded" && n._snapdomSrc) { if ($(n.family)) continue; let i = n._snapdomSrc; if (!i.startsWith("data:")) { if (f.resource.has(n._snapdomSrc)) i = f.resource.get(n._snapdomSrc), f.font.add(n._snapdomSrc); else if (!f.font.has(n._snapdomSrc)) try { let o = yield (yield fetch(n._snapdomSrc)).blob(); i = yield new Promise(r => { let d = new FileReader; d.onload = () => r(d.result), d.readAsDataURL(o) }), f.resource.set(n._snapdomSrc, i), f.font.add(n._snapdomSrc) } catch (l) { console.warn("[snapdom] Failed to fetch dynamic font src:", n._snapdomSrc); continue } } s += `@font-face{font-family:'${n.family}';src:url(${i});font-style:${n.style || "normal"};font-weight:${n.weight || "normal"};}` } if (s && (f.resource.set("fonts-embed-css", s), e)) { let n = document.createElement("style"); n.setAttribute("data-snapdom", "embedFonts"), n.textContent = s, document.head.appendChild(n) } return s }) } function re(e, t, a, c = !1, s) { return h(this, null, function* () { if (!(e instanceof Element) || !(t instanceof Element)) return; for (let l of ["::before", "::after", "::first-letter"]) try { let o = N(e, l); if (!o || typeof o[Symbol.iterator] != "function") continue; if (l === "::first-letter") { let E = getComputedStyle(e); if (!(o.color !== E.color || o.fontSize !== E.fontSize || o.fontWeight !== E.fontWeight)) continue; let M = Array.from(t.childNodes).find(ne => ne.nodeType === Node.TEXT_NODE && ne.textContent && ne.textContent.trim().length > 0); if (!M) continue; let fe = M.textContent, te = fe.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u), F = te == null ? void 0 : te[0], Fe = fe.slice((F == null ? void 0 : F.length) || 0); if (!F || /[\uD800-\uDFFF]/.test(F)) continue; let H = document.createElement("span"); H.textContent = F, H.dataset.snapdomPseudo = "::first-letter"; let Ue = oe(o), Be = O(Ue, "span", a); f.preStyleMap.set(H, Be); let de = document.createTextNode(Fe); t.replaceChild(de, M), t.insertBefore(H, de); continue } let r = o.getPropertyValue("content"), d = o.getPropertyValue("background-image"), p = o.getPropertyValue("background-color"), m = o.getPropertyValue("font-family"), u = parseInt(o.getPropertyValue("font-size")) || 32, y = parseInt(o.getPropertyValue("font-weight")) || !1, w = o.getPropertyValue("color") || "#000", x = o.getPropertyValue("display"), g = parseFloat(o.getPropertyValue("width")), b = parseFloat(o.getPropertyValue("height")), I = o.getPropertyValue("border-style"), k = o.getPropertyValue("transform"), T = $(m), C; /counter\s*\(|counters\s*\(/.test(r) ? C = "- " : C = be(r); let W = r !== "none" && C !== "", z = d && d !== "none", V = p && p !== "transparent" && p !== "rgba(0, 0, 0, 0)", J = x !== "inline" && (g > 0 || b > 0), Q = I && I !== "none", A = k && k !== "none"; if (!(W || z || V || J || Q || A)) continue; let v = document.createElement("span"); v.dataset.snapdomPseudo = l; let Z = oe(o), ee = O(Z, "span", a); if (f.preStyleMap.set(v, ee), T && C.length === 1) { let E = document.createElement("img"); E.src = yield $e(C, m, y, u, w), E.style = `width:${u}px;height:auto;object-fit:contain;`, v.appendChild(E) } else if (C.startsWith("url(")) { let E = _(C); if (E && E.trim() !== "") try { let R = document.createElement("img"), M = yield P(Y(E, { useProxy: s })); R.src = M, R.style = `width:${u}px;height:auto;object-fit:contain;`, v.appendChild(R) } catch (R) { console.error(`[snapdom] Error in pseudo ${l} for`, e, R) } } else !T && W && (v.textContent = C); if (z) try { let E = j(d), R = yield Promise.all(E.map(M => B(M))); v.style.backgroundImage = R.join(", ") } catch (E) { console.warn(`[snapdom] Failed to inline background-image for ${l}`, E) } if (V && (v.style.backgroundColor = p), !(v.childNodes.length > 0 || v.textContent && v.textContent.trim() !== "" || z || V || J || Q || A)) continue; l === "::before" ? t.insertBefore(v, t.firstChild) : t.appendChild(v) } catch (o) { console.warn(`[snapdom] Failed to capture ${l} for`, e, o) } let n = Array.from(e.children), i = Array.from(t.children).filter(l => !l.dataset.snapdomPseudo); for (let l = 0; l < Math.min(n.length, i.length); l++)yield re(n[l], i[l], a, c, s) }) } function Ie(e) { if (!e) return; let t = document.querySelectorAll("svg > defs"); t.length && e.querySelectorAll("svg").forEach(a => { let c = a.querySelectorAll("use"); if (!c.length) return; let s = new Set; if (c.forEach(i => { let l = i.getAttribute("xlink:href") || i.getAttribute("href"); l && l.startsWith("#") && s.add(l.slice(1)) }), !s.size) return; let n = document.createElementNS("http://www.w3.org/2000/svg", "defs"); for (let i of s) for (let l of t) { let o = l.querySelector(`#${CSS.escape(i)}`); if (o) { n.appendChild(o.cloneNode(!0)); break } } n.childNodes.length && a.insertBefore(n, a.firstChild) }) } function Re(s) { return h(this, arguments, function* (e, t = !1, a = !1, c = {}) { var l; let n, i = ""; try { n = q(e, t, c, e) } catch (o) { throw console.warn("deepClone failed:", o), o } try { yield re(e, n, t, a, c.useProxy) } catch (o) { console.warn("inlinePseudoElements failed:", o) } try { Ie(n) } catch (o) { console.warn("inlineExternalDef failed:", o) } if (t) { let o = Se(); i = Array.from(o.entries()).map(([r, d]) => `.${d}{${r}}`).join(""); for (let [r, d] of f.preStyleMap.entries()) { if (r.tagName === "STYLE") continue; let p = o.get(d); p && r.classList.add(p); let m = (l = r.style) == null ? void 0 : l.backgroundImage; r.removeAttribute("style"), m && m !== "none" && (r.style.backgroundImage = m) } } else for (let [o, r] of f.preStyleMap.entries()) o.tagName !== "STYLE" && o.setAttribute("style", r.replace(/;/g, "; ")); for (let [o, r] of f.preNodeMap.entries()) { let d = r.scrollLeft, p = r.scrollTop; if ((d || p) && o instanceof HTMLElement) { o.style.overflow = "hidden", o.style.scrollbarWidth = "none", o.style.msOverflowStyle = "none"; let u = document.createElement("div"); for (u.style.transform = `translate(${-d}px, ${-p}px)`, u.style.willChange = "transform", u.style.display = "inline-block", u.style.width = "100%"; o.firstChild;)u.appendChild(o.firstChild); o.appendChild(u) } } if (e === f.preNodeMap.get(n)) { let o = f.preStyle.get(e) || window.getComputedStyle(e); f.preStyle.set(e, o); let r = Ee(o.transform); n.style.margin = "0", n.style.position = "static", n.style.top = "auto", n.style.left = "auto", n.style.right = "auto", n.style.bottom = "auto", n.style.zIndex = "auto", n.style.float = "none", n.style.clear = "none", n.style.transform = r || "" } for (let [o, r] of f.preNodeMap.entries()) r.tagName === "PRE" && (o.style.marginTop = "0", o.style.marginBlockStart = "0"); return { clone: n, classCSS: i } }) } function Ne(a) { return h(this, arguments, function* (e, t = {}) { let c = Array.from(e.querySelectorAll("img")), s = n => h(null, null, function* () { let i = n.src; try { let l = yield P(i, { useProxy: t.useProxy }); n.src = l, n.width || (n.width = n.naturalWidth || 100), n.height || (n.height = n.naturalHeight || 100) } catch (l) { let o = document.createElement("div"); o.style = `width: ${n.width || 100}px; height: ${n.height || 100}px; background: #ccc; display: inline-block; text-align: center; line-height: ${n.height || 100}px; color: #666; font-size: 12px;`, o.innerText = "img", n.replaceWith(o) } }); for (let n = 0; n < c.length; n += 4) { let i = c.slice(n, n + 4).map(s); yield Promise.allSettled(i) } }) } function Te(c, s) { return h(this, arguments, function* (e, t, a = {}) { let n = [[e, t]], i = ["background-image", "mask", "mask-image", "-webkit-mask-image", "mask-source", "mask-box-image-source", "mask-border-source", "-webkit-mask-box-image-source"]; for (; n.length;) { let [l, o] = n.shift(), r = f.preStyle.get(l) || N(l); f.preStyle.has(l) || f.preStyle.set(l, r); for (let u of i) { let y = r.getPropertyValue(u); if (!y || y === "none") continue; let w = j(y), x = yield Promise.all(w.map(g => B(g, a))); x.some(g => g && g !== "none" && !/^url\(undefined/.test(g)) && o.style.setProperty(u, x.join(", ")) } let d = r.getPropertyValue("background-color"); d && d !== "transparent" && d !== "rgba(0, 0, 0, 0)" && (o.style.backgroundColor = d); let p = Array.from(l.children), m = Array.from(o.children); for (let u = 0; u < Math.min(p.length, m.length); u++)n.push([p[u], m[u]]) } }) } function Ae(a) { return h(this, arguments, function* (e, t = {}) { if (!e) throw new Error("Element cannot be null or undefined"); f.reset(); let { compress: c = !0, embedFonts: s = !1, fast: n = !0, scale: i = 1, useProxy: l = "" } = t, o, r, d = "", p = "", m, u; if ({ clone: o, classCSS: r } = yield Re(e, c, s, t), yield new Promise(w => { D(() => h(null, null, function* () { yield Ne(o, t), w() }), { fast: n }) }), yield new Promise(w => { D(() => h(null, null, function* () { yield Te(e, o, t), w() }), { fast: n }) }), s && (yield new Promise(w => { D(() => h(null, null, function* () { d = yield G(), w() }), { fast: n }) })), c) { let w = we(o).sort(), x = w.join(","); f.baseStyle.has(x) ? p = f.baseStyle.get(x) : yield new Promise(g => { D(() => { p = xe(w), f.baseStyle.set(x, p), g() }, { fast: n }) }) } yield new Promise(w => { D(() => { let x = e.getBoundingClientRect(), g = x.width, b = x.height, I = Number.isFinite(t.width), k = Number.isFinite(t.height), T = typeof i == "number" && i !== 1; if (!T) { let A = x.width / x.height; I && k ? (g = t.width, b = t.height) : I ? (g = t.width, b = g / A) : k && (b = t.height, g = b * A) } if (g = Math.ceil(g), b = Math.ceil(b), o.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"), o.style.transformOrigin = "top left", !T && (I || k)) { let A = x.width, ce = x.height, v = g / A, Z = b / ce, ee = o.style.transform || "", le = `scale(${v}, ${Z})`; o.style.transform = `${le} ${ee}`.trim() } let C = "http://www.w3.org/2000/svg", L = document.createElementNS(C, "foreignObject"); L.setAttribute("width", "100%"), L.setAttribute("height", "100%"); let W = document.createElement("style"); W.textContent = p + d + "svg{overflow:visible;}" + r, L.appendChild(W), L.appendChild(o); let V = new XMLSerializer().serializeToString(L); u = `` + V + "", m = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(u)}`, w() }, { fast: n }) }); let y = document.getElementById("snapdom-sandbox"); return y && y.style.position === "absolute" && y.remove(), m }) } function qe(c, s) { return h(this, arguments, function* (e, { dpr: t = 1, scale: a = 1 }) { let n = new Image; return n.src = e, yield n.decode(), n.width = n.width * a, n.height = n.height * a, n }) } function Me(c) { return h(this, arguments, function* (e, { dpr: t = 1, scale: a = 1 } = {}) { let s = new Image; s.src = e, s.crossOrigin = "anonymous", s.loading = "eager", s.decoding = "sync"; let n = Ce(), i = !1; if (n && (document.body.appendChild(s), i = !0), yield s.decode(), n && (yield new Promise(p => setTimeout(p, 100))), s.width === 0 || s.height === 0) throw i && s.remove(), new Error("Image failed to load or has no dimensions"); let l = s.width * a, o = s.height * a, r = document.createElement("canvas"); r.width = Math.ceil(l * t), r.height = Math.ceil(o * t), r.style.width = `${l}px`, r.style.height = `${o}px`; let d = r.getContext("2d"); return d.scale(t, t), d.drawImage(s, 0, 0, l, o), i && s.remove(), r }) } function Pe(n) { return h(this, arguments, function* (e, { type: t = "svg", scale: a = 1, backgroundColor: c = "#fff", quality: s } = {}) { let i = { jpg: "image/jpeg", jpeg: "image/jpeg", png: "image/png", webp: "image/webp" }[t] || "image/png"; if (t === "svg") { let o = decodeURIComponent(e.split(",")[1]); return new Blob([o], { type: "image/svg+xml" }) } let l = yield ie(e, { dpr: 1, scale: a }, c); return new Promise(o => { l.toBlob(r => o(r), `${i}`, s) }) }) } function ie(s, n, i) { return h(this, arguments, function* (e, { dpr: t = 1, scale: a = 1 }, c) { let l = yield Me(e, { dpr: t, scale: a }); if (!c) return l; let o = document.createElement("canvas"); o.width = l.width, o.height = l.height; let r = o.getContext("2d"); return r.fillStyle = c, r.fillRect(0, 0, o.width, o.height), r.drawImage(l, 0, 0), o }) } function se(i, l) { return h(this, arguments, function* (e, { dpr: t = 1, scale: a = 1, backgroundColor: c, quality: s }, n = "png") { let o = ["jpg", "jpeg", "webp"].includes(n) ? "#fff" : void 0, r = c != null ? c : o, d = yield ie(e, { dpr: t, scale: a }, r), p = new Image; return p.src = d.toDataURL(`image/${n}`, s), yield p.decode(), p.style.width = `${d.width / t}px`, p.style.height = `${d.height / t}px`, p }) } function ze(i) { return h(this, arguments, function* (e, { dpr: t = 1, scale: a = 1, backgroundColor: c, format: s = "png", filename: n = "snapDOM" } = {}) { if (s === "svg") { let u = yield Pe(e), y = URL.createObjectURL(u), w = document.createElement("a"); w.href = y, w.download = `${n}.svg`, w.click(), URL.revokeObjectURL(y); return } let l = ["jpg", "jpeg", "webp"].includes(s) ? "#fff" : void 0, o = c != null ? c : l, r = yield ie(e, { dpr: t, scale: a }, o), d = { jpg: "image/jpeg", jpeg: "image/jpeg", png: "image/png", webp: "image/webp" }[s] || "image/png", p = r.toDataURL(d), m = document.createElement("a"); m.href = p, m.download = `${n}.${s}`, m.click() }) } function S(a) { return h(this, arguments, function* (e, t = {}) { if (t = U({ scale: 1 }, t), !e) throw new Error("Element cannot be null or undefined"); return t.iconFonts && ve(t.iconFonts), yield S.capture(e, t) }) } S.capture = (a, ...c) => h(null, [a, ...c], function* (e, t = {}) { let s = yield Ae(e, t), n = window.devicePixelRatio || 1, i = t.scale || 1; return { url: s, options: t, toRaw: () => s, toImg: () => qe(s, { dpr: n, scale: i }), toCanvas: () => Me(s, { dpr: n, scale: i }), toBlob: l => Pe(s, U({ dpr: n, scale: i }, l)), toPng: l => se(s, U({ dpr: n, scale: i }, l), "png"), toJpg: l => se(s, U({ dpr: n, scale: i }, l), "jpeg"), toWebp: l => se(s, U({ dpr: n, scale: i }, l), "webp"), download: ({ format: l = "png", filename: o = "capture", backgroundColor: r } = {}) => ze(s, { dpr: n, scale: i, backgroundColor: r, format: l, filename: o }) } }); S.toRaw = (e, t) => h(null, null, function* () { return (yield S.capture(e, t)).toRaw() }); S.toImg = (e, t) => h(null, null, function* () { return (yield S.capture(e, t)).toImg() }); S.toCanvas = (e, t) => h(null, null, function* () { return (yield S.capture(e, t)).toCanvas() }); S.toBlob = (e, t) => h(null, null, function* () { return (yield S.capture(e, t)).toBlob(t) }); S.toPng = (e, t) => h(null, null, function* () { return (yield S.capture(e, t)).toPng(t) }); S.toJpg = (e, t) => h(null, null, function* () { return (yield S.capture(e, t)).toJpg(t) }); S.toWebp = (e, t) => h(null, null, function* () { return (yield S.capture(e, t)).toWebp(t) }); S.download = (a, ...c) => h(null, [a, ...c], function* (e, t = {}) { let r = t, { format: s = "png", filename: n = "capture", backgroundColor: i } = r, l = he(r, ["format", "filename", "backgroundColor"]); return yield (yield S.capture(e, l)).download({ format: s, filename: n, backgroundColor: i }) }); function Le() { return h(this, arguments, function* (e = document, t = {}) { let { embedFonts: a = !0, reset: c = !1 } = t; if (c) { f.reset(); return } yield document.fonts.ready, ge(); let s = [], n = []; e != null && e.querySelectorAll && (s = Array.from(e.querySelectorAll("img[src]")), n = Array.from(e.querySelectorAll("*"))); let i = []; for (let l of s) { let o = l.src; f.image.has(o) || i.push(P(o, { useProxy: t.useProxy }).then(r => f.image.set(o, r)).catch(() => { })) } for (let l of n) { let o = N(l).backgroundImage; if (o && o !== "none") { let r = j(o); for (let d of r) d.startsWith("url(") && i.push(B(d, t).catch(() => { })) } } a && (yield G({ preCached: !0 })), yield Promise.all(i) }) } typeof window != "undefined" && (window.snapdom = S, window.preCache = Le); })();