@walkeros/web-source-cmp-usercentrics 3.4.1-next-1776790594143 → 3.4.2
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/dist/dev.d.mts +87 -0
- package/dist/dev.d.ts +87 -0
- package/dist/examples/index.d.mts +87 -0
- package/dist/examples/index.d.ts +87 -0
- package/dist/index.browser.js +1 -1
- package/dist/index.d.mts +125 -5
- package/dist/index.d.ts +125 -5
- package/dist/index.es5.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +1 -1
- package/package.json +3 -4
package/dist/dev.d.mts
CHANGED
|
@@ -23,6 +23,93 @@ interface UsercentricsEventDetail {
|
|
|
23
23
|
declare global {
|
|
24
24
|
interface WindowEventMap {
|
|
25
25
|
ucEvent: CustomEvent<UsercentricsEventDetail>;
|
|
26
|
+
UC_UI_CMP_EVENT: CustomEvent<UsercentricsV3CmpEventDetail>;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Usercentrics V2 service info shape returned by `UC_UI.getServicesBaseInfo()`.
|
|
31
|
+
* Only the fields we use are typed — minimal surface, not a full V2 API mirror.
|
|
32
|
+
*/
|
|
33
|
+
interface UsercentricsV2Service {
|
|
34
|
+
/** Category slug: 'essential' | 'functional' | 'marketing' | custom */
|
|
35
|
+
categorySlug: string;
|
|
36
|
+
/** Consent state for this service */
|
|
37
|
+
consent: {
|
|
38
|
+
status: boolean;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Usercentrics V2 window API (`window.UC_UI`).
|
|
43
|
+
*
|
|
44
|
+
* Methods are synchronous (unlike V3). All methods are optional because
|
|
45
|
+
* Usercentrics does not guarantee every deployment exposes every method.
|
|
46
|
+
*/
|
|
47
|
+
interface UsercentricsV2Api {
|
|
48
|
+
isInitialized?: () => boolean;
|
|
49
|
+
getServicesBaseInfo?: () => UsercentricsV2Service[];
|
|
50
|
+
areAllConsentsAccepted?: () => boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Usercentrics V3 category state. The SDK may add future states; we handle
|
|
54
|
+
* unknowns conservatively as non-accepting.
|
|
55
|
+
*/
|
|
56
|
+
type UsercentricsV3CategoryState = 'ALL_ACCEPTED' | 'ALL_DENIED' | 'SOME_ACCEPTED' | 'NO_STATE' | string;
|
|
57
|
+
/**
|
|
58
|
+
* Minimal V3 CategoryData — only fields the adapter reads.
|
|
59
|
+
*/
|
|
60
|
+
interface UsercentricsV3CategoryData {
|
|
61
|
+
state: UsercentricsV3CategoryState;
|
|
62
|
+
name: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Minimal V3 ConsentData — only the `type` field is used to distinguish
|
|
66
|
+
* explicit vs implicit consent. Other fields (status, version, etc.) exist on
|
|
67
|
+
* the real SDK but are not read by this adapter.
|
|
68
|
+
*/
|
|
69
|
+
interface UsercentricsV3ConsentData {
|
|
70
|
+
type: 'EXPLICIT' | 'IMPLICIT' | string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Minimal V3 ConsentDetails — only the fields the adapter reads.
|
|
74
|
+
* The real SDK also exposes `services`, but the adapter currently operates
|
|
75
|
+
* at category level only.
|
|
76
|
+
*/
|
|
77
|
+
interface UsercentricsV3ConsentDetails {
|
|
78
|
+
consent: UsercentricsV3ConsentData;
|
|
79
|
+
categories: Record<string, UsercentricsV3CategoryData>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Usercentrics V3 window API (`window.__ucCmp`).
|
|
83
|
+
*
|
|
84
|
+
* Only the methods this adapter calls are typed — the real SDK surface is
|
|
85
|
+
* much wider but we intentionally keep this narrow.
|
|
86
|
+
*/
|
|
87
|
+
interface UsercentricsV3Api {
|
|
88
|
+
isInitialized: () => Promise<boolean>;
|
|
89
|
+
getConsentDetails: () => Promise<UsercentricsV3ConsentDetails>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* V3 CMP event detail. Fired on `UC_UI_CMP_EVENT` (or custom name).
|
|
93
|
+
* `source: 'CMP'` + a decision `type` tells us a user action has been taken.
|
|
94
|
+
*/
|
|
95
|
+
interface UsercentricsV3CmpEventDetail {
|
|
96
|
+
source?: string;
|
|
97
|
+
type?: string;
|
|
98
|
+
}
|
|
99
|
+
declare global {
|
|
100
|
+
interface Window {
|
|
101
|
+
/**
|
|
102
|
+
* Usercentrics V2 CMP API. Attached once the V2 Browser SDK is
|
|
103
|
+
* initialized. Optional because the SDK loads asynchronously — guard
|
|
104
|
+
* with a truthiness check before access.
|
|
105
|
+
*/
|
|
106
|
+
UC_UI?: UsercentricsV2Api;
|
|
107
|
+
/**
|
|
108
|
+
* Usercentrics V3 CMP API. Attached once the V3 Browser SDK is
|
|
109
|
+
* initialized. Optional because the SDK loads asynchronously — guard
|
|
110
|
+
* with a truthiness check before access.
|
|
111
|
+
*/
|
|
112
|
+
__ucCmp?: UsercentricsV3Api;
|
|
26
113
|
}
|
|
27
114
|
}
|
|
28
115
|
|
package/dist/dev.d.ts
CHANGED
|
@@ -23,6 +23,93 @@ interface UsercentricsEventDetail {
|
|
|
23
23
|
declare global {
|
|
24
24
|
interface WindowEventMap {
|
|
25
25
|
ucEvent: CustomEvent<UsercentricsEventDetail>;
|
|
26
|
+
UC_UI_CMP_EVENT: CustomEvent<UsercentricsV3CmpEventDetail>;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Usercentrics V2 service info shape returned by `UC_UI.getServicesBaseInfo()`.
|
|
31
|
+
* Only the fields we use are typed — minimal surface, not a full V2 API mirror.
|
|
32
|
+
*/
|
|
33
|
+
interface UsercentricsV2Service {
|
|
34
|
+
/** Category slug: 'essential' | 'functional' | 'marketing' | custom */
|
|
35
|
+
categorySlug: string;
|
|
36
|
+
/** Consent state for this service */
|
|
37
|
+
consent: {
|
|
38
|
+
status: boolean;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Usercentrics V2 window API (`window.UC_UI`).
|
|
43
|
+
*
|
|
44
|
+
* Methods are synchronous (unlike V3). All methods are optional because
|
|
45
|
+
* Usercentrics does not guarantee every deployment exposes every method.
|
|
46
|
+
*/
|
|
47
|
+
interface UsercentricsV2Api {
|
|
48
|
+
isInitialized?: () => boolean;
|
|
49
|
+
getServicesBaseInfo?: () => UsercentricsV2Service[];
|
|
50
|
+
areAllConsentsAccepted?: () => boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Usercentrics V3 category state. The SDK may add future states; we handle
|
|
54
|
+
* unknowns conservatively as non-accepting.
|
|
55
|
+
*/
|
|
56
|
+
type UsercentricsV3CategoryState = 'ALL_ACCEPTED' | 'ALL_DENIED' | 'SOME_ACCEPTED' | 'NO_STATE' | string;
|
|
57
|
+
/**
|
|
58
|
+
* Minimal V3 CategoryData — only fields the adapter reads.
|
|
59
|
+
*/
|
|
60
|
+
interface UsercentricsV3CategoryData {
|
|
61
|
+
state: UsercentricsV3CategoryState;
|
|
62
|
+
name: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Minimal V3 ConsentData — only the `type` field is used to distinguish
|
|
66
|
+
* explicit vs implicit consent. Other fields (status, version, etc.) exist on
|
|
67
|
+
* the real SDK but are not read by this adapter.
|
|
68
|
+
*/
|
|
69
|
+
interface UsercentricsV3ConsentData {
|
|
70
|
+
type: 'EXPLICIT' | 'IMPLICIT' | string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Minimal V3 ConsentDetails — only the fields the adapter reads.
|
|
74
|
+
* The real SDK also exposes `services`, but the adapter currently operates
|
|
75
|
+
* at category level only.
|
|
76
|
+
*/
|
|
77
|
+
interface UsercentricsV3ConsentDetails {
|
|
78
|
+
consent: UsercentricsV3ConsentData;
|
|
79
|
+
categories: Record<string, UsercentricsV3CategoryData>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Usercentrics V3 window API (`window.__ucCmp`).
|
|
83
|
+
*
|
|
84
|
+
* Only the methods this adapter calls are typed — the real SDK surface is
|
|
85
|
+
* much wider but we intentionally keep this narrow.
|
|
86
|
+
*/
|
|
87
|
+
interface UsercentricsV3Api {
|
|
88
|
+
isInitialized: () => Promise<boolean>;
|
|
89
|
+
getConsentDetails: () => Promise<UsercentricsV3ConsentDetails>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* V3 CMP event detail. Fired on `UC_UI_CMP_EVENT` (or custom name).
|
|
93
|
+
* `source: 'CMP'` + a decision `type` tells us a user action has been taken.
|
|
94
|
+
*/
|
|
95
|
+
interface UsercentricsV3CmpEventDetail {
|
|
96
|
+
source?: string;
|
|
97
|
+
type?: string;
|
|
98
|
+
}
|
|
99
|
+
declare global {
|
|
100
|
+
interface Window {
|
|
101
|
+
/**
|
|
102
|
+
* Usercentrics V2 CMP API. Attached once the V2 Browser SDK is
|
|
103
|
+
* initialized. Optional because the SDK loads asynchronously — guard
|
|
104
|
+
* with a truthiness check before access.
|
|
105
|
+
*/
|
|
106
|
+
UC_UI?: UsercentricsV2Api;
|
|
107
|
+
/**
|
|
108
|
+
* Usercentrics V3 CMP API. Attached once the V3 Browser SDK is
|
|
109
|
+
* initialized. Optional because the SDK loads asynchronously — guard
|
|
110
|
+
* with a truthiness check before access.
|
|
111
|
+
*/
|
|
112
|
+
__ucCmp?: UsercentricsV3Api;
|
|
26
113
|
}
|
|
27
114
|
}
|
|
28
115
|
|
|
@@ -21,6 +21,93 @@ interface UsercentricsEventDetail {
|
|
|
21
21
|
declare global {
|
|
22
22
|
interface WindowEventMap {
|
|
23
23
|
ucEvent: CustomEvent<UsercentricsEventDetail>;
|
|
24
|
+
UC_UI_CMP_EVENT: CustomEvent<UsercentricsV3CmpEventDetail>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Usercentrics V2 service info shape returned by `UC_UI.getServicesBaseInfo()`.
|
|
29
|
+
* Only the fields we use are typed — minimal surface, not a full V2 API mirror.
|
|
30
|
+
*/
|
|
31
|
+
interface UsercentricsV2Service {
|
|
32
|
+
/** Category slug: 'essential' | 'functional' | 'marketing' | custom */
|
|
33
|
+
categorySlug: string;
|
|
34
|
+
/** Consent state for this service */
|
|
35
|
+
consent: {
|
|
36
|
+
status: boolean;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Usercentrics V2 window API (`window.UC_UI`).
|
|
41
|
+
*
|
|
42
|
+
* Methods are synchronous (unlike V3). All methods are optional because
|
|
43
|
+
* Usercentrics does not guarantee every deployment exposes every method.
|
|
44
|
+
*/
|
|
45
|
+
interface UsercentricsV2Api {
|
|
46
|
+
isInitialized?: () => boolean;
|
|
47
|
+
getServicesBaseInfo?: () => UsercentricsV2Service[];
|
|
48
|
+
areAllConsentsAccepted?: () => boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Usercentrics V3 category state. The SDK may add future states; we handle
|
|
52
|
+
* unknowns conservatively as non-accepting.
|
|
53
|
+
*/
|
|
54
|
+
type UsercentricsV3CategoryState = 'ALL_ACCEPTED' | 'ALL_DENIED' | 'SOME_ACCEPTED' | 'NO_STATE' | string;
|
|
55
|
+
/**
|
|
56
|
+
* Minimal V3 CategoryData — only fields the adapter reads.
|
|
57
|
+
*/
|
|
58
|
+
interface UsercentricsV3CategoryData {
|
|
59
|
+
state: UsercentricsV3CategoryState;
|
|
60
|
+
name: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Minimal V3 ConsentData — only the `type` field is used to distinguish
|
|
64
|
+
* explicit vs implicit consent. Other fields (status, version, etc.) exist on
|
|
65
|
+
* the real SDK but are not read by this adapter.
|
|
66
|
+
*/
|
|
67
|
+
interface UsercentricsV3ConsentData {
|
|
68
|
+
type: 'EXPLICIT' | 'IMPLICIT' | string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Minimal V3 ConsentDetails — only the fields the adapter reads.
|
|
72
|
+
* The real SDK also exposes `services`, but the adapter currently operates
|
|
73
|
+
* at category level only.
|
|
74
|
+
*/
|
|
75
|
+
interface UsercentricsV3ConsentDetails {
|
|
76
|
+
consent: UsercentricsV3ConsentData;
|
|
77
|
+
categories: Record<string, UsercentricsV3CategoryData>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Usercentrics V3 window API (`window.__ucCmp`).
|
|
81
|
+
*
|
|
82
|
+
* Only the methods this adapter calls are typed — the real SDK surface is
|
|
83
|
+
* much wider but we intentionally keep this narrow.
|
|
84
|
+
*/
|
|
85
|
+
interface UsercentricsV3Api {
|
|
86
|
+
isInitialized: () => Promise<boolean>;
|
|
87
|
+
getConsentDetails: () => Promise<UsercentricsV3ConsentDetails>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* V3 CMP event detail. Fired on `UC_UI_CMP_EVENT` (or custom name).
|
|
91
|
+
* `source: 'CMP'` + a decision `type` tells us a user action has been taken.
|
|
92
|
+
*/
|
|
93
|
+
interface UsercentricsV3CmpEventDetail {
|
|
94
|
+
source?: string;
|
|
95
|
+
type?: string;
|
|
96
|
+
}
|
|
97
|
+
declare global {
|
|
98
|
+
interface Window {
|
|
99
|
+
/**
|
|
100
|
+
* Usercentrics V2 CMP API. Attached once the V2 Browser SDK is
|
|
101
|
+
* initialized. Optional because the SDK loads asynchronously — guard
|
|
102
|
+
* with a truthiness check before access.
|
|
103
|
+
*/
|
|
104
|
+
UC_UI?: UsercentricsV2Api;
|
|
105
|
+
/**
|
|
106
|
+
* Usercentrics V3 CMP API. Attached once the V3 Browser SDK is
|
|
107
|
+
* initialized. Optional because the SDK loads asynchronously — guard
|
|
108
|
+
* with a truthiness check before access.
|
|
109
|
+
*/
|
|
110
|
+
__ucCmp?: UsercentricsV3Api;
|
|
24
111
|
}
|
|
25
112
|
}
|
|
26
113
|
|
package/dist/examples/index.d.ts
CHANGED
|
@@ -21,6 +21,93 @@ interface UsercentricsEventDetail {
|
|
|
21
21
|
declare global {
|
|
22
22
|
interface WindowEventMap {
|
|
23
23
|
ucEvent: CustomEvent<UsercentricsEventDetail>;
|
|
24
|
+
UC_UI_CMP_EVENT: CustomEvent<UsercentricsV3CmpEventDetail>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Usercentrics V2 service info shape returned by `UC_UI.getServicesBaseInfo()`.
|
|
29
|
+
* Only the fields we use are typed — minimal surface, not a full V2 API mirror.
|
|
30
|
+
*/
|
|
31
|
+
interface UsercentricsV2Service {
|
|
32
|
+
/** Category slug: 'essential' | 'functional' | 'marketing' | custom */
|
|
33
|
+
categorySlug: string;
|
|
34
|
+
/** Consent state for this service */
|
|
35
|
+
consent: {
|
|
36
|
+
status: boolean;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Usercentrics V2 window API (`window.UC_UI`).
|
|
41
|
+
*
|
|
42
|
+
* Methods are synchronous (unlike V3). All methods are optional because
|
|
43
|
+
* Usercentrics does not guarantee every deployment exposes every method.
|
|
44
|
+
*/
|
|
45
|
+
interface UsercentricsV2Api {
|
|
46
|
+
isInitialized?: () => boolean;
|
|
47
|
+
getServicesBaseInfo?: () => UsercentricsV2Service[];
|
|
48
|
+
areAllConsentsAccepted?: () => boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Usercentrics V3 category state. The SDK may add future states; we handle
|
|
52
|
+
* unknowns conservatively as non-accepting.
|
|
53
|
+
*/
|
|
54
|
+
type UsercentricsV3CategoryState = 'ALL_ACCEPTED' | 'ALL_DENIED' | 'SOME_ACCEPTED' | 'NO_STATE' | string;
|
|
55
|
+
/**
|
|
56
|
+
* Minimal V3 CategoryData — only fields the adapter reads.
|
|
57
|
+
*/
|
|
58
|
+
interface UsercentricsV3CategoryData {
|
|
59
|
+
state: UsercentricsV3CategoryState;
|
|
60
|
+
name: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Minimal V3 ConsentData — only the `type` field is used to distinguish
|
|
64
|
+
* explicit vs implicit consent. Other fields (status, version, etc.) exist on
|
|
65
|
+
* the real SDK but are not read by this adapter.
|
|
66
|
+
*/
|
|
67
|
+
interface UsercentricsV3ConsentData {
|
|
68
|
+
type: 'EXPLICIT' | 'IMPLICIT' | string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Minimal V3 ConsentDetails — only the fields the adapter reads.
|
|
72
|
+
* The real SDK also exposes `services`, but the adapter currently operates
|
|
73
|
+
* at category level only.
|
|
74
|
+
*/
|
|
75
|
+
interface UsercentricsV3ConsentDetails {
|
|
76
|
+
consent: UsercentricsV3ConsentData;
|
|
77
|
+
categories: Record<string, UsercentricsV3CategoryData>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Usercentrics V3 window API (`window.__ucCmp`).
|
|
81
|
+
*
|
|
82
|
+
* Only the methods this adapter calls are typed — the real SDK surface is
|
|
83
|
+
* much wider but we intentionally keep this narrow.
|
|
84
|
+
*/
|
|
85
|
+
interface UsercentricsV3Api {
|
|
86
|
+
isInitialized: () => Promise<boolean>;
|
|
87
|
+
getConsentDetails: () => Promise<UsercentricsV3ConsentDetails>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* V3 CMP event detail. Fired on `UC_UI_CMP_EVENT` (or custom name).
|
|
91
|
+
* `source: 'CMP'` + a decision `type` tells us a user action has been taken.
|
|
92
|
+
*/
|
|
93
|
+
interface UsercentricsV3CmpEventDetail {
|
|
94
|
+
source?: string;
|
|
95
|
+
type?: string;
|
|
96
|
+
}
|
|
97
|
+
declare global {
|
|
98
|
+
interface Window {
|
|
99
|
+
/**
|
|
100
|
+
* Usercentrics V2 CMP API. Attached once the V2 Browser SDK is
|
|
101
|
+
* initialized. Optional because the SDK loads asynchronously — guard
|
|
102
|
+
* with a truthiness check before access.
|
|
103
|
+
*/
|
|
104
|
+
UC_UI?: UsercentricsV2Api;
|
|
105
|
+
/**
|
|
106
|
+
* Usercentrics V3 CMP API. Attached once the V3 Browser SDK is
|
|
107
|
+
* initialized. Optional because the SDK loads asynchronously — guard
|
|
108
|
+
* with a truthiness check before access.
|
|
109
|
+
*/
|
|
110
|
+
__ucCmp?: UsercentricsV3Api;
|
|
24
111
|
}
|
|
25
112
|
}
|
|
26
113
|
|
package/dist/index.browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var SourceUsercentrics=(()=>{var e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r=(n,t)=>{for(var o in t)e(n,o,{get:t[o],enumerable:!0})},s={};r(s,{SourceUsercentrics:()=>i,createMockElbFn:()=>w,createTrigger:()=>Ue,default:()=>Ke,fullConsent:()=>a,fullConsentCustomMapped:()=>m,fullConsentMapped:()=>p,fullConsentUpperCase:()=>f,implicitConsent:()=>l,minimalConsent:()=>u,minimalConsentMapped:()=>y,nonConsentEvent:()=>d,noopLogger:()=>k,partialConsent:()=>c,partialConsentMapped:()=>v,serviceLevelConsent:()=>g,serviceLevelMapped:()=>h,sourceUsercentrics:()=>Le,step:()=>j,trigger:()=>Ge});var i={},a={event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0},"Google Analytics":!0,"Google Ads Remarketing":!0},c={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:!0,marketing:!1},"Google Analytics":!0,"Google Ads Remarketing":!1},u={event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},l={event:"consent_status",type:"implicit",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},f={event:"consent_status",type:"EXPLICIT",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},g={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:"partial",marketing:"partial"},"Google Analytics":!0,"Google Ads Remarketing":!1,Hotjar:!0},d={event:"other_event",type:"explicit"},p={essential:!0,functional:!0,marketing:!0},v={essential:!0,functional:!0,marketing:!1},y={essential:!0,functional:!1,marketing:!1},m={functional:!0,marketing:!0},h={essential:!0,google_analytics:!0,google_ads_remarketing:!1,hotjar:!0},b=()=>{},w=()=>()=>Promise.resolve({ok:!0}),k={error:b,warn:b,info:b,debug:b,throw:e=>{throw"string"==typeof e?new Error(e):e},json:b,scope:()=>k},j={};r(j,{categoryMapOverride:()=>x,customEventName:()=>C,fullConsent:()=>O,minimalConsent:()=>A});var O={title:"Full consent",description:"A Usercentrics onAcceptAllServices event emits a walker consent command with essential, functional, and marketing granted.",trigger:{type:"consent"},in:{event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},out:[["elb","walker consent",{essential:!0,functional:!0,marketing:!0}]]},A={title:"Minimal consent",description:"A Usercentrics onDenyAllServices event emits a walker consent command with only essential granted.",trigger:{type:"consent"},in:{event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1}},out:[["elb","walker consent",{essential:!0,functional:!1,marketing:!1}]]},x={title:"Category map override",description:"Custom categoryMap remaps essential to functional and functional to analytics",trigger:{type:"consent"},in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!1}},mapping:{categoryMap:{essential:"functional",functional:"analytics"}},out:[["elb","walker consent",{functional:!0,analytics:!0,marketing:!1}]]},C={title:"Custom event name",description:"Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",trigger:{type:"consent",options:{eventName:"UC_SDK_EVENT"}},in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!0}},mapping:{eventName:"UC_SDK_EVENT"},out:[["elb","walker consent",{essential:!0,functional:!0,marketing:!0}]]},S=Object.defineProperty;((e,n)=>{for(var t in n)S(e,t,{get:n[t],enumerable:!0})})({},{Level:()=>_});var E,_=((E=_||{})[E.ERROR=0]="ERROR",E[E.WARN=1]="WARN",E[E.INFO=2]="INFO",E[E.DEBUG=3]="DEBUG",E);function $(e){return{_meta:{hops:0,path:[e]}}}var q={merge:!0,shallow:!0,extend:!0};function D(e,n={},t={}){t={...q,...t};const o=Object.entries(n).reduce((n,[o,r])=>{const s=e[o];return t.merge&&Array.isArray(s)&&Array.isArray(r)?n[o]=r.reduce((e,n)=>e.includes(n)?e:[...e,n],[...s]):(t.extend||o in e)&&(n[o]=r),n},{});return t.shallow?{...e,...o}:(Object.assign(e,o),e)}function P(e){return Array.isArray(e)}function M(e){return void 0!==e}function R(e){return"function"==typeof e}function I(e){return"object"==typeof e&&null!==e&&!P(e)&&"[object Object]"===Object.prototype.toString.call(e)}function N(e){return"string"==typeof e}function T(e,n=new WeakMap){if("object"!=typeof e||null===e)return e;if(n.has(e))return n.get(e);const t=Object.prototype.toString.call(e);if("[object Object]"===t){const t={};n.set(e,t);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=T(e[o],n));return t}if("[object Array]"===t){const t=[];return n.set(e,t),e.forEach(e=>{t.push(T(e,n))}),t}if("[object Date]"===t)return new Date(e.getTime());if("[object RegExp]"===t){const n=e;return new RegExp(n.source,n.flags)}return e}function U(e,n="",t){const o=n.split(".");let r=e;for(let e=0;e<o.length;e++){const n=o[e];if("*"===n&&P(r)){const n=o.slice(e+1).join("."),s=[];for(const e of r){const o=U(e,n,t);s.push(o)}return s}if(r=r instanceof Object?r[n]:void 0,void 0===r)break}return M(r)?r:t}function G(e,n,t){if(!I(e))return e;const o=T(e),r=n.split(".");let s=o;for(let e=0;e<r.length;e++){const n=r[e];e===r.length-1?s[n]=t:(n in s&&"object"==typeof s[n]&&null!==s[n]||(s[n]={}),s=s[n])}return o}var H={data:e=>e.data,globals:e=>e.globals,context:e=>e.context,user:e=>e.user,source:e=>e.source,version:e=>e.version,event:e=>({entity:e.entity,action:e.action,id:e.id,timestamp:e.timestamp,name:e.name,trigger:e.trigger,group:e.group,count:e.count,timing:e.timing})};function L(e,n={},t={}){const o={...n,...t},r={};let s=!e||0===Object.keys(e).length;return Object.keys(o).forEach(n=>{o[n]&&(r[n]=!0,e&&e[n]&&(s=!0))}),!!s&&r}function K(e=6,n){if(n){const t=n.length;let o="";for(let r=0;r<e;r++)o+=n[Math.random()*t|0];return o}let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function B(e,n=1e3,t=!1){let o,r=null,s=!1;return(...i)=>new Promise(a=>{const c=t&&!s;r&&clearTimeout(r),r=setTimeout(()=>{r=null,t&&!s||(o=e(...i),a(o))},n),c&&(s=!0,o=e(...i),a(o))})}function W(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function F(e,n){let t,o={};return e instanceof Error?(t=e.message,o.error=W(e)):t=e,void 0!==n&&(n instanceof Error?o.error=W(n):"object"==typeof n&&null!==n?(o={...o,...n},"error"in o&&o.error instanceof Error&&(o.error=W(o.error))):o.value=n),{message:t,context:o}}var V=(e,n,t,o)=>{const r=`${_[e]}${o.length>0?` [${o.join(":")}]`:""}`,s=Object.keys(t).length>0,i=0===e?console.error:1===e?console.warn:console.log;s?i(r,n,t):i(r,n)};function z(e={}){return J({level:void 0!==e.level?(n=e.level,"string"==typeof n?_[n]:n):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]});var n}function J(e){const{level:n,handler:t,jsonHandler:o,scope:r}=e,s=(e,o,s)=>{if(e<=n){const n=F(o,s);t?t(e,n.message,n.context,r,V):V(e,n.message,n.context,r)}};return{error:(e,n)=>s(0,e,n),warn:(e,n)=>s(1,e,n),info:(e,n)=>s(2,e,n),debug:(e,n)=>s(3,e,n),throw:(e,n)=>{const o=F(e,n);throw t?t(0,o.message,o.context,r,V):V(0,o.message,o.context,r),new Error(o.message)},json:e=>{o?o(e):console.log(JSON.stringify(e,null,2))},scope:e=>J({level:n,handler:t,jsonHandler:o,scope:[...r,e]})}}function X(e){return function(e){return"boolean"==typeof e}(e)||N(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!M(e)||P(e)&&e.every(X)||I(e)&&Object.values(e).every(X)}function Q(e){return X(e)?e:void 0}function Y(e,n,t){return function(...o){try{return e(...o)}catch(e){if(!n)return;return n(e)}finally{null==t||t()}}}function Z(e,n,t){return async function(...o){try{return await e(...o)}catch(e){if(!n)return;return await n(e)}finally{await(null==t?void 0:t())}}}async function ee(e,n={},t={}){var o;if(!M(e))return;const r=I(e)&&e.consent||t.consent||(null==(o=t.collector)?void 0:o.consent),s=P(n)?n:[n];for(const n of s){const o=await Z(ne)(e,n,{...t,consent:r});if(M(o))return o}}async function ne(e,n,t={}){const{collector:o,consent:r}=t;return(P(n)?n:[n]).reduce(async(n,s)=>{const i=await n;if(i)return i;const a=N(s)?{key:s}:s;if(!Object.keys(a).length)return;const{condition:c,consent:u,fn:l,key:f,loop:g,map:d,set:p,validate:v,value:y}=a;if(c&&!await Z(c)(e,s,o))return;if(u&&!L(u,r))return y;let m=M(y)?y:e;if(l&&(m=await Z(l)(e,s,t)),f&&(m=U(e,f,y)),g){const[n,o]=g,r="this"===n?[e]:await ee(e,n,t);P(r)&&(m=(await Promise.all(r.map(e=>ee(e,o,t)))).filter(M))}else d?m=await Object.entries(d).reduce(async(n,[o,r])=>{const s=await n,i=await ee(e,r,t);return M(i)&&(s[o]=i),s},Promise.resolve({})):p&&(m=await Promise.all(p.map(n=>ne(e,n,t))));v&&!await Z(v)(m)&&(m=void 0);const h=Q(m);return M(h)?h:Q(y)},Promise.resolve(void 0))}async function te(e,n,t){var o;n.policy&&await Promise.all(Object.entries(n.policy).map(async([n,o])=>{const r=await ee(e,o,{collector:t});e=G(e,n,r)}));const{eventMapping:r,mappingKey:s}=await async function(e,n){var t;const[o,r]=(e.name||"").split(" ");if(!n||!o||!r)return{};let s,i="",a=o,c=r;const u=n=>{if(n)return(n=P(n)?n:[n]).find(n=>!n.condition||n.condition(e))};n[a]||(a="*");const l=n[a];return l&&(l[c]||(c="*"),s=u(l[c])),s||(a="*",c="*",s=u(null==(t=n[a])?void 0:t[c])),s&&(i=`${a} ${c}`),{eventMapping:s,mappingKey:i}}(e,n.mapping);(null==r?void 0:r.policy)&&await Promise.all(Object.entries(r.policy).map(async([n,o])=>{const r=await ee(e,o,{collector:t});e=G(e,n,r)}));let i=n.data&&await ee(e,n.data,{collector:t});const a=Boolean(null==r?void 0:r.skip);if(r){if(r.ignore)return{event:e,data:i,mapping:r,mappingKey:s,ignore:!0,skip:a};if(r.name&&(e.name=r.name),r.data){const n=r.data&&await ee(e,r.data,{collector:t});i=I(i)&&I(n)?D(i,n):n}}const c=null!=(o=null==r?void 0:r.include)?o:n.include;if(c&&c.length>0){const n=function(e,n){const t={},o=n.includes("all")?Object.keys(H):n;for(const n of o){const o=H[n];if(!o)continue;const r=o(e);if(I(r))for(const[e,o]of Object.entries(r)){if(void 0===o)continue;const r="context"===n&&Array.isArray(o)?o[0]:o;t[`${n}_${e}`]=r}}return t}(e,c);Object.keys(n).length>0&&(i=I(i)?D(n,i):null!=i?i:n)}return{event:e,data:i,mapping:r,mappingKey:s,ignore:!1,skip:a}}function oe(e,n,t,o){return function(...r){let s;const i="pre"+n,a="post"+n,c=t[i],u=t[a],l=(e,n)=>{o?o.warn(e,{error:n}):console.warn(e,n)};if(c)try{s=c({fn:e},...r)}catch(n){l(`Hook ${String(i)} failed, falling back to original function`,n),s=e(...r)}else s=e(...r);if(u)try{s=u({fn:e,result:s},...r)}catch(e){l(`Hook ${String(a)} failed, keeping original result`,e)}return s}}function re(e){if("*"===e)return()=>!0;if("and"in e){const n=e.and.map(re);return e=>n.every(n=>n(e))}if("or"in e){const n=e.or.map(re);return e=>n.some(n=>n(e))}return function(e){const{key:n,operator:t,value:o,not:r}=e,s=function(e,n){switch(e){case"eq":return e=>String(null!=e?e:"")===n;case"contains":return e=>String(null!=e?e:"").includes(n);case"prefix":return e=>String(null!=e?e:"").startsWith(n);case"suffix":return e=>String(null!=e?e:"").endsWith(n);case"regex":{const e=new RegExp(n);return n=>e.test(String(null!=n?n:""))}case"gt":{const e=Number(n);return n=>Number(n)>e}case"lt":{const e=Number(n);return n=>Number(n)<e}case"exists":return e=>null!=e}}(t,o);return e=>{const t=U(e,n),o=s(t);return r?!o:o}}(e)}function se(e){return Array.isArray(e)&&e.length>0&&"object"==typeof e[0]&&null!==e[0]&&"match"in e[0]}function ie(e){if(null!=e){if("string"==typeof e)return{type:"static",value:e};if(Array.isArray(e)){if(0===e.length)return;return se(e)?{type:"routes",routes:e.map(e=>({match:re(e.match),next:ie(e.next)}))}:{type:"chain",value:e}}}}function ae(e,n={}){if(e){if("static"===e.type)return e.value;if("chain"===e.type)return e.value;for(const t of e.routes)if(t.match(n))return ae(t.next,n)}}function ce(e,n){const t={ingest:null!=e?e:{}};return void 0!==n&&(t.event=n),t}function ue(e){var n;return{full:null!=(n=e.full)&&n,storeId:e.store,rules:e.rules.map(e=>({match:re(e.match),key:e.key,ttl:e.ttl,update:e.update}))}}function le(e,n,t,o){const r=e.rules.find(e=>e.match(t));if(!r)return null;const s=r.key.map(e=>{var n;return String(null!=(n=U(t,e))?n:"")});if(s.every(e=>""===e))return null;const i=`${o}:${s.join(":")}`,a=n.get(i);return void 0!==a?{status:"HIT",key:i,value:a,rule:r}:{status:"MISS",key:i,rule:r}}function fe(e,n,t,o){e.set(n,t,1e3*o)}async function ge(e,n,t){if(!n)return e;let o=e;for(const[e,r]of Object.entries(n))o=G(o,e,await ee(t,r));return o}var de={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",Shutdown:"shutdown",User:"user",Walker:"walker"};function pe(e,n){return e.storeId&&n.stores[e.storeId]?n.stores[e.storeId]:n.stores.__cache}function ve(e){var n;const t={};for(const[o,r]of Object.entries(e)){const e=null==(n=r.config)?void 0:n.next;e&&!se(e)?t[o]={next:e}:t[o]={}}return t}function ye(e,n){const t=e.config||{},o=e[n];return void 0!==o?{config:{...t,[n]:o},chainValue:o}:{config:t,chainValue:void 0}}function me(e,n={}){if(!e)return[];if(Array.isArray(e))return e;const t=[],o=new Set;let r=e;for(;r&&n[r]&&!o.has(r);){o.add(r),t.push(r);const e=n[r].next;if(Array.isArray(e)){t.push(...e);break}r=e}return t}async function he(e,n,t){if(n.init&&!n.config.init){const o=n.type||"unknown",r=e.logger.scope(`transformer:${o}`),s={collector:e,logger:r,id:t,ingest:$(t),config:n.config,env:ke(n.config.env)};r.debug("init");const i=await oe(n.init,"TransformerInit",e.hooks,e.logger)(s);if(!1===i)return!1;n.config={...i||n.config,env:(null==i?void 0:i.env)||n.config.env,init:!0},r.debug("init done")}return!0}async function be(e,n,t,o,r,s){const i=n.type||"unknown",a=e.logger.scope(`transformer:${i}`),c={collector:e,logger:a,id:t,ingest:r,config:n.config,env:{...ke(n.config.env),...s?{respond:s}:{}}};a.debug("push",{event:o.name});const u=await oe(n.push,"TransformerPush",e.hooks,e.logger)(o,c);return a.debug("push done"),u}async function we(e,n,t,o,r,s,i){var a,c,u,l,f,g;i&&(null==r?void 0:r._meta)&&(r._meta.chainPath=i);let d=o,p=s;for(const o of t){const s=n[o];if(!s){e.logger.warn(`Transformer not found: ${o}`);continue}if(r&&r._meta&&r._meta.path.length>256)return e.logger.error(`Max path length exceeded at ${o}`),{event:null,respond:p};if(r&&r._meta&&(r._meta.hops++,r._meta.path.push(o)),!await Z(he)(e,s,o))return e.logger.error(`Transformer init failed: ${o}`),{event:null,respond:p};if(i&&void 0!==(null==(c=null==(a=s.config)?void 0:a.chainMocks)?void 0:c[i])){const n=s.config.chainMocks[i];e.logger.scope(`transformer:${s.type||"unknown"}`).debug("chainMock",{chain:i}),d=n;continue}if(void 0!==(null==(u=s.config)?void 0:u.mock)){e.logger.scope(`transformer:${s.type||"unknown"}`).debug("mock"),d=s.config.mock;continue}if(null==(l=s.config)?void 0:l.disabled)continue;const v=null==(f=s.config)?void 0:f.cache,y=v?ue(v):void 0,m=y?pe(y,e):void 0;let h;if(y&&m){const e=le(y,m,ce(r,d),`t:${o}`);if("HIT"===(null==e?void 0:e.status)&&e.value){if(d=e.value,y.full)return{event:d,respond:p};continue}"MISS"===(null==e?void 0:e.status)&&(h={key:e.key,ttl:e.rule.ttl})}const b=s.config.before;if(b){const t=me("string"==typeof b||Array.isArray(b)&&!se(b)?b:ae(ie(b),ce(r,d))||void 0,ve(n));if(t.length>0){const o=await we(e,n,t,d,r,p,i);if(null===o.event)return{event:null,respond:null!=(g=o.respond)?g:p};o.respond&&(p=o.respond),d=Array.isArray(o.event)?o.event[0]:o.event}}const w=await Z(be,n=>(e.logger.scope(`transformer:${s.type||"unknown"}`).error("Push failed",{error:n}),!1))(e,s,o,d,r,p);if(!1===w)return{event:null,respond:p};if(Array.isArray(w)){const s=t.slice(t.indexOf(o)+1),a=await Promise.all(w.map(async t=>{const o=t.event||d,a=r?{...r,_meta:{...r._meta,path:[...r._meta.path]}}:$("unknown");if(t.next){let r=t.next;if(se(t.next)){r=ae(ie(t.next),ce(a,o))}if(r){const t=me(r,ve(n));if(t.length>0)return we(e,n,t,o,a,p,i)}return{event:o,respond:p}}return s.length>0?we(e,n,s,o,a,p,i):{event:o,respond:p}}));let c=p;const u=[];for(const e of a.flat())if(null!==e)if(e&&"object"==typeof e&&"event"in e){const n=e;if(n.respond&&(c=n.respond),null===n.event)continue;Array.isArray(n.event)?u.push(...n.event):u.push(n.event)}else u.push(e);return 0===u.length?{event:null,respond:c}:1===u.length?{event:u[0],respond:c}:{event:u,respond:c}}if(w&&"object"==typeof w){const{event:t,respond:o,next:s}=w;if(o&&(p=o),s){let o=s;if(se(s)){if(o=ae(ie(s),ce(r,d)),!o){t&&(d=t);continue}}const a=me(o,ve(n));return a.length>0?we(e,n,a,t||d,r,p,i):(e.logger.warn(`Branch target not found: ${JSON.stringify(s)}`),{event:null,respond:p})}t&&(d=t)}if(h&&m&&fe(m,h.key,d,h.ttl),(!w||"object"==typeof w&&!w.next)&&s.config.next&&se(s.config.next)){const t=ae(ie(s.config.next),ce(r,d));if(t){const o=me(t,ve(n));if(o.length>0)return we(e,n,o,d,r,p,i)}return{event:d,respond:p}}}return{event:d,respond:p}}function ke(e){return e&&I(e)?e:{}}async function je(e,n,t){var o;const{code:r,config:s={},env:i={},primary:a,next:c,before:u,cache:l}=t;let f,g=$(n);const d=l?ue({...l,full:null==(o=l.full)||o}):void 0,p=ie(c),v=Array.isArray(c)&&se(c)||!p?void 0:me(ae(p),ve(e.transformers)),y=ie(u),m=Array.isArray(u)&&se(u)||!y?void 0:me(ae(y),ve(e.transformers)),h=e.logger.scope("source").scope(n),b={push:async(t,o={})=>{let r,i=t;const a=null!=m?m:y?me(ae(y,ce(g)),ve(e.transformers)):[];if(a.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const t=await we(e,e.transformers,a,i,g,f,`source.${n}.before`);if(null===t.event)return{ok:!0};t.respond&&(f=t.respond),i=Array.isArray(t.event)?t.event[0]:t.event}if(d){const t=pe(d,e);if(t){const e=ce(g),o=le(d,t,e,`s:${n}`);if(o){if("HIT"===o.status&&void 0!==o.value&&d.full){let n=o.value;return o.rule.update&&(n=await ge(n,o.rule.update,{...e,cache:{status:"HIT"}})),null==f||f(n),{ok:!0}}if("MISS"===o.status&&d.full&&f){const n=f,s=o.rule.update,i={...e,cache:{status:"MISS"}},a=o.key,c=o.rule.ttl;f=e=>{fe(t,a,e,c),s?r=(async()=>{const t=await ge(e,s,i);n(t)})():n(e)}}"MISS"!==o.status||d.full||fe(t,o.key,!0,o.rule.ttl)}}}const c=null!=v?v:p?me(ae(p,ce(g)),ve(e.transformers)):[],u=await e.push(i,{...o,id:n,ingest:g,respond:f,mapping:s,preChain:c});return r&&await r,u},command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:h,...i},w={collector:e,logger:h,id:n,config:s,env:b,setIngest:async t=>{if(!s.ingest)return void(g=$(n));const o=await ee(t,s.ingest,{collector:e}),r=$(n);g={...r,...o,_meta:r._meta}},setRespond:e=>{f=e}},k=await Z(r)(w);if(!k)return;const j=k.type||"unknown",O=e.logger.scope(j).scope(n);return b.logger=O,a&&(k.config={...k.config,primary:a}),k}function Oe(e,n,t,o,r){if(!n.on)return;const s=n.type||"unknown",i=e.logger.scope(s).scope("on").scope(o),a={collector:e,logger:i,id:t,config:n.config,data:r,env:De(n.env,n.config.env)};Y(n.on)(o,a)}function Ae(e,n,t,o){let r;switch(n){case de.Consent:r=o||e.consent;break;case de.Session:r=e.session;break;case de.User:r=o||e.user;break;case de.Custom:r=o||e.custom;break;case de.Globals:r=o||e.globals;break;case de.Config:r=o||e.config;break;case de.Ready:case de.Run:default:r=void 0}if(t.length)switch(n){case de.Consent:!function(e,n,t){const o=t||e.consent;n.forEach(n=>{Object.keys(o).filter(e=>e in n).forEach(t=>{Y(n[t])(e,o)})})}(e,t,o);break;case de.Ready:case de.Run:i=t,(s=e).allowed&&i.forEach(e=>{Y(e)(s)});break;case de.Session:!function(e,n){e.session&&n.forEach(n=>{Y(n)(e,e.session)})}(e,t);break;default:t.forEach(n=>{"function"==typeof n&&Y(n)(e,r)})}var s,i}function xe(e,n,t,o){if(!e)return[];if(n){const e=ae(n,ce(o));return e?me(e,ve(t)):[]}return me(e,ve(t))}async function Ce(e,n,t){const{code:o,config:r={},env:s={},before:i,next:a,cache:c}=n;if(!R(o.push))return $e({ok:!1,failed:{invalid:{type:"invalid",error:"Destination code must have a push method"}}});const u=t||r||{init:!1};let l=i?{...u,before:i}:{...u};a&&(l={...l,next:a}),c&&(l={...l,cache:c});const f={...o,config:l,env:De(o.env,s)};let g=f.config.id;if(!g)do{g=K(5,"abcdefghijklmnopqrstuvwxyz")}while(e.destinations[g]);return e.destinations[g]=f,!1!==f.config.queue&&(f.queuePush=[...e.queue]),Se(e,void 0,{},{[g]:f})}async function Se(e,n,t={},o){const{allowed:r,consent:s,globals:i,user:a}=e;if(!r)return $e({ok:!1});n&&(e.queue.push(n),e.status.in++),o||(o=e.destinations);const c=await Promise.all(Object.entries(o||{}).map(async([o,r])=>{var c,u,l;if(r.config.disabled)return{id:o,destination:r,skipped:!0};let f=(r.queuePush||[]).map(e=>({...e,consent:s}));r.queuePush=[],n&&f.push(T(n));const g=t.ingest?{...t.ingest,_meta:{...t.ingest._meta,path:[...t.ingest._meta.path]}}:$("unknown");if(!f.length&&!(null==(c=r.queueOn)?void 0:c.length))return{id:o,destination:r,skipped:!0};if(!f.length&&(null==(u=r.queueOn)?void 0:u.length)){const n=await Z(Ee)(e,r,o);return{id:o,destination:r,skipped:!n}}const d=[],p=f.filter(e=>{const n=L(r.config.consent,s,e.consent);return!n||(e.consent=n,d.push(e),!1)});if(r.queuePush.push(...p),!d.length)return{id:o,destination:r,queue:f};if(!await Z(Ee)(e,r,o))return{id:o,destination:r,queue:f};let v,y;r.dlq||(r.dlq=[]);const m=r.config.before,h=xe(m,m&&se(m)?ie(m):void 0,e.transformers,g),b=r.config.next,w=b&&se(b)?ie(b):void 0,k=null==(l=r.config)?void 0:l.cache,j=k?ue(k):void 0,O=j?pe(j,e):void 0;let A=0;return await Promise.all(d.map(async n=>{let s;if(n.globals=D(i,n.globals),n.user=D(a,n.user),(null==j?void 0:j.full)&&O){const e=ce(g,n),t=le(j,O,e,`d:${o}`);if("HIT"===(null==t?void 0:t.status))return n;"MISS"===(null==t?void 0:t.status)&&(s={key:t.key,ttl:t.rule.ttl})}let c=n,u=t.respond;if(h.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const r=await we(e,e.transformers,h,n,g,t.respond,`destination.${o}.before`);if(null===r.event)return n;r.respond&&(u=r.respond),c=Array.isArray(r.event)?r.event[0]:r.event}if(j&&!j.full&&O){const e=ce(g,c),t=le(j,O,e,`d:${o}`);if("HIT"===(null==t?void 0:t.status))return n;"MISS"===(null==t?void 0:t.status)&&(s={key:t.key,ttl:t.rule.ttl})}const l=Date.now();let f=!1;const d=await Z(_e,n=>{const t=r.type||"unknown";e.logger.scope(t).error("Push failed",{error:n,event:c.name}),v=n,f=!0,r.dlq.push([c,n])})(e,r,o,c,g,u);if(A+=Date.now()-l,s&&O&&void 0===r.config.mock&&fe(O,s.key,null==d||d,s.ttl),void 0!==d&&(y=d),!f&&b){void 0!==d&&(g._response=d);const n=xe(b,w,e.transformers,g);if(n.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const t=await we(e,e.transformers,n,c,g,u,`destination.${o}.next`);t.respond&&(u=t.respond)}}return n})),{id:o,destination:r,error:v,response:y,totalDuration:A}})),u={},l={},f={};for(const n of c){if(n.skipped)continue;const t={type:n.destination.type||"unknown",data:n.response};e.status.destinations[n.id]||(e.status.destinations[n.id]={count:0,failed:0,duration:0});const o=e.status.destinations[n.id],r=Date.now();n.error?(t.error=n.error,f[n.id]=t,o.failed++,o.lastAt=r,o.duration+=n.totalDuration||0,e.status.failed++):n.queue&&n.queue.length?l[n.id]=t:(u[n.id]=t,o.count++,o.lastAt=r,o.duration+=n.totalDuration||0,e.status.out++)}return $e({event:n,...Object.keys(u).length&&{done:u},...Object.keys(l).length&&{queued:l},...Object.keys(f).length&&{failed:f}})}async function Ee(e,n,t){var o;if(n.init&&!n.config.init){const r=n.type||"unknown",s=e.logger.scope(r),i={collector:e,logger:s,id:t,config:n.config,env:De(n.env,n.config.env)};s.debug("init");const a=await oe(n.init,"DestinationInit",e.hooks,e.logger)(i);if(!1===a)return a;if(n.config={...a||n.config,init:!0},null==(o=n.queueOn)?void 0:o.length){const o=n.queueOn;n.queueOn=[];for(const{type:r,data:s}of o)Oe(e,n,t,r,s)}s.debug("init done")}return!0}async function _e(e,n,t,o,r,s){const{config:i}=n,a=await te(o,i,e);if(a.ignore)return!1;const c=n.type||"unknown",u=e.logger.scope(c),l={collector:e,logger:u,id:t,config:i,data:a.data,rule:a.mapping,ingest:r,env:{...De(n.env,i.env),...s?{respond:s}:{}}};if(void 0!==i.mock)return u.debug("mock",{event:a.event.name}),i.mock;const f=a.mapping,g=a.mappingKey||"* *";if(!(null==f?void 0:f.batch)||!n.pushBatch||void 0!==i.mock){u.debug("push",{event:a.event.name});const t=await oe(n.push,"DestinationPush",e.hooks,e.logger)(a.event,l);return u.debug("push done"),t}{if(n.batches=n.batches||{},!n.batches[g]){const o={key:g,events:[],data:[]};n.batches[g]={batched:o,batchFn:B(()=>{const o=n.batches[g].batched,a={collector:e,logger:u,id:t,config:i,data:void 0,rule:f,ingest:r,env:{...De(n.env,i.env),...s?{respond:s}:{}}};u.debug("push batch",{events:o.events.length}),oe(n.pushBatch,"DestinationPushBatch",e.hooks,e.logger)(o,a),u.debug("push batch done"),o.events=[],o.data=[]},f.batch)}}const o=n.batches[g];o.batched.events.push(a.event),M(a.data)&&o.batched.data.push(a.data),o.batchFn()}return!0}function $e(e){return{ok:!(null==e?void 0:e.failed),...e}}function qe(e){const{code:n,config:t={},env:o={},cache:r}=e,{config:s}=ye(e,"before"),{config:i}=ye({...e,config:s},"next"),a={...n.config,...t,...i};r&&(a.cache=r);const c=De(n.env,o);return{...n,config:a,env:c}}function De(e,n){return e||n?n?e&&I(e)&&I(n)?{...e,...n}:n:e:{}}async function Pe(e,n,t){const o=Object.entries(e).map(async([e,o])=>{var r;const s=o.destroy;if(!s)return;const i=o.type||"unknown",a=t.scope(i),c={id:e,config:o.config,env:null!=(r=o.env)?r:{},logger:a};try{await Promise.race([s(c),new Promise((t,o)=>setTimeout(()=>o(new Error(`${n} '${e}' destroy timed out`)),5e3))])}catch(t){a.error(`${n} '${e}' destroy failed: ${t}`)}});await Promise.allSettled(o)}async function Me(e,n,t,o){let r,s,i=!1;switch(n){case de.Config:I(t)&&(D(e.config,t,{shallow:!1}),s=t,i=!0);break;case de.Consent:if(I(t)){const{update:n}=function(e,n){const t={};return Object.entries(n).forEach(([e,n])=>{t[e]=!!n}),e.consent=D(e.consent,t),{update:t}}(e,t);s=n,i=!0}break;case de.Custom:I(t)&&(e.custom=D(e.custom,t),s=t,i=!0);break;case de.Destination:I(t)&&("code"in t&&I(t.code)?r=await Ce(e,t,o):R(t.push)&&(r=await Ce(e,{code:t},o)));break;case de.Globals:I(t)&&(e.globals=D(e.globals,t),s=t,i=!0);break;case de.On:N(t)&&await async function(e,n,t){const o=e.on,r=o[n]||[],s=P(t)?t:[t];s.forEach(e=>{r.push(e)}),o[n]=r,Ae(e,n,s)}(e,t,o);break;case de.Ready:i=!0;break;case de.Run:r=await async function(e,n){return e.allowed=!0,e.count=0,e.group=K(),e.timing=Date.now(),n&&(n.consent&&(e.consent=D(e.consent,n.consent)),n.user&&(e.user=D(e.user,n.user)),n.globals&&(e.globals=D(e.config.globalsStatic||{},n.globals)),n.custom&&(e.custom=D(e.custom,n.custom))),Object.values(e.destinations).forEach(e=>{e.queuePush=[]}),e.queue=[],e.round++,await Se(e)}(e,t),i=!0;break;case de.Session:i=!0;break;case de.Shutdown:await async function(e){const n=e.logger;await Pe(e.sources,"source",n),await Pe(e.destinations,"destination",n),await Pe(e.transformers,"transformer",n),await Pe(e.stores,"store",n)}(e);break;case de.User:I(t)&&(D(e.user,t,{shallow:!1}),s=t,i=!0)}return i&&(await async function(e,n,t,o){let r,s=t||[];switch(t||(s=e.on[n]||[]),n){case de.Consent:r=o||e.consent;break;case de.Session:r=e.session;break;case de.User:r=o||e.user;break;case de.Custom:r=o||e.custom;break;case de.Globals:r=o||e.globals;break;case de.Config:r=o||e.config;break;case de.Ready:case de.Run:default:r=void 0}let i=!1;for(const t of Object.values(e.sources))t.on&&!1===await Z(t.on)(n,r)&&(i=!0);return Object.entries(e.destinations).forEach(([t,o])=>{if(o.on){if(!o.config.init)return o.queueOn=o.queueOn||[],void o.queueOn.push({type:n,data:r});Oe(e,o,t,n,r)}}),(Object.keys(e.pending.sources).length>0||Object.keys(e.pending.destinations).length>0)&&await async function(e,n){var t,o;for(const[o,r]of Object.entries(e.pending.sources)){if(!e.pending.sources[o]||e.sources[o])continue;const s=null==(t=r.config)?void 0:t.require;if(!s)continue;const i=s.indexOf(n);if(-1===i)continue;if(s.splice(i,1),s.length>0)continue;delete e.pending.sources[o];const a=await je(e,o,r);a&&(e.sources[o]=a)}for(const[t,r]of Object.entries(e.pending.destinations)){if(!e.pending.destinations[t]||e.destinations[t])continue;const s=null==(o=r.config)?void 0:o.require;if(!s)continue;const i=s.indexOf(n);if(-1===i)continue;if(s.splice(i,1),s.length>0)continue;delete e.pending.destinations[t];const a=qe(r);!1!==a.config.queue&&(a.queuePush=[...e.queue]),e.destinations[t]=a}}(e,n),Ae(e,n,s,o),!i}(e,n,void 0,s),r=await Se(e)),r||$e({ok:!0})}function Re(e,n){if(!n.name)throw new Error("Event name is required");const[t,o]=n.name.split(" ");if(!t||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:r=Date.now(),group:s=e.group,count:i=e.count}=n,{name:a=`${t} ${o}`,data:c={},context:u={},globals:l=e.globals,custom:f={},user:g=e.user,nested:d=[],consent:p=e.consent,id:v=`${r}-${s}-${i}`,trigger:y="",entity:m=t,action:h=o,timing:b=0,version:w={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=n;return{name:a,data:c,context:u,globals:l,custom:f,user:g,nested:d,consent:p,id:v,trigger:y,entity:m,action:h,timestamp:r,timing:b,group:s,count:i,version:w,source:k}}async function Ie(e){var n,t;const o=D({globalsStatic:{},sessionStatic:{},tagging:0,run:!0},e,{merge:!1,extend:!1}),r=z({level:null==(n=e.logger)?void 0:n.level,handler:null==(t=e.logger)?void 0:t.handler}),s={...o.globalsStatic,...e.globals},i={allowed:!1,config:o,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},transformers:{},stores:{},globals:s,group:"",hooks:e.hooks||{},logger:r,on:{},queue:[],round:0,session:void 0,status:{startedAt:Date.now(),in:0,out:0,failed:0,sources:{},destinations:{}},timing:Date.now(),user:e.user||{},version:"3.4.1-next-1776790594143",sources:{},pending:{sources:{},destinations:{}},push:void 0,command:void 0};var a,c;i.push=function(e,n){return oe(async(t,o={})=>await Z(async()=>{var r;const s=Date.now(),{id:i,ingest:a,respond:c,mapping:u,preChain:l,include:f,exclude:g}=o;let d=c,p=t;const v=f||g?function(e,n,t){let o=e;return n&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>n.includes(e)))),t&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>!t.includes(e)))),o}(e.destinations,f,g):void 0,y=null!=a?a:$(i||"unknown");if(u){const n=await te(p,u,e);if(n.ignore)return $e({ok:!0});if(u.consent&&!L(u.consent,e.consent,n.event.consent))return $e({ok:!0});p=n.event}if((null==l?void 0:l.length)&&e.transformers&&Object.keys(e.transformers).length>0){const t=await we(e,e.transformers,l,p,y,d,i?`source.${i}.next`:void 0);if(null===t.event)return $e({ok:!0});if(t.respond&&(d=t.respond),Array.isArray(t.event)){const o=await Promise.all(t.event.map(async t=>{const o=n(t),r=Re(e,o);return Se(e,r,{id:i,ingest:y,respond:d},v)}));if(i){e.status.sources[i]||(e.status.sources[i]={count:0,duration:0});const n=e.status.sources[i];n.count+=t.event.length,n.lastAt=Date.now(),n.duration+=Date.now()-s}return null!=(r=o[0])?r:$e({ok:!0})}p=t.event}const m=n(p),h=Re(e,m),b=await Se(e,h,{id:i,ingest:y,respond:d},v);if(i){e.status.sources[i]||(e.status.sources[i]={count:0,duration:0});const n=e.status.sources[i];n.count++,n.lastAt=Date.now(),n.duration+=Date.now()-s}return b},()=>$e({ok:!1}))(),"Push",e.hooks,e.logger)}(i,e=>({timing:Math.round((Date.now()-i.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),i.command=(c=Me,oe(async(e,n,t)=>await Z(async()=>await c(a,e,n,t),()=>$e({ok:!1}))(),"Command",(a=i).hooks,a.logger));const u=e.stores||{};if(i.stores=await async function(e,n={}){const t={};for(const[o,r]of Object.entries(n)){const{code:n,config:s={},env:i={}}=r,a=e.logger.scope("store").scope(o),c={collector:e,logger:a,id:o,config:s,env:i},u=await n(c),l=u.get,f=u.set,g=u.delete;u.get=oe(l,"StoreGet",e.hooks,e.logger),u.set=oe(f,"StoreSet",e.hooks,e.logger),u.delete=oe(g,"StoreDelete",e.hooks,e.logger),t[o]=u}return t}(i,u),function(e,n,t){const o=new Map;for(const[t,r]of Object.entries(e))n[t]&&o.set(r,n[t]);if(0!==o.size)for(const e of[t.transformers,t.destinations,t.sources])if(e)for(const n of Object.values(e))r(n.env);function r(e){if(e)for(const[n,t]of Object.entries(e))if("object"==typeof t&&null!==t){const r=o.get(t);r&&(e[n]=r)}}}(u,i.stores,e),!i.stores.__cache){const e=new Map;i.stores.__cache={type:"memory",config:{},get:n=>{const t=e.get(n);if(t){if(!(t.expires&&Date.now()>t.expires))return t.value;e.delete(n)}},set:(n,t,o)=>{e.set(n,{value:t,expires:o?Date.now()+o:void 0})},delete:n=>{e.delete(n)}}}return i.destinations=await async function(e,n={}){var t,o;const r={};for(const[s,i]of Object.entries(n))(null==(o=null==(t=i.config)?void 0:t.require)?void 0:o.length)?e.pending.destinations[s]=i:r[s]=qe(i);return r}(i,e.destinations||{}),i.transformers=await async function(e,n={}){const t={};for(const[o,r]of Object.entries(n)){const{code:n,env:s={}}=r,{config:i}=ye(r,"before"),{config:a}=ye({...r,config:i},"next"),c=Object.keys(s).length>0?{...a,env:s}:a,{cache:u}=r,l=u?{...c,cache:u}:c,f=e.logger.scope("transformer").scope(o),g={collector:e,logger:f,id:o,ingest:$(o),config:l,env:s},d=await n(g);t[o]=d}return t}(i,e.transformers||{}),i}async function Ne(e){e=e||{};const n=await Ie(e),t=(o=n,{type:"elb",config:{},push:async(e,n,t,r,s,i)=>{if("string"==typeof e&&e.startsWith("walker ")){const r=e.replace("walker ","");return o.command(r,n,t)}let a;if("string"==typeof e)a={name:e},n&&"object"==typeof n&&!Array.isArray(n)&&(a.data=n);else{if(!e||"object"!=typeof e)return $e({ok:!1});a=e,n&&"object"==typeof n&&!Array.isArray(n)&&(a.data={...a.data||{},...n})}return r&&"object"==typeof r&&(a.context=r),s&&Array.isArray(s)&&(a.nested=s),i&&"object"==typeof i&&(a.custom=i),o.push(a)}});var o;n.sources.elb=t;const r=await async function(e,n={}){const t={};for(const[o,r]of Object.entries(n)){const{config:n={}}=r;if(n.require&&n.require.length>0){e.pending.sources[o]=r;continue}const s=await je(e,o,r);s&&(t[o]=s)}return t}(n,e.sources||{});Object.assign(n.sources,r);const{consent:s,user:i,globals:a,custom:c}=e;s&&await n.command("consent",s),i&&await n.command("user",i),a&&Object.assign(n.globals,a),c&&Object.assign(n.custom,c),n.config.run&&await n.command("run");let u=t.push;const l=Object.values(n.sources).filter(e=>"elb"!==e.type),f=l.find(e=>e.config.primary);return f?u=f.push:l.length>0&&(u=l[0].push),{collector:n,elb:u}}var Te,Ue=async e=>{let n;return{get flow(){return n},trigger:(t,o)=>async t=>{var r;if(!n){const t=await Ne({...e,run:null==(r=e.run)||r});n={collector:t.collector,elb:t.elb}}const s=(null==o?void 0:o.eventName)||"ucEvent";window.dispatchEvent(new CustomEvent(s,{detail:t}))}}},Ge=(e,n)=>{if(e&&"object"==typeof e)return()=>{n.window.dispatchEvent(new CustomEvent("ucEvent",{detail:e}))}},He=["action","event","type","ucCategory"],Le=async e=>{var n,t,o,r,s,i,a,c;const{config:u,env:l}=e,{elb:f}=l,g=null!=(n=l.window)?n:void 0!==globalThis.window?globalThis.window:void 0,d={eventName:null!=(o=null==(t=null==u?void 0:u.settings)?void 0:t.eventName)?o:"ucEvent",categoryMap:null!=(s=null==(r=null==u?void 0:u.settings)?void 0:r.categoryMap)?s:{},explicitOnly:null==(a=null==(i=null==u?void 0:u.settings)?void 0:i.explicitOnly)||a},p={settings:d};let v;if(g){const e=e=>Object.values(e).every(e=>"boolean"==typeof e),n=n=>{const t={};return n.ucCategory&&e(n.ucCategory)?Object.entries(n.ucCategory).forEach(([e,n])=>{var o,r;if("boolean"!=typeof n)return;const s=null!=(r=null==(o=d.categoryMap)?void 0:o[e])?r:e;t[s]=t[s]||n}):(n.ucCategory&&Object.entries(n.ucCategory).forEach(([e,n])=>{var o,r;if("boolean"==typeof n){const s=null!=(r=null==(o=d.categoryMap)?void 0:o[e])?r:e;t[s]=t[s]||n}}),Object.entries(n).forEach(([e,n])=>{if(He.includes(e))return;if("boolean"!=typeof n)return;const o=e.toLowerCase().replace(/ /g,"_");t[o]=n})),t},t=e=>{var t;if("consent_status"!==e.event)return;if(d.explicitOnly&&"explicit"!==(null==(t=e.type)?void 0:t.toLowerCase()))return;const o=n(e);Object.keys(o).length>0&&f("walker consent",o)},o=null!=(c=d.eventName)?c:"ucEvent";v=e=>{const n=e;n.detail&&t(n.detail)},g.addEventListener(o,v)}return{type:"usercentrics",config:p,push:f,destroy:async e=>{var n;if(g&&v){const e=null!=(n=d.eventName)?n:"ucEvent";g.removeEventListener(e,v)}}}},Ke=Le;return Te=s,((r,s,i,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let c of t(s))o.call(r,c)||c===i||e(r,c,{get:()=>s[c],enumerable:!(a=n(s,c))||a.enumerable});return r})(e({},"__esModule",{value:!0}),Te)})();
|
|
1
|
+
"use strict";var SourceUsercentrics=(()=>{var e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r=(n,t)=>{for(var o in t)e(n,o,{get:t[o],enumerable:!0})},s={};r(s,{SourceUsercentrics:()=>d,createMockElbFn:()=>E,createTrigger:()=>We,default:()=>Je,fullConsent:()=>p,fullConsentCustomMapped:()=>A,fullConsentMapped:()=>k,fullConsentUpperCase:()=>h,implicitConsent:()=>m,minimalConsent:()=>y,minimalConsentMapped:()=>O,nonConsentEvent:()=>w,noopLogger:()=>_,partialConsent:()=>v,partialConsentMapped:()=>j,serviceLevelConsent:()=>b,serviceLevelMapped:()=>C,sourceUsercentrics:()=>ze,step:()=>S,trigger:()=>Fe});var i=["action","event","type","ucCategory"];function a(e,n,t){e[n]=(void 0===e[n]||Boolean(e[n]))&&t}function c(e,n){const t={};var o;return e.ucCategory&&(o=e.ucCategory,Object.values(o).every(e=>"boolean"==typeof e))?Object.entries(e.ucCategory).forEach(([e,o])=>{var r,s;if("boolean"!=typeof o)return;const i=null!=(s=null==(r=n.categoryMap)?void 0:r[e])?s:e;a(t,i,o)}):(e.ucCategory&&Object.entries(e.ucCategory).forEach(([e,o])=>{var r,s;if("boolean"==typeof o){const i=null!=(s=null==(r=n.categoryMap)?void 0:r[e])?s:e;a(t,i,o)}}),Object.entries(e).forEach(([e,n])=>{if(i.includes(e))return;if("boolean"!=typeof n)return;const o=e.toLowerCase().replace(/ /g,"_");a(t,o,n)})),t}function u(e){const n={};return e.forEach(e=>{var t,o;const r=e.categorySlug,s=null!=(o=null==(t=e.consent)?void 0:t.status)&&o;n[r]=(void 0===n[r]||n[r])&&s}),n}function l(e){var n,t;const{window:o,elb:r,settings:s,logger:i}=e,a=null!=(n=s.eventName)?n:"ucEvent",l=e=>{var n;if(i.debug("event received",e),"consent_status"!==e.event)return;if(s.explicitOnly&&"explicit"!==(null==(n=e.type)?void 0:n.toLowerCase()))return;const t=c(e,s);Object.keys(t).length>0&&r("walker consent",t)},f=e=>{const n=e;n.detail&&l(n.detail)};o.addEventListener(a,f);const g=o.UC_UI;if((null==(t=null==g?void 0:g.isInitialized)?void 0:t.call(g))&&g.getServicesBaseInfo){const e=g.getServicesBaseInfo();e.length>0&&l(function(e){return{event:"consent_status",type:"implicit",ucCategory:u(e)}}(e))}return()=>{o.removeEventListener(a,f)}}var f=new Set(["ACCEPT_ALL","DENY_ALL","SAVE"]);async function g(e){var n;const{window:t,elb:o,settings:r,logger:s}=e,i=null!=(n=r.v3EventName)?n:"UC_UI_CMP_EVENT",a=async e=>{const n=function(e){const n={};return Object.entries(e.categories).forEach(([e,t])=>{n[e]="ALL_ACCEPTED"===t.state}),{event:"consent_status",type:"EXPLICIT"===e.consent.type?"explicit":"implicit",ucCategory:n}}(await e.getConsentDetails());if(s.debug("event received",n),r.explicitOnly&&"explicit"!==n.type)return;const t=c(n,r);Object.keys(t).length>0&&o("walker consent",t)},u=e=>{const n=t.__ucCmp;if(!n)return;const o=e.detail;o&&"CMP"===o.source&&o.type&&f.has(o.type)&&a(n).catch(()=>{})};t.addEventListener(i,u);const l=t.__ucCmp;if(l)try{await l.isInitialized()&&await a(l)}catch(e){s.warn("v3 static consent read failed",e)}return()=>{t.removeEventListener(i,u)}}var d={},p={event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0},"Google Analytics":!0,"Google Ads Remarketing":!0},v={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:!0,marketing:!1},"Google Analytics":!0,"Google Ads Remarketing":!1},y={event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},m={event:"consent_status",type:"implicit",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},h={event:"consent_status",type:"EXPLICIT",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},b={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:"partial",marketing:"partial"},"Google Analytics":!0,"Google Ads Remarketing":!1,Hotjar:!0},w={event:"other_event",type:"explicit"},k={essential:!0,functional:!0,marketing:!0},j={essential:!0,functional:!0,marketing:!1},O={essential:!0,functional:!1,marketing:!1},A={functional:!0,marketing:!0},C={essential:!0,google_analytics:!0,google_ads_remarketing:!1,hotjar:!0},x=()=>{},E=()=>()=>Promise.resolve({ok:!0}),_={error:x,warn:x,info:x,debug:x,throw:e=>{throw"string"==typeof e?new Error(e):e},json:x,scope:()=>_},S={};r(S,{categoryMapOverride:()=>$,customEventName:()=>q,fullConsent:()=>P,minimalConsent:()=>D});var P={title:"Full consent",description:"A Usercentrics onAcceptAllServices event emits a walker consent command with essential, functional, and marketing granted.",trigger:{type:"consent"},in:{event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},out:[["elb","walker consent",{essential:!0,functional:!0,marketing:!0}]]},D={title:"Minimal consent",description:"A Usercentrics onDenyAllServices event emits a walker consent command with only essential granted.",trigger:{type:"consent"},in:{event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1}},out:[["elb","walker consent",{essential:!0,functional:!1,marketing:!1}]]},$={title:"Category map override",description:"Custom categoryMap remaps essential to functional and functional to analytics",trigger:{type:"consent"},in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!1}},mapping:{categoryMap:{essential:"functional",functional:"analytics"}},out:[["elb","walker consent",{functional:!0,analytics:!0,marketing:!1}]]},q={title:"Custom event name",description:"Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2",trigger:{type:"consent",options:{eventName:"UC_SDK_EVENT"}},in:{event:"consent_status",type:"explicit",ucCategory:{essential:!0,functional:!0,marketing:!0}},mapping:{eventName:"UC_SDK_EVENT"},out:[["elb","walker consent",{essential:!0,functional:!0,marketing:!0}]]},M=Object.defineProperty;((e,n)=>{for(var t in n)M(e,t,{get:n[t],enumerable:!0})})({},{Level:()=>N});var I,N=((I=N||{})[I.ERROR=0]="ERROR",I[I.WARN=1]="WARN",I[I.INFO=2]="INFO",I[I.DEBUG=3]="DEBUG",I);function R(e){return{_meta:{hops:0,path:[e]}}}var U={merge:!0,shallow:!0,extend:!0};function T(e,n={},t={}){t={...U,...t};const o=Object.entries(n).reduce((n,[o,r])=>{const s=e[o];return t.merge&&Array.isArray(s)&&Array.isArray(r)?n[o]=r.reduce((e,n)=>e.includes(n)?e:[...e,n],[...s]):(t.extend||o in e)&&(n[o]=r),n},{});return t.shallow?{...e,...o}:(Object.assign(e,o),e)}function L(e){return Array.isArray(e)}function G(e){return void 0!==e}function H(e){return"function"==typeof e}function V(e){return"object"==typeof e&&null!==e&&!L(e)&&"[object Object]"===Object.prototype.toString.call(e)}function B(e){return"string"==typeof e}function K(e,n=new WeakMap){if("object"!=typeof e||null===e)return e;if(n.has(e))return n.get(e);const t=Object.prototype.toString.call(e);if("[object Object]"===t){const t={};n.set(e,t);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=K(e[o],n));return t}if("[object Array]"===t){const t=[];return n.set(e,t),e.forEach(e=>{t.push(K(e,n))}),t}if("[object Date]"===t)return new Date(e.getTime());if("[object RegExp]"===t){const n=e;return new RegExp(n.source,n.flags)}return e}function W(e,n="",t){const o=n.split(".");let r=e;for(let e=0;e<o.length;e++){const n=o[e];if("*"===n&&L(r)){const n=o.slice(e+1).join("."),s=[];for(const e of r){const o=W(e,n,t);s.push(o)}return s}if(r=r instanceof Object?r[n]:void 0,void 0===r)break}return G(r)?r:t}function F(e,n,t){if(!V(e))return e;const o=K(e),r=n.split(".");let s=o;for(let e=0;e<r.length;e++){const n=r[e];e===r.length-1?s[n]=t:(n in s&&"object"==typeof s[n]&&null!==s[n]||(s[n]={}),s=s[n])}return o}var z={data:e=>e.data,globals:e=>e.globals,context:e=>e.context,user:e=>e.user,source:e=>e.source,version:e=>e.version,event:e=>({entity:e.entity,action:e.action,id:e.id,timestamp:e.timestamp,name:e.name,trigger:e.trigger,group:e.group,count:e.count,timing:e.timing})};function J(e,n={},t={}){const o={...n,...t},r={};let s=!e||0===Object.keys(e).length;return Object.keys(o).forEach(n=>{o[n]&&(r[n]=!0,e&&e[n]&&(s=!0))}),!!s&&r}function X(e=6,n){if(n){const t=n.length;let o="";for(let r=0;r<e;r++)o+=n[Math.random()*t|0];return o}let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function Y(e,n=1e3,t=!1){let o,r=null,s=!1;return(...i)=>new Promise(a=>{const c=t&&!s;r&&clearTimeout(r),r=setTimeout(()=>{r=null,t&&!s||(o=e(...i),a(o))},n),c&&(s=!0,o=e(...i),a(o))})}function Q(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function Z(e,n){let t,o={};return e instanceof Error?(t=e.message,o.error=Q(e)):t=e,void 0!==n&&(n instanceof Error?o.error=Q(n):"object"==typeof n&&null!==n?(o={...o,...n},"error"in o&&o.error instanceof Error&&(o.error=Q(o.error))):o.value=n),{message:t,context:o}}var ee=(e,n,t,o)=>{const r=`${N[e]}${o.length>0?` [${o.join(":")}]`:""}`,s=Object.keys(t).length>0,i=0===e?console.error:1===e?console.warn:console.log;s?i(r,n,t):i(r,n)};function ne(e={}){return te({level:void 0!==e.level?(n=e.level,"string"==typeof n?N[n]:n):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]});var n}function te(e){const{level:n,handler:t,jsonHandler:o,scope:r}=e,s=(e,o,s)=>{if(e<=n){const n=Z(o,s);t?t(e,n.message,n.context,r,ee):ee(e,n.message,n.context,r)}};return{error:(e,n)=>s(0,e,n),warn:(e,n)=>s(1,e,n),info:(e,n)=>s(2,e,n),debug:(e,n)=>s(3,e,n),throw:(e,n)=>{const o=Z(e,n);throw t?t(0,o.message,o.context,r,ee):ee(0,o.message,o.context,r),new Error(o.message)},json:e=>{o?o(e):console.log(JSON.stringify(e,null,2))},scope:e=>te({level:n,handler:t,jsonHandler:o,scope:[...r,e]})}}function oe(e){return function(e){return"boolean"==typeof e}(e)||B(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!G(e)||L(e)&&e.every(oe)||V(e)&&Object.values(e).every(oe)}function re(e){return oe(e)?e:void 0}function se(e,n,t){return function(...o){try{return e(...o)}catch(e){if(!n)return;return n(e)}finally{null==t||t()}}}function ie(e,n,t){return async function(...o){try{return await e(...o)}catch(e){if(!n)return;return await n(e)}finally{await(null==t?void 0:t())}}}async function ae(e,n={},t={}){var o;if(!G(e))return;const r=V(e)&&e.consent||t.consent||(null==(o=t.collector)?void 0:o.consent),s=L(n)?n:[n];for(const n of s){const o=await ie(ce)(e,n,{...t,consent:r});if(G(o))return o}}async function ce(e,n,t={}){const{collector:o,consent:r}=t;return(L(n)?n:[n]).reduce(async(n,s)=>{const i=await n;if(i)return i;const a=B(s)?{key:s}:s;if(!Object.keys(a).length)return;const{condition:c,consent:u,fn:l,key:f,loop:g,map:d,set:p,validate:v,value:y}=a;if(c&&!await ie(c)(e,s,o))return;if(u&&!J(u,r))return y;let m=G(y)?y:e;if(l&&(m=await ie(l)(e,s,t)),f&&(m=W(e,f,y)),g){const[n,o]=g,r="this"===n?[e]:await ae(e,n,t);L(r)&&(m=(await Promise.all(r.map(e=>ae(e,o,t)))).filter(G))}else d?m=await Object.entries(d).reduce(async(n,[o,r])=>{const s=await n,i=await ae(e,r,t);return G(i)&&(s[o]=i),s},Promise.resolve({})):p&&(m=await Promise.all(p.map(n=>ce(e,n,t))));v&&!await ie(v)(m)&&(m=void 0);const h=re(m);return G(h)?h:re(y)},Promise.resolve(void 0))}async function ue(e,n,t){var o;n.policy&&await Promise.all(Object.entries(n.policy).map(async([n,o])=>{const r=await ae(e,o,{collector:t});e=F(e,n,r)}));const{eventMapping:r,mappingKey:s}=await async function(e,n){var t;const[o,r]=(e.name||"").split(" ");if(!n||!o||!r)return{};let s,i="",a=o,c=r;const u=n=>{if(n)return(n=L(n)?n:[n]).find(n=>!n.condition||n.condition(e))};n[a]||(a="*");const l=n[a];return l&&(l[c]||(c="*"),s=u(l[c])),s||(a="*",c="*",s=u(null==(t=n[a])?void 0:t[c])),s&&(i=`${a} ${c}`),{eventMapping:s,mappingKey:i}}(e,n.mapping);(null==r?void 0:r.policy)&&await Promise.all(Object.entries(r.policy).map(async([n,o])=>{const r=await ae(e,o,{collector:t});e=F(e,n,r)}));let i=n.data&&await ae(e,n.data,{collector:t});const a=Boolean(null==r?void 0:r.skip);if(r){if(r.ignore)return{event:e,data:i,mapping:r,mappingKey:s,ignore:!0,skip:a};if(r.name&&(e.name=r.name),r.data){const n=r.data&&await ae(e,r.data,{collector:t});i=V(i)&&V(n)?T(i,n):n}}const c=null!=(o=null==r?void 0:r.include)?o:n.include;if(c&&c.length>0){const n=function(e,n){const t={},o=n.includes("all")?Object.keys(z):n;for(const n of o){const o=z[n];if(!o)continue;const r=o(e);if(V(r))for(const[e,o]of Object.entries(r)){if(void 0===o)continue;const r="context"===n&&Array.isArray(o)?o[0]:o;t[`${n}_${e}`]=r}}return t}(e,c);Object.keys(n).length>0&&(i=V(i)?T(n,i):null!=i?i:n)}return{event:e,data:i,mapping:r,mappingKey:s,ignore:!1,skip:a}}function le(e,n,t,o){return function(...r){let s;const i="pre"+n,a="post"+n,c=t[i],u=t[a],l=(e,n)=>{o?o.warn(e,{error:n}):console.warn(e,n)};if(c)try{s=c({fn:e},...r)}catch(n){l(`Hook ${String(i)} failed, falling back to original function`,n),s=e(...r)}else s=e(...r);if(u)try{s=u({fn:e,result:s},...r)}catch(e){l(`Hook ${String(a)} failed, keeping original result`,e)}return s}}function fe(e){if("*"===e)return()=>!0;if("and"in e){const n=e.and.map(fe);return e=>n.every(n=>n(e))}if("or"in e){const n=e.or.map(fe);return e=>n.some(n=>n(e))}return function(e){const{key:n,operator:t,value:o,not:r}=e,s=function(e,n){switch(e){case"eq":return e=>String(null!=e?e:"")===n;case"contains":return e=>String(null!=e?e:"").includes(n);case"prefix":return e=>String(null!=e?e:"").startsWith(n);case"suffix":return e=>String(null!=e?e:"").endsWith(n);case"regex":{const e=new RegExp(n);return n=>e.test(String(null!=n?n:""))}case"gt":{const e=Number(n);return n=>Number(n)>e}case"lt":{const e=Number(n);return n=>Number(n)<e}case"exists":return e=>null!=e}}(t,o);return e=>{const t=W(e,n),o=s(t);return r?!o:o}}(e)}function ge(e){return Array.isArray(e)&&e.length>0&&"object"==typeof e[0]&&null!==e[0]&&"match"in e[0]}function de(e){if(null!=e){if("string"==typeof e)return{type:"static",value:e};if(Array.isArray(e)){if(0===e.length)return;return ge(e)?{type:"routes",routes:e.map(e=>({match:fe(e.match),next:de(e.next)}))}:{type:"chain",value:e}}}}function pe(e,n={}){if(e){if("static"===e.type)return e.value;if("chain"===e.type)return e.value;for(const t of e.routes)if(t.match(n))return pe(t.next,n)}}function ve(e,n){const t={ingest:null!=e?e:{}};return void 0!==n&&(t.event=n),t}function ye(e){var n;return{full:null!=(n=e.full)&&n,storeId:e.store,rules:e.rules.map(e=>({match:fe(e.match),key:e.key,ttl:e.ttl,update:e.update}))}}function me(e,n,t,o){const r=e.rules.find(e=>e.match(t));if(!r)return null;const s=r.key.map(e=>{var n;return String(null!=(n=W(t,e))?n:"")});if(s.every(e=>""===e))return null;const i=`${o}:${s.join(":")}`,a=n.get(i);return void 0!==a?{status:"HIT",key:i,value:a,rule:r}:{status:"MISS",key:i,rule:r}}function he(e,n,t,o){e.set(n,t,1e3*o)}async function be(e,n,t){if(!n)return e;let o=e;for(const[e,r]of Object.entries(n))o=F(o,e,await ae(t,r));return o}var we={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",Shutdown:"shutdown",User:"user",Walker:"walker"};function ke(e,n){return e.storeId&&n.stores[e.storeId]?n.stores[e.storeId]:n.stores.__cache}function je(e){var n;const t={};for(const[o,r]of Object.entries(e)){const e=null==(n=r.config)?void 0:n.next;e&&!ge(e)?t[o]={next:e}:t[o]={}}return t}function Oe(e,n){const t=e.config||{},o=e[n];return void 0!==o?{config:{...t,[n]:o},chainValue:o}:{config:t,chainValue:void 0}}function Ae(e,n={}){if(!e)return[];if(Array.isArray(e))return e;const t=[],o=new Set;let r=e;for(;r&&n[r]&&!o.has(r);){o.add(r),t.push(r);const e=n[r].next;if(Array.isArray(e)){t.push(...e);break}r=e}return t}async function Ce(e,n,t){if(n.init&&!n.config.init){const o=n.type||"unknown",r=e.logger.scope(`transformer:${o}`),s={collector:e,logger:r,id:t,ingest:R(t),config:n.config,env:_e(n.config.env)};r.debug("init");const i=await le(n.init,"TransformerInit",e.hooks,e.logger)(s);if(!1===i)return!1;n.config={...i||n.config,env:(null==i?void 0:i.env)||n.config.env,init:!0},r.debug("init done")}return!0}async function xe(e,n,t,o,r,s){const i=n.type||"unknown",a=e.logger.scope(`transformer:${i}`),c={collector:e,logger:a,id:t,ingest:r,config:n.config,env:{..._e(n.config.env),...s?{respond:s}:{}}};a.debug("push",{event:o.name});const u=await le(n.push,"TransformerPush",e.hooks,e.logger)(o,c);return a.debug("push done"),u}async function Ee(e,n,t,o,r,s,i){var a,c,u,l,f,g;i&&(null==r?void 0:r._meta)&&(r._meta.chainPath=i);let d=o,p=s;for(const o of t){const s=n[o];if(!s){e.logger.warn(`Transformer not found: ${o}`);continue}if(r&&r._meta&&r._meta.path.length>256)return e.logger.error(`Max path length exceeded at ${o}`),{event:null,respond:p};if(r&&r._meta&&(r._meta.hops++,r._meta.path.push(o)),!await ie(Ce)(e,s,o))return e.logger.error(`Transformer init failed: ${o}`),{event:null,respond:p};if(i&&void 0!==(null==(c=null==(a=s.config)?void 0:a.chainMocks)?void 0:c[i])){const n=s.config.chainMocks[i];e.logger.scope(`transformer:${s.type||"unknown"}`).debug("chainMock",{chain:i}),d=n;continue}if(void 0!==(null==(u=s.config)?void 0:u.mock)){e.logger.scope(`transformer:${s.type||"unknown"}`).debug("mock"),d=s.config.mock;continue}if(null==(l=s.config)?void 0:l.disabled)continue;const v=null==(f=s.config)?void 0:f.cache,y=v?ye(v):void 0,m=y?ke(y,e):void 0;let h;if(y&&m){const e=me(y,m,ve(r,d),`t:${o}`);if("HIT"===(null==e?void 0:e.status)&&e.value){if(d=e.value,y.full)return{event:d,respond:p};continue}"MISS"===(null==e?void 0:e.status)&&(h={key:e.key,ttl:e.rule.ttl})}const b=s.config.before;if(b){const t=Ae("string"==typeof b||Array.isArray(b)&&!ge(b)?b:pe(de(b),ve(r,d))||void 0,je(n));if(t.length>0){const o=await Ee(e,n,t,d,r,p,i);if(null===o.event)return{event:null,respond:null!=(g=o.respond)?g:p};o.respond&&(p=o.respond),d=Array.isArray(o.event)?o.event[0]:o.event}}const w=await ie(xe,n=>(e.logger.scope(`transformer:${s.type||"unknown"}`).error("Push failed",{error:n}),!1))(e,s,o,d,r,p);if(!1===w)return{event:null,respond:p};if(Array.isArray(w)){const s=t.slice(t.indexOf(o)+1),a=await Promise.all(w.map(async t=>{const o=t.event||d,a=r?{...r,_meta:{...r._meta,path:[...r._meta.path]}}:R("unknown");if(t.next){let r=t.next;if(ge(t.next)){r=pe(de(t.next),ve(a,o))}if(r){const t=Ae(r,je(n));if(t.length>0)return Ee(e,n,t,o,a,p,i)}return{event:o,respond:p}}return s.length>0?Ee(e,n,s,o,a,p,i):{event:o,respond:p}}));let c=p;const u=[];for(const e of a.flat())if(null!==e)if(e&&"object"==typeof e&&"event"in e){const n=e;if(n.respond&&(c=n.respond),null===n.event)continue;Array.isArray(n.event)?u.push(...n.event):u.push(n.event)}else u.push(e);return 0===u.length?{event:null,respond:c}:1===u.length?{event:u[0],respond:c}:{event:u,respond:c}}if(w&&"object"==typeof w){const{event:t,respond:o,next:s}=w;if(o&&(p=o),s){let o=s;if(ge(s)){if(o=pe(de(s),ve(r,d)),!o){t&&(d=t);continue}}const a=Ae(o,je(n));return a.length>0?Ee(e,n,a,t||d,r,p,i):(e.logger.warn(`Branch target not found: ${JSON.stringify(s)}`),{event:null,respond:p})}t&&(d=t)}if(h&&m&&he(m,h.key,d,h.ttl),(!w||"object"==typeof w&&!w.next)&&s.config.next&&ge(s.config.next)){const t=pe(de(s.config.next),ve(r,d));if(t){const o=Ae(t,je(n));if(o.length>0)return Ee(e,n,o,d,r,p,i)}return{event:d,respond:p}}}return{event:d,respond:p}}function _e(e){return e&&V(e)?e:{}}async function Se(e,n,t){var o;const{code:r,config:s={},env:i={},primary:a,next:c,before:u,cache:l}=t;let f,g=R(n);const d=l?ye({...l,full:null==(o=l.full)||o}):void 0,p=de(c),v=Array.isArray(c)&&ge(c)||!p?void 0:Ae(pe(p),je(e.transformers)),y=de(u),m=Array.isArray(u)&&ge(u)||!y?void 0:Ae(pe(y),je(e.transformers)),h=e.logger.scope("source").scope(n),b={push:async(t,o={})=>{let r,i=t;const a=null!=m?m:y?Ae(pe(y,ve(g)),je(e.transformers)):[];if(a.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const t=await Ee(e,e.transformers,a,i,g,f,`source.${n}.before`);if(null===t.event)return{ok:!0};t.respond&&(f=t.respond),i=Array.isArray(t.event)?t.event[0]:t.event}if(d){const t=ke(d,e);if(t){const e=ve(g),o=me(d,t,e,`s:${n}`);if(o){if("HIT"===o.status&&void 0!==o.value&&d.full){let n=o.value;return o.rule.update&&(n=await be(n,o.rule.update,{...e,cache:{status:"HIT"}})),null==f||f(n),{ok:!0}}if("MISS"===o.status&&d.full&&f){const n=f,s=o.rule.update,i={...e,cache:{status:"MISS"}},a=o.key,c=o.rule.ttl;f=e=>{he(t,a,e,c),s?r=(async()=>{const t=await be(e,s,i);n(t)})():n(e)}}"MISS"!==o.status||d.full||he(t,o.key,!0,o.rule.ttl)}}}const c=null!=v?v:p?Ae(pe(p,ve(g)),je(e.transformers)):[],u=await e.push(i,{...o,id:n,ingest:g,respond:f,mapping:s,preChain:c});return r&&await r,u},command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:h,...i},w={collector:e,logger:h,id:n,config:s,env:b,setIngest:async t=>{if(!s.ingest)return void(g=R(n));const o=await ae(t,s.ingest,{collector:e}),r=R(n);g={...r,...o,_meta:r._meta}},setRespond:e=>{f=e}},k=await ie(r)(w);if(!k)return;const j=k.type||"unknown",O=e.logger.scope(j).scope(n);return b.logger=O,a&&(k.config={...k.config,primary:a}),k}function Pe(e,n,t,o,r){if(!n.on)return;const s=n.type||"unknown",i=e.logger.scope(s).scope("on").scope(o),a={collector:e,logger:i,id:t,config:n.config,data:r,env:Te(n.env,n.config.env)};se(n.on)(o,a)}function De(e,n,t,o){let r;switch(n){case we.Consent:r=o||e.consent;break;case we.Session:r=e.session;break;case we.User:r=o||e.user;break;case we.Custom:r=o||e.custom;break;case we.Globals:r=o||e.globals;break;case we.Config:r=o||e.config;break;case we.Ready:case we.Run:default:r=void 0}if(t.length)switch(n){case we.Consent:!function(e,n,t){const o=t||e.consent;n.forEach(n=>{Object.keys(o).filter(e=>e in n).forEach(t=>{se(n[t])(e,o)})})}(e,t,o);break;case we.Ready:case we.Run:i=t,(s=e).allowed&&i.forEach(e=>{se(e)(s)});break;case we.Session:!function(e,n){e.session&&n.forEach(n=>{se(n)(e,e.session)})}(e,t);break;default:t.forEach(n=>{"function"==typeof n&&se(n)(e,r)})}var s,i}function $e(e,n,t,o){if(!e)return[];if(n){const e=pe(n,ve(o));return e?Ae(e,je(t)):[]}return Ae(e,je(t))}async function qe(e,n,t){const{code:o,config:r={},env:s={},before:i,next:a,cache:c}=n;if(!H(o.push))return Re({ok:!1,failed:{invalid:{type:"invalid",error:"Destination code must have a push method"}}});const u=t||r||{init:!1};let l=i?{...u,before:i}:{...u};a&&(l={...l,next:a}),c&&(l={...l,cache:c});const f={...o,config:l,env:Te(o.env,s)};let g=f.config.id;if(!g)do{g=X(5,"abcdefghijklmnopqrstuvwxyz")}while(e.destinations[g]);return e.destinations[g]=f,!1!==f.config.queue&&(f.queuePush=[...e.queue]),Me(e,void 0,{},{[g]:f})}async function Me(e,n,t={},o){const{allowed:r,consent:s,globals:i,user:a}=e;if(!r)return Re({ok:!1});n&&(e.queue.push(n),e.status.in++),o||(o=e.destinations);const c=await Promise.all(Object.entries(o||{}).map(async([o,r])=>{var c,u,l;if(r.config.disabled)return{id:o,destination:r,skipped:!0};let f=(r.queuePush||[]).map(e=>({...e,consent:s}));r.queuePush=[],n&&f.push(K(n));const g=t.ingest?{...t.ingest,_meta:{...t.ingest._meta,path:[...t.ingest._meta.path]}}:R("unknown");if(!f.length&&!(null==(c=r.queueOn)?void 0:c.length))return{id:o,destination:r,skipped:!0};if(!f.length&&(null==(u=r.queueOn)?void 0:u.length)){const n=await ie(Ie)(e,r,o);return{id:o,destination:r,skipped:!n}}const d=[],p=f.filter(e=>{const n=J(r.config.consent,s,e.consent);return!n||(e.consent=n,d.push(e),!1)});if(r.queuePush.push(...p),!d.length)return{id:o,destination:r,queue:f};if(!await ie(Ie)(e,r,o))return{id:o,destination:r,queue:f};let v,y;r.dlq||(r.dlq=[]);const m=r.config.before,h=$e(m,m&&ge(m)?de(m):void 0,e.transformers,g),b=r.config.next,w=b&&ge(b)?de(b):void 0,k=null==(l=r.config)?void 0:l.cache,j=k?ye(k):void 0,O=j?ke(j,e):void 0;let A=0;return await Promise.all(d.map(async n=>{let s;if(n.globals=T(i,n.globals),n.user=T(a,n.user),(null==j?void 0:j.full)&&O){const e=ve(g,n),t=me(j,O,e,`d:${o}`);if("HIT"===(null==t?void 0:t.status))return n;"MISS"===(null==t?void 0:t.status)&&(s={key:t.key,ttl:t.rule.ttl})}let c=n,u=t.respond;if(h.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const r=await Ee(e,e.transformers,h,n,g,t.respond,`destination.${o}.before`);if(null===r.event)return n;r.respond&&(u=r.respond),c=Array.isArray(r.event)?r.event[0]:r.event}if(j&&!j.full&&O){const e=ve(g,c),t=me(j,O,e,`d:${o}`);if("HIT"===(null==t?void 0:t.status))return n;"MISS"===(null==t?void 0:t.status)&&(s={key:t.key,ttl:t.rule.ttl})}const l=Date.now();let f=!1;const d=await ie(Ne,n=>{const t=r.type||"unknown";e.logger.scope(t).error("Push failed",{error:n,event:c.name}),v=n,f=!0,r.dlq.push([c,n])})(e,r,o,c,g,u);if(A+=Date.now()-l,s&&O&&void 0===r.config.mock&&he(O,s.key,null==d||d,s.ttl),void 0!==d&&(y=d),!f&&b){void 0!==d&&(g._response=d);const n=$e(b,w,e.transformers,g);if(n.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const t=await Ee(e,e.transformers,n,c,g,u,`destination.${o}.next`);t.respond&&(u=t.respond)}}return n})),{id:o,destination:r,error:v,response:y,totalDuration:A}})),u={},l={},f={};for(const n of c){if(n.skipped)continue;const t={type:n.destination.type||"unknown",data:n.response};e.status.destinations[n.id]||(e.status.destinations[n.id]={count:0,failed:0,duration:0});const o=e.status.destinations[n.id],r=Date.now();n.error?(t.error=n.error,f[n.id]=t,o.failed++,o.lastAt=r,o.duration+=n.totalDuration||0,e.status.failed++):n.queue&&n.queue.length?l[n.id]=t:(u[n.id]=t,o.count++,o.lastAt=r,o.duration+=n.totalDuration||0,e.status.out++)}return Re({event:n,...Object.keys(u).length&&{done:u},...Object.keys(l).length&&{queued:l},...Object.keys(f).length&&{failed:f}})}async function Ie(e,n,t){var o;if(n.init&&!n.config.init){const r=n.type||"unknown",s=e.logger.scope(r),i={collector:e,logger:s,id:t,config:n.config,env:Te(n.env,n.config.env)};s.debug("init");const a=await le(n.init,"DestinationInit",e.hooks,e.logger)(i);if(!1===a)return a;if(n.config={...a||n.config,init:!0},null==(o=n.queueOn)?void 0:o.length){const o=n.queueOn;n.queueOn=[];for(const{type:r,data:s}of o)Pe(e,n,t,r,s)}s.debug("init done")}return!0}async function Ne(e,n,t,o,r,s){const{config:i}=n,a=await ue(o,i,e);if(a.ignore)return!1;const c=n.type||"unknown",u=e.logger.scope(c),l={collector:e,logger:u,id:t,config:i,data:a.data,rule:a.mapping,ingest:r,env:{...Te(n.env,i.env),...s?{respond:s}:{}}};if(void 0!==i.mock)return u.debug("mock",{event:a.event.name}),i.mock;const f=a.mapping,g=a.mappingKey||"* *";if(!(null==f?void 0:f.batch)||!n.pushBatch||void 0!==i.mock){u.debug("push",{event:a.event.name});const t=await le(n.push,"DestinationPush",e.hooks,e.logger)(a.event,l);return u.debug("push done"),t}{if(n.batches=n.batches||{},!n.batches[g]){const o={key:g,events:[],data:[]};n.batches[g]={batched:o,batchFn:Y(()=>{const o=n.batches[g].batched,a={collector:e,logger:u,id:t,config:i,data:void 0,rule:f,ingest:r,env:{...Te(n.env,i.env),...s?{respond:s}:{}}};u.debug("push batch",{events:o.events.length}),le(n.pushBatch,"DestinationPushBatch",e.hooks,e.logger)(o,a),u.debug("push batch done"),o.events=[],o.data=[]},f.batch)}}const o=n.batches[g];o.batched.events.push(a.event),G(a.data)&&o.batched.data.push(a.data),o.batchFn()}return!0}function Re(e){return{ok:!(null==e?void 0:e.failed),...e}}function Ue(e){const{code:n,config:t={},env:o={},cache:r}=e,{config:s}=Oe(e,"before"),{config:i}=Oe({...e,config:s},"next"),a={...n.config,...t,...i};r&&(a.cache=r);const c=Te(n.env,o);return{...n,config:a,env:c}}function Te(e,n){return e||n?n?e&&V(e)&&V(n)?{...e,...n}:n:e:{}}async function Le(e,n,t){const o=Object.entries(e).map(async([e,o])=>{var r;const s=o.destroy;if(!s)return;const i=o.type||"unknown",a=t.scope(i),c={id:e,config:o.config,env:null!=(r=o.env)?r:{},logger:a};try{await Promise.race([s(c),new Promise((t,o)=>setTimeout(()=>o(new Error(`${n} '${e}' destroy timed out`)),5e3))])}catch(t){a.error(`${n} '${e}' destroy failed: ${t}`)}});await Promise.allSettled(o)}async function Ge(e,n,t,o){let r,s,i=!1;switch(n){case we.Config:V(t)&&(T(e.config,t,{shallow:!1}),s=t,i=!0);break;case we.Consent:if(V(t)){const{update:n}=function(e,n){const t={};return Object.entries(n).forEach(([e,n])=>{t[e]=!!n}),e.consent=T(e.consent,t),{update:t}}(e,t);s=n,i=!0}break;case we.Custom:V(t)&&(e.custom=T(e.custom,t),s=t,i=!0);break;case we.Destination:V(t)&&("code"in t&&V(t.code)?r=await qe(e,t,o):H(t.push)&&(r=await qe(e,{code:t},o)));break;case we.Globals:V(t)&&(e.globals=T(e.globals,t),s=t,i=!0);break;case we.On:B(t)&&await async function(e,n,t){const o=e.on,r=o[n]||[],s=L(t)?t:[t];s.forEach(e=>{r.push(e)}),o[n]=r,De(e,n,s)}(e,t,o);break;case we.Ready:i=!0;break;case we.Run:r=await async function(e,n){return e.allowed=!0,e.count=0,e.group=X(),e.timing=Date.now(),n&&(n.consent&&(e.consent=T(e.consent,n.consent)),n.user&&(e.user=T(e.user,n.user)),n.globals&&(e.globals=T(e.config.globalsStatic||{},n.globals)),n.custom&&(e.custom=T(e.custom,n.custom))),Object.values(e.destinations).forEach(e=>{e.queuePush=[]}),e.queue=[],e.round++,await Me(e)}(e,t),i=!0;break;case we.Session:i=!0;break;case we.Shutdown:await async function(e){const n=e.logger;await Le(e.sources,"source",n),await Le(e.destinations,"destination",n),await Le(e.transformers,"transformer",n),await Le(e.stores,"store",n)}(e);break;case we.User:V(t)&&(T(e.user,t,{shallow:!1}),s=t,i=!0)}return i&&(await async function(e,n,t,o){let r,s=t||[];switch(t||(s=e.on[n]||[]),n){case we.Consent:r=o||e.consent;break;case we.Session:r=e.session;break;case we.User:r=o||e.user;break;case we.Custom:r=o||e.custom;break;case we.Globals:r=o||e.globals;break;case we.Config:r=o||e.config;break;case we.Ready:case we.Run:default:r=void 0}let i=!1;for(const t of Object.values(e.sources))t.on&&!1===await ie(t.on)(n,r)&&(i=!0);return Object.entries(e.destinations).forEach(([t,o])=>{if(o.on){if(!o.config.init)return o.queueOn=o.queueOn||[],void o.queueOn.push({type:n,data:r});Pe(e,o,t,n,r)}}),(Object.keys(e.pending.sources).length>0||Object.keys(e.pending.destinations).length>0)&&await async function(e,n){var t,o;for(const[o,r]of Object.entries(e.pending.sources)){if(!e.pending.sources[o]||e.sources[o])continue;const s=null==(t=r.config)?void 0:t.require;if(!s)continue;const i=s.indexOf(n);if(-1===i)continue;if(s.splice(i,1),s.length>0)continue;delete e.pending.sources[o];const a=await Se(e,o,r);a&&(e.sources[o]=a)}for(const[t,r]of Object.entries(e.pending.destinations)){if(!e.pending.destinations[t]||e.destinations[t])continue;const s=null==(o=r.config)?void 0:o.require;if(!s)continue;const i=s.indexOf(n);if(-1===i)continue;if(s.splice(i,1),s.length>0)continue;delete e.pending.destinations[t];const a=Ue(r);!1!==a.config.queue&&(a.queuePush=[...e.queue]),e.destinations[t]=a}}(e,n),De(e,n,s,o),!i}(e,n,void 0,s),r=await Me(e)),r||Re({ok:!0})}function He(e,n){if(!n.name)throw new Error("Event name is required");const[t,o]=n.name.split(" ");if(!t||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:r=Date.now(),group:s=e.group,count:i=e.count}=n,{name:a=`${t} ${o}`,data:c={},context:u={},globals:l=e.globals,custom:f={},user:g=e.user,nested:d=[],consent:p=e.consent,id:v=`${r}-${s}-${i}`,trigger:y="",entity:m=t,action:h=o,timing:b=0,version:w={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=n;return{name:a,data:c,context:u,globals:l,custom:f,user:g,nested:d,consent:p,id:v,trigger:y,entity:m,action:h,timestamp:r,timing:b,group:s,count:i,version:w,source:k}}async function Ve(e){var n,t;const o=T({globalsStatic:{},sessionStatic:{},tagging:0,run:!0},e,{merge:!1,extend:!1}),r=ne({level:null==(n=e.logger)?void 0:n.level,handler:null==(t=e.logger)?void 0:t.handler}),s={...o.globalsStatic,...e.globals},i={allowed:!1,config:o,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},transformers:{},stores:{},globals:s,group:"",hooks:e.hooks||{},logger:r,on:{},queue:[],round:0,session:void 0,status:{startedAt:Date.now(),in:0,out:0,failed:0,sources:{},destinations:{}},timing:Date.now(),user:e.user||{},version:"3.4.2",sources:{},pending:{sources:{},destinations:{}},push:void 0,command:void 0};var a,c;i.push=function(e,n){return le(async(t,o={})=>await ie(async()=>{var r;const s=Date.now(),{id:i,ingest:a,respond:c,mapping:u,preChain:l,include:f,exclude:g}=o;let d=c,p=t;const v=f||g?function(e,n,t){let o=e;return n&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>n.includes(e)))),t&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>!t.includes(e)))),o}(e.destinations,f,g):void 0,y=null!=a?a:R(i||"unknown");if(u){const n=await ue(p,u,e);if(n.ignore)return Re({ok:!0});if(u.consent&&!J(u.consent,e.consent,n.event.consent))return Re({ok:!0});p=n.event}if((null==l?void 0:l.length)&&e.transformers&&Object.keys(e.transformers).length>0){const t=await Ee(e,e.transformers,l,p,y,d,i?`source.${i}.next`:void 0);if(null===t.event)return Re({ok:!0});if(t.respond&&(d=t.respond),Array.isArray(t.event)){const o=await Promise.all(t.event.map(async t=>{const o=n(t),r=He(e,o);return Me(e,r,{id:i,ingest:y,respond:d},v)}));if(i){e.status.sources[i]||(e.status.sources[i]={count:0,duration:0});const n=e.status.sources[i];n.count+=t.event.length,n.lastAt=Date.now(),n.duration+=Date.now()-s}return null!=(r=o[0])?r:Re({ok:!0})}p=t.event}const m=n(p),h=He(e,m),b=await Me(e,h,{id:i,ingest:y,respond:d},v);if(i){e.status.sources[i]||(e.status.sources[i]={count:0,duration:0});const n=e.status.sources[i];n.count++,n.lastAt=Date.now(),n.duration+=Date.now()-s}return b},()=>Re({ok:!1}))(),"Push",e.hooks,e.logger)}(i,e=>({timing:Math.round((Date.now()-i.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),i.command=(c=Ge,le(async(e,n,t)=>await ie(async()=>await c(a,e,n,t),()=>Re({ok:!1}))(),"Command",(a=i).hooks,a.logger));const u=e.stores||{};if(i.stores=await async function(e,n={}){const t={};for(const[o,r]of Object.entries(n)){const{code:n,config:s={},env:i={}}=r,a=e.logger.scope("store").scope(o),c={collector:e,logger:a,id:o,config:s,env:i},u=await n(c),l=u.get,f=u.set,g=u.delete;u.get=le(l,"StoreGet",e.hooks,e.logger),u.set=le(f,"StoreSet",e.hooks,e.logger),u.delete=le(g,"StoreDelete",e.hooks,e.logger),t[o]=u}return t}(i,u),function(e,n,t){const o=new Map;for(const[t,r]of Object.entries(e))n[t]&&o.set(r,n[t]);if(0!==o.size)for(const e of[t.transformers,t.destinations,t.sources])if(e)for(const n of Object.values(e))r(n.env);function r(e){if(e)for(const[n,t]of Object.entries(e))if("object"==typeof t&&null!==t){const r=o.get(t);r&&(e[n]=r)}}}(u,i.stores,e),!i.stores.__cache){const e=new Map;i.stores.__cache={type:"memory",config:{},get:n=>{const t=e.get(n);if(t){if(!(t.expires&&Date.now()>t.expires))return t.value;e.delete(n)}},set:(n,t,o)=>{e.set(n,{value:t,expires:o?Date.now()+o:void 0})},delete:n=>{e.delete(n)}}}return i.destinations=await async function(e,n={}){var t,o;const r={};for(const[s,i]of Object.entries(n))(null==(o=null==(t=i.config)?void 0:t.require)?void 0:o.length)?e.pending.destinations[s]=i:r[s]=Ue(i);return r}(i,e.destinations||{}),i.transformers=await async function(e,n={}){const t={};for(const[o,r]of Object.entries(n)){const{code:n,env:s={}}=r,{config:i}=Oe(r,"before"),{config:a}=Oe({...r,config:i},"next"),c=Object.keys(s).length>0?{...a,env:s}:a,{cache:u}=r,l=u?{...c,cache:u}:c,f=e.logger.scope("transformer").scope(o),g={collector:e,logger:f,id:o,ingest:R(o),config:l,env:s},d=await n(g);t[o]=d}return t}(i,e.transformers||{}),i}async function Be(e){e=e||{};const n=await Ve(e),t=(o=n,{type:"elb",config:{},push:async(e,n,t,r,s,i)=>{if("string"==typeof e&&e.startsWith("walker ")){const r=e.replace("walker ","");return o.command(r,n,t)}let a;if("string"==typeof e)a={name:e},n&&"object"==typeof n&&!Array.isArray(n)&&(a.data=n);else{if(!e||"object"!=typeof e)return Re({ok:!1});a=e,n&&"object"==typeof n&&!Array.isArray(n)&&(a.data={...a.data||{},...n})}return r&&"object"==typeof r&&(a.context=r),s&&Array.isArray(s)&&(a.nested=s),i&&"object"==typeof i&&(a.custom=i),o.push(a)}});var o;n.sources.elb=t;const r=await async function(e,n={}){const t={};for(const[o,r]of Object.entries(n)){const{config:n={}}=r;if(n.require&&n.require.length>0){e.pending.sources[o]=r;continue}const s=await Se(e,o,r);s&&(t[o]=s)}return t}(n,e.sources||{});Object.assign(n.sources,r);const{consent:s,user:i,globals:a,custom:c}=e;s&&await n.command("consent",s),i&&await n.command("user",i),a&&Object.assign(n.globals,a),c&&Object.assign(n.custom,c),n.config.run&&await n.command("run");let u=t.push;const l=Object.values(n.sources).filter(e=>"elb"!==e.type),f=l.find(e=>e.config.primary);return f?u=f.push:l.length>0&&(u=l[0].push),{collector:n,elb:u}}var Ke,We=async e=>{let n;return{get flow(){return n},trigger:(t,o)=>async t=>{var r;if(!n){const t=await Be({...e,run:null==(r=e.run)||r});n={collector:t.collector,elb:t.elb}}const s=(null==o?void 0:o.eventName)||"ucEvent";window.dispatchEvent(new CustomEvent(s,{detail:t}))}}},Fe=(e,n)=>{if(e&&"object"==typeof e)return()=>{n.window.dispatchEvent(new CustomEvent("ucEvent",{detail:e}))}},ze=async e=>{var n,t,o,r,s,i,a,c,u,f,d,p;const{config:v,env:y}=e,{elb:m,logger:h}=y,b=null!=(n=y.window)?n:void 0!==globalThis.window?globalThis.window:void 0,w={eventName:null!=(o=null==(t=null==v?void 0:v.settings)?void 0:t.eventName)?o:"ucEvent",categoryMap:null!=(s=null==(r=null==v?void 0:v.settings)?void 0:r.categoryMap)?s:{},explicitOnly:null==(a=null==(i=null==v?void 0:v.settings)?void 0:i.explicitOnly)||a,apiVersion:null!=(u=null==(c=null==v?void 0:v.settings)?void 0:c.apiVersion)?u:"auto",v3EventName:null!=(d=null==(f=null==v?void 0:v.settings)?void 0:f.v3EventName)?d:"UC_UI_CMP_EVENT"},k={settings:w},j=[];if(b){const e={window:b,elb:m,settings:w,logger:h},n=null!=(p=w.apiVersion)?p:"auto";"v2"===n?j.push(l(e)):"v3"===n||b.__ucCmp?j.push(await g(e)):b.UC_UI?j.push(l(e)):(j.push(l(e)),j.push(await g(e)))}return{type:"usercentrics",config:k,push:m,destroy:async()=>{j.forEach(e=>e())}}},Je=ze;return Ke=s,((r,s,i,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let c of t(s))o.call(r,c)||c===i||e(r,c,{get:()=>s[c],enumerable:!(a=n(s,c))||a.enumerable});return r})(e({},"__esModule",{value:!0}),Ke)})();
|