@uniformdev/canvas-next-rsc-client 19.77.0 → 19.78.1

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/index.js CHANGED
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
2
  "use client";
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __commonJS = (cb, mod) => function __require() {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ };
7
12
  var __export = (target, all) => {
8
13
  for (var name in all)
9
14
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,8 +21,224 @@ var __copyProps = (to, from, except, desc) => {
16
21
  }
17
22
  return to;
18
23
  };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
19
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
33
 
34
+ // ../../node_modules/.pnpm/rfdc@1.3.0/node_modules/rfdc/index.js
35
+ var require_rfdc = __commonJS({
36
+ "../../node_modules/.pnpm/rfdc@1.3.0/node_modules/rfdc/index.js"(exports, module2) {
37
+ "use strict";
38
+ module2.exports = rfdc4;
39
+ function copyBuffer(cur) {
40
+ if (cur instanceof Buffer) {
41
+ return Buffer.from(cur);
42
+ }
43
+ return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length);
44
+ }
45
+ function rfdc4(opts) {
46
+ opts = opts || {};
47
+ if (opts.circles)
48
+ return rfdcCircles(opts);
49
+ return opts.proto ? cloneProto : clone2;
50
+ function cloneArray(a, fn) {
51
+ var keys = Object.keys(a);
52
+ var a2 = new Array(keys.length);
53
+ for (var i = 0; i < keys.length; i++) {
54
+ var k = keys[i];
55
+ var cur = a[k];
56
+ if (typeof cur !== "object" || cur === null) {
57
+ a2[k] = cur;
58
+ } else if (cur instanceof Date) {
59
+ a2[k] = new Date(cur);
60
+ } else if (ArrayBuffer.isView(cur)) {
61
+ a2[k] = copyBuffer(cur);
62
+ } else {
63
+ a2[k] = fn(cur);
64
+ }
65
+ }
66
+ return a2;
67
+ }
68
+ function clone2(o) {
69
+ if (typeof o !== "object" || o === null)
70
+ return o;
71
+ if (o instanceof Date)
72
+ return new Date(o);
73
+ if (Array.isArray(o))
74
+ return cloneArray(o, clone2);
75
+ if (o instanceof Map)
76
+ return new Map(cloneArray(Array.from(o), clone2));
77
+ if (o instanceof Set)
78
+ return new Set(cloneArray(Array.from(o), clone2));
79
+ var o2 = {};
80
+ for (var k in o) {
81
+ if (Object.hasOwnProperty.call(o, k) === false)
82
+ continue;
83
+ var cur = o[k];
84
+ if (typeof cur !== "object" || cur === null) {
85
+ o2[k] = cur;
86
+ } else if (cur instanceof Date) {
87
+ o2[k] = new Date(cur);
88
+ } else if (cur instanceof Map) {
89
+ o2[k] = new Map(cloneArray(Array.from(cur), clone2));
90
+ } else if (cur instanceof Set) {
91
+ o2[k] = new Set(cloneArray(Array.from(cur), clone2));
92
+ } else if (ArrayBuffer.isView(cur)) {
93
+ o2[k] = copyBuffer(cur);
94
+ } else {
95
+ o2[k] = clone2(cur);
96
+ }
97
+ }
98
+ return o2;
99
+ }
100
+ function cloneProto(o) {
101
+ if (typeof o !== "object" || o === null)
102
+ return o;
103
+ if (o instanceof Date)
104
+ return new Date(o);
105
+ if (Array.isArray(o))
106
+ return cloneArray(o, cloneProto);
107
+ if (o instanceof Map)
108
+ return new Map(cloneArray(Array.from(o), cloneProto));
109
+ if (o instanceof Set)
110
+ return new Set(cloneArray(Array.from(o), cloneProto));
111
+ var o2 = {};
112
+ for (var k in o) {
113
+ var cur = o[k];
114
+ if (typeof cur !== "object" || cur === null) {
115
+ o2[k] = cur;
116
+ } else if (cur instanceof Date) {
117
+ o2[k] = new Date(cur);
118
+ } else if (cur instanceof Map) {
119
+ o2[k] = new Map(cloneArray(Array.from(cur), cloneProto));
120
+ } else if (cur instanceof Set) {
121
+ o2[k] = new Set(cloneArray(Array.from(cur), cloneProto));
122
+ } else if (ArrayBuffer.isView(cur)) {
123
+ o2[k] = copyBuffer(cur);
124
+ } else {
125
+ o2[k] = cloneProto(cur);
126
+ }
127
+ }
128
+ return o2;
129
+ }
130
+ }
131
+ function rfdcCircles(opts) {
132
+ var refs = [];
133
+ var refsNew = [];
134
+ return opts.proto ? cloneProto : clone2;
135
+ function cloneArray(a, fn) {
136
+ var keys = Object.keys(a);
137
+ var a2 = new Array(keys.length);
138
+ for (var i = 0; i < keys.length; i++) {
139
+ var k = keys[i];
140
+ var cur = a[k];
141
+ if (typeof cur !== "object" || cur === null) {
142
+ a2[k] = cur;
143
+ } else if (cur instanceof Date) {
144
+ a2[k] = new Date(cur);
145
+ } else if (ArrayBuffer.isView(cur)) {
146
+ a2[k] = copyBuffer(cur);
147
+ } else {
148
+ var index = refs.indexOf(cur);
149
+ if (index !== -1) {
150
+ a2[k] = refsNew[index];
151
+ } else {
152
+ a2[k] = fn(cur);
153
+ }
154
+ }
155
+ }
156
+ return a2;
157
+ }
158
+ function clone2(o) {
159
+ if (typeof o !== "object" || o === null)
160
+ return o;
161
+ if (o instanceof Date)
162
+ return new Date(o);
163
+ if (Array.isArray(o))
164
+ return cloneArray(o, clone2);
165
+ if (o instanceof Map)
166
+ return new Map(cloneArray(Array.from(o), clone2));
167
+ if (o instanceof Set)
168
+ return new Set(cloneArray(Array.from(o), clone2));
169
+ var o2 = {};
170
+ refs.push(o);
171
+ refsNew.push(o2);
172
+ for (var k in o) {
173
+ if (Object.hasOwnProperty.call(o, k) === false)
174
+ continue;
175
+ var cur = o[k];
176
+ if (typeof cur !== "object" || cur === null) {
177
+ o2[k] = cur;
178
+ } else if (cur instanceof Date) {
179
+ o2[k] = new Date(cur);
180
+ } else if (cur instanceof Map) {
181
+ o2[k] = new Map(cloneArray(Array.from(cur), clone2));
182
+ } else if (cur instanceof Set) {
183
+ o2[k] = new Set(cloneArray(Array.from(cur), clone2));
184
+ } else if (ArrayBuffer.isView(cur)) {
185
+ o2[k] = copyBuffer(cur);
186
+ } else {
187
+ var i = refs.indexOf(cur);
188
+ if (i !== -1) {
189
+ o2[k] = refsNew[i];
190
+ } else {
191
+ o2[k] = clone2(cur);
192
+ }
193
+ }
194
+ }
195
+ refs.pop();
196
+ refsNew.pop();
197
+ return o2;
198
+ }
199
+ function cloneProto(o) {
200
+ if (typeof o !== "object" || o === null)
201
+ return o;
202
+ if (o instanceof Date)
203
+ return new Date(o);
204
+ if (Array.isArray(o))
205
+ return cloneArray(o, cloneProto);
206
+ if (o instanceof Map)
207
+ return new Map(cloneArray(Array.from(o), cloneProto));
208
+ if (o instanceof Set)
209
+ return new Set(cloneArray(Array.from(o), cloneProto));
210
+ var o2 = {};
211
+ refs.push(o);
212
+ refsNew.push(o2);
213
+ for (var k in o) {
214
+ var cur = o[k];
215
+ if (typeof cur !== "object" || cur === null) {
216
+ o2[k] = cur;
217
+ } else if (cur instanceof Date) {
218
+ o2[k] = new Date(cur);
219
+ } else if (cur instanceof Map) {
220
+ o2[k] = new Map(cloneArray(Array.from(cur), cloneProto));
221
+ } else if (cur instanceof Set) {
222
+ o2[k] = new Set(cloneArray(Array.from(cur), cloneProto));
223
+ } else if (ArrayBuffer.isView(cur)) {
224
+ o2[k] = copyBuffer(cur);
225
+ } else {
226
+ var i = refs.indexOf(cur);
227
+ if (i !== -1) {
228
+ o2[k] = refsNew[i];
229
+ } else {
230
+ o2[k] = cloneProto(cur);
231
+ }
232
+ }
233
+ }
234
+ refs.pop();
235
+ refsNew.pop();
236
+ return o2;
237
+ }
238
+ }
239
+ }
240
+ });
241
+
21
242
  // src/index.ts
