@highlight-run/rrweb 2.0.11 → 2.0.12

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.
Files changed (41) hide show
  1. package/dist/plugins/console-record.js +5 -5
  2. package/dist/plugins/console-record.min.js +5 -5
  3. package/dist/plugins/console-record.min.js.map +1 -1
  4. package/dist/plugins/console-replay.js +3 -3
  5. package/dist/plugins/console-replay.min.js +3 -3
  6. package/dist/plugins/console-replay.min.js.map +1 -1
  7. package/dist/record/rrweb-record-pack.js +2 -2
  8. package/dist/record/rrweb-record-pack.min.js +2 -2
  9. package/dist/record/rrweb-record-pack.min.js.map +1 -1
  10. package/dist/record/rrweb-record.js +3 -3
  11. package/dist/record/rrweb-record.min.js +3 -3
  12. package/dist/record/rrweb-record.min.js.map +1 -1
  13. package/dist/replay/rrweb-replay-unpack.js +4 -3
  14. package/dist/replay/rrweb-replay-unpack.min.js +4 -3
  15. package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
  16. package/dist/replay/rrweb-replay.js +4 -3
  17. package/dist/replay/rrweb-replay.min.js +4 -3
  18. package/dist/replay/rrweb-replay.min.js.map +1 -1
  19. package/dist/rrweb-all.js +25 -24
  20. package/dist/rrweb-all.min.js +25 -24
  21. package/dist/rrweb-all.min.js.map +1 -1
  22. package/dist/rrweb.js +15 -14
  23. package/dist/rrweb.min.js +15 -14
  24. package/dist/rrweb.min.js.map +1 -1
  25. package/es/rrweb/packages/rrdom/es/virtual-dom.js +63 -1
  26. package/es/rrweb/packages/rrweb/src/index.js +1 -1
  27. package/es/rrweb/packages/rrweb/src/record/index.js +1 -1
  28. package/es/rrweb/packages/rrweb/src/record/mutation.js +1 -1
  29. package/es/rrweb/packages/rrweb/src/record/observer.js +1 -1
  30. package/es/rrweb/packages/rrweb/src/replay/index.js +1 -1
  31. package/es/rrweb/packages/rrweb/src/utils.js +1 -1
  32. package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1871 -0
  33. package/lib/plugins/console-record.js +9 -1
  34. package/lib/plugins/console-replay.js +9 -1
  35. package/lib/record/rrweb-record-pack.js +9 -3
  36. package/lib/record/rrweb-record.js +1063 -17
  37. package/lib/replay/rrweb-replay-unpack.js +999 -47
  38. package/lib/replay/rrweb-replay.js +999 -47
  39. package/lib/rrweb-all.js +2020 -88
  40. package/lib/rrweb.js +2020 -88
  41. package/package.json +3 -3
