(function(l,c){typeof exports=="object"&&typeof module<"u"?module.exports=c():typeof define=="function"&&define.amd?define(c):(l=typeof globalThis<"u"?globalThis:l||self,l.AwxCookieBanner=c())})(this,function(){"use strict";class l{constructor(e){const o={language:"en",cssUrl:"./awx-cookie-banner.css",consentCookieKey:"awx-banner-consent",expiredConsentCookie:"next_year",showAgainWhenCustomAllow:1,events:{onAllow:()=>{}},ui:{color:"#660099",textColor:"#000000",overlayBgColor:"rgba(0, 0, 0, 0.5)",contentBgColor:"#fff",logoUrl:"https://placehold.co/100x60",font:{family:"sans-serif",size:"15px"}},i18n:{en:{consent:"Consent",consentDetail:"Detail",detail:"Details",detailContent:{necessary:"Necessary",necessaryContent:"Necessary content",features:"Features",featureContent:"Feature content",analytics:"Analytics",analyticsContent:"Analytics content",marketing:"Marketing",marketingContent:"Marketing content",unclassified:"Unclassified",unclassifiedContent:"Unclassified content"},about:"About",aboutContent:"About content",customize:"Customize",allowSelection:"Allow selection",allowAll:"Allow all"},no:{consent:"Consent",consentDetail:"Detail",detail:"Details",detailContent:{necessary:"Necessary",necessaryContent:"Necessary content",features:"Features",featureContent:"Feature content",analytics:"Analytics",analyticsContent:"Analytics content",marketing:"Marketing",marketingContent:"Marketing content",unclassified:"Unclassified",unclassifiedContent:"Unclassified content"},about:"About",aboutContent:"About content",customize:"Customize",allowSelection:"Allow selection",allowAll:"Allow all"}},section:{necessary:!0,features:!0,analytics:!0,marketing:!0,unclassified:!0}};this.options=this.deepMerge(o,e),this.iframe=null}show(){if(document.cookie.split(";").some(e=>e.trim().startsWith(`${this.options.consentCookieKey}=`))){this.handleOnAllow(this.getCookieValue());return}if(!this.iframe){this.iframe=this.createBannerModal(),document.body.prepend(this.iframe),this.bindEvents(this.iframe);return}this.iframe.style.display="block"}hide(){this.iframe.style.display="none"}showDetail(e){e.getElementById("awx-cookie-banner").querySelector(".awx-cookie-tab[data-tab='detail']").click()}onIframeLoaded(e){return new Promise(o=>{e.addEventListener("load",()=>{o(e)})})}async bindEvents(e){const t=(await this.onIframeLoaded(e)).contentWindow.document,n=t.getElementById("awx-cookie-banner");t.documentElement.style.setProperty("--awx-cookie-ui-color",this.options.ui.color),t.documentElement.style.setProperty("--awx-cookie-ui-text-color",this.options.ui.textColor),t.documentElement.style.setProperty("--awx-cookie-ui-content-bg-color",this.options.ui.contentBgColor),n.style.fontFamily=this.options.ui.font.family,n.style.fontSize=this.options.ui.font.size;const a=n.querySelector("#awx-banner-customize-btn"),s=n.querySelector("#awx-banner-allow-selection-btn"),i=n.querySelector("#awx-banner-allow-all-btn");a.addEventListener("click",()=>this.showDetail(t)),s.addEventListener("click",()=>this.allow(t)),i.addEventListener("click",()=>this.allow(t,!0)),this.toggleCollapsible(t),this.handleTabs(t)}toggleCollapsible(e){const o=e.getElementsByClassName("awx-cookie-collapse-action");let t;for(t=0;t Artworx Cookie Banner ${this.importGoogleFonts()} ${e.outerHTML}
OSZAR »
`;return n.srcdoc=a,n.style.cssText="width: 100%; height: 100%; position: fixed; top: 0; left: 0; z-index: 9999; border: none;",n}importGoogleFonts(){return this.options.ui.font.family?` `:""}renderNecessary(){return` `}renderFeatures(){return` `}renderAnalytics(){return` `}renderMarketing(){return` `}renderUnclassified(){return` `}createBannerContent(){const e=document.createElement("div");return e.innerHTML=` `,e}handleTabs(e){const o=e.querySelectorAll(".awx-cookie-tab");o.forEach(t=>{t.addEventListener("click",function(){const n=this.dataset.tab;o.forEach(i=>i.classList.remove("active")),this.classList.add("active"),e.querySelectorAll(".awx-cookie-tab-pane").forEach(i=>{i.style.display=i.dataset.tab===n?"block":"none"});const a=e.getElementById("awx-banner-customize-btn"),s=e.getElementById("awx-banner-allow-selection-btn");n==="detail"?(a.style.display="none",s.style.display="block"):(a.style.display="block",s.style.display="none")})})}allow(e,o){const t=e.getElementsByClassName("awx-banner-option"),n={necessary:!0,features:!1,analytics:!1,marketing:!1,unclassified:!0};for(const s of t)(s.checked||o)&&(n[s.value]=!0);this.handleOnAllow(n);let a=this.getDaysFromExpiration(this.options.expiredConsentCookie);o||(a=this.options.showAgainWhenCustomAllow),this.setCookie(this.options.consentCookieKey,JSON.stringify(n),a),this.hide()}handleOnAllow(e){this.options.events.onAllow(e);const o=new CustomEvent("awx-cookie-banner.allow",{detail:e});window.dispatchEvent(o)}translate(e){return e.split(".").reduce((t,n)=>t&&t[n],this.options.i18n[this.options.language])||e.split(".").reduce((t,n)=>t&&t[n],this.options.i18n.en)}deepMerge(e,o){for(const t in o)o[t]instanceof Object?(e[t]||(e[t]={}),this.deepMerge(e[t],o[t])):e[t]=o[t];return e}setCookie(e,o,t){const n=new Date(Date.now()+t*864e5).toUTCString();document.cookie=`${e}=${encodeURIComponent(o)}; expires=${n}; path=/`}getCookieValue(){const e=document.cookie.split(";").find(o=>o.trim().startsWith(`${this.options.consentCookieKey}=`)).split("=")[1];return JSON.parse(decodeURIComponent(e))}getDaysFromExpiration(e){switch(e){case"next_visit":return 0;case"next_week":return 7;case"next_month":return 30;case"next_year":return 365;case"no_expires":return 400;default:return 365}}}return l});