@onerjs/snapdom 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +969 -0
- package/dist/plugins.mjs +7 -0
- package/dist/preCache.mjs +10 -0
- package/dist/snapdom.js +14 -0
- package/dist/snapdom.mjs +14 -0
- package/package.json +86 -0
- package/types/snapdom.d.ts +375 -0
package/dist/snapdom.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SnapDOM
|
|
3
|
+
* v2.7.0
|
|
4
|
+
* Author: Juan Martin Muda
|
|
5
|
+
* License: MIT
|
|
6
|
+
*/
|
|
7
|
+
var Rr=Object.defineProperty;var j=(t,e)=>()=>(t&&(e=t(t=0)),e);var $t=(t,e)=>{for(var n in e)Rr(t,n,{get:e[n],enumerable:!0})};function De(t){if(t===!0)return"soft";if(t===!1)return"disabled";if(typeof t=="string"){let e=t.toLowerCase().trim();if(e==="auto")return"auto";if(e==="full")return"full";if(e==="soft"||e==="disabled")return e}return"soft"}function jt(t="soft"){switch(x.session.__counterEpoch=(x.session.__counterEpoch||0)+1,t){case"auto":{x.session.styleMap=new Map,x.session.nodeMap=new Map;return}case"soft":{x.session.styleMap=new Map,x.session.nodeMap=new Map,x.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{x.session.styleMap=new Map,x.session.nodeMap=new Map,x.session.styleCache=new WeakMap,x.computedStyle=new WeakMap,x.baseStyle=new O(50),x.defaultStyle=new O(30),x.image=new O(100),x.background=new O(100),x.resource=new O(150),x.font=new Set;return}default:{x.session.styleMap=new Map,x.session.nodeMap=new Map,x.session.styleCache=new WeakMap;return}}}var O,x,X=j(()=>{"use strict";O=class extends Map{constructor(e=100,...n){super(...n),this._maxSize=e}set(e,n){if(this.size>=this._maxSize&&!this.has(e)){let r=this.keys().next().value;r!==void 0&&this.delete(r)}return super.set(e,n)}},x={image:new O(100),background:new O(100),resource:new O(150),defaultStyle:new O(30),baseStyle:new O(50),computedStyle:new WeakMap,measureHints:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}}});function mt(t){let e=t.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function ue(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(o=>o.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(o=>o.trim());return s.length!==16?`matrix3d(${r})`:(s[12]="0",s[13]="0",`matrix3d(${s.join(", ")})`)}),e.trim().replace(/\s{2,}/g," ")}function ut(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function fe(t,e){if(!t||/^(data|blob|about|#)/i.test(t.trim()))return t;try{let n=e||typeof document<"u"&&(document.baseURI||document.location?.href)||"http://localhost/";return new URL(t,n).href}catch{return t}}var Rt=j(()=>{"use strict"});function Lr(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let r=new Map,s=0;function o(i,u,a){if(s>=n)return;let l=Date.now();(r.get(u)||0)>l||(r.set(u,l+e),s++,i==="warn"&&console&&console.warn?console.warn(`${t} ${a}`):console&&console.error&&console.error(`${t} ${a}`))}return{warnOnce(i,u){o("warn",i,u)},errorOnce(i,u){o("error",i,u)},reset(){r.clear(),s=0}}}function Pr(t){return/^data:|^blob:|^about:blank$/i.test(t)}function Nr(t,e){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=e.includes("{url}")?e.split("{url}")[0]:e,s=new URL(r||".",n),o=new URL(t,n);if(o.origin===s.origin)return!0;let i=o.searchParams;if(i&&(i.has("url")||i.has("target")))return!0}catch{}return!1}function Tr(t,e){if(!e||Pr(t)||Nr(t,e))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 Ir(t,e){if(!e)return t;if(e.includes("{url}"))return e.replace("{urlRaw}",ut(t)).replace("{url}",encodeURIComponent(t));if(/[?&]url=?$/.test(e))return`${e}${encodeURIComponent(t)}`;if(e.endsWith("?"))return`${e}url=${encodeURIComponent(t)}`;if(e.endsWith("/"))return`${e}${ut(t)}`;let n=e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function ze(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 _r(t,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,t].join("|")}async function U(t,e={}){let n=e.as??"blob",r=e.timeout??3e3,s=e.useProxy||"",o=e.errorTTL??8e3,i=e.headers||{},u=!!e.silent;if(/^data:/i.test(t))try{if(n==="text")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1};if(n==="dataURL")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1,mime:String(t).slice(5).split(";")[0]||""};let[,h="",g=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],C=/;base64/i.test(h)?atob(g):decodeURIComponent(g),b=new Uint8Array([...C].map(k=>k.charCodeAt(0))),S=new Blob([b],{type:(h||"").split(";")[0]||""});return{ok:!0,data:S,status:200,url:t,fromCache:!1,mime:S.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let h=await fetch(t);if(!h.ok)return{ok:!1,data:null,status:h.status,url:t,fromCache:!1,reason:"http_error"};let g=await h.blob(),w=g.type||h.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ze(g),status:h.status,url:t,fromCache:!1,mime:w}:n==="text"?{ok:!0,data:await g.text(),status:h.status,url:t,fromCache:!1,mime:w}:{ok:!0,data:g,status:h.status,url:t,fromCache:!1,mime:w}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(t))return n==="dataURL"?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:t,fromCache:!1,mime:"image/png"}:{ok:!0,data:n==="text"?"":new Blob([]),status:200,url:t,fromCache:!1};let a=_r(t,{as:n,timeout:r,useProxy:s,errorTTL:o}),l=Vt.get(a);if(l&&l.until>Date.now())return{...l.result,fromCache:!0};l&&Vt.delete(a);let c=de.get(a);if(c)return c;let f=Tr(t,s)?Ir(t,s):t,d=e.credentials;if(!d)try{let h=typeof location<"u"&&location.href?location.href:"http://localhost/",g=new URL(t,h);d=typeof location<"u"&&g.origin===location.origin?"include":"omit"}catch{d="omit"}let m=new AbortController,y=setTimeout(()=>m.abort("timeout"),r),p=(async()=>{try{let h=await fetch(f,{signal:m.signal,credentials:d,headers:i});if(!h.ok){let C={ok:!1,data:null,status:h.status,url:f,fromCache:!1,reason:"http_error"};if(o>0&&Vt.set(a,{until:Date.now()+o,result:C}),!u){let b=`${h.status} ${h.statusText||""}`.trim();He.warnOnce(`http:${h.status}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${b} while fetching ${n} ${t}`)}return e.onError&&e.onError(C),C}if(n==="text")return{ok:!0,data:await h.text(),status:h.status,url:f,fromCache:!1};let g=await h.blob(),w=g.type||h.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ze(g),status:h.status,url:f,fromCache:!1,mime:w}:{ok:!0,data:g,status:h.status,url:f,fromCache:!1,mime:w}}catch(h){let g=h&&typeof h=="object"&&"name"in h&&h.name==="AbortError"?String(h.message||"").includes("timeout")?"timeout":"abort":"network",w={ok:!1,data:null,status:0,url:f,fromCache:!1,reason:g};if(!/^blob:/i.test(t)&&o>0&&Vt.set(a,{until:Date.now()+o,result:w}),!u){let C=`${g}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,b=g==="timeout"?`Timeout after ${r}ms. Consider increasing timeout or using a proxy for ${t}`:g==="abort"?`Request aborted while fetching ${n} ${t}`:`Network/CORS issue while fetching ${n} ${t}. A proxy may be required`;He.errorOnce(C,b)}return e.onError&&e.onError(w),w}finally{clearTimeout(y),de.delete(a)}})();return de.set(a,p),p}var He,de,Vt,pt=j(()=>{"use strict";Rt();He=Lr("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),de=new Map,Vt=new Map});async function ht(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(t)||t.trim()==="none")return t;let r=mt(t);if(!r)return t;let s=fe(r),o=ut(s);if(x.background.has(o)){let i=x.background.get(o);return i?`url("${i}")`:"none"}try{let i=await U(o,{as:"dataURL",useProxy:e.useProxy});return i.ok?(x.background.set(o,i.data),`url("${i.data}")`):(x.background.set(o,null),"none")}catch{return x.background.set(o,null),"none"}}var qe=j(()=>{"use strict";X();Rt();pt()});function me(){for(let t of Wr){let e=String(t).toLowerCase();Xt.has(e)||Gt.has(e)||pe(e)}}function pe(t){if(t=String(t).toLowerCase(),Gt.has(t)){let o={};return x.defaultStyle.set(t,o),o}if(x.defaultStyle.has(t))return x.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 o of r){if(Lt(o))continue;let i=r.getPropertyValue(o);s[o]=i}return e.removeChild(n),x.defaultStyle.set(t,s),s}function Lt(t){let e=String(t).toLowerCase();return!!(Br.has(e)||Or.test(e)||Ur.test(e))}function wt(t,e){if(e=String(e||"").toLowerCase(),Gt.has(e))return"";let n=[],r=pe(e),u=(t.display||"").toLowerCase()==="inline"||new Set(["span","small","em","strong","b","i","u","s","code","cite","mark","sub","sup"]).has(e);for(let[a,l]of Object.entries(t)){if(Lt(a)||u&&(a==="width"||a==="min-width"||a==="max-width"))continue;let c=r[a];l&&l!==c&&n.push(`${a}:${l}`)}return n.sort(),n.join(";")}function he(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 ge(t){let e=new Map;for(let r of t){let s=x.defaultStyle.get(r);if(!s)continue;let o=Object.entries(s).map(([i,u])=>`${i}:${u};`).sort().join("");o&&(e.has(o)||e.set(o,[]),e.get(o).push(r))}let n="";for(let[r,s]of e.entries())n+=`${s.join(",")} { ${r} }
|
|
8
|
+
`;return n}function ye(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 Dr(t){try{let e=t?.ownerDocument;if(!e)return typeof window<"u"?window:null;let n=e.defaultView;if(n&&typeof n.getComputedStyle=="function")return n;if(typeof window<"u"&&window.frames)for(let r=0;r<window.frames.length;r++)try{if(window.frames[r]?.document===e)return window.frames[r]}catch{}}catch{}return typeof window<"u"?window:null}function H(t,e=null){let n=()=>{let o={length:0,getPropertyValue:()=>"",item:()=>""};return o[Symbol.iterator]=function*(){},o};if(!(t instanceof Element)){let o=typeof window<"u"?window:null;if(o&&typeof o.getComputedStyle=="function")try{return o.getComputedStyle(t,e)||n()}catch{return n()}return n()}let r=x.computedStyle.get(t);r||(r=new Map,x.computedStyle.set(t,r));let s=r.get(e);if(!s){let o=Dr(t),i=null;try{i=o&&typeof o.getComputedStyle=="function"?o.getComputedStyle(t,e):null}catch{}if(!i&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{t.ownerDocument===document&&(i=window.getComputedStyle(t,e))}catch{}s=i||n(),r.set(e,s)}return s}function Yt(t){let e={};for(let n of t)e[n]=t.getPropertyValue(n);return e}function St(t){let e=[],n=0,r=0;for(let s=0;s<t.length;s++){let o=t[s];o==="("&&n++,o===")"&&n--,o===","&&n===0&&(e.push(t.slice(r,s).trim()),r=s+1)}return e.push(t.slice(r).trim()),e}var Xt,Gt,Wr,Ur,Or,Br,be=j(()=>{"use strict";X();Xt=new Set(["meta","script","noscript","title","link","template"]),Gt=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"]),Wr=["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"];Ur=/(?:^|-)(animation|transition)(?:-|$)/i,Or=/^(--.+|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,Br=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","zoom"])});function ot(t,{fast:e=!1}={}){if(e)return t();"requestIdleCallback"in window?requestIdleCallback(t,{timeout:50}):setTimeout(t,1)}function we(){if(typeof navigator>"u")return!1;if(navigator.userAgentData)return navigator.userAgentData.platform==="iOS";let t=navigator.userAgent||"",e=/iPhone|iPad|iPod/.test(t),n=navigator.maxTouchPoints>2&&/Macintosh/.test(t);return e||n}function z(){if(typeof navigator>"u")return!1;let t=navigator.userAgent||"",e=t.toLowerCase(),n=e.includes("safari")&&!e.includes("chrome")&&!e.includes("crios")&&!e.includes("fxios")&&!e.includes("android"),r=/applewebkit/i.test(t),s=/mobile/i.test(t),o=!/safari/i.test(t),i=r&&s&&o,u=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(t),a=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(e),l=/ipad|iphone|ipod/.test(e)&&r;return n||i||u||a||l}function je(){if(typeof navigator>"u")return!1;let t=(navigator.userAgent||"").toLowerCase();return t.includes("firefox")||t.includes("fxios")}var xt=j(()=>{"use strict"});function R(t,e,n){let r=t&&typeof t=="object"&&(t.options||t);r&&r.debug&&(n!==void 0?console.warn("[snapdom]",e,n):console.warn("[snapdom]",e))}var Se=j(()=>{"use strict"});var Y=j(()=>{"use strict";qe();be();xt();Rt();Se()});var mr={};$t(mr,{toCanvas:()=>yt});function li(t){return typeof t=="string"&&/^data:image\/svg\+xml/i.test(t)}function ui(t){let e=t.indexOf(",");return e>=0?decodeURIComponent(t.slice(e+1)):""}function fi(t){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}function di(t){let e=[],n="",r=0;for(let s=0;s<t.length;s++){let o=t[s];o==="("&&r++,o===")"&&(r=Math.max(0,r-1)),o===";"&&r===0?(e.push(n),n=""):n+=o}return n.trim()&&e.push(n),e.map(s=>s.trim()).filter(Boolean)}function mi(t){let e=[],n="",r=0;for(let o=0;o<t.length;o++){let i=t[o];i==="("&&r++,i===")"&&(r=Math.max(0,r-1)),i===","&&r===0?(e.push(n.trim()),n=""):n+=i}n.trim()&&e.push(n.trim());let s=[];for(let o of e){if(/\binset\b/i.test(o))continue;let i=o.match(/-?\d+(?:\.\d+)?px/gi)||[],[u="0px",a="0px",l="0px"]=i,c=o.replace(/-?\d+(?:\.\d+)?px/gi,"").replace(/\binset\b/ig,"").trim().replace(/\s{2,}/g," "),f=!!c&&c!==",";s.push(`drop-shadow(${u} ${a} ${l}${f?` ${c}`:""})`)}return s.join(" ")}function dr(t){let e=di(t),n=null,r=null,s=null,o=[];for(let u of e){let a=u.indexOf(":");if(a<0)continue;let l=u.slice(0,a).trim().toLowerCase(),c=u.slice(a+1).trim();l==="box-shadow"?s=c:l==="filter"?n=c:l==="-webkit-filter"?r=c:o.push([l,c])}if(s){let u=mi(s);u&&(n=n?`${n} ${u}`:u,r=r?`${r} ${u}`:u)}let i=[...o];return n&&i.push(["filter",n]),r&&i.push(["-webkit-filter",r]),i.map(([u,a])=>`${u}:${a}`).join(";")}function pi(t){return t.replace(/([^{}]+)\{([^}]*)\}/g,(e,n,r)=>`${n}{${dr(r)}}`)}function hi(t){return t=t.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi,(e,n)=>e.replace(n,pi(n))),t=t.replace(/style=(['"])([\s\S]*?)\1/gi,(e,n,r)=>`style=${n}${dr(r)}${n}`),t}function gi(t){if(!z()||!li(t))return t;try{let e=ui(t),n=hi(e);return fi(n)}catch{return t}}async function yt(t,e){let{width:n,height:r,scale:s=1,dpr:o=1,meta:i={},backgroundColor:u}=e;t=gi(t);let a=new Image;a.loading="eager",a.decoding="sync",a.crossOrigin="anonymous",a.src=t,await a.decode();let l=a.naturalWidth,c=a.naturalHeight,f=Number.isFinite(i.w0)?i.w0:l,d=Number.isFinite(i.h0)?i.h0:c,m,y,p=Number.isFinite(n),h=Number.isFinite(r);if(p&&h)m=Math.max(1,n),y=Math.max(1,r);else if(p){let C=n/Math.max(1,f);m=n,y=d*C}else if(h){let C=r/Math.max(1,d);y=r,m=f*C}else m=l,y=c;m=m*s,y=y*s;let g=document.createElement("canvas");g.width=m*o,g.height=y*o,g.style.width=`${m}px`,g.style.height=`${y}px`;let w=g.getContext("2d");return o!==1&&w.scale(o,o),u&&(w.save(),w.fillStyle=u,w.fillRect(0,0,m,y),w.restore()),w.drawImage(a,0,0,m,y),g}var Wt=j(()=>{"use strict";xt()});var se={};$t(se,{rasterize:()=>Ne});async function Ne(t,e){let n=await yt(t,e),r=new Image;return r.src=n.toDataURL(`image/${e.format}`,e.quality),await r.decode(),r.style.width=`${n.width/e.dpr}px`,r.style.height=`${n.height/e.dpr}px`,r}var Ut=j(()=>{"use strict";Wt()});var Te={};$t(Te,{toImg:()=>yi,toSvg:()=>yi});async function yi(t,e){let{scale:n=1,width:r,height:s,meta:o={}}=e,i=Number.isFinite(r),u=Number.isFinite(s),a=Number.isFinite(n)&&n!==1||i||u;if(z()&&a)return await Ne(t,{...e,format:"png",quality:1,meta:o});let l=new Image;if(l.decoding="sync",l.loading="eager",l.src=t,await l.decode(),i&&u)l.style.width=`${r}px`,l.style.height=`${s}px`;else if(i){let c=Number.isFinite(o.w0)?o.w0:l.naturalWidth,f=Number.isFinite(o.h0)?o.h0:l.naturalHeight,d=r/Math.max(1,c);l.style.width=`${r}px`,l.style.height=`${Math.round(f*d)}px`}else if(u){let c=Number.isFinite(o.w0)?o.w0:l.naturalWidth,f=Number.isFinite(o.h0)?o.h0:l.naturalHeight,d=s/Math.max(1,f);l.style.height=`${s}px`,l.style.width=`${Math.round(c*d)}px`}else{let c=Math.round(l.naturalWidth*n),f=Math.round(l.naturalHeight*n);if(l.style.width=`${c}px`,l.style.height=`${f}px`,typeof t=="string"&&t.startsWith("data:image/svg+xml"))try{let m=decodeURIComponent(t.split(",")[1]).replace(/width="[^"]*"/,`width="${c}"`).replace(/height="[^"]*"/,`height="${f}"`);t=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(m)}`,l.src=t}catch(d){R(e,"SVG width/height patch in toImg failed",d)}}return l}var Ie=j(()=>{"use strict";Y();Ut()});var pr={};$t(pr,{toBlob:()=>_e});async function _e(t,e){let n=e.type;if(n==="svg"){let s=decodeURIComponent(t.split(",")[1]);return new Blob([s],{type:"image/svg+xml"})}let r=await yt(t,e);return new Promise(s=>r.toBlob(o=>s(o),`image/${n}`,e.quality))}var We=j(()=>{"use strict";Wt()});var gr={};$t(gr,{download:()=>bi});async function hr(t,e){let n=new File([t],e,{type:t.type});if(!navigator.canShare?.({files:[n]}))return!1;try{await navigator.share({files:[n],title:e})}catch(r){if(r.name!=="AbortError")return!1}return!0}async function bi(t,e){let n=new Set(["png","jpeg","jpg","webp","svg"]),r=(e?.type||"").toLowerCase(),s=n.has(r)?r:"",o=(e?.format||s||"").toLowerCase(),i=o==="jpg"?"jpeg":o||"png",u=e?.filename||`snapdom.${i}`,a={...e||{},format:i,type:i};a.dpr=1;let l=we();if(i==="svg"){let d=await _e(t,{...a,type:"svg"});if(l&&await hr(d,u))return;let m=URL.createObjectURL(d),y=document.createElement("a");y.href=m,y.download=u,document.body.appendChild(y),y.click(),URL.revokeObjectURL(m),y.remove();return}let c=await yt(t,a);if(l){let d=`image/${i}`,m=await new Promise(y=>c.toBlob(y,d,e?.quality));if(m&&await hr(m,u))return}let f=document.createElement("a");f.href=c.toDataURL(`image/${i}`,e?.quality),f.download=u,document.body.appendChild(f),f.click(),f.remove()}var yr=j(()=>{"use strict";We();Wt();xt()});Y();Y();X();var Ve=new WeakMap,Nt=new Map,Hr=2e3,xe=0;function Pt(){xe++,Nt.size>Hr&&Nt.clear()}var Xe=!1;function zr(t=document.documentElement){if(!Xe){Xe=!0;try{new MutationObserver(()=>Pt()).observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>Pt()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let e=document.fonts;e&&(e.addEventListener?.("loadingdone",Pt),e.ready?.then(()=>Pt()).catch(()=>{}))}catch{}}}function qr(t,e={}){let n={},r=t.getPropertyValue("visibility"),s=e.excludeStyleProps;for(let f=0;f<t.length;f++){let d=t[f];if(Lt(d)||s&&(s instanceof RegExp&&s.test(d)||typeof s=="function"&&s(d)))continue;let m=t.getPropertyValue(d);(d==="background-image"||d==="content")&&m.includes("url(")&&!m.includes("data:")&&(m="none"),n[d]=m}let o=["text-decoration-line","text-decoration-color","text-decoration-style","text-decoration-thickness","text-underline-offset","text-decoration-skip-ink"];for(let f of o)if(!n[f])try{let d=t.getPropertyValue(f);d&&(n[f]=d)}catch{}let i=["-webkit-text-stroke","-webkit-text-stroke-width","-webkit-text-stroke-color","paint-order"];for(let f of i)if(!n[f])try{let d=t.getPropertyValue(f);d&&(n[f]=d)}catch{}if(e.embedFonts){let f=["font-feature-settings","font-variation-settings","font-kerning","font-variant","font-variant-ligatures","font-optical-sizing"];for(let d of f)if(!n[d])try{let m=t.getPropertyValue(d);m&&(n[d]=m)}catch{}}r==="hidden"&&(n.opacity="0");try{(n["content-visibility"]||t.getPropertyValue("content-visibility"))==="hidden"&&(n.visibility="hidden")}catch{}let u=parseFloat(t.getPropertyValue("border-top-width")||0)||0,a=parseFloat(t.getPropertyValue("border-right-width")||0)||0,l=parseFloat(t.getPropertyValue("border-bottom-width")||0)||0,c=parseFloat(t.getPropertyValue("border-left-width")||0)||0;if(u===0&&a===0&&l===0&&c===0){let f=(t.getPropertyValue("border-image-source")||"").trim(),d=f&&f!=="none",m=["border","border-top","border-right","border-bottom","border-left","border-width","border-style","border-color","border-top-width","border-top-style","border-top-color","border-right-width","border-right-style","border-right-color","border-bottom-width","border-bottom-style","border-bottom-color","border-left-width","border-left-style","border-left-color","border-block","border-block-width","border-block-style","border-block-color","border-inline","border-inline-width","border-inline-style","border-inline-color"];for(let y of m)delete n[y];d||(n.border="none")}return n}var Ge=new WeakMap;function jr(t){let e=Ge.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(";"),Ge.set(t,e),e)}function Vr(t,e=null,n={}){let r=Ve.get(t);if(r&&r.epoch===xe)return r.snapshot;let s=e||getComputedStyle(t),o=qr(s,n);return Zr(t,s,o),Ve.set(t,{epoch:xe,snapshot:o}),o}function Xr(t,e){return t&&t.session&&t.persist?t:t&&(t.styleMap||t.styleCache||t.nodeMap)?{session:t,persist:{snapshotKeyCache:Nt,defaultStyle:x.defaultStyle,baseStyle:x.baseStyle,image:x.image,resource:x.resource,background:x.background,font:x.font},options:e||{}}:{session:x.session,persist:{snapshotKeyCache:Nt,defaultStyle:x.defaultStyle,baseStyle:x.baseStyle,image:x.image,resource:x.resource,background:x.background,font:x.font},options:t||e||{}}}function Gr(t,e,n){if(!(!t.style||t.style.length===0))for(let r=0;r<t.style.length;r++){let s=t.style[r],o=n.getPropertyValue(s);o&&e.style.setProperty(s,o)}}async function it(t,e,n,r){if(t.tagName==="STYLE")return;let s=Xr(n,r),o=s.options&&s.options.cache||"auto";o!=="disabled"&&zr(document.documentElement),o==="disabled"&&!s.session.__bumpedForDisabled&&(Pt(),Nt.clear(),s.session.__bumpedForDisabled=!0);let{session:i,persist:u}=s;if(!i.styleCache.has(t)){let d=null;try{d=getComputedStyle(t)}catch{}i.styleCache.set(t,d||getComputedStyle(document.documentElement))}let a=i.styleCache.get(t);t.getAttribute?.("style")&&Gr(t,e,a);let l=Vr(t,a,s.options),c=jr(l),f=u.snapshotKeyCache.get(c);if(!f){let d=t.tagName?.toLowerCase()||"div";f=wt(l,d),u.snapshotKeyCache.set(c,f)}i.styleMap.set(e,f)}function Yr(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof HTMLIFrameElement||t instanceof SVGElement||t instanceof HTMLObjectElement||t instanceof HTMLEmbedElement}function Kr(t){return t.backgroundImage&&t.backgroundImage!=="none"||t.backgroundColor&&t.backgroundColor!=="rgba(0, 0, 0, 0)"&&t.backgroundColor!=="transparent"||(parseFloat(t.borderTopWidth)||0)>0||(parseFloat(t.borderBottomWidth)||0)>0||(parseFloat(t.paddingTop)||0)>0||(parseFloat(t.paddingBottom)||0)>0?!0:(t.overflowBlock||t.overflowY||"visible")!=="visible"}function Qr(t){let e=t.parentElement;if(!e)return!1;let n=getComputedStyle(e).display||"";return n.includes("flex")||n.includes("grid")}function Jr(t,e){if(t.textContent&&/\S/.test(t.textContent))return!0;let n=t.firstElementChild,r=t.lastElementChild;if(n&&n.tagName==="BR"||r&&r.tagName==="BR")return!0;let s=t.scrollHeight;if(s===0)return!1;let o=parseFloat(e.paddingTop)||0,i=parseFloat(e.paddingBottom)||0;return s>o+i}function Zr(t,e,n){if(t instanceof HTMLElement&&t.style&&t.style.height)return;let r=t.tagName&&t.tagName.toLowerCase();if(!r||!["div","section","article","main","aside","header","footer","nav"].includes(r))return;let o=parseFloat(e.height);if(Number.isFinite(o)&&t.scrollHeight>0&&Math.abs(o-t.scrollHeight)>2||e.aspectRatio&&e.aspectRatio!=="none"&&e.aspectRatio!=="auto")return;let u=e.display||"";if(u.includes("flex")||u.includes("grid")||Yr(t))return;let a=e.position;if(a==="absolute"||a==="fixed"||a==="sticky"||e.transform!=="none"||Kr(e)||Qr(t))return;let l=e.overflowX||e.overflow||"visible",c=e.overflowY||e.overflow||"visible";if(l!=="visible"||c!=="visible")return;let f=e.clip;f&&f!=="auto"&&f!=="rect(auto, auto, auto, auto)"||e.visibility==="hidden"||e.opacity==="0"||Jr(t,e)&&(delete n.height,delete n["block-size"])}be();var Ke=["fill","stroke","color","background-color","stop-color"],Ye=new Map;function to(t,e){let n=e+"::"+t.toLowerCase(),r=Ye.get(n);if(r)return r;let s=document,o=e==="http://www.w3.org/2000/svg"?s.createElementNS(e,t):s.createElement(t),i=s.createElement("div");i.style.cssText="position:absolute;left:-99999px;top:-99999px;contain:strict;display:block;",i.appendChild(o),s.documentElement.appendChild(i);let u=getComputedStyle(o),a={};for(let l of Ke)a[l]=u.getPropertyValue(l)||"";return i.remove(),Ye.set(n,a),a}function Qe(t,e){if(!(t instanceof Element)||!(e instanceof Element))return;let n=t.getAttribute?.("style"),r=!!(n&&n.includes("var("));if(!r&&t.attributes?.length){let o=t.attributes;for(let i=0;i<o.length;i++){let u=o[i];if(u&&typeof u.value=="string"&&u.value.includes("var(")){r=!0;break}}}let s=null;if(r)try{s=getComputedStyle(t)}catch{}if(r){let o=t.style;if(o&&o.length){let i=new Set;for(let u=0;u<o.length;u++){let a=o[u];if(i.has(a))continue;i.add(a);let l=o.getPropertyValue(a);if(!l||!l.includes("var("))continue;let c=s&&s.getPropertyValue(a);if(c)try{e.style.setProperty(a,c.trim(),o.getPropertyPriority(a))}catch{}}}}if(r&&t.attributes?.length){let o=t.attributes;for(let i=0;i<o.length;i++){let u=o[i];if(!u||typeof u.value!="string"||!u.value.includes("var("))continue;let a=u.name,l=s&&s.getPropertyValue(a);if(l)try{e.style.setProperty(a,l.trim())}catch{}}}if(!r){if(!s)try{s=getComputedStyle(t)}catch{s=null}if(!s)return;let o=t.namespaceURI||"html",i=to(t.tagName,o);for(let u of Ke){let a=s.getPropertyValue(u)||"",l=i[u]||"";if(a&&a!==l)try{e.style.setProperty(u,a.trim())}catch{}}}}Y();Y();X();pt();function Qt(t,e,n){return Promise.all(t.map(r=>new Promise(s=>{function o(){ot(i=>{(i&&typeof i.timeRemaining=="function"?i.timeRemaining()>0:!0)?e(r,s):o()},{fast:n})}o()})))}function eo(t){return t=t.trim(),!t||/:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(t)?t:`${t}:not([data-sd-slotted])`}function no(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?eo(r):r;return`:where(${e} ${s})`}).join(", ")}function Ze(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,o)=>{let i=no(o,e,!0);return`${r}${s}${i}{`}),t):""}function tn(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}function en(t){let e="";try{t.querySelectorAll("style").forEach(r=>{e+=(r.textContent||"")+`
|
|
9
|
+
`});let n=t.adoptedStyleSheets||[];for(let r of n)try{if(r&&r.cssRules)for(let s of r.cssRules)e+=s.cssText+`
|
|
10
|
+
`}catch{}}catch{}return e}function nn(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 rn(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 on(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 ro(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 sn(t,e,n){let r=[];for(let s of e){let o=ro(t,s);o&&r.push(`${s}: ${o};`)}return r.length?`${n}{${r.join("")}}
|
|
11
|
+
`:""}function an(t){t&&(t.nodeType===Node.ELEMENT_NODE&&t.setAttribute("data-sd-slotted",""),t.querySelectorAll&&t.querySelectorAll("*").forEach(e=>e.setAttribute("data-sd-slotted","")))}async function oo(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},r=n(),s=0;for(;s<e&&(!r||!r.body&&!r.documentElement);)await new Promise(o=>setTimeout(o,0)),r=n(),s++;return r&&(r.body||r.documentElement)?r:null}function io(t){let e=t.getBoundingClientRect(),n=0,r=0,s=0,o=0;try{let a=getComputedStyle(t);n=parseFloat(a.borderLeftWidth)||0,r=parseFloat(a.borderRightWidth)||0,s=parseFloat(a.borderTopWidth)||0,o=parseFloat(a.borderBottomWidth)||0}catch{}let i=Math.max(0,Math.round(e.width-(n+r))),u=Math.max(0,Math.round(e.height-(s+o)));return{contentWidth:i,contentHeight:u,rect:e}}function K(t){let e=0,n=0;if(t.offsetWidth>0&&(e=t.offsetWidth),t.offsetHeight>0&&(n=t.offsetHeight),e===0||n===0)try{let r=getComputedStyle(t);if(e===0){let s=parseFloat(r.width);!isNaN(s)&&s>0&&(e=s)}if(n===0){let s=parseFloat(r.height);!isNaN(s)&&s>0&&(n=s)}}catch{}if(e===0||n===0)try{if(e===0){let r=parseFloat(t.getAttribute("width"));!isNaN(r)&&r>0&&(e=r)}if(n===0){let r=parseFloat(t.getAttribute("height"));!isNaN(r)&&r>0&&(n=r)}}catch{}if((e===0||n===0)&&(t.naturalWidth||t.naturalHeight))try{e===0&&t.naturalWidth>0&&(e=t.naturalWidth),n===0&&t.naturalHeight>0&&(n=t.naturalHeight)}catch{}return{width:e,height:n}}function so(t,e,n){let r=t.createElement("style");return r.setAttribute("data-sd-iframe-pin",""),r.textContent=`html, body {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(t.head||t.documentElement).appendChild(r),()=>{try{r.remove()}catch{}}}async function cn(t,e,n){let r=await oo(t,3);if(!r)throw new Error("iframe document not accessible/ready");let{contentWidth:s,contentHeight:o,rect:i}=io(t),u=n?.snap;if(!u&&typeof window<"u"&&window.snapdom&&(u=window.snapdom),!u||typeof u.toPng!="function")throw new Error("[snapdom] iframe capture requires snapdom.toPng. Use snapdom(el) or pass options.snap. With ESM, assign window.snapdom = snapdom after import if using iframes.");let a={...n,scale:1},l=so(r,s,o),c;try{c=await u.toPng(r.documentElement,a)}finally{l()}c.style.display="block",c.style.width=`${s}px`,c.style.height=`${o}px`;let f=document.createElement("div");return e.nodeMap.set(f,t),it(t,f,e,n),f.style.overflow="hidden",f.style.display="block",f.style.width||(f.style.width=`${Math.round(i.width)}px`),f.style.height||(f.style.height=`${Math.round(i.height)}px`),f.appendChild(c),f}function ln(t){let{width:e,height:n}=K(t),r=t.getBoundingClientRect(),s;try{s=window.getComputedStyle(t)}catch{}let o=s?parseFloat(s.width):NaN,i=s?parseFloat(s.height):NaN,u=Math.round(e||r.width||0),a=Math.round(n||r.height||0),l=Number.isFinite(o)&&o>0?Math.round(o):Math.max(12,u||16),c=Number.isFinite(i)&&i>0?Math.round(i):Math.max(12,a||16),f=(t.type||"text").toLowerCase()==="checkbox",d=!!t.checked,m=!!t.indeterminate,p=Math.max(Math.min(l,c),12),h="middle";try{s&&s.verticalAlign&&(h=s.verticalAlign)}catch{}let g=document.createElement("div");g.setAttribute("data-snapdom-input-replacement",t.type||"checkbox"),g.style.cssText=`display:inline-block;width:${p}px;height:${p}px;vertical-align:${h};flex-shrink:0;line-height:0;`;let w=document.createElementNS("http://www.w3.org/2000/svg","svg");w.setAttribute("width",String(p)),w.setAttribute("height",String(p)),w.setAttribute("viewBox",`0 0 ${p} ${p}`),g.appendChild(w);function C(){let b="#0a6ed1";try{s&&(b=s.accentColor||s.color||b)}catch{}let S=2,k=S/2,A=p-S;if(w.innerHTML="",f){let v=document.createElementNS("http://www.w3.org/2000/svg","rect");if(v.setAttribute("x",String(k)),v.setAttribute("y",String(k)),v.setAttribute("width",String(A)),v.setAttribute("height",String(A)),v.setAttribute("rx","2"),v.setAttribute("ry","2"),v.setAttribute("fill",d?b:"none"),v.setAttribute("stroke",b),v.setAttribute("stroke-width",String(S)),w.appendChild(v),d){let E=document.createElementNS("http://www.w3.org/2000/svg","path");E.setAttribute("d",`M ${k+2} ${p/2} L ${p/2-1} ${p-k-2} L ${p-k-2} ${k+2}`),E.setAttribute("stroke","white"),E.setAttribute("stroke-width",String(Math.max(1.5,S))),E.setAttribute("fill","none"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round"),w.appendChild(E)}else if(m){let E=document.createElementNS("http://www.w3.org/2000/svg","rect"),P=Math.max(6,A-4);E.setAttribute("x",String((p-P)/2)),E.setAttribute("y",String((p-S)/2)),E.setAttribute("width",String(P)),E.setAttribute("height",String(S)),E.setAttribute("fill",b),E.setAttribute("rx","1"),w.appendChild(E)}}else{let v=document.createElementNS("http://www.w3.org/2000/svg","circle");if(v.setAttribute("cx",String(p/2)),v.setAttribute("cy",String(p/2)),v.setAttribute("r",String((p-S)/2)),v.setAttribute("fill",d?b:"none"),v.setAttribute("stroke",b),v.setAttribute("stroke-width",String(S)),w.appendChild(v),d){let E=document.createElementNS("http://www.w3.org/2000/svg","circle"),P=Math.max(2,(p-S*2)*.35);E.setAttribute("cx",String(p/2)),E.setAttribute("cy",String(p/2)),E.setAttribute("r",String(P)),E.setAttribute("fill","white"),w.appendChild(E)}}g.style.setProperty("width",`${p}px`,"important"),g.style.setProperty("height",`${p}px`,"important"),g.style.setProperty("min-width",`${p}px`,"important"),g.style.setProperty("min-height",`${p}px`,"important")}return C(),{el:g,applyVisual:C}}var Tt=new O(80);async function It(t){if(x.resource?.has(t))return x.resource.get(t);if(Tt.has(t))return Tt.get(t);let e=(async()=>{let n=await U(t,{as:"dataURL",silent:!0});if(!n.ok||typeof n.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);return x.resource?.set(t,n.data),n.data})();Tt.set(t,e);try{let n=await e;return Tt.set(t,n),n}catch(n){throw Tt.delete(t),n}}var ao=/\bblob:[^)"'\s]+/g;async function Je(t){if(!t||t.indexOf("blob:")===-1)return t;let e=Array.from(new Set(t.match(ao)||[]));if(e.length===0)return t;let n=t;for(let r of e)try{let s=await It(r);n=n.split(r).join(s)}catch{}return n}function Kt(t){return typeof t=="string"&&t.startsWith("blob:")}function co(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 lo(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}async function un(t,e=null){if(!t)return;let n=e,r=t.querySelectorAll?t.querySelectorAll("img"):[];for(let a of r)try{let c=a.getAttribute("src")||a.currentSrc||"";if(Kt(c)){let d=await It(c);a.setAttribute("src",d)}let f=a.getAttribute("srcset");if(f&&f.includes("blob:")){let d=co(f),m=!1;for(let y of d)if(Kt(y.url))try{y.url=await It(y.url),m=!0}catch(p){R(n,"blobUrlToDataUrl for srcset item failed",p)}m&&a.setAttribute("srcset",lo(d))}}catch(l){R(n,"resolveBlobUrls for img failed",l)}let s=t.querySelectorAll?t.querySelectorAll("image"):[];for(let a of s)try{let l="http://www.w3.org/1999/xlink",c=a.getAttribute("href")||a.getAttributeNS?.(l,"href");if(Kt(c)){let f=await It(c);a.setAttribute("href",f),a.removeAttributeNS?.(l,"href")}}catch(l){R(n,"resolveBlobUrls for SVG image href failed",l)}let o=t.querySelectorAll?t.querySelectorAll("[style*='blob:']"):[];for(let a of o)try{let l=a.getAttribute("style");if(l&&l.includes("blob:")){let c=await Je(l);a.setAttribute("style",c)}}catch(l){R(n,"replaceBlobUrls in inline style failed",l)}let i=t.querySelectorAll?t.querySelectorAll("style"):[];for(let a of i)try{let l=a.textContent||"";l.includes("blob:")&&(a.textContent=await Je(l))}catch(l){R(n,"replaceBlobUrls in style tag failed",l)}let u=["poster"];for(let a of u){let l=t.querySelectorAll?t.querySelectorAll(`[${a}^='blob:']`):[];for(let c of l)try{let f=c.getAttribute(a);Kt(f)&&c.setAttribute(a,await It(f))}catch(f){R(n,`resolveBlobUrls for ${a} failed`,f)}}}xt();async function _t(t,e,n){if(!t)throw new Error("Invalid node");let r=new Set,s=null,o=null;if(t.nodeType===Node.ELEMENT_NODE){let c=(t.localName||t.tagName||"").toLowerCase();if(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox")||Xt.has(c))return null;if(c==="foreignobject"){let f=t.parentElement,d=!1;for(;f&&f.tagName?.toLowerCase()!=="foreignobject";){if(f.tagName?.toLowerCase()==="svg"){d=!0;break}f=f.parentElement}if(!d)return R(e,"Nested <foreignObject> without SVG ancestor skipped (SVG spec limitation)"),null}}if(t.nodeType===Node.TEXT_NODE||t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if(t.getAttribute("data-capture")==="exclude"){if(n.excludeMode==="hide"){let c=document.createElement("div"),{width:f,height:d}=K(t),m=f||t.getBoundingClientRect().width||0,y=d||t.getBoundingClientRect().height||0;return c.style.cssText=`display:inline-block;width:${m}px;height:${y}px;visibility:hidden;`,c}else if(n.excludeMode==="remove")return null}if(n.exclude&&Array.isArray(n.exclude))for(let c of n.exclude)try{if(t.matches?.(c)){if(n.excludeMode==="hide"){let f=document.createElement("div"),{width:d,height:m}=K(t),y=d||t.getBoundingClientRect().width||0,p=m||t.getBoundingClientRect().height||0;return f.style.cssText=`display:inline-block;width:${y}px;height:${p}px;visibility:hidden;`,f}else if(n.excludeMode==="remove")return null}}catch(f){console.warn(`Invalid selector in exclude option: ${c}`,f)}if(typeof n.filter=="function")try{if(!n.filter(t)){if(n.filterMode==="hide"){let c=document.createElement("div"),{width:f,height:d}=K(t),m=f||t.getBoundingClientRect().width||0,y=d||t.getBoundingClientRect().height||0;return c.style.cssText=`display:inline-block;width:${m}px;height:${y}px;visibility:hidden;`,c}else if(n.filterMode==="remove")return null}}catch(c){console.warn("Error in filter function:",c)}if(t.tagName==="IFRAME"){let c=!1;try{c=!!(t.contentDocument||t.contentWindow?.document)}catch(f){R(e,"iframe same-origin probe failed",f)}if(c)try{return await cn(t,e,n)}catch(f){console.warn("[SnapDOM] iframe rasterization failed, fallback:",f)}if(c||console.warn("[snapdom] cross-origin <iframe> skipped (cannot access content). Use options.placeholders to show a placeholder instead.",t),n.placeholders){let{width:f,height:d}=K(t),m=document.createElement("div");return m.style.cssText=`width:${f}px;height:${d}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;`,it(t,m,e,n),m}else{let{width:f,height:d}=K(t),m=document.createElement("div");return m.style.cssText=`display:inline-block;width:${f}px;height:${d}px;visibility:hidden;`,it(t,m,e,n),m}}if(t.getAttribute("data-capture")==="placeholder"){let c=t.cloneNode(!1);e.nodeMap.set(c,t),it(t,c,e,n);let f=document.createElement("div");return f.textContent=t.getAttribute("data-placeholder-text")||"",f.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",c.appendChild(f),c}if(t.tagName==="CANVAS"){let c="";try{let y=t.getContext("2d",{willReadFrequently:!0});try{y&&y.getImageData(0,0,1,1)}catch{}if(await new Promise(p=>requestAnimationFrame(p)),c=t.toDataURL("image/png"),!c||c==="data:,"){try{y&&y.getImageData(0,0,1,1)}catch{}if(await new Promise(p=>requestAnimationFrame(p)),c=t.toDataURL("image/png"),!c||c==="data:,"){let p=document.createElement("canvas");p.width=t.width,p.height=t.height;let h=p.getContext("2d");h&&(h.drawImage(t,0,0),c=p.toDataURL("image/png"))}}}catch(y){R(e,"Canvas toDataURL failed, using empty/fallback",y)}let f=document.createElement("img");try{f.decoding="sync",f.loading="eager"}catch(y){R(e,"img decoding/loading hints failed",y)}c&&(f.src=c),f.width=t.width,f.height=t.height;let{width:d,height:m}=K(t);return d>0&&(f.style.width=`${d}px`),m>0&&(f.style.height=`${m}px`),e.nodeMap.set(f,t),it(t,f,e,n),f}if(t.tagName==="VIDEO"){let c="";try{let y=document.createElement("canvas");y.width=t.videoWidth||t.offsetWidth||320,y.height=t.videoHeight||t.offsetHeight||240;let p=y.getContext("2d");p&&(p.drawImage(t,0,0,y.width,y.height),c=y.toDataURL("image/png"),(!c||c==="data:,")&&(c=""))}catch(y){R(e,"Video frame capture failed, using poster fallback",y)}let f=document.createElement("img");try{f.decoding="sync",f.loading="eager"}catch{}c?f.src=c:t.poster&&(f.src=t.poster),f.width=t.videoWidth||t.offsetWidth||0,f.height=t.videoHeight||t.offsetHeight||0;let{width:d,height:m}=K(t);return d>0&&(f.style.width=`${d}px`),m>0&&(f.style.height=`${m}px`),f.style.objectFit="contain",e.nodeMap.set(f,t),it(t,f,e,n),f}let i;try{if(i=t.cloneNode(!1),i.attributes?.length)try{for(let c of i.attributes)/[\x00-\x08\x0B\x0C\x0E-\x1F\uFFFE\uFFFF]/.test(c.value)&&i.setAttribute(c.name,c.value.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\uFFFE\uFFFF]/g,""))}catch{}if(Qe(t,i),e.nodeMap.set(i,t),t.tagName==="IMG"){rn(t,i);try{let{width:c,height:f}=K(t),d=Math.round(c||0),m=Math.round(f||0);d&&(i.dataset.snapdomWidth=String(d)),m&&(i.dataset.snapdomHeight=String(m))}catch(c){R(e,"getUnscaledDimensions for IMG failed",c)}try{let c=t.getAttribute("style")||"",f=window.getComputedStyle(t),d=C=>{let b=c.match(new RegExp(`${C}\\s*:\\s*([^;]+)`,"i")),S=b?b[1].trim():f.getPropertyValue(C);return/%|auto/i.test(String(S||""))},m=parseInt(i.dataset.snapdomWidth||"0",10),y=parseInt(i.dataset.snapdomHeight||"0",10),p=d("width")||!m,h=d("height")||!y;p&&m&&(i.style.width=`${m}px`),h&&y&&(i.style.height=`${y}px`);let g=f.getPropertyValue("object-fit"),w=f.getPropertyValue("object-position");g&&g!=="fill"?(i.style.objectFit=g,w&&(i.style.objectPosition=w)):(m&&(i.style.minWidth=`${m}px`),y&&(i.style.minHeight=`${y}px`))}catch(c){R(e,"IMG dimension freeze failed",c)}}}catch(c){throw console.error("[Snapdom] Failed to clone node:",t,c),c}let u=null;if(t instanceof HTMLTextAreaElement){let{width:c,height:f}=K(t),d=c||t.getBoundingClientRect().width||0,m=f||t.getBoundingClientRect().height||0;d&&(i.style.width=`${d}px`),m&&(i.style.height=`${m}px`)}if(t instanceof HTMLInputElement){let c=(t.type||"text").toLowerCase();if((c==="checkbox"||c==="radio")&&je()){let{el:d,applyVisual:m}=ln(t);e.nodeMap.set(d,t),u=m,i=d}else 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))}if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&!t.value&&t.placeholder)try{let c=window.getComputedStyle(t,"::placeholder"),f=c&&c.color;if(f&&f!=="rgba(0, 0, 0, 0)"){let d="snapdom-ph-"+(Math.random()*1e6|0);i.classList.add(d);let m=document.createElement("style");m.textContent=`.${d}::placeholder{color:${f}!important;opacity:${c.opacity||"1"}!important;}`,i.prepend(m)}}catch{}if(t instanceof HTMLSelectElement&&(s=t.value),t instanceof HTMLTextAreaElement&&(o=t.value),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){t.disabled&&i.setAttribute("disabled",""),t.required&&i.setAttribute("required",""),t.readOnly&&i.setAttribute("readonly","");let c=t;c.min!==void 0&&c.min!==""&&i.setAttribute("min",c.min),c.max!==void 0&&c.max!==""&&i.setAttribute("max",c.max),c.pattern!==void 0&&c.pattern!==""&&i.setAttribute("pattern",c.pattern);let f=t.getAttribute("aria-invalid");f!==null&&i.setAttribute("aria-invalid",f)}if(it(t,i,e,n),u&&u(),t instanceof SVGElement){let c=["fill","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","opacity","fill-opacity","stroke-opacity","fill-rule","clip-rule","marker","marker-start","marker-mid","marker-end","visibility","display"];try{let f=window.getComputedStyle(t);for(let d of c){let m=f.getPropertyValue(d);m&&i.style.setProperty(d,m)}}catch{}}if(t.shadowRoot){let g=function(b,S){if(b.nodeType===Node.ELEMENT_NODE&&b.tagName==="STYLE")return S(null);_t(b,e,n).then(k=>{S(k||null)}).catch(()=>{S(null)})};var a=g;try{let b=t.shadowRoot.querySelectorAll("slot");for(let S of b){let k=[];try{k=S.assignedNodes?.({flatten:!0})||S.assignedNodes?.()||[]}catch{k=S.assignedNodes?.()||[]}for(let A of k)r.add(A)}}catch{}let c=tn(e),f=`[data-sd="${c}"]`;try{i.setAttribute("data-sd",c)}catch{}let d=en(t.shadowRoot),m=Ze(d,f),y=on(d),p=sn(t,y,f);nn(i,p+m,c);let h=document.createDocumentFragment(),w=await Qt(Array.from(t.shadowRoot.childNodes),g,n.fast);h.append(...w.filter(b=>!!b)),i.appendChild(h)}if(t.tagName==="SLOT"){let m=function(h,g){_t(h,e,n).then(w=>{w&&an(w),g(w||null)}).catch(()=>{g(null)})};var a=m;let c=t.assignedNodes?.({flatten:!0})||[],f=c.length>0?c:Array.from(t.childNodes),d=document.createDocumentFragment(),y=await Qt(Array.from(f),m,n.fast);return d.append(...y.filter(h=>!!h)),d}function a(c,f){if(r.has(c))return f(null);_t(c,e,n).then(d=>{f(d||null)}).catch(()=>{f(null)})}let l=await Qt(Array.from(t.childNodes),a,n.fast);if(i.append(...l.filter(c=>!!c)),s!==null&&i instanceof HTMLSelectElement){i.value=s;for(let c of i.options)c.value===s?c.setAttribute("selected",""):c.removeAttribute("selected")}return o!==null&&i instanceof HTMLTextAreaElement&&(i.textContent=o),i}Y();Rt();X();var uo=[/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],Ct=Object.assign({materialIconsFilled:"https://fonts.gstatic.com/s/materialicons/v48/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2",materialIconsOutlined:"https://fonts.gstatic.com/s/materialiconsoutlined/v110/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUcel5euIg.woff2",materialIconsRound:"https://fonts.gstatic.com/s/materialiconsround/v109/LDItaoyNOAY6Uewc665JcIzCKsKc_M9flwmPq_HTTw.woff2",materialIconsSharp:"https://fonts.gstatic.com/s/materialiconssharp/v110/oPWQ_lt5nv4pWNJpghLP75WiFR4kLh3kvmvRImcycg.woff2"},typeof window<"u"&&window.__SNAPDOM_ICON_FONTS__||{}),Ce=[];function dn(t){let e=Array.isArray(t)?t:[t];for(let n of e)n instanceof RegExp?Ce.push(n):typeof n=="string"?Ce.push(new RegExp(n,"i")):console.warn("[snapdom] Ignored invalid iconFont value:",n)}function Q(t){let e=typeof t=="string"?t:"",n=[...uo,...Ce];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))}function fo(t=""){let e=String(t).toLowerCase();return/\bmaterial\s*icons\b/.test(e)||/\bmaterial\s*symbols\b/.test(e)}var fn=new Map;function mo(t=""){let e=Object.create(null),n=String(t||""),r=/['"]?\s*([A-Za-z]{3,4})\s*['"]?\s*([+-]?\d+(?:\.\d+)?)\s*/g,s;for(;s=r.exec(n);)e[s[1].toUpperCase()]=Number(s[2]);return e}async function po(t,e,n){let r=String(t||""),s=r.toLowerCase(),o=String(e||"").toLowerCase();if(/\bmaterial\s*icons\b/.test(s)&&!/\bsymbols\b/.test(s))return{familyForMeasure:r,familyForCanvas:r};if(!/\bmaterial\s*symbols\b/.test(s))return{familyForMeasure:r,familyForCanvas:r};let u=n&&(n.FILL??n.fill),a="outlined";/\brounded\b/.test(o)||/\bround\b/.test(o)?a="rounded":/\bsharp\b/.test(o)?a="sharp":/\boutlined\b/.test(o)&&(a="outlined");let l=u===1,c=null;if(l&&(a==="outlined"&&Ct.materialIconsFilled?c={url:Ct.materialIconsFilled,alias:"snapdom-mi-filled"}:a==="rounded"&&Ct.materialIconsRound?c={url:Ct.materialIconsRound,alias:"snapdom-mi-round"}:a==="sharp"&&Ct.materialIconsSharp&&(c={url:Ct.materialIconsSharp,alias:"snapdom-mi-sharp"})),!c)return{familyForMeasure:r,familyForCanvas:r};if(!fn.has(c.alias))try{let d=new FontFace(c.alias,`url(${c.url})`,{style:"normal",weight:"400"});document.fonts.add(d),await d.load(),fn.set(c.alias,!0)}catch{return{familyForMeasure:r,familyForCanvas:r}}let f=`"${c.alias}"`;return{familyForMeasure:f,familyForCanvas:f}}async function ho(t="Material Icons",e=24){try{await Promise.all([document.fonts.load(`400 ${e}px "${String(t).replace(/["']/g,"")}"`),document.fonts.ready])}catch{}}function go(t){let e=t.getPropertyValue("-webkit-text-fill-color")?.trim()||"",n=/^transparent$/i.test(e)||/rgba?\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(e);if(e&&!n&&e.toLowerCase()!=="currentcolor")return e;let r=t.color?.trim();return r&&r!=="inherit"?r:"#000"}async function yo(t,{family:e="Material Icons",weight:n="normal",fontSize:r=32,color:s="#000",variation:o="",className:i=""}={}){let u=String(e||"").replace(/^['"]+|['"]+$/g,""),a=window.devicePixelRatio||1,l=mo(o),{familyForMeasure:c,familyForCanvas:f}=await po(u,i,l);await ho(f.replace(/^["']+|["']+$/g,""),r);let d=document.createElement("span");d.textContent=t,d.style.position="absolute",d.style.visibility="hidden",d.style.left="-99999px",d.style.whiteSpace="nowrap",d.style.fontFamily=c,d.style.fontWeight=String(n||"normal"),d.style.fontSize=`${r}px`,d.style.lineHeight="1",d.style.margin="0",d.style.padding="0",d.style.fontFeatureSettings="'liga' 1",d.style.fontVariantLigatures="normal",d.style.color=s,document.body.appendChild(d);let m=d.getBoundingClientRect(),y=Math.max(1,Math.ceil(m.width)),p=Math.max(1,Math.ceil(m.height));document.body.removeChild(d);let h=document.createElement("canvas");h.width=y*a,h.height=p*a;let g=h.getContext("2d");g.scale(a,a),g.font=`${n?`${n} `:""}${r}px ${f}`,g.textAlign="left",g.textBaseline="top",g.fillStyle=s;try{g.fontKerning="normal"}catch{}return g.fillText(t,0,0),{dataUrl:h.toDataURL(),width:y,height:p}}async function mn(t,e){if(!(t instanceof Element))return 0;let n='.material-icons, [class*="material-symbols"]',r=Array.from(t.querySelectorAll(n)).filter(i=>i&&i.textContent&&i.textContent.trim());if(r.length===0)return 0;let s=e instanceof Element?Array.from(e.querySelectorAll(n)).filter(i=>i&&i.textContent&&i.textContent.trim()):[],o=0;for(let i=0;i<r.length;i++){let u=r[i],a=s[i]||null;try{let l=getComputedStyle(a||u),c=l.fontFamily||"Material Icons";if(!fo(c))continue;let f=(a||u).textContent.trim();if(!f)continue;let d=parseInt(l.fontSize,10)||24,m=l.fontWeight&&l.fontWeight!=="normal"?l.fontWeight:"normal",y=go(l),p=l.fontVariationSettings&&l.fontVariationSettings!=="normal"?l.fontVariationSettings:"",h=(a||u).className||"",{dataUrl:g,width:w,height:C}=await yo(f,{family:c,weight:m,fontSize:d,color:y,variation:p,className:h});u.textContent="";let b=u.ownerDocument.createElement("img");b.src=g,b.alt=f,b.style.height=`${d}px`,b.style.width=`${Math.max(1,Math.round(w/C*d))}px`,b.style.objectFit="contain",b.style.verticalAlign=getComputedStyle(u).verticalAlign||"baseline",u.appendChild(b),o++}catch{}}return o}pt();async function gn(t,e,n,r=32,s="#000"){e=e.replace(/^['"]+|['"]+$/g,"");let o=window.devicePixelRatio||1;try{await document.fonts.ready}catch{}let i=document.createElement("span");i.textContent=t,i.style.position="absolute",i.style.visibility="hidden",i.style.fontFamily=`"${e}"`,i.style.fontWeight=n||"normal",i.style.fontSize=`${r}px`,i.style.lineHeight="1",i.style.whiteSpace="nowrap",i.style.padding="0",i.style.margin="0",document.body.appendChild(i);let u=i.getBoundingClientRect(),a=Math.ceil(u.width),l=Math.ceil(u.height);document.body.removeChild(i);let c=document.createElement("canvas");c.width=Math.max(1,a*o),c.height=Math.max(1,l*o);let f=c.getContext("2d");return f.scale(o,o),f.font=n?`${n} ${r}px "${e}"`:`${r}px "${e}"`,f.textAlign="left",f.textBaseline="top",f.fillStyle=s,f.fillText(t,0,0),{dataUrl:c.toDataURL(),width:a,height:l}}var yn=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]),bo=["katex","mathjax","mathml"];function ke(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^['"]+|['"]+$/g,"");if(n&&!yn.has(n.toLowerCase()))return n}return""}function wo(t){if(!t)return[];let e=[];for(let n of t.split(",")){let r=n.trim().replace(/^['"]+|['"]+$/g,"");r&&(yn.has(r.toLowerCase())||e.push(r))}return e}function Jt(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 Zt(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function So(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function xo(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let s=Jt(n[1]),o=Jt(n[2]);return{min:Math.min(s,o),max:Math.max(s,o)}}let r=Jt(e);return{min:r,max:r}}function Co(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function Ao(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let o=parseFloat(n[1]),i=parseFloat(n[2]);return{min:Math.min(o,i),max:Math.max(o,i)}}let r=e.match(/(\d+(?:\.\d+)?)\s*%/),s=r?parseFloat(r[1]):100;return{min:s,max:s}}function ko(t){return!t||typeof t!="string"?"":t.replace(/\s+(variable|vf|v[0-9]+)$/i,"").trim().toLowerCase().replace(/\s+/g,"-")}function vo(t,e,n=[]){if(!t)return!1;try{let r=new URL(t,location.href);if(r.origin===location.origin)return!0;let o=r.host.toLowerCase();if(["fonts.googleapis.com","fonts.gstatic.com","use.typekit.net","p.typekit.net","kit.fontawesome.com","use.fontawesome.com","cdn.jsdelivr.net","unpkg.com","cdnjs.cloudflare.com","esm.sh"].some(a=>o.endsWith(a))||n.some(a=>o===a.toLowerCase()||o.endsWith("."+a.toLowerCase())))return!0;let u=(r.pathname+r.search).toLowerCase();if(/\bfont(s)?\b/.test(u)||/\.woff2?(\b|$)/.test(u)||bo.some(a=>u.includes(a)))return!0;for(let a of e){let l=a.toLowerCase().replace(/\s+/g,"+"),c=a.toLowerCase().replace(/\s+/g,"-"),f=ko(a);if(u.includes(l)||u.includes(c)||f&&u.includes(f))return!0}return!1}catch{return!1}}function Eo(t){let e=new Set;for(let n of t||[]){let r=String(n).split("__")[0]?.trim();r&&e.add(r)}return e}function pn(t,e){return t&&t.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/g,(n,r,s)=>{let o=(s||"").trim();if(!o||/^data:|^blob:|^https?:|^file:|^about:/i.test(o))return n;let i=o;try{i=new URL(o,e||location.href).href}catch{}return`url("${i}")`})}var Ae=/@import\s+(?:url\(\s*(['"]?)([^)"']+)\1\s*\)|(['"])([^"']+)\3)([^;]*);/g,te=4;async function Mo(t,e,n){if(!t)return t;let r=new Set;function s(u,a){try{return new URL(u,a||location.href).href}catch{return u}}async function o(u,a,l=0){if(l>te)return console.warn(`[snapDOM] @import depth exceeded (${te}) at ${a}`),u;let c="",f=0,d;for(;d=Ae.exec(u);){c+=u.slice(f,d.index),f=Ae.lastIndex;let m=(d[2]||d[4]||"").trim(),y=s(m,a);if(r.has(y)){console.warn(`[snapDOM] Skipping circular @import: ${y}`);continue}r.add(y);let p="";try{let h=await U(y,{as:"text",useProxy:n,silent:!0});h.ok&&typeof h.data=="string"&&(p=h.data)}catch{}p?(p=pn(p,y),p=await o(p,y,l+1),c+=`
|
|
12
|
+
/* inlined: ${y} */
|
|
13
|
+
${p}
|
|
14
|
+
`):c+=d[0]}return c+=u.slice(f),c}let i=pn(t,e||location.href);return i=await o(i,e||location.href,0),i}var bn=/url\((["']?)([^"')]+)\1\)/g,Fo=/@font-face[^{}]*\{[^}]*\}/g;function wn(t){if(!t)return[];let e=[],n=t.split(",").map(r=>r.trim()).filter(Boolean);for(let r of n){let s=r.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!s)continue;let o=s[1],i=s[2],u=a=>{if(!a.includes("?"))return parseInt(a,16);let l=parseInt(a.replace(/\?/g,"0"),16),c=parseInt(a.replace(/\?/g,"F"),16);return[l,c]};if(i){let a=u(o),l=u(i),c=Array.isArray(a)?a[0]:a,f=Array.isArray(l)?l[1]:l;e.push([Math.min(c,f),Math.max(c,f)])}else{let a=u(o);Array.isArray(a)?e.push([a[0],a[1]]):e.push([a,a])}}return e}function Sn(t,e){if(!e.length||!t||t.size===0)return!0;for(let n of t)for(let[r,s]of e)if(n>=r&&n<=s)return!0;return!1}function ve(t,e){let n=[];if(!t)return n;for(let r of t.matchAll(bn)){let s=(r[2]||"").trim();if(!(!s||s.startsWith("data:"))){if(!/^https?:/i.test(s))try{s=new URL(s,e||location.href).href}catch{}n.push(s)}}return n}async function xn(t,e,n=""){let r=t;for(let s of t.matchAll(bn)){let o=mt(s[0]);if(!o)continue;let i=o;if(!i.startsWith("http")&&!i.startsWith("data:"))try{i=new URL(i,e||location.href).href}catch{}if(!Q(i)){if(x.resource?.has(i)){x.font?.add(i),r=r.replace(s[0],`url(${x.resource.get(i)})`);continue}if(!x.font?.has(i))try{let u=await U(i,{as:"dataURL",useProxy:n,silent:!0});if(u.ok&&typeof u.data=="string"){let a=u.data;x.resource?.set(i,a),x.font?.add(i),r=r.replace(s[0],`url(${a})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",i)}}}return r}function $o(t){if(!t.length)return null;let e=(u,a)=>t.some(([l,c])=>!(c<u||l>a)),n=e(0,255)||e(305,305),r=e(256,591)||e(7680,7935),s=e(880,1023),o=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":o?"cyrillic":s?"greek":r?"latin-ext":n?"latin":null}function hn(t={}){let e=new Set((t.families||[]).map(s=>String(s).toLowerCase())),n=new Set((t.domains||[]).map(s=>String(s).toLowerCase())),r=new Set((t.subsets||[]).map(s=>String(s).toLowerCase()));return(s,o)=>{if(e.size&&e.has(s.family.toLowerCase()))return!0;if(n.size)for(let i of s.srcUrls)try{if(n.has(new URL(i).host.toLowerCase()))return!0}catch{}if(r.size){let i=$o(o);if(i&&r.has(i))return!0}return!1}}function Ro(t){if(!t)return t;let e=/@font-face[^{}]*\{[^}]*\}/gi,n=new Set,r=[];for(let o of t.match(e)||[]){let i=o.match(/font-family:\s*([^;]+);/i)?.[1]||"",u=ke(i),a=(o.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),l=(o.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),c=(o.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),f=(o.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),d=(o.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),m=ve(d,location.href),y=m.length?m.map(h=>String(h).toLowerCase()).sort().join("|"):d.toLowerCase(),p=[String(u||"").toLowerCase(),a,l,c,f.toLowerCase(),y].join("|");n.has(p)||(n.add(p),r.push(o))}if(r.length===0)return t;let s=0;return t.replace(e,()=>r[s++]||"")}function Lo(t,e,n,r,s){let o=Array.from(t||[]).sort().join("|"),i=e?JSON.stringify({families:(e.families||[]).map(c=>String(c).toLowerCase()).sort(),domains:(e.domains||[]).map(c=>String(c).toLowerCase()).sort(),subsets:(e.subsets||[]).map(c=>String(c).toLowerCase()).sort()}):"",u=(n||[]).map(c=>`${(c.family||"").toLowerCase()}::${c.weight||"normal"}::${c.style||"normal"}::${c.src||""}`).sort().join("|"),a=r||"",l=(s||[]).map(c=>String(c).toLowerCase()).sort().join("|");return`fonts-embed-css::req=${o}::ex=${i}::lf=${u}::px=${a}::fd=${l}`}async function Cn(t,e,n,r){let s;try{s=t.cssRules||[]}catch{return}let o=(i,u)=>{try{return new URL(i,u||location.href).href}catch{return i}};for(let i of s){if(i.type===CSSRule.IMPORT_RULE&&i.styleSheet){let u=i.href?o(i.href,e):e;if(r.depth>=te){console.warn(`[snapDOM] CSSOM import depth exceeded (${te}) at ${u}`);continue}if(u&&r.visitedSheets.has(u)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${u}`);continue}u&&r.visitedSheets.add(u);let a={...r,depth:(r.depth||0)+1};await Cn(i.styleSheet,u,n,a);continue}if(i.type===CSSRule.FONT_FACE_RULE){let u=(i.style.getPropertyValue("font-family")||"").trim(),a=ke(u);if(!a||Q(a))continue;let l=(i.style.getPropertyValue("font-weight")||"400").trim(),c=(i.style.getPropertyValue("font-style")||"normal").trim(),f=(i.style.getPropertyValue("font-stretch")||"100%").trim(),d=(i.style.getPropertyValue("src")||"").trim(),m=(i.style.getPropertyValue("unicode-range")||"").trim();if(!r.faceMatchesRequired(a,c,l,f))continue;let y=wn(m);if(!Sn(r.usedCodepoints,y))continue;let p={family:a,weightSpec:l,styleSpec:c,stretchSpec:f,unicodeRange:m,srcRaw:d,srcUrls:ve(d,e||location.href),href:e||location.href};if(r.simpleExcluder&&r.simpleExcluder(p,y))continue;if(/url\(/i.test(d)){let h=await xn(d,e||location.href,r.useProxy);await n(`@font-face{font-family:${a};src:${h};font-style:${c};font-weight:${l};font-stretch:${f};${m?`unicode-range:${m};`:""}}`)}else await n(`@font-face{font-family:${a};src:${d};font-style:${c};font-weight:${l};font-stretch:${f};${m?`unicode-range:${m};`:""}}`)}}}async function ee({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:r=[],useProxy:s="",fontStylesheetDomains:o=[]}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let i=new Map;for(let h of t){let[g,w,C,b]=String(h).split("__");if(!g)continue;let S=i.get(g)||[];S.push({w:parseInt(w,10),s:C,st:parseInt(b,10)}),i.set(g,S)}function u(h,g,w,C){if(!i.has(h))return!1;let b=i.get(h),S=xo(w),k=Co(g),A=Ao(C),v=S.min!==S.max,E=S.min,P=L=>k.kind==="normal"&&L==="normal"||k.kind!=="normal"&&(L==="italic"||L==="oblique"),I=!1;for(let L of b){let _=v?L.w>=S.min&&L.w<=S.max:L.w===E,B=P(Zt(L.s)),F=L.st>=A.min&&L.st<=A.max;if(_&&B&&F){I=!0;break}}if(I)return!0;if(!v)for(let L of b){let _=P(Zt(L.s)),B=L.st>=A.min&&L.st<=A.max;if(Math.abs(E-L.w)<=300&&_&&B)return!0}if(!v&&k.kind==="normal"&&b.some(_=>Zt(_.s)!=="normal"))for(let _ of b){let B=Math.abs(E-_.w)<=300,F=_.st>=A.min&&_.st<=A.max;if(B&&F)return!0}return!1}let a=hn(n),l=Lo(t,n,r,s,o);if(x.resource?.has(l))return x.resource.get(l);let c=Eo(t),f=[],d=Ae;for(let h of document.querySelectorAll("style")){let g=h.textContent||"";for(let w of g.matchAll(d)){let C=(w[2]||w[4]||"").trim();if(!C||Q(C))continue;!!document.querySelector(`link[rel="stylesheet"][href="${C}"]`)||f.push(C)}}f.length&&await Promise.all(f.map(h=>new Promise(g=>{if(document.querySelector(`link[rel="stylesheet"][href="${h}"]`))return g(null);let w=document.createElement("link");w.rel="stylesheet",w.href=h,w.setAttribute("data-snapdom","injected-import"),w.onload=()=>g(w),w.onerror=()=>g(null),document.head.appendChild(w)})));let m="",y=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(h=>!!h.href);for(let h of y)try{if(Q(h.href))continue;let g="",w=!1;try{w=new URL(h.href,location.href).origin===location.origin}catch{}if(!w){let b=Array.isArray(o)?o:[];if(!vo(h.href,c,b))continue}if(w){let b=Array.from(document.styleSheets).find(S=>S.href===h.href);if(b)try{let S=b.cssRules||[];g=Array.from(S).map(k=>k.cssText).join("")}catch{}}if(!g){let b=await U(h.href,{as:"text",useProxy:s});if(b?.ok&&typeof b.data=="string"&&(g=b.data),Q(h.href))continue}g=await Mo(g,h.href,s);let C="";for(let b of g.match(Fo)||[]){let S=(b.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),k=ke(S);if(!k||Q(k))continue;let A=(b.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),v=(b.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),E=(b.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),P=(b.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),I=(b.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),L=ve(I,h.href);if(!u(k,v,A,E))continue;let _=wn(P);if(!Sn(e,_))continue;let B={family:k,weightSpec:A,styleSpec:v,stretchSpec:E,unicodeRange:P,srcRaw:I,srcUrls:L,href:h.href};if(n&&a(B,_))continue;let F=/url\(/i.test(I)?await xn(b,h.href,s):b;C+=F}C.trim()&&(m+=C)}catch{console.warn("[snapDOM] Failed to process stylesheet:",h.href)}let p={requiredIndex:i,usedCodepoints:e,faceMatchesRequired:u,simpleExcluder:n?hn(n):null,useProxy:s,visitedSheets:new Set,depth:0};for(let h of document.styleSheets)if(!(h.href&&y.some(g=>g.href===h.href)))try{let g=h.href||location.origin+"/";g&&p.visitedSheets.add(g),await Cn(h,g,async w=>{m+=w},p)}catch{}try{for(let h of document.fonts||[]){if(!h||!h.family||h.status!=="loaded"||!h._snapdomSrc)continue;let g=String(h.family).replace(/^['"]+|['"]+$/g,"");if(Q(g)||!i.has(g)||n?.families&&n.families.some(C=>String(C).toLowerCase()===g.toLowerCase()))continue;let w=h._snapdomSrc;if(!String(w).startsWith("data:")){if(x.resource?.has(h._snapdomSrc))w=x.resource.get(h._snapdomSrc),x.font?.add(h._snapdomSrc);else if(!x.font?.has(h._snapdomSrc))try{let C=await U(h._snapdomSrc,{as:"dataURL",useProxy:s,silent:!0});if(C.ok&&typeof C.data=="string")w=C.data,x.resource?.set(h._snapdomSrc,w),x.font?.add(h._snapdomSrc);else continue}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",h._snapdomSrc);continue}}m+=`@font-face{font-family:'${g}';src:url(${w});font-style:${h.style||"normal"};font-weight:${h.weight||"normal"};}`}}catch{}for(let h of r){if(!h||typeof h!="object")continue;let g=String(h.family||"").replace(/^['"]+|['"]+$/g,"");if(!g||Q(g)||!i.has(g)||n?.families&&n.families.some(A=>String(A).toLowerCase()===g.toLowerCase()))continue;let w=h.weight!=null?String(h.weight):"normal",C=h.style!=null?String(h.style):"normal",b=h.stretchPct!=null?`${h.stretchPct}%`:"100%",S=String(h.src||""),k=S;if(!k.startsWith("data:")){if(x.resource?.has(S))k=x.resource.get(S),x.font?.add(S);else if(!x.font?.has(S))try{let A=await U(S,{as:"dataURL",useProxy:s,silent:!0});if(A.ok&&typeof A.data=="string")k=A.data,x.resource?.set(S,k),x.font?.add(S);else continue}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",S);continue}}m+=`@font-face{font-family:'${g}';src:url(${k});font-style:${C};font-weight:${w};font-stretch:${b};}`}return m&&(m=Ro(m),x.resource?.set(l,m)),m}function At(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),r=i=>{let u=wo(i.fontFamily);if(u.length)for(let a of u){let l=(c,f,d)=>`${a}__${Jt(c)}__${Zt(f)}__${So(d)}`;e.add(l(i.fontWeight,i.fontStyle,i.fontStretch))}};r(getComputedStyle(t));let s=getComputedStyle(t,"::before");s&&s.content&&s.content!=="none"&&r(s);let o=getComputedStyle(t,"::after");for(o&&o.content&&o.content!=="none"&&r(o);n.nextNode();){let i=n.currentNode,u=getComputedStyle(i);r(u);let a=getComputedStyle(i,"::before");a&&a.content&&a.content!=="none"&&r(a);let l=getComputedStyle(i,"::after");l&&l.content&&l.content!=="none"&&r(l)}return e}function ne(t){let e=new Set,n=s=>{if(s)for(let o of s)e.add(o.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 o=s;for(let i of["::before","::after"]){let a=getComputedStyle(o,i)?.getPropertyValue("content");if(!(!a||a==="none"))if(/^"/.test(a)||/^'/.test(a))n(a.slice(1,-1));else{let l=a.match(/\\[0-9A-Fa-f]{1,6}/g);if(l)for(let c of l)try{e.add(parseInt(c.slice(1),16))}catch{}}}}}return e}async function kt(t,e=2){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 o of n){let i=document.createElement("span");i.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",i.style.fontFamily=`"${o}"`,i.style.fontWeight="700",i.style.fontStyle="italic",i.style.fontSize="32px",i.style.lineHeight="1",i.style.whiteSpace="nowrap",i.style.margin="0",i.style.padding="0",s.appendChild(i)}document.body.appendChild(s),s.offsetWidth,document.body.removeChild(s)};for(let s=0;s<Math.max(1,e);s++)r(),await new Promise(o=>requestAnimationFrame(()=>requestAnimationFrame(o)))}X();function En(t){return/\bcounter\s*\(|\bcounters\s*\(/.test(t||"")}function Po(t){return(t||"").replace(/"([^"]*)"/g,"$1")}function An(t,e=!1){let n="",r=Math.max(1,t);for(;r>0;)r--,n=String.fromCharCode(97+r%26)+n,r=Math.floor(r/26);return e?n.toUpperCase():n}function kn(t,e=!0){let n=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],r=Math.max(1,Math.min(3999,t)),s="";for(let[o,i]of n)for(;r>=o;)s+=i,r-=o;return e?s:s.toLowerCase()}function vn(t,e){switch((e||"decimal").toLowerCase()){case"decimal":return String(t);case"decimal-leading-zero":{let n=Math.abs(t);return(t<0?"-":"")+(n<10?"0":"")+String(n)}case"lower-alpha":return An(t,!1);case"upper-alpha":return An(t,!0);case"lower-roman":return kn(t,!1);case"upper-roman":return kn(t,!0);default:return String(t)}}function Mn(t){let e=()=>x?.session?.__counterEpoch??0,n=e(),r=new WeakMap,s=t instanceof Document?t.documentElement:t,o=d=>d&&d.tagName==="LI",i=d=>{let m=0,y=d?.parentElement;if(!y)return 0;for(let p of y.children){if(p===d)break;p.tagName==="LI"&&m++}return m},u=d=>{let m=new Map;for(let[y,p]of d)m.set(y,p.slice());return m},a=(d,m,y)=>{let p=u(d),h;try{h=y.style?.counterReset||getComputedStyle(y).counterReset}catch{}if(h&&h!=="none")for(let C of h.split(",")){let b=C.trim().split(/\s+/),S=b[0],k=Number.isFinite(Number(b[1]))?Number(b[1]):0;if(!S)continue;let A=m.get(S);if(A&&A.length){let v=A.slice();v.push(k),p.set(S,v)}else p.set(S,[k])}let g;try{g=y.style?.counterSet||getComputedStyle(y).counterSet}catch{}if(g&&g!=="none")for(let C of g.split(",")){let b=C.trim().split(/\s+/),S=b[0],k=Number.isFinite(Number(b[1]))?Number(b[1]):0;if(!S)continue;let A=p.get(S)||[];A.length===0&&A.push(0),A[A.length-1]=k,p.set(S,A)}let w;try{w=y.style?.counterIncrement||getComputedStyle(y).counterIncrement}catch{}if(w&&w!=="none")for(let C of w.split(",")){let b=C.trim().split(/\s+/),S=b[0],k=Number.isFinite(Number(b[1]))?Number(b[1]):1;if(!S)continue;let A=p.get(S)||[];A.length===0&&A.push(0),A[A.length-1]+=k,p.set(S,A)}try{if(getComputedStyle(y).display==="list-item"&&o(y)){let b=y.parentElement,S=1;if(b&&b.tagName==="OL"){let A=b.getAttribute("start"),v=Number.isFinite(Number(A))?Number(A):1,E=i(y),P=y.getAttribute("value");S=Number.isFinite(Number(P))?Number(P):v+E}else S=1+i(y);let k=p.get("list-item")||[];k.length===0&&k.push(0),k[k.length-1]=S,p.set("list-item",k)}}catch{}return p},l=(d,m,y)=>{let p=a(y,m,d);r.set(d,p);let h=p;for(let w of d.children)h=l(w,p,h);let g=new Map;for(let[w,C]of y){let b=C.length,S=h.get(w);g.set(w,S&&S.length?S.slice(0,b):C.slice())}for(let[w,C]of h)!g.has(w)&&C.length&&!m.has(w)&&g.set(w,C.slice(0,1));return g},c=new Map;l(s,c,c);function f(){let d=e();if(d!==n){n=d;let m=new Map;l(s,m,m)}}return{get(d,m){f();let y=r.get(d)?.get(m);return y&&y.length?y[y.length-1]:0},getStack(d,m){f();let y=r.get(d)?.get(m);return y?y.slice():[]}}}function Fn(t,e,n){if(!t||t==="none")return t;try{let r=/\b(counter|counters)\s*\(([^)]+)\)/g,s=t.replace(r,(o,i,u)=>{let a=String(u).split(",").map(l=>l.trim());if(i==="counter"){let l=a[0]?.replace(/^["']|["']$/g,""),c=(a[1]||"decimal").toLowerCase(),f=n.get(e,l);return vn(f,c)}else{let l=a[0]?.replace(/^["']|["']$/g,""),c=a[1]?.replace(/^["']|["']$/g,"")??"",f=(a[2]||"decimal").toLowerCase(),d=n.getStack(e,l);return d.length?d.map(y=>vn(y,f)).join(c):""}});return Po(s)}catch{return"- "}}pt();X();var vt=new WeakMap,$n=1e3;function No(t,e){let n=Nn(t);return e?(e.__pseudoPreflightFp!==n&&(e.__pseudoPreflight=Ln(t),e.__pseudoPreflightFp=n),!!e.__pseudoPreflight):Ln(t)}function Ee(t){try{return t&&t.cssRules?t.cssRules:null}catch{return null}}function Nn(t){let e=t.querySelectorAll('style,link[rel~="stylesheet"]'),n=`n:${e.length}|`,r=0;for(let o=0;o<e.length;o++){let i=e[o];if(i.tagName==="STYLE"){let u=i.textContent?i.textContent.length:0;n+=`S${u}|`;let a=i.sheet,l=a?Ee(a):null;l&&(r+=l.length)}else{let u=i.getAttribute("href")||"",a=i.getAttribute("media")||"all";n+=`L${u}|m:${a}|`;let l=i.sheet,c=l?Ee(l):null;c&&(r+=c.length)}}let s=t.adoptedStyleSheets;return n+=`ass:${Array.isArray(s)?s.length:0}|tr:${r}`,n}function Rn(t,e,n){let r=Ee(t);if(!r)return!1;for(let s=0;s<r.length;s++){if(n.budget<=0)return!1;let o=r[s],i=o&&o.cssText?o.cssText:"";n.budget--;for(let u of e)if(i.includes(u))return!0;if(o&&o.cssRules&&o.cssRules.length)for(let u=0;u<o.cssRules.length&&n.budget>0;u++){let a=o.cssRules[u],l=a&&a.cssText?a.cssText:"";n.budget--;for(let c of e)if(l.includes(c))return!0}if(n.budget<=0)return!1}return!1}function Ln(t=document){let e=Nn(t),n=vt.get(t);if(n&&n.fingerprint===e)return n.result;let r=["::before","::after","::first-letter",":before",":after",":first-letter","counter(","counters(","counter-increment","counter-reset"],s=t.querySelectorAll("style");for(let i=0;i<s.length;i++){let u=s[i].textContent||"";for(let a of r)if(u.includes(a))return vt.set(t,{fingerprint:e,result:!0}),!0}let o=t.adoptedStyleSheets;if(Array.isArray(o)&&o.length){let i={budget:$n};try{for(let u of o)if(Rn(u,r,i))return vt.set(t,{fingerprint:e,result:!0}),!0}catch{}}{let i=t.querySelectorAll('style,link[rel~="stylesheet"]'),u={budget:$n};for(let a=0;a<i.length&&u.budget>0;a++){let l=i[a],c=null;if(l.tagName,c=l.sheet||null,c&&Rn(c,r,u))return vt.set(t,{fingerprint:e,result:!0}),!0}}return t.querySelector('[style*="counter("], [style*="counters("]')?(vt.set(t,{fingerprint:e,result:!0}),!0):(vt.set(t,{fingerprint:e,result:!1}),!1)}var Et=new WeakMap,Pn=-1;function To(t){return(t||"").replace(/"([^"]*)"/g,"$1")}function Io(t){if(!t)return"";let e=[],n=/"([^"]*)"/g,r;for(;r=n.exec(t);)e.push(r[1]);return e.length?e.join(""):To(t)}function Me(t,e){let n=t.parentElement,r=n?Et.get(n):null;return r?{get(s,o){let i=e.get(s,o),u=r.get(o);return typeof u=="number"?Math.max(i,u):i},getStack(s,o){let i=e.getStack(s,o);if(!i.length)return i;let u=r.get(o);if(typeof u=="number"){let a=i.slice();return a[a.length-1]=Math.max(a[a.length-1],u),a}return i}}:e}function Fe(t,e,n){let r=new Map;function s(a){let l=[];if(!a||a==="none")return l;for(let c of String(a).split(",")){let f=c.trim().split(/\s+/),d=f[0],m=Number.isFinite(Number(f[1]))?Number(f[1]):void 0;d&&l.push({name:d,num:m})}return l}let o=s(e?.counterReset),i=s(e?.counterIncrement);function u(a){if(r.has(a))return r.get(a).slice();let l=n.getStack(t,a);l=l.length?l.slice():[];let c=o.find(d=>d.name===a);if(c){let d=Number.isFinite(c.num)?c.num:0;l=l.length?[...l,d]:[d]}let f=i.find(d=>d.name===a);if(f){let d=Number.isFinite(f.num)?f.num:1;l.length===0&&(l=[0]),l[l.length-1]+=d}return r.set(a,l.slice()),l}return{get(a,l){let c=u(l);return c.length?c[c.length-1]:0},getStack(a,l){return u(l)},__incs:i}}function _o(t,e,n){let r;try{r=H(t,e)}catch{}let s=r?.content;if(!s||s==="none"||s==="normal")return{text:"",incs:[]};let o=Me(t,n),i=Fe(t,r,o),u=En(s)?Fn(s,t,i):s;return{text:Io(u),incs:i.__incs||[]}}async function re(t,e,n,r){if(!(t instanceof Element)||!(e instanceof Element))return;let s=t.ownerDocument||document;if(!No(s,n))return;let o=x?.session?.__counterEpoch??0;if(Pn!==o&&(Et=new WeakMap,n&&(n.__counterCtx=null),Pn=o),!n.__counterCtx)try{n.__counterCtx=Mn(t.ownerDocument||document)}catch(a){R(n,"buildCounterContext failed",a)}let i=n.__counterCtx;for(let a of["::before","::after","::first-letter"])try{let l=H(t,a);if(!l||l.content==="none"&&l.backgroundImage==="none"&&l.backgroundColor==="transparent"&&(l.borderStyle==="none"||parseFloat(l.borderWidth)===0)&&(!l.transform||l.transform==="none")&&l.display==="inline")continue;if(a==="::first-letter"){let $=H(t);if(!(l.color!==$.color||l.fontSize!==$.fontSize||l.fontWeight!==$.fontWeight||l.fontFamily!==$.fontFamily||l.fontStyle!==$.fontStyle||l.textTransform!==$.textTransform||l.float!==$.float||l.paddingTop!==$.paddingTop||l.paddingRight!==$.paddingRight||l.paddingBottom!==$.paddingBottom||l.paddingLeft!==$.paddingLeft||l.marginTop!==$.marginTop||l.marginRight!==$.marginRight||l.marginBottom!==$.marginBottom||l.marginLeft!==$.marginLeft))continue;let W=Array.from(e.childNodes).find(Ht=>Ht.nodeType===Node.TEXT_NODE&&Ht.textContent?.trim().length>0);if(!W)continue;let D=W.textContent,tt=D.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0],bt=D.slice(tt?.length||0);if(!tt||/[\uD800-\uDFFF]/.test(tt))continue;let et=document.createElement("span");et.textContent=tt,et.dataset.snapdomPseudo="::first-letter";let Ot=Yt(l),Bt=wt(Ot,"span");n.styleMap.set(et,Bt);let Dt=document.createTextNode(bt);e.replaceChild(Dt,W),e.insertBefore(et,Dt);continue}let f=l.content??"",d=f===""||f==="none"||f==="normal",{text:m,incs:y}=_o(t,a,i),p=l.backgroundImage,h=l.backgroundColor,g=l.fontFamily,w=parseInt(l.fontSize)||32,C=parseInt(l.fontWeight)||!1,b=l.color||"#000",S=l.borderStyle,k=parseFloat(l.borderWidth),A=l.transform,v=Q(g),E=!d&&m!=="",P=p&&p!=="none",I=h&&h!=="transparent"&&h!=="rgba(0, 0, 0, 0)",L=S&&S!=="none"&&k>0,_=A&&A!=="none";if(!(E||P||I||L||_)){if(y&&y.length&&t.parentElement){let $=Et.get(t.parentElement)||new Map;for(let{name:T}of y){if(!T)continue;let W=Me(t,i),Z=Fe(t,H(t,a),W).get(t,T);$.set(T,Z)}Et.set(t.parentElement,$)}continue}let F=document.createElement("span");F.dataset.snapdomPseudo=a,F.style.pointerEvents="none";let ft=Yt(l),dt=wt(ft,"span");if(n.styleMap.set(F,dt),v&&m&&m.length===1){let{dataUrl:$,width:T,height:W}=await gn(m,g,C,w,b),D=document.createElement("img");D.src=$,D.style=`height:${w}px;width:${T/W*w}px;object-fit:contain;`,F.appendChild(D),e.dataset.snapdomHasIcon="true"}else if(m&&m.startsWith("url(")){let $=mt(m);if($?.trim())try{let T=await U(ut($),{as:"dataURL",useProxy:r.useProxy});if(T?.ok&&typeof T.data=="string"){let W=document.createElement("img");W.src=T.data,W.style=`width:${w}px;height:auto;object-fit:contain;`,F.appendChild(W)}}catch(T){console.error(`[snapdom] Error in pseudo ${a} for`,t,T)}}else!v&&E&&(F.textContent=m);F.style.backgroundImage="none","maskImage"in F.style&&(F.style.maskImage="none"),"webkitMaskImage"in F.style&&(F.style.webkitMaskImage="none");try{F.style.backgroundRepeat=l.backgroundRepeat,F.style.backgroundSize=l.backgroundSize,l.backgroundPositionX&&l.backgroundPositionY?(F.style.backgroundPositionX=l.backgroundPositionX,F.style.backgroundPositionY=l.backgroundPositionY):F.style.backgroundPosition=l.backgroundPosition,F.style.backgroundOrigin=l.backgroundOrigin,F.style.backgroundClip=l.backgroundClip,F.style.backgroundAttachment=l.backgroundAttachment,F.style.backgroundBlendMode=l.backgroundBlendMode}catch{}if(P)try{let $=St(p),T=await Promise.all($.map(ht));F.style.backgroundImage=T.join(", ")}catch($){console.warn(`[snapdom] Failed to inline background-image for ${a}`,$)}I&&(F.style.backgroundColor=h);let st=F.childNodes.length>0||F.textContent?.trim()!==""||P||I||L||_;if(y&&y.length&&t.parentElement){let $=Et.get(t.parentElement)||new Map,T=Me(t,i),W=Fe(t,H(t,a),T);for(let{name:D}of y){if(!D)continue;let Z=W.get(t,D);$.set(D,Z)}Et.set(t.parentElement,$)}if(!st)continue;a==="::before"?(e.dataset.snapdomHasBefore="1",e.insertBefore(F,e.firstChild)):(e.dataset.snapdomHasAfter="1",e.appendChild(F))}catch(l){console.warn(`[snapdom] Failed to capture ${a} for`,t,l)}let u=Array.from(e.children).filter(a=>!a.dataset.snapdomPseudo);if(n.nodeMap)for(let a of u){let l=n.nodeMap.get(a);l instanceof Element&&await re(l,a,n,r)}else{let a=Array.from(t.children);for(let l=0;l<Math.min(a.length,u.length);l++)await re(a[l],u[l],n,r)}}function Tn(t,e){if(!t||!(t instanceof Element))return;let n=t.ownerDocument||document,r=e||n,s=t instanceof SVGSVGElement?[t]:Array.from(t.querySelectorAll("svg"));if(s.length===0)return;let o=/url\(\s*#([^)]+)\)/g,i=["fill","stroke","filter","clip-path","mask","marker","marker-start","marker-mid","marker-end"],u=b=>window.CSS&&CSS.escape?CSS.escape(b):b.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),a="http://www.w3.org/1999/xlink",l=b=>{if(!b||!b.getAttribute)return null;let S=b.getAttribute("href")||b.getAttribute("xlink:href")||(typeof b.getAttributeNS=="function"?b.getAttributeNS(a,"href"):null);if(S)return S;let k=b.attributes;if(!k)return null;for(let A=0;A<k.length;A++){let v=k[A];if(!v||!v.name)continue;if(v.name==="href")return v.value;let E=v.name.indexOf(":");if(E!==-1&&v.name.slice(E+1)==="href")return v.value}return null},c=new Set(Array.from(t.querySelectorAll("[id]")).map(b=>b.id)),f=new Set,d=!1,m=(b,S=null)=>{if(!b)return;o.lastIndex=0;let k;for(;k=o.exec(b);){d=!0;let A=(k[1]||"").trim();A&&(c.has(A)||(f.add(A),S&&!S.has(A)&&S.add(A)))}},y=b=>{let S=b.querySelectorAll("use");for(let v of S){let E=l(v);if(!E||!E.startsWith("#"))continue;d=!0;let P=E.slice(1).trim();P&&!c.has(P)&&f.add(P)}let A=b.querySelectorAll('*[style*="url("],*[fill^="url("], *[stroke^="url("],*[filter^="url("],*[clip-path^="url("],*[mask^="url("],*[marker^="url("],*[marker-start^="url("],*[marker-mid^="url("],*[marker-end^="url("]');for(let v of A){m(v.getAttribute("style")||"");for(let E of i)m(v.getAttribute(E))}};for(let b of s)y(b);if(!d)return;let p=t.querySelector("svg.inline-defs-container");p||(p=n.createElementNS("http://www.w3.org/2000/svg","svg"),p.classList.add("inline-defs-container"),p.setAttribute("aria-hidden","true"),p.setAttribute("style","position:absolute;width:0;height:0;overflow:hidden"),t.insertBefore(p,t.firstChild||null));let h=p.querySelector("defs")||null,g=b=>{if(!b||c.has(b))return null;let S=u(b),k=A=>{let v=r.querySelector(A);return v&&!t.contains(v)?v:null};return k(`svg defs > *#${S}`)||k(`svg > symbol#${S}`)||k(`*#${S}`)};if(!f.size)return;let w=new Set(f),C=new Set;for(;w.size;){let b=w.values().next().value;if(w.delete(b),!b||c.has(b)||C.has(b))continue;let S=g(b);if(!S){C.add(b);continue}h||(h=n.createElementNS("http://www.w3.org/2000/svg","defs"),p.appendChild(h));let k=S.cloneNode(!0);k.id||k.setAttribute("id",b),h.appendChild(k),C.add(b),c.add(b);let A=[k,...k.querySelectorAll("*")];for(let v of A){let E=l(v);if(E&&E.startsWith("#")){let I=E.slice(1).trim();I&&!c.has(I)&&!C.has(I)&&w.add(I)}let P=v.getAttribute?.("style")||"";P&&m(P,w);for(let I of i){let L=v.getAttribute?.(I);L&&m(L,w)}}}}X();function _n(t,e){if(!t||!e)return;let n=t.scrollTop||0;if(!n)return;getComputedStyle(e).position==="static"&&(e.style.position="relative");let r=t.getBoundingClientRect(),s=t.clientHeight,o="data-snap-ph",i=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;i.nextNode();){let u=i.currentNode,a=getComputedStyle(u),l=a.position;if(l!=="sticky"&&l!=="-webkit-sticky")continue;let c=In(a.top),f=In(a.bottom);if(c==null&&f==null)continue;let d=Wo(u,t),m=Uo(e,d,o);if(!m)continue;let y=u.getBoundingClientRect(),p=y.width,h=y.height,g=y.left-r.left;if(!(p>0&&h>0)||!Number.isFinite(g))continue;let w=c!=null?c+n:n+(s-h-f);if(!Number.isFinite(w))continue;let C=Number.parseInt(a.zIndex,10),b=Number.isFinite(C),S=b?Math.max(C,1)+1:2,k=b?C-1:0,A=m.cloneNode(!1);A.setAttribute(o,"1"),A.style.position="sticky",A.style.left=`${g}px`,A.style.top=`${w}px`,A.style.width=`${p}px`,A.style.height=`${h}px`,A.style.visibility="hidden",A.style.zIndex=String(k),A.style.overflow="hidden",A.style.background="transparent",A.style.boxShadow="none",A.style.filter="none",m.parentElement?.insertBefore(A,m),m.style.position="absolute",m.style.left=`${g}px`,m.style.top=`${w}px`,m.style.bottom="auto",m.style.zIndex=String(S),m.style.pointerEvents="none"}}function In(t){if(!t||t==="auto")return null;let e=Number.parseFloat(t);return Number.isFinite(e)?e:null}function Wo(t,e){let n=[];for(let r=t;r&&r!==e;){let s=r.parentElement;if(!s)break;n.push(Array.prototype.indexOf.call(s.children,r)),r=s}return n.reverse()}function Uo(t,e,n){let r=t;for(let s=0;s<e.length;s++)if(r=Oo(r,n)[e[s]],!r)return null;return r instanceof HTMLElement?r:null}function Oo(t,e){let n=[],r=t.children;for(let s=0;s<r.length;s++){let o=r[s];o.hasAttribute(e)||n.push(o)}return n}function Wn(t){let e=getComputedStyle(t),n=e.outlineStyle,r=e.outlineWidth,s=e.borderStyle,o=e.borderWidth,i=n!=="none"&&parseFloat(r)>0,u=s==="none"||parseFloat(o)===0;i&&u&&(t.style.border=`${r} solid transparent`)}function Un(t){let e=[];try{let n=t.querySelectorAll("*");for(let r of n){if(!(r instanceof HTMLElement))continue;let s=r.style.contentVisibility||"",o=getComputedStyle(r),i=o.contentVisibility||o.getPropertyValue("content-visibility")||"";(i==="auto"||i==="hidden")&&(e.push({el:r,original:s}),r.style.contentVisibility="visible")}if(t instanceof HTMLElement){let r=getComputedStyle(t),s=r.contentVisibility||r.getPropertyValue("content-visibility")||"";(s==="auto"||s==="hidden")&&(e.push({el:t,original:t.style.contentVisibility||""}),t.style.contentVisibility="visible")}}catch{}return()=>{for(let{el:n,original:r}of e)try{n.style.contentVisibility=r}catch{}}}async function On(t,e={}){let n={styleMap:x.session.styleMap,styleCache:x.session.styleCache,nodeMap:x.session.nodeMap,options:e},r,s="",o="";Wn(t);let i=Un(t);try{Tn(t)}catch(c){console.warn("inlineExternal defs or symbol failed:",c)}try{r=await _t(t,n,e)}catch(c){throw console.warn("deepClone failed:",c),c}finally{i()}try{await re(t,r,n,e)}catch(c){console.warn("inlinePseudoElements failed:",c)}await un(r,n);try{let c=r.querySelectorAll("style[data-sd]");for(let f of c)o+=f.textContent||"",f.remove()}catch(c){R(n,"Failed to extract shadow CSS from style[data-sd]",c)}let u=ye(n.styleMap);s=Array.from(u.entries()).map(([c,f])=>`.${f}{${c}}`).join(""),s=o+"[data-snapdom-has-after]::after,[data-snapdom-has-before]::before{content:none!important;display:none!important}"+s;for(let[c,f]of n.styleMap.entries()){if(c.tagName==="STYLE")continue;if(c.getRootNode&&c.getRootNode()instanceof ShadowRoot){c.setAttribute("style",f.replace(/;/g,"; "));continue}let d=u.get(f);d&&c.classList.add(d);let m=c.style?.backgroundImage,y=c.dataset?.snapdomHasIcon;m&&m!=="none"&&(c.style.backgroundImage=m),y&&(c.style.verticalAlign="middle",c.style.display="inline")}for(let[c,f]of n.nodeMap.entries()){let d=f.scrollLeft,m=f.scrollTop;if((d||m)&&c instanceof HTMLElement){c.style.overflow="hidden",c.style.scrollbarWidth="none",c.style.msOverflowStyle="none";try{let h=c.querySelectorAll("*");for(let g of h){if(!(g instanceof HTMLElement))continue;let w=g.style.position;if(w==="fixed"||w==="absolute"){let C=parseFloat(g.style.top)||0,b=parseFloat(g.style.left)||0;g.style.top=`${C+m}px`,g.style.left=`${b+d}px`,w==="fixed"&&(g.style.position="absolute")}}}catch{}let p=document.createElement("div");for(p.style.transform=`translate(${-d}px, ${-m}px)`,p.style.willChange="transform",p.style.display="inline-block",p.style.width="100%";c.firstChild;)p.appendChild(c.firstChild);c.appendChild(p)}}let l=r instanceof HTMLElement&&r.firstElementChild instanceof HTMLElement?r.firstElementChild:r;if(_n(t,l),t===n.nodeMap.get(r)){let c=n.styleCache.get(t)||H(t);n.styleCache.set(t,c);let f=ue(c.transform);r.style.margin="0",r.style.top="auto",r.style.left="auto",r.style.right="auto",r.style.bottom="auto",r.style.animation="none",r.style.transition="none",r.style.willChange="auto",r.style.float="none",r.style.clear="none",r.style.transform=f||""}for(let[c,f]of n.nodeMap.entries())f.tagName==="PRE"&&(c.style.marginTop="0",c.style.marginBlockStart="0");return{clone:r,classCSS:s,styleCache:n.styleCache}}pt();var Bn="http://www.w3.org/1999/xlink";function Bo(t){return t.getAttribute("href")||t.getAttribute("xlink:href")||(typeof t.getAttributeNS=="function"?t.getAttributeNS(Bn,"href"):null)}function Do(t){let e=parseInt(t.dataset?.snapdomWidth||"",10)||0,n=parseInt(t.dataset?.snapdomHeight||"",10)||0,r=parseInt(t.getAttribute("width")||"",10)||0,s=parseInt(t.getAttribute("height")||"",10)||0,o=parseFloat(t.style?.width||"")||0,i=parseFloat(t.style?.height||"")||0,u=e||o||r||t.width||t.naturalWidth||100,a=n||i||s||t.height||t.naturalHeight||100;return{width:u,height:a}}async function Dn(t,e={}){let n=Array.from(t.querySelectorAll("img")),r=async i=>{if(!i.getAttribute("src")){let d=i.currentSrc||i.src||"";d&&i.setAttribute("src",d)}i.removeAttribute("srcset"),i.removeAttribute("sizes");let u=i.src||"";if(!u)return;let a=await U(u,{as:"dataURL",useProxy:e.useProxy});if(a.ok&&typeof a.data=="string"&&a.data.startsWith("data:")){i.src=a.data,i.width||(i.width=i.naturalWidth||100),i.height||(i.height=i.naturalHeight||100);return}let{width:l,height:c}=Do(i),{fallbackURL:f}=e||{};if(f)try{let d=typeof f=="function"?await f({width:l,height:c,src:u,element:i}):f;if(d){let m=await U(d,{as:"dataURL",useProxy:e.useProxy});if(m?.ok&&typeof m.data=="string"){i.src=m.data,i.width||(i.width=l),i.height||(i.height=c);return}}}catch{}if(e.placeholders!==!1){let d=document.createElement("div");d.style.cssText=[`width:${l}px`,`height:${c}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${c}px`,"color:#666","font-size:12px","overflow:hidden"].join(";"),d.textContent="img",i.replaceWith(d)}else{let d=document.createElement("div");d.style.cssText=`display:inline-block;width:${l}px;height:${c}px;visibility:hidden;`,i.replaceWith(d)}};for(let i=0;i<n.length;i+=4){let u=n.slice(i,i+4).map(r);await Promise.allSettled(u)}let s=Array.from(t.querySelectorAll("image")),o=async i=>{let u=Bo(i);if(!u||u.startsWith("data:")||u.startsWith("blob:"))return;let a=await U(u,{as:"dataURL",useProxy:e.useProxy});a.ok&&typeof a.data=="string"&&a.data.startsWith("data:")&&(i.setAttribute("href",a.data),i.removeAttribute("xlink:href"),typeof i.removeAttributeNS=="function"&&i.removeAttributeNS(Bn,"href"))};for(let i=0;i<s.length;i+=4){let u=s.slice(i,i+4).map(o);await Promise.allSettled(u)}}Y();async function oe(t,e,n,r={}){let s=[[t,e]],o=["background-image","mask","mask-image","-webkit-mask","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source"],i=["mask-position","mask-size","mask-repeat","-webkit-mask-position","-webkit-mask-size","-webkit-mask-repeat","mask-origin","mask-clip","-webkit-mask-origin","-webkit-mask-clip","-webkit-mask-position-x","-webkit-mask-position-y"],u=["background-position","background-position-x","background-position-y","background-size","background-repeat","background-origin","background-clip","background-attachment","background-blend-mode"],a=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;s.length;){let[l,c]=s.shift();if(!c)continue;let f=n.get(l)||H(l);n.has(l)||n.set(l,f);let d=(()=>{let p=f.getPropertyValue("border-image"),h=f.getPropertyValue("border-image-source");return p&&p!=="none"||h&&h!=="none"})();for(let p of u){let h=f.getPropertyValue(p);h&&c.style.setProperty(p,h)}for(let p of o){let h=f.getPropertyValue(p);if(p==="background-image"&&(!h||h==="none")){let C=f.getPropertyValue("background");C&&/url\s*\(/.test(C)&&(h=St(C).filter(b=>/url\s*\(/.test(b)).join(", ")||h)}if(!h||h==="none")continue;let g=St(h),w=await Promise.all(g.map(C=>ht(C,r)));w.some(C=>C&&C!=="none"&&!/^url\(undefined/.test(C))&&c.style.setProperty(p,w.join(", "))}for(let p of i){let h=f.getPropertyValue(p);!h||h==="initial"||c.style.setProperty(p,h)}if(d)for(let p of a){let h=f.getPropertyValue(p);!h||h==="initial"||c.style.setProperty(p,h)}let m=l.shadowRoot?Array.from(l.shadowRoot.children).filter(p=>p.tagName!=="STYLE"):Array.from(l.children),y=Array.from(c.children).filter(p=>!(p.dataset?.snapdomPseudo||p.tagName==="STYLE"&&p.dataset?.sd));for(let p=0;p<Math.min(m.length,y.length);p++)s.push([m[p],y[p]])}}Y();X();function Hn(t){if(!t)return()=>{};let e=[];function n(r){let s=Ho(r);s&&e.push(s);for(let o of r.children||[])n(o)}return n(t),()=>e.forEach(r=>r())}function Ho(t){if(!t)return()=>{};let e=zo(t);if(e<=0)return()=>{};if(!Vo(t))return()=>{};let n=getComputedStyle(t),r=Math.round(qo(n)*e+jo(n)),s=t.textContent??"",o=s;if(t.scrollHeight<=r+.5)return()=>{};let i=0,u=s.length,a=-1;for(;i<=u;){let l=i+u>>1;t.textContent=s.slice(0,l)+"\u2026",t.scrollHeight<=r+.5?(a=l,i=l+1):u=l-1}return t.textContent=(a>=0?s.slice(0,a):"")+"\u2026",()=>{t.textContent=o}}function zo(t){let e=getComputedStyle(t),n=e.getPropertyValue("-webkit-line-clamp")||e.getPropertyValue("line-clamp");n=(n||"").trim();let r=parseInt(n,10);return Number.isFinite(r)&&r>0?r:0}function qo(t){let e=(t.lineHeight||"").trim(),n=parseFloat(t.fontSize)||16;return!e||e==="normal"?Math.round(n*1.2):e.endsWith("px")?parseFloat(e):/^\d+(\.\d+)?$/.test(e)?Math.round(parseFloat(e)*n):e.endsWith("%")?Math.round(parseFloat(e)/100*n):Math.round(n*1.2)}function jo(t){return(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)}function Vo(t){return t.childElementCount>0?!1:Array.from(t.childNodes).some(e=>e.nodeType===Node.TEXT_NODE)}var Mt=[];function ie(t){if(!t)return null;if(Array.isArray(t)){let[e,n]=t;return typeof e=="function"?e(n):e}if(typeof t=="object"&&"plugin"in t){let{plugin:e,options:n}=t;return typeof e=="function"?e(n):e}return typeof t=="function"?t():t}function zn(...t){let e=t.flat();for(let n of e){let r=ie(n);r&&(Mt.some(s=>s&&s.name&&r.name&&s.name===r.name)||Mt.push(r))}}function qn(t){return(t&&Array.isArray(t.plugins)?t.plugins:Mt)||Mt}async function J(t,e,n){let r=n,s=qn(e);for(let o of s){let i=o&&typeof o[t]=="function"?o[t]:null;if(!i)continue;let u=await i(e,r);typeof u<"u"&&(r=u)}return r}async function jn(t,e,n){let r=[],s=qn(e);for(let o of s){let i=o&&typeof o[t]=="function"?o[t]:null;if(!i)continue;let u=await i(e,n);typeof u<"u"&&r.push(u)}return r}function Xo(t){let e=[];if(Array.isArray(t))for(let n of t){let r=ie(n);if(!r||!r.name)continue;let s=e.findIndex(o=>o&&o.name===r.name);s>=0&&e.splice(s,1),e.push(r)}for(let n of Mt)n&&n.name&&!e.some(r=>r.name===n.name)&&e.push(n);return Object.freeze(e)}function Vn(t,e,n=!1){return!t||t.plugins&&!n||(t.plugins=Xo(e)),t}function Xn(){return Mt.slice()}function gt(t){return!!(!t||t.startsWith("data:")||t.startsWith("blob:")||/^data:image\/(gif|png|svg)/.test(t)&&t.length<200)}function Go(t,e){return!t||!(t instanceof Element)?!1:t.querySelector("picture")?!0:e?!!t.querySelector("img[data-src], img[data-lazy-src], img[data-original], img[data-hi-res-src], img[data-srcset], img[data-lazy-srcset]"):!1}function Yo(t,e){let n=t.currentSrc||"";if(n&&!gt(n))return n;let r=e.querySelectorAll("source[srcset]"),s=null;for(let o of r){let i=o.getAttribute("srcset");if(!i||gt(i))continue;let u=o.getAttribute("media");if(u)try{if(window.matchMedia(u).matches)return i.split(",")[0].trim().split(/\s+/)[0]}catch{}s||(s=i.split(",")[0].trim().split(/\s+/)[0])}return s}function Ko(t){let e=[t.getAttribute("data-src"),t.getAttribute("data-lazy-src"),t.getAttribute("data-original"),t.getAttribute("data-hi-res-src")];for(let r of e)if(r&&!gt(r))return r;let n=t.getAttribute("data-srcset")||t.getAttribute("data-lazy-srcset");if(n){let r=n.split(",")[0].trim().split(/\s+/)[0];if(r&&!gt(r))return r}return null}function Qo(t={}){let e=t.pictureResolver&&typeof t.pictureResolver=="object"?t.pictureResolver:{};return{timeout:e.timeout??5e3,concurrency:e.concurrency??4,resolveLazySrc:e.resolveLazySrc!==!1,silent:e.silent??!1,useProxy:typeof t.useProxy=="string"?t.useProxy:""}}async function Gn(t,e={}){if(!t||!(t instanceof Element)||e.resolvePicturePlaceholders===!1)return null;let{timeout:n,concurrency:r,resolveLazySrc:s,silent:o,useProxy:i}=Qo(e);if(!Go(t,s))return null;let u=[],a=[];async function l(d){let m=new AbortController,y=setTimeout(()=>m.abort(),n);try{let p=await fetch(d,{credentials:"include",signal:m.signal});if(!p.ok&&i){let g=i.includes("{url}")?i.replace("{url}",encodeURIComponent(d)):i.endsWith("?")?`${i}${encodeURIComponent(d)}`:`${i}${i.includes("?")?"&":"?"}url=${encodeURIComponent(d)}`;p=await fetch(g,{signal:m.signal})}if(!p.ok)return null;let h=await p.blob();return await new Promise((g,w)=>{let C=new FileReader;C.onload=()=>g(C.result),C.onerror=w,C.readAsDataURL(h)})}catch{return null}finally{clearTimeout(y)}}async function c(d){for(let m=0;m<d.length;m+=r){let y=d.slice(m,m+r);await Promise.allSettled(y.map(p=>p()))}}let f=t.querySelectorAll("picture");for(let d of f){let m=d.querySelector("img");if(!m)continue;let y=m.getAttribute("src")||"";if(!gt(y))continue;let p=Yo(m,d);p&&a.push(async()=>{let h=await l(p);if(!h){o||console.warn(`[snapdom:picture-resolver] Failed to fetch: ${p.slice(0,60)}`);return}let g=m.getAttribute("src"),w=m.getAttribute("srcset"),C=m.getAttribute("sizes"),b=[];m.src=h,m.setAttribute("src",h),m.removeAttribute("srcset"),m.removeAttribute("sizes");let S=d.querySelectorAll("source");for(let k of S)b.push({el:k,parent:k.parentElement,next:k.nextSibling}),k.remove();u.push(()=>{g!==null?m.setAttribute("src",g):m.removeAttribute("src"),w!==null&&m.setAttribute("srcset",w),C!==null&&m.setAttribute("sizes",C);for(let{el:k,parent:A,next:v}of b)A&&A.insertBefore(k,v)})})}if(s){let d=t.querySelectorAll("img");for(let m of d){if(m.closest("picture")&>(m.getAttribute("src")||""))continue;let y=m.getAttribute("src")||"",p=Ko(m);p&>(y)&&a.push(async()=>{let h=await l(p);if(!h)return;let g=m.getAttribute("src");m.src=h,m.setAttribute("src",h),m.removeAttribute("srcset"),m.removeAttribute("sizes"),u.push(()=>{g!==null?m.setAttribute("src",g):m.removeAttribute("src")})})}}return a.length===0?null:(await c(a),async function(){for(let m of u)try{m()}catch{}})}Y();function Yn(t,e,n={}){if(!t||!e||!e.style)return;let r=getComputedStyle(t);try{e.style.boxShadow="none"}catch(i){R(n,"stripRootShadows boxShadow",i)}try{e.style.textShadow="none"}catch(i){R(n,"stripRootShadows textShadow",i)}try{e.style.outline="none"}catch(i){R(n,"stripRootShadows outline",i)}let o=(r.filter||"").replace(/\bblur\([^()]*\)\s*/gi,"").replace(/\bdrop-shadow\([^()]*\)\s*/gi,"").trim().replace(/\s+/g," ");try{e.style.filter=o.length?o:"none"}catch(i){R(n,"stripRootShadows filter",i)}}function Jo(t){let e=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT),n=[];for(;e.nextNode();)n.push(e.currentNode);for(let r of n)r.remove()}function Zo(t,e={}){let{stripFrameworkDirectives:n=!0}=e,r=new Set(["xml","xlink"]),s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;s.nextNode();){let o=s.currentNode;for(let i of Array.from(o.attributes)){let u=i.name;if(u.includes("@")){o.removeAttribute(u);continue}if(u.includes(":")){let a=u.split(":",1)[0];if(!r.has(a)){o.removeAttribute(u);continue}}if(n&&(u.startsWith("x-")||u.startsWith("v-")||u.startsWith(":")||u.startsWith("on:")||u.startsWith("bind:")||u.startsWith("let:")||u.startsWith("class:"))){o.removeAttribute(u);continue}}}}function Kn(t,e={}){t&&(Zo(t,e),Jo(t))}function ti(t){try{let e=t.getAttribute?.("style")||"";return/\b(height|width|block-size|inline-size)\s*:/.test(e)}catch{return!1}}function ei(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof HTMLIFrameElement||t instanceof SVGElement||t instanceof HTMLObjectElement||t instanceof HTMLEmbedElement}function ni(t,e){if(!(t instanceof Element)||ti(t)||ei(t))return!1;let n=e.position;if(n==="absolute"||n==="fixed"||n==="sticky")return!1;let r=e.display||"";return!(r.includes("flex")||r.includes("grid")||r.startsWith("table")||e.transform&&e.transform!=="none")}function Qn(t,e,n=new Map){function r(s,o){if(!(s instanceof Element)||!(o instanceof Element))return;let i=s.childElementCount>o.childElementCount,u=n.get(s)||getComputedStyle(s);if(n.has(s)||n.set(s,u),i&&ni(s,u)){o.style.height||(o.style.height="auto"),o.style.width||(o.style.width="auto"),o.style.removeProperty("block-size"),o.style.removeProperty("inline-size"),o.style.minHeight||(o.style.minHeight="0"),o.style.minWidth||(o.style.minWidth="0"),o.style.maxHeight||(o.style.maxHeight="none"),o.style.maxWidth||(o.style.maxWidth="none");let c=u.overflowY||u.overflowBlock||"visible",f=u.overflowX||u.overflowInline||"visible";(c!=="visible"||f!=="visible")&&(o.style.overflow="visible")}let a=Array.from(s.children),l=Array.from(o.children);for(let c=0;c<Math.min(a.length,l.length);c++)r(a[c],l[c])}r(t,e)}function ri(t){let e=getComputedStyle(t);return!(e.display==="none"||e.position==="absolute"||e.position==="fixed")}function oi(t,e){if(!(t instanceof Element))return!1;if(t.getAttribute("data-capture")==="exclude"&&e?.excludeMode==="remove")return!0;if(Array.isArray(e?.exclude))for(let n of e.exclude)try{if(t.matches(n))return e.excludeMode==="remove"}catch(r){R(e,"exclude selector match failed",r)}return!1}function Jn(t,e){let n=getComputedStyle(t),r=t.getBoundingClientRect(),s=1/0,o=-1/0,i=!1,u=Array.from(t.children);for(let m of u){if(oi(m,e)||!ri(m))continue;let y=m.getBoundingClientRect(),p=y.top-r.top,h=y.bottom-r.top;h<=p||(p<s&&(s=p),h>o&&(o=h),i=!0)}let a=i?Math.max(0,o-s):0,l=parseFloat(n.borderTopWidth)||0,c=parseFloat(n.borderBottomWidth)||0,f=parseFloat(n.paddingTop)||0,d=parseFloat(n.paddingBottom)||0;return l+c+f+d+a}var M=(t,e=3)=>Number.isFinite(t)?Math.round(t*10**e)/10**e:t,ii=/::-webkit-scrollbar(-[a-z]+)?\b/i;function $e(t,e=new Set){let n="";if(!t)return n;for(let r=0;r<t.length;r++){let s=t[r];try{if(s.type===CSSRule.IMPORT_RULE&&s.styleSheet){n+=$e(s.styleSheet.cssRules,e);continue}if(s.type===CSSRule.MEDIA_RULE&&s.cssRules){let o=$e(s.cssRules,e);o&&(n+=`@media ${s.conditionText}{${o}}`);continue}if(s.type===CSSRule.STYLE_RULE){let o=s.selectorText||"";if(ii.test(o)){let i=s.cssText;i&&!e.has(i)&&(e.add(i),n+=i)}}}catch{}}return n}function Zn(t){if(!t||!t.styleSheets)return"";let e=new Set,n="";for(let r of Array.from(t.styleSheets))try{let s=r.cssRules;s&&(n+=$e(s,e))}catch{}return n}function tr(t){let e=t.boxShadow||"";if(!e||e==="none")return{top:0,right:0,bottom:0,left:0};let n=e.split(/\),(?=(?:[^()]*\([^()]*\))*[^()]*$)/).map(u=>u.trim()),r=0,s=0,o=0,i=0;for(let u of n){let a=u.match(/-?\d+(\.\d+)?px/g)?.map(p=>parseFloat(p))||[];if(a.length<2)continue;let[l,c,f=0,d=0]=a,m=Math.abs(l)+f+d,y=Math.abs(c)+f+d;s=Math.max(s,m+Math.max(l,0)),i=Math.max(i,m+Math.max(-l,0)),o=Math.max(o,y+Math.max(c,0)),r=Math.max(r,y+Math.max(-c,0))}return{top:Math.ceil(r),right:Math.ceil(s),bottom:Math.ceil(o),left:Math.ceil(i)}}function er(t){let e=(t.filter||"").match(/blur\(\s*([0-9.]+)px\s*\)/),n=e?Math.ceil(parseFloat(e[1])||0):0;return{top:n,right:n,bottom:n,left:n}}function nr(t){if((t.outlineStyle||"none")==="none")return{top:0,right:0,bottom:0,left:0};let e=Math.ceil(parseFloat(t.outlineWidth||"0")||0),n=parseFloat(t.outlineOffset||"0")||0,r=e+Math.max(0,Math.ceil(n));return{top:r,right:r,bottom:r,left:r}}function rr(t){let e=`${t.filter||""} ${t.webkitFilter||""}`.trim();if(!e||e==="none")return{bleed:{top:0,right:0,bottom:0,left:0},has:!1};let n=e.match(/drop-shadow\((?:[^()]|\([^()]*\))*\)/gi)||[],r=0,s=0,o=0,i=0,u=!1;for(let a of n){u=!0;let l=a.match(/-?\d+(?:\.\d+)?px/gi)?.map(p=>parseFloat(p))||[],[c=0,f=0,d=0]=l,m=Math.abs(c)+d,y=Math.abs(f)+d;s=Math.max(s,m+Math.max(c,0)),i=Math.max(i,m+Math.max(-c,0)),o=Math.max(o,y+Math.max(f,0)),r=Math.max(r,y+Math.max(-f,0))}return{bleed:{top:M(r),right:M(s),bottom:M(o),left:M(i)},has:u}}function or(t,e){if(!t||!e||!e.style)return null;let n=getComputedStyle(t);try{e.style.transformOrigin="0 0"}catch{}try{"translate"in e.style&&(e.style.translate="none"),"rotate"in e.style&&(e.style.rotate="none")}catch{}let r=n.transform||"none";if(!r||r==="none")try{let u=lr(t);if(u.a===1&&u.b===0&&u.c===0&&u.d===1)return e.style.transform="none",{a:1,b:0,c:0,d:1}}catch{}function s(u,a,l,c){let f=Math.sqrt(u*u+a*a)||0,d=0,m=0;if(f>0){let y=u/f,p=a/f;d=y*l+p*c;let h=l-y*d,g=c-p*d;m=Math.sqrt(h*h+g*g)||0,m>0?d=d/m:d=0}return{a:f,b:0,c:d*m,d:m}}let o=r.match(/^matrix\(\s*([^)]+)\)$/i);if(o){let u=o[1].split(",").map(a=>parseFloat(a.trim()));if(u.length===6&&u.every(Number.isFinite)){let[a,l,c,f]=u,d=s(a,l,c,f);try{e.style.transform=`matrix(${d.a}, ${d.b}, ${d.c}, ${d.d}, 0, 0)`}catch{}return d}}let i=r.match(/^matrix3d\(\s*([^)]+)\)$/i);if(i){let u=i[1].split(",").map(a=>parseFloat(a.trim()));if(u.length===16&&u.every(Number.isFinite)){let a=u[0],l=u[1],c=u[4],f=u[5],d=s(a,l,c,f);try{e.style.transform=`matrix(${d.a}, ${d.b}, ${d.c}, ${d.d}, 0, 0)`}catch{}return d}}try{let u=new DOMMatrix(r),a=s(u.a,u.b,u.c,u.d);try{e.style.transform=`matrix(${a.a}, ${a.b}, ${a.c}, ${a.d}, 0, 0)`}catch{}return a}catch{return null}}function Le(t,e,n,r,s){let o=n.a,i=n.b,u=n.c,a=n.d,l=n.e||0,c=n.f||0;function f(g,w){let C=g-r,b=w-s,S=o*C+u*b,k=i*C+a*b;return S+=r+l,k+=s+c,[S,k]}let d=[f(0,0),f(t,0),f(0,e),f(t,e)],m=1/0,y=1/0,p=-1/0,h=-1/0;for(let[g,w]of d)g<m&&(m=g),w<y&&(y=w),g>p&&(p=g),w>h&&(h=w);return{minX:m,minY:y,maxX:p,maxY:h,width:p-m,height:h-y}}function ir(t,e,n){let r=(t.transformOrigin||"0 0").trim().split(/\s+/),[s,o]=[r[0]||"0",r[1]||"0"],i=(u,a)=>{let l=u.toLowerCase();return l==="left"||l==="top"?0:l==="center"?a/2:l==="right"||l==="bottom"?a:l.endsWith("px")?parseFloat(l)||0:l.endsWith("%")?(parseFloat(l)||0)*a/100:/^-?\d+(\.\d+)?$/.test(l)&&parseFloat(l)||0};return{ox:i(s,e),oy:i(o,n)}}function sr(t){let e={rotate:"0deg",scale:null,translate:null},n=typeof t.computedStyleMap=="function"?t.computedStyleMap():null;if(n){let s=a=>{try{return typeof n.has=="function"&&!n.has(a)||typeof n.get!="function"?null:n.get(a)}catch{return null}},o=s("rotate");if(o)if(o.angle){let a=o.angle;e.rotate=a.unit==="rad"?a.value*180/Math.PI+"deg":a.value+a.unit}else o.unit?e.rotate=o.unit==="rad"?o.value*180/Math.PI+"deg":o.value+o.unit:e.rotate=String(o);else{let a=getComputedStyle(t);e.rotate=a.rotate&&a.rotate!=="none"?a.rotate:"0deg"}let i=s("scale");if(i){let a="x"in i&&i.x?.value!=null?i.x.value:Array.isArray(i)?i[0]?.value:Number(i)||1,l="y"in i&&i.y?.value!=null?i.y.value:Array.isArray(i)?i[1]?.value:a;e.scale=`${a} ${l}`}else{let a=getComputedStyle(t);e.scale=a.scale&&a.scale!=="none"?a.scale:null}let u=s("translate");if(u){let a="x"in u&&"value"in u.x?u.x.value:Array.isArray(u)?u[0]?.value:0,l="y"in u&&"value"in u.y?u.y.value:Array.isArray(u)?u[1]?.value:0,c="x"in u&&u.x?.unit?u.x.unit:"px",f="y"in u&&u.y?.unit?u.y.unit:"px";e.translate=`${a}${c} ${l}${f}`}else{let a=getComputedStyle(t);e.translate=a.translate&&a.translate!=="none"?a.translate:null}return e}let r=getComputedStyle(t);return e.rotate=r.rotate&&r.rotate!=="none"?r.rotate:"0deg",e.scale=r.scale&&r.scale!=="none"?r.scale:null,e.translate=r.translate&&r.translate!=="none"?r.translate:null,e}var Re=null;function si(){if(Re)return Re;let t=document.createElement("div");return t.id="snapdom-measure-slot",t.setAttribute("aria-hidden","true"),Object.assign(t.style,{position:"absolute",left:"-99999px",top:"0px",width:"0px",height:"0px",overflow:"hidden",opacity:"0",pointerEvents:"none",contain:"size layout style"}),document.documentElement.appendChild(t),Re=t,t}function ar(t){let e=si(),n=document.createElement("div");n.style.transformOrigin="0 0",t.baseTransform&&(n.style.transform=t.baseTransform),t.rotate&&(n.style.rotate=t.rotate),t.scale&&(n.style.scale=t.scale),t.translate&&(n.style.translate=t.translate),e.appendChild(n);let r=lr(n);return e.removeChild(n),r}function cr(t){let e=getComputedStyle(t),n=e.transform||"none";if(n!=="none"&&!/^matrix\(\s*1\s*,\s*0\s*,\s*0\s*,\s*1\s*,\s*0\s*,\s*0\s*\)$/i.test(n))return!0;let s=e.rotate&&e.rotate!=="none"&&e.rotate!=="0deg",o=e.scale&&e.scale!=="none"&&e.scale!=="1",i=e.translate&&e.translate!=="none"&&e.translate!=="0px 0px";return!!(s||o||i)}function lr(t){let e=getComputedStyle(t).transform;if(!e||e==="none")return new DOMMatrix;try{return new DOMMatrix(e)}catch{return new WebKitCSSMatrix(e)}}function ai(t){if(Array.isArray(t.plugins)){for(let e of t.plugins)if(ie(e)?.name==="picture-resolver")return!0}return Xn().some(e=>e?.name==="picture-resolver")}async function Pe(t,e){if(!t)throw new Error("Element cannot be null or undefined");jt(e.cache);let n=e.fast,r=e.outerTransforms!==!1,s=!!e.outerShadows,o={element:t,options:e,plugins:e.plugins},i,u,a,l="",c="",f,d,m=null;await J("beforeSnap",o);let y=null;e.resolvePicturePlaceholders!==!1&&!ai(e)&&(y=await Gn(o.element,o.options)),await J("beforeClone",o);let p=Hn(o.element);try{({clone:i,classCSS:u,styleCache:a}=await On(o.element,o.options)),!r&&i&&(m=or(o.element,i)),!s&&i&&Yn(o.element,i,o.options)}finally{p()}if(o={clone:i,classCSS:u,styleCache:a,...o},await J("afterClone",o),y&&await y(),Kn(o.clone),o.options?.excludeMode==="remove")try{Qn(o.element,o.clone,o.styleCache)}catch(b){console.warn("[snapdom] shrink pass failed:",b)}try{await mn(o.clone,o.element)}catch{}await new Promise(b=>{ot(async()=>{await Dn(o.clone,o.options),b()},{fast:n})}),await new Promise(b=>{ot(async()=>{await oe(o.element,o.clone,o.styleCache,o.options),b()},{fast:n})}),e.embedFonts&&await new Promise(b=>{ot(async()=>{let S=At(o.element),k=ne(o.element);if(z()){let A=new Set(Array.from(S).map(v=>String(v).split("__")[0]).filter(Boolean));await kt(A,1)}l=await ee({required:S,usedCodepoints:k,preCached:!1,exclude:o.options.excludeFonts,useProxy:o.options.useProxy,fontStylesheetDomains:o.options.fontStylesheetDomains}),b()},{fast:n})});let h=he(o.clone).sort(),g=h.join(",");x.baseStyle.has(g)?c=x.baseStyle.get(g):await new Promise(b=>{ot(()=>{c=ge(h),x.baseStyle.set(g,c),b()},{fast:n})});let w=Zn(o.element?.ownerDocument||document);o={fontsCSS:l,baseCSS:c,scrollbarCSS:w,...o},await J("beforeRender",o),await new Promise(b=>{ot(()=>{let S=H(o.element),k=o.element.getBoundingClientRect(),A=Math.max(1,M(o.element.offsetWidth||parseFloat(S.width)||k.width||1)),v=Math.max(1,M(o.element.offsetHeight||parseFloat(S.height)||k.height||1)),E=o.element.ownerDocument||document;if(o.element===E.body||o.element===E.documentElement){let q=Math.max(o.element.scrollHeight||0,E.documentElement?.scrollHeight||0,E.body?.scrollHeight||0),V=Math.max(o.element.scrollWidth||0,E.documentElement?.scrollWidth||0,E.body?.scrollWidth||0);q>0&&(v=Math.max(v,M(q))),V>0&&(A=Math.max(A,M(V)));try{let nt=(o.scrollbarCSS||"").length+(o.baseCSS||"").length+(o.fontsCSS||"").length+(o.classCSS||"").length,G=x.measureHints.get(o.element);if(G&&G.cssLen===nt&&G.w0===A)G.csh>0&&(v=Math.max(v,M(G.csh))),G.csw>0&&(A=Math.max(A,M(G.csw)));else{let rt=E.createElement("div");rt.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;width:"+A+"px!important;overflow:visible!important;visibility:hidden!important;";let qt=E.createElement("style");qt.textContent=(o.scrollbarCSS||"")+o.baseCSS+o.fontsCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+o.classCSS,rt.appendChild(qt),rt.appendChild(o.clone.cloneNode(!0)),E.body.appendChild(rt);let Ft=rt.scrollHeight,lt=rt.scrollWidth;E.body.removeChild(rt),x.measureHints.set(o.element,{cssLen:nt,w0:A,csh:Ft,csw:lt}),Ft>0&&(v=Math.max(v,M(Ft))),lt>0&&(A=Math.max(A,M(lt)))}}catch{}}if(o.options?.excludeMode==="remove"){let q=Jn(o.element,o.options);Number.isFinite(q)&&q>0&&(v=Math.max(1,Math.min(v,M(q+1))))}let I=(q,V=NaN)=>{let nt=typeof q=="string"?parseFloat(q):q;return Number.isFinite(nt)?nt:V},L=I(o.options.width),_=I(o.options.height),B=A,F=v,ft=Number.isFinite(L),dt=Number.isFinite(_),ae=v>0?A/v:1;ft&&dt?(B=Math.max(1,M(L)),F=Math.max(1,M(_))):ft?(B=Math.max(1,M(L)),F=Math.max(1,M(B/(ae||1)))):dt?(F=Math.max(1,M(_)),B=Math.max(1,M(F*(ae||1)))):(B=A,F=v);let st=0,$=0,T=A,W=v;if(!r&&m&&Number.isFinite(m.a)){let q={a:m.a,b:m.b||0,c:m.c||0,d:m.d||1,e:0,f:0},V=Le(A,v,q,0,0);st=M(V.minX),$=M(V.minY),T=M(V.maxX),W=M(V.maxY)}else if(r&&ur(o.element)){let V=S.transform&&S.transform!=="none"?S.transform:"",nt=sr(o.element),G=ar({baseTransform:V,rotate:nt.rotate||"0deg",scale:nt.scale,translate:nt.translate}),{ox:rt,oy:qt}=ir(S,A,v),Ft=G.is2D?G:new DOMMatrix(G.toString()),lt=Le(A,v,Ft,rt,qt);st=M(lt.minX),$=M(lt.minY),T=M(lt.maxX),W=M(lt.maxY)}let D=tr(S),Z=er(S),tt=nr(S),bt=rr(S),et=s?{top:M(D.top+Z.top+tt.top+bt.bleed.top),right:M(D.right+Z.right+tt.right+bt.bleed.right),bottom:M(D.bottom+Z.bottom+tt.bottom+bt.bleed.bottom),left:M(D.left+Z.left+tt.left+bt.bleed.left)}:{top:0,right:0,bottom:0,left:0};st=M(st-et.left),$=M($-et.top),T=M(T+et.right),W=M(W+et.bottom);let Ot=Math.max(1,M(T-st)),Bt=Math.max(1,M(W-$)),Dt=ft||dt?M(B/A):1,Ht=dt||ft?M(F/v):1,Sr=Math.max(1,M(Ot*Dt)),xr=Math.max(1,M(Bt*Ht)),Ue="http://www.w3.org/2000/svg",Cr=z()&&ur(o.element)?1:0,at=M(Cr+(r?0:1)),ct=document.createElementNS(Ue,"foreignObject"),Ar=M(st),kr=M($);ct.setAttribute("x",String(M(-(Ar-at)))),ct.setAttribute("y",String(M(-(kr-at)))),ct.setAttribute("width",String(M(A+at*2))),ct.setAttribute("height",String(M(v+at*2))),ct.style.overflow="visible";let Oe=document.createElement("style"),vr='svg{overflow:visible;} foreignObject{overflow:visible;} foreignObject *{min-width:0;} foreignObject pre,foreignObject [style*="white-space"]{white-space:inherit;}';Oe.textContent=(o.scrollbarCSS||"")+o.baseCSS+o.fontsCSS+vr+o.classCSS,ct.appendChild(Oe);let zt=document.createElement("div");zt.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),zt.style.cssText=`all:initial;box-sizing:border-box;display:block;overflow:visible;width:${M(A)}px;height:${M(v)}px`,zt.appendChild(o.clone),ct.appendChild(zt);let Er=new XMLSerializer().serializeToString(ct),ce=M(Ot+at*2),le=M(Bt+at*2),Be=ft||dt;e.meta={w0:A,h0:v,vbW:ce,vbH:le,targetW:B,targetH:F};let Mr=z()&&Be?ce:M(Sr+at*2),Fr=z()&&Be?le:M(xr+at*2),$r=parseFloat(H(E.documentElement)?.fontSize)||16;d=`<svg xmlns="${Ue}" width="${Mr}" height="${Fr}" viewBox="0 0 ${ce} ${le}" font-size="${$r}px">`+Er+"</svg>",f=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(d)}`,o={svgString:d,dataURL:f,...o},b()},{fast:n})}),await J("afterRender",o);let C=document.getElementById("snapdom-sandbox");return C&&C.style.position==="absolute"&&C.remove(),o.dataURL}function ur(t){return cr(t)}X();function fr(t={}){let e=t.format??"png";e==="jpg"&&(e="jpeg");let n=De(t.cache);return{debug:t.debug??!1,fast:t.fast??!0,scale:t.scale??1,exclude:t.exclude??[],excludeMode:t.excludeMode??"hide",filter:t.filter??null,filterMode:t.filterMode??"hide",placeholders:t.placeholders!==!1,embedFonts:t.embedFonts??!1,iconFonts:Array.isArray(t.iconFonts)?t.iconFonts:t.iconFonts?[t.iconFonts]:[],localFonts:Array.isArray(t.localFonts)?t.localFonts:[],excludeFonts:t.excludeFonts??void 0,fontStylesheetDomains:Array.isArray(t.fontStylesheetDomains)?t.fontStylesheetDomains:[],fallbackURL:t.fallbackURL??void 0,cache:n,useProxy:typeof t.useProxy=="string"?t.useProxy:"",width:t.width??null,height:t.height??null,format:e,type:t.type??"svg",quality:t.quality??.92,dpr:t.dpr??(window.devicePixelRatio||1),backgroundColor:t.backgroundColor??(["jpeg","webp"].includes(e)?"#ffffff":null),filename:t.filename??"snapDOM",outerTransforms:t.outerTransforms??!0,outerShadows:t.outerShadows??!1,safariWarmupAttempts:Math.min(3,Math.max(1,(t.safariWarmupAttempts??3)|0)),excludeStyleProps:t.excludeStyleProps??null,resolvePicturePlaceholders:t.resolvePicturePlaceholders!==!1,pictureResolver:t.pictureResolver&&typeof t.pictureResolver=="object"?t.pictureResolver:{}}}xt();Se();Y();pt();X();async function ci(t=document,e={}){let{embedFonts:n=!0,useProxy:r=""}=e,s=e.cache??e.cacheOpt??"full";jt(s);try{await document.fonts?.ready}catch{}try{me()}catch{}x.session=x.session||{},x.session.styleCache||(x.session.styleCache=new WeakMap),x.image=x.image||new O(100),x.background=x.background||new O(100);try{await oe(t,void 0,x.session.styleCache,{useProxy:r})}catch{}let o=[],i=[];try{if(t&&t.nodeType===1){let a=t.querySelectorAll?Array.from(t.querySelectorAll("*")):[];i=[t,...a],o=[],t.tagName==="IMG"&&t.getAttribute("src")&&o.push(t),o.push(...Array.from(t.querySelectorAll?.("img[src]")||[]))}else t?.querySelectorAll&&(o=Array.from(t.querySelectorAll("img[src]")),i=Array.from(t.querySelectorAll("*")))}catch{}let u=[];for(let a of o){let l=a?.currentSrc||a?.src;if(l&&!x.image.has(l)){let c=Promise.resolve().then(async()=>{let f=await U(l,{as:"dataURL",useProxy:r});f?.ok&&typeof f.data=="string"&&x.image.set(l,f.data)}).catch(()=>{});u.push(c)}}for(let a of i){let l="";try{l=a?.style?.backgroundImage||"",(!l||l==="none")&&(l=H(a).backgroundImage)}catch{}if(l&&l!=="none"){let c=l.match(/url\((?:[^()"']+|"(?:[^"]*)"|'(?:[^']*)')\)/gi)||[];for(let f of c){let d=Promise.resolve().then(()=>ht(f,{...e,useProxy:r})).catch(()=>{});u.push(d)}}}if(n)try{let a=At(t),l=ne(t);if(typeof z=="function"?z():!!z){let f=new Set(Array.from(a).map(d=>String(d).split("__")[0]).filter(Boolean));await kt(f,3)}await ee({required:a,usedCodepoints:l,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??r,fontStylesheetDomains:e.fontStylesheetDomains})}catch{}await Promise.allSettled(u)}function wi(...t){return zn(...t),N}var N=Object.assign(xi,{plugins:wi}),wr=Symbol("snapdom.internal"),Si=Symbol("snapdom.internal.silent"),br=!1;async function xi(t,e){if(!t)throw new Error("Element cannot be null or undefined");let n=fr(e);if(Vn(n,e&&e.plugins),z()&&(n.embedFonts===!0||Ai(t))){if(n.embedFonts)try{let s=At(t),o=new Set([...s].map(i=>String(i).split("__")[0]).filter(Boolean));await kt(o,1)}catch{}let r=n.safariWarmupAttempts??3;for(let s=0;s<r;s++)try{await Ci(t,e)}catch{}}return n.iconFonts&&n.iconFonts.length>0&&dn(n.iconFonts),n.snap||(n.snap={toPng:(r,s)=>N.toPng(r,s),toSvg:(r,s)=>N.toSvg(r,s)}),N.capture(t,n,wr)}N.capture=async(t,e,n)=>{if(n!==wr)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");let r=await Pe(t,e),s={img:async(p,h)=>{let{toImg:g}=await Promise.resolve().then(()=>(Ie(),Te));return g(r,{...p,...h||{}})},svg:async(p,h)=>{let{toSvg:g}=await Promise.resolve().then(()=>(Ie(),Te));return g(r,{...p,...h||{}})},canvas:async(p,h)=>{let{toCanvas:g}=await Promise.resolve().then(()=>(Wt(),mr));return g(r,{...p,...h||{}})},blob:async(p,h)=>{let{toBlob:g}=await Promise.resolve().then(()=>(We(),pr));return g(r,{...p,...h||{}})},png:async(p,h)=>{let{rasterize:g}=await Promise.resolve().then(()=>(Ut(),se));return g(r,{...p,...h||{},format:"png"})},jpeg:async(p,h)=>{let{rasterize:g}=await Promise.resolve().then(()=>(Ut(),se));return g(r,{...p,...h||{},format:"jpeg"})},webp:async(p,h)=>{let{rasterize:g}=await Promise.resolve().then(()=>(Ut(),se));return g(r,{...p,...h||{},format:"webp"})},download:async(p,h)=>{let{download:g}=await Promise.resolve().then(()=>(yr(),gr));return g(r,{...p,...h||{}})}},o={};for(let p of["img","svg","canvas","blob","png","jpeg","webp"])o[p]=async h=>s[p](e,{...h||{},[Si]:!0});o.jpg=o.jpeg;let i={...e,export:{url:r},exports:o},u=await jn("defineExports",i),a=Object.assign({},...u.filter(p=>p&&typeof p=="object")),l={...s,...a};l.jpeg&&!l.jpg&&(l.jpg=(p,h)=>l.jpeg(p,h));function c(p,h){let g={...e,...h||{}};return(p==="jpeg"||p==="jpg")&&(g.backgroundColor==null||g.backgroundColor==="transparent")&&(g.backgroundColor="#ffffff"),g}let f=!1,d=Promise.resolve();async function m(p,h){let g=async()=>{let w=l[p];if(!w)throw new Error(`[snapdom] Unknown export type: ${p}`);let C=c(p,h),b={...e,export:{type:p,options:C,url:r}};await J("beforeExport",b);let S=await w(b,C);return await J("afterExport",b,S),f||(f=!0,await J("afterSnap",e)),S};return d=d.then(g)}let y={url:r,toRaw:()=>r,to:(p,h)=>m(p,h),toImg:p=>m("img",p),toSvg:p=>m("svg",p),toCanvas:p=>m("canvas",p),toBlob:p=>m("blob",p),toPng:p=>m("png",p),toJpg:p=>m("jpg",p),toWebp:p=>m("webp",p),download:p=>m("download",p)};for(let p of Object.keys(l)){let h="to"+p.charAt(0).toUpperCase()+p.slice(1);y[h]||(y[h]=g=>m(p,g))}return y};N.toRaw=(t,e)=>N(t,e).then(n=>n.toRaw());N.toImg=(t,e)=>N(t,e).then(n=>n.toImg());N.toSvg=(t,e)=>N(t,e).then(n=>n.toSvg());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 Ci(t,e){if(br)return;let n={...e,fast:!0,embedFonts:!0,scale:.2},r;try{r=await Pe(t,n)}catch(s){R(e,"safariWarmup pre-capture failed",s)}await new Promise(s=>requestAnimationFrame(()=>requestAnimationFrame(s))),r&&await new Promise(s=>{let o=new Image;try{o.decoding="sync",o.loading="eager"}catch(i){R(e,"safariWarmup img hints failed",i)}o.style.cssText="position:fixed;left:0px;top:0px;width:10px;height:10px;opacity:0.01;pointer-events:none;",o.src=r,document.body.appendChild(o),(async()=>{try{typeof o.decode=="function"&&await o.decode()}catch(u){R(e,"safariWarmup img.decode failed",u)}let i=performance.now();for(;!(o.complete&&o.naturalWidth>0)&&performance.now()-i<900;)await new Promise(u=>setTimeout(u,200));await new Promise(u=>requestAnimationFrame(u));try{let u=document.createElement("canvas");u.width=Math.max(1,o.naturalWidth||10),u.height=Math.max(1,o.naturalHeight||10);let a=u.getContext("2d");a&&a.drawImage(o,0,0)}catch{}await new Promise(u=>requestAnimationFrame(u));try{o.remove()}catch(u){R(e,"safariWarmup img.remove failed",u)}s()})()}),t.querySelectorAll("canvas").forEach(s=>{try{let o=s.getContext("2d",{willReadFrequently:!0});o&&o.getImageData(0,0,1,1)}catch(o){R(e,"safariWarmup canvas poke failed",o)}}),br=!0}function Ai(t){let e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){let n=e.currentNode,r=getComputedStyle(n),s=r.backgroundImage&&r.backgroundImage!=="none",o=r.maskImage&&r.maskImage!=="none"||r.webkitMaskImage&&r.webkitMaskImage!=="none";if(s||o||n.tagName==="CANVAS")return!0}return!1}export{ci as preCache,N as snapdom};
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onerjs/snapdom",
|
|
3
|
+
"version": "2.7.0",
|
|
4
|
+
"description": "snapDOM captures HTML elements to images with exceptional speed and accuracy.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/snapdom.js",
|
|
7
|
+
"module": "./dist/snapdom.mjs",
|
|
8
|
+
"types": "./types/snapdom.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"workspaces": [
|
|
11
|
+
"packages/*"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./types/snapdom.d.ts",
|
|
16
|
+
"import": "./dist/snapdom.mjs",
|
|
17
|
+
"require": "./dist/snapdom.js",
|
|
18
|
+
"default": "./dist/snapdom.mjs"
|
|
19
|
+
},
|
|
20
|
+
"./preCache": {
|
|
21
|
+
"import": "./dist/preCache.mjs"
|
|
22
|
+
},
|
|
23
|
+
"./plugins": {
|
|
24
|
+
"import": "./dist/plugins.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/",
|
|
29
|
+
"types/snapdom.d.ts",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"compile": "node esbuild.config.mjs",
|
|
34
|
+
"lint": "eslint src __tests__ --ext .js",
|
|
35
|
+
"lint:fix": "eslint src __tests__ --ext .js --fix",
|
|
36
|
+
"test": "npm run lint:fix && npx vitest run --browser.headless --reporter=verbose",
|
|
37
|
+
"test:coverage": "npx vitest run --browser.headless --coverage",
|
|
38
|
+
"test:benchmark": "npx vitest bench --browser.headless --watch=false",
|
|
39
|
+
"bump:dry": "npx @zumerbox/bump -d",
|
|
40
|
+
"bump": "npx @zumerbox/bump && npx @zumerbox/changelog",
|
|
41
|
+
"build": "npm run compile && npm pack",
|
|
42
|
+
"prebuild": "git add CHANGELOG.md"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/zumerlab/snapdom.git"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"zumerlab",
|
|
50
|
+
"snapDOM",
|
|
51
|
+
"screenshot",
|
|
52
|
+
"engine",
|
|
53
|
+
"html capture",
|
|
54
|
+
"dom capture",
|
|
55
|
+
"html to image",
|
|
56
|
+
"dom to image",
|
|
57
|
+
"html screenshot",
|
|
58
|
+
"capture element",
|
|
59
|
+
"html snapshot",
|
|
60
|
+
"element screenshot",
|
|
61
|
+
"web capture",
|
|
62
|
+
"snapshot tool",
|
|
63
|
+
"render html",
|
|
64
|
+
"capture dom",
|
|
65
|
+
"web snapshot",
|
|
66
|
+
"html export",
|
|
67
|
+
"dom snapshot",
|
|
68
|
+
"html to png",
|
|
69
|
+
"html to svg"
|
|
70
|
+
],
|
|
71
|
+
"author": "Juan Martin Muda",
|
|
72
|
+
"license": "MIT",
|
|
73
|
+
"bugs": {
|
|
74
|
+
"url": "https://github.com/zumerlab/snapdom/issues"
|
|
75
|
+
},
|
|
76
|
+
"homepage": "https://zumerlab.github.io/snapdom/",
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@eslint/js": "^9.36.0",
|
|
79
|
+
"@vitest/browser": "^3.1.2",
|
|
80
|
+
"@vitest/coverage-v8": "^3.1.2",
|
|
81
|
+
"eslint": "^9.36.0",
|
|
82
|
+
"globals": "^16.4.0",
|
|
83
|
+
"playwright": "^1.52.0",
|
|
84
|
+
"esbuild": "^0.24.0"
|
|
85
|
+
}
|
|
86
|
+
}
|