@uniformdev/context 14.2.1-alpha.128 → 14.2.1-alpha.145
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/api/api.d.ts +1 -1
- package/dist/chunk-A5FZYSIL.mjs +76 -0
- package/dist/chunk-FJWWKKCL.mjs +307 -0
- package/dist/chunk-YGARAHYJ.mjs +11 -0
- package/dist/index.d.ts +28 -7
- package/dist/index.esm.js +3 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/types-c81df08a.d.ts +727 -0
- package/package.json +4 -3
package/dist/api/api.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { a as AggregateGetParameters, b as AggregateGetResponse, c as AggregatePutParameters, d as AggregateDeleteParameters, D as DimensionGetParameters, e as DimensionGetResponse, f as EnrichmentGetParameters, g as EnrichmentGetResponse, h as EnrichmentPutParameters, i as EnrichmentDeleteParameters, j as EnrichmentValuePutParameters, k as EnrichmentValueDeleteParameters, M as ManifestGetParameters, l as ManifestGetResponse, m as QuirkGetParameters, n as QuirkGetResponse, o as QuirkPutParameters, p as QuirkDeleteParameters, q as SignalGetParameters, r as SignalGetResponse, s as SignalPutParameters, t as SignalDeleteParameters, u as TestGetParameters, v as TestGetResponse, w as TestPutParameters, x as TestDeleteParameters, y as DimensionDefinition } from '../contextTypes-7f24fc7c';
|
2
2
|
export { A as Aggregate, d as AggregateDeleteParameters, a as AggregateGetParameters, b as AggregateGetResponse, c as AggregatePutParameters, C as CookieCriteria, I as CurrentPageCriteria, y as DimensionDefinition, D as DimensionGetParameters, e as DimensionGetResponse, z as EnrichmentCategory, E as EnrichmentCategoryWithValues, i as EnrichmentDeleteParameters, f as EnrichmentGetParameters, g as EnrichmentGetResponse, h as EnrichmentPutParameters, B as EnrichmentValue, k as EnrichmentValueDeleteParameters, j as EnrichmentValuePutParameters, H as EventCriteria, M as ManifestGetParameters, l as ManifestGetResponse, P as PageViewCountCriteria, F as QueryStringCriteria, Q as Quirk, G as QuirkCriteria, p as QuirkDeleteParameters, m as QuirkGetParameters, n as QuirkGetResponse, o as QuirkPutParameters, R as RootSignalCriteriaGroup, t as SignalDeleteParameters, q as SignalGetParameters, r as SignalGetResponse, s as SignalPutParameters, S as SignalWithId, T as Test, x as TestDeleteParameters, u as TestGetParameters, v as TestGetResponse, w as TestPutParameters } from '../contextTypes-7f24fc7c';
|
3
|
-
import {
|
3
|
+
import { f as ManifestV2 } from '../types-c81df08a';
|
4
4
|
import '../v2-manifest.swagger-d0899723';
|
5
5
|
import 'mitt';
|
6
6
|
|
@@ -0,0 +1,76 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
11
|
+
}) : x)(function(x) {
|
12
|
+
if (typeof require !== "undefined")
|
13
|
+
return require.apply(this, arguments);
|
14
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
15
|
+
});
|
16
|
+
var __esm = (fn, res) => function __init() {
|
17
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
18
|
+
};
|
19
|
+
var __commonJS = (cb, mod) => function __require2() {
|
20
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
21
|
+
};
|
22
|
+
var __reExport = (target, module, copyDefault, desc) => {
|
23
|
+
if (module && typeof module === "object" || typeof module === "function") {
|
24
|
+
for (let key of __getOwnPropNames(module))
|
25
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
26
|
+
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
|
27
|
+
}
|
28
|
+
return target;
|
29
|
+
};
|
30
|
+
var __toESM = (module, isNodeMode) => {
|
31
|
+
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", !isNodeMode && module && module.__esModule ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
32
|
+
};
|
33
|
+
var __publicField = (obj, key, value) => {
|
34
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
35
|
+
return value;
|
36
|
+
};
|
37
|
+
var __accessCheck = (obj, member, msg) => {
|
38
|
+
if (!member.has(obj))
|
39
|
+
throw TypeError("Cannot " + msg);
|
40
|
+
};
|
41
|
+
var __privateGet = (obj, member, getter) => {
|
42
|
+
__accessCheck(obj, member, "read from private field");
|
43
|
+
return getter ? getter.call(obj) : member.get(obj);
|
44
|
+
};
|
45
|
+
var __privateAdd = (obj, member, value) => {
|
46
|
+
if (member.has(obj))
|
47
|
+
throw TypeError("Cannot add the same private member more than once");
|
48
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
49
|
+
};
|
50
|
+
var __privateSet = (obj, member, value, setter) => {
|
51
|
+
__accessCheck(obj, member, "write to private field");
|
52
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
53
|
+
return value;
|
54
|
+
};
|
55
|
+
var __privateMethod = (obj, member, method) => {
|
56
|
+
__accessCheck(obj, member, "access private method");
|
57
|
+
return method;
|
58
|
+
};
|
59
|
+
|
60
|
+
// ../../node_modules/.pnpm/tsup@5.12.1_typescript@4.6.2/node_modules/tsup/assets/esm_shims.js
|
61
|
+
var init_esm_shims = __esm({
|
62
|
+
"../../node_modules/.pnpm/tsup@5.12.1_typescript@4.6.2/node_modules/tsup/assets/esm_shims.js"() {
|
63
|
+
}
|
64
|
+
});
|
65
|
+
|
66
|
+
export {
|
67
|
+
__require,
|
68
|
+
__commonJS,
|
69
|
+
__toESM,
|
70
|
+
__publicField,
|
71
|
+
__privateGet,
|
72
|
+
__privateAdd,
|
73
|
+
__privateSet,
|
74
|
+
__privateMethod,
|
75
|
+
init_esm_shims
|
76
|
+
};
|
@@ -0,0 +1,307 @@
|
|
1
|
+
import {
|
2
|
+
__privateAdd,
|
3
|
+
__privateGet,
|
4
|
+
__publicField,
|
5
|
+
init_esm_shims
|
6
|
+
} from "./chunk-A5FZYSIL.mjs";
|
7
|
+
|
8
|
+
// src/api/apiClientUtils.ts
|
9
|
+
init_esm_shims();
|
10
|
+
var nullLimitPolicy = async (func) => await func();
|
11
|
+
var ApiClientError = class extends Error {
|
12
|
+
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText) {
|
13
|
+
super(`${errorMessage}
|
14
|
+
${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri})`);
|
15
|
+
this.errorMessage = errorMessage;
|
16
|
+
this.fetchMethod = fetchMethod;
|
17
|
+
this.fetchUri = fetchUri;
|
18
|
+
this.statusCode = statusCode;
|
19
|
+
this.statusText = statusText;
|
20
|
+
Object.setPrototypeOf(this, ApiClientError.prototype);
|
21
|
+
}
|
22
|
+
};
|
23
|
+
|
24
|
+
// src/api/AggregateClient.ts
|
25
|
+
init_esm_shims();
|
26
|
+
|
27
|
+
// src/api/ApiClient.ts
|
28
|
+
init_esm_shims();
|
29
|
+
var ApiClient = class {
|
30
|
+
constructor(options) {
|
31
|
+
__publicField(this, "options");
|
32
|
+
var _a, _b, _c, _d, _e, _f;
|
33
|
+
if (!options.apiKey && !options.bearerToken) {
|
34
|
+
throw new Error("You must provide an API key or a bearer token");
|
35
|
+
}
|
36
|
+
this.options = {
|
37
|
+
...options,
|
38
|
+
fetch: (_a = options.fetch) != null ? _a : fetch,
|
39
|
+
apiHost: (_b = options.apiHost) != null ? _b : "https://uniform.app",
|
40
|
+
apiKey: (_c = options.apiKey) != null ? _c : null,
|
41
|
+
projectId: (_d = options.projectId) != null ? _d : null,
|
42
|
+
bearerToken: (_e = options.bearerToken) != null ? _e : null,
|
43
|
+
limitPolicy: (_f = options.limitPolicy) != null ? _f : nullLimitPolicy
|
44
|
+
};
|
45
|
+
}
|
46
|
+
async apiClient(fetchUri, options) {
|
47
|
+
return this.options.limitPolicy(async () => {
|
48
|
+
var _a;
|
49
|
+
const authHeaders = this.options.apiKey ? {
|
50
|
+
"x-api-key": this.options.apiKey
|
51
|
+
} : {
|
52
|
+
Authorization: `Bearer ${this.options.bearerToken}`
|
53
|
+
};
|
54
|
+
const apiResponse = await fetch(fetchUri.toString(), {
|
55
|
+
...options,
|
56
|
+
headers: {
|
57
|
+
...options == null ? void 0 : options.headers,
|
58
|
+
...authHeaders
|
59
|
+
}
|
60
|
+
});
|
61
|
+
if (!apiResponse.ok) {
|
62
|
+
let message = "";
|
63
|
+
try {
|
64
|
+
const responseText = await apiResponse.text();
|
65
|
+
try {
|
66
|
+
const parsed = JSON.parse(responseText);
|
67
|
+
if (parsed.errorMessage) {
|
68
|
+
message = Array.isArray(parsed.errorMessage) ? parsed.errorMessage.join(", ") : parsed.errorMessage;
|
69
|
+
} else {
|
70
|
+
message = responseText;
|
71
|
+
}
|
72
|
+
} catch (e) {
|
73
|
+
message = responseText;
|
74
|
+
}
|
75
|
+
} catch (e) {
|
76
|
+
message = `General error`;
|
77
|
+
}
|
78
|
+
throw new ApiClientError(message, (_a = options == null ? void 0 : options.method) != null ? _a : "GET", fetchUri.toString(), apiResponse.status);
|
79
|
+
}
|
80
|
+
if (options == null ? void 0 : options.expectNoContent) {
|
81
|
+
return null;
|
82
|
+
}
|
83
|
+
return await apiResponse.json();
|
84
|
+
});
|
85
|
+
}
|
86
|
+
createUrl(path, queryParams) {
|
87
|
+
const url = new URL(`${this.options.apiHost}${path}`);
|
88
|
+
Object.entries(queryParams != null ? queryParams : {}).forEach(([key, value]) => {
|
89
|
+
var _a;
|
90
|
+
if (typeof value !== "undefined" && value !== null) {
|
91
|
+
url.searchParams.append(key, (_a = value == null ? void 0 : value.toString()) != null ? _a : "");
|
92
|
+
}
|
93
|
+
});
|
94
|
+
return url;
|
95
|
+
}
|
96
|
+
};
|
97
|
+
|
98
|
+
// src/api/AggregateClient.ts
|
99
|
+
var _url;
|
100
|
+
var _AggregateClient = class extends ApiClient {
|
101
|
+
constructor(options) {
|
102
|
+
super(options);
|
103
|
+
}
|
104
|
+
async get(options) {
|
105
|
+
const { projectId } = this.options;
|
106
|
+
const fetchUri = this.createUrl(__privateGet(_AggregateClient, _url), { ...options, projectId });
|
107
|
+
return await this.apiClient(fetchUri);
|
108
|
+
}
|
109
|
+
async upsert(body) {
|
110
|
+
const fetchUri = this.createUrl(__privateGet(_AggregateClient, _url));
|
111
|
+
await this.apiClient(fetchUri, {
|
112
|
+
method: "PUT",
|
113
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
114
|
+
expectNoContent: true
|
115
|
+
});
|
116
|
+
}
|
117
|
+
async remove(body) {
|
118
|
+
const fetchUri = this.createUrl(__privateGet(_AggregateClient, _url));
|
119
|
+
await this.apiClient(fetchUri, {
|
120
|
+
method: "DELETE",
|
121
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
122
|
+
expectNoContent: true
|
123
|
+
});
|
124
|
+
}
|
125
|
+
};
|
126
|
+
var AggregateClient = _AggregateClient;
|
127
|
+
_url = new WeakMap();
|
128
|
+
__privateAdd(AggregateClient, _url, "/api/v2/aggregate");
|
129
|
+
|
130
|
+
// src/api/EnrichmentClient.ts
|
131
|
+
init_esm_shims();
|
132
|
+
var _url2, _valueUrl;
|
133
|
+
var _EnrichmentClient = class extends ApiClient {
|
134
|
+
constructor(options) {
|
135
|
+
super(options);
|
136
|
+
}
|
137
|
+
async get(options) {
|
138
|
+
const { projectId } = this.options;
|
139
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _url2), { ...options, projectId });
|
140
|
+
return await this.apiClient(fetchUri);
|
141
|
+
}
|
142
|
+
async upsertCategory(body) {
|
143
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _url2));
|
144
|
+
await this.apiClient(fetchUri, {
|
145
|
+
method: "PUT",
|
146
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
147
|
+
expectNoContent: true
|
148
|
+
});
|
149
|
+
}
|
150
|
+
async removeCategory(body) {
|
151
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _url2));
|
152
|
+
await this.apiClient(fetchUri, {
|
153
|
+
method: "DELETE",
|
154
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
155
|
+
expectNoContent: true
|
156
|
+
});
|
157
|
+
}
|
158
|
+
async upsertValue(body) {
|
159
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _valueUrl));
|
160
|
+
await this.apiClient(fetchUri, {
|
161
|
+
method: "PUT",
|
162
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
163
|
+
expectNoContent: true
|
164
|
+
});
|
165
|
+
}
|
166
|
+
async removeValue(body) {
|
167
|
+
const fetchUri = this.createUrl(__privateGet(_EnrichmentClient, _valueUrl));
|
168
|
+
await this.apiClient(fetchUri, {
|
169
|
+
method: "DELETE",
|
170
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
171
|
+
expectNoContent: true
|
172
|
+
});
|
173
|
+
}
|
174
|
+
};
|
175
|
+
var EnrichmentClient = _EnrichmentClient;
|
176
|
+
_url2 = new WeakMap();
|
177
|
+
_valueUrl = new WeakMap();
|
178
|
+
__privateAdd(EnrichmentClient, _url2, "/api/v1/enrichments");
|
179
|
+
__privateAdd(EnrichmentClient, _valueUrl, "/api/v1/enrichment-values");
|
180
|
+
|
181
|
+
// src/api/ManifestClient.ts
|
182
|
+
init_esm_shims();
|
183
|
+
var _url3;
|
184
|
+
var _ManifestClient = class extends ApiClient {
|
185
|
+
constructor(options) {
|
186
|
+
super(options);
|
187
|
+
}
|
188
|
+
async get(options) {
|
189
|
+
const { projectId } = this.options;
|
190
|
+
const fetchUri = this.createUrl(__privateGet(_ManifestClient, _url3), { ...options, projectId });
|
191
|
+
return await this.apiClient(fetchUri);
|
192
|
+
}
|
193
|
+
};
|
194
|
+
var ManifestClient = _ManifestClient;
|
195
|
+
_url3 = new WeakMap();
|
196
|
+
__privateAdd(ManifestClient, _url3, "/api/v2/manifest");
|
197
|
+
|
198
|
+
// src/api/QuirkClient.ts
|
199
|
+
init_esm_shims();
|
200
|
+
var _url4;
|
201
|
+
var _QuirkClient = class extends ApiClient {
|
202
|
+
constructor(options) {
|
203
|
+
super(options);
|
204
|
+
}
|
205
|
+
async get(options) {
|
206
|
+
const { projectId } = this.options;
|
207
|
+
const fetchUri = this.createUrl(__privateGet(_QuirkClient, _url4), { ...options, projectId });
|
208
|
+
return await this.apiClient(fetchUri);
|
209
|
+
}
|
210
|
+
async upsert(body) {
|
211
|
+
const fetchUri = this.createUrl(__privateGet(_QuirkClient, _url4));
|
212
|
+
await this.apiClient(fetchUri, {
|
213
|
+
method: "PUT",
|
214
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
215
|
+
expectNoContent: true
|
216
|
+
});
|
217
|
+
}
|
218
|
+
async remove(body) {
|
219
|
+
const fetchUri = this.createUrl(__privateGet(_QuirkClient, _url4));
|
220
|
+
await this.apiClient(fetchUri, {
|
221
|
+
method: "DELETE",
|
222
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
223
|
+
expectNoContent: true
|
224
|
+
});
|
225
|
+
}
|
226
|
+
};
|
227
|
+
var QuirkClient = _QuirkClient;
|
228
|
+
_url4 = new WeakMap();
|
229
|
+
__privateAdd(QuirkClient, _url4, "/api/v2/quirk");
|
230
|
+
|
231
|
+
// src/api/SignalClient.ts
|
232
|
+
init_esm_shims();
|
233
|
+
var _url5;
|
234
|
+
var _SignalClient = class extends ApiClient {
|
235
|
+
constructor(options) {
|
236
|
+
super(options);
|
237
|
+
}
|
238
|
+
async get(options) {
|
239
|
+
const { projectId } = this.options;
|
240
|
+
const fetchUri = this.createUrl(__privateGet(_SignalClient, _url5), { ...options, projectId });
|
241
|
+
return await this.apiClient(fetchUri);
|
242
|
+
}
|
243
|
+
async upsert(body) {
|
244
|
+
const fetchUri = this.createUrl(__privateGet(_SignalClient, _url5));
|
245
|
+
await this.apiClient(fetchUri, {
|
246
|
+
method: "PUT",
|
247
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
248
|
+
expectNoContent: true
|
249
|
+
});
|
250
|
+
}
|
251
|
+
async remove(body) {
|
252
|
+
const fetchUri = this.createUrl(__privateGet(_SignalClient, _url5));
|
253
|
+
await this.apiClient(fetchUri, {
|
254
|
+
method: "DELETE",
|
255
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
256
|
+
expectNoContent: true
|
257
|
+
});
|
258
|
+
}
|
259
|
+
};
|
260
|
+
var SignalClient = _SignalClient;
|
261
|
+
_url5 = new WeakMap();
|
262
|
+
__privateAdd(SignalClient, _url5, "/api/v2/signal");
|
263
|
+
|
264
|
+
// src/api/TestClient.ts
|
265
|
+
init_esm_shims();
|
266
|
+
var _url6;
|
267
|
+
var _TestClient = class extends ApiClient {
|
268
|
+
constructor(options) {
|
269
|
+
super(options);
|
270
|
+
}
|
271
|
+
async get(options) {
|
272
|
+
const { projectId } = this.options;
|
273
|
+
const fetchUri = this.createUrl(__privateGet(_TestClient, _url6), { ...options, projectId });
|
274
|
+
return await this.apiClient(fetchUri);
|
275
|
+
}
|
276
|
+
async upsert(body) {
|
277
|
+
const fetchUri = this.createUrl(__privateGet(_TestClient, _url6));
|
278
|
+
await this.apiClient(fetchUri, {
|
279
|
+
method: "PUT",
|
280
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
281
|
+
expectNoContent: true
|
282
|
+
});
|
283
|
+
}
|
284
|
+
async remove(body) {
|
285
|
+
const fetchUri = this.createUrl(__privateGet(_TestClient, _url6));
|
286
|
+
await this.apiClient(fetchUri, {
|
287
|
+
method: "DELETE",
|
288
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
289
|
+
expectNoContent: true
|
290
|
+
});
|
291
|
+
}
|
292
|
+
};
|
293
|
+
var TestClient = _TestClient;
|
294
|
+
_url6 = new WeakMap();
|
295
|
+
__privateAdd(TestClient, _url6, "/api/v2/test");
|
296
|
+
|
297
|
+
export {
|
298
|
+
nullLimitPolicy,
|
299
|
+
ApiClientError,
|
300
|
+
ApiClient,
|
301
|
+
AggregateClient,
|
302
|
+
EnrichmentClient,
|
303
|
+
ManifestClient,
|
304
|
+
QuirkClient,
|
305
|
+
SignalClient,
|
306
|
+
TestClient
|
307
|
+
};
|
package/dist/index.d.ts
CHANGED
@@ -1,26 +1,47 @@
|
|
1
|
-
import {
|
2
|
-
export { A as AggregateDimension,
|
1
|
+
import { T as TransitionDataStore, S as StorageCommands, V as VisitorData, a as TransitionDataStoreOptions, D as DecayFunction, O as OutputSeverity, L as LogDrain, C as ContextPlugin, b as CriteriaEvaluator, c as StringMatch, d as ScoreVector, A as AggregateDimension, e as VariantMatchCriteria } from './types-c81df08a';
|
2
|
+
export { A as AggregateDimension, k as AggregateDimensionInput, a7 as BehaviorTag, Z as Context, Y as ContextEvents, U as ContextOptions, C as ContextPlugin, q as ContextState, r as ContextStateUpdate, b as CriteriaEvaluator, l as CriteriaEvaluatorResult, D as DecayFunction, z as DecayOptions, af as DevToolsActions, aj as DevToolsDataEvent, ag as DevToolsEvent, ah as DevToolsEvents, an as DevToolsForgetEvent, ak as DevToolsHelloEvent, ai as DevToolsLogEvent, am as DevToolsRawCommandsEvent, ae as DevToolsState, ad as DevToolsUiVersion, al as DevToolsUpdateEvent, a6 as DimensionMatch, E as EnrichmentCategory, n as EnrichmentData, o as EventData, G as GroupCriteriaEvaluator, I as IdentifyCommand, L as LogDrain, a1 as LogMessage, _ as LogMessages, M as ManifestInstance, f as ManifestV2, a0 as MessageFunc, t as ModifyScoreCommand, u as ModifySessionScoreCommand, N as NumberMatch, O as OutputSeverity, W as PersonalizationEvent, P as PersonalizationManifest, a4 as PersonalizeOptions, a9 as PersonalizedResult, a8 as PersonalizedVariant, Q as Quirks, K as SERVER_STATE_ID, d as ScoreVector, J as ServerToClientTransitionState, v as SetConsentCommand, y as SetControlGroupCommand, w as SetQuirkCommand, x as SetTestCommand, $ as Severity, g as Signal, i as SignalCriteria, h as SignalCriteriaGroup, s as StorageCommand, S as StorageCommands, c as StringMatch, ac as TaggedContent, j as TestDefinition, X as TestEvent, a3 as TestOptions, ab as TestResult, aa as TestVariant, m as Tests, T as TransitionDataStore, R as TransitionDataStoreEvents, a as TransitionDataStoreOptions, e as VariantMatchCriteria, V as VisitorData, H as VisitorDataStore, F as VisitorDataStoreEvents, B as VisitorDataStoreOptions, p as emptyVisitorData, a5 as personalizeVariations, a2 as testVariations } from './types-c81df08a';
|
3
|
+
import Cookies from 'js-cookie';
|
3
4
|
import './v2-manifest.swagger-d0899723';
|
4
5
|
import 'mitt';
|
5
6
|
|
6
7
|
declare type CookieTransitionDataStoreOptions = {
|
7
|
-
|
8
|
+
/**
|
9
|
+
* The value of the score cookie during server-side rendering.
|
10
|
+
* Should be parsed from the incoming request.
|
11
|
+
* IMPORTANT: If not passed, the transition store will not have any effect during SSR.
|
12
|
+
*/
|
13
|
+
serverCookieValue?: string;
|
14
|
+
/**
|
15
|
+
* The name of the cookie to store client-to-server score information in.
|
16
|
+
* Defaults to UNIFORM_DEFAULT_COOKIE_NAME if not set.
|
17
|
+
*/
|
8
18
|
cookieName?: string;
|
19
|
+
/**
|
20
|
+
* Attributes to set on the transfer cookie.
|
21
|
+
* Persistence is not necessary, because the data is only used for temporary transition;
|
22
|
+
* local storage is the master copy. Defaults to SameSite=Lax.
|
23
|
+
*/
|
24
|
+
cookieAttributes?: Cookies.CookieAttributes;
|
9
25
|
};
|
26
|
+
declare const UNIFORM_DEFAULT_COOKIE_NAME = "ufvd";
|
27
|
+
/**
|
28
|
+
* Handles client-to-server score handoff using an encoded cookie with the visitor score vector.
|
29
|
+
* NOTE: forget me is not supported when on the server side.
|
30
|
+
*/
|
10
31
|
declare class CookieTransitionDataStore extends TransitionDataStore {
|
11
32
|
#private;
|
12
|
-
constructor({
|
33
|
+
constructor({ serverCookieValue, cookieName, cookieAttributes, }: CookieTransitionDataStoreOptions);
|
13
34
|
handleDelete(): Promise<void>;
|
14
35
|
handleUpdateData(_: StorageCommands[], computedValue: VisitorData): Promise<void>;
|
15
36
|
}
|
16
37
|
|
17
38
|
declare type EdgeTransitionDataStoreOptions = TransitionDataStoreOptions & {
|
18
|
-
|
39
|
+
serverCookieValue?: string;
|
19
40
|
visitorIdCookieName?: string;
|
20
41
|
};
|
21
42
|
declare class EdgeTransitionDataStore extends TransitionDataStore {
|
22
43
|
#private;
|
23
|
-
constructor({
|
44
|
+
constructor({ serverCookieValue, visitorIdCookieName, ...base }: EdgeTransitionDataStoreOptions);
|
24
45
|
handleDelete(fromAllDevices?: boolean): Promise<void>;
|
25
46
|
handleUpdateData(commands: StorageCommands[]): Promise<void>;
|
26
47
|
}
|
@@ -126,4 +147,4 @@ declare const EdgeNodeTagName = "nesitag";
|
|
126
147
|
*/
|
127
148
|
declare function enableContextDevTools(): ContextPlugin;
|
128
149
|
|
129
|
-
export { CookieTransitionDataStore, CookieTransitionDataStoreOptions, EdgeNodeTagName, EdgePersonalizeComponentOptions, EdgeTestComponentOptions, EdgeTransitionDataStore, EdgeTransitionDataStoreOptions, LinearDecayOptions, ScriptType, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, currentPageEvaluator, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, evaluateVariantMatch, eventEvaluator, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, queryStringEvaluator, quirkEvaluator };
|
150
|
+
export { CookieTransitionDataStore, CookieTransitionDataStoreOptions, EdgeNodeTagName, EdgePersonalizeComponentOptions, EdgeTestComponentOptions, EdgeTransitionDataStore, EdgeTransitionDataStoreOptions, LinearDecayOptions, ScriptType, UNIFORM_DEFAULT_COOKIE_NAME, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, currentPageEvaluator, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, evaluateVariantMatch, eventEvaluator, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, queryStringEvaluator, quirkEvaluator };
|
package/dist/index.esm.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import{a as H}from"./chunk-CEKV2MHL.mjs";import{d as D,e as s,f as d,g as m,h as S,i as u}from"./chunk-AFJ7PNM5.mjs";u();u();u();function yt(r,t){let e={...r};for(let o in t){let i=Dt(r,o,t,new Set([o]));i!==0&&(e[o]=i)}return e}function Dt(r,t,e,o){var a;let i=0;for(let n of e[t].inputs){let c=(a=r[n.dim])!=null?a:0;if(!c&&e[n.dim]){if(o.has(n.dim))continue;let g=new Set(o);g.add(n.dim),c=Dt(r,n.dim,e,g)}if(c!==0)if(n.sign==="c"){i=0;break}else n.sign==="-"?i-=c:i+=c}return i}u();var G,w,it=class{constructor(t,e,o){d(this,G,void 0);d(this,w,void 0);D(this,"signal");m(this,w,t),this.signal=e,m(this,G,o)}computeSignal(t,e){if(t.scores[s(this,w)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=s(this,G).evaluate(t,this.signal.crit,e,this.signal,s(this,w)),a=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!i.changed){if(i.result)e.push({type:a,data:{dimension:s(this,w),delta:this.signal.str}});else if(this.signal.dur==="t"){let n=t.visitor.sessionScores[s(this,w)];n&&e.push({type:a,data:{dimension:s(this,w),delta:-n}})}}}};G=new WeakMap,w=new WeakMap;var V,_,nt=class{constructor({manifest:t,evaluator:e=new j({})}){D(this,"data");d(this,V,void 0);d(this,_,void 0);var o,i,a;m(this,V,(o=t.project)!=null?o:{}),this.data=t,m(this,_,Object.entries((a=(i=s(this,V).pz)==null?void 0:i.sig)!=null?a:[]).map(([n,c])=>new it(n,c,e)))}rollForControlGroup(){var t,e;return Math.random()<((e=(t=s(this,V).pz)==null?void 0:t.control)!=null?e:0)}getTest(t){var e;return(e=s(this,V).test)==null?void 0:e[t]}computeSignals(t){let e=[];return s(this,_).forEach(o=>{o.computeSignal(t,e)}),e}computeAggregateDimensions(t){var e,o;return yt(t,(o=(e=s(this,V).pz)==null?void 0:e.agg)!=null?o:{})}getDimensionByKey(t){var o,i,a,n;let e=t.indexOf(H);return e<=0?(i=(o=s(this,V).pz)==null?void 0:o.sig)==null?void 0:i[t]:(n=(a=s(this,V).pz)==null?void 0:a.enr)==null?void 0:n[t.substring(0,e)]}};V=new WeakMap,_=new WeakMap;u();import{dequal as Jt}from"dequal/lite";var xt=(r,t)=>{var a,n;if(t.type!=="CK")return{result:!1,changed:!1};let e=!Jt(Ct(r.state.cookies),Ct((a=r.previousState)==null?void 0:a.cookies)),o=(n=r.state.cookies)==null?void 0:n[t.cookieName];return{result:b(o,t.match),changed:e}};function Ct(r){if(!r)return;if(!r.ufvd)return r;let{ufvd:t,...e}=r;return e}u();u();function Vt(r,t){var o;if(typeof r=="undefined"||r===null)return!1;let e=Number(r);if(isNaN(e))return!1;switch((o=t==null?void 0:t.op)!=null?o:"="){case"=":return e===t.rhs;case"!=":return e!==t.rhs;case">":return e>t.rhs;case"<":return e<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}u();function Y(r,t){return`${r}${H}${t}`}var st=Y("$pvc","v"),bt=(r,t,e)=>{var n,c;if(t.type!=="PVC")return{result:!1,changed:!1};let o=!r.previousState||((n=r.state.url)==null?void 0:n.toString())!==((c=r.previousState.url)==null?void 0:c.toString()),a=(r.visitor.sessionScores[st]||0)+1;if(Vt(a,t.match)){let l=e.some(g=>g.type==="modscoreS"&&g.data.dimension===st);return o&&!l&&e.push({type:"modscoreS",data:{dimension:st,delta:1}}),{result:!0,changed:o}}return{result:!1,changed:o}};u();var Et=(r,t)=>{var a,n,c,l,g;if(t.type!=="QS")return{result:!1,changed:!1};let e=!r.previousState||((n=(a=r.state.url)==null?void 0:a.searchParams)==null?void 0:n.toString())!==((l=(c=r.previousState.url)==null?void 0:c.searchParams)==null?void 0:l.toString()),o=(g=r.state.url)==null?void 0:g.searchParams.get(t.queryName);return{result:b(o,t.match),changed:e}};u();var Tt=(r,t,e,o,i)=>{var y;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof window=="undefined"&&o.dur==="t"&&r.scores[i]>0)return{result:!0,changed:!1};let a=r.visitor.quirks[t.key],n=(y=r.state.quirks)==null?void 0:y[t.key],c=n!=null?n:a,l=Boolean(n&&a!==n);return{result:b(c,t.match),changed:l}};u();var wt=(r,t)=>{var o,i;if(t.type!=="EVT")return{result:!1,changed:!1};let e=(i=(o=r.state.events)==null?void 0:o.some(a=>b(a.event,t.event)))!=null?i:!1;return{result:e,changed:e}};u();var kt=(r,t)=>{var i,a,n,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let e=!r.previousState||((a=(i=r.state.url)==null?void 0:i.pathname)==null?void 0:a.toString())!==((c=(n=r.previousState.url)==null?void 0:n.pathname)==null?void 0:c.toString());return{result:b((l=r.state.url)==null?void 0:l.pathname,t.path),changed:e}};u();var F,j=class{constructor(t){d(this,F,void 0);m(this,F,t)}evaluate(t,e,o,i,a){let n=!(e.op==="&"||!e.op),c=!1;for(let l of e.clauses){let g;if(l.type==="G")g=this.evaluate(t,l,o,i,a);else{let y=s(this,F)[l.type];if(!y)throw new Error(`${l.type} signal criteria not registered`);g=y(t,l,o,i,a)}if(g.changed&&(c=!0),g.result===n)return{result:n,changed:c}}return{result:!n,changed:c}}};F=new WeakMap;u();function b(r,t){var n,c,l,g,y,x;let e=(n=t==null?void 0:t.op)!=null?n:"=";if(t.op==="*")return r!==null&&typeof r!="undefined";if(t.op==="!*")return r===null||typeof r=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${e}`);let o=(c=t.cs)!=null?c:!1,i=(o?r!=null?r:"":Pt(r)).toString(),a=(o?t.rhs:Pt(t.rhs)).toString();switch(e){case"=":return i===a;case"!=":return i!==a;case"~":return(l=i.includes(a))!=null?l:!1;case"!~":return!((g=i.includes(a))==null||g);case"//":return new RegExp(t.rhs.toString(),o?"":"i").test((y=r==null?void 0:r.toString())!=null?y:"");case"!//":return!new RegExp(t.rhs.toString(),o?"":"i").test((x=r==null?void 0:r.toString())!=null?x:"");default:throw new Error(`Unknown match type ${e}.`)}}function Pt(r){var t,e;return(e=(t=r==null?void 0:r.toString())==null?void 0:t.toUpperCase())!=null?e:""}u();var X=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});u();u();import Ht from"mitt";import{dequal as Yt}from"dequal/lite";var Xt="__UNIFORM_DATA__",O,z,Q=class{constructor({initialData:t}){d(this,O,void 0);d(this,z,Ht());D(this,"events",{on:s(this,z).on,off:s(this,z).off});t&&m(this,O,t)}get data(){return s(this,O)}updateData(t,e){return m(this,O,e),this.handleUpdateData(t,e)}async delete(t){m(this,O,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){Yt(this.data,t)||(m(this,O,t),s(this,z).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Xt);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};O=new WeakMap,z=new WeakMap;u();var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ot=at.split(""),Mt=new Array(123);for(let r=0;r<at.length;r++)Mt[at.charCodeAt(r)]=r;var ut=r=>{if(r<0)return`-${ut(-r)}`;let t=r>>>0,e=r/4294967296>>>0,o="";for(;e>0;)o=Ot[63&t]+o,t>>>=6,t|=(63&e)<<26,e>>>=6;let i="";do i=Ot[63&t]+i,t>>>=6;while(t>0);return i+o},Rt=r=>{let t=0,e=r.charAt(0)==="-"?1:0;for(let o=e;o<r.length;o++)t=t*64+Mt[r.charCodeAt(o)];return e?-t:t};var Lt=typeof window=="undefined",R,L,Wt=class extends Q{constructor({cookieAdapter:t,cookieName:e="ufvd"}){super({initialData:Lt?Zt(t.get(e)):void 0});d(this,R,void 0);d(this,L,void 0);m(this,R,e),m(this,L,t)}handleDelete(){return s(this,L).remove(s(this,R)),Promise.resolve()}async handleUpdateData(t,e){Lt||(e.consent?s(this,L).set(s(this,R),te(e)):s(this,L).remove(s(this,R)))}};R=new WeakMap,L=new WeakMap;var It="~",zt="!",qt="-";function Zt(r){if(!r)return;let t=r.split(It);if(t.length>3)return;let[e,o,i]=t;return{consent:!0,sessionScores:Ut(ct(o)),scores:Ut(ct(i)),tests:ct(e)}}function ct(r){return r.split(zt).map(e=>e.split(qt)).reduce((e,o)=>(o.length!==2||(e[o[0]]=o[1]),e),{})}function Ut(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=Rt(o),t),{})}function te(r){return[lt(r.tests),lt(At(r.sessionScores)),lt(At(r.scores))].join(It)}function At(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=ut(o),t),{})}function lt(r){return Object.entries(r).map(t=>t.join(qt)).join(zt)}u();var W,re,ee=class extends Q{constructor({cookieAdapter:t,visitorIdCookieName:e="ufvi",...o}){super(o);d(this,W);o.initialData||S(this,W,re).call(this).catch(i=>{console.error(i)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let e=await new Promise(o=>{setTimeout(()=>{o(void 0)},2e3)});e&&this.signalAsyncDataUpdate(e)}};W=new WeakSet,re=async function(){let t=await new Promise(e=>{setTimeout(()=>{e(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};u();function ar(r){let{gracePeriod:t=864e5,decayRate:e=1/30,decayCap:o=.95}=r!=null?r:{};return function({now:a,lastUpd:n,scores:c,sessionScores:l}){if(typeof n!="number")return!1;let y=a-n-t;if(y<=0)return!1;let x=y/864e5,I=1-Math.min(o,x*e);return I<=0?!1:(Nt(c,I),Nt(l,I),!0)}}function Nt(r,t){for(let e in r)r[e]*=t}u();import ne from"mitt";import{dequal as Z}from"dequal/lite";u();var dt=class{constructor(){D(this,"inMemoryFallback",{});D(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let e=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||e)return e;try{let o=localStorage.getItem(t);return o?JSON.parse(o):void 0}catch(o){return e}}set(t,e,o){if(this.inMemoryFallback[t]=e,!(!this.hasLocalStorageObject||!o))try{localStorage.setItem(t,JSON.stringify(e))}catch(i){console.warn(i)}}delete(t,e){e||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(o){}}};u();import oe from"rfdc";var ie=oe();function $t(r,t,e){let o=t?ie(t):X();return r.forEach(i=>{var a,n;switch(i.type){case"consent":o.consent=i.data;break;case"setquirk":o.quirks[i.data.key]=i.data.value;break;case"settest":o.tests[i.data.test]=i.data.variant;break;case"modscore":if(e)break;let c=Number(i.data.delta);if(isNaN(c))throw new Error("Non-number delta received");let l=(a=o.scores[i.data.dimension])!=null?a:0;o.scores[i.data.dimension]=l+c;break;case"modscoreS":if(e)break;let g=Number(i.data.delta);if(isNaN(g))throw new Error("Non-number delta received");let y=(n=o.sessionScores[i.data.dimension])!=null?n:0;o.sessionScores[i.data.dimension]=y+g;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var tt="ufvisitor",E,U,N,h,C,M,k,q,et,se,rt,ae,K,Gt,B,_t,pt=class{constructor(t){d(this,C);d(this,k);d(this,et);d(this,rt);d(this,K);d(this,B);d(this,E,ne());d(this,U,new dt);d(this,N,void 0);d(this,h,void 0);D(this,"events",{on:s(this,E).on,off:s(this,E).off});if(m(this,h,t),s(this,C,M)||S(this,k,q).call(this,S(this,B,_t).call(this),!0),t.transitionStore){let e=t.transitionStore.getClientTransitionState();if(e){let i=[];e.quirks&&i.push(...Object.entries(e.quirks).map(([a,n])=>({type:"setquirk",data:{key:a,value:n}}))),e.tests&&i.push(...Object.entries(e.tests).map(([a,n])=>({type:"settest",data:{test:a,variant:n}}))),this.updateData(i),e.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(e.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{S(this,k,q).call(this,{...s(this,C,M).visitorData,...i})});let o=t.transitionStore.data;o&&S(this,k,q).call(this,{...s(this,C,M).visitorData,...o},!0)}}get data(){var e,o;let t=s(this,C,M);if(S(this,rt,ae).call(this,t)){let{sessionScores:i,...a}=t.visitorData;return S(this,k,q).call(this,{...a,sessionScores:{}}),(o=(e=s(this,h)).onLogMessage)==null||o.call(e,["info",120]),s(this,C,M).visitorData}return t.visitorData}get decayEnabled(){return!!s(this,h).decay}async updateData(t){var o,i,a,n;if(t.length===0)return;(i=(o=s(this,h)).onLogMessage)==null||i.call(o,["debug",101,t]);let e=$t(t,this.data,(a=s(this,C,M))==null?void 0:a.visitorData.controlGroup);t.some(c=>c.type==="consent"&&!c.data)&&s(this,U).delete(tt,!0),S(this,k,q).call(this,e),await((n=s(this,h).transitionStore)==null?void 0:n.updateData(t,s(this,C,M).visitorData))}async delete(t){var e,o,i;s(this,U).delete(tt,!1),await((e=s(this,h).transitionStore)==null?void 0:e.delete(t)),S(this,k,q).call(this,S(this,B,_t).call(this)),(i=(o=s(this,h)).onLogMessage)==null||i.call(o,["info",103,t])}};E=new WeakMap,U=new WeakMap,N=new WeakMap,h=new WeakMap,C=new WeakSet,M=function(){return s(this,U).get(tt)},k=new WeakSet,q=function(t,e=!1){var y,x,I,ht,vt,St;let o=s(this,C,M),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(S(this,K,Gt).call(this,t.scores),S(this,K,Gt).call(this,t.sessionScores),(x=(y=s(this,h)).decay)==null||x.call(y,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores}));let a=!Z(o==null?void 0:o.visitorData.scores,t.scores),n=!Z(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),c=!Z(o==null?void 0:o.visitorData.quirks,t.quirks),l=!Z(o==null?void 0:o.visitorData.tests,t.tests),g={updated:i,visitorData:t};S(this,et,se).call(this),s(this,U).set(tt,g,!!t.consent),(ht=(I=s(this,h)).onLogMessage)==null||ht.call(I,["debug",102,t]),e||((a||n)&&s(this,E).emit("scoresUpdated",t),c&&s(this,E).emit("quirksUpdated",t),l&&s(this,E).emit("testsUpdated",t),((vt=o==null?void 0:o.visitorData)==null?void 0:vt.consent)!==t.consent&&s(this,E).emit("consentUpdated",t),((St=o==null?void 0:o.visitorData)==null?void 0:St.controlGroup)!==t.controlGroup&&s(this,E).emit("controlGroupUpdated",t))},et=new WeakSet,se=function(){typeof window=="undefined"||!s(this,h).visitLifespan||(s(this,N)&&window.clearTimeout(s(this,N)),m(this,N,window.setTimeout(()=>{this.data},s(this,h).visitLifespan+50)))},rt=new WeakSet,ae=function(t){let e=s(this,h).visitLifespan;return e?t.updated+e<Date.now():!1},K=new WeakSet,Gt=function(t){var e,o;if(!!s(this,h).manifest)for(let i in t){let a=t[i],n=s(this,h).manifest.getDimensionByKey(i);!n||a>n.cap&&((o=(e=s(this,h)).onLogMessage)==null||o.call(e,["debug",110,{dim:i,score:a,cap:n.cap}]),t[i]=n.cap)}},B=new WeakSet,_t=function(){var t,e,o;return{...X(),consent:(t=s(this,h).defaultConsent)!=null?t:!1,controlGroup:(o=(e=s(this,h).manifest)==null?void 0:e.rollForControlGroup())!=null?o:!1}};u();import ce from"mitt";u();u();function jt({context:r,variations:t,take:e=1}){var c,l;let o=(c=r.storage.data.controlGroup)!=null?c:!1,i=[],a=!1,n=r.scores;for(let g of t){if(i.length===e)break;if(!((l=g.pz)!=null&&l.crit.length)){i.push(g);continue}!o&&Ft(g.pz,n)&&(a=!0,i.push(g))}return{personalized:a,variations:i}}u();function Ft(r,t){return r!=null&&r.crit?!r.op||r.op==="&"?r.crit.every(e=>Qt(e,t)):r.crit.some(e=>Qt(e,t)):!0}function Qt(r,t){var n;let{op:e,l:o}=r,i=(n=t[o])!=null?n:0;if(e==="+")return Math.max(...Object.values(t))===i&&i>0;if(e==="-")return Math.min(...Object.values(t))===i&&i>0;let a=r.rDim?t[r.rDim]:r.r;if(a===void 0)return!1;if(e===">")return i>a;if(e===">=")return i>=a;if(e==="<")return i<a;if(e==="<=")return i<=a;if(e==="=")return i===a;if(e==="!=")return i!==a;throw new Error(`Unknown op: ${e}`)}u();var ue=r=>{let{values:t,total:e,missingDistribution:o}=r.reduce((i,a)=>(a.testDistribution?i.total+=a.testDistribution:++i.missingDistribution,i.values.push(a.testDistribution),i),{values:[],total:0,missingDistribution:0});if(e>100)throw new Error(`Total distribution ${e} is over the maximum 100.`);if(e<100){let a=(100-e)/o;t.forEach((n,c)=>{typeof n=="undefined"&&(t[c]=a)})}return t},ft=({name:r,context:t,variations:e})=>{var a;let o,i=t.getTestVariantId(r);if(i===null)return{result:void 0,variantAssigned:!1};if(i&&(o=e.find(n=>n.id===i),o||t.log("warn",401,{test:r,variant:i})),!o){let n=ue(e),c=Math.floor(Math.random()*100),l=0;o=e.find((g,y)=>{let x=n[y];if(c>l&&c<=l+x)return g;l+=x}),o&&t.setTestVariantId(r,(a=o.id)!=null?a:"Unknown")}return{result:o,variantAssigned:!i}};import{dequal as Kt}from"dequal/lite";var A,P,T,J,v,$,gt,le=class{constructor(t){d(this,$);D(this,"manifest");d(this,A,!1);d(this,P,{});d(this,T,void 0);d(this,J,{});d(this,v,ce());D(this,"events",{on:s(this,v).on,off:s(this,v).off});D(this,"storage");var i,a;let{manifest:e,...o}=t;m(this,T,{}),(i=t.plugins)==null||i.forEach(n=>{!n.logDrain||s(this,v).on("log",n.logDrain)}),this.manifest=new nt({manifest:e,evaluator:new j({CK:xt,QS:Et,QK:Tt,PVC:bt,EVT:wt,PV:kt})}),this.storage=new pt({...o,manifest:this.manifest,onServerTransitionScoresReceived:n=>{m(this,P,n),m(this,A,!0),s(this,v).emit("log",["debug",130,n])},onLogMessage:n=>s(this,v).emit("log",n)}),this.storage.events.on("scoresUpdated",S(this,$,gt).bind(this)),s(this,A)||S(this,$,gt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",n=>{let c=this.manifest.computeSignals({scores:s(this,P),state:s(this,T),previousState:s(this,T),visitor:this.storage.data});this.storage.updateData(c),s(this,v).emit("quirksUpdated",n.quirks),s(this,v).emit("log",["info",4,n.quirks])}),s(this,v).emit("log",["debug",1]),(a=t.plugins)==null||a.forEach(n=>{!n.init||n.init(this)})}get scores(){return s(this,P)}async update(t){var o;let e=[];t.quirks&&e.push(...Object.entries(t.quirks).map(([i,a])=>({type:"setquirk",data:{key:i,value:a}}))),t.enrichments&&t.enrichments.forEach(i=>{let a=Y(i.cat,i.key);this.manifest.getDimensionByKey(a)?e.push({type:"modscore",data:{dimension:a,delta:i.str}}):s(this,v).emit("log",["warn",5,i])}),e.push(...this.manifest.computeSignals({state:t,previousState:s(this,T),visitor:this.storage.data,scores:s(this,P)})),s(this,v).emit("log",["debug",2,{...t,url:(o=t.url)==null?void 0:o.toString()}]),m(this,T,{...s(this,T),...t}),await this.storage.updateData(e),s(this,A)&&(S(this,$,gt).call(this,this.storage.data),m(this,A,!1),s(this,v).emit("log",["debug",131]))}getTestVariantId(t){var o;let e=this.manifest.getTest(t);return e?(o=e.wv)!=null?o:this.storage.data.tests[t]:(s(this,v).emit("log",["warn",401,t]),null)}setTestVariantId(t,e){this.storage.updateData([{type:"settest",data:{test:t,variant:e}}])}log(...t){s(this,v).emit("log",t)}test(t){var o,i;let e=ft({...t,context:this});return s(this,v).emit("testResult",{name:t.name,variantId:(i=(o=e.result)==null?void 0:o.id)!=null?i:void 0,variantAssigned:e.variantAssigned}),e}personalize(t){let e=jt({...t,context:this}),o=s(this,J)[t.name],i={name:t.name,variantIds:e.variations.map(a=>{var n;return(n=a.id)!=null?n:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return o&&Kt(i.variantIds,o)&&(i.changed=!1),s(this,v).emit("personalizationResult",i),s(this,J)[t.name]=i.variantIds,e}async forget(t){m(this,T,{}),await this.storage.delete(t)}};A=new WeakMap,P=new WeakMap,T=new WeakMap,J=new WeakMap,v=new WeakMap,$=new WeakSet,gt=function(t){var i;let e={...t.scores};for(let a in t.sessionScores)e[a]=((i=e[a])!=null?i:0)+t.sessionScores[a];e=this.manifest.computeAggregateDimensions(e),!Kt(e,s(this,P))&&(m(this,P,e),s(this,v).emit("scoresUpdated",e),s(this,v).emit("log",["info",3,e]))};u();u();function ot(r,t){if(r==="none")return!1;switch(t){case"debug":return r==="debug";case"info":return r==="info"||r==="debug";case"warn":return r==="warn"||r==="info"||r==="debug";case"error":return r==="debug"||"info";default:return!1}}function de(r){return([t,e,...o])=>{!ot(r,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${e}
|
2
|
-
`,...o.map(i=>JSON.stringify(i,null,2)))}}function
|
3
|
-
`,...l.map(
|
1
|
+
import{a as H}from"./chunk-CEKV2MHL.mjs";import{d as D,e as s,f as d,g,h as S,i as u}from"./chunk-AFJ7PNM5.mjs";u();u();u();function Ct(r,t){let e={...r};for(let o in t){let i=Vt(r,o,t,new Set([o]));i!==0&&(e[o]=i)}return e}function Vt(r,t,e,o){var a;let i=0;for(let n of e[t].inputs){let c=(a=r[n.dim])!=null?a:0;if(!c&&e[n.dim]){if(o.has(n.dim))continue;let m=new Set(o);m.add(n.dim),c=Vt(r,n.dim,e,m)}if(c!==0)if(n.sign==="c"){i=0;break}else n.sign==="-"?i-=c:i+=c}return i}u();var $,k,it=class{constructor(t,e,o){d(this,$,void 0);d(this,k,void 0);D(this,"signal");g(this,k,t),this.signal=e,g(this,$,o)}computeSignal(t,e){if(t.scores[s(this,k)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=s(this,$).evaluate(t,this.signal.crit,e,this.signal,s(this,k)),a=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!i.changed){if(i.result)e.push({type:a,data:{dimension:s(this,k),delta:this.signal.str}});else if(this.signal.dur==="t"){let n=t.visitor.sessionScores[s(this,k)];n&&e.push({type:a,data:{dimension:s(this,k),delta:-n}})}}}};$=new WeakMap,k=new WeakMap;var x,G,nt=class{constructor({manifest:t,evaluator:e=new _({})}){D(this,"data");d(this,x,void 0);d(this,G,void 0);var o,i,a;g(this,x,(o=t.project)!=null?o:{}),this.data=t,g(this,G,Object.entries((a=(i=s(this,x).pz)==null?void 0:i.sig)!=null?a:[]).map(([n,c])=>new it(n,c,e)))}rollForControlGroup(){var t,e;return Math.random()<((e=(t=s(this,x).pz)==null?void 0:t.control)!=null?e:0)}getTest(t){var e;return(e=s(this,x).test)==null?void 0:e[t]}computeSignals(t){let e=[];return s(this,G).forEach(o=>{o.computeSignal(t,e)}),e}computeAggregateDimensions(t){var e,o;return Ct(t,(o=(e=s(this,x).pz)==null?void 0:e.agg)!=null?o:{})}getDimensionByKey(t){var o,i,a,n;let e=t.indexOf(H);return e<=0?(i=(o=s(this,x).pz)==null?void 0:o.sig)==null?void 0:i[t]:(n=(a=s(this,x).pz)==null?void 0:a.enr)==null?void 0:n[t.substring(0,e)]}};x=new WeakMap,G=new WeakMap;u();import{dequal as Ht}from"dequal/lite";var bt=(r,t)=>{var a,n;if(t.type!=="CK")return{result:!1,changed:!1};let e=!Ht(xt(r.state.cookies),xt((a=r.previousState)==null?void 0:a.cookies)),o=(n=r.state.cookies)==null?void 0:n[t.cookieName];return{result:b(o,t.match),changed:e}};function xt(r){if(!r)return;if(!r.ufvd)return r;let{ufvd:t,...e}=r;return e}u();u();function Et(r,t){var o;if(typeof r=="undefined"||r===null)return!1;let e=Number(r);if(isNaN(e))return!1;switch((o=t==null?void 0:t.op)!=null?o:"="){case"=":return e===t.rhs;case"!=":return e!==t.rhs;case">":return e>t.rhs;case"<":return e<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}u();function Y(r,t){return`${r}${H}${t}`}var st=Y("$pvc","v"),Tt=(r,t,e)=>{var n,c;if(t.type!=="PVC")return{result:!1,changed:!1};let o=!r.previousState||((n=r.state.url)==null?void 0:n.toString())!==((c=r.previousState.url)==null?void 0:c.toString()),a=(r.visitor.sessionScores[st]||0)+1;if(Et(a,t.match)){let l=e.some(m=>m.type==="modscoreS"&&m.data.dimension===st);return o&&!l&&e.push({type:"modscoreS",data:{dimension:st,delta:1}}),{result:!0,changed:o}}return{result:!1,changed:o}};u();var kt=(r,t)=>{var a,n,c,l,m;if(t.type!=="QS")return{result:!1,changed:!1};let e=!r.previousState||((n=(a=r.state.url)==null?void 0:a.searchParams)==null?void 0:n.toString())!==((l=(c=r.previousState.url)==null?void 0:c.searchParams)==null?void 0:l.toString()),o=(m=r.state.url)==null?void 0:m.searchParams.get(t.queryName);return{result:b(o,t.match),changed:e}};u();var wt=(r,t,e,o,i)=>{var y;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&o.dur==="t"&&r.scores[i]>0)return{result:!0,changed:!1};let a=r.visitor.quirks[t.key],n=(y=r.state.quirks)==null?void 0:y[t.key],c=n!=null?n:a,l=Boolean(n&&a!==n);return{result:b(c,t.match),changed:l}};u();var Pt=(r,t)=>{var o,i;if(t.type!=="EVT")return{result:!1,changed:!1};let e=(i=(o=r.state.events)==null?void 0:o.some(a=>b(a.event,t.event)))!=null?i:!1;return{result:e,changed:e}};u();var Ot=(r,t)=>{var i,a,n,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let e=!r.previousState||((a=(i=r.state.url)==null?void 0:i.pathname)==null?void 0:a.toString())!==((c=(n=r.previousState.url)==null?void 0:n.pathname)==null?void 0:c.toString());return{result:b((l=r.state.url)==null?void 0:l.pathname,t.path),changed:e}};u();var F,_=class{constructor(t){d(this,F,void 0);g(this,F,t)}evaluate(t,e,o,i,a){let n=!(e.op==="&"||!e.op),c=!1;for(let l of e.clauses){let m;if(l.type==="G")m=this.evaluate(t,l,o,i,a);else{let y=s(this,F)[l.type];if(!y)throw new Error(`${l.type} signal criteria not registered`);m=y(t,l,o,i,a)}if(m.changed&&(c=!0),m.result===n)return{result:n,changed:c}}return{result:!n,changed:c}}};F=new WeakMap;u();function b(r,t){var n,c,l,m,y,V;let e=(n=t==null?void 0:t.op)!=null?n:"=";if(t.op==="*")return r!==null&&typeof r!="undefined";if(t.op==="!*")return r===null||typeof r=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${e}`);let o=(c=t.cs)!=null?c:!1,i=(o?r!=null?r:"":Mt(r)).toString(),a=(o?t.rhs:Mt(t.rhs)).toString();switch(e){case"=":return i===a;case"!=":return i!==a;case"~":return(l=i.includes(a))!=null?l:!1;case"!~":return!((m=i.includes(a))==null||m);case"//":return new RegExp(t.rhs.toString(),o?"":"i").test((y=r==null?void 0:r.toString())!=null?y:"");case"!//":return!new RegExp(t.rhs.toString(),o?"":"i").test((V=r==null?void 0:r.toString())!=null?V:"");default:throw new Error(`Unknown match type ${e}.`)}}function Mt(r){var t,e;return(e=(t=r==null?void 0:r.toString())==null?void 0:t.toUpperCase())!=null?e:""}u();var X=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});u();u();import Yt from"mitt";import{dequal as Xt}from"dequal/lite";var Wt="__UNIFORM_DATA__",O,I,j=class{constructor({initialData:t}){d(this,O,void 0);d(this,I,Yt());D(this,"events",{on:s(this,I).on,off:s(this,I).off});t&&g(this,O,t)}get data(){return s(this,O)}updateData(t,e){return g(this,O,e),this.handleUpdateData(t,e)}async delete(t){g(this,O,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){Xt(this.data,t)||(g(this,O,t),s(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Wt);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};O=new WeakMap,I=new WeakMap;u();var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rt=at.split(""),Ut=new Array(123);for(let r=0;r<at.length;r++)Ut[at.charCodeAt(r)]=r;var ut=r=>{if(r<0)return`-${ut(-r)}`;let t=r>>>0,e=r/4294967296>>>0,o="";for(;e>0;)o=Rt[63&t]+o,t>>>=6,t|=(63&e)<<26,e>>>=6;let i="";do i=Rt[63&t]+i,t>>>=6;while(t>0);return i+o},Lt=r=>{let t=0,e=r.charAt(0)==="-"?1:0;for(let o=e;o<r.length;o++)t=t*64+Ut[r.charCodeAt(o)];return e?-t:t};import ct from"js-cookie";var lt=typeof document=="undefined",Zt="ufvd",R,Q,te=class extends j{constructor({serverCookieValue:t,cookieName:e=Zt,cookieAttributes:o={sameSite:"lax"}}){super({initialData:lt?ee(t):void 0});d(this,R,void 0);d(this,Q,void 0);g(this,R,e),g(this,Q,o)}handleDelete(){return lt||ct.remove(s(this,R)),Promise.resolve()}async handleUpdateData(t,e){lt||(e.consent?ct.set(s(this,R),re(e),s(this,Q)):ct.remove(s(this,R)))}};R=new WeakMap,Q=new WeakMap;var zt="~",Nt="!",qt="-";function ee(r){if(!r)return;let t=r.split(zt);if(t.length>3)return;let[e,o,i]=t;return{consent:!0,sessionScores:At(dt(o)),scores:At(dt(i)),tests:dt(e)}}function dt(r){return r.split(Nt).map(e=>e.split(qt)).reduce((e,o)=>(o.length!==2||(e[o[0]]=o[1]),e),{})}function At(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=Lt(o),t),{})}function re(r){return[ft(r.tests),ft(It(r.sessionScores)),ft(It(r.scores))].join(zt)}function It(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=ut(o),t),{})}function ft(r){return Object.entries(r).map(t=>t.join(qt)).join(Nt)}u();var W,ie,oe=class extends j{constructor({serverCookieValue:t,visitorIdCookieName:e="ufvi",...o}){super(o);d(this,W);o.initialData||S(this,W,ie).call(this).catch(i=>{console.error(i)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let e=await new Promise(o=>{setTimeout(()=>{o(void 0)},2e3)});e&&this.signalAsyncDataUpdate(e)}};W=new WeakSet,ie=async function(){let t=await new Promise(e=>{setTimeout(()=>{e(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};u();function lr(r){let{gracePeriod:t=864e5,decayRate:e=1/30,decayCap:o=.95}=r!=null?r:{};return function({now:a,lastUpd:n,scores:c,sessionScores:l}){if(typeof n!="number")return!1;let y=a-n-t;if(y<=0)return!1;let V=y/864e5,A=1-Math.min(o,V*e);return A<=0?!1:($t(c,A),$t(l,A),!0)}}function $t(r,t){for(let e in r)r[e]*=t}u();import ae from"mitt";import{dequal as Z}from"dequal/lite";u();var pt=class{constructor(){D(this,"inMemoryFallback",{});D(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let e=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||e)return e;try{let o=localStorage.getItem(t);return o?JSON.parse(o):void 0}catch(o){return e}}set(t,e,o){if(this.inMemoryFallback[t]=e,!(!this.hasLocalStorageObject||!o))try{localStorage.setItem(t,JSON.stringify(e))}catch(i){console.warn(i)}}delete(t,e){e||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(o){}}};u();import ne from"rfdc";var se=ne();function Gt(r,t,e){let o=t?se(t):X();return r.forEach(i=>{var a,n;switch(i.type){case"consent":o.consent=i.data;break;case"setquirk":o.quirks[i.data.key]=i.data.value;break;case"settest":o.tests[i.data.test]=i.data.variant;break;case"modscore":if(e)break;let c=Number(i.data.delta);if(isNaN(c))throw new Error("Non-number delta received");let l=(a=o.scores[i.data.dimension])!=null?a:0;o.scores[i.data.dimension]=l+c;break;case"modscoreS":if(e)break;let m=Number(i.data.delta);if(isNaN(m))throw new Error("Non-number delta received");let y=(n=o.sessionScores[i.data.dimension])!=null?n:0;o.sessionScores[i.data.dimension]=y+m;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var tt="ufvisitor",E,U,N,h,C,M,w,z,et,ue,rt,ce,K,_t,B,Ft,mt=class{constructor(t){d(this,C);d(this,w);d(this,et);d(this,rt);d(this,K);d(this,B);d(this,E,ae());d(this,U,new pt);d(this,N,void 0);d(this,h,void 0);D(this,"events",{on:s(this,E).on,off:s(this,E).off});if(g(this,h,t),s(this,C,M)||S(this,w,z).call(this,S(this,B,Ft).call(this),!0),t.transitionStore){let e=t.transitionStore.getClientTransitionState();if(e){let i=[];e.quirks&&i.push(...Object.entries(e.quirks).map(([a,n])=>({type:"setquirk",data:{key:a,value:n}}))),e.tests&&i.push(...Object.entries(e.tests).map(([a,n])=>({type:"settest",data:{test:a,variant:n}}))),this.updateData(i),e.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(e.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{S(this,w,z).call(this,{...s(this,C,M).visitorData,...i})});let o=t.transitionStore.data;o&&S(this,w,z).call(this,{...s(this,C,M).visitorData,...o},!0)}}get data(){var e,o;let t=s(this,C,M);if(S(this,rt,ce).call(this,t)){let{sessionScores:i,...a}=t.visitorData;return S(this,w,z).call(this,{...a,sessionScores:{}}),(o=(e=s(this,h)).onLogMessage)==null||o.call(e,["info",120]),s(this,C,M).visitorData}return t.visitorData}get decayEnabled(){return!!s(this,h).decay}async updateData(t){var o,i,a,n;if(t.length===0)return;(i=(o=s(this,h)).onLogMessage)==null||i.call(o,["debug",101,t]);let e=Gt(t,this.data,(a=s(this,C,M))==null?void 0:a.visitorData.controlGroup);t.some(c=>c.type==="consent"&&!c.data)&&s(this,U).delete(tt,!0),S(this,w,z).call(this,e),await((n=s(this,h).transitionStore)==null?void 0:n.updateData(t,s(this,C,M).visitorData))}async delete(t){var e,o,i;s(this,U).delete(tt,!1),await((e=s(this,h).transitionStore)==null?void 0:e.delete(t)),S(this,w,z).call(this,S(this,B,Ft).call(this)),(i=(o=s(this,h)).onLogMessage)==null||i.call(o,["info",103,t])}};E=new WeakMap,U=new WeakMap,N=new WeakMap,h=new WeakMap,C=new WeakSet,M=function(){return s(this,U).get(tt)},w=new WeakSet,z=function(t,e=!1){var y,V,A,St,yt,Dt;let o=s(this,C,M),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(S(this,K,_t).call(this,t.scores),S(this,K,_t).call(this,t.sessionScores),(V=(y=s(this,h)).decay)==null||V.call(y,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores}));let a=!Z(o==null?void 0:o.visitorData.scores,t.scores),n=!Z(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),c=!Z(o==null?void 0:o.visitorData.quirks,t.quirks),l=!Z(o==null?void 0:o.visitorData.tests,t.tests),m={updated:i,visitorData:t};S(this,et,ue).call(this),s(this,U).set(tt,m,!!t.consent),(St=(A=s(this,h)).onLogMessage)==null||St.call(A,["debug",102,t]),e||((a||n)&&s(this,E).emit("scoresUpdated",t),c&&s(this,E).emit("quirksUpdated",t),l&&s(this,E).emit("testsUpdated",t),((yt=o==null?void 0:o.visitorData)==null?void 0:yt.consent)!==t.consent&&s(this,E).emit("consentUpdated",t),((Dt=o==null?void 0:o.visitorData)==null?void 0:Dt.controlGroup)!==t.controlGroup&&s(this,E).emit("controlGroupUpdated",t))},et=new WeakSet,ue=function(){typeof document=="undefined"||!s(this,h).visitLifespan||(s(this,N)&&window.clearTimeout(s(this,N)),g(this,N,window.setTimeout(()=>{this.data},s(this,h).visitLifespan+50)))},rt=new WeakSet,ce=function(t){let e=s(this,h).visitLifespan;return e?t.updated+e<Date.now():!1},K=new WeakSet,_t=function(t){var e,o;if(!!s(this,h).manifest)for(let i in t){let a=t[i],n=s(this,h).manifest.getDimensionByKey(i);!n||a>n.cap&&((o=(e=s(this,h)).onLogMessage)==null||o.call(e,["debug",110,{dim:i,score:a,cap:n.cap}]),t[i]=n.cap)}},B=new WeakSet,Ft=function(){var t,e,o;return{...X(),consent:(t=s(this,h).defaultConsent)!=null?t:!1,controlGroup:(o=(e=s(this,h).manifest)==null?void 0:e.rollForControlGroup())!=null?o:!1}};u();import de from"mitt";u();u();function jt({context:r,variations:t,take:e=1}){var c,l;let o=(c=r.storage.data.controlGroup)!=null?c:!1,i=[],a=!1,n=r.scores;for(let m of t){if(i.length===e)break;if(!((l=m.pz)!=null&&l.crit.length)){i.push(m);continue}!o&&Qt(m.pz,n)&&(a=!0,i.push(m))}return{personalized:a,variations:i}}u();function Qt(r,t){return r!=null&&r.crit?!r.op||r.op==="&"?r.crit.every(e=>Kt(e,t)):r.crit.some(e=>Kt(e,t)):!0}function Kt(r,t){var n;let{op:e,l:o}=r,i=(n=t[o])!=null?n:0;if(e==="+")return Math.max(...Object.values(t))===i&&i>0;if(e==="-")return Math.min(...Object.values(t))===i&&i>0;let a=r.rDim?t[r.rDim]:r.r;if(a===void 0)return!1;if(e===">")return i>a;if(e===">=")return i>=a;if(e==="<")return i<a;if(e==="<=")return i<=a;if(e==="=")return i===a;if(e==="!=")return i!==a;throw new Error(`Unknown op: ${e}`)}u();var le=r=>{let{values:t,total:e,missingDistribution:o}=r.reduce((i,a)=>(a.testDistribution?i.total+=a.testDistribution:++i.missingDistribution,i.values.push(a.testDistribution),i),{values:[],total:0,missingDistribution:0});if(e>100)throw new Error(`Total distribution ${e} is over the maximum 100.`);if(e<100){let a=(100-e)/o;t.forEach((n,c)=>{typeof n=="undefined"&&(t[c]=a)})}return t},gt=({name:r,context:t,variations:e})=>{var a;let o,i=t.getTestVariantId(r);if(i===null)return{result:void 0,variantAssigned:!1};if(i&&(o=e.find(n=>n.id===i),o||t.log("warn",401,{test:r,variant:i})),!o){let n=le(e),c=Math.floor(Math.random()*100),l=0;o=e.find((m,y)=>{let V=n[y];if(c>l&&c<=l+V)return m;l+=V}),o&&t.setTestVariantId(r,(a=o.id)!=null?a:"Unknown")}return{result:o,variantAssigned:!i}};import{dequal as Bt}from"dequal/lite";var L,P,T,J,v,q,ht,fe=class{constructor(t){d(this,q);D(this,"manifest");d(this,L,!1);d(this,P,{});d(this,T,void 0);d(this,J,{});d(this,v,de());D(this,"events",{on:s(this,v).on,off:s(this,v).off});D(this,"storage");var i,a;let{manifest:e,...o}=t;g(this,T,{}),(i=t.plugins)==null||i.forEach(n=>{!n.logDrain||s(this,v).on("log",n.logDrain)}),this.manifest=new nt({manifest:e,evaluator:new _({CK:bt,QS:kt,QK:wt,PVC:Tt,EVT:Pt,PV:Ot})}),this.storage=new mt({...o,manifest:this.manifest,onServerTransitionScoresReceived:n=>{g(this,P,n),g(this,L,!0),s(this,v).emit("log",["debug",130,n])},onLogMessage:n=>s(this,v).emit("log",n)}),this.storage.events.on("scoresUpdated",S(this,q,ht).bind(this)),s(this,L)||S(this,q,ht).call(this,this.storage.data),this.storage.events.on("quirksUpdated",n=>{let c=this.manifest.computeSignals({scores:s(this,P),state:s(this,T),previousState:s(this,T),visitor:this.storage.data});this.storage.updateData(c),s(this,v).emit("quirksUpdated",n.quirks),s(this,v).emit("log",["info",4,n.quirks])}),s(this,v).emit("log",["debug",1]),(a=t.plugins)==null||a.forEach(n=>{!n.init||n.init(this)})}get scores(){return s(this,P)}async update(t){var o;let e=[];t.quirks&&e.push(...Object.entries(t.quirks).map(([i,a])=>({type:"setquirk",data:{key:i,value:a}}))),t.enrichments&&t.enrichments.forEach(i=>{let a=Y(i.cat,i.key);this.manifest.getDimensionByKey(a)?e.push({type:"modscore",data:{dimension:a,delta:i.str}}):s(this,v).emit("log",["warn",5,i])}),e.push(...this.manifest.computeSignals({state:t,previousState:s(this,T),visitor:this.storage.data,scores:s(this,P)})),s(this,v).emit("log",["debug",2,{...t,url:(o=t.url)==null?void 0:o.toString()}]),g(this,T,{...s(this,T),...t}),await this.storage.updateData(e),s(this,L)&&(S(this,q,ht).call(this,this.storage.data),g(this,L,!1),s(this,v).emit("log",["debug",131]))}getTestVariantId(t){var o;let e=this.manifest.getTest(t);return e?(o=e.wv)!=null?o:this.storage.data.tests[t]:(s(this,v).emit("log",["warn",401,t]),null)}setTestVariantId(t,e){this.storage.updateData([{type:"settest",data:{test:t,variant:e}}])}log(...t){s(this,v).emit("log",t)}test(t){var o,i;let e=gt({...t,context:this});return s(this,v).emit("testResult",{name:t.name,variantId:(i=(o=e.result)==null?void 0:o.id)!=null?i:void 0,variantAssigned:e.variantAssigned}),e}personalize(t){let e=jt({...t,context:this}),o=s(this,J)[t.name],i={name:t.name,variantIds:e.variations.map(a=>{var n;return(n=a.id)!=null?n:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return o&&Bt(i.variantIds,o)&&(i.changed=!1),s(this,v).emit("personalizationResult",i),s(this,J)[t.name]=i.variantIds,e}async forget(t){g(this,T,{}),await this.storage.delete(t)}};L=new WeakMap,P=new WeakMap,T=new WeakMap,J=new WeakMap,v=new WeakMap,q=new WeakSet,ht=function(t){var i;let e={...t.scores};for(let a in t.sessionScores)e[a]=((i=e[a])!=null?i:0)+t.sessionScores[a];e=this.manifest.computeAggregateDimensions(e),!Bt(e,s(this,P))&&(g(this,P,e),s(this,v).emit("scoresUpdated",e),s(this,v).emit("log",["info",3,e]))};u();u();function ot(r,t){if(r==="none")return!1;switch(t){case"debug":return r==="debug";case"info":return r==="info"||r==="debug";case"warn":return r==="warn"||r==="info"||r==="debug";case"error":return r==="debug"||"info";default:return!1}}function pe(r){return([t,e,...o])=>{!ot(r,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${e}
|
2
|
+
`,...o.map(i=>JSON.stringify(i,null,2)))}}function Jr(r){return{logDrain:pe(r)}}u();u();var Jt={1:()=>["context","constructed"],2:r=>["context","received data update",r],3:r=>["context","new score vector",r],4:r=>["context","updated quirks",r],5:r=>["context","ignored enrichment update for unknown enrichment category",r.cat],101:r=>["storage","received update commands",r],102:r=>["storage","data was updated",r],103:r=>["storage",`data was deleted ${r?"from all devices":"from this device"}`],110:({dim:r,cap:t,score:e})=>["storage",`${r} score ${e} exceeded cap ${t}. Rounded down.`],120:()=>["storage","visitor data expired and was cleared"],130:r=>["storage","server to client transition score data was loaded; it will persist until the next update event occurs",r],131:()=>["storage","server to client transition data was discarded"],401:r=>["testing",`${r} was unknown; it will not be run.`],402:({test:r,variant:t})=>["testing",`${r} no longer has visitor's variant ${t}; it will be removed.`],700:()=>["gtag","gtag is not defined, skipping analytics event emission. Ensure you have added the gtag script to your page."],701:()=>["gtag","enabled gtag event signal redirection"]};function me(r){return([t,e,...o])=>{if(!ot(r,t))return;let i=Jt[e],a=`\u{1F94B} [${new Date().toLocaleTimeString()}][${t}]`;if(!i){console[t](`${a} unknown event ID ${e} - ensure all Uniform packages are the same version`,...o);return}let[n,c,...l]=i(...o);console[t](`${a}[${n}] ${c} (Event ID: ${e})
|
3
|
+
`,...l.map(m=>JSON.stringify(m,null,2)))}}function Zr(r){return{logDrain:me(r)}}u();var ge=(c=>(c.ListStart="nesi-list-start",c.ListEnd="nesi-list-end",c.ListItem="nesi-list-item-html",c.ListItemSettings="nesi-list-item-settings",c.TestStart="nesi-test-start",c.TestEnd="nesi-test-end",c.Unknown="unknown",c))(ge||{}),eo="nesitag";u();var vt=typeof top!="undefined";function oo(){return{logDrain:r=>{!vt||top==null||top.postMessage({type:"uniform:context:log",message:r},window.location.origin)},init:r=>{let t=[],e=[],o=()=>{!vt||top==null||top.postMessage({type:"uniform:context:data",data:{scores:r.scores,data:r.storage.data,manifest:r.manifest.data,personalizations:t,tests:e}},window.location.origin)},i=n=>{!n.changed||(t.push(n),o())},a=n=>{!n.variantAssigned||(e.push(n),o())};if(vt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=r;try{top==null||top.addEventListener("message",async n=>{if(!n.data)return;let c=n.data;await he(c,r)})}catch(n){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",n)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),o()}return r.events.on("personalizationResult",i),r.events.on("testResult",a),r.storage.events.on("*",o),()=>{r.storage.events.off("*",o),r.events.off("personalizationResult",i),r.events.off("testResult",a)}}}}async function he(r,t){r.type==="uniform-in:context:update"&&r.newData&&await t.update(r.newData),r.type==="uniform-in:context:commands"&&r.commands&&Array.isArray(r.commands)&&await t.storage.updateData(r.commands),r.type==="uniform-in:context:forget"&&await t.forget(!1)}export{fe as Context,te as CookieTransitionDataStore,eo as EdgeNodeTagName,oe as EdgeTransitionDataStore,_ as GroupCriteriaEvaluator,nt as ManifestInstance,Wt as SERVER_STATE_ID,ge as ScriptType,j as TransitionDataStore,Zt as UNIFORM_DEFAULT_COOKIE_NAME,mt as VisitorDataStore,Ct as computeAggregateDimensions,bt as cookieEvaluator,pe as createConsoleLogDrain,me as createDebugConsoleLogDrain,lr as createLinearDecay,Ot as currentPageEvaluator,X as emptyVisitorData,Jr as enableConsoleLogDrain,oo as enableContextDevTools,Zr as enableDebugConsoleLogDrain,Qt as evaluateVariantMatch,Pt as eventEvaluator,Y as getEnrichmentVectorKey,b as isStringMatch,st as pageViewCountDimension,Tt as pageViewCountEvaluator,jt as personalizeVariations,kt as queryStringEvaluator,wt as quirkEvaluator,gt as testVariations};
|