Skip to content

feat(Dom2Image): update SnapDOM to v3.5.0 - #1259

Merged
ArgoZhang merged 3 commits into
masterfrom
dev-dom2image
Oct 28, 2026
Merged

ArgoZhang merged 3 commits into
masterfrom
dev-dom2image

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Link issues

fixes #1258

Summary By Copilot

Update the bundled SnapDOM from v3.4.0 to the official v3.5.0 npm release.

Regression?

  • Yes
  • No

Browser regression testing has not been run.

Risk

  • High
  • Medium
  • Low

Only the vendored JavaScript bundle changes; wrapper APIs remain unchanged.

Verification

  • Manual (required)

  • Automated

  • node --check "src\components\BootstrapBlazor.Dom2Image\wwwroot\lib\snapdom.mjs" — passed.

  • node --input-type=module -e "import { snapdom } from './src/components/BootstrapBlazor.Dom2Image/wwwroot/lib/snapdom.mjs'; if (typeof snapdom !== 'function') throw new Error('Missing snapdom export'); console.log('snapdom export: OK');" — passed.

  • git diff --check — passed.

No browser capture tests or .NET unit tests were run; this change only replaces the upstream bundle.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

The existing static asset path and MIT license header are preserved.

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Upgrade the Dom2Image component to SnapDOM v3.5.0.

Enhancements:

  • Update the bundled SnapDOM dependency to the official v3.5.0 release while preserving the existing integration and asset packaging.

Build:

  • Update the project dependency reference for SnapDOM.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This low-risk dependency refresh replaces the bundled SnapDOM v3.4.0 JavaScript with the official v3.5.0 release in place, leaving Dom2Image wrapper APIs and packaging paths unchanged; automated static/module checks passed, but browser capture and .NET tests were not run.

File-Level Changes

Change Details Files
Upgrade the vendored SnapDOM runtime to the official v3.5.0 release while preserving the existing integration surface.
  • Replace the generated SnapDOM bundle content with the v3.5.0 distribution.
  • Preserve the static asset location, module export, and MIT license header.
  • Keep wrapper APIs unchanged and validate module syntax, export availability, and diff formatting.
src/components/BootstrapBlazor.Dom2Image/wwwroot/lib/snapdom.mjs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto Bot added the enhancement New feature or request label Oct 28, 2026
@bb-auto bb-auto Bot added this to the v10.0.0 milestone Oct 28, 2026
bb-auto[bot]
bb-auto Bot previously approved these changes Oct 28, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

bb-auto[bot]
bb-auto Bot previously approved these changes Oct 28, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@ArgoZhang
ArgoZhang merged commit f70003f into master Oct 28, 2026
2 of 3 checks passed
@ArgoZhang
ArgoZhang deleted the dev-dom2image branch October 28, 2026 07:34

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New security issues found

