@zumer/snapdom
Advanced tools
+1
-1
| /* | ||
| * SnapDOM | ||
| * v2.12.8 | ||
| * v2.12.9 | ||
| * Author: Juan Martin Muda | ||
@@ -5,0 +5,0 @@ * License: MIT |
| /* | ||
| * SnapDOM | ||
| * v2.12.8 | ||
| * v2.12.9 | ||
| * Author: Juan Martin Muda | ||
| * License: MIT | ||
| */ | ||
| var $=class extends Map{constructor(e=100,...n){super(...n),this._maxSize=e}set(e,n){if(this.size>=this._maxSize&&!this.has(e)){let o=this.keys().next().value;o!==void 0&&this.delete(o)}return super.set(e,n)}},m={image:new $(100),background:new $(100),resource:new $(150),defaultStyle:new $(30),baseStyle:new $(50),computedStyle:new WeakMap,measureHints:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}};function tt(t="soft"){switch(m.session.__counterEpoch=(m.session.__counterEpoch||0)+1,t){case"auto":{m.session.styleMap=new Map,m.session.nodeMap=new Map;return}case"soft":{m.session.styleMap=new Map,m.session.nodeMap=new Map,m.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{m.session.styleMap=new Map,m.session.nodeMap=new Map,m.session.styleCache=new WeakMap,m.computedStyle=new WeakMap,m.measureHints=new WeakMap,m.baseStyle=new $(50),m.defaultStyle=new $(30),m.image=new $(100),m.background=new $(100),m.resource=new $(150),m.font=new Set;return}default:{m.session.styleMap=new Map,m.session.nodeMap=new Map,m.session.styleCache=new WeakMap;return}}}function q(t){let e=t.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function v(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function et(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}}function bt(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,s=0;function a(r,l,i){if(s>=n)return;let u=Date.now();(o.get(l)||0)>u||(o.set(l,u+e),s++,r==="warn"&&console&&console.warn?console.warn(`${t} ${i}`):console&&console.error&&console.error(`${t} ${i}`))}return{warnOnce(r,l){a("warn",r,l)},errorOnce(r,l){a("error",r,l)},reset(){o.clear(),s=0}}}var nt=bt("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),K=new Map,V=new Map;function Ct(t){return/^data:|^blob:|^about:blank$/i.test(t)}function kt(t,e){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=e.includes("{url}")?e.split("{url}")[0]:e,s=new URL(o||".",n),a=new URL(t,n);if(a.origin===s.origin)return!0;let r=a.searchParams;if(r&&(r.has("url")||r.has("target")))return!0}catch{}return!1}function xt(t,e){if(!e||Ct(t)||kt(t,e))return!1;try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=new URL(t,n);return typeof location<"u"?o.origin!==location.origin:!0}catch{return!!e}}function At(t,e){if(!e)return t;if(e.includes("{url}"))return e.replace("{urlRaw}",v(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}${v(t)}`;let n=e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function ot(t){return new Promise((e,n)=>{let o=new FileReader;o.onload=()=>e(String(o.result||"")),o.onerror=()=>n(new Error("read_failed")),o.readAsDataURL(t)})}function Rt(t,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,t].join("|")}async function E(t,e={}){let n=e.as??"blob",o=e.timeout??3e3,s=e.useProxy||"",a=e.errorTTL??8e3,r=e.headers||{},l=!!e.silent;if(/^data:/i.test(t))try{if(n==="text")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1};if(n==="dataURL")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1,mime:String(t).slice(5).split(";")[0]||""};let[,g="",c=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],d=/;base64/i.test(g)?atob(c):decodeURIComponent(c),C=new Uint8Array([...d].map(y=>y.charCodeAt(0))),w=new Blob([C],{type:(g||"").split(";")[0]||""});return{ok:!0,data:w,status:200,url:t,fromCache:!1,mime:w.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let g=await fetch(t);if(!g.ok)return{ok:!1,data:null,status:g.status,url:t,fromCache:!1,reason:"http_error"};let c=await g.blob(),f=c.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ot(c),status:g.status,url:t,fromCache:!1,mime:f}:n==="text"?{ok:!0,data:await c.text(),status:g.status,url:t,fromCache:!1,mime:f}:{ok:!0,data:c,status:g.status,url:t,fromCache:!1,mime:f}}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 i=Rt(t,{as:n,timeout:o,useProxy:s,errorTTL:a}),u=V.get(i);if(u&&u.until>Date.now())return{...u.result,fromCache:!0};u&&V.delete(i);let p=K.get(i);if(p)return p;let h=xt(t,s)?At(t,s):t,S=e.credentials;if(!S)try{let g=typeof location<"u"&&location.href?location.href:"http://localhost/",c=new URL(t,g);S=typeof location<"u"&&c.origin===location.origin?"include":"omit"}catch{S="omit"}let x=new AbortController,b=setTimeout(()=>x.abort("timeout"),o),A=(async()=>{try{let g=await fetch(h,{signal:x.signal,credentials:S,headers:r});if(!g.ok){let d={ok:!1,data:null,status:g.status,url:h,fromCache:!1,reason:"http_error"};if(a>0&&V.set(i,{until:Date.now()+a,result:d}),!l){let C=`${g.status} ${g.statusText||""}`.trim();nt.warnOnce(`http:${g.status}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${C} while fetching ${n} ${t}`)}return e.onError&&e.onError(d),d}if(n==="text")return{ok:!0,data:await g.text(),status:g.status,url:h,fromCache:!1};let c=await g.blob(),f=c.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ot(c),status:g.status,url:h,fromCache:!1,mime:f}:{ok:!0,data:c,status:g.status,url:h,fromCache:!1,mime:f}}catch(g){let c=g&&typeof g=="object"&&"name"in g&&g.name==="AbortError"?String(g.message||"").includes("timeout")?"timeout":"abort":"network",f={ok:!1,data:null,status:0,url:h,fromCache:!1,reason:c};if(!/^blob:/i.test(t)&&a>0&&V.set(i,{until:Date.now()+a,result:f}),!l){let d=`${c}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,C=c==="timeout"?`Timeout after ${o}ms. Consider increasing timeout or using a proxy for ${t}`:c==="abort"?`Request aborted while fetching ${n} ${t}`:`Network/CORS issue while fetching ${n} ${t}. A proxy may be required`;nt.errorOnce(d,C)}return e.onError&&e.onError(f),f}finally{clearTimeout(b),K.delete(i)}})();return K.set(i,A),A}async function P(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(t)||t.trim()==="none")return t;let o=q(t);if(!o)return t;let s=et(o),a=v(s),r=(e.useProxy||"")+"|"+a;if(m.background.has(r)){let l=m.background.get(r);return l?`url("${l}")`:"none"}try{let l=await E(a,{as:"dataURL",useProxy:e.useProxy});return l.ok?(m.background.set(r,l.data),`url("${l.data}")`):(m.background.set(r,null),"none")}catch{return m.background.set(r,null),"none"}}var rt=new Set(["meta","script","noscript","title","link","template"]),Y=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"]),$t=["div","span","p","a","img","ul","li","button","input","select","textarea","label","section","article","header","footer","nav","main","aside","h1","h2","h3","h4","h5","h6","table","thead","tbody","tr","td","th"];function H(){for(let t of $t){let e=String(t).toLowerCase();rt.has(e)||Y.has(e)||st(e)}}function st(t){if(t=String(t).toLowerCase(),Y.has(t)){let a={};return m.defaultStyle.set(t,a),a}if(m.defaultStyle.has(t))return m.defaultStyle.get(t);let e=document.getElementById("snapdom-sandbox");e||(e=document.createElement("div"),e.id="snapdom-sandbox",e.setAttribute("data-snapdom-sandbox","true"),e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.width="0px",e.style.height="0px",e.style.overflow="hidden",document.body.appendChild(e));let n=document.createElement(t);n.style.all="initial",e.appendChild(n);let o=getComputedStyle(n),s={};for(let a of o){if(at(a))continue;let r=o.getPropertyValue(a);s[a]=r}return e.removeChild(n),m.defaultStyle.set(t,s),s}var Lt=/(?:^|-)(animation|transition)(?:-|$)/i,Mt=/^(--.+|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,Et=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 at(t){let e=String(t).toLowerCase();return!!(Et.has(e)||Mt.test(e)||Lt.test(e))}function _t(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 o=0;o<window.frames.length;o++)try{if(window.frames[o]?.document===e)return window.frames[o]}catch{}}catch{}return typeof window<"u"?window:null}function N(t,e=null){let n=()=>{let a={length:0,getPropertyValue:()=>"",item:()=>""};return a[Symbol.iterator]=function*(){},a};if(!(t instanceof Element)){let a=typeof window<"u"?window:null;if(a&&typeof a.getComputedStyle=="function")try{return a.getComputedStyle(t,e)||n()}catch{return n()}return n()}let o=m.computedStyle.get(t);o||(o=new Map,m.computedStyle.set(t,o));let s=o.get(e);if(!s){let a=_t(t),r=null;try{r=a&&typeof a.getComputedStyle=="function"?a.getComputedStyle(t,e):null}catch{}if(!r&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{t.ownerDocument===document&&(r=window.getComputedStyle(t,e))}catch{}s=r||n(),o.set(e,s)}return s}function j(t){let e=[],n=0,o=0;for(let s=0;s<t.length;s++){let a=t[s];a==="("&&n++,a===")"&&n--,a===","&&n===0&&(e.push(t.slice(o,s).trim()),o=s+1)}return e.push(t.slice(o).trim()),e}function B(){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"),o=/applewebkit/i.test(t),s=/mobile/i.test(t),a=!/safari/i.test(t),r=o&&s&&a,l=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(t),i=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(e),u=/ipad|iphone|ipod/.test(e)&&o;return n||r||l||i||u}var Ft=[/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],ge=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__||{}),Ut=[];function F(t){let e=typeof t=="string"?t:"",n=[...Ft,...Ut];for(let o of n)if(o instanceof RegExp&&o.test(e))return!0;return!!(/icon/i.test(e)||/glyph/i.test(e)||/symbols/i.test(e)||/feather/i.test(e)||/fontawesome/i.test(e))}var lt=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]),It=["katex","mathjax","mathml"];function J(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^['"]+|['"]+$/g,"");if(n&&!lt.has(n.toLowerCase()))return n}return""}function Ot(t){if(!t)return[];let e=[];for(let n of t.split(",")){let o=n.trim().replace(/^['"]+|['"]+$/g,"");o&&(lt.has(o.toLowerCase())||e.push(o))}return e}function z(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 G(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function Tt(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function vt(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let s=z(n[1]),a=z(n[2]);return{min:Math.min(s,a),max:Math.max(s,a)}}let o=z(e);return{min:o,max:o}}function Pt(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function Nt(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let a=parseFloat(n[1]),r=parseFloat(n[2]);return{min:Math.min(a,r),max:Math.max(a,r)}}let o=e.match(/(\d+(?:\.\d+)?)\s*%/),s=o?parseFloat(o[1]):100;return{min:s,max:s}}function Bt(t){return!t||typeof t!="string"?"":t.replace(/\s+(variable|vf|v[0-9]+)$/i,"").trim().toLowerCase().replace(/\s+/g,"-")}function Dt(t,e,n=[]){if(!t)return!1;try{let o=new URL(t,location.href);if(o.origin===location.origin)return!0;let a=o.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(i=>a.endsWith(i))||n.some(i=>a===i.toLowerCase()||a.endsWith("."+i.toLowerCase())))return!0;let l=(o.pathname+o.search).toLowerCase();if(/\bfont(s)?\b/.test(l)||/\.woff2?(\b|$)/.test(l)||It.some(i=>l.includes(i)))return!0;for(let i of e){let u=i.toLowerCase().replace(/\s+/g,"+"),p=i.toLowerCase().replace(/\s+/g,"-"),h=Bt(i);if(l.includes(u)||l.includes(p)||h&&l.includes(h))return!0}return!1}catch{return!1}}function Wt(t){let e=new Set;for(let n of t||[]){let o=String(n).split("__")[0]?.trim();o&&e.add(o)}return e}function it(t,e){return t&&t.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/g,(n,o,s)=>{let a=(s||"").trim();if(!a||/^data:|^blob:|^https?:|^file:|^about:/i.test(a))return n;let r=a;try{r=new URL(a,e||location.href).href}catch{}return`url("${r}")`})}var Q=/@import\s+(?:url\(\s*(['"]?)([^)"']+)\1\s*\)|(['"])([^"']+)\3)([^;]*);/g,X=4;async function qt(t,e,n){if(!t)return t;let o=new Set;function s(l,i){try{return new URL(l,i||location.href).href}catch{return l}}async function a(l,i,u=0){if(u>X)return console.warn(`[snapDOM] @import depth exceeded (${X}) at ${i}`),l;let p="",h=0,S;for(;S=Q.exec(l);){p+=l.slice(h,S.index),h=Q.lastIndex;let x=(S[2]||S[4]||"").trim(),b=s(x,i);if(o.has(b)){console.warn(`[snapDOM] Skipping circular @import: ${b}`);continue}o.add(b);let A="";try{let g=await E(b,{as:"text",useProxy:n,silent:!0});g.ok&&typeof g.data=="string"&&(A=g.data)}catch{}A?(A=it(A,b),A=await a(A,b,u+1),p+=` | ||
| var L=class extends Map{constructor(e=100,...n){super(...n),this._maxSize=e}set(e,n){if(this.size>=this._maxSize&&!this.has(e)){let o=this.keys().next().value;o!==void 0&&this.delete(o)}return super.set(e,n)}},m={image:new L(100),background:new L(100),resource:new L(150),defaultStyle:new L(30),baseStyle:new L(50),computedStyle:new WeakMap,measureHints:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}};function tt(t="soft"){switch(m.session.__counterEpoch=(m.session.__counterEpoch||0)+1,t){case"auto":{m.session.styleMap=new Map,m.session.nodeMap=new Map;return}case"soft":{m.session.styleMap=new Map,m.session.nodeMap=new Map,m.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{m.session.styleMap=new Map,m.session.nodeMap=new Map,m.session.styleCache=new WeakMap,m.computedStyle=new WeakMap,m.measureHints=new WeakMap,m.baseStyle=new L(50),m.defaultStyle=new L(30),m.image=new L(100),m.background=new L(100),m.resource=new L(150),m.font=new Set;return}default:{m.session.styleMap=new Map,m.session.nodeMap=new Map,m.session.styleCache=new WeakMap;return}}}function q(t){let e=t.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function v(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function et(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}}function bt(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,s=0;function a(r,l,i){if(s>=n)return;let u=Date.now();(o.get(l)||0)>u||(o.set(l,u+e),s++,r==="warn"&&console&&console.warn?console.warn(`${t} ${i}`):console&&console.error&&console.error(`${t} ${i}`))}return{warnOnce(r,l){a("warn",r,l)},errorOnce(r,l){a("error",r,l)},reset(){o.clear(),s=0}}}var nt=bt("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),K=new Map,V=new Map;function Ct(t){return/^data:|^blob:|^about:blank$/i.test(t)}function xt(t,e){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=e.includes("{url}")?e.split("{url}")[0]:e,s=new URL(o||".",n),a=new URL(t,n);if(a.origin===s.origin)return!0;let r=a.searchParams;if(r&&(r.has("url")||r.has("target")))return!0}catch{}return!1}function kt(t,e){if(!e||Ct(t)||xt(t,e))return!1;try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=new URL(t,n);return typeof location<"u"?o.origin!==location.origin:!0}catch{return!!e}}function At(t,e){if(!e)return t;if(e.includes("{url}"))return e.replace("{urlRaw}",v(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}${v(t)}`;let n=e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function ot(t){return new Promise((e,n)=>{let o=new FileReader;o.onload=()=>e(String(o.result||"")),o.onerror=()=>n(new Error("read_failed")),o.readAsDataURL(t)})}function Rt(t,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,t].join("|")}async function E(t,e={}){let n=e.as??"blob",o=e.timeout??3e3,s=e.useProxy||"",a=e.errorTTL??8e3,r=e.headers||{},l=!!e.silent;if(/^data:/i.test(t))try{if(n==="text")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1};if(n==="dataURL")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1,mime:String(t).slice(5).split(";")[0]||""};let[,g="",c=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],d=/;base64/i.test(g)?atob(c):decodeURIComponent(c),C=new Uint8Array([...d].map(y=>y.charCodeAt(0))),w=new Blob([C],{type:(g||"").split(";")[0]||""});return{ok:!0,data:w,status:200,url:t,fromCache:!1,mime:w.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let g=await fetch(t);if(!g.ok)return{ok:!1,data:null,status:g.status,url:t,fromCache:!1,reason:"http_error"};let c=await g.blob(),f=c.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ot(c),status:g.status,url:t,fromCache:!1,mime:f}:n==="text"?{ok:!0,data:await c.text(),status:g.status,url:t,fromCache:!1,mime:f}:{ok:!0,data:c,status:g.status,url:t,fromCache:!1,mime:f}}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 i=Rt(t,{as:n,timeout:o,useProxy:s,errorTTL:a}),u=V.get(i);if(u&&u.until>Date.now())return{...u.result,fromCache:!0};u&&V.delete(i);let p=K.get(i);if(p)return p;let h=kt(t,s)?At(t,s):t,S=e.credentials;if(!S)try{let g=typeof location<"u"&&location.href?location.href:"http://localhost/",c=new URL(t,g);S=typeof location<"u"&&c.origin===location.origin?"include":"omit"}catch{S="omit"}let k=new AbortController,b=setTimeout(()=>k.abort("timeout"),o),A=(async()=>{try{let g=await fetch(h,{signal:k.signal,credentials:S,headers:r});if(!g.ok){let d={ok:!1,data:null,status:g.status,url:h,fromCache:!1,reason:"http_error"};if(a>0&&V.set(i,{until:Date.now()+a,result:d}),!l){let C=`${g.status} ${g.statusText||""}`.trim();nt.warnOnce(`http:${g.status}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${C} while fetching ${n} ${t}`)}return e.onError&&e.onError(d),d}if(n==="text")return{ok:!0,data:await g.text(),status:g.status,url:h,fromCache:!1};let c=await g.blob(),f=c.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ot(c),status:g.status,url:h,fromCache:!1,mime:f}:{ok:!0,data:c,status:g.status,url:h,fromCache:!1,mime:f}}catch(g){let c=g&&typeof g=="object"&&"name"in g&&g.name==="AbortError"?String(g.message||"").includes("timeout")?"timeout":"abort":"network",f={ok:!1,data:null,status:0,url:h,fromCache:!1,reason:c};if(!/^blob:/i.test(t)&&a>0&&V.set(i,{until:Date.now()+a,result:f}),!l){let d=`${c}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,C=c==="timeout"?`Timeout after ${o}ms. Consider increasing timeout or using a proxy for ${t}`:c==="abort"?`Request aborted while fetching ${n} ${t}`:`Network/CORS issue while fetching ${n} ${t}. A proxy may be required`;nt.errorOnce(d,C)}return e.onError&&e.onError(f),f}finally{clearTimeout(b),K.delete(i)}})();return K.set(i,A),A}async function P(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(t)||t.trim()==="none")return t;let o=q(t);if(!o)return t;let s=et(o),a=v(s),r=(e.useProxy||"")+"|"+a;if(m.background.has(r)){let l=m.background.get(r);return l?`url("${l}")`:"none"}try{let l=await E(a,{as:"dataURL",useProxy:e.useProxy});return l.ok?(m.background.set(r,l.data),`url("${l.data}")`):(m.background.set(r,null),"none")}catch{return m.background.set(r,null),"none"}}var rt=new Set(["meta","script","noscript","title","link","template"]),Y=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"]),Lt=["div","span","p","a","img","ul","li","button","input","select","textarea","label","section","article","header","footer","nav","main","aside","h1","h2","h3","h4","h5","h6","table","thead","tbody","tr","td","th"];function H(){for(let t of Lt){let e=String(t).toLowerCase();rt.has(e)||Y.has(e)||st(e)}}function st(t){if(t=String(t).toLowerCase(),Y.has(t)){let a={};return m.defaultStyle.set(t,a),a}if(m.defaultStyle.has(t))return m.defaultStyle.get(t);let e=document.getElementById("snapdom-sandbox");e||(e=document.createElement("div"),e.id="snapdom-sandbox",e.setAttribute("data-snapdom-sandbox","true"),e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.width="0px",e.style.height="0px",e.style.overflow="hidden",document.body.appendChild(e));let n=document.createElement(t);n.style.all="initial",e.appendChild(n);let o=getComputedStyle(n),s={};for(let a of o){if(at(a))continue;let r=o.getPropertyValue(a);s[a]=r}return e.removeChild(n),m.defaultStyle.set(t,s),s}var $t=/(?:^|-)(animation|transition)(?:-|$)/i,Mt=/^(--.+|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,Et=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 at(t){let e=String(t).toLowerCase();return!!(Et.has(e)||Mt.test(e)||$t.test(e))}function _t(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 o=0;o<window.frames.length;o++)try{if(window.frames[o]?.document===e)return window.frames[o]}catch{}}catch{}return typeof window<"u"?window:null}function N(t,e=null){let n=()=>{let a={length:0,getPropertyValue:()=>"",item:()=>""};return a[Symbol.iterator]=function*(){},a};if(!(t instanceof Element)){let a=typeof window<"u"?window:null;if(a&&typeof a.getComputedStyle=="function")try{return a.getComputedStyle(t,e)||n()}catch{return n()}return n()}let o=m.computedStyle.get(t);o||(o=new Map,m.computedStyle.set(t,o));let s=o.get(e);if(!s){let a=_t(t),r=null;try{r=a&&typeof a.getComputedStyle=="function"?a.getComputedStyle(t,e):null}catch{}if(!r&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{t.ownerDocument===document&&(r=window.getComputedStyle(t,e))}catch{}s=r||n(),o.set(e,s)}return s}function j(t){let e=[],n=0,o=0;for(let s=0;s<t.length;s++){let a=t[s];a==="("&&n++,a===")"&&n--,a===","&&n===0&&(e.push(t.slice(o,s).trim()),o=s+1)}return e.push(t.slice(o).trim()),e}function D(){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"),o=/applewebkit/i.test(t),s=/mobile/i.test(t),a=!/safari/i.test(t),r=o&&s&&a,l=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(t),i=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(e),u=/ipad|iphone|ipod/.test(e)&&o;return n||r||l||i||u}var Ft=[/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],ge=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__||{}),Ut=[];function F(t){let e=typeof t=="string"?t:"",n=[...Ft,...Ut];for(let o of n)if(o instanceof RegExp&&o.test(e))return!0;return!!(/icon/i.test(e)||/glyph/i.test(e)||/symbols/i.test(e)||/feather/i.test(e)||/fontawesome/i.test(e))}var lt=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]),It=["katex","mathjax","mathml"];function J(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^['"]+|['"]+$/g,"");if(n&&!lt.has(n.toLowerCase()))return n}return""}function Tt(t){if(!t)return[];let e=[];for(let n of t.split(",")){let o=n.trim().replace(/^['"]+|['"]+$/g,"");o&&(lt.has(o.toLowerCase())||e.push(o))}return e}function G(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 z(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function Ot(t){let e=String(t??"100%").match(/(\d+(?:\.\d+)?)\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function vt(t){let e=String(t||"400").trim(),n=e.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let s=G(n[1]),a=G(n[2]);return{min:Math.min(s,a),max:Math.max(s,a)}}let o=G(e);return{min:o,max:o}}function Pt(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function Nt(t){let e=String(t||"100%").trim(),n=e.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let a=parseFloat(n[1]),r=parseFloat(n[2]);return{min:Math.min(a,r),max:Math.max(a,r)}}let o=e.match(/(\d+(?:\.\d+)?)\s*%/),s=o?parseFloat(o[1]):100;return{min:s,max:s}}function Dt(t){return!t||typeof t!="string"?"":t.replace(/\s+(variable|vf|v[0-9]+)$/i,"").trim().toLowerCase().replace(/\s+/g,"-")}function Bt(t,e,n=[]){if(!t)return!1;try{let o=new URL(t,location.href);if(o.origin===location.origin)return!0;let a=o.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(i=>a.endsWith(i))||n.some(i=>a===i.toLowerCase()||a.endsWith("."+i.toLowerCase())))return!0;let l=(o.pathname+o.search).toLowerCase();if(/\bfont(s)?\b/.test(l)||/\.woff2?(\b|$)/.test(l)||It.some(i=>l.includes(i)))return!0;for(let i of e){let u=i.toLowerCase().replace(/\s+/g,"+"),p=i.toLowerCase().replace(/\s+/g,"-"),h=Dt(i);if(l.includes(u)||l.includes(p)||h&&l.includes(h))return!0}return!1}catch{return!1}}function Wt(t){let e=new Set;for(let n of t||[]){let o=String(n).split("__")[0]?.trim();o&&e.add(o)}return e}function it(t,e){return t&&t.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/g,(n,o,s)=>{let a=(s||"").trim();if(!a||/^data:|^blob:|^https?:|^file:|^about:/i.test(a))return n;let r=a;try{r=new URL(a,e||location.href).href}catch{}return`url("${r}")`})}var Q=/@import\s+(?:url\(\s*(['"]?)([^)"']+)\1\s*\)|(['"])([^"']+)\3)([^;]*);/g,X=4;async function qt(t,e,n){if(!t)return t;let o=new Set;function s(l,i){try{return new URL(l,i||location.href).href}catch{return l}}async function a(l,i,u=0){if(u>X)return console.warn(`[snapDOM] @import depth exceeded (${X}) at ${i}`),l;let p="",h=0,S;for(;S=Q.exec(l);){p+=l.slice(h,S.index),h=Q.lastIndex;let k=(S[2]||S[4]||"").trim(),b=s(k,i);if(o.has(b)){console.warn(`[snapDOM] Skipping circular @import: ${b}`);continue}o.add(b);let A="";try{let g=await E(b,{as:"text",useProxy:n,silent:!0});g.ok&&typeof g.data=="string"&&(A=g.data)}catch{}A?(A=it(A,b),A=await a(A,b,u+1),p+=` | ||
| /* inlined: ${b} */ | ||
| ${A} | ||
| `):p+=S[0]}return p+=l.slice(h),p}let r=it(t,e||location.href);return r=await a(r,e||location.href,0),r}var ft=/url\((["']?)([^"')]+)\1\)/g,Vt=/@font-face[^{}]*\{[^}]*\}/g;function ut(t){if(!t)return[];let e=[],n=t.split(",").map(o=>o.trim()).filter(Boolean);for(let o of n){let s=o.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!s)continue;let a=s[1],r=s[2],l=i=>{if(!i.includes("?"))return parseInt(i,16);let u=parseInt(i.replace(/\?/g,"0"),16),p=parseInt(i.replace(/\?/g,"F"),16);return[u,p]};if(r){let i=l(a),u=l(r),p=Array.isArray(i)?i[0]:i,h=Array.isArray(u)?u[1]:u;e.push([Math.min(p,h),Math.max(p,h)])}else{let i=l(a);Array.isArray(i)?e.push([i[0],i[1]]):e.push([i,i])}}return e}function mt(t,e){if(!e.length||!t||t.size===0)return!0;for(let n of t)for(let[o,s]of e)if(n>=o&&n<=s)return!0;return!1}function Z(t,e){let n=[];if(!t)return n;for(let o of t.matchAll(ft)){let s=(o[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 dt(t,e,n=""){let o=t;for(let s of t.matchAll(ft)){let a=q(s[0]);if(!a)continue;let r=a;if(!r.startsWith("http")&&!r.startsWith("data:"))try{r=new URL(r,e||location.href).href}catch{}if(!F(r)){if(m.resource?.has(r)){m.font?.add(r),o=o.replace(s[0],`url(${m.resource.get(r)})`);continue}if(!m.font?.has(r))try{let l=await E(r,{as:"dataURL",useProxy:n,silent:!0});if(l.ok&&typeof l.data=="string"){let i=l.data;m.resource?.set(r,i),m.font?.add(r),o=o.replace(s[0],`url(${i})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",r)}}}return o}function jt(t){if(!t.length)return null;let e=(l,i)=>t.some(([u,p])=>!(p<l||u>i)),n=e(0,255)||e(305,305),o=e(256,591)||e(7680,7935),s=e(880,1023),a=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":a?"cyrillic":s?"greek":o?"latin-ext":n?"latin":null}function ct(t={}){let e=new Set((t.families||[]).map(s=>String(s).toLowerCase())),n=new Set((t.domains||[]).map(s=>String(s).toLowerCase())),o=new Set((t.subsets||[]).map(s=>String(s).toLowerCase()));return(s,a)=>{if(e.size&&e.has(s.family.toLowerCase()))return!0;if(n.size)for(let r of s.srcUrls)try{if(n.has(new URL(r).host.toLowerCase()))return!0}catch{}if(o.size){let r=jt(a);if(r&&o.has(r))return!0}return!1}}function zt(t){if(!t)return t;let e=/@font-face[^{}]*\{[^}]*\}/gi,n=new Set,o=[];for(let a of t.match(e)||[]){let r=a.match(/font-family:\s*([^;]+);/i)?.[1]||"",l=J(r),i=(a.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),u=(a.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),p=(a.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),h=(a.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),S=(a.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),x=Z(S,location.href),b=x.length?x.map(g=>String(g).toLowerCase()).sort().join("|"):S.toLowerCase(),A=[String(l||"").toLowerCase(),i,u,p,h.toLowerCase(),b].join("|");n.has(A)||(n.add(A),o.push(a))}if(o.length===0)return t;let s=0;return t.replace(e,()=>o[s++]||"")}function Gt(t,e,n,o,s){let a=Array.from(t||[]).sort().join("|"),r=e?JSON.stringify({families:(e.families||[]).map(p=>String(p).toLowerCase()).sort(),domains:(e.domains||[]).map(p=>String(p).toLowerCase()).sort(),subsets:(e.subsets||[]).map(p=>String(p).toLowerCase()).sort()}):"",l=(n||[]).map(p=>`${(p.family||"").toLowerCase()}::${p.weight||"normal"}::${p.style||"normal"}::${p.src||""}`).sort().join("|"),i=o||"",u=(s||[]).map(p=>String(p).toLowerCase()).sort().join("|");return`fonts-embed-css::req=${a}::ex=${r}::lf=${l}::px=${i}::fd=${u}`}async function pt(t,e,n,o){let s;try{s=t.cssRules||[]}catch{return}let a=(r,l)=>{try{return new URL(r,l||location.href).href}catch{return r}};for(let r of s){if(r.type===CSSRule.IMPORT_RULE&&r.styleSheet){let l=r.href?a(r.href,e):e;if(o.depth>=X){console.warn(`[snapDOM] CSSOM import depth exceeded (${X}) at ${l}`);continue}if(l&&o.visitedSheets.has(l)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${l}`);continue}l&&o.visitedSheets.add(l);let i={...o,depth:(o.depth||0)+1};await pt(r.styleSheet,l,n,i);continue}if(r.type===CSSRule.FONT_FACE_RULE){let l=(r.style.getPropertyValue("font-family")||"").trim(),i=J(l);if(!i||F(i))continue;let u=(r.style.getPropertyValue("font-weight")||"400").trim(),p=(r.style.getPropertyValue("font-style")||"normal").trim(),h=(r.style.getPropertyValue("font-stretch")||"100%").trim(),S=(r.style.getPropertyValue("src")||"").trim(),x=(r.style.getPropertyValue("unicode-range")||"").trim();if(!o.faceMatchesRequired(i,p,u,h))continue;let b=ut(x);if(!mt(o.usedCodepoints,b))continue;let A={family:i,weightSpec:u,styleSpec:p,stretchSpec:h,unicodeRange:x,srcRaw:S,srcUrls:Z(S,e||location.href),href:e||location.href};if(o.simpleExcluder&&o.simpleExcluder(A,b))continue;if(/url\(/i.test(S)){let g=await dt(S,e||location.href,o.useProxy);await n(`@font-face{font-family:${i};src:${g};font-style:${p};font-weight:${u};font-stretch:${h};${x?`unicode-range:${x};`:""}}`)}else await n(`@font-face{font-family:${i};src:${S};font-style:${p};font-weight:${u};font-stretch:${h};${x?`unicode-range:${x};`:""}}`)}}}async function ht({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:o=[],useProxy:s="",fontStylesheetDomains:a=[]}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let r=new Map;for(let c of t){let[f,d,C,w]=String(c).split("__");if(!f)continue;let y=f.toLowerCase(),k=r.get(y)||[];k.push({w:parseInt(d,10),s:C,st:parseInt(w,10)}),r.set(y,k)}function l(c,f,d,C){let w=String(c).toLowerCase();if(!r.has(w))return!1;let y=r.get(w),k=vt(d),L=Pt(f),_=Nt(C),I=k.min!==k.max,O=k.min,T=R=>L.kind==="normal"&&R==="normal"||L.kind!=="normal"&&(R==="italic"||R==="oblique"),D=!1;for(let R of y){let M=I?R.w>=k.min&&R.w<=k.max:R.w===O,U=T(G(R.s)),W=R.st>=_.min&&R.st<=_.max;if(M&&U&&W){D=!0;break}}if(D)return!0;if(!I)for(let R of y){let M=T(G(R.s)),U=R.st>=_.min&&R.st<=_.max;if(Math.abs(O-R.w)<=300&&M&&U)return!0}if(!I&&L.kind==="normal"&&y.some(M=>G(M.s)!=="normal"))for(let M of y){let U=Math.abs(O-M.w)<=300,W=M.st>=_.min&&M.st<=_.max;if(U&&W)return!0}return!1}let i=ct(n),u=Gt(t,n,o,s,a);if(m.resource?.has(u))return m.resource.get(u);let p=Wt(t),h=[],S=Q;for(let c of document.querySelectorAll("style")){let f=c.textContent||"";for(let d of f.matchAll(S)){let C=(d[2]||d[4]||"").trim();if(!C||F(C))continue;!!document.querySelector(`link[rel="stylesheet"][href="${C}"]`)||h.push(C)}}let x=[];h.length&&await Promise.all(h.map(c=>new Promise(f=>{if(document.querySelector(`link[rel="stylesheet"][href="${c}"]`))return f(null);let d=document.createElement("link");d.rel="stylesheet",d.href=c,d.setAttribute("data-snapdom","injected-import"),d.onload=()=>f(d),d.onerror=()=>f(null),document.head.appendChild(d),x.push(d)})));let b="",A=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(c=>!!c.href);for(let c of x)try{c.remove()}catch{}for(let c of A)try{if(F(c.href))continue;let f="",d=!1;try{d=new URL(c.href,location.href).origin===location.origin}catch{}if(!d){let w=Array.isArray(a)?a:[];if(!Dt(c.href,p,w))continue}if(d){let w=Array.from(document.styleSheets).find(y=>y.href===c.href);if(w)try{let y=w.cssRules||[];f=Array.from(y).map(k=>k.cssText).join("")}catch{}}if(!f){let w=await E(c.href,{as:"text",useProxy:s});if(w?.ok&&typeof w.data=="string"&&(f=w.data),F(c.href))continue}f=await qt(f,c.href,s);let C="";for(let w of f.match(Vt)||[]){let y=(w.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),k=J(y);if(!k||F(k))continue;let L=(w.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),_=(w.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),I=(w.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),O=(w.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),T=(w.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),D=Z(T,c.href);if(!l(k,_,L,I))continue;let R=ut(O);if(!mt(e,R))continue;let M={family:k,weightSpec:L,styleSpec:_,stretchSpec:I,unicodeRange:O,srcRaw:T,srcUrls:D,href:c.href};if(n&&i(M,R))continue;let U=/url\(/i.test(T)?await dt(w,c.href,s):w;C+=U}C.trim()&&(b+=C)}catch{console.warn("[snapDOM] Failed to process stylesheet:",c.href)}let g={requiredIndex:r,usedCodepoints:e,faceMatchesRequired:l,simpleExcluder:n?ct(n):null,useProxy:s,visitedSheets:new Set,depth:0};for(let c of document.styleSheets)if(!(c.href&&A.some(f=>f.href===c.href)))try{let f=c.href||location.origin+"/";f&&g.visitedSheets.add(f),await pt(c,f,async d=>{b+=d},g)}catch{}try{for(let c of document.fonts||[]){if(!c||!c.family||c.status!=="loaded"||!c._snapdomSrc)continue;let f=String(c.family).replace(/^['"]+|['"]+$/g,"");if(F(f)||!r.has(f.toLowerCase())||n?.families&&n.families.some(C=>String(C).toLowerCase()===f.toLowerCase()))continue;let d=c._snapdomSrc;if(!String(d).startsWith("data:")){if(m.resource?.has(c._snapdomSrc))d=m.resource.get(c._snapdomSrc),m.font?.add(c._snapdomSrc);else if(!m.font?.has(c._snapdomSrc))try{let C=await E(c._snapdomSrc,{as:"dataURL",useProxy:s,silent:!0});if(C.ok&&typeof C.data=="string")d=C.data,m.resource?.set(c._snapdomSrc,d),m.font?.add(c._snapdomSrc);else continue}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",c._snapdomSrc);continue}}b+=`@font-face{font-family:'${f}';src:url(${d});font-style:${c.style||"normal"};font-weight:${c.weight||"normal"};}`}}catch{}for(let c of o){if(!c||typeof c!="object")continue;let f=String(c.family||"").replace(/^['"]+|['"]+$/g,"");if(!f||F(f)||!r.has(f.toLowerCase())||n?.families&&n.families.some(L=>String(L).toLowerCase()===f.toLowerCase()))continue;let d=c.weight!=null?String(c.weight):"normal",C=c.style!=null?String(c.style):"normal",w=c.stretchPct!=null?`${c.stretchPct}%`:"100%",y=String(c.src||""),k=y;if(!k.startsWith("data:")){if(m.resource?.has(y))k=m.resource.get(y),m.font?.add(y);else if(!m.font?.has(y))try{let L=await E(y,{as:"dataURL",useProxy:s,silent:!0});if(L.ok&&typeof L.data=="string")k=L.data,m.resource?.set(y,k),m.font?.add(y);else continue}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",y);continue}}b+=`@font-face{font-family:'${f}';src:url(${k});font-style:${C};font-weight:${d};font-stretch:${w};}`}return b&&(b=zt(b),m.resource?.set(u,b)),b}function gt(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),o=r=>{let l=Ot(r.fontFamily);if(l.length)for(let i of l){let u=(p,h,S)=>`${i}__${z(p)}__${G(h)}__${Tt(S)}`;e.add(u(r.fontWeight,r.fontStyle,r.fontStretch))}};o(getComputedStyle(t));let s=getComputedStyle(t,"::before");s&&s.content&&s.content!=="none"&&o(s);let a=getComputedStyle(t,"::after");for(a&&a.content&&a.content!=="none"&&o(a);n.nextNode();){let r=n.currentNode,l=getComputedStyle(r);o(l);let i=getComputedStyle(r,"::before");i&&i.content&&i.content!=="none"&&o(i);let u=getComputedStyle(r,"::after");u&&u.content&&u.content!=="none"&&o(u)}return e}function yt(t){let e=new Set,n=s=>{if(s)for(let a of s)e.add(a.codePointAt(0))},o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;o.nextNode();){let s=o.currentNode;if(s.nodeType===Node.TEXT_NODE)n(s.nodeValue||"");else if(s.nodeType===Node.ELEMENT_NODE){let a=s;for(let r of["::before","::after"]){let i=getComputedStyle(a,r)?.getPropertyValue("content");if(!(!i||i==="none"))if(/^"/.test(i)||/^'/.test(i))n(i.slice(1,-1));else{let u=i.match(/\\[0-9A-Fa-f]{1,6}/g);if(u)for(let p of u)try{e.add(parseInt(p.slice(1),16))}catch{}}}}}return e}async function wt(t,e=2){try{await document.fonts.ready}catch{}let n=Array.from(t||[]).filter(Boolean);if(n.length===0)return;let o=()=>{let s=document.createElement("div");s.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;";for(let a of n){let r=document.createElement("span");r.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",r.style.fontFamily=`"${a}"`,r.style.fontWeight="700",r.style.fontStyle="italic",r.style.fontSize="32px",r.style.lineHeight="1",r.style.whiteSpace="nowrap",r.style.margin="0",r.style.padding="0",s.appendChild(r)}document.body.appendChild(s),s.offsetWidth,document.body.removeChild(s)};for(let s=0;s<Math.max(1,e);s++)o(),await new Promise(a=>requestAnimationFrame(()=>requestAnimationFrame(a)))}async function St(t,e,n,o={}){let s=[[t,e]],a=["background-image","mask","mask-image","-webkit-mask","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source"],r=["mask-position","mask-size","mask-repeat","mask-mode","mask-composite","-webkit-mask-position","-webkit-mask-size","-webkit-mask-repeat","-webkit-mask-composite","mask-origin","mask-clip","-webkit-mask-origin","-webkit-mask-clip","-webkit-mask-position-x","-webkit-mask-position-y"],l=["background-position","background-position-x","background-position-y","background-size","background-repeat","background-origin","background-clip","background-attachment","background-blend-mode"],i=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;s.length;){let[u,p]=s.shift();if(!p)continue;let h=n.get(u)||N(u);n.has(u)||n.set(u,h);let S=(()=>{let f=h.getPropertyValue("border-image"),d=h.getPropertyValue("border-image-source");return f&&f!=="none"||d&&d!=="none"})(),x=h.getPropertyValue("background-image"),b=h.getPropertyValue("background-color");if(x&&x!=="none"||b&&b!=="rgba(0, 0, 0, 0)"&&b!=="transparent"||/url\s*\(|gradient\s*\(/i.test(h.getPropertyValue("background")||""))for(let f of l){let d=h.getPropertyValue(f);d&&p.style.setProperty(f,d)}for(let f of a){let d=h.getPropertyValue(f);if(f==="background-image"&&(!d||d==="none")){let y=h.getPropertyValue("background");y&&/url\s*\(/.test(y)&&(d=j(y).filter(k=>/url\s*\(/.test(k)).join(", ")||d)}if(!d||d==="none")continue;let C=j(d),w=await Promise.all(C.map(y=>P(y,o)));w.some(y=>y&&y!=="none"&&!/^url\(undefined/.test(y))&&p.style.setProperty(f,w.join(", "))}for(let f of r){let d=h.getPropertyValue(f);!d||d==="initial"||p.style.setProperty(f,d)}if(S)for(let f of i){let d=h.getPropertyValue(f);!d||d==="initial"||p.style.setProperty(f,d)}let g=u.shadowRoot?Array.from(u.shadowRoot.children).filter(f=>f.tagName!=="STYLE"):Array.from(u.children),c=Array.from(p.children).filter(f=>!(f.dataset?.snapdomPseudo||f.tagName==="STYLE"&&f.dataset?.sd));for(let f=0;f<Math.min(g.length,c.length);f++)s.push([g[f],c[f]])}}async function _e(t=document,e={}){let{embedFonts:n=!0,useProxy:o=""}=e,s=e.cache??e.cacheOpt??"full";tt(s);try{await document.fonts?.ready}catch{}try{H()}catch{}m.session=m.session||{},m.session.styleCache||(m.session.styleCache=new WeakMap),m.image=m.image||new $(100),m.background=m.background||new $(100);try{await St(t,void 0,m.session.styleCache,{useProxy:o})}catch{}let a=[],r=[];try{if(t&&t.nodeType===1){let i=t.querySelectorAll?Array.from(t.querySelectorAll("*")):[];r=[t,...i],a=[],t.tagName==="IMG"&&t.getAttribute("src")&&a.push(t),a.push(...Array.from(t.querySelectorAll?.("img[src]")||[]))}else t?.querySelectorAll&&(a=Array.from(t.querySelectorAll("img[src]")),r=Array.from(t.querySelectorAll("*")))}catch{}let l=[];for(let i of a){let u=i?.currentSrc||i?.src;if(u&&!m.image.has(u)){let p=Promise.resolve().then(async()=>{let h=await E(u,{as:"dataURL",useProxy:o});h?.ok&&typeof h.data=="string"&&m.image.set(u,h.data)}).catch(()=>{});l.push(p)}}for(let i of r){let u="";try{u=i?.style?.backgroundImage||"",(!u||u==="none")&&(u=N(i).backgroundImage)}catch{}if(u&&u!=="none"){let p=u.match(/url\((?:[^()"']+|"(?:[^"]*)"|'(?:[^']*)')\)/gi)||[];for(let h of p){let S=Promise.resolve().then(()=>P(h,{...e,useProxy:o})).catch(()=>{});l.push(S)}}}if(n)try{let i=gt(t),u=yt(t);if(typeof B=="function"?B():!!B){let h=new Set(Array.from(i).map(S=>String(S).split("__")[0]).filter(Boolean));await wt(h,3)}await ht({required:i,usedCodepoints:u,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??o,fontStylesheetDomains:e.fontStylesheetDomains})}catch{}await Promise.allSettled(l)}export{_e as preCache}; | ||
| `):p+=S[0]}return p+=l.slice(h),p}let r=it(t,e||location.href);return r=await a(r,e||location.href,0),r}var ft=/url\((["']?)([^"')]+)\1\)/g,Vt=/@font-face[^{}]*\{[^}]*\}/g;function ut(t){if(!t)return[];let e=[],n=t.split(",").map(o=>o.trim()).filter(Boolean);for(let o of n){let s=o.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!s)continue;let a=s[1],r=s[2],l=i=>{if(!i.includes("?"))return parseInt(i,16);let u=parseInt(i.replace(/\?/g,"0"),16),p=parseInt(i.replace(/\?/g,"F"),16);return[u,p]};if(r){let i=l(a),u=l(r),p=Array.isArray(i)?i[0]:i,h=Array.isArray(u)?u[1]:u;e.push([Math.min(p,h),Math.max(p,h)])}else{let i=l(a);Array.isArray(i)?e.push([i[0],i[1]]):e.push([i,i])}}return e}function mt(t,e){if(!e.length||!t||t.size===0)return!0;for(let n of t)for(let[o,s]of e)if(n>=o&&n<=s)return!0;return!1}function Z(t,e){let n=[];if(!t)return n;for(let o of t.matchAll(ft)){let s=(o[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 dt(t,e,n=""){let o=t;for(let s of t.matchAll(ft)){let a=q(s[0]);if(!a)continue;let r=a;if(!r.startsWith("http")&&!r.startsWith("data:"))try{r=new URL(r,e||location.href).href}catch{}if(!F(r)){if(m.resource?.has(r)){m.font?.add(r),o=o.replace(s[0],`url(${m.resource.get(r)})`);continue}if(!m.font?.has(r))try{let l=await E(r,{as:"dataURL",useProxy:n,silent:!0});if(l.ok&&typeof l.data=="string"){let i=l.data;m.resource?.set(r,i),m.font?.add(r),o=o.replace(s[0],`url(${i})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",r)}}}return o}function jt(t){if(!t.length)return null;let e=(l,i)=>t.some(([u,p])=>!(p<l||u>i)),n=e(0,255)||e(305,305),o=e(256,591)||e(7680,7935),s=e(880,1023),a=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":a?"cyrillic":s?"greek":o?"latin-ext":n?"latin":null}function ct(t={}){let e=new Set((t.families||[]).map(s=>String(s).toLowerCase())),n=new Set((t.domains||[]).map(s=>String(s).toLowerCase())),o=new Set((t.subsets||[]).map(s=>String(s).toLowerCase()));return(s,a)=>{if(e.size&&e.has(s.family.toLowerCase()))return!0;if(n.size)for(let r of s.srcUrls)try{if(n.has(new URL(r).host.toLowerCase()))return!0}catch{}if(o.size){let r=jt(a);if(r&&o.has(r))return!0}return!1}}function Gt(t){if(!t)return t;let e=/@font-face[^{}]*\{[^}]*\}/gi,n=new Set,o=[];for(let a of t.match(e)||[]){let r=a.match(/font-family:\s*([^;]+);/i)?.[1]||"",l=J(r),i=(a.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),u=(a.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),p=(a.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),h=(a.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),S=(a.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),k=Z(S,location.href),b=k.length?k.map(g=>String(g).toLowerCase()).sort().join("|"):S.toLowerCase(),A=[String(l||"").toLowerCase(),i,u,p,h.toLowerCase(),b].join("|");n.has(A)||(n.add(A),o.push(a))}if(o.length===0)return t;let s=0;return t.replace(e,()=>o[s++]||"")}function zt(t,e,n,o,s){let a=Array.from(t||[]).sort().join("|"),r=e?JSON.stringify({families:(e.families||[]).map(p=>String(p).toLowerCase()).sort(),domains:(e.domains||[]).map(p=>String(p).toLowerCase()).sort(),subsets:(e.subsets||[]).map(p=>String(p).toLowerCase()).sort()}):"",l=(n||[]).map(p=>`${(p.family||"").toLowerCase()}::${p.weight||"normal"}::${p.style||"normal"}::${p.src||""}`).sort().join("|"),i=o||"",u=(s||[]).map(p=>String(p).toLowerCase()).sort().join("|");return`fonts-embed-css::req=${a}::ex=${r}::lf=${l}::px=${i}::fd=${u}`}async function pt(t,e,n,o){let s;try{s=t.cssRules||[]}catch{return}let a=(r,l)=>{try{return new URL(r,l||location.href).href}catch{return r}};for(let r of s){if(r.type===CSSRule.IMPORT_RULE&&r.styleSheet){let l=r.href?a(r.href,e):e;if(o.depth>=X){console.warn(`[snapDOM] CSSOM import depth exceeded (${X}) at ${l}`);continue}if(l&&o.visitedSheets.has(l)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${l}`);continue}l&&o.visitedSheets.add(l);let i={...o,depth:(o.depth||0)+1};await pt(r.styleSheet,l,n,i);continue}if(r.type===CSSRule.FONT_FACE_RULE){let l=(r.style.getPropertyValue("font-family")||"").trim(),i=J(l);if(!i||F(i))continue;let u=(r.style.getPropertyValue("font-weight")||"400").trim(),p=(r.style.getPropertyValue("font-style")||"normal").trim(),h=(r.style.getPropertyValue("font-stretch")||"100%").trim(),S=(r.style.getPropertyValue("src")||"").trim(),k=(r.style.getPropertyValue("unicode-range")||"").trim();if(!o.faceMatchesRequired(i,p,u,h))continue;let b=ut(k);if(!mt(o.usedCodepoints,b))continue;let A={family:i,weightSpec:u,styleSpec:p,stretchSpec:h,unicodeRange:k,srcRaw:S,srcUrls:Z(S,e||location.href),href:e||location.href};if(o.simpleExcluder&&o.simpleExcluder(A,b))continue;if(/url\(/i.test(S)){let g=await dt(S,e||location.href,o.useProxy);await n(`@font-face{font-family:${i};src:${g};font-style:${p};font-weight:${u};font-stretch:${h};${k?`unicode-range:${k};`:""}}`)}else await n(`@font-face{font-family:${i};src:${S};font-style:${p};font-weight:${u};font-stretch:${h};${k?`unicode-range:${k};`:""}}`)}}}async function ht({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:o=[],useProxy:s="",fontStylesheetDomains:a=[]}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let r=new Map;for(let c of t){let[f,d,C,w]=String(c).split("__");if(!f)continue;let y=f.toLowerCase(),x=r.get(y)||[];x.push({w:parseInt(d,10),s:C,st:parseInt(w,10)}),r.set(y,x)}function l(c,f,d,C){let w=String(c).toLowerCase();if(!r.has(w))return!1;let y=r.get(w),x=vt(d),$=Pt(f),_=Nt(C),I=x.min!==x.max,T=x.min,O=R=>$.kind==="normal"&&R==="normal"||$.kind!=="normal"&&(R==="italic"||R==="oblique"),B=!1;for(let R of y){let M=I?R.w>=x.min&&R.w<=x.max:R.w===T,U=O(z(R.s)),W=R.st>=_.min&&R.st<=_.max;if(M&&U&&W){B=!0;break}}if(B)return!0;if(!I)for(let R of y){let M=O(z(R.s)),U=R.st>=_.min&&R.st<=_.max;if(Math.abs(T-R.w)<=300&&M&&U)return!0}if(!I&&$.kind==="normal"&&y.some(M=>z(M.s)!=="normal"))for(let M of y){let U=Math.abs(T-M.w)<=300,W=M.st>=_.min&&M.st<=_.max;if(U&&W)return!0}return!1}let i=ct(n),u=zt(t,n,o,s,a);if(m.resource?.has(u))return m.resource.get(u);let p=Wt(t),h=[],S=Q;for(let c of document.querySelectorAll("style")){let f=c.textContent||"";for(let d of f.matchAll(S)){let C=(d[2]||d[4]||"").trim();if(!C||F(C))continue;!!document.querySelector(`link[rel="stylesheet"][href="${C}"]`)||h.push(C)}}let k=[];h.length&&await Promise.all(h.map(c=>new Promise(f=>{if(document.querySelector(`link[rel="stylesheet"][href="${c}"]`))return f(null);let d=document.createElement("link");d.rel="stylesheet",d.href=c,d.setAttribute("data-snapdom","injected-import"),d.onload=()=>f(d),d.onerror=()=>f(null),document.head.appendChild(d),k.push(d)})));let b="",A=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).filter(c=>!!c.href);for(let c of k)try{c.remove()}catch{}for(let c of A)try{if(F(c.href))continue;let f="",d=!1;try{d=new URL(c.href,location.href).origin===location.origin}catch{}if(!d){let w=Array.isArray(a)?a:[];if(!Bt(c.href,p,w))continue}if(d){let w=Array.from(document.styleSheets).find(y=>y.href===c.href);if(w)try{let y=w.cssRules||[];f=Array.from(y).map(x=>x.cssText).join("")}catch{}}if(!f){let w=await E(c.href,{as:"text",useProxy:s});if(w?.ok&&typeof w.data=="string"&&(f=w.data),F(c.href))continue}f=await qt(f,c.href,s);let C="";for(let w of f.match(Vt)||[]){let y=(w.match(/font-family:\s*([^;]+);/i)?.[1]||"").trim(),x=J(y);if(!x||F(x))continue;let $=(w.match(/font-weight:\s*([^;]+);/i)?.[1]||"400").trim(),_=(w.match(/font-style:\s*([^;]+);/i)?.[1]||"normal").trim(),I=(w.match(/font-stretch:\s*([^;]+);/i)?.[1]||"100%").trim(),T=(w.match(/unicode-range:\s*([^;]+);/i)?.[1]||"").trim(),O=(w.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||"").trim(),B=Z(O,c.href);if(!l(x,_,$,I))continue;let R=ut(T);if(!mt(e,R))continue;let M={family:x,weightSpec:$,styleSpec:_,stretchSpec:I,unicodeRange:T,srcRaw:O,srcUrls:B,href:c.href};if(n&&i(M,R))continue;let U=/url\(/i.test(O)?await dt(w,c.href,s):w;C+=U}C.trim()&&(b+=C)}catch{console.warn("[snapDOM] Failed to process stylesheet:",c.href)}let g={requiredIndex:r,usedCodepoints:e,faceMatchesRequired:l,simpleExcluder:n?ct(n):null,useProxy:s,visitedSheets:new Set,depth:0};for(let c of document.styleSheets)if(!(c.href&&A.some(f=>f.href===c.href)))try{let f=c.href||location.origin+"/";f&&g.visitedSheets.add(f),await pt(c,f,async d=>{b+=d},g)}catch{}try{for(let c of document.fonts||[]){if(!c||!c.family||c.status!=="loaded"||!c._snapdomSrc)continue;let f=String(c.family).replace(/^['"]+|['"]+$/g,"");if(F(f)||!r.has(f.toLowerCase())||n?.families&&n.families.some(C=>String(C).toLowerCase()===f.toLowerCase()))continue;let d=c._snapdomSrc;if(!String(d).startsWith("data:")){if(m.resource?.has(c._snapdomSrc))d=m.resource.get(c._snapdomSrc),m.font?.add(c._snapdomSrc);else if(!m.font?.has(c._snapdomSrc))try{let C=await E(c._snapdomSrc,{as:"dataURL",useProxy:s,silent:!0});if(C.ok&&typeof C.data=="string")d=C.data,m.resource?.set(c._snapdomSrc,d),m.font?.add(c._snapdomSrc);else continue}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",c._snapdomSrc);continue}}b+=`@font-face{font-family:'${f}';src:url(${d});font-style:${c.style||"normal"};font-weight:${c.weight||"normal"};}`}}catch{}for(let c of o){if(!c||typeof c!="object")continue;let f=String(c.family||"").replace(/^['"]+|['"]+$/g,"");if(!f||F(f)||!r.has(f.toLowerCase())||n?.families&&n.families.some($=>String($).toLowerCase()===f.toLowerCase()))continue;let d=c.weight!=null?String(c.weight):"normal",C=c.style!=null?String(c.style):"normal",w=c.stretchPct!=null?`${c.stretchPct}%`:"100%",y=String(c.src||""),x=y;if(!x.startsWith("data:")){if(m.resource?.has(y))x=m.resource.get(y),m.font?.add(y);else if(!m.font?.has(y))try{let $=await E(y,{as:"dataURL",useProxy:s,silent:!0});if($.ok&&typeof $.data=="string")x=$.data,m.resource?.set(y,x),m.font?.add(y);else continue}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",y);continue}}b+=`@font-face{font-family:'${f}';src:url(${x});font-style:${C};font-weight:${d};font-stretch:${w};}`}return b&&(b=Gt(b),m.resource?.set(u,b)),b}function gt(t){let e=new Set;if(!t)return e;let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),o=r=>{let l=Tt(r.fontFamily);if(l.length)for(let i of l){let u=(p,h,S)=>`${i}__${G(p)}__${z(h)}__${Ot(S)}`;e.add(u(r.fontWeight,r.fontStyle,r.fontStretch))}};o(getComputedStyle(t));let s=getComputedStyle(t,"::before");s&&s.content&&s.content!=="none"&&o(s);let a=getComputedStyle(t,"::after");for(a&&a.content&&a.content!=="none"&&o(a);n.nextNode();){let r=n.currentNode,l=getComputedStyle(r);o(l);let i=getComputedStyle(r,"::before");i&&i.content&&i.content!=="none"&&o(i);let u=getComputedStyle(r,"::after");u&&u.content&&u.content!=="none"&&o(u)}return e}function yt(t){let e=new Set,n=s=>{if(s)for(let a of s)e.add(a.codePointAt(0))},o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;o.nextNode();){let s=o.currentNode;if(s.nodeType===Node.TEXT_NODE)n(s.nodeValue||"");else if(s.nodeType===Node.ELEMENT_NODE){let a=s;for(let r of["::before","::after"]){let i=getComputedStyle(a,r)?.getPropertyValue("content");if(!(!i||i==="none"))if(/^"/.test(i)||/^'/.test(i))n(i.slice(1,-1));else{let u=i.match(/\\[0-9A-Fa-f]{1,6}/g);if(u)for(let p of u)try{e.add(parseInt(p.slice(1),16))}catch{}}}}}return e}async function wt(t,e=2){try{await document.fonts.ready}catch{}let n=Array.from(t||[]).filter(Boolean);if(n.length===0)return;let o=()=>{let s=document.createElement("div");s.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;";for(let a of n){let r=document.createElement("span");r.textContent="AaBbGg1234\xC1\xC9\xCD\xD3\xDA\xE7\xF1\u2014\u221E",r.style.fontFamily=`"${a}"`,r.style.fontWeight="700",r.style.fontStyle="italic",r.style.fontSize="32px",r.style.lineHeight="1",r.style.whiteSpace="nowrap",r.style.margin="0",r.style.padding="0",s.appendChild(r)}document.body.appendChild(s),s.offsetWidth,document.body.removeChild(s)};for(let s=0;s<Math.max(1,e);s++)o(),await new Promise(a=>requestAnimationFrame(()=>requestAnimationFrame(a)))}async function St(t,e,n,o={}){let s=[[t,e]],a=["background-image","mask","mask-image","-webkit-mask","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source"],r=["mask-position","mask-size","mask-repeat","mask-mode","mask-composite","-webkit-mask-position","-webkit-mask-size","-webkit-mask-repeat","-webkit-mask-composite","mask-origin","mask-clip","-webkit-mask-origin","-webkit-mask-clip","-webkit-mask-position-x","-webkit-mask-position-y"],l=["background-position","background-position-x","background-position-y","background-size","background-repeat","background-origin","background-clip","background-attachment","background-blend-mode"],i=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];for(;s.length;){let[u,p]=s.shift();if(!p)continue;let h=n.get(u)||N(u);n.has(u)||n.set(u,h);let S=(()=>{let f=h.getPropertyValue("border-image"),d=h.getPropertyValue("border-image-source");return f&&f!=="none"||d&&d!=="none"})(),k=h.getPropertyValue("background-image"),b=h.getPropertyValue("background-color");if(k&&k!=="none"||b&&b!=="rgba(0, 0, 0, 0)"&&b!=="transparent"||/url\s*\(|gradient\s*\(/i.test(h.getPropertyValue("background")||""))for(let f of l){let d=h.getPropertyValue(f);d&&p.style.setProperty(f,d)}for(let f of a){let d=h.getPropertyValue(f);if(f==="background-image"&&(!d||d==="none")){let y=h.getPropertyValue("background");y&&/url\s*\(/.test(y)&&(d=j(y).filter(x=>/url\s*\(/.test(x)).join(", ")||d)}if(!d||d==="none")continue;let C=j(d),w=await Promise.all(C.map(y=>P(y,o)));w.some(y=>y&&y!=="none"&&!/^url\(undefined/.test(y))&&p.style.setProperty(f,w.join(", "))}for(let f of r){let d=h.getPropertyValue(f);!d||d==="initial"||p.style.setProperty(f,d)}if(S)for(let f of i){let d=h.getPropertyValue(f);!d||d==="initial"||p.style.setProperty(f,d)}let g=u.shadowRoot?Array.from(u.shadowRoot.children).filter(f=>f.tagName!=="STYLE"):Array.from(u.children),c=Array.from(p.children).filter(f=>!(f.dataset?.snapdomPseudo||f.tagName==="STYLE"&&f.dataset?.sd));for(let f=0;f<Math.min(g.length,c.length);f++)s.push([g[f],c[f]])}}async function _e(t=document,e={}){let{embedFonts:n=!0,useProxy:o=""}=e,s=e.cache??e.cacheOpt??"full";tt(s);try{await document.fonts?.ready}catch{}try{H()}catch{}m.session=m.session||{},m.session.styleCache||(m.session.styleCache=new WeakMap),m.image=m.image||new L(100),m.background=m.background||new L(100);try{await St(t,void 0,m.session.styleCache,{useProxy:o})}catch{}let a=[],r=[];try{if(t&&t.nodeType===1){let i=t.querySelectorAll?Array.from(t.querySelectorAll("*")):[];r=[t,...i],a=[],t.tagName==="IMG"&&t.getAttribute("src")&&a.push(t),a.push(...Array.from(t.querySelectorAll?.("img[src]")||[]))}else t?.querySelectorAll&&(a=Array.from(t.querySelectorAll("img[src]")),r=Array.from(t.querySelectorAll("*")))}catch{}let l=[];for(let i of a){let u=i?.currentSrc||i?.src;if(u&&!m.image.has(u)){let p=Promise.resolve().then(async()=>{let h=await E(u,{as:"dataURL",useProxy:o});h?.ok&&typeof h.data=="string"&&m.image.set(u,h.data)}).catch(()=>{});l.push(p)}}for(let i of r){let u="";try{u=i?.style?.backgroundImage||"",(!u||u==="none")&&(u=N(i).backgroundImage)}catch{}if(u&&u!=="none"){let p=u.match(/url\((?:[^()"']+|"(?:[^"]*)"|'(?:[^']*)')\)/gi)||[];for(let h of p){let S=Promise.resolve().then(()=>P(h,{...e,useProxy:o})).catch(()=>{});l.push(S)}}}if(n)try{let i=gt(t),u=yt(t);if(typeof D=="function"?D():!!D){let h=new Set(Array.from(i).map(S=>String(S).split("__")[0]).filter(Boolean));await wt(h,3)}await ht({required:i,usedCodepoints:u,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??o,fontStylesheetDomains:e.fontStylesheetDomains})}catch{}await Promise.allSettled(l)}export{_e as preCache}; |
+1
-1
| { | ||
| "name": "@zumer/snapdom", | ||
| "version": "2.12.8", | ||
| "version": "2.12.9", | ||
| "description": "Fast, modern alternative to html2canvas — captures HTML elements to images (PNG, JPG, SVG, WebP) with exceptional speed and accuracy.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
342266
0.11%1443
0.14%2
100%