@mparticle/web-rokt-kit 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const Ee = [
1
+ const ve = [
2
2
  "active_time_on_site_ms",
3
3
  "billingaddress1",
4
4
  "billingaddress2",
@@ -23,15 +23,15 @@ const Ee = [
23
23
  "shippingstate",
24
24
  "shippingzipcode",
25
25
  "totalprice"
26
- ], _e = new Set(Ee);
27
- function se(i) {
28
- return _e.has(i.toLowerCase());
26
+ ], Pe = new Set(ve);
27
+ function ue(i) {
28
+ return Pe.has(i.toLowerCase());
29
29
  }
30
- function T(i) {
30
+ function L(i) {
31
31
  const e = {}, t = i || {}, n = Object.keys(t);
32
32
  for (let r = 0; r < n.length; r++) {
33
33
  const s = n[r];
34
- se(s) || (e[s] = t[s]);
34
+ ue(s) || (e[s] = t[s]);
35
35
  }
36
36
  return e;
37
37
  }
@@ -41,13 +41,13 @@ function E(i) {
41
41
  function m(i) {
42
42
  return typeof i == "string";
43
43
  }
44
- function b(i) {
44
+ function O(i) {
45
45
  return typeof i == "function";
46
46
  }
47
- function C(i) {
48
- return i == null ? !0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
47
+ function T(i) {
48
+ return i == null ? !0 : typeof i == "string" ? i.length === 0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
49
49
  }
50
- function F(i) {
50
+ function j(i) {
51
51
  try {
52
52
  const e = new URL(i);
53
53
  return e.search = "", e.toString();
@@ -55,15 +55,21 @@ function F(i) {
55
55
  return i;
56
56
  }
57
57
  }
58
- const H = "__rokt_ls_probe__";
59
- function K() {
58
+ function de(i) {
59
+ let e = 5381;
60
+ for (let t = 0; t < i.length; t++)
61
+ e = (e << 5) + e + i.charCodeAt(t), e = e & e;
62
+ return e;
63
+ }
64
+ const _ = "mp-rokt-kit", J = "__rokt_ls_probe__";
65
+ function x() {
60
66
  try {
61
- return window.localStorage.setItem(H, "1"), window.localStorage.removeItem(H), !0;
67
+ return window.localStorage.setItem(J, "1"), window.localStorage.removeItem(J), !0;
62
68
  } catch {
63
69
  return !1;
64
70
  }
65
71
  }
66
- function x(i) {
72
+ function V(i) {
67
73
  try {
68
74
  const e = window.localStorage.getItem(i);
69
75
  return e === null ? null : JSON.parse(e);
@@ -71,58 +77,58 @@ function x(i) {
71
77
  return null;
72
78
  }
73
79
  }
74
- function oe(i, e) {
80
+ function he(i, e) {
75
81
  try {
76
82
  return window.localStorage.setItem(i, JSON.stringify(e)), !0;
77
83
  } catch {
78
84
  return !1;
79
85
  }
80
86
  }
81
- function Se(i) {
87
+ function be(i) {
82
88
  try {
83
89
  window.localStorage.removeItem(i);
84
90
  } catch {
85
91
  }
86
92
  }
87
- function Y(i, e) {
88
- const t = x(i);
93
+ function D(i, e) {
94
+ const t = V(i);
89
95
  return E(t) ? t[e] : void 0;
90
96
  }
91
- function ae(i, e, t) {
92
- const n = x(i), r = E(n) ? { ...n } : {};
93
- return r[e] = t, oe(i, r);
97
+ function G(i, e, t) {
98
+ const n = V(i), r = E(n) ? { ...n } : {};
99
+ return r[e] = t, he(i, r);
94
100
  }
95
- function ce(i, e) {
96
- const t = x(i);
101
+ function ge(i, e) {
102
+ const t = V(i);
97
103
  if (!E(t) || !(e in t))
98
104
  return;
99
105
  const n = { ...t };
100
- delete n[e], Object.keys(n).length === 0 ? Se(i) : oe(i, n);
106
+ delete n[e], Object.keys(n).length === 0 ? be(i) : he(i, n);
101
107
  }
102
- const _ = "mp-rokt-kit", j = "pageViews", O = "utmParams", le = 25, Ie = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
103
- function ue(i) {
104
- return i.slice(-le);
108
+ const H = "pageViews", C = "utmParams", pe = 25, Re = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
109
+ function fe(i) {
110
+ return i.slice(-pe);
105
111
  }
106
- function V() {
107
- const i = Y(_, j);
112
+ function B() {
113
+ const i = D(_, H);
108
114
  return Array.isArray(i) ? i : [];
109
115
  }
110
- function Ae(i) {
111
- const e = ue(i);
116
+ function ke(i) {
117
+ const e = fe(i);
112
118
  for (let t = 0; t < e.length; t++) {
113
119
  const n = e.slice(t);
114
- if (ae(_, j, n))
120
+ if (G(_, H, n))
115
121
  return n.length;
116
122
  }
117
123
  return 0;
118
124
  }
119
- function z() {
120
- ce(_, j);
125
+ function Q() {
126
+ ge(_, H);
121
127
  }
122
- function ye(i) {
123
- const e = ue(i);
128
+ function Te(i) {
129
+ const e = fe(i);
124
130
  return e.map((t, n) => {
125
- const r = t.activeTimeOnSite, s = r !== void 0 && Number.isFinite(r), c = e[n + 1]?.activeTimeOnSite, u = c !== void 0 && Number.isFinite(c), l = s && u ? c - r : void 0;
131
+ const r = t.activeTimeOnSite, s = r !== void 0 && Number.isFinite(r), a = e[n + 1]?.activeTimeOnSite, u = a !== void 0 && Number.isFinite(a), l = s && u ? a - r : void 0;
126
132
  return {
127
133
  pageUrl: t.pageUrl,
128
134
  sourceMessageId: t.sourceMessageId,
@@ -134,19 +140,19 @@ function ye(i) {
134
140
  };
135
141
  });
136
142
  }
137
- function ke(i) {
138
- if (Y(_, O) !== void 0)
143
+ function we(i) {
144
+ if (D(_, C) !== void 0)
139
145
  return;
140
146
  const e = new URLSearchParams(window.location.search), t = {};
141
- for (const r of Ie) {
147
+ for (const r of Re) {
142
148
  const s = e.get(r);
143
149
  s && (t[r] = s);
144
150
  }
145
151
  if (Object.keys(t).length === 0)
146
152
  return;
147
153
  const n = Object.keys(t).join(", ");
148
- if (!ae(_, O, t)) {
149
- const r = K() ? "quota" : "ls_unavailable";
154
+ if (!G(_, C, t)) {
155
+ const r = x() ? "quota" : "ls_unavailable";
150
156
  i?.log({
151
157
  message: `Rokt Kit: Failed to persist UTM params [reason: ${r}]`,
152
158
  code: "UTM_CAPTURE_FAILED"
@@ -158,17 +164,67 @@ function ke(i) {
158
164
  code: "UTM_CAPTURE_SUCCESS"
159
165
  });
160
166
  }
161
- function Re() {
162
- const i = Y(_, O);
167
+ function Le() {
168
+ const i = D(_, C);
163
169
  return E(i) ? i : null;
164
170
  }
165
- function $() {
166
- ce(_, O);
171
+ function X() {
172
+ ge(_, C);
167
173
  }
168
- function ve() {
174
+ function Oe() {
169
175
  const e = document.querySelector('link[rel="canonical"]')?.href;
170
176
  if (e)
171
- return F(e);
177
+ return j(e);
178
+ }
179
+ const W = [
180
+ {
181
+ accountId: "2919171670744024290",
182
+ pathname: "/checkout",
183
+ targetPageIdentifier: "prod.rokt.conf",
184
+ attributeKeys: [
185
+ "email",
186
+ "amount",
187
+ "concessions_total",
188
+ "customertype",
189
+ "eventvenue",
190
+ "firstname",
191
+ "lastname",
192
+ "locale",
193
+ "member_status",
194
+ "billingzipcode",
195
+ "country",
196
+ "currency",
197
+ "language"
198
+ ]
199
+ }
200
+ ];
201
+ function Ne(i, e) {
202
+ if (i)
203
+ return W.find((t) => t.accountId === i && t.pathname === e);
204
+ }
205
+ function Ue(i, e) {
206
+ if (!(!i || !m(e)))
207
+ return W.find((t) => t.accountId === i && t.targetPageIdentifier === e);
208
+ }
209
+ function Ce(i, e) {
210
+ return i ? W.some((t) => t.accountId === i && t.attributeKeys.includes(e)) : !1;
211
+ }
212
+ const De = 6e4;
213
+ function Ke(i) {
214
+ return E(i) && typeof i.expiresAt == "number" && E(i.attributes);
215
+ }
216
+ function Me(i, e) {
217
+ return `activePreselect:${i}:${e}`;
218
+ }
219
+ function Fe(i) {
220
+ const e = D(_, i);
221
+ return Ke(e) ? e : null;
222
+ }
223
+ function xe(i, e) {
224
+ G(_, i, {
225
+ expiresAt: Date.now() + De,
226
+ attributes: e
227
+ });
172
228
  }
173
229
  function M(i, e) {
174
230
  return {
@@ -176,39 +232,130 @@ function M(i, e) {
176
232
  code: "ATTRIBUTE_SETTER_CALLED"
177
233
  };
178
234
  }
179
- function we(i) {
235
+ function Ye(i) {
180
236
  return {
181
237
  message: `Rokt Kit: selectPlacements dispatched [placementAttributeKeys=${i.join(",")}]`,
182
238
  code: "SELECT_PLACEMENTS_DISPATCHED"
183
239
  };
184
240
  }
185
- function Te() {
241
+ function k(i, e) {
242
+ const t = {
243
+ fired: "PRESELECT_FIRED",
244
+ missed: "PRESELECT_MISSED",
245
+ queued: "PRESELECT_QUEUED",
246
+ skipped: "PRESELECT_SKIPPED"
247
+ };
248
+ return {
249
+ message: `Rokt Kit: preselect ${i} [reason=${e}]`,
250
+ code: t[i]
251
+ };
252
+ }
253
+ function je() {
254
+ return { pending: [] };
255
+ }
256
+ function F(i, e) {
257
+ const t = i.pending.findIndex((n) => n.pathname === e.pathname);
258
+ if (t >= 0) {
259
+ i.pending[t] = e;
260
+ return;
261
+ }
262
+ i.pending.push(e);
263
+ }
264
+ function Ve(i) {
265
+ if (!i?.getUserIdentities)
266
+ return !1;
267
+ const e = i.getUserIdentities().userIdentities;
268
+ return e ? Object.keys(e).some((t) => {
269
+ const n = e[t];
270
+ return m(n) && n.length > 0;
271
+ }) : !1;
272
+ }
273
+ function Ge(i, e) {
274
+ Promise.resolve(i.selectPlacements(e)).catch((t) => {
275
+ const n = t instanceof Error ? t.message : String(t);
276
+ i.log({
277
+ message: `Rokt Kit: Preselect selectPlacements call failed: ${n}`,
278
+ code: "PRESELECT_DISPATCH_FAILED"
279
+ });
280
+ });
281
+ }
282
+ function me(i, e, t, n = window.location.pathname) {
283
+ const r = Ne(e.accountId, n);
284
+ if (!r)
285
+ return;
286
+ if (!e.isKitReady()) {
287
+ F(i, { event: t, pathname: n }), e.logPlacementDiagnostic(k("queued", "not_ready"));
288
+ return;
289
+ }
290
+ if (!e.isPreselectionEnabled())
291
+ return;
292
+ if (!Ve(e.filteredUser)) {
293
+ e.logPlacementDiagnostic(k("missed", "no_valid_identity")), F(i, { event: t, pathname: n });
294
+ return;
295
+ }
296
+ const s = e.filteredUser?.getAllUserAttributes?.() || {}, o = {}, a = [];
297
+ for (const h of r.attributeKeys) {
298
+ const S = e.getEventAttributeValue(t, h), p = T(S) ? e.userAttributes[h] ?? s[h] : S;
299
+ if (T(p)) {
300
+ a.push(h);
301
+ continue;
302
+ }
303
+ o[h] = p;
304
+ }
305
+ if (a.length > 0) {
306
+ for (const h of a)
307
+ e.logPlacementDiagnostic(k("missed", `missing_attribute:${h}`));
308
+ F(i, { event: t, pathname: n });
309
+ return;
310
+ }
311
+ const u = Me(e.accountId || "", n), l = Fe(u), g = !!l && JSON.stringify(l.attributes) === JSON.stringify(o);
312
+ if (l && l.expiresAt > Date.now() && g) {
313
+ e.logPlacementDiagnostic(k("skipped", "active_preselection"));
314
+ return;
315
+ }
316
+ const b = {
317
+ attributes: o,
318
+ preselect: !0,
319
+ identifier: r.targetPageIdentifier,
320
+ omitUrl: !0
321
+ };
322
+ xe(u, o), e.logPlacementDiagnostic(k("fired", "fired")), Ge(e, b);
323
+ }
324
+ function He(i, e, t = window.location.pathname) {
325
+ if (i.pending.length === 0)
326
+ return;
327
+ const n = i.pending;
328
+ i.pending = [], n.forEach(({ event: r, pathname: s }) => {
329
+ s === t && me(i, e, r, s);
330
+ });
331
+ }
332
+ function We() {
186
333
  return {
187
334
  context: null,
188
335
  lifecycle: "idle",
189
336
  recreateInFlight: null
190
337
  };
191
338
  }
192
- function be(i, e) {
339
+ function ze(i, e) {
193
340
  i.context = {
194
341
  accountId: e.accountId,
195
342
  launcherOptions: { ...e.launcherOptions },
196
343
  legacyRoktExtensions: [...e.legacyRoktExtensions]
197
344
  };
198
345
  }
199
- function Le(i) {
346
+ function $e(i) {
200
347
  i.lifecycle = "attached";
201
348
  }
202
- function Pe(i) {
349
+ function qe(i) {
203
350
  i.lifecycle !== "idle" && (i.lifecycle = "terminated");
204
351
  }
205
- function Oe(i) {
352
+ function Je(i) {
206
353
  i.lifecycle = "terminated";
207
354
  }
208
- function Ne(i) {
355
+ function Be(i) {
209
356
  i.context = null, i.lifecycle = "idle", i.recreateInFlight = null;
210
357
  }
211
- function Ue(i, e, t) {
358
+ function Qe(i, e, t) {
212
359
  if (i.recreateInFlight)
213
360
  return i.recreateInFlight;
214
361
  if (i.lifecycle !== "terminated" || !i.context || !e)
@@ -219,42 +366,42 @@ function Ue(i, e, t) {
219
366
  i.recreateInFlight = null;
220
367
  }), i.recreateInFlight;
221
368
  }
222
- const d = "Rokt", L = 181, Ce = "selectPlacements", Me = "apps.roktecommerce.com", Ke = 0.1, De = "ThankYouPageJourney", Fe = "rokt-launcher", xe = "rokt-thank-you-element", Ye = "userIdentifiedInWorkspace", je = 3, We = 2, Ge = "page_events", He = "page_view_attributes", Ve = "mparticle_session_id", ze = "mparticle_device_id", q = 500, W = {
369
+ const d = "Rokt", N = 181, Xe = "selectPlacements", Ze = "apps.roktecommerce.com", et = 0.1, tt = "ThankYouPageJourney", it = "rokt-launcher", nt = "rokt-thank-you-element", rt = "userIdentifiedInWorkspace", st = 3, ot = 2, ct = "page_events", at = "page_view_attributes", lt = "mparticle_session_id", ut = "mparticle_device_id", Z = 500, z = {
223
370
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
224
371
  UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
225
372
  IDENTITY_REQUEST: "IDENTITY_REQUEST",
226
373
  LOG_DELIVERY_FAILURE: "LOG_DELIVERY_FAILURE"
227
- }, A = {
374
+ }, v = {
228
375
  ERROR: "ERROR",
229
376
  INFO: "INFO",
230
377
  WARNING: "WARNING"
231
- }, $e = "apps.rokt-api.com", qe = "/v1/log", Be = "/v1/errors", Je = 10;
232
- function a() {
378
+ }, dt = "apps.rokt-api.com", ht = "/v1/log", gt = "/v1/errors", pt = 10;
379
+ function c() {
233
380
  return window.mParticle;
234
381
  }
235
- function B(i, e) {
236
- const n = [N(i), "/wsdk/integrations/launcher.js"].join("");
382
+ function ee(i, e) {
383
+ const n = [K(i), "/wsdk/integrations/launcher.js"].join("");
237
384
  return !e || e.length === 0 ? n : n + "?extensions=" + e.join(",");
238
385
  }
239
- function J(i) {
240
- return [N(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
386
+ function te(i) {
387
+ return [K(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
241
388
  }
242
- function N(i) {
243
- const e = typeof i < "u" ? i : $e;
389
+ function K(i) {
390
+ const e = i !== void 0 ? i : dt;
244
391
  return e.includes("://") ? e.replace(/\/+$/, "") : ["https://", e].join("");
245
392
  }
246
- function de(i, e, t) {
393
+ function Ee(i, e, t) {
247
394
  if (i)
248
395
  return i.startsWith("http://") || i.startsWith("https://") ? i : "https://" + i;
249
396
  const r = e?.includes("://") && !/^https?:\/\//i.test(e) ? void 0 : e;
250
- return N(r) + t;
397
+ return K(r) + t;
251
398
  }
252
- function Q(i, e, t) {
399
+ function ie(i, e, t) {
253
400
  if (document.getElementById(i)) return;
254
401
  const n = document.head || document.body, r = document.createElement("script");
255
402
  r.id = i, r.type = "text/javascript", r.src = e, r.async = !0, r.crossOrigin = "anonymous", r.fetchPriority = "high", t?.onLoad && (r.onload = t.onLoad), t?.onError && (r.onerror = t.onError), n.appendChild(r);
256
403
  }
257
- function P(i) {
404
+ function U(i) {
258
405
  if (!i)
259
406
  return [];
260
407
  try {
@@ -264,12 +411,12 @@ function P(i) {
264
411
  }
265
412
  return [];
266
413
  }
267
- function X(i) {
268
- const e = i ? P(i) : [], t = [], n = [];
414
+ function ne(i) {
415
+ const e = i ? U(i) : [], t = [], n = [];
269
416
  let r = !1;
270
417
  for (let s = 0; s < e.length; s++) {
271
418
  const o = e[s].value;
272
- o === "thank-you-journey" ? (r = !0, n.push(De)) : t.push(o);
419
+ o === "thank-you-journey" ? (r = !0, n.push(tt)) : t.push(o);
273
420
  }
274
421
  return {
275
422
  roktExtensionsQueryParams: t,
@@ -277,14 +424,14 @@ function X(i) {
277
424
  loadThankYouElement: r
278
425
  };
279
426
  }
280
- async function Qe(i, e) {
427
+ async function ft(i, e) {
281
428
  const t = [];
282
429
  if (e)
283
430
  for (const n of i)
284
431
  t.push(e.use(n));
285
432
  return Promise.all(t);
286
433
  }
287
- function Z(i) {
434
+ function re(i) {
288
435
  if (!i)
289
436
  return {};
290
437
  const e = {};
@@ -294,7 +441,7 @@ function Z(i) {
294
441
  }
295
442
  return e;
296
443
  }
297
- function ee(i) {
444
+ function se(i) {
298
445
  const e = {};
299
446
  if (!Array.isArray(i))
300
447
  return e;
@@ -310,20 +457,14 @@ function ee(i) {
310
457
  }
311
458
  return e;
312
459
  }
313
- function te(i, e, t) {
314
- return a().generateHash([i, e, t].join(""));
460
+ function oe(i, e, t) {
461
+ return c().generateHash([i, e, t].join(""));
315
462
  }
316
- function Xe(i) {
317
- let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "3.1.0";
463
+ function mt(i) {
464
+ let n = "mParticle_wsdkv_" + c().getVersion() + "_kitv_" + "3.2.0";
318
465
  return i && (n += "_" + i), n;
319
466
  }
320
- function he(i) {
321
- let e = 5381;
322
- for (let t = 0; t < i.length; t++)
323
- e = (e << 5) + e + i.charCodeAt(t), e = e & e;
324
- return e;
325
- }
326
- function D(i) {
467
+ function Y(i) {
327
468
  const e = document.createElement("iframe");
328
469
  e.style.display = "none", e.setAttribute("sandbox", "allow-scripts allow-same-origin"), e.src = i, e.onload = function() {
329
470
  e.onload = null, e.parentNode && e.parentNode.removeChild(e);
@@ -331,54 +472,54 @@ function D(i) {
331
472
  const t = document.body || document.head;
332
473
  t && t.appendChild(e);
333
474
  }
334
- function ie(i, e) {
335
- const t = he(window.location.origin);
336
- if (y._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= Ke)
475
+ function ce(i, e) {
476
+ const t = de(window.location.origin);
477
+ if (P._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= et)
337
478
  return;
338
479
  const r = window.__rokt_li_guid__;
339
480
  if (!r || i && i.includes("://") && !/^https:\/\//i.test(i))
340
481
  return;
341
- const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), c = i ? N(i) : "https://apps.rokt.com";
342
- D(c + "/v1/wsdk-init/index.html?" + o), D(
343
- "https://" + Me + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
482
+ const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), a = i ? K(i) : "https://apps.rokt.com";
483
+ Y(a + "/v1/wsdk-init/index.html?" + o), Y(
484
+ "https://" + Ze + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
344
485
  );
345
486
  }
346
- function Ze() {
487
+ function Et() {
347
488
  return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
348
489
  }
349
- function et() {
490
+ function _t() {
350
491
  return typeof window < "u" ? window.location?.href : void 0;
351
492
  }
352
- function tt() {
493
+ function It() {
353
494
  return typeof window < "u" ? window.navigator?.userAgent : void 0;
354
495
  }
355
- class ge {
496
+ class _e {
356
497
  constructor() {
357
498
  this._logCount = {};
358
499
  }
359
500
  incrementAndCheck(e) {
360
501
  const n = (this._logCount[e] || 0) + 1;
361
- return this._logCount[e] = n, n > Je;
502
+ return this._logCount[e] = n, n > pt;
362
503
  }
363
504
  }
364
- class R {
505
+ class w {
365
506
  constructor(e, t, n, r, s) {
366
507
  this._reporter = "mp-wsdk";
367
508
  const o = e.isLoggingEnabled;
368
- this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new ge(), this._isEnabled = Ze() || o;
509
+ this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new _e(), this._isEnabled = Et() || o;
369
510
  }
370
511
  send(e, t, n, r, s, o) {
371
512
  if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
372
513
  try {
373
- const c = {
514
+ const a = {
374
515
  additionalInformation: {
375
516
  message: n,
376
517
  version: this._integrationName
377
518
  },
378
519
  severity: t,
379
- code: r || W.UNKNOWN_ERROR,
380
- url: et(),
381
- deviceInfo: tt(),
520
+ code: r || z.UNKNOWN_ERROR,
521
+ url: _t(),
522
+ deviceInfo: It(),
382
523
  stackTrace: s,
383
524
  reporter: this._reporter,
384
525
  integration: this._integrationName
@@ -391,7 +532,7 @@ class R {
391
532
  this._launcherInstanceGuid && (u["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (u["rokt-account-id"] = this._accountId), fetch(e, {
392
533
  method: "POST",
393
534
  headers: u,
394
- body: JSON.stringify(c)
535
+ body: JSON.stringify(a)
395
536
  }).then((l) => {
396
537
  if (!l.ok) {
397
538
  const g = new Error("HTTP " + l.status + " from log endpoint");
@@ -400,29 +541,29 @@ class R {
400
541
  }).catch((l) => {
401
542
  console.error("ReportingTransport: Failed to send log", l), o && o(l);
402
543
  });
403
- } catch (c) {
404
- console.error("ReportingTransport: Failed to send log", c), o && o(c);
544
+ } catch (a) {
545
+ console.error("ReportingTransport: Failed to send log", a), o && o(a);
405
546
  }
406
547
  }
407
548
  }
408
- class ne {
549
+ class ae {
409
550
  constructor(e, t, n, r, s) {
410
- this._transport = new R(e, t, n, r, s), this._errorUrl = de(e?.errorUrl, e?.integrationDomain, Be);
551
+ this._transport = new w(e, t, n, r, s), this._errorUrl = Ee(e?.errorUrl, e?.integrationDomain, gt);
411
552
  }
412
553
  report(e) {
413
554
  if (!e) return;
414
- const t = e.severity || A.ERROR;
555
+ const t = e.severity || v.ERROR;
415
556
  this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
416
557
  }
417
558
  }
418
- class re {
559
+ class le {
419
560
  constructor(e, t, n, r, s, o) {
420
- this._transport = new R(e, n, r, s, o), this._diagnosticTransport = new R(e, n, r, s), this._placementDiagnosticTransport = new R(
561
+ this._transport = new w(e, n, r, s, o), this._diagnosticTransport = new w(e, n, r, s), this._placementDiagnosticTransport = new w(
421
562
  e,
422
563
  n,
423
564
  r,
424
565
  s
425
- ), this._loggingUrl = de(e?.loggingUrl, e?.integrationDomain, qe), this._errorReportingService = t;
566
+ ), this._loggingUrl = Ee(e?.loggingUrl, e?.integrationDomain, ht), this._errorReportingService = t;
426
567
  }
427
568
  log(e) {
428
569
  e && this._send(this._transport, e);
@@ -436,7 +577,7 @@ class re {
436
577
  _send(e, t) {
437
578
  e.send(
438
579
  this._loggingUrl,
439
- A.INFO,
580
+ v.INFO,
440
581
  t.message,
441
582
  t.code,
442
583
  void 0,
@@ -445,16 +586,16 @@ class re {
445
586
  const r = typeof n.statusCode == "number";
446
587
  this._errorReportingService.report({
447
588
  message: "LoggingService: Failed to send log: " + n.message,
448
- code: W.LOG_DELIVERY_FAILURE,
449
- severity: r ? A.ERROR : A.WARNING
589
+ code: z.LOG_DELIVERY_FAILURE,
590
+ severity: r ? v.ERROR : v.WARNING
450
591
  });
451
592
  }
452
593
  }
453
594
  );
454
595
  }
455
596
  }
456
- function it(i) {
457
- const e = F(window.location.href), t = i.EventAttributes?.title || document.title, n = ve(), r = i.ActiveTimeOnSite;
597
+ function St(i) {
598
+ const e = j(window.location.href), t = i.EventAttributes?.title || document.title, n = Oe(), r = i.ActiveTimeOnSite;
458
599
  return {
459
600
  pageUrl: e,
460
601
  sourceMessageId: i.SourceMessageId,
@@ -464,14 +605,14 @@ function it(i) {
464
605
  ...Number.isFinite(r) ? { activeTimeOnSite: r } : {}
465
606
  };
466
607
  }
467
- const f = class f {
608
+ const I = class I {
468
609
  constructor() {
469
- this.name = d, this.id = L, this.moduleId = L, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null, this._launcherAttachState = Te();
610
+ this.name = d, this.id = N, this.moduleId = N, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null, this._launcherAttachState = We(), this.accountId = null, this._preselectState = je();
470
611
  }
471
612
  // ---- Private helpers ----
472
613
  getEventAttributeValue(e, t) {
473
614
  const n = e && e.EventAttributes;
474
- return !n || typeof n[t] > "u" ? null : n[t];
615
+ return !n || n[t] === void 0 ? null : n[t];
475
616
  }
476
617
  doesEventAttributeConditionMatch(e, t) {
477
618
  if (!e || !m(e.operator))
@@ -497,28 +638,28 @@ const f = class f {
497
638
  const t = Object.keys(this.placementEventAttributeMappingLookup);
498
639
  for (let n = 0; n < t.length; n++) {
499
640
  const r = t[n], s = this.placementEventAttributeMappingLookup[r];
500
- if (C(s))
641
+ if (T(s))
501
642
  continue;
502
643
  let o = !0;
503
- for (let c = 0; c < s.length; c++)
504
- if (!this.doesEventMatchRule(e, s[c])) {
644
+ for (let a = 0; a < s.length; a++)
645
+ if (!this.doesEventMatchRule(e, s[a])) {
505
646
  o = !1;
506
647
  break;
507
648
  }
508
- o && a().Rokt.setLocalSessionAttribute?.(r, !0);
649
+ o && c().Rokt.setLocalSessionAttribute?.(r, !0);
509
650
  }
510
651
  }
511
652
  capturePageView(e) {
512
653
  let t;
513
654
  try {
514
- t = F(window.location.href);
515
- const n = V(), r = it(e);
655
+ t = j(window.location.href);
656
+ const n = B(), r = St(e);
516
657
  n.push(r);
517
- const s = Math.min(n.length, le), o = Ae(n);
658
+ const s = Math.min(n.length, pe), o = ke(n);
518
659
  if (o === 0) {
519
- const c = K() ? "quota" : "ls_unavailable";
660
+ const a = x() ? "quota" : "ls_unavailable";
520
661
  this.loggingService?.log({
521
- message: `Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,
662
+ message: `Rokt Kit: Failed to persist page view for ${t} [reason: ${a}]`,
522
663
  code: "PAGE_VIEW_CAPTURE_FAILED"
523
664
  });
524
665
  } else o < s && this.loggingService?.log({
@@ -526,15 +667,41 @@ const f = class f {
526
667
  code: "PAGE_VIEW_QUOTA_EVICTION"
527
668
  });
528
669
  } catch (n) {
529
- const r = K() ? "exception" : "ls_unavailable", s = n instanceof Error ? n.message : String(n);
670
+ const r = x() ? "exception" : "ls_unavailable", s = n instanceof Error ? n.message : String(n);
530
671
  this.loggingService?.log({
531
672
  message: `Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,
532
673
  code: "PAGE_VIEW_CAPTURE_FAILED"
533
674
  });
534
675
  }
535
676
  }
677
+ isPreselectionEnabled() {
678
+ return this.launcher?.enablePreselection === !0;
679
+ }
680
+ buildCacheMatchKeys(e) {
681
+ if (!this.isPreselectionEnabled())
682
+ return;
683
+ const t = Ue(this.accountId, e);
684
+ if (t)
685
+ return t.attributeKeys;
686
+ }
687
+ buildPreselectHost() {
688
+ return {
689
+ accountId: this.accountId,
690
+ filteredUser: this.filters.filteredUser,
691
+ userAttributes: this.userAttributes,
692
+ isKitReady: () => this.isKitReady(),
693
+ isPreselectionEnabled: () => this.isPreselectionEnabled(),
694
+ getEventAttributeValue: (e, t) => this.getEventAttributeValue(e, t),
695
+ logPlacementDiagnostic: (e) => this.loggingService?.logPlacementDiagnostic(e),
696
+ log: (e) => this.loggingService?.log(e),
697
+ selectPlacements: (e) => this.selectPlacements(e)
698
+ };
699
+ }
700
+ flushPendingPreselectDispatches() {
701
+ He(this._preselectState, this.buildPreselectHost());
702
+ }
536
703
  isLauncherReadyToAttach() {
537
- return !!window.Rokt && b(window.Rokt.createLauncher);
704
+ return !!window.Rokt && O(window.Rokt.createLauncher);
538
705
  }
539
706
  /**
540
707
  * Returns the user identities from the filtered user, if any.
@@ -546,38 +713,38 @@ const f = class f {
546
713
  return this.replaceOtherIdentityWithEmailsha256(t);
547
714
  }
548
715
  returnLocalSessionAttributes() {
549
- return !a().Rokt || typeof a().Rokt.getLocalSessionAttributes != "function" ? {} : a().Rokt.getLocalSessionAttributes();
716
+ return !c().Rokt || typeof c().Rokt.getLocalSessionAttributes != "function" ? {} : c().Rokt.getLocalSessionAttributes();
550
717
  }
551
718
  replaceOtherIdentityWithEmailsha256(e) {
552
719
  const t = { ...e || {} }, n = this._mappedEmailSha256Key;
553
- return n && e[n] && (t[f.EMAIL_SHA256_KEY] = e[n]), n && delete t[n], t;
720
+ return n && e[n] && (t[I.EMAIL_SHA256_KEY] = e[n]), n && delete t[n], t;
554
721
  }
555
722
  logSelectPlacementsEvent(e) {
556
- if (!window.mParticle || typeof a().logEvent != "function" || !E(e))
723
+ if (!window.mParticle || typeof c().logEvent != "function" || !E(e))
557
724
  return;
558
- const t = a().EventType.Other;
559
- a().logEvent(Ce, t, e);
725
+ const t = c().EventType.Other;
726
+ c().logEvent(Xe, t, e);
560
727
  }
561
728
  setRoktSessionId(e) {
562
729
  if (!(!e || typeof e != "string"))
563
730
  try {
564
- const t = a().getInstance();
565
- t && b(t.setIntegrationAttribute) && t.setIntegrationAttribute(L, {
731
+ const t = c().getInstance();
732
+ t && O(t.setIntegrationAttribute) && t.setIntegrationAttribute(N, {
566
733
  roktSessionId: e
567
734
  });
568
735
  } catch {
569
736
  }
570
737
  }
571
738
  readMpSessionId() {
572
- const e = a()?.sessionManager, t = e?.getSessionId ?? e?.getSession;
573
- if (b(t))
739
+ const e = c()?.sessionManager, t = e?.getSessionId ?? e?.getSession;
740
+ if (O(t))
574
741
  return t.call(e) || void 0;
575
742
  }
576
743
  readMpDeviceId() {
577
- return a()?.getDeviceId?.() || void 0;
744
+ return c()?.getDeviceId?.() || void 0;
578
745
  }
579
746
  attachLauncher(e, t, n = []) {
580
- be(this._launcherAttachState, {
747
+ ze(this._launcherAttachState, {
581
748
  accountId: e,
582
749
  launcherOptions: t || {},
583
750
  legacyRoktExtensions: n
@@ -588,25 +755,25 @@ const f = class f {
588
755
  };
589
756
  let s;
590
757
  return this.isPartnerInLocalLauncherTestGroup() ? s = Promise.resolve(window.Rokt.createLocalLauncher(r)) : s = window.Rokt.createLauncher(r), s.then(async (o) => {
591
- await Qe([...n], o), this.initRoktLauncher(o);
758
+ await ft([...n], o), this.initRoktLauncher(o);
592
759
  }).catch((o) => {
593
- Oe(this._launcherAttachState), console.error("Error creating Rokt launcher:", o);
760
+ Je(this._launcherAttachState), console.error("Error creating Rokt launcher:", o);
594
761
  });
595
762
  }
596
763
  recreateLauncherIfTerminated() {
597
- return Ue(
764
+ return Qe(
598
765
  this._launcherAttachState,
599
766
  this.isLauncherReadyToAttach(),
600
767
  (e) => this.attachLauncher(e.accountId, e.launcherOptions, e.legacyRoktExtensions)
601
768
  );
602
769
  }
603
770
  initRoktLauncher(e) {
604
- window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e, Le(this._launcherAttachState);
605
- const t = a().Rokt?.filters;
606
- t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, ie(this.domain, this.integrationName), a().Rokt.attachKit(this);
771
+ window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e, $e(this._launcherAttachState);
772
+ const t = c().Rokt?.filters;
773
+ t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, ce(this.domain, this.integrationName), c().Rokt.attachKit(this), this.flushPendingPreselectDispatches();
607
774
  }
608
775
  fetchOptimizely() {
609
- const e = a()._getActiveForwarders().filter((t) => t.name === "Optimizely");
776
+ const e = c()._getActiveForwarders().filter((t) => t.name === "Optimizely");
610
777
  try {
611
778
  if (e.length > 0 && window.optimizely) {
612
779
  const t = window.optimizely.get("state");
@@ -623,107 +790,107 @@ const f = class f {
623
790
  // When the partner has opted out of targeting (noTargeting launcher option),
624
791
  // the kit must not collect behavioral targeting signals such as page views.
625
792
  isTargetingDisabled() {
626
- return a().Rokt?.launcherOptions?.noTargeting === !0;
793
+ return c().Rokt?.launcherOptions?.noTargeting === !0;
627
794
  }
628
795
  isPartnerInLocalLauncherTestGroup() {
629
- return !!(a().config && a().config.isLocalLauncherEnabled && this.isAssignedToSampleGroup());
796
+ return !!(c().config && c().config.isLocalLauncherEnabled && this.isAssignedToSampleGroup());
630
797
  }
631
798
  isAssignedToSampleGroup() {
632
799
  return Math.random() > 0.5;
633
800
  }
634
801
  captureTiming(e) {
635
- window && a() && a().captureTiming && e && a().captureTiming(e);
802
+ window && c() && c().captureTiming && e && c().captureTiming(e);
636
803
  }
637
804
  // ---- Public methods (mParticle Kit Callbacks) ----
638
805
  /**
639
806
  * Initializes the Rokt forwarder with settings from the mParticle server.
640
807
  */
641
808
  init(e, t, n, r, s) {
642
- const o = e, c = o.accountId;
643
- this.userAttributes = T(s), this._onboardingExpProvider = o.onboardingExpProvider;
644
- const u = P(o.placementEventMapping);
645
- this.placementEventMappingLookup = Z(u);
646
- const l = P(
809
+ const o = e, a = o.accountId;
810
+ this.accountId = a || null, this.userAttributes = L(s), this._onboardingExpProvider = o.onboardingExpProvider;
811
+ const u = U(o.placementEventMapping);
812
+ this.placementEventMappingLookup = re(u);
813
+ const l = U(
647
814
  o.placementEventAttributeMapping
648
815
  );
649
- this.placementEventAttributeMappingLookup = ee(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
650
- const g = a().Rokt?.domain, { roktExtensionsQueryParams: U, legacyRoktExtensions: v, loadThankYouElement: w } = X(
816
+ this.placementEventAttributeMappingLookup = se(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
817
+ const g = c().Rokt?.domain, { roktExtensionsQueryParams: b, legacyRoktExtensions: h, loadThankYouElement: S } = ne(
651
818
  o.roktExtensions
652
819
  ), p = {
653
- ...a().Rokt?.launcherOptions || {}
820
+ ...c().Rokt?.launcherOptions || {}
654
821
  };
655
- this.integrationName = Xe(p.integrationName), p.integrationName = this.integrationName, this.domain = g;
656
- const k = {
822
+ this.integrationName = mt(p.integrationName), p.integrationName = this.integrationName, this.domain = g;
823
+ const R = {
657
824
  loggingUrl: o.loggingUrl,
658
825
  errorUrl: o.errorUrl,
659
826
  integrationDomain: g,
660
- isLoggingEnabled: a().config?.isLoggingEnabled === !0
661
- }, S = new ne(
662
- k,
827
+ isLoggingEnabled: c().config?.isLoggingEnabled === !0
828
+ }, y = new ae(
829
+ R,
663
830
  this.integrationName,
664
831
  window.__rokt_li_guid__,
665
832
  o.accountId
666
- ), I = new re(
667
- k,
668
- S,
833
+ ), A = new le(
834
+ R,
835
+ y,
669
836
  this.integrationName,
670
837
  window.__rokt_li_guid__,
671
838
  o.accountId
672
839
  );
673
- if (this.errorReportingService = S, this.loggingService = I, this.isTargetingDisabled())
840
+ if (this.errorReportingService = y, this.loggingService = A, this.isTargetingDisabled())
674
841
  try {
675
- z(), $();
676
- } catch (h) {
842
+ Q(), X();
843
+ } catch (f) {
677
844
  this.errorReportingService?.report({
678
845
  message: "Rokt Kit: Failed to clear page views when targeting is disabled",
679
846
  code: "PAGE_VIEW_CAPTURE_FAILED",
680
- severity: A.INFO,
681
- stackTrace: h instanceof Error ? h.stack : void 0
847
+ severity: v.INFO,
848
+ stackTrace: f instanceof Error ? f.stack : void 0
682
849
  });
683
850
  }
684
- return a()._registerErrorReportingService && a()._registerErrorReportingService(S), a()._registerLoggingService && a()._registerLoggingService(I), n ? (this.testHelpers = {
685
- generateLauncherScript: B,
686
- generateThankYouElementScript: J,
687
- extractRoktExtensionConfig: X,
688
- hashEventMessage: te,
689
- parseSettingsString: P,
690
- generateMappedEventLookup: Z,
691
- generateMappedEventAttributeLookup: ee,
692
- sendAdBlockMeasurementSignals: ie,
693
- createAutoRemovedIframe: D,
694
- djb2: he,
695
- setAllowedOriginHashes: (h) => {
696
- f._allowedOriginHashes = h;
851
+ return c()._registerErrorReportingService && c()._registerErrorReportingService(y), c()._registerLoggingService && c()._registerLoggingService(A), n ? (this.testHelpers = {
852
+ generateLauncherScript: ee,
853
+ generateThankYouElementScript: te,
854
+ extractRoktExtensionConfig: ne,
855
+ hashEventMessage: oe,
856
+ parseSettingsString: U,
857
+ generateMappedEventLookup: re,
858
+ generateMappedEventAttributeLookup: se,
859
+ sendAdBlockMeasurementSignals: ce,
860
+ createAutoRemovedIframe: Y,
861
+ djb2: de,
862
+ setAllowedOriginHashes: (f) => {
863
+ I._allowedOriginHashes = f;
697
864
  },
698
- ReportingTransport: R,
699
- ErrorReportingService: ne,
700
- LoggingService: re,
701
- RateLimiter: ge,
702
- ErrorCodes: W,
703
- WSDKErrorSeverity: A,
704
- resetLauncherAttachState: () => Ne(this._launcherAttachState)
705
- }, this.attachLauncher(c, p), "Successfully initialized: " + d) : (w && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), Q(xe, J(g), {
865
+ ReportingTransport: w,
866
+ ErrorReportingService: ae,
867
+ LoggingService: le,
868
+ RateLimiter: _e,
869
+ ErrorCodes: z,
870
+ WSDKErrorSeverity: v,
871
+ resetLauncherAttachState: () => Be(this._launcherAttachState)
872
+ }, this.attachLauncher(a, p), "Successfully initialized: " + d) : (S && (c().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), ie(nt, te(g), {
706
873
  onLoad: () => {
707
874
  this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
708
875
  },
709
- onError: (h) => {
710
- console.error("Error loading Rokt Thank You Element script:", h);
876
+ onError: (f) => {
877
+ console.error("Error loading Rokt Thank You Element script:", f);
711
878
  }
712
- })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, v) : (Q(Fe, B(g, U), {
879
+ })), this.isLauncherReadyToAttach() ? this.attachLauncher(a, p, h) : (ie(it, ee(g, b), {
713
880
  onLoad: () => {
714
- this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, v) : console.error("Rokt object is not available after script load.");
881
+ this.isLauncherReadyToAttach() ? this.attachLauncher(a, p, h) : console.error("Rokt object is not available after script load.");
715
882
  },
716
- onError: (h) => {
717
- console.error("Error loading Rokt launcher script:", h);
883
+ onError: (f) => {
884
+ console.error("Error loading Rokt launcher script:", f);
718
885
  }
719
- }), this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
886
+ }), this.captureTiming(I.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
720
887
  }
721
888
  process(e) {
722
- if (this.isTargetingDisabled() || (e.EventDataType === je && (ke(this.loggingService), this.capturePageView(e)), e.EventDataType === We && (z(), $())), !this.isKitReady())
889
+ if (this.isTargetingDisabled() || (e.EventDataType === st && (we(this.loggingService), this.capturePageView(e), me(this._preselectState, this.buildPreselectHost(), e)), e.EventDataType === ot && (Q(), X())), !this.isKitReady())
723
890
  return "Kit not ready for forwarder: " + d;
724
- if (b(a().Rokt?.setLocalSessionAttribute) && (C(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !C(this.placementEventMappingLookup))) {
725
- const t = te(e.EventDataType, e.EventCategory, e.EventName ?? "");
726
- this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
891
+ if (O(c().Rokt?.setLocalSessionAttribute) && (T(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !T(this.placementEventMappingLookup))) {
892
+ const t = oe(e.EventDataType, e.EventCategory, e.EventName ?? "");
893
+ this.placementEventMappingLookup[String(t)] && c().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
727
894
  }
728
895
  return "Successfully sent to forwarder: " + d;
729
896
  }
@@ -735,23 +902,25 @@ const f = class f {
735
902
  window.Rokt.setExtensionData(e);
736
903
  }
737
904
  setUserAttribute(e, t) {
738
- return this.loggingService?.logDiagnostic(M("setUserAttribute", [e])), se(e) || (this.userAttributes[e] = t), "Successfully set user attribute for forwarder: " + d;
905
+ return this.loggingService?.logDiagnostic(M("setUserAttribute", [e])), ue(e) || (this.userAttributes[e] = t), Ce(this.accountId, e) && this.flushPendingPreselectDispatches(), "Successfully set user attribute for forwarder: " + d;
739
906
  }
740
907
  removeUserAttribute(e) {
741
908
  return this.loggingService?.logDiagnostic(M("removeUserAttribute", [e])), delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
742
909
  }
743
910
  handleIdentityComplete(e, t) {
744
- return this.userAttributes = T(e.getAllUserAttributes()), this.loggingService?.logDiagnostic(M(t, Object.keys(this.userAttributes))), "Successfully called " + t + " for forwarder: " + d;
911
+ return this.userAttributes = L(e.getAllUserAttributes()), this.loggingService?.logDiagnostic(M(t, Object.keys(this.userAttributes))), "Successfully called " + t + " for forwarder: " + d;
745
912
  }
746
913
  onUserIdentified(e) {
747
914
  const t = e;
748
- return this.filters.filteredUser = t, this._workspaceSearchInFlightPromise = this.search(t), this.handleIdentityComplete(e, "onUserIdentified");
915
+ this.filters.filteredUser = t, this._workspaceSearchInFlightPromise = this.search(t);
916
+ const n = this.handleIdentityComplete(e, "onUserIdentified");
917
+ return this.flushPendingPreselectDispatches(), n;
749
918
  }
750
919
  search(e) {
751
920
  const t = this._workspaceIdSyncApiKey;
752
921
  if (!t)
753
922
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
754
- const n = a().Identity?.search;
923
+ const n = c().Identity?.search;
755
924
  if (typeof n != "function")
756
925
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
757
926
  const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, s = {};
@@ -763,8 +932,8 @@ const f = class f {
763
932
  const o = Object.keys(s);
764
933
  if (o.length === 0)
765
934
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
766
- const c = o.sort().map((u) => `${u}=${s[u]}`).join("&");
767
- return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((u) => {
935
+ const a = o.sort().map((u) => `${u}=${s[u]}`).join("&");
936
+ return a === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = a, new Promise((u) => {
768
937
  try {
769
938
  n(t, s, (l) => {
770
939
  l?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), u();
@@ -812,7 +981,7 @@ const f = class f {
812
981
  if (t) {
813
982
  const n = this._workspaceSearchInFlightPromise, r = n ? Promise.race([
814
983
  n,
815
- new Promise((s) => setTimeout(s, q))
984
+ new Promise((s) => setTimeout(s, Z))
816
985
  ]) : Promise.resolve();
817
986
  return Promise.all([t, r]).then(
818
987
  () => this._dispatchPlacements(e)
@@ -822,33 +991,42 @@ const f = class f {
822
991
  const n = this._workspaceSearchInFlightPromise;
823
992
  return Promise.race([
824
993
  n,
825
- new Promise((r) => setTimeout(r, q))
994
+ new Promise((r) => setTimeout(r, Z))
826
995
  ]).then(() => this._dispatchPlacements(e));
827
996
  }
828
997
  return this._dispatchPlacements(e);
829
998
  }
830
999
  _dispatchPlacements(e) {
831
- const t = e && e.attributes || {}, r = { ...T(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
1000
+ const t = e && e.attributes || {}, r = { ...L(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], a = s.filteredUser || null, u = a ? a.getMPID() : null;
832
1001
  let l;
833
- s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = T(l);
834
- const g = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, U = this.returnUserIdentities(c), v = this.returnLocalSessionAttributes(), w = ye(V()), p = Re(), k = this.readMpSessionId(), S = this.readMpDeviceId(), I = {
835
- ...U,
1002
+ s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = L(l);
1003
+ const g = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, b = this.returnUserIdentities(a), h = this.returnLocalSessionAttributes(), S = Te(B()), p = Le(), R = this.readMpSessionId(), y = this.readMpDeviceId(), A = {
1004
+ ...b,
836
1005
  ...l,
837
1006
  ...g,
838
- ...v,
839
- ...w.length ? { [Ge]: JSON.stringify(w) } : {},
840
- ...p ? { [He]: p } : {},
841
- ...this.userIdentifiedInWorkspace ? { [Ye]: !0 } : {},
842
- ...k ? { [Ve]: k } : {},
843
- ...S ? { [ze]: S } : {},
1007
+ ...h,
1008
+ ...S.length ? { [ct]: JSON.stringify(S) } : {},
1009
+ ...p ? { [at]: p } : {},
1010
+ ...this.userIdentifiedInWorkspace ? { [rt]: !0 } : {},
1011
+ ...R ? { [lt]: R } : {},
1012
+ ...y ? { [ut]: y } : {},
844
1013
  mpid: u
845
- }, h = { ...e, attributes: I };
1014
+ }, f = this.buildCacheMatchKeys(typeof e.identifier == "string" ? e.identifier : void 0), Ie = {
1015
+ ...e,
1016
+ attributes: A,
1017
+ ...f !== void 0 ? { cacheMatchKeys: f } : {}
1018
+ };
846
1019
  this.loggingService?.logPlacementDiagnostic(
847
- we(Object.keys(I))
1020
+ Ye(Object.keys(A))
848
1021
  );
849
- const G = this.launcher.selectPlacements(h), pe = () => this.logSelectPlacementsEvent(I);
850
- return Promise.resolve(G).then((fe) => fe?.context?.sessionId?.then((me) => this.setRoktSessionId(me))).catch(() => {
851
- }).finally(pe), G;
1022
+ const $ = this.launcher.selectPlacements(Ie), q = e.preselect === !0, Se = () => {
1023
+ q || this.logSelectPlacementsEvent(A);
1024
+ };
1025
+ return Promise.resolve($).then((ye) => {
1026
+ if (!q)
1027
+ return ye?.context?.sessionId?.then((Ae) => this.setRoktSessionId(Ae));
1028
+ }).catch(() => {
1029
+ }).finally(Se), $;
852
1030
  }
853
1031
  /**
854
1032
  * Passes attributes to the Rokt Web SDK for client-side hashing.
@@ -874,7 +1052,7 @@ const f = class f {
874
1052
  * here would flip the kit to not-ready with no drain path for queued calls.
875
1053
  */
876
1054
  terminate() {
877
- return this.isKitReady() ? (Pe(this._launcherAttachState), this.launcher.terminate()) : (console.error("Rokt Kit: Not initialized"), Promise.resolve());
1055
+ return this.isKitReady() ? (qe(this._launcherAttachState), this.launcher.terminate()) : (console.error("Rokt Kit: Not initialized"), Promise.resolve());
878
1056
  }
879
1057
  /**
880
1058
  * Registers a callback to be invoked once rokt-thank-you-element.js becomes available.
@@ -883,14 +1061,14 @@ const f = class f {
883
1061
  this._isThankYouElementLoaded ? e() : this._thankYouElementOnLoadCallback = e;
884
1062
  }
885
1063
  };
886
- f._allowedOriginHashes = [-553112570, 549508659], f.PERFORMANCE_MARKS = {
1064
+ I._allowedOriginHashes = [-553112570, 549508659], I.PERFORMANCE_MARKS = {
887
1065
  RoktScriptAppended: "mp:RoktScriptAppended"
888
- }, f.EMAIL_SHA256_KEY = "emailsha256";
889
- let y = f;
890
- function nt() {
891
- return L;
1066
+ }, I.EMAIL_SHA256_KEY = "emailsha256";
1067
+ let P = I;
1068
+ function yt() {
1069
+ return N;
892
1070
  }
893
- function rt(i) {
1071
+ function At(i) {
894
1072
  if (!i) {
895
1073
  window.console.log("You must pass a config object to register the kit " + d);
896
1074
  return;
@@ -900,17 +1078,17 @@ function rt(i) {
900
1078
  return;
901
1079
  }
902
1080
  E(i.kits) ? i.kits[d] = {
903
- constructor: y
1081
+ constructor: P
904
1082
  } : (i.kits = {}, i.kits[d] = {
905
- constructor: y
1083
+ constructor: P
906
1084
  }), window.console.log("Successfully registered " + d + " to your mParticle configuration");
907
1085
  }
908
- typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
1086
+ typeof window < "u" && window.mParticle && c().addForwarder && c().addForwarder({
909
1087
  name: d,
910
- constructor: y,
911
- getId: nt
1088
+ constructor: P,
1089
+ getId: yt
912
1090
  });
913
1091
  export {
914
- rt as register
1092
+ At as register
915
1093
  };
916
1094
  //# sourceMappingURL=Rokt-Kit.esm.js.map