function initCookieConsent_memo(){function setCookie_memo(name,value,days){let expires="";if(days){const d=new Date();d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000);expires="; expires=" + d.toUTCString();}document.cookie=name+"="+(value || "") + expires + "; path=/; SameSite=Lax";}function getCookie_memo(name){const nameEQ=name+"=";const ca = document.cookie.split(";");for (let i = 0; i < ca.length; i++){let c=ca[i];while(c.charAt(0) === " ")c=c.substring(1,c.length);if(c.indexOf(nameEQ) === 0)return c.substring(nameEQ.length,c.length);}return null;}const COOKIE_NAME = "cookieConsentPrefs";const defaultPrefs={essential: true,statistics: false,marketing: false};let prefs = defaultPrefs;const styleContent = ` #cookie-consent-banner{position:fixed;bottom:0;left:0;right:0;background:#222;color:#fff;padding:15px 20px;font-family:Arial;font-size:14px;display:flex;align-items:center;z-index:2147483647;box-shadow:0 -2px 5px #0000004d;pointer-events:auto;gap:30px} #cookie-consent-banner > div:first-child{flex:1;display:flex;flex-direction:column;justify-content:center} #cookie-consent-banner > div:first-child h1{margin:0 0 5px;font-size:20px;font-weight:700;display:block;color:#fff} #cookie-consent-banner > div:first-child p{margin:0 0 5px;font-size:14px;line-height:1.3;display:block;color:#fff} #cookie-consent-banner > div:first-child a{color:#fff;text-decoration:underline;cursor:pointer;font-size:14px;width:fit-content} #cookie-consent-banner > div:last-child{display:flex;gap:10px;flex-wrap:nowrap;justify-content:flex-end} #cookie-consent-banner button{background:#0072ce;border:none;color:#fff;padding:8px 14px;cursor:pointer;border-radius:3px;font-weight:600;white-space:nowrap} #cookie-consent-banner button:hover{background:#005bb5} #cookie-consent-panel{position:fixed;top:0;left:0;height:100vh;width:350px;background:#222;font-family:Arial;color:#fff;font-size:14px;padding:25px 20px;overflow-y:auto;z-index:2147483647;display:flex;flex-direction:column;transform:translateX(-100%);transition:transform .3s ease-in-out;border-right:1px solid #ccc} #cookie-consent-panel.show{transform:translateX(0)} #cookie-consent-panel h2{margin-top:0;font-weight:700;font-size:20px;margin-bottom:15px;color:#fff} #cookie-consent-panel p{margin-bottom:15px;line-height:1.4;color:#fff} #cookie-consent-panel .cookie-category{margin-bottom:15px;border-bottom:1px solid #ddd;padding-bottom:10px} .cookie-row{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px} .checkbox-toggle-label{position:relative;display:inline-flex;align-items:center;justify-content:space-between;width:90px;height:32px;background-color:#888;border-radius:20px;padding:4px 8px;cursor:pointer;font-size:12px;transition:background-color .3s} .checkbox-toggle-label .checkbox-toggle-on,.checkbox-toggle-label .checkbox-toggle-off{z-index:2;font-weight:600;font-size:12px;transition:color .3s} .checkbox-toggle-toggle{width:50%;height:100%;background:#fff;border-radius:50px;position:absolute;top:0;left:0;transition:transform .3s;z-index:1} .checkbox-toggle-input:checked ~ .checkbox-toggle-toggle{transform:translate(100%,0%)} .checkbox-toggle-input:checked ~ .checkbox-toggle-on{color:#0c6} .checkbox-toggle-input:not(:checked) ~ .checkbox-toggle-off{color:#ccc} .checkbox-toggle-input:checked ~ .checkbox-toggle-label{background-color:#0c6!important} .checkbox-toggle-label:focus-within{outline:auto} .checkbox-toggle-input{position:absolute;opacity:0;width:0;height:0} .checkbox-toggle-on,.checkbox-toggle-off{color:#fff;font-weight:600;transition:opacity .2s;z-index:2} .checkbox-toggle-toggle{width:50%;height:100%;background:#fff;border-radius:50px;position:absolute;top:0;left:0;transition:transform .3s;z-index:1} .checkbox-toggle-input:checked ~ .checkbox-toggle-toggle{transform:translate(100%,0%)} .ccc-sr-only{position:absolute!important;height:1px;width:1px;overflow:hidden;clip:rect(1px,1px,1px,1px);white-space:nowrap} .checkbox-toggle-label:focus-within{outline:auto} #cookie-consent-panel button{background:#0072ce;border:none;color:#fff;padding:10px 16px;margin-top:10px;cursor:pointer;border-radius:3px;font-weight:600;width:100%} #cookie-consent-panel button:hover{background:#005bb5} #cookie-consent-panel #close-panel{background:transparent;border:2px solid #fff} .cookie-title-with-toggle{display:flex;align-items:center;gap:6px;cursor:pointer;user-select:none} .arrow{display:inline-block;transition:transform .3s ease;font-size:14px} .cookie-title-with-toggle.active .arrow{transform:rotate(180deg)} .cookie-description{display:none;margin-top:10px;font-size:13px;color:#444} @media screen and (max-width: 576px) {#cookie-consent-banner{flex-direction:column!important}} `;function injectStyle_memo(){if (!document.getElementById("cookie-consent-style")){const style=document.createElement("style");style.id="cookie-consent-style";style.textContent=styleContent;document.head.appendChild(style);}} function createBanner_cookie() { if (document.getElementById("cookie-consent-banner"))return; const banner = document.createElement("div"); banner.id = "cookie-consent-banner"; banner.innerHTML = `

Este website utiliza cookies

Utilizamos cookies para personalizar conteúdo e anúncios, fornecer funcionalidades de redes sociais e analisar o nosso tráfego...

Ver mais
`; document.body.appendChild(banner); document.getElementById("cookie-accept-all").addEventListener("click", () => {prefs = { essential:true,statistics:true,marketing:true };savePrefs_memo();removeBanner_cookie();}); document.getElementById("cookie-view-more").addEventListener("click", () => {removeBanner_cookie();showPanel_cookie();}); document.getElementById("cookie-details-all").addEventListener("click", () => {removeBanner_cookie();showPanel_cookie();}); }function removeBanner_cookie() {const b = document.getElementById("cookie-consent-banner");if (b) b.remove();}function updateSwitchLabels() { const switches = document.querySelectorAll("#cookie-consent-panel .switch"); switches.forEach(s => { const input = s.querySelector("input"); const label = s.querySelector(".switch-label"); if (input && label) { label.textContent = input.checked ? "On" : "Off"; input.addEventListener("change", () => {label.textContent = input.checked ? "On" : "Off";}); } }); } function createPanel_cookie(){ if (document.getElementById("cookie-consent-panel")) return; const panel = document.createElement("div"); panel.id = "cookie-consent-panel"; panel.innerHTML = `

Configuração de Cookies

Utilizamos cookies para personalizar conteúdo e anúncios, fornecer funcionalidades de redes sociais e analisar o nosso tráfego.
Concorda com os nossos cookies se continuar a utilizar o nosso website.

`; document.body.appendChild(panel);updateSwitchLabels(); document.getElementById("cookie-save-prefs").addEventListener("click", () => {const newPrefs = {essential: true,statistics: document.getElementById("cookie-statistics").checked,marketing: document.getElementById("cookie-marketing").checked};savePrefs_memo(newPrefs);hidePanel_cookie();}); document.querySelectorAll('.cookie-title-with-toggle').forEach(toggle => { toggle.addEventListener('click', () => { const category = toggle.closest('.cookie-category'); const desc = category.querySelector('.cookie-description'); const isVisible = desc.style.display === 'table'; desc.style.display = isVisible ? 'none' : 'table'; toggle.classList.toggle('active', !isVisible); toggle.setAttribute('aria-expanded', String(!isVisible)); }); toggle.addEventListener('keydown', e => {if (e.key === 'Enter' || e.key === ' ') {e.preventDefault();toggle.click();}}); }); document.getElementById("close-panel").addEventListener("click", () => {hidePanel_cookie();}); } function showPanel_cookie() {const panel = document.getElementById("cookie-consent-panel");if (panel){document.getElementById("cookie-statistics").checked = prefs.statistics;document.getElementById("cookie-marketing").checked = prefs.marketing;panel.classList.add("show");updateSwitchLabels();}} function hidePanel_cookie() {const panel = document.getElementById("cookie-consent-panel");if (panel) panel.classList.remove("show");} function removeOptionalCookies() { const consent = JSON.parse(getCookie_memo("cookieConsentPrefs") || "{}"); if (!consent.statistics) { document.cookie = '_ga=; Max-Age=0; path=/'; document.cookie = '_gid=; Max-Age=0; path=/'; document.cookie = '_gat=; Max-Age=0; path=/'; const gaScript = document.querySelector('script[src*="googletagmanager"]'); if (gaScript) gaScript.remove(); if (window.gtag) delete window.gtag; } if (!consent.marketing) { document.cookie = '_gcl_au=; Max-Age=0; path=/'; const jivoScript = document.getElementById('jivo-widget'); if (jivoScript) jivoScript.remove(); if (window.jivo_api) { try { window.jivo_api.close(); delete window.jivo_api; } catch (e) {} } const fbScript = document.querySelector('script[src*="connect.facebook.net"]'); if (fbScript) fbScript.remove(); if (window.fbq) delete window.fbq; } } function loadJivoIfAllowed() { const cookie = getCookie_memo(COOKIE_NAME); if (cookie) { try { const consent = JSON.parse(cookie); if (consent.marketing && !document.getElementById('jivo-widget')) { const jivo = document.createElement('script'); jivo.src = '//code.jivosite.com/widget/'; jivo.id = 'jivo-widget'; jivo.async = true; document.head.appendChild(jivo); } } catch (e) { console.warn("Erro ao carregar consentimento para JivoChat"); } } } function savePrefs_memo(passedPrefs) { const updatedPrefs = passedPrefs || prefs; prefs = updatedPrefs; setCookie_memo(COOKIE_NAME, JSON.stringify(updatedPrefs), 365); removeOptionalCookies(); if ((updatedPrefs.statistics || updatedPrefs.marketing) && !window.gtagScriptLoaded) { } } function openCookieSettings() { const panel = document.getElementById("cookie-consent-panel"); if (!panel) {console.warn("Painel de cookies não foi encontrado.");return;} const cookiePrefs = getCookie_memo("cookieConsentPrefs"); if (cookiePrefs) { try { const prefs = JSON.parse(cookiePrefs); document.getElementById("cookie-statistics").checked = !!prefs.statistics; document.getElementById("cookie-marketing").checked = !!prefs.marketing; } catch (e) { console.warn("Erro ao ler preferências de cookies."); } } panel.classList.add("show"); updateSwitchLabels(); } function loadPrefs_memo() { const cookie = getCookie_memo(COOKIE_NAME); if (cookie) { try { const c = JSON.parse(cookie); if (typeof c === "object" && c !== null) { prefs = {essential: true,statistics: !!c.statistics,marketing: !!c.marketing}; } } catch (e) {prefs = defaultPrefs;} } else {prefs = defaultPrefs;} } function init_memo() { injectStyle_memo(); loadPrefs_memo(); createPanel_cookie(); if (!getCookie_memo(COOKIE_NAME)) {createBanner_cookie();} } window.openCookieSettings = openCookieSettings; window.savePrefs_memo = savePrefs_memo; init_memo(); } initCookieConsent_memo(); window.addEventListener("load", function () { const consentCookie = document.cookie.split(';').find(c => c.trim().startsWith('cookieConsentPrefs=')); if (!consentCookie) {console.log('Consentimento de cookies ainda não dado. Scripts bloqueados.');} else { try { const valor = decodeURIComponent(consentCookie.split('=')[1]); const prefs = JSON.parse(valor); if (prefs.statistics || prefs.marketing) {savePrefs_memo(prefs);} } catch (e) { console.warn('Erro a ler cookie de consentimento:', e); document.cookie = "cookieConsentPrefs=; Max-Age=0; path=/"; } } });