22
243
  var src_exports = {};
23
244
  __export(src_exports, {
@@ -120,6 +341,549 @@ var ContextUpdateTransferClient = ({
120
341
  return null;
121
342
  };
122
343
 
344
+ // ../../node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/lite/index.mjs
345
+ var has = Object.prototype.hasOwnProperty;
346
+ function dequal(foo, bar) {
347
+ var ctor, len;
348
+ if (foo === bar)
349
+ return true;
350
+ if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
351
+ if (ctor === Date)
352
+ return foo.getTime() === bar.getTime();
353
+ if (ctor === RegExp)
354
+ return foo.toString() === bar.toString();
355
+ if (ctor === Array) {
356
+ if ((len = foo.length) === bar.length) {
357
+ while (len-- && dequal(foo[len], bar[len]))
358
+ ;
359
+ }
360
+ return len === -1;
361
+ }
362
+ if (!ctor || typeof foo === "object") {
363
+ len = 0;
364
+ for (ctor in foo) {
365
+ if (has.call(foo, ctor) && ++len && !has.call(bar, ctor))
366
+ return false;
367
+ if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor]))
368
+ return false;
369
+ }
370
+ return Object.keys(bar).length === len;
371
+ }
372
+ }
373
+ return foo !== foo && bar !== bar;
374
+ }
375
+
376
+ // ../../node_modules/.pnpm/js-cookie@3.0.5/node_modules/js-cookie/dist/js.cookie.mjs
377
+ function assign(target) {
378
+ for (var i = 1; i < arguments.length; i++) {
379
+ var source = arguments[i];
380
+ for (var key in source) {
381
+ target[key] = source[key];
382
+ }
383
+ }
384
+ return target;
385
+ }
386
+ var defaultConverter = {
387
+ read: function(value) {
388
+ if (value[0] === '"') {
389
+ value = value.slice(1, -1);
390
+ }
391
+ return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
392
+ },
393
+ write: function(value) {
394
+ return encodeURIComponent(value).replace(
395
+ /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
396
+ decodeURIComponent
397
+ );
398
+ }
399
+ };
400
+ function init(converter, defaultAttributes) {
401
+ function set(name, value, attributes) {
402
+ if (typeof document === "undefined") {
403
+ return;
404
+ }
405
+ attributes = assign({}, defaultAttributes, attributes);
406
+ if (typeof attributes.expires === "number") {
407
+ attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
408
+ }
409
+ if (attributes.expires) {
410
+ attributes.expires = attributes.expires.toUTCString();
411
+ }
412
+ name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
413
+ var stringifiedAttributes = "";
414
+ for (var attributeName in attributes) {
415
+ if (!attributes[attributeName]) {
416
+ continue;
417
+ }
418
+ stringifiedAttributes += "; " + attributeName;
419
+ if (attributes[attributeName] === true) {
420
+ continue;
421
+ }
422
+ stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
423
+ }
424
+ return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes;
425
+ }
426
+ function get(name) {
427
+ if (typeof document === "undefined" || arguments.length && !name) {
428
+ return;
429
+ }
430
+ var cookies = document.cookie ? document.cookie.split("; ") : [];
431
+ var jar = {};
432
+ for (var i = 0; i < cookies.length; i++) {
433
+ var parts = cookies[i].split("=");
434
+ var value = parts.slice(1).join("=");
435
+ try {
436
+ var found = decodeURIComponent(parts[0]);
437
+ jar[found] = converter.read(value, found);
438
+ if (name === found) {
439
+ break;
440
+ }
441
+ } catch (e) {
442
+ }
443
+ }
444
+ return name ? jar[name] : jar;
445
+ }
446
+ return Object.create(
447
+ {
448
+ set,
449
+ get,
450
+ remove: function(name, attributes) {
451
+ set(
452
+ name,
453
+ "",
454
+ assign({}, attributes, {
455
+ expires: -1
456
+ })
457
+ );
458
+ },
459
+ withAttributes: function(attributes) {
460
+ return init(this.converter, assign({}, this.attributes, attributes));
461
+ },
462
+ withConverter: function(converter2) {
463
+ return init(assign({}, this.converter, converter2), this.attributes);
464
+ }
465
+ },
466
+ {
467
+ attributes: { value: Object.freeze(defaultAttributes) },
468
+ converter: { value: Object.freeze(converter) }
469
+ }
470
+ );
471
+ }
472
+ var api = init(defaultConverter, { path: "/" });
473
+
474
+ // ../context/dist/index.mjs
475
+ var import_rfdc = __toESM(require_rfdc(), 1);
476
+ var import_rfdc2 = __toESM(require_rfdc(), 1);
477
+ var import_rfdc3 = __toESM(require_rfdc(), 1);
478
+ var __accessCheck = (obj, member, msg) => {
479
+ if (!member.has(obj))
480
+ throw TypeError("Cannot " + msg);
481
+ };
482
+ var __privateGet = (obj, member, getter) => {
483
+ __accessCheck(obj, member, "read from private field");
484
+ return getter ? getter.call(obj) : member.get(obj);
485
+ };
486
+ var __privateSet = (obj, member, value, setter) => {
487
+ __accessCheck(obj, member, "write to private field");
488
+ setter ? setter.call(obj, value) : member.set(obj, value);
489
+ return value;
490
+ };
491
+ var __privateMethod = (obj, member, method) => {
492
+ __accessCheck(obj, member, "access private method");
493
+ return method;
494
+ };
495
+ var ENR_SEPARATOR = "_";
496
+ var _evaluator;
497
+ var _onLogMessage;
498
+ _evaluator = /* @__PURE__ */ new WeakMap();
499
+ _onLogMessage = /* @__PURE__ */ new WeakMap();
500
+ var _mf;
501
+ var _signalInstances;
502
+ var _onLogMessage2;
503
+ _mf = /* @__PURE__ */ new WeakMap();
504
+ _signalInstances = /* @__PURE__ */ new WeakMap();
505
+ _onLogMessage2 = /* @__PURE__ */ new WeakMap();
506
+ function getEnrichmentVectorKey(category, value) {
507
+ return `${category}${ENR_SEPARATOR}${value}`;
508
+ }
509
+ function isNumberMatch(lhs, match) {
510
+ var _a;
511
+ if (typeof lhs === "undefined" || lhs === null) {
512
+ return false;
513
+ }
514
+ const lhsValue = Number(lhs);
515
+ if (isNaN(lhsValue)) {
516
+ return false;
517
+ }
518
+ switch ((_a = match == null ? void 0 : match.op) != null ? _a : "=") {
519
+ case "=":
520
+ return lhsValue === match.rhs;
521
+ case "!=":
522
+ return lhsValue !== match.rhs;
523
+ case ">":
524
+ return lhsValue > match.rhs;
525
+ case "<":
526
+ return lhsValue < match.rhs;
527
+ default:
528
+ console.warn(`Unknown match type ${match.op} is false.`);
529
+ return false;
530
+ }
531
+ }
532
+ function explainNumberMatch(lhs, match) {
533
+ return `${lhs} ${explainNumberMatchCriteria(match)}`;
534
+ }
535
+ function explainNumberMatchCriteria(match) {
536
+ return `${match.op} ${match.rhs}`;
537
+ }
538
+ var pageViewCountDimension = getEnrichmentVectorKey("$pvc", "v");
539
+ var pageViewCountEvaluator = ({ update, criteria, commands, onLogMessage }) => {
540
+ var _a, _b;
541
+ if (criteria.type !== "PVC") {
542
+ return { result: false, changed: false };
543
+ }
544
+ const hasUrlChanged = Boolean(
545
+ update.state.url && (!update.previousState || ((_a = update.state.url) == null ? void 0 : _a.toString()) !== ((_b = update.previousState.url) == null ? void 0 : _b.toString()))
546
+ );
547
+ const existingValueNumber = update.visitor.sessionScores[pageViewCountDimension] || 0;
548
+ const updatedCount = existingValueNumber + 1;
549
+ const finalResult = { result: false, changed: hasUrlChanged };
550
+ const hasExistingPageViewIncrementCommand = commands.some(
551
+ (c) => c.type === "modscoreS" && c.data.dimension === pageViewCountDimension
552
+ );
553
+ if (hasUrlChanged && !hasExistingPageViewIncrementCommand) {
554
+ commands.push({
555
+ type: "modscoreS",
556
+ data: {
557
+ dimension: pageViewCountDimension,
558
+ delta: 1
559
+ }
560
+ });
561
+ }
562
+ if (isNumberMatch(updatedCount, criteria.match)) {
563
+ finalResult.result = true;
564
+ }
565
+ onLogMessage == null ? void 0 : onLogMessage([
566
+ "debug",
567
+ 203,
568
+ { criteria, result: finalResult, explanation: explainNumberMatch(updatedCount, criteria.match) }
569
+ ]);
570
+ return finalResult;
571
+ };
572
+ pageViewCountEvaluator.alwaysExecute = true;
573
+ var _evaluators;
574
+ _evaluators = /* @__PURE__ */ new WeakMap();
575
+ var _data;
576
+ var _initialData;
577
+ var _mitt;
578
+ _data = /* @__PURE__ */ new WeakMap();
579
+ _initialData = /* @__PURE__ */ new WeakMap();
580
+ _mitt = /* @__PURE__ */ new WeakMap();
581
+ var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
582
+ var b2s = alphabet.split("");
583
+ var s2b = new Array(123);
584
+ for (let i = 0; i < alphabet.length; i++) {
585
+ s2b[alphabet.charCodeAt(i)] = i;
586
+ }
587
+ var _cookieName;
588
+ var _cookieAttributes;
589
+ _cookieName = /* @__PURE__ */ new WeakMap();
590
+ _cookieAttributes = /* @__PURE__ */ new WeakMap();
591
+ var _fetchData;
592
+ var fetchData_fn;
593
+ _fetchData = /* @__PURE__ */ new WeakSet();
594
+ fetchData_fn = async function() {
595
+ const serviceData = await new Promise((resolve) => {
596
+ setTimeout(() => {
597
+ resolve(void 0);
598
+ }, 2e3);
599
+ });
600
+ if (serviceData) {
601
+ this.signalAsyncDataUpdate(serviceData);
602
+ }
603
+ };
604
+ var emptyVisitorData = () => ({
605
+ quirks: {},
606
+ scores: {},
607
+ sessionScores: {},
608
+ tests: {},
609
+ consent: false,
610
+ controlGroup: false
611
+ });
612
+ var clone = (0, import_rfdc.default)();
613
+ var STORAGE_KEY = "ufvisitor";
614
+ var _mitt2;
615
+ var _persist;
616
+ var _visitTimeout;
617
+ var _options;
618
+ var _currentData;
619
+ var currentData_get;
620
+ var _replaceData;
621
+ var replaceData_fn;
622
+ var _setVisitTimeout;
623
+ var setVisitTimeout_fn;
624
+ var _isExpired;
625
+ var isExpired_fn;
626
+ var _handleCaps;
627
+ var handleCaps_fn;
628
+ var _defaultData;
629
+ var defaultData_fn;
630
+ _mitt2 = /* @__PURE__ */ new WeakMap();
631
+ _persist = /* @__PURE__ */ new WeakMap();
632
+ _visitTimeout = /* @__PURE__ */ new WeakMap();
633
+ _options = /* @__PURE__ */ new WeakMap();
634
+ _currentData = /* @__PURE__ */ new WeakSet();
635
+ currentData_get = function() {
636
+ return __privateGet(this, _persist).get(STORAGE_KEY);
637
+ };
638
+ _replaceData = /* @__PURE__ */ new WeakSet();
639
+ replaceData_fn = function(data, quiet = false) {
640
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
641
+ const oldData = __privateGet(this, _currentData, currentData_get);
642
+ const now = Date.now();
643
+ if (data.controlGroup) {
644
+ data.scores = {};
645
+ data.sessionScores = {};
646
+ } else {
647
+ __privateMethod(this, _handleCaps, handleCaps_fn).call(this, data.scores);
648
+ __privateMethod(this, _handleCaps, handleCaps_fn).call(this, data.sessionScores);
649
+ (_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
650
+ now,
651
+ lastUpd: oldData == null ? void 0 : oldData.updated,
652
+ scores: data.scores,
653
+ sessionScores: data.sessionScores,
654
+ onLogMessage: __privateGet(this, _options).onLogMessage
655
+ });
656
+ }
657
+ const haveScoresChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.scores, data.scores);
658
+ const haveSessionScoresChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.sessionScores, data.sessionScores);
659
+ const haveQuirksChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.quirks, data.quirks);
660
+ const haveTestsChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.tests, data.tests);
661
+ const updatedData = {
662
+ updated: now,
663
+ visitorData: data
664
+ };
665
+ __privateMethod(this, _setVisitTimeout, setVisitTimeout_fn).call(this);
666
+ __privateGet(this, _persist).set(STORAGE_KEY, updatedData, !!data.consent);
667
+ (_d = (_c = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _d.call(_c, ["debug", 102, data]);
668
+ if (!quiet) {
669
+ if (haveScoresChanged || haveSessionScoresChanged) {
670
+ __privateGet(this, _mitt2).emit("scoresUpdated", data);
671
+ }
672
+ if (haveQuirksChanged) {
673
+ __privateGet(this, _mitt2).emit("quirksUpdated", data);
674
+ }
675
+ if (haveTestsChanged) {
676
+ __privateGet(this, _mitt2).emit("testsUpdated", data);
677
+ }
678
+ if (((_e = oldData == null ? void 0 : oldData.visitorData) == null ? void 0 : _e.consent) !== data.consent) {
679
+ __privateGet(this, _mitt2).emit("consentUpdated", data);
680
+ }
681
+ if (((_f = oldData == null ? void 0 : oldData.visitorData) == null ? void 0 : _f.controlGroup) !== data.controlGroup) {
682
+ __privateGet(this, _mitt2).emit("controlGroupUpdated", data);
683
+ (_i = (_h = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _i.call(_h, ["debug", 104, (_g = data.controlGroup) != null ? _g : false]);
684
+ }
685
+ }
686
+ };
687
+ _setVisitTimeout = /* @__PURE__ */ new WeakSet();
688
+ setVisitTimeout_fn = function() {
689
+ if (typeof document === "undefined" || !__privateGet(this, _options).visitLifespan) {
690
+ return;
691
+ }
692
+ if (__privateGet(this, _visitTimeout)) {
693
+ window.clearTimeout(__privateGet(this, _visitTimeout));
694
+ }
695
+ __privateSet(this, _visitTimeout, window.setTimeout(() => {
696
+ this.data;
697
+ }, __privateGet(this, _options).visitLifespan + 50));
698
+ };
699
+ _isExpired = /* @__PURE__ */ new WeakSet();
700
+ isExpired_fn = function(data) {
701
+ const expires = __privateGet(this, _options).visitLifespan;
702
+ return expires ? data.updated + expires < Date.now() : false;
703
+ };
704
+ _handleCaps = /* @__PURE__ */ new WeakSet();
705
+ handleCaps_fn = function(scores) {
706
+ var _a, _b;
707
+ if (!__privateGet(this, _options).manifest) {
708
+ return;
709
+ }
710
+ for (const dim in scores) {
711
+ const score = scores[dim];
712
+ const dimDef = __privateGet(this, _options).manifest.getDimensionByKey(dim);
713
+ if (!dimDef) {
714
+ continue;
715
+ }
716
+ if (score > dimDef.cap) {
717
+ (_b = (_a = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _b.call(_a, ["debug", 110, { dim, score, cap: dimDef.cap }]);
718
+ scores[dim] = dimDef.cap;
719
+ }
720
+ }
721
+ };
722
+ _defaultData = /* @__PURE__ */ new WeakSet();
723
+ defaultData_fn = function() {
724
+ var _a, _b, _c;
725
+ return {
726
+ ...emptyVisitorData(),
727
+ consent: (_a = __privateGet(this, _options).defaultConsent) != null ? _a : false,
728
+ controlGroup: (_c = (_b = __privateGet(this, _options).manifest) == null ? void 0 : _b.rollForControlGroup()) != null ? _c : false
729
+ };
730
+ };
731
+ var _serverTransitionState;
732
+ var _scores;
733
+ var _state;
734
+ var _pzCache;
735
+ var _mitt3;
736
+ var _emitTest;
737
+ var emitTest_fn;
738
+ var _updateComputedScores;
739
+ var updateComputedScores_fn;
740
+ var _calculateScores;
741
+ var calculateScores_fn;
742
+ _serverTransitionState = /* @__PURE__ */ new WeakMap();
743
+ _scores = /* @__PURE__ */ new WeakMap();
744
+ _state = /* @__PURE__ */ new WeakMap();
745
+ _pzCache = /* @__PURE__ */ new WeakMap();
746
+ _mitt3 = /* @__PURE__ */ new WeakMap();
747
+ _emitTest = /* @__PURE__ */ new WeakSet();
748
+ emitTest_fn = function(event) {
749
+ __privateGet(this, _mitt3).emit("testResult", event);
750
+ };
751
+ _updateComputedScores = /* @__PURE__ */ new WeakSet();
752
+ updateComputedScores_fn = function(newData) {
753
+ const newScores = __privateMethod(this, _calculateScores, calculateScores_fn).call(this, newData);
754
+ const newScoresHaveChanged = !dequal(newScores, __privateGet(this, _scores));
755
+ if (newScoresHaveChanged) {
756
+ __privateSet(this, _scores, newScores);
757
+ __privateGet(this, _mitt3).emit("scoresUpdated", newScores);
758
+ __privateGet(this, _mitt3).emit("log", ["info", 3, newScores]);
759
+ }
760
+ };
761
+ _calculateScores = /* @__PURE__ */ new WeakSet();
762
+ calculateScores_fn = function(newData) {
763
+ var _a;
764
+ let newScores = { ...newData.scores };
765
+ for (const session in newData.sessionScores) {
766
+ newScores[session] = ((_a = newScores[session]) != null ? _a : 0) + newData.sessionScores[session];
767
+ }
768
+ newScores = this.manifest.computeAggregateDimensions(newScores);
769
+ return newScores;
770
+ };
771
+ var isBrowser = typeof top !== "undefined";
772
+ function enableContextDevTools(options) {
773
+ return {
774
+ logDrain: (message) => {
775
+ if (!isBrowser) {
776
+ return;
777
+ }
778
+ top == null ? void 0 : top.postMessage(
779
+ {
780
+ type: "uniform:context:log",
781
+ message
782
+ },
783
+ window.location.origin
784
+ );
785
+ },
786
+ init: (context) => {
787
+ const personalizations = [];
788
+ const tests = [];
789
+ const onContextDataUpdated = () => {
790
+ if (!isBrowser) {
791
+ return;
792
+ }
793
+ top == null ? void 0 : top.postMessage(
794
+ {
795
+ type: "uniform:context:data",
796
+ data: {
797
+ scores: context.scores,
798
+ data: context.storage.data,
799
+ manifest: context.manifest.data,
800
+ personalizations,
801
+ tests
802
+ }
803
+ },
804
+ window.location.origin
805
+ );
806
+ };
807
+ const onPersonalizationResult = (e) => {
808
+ if (!e.changed)
809
+ return;
810
+ personalizations.push(e);
811
+ };
812
+ const onTestResult = (e) => {
813
+ if (!e.variantAssigned)
814
+ return;
815
+ tests.push(e);
816
+ };
817
+ if (isBrowser) {
818
+ window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__ = context;
819
+ try {
820
+ top == null ? void 0 : top.addEventListener("message", async (event) => {
821
+ if (!event.data) {
822
+ return;
823
+ }
824
+ const message = event.data;
825
+ await handleMessageFromDevTools({
826
+ message,
827
+ context,
828
+ afterMessageReceived: options == null ? void 0 : options.onAfterMessageReceived
829
+ });
830
+ });
831
+ } catch (e) {
832
+ console.warn(
833
+ "Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",
834
+ e
835
+ );
836
+ }
837
+ top == null ? void 0 : top.postMessage(
838
+ {
839
+ type: "uniform:context:hello",
840
+ uiVersion: 2
841
+ },
842
+ window.location.origin
843
+ );
844
+ onContextDataUpdated();
845
+ }
846
+ context.events.on("personalizationResult", onPersonalizationResult);
847
+ context.events.on("testResult", onTestResult);
848
+ context.events.on("scoresUpdated", onContextDataUpdated);
849
+ context.storage.events.on("*", onContextDataUpdated);
850
+ return () => {
851
+ context.events.off("scoresUpdated", onContextDataUpdated);
852
+ context.storage.events.off("*", onContextDataUpdated);
853
+ context.events.off("personalizationResult", onPersonalizationResult);
854
+ context.events.off("testResult", onTestResult);
855
+ };
856
+ }
857
+ };
858
+ }
859
+ async function handleMessageFromDevTools({
860
+ message,
861
+ context,
862
+ afterMessageReceived
863
+ }) {
864
+ let receivedUniformMessage = false;
865
+ if (message.type === "uniform-in:context:update" && message.newData) {
866
+ receivedUniformMessage = true;
867
+ await context.update(message.newData);
868
+ }
869
+ if (message.type === "uniform-in:context:commands" && message.commands && Array.isArray(message.commands)) {
870
+ receivedUniformMessage = true;
871
+ await context.storage.updateData(message.commands);
872
+ }
873
+ if (message.type === "uniform-in:context:forget") {
874
+ receivedUniformMessage = true;
875
+ await context.forget(false);
876
+ }
877
+ if (receivedUniformMessage && typeof afterMessageReceived === "function") {
878
+ afterMessageReceived(message);
879
+ }
880
+ }
881
+ var dc = (0, import_rfdc2.default)();
882
+ var dc2 = (0, import_rfdc3.default)();
883
+
884
+ // src/components/DefaultUniformClientContext.tsx
885
+ var import_navigation3 = require("next/navigation");
886
+
123
887
  // src/context/createClientUniformContext.ts
124
888
  var import_canvas_next_rsc_shared = require("@uniformdev/canvas-next-rsc-shared");
125
889
  var createClientUniformContext = (options) => {
@@ -145,10 +909,22 @@ var useInitUniformContext = (callback) => {
145
909
  };
146
910
 
147
911
  // src/components/DefaultUniformClientContext.tsx
148
- var DefaultUniformClientContext = ({ manifest }) => {
912
+ var DefaultUniformClientContext = ({ manifest, disableDevTools }) => {
913
+ const router = (0, import_navigation3.useRouter)();
149
914
  useInitUniformContext(() => {
915
+ const plugins = [];
916
+ if (!disableDevTools) {
917
+ plugins.push(
918
+ enableContextDevTools({
919
+ onAfterMessageReceived: () => {
920
+ router.refresh();
921
+ }
922
+ })
923
+ );
924
+ }
150
925
  return createClientUniformContext({
151
- manifest
926
+ manifest,
927
+ plugins
152
928
  });
153
929
  });
154
930
  return null;
@@ -200,12 +976,12 @@ var TestClient = (props) => {
200
976
 
201
977
  // src/components/UniformScriptClient.tsx
202
978
  var import_canvas4 = require("@uniformdev/canvas");
203
- var import_navigation3 = require("next/navigation");
979
+ var import_navigation4 = require("next/navigation");
204
980
  var import_react8 = require("react");
205
981
  var import_jsx_runtime3 = require("react/jsx-runtime");
206
982
  var UniformScript = () => {
207
- const router = (0, import_navigation3.useRouter)();
208
- const params = (0, import_navigation3.useSearchParams)();
983
+ const router = (0, import_navigation4.useRouter)();
984
+ const params = (0, import_navigation4.useSearchParams)();
209
985
  const needsToRefreshRef = (0, import_react8.useRef)(false);
210
986
  const enabled = params.get(import_canvas4.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM) === "true";
211
987
  const channel = (0, import_react8.useMemo)(() => {
@@ -284,3 +1060,8 @@ var UniformScript = () => {
284
1060
  useInitUniformContext,
285
1061
  useUniformContext
286
1062
  });
1063
+ /*! Bundled license information:
1064
+
1065
+ js-cookie/dist/js.cookie.mjs:
1066
+ (*! js-cookie v3.0.5 | MIT *)
1067
+ */