acronweb-cookies
Version:
A modern, GDPR-compliant cookie consent plugin for React and Next.js applications
625 lines (615 loc) • 42.1 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var jsxRuntime = require('react/jsx-runtime');
var react = require('react');
var framerMotion = require('framer-motion');
var lucideReact = require('lucide-react');
var Cookies = require('js-cookie');
var app = require('firebase/app');
var firestore = require('firebase/firestore');
var analytics$1 = require('firebase/analytics');
function usePathname() {
const [pathname, setPathname] = react.useState(null);
react.useEffect(() => {
// Try to use Next.js usePathname if available
try {
const nextNavigation = require('next/navigation');
if (nextNavigation.usePathname) {
return nextNavigation.usePathname();
}
}
catch (_a) {
// Next.js not available, use window.location
}
// Fallback to window.location
if (typeof window !== 'undefined') {
setPathname(window.location.pathname);
const handlePopState = () => {
setPathname(window.location.pathname);
};
window.addEventListener('popstate', handlePopState);
return () => window.removeEventListener('popstate', handlePopState);
}
}, []);
return pathname;
}
class AcronWebCookieManager {
constructor() {
this.CONSENT_KEY = 'acronweb_cookie_consent';
this.SETTINGS_KEY = 'acronweb_cookie_settings';
this.USER_ID_KEY = 'acronweb_user_id';
}
setConsent(consent, settings) {
var _a, _b, _c;
try {
// Save to localStorage
localStorage.setItem(this.CONSENT_KEY, consent.toString());
// Save to cookies with 1 year expiration
Cookies.set(this.CONSENT_KEY, consent.toString(), {
expires: 365,
sameSite: 'strict',
secure: window.location.protocol === 'https:'
});
// Save settings if provided
if (settings) {
const defaultSettings = {
necessary: true, // Always true
analytics: (_a = settings.analytics) !== null && _a !== void 0 ? _a : false,
marketing: (_b = settings.marketing) !== null && _b !== void 0 ? _b : false,
preferences: (_c = settings.preferences) !== null && _c !== void 0 ? _c : false
};
localStorage.setItem(this.SETTINGS_KEY, JSON.stringify(defaultSettings));
Cookies.set(this.SETTINGS_KEY, JSON.stringify(defaultSettings), {
expires: 365,
sameSite: 'strict',
secure: window.location.protocol === 'https:'
});
}
// Generate and save user ID if not exists
this.ensureUserId();
}
catch (error) {
console.warn('Failed to save cookie consent:', error);
}
}
getConsent() {
try {
// Try localStorage first
const localStorageConsent = localStorage.getItem(this.CONSENT_KEY);
if (localStorageConsent !== null) {
return localStorageConsent === 'true';
}
// Fallback to cookies
const cookieConsent = Cookies.get(this.CONSENT_KEY);
if (cookieConsent !== undefined) {
return cookieConsent === 'true';
}
return null;
}
catch (error) {
console.warn('Failed to get cookie consent:', error);
return null;
}
}
clearConsent() {
try {
localStorage.removeItem(this.CONSENT_KEY);
localStorage.removeItem(this.SETTINGS_KEY);
localStorage.removeItem(this.USER_ID_KEY);
Cookies.remove(this.CONSENT_KEY);
Cookies.remove(this.SETTINGS_KEY);
Cookies.remove(this.USER_ID_KEY);
}
catch (error) {
console.warn('Failed to clear cookie consent:', error);
}
}
setCookie(name, value, options) {
try {
const defaultOptions = {
expires: 365,
sameSite: 'strict',
secure: window.location.protocol === 'https:',
...options
};
Cookies.set(name, value, defaultOptions);
}
catch (error) {
console.warn(`Failed to set cookie ${name}:`, error);
}
}
getCookie(name) {
try {
return Cookies.get(name);
}
catch (error) {
console.warn(`Failed to get cookie ${name}:`, error);
return undefined;
}
}
removeCookie(name) {
try {
Cookies.remove(name);
}
catch (error) {
console.warn(`Failed to remove cookie ${name}:`, error);
}
}
getSettings() {
try {
// Try localStorage first
const localStorageSettings = localStorage.getItem(this.SETTINGS_KEY);
if (localStorageSettings) {
return JSON.parse(localStorageSettings);
}
// Fallback to cookies
const cookieSettings = Cookies.get(this.SETTINGS_KEY);
if (cookieSettings) {
return JSON.parse(cookieSettings);
}
return null;
}
catch (error) {
console.warn('Failed to get cookie settings:', error);
return null;
}
}
getUserId() {
try {
let userId = localStorage.getItem(this.USER_ID_KEY) || Cookies.get(this.USER_ID_KEY);
if (!userId) {
userId = this.generateUserId();
this.ensureUserId();
}
return userId;
}
catch (error) {
console.warn('Failed to get user ID:', error);
return this.generateUserId();
}
}
generateUserId() {
return 'user_' + Math.random().toString(36).substr(2, 9) + '_' + Date.now().toString(36);
}
ensureUserId() {
try {
const userId = this.getUserId();
if (!localStorage.getItem(this.USER_ID_KEY)) {
localStorage.setItem(this.USER_ID_KEY, userId);
}
if (!Cookies.get(this.USER_ID_KEY)) {
Cookies.set(this.USER_ID_KEY, userId, {
expires: 365,
sameSite: 'strict',
secure: window.location.protocol === 'https:'
});
}
}
catch (error) {
console.warn('Failed to ensure user ID:', error);
}
}
async saveToFirebase(consent) {
// This will be implemented by the Firebase service
// For now, we just log it
console.log('Saving consent to Firebase:', consent);
}
}
// Export singleton instance
const cookieManager = new AcronWebCookieManager();
let analytics = null;
class AcronWebFirebaseService {
constructor() {
this.app = null;
this.db = null;
this.isInitialized = false;
}
initialize(config) {
try {
if (this.isInitialized) {
console.warn('Firebase is already initialized');
return;
}
this.app = app.initializeApp(config);
this.db = firestore.getFirestore(this.app);
// Initialize analytics only if measurementId exists
if (config.measurementId) {
try {
analytics = analytics$1.getAnalytics(this.app);
console.log('Firebase Analytics initialized');
}
catch (err) {
console.warn('Firebase Analytics could not be initialized:', err);
}
}
this.isInitialized = true;
console.log('AcronWeb Firebase service initialized successfully');
}
catch (error) {
console.error('Failed to initialize Firebase:', error);
throw new Error('Firebase initialization failed');
}
}
async saveConsent(consent) {
if (!this.isInitialized || !this.db) {
console.warn('Firebase not initialized, skipping save');
return;
}
try {
const consentData = {
...consent,
timestamp: firestore.Timestamp.fromDate(consent.timestamp),
createdAt: firestore.Timestamp.now(),
updatedAt: firestore.Timestamp.now()
};
// Save to users collection
const userRef = firestore.doc(this.db, 'users', consent.id);
await firestore.setDoc(userRef, {
id: consent.id,
consent: consent.consent,
language: consent.language,
userAgent: consent.userAgent,
ipAddress: consent.ipAddress,
country: consent.country,
city: consent.city,
createdAt: consentData.createdAt,
updatedAt: consentData.updatedAt
}, { merge: true });
// Save to consents collection for analytics
const consentRef = firestore.doc(this.db, 'consents', `${consent.id}_${Date.now()}`);
await firestore.setDoc(consentRef, consentData);
console.log('Consent saved to Firebase successfully');
}
catch (error) {
console.error('Failed to save consent to Firebase:', error);
throw new Error('Failed to save consent data');
}
}
async getConsent(userId) {
var _a;
if (!this.isInitialized || !this.db) {
console.warn('Firebase not initialized, cannot get consent');
return null;
}
try {
const userRef = firestore.doc(this.db, 'users', userId);
const userDoc = await firestore.getDoc(userRef);
if (userDoc.exists()) {
const data = userDoc.data();
return {
id: data.id,
consent: data.consent,
timestamp: ((_a = data.updatedAt) === null || _a === void 0 ? void 0 : _a.toDate()) || new Date(),
language: data.language,
userAgent: data.userAgent,
ipAddress: data.ipAddress,
country: data.country,
city: data.city
};
}
return null;
}
catch (error) {
console.error('Failed to get consent from Firebase:', error);
return null;
}
}
async getConsentStats() {
if (!this.isInitialized || !this.db) {
console.warn('Firebase not initialized, cannot get stats');
return { total: 0, accepted: 0, declined: 0, byLanguage: {} };
}
try {
const consentsRef = firestore.collection(this.db, 'consents');
const querySnapshot = await firestore.getDocs(consentsRef);
const stats = {
total: 0,
accepted: 0,
declined: 0,
byLanguage: {}
};
querySnapshot.forEach((doc) => {
const data = doc.data();
stats.total++;
if (data.consent) {
stats.accepted++;
}
else {
stats.declined++;
}
const lang = data.language || 'unknown';
stats.byLanguage[lang] = (stats.byLanguage[lang] || 0) + 1;
});
return stats;
}
catch (error) {
console.error('Failed to get consent stats from Firebase:', error);
return { total: 0, accepted: 0, declined: 0, byLanguage: {} };
}
}
async getUserLocation() {
try {
// Try to get IP-based location
const response = await fetch('https://ipapi.co/json/');
const data = await response.json();
return {
country: data.country_name,
city: data.city,
ipAddress: data.ip
};
}
catch (error) {
console.warn('Failed to get user location:', error);
return {};
}
}
isReady() {
return this.isInitialized && this.db !== null;
}
getApp() {
return this.app;
}
getDb() {
return this.db;
}
}
// Export singleton instance
const firebaseService = new AcronWebFirebaseService();
function CookieConsent({ language, firebaseConfig, onAccept, onDecline, customContent, privacyUrl = '/privacy', showPoweredBy = true, theme = 'auto', position = 'bottom-left', autoHide = false, autoHideDelay = 5000 }) {
const [isVisible, setIsVisible] = react.useState(false);
const [isLoaded, setIsLoaded] = react.useState(false);
const [isMobile, setIsMobile] = react.useState(false);
const pathname = usePathname();
// Determine language based on prop or pathname
const currentLanguage = language || ((pathname === null || pathname === void 0 ? void 0 : pathname.startsWith('/en')) ? 'en' : 'el');
// Initialize Firebase if config is provided
react.useEffect(() => {
if (firebaseConfig && !firebaseService.isReady()) {
try {
firebaseService.initialize(firebaseConfig);
}
catch (error) {
console.warn('Failed to initialize Firebase:', error);
}
}
}, [firebaseConfig]);
// Check if mobile on mount and resize
react.useEffect(() => {
const checkMobile = () => {
setIsMobile(window.innerWidth < 768);
};
checkMobile();
window.addEventListener('resize', checkMobile);
return () => window.removeEventListener('resize', checkMobile);
}, []);
// Check localStorage on mount and when language changes
react.useEffect(() => {
setIsLoaded(false);
setIsVisible(false);
setTimeout(() => {
setIsLoaded(true);
// Εμφανίζεται μόνο αν ΔΕΝ υπάρχει αποθηκευμένη επιλογή
try {
const consent = cookieManager.getConsent();
if (consent === null) {
setIsVisible(true);
}
else {
setIsVisible(false);
}
}
catch (_a) {
setIsVisible(true);
}
}, 0);
}, [currentLanguage]);
// Auto-hide functionality
react.useEffect(() => {
if (autoHide && isVisible && autoHideDelay > 0) {
const timer = setTimeout(() => {
setIsVisible(false);
}, autoHideDelay);
return () => clearTimeout(timer);
}
}, [autoHide, isVisible, autoHideDelay]);
// Show consent when language changes if user hasn't made a choice yet
react.useEffect(() => {
// Listener for manual open
const openHandler = () => setIsVisible(true);
window.addEventListener('openCookieConsent', openHandler);
return () => window.removeEventListener('openCookieConsent', openHandler);
}, [currentLanguage, isLoaded]);
const handleAccept = async () => {
try {
cookieManager.setConsent(true);
// Save to Firebase if available
if (firebaseService.isReady()) {
const location = await firebaseService.getUserLocation();
const consent = {
id: cookieManager.getUserId(),
consent: true,
timestamp: new Date(),
language: currentLanguage,
userAgent: navigator.userAgent,
...location
};
try {
await firebaseService.saveConsent(consent);
}
catch (error) {
console.warn('Failed to save to Firebase:', error);
}
}
onAccept === null || onAccept === void 0 ? void 0 : onAccept(true);
}
catch (error) {
console.warn('Failed to save consent:', error);
}
setIsVisible(false);
};
const handleDecline = async () => {
try {
cookieManager.setConsent(false);
// Save to Firebase if available
if (firebaseService.isReady()) {
const location = await firebaseService.getUserLocation();
const consent = {
id: cookieManager.getUserId(),
consent: false,
timestamp: new Date(),
language: currentLanguage,
userAgent: navigator.userAgent,
...location
};
try {
await firebaseService.saveConsent(consent);
}
catch (error) {
console.warn('Failed to save to Firebase:', error);
}
}
onDecline === null || onDecline === void 0 ? void 0 : onDecline();
}
catch (error) {
console.warn('Failed to save consent:', error);
}
setIsVisible(false);
};
const defaultContent = {
el: {
title: 'Cookies Consent',
description: 'Αυτός ο ιστότοπος χρησιμοποιεί cookies για να εξασφαλίσει την καλύτερη εμπειρία στον ιστότοπό μας.',
accept: 'Καταλαβαίνω',
learnMore: 'Μάθε περισσότερα',
decline: 'Απόρριψη'
},
en: {
title: 'Cookies Consent',
description: 'This website uses cookies to ensure you get the best experience on our website.',
accept: 'I understand',
learnMore: 'Learn more',
decline: 'Decline'
}
};
const currentContent = {
...defaultContent[currentLanguage],
...customContent === null || customContent === void 0 ? void 0 : customContent[currentLanguage]
};
// Don't render anything until we've checked localStorage
if (!isLoaded) {
return null;
}
// Calculate position styles
const getPositionStyles = () => {
const baseStyles = {
position: 'fixed',
zIndex: 9999,
};
if (isMobile) {
return {
...baseStyles,
top: 0,
left: 0,
right: 0,
bottom: 0,
margin: 0,
width: '100vw',
height: '100vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
background: 'rgba(0,0,0,0.10)',
transform: 'translateY(10%)',
};
}
switch (position) {
case 'bottom-right':
return { ...baseStyles, bottom: '24px', right: '24px', maxWidth: '384px', width: '100%' };
case 'top-left':
return { ...baseStyles, top: '24px', left: '24px', maxWidth: '384px', width: '100%' };
case 'top-right':
return { ...baseStyles, top: '24px', right: '24px', maxWidth: '384px', width: '100%' };
case 'center':
return {
...baseStyles,
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
maxWidth: '384px',
width: '100%'
};
default: // bottom-left
return { ...baseStyles, bottom: '24px', left: '24px', maxWidth: '384px', width: '100%' };
}
};
return (jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isVisible && (jsxRuntime.jsx(framerMotion.motion.div, { initial: { opacity: 0, y: 100, scale: 0.8 }, animate: { opacity: 1, y: 0, scale: 1 }, exit: { opacity: 0, y: 100, scale: 0.8 }, transition: { type: "spring", stiffness: 300, damping: 30 }, className: "fixed z-[9999] pointer-events-auto", style: getPositionStyles(), children: jsxRuntime.jsxs("div", { className: "relative bg-white dark:bg-slate-900 rounded-3xl shadow-2xl p-8 border border-slate-200/80 dark:border-slate-700/80 backdrop-blur-xl", style: isMobile ? { maxWidth: 400, width: '100vw', maxHeight: '100vh', overflowY: 'auto', transform: 'scale(0.93)' } : {}, children: [jsxRuntime.jsx("div", { className: "flex justify-center mb-6", children: jsxRuntime.jsx("div", { className: "w-24 h-24 bg-gradient-to-br from-amber-50 to-amber-100 dark:from-amber-900/30 dark:to-amber-800/30 rounded-full flex items-center justify-center shadow-lg p-2", children: jsxRuntime.jsxs("svg", { viewBox: "0 0 64 64", xmlns: "http://www.w3.org/2000/svg", className: "w-16 h-16", "aria-hidden": "true", role: "img", preserveAspectRatio: "xMidYMid meet", fill: "#000000", children: [jsxRuntime.jsx("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }), jsxRuntime.jsx("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsxs("g", { id: "SVGRepo_iconCarrier", children: [jsxRuntime.jsx("path", { d: "M36.9 22.7l2.5-18.6C37 3.5 34.6 2 32 2c-2.6 0-5 1.5-7.5 2.2c-2.5.6-5.3.5-7.5 1.8s-3.6 3.8-5.4 5.6C9.8 13.4 7.3 14.8 6 17c-1.3 2.2-1.2 5-1.9 7.5C3.5 27 2 29.4 2 32c0 2.6 1.5 5 2.2 7.5c.6 2.5.5 5.3 1.8 7.5s3.8 3.6 5.6 5.4c1.8 1.8 3.1 4.3 5.4 5.6c2.2 1.3 5 1.2 7.5 1.9c2.5.6 4.9 2.1 7.5 2.1c2.6 0 5-1.5 7.5-2.2c2.5-.7 5.3-.6 7.5-1.9c2.2-1.3 3.6-3.8 5.4-5.6c1.8-1.8 4.3-3.1 5.6-5.4c1.3-2.2 1.2-5 1.9-7.5c.6-2.4 2.1-4.8 2.1-7.4c0-2.6-2.1-8.1-2.1-8.1l-23-1.2", fill: "#dda85f", children: " " }), jsxRuntime.jsx("path", { d: "M59.4 22.4c-1 .3-2.4.2-3.9-.4c-2.1-.8-3.4-2.5-3.8-4.5c-1 .3-3.4 0-5-1c-2.4-1.5-2.9-5.7-2.9-5.7c-2.7-.8-4.7-4-4.4-6.7c-2.2-.6-5-.5-7.4-.5c-2.4 0-4.6 1.4-6.8 2c-2.3.6-4.9.5-6.9 1.7s-3.3 3.5-4.9 5.1c-1.7 1.7-4 2.9-5.1 4.9c-1.2 2-1.1 4.6-1.7 6.9c-.6 2.2-2 4.4-2 6.8c0 2.4 1.4 4.6 2 6.8c.6 2.3.5 4.9 1.7 6.9s3.5 3.3 5.1 4.9c1.7 1.7 2.9 4 4.9 5.1c2 1.2 4.6 1.1 6.9 1.7c2.2.6 4.4 2 6.8 2c2.4 0 4.6-1.4 6.8-2c2.3-.6 4.9-.5 6.9-1.7s3.3-3.5 4.9-5.1c1.7-1.7 4-2.9 5.1-4.9c1.2-2 1.1-4.6 1.7-6.9c.6-2.2 3-4 3.3-6.4c.8-3.9-1.2-8.3-1.3-9", fill: "#f2cb7d", children: " " }), jsxRuntime.jsxs("g", { fill: "#dda85f", children: [jsxRuntime.jsx("path", { d: "M50.1 10.8l-1.4 1.4l-1.3-1.4l1.3-1.3z", children: " " }), jsxRuntime.jsx("path", { d: "M55.8 17.8l-.6.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M50.8 13.2l-.7.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M44.6 7.1l-.7.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M57.2 20.3l-.7.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M57.8 17.8l-.7.7l-.7-.7l.7-.7z", children: " " })] }), jsxRuntime.jsx("path", { d: "M11.8 20.6c-1 1.7.5 4.8 2.5 5.7c2.9 1.2 4.6 1.4 6.4-1.7c.6-1.1 1.4-4 1.1-4.7c-.4-1-2.1-3-3.2-3c-3.1.1-6.1 2.5-6.8 3.7", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M12.3 20.6c-.7 1.2 1.1 4.8 3.5 4.5c3.3-.4 3-7.2 1.6-7.2c-2.4 0-4.6 1.8-5.1 2.7", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { d: "M45.2 39.1c1.4-.4 2.4-2.9 1.8-4.4c-.9-2.3-1.8-3.3-4.4-2.6c-.9.3-3 1.4-3.2 1.9c-.3.8-.5 2.8.1 3.4c1.7 1.7 4.7 2 5.7 1.7", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M43.8 36.7c1.1-.3 2.8-3.7 1-3.9c-3.1-.5-5.5 1-5.2 2.7c.3 1.7 3.4 1.4 4.2 1.2", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { d: "M24.9 44.5c-.3-1.2-2.5-2.1-3.9-1.5c-2 .8-2.9 1.5-2.2 3.8c.2.8 1.2 2.6 1.7 2.7c.7.3 2.4.4 2.9-.1c1.5-1.4 1.7-4 1.5-4.9", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M23.2 43.6c-.2-.9-4.4.4-4 2c.8 2.7.8 3.1 1.6 3c1.5-.4 2.5-4.3 2.4-5", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { d: "M51.1 25.5c-1.2.3-2.1 2.5-1.5 3.9c.8 2 2.7 2.3 4.8 1.2c1.8-.9 1.9-4.1 1.4-4.7c-1.5-1.5-3.8-.6-4.7-.4", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M50.6 26.6c-.6.7-1.1 3.5.4 3.1c2.7-.8 4.6-3.5 3.4-3.9c-1.5-.5-3.1 0-3.8.8", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { fill: "#6d4934", d: "M22.74 16.112l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsxs("g", { fill: "#dda85f", children: [jsxRuntime.jsx("path", { d: "M14.706 33.483l1.979-1.98l1.98 1.979l-1.979 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M34.698 44.811l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M32.038 39.289l2.687-2.687l2.687 2.687l-2.687 2.687z", children: " " }), jsxRuntime.jsx("path", { d: "M24.696 9.827l2.687-2.687l2.687 2.687l-2.687 2.687z", children: " " })] }), jsxRuntime.jsxs("g", { fill: "#6d4934", children: [jsxRuntime.jsx("path", { d: "M41.122 46.347l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M49.076 35.215l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M41.812 24.637l.99-.99l.99.99l-.99.99z", children: " " }), jsxRuntime.jsx("path", { d: "M13.726 38.266l.99-.99l.99.99l-.99.99z", children: " " })] })] })] }) }) }), jsxRuntime.jsxs("div", { className: "text-center", children: [jsxRuntime.jsx("h3", { className: "text-2xl font-bold text-gray-900 dark:text-slate-100 mb-4", children: currentContent.title }), jsxRuntime.jsx("p", { className: "text-gray-600 dark:text-slate-300 text-sm leading-relaxed mb-8", children: currentContent.description }), jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 mb-6", children: [jsxRuntime.jsxs("button", { onClick: handleAccept, className: "group relative w-full px-8 py-4 bg-gradient-to-r from-blue-500 via-blue-600 to-blue-700 hover:from-blue-600 hover:via-blue-700 hover:to-blue-800 text-white font-bold rounded-3xl transition-all duration-500 transform hover:scale-[1.03] shadow-xl hover:shadow-2xl border-0 overflow-hidden", children: [jsxRuntime.jsx("div", { className: "absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-1000" }), jsxRuntime.jsxs("span", { className: "relative z-10 flex items-center justify-center gap-2", children: [jsxRuntime.jsx("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M5 13l4 4L19 7" }) }), currentContent.accept] })] }), jsxRuntime.jsxs("button", { onClick: handleDecline, className: "group relative w-full px-8 py-4 bg-white dark:bg-slate-800 border-2 border-gray-200 dark:border-slate-600 text-gray-700 dark:text-slate-300 hover:bg-gray-50 dark:hover:bg-slate-700 hover:border-gray-300 dark:hover:border-slate-500 font-semibold rounded-3xl transition-all duration-300 transform hover:scale-[1.02] shadow-lg hover:shadow-xl", children: [jsxRuntime.jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-transparent via-gray-50/50 dark:via-slate-700/50 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 rounded-3xl" }), jsxRuntime.jsxs("span", { className: "relative z-10 flex items-center justify-center gap-2", children: [jsxRuntime.jsx("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M6 18L18 6M6 6l12 12" }) }), currentContent.decline] })] })] }), jsxRuntime.jsx("div", { className: "pt-4 border-t border-gray-200 dark:border-slate-700", children: jsxRuntime.jsxs("a", { href: privacyUrl, className: "inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 text-sm font-medium transition-colors", children: [currentContent.learnMore, jsxRuntime.jsx(lucideReact.ExternalLink, { className: "w-4 h-4" })] }) }), showPoweredBy && (jsxRuntime.jsx("div", { className: "mt-6 pt-4 border-t border-gray-100 dark:border-slate-800", children: jsxRuntime.jsx("div", { className: "flex items-center justify-center gap-2 group cursor-pointer transition-all duration-300", children: jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5", children: [jsxRuntime.jsx("span", { className: "text-xs font-bold text-gray-600 dark:text-gray-400 group-hover:text-amber-600 dark:group-hover:text-amber-400 transition-colors duration-300", children: "Powered by" }), jsxRuntime.jsx("div", { className: "relative flex items-center", children: jsxRuntime.jsxs("svg", { viewBox: "0 0 64 64", xmlns: "http://www.w3.org/2000/svg", className: "w-6 h-6 transition-all duration-300 group-hover:scale-110", "aria-hidden": "true", role: "img", preserveAspectRatio: "xMidYMid meet", fill: "#000000", children: [jsxRuntime.jsx("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }), jsxRuntime.jsx("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsxs("g", { id: "SVGRepo_iconCarrier", children: [jsxRuntime.jsx("path", { d: "M36.9 22.7l2.5-18.6C37 3.5 34.6 2 32 2c-2.6 0-5 1.5-7.5 2.2c-2.5.6-5.3.5-7.5 1.8s-3.6 3.8-5.4 5.6C9.8 13.4 7.3 14.8 6 17c-1.3 2.2-1.2 5-1.9 7.5C3.5 27 2 29.4 2 32c0 2.6 1.5 5 2.2 7.5c.6 2.5.5 5.3 1.8 7.5s3.8 3.6 5.6 5.4c1.8 1.8 3.1 4.3 5.4 5.6c2.2 1.3 5 1.2 7.5 1.9c2.5.6 4.9 2.1 7.5 2.1c2.6 0 5-1.5 7.5-2.2c2.5-.7 5.3-.6 7.5-1.9c2.2-1.3 3.6-3.8 5.4-5.6c1.8-1.8 4.3-3.1 5.6-5.4c1.3-2.2 1.2-5 1.9-7.5c.6-2.4 2.1-4.8 2.1-7.4c0-2.6-2.1-8.1-2.1-8.1l-23-1.2", fill: "#dda85f", children: " " }), jsxRuntime.jsx("path", { d: "M59.4 22.4c-1 .3-2.4.2-3.9-.4c-2.1-.8-3.4-2.5-3.8-4.5c-1 .3-3.4 0-5-1c-2.4-1.5-2.9-5.7-2.9-5.7c-2.7-.8-4.7-4-4.4-6.7c-2.2-.6-5-.5-7.4-.5c-2.4 0-4.6 1.4-6.8 2c-2.3.6-4.9.5-6.9 1.7s-3.3 3.5-4.9 5.1c-1.7 1.7-4 2.9-5.1 4.9c-1.2 2-1.1 4.6-1.7 6.9c-.6 2.2-2 4.4-2 6.8c0 2.4 1.4 4.6 2 6.8c.6 2.3.5 4.9 1.7 6.9s3.5 3.3 5.1 4.9c1.7 1.7 2.9 4 4.9 5.1c2 1.2 4.6 1.1 6.9 1.7c2.2.6 4.4 2 6.8 2c2.4 0 4.6-1.4 6.8-2c2.3-.6 4.9-.5 6.9-1.7s3.3-3.5 4.9-5.1c1.7-1.7 4-2.9 5.1-4.9c1.2-2 1.1-4.6 1.7-6.9c.6-2.2 3-4 3.3-6.4c.8-3.9-1.2-8.3-1.3-9", fill: "#f2cb7d", children: " " }), jsxRuntime.jsxs("g", { fill: "#dda85f", children: [jsxRuntime.jsx("path", { d: "M50.1 10.8l-1.4 1.4l-1.3-1.4l1.3-1.3z", children: " " }), jsxRuntime.jsx("path", { d: "M55.8 17.8l-.6.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M50.8 13.2l-.7.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M44.6 7.1l-.7.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M57.2 20.3l-.7.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M57.8 17.8l-.7.7l-.7-.7l.7-.7z", children: " " })] }), jsxRuntime.jsx("path", { d: "M11.8 20.6c-1 1.7.5 4.8 2.5 5.7c2.9 1.2 4.6 1.4 6.4-1.7c.6-1.1 1.4-4 1.1-4.7c-.4-1-2.1-3-3.2-3c-3.1.1-6.1 2.5-6.8 3.7", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M12.3 20.6c-.7 1.2 1.1 4.8 3.5 4.5c3.3-.4 3-7.2 1.6-7.2c-2.4 0-4.6 1.8-5.1 2.7", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { d: "M45.2 39.1c1.4-.4 2.4-2.9 1.8-4.4c-.9-2.3-1.8-3.3-4.4-2.6c-.9.3-3 1.4-3.2 1.9c-.3.8-.5 2.8.1 3.4c1.7 1.7 4.7 2 5.7 1.7", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M43.8 36.7c1.1-.3 2.8-3.7 1-3.9c-3.1-.5-5.5 1-5.2 2.7c.3 1.7 3.4 1.4 4.2 1.2", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { d: "M24.9 44.5c-.3-1.2-2.5-2.1-3.9-1.5c-2 .8-2.9 1.5-2.2 3.8c.2.8 1.2 2.6 1.7 2.7c.7.3 2.4.4 2.9-.1c1.5-1.4 1.7-4 1.5-4.9", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M23.2 43.6c-.2-.9-4.4.4-4 2c.8 2.7.8 3.1 1.6 3c1.5-.4 2.5-4.3 2.4-5", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { d: "M51.1 25.5c-1.2.3-2.1 2.5-1.5 3.9c.8 2 2.7 2.3 4.8 1.2c1.8-.9 1.9-4.1 1.4-4.7c-1.5-1.5-3.8-.6-4.7-.4", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M50.6 26.6c-.6.7-1.1 3.5.4 3.1c2.7-.8 4.6-3.5 3.4-3.9c-1.5-.5-3.1 0-3.8.8", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { fill: "#6d4934", d: "M22.74 16.112l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsxs("g", { fill: "#dda85f", children: [jsxRuntime.jsx("path", { d: "M14.706 33.483l1.979-1.98l1.98 1.979l-1.979 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M34.698 44.811l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M32.038 39.289l2.687-2.687l2.687 2.687l-2.687 2.687z", children: " " }), jsxRuntime.jsx("path", { d: "M24.696 9.827l2.687-2.687l2.687 2.687l-2.687 2.687z", children: " " })] }), jsxRuntime.jsxs("g", { fill: "#6d4934", children: [jsxRuntime.jsx("path", { d: "M41.122 46.347l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M49.076 35.215l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M41.812 24.637l.99-.99l.99.99l-.99.99z", children: " " }), jsxRuntime.jsx("path", { d: "M13.726 38.266l.99-.99l.99.99l-.99.99z", children: " " })] })] })] }) }), jsxRuntime.jsxs("div", { className: "flex items-baseline gap-0.5", children: [jsxRuntime.jsx("span", { className: "text-xs font-bold bg-gradient-to-r from-amber-800 via-amber-700 to-amber-900 dark:from-amber-300 dark:via-amber-200 dark:to-amber-400 bg-clip-text text-transparent group-hover:from-amber-900 group-hover:via-amber-800 group-hover:to-amber-950 dark:group-hover:from-amber-200 dark:group-hover:via-amber-100 dark:group-hover:to-amber-300 transition-all duration-300", style: {
fontFamily: "'Inter', 'SF Pro Display', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif",
fontWeight: 800,
letterSpacing: "-0.02em",
lineHeight: 1.1,
verticalAlign: 'baseline'
}, children: "ACRON" }), jsxRuntime.jsx("span", { className: "text-xs font-bold text-gray-700 dark:text-gray-300 group-hover:text-gray-900 dark:group-hover:text-white transition-colors duration-300 gegola-font", children: "WEB" })] }), jsxRuntime.jsx("span", { className: "text-xs font-bold text-gray-600 dark:text-gray-400 group-hover:text-amber-600 dark:group-hover:text-amber-400 transition-colors duration-300 gegola-font", children: "Cookies" })] }) }) }))] })] }) }, currentLanguage)) }, currentLanguage));
}
function CookieSettingsButton({ language }) {
const pathname = usePathname();
const currentLanguage = language || ((pathname === null || pathname === void 0 ? void 0 : pathname.startsWith('/en')) ? 'en' : 'el');
const content = {
el: {
buttonText: 'Ρυθμίσεις Cookies',
},
en: {
buttonText: 'Cookie Settings',
}
};
const currentContent = content[currentLanguage];
return (jsxRuntime.jsxs("button", { onClick: () => window.dispatchEvent(new Event('openCookieConsent')), className: "group relative flex items-center justify-center px-3 py-1 border border-amber-500 dark:border-amber-400 text-amber-700 dark:text-amber-300 bg-transparent font-medium rounded-lg transition-all duration-200 hover:border-amber-600 hover:text-amber-800 dark:hover:border-amber-300 dark:hover:text-amber-100 text-xs shadow-none min-w-[120px]", style: { minHeight: 0 }, children: [jsxRuntime.jsx("svg", { viewBox: "0 0 64 64", xmlns: "http://www.w3.org/2000/svg", className: "w-4 h-4 inline-block align-middle flex-shrink-0 mr-1", "aria-hidden": "true", role: "img", preserveAspectRatio: "xMidYMid meet", fill: "currentColor", children: jsxRuntime.jsxs("g", { id: "SVGRepo_iconCarrier", children: [jsxRuntime.jsx("path", { d: "M36.9 22.7l2.5-18.6C37 3.5 34.6 2 32 2c-2.6 0-5 1.5-7.5 2.2c-2.5.6-5.3.5-7.5 1.8s-3.6 3.8-5.4 5.6C9.8 13.4 7.3 14.8 6 17c-1.3 2.2-1.2 5-1.9 7.5C3.5 27 2 29.4 2 32c0 2.6 1.5 5 2.2 7.5c.6 2.5.5 5.3 1.8 7.5s3.8 3.6 5.6 5.4c1.8 1.8 3.1 4.3 5.4 5.6c2.2 1.3 5 1.2 7.5 1.9c2.5.6 4.9 2.1 7.5 2.1c2.6 0 5-1.5 7.5-2.2c2.5-.7 5.3-.6 7.5-1.9c2.2-1.3 3.6-3.8 5.4-5.6c1.8-1.8 4.3-3.1 5.6-5.4c1.3-2.2 1.2-5 1.9-7.5c.6-2.4 2.1-4.8 2.1-7.4c0-2.6-2.1-8.1-2.1-8.1l-23-1.2", fill: "#dda85f", children: " " }), jsxRuntime.jsx("path", { d: "M59.4 22.4c-1 .3-2.4.2-3.9-.4c-2.1-.8-3.4-2.5-3.8-4.5c-1 .3-3.4 0-5-1c-2.4-1.5-2.9-5.7-2.9-5.7c-2.7-.8-4.7-4-4.4-6.7c-2.2-.6-5-.5-7.4-.5c-2.4 0-4.6 1.4-6.8 2c-2.3.6-4.9.5-6.9 1.7s-3.3 3.5-4.9 5.1c-1.7 1.7-4 2.9-5.1 4.9c-1.2 2-1.1 4.6-1.7 6.9c-.6 2.2-2 4.4-2 6.8c0 2.4 1.4 4.6 2 6.8c.6 2.3.5 4.9 1.7 6.9s3.5 3.3 5.1 4.9c1.7 1.7 2.9 4 4.9 5.1c2 1.2 4.6 1.1 6.9 1.7c2.2.6 4.4 2 6.8 2c2.4 0 4.6-1.4 6.8-2c2.3-.6 4.9-.5 6.9-1.7s3.3-3.5 4.9-5.1c1.7-1.7 4-2.9 5.1-4.9c1.2-2 1.1-4.6 1.7-6.9c.6-2.2 3-4 3.3-6.4c.8-3.9-1.2-8.3-1.3-9", fill: "#f2cb7d", children: " " }), jsxRuntime.jsxs("g", { fill: "#dda85f", children: [jsxRuntime.jsx("path", { d: "M50.1 10.8l-1.4 1.4l-1.3-1.4l1.3-1.3z", children: " " }), jsxRuntime.jsx("path", { d: "M55.8 17.8l-.6.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M50.8 13.2l-.7.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M44.6 7.1l-.7.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M57.2 20.3l-.7.7l-.7-.7l.7-.7z", children: " " }), jsxRuntime.jsx("path", { d: "M57.8 17.8l-.7.7l-.7-.7l.7-.7z", children: " " })] }), jsxRuntime.jsx("path", { d: "M11.8 20.6c-1 1.7.5 4.8 2.5 5.7c2.9 1.2 4.6 1.4 6.4-1.7c.6-1.1 1.4-4 1.1-4.7c-.4-1-2.1-3-3.2-3c-3.1.1-6.1 2.5-6.8 3.7", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M12.3 20.6c-.7 1.2 1.1 4.8 3.5 4.5c3.3-.4 3-7.2 1.6-7.2c-2.4 0-4.6 1.8-5.1 2.7", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { d: "M45.2 39.1c1.4-.4 2.4-2.9 1.8-4.4c-.9-2.3-1.8-3.3-4.4-2.6c-.9.3-3 1.4-3.2 1.9c-.3.8-.5 2.8.1 3.4c1.7 1.7 4.7 2 5.7 1.7", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M43.8 36.7c1.1-.3 2.8-3.7 1-3.9c-3.1-.5-5.5 1-5.2 2.7c.3 1.7 3.4 1.4 4.2 1.2", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { d: "M24.9 44.5c-.3-1.2-2.5-2.1-3.9-1.5c-2 .8-2.9 1.5-2.2 3.8c.2.8 1.2 2.6 1.7 2.7c.7.3 2.4.4 2.9-.1c1.5-1.4 1.7-4 1.5-4.9", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M23.2 43.6c-.2-.9-4.4.4-4 2c.8 2.7.8 3.1 1.6 3c1.5-.4 2.5-4.3 2.4-5", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { d: "M51.1 25.5c-1.2.3-2.1 2.5-1.5 3.9c.8 2 2.7 2.3 4.8 1.2c1.8-.9 1.9-4.1 1.4-4.7c-1.5-1.5-3.8-.6-4.7-.4", fill: "#6d4934", children: " " }), jsxRuntime.jsx("path", { d: "M50.6 26.6c-.6.7-1.1 3.5.4 3.1c2.7-.8 4.6-3.5 3.4-3.9c-1.5-.5-3.1 0-3.8.8", fill: "#a37f6a", children: " " }), jsxRuntime.jsx("path", { fill: "#6d4934", d: "M22.74 16.112l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsxs("g", { fill: "#dda85f", children: [jsxRuntime.jsx("path", { d: "M14.706 33.483l1.979-1.98l1.98 1.979l-1.979 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M34.698 44.811l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M32.038 39.289l2.687-2.687l2.687 2.687l-2.687 2.687z", children: " " }), jsxRuntime.jsx("path", { d: "M24.696 9.827l2.687-2.687l2.687 2.687l-2.687 2.687z", children: " " })] }), jsxRuntime.jsxs("g", { fill: "#6d4934", children: [jsxRuntime.jsx("path", { d: "M41.122 46.347l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M49.076 35.215l1.98-1.98l1.98 1.98l-1.98 1.98z", children: " " }), jsxRuntime.jsx("path", { d: "M41.812 24.637l.99-.99l.99.99l-.99.99z", children: " " }), jsxRuntime.jsx("path", { d: "M13.726 38.266l.99-.99l.99.99l-.99.99z", children: " " })] })] }) }), jsxRuntime.jsx("span", { className: "text-xs font-semibold whitespace-nowrap", children: currentContent.buttonText })] }));
}
// Main component
// Utility functions
const openCookieConsent = () => {
if (typeof window !== 'undefined') {
window.dispatchEvent(new CustomEvent('openCookieConsent'));
}
};
const clearCookieConsent = () => {
if (typeof window !== 'undefined') {
const { cookieManager } = require('./utils/cookieManager');
cookieManager.clearConsent();
}
};
const getCookieConsent = () => {
if (typeof window !== 'undefined') {
const { cookieManager } = require('./utils/cookieManager');
return cookieManager.getConsent();
}
return null;
};
const setCookieConsent = (consent, settings) => {
if (typeof window !== 'undefined') {
const { cookieManager } = require('./utils/cookieManager');
cookieManager.setConsent(consent, settings);
}
};
// Default export
var index = {
CookieConsent: typeof window !== 'undefined' ? require('./components/CookieConsent').CookieConsent : null,
CookieSettingsButton: typeof window !== 'undefined' ? require('./components/CookieSettingsButton').CookieSettingsButton : null,
cookieManager: typeof window !== 'undefined' ? require('./utils/cookieManager').cookieManager : null,
firebaseService: typeof window !== 'undefined' ? require('./services/firebaseService').firebaseService : null,
openCookieConsent,
clearCookieConsent,
getCookieConsent,
setCookieConsent
};
exports.AcronWebCookieManager = AcronWebCookieManager;
exports.AcronWebFirebaseService = AcronWebFirebaseService;
exports.CookieConsent = CookieConsent;
exports.CookieSettingsButton = CookieSettingsButton;
exports.clearCookieConsent = clearCookieConsent;
exports.cookieManager = cookieManager;
exports.default = index;
exports.firebaseService = firebaseService;
exports.getCookieConsent = getCookieConsent;
exports.openCookieConsent = openCookieConsent;
exports.setCookieConsent = setCookieConsent;
//# sourceMappingURL=index.js.map