System.register([],function(t,e){var r,n,i,o,l,a,s,c,u,d,f,h,m,p,g,y,b,w,x,S,v,C,M,$,k,A,E,F,N,R,L,P,T,W,I,_,O,D,H,j,U,B,V,q,z,X,Y,G,Q,J,K,Z,tt,et,rt,nt,it,ot,lt,at,st,ct,ut,dt,ft,ht,mt,pt,gt,yt,bt,wt,xt,St,vt,Ct,Mt,$t,kt,At,Et,Ft,Nt,Rt,Lt,Pt,Tt,Wt,It,_t,Ot,Dt,Ht,jt,Ut,Bt,Vt;function qt(t){let e=t.match(/url\((['"]?)(.*?)(\1)\)/);if(!e)return null;let r=e[2].trim();return r.startsWith("#")?null:r}function zt(t,e=1){let r=t.match(/^\s*-?(?:webkit-)?image-set\(([\s\S]*)\)\s*$/i);if(!r)return null;let n=[];for(let i of r[1].split(",")){let t=i.match(/url\((['"]?)(.*?)(\1)\)/);if(!t)continue;let e=i.match(/type\(\s*["']([^"']+)["']\s*\)/i);if(e&&!s.test(e[1].trim()))continue;let r=i.match(/(\d+(?:\.\d+)?)\s*(x|dpi|dppx)/i),o=1;if(r){let t=parseFloat(r[1]);o=/dpi/i.test(r[2])?t/96:t}n.push({url:t[2].trim(),dppx:o})}return n.length?(n.sort((t,e)=>t.dppx-e.dppx),(n.find(t=>t.dppx>=e)||n[n.length-1]).url):null}function Xt(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function Yt(t,e){if(!e||function(t){return/^data:|^blob:|^about:blank$/i.test(t)}(t)||function(t,e){try{let r=typeof location<"u"&&location.href?location.href:"http://localhost/",n=e.includes("{url}")?e.split("{url}")[0]:e,i=new URL(n||".",r),o=new URL(t,r);if(o.origin===i.origin)return!0;let l=o.searchParams;if(l&&(l.has("url")||l.has("target")))return!0}catch{}return!1}(t,e))return!1;try{let e=typeof location<"u"&&location.href?location.href:"http://localhost/",r=new URL(t,e);return!(typeof location<"u")||r.origin!==location.origin}catch{return!!e}}function Gt(t){return new Promise((e,r)=>{let n=new FileReader;n.onload=()=>e(String(n.result||"")),n.onerror=()=>r(new Error("read_failed")),n.readAsDataURL(t)})}async function Qt(t,e={}){let r=e.as??"blob",n=e.timeout??3e3,i=e.useProxy||"",o=e.errorTTL??8e3,l=e.headers||{},a=!!e.silent;if(/^data:/i.test(t))try{if("text"===r)return{ok:!0,data:String(t),status:200,url:t,fromCache:!1};if("dataURL"===r)return{ok:!0,data:String(t),status:200,url:t,fromCache:!1,mime:String(t).slice(5).split(";")[0]||""};let[,e="",n=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],i=/;base64/i.test(e)?atob(n):decodeURIComponent(n),o=new Uint8Array([...i].map(t=>t.charCodeAt(0))),l=new Blob([o],{type:(e||"").split(";")[0]||""});return{ok:!0,data:l,status:200,url:t,fromCache:!1,mime:l.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let e=await fetch(t);if(!e.ok)return{ok:!1,data:null,status:e.status,url:t,fromCache:!1,reason:"http_error"};let n=await e.blob(),i=n.type||e.headers.get("content-type")||"";return"dataURL"===r?{ok:!0,data:await Gt(n),status:e.status,url:t,fromCache:!1,mime:i}:"text"===r?{ok:!0,data:await n.text(),status:e.status,url:t,fromCache:!1,mime:i}:{ok:!0,data:n,status:e.status,url:t,fromCache:!1,mime:i}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(t))return"dataURL"===r?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:t,fromCache:!1,mime:"image/png"}:{ok:!0,data:"text"===r?"":new Blob([]),status:200,url:t,fromCache:!1};let s=function(t,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,t].join("|")}(t,{as:r,timeout:n,useProxy:i,errorTTL:o}),c=f.get(s);if(c&&c.until>Date.now())return{...c.result,fromCache:!0};c&&f.delete(s);let h=d.get(s);if(h)return h;let m=Yt(t,i)?function(t,e){return e?e.includes("{url}")?e.replace("{urlRaw}",Xt(t)).replace("{url}",encodeURIComponent(t)):/[?&]url=?$/.test(e)?`${e}${encodeURIComponent(t)}`:e.endsWith("?")?`${e}url=${encodeURIComponent(t)}`:e.endsWith("/")?`${e}${Xt(t)}`:`${e}${e.includes("?")?"&":"?"}url=${encodeURIComponent(t)}`:t}(t,i):t,p=e.credentials;if(!p)try{let e=typeof location<"u"&&location.href?location.href:"http://localhost/",r=new URL(t,e);p=typeof location<"u"&&r.origin===location.origin?"include":"omit"}catch{p="omit"}let g=new AbortController,y=setTimeout(()=>g.abort("timeout"),n),b=(async()=>{try{let n=await fetch(m,{signal:g.signal,credentials:p,headers:l});if(!n.ok){let i={ok:!1,data:null,status:n.status,url:m,fromCache:!1,reason:"http_error"};if(o>0&&f.set(s,{until:Date.now()+o,result:i}),!a){let e=`${n.status} ${n.statusText||""}`.trim();u.warnOnce(`http:${n.status}:${r}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${e} while fetching ${r} ${t}`)}return e.onError&&e.onError(i),i}if("text"===r)return{ok:!0,data:await n.text(),status:n.status,url:m,fromCache:!1};let i=await n.blob(),c=i.type||n.headers.get("content-type")||"";return"dataURL"===r?{ok:!0,data:await Gt(i),status:n.status,url:m,fromCache:!1,mime:c}:{ok:!0,data:i,status:n.status,url:m,fromCache:!1,mime:c}}catch(i){let l=i&&"object"==typeof i&&"name"in i&&"AbortError"===i.name?String(i.message||"").includes("timeout")?"timeout":"abort":"network",c={ok:!1,data:null,status:0,url:m,fromCache:!1,reason:l};if(!/^blob:/i.test(t)&&o>0&&f.set(s,{until:Date.now()+o,result:c}),!a){let e=`${l}:${r}:${new URL(t,location?.href??"http://localhost/").origin}`,i="timeout"===l?`Timeout after ${n}ms. Consider increasing timeout or using a proxy for ${t}`:"abort"===l?`Request aborted while fetching ${r} ${t}`:`Network/CORS issue while fetching ${r} ${t}. A proxy may be required`;u.errorOnce(e,i)}return e.onError&&e.onError(c),c}finally{clearTimeout(y),d.delete(s)}})();return d.set(s,b),b}async function Jt(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(t)||"none"===t.trim())return t;let r=zt(t,typeof devicePixelRatio<"u"&&devicePixelRatio||1)??qt(t);if(!r)return t;let n=Xt(function(t,e){if(!t||/^(data|blob|about|#)/i.test(t.trim()))return t;try{let r=e||typeof document<"u"&&(document.baseURI||document.location?.href)||"http://localhost/";return new URL(t,r).href}catch{return t}}(r)),i=(e.useProxy||"")+"|"+n;if(l.background.has(i)){let t=l.background.get(i);return t?`url("${t}")`:"none"}try{let t=await Qt(n,{as:"dataURL",useProxy:e.useProxy});return t.ok?(l.background.set(i,t.data),`url("${t.data}")`):(l.background.set(i,null),"none")}catch{return l.background.set(i,null),"none"}}function Kt(t){if(t=String(t).toLowerCase(),g.has(t)){let e={};return l.defaultStyle.set(t,e),e}if(l.defaultStyle.has(t))return l.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 r=document.createElement(t);r.style.all="initial",e.appendChild(r);let n=getComputedStyle(r),i={};for(let o of n)Zt(o)||(i[o]=n.getPropertyValue(o));return e.removeChild(r),l.defaultStyle.set(t,i),i}function Zt(t){let e=x.get(t);if(void 0===e){let r=String(t).toLowerCase();e=w.has(r)||b.test(r)||y.test(r),x.set(t,e)}return e}function te(t,e){return!C.has(t)&&("inline"===e||S.has(t)||v.has(t))}function ee(t,e,r=!0,n=!1){if(e=String(e||"").toLowerCase(),g.has(e))return"";let i=[],o=Kt(e),l=(t.display||"").toLowerCase(),a="inline"===l,s=te(e,l),c=t["text-wrap-mode"]||t["white-space"]||"",u=s&&r&&!a&&("nowrap"===c||"pre"===c),d=s&&r&&!u,f=!1;for(let h in t){if(Zt(h))continue;let e=t[h];if(d){if(M.has(h))continue;if($.has(h)){e&&e!==o[h]&&(i.push(`${h}:${e}`),"auto"!==e&&(f=!0));continue}}if(e&&e!==o[h]){if(!u&&("width"===h||"inline-size"===h)&&e.endsWith("px")&&e.includes(".")){let t=parseFloat(e);if(Number.isFinite(t)){i.push(`${h}:${Math.ceil(16*t)/16}px`);continue}}i.push(`${h}:${e}`)}}if(d&&!a&&!n&&!f){let e=t.width;e&&"auto"!==e&&e!==o.width&&i.push(`min-width:${e}`)}return i.sort(),i.join(";")}function re(t,e=null){let r=()=>{let t={length:0,getPropertyValue:()=>"",item:()=>""};return t[Symbol.iterator]=function*(){},t};if(1!==t?.nodeType){let n=typeof window<"u"?window:null;if(n&&"function"==typeof n.getComputedStyle)try{return n.getComputedStyle(t,e)||r()}catch{return r()}return r()}let n=l.computedStyle.get(t);n||(n=new Map,l.computedStyle.set(t,n));let i=n.get(e);if(!i){let o=function(t){try{let e=t?.ownerDocument;if(!e)return typeof window<"u"?window:null;let r=e.defaultView;if(r&&"function"==typeof r.getComputedStyle)return r;if(typeof window<"u"&&window.frames)for(let t=0;t"u")return!1;let t=navigator.userAgent||"",e=t.toLowerCase(),r=e.includes("safari")&&!e.includes("chrome")&&!e.includes("crios")&&!e.includes("fxios")&&!e.includes("android"),n=/applewebkit/i.test(t),i=/mobile/i.test(t),o=!/safari/i.test(t),l=n&&i&&o,a=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(t),s=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(e),c=/ipad|iphone|ipod/.test(e)&&n;return r||l||a||s||c}function ae(t,e,r){let n=t&&"object"==typeof t&&(t.options||t);n&&n.debug&&(void 0!==r?console.warn("[snapdom]",e,r):console.warn("[snapdom]",e))}function se(t){let e=t.indexOf(",");return e>=0?decodeURIComponent(t.slice(e+1)):""}function ce(t){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}function ue(t){let e=[],r="",n=0;for(let i=0;it.trim()).filter(Boolean)}function de(t){let e=ue(t),r=null,n=null,i=null,o=[];for(let a of e){let t=a.indexOf(":");if(t<0)continue;let e=a.slice(0,t).trim().toLowerCase(),l=a.slice(t+1).trim();"box-shadow"===e?i=l:"filter"===e?r=l:"-webkit-filter"===e?n=l:o.push([e,l])}if(i){let t=function(t){let e=[],r="",n=0;for(let o=0;o`${t}:${e}`).join(";")}function fe(t){return t=(t=t.replace(/]*>([\s\S]*?)<\/style>/gi,(t,e)=>t.replace(e,function(t){return t.replace(/([^{}]+)\{([^}]*)\}/g,(t,e,r)=>`${e}{${de(r)}}`)}(e)))).replace(/style=(['"])([\s\S]*?)\1/gi,(t,e,r)=>`style=${e}${de(r)}${e}`)}function he(t,e){let r=t=>ue(t).map(t=>{let r=t.indexOf(":");if(r<0)return t;let n=t.slice(0,r).trim().toLowerCase();return"text-shadow"===n||e&&"box-shadow"===n?`${n}:${function(t){let e=[],r=0,n=0;for(let i=0;i{let e=0,r=0,n="",i=0;for(;i]*>([\s\S]*?)<\/style>/gi,(t,e)=>t.replace(e,e.replace(/([^{}]+)\{([^}]*)\}/g,(t,e,n)=>`${e}{${r(n)}}`)))).replace(/style=(['"])([\s\S]*?)\1/gi,(t,e,n)=>`style=${e}${r(n)}${e}`)}async function me(t){if(!/(?:box-shadow|text-shadow)\s*:[^;"}]*px/i.test(t))return{svg:t,naturalOnly:!1};let{native:e,flippedY:r}=await(T||(T=(async()=>{try{let t='
',e=new Image;e.decoding="sync",e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`,await e.decode();let r=document.createElement("canvas");r.width=8,r.height=20;let n=r.getContext("2d",{willReadFrequently:!0});n.drawImage(e,0,0);let i=n.getImageData(2,18,1,1).data[3]>128,o=n.getImageData(2,2,1,1).data[3]>128;return{native:i||o,flippedY:o&&!i}}catch{return{native:!1,flippedY:!1}}})()));try{let n=t;return e||(n=fe(n)),r&&(n=he(n,e)),{svg:n,naturalOnly:!0}}catch{return{svg:t,naturalOnly:!0}}}async function pe(t,e){let{width:r,height:n,scale:i=1,dpr:o=1,meta:l={},backgroundColor:a}=e,s=t,c=!1,u=!1;if(function(t){return"string"==typeof t&&/^data:image\/svg\+xml/i.test(t)}(t)){let e=(function(t){let e=t.indexOf(",");if(e<0)return"";let r=t.slice(e+1,e+1201).replace(/%[0-9A-Fa-f]?$/,"");try{return decodeURIComponent(r)}catch{return""}}(t).match(/]*>/i)||[])[0]||"",r=parseFloat((e.match(/\bwidth="([\d.]+)/i)||[])[1]),n=parseFloat((e.match(/\bheight="([\d.]+)/i)||[])[1]),i=Number.isFinite(r)&&Number.isFinite(n)&&r>0&&n>0&&Math.min(1,L/r,L/n,Math.sqrt(P/(r*n)))<1;if(i||le())try{let e=se(t);if(le()){let t=await me(e);e=t.svg,c=t.naturalOnly,u=/@font-face|data:image\//i.test(e)}i&&(e=function(t){try{let e=t.match(/]*>/i);if(!e)return t;let r=e[0],n=parseFloat((r.match(/\bwidth="([\d.]+)/i)||[])[1]),i=parseFloat((r.match(/\bheight="([\d.]+)/i)||[])[1]);if(!Number.isFinite(n)||!Number.isFinite(i)||n<=0||i<=0)return t;let o=Math.min(1,L/n,L/i,Math.sqrt(P/(n*i)));if(o>=1)return t;let l=Math.max(1,Math.floor(n*o)),a=Math.max(1,Math.floor(i*o));return console.warn(`[snapDOM] Capture ${Math.round(n)}×${Math.round(i)}px exceeds the browser image-decode limit (${L}px/side); downscaling to ${l}×${a}px. Lower \`scale\` or set \`width\`/\`height\` to control output size.`),t.replace(r,r.replace(/(\bwidth=")[\d.]+/i,`$1${l}`).replace(/(\bheight=")[\d.]+/i,`$1${a}`))}catch{return t}}(e)),s=ce(e)}catch{s=t}}let d=new Image;d.loading="eager",d.decoding="sync",d.crossOrigin="anonymous",d.src=s,await d.decode(),le()&&await async function(t,e){t.setAttribute("data-snapdom-internal",""),t.style.cssText="position:fixed;left:-99999px;top:-99999px;pointer-events:none",document.body.appendChild(t);try{let r=document.createElement("canvas");r.width=16,r.height=16;let n=()=>new Promise(t=>{requestAnimationFrame(t),setTimeout(t,50)}),i=r.getContext("2d",{willReadFrequently:!0});if(!i)return await n(),void(await n());let o=performance.now()+(e?600:150);for(;;){i.clearRect(0,0,16,16);try{i.drawImage(t,0,0,16,16)}catch{return}let e=i.getImageData(0,0,16,16).data,r=!1;for(let t=3;t0){r=!0;break}if(r||performance.now()>o)return;await n()}}finally{try{t.remove()}catch{}}}(d,u);let f,h,m=d.naturalWidth,p=d.naturalHeight,g=Number.isFinite(l.vbW)?l.vbW:Number.isFinite(l.w0)?l.w0:m,y=Number.isFinite(l.vbH)?l.vbH:Number.isFinite(l.h0)?l.h0:p,b=Number.isFinite(r),w=Number.isFinite(n);b&&w?(f=Math.max(1,r),h=Math.max(1,n)):b?(f=r,h=y*(r/Math.max(1,g))):w?(h=n,f=g*(n/Math.max(1,y))):(f=m,h=p),f*=i,h*=i;let x=f*o,S=h*o,v=Math.max(x/L,S/L,Math.sqrt(x*S/P));v>1&&(console.warn(`[snapDOM] Output ${Math.round(x)}×${Math.round(S)}px exceeds the browser canvas limit (${L}px/side); downscaling. Lower \`scale\`/\`dpr\` or set \`width\`/\`height\`.`),f/=v,h/=v);let C=document.createElement("canvas");C.width=f*o,C.height=h*o,C.style.width=`${f}px`,C.style.height=`${h}px`;let M=C.getContext("2d");if(1!==o&&M.scale(o,o),a&&(M.save(),M.fillStyle=a,M.fillRect(0,0,f,h),M.restore()),!c||Math.round(f*o)===m&&Math.round(h*o)===p)M.drawImage(d,0,0,f,h);else{let t=document.createElement("canvas");t.width=m,t.height=p,t.getContext("2d").drawImage(d,0,0),M.drawImage(t,0,0,f,h)}return C}async function ge(t,e){let r=await pe(t,e),n=await new Promise(t=>{let n=()=>t(r.toDataURL(`image/${e.format}`,e.quality));try{r.toBlob(e=>{if(!e)return n();let r=new FileReader;r.onload=()=>t(String(r.result||"")),r.onerror=n,r.readAsDataURL(e)},`image/${e.format}`,e.quality)}catch{n()}}),i=new Image;return i.src=n,await i.decode(),i.style.width=r.width/e.dpr+"px",i.style.height=r.height/e.dpr+"px",i}async function ye(t,e){let{scale:r=1,width:n,height:i,meta:o={}}=e,l=Number.isFinite(n),a=Number.isFinite(i),s=Number.isFinite(r)&&1!==r||l||a;if(le()&&s)try{let{svg:e}=await me(se(t)),s=(e.match(/]*>/i)||[])[0]||"",c=parseFloat((s.match(/\bwidth="([\d.]+)/i)||[])[1]),u=parseFloat((s.match(/\bheight="([\d.]+)/i)||[])[1]);if(!Number.isFinite(c)||!Number.isFinite(u))throw new Error("svg without dimensions");let d,f,h=Number.isFinite(o.vbW)?o.vbW:Number.isFinite(o.w0)?o.w0:c,m=Number.isFinite(o.vbH)?o.vbH:Number.isFinite(o.h0)?o.h0:u;l&&a?(d=n,f=i):l?(d=n,f=Math.round(m*(n/Math.max(1,h)))):a?(f=i,d=Math.round(h*(i/Math.max(1,m)))):(d=Math.round(c*r),f=Math.round(u*r));let p=e.replace(/width="[^"]*"/,`width="${d}"`).replace(/height="[^"]*"/,`height="${f}"`),g=new Image;return g.decoding="sync",g.loading="eager",g.src=ce(p),await g.decode(),g.style.width=`${d}px`,g.style.height=`${f}px`,g}catch(u){return ae(e,"safari vector toImg failed, falling back to PNG",u),ge(t,{...e,format:"png",quality:1,meta:o})}let c=new Image;if(c.decoding="sync",c.loading="eager",c.src=t,await c.decode(),l&&a)c.style.width=`${n}px`,c.style.height=`${i}px`;else if(l){let t=Number.isFinite(o.vbW)?o.vbW:Number.isFinite(o.w0)?o.w0:c.naturalWidth,e=Number.isFinite(o.vbH)?o.vbH:Number.isFinite(o.h0)?o.h0:c.naturalHeight,r=n/Math.max(1,t);c.style.width=`${n}px`,c.style.height=`${Math.round(e*r)}px`}else if(a){let t=Number.isFinite(o.vbW)?o.vbW:Number.isFinite(o.w0)?o.w0:c.naturalWidth,e=Number.isFinite(o.vbH)?o.vbH:Number.isFinite(o.h0)?o.h0:c.naturalHeight,r=i/Math.max(1,e);c.style.height=`${i}px`,c.style.width=`${Math.round(t*r)}px`}else{let n=Math.round(c.naturalWidth*r),i=Math.round(c.naturalHeight*r);if(c.style.width=`${n}px`,c.style.height=`${i}px`,"string"==typeof t&&t.startsWith("data:image/svg+xml"))try{let e=decodeURIComponent(t.split(",")[1]).replace(/width="[^"]*"/,`width="${n}"`).replace(/height="[^"]*"/,`height="${i}"`);t=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,c.src=t}catch(d){ae(e,"SVG width/height patch in toImg failed",d)}}return c}async function be(t,e){let r=e.type;if("svg"===r){let e=decodeURIComponent(t.split(",")[1]);return new Blob([e],{type:"image/svg+xml"})}let n=await pe(t,e);return new Promise(t=>n.toBlob(e=>t(e),`image/${r}`,e.quality))}async function we(t,e){let r=new File([t],e,{type:t.type});if(!navigator.canShare?.({files:[r]}))return!1;try{await navigator.share({files:[r],title:e})}catch(n){if("AbortError"!==n.name)return!1}return!0}async function xe(t,e){let r=new Set(["png","jpeg","jpg","webp","svg"]),n=(e?.type||"").toLowerCase(),i=r.has(n)?n:"",o=(e?.format||i||"").toLowerCase(),l="jpg"===o?"jpeg":o||"png",a=e?.filename||`snapdom.${l}`,s={...e||{},format:l,type:l};s.dpr=1;let c=function(){if(typeof navigator>"u")return!1;if(navigator.userAgentData)return"iOS"===navigator.userAgentData.platform;let t=navigator.userAgent||"",e=/iPhone|iPad|iPod/.test(t),r=navigator.maxTouchPoints>2&&/Macintosh/.test(t);return e||r}();if("svg"===l){let e=await be(t,{...s,type:"svg"});if(c&&await we(e,a))return;let r=URL.createObjectURL(e),n=document.createElement("a");return n.href=r,n.download=a,document.body.appendChild(n),n.click(),URL.revokeObjectURL(r),void n.remove()}let u=await pe(t,s);if(c){let t=`image/${l}`,r=await new Promise(r=>u.toBlob(r,t,e?.quality));if(r&&await we(r,a))return}let d=document.createElement("a");d.href=u.toDataURL(`image/${l}`,e?.quality),d.download=a,document.body.appendChild(d),d.click(),d.remove()}function Se(){X++,q.size>z&&q.clear()}function ve(t){let e=t&&(1===t.nodeType?t:t.parentElement);return!!(e&&e.closest&&e.closest(Y))}function Ce(t){for(let e of t)if(!ve(e.target)){if("childList"===e.type){let t=!0;for(let r of e.addedNodes)if(!ve(r)){t=!1;break}if(t)for(let r of e.removedNodes)if(!ve(r)){t=!1;break}if(t)continue}return!0}return!1}function Me(t){let e=V.get(t);if(e&&e.epoch===X){let t=e.snapshot&&e.snapshot.__needsBgInline;if(void 0!==t)return t}return!0}function $e(t,e=null,r={}){let n=V.get(t),i=!(!r||!r.embedFonts),o=r&&r.excludeStyleProps||null;if(n&&n.epoch===X&&n.embedFonts===i&&n.excludeStyleProps===o)return n.snapshot;let l=e||getComputedStyle(t),a=function(t,e={}){let r={},n=t.getPropertyValue("visibility"),i=e.excludeStyleProps;for(let u=0;u0&&Math.abs(i-t.scrollHeight)>2||e.aspectRatio&&"none"!==e.aspectRatio&&"auto"!==e.aspectRatio)return;let o=e.display||"";if(o.includes("flex")||o.includes("grid")||function(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof HTMLIFrameElement||t instanceof SVGElement||t instanceof HTMLObjectElement||t instanceof HTMLEmbedElement}(t))return;let l=e.position;if("absolute"===l||"fixed"===l||"sticky"===l||"none"!==e.transform||function(t){return!!(t.backgroundImage&&"none"!==t.backgroundImage||t.backgroundColor&&"rgba(0, 0, 0, 0)"!==t.backgroundColor&&"transparent"!==t.backgroundColor||(parseFloat(t.borderTopWidth)||0)>0||(parseFloat(t.borderBottomWidth)||0)>0||(parseFloat(t.paddingTop)||0)>0||(parseFloat(t.paddingBottom)||0)>0)||"visible"!==(t.overflowBlock||t.overflowY||"visible")}(e)||Ae(t))return;let a=e.overflowX||e.overflow||"visible",s=e.overflowY||e.overflow||"visible";if("visible"!==a||"visible"!==s)return;let c=e.clip;c&&"auto"!==c&&"rect(auto, auto, auto, auto)"!==c||"hidden"===e.visibility||"0"===e.opacity||function(t){for(let n=t.firstChild;n;n=n.nextSibling)if(3===n.nodeType&&/\S/.test(n.nodeValue))return!0;let e=t.firstElementChild,r=t.lastElementChild;if(e&&"BR"===e.tagName||r&&"BR"===r.tagName)return!0;for(let n=t.firstElementChild;n;n=n.nextElementSibling){let t=re(n);if("none"===t.display)continue;let e=t.position;if("absolute"!==e&&"fixed"!==e)return!0}return!1}(t)&&(delete r.height,delete r["block-size"])}(t,l,a),V.set(t,{epoch:X,snapshot:a,embedFonts:i,excludeStyleProps:o}),a}async function ke(t,e,r,n){if("STYLE"===t.tagName)return;let i=function(t,e){return t&&t.session&&t.persist?t:t&&(t.styleMap||t.styleCache||t.nodeMap)?{session:t,persist:{snapshotKeyCache:q,defaultStyle:l.defaultStyle,baseStyle:l.baseStyle,image:l.image,resource:l.resource,background:l.background,font:l.font},options:e||{}}:{session:l.session,persist:{snapshotKeyCache:q,defaultStyle:l.defaultStyle,baseStyle:l.baseStyle,image:l.image,resource:l.resource,background:l.background,font:l.font},options:t||e||{}}}(r,n),o=i.options&&i.options.cache||"auto";"disabled"!==o&&function(t=document.documentElement){if(G)return;G=!0;let e=t=>{Ce(t)&&Se()};try{new MutationObserver(e).observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(e).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let t=document.fonts;t&&(t.addEventListener?.("loadingdone",Se),t.ready?.then(()=>Se()).catch(()=>{}))}catch{}}(document.documentElement),"disabled"===o&&!i.session.__bumpedForDisabled&&(Se(),q.clear(),i.session.__bumpedForDisabled=!0);let{session:a,persist:s}=i;if(!a.styleCache.has(t)){let e=null;try{e=getComputedStyle(t)}catch{}a.styleCache.set(t,e||getComputedStyle(document.documentElement))}let c=a.styleCache.get(t);t.getAttribute?.("style")&&function(t,e,r){if(t.style&&0!==t.style.length)for(let n=0;nt[0]e[0]?1:0).map(([t,e])=>`${t}:${e}`).join(";"),J.set(t,e),e)}(d),p=!0;if(te(h,(d.display||"").toLowerCase())){p=function(t){for(let e=t.firstChild;e;e=e.nextSibling){if(3===e.nodeType&&/\S/.test(e.nodeValue||""))return!0;if(1===e.nodeType){let t=re(e).position;if("absolute"!==t&&"fixed"!==t)return!0}}return!1}(t),m=`${m}|${h}${p?"|c":""}${f?"|f":""}`;let e=d["text-wrap-mode"]||d["white-space"]||"";p&&"nowrap"!==e&&"pre"!==e&&(a.reconcileRisk=(a.reconcileRisk||0)+1)}let g=s.snapshotKeyCache.get(m);void 0===g&&(g=ee(d,h,p,f),s.snapshotKeyCache.set(m,g)),a.styleMap.set(e,g)}function Ae(t){let e=t.parentElement;if(!e)return!1;let r=re(e).display||"";return r.includes("flex")||r.includes("grid")}function Ee(t){let e=t;for(;e&&1===e.nodeType;){if("http://www.w3.org/2000/svg"===e.namespaceURI){if("mask"===e.localName||"clipPath"===e.localName)return!1;if(Z.has(e.localName))return!0}e=e.parentNode}return!1}function Fe(t,e){if(1!==t?.nodeType||1!==e?.nodeType||Ee(t))return;let r=t.getAttribute?.("style"),n=!(!r||!r.includes("var("));if(!n&&t.attributes?.length){let e=t.attributes;for(let t=0;tt.d-e.d);let i=window.devicePixelRatio||1;return(n.find(t=>t.d>=i)||n[n.length-1]).url}function Le(t,e){let r=t.currentSrc||"";if(r&&!Ne(r))return r;let n=e.querySelectorAll("source[srcset]"),i=null;for(let o of n){let e=o.getAttribute("srcset");if(!e||Ne(e))continue;let r=o.getAttribute("type");if(r&&!rt.test(r.trim()))continue;let n=o.getAttribute("media");if(n)try{if(window.matchMedia(n).matches)return Re(e,t)}catch{}i||(i=Re(e,t))}return i}function Pe(t){let e=[t.getAttribute("data-src"),t.getAttribute("data-lazy-src"),t.getAttribute("data-original"),t.getAttribute("data-hi-res-src")];for(let n of e)if(n&&!Ne(n))return n;let r=t.getAttribute("data-srcset")||t.getAttribute("data-lazy-srcset");if(r){let t=r.split(",")[0].trim().split(/\s+/)[0];if(t&&!Ne(t))return t}return null}async function Te(t,e={}){if(!t||1!==t?.nodeType||!1===e.resolvePicturePlaceholders)return null;let{timeout:r,concurrency:n,resolveLazySrc:i,silent:o,useProxy:l}=function(t={}){let e=t.pictureResolver&&"object"==typeof t.pictureResolver?t.pictureResolver:{};return{timeout:e.timeout??5e3,concurrency:e.concurrency??4,resolveLazySrc:!1!==e.resolveLazySrc,silent:e.silent??!1,useProxy:"string"==typeof t.useProxy?t.useProxy:""}}(e);if(!function(t,e){return!(!t||1!==t?.nodeType||!(t.matches?.("picture")||t.querySelector("picture")||e&&(t.matches?.(et)||t.querySelector(et))))}(t,i))return null;let a=[],s=[];async function c(t){let e=await Qt(t,{as:"dataURL",timeout:r,useProxy:l,silent:!0});return e.ok?e.data:null}let u=Array.from(t.querySelectorAll("picture"));t.matches?.("picture")&&u.unshift(t);for(let d of u){let t=d.querySelector("img");if(!t)continue;if(!Ne(t.getAttribute("src")||""))continue;let e=Le(t,d);e&&s.push(async()=>{let r=await c(e);if(!r)return void(o||console.warn(`[snapdom:picture-resolver] Failed to fetch: ${e.slice(0,60)}`));let n=t.getAttribute("src"),i=t.getAttribute("srcset"),l=t.getAttribute("sizes"),s=[];t.src=r,t.setAttribute("src",r),t.removeAttribute("srcset"),t.removeAttribute("sizes");let u=d.querySelectorAll("source");for(let t of u)s.push({el:t,parent:t.parentElement,next:t.nextSibling}),t.remove();a.push(()=>{null!==n?t.setAttribute("src",n):t.removeAttribute("src"),null!==i&&t.setAttribute("srcset",i),null!==l&&t.setAttribute("sizes",l);for(let{el:t,parent:e,next:r}of s)e&&e.insertBefore(t,r)})})}if(i){let e=Array.from(t.querySelectorAll("img"));"img"===t.localName&&e.unshift(t);for(let t of e){if(t.closest("picture")&&Ne(t.getAttribute("src")||""))continue;let e=t.getAttribute("src")||"",r=Pe(t);r&&Ne(e)&&s.push(async()=>{let e=await c(r);if(!e)return;let n=t.getAttribute("src");t.src=e,t.setAttribute("src",e),t.removeAttribute("srcset"),t.removeAttribute("sizes"),a.push(()=>{null!==n?t.setAttribute("src",n):t.removeAttribute("src")})})}}return 0===s.length?null:(await async function(t){for(let e=0;et()))}}(s),async function(){for(let t of a)try{t()}catch{}})}function We(t,e,r){return r?Promise.all(t.map(t=>new Promise(r=>e(t,r)))):Promise.all(t.map(t=>new Promise(n=>{!function i(){oe(r=>{!r||"function"!=typeof r.timeRemaining||r.timeRemaining()>0?e(t,n):i()},{fast:r})}()})))}function Ie(t,e){return t?t=(t=(t=(t=(t=t.replace(/:host\(([^)]+)\)/g,(t,r)=>`:where(${e}:is(${r.trim()}))`)).replace(/:host\b/g,`:where(${e})`)).replace(/:host-context\(([^)]+)\)/g,(t,r)=>`:where(:where(${r.trim()}) ${e})`)).replace(/::slotted\(([^)]+)\)/g,(t,r)=>`:where(${e} ${r.trim()})`)).replace(/(^|})(\s*)([^@}{]+){/g,(t,r,n,i)=>`${r}${n}${function(t,e,r=!0){return t.split(",").map(t=>t.trim()).filter(Boolean).map(t=>t.startsWith(":where(")||t.startsWith("@")?t:`:where(${e} ${r?function(t){return!(t=t.trim())||/:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(t)?t:`${t}:not([data-sd-slotted])`}(t):t})`).join(", ")}(i,e,!0)}{`):""}function _e(t,e){try{let r=getComputedStyle(t).getPropertyValue(e).trim();if(r)return r}catch{}try{let t=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(t)return t}catch{}return""}function Oe(t){let e=0,r=0;if(t.offsetWidth>0&&(e=t.offsetWidth),t.offsetHeight>0&&(r=t.offsetHeight),0===e||0===r)try{let n=getComputedStyle(t);if(0===e){let t=parseFloat(n.width);!isNaN(t)&&t>0&&(e=t)}if(0===r){let t=parseFloat(n.height);!isNaN(t)&&t>0&&(r=t)}}catch{}if(0===e||0===r)try{if(0===e){let r=parseFloat(t.getAttribute("width"));!isNaN(r)&&r>0&&(e=r)}if(0===r){let e=parseFloat(t.getAttribute("height"));!isNaN(e)&&e>0&&(r=e)}}catch{}if((0===e||0===r)&&(t.naturalWidth||t.naturalHeight))try{0===e&&t.naturalWidth>0&&(e=t.naturalWidth),0===r&&t.naturalHeight>0&&(r=t.naturalHeight)}catch{}return{width:e,height:r}}async function De(t,e,r){let n=await async function(t,e=3){let r=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},n=r(),i=0;for(;isetTimeout(t,0)),n=r(),i++;return n&&(n.body||n.documentElement)?n:null}(t,3);if(!n)throw new Error("iframe document not accessible/ready");let{contentWidth:i,contentHeight:o,rect:a}=function(t){let e=t.getBoundingClientRect(),r=0,n=0,i=0,o=0;try{let e=getComputedStyle(t);r=parseFloat(e.borderLeftWidth)||0,n=parseFloat(e.borderRightWidth)||0,i=parseFloat(e.borderTopWidth)||0,o=parseFloat(e.borderBottomWidth)||0}catch{}return{contentWidth:Math.max(0,Math.round(e.width-(r+n))),contentHeight:Math.max(0,Math.round(e.height-(i+o))),rect:e}}(t),s=r?.snap;if(!s&&typeof window<"u"&&window.snapdom&&(s=window.snapdom),!s||"function"!=typeof s.toPng)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 c,u={...r,scale:1,clip:null},d=function(t,e,r){let n=t.defaultView,i=n?n.scrollX:0,o=n?n.scrollY:0,l=t.body?t.body.scrollLeft:0,a=t.body?t.body.scrollTop:0,s=t.documentElement?t.documentElement.scrollLeft:0,c=t.documentElement?t.documentElement.scrollTop:0,u=0,d=0,f=0,h=0;try{let e=n&&t.body?n.getComputedStyle(t.body):null;e&&(u=(parseFloat(e.marginTop)||0)+(parseFloat(e.paddingTop)||0),d=(parseFloat(e.marginRight)||0)+(parseFloat(e.paddingRight)||0),f=(parseFloat(e.marginBottom)||0)+(parseFloat(e.paddingBottom)||0),h=(parseFloat(e.marginLeft)||0)+(parseFloat(e.paddingLeft)||0))}catch{}try{t.documentElement.setAttribute("data-sd-pinned","")}catch{}let m=t.createElement("style");return m.setAttribute("data-sd-iframe-pin",""),m.textContent=`html {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${r}px !important;min-width: ${e}px !important;min-height: ${r}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}body {margin: 0 !important;padding: ${u}px ${d}px ${f}px ${h}px !important;width: ${e}px !important;height: ${r}px !important;min-width: ${e}px !important;min-height: ${r}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(t.head||t.documentElement).appendChild(m),()=>{try{m.remove()}catch{}try{t.documentElement.removeAttribute("data-sd-pinned")}catch{}try{n&&"function"==typeof n.scrollTo&&n.scrollTo(i,o),t.body&&(t.body.scrollLeft=l,t.body.scrollTop=a),t.documentElement&&(t.documentElement.scrollLeft=s,t.documentElement.scrollTop=c)}catch{}}}(n,i,o),f=l.session.nodeMap,h=l.session.styleMap,m=l.session.styleCache;try{c=await s.toPng(n.documentElement,u)}finally{d(),l.session.nodeMap=f,l.session.styleMap=h,l.session.styleCache=m}c.style.display="block",c.style.width=`${i}px`,c.style.height=`${o}px`;let p=document.createElement("div");return e.nodeMap.set(p,t),ke(t,p,e,r),p.style.overflow="hidden",p.style.display="block",p.style.width||(p.style.width=`${Math.round(a.width)}px`),p.style.height||(p.style.height=`${Math.round(a.height)}px`),p.appendChild(c),p}async function He(t){if(l.resource?.has(t))return l.resource.get(t);if(nt.has(t))return nt.get(t);let e=(async()=>{let e=await Qt(t,{as:"dataURL",silent:!0});if(!e.ok||"string"!=typeof e.data)throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);return l.resource?.set(t,e.data),e.data})();nt.set(t,e);try{let r=await e;return nt.set(t,r),r}catch(r){throw nt.delete(t),r}}async function je(t){if(!t||-1===t.indexOf("blob:"))return t;let e=Array.from(new Set(t.match(it)||[]));if(0===e.length)return t;let r=t;for(let n of e)try{let t=await He(n);r=r.split(n).join(t)}catch{}return r}function Ue(t){return"string"==typeof t&&t.startsWith("blob:")}function Be(t){return(t||"").split(",").map(t=>t.trim()).filter(Boolean).map(t=>{let e=t.match(/^(\S+)(\s+.+)?$/);return e?{url:e[1],desc:e[2]||""}:null}).filter(Boolean)}function Ve(t){return t.map(t=>t.desc?`${t.url} ${t.desc.trim()}`:t.url).join(", ")}function qe(t,e){let r=t.querySelectorAll?Array.from(t.querySelectorAll(e)):[];return t.matches?.(e)&&r.unshift(t),r}function ze(t,e){ot.set(String(t).toUpperCase(),e)}function Xe(t){let{width:e,height:r}=Oe(t),n=e,i=r;if(!n||!i){let e=t.getBoundingClientRect();n=n||e.width||0,i=i||e.height||0}let o=document.createElement("div");return o.style.cssText=`display:inline-block;width:${n}px;height:${i}px;visibility:hidden;`,o}function Ye(t,e){return t.right>=e.left-at&&t.left<=e.right+at&&t.bottom>=e.top-at&&t.top<=e.bottom+at}async function Ge(t,e,r){if(!t)throw new Error("Invalid node");let n,i=new Set,o=null,l=null;if(t.nodeType===Node.ELEMENT_NODE){let r=(t.localName||t.tagName||"").toLowerCase();if("snapdom-sandbox"===t.id||t.hasAttribute("data-snapdom-sandbox")||p.has(r))return null;if("foreignobject"===r&&t.parentElement?.closest?.("foreignObject"))return ae(e,"Nested skipped (SVG spec limitation — not rendered by browsers)"),null;if("source"===r&&"picture"===t.parentElement?.localName)return null}if(t.nodeType===Node.TEXT_NODE||t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if("exclude"===t.getAttribute("data-capture")){if("hide"===r.excludeMode)return Xe(t);if("remove"===r.excludeMode)return null}if(r.exclude&&Array.isArray(r.exclude))for(let h of r.exclude)try{if(t.matches?.(h)){if("hide"===r.excludeMode)return Xe(t);if("remove"===r.excludeMode)return null}}catch(u){console.warn(`Invalid selector in exclude option: ${h}`,u)}if("function"==typeof r.filter)try{if(!r.filter(t)){if("hide"===r.filterMode)return Xe(t);if("remove"===r.filterMode)return null}}catch(d){console.warn("Error in filter function:",d)}if(e.clip&&function(t,e){if(t===e.root)return!1;let r;try{r=t.getBoundingClientRect()}catch{return!1}if(0===r.width&&0===r.height)return!1;let n=re(t);if("inline"===n.display&&!st.has((t.localName||"").toLowerCase()))return!1;let i=e.rect,o=t.scrollWidth||0,l=t.scrollHeight||0,a={left:"rtl"===n.direction?Math.min(r.left,r.right-o):r.left,top:r.top,right:Math.max(r.right,r.left+o),bottom:Math.max(r.bottom,r.top+l)},s=n.writingMode||"";if((s.startsWith("vertical")||s.startsWith("sideways"))&&(a.top=Math.min(r.top,r.bottom-l),a.left=Math.min(a.left,r.right-o)),Ye(a,i))return!1;let c=(t.ownerDocument||document).createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;c.nextNode();){let t=c.currentNode.getBoundingClientRect();if((t.width>0||t.height>0)&&Ye(t,i))return!1}return!0}(t,e.clip))return function(t,e,r){let n=t.cloneNode(!1);"IMG"===t.tagName&&(n.removeAttribute("src"),n.removeAttribute("srcset"),n.removeAttribute("sizes")),ke(t,n,e,r);let{width:i,height:o}=Oe(t);return i>0&&(n.style.width=`${i}px`,n.style.minWidth=`${i}px`,n.style.maxWidth=`${i}px`),o>0&&(n.style.height=`${o}px`,n.style.minHeight=`${o}px`,n.style.maxHeight=`${o}px`),n.style.visibility="hidden",n.style.overflow="hidden",n.style.boxSizing="border-box",n}(t,e,r);if(r.__resolveNodeHooks)for(let h of r.__resolveNodeHooks){let n;try{n=await h(t,r)}catch(f){ae(e,"resolveNode plugin hook failed",f)}if(null===n)return null;if(n instanceof Node)return n.nodeType===Node.ELEMENT_NODE&&(e.nodeMap.set(n,t),ke(t,n,e,r)),n}{let n=lt.has(t.tagName)&&ot.get(t.tagName);if(n){let i=await n(t,e,r);if(void 0!==i)return i}}if("placeholder"===t.getAttribute("data-capture")){let n=t.cloneNode(!1);e.nodeMap.set(n,t),ke(t,n,e,r);let i=document.createElement("div");return i.textContent=t.getAttribute("data-placeholder-text")||"",i.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",n.appendChild(i),n}{let n=!lt.has(t.tagName)&&ot.get(t.tagName);if(n){let i=await n(t,e,r);if(void 0!==i)return i}}try{if(n=t.cloneNode(!1),n.attributes?.length)try{for(let t of n.attributes)/[\x00-\x08\x0B\x0C\x0E-\x1F\uFFFE\uFFFF]/.test(t.value)&&n.setAttribute(t.name,t.value.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\uFFFE\uFFFF]/g,""))}catch{}if(Fe(t,n),e.nodeMap.set(n,t),"IMG"===t.tagName){!function(t,e){try{let r=null,n=re(t).content;if(n&&n.includes("url(")){let t=n.match(/url\(["']?([^"')]+)["']?\)/);t&&(r=t[1])}let i=t.closest?.("picture"),o=r||(i?Le(t,i):t.currentSrc)||t.src||Re(t.getAttribute("srcset"),t)||"";if(!o)return;e.setAttribute("src",o),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}(t,n);try{let{width:e,height:r}=Oe(t),i=Math.round(e||0),o=Math.round(r||0);i&&(n.dataset.snapdomWidth=String(i)),o&&(n.dataset.snapdomHeight=String(o))}catch(d){ae(e,"getUnscaledDimensions for IMG failed",d)}try{let e=t.getAttribute("style")||"",r=window.getComputedStyle(t),i=t=>{let n=e.match(new RegExp(`${t}\\s*:\\s*([^;]+)`,"i")),i=n?n[1].trim():r.getPropertyValue(t);return/%|auto/i.test(String(i||""))},o=parseInt(n.dataset.snapdomWidth||"0",10),l=parseInt(n.dataset.snapdomHeight||"0",10),a=i("width")||!o,s=i("height")||!l;a&&o&&(n.style.width=`${o}px`),s&&l&&(n.style.height=`${l}px`);let c=r.getPropertyValue("object-fit"),u=r.getPropertyValue("object-position");c&&"fill"!==c?(n.style.objectFit=c,u&&(n.style.objectPosition=u)):(o&&(n.style.minWidth=`${o}px`),l&&(n.style.minHeight=`${l}px`))}catch(d){ae(e,"IMG dimension freeze failed",d)}}}catch(d){throw console.error("[Snapdom] Failed to clone node:",t,d),d}let a=null;if(t instanceof HTMLTextAreaElement){let{width:e,height:r}=Oe(t),i=e||t.getBoundingClientRect().width||0,o=r||t.getBoundingClientRect().height||0;i&&(n.style.width=`${i}px`),o&&(n.style.height=`${o}px`)}if(t instanceof HTMLInputElement){let r=(t.type||"text").toLowerCase();if("checkbox"!==r&&"radio"!==r||!function(){if(typeof navigator>"u")return!1;let t=(navigator.userAgent||"").toLowerCase();return t.includes("firefox")||t.includes("fxios")}())n.value=t.value,n.setAttribute("value",t.value),void 0!==t.checked&&(n.checked=t.checked,t.checked&&n.setAttribute("checked",""),t.indeterminate&&(n.indeterminate=t.indeterminate));else{let{el:r,applyVisual:i}=function(t){let e,{width:r,height:n}=Oe(t),i=t.getBoundingClientRect();try{e=window.getComputedStyle(t)}catch{}let o=e?parseFloat(e.width):NaN,l=e?parseFloat(e.height):NaN,a=Math.round(r||i.width||0),s=Math.round(n||i.height||0),c=Number.isFinite(o)&&o>0?Math.round(o):Math.max(12,a||16),u=Number.isFinite(l)&&l>0?Math.round(l):Math.max(12,s||16),d="checkbox"===(t.type||"text").toLowerCase(),f=!!t.checked,h=!!t.indeterminate,m=Math.max(Math.min(c,u),12),p="middle";try{e&&e.verticalAlign&&(p=e.verticalAlign)}catch{}let g=document.createElement("div");g.setAttribute("data-snapdom-input-replacement",t.type||"checkbox"),g.style.cssText=`display:inline-block;width:${m}px;height:${m}px;vertical-align:${p};flex-shrink:0;line-height:0;`;let y=document.createElementNS("http://www.w3.org/2000/svg","svg");function b(){let t="#0a6ed1";try{e&&(t=e.accentColor||e.color||t)}catch{}let r=m-2;if(y.innerHTML="",d){let e=document.createElementNS("http://www.w3.org/2000/svg","rect");if(e.setAttribute("x",String(1)),e.setAttribute("y",String(1)),e.setAttribute("width",String(r)),e.setAttribute("height",String(r)),e.setAttribute("rx","2"),e.setAttribute("ry","2"),e.setAttribute("fill",f?t:"none"),e.setAttribute("stroke",t),e.setAttribute("stroke-width",String(2)),y.appendChild(e),f){let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",`M 3 ${m/2} L ${m/2-1} ${m-1-2} L ${m-1-2} 3`),t.setAttribute("stroke","white"),t.setAttribute("stroke-width",String(Math.max(1.5,2))),t.setAttribute("fill","none"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),y.appendChild(t)}else if(h){let e=document.createElementNS("http://www.w3.org/2000/svg","rect"),n=Math.max(6,r-4);e.setAttribute("x",String((m-n)/2)),e.setAttribute("y",String((m-2)/2)),e.setAttribute("width",String(n)),e.setAttribute("height",String(2)),e.setAttribute("fill",t),e.setAttribute("rx","1"),y.appendChild(e)}}else{let e=document.createElementNS("http://www.w3.org/2000/svg","circle");if(e.setAttribute("cx",String(m/2)),e.setAttribute("cy",String(m/2)),e.setAttribute("r",String((m-2)/2)),e.setAttribute("fill",f?t:"none"),e.setAttribute("stroke",t),e.setAttribute("stroke-width",String(2)),y.appendChild(e),f){let t=document.createElementNS("http://www.w3.org/2000/svg","circle"),e=Math.max(2,.35*(m-4));t.setAttribute("cx",String(m/2)),t.setAttribute("cy",String(m/2)),t.setAttribute("r",String(e)),t.setAttribute("fill","white"),y.appendChild(t)}}g.style.setProperty("width",`${m}px`,"important"),g.style.setProperty("height",`${m}px`,"important"),g.style.setProperty("min-width",`${m}px`,"important"),g.style.setProperty("min-height",`${m}px`,"important")}return y.setAttribute("width",String(m)),y.setAttribute("height",String(m)),y.setAttribute("viewBox",`0 0 ${m} ${m}`),g.appendChild(y),b(),{el:g,applyVisual:b}}(t);e.nodeMap.set(r,t),a=i,n=r}}if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&!t.value&&t.placeholder)try{let e=window.getComputedStyle(t,"::placeholder"),r=e&&e.color;if(r&&"rgba(0, 0, 0, 0)"!==r){let t="snapdom-ph-"+(1e6*Math.random()|0);n.classList.add(t);let i=document.createElement("style");i.textContent=`.${t}::placeholder{color:${r}!important;opacity:${e.opacity||"1"}!important;-webkit-text-fill-color:${r}!important;}`,n.prepend(i)}}catch{}if(t instanceof HTMLSelectElement&&(o=t.value),t instanceof HTMLTextAreaElement&&(l=t.value),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){t.disabled&&n.setAttribute("disabled",""),t.required&&n.setAttribute("required",""),t.readOnly&&n.setAttribute("readonly","");let e=t;void 0!==e.min&&""!==e.min&&n.setAttribute("min",e.min),void 0!==e.max&&""!==e.max&&n.setAttribute("max",e.max),void 0!==e.pattern&&""!==e.pattern&&n.setAttribute("pattern",e.pattern);let r=t.getAttribute("aria-invalid");null!==r&&n.setAttribute("aria-invalid",r)}if(Ee(t)||ke(t,n,e,r),a&&a(),t instanceof SVGElement&&!Ee(t)){let e=["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 r=window.getComputedStyle(t);for(let t of e){let e=r.getPropertyValue(t);e&&n.style.setProperty(t,e)}}catch{}}if(t.shadowRoot){let o=function(t,n){if(t.nodeType===Node.ELEMENT_NODE&&"STYLE"===t.tagName)return n(null);Ge(t,e,r).then(t=>{n(t||null)}).catch(()=>{n(null)})};var s=o;try{let e=t.shadowRoot.querySelectorAll("slot");for(let t of e){let e=[];try{e=t.assignedNodes?.({flatten:!0})||t.assignedNodes?.()||[]}catch{e=t.assignedNodes?.()||[]}for(let t of e)i.add(t)}}catch{}let l=function(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}(e),a=`[data-sd="${l}"]`;try{n.setAttribute("data-sd",l)}catch{}let c=function(t){let e="";try{t.querySelectorAll("style").forEach(t=>{e+=(t.textContent||"")+"\n"});let r=t.adoptedStyleSheets||[];for(let t of r)try{if(t&&t.cssRules)for(let r of t.cssRules)e+=r.cssText+"\n"}catch{}}catch{}return e}(t.shadowRoot),u=Ie(c,a),d=function(t,e,r){let n=[];for(let i of e){let e=_e(t,i);e&&n.push(`${i}: ${e};`)}return n.length?`${r}{${n.join("")}}\n`:""}(t,function(t){let e=new Set;if(!t)return e;let r,n=/var\(\s*(--[A-Za-z0-9_-]+)\b/g;for(;r=n.exec(t);)e.add(r[1]);return e}(c),a);!function(t,e,r){if(!e)return;let n=document.createElement("style");n.setAttribute("data-sd",r),n.textContent=e,t.insertBefore(n,t.firstChild||null)}(n,d+u,l);let f=document.createDocumentFragment(),h=await We(Array.from(t.shadowRoot.childNodes),o,r.fast);f.append(...h.filter(t=>!!t)),n.appendChild(f)}if("SLOT"===t.tagName){let n=function(t,n){Ge(t,e,r).then(t=>{t&&function(t){t&&(t.nodeType===Node.ELEMENT_NODE&&t.setAttribute("data-sd-slotted",""),t.querySelectorAll&&t.querySelectorAll("*").forEach(t=>t.setAttribute("data-sd-slotted","")))}(t),n(t||null)}).catch(()=>{n(null)})};s=n;let i=t.assignedNodes?.({flatten:!0})||[],o=i.length>0?i:Array.from(t.childNodes),l=document.createDocumentFragment(),a=await We(Array.from(o),n,r.fast);return l.append(...a.filter(t=>!!t)),l}function s(t,n){if(i.has(t))return n(null);Ge(t,e,r).then(t=>{n(t||null)}).catch(()=>{n(null)})}let c=await We(Array.from(t.childNodes),s,r.fast);if(n.append(...c.filter(t=>!!t)),null!==o&&n instanceof HTMLSelectElement){n.value=o;for(let t of n.options)t.value===o?t.setAttribute("selected",""):t.removeAttribute("selected")}return null!==l&&n instanceof HTMLTextAreaElement&&(n.textContent=l),n}async function Qe(t,e,r){let n=!1;try{n=!(!t.contentDocument&&!t.contentWindow?.document)}catch(i){ae(e,"iframe same-origin probe failed",i)}if(n)try{return await De(t,e,r)}catch(i){console.warn("[SnapDOM] iframe rasterization failed, fallback:",i)}if(n||console.warn("[snapdom] cross-origin