react-cookienotice
Version:
A lightweight & customizable cookie banner for your React App
841 lines (838 loc) • 31.4 kB
JavaScript
/**
* react-cookienotice v7.0.1
* (c) 2020-2025 by xavierbriole
* Released under the MIT License.
*/
import Pe, { useState as xe, useRef as Le, useEffect as $e, useCallback as C, useMemo as Me } from "react";
var ve = { exports: {} }, oe = {};
/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Se;
function Ye() {
if (Se) return oe;
Se = 1;
var t = Symbol.for("react.transitional.element"), c = Symbol.for("react.fragment");
function s(d, l, m) {
var p = null;
if (m !== void 0 && (p = "" + m), l.key !== void 0 && (p = "" + l.key), "key" in l) {
m = {};
for (var f in l)
f !== "key" && (m[f] = l[f]);
} else m = l;
return l = m.ref, {
$$typeof: t,
type: d,
key: p,
ref: l !== void 0 ? l : null,
props: m
};
}
return oe.Fragment = c, oe.jsx = s, oe.jsxs = s, oe;
}
var ne = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Ne;
function We() {
return Ne || (Ne = 1, process.env.NODE_ENV !== "production" && function() {
function t(e) {
if (e == null) return null;
if (typeof e == "function")
return e.$$typeof === Ae ? null : e.displayName || e.name || null;
if (typeof e == "string") return e;
switch (e) {
case J:
return "Fragment";
case ke:
return "Portal";
case U:
return "Profiler";
case ie:
return "StrictMode";
case X:
return "Suspense";
case Z:
return "SuspenseList";
}
if (typeof e == "object")
switch (typeof e.tag == "number" && console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
), e.$$typeof) {
case ae:
return (e.displayName || "Context") + ".Provider";
case ce:
return (e._context.displayName || "Context") + ".Consumer";
case F:
var o = e.render;
return e = e.displayName, e || (e = o.displayName || o.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
case Q:
return o = e.displayName || null, o !== null ? o : t(e.type) || "Memo";
case K:
o = e._payload, e = e._init;
try {
return t(e(o));
} catch {
}
}
return null;
}
function c(e) {
return "" + e;
}
function s(e) {
try {
c(e);
var o = !1;
} catch {
o = !0;
}
if (o) {
o = console;
var n = o.error, a = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
return n.call(
o,
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
a
), c(e);
}
}
function d() {
}
function l() {
if (Y === 0) {
D = console.log, le = console.info, ue = console.warn, fe = console.error, de = console.group, be = console.groupCollapsed, me = console.groupEnd;
var e = {
configurable: !0,
enumerable: !0,
value: d,
writable: !0
};
Object.defineProperties(console, {
info: e,
log: e,
warn: e,
error: e,
group: e,
groupCollapsed: e,
groupEnd: e
});
}
Y++;
}
function m() {
if (Y--, Y === 0) {
var e = { configurable: !0, enumerable: !0, writable: !0 };
Object.defineProperties(console, {
log: S({}, e, { value: D }),
info: S({}, e, { value: le }),
warn: S({}, e, { value: ue }),
error: S({}, e, { value: fe }),
group: S({}, e, { value: de }),
groupCollapsed: S({}, e, { value: be }),
groupEnd: S({}, e, { value: me })
});
}
0 > Y && console.error(
"disabledDepth fell below zero. This is a bug in React. Please file an issue."
);
}
function p(e) {
if (ee === void 0)
try {
throw Error();
} catch (n) {
var o = n.stack.trim().match(/\n( *(at )?)/);
ee = o && o[1] || "", P = -1 < n.stack.indexOf(`
at`) ? " (<anonymous>)" : -1 < n.stack.indexOf("@") ? "@unknown:0:0" : "";
}
return `
` + ee + e + P;
}
function f(e, o) {
if (!e || ye) return "";
var n = je.get(e);
if (n !== void 0) return n;
ye = !0, n = Error.prepareStackTrace, Error.prepareStackTrace = void 0;
var a = null;
a = T.H, T.H = null, l();
try {
var h = {
DetermineComponentFrameRoot: function() {
try {
if (o) {
var L = function() {
throw Error();
};
if (Object.defineProperty(L.prototype, "props", {
set: function() {
throw Error();
}
}), typeof Reflect == "object" && Reflect.construct) {
try {
Reflect.construct(L, []);
} catch (_) {
var pe = _;
}
Reflect.construct(e, [], L);
} else {
try {
L.call();
} catch (_) {
pe = _;
}
e.call(L.prototype);
}
} else {
try {
throw Error();
} catch (_) {
pe = _;
}
(L = e()) && typeof L.catch == "function" && L.catch(function() {
});
}
} catch (_) {
if (_ && pe && typeof _.stack == "string")
return [_.stack, pe.stack];
}
return [null, null];
}
};
h.DetermineComponentFrameRoot.displayName = "DetermineComponentFrameRoot";
var u = Object.getOwnPropertyDescriptor(
h.DetermineComponentFrameRoot,
"name"
);
u && u.configurable && Object.defineProperty(
h.DetermineComponentFrameRoot,
"name",
{ value: "DetermineComponentFrameRoot" }
);
var r = h.DetermineComponentFrameRoot(), N = r[0], V = r[1];
if (N && V) {
var A = N.split(`
`), W = V.split(`
`);
for (r = u = 0; u < A.length && !A[u].includes(
"DetermineComponentFrameRoot"
); )
u++;
for (; r < W.length && !W[r].includes(
"DetermineComponentFrameRoot"
); )
r++;
if (u === A.length || r === W.length)
for (u = A.length - 1, r = W.length - 1; 1 <= u && 0 <= r && A[u] !== W[r]; )
r--;
for (; 1 <= u && 0 <= r; u--, r--)
if (A[u] !== W[r]) {
if (u !== 1 || r !== 1)
do
if (u--, r--, 0 > r || A[u] !== W[r]) {
var te = `
` + A[u].replace(
" at new ",
" at "
);
return e.displayName && te.includes("<anonymous>") && (te = te.replace("<anonymous>", e.displayName)), typeof e == "function" && je.set(e, te), te;
}
while (1 <= u && 0 <= r);
break;
}
}
} finally {
ye = !1, T.H = a, m(), Error.prepareStackTrace = n;
}
return A = (A = e ? e.displayName || e.name : "") ? p(A) : "", typeof e == "function" && je.set(e, A), A;
}
function b(e) {
if (e == null) return "";
if (typeof e == "function") {
var o = e.prototype;
return f(
e,
!(!o || !o.isReactComponent)
);
}
if (typeof e == "string") return p(e);
switch (e) {
case X:
return p("Suspense");
case Z:
return p("SuspenseList");
}
if (typeof e == "object")
switch (e.$$typeof) {
case F:
return e = f(e.render, !1), e;
case Q:
return b(e.type);
case K:
o = e._payload, e = e._init;
try {
return b(e(o));
} catch {
}
}
return "";
}
function x() {
var e = T.A;
return e === null ? null : e.getOwner();
}
function k(e) {
if (O.call(e, "key")) {
var o = Object.getOwnPropertyDescriptor(e, "key").get;
if (o && o.isReactWarning) return !1;
}
return e.key !== void 0;
}
function y(e, o) {
function n() {
Ce || (Ce = !0, console.error(
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
o
));
}
n.isReactWarning = !0, Object.defineProperty(e, "key", {
get: n,
configurable: !0
});
}
function $() {
var e = t(this.type);
return we[e] || (we[e] = !0, console.error(
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
)), e = this.props.ref, e !== void 0 ? e : null;
}
function M(e, o, n, a, h, u) {
return n = u.ref, e = {
$$typeof: G,
type: e,
key: o,
props: u,
_owner: h
}, (n !== void 0 ? n : null) !== null ? Object.defineProperty(e, "ref", {
enumerable: !1,
get: $
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: 0
}), Object.defineProperty(e, "_debugInfo", {
configurable: !1,
enumerable: !1,
writable: !0,
value: null
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
}
function B(e, o, n, a, h, u) {
if (typeof e == "string" || typeof e == "function" || e === J || e === U || e === ie || e === X || e === Z || e === ge || typeof e == "object" && e !== null && (e.$$typeof === K || e.$$typeof === Q || e.$$typeof === ae || e.$$typeof === ce || e.$$typeof === F || e.$$typeof === Ee || e.getModuleId !== void 0)) {
var r = o.children;
if (r !== void 0)
if (a)
if (R(r)) {
for (a = 0; a < r.length; a++)
E(r[a], e);
Object.freeze && Object.freeze(r);
} else
console.error(
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
);
else E(r, e);
} else
r = "", (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (r += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."), e === null ? a = "null" : R(e) ? a = "array" : e !== void 0 && e.$$typeof === G ? (a = "<" + (t(e.type) || "Unknown") + " />", r = " Did you accidentally export a JSX literal instead of a component?") : a = typeof e, console.error(
"React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",
a,
r
);
if (O.call(o, "key")) {
r = t(e);
var N = Object.keys(o).filter(function(A) {
return A !== "key";
});
a = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", ze[r + a] || (N = 0 < N.length ? "{" + N.join(": ..., ") + ": ...}" : "{}", console.error(
`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,
a,
r,
N,
r
), ze[r + a] = !0);
}
if (r = null, n !== void 0 && (s(n), r = "" + n), k(o) && (s(o.key), r = "" + o.key), "key" in o) {
n = {};
for (var V in o)
V !== "key" && (n[V] = o[V]);
} else n = o;
return r && y(
n,
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
), M(e, r, u, h, x(), n);
}
function E(e, o) {
if (typeof e == "object" && e && e.$$typeof !== Re) {
if (R(e))
for (var n = 0; n < e.length; n++) {
var a = e[n];
g(a) && z(a, o);
}
else if (g(e))
e._store && (e._store.validated = 1);
else if (e === null || typeof e != "object" ? n = null : (n = se && e[se] || e["@@iterator"], n = typeof n == "function" ? n : null), typeof n == "function" && n !== e.entries && (n = n.call(e), n !== e))
for (; !(e = n.next()).done; )
g(e.value) && z(e.value, o);
}
}
function g(e) {
return typeof e == "object" && e !== null && e.$$typeof === G;
}
function z(e, o) {
if (e._store && !e._store.validated && e.key == null && (e._store.validated = 1, o = I(o), !Oe[o])) {
Oe[o] = !0;
var n = "";
e && e._owner != null && e._owner !== x() && (n = null, typeof e._owner.tag == "number" ? n = t(e._owner.type) : typeof e._owner.name == "string" && (n = e._owner.name), n = " It was passed a child from " + n + ".");
var a = T.getCurrentStack;
T.getCurrentStack = function() {
var h = b(e.type);
return a && (h += a() || ""), h;
}, console.error(
'Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',
o,
n
), T.getCurrentStack = a;
}
}
function I(e) {
var o = "", n = x();
return n && (n = t(n.type)) && (o = `
Check the render method of \`` + n + "`."), o || (e = t(e)) && (o = `
Check the top-level render call using <` + e + ">."), o;
}
var q = Pe, G = Symbol.for("react.transitional.element"), ke = Symbol.for("react.portal"), J = Symbol.for("react.fragment"), ie = Symbol.for("react.strict_mode"), U = Symbol.for("react.profiler"), ce = Symbol.for("react.consumer"), ae = Symbol.for("react.context"), F = Symbol.for("react.forward_ref"), X = Symbol.for("react.suspense"), Z = Symbol.for("react.suspense_list"), Q = Symbol.for("react.memo"), K = Symbol.for("react.lazy"), ge = Symbol.for("react.offscreen"), se = Symbol.iterator, Ae = Symbol.for("react.client.reference"), T = q.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, O = Object.prototype.hasOwnProperty, S = Object.assign, Ee = Symbol.for("react.client.reference"), R = Array.isArray, Y = 0, D, le, ue, fe, de, be, me;
d.__reactDisabledLog = !0;
var ee, P, ye = !1, je = new (typeof WeakMap == "function" ? WeakMap : Map)(), Re = Symbol.for("react.client.reference"), Ce, we = {}, ze = {}, Oe = {};
ne.Fragment = J, ne.jsx = function(e, o, n, a, h) {
return B(e, o, n, !1, a, h);
}, ne.jsxs = function(e, o, n, a, h) {
return B(e, o, n, !0, a, h);
};
}()), ne;
}
var _e;
function Be() {
return _e || (_e = 1, process.env.NODE_ENV === "production" ? ve.exports = Ye() : ve.exports = We()), ve.exports;
}
var i = Be();
const he = (t) => {
const { name: c, value: s, expires: d, secure: l, httpOnly: m, sameSite: p } = t, f = /* @__PURE__ */ new Date();
f.setTime(f.getTime() + d * 24 * 60 * 60 * 1e3);
let b = `${c}=${s};expires=${f.toUTCString()};path=/;`;
l && (b += "Secure;"), m && (b += "HttpOnly;"), b += `SameSite=${p};`, document.cookie = b;
}, Ue = (t) => {
const c = document.cookie.match(`(^|;) ?${t}=([^;]*)(;|$)`);
return c ? decodeURIComponent(c[2]) : null;
}, v = (t) => {
process.env.NODE_ENV === "development" && console.error(`[react-cookienotice] ${t}`);
}, j = (t) => {
if (typeof t == "string")
return t;
}, Ve = (t) => {
if (typeof t == "number") {
if (t >= 0)
return t;
v("timeout should be a positive number");
}
return 1e3;
}, He = (t) => {
if (Array.isArray(t)) {
if (t.length === 0 && v("services should have at least one element"), t.every((c) => typeof c == "object"))
return t;
v("services should contain only objects");
}
}, Ie = (t) => {
if (typeof t == "string") {
if (t.lastIndexOf("http://", 0) === 0 || t.lastIndexOf("https://", 0) === 0)
return t;
v('a link should start with "http://" or "https://"');
}
}, qe = (t) => {
if (typeof t == "boolean")
return t;
}, Ge = (t) => typeof t == "object" ? ((t.vertical !== "top" || t.vertical !== "bottom") && v('placement.vertical parameter should be "top" or "bottom"'), (t.horizontal !== "left" || t.horizontal !== "right") && v('placement.horizontal parameter should be "left" or "right"'), t) : { vertical: "bottom", horizontal: "left" }, Je = (t) => typeof t == "object" ? (typeof t.name != "string" && v("cookieOptions.name parameter should be a string"), typeof t.value != "string" && v("cookieOptions.value parameter should be a string"), typeof t.expires != "number" && v("cookieOptions.expires parameter should be a number"), typeof t.secure != "boolean" && v("cookieOptions.secure parameter should be a boolean"), typeof t.httpOnly != "boolean" && v("cookieOptions.httpOnly parameter should be a boolean"), /* v8 ignore next 3 */
(t.sameSite !== "strict" || t.sameSite !== "lax" || t.sameSite !== "none") && v(
'cookieOptions.sameSite parameter should be "strict", "lax" or "none"'
), /\s/.test(t.name) && v("cookieOptions.name parameter should not contain whitespace"), t.name === "" && v("cookieOptions.name parameter should have at least one character"), /\s/.test(t.value) && v("cookieOptions.value parameter should not contain whitespace"), t.value === "" && v("cookieOptions.value parameter should have at least one character"), t.expires <= 0 && v("cookieOptions.expires parameter should be more than 0 day"), t) : {
name: "hide-notice",
value: "true",
expires: 30,
secure: !1,
httpOnly: !1,
sameSite: "lax"
}, Fe = {
"text.title": "Cookie-Zustimmung",
"text.description": "Indem Sie auf „Akzeptieren“ klicken, stimmen Sie der Verwendung von Cookies auf unserer Website zu, um Ihnen durch die Speicherung Ihrer Cookie-Einstellungen ein möglichst relevantes Erlebnis zu bieten.",
"text.customizeTitle": "Anpassen",
"button.accept": "Akzeptieren",
"button.acceptAll": "Akzeptiere alle",
"button.declineAll": "Alles ablehnen",
"button.customize": "Anpassen",
"button.back": "Zurück",
"button.customizeAcceptAll": "Akzeptiere alle",
"text.alwaysActive": "Immer aktiv"
}, Xe = {
"text.title": "Cookie consent",
"text.description": "By clicking Accept, you consent to our website's use of cookies to provide you with the most relevant experience by remembering your cookie preferences.",
"text.customizeTitle": "Customize",
"button.accept": "Accept",
"button.acceptAll": "Accept all",
"button.declineAll": "Decline all",
"button.customize": "Customize",
"button.back": "Back",
"button.customizeAcceptAll": "Accept all",
"text.alwaysActive": "Always active"
}, Ze = {
"text.title": "Consentimiento de cookies",
"text.description": "Al hacer clic en Aceptar, usted acepta el uso de cookies por parte de nuestro sitio web para brindarle la experiencia más relevante al recordar sus preferencias de cookies.",
"text.customizeTitle": "Personalizar",
"button.accept": "Aceptar",
"button.acceptAll": "Aceptar todo",
"button.declineAll": "Rechazar todo",
"button.customize": "Personalizar",
"button.back": "Atrás",
"button.customizeAcceptAll": "Aceptar todo",
"text.alwaysActive": "Siempre activo"
}, Qe = {
"text.title": "Consentement aux cookies",
"text.description": "En cliquant sur Accepter, vous consentez à l'utilisation de cookies par notre site Web pour vous offrir l'expérience la plus pertinente en mémorisant vos préférences en matière de cookies.",
"text.customizeTitle": "Personnaliser",
"button.accept": "Accepter",
"button.acceptAll": "Accepter tout",
"button.declineAll": "Refuser tout",
"button.customize": "Personnaliser",
"button.back": "Retour",
"button.customizeAcceptAll": "Accepter tout",
"text.alwaysActive": "Toujours actif"
}, Ke = {
"text.title": "Consenso ai cookie",
"text.description": "Facendo clic su Accetta, acconsenti all'utilizzo dei cookie da parte del nostro sito Web per fornirti l'esperienza più pertinente ricordando le tue preferenze sui cookie.",
"text.customizeTitle": "personalizzare",
"button.accept": "Accettare",
"button.acceptAll": "Accettare tutti",
"button.declineAll": "Rifiuta tutto",
"button.customize": "personalizzare",
"button.back": "Indietro",
"button.customizeAcceptAll": "Accettare tutti",
"text.alwaysActive": "Sempre attivo"
}, De = {
"text.title": "쿠키 동의",
"text.description": "동의를 클릭하면 귀하의 쿠키 기본 설정을 기억함으로써 가장 관련성 높은 경험을 제공하기 위해 당사 웹사이트의 쿠키 사용에 동의하는 것입니다.",
"text.customizeTitle": "사용자 정의",
"button.accept": "수용하다",
"button.acceptAll": "모든것을 받아 들인다",
"button.declineAll": "모두 거절",
"button.customize": "사용자 정의",
"button.back": "뒤쪽에",
"button.customizeAcceptAll": "모든것을 받아 들인다",
"text.alwaysActive": "항상 활성"
}, et = {
"text.title": "Consentiment als cookies",
"text.description": "En clicant Acceptar, consentètz a l'utilizacion de cookies per nòstre site Web per vos ofrir l'experiéncia mai pertinenta en memorizant vòstras preferéncias a prepaus dels cookies.",
"text.customizeTitle": "Personalizat",
"button.accept": "Acceptar",
"button.acceptAll": "Acceptar tot",
"button.declineAll": "Declinar tot",
"button.customize": "Personalizat",
"button.back": "Precedent",
"button.customizeAcceptAll": "Acceptar tot",
"text.alwaysActive": "Totjorn actiu"
}, tt = {
"text.title": "Cookie 同意",
"text.description": "单击“接受”即表示您同意我们的网站使用 cookie, 通过记住您的 cookie 偏好来为您提供最相关的体验。",
"text.customizeTitle": "定制",
"button.accept": "接受",
"button.acceptAll": "全都接受",
"button.declineAll": "全部拒绝",
"button.customize": "定制",
"button.back": "后退",
"button.customizeAcceptAll": "全都接受",
"text.alwaysActive": "始终活跃"
}, Te = {
de: Fe,
en: Xe,
es: Ze,
fr: Qe,
it: Ke,
ko: De,
oc: et,
zh: tt
}, ot = "en", w = (t, c) => {
if (c !== void 0)
return c;
const s = navigator.language.split("-")[0], l = Object.keys(Te).includes(s) ? s : ot;
return Te[l][t] === void 0 ? (v(`no message found for id "${t}"`), t) : Te[l][t];
}, H = ({ onClick: t, children: c }) => /* @__PURE__ */ i.jsx("button", { className: "react-cookienotice-button", onClick: t, children: c }), re = ({ children: t }) => /* @__PURE__ */ i.jsx("span", { className: "react-cookienotice-label", children: t }), nt = ({
name: t,
description: c,
code: s,
alwaysActive: d,
alwaysActiveLabel: l,
isChecked: m,
onCheckboxChange: p
}) => {
const [f, b] = xe(!1), x = Le(null), k = () => {
b(!f);
};
return $e(() => {
if (x.current instanceof HTMLDivElement) {
if (f) {
x.current.style.maxHeight = `${x.current.scrollHeight}px`;
return;
}
x.current.style.maxHeight = "0";
}
}, [f]), /* @__PURE__ */ i.jsxs("div", { className: "react-cookienotice-service", children: [
/* @__PURE__ */ i.jsxs("div", { className: "react-cookienotice-service-checkbox", children: [
/* @__PURE__ */ i.jsx(
"input",
{
type: "checkbox",
id: s,
name: s,
checked: d || m,
onChange: p,
disabled: d
}
),
/* @__PURE__ */ i.jsx("label", { htmlFor: s, children: s })
] }),
/* @__PURE__ */ i.jsxs("div", { className: "react-cookienotice-service-info", children: [
/* @__PURE__ */ i.jsxs(
"button",
{
className: `react-cookienotice-service-info-title${f ? " open" : ""}`,
onClick: k,
children: [
t,
d && /* @__PURE__ */ i.jsx("div", { className: "react-cookienotice-service-info-title-always-active", children: /* @__PURE__ */ i.jsx(re, { children: w("text.alwaysActive", l) }) })
]
}
),
/* @__PURE__ */ i.jsx(
"div",
{
ref: x,
className: "react-cookienotice-service-info-content",
children: /* @__PURE__ */ i.jsx(re, { children: c })
}
)
] })
] });
}, rt = ({
customizeTitleLabel: t,
services: c,
onAcceptButtonClick: s,
acceptButtonLabel: d,
onBackButtonClick: l,
backButtonLabel: m,
alwaysActiveLabel: p,
customizeAcceptAllButtonLabel: f,
onCustomizeAcceptAllButtonClick: b,
customizeAcceptAllTimeout: x
}) => {
const [k, y] = xe([]), $ = C(
(E) => {
const { name: g } = E.target;
if (k.includes(g)) {
y(
k.filter((z) => z !== g)
);
return;
}
y([...k, g]);
},
[k]
), M = C(() => {
const E = c.filter(({ alwaysActive: g }) => g).map(({ code: g }) => g);
s([...k, ...E]);
}, [k, s]), B = C(() => {
y(c.map(({ code: E }) => E)), setTimeout(() => {
b == null || b(c.map(({ code: E }) => E));
}, x);
}, []);
return /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
/* @__PURE__ */ i.jsxs("div", { className: "react-cookienotice-body", children: [
/* @__PURE__ */ i.jsx("div", { className: "react-cookienotice-title", children: /* @__PURE__ */ i.jsx(re, { children: w("text.customizeTitle", t) }) }),
/* @__PURE__ */ i.jsx("div", { className: "react-cookienotice-services", children: c.map(({ name: E, description: g, code: z, alwaysActive: I }, q) => /* @__PURE__ */ i.jsx(
nt,
{
name: E,
description: g,
code: z,
alwaysActive: I,
alwaysActiveLabel: p,
isChecked: k.includes(z),
onCheckboxChange: $
},
q
)) })
] }),
/* @__PURE__ */ i.jsxs("div", { className: "react-cookienotice-buttons", children: [
/* @__PURE__ */ i.jsx(H, { onClick: l, children: w("button.back", m) }),
/* @__PURE__ */ i.jsx(H, { onClick: B, children: w(
"button.customizeAcceptAll",
f
) }),
/* @__PURE__ */ i.jsx(H, { onClick: M, children: w("button.accept", d) })
] })
] });
}, it = ({ to: t, newTab: c, label: s }) => /* @__PURE__ */ i.jsx(
"a",
{
href: t,
target: c ? "_blank" : "_self",
rel: c ? "noreferrer" : void 0,
className: "react-cookienotice-link",
children: s
}
), ct = ({
titleLabel: t,
descriptionLabel: c,
readMoreLink: s,
readMoreInNewTab: d,
readMoreLabel: l,
onAcceptAllButtonClick: m,
acceptAllButtonLabel: p,
onCustomizeButtonClick: f,
customizeButtonLabel: b,
onDeclineAllButtonClick: x,
declineAllButtonLabel: k,
services: y
}) => {
const $ = C(() => {
m(y == null ? void 0 : y.map(({ code: M }) => M));
}, []);
return /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
/* @__PURE__ */ i.jsxs("div", { className: "react-cookienotice-body", children: [
/* @__PURE__ */ i.jsx("div", { className: "react-cookienotice-title", children: /* @__PURE__ */ i.jsx(re, { children: w("text.title", t) }) }),
/* @__PURE__ */ i.jsx("div", { className: "react-cookienotice-description", children: /* @__PURE__ */ i.jsx(re, { children: w("text.description", c) }) }),
s && d && l && /* @__PURE__ */ i.jsx("div", { className: "react-cookienotice-read-more", children: /* @__PURE__ */ i.jsx(
it,
{
to: s,
newTab: d,
label: l
}
) })
] }),
/* @__PURE__ */ i.jsxs("div", { className: "react-cookienotice-buttons", children: [
/* @__PURE__ */ i.jsx(H, { onClick: x, children: w("button.declineAll", k) }),
y && y.length > 0 && /* @__PURE__ */ i.jsx(H, { onClick: f, children: w("button.customize", b) }),
/* @__PURE__ */ i.jsx(H, { onClick: $, children: w("button.acceptAll", p) })
] })
] });
}, st = ({
acceptAllButtonLabel: t,
onAcceptAllButtonClick: c,
declineAllButtonLabel: s,
onDeclineAllButtonClick: d,
customizeButtonLabel: l,
customizeTitleLabel: m,
services: p,
acceptButtonLabel: f,
onAcceptButtonClick: b,
backButtonLabel: x,
alwaysActiveLabel: k,
customizeAcceptAllButtonLabel: y,
customizeAcceptAllTimeout: $,
titleLabel: M,
descriptionLabel: B,
readMoreLabel: E,
readMoreLink: g,
readMoreInNewTab: z,
placement: I,
cookieOptions: q
}) => {
const G = j(t), ke = j(s), J = j(l), ie = j(m), U = He(p), ce = j(f), ae = j(x), F = j(k), X = j(
y
), Z = Ve(
$
), Q = j(M), K = j(B), ge = j(E), se = Ie(g), Ae = qe(z), T = Ge(I), O = Je(q), S = Me(
() => Ue(O.name) === O.value,
[]
), [Ee, R] = xe(!1), [Y, D] = xe(!1), le = C((P) => {
R(!0), he(O), b == null || b(P);
}, []), ue = C(() => {
D(!1);
}, []), fe = C((P) => {
R(!0), he(O), c == null || c(P);
}, []), de = C(() => {
D(!0);
}, []), be = C(() => {
R(!0), he(O), d == null || d();
}, []), me = C(
(P) => {
R(!0), he(O), c == null || c(P);
},
[]
), ee = () => Y && U ? /* @__PURE__ */ i.jsx(
rt,
{
customizeTitleLabel: ie,
services: U,
onAcceptButtonClick: le,
acceptButtonLabel: ce,
onBackButtonClick: ue,
backButtonLabel: ae,
alwaysActiveLabel: F,
customizeAcceptAllButtonLabel: X,
onCustomizeAcceptAllButtonClick: me,
customizeAcceptAllTimeout: Z
}
) : /* @__PURE__ */ i.jsx(
ct,
{
titleLabel: Q,
descriptionLabel: K,
readMoreLink: se,
readMoreInNewTab: Ae,
readMoreLabel: ge,
onAcceptAllButtonClick: fe,
acceptAllButtonLabel: G,
onCustomizeButtonClick: de,
customizeButtonLabel: J,
onDeclineAllButtonClick: be,
declineAllButtonLabel: ke,
services: U
}
);
return /* @__PURE__ */ i.jsx(
"div",
{
className: `react-cookienotice-root${Ee ? " hide-with-animation" : ""}${S ? " hidden" : ""} ${T.vertical} ${T.horizontal}`,
children: ee()
}
);
};
export {
st as CookieNotice
};