import "https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@3.1.0/dist/cookieconsent.umd.js"; const updateGtagConsent = ({ analytics, ads }) => { if (typeof gtag !== "function") return; gtag("consent", "update", { analytics_storage: analytics ? "granted" : "denied", ad_storage: ads ? "granted" : "denied", }); }; const applyConsentState = (cookie) => { const categories = cookie?.categories ?? []; const analytics = categories.includes("analytics"); const ads = categories.includes("ads"); updateGtagConsent({ analytics, ads }); }; CookieConsent.run({ guiOptions: { consentModal: { layout: "box", position: "bottom right", equalWeightButtons: true, flipButtons: true, }, preferencesModal: { layout: "box", position: "right", equalWeightButtons: true, flipButtons: false, }, }, categories: { necessary: { readOnly: true, }, analytics: { enabled: true, }, ads: { enabled: true, }, }, language: { default: "en", autoDetect: "browser", translations: { en: { consentModal: { title: "Cookie preferences", description: "This site uses cookies for analytics (Google Analytics, Vercel Analytics) and to show ads (Google AdSense). You can accept all, reject non-essential cookies, or manage your choices below.", acceptAllBtn: "Accept all", acceptNecessaryBtn: "Reject non-essential", showPreferencesBtn: "Manage preferences", footer: 'Privacy Policy Terms and Conditions', }, preferencesModal: { title: "Cookie preferences", acceptAllBtn: "Accept all", acceptNecessaryBtn: "Reject non-essential", savePreferencesBtn: "Save preferences", closeIconLabel: "Close", serviceCounterLabel: "Service|Services", sections: [ { title: "How we use cookies", description: "We use cookies only for site analytics and advertising. You can enable or disable each category below. Necessary cookies are required for the site to function and cannot be turned off.", }, { title: 'Strictly necessary Always on', description: "Essential for the site to work (e.g. security, basic layout). These cannot be disabled.", linkedCategory: "necessary", }, { title: "Analytics", description: "We use Google Analytics and Vercel Analytics to understand how visitors use the site (e.g. page views, traffic). Data is anonymized where possible.", linkedCategory: "analytics", }, { title: "Advertising", description: "We use Google AdSense to show ads. These cookies help deliver relevant ads and measure ad performance.", linkedCategory: "ads", }, { title: "Legal & contact", description: 'Read our Privacy Policy and Terms and Conditions. For questions about cookies or your data, use the contact page.', }, ], }, }, }, }, onConsent: ({ cookie }) => { applyConsentState(cookie); }, onChange: ({ cookie, changedCategories }) => { const relevantChanges = changedCategories.filter((category) => ["analytics", "ads"].includes(category), ); if (relevantChanges.length === 0) return; const shouldReload = relevantChanges.some( (category) => !CookieConsent.acceptedCategory(category), ); if (shouldReload) { window.location.reload(); return; } applyConsentState(cookie); }, });