(function () { "use strict"; var KEY = "veinsforge-theme"; var root = document.documentElement; function preferred() { try { if (window.matchMedia && window.matchMedia("(prefers-color-scheme: light)").matches) { return "light"; } } catch (e) {} return "dark"; } function apply(theme) { root.setAttribute("data-theme", theme === "light" ? "light" : "dark"); } try { apply(localStorage.getItem(KEY) || preferred()); } catch (e) { apply(preferred()); } var toggle = document.getElementById("theme-toggle"); if (toggle) { toggle.addEventListener("click", function () { var next = root.getAttribute("data-theme") === "light" ? "dark" : "light"; apply(next); try { localStorage.setItem(KEY, next); } catch (e) {} }); } var copies = document.querySelectorAll(".copy-input"); for (var i = 0; i < copies.length; i++) { copies[i].addEventListener("focus", function () { this.select(); }); } function highlightCode() { if (!window.hljs) return; var blocks = document.querySelectorAll("pre.code code[class*='language-']"); for (var i = 0; i < blocks.length; i++) { var block = blocks[i]; // Very large files can lock up the tab during synchronous highlighting. if (block.textContent.length > 500000) continue; try { window.hljs.highlightElement(block); } catch (e) {} } } highlightCode(); })();