). We later use the `html:has(head > [data-stack-theme=XYZ])` selector to apply styles based on the theme. */",document.head.appendChild(b)),b.setAttribute("data-stack-theme",a)},d=()=>{let a=getComputedStyle(document.documentElement).getPropertyValue("color-scheme");if(a){let d=b(a);if(d)return c(d),!0}return!1},e=()=>{let a=getComputedStyle(document.documentElement).getPropertyValue("--background");if(a){var b;let d,e,f;/^\d+\s\d+%\s\d+(\.\d+)?%$/.test(a)&&(a=`hsl(${a})`);let g=(b=a,(d=document.createElement("div")).style.color=b,document.body.appendChild(d),e=getComputedStyle(d).color,document.body.removeChild(d),(f=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))?[parseInt(f[1]),parseInt(f[2]),parseInt(f[3])]:null);if(g)return(299*g[0]+587*g[1]+114*g[2])/1e3<128?c("dark"):c("light"),!0}return!1},f=()=>{for(let d of a){let a=document.documentElement.getAttribute(d);if(a){let d=b(a);if(d)return c(d),!0}}return!1};new MutationObserver(b=>{b.forEach(b=>{if(!d()&&!(b.attributeName&&a.includes(b.attributeName)&&f())&&e())return})}).observe(document.documentElement,{attributes:!0,attributeFilter:a}),d()||f()||e()})()
All Things Web