package/lib/rrweb.js CHANGED
@@ -2,7 +2,1875 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var rrwebSnapshot = require('@highlight-run/rrweb-snapshot');
5
+ var NodeType$2;
6
+ (function (NodeType) {
7
+ NodeType[NodeType["Document"] = 0] = "Document";
8
+ NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
9
+ NodeType[NodeType["Element"] = 2] = "Element";
10
+ NodeType[NodeType["Text"] = 3] = "Text";
11
+ NodeType[NodeType["CDATA"] = 4] = "CDATA";
12
+ NodeType[NodeType["Comment"] = 5] = "Comment";
13
+ })(NodeType$2 || (NodeType$2 = {}));
14
+
15
+ function isElement(n) {
16
+ return n.nodeType === n.ELEMENT_NODE;
17
+ }
18
+ function isShadowRoot(n) {
19
+ var _a;
20
+ var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;
21
+ return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n);
22
+ }
23
+ var Mirror$2 = (function () {
24
+ function Mirror() {
25
+ this.idNodeMap = new Map();
26
+ this.nodeMetaMap = new WeakMap();
27
+ }
28
+ Mirror.prototype.getId = function (n) {
29
+ var _a;
30
+ if (!n)
31
+ return -1;
32
+ var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
33
+ return id !== null && id !== void 0 ? id : -1;
34
+ };
35
+ Mirror.prototype.getNode = function (id) {
36
+ return this.idNodeMap.get(id) || null;
37
+ };
38
+ Mirror.prototype.getIds = function () {
39
+ return Array.from(this.idNodeMap.keys());
40
+ };
41
+ Mirror.prototype.getMeta = function (n) {
42
+ return this.nodeMetaMap.get(n) || null;
43
+ };
44
+ Mirror.prototype.removeNodeFromMap = function (n) {
45
+ var _this = this;
46
+ var id = this.getId(n);
47
+ this.idNodeMap["delete"](id);
48
+ if (n.childNodes) {
49
+ n.childNodes.forEach(function (childNode) {
50
+ return _this.removeNodeFromMap(childNode);
51
+ });
52
+ }
53
+ };
54
+ Mirror.prototype.has = function (id) {
55
+ return this.idNodeMap.has(id);
56
+ };
57
+ Mirror.prototype.hasNode = function (node) {
58
+ return this.nodeMetaMap.has(node);
59
+ };
60
+ Mirror.prototype.add = function (n, meta) {
61
+ var id = meta.id;
62
+ this.idNodeMap.set(id, n);
63
+ this.nodeMetaMap.set(n, meta);
64
+ };
65
+ Mirror.prototype.replace = function (id, n) {
66
+ this.idNodeMap.set(id, n);
67
+ };
68
+ Mirror.prototype.reset = function () {
69
+ this.idNodeMap = new Map();
70
+ this.nodeMetaMap = new WeakMap();
71
+ };
72
+ return Mirror;
73
+ }());
74
+ function createMirror$2() {
75
+ return new Mirror$2();
76
+ }
77
+ function maskInputValue(_a) {
78
+ var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;
79
+ var text = value || '';
80
+ if (maskInputOptions[tagName.toLowerCase()] ||
81
+ maskInputOptions[type]) {
82
+ if (maskInputFn) {
83
+ text = maskInputFn(text);
84
+ }
85
+ else {
86
+ text = '*'.repeat(text.length);
87
+ }
88
+ }
89
+ return text;
90
+ }
91
+ var ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';
92
+ function is2DCanvasBlank(canvas) {
93
+ var ctx = canvas.getContext('2d');
94
+ if (!ctx)
95
+ return true;
96
+ var chunkSize = 50;
97
+ for (var x = 0; x < canvas.width; x += chunkSize) {
98
+ for (var y = 0; y < canvas.height; y += chunkSize) {
99
+ var getImageData = ctx.getImageData;
100
+ var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData
101
+ ? getImageData[ORIGINAL_ATTRIBUTE_NAME]
102
+ : getImageData;
103
+ var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
104
+ if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))
105
+ return false;
106
+ }
107
+ }
108
+ return true;
109
+ }
110
+ function obfuscateText(text) {
111
+ text = text.replace(/[^ -~]+/g, '');
112
+ text =
113
+ (text === null || text === void 0 ? void 0 : text.split(' ').map(function (word) { return Math.random().toString(20).substr(2, word.length); }).join(' ')) || '';
114
+ return text;
115
+ }
116
+
117
+ var _id = 1;
118
+ var tagNameRegex = new RegExp('[^a-z0-9-_:]');
119
+ var IGNORED_NODE = -2;
120
+ function genId() {
121
+ return _id++;
122
+ }
123
+ function getValidTagName$1(element) {
124
+ if (element instanceof HTMLFormElement) {
125
+ return 'form';
126
+ }
127
+ var processedTagName = element.tagName.toLowerCase().trim();
128
+ if (tagNameRegex.test(processedTagName)) {
129
+ return 'div';
130
+ }
131
+ return processedTagName;
132
+ }
133
+ function getCssRulesString(s) {
134
+ try {
135
+ var rules = s.rules || s.cssRules;
136
+ return rules ? Array.from(rules).map(getCssRuleString).join('') : null;
137
+ }
138
+ catch (error) {
139
+ return null;
140
+ }
141
+ }
142
+ function getCssRuleString(rule) {
143
+ var cssStringified = rule.cssText;
144
+ if (isCSSImportRule(rule)) {
145
+ try {
146
+ cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
147
+ }
148
+ catch (_a) {
149
+ }
150
+ }
151
+ return cssStringified;
152
+ }
153
+ function isCSSImportRule(rule) {
154
+ return 'styleSheet' in rule;
155
+ }
156
+ function stringifyStyleSheet(sheet) {
157
+ return sheet.cssRules
158
+ ? Array.from(sheet.cssRules)
159
+ .map(function (rule) { return rule.cssText || ''; })
160
+ .join('')
161
+ : '';
162
+ }
163
+ function extractOrigin(url) {
164
+ var origin = '';
165
+ if (url.indexOf('//') > -1) {
166
+ origin = url.split('/').slice(0, 3).join('/');
167
+ }
168
+ else {
169
+ origin = url.split('/')[0];
170
+ }
171
+ origin = origin.split('?')[0];
172
+ return origin;
173
+ }
174
+ var canvasService;
175
+ var canvasCtx;
176
+ var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
177
+ var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/;
178
+ var DATA_URI = /^(data:)([^,]*),(.*)/i;
179
+ function absoluteToStylesheet(cssText, href) {
180
+ return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {
181
+ var filePath = path1 || path2 || path3;
182
+ var maybeQuote = quote1 || quote2 || '';
183
+ if (!filePath) {
184
+ return origin;
185
+ }
186
+ if (!RELATIVE_PATH.test(filePath)) {
187
+ return "url(" + maybeQuote + filePath + maybeQuote + ")";
188
+ }
189
+ if (DATA_URI.test(filePath)) {
190
+ return "url(" + maybeQuote + filePath + maybeQuote + ")";
191
+ }
192
+ if (filePath[0] === '/') {
193
+ return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
194
+ }
195
+ var stack = href.split('/');
196
+ var parts = filePath.split('/');
197
+ stack.pop();
198
+ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
199
+ var part = parts_1[_i];
200
+ if (part === '.') {
201
+ continue;
202
+ }
203
+ else if (part === '..') {
204
+ stack.pop();
205
+ }
206
+ else {
207
+ stack.push(part);
208
+ }
209
+ }
210
+ return "url(" + maybeQuote + stack.join('/') + maybeQuote + ")";
211
+ });
212
+ }
213
+ var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
214
+ var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
215
+ function getAbsoluteSrcsetString(doc, attributeValue) {
216
+ if (attributeValue.trim() === '') {
217
+ return attributeValue;
218
+ }
219
+ var pos = 0;
220
+ function collectCharacters(regEx) {
221
+ var chars;
222
+ var match = regEx.exec(attributeValue.substring(pos));
223
+ if (match) {
224
+ chars = match[0];
225
+ pos += chars.length;
226
+ return chars;
227
+ }
228
+ return '';
229
+ }
230
+ var output = [];
231
+ while (true) {
232
+ collectCharacters(SRCSET_COMMAS_OR_SPACES);
233
+ if (pos >= attributeValue.length) {
234
+ break;
235
+ }
236
+ var url = collectCharacters(SRCSET_NOT_SPACES);
237
+ if (url.slice(-1) === ',') {
238
+ url = absoluteToDoc(doc, url.substring(0, url.length - 1));
239
+ output.push(url);
240
+ }
241
+ else {
242
+ var descriptorsStr = '';
243
+ url = absoluteToDoc(doc, url);
244
+ var inParens = false;
245
+ while (true) {
246
+ var c = attributeValue.charAt(pos);
247
+ if (c === '') {
248
+ output.push((url + descriptorsStr).trim());
249
+ break;
250
+ }
251
+ else if (!inParens) {
252
+ if (c === ',') {
253
+ pos += 1;
254
+ output.push((url + descriptorsStr).trim());
255
+ break;
256
+ }
257
+ else if (c === '(') {
258
+ inParens = true;
259
+ }
260
+ }
261
+ else {
262
+ if (c === ')') {
263
+ inParens = false;
264
+ }
265
+ }
266
+ descriptorsStr += c;
267
+ pos += 1;
268
+ }
269
+ }
270
+ }
271
+ return output.join(', ');
272
+ }
273
+ function absoluteToDoc(doc, attributeValue) {
274
+ if (!attributeValue || attributeValue.trim() === '') {
275
+ return attributeValue;
276
+ }
277
+ var a = doc.createElement('a');
278
+ a.href = attributeValue;
279
+ return a.href;
280
+ }
281
+ function isSVGElement(el) {
282
+ return Boolean(el.tagName === 'svg' || el.ownerSVGElement);
283
+ }
284
+ function getHref() {
285
+ var a = document.createElement('a');
286
+ a.href = '';
287
+ return a.href;
288
+ }
289
+ function transformAttribute(doc, tagName, name, value) {
290
+ if (name === 'src' || (name === 'href' && value)) {
291
+ return absoluteToDoc(doc, value);
292
+ }
293
+ else if (name === 'xlink:href' && value && value[0] !== '#') {
294
+ return absoluteToDoc(doc, value);
295
+ }
296
+ else if (name === 'background' &&
297
+ value &&
298
+ (tagName === 'table' || tagName === 'td' || tagName === 'th')) {
299
+ return absoluteToDoc(doc, value);
300
+ }
301
+ else if (name === 'srcset' && value) {
302
+ return getAbsoluteSrcsetString(doc, value);
303
+ }
304
+ else if (name === 'style' && value) {
305
+ return absoluteToStylesheet(value, getHref());
306
+ }
307
+ else if (tagName === 'object' && name === 'data' && value) {
308
+ return absoluteToDoc(doc, value);
309
+ }
310
+ else {
311
+ return value;
312
+ }
313
+ }
314
+ function _isBlockedElement(element, blockClass, blockSelector) {
315
+ if (typeof blockClass === 'string') {
316
+ if (element.classList.contains(blockClass)) {
317
+ return true;
318
+ }
319
+ }
320
+ else {
321
+ for (var eIndex = element.classList.length; eIndex--;) {
322
+ var className = element.classList[eIndex];
323
+ if (blockClass.test(className)) {
324
+ return true;
325
+ }
326
+ }
327
+ }
328
+ if (blockSelector) {
329
+ return element.matches(blockSelector);
330
+ }
331
+ return false;
332
+ }
333
+ function classMatchesRegex(node, regex, checkAncestors) {
334
+ if (!node)
335
+ return false;
336
+ if (node.nodeType !== node.ELEMENT_NODE) {
337
+ if (!checkAncestors)
338
+ return false;
339
+ return classMatchesRegex(node.parentNode, regex, checkAncestors);
340
+ }
341
+ for (var eIndex = node.classList.length; eIndex--;) {
342
+ var className = node.classList[eIndex];
343
+ if (regex.test(className)) {
344
+ return true;
345
+ }
346
+ }
347
+ if (!checkAncestors)
348
+ return false;
349
+ return classMatchesRegex(node.parentNode, regex, checkAncestors);
350
+ }
351
+ function needMaskingText(node, maskTextClass, maskTextSelector) {
352
+ var el = node.nodeType === node.ELEMENT_NODE
353
+ ? node
354
+ : node.parentElement;
355
+ if (el === null)
356
+ return false;
357
+ if (typeof maskTextClass === 'string') {
358
+ if (el.classList.contains(maskTextClass))
359
+ return true;
360
+ if (el.closest("." + maskTextClass))
361
+ return true;
362
+ }
363
+ else {
364
+ if (classMatchesRegex(el, maskTextClass, true))
365
+ return true;
366
+ }
367
+ if (maskTextSelector) {
368
+ if (el.matches(maskTextSelector))
369
+ return true;
370
+ if (el.closest(maskTextSelector))
371
+ return true;
372
+ }
373
+ return false;
374
+ }
375
+ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
376
+ var win = iframeEl.contentWindow;
377
+ if (!win) {
378
+ return;
379
+ }
380
+ var fired = false;
381
+ var readyState;
382
+ try {
383
+ readyState = win.document.readyState;
384
+ }
385
+ catch (error) {
386
+ return;
387
+ }
388
+ if (readyState !== 'complete') {
389
+ var timer_1 = setTimeout(function () {
390
+ if (!fired) {
391
+ listener();
392
+ fired = true;
393
+ }
394
+ }, iframeLoadTimeout);
395
+ iframeEl.addEventListener('load', function () {
396
+ clearTimeout(timer_1);
397
+ fired = true;
398
+ listener();
399
+ });
400
+ return;
401
+ }
402
+ var blankUrl = 'about:blank';
403
+ if (win.location.href !== blankUrl ||
404
+ iframeEl.src === blankUrl ||
405
+ iframeEl.src === '') {
406
+ setTimeout(listener, 0);
407
+ return;
408
+ }
409
+ iframeEl.addEventListener('load', listener);
410
+ }
411
+ function isStylesheetLoaded(link) {
412
+ if (!link.getAttribute('href'))
413
+ return true;
414
+ return link.sheet !== null;
415
+ }
416
+ function onceStylesheetLoaded(link, listener, iframeLoadTimeout) {
417
+ var fired = false;
418
+ var styleSheetLoaded;
419
+ try {
420
+ styleSheetLoaded = link.sheet;
421
+ }
422
+ catch (error) {
423
+ return;
424
+ }
425
+ if (styleSheetLoaded)
426
+ return;
427
+ var timer = setTimeout(function () {
428
+ if (!fired) {
429
+ listener();
430
+ fired = true;
431
+ }
432
+ }, iframeLoadTimeout);
433
+ link.addEventListener('load', function () {
434
+ clearTimeout(timer);
435
+ fired = true;
436
+ listener();
437
+ });
438
+ }
439
+ function serializeNode(n, options) {
440
+ var doc = options.doc, mirror = 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, enableStrictPrivacy = options.enableStrictPrivacy;
441
+ var rootId = getRootId(doc, mirror);
442
+ switch (n.nodeType) {
443
+ case n.DOCUMENT_NODE:
444
+ if (n.compatMode !== 'CSS1Compat') {
445
+ return {
446
+ type: NodeType$2.Document,
447
+ childNodes: [],
448
+ compatMode: n.compatMode,
449
+ rootId: rootId
450
+ };
451
+ }
452
+ else {
453
+ return {
454
+ type: NodeType$2.Document,
455
+ childNodes: [],
456
+ rootId: rootId
457
+ };
458
+ }
459
+ case n.DOCUMENT_TYPE_NODE:
460
+ return {
461
+ type: NodeType$2.DocumentType,
462
+ name: n.name,
463
+ publicId: n.publicId,
464
+ systemId: n.systemId,
465
+ rootId: rootId
466
+ };
467
+ case n.ELEMENT_NODE:
468
+ return serializeElementNode(n, {
469
+ doc: doc,
470
+ blockClass: blockClass,
471
+ blockSelector: blockSelector,
472
+ inlineStylesheet: inlineStylesheet,
473
+ maskInputOptions: maskInputOptions,
474
+ maskInputFn: maskInputFn,
475
+ dataURLOptions: dataURLOptions,
476
+ inlineImages: inlineImages,
477
+ recordCanvas: recordCanvas,
478
+ keepIframeSrcFn: keepIframeSrcFn,
479
+ newlyAddedElement: newlyAddedElement,
480
+ enableStrictPrivacy: enableStrictPrivacy,
481
+ rootId: rootId
482
+ });
483
+ case n.TEXT_NODE:
484
+ return serializeTextNode(n, {
485
+ maskTextClass: maskTextClass,
486
+ maskTextSelector: maskTextSelector,
487
+ maskTextFn: maskTextFn,
488
+ enableStrictPrivacy: enableStrictPrivacy,
489
+ rootId: rootId
490
+ });
491
+ case n.CDATA_SECTION_NODE:
492
+ return {
493
+ type: NodeType$2.CDATA,
494
+ textContent: '',
495
+ rootId: rootId
496
+ };
497
+ case n.COMMENT_NODE:
498
+ return {
499
+ type: NodeType$2.Comment,
500
+ textContent: n.textContent || '',
501
+ rootId: rootId
502
+ };
503
+ default:
504
+ return false;
505
+ }
506
+ }
507
+ function getRootId(doc, mirror) {
508
+ if (!mirror.hasNode(doc))
509
+ return undefined;
510
+ var docId = mirror.getId(doc);
511
+ return docId === 1 ? undefined : docId;
512
+ }
513
+ function serializeTextNode(n, options) {
514
+ var _a;
515
+ var maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, maskTextFn = options.maskTextFn, enableStrictPrivacy = options.enableStrictPrivacy, rootId = options.rootId;
516
+ var parentTagName = n.parentNode && n.parentNode.tagName;
517
+ var textContent = n.textContent;
518
+ var isStyle = parentTagName === 'STYLE' ? true : undefined;
519
+ var isScript = parentTagName === 'SCRIPT' ? true : undefined;
520
+ var textContentHandled = false;
521
+ if (isStyle && textContent) {
522
+ try {
523
+ if (n.nextSibling || n.previousSibling) {
524
+ }
525
+ else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
526
+ textContent = stringifyStyleSheet(n.parentNode.sheet);
527
+ }
528
+ }
529
+ catch (err) {
530
+ console.warn("Cannot get CSS styles from text's parentNode. Error: " + err, n);
531
+ }
532
+ textContent = absoluteToStylesheet(textContent, getHref());
533
+ textContentHandled = true;
534
+ }
535
+ if (isScript) {
536
+ textContent = 'SCRIPT_PLACEHOLDER';
537
+ textContentHandled = true;
538
+ }
539
+ else if (parentTagName === 'NOSCRIPT') {
540
+ textContent = '';
541
+ textContentHandled = true;
542
+ }
543
+ if (!isStyle &&
544
+ !isScript &&
545
+ textContent &&
546
+ needMaskingText(n, maskTextClass, maskTextSelector)) {
547
+ textContent = maskTextFn
548
+ ? maskTextFn(textContent)
549
+ : textContent.replace(/[\S]/g, '*');
550
+ }
551
+ if (enableStrictPrivacy && !textContentHandled && parentTagName) {
552
+ var IGNORE_TAG_NAMES = new Set([
553
+ 'HEAD',
554
+ 'TITLE',
555
+ 'STYLE',
556
+ 'SCRIPT',
557
+ 'HTML',
558
+ 'BODY',
559
+ 'NOSCRIPT',
560
+ ]);
561
+ if (!IGNORE_TAG_NAMES.has(parentTagName) && textContent) {
562
+ textContent = obfuscateText(textContent);
563
+ }
564
+ }
565
+ return {
566
+ type: NodeType$2.Text,
567
+ textContent: textContent || '',
568
+ isStyle: isStyle,
569
+ rootId: rootId
570
+ };
571
+ }
572
+ function serializeElementNode(n, options) {
573
+ 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, enableStrictPrivacy = options.enableStrictPrivacy, rootId = options.rootId;
574
+ var needBlock = _isBlockedElement(n, blockClass, blockSelector);
575
+ var tagName = getValidTagName$1(n);
576
+ var attributes = {};
577
+ var len = n.attributes.length;
578
+ for (var i = 0; i < len; i++) {
579
+ var attr = n.attributes[i];
580
+ attributes[attr.name] = transformAttribute(doc, tagName, attr.name, attr.value);
581
+ }
582
+ if (tagName === 'link' && inlineStylesheet) {
583
+ var stylesheet = Array.from(doc.styleSheets).find(function (s) {
584
+ return s.href === n.href;
585
+ });
586
+ var cssText = null;
587
+ if (stylesheet) {
588
+ cssText = getCssRulesString(stylesheet);
589
+ }
590
+ if (cssText) {
591
+ delete attributes.rel;
592
+ delete attributes.href;
593
+ attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
594
+ }
595
+ }
596
+ if (tagName === 'style' &&
597
+ n.sheet &&
598
+ !(n.innerText || n.textContent || '').trim().length) {
599
+ var cssText = getCssRulesString(n.sheet);
600
+ if (cssText) {
601
+ attributes._cssText = absoluteToStylesheet(cssText, getHref());
602
+ }
603
+ }
604
+ if (tagName === 'input' || tagName === 'textarea' || tagName === 'select') {
605
+ var value = n.value;
606
+ if (attributes.type !== 'radio' &&
607
+ attributes.type !== 'checkbox' &&
608
+ attributes.type !== 'submit' &&
609
+ attributes.type !== 'button' &&
610
+ value) {
611
+ attributes.value = maskInputValue({
612
+ type: attributes.type,
613
+ tagName: tagName,
614
+ value: value,
615
+ maskInputOptions: maskInputOptions,
616
+ maskInputFn: maskInputFn
617
+ });
618
+ }
619
+ else if (n.checked) {
620
+ attributes.checked = n.checked;
621
+ }
622
+ }
623
+ if (tagName === 'option') {
624
+ if (n.selected && !maskInputOptions['select']) {
625
+ attributes.selected = true;
626
+ }
627
+ else {
628
+ delete attributes.selected;
629
+ }
630
+ }
631
+ if (tagName === 'canvas' && recordCanvas) {
632
+ if (n.__context === '2d') {
633
+ if (!is2DCanvasBlank(n)) {
634
+ attributes.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
635
+ }
636
+ }
637
+ else if (!('__context' in n)) {
638
+ var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
639
+ var blankCanvas = document.createElement('canvas');
640
+ blankCanvas.width = n.width;
641
+ blankCanvas.height = n.height;
642
+ var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
643
+ if (canvasDataURL !== blankCanvasDataURL) {
644
+ attributes.rr_dataURL = canvasDataURL;
645
+ }
646
+ }
647
+ }
648
+ if (tagName === 'img' && inlineImages) {
649
+ if (!canvasService) {
650
+ canvasService = doc.createElement('canvas');
651
+ canvasCtx = canvasService.getContext('2d');
652
+ }
653
+ var image_1 = n;
654
+ var oldValue_1 = image_1.crossOrigin;
655
+ image_1.crossOrigin = 'anonymous';
656
+ var recordInlineImage = function () {
657
+ try {
658
+ canvasService.width = image_1.naturalWidth;
659
+ canvasService.height = image_1.naturalHeight;
660
+ canvasCtx.drawImage(image_1, 0, 0);
661
+ attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
662
+ }
663
+ catch (err) {
664
+ console.warn("Cannot inline img src=" + image_1.currentSrc + "! Error: " + err);
665
+ }
666
+ oldValue_1
667
+ ? (attributes.crossOrigin = oldValue_1)
668
+ : image_1.removeAttribute('crossorigin');
669
+ };
670
+ if (image_1.complete && image_1.naturalWidth !== 0)
671
+ recordInlineImage();
672
+ else
673
+ image_1.onload = recordInlineImage;
674
+ }
675
+ if (tagName === 'audio' || tagName === 'video') {
676
+ attributes.rr_mediaState = n.paused
677
+ ? 'paused'
678
+ : 'played';
679
+ attributes.rr_mediaCurrentTime = n.currentTime;
680
+ }
681
+ if (!newlyAddedElement) {
682
+ if (n.scrollLeft) {
683
+ attributes.rr_scrollLeft = n.scrollLeft;
684
+ }
685
+ if (n.scrollTop) {
686
+ attributes.rr_scrollTop = n.scrollTop;
687
+ }
688
+ }
689
+ if (needBlock || (tagName === 'img' && enableStrictPrivacy)) {
690
+ var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height;
691
+ attributes = {
692
+ "class": attributes["class"],
693
+ rr_width: width + "px",
694
+ rr_height: height + "px"
695
+ };
696
+ needBlock = true;
697
+ }
698
+ if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) {
699
+ if (!n.contentDocument) {
700
+ attributes.rr_src = attributes.src;
701
+ }
702
+ delete attributes.src;
703
+ }
704
+ return {
705
+ type: NodeType$2.Element,
706
+ tagName: tagName,
707
+ attributes: attributes,
708
+ childNodes: [],
709
+ isSVG: isSVGElement(n) || undefined,
710
+ needBlock: needBlock,
711
+ rootId: rootId
712
+ };
713
+ }
714
+ function lowerIfExists(maybeAttr) {
715
+ if (maybeAttr === undefined) {
716
+ return '';
717
+ }
718
+ else {
719
+ return maybeAttr.toLowerCase();
720
+ }
721
+ }
722
+ function slimDOMExcluded(sn, slimDOMOptions) {
723
+ if (slimDOMOptions.comment && sn.type === NodeType$2.Comment) {
724
+ return true;
725
+ }
726
+ else if (sn.type === NodeType$2.Element) {
727
+ if (slimDOMOptions.script &&
728
+ (sn.tagName === 'script' ||
729
+ (sn.tagName === 'link' &&
730
+ sn.attributes.rel === 'preload' &&
731
+ sn.attributes.as === 'script') ||
732
+ (sn.tagName === 'link' &&
733
+ sn.attributes.rel === 'prefetch' &&
734
+ typeof sn.attributes.href === 'string' &&
735
+ sn.attributes.href.endsWith('.js')))) {
736
+ return true;
737
+ }
738
+ else if (slimDOMOptions.headFavicon &&
739
+ ((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||
740
+ (sn.tagName === 'meta' &&
741
+ (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||
742
+ lowerIfExists(sn.attributes.name) === 'application-name' ||
743
+ lowerIfExists(sn.attributes.rel) === 'icon' ||
744
+ lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||
745
+ lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {
746
+ return true;
747
+ }
748
+ else if (sn.tagName === 'meta') {
749
+ if (slimDOMOptions.headMetaDescKeywords &&
750
+ lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
751
+ return true;
752
+ }
753
+ else if (slimDOMOptions.headMetaSocial &&
754
+ (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||
755
+ lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||
756
+ lowerIfExists(sn.attributes.name) === 'pinterest')) {
757
+ return true;
758
+ }
759
+ else if (slimDOMOptions.headMetaRobots &&
760
+ (lowerIfExists(sn.attributes.name) === 'robots' ||
761
+ lowerIfExists(sn.attributes.name) === 'googlebot' ||
762
+ lowerIfExists(sn.attributes.name) === 'bingbot')) {
763
+ return true;
764
+ }
765
+ else if (slimDOMOptions.headMetaHttpEquiv &&
766
+ sn.attributes['http-equiv'] !== undefined) {
767
+ return true;
768
+ }
769
+ else if (slimDOMOptions.headMetaAuthorship &&
770
+ (lowerIfExists(sn.attributes.name) === 'author' ||
771
+ lowerIfExists(sn.attributes.name) === 'generator' ||
772
+ lowerIfExists(sn.attributes.name) === 'framework' ||
773
+ lowerIfExists(sn.attributes.name) === 'publisher' ||
774
+ lowerIfExists(sn.attributes.name) === 'progid' ||
775
+ lowerIfExists(sn.attributes.property).match(/^article:/) ||
776
+ lowerIfExists(sn.attributes.property).match(/^product:/))) {
777
+ return true;
778
+ }
779
+ else if (slimDOMOptions.headMetaVerification &&
780
+ (lowerIfExists(sn.attributes.name) === 'google-site-verification' ||
781
+ lowerIfExists(sn.attributes.name) === 'yandex-verification' ||
782
+ lowerIfExists(sn.attributes.name) === 'csrf-token' ||
783
+ lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||
784
+ lowerIfExists(sn.attributes.name) === 'verify-v1' ||
785
+ lowerIfExists(sn.attributes.name) === 'verification' ||
786
+ lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {
787
+ return true;
788
+ }
789
+ }
790
+ }
791
+ return false;
792
+ }
793
+ function serializeNodeWithId(n, options) {
794
+ var doc = options.doc, mirror = 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 ? 5000 : _g, onStylesheetLoad = options.onStylesheetLoad, _h = options.stylesheetLoadTimeout, stylesheetLoadTimeout = _h === void 0 ? 5000 : _h, _j = options.keepIframeSrcFn, keepIframeSrcFn = _j === void 0 ? function () { return false; } : _j, _k = options.newlyAddedElement, newlyAddedElement = _k === void 0 ? false : _k, enableStrictPrivacy = options.enableStrictPrivacy;
795
+ var _l = options.preserveWhiteSpace, preserveWhiteSpace = _l === void 0 ? true : _l;
796
+ var _serializedNode = serializeNode(n, {
797
+ doc: doc,
798
+ mirror: mirror,
799
+ blockClass: blockClass,
800
+ blockSelector: blockSelector,
801
+ maskTextClass: maskTextClass,
802
+ maskTextSelector: maskTextSelector,
803
+ inlineStylesheet: inlineStylesheet,
804
+ maskInputOptions: maskInputOptions,
805
+ maskTextFn: maskTextFn,
806
+ maskInputFn: maskInputFn,
807
+ dataURLOptions: dataURLOptions,
808
+ inlineImages: inlineImages,
809
+ recordCanvas: recordCanvas,
810
+ keepIframeSrcFn: keepIframeSrcFn,
811
+ newlyAddedElement: newlyAddedElement,
812
+ enableStrictPrivacy: enableStrictPrivacy
813
+ });
814
+ if (!_serializedNode) {
815
+ console.warn(n, 'not serialized');
816
+ return null;
817
+ }
818
+ var id;
819
+ if (mirror.hasNode(n)) {
820
+ id = mirror.getId(n);
821
+ }
822
+ else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||
823
+ (!preserveWhiteSpace &&
824
+ _serializedNode.type === NodeType$2.Text &&
825
+ !_serializedNode.isStyle &&
826
+ !_serializedNode.textContent.replace(/^\s+|\s+$/gm, '').length)) {
827
+ id = IGNORED_NODE;
828
+ }
829
+ else {
830
+ id = genId();
831
+ }
832
+ if (id === IGNORED_NODE) {
833
+ return null;
834
+ }
835
+ var serializedNode = Object.assign(_serializedNode, { id: id });
836
+ mirror.add(n, serializedNode);
837
+ if (onSerialize) {
838
+ onSerialize(n);
839
+ }
840
+ var recordChild = !skipChild;
841
+ if (serializedNode.type === NodeType$2.Element) {
842
+ recordChild = recordChild && !serializedNode.needBlock;
843
+ if (serializedNode.needBlock && serializedNode.tagName === 'img') {
844
+ var clone = n.cloneNode();
845
+ clone.src = '';
846
+ mirror.add(clone, serializedNode);
847
+ }
848
+ delete serializedNode.needBlock;
849
+ if (n.shadowRoot)
850
+ serializedNode.isShadowHost = true;
851
+ }
852
+ if ((serializedNode.type === NodeType$2.Document ||
853
+ serializedNode.type === NodeType$2.Element) &&
854
+ recordChild) {
855
+ if (slimDOMOptions.headWhitespace &&
856
+ serializedNode.type === NodeType$2.Element &&
857
+ serializedNode.tagName === 'head') {
858
+ preserveWhiteSpace = false;
859
+ }
860
+ var bypassOptions = {
861
+ doc: doc,
862
+ mirror: mirror,
863
+ blockClass: blockClass,
864
+ blockSelector: blockSelector,
865
+ maskTextClass: maskTextClass,
866
+ maskTextSelector: maskTextSelector,
867
+ skipChild: skipChild,
868
+ inlineStylesheet: inlineStylesheet,
869
+ maskInputOptions: maskInputOptions,
870
+ maskTextFn: maskTextFn,
871
+ maskInputFn: maskInputFn,
872
+ slimDOMOptions: slimDOMOptions,
873
+ dataURLOptions: dataURLOptions,
874
+ inlineImages: inlineImages,
875
+ recordCanvas: recordCanvas,
876
+ preserveWhiteSpace: preserveWhiteSpace,
877
+ onSerialize: onSerialize,
878
+ onIframeLoad: onIframeLoad,
879
+ iframeLoadTimeout: iframeLoadTimeout,
880
+ onStylesheetLoad: onStylesheetLoad,
881
+ stylesheetLoadTimeout: stylesheetLoadTimeout,
882
+ keepIframeSrcFn: keepIframeSrcFn,
883
+ enableStrictPrivacy: enableStrictPrivacy
884
+ };
885
+ for (var _i = 0, _m = Array.from(n.childNodes); _i < _m.length; _i++) {
886
+ var childN = _m[_i];
887
+ var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
888
+ if (serializedChildNode) {
889
+ serializedNode.childNodes.push(serializedChildNode);
890
+ }
891
+ }
892
+ if (isElement(n) && n.shadowRoot) {
893
+ for (var _o = 0, _p = Array.from(n.shadowRoot.childNodes); _o < _p.length; _o++) {
894
+ var childN = _p[_o];
895
+ var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
896
+ if (serializedChildNode) {
897
+ serializedChildNode.isShadow = true;
898
+ serializedNode.childNodes.push(serializedChildNode);
899
+ }
900
+ }
901
+ }
902
+ }
903
+ if (n.parentNode && isShadowRoot(n.parentNode)) {
904
+ serializedNode.isShadow = true;
905
+ }
906
+ if (serializedNode.type === NodeType$2.Element &&
907
+ serializedNode.tagName === 'iframe') {
908
+ onceIframeLoaded(n, function () {
909
+ var iframeDoc = n.contentDocument;
910
+ if (iframeDoc && onIframeLoad) {
911
+ var serializedIframeNode = serializeNodeWithId(iframeDoc, {
912
+ doc: iframeDoc,
913
+ mirror: mirror,
914
+ blockClass: blockClass,
915
+ blockSelector: blockSelector,
916
+ maskTextClass: maskTextClass,
917
+ maskTextSelector: maskTextSelector,
918
+ skipChild: false,
919
+ inlineStylesheet: inlineStylesheet,
920
+ maskInputOptions: maskInputOptions,
921
+ maskTextFn: maskTextFn,
922
+ maskInputFn: maskInputFn,
923
+ slimDOMOptions: slimDOMOptions,
924
+ dataURLOptions: dataURLOptions,
925
+ inlineImages: inlineImages,
926
+ recordCanvas: recordCanvas,
927
+ preserveWhiteSpace: preserveWhiteSpace,
928
+ onSerialize: onSerialize,
929
+ onIframeLoad: onIframeLoad,
930
+ iframeLoadTimeout: iframeLoadTimeout,
931
+ onStylesheetLoad: onStylesheetLoad,
932
+ stylesheetLoadTimeout: stylesheetLoadTimeout,
933
+ keepIframeSrcFn: keepIframeSrcFn,
934
+ enableStrictPrivacy: enableStrictPrivacy
935
+ });
936
+ if (serializedIframeNode) {
937
+ onIframeLoad(n, serializedIframeNode);
938
+ }
939
+ }
940
+ }, iframeLoadTimeout);
941
+ }
942
+ if (serializedNode.type === NodeType$2.Element &&
943
+ serializedNode.tagName === 'link' &&
944
+ serializedNode.attributes.rel === 'stylesheet') {
945
+ onceStylesheetLoaded(n, function () {
946
+ if (onStylesheetLoad) {
947
+ var serializedLinkNode = serializeNodeWithId(n, {
948
+ doc: doc,
949
+ mirror: mirror,
950
+ blockClass: blockClass,
951
+ blockSelector: blockSelector,
952
+ maskTextClass: maskTextClass,
953
+ maskTextSelector: maskTextSelector,
954
+ skipChild: false,
955
+ inlineStylesheet: inlineStylesheet,
956
+ maskInputOptions: maskInputOptions,
957
+ maskTextFn: maskTextFn,
958
+ maskInputFn: maskInputFn,
959
+ slimDOMOptions: slimDOMOptions,
960
+ dataURLOptions: dataURLOptions,
961
+ inlineImages: inlineImages,
962
+ recordCanvas: recordCanvas,
963
+ preserveWhiteSpace: preserveWhiteSpace,
964
+ onSerialize: onSerialize,
965
+ onIframeLoad: onIframeLoad,
966
+ iframeLoadTimeout: iframeLoadTimeout,
967
+ onStylesheetLoad: onStylesheetLoad,
968
+ stylesheetLoadTimeout: stylesheetLoadTimeout,
969
+ keepIframeSrcFn: keepIframeSrcFn,
970
+ enableStrictPrivacy: enableStrictPrivacy
971
+ });
972
+ if (serializedLinkNode) {
973
+ onStylesheetLoad(n, serializedLinkNode);
974
+ }
975
+ }
976
+ }, stylesheetLoadTimeout);
977
+ if (isStylesheetLoaded(n) === false)
978
+ return null;
979
+ }
980
+ return serializedNode;
981
+ }
982
+ function snapshot(n, options) {
983
+ var _a = options || {}, _b = _a.mirror, mirror = _b === void 0 ? new Mirror$2() : _b, _c = _a.blockClass, blockClass = _c === void 0 ? 'highlight-block' : _c, _d = _a.blockSelector, blockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'highlight-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 () { return false; } : _m, _o = _a.enableStrictPrivacy, enableStrictPrivacy = _o === void 0 ? false : _o;
984
+ var maskInputOptions = maskAllInputs === true
985
+ ? {
986
+ color: true,
987
+ date: true,
988
+ 'datetime-local': true,
989
+ email: true,
990
+ month: true,
991
+ number: true,
992
+ range: true,
993
+ search: true,
994
+ tel: true,
995
+ text: true,
996
+ time: true,
997
+ url: true,
998
+ week: true,
999
+ textarea: true,
1000
+ select: true,
1001
+ password: true
1002
+ }
1003
+ : maskAllInputs === false
1004
+ ? {
1005
+ password: true
1006
+ }
1007
+ : maskAllInputs;
1008
+ var slimDOMOptions = slimDOM === true || slimDOM === 'all'
1009
+ ?
1010
+ {
1011
+ script: true,
1012
+ comment: true,
1013
+ headFavicon: true,
1014
+ headWhitespace: true,
1015
+ headMetaDescKeywords: slimDOM === 'all',
1016
+ headMetaSocial: true,
1017
+ headMetaRobots: true,
1018
+ headMetaHttpEquiv: true,
1019
+ headMetaAuthorship: true,
1020
+ headMetaVerification: true
1021
+ }
1022
+ : slimDOM === false
1023
+ ? {}
1024
+ : slimDOM;
1025
+ return serializeNodeWithId(n, {
1026
+ doc: n,
1027
+ mirror: mirror,
1028
+ blockClass: blockClass,
1029
+ blockSelector: blockSelector,
1030
+ maskTextClass: maskTextClass,
1031
+ maskTextSelector: maskTextSelector,
1032
+ skipChild: false,
1033
+ inlineStylesheet: inlineStylesheet,
1034
+ maskInputOptions: maskInputOptions,
1035
+ maskTextFn: maskTextFn,
1036
+ maskInputFn: maskInputFn,
1037
+ slimDOMOptions: slimDOMOptions,
1038
+ dataURLOptions: dataURLOptions,
1039
+ inlineImages: inlineImages,
1040
+ recordCanvas: recordCanvas,
1041
+ preserveWhiteSpace: preserveWhiteSpace,
1042
+ onSerialize: onSerialize,
1043
+ onIframeLoad: onIframeLoad,
1044
+ iframeLoadTimeout: iframeLoadTimeout,
1045
+ onStylesheetLoad: onStylesheetLoad,
1046
+ stylesheetLoadTimeout: stylesheetLoadTimeout,
1047
+ keepIframeSrcFn: keepIframeSrcFn,
1048
+ newlyAddedElement: false,
1049
+ enableStrictPrivacy: enableStrictPrivacy
1050
+ });
1051
+ }
1052
+
1053
+ var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
1054
+ function parse(css, options) {
1055
+ if (options === void 0) { options = {}; }
1056
+ var lineno = 1;
1057
+ var column = 1;
1058
+ function updatePosition(str) {
1059
+ var lines = str.match(/\n/g);
1060
+ if (lines) {
1061
+ lineno += lines.length;
1062
+ }
1063
+ var i = str.lastIndexOf('\n');
1064
+ column = i === -1 ? column + str.length : str.length - i;
1065
+ }
1066
+ function position() {
1067
+ var start = { line: lineno, column: column };
1068
+ return function (node) {
1069
+ node.position = new Position(start);
1070
+ whitespace();
1071
+ return node;
1072
+ };
1073
+ }
1074
+ var Position = (function () {
1075
+ function Position(start) {
1076
+ this.start = start;
1077
+ this.end = { line: lineno, column: column };
1078
+ this.source = options.source;
1079
+ }
1080
+ return Position;
1081
+ }());
1082
+ Position.prototype.content = css;
1083
+ var errorsList = [];
1084
+ function error(msg) {
1085
+ var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
1086
+ err.reason = msg;
1087
+ err.filename = options.source;
1088
+ err.line = lineno;
1089
+ err.column = column;
1090
+ err.source = css;
1091
+ if (options.silent) {
1092
+ errorsList.push(err);
1093
+ }
1094
+ else {
1095
+ throw err;
1096
+ }
1097
+ }
1098
+ function stylesheet() {
1099
+ var rulesList = rules();
1100
+ return {
1101
+ type: 'stylesheet',
1102
+ stylesheet: {
1103
+ source: options.source,
1104
+ rules: rulesList,
1105
+ parsingErrors: errorsList
1106
+ }
1107
+ };
1108
+ }
1109
+ function open() {
1110
+ return match(/^{\s*/);
1111
+ }
1112
+ function close() {
1113
+ return match(/^}/);
1114
+ }
1115
+ function rules() {
1116
+ var node;
1117
+ var rules = [];
1118
+ whitespace();
1119
+ comments(rules);
1120
+ while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
1121
+ if (node !== false) {
1122
+ rules.push(node);
1123
+ comments(rules);
1124
+ }
1125
+ }
1126
+ return rules;
1127
+ }
1128
+ function match(re) {
1129
+ var m = re.exec(css);
1130
+ if (!m) {
1131
+ return;
1132
+ }
1133
+ var str = m[0];
1134
+ updatePosition(str);
1135
+ css = css.slice(str.length);
1136
+ return m;
1137
+ }
1138
+ function whitespace() {
1139
+ match(/^\s*/);
1140
+ }
1141
+ function comments(rules) {
1142
+ if (rules === void 0) { rules = []; }
1143
+ var c;
1144
+ while ((c = comment())) {
1145
+ if (c !== false) {
1146
+ rules.push(c);
1147
+ }
1148
+ c = comment();
1149
+ }
1150
+ return rules;
1151
+ }
1152
+ function comment() {
1153
+ var pos = position();
1154
+ if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
1155
+ return;
1156
+ }
1157
+ var i = 2;
1158
+ while ('' !== css.charAt(i) &&
1159
+ ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
1160
+ ++i;
1161
+ }
1162
+ i += 2;
1163
+ if ('' === css.charAt(i - 1)) {
1164
+ return error('End of comment missing');
1165
+ }
1166
+ var str = css.slice(2, i - 2);
1167
+ column += 2;
1168
+ updatePosition(str);
1169
+ css = css.slice(i);
1170
+ column += 2;
1171
+ return pos({
1172
+ type: 'comment',
1173
+ comment: str
1174
+ });
1175
+ }
1176
+ function selector() {
1177
+ var m = match(/^([^{]+)/);
1178
+ if (!m) {
1179
+ return;
1180
+ }
1181
+ return trim(m[0])
1182
+ .replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
1183
+ .replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) {
1184
+ return m.replace(/,/g, '\u200C');
1185
+ })
1186
+ .split(/\s*(?![^(]*\)),\s*/)
1187
+ .map(function (s) {
1188
+ return s.replace(/\u200C/g, ',');
1189
+ });
1190
+ }
1191
+ function declaration() {
1192
+ var pos = position();
1193
+ var propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
1194
+ if (!propMatch) {
1195
+ return;
1196
+ }
1197
+ var prop = trim(propMatch[0]);
1198
+ if (!match(/^:\s*/)) {
1199
+ return error("property missing ':'");
1200
+ }
1201
+ var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
1202
+ var ret = pos({
1203
+ type: 'declaration',
1204
+ property: prop.replace(commentre, ''),
1205
+ value: val ? trim(val[0]).replace(commentre, '') : ''
1206
+ });
1207
+ match(/^[;\s]*/);
1208
+ return ret;
1209
+ }
1210
+ function declarations() {
1211
+ var decls = [];
1212
+ if (!open()) {
1213
+ return error("missing '{'");
1214
+ }
1215
+ comments(decls);
1216
+ var decl;
1217
+ while ((decl = declaration())) {
1218
+ if (decl !== false) {
1219
+ decls.push(decl);
1220
+ comments(decls);
1221
+ }
1222
+ decl = declaration();
1223
+ }
1224
+ if (!close()) {
1225
+ return error("missing '}'");
1226
+ }
1227
+ return decls;
1228
+ }
1229
+ function keyframe() {
1230
+ var m;
1231
+ var vals = [];
1232
+ var pos = position();
1233
+ while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) {
1234
+ vals.push(m[1]);
1235
+ match(/^,\s*/);
1236
+ }
1237
+ if (!vals.length) {
1238
+ return;
1239
+ }
1240
+ return pos({
1241
+ type: 'keyframe',
1242
+ values: vals,
1243
+ declarations: declarations()
1244
+ });
1245
+ }
1246
+ function atkeyframes() {
1247
+ var pos = position();
1248
+ var m = match(/^@([-\w]+)?keyframes\s*/);
1249
+ if (!m) {
1250
+ return;
1251
+ }
1252
+ var vendor = m[1];
1253
+ m = match(/^([-\w]+)\s*/);
1254
+ if (!m) {
1255
+ return error('@keyframes missing name');
1256
+ }
1257
+ var name = m[1];
1258
+ if (!open()) {
1259
+ return error("@keyframes missing '{'");
1260
+ }
1261
+ var frame;
1262
+ var frames = comments();
1263
+ while ((frame = keyframe())) {
1264
+ frames.push(frame);
1265
+ frames = frames.concat(comments());
1266
+ }
1267
+ if (!close()) {
1268
+ return error("@keyframes missing '}'");
1269
+ }
1270
+ return pos({
1271
+ type: 'keyframes',
1272
+ name: name,
1273
+ vendor: vendor,
1274
+ keyframes: frames
1275
+ });
1276
+ }
1277
+ function atsupports() {
1278
+ var pos = position();
1279
+ var m = match(/^@supports *([^{]+)/);
1280
+ if (!m) {
1281
+ return;
1282
+ }
1283
+ var supports = trim(m[1]);
1284
+ if (!open()) {
1285
+ return error("@supports missing '{'");
1286
+ }
1287
+ var style = comments().concat(rules());
1288
+ if (!close()) {
1289
+ return error("@supports missing '}'");
1290
+ }
1291
+ return pos({
1292
+ type: 'supports',
1293
+ supports: supports,
1294
+ rules: style
1295
+ });
1296
+ }
1297
+ function athost() {
1298
+ var pos = position();
1299
+ var m = match(/^@host\s*/);
1300
+ if (!m) {
1301
+ return;
1302
+ }
1303
+ if (!open()) {
1304
+ return error("@host missing '{'");
1305
+ }
1306
+ var style = comments().concat(rules());
1307
+ if (!close()) {
1308
+ return error("@host missing '}'");
1309
+ }
1310
+ return pos({
1311
+ type: 'host',
1312
+ rules: style
1313
+ });
1314
+ }
1315
+ function atmedia() {
1316
+ var pos = position();
1317
+ var m = match(/^@media *([^{]+)/);
1318
+ if (!m) {
1319
+ return;
1320
+ }
1321
+ var media = trim(m[1]);
1322
+ if (!open()) {
1323
+ return error("@media missing '{'");
1324
+ }
1325
+ var style = comments().concat(rules());
1326
+ if (!close()) {
1327
+ return error("@media missing '}'");
1328
+ }
1329
+ return pos({
1330
+ type: 'media',
1331
+ media: media,
1332
+ rules: style
1333
+ });
1334
+ }
1335
+ function atcustommedia() {
1336
+ var pos = position();
1337
+ var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
1338
+ if (!m) {
1339
+ return;
1340
+ }
1341
+ return pos({
1342
+ type: 'custom-media',
1343
+ name: trim(m[1]),
1344
+ media: trim(m[2])
1345
+ });
1346
+ }
1347
+ function atpage() {
1348
+ var pos = position();
1349
+ var m = match(/^@page */);
1350
+ if (!m) {
1351
+ return;
1352
+ }
1353
+ var sel = selector() || [];
1354
+ if (!open()) {
1355
+ return error("@page missing '{'");
1356
+ }
1357
+ var decls = comments();
1358
+ var decl;
1359
+ while ((decl = declaration())) {
1360
+ decls.push(decl);
1361
+ decls = decls.concat(comments());
1362
+ }
1363
+ if (!close()) {
1364
+ return error("@page missing '}'");
1365
+ }
1366
+ return pos({
1367
+ type: 'page',
1368
+ selectors: sel,
1369
+ declarations: decls
1370
+ });
1371
+ }
1372
+ function atdocument() {
1373
+ var pos = position();
1374
+ var m = match(/^@([-\w]+)?document *([^{]+)/);
1375
+ if (!m) {
1376
+ return;
1377
+ }
1378
+ var vendor = trim(m[1]);
1379
+ var doc = trim(m[2]);
1380
+ if (!open()) {
1381
+ return error("@document missing '{'");
1382
+ }
1383
+ var style = comments().concat(rules());
1384
+ if (!close()) {
1385
+ return error("@document missing '}'");
1386
+ }
1387
+ return pos({
1388
+ type: 'document',
1389
+ document: doc,
1390
+ vendor: vendor,
1391
+ rules: style
1392
+ });
1393
+ }
1394
+ function atfontface() {
1395
+ var pos = position();
1396
+ var m = match(/^@font-face\s*/);
1397
+ if (!m) {
1398
+ return;
1399
+ }
1400
+ if (!open()) {
1401
+ return error("@font-face missing '{'");
1402
+ }
1403
+ var decls = comments();
1404
+ var decl;
1405
+ while ((decl = declaration())) {
1406
+ decls.push(decl);
1407
+ decls = decls.concat(comments());
1408
+ }
1409
+ if (!close()) {
1410
+ return error("@font-face missing '}'");
1411
+ }
1412
+ return pos({
1413
+ type: 'font-face',
1414
+ declarations: decls
1415
+ });
1416
+ }
1417
+ var atimport = _compileAtrule('import');
1418
+ var atcharset = _compileAtrule('charset');
1419
+ var atnamespace = _compileAtrule('namespace');
1420
+ function _compileAtrule(name) {
1421
+ var re = new RegExp('^@' + name + '\\s*([^;]+);');
1422
+ return function () {
1423
+ var pos = position();
1424
+ var m = match(re);
1425
+ if (!m) {
1426
+ return;
1427
+ }
1428
+ var ret = { type: name };
1429
+ ret[name] = m[1].trim();
1430
+ return pos(ret);
1431
+ };
1432
+ }
1433
+ function atrule() {
1434
+ if (css[0] !== '@') {
1435
+ return;
1436
+ }
1437
+ return (atkeyframes() ||
1438
+ atmedia() ||
1439
+ atcustommedia() ||
1440
+ atsupports() ||
1441
+ atimport() ||
1442
+ atcharset() ||
1443
+ atnamespace() ||
1444
+ atdocument() ||
1445
+ atpage() ||
1446
+ athost() ||
1447
+ atfontface());
1448
+ }
1449
+ function rule() {
1450
+ var pos = position();
1451
+ var sel = selector();
1452
+ if (!sel) {
1453
+ return error('selector missing');
1454
+ }
1455
+ comments();
1456
+ return pos({
1457
+ type: 'rule',
1458
+ selectors: sel,
1459
+ declarations: declarations()
1460
+ });
1461
+ }
1462
+ return addParent(stylesheet());
1463
+ }
1464
+ function trim(str) {
1465
+ return str ? str.replace(/^\s+|\s+$/g, '') : '';
1466
+ }
1467
+ function addParent(obj, parent) {
1468
+ var isNode = obj && typeof obj.type === 'string';
1469
+ var childParent = isNode ? obj : parent;
1470
+ for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
1471
+ var k = _a[_i];
1472
+ var value = obj[k];
1473
+ if (Array.isArray(value)) {
1474
+ value.forEach(function (v) {
1475
+ addParent(v, childParent);
1476
+ });
1477
+ }
1478
+ else if (value && typeof value === 'object') {
1479
+ addParent(value, childParent);
1480
+ }
1481
+ }
1482
+ if (isNode) {
1483
+ Object.defineProperty(obj, 'parent', {
1484
+ configurable: true,
1485
+ writable: true,
1486
+ enumerable: false,
1487
+ value: parent || null
1488
+ });
1489
+ }
1490
+ return obj;
1491
+ }
1492
+
1493
+ var tagMap = {
1494
+ script: 'noscript',
1495
+ altglyph: 'altGlyph',
1496
+ altglyphdef: 'altGlyphDef',
1497
+ altglyphitem: 'altGlyphItem',
1498
+ animatecolor: 'animateColor',
1499
+ animatemotion: 'animateMotion',
1500
+ animatetransform: 'animateTransform',
1501
+ clippath: 'clipPath',
1502
+ feblend: 'feBlend',
1503
+ fecolormatrix: 'feColorMatrix',
1504
+ fecomponenttransfer: 'feComponentTransfer',
1505
+ fecomposite: 'feComposite',
1506
+ feconvolvematrix: 'feConvolveMatrix',
1507
+ fediffuselighting: 'feDiffuseLighting',
1508
+ fedisplacementmap: 'feDisplacementMap',
1509
+ fedistantlight: 'feDistantLight',
1510
+ fedropshadow: 'feDropShadow',
1511
+ feflood: 'feFlood',
1512
+ fefunca: 'feFuncA',
1513
+ fefuncb: 'feFuncB',
1514
+ fefuncg: 'feFuncG',
1515
+ fefuncr: 'feFuncR',
1516
+ fegaussianblur: 'feGaussianBlur',
1517
+ feimage: 'feImage',
1518
+ femerge: 'feMerge',
1519
+ femergenode: 'feMergeNode',
1520
+ femorphology: 'feMorphology',
1521
+ feoffset: 'feOffset',
1522
+ fepointlight: 'fePointLight',
1523
+ fespecularlighting: 'feSpecularLighting',
1524
+ fespotlight: 'feSpotLight',
1525
+ fetile: 'feTile',
1526
+ feturbulence: 'feTurbulence',
1527
+ foreignobject: 'foreignObject',
1528
+ glyphref: 'glyphRef',
1529
+ lineargradient: 'linearGradient',
1530
+ radialgradient: 'radialGradient'
1531
+ };
1532
+ function getTagName(n) {
1533
+ var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;
1534
+ if (tagName === 'link' && n.attributes._cssText) {
1535
+ tagName = 'style';
1536
+ }
1537
+ return tagName;
1538
+ }
1539
+ function escapeRegExp(str) {
1540
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1541
+ }
1542
+ var HOVER_SELECTOR = /([^\\]):hover/;
1543
+ var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');
1544
+ function addHoverClass(cssText, cache) {
1545
+ var _a;
1546
+ if (!((_a = window === null || window === void 0 ? void 0 : window.HIG_CONFIGURATION) === null || _a === void 0 ? void 0 : _a.enableOnHoverClass)) {
1547
+ return cssText;
1548
+ }
1549
+ var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);
1550
+ if (cachedStyle)
1551
+ return cachedStyle;
1552
+ var ast = parse(cssText, {
1553
+ silent: true
1554
+ });
1555
+ if (!ast.stylesheet) {
1556
+ return cssText;
1557
+ }
1558
+ var selectors = [];
1559
+ ast.stylesheet.rules.forEach(function (rule) {
1560
+ if ('selectors' in rule) {
1561
+ (rule.selectors || []).forEach(function (selector) {
1562
+ if (HOVER_SELECTOR.test(selector)) {
1563
+ selectors.push(selector);
1564
+ }
1565
+ });
1566
+ }
1567
+ });
1568
+ if (selectors.length === 0) {
1569
+ return cssText;
1570
+ }
1571
+ var selectorMatcher = new RegExp(selectors
1572
+ .filter(function (selector, index) { return selectors.indexOf(selector) === index; })
1573
+ .sort(function (a, b) { return b.length - a.length; })
1574
+ .map(function (selector) {
1575
+ return escapeRegExp(selector);
1576
+ })
1577
+ .join('|'), 'g');
1578
+ var result = cssText.replace(selectorMatcher, function (selector) {
1579
+ var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\:hover');
1580
+ return selector + ", " + newSelector;
1581
+ });
1582
+ cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);
1583
+ return result;
1584
+ }
1585
+ function createCache() {
1586
+ var stylesWithHoverClass = new Map();
1587
+ return {
1588
+ stylesWithHoverClass: stylesWithHoverClass
1589
+ };
1590
+ }
1591
+ function buildNode(n, options) {
1592
+ var doc = options.doc, hackCss = options.hackCss, cache = options.cache;
1593
+ switch (n.type) {
1594
+ case NodeType$2.Document:
1595
+ return doc.implementation.createDocument(null, '', null);
1596
+ case NodeType$2.DocumentType:
1597
+ return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);
1598
+ case NodeType$2.Element:
1599
+ var tagName = getTagName(n);
1600
+ var node_1;
1601
+ if (n.isSVG) {
1602
+ node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
1603
+ }
1604
+ else {
1605
+ node_1 = doc.createElement(tagName);
1606
+ }
1607
+ var _loop_1 = function (name_1) {
1608
+ if (!n.attributes.hasOwnProperty(name_1)) {
1609
+ return "continue";
1610
+ }
1611
+ var value = n.attributes[name_1];
1612
+ if (tagName === 'option' && name_1 === 'selected' && value === false) {
1613
+ return "continue";
1614
+ }
1615
+ value =
1616
+ typeof value === 'boolean' || typeof value === 'number' ? '' : value;
1617
+ if (!name_1.startsWith('rr_')) {
1618
+ var isTextarea = tagName === 'textarea' && name_1 === 'value';
1619
+ var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';
1620
+ if (isRemoteOrDynamicCss && hackCss) {
1621
+ value = addHoverClass(value, cache);
1622
+ if (typeof value === 'string') {
1623
+ var regex = /url\(\"https:\/\/\S*(.eot|.woff2|.ttf|.woff)\S*\"\)/gm;
1624
+ var m = void 0;
1625
+ var fontUrls_1 = [];
1626
+ var PROXY_URL_1 = 'https://replay-cors-proxy.highlightrun.workers.dev';
1627
+ while ((m = regex.exec(value)) !== null) {
1628
+ if (m.index === regex.lastIndex) {
1629
+ regex.lastIndex++;
1630
+ }
1631
+ m.forEach(function (match, groupIndex) {
1632
+ if (groupIndex === 0) {
1633
+ var url = match.slice(5, match.length - 2);
1634
+ fontUrls_1.push({
1635
+ originalUrl: url,
1636
+ proxyUrl: url.replace(url, PROXY_URL_1 + "?url=" + url)
1637
+ });
1638
+ }
1639
+ });
1640
+ }
1641
+ fontUrls_1.forEach(function (urlPair) {
1642
+ value = value.replace(urlPair.originalUrl, urlPair.proxyUrl);
1643
+ });
1644
+ }
1645
+ }
1646
+ if (isTextarea || isRemoteOrDynamicCss) {
1647
+ var child = doc.createTextNode(value);
1648
+ for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {
1649
+ var c = _a[_i];
1650
+ if (c.nodeType === node_1.TEXT_NODE) {
1651
+ node_1.removeChild(c);
1652
+ }
1653
+ }
1654
+ node_1.appendChild(child);
1655
+ return "continue";
1656
+ }
1657
+ try {
1658
+ if (n.isSVG && name_1 === 'xlink:href') {
1659
+ node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);
1660
+ }
1661
+ else if (name_1 === 'onload' ||
1662
+ name_1 === 'onclick' ||
1663
+ name_1.substring(0, 7) === 'onmouse') {
1664
+ node_1.setAttribute('_' + name_1, value);
1665
+ }
1666
+ else if (tagName === 'meta' &&
1667
+ n.attributes['http-equiv'] === 'Content-Security-Policy' &&
1668
+ name_1 === 'content') {
1669
+ node_1.setAttribute('csp-content', value);
1670
+ return "continue";
1671
+ }
1672
+ else if (tagName === 'link' &&
1673
+ n.attributes.rel === 'preload' &&
1674
+ n.attributes.as === 'script') {
1675
+ }
1676
+ else if (tagName === 'link' &&
1677
+ n.attributes.rel === 'prefetch' &&
1678
+ typeof n.attributes.href === 'string' &&
1679
+ n.attributes.href.endsWith('.js')) {
1680
+ }
1681
+ else if (tagName === 'img' &&
1682
+ n.attributes.srcset &&
1683
+ n.attributes.rr_dataURL) {
1684
+ node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);
1685
+ }
1686
+ else {
1687
+ node_1.setAttribute(name_1, value);
1688
+ }
1689
+ }
1690
+ catch (error) {
1691
+ }
1692
+ }
1693
+ else {
1694
+ if (tagName === 'canvas' && name_1 === 'rr_dataURL') {
1695
+ var image_1 = document.createElement('img');
1696
+ image_1.src = value;
1697
+ image_1.onload = function () {
1698
+ var ctx = node_1.getContext('2d');
1699
+ if (ctx) {
1700
+ ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);
1701
+ }
1702
+ };
1703
+ }
1704
+ else if (tagName === 'img' && name_1 === 'rr_dataURL') {
1705
+ var image = node_1;
1706
+ if (!image.currentSrc.startsWith('data:')) {
1707
+ image.setAttribute('rrweb-original-src', n.attributes.src);
1708
+ image.src = value;
1709
+ image.setAttribute('rrweb-inline-src', value);
1710
+ }
1711
+ }
1712
+ if (name_1 === 'rr_width') {
1713
+ node_1.style.width = value;
1714
+ }
1715
+ else if (name_1 === 'rr_height') {
1716
+ node_1.style.height = value;
1717
+ }
1718
+ else if (name_1 === 'rr_mediaCurrentTime') {
1719
+ node_1.currentTime = n.attributes
1720
+ .rr_mediaCurrentTime;
1721
+ }
1722
+ else if (name_1 === 'rr_mediaState') {
1723
+ switch (value) {
1724
+ case 'played':
1725
+ node_1
1726
+ .play()["catch"](function (e) { return console.warn('media playback error', e); });
1727
+ break;
1728
+ case 'paused':
1729
+ node_1.pause();
1730
+ break;
1731
+ }
1732
+ }
1733
+ }
1734
+ };
1735
+ for (var name_1 in n.attributes) {
1736
+ _loop_1(name_1);
1737
+ }
1738
+ if (tagName === 'img') {
1739
+ var image = node_1;
1740
+ if (!image.currentSrc.startsWith('data:')) {
1741
+ var inlineSrc = image.getAttribute('rrweb-inline-src');
1742
+ if (inlineSrc === null || inlineSrc === void 0 ? void 0 : inlineSrc.startsWith('data:')) {
1743
+ image.src = inlineSrc;
1744
+ }
1745
+ }
1746
+ }
1747
+ if (n.isShadowHost) {
1748
+ if (!node_1.shadowRoot) {
1749
+ node_1.attachShadow({ mode: 'open' });
1750
+ }
1751
+ else {
1752
+ while (node_1.shadowRoot.firstChild) {
1753
+ node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);
1754
+ }
1755
+ }
1756
+ }
1757
+ return node_1;
1758
+ case NodeType$2.Text:
1759
+ return doc.createTextNode(n.isStyle && hackCss
1760
+ ? addHoverClass(n.textContent, cache)
1761
+ : n.textContent);
1762
+ case NodeType$2.CDATA:
1763
+ return doc.createCDATASection(n.textContent);
1764
+ case NodeType$2.Comment:
1765
+ return doc.createComment(n.textContent);
1766
+ default:
1767
+ return null;
1768
+ }
1769
+ }
1770
+ function buildNodeWithSN(n, options) {
1771
+ var doc = options.doc, mirror = options.mirror, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;
1772
+ var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });
1773
+ if (!node) {
1774
+ return null;
1775
+ }
1776
+ if (n.rootId) {
1777
+ console.assert(mirror.getNode(n.rootId) === doc, 'Target document should have the same root id.');
1778
+ }
1779
+ if (n.type === NodeType$2.Document) {
1780
+ doc.close();
1781
+ doc.open();
1782
+ if (n.compatMode === 'BackCompat' &&
1783
+ n.childNodes &&
1784
+ n.childNodes[0].type !== NodeType$2.DocumentType) {
1785
+ if (n.childNodes[0].type === NodeType$2.Element &&
1786
+ 'xmlns' in n.childNodes[0].attributes &&
1787
+ n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {
1788
+ doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">');
1789
+ }
1790
+ else {
1791
+ doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">');
1792
+ }
1793
+ }
1794
+ node = doc;
1795
+ }
1796
+ mirror.add(node, n);
1797
+ if ((n.type === NodeType$2.Document || n.type === NodeType$2.Element) &&
1798
+ !skipChild) {
1799
+ for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {
1800
+ var childN = _c[_i];
1801
+ var childNode = buildNodeWithSN(childN, {
1802
+ doc: doc,
1803
+ mirror: mirror,
1804
+ skipChild: false,
1805
+ hackCss: hackCss,
1806
+ afterAppend: afterAppend,
1807
+ cache: cache
1808
+ });
1809
+ if (!childNode) {
1810
+ console.warn('Failed to rebuild', childN);
1811
+ continue;
1812
+ }
1813
+ if (childN.isShadow && isElement(node) && node.shadowRoot) {
1814
+ node.shadowRoot.appendChild(childNode);
1815
+ }
1816
+ else {
1817
+ node.appendChild(childNode);
1818
+ }
1819
+ if (afterAppend) {
1820
+ afterAppend(childNode);
1821
+ }
1822
+ }
1823
+ }
1824
+ return node;
1825
+ }
1826
+ function visit(mirror, onVisit) {
1827
+ function walk(node) {
1828
+ onVisit(node);
1829
+ }
1830
+ for (var _i = 0, _a = mirror.getIds(); _i < _a.length; _i++) {
1831
+ var id = _a[_i];
1832
+ if (mirror.has(id)) {
1833
+ walk(mirror.getNode(id));
1834
+ }
1835
+ }
1836
+ }
1837
+ function handleScroll(node, mirror) {
1838
+ var n = mirror.getMeta(node);
1839
+ if ((n === null || n === void 0 ? void 0 : n.type) !== NodeType$2.Element) {
1840
+ return;
1841
+ }
1842
+ var el = node;
1843
+ for (var name_2 in n.attributes) {
1844
+ if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {
1845
+ continue;
1846
+ }
1847
+ var value = n.attributes[name_2];
1848
+ if (name_2 === 'rr_scrollLeft') {
1849
+ el.scrollLeft = value;
1850
+ }
1851
+ if (name_2 === 'rr_scrollTop') {
1852
+ el.scrollTop = value;
1853
+ }
1854
+ }
1855
+ }
1856
+ function rebuild(n, options) {
1857
+ var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache, _b = options.mirror, mirror = _b === void 0 ? new Mirror$2() : _b;
1858
+ var node = buildNodeWithSN(n, {
1859
+ doc: doc,
1860
+ mirror: mirror,
1861
+ skipChild: false,
1862
+ hackCss: hackCss,
1863
+ afterAppend: afterAppend,
1864
+ cache: cache
1865
+ });
1866
+ visit(mirror, function (visitedNode) {
1867
+ if (onVisit) {
1868
+ onVisit(visitedNode);
1869
+ }
1870
+ handleScroll(visitedNode, mirror);
1871
+ });
1872
+ return node;
1873
+ }
6
1874
 