`;return e}function Os(t){let e="";try{t.querySelectorAll("style").forEach(o=>{let i=null;try{i=o.sheet&&o.sheet.cssRules}catch{}e+=(i?Se(i):o.textContent||"")+`
`});let n=t.adoptedStyleSheets||[];for(let o of n)try{o&&o.cssRules&&(e+=Se(o.cssRules))}catch{}}catch{}return e}function Ws(t,e,n){if(!e)return;let o=document.createElement("style");o.setAttribute("data-sd",n),o.textContent=e,t.insertBefore(o,t.firstChild||null)}function Ds(t,e,n={}){try{let o=null,i=W(t).content;if(i&&i.includes("url(")){let u=i.match(/url\(["']?([^"')]+)["']?\)/);u&&(o=u[1])}let r=t.closest?.("picture"),s=t.getAttribute("src")||"",a=t.getAttribute("srcset")||"",l=o||(r?Fs(t,r):!a.trim()&&s.startsWith("data:")?s:t.currentSrc)||He(a,t)||t.src||"";if((!l||ze(l))&&n.resolvePicturePlaceholders!==!1){let u=Ts(t);u&&(l=u)}if(!l)return;e.getAttribute("src")!==l&&e.setAttribute("src",l),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}function Bs(t){let e=new Set;if(!t)return e;let n=/var\(\s*(--[A-Za-z0-9_-]+)\b/g,o;for(;o=n.exec(t);)e.add(o[1]);return e}function eu(t,e){try{let o=getComputedStyle(t).getPropertyValue(e).trim();if(o)return o}catch{}try{let o=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(o)return o}catch{}return""}function Us(t,e,n){let o=[];for(let i of e){let r=eu(t,i);r&&o.push(`${i}: ${r};`)}return o.length?`${n}{${o.join("")}}
`:""}function zs(t,e){if(!t)return;let n=o=>{let i=o.getAttribute("data-sd-slotted")||"";e?` ${i} `.includes(` ${e} `)||o.setAttribute("data-sd-slotted",i?`${i} ${e}`:e):o.setAttribute("data-sd-slotted",i)};t.nodeType===Node.ELEMENT_NODE&&n(t),t.querySelectorAll?.("*").forEach(n)}async function nu(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},o=n(),i=0;for(;i<e&&(!o||!o.body&&!o.documentElement);)await new Promise(r=>setTimeout(r,0)),o=n(),i++;return o&&(o.body||o.documentElement)?o:null}function ou(t){let e=t.getBoundingClientRect(),n=0,o=0,i=0,r=0;try{let l=getComputedStyle(t);n=parseFloat(l.borderLeftWidth)||0,o=parseFloat(l.borderRightWidth)||0,i=parseFloat(l.borderTopWidth)||0,r=parseFloat(l.borderBottomWidth)||0}catch{}let s=Math.max(0,Math.round(e.width-(n+o))),a=Math.max(0,Math.round(e.height-(i+r)));return{contentWidth:s,contentHeight:a,rect:e}}function Et(t){let e=0,n=0;if(t.offsetWidth>0&&(e=t.offsetWidth),t.offsetHeight>0&&(n=t.offsetHeight),e===0||n===0)try{let o=getComputedStyle(t);if(e===0){let i=parseFloat(o.width);!isNaN(i)&&i>0&&(e=i)}if(n===0){let i=parseFloat(o.height);!isNaN(i)&&i>0&&(n=i)}}catch{}if(e===0||n===0)try{if(e===0){let o=parseFloat(t.getAttribute("width"));!isNaN(o)&&o>0&&(e=o)}if(n===0){let o=parseFloat(t.getAttribute("height"));!isNaN(o)&&o>0&&(n=o)}}catch{}if((e===0||n===0)&&(t.naturalWidth||t.naturalHeight))try{e===0&&t.naturalWidth>0&&(e=t.naturalWidth),n===0&&t.naturalHeight>0&&(n=t.naturalHeight)}catch{}return{width:e,height:n}}var $s=new WeakMap;function ru(t,e,n){let o=t.defaultView,i=o?o.scrollX:0,r=o?o.scrollY:0,s=t.body?t.body.scrollLeft:0,a=t.body?t.body.scrollTop:0,l=t.documentElement?t.documentElement.scrollLeft:0,u=t.documentElement?t.documentElement.scrollTop:0,c=0,f=0,d=0,h=0;try{let p=o&&t.body?o.getComputedStyle(t.body):null;p&&(c=(parseFloat(p.marginTop)||0)+(parseFloat(p.paddingTop)||0),f=(parseFloat(p.marginRight)||0)+(parseFloat(p.paddingRight)||0),d=(parseFloat(p.marginBottom)||0)+(parseFloat(p.paddingBottom)||0),h=(parseFloat(p.marginLeft)||0)+(parseFloat(p.paddingLeft)||0))}catch{}let m=`html {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}body {margin: 0 !important;padding: ${c}px ${f}px ${d}px ${h}px !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,g;try{let p=$s.get(t);p||$s.set(t,p=new o.CSSStyleSheet),p.replaceSync(m),t.adoptedStyleSheets=[...t.adoptedStyleSheets,p],g=()=>{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(y=>y!==p)}}catch{let p=t.createElement("style");p.setAttribute("data-sd-iframe-pin",""),tt(p),p.textContent=m,(t.head||t.documentElement).appendChild(p),g=()=>p.remove()}if(xe(t.documentElement),i||r)try{t.body&&(t.body.scrollLeft=i,t.body.scrollTop=r),t.documentElement&&(t.documentElement.scrollLeft||(t.documentElement.scrollLeft=i),t.documentElement.scrollTop||(t.documentElement.scrollTop=r))}catch{}return()=>{try{g()}catch{}try{o&&typeof o.scrollTo=="function"&&o.scrollTo(i,r),t.body&&(t.body.scrollLeft=s,t.body.scrollTop=a),t.documentElement&&(t.documentElement.scrollLeft=l,t.documentElement.scrollTop=u)}catch{}xe(t.documentElement)}}async function Sr(t,e,n){let o=await nu(t,3);if(!o)throw new Error("The iframe document isn't ready.");let{contentWidth:i,contentHeight:r,rect:s}=ou(t),a=n?.snap;if(!a||typeof a.toPng!="function")throw new Error("Iframes are only captured through snapdom(el).");let l={...n,scale:1,clip:null,__pinned:!0},u=ru(o,i,r),c;try{c=await a.toPng(o.documentElement,l)}finally{u()}c.style.display="block",c.style.width=`${i}px`,c.style.height=`${r}px`;let f=document.createElement("div");return e.nodeMap.set(f,t),wt(t,f,e,n),f.style.overflow="hidden",f.style.display="block",f.style.width||(f.style.width=`${Math.round(s.width)}px`),f.style.height||(f.style.height=`${Math.round(s.height)}px`),f.appendChild(c),f}function Hs(t){try{let e=t&&t.accentColor;if(e&&e!=="auto"&&e!=="none")return e;let n=t&&t.color;if(n)return n}catch{}return"#0a6ed1"}function js(t){let{width:e,height:n}=Et(t),o=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let r=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Number.isFinite(r)&&r>0?r:e||o.width||128,l=Number.isFinite(s)&&s>0?s:n||o.height||16,u=Number.parseFloat(t.min)||0,c=Number.isFinite(Number.parseFloat(t.max))?Number.parseFloat(t.max):100,f=Number.parseFloat(t.value),d=c-u,h=d>0&&Number.isFinite(f)?Math.min(1,Math.max(0,(f-u)/d)):.5,m="middle";try{i&&i.verticalAlign&&(m=i.verticalAlign)}catch{}let g=document.createElement("div");g.setAttribute("data-snapdom-input-replacement","range"),g.style.cssText=`display:inline-block;width:${a}px;height:${l}px;vertical-align:${m};flex-shrink:0;line-height:0;`;let p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.setAttribute("width",String(a)),p.setAttribute("height",String(l)),p.setAttribute("viewBox",`0 0 ${a} ${l}`),p.style.cssText=`width:${a}px;height:${l}px;overflow:visible`,g.appendChild(p);function y(){let b=Hs(i),w=!!t.disabled,S=Math.max(2,Math.min(4,l)),v=(l-S)/2,C=Math.max(10,Math.min(14,Math.max(l,10))),A=C/2,F=A+h*Math.max(0,a-C);p.innerHTML="";let T=(x,E,_,$)=>{let R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(x)),R.setAttribute("y",String(v)),R.setAttribute("width",String(Math.max(0,E))),R.setAttribute("height",String(S)),R.setAttribute("rx",String(S/2)),R.setAttribute("fill",_),$&&R.setAttribute("fill-opacity",$),p.appendChild(R)};T(0,a,"#808080","0.4"),T(0,F,b);let M=document.createElementNS("http://www.w3.org/2000/svg","circle");M.setAttribute("cx",String(F)),M.setAttribute("cy",String(l/2)),M.setAttribute("r",String(A)),M.setAttribute("fill",b),p.appendChild(M),w&&p.setAttribute("opacity","0.5"),g.style.setProperty("width",`${a}px`,"important"),g.style.setProperty("height",`${l}px`,"important"),g.style.setProperty("min-width",`${a}px`,"important"),g.style.setProperty("min-height",`${l}px`,"important")}return y(),{el:g,applyVisual:y}}function Vs(t){let{width:e,height:n}=Et(t),o=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let r=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Math.round(e||o.width||0),l=Math.round(n||o.height||0),u=Number.isFinite(r)&&r>0?Math.round(r):Math.max(12,a||16),c=Number.isFinite(s)&&s>0?Math.round(s):Math.max(12,l||16),f=(t.type||"text").toLowerCase()==="checkbox",d=!!t.checked,h=!!t.indeterminate,g=Math.max(Math.min(u,c),12),p=Math.max(u,g),y=Math.max(c,g),b="middle";try{i&&i.verticalAlign&&(b=i.verticalAlign)}catch{}let w=document.createElement("div");w.setAttribute("data-snapdom-input-replacement",t.type||"checkbox"),w.style.cssText=`display:inline-block;width:${p}px;height:${y}px;vertical-align:${b};flex-shrink:0;line-height:0;`;let S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("width",String(p)),S.setAttribute("height",String(y)),S.setAttribute("viewBox",`0 0 ${g} ${g}`),S.style.cssText=`width:${p}px;height:${y}px`,w.appendChild(S);function v(){let C=Hs(i),A=2,F=A/2,T=g-A;if(S.innerHTML="",f){let M=document.createElementNS("http://www.w3.org/2000/svg","rect");if(M.setAttribute("x",String(F)),M.setAttribute("y",String(F)),M.setAttribute("width",String(T)),M.setAttribute("height",String(T)),M.setAttribute("rx","2"),M.setAttribute("ry","2"),M.setAttribute("fill",d?C:"none"),M.setAttribute("stroke",C),M.setAttribute("stroke-width",String(A)),S.appendChild(M),d){let x=document.createElementNS("http://www.w3.org/2000/svg","path");x.setAttribute("d",`M ${F+2} ${g/2} L ${g/2-1} ${g-F-2} L ${g-F-2} ${F+2}`),x.setAttribute("stroke","white"),x.setAttribute("stroke-width",String(Math.max(1.5,A))),x.setAttribute("fill","none"),x.setAttribute("stroke-linecap","round"),x.setAttribute("stroke-linejoin","round"),S.appendChild(x)}else if(h){let x=document.createElementNS("http://www.w3.org/2000/svg","rect"),E=Math.max(6,T-4);x.setAttribute("x",String((g-E)/2)),x.setAttribute("y",String((g-A)/2)),x.setAttribute("width",String(E)),x.setAttribute("height",String(A)),x.setAttribute("fill",C),x.setAttribute("rx","1"),S.appendChild(x)}}else{let M=document.createElementNS("http://www.w3.org/2000/svg","circle");if(M.setAttribute("cx",String(g/2)),M.setAttribute("cy",String(g/2)),M.setAttribute("r",String((g-A)/2)),M.setAttribute("fill",d?C:"none"),M.setAttribute("stroke",C),M.setAttribute("stroke-width",String(A)),S.appendChild(M),d){let x=document.createElementNS("http://www.w3.org/2000/svg","circle"),E=Math.max(2,(g-A*2)*.35);x.setAttribute("cx",String(g/2)),x.setAttribute("cy",String(g/2)),x.setAttribute("r",String(E)),x.setAttribute("fill","white"),S.appendChild(x)}}w.style.setProperty("width",`${p}px`,"important"),w.style.setProperty("height",`${y}px`,"important"),w.style.setProperty("min-width",`${p}px`,"important"),w.style.setProperty("min-height",`${y}px`,"important")}return v(),{el:w,applyVisual:v}}var Sn=new gt(80);async function iu(t){if(j.resource?.has(t))return j.resource.get(t);if(Sn.has(t))return Sn.get(t);let e=(async()=>{let n=await dt(t,{as:"dataURL"});if(!n.ok||typeof n.data!="string")throw new Error(`Couldn't read ${t}`);return j.resource?.set(t,n.data),n.data})();Sn.set(t,e);try{let n=await e;return Sn.set(t,n),n}catch(n){throw Sn.delete(t),n}}var Ps=/\bblob:[^)"'\s]+/g;function Yn(t){return typeof t=="string"&&t.startsWith("blob:")}function su(t){return(t||"").split(",").map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.match(/^(\S+)(\s+.+)?$/);return n?{url:n[1],desc:n[2]||""}:null}).filter(Boolean)}function au(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}function vn(t,e){let n=t.querySelectorAll?Array.from(t.querySelectorAll(e)):[];return t.matches?.(e)&&n.unshift(t),n}async function Kn(t,e=null){if(!t)return;let n=e,o=new Set,i=[],r=new Map,s=(g,p,y,b)=>{o.add(y),i.push(()=>{r.has(y)&&(g.setAttribute(p,r.get(y)),b?.())})},a=(g,p)=>{if(!g||!g.includes("blob:"))return;let y=g.match(Ps)||[];if(y.length){for(let b of y)o.add(b);i.push(()=>{let b=g.replace(Ps,w=>r.get(w)||w);b!==g&&p(b)})}},l=vn(t,"img");for(let g of l)try{let y=g.getAttribute("src")||g.currentSrc||"";Yn(y)&&s(g,"src",y);let b=g.getAttribute("srcset");if(b&&b.includes("blob:")){let w=su(b);for(let S of w)Yn(S.url)&&o.add(S.url);i.push(()=>{let S=!1;for(let v of w)r.has(v.url)&&(v.url=r.get(v.url),S=!0);S&&g.setAttribute("srcset",au(w))})}}catch(p){D(n,"Couldn't inline a blob: image.",p)}let u=vn(t,"image");for(let g of u)try{let p="http://www.w3.org/1999/xlink",y=g.getAttribute("href")||g.getAttributeNS?.(p,"href");Yn(y)&&s(g,"href",y,()=>g.removeAttributeNS?.(p,"href"))}catch(p){D(n,"Couldn't inline a blob: SVG image.",p)}let c=vn(t,"[style*='blob:']");for(let g of c)try{let p=g.getAttribute("style");a(p,y=>g.setAttribute("style",y))}catch(p){D(n,"Couldn't inline blob: URLs in a style attribute.",p)}let f=vn(t,"style");for(let g of f)try{let p=g.textContent||"";a(p,y=>{g.textContent=y})}catch(p){D(n,"Couldn't inline blob: URLs in a <style>.",p)}let d=["poster"];for(let g of d){let p=vn(t,`[${g}^='blob:']`);for(let y of p)try{let b=y.getAttribute(g);Yn(b)&&s(y,g,b)}catch(b){D(n,`Couldn't inline the blob: URL in ${g}.`,b)}}if(!o.size)return;let h=[...o],m=0;await Promise.all(Array.from({length:Math.min(4,h.length)},async()=>{for(;m<h.length;){let g=h[m++];try{r.set(g,await iu(g))}catch(p){D(n,"Couldn't read a blob: URL; kept it as is.",p)}}}));for(let g of i)try{g()}catch(p){D(n,"Couldn't write an inlined blob: URL.",p)}}var lu=["font-family","font-size","font-style","font-weight","font-stretch","font-variant","font-feature-settings","font-variation-settings","font-kerning","letter-spacing","text-transform"],cu=new Set(["text","search","email","url","tel","number","submit","reset","button"]),fu=/[^\s\uD800-\uDFFF]{2,}/;function Gs(t,e=document){let n=e.defaultView||window;if(!At()||!e.body||!(n.visualViewport?.scale<1||n.screen.width<e.documentElement.clientWidth))return;let o=tt(e.createElement("div"));o.style.cssText="position:absolute;left:0;top:0;width:0;height:0;overflow:hidden;visibility:hidden";let i=[];for(let[r,s]of t){if(r.nodeType!==1||s.nodeType!==1)continue;let a=n.getComputedStyle(s),l=s.localName==="textarea"||s.localName==="input"&&cu.has(s.type)?du(s,a,e):uu(s,a.textAlign==="justify"||a.textAlignLast==="justify");if(!l)continue;let u=s.getBoundingClientRect(),c=s.offsetWidth&&u.width?u.width/s.offsetWidth:1,f=e.createElement("span");f.style.whiteSpace="pre";for(let d of lu)f.style.setProperty(d,a.getPropertyValue(d));f.textContent=l.word,o.appendChild(f),i.push({clone:r,cs:a,span:f,live:l.distance/c,centers:l.centers,height:l.height})}if(i.length){e.body.appendChild(o);try{for(let{clone:r,cs:s,span:a,live:l,centers:u,height:c}of i){let f=a.firstChild,d=(parseFloat(s.letterSpacing)||0)*(u?f.length-1:f.length),h=c?e.createRange():null;h&&h.selectNodeContents(a);let m=c?h.getBoundingClientRect().height:u?Math.abs(Ns(f,f.length-1)-Ns(f,0)):a.getBoundingClientRect().width,g=(l-(c?0:d))/(m-(c?0:d));if(g>1.005&&Number.isFinite(g)){if(c){let p=[];for(let y of[!1,!0]){let b=parseFloat(s.fontSize),w=b*(g+1);for(let S=0;S<10;S++){let v=(b+w)/2;a.style.fontSize=`${v}px`;let C=h.getBoundingClientRect().height;(y?C>l:C>=l)?w=v:b=v}p.push((b+w)/2)}g=(p[0]+p[1])/2/parseFloat(s.fontSize)}r.style.setProperty("font-size",`${parseFloat(s.fontSize)*g}px`),s.lineHeight!=="normal"&&r.style.setProperty("line-height",`${parseFloat(s.lineHeight)*g}px`)}}}finally{o.remove()}}}function Ns(t,e){let n=t.ownerDocument.createRange();n.setStart(t,e),n.setEnd(t,e+1);let o=n.getBoundingClientRect();return o.left+o.width/2}function uu(t,e=!1){for(let n=t.firstChild;n;n=n.nextSibling){if(n.nodeType!==3)continue;let o=/\S+/.exec(n.data);if(!o)continue;let i=t.ownerDocument.createRange();i.setStart(n,o.index),i.setEnd(n,o.index+o[0].length);let r=i.getClientRects();return r.length===1?{word:o[0],distance:e?r[0].height:r[0].width,centers:!1,height:e}:null}return null}function du(t,e,n){let o=fu.exec(t.value.split(`
`)[0]);if(!o||t.scrollLeft||t.scrollTop||!n.caretPositionFromPoint)return null;let i=t.getBoundingClientRect(),r=t.localName==="textarea"?i.top+(parseFloat(e.borderTopWidth)||0)+(parseFloat(e.paddingTop)||0)+3:i.top+i.height/2,s=c=>{let f=n.caretPositionFromPoint(c,r);return f&&f.offsetNode===t?f.offset:-1},a=i.width/16,l=c=>{let f=i.left;for(;f<=i.right&&s(f)<c;)f+=a;if(f>i.right)return NaN;let d=f-a;for(let h=0;h<16;h++){let m=(d+f)/2;s(m)>=c?f=m:d=m}return f},u=Math.abs(l(o.index+o[0].length)-l(o.index+1));return Number.isFinite(u)?{word:o[0],distance:u,centers:!0}:null}yt();var qs=new Set(["rgba(0, 0, 0, 0)","transparent"]),vr="Highlight";function Xs(t){let n=(t.ownerDocument||document).getSelection?.();if(!n||n.isCollapsed||n.rangeCount===0)return null;let o=[];for(let i=0;i<n.rangeCount;i+=1){let r=n.getRangeAt(i);if(!r.collapsed)try{r.intersectsNode(t)&&o.push(r)}catch{}}return o.length?{ranges:o,styles:new Map}:null}function pu(t,e){if(e.styles.has(t))return e.styles.get(t);let n;try{let o=getComputedStyle(t);if(o.userSelect==="none"||o.webkitUserSelect==="none"||o.getPropertyValue("-webkit-user-select")==="none")return e.styles.set(t,null),null;let i=getComputedStyle(t,"::selection"),r=[],s=i.backgroundColor,a=s&&!qs.has(s)&&s!==o.backgroundColor;r.push(`background-color:${a?s:vr}`),i.color&&i.color!==o.color&&r.push(`color:${i.color}`,`-webkit-text-fill-color:${i.color}`),i.textShadow&&i.textShadow!==o.textShadow&&r.push(`text-shadow:${i.textShadow}`),i.textDecorationLine&&i.textDecorationLine!=="none"&&i.textDecorationLine!==o.textDecorationLine&&r.push(`text-decoration:${i.textDecorationLine} ${i.textDecorationStyle||"solid"} ${i.textDecorationColor||"currentcolor"}`),n=r.join(";")}catch{n=`background-color:${vr}`}return e.styles.set(t,n),n}function Ys(t,e){let n=t.data;if(!n)return null;let o=t.parentElement;if(!o)return null;let i=[];for(let u of e.ranges){let c=!1;try{c=u.intersectsNode(t)}catch{}if(!c)continue;let f=u.startContainer===t?u.startOffset:0,d=u.endContainer===t?u.endOffset:n.length;d>f&&i.push([f,d])}if(i.length===0)return null;let r=pu(o,e);if(!r)return null;i.sort((u,c)=>u[0]-c[0]);let s=t.ownerDocument||document,a=s.createDocumentFragment(),l=0;for(let[u,c]of i){u>l&&a.append(s.createTextNode(n.slice(l,u)));let f=s.createElement("span");f.setAttribute("data-snapdom-selection",""),f.setAttribute("style",`all:unset;${r}`),f.textContent=n.slice(u,c),a.append(f),l=c}return l<n.length&&a.append(s.createTextNode(n.slice(l))),a}var Jn=t=>Number.parseFloat(t)||0,hu=["font-family","font-size","font-weight","font-style","font-variant","font-stretch","letter-spacing","word-spacing","text-transform","text-indent","text-align","line-height","tab-size","direction"];function mu(t,e){try{let o=getComputedStyle(t,"::selection").backgroundColor;if(o&&!qs.has(o)&&o!==e.backgroundColor)return o}catch{}return vr}function Ks(t,e){let n=t.ownerDocument||document;if(n.activeElement!==t)return;let o=null,i=null;try{o=t.selectionStart,i=t.selectionEnd}catch{return}if(o==null||i==null||o===i)return;let r=t.value||"";if(t.localName==="input"&&t.type==="password"&&(r="\u2022".repeat(r.length)),!r)return;let s=getComputedStyle(t),a=t.localName==="textarea",l=Jn(s.paddingLeft),u=Jn(s.paddingTop),c=t.clientWidth-l-Jn(s.paddingRight),f=t.clientHeight-u-Jn(s.paddingBottom),d=n.createElement("div");d.style.cssText="position:absolute;top:0;left:-99999px;visibility:hidden;margin:0;border:0;padding:0;box-sizing:content-box;";for(let p of hu)d.style.setProperty(p,s.getPropertyValue(p));a?(d.style.whiteSpace="pre-wrap",d.style.overflowWrap="break-word",d.style.width=`${Math.max(0,c)}px`):d.style.whiteSpace="pre";let h=n.createElement("span");h.textContent=r.slice(o,i),d.append(n.createTextNode(r.slice(0,o)),h,n.createTextNode(r.slice(i))),n.body.appendChild(d);let m=[];try{let p=d.getBoundingClientRect(),y=-t.scrollLeft,b=-t.scrollTop;if(!a){b+=Math.max(0,(f-p.height)/2);let w=s.direction==="rtl",S=s.textAlign;S==="start"?S=w?"right":"left":S==="end"&&(S=w?"left":"right");let v=c-p.width;v>0&&(S==="right"?y+=v:S==="center"&&(y+=v/2))}for(let w of h.getClientRects())w.width<=0||w.height<=0||m.push({x:l+(w.left-p.left)+y,y:u+(w.top-p.top)+b,width:w.width,height:w.height})}finally{d.remove()}if(m.length===0)return;let g=mu(t,s);e.__snapdomFieldSelection={images:m.map(()=>`linear-gradient(${g},${g})`),positions:m.map(p=>`${p.x}px ${p.y}px`),sizes:m.map(p=>`${p.width}px ${p.height}px`),repeats:m.map(()=>"no-repeat"),origins:m.map(()=>"padding-box"),clips:m.map(()=>"padding-box"),base:{image:s.backgroundImage,position:s.backgroundPosition,size:s.backgroundSize,repeat:s.backgroundRepeat,origin:s.backgroundOrigin,clip:s.backgroundClip}}}function Js(t){for(let e of t.keys()){let n=e.__snapdomFieldSelection;if(!n)continue;delete e.__snapdomFieldSelection;let{images:o,positions:i,sizes:r,repeats:s,origins:a,clips:l,base:u}=n,c=e.style.backgroundImage||u.image;c&&c!=="none"?(o.push(c),i.push(e.style.backgroundPosition||u.position),r.push(e.style.backgroundSize||u.size),s.push(e.style.backgroundRepeat||u.repeat),a.push(e.style.backgroundOrigin||u.origin),l.push(e.style.backgroundClip||u.clip)):(o.push("linear-gradient(transparent,transparent)"),i.push("0% 0%"),r.push("auto"),s.push("repeat"),a.push(u.origin||"padding-box"),l.push(u.clip||"border-box")),e.style.backgroundImage=o.join(","),e.style.backgroundPosition=i.join(","),e.style.backgroundSize=r.join(","),e.style.backgroundRepeat=s.join(","),e.style.backgroundOrigin=a.join(","),e.style.backgroundClip=l.join(",")}}Tt();vt();var gu=["transform","translate","rotate","scale","transform-origin","transform-box"],yu={circle:["cx","cy","r","vector-effect"],ellipse:["cx","cy","rx","ry","vector-effect"],rect:["x","y","width","height","rx","ry","vector-effect"],path:["d","vector-effect"],line:["vector-effect"],polyline:["vector-effect"],polygon:["vector-effect"],use:["x","y","width","height","vector-effect"],g:[],clipPath:[]},bu={r:"0px",cx:"0px",cy:"0px",x:"0px",y:"0px",rx:"auto",ry:"auto",width:"auto",height:"auto",d:"none","vector-effect":"none",transform:"none",translate:"none",rotate:"none",scale:"none","transform-origin":"0px 0px","transform-box":"view-box"},Qs=new Set(["transform","translate","rotate","scale"]),Zs=new WeakMap,wu=new Map;function xu(t){let e=t.localName,n=yu[e];if(!n)return null;let o=gs(t);if(o&&(o.size===0||!ys(t)))return null;let i=o?Zs.get(o):wu;i||Zs.set(o,i=new Map);let r=i.get(e);return r||(r=[...n,...gu].filter(s=>!o||o.has(s)),i.set(e,r)),r.length?r:null}var ta=/^-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?$/i;function Su(t,e){let n=t.trim();if(!ta.test(n)||!ta.test(e))return!1;let o=parseFloat(n),i=parseFloat(e);return Math.abs(o-i)<=1e-4*Math.max(1,Math.abs(o))}function vu(t){let e=t.transform?.baseVal;if(!e?.numberOfItems)return null;let n=new DOMMatrix;for(let o=0;o<e.numberOfItems;o++){let i=e.getItem(o).matrix;n=n.multiply(new DOMMatrix([i.a,i.b,i.c,i.d,i.e,i.f]))}return n}function Cu(t,e){let n=vu(t),o=e==="none"?[1,0,0,1,0,0]:e.startsWith("matrix(")?e.slice(7,-1).split(",").map(Number):null;if(!o||o.length!==6)return!1;if(!n)return o.join()==="1,0,0,1,0,0";let i=[n.a,n.b,n.c,n.d,n.e,n.f];for(let r=0;r<6;r++)if(Math.abs(i[r]-o[r])>1e-4*Math.max(1,Math.abs(i[r])))return!1;return!0}function ku(t,e,n,o){let i=!1;for(let r of o){if(!i&&(r==="transform-origin"||r==="transform-box")&&!t.hasAttribute("transform"))continue;let s=n.getPropertyValue(r);if(!s)continue;Qs.has(r)&&s!=="none"&&(i=!0);let a=Qs.has(r)&&r!=="transform"?null:t.getAttribute(r);if(a!=null){if(s===a||s===a+"px"||r==="d"||r==="transform"&&(s==="none"||Cu(t,s))||Su(a,s))continue}else if(s===bu[r])continue;e.style.setProperty(r,s)}}var Cr=new Map,ea=new Set(["IFRAME"]);function je(t,e){Cr.set(String(t).toUpperCase(),e)}function Qn(t){let e=W(t),n=e.display;if(n==="none")return null;let o=/^(block|inline-block|flow-root|flex|inline-flex|grid|inline-grid|list-item)$/.test(n),i=h=>parseFloat(h)||0,r=(h,m,g,p,y)=>{if(!o||!h?.endsWith("px"))return null;let b=parseFloat(h);if(!Number.isFinite(b)||b<0)return null;if(e.boxSizing==="border-box")return b;let w=p-y-g;return b+m+g+(w>0&&b+m<y+w/2?w:0)},[s,a,l,u]=/scroll|auto/.test(e.overflow)?[t.offsetWidth,t.clientWidth,t.offsetHeight,t.clientHeight]:[0,0,0,0],c=r(e.width,i(e.paddingLeft)+i(e.paddingRight),i(e.borderLeftWidth)+i(e.borderRightWidth),s,a),f=r(e.height,i(e.paddingTop)+i(e.paddingBottom),i(e.borderTopWidth)+i(e.borderBottomWidth),l,u);if(c===null||f===null){let{width:h,height:m}=Et(t),g=h,p=m;if(c===null&&!g||f===null&&!p){let y=t.getBoundingClientRect();g||=y.width||0,p||=y.height||0}c??=g,f??=p}let d=document.createElement("div");return d.style.cssText=`display:${n==="inline"?"inline-block":n};box-sizing:border-box;width:${c}px;height:${f}px;visibility:hidden;`,d}var Mu=new Set(["style","option","optgroup"]),Zn=200,Au=new Set(["img","canvas","video","iframe","object","embed"]);function Cn(t){let e=0;for(let n of t.matchAll(/-?[\d.]+px/g))e+=Math.abs(parseFloat(n[0]));return e}function sa(t){let e=t.filter;return!e||e==="none"?0:e.includes("url(")?Zn:3*Cn(e)}function aa(t,e){if(!t)return 0;let n=e.filterReach||=new WeakMap,o=n.get(t);return o===void 0&&(o=sa(W(t))+(t===e.root?0:aa(t.parentElement,e)),n.set(t,o)),o}function na(t,e,n){try{if(!e||!t.matches(e))return!1}catch{return!0}let o=W(t,n).content;return!!o&&o!=="none"&&o!=="normal"}function _u(t,e,n){let{before:o,after:i}=ae(t);if(o===null||i===null||na(t,o,"::before")||na(t,i,"::after")||e.borderImageSource&&e.borderImageSource!=="none"||e.webkitBoxReflect&&e.webkitBoxReflect!=="none")return Zn;let r=parseFloat(e.fontSize)||16,s=e.outlineStyle==="none"?0:Cn(e.outlineWidth)+Cn(e.outlineOffset);return Math.max(r*(e.display==="list-item"?3:1),s,Cn(e.boxShadow),Cn(e.textShadow),sa(e))+aa(t.parentElement,n)}function oa(t,e,n,o){let i=o.rect,r=Math.max(i.left-n.right,n.left-i.right,i.top-n.bottom,n.top-i.bottom);if(r<=0)return!0;if(r>Zn)return!1;let s=o.inkReach||=new WeakMap,a=s.get(t);return a===void 0&&s.set(t,a=_u(t,e||W(t),o)),r<=a}function Eu(t,e){if(t===e.root)return!1;let n;try{n=t.getBoundingClientRect()}catch{return!1}if(n.width===0&&n.height===0)return!1;let o=W(t);if(o.display==="inline"&&!Au.has((t.localName||"").toLowerCase()))return!1;let i=t.scrollWidth||0,r=t.scrollHeight||0,s={left:o.directi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (javascript.browser.security.insecure-document-method): User controlled data in methods like innerHTML, outerHTML or document.write is an anti-pattern that can lead to XSS vulnerabilities

Source: opengrep

`;return e}function Os(t){let e="";try{t.querySelectorAll("style").forEach(o=>{let i=null;try{i=o.sheet&&o.sheet.cssRules}catch{}e+=(i?Se(i):o.textContent||"")+`
`});let n=t.adoptedStyleSheets||[];for(let o of n)try{o&&o.cssRules&&(e+=Se(o.cssRules))}catch{}}catch{}return e}function Ws(t,e,n){if(!e)return;let o=document.createElement("style");o.setAttribute("data-sd",n),o.textContent=e,t.insertBefore(o,t.firstChild||null)}function Ds(t,e,n={}){try{let o=null,i=W(t).content;if(i&&i.includes("url(")){let u=i.match(/url\(["']?([^"')]+)["']?\)/);u&&(o=u[1])}let r=t.closest?.("picture"),s=t.getAttribute("src")||"",a=t.getAttribute("srcset")||"",l=o||(r?Fs(t,r):!a.trim()&&s.startsWith("data:")?s:t.currentSrc)||He(a,t)||t.src||"";if((!l||ze(l))&&n.resolvePicturePlaceholders!==!1){let u=Ts(t);u&&(l=u)}if(!l)return;e.getAttribute("src")!==l&&e.setAttribute("src",l),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}function Bs(t){let e=new Set;if(!t)return e;let n=/var\(\s*(--[A-Za-z0-9_-]+)\b/g,o;for(;o=n.exec(t);)e.add(o[1]);return e}function eu(t,e){try{let o=getComputedStyle(t).getPropertyValue(e).trim();if(o)return o}catch{}try{let o=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(o)return o}catch{}return""}function Us(t,e,n){let o=[];for(let i of e){let r=eu(t,i);r&&o.push(`${i}: ${r};`)}return o.length?`${n}{${o.join("")}}
`:""}function zs(t,e){if(!t)return;let n=o=>{let i=o.getAttribute("data-sd-slotted")||"";e?` ${i} `.includes(` ${e} `)||o.setAttribute("data-sd-slotted",i?`${i} ${e}`:e):o.setAttribute("data-sd-slotted",i)};t.nodeType===Node.ELEMENT_NODE&&n(t),t.querySelectorAll?.("*").forEach(n)}async function nu(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},o=n(),i=0;for(;i<e&&(!o||!o.body&&!o.documentElement);)await new Promise(r=>setTimeout(r,0)),o=n(),i++;return o&&(o.body||o.documentElement)?o:null}function ou(t){let e=t.getBoundingClientRect(),n=0,o=0,i=0,r=0;try{let l=getComputedStyle(t);n=parseFloat(l.borderLeftWidth)||0,o=parseFloat(l.borderRightWidth)||0,i=parseFloat(l.borderTopWidth)||0,r=parseFloat(l.borderBottomWidth)||0}catch{}let s=Math.max(0,Math.round(e.width-(n+o))),a=Math.max(0,Math.round(e.height-(i+r)));return{contentWidth:s,contentHeight:a,rect:e}}function Et(t){let e=0,n=0;if(t.offsetWidth>0&&(e=t.offsetWidth),t.offsetHeight>0&&(n=t.offsetHeight),e===0||n===0)try{let o=getComputedStyle(t);if(e===0){let i=parseFloat(o.width);!isNaN(i)&&i>0&&(e=i)}if(n===0){let i=parseFloat(o.height);!isNaN(i)&&i>0&&(n=i)}}catch{}if(e===0||n===0)try{if(e===0){let o=parseFloat(t.getAttribute("width"));!isNaN(o)&&o>0&&(e=o)}if(n===0){let o=parseFloat(t.getAttribute("height"));!isNaN(o)&&o>0&&(n=o)}}catch{}if((e===0||n===0)&&(t.naturalWidth||t.naturalHeight))try{e===0&&t.naturalWidth>0&&(e=t.naturalWidth),n===0&&t.naturalHeight>0&&(n=t.naturalHeight)}catch{}return{width:e,height:n}}var $s=new WeakMap;function ru(t,e,n){let o=t.defaultView,i=o?o.scrollX:0,r=o?o.scrollY:0,s=t.body?t.body.scrollLeft:0,a=t.body?t.body.scrollTop:0,l=t.documentElement?t.documentElement.scrollLeft:0,u=t.documentElement?t.documentElement.scrollTop:0,c=0,f=0,d=0,h=0;try{let p=o&&t.body?o.getComputedStyle(t.body):null;p&&(c=(parseFloat(p.marginTop)||0)+(parseFloat(p.paddingTop)||0),f=(parseFloat(p.marginRight)||0)+(parseFloat(p.paddingRight)||0),d=(parseFloat(p.marginBottom)||0)+(parseFloat(p.paddingBottom)||0),h=(parseFloat(p.marginLeft)||0)+(parseFloat(p.paddingLeft)||0))}catch{}let m=`html {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}body {margin: 0 !important;padding: ${c}px ${f}px ${d}px ${h}px !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,g;try{let p=$s.get(t);p||$s.set(t,p=new o.CSSStyleSheet),p.replaceSync(m),t.adoptedStyleSheets=[...t.adoptedStyleSheets,p],g=()=>{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(y=>y!==p)}}catch{let p=t.createElement("style");p.setAttribute("data-sd-iframe-pin",""),tt(p),p.textContent=m,(t.head||t.documentElement).appendChild(p),g=()=>p.remove()}if(xe(t.documentElement),i||r)try{t.body&&(t.body.scrollLeft=i,t.body.scrollTop=r),t.documentElement&&(t.documentElement.scrollLeft||(t.documentElement.scrollLeft=i),t.documentElement.scrollTop||(t.documentElement.scrollTop=r))}catch{}return()=>{try{g()}catch{}try{o&&typeof o.scrollTo=="function"&&o.scrollTo(i,r),t.body&&(t.body.scrollLeft=s,t.body.scrollTop=a),t.documentElement&&(t.documentElement.scrollLeft=l,t.documentElement.scrollTop=u)}catch{}xe(t.documentElement)}}async function Sr(t,e,n){let o=await nu(t,3);if(!o)throw new Error("The iframe document isn't ready.");let{contentWidth:i,contentHeight:r,rect:s}=ou(t),a=n?.snap;if(!a||typeof a.toPng!="function")throw new Error("Iframes are only captured through snapdom(el).");let l={...n,scale:1,clip:null,__pinned:!0},u=ru(o,i,r),c;try{c=await a.toPng(o.documentElement,l)}finally{u()}c.style.display="block",c.style.width=`${i}px`,c.style.height=`${r}px`;let f=document.createElement("div");return e.nodeMap.set(f,t),wt(t,f,e,n),f.style.overflow="hidden",f.style.display="block",f.style.width||(f.style.width=`${Math.round(s.width)}px`),f.style.height||(f.style.height=`${Math.round(s.height)}px`),f.appendChild(c),f}function Hs(t){try{let e=t&&t.accentColor;if(e&&e!=="auto"&&e!=="none")return e;let n=t&&t.color;if(n)return n}catch{}return"#0a6ed1"}function js(t){let{width:e,height:n}=Et(t),o=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let r=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Number.isFinite(r)&&r>0?r:e||o.width||128,l=Number.isFinite(s)&&s>0?s:n||o.height||16,u=Number.parseFloat(t.min)||0,c=Number.isFinite(Number.parseFloat(t.max))?Number.parseFloat(t.max):100,f=Number.parseFloat(t.value),d=c-u,h=d>0&&Number.isFinite(f)?Math.min(1,Math.max(0,(f-u)/d)):.5,m="middle";try{i&&i.verticalAlign&&(m=i.verticalAlign)}catch{}let g=document.createElement("div");g.setAttribute("data-snapdom-input-replacement","range"),g.style.cssText=`display:inline-block;width:${a}px;height:${l}px;vertical-align:${m};flex-shrink:0;line-height:0;`;let p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.setAttribute("width",String(a)),p.setAttribute("height",String(l)),p.setAttribute("viewBox",`0 0 ${a} ${l}`),p.style.cssText=`width:${a}px;height:${l}px;overflow:visible`,g.appendChild(p);function y(){let b=Hs(i),w=!!t.disabled,S=Math.max(2,Math.min(4,l)),v=(l-S)/2,C=Math.max(10,Math.min(14,Math.max(l,10))),A=C/2,F=A+h*Math.max(0,a-C);p.innerHTML="";let T=(x,E,_,$)=>{let R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(x)),R.setAttribute("y",String(v)),R.setAttribute("width",String(Math.max(0,E))),R.setAttribute("height",String(S)),R.setAttribute("rx",String(S/2)),R.setAttribute("fill",_),$&&R.setAttribute("fill-opacity",$),p.appendChild(R)};T(0,a,"#808080","0.4"),T(0,F,b);let M=document.createElementNS("http://www.w3.org/2000/svg","circle");M.setAttribute("cx",String(F)),M.setAttribute("cy",String(l/2)),M.setAttribute("r",String(A)),M.setAttribute("fill",b),p.appendChild(M),w&&p.setAttribute("opacity","0.5"),g.style.setProperty("width",`${a}px`,"important"),g.style.setProperty("height",`${l}px`,"important"),g.style.setProperty("min-width",`${a}px`,"important"),g.style.setProperty("min-height",`${l}px`,"important")}return y(),{el:g,applyVisual:y}}function Vs(t){let{width:e,height:n}=Et(t),o=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let r=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Math.round(e||o.width||0),l=Math.round(n||o.height||0),u=Number.isFinite(r)&&r>0?Math.round(r):Math.max(12,a||16),c=Number.isFinite(s)&&s>0?Math.round(s):Math.max(12,l||16),f=(t.type||"text").toLowerCase()==="checkbox",d=!!t.checked,h=!!t.indeterminate,g=Math.max(Math.min(u,c),12),p=Math.max(u,g),y=Math.max(c,g),b="middle";try{i&&i.verticalAlign&&(b=i.verticalAlign)}catch{}let w=document.createElement("div");w.setAttribute("data-snapdom-input-replacement",t.type||"checkbox"),w.style.cssText=`display:inline-block;width:${p}px;height:${y}px;vertical-align:${b};flex-shrink:0;line-height:0;`;let S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("width",String(p)),S.setAttribute("height",String(y)),S.setAttribute("viewBox",`0 0 ${g} ${g}`),S.style.cssText=`width:${p}px;height:${y}px`,w.appendChild(S);function v(){let C=Hs(i),A=2,F=A/2,T=g-A;if(S.innerHTML="",f){let M=document.createElementNS("http://www.w3.org/2000/svg","rect");if(M.setAttribute("x",String(F)),M.setAttribute("y",String(F)),M.setAttribute("width",String(T)),M.setAttribute("height",String(T)),M.setAttribute("rx","2"),M.setAttribute("ry","2"),M.setAttribute("fill",d?C:"none"),M.setAttribute("stroke",C),M.setAttribute("stroke-width",String(A)),S.appendChild(M),d){let x=document.createElementNS("http://www.w3.org/2000/svg","path");x.setAttribute("d",`M ${F+2} ${g/2} L ${g/2-1} ${g-F-2} L ${g-F-2} ${F+2}`),x.setAttribute("stroke","white"),x.setAttribute("stroke-width",String(Math.max(1.5,A))),x.setAttribute("fill","none"),x.setAttribute("stroke-linecap","round"),x.setAttribute("stroke-linejoin","round"),S.appendChild(x)}else if(h){let x=document.createElementNS("http://www.w3.org/2000/svg","rect"),E=Math.max(6,T-4);x.setAttribute("x",String((g-E)/2)),x.setAttribute("y",String((g-A)/2)),x.setAttribute("width",String(E)),x.setAttribute("height",String(A)),x.setAttribute("fill",C),x.setAttribute("rx","1"),S.appendChild(x)}}else{let M=document.createElementNS("http://www.w3.org/2000/svg","circle");if(M.setAttribute("cx",String(g/2)),M.setAttribute("cy",String(g/2)),M.setAttribute("r",String((g-A)/2)),M.setAttribute("fill",d?C:"none"),M.setAttribute("stroke",C),M.setAttribute("stroke-width",String(A)),S.appendChild(M),d){let x=document.createElementNS("http://www.w3.org/2000/svg","circle"),E=Math.max(2,(g-A*2)*.35);x.setAttribute("cx",String(g/2)),x.setAttribute("cy",String(g/2)),x.setAttribute("r",String(E)),x.setAttribute("fill","white"),S.appendChild(x)}}w.style.setProperty("width",`${p}px`,"important"),w.style.setProperty("height",`${y}px`,"important"),w.style.setProperty("min-width",`${p}px`,"important"),w.style.setProperty("min-height",`${y}px`,"important")}return v(),{el:w,applyVisual:v}}var Sn=new gt(80);async function iu(t){if(j.resource?.has(t))return j.resource.get(t);if(Sn.has(t))return Sn.get(t);let e=(async()=>{let n=await dt(t,{as:"dataURL"});if(!n.ok||typeof n.data!="string")throw new Error(`Couldn't read ${t}`);return j.resource?.set(t,n.data),n.data})();Sn.set(t,e);try{let n=await e;return Sn.set(t,n),n}catch(n){throw Sn.delete(t),n}}var Ps=/\bblob:[^)"'\s]+/g;function Yn(t){return typeof t=="string"&&t.startsWith("blob:")}function su(t){return(t||"").split(",").map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.match(/^(\S+)(\s+.+)?$/);return n?{url:n[1],desc:n[2]||""}:null}).filter(Boolean)}function au(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}function vn(t,e){let n=t.querySelectorAll?Array.from(t.querySelectorAll(e)):[];return t.matches?.(e)&&n.unshift(t),n}async function Kn(t,e=null){if(!t)return;let n=e,o=new Set,i=[],r=new Map,s=(g,p,y,b)=>{o.add(y),i.push(()=>{r.has(y)&&(g.setAttribute(p,r.get(y)),b?.())})},a=(g,p)=>{if(!g||!g.includes("blob:"))return;let y=g.match(Ps)||[];if(y.length){for(let b of y)o.add(b);i.push(()=>{let b=g.replace(Ps,w=>r.get(w)||w);b!==g&&p(b)})}},l=vn(t,"img");for(let g of l)try{let y=g.getAttribute("src")||g.currentSrc||"";Yn(y)&&s(g,"src",y);let b=g.getAttribute("srcset");if(b&&b.includes("blob:")){let w=su(b);for(let S of w)Yn(S.url)&&o.add(S.url);i.push(()=>{let S=!1;for(let v of w)r.has(v.url)&&(v.url=r.get(v.url),S=!0);S&&g.setAttribute("srcset",au(w))})}}catch(p){D(n,"Couldn't inline a blob: image.",p)}let u=vn(t,"image");for(let g of u)try{let p="http://www.w3.org/1999/xlink",y=g.getAttribute("href")||g.getAttributeNS?.(p,"href");Yn(y)&&s(g,"href",y,()=>g.removeAttributeNS?.(p,"href"))}catch(p){D(n,"Couldn't inline a blob: SVG image.",p)}let c=vn(t,"[style*='blob:']");for(let g of c)try{let p=g.getAttribute("style");a(p,y=>g.setAttribute("style",y))}catch(p){D(n,"Couldn't inline blob: URLs in a style attribute.",p)}let f=vn(t,"style");for(let g of f)try{let p=g.textContent||"";a(p,y=>{g.textContent=y})}catch(p){D(n,"Couldn't inline blob: URLs in a <style>.",p)}let d=["poster"];for(let g of d){let p=vn(t,`[${g}^='blob:']`);for(let y of p)try{let b=y.getAttribute(g);Yn(b)&&s(y,g,b)}catch(b){D(n,`Couldn't inline the blob: URL in ${g}.`,b)}}if(!o.size)return;let h=[...o],m=0;await Promise.all(Array.from({length:Math.min(4,h.length)},async()=>{for(;m<h.length;){let g=h[m++];try{r.set(g,await iu(g))}catch(p){D(n,"Couldn't read a blob: URL; kept it as is.",p)}}}));for(let g of i)try{g()}catch(p){D(n,"Couldn't write an inlined blob: URL.",p)}}var lu=["font-family","font-size","font-style","font-weight","font-stretch","font-variant","font-feature-settings","font-variation-settings","font-kerning","letter-spacing","text-transform"],cu=new Set(["text","search","email","url","tel","number","submit","reset","button"]),fu=/[^\s\uD800-\uDFFF]{2,}/;function Gs(t,e=document){let n=e.defaultView||window;if(!At()||!e.body||!(n.visualViewport?.scale<1||n.screen.width<e.documentElement.clientWidth))return;let o=tt(e.createElement("div"));o.style.cssText="position:absolute;left:0;top:0;width:0;height:0;overflow:hidden;visibility:hidden";let i=[];for(let[r,s]of t){if(r.nodeType!==1||s.nodeType!==1)continue;let a=n.getComputedStyle(s),l=s.localName==="textarea"||s.localName==="input"&&cu.has(s.type)?du(s,a,e):uu(s,a.textAlign==="justify"||a.textAlignLast==="justify");if(!l)continue;let u=s.getBoundingClientRect(),c=s.offsetWidth&&u.width?u.width/s.offsetWidth:1,f=e.createElement("span");f.style.whiteSpace="pre";for(let d of lu)f.style.setProperty(d,a.getPropertyValue(d));f.textContent=l.word,o.appendChild(f),i.push({clone:r,cs:a,span:f,live:l.distance/c,centers:l.centers,height:l.height})}if(i.length){e.body.appendChild(o);try{for(let{clone:r,cs:s,span:a,live:l,centers:u,height:c}of i){let f=a.firstChild,d=(parseFloat(s.letterSpacing)||0)*(u?f.length-1:f.length),h=c?e.createRange():null;h&&h.selectNodeContents(a);let m=c?h.getBoundingClientRect().height:u?Math.abs(Ns(f,f.length-1)-Ns(f,0)):a.getBoundingClientRect().width,g=(l-(c?0:d))/(m-(c?0:d));if(g>1.005&&Number.isFinite(g)){if(c){let p=[];for(let y of[!1,!0]){let b=parseFloat(s.fontSize),w=b*(g+1);for(let S=0;S<10;S++){let v=(b+w)/2;a.style.fontSize=`${v}px`;let C=h.getBoundingClientRect().height;(y?C>l:C>=l)?w=v:b=v}p.push((b+w)/2)}g=(p[0]+p[1])/2/parseFloat(s.fontSize)}r.style.setProperty("font-size",`${parseFloat(s.fontSize)*g}px`),s.lineHeight!=="normal"&&r.style.setProperty("line-height",`${parseFloat(s.lineHeight)*g}px`)}}}finally{o.remove()}}}function Ns(t,e){let n=t.ownerDocument.createRange();n.setStart(t,e),n.setEnd(t,e+1);let o=n.getBoundingClientRect();return o.left+o.width/2}function uu(t,e=!1){for(let n=t.firstChild;n;n=n.nextSibling){if(n.nodeType!==3)continue;let o=/\S+/.exec(n.data);if(!o)continue;let i=t.ownerDocument.createRange();i.setStart(n,o.index),i.setEnd(n,o.index+o[0].length);let r=i.getClientRects();return r.length===1?{word:o[0],distance:e?r[0].height:r[0].width,centers:!1,height:e}:null}return null}function du(t,e,n){let o=fu.exec(t.value.split(`
`)[0]);if(!o||t.scrollLeft||t.scrollTop||!n.caretPositionFromPoint)return null;let i=t.getBoundingClientRect(),r=t.localName==="textarea"?i.top+(parseFloat(e.borderTopWidth)||0)+(parseFloat(e.paddingTop)||0)+3:i.top+i.height/2,s=c=>{let f=n.caretPositionFromPoint(c,r);return f&&f.offsetNode===t?f.offset:-1},a=i.width/16,l=c=>{let f=i.left;for(;f<=i.right&&s(f)<c;)f+=a;if(f>i.right)return NaN;let d=f-a;for(let h=0;h<16;h++){let m=(d+f)/2;s(m)>=c?f=m:d=m}return f},u=Math.abs(l(o.index+o[0].length)-l(o.index+1));return Number.isFinite(u)?{word:o[0],distance:u,centers:!0}:null}yt();var qs=new Set(["rgba(0, 0, 0, 0)","transparent"]),vr="Highlight";function Xs(t){let n=(t.ownerDocument||document).getSelection?.();if(!n||n.isCollapsed||n.rangeCount===0)return null;let o=[];for(let i=0;i<n.rangeCount;i+=1){let r=n.getRangeAt(i);if(!r.collapsed)try{r.intersectsNode(t)&&o.push(r)}catch{}}return o.length?{ranges:o,styles:new Map}:null}function pu(t,e){if(e.styles.has(t))return e.styles.get(t);let n;try{let o=getComputedStyle(t);if(o.userSelect==="none"||o.webkitUserSelect==="none"||o.getPropertyValue("-webkit-user-select")==="none")return e.styles.set(t,null),null;let i=getComputedStyle(t,"::selection"),r=[],s=i.backgroundColor,a=s&&!qs.has(s)&&s!==o.backgroundColor;r.push(`background-color:${a?s:vr}`),i.color&&i.color!==o.color&&r.push(`color:${i.color}`,`-webkit-text-fill-color:${i.color}`),i.textShadow&&i.textShadow!==o.textShadow&&r.push(`text-shadow:${i.textShadow}`),i.textDecorationLine&&i.textDecorationLine!=="none"&&i.textDecorationLine!==o.textDecorationLine&&r.push(`text-decoration:${i.textDecorationLine} ${i.textDecorationStyle||"solid"} ${i.textDecorationColor||"currentcolor"}`),n=r.join(";")}catch{n=`background-color:${vr}`}return e.styles.set(t,n),n}function Ys(t,e){let n=t.data;if(!n)return null;let o=t.parentElement;if(!o)return null;let i=[];for(let u of e.ranges){let c=!1;try{c=u.intersectsNode(t)}catch{}if(!c)continue;let f=u.startContainer===t?u.startOffset:0,d=u.endContainer===t?u.endOffset:n.length;d>f&&i.push([f,d])}if(i.length===0)return null;let r=pu(o,e);if(!r)return null;i.sort((u,c)=>u[0]-c[0]);let s=t.ownerDocument||document,a=s.createDocumentFragment(),l=0;for(let[u,c]of i){u>l&&a.append(s.createTextNode(n.slice(l,u)));let f=s.createElement("span");f.setAttribute("data-snapdom-selection",""),f.setAttribute("style",`all:unset;${r}`),f.textContent=n.slice(u,c),a.append(f),l=c}return l<n.length&&a.append(s.createTextNode(n.slice(l))),a}var Jn=t=>Number.parseFloat(t)||0,hu=["font-family","font-size","font-weight","font-style","font-variant","font-stretch","letter-spacing","word-spacing","text-transform","text-indent","text-align","line-height","tab-size","direction"];function mu(t,e){try{let o=getComputedStyle(t,"::selection").backgroundColor;if(o&&!qs.has(o)&&o!==e.backgroundColor)return o}catch{}return vr}function Ks(t,e){let n=t.ownerDocument||document;if(n.activeElement!==t)return;let o=null,i=null;try{o=t.selectionStart,i=t.selectionEnd}catch{return}if(o==null||i==null||o===i)return;let r=t.value||"";if(t.localName==="input"&&t.type==="password"&&(r="\u2022".repeat(r.length)),!r)return;let s=getComputedStyle(t),a=t.localName==="textarea",l=Jn(s.paddingLeft),u=Jn(s.paddingTop),c=t.clientWidth-l-Jn(s.paddingRight),f=t.clientHeight-u-Jn(s.paddingBottom),d=n.createElement("div");d.style.cssText="position:absolute;top:0;left:-99999px;visibility:hidden;margin:0;border:0;padding:0;box-sizing:content-box;";for(let p of hu)d.style.setProperty(p,s.getPropertyValue(p));a?(d.style.whiteSpace="pre-wrap",d.style.overflowWrap="break-word",d.style.width=`${Math.max(0,c)}px`):d.style.whiteSpace="pre";let h=n.createElement("span");h.textContent=r.slice(o,i),d.append(n.createTextNode(r.slice(0,o)),h,n.createTextNode(r.slice(i))),n.body.appendChild(d);let m=[];try{let p=d.getBoundingClientRect(),y=-t.scrollLeft,b=-t.scrollTop;if(!a){b+=Math.max(0,(f-p.height)/2);let w=s.direction==="rtl",S=s.textAlign;S==="start"?S=w?"right":"left":S==="end"&&(S=w?"left":"right");let v=c-p.width;v>0&&(S==="right"?y+=v:S==="center"&&(y+=v/2))}for(let w of h.getClientRects())w.width<=0||w.height<=0||m.push({x:l+(w.left-p.left)+y,y:u+(w.top-p.top)+b,width:w.width,height:w.height})}finally{d.remove()}if(m.length===0)return;let g=mu(t,s);e.__snapdomFieldSelection={images:m.map(()=>`linear-gradient(${g},${g})`),positions:m.map(p=>`${p.x}px ${p.y}px`),sizes:m.map(p=>`${p.width}px ${p.height}px`),repeats:m.map(()=>"no-repeat"),origins:m.map(()=>"padding-box"),clips:m.map(()=>"padding-box"),base:{image:s.backgroundImage,position:s.backgroundPosition,size:s.backgroundSize,repeat:s.backgroundRepeat,origin:s.backgroundOrigin,clip:s.backgroundClip}}}function Js(t){for(let e of t.keys()){let n=e.__snapdomFieldSelection;if(!n)continue;delete e.__snapdomFieldSelection;let{images:o,positions:i,sizes:r,repeats:s,origins:a,clips:l,base:u}=n,c=e.style.backgroundImage||u.image;c&&c!=="none"?(o.push(c),i.push(e.style.backgroundPosition||u.position),r.push(e.style.backgroundSize||u.size),s.push(e.style.backgroundRepeat||u.repeat),a.push(e.style.backgroundOrigin||u.origin),l.push(e.style.backgroundClip||u.clip)):(o.push("linear-gradient(transparent,transparent)"),i.push("0% 0%"),r.push("auto"),s.push("repeat"),a.push(u.origin||"padding-box"),l.push(u.clip||"border-box")),e.style.backgroundImage=o.join(","),e.style.backgroundPosition=i.join(","),e.style.backgroundSize=r.join(","),e.style.backgroundRepeat=s.join(","),e.style.backgroundOrigin=a.join(","),e.style.backgroundClip=l.join(",")}}Tt();vt();var gu=["transform","translate","rotate","scale","transform-origin","transform-box"],yu={circle:["cx","cy","r","vector-effect"],ellipse:["cx","cy","rx","ry","vector-effect"],rect:["x","y","width","height","rx","ry","vector-effect"],path:["d","vector-effect"],line:["vector-effect"],polyline:["vector-effect"],polygon:["vector-effect"],use:["x","y","width","height","vector-effect"],g:[],clipPath:[]},bu={r:"0px",cx:"0px",cy:"0px",x:"0px",y:"0px",rx:"auto",ry:"auto",width:"auto",height:"auto",d:"none","vector-effect":"none",transform:"none",translate:"none",rotate:"none",scale:"none","transform-origin":"0px 0px","transform-box":"view-box"},Qs=new Set(["transform","translate","rotate","scale"]),Zs=new WeakMap,wu=new Map;function xu(t){let e=t.localName,n=yu[e];if(!n)return null;let o=gs(t);if(o&&(o.size===0||!ys(t)))return null;let i=o?Zs.get(o):wu;i||Zs.set(o,i=new Map);let r=i.get(e);return r||(r=[...n,...gu].filter(s=>!o||o.has(s)),i.set(e,r)),r.length?r:null}var ta=/^-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?$/i;function Su(t,e){let n=t.trim();if(!ta.test(n)||!ta.test(e))return!1;let o=parseFloat(n),i=parseFloat(e);return Math.abs(o-i)<=1e-4*Math.max(1,Math.abs(o))}function vu(t){let e=t.transform?.baseVal;if(!e?.numberOfItems)return null;let n=new DOMMatrix;for(let o=0;o<e.numberOfItems;o++){let i=e.getItem(o).matrix;n=n.multiply(new DOMMatrix([i.a,i.b,i.c,i.d,i.e,i.f]))}return n}function Cu(t,e){let n=vu(t),o=e==="none"?[1,0,0,1,0,0]:e.startsWith("matrix(")?e.slice(7,-1).split(",").map(Number):null;if(!o||o.length!==6)return!1;if(!n)return o.join()==="1,0,0,1,0,0";let i=[n.a,n.b,n.c,n.d,n.e,n.f];for(let r=0;r<6;r++)if(Math.abs(i[r]-o[r])>1e-4*Math.max(1,Math.abs(i[r])))return!1;return!0}function ku(t,e,n,o){let i=!1;for(let r of o){if(!i&&(r==="transform-origin"||r==="transform-box")&&!t.hasAttribute("transform"))continue;let s=n.getPropertyValue(r);if(!s)continue;Qs.has(r)&&s!=="none"&&(i=!0);let a=Qs.has(r)&&r!=="transform"?null:t.getAttribute(r);if(a!=null){if(s===a||s===a+"px"||r==="d"||r==="transform"&&(s==="none"||Cu(t,s))||Su(a,s))continue}else if(s===bu[r])continue;e.style.setProperty(r,s)}}var Cr=new Map,ea=new Set(["IFRAME"]);function je(t,e){Cr.set(String(t).toUpperCase(),e)}function Qn(t){let e=W(t),n=e.display;if(n==="none")return null;let o=/^(block|inline-block|flow-root|flex|inline-flex|grid|inline-grid|list-item)$/.test(n),i=h=>parseFloat(h)||0,r=(h,m,g,p,y)=>{if(!o||!h?.endsWith("px"))return null;let b=parseFloat(h);if(!Number.isFinite(b)||b<0)return null;if(e.boxSizing==="border-box")return b;let w=p-y-g;return b+m+g+(w>0&&b+m<y+w/2?w:0)},[s,a,l,u]=/scroll|auto/.test(e.overflow)?[t.offsetWidth,t.clientWidth,t.offsetHeight,t.clientHeight]:[0,0,0,0],c=r(e.width,i(e.paddingLeft)+i(e.paddingRight),i(e.borderLeftWidth)+i(e.borderRightWidth),s,a),f=r(e.height,i(e.paddingTop)+i(e.paddingBottom),i(e.borderTopWidth)+i(e.borderBottomWidth),l,u);if(c===null||f===null){let{width:h,height:m}=Et(t),g=h,p=m;if(c===null&&!g||f===null&&!p){let y=t.getBoundingClientRect();g||=y.width||0,p||=y.height||0}c??=g,f??=p}let d=document.createElement("div");return d.style.cssText=`display:${n==="inline"?"inline-block":n};box-sizing:border-box;width:${c}px;height:${f}px;visibility:hidden;`,d}var Mu=new Set(["style","option","optgroup"]),Zn=200,Au=new Set(["img","canvas","video","iframe","object","embed"]);function Cn(t){let e=0;for(let n of t.matchAll(/-?[\d.]+px/g))e+=Math.abs(parseFloat(n[0]));return e}function sa(t){let e=t.filter;return!e||e==="none"?0:e.includes("url(")?Zn:3*Cn(e)}function aa(t,e){if(!t)return 0;let n=e.filterReach||=new WeakMap,o=n.get(t);return o===void 0&&(o=sa(W(t))+(t===e.root?0:aa(t.parentElement,e)),n.set(t,o)),o}function na(t,e,n){try{if(!e||!t.matches(e))return!1}catch{return!0}let o=W(t,n).content;return!!o&&o!=="none"&&o!=="normal"}function _u(t,e,n){let{before:o,after:i}=ae(t);if(o===null||i===null||na(t,o,"::before")||na(t,i,"::after")||e.borderImageSource&&e.borderImageSource!=="none"||e.webkitBoxReflect&&e.webkitBoxReflect!=="none")return Zn;let r=parseFloat(e.fontSize)||16,s=e.outlineStyle==="none"?0:Cn(e.outlineWidth)+Cn(e.outlineOffset);return Math.max(r*(e.display==="list-item"?3:1),s,Cn(e.boxShadow),Cn(e.textShadow),sa(e))+aa(t.parentElement,n)}function oa(t,e,n,o){let i=o.rect,r=Math.max(i.left-n.right,n.left-i.right,i.top-n.bottom,n.top-i.bottom);if(r<=0)return!0;if(r>Zn)return!1;let s=o.inkReach||=new WeakMap,a=s.get(t);return a===void 0&&s.set(t,a=_u(t,e||W(t),o)),r<=a}function Eu(t,e){if(t===e.root)return!1;let n;try{n=t.getBoundingClientRect()}catch{return!1}if(n.width===0&&n.height===0)return!1;let o=W(t);if(o.display==="inline"&&!Au.has((t.localName||"").toLowerCase()))return!1;let i=t.scrollWidth||0,r=t.scrollHeight||0,s={left:o.directi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (javascript.browser.security.insecure-innerhtml): User controlled data in a p.innerHTML is an anti-pattern that can lead to XSS vulnerabilities

Source: opengrep

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New security issues found

`;return e}function Os(t){let e="";try{t.querySelectorAll("style").forEach(o=>{let i=null;try{i=o.sheet&&o.sheet.cssRules}catch{}e+=(i?Se(i):o.textContent||"")+`
`});let n=t.adoptedStyleSheets||[];for(let o of n)try{o&&o.cssRules&&(e+=Se(o.cssRules))}catch{}}catch{}return e}function Ws(t,e,n){if(!e)return;let o=document.createElement("style");o.setAttribute("data-sd",n),o.textContent=e,t.insertBefore(o,t.firstChild||null)}function Ds(t,e,n={}){try{let o=null,i=W(t).content;if(i&&i.includes("url(")){let u=i.match(/url\(["']?([^"')]+)["']?\)/);u&&(o=u[1])}let r=t.closest?.("picture"),s=t.getAttribute("src")||"",a=t.getAttribute("srcset")||"",l=o||(r?Fs(t,r):!a.trim()&&s.startsWith("data:")?s:t.currentSrc)||He(a,t)||t.src||"";if((!l||ze(l))&&n.resolvePicturePlaceholders!==!1){let u=Ts(t);u&&(l=u)}if(!l)return;e.getAttribute("src")!==l&&e.setAttribute("src",l),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}function Bs(t){let e=new Set;if(!t)return e;let n=/var\(\s*(--[A-Za-z0-9_-]+)\b/g,o;for(;o=n.exec(t);)e.add(o[1]);return e}function eu(t,e){try{let o=getComputedStyle(t).getPropertyValue(e).trim();if(o)return o}catch{}try{let o=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(o)return o}catch{}return""}function Us(t,e,n){let o=[];for(let i of e){let r=eu(t,i);r&&o.push(`${i}: ${r};`)}return o.length?`${n}{${o.join("")}}
`:""}function zs(t,e){if(!t)return;let n=o=>{let i=o.getAttribute("data-sd-slotted")||"";e?` ${i} `.includes(` ${e} `)||o.setAttribute("data-sd-slotted",i?`${i} ${e}`:e):o.setAttribute("data-sd-slotted",i)};t.nodeType===Node.ELEMENT_NODE&&n(t),t.querySelectorAll?.("*").forEach(n)}async function nu(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},o=n(),i=0;for(;i<e&&(!o||!o.body&&!o.documentElement);)await new Promise(r=>setTimeout(r,0)),o=n(),i++;return o&&(o.body||o.documentElement)?o:null}function ou(t){let e=t.getBoundingClientRect(),n=0,o=0,i=0,r=0;try{let l=getComputedStyle(t);n=parseFloat(l.borderLeftWidth)||0,o=parseFloat(l.borderRightWidth)||0,i=parseFloat(l.borderTopWidth)||0,r=parseFloat(l.borderBottomWidth)||0}catch{}let s=Math.max(0,Math.round(e.width-(n+o))),a=Math.max(0,Math.round(e.height-(i+r)));return{contentWidth:s,contentHeight:a,rect:e}}function Et(t){let e=0,n=0;if(t.offsetWidth>0&&(e=t.offsetWidth),t.offsetHeight>0&&(n=t.offsetHeight),e===0||n===0)try{let o=getComputedStyle(t);if(e===0){let i=parseFloat(o.width);!isNaN(i)&&i>0&&(e=i)}if(n===0){let i=parseFloat(o.height);!isNaN(i)&&i>0&&(n=i)}}catch{}if(e===0||n===0)try{if(e===0){let o=parseFloat(t.getAttribute("width"));!isNaN(o)&&o>0&&(e=o)}if(n===0){let o=parseFloat(t.getAttribute("height"));!isNaN(o)&&o>0&&(n=o)}}catch{}if((e===0||n===0)&&(t.naturalWidth||t.naturalHeight))try{e===0&&t.naturalWidth>0&&(e=t.naturalWidth),n===0&&t.naturalHeight>0&&(n=t.naturalHeight)}catch{}return{width:e,height:n}}var $s=new WeakMap;function ru(t,e,n){let o=t.defaultView,i=o?o.scrollX:0,r=o?o.scrollY:0,s=t.body?t.body.scrollLeft:0,a=t.body?t.body.scrollTop:0,l=t.documentElement?t.documentElement.scrollLeft:0,u=t.documentElement?t.documentElement.scrollTop:0,c=0,f=0,d=0,h=0;try{let p=o&&t.body?o.getComputedStyle(t.body):null;p&&(c=(parseFloat(p.marginTop)||0)+(parseFloat(p.paddingTop)||0),f=(parseFloat(p.marginRight)||0)+(parseFloat(p.paddingRight)||0),d=(parseFloat(p.marginBottom)||0)+(parseFloat(p.paddingBottom)||0),h=(parseFloat(p.marginLeft)||0)+(parseFloat(p.paddingLeft)||0))}catch{}let m=`html {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}body {margin: 0 !important;padding: ${c}px ${f}px ${d}px ${h}px !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,g;try{let p=$s.get(t);p||$s.set(t,p=new o.CSSStyleSheet),p.replaceSync(m),t.adoptedStyleSheets=[...t.adoptedStyleSheets,p],g=()=>{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(y=>y!==p)}}catch{let p=t.createElement("style");p.setAttribute("data-sd-iframe-pin",""),tt(p),p.textContent=m,(t.head||t.documentElement).appendChild(p),g=()=>p.remove()}if(xe(t.documentElement),i||r)try{t.body&&(t.body.scrollLeft=i,t.body.scrollTop=r),t.documentElement&&(t.documentElement.scrollLeft||(t.documentElement.scrollLeft=i),t.documentElement.scrollTop||(t.documentElement.scrollTop=r))}catch{}return()=>{try{g()}catch{}try{o&&typeof o.scrollTo=="function"&&o.scrollTo(i,r),t.body&&(t.body.scrollLeft=s,t.body.scrollTop=a),t.documentElement&&(t.documentElement.scrollLeft=l,t.documentElement.scrollTop=u)}catch{}xe(t.documentElement)}}async function Sr(t,e,n){let o=await nu(t,3);if(!o)throw new Error("The iframe document isn't ready.");let{contentWidth:i,contentHeight:r,rect:s}=ou(t),a=n?.snap;if(!a||typeof a.toPng!="function")throw new Error("Iframes are only captured through snapdom(el).");let l={...n,scale:1,clip:null,__pinned:!0},u=ru(o,i,r),c;try{c=await a.toPng(o.documentElement,l)}finally{u()}c.style.display="block",c.style.width=`${i}px`,c.style.height=`${r}px`;let f=document.createElement("div");return e.nodeMap.set(f,t),wt(t,f,e,n),f.style.overflow="hidden",f.style.display="block",f.style.width||(f.style.width=`${Math.round(s.width)}px`),f.style.height||(f.style.height=`${Math.round(s.height)}px`),f.appendChild(c),f}function Hs(t){try{let e=t&&t.accentColor;if(e&&e!=="auto"&&e!=="none")return e;let n=t&&t.color;if(n)return n}catch{}return"#0a6ed1"}function js(t){let{width:e,height:n}=Et(t),o=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let r=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Number.isFinite(r)&&r>0?r:e||o.width||128,l=Number.isFinite(s)&&s>0?s:n||o.height||16,u=Number.parseFloat(t.min)||0,c=Number.isFinite(Number.parseFloat(t.max))?Number.parseFloat(t.max):100,f=Number.parseFloat(t.value),d=c-u,h=d>0&&Number.isFinite(f)?Math.min(1,Math.max(0,(f-u)/d)):.5,m="middle";try{i&&i.verticalAlign&&(m=i.verticalAlign)}catch{}let g=document.createElement("div");g.setAttribute("data-snapdom-input-replacement","range"),g.style.cssText=`display:inline-block;width:${a}px;height:${l}px;vertical-align:${m};flex-shrink:0;line-height:0;`;let p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.setAttribute("width",String(a)),p.setAttribute("height",String(l)),p.setAttribute("viewBox",`0 0 ${a} ${l}`),p.style.cssText=`width:${a}px;height:${l}px;overflow:visible`,g.appendChild(p);function y(){let b=Hs(i),w=!!t.disabled,S=Math.max(2,Math.min(4,l)),v=(l-S)/2,C=Math.max(10,Math.min(14,Math.max(l,10))),A=C/2,F=A+h*Math.max(0,a-C);p.innerHTML="";let T=(x,E,_,$)=>{let R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(x)),R.setAttribute("y",String(v)),R.setAttribute("width",String(Math.max(0,E))),R.setAttribute("height",String(S)),R.setAttribute("rx",String(S/2)),R.setAttribute("fill",_),$&&R.setAttribute("fill-opacity",$),p.appendChild(R)};T(0,a,"#808080","0.4"),T(0,F,b);let M=document.createElementNS("http://www.w3.org/2000/svg","circle");M.setAttribute("cx",String(F)),M.setAttribute("cy",String(l/2)),M.setAttribute("r",String(A)),M.setAttribute("fill",b),p.appendChild(M),w&&p.setAttribute("opacity","0.5"),g.style.setProperty("width",`${a}px`,"important"),g.style.setProperty("height",`${l}px`,"important"),g.style.setProperty("min-width",`${a}px`,"important"),g.style.setProperty("min-height",`${l}px`,"important")}return y(),{el:g,applyVisual:y}}function Vs(t){let{width:e,height:n}=Et(t),o=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let r=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Math.round(e||o.width||0),l=Math.round(n||o.height||0),u=Number.isFinite(r)&&r>0?Math.round(r):Math.max(12,a||16),c=Number.isFinite(s)&&s>0?Math.round(s):Math.max(12,l||16),f=(t.type||"text").toLowerCase()==="checkbox",d=!!t.checked,h=!!t.indeterminate,g=Math.max(Math.min(u,c),12),p=Math.max(u,g),y=Math.max(c,g),b="middle";try{i&&i.verticalAlign&&(b=i.verticalAlign)}catch{}let w=document.createElement("div");w.setAttribute("data-snapdom-input-replacement",t.type||"checkbox"),w.style.cssText=`display:inline-block;width:${p}px;height:${y}px;vertical-align:${b};flex-shrink:0;line-height:0;`;let S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("width",String(p)),S.setAttribute("height",String(y)),S.setAttribute("viewBox",`0 0 ${g} ${g}`),S.style.cssText=`width:${p}px;height:${y}px`,w.appendChild(S);function v(){let C=Hs(i),A=2,F=A/2,T=g-A;if(S.innerHTML="",f){let M=document.createElementNS("http://www.w3.org/2000/svg","rect");if(M.setAttribute("x",String(F)),M.setAttribute("y",String(F)),M.setAttribute("width",String(T)),M.setAttribute("height",String(T)),M.setAttribute("rx","2"),M.setAttribute("ry","2"),M.setAttribute("fill",d?C:"none"),M.setAttribute("stroke",C),M.setAttribute("stroke-width",String(A)),S.appendChild(M),d){let x=document.createElementNS("http://www.w3.org/2000/svg","path");x.setAttribute("d",`M ${F+2} ${g/2} L ${g/2-1} ${g-F-2} L ${g-F-2} ${F+2}`),x.setAttribute("stroke","white"),x.setAttribute("stroke-width",String(Math.max(1.5,A))),x.setAttribute("fill","none"),x.setAttribute("stroke-linecap","round"),x.setAttribute("stroke-linejoin","round"),S.appendChild(x)}else if(h){let x=document.createElementNS("http://www.w3.org/2000/svg","rect"),E=Math.max(6,T-4);x.setAttribute("x",String((g-E)/2)),x.setAttribute("y",String((g-A)/2)),x.setAttribute("width",String(E)),x.setAttribute("height",String(A)),x.setAttribute("fill",C),x.setAttribute("rx","1"),S.appendChild(x)}}else{let M=document.createElementNS("http://www.w3.org/2000/svg","circle");if(M.setAttribute("cx",String(g/2)),M.setAttribute("cy",String(g/2)),M.setAttribute("r",String((g-A)/2)),M.setAttribute("fill",d?C:"none"),M.setAttribute("stroke",C),M.setAttribute("stroke-width",String(A)),S.appendChild(M),d){let x=document.createElementNS("http://www.w3.org/2000/svg","circle"),E=Math.max(2,(g-A*2)*.35);x.setAttribute("cx",String(g/2)),x.setAttribute("cy",String(g/2)),x.setAttribute("r",String(E)),x.setAttribute("fill","white"),S.appendChild(x)}}w.style.setProperty("width",`${p}px`,"important"),w.style.setProperty("height",`${y}px`,"important"),w.style.setProperty("min-width",`${p}px`,"important"),w.style.setProperty("min-height",`${y}px`,"important")}return v(),{el:w,applyVisual:v}}var Sn=new gt(80);async function iu(t){if(j.resource?.has(t))return j.resource.get(t);if(Sn.has(t))return Sn.get(t);let e=(async()=>{let n=await dt(t,{as:"dataURL"});if(!n.ok||typeof n.data!="string")throw new Error(`Couldn't read ${t}`);return j.resource?.set(t,n.data),n.data})();Sn.set(t,e);try{let n=await e;return Sn.set(t,n),n}catch(n){throw Sn.delete(t),n}}var Ps=/\bblob:[^)"'\s]+/g;function Yn(t){return typeof t=="string"&&t.startsWith("blob:")}function su(t){return(t||"").split(",").map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.match(/^(\S+)(\s+.+)?$/);return n?{url:n[1],desc:n[2]||""}:null}).filter(Boolean)}function au(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}function vn(t,e){let n=t.querySelectorAll?Array.from(t.querySelectorAll(e)):[];return t.matches?.(e)&&n.unshift(t),n}async function Kn(t,e=null){if(!t)return;let n=e,o=new Set,i=[],r=new Map,s=(g,p,y,b)=>{o.add(y),i.push(()=>{r.has(y)&&(g.setAttribute(p,r.get(y)),b?.())})},a=(g,p)=>{if(!g||!g.includes("blob:"))return;let y=g.match(Ps)||[];if(y.length){for(let b of y)o.add(b);i.push(()=>{let b=g.replace(Ps,w=>r.get(w)||w);b!==g&&p(b)})}},l=vn(t,"img");for(let g of l)try{let y=g.getAttribute("src")||g.currentSrc||"";Yn(y)&&s(g,"src",y);let b=g.getAttribute("srcset");if(b&&b.includes("blob:")){let w=su(b);for(let S of w)Yn(S.url)&&o.add(S.url);i.push(()=>{let S=!1;for(let v of w)r.has(v.url)&&(v.url=r.get(v.url),S=!0);S&&g.setAttribute("srcset",au(w))})}}catch(p){D(n,"Couldn't inline a blob: image.",p)}let u=vn(t,"image");for(let g of u)try{let p="http://www.w3.org/1999/xlink",y=g.getAttribute("href")||g.getAttributeNS?.(p,"href");Yn(y)&&s(g,"href",y,()=>g.removeAttributeNS?.(p,"href"))}catch(p){D(n,"Couldn't inline a blob: SVG image.",p)}let c=vn(t,"[style*='blob:']");for(let g of c)try{let p=g.getAttribute("style");a(p,y=>g.setAttribute("style",y))}catch(p){D(n,"Couldn't inline blob: URLs in a style attribute.",p)}let f=vn(t,"style");for(let g of f)try{let p=g.textContent||"";a(p,y=>{g.textContent=y})}catch(p){D(n,"Couldn't inline blob: URLs in a <style>.",p)}let d=["poster"];for(let g of d){let p=vn(t,`[${g}^='blob:']`);for(let y of p)try{let b=y.getAttribute(g);Yn(b)&&s(y,g,b)}catch(b){D(n,`Couldn't inline the blob: URL in ${g}.`,b)}}if(!o.size)return;let h=[...o],m=0;await Promise.all(Array.from({length:Math.min(4,h.length)},async()=>{for(;m<h.length;){let g=h[m++];try{r.set(g,await iu(g))}catch(p){D(n,"Couldn't read a blob: URL; kept it as is.",p)}}}));for(let g of i)try{g()}catch(p){D(n,"Couldn't write an inlined blob: URL.",p)}}var lu=["font-family","font-size","font-style","font-weight","font-stretch","font-variant","font-feature-settings","font-variation-settings","font-kerning","letter-spacing","text-transform"],cu=new Set(["text","search","email","url","tel","number","submit","reset","button"]),fu=/[^\s\uD800-\uDFFF]{2,}/;function Gs(t,e=document){let n=e.defaultView||window;if(!At()||!e.body||!(n.visualViewport?.scale<1||n.screen.width<e.documentElement.clientWidth))return;let o=tt(e.createElement("div"));o.style.cssText="position:absolute;left:0;top:0;width:0;height:0;overflow:hidden;visibility:hidden";let i=[];for(let[r,s]of t){if(r.nodeType!==1||s.nodeType!==1)continue;let a=n.getComputedStyle(s),l=s.localName==="textarea"||s.localName==="input"&&cu.has(s.type)?du(s,a,e):uu(s,a.textAlign==="justify"||a.textAlignLast==="justify");if(!l)continue;let u=s.getBoundingClientRect(),c=s.offsetWidth&&u.width?u.width/s.offsetWidth:1,f=e.createElement("span");f.style.whiteSpace="pre";for(let d of lu)f.style.setProperty(d,a.getPropertyValue(d));f.textContent=l.word,o.appendChild(f),i.push({clone:r,cs:a,span:f,live:l.distance/c,centers:l.centers,height:l.height})}if(i.length){e.body.appendChild(o);try{for(let{clone:r,cs:s,span:a,live:l,centers:u,height:c}of i){let f=a.firstChild,d=(parseFloat(s.letterSpacing)||0)*(u?f.length-1:f.length),h=c?e.createRange():null;h&&h.selectNodeContents(a);let m=c?h.getBoundingClientRect().height:u?Math.abs(Ns(f,f.length-1)-Ns(f,0)):a.getBoundingClientRect().width,g=(l-(c?0:d))/(m-(c?0:d));if(g>1.005&&Number.isFinite(g)){if(c){let p=[];for(let y of[!1,!0]){let b=parseFloat(s.fontSize),w=b*(g+1);for(let S=0;S<10;S++){let v=(b+w)/2;a.style.fontSize=`${v}px`;let C=h.getBoundingClientRect().height;(y?C>l:C>=l)?w=v:b=v}p.push((b+w)/2)}g=(p[0]+p[1])/2/parseFloat(s.fontSize)}r.style.setProperty("font-size",`${parseFloat(s.fontSize)*g}px`),s.lineHeight!=="normal"&&r.style.setProperty("line-height",`${parseFloat(s.lineHeight)*g}px`)}}}finally{o.remove()}}}function Ns(t,e){let n=t.ownerDocument.createRange();n.setStart(t,e),n.setEnd(t,e+1);let o=n.getBoundingClientRect();return o.left+o.width/2}function uu(t,e=!1){for(let n=t.firstChild;n;n=n.nextSibling){if(n.nodeType!==3)continue;let o=/\S+/.exec(n.data);if(!o)continue;let i=t.ownerDocument.createRange();i.setStart(n,o.index),i.setEnd(n,o.index+o[0].length);let r=i.getClientRects();return r.length===1?{word:o[0],distance:e?r[0].height:r[0].width,centers:!1,height:e}:null}return null}function du(t,e,n){let o=fu.exec(t.value.split(`
`)[0]);if(!o||t.scrollLeft||t.scrollTop||!n.caretPositionFromPoint)return null;let i=t.getBoundingClientRect(),r=t.localName==="textarea"?i.top+(parseFloat(e.borderTopWidth)||0)+(parseFloat(e.paddingTop)||0)+3:i.top+i.height/2,s=c=>{let f=n.caretPositionFromPoint(c,r);return f&&f.offsetNode===t?f.offset:-1},a=i.width/16,l=c=>{let f=i.left;for(;f<=i.right&&s(f)<c;)f+=a;if(f>i.right)return NaN;let d=f-a;for(let h=0;h<16;h++){let m=(d+f)/2;s(m)>=c?f=m:d=m}return f},u=Math.abs(l(o.index+o[0].length)-l(o.index+1));return Number.isFinite(u)?{word:o[0],distance:u,centers:!0}:null}yt();var qs=new Set(["rgba(0, 0, 0, 0)","transparent"]),vr="Highlight";function Xs(t){let n=(t.ownerDocument||document).getSelection?.();if(!n||n.isCollapsed||n.rangeCount===0)return null;let o=[];for(let i=0;i<n.rangeCount;i+=1){let r=n.getRangeAt(i);if(!r.collapsed)try{r.intersectsNode(t)&&o.push(r)}catch{}}return o.length?{ranges:o,styles:new Map}:null}function pu(t,e){if(e.styles.has(t))return e.styles.get(t);let n;try{let o=getComputedStyle(t);if(o.userSelect==="none"||o.webkitUserSelect==="none"||o.getPropertyValue("-webkit-user-select")==="none")return e.styles.set(t,null),null;let i=getComputedStyle(t,"::selection"),r=[],s=i.backgroundColor,a=s&&!qs.has(s)&&s!==o.backgroundColor;r.push(`background-color:${a?s:vr}`),i.color&&i.color!==o.color&&r.push(`color:${i.color}`,`-webkit-text-fill-color:${i.color}`),i.textShadow&&i.textShadow!==o.textShadow&&r.push(`text-shadow:${i.textShadow}`),i.textDecorationLine&&i.textDecorationLine!=="none"&&i.textDecorationLine!==o.textDecorationLine&&r.push(`text-decoration:${i.textDecorationLine} ${i.textDecorationStyle||"solid"} ${i.textDecorationColor||"currentcolor"}`),n=r.join(";")}catch{n=`background-color:${vr}`}return e.styles.set(t,n),n}function Ys(t,e){let n=t.data;if(!n)return null;let o=t.parentElement;if(!o)return null;let i=[];for(let u of e.ranges){let c=!1;try{c=u.intersectsNode(t)}catch{}if(!c)continue;let f=u.startContainer===t?u.startOffset:0,d=u.endContainer===t?u.endOffset:n.length;d>f&&i.push([f,d])}if(i.length===0)return null;let r=pu(o,e);if(!r)return null;i.sort((u,c)=>u[0]-c[0]);let s=t.ownerDocument||document,a=s.createDocumentFragment(),l=0;for(let[u,c]of i){u>l&&a.append(s.createTextNode(n.slice(l,u)));let f=s.createElement("span");f.setAttribute("data-snapdom-selection",""),f.setAttribute("style",`all:unset;${r}`),f.textContent=n.slice(u,c),a.append(f),l=c}return l<n.length&&a.append(s.createTextNode(n.slice(l))),a}var Jn=t=>Number.parseFloat(t)||0,hu=["font-family","font-size","font-weight","font-style","font-variant","font-stretch","letter-spacing","word-spacing","text-transform","text-indent","text-align","line-height","tab-size","direction"];function mu(t,e){try{let o=getComputedStyle(t,"::selection").backgroundColor;if(o&&!qs.has(o)&&o!==e.backgroundColor)return o}catch{}return vr}function Ks(t,e){let n=t.ownerDocument||document;if(n.activeElement!==t)return;let o=null,i=null;try{o=t.selectionStart,i=t.selectionEnd}catch{return}if(o==null||i==null||o===i)return;let r=t.value||"";if(t.localName==="input"&&t.type==="password"&&(r="\u2022".repeat(r.length)),!r)return;let s=getComputedStyle(t),a=t.localName==="textarea",l=Jn(s.paddingLeft),u=Jn(s.paddingTop),c=t.clientWidth-l-Jn(s.paddingRight),f=t.clientHeight-u-Jn(s.paddingBottom),d=n.createElement("div");d.style.cssText="position:absolute;top:0;left:-99999px;visibility:hidden;margin:0;border:0;padding:0;box-sizing:content-box;";for(let p of hu)d.style.setProperty(p,s.getPropertyValue(p));a?(d.style.whiteSpace="pre-wrap",d.style.overflowWrap="break-word",d.style.width=`${Math.max(0,c)}px`):d.style.whiteSpace="pre";let h=n.createElement("span");h.textContent=r.slice(o,i),d.append(n.createTextNode(r.slice(0,o)),h,n.createTextNode(r.slice(i))),n.body.appendChild(d);let m=[];try{let p=d.getBoundingClientRect(),y=-t.scrollLeft,b=-t.scrollTop;if(!a){b+=Math.max(0,(f-p.height)/2);let w=s.direction==="rtl",S=s.textAlign;S==="start"?S=w?"right":"left":S==="end"&&(S=w?"left":"right");let v=c-p.width;v>0&&(S==="right"?y+=v:S==="center"&&(y+=v/2))}for(let w of h.getClientRects())w.width<=0||w.height<=0||m.push({x:l+(w.left-p.left)+y,y:u+(w.top-p.top)+b,width:w.width,height:w.height})}finally{d.remove()}if(m.length===0)return;let g=mu(t,s);e.__snapdomFieldSelection={images:m.map(()=>`linear-gradient(${g},${g})`),positions:m.map(p=>`${p.x}px ${p.y}px`),sizes:m.map(p=>`${p.width}px ${p.height}px`),repeats:m.map(()=>"no-repeat"),origins:m.map(()=>"padding-box"),clips:m.map(()=>"padding-box"),base:{image:s.backgroundImage,position:s.backgroundPosition,size:s.backgroundSize,repeat:s.backgroundRepeat,origin:s.backgroundOrigin,clip:s.backgroundClip}}}function Js(t){for(let e of t.keys()){let n=e.__snapdomFieldSelection;if(!n)continue;delete e.__snapdomFieldSelection;let{images:o,positions:i,sizes:r,repeats:s,origins:a,clips:l,base:u}=n,c=e.style.backgroundImage||u.image;c&&c!=="none"?(o.push(c),i.push(e.style.backgroundPosition||u.position),r.push(e.style.backgroundSize||u.size),s.push(e.style.backgroundRepeat||u.repeat),a.push(e.style.backgroundOrigin||u.origin),l.push(e.style.backgroundClip||u.clip)):(o.push("linear-gradient(transparent,transparent)"),i.push("0% 0%"),r.push("auto"),s.push("repeat"),a.push(u.origin||"padding-box"),l.push(u.clip||"border-box")),e.style.backgroundImage=o.join(","),e.style.backgroundPosition=i.join(","),e.style.backgroundSize=r.join(","),e.style.backgroundRepeat=s.join(","),e.style.backgroundOrigin=a.join(","),e.style.backgroundClip=l.join(",")}}Tt();vt();var gu=["transform","translate","rotate","scale","transform-origin","transform-box"],yu={circle:["cx","cy","r","vector-effect"],ellipse:["cx","cy","rx","ry","vector-effect"],rect:["x","y","width","height","rx","ry","vector-effect"],path:["d","vector-effect"],line:["vector-effect"],polyline:["vector-effect"],polygon:["vector-effect"],use:["x","y","width","height","vector-effect"],g:[],clipPath:[]},bu={r:"0px",cx:"0px",cy:"0px",x:"0px",y:"0px",rx:"auto",ry:"auto",width:"auto",height:"auto",d:"none","vector-effect":"none",transform:"none",translate:"none",rotate:"none",scale:"none","transform-origin":"0px 0px","transform-box":"view-box"},Qs=new Set(["transform","translate","rotate","scale"]),Zs=new WeakMap,wu=new Map;function xu(t){let e=t.localName,n=yu[e];if(!n)return null;let o=gs(t);if(o&&(o.size===0||!ys(t)))return null;let i=o?Zs.get(o):wu;i||Zs.set(o,i=new Map);let r=i.get(e);return r||(r=[...n,...gu].filter(s=>!o||o.has(s)),i.set(e,r)),r.length?r:null}var ta=/^-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?$/i;function Su(t,e){let n=t.trim();if(!ta.test(n)||!ta.test(e))return!1;let o=parseFloat(n),i=parseFloat(e);return Math.abs(o-i)<=1e-4*Math.max(1,Math.abs(o))}function vu(t){let e=t.transform?.baseVal;if(!e?.numberOfItems)return null;let n=new DOMMatrix;for(let o=0;o<e.numberOfItems;o++){let i=e.getItem(o).matrix;n=n.multiply(new DOMMatrix([i.a,i.b,i.c,i.d,i.e,i.f]))}return n}function Cu(t,e){let n=vu(t),o=e==="none"?[1,0,0,1,0,0]:e.startsWith("matrix(")?e.slice(7,-1).split(",").map(Number):null;if(!o||o.length!==6)return!1;if(!n)return o.join()==="1,0,0,1,0,0";let i=[n.a,n.b,n.c,n.d,n.e,n.f];for(let r=0;r<6;r++)if(Math.abs(i[r]-o[r])>1e-4*Math.max(1,Math.abs(i[r])))return!1;return!0}function ku(t,e,n,o){let i=!1;for(let r of o){if(!i&&(r==="transform-origin"||r==="transform-box")&&!t.hasAttribute("transform"))continue;let s=n.getPropertyValue(r);if(!s)continue;Qs.has(r)&&s!=="none"&&(i=!0);let a=Qs.has(r)&&r!=="transform"?null:t.getAttribute(r);if(a!=null){if(s===a||s===a+"px"||r==="d"||r==="transform"&&(s==="none"||Cu(t,s))||Su(a,s))continue}else if(s===bu[r])continue;e.style.setProperty(r,s)}}var Cr=new Map,ea=new Set(["IFRAME"]);function je(t,e){Cr.set(String(t).toUpperCase(),e)}function Qn(t){let e=W(t),n=e.display;if(n==="none")return null;let o=/^(block|inline-block|flow-root|flex|inline-flex|grid|inline-grid|list-item)$/.test(n),i=h=>parseFloat(h)||0,r=(h,m,g,p,y)=>{if(!o||!h?.endsWith("px"))return null;let b=parseFloat(h);if(!Number.isFinite(b)||b<0)return null;if(e.boxSizing==="border-box")return b;let w=p-y-g;return b+m+g+(w>0&&b+m<y+w/2?w:0)},[s,a,l,u]=/scroll|auto/.test(e.overflow)?[t.offsetWidth,t.clientWidth,t.offsetHeight,t.clientHeight]:[0,0,0,0],c=r(e.width,i(e.paddingLeft)+i(e.paddingRight),i(e.borderLeftWidth)+i(e.borderRightWidth),s,a),f=r(e.height,i(e.paddingTop)+i(e.paddingBottom),i(e.borderTopWidth)+i(e.borderBottomWidth),l,u);if(c===null||f===null){let{width:h,height:m}=Et(t),g=h,p=m;if(c===null&&!g||f===null&&!p){let y=t.getBoundingClientRect();g||=y.width||0,p||=y.height||0}c??=g,f??=p}let d=document.createElement("div");return d.style.cssText=`display:${n==="inline"?"inline-block":n};box-sizing:border-box;width:${c}px;height:${f}px;visibility:hidden;`,d}var Mu=new Set(["style","option","optgroup"]),Zn=200,Au=new Set(["img","canvas","video","iframe","object","embed"]);function Cn(t){let e=0;for(let n of t.matchAll(/-?[\d.]+px/g))e+=Math.abs(parseFloat(n[0]));return e}function sa(t){let e=t.filter;return!e||e==="none"?0:e.includes("url(")?Zn:3*Cn(e)}function aa(t,e){if(!t)return 0;let n=e.filterReach||=new WeakMap,o=n.get(t);return o===void 0&&(o=sa(W(t))+(t===e.root?0:aa(t.parentElement,e)),n.set(t,o)),o}function na(t,e,n){try{if(!e||!t.matches(e))return!1}catch{return!0}let o=W(t,n).content;return!!o&&o!=="none"&&o!=="normal"}function _u(t,e,n){let{before:o,after:i}=ae(t);if(o===null||i===null||na(t,o,"::before")||na(t,i,"::after")||e.borderImageSource&&e.borderImageSource!=="none"||e.webkitBoxReflect&&e.webkitBoxReflect!=="none")return Zn;let r=parseFloat(e.fontSize)||16,s=e.outlineStyle==="none"?0:Cn(e.outlineWidth)+Cn(e.outlineOffset);return Math.max(r*(e.display==="list-item"?3:1),s,Cn(e.boxShadow),Cn(e.textShadow),sa(e))+aa(t.parentElement,n)}function oa(t,e,n,o){let i=o.rect,r=Math.max(i.left-n.right,n.left-i.right,i.top-n.bottom,n.top-i.bottom);if(r<=0)return!0;if(r>Zn)return!1;let s=o.inkReach||=new WeakMap,a=s.get(t);return a===void 0&&s.set(t,a=_u(t,e||W(t),o)),r<=a}function Eu(t,e){if(t===e.root)return!1;let n;try{n=t.getBoundingClientRect()}catch{return!1}if(n.width===0&&n.height===0)return!1;let o=W(t);if(o.display==="inline"&&!Au.has((t.localName||"").toLowerCase()))return!1;let i=t.scrollWidth||0,r=t.scrollHeight||0,s={left:o.directi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (javascript.browser.security.insecure-document-method): User controlled data in methods like innerHTML, outerHTML or document.write is an anti-pattern that can lead to XSS vulnerabilities

Source: opengrep

`;return e}function Os(t){let e="";try{t.querySelectorAll("style").forEach(o=>{let i=null;try{i=o.sheet&&o.sheet.cssRules}catch{}e+=(i?Se(i):o.textContent||"")+`
`});let n=t.adoptedStyleSheets||[];for(let o of n)try{o&&o.cssRules&&(e+=Se(o.cssRules))}catch{}}catch{}return e}function Ws(t,e,n){if(!e)return;let o=document.createElement("style");o.setAttribute("data-sd",n),o.textContent=e,t.insertBefore(o,t.firstChild||null)}function Ds(t,e,n={}){try{let o=null,i=W(t).content;if(i&&i.includes("url(")){let u=i.match(/url\(["']?([^"')]+)["']?\)/);u&&(o=u[1])}let r=t.closest?.("picture"),s=t.getAttribute("src")||"",a=t.getAttribute("srcset")||"",l=o||(r?Fs(t,r):!a.trim()&&s.startsWith("data:")?s:t.currentSrc)||He(a,t)||t.src||"";if((!l||ze(l))&&n.resolvePicturePlaceholders!==!1){let u=Ts(t);u&&(l=u)}if(!l)return;e.getAttribute("src")!==l&&e.setAttribute("src",l),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}function Bs(t){let e=new Set;if(!t)return e;let n=/var\(\s*(--[A-Za-z0-9_-]+)\b/g,o;for(;o=n.exec(t);)e.add(o[1]);return e}function eu(t,e){try{let o=getComputedStyle(t).getPropertyValue(e).trim();if(o)return o}catch{}try{let o=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(o)return o}catch{}return""}function Us(t,e,n){let o=[];for(let i of e){let r=eu(t,i);r&&o.push(`${i}: ${r};`)}return o.length?`${n}{${o.join("")}}
`:""}function zs(t,e){if(!t)return;let n=o=>{let i=o.getAttribute("data-sd-slotted")||"";e?` ${i} `.includes(` ${e} `)||o.setAttribute("data-sd-slotted",i?`${i} ${e}`:e):o.setAttribute("data-sd-slotted",i)};t.nodeType===Node.ELEMENT_NODE&&n(t),t.querySelectorAll?.("*").forEach(n)}async function nu(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},o=n(),i=0;for(;i<e&&(!o||!o.body&&!o.documentElement);)await new Promise(r=>setTimeout(r,0)),o=n(),i++;return o&&(o.body||o.documentElement)?o:null}function ou(t){let e=t.getBoundingClientRect(),n=0,o=0,i=0,r=0;try{let l=getComputedStyle(t);n=parseFloat(l.borderLeftWidth)||0,o=parseFloat(l.borderRightWidth)||0,i=parseFloat(l.borderTopWidth)||0,r=parseFloat(l.borderBottomWidth)||0}catch{}let s=Math.max(0,Math.round(e.width-(n+o))),a=Math.max(0,Math.round(e.height-(i+r)));return{contentWidth:s,contentHeight:a,rect:e}}function Et(t){let e=0,n=0;if(t.offsetWidth>0&&(e=t.offsetWidth),t.offsetHeight>0&&(n=t.offsetHeight),e===0||n===0)try{let o=getComputedStyle(t);if(e===0){let i=parseFloat(o.width);!isNaN(i)&&i>0&&(e=i)}if(n===0){let i=parseFloat(o.height);!isNaN(i)&&i>0&&(n=i)}}catch{}if(e===0||n===0)try{if(e===0){let o=parseFloat(t.getAttribute("width"));!isNaN(o)&&o>0&&(e=o)}if(n===0){let o=parseFloat(t.getAttribute("height"));!isNaN(o)&&o>0&&(n=o)}}catch{}if((e===0||n===0)&&(t.naturalWidth||t.naturalHeight))try{e===0&&t.naturalWidth>0&&(e=t.naturalWidth),n===0&&t.naturalHeight>0&&(n=t.naturalHeight)}catch{}return{width:e,height:n}}var $s=new WeakMap;function ru(t,e,n){let o=t.defaultView,i=o?o.scrollX:0,r=o?o.scrollY:0,s=t.body?t.body.scrollLeft:0,a=t.body?t.body.scrollTop:0,l=t.documentElement?t.documentElement.scrollLeft:0,u=t.documentElement?t.documentElement.scrollTop:0,c=0,f=0,d=0,h=0;try{let p=o&&t.body?o.getComputedStyle(t.body):null;p&&(c=(parseFloat(p.marginTop)||0)+(parseFloat(p.paddingTop)||0),f=(parseFloat(p.marginRight)||0)+(parseFloat(p.paddingRight)||0),d=(parseFloat(p.marginBottom)||0)+(parseFloat(p.paddingBottom)||0),h=(parseFloat(p.marginLeft)||0)+(parseFloat(p.paddingLeft)||0))}catch{}let m=`html {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}body {margin: 0 !important;padding: ${c}px ${f}px ${d}px ${h}px !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,g;try{let p=$s.get(t);p||$s.set(t,p=new o.CSSStyleSheet),p.replaceSync(m),t.adoptedStyleSheets=[...t.adoptedStyleSheets,p],g=()=>{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(y=>y!==p)}}catch{let p=t.createElement("style");p.setAttribute("data-sd-iframe-pin",""),tt(p),p.textContent=m,(t.head||t.documentElement).appendChild(p),g=()=>p.remove()}if(xe(t.documentElement),i||r)try{t.body&&(t.body.scrollLeft=i,t.body.scrollTop=r),t.documentElement&&(t.documentElement.scrollLeft||(t.documentElement.scrollLeft=i),t.documentElement.scrollTop||(t.documentElement.scrollTop=r))}catch{}return()=>{try{g()}catch{}try{o&&typeof o.scrollTo=="function"&&o.scrollTo(i,r),t.body&&(t.body.scrollLeft=s,t.body.scrollTop=a),t.documentElement&&(t.documentElement.scrollLeft=l,t.documentElement.scrollTop=u)}catch{}xe(t.documentElement)}}async function Sr(t,e,n){let o=await nu(t,3);if(!o)throw new Error("The iframe document isn't ready.");let{contentWidth:i,contentHeight:r,rect:s}=ou(t),a=n?.snap;if(!a||typeof a.toPng!="function")throw new Error("Iframes are only captured through snapdom(el).");let l={...n,scale:1,clip:null,__pinned:!0},u=ru(o,i,r),c;try{c=await a.toPng(o.documentElement,l)}finally{u()}c.style.display="block",c.style.width=`${i}px`,c.style.height=`${r}px`;let f=document.createElement("div");return e.nodeMap.set(f,t),wt(t,f,e,n),f.style.overflow="hidden",f.style.display="block",f.style.width||(f.style.width=`${Math.round(s.width)}px`),f.style.height||(f.style.height=`${Math.round(s.height)}px`),f.appendChild(c),f}function Hs(t){try{let e=t&&t.accentColor;if(e&&e!=="auto"&&e!=="none")return e;let n=t&&t.color;if(n)return n}catch{}return"#0a6ed1"}function js(t){let{width:e,height:n}=Et(t),o=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let r=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Number.isFinite(r)&&r>0?r:e||o.width||128,l=Number.isFinite(s)&&s>0?s:n||o.height||16,u=Number.parseFloat(t.min)||0,c=Number.isFinite(Number.parseFloat(t.max))?Number.parseFloat(t.max):100,f=Number.parseFloat(t.value),d=c-u,h=d>0&&Number.isFinite(f)?Math.min(1,Math.max(0,(f-u)/d)):.5,m="middle";try{i&&i.verticalAlign&&(m=i.verticalAlign)}catch{}let g=document.createElement("div");g.setAttribute("data-snapdom-input-replacement","range"),g.style.cssText=`display:inline-block;width:${a}px;height:${l}px;vertical-align:${m};flex-shrink:0;line-height:0;`;let p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.setAttribute("width",String(a)),p.setAttribute("height",String(l)),p.setAttribute("viewBox",`0 0 ${a} ${l}`),p.style.cssText=`width:${a}px;height:${l}px;overflow:visible`,g.appendChild(p);function y(){let b=Hs(i),w=!!t.disabled,S=Math.max(2,Math.min(4,l)),v=(l-S)/2,C=Math.max(10,Math.min(14,Math.max(l,10))),A=C/2,F=A+h*Math.max(0,a-C);p.innerHTML="";let T=(x,E,_,$)=>{let R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(x)),R.setAttribute("y",String(v)),R.setAttribute("width",String(Math.max(0,E))),R.setAttribute("height",String(S)),R.setAttribute("rx",String(S/2)),R.setAttribute("fill",_),$&&R.setAttribute("fill-opacity",$),p.appendChild(R)};T(0,a,"#808080","0.4"),T(0,F,b);let M=document.createElementNS("http://www.w3.org/2000/svg","circle");M.setAttribute("cx",String(F)),M.setAttribute("cy",String(l/2)),M.setAttribute("r",String(A)),M.setAttribute("fill",b),p.appendChild(M),w&&p.setAttribute("opacity","0.5"),g.style.setProperty("width",`${a}px`,"important"),g.style.setProperty("height",`${l}px`,"important"),g.style.setProperty("min-width",`${a}px`,"important"),g.style.setProperty("min-height",`${l}px`,"important")}return y(),{el:g,applyVisual:y}}function Vs(t){let{width:e,height:n}=Et(t),o=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let r=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Math.round(e||o.width||0),l=Math.round(n||o.height||0),u=Number.isFinite(r)&&r>0?Math.round(r):Math.max(12,a||16),c=Number.isFinite(s)&&s>0?Math.round(s):Math.max(12,l||16),f=(t.type||"text").toLowerCase()==="checkbox",d=!!t.checked,h=!!t.indeterminate,g=Math.max(Math.min(u,c),12),p=Math.max(u,g),y=Math.max(c,g),b="middle";try{i&&i.verticalAlign&&(b=i.verticalAlign)}catch{}let w=document.createElement("div");w.setAttribute("data-snapdom-input-replacement",t.type||"checkbox"),w.style.cssText=`display:inline-block;width:${p}px;height:${y}px;vertical-align:${b};flex-shrink:0;line-height:0;`;let S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("width",String(p)),S.setAttribute("height",String(y)),S.setAttribute("viewBox",`0 0 ${g} ${g}`),S.style.cssText=`width:${p}px;height:${y}px`,w.appendChild(S);function v(){let C=Hs(i),A=2,F=A/2,T=g-A;if(S.innerHTML="",f){let M=document.createElementNS("http://www.w3.org/2000/svg","rect");if(M.setAttribute("x",String(F)),M.setAttribute("y",String(F)),M.setAttribute("width",String(T)),M.setAttribute("height",String(T)),M.setAttribute("rx","2"),M.setAttribute("ry","2"),M.setAttribute("fill",d?C:"none"),M.setAttribute("stroke",C),M.setAttribute("stroke-width",String(A)),S.appendChild(M),d){let x=document.createElementNS("http://www.w3.org/2000/svg","path");x.setAttribute("d",`M ${F+2} ${g/2} L ${g/2-1} ${g-F-2} L ${g-F-2} ${F+2}`),x.setAttribute("stroke","white"),x.setAttribute("stroke-width",String(Math.max(1.5,A))),x.setAttribute("fill","none"),x.setAttribute("stroke-linecap","round"),x.setAttribute("stroke-linejoin","round"),S.appendChild(x)}else if(h){let x=document.createElementNS("http://www.w3.org/2000/svg","rect"),E=Math.max(6,T-4);x.setAttribute("x",String((g-E)/2)),x.setAttribute("y",String((g-A)/2)),x.setAttribute("width",String(E)),x.setAttribute("height",String(A)),x.setAttribute("fill",C),x.setAttribute("rx","1"),S.appendChild(x)}}else{let M=document.createElementNS("http://www.w3.org/2000/svg","circle");if(M.setAttribute("cx",String(g/2)),M.setAttribute("cy",String(g/2)),M.setAttribute("r",String((g-A)/2)),M.setAttribute("fill",d?C:"none"),M.setAttribute("stroke",C),M.setAttribute("stroke-width",String(A)),S.appendChild(M),d){let x=document.createElementNS("http://www.w3.org/2000/svg","circle"),E=Math.max(2,(g-A*2)*.35);x.setAttribute("cx",String(g/2)),x.setAttribute("cy",String(g/2)),x.setAttribute("r",String(E)),x.setAttribute("fill","white"),S.appendChild(x)}}w.style.setProperty("width",`${p}px`,"important"),w.style.setProperty("height",`${y}px`,"important"),w.style.setProperty("min-width",`${p}px`,"important"),w.style.setProperty("min-height",`${y}px`,"important")}return v(),{el:w,applyVisual:v}}var Sn=new gt(80);async function iu(t){if(j.resource?.has(t))return j.resource.get(t);if(Sn.has(t))return Sn.get(t);let e=(async()=>{let n=await dt(t,{as:"dataURL"});if(!n.ok||typeof n.data!="string")throw new Error(`Couldn't read ${t}`);return j.resource?.set(t,n.data),n.data})();Sn.set(t,e);try{let n=await e;return Sn.set(t,n),n}catch(n){throw Sn.delete(t),n}}var Ps=/\bblob:[^)"'\s]+/g;function Yn(t){return typeof t=="string"&&t.startsWith("blob:")}function su(t){return(t||"").split(",").map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.match(/^(\S+)(\s+.+)?$/);return n?{url:n[1],desc:n[2]||""}:null}).filter(Boolean)}function au(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}function vn(t,e){let n=t.querySelectorAll?Array.from(t.querySelectorAll(e)):[];return t.matches?.(e)&&n.unshift(t),n}async function Kn(t,e=null){if(!t)return;let n=e,o=new Set,i=[],r=new Map,s=(g,p,y,b)=>{o.add(y),i.push(()=>{r.has(y)&&(g.setAttribute(p,r.get(y)),b?.())})},a=(g,p)=>{if(!g||!g.includes("blob:"))return;let y=g.match(Ps)||[];if(y.length){for(let b of y)o.add(b);i.push(()=>{let b=g.replace(Ps,w=>r.get(w)||w);b!==g&&p(b)})}},l=vn(t,"img");for(let g of l)try{let y=g.getAttribute("src")||g.currentSrc||"";Yn(y)&&s(g,"src",y);let b=g.getAttribute("srcset");if(b&&b.includes("blob:")){let w=su(b);for(let S of w)Yn(S.url)&&o.add(S.url);i.push(()=>{let S=!1;for(let v of w)r.has(v.url)&&(v.url=r.get(v.url),S=!0);S&&g.setAttribute("srcset",au(w))})}}catch(p){D(n,"Couldn't inline a blob: image.",p)}let u=vn(t,"image");for(let g of u)try{let p="http://www.w3.org/1999/xlink",y=g.getAttribute("href")||g.getAttributeNS?.(p,"href");Yn(y)&&s(g,"href",y,()=>g.removeAttributeNS?.(p,"href"))}catch(p){D(n,"Couldn't inline a blob: SVG image.",p)}let c=vn(t,"[style*='blob:']");for(let g of c)try{let p=g.getAttribute("style");a(p,y=>g.setAttribute("style",y))}catch(p){D(n,"Couldn't inline blob: URLs in a style attribute.",p)}let f=vn(t,"style");for(let g of f)try{let p=g.textContent||"";a(p,y=>{g.textContent=y})}catch(p){D(n,"Couldn't inline blob: URLs in a <style>.",p)}let d=["poster"];for(let g of d){let p=vn(t,`[${g}^='blob:']`);for(let y of p)try{let b=y.getAttribute(g);Yn(b)&&s(y,g,b)}catch(b){D(n,`Couldn't inline the blob: URL in ${g}.`,b)}}if(!o.size)return;let h=[...o],m=0;await Promise.all(Array.from({length:Math.min(4,h.length)},async()=>{for(;m<h.length;){let g=h[m++];try{r.set(g,await iu(g))}catch(p){D(n,"Couldn't read a blob: URL; kept it as is.",p)}}}));for(let g of i)try{g()}catch(p){D(n,"Couldn't write an inlined blob: URL.",p)}}var lu=["font-family","font-size","font-style","font-weight","font-stretch","font-variant","font-feature-settings","font-variation-settings","font-kerning","letter-spacing","text-transform"],cu=new Set(["text","search","email","url","tel","number","submit","reset","button"]),fu=/[^\s\uD800-\uDFFF]{2,}/;function Gs(t,e=document){let n=e.defaultView||window;if(!At()||!e.body||!(n.visualViewport?.scale<1||n.screen.width<e.documentElement.clientWidth))return;let o=tt(e.createElement("div"));o.style.cssText="position:absolute;left:0;top:0;width:0;height:0;overflow:hidden;visibility:hidden";let i=[];for(let[r,s]of t){if(r.nodeType!==1||s.nodeType!==1)continue;let a=n.getComputedStyle(s),l=s.localName==="textarea"||s.localName==="input"&&cu.has(s.type)?du(s,a,e):uu(s,a.textAlign==="justify"||a.textAlignLast==="justify");if(!l)continue;let u=s.getBoundingClientRect(),c=s.offsetWidth&&u.width?u.width/s.offsetWidth:1,f=e.createElement("span");f.style.whiteSpace="pre";for(let d of lu)f.style.setProperty(d,a.getPropertyValue(d));f.textContent=l.word,o.appendChild(f),i.push({clone:r,cs:a,span:f,live:l.distance/c,centers:l.centers,height:l.height})}if(i.length){e.body.appendChild(o);try{for(let{clone:r,cs:s,span:a,live:l,centers:u,height:c}of i){let f=a.firstChild,d=(parseFloat(s.letterSpacing)||0)*(u?f.length-1:f.length),h=c?e.createRange():null;h&&h.selectNodeContents(a);let m=c?h.getBoundingClientRect().height:u?Math.abs(Ns(f,f.length-1)-Ns(f,0)):a.getBoundingClientRect().width,g=(l-(c?0:d))/(m-(c?0:d));if(g>1.005&&Number.isFinite(g)){if(c){let p=[];for(let y of[!1,!0]){let b=parseFloat(s.fontSize),w=b*(g+1);for(let S=0;S<10;S++){let v=(b+w)/2;a.style.fontSize=`${v}px`;let C=h.getBoundingClientRect().height;(y?C>l:C>=l)?w=v:b=v}p.push((b+w)/2)}g=(p[0]+p[1])/2/parseFloat(s.fontSize)}r.style.setProperty("font-size",`${parseFloat(s.fontSize)*g}px`),s.lineHeight!=="normal"&&r.style.setProperty("line-height",`${parseFloat(s.lineHeight)*g}px`)}}}finally{o.remove()}}}function Ns(t,e){let n=t.ownerDocument.createRange();n.setStart(t,e),n.setEnd(t,e+1);let o=n.getBoundingClientRect();return o.left+o.width/2}function uu(t,e=!1){for(let n=t.firstChild;n;n=n.nextSibling){if(n.nodeType!==3)continue;let o=/\S+/.exec(n.data);if(!o)continue;let i=t.ownerDocument.createRange();i.setStart(n,o.index),i.setEnd(n,o.index+o[0].length);let r=i.getClientRects();return r.length===1?{word:o[0],distance:e?r[0].height:r[0].width,centers:!1,height:e}:null}return null}function du(t,e,n){let o=fu.exec(t.value.split(`
`)[0]);if(!o||t.scrollLeft||t.scrollTop||!n.caretPositionFromPoint)return null;let i=t.getBoundingClientRect(),r=t.localName==="textarea"?i.top+(parseFloat(e.borderTopWidth)||0)+(parseFloat(e.paddingTop)||0)+3:i.top+i.height/2,s=c=>{let f=n.caretPositionFromPoint(c,r);return f&&f.offsetNode===t?f.offset:-1},a=i.width/16,l=c=>{let f=i.left;for(;f<=i.right&&s(f)<c;)f+=a;if(f>i.right)return NaN;let d=f-a;for(let h=0;h<16;h++){let m=(d+f)/2;s(m)>=c?f=m:d=m}return f},u=Math.abs(l(o.index+o[0].length)-l(o.index+1));return Number.isFinite(u)?{word:o[0],distance:u,centers:!0}:null}yt();var qs=new Set(["rgba(0, 0, 0, 0)","transparent"]),vr="Highlight";function Xs(t){let n=(t.ownerDocument||document).getSelection?.();if(!n||n.isCollapsed||n.rangeCount===0)return null;let o=[];for(let i=0;i<n.rangeCount;i+=1){let r=n.getRangeAt(i);if(!r.collapsed)try{r.intersectsNode(t)&&o.push(r)}catch{}}return o.length?{ranges:o,styles:new Map}:null}function pu(t,e){if(e.styles.has(t))return e.styles.get(t);let n;try{let o=getComputedStyle(t);if(o.userSelect==="none"||o.webkitUserSelect==="none"||o.getPropertyValue("-webkit-user-select")==="none")return e.styles.set(t,null),null;let i=getComputedStyle(t,"::selection"),r=[],s=i.backgroundColor,a=s&&!qs.has(s)&&s!==o.backgroundColor;r.push(`background-color:${a?s:vr}`),i.color&&i.color!==o.color&&r.push(`color:${i.color}`,`-webkit-text-fill-color:${i.color}`),i.textShadow&&i.textShadow!==o.textShadow&&r.push(`text-shadow:${i.textShadow}`),i.textDecorationLine&&i.textDecorationLine!=="none"&&i.textDecorationLine!==o.textDecorationLine&&r.push(`text-decoration:${i.textDecorationLine} ${i.textDecorationStyle||"solid"} ${i.textDecorationColor||"currentcolor"}`),n=r.join(";")}catch{n=`background-color:${vr}`}return e.styles.set(t,n),n}function Ys(t,e){let n=t.data;if(!n)return null;let o=t.parentElement;if(!o)return null;let i=[];for(let u of e.ranges){let c=!1;try{c=u.intersectsNode(t)}catch{}if(!c)continue;let f=u.startContainer===t?u.startOffset:0,d=u.endContainer===t?u.endOffset:n.length;d>f&&i.push([f,d])}if(i.length===0)return null;let r=pu(o,e);if(!r)return null;i.sort((u,c)=>u[0]-c[0]);let s=t.ownerDocument||document,a=s.createDocumentFragment(),l=0;for(let[u,c]of i){u>l&&a.append(s.createTextNode(n.slice(l,u)));let f=s.createElement("span");f.setAttribute("data-snapdom-selection",""),f.setAttribute("style",`all:unset;${r}`),f.textContent=n.slice(u,c),a.append(f),l=c}return l<n.length&&a.append(s.createTextNode(n.slice(l))),a}var Jn=t=>Number.parseFloat(t)||0,hu=["font-family","font-size","font-weight","font-style","font-variant","font-stretch","letter-spacing","word-spacing","text-transform","text-indent","text-align","line-height","tab-size","direction"];function mu(t,e){try{let o=getComputedStyle(t,"::selection").backgroundColor;if(o&&!qs.has(o)&&o!==e.backgroundColor)return o}catch{}return vr}function Ks(t,e){let n=t.ownerDocument||document;if(n.activeElement!==t)return;let o=null,i=null;try{o=t.selectionStart,i=t.selectionEnd}catch{return}if(o==null||i==null||o===i)return;let r=t.value||"";if(t.localName==="input"&&t.type==="password"&&(r="\u2022".repeat(r.length)),!r)return;let s=getComputedStyle(t),a=t.localName==="textarea",l=Jn(s.paddingLeft),u=Jn(s.paddingTop),c=t.clientWidth-l-Jn(s.paddingRight),f=t.clientHeight-u-Jn(s.paddingBottom),d=n.createElement("div");d.style.cssText="position:absolute;top:0;left:-99999px;visibility:hidden;margin:0;border:0;padding:0;box-sizing:content-box;";for(let p of hu)d.style.setProperty(p,s.getPropertyValue(p));a?(d.style.whiteSpace="pre-wrap",d.style.overflowWrap="break-word",d.style.width=`${Math.max(0,c)}px`):d.style.whiteSpace="pre";let h=n.createElement("span");h.textContent=r.slice(o,i),d.append(n.createTextNode(r.slice(0,o)),h,n.createTextNode(r.slice(i))),n.body.appendChild(d);let m=[];try{let p=d.getBoundingClientRect(),y=-t.scrollLeft,b=-t.scrollTop;if(!a){b+=Math.max(0,(f-p.height)/2);let w=s.direction==="rtl",S=s.textAlign;S==="start"?S=w?"right":"left":S==="end"&&(S=w?"left":"right");let v=c-p.width;v>0&&(S==="right"?y+=v:S==="center"&&(y+=v/2))}for(let w of h.getClientRects())w.width<=0||w.height<=0||m.push({x:l+(w.left-p.left)+y,y:u+(w.top-p.top)+b,width:w.width,height:w.height})}finally{d.remove()}if(m.length===0)return;let g=mu(t,s);e.__snapdomFieldSelection={images:m.map(()=>`linear-gradient(${g},${g})`),positions:m.map(p=>`${p.x}px ${p.y}px`),sizes:m.map(p=>`${p.width}px ${p.height}px`),repeats:m.map(()=>"no-repeat"),origins:m.map(()=>"padding-box"),clips:m.map(()=>"padding-box"),base:{image:s.backgroundImage,position:s.backgroundPosition,size:s.backgroundSize,repeat:s.backgroundRepeat,origin:s.backgroundOrigin,clip:s.backgroundClip}}}function Js(t){for(let e of t.keys()){let n=e.__snapdomFieldSelection;if(!n)continue;delete e.__snapdomFieldSelection;let{images:o,positions:i,sizes:r,repeats:s,origins:a,clips:l,base:u}=n,c=e.style.backgroundImage||u.image;c&&c!=="none"?(o.push(c),i.push(e.style.backgroundPosition||u.position),r.push(e.style.backgroundSize||u.size),s.push(e.style.backgroundRepeat||u.repeat),a.push(e.style.backgroundOrigin||u.origin),l.push(e.style.backgroundClip||u.clip)):(o.push("linear-gradient(transparent,transparent)"),i.push("0% 0%"),r.push("auto"),s.push("repeat"),a.push(u.origin||"padding-box"),l.push(u.clip||"border-box")),e.style.backgroundImage=o.join(","),e.style.backgroundPosition=i.join(","),e.style.backgroundSize=r.join(","),e.style.backgroundRepeat=s.join(","),e.style.backgroundOrigin=a.join(","),e.style.backgroundClip=l.join(",")}}Tt();vt();var gu=["transform","translate","rotate","scale","transform-origin","transform-box"],yu={circle:["cx","cy","r","vector-effect"],ellipse:["cx","cy","rx","ry","vector-effect"],rect:["x","y","width","height","rx","ry","vector-effect"],path:["d","vector-effect"],line:["vector-effect"],polyline:["vector-effect"],polygon:["vector-effect"],use:["x","y","width","height","vector-effect"],g:[],clipPath:[]},bu={r:"0px",cx:"0px",cy:"0px",x:"0px",y:"0px",rx:"auto",ry:"auto",width:"auto",height:"auto",d:"none","vector-effect":"none",transform:"none",translate:"none",rotate:"none",scale:"none","transform-origin":"0px 0px","transform-box":"view-box"},Qs=new Set(["transform","translate","rotate","scale"]),Zs=new WeakMap,wu=new Map;function xu(t){let e=t.localName,n=yu[e];if(!n)return null;let o=gs(t);if(o&&(o.size===0||!ys(t)))return null;let i=o?Zs.get(o):wu;i||Zs.set(o,i=new Map);let r=i.get(e);return r||(r=[...n,...gu].filter(s=>!o||o.has(s)),i.set(e,r)),r.length?r:null}var ta=/^-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?$/i;function Su(t,e){let n=t.trim();if(!ta.test(n)||!ta.test(e))return!1;let o=parseFloat(n),i=parseFloat(e);return Math.abs(o-i)<=1e-4*Math.max(1,Math.abs(o))}function vu(t){let e=t.transform?.baseVal;if(!e?.numberOfItems)return null;let n=new DOMMatrix;for(let o=0;o<e.numberOfItems;o++){let i=e.getItem(o).matrix;n=n.multiply(new DOMMatrix([i.a,i.b,i.c,i.d,i.e,i.f]))}return n}function Cu(t,e){let n=vu(t),o=e==="none"?[1,0,0,1,0,0]:e.startsWith("matrix(")?e.slice(7,-1).split(",").map(Number):null;if(!o||o.length!==6)return!1;if(!n)return o.join()==="1,0,0,1,0,0";let i=[n.a,n.b,n.c,n.d,n.e,n.f];for(let r=0;r<6;r++)if(Math.abs(i[r]-o[r])>1e-4*Math.max(1,Math.abs(i[r])))return!1;return!0}function ku(t,e,n,o){let i=!1;for(let r of o){if(!i&&(r==="transform-origin"||r==="transform-box")&&!t.hasAttribute("transform"))continue;let s=n.getPropertyValue(r);if(!s)continue;Qs.has(r)&&s!=="none"&&(i=!0);let a=Qs.has(r)&&r!=="transform"?null:t.getAttribute(r);if(a!=null){if(s===a||s===a+"px"||r==="d"||r==="transform"&&(s==="none"||Cu(t,s))||Su(a,s))continue}else if(s===bu[r])continue;e.style.setProperty(r,s)}}var Cr=new Map,ea=new Set(["IFRAME"]);function je(t,e){Cr.set(String(t).toUpperCase(),e)}function Qn(t){let e=W(t),n=e.display;if(n==="none")return null;let o=/^(block|inline-block|flow-root|flex|inline-flex|grid|inline-grid|list-item)$/.test(n),i=h=>parseFloat(h)||0,r=(h,m,g,p,y)=>{if(!o||!h?.endsWith("px"))return null;let b=parseFloat(h);if(!Number.isFinite(b)||b<0)return null;if(e.boxSizing==="border-box")return b;let w=p-y-g;return b+m+g+(w>0&&b+m<y+w/2?w:0)},[s,a,l,u]=/scroll|auto/.test(e.overflow)?[t.offsetWidth,t.clientWidth,t.offsetHeight,t.clientHeight]:[0,0,0,0],c=r(e.width,i(e.paddingLeft)+i(e.paddingRight),i(e.borderLeftWidth)+i(e.borderRightWidth),s,a),f=r(e.height,i(e.paddingTop)+i(e.paddingBottom),i(e.borderTopWidth)+i(e.borderBottomWidth),l,u);if(c===null||f===null){let{width:h,height:m}=Et(t),g=h,p=m;if(c===null&&!g||f===null&&!p){let y=t.getBoundingClientRect();g||=y.width||0,p||=y.height||0}c??=g,f??=p}let d=document.createElement("div");return d.style.cssText=`display:${n==="inline"?"inline-block":n};box-sizing:border-box;width:${c}px;height:${f}px;visibility:hidden;`,d}var Mu=new Set(["style","option","optgroup"]),Zn=200,Au=new Set(["img","canvas","video","iframe","object","embed"]);function Cn(t){let e=0;for(let n of t.matchAll(/-?[\d.]+px/g))e+=Math.abs(parseFloat(n[0]));return e}function sa(t){let e=t.filter;return!e||e==="none"?0:e.includes("url(")?Zn:3*Cn(e)}function aa(t,e){if(!t)return 0;let n=e.filterReach||=new WeakMap,o=n.get(t);return o===void 0&&(o=sa(W(t))+(t===e.root?0:aa(t.parentElement,e)),n.set(t,o)),o}function na(t,e,n){try{if(!e||!t.matches(e))return!1}catch{return!0}let o=W(t,n).content;return!!o&&o!=="none"&&o!=="normal"}function _u(t,e,n){let{before:o,after:i}=ae(t);if(o===null||i===null||na(t,o,"::before")||na(t,i,"::after")||e.borderImageSource&&e.borderImageSource!=="none"||e.webkitBoxReflect&&e.webkitBoxReflect!=="none")return Zn;let r=parseFloat(e.fontSize)||16,s=e.outlineStyle==="none"?0:Cn(e.outlineWidth)+Cn(e.outlineOffset);return Math.max(r*(e.display==="list-item"?3:1),s,Cn(e.boxShadow),Cn(e.textShadow),sa(e))+aa(t.parentElement,n)}function oa(t,e,n,o){let i=o.rect,r=Math.max(i.left-n.right,n.left-i.right,i.top-n.bottom,n.top-i.bottom);if(r<=0)return!0;if(r>Zn)return!1;let s=o.inkReach||=new WeakMap,a=s.get(t);return a===void 0&&s.set(t,a=_u(t,e||W(t),o)),r<=a}function Eu(t,e){if(t===e.root)return!1;let n;try{n=t.getBoundingClientRect()}catch{return!1}if(n.width===0&&n.height===0)return!1;let o=W(t);if(o.display==="inline"&&!Au.has((t.localName||"").toLowerCase()))return!1;let i=t.scrollWidth||0,r=t.scrollHeight||0,s={left:o.directi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (javascript.browser.security.insecure-innerhtml): User controlled data in a p.innerHTML is an anti-pattern that can lead to XSS vulnerabilities

Source: opengrep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(Dom2Image): update SnapDOM to v3.5.0

1 participant