cookiecraft 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CookieCraft={})}(this,function(e){"use strict";class t{save(e){try{localStorage.setItem(t.STORAGE_KEY,JSON.stringify(e))}catch(e){}}load(){try{const e=localStorage.getItem(t.STORAGE_KEY);if(!e)return null;const i=JSON.parse(e);if(!this.validateSchema(i)){const e=this.migrate(i);return e?(this.save(e),e):null}return i}catch(e){return null}}clear(){try{localStorage.removeItem(t.STORAGE_KEY)}catch(e){}}isExpired(e){const t=new Date(e.expiresAt);return!!isNaN(t.getTime())||t<new Date}validateSchema(e){return e&&"number"==typeof e.version&&"string"==typeof e.timestamp&&"object"==typeof e.categories&&"string"==typeof e.expiresAt}migrate(e){if(!e||"object"!=typeof e)return null;const i=e;if(i.categories&&"object"==typeof i.categories){const e=new Date,s=new Date(e);s.setMonth(s.getMonth()+t.EXPIRY_MONTHS);const n=i.categories,o={necessary:!0===n.necessary,analytics:!0===n.analytics,marketing:!0===n.marketing};return"preferences"in n&&(o.preferences=!0===n.preferences),{version:"number"==typeof i.version?i.version:1,timestamp:"string"==typeof i.timestamp?i.timestamp:e.toISOString(),categories:o,expiresAt:"string"==typeof i.expiresAt?i.expiresAt:s.toISOString()}}return null}}t.STORAGE_KEY="cookiecraft_consent",t.EXPIRY_MONTHS=13;class i{constructor(e){this.consent=null,this.config=e}validateConsent(e){if(!e.necessary)return!1;if(this.config.categories&&Object.keys(this.config.categories).length>0)for(const t of Object.keys(e))if(!(t in this.config.categories))return!1;for(const t of Object.keys(e))e[t]=!0===e[t];return!0}updateConsent(e){if(!this.validateConsent(e))throw Error("Invalid consent categories");return this.consent=this.createConsentRecord(e),this.consent}needsConsent(){return null===this.consent}needsUpdate(e){return e.version<this.config.revision}getCurrentConsent(){return this.consent}createConsentRecord(e){const i=new Date,s=new Date(i);return s.setMonth(s.getMonth()+t.EXPIRY_MONTHS),{version:this.config.revision,timestamp:i.toISOString(),categories:Object.assign({},e),expiresAt:s.toISOString()}}}class s{constructor(){this.events=new Map}on(e,t){this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(t)}off(e,t){this.events.has(e)&&this.events.get(e).delete(t)}emit(e,t){this.events.has(e)&&this.events.get(e).forEach(e=>{try{e(t)}catch(e){}})}clear(){this.events.clear()}clearEvent(e){this.events.delete(e)}}class n{constructor(e,t){this.observer=null,this.blockedScripts=new Map,this.currentConsent=null,this.categoryManager=e,this.eventEmitter=t}init(){this.blockExistingScripts(),this.observeDOM()}block(){this.currentConsent=null,this.blockedScripts.clear(),this.blockExistingScripts()}unblock(e){this.currentConsent=e;const t=[];this.blockedScripts.forEach((i,s)=>{const n=this.categoryManager.getCategoryForScript(i);n&&this.categoryManager.isAllowed(n,e)&&(this.reactivateScript(i),t.push(s))}),t.forEach(e=>this.blockedScripts.delete(e))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null)}blockExistingScripts(){document.querySelectorAll("script[data-cookieconsent]").forEach(e=>{e instanceof HTMLScriptElement&&this.processScript(e)})}observeDOM(){this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e instanceof HTMLScriptElement&&e.hasAttribute("data-cookieconsent")&&this.processScript(e)})})}),this.observer.observe(document.documentElement,{childList:!0,subtree:!0})}processScript(e){const t=this.categoryManager.getCategoryForScript(e);if(t&&!(this.currentConsent&&this.categoryManager.isAllowed(t,this.currentConsent)||"text/plain"===e.type)){const t=this.generateScriptId(e);if(this.blockedScripts.has(t))return;e.setAttribute("data-original-type",e.type||"text/javascript"),e.type="text/plain",this.blockedScripts.set(t,e)}}reactivateScript(e){const t=document.createElement("script");Array.from(e.attributes).forEach(e=>{"type"!==e.name&&"data-original-type"!==e.name&&t.setAttribute(e.name,e.value)});const i=e.getAttribute("data-original-type")||"text/javascript";t.type=i,e.src?t.src=e.src:t.textContent=e.textContent,e.parentNode&&(e.parentNode.insertBefore(t,e),e.parentNode.removeChild(e)),this.eventEmitter.emit("script:activated",{category:e.getAttribute("data-cookieconsent"),src:e.src||"inline"})}generateScriptId(e){if(e.src)return"src:"+e.src;const t=e.textContent||"",i=e.getAttribute("data-cookieconsent")||"",s=e.getAttribute("data-cc-id");if(s)return s;const n=`inline:${i}:${this.simpleHash(t)}`;return e.setAttribute("data-cc-id",n),n}simpleHash(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return t.toString(36)}}class o{constructor(){this.categories=new Map,this.initializeDefaultPatterns()}registerCategory(e,t){this.categories.set(e,t)}getCategoryForScript(e){const t=e.getAttribute("data-cookieconsent");if(t)return t;const i=e.src;if(!i)return null;for(const[e,t]of this.categories)if(t.some(e=>i.includes(e)))return e;return null}isAllowed(e,t){return!0===t[e]}initializeDefaultPatterns(){this.categories.set("analytics",["google-analytics.com","analytics.google.com","plausible.io","matomo.org","hotjar.com","mixpanel.com","segment.com","amplitude.com"]),this.categories.set("marketing",["googletagmanager.com","facebook.net","facebook.com/tr","connect.facebook.net","doubleclick.net","ads.google.com","linkedin.com/analytics","twitter.com/i/adsct","pinterest.com/ct","adroll.com","taboola.com","outbrain.com","tiktok.com"]),this.categories.set("necessary",[])}}const c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},a=/[&<>"'`]/g;function r(e){return e.replace(a,e=>c[e]||e)}function l(e){const t=e.trim();return t.startsWith("https://")||t.startsWith("http://")||t.startsWith("/")||t.startsWith("./")?r(t):""}function h(e){const t=e.trim();return/^#[0-9a-fA-F]{3,8}$/.test(t)||/^rgba?\(\s*[\d\s,./%]+\)$/.test(t)||/^hsla?\(\s*[\d\s,./%deg]+\)$/.test(t)||/^[a-zA-Z]+$/.test(t)&&!["inherit","initial","unset","revert","revert-layer"].includes(t.toLowerCase())?t:""}function d(e){const t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t;if(/^#[0-9a-fA-F]{3}$/.test(t)){const e=t[1],i=t[2],s=t[3];return`#${e}${e}${i}${i}${s}${s}`}return/^#[0-9a-fA-F]{8}$/.test(t)?t.substring(0,7):null}function u(e){if(!e)return"";const t=d(e);if(!t)return`--cc-primary: ${e};`;const i=function(e){const t=d(e);if(!t)return e;const i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16),c=e=>Math.max(0,Math.min(255,Math.round(e+-15*e/100))),a=e=>{const t=e.toString(16);return 1===t.length?"0"+t:t};return`#${a(c(s))}${a(c(n))}${a(c(o))}`}(t);return`--cc-primary: ${t}; --cc-primary-hover: ${i};`}class p{constructor(e,t){this.element=null,this.hideTimeout=null,this.previousActiveElement=null,this.config=e,this.eventEmitter=t}show(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null);const e=()=>{this.element||(this.previousActiveElement=document.activeElement,this.element=this.createDOM(),document.body.appendChild(this.element),this.attachListeners()),requestAnimationFrame(()=>{var e;null===(e=this.element)||void 0===e||e.classList.add("is-visible")}),this.config.disablePageInteraction&&(document.body.style.overflow="hidden",this.trapFocus())};document.body?e():document.addEventListener("DOMContentLoaded",e)}hide(){var e;null===(e=this.element)||void 0===e||e.classList.remove("is-visible"),this.config.disablePageInteraction&&(document.body.style.overflow=""),this.hideTimeout=setTimeout(()=>{this.destroy()},300)}destroy(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),this.element&&(this.element.remove(),this.element=null),this.previousActiveElement&&document.contains(this.previousActiveElement)&&(this.previousActiveElement.focus(),this.previousActiveElement=null)}createDOM(){const e=this.config.translations||{},t=this.config.theme||"light",i=this.config.position||"bottom",s=this.config.layout||"bar",n=!1!==this.config.backdropBlur,o=this.config.disablePageInteraction,c=u(this.config.primaryColor?h(this.config.primaryColor):""),a=`\n <div\n class="cc-banner cc-banner--${r(i)} cc-banner--${r(s)} ${n?"cc-backdrop-blur":""}"\n role="${o?"dialog":"region"}"\n ${o?'aria-modal="true"':""}\n aria-label="Cookie consent"\n aria-live="polite"\n data-theme="${r(t)}"\n style="${c}"\n >\n <div class="cc-banner__container">\n <div class="cc-banner__content">\n <h2 class="cc-banner__title">\n ${r(e.title||"We use cookies")}\n </h2>\n <p class="cc-banner__description">\n ${this.getDescriptionHTML()}\n </p>\n </div>\n <div class="cc-banner__actions">\n <button\n class="cc-btn cc-btn--ghost"\n data-action="reject"\n aria-label="${r(e.rejectAll||"Essentials only")}"\n >\n ${r(e.rejectAll||"Essentials only")}\n </button>\n <button\n class="cc-btn cc-btn--tertiary"\n data-action="customize"\n aria-label="${r(e.customize||"Customize")}"\n >\n ${r(e.customize||"Customize")}\n </button>\n <button\n class="cc-btn cc-btn--accept"\n data-action="accept"\n aria-label="${r(e.acceptAll||"Accept all")}"\n >\n ${r(e.acceptAll||"Accept all")}\n </button>\n </div>\n </div>\n </div>\n `,l=document.createElement("div");return l.innerHTML=a.trim(),l.firstChild}attachListeners(){var e,t;null===(e=this.element)||void 0===e||e.addEventListener("click",e=>{const t=e.target.closest("[data-action]");if(t)switch(t.getAttribute("data-action")){case"accept":this.handleAcceptAll();break;case"reject":this.handleRejectAll();break;case"customize":this.handleCustomize()}}),null===(t=this.element)||void 0===t||t.addEventListener("keydown",e=>{"Escape"===e.key&&this.config.disablePageInteraction&&this.handleRejectAll()})}handleAcceptAll(){const e={necessary:!0,analytics:!0,marketing:!0};for(const t of Object.keys(this.config.categories))e[t]=!0;this.eventEmitter.emit("consent:accept",e),this.hide()}handleRejectAll(){const e={necessary:!0,analytics:!1,marketing:!1};for(const t of Object.keys(this.config.categories))"necessary"!==t&&(e[t]=!1);this.eventEmitter.emit("consent:reject",e),this.hide()}handleCustomize(){this.eventEmitter.emit("preferences:show"),this.hide()}trapFocus(){var e,t;const i=null===(e=this.element)||void 0===e?void 0:e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!i||0===i.length)return;const s=i[0],n=i[i.length-1];null==s||s.focus(),null===(t=this.element)||void 0===t||t.addEventListener("keydown",e=>{"Tab"===e.key&&(e.shiftKey&&document.activeElement===s?(e.preventDefault(),n.focus()):e.shiftKey||document.activeElement!==n||(e.preventDefault(),s.focus()))})}getDescriptionHTML(){const e=this.config.translations||{},t=r(e.description||"We use cookies to improve your experience on our site. You can choose which cookies you accept.");if(e.privacyPolicyUrl){const i=l(e.privacyPolicyUrl);if(i)return`${t} <a href="${i}" target="_blank" rel="noopener noreferrer">${r(e.privacyPolicyLabel||"Privacy Policy")}</a>`}return t}}class f{constructor(e,t,i){this.element=null,this.previousActiveElement=null,this.config=e,this.eventEmitter=t,this.currentConsent=i}show(){const e=()=>{this.element||(this.previousActiveElement=document.activeElement,this.element=this.createDOM(),document.body.appendChild(this.element),this.attachListeners()),this.element.classList.add("is-visible"),this.trapFocus(),document.body.style.overflow="hidden"};document.body?e():document.addEventListener("DOMContentLoaded",e)}hide(){var e;null===(e=this.element)||void 0===e||e.classList.remove("is-visible"),document.body.style.overflow="",this.previousActiveElement&&document.contains(this.previousActiveElement)&&(this.previousActiveElement.focus(),this.previousActiveElement=null),setTimeout(()=>{this.destroy()},300)}destroy(){this.element&&(this.element.remove(),this.element=null)}createDOM(){const e=this.config.translations||{},t=this.config.theme||"light",i=this.config.preferencesPosition||"center",s=u(this.config.primaryColor?h(this.config.primaryColor):""),n=e.privacyPolicyUrl?(()=>{const t=l(e.privacyPolicyUrl);return t?`\n <a href="${t}" target="_blank" rel="noopener noreferrer" class="cc-privacy-link">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>\n <polyline points="15 3 21 3 21 9"/>\n <line x1="10" y1="14" x2="21" y2="3"/>\n </svg>\n ${r(e.privacyPolicyLabel||"Privacy Policy")}\n </a>\n `:""})():"",o=`\n <div\n class="cc-modal cc-modal--${r(i)}"\n role="dialog"\n aria-modal="true"\n aria-labelledby="cc-modal-title"\n data-theme="${r(t)}"\n style="${s}"\n >\n <div class="cc-modal__overlay"></div>\n <div class="cc-modal__content">\n <div class="cc-modal__header">\n <h2 id="cc-modal-title">\n ${r(e.preferencesTitle||e.title||"Cookie Preferences")}\n </h2>\n </div>\n\n <div class="cc-modal__body">\n ${this.renderCategories()}\n </div>\n\n <div class="cc-modal__footer">\n <div class="cc-modal__footer-links">\n ${n}\n </div>\n <div class="cc-modal__footer-actions">\n <button\n class="cc-btn cc-btn--secondary"\n data-action="reject"\n >\n ${r(e.essentialsOnly||"Essentials only")}\n </button>\n <button\n class="cc-btn cc-btn--primary"\n data-action="save"\n >\n ${r(e.savePreferences||"Save preferences")}\n </button>\n </div>\n </div>\n </div>\n </div>\n `,c=document.createElement("div");return c.innerHTML=o.trim(),c.firstChild}renderCategories(){return Object.entries(this.config.categories).map(([e,t])=>{const i=!0===this.currentConsent[e],s=t.readOnly;return`\n <div class="cc-category">\n <div class="cc-category__header">\n <label class="cc-toggle ${s?"cc-toggle--disabled":""}">\n <input\n type="checkbox"\n data-category="${r(e)}"\n ${i?"checked":""}\n ${s?"disabled":""}\n aria-label="${r(t.label)} cookies"\n >\n <span class="cc-toggle__slider"></span>\n </label>\n <div class="cc-category__info">\n <h3>${r(t.label)}</h3>\n <p>${r(t.description)}</p>\n </div>\n </div>\n </div>\n `}).join("")}attachListeners(){var e;null===(e=this.element)||void 0===e||e.addEventListener("click",e=>{const t=e.target.closest("[data-action]");if(!t)return;const i=t.getAttribute("data-action");"save"===i?this.handleSave():"reject"===i&&this.handleRejectAll()})}handleSave(){var e;const t=null===(e=this.element)||void 0===e?void 0:e.querySelectorAll("input[data-category]"),i={necessary:!0,analytics:!1,marketing:!1};for(const e of Object.keys(this.config.categories))"necessary"!==e&&(i[e]=!1);null==t||t.forEach(e=>{if(e instanceof HTMLInputElement){const t=e.getAttribute("data-category");t&&(i[t]=e.checked)}}),this.eventEmitter.emit("consent:update",i),this.hide()}handleRejectAll(){const e={necessary:!0,analytics:!1,marketing:!1};for(const t of Object.keys(this.config.categories))"necessary"!==t&&(e[t]=!1);this.eventEmitter.emit("consent:reject",e),this.hide()}trapFocus(){var e,t;const i=null===(e=this.element)||void 0===e?void 0:e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!i||0===i.length)return;const s=i[0],n=i[i.length-1];null==s||s.focus(),null===(t=this.element)||void 0===t||t.addEventListener("keydown",e=>{"Tab"===e.key&&(e.shiftKey&&document.activeElement===s?(e.preventDefault(),n.focus()):e.shiftKey||document.activeElement!==n||(e.preventDefault(),s.focus()))})}}class v{constructor(e,t){this.element=null,this.isVisible=!1,this.config=e,this.eventEmitter=t}show(){const e=()=>{this.element||(this.element=this.createDOM(),document.body.appendChild(this.element),this.attachListeners()),requestAnimationFrame(()=>{var e;null===(e=this.element)||void 0===e||e.classList.add("is-visible"),this.isVisible=!0})};document.body?e():document.addEventListener("DOMContentLoaded",e)}hide(){var e;null===(e=this.element)||void 0===e||e.classList.remove("is-visible"),this.isVisible=!1}destroy(){this.element&&(this.element.remove(),this.element=null),this.isVisible=!1}getIsVisible(){return this.isVisible}createDOM(){const e=this.config.translations||{},t=this.config.theme||"light",i=this.config.widgetPosition||"bottom-right",s=this.config.widgetStyle||"full",n=u(this.config.primaryColor?h(this.config.primaryColor):""),o=`\n <div\n class="cc-widget cc-widget--${r(i)} cc-widget--${r(s)}"\n role="button"\n aria-label="${r(e.cookieSettings||"Cookie settings")}"\n tabindex="0"\n data-theme="${r(t)}"\n style="${n}"\n >\n <svg class="cc-widget__icon" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <defs>\n <path id="cc-ck-a" d="M6,9 C5.448,9 5,8.552 5,8 C5,7.448 5.448,7 6,7 C6.552,7 7,7.448 7,8 C7,8.552 6.552,9 6,9 Z M0.5,5 C0.776,5 1,5.224 1,5.5 C1,5.776 0.776,6 0.5,6 C0.224,6 0,5.776 0,5.5 C0,5.224 0.224,5 0.5,5 Z M1.5,0 C1.776,0 2,0.224 2,0.5 C2,0.776 1.776,1 1.5,1 C1.224,1 1,0.776 1,0.5 C1,0.224 1.224,0 1.5,0 Z"/>\n <path id="cc-ck-c" d="M16.899,14.984 C14.727,14.802 12.991,13.088 12.773,10.927 C10.117,10.808 8,8.617 8,5.932 C8,4.837 8.352,3.824 8.949,3 C5.027,3.515 2,6.87 2,10.932 C2,15.35 5.582,18.932 10,18.932 C12.939,18.932 15.509,17.346 16.899,14.984 Z M18.623,15.998 C16.839,19.029 13.583,20.932 10,20.932 C4.477,20.932 0,16.454 0,10.932 C0,5.897 3.74,1.666 8.689,1.017 C10.429,0.789 11.599,2.753 10.568,4.174 C10.2,4.682 10,5.289 10,5.932 C10,7.537 11.265,8.857 12.862,8.929 C13.854,8.973 14.663,9.738 14.763,10.726 C14.884,11.932 15.857,12.889 17.067,12.991 C18.535,13.114 19.37,14.729 18.623,15.998 Z M10,18 C8.343,18 7,16.657 7,15 C7,13.343 8.343,12 10,12 C11.657,12 13,13.343 13,15 C13,16.657 11.657,18 10,18 Z M10,16 C10.552,16 11,15.552 11,15 C11,14.448 10.552,14 10,14 C9.448,14 9,14.448 9,15 C9,15.552 9.448,16 10,16 Z M4.5,14 C3.672,14 3,13.328 3,12.5 C3,11.672 3.672,11 4.5,11 C5.328,11 6,11.672 6,12.5 C6,13.328 5.328,14 4.5,14 Z M4.5,12 C4.224,12 4,12.224 4,12.5 C4,12.776 4.224,13 4.5,13 C4.776,13 5,12.776 5,12.5 C5,12.224 4.776,12 4.5,12 Z M5.5,9 C4.672,9 4,8.328 4,7.5 C4,6.672 4.672,6 5.5,6 C6.328,6 7,6.672 7,7.5 C7,8.328 6.328,9 5.5,9 Z M5.5,7 C5.224,7 5,7.224 5,7.5 C5,7.776 5.224,8 5.5,8 C5.776,8 6,7.776 6,7.5 C6,7.224 5.776,7 5.5,7 Z"/>\n </defs>\n <g fill="currentColor" fill-rule="evenodd" transform="translate(3 1)">\n <g transform="translate(4 7)">\n <use href="#cc-ck-a"/>\n </g>\n <use href="#cc-ck-c"/>\n </g>\n </svg>\n <span class="cc-widget__text">\n ${r(e.cookies||"Cookies")}\n </span>\n </div>\n `,c=document.createElement("div");return c.innerHTML=o.trim(),c.firstChild}attachListeners(){var e,t;null===(e=this.element)||void 0===e||e.addEventListener("click",()=>{this.handleClick()}),null===(t=this.element)||void 0===t||t.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick())})}handleClick(){this.eventEmitter.emit("preferences:show")}}class m{constructor(e,t){this.dataLayerManager=e,this.config=t}setDefaultConsent(){var e;const t={ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",analytics_storage:"denied",functionality_storage:"denied",personalization_storage:"denied",security_storage:"granted"},i=null!==(e=this.config.gtmWaitForUpdate)&&void 0!==e?e:500;i>0&&(t.wait_for_update=i),this.dataLayerManager.pushConsent("default",t),this.config.gtmUrlPassthrough&&this.dataLayerManager.pushSet("url_passthrough",!0),this.config.gtmAdsDataRedaction&&this.dataLayerManager.pushSet("ads_data_redaction",!0)}updateConsent(e){const t=this.mapCategoriesToGTM(e);this.dataLayerManager.pushConsent("update",t)}mapCategoriesToGTM(e){const t=!("preferences"in this.config.categories)||!0===e.preferences;return{ad_storage:e.marketing?"granted":"denied",ad_user_data:e.marketing?"granted":"denied",ad_personalization:e.marketing?"granted":"denied",analytics_storage:e.analytics?"granted":"denied",functionality_storage:t?"granted":"denied",personalization_storage:t?"granted":"denied",security_storage:"granted"}}}class g{ensureGtag(){window.dataLayer=window.dataLayer||[],"function"!=typeof window.gtag&&(window.gtag=function(){window.dataLayer.push(arguments)})}pushConsent(e,t){this.ensureGtag(),window.gtag("consent",e,t)}pushSet(e,t){this.ensureGtag(),window.gtag("set",e,t)}}const y={analytics:[/^_ga/,/^_gid/,/^_gat/,/^_gcl/,/^_hj/,/^_pk_/,/^mp_/,/^ajs_/,/^amplitude/,/^plausible/],marketing:[/^_fbp/,/^_fbc/,/^fr$/,/^_pin_/,/^_tt_/,/^li_/,/^_uet/,/^IDE$/,/^test_cookie/,/^MUID$/,/^NID$/],preferences:[/^lang$/,/^locale$/,/^i18n/]};function b(e){const t=window.location.hostname,i=["/",window.location.pathname],s=["",t],n=t.split(".");n.length>2&&s.push("."+n.slice(-2).join(".")),s.push("."+t);for(const t of s)for(const s of i){const i=t?"; domain="+t:"";document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${s}${i}`,document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${s}${i}; secure`,document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${s}${i}; samesite=lax`,document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${s}${i}; samesite=none; secure`}}function k(e){const t=y[e];if(!t)return;const i=document.cookie.split(";").map(e=>e.trim().split("=")[0]).filter(Boolean);for(const e of i)t.some(t=>t.test(e))&&b(e)}function C(e){for(const[t,i]of Object.entries(e))i||"necessary"===t||k(t)}const w={en:{title:"We use cookies",description:"We use cookies to improve your experience on our site. You can choose which cookies you accept.",acceptAll:"Accept all",rejectAll:"Essentials only",customize:"Customize",savePreferences:"Save preferences",essentialsOnly:"Essentials only",preferencesTitle:"Cookie Preferences",cookieSettings:"Cookie settings",cookies:"Cookies",privacyPolicyLabel:"Privacy Policy"},fr:{title:"Nous utilisons des cookies",description:"Ce site utilise des cookies pour améliorer votre expérience de navigation. Vous pouvez choisir les cookies que vous acceptez.",acceptAll:"Tout accepter",rejectAll:"Essentiels uniquement",customize:"Personnaliser",savePreferences:"Enregistrer",essentialsOnly:"Essentiels uniquement",preferencesTitle:"Préférences des cookies",cookieSettings:"Paramètres des cookies",cookies:"Cookies",privacyPolicyLabel:"Politique de confidentialité"},de:{title:"Wir verwenden Cookies",description:"Diese Website verwendet Cookies, um Ihr Erlebnis zu verbessern. Sie können wählen, welche Cookies Sie akzeptieren.",acceptAll:"Alle akzeptieren",rejectAll:"Nur essenzielle",customize:"Anpassen",savePreferences:"Speichern",essentialsOnly:"Nur essenzielle",preferencesTitle:"Cookie-Einstellungen",cookieSettings:"Cookie-Einstellungen",cookies:"Cookies",privacyPolicyLabel:"Datenschutzrichtlinie"},es:{title:"Usamos cookies",description:"Este sitio utiliza cookies para mejorar su experiencia. Puede elegir qué cookies acepta.",acceptAll:"Aceptar todo",rejectAll:"Solo esenciales",customize:"Personalizar",savePreferences:"Guardar",essentialsOnly:"Solo esenciales",preferencesTitle:"Preferencias de cookies",cookieSettings:"Configuración de cookies",cookies:"Cookies",privacyPolicyLabel:"Política de privacidad"},it:{title:"Utilizziamo i cookie",description:"Questo sito utilizza i cookie per migliorare la tua esperienza. Puoi scegliere quali cookie accettare.",acceptAll:"Accetta tutti",rejectAll:"Solo essenziali",customize:"Personalizza",savePreferences:"Salva",essentialsOnly:"Solo essenziali",preferencesTitle:"Preferenze cookie",cookieSettings:"Impostazioni cookie",cookies:"Cookie",privacyPolicyLabel:"Informativa sulla privacy"},nl:{title:"Wij gebruiken cookies",description:"Deze site maakt gebruik van cookies om uw ervaring te verbeteren. U kunt kiezen welke cookies u accepteert.",acceptAll:"Alles accepteren",rejectAll:"Alleen essentieel",customize:"Aanpassen",savePreferences:"Opslaan",essentialsOnly:"Alleen essentieel",preferencesTitle:"Cookie-voorkeuren",cookieSettings:"Cookie-instellingen",cookies:"Cookies",privacyPolicyLabel:"Privacybeleid"},pt:{title:"Utilizamos cookies",description:"Este site utiliza cookies para melhorar a sua experiência. Pode escolher quais cookies aceita.",acceptAll:"Aceitar todos",rejectAll:"Apenas essenciais",customize:"Personalizar",savePreferences:"Guardar",essentialsOnly:"Apenas essenciais",preferencesTitle:"Preferências de cookies",cookieSettings:"Definições de cookies",cookies:"Cookies",privacyPolicyLabel:"Política de privacidade"}};e.CookieConsent=class{constructor(e){if(this.banner=null,this.preferenceCenter=null,this.floatingWidget=null,this.gtmIntegration=null,this.hideTimeout=null,"undefined"==typeof window)return this.config=e,this.consentManager=null,this.storageManager=null,this.eventEmitter=null,void(this.scriptBlocker=null);this.config=this.validateConfig(e),this.consentManager=new i(this.config),this.storageManager=new t,this.eventEmitter=new s,this.scriptBlocker=new n(new o,this.eventEmitter),this.config.gtmConsentMode&&(this.gtmIntegration=new m(new g,this.config)),this.eventEmitter.on("consent:accept",e=>{var t,i;this.updateConsent(e),null===(i=(t=this.config).onAccept)||void 0===i||i.call(t,e)}),this.eventEmitter.on("consent:reject",e=>{var t,i;this.updateConsent(e),null===(i=(t=this.config).onReject)||void 0===i||i.call(t)}),this.eventEmitter.on("consent:update",e=>{var t,i;this.updateConsent(e),null===(i=(t=this.config).onChange)||void 0===i||i.call(t,e)}),this.eventEmitter.on("preferences:show",()=>{this.showPreferences()})}init(){if("undefined"==typeof window)return;this.scriptBlocker.init(),this.gtmIntegration&&this.gtmIntegration.setDefaultConsent();const e=this.storageManager.load();e&&!this.storageManager.isExpired(e)?this.consentManager.needsUpdate(e)?this.config.autoShow&&this.showBanner():(this.applyConsent(e.categories),this.gtmIntegration&&this.gtmIntegration.updateConsent(e.categories),this.eventEmitter.emit("consent:load",e),this.config.showWidget&&this.showFloatingWidget()):this.config.autoShow&&this.showBanner(),window.cookieConsent=this,this.eventEmitter.emit("consent:init")}show(){this.showBanner()}hide(){var e;null===(e=this.banner)||void 0===e||e.hide()}showPreferences(){var e;const t=(null===(e=this.storageManager.load())||void 0===e?void 0:e.categories)||{necessary:!0,analytics:!0,marketing:!0};for(const e of Object.keys(this.config.categories))e in t||(t[e]="necessary"===e);this.preferenceCenter&&this.preferenceCenter.destroy(),this.preferenceCenter=new f(this.config,this.eventEmitter,t),this.preferenceCenter.show()}updateConsent(e){const t=this.consentManager.updateConsent(e);this.storageManager.save(t),this.applyConsent(e),this.gtmIntegration&&this.gtmIntegration.updateConsent(e),this.config.showWidget&&setTimeout(()=>{this.showFloatingWidget()},400)}getConsent(){return this.storageManager.load()}reset(){var e,t;this.storageManager.clear(),this.scriptBlocker.block();const i={necessary:!0,analytics:!1,marketing:!1};for(const e of Object.keys(this.config.categories))"necessary"!==e&&(i[e]=!1);C(i),this.gtmIntegration&&this.gtmIntegration.updateConsent(i),null===(t=(e=this.config).onReject)||void 0===t||t.call(e),this.showBanner()}on(e,t){this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}destroy(){var e,t,i,s;this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),null===(e=this.banner)||void 0===e||e.destroy(),this.banner=null,null===(t=this.preferenceCenter)||void 0===t||t.destroy(),this.preferenceCenter=null,null===(i=this.floatingWidget)||void 0===i||i.destroy(),this.floatingWidget=null,null===(s=this.scriptBlocker)||void 0===s||s.destroy(),this.eventEmitter.clear(),window.cookieConsent===this&&(window.cookieConsent=void 0)}showBanner(){this.banner||(this.banner=new p(this.config,this.eventEmitter)),this.banner.show(),this.eventEmitter.emit("consent:show")}showFloatingWidget(){this.floatingWidget||(this.floatingWidget=new v(this.config,this.eventEmitter)),this.floatingWidget.show()}applyConsent(e){this.scriptBlocker.unblock(e),C(e)}validateConfig(e){var t;const i=(null===(t=e.language)||void 0===t?void 0:t.toLowerCase().split("-")[0])||"en",s=Object.assign(Object.assign({},w[i]||w.en),e.translations);return Object.assign(Object.assign({},e),{translations:s,categories:e.categories||{necessary:{enabled:!0,readOnly:!0,label:"Essential",description:"Required for the website to function properly."},analytics:{enabled:!0,readOnly:!1,label:"Analytics",description:"Help us understand how you use our site."},marketing:{enabled:!0,readOnly:!1,label:"Marketing",description:"Used to deliver relevant advertisements."}},mode:e.mode||"opt-in",autoShow:void 0===e.autoShow||e.autoShow,revision:e.revision||1,gtmConsentMode:e.gtmConsentMode||!1,disablePageInteraction:e.disablePageInteraction||!1,theme:e.theme||"light",position:e.position||"bottom-left",layout:e.layout||"box",backdropBlur:!1!==e.backdropBlur,animationStyle:e.animationStyle||"smooth",preferencesPosition:e.preferencesPosition||"center",showWidget:void 0===e.showWidget||e.showWidget,widgetPosition:e.widgetPosition||"bottom-left",widgetStyle:e.widgetStyle||"compact"})}}});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CookieCraft={})}(this,function(e){"use strict";class t{save(e){try{localStorage.setItem(t.STORAGE_KEY,JSON.stringify(e))}catch(e){}}load(){try{const e=localStorage.getItem(t.STORAGE_KEY);if(!e)return null;const i=JSON.parse(e);if(!this.validateSchema(i)){const e=this.migrate(i);return e?(this.save(e),e):null}return i}catch(e){return null}}clear(){try{localStorage.removeItem(t.STORAGE_KEY)}catch(e){}}isExpired(e){const t=new Date(e.expiresAt);return!!isNaN(t.getTime())||t<new Date}validateSchema(e){return e&&"number"==typeof e.version&&"string"==typeof e.timestamp&&"object"==typeof e.categories&&"string"==typeof e.expiresAt}migrate(e){if(!e||"object"!=typeof e)return null;const i=e;if(i.categories&&"object"==typeof i.categories){const e=new Date,s=new Date(e);s.setMonth(s.getMonth()+t.EXPIRY_MONTHS);const n=i.categories,o={necessary:!0===n.necessary,analytics:!0===n.analytics,marketing:!0===n.marketing};return"preferences"in n&&(o.preferences=!0===n.preferences),{version:"number"==typeof i.version?i.version:1,timestamp:"string"==typeof i.timestamp?i.timestamp:e.toISOString(),categories:o,expiresAt:"string"==typeof i.expiresAt?i.expiresAt:s.toISOString()}}return null}}t.STORAGE_KEY="cookiecraft_consent",t.EXPIRY_MONTHS=13;class i{constructor(e){this.consent=null,this.config=e}validateConsent(e){if(!e.necessary)return!1;if(this.config.categories&&Object.keys(this.config.categories).length>0)for(const t of Object.keys(e))if(!(t in this.config.categories))return!1;for(const t of Object.keys(e))e[t]=!0===e[t];return!0}updateConsent(e){if(!this.validateConsent(e))throw Error("Invalid consent categories");return this.consent=this.createConsentRecord(e),this.consent}needsConsent(){return null===this.consent}needsUpdate(e){return e.version<this.config.revision}getCurrentConsent(){return this.consent}createConsentRecord(e){const i=new Date,s=new Date(i);return s.setMonth(s.getMonth()+t.EXPIRY_MONTHS),{version:this.config.revision,timestamp:i.toISOString(),categories:Object.assign({},e),expiresAt:s.toISOString()}}}class s{constructor(){this.events=new Map}on(e,t){this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(t)}off(e,t){this.events.has(e)&&this.events.get(e).delete(t)}emit(e,t){this.events.has(e)&&this.events.get(e).forEach(e=>{try{e(t)}catch(e){}})}clear(){this.events.clear()}clearEvent(e){this.events.delete(e)}}class n{constructor(e,t){this.observer=null,this.blockedScripts=new Map,this.currentConsent=null,this.categoryManager=e,this.eventEmitter=t}init(){this.blockExistingScripts(),this.observeDOM()}block(){this.currentConsent=null,this.blockedScripts.clear(),this.blockExistingScripts()}unblock(e){this.currentConsent=e;const t=[];this.blockedScripts.forEach((i,s)=>{const n=this.categoryManager.getCategoryForScript(i);n&&this.categoryManager.isAllowed(n,e)&&(this.reactivateScript(i),t.push(s))}),t.forEach(e=>this.blockedScripts.delete(e))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null)}blockExistingScripts(){document.querySelectorAll("script[data-cookieconsent]").forEach(e=>{e instanceof HTMLScriptElement&&this.processScript(e)})}observeDOM(){this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e instanceof HTMLScriptElement&&e.hasAttribute("data-cookieconsent")&&this.processScript(e)})})}),this.observer.observe(document.documentElement,{childList:!0,subtree:!0})}processScript(e){const t=this.categoryManager.getCategoryForScript(e);if(t&&!(this.currentConsent&&this.categoryManager.isAllowed(t,this.currentConsent)||"text/plain"===e.type)){const t=this.generateScriptId(e);if(this.blockedScripts.has(t))return;e.setAttribute("data-original-type",e.type||"text/javascript"),e.type="text/plain",this.blockedScripts.set(t,e)}}reactivateScript(e){const t=document.createElement("script");Array.from(e.attributes).forEach(e=>{"type"!==e.name&&"data-original-type"!==e.name&&t.setAttribute(e.name,e.value)});const i=e.getAttribute("data-original-type")||"text/javascript";t.type=i,e.src?t.src=e.src:t.textContent=e.textContent,e.parentNode&&(e.parentNode.insertBefore(t,e),e.parentNode.removeChild(e)),this.eventEmitter.emit("script:activated",{category:e.getAttribute("data-cookieconsent"),src:e.src||"inline"})}generateScriptId(e){if(e.src)return"src:"+e.src;const t=e.textContent||"",i=e.getAttribute("data-cookieconsent")||"",s=e.getAttribute("data-cc-id");if(s)return s;const n=`inline:${i}:${this.simpleHash(t)}`;return e.setAttribute("data-cc-id",n),n}simpleHash(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return t.toString(36)}}class o{constructor(){this.categories=new Map,this.initializeDefaultPatterns()}registerCategory(e,t){this.categories.set(e,t)}getCategoryForScript(e){const t=e.getAttribute("data-cookieconsent");if(t)return t;const i=e.src;if(!i)return null;for(const[e,t]of this.categories)if(t.some(e=>i.includes(e)))return e;return null}isAllowed(e,t){return!0===t[e]}initializeDefaultPatterns(){this.categories.set("analytics",["google-analytics.com","analytics.google.com","plausible.io","matomo.org","hotjar.com","mixpanel.com","segment.com","amplitude.com"]),this.categories.set("marketing",["googletagmanager.com","facebook.net","facebook.com/tr","connect.facebook.net","doubleclick.net","ads.google.com","linkedin.com/analytics","twitter.com/i/adsct","pinterest.com/ct","adroll.com","taboola.com","outbrain.com","tiktok.com"]),this.categories.set("necessary",[])}}const c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},a=/[&<>"'`]/g;function r(e){return e.replace(a,e=>c[e]||e)}function l(e){const t=e.trim();return t.startsWith("https://")||t.startsWith("http://")||t.startsWith("/")||t.startsWith("./")?r(t):""}function h(e){const t=e.trim();return/^#[0-9a-fA-F]{3,8}$/.test(t)||/^rgba?\(\s*[\d\s,./%]+\)$/.test(t)||/^hsla?\(\s*[\d\s,./%deg]+\)$/.test(t)||/^[a-zA-Z]+$/.test(t)&&!["inherit","initial","unset","revert","revert-layer"].includes(t.toLowerCase())?t:""}function d(e){const t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t;if(/^#[0-9a-fA-F]{3}$/.test(t)){const e=t[1],i=t[2],s=t[3];return`#${e}${e}${i}${i}${s}${s}`}return/^#[0-9a-fA-F]{8}$/.test(t)?t.substring(0,7):null}function u(e){if(!e)return"";const t=d(e);if(!t)return`--cc-primary: ${e};`;const i=function(e){const t=d(e);if(!t)return e;const i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16),c=e=>Math.max(0,Math.min(255,Math.round(e+-15*e/100))),a=e=>{const t=e.toString(16);return 1===t.length?"0"+t:t};return`#${a(c(s))}${a(c(n))}${a(c(o))}`}(t);return`--cc-primary: ${t}; --cc-primary-hover: ${i};`}class p{constructor(e,t){this.element=null,this.hideTimeout=null,this.previousActiveElement=null,this.config=e,this.eventEmitter=t}show(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null);const e=()=>{this.element||(this.previousActiveElement=document.activeElement,this.element=this.createDOM(),document.body.appendChild(this.element),this.attachListeners()),requestAnimationFrame(()=>{var e;null===(e=this.element)||void 0===e||e.classList.add("is-visible")}),this.config.disablePageInteraction&&(document.body.style.overflow="hidden",this.trapFocus())};document.body?e():document.addEventListener("DOMContentLoaded",e)}hide(){var e;null===(e=this.element)||void 0===e||e.classList.remove("is-visible"),this.config.disablePageInteraction&&(document.body.style.overflow=""),this.hideTimeout=setTimeout(()=>{this.destroy()},300)}destroy(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),this.element&&(this.element.remove(),this.element=null),this.previousActiveElement&&document.contains(this.previousActiveElement)&&(this.previousActiveElement.focus(),this.previousActiveElement=null)}createDOM(){const e=this.config.translations||{},t=this.config.theme||"light",i=this.config.position||"bottom",s=this.config.layout||"bar",n=!1!==this.config.backdropBlur,o=this.config.disablePageInteraction,c=u(this.config.primaryColor?h(this.config.primaryColor):""),a=e.title?`<h2 class="cc-banner__title">${r(e.title)}</h2>`:"",l=this.getDescriptionHTML(),d=l?`<p class="cc-banner__description">${l}</p>`:"",p=`\n <div\n class="cc-banner cc-banner--${r(i)} cc-banner--${r(s)} ${n?"cc-backdrop-blur":""}"\n role="${o?"dialog":"region"}"\n ${o?'aria-modal="true"':""}\n aria-label="Cookie consent"\n aria-live="polite"\n data-theme="${r(t)}"\n style="${c}"\n >\n <div class="cc-banner__container">\n <div class="cc-banner__content">\n ${a}\n ${d}\n </div>\n <div class="cc-banner__actions">\n <button\n class="cc-btn cc-btn--accept"\n data-action="accept"\n aria-label="${r(e.acceptAll||"Accept all")}"\n >\n ${r(e.acceptAll||"Accept all")}\n </button>\n </div>\n </div>\n </div>\n `,f=document.createElement("div");return f.innerHTML=p.trim(),f.firstChild}attachListeners(){var e,t;null===(e=this.element)||void 0===e||e.addEventListener("click",e=>{const t=e.target.closest("[data-action]");if(t)switch(t.getAttribute("data-action")){case"accept":this.handleAcceptAll();break;case"reject":this.handleRejectAll();break;case"customize":this.handleCustomize()}}),null===(t=this.element)||void 0===t||t.addEventListener("keydown",e=>{"Escape"===e.key&&this.config.disablePageInteraction&&this.handleRejectAll()})}handleAcceptAll(){const e={necessary:!0,analytics:!0,marketing:!0};for(const t of Object.keys(this.config.categories))e[t]=!0;this.eventEmitter.emit("consent:accept",e),this.hide()}handleRejectAll(){const e={necessary:!0,analytics:!1,marketing:!1};for(const t of Object.keys(this.config.categories))"necessary"!==t&&(e[t]=!1);this.eventEmitter.emit("consent:reject",e),this.hide()}handleCustomize(){this.eventEmitter.emit("preferences:show"),this.hide()}trapFocus(){var e,t;const i=null===(e=this.element)||void 0===e?void 0:e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!i||0===i.length)return;const s=i[0],n=i[i.length-1];null==s||s.focus(),null===(t=this.element)||void 0===t||t.addEventListener("keydown",e=>{"Tab"===e.key&&(e.shiftKey&&document.activeElement===s?(e.preventDefault(),n.focus()):e.shiftKey||document.activeElement!==n||(e.preventDefault(),s.focus()))})}getDescriptionHTML(){const e=this.config.translations||{};if(!e.description)return"";const t=r(e.description),i=r(e.customize||"Customize");let s=t;if(e.privacyPolicyUrl){const t=l(e.privacyPolicyUrl);t&&(s+=` <a href="${t}" target="_blank" rel="noopener noreferrer">${r(e.privacyPolicyLabel||"Privacy Policy")}</a>`)}return s+=` <span class="cc-banner__customize" data-action="customize">${i}</span>`,s}}class f{constructor(e,t,i){this.element=null,this.previousActiveElement=null,this.config=e,this.eventEmitter=t,this.currentConsent=i}show(){const e=()=>{this.element||(this.previousActiveElement=document.activeElement,this.element=this.createDOM(),document.body.appendChild(this.element),this.attachListeners()),this.element.classList.add("is-visible"),this.trapFocus(),document.body.style.overflow="hidden"};document.body?e():document.addEventListener("DOMContentLoaded",e)}hide(){var e;null===(e=this.element)||void 0===e||e.classList.remove("is-visible"),document.body.style.overflow="",this.previousActiveElement&&document.contains(this.previousActiveElement)&&(this.previousActiveElement.focus(),this.previousActiveElement=null),setTimeout(()=>{this.destroy()},300)}destroy(){this.element&&(this.element.remove(),this.element=null)}createDOM(){const e=this.config.translations||{},t=this.config.theme||"light",i=this.config.preferencesPosition||"center",s=u(this.config.primaryColor?h(this.config.primaryColor):""),n=e.privacyPolicyUrl?(()=>{const t=l(e.privacyPolicyUrl);return t?`\n <a href="${t}" target="_blank" rel="noopener noreferrer" class="cc-privacy-link">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>\n <polyline points="15 3 21 3 21 9"/>\n <line x1="10" y1="14" x2="21" y2="3"/>\n </svg>\n ${r(e.privacyPolicyLabel||"Privacy Policy")}\n </a>\n `:""})():"",o=`\n <div\n class="cc-modal cc-modal--${r(i)}"\n role="dialog"\n aria-modal="true"\n aria-labelledby="cc-modal-title"\n data-theme="${r(t)}"\n style="${s}"\n >\n <div class="cc-modal__overlay"></div>\n <div class="cc-modal__content">\n <div class="cc-modal__header">\n <h2 id="cc-modal-title">\n ${r(e.preferencesTitle||e.title||"Cookie Preferences")}\n </h2>\n </div>\n\n <div class="cc-modal__body">\n ${this.renderCategories()}\n </div>\n\n <div class="cc-modal__footer">\n <div class="cc-modal__footer-links">\n ${n}\n </div>\n <div class="cc-modal__footer-actions">\n <button\n class="cc-btn cc-btn--secondary"\n data-action="reject"\n >\n ${r(e.essentialsOnly||"Essentials only")}\n </button>\n <button\n class="cc-btn cc-btn--primary"\n data-action="save"\n >\n ${r(e.savePreferences||"Save preferences")}\n </button>\n </div>\n </div>\n </div>\n </div>\n `,c=document.createElement("div");return c.innerHTML=o.trim(),c.firstChild}renderCategories(){return Object.entries(this.config.categories).map(([e,t])=>{const i=!0===this.currentConsent[e],s=t.readOnly;return`\n <div class="cc-category">\n <div class="cc-category__header">\n <label class="cc-toggle ${s?"cc-toggle--disabled":""}">\n <input\n type="checkbox"\n data-category="${r(e)}"\n ${i?"checked":""}\n ${s?"disabled":""}\n aria-label="${r(t.label)} cookies"\n >\n <span class="cc-toggle__slider"></span>\n </label>\n <div class="cc-category__info">\n <h3>${r(t.label)}</h3>\n <p>${r(t.description)}</p>\n </div>\n </div>\n </div>\n `}).join("")}attachListeners(){var e;null===(e=this.element)||void 0===e||e.addEventListener("click",e=>{const t=e.target.closest("[data-action]");if(!t)return;const i=t.getAttribute("data-action");"save"===i?this.handleSave():"reject"===i&&this.handleRejectAll()})}handleSave(){var e;const t=null===(e=this.element)||void 0===e?void 0:e.querySelectorAll("input[data-category]"),i={necessary:!0,analytics:!1,marketing:!1};for(const e of Object.keys(this.config.categories))"necessary"!==e&&(i[e]=!1);null==t||t.forEach(e=>{if(e instanceof HTMLInputElement){const t=e.getAttribute("data-category");t&&(i[t]=e.checked)}}),this.eventEmitter.emit("consent:update",i),this.hide()}handleRejectAll(){const e={necessary:!0,analytics:!1,marketing:!1};for(const t of Object.keys(this.config.categories))"necessary"!==t&&(e[t]=!1);this.eventEmitter.emit("consent:reject",e),this.hide()}trapFocus(){var e,t;const i=null===(e=this.element)||void 0===e?void 0:e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!i||0===i.length)return;const s=i[0],n=i[i.length-1];null==s||s.focus(),null===(t=this.element)||void 0===t||t.addEventListener("keydown",e=>{"Tab"===e.key&&(e.shiftKey&&document.activeElement===s?(e.preventDefault(),n.focus()):e.shiftKey||document.activeElement!==n||(e.preventDefault(),s.focus()))})}}class v{constructor(e,t){this.element=null,this.isVisible=!1,this.config=e,this.eventEmitter=t}show(){const e=()=>{this.element||(this.element=this.createDOM(),document.body.appendChild(this.element),this.attachListeners()),requestAnimationFrame(()=>{var e;null===(e=this.element)||void 0===e||e.classList.add("is-visible"),this.isVisible=!0})};document.body?e():document.addEventListener("DOMContentLoaded",e)}hide(){var e;null===(e=this.element)||void 0===e||e.classList.remove("is-visible"),this.isVisible=!1}destroy(){this.element&&(this.element.remove(),this.element=null),this.isVisible=!1}getIsVisible(){return this.isVisible}createDOM(){const e=this.config.translations||{},t=this.config.theme||"light",i=this.config.widgetPosition||"bottom-right",s=this.config.widgetStyle||"full",n=u(this.config.primaryColor?h(this.config.primaryColor):""),o=`\n <div\n class="cc-widget cc-widget--${r(i)} cc-widget--${r(s)}"\n role="button"\n aria-label="${r(e.cookieSettings||"Cookie settings")}"\n tabindex="0"\n data-theme="${r(t)}"\n style="${n}"\n >\n <svg class="cc-widget__icon" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">\n <defs>\n <path id="cc-ck-a" d="M6,9 C5.448,9 5,8.552 5,8 C5,7.448 5.448,7 6,7 C6.552,7 7,7.448 7,8 C7,8.552 6.552,9 6,9 Z M0.5,5 C0.776,5 1,5.224 1,5.5 C1,5.776 0.776,6 0.5,6 C0.224,6 0,5.776 0,5.5 C0,5.224 0.224,5 0.5,5 Z M1.5,0 C1.776,0 2,0.224 2,0.5 C2,0.776 1.776,1 1.5,1 C1.224,1 1,0.776 1,0.5 C1,0.224 1.224,0 1.5,0 Z"/>\n <path id="cc-ck-c" d="M16.899,14.984 C14.727,14.802 12.991,13.088 12.773,10.927 C10.117,10.808 8,8.617 8,5.932 C8,4.837 8.352,3.824 8.949,3 C5.027,3.515 2,6.87 2,10.932 C2,15.35 5.582,18.932 10,18.932 C12.939,18.932 15.509,17.346 16.899,14.984 Z M18.623,15.998 C16.839,19.029 13.583,20.932 10,20.932 C4.477,20.932 0,16.454 0,10.932 C0,5.897 3.74,1.666 8.689,1.017 C10.429,0.789 11.599,2.753 10.568,4.174 C10.2,4.682 10,5.289 10,5.932 C10,7.537 11.265,8.857 12.862,8.929 C13.854,8.973 14.663,9.738 14.763,10.726 C14.884,11.932 15.857,12.889 17.067,12.991 C18.535,13.114 19.37,14.729 18.623,15.998 Z M10,18 C8.343,18 7,16.657 7,15 C7,13.343 8.343,12 10,12 C11.657,12 13,13.343 13,15 C13,16.657 11.657,18 10,18 Z M10,16 C10.552,16 11,15.552 11,15 C11,14.448 10.552,14 10,14 C9.448,14 9,14.448 9,15 C9,15.552 9.448,16 10,16 Z M4.5,14 C3.672,14 3,13.328 3,12.5 C3,11.672 3.672,11 4.5,11 C5.328,11 6,11.672 6,12.5 C6,13.328 5.328,14 4.5,14 Z M4.5,12 C4.224,12 4,12.224 4,12.5 C4,12.776 4.224,13 4.5,13 C4.776,13 5,12.776 5,12.5 C5,12.224 4.776,12 4.5,12 Z M5.5,9 C4.672,9 4,8.328 4,7.5 C4,6.672 4.672,6 5.5,6 C6.328,6 7,6.672 7,7.5 C7,8.328 6.328,9 5.5,9 Z M5.5,7 C5.224,7 5,7.224 5,7.5 C5,7.776 5.224,8 5.5,8 C5.776,8 6,7.776 6,7.5 C6,7.224 5.776,7 5.5,7 Z"/>\n </defs>\n <g fill="currentColor" fill-rule="evenodd" transform="translate(3 1)">\n <g transform="translate(4 7)">\n <use href="#cc-ck-a"/>\n </g>\n <use href="#cc-ck-c"/>\n </g>\n </svg>\n <span class="cc-widget__text">\n ${r(e.cookies||"Cookies")}\n </span>\n </div>\n `,c=document.createElement("div");return c.innerHTML=o.trim(),c.firstChild}attachListeners(){var e,t;null===(e=this.element)||void 0===e||e.addEventListener("click",()=>{this.handleClick()}),null===(t=this.element)||void 0===t||t.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleClick())})}handleClick(){this.eventEmitter.emit("preferences:show")}}class m{constructor(e,t){this.dataLayerManager=e,this.config=t}setDefaultConsent(){var e;const t={ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",analytics_storage:"denied",functionality_storage:"denied",personalization_storage:"denied",security_storage:"granted"},i=null!==(e=this.config.gtmWaitForUpdate)&&void 0!==e?e:500;i>0&&(t.wait_for_update=i),this.dataLayerManager.pushConsent("default",t),this.config.gtmUrlPassthrough&&this.dataLayerManager.pushSet("url_passthrough",!0),this.config.gtmAdsDataRedaction&&this.dataLayerManager.pushSet("ads_data_redaction",!0)}updateConsent(e){const t=this.mapCategoriesToGTM(e);this.dataLayerManager.pushConsent("update",t)}mapCategoriesToGTM(e){const t=!("preferences"in this.config.categories)||!0===e.preferences;return{ad_storage:e.marketing?"granted":"denied",ad_user_data:e.marketing?"granted":"denied",ad_personalization:e.marketing?"granted":"denied",analytics_storage:e.analytics?"granted":"denied",functionality_storage:t?"granted":"denied",personalization_storage:t?"granted":"denied",security_storage:"granted"}}}class g{ensureGtag(){window.dataLayer=window.dataLayer||[],"function"!=typeof window.gtag&&(window.gtag=function(){window.dataLayer.push(arguments)})}pushConsent(e,t){this.ensureGtag(),window.gtag("consent",e,t)}pushSet(e,t){this.ensureGtag(),window.gtag("set",e,t)}}const y={analytics:[/^_ga/,/^_gid/,/^_gat/,/^_gcl/,/^_hj/,/^_pk_/,/^mp_/,/^ajs_/,/^amplitude/,/^plausible/],marketing:[/^_fbp/,/^_fbc/,/^fr$/,/^_pin_/,/^_tt_/,/^li_/,/^_uet/,/^IDE$/,/^test_cookie/,/^MUID$/,/^NID$/],preferences:[/^lang$/,/^locale$/,/^i18n/]};function b(e){const t=window.location.hostname,i=["/",window.location.pathname],s=["",t],n=t.split(".");n.length>2&&s.push("."+n.slice(-2).join(".")),s.push("."+t);for(const t of s)for(const s of i){const i=t?"; domain="+t:"";document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${s}${i}`,document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${s}${i}; secure`,document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${s}${i}; samesite=lax`,document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${s}${i}; samesite=none; secure`}}function k(e){const t=y[e];if(!t)return;const i=document.cookie.split(";").map(e=>e.trim().split("=")[0]).filter(Boolean);for(const e of i)t.some(t=>t.test(e))&&b(e)}function C(e){for(const[t,i]of Object.entries(e))i||"necessary"===t||k(t)}const w={en:{title:"We use cookies",description:"We use cookies to improve your experience on our site. You can choose which cookies you accept.",acceptAll:"Accept all",rejectAll:"Essentials only",customize:"Manage preferences",savePreferences:"Save preferences",essentialsOnly:"Essentials only",preferencesTitle:"Cookie Preferences",cookieSettings:"Cookie settings",cookies:"Cookies",privacyPolicyLabel:"Privacy Policy"},fr:{title:"Nous utilisons des cookies",description:"Ce site utilise des cookies pour améliorer votre expérience de navigation. Vous pouvez choisir les cookies que vous acceptez.",acceptAll:"Tout accepter",rejectAll:"Essentiels uniquement",customize:"Gérer mes préférences",savePreferences:"Enregistrer",essentialsOnly:"Essentiels uniquement",preferencesTitle:"Préférences des cookies",cookieSettings:"Paramètres des cookies",cookies:"Cookies",privacyPolicyLabel:"Politique de confidentialité"},de:{title:"Wir verwenden Cookies",description:"Diese Website verwendet Cookies, um Ihr Erlebnis zu verbessern. Sie können wählen, welche Cookies Sie akzeptieren.",acceptAll:"Alle akzeptieren",rejectAll:"Nur essenzielle",customize:"Einstellungen verwalten",savePreferences:"Speichern",essentialsOnly:"Nur essenzielle",preferencesTitle:"Cookie-Einstellungen",cookieSettings:"Cookie-Einstellungen",cookies:"Cookies",privacyPolicyLabel:"Datenschutzrichtlinie"},es:{title:"Usamos cookies",description:"Este sitio utiliza cookies para mejorar su experiencia. Puede elegir qué cookies acepta.",acceptAll:"Aceptar todo",rejectAll:"Solo esenciales",customize:"Gestionar preferencias",savePreferences:"Guardar",essentialsOnly:"Solo esenciales",preferencesTitle:"Preferencias de cookies",cookieSettings:"Configuración de cookies",cookies:"Cookies",privacyPolicyLabel:"Política de privacidad"},it:{title:"Utilizziamo i cookie",description:"Questo sito utilizza i cookie per migliorare la tua esperienza. Puoi scegliere quali cookie accettare.",acceptAll:"Accetta tutti",rejectAll:"Solo essenziali",customize:"Gestisci preferenze",savePreferences:"Salva",essentialsOnly:"Solo essenziali",preferencesTitle:"Preferenze cookie",cookieSettings:"Impostazioni cookie",cookies:"Cookie",privacyPolicyLabel:"Informativa sulla privacy"},nl:{title:"Wij gebruiken cookies",description:"Deze site maakt gebruik van cookies om uw ervaring te verbeteren. U kunt kiezen welke cookies u accepteert.",acceptAll:"Alles accepteren",rejectAll:"Alleen essentieel",customize:"Voorkeuren beheren",savePreferences:"Opslaan",essentialsOnly:"Alleen essentieel",preferencesTitle:"Cookie-voorkeuren",cookieSettings:"Cookie-instellingen",cookies:"Cookies",privacyPolicyLabel:"Privacybeleid"},pt:{title:"Utilizamos cookies",description:"Este site utiliza cookies para melhorar a sua experiência. Pode escolher quais cookies aceita.",acceptAll:"Aceitar todos",rejectAll:"Apenas essenciais",customize:"Gerir preferências",savePreferences:"Guardar",essentialsOnly:"Apenas essenciais",preferencesTitle:"Preferências de cookies",cookieSettings:"Definições de cookies",cookies:"Cookies",privacyPolicyLabel:"Política de privacidade"}};e.CookieConsent=class{constructor(e){if(this.banner=null,this.preferenceCenter=null,this.floatingWidget=null,this.gtmIntegration=null,this.hideTimeout=null,"undefined"==typeof window)return this.config=e,this.consentManager=null,this.storageManager=null,this.eventEmitter=null,void(this.scriptBlocker=null);this.config=this.validateConfig(e),this.consentManager=new i(this.config),this.storageManager=new t,this.eventEmitter=new s,this.scriptBlocker=new n(new o,this.eventEmitter),this.config.gtmConsentMode&&(this.gtmIntegration=new m(new g,this.config)),this.eventEmitter.on("consent:accept",e=>{var t,i;this.updateConsent(e),null===(i=(t=this.config).onAccept)||void 0===i||i.call(t,e)}),this.eventEmitter.on("consent:reject",e=>{var t,i;this.updateConsent(e),null===(i=(t=this.config).onReject)||void 0===i||i.call(t)}),this.eventEmitter.on("consent:update",e=>{var t,i;this.updateConsent(e),null===(i=(t=this.config).onChange)||void 0===i||i.call(t,e)}),this.eventEmitter.on("preferences:show",()=>{this.showPreferences()})}init(){if("undefined"==typeof window)return;this.scriptBlocker.init(),this.gtmIntegration&&this.gtmIntegration.setDefaultConsent();const e=this.storageManager.load();e&&!this.storageManager.isExpired(e)?this.consentManager.needsUpdate(e)?this.config.autoShow&&this.showBanner():(this.applyConsent(e.categories),this.gtmIntegration&&this.gtmIntegration.updateConsent(e.categories),this.eventEmitter.emit("consent:load",e),this.config.showWidget&&this.showFloatingWidget()):this.config.autoShow&&this.showBanner(),window.cookieConsent=this,this.eventEmitter.emit("consent:init")}show(){this.showBanner()}hide(){var e;null===(e=this.banner)||void 0===e||e.hide()}showPreferences(){var e;const t=(null===(e=this.storageManager.load())||void 0===e?void 0:e.categories)||{necessary:!0,analytics:!0,marketing:!0};for(const e of Object.keys(this.config.categories))e in t||(t[e]="necessary"===e);this.preferenceCenter&&this.preferenceCenter.destroy(),this.preferenceCenter=new f(this.config,this.eventEmitter,t),this.preferenceCenter.show()}updateConsent(e){const t=this.consentManager.updateConsent(e);this.storageManager.save(t),this.applyConsent(e),this.gtmIntegration&&this.gtmIntegration.updateConsent(e),this.config.showWidget&&setTimeout(()=>{this.showFloatingWidget()},400)}getConsent(){return this.storageManager.load()}reset(){var e,t;this.storageManager.clear(),this.scriptBlocker.block();const i={necessary:!0,analytics:!1,marketing:!1};for(const e of Object.keys(this.config.categories))"necessary"!==e&&(i[e]=!1);C(i),this.gtmIntegration&&this.gtmIntegration.updateConsent(i),null===(t=(e=this.config).onReject)||void 0===t||t.call(e),this.showBanner()}on(e,t){this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}destroy(){var e,t,i,s;this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),null===(e=this.banner)||void 0===e||e.destroy(),this.banner=null,null===(t=this.preferenceCenter)||void 0===t||t.destroy(),this.preferenceCenter=null,null===(i=this.floatingWidget)||void 0===i||i.destroy(),this.floatingWidget=null,null===(s=this.scriptBlocker)||void 0===s||s.destroy(),this.eventEmitter.clear(),window.cookieConsent===this&&(window.cookieConsent=void 0)}showBanner(){this.banner||(this.banner=new p(this.config,this.eventEmitter)),this.banner.show(),this.eventEmitter.emit("consent:show")}showFloatingWidget(){this.floatingWidget||(this.floatingWidget=new v(this.config,this.eventEmitter)),this.floatingWidget.show()}applyConsent(e){this.scriptBlocker.unblock(e),C(e)}validateConfig(e){var t;const i=(null===(t=e.language)||void 0===t?void 0:t.toLowerCase().split("-")[0])||"en",s=Object.assign(Object.assign({},w[i]||w.en),e.translations);return Object.assign(Object.assign({},e),{translations:s,categories:e.categories||{necessary:{enabled:!0,readOnly:!0,label:"Essential",description:"Required for the website to function properly."},analytics:{enabled:!0,readOnly:!1,label:"Analytics",description:"Help us understand how you use our site."},marketing:{enabled:!0,readOnly:!1,label:"Marketing",description:"Used to deliver relevant advertisements."}},mode:e.mode||"opt-in",autoShow:void 0===e.autoShow||e.autoShow,revision:e.revision||1,gtmConsentMode:e.gtmConsentMode||!1,disablePageInteraction:e.disablePageInteraction||!1,theme:e.theme||"light",position:e.position||"bottom-left",layout:e.layout||"box",backdropBlur:!1!==e.backdropBlur,animationStyle:e.animationStyle||"smooth",preferencesPosition:e.preferencesPosition||"center",showWidget:void 0===e.showWidget||e.showWidget,widgetPosition:e.widgetPosition||"bottom-left",widgetStyle:e.widgetStyle||"compact"})}}});
2
2
  //# sourceMappingURL=cookiecraft.min.js.map