var src_default = "dialog{all:unset;box-sizing:border-box;border:1px solid;max-width:36rem;margin-left:auto;padding:1rem;position:fixed;bottom:1.25rem;left:1.25rem;right:1.25rem}dialog:not([open]){display:none}.buttons{gap:.5rem;margin-top:1.25rem;display:flex}button{background-color:unset;border:none;padding:0}", ConsentChangeEvent = class extends Event {
value;
constructor(e) {
super("consentchange"), this.value = e;
}
}, CookieBanner = class extends HTMLElement {
#e = null;
#t = null;
consent = "prompting";
storageKey = "cookie-consent";
#n() {
let e = localStorage.getItem(this.storageKey);
return e === "granted" || e === "denied" ? e : "prompting";
}
#r(e) {
let t = new StorageEvent("storage", {
key: this.storageKey,
newValue: e
});
localStorage.setItem(this.storageKey, e), window.dispatchEvent(t);
}
#i(e) {
return {
analytics_storage: e,
ad_storage: e,
ad_user_data: e,
ad_personalization: e,
functionality_storage: e,
personalization_storage: e
};
}
#a() {
this.#e && (this.#e.querySelector("[data-accept]")?.addEventListener("click", () => this.#r("granted")), this.#e.querySelector("[data-reject]")?.addEventListener("click", () => this.#r("denied")), window.addEventListener("storage", (e) => {
if (e.key !== this.storageKey) return;
let n = e.newValue;
if (n !== "granted" && n !== "denied") return this.promptForConsent();
this.#t?.close(), this.consent = n;
let r = this.#i(n);
window.gtag?.("consent", "update", r), this.dispatchEvent(new ConsentChangeEvent(this.consent));
}, { passive: !0 }));
}
#o() {
this.#e = this.attachShadow({ mode: "open" }), this.#e.innerHTML = `
`, this.#t = this.#e.querySelector("dialog"), this.consent === "prompting" && this.#t?.show();
}
promptForConsent() {
this.consent = "prompting", this.#t?.show();
}
connectedCallback() {
this.storageKey = this.getAttribute("storage-key") || this.storageKey, this.consent = this.#n(), this.#o(), this.#a();
}
};
customElements.define("cookie-banner", CookieBanner);
export { ConsentChangeEvent, CookieBanner };