export type CookieConsentCategoryId = | 'necessary' | 'analytics' | 'marketing' | 'preferences' | string; export interface CookieConsentCategory { id?: CookieConsentCategoryId; title?: string; description?: string; details?: string; required?: boolean; defaultValue?: boolean; } export interface CookieConsentScript { id?: string; category: CookieConsentCategoryId; src?: string; selector?: string; async?: boolean; defer?: boolean; attributes?: Record; callback?: () => void; factory?: () => void | Promise; } export interface CookieConsentEmbed { id?: string; provider: 'youtube' | 'vimeo'; category?: CookieConsentCategoryId; src: string; target?: string; title?: string; description?: string; thumbnail?: string; allow?: string; width?: string | number; height?: string | number; iframeAttributes?: Record; } export interface CookieConsentState { categories: Record; createdAt: string; updatedAt: string; policyVersion: string; language: string; } export type CookieConsentLanguage = | 'browser' | 'auto' | 'en' | 'en-gb' | 'en-GB' | 'en_gb' | 'en-uk' | 'en-UK' | 'de' | 'fr' | 'es' | 'ca-es' | 'ca_es' | 'it' | 'sv' | 'no' | 'nl' | 'pt' | 'fi' | 'hu' | 'cs' | 'hr' | 'da' | 'sk' | 'sl' | 'pl' | 'el' | 'he' | 'mk' | 'uk' | 'ro' | 'sr' | 'et' | 'lt' | 'lv' | 'ru' | 'bg' | 'cy' | 'ja' | 'ar' | 'tr' | string; export type CookieConsentMode = 'gdpr' | 'eprivacy'; export interface CookieConsentConfig { autoShow?: boolean; mode?: CookieConsentMode; policyVersion?: string; providedBy?: string; language?: CookieConsentLanguage; defaultLanguage?: CookieConsentLanguage; fallbackLanguage?: CookieConsentLanguage; layout?: 'bottom' | 'top' | 'floating' | 'center'; logo?: string | (() => HTMLElement); policyLinks?: Array<{ label: string; href: string; target?: string; rel?: string; }>; components?: { logo?: boolean; title?: boolean; description?: boolean; policyLinks?: boolean; footer?: boolean; buttons?: { acceptAll?: boolean; rejectAll?: boolean; customize?: boolean; save?: boolean; }; }; categories?: Record; scripts?: CookieConsentScript[]; embeds?: { enabled?: boolean; category?: CookieConsentCategoryId; autoScan?: boolean; items?: CookieConsentEmbed[]; providers?: { youtube?: { enabled?: boolean; privacyMode?: boolean; }; vimeo?: { enabled?: boolean; dnt?: boolean; }; }; placeholder?: { title?: string; description?: string; buttonText?: string; }; }; storage?: { type?: 'cookie' | 'localStorage'; cookieName?: string; expiresDays?: number; sameSite?: 'Lax' | 'Strict' | 'None'; secure?: boolean; domain?: string; path?: string; }; style?: { className?: string; }; floatingButton?: { enabled?: boolean; showAfterConsent?: boolean; text?: string; }; content?: Record; translations?: Record; integrations?: { googleConsentMode?: boolean; }; callbacks?: Record void>; } export interface CookieConsentInstance { getConsent(): CookieConsentState | null; hasConsent(category: CookieConsentCategoryId): boolean; setConsent(consentState: Pick): CookieConsentState; acceptCategory(category: CookieConsentCategoryId): CookieConsentState; resetConsent(): void; openBanner(): void; openPreferences(): void; close(): void; on(eventName: string, handler: (payload: unknown) => void): () => void; off(eventName: string, handler: (payload: unknown) => void): void; registerScript(scriptDefinition: CookieConsentScript): void; loadCategory(category: CookieConsentCategoryId): void; registerEmbed(embedDefinition: CookieConsentEmbed): CookieConsentEmbed | null; loadEmbed(id: string): void; loadEmbedsByCategory(category: CookieConsentCategoryId): void; getEventLog(): Array<{ eventName: string; payload: unknown; timestamp: string }>; } export interface CookieConsentApi { init( config?: CookieConsentConfig | (() => CookieConsentConfig | Promise) ): Promise; getInstance(): CookieConsentInstance | null; getConsent(): CookieConsentState | null; hasConsent(category: CookieConsentCategoryId): boolean; setConsent(consentState: Pick): CookieConsentState; acceptCategory(category: CookieConsentCategoryId): CookieConsentState; resetConsent(): void; openBanner(): void; openPreferences(): void; close(): void; on(eventName: string, handler: (payload: unknown) => void): () => void; off(eventName: string, handler: (payload: unknown) => void): void; registerScript(scriptDefinition: CookieConsentScript): void; loadCategory(category: CookieConsentCategoryId): void; registerEmbed(embedDefinition: CookieConsentEmbed): CookieConsentEmbed | null; loadEmbed(id: string): void; loadEmbedsByCategory(category: CookieConsentCategoryId): void; } export const CookieConsent: CookieConsentApi; export default CookieConsent;