(function () { "use strict"; const STORAGE_KEY = "emagrants_cookie_consent_v1"; function getConsent() { try { return localStorage.getItem(STORAGE_KEY); } catch (error) { return null; } } function saveConsent(choice) { try { localStorage.setItem(STORAGE_KEY, choice); } catch (error) { console.warn("Cookie preference could not be saved."); } } function removeBanner(banner) { if (!banner) { return; } banner.classList.add("cookie-notice--hidden"); setTimeout(function () { if (banner.parentNode) { banner.parentNode.removeChild(banner); } }, 250); } function createBanner() { if (getConsent()) { return; } if (document.getElementById("cookie-notice")) { return; } const banner = document.createElement("aside"); banner.id = "cookie-notice"; banner.className = "cookie-notice"; banner.setAttribute( "role", "dialog" ); banner.setAttribute( "aria-label", "Cookie notice" ); banner.innerHTML = ` `; document.body.appendChild(banner); banner.addEventListener( "click", function (event) { const button = event.target.closest( "[data-cookie-choice]" ); if (!button) { return; } const choice = button.getAttribute( "data-cookie-choice" ); saveConsent(choice); removeBanner(banner); } ); } function initialize() { if ( document.readyState === "loading" ) { document.addEventListener( "DOMContentLoaded", createBanner ); } else { createBanner(); } } initialize(); })();