@cedarai/session-replay-sdk 0.1.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.
@@ -0,0 +1,4076 @@
1
+ "use strict";
2
+ (() => {
3
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
5
+ }) : x)(function(x) {
6
+ if (typeof require !== "undefined") return require.apply(this, arguments);
7
+ throw Error('Dynamic require of "' + x + '" is not supported');
8
+ });
9
+
10
+ // src/transport.ts
11
+ var Transport = class {
12
+ config;
13
+ queue = [];
14
+ timer = null;
15
+ started = false;
16
+ startedAt = Date.now();
17
+ fetchFn;
18
+ /**
19
+ * @param config SDK configuration
20
+ * @param originalFetch Original fetch reference to avoid self-interception.
21
+ * If not provided, uses globalThis.fetch.
22
+ */
23
+ constructor(config2, originalFetch) {
24
+ this.config = config2;
25
+ const fn = originalFetch ?? globalThis.fetch;
26
+ this.fetchFn = fn.bind(globalThis);
27
+ }
28
+ start() {
29
+ if (this.started) return;
30
+ this.started = true;
31
+ this.startedAt = Date.now();
32
+ const interval = this.config.batchIntervalMs ?? 5e3;
33
+ this.timer = setInterval(() => {
34
+ this.flush();
35
+ }, interval);
36
+ }
37
+ stop() {
38
+ if (!this.started) return;
39
+ this.started = false;
40
+ if (this.timer !== null) {
41
+ clearInterval(this.timer);
42
+ this.timer = null;
43
+ }
44
+ this.flush();
45
+ }
46
+ enqueue(event) {
47
+ if (!this.started) return;
48
+ this.queue.push(event);
49
+ const maxSize = this.config.batchMaxSize ?? 1024 * 512;
50
+ const estimatedSize = this.estimateQueueSize();
51
+ if (estimatedSize >= maxSize) {
52
+ this.flush();
53
+ }
54
+ }
55
+ flush() {
56
+ if (this.queue.length === 0) return;
57
+ const events = this.queue.splice(0);
58
+ const payload = this.buildPayload(events);
59
+ this.fetchFn(`${this.config.serverUrl}/api/ingest`, {
60
+ method: "POST",
61
+ headers: { "Content-Type": "application/json" },
62
+ body: JSON.stringify(payload)
63
+ }).catch(() => {
64
+ });
65
+ }
66
+ /**
67
+ * Flush via sendBeacon for page unload. sendBeacon cannot set custom headers,
68
+ * so we send as a Blob and indicate gzip via query param.
69
+ */
70
+ flushOnUnload() {
71
+ if (this.queue.length === 0) return;
72
+ const events = this.queue.splice(0);
73
+ const payload = this.buildPayload(events);
74
+ const body = JSON.stringify(payload);
75
+ const blob = new Blob([body], { type: "application/json" });
76
+ const url = `${this.config.serverUrl}/api/ingest?encoding=gzip`;
77
+ navigator.sendBeacon(url, blob);
78
+ }
79
+ buildPayload(events) {
80
+ return {
81
+ sessionId: this.config.cedarSessionId,
82
+ batchTimestamp: Date.now(),
83
+ startedAt: this.startedAt,
84
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "",
85
+ viewportWidth: typeof window !== "undefined" ? window.innerWidth : 0,
86
+ viewportHeight: typeof window !== "undefined" ? window.innerHeight : 0,
87
+ url: typeof window !== "undefined" ? window.location.href : "",
88
+ events
89
+ };
90
+ }
91
+ estimateQueueSize() {
92
+ let size = 0;
93
+ for (const event of this.queue) {
94
+ size += JSON.stringify(event).length;
95
+ }
96
+ return size;
97
+ }
98
+ };
99
+
100
+ // src/console.ts
101
+ var LEVELS = ["log", "warn", "error", "info", "debug"];
102
+ var ConsoleCapture = class {
103
+ onEvent;
104
+ config;
105
+ originals = {};
106
+ started = false;
107
+ constructor(onEvent2, config2) {
108
+ this.onEvent = onEvent2;
109
+ this.config = config2 ?? {};
110
+ }
111
+ start() {
112
+ if (this.started) return;
113
+ this.started = true;
114
+ for (const level of LEVELS) {
115
+ if (this.config[level] === false) continue;
116
+ const original = console[level];
117
+ this.originals[level] = original;
118
+ console[level] = (...args) => {
119
+ original.apply(console, args);
120
+ this.onEvent({
121
+ type: "console",
122
+ timestamp: Date.now(),
123
+ data: {
124
+ level,
125
+ args: args.map((a) => typeof a === "string" ? a : JSON.stringify(a))
126
+ }
127
+ });
128
+ };
129
+ }
130
+ }
131
+ stop() {
132
+ if (!this.started) return;
133
+ this.started = false;
134
+ for (const level of LEVELS) {
135
+ const orig = this.originals[level];
136
+ if (orig) {
137
+ console[level] = orig;
138
+ }
139
+ }
140
+ this.originals = {};
141
+ }
142
+ };
143
+
144
+ // src/errors.ts
145
+ var ErrorCapture = class {
146
+ onEvent;
147
+ started = false;
148
+ prevOnError = null;
149
+ rejectionHandler = null;
150
+ constructor(onEvent2) {
151
+ this.onEvent = onEvent2;
152
+ }
153
+ start() {
154
+ if (this.started) return;
155
+ this.started = true;
156
+ this.prevOnError = globalThis.onerror;
157
+ globalThis.onerror = (message, source, lineno, colno, error) => {
158
+ this.onEvent({
159
+ type: "error",
160
+ timestamp: Date.now(),
161
+ data: {
162
+ message: error?.message ?? String(message),
163
+ stack: error?.stack,
164
+ source: source || void 0,
165
+ lineno,
166
+ colno,
167
+ type: "uncaught"
168
+ }
169
+ });
170
+ };
171
+ this.rejectionHandler = (event) => {
172
+ const reason = event.reason;
173
+ const message = reason instanceof Error ? reason.message : String(reason);
174
+ const stack = reason instanceof Error ? reason.stack : void 0;
175
+ this.onEvent({
176
+ type: "error",
177
+ timestamp: Date.now(),
178
+ data: {
179
+ message,
180
+ stack,
181
+ type: "unhandledrejection"
182
+ }
183
+ });
184
+ };
185
+ globalThis.addEventListener(
186
+ "unhandledrejection",
187
+ this.rejectionHandler
188
+ );
189
+ }
190
+ stop() {
191
+ if (!this.started) return;
192
+ this.started = false;
193
+ globalThis.onerror = this.prevOnError;
194
+ this.prevOnError = null;
195
+ if (this.rejectionHandler) {
196
+ globalThis.removeEventListener(
197
+ "unhandledrejection",
198
+ this.rejectionHandler
199
+ );
200
+ this.rejectionHandler = null;
201
+ }
202
+ }
203
+ captureException(error, options) {
204
+ if (!this.started) return;
205
+ this.onEvent({
206
+ type: "error",
207
+ timestamp: Date.now(),
208
+ data: {
209
+ message: error.message,
210
+ stack: error.stack,
211
+ type: "manual",
212
+ tags: options?.tags,
213
+ extra: options?.extra
214
+ }
215
+ });
216
+ }
217
+ };
218
+
219
+ // src/network.ts
220
+ var nextId = 0;
221
+ var NetworkCapture = class {
222
+ onEvent;
223
+ serverUrl;
224
+ originalFetch = null;
225
+ started = false;
226
+ constructor(onEvent2, serverUrl) {
227
+ this.onEvent = onEvent2;
228
+ this.serverUrl = serverUrl;
229
+ }
230
+ start() {
231
+ if (this.started) return;
232
+ this.started = true;
233
+ this.originalFetch = globalThis.fetch;
234
+ globalThis.fetch = async (input, init) => {
235
+ const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
236
+ if (url.startsWith(this.serverUrl)) {
237
+ return this.originalFetch(input, init);
238
+ }
239
+ const method = init?.method?.toUpperCase() ?? "GET";
240
+ const requestBody = init?.body ? String(init.body) : void 0;
241
+ const startTime = performance.now();
242
+ const id = String(++nextId);
243
+ let graphqlOperationName;
244
+ if (requestBody) {
245
+ try {
246
+ const parsed = JSON.parse(requestBody);
247
+ if (parsed.operationName) {
248
+ graphqlOperationName = parsed.operationName;
249
+ }
250
+ } catch {
251
+ }
252
+ }
253
+ try {
254
+ const response = await this.originalFetch(input, init);
255
+ const endTime = performance.now();
256
+ let responseBody;
257
+ try {
258
+ const cloned = response.clone();
259
+ responseBody = await cloned.text();
260
+ } catch {
261
+ }
262
+ this.onEvent({
263
+ type: "network",
264
+ timestamp: Date.now(),
265
+ data: {
266
+ id,
267
+ method,
268
+ url,
269
+ graphqlOperationName,
270
+ requestBody,
271
+ status: response.status,
272
+ responseBody,
273
+ startTime,
274
+ endTime,
275
+ duration: endTime - startTime
276
+ }
277
+ });
278
+ return response;
279
+ } catch (err) {
280
+ const endTime = performance.now();
281
+ this.onEvent({
282
+ type: "network",
283
+ timestamp: Date.now(),
284
+ data: {
285
+ id,
286
+ method,
287
+ url,
288
+ graphqlOperationName,
289
+ requestBody,
290
+ startTime,
291
+ endTime,
292
+ duration: endTime - startTime,
293
+ error: err instanceof Error ? err.message : String(err)
294
+ }
295
+ });
296
+ throw err;
297
+ }
298
+ };
299
+ }
300
+ stop() {
301
+ if (!this.started) return;
302
+ this.started = false;
303
+ if (this.originalFetch) {
304
+ globalThis.fetch = this.originalFetch;
305
+ this.originalFetch = null;
306
+ }
307
+ }
308
+ };
309
+
310
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
311
+ var NodeType;
312
+ (function(NodeType2) {
313
+ NodeType2[NodeType2["Document"] = 0] = "Document";
314
+ NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
315
+ NodeType2[NodeType2["Element"] = 2] = "Element";
316
+ NodeType2[NodeType2["Text"] = 3] = "Text";
317
+ NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
318
+ NodeType2[NodeType2["Comment"] = 5] = "Comment";
319
+ })(NodeType || (NodeType = {}));
320
+ function isElement(n) {
321
+ return n.nodeType === n.ELEMENT_NODE;
322
+ }
323
+ function isShadowRoot(n) {
324
+ var host = n === null || n === void 0 ? void 0 : n.host;
325
+ return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n);
326
+ }
327
+ function isNativeShadowDom(shadowRoot) {
328
+ return Object.prototype.toString.call(shadowRoot) === "[object ShadowRoot]";
329
+ }
330
+ function fixBrowserCompatibilityIssuesInCSS(cssText) {
331
+ if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
332
+ cssText = cssText.replace(" background-clip: text;", " -webkit-background-clip: text; background-clip: text;");
333
+ }
334
+ return cssText;
335
+ }
336
+ function getCssRulesString(s) {
337
+ try {
338
+ var rules = s.rules || s.cssRules;
339
+ return rules ? fixBrowserCompatibilityIssuesInCSS(Array.from(rules).map(getCssRuleString).join("")) : null;
340
+ } catch (error) {
341
+ return null;
342
+ }
343
+ }
344
+ function getCssRuleString(rule) {
345
+ var cssStringified = rule.cssText;
346
+ if (isCSSImportRule(rule)) {
347
+ try {
348
+ cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
349
+ } catch (_a) {
350
+ }
351
+ }
352
+ return cssStringified;
353
+ }
354
+ function isCSSImportRule(rule) {
355
+ return "styleSheet" in rule;
356
+ }
357
+ var Mirror = (function() {
358
+ function Mirror2() {
359
+ this.idNodeMap = /* @__PURE__ */ new Map();
360
+ this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
361
+ }
362
+ Mirror2.prototype.getId = function(n) {
363
+ var _a;
364
+ if (!n)
365
+ return -1;
366
+ var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
367
+ return id !== null && id !== void 0 ? id : -1;
368
+ };
369
+ Mirror2.prototype.getNode = function(id) {
370
+ return this.idNodeMap.get(id) || null;
371
+ };
372
+ Mirror2.prototype.getIds = function() {
373
+ return Array.from(this.idNodeMap.keys());
374
+ };
375
+ Mirror2.prototype.getMeta = function(n) {
376
+ return this.nodeMetaMap.get(n) || null;
377
+ };
378
+ Mirror2.prototype.removeNodeFromMap = function(n) {
379
+ var _this = this;
380
+ var id = this.getId(n);
381
+ this.idNodeMap["delete"](id);
382
+ if (n.childNodes) {
383
+ n.childNodes.forEach(function(childNode) {
384
+ return _this.removeNodeFromMap(childNode);
385
+ });
386
+ }
387
+ };
388
+ Mirror2.prototype.has = function(id) {
389
+ return this.idNodeMap.has(id);
390
+ };
391
+ Mirror2.prototype.hasNode = function(node) {
392
+ return this.nodeMetaMap.has(node);
393
+ };
394
+ Mirror2.prototype.add = function(n, meta) {
395
+ var id = meta.id;
396
+ this.idNodeMap.set(id, n);
397
+ this.nodeMetaMap.set(n, meta);
398
+ };
399
+ Mirror2.prototype.replace = function(id, n) {
400
+ var oldNode = this.getNode(id);
401
+ if (oldNode) {
402
+ var meta = this.nodeMetaMap.get(oldNode);
403
+ if (meta)
404
+ this.nodeMetaMap.set(n, meta);
405
+ }
406
+ this.idNodeMap.set(id, n);
407
+ };
408
+ Mirror2.prototype.reset = function() {
409
+ this.idNodeMap = /* @__PURE__ */ new Map();
410
+ this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
411
+ };
412
+ return Mirror2;
413
+ })();
414
+ function createMirror() {
415
+ return new Mirror();
416
+ }
417
+ function maskInputValue(_a) {
418
+ var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;
419
+ var text = value || "";
420
+ if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
421
+ if (maskInputFn) {
422
+ text = maskInputFn(text);
423
+ } else {
424
+ text = "*".repeat(text.length);
425
+ }
426
+ }
427
+ return text;
428
+ }
429
+ var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
430
+ function is2DCanvasBlank(canvas) {
431
+ var ctx = canvas.getContext("2d");
432
+ if (!ctx)
433
+ return true;
434
+ var chunkSize = 50;
435
+ for (var x = 0; x < canvas.width; x += chunkSize) {
436
+ for (var y = 0; y < canvas.height; y += chunkSize) {
437
+ var getImageData = ctx.getImageData;
438
+ var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
439
+ var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
440
+ if (pixelBuffer.some(function(pixel) {
441
+ return pixel !== 0;
442
+ }))
443
+ return false;
444
+ }
445
+ }
446
+ return true;
447
+ }
448
+ var _id = 1;
449
+ var tagNameRegex = new RegExp("[^a-z0-9-_:]");
450
+ var IGNORED_NODE = -2;
451
+ function genId() {
452
+ return _id++;
453
+ }
454
+ function getValidTagName(element) {
455
+ if (element instanceof HTMLFormElement) {
456
+ return "form";
457
+ }
458
+ var processedTagName = element.tagName.toLowerCase().trim();
459
+ if (tagNameRegex.test(processedTagName)) {
460
+ return "div";
461
+ }
462
+ return processedTagName;
463
+ }
464
+ function stringifyStyleSheet(sheet) {
465
+ return sheet.cssRules ? Array.from(sheet.cssRules).map(function(rule) {
466
+ return rule.cssText || "";
467
+ }).join("") : "";
468
+ }
469
+ function extractOrigin(url) {
470
+ var origin = "";
471
+ if (url.indexOf("//") > -1) {
472
+ origin = url.split("/").slice(0, 3).join("/");
473
+ } else {
474
+ origin = url.split("/")[0];
475
+ }
476
+ origin = origin.split("?")[0];
477
+ return origin;
478
+ }
479
+ var canvasService;
480
+ var canvasCtx;
481
+ var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
482
+ var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/;
483
+ var DATA_URI = /^(data:)([^,]*),(.*)/i;
484
+ function absoluteToStylesheet(cssText, href) {
485
+ return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
486
+ var filePath = path1 || path2 || path3;
487
+ var maybeQuote = quote1 || quote2 || "";
488
+ if (!filePath) {
489
+ return origin;
490
+ }
491
+ if (!RELATIVE_PATH.test(filePath)) {
492
+ return "url(".concat(maybeQuote).concat(filePath).concat(maybeQuote, ")");
493
+ }
494
+ if (DATA_URI.test(filePath)) {
495
+ return "url(".concat(maybeQuote).concat(filePath).concat(maybeQuote, ")");
496
+ }
497
+ if (filePath[0] === "/") {
498
+ return "url(".concat(maybeQuote).concat(extractOrigin(href) + filePath).concat(maybeQuote, ")");
499
+ }
500
+ var stack = href.split("/");
501
+ var parts = filePath.split("/");
502
+ stack.pop();
503
+ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
504
+ var part = parts_1[_i];
505
+ if (part === ".") {
506
+ continue;
507
+ } else if (part === "..") {
508
+ stack.pop();
509
+ } else {
510
+ stack.push(part);
511
+ }
512
+ }
513
+ return "url(".concat(maybeQuote).concat(stack.join("/")).concat(maybeQuote, ")");
514
+ });
515
+ }
516
+ var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
517
+ var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
518
+ function getAbsoluteSrcsetString(doc, attributeValue) {
519
+ if (attributeValue.trim() === "") {
520
+ return attributeValue;
521
+ }
522
+ var pos = 0;
523
+ function collectCharacters(regEx) {
524
+ var chars2;
525
+ var match = regEx.exec(attributeValue.substring(pos));
526
+ if (match) {
527
+ chars2 = match[0];
528
+ pos += chars2.length;
529
+ return chars2;
530
+ }
531
+ return "";
532
+ }
533
+ var output = [];
534
+ while (true) {
535
+ collectCharacters(SRCSET_COMMAS_OR_SPACES);
536
+ if (pos >= attributeValue.length) {
537
+ break;
538
+ }
539
+ var url = collectCharacters(SRCSET_NOT_SPACES);
540
+ if (url.slice(-1) === ",") {
541
+ url = absoluteToDoc(doc, url.substring(0, url.length - 1));
542
+ output.push(url);
543
+ } else {
544
+ var descriptorsStr = "";
545
+ url = absoluteToDoc(doc, url);
546
+ var inParens = false;
547
+ while (true) {
548
+ var c = attributeValue.charAt(pos);
549
+ if (c === "") {
550
+ output.push((url + descriptorsStr).trim());
551
+ break;
552
+ } else if (!inParens) {
553
+ if (c === ",") {
554
+ pos += 1;
555
+ output.push((url + descriptorsStr).trim());
556
+ break;
557
+ } else if (c === "(") {
558
+ inParens = true;
559
+ }
560
+ } else {
561
+ if (c === ")") {
562
+ inParens = false;
563
+ }
564
+ }
565
+ descriptorsStr += c;
566
+ pos += 1;
567
+ }
568
+ }
569
+ }
570
+ return output.join(", ");
571
+ }
572
+ function absoluteToDoc(doc, attributeValue) {
573
+ if (!attributeValue || attributeValue.trim() === "") {
574
+ return attributeValue;
575
+ }
576
+ var a = doc.createElement("a");
577
+ a.href = attributeValue;
578
+ return a.href;
579
+ }
580
+ function isSVGElement(el) {
581
+ return Boolean(el.tagName === "svg" || el.ownerSVGElement);
582
+ }
583
+ function getHref() {
584
+ var a = document.createElement("a");
585
+ a.href = "";
586
+ return a.href;
587
+ }
588
+ function transformAttribute(doc, tagName, name, value) {
589
+ if (name === "src" || name === "href" && value && !(tagName === "use" && value[0] === "#")) {
590
+ return absoluteToDoc(doc, value);
591
+ } else if (name === "xlink:href" && value && value[0] !== "#") {
592
+ return absoluteToDoc(doc, value);
593
+ } else if (name === "background" && value && (tagName === "table" || tagName === "td" || tagName === "th")) {
594
+ return absoluteToDoc(doc, value);
595
+ } else if (name === "srcset" && value) {
596
+ return getAbsoluteSrcsetString(doc, value);
597
+ } else if (name === "style" && value) {
598
+ return absoluteToStylesheet(value, getHref());
599
+ } else if (tagName === "object" && name === "data" && value) {
600
+ return absoluteToDoc(doc, value);
601
+ } else {
602
+ return value;
603
+ }
604
+ }
605
+ function _isBlockedElement(element, blockClass, blockSelector) {
606
+ if (typeof blockClass === "string") {
607
+ if (element.classList.contains(blockClass)) {
608
+ return true;
609
+ }
610
+ } else {
611
+ for (var eIndex = element.classList.length; eIndex--; ) {
612
+ var className = element.classList[eIndex];
613
+ if (blockClass.test(className)) {
614
+ return true;
615
+ }
616
+ }
617
+ }
618
+ if (blockSelector) {
619
+ return element.matches(blockSelector);
620
+ }
621
+ return false;
622
+ }
623
+ function classMatchesRegex(node, regex, checkAncestors) {
624
+ if (!node)
625
+ return false;
626
+ if (node.nodeType !== node.ELEMENT_NODE) {
627
+ if (!checkAncestors)
628
+ return false;
629
+ return classMatchesRegex(node.parentNode, regex, checkAncestors);
630
+ }
631
+ for (var eIndex = node.classList.length; eIndex--; ) {
632
+ var className = node.classList[eIndex];
633
+ if (regex.test(className)) {
634
+ return true;
635
+ }
636
+ }
637
+ if (!checkAncestors)
638
+ return false;
639
+ return classMatchesRegex(node.parentNode, regex, checkAncestors);
640
+ }
641
+ function needMaskingText(node, maskTextClass, maskTextSelector) {
642
+ var el = node.nodeType === node.ELEMENT_NODE ? node : node.parentElement;
643
+ if (el === null)
644
+ return false;
645
+ if (typeof maskTextClass === "string") {
646
+ if (el.classList.contains(maskTextClass))
647
+ return true;
648
+ if (el.closest(".".concat(maskTextClass)))
649
+ return true;
650
+ } else {
651
+ if (classMatchesRegex(el, maskTextClass, true))
652
+ return true;
653
+ }
654
+ if (maskTextSelector) {
655
+ if (el.matches(maskTextSelector))
656
+ return true;
657
+ if (el.closest(maskTextSelector))
658
+ return true;
659
+ }
660
+ return false;
661
+ }
662
+ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
663
+ var win = iframeEl.contentWindow;
664
+ if (!win) {
665
+ return;
666
+ }
667
+ var fired = false;
668
+ var readyState;
669
+ try {
670
+ readyState = win.document.readyState;
671
+ } catch (error) {
672
+ return;
673
+ }
674
+ if (readyState !== "complete") {
675
+ var timer_1 = setTimeout(function() {
676
+ if (!fired) {
677
+ listener();
678
+ fired = true;
679
+ }
680
+ }, iframeLoadTimeout);
681
+ iframeEl.addEventListener("load", function() {
682
+ clearTimeout(timer_1);
683
+ fired = true;
684
+ listener();
685
+ });
686
+ return;
687
+ }
688
+ var blankUrl = "about:blank";
689
+ if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
690
+ setTimeout(listener, 0);
691
+ return iframeEl.addEventListener("load", listener);
692
+ }
693
+ iframeEl.addEventListener("load", listener);
694
+ }
695
+ function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
696
+ var fired = false;
697
+ var styleSheetLoaded;
698
+ try {
699
+ styleSheetLoaded = link.sheet;
700
+ } catch (error) {
701
+ return;
702
+ }
703
+ if (styleSheetLoaded)
704
+ return;
705
+ var timer = setTimeout(function() {
706
+ if (!fired) {
707
+ listener();
708
+ fired = true;
709
+ }
710
+ }, styleSheetLoadTimeout);
711
+ link.addEventListener("load", function() {
712
+ clearTimeout(timer);
713
+ fired = true;
714
+ listener();
715
+ });
716
+ }
717
+ function serializeNode(n, options) {
718
+ var doc = options.doc, mirror2 = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _a = options.maskInputOptions, maskInputOptions = _a === void 0 ? {} : _a, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _b = options.dataURLOptions, dataURLOptions = _b === void 0 ? {} : _b, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, _c = options.newlyAddedElement, newlyAddedElement = _c === void 0 ? false : _c;
719
+ var rootId = getRootId(doc, mirror2);
720
+ switch (n.nodeType) {
721
+ case n.DOCUMENT_NODE:
722
+ if (n.compatMode !== "CSS1Compat") {
723
+ return {
724
+ type: NodeType.Document,
725
+ childNodes: [],
726
+ compatMode: n.compatMode
727
+ };
728
+ } else {
729
+ return {
730
+ type: NodeType.Document,
731
+ childNodes: []
732
+ };
733
+ }
734
+ case n.DOCUMENT_TYPE_NODE:
735
+ return {
736
+ type: NodeType.DocumentType,
737
+ name: n.name,
738
+ publicId: n.publicId,
739
+ systemId: n.systemId,
740
+ rootId
741
+ };
742
+ case n.ELEMENT_NODE:
743
+ return serializeElementNode(n, {
744
+ doc,
745
+ blockClass,
746
+ blockSelector,
747
+ inlineStylesheet,
748
+ maskInputOptions,
749
+ maskInputFn,
750
+ dataURLOptions,
751
+ inlineImages,
752
+ recordCanvas,
753
+ keepIframeSrcFn,
754
+ newlyAddedElement,
755
+ rootId
756
+ });
757
+ case n.TEXT_NODE:
758
+ return serializeTextNode(n, {
759
+ maskTextClass,
760
+ maskTextSelector,
761
+ maskTextFn,
762
+ rootId
763
+ });
764
+ case n.CDATA_SECTION_NODE:
765
+ return {
766
+ type: NodeType.CDATA,
767
+ textContent: "",
768
+ rootId
769
+ };
770
+ case n.COMMENT_NODE:
771
+ return {
772
+ type: NodeType.Comment,
773
+ textContent: n.textContent || "",
774
+ rootId
775
+ };
776
+ default:
777
+ return false;
778
+ }
779
+ }
780
+ function getRootId(doc, mirror2) {
781
+ if (!mirror2.hasNode(doc))
782
+ return void 0;
783
+ var docId = mirror2.getId(doc);
784
+ return docId === 1 ? void 0 : docId;
785
+ }
786
+ function serializeTextNode(n, options) {
787
+ var _a;
788
+ var maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, maskTextFn = options.maskTextFn, rootId = options.rootId;
789
+ var parentTagName = n.parentNode && n.parentNode.tagName;
790
+ var textContent = n.textContent;
791
+ var isStyle = parentTagName === "STYLE" ? true : void 0;
792
+ var isScript = parentTagName === "SCRIPT" ? true : void 0;
793
+ if (isStyle && textContent) {
794
+ try {
795
+ if (n.nextSibling || n.previousSibling) {
796
+ } else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
797
+ textContent = stringifyStyleSheet(n.parentNode.sheet);
798
+ }
799
+ } catch (err) {
800
+ console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(err), n);
801
+ }
802
+ textContent = absoluteToStylesheet(textContent, getHref());
803
+ }
804
+ if (isScript) {
805
+ textContent = "SCRIPT_PLACEHOLDER";
806
+ }
807
+ if (!isStyle && !isScript && textContent && needMaskingText(n, maskTextClass, maskTextSelector)) {
808
+ textContent = maskTextFn ? maskTextFn(textContent) : textContent.replace(/[\S]/g, "*");
809
+ }
810
+ return {
811
+ type: NodeType.Text,
812
+ textContent: textContent || "",
813
+ isStyle,
814
+ rootId
815
+ };
816
+ }
817
+ function serializeElementNode(n, options) {
818
+ var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, inlineStylesheet = options.inlineStylesheet, _a = options.maskInputOptions, maskInputOptions = _a === void 0 ? {} : _a, maskInputFn = options.maskInputFn, _b = options.dataURLOptions, dataURLOptions = _b === void 0 ? {} : _b, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, _c = options.newlyAddedElement, newlyAddedElement = _c === void 0 ? false : _c, rootId = options.rootId;
819
+ var needBlock = _isBlockedElement(n, blockClass, blockSelector);
820
+ var tagName = getValidTagName(n);
821
+ var attributes = {};
822
+ var len = n.attributes.length;
823
+ for (var i = 0; i < len; i++) {
824
+ var attr = n.attributes[i];
825
+ attributes[attr.name] = transformAttribute(doc, tagName, attr.name, attr.value);
826
+ }
827
+ if (tagName === "link" && inlineStylesheet) {
828
+ var stylesheet = Array.from(doc.styleSheets).find(function(s) {
829
+ return s.href === n.href;
830
+ });
831
+ var cssText = null;
832
+ if (stylesheet) {
833
+ cssText = getCssRulesString(stylesheet);
834
+ }
835
+ if (cssText) {
836
+ delete attributes.rel;
837
+ delete attributes.href;
838
+ attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
839
+ }
840
+ }
841
+ if (tagName === "style" && n.sheet && !(n.innerText || n.textContent || "").trim().length) {
842
+ var cssText = getCssRulesString(n.sheet);
843
+ if (cssText) {
844
+ attributes._cssText = absoluteToStylesheet(cssText, getHref());
845
+ }
846
+ }
847
+ if (tagName === "input" || tagName === "textarea" || tagName === "select") {
848
+ var value = n.value;
849
+ var checked = n.checked;
850
+ if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
851
+ attributes.value = maskInputValue({
852
+ type: attributes.type,
853
+ tagName,
854
+ value,
855
+ maskInputOptions,
856
+ maskInputFn
857
+ });
858
+ } else if (checked) {
859
+ attributes.checked = checked;
860
+ }
861
+ }
862
+ if (tagName === "option") {
863
+ if (n.selected && !maskInputOptions["select"]) {
864
+ attributes.selected = true;
865
+ } else {
866
+ delete attributes.selected;
867
+ }
868
+ }
869
+ if (tagName === "canvas" && recordCanvas) {
870
+ if (n.__context === "2d") {
871
+ if (!is2DCanvasBlank(n)) {
872
+ attributes.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
873
+ }
874
+ } else if (!("__context" in n)) {
875
+ var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
876
+ var blankCanvas = document.createElement("canvas");
877
+ blankCanvas.width = n.width;
878
+ blankCanvas.height = n.height;
879
+ var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
880
+ if (canvasDataURL !== blankCanvasDataURL) {
881
+ attributes.rr_dataURL = canvasDataURL;
882
+ }
883
+ }
884
+ }
885
+ if (tagName === "img" && inlineImages) {
886
+ if (!canvasService) {
887
+ canvasService = doc.createElement("canvas");
888
+ canvasCtx = canvasService.getContext("2d");
889
+ }
890
+ var image_1 = n;
891
+ var oldValue_1 = image_1.crossOrigin;
892
+ image_1.crossOrigin = "anonymous";
893
+ var recordInlineImage = function() {
894
+ try {
895
+ canvasService.width = image_1.naturalWidth;
896
+ canvasService.height = image_1.naturalHeight;
897
+ canvasCtx.drawImage(image_1, 0, 0);
898
+ attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
899
+ } catch (err) {
900
+ console.warn("Cannot inline img src=".concat(image_1.currentSrc, "! Error: ").concat(err));
901
+ }
902
+ oldValue_1 ? attributes.crossOrigin = oldValue_1 : image_1.removeAttribute("crossorigin");
903
+ };
904
+ if (image_1.complete && image_1.naturalWidth !== 0)
905
+ recordInlineImage();
906
+ else
907
+ image_1.onload = recordInlineImage;
908
+ }
909
+ if (tagName === "audio" || tagName === "video") {
910
+ attributes.rr_mediaState = n.paused ? "paused" : "played";
911
+ attributes.rr_mediaCurrentTime = n.currentTime;
912
+ }
913
+ if (!newlyAddedElement) {
914
+ if (n.scrollLeft) {
915
+ attributes.rr_scrollLeft = n.scrollLeft;
916
+ }
917
+ if (n.scrollTop) {
918
+ attributes.rr_scrollTop = n.scrollTop;
919
+ }
920
+ }
921
+ if (needBlock) {
922
+ var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height;
923
+ attributes = {
924
+ "class": attributes["class"],
925
+ rr_width: "".concat(width, "px"),
926
+ rr_height: "".concat(height, "px")
927
+ };
928
+ }
929
+ if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
930
+ if (!n.contentDocument) {
931
+ attributes.rr_src = attributes.src;
932
+ }
933
+ delete attributes.src;
934
+ }
935
+ return {
936
+ type: NodeType.Element,
937
+ tagName,
938
+ attributes,
939
+ childNodes: [],
940
+ isSVG: isSVGElement(n) || void 0,
941
+ needBlock,
942
+ rootId
943
+ };
944
+ }
945
+ function lowerIfExists(maybeAttr) {
946
+ if (maybeAttr === void 0) {
947
+ return "";
948
+ } else {
949
+ return maybeAttr.toLowerCase();
950
+ }
951
+ }
952
+ function slimDOMExcluded(sn, slimDOMOptions) {
953
+ if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
954
+ return true;
955
+ } else if (sn.type === NodeType.Element) {
956
+ if (slimDOMOptions.script && (sn.tagName === "script" || sn.tagName === "link" && sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && sn.attributes.href.endsWith(".js"))) {
957
+ return true;
958
+ } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
959
+ return true;
960
+ } else if (sn.tagName === "meta") {
961
+ if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
962
+ return true;
963
+ } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
964
+ return true;
965
+ } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
966
+ return true;
967
+ } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
968
+ return true;
969
+ } else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
970
+ return true;
971
+ } else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) {
972
+ return true;
973
+ }
974
+ }
975
+ }
976
+ return false;
977
+ }
978
+ function serializeNodeWithId(n, options) {
979
+ var doc = options.doc, mirror2 = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5e3 : _g, onStylesheetLoad = options.onStylesheetLoad, _h = options.stylesheetLoadTimeout, stylesheetLoadTimeout = _h === void 0 ? 5e3 : _h, _j = options.keepIframeSrcFn, keepIframeSrcFn = _j === void 0 ? function() {
980
+ return false;
981
+ } : _j, _k = options.newlyAddedElement, newlyAddedElement = _k === void 0 ? false : _k;
982
+ var _l = options.preserveWhiteSpace, preserveWhiteSpace = _l === void 0 ? true : _l;
983
+ var _serializedNode = serializeNode(n, {
984
+ doc,
985
+ mirror: mirror2,
986
+ blockClass,
987
+ blockSelector,
988
+ maskTextClass,
989
+ maskTextSelector,
990
+ inlineStylesheet,
991
+ maskInputOptions,
992
+ maskTextFn,
993
+ maskInputFn,
994
+ dataURLOptions,
995
+ inlineImages,
996
+ recordCanvas,
997
+ keepIframeSrcFn,
998
+ newlyAddedElement
999
+ });
1000
+ if (!_serializedNode) {
1001
+ console.warn(n, "not serialized");
1002
+ return null;
1003
+ }
1004
+ var id;
1005
+ if (mirror2.hasNode(n)) {
1006
+ id = mirror2.getId(n);
1007
+ } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1008
+ id = IGNORED_NODE;
1009
+ } else {
1010
+ id = genId();
1011
+ }
1012
+ var serializedNode = Object.assign(_serializedNode, { id });
1013
+ mirror2.add(n, serializedNode);
1014
+ if (id === IGNORED_NODE) {
1015
+ return null;
1016
+ }
1017
+ if (onSerialize) {
1018
+ onSerialize(n);
1019
+ }
1020
+ var recordChild = !skipChild;
1021
+ if (serializedNode.type === NodeType.Element) {
1022
+ recordChild = recordChild && !serializedNode.needBlock;
1023
+ delete serializedNode.needBlock;
1024
+ var shadowRoot = n.shadowRoot;
1025
+ if (shadowRoot && isNativeShadowDom(shadowRoot))
1026
+ serializedNode.isShadowHost = true;
1027
+ }
1028
+ if ((serializedNode.type === NodeType.Document || serializedNode.type === NodeType.Element) && recordChild) {
1029
+ if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType.Element && serializedNode.tagName === "head") {
1030
+ preserveWhiteSpace = false;
1031
+ }
1032
+ var bypassOptions = {
1033
+ doc,
1034
+ mirror: mirror2,
1035
+ blockClass,
1036
+ blockSelector,
1037
+ maskTextClass,
1038
+ maskTextSelector,
1039
+ skipChild,
1040
+ inlineStylesheet,
1041
+ maskInputOptions,
1042
+ maskTextFn,
1043
+ maskInputFn,
1044
+ slimDOMOptions,
1045
+ dataURLOptions,
1046
+ inlineImages,
1047
+ recordCanvas,
1048
+ preserveWhiteSpace,
1049
+ onSerialize,
1050
+ onIframeLoad,
1051
+ iframeLoadTimeout,
1052
+ onStylesheetLoad,
1053
+ stylesheetLoadTimeout,
1054
+ keepIframeSrcFn
1055
+ };
1056
+ for (var _i = 0, _m = Array.from(n.childNodes); _i < _m.length; _i++) {
1057
+ var childN = _m[_i];
1058
+ var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1059
+ if (serializedChildNode) {
1060
+ serializedNode.childNodes.push(serializedChildNode);
1061
+ }
1062
+ }
1063
+ if (isElement(n) && n.shadowRoot) {
1064
+ for (var _o = 0, _p = Array.from(n.shadowRoot.childNodes); _o < _p.length; _o++) {
1065
+ var childN = _p[_o];
1066
+ var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1067
+ if (serializedChildNode) {
1068
+ isNativeShadowDom(n.shadowRoot) && (serializedChildNode.isShadow = true);
1069
+ serializedNode.childNodes.push(serializedChildNode);
1070
+ }
1071
+ }
1072
+ }
1073
+ }
1074
+ if (n.parentNode && isShadowRoot(n.parentNode) && isNativeShadowDom(n.parentNode)) {
1075
+ serializedNode.isShadow = true;
1076
+ }
1077
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "iframe") {
1078
+ onceIframeLoaded(n, function() {
1079
+ var iframeDoc = n.contentDocument;
1080
+ if (iframeDoc && onIframeLoad) {
1081
+ var serializedIframeNode = serializeNodeWithId(iframeDoc, {
1082
+ doc: iframeDoc,
1083
+ mirror: mirror2,
1084
+ blockClass,
1085
+ blockSelector,
1086
+ maskTextClass,
1087
+ maskTextSelector,
1088
+ skipChild: false,
1089
+ inlineStylesheet,
1090
+ maskInputOptions,
1091
+ maskTextFn,
1092
+ maskInputFn,
1093
+ slimDOMOptions,
1094
+ dataURLOptions,
1095
+ inlineImages,
1096
+ recordCanvas,
1097
+ preserveWhiteSpace,
1098
+ onSerialize,
1099
+ onIframeLoad,
1100
+ iframeLoadTimeout,
1101
+ onStylesheetLoad,
1102
+ stylesheetLoadTimeout,
1103
+ keepIframeSrcFn
1104
+ });
1105
+ if (serializedIframeNode) {
1106
+ onIframeLoad(n, serializedIframeNode);
1107
+ }
1108
+ }
1109
+ }, iframeLoadTimeout);
1110
+ }
1111
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "link" && serializedNode.attributes.rel === "stylesheet") {
1112
+ onceStylesheetLoaded(n, function() {
1113
+ if (onStylesheetLoad) {
1114
+ var serializedLinkNode = serializeNodeWithId(n, {
1115
+ doc,
1116
+ mirror: mirror2,
1117
+ blockClass,
1118
+ blockSelector,
1119
+ maskTextClass,
1120
+ maskTextSelector,
1121
+ skipChild: false,
1122
+ inlineStylesheet,
1123
+ maskInputOptions,
1124
+ maskTextFn,
1125
+ maskInputFn,
1126
+ slimDOMOptions,
1127
+ dataURLOptions,
1128
+ inlineImages,
1129
+ recordCanvas,
1130
+ preserveWhiteSpace,
1131
+ onSerialize,
1132
+ onIframeLoad,
1133
+ iframeLoadTimeout,
1134
+ onStylesheetLoad,
1135
+ stylesheetLoadTimeout,
1136
+ keepIframeSrcFn
1137
+ });
1138
+ if (serializedLinkNode) {
1139
+ onStylesheetLoad(n, serializedLinkNode);
1140
+ }
1141
+ }
1142
+ }, stylesheetLoadTimeout);
1143
+ }
1144
+ return serializedNode;
1145
+ }
1146
+ function snapshot(n, options) {
1147
+ var _a = options || {}, _b = _a.mirror, mirror2 = _b === void 0 ? new Mirror() : _b, _c = _a.blockClass, blockClass = _c === void 0 ? "rr-block" : _c, _d = _a.blockSelector, blockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? "rr-mask" : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.inlineStylesheet, inlineStylesheet = _g === void 0 ? true : _g, _h = _a.inlineImages, inlineImages = _h === void 0 ? false : _h, _j = _a.recordCanvas, recordCanvas = _j === void 0 ? false : _j, _k = _a.maskAllInputs, maskAllInputs = _k === void 0 ? false : _k, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _l = _a.slimDOM, slimDOM = _l === void 0 ? false : _l, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, onStylesheetLoad = _a.onStylesheetLoad, stylesheetLoadTimeout = _a.stylesheetLoadTimeout, _m = _a.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function() {
1148
+ return false;
1149
+ } : _m;
1150
+ var maskInputOptions = maskAllInputs === true ? {
1151
+ color: true,
1152
+ date: true,
1153
+ "datetime-local": true,
1154
+ email: true,
1155
+ month: true,
1156
+ number: true,
1157
+ range: true,
1158
+ search: true,
1159
+ tel: true,
1160
+ text: true,
1161
+ time: true,
1162
+ url: true,
1163
+ week: true,
1164
+ textarea: true,
1165
+ select: true,
1166
+ password: true
1167
+ } : maskAllInputs === false ? {
1168
+ password: true
1169
+ } : maskAllInputs;
1170
+ var slimDOMOptions = slimDOM === true || slimDOM === "all" ? {
1171
+ script: true,
1172
+ comment: true,
1173
+ headFavicon: true,
1174
+ headWhitespace: true,
1175
+ headMetaDescKeywords: slimDOM === "all",
1176
+ headMetaSocial: true,
1177
+ headMetaRobots: true,
1178
+ headMetaHttpEquiv: true,
1179
+ headMetaAuthorship: true,
1180
+ headMetaVerification: true
1181
+ } : slimDOM === false ? {} : slimDOM;
1182
+ return serializeNodeWithId(n, {
1183
+ doc: n,
1184
+ mirror: mirror2,
1185
+ blockClass,
1186
+ blockSelector,
1187
+ maskTextClass,
1188
+ maskTextSelector,
1189
+ skipChild: false,
1190
+ inlineStylesheet,
1191
+ maskInputOptions,
1192
+ maskTextFn,
1193
+ maskInputFn,
1194
+ slimDOMOptions,
1195
+ dataURLOptions,
1196
+ inlineImages,
1197
+ recordCanvas,
1198
+ preserveWhiteSpace,
1199
+ onSerialize,
1200
+ onIframeLoad,
1201
+ iframeLoadTimeout,
1202
+ onStylesheetLoad,
1203
+ stylesheetLoadTimeout,
1204
+ keepIframeSrcFn,
1205
+ newlyAddedElement: false
1206
+ });
1207
+ }
1208
+ var HOVER_SELECTOR = /([^\\]):hover/;
1209
+ var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, "g");
1210
+
1211
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/utils.js
1212
+ function on(type, fn, target = document) {
1213
+ const options = { capture: true, passive: true };
1214
+ target.addEventListener(type, fn, options);
1215
+ return () => target.removeEventListener(type, fn, options);
1216
+ }
1217
+ var DEPARTED_MIRROR_ACCESS_WARNING = "Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";
1218
+ var _mirror = {
1219
+ map: {},
1220
+ getId() {
1221
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1222
+ return -1;
1223
+ },
1224
+ getNode() {
1225
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1226
+ return null;
1227
+ },
1228
+ removeNodeFromMap() {
1229
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1230
+ },
1231
+ has() {
1232
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1233
+ return false;
1234
+ },
1235
+ reset() {
1236
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1237
+ }
1238
+ };
1239
+ if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
1240
+ _mirror = new Proxy(_mirror, {
1241
+ get(target, prop, receiver) {
1242
+ if (prop === "map") {
1243
+ console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1244
+ }
1245
+ return Reflect.get(target, prop, receiver);
1246
+ }
1247
+ });
1248
+ }
1249
+ function throttle(func, wait, options = {}) {
1250
+ let timeout = null;
1251
+ let previous = 0;
1252
+ return function(...args) {
1253
+ const now = Date.now();
1254
+ if (!previous && options.leading === false) {
1255
+ previous = now;
1256
+ }
1257
+ const remaining = wait - (now - previous);
1258
+ const context = this;
1259
+ if (remaining <= 0 || remaining > wait) {
1260
+ if (timeout) {
1261
+ clearTimeout(timeout);
1262
+ timeout = null;
1263
+ }
1264
+ previous = now;
1265
+ func.apply(context, args);
1266
+ } else if (!timeout && options.trailing !== false) {
1267
+ timeout = setTimeout(() => {
1268
+ previous = options.leading === false ? 0 : Date.now();
1269
+ timeout = null;
1270
+ func.apply(context, args);
1271
+ }, remaining);
1272
+ }
1273
+ };
1274
+ }
1275
+ function hookSetter(target, key, d, isRevoked, win = window) {
1276
+ const original = win.Object.getOwnPropertyDescriptor(target, key);
1277
+ win.Object.defineProperty(target, key, isRevoked ? d : {
1278
+ set(value) {
1279
+ setTimeout(() => {
1280
+ d.set.call(this, value);
1281
+ }, 0);
1282
+ if (original && original.set) {
1283
+ original.set.call(this, value);
1284
+ }
1285
+ }
1286
+ });
1287
+ return () => hookSetter(target, key, original || {}, true);
1288
+ }
1289
+ function patch(source, name, replacement) {
1290
+ try {
1291
+ if (!(name in source)) {
1292
+ return () => {
1293
+ };
1294
+ }
1295
+ const original = source[name];
1296
+ const wrapped = replacement(original);
1297
+ if (typeof wrapped === "function") {
1298
+ wrapped.prototype = wrapped.prototype || {};
1299
+ Object.defineProperties(wrapped, {
1300
+ __rrweb_original__: {
1301
+ enumerable: false,
1302
+ value: original
1303
+ }
1304
+ });
1305
+ }
1306
+ source[name] = wrapped;
1307
+ return () => {
1308
+ source[name] = original;
1309
+ };
1310
+ } catch (_a) {
1311
+ return () => {
1312
+ };
1313
+ }
1314
+ }
1315
+ function getWindowHeight() {
1316
+ return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
1317
+ }
1318
+ function getWindowWidth() {
1319
+ return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
1320
+ }
1321
+ function isBlocked(node, blockClass, blockSelector, checkAncestors) {
1322
+ if (!node) {
1323
+ return false;
1324
+ }
1325
+ const el = node.nodeType === node.ELEMENT_NODE ? node : node.parentElement;
1326
+ if (!el)
1327
+ return false;
1328
+ if (typeof blockClass === "string") {
1329
+ if (el.classList.contains(blockClass))
1330
+ return true;
1331
+ if (checkAncestors && el.closest("." + blockClass) !== null)
1332
+ return true;
1333
+ } else {
1334
+ if (classMatchesRegex(el, blockClass, checkAncestors))
1335
+ return true;
1336
+ }
1337
+ if (blockSelector) {
1338
+ if (node.matches(blockSelector))
1339
+ return true;
1340
+ if (checkAncestors && el.closest(blockSelector) !== null)
1341
+ return true;
1342
+ }
1343
+ return false;
1344
+ }
1345
+ function isSerialized(n, mirror2) {
1346
+ return mirror2.getId(n) !== -1;
1347
+ }
1348
+ function isIgnored(n, mirror2) {
1349
+ return mirror2.getId(n) === IGNORED_NODE;
1350
+ }
1351
+ function isAncestorRemoved(target, mirror2) {
1352
+ if (isShadowRoot(target)) {
1353
+ return false;
1354
+ }
1355
+ const id = mirror2.getId(target);
1356
+ if (!mirror2.has(id)) {
1357
+ return true;
1358
+ }
1359
+ if (target.parentNode && target.parentNode.nodeType === target.DOCUMENT_NODE) {
1360
+ return false;
1361
+ }
1362
+ if (!target.parentNode) {
1363
+ return true;
1364
+ }
1365
+ return isAncestorRemoved(target.parentNode, mirror2);
1366
+ }
1367
+ function isTouchEvent(event) {
1368
+ return Boolean(event.changedTouches);
1369
+ }
1370
+ function polyfill(win = window) {
1371
+ if ("NodeList" in win && !win.NodeList.prototype.forEach) {
1372
+ win.NodeList.prototype.forEach = Array.prototype.forEach;
1373
+ }
1374
+ if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
1375
+ win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
1376
+ }
1377
+ if (!Node.prototype.contains) {
1378
+ Node.prototype.contains = (...args) => {
1379
+ let node = args[0];
1380
+ if (!(0 in args)) {
1381
+ throw new TypeError("1 argument is required");
1382
+ }
1383
+ do {
1384
+ if (this === node) {
1385
+ return true;
1386
+ }
1387
+ } while (node = node && node.parentNode);
1388
+ return false;
1389
+ };
1390
+ }
1391
+ }
1392
+ function isSerializedIframe(n, mirror2) {
1393
+ return Boolean(n.nodeName === "IFRAME" && mirror2.getMeta(n));
1394
+ }
1395
+ function isSerializedStylesheet(n, mirror2) {
1396
+ return Boolean(n.nodeName === "LINK" && n.nodeType === n.ELEMENT_NODE && n.getAttribute && n.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n));
1397
+ }
1398
+ function hasShadowRoot(n) {
1399
+ return Boolean(n === null || n === void 0 ? void 0 : n.shadowRoot);
1400
+ }
1401
+ var StyleSheetMirror = class {
1402
+ constructor() {
1403
+ this.id = 1;
1404
+ this.styleIDMap = /* @__PURE__ */ new WeakMap();
1405
+ this.idStyleMap = /* @__PURE__ */ new Map();
1406
+ }
1407
+ getId(stylesheet) {
1408
+ var _a;
1409
+ return (_a = this.styleIDMap.get(stylesheet)) !== null && _a !== void 0 ? _a : -1;
1410
+ }
1411
+ has(stylesheet) {
1412
+ return this.styleIDMap.has(stylesheet);
1413
+ }
1414
+ add(stylesheet, id) {
1415
+ if (this.has(stylesheet))
1416
+ return this.getId(stylesheet);
1417
+ let newId;
1418
+ if (id === void 0) {
1419
+ newId = this.id++;
1420
+ } else
1421
+ newId = id;
1422
+ this.styleIDMap.set(stylesheet, newId);
1423
+ this.idStyleMap.set(newId, stylesheet);
1424
+ return newId;
1425
+ }
1426
+ getStyle(id) {
1427
+ return this.idStyleMap.get(id) || null;
1428
+ }
1429
+ reset() {
1430
+ this.styleIDMap = /* @__PURE__ */ new WeakMap();
1431
+ this.idStyleMap = /* @__PURE__ */ new Map();
1432
+ this.id = 1;
1433
+ }
1434
+ generateId() {
1435
+ return this.id++;
1436
+ }
1437
+ };
1438
+
1439
+ // ../../node_modules/rrweb/es/rrweb/packages/types/dist/types.js
1440
+ var EventType = /* @__PURE__ */ ((EventType2) => {
1441
+ EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
1442
+ EventType2[EventType2["Load"] = 1] = "Load";
1443
+ EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
1444
+ EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
1445
+ EventType2[EventType2["Meta"] = 4] = "Meta";
1446
+ EventType2[EventType2["Custom"] = 5] = "Custom";
1447
+ EventType2[EventType2["Plugin"] = 6] = "Plugin";
1448
+ return EventType2;
1449
+ })(EventType || {});
1450
+ var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
1451
+ IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
1452
+ IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
1453
+ IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
1454
+ IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
1455
+ IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
1456
+ IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
1457
+ IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
1458
+ IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
1459
+ IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
1460
+ IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
1461
+ IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
1462
+ IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
1463
+ IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
1464
+ IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
1465
+ IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
1466
+ IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
1467
+ return IncrementalSource2;
1468
+ })(IncrementalSource || {});
1469
+ var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
1470
+ MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
1471
+ MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
1472
+ MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
1473
+ MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
1474
+ MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
1475
+ MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
1476
+ MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
1477
+ MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
1478
+ MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
1479
+ MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
1480
+ MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
1481
+ return MouseInteractions2;
1482
+ })(MouseInteractions || {});
1483
+ var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {
1484
+ CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
1485
+ CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
1486
+ CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
1487
+ return CanvasContext2;
1488
+ })(CanvasContext || {});
1489
+
1490
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js
1491
+ function isNodeInLinkedList(n) {
1492
+ return "__ln" in n;
1493
+ }
1494
+ var DoubleLinkedList = class {
1495
+ constructor() {
1496
+ this.length = 0;
1497
+ this.head = null;
1498
+ }
1499
+ get(position) {
1500
+ if (position >= this.length) {
1501
+ throw new Error("Position outside of list range");
1502
+ }
1503
+ let current = this.head;
1504
+ for (let index = 0; index < position; index++) {
1505
+ current = (current === null || current === void 0 ? void 0 : current.next) || null;
1506
+ }
1507
+ return current;
1508
+ }
1509
+ addNode(n) {
1510
+ const node = {
1511
+ value: n,
1512
+ previous: null,
1513
+ next: null
1514
+ };
1515
+ n.__ln = node;
1516
+ if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {
1517
+ const current = n.previousSibling.__ln.next;
1518
+ node.next = current;
1519
+ node.previous = n.previousSibling.__ln;
1520
+ n.previousSibling.__ln.next = node;
1521
+ if (current) {
1522
+ current.previous = node;
1523
+ }
1524
+ } else if (n.nextSibling && isNodeInLinkedList(n.nextSibling) && n.nextSibling.__ln.previous) {
1525
+ const current = n.nextSibling.__ln.previous;
1526
+ node.previous = current;
1527
+ node.next = n.nextSibling.__ln;
1528
+ n.nextSibling.__ln.previous = node;
1529
+ if (current) {
1530
+ current.next = node;
1531
+ }
1532
+ } else {
1533
+ if (this.head) {
1534
+ this.head.previous = node;
1535
+ }
1536
+ node.next = this.head;
1537
+ this.head = node;
1538
+ }
1539
+ this.length++;
1540
+ }
1541
+ removeNode(n) {
1542
+ const current = n.__ln;
1543
+ if (!this.head) {
1544
+ return;
1545
+ }
1546
+ if (!current.previous) {
1547
+ this.head = current.next;
1548
+ if (this.head) {
1549
+ this.head.previous = null;
1550
+ }
1551
+ } else {
1552
+ current.previous.next = current.next;
1553
+ if (current.next) {
1554
+ current.next.previous = current.previous;
1555
+ }
1556
+ }
1557
+ if (n.__ln) {
1558
+ delete n.__ln;
1559
+ }
1560
+ this.length--;
1561
+ }
1562
+ };
1563
+ var moveKey = (id, parentId) => `${id}@${parentId}`;
1564
+ var MutationBuffer = class {
1565
+ constructor() {
1566
+ this.frozen = false;
1567
+ this.locked = false;
1568
+ this.texts = [];
1569
+ this.attributes = [];
1570
+ this.removes = [];
1571
+ this.mapRemoves = [];
1572
+ this.movedMap = {};
1573
+ this.addedSet = /* @__PURE__ */ new Set();
1574
+ this.movedSet = /* @__PURE__ */ new Set();
1575
+ this.droppedSet = /* @__PURE__ */ new Set();
1576
+ this.processMutations = (mutations) => {
1577
+ mutations.forEach(this.processMutation);
1578
+ this.emit();
1579
+ };
1580
+ this.emit = () => {
1581
+ if (this.frozen || this.locked) {
1582
+ return;
1583
+ }
1584
+ const adds = [];
1585
+ const addList = new DoubleLinkedList();
1586
+ const getNextId = (n) => {
1587
+ let ns = n;
1588
+ let nextId2 = IGNORED_NODE;
1589
+ while (nextId2 === IGNORED_NODE) {
1590
+ ns = ns && ns.nextSibling;
1591
+ nextId2 = ns && this.mirror.getId(ns);
1592
+ }
1593
+ return nextId2;
1594
+ };
1595
+ const pushAdd = (n) => {
1596
+ var _a, _b, _c, _d;
1597
+ let shadowHost = null;
1598
+ if (((_b = (_a = n.getRootNode) === null || _a === void 0 ? void 0 : _a.call(n)) === null || _b === void 0 ? void 0 : _b.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && n.getRootNode().host)
1599
+ shadowHost = n.getRootNode().host;
1600
+ let rootShadowHost = shadowHost;
1601
+ while (((_d = (_c = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _c === void 0 ? void 0 : _c.call(rootShadowHost)) === null || _d === void 0 ? void 0 : _d.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && rootShadowHost.getRootNode().host)
1602
+ rootShadowHost = rootShadowHost.getRootNode().host;
1603
+ const notInDoc = !this.doc.contains(n) && (!rootShadowHost || !this.doc.contains(rootShadowHost));
1604
+ if (!n.parentNode || notInDoc) {
1605
+ return;
1606
+ }
1607
+ const parentId = isShadowRoot(n.parentNode) ? this.mirror.getId(shadowHost) : this.mirror.getId(n.parentNode);
1608
+ const nextId2 = getNextId(n);
1609
+ if (parentId === -1 || nextId2 === -1) {
1610
+ return addList.addNode(n);
1611
+ }
1612
+ const sn = serializeNodeWithId(n, {
1613
+ doc: this.doc,
1614
+ mirror: this.mirror,
1615
+ blockClass: this.blockClass,
1616
+ blockSelector: this.blockSelector,
1617
+ maskTextClass: this.maskTextClass,
1618
+ maskTextSelector: this.maskTextSelector,
1619
+ skipChild: true,
1620
+ newlyAddedElement: true,
1621
+ inlineStylesheet: this.inlineStylesheet,
1622
+ maskInputOptions: this.maskInputOptions,
1623
+ maskTextFn: this.maskTextFn,
1624
+ maskInputFn: this.maskInputFn,
1625
+ slimDOMOptions: this.slimDOMOptions,
1626
+ dataURLOptions: this.dataURLOptions,
1627
+ recordCanvas: this.recordCanvas,
1628
+ inlineImages: this.inlineImages,
1629
+ onSerialize: (currentN) => {
1630
+ if (isSerializedIframe(currentN, this.mirror)) {
1631
+ this.iframeManager.addIframe(currentN);
1632
+ }
1633
+ if (isSerializedStylesheet(currentN, this.mirror)) {
1634
+ this.stylesheetManager.trackLinkElement(currentN);
1635
+ }
1636
+ if (hasShadowRoot(n)) {
1637
+ this.shadowDomManager.addShadowRoot(n.shadowRoot, this.doc);
1638
+ }
1639
+ },
1640
+ onIframeLoad: (iframe, childSn) => {
1641
+ this.iframeManager.attachIframe(iframe, childSn);
1642
+ this.shadowDomManager.observeAttachShadow(iframe);
1643
+ },
1644
+ onStylesheetLoad: (link, childSn) => {
1645
+ this.stylesheetManager.attachLinkElement(link, childSn);
1646
+ }
1647
+ });
1648
+ if (sn) {
1649
+ adds.push({
1650
+ parentId,
1651
+ nextId: nextId2,
1652
+ node: sn
1653
+ });
1654
+ }
1655
+ };
1656
+ while (this.mapRemoves.length) {
1657
+ this.mirror.removeNodeFromMap(this.mapRemoves.shift());
1658
+ }
1659
+ for (const n of Array.from(this.movedSet.values())) {
1660
+ if (isParentRemoved(this.removes, n, this.mirror) && !this.movedSet.has(n.parentNode)) {
1661
+ continue;
1662
+ }
1663
+ pushAdd(n);
1664
+ }
1665
+ for (const n of Array.from(this.addedSet.values())) {
1666
+ if (!isAncestorInSet(this.droppedSet, n) && !isParentRemoved(this.removes, n, this.mirror)) {
1667
+ pushAdd(n);
1668
+ } else if (isAncestorInSet(this.movedSet, n)) {
1669
+ pushAdd(n);
1670
+ } else {
1671
+ this.droppedSet.add(n);
1672
+ }
1673
+ }
1674
+ let candidate = null;
1675
+ while (addList.length) {
1676
+ let node = null;
1677
+ if (candidate) {
1678
+ const parentId = this.mirror.getId(candidate.value.parentNode);
1679
+ const nextId2 = getNextId(candidate.value);
1680
+ if (parentId !== -1 && nextId2 !== -1) {
1681
+ node = candidate;
1682
+ }
1683
+ }
1684
+ if (!node) {
1685
+ for (let index = addList.length - 1; index >= 0; index--) {
1686
+ const _node = addList.get(index);
1687
+ if (_node) {
1688
+ const parentId = this.mirror.getId(_node.value.parentNode);
1689
+ const nextId2 = getNextId(_node.value);
1690
+ if (nextId2 === -1)
1691
+ continue;
1692
+ else if (parentId !== -1) {
1693
+ node = _node;
1694
+ break;
1695
+ } else {
1696
+ const unhandledNode = _node.value;
1697
+ if (unhandledNode.parentNode && unhandledNode.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
1698
+ const shadowHost = unhandledNode.parentNode.host;
1699
+ const parentId2 = this.mirror.getId(shadowHost);
1700
+ if (parentId2 !== -1) {
1701
+ node = _node;
1702
+ break;
1703
+ }
1704
+ }
1705
+ }
1706
+ }
1707
+ }
1708
+ }
1709
+ if (!node) {
1710
+ while (addList.head) {
1711
+ addList.removeNode(addList.head.value);
1712
+ }
1713
+ break;
1714
+ }
1715
+ candidate = node.previous;
1716
+ addList.removeNode(node.value);
1717
+ pushAdd(node.value);
1718
+ }
1719
+ const payload = {
1720
+ texts: this.texts.map((text) => ({
1721
+ id: this.mirror.getId(text.node),
1722
+ value: text.value
1723
+ })).filter((text) => this.mirror.has(text.id)),
1724
+ attributes: this.attributes.map((attribute) => ({
1725
+ id: this.mirror.getId(attribute.node),
1726
+ attributes: attribute.attributes
1727
+ })).filter((attribute) => this.mirror.has(attribute.id)),
1728
+ removes: this.removes,
1729
+ adds
1730
+ };
1731
+ if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
1732
+ return;
1733
+ }
1734
+ this.texts = [];
1735
+ this.attributes = [];
1736
+ this.removes = [];
1737
+ this.addedSet = /* @__PURE__ */ new Set();
1738
+ this.movedSet = /* @__PURE__ */ new Set();
1739
+ this.droppedSet = /* @__PURE__ */ new Set();
1740
+ this.movedMap = {};
1741
+ this.mutationCb(payload);
1742
+ };
1743
+ this.processMutation = (m) => {
1744
+ if (isIgnored(m.target, this.mirror)) {
1745
+ return;
1746
+ }
1747
+ switch (m.type) {
1748
+ case "characterData": {
1749
+ const value = m.target.textContent;
1750
+ if (!isBlocked(m.target, this.blockClass, this.blockSelector, false) && value !== m.oldValue) {
1751
+ this.texts.push({
1752
+ value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value ? this.maskTextFn ? this.maskTextFn(value) : value.replace(/[\S]/g, "*") : value,
1753
+ node: m.target
1754
+ });
1755
+ }
1756
+ break;
1757
+ }
1758
+ case "attributes": {
1759
+ const target = m.target;
1760
+ let value = m.target.getAttribute(m.attributeName);
1761
+ if (m.attributeName === "value") {
1762
+ value = maskInputValue({
1763
+ maskInputOptions: this.maskInputOptions,
1764
+ tagName: m.target.tagName,
1765
+ type: m.target.getAttribute("type"),
1766
+ value,
1767
+ maskInputFn: this.maskInputFn
1768
+ });
1769
+ }
1770
+ if (isBlocked(m.target, this.blockClass, this.blockSelector, false) || value === m.oldValue) {
1771
+ return;
1772
+ }
1773
+ let item = this.attributes.find((a) => a.node === m.target);
1774
+ if (target.tagName === "IFRAME" && m.attributeName === "src" && !this.keepIframeSrcFn(value)) {
1775
+ if (!target.contentDocument) {
1776
+ m.attributeName = "rr_src";
1777
+ } else {
1778
+ return;
1779
+ }
1780
+ }
1781
+ if (!item) {
1782
+ item = {
1783
+ node: m.target,
1784
+ attributes: {}
1785
+ };
1786
+ this.attributes.push(item);
1787
+ }
1788
+ if (m.attributeName === "style") {
1789
+ const old = this.doc.createElement("span");
1790
+ if (m.oldValue) {
1791
+ old.setAttribute("style", m.oldValue);
1792
+ }
1793
+ if (item.attributes.style === void 0 || item.attributes.style === null) {
1794
+ item.attributes.style = {};
1795
+ }
1796
+ const styleObj = item.attributes.style;
1797
+ for (const pname of Array.from(target.style)) {
1798
+ const newValue = target.style.getPropertyValue(pname);
1799
+ const newPriority = target.style.getPropertyPriority(pname);
1800
+ if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
1801
+ if (newPriority === "") {
1802
+ styleObj[pname] = newValue;
1803
+ } else {
1804
+ styleObj[pname] = [newValue, newPriority];
1805
+ }
1806
+ }
1807
+ }
1808
+ for (const pname of Array.from(old.style)) {
1809
+ if (target.style.getPropertyValue(pname) === "") {
1810
+ styleObj[pname] = false;
1811
+ }
1812
+ }
1813
+ } else {
1814
+ item.attributes[m.attributeName] = transformAttribute(this.doc, target.tagName, m.attributeName, value);
1815
+ }
1816
+ break;
1817
+ }
1818
+ case "childList": {
1819
+ if (isBlocked(m.target, this.blockClass, this.blockSelector, true))
1820
+ return;
1821
+ m.addedNodes.forEach((n) => this.genAdds(n, m.target));
1822
+ m.removedNodes.forEach((n) => {
1823
+ const nodeId = this.mirror.getId(n);
1824
+ const parentId = isShadowRoot(m.target) ? this.mirror.getId(m.target.host) : this.mirror.getId(m.target);
1825
+ if (isBlocked(m.target, this.blockClass, this.blockSelector, false) || isIgnored(n, this.mirror) || !isSerialized(n, this.mirror)) {
1826
+ return;
1827
+ }
1828
+ if (this.addedSet.has(n)) {
1829
+ deepDelete(this.addedSet, n);
1830
+ this.droppedSet.add(n);
1831
+ } else if (this.addedSet.has(m.target) && nodeId === -1) ;
1832
+ else if (isAncestorRemoved(m.target, this.mirror)) ;
1833
+ else if (this.movedSet.has(n) && this.movedMap[moveKey(nodeId, parentId)]) {
1834
+ deepDelete(this.movedSet, n);
1835
+ } else {
1836
+ this.removes.push({
1837
+ parentId,
1838
+ id: nodeId,
1839
+ isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
1840
+ });
1841
+ }
1842
+ this.mapRemoves.push(n);
1843
+ });
1844
+ break;
1845
+ }
1846
+ }
1847
+ };
1848
+ this.genAdds = (n, target) => {
1849
+ if (this.mirror.hasNode(n)) {
1850
+ if (isIgnored(n, this.mirror)) {
1851
+ return;
1852
+ }
1853
+ this.movedSet.add(n);
1854
+ let targetId = null;
1855
+ if (target && this.mirror.hasNode(target)) {
1856
+ targetId = this.mirror.getId(target);
1857
+ }
1858
+ if (targetId && targetId !== -1) {
1859
+ this.movedMap[moveKey(this.mirror.getId(n), targetId)] = true;
1860
+ }
1861
+ } else {
1862
+ this.addedSet.add(n);
1863
+ this.droppedSet.delete(n);
1864
+ }
1865
+ if (!isBlocked(n, this.blockClass, this.blockSelector, false))
1866
+ n.childNodes.forEach((childN) => this.genAdds(childN));
1867
+ };
1868
+ }
1869
+ init(options) {
1870
+ [
1871
+ "mutationCb",
1872
+ "blockClass",
1873
+ "blockSelector",
1874
+ "maskTextClass",
1875
+ "maskTextSelector",
1876
+ "inlineStylesheet",
1877
+ "maskInputOptions",
1878
+ "maskTextFn",
1879
+ "maskInputFn",
1880
+ "keepIframeSrcFn",
1881
+ "recordCanvas",
1882
+ "inlineImages",
1883
+ "slimDOMOptions",
1884
+ "dataURLOptions",
1885
+ "doc",
1886
+ "mirror",
1887
+ "iframeManager",
1888
+ "stylesheetManager",
1889
+ "shadowDomManager",
1890
+ "canvasManager"
1891
+ ].forEach((key) => {
1892
+ this[key] = options[key];
1893
+ });
1894
+ }
1895
+ freeze() {
1896
+ this.frozen = true;
1897
+ this.canvasManager.freeze();
1898
+ }
1899
+ unfreeze() {
1900
+ this.frozen = false;
1901
+ this.canvasManager.unfreeze();
1902
+ this.emit();
1903
+ }
1904
+ isFrozen() {
1905
+ return this.frozen;
1906
+ }
1907
+ lock() {
1908
+ this.locked = true;
1909
+ this.canvasManager.lock();
1910
+ }
1911
+ unlock() {
1912
+ this.locked = false;
1913
+ this.canvasManager.unlock();
1914
+ this.emit();
1915
+ }
1916
+ reset() {
1917
+ this.shadowDomManager.reset();
1918
+ this.canvasManager.reset();
1919
+ }
1920
+ };
1921
+ function deepDelete(addsSet, n) {
1922
+ addsSet.delete(n);
1923
+ n.childNodes.forEach((childN) => deepDelete(addsSet, childN));
1924
+ }
1925
+ function isParentRemoved(removes, n, mirror2) {
1926
+ if (removes.length === 0)
1927
+ return false;
1928
+ return _isParentRemoved(removes, n, mirror2);
1929
+ }
1930
+ function _isParentRemoved(removes, n, mirror2) {
1931
+ const { parentNode } = n;
1932
+ if (!parentNode) {
1933
+ return false;
1934
+ }
1935
+ const parentId = mirror2.getId(parentNode);
1936
+ if (removes.some((r) => r.id === parentId)) {
1937
+ return true;
1938
+ }
1939
+ return _isParentRemoved(removes, parentNode, mirror2);
1940
+ }
1941
+ function isAncestorInSet(set, n) {
1942
+ if (set.size === 0)
1943
+ return false;
1944
+ return _isAncestorInSet(set, n);
1945
+ }
1946
+ function _isAncestorInSet(set, n) {
1947
+ const { parentNode } = n;
1948
+ if (!parentNode) {
1949
+ return false;
1950
+ }
1951
+ if (set.has(parentNode)) {
1952
+ return true;
1953
+ }
1954
+ return _isAncestorInSet(set, parentNode);
1955
+ }
1956
+
1957
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observer.js
1958
+ var mutationBuffers = [];
1959
+ var isCSSGroupingRuleSupported = typeof CSSGroupingRule !== "undefined";
1960
+ var isCSSMediaRuleSupported = typeof CSSMediaRule !== "undefined";
1961
+ var isCSSSupportsRuleSupported = typeof CSSSupportsRule !== "undefined";
1962
+ var isCSSConditionRuleSupported = typeof CSSConditionRule !== "undefined";
1963
+ function getEventTarget(event) {
1964
+ try {
1965
+ if ("composedPath" in event) {
1966
+ const path = event.composedPath();
1967
+ if (path.length) {
1968
+ return path[0];
1969
+ }
1970
+ } else if ("path" in event && event.path.length) {
1971
+ return event.path[0];
1972
+ }
1973
+ return event.target;
1974
+ } catch (_a) {
1975
+ return event.target;
1976
+ }
1977
+ }
1978
+ function initMutationObserver(options, rootEl) {
1979
+ var _a, _b;
1980
+ const mutationBuffer = new MutationBuffer();
1981
+ mutationBuffers.push(mutationBuffer);
1982
+ mutationBuffer.init(options);
1983
+ let mutationObserverCtor = window.MutationObserver || window.__rrMutationObserver;
1984
+ const angularZoneSymbol = (_b = (_a = window === null || window === void 0 ? void 0 : window.Zone) === null || _a === void 0 ? void 0 : _a.__symbol__) === null || _b === void 0 ? void 0 : _b.call(_a, "MutationObserver");
1985
+ if (angularZoneSymbol && window[angularZoneSymbol]) {
1986
+ mutationObserverCtor = window[angularZoneSymbol];
1987
+ }
1988
+ const observer = new mutationObserverCtor(mutationBuffer.processMutations.bind(mutationBuffer));
1989
+ observer.observe(rootEl, {
1990
+ attributes: true,
1991
+ attributeOldValue: true,
1992
+ characterData: true,
1993
+ characterDataOldValue: true,
1994
+ childList: true,
1995
+ subtree: true
1996
+ });
1997
+ return observer;
1998
+ }
1999
+ function initMoveObserver({ mousemoveCb, sampling, doc, mirror: mirror2 }) {
2000
+ if (sampling.mousemove === false) {
2001
+ return () => {
2002
+ };
2003
+ }
2004
+ const threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
2005
+ const callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
2006
+ let positions = [];
2007
+ let timeBaseline;
2008
+ const wrappedCb = throttle((source) => {
2009
+ const totalOffset = Date.now() - timeBaseline;
2010
+ mousemoveCb(positions.map((p) => {
2011
+ p.timeOffset -= totalOffset;
2012
+ return p;
2013
+ }), source);
2014
+ positions = [];
2015
+ timeBaseline = null;
2016
+ }, callbackThreshold);
2017
+ const updatePosition = throttle((evt) => {
2018
+ const target = getEventTarget(evt);
2019
+ const { clientX, clientY } = isTouchEvent(evt) ? evt.changedTouches[0] : evt;
2020
+ if (!timeBaseline) {
2021
+ timeBaseline = Date.now();
2022
+ }
2023
+ positions.push({
2024
+ x: clientX,
2025
+ y: clientY,
2026
+ id: mirror2.getId(target),
2027
+ timeOffset: Date.now() - timeBaseline
2028
+ });
2029
+ wrappedCb(typeof DragEvent !== "undefined" && evt instanceof DragEvent ? IncrementalSource.Drag : evt instanceof MouseEvent ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
2030
+ }, threshold, {
2031
+ trailing: false
2032
+ });
2033
+ const handlers = [
2034
+ on("mousemove", updatePosition, doc),
2035
+ on("touchmove", updatePosition, doc),
2036
+ on("drag", updatePosition, doc)
2037
+ ];
2038
+ return () => {
2039
+ handlers.forEach((h) => h());
2040
+ };
2041
+ }
2042
+ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror: mirror2, blockClass, blockSelector, sampling }) {
2043
+ if (sampling.mouseInteraction === false) {
2044
+ return () => {
2045
+ };
2046
+ }
2047
+ const disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
2048
+ const handlers = [];
2049
+ const getHandler = (eventKey) => {
2050
+ return (event) => {
2051
+ const target = getEventTarget(event);
2052
+ if (isBlocked(target, blockClass, blockSelector, true)) {
2053
+ return;
2054
+ }
2055
+ const e = isTouchEvent(event) ? event.changedTouches[0] : event;
2056
+ if (!e) {
2057
+ return;
2058
+ }
2059
+ const id = mirror2.getId(target);
2060
+ const { clientX, clientY } = e;
2061
+ mouseInteractionCb({
2062
+ type: MouseInteractions[eventKey],
2063
+ id,
2064
+ x: clientX,
2065
+ y: clientY
2066
+ });
2067
+ };
2068
+ };
2069
+ Object.keys(MouseInteractions).filter((key) => Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false).forEach((eventKey) => {
2070
+ const eventName = eventKey.toLowerCase();
2071
+ const handler = getHandler(eventKey);
2072
+ handlers.push(on(eventName, handler, doc));
2073
+ });
2074
+ return () => {
2075
+ handlers.forEach((h) => h());
2076
+ };
2077
+ }
2078
+ function initScrollObserver({ scrollCb, doc, mirror: mirror2, blockClass, blockSelector, sampling }) {
2079
+ const updatePosition = throttle((evt) => {
2080
+ const target = getEventTarget(evt);
2081
+ if (!target || isBlocked(target, blockClass, blockSelector, true)) {
2082
+ return;
2083
+ }
2084
+ const id = mirror2.getId(target);
2085
+ if (target === doc) {
2086
+ const scrollEl = doc.scrollingElement || doc.documentElement;
2087
+ scrollCb({
2088
+ id,
2089
+ x: scrollEl.scrollLeft,
2090
+ y: scrollEl.scrollTop
2091
+ });
2092
+ } else {
2093
+ scrollCb({
2094
+ id,
2095
+ x: target.scrollLeft,
2096
+ y: target.scrollTop
2097
+ });
2098
+ }
2099
+ }, sampling.scroll || 100);
2100
+ return on("scroll", updatePosition, doc);
2101
+ }
2102
+ function initViewportResizeObserver({ viewportResizeCb }) {
2103
+ let lastH = -1;
2104
+ let lastW = -1;
2105
+ const updateDimension = throttle(() => {
2106
+ const height = getWindowHeight();
2107
+ const width = getWindowWidth();
2108
+ if (lastH !== height || lastW !== width) {
2109
+ viewportResizeCb({
2110
+ width: Number(width),
2111
+ height: Number(height)
2112
+ });
2113
+ lastH = height;
2114
+ lastW = width;
2115
+ }
2116
+ }, 200);
2117
+ return on("resize", updateDimension, window);
2118
+ }
2119
+ function wrapEventWithUserTriggeredFlag(v, enable) {
2120
+ const value = Object.assign({}, v);
2121
+ if (!enable)
2122
+ delete value.userTriggered;
2123
+ return value;
2124
+ }
2125
+ var INPUT_TAGS = ["INPUT", "TEXTAREA", "SELECT"];
2126
+ var lastInputValueMap = /* @__PURE__ */ new WeakMap();
2127
+ function initInputObserver({ inputCb, doc, mirror: mirror2, blockClass, blockSelector, ignoreClass, maskInputOptions, maskInputFn, sampling, userTriggeredOnInput }) {
2128
+ function eventHandler(event) {
2129
+ let target = getEventTarget(event);
2130
+ const userTriggered = event.isTrusted;
2131
+ if (target && target.tagName === "OPTION")
2132
+ target = target.parentElement;
2133
+ if (!target || !target.tagName || INPUT_TAGS.indexOf(target.tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
2134
+ return;
2135
+ }
2136
+ const type = target.type;
2137
+ if (target.classList.contains(ignoreClass)) {
2138
+ return;
2139
+ }
2140
+ let text = target.value;
2141
+ let isChecked = false;
2142
+ if (type === "radio" || type === "checkbox") {
2143
+ isChecked = target.checked;
2144
+ } else if (maskInputOptions[target.tagName.toLowerCase()] || maskInputOptions[type]) {
2145
+ text = maskInputValue({
2146
+ maskInputOptions,
2147
+ tagName: target.tagName,
2148
+ type,
2149
+ value: text,
2150
+ maskInputFn
2151
+ });
2152
+ }
2153
+ cbWithDedup(target, wrapEventWithUserTriggeredFlag({ text, isChecked, userTriggered }, userTriggeredOnInput));
2154
+ const name = target.name;
2155
+ if (type === "radio" && name && isChecked) {
2156
+ doc.querySelectorAll(`input[type="radio"][name="${name}"]`).forEach((el) => {
2157
+ if (el !== target) {
2158
+ cbWithDedup(el, wrapEventWithUserTriggeredFlag({
2159
+ text: el.value,
2160
+ isChecked: !isChecked,
2161
+ userTriggered: false
2162
+ }, userTriggeredOnInput));
2163
+ }
2164
+ });
2165
+ }
2166
+ }
2167
+ function cbWithDedup(target, v) {
2168
+ const lastInputValue = lastInputValueMap.get(target);
2169
+ if (!lastInputValue || lastInputValue.text !== v.text || lastInputValue.isChecked !== v.isChecked) {
2170
+ lastInputValueMap.set(target, v);
2171
+ const id = mirror2.getId(target);
2172
+ inputCb(Object.assign(Object.assign({}, v), { id }));
2173
+ }
2174
+ }
2175
+ const events = sampling.input === "last" ? ["change"] : ["input", "change"];
2176
+ const handlers = events.map((eventName) => on(eventName, eventHandler, doc));
2177
+ const currentWindow = doc.defaultView;
2178
+ if (!currentWindow) {
2179
+ return () => {
2180
+ handlers.forEach((h) => h());
2181
+ };
2182
+ }
2183
+ const propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
2184
+ const hookProperties = [
2185
+ [currentWindow.HTMLInputElement.prototype, "value"],
2186
+ [currentWindow.HTMLInputElement.prototype, "checked"],
2187
+ [currentWindow.HTMLSelectElement.prototype, "value"],
2188
+ [currentWindow.HTMLTextAreaElement.prototype, "value"],
2189
+ [currentWindow.HTMLSelectElement.prototype, "selectedIndex"],
2190
+ [currentWindow.HTMLOptionElement.prototype, "selected"]
2191
+ ];
2192
+ if (propertyDescriptor && propertyDescriptor.set) {
2193
+ handlers.push(...hookProperties.map((p) => hookSetter(p[0], p[1], {
2194
+ set() {
2195
+ eventHandler({ target: this });
2196
+ }
2197
+ }, false, currentWindow)));
2198
+ }
2199
+ return () => {
2200
+ handlers.forEach((h) => h());
2201
+ };
2202
+ }
2203
+ function getNestedCSSRulePositions(rule) {
2204
+ const positions = [];
2205
+ function recurse(childRule, pos) {
2206
+ if (isCSSGroupingRuleSupported && childRule.parentRule instanceof CSSGroupingRule || isCSSMediaRuleSupported && childRule.parentRule instanceof CSSMediaRule || isCSSSupportsRuleSupported && childRule.parentRule instanceof CSSSupportsRule || isCSSConditionRuleSupported && childRule.parentRule instanceof CSSConditionRule) {
2207
+ const rules = Array.from(childRule.parentRule.cssRules);
2208
+ const index = rules.indexOf(childRule);
2209
+ pos.unshift(index);
2210
+ } else if (childRule.parentStyleSheet) {
2211
+ const rules = Array.from(childRule.parentStyleSheet.cssRules);
2212
+ const index = rules.indexOf(childRule);
2213
+ pos.unshift(index);
2214
+ }
2215
+ return pos;
2216
+ }
2217
+ return recurse(rule, positions);
2218
+ }
2219
+ function getIdAndStyleId(sheet, mirror2, styleMirror) {
2220
+ let id, styleId;
2221
+ if (!sheet)
2222
+ return {};
2223
+ if (sheet.ownerNode)
2224
+ id = mirror2.getId(sheet.ownerNode);
2225
+ else
2226
+ styleId = styleMirror.getId(sheet);
2227
+ return {
2228
+ styleId,
2229
+ id
2230
+ };
2231
+ }
2232
+ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetManager }, { win }) {
2233
+ const insertRule = win.CSSStyleSheet.prototype.insertRule;
2234
+ win.CSSStyleSheet.prototype.insertRule = function(rule, index) {
2235
+ const { id, styleId } = getIdAndStyleId(this, mirror2, stylesheetManager.styleMirror);
2236
+ if (id && id !== -1 || styleId && styleId !== -1) {
2237
+ styleSheetRuleCb({
2238
+ id,
2239
+ styleId,
2240
+ adds: [{ rule, index }]
2241
+ });
2242
+ }
2243
+ return insertRule.apply(this, [rule, index]);
2244
+ };
2245
+ const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
2246
+ win.CSSStyleSheet.prototype.deleteRule = function(index) {
2247
+ const { id, styleId } = getIdAndStyleId(this, mirror2, stylesheetManager.styleMirror);
2248
+ if (id && id !== -1 || styleId && styleId !== -1) {
2249
+ styleSheetRuleCb({
2250
+ id,
2251
+ styleId,
2252
+ removes: [{ index }]
2253
+ });
2254
+ }
2255
+ return deleteRule.apply(this, [index]);
2256
+ };
2257
+ let replace;
2258
+ if (win.CSSStyleSheet.prototype.replace) {
2259
+ replace = win.CSSStyleSheet.prototype.replace;
2260
+ win.CSSStyleSheet.prototype.replace = function(text) {
2261
+ const { id, styleId } = getIdAndStyleId(this, mirror2, stylesheetManager.styleMirror);
2262
+ if (id && id !== -1 || styleId && styleId !== -1) {
2263
+ styleSheetRuleCb({
2264
+ id,
2265
+ styleId,
2266
+ replace: text
2267
+ });
2268
+ }
2269
+ return replace.apply(this, [text]);
2270
+ };
2271
+ }
2272
+ let replaceSync;
2273
+ if (win.CSSStyleSheet.prototype.replaceSync) {
2274
+ replaceSync = win.CSSStyleSheet.prototype.replaceSync;
2275
+ win.CSSStyleSheet.prototype.replaceSync = function(text) {
2276
+ const { id, styleId } = getIdAndStyleId(this, mirror2, stylesheetManager.styleMirror);
2277
+ if (id && id !== -1 || styleId && styleId !== -1) {
2278
+ styleSheetRuleCb({
2279
+ id,
2280
+ styleId,
2281
+ replaceSync: text
2282
+ });
2283
+ }
2284
+ return replaceSync.apply(this, [text]);
2285
+ };
2286
+ }
2287
+ const supportedNestedCSSRuleTypes = {};
2288
+ if (isCSSGroupingRuleSupported) {
2289
+ supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
2290
+ } else {
2291
+ if (isCSSMediaRuleSupported) {
2292
+ supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
2293
+ }
2294
+ if (isCSSConditionRuleSupported) {
2295
+ supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
2296
+ }
2297
+ if (isCSSSupportsRuleSupported) {
2298
+ supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
2299
+ }
2300
+ }
2301
+ const unmodifiedFunctions = {};
2302
+ Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
2303
+ unmodifiedFunctions[typeKey] = {
2304
+ insertRule: type.prototype.insertRule,
2305
+ deleteRule: type.prototype.deleteRule
2306
+ };
2307
+ type.prototype.insertRule = function(rule, index) {
2308
+ const { id, styleId } = getIdAndStyleId(this.parentStyleSheet, mirror2, stylesheetManager.styleMirror);
2309
+ if (id && id !== -1 || styleId && styleId !== -1) {
2310
+ styleSheetRuleCb({
2311
+ id,
2312
+ styleId,
2313
+ adds: [
2314
+ {
2315
+ rule,
2316
+ index: [
2317
+ ...getNestedCSSRulePositions(this),
2318
+ index || 0
2319
+ ]
2320
+ }
2321
+ ]
2322
+ });
2323
+ }
2324
+ return unmodifiedFunctions[typeKey].insertRule.apply(this, [rule, index]);
2325
+ };
2326
+ type.prototype.deleteRule = function(index) {
2327
+ const { id, styleId } = getIdAndStyleId(this.parentStyleSheet, mirror2, stylesheetManager.styleMirror);
2328
+ if (id && id !== -1 || styleId && styleId !== -1) {
2329
+ styleSheetRuleCb({
2330
+ id,
2331
+ styleId,
2332
+ removes: [
2333
+ { index: [...getNestedCSSRulePositions(this), index] }
2334
+ ]
2335
+ });
2336
+ }
2337
+ return unmodifiedFunctions[typeKey].deleteRule.apply(this, [index]);
2338
+ };
2339
+ });
2340
+ return () => {
2341
+ win.CSSStyleSheet.prototype.insertRule = insertRule;
2342
+ win.CSSStyleSheet.prototype.deleteRule = deleteRule;
2343
+ replace && (win.CSSStyleSheet.prototype.replace = replace);
2344
+ replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
2345
+ Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
2346
+ type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
2347
+ type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
2348
+ });
2349
+ };
2350
+ }
2351
+ function initAdoptedStyleSheetObserver({ mirror: mirror2, stylesheetManager }, host) {
2352
+ var _a, _b, _c;
2353
+ let hostId = null;
2354
+ if (host.nodeName === "#document")
2355
+ hostId = mirror2.getId(host);
2356
+ else
2357
+ hostId = mirror2.getId(host.host);
2358
+ const patchTarget = host.nodeName === "#document" ? (_a = host.defaultView) === null || _a === void 0 ? void 0 : _a.Document : (_c = (_b = host.ownerDocument) === null || _b === void 0 ? void 0 : _b.defaultView) === null || _c === void 0 ? void 0 : _c.ShadowRoot;
2359
+ const originalPropertyDescriptor = Object.getOwnPropertyDescriptor(patchTarget === null || patchTarget === void 0 ? void 0 : patchTarget.prototype, "adoptedStyleSheets");
2360
+ if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor)
2361
+ return () => {
2362
+ };
2363
+ Object.defineProperty(host, "adoptedStyleSheets", {
2364
+ configurable: originalPropertyDescriptor.configurable,
2365
+ enumerable: originalPropertyDescriptor.enumerable,
2366
+ get() {
2367
+ var _a2;
2368
+ return (_a2 = originalPropertyDescriptor.get) === null || _a2 === void 0 ? void 0 : _a2.call(this);
2369
+ },
2370
+ set(sheets) {
2371
+ var _a2;
2372
+ const result = (_a2 = originalPropertyDescriptor.set) === null || _a2 === void 0 ? void 0 : _a2.call(this, sheets);
2373
+ if (hostId !== null && hostId !== -1) {
2374
+ try {
2375
+ stylesheetManager.adoptStyleSheets(sheets, hostId);
2376
+ } catch (e) {
2377
+ }
2378
+ }
2379
+ return result;
2380
+ }
2381
+ });
2382
+ return () => {
2383
+ Object.defineProperty(host, "adoptedStyleSheets", {
2384
+ configurable: originalPropertyDescriptor.configurable,
2385
+ enumerable: originalPropertyDescriptor.enumerable,
2386
+ get: originalPropertyDescriptor.get,
2387
+ set: originalPropertyDescriptor.set
2388
+ });
2389
+ };
2390
+ }
2391
+ function initStyleDeclarationObserver({ styleDeclarationCb, mirror: mirror2, ignoreCSSAttributes, stylesheetManager }, { win }) {
2392
+ const setProperty = win.CSSStyleDeclaration.prototype.setProperty;
2393
+ win.CSSStyleDeclaration.prototype.setProperty = function(property, value, priority) {
2394
+ var _a;
2395
+ if (ignoreCSSAttributes.has(property)) {
2396
+ return setProperty.apply(this, [property, value, priority]);
2397
+ }
2398
+ const { id, styleId } = getIdAndStyleId((_a = this.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet, mirror2, stylesheetManager.styleMirror);
2399
+ if (id && id !== -1 || styleId && styleId !== -1) {
2400
+ styleDeclarationCb({
2401
+ id,
2402
+ styleId,
2403
+ set: {
2404
+ property,
2405
+ value,
2406
+ priority
2407
+ },
2408
+ index: getNestedCSSRulePositions(this.parentRule)
2409
+ });
2410
+ }
2411
+ return setProperty.apply(this, [property, value, priority]);
2412
+ };
2413
+ const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
2414
+ win.CSSStyleDeclaration.prototype.removeProperty = function(property) {
2415
+ var _a;
2416
+ if (ignoreCSSAttributes.has(property)) {
2417
+ return removeProperty.apply(this, [property]);
2418
+ }
2419
+ const { id, styleId } = getIdAndStyleId((_a = this.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet, mirror2, stylesheetManager.styleMirror);
2420
+ if (id && id !== -1 || styleId && styleId !== -1) {
2421
+ styleDeclarationCb({
2422
+ id,
2423
+ styleId,
2424
+ remove: {
2425
+ property
2426
+ },
2427
+ index: getNestedCSSRulePositions(this.parentRule)
2428
+ });
2429
+ }
2430
+ return removeProperty.apply(this, [property]);
2431
+ };
2432
+ return () => {
2433
+ win.CSSStyleDeclaration.prototype.setProperty = setProperty;
2434
+ win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
2435
+ };
2436
+ }
2437
+ function initMediaInteractionObserver({ mediaInteractionCb, blockClass, blockSelector, mirror: mirror2, sampling }) {
2438
+ const handler = (type) => throttle((event) => {
2439
+ const target = getEventTarget(event);
2440
+ if (!target || isBlocked(target, blockClass, blockSelector, true)) {
2441
+ return;
2442
+ }
2443
+ const { currentTime, volume, muted, playbackRate } = target;
2444
+ mediaInteractionCb({
2445
+ type,
2446
+ id: mirror2.getId(target),
2447
+ currentTime,
2448
+ volume,
2449
+ muted,
2450
+ playbackRate
2451
+ });
2452
+ }, sampling.media || 500);
2453
+ const handlers = [
2454
+ on("play", handler(0)),
2455
+ on("pause", handler(1)),
2456
+ on("seeked", handler(2)),
2457
+ on("volumechange", handler(3)),
2458
+ on("ratechange", handler(4))
2459
+ ];
2460
+ return () => {
2461
+ handlers.forEach((h) => h());
2462
+ };
2463
+ }
2464
+ function initFontObserver({ fontCb, doc }) {
2465
+ const win = doc.defaultView;
2466
+ if (!win) {
2467
+ return () => {
2468
+ };
2469
+ }
2470
+ const handlers = [];
2471
+ const fontMap = /* @__PURE__ */ new WeakMap();
2472
+ const originalFontFace = win.FontFace;
2473
+ win.FontFace = function FontFace(family, source, descriptors) {
2474
+ const fontFace = new originalFontFace(family, source, descriptors);
2475
+ fontMap.set(fontFace, {
2476
+ family,
2477
+ buffer: typeof source !== "string",
2478
+ descriptors,
2479
+ fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
2480
+ });
2481
+ return fontFace;
2482
+ };
2483
+ const restoreHandler = patch(doc.fonts, "add", function(original) {
2484
+ return function(fontFace) {
2485
+ setTimeout(() => {
2486
+ const p = fontMap.get(fontFace);
2487
+ if (p) {
2488
+ fontCb(p);
2489
+ fontMap.delete(fontFace);
2490
+ }
2491
+ }, 0);
2492
+ return original.apply(this, [fontFace]);
2493
+ };
2494
+ });
2495
+ handlers.push(() => {
2496
+ win.FontFace = originalFontFace;
2497
+ });
2498
+ handlers.push(restoreHandler);
2499
+ return () => {
2500
+ handlers.forEach((h) => h());
2501
+ };
2502
+ }
2503
+ function initSelectionObserver(param) {
2504
+ const { doc, mirror: mirror2, blockClass, blockSelector, selectionCb } = param;
2505
+ let collapsed = true;
2506
+ const updateSelection = () => {
2507
+ const selection = doc.getSelection();
2508
+ if (!selection || collapsed && (selection === null || selection === void 0 ? void 0 : selection.isCollapsed))
2509
+ return;
2510
+ collapsed = selection.isCollapsed || false;
2511
+ const ranges = [];
2512
+ const count = selection.rangeCount || 0;
2513
+ for (let i = 0; i < count; i++) {
2514
+ const range = selection.getRangeAt(i);
2515
+ const { startContainer, startOffset, endContainer, endOffset } = range;
2516
+ const blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
2517
+ if (blocked)
2518
+ continue;
2519
+ ranges.push({
2520
+ start: mirror2.getId(startContainer),
2521
+ startOffset,
2522
+ end: mirror2.getId(endContainer),
2523
+ endOffset
2524
+ });
2525
+ }
2526
+ selectionCb({ ranges });
2527
+ };
2528
+ updateSelection();
2529
+ return on("selectionchange", updateSelection);
2530
+ }
2531
+ function mergeHooks(o, hooks) {
2532
+ const { mutationCb, mousemoveCb, mouseInteractionCb, scrollCb, viewportResizeCb, inputCb, mediaInteractionCb, styleSheetRuleCb, styleDeclarationCb, canvasMutationCb, fontCb, selectionCb } = o;
2533
+ o.mutationCb = (...p) => {
2534
+ if (hooks.mutation) {
2535
+ hooks.mutation(...p);
2536
+ }
2537
+ mutationCb(...p);
2538
+ };
2539
+ o.mousemoveCb = (...p) => {
2540
+ if (hooks.mousemove) {
2541
+ hooks.mousemove(...p);
2542
+ }
2543
+ mousemoveCb(...p);
2544
+ };
2545
+ o.mouseInteractionCb = (...p) => {
2546
+ if (hooks.mouseInteraction) {
2547
+ hooks.mouseInteraction(...p);
2548
+ }
2549
+ mouseInteractionCb(...p);
2550
+ };
2551
+ o.scrollCb = (...p) => {
2552
+ if (hooks.scroll) {
2553
+ hooks.scroll(...p);
2554
+ }
2555
+ scrollCb(...p);
2556
+ };
2557
+ o.viewportResizeCb = (...p) => {
2558
+ if (hooks.viewportResize) {
2559
+ hooks.viewportResize(...p);
2560
+ }
2561
+ viewportResizeCb(...p);
2562
+ };
2563
+ o.inputCb = (...p) => {
2564
+ if (hooks.input) {
2565
+ hooks.input(...p);
2566
+ }
2567
+ inputCb(...p);
2568
+ };
2569
+ o.mediaInteractionCb = (...p) => {
2570
+ if (hooks.mediaInteaction) {
2571
+ hooks.mediaInteaction(...p);
2572
+ }
2573
+ mediaInteractionCb(...p);
2574
+ };
2575
+ o.styleSheetRuleCb = (...p) => {
2576
+ if (hooks.styleSheetRule) {
2577
+ hooks.styleSheetRule(...p);
2578
+ }
2579
+ styleSheetRuleCb(...p);
2580
+ };
2581
+ o.styleDeclarationCb = (...p) => {
2582
+ if (hooks.styleDeclaration) {
2583
+ hooks.styleDeclaration(...p);
2584
+ }
2585
+ styleDeclarationCb(...p);
2586
+ };
2587
+ o.canvasMutationCb = (...p) => {
2588
+ if (hooks.canvasMutation) {
2589
+ hooks.canvasMutation(...p);
2590
+ }
2591
+ canvasMutationCb(...p);
2592
+ };
2593
+ o.fontCb = (...p) => {
2594
+ if (hooks.font) {
2595
+ hooks.font(...p);
2596
+ }
2597
+ fontCb(...p);
2598
+ };
2599
+ o.selectionCb = (...p) => {
2600
+ if (hooks.selection) {
2601
+ hooks.selection(...p);
2602
+ }
2603
+ selectionCb(...p);
2604
+ };
2605
+ }
2606
+ function initObservers(o, hooks = {}) {
2607
+ const currentWindow = o.doc.defaultView;
2608
+ if (!currentWindow) {
2609
+ return () => {
2610
+ };
2611
+ }
2612
+ mergeHooks(o, hooks);
2613
+ const mutationObserver = initMutationObserver(o, o.doc);
2614
+ const mousemoveHandler = initMoveObserver(o);
2615
+ const mouseInteractionHandler = initMouseInteractionObserver(o);
2616
+ const scrollHandler = initScrollObserver(o);
2617
+ const viewportResizeHandler = initViewportResizeObserver(o);
2618
+ const inputHandler = initInputObserver(o);
2619
+ const mediaInteractionHandler = initMediaInteractionObserver(o);
2620
+ const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });
2621
+ const adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o, o.doc);
2622
+ const styleDeclarationObserver = initStyleDeclarationObserver(o, {
2623
+ win: currentWindow
2624
+ });
2625
+ const fontObserver = o.collectFonts ? initFontObserver(o) : () => {
2626
+ };
2627
+ const selectionObserver = initSelectionObserver(o);
2628
+ const pluginHandlers = [];
2629
+ for (const plugin of o.plugins) {
2630
+ pluginHandlers.push(plugin.observer(plugin.callback, currentWindow, plugin.options));
2631
+ }
2632
+ return () => {
2633
+ mutationBuffers.forEach((b) => b.reset());
2634
+ mutationObserver.disconnect();
2635
+ mousemoveHandler();
2636
+ mouseInteractionHandler();
2637
+ scrollHandler();
2638
+ viewportResizeHandler();
2639
+ inputHandler();
2640
+ mediaInteractionHandler();
2641
+ styleSheetObserver();
2642
+ adoptedStyleSheetObserver();
2643
+ styleDeclarationObserver();
2644
+ fontObserver();
2645
+ selectionObserver();
2646
+ pluginHandlers.forEach((h) => h());
2647
+ };
2648
+ }
2649
+
2650
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/cross-origin-iframe-mirror.js
2651
+ var CrossOriginIframeMirror = class {
2652
+ constructor(generateIdFn) {
2653
+ this.generateIdFn = generateIdFn;
2654
+ this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
2655
+ this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
2656
+ }
2657
+ getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
2658
+ const idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
2659
+ const remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
2660
+ let id = idToRemoteIdMap.get(remoteId);
2661
+ if (!id) {
2662
+ id = this.generateIdFn();
2663
+ idToRemoteIdMap.set(remoteId, id);
2664
+ remoteIdToIdMap.set(id, remoteId);
2665
+ }
2666
+ return id;
2667
+ }
2668
+ getIds(iframe, remoteId) {
2669
+ const idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
2670
+ const remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
2671
+ return remoteId.map((id) => this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap));
2672
+ }
2673
+ getRemoteId(iframe, id, map) {
2674
+ const remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
2675
+ if (typeof id !== "number")
2676
+ return id;
2677
+ const remoteId = remoteIdToIdMap.get(id);
2678
+ if (!remoteId)
2679
+ return -1;
2680
+ return remoteId;
2681
+ }
2682
+ getRemoteIds(iframe, ids) {
2683
+ const remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
2684
+ return ids.map((id) => this.getRemoteId(iframe, id, remoteIdToIdMap));
2685
+ }
2686
+ reset(iframe) {
2687
+ if (!iframe) {
2688
+ this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
2689
+ this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
2690
+ return;
2691
+ }
2692
+ this.iframeIdToRemoteIdMap.delete(iframe);
2693
+ this.iframeRemoteIdToIdMap.delete(iframe);
2694
+ }
2695
+ getIdToRemoteIdMap(iframe) {
2696
+ let idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
2697
+ if (!idToRemoteIdMap) {
2698
+ idToRemoteIdMap = /* @__PURE__ */ new Map();
2699
+ this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
2700
+ }
2701
+ return idToRemoteIdMap;
2702
+ }
2703
+ getRemoteIdToIdMap(iframe) {
2704
+ let remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
2705
+ if (!remoteIdToIdMap) {
2706
+ remoteIdToIdMap = /* @__PURE__ */ new Map();
2707
+ this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
2708
+ }
2709
+ return remoteIdToIdMap;
2710
+ }
2711
+ };
2712
+
2713
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/iframe-manager.js
2714
+ var IframeManager = class {
2715
+ constructor(options) {
2716
+ this.iframes = /* @__PURE__ */ new WeakMap();
2717
+ this.crossOriginIframeMap = /* @__PURE__ */ new WeakMap();
2718
+ this.crossOriginIframeMirror = new CrossOriginIframeMirror(genId);
2719
+ this.mutationCb = options.mutationCb;
2720
+ this.wrappedEmit = options.wrappedEmit;
2721
+ this.stylesheetManager = options.stylesheetManager;
2722
+ this.recordCrossOriginIframes = options.recordCrossOriginIframes;
2723
+ this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
2724
+ this.mirror = options.mirror;
2725
+ if (this.recordCrossOriginIframes) {
2726
+ window.addEventListener("message", this.handleMessage.bind(this));
2727
+ }
2728
+ }
2729
+ addIframe(iframeEl) {
2730
+ this.iframes.set(iframeEl, true);
2731
+ if (iframeEl.contentWindow)
2732
+ this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
2733
+ }
2734
+ addLoadListener(cb) {
2735
+ this.loadListener = cb;
2736
+ }
2737
+ attachIframe(iframeEl, childSn) {
2738
+ var _a;
2739
+ this.mutationCb({
2740
+ adds: [
2741
+ {
2742
+ parentId: this.mirror.getId(iframeEl),
2743
+ nextId: null,
2744
+ node: childSn
2745
+ }
2746
+ ],
2747
+ removes: [],
2748
+ texts: [],
2749
+ attributes: [],
2750
+ isAttachIframe: true
2751
+ });
2752
+ (_a = this.loadListener) === null || _a === void 0 ? void 0 : _a.call(this, iframeEl);
2753
+ if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0)
2754
+ this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
2755
+ }
2756
+ handleMessage(message) {
2757
+ if (message.data.type === "rrweb") {
2758
+ const iframeSourceWindow = message.source;
2759
+ if (!iframeSourceWindow)
2760
+ return;
2761
+ const iframeEl = this.crossOriginIframeMap.get(message.source);
2762
+ if (!iframeEl)
2763
+ return;
2764
+ const transformedEvent = this.transformCrossOriginEvent(iframeEl, message.data.event);
2765
+ if (transformedEvent)
2766
+ this.wrappedEmit(transformedEvent, message.data.isCheckout);
2767
+ }
2768
+ }
2769
+ transformCrossOriginEvent(iframeEl, e) {
2770
+ var _a;
2771
+ switch (e.type) {
2772
+ case EventType.FullSnapshot: {
2773
+ this.crossOriginIframeMirror.reset(iframeEl);
2774
+ this.crossOriginIframeStyleMirror.reset(iframeEl);
2775
+ this.replaceIdOnNode(e.data.node, iframeEl);
2776
+ return {
2777
+ timestamp: e.timestamp,
2778
+ type: EventType.IncrementalSnapshot,
2779
+ data: {
2780
+ source: IncrementalSource.Mutation,
2781
+ adds: [
2782
+ {
2783
+ parentId: this.mirror.getId(iframeEl),
2784
+ nextId: null,
2785
+ node: e.data.node
2786
+ }
2787
+ ],
2788
+ removes: [],
2789
+ texts: [],
2790
+ attributes: [],
2791
+ isAttachIframe: true
2792
+ }
2793
+ };
2794
+ }
2795
+ case EventType.Meta:
2796
+ case EventType.Load:
2797
+ case EventType.DomContentLoaded: {
2798
+ return false;
2799
+ }
2800
+ case EventType.Plugin: {
2801
+ return e;
2802
+ }
2803
+ case EventType.Custom: {
2804
+ this.replaceIds(e.data.payload, iframeEl, ["id", "parentId", "previousId", "nextId"]);
2805
+ return e;
2806
+ }
2807
+ case EventType.IncrementalSnapshot: {
2808
+ switch (e.data.source) {
2809
+ case IncrementalSource.Mutation: {
2810
+ e.data.adds.forEach((n) => {
2811
+ this.replaceIds(n, iframeEl, [
2812
+ "parentId",
2813
+ "nextId",
2814
+ "previousId"
2815
+ ]);
2816
+ this.replaceIdOnNode(n.node, iframeEl);
2817
+ });
2818
+ e.data.removes.forEach((n) => {
2819
+ this.replaceIds(n, iframeEl, ["parentId", "id"]);
2820
+ });
2821
+ e.data.attributes.forEach((n) => {
2822
+ this.replaceIds(n, iframeEl, ["id"]);
2823
+ });
2824
+ e.data.texts.forEach((n) => {
2825
+ this.replaceIds(n, iframeEl, ["id"]);
2826
+ });
2827
+ return e;
2828
+ }
2829
+ case IncrementalSource.Drag:
2830
+ case IncrementalSource.TouchMove:
2831
+ case IncrementalSource.MouseMove: {
2832
+ e.data.positions.forEach((p) => {
2833
+ this.replaceIds(p, iframeEl, ["id"]);
2834
+ });
2835
+ return e;
2836
+ }
2837
+ case IncrementalSource.ViewportResize: {
2838
+ return false;
2839
+ }
2840
+ case IncrementalSource.MediaInteraction:
2841
+ case IncrementalSource.MouseInteraction:
2842
+ case IncrementalSource.Scroll:
2843
+ case IncrementalSource.CanvasMutation:
2844
+ case IncrementalSource.Input: {
2845
+ this.replaceIds(e.data, iframeEl, ["id"]);
2846
+ return e;
2847
+ }
2848
+ case IncrementalSource.StyleSheetRule:
2849
+ case IncrementalSource.StyleDeclaration: {
2850
+ this.replaceIds(e.data, iframeEl, ["id"]);
2851
+ this.replaceStyleIds(e.data, iframeEl, ["styleId"]);
2852
+ return e;
2853
+ }
2854
+ case IncrementalSource.Font: {
2855
+ return e;
2856
+ }
2857
+ case IncrementalSource.Selection: {
2858
+ e.data.ranges.forEach((range) => {
2859
+ this.replaceIds(range, iframeEl, ["start", "end"]);
2860
+ });
2861
+ return e;
2862
+ }
2863
+ case IncrementalSource.AdoptedStyleSheet: {
2864
+ this.replaceIds(e.data, iframeEl, ["id"]);
2865
+ this.replaceStyleIds(e.data, iframeEl, ["styleIds"]);
2866
+ (_a = e.data.styles) === null || _a === void 0 ? void 0 : _a.forEach((style) => {
2867
+ this.replaceStyleIds(style, iframeEl, ["styleId"]);
2868
+ });
2869
+ return e;
2870
+ }
2871
+ }
2872
+ }
2873
+ }
2874
+ }
2875
+ replace(iframeMirror, obj, iframeEl, keys) {
2876
+ for (const key of keys) {
2877
+ if (!Array.isArray(obj[key]) && typeof obj[key] !== "number")
2878
+ continue;
2879
+ if (Array.isArray(obj[key])) {
2880
+ obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
2881
+ } else {
2882
+ obj[key] = iframeMirror.getId(iframeEl, obj[key]);
2883
+ }
2884
+ }
2885
+ return obj;
2886
+ }
2887
+ replaceIds(obj, iframeEl, keys) {
2888
+ return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
2889
+ }
2890
+ replaceStyleIds(obj, iframeEl, keys) {
2891
+ return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
2892
+ }
2893
+ replaceIdOnNode(node, iframeEl) {
2894
+ this.replaceIds(node, iframeEl, ["id"]);
2895
+ if ("childNodes" in node) {
2896
+ node.childNodes.forEach((child) => {
2897
+ this.replaceIdOnNode(child, iframeEl);
2898
+ });
2899
+ }
2900
+ }
2901
+ };
2902
+
2903
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js
2904
+ var ShadowDomManager = class {
2905
+ constructor(options) {
2906
+ this.shadowDoms = /* @__PURE__ */ new WeakSet();
2907
+ this.restorePatches = [];
2908
+ this.mutationCb = options.mutationCb;
2909
+ this.scrollCb = options.scrollCb;
2910
+ this.bypassOptions = options.bypassOptions;
2911
+ this.mirror = options.mirror;
2912
+ const manager = this;
2913
+ this.restorePatches.push(patch(Element.prototype, "attachShadow", function(original) {
2914
+ return function(option) {
2915
+ const shadowRoot = original.call(this, option);
2916
+ if (this.shadowRoot)
2917
+ manager.addShadowRoot(this.shadowRoot, this.ownerDocument);
2918
+ return shadowRoot;
2919
+ };
2920
+ }));
2921
+ }
2922
+ addShadowRoot(shadowRoot, doc) {
2923
+ if (!isNativeShadowDom(shadowRoot))
2924
+ return;
2925
+ if (this.shadowDoms.has(shadowRoot))
2926
+ return;
2927
+ this.shadowDoms.add(shadowRoot);
2928
+ initMutationObserver(Object.assign(Object.assign({}, this.bypassOptions), { doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
2929
+ initScrollObserver(Object.assign(Object.assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: shadowRoot, mirror: this.mirror }));
2930
+ setTimeout(() => {
2931
+ if (shadowRoot.adoptedStyleSheets && shadowRoot.adoptedStyleSheets.length > 0)
2932
+ this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot.adoptedStyleSheets, this.mirror.getId(shadowRoot.host));
2933
+ initAdoptedStyleSheetObserver({
2934
+ mirror: this.mirror,
2935
+ stylesheetManager: this.bypassOptions.stylesheetManager
2936
+ }, shadowRoot);
2937
+ }, 0);
2938
+ }
2939
+ observeAttachShadow(iframeElement) {
2940
+ if (iframeElement.contentWindow) {
2941
+ const manager = this;
2942
+ this.restorePatches.push(patch(iframeElement.contentWindow.HTMLElement.prototype, "attachShadow", function(original) {
2943
+ return function(option) {
2944
+ const shadowRoot = original.call(this, option);
2945
+ if (this.shadowRoot)
2946
+ manager.addShadowRoot(this.shadowRoot, iframeElement.contentDocument);
2947
+ return shadowRoot;
2948
+ };
2949
+ }));
2950
+ }
2951
+ }
2952
+ reset() {
2953
+ this.restorePatches.forEach((restorePatch) => restorePatch());
2954
+ this.shadowDoms = /* @__PURE__ */ new WeakSet();
2955
+ }
2956
+ };
2957
+
2958
+ // ../../node_modules/rrweb/es/rrweb/ext/tslib/tslib.es6.js
2959
+ function __rest(s, e) {
2960
+ var t = {};
2961
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2962
+ t[p] = s[p];
2963
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
2964
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2965
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2966
+ t[p[i]] = s[p[i]];
2967
+ }
2968
+ return t;
2969
+ }
2970
+ function __awaiter(thisArg, _arguments, P, generator) {
2971
+ function adopt(value) {
2972
+ return value instanceof P ? value : new P(function(resolve) {
2973
+ resolve(value);
2974
+ });
2975
+ }
2976
+ return new (P || (P = Promise))(function(resolve, reject) {
2977
+ function fulfilled(value) {
2978
+ try {
2979
+ step(generator.next(value));
2980
+ } catch (e) {
2981
+ reject(e);
2982
+ }
2983
+ }
2984
+ function rejected(value) {
2985
+ try {
2986
+ step(generator["throw"](value));
2987
+ } catch (e) {
2988
+ reject(e);
2989
+ }
2990
+ }
2991
+ function step(result) {
2992
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
2993
+ }
2994
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
2995
+ });
2996
+ }
2997
+
2998
+ // ../../node_modules/rrweb/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js
2999
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
3000
+ var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
3001
+ for (i = 0; i < chars.length; i++) {
3002
+ lookup[chars.charCodeAt(i)] = i;
3003
+ }
3004
+ var i;
3005
+ var encode = function(arraybuffer) {
3006
+ var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";
3007
+ for (i = 0; i < len; i += 3) {
3008
+ base64 += chars[bytes[i] >> 2];
3009
+ base64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
3010
+ base64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
3011
+ base64 += chars[bytes[i + 2] & 63];
3012
+ }
3013
+ if (len % 3 === 2) {
3014
+ base64 = base64.substring(0, base64.length - 1) + "=";
3015
+ } else if (len % 3 === 1) {
3016
+ base64 = base64.substring(0, base64.length - 2) + "==";
3017
+ }
3018
+ return base64;
3019
+ };
3020
+
3021
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js
3022
+ var canvasVarMap = /* @__PURE__ */ new Map();
3023
+ function variableListFor(ctx, ctor) {
3024
+ let contextMap = canvasVarMap.get(ctx);
3025
+ if (!contextMap) {
3026
+ contextMap = /* @__PURE__ */ new Map();
3027
+ canvasVarMap.set(ctx, contextMap);
3028
+ }
3029
+ if (!contextMap.has(ctor)) {
3030
+ contextMap.set(ctor, []);
3031
+ }
3032
+ return contextMap.get(ctor);
3033
+ }
3034
+ var saveWebGLVar = (value, win, ctx) => {
3035
+ if (!value || !(isInstanceOfWebGLObject(value, win) || typeof value === "object"))
3036
+ return;
3037
+ const name = value.constructor.name;
3038
+ const list = variableListFor(ctx, name);
3039
+ let index = list.indexOf(value);
3040
+ if (index === -1) {
3041
+ index = list.length;
3042
+ list.push(value);
3043
+ }
3044
+ return index;
3045
+ };
3046
+ function serializeArg(value, win, ctx) {
3047
+ if (value instanceof Array) {
3048
+ return value.map((arg) => serializeArg(arg, win, ctx));
3049
+ } else if (value === null) {
3050
+ return value;
3051
+ } else if (value instanceof Float32Array || value instanceof Float64Array || value instanceof Int32Array || value instanceof Uint32Array || value instanceof Uint8Array || value instanceof Uint16Array || value instanceof Int16Array || value instanceof Int8Array || value instanceof Uint8ClampedArray) {
3052
+ const name = value.constructor.name;
3053
+ return {
3054
+ rr_type: name,
3055
+ args: [Object.values(value)]
3056
+ };
3057
+ } else if (value instanceof ArrayBuffer) {
3058
+ const name = value.constructor.name;
3059
+ const base64 = encode(value);
3060
+ return {
3061
+ rr_type: name,
3062
+ base64
3063
+ };
3064
+ } else if (value instanceof DataView) {
3065
+ const name = value.constructor.name;
3066
+ return {
3067
+ rr_type: name,
3068
+ args: [
3069
+ serializeArg(value.buffer, win, ctx),
3070
+ value.byteOffset,
3071
+ value.byteLength
3072
+ ]
3073
+ };
3074
+ } else if (value instanceof HTMLImageElement) {
3075
+ const name = value.constructor.name;
3076
+ const { src } = value;
3077
+ return {
3078
+ rr_type: name,
3079
+ src
3080
+ };
3081
+ } else if (value instanceof HTMLCanvasElement) {
3082
+ const name = "HTMLImageElement";
3083
+ const src = value.toDataURL();
3084
+ return {
3085
+ rr_type: name,
3086
+ src
3087
+ };
3088
+ } else if (value instanceof ImageData) {
3089
+ const name = value.constructor.name;
3090
+ return {
3091
+ rr_type: name,
3092
+ args: [serializeArg(value.data, win, ctx), value.width, value.height]
3093
+ };
3094
+ } else if (isInstanceOfWebGLObject(value, win) || typeof value === "object") {
3095
+ const name = value.constructor.name;
3096
+ const index = saveWebGLVar(value, win, ctx);
3097
+ return {
3098
+ rr_type: name,
3099
+ index
3100
+ };
3101
+ }
3102
+ return value;
3103
+ }
3104
+ var serializeArgs = (args, win, ctx) => {
3105
+ return [...args].map((arg) => serializeArg(arg, win, ctx));
3106
+ };
3107
+ var isInstanceOfWebGLObject = (value, win) => {
3108
+ const webGLConstructorNames = [
3109
+ "WebGLActiveInfo",
3110
+ "WebGLBuffer",
3111
+ "WebGLFramebuffer",
3112
+ "WebGLProgram",
3113
+ "WebGLRenderbuffer",
3114
+ "WebGLShader",
3115
+ "WebGLShaderPrecisionFormat",
3116
+ "WebGLTexture",
3117
+ "WebGLUniformLocation",
3118
+ "WebGLVertexArrayObject",
3119
+ "WebGLVertexArrayObjectOES"
3120
+ ];
3121
+ const supportedWebGLConstructorNames = webGLConstructorNames.filter((name) => typeof win[name] === "function");
3122
+ return Boolean(supportedWebGLConstructorNames.find((name) => value instanceof win[name]));
3123
+ };
3124
+
3125
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js
3126
+ function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
3127
+ const handlers = [];
3128
+ const props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
3129
+ for (const prop of props2D) {
3130
+ try {
3131
+ if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
3132
+ continue;
3133
+ }
3134
+ const restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
3135
+ return function(...args) {
3136
+ if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
3137
+ setTimeout(() => {
3138
+ const recordArgs = serializeArgs([...args], win, this);
3139
+ cb(this.canvas, {
3140
+ type: CanvasContext["2D"],
3141
+ property: prop,
3142
+ args: recordArgs
3143
+ });
3144
+ }, 0);
3145
+ }
3146
+ return original.apply(this, args);
3147
+ };
3148
+ });
3149
+ handlers.push(restoreHandler);
3150
+ } catch (_a) {
3151
+ const hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
3152
+ set(v) {
3153
+ cb(this.canvas, {
3154
+ type: CanvasContext["2D"],
3155
+ property: prop,
3156
+ args: [v],
3157
+ setter: true
3158
+ });
3159
+ }
3160
+ });
3161
+ handlers.push(hookHandler);
3162
+ }
3163
+ }
3164
+ return () => {
3165
+ handlers.forEach((h) => h());
3166
+ };
3167
+ }
3168
+
3169
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js
3170
+ function initCanvasContextObserver(win, blockClass, blockSelector) {
3171
+ const handlers = [];
3172
+ try {
3173
+ const restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
3174
+ return function(contextType, ...args) {
3175
+ if (!isBlocked(this, blockClass, blockSelector, true)) {
3176
+ if (!("__context" in this))
3177
+ this.__context = contextType;
3178
+ }
3179
+ return original.apply(this, [contextType, ...args]);
3180
+ };
3181
+ });
3182
+ handlers.push(restoreHandler);
3183
+ } catch (_a) {
3184
+ console.error("failed to patch HTMLCanvasElement.prototype.getContext");
3185
+ }
3186
+ return () => {
3187
+ handlers.forEach((h) => h());
3188
+ };
3189
+ }
3190
+
3191
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js
3192
+ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, mirror2, win) {
3193
+ const handlers = [];
3194
+ const props = Object.getOwnPropertyNames(prototype);
3195
+ for (const prop of props) {
3196
+ if ([
3197
+ "isContextLost",
3198
+ "canvas",
3199
+ "drawingBufferWidth",
3200
+ "drawingBufferHeight"
3201
+ ].includes(prop)) {
3202
+ continue;
3203
+ }
3204
+ try {
3205
+ if (typeof prototype[prop] !== "function") {
3206
+ continue;
3207
+ }
3208
+ const restoreHandler = patch(prototype, prop, function(original) {
3209
+ return function(...args) {
3210
+ const result = original.apply(this, args);
3211
+ saveWebGLVar(result, win, this);
3212
+ if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
3213
+ const recordArgs = serializeArgs([...args], win, this);
3214
+ const mutation = {
3215
+ type,
3216
+ property: prop,
3217
+ args: recordArgs
3218
+ };
3219
+ cb(this.canvas, mutation);
3220
+ }
3221
+ return result;
3222
+ };
3223
+ });
3224
+ handlers.push(restoreHandler);
3225
+ } catch (_a) {
3226
+ const hookHandler = hookSetter(prototype, prop, {
3227
+ set(v) {
3228
+ cb(this.canvas, {
3229
+ type,
3230
+ property: prop,
3231
+ args: [v],
3232
+ setter: true
3233
+ });
3234
+ }
3235
+ });
3236
+ handlers.push(hookHandler);
3237
+ }
3238
+ }
3239
+ return handlers;
3240
+ }
3241
+ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, mirror2) {
3242
+ const handlers = [];
3243
+ handlers.push(...patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, mirror2, win));
3244
+ if (typeof win.WebGL2RenderingContext !== "undefined") {
3245
+ handlers.push(...patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, mirror2, win));
3246
+ }
3247
+ return () => {
3248
+ handlers.forEach((h) => h());
3249
+ };
3250
+ }
3251
+
3252
+ // ../../node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js
3253
+ var WorkerClass = null;
3254
+ try {
3255
+ WorkerThreads = typeof module !== "undefined" && typeof module.require === "function" && module.require("worker_threads") || typeof __non_webpack_require__ === "function" && __non_webpack_require__("worker_threads") || typeof __require === "function" && __require("worker_threads");
3256
+ WorkerClass = WorkerThreads.Worker;
3257
+ } catch (e) {
3258
+ }
3259
+ var WorkerThreads;
3260
+
3261
+ // ../../node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js
3262
+ function decodeBase64(base64, enableUnicode) {
3263
+ return Buffer.from(base64, "base64").toString(enableUnicode ? "utf16" : "utf8");
3264
+ }
3265
+ function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
3266
+ var sourcemap = sourcemapArg === void 0 ? null : sourcemapArg;
3267
+ var enableUnicode = enableUnicodeArg === void 0 ? false : enableUnicodeArg;
3268
+ var source = decodeBase64(base64, enableUnicode);
3269
+ var start = source.indexOf("\n", 10) + 1;
3270
+ var body = source.substring(start) + (sourcemap ? "//# sourceMappingURL=" + sourcemap : "");
3271
+ return function WorkerFactory2(options) {
3272
+ return new WorkerClass(body, Object.assign({}, options, { eval: true }));
3273
+ };
3274
+ }
3275
+
3276
+ // ../../node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js
3277
+ function decodeBase642(base64, enableUnicode) {
3278
+ var binaryString = atob(base64);
3279
+ if (enableUnicode) {
3280
+ var binaryView = new Uint8Array(binaryString.length);
3281
+ for (var i = 0, n = binaryString.length; i < n; ++i) {
3282
+ binaryView[i] = binaryString.charCodeAt(i);
3283
+ }
3284
+ return String.fromCharCode.apply(null, new Uint16Array(binaryView.buffer));
3285
+ }
3286
+ return binaryString;
3287
+ }
3288
+ function createURL(base64, sourcemapArg, enableUnicodeArg) {
3289
+ var sourcemap = sourcemapArg === void 0 ? null : sourcemapArg;
3290
+ var enableUnicode = enableUnicodeArg === void 0 ? false : enableUnicodeArg;
3291
+ var source = decodeBase642(base64, enableUnicode);
3292
+ var start = source.indexOf("\n", 10) + 1;
3293
+ var body = source.substring(start) + (sourcemap ? "//# sourceMappingURL=" + sourcemap : "");
3294
+ var blob = new Blob([body], { type: "application/javascript" });
3295
+ return URL.createObjectURL(blob);
3296
+ }
3297
+ function createBase64WorkerFactory2(base64, sourcemapArg, enableUnicodeArg) {
3298
+ var url;
3299
+ return function WorkerFactory2(options) {
3300
+ url = url || createURL(base64, sourcemapArg, enableUnicodeArg);
3301
+ return new Worker(url, options);
3302
+ };
3303
+ }
3304
+
3305
+ // ../../node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js
3306
+ var kIsNodeJS = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
3307
+ function isNodeJS() {
3308
+ return kIsNodeJS;
3309
+ }
3310
+
3311
+ // ../../node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js
3312
+ function createBase64WorkerFactory3(base64, sourcemapArg, enableUnicodeArg) {
3313
+ if (isNodeJS()) {
3314
+ return createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg);
3315
+ }
3316
+ return createBase64WorkerFactory2(base64, sourcemapArg, enableUnicodeArg);
3317
+ }
3318
+
3319
+ // ../../node_modules/rrweb/es/rrweb/_virtual/image-bitmap-data-url-worker.js
3320
+ var WorkerFactory = createBase64WorkerFactory3("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=", null, false);
3321
+
3322
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js
3323
+ var CanvasManager = class {
3324
+ constructor(options) {
3325
+ this.pendingCanvasMutations = /* @__PURE__ */ new Map();
3326
+ this.rafStamps = { latestId: 0, invokeId: null };
3327
+ this.frozen = false;
3328
+ this.locked = false;
3329
+ this.processMutation = (target, mutation) => {
3330
+ const newFrame = this.rafStamps.invokeId && this.rafStamps.latestId !== this.rafStamps.invokeId;
3331
+ if (newFrame || !this.rafStamps.invokeId)
3332
+ this.rafStamps.invokeId = this.rafStamps.latestId;
3333
+ if (!this.pendingCanvasMutations.has(target)) {
3334
+ this.pendingCanvasMutations.set(target, []);
3335
+ }
3336
+ this.pendingCanvasMutations.get(target).push(mutation);
3337
+ };
3338
+ const { sampling = "all", win, blockClass, blockSelector, recordCanvas, dataURLOptions } = options;
3339
+ this.mutationCb = options.mutationCb;
3340
+ this.mirror = options.mirror;
3341
+ if (recordCanvas && sampling === "all")
3342
+ this.initCanvasMutationObserver(win, blockClass, blockSelector);
3343
+ if (recordCanvas && typeof sampling === "number")
3344
+ this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
3345
+ dataURLOptions
3346
+ });
3347
+ }
3348
+ reset() {
3349
+ this.pendingCanvasMutations.clear();
3350
+ this.resetObservers && this.resetObservers();
3351
+ }
3352
+ freeze() {
3353
+ this.frozen = true;
3354
+ }
3355
+ unfreeze() {
3356
+ this.frozen = false;
3357
+ }
3358
+ lock() {
3359
+ this.locked = true;
3360
+ }
3361
+ unlock() {
3362
+ this.locked = false;
3363
+ }
3364
+ initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
3365
+ const canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector);
3366
+ const snapshotInProgressMap = /* @__PURE__ */ new Map();
3367
+ const worker = new WorkerFactory();
3368
+ worker.onmessage = (e) => {
3369
+ const { id } = e.data;
3370
+ snapshotInProgressMap.set(id, false);
3371
+ if (!("base64" in e.data))
3372
+ return;
3373
+ const { base64, type, width, height } = e.data;
3374
+ this.mutationCb({
3375
+ id,
3376
+ type: CanvasContext["2D"],
3377
+ commands: [
3378
+ {
3379
+ property: "clearRect",
3380
+ args: [0, 0, width, height]
3381
+ },
3382
+ {
3383
+ property: "drawImage",
3384
+ args: [
3385
+ {
3386
+ rr_type: "ImageBitmap",
3387
+ args: [
3388
+ {
3389
+ rr_type: "Blob",
3390
+ data: [{ rr_type: "ArrayBuffer", base64 }],
3391
+ type
3392
+ }
3393
+ ]
3394
+ },
3395
+ 0,
3396
+ 0
3397
+ ]
3398
+ }
3399
+ ]
3400
+ });
3401
+ };
3402
+ const timeBetweenSnapshots = 1e3 / fps;
3403
+ let lastSnapshotTime = 0;
3404
+ let rafId;
3405
+ const getCanvas = () => {
3406
+ const matchedCanvas = [];
3407
+ win.document.querySelectorAll("canvas").forEach((canvas) => {
3408
+ if (!isBlocked(canvas, blockClass, blockSelector, true)) {
3409
+ matchedCanvas.push(canvas);
3410
+ }
3411
+ });
3412
+ return matchedCanvas;
3413
+ };
3414
+ const takeCanvasSnapshots = (timestamp) => {
3415
+ if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
3416
+ rafId = requestAnimationFrame(takeCanvasSnapshots);
3417
+ return;
3418
+ }
3419
+ lastSnapshotTime = timestamp;
3420
+ getCanvas().forEach((canvas) => __awaiter(this, void 0, void 0, function* () {
3421
+ var _a;
3422
+ const id = this.mirror.getId(canvas);
3423
+ if (snapshotInProgressMap.get(id))
3424
+ return;
3425
+ snapshotInProgressMap.set(id, true);
3426
+ if (["webgl", "webgl2"].includes(canvas.__context)) {
3427
+ const context = canvas.getContext(canvas.__context);
3428
+ if (((_a = context === null || context === void 0 ? void 0 : context.getContextAttributes()) === null || _a === void 0 ? void 0 : _a.preserveDrawingBuffer) === false) {
3429
+ context === null || context === void 0 ? void 0 : context.clear(context.COLOR_BUFFER_BIT);
3430
+ }
3431
+ }
3432
+ const bitmap = yield createImageBitmap(canvas);
3433
+ worker.postMessage({
3434
+ id,
3435
+ bitmap,
3436
+ width: canvas.width,
3437
+ height: canvas.height,
3438
+ dataURLOptions: options.dataURLOptions
3439
+ }, [bitmap]);
3440
+ }));
3441
+ rafId = requestAnimationFrame(takeCanvasSnapshots);
3442
+ };
3443
+ rafId = requestAnimationFrame(takeCanvasSnapshots);
3444
+ this.resetObservers = () => {
3445
+ canvasContextReset();
3446
+ cancelAnimationFrame(rafId);
3447
+ };
3448
+ }
3449
+ initCanvasMutationObserver(win, blockClass, blockSelector) {
3450
+ this.startRAFTimestamping();
3451
+ this.startPendingCanvasMutationFlusher();
3452
+ const canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector);
3453
+ const canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
3454
+ const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector, this.mirror);
3455
+ this.resetObservers = () => {
3456
+ canvasContextReset();
3457
+ canvas2DReset();
3458
+ canvasWebGL1and2Reset();
3459
+ };
3460
+ }
3461
+ startPendingCanvasMutationFlusher() {
3462
+ requestAnimationFrame(() => this.flushPendingCanvasMutations());
3463
+ }
3464
+ startRAFTimestamping() {
3465
+ const setLatestRAFTimestamp = (timestamp) => {
3466
+ this.rafStamps.latestId = timestamp;
3467
+ requestAnimationFrame(setLatestRAFTimestamp);
3468
+ };
3469
+ requestAnimationFrame(setLatestRAFTimestamp);
3470
+ }
3471
+ flushPendingCanvasMutations() {
3472
+ this.pendingCanvasMutations.forEach((values, canvas) => {
3473
+ const id = this.mirror.getId(canvas);
3474
+ this.flushPendingCanvasMutationFor(canvas, id);
3475
+ });
3476
+ requestAnimationFrame(() => this.flushPendingCanvasMutations());
3477
+ }
3478
+ flushPendingCanvasMutationFor(canvas, id) {
3479
+ if (this.frozen || this.locked) {
3480
+ return;
3481
+ }
3482
+ const valuesWithType = this.pendingCanvasMutations.get(canvas);
3483
+ if (!valuesWithType || id === -1)
3484
+ return;
3485
+ const values = valuesWithType.map((value) => {
3486
+ const rest = __rest(value, ["type"]);
3487
+ return rest;
3488
+ });
3489
+ const { type } = valuesWithType[0];
3490
+ this.mutationCb({ id, type, commands: values });
3491
+ this.pendingCanvasMutations.delete(canvas);
3492
+ }
3493
+ };
3494
+
3495
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js
3496
+ var StylesheetManager = class {
3497
+ constructor(options) {
3498
+ this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
3499
+ this.styleMirror = new StyleSheetMirror();
3500
+ this.mutationCb = options.mutationCb;
3501
+ this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
3502
+ }
3503
+ attachLinkElement(linkEl, childSn) {
3504
+ if ("_cssText" in childSn.attributes)
3505
+ this.mutationCb({
3506
+ adds: [],
3507
+ removes: [],
3508
+ texts: [],
3509
+ attributes: [
3510
+ {
3511
+ id: childSn.id,
3512
+ attributes: childSn.attributes
3513
+ }
3514
+ ]
3515
+ });
3516
+ this.trackLinkElement(linkEl);
3517
+ }
3518
+ trackLinkElement(linkEl) {
3519
+ if (this.trackedLinkElements.has(linkEl))
3520
+ return;
3521
+ this.trackedLinkElements.add(linkEl);
3522
+ this.trackStylesheetInLinkElement(linkEl);
3523
+ }
3524
+ adoptStyleSheets(sheets, hostId) {
3525
+ if (sheets.length === 0)
3526
+ return;
3527
+ const adoptedStyleSheetData = {
3528
+ id: hostId,
3529
+ styleIds: []
3530
+ };
3531
+ const styles = [];
3532
+ for (const sheet of sheets) {
3533
+ let styleId;
3534
+ if (!this.styleMirror.has(sheet)) {
3535
+ styleId = this.styleMirror.add(sheet);
3536
+ const rules = Array.from(sheet.rules || CSSRule);
3537
+ styles.push({
3538
+ styleId,
3539
+ rules: rules.map((r, index) => {
3540
+ return {
3541
+ rule: getCssRuleString(r),
3542
+ index
3543
+ };
3544
+ })
3545
+ });
3546
+ } else
3547
+ styleId = this.styleMirror.getId(sheet);
3548
+ adoptedStyleSheetData.styleIds.push(styleId);
3549
+ }
3550
+ if (styles.length > 0)
3551
+ adoptedStyleSheetData.styles = styles;
3552
+ this.adoptedStyleSheetCb(adoptedStyleSheetData);
3553
+ }
3554
+ reset() {
3555
+ this.styleMirror.reset();
3556
+ this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
3557
+ }
3558
+ trackStylesheetInLinkElement(linkEl) {
3559
+ }
3560
+ };
3561
+
3562
+ // ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js
3563
+ function wrapEvent(e) {
3564
+ return Object.assign(Object.assign({}, e), { timestamp: Date.now() });
3565
+ }
3566
+ var wrappedEmit;
3567
+ var takeFullSnapshot;
3568
+ var canvasManager;
3569
+ var recording = false;
3570
+ var mirror = createMirror();
3571
+ function record(options = {}) {
3572
+ const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = "rr-block", blockSelector = null, ignoreClass = "rr-ignore", maskTextClass = "rr-mask", maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, dataURLOptions = {}, mousemoveWait, recordCanvas = false, recordCrossOriginIframes = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, ignoreCSSAttributes = /* @__PURE__ */ new Set([]) } = options;
3573
+ const inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
3574
+ let passEmitsToParent = false;
3575
+ if (!inEmittingFrame) {
3576
+ try {
3577
+ window.parent.document;
3578
+ passEmitsToParent = false;
3579
+ } catch (e) {
3580
+ passEmitsToParent = true;
3581
+ }
3582
+ }
3583
+ if (inEmittingFrame && !emit) {
3584
+ throw new Error("emit function is required");
3585
+ }
3586
+ if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
3587
+ sampling.mousemove = mousemoveWait;
3588
+ }
3589
+ mirror.reset();
3590
+ const maskInputOptions = maskAllInputs === true ? {
3591
+ color: true,
3592
+ date: true,
3593
+ "datetime-local": true,
3594
+ email: true,
3595
+ month: true,
3596
+ number: true,
3597
+ range: true,
3598
+ search: true,
3599
+ tel: true,
3600
+ text: true,
3601
+ time: true,
3602
+ url: true,
3603
+ week: true,
3604
+ textarea: true,
3605
+ select: true,
3606
+ password: true
3607
+ } : _maskInputOptions !== void 0 ? _maskInputOptions : { password: true };
3608
+ const slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
3609
+ script: true,
3610
+ comment: true,
3611
+ headFavicon: true,
3612
+ headWhitespace: true,
3613
+ headMetaSocial: true,
3614
+ headMetaRobots: true,
3615
+ headMetaHttpEquiv: true,
3616
+ headMetaVerification: true,
3617
+ headMetaAuthorship: _slimDOMOptions === "all",
3618
+ headMetaDescKeywords: _slimDOMOptions === "all"
3619
+ } : _slimDOMOptions ? _slimDOMOptions : {};
3620
+ polyfill();
3621
+ let lastFullSnapshotEvent;
3622
+ let incrementalSnapshotCount = 0;
3623
+ const eventProcessor = (e) => {
3624
+ for (const plugin of plugins || []) {
3625
+ if (plugin.eventProcessor) {
3626
+ e = plugin.eventProcessor(e);
3627
+ }
3628
+ }
3629
+ if (packFn) {
3630
+ e = packFn(e);
3631
+ }
3632
+ return e;
3633
+ };
3634
+ wrappedEmit = (e, isCheckout) => {
3635
+ var _a;
3636
+ if (((_a = mutationBuffers[0]) === null || _a === void 0 ? void 0 : _a.isFrozen()) && e.type !== EventType.FullSnapshot && !(e.type === EventType.IncrementalSnapshot && e.data.source === IncrementalSource.Mutation)) {
3637
+ mutationBuffers.forEach((buf) => buf.unfreeze());
3638
+ }
3639
+ if (inEmittingFrame) {
3640
+ emit === null || emit === void 0 ? void 0 : emit(eventProcessor(e), isCheckout);
3641
+ } else if (passEmitsToParent) {
3642
+ const message = {
3643
+ type: "rrweb",
3644
+ event: eventProcessor(e),
3645
+ isCheckout
3646
+ };
3647
+ window.parent.postMessage(message, "*");
3648
+ }
3649
+ if (e.type === EventType.FullSnapshot) {
3650
+ lastFullSnapshotEvent = e;
3651
+ incrementalSnapshotCount = 0;
3652
+ } else if (e.type === EventType.IncrementalSnapshot) {
3653
+ if (e.data.source === IncrementalSource.Mutation && e.data.isAttachIframe) {
3654
+ return;
3655
+ }
3656
+ incrementalSnapshotCount++;
3657
+ const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
3658
+ const exceedTime = checkoutEveryNms && e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
3659
+ if (exceedCount || exceedTime) {
3660
+ takeFullSnapshot(true);
3661
+ }
3662
+ }
3663
+ };
3664
+ const wrappedMutationEmit = (m) => {
3665
+ wrappedEmit(wrapEvent({
3666
+ type: EventType.IncrementalSnapshot,
3667
+ data: Object.assign({ source: IncrementalSource.Mutation }, m)
3668
+ }));
3669
+ };
3670
+ const wrappedScrollEmit = (p) => wrappedEmit(wrapEvent({
3671
+ type: EventType.IncrementalSnapshot,
3672
+ data: Object.assign({ source: IncrementalSource.Scroll }, p)
3673
+ }));
3674
+ const wrappedCanvasMutationEmit = (p) => wrappedEmit(wrapEvent({
3675
+ type: EventType.IncrementalSnapshot,
3676
+ data: Object.assign({ source: IncrementalSource.CanvasMutation }, p)
3677
+ }));
3678
+ const wrappedAdoptedStyleSheetEmit = (a) => wrappedEmit(wrapEvent({
3679
+ type: EventType.IncrementalSnapshot,
3680
+ data: Object.assign({ source: IncrementalSource.AdoptedStyleSheet }, a)
3681
+ }));
3682
+ const stylesheetManager = new StylesheetManager({
3683
+ mutationCb: wrappedMutationEmit,
3684
+ adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
3685
+ });
3686
+ const iframeManager = new IframeManager({
3687
+ mirror,
3688
+ mutationCb: wrappedMutationEmit,
3689
+ stylesheetManager,
3690
+ recordCrossOriginIframes,
3691
+ wrappedEmit
3692
+ });
3693
+ for (const plugin of plugins || []) {
3694
+ if (plugin.getMirror)
3695
+ plugin.getMirror({
3696
+ nodeMirror: mirror,
3697
+ crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
3698
+ crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
3699
+ });
3700
+ }
3701
+ canvasManager = new CanvasManager({
3702
+ recordCanvas,
3703
+ mutationCb: wrappedCanvasMutationEmit,
3704
+ win: window,
3705
+ blockClass,
3706
+ blockSelector,
3707
+ mirror,
3708
+ sampling: sampling.canvas,
3709
+ dataURLOptions
3710
+ });
3711
+ const shadowDomManager = new ShadowDomManager({
3712
+ mutationCb: wrappedMutationEmit,
3713
+ scrollCb: wrappedScrollEmit,
3714
+ bypassOptions: {
3715
+ blockClass,
3716
+ blockSelector,
3717
+ maskTextClass,
3718
+ maskTextSelector,
3719
+ inlineStylesheet,
3720
+ maskInputOptions,
3721
+ dataURLOptions,
3722
+ maskTextFn,
3723
+ maskInputFn,
3724
+ recordCanvas,
3725
+ inlineImages,
3726
+ sampling,
3727
+ slimDOMOptions,
3728
+ iframeManager,
3729
+ stylesheetManager,
3730
+ canvasManager,
3731
+ keepIframeSrcFn
3732
+ },
3733
+ mirror
3734
+ });
3735
+ takeFullSnapshot = (isCheckout = false) => {
3736
+ var _a, _b, _c, _d, _e, _f;
3737
+ wrappedEmit(wrapEvent({
3738
+ type: EventType.Meta,
3739
+ data: {
3740
+ href: window.location.href,
3741
+ width: getWindowWidth(),
3742
+ height: getWindowHeight()
3743
+ }
3744
+ }), isCheckout);
3745
+ stylesheetManager.reset();
3746
+ mutationBuffers.forEach((buf) => buf.lock());
3747
+ const node = snapshot(document, {
3748
+ mirror,
3749
+ blockClass,
3750
+ blockSelector,
3751
+ maskTextClass,
3752
+ maskTextSelector,
3753
+ inlineStylesheet,
3754
+ maskAllInputs: maskInputOptions,
3755
+ maskTextFn,
3756
+ slimDOM: slimDOMOptions,
3757
+ dataURLOptions,
3758
+ recordCanvas,
3759
+ inlineImages,
3760
+ onSerialize: (n) => {
3761
+ if (isSerializedIframe(n, mirror)) {
3762
+ iframeManager.addIframe(n);
3763
+ }
3764
+ if (isSerializedStylesheet(n, mirror)) {
3765
+ stylesheetManager.trackLinkElement(n);
3766
+ }
3767
+ if (hasShadowRoot(n)) {
3768
+ shadowDomManager.addShadowRoot(n.shadowRoot, document);
3769
+ }
3770
+ },
3771
+ onIframeLoad: (iframe, childSn) => {
3772
+ iframeManager.attachIframe(iframe, childSn);
3773
+ shadowDomManager.observeAttachShadow(iframe);
3774
+ },
3775
+ onStylesheetLoad: (linkEl, childSn) => {
3776
+ stylesheetManager.attachLinkElement(linkEl, childSn);
3777
+ },
3778
+ keepIframeSrcFn
3779
+ });
3780
+ if (!node) {
3781
+ return console.warn("Failed to snapshot the document");
3782
+ }
3783
+ wrappedEmit(wrapEvent({
3784
+ type: EventType.FullSnapshot,
3785
+ data: {
3786
+ node,
3787
+ initialOffset: {
3788
+ left: window.pageXOffset !== void 0 ? window.pageXOffset : (document === null || document === void 0 ? void 0 : document.documentElement.scrollLeft) || ((_b = (_a = document === null || document === void 0 ? void 0 : document.body) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.scrollLeft) || ((_c = document === null || document === void 0 ? void 0 : document.body) === null || _c === void 0 ? void 0 : _c.scrollLeft) || 0,
3789
+ top: window.pageYOffset !== void 0 ? window.pageYOffset : (document === null || document === void 0 ? void 0 : document.documentElement.scrollTop) || ((_e = (_d = document === null || document === void 0 ? void 0 : document.body) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.scrollTop) || ((_f = document === null || document === void 0 ? void 0 : document.body) === null || _f === void 0 ? void 0 : _f.scrollTop) || 0
3790
+ }
3791
+ }
3792
+ }));
3793
+ mutationBuffers.forEach((buf) => buf.unlock());
3794
+ if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)
3795
+ stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
3796
+ };
3797
+ try {
3798
+ const handlers = [];
3799
+ handlers.push(on("DOMContentLoaded", () => {
3800
+ wrappedEmit(wrapEvent({
3801
+ type: EventType.DomContentLoaded,
3802
+ data: {}
3803
+ }));
3804
+ }));
3805
+ const observe = (doc) => {
3806
+ var _a;
3807
+ return initObservers({
3808
+ mutationCb: wrappedMutationEmit,
3809
+ mousemoveCb: (positions, source) => wrappedEmit(wrapEvent({
3810
+ type: EventType.IncrementalSnapshot,
3811
+ data: {
3812
+ source,
3813
+ positions
3814
+ }
3815
+ })),
3816
+ mouseInteractionCb: (d) => wrappedEmit(wrapEvent({
3817
+ type: EventType.IncrementalSnapshot,
3818
+ data: Object.assign({ source: IncrementalSource.MouseInteraction }, d)
3819
+ })),
3820
+ scrollCb: wrappedScrollEmit,
3821
+ viewportResizeCb: (d) => wrappedEmit(wrapEvent({
3822
+ type: EventType.IncrementalSnapshot,
3823
+ data: Object.assign({ source: IncrementalSource.ViewportResize }, d)
3824
+ })),
3825
+ inputCb: (v) => wrappedEmit(wrapEvent({
3826
+ type: EventType.IncrementalSnapshot,
3827
+ data: Object.assign({ source: IncrementalSource.Input }, v)
3828
+ })),
3829
+ mediaInteractionCb: (p) => wrappedEmit(wrapEvent({
3830
+ type: EventType.IncrementalSnapshot,
3831
+ data: Object.assign({ source: IncrementalSource.MediaInteraction }, p)
3832
+ })),
3833
+ styleSheetRuleCb: (r) => wrappedEmit(wrapEvent({
3834
+ type: EventType.IncrementalSnapshot,
3835
+ data: Object.assign({ source: IncrementalSource.StyleSheetRule }, r)
3836
+ })),
3837
+ styleDeclarationCb: (r) => wrappedEmit(wrapEvent({
3838
+ type: EventType.IncrementalSnapshot,
3839
+ data: Object.assign({ source: IncrementalSource.StyleDeclaration }, r)
3840
+ })),
3841
+ canvasMutationCb: wrappedCanvasMutationEmit,
3842
+ fontCb: (p) => wrappedEmit(wrapEvent({
3843
+ type: EventType.IncrementalSnapshot,
3844
+ data: Object.assign({ source: IncrementalSource.Font }, p)
3845
+ })),
3846
+ selectionCb: (p) => {
3847
+ wrappedEmit(wrapEvent({
3848
+ type: EventType.IncrementalSnapshot,
3849
+ data: Object.assign({ source: IncrementalSource.Selection }, p)
3850
+ }));
3851
+ },
3852
+ blockClass,
3853
+ ignoreClass,
3854
+ maskTextClass,
3855
+ maskTextSelector,
3856
+ maskInputOptions,
3857
+ inlineStylesheet,
3858
+ sampling,
3859
+ recordCanvas,
3860
+ inlineImages,
3861
+ userTriggeredOnInput,
3862
+ collectFonts,
3863
+ doc,
3864
+ maskInputFn,
3865
+ maskTextFn,
3866
+ keepIframeSrcFn,
3867
+ blockSelector,
3868
+ slimDOMOptions,
3869
+ dataURLOptions,
3870
+ mirror,
3871
+ iframeManager,
3872
+ stylesheetManager,
3873
+ shadowDomManager,
3874
+ canvasManager,
3875
+ ignoreCSSAttributes,
3876
+ plugins: ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.filter((p) => p.observer)) === null || _a === void 0 ? void 0 : _a.map((p) => ({
3877
+ observer: p.observer,
3878
+ options: p.options,
3879
+ callback: (payload) => wrappedEmit(wrapEvent({
3880
+ type: EventType.Plugin,
3881
+ data: {
3882
+ plugin: p.name,
3883
+ payload
3884
+ }
3885
+ }))
3886
+ }))) || []
3887
+ }, hooks);
3888
+ };
3889
+ iframeManager.addLoadListener((iframeEl) => {
3890
+ handlers.push(observe(iframeEl.contentDocument));
3891
+ });
3892
+ const init = () => {
3893
+ takeFullSnapshot();
3894
+ handlers.push(observe(document));
3895
+ recording = true;
3896
+ };
3897
+ if (document.readyState === "interactive" || document.readyState === "complete") {
3898
+ init();
3899
+ } else {
3900
+ handlers.push(on("load", () => {
3901
+ wrappedEmit(wrapEvent({
3902
+ type: EventType.Load,
3903
+ data: {}
3904
+ }));
3905
+ init();
3906
+ }, window));
3907
+ }
3908
+ return () => {
3909
+ handlers.forEach((h) => h());
3910
+ recording = false;
3911
+ };
3912
+ } catch (error) {
3913
+ console.warn(error);
3914
+ }
3915
+ }
3916
+ record.addCustomEvent = (tag, payload) => {
3917
+ if (!recording) {
3918
+ throw new Error("please add custom event after start recording");
3919
+ }
3920
+ wrappedEmit(wrapEvent({
3921
+ type: EventType.Custom,
3922
+ data: {
3923
+ tag,
3924
+ payload
3925
+ }
3926
+ }));
3927
+ };
3928
+ record.freezePage = () => {
3929
+ mutationBuffers.forEach((buf) => buf.freeze());
3930
+ };
3931
+ record.takeFullSnapshot = (isCheckout) => {
3932
+ if (!recording) {
3933
+ throw new Error("please take full snapshot after start recording");
3934
+ }
3935
+ takeFullSnapshot(isCheckout);
3936
+ };
3937
+ record.mirror = mirror;
3938
+
3939
+ // src/recorder.ts
3940
+ var RecorderCapture = class {
3941
+ onEvent;
3942
+ config;
3943
+ stopFn = null;
3944
+ started = false;
3945
+ constructor(onEvent2, config2) {
3946
+ this.onEvent = onEvent2;
3947
+ this.config = config2 ?? {};
3948
+ }
3949
+ start() {
3950
+ if (this.started) return;
3951
+ this.started = true;
3952
+ const { checkoutEveryNms, blockSelector, maskAllInputs, inlineStylesheet, sampling } = this.config;
3953
+ const result = record({
3954
+ emit: (event) => {
3955
+ if (!this.started) return;
3956
+ this.onEvent({
3957
+ type: "rrweb",
3958
+ data: event
3959
+ });
3960
+ },
3961
+ ...checkoutEveryNms !== void 0 && { checkoutEveryNms },
3962
+ ...blockSelector !== void 0 && { blockSelector },
3963
+ ...maskAllInputs !== void 0 && { maskAllInputs },
3964
+ ...inlineStylesheet !== void 0 && { inlineStylesheet },
3965
+ ...sampling !== void 0 && { sampling }
3966
+ });
3967
+ this.stopFn = result ?? null;
3968
+ }
3969
+ stop() {
3970
+ if (!this.started) return;
3971
+ this.started = false;
3972
+ this.stopFn?.();
3973
+ this.stopFn = null;
3974
+ }
3975
+ };
3976
+
3977
+ // src/index.ts
3978
+ var config = null;
3979
+ var transport = null;
3980
+ var consoleCapture = null;
3981
+ var errorCapture = null;
3982
+ var networkCapture = null;
3983
+ var recorderCapture = null;
3984
+ function onEvent(event) {
3985
+ transport?.enqueue(event);
3986
+ }
3987
+ var CedarReplay = {
3988
+ init(initConfig) {
3989
+ if (config) {
3990
+ CedarReplay.stop();
3991
+ }
3992
+ config = initConfig;
3993
+ const originalFetch = globalThis.fetch;
3994
+ transport = new Transport(
3995
+ {
3996
+ serverUrl: config.serverUrl,
3997
+ cedarSessionId: config.cedarSessionId,
3998
+ batchIntervalMs: config.batchIntervalMs,
3999
+ batchMaxSize: config.batchMaxSize
4000
+ },
4001
+ originalFetch
4002
+ );
4003
+ transport.start();
4004
+ consoleCapture = new ConsoleCapture(onEvent, config.console);
4005
+ consoleCapture.start();
4006
+ errorCapture = new ErrorCapture(onEvent);
4007
+ errorCapture.start();
4008
+ networkCapture = new NetworkCapture(onEvent, config.serverUrl);
4009
+ networkCapture.start();
4010
+ recorderCapture = new RecorderCapture(onEvent, config.recorder);
4011
+ recorderCapture.start();
4012
+ },
4013
+ stop() {
4014
+ recorderCapture?.stop();
4015
+ recorderCapture = null;
4016
+ networkCapture?.stop();
4017
+ networkCapture = null;
4018
+ errorCapture?.stop();
4019
+ errorCapture = null;
4020
+ consoleCapture?.stop();
4021
+ consoleCapture = null;
4022
+ transport?.stop();
4023
+ transport = null;
4024
+ config = null;
4025
+ },
4026
+ captureException(error, options) {
4027
+ errorCapture?.captureException(error, options);
4028
+ },
4029
+ track(name, properties) {
4030
+ if (!transport) return;
4031
+ const event = {
4032
+ type: "custom",
4033
+ timestamp: Date.now(),
4034
+ data: { name, properties }
4035
+ };
4036
+ transport.enqueue(event);
4037
+ },
4038
+ identify(userId, traits) {
4039
+ if (!transport) return;
4040
+ const event = {
4041
+ type: "custom",
4042
+ timestamp: Date.now(),
4043
+ data: {
4044
+ name: "__cedar_identify",
4045
+ properties: { userId, ...traits }
4046
+ }
4047
+ };
4048
+ transport.enqueue(event);
4049
+ },
4050
+ getSessionURL() {
4051
+ if (!config) return null;
4052
+ return `${config.serverUrl}/sessions/${config.cedarSessionId}`;
4053
+ }
4054
+ };
4055
+
4056
+ // src/global.ts
4057
+ globalThis.CedarReplay = CedarReplay;
4058
+ })();
4059
+ /*! Bundled license information:
4060
+
4061
+ rrweb/es/rrweb/ext/tslib/tslib.es6.js:
4062
+ (*! *****************************************************************************
4063
+ Copyright (c) Microsoft Corporation.
4064
+
4065
+ Permission to use, copy, modify, and/or distribute this software for any
4066
+ purpose with or without fee is hereby granted.
4067
+
4068
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
4069
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
4070
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
4071
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
4072
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
4073
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
4074
+ PERFORMANCE OF THIS SOFTWARE.
4075
+ ***************************************************************************** *)
4076
+ */