@cookieyes/core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +134 -24
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -90,6 +90,11 @@ declare function _clearStopHandlers(): void;
|
|
|
90
90
|
*/
|
|
91
91
|
type ConsentCategory = "necessary" | "functional" | "analytics" | "performance" | "advertisement" | (string & {});
|
|
92
92
|
type Regulation = "GDPR" | "CCPA" | "DEFAULT";
|
|
93
|
+
/** Display text for one consent category. */
|
|
94
|
+
type CategoryText = {
|
|
95
|
+
label: string;
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
93
98
|
type TranslationMap = {
|
|
94
99
|
bannerTitle: string;
|
|
95
100
|
bannerDescription: string;
|
|
@@ -104,27 +109,12 @@ type TranslationMap = {
|
|
|
104
109
|
preferencesTitle: string;
|
|
105
110
|
preferencesIntro: string;
|
|
106
111
|
categories: {
|
|
107
|
-
necessary:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
description: string;
|
|
114
|
-
};
|
|
115
|
-
analytics: {
|
|
116
|
-
label: string;
|
|
117
|
-
description: string;
|
|
118
|
-
};
|
|
119
|
-
performance: {
|
|
120
|
-
label: string;
|
|
121
|
-
description: string;
|
|
122
|
-
};
|
|
123
|
-
advertisement: {
|
|
124
|
-
label: string;
|
|
125
|
-
description: string;
|
|
126
|
-
};
|
|
127
|
-
};
|
|
112
|
+
necessary: CategoryText;
|
|
113
|
+
functional: CategoryText;
|
|
114
|
+
analytics: CategoryText;
|
|
115
|
+
performance: CategoryText;
|
|
116
|
+
advertisement: CategoryText;
|
|
117
|
+
} & Record<string, CategoryText>;
|
|
128
118
|
optOut: {
|
|
129
119
|
title: string;
|
|
130
120
|
description: string;
|
|
@@ -138,6 +128,19 @@ type TranslationMap = {
|
|
|
138
128
|
dismissButton: string;
|
|
139
129
|
};
|
|
140
130
|
};
|
|
131
|
+
/** A subset of TranslationMap — lets a customer override just a few strings. */
|
|
132
|
+
type DeepPartial<T> = T extends object ? {
|
|
133
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
134
|
+
} : T;
|
|
135
|
+
type PartialTranslations = DeepPartial<TranslationMap>;
|
|
136
|
+
/** Reading direction of a language. */
|
|
137
|
+
type TextDirection = "ltr" | "rtl";
|
|
138
|
+
/** The active language, its reading direction, and the languages currently loaded. */
|
|
139
|
+
type LanguageInfo = {
|
|
140
|
+
language: string;
|
|
141
|
+
direction: TextDirection;
|
|
142
|
+
languages: string[];
|
|
143
|
+
};
|
|
141
144
|
type ThemeConfig = {
|
|
142
145
|
primaryColor?: string | undefined;
|
|
143
146
|
backgroundColor?: string | undefined;
|
|
@@ -157,9 +160,16 @@ type ScriptEntry = {
|
|
|
157
160
|
onLoad?: (() => void) | undefined;
|
|
158
161
|
};
|
|
159
162
|
type I18nConfig = {
|
|
160
|
-
|
|
163
|
+
/** Translations per language. Each may be partial — missing text falls back to English. */
|
|
164
|
+
messages?: Record<string, PartialTranslations> | undefined;
|
|
161
165
|
locale?: string | undefined;
|
|
162
166
|
detectBrowserLanguage?: boolean | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* Called when a language is switched to that isn't already in `messages` —
|
|
169
|
+
* return its translations (fetch them from your own URL, import them, etc.).
|
|
170
|
+
* Lets you load languages on demand instead of bundling them all upfront.
|
|
171
|
+
*/
|
|
172
|
+
loadLanguage?: ((tag: string) => PartialTranslations | Promise<PartialTranslations>) | undefined;
|
|
163
173
|
};
|
|
164
174
|
type ConsentConfig = {
|
|
165
175
|
apiUrl?: string | undefined;
|
|
@@ -369,6 +379,24 @@ type ConsentChangePayload = {
|
|
|
369
379
|
allowedCategories: ConsentCategory[];
|
|
370
380
|
deniedCategories: ConsentCategory[];
|
|
371
381
|
};
|
|
382
|
+
/** Which consent event to listen for. See {@link ConsentStore.on}. */
|
|
383
|
+
type ConsentEventType = "save" | "change";
|
|
384
|
+
type ConsentEventPayload = {
|
|
385
|
+
/** The full committed consent map in effect when the event fired. */
|
|
386
|
+
categories: Record<string, boolean>;
|
|
387
|
+
/** Categories whose value differed from before. Empty on the initial replay. */
|
|
388
|
+
changedCategories: ConsentCategory[];
|
|
389
|
+
/**
|
|
390
|
+
* `true` when this is the one-off replay a listener gets on attach (here's
|
|
391
|
+
* the current state), `false` when the visitor actually just acted.
|
|
392
|
+
*/
|
|
393
|
+
isInitial: boolean;
|
|
394
|
+
};
|
|
395
|
+
type ConsentEventListener = (payload: ConsentEventPayload) => void;
|
|
396
|
+
/** Restrict a listener to a single category (fires only when it changes). */
|
|
397
|
+
type ConsentEventOptions = {
|
|
398
|
+
category?: ConsentCategory;
|
|
399
|
+
};
|
|
372
400
|
type ActiveUI = "banner" | "dialog" | null;
|
|
373
401
|
type ConsentStoreState = ConsentSnapshot & {
|
|
374
402
|
activeUI: ActiveUI;
|
|
@@ -395,6 +423,32 @@ type ConsentStoreState = ConsentSnapshot & {
|
|
|
395
423
|
type ConsentStore = {
|
|
396
424
|
subscribe: (listener: (state: ConsentStoreState) => void) => () => void;
|
|
397
425
|
getState: () => ConsentStoreState;
|
|
426
|
+
/** Text for the active language (English fills gaps). Swaps on `setLanguage`. */
|
|
427
|
+
translations: TranslationMap;
|
|
428
|
+
/** The active language, its reading direction, and the languages loaded. */
|
|
429
|
+
getLanguageInfo: () => LanguageInfo;
|
|
430
|
+
/**
|
|
431
|
+
* Switch language live (no reload) — `subscribe` listeners fire so a custom UI
|
|
432
|
+
* can re-render. Loads the language via `i18n.loadLanguage` if not bundled.
|
|
433
|
+
*/
|
|
434
|
+
setLanguage: (tag: string) => Promise<void>;
|
|
435
|
+
/** Customer-provided text for a category in the active language, if any. */
|
|
436
|
+
getCategoryText: (id: string) => Partial<CategoryText> | undefined;
|
|
437
|
+
/**
|
|
438
|
+
* The category taxonomy in effect (custom list or the built-in five) — its
|
|
439
|
+
* ids, which are `required`, etc. Use it to render categories in a custom UI
|
|
440
|
+
* so it follows whatever taxonomy is configured.
|
|
441
|
+
*/
|
|
442
|
+
categories: ResolvedCategories;
|
|
443
|
+
/**
|
|
444
|
+
* React to consent decisions. `"save"` fires on every save (even an
|
|
445
|
+
* unchanged re-confirm); `"change"` fires only when a category actually
|
|
446
|
+
* differs — use it to (re)load a script without re-running on a re-confirm.
|
|
447
|
+
* The listener fires once immediately with the current state
|
|
448
|
+
* (`isInitial: true`). Pass `{ category }` to only hear about one category.
|
|
449
|
+
* Returns an unsubscribe function.
|
|
450
|
+
*/
|
|
451
|
+
on: (type: ConsentEventType, listener: ConsentEventListener, options?: ConsentEventOptions) => () => void;
|
|
398
452
|
};
|
|
399
453
|
type ConsentRuntime = {
|
|
400
454
|
consentManager: ConsentManager;
|
|
@@ -517,6 +571,26 @@ declare function _warnOfflineModeDeprecated(): void;
|
|
|
517
571
|
/** @internal test-only — resets the one-time warning guard between test cases. */
|
|
518
572
|
declare function _resetOfflineModeWarning(): void;
|
|
519
573
|
|
|
574
|
+
type ConsentEmitter = {
|
|
575
|
+
/**
|
|
576
|
+
* Listen for consent events. `"save"` fires on every saved decision (even an
|
|
577
|
+
* unchanged re-confirm); `"change"` fires only when a category actually
|
|
578
|
+
* differs. The listener fires once immediately with the current state
|
|
579
|
+
* (`isInitial: true`) so a late listener isn't blind to earlier choices.
|
|
580
|
+
* Pass `{ category }` to only be called when that one category changes.
|
|
581
|
+
* Returns an unsubscribe function.
|
|
582
|
+
*/
|
|
583
|
+
on: (type: ConsentEventType, listener: ConsentEventListener, options?: ConsentEventOptions) => () => void;
|
|
584
|
+
/** Feed in the committed categories after a save; the emitter fans out events. */
|
|
585
|
+
push: (categories: Record<string, boolean>) => void;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* The consent event fan-out, shared by the core and React runtimes so both
|
|
589
|
+
* behave identically. `getCommitted` returns the consent currently in effect,
|
|
590
|
+
* used for the immediate replay a new listener receives.
|
|
591
|
+
*/
|
|
592
|
+
declare function createConsentEmitter(getCommitted: () => Record<string, boolean>): ConsentEmitter;
|
|
593
|
+
|
|
520
594
|
type GcmValue = "granted" | "denied";
|
|
521
595
|
/**
|
|
522
596
|
* Compute the granted/denied value for every GCM signal from the current
|
|
@@ -541,8 +615,44 @@ declare function broadcastGoogleConsent(resolved: ResolvedCategories, categories
|
|
|
541
615
|
|
|
542
616
|
declare const en: TranslationMap;
|
|
543
617
|
|
|
618
|
+
/** The base subtag of a language tag, lowercased: "en-GB" → "en". */
|
|
619
|
+
declare function primaryOf(tag: string): string;
|
|
620
|
+
/** Reading direction for a language tag, e.g. "ar" or "ar-EG" → "rtl". */
|
|
621
|
+
declare function getTextDirection(tag: string): TextDirection;
|
|
622
|
+
/** Deep-merge a (possibly partial) override onto a complete base map. */
|
|
623
|
+
declare function mergeTranslations(base: TranslationMap, override?: PartialTranslations): TranslationMap;
|
|
624
|
+
/**
|
|
625
|
+
* The language to start in, resolved in order: explicit `locale`, then the
|
|
626
|
+
* browser's language, then English. Only returns one we actually have text for
|
|
627
|
+
* (others can be brought in later via `loadLanguage`).
|
|
628
|
+
*/
|
|
629
|
+
declare function pickLanguage(i18n?: I18nConfig): string;
|
|
630
|
+
/** Full translations for the resolved starting language, English filling any gaps. */
|
|
544
631
|
declare function resolveTranslations(i18n?: I18nConfig): TranslationMap;
|
|
545
632
|
|
|
633
|
+
type LanguageController = {
|
|
634
|
+
/** Text for the active language (English fills any gaps). */
|
|
635
|
+
getTranslations: () => TranslationMap;
|
|
636
|
+
getLanguageInfo: () => LanguageInfo;
|
|
637
|
+
/** Switch language live; loads via `i18n.loadLanguage` if not already present. */
|
|
638
|
+
setLanguage: (tag: string) => Promise<void>;
|
|
639
|
+
/**
|
|
640
|
+
* The customer's own text for a category in the *active* language, if they
|
|
641
|
+
* provided it — kept separate from the English defaults so a translation can
|
|
642
|
+
* win over a category's config label without the English default masking it.
|
|
643
|
+
*/
|
|
644
|
+
getCategoryText: (id: string) => Partial<CategoryText> | undefined;
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* Owns the active language: which one is showing, its (English-filled) text,
|
|
648
|
+
* and switching to another — loading it on demand when a loader is provided.
|
|
649
|
+
* `onChange` runs after every switch so the UI can re-render.
|
|
650
|
+
*
|
|
651
|
+
* Framework-agnostic: used by both the core and React runtimes, so they behave
|
|
652
|
+
* identically.
|
|
653
|
+
*/
|
|
654
|
+
declare function createLanguageController(i18n: I18nConfig | undefined, onChange: () => void): LanguageController;
|
|
655
|
+
|
|
546
656
|
declare function createConsentManager(config: ConsentConfig): ConsentManager;
|
|
547
657
|
|
|
548
658
|
declare function getOrCreateConsentRuntime(config: CookieYesConfig): ConsentRuntime;
|
|
@@ -555,5 +665,5 @@ declare function getOrCreateConsentRuntime(config: CookieYesConfig): ConsentRunt
|
|
|
555
665
|
declare function initCookieYes(config: CookieYesConfig): ConsentRuntime;
|
|
556
666
|
declare function resetConsentRuntime(): void;
|
|
557
667
|
|
|
558
|
-
export { DEFAULT_CATEGORIES, _clearStopHandlers, _normalizeConfig, _resetOfflineModeWarning, _warnOfflineModeDeprecated, broadcastGoogleConsent, computeGoogleConsent, createConsentManager, en as defaultTranslations, generateConsentId, getOrCreateConsentRuntime, initCookieYes, installNetworkBlocker, parseCookie, registerStopHandler, resetConsentRuntime, resolveBuiltInIntegration, resolveCategories, resolveTranslations, serializeCookie, uninstallNetworkBlocker };
|
|
559
|
-
export type { ActiveUI, AnyStopHandler, BlockedRequestInfo, BuiltInIntegration, CategoryDef, ColorScheme, ConsentBackend, ConsentCategory, ConsentChangePayload, ConsentConfig, ConsentManager, ConsentPayload, ConsentRuntime, ConsentRuntimeMode, ConsentRuntimeOptions, ConsentSnapshot, ConsentStore, ConsentStoreState, CookieYesConfig, CookieYesOfflineConfig, CookieYesSelfHostedConfig, GoogleConsentSignal, I18nConfig, NetworkBlockerConfig, NetworkBlockerRule, Regulation, ReloadNoticeState, ReloadOnlyHandler, ResolvedCategories, ScriptEntry, StopHandler, ThemeConfig, TranslationMap, _NormalizedConfig };
|
|
668
|
+
export { DEFAULT_CATEGORIES, _clearStopHandlers, _normalizeConfig, _resetOfflineModeWarning, _warnOfflineModeDeprecated, broadcastGoogleConsent, computeGoogleConsent, createConsentEmitter, createConsentManager, createLanguageController, en as defaultTranslations, generateConsentId, getOrCreateConsentRuntime, getTextDirection, initCookieYes, installNetworkBlocker, mergeTranslations, parseCookie, pickLanguage, primaryOf, registerStopHandler, resetConsentRuntime, resolveBuiltInIntegration, resolveCategories, resolveTranslations, serializeCookie, uninstallNetworkBlocker };
|
|
669
|
+
export type { ActiveUI, AnyStopHandler, BlockedRequestInfo, BuiltInIntegration, CategoryDef, CategoryText, ColorScheme, ConsentBackend, ConsentCategory, ConsentChangePayload, ConsentConfig, ConsentEmitter, ConsentEventListener, ConsentEventOptions, ConsentEventPayload, ConsentEventType, ConsentManager, ConsentPayload, ConsentRuntime, ConsentRuntimeMode, ConsentRuntimeOptions, ConsentSnapshot, ConsentStore, ConsentStoreState, CookieYesConfig, CookieYesOfflineConfig, CookieYesSelfHostedConfig, GoogleConsentSignal, I18nConfig, LanguageController, LanguageInfo, NetworkBlockerConfig, NetworkBlockerRule, PartialTranslations, Regulation, ReloadNoticeState, ReloadOnlyHandler, ResolvedCategories, ScriptEntry, StopHandler, TextDirection, ThemeConfig, TranslationMap, _NormalizedConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e="cookieyes-consent",t=new Set(["consentid","consent","action","tax","lastRenewedDate"]);function o(e){const o={categories:{}};for(const n of e.split(",")){const e=n.indexOf(":");if(-1===e)continue;const r=n.slice(0,e).trim(),a=n.slice(e+1).trim();t.has(r)?o[r]=a:r.length>0&&(o.categories[r]=a)}return o}function n(e){const t=[`consentid:${e.consentId}`,"consent:"+(e.hasActed?"yes":"no"),"action:"+(e.hasActed?"yes":"no")];e.taxonomyHash&&t.push(`tax:${e.taxonomyHash}`);for(const[o,n]of Object.entries(e.categories))t.push(`${o}:${n?"yes":"no"}`);return t.push(`lastRenewedDate:${e.lastRenewed??Date.now()}`),t.join(",")}function r(t){if("undefined"==typeof document)return;const o=encodeURIComponent(n(t));document.cookie=`${e}=${o}; max-age=31536000; path=/; SameSite=Lax`}function a(){"undefined"!=typeof document&&(document.cookie=`${e}=; max-age=0; path=/`)}function i(){const e=new Uint8Array(32);if("undefined"!=typeof crypto&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(256*Math.random());return btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"").slice(0,44)}function s(e,t,o){const n="CCPA"===t,r={};for(const e of o.ids)r[e]=!!o.requiredIds.has(e)||n;return{consentId:e,hasActed:!1,categories:r,regulation:t,taxonomyHash:o.taxonomyHash}}const c=[{id:"necessary",required:!0},{id:"functional",gcm:["functionality_storage","personalization_storage"]},{id:"analytics",gcm:["analytics_storage"]},{id:"performance"},{id:"advertisement",gcm:["ad_storage","ad_user_data","ad_personalization"]}];function d(e){let t=2166136261;for(let o=0;o<e.length;o++)t^=e.charCodeAt(o),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function l(e,t){const o=e.map(e=>e.id),n=new Set(e.filter(e=>e.required).map(e=>e.id)),r=e.map(e=>`${e.id}:${e.required?1:0}:${(e.gcm??[]).join("+")}`).join("|");return{list:e,ids:o,requiredIds:n,taxonomyHash:d(r),isDefault:t}}function u(e){if(!e||0===e.length)return l(c,!0);const o=function(e){const o=e.map(e=>e.id);return o.some(e=>"string"!=typeof e||0===e.length)?"every category needs a non-empty string id":o.some(e=>e.includes(",")||e.includes(":"))?"category ids must not contain ',' or ':'":new Set(o).size!==o.length?"category ids must be unique":o.some(e=>t.has(e))?`category ids must not be one of the reserved keys: ${[...t].join(", ")}`:e.some(e=>!0===e.required)?null:"at least one category must be marked { required: true }"}(e);return o?("undefined"!=typeof console&&console.warn(`[cookieyes] Invalid categories config (${o}). Falling back to the default five (necessary, functional, analytics, performance, advertisement).`),l(c,!0)):l(e,!1)}function f(e){"undefined"!=typeof console&&console.warn(e)}function g(e){const t={mode:e.mode},o=e.overrides?.regulation;return void 0!==e.regulation?(t.regulation=e.regulation,void 0!==o&&f("[CookieYes] Received both `regulation` and the deprecated `overrides.regulation`. Using the top-level `regulation` and ignoring `overrides`. Drop the `overrides` object — it is deprecated and will be removed after three release cycles.")):void 0!==o&&(t.regulation=o),void 0!==e.colorScheme&&(t.colorScheme=e.colorScheme),void 0!==e.theme&&(t.theme=e.theme),void 0!==e.i18n&&(t.i18n=e.i18n),void 0!==e.consentCategories&&(t.consentCategories=e.consentCategories),void 0!==e.categories&&(t.categories=e.categories),void 0!==e.networkBlocker&&(t.networkBlocker=e.networkBlocker),void 0!==e.reloadOnRevoke&&(t.reloadOnRevoke=e.reloadOnRevoke),void 0!==e.integrations&&(t.integrations=e.integrations),void 0!==e.customStopHandlers&&(t.customStopHandlers=e.customStopHandlers),void 0!==e.onConsentReady&&(t.onConsentReady=e.onConsentReady),void 0!==e.onConsentUpdate&&(t.onConsentUpdate=e.onConsentUpdate),"self-hosted"===e.mode&&(void 0!==e.apiKey&&(t.apiKey=e.apiKey),void 0!==e.backend&&(t.backend=e.backend),void 0!==e.apiUrl?(t.apiUrl=e.apiUrl,void 0!==e.backendURL&&f("[CookieYes] Received both `apiUrl` and the deprecated `backendURL`. Using `apiUrl` and ignoring `backendURL`. Rename `backendURL` to `apiUrl` — the alias is deprecated and will be removed after three release cycles.")):void 0!==e.backendURL&&(t.apiUrl=e.backendURL)),t}let p=!1;function h(){p||(p=!0,"undefined"!=typeof console&&console.warn('[cookieyes] mode: "offline" has been renamed to "cookie-only". Both do exactly the same thing, but "offline" is deprecated and will be removed in 3 releases. Update to .mode("cookie-only") (or { mode: "cookie-only" }).'))}function y(){p=!1}const m=["ad_storage","ad_user_data","ad_personalization","analytics_storage","functionality_storage","personalization_storage","security_storage"];function w(e,t){const o={};for(const e of m)o[e]="denied";o.security_storage="granted";for(const n of e.list)if(n.gcm&&0!==n.gcm.length&&t[n.id])for(const e of n.gcm)o[e]="granted";return o}function v(e,t){if("undefined"==typeof window||!Array.isArray(window.dataLayer))return;const o=w(e,t),n=window.dataLayer;if(!n)return;!function(){n.push(arguments)}("consent","update",o)}const k={bannerTitle:"We value your privacy",bannerDescription:"We use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking “Accept All”, you consent to our use of cookies.",acceptAll:"Accept All",rejectAll:"Reject All",managePreferences:"Customise",savePreferences:"Save My Preferences",doNotSell:"Do Not Sell or Share My Personal Information",ccpaDescription:"This website or its third-party tools process personal data. You can opt out of the sale of your personal information by clicking on the “Do Not Sell or Share My Personal Information” link.",accept:"Accept",poweredBy:"Powered by CookieYes",preferencesTitle:"Customise Consent Preferences",preferencesIntro:"We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.",categories:{necessary:{label:"Necessary",description:"Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data."},functional:{label:"Functional",description:"Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features."},analytics:{label:"Analytics",description:"Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc."},performance:{label:"Performance",description:"Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors."},advertisement:{label:"Advertisement",description:"Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns."}},optOut:{title:"Opt-out Preferences",description:'We use third-party cookies that help us analyse how you use this website, store your preferences, and provide the content and advertisements that are relevant to you. However, you can opt out of these cookies by checking "Do Not Sell or Share My Personal Information" and clicking the "Save My Preferences" button. Once you opt out, you can opt in again at any time by unchecking "Do Not Sell or Share My Personal Information" and clicking the "Save My Preferences" button.',cancel:"Cancel",successText:"Your opt-out preference has been honored.",successCountdown:"Banner closes automatically in {seconds} s..."},reloadNotice:{message:"Some tracking on this page can only be fully stopped by reloading. Reload to apply your change, or dismiss to keep browsing.",reloadButton:"Reload page",dismissButton:"Dismiss"}};function b(e){const t=e?.messages??{},o=e?.detectBrowserLanguage??!0,n=[];e?.locale&&n.push(e.locale),o&&"undefined"!=typeof navigator&&navigator.language&&n.push(navigator.language);for(const e of n){const o=e.split("-")[0]?.toLowerCase()??"",n=t[e]??(o?t[o]:void 0);if(n)return n}return t.en??k}const R=new Map,S=new Map;function C(e,t){if(document.getElementById(e))return;const o=document.createElement("script");o.id=e,o.src=t.src,o.async=!0,t.onLoad&&o.addEventListener("load",t.onLoad,{once:!0}),document.head.appendChild(o),S.set(e,o)}function U(e){return"needsReload"in e&&!0===e.needsReload}function A(e){switch(e.vendor){case"meta":return{id:"meta",category:e.category??"advertisement",stop:()=>window.fbq?.("consent","revoke"),resume:()=>window.fbq?.("consent","grant")};case"tiktok":return{id:"tiktok",category:e.category??"advertisement",needsReload:!0};case"linkedin":return{id:"linkedin",category:e.category??"advertisement",needsReload:!0};case"hotjar":return{id:"hotjar",category:e.category??"analytics",needsReload:!0};case"segment":return{id:"segment",category:e.category??"analytics",needsReload:!0}}}const x=new Map,B=new Set,H=new Set;function I(e){x.set(e.id,e)}function P(){x.clear(),B.clear(),H.clear()}function q(e){const t=[];for(const o of x.values()){const n=!0!==e[o.category];if(U(o))n?H.has(o.id)&&(t.push(o.id),H.delete(o.id)):H.add(o.id);else if(n){if(!B.has(o.id))try{o.stop(),B.add(o.id)}catch{t.push(o.id)}}else if(B.has(o.id)){B.delete(o.id);try{o.resume?.()}catch{}}}return{reloadRequiredBy:t}}function L(e){return{consentId:e.consentId,categories:e.categories,regulation:e.regulation,domain:"undefined"!=typeof window?window.location.hostname:"unknown"}}function O(t){const n=new Set,c=u(t.categories);let d,l,f,g=!1;function p(e){const t={};for(const o of c.ids)t[o]=!!c.requiredIds.has(o)||e(o);return t}let h=[],y=!1;for(const e of t.integrations??[])I(A(e));for(const e of t.customStopHandlers??[])I(e);const m=function(){if("undefined"==typeof document)return null;const t=document.cookie.split(";");for(const n of t){const t=n.trim(),r=t.indexOf("=");if(-1!==r&&t.slice(0,r).trim()===e){const e=t.slice(r+1).trim();return o(decodeURIComponent(e))}}return null}(),w=t.regulation??"DEFAULT",k=m?.tax,b=k===c.taxonomyHash,P=null!=m&&(b||void 0===k&&c.isDefault);if(null!=m&&P)d=function(e,t,o){const n={};for(const t of o.ids)n[t]=!!o.requiredIds.has(t)||"yes"===e.categories[t];return{consentId:e.consentid??i(),hasActed:"yes"===e.action,categories:n,regulation:t,lastRenewed:e.lastRenewedDate?Number(e.lastRenewedDate):void 0,taxonomyHash:e.tax}}(m,w,c);else{const e=m?.consentid??i();d=s(e,w,c),null!=m&&a(),"CCPA"===d.regulation&&r(d)}function O(){const e={consentId:d.consentId,hasActed:d.hasActed,categories:{...d.categories},regulation:d.regulation,lastRenewed:d.lastRenewed,taxonomyHash:d.taxonomyHash};for(const t of n)t(e)}function M(){!function(e){if("undefined"!=typeof document)for(const[t,o]of R)!0===e[o.category]&&(S.has(t)||C(t,o))}(f)}function _(){if(d={...d,hasActed:!0,lastRenewed:Date.now()},r(d),t.backend)try{Promise.resolve(t.backend.persist(L(d))).catch(()=>{})}catch{}else t.apiUrl&&async function(e,t,o){const n=L(o),r={"Content-Type":"application/json"};t&&(r.Authorization=`Bearer ${t}`);try{await fetch(e,{method:"POST",headers:r,body:JSON.stringify(n),keepalive:!0})}catch{}}(t.apiUrl,t.apiKey,d);let e=!1;for(const t of c.ids)if(l[t]&&!d.categories[t]){e=!0;break}l={...d.categories},f={...d.categories},M();const{reloadRequiredBy:o}=q(f);var n;((n=o).length!==h.length||n.some((e,t)=>e!==h[t]))&&(h=n,y=!1),v(c,f),O(),t.onConsentUpdate?.(d),e&&t.reloadOnRevoke&&"undefined"!=typeof window&&window.location.reload()}d={...d,taxonomyHash:c.taxonomyHash},l={...d.categories},f={...d.categories},Promise.resolve().then(()=>t.onConsentReady?.(d));const $={get consentId(){return d.consentId},get hasActed(){return d.hasActed},get categories(){return{...d.categories}},get committedCategories(){return{...f}},get regulation(){return d.regulation},get lastRenewed(){return d.lastRenewed},get taxonomyHash(){return d.taxonomyHash},get isPreferencesOpen(){return g},acceptAll(){d={...d,categories:p(()=>!0)},g=!1,_()},rejectAll(){d={...d,categories:p(()=>!1)},g=!1,_()},acceptSelected(e){d={...d,categories:p(t=>e.includes(t))},g=!1,_()},updateCategory(e,t){c.requiredIds.has(e)||c.ids.includes(e)&&(d={...d,categories:{...d.categories,[e]:t}},O())},savePreferences(){g=!1,_()},resetConsent(){a();const e=i();d=s(e,d.regulation,c),f={...d.categories},l={...d.categories},g=!1,q(f),v(c,f),h=[],y=!1,O()},showPreferences(){g=!0,O()},hidePreferences(){g=!1,O()},subscribe:e=>(n.add(e),()=>n.delete(e)),registerScript(e){!function(e){R.set(e.id,e)}(e),M()},get reloadNotice(){return{required:h.length>0&&!y,reasons:[...h]}},dismissReloadNotice(){y||(y=!0,O())}};return M(),function(e){for(const t of x.values()){const o=!0!==e[t.category];if(U(t))o?H.delete(t.id):H.add(t.id);else try{o?(t.stop(),B.add(t.id)):(B.delete(t.id),t.resume?.())}catch{}}}(d.categories),v(c,d.categories),$}function M(e,t,o,n){let r;try{const e="undefined"!=typeof window?window.location.href:"http://localhost";r=new URL(t,e)}catch{return null}const a=r.hostname.toLowerCase(),i=r.pathname+r.search,s=o.toUpperCase();for(const t of e){const e=t.domain.toLowerCase();if((a===e||a.endsWith("."+e))&&((!t.pathIncludes||i.includes(t.pathIncludes))&&(!t.methods||t.methods.map(e=>e.toUpperCase()).includes(s))&&!n(t.category)))return t}return null}let _=null;function $(e,t){if("undefined"==typeof window)return()=>{};if(_)return()=>{};if(!e.rules.length)return()=>{};const o={originalFetch:window.fetch,originalXhrOpen:XMLHttpRequest.prototype.open,originalXhrSend:XMLHttpRequest.prototype.send,originalSendBeacon:"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon?navigator.sendBeacon:void 0};_=o;const n=!1!==e.logBlockedRequests;function r(t){n&&console.warn(`[cookieyes] blocked ${t.method} ${t.url} (rule "${t.rule.id}", category: ${t.rule.category})`),e.onRequestBlocked?.(t)}if(window.fetch=function(n,a){let i="",s=a?.method??"GET";"string"==typeof n?i=n:n instanceof URL?i=n.toString():(i=n.url,s=a?.method??n.method);const c=M(e.rules,i,s,t);return c?(r({rule:c,url:i,method:s}),Promise.reject(new TypeError(`Blocked by consent (rule: ${c.id}, category: ${c.category})`))):o.originalFetch.call(window,n,a)},XMLHttpRequest.prototype.open=function(e,t,...n){return this._cyUrl=t.toString(),this._cyMethod=e,o.originalXhrOpen.apply(this,[e,t,...n])},XMLHttpRequest.prototype.send=function(n){const a=this._cyUrl??"",i=this._cyMethod??"GET",s=M(e.rules,a,i,t);return s?(r({rule:s,url:a,method:i}),void this.abort()):o.originalXhrSend.call(this,n)},o.originalSendBeacon){const n=o.originalSendBeacon;navigator.sendBeacon=function(o,a){const i=M(e.rules,o.toString(),"POST",t);return i?(r({rule:i,url:o.toString(),method:"POST"}),!0):n.call(navigator,o,a)}}return D}function D(){_&&("undefined"!=typeof window&&(window.fetch=_.originalFetch,XMLHttpRequest.prototype.open=_.originalXhrOpen,XMLHttpRequest.prototype.send=_.originalXhrSend,_.originalSendBeacon&&(navigator.sendBeacon=_.originalSendBeacon)),_=null)}let j=null;function T(e){if(j)return j;"offline"===e.mode&&h();const t=g(e),o=new Set,n=t.onConsentUpdate,r={};"self-hosted"===t.mode&&(t.backend?r.backend=t.backend:t.apiUrl&&(r.apiUrl=t.apiUrl)),t.apiKey&&(r.apiKey=t.apiKey),t.regulation&&(r.regulation=t.regulation),t.colorScheme&&(r.colorScheme=t.colorScheme),t.theme&&(r.theme=t.theme),t.reloadOnRevoke&&(r.reloadOnRevoke=t.reloadOnRevoke),t.integrations&&(r.integrations=t.integrations),t.customStopHandlers&&(r.customStopHandlers=t.customStopHandlers),t.categories&&(r.categories=t.categories),t.onConsentReady&&(r.onConsentReady=t.onConsentReady),r.onConsentUpdate=e=>{n?.(e);const t=function(e){const t=[],o=[];for(const n of Object.keys(e))e[n]?t.push(n):o.push(n);return{allowedCategories:t,deniedCategories:o}}(e.categories);for(const e of o)e(t)};const a=O(r);function i(){const e=a.categories;return{consentId:a.consentId,hasActed:a.hasActed,categories:e,consents:e,committedConsents:a.committedCategories,regulation:a.regulation,lastRenewed:a.lastRenewed,taxonomyHash:a.taxonomyHash,activeUI:a.isPreferencesOpen?"dialog":a.hasActed?null:"banner",has:e=>!0===a.committedCategories[e],saveConsents:async e=>{"all"===e?a.acceptAll():"necessary"===e?a.rejectAll():a.acceptSelected(e)},setConsent:(e,t)=>a.updateCategory(e,t),subscribeToConsentChanges:e=>(o.add(e),()=>{o.delete(e)})}}const s={subscribe:e=>a.subscribe(()=>e(i())),getState:i};return t.networkBlocker&&t.networkBlocker.rules.length>0&&$(t.networkBlocker,e=>!0===a.committedCategories[e]),j={consentManager:a,consentStore:s},j}function N(e){return T(e)}function X(){j=null}export{c as DEFAULT_CATEGORIES,P as _clearStopHandlers,g as _normalizeConfig,y as _resetOfflineModeWarning,h as _warnOfflineModeDeprecated,v as broadcastGoogleConsent,w as computeGoogleConsent,O as createConsentManager,k as defaultTranslations,i as generateConsentId,T as getOrCreateConsentRuntime,N as initCookieYes,$ as installNetworkBlocker,o as parseCookie,I as registerStopHandler,X as resetConsentRuntime,A as resolveBuiltInIntegration,u as resolveCategories,b as resolveTranslations,n as serializeCookie,D as uninstallNetworkBlocker};
|
|
1
|
+
const e="cookieyes-consent",t=new Set(["consentid","consent","action","tax","lastRenewedDate"]);function n(e){const n={categories:{}};for(const o of e.split(",")){const e=o.indexOf(":");if(-1===e)continue;const r=o.slice(0,e).trim(),a=o.slice(e+1).trim();t.has(r)?n[r]=a:r.length>0&&(n.categories[r]=a)}return n}function o(e){const t=[`consentid:${e.consentId}`,"consent:"+(e.hasActed?"yes":"no"),"action:"+(e.hasActed?"yes":"no")];e.taxonomyHash&&t.push(`tax:${e.taxonomyHash}`);for(const[n,o]of Object.entries(e.categories))t.push(`${n}:${o?"yes":"no"}`);return t.push(`lastRenewedDate:${e.lastRenewed??Date.now()}`),t.join(",")}function r(t){if("undefined"==typeof document)return;const n=encodeURIComponent(o(t));document.cookie=`${e}=${n}; max-age=31536000; path=/; SameSite=Lax`}function a(){"undefined"!=typeof document&&(document.cookie=`${e}=; max-age=0; path=/`)}function s(){const e=new Uint8Array(32);if("undefined"!=typeof crypto&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(256*Math.random());return btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"").slice(0,44)}function i(e,t,n){const o="CCPA"===t,r={};for(const e of n.ids)r[e]=!!n.requiredIds.has(e)||o;return{consentId:e,hasActed:!1,categories:r,regulation:t,taxonomyHash:n.taxonomyHash}}const c=[{id:"necessary",required:!0},{id:"functional",gcm:["functionality_storage","personalization_storage"]},{id:"analytics",gcm:["analytics_storage"]},{id:"performance"},{id:"advertisement",gcm:["ad_storage","ad_user_data","ad_personalization"]}];function d(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function l(e,t){const n=e.map(e=>e.id),o=new Set(e.filter(e=>e.required).map(e=>e.id)),r=e.map(e=>`${e.id}:${e.required?1:0}:${(e.gcm??[]).join("+")}`).join("|");return{list:e,ids:n,requiredIds:o,taxonomyHash:d(r),isDefault:t}}function u(e){if(!e||0===e.length)return l(c,!0);const n=function(e){const n=e.map(e=>e.id);return n.some(e=>"string"!=typeof e||0===e.length)?"every category needs a non-empty string id":n.some(e=>e.includes(",")||e.includes(":"))?"category ids must not contain ',' or ':'":new Set(n).size!==n.length?"category ids must be unique":n.some(e=>t.has(e))?`category ids must not be one of the reserved keys: ${[...t].join(", ")}`:e.some(e=>!0===e.required)?null:"at least one category must be marked { required: true }"}(e);return n?("undefined"!=typeof console&&console.warn(`[cookieyes] Invalid categories config (${n}). Falling back to the default five (necessary, functional, analytics, performance, advertisement).`),l(c,!0)):l(e,!1)}function g(e){"undefined"!=typeof console&&console.warn(e)}function f(e){const t={mode:e.mode},n=e.overrides?.regulation;return void 0!==e.regulation?(t.regulation=e.regulation,void 0!==n&&g("[CookieYes] Received both `regulation` and the deprecated `overrides.regulation`. Using the top-level `regulation` and ignoring `overrides`. Drop the `overrides` object — it is deprecated and will be removed after three release cycles.")):void 0!==n&&(t.regulation=n),void 0!==e.colorScheme&&(t.colorScheme=e.colorScheme),void 0!==e.theme&&(t.theme=e.theme),void 0!==e.i18n&&(t.i18n=e.i18n),void 0!==e.consentCategories&&(t.consentCategories=e.consentCategories),void 0!==e.categories&&(t.categories=e.categories),void 0!==e.networkBlocker&&(t.networkBlocker=e.networkBlocker),void 0!==e.reloadOnRevoke&&(t.reloadOnRevoke=e.reloadOnRevoke),void 0!==e.integrations&&(t.integrations=e.integrations),void 0!==e.customStopHandlers&&(t.customStopHandlers=e.customStopHandlers),void 0!==e.onConsentReady&&(t.onConsentReady=e.onConsentReady),void 0!==e.onConsentUpdate&&(t.onConsentUpdate=e.onConsentUpdate),"self-hosted"===e.mode&&(void 0!==e.apiKey&&(t.apiKey=e.apiKey),void 0!==e.backend&&(t.backend=e.backend),void 0!==e.apiUrl?(t.apiUrl=e.apiUrl,void 0!==e.backendURL&&g("[CookieYes] Received both `apiUrl` and the deprecated `backendURL`. Using `apiUrl` and ignoring `backendURL`. Rename `backendURL` to `apiUrl` — the alias is deprecated and will be removed after three release cycles.")):void 0!==e.backendURL&&(t.apiUrl=e.backendURL)),t}let h=!1;function p(){h||(h=!0,"undefined"!=typeof console&&console.warn('[cookieyes] mode: "offline" has been renamed to "cookie-only". Both do exactly the same thing, but "offline" is deprecated and will be removed in 3 releases. Update to .mode("cookie-only") (or { mode: "cookie-only" }).'))}function y(){h=!1}function m(e){const t={save:new Set,change:new Set};let n={...e()};function o(e,t,n){try{e.listener(n)}catch(e){"undefined"!=typeof console&&console.error(`[cookieyes] a consent "${t}" listener threw; others are unaffected:`,e)}}function r(e,n){for(const r of[...t[e]])r.category&&!n.changedCategories.includes(r.category)||o(r,e,n)}return{on(n,r,a){const s=a?.category?{listener:r,category:a.category}:{listener:r};return t[n].add(s),o(s,n,{categories:{...e()},changedCategories:[],isInitial:!0}),()=>{t[n].delete(s)}},push(e){const t={...e},o=[];for(const e of Object.keys(t))n[e]!==t[e]&&o.push(e);n=t,r("save",{categories:t,changedCategories:o,isInitial:!1}),o.length>0&&r("change",{categories:t,changedCategories:o,isInitial:!1})}}}const w=["ad_storage","ad_user_data","ad_personalization","analytics_storage","functionality_storage","personalization_storage","security_storage"];function v(e,t){const n={};for(const e of w)n[e]="denied";n.security_storage="granted";for(const o of e.list)if(o.gcm&&0!==o.gcm.length&&t[o.id])for(const e of o.gcm)n[e]="granted";return n}function k(e,t){if("undefined"==typeof window||!Array.isArray(window.dataLayer))return;const n=v(e,t),o=window.dataLayer;if(!o)return;!function(){o.push(arguments)}("consent","update",n)}const b={bannerTitle:"We value your privacy",bannerDescription:"We use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking “Accept All”, you consent to our use of cookies.",acceptAll:"Accept All",rejectAll:"Reject All",managePreferences:"Customise",savePreferences:"Save My Preferences",doNotSell:"Do Not Sell or Share My Personal Information",ccpaDescription:"This website or its third-party tools process personal data. You can opt out of the sale of your personal information by clicking on the “Do Not Sell or Share My Personal Information” link.",accept:"Accept",poweredBy:"Powered by CookieYes",preferencesTitle:"Customise Consent Preferences",preferencesIntro:"We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.",categories:{necessary:{label:"Necessary",description:"Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data."},functional:{label:"Functional",description:"Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features."},analytics:{label:"Analytics",description:"Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc."},performance:{label:"Performance",description:"Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors."},advertisement:{label:"Advertisement",description:"Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns."}},optOut:{title:"Opt-out Preferences",description:'We use third-party cookies that help us analyse how you use this website, store your preferences, and provide the content and advertisements that are relevant to you. However, you can opt out of these cookies by checking "Do Not Sell or Share My Personal Information" and clicking the "Save My Preferences" button. Once you opt out, you can opt in again at any time by unchecking "Do Not Sell or Share My Personal Information" and clicking the "Save My Preferences" button.',cancel:"Cancel",successText:"Your opt-out preference has been honored.",successCountdown:"Banner closes automatically in {seconds} s..."},reloadNotice:{message:"Some tracking on this page can only be fully stopped by reloading. Reload to apply your change, or dismiss to keep browsing.",reloadButton:"Reload page",dismissButton:"Dismiss"}},S=new Set(["ar","he","fa","ur","ps","sd","yi","dv"]);function C(e){return e.split("-")[0]?.toLowerCase()??""}function R(e){return S.has(C(e))?"rtl":"ltr"}function A(e,t){if(!t)return e;const n={...e};for(const[o,r]of Object.entries(t)){if(null==r)continue;const t=e[o],a="object"==typeof r&&!Array.isArray(r)&&"object"==typeof t&&null!=t;n[o]=a?A(t,r):r}return n}function U(e){const t=e?.messages??{},n=[];e?.locale&&n.push(e.locale),(e?.detectBrowserLanguage??1)&&"undefined"!=typeof navigator&&navigator.language&&n.push(navigator.language);for(const e of n){if(t[e])return e;const n=C(e);if(n&&t[n])return n}return"en"}function I(e){const t=e?.messages??{},n=U(e);return A(b,t[n]??t[C(n)])}function x(e,t){const n={...e?.messages},o=e?.loadLanguage,r=new Set;let a=U(e),s=l(a),i=u();function c(e){return n[e]??n[C(e)]}function d(e){return"en"===C(e)||void 0!==c(e)}function l(e){return A(b,c(e))}function u(){return{language:a,direction:R(a),languages:Array.from(new Set(["en",...Object.keys(n)]))}}function g(e){a=e,s=l(e),i=u(),t()}function f(e,t){r.has(e)||"undefined"==typeof console||(r.add(e),console.warn(`[cookieyes] no translations for language "${e}"; staying on "${a}". Add it to i18n.messages or provide i18n.loadLanguage.`,t??""))}function h(e){return d(e)?(g(e),Promise.resolve()):o?Promise.resolve().then(()=>o(e)).then(t=>{n[e]=t,g(e)}).catch(t=>f(e,t)):(f(e),Promise.resolve())}return o&&e?.locale&&!d(e.locale)&&"undefined"!=typeof window&&h(e.locale),{getTranslations:()=>s,getLanguageInfo:()=>i,setLanguage:h,getCategoryText:function(e){return c(a)?.categories?.[e]}}}const L=new Map,P=new Map;function B(e,t){if(document.getElementById(e))return;const n=document.createElement("script");n.id=e,n.src=t.src,n.async=!0,t.onLoad&&n.addEventListener("load",t.onLoad,{once:!0}),document.head.appendChild(n),P.set(e,n)}function H(e){return"needsReload"in e&&!0===e.needsReload}function O(e){switch(e.vendor){case"meta":return{id:"meta",category:e.category??"advertisement",stop:()=>window.fbq?.("consent","revoke"),resume:()=>window.fbq?.("consent","grant")};case"tiktok":return{id:"tiktok",category:e.category??"advertisement",needsReload:!0};case"linkedin":return{id:"linkedin",category:e.category??"advertisement",needsReload:!0};case"hotjar":return{id:"hotjar",category:e.category??"analytics",needsReload:!0};case"segment":return{id:"segment",category:e.category??"analytics",needsReload:!0}}}const q=new Map,$=new Set,M=new Set;function j(e){q.set(e.id,e)}function T(){q.clear(),$.clear(),M.clear()}function _(e){const t=[];for(const n of q.values()){const o=!0!==e[n.category];if(H(n))o?M.has(n.id)&&(t.push(n.id),M.delete(n.id)):M.add(n.id);else if(o){if(!$.has(n.id))try{n.stop(),$.add(n.id)}catch{t.push(n.id)}}else if($.has(n.id)){$.delete(n.id);try{n.resume?.()}catch{}}}return{reloadRequiredBy:t}}function D(e){return{consentId:e.consentId,categories:e.categories,regulation:e.regulation,domain:"undefined"!=typeof window?window.location.hostname:"unknown"}}function N(t){const o=new Set,c=u(t.categories);let d,l,g,f=!1;function h(e){const t={};for(const n of c.ids)t[n]=!!c.requiredIds.has(n)||e(n);return t}let p=[],y=!1;for(const e of t.integrations??[])j(O(e));for(const e of t.customStopHandlers??[])j(e);const m=function(){if("undefined"==typeof document)return null;const t=document.cookie.split(";");for(const o of t){const t=o.trim(),r=t.indexOf("=");if(-1!==r&&t.slice(0,r).trim()===e){const e=t.slice(r+1).trim();return n(decodeURIComponent(e))}}return null}(),w=t.regulation??"DEFAULT",v=m?.tax,b=v===c.taxonomyHash,S=null!=m&&(b||void 0===v&&c.isDefault);if(null!=m&&S)d=function(e,t,n){const o={};for(const t of n.ids)o[t]=!!n.requiredIds.has(t)||"yes"===e.categories[t];return{consentId:e.consentid??s(),hasActed:"yes"===e.action,categories:o,regulation:t,lastRenewed:e.lastRenewedDate?Number(e.lastRenewedDate):void 0,taxonomyHash:e.tax}}(m,w,c);else{const e=m?.consentid??s();d=i(e,w,c),null!=m&&a(),"CCPA"===d.regulation&&r(d)}function C(){const e={consentId:d.consentId,hasActed:d.hasActed,categories:{...d.categories},regulation:d.regulation,lastRenewed:d.lastRenewed,taxonomyHash:d.taxonomyHash};for(const t of o)t(e)}function R(){!function(e){if("undefined"!=typeof document)for(const[t,n]of L)!0===e[n.category]&&(P.has(t)||B(t,n))}(g)}function A(){if(d={...d,hasActed:!0,lastRenewed:Date.now()},r(d),t.backend)try{Promise.resolve(t.backend.persist(D(d))).catch(()=>{})}catch{}else t.apiUrl&&async function(e,t,n){const o=D(n),r={"Content-Type":"application/json"};t&&(r.Authorization=`Bearer ${t}`);try{await fetch(e,{method:"POST",headers:r,body:JSON.stringify(o),keepalive:!0})}catch{}}(t.apiUrl,t.apiKey,d);let e=!1;for(const t of c.ids)if(l[t]&&!d.categories[t]){e=!0;break}l={...d.categories},g={...d.categories},R();const{reloadRequiredBy:n}=_(g);var o;((o=n).length!==p.length||o.some((e,t)=>e!==p[t]))&&(p=o,y=!1),k(c,g),C(),t.onConsentUpdate?.(d),e&&t.reloadOnRevoke&&"undefined"!=typeof window&&window.location.reload()}d={...d,taxonomyHash:c.taxonomyHash},l={...d.categories},g={...d.categories},Promise.resolve().then(()=>t.onConsentReady?.(d));const U={get consentId(){return d.consentId},get hasActed(){return d.hasActed},get categories(){return{...d.categories}},get committedCategories(){return{...g}},get regulation(){return d.regulation},get lastRenewed(){return d.lastRenewed},get taxonomyHash(){return d.taxonomyHash},get isPreferencesOpen(){return f},acceptAll(){d={...d,categories:h(()=>!0)},f=!1,A()},rejectAll(){d={...d,categories:h(()=>!1)},f=!1,A()},acceptSelected(e){d={...d,categories:h(t=>e.includes(t))},f=!1,A()},updateCategory(e,t){c.requiredIds.has(e)||c.ids.includes(e)&&(d={...d,categories:{...d.categories,[e]:t}},C())},savePreferences(){f=!1,A()},resetConsent(){a();const e=s();d=i(e,d.regulation,c),g={...d.categories},l={...d.categories},f=!1,_(g),k(c,g),p=[],y=!1,C()},showPreferences(){f=!0,C()},hidePreferences(){f=!1,C()},subscribe:e=>(o.add(e),()=>o.delete(e)),registerScript(e){!function(e){L.set(e.id,e)}(e),R()},get reloadNotice(){return{required:p.length>0&&!y,reasons:[...p]}},dismissReloadNotice(){y||(y=!0,C())}};return R(),function(e){for(const t of q.values()){const n=!0!==e[t.category];if(H(t))n?M.delete(t.id):M.add(t.id);else try{n?(t.stop(),$.add(t.id)):($.delete(t.id),t.resume?.())}catch{}}}(d.categories),k(c,d.categories),U}function X(e,t,n,o){let r;try{const e="undefined"!=typeof window?window.location.href:"http://localhost";r=new URL(t,e)}catch{return null}const a=r.hostname.toLowerCase(),s=r.pathname+r.search,i=n.toUpperCase();for(const t of e){const e=t.domain.toLowerCase();if((a===e||a.endsWith("."+e))&&((!t.pathIncludes||s.includes(t.pathIncludes))&&(!t.methods||t.methods.map(e=>e.toUpperCase()).includes(i))&&!o(t.category)))return t}return null}let E=null;function F(e,t){if("undefined"==typeof window)return()=>{};if(E)return()=>{};if(!e.rules.length)return()=>{};const n={originalFetch:window.fetch,originalXhrOpen:XMLHttpRequest.prototype.open,originalXhrSend:XMLHttpRequest.prototype.send,originalSendBeacon:"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon?navigator.sendBeacon:void 0};E=n;const o=!1!==e.logBlockedRequests;function r(t){o&&console.warn(`[cookieyes] blocked ${t.method} ${t.url} (rule "${t.rule.id}", category: ${t.rule.category})`),e.onRequestBlocked?.(t)}if(window.fetch=function(o,a){let s="",i=a?.method??"GET";"string"==typeof o?s=o:o instanceof URL?s=o.toString():(s=o.url,i=a?.method??o.method);const c=X(e.rules,s,i,t);return c?(r({rule:c,url:s,method:i}),Promise.reject(new TypeError(`Blocked by consent (rule: ${c.id}, category: ${c.category})`))):n.originalFetch.call(window,o,a)},XMLHttpRequest.prototype.open=function(e,t,...o){return this._cyUrl=t.toString(),this._cyMethod=e,n.originalXhrOpen.apply(this,[e,t,...o])},XMLHttpRequest.prototype.send=function(o){const a=this._cyUrl??"",s=this._cyMethod??"GET",i=X(e.rules,a,s,t);return i?(r({rule:i,url:a,method:s}),void this.abort()):n.originalXhrSend.call(this,o)},n.originalSendBeacon){const o=n.originalSendBeacon;navigator.sendBeacon=function(n,a){const s=X(e.rules,n.toString(),"POST",t);return s?(r({rule:s,url:n.toString(),method:"POST"}),!0):o.call(navigator,n,a)}}return K}function K(){E&&("undefined"!=typeof window&&(window.fetch=E.originalFetch,XMLHttpRequest.prototype.open=E.originalXhrOpen,XMLHttpRequest.prototype.send=E.originalXhrSend,E.originalSendBeacon&&(navigator.sendBeacon=E.originalSendBeacon)),E=null)}let z=null;function Y(e){if(z)return z;"offline"===e.mode&&p();const t=f(e),n=new Set,o=t.onConsentUpdate;let r;const a={};"self-hosted"===t.mode&&(t.backend?a.backend=t.backend:t.apiUrl&&(a.apiUrl=t.apiUrl)),t.apiKey&&(a.apiKey=t.apiKey),t.regulation&&(a.regulation=t.regulation),t.colorScheme&&(a.colorScheme=t.colorScheme),t.theme&&(a.theme=t.theme),t.reloadOnRevoke&&(a.reloadOnRevoke=t.reloadOnRevoke),t.integrations&&(a.integrations=t.integrations),t.customStopHandlers&&(a.customStopHandlers=t.customStopHandlers),t.categories&&(a.categories=t.categories),t.onConsentReady&&(a.onConsentReady=t.onConsentReady),a.onConsentUpdate=e=>{o?.(e),r.push(e.categories);const t=function(e){const t=[],n=[];for(const o of Object.keys(e))e[o]?t.push(o):n.push(o);return{allowedCategories:t,deniedCategories:n}}(e.categories);for(const e of n)e(t)};const s=N(a);r=m(()=>s.committedCategories);const i=u(t.categories),c=new Set;function d(){const e=g();for(const t of c)t(e)}s.subscribe(d);const l=x(t.i18n,d);function g(){const e=s.categories;return{consentId:s.consentId,hasActed:s.hasActed,categories:e,consents:e,committedConsents:s.committedCategories,regulation:s.regulation,lastRenewed:s.lastRenewed,taxonomyHash:s.taxonomyHash,activeUI:s.isPreferencesOpen?"dialog":s.hasActed?null:"banner",has:e=>!0===s.committedCategories[e],saveConsents:async e=>{"all"===e?s.acceptAll():"necessary"===e?s.rejectAll():s.acceptSelected(e)},setConsent:(e,t)=>s.updateCategory(e,t),subscribeToConsentChanges:e=>(n.add(e),()=>{n.delete(e)})}}const h={subscribe:e=>(c.add(e),()=>{c.delete(e)}),getState:g,on:(e,t,n)=>r.on(e,t,n),get translations(){return l.getTranslations()},getLanguageInfo:l.getLanguageInfo,setLanguage:l.setLanguage,getCategoryText:l.getCategoryText,categories:i};return t.networkBlocker&&t.networkBlocker.rules.length>0&&F(t.networkBlocker,e=>!0===s.committedCategories[e]),z={consentManager:s,consentStore:h},z}function W(e){return Y(e)}function G(){z=null}export{c as DEFAULT_CATEGORIES,T as _clearStopHandlers,f as _normalizeConfig,y as _resetOfflineModeWarning,p as _warnOfflineModeDeprecated,k as broadcastGoogleConsent,v as computeGoogleConsent,m as createConsentEmitter,N as createConsentManager,x as createLanguageController,b as defaultTranslations,s as generateConsentId,Y as getOrCreateConsentRuntime,R as getTextDirection,W as initCookieYes,F as installNetworkBlocker,A as mergeTranslations,n as parseCookie,U as pickLanguage,C as primaryOf,j as registerStopHandler,G as resetConsentRuntime,O as resolveBuiltInIntegration,u as resolveCategories,I as resolveTranslations,o as serializeCookie,K as uninstallNetworkBlocker};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|