7
1875
  function on(type, fn, target = document) {
8
1876
  const options = { capture: true, passive: true };
@@ -151,7 +2019,7 @@ function isBlocked(node, blockClass, checkAncestors) {
151
2019
  return true;
152
2020
  }
153
2021
  else {
154
- if (rrwebSnapshot.classMatchesRegex(el, blockClass, checkAncestors))
2022
+ if (classMatchesRegex(el, blockClass, checkAncestors))
155
2023
  return true;
156
2024
  }
157
2025
  return false;
@@ -160,10 +2028,10 @@ function isSerialized(n, mirror) {
160
2028
  return mirror.getId(n) !== -1;
161
2029
  }
162
2030
  function isIgnored(n, mirror) {
163
- return mirror.getId(n) === rrwebSnapshot.IGNORED_NODE;
2031
+ return mirror.getId(n) === IGNORED_NODE;
164
2032
  }
165
2033
  function isAncestorRemoved(target, mirror) {
166
- if (rrwebSnapshot.isShadowRoot(target)) {
2034
+ if (isShadowRoot(target)) {
167
2035
  return false;
168
2036
  }
169
2037
  const id = mirror.getId(target);
@@ -310,30 +2178,30 @@ function uniqueTextMutations(mutations) {
310
2178
  }
311
2179
 
312
2180
  var utils = /*#__PURE__*/Object.freeze({
313
- __proto__: null,
314
- on: on,
315
- get _mirror () { return exports.mirror; },
316
- throttle: throttle,
317
- hookSetter: hookSetter,
318
- patch: patch,
319
- getWindowHeight: getWindowHeight,
320
- getWindowWidth: getWindowWidth,
321
- isCanvasNode: isCanvasNode,
322
- isBlocked: isBlocked,
323
- isSerialized: isSerialized,
324
- isIgnored: isIgnored,
325
- isAncestorRemoved: isAncestorRemoved,
326
- isTouchEvent: isTouchEvent,
327
- polyfill: polyfill$1,
328
- queueToResolveTrees: queueToResolveTrees,
329
- iterateResolveTree: iterateResolveTree,
330
- isSerializedIframe: isSerializedIframe,
331
- isSerializedStylesheet: isSerializedStylesheet,
332
- getBaseDimension: getBaseDimension,
333
- hasShadowRoot: hasShadowRoot,
334
- getNestedRule: getNestedRule$1,
335
- getPositionsAndIndex: getPositionsAndIndex$1,
336
- uniqueTextMutations: uniqueTextMutations
2181
+ __proto__: null,
2182
+ on: on,
2183
+ get _mirror () { return exports.mirror; },
2184
+ throttle: throttle,
2185
+ hookSetter: hookSetter,
2186
+ patch: patch,
2187
+ getWindowHeight: getWindowHeight,
2188
+ getWindowWidth: getWindowWidth,
2189
+ isCanvasNode: isCanvasNode,
2190
+ isBlocked: isBlocked,
2191
+ isSerialized: isSerialized,
2192
+ isIgnored: isIgnored,
2193
+ isAncestorRemoved: isAncestorRemoved,
2194
+ isTouchEvent: isTouchEvent,
2195
+ polyfill: polyfill$1,
2196
+ queueToResolveTrees: queueToResolveTrees,
2197
+ iterateResolveTree: iterateResolveTree,
2198
+ isSerializedIframe: isSerializedIframe,
2199
+ isSerializedStylesheet: isSerializedStylesheet,
2200
+ getBaseDimension: getBaseDimension,
2201
+ hasShadowRoot: hasShadowRoot,
2202
+ getNestedRule: getNestedRule$1,
2203
+ getPositionsAndIndex: getPositionsAndIndex$1,
2204
+ uniqueTextMutations: uniqueTextMutations
337
2205
  });
338
2206
 
339
2207
  exports.EventType = void 0;
@@ -512,8 +2380,8 @@ class MutationBuffer {
512
2380
  const addList = new DoubleLinkedList();
513
2381
  const getNextId = (n) => {
514
2382
  let ns = n;
515
- let nextId = rrwebSnapshot.IGNORED_NODE;
516
- while (nextId === rrwebSnapshot.IGNORED_NODE) {
2383
+ let nextId = IGNORED_NODE;
2384
+ while (nextId === IGNORED_NODE) {
517
2385
  ns = ns && ns.nextSibling;
518
2386
  nextId = ns && this.mirror.getId(ns);
519
2387
  }
@@ -534,14 +2402,14 @@ class MutationBuffer {
534
2402
  if (!n.parentNode || notInDoc) {
535
2403
  return;
536
2404
  }
537
- const parentId = rrwebSnapshot.isShadowRoot(n.parentNode)
2405
+ const parentId = isShadowRoot(n.parentNode)
538
2406
  ? this.mirror.getId(shadowHost)
539
2407
  : this.mirror.getId(n.parentNode);
540
2408
  const nextId = getNextId(n);
541
2409
  if (parentId === -1 || nextId === -1) {
542
2410
  return addList.addNode(n);
543
2411
  }
544
- const sn = rrwebSnapshot.serializeNodeWithId(n, {
2412
+ const sn = serializeNodeWithId(n, {
545
2413
  doc: this.doc,
546
2414
  mirror: this.mirror,
547
2415
  blockClass: this.blockClass,
@@ -645,7 +2513,7 @@ class MutationBuffer {
645
2513
  .map((text) => {
646
2514
  let value = text.value;
647
2515
  if (this.enableStrictPrivacy && value) {
648
- value = rrwebSnapshot.obfuscateText(value);
2516
+ value = obfuscateText(value);
649
2517
  }
650
2518
  return {
651
2519
  id: this.mirror.getId(text.node),
@@ -687,7 +2555,7 @@ class MutationBuffer {
687
2555
  if (!isBlocked(m.target, this.blockClass, false) &&
688
2556
  value !== m.oldValue) {
689
2557
  this.texts.push({
690
- value: rrwebSnapshot.needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value
2558
+ value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value
691
2559
  ? this.maskTextFn
692
2560
  ? this.maskTextFn(value)
693
2561
  : value.replace(/[\S]/g, '*')
@@ -701,7 +2569,7 @@ class MutationBuffer {
701
2569
  const target = m.target;
702
2570
  let value = m.target.getAttribute(m.attributeName);
703
2571
  if (m.attributeName === 'value') {
704
- value = rrwebSnapshot.maskInputValue({
2572
+ value = maskInputValue({
705
2573
  maskInputOptions: this.maskInputOptions,
706
2574
  tagName: m.target.tagName,
707
2575
  type: m.target.getAttribute('type'),
@@ -759,7 +2627,7 @@ class MutationBuffer {
759
2627
  break;
760
2628
  }
761
2629
  }
762
- item.attributes[m.attributeName] = rrwebSnapshot.transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
2630
+ item.attributes[m.attributeName] = transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
763
2631
  }
764
2632
  break;
765
2633
  }
@@ -769,7 +2637,7 @@ class MutationBuffer {
769
2637
  m.addedNodes.forEach((n) => this.genAdds(n, m.target));
770
2638
  m.removedNodes.forEach((n) => {
771
2639
  const nodeId = this.mirror.getId(n);
772
- const parentId = rrwebSnapshot.isShadowRoot(m.target)
2640
+ const parentId = isShadowRoot(m.target)
773
2641
  ? this.mirror.getId(m.target.host)
774
2642
  : this.mirror.getId(m.target);
775
2643
  if (isBlocked(m.target, this.blockClass, false) ||
@@ -791,7 +2659,7 @@ class MutationBuffer {
791
2659
  this.removes.push({
792
2660
  parentId,
793
2661
  id: nodeId,
794
- isShadow: rrwebSnapshot.isShadowRoot(m.target) ? true : undefined,
2662
+ isShadow: isShadowRoot(m.target) ? true : undefined,
795
2663
  });
796
2664
  }
797
2665
  this.mapRemoves.push(n);
@@ -1120,7 +2988,7 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, mask
1120
2988
  }
1121
2989
  else if (maskInputOptions[target.tagName.toLowerCase()] ||
1122
2990
  maskInputOptions[type]) {
1123
- text = rrwebSnapshot.maskInputValue({
2991
+ text = maskInputValue({
1124
2992
  maskInputOptions,
1125
2993
  tagName: target.tagName,
1126
2994
  type,
@@ -2156,7 +4024,7 @@ function wrapEvent(e) {
2156
4024
  }
2157
4025
  let wrappedEmit;
2158
4026
  let takeFullSnapshot;
2159
- const mirror = rrwebSnapshot.createMirror();
4027
+ const mirror = createMirror$2();
2160
4028
  function record(options = {}) {
2161
4029
  const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'highlight-block', blockSelector = null, ignoreClass = 'highlight-ignore', maskTextClass = 'highlight-mask', maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, mousemoveWait, recordCanvas = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, enableStrictPrivacy = false, } = options;
2162
4030
  if (!emit) {
@@ -2307,7 +4175,7 @@ function record(options = {}) {
2307
4175
  },
2308
4176
  }), isCheckout);
2309
4177
  mutationBuffers.forEach((buf) => buf.lock());
2310
- const node = rrwebSnapshot.snapshot(document, {
4178
+ const node = snapshot(document, {
2311
4179
  mirror,
2312
4180
  blockClass,
2313
4181
  blockSelector,
@@ -2500,6 +4368,70 @@ record.takeFullSnapshot = (isCheckout) => {
2500
4368
  };
2501
4369
  record.mirror = mirror;
2502
4370
 
4371
+ var NodeType$1;
4372
+ (function (NodeType) {
4373
+ NodeType[NodeType["Document"] = 0] = "Document";
4374
+ NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
4375
+ NodeType[NodeType["Element"] = 2] = "Element";
4376
+ NodeType[NodeType["Text"] = 3] = "Text";
4377
+ NodeType[NodeType["CDATA"] = 4] = "CDATA";
4378
+ NodeType[NodeType["Comment"] = 5] = "Comment";
4379
+ })(NodeType$1 || (NodeType$1 = {}));
4380
+ var Mirror$1 = (function () {
4381
+ function Mirror() {
4382
+ this.idNodeMap = new Map();
4383
+ this.nodeMetaMap = new WeakMap();
4384
+ }
4385
+ Mirror.prototype.getId = function (n) {
4386
+ var _a;
4387
+ if (!n)
4388
+ return -1;
4389
+ var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
4390
+ return id !== null && id !== void 0 ? id : -1;
4391
+ };
4392
+ Mirror.prototype.getNode = function (id) {
4393
+ return this.idNodeMap.get(id) || null;
4394
+ };
4395
+ Mirror.prototype.getIds = function () {
4396
+ return Array.from(this.idNodeMap.keys());
4397
+ };
4398
+ Mirror.prototype.getMeta = function (n) {
4399
+ return this.nodeMetaMap.get(n) || null;
4400
+ };
4401
+ Mirror.prototype.removeNodeFromMap = function (n) {
4402
+ var _this = this;
4403
+ var id = this.getId(n);
4404
+ this.idNodeMap["delete"](id);
4405
+ if (n.childNodes) {
4406
+ n.childNodes.forEach(function (childNode) {
4407
+ return _this.removeNodeFromMap(childNode);
4408
+ });
4409
+ }
4410
+ };
4411
+ Mirror.prototype.has = function (id) {
4412
+ return this.idNodeMap.has(id);
4413
+ };
4414
+ Mirror.prototype.hasNode = function (node) {
4415
+ return this.nodeMetaMap.has(node);
4416
+ };
4417
+ Mirror.prototype.add = function (n, meta) {
4418
+ var id = meta.id;
4419
+ this.idNodeMap.set(id, n);
4420
+ this.nodeMetaMap.set(n, meta);
4421
+ };
4422
+ Mirror.prototype.replace = function (id, n) {
4423
+ this.idNodeMap.set(id, n);
4424
+ };
4425
+ Mirror.prototype.reset = function () {
4426
+ this.idNodeMap = new Map();
4427
+ this.nodeMetaMap = new WeakMap();
4428
+ };
4429
+ return Mirror;
4430
+ }());
4431
+ function createMirror$1() {
4432
+ return new Mirror$1();
4433
+ }
4434
+
2503
4435
  function parseCSSText(cssText) {
2504
4436
  const res = {};
2505
4437
  const listDelimiter = /;(?![^(]*\))/g;
@@ -2590,21 +4522,21 @@ function BaseRRDocumentImpl(RRNodeClass) {
2590
4522
  this.nodeType = NodeType.DOCUMENT_NODE;
2591
4523
  this.nodeName = '#document';
2592
4524
  this.compatMode = 'CSS1Compat';
2593
- this.RRNodeType = rrwebSnapshot.NodeType.Document;
4525
+ this.RRNodeType = NodeType$1.Document;
2594
4526
  this.textContent = null;
2595
4527
  }
2596
4528
  get documentElement() {
2597
- return (this.childNodes.find((node) => node.RRNodeType === rrwebSnapshot.NodeType.Element &&
4529
+ return (this.childNodes.find((node) => node.RRNodeType === NodeType$1.Element &&
2598
4530
  node.tagName === 'HTML') || null);
2599
4531
  }
2600
4532
  get body() {
2601
4533
  var _a;
2602
- return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === rrwebSnapshot.NodeType.Element &&
4534
+ return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element &&
2603
4535
  node.tagName === 'BODY')) || null);
2604
4536
  }
2605
4537
  get head() {
2606
4538
  var _a;
2607
- return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === rrwebSnapshot.NodeType.Element &&
4539
+ return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element &&
2608
4540
  node.tagName === 'HEAD')) || null);
2609
4541
  }
2610
4542
  get implementation() {
@@ -2615,10 +4547,10 @@ function BaseRRDocumentImpl(RRNodeClass) {
2615
4547
  }
2616
4548
  appendChild(childNode) {
2617
4549
  const nodeType = childNode.RRNodeType;
2618
- if (nodeType === rrwebSnapshot.NodeType.Element ||
2619
- nodeType === rrwebSnapshot.NodeType.DocumentType) {
4550
+ if (nodeType === NodeType$1.Element ||
4551
+ nodeType === NodeType$1.DocumentType) {
2620
4552
  if (this.childNodes.some((s) => s.RRNodeType === nodeType)) {
2621
- throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === rrwebSnapshot.NodeType.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
4553
+ throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
2622
4554
  }
2623
4555
  }
2624
4556
  childNode.parentElement = null;
@@ -2628,10 +4560,10 @@ function BaseRRDocumentImpl(RRNodeClass) {
2628
4560
  }
2629
4561
  insertBefore(newChild, refChild) {
2630
4562
  const nodeType = newChild.RRNodeType;
2631
- if (nodeType === rrwebSnapshot.NodeType.Element ||
2632
- nodeType === rrwebSnapshot.NodeType.DocumentType) {
4563
+ if (nodeType === NodeType$1.Element ||
4564
+ nodeType === NodeType$1.DocumentType) {
2633
4565
  if (this.childNodes.some((s) => s.RRNodeType === nodeType)) {
2634
- throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === rrwebSnapshot.NodeType.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
4566
+ throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
2635
4567
  }
2636
4568
  }
2637
4569
  if (refChild === null)
@@ -2713,7 +4645,7 @@ function BaseRRDocumentTypeImpl(RRNodeClass) {
2713
4645
  constructor(qualifiedName, publicId, systemId) {
2714
4646
  super();
2715
4647
  this.nodeType = NodeType.DOCUMENT_TYPE_NODE;
2716
- this.RRNodeType = rrwebSnapshot.NodeType.DocumentType;
4648
+ this.RRNodeType = NodeType$1.DocumentType;
2717
4649
  this.textContent = null;
2718
4650
  this.name = qualifiedName;
2719
4651
  this.publicId = publicId;
@@ -2730,7 +4662,7 @@ function BaseRRElementImpl(RRNodeClass) {
2730
4662
  constructor(tagName) {
2731
4663
  super();
2732
4664
  this.nodeType = NodeType.ELEMENT_NODE;
2733
- this.RRNodeType = rrwebSnapshot.NodeType.Element;
4665
+ this.RRNodeType = NodeType$1.Element;
2734
4666
  this.attributes = {};
2735
4667
  this.shadowRoot = null;
2736
4668
  this.tagName = tagName.toUpperCase();
@@ -2857,7 +4789,7 @@ function BaseRRTextImpl(RRNodeClass) {
2857
4789
  super();
2858
4790
  this.nodeType = NodeType.TEXT_NODE;
2859
4791
  this.nodeName = '#text';
2860
- this.RRNodeType = rrwebSnapshot.NodeType.Text;
4792
+ this.RRNodeType = NodeType$1.Text;
2861
4793
  this.data = data;
2862
4794
  }
2863
4795
  get textContent() {
@@ -2877,7 +4809,7 @@ function BaseRRCommentImpl(RRNodeClass) {
2877
4809
  super();
2878
4810
  this.nodeType = NodeType.COMMENT_NODE;
2879
4811
  this.nodeName = '#comment';
2880
- this.RRNodeType = rrwebSnapshot.NodeType.Comment;
4812
+ this.RRNodeType = NodeType$1.Comment;
2881
4813
  this.data = data;
2882
4814
  }
2883
4815
  get textContent() {
@@ -2897,7 +4829,7 @@ function BaseRRCDATASectionImpl(RRNodeClass) {
2897
4829
  super();
2898
4830
  this.nodeName = '#cdata-section';
2899
4831
  this.nodeType = NodeType.CDATA_SECTION_NODE;
2900
- this.RRNodeType = rrwebSnapshot.NodeType.CDATA;
4832
+ this.RRNodeType = NodeType$1.CDATA;
2901
4833
  this.data = data;
2902
4834
  }
2903
4835
  get textContent() {
@@ -2967,12 +4899,12 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
2967
4899
  }
2968
4900
  let inputDataToApply = null, scrollDataToApply = null;
2969
4901
  switch (newTree.RRNodeType) {
2970
- case rrwebSnapshot.NodeType.Document: {
4902
+ case NodeType$1.Document: {
2971
4903
  const newRRDocument = newTree;
2972
4904
  scrollDataToApply = newRRDocument.scrollData;
2973
4905
  break;
2974
4906
  }
2975
- case rrwebSnapshot.NodeType.Element: {
4907
+ case NodeType$1.Element: {
2976
4908
  const oldElement = oldTree;
2977
4909
  const newRRElement = newTree;
2978
4910
  diffProps(oldElement, newRRElement, rrnodeMirror);
@@ -3012,9 +4944,9 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
3012
4944
  }
3013
4945
  break;
3014
4946
  }
3015
- case rrwebSnapshot.NodeType.Text:
3016
- case rrwebSnapshot.NodeType.Comment:
3017
- case rrwebSnapshot.NodeType.CDATA:
4947
+ case NodeType$1.Text:
4948
+ case NodeType$1.Comment:
4949
+ case NodeType$1.CDATA:
3018
4950
  if (oldTree.textContent !==
3019
4951
  newTree.data)
3020
4952
  oldTree.textContent = newTree.data;
@@ -3129,7 +5061,7 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
3129
5061
  else {
3130
5062
  const newNode = createOrGetNode(newStartNode, replayer.mirror, rrnodeMirror);
3131
5063
  if (parentNode.nodeName === '#document' &&
3132
- ((_a = replayer.mirror.getMeta(newNode)) === null || _a === void 0 ? void 0 : _a.type) === rrwebSnapshot.NodeType.Element &&
5064
+ ((_a = replayer.mirror.getMeta(newNode)) === null || _a === void 0 ? void 0 : _a.type) === NodeType$1.Element &&
3133
5065
  parentNode.documentElement) {
3134
5066
  parentNode.removeChild(parentNode.documentElement);
3135
5067
  oldChildren[oldStartIndex] = undefined;
@@ -3181,13 +5113,13 @@ function createOrGetNode(rrNode, domMirror, rrnodeMirror) {
3181
5113
  if (node !== null)
3182
5114
  return node;
3183
5115
  switch (rrNode.RRNodeType) {
3184
- case rrwebSnapshot.NodeType.Document:
5116
+ case NodeType$1.Document:
3185
5117
  node = new Document();
3186
5118
  break;
3187
- case rrwebSnapshot.NodeType.DocumentType:
5119
+ case NodeType$1.DocumentType:
3188
5120
  node = document.implementation.createDocumentType(rrNode.name, rrNode.publicId, rrNode.systemId);
3189
5121
  break;
3190
- case rrwebSnapshot.NodeType.Element: {
5122
+ case NodeType$1.Element: {
3191
5123
  rrNode.tagName.toLowerCase();
3192
5124
  if (sn && 'isSVG' in sn && (sn === null || sn === void 0 ? void 0 : sn.isSVG)) {
3193
5125
  node = document.createElementNS(NAMESPACES['svg'], rrNode.tagName.toLowerCase());
@@ -3196,13 +5128,13 @@ function createOrGetNode(rrNode, domMirror, rrnodeMirror) {
3196
5128
  node = document.createElement(rrNode.tagName);
3197
5129
  break;
3198
5130
  }
3199
- case rrwebSnapshot.NodeType.Text:
5131
+ case NodeType$1.Text:
3200
5132
  node = document.createTextNode(rrNode.data);
3201
5133
  break;
3202
- case rrwebSnapshot.NodeType.Comment:
5134
+ case NodeType$1.Comment:
3203
5135
  node = document.createComment(rrNode.data);
3204
5136
  break;
3205
- case rrwebSnapshot.NodeType.CDATA:
5137
+ case NodeType$1.CDATA:
3206
5138
  node = document.createCDATASection(rrNode.data);
3207
5139
  break;
3208
5140
  }
@@ -3435,7 +5367,7 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
3435
5367
  }
3436
5368
  return rrNode;
3437
5369
  }
3438
- function buildFromDom(dom, domMirror = rrwebSnapshot.createMirror(), rrdom = new RRDocument()) {
5370
+ function buildFromDom(dom, domMirror = createMirror$1(), rrdom = new RRDocument()) {
3439
5371
  function walk(node, parentRRNode) {
3440
5372
  const rrNode = buildFromNode(node, rrdom, domMirror, parentRRNode);
3441
5373
  if (rrNode === null)
@@ -3513,13 +5445,13 @@ class Mirror {
3513
5445
  }
3514
5446
  function getDefaultSN(node, id) {
3515
5447
  switch (node.RRNodeType) {
3516
- case rrwebSnapshot.NodeType.Document:
5448
+ case NodeType$1.Document:
3517
5449
  return {
3518
5450
  id,
3519
5451
  type: node.RRNodeType,
3520
5452
  childNodes: [],
3521
5453
  };
3522
- case rrwebSnapshot.NodeType.DocumentType:
5454
+ case NodeType$1.DocumentType:
3523
5455
  const doctype = node;
3524
5456
  return {
3525
5457
  id,
@@ -3528,7 +5460,7 @@ function getDefaultSN(node, id) {
3528
5460
  publicId: doctype.publicId,
3529
5461
  systemId: doctype.systemId,
3530
5462
  };
3531
- case rrwebSnapshot.NodeType.Element:
5463
+ case NodeType$1.Element:
3532
5464
  return {
3533
5465
  id,
3534
5466
  type: node.RRNodeType,
@@ -3536,19 +5468,19 @@ function getDefaultSN(node, id) {
3536
5468
  attributes: {},
3537
5469
  childNodes: [],
3538
5470
  };
3539
- case rrwebSnapshot.NodeType.Text:
5471
+ case NodeType$1.Text:
3540
5472
  return {
3541
5473
  id,
3542
5474
  type: node.RRNodeType,
3543
5475
  textContent: node.textContent || '',
3544
5476
  };
3545
- case rrwebSnapshot.NodeType.Comment:
5477
+ case NodeType$1.Comment:
3546
5478
  return {
3547
5479
  id,
3548
5480
  type: node.RRNodeType,
3549
5481
  textContent: node.textContent || '',
3550
5482
  };
3551
- case rrwebSnapshot.NodeType.CDATA:
5483
+ case NodeType$1.CDATA:
3552
5484
  return {
3553
5485
  id,
3554
5486
  type: node.RRNodeType,
@@ -3620,8 +5552,8 @@ function mitt$1(all ) {
3620
5552
  }
3621
5553
 
3622
5554
  var mittProxy = /*#__PURE__*/Object.freeze({
3623
- __proto__: null,
3624
- 'default': mitt$1
5555
+ __proto__: null,
5556
+ 'default': mitt$1
3625
5557
  });
3626
5558
 
3627
5559
  function polyfill(w = window, d = document) {
@@ -4439,10 +6371,10 @@ class Replayer {
4439
6371
  this.emitter = mitt();
4440
6372
  this.activityIntervals = [];
4441
6373
  this.legacy_missingNodeRetryMap = {};
4442
- this.cache = rrwebSnapshot.createCache();
6374
+ this.cache = createCache();
4443
6375
  this.imageMap = new Map();
4444
6376
  this.canvasEventMap = new Map();
4445
- this.mirror = rrwebSnapshot.createMirror();
6377
+ this.mirror = createMirror$2();
4446
6378
  this.firstFullSnapshot = null;
4447
6379
  this.newDocumentQueue = [];
4448
6380
  this.mousePos = null;
@@ -4784,7 +6716,7 @@ class Replayer {
4784
6716
  this.iframe.style.pointerEvents = 'none';
4785
6717
  }
4786
6718
  resetCache() {
4787
- this.cache = rrwebSnapshot.createCache();
6719
+ this.cache = createCache();
4788
6720
  }
4789
6721
  setupDom() {
4790
6722
  this.wrapper = document.createElement('div');
@@ -4986,7 +6918,7 @@ class Replayer {
4986
6918
  }
4987
6919
  this.legacy_missingNodeRetryMap = {};
4988
6920
  const collected = [];
4989
- rrwebSnapshot.rebuild(event.data.node, {
6921
+ rebuild(event.data.node, {
4990
6922
  doc: this.iframe.contentDocument,
4991
6923
  afterAppend: (builtNode) => {
4992
6924
  this.collectIframeAndAttachDocument(collected, builtNode);
@@ -5043,7 +6975,7 @@ class Replayer {
5043
6975
  ? this.virtualDom.mirror
5044
6976
  : this.mirror;
5045
6977
  const collected = [];
5046
- rrwebSnapshot.buildNodeWithSN(mutation.node, {
6978
+ buildNodeWithSN(mutation.node, {
5047
6979
  doc: iframeEl.contentDocument,
5048
6980
  mirror: mirror,
5049
6981
  hackCss: true,
@@ -5051,7 +6983,7 @@ class Replayer {
5051
6983
  afterAppend: (builtNode) => {
5052
6984
  this.collectIframeAndAttachDocument(collected, builtNode);
5053
6985
  const sn = mirror.getMeta(builtNode);
5054
- if ((sn === null || sn === void 0 ? void 0 : sn.type) === rrwebSnapshot.NodeType.Element &&
6986
+ if ((sn === null || sn === void 0 ? void 0 : sn.type) === NodeType$2.Element &&
5055
6987
  (sn === null || sn === void 0 ? void 0 : sn.tagName.toUpperCase()) === 'HTML') {
5056
6988
  const { documentElement, head } = iframeEl.contentDocument;
5057
6989
  this.insertStyleRules(documentElement, head);
@@ -5605,7 +7537,7 @@ class Replayer {
5605
7537
  }
5606
7538
  let parent = mirror.getNode(mutation.parentId);
5607
7539
  if (!parent) {
5608
- if (mutation.node.type === rrwebSnapshot.NodeType.Document) {
7540
+ if (mutation.node.type === NodeType$2.Document) {
5609
7541
  return this.newDocumentQueue.push(mutation);
5610
7542
  }
5611
7543
  return queue.push(mutation);
@@ -5641,7 +7573,7 @@ class Replayer {
5641
7573
  this.attachDocumentToIframe(mutation, parent);
5642
7574
  return;
5643
7575
  }
5644
- const target = rrwebSnapshot.buildNodeWithSN(mutation.node, {
7576
+ const target = buildNodeWithSN(mutation.node, {
5645
7577
  doc: targetDoc,
5646
7578
  mirror: mirror,
5647
7579
  skipChild: true,
@@ -5657,9 +7589,9 @@ class Replayer {
5657
7589
  }
5658
7590
  const parentSn = mirror.getMeta(parent);
5659
7591
  if (parentSn &&
5660
- parentSn.type === rrwebSnapshot.NodeType.Element &&
7592
+ parentSn.type === NodeType$2.Element &&
5661
7593
  parentSn.tagName === 'textarea' &&
5662
- mutation.node.type === rrwebSnapshot.NodeType.Text) {
7594
+ mutation.node.type === NodeType$2.Text) {
5663
7595
  const childNodeArray = Array.isArray(parent.childNodes)
5664
7596
  ? parent.childNodes
5665
7597
  : Array.from(parent.childNodes);
@@ -5802,7 +7734,7 @@ class Replayer {
5802
7734
  behavior: isSync ? 'auto' : 'smooth',
5803
7735
  });
5804
7736
  }
5805
- else if ((sn === null || sn === void 0 ? void 0 : sn.type) === rrwebSnapshot.NodeType.Document) {
7737
+ else if ((sn === null || sn === void 0 ? void 0 : sn.type) === NodeType$2.Document) {
5806
7738
  target.defaultView.scrollTo({
5807
7739
  top: d.y,
5808
7740
  left: d.x,