@sentry/replay 7.35.0 → 7.37.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.
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getCurrentHub, addBreadcrumb, addGlobalEventProcessor, prepareEvent, setContext, captureException } from '@sentry/core';
2
- import { GLOBAL_OBJ, logger, uuid4, htmlTreeAsString, addInstrumentationHandler, browserPerformanceTimeOrigin, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, updateRateLimits, isRateLimited, disabledUntil, isNodeEnv, dropUndefinedKeys } from '@sentry/utils';
2
+ import { GLOBAL_OBJ, logger, uuid4, htmlTreeAsString, addInstrumentationHandler, browserPerformanceTimeOrigin, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, isNodeEnv, dropUndefinedKeys } from '@sentry/utils';
3
3
 
4
4
  // exporting a separate copy of `WINDOW` rather than exporting the one from `@sentry/browser`
5
5
  // prevents the browser package from being bundled in the CDN bundle, and avoids a
@@ -33,83 +33,6 @@ const ERROR_CHECKOUT_TIME = 60000;
33
33
  const RETRY_BASE_INTERVAL = 5000;
34
34
  const RETRY_MAX_COUNT = 3;
35
35
 
36
- /*! *****************************************************************************
37
- Copyright (c) Microsoft Corporation.
38
-
39
- Permission to use, copy, modify, and/or distribute this software for any
40
- purpose with or without fee is hereby granted.
41
-
42
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
43
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
44
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
45
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
46
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
47
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
48
- PERFORMANCE OF THIS SOFTWARE.
49
- ***************************************************************************** */
50
-
51
- var __assign = function() {
52
- __assign = Object.assign || function __assign(t) {
53
- for (var s, i = 1, n = arguments.length; i < n; i++) {
54
- s = arguments[i];
55
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
56
- }
57
- return t;
58
- };
59
- return __assign.apply(this, arguments);
60
- };
61
-
62
- function __rest(s, e) {
63
- var t = {};
64
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
65
- t[p] = s[p];
66
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
67
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
68
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
69
- t[p[i]] = s[p[i]];
70
- }
71
- return t;
72
- }
73
-
74
- function __values(o) {
75
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
76
- if (m) return m.call(o);
77
- if (o && typeof o.length === "number") return {
78
- next: function () {
79
- if (o && i >= o.length) o = void 0;
80
- return { value: o && o[i++], done: !o };
81
- }
82
- };
83
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
84
- }
85
-
86
- function __read(o, n) {
87
- var m = typeof Symbol === "function" && o[Symbol.iterator];
88
- if (!m) return o;
89
- var i = m.call(o), r, ar = [], e;
90
- try {
91
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
92
- }
93
- catch (error) { e = { error: error }; }
94
- finally {
95
- try {
96
- if (r && !r.done && (m = i["return"])) m.call(i);
97
- }
98
- finally { if (e) throw e.error; }
99
- }
100
- return ar;
101
- }
102
-
103
- function __spreadArray(to, from, pack) {
104
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
105
- if (ar || !(i in from)) {
106
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
107
- ar[i] = from[i];
108
- }
109
- }
110
- return to.concat(ar || Array.prototype.slice.call(from));
111
- }
112
-
113
36
  var NodeType;
114
37
  (function (NodeType) {
115
38
  NodeType[NodeType["Document"] = 0] = "Document";
@@ -124,13 +47,11 @@ function isElement(n) {
124
47
  return n.nodeType === n.ELEMENT_NODE;
125
48
  }
126
49
  function isShadowRoot(n) {
127
- var _a;
128
- var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;
50
+ const host = n === null || n === void 0 ? void 0 : n.host;
129
51
  return Boolean(host && host.shadowRoot && host.shadowRoot === n);
130
52
  }
131
- function maskInputValue(_a) {
132
- var input = _a.input, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;
133
- var text = value || '';
53
+ function maskInputValue({ input, maskInputSelector, unmaskInputSelector, maskInputOptions, tagName, type, value, maskInputFn, }) {
54
+ let text = value || '';
134
55
  if (unmaskInputSelector && input.matches(unmaskInputSelector)) {
135
56
  return text;
136
57
  }
@@ -146,29 +67,29 @@ function maskInputValue(_a) {
146
67
  }
147
68
  return text;
148
69
  }
149
- var ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';
70
+ const ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';
150
71
  function is2DCanvasBlank(canvas) {
151
- var ctx = canvas.getContext('2d');
72
+ const ctx = canvas.getContext('2d');
152
73
  if (!ctx)
153
74
  return true;
154
- var chunkSize = 50;
155
- for (var x = 0; x < canvas.width; x += chunkSize) {
156
- for (var y = 0; y < canvas.height; y += chunkSize) {
157
- var getImageData = ctx.getImageData;
158
- var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData
75
+ const chunkSize = 50;
76
+ for (let x = 0; x < canvas.width; x += chunkSize) {
77
+ for (let y = 0; y < canvas.height; y += chunkSize) {
78
+ const getImageData = ctx.getImageData;
79
+ const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData
159
80
  ? getImageData[ORIGINAL_ATTRIBUTE_NAME]
160
81
  : getImageData;
161
- var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
162
- if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))
82
+ const pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
83
+ if (pixelBuffer.some((pixel) => pixel !== 0))
163
84
  return false;
164
85
  }
165
86
  }
166
87
  return true;
167
88
  }
168
89
 
169
- var _id = 1;
170
- var tagNameRegex = new RegExp('[^a-z0-9-_:]');
171
- var IGNORED_NODE = -2;
90
+ let _id = 1;
91
+ const tagNameRegex = new RegExp('[^a-z0-9-_:]');
92
+ const IGNORED_NODE = -2;
172
93
  function genId() {
173
94
  return _id++;
174
95
  }
@@ -176,7 +97,7 @@ function getValidTagName(element) {
176
97
  if (element instanceof HTMLFormElement) {
177
98
  return 'form';
178
99
  }
179
- var processedTagName = element.tagName.toLowerCase().trim();
100
+ const processedTagName = element.tagName.toLowerCase().trim();
180
101
  if (tagNameRegex.test(processedTagName)) {
181
102
  return 'div';
182
103
  }
@@ -184,7 +105,7 @@ function getValidTagName(element) {
184
105
  }
185
106
  function getCssRulesString(s) {
186
107
  try {
187
- var rules = s.rules || s.cssRules;
108
+ const rules = s.rules || s.cssRules;
188
109
  return rules ? Array.from(rules).map(getCssRuleString).join('') : null;
189
110
  }
190
111
  catch (error) {
@@ -192,7 +113,7 @@ function getCssRulesString(s) {
192
113
  }
193
114
  }
194
115
  function getCssRuleString(rule) {
195
- var cssStringified = rule.cssText;
116
+ let cssStringified = rule.cssText;
196
117
  if (isCSSImportRule(rule)) {
197
118
  try {
198
119
  cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
@@ -208,12 +129,12 @@ function isCSSImportRule(rule) {
208
129
  function stringifyStyleSheet(sheet) {
209
130
  return sheet.cssRules
210
131
  ? Array.from(sheet.cssRules)
211
- .map(function (rule) { return rule.cssText || ''; })
132
+ .map((rule) => rule.cssText || '')
212
133
  .join('')
213
134
  : '';
214
135
  }
215
136
  function extractOrigin(url) {
216
- var origin = '';
137
+ let origin = '';
217
138
  if (url.indexOf('//') > -1) {
218
139
  origin = url.split('/').slice(0, 3).join('/');
219
140
  }
@@ -223,32 +144,31 @@ function extractOrigin(url) {
223
144
  origin = origin.split('?')[0];
224
145
  return origin;
225
146
  }
226
- var canvasService;
227
- var canvasCtx;
228
- var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
229
- var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/;
230
- var DATA_URI = /^(data:)([^,]*),(.*)/i;
147
+ let canvasService;
148
+ let canvasCtx;
149
+ const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
150
+ const RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/;
151
+ const DATA_URI = /^(data:)([^,]*),(.*)/i;
231
152
  function absoluteToStylesheet(cssText, href) {
232
- return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {
233
- var filePath = path1 || path2 || path3;
234
- var maybeQuote = quote1 || quote2 || '';
153
+ return (cssText || '').replace(URL_IN_CSS_REF, (origin, quote1, path1, quote2, path2, path3) => {
154
+ const filePath = path1 || path2 || path3;
155
+ const maybeQuote = quote1 || quote2 || '';
235
156
  if (!filePath) {
236
157
  return origin;
237
158
  }
238
159
  if (!RELATIVE_PATH.test(filePath)) {
239
- return "url(" + maybeQuote + filePath + maybeQuote + ")";
160
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
240
161
  }
241
162
  if (DATA_URI.test(filePath)) {
242
- return "url(" + maybeQuote + filePath + maybeQuote + ")";
163
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
243
164
  }
244
165
  if (filePath[0] === '/') {
245
- return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
166
+ return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
246
167
  }
247
- var stack = href.split('/');
248
- var parts = filePath.split('/');
168
+ const stack = href.split('/');
169
+ const parts = filePath.split('/');
249
170
  stack.pop();
250
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
251
- var part = parts_1[_i];
171
+ for (const part of parts) {
252
172
  if (part === '.') {
253
173
  continue;
254
174
  }
@@ -259,19 +179,19 @@ function absoluteToStylesheet(cssText, href) {
259
179
  stack.push(part);
260
180
  }
261
181
  }
262
- return "url(" + maybeQuote + stack.join('/') + maybeQuote + ")";
182
+ return `url(${maybeQuote}${stack.join('/')}${maybeQuote})`;
263
183
  });
264
184
  }
265
- var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
266
- var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
185
+ const SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
186
+ const SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
267
187
  function getAbsoluteSrcsetString(doc, attributeValue) {
268
188
  if (attributeValue.trim() === '') {
269
189
  return attributeValue;
270
190
  }
271
- var pos = 0;
191
+ let pos = 0;
272
192
  function collectCharacters(regEx) {
273
- var chars;
274
- var match = regEx.exec(attributeValue.substring(pos));
193
+ let chars;
194
+ let match = regEx.exec(attributeValue.substring(pos));
275
195
  if (match) {
276
196
  chars = match[0];
277
197
  pos += chars.length;
@@ -279,23 +199,23 @@ function getAbsoluteSrcsetString(doc, attributeValue) {
279
199
  }
280
200
  return '';
281
201
  }
282
- var output = [];
202
+ let output = [];
283
203
  while (true) {
284
204
  collectCharacters(SRCSET_COMMAS_OR_SPACES);
285
205
  if (pos >= attributeValue.length) {
286
206
  break;
287
207
  }
288
- var url = collectCharacters(SRCSET_NOT_SPACES);
208
+ let url = collectCharacters(SRCSET_NOT_SPACES);
289
209
  if (url.slice(-1) === ',') {
290
210
  url = absoluteToDoc(doc, url.substring(0, url.length - 1));
291
211
  output.push(url);
292
212
  }
293
213
  else {
294
- var descriptorsStr = '';
214
+ let descriptorsStr = '';
295
215
  url = absoluteToDoc(doc, url);
296
- var inParens = false;
216
+ let inParens = false;
297
217
  while (true) {
298
- var c = attributeValue.charAt(pos);
218
+ let c = attributeValue.charAt(pos);
299
219
  if (c === '') {
300
220
  output.push((url + descriptorsStr).trim());
301
221
  break;
@@ -326,7 +246,7 @@ function absoluteToDoc(doc, attributeValue) {
326
246
  if (!attributeValue || attributeValue.trim() === '') {
327
247
  return attributeValue;
328
248
  }
329
- var a = doc.createElement('a');
249
+ const a = doc.createElement('a');
330
250
  a.href = attributeValue;
331
251
  return a.href;
332
252
  }
@@ -334,7 +254,7 @@ function isSVGElement(el) {
334
254
  return Boolean(el.tagName === 'svg' || el.ownerSVGElement);
335
255
  }
336
256
  function getHref() {
337
- var a = document.createElement('a');
257
+ const a = document.createElement('a');
338
258
  a.href = '';
339
259
  return a.href;
340
260
  }
@@ -373,8 +293,8 @@ function _isBlockedElement(element, blockClass, blockSelector, unblockSelector)
373
293
  }
374
294
  }
375
295
  else {
376
- for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {
377
- var className = element.classList[eIndex];
296
+ for (let eIndex = 0; eIndex < element.classList.length; eIndex++) {
297
+ const className = element.classList[eIndex];
378
298
  if (blockClass.test(className)) {
379
299
  return true;
380
300
  }
@@ -402,8 +322,8 @@ function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelect
402
322
  }
403
323
  }
404
324
  else {
405
- for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {
406
- var className = node.classList[eIndex];
325
+ for (let eIndex = 0; eIndex < node.classList.length; eIndex++) {
326
+ const className = node.classList[eIndex];
407
327
  if (maskTextClass.test(className)) {
408
328
  return true;
409
329
  }
@@ -422,12 +342,12 @@ function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelect
422
342
  return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
423
343
  }
424
344
  function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
425
- var win = iframeEl.contentWindow;
345
+ const win = iframeEl.contentWindow;
426
346
  if (!win) {
427
347
  return;
428
348
  }
429
- var fired = false;
430
- var readyState;
349
+ let fired = false;
350
+ let readyState;
431
351
  try {
432
352
  readyState = win.document.readyState;
433
353
  }
@@ -435,20 +355,20 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
435
355
  return;
436
356
  }
437
357
  if (readyState !== 'complete') {
438
- var timer_1 = setTimeout(function () {
358
+ const timer = setTimeout(() => {
439
359
  if (!fired) {
440
360
  listener();
441
361
  fired = true;
442
362
  }
443
363
  }, iframeLoadTimeout);
444
- iframeEl.addEventListener('load', function () {
445
- clearTimeout(timer_1);
364
+ iframeEl.addEventListener('load', () => {
365
+ clearTimeout(timer);
446
366
  fired = true;
447
367
  listener();
448
368
  });
449
369
  return;
450
370
  }
451
- var blankUrl = 'about:blank';
371
+ const blankUrl = 'about:blank';
452
372
  if (win.location.href !== blankUrl ||
453
373
  iframeEl.src === blankUrl ||
454
374
  iframeEl.src === '') {
@@ -459,10 +379,10 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
459
379
  }
460
380
  function serializeNode(n, options) {
461
381
  var _a;
462
- var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, inlineStylesheet = options.inlineStylesheet, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn;
463
- var rootId;
382
+ const { doc, blockClass, blockSelector, unblockSelector, maskTextClass, maskTextSelector, unmaskTextSelector, inlineStylesheet, maskInputSelector, unmaskInputSelector, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, } = options;
383
+ let rootId;
464
384
  if (doc.__sn) {
465
- var docId = doc.__sn.id;
385
+ const docId = doc.__sn.id;
466
386
  rootId = docId === 1 ? undefined : docId;
467
387
  }
468
388
  switch (n.nodeType) {
@@ -472,14 +392,14 @@ function serializeNode(n, options) {
472
392
  type: NodeType.Document,
473
393
  childNodes: [],
474
394
  compatMode: n.compatMode,
475
- rootId: rootId
395
+ rootId,
476
396
  };
477
397
  }
478
398
  else {
479
399
  return {
480
400
  type: NodeType.Document,
481
401
  childNodes: [],
482
- rootId: rootId
402
+ rootId,
483
403
  };
484
404
  }
485
405
  case n.DOCUMENT_TYPE_NODE:
@@ -488,28 +408,27 @@ function serializeNode(n, options) {
488
408
  name: n.name,
489
409
  publicId: n.publicId,
490
410
  systemId: n.systemId,
491
- rootId: rootId
411
+ rootId,
492
412
  };
493
413
  case n.ELEMENT_NODE:
494
- var needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);
495
- var tagName = getValidTagName(n);
496
- var attributes_1 = {};
497
- for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) {
498
- var _e = _d[_i], name_1 = _e.name, value = _e.value;
499
- attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value);
414
+ const needBlock = _isBlockedElement(n, blockClass, blockSelector, unblockSelector);
415
+ const tagName = getValidTagName(n);
416
+ let attributes = {};
417
+ for (const { name, value } of Array.from(n.attributes)) {
418
+ attributes[name] = transformAttribute(doc, tagName, name, value);
500
419
  }
501
420
  if (tagName === 'link' && inlineStylesheet) {
502
- var stylesheet = Array.from(doc.styleSheets).find(function (s) {
421
+ const stylesheet = Array.from(doc.styleSheets).find((s) => {
503
422
  return s.href === n.href;
504
423
  });
505
- var cssText = null;
424
+ let cssText = null;
506
425
  if (stylesheet) {
507
426
  cssText = getCssRulesString(stylesheet);
508
427
  }
509
428
  if (cssText) {
510
- delete attributes_1.rel;
511
- delete attributes_1.href;
512
- attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);
429
+ delete attributes.rel;
430
+ delete attributes.href;
431
+ attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
513
432
  }
514
433
  }
515
434
  if (tagName === 'style' &&
@@ -517,57 +436,57 @@ function serializeNode(n, options) {
517
436
  !(n.innerText ||
518
437
  n.textContent ||
519
438
  '').trim().length) {
520
- var cssText = getCssRulesString(n.sheet);
439
+ const cssText = getCssRulesString(n.sheet);
521
440
  if (cssText) {
522
- attributes_1._cssText = absoluteToStylesheet(cssText, getHref());
441
+ attributes._cssText = absoluteToStylesheet(cssText, getHref());
523
442
  }
524
443
  }
525
444
  if (tagName === 'input' ||
526
445
  tagName === 'textarea' ||
527
446
  tagName === 'select') {
528
- var value = n.value;
529
- if (attributes_1.type !== 'radio' &&
530
- attributes_1.type !== 'checkbox' &&
531
- attributes_1.type !== 'submit' &&
532
- attributes_1.type !== 'button' &&
447
+ const value = n.value;
448
+ if (attributes.type !== 'radio' &&
449
+ attributes.type !== 'checkbox' &&
450
+ attributes.type !== 'submit' &&
451
+ attributes.type !== 'button' &&
533
452
  value) {
534
- attributes_1.value = maskInputValue({
453
+ attributes.value = maskInputValue({
535
454
  input: n,
536
- type: attributes_1.type,
537
- tagName: tagName,
538
- value: value,
539
- maskInputSelector: maskInputSelector,
540
- unmaskInputSelector: unmaskInputSelector,
541
- maskInputOptions: maskInputOptions,
542
- maskInputFn: maskInputFn
455
+ type: attributes.type,
456
+ tagName,
457
+ value,
458
+ maskInputSelector,
459
+ unmaskInputSelector,
460
+ maskInputOptions,
461
+ maskInputFn,
543
462
  });
544
463
  }
545
464
  else if (n.checked) {
546
- attributes_1.checked = n.checked;
465
+ attributes.checked = n.checked;
547
466
  }
548
467
  }
549
468
  if (tagName === 'option') {
550
469
  if (n.selected && !maskInputOptions['select']) {
551
- attributes_1.selected = true;
470
+ attributes.selected = true;
552
471
  }
553
472
  else {
554
- delete attributes_1.selected;
473
+ delete attributes.selected;
555
474
  }
556
475
  }
557
476
  if (tagName === 'canvas' && recordCanvas) {
558
477
  if (n.__context === '2d') {
559
478
  if (!is2DCanvasBlank(n)) {
560
- attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
479
+ attributes.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
561
480
  }
562
481
  }
563
482
  else if (!('__context' in n)) {
564
- var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
565
- var blankCanvas = document.createElement('canvas');
483
+ const canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
484
+ const blankCanvas = document.createElement('canvas');
566
485
  blankCanvas.width = n.width;
567
486
  blankCanvas.height = n.height;
568
- var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
487
+ const blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
569
488
  if (canvasDataURL !== blankCanvasDataURL) {
570
- attributes_1.rr_dataURL = canvasDataURL;
489
+ attributes.rr_dataURL = canvasDataURL;
571
490
  }
572
491
  }
573
492
  }
@@ -576,68 +495,68 @@ function serializeNode(n, options) {
576
495
  canvasService = doc.createElement('canvas');
577
496
  canvasCtx = canvasService.getContext('2d');
578
497
  }
579
- var image_1 = n;
580
- var oldValue_1 = image_1.crossOrigin;
581
- image_1.crossOrigin = 'anonymous';
582
- var recordInlineImage = function () {
498
+ const image = n;
499
+ const oldValue = image.crossOrigin;
500
+ image.crossOrigin = 'anonymous';
501
+ const recordInlineImage = () => {
583
502
  try {
584
- canvasService.width = image_1.naturalWidth;
585
- canvasService.height = image_1.naturalHeight;
586
- canvasCtx.drawImage(image_1, 0, 0);
587
- attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
503
+ canvasService.width = image.naturalWidth;
504
+ canvasService.height = image.naturalHeight;
505
+ canvasCtx.drawImage(image, 0, 0);
506
+ attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
588
507
  }
589
508
  catch (err) {
590
- console.warn("Cannot inline img src=" + image_1.currentSrc + "! Error: " + err);
509
+ console.warn(`Cannot inline img src=${image.currentSrc}! Error: ${err}`);
591
510
  }
592
- oldValue_1
593
- ? (attributes_1.crossOrigin = oldValue_1)
594
- : delete attributes_1.crossOrigin;
511
+ oldValue
512
+ ? (attributes.crossOrigin = oldValue)
513
+ : delete attributes.crossOrigin;
595
514
  };
596
- if (image_1.complete && image_1.naturalWidth !== 0)
515
+ if (image.complete && image.naturalWidth !== 0)
597
516
  recordInlineImage();
598
517
  else
599
- image_1.onload = recordInlineImage;
518
+ image.onload = recordInlineImage;
600
519
  }
601
520
  if (tagName === 'audio' || tagName === 'video') {
602
- attributes_1.rr_mediaState = n.paused
521
+ attributes.rr_mediaState = n.paused
603
522
  ? 'paused'
604
523
  : 'played';
605
- attributes_1.rr_mediaCurrentTime = n.currentTime;
524
+ attributes.rr_mediaCurrentTime = n.currentTime;
606
525
  }
607
526
  if (n.scrollLeft) {
608
- attributes_1.rr_scrollLeft = n.scrollLeft;
527
+ attributes.rr_scrollLeft = n.scrollLeft;
609
528
  }
610
529
  if (n.scrollTop) {
611
- attributes_1.rr_scrollTop = n.scrollTop;
530
+ attributes.rr_scrollTop = n.scrollTop;
612
531
  }
613
532
  if (needBlock) {
614
- var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height;
615
- attributes_1 = {
616
- "class": attributes_1["class"],
617
- rr_width: width + "px",
618
- rr_height: height + "px"
533
+ const { width, height } = n.getBoundingClientRect();
534
+ attributes = {
535
+ class: attributes.class,
536
+ rr_width: `${width}px`,
537
+ rr_height: `${height}px`,
619
538
  };
620
539
  }
621
- if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) {
540
+ if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) {
622
541
  if (!n.contentDocument) {
623
- attributes_1.rr_src = attributes_1.src;
542
+ attributes.rr_src = attributes.src;
624
543
  }
625
- delete attributes_1.src;
544
+ delete attributes.src;
626
545
  }
627
546
  return {
628
547
  type: NodeType.Element,
629
- tagName: tagName,
630
- attributes: attributes_1,
548
+ tagName,
549
+ attributes,
631
550
  childNodes: [],
632
551
  isSVG: isSVGElement(n) || undefined,
633
- needBlock: needBlock,
634
- rootId: rootId
552
+ needBlock,
553
+ rootId,
635
554
  };
636
555
  case n.TEXT_NODE:
637
- var parentTagName = n.parentNode && n.parentNode.tagName;
638
- var textContent = n.textContent;
639
- var isStyle = parentTagName === 'STYLE' ? true : undefined;
640
- var isScript = parentTagName === 'SCRIPT' ? true : undefined;
556
+ const parentTagName = n.parentNode && n.parentNode.tagName;
557
+ let textContent = n.textContent;
558
+ const isStyle = parentTagName === 'STYLE' ? true : undefined;
559
+ const isScript = parentTagName === 'SCRIPT' ? true : undefined;
641
560
  if (isStyle && textContent) {
642
561
  try {
643
562
  if (n.nextSibling || n.previousSibling) {
@@ -647,7 +566,7 @@ function serializeNode(n, options) {
647
566
  }
648
567
  }
649
568
  catch (err) {
650
- console.warn("Cannot get CSS styles from text's parentNode. Error: " + err, n);
569
+ console.warn(`Cannot get CSS styles from text's parentNode. Error: ${err}`, n);
651
570
  }
652
571
  textContent = absoluteToStylesheet(textContent, getHref());
653
572
  }
@@ -665,20 +584,20 @@ function serializeNode(n, options) {
665
584
  return {
666
585
  type: NodeType.Text,
667
586
  textContent: textContent || '',
668
- isStyle: isStyle,
669
- rootId: rootId
587
+ isStyle,
588
+ rootId,
670
589
  };
671
590
  case n.CDATA_SECTION_NODE:
672
591
  return {
673
592
  type: NodeType.CDATA,
674
593
  textContent: '',
675
- rootId: rootId
594
+ rootId,
676
595
  };
677
596
  case n.COMMENT_NODE:
678
597
  return {
679
598
  type: NodeType.Comment,
680
599
  textContent: n.textContent || '',
681
- rootId: rootId
600
+ rootId,
682
601
  };
683
602
  default:
684
603
  return false;
@@ -764,32 +683,32 @@ function slimDOMExcluded(sn, slimDOMOptions) {
764
683
  return false;
765
684
  }
766
685
  function serializeNodeWithId(n, options) {
767
- var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, unblockSelector = options.unblockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, unmaskTextSelector = options.unmaskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, maskInputSelector = options.maskInputSelector, unmaskInputSelector = options.unmaskInputSelector, _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, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h;
768
- var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j;
769
- var _serializedNode = serializeNode(n, {
770
- doc: doc,
771
- blockClass: blockClass,
772
- blockSelector: blockSelector,
773
- unblockSelector: unblockSelector,
774
- maskTextClass: maskTextClass,
775
- maskTextSelector: maskTextSelector,
776
- unmaskTextSelector: unmaskTextSelector,
777
- inlineStylesheet: inlineStylesheet,
778
- maskInputSelector: maskInputSelector,
779
- unmaskInputSelector: unmaskInputSelector,
780
- maskInputOptions: maskInputOptions,
781
- maskTextFn: maskTextFn,
782
- maskInputFn: maskInputFn,
783
- dataURLOptions: dataURLOptions,
784
- inlineImages: inlineImages,
785
- recordCanvas: recordCanvas,
786
- keepIframeSrcFn: keepIframeSrcFn
686
+ const { doc, map, blockClass, blockSelector, unblockSelector, maskTextClass, maskTextSelector, unmaskTextSelector, skipChild = false, inlineStylesheet = true, maskInputSelector, unmaskInputSelector, maskInputOptions = {}, maskTextFn, maskInputFn, slimDOMOptions, dataURLOptions = {}, inlineImages = false, recordCanvas = false, onSerialize, onIframeLoad, iframeLoadTimeout = 5000, keepIframeSrcFn = () => false, } = options;
687
+ let { preserveWhiteSpace = true } = options;
688
+ const _serializedNode = serializeNode(n, {
689
+ doc,
690
+ blockClass,
691
+ blockSelector,
692
+ unblockSelector,
693
+ maskTextClass,
694
+ maskTextSelector,
695
+ unmaskTextSelector,
696
+ inlineStylesheet,
697
+ maskInputSelector,
698
+ unmaskInputSelector,
699
+ maskInputOptions,
700
+ maskTextFn,
701
+ maskInputFn,
702
+ dataURLOptions,
703
+ inlineImages,
704
+ recordCanvas,
705
+ keepIframeSrcFn,
787
706
  });
788
707
  if (!_serializedNode) {
789
708
  console.warn(n, 'not serialized');
790
709
  return null;
791
710
  }
792
- var id;
711
+ let id;
793
712
  if ('__sn' in n) {
794
713
  id = n.__sn.id;
795
714
  }
@@ -803,7 +722,7 @@ function serializeNodeWithId(n, options) {
803
722
  else {
804
723
  id = genId();
805
724
  }
806
- var serializedNode = Object.assign(_serializedNode, { id: id });
725
+ const serializedNode = Object.assign(_serializedNode, { id });
807
726
  n.__sn = serializedNode;
808
727
  if (id === IGNORED_NODE) {
809
728
  return null;
@@ -812,7 +731,7 @@ function serializeNodeWithId(n, options) {
812
731
  if (onSerialize) {
813
732
  onSerialize(n);
814
733
  }
815
- var recordChild = !skipChild;
734
+ let recordChild = !skipChild;
816
735
  if (serializedNode.type === NodeType.Element) {
817
736
  recordChild = recordChild && !serializedNode.needBlock;
818
737
  delete serializedNode.needBlock;
@@ -827,43 +746,41 @@ function serializeNodeWithId(n, options) {
827
746
  _serializedNode.tagName === 'head') {
828
747
  preserveWhiteSpace = false;
829
748
  }
830
- var bypassOptions = {
831
- doc: doc,
832
- map: map,
833
- blockClass: blockClass,
834
- blockSelector: blockSelector,
835
- unblockSelector: unblockSelector,
836
- maskTextClass: maskTextClass,
837
- maskTextSelector: maskTextSelector,
838
- unmaskTextSelector: unmaskTextSelector,
839
- skipChild: skipChild,
840
- inlineStylesheet: inlineStylesheet,
841
- maskInputSelector: maskInputSelector,
842
- unmaskInputSelector: unmaskInputSelector,
843
- maskInputOptions: maskInputOptions,
844
- maskTextFn: maskTextFn,
845
- maskInputFn: maskInputFn,
846
- slimDOMOptions: slimDOMOptions,
847
- dataURLOptions: dataURLOptions,
848
- inlineImages: inlineImages,
849
- recordCanvas: recordCanvas,
850
- preserveWhiteSpace: preserveWhiteSpace,
851
- onSerialize: onSerialize,
852
- onIframeLoad: onIframeLoad,
853
- iframeLoadTimeout: iframeLoadTimeout,
854
- keepIframeSrcFn: keepIframeSrcFn
749
+ const bypassOptions = {
750
+ doc,
751
+ map,
752
+ blockClass,
753
+ blockSelector,
754
+ unblockSelector,
755
+ maskTextClass,
756
+ maskTextSelector,
757
+ unmaskTextSelector,
758
+ skipChild,
759
+ inlineStylesheet,
760
+ maskInputSelector,
761
+ unmaskInputSelector,
762
+ maskInputOptions,
763
+ maskTextFn,
764
+ maskInputFn,
765
+ slimDOMOptions,
766
+ dataURLOptions,
767
+ inlineImages,
768
+ recordCanvas,
769
+ preserveWhiteSpace,
770
+ onSerialize,
771
+ onIframeLoad,
772
+ iframeLoadTimeout,
773
+ keepIframeSrcFn,
855
774
  };
856
- for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) {
857
- var childN = _k[_i];
858
- var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
775
+ for (const childN of Array.from(n.childNodes)) {
776
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
859
777
  if (serializedChildNode) {
860
778
  serializedNode.childNodes.push(serializedChildNode);
861
779
  }
862
780
  }
863
781
  if (isElement(n) && n.shadowRoot) {
864
- for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) {
865
- var childN = _m[_l];
866
- var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
782
+ for (const childN of Array.from(n.shadowRoot.childNodes)) {
783
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
867
784
  if (serializedChildNode) {
868
785
  serializedChildNode.isShadow = true;
869
786
  serializedNode.childNodes.push(serializedChildNode);
@@ -876,34 +793,34 @@ function serializeNodeWithId(n, options) {
876
793
  }
877
794
  if (serializedNode.type === NodeType.Element &&
878
795
  serializedNode.tagName === 'iframe') {
879
- onceIframeLoaded(n, function () {
880
- var iframeDoc = n.contentDocument;
796
+ onceIframeLoaded(n, () => {
797
+ const iframeDoc = n.contentDocument;
881
798
  if (iframeDoc && onIframeLoad) {
882
- var serializedIframeNode = serializeNodeWithId(iframeDoc, {
799
+ const serializedIframeNode = serializeNodeWithId(iframeDoc, {
883
800
  doc: iframeDoc,
884
- map: map,
885
- blockClass: blockClass,
886
- blockSelector: blockSelector,
887
- unblockSelector: unblockSelector,
888
- maskTextClass: maskTextClass,
889
- maskTextSelector: maskTextSelector,
890
- unmaskTextSelector: unmaskTextSelector,
801
+ map,
802
+ blockClass,
803
+ blockSelector,
804
+ unblockSelector,
805
+ maskTextClass,
806
+ maskTextSelector,
807
+ unmaskTextSelector,
891
808
  skipChild: false,
892
- inlineStylesheet: inlineStylesheet,
893
- maskInputSelector: maskInputSelector,
894
- unmaskInputSelector: unmaskInputSelector,
895
- maskInputOptions: maskInputOptions,
896
- maskTextFn: maskTextFn,
897
- maskInputFn: maskInputFn,
898
- slimDOMOptions: slimDOMOptions,
899
- dataURLOptions: dataURLOptions,
900
- inlineImages: inlineImages,
901
- recordCanvas: recordCanvas,
902
- preserveWhiteSpace: preserveWhiteSpace,
903
- onSerialize: onSerialize,
904
- onIframeLoad: onIframeLoad,
905
- iframeLoadTimeout: iframeLoadTimeout,
906
- keepIframeSrcFn: keepIframeSrcFn
809
+ inlineStylesheet,
810
+ maskInputSelector,
811
+ unmaskInputSelector,
812
+ maskInputOptions,
813
+ maskTextFn,
814
+ maskInputFn,
815
+ slimDOMOptions,
816
+ dataURLOptions,
817
+ inlineImages,
818
+ recordCanvas,
819
+ preserveWhiteSpace,
820
+ onSerialize,
821
+ onIframeLoad,
822
+ iframeLoadTimeout,
823
+ keepIframeSrcFn,
907
824
  });
908
825
  if (serializedIframeNode) {
909
826
  onIframeLoad(n, serializedIframeNode);
@@ -914,9 +831,9 @@ function serializeNodeWithId(n, options) {
914
831
  return serializedNode;
915
832
  }
916
833
  function snapshot(n, options) {
917
- var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.unblockSelector, unblockSelector = _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.unmaskTextSelector, unmaskTextSelector = _g === void 0 ? null : _g, _h = _a.inlineStylesheet, inlineStylesheet = _h === void 0 ? true : _h, _j = _a.inlineImages, inlineImages = _j === void 0 ? false : _j, _k = _a.recordCanvas, recordCanvas = _k === void 0 ? false : _k, _l = _a.maskInputSelector, maskInputSelector = _l === void 0 ? null : _l, _m = _a.unmaskInputSelector, unmaskInputSelector = _m === void 0 ? null : _m, _o = _a.maskAllInputs, maskAllInputs = _o === void 0 ? false : _o, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _p = _a.slimDOM, slimDOM = _p === void 0 ? false : _p, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _q = _a.keepIframeSrcFn, keepIframeSrcFn = _q === void 0 ? function () { return false; } : _q;
918
- var idNodeMap = {};
919
- var maskInputOptions = maskAllInputs === true
834
+ const { blockClass = 'rr-block', blockSelector = null, unblockSelector = null, maskTextClass = 'rr-mask', maskTextSelector = null, unmaskTextSelector = null, inlineStylesheet = true, inlineImages = false, recordCanvas = false, maskInputSelector = null, unmaskInputSelector = null, maskAllInputs = false, maskTextFn, maskInputFn, slimDOM = false, dataURLOptions, preserveWhiteSpace, onSerialize, onIframeLoad, iframeLoadTimeout, keepIframeSrcFn = () => false, } = options || {};
835
+ const idNodeMap = {};
836
+ const maskInputOptions = maskAllInputs === true
920
837
  ? {
921
838
  color: true,
922
839
  date: true,
@@ -933,14 +850,14 @@ function snapshot(n, options) {
933
850
  week: true,
934
851
  textarea: true,
935
852
  select: true,
936
- password: true
853
+ password: true,
937
854
  }
938
855
  : maskAllInputs === false
939
856
  ? {
940
- password: true
857
+ password: true,
941
858
  }
942
859
  : maskAllInputs;
943
- var slimDOMOptions = slimDOM === true || slimDOM === 'all'
860
+ const slimDOMOptions = slimDOM === true || slimDOM === 'all'
944
861
  ?
945
862
  {
946
863
  script: true,
@@ -952,7 +869,7 @@ function snapshot(n, options) {
952
869
  headMetaRobots: true,
953
870
  headMetaHttpEquiv: true,
954
871
  headMetaAuthorship: true,
955
- headMetaVerification: true
872
+ headMetaVerification: true,
956
873
  }
957
874
  : slimDOM === false
958
875
  ? {}
@@ -961,28 +878,28 @@ function snapshot(n, options) {
961
878
  serializeNodeWithId(n, {
962
879
  doc: n,
963
880
  map: idNodeMap,
964
- blockClass: blockClass,
965
- blockSelector: blockSelector,
966
- unblockSelector: unblockSelector,
967
- maskTextClass: maskTextClass,
968
- maskTextSelector: maskTextSelector,
969
- unmaskTextSelector: unmaskTextSelector,
881
+ blockClass,
882
+ blockSelector,
883
+ unblockSelector,
884
+ maskTextClass,
885
+ maskTextSelector,
886
+ unmaskTextSelector,
970
887
  skipChild: false,
971
- inlineStylesheet: inlineStylesheet,
972
- maskInputSelector: maskInputSelector,
973
- unmaskInputSelector: unmaskInputSelector,
974
- maskInputOptions: maskInputOptions,
975
- maskTextFn: maskTextFn,
976
- maskInputFn: maskInputFn,
977
- slimDOMOptions: slimDOMOptions,
978
- dataURLOptions: dataURLOptions,
979
- inlineImages: inlineImages,
980
- recordCanvas: recordCanvas,
981
- preserveWhiteSpace: preserveWhiteSpace,
982
- onSerialize: onSerialize,
983
- onIframeLoad: onIframeLoad,
984
- iframeLoadTimeout: iframeLoadTimeout,
985
- keepIframeSrcFn: keepIframeSrcFn
888
+ inlineStylesheet,
889
+ maskInputSelector,
890
+ unmaskInputSelector,
891
+ maskInputOptions,
892
+ maskTextFn,
893
+ maskInputFn,
894
+ slimDOMOptions,
895
+ dataURLOptions,
896
+ inlineImages,
897
+ recordCanvas,
898
+ preserveWhiteSpace,
899
+ onSerialize,
900
+ onIframeLoad,
901
+ iframeLoadTimeout,
902
+ keepIframeSrcFn,
986
903
  }),
987
904
  idNodeMap,
988
905
  ];
@@ -1062,71 +979,67 @@ var ReplayerEvents;
1062
979
  ReplayerEvents["PlayBack"] = "play-back";
1063
980
  })(ReplayerEvents || (ReplayerEvents = {}));
1064
981
 
1065
- function on(type, fn, target) {
1066
- if (target === void 0) { target = document; }
1067
- var options = { capture: true, passive: true };
982
+ function on(type, fn, target = document) {
983
+ const options = { capture: true, passive: true };
1068
984
  target.addEventListener(type, fn, options);
1069
- return function () { return target.removeEventListener(type, fn, options); };
985
+ return () => target.removeEventListener(type, fn, options);
1070
986
  }
1071
987
  function createMirror() {
1072
988
  return {
1073
989
  map: {},
1074
- getId: function (n) {
990
+ getId(n) {
1075
991
  if (!n || !n.__sn) {
1076
992
  return -1;
1077
993
  }
1078
994
  return n.__sn.id;
1079
995
  },
1080
- getNode: function (id) {
996
+ getNode(id) {
1081
997
  return this.map[id] || null;
1082
998
  },
1083
- removeNodeFromMap: function (n) {
1084
- var _this = this;
1085
- var id = n.__sn && n.__sn.id;
999
+ removeNodeFromMap(n) {
1000
+ const id = n.__sn && n.__sn.id;
1086
1001
  delete this.map[id];
1087
1002
  if (n.childNodes) {
1088
- n.childNodes.forEach(function (child) {
1089
- return _this.removeNodeFromMap(child);
1090
- });
1003
+ n.childNodes.forEach((child) => this.removeNodeFromMap(child));
1091
1004
  }
1092
1005
  },
1093
- has: function (id) {
1006
+ has(id) {
1094
1007
  return this.map.hasOwnProperty(id);
1095
1008
  },
1096
- reset: function () {
1009
+ reset() {
1097
1010
  this.map = {};
1098
1011
  },
1099
1012
  };
1100
1013
  }
1101
- var DEPARTED_MIRROR_ACCESS_WARNING = 'Please stop import mirror directly. Instead of that,' +
1014
+ const DEPARTED_MIRROR_ACCESS_WARNING = 'Please stop import mirror directly. Instead of that,' +
1102
1015
  '\r\n' +
1103
1016
  'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +
1104
1017
  '\r\n' +
1105
1018
  'or you can use record.mirror to access the mirror instance during recording.';
1106
- var _mirror = {
1019
+ let _mirror = {
1107
1020
  map: {},
1108
- getId: function () {
1021
+ getId() {
1109
1022
  console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1110
1023
  return -1;
1111
1024
  },
1112
- getNode: function () {
1025
+ getNode() {
1113
1026
  console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1114
1027
  return null;
1115
1028
  },
1116
- removeNodeFromMap: function () {
1029
+ removeNodeFromMap() {
1117
1030
  console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1118
1031
  },
1119
- has: function () {
1032
+ has() {
1120
1033
  console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1121
1034
  return false;
1122
1035
  },
1123
- reset: function () {
1036
+ reset() {
1124
1037
  console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1125
1038
  },
1126
1039
  };
1127
1040
  if (typeof window !== 'undefined' && window.Proxy && window.Reflect) {
1128
1041
  _mirror = new Proxy(_mirror, {
1129
- get: function (target, prop, receiver) {
1042
+ get(target, prop, receiver) {
1130
1043
  if (prop === 'map') {
1131
1044
  console.error(DEPARTED_MIRROR_ACCESS_WARNING);
1132
1045
  }
@@ -1134,18 +1047,17 @@ if (typeof window !== 'undefined' && window.Proxy && window.Reflect) {
1134
1047
  },
1135
1048
  });
1136
1049
  }
1137
- function throttle(func, wait, options) {
1138
- if (options === void 0) { options = {}; }
1139
- var timeout = null;
1140
- var previous = 0;
1050
+ function throttle(func, wait, options = {}) {
1051
+ let timeout = null;
1052
+ let previous = 0;
1141
1053
  return function (arg) {
1142
- var now = Date.now();
1054
+ let now = Date.now();
1143
1055
  if (!previous && options.leading === false) {
1144
1056
  previous = now;
1145
1057
  }
1146
- var remaining = wait - (now - previous);
1147
- var context = this;
1148
- var args = arguments;
1058
+ let remaining = wait - (now - previous);
1059
+ let context = this;
1060
+ let args = arguments;
1149
1061
  if (remaining <= 0 || remaining > wait) {
1150
1062
  if (timeout) {
1151
1063
  clearTimeout(timeout);
@@ -1155,7 +1067,7 @@ function throttle(func, wait, options) {
1155
1067
  func.apply(context, args);
1156
1068
  }
1157
1069
  else if (!timeout && options.trailing !== false) {
1158
- timeout = setTimeout(function () {
1070
+ timeout = setTimeout(() => {
1159
1071
  previous = options.leading === false ? 0 : Date.now();
1160
1072
  timeout = null;
1161
1073
  func.apply(context, args);
@@ -1163,47 +1075,45 @@ function throttle(func, wait, options) {
1163
1075
  }
1164
1076
  };
1165
1077
  }
1166
- function hookSetter(target, key, d, isRevoked, win) {
1167
- if (win === void 0) { win = window; }
1168
- var original = win.Object.getOwnPropertyDescriptor(target, key);
1078
+ function hookSetter(target, key, d, isRevoked, win = window) {
1079
+ const original = win.Object.getOwnPropertyDescriptor(target, key);
1169
1080
  win.Object.defineProperty(target, key, isRevoked
1170
1081
  ? d
1171
1082
  : {
1172
- set: function (value) {
1173
- var _this = this;
1174
- setTimeout(function () {
1175
- d.set.call(_this, value);
1083
+ set(value) {
1084
+ setTimeout(() => {
1085
+ d.set.call(this, value);
1176
1086
  }, 0);
1177
1087
  if (original && original.set) {
1178
1088
  original.set.call(this, value);
1179
1089
  }
1180
1090
  },
1181
1091
  });
1182
- return function () { return hookSetter(target, key, original || {}, true); };
1092
+ return () => hookSetter(target, key, original || {}, true);
1183
1093
  }
1184
1094
  function patch(source, name, replacement) {
1185
1095
  try {
1186
1096
  if (!(name in source)) {
1187
- return function () { };
1097
+ return () => { };
1188
1098
  }
1189
- var original_1 = source[name];
1190
- var wrapped = replacement(original_1);
1099
+ const original = source[name];
1100
+ const wrapped = replacement(original);
1191
1101
  if (typeof wrapped === 'function') {
1192
1102
  wrapped.prototype = wrapped.prototype || {};
1193
1103
  Object.defineProperties(wrapped, {
1194
1104
  __rrweb_original__: {
1195
1105
  enumerable: false,
1196
- value: original_1,
1106
+ value: original,
1197
1107
  },
1198
1108
  });
1199
1109
  }
1200
1110
  source[name] = wrapped;
1201
- return function () {
1202
- source[name] = original_1;
1111
+ return () => {
1112
+ source[name] = original;
1203
1113
  };
1204
1114
  }
1205
1115
  catch (_a) {
1206
- return function () { };
1116
+ return () => { };
1207
1117
  }
1208
1118
  }
1209
1119
  function getWindowHeight() {
@@ -1221,23 +1131,23 @@ function isBlocked(node, blockClass) {
1221
1131
  return false;
1222
1132
  }
1223
1133
  if (node.nodeType === node.ELEMENT_NODE) {
1224
- var needBlock_1 = false;
1134
+ let needBlock = false;
1225
1135
  if (typeof blockClass === 'string') {
1226
1136
  if (node.closest !== undefined) {
1227
1137
  return node.closest('.' + blockClass) !== null;
1228
1138
  }
1229
1139
  else {
1230
- needBlock_1 = node.classList.contains(blockClass);
1140
+ needBlock = node.classList.contains(blockClass);
1231
1141
  }
1232
1142
  }
1233
1143
  else {
1234
- node.classList.forEach(function (className) {
1144
+ node.classList.forEach((className) => {
1235
1145
  if (blockClass.test(className)) {
1236
- needBlock_1 = true;
1146
+ needBlock = true;
1237
1147
  }
1238
1148
  });
1239
1149
  }
1240
- return needBlock_1 || isBlocked(node.parentNode, blockClass);
1150
+ return needBlock || isBlocked(node.parentNode, blockClass);
1241
1151
  }
1242
1152
  if (node.nodeType === node.TEXT_NODE) {
1243
1153
  return isBlocked(node.parentNode, blockClass);
@@ -1254,7 +1164,7 @@ function isAncestorRemoved(target, mirror) {
1254
1164
  if (isShadowRoot(target)) {
1255
1165
  return false;
1256
1166
  }
1257
- var id = mirror.getId(target);
1167
+ const id = mirror.getId(target);
1258
1168
  if (!mirror.has(id)) {
1259
1169
  return true;
1260
1170
  }
@@ -1270,8 +1180,7 @@ function isAncestorRemoved(target, mirror) {
1270
1180
  function isTouchEvent(event) {
1271
1181
  return Boolean(event.changedTouches);
1272
1182
  }
1273
- function polyfill(win) {
1274
- if (win === void 0) { win = window; }
1183
+ function polyfill(win = window) {
1275
1184
  if ('NodeList' in win && !win.NodeList.prototype.forEach) {
1276
1185
  win.NodeList.prototype.forEach = Array.prototype
1277
1186
  .forEach;
@@ -1307,30 +1216,30 @@ function hasShadowRoot(n) {
1307
1216
  function isNodeInLinkedList(n) {
1308
1217
  return '__ln' in n;
1309
1218
  }
1310
- var DoubleLinkedList = (function () {
1311
- function DoubleLinkedList() {
1219
+ class DoubleLinkedList {
1220
+ constructor() {
1312
1221
  this.length = 0;
1313
1222
  this.head = null;
1314
1223
  }
1315
- DoubleLinkedList.prototype.get = function (position) {
1224
+ get(position) {
1316
1225
  if (position >= this.length) {
1317
1226
  throw new Error('Position outside of list range');
1318
1227
  }
1319
- var current = this.head;
1320
- for (var index = 0; index < position; index++) {
1228
+ let current = this.head;
1229
+ for (let index = 0; index < position; index++) {
1321
1230
  current = (current === null || current === void 0 ? void 0 : current.next) || null;
1322
1231
  }
1323
1232
  return current;
1324
- };
1325
- DoubleLinkedList.prototype.addNode = function (n) {
1326
- var node = {
1233
+ }
1234
+ addNode(n) {
1235
+ const node = {
1327
1236
  value: n,
1328
1237
  previous: null,
1329
1238
  next: null,
1330
1239
  };
1331
1240
  n.__ln = node;
1332
1241
  if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {
1333
- var current = n.previousSibling.__ln.next;
1242
+ const current = n.previousSibling.__ln.next;
1334
1243
  node.next = current;
1335
1244
  node.previous = n.previousSibling.__ln;
1336
1245
  n.previousSibling.__ln.next = node;
@@ -1341,7 +1250,7 @@ var DoubleLinkedList = (function () {
1341
1250
  else if (n.nextSibling &&
1342
1251
  isNodeInLinkedList(n.nextSibling) &&
1343
1252
  n.nextSibling.__ln.previous) {
1344
- var current = n.nextSibling.__ln.previous;
1253
+ const current = n.nextSibling.__ln.previous;
1345
1254
  node.previous = current;
1346
1255
  node.next = n.nextSibling.__ln;
1347
1256
  n.nextSibling.__ln.previous = node;
@@ -1357,9 +1266,9 @@ var DoubleLinkedList = (function () {
1357
1266
  this.head = node;
1358
1267
  }
1359
1268
  this.length++;
1360
- };
1361
- DoubleLinkedList.prototype.removeNode = function (n) {
1362
- var current = n.__ln;
1269
+ }
1270
+ removeNode(n) {
1271
+ const current = n.__ln;
1363
1272
  if (!this.head) {
1364
1273
  return;
1365
1274
  }
@@ -1379,16 +1288,14 @@ var DoubleLinkedList = (function () {
1379
1288
  delete n.__ln;
1380
1289
  }
1381
1290
  this.length--;
1382
- };
1383
- return DoubleLinkedList;
1384
- }());
1385
- var moveKey = function (id, parentId) { return "".concat(id, "@").concat(parentId); };
1291
+ }
1292
+ }
1293
+ const moveKey = (id, parentId) => `${id}@${parentId}`;
1386
1294
  function isINode(n) {
1387
1295
  return '__sn' in n;
1388
1296
  }
1389
- var MutationBuffer = (function () {
1390
- function MutationBuffer() {
1391
- var _this = this;
1297
+ class MutationBuffer {
1298
+ constructor() {
1392
1299
  this.frozen = false;
1393
1300
  this.locked = false;
1394
1301
  this.texts = [];
@@ -1399,146 +1306,125 @@ var MutationBuffer = (function () {
1399
1306
  this.addedSet = new Set();
1400
1307
  this.movedSet = new Set();
1401
1308
  this.droppedSet = new Set();
1402
- this.processMutations = function (mutations) {
1403
- mutations.forEach(_this.processMutation);
1404
- _this.emit();
1309
+ this.processMutations = (mutations) => {
1310
+ mutations.forEach(this.processMutation);
1311
+ this.emit();
1405
1312
  };
1406
- this.emit = function () {
1407
- var e_1, _a, e_2, _b;
1408
- if (_this.frozen || _this.locked) {
1313
+ this.emit = () => {
1314
+ if (this.frozen || this.locked) {
1409
1315
  return;
1410
1316
  }
1411
- var adds = [];
1412
- var addList = new DoubleLinkedList();
1413
- var getNextId = function (n) {
1414
- var ns = n;
1415
- var nextId = IGNORED_NODE;
1317
+ const adds = [];
1318
+ const addList = new DoubleLinkedList();
1319
+ const getNextId = (n) => {
1320
+ let ns = n;
1321
+ let nextId = IGNORED_NODE;
1416
1322
  while (nextId === IGNORED_NODE) {
1417
1323
  ns = ns && ns.nextSibling;
1418
- nextId = ns && _this.mirror.getId(ns);
1324
+ nextId = ns && this.mirror.getId(ns);
1419
1325
  }
1420
1326
  return nextId;
1421
1327
  };
1422
- var pushAdd = function (n) {
1328
+ const pushAdd = (n) => {
1423
1329
  var _a, _b, _c, _d, _e;
1424
- var shadowHost = n.getRootNode
1330
+ const shadowHost = n.getRootNode
1425
1331
  ? (_a = n.getRootNode()) === null || _a === void 0 ? void 0 : _a.host
1426
1332
  : null;
1427
- var rootShadowHost = shadowHost;
1333
+ let rootShadowHost = shadowHost;
1428
1334
  while ((_c = (_b = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _b === void 0 ? void 0 : _b.call(rootShadowHost)) === null || _c === void 0 ? void 0 : _c.host)
1429
1335
  rootShadowHost =
1430
1336
  ((_e = (_d = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _d === void 0 ? void 0 : _d.call(rootShadowHost)) === null || _e === void 0 ? void 0 : _e.host) ||
1431
1337
  null;
1432
- var notInDoc = !_this.doc.contains(n) &&
1433
- (rootShadowHost === null || !_this.doc.contains(rootShadowHost));
1338
+ const notInDoc = !this.doc.contains(n) &&
1339
+ (rootShadowHost === null || !this.doc.contains(rootShadowHost));
1434
1340
  if (!n.parentNode || notInDoc) {
1435
1341
  return;
1436
1342
  }
1437
- var parentId = isShadowRoot(n.parentNode)
1438
- ? _this.mirror.getId(shadowHost)
1439
- : _this.mirror.getId(n.parentNode);
1440
- var nextId = getNextId(n);
1343
+ const parentId = isShadowRoot(n.parentNode)
1344
+ ? this.mirror.getId(shadowHost)
1345
+ : this.mirror.getId(n.parentNode);
1346
+ const nextId = getNextId(n);
1441
1347
  if (parentId === -1 || nextId === -1) {
1442
1348
  return addList.addNode(n);
1443
1349
  }
1444
- var sn = serializeNodeWithId(n, {
1445
- doc: _this.doc,
1446
- map: _this.mirror.map,
1447
- blockClass: _this.blockClass,
1448
- blockSelector: _this.blockSelector,
1449
- unblockSelector: _this.unblockSelector,
1450
- maskTextClass: _this.maskTextClass,
1451
- maskTextSelector: _this.maskTextSelector,
1452
- unmaskTextSelector: _this.unmaskTextSelector,
1453
- maskInputSelector: _this.maskInputSelector,
1454
- unmaskInputSelector: _this.unmaskInputSelector,
1350
+ let sn = serializeNodeWithId(n, {
1351
+ doc: this.doc,
1352
+ map: this.mirror.map,
1353
+ blockClass: this.blockClass,
1354
+ blockSelector: this.blockSelector,
1355
+ unblockSelector: this.unblockSelector,
1356
+ maskTextClass: this.maskTextClass,
1357
+ maskTextSelector: this.maskTextSelector,
1358
+ unmaskTextSelector: this.unmaskTextSelector,
1359
+ maskInputSelector: this.maskInputSelector,
1360
+ unmaskInputSelector: this.unmaskInputSelector,
1455
1361
  skipChild: true,
1456
- inlineStylesheet: _this.inlineStylesheet,
1457
- maskInputOptions: _this.maskInputOptions,
1458
- maskTextFn: _this.maskTextFn,
1459
- maskInputFn: _this.maskInputFn,
1460
- slimDOMOptions: _this.slimDOMOptions,
1461
- recordCanvas: _this.recordCanvas,
1462
- inlineImages: _this.inlineImages,
1463
- onSerialize: function (currentN) {
1362
+ inlineStylesheet: this.inlineStylesheet,
1363
+ maskInputOptions: this.maskInputOptions,
1364
+ maskTextFn: this.maskTextFn,
1365
+ maskInputFn: this.maskInputFn,
1366
+ slimDOMOptions: this.slimDOMOptions,
1367
+ recordCanvas: this.recordCanvas,
1368
+ inlineImages: this.inlineImages,
1369
+ onSerialize: (currentN) => {
1464
1370
  if (isIframeINode(currentN)) {
1465
- _this.iframeManager.addIframe(currentN);
1371
+ this.iframeManager.addIframe(currentN);
1466
1372
  }
1467
1373
  if (hasShadowRoot(n)) {
1468
- _this.shadowDomManager.addShadowRoot(n.shadowRoot, document);
1374
+ this.shadowDomManager.addShadowRoot(n.shadowRoot, document);
1469
1375
  }
1470
1376
  },
1471
- onIframeLoad: function (iframe, childSn) {
1472
- _this.iframeManager.attachIframe(iframe, childSn);
1473
- _this.shadowDomManager.observeAttachShadow(iframe);
1377
+ onIframeLoad: (iframe, childSn) => {
1378
+ this.iframeManager.attachIframe(iframe, childSn);
1379
+ this.shadowDomManager.observeAttachShadow(iframe);
1474
1380
  },
1475
1381
  });
1476
1382
  if (sn) {
1477
1383
  adds.push({
1478
- parentId: parentId,
1479
- nextId: nextId,
1384
+ parentId,
1385
+ nextId,
1480
1386
  node: sn,
1481
1387
  });
1482
1388
  }
1483
1389
  };
1484
- while (_this.mapRemoves.length) {
1485
- _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
1390
+ while (this.mapRemoves.length) {
1391
+ this.mirror.removeNodeFromMap(this.mapRemoves.shift());
1486
1392
  }
1487
- try {
1488
- for (var _c = __values(_this.movedSet), _d = _c.next(); !_d.done; _d = _c.next()) {
1489
- var n = _d.value;
1490
- if (isParentRemoved(_this.removes, n, _this.mirror) &&
1491
- !_this.movedSet.has(n.parentNode)) {
1492
- continue;
1493
- }
1494
- pushAdd(n);
1393
+ for (const n of this.movedSet) {
1394
+ if (isParentRemoved(this.removes, n, this.mirror) &&
1395
+ !this.movedSet.has(n.parentNode)) {
1396
+ continue;
1495
1397
  }
1398
+ pushAdd(n);
1496
1399
  }
1497
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1498
- finally {
1499
- try {
1500
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1400
+ for (const n of this.addedSet) {
1401
+ if (!isAncestorInSet(this.droppedSet, n) &&
1402
+ !isParentRemoved(this.removes, n, this.mirror)) {
1403
+ pushAdd(n);
1501
1404
  }
1502
- finally { if (e_1) throw e_1.error; }
1503
- }
1504
- try {
1505
- for (var _e = __values(_this.addedSet), _f = _e.next(); !_f.done; _f = _e.next()) {
1506
- var n = _f.value;
1507
- if (!isAncestorInSet(_this.droppedSet, n) &&
1508
- !isParentRemoved(_this.removes, n, _this.mirror)) {
1509
- pushAdd(n);
1510
- }
1511
- else if (isAncestorInSet(_this.movedSet, n)) {
1512
- pushAdd(n);
1513
- }
1514
- else {
1515
- _this.droppedSet.add(n);
1516
- }
1405
+ else if (isAncestorInSet(this.movedSet, n)) {
1406
+ pushAdd(n);
1517
1407
  }
1518
- }
1519
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1520
- finally {
1521
- try {
1522
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
1408
+ else {
1409
+ this.droppedSet.add(n);
1523
1410
  }
1524
- finally { if (e_2) throw e_2.error; }
1525
1411
  }
1526
- var candidate = null;
1412
+ let candidate = null;
1527
1413
  while (addList.length) {
1528
- var node = null;
1414
+ let node = null;
1529
1415
  if (candidate) {
1530
- var parentId = _this.mirror.getId(candidate.value.parentNode);
1531
- var nextId = getNextId(candidate.value);
1416
+ const parentId = this.mirror.getId(candidate.value.parentNode);
1417
+ const nextId = getNextId(candidate.value);
1532
1418
  if (parentId !== -1 && nextId !== -1) {
1533
1419
  node = candidate;
1534
1420
  }
1535
1421
  }
1536
1422
  if (!node) {
1537
- for (var index = addList.length - 1; index >= 0; index--) {
1538
- var _node = addList.get(index);
1423
+ for (let index = addList.length - 1; index >= 0; index--) {
1424
+ const _node = addList.get(index);
1539
1425
  if (_node) {
1540
- var parentId = _this.mirror.getId(_node.value.parentNode);
1541
- var nextId = getNextId(_node.value);
1426
+ const parentId = this.mirror.getId(_node.value.parentNode);
1427
+ const nextId = getNextId(_node.value);
1542
1428
  if (parentId !== -1 && nextId !== -1) {
1543
1429
  node = _node;
1544
1430
  break;
@@ -1556,21 +1442,21 @@ var MutationBuffer = (function () {
1556
1442
  addList.removeNode(node.value);
1557
1443
  pushAdd(node.value);
1558
1444
  }
1559
- var payload = {
1560
- texts: _this.texts
1561
- .map(function (text) { return ({
1562
- id: _this.mirror.getId(text.node),
1445
+ const payload = {
1446
+ texts: this.texts
1447
+ .map((text) => ({
1448
+ id: this.mirror.getId(text.node),
1563
1449
  value: text.value,
1564
- }); })
1565
- .filter(function (text) { return _this.mirror.has(text.id); }),
1566
- attributes: _this.attributes
1567
- .map(function (attribute) { return ({
1568
- id: _this.mirror.getId(attribute.node),
1450
+ }))
1451
+ .filter((text) => this.mirror.has(text.id)),
1452
+ attributes: this.attributes
1453
+ .map((attribute) => ({
1454
+ id: this.mirror.getId(attribute.node),
1569
1455
  attributes: attribute.attributes,
1570
- }); })
1571
- .filter(function (attribute) { return _this.mirror.has(attribute.id); }),
1572
- removes: _this.removes,
1573
- adds: adds,
1456
+ }))
1457
+ .filter((attribute) => this.mirror.has(attribute.id)),
1458
+ removes: this.removes,
1459
+ adds,
1574
1460
  };
1575
1461
  if (!payload.texts.length &&
1576
1462
  !payload.attributes.length &&
@@ -1578,28 +1464,27 @@ var MutationBuffer = (function () {
1578
1464
  !payload.adds.length) {
1579
1465
  return;
1580
1466
  }
1581
- _this.texts = [];
1582
- _this.attributes = [];
1583
- _this.removes = [];
1584
- _this.addedSet = new Set();
1585
- _this.movedSet = new Set();
1586
- _this.droppedSet = new Set();
1587
- _this.movedMap = {};
1588
- _this.mutationCb(payload);
1467
+ this.texts = [];
1468
+ this.attributes = [];
1469
+ this.removes = [];
1470
+ this.addedSet = new Set();
1471
+ this.movedSet = new Set();
1472
+ this.droppedSet = new Set();
1473
+ this.movedMap = {};
1474
+ this.mutationCb(payload);
1589
1475
  };
1590
- this.processMutation = function (m) {
1591
- var e_3, _a, e_4, _b;
1476
+ this.processMutation = (m) => {
1592
1477
  if (isIgnored(m.target)) {
1593
1478
  return;
1594
1479
  }
1595
1480
  switch (m.type) {
1596
1481
  case 'characterData': {
1597
- var value = m.target.textContent;
1598
- if (!isBlocked(m.target, _this.blockClass) && value !== m.oldValue) {
1599
- _this.texts.push({
1600
- value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, _this.unmaskTextSelector) && value
1601
- ? _this.maskTextFn
1602
- ? _this.maskTextFn(value)
1482
+ const value = m.target.textContent;
1483
+ if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {
1484
+ this.texts.push({
1485
+ value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector, this.unmaskTextSelector) && value
1486
+ ? this.maskTextFn
1487
+ ? this.maskTextFn(value)
1603
1488
  : value.replace(/[\S]/g, '*')
1604
1489
  : value,
1605
1490
  node: m.target,
@@ -1608,33 +1493,33 @@ var MutationBuffer = (function () {
1608
1493
  break;
1609
1494
  }
1610
1495
  case 'attributes': {
1611
- var target = m.target;
1612
- var value = m.target.getAttribute(m.attributeName);
1496
+ const target = m.target;
1497
+ let value = m.target.getAttribute(m.attributeName);
1613
1498
  if (m.attributeName === 'value') {
1614
1499
  value = maskInputValue({
1615
1500
  input: target,
1616
- maskInputSelector: _this.maskInputSelector,
1617
- unmaskInputSelector: _this.unmaskInputSelector,
1618
- maskInputOptions: _this.maskInputOptions,
1501
+ maskInputSelector: this.maskInputSelector,
1502
+ unmaskInputSelector: this.unmaskInputSelector,
1503
+ maskInputOptions: this.maskInputOptions,
1619
1504
  tagName: m.target.tagName,
1620
1505
  type: m.target.getAttribute('type'),
1621
- value: value,
1622
- maskInputFn: _this.maskInputFn,
1506
+ value,
1507
+ maskInputFn: this.maskInputFn,
1623
1508
  });
1624
1509
  }
1625
- if (isBlocked(m.target, _this.blockClass) || value === m.oldValue) {
1510
+ if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {
1626
1511
  return;
1627
1512
  }
1628
- var item = _this.attributes.find(function (a) { return a.node === m.target; });
1513
+ let item = this.attributes.find((a) => a.node === m.target);
1629
1514
  if (!item) {
1630
1515
  item = {
1631
1516
  node: m.target,
1632
1517
  attributes: {},
1633
1518
  };
1634
- _this.attributes.push(item);
1519
+ this.attributes.push(item);
1635
1520
  }
1636
1521
  if (m.attributeName === 'style') {
1637
- var old = _this.doc.createElement('span');
1522
+ const old = this.doc.createElement('span');
1638
1523
  if (m.oldValue) {
1639
1524
  old.setAttribute('style', m.oldValue);
1640
1525
  }
@@ -1643,44 +1528,24 @@ var MutationBuffer = (function () {
1643
1528
  item.attributes.style = {};
1644
1529
  }
1645
1530
  try {
1646
- var styleObj = item.attributes.style;
1647
- try {
1648
- for (var _c = __values(Array.from(target.style)), _d = _c.next(); !_d.done; _d = _c.next()) {
1649
- var pname = _d.value;
1650
- var newValue = target.style.getPropertyValue(pname);
1651
- var newPriority = target.style.getPropertyPriority(pname);
1652
- if (newValue !== old.style.getPropertyValue(pname) ||
1653
- newPriority !== old.style.getPropertyPriority(pname)) {
1654
- if (newPriority === '') {
1655
- styleObj[pname] = newValue;
1656
- }
1657
- else {
1658
- styleObj[pname] = [newValue, newPriority];
1659
- }
1531
+ const styleObj = item.attributes.style;
1532
+ for (const pname of Array.from(target.style)) {
1533
+ const newValue = target.style.getPropertyValue(pname);
1534
+ const newPriority = target.style.getPropertyPriority(pname);
1535
+ if (newValue !== old.style.getPropertyValue(pname) ||
1536
+ newPriority !== old.style.getPropertyPriority(pname)) {
1537
+ if (newPriority === '') {
1538
+ styleObj[pname] = newValue;
1660
1539
  }
1661
- }
1662
- }
1663
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1664
- finally {
1665
- try {
1666
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1667
- }
1668
- finally { if (e_3) throw e_3.error; }
1669
- }
1670
- try {
1671
- for (var _e = __values(Array.from(old.style)), _f = _e.next(); !_f.done; _f = _e.next()) {
1672
- var pname = _f.value;
1673
- if (target.style.getPropertyValue(pname) === '') {
1674
- styleObj[pname] = false;
1540
+ else {
1541
+ styleObj[pname] = [newValue, newPriority];
1675
1542
  }
1676
1543
  }
1677
1544
  }
1678
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1679
- finally {
1680
- try {
1681
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
1545
+ for (const pname of Array.from(old.style)) {
1546
+ if (target.style.getPropertyValue(pname) === '') {
1547
+ styleObj[pname] = false;
1682
1548
  }
1683
- finally { if (e_4) throw e_4.error; }
1684
1549
  }
1685
1550
  }
1686
1551
  catch (error) {
@@ -1688,70 +1553,69 @@ var MutationBuffer = (function () {
1688
1553
  }
1689
1554
  }
1690
1555
  else {
1691
- item.attributes[m.attributeName] = transformAttribute(_this.doc, m.target.tagName, m.attributeName, value);
1556
+ item.attributes[m.attributeName] = transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
1692
1557
  }
1693
1558
  break;
1694
1559
  }
1695
1560
  case 'childList': {
1696
- m.addedNodes.forEach(function (n) { return _this.genAdds(n, m.target); });
1697
- m.removedNodes.forEach(function (n) {
1698
- var nodeId = _this.mirror.getId(n);
1699
- var parentId = isShadowRoot(m.target)
1700
- ? _this.mirror.getId(m.target.host)
1701
- : _this.mirror.getId(m.target);
1702
- if (isBlocked(m.target, _this.blockClass) || isIgnored(n)) {
1561
+ m.addedNodes.forEach((n) => this.genAdds(n, m.target));
1562
+ m.removedNodes.forEach((n) => {
1563
+ const nodeId = this.mirror.getId(n);
1564
+ const parentId = isShadowRoot(m.target)
1565
+ ? this.mirror.getId(m.target.host)
1566
+ : this.mirror.getId(m.target);
1567
+ if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {
1703
1568
  return;
1704
1569
  }
1705
- if (_this.addedSet.has(n)) {
1706
- deepDelete(_this.addedSet, n);
1707
- _this.droppedSet.add(n);
1570
+ if (this.addedSet.has(n)) {
1571
+ deepDelete(this.addedSet, n);
1572
+ this.droppedSet.add(n);
1708
1573
  }
1709
- else if (_this.addedSet.has(m.target) && nodeId === -1) ;
1710
- else if (isAncestorRemoved(m.target, _this.mirror)) ;
1711
- else if (_this.movedSet.has(n) &&
1712
- _this.movedMap[moveKey(nodeId, parentId)]) {
1713
- deepDelete(_this.movedSet, n);
1574
+ else if (this.addedSet.has(m.target) && nodeId === -1) ;
1575
+ else if (isAncestorRemoved(m.target, this.mirror)) ;
1576
+ else if (this.movedSet.has(n) &&
1577
+ this.movedMap[moveKey(nodeId, parentId)]) {
1578
+ deepDelete(this.movedSet, n);
1714
1579
  }
1715
1580
  else {
1716
- _this.removes.push({
1717
- parentId: parentId,
1581
+ this.removes.push({
1582
+ parentId,
1718
1583
  id: nodeId,
1719
1584
  isShadow: isShadowRoot(m.target) ? true : undefined,
1720
1585
  });
1721
1586
  }
1722
- _this.mapRemoves.push(n);
1587
+ this.mapRemoves.push(n);
1723
1588
  });
1724
1589
  break;
1725
1590
  }
1726
1591
  }
1727
1592
  };
1728
- this.genAdds = function (n, target) {
1729
- if (target && isBlocked(target, _this.blockClass)) {
1593
+ this.genAdds = (n, target) => {
1594
+ if (target && isBlocked(target, this.blockClass)) {
1730
1595
  return;
1731
1596
  }
1732
1597
  if (isINode(n)) {
1733
1598
  if (isIgnored(n)) {
1734
1599
  return;
1735
1600
  }
1736
- _this.movedSet.add(n);
1737
- var targetId = null;
1601
+ this.movedSet.add(n);
1602
+ let targetId = null;
1738
1603
  if (target && isINode(target)) {
1739
1604
  targetId = target.__sn.id;
1740
1605
  }
1741
1606
  if (targetId) {
1742
- _this.movedMap[moveKey(n.__sn.id, targetId)] = true;
1607
+ this.movedMap[moveKey(n.__sn.id, targetId)] = true;
1743
1608
  }
1744
1609
  }
1745
1610
  else {
1746
- _this.addedSet.add(n);
1747
- _this.droppedSet.delete(n);
1611
+ this.addedSet.add(n);
1612
+ this.droppedSet.delete(n);
1748
1613
  }
1749
- if (!isBlocked(n, _this.blockClass))
1750
- n.childNodes.forEach(function (childN) { return _this.genAdds(childN); });
1614
+ if (!isBlocked(n, this.blockClass))
1615
+ n.childNodes.forEach((childN) => this.genAdds(childN));
1751
1616
  };
1752
1617
  }
1753
- MutationBuffer.prototype.init = function (options) {
1754
- var _this = this;
1618
+ init(options) {
1755
1619
  [
1756
1620
  'mutationCb',
1757
1621
  'blockClass',
@@ -1774,54 +1638,53 @@ var MutationBuffer = (function () {
1774
1638
  'iframeManager',
1775
1639
  'shadowDomManager',
1776
1640
  'canvasManager',
1777
- ].forEach(function (key) {
1778
- _this[key] = options[key];
1641
+ ].forEach((key) => {
1642
+ this[key] = options[key];
1779
1643
  });
1780
- };
1781
- MutationBuffer.prototype.freeze = function () {
1644
+ }
1645
+ freeze() {
1782
1646
  this.frozen = true;
1783
1647
  this.canvasManager.freeze();
1784
- };
1785
- MutationBuffer.prototype.unfreeze = function () {
1648
+ }
1649
+ unfreeze() {
1786
1650
  this.frozen = false;
1787
1651
  this.canvasManager.unfreeze();
1788
1652
  this.emit();
1789
- };
1790
- MutationBuffer.prototype.isFrozen = function () {
1653
+ }
1654
+ isFrozen() {
1791
1655
  return this.frozen;
1792
- };
1793
- MutationBuffer.prototype.lock = function () {
1656
+ }
1657
+ lock() {
1794
1658
  this.locked = true;
1795
1659
  this.canvasManager.lock();
1796
- };
1797
- MutationBuffer.prototype.unlock = function () {
1660
+ }
1661
+ unlock() {
1798
1662
  this.locked = false;
1799
1663
  this.canvasManager.unlock();
1800
1664
  this.emit();
1801
- };
1802
- MutationBuffer.prototype.reset = function () {
1665
+ }
1666
+ reset() {
1803
1667
  this.shadowDomManager.reset();
1804
1668
  this.canvasManager.reset();
1805
- };
1806
- return MutationBuffer;
1807
- }());
1669
+ }
1670
+ }
1808
1671
  function deepDelete(addsSet, n) {
1809
1672
  addsSet.delete(n);
1810
- n.childNodes.forEach(function (childN) { return deepDelete(addsSet, childN); });
1673
+ n.childNodes.forEach((childN) => deepDelete(addsSet, childN));
1811
1674
  }
1812
1675
  function isParentRemoved(removes, n, mirror) {
1813
- var parentNode = n.parentNode;
1676
+ const { parentNode } = n;
1814
1677
  if (!parentNode) {
1815
1678
  return false;
1816
1679
  }
1817
- var parentId = mirror.getId(parentNode);
1818
- if (removes.some(function (r) { return r.id === parentId; })) {
1680
+ const parentId = mirror.getId(parentNode);
1681
+ if (removes.some((r) => r.id === parentId)) {
1819
1682
  return true;
1820
1683
  }
1821
1684
  return isParentRemoved(removes, parentNode, mirror);
1822
1685
  }
1823
1686
  function isAncestorInSet(set, n) {
1824
- var parentNode = n.parentNode;
1687
+ const { parentNode } = n;
1825
1688
  if (!parentNode) {
1826
1689
  return false;
1827
1690
  }
@@ -1831,17 +1694,28 @@ function isAncestorInSet(set, n) {
1831
1694
  return isAncestorInSet(set, parentNode);
1832
1695
  }
1833
1696
 
1834
- const MutationBuffer$1 = MutationBuffer;
1697
+ const callbackWrapper = (cb) => {
1698
+ const rrwebWrapped = (...rest) => {
1699
+ try {
1700
+ return cb(...rest);
1701
+ }
1702
+ catch (error) {
1703
+ try {
1704
+ error.__rrweb__ = true;
1705
+ }
1706
+ catch (_a) {
1707
+ }
1708
+ throw error;
1709
+ }
1710
+ };
1711
+ return rrwebWrapped;
1712
+ };
1835
1713
 
1836
- var mutationBuffers = [];
1837
- var isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined';
1838
- var isCSSMediaRuleSupported = typeof CSSMediaRule !== 'undefined';
1839
- var isCSSSupportsRuleSupported = typeof CSSSupportsRule !== 'undefined';
1840
- var isCSSConditionRuleSupported = typeof CSSConditionRule !== 'undefined';
1714
+ const mutationBuffers = [];
1841
1715
  function getEventTarget(event) {
1842
1716
  try {
1843
1717
  if ('composedPath' in event) {
1844
- var path = event.composedPath();
1718
+ const path = event.composedPath();
1845
1719
  if (path.length) {
1846
1720
  return path[0];
1847
1721
  }
@@ -1855,17 +1729,17 @@ function getEventTarget(event) {
1855
1729
  }
1856
1730
  function initMutationObserver(options, rootEl) {
1857
1731
  var _a, _b;
1858
- var mutationBuffer = new MutationBuffer$1();
1732
+ const mutationBuffer = new MutationBuffer();
1859
1733
  mutationBuffers.push(mutationBuffer);
1860
1734
  mutationBuffer.init(options);
1861
- var mutationObserverCtor = window.MutationObserver ||
1735
+ let mutationObserverCtor = window.MutationObserver ||
1862
1736
  window.__rrMutationObserver;
1863
- var 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');
1737
+ 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');
1864
1738
  if (angularZoneSymbol &&
1865
1739
  window[angularZoneSymbol]) {
1866
1740
  mutationObserverCtor = window[angularZoneSymbol];
1867
1741
  }
1868
- var observer = new mutationObserverCtor(mutationBuffer.processMutations.bind(mutationBuffer));
1742
+ const observer = new mutationObserverCtor(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
1869
1743
  observer.observe(rootEl, {
1870
1744
  attributes: true,
1871
1745
  attributeOldValue: true,
@@ -1876,31 +1750,30 @@ function initMutationObserver(options, rootEl) {
1876
1750
  });
1877
1751
  return observer;
1878
1752
  }
1879
- function initMoveObserver(_a) {
1880
- var mousemoveCb = _a.mousemoveCb, sampling = _a.sampling, doc = _a.doc, mirror = _a.mirror;
1753
+ function initMoveObserver({ mousemoveCb, sampling, doc, mirror, }) {
1881
1754
  if (sampling.mousemove === false) {
1882
- return function () { };
1755
+ return () => { };
1883
1756
  }
1884
- var threshold = typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;
1885
- var callbackThreshold = typeof sampling.mousemoveCallback === 'number'
1757
+ const threshold = typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;
1758
+ const callbackThreshold = typeof sampling.mousemoveCallback === 'number'
1886
1759
  ? sampling.mousemoveCallback
1887
1760
  : 500;
1888
- var positions = [];
1889
- var timeBaseline;
1890
- var wrappedCb = throttle(function (source) {
1891
- var totalOffset = Date.now() - timeBaseline;
1892
- mousemoveCb(positions.map(function (p) {
1761
+ let positions = [];
1762
+ let timeBaseline;
1763
+ const wrappedCb = throttle((source) => {
1764
+ const totalOffset = Date.now() - timeBaseline;
1765
+ callbackWrapper(mousemoveCb)(positions.map((p) => {
1893
1766
  p.timeOffset -= totalOffset;
1894
1767
  return p;
1895
1768
  }), source);
1896
1769
  positions = [];
1897
1770
  timeBaseline = null;
1898
1771
  }, callbackThreshold);
1899
- var updatePosition = throttle(function (evt) {
1900
- var target = getEventTarget(evt);
1901
- var _a = isTouchEvent(evt)
1772
+ const updatePosition = throttle((evt) => {
1773
+ const target = getEventTarget(evt);
1774
+ const { clientX, clientY } = isTouchEvent(evt)
1902
1775
  ? evt.changedTouches[0]
1903
- : evt, clientX = _a.clientX, clientY = _a.clientY;
1776
+ : evt;
1904
1777
  if (!timeBaseline) {
1905
1778
  timeBaseline = Date.now();
1906
1779
  }
@@ -1918,95 +1791,90 @@ function initMoveObserver(_a) {
1918
1791
  }, threshold, {
1919
1792
  trailing: false,
1920
1793
  });
1921
- var handlers = [
1922
- on('mousemove', updatePosition, doc),
1923
- on('touchmove', updatePosition, doc),
1924
- on('drag', updatePosition, doc),
1794
+ const handlers = [
1795
+ on('mousemove', callbackWrapper(updatePosition), doc),
1796
+ on('touchmove', callbackWrapper(updatePosition), doc),
1797
+ on('drag', callbackWrapper(updatePosition), doc),
1925
1798
  ];
1926
- return function () {
1927
- handlers.forEach(function (h) { return h(); });
1928
- };
1799
+ return callbackWrapper(() => {
1800
+ handlers.forEach((h) => h());
1801
+ });
1929
1802
  }
1930
- function initMouseInteractionObserver(_a) {
1931
- var mouseInteractionCb = _a.mouseInteractionCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, sampling = _a.sampling;
1803
+ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockClass, sampling, }) {
1932
1804
  if (sampling.mouseInteraction === false) {
1933
- return function () { };
1805
+ return () => { };
1934
1806
  }
1935
- var disableMap = sampling.mouseInteraction === true ||
1807
+ const disableMap = sampling.mouseInteraction === true ||
1936
1808
  sampling.mouseInteraction === undefined
1937
1809
  ? {}
1938
1810
  : sampling.mouseInteraction;
1939
- var handlers = [];
1940
- var getHandler = function (eventKey) {
1941
- return function (event) {
1942
- var target = getEventTarget(event);
1811
+ const handlers = [];
1812
+ const getHandler = (eventKey) => {
1813
+ return (event) => {
1814
+ const target = getEventTarget(event);
1943
1815
  if (isBlocked(target, blockClass)) {
1944
1816
  return;
1945
1817
  }
1946
- var e = isTouchEvent(event) ? event.changedTouches[0] : event;
1818
+ const e = isTouchEvent(event) ? event.changedTouches[0] : event;
1947
1819
  if (!e) {
1948
1820
  return;
1949
1821
  }
1950
- var id = mirror.getId(target);
1951
- var clientX = e.clientX, clientY = e.clientY;
1952
- mouseInteractionCb({
1822
+ const id = mirror.getId(target);
1823
+ const { clientX, clientY } = e;
1824
+ callbackWrapper(mouseInteractionCb)({
1953
1825
  type: MouseInteractions[eventKey],
1954
- id: id,
1826
+ id,
1955
1827
  x: clientX,
1956
1828
  y: clientY,
1957
1829
  });
1958
1830
  };
1959
1831
  };
1960
1832
  Object.keys(MouseInteractions)
1961
- .filter(function (key) {
1962
- return Number.isNaN(Number(key)) &&
1963
- !key.endsWith('_Departed') &&
1964
- disableMap[key] !== false;
1965
- })
1966
- .forEach(function (eventKey) {
1967
- var eventName = eventKey.toLowerCase();
1968
- var handler = getHandler(eventKey);
1833
+ .filter((key) => Number.isNaN(Number(key)) &&
1834
+ !key.endsWith('_Departed') &&
1835
+ disableMap[key] !== false)
1836
+ .forEach((eventKey) => {
1837
+ const eventName = eventKey.toLowerCase();
1838
+ const handler = callbackWrapper(getHandler(eventKey));
1969
1839
  handlers.push(on(eventName, handler, doc));
1970
1840
  });
1971
- return function () {
1972
- handlers.forEach(function (h) { return h(); });
1973
- };
1841
+ return callbackWrapper(() => {
1842
+ handlers.forEach((h) => h());
1843
+ });
1974
1844
  }
1975
- function initScrollObserver(_a) {
1976
- var scrollCb = _a.scrollCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, sampling = _a.sampling;
1977
- var updatePosition = throttle(function (evt) {
1978
- var target = getEventTarget(evt);
1845
+ function initScrollObserver({ scrollCb, doc, mirror, blockClass, sampling, }) {
1846
+ const updatePosition = throttle((evt) => {
1847
+ const target = getEventTarget(evt);
1979
1848
  if (!target || isBlocked(target, blockClass)) {
1980
1849
  return;
1981
1850
  }
1982
- var id = mirror.getId(target);
1851
+ const id = mirror.getId(target);
1983
1852
  if (target === doc) {
1984
- var scrollEl = (doc.scrollingElement || doc.documentElement);
1985
- scrollCb({
1986
- id: id,
1853
+ const scrollEl = (doc.scrollingElement || doc.documentElement);
1854
+ callbackWrapper(scrollCb)({
1855
+ id,
1987
1856
  x: scrollEl.scrollLeft,
1988
1857
  y: scrollEl.scrollTop,
1989
1858
  });
1990
1859
  }
1991
1860
  else {
1992
- scrollCb({
1993
- id: id,
1861
+ callbackWrapper(scrollCb)({
1862
+ id,
1994
1863
  x: target.scrollLeft,
1995
1864
  y: target.scrollTop,
1996
1865
  });
1997
1866
  }
1998
1867
  }, sampling.scroll || 100);
1999
- return on('scroll', updatePosition, doc);
2000
- }
2001
- function initViewportResizeObserver(_a) {
2002
- var viewportResizeCb = _a.viewportResizeCb;
2003
- var lastH = -1;
2004
- var lastW = -1;
2005
- var updateDimension = throttle(function () {
2006
- var height = getWindowHeight();
2007
- var width = getWindowWidth();
1868
+ return on('scroll', callbackWrapper(updatePosition), doc);
1869
+ }
1870
+ function initViewportResizeObserver({ viewportResizeCb, }) {
1871
+ let lastH = -1;
1872
+ let lastW = -1;
1873
+ const updateDimension = throttle(() => {
1874
+ const height = getWindowHeight();
1875
+ const width = getWindowWidth();
2008
1876
  if (lastH !== height || lastW !== width) {
2009
- viewportResizeCb({
1877
+ callbackWrapper(viewportResizeCb)({
2010
1878
  width: Number(width),
2011
1879
  height: Number(height),
2012
1880
  });
@@ -2014,21 +1882,20 @@ function initViewportResizeObserver(_a) {
2014
1882
  lastW = width;
2015
1883
  }
2016
1884
  }, 200);
2017
- return on('resize', updateDimension, window);
1885
+ return on('resize', callbackWrapper(updateDimension), window);
2018
1886
  }
2019
1887
  function wrapEventWithUserTriggeredFlag(v, enable) {
2020
- var value = __assign({}, v);
1888
+ const value = Object.assign({}, v);
2021
1889
  if (!enable)
2022
1890
  delete value.userTriggered;
2023
1891
  return value;
2024
1892
  }
2025
- var INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
2026
- var lastInputValueMap = new WeakMap();
2027
- function initInputObserver(_a) {
2028
- var inputCb = _a.inputCb, doc = _a.doc, mirror = _a.mirror, blockClass = _a.blockClass, ignoreClass = _a.ignoreClass, ignoreSelector = _a.ignoreSelector, maskInputSelector = _a.maskInputSelector, unmaskInputSelector = _a.unmaskInputSelector, maskInputOptions = _a.maskInputOptions, maskInputFn = _a.maskInputFn, sampling = _a.sampling, userTriggeredOnInput = _a.userTriggeredOnInput;
1893
+ const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
1894
+ const lastInputValueMap = new WeakMap();
1895
+ function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, ignoreSelector, maskInputSelector, unmaskInputSelector, maskInputOptions, maskInputFn, sampling, userTriggeredOnInput, }) {
2029
1896
  function eventHandler(event) {
2030
- var target = getEventTarget(event);
2031
- var userTriggered = event.isTrusted;
1897
+ let target = getEventTarget(event);
1898
+ const userTriggered = event.isTrusted;
2032
1899
  if (target && target.tagName === 'OPTION')
2033
1900
  target = target.parentElement;
2034
1901
  if (!target ||
@@ -2037,13 +1904,13 @@ function initInputObserver(_a) {
2037
1904
  isBlocked(target, blockClass)) {
2038
1905
  return;
2039
1906
  }
2040
- var type = target.type;
1907
+ const type = target.type;
2041
1908
  if (target.classList.contains(ignoreClass) ||
2042
1909
  (ignoreSelector && target.matches(ignoreSelector))) {
2043
1910
  return;
2044
1911
  }
2045
- var text = target.value;
2046
- var isChecked = false;
1912
+ let text = target.value;
1913
+ let isChecked = false;
2047
1914
  if (type === 'radio' || type === 'checkbox') {
2048
1915
  isChecked = target.checked;
2049
1916
  }
@@ -2051,23 +1918,23 @@ function initInputObserver(_a) {
2051
1918
  maskInputOptions[type]) {
2052
1919
  text = maskInputValue({
2053
1920
  input: target,
2054
- maskInputOptions: maskInputOptions,
2055
- maskInputSelector: maskInputSelector,
2056
- unmaskInputSelector: unmaskInputSelector,
1921
+ maskInputOptions,
1922
+ maskInputSelector,
1923
+ unmaskInputSelector,
2057
1924
  tagName: target.tagName,
2058
- type: type,
1925
+ type,
2059
1926
  value: text,
2060
- maskInputFn: maskInputFn,
1927
+ maskInputFn,
2061
1928
  });
2062
1929
  }
2063
- cbWithDedup(target, wrapEventWithUserTriggeredFlag({ text: text, isChecked: isChecked, userTriggered: userTriggered }, userTriggeredOnInput));
2064
- var name = target.name;
1930
+ cbWithDedup(target, callbackWrapper(wrapEventWithUserTriggeredFlag)({ text, isChecked, userTriggered }, userTriggeredOnInput));
1931
+ const name = target.name;
2065
1932
  if (type === 'radio' && name && isChecked) {
2066
1933
  doc
2067
- .querySelectorAll("input[type=\"radio\"][name=\"".concat(name, "\"]"))
2068
- .forEach(function (el) {
1934
+ .querySelectorAll(`input[type="radio"][name="${name}"]`)
1935
+ .forEach((el) => {
2069
1936
  if (el !== target) {
2070
- cbWithDedup(el, wrapEventWithUserTriggeredFlag({
1937
+ cbWithDedup(el, callbackWrapper(wrapEventWithUserTriggeredFlag)({
2071
1938
  text: el.value,
2072
1939
  isChecked: !isChecked,
2073
1940
  userTriggered: false,
@@ -2077,19 +1944,19 @@ function initInputObserver(_a) {
2077
1944
  }
2078
1945
  }
2079
1946
  function cbWithDedup(target, v) {
2080
- var lastInputValue = lastInputValueMap.get(target);
1947
+ const lastInputValue = lastInputValueMap.get(target);
2081
1948
  if (!lastInputValue ||
2082
1949
  lastInputValue.text !== v.text ||
2083
1950
  lastInputValue.isChecked !== v.isChecked) {
2084
1951
  lastInputValueMap.set(target, v);
2085
- var id = mirror.getId(target);
2086
- inputCb(__assign(__assign({}, v), { id: id }));
1952
+ const id = mirror.getId(target);
1953
+ inputCb(Object.assign(Object.assign({}, v), { id }));
2087
1954
  }
2088
1955
  }
2089
- var events = sampling.input === 'last' ? ['change'] : ['input', 'change'];
2090
- var handlers = events.map(function (eventName) { return on(eventName, eventHandler, doc); });
2091
- var propertyDescriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
2092
- var hookProperties = [
1956
+ const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];
1957
+ const handlers = events.map((eventName) => on(eventName, callbackWrapper(eventHandler), doc));
1958
+ const propertyDescriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
1959
+ const hookProperties = [
2093
1960
  [HTMLInputElement.prototype, 'value'],
2094
1961
  [HTMLInputElement.prototype, 'checked'],
2095
1962
  [HTMLSelectElement.prototype, 'value'],
@@ -2098,213 +1965,222 @@ function initInputObserver(_a) {
2098
1965
  [HTMLOptionElement.prototype, 'selected'],
2099
1966
  ];
2100
1967
  if (propertyDescriptor && propertyDescriptor.set) {
2101
- handlers.push.apply(handlers, __spreadArray([], __read(hookProperties.map(function (p) {
2102
- return hookSetter(p[0], p[1], {
2103
- set: function () {
2104
- eventHandler({ target: this });
2105
- },
2106
- });
2107
- })), false));
1968
+ handlers.push(...hookProperties.map((p) => hookSetter(p[0], p[1], {
1969
+ set() {
1970
+ callbackWrapper(eventHandler)({ target: this });
1971
+ },
1972
+ })));
2108
1973
  }
2109
- return function () {
2110
- handlers.forEach(function (h) { return h(); });
2111
- };
1974
+ return callbackWrapper(() => {
1975
+ handlers.forEach((h) => h());
1976
+ });
2112
1977
  }
2113
1978
  function getNestedCSSRulePositions(rule) {
2114
- var positions = [];
1979
+ const positions = [];
2115
1980
  function recurse(childRule, pos) {
2116
- if ((isCSSGroupingRuleSupported &&
1981
+ if ((hasNestedCSSRule('CSSGroupingRule') &&
2117
1982
  childRule.parentRule instanceof CSSGroupingRule) ||
2118
- (isCSSMediaRuleSupported &&
1983
+ (hasNestedCSSRule('CSSMediaRule') &&
2119
1984
  childRule.parentRule instanceof CSSMediaRule) ||
2120
- (isCSSSupportsRuleSupported &&
1985
+ (hasNestedCSSRule('CSSSupportsRule') &&
2121
1986
  childRule.parentRule instanceof CSSSupportsRule) ||
2122
- (isCSSConditionRuleSupported &&
1987
+ (hasNestedCSSRule('CSSConditionRule') &&
2123
1988
  childRule.parentRule instanceof CSSConditionRule)) {
2124
- var rules = Array.from(childRule.parentRule.cssRules);
2125
- var index = rules.indexOf(childRule);
1989
+ const rules = Array.from(childRule.parentRule.cssRules);
1990
+ const index = rules.indexOf(childRule);
2126
1991
  pos.unshift(index);
2127
1992
  }
2128
1993
  else {
2129
- var rules = Array.from(childRule.parentStyleSheet.cssRules);
2130
- var index = rules.indexOf(childRule);
1994
+ const rules = Array.from(childRule.parentStyleSheet.cssRules);
1995
+ const index = rules.indexOf(childRule);
2131
1996
  pos.unshift(index);
2132
1997
  }
2133
1998
  return pos;
2134
1999
  }
2135
2000
  return recurse(rule, positions);
2136
2001
  }
2137
- function initStyleSheetObserver(_a, _b) {
2138
- var styleSheetRuleCb = _a.styleSheetRuleCb, mirror = _a.mirror;
2139
- var win = _b.win;
2002
+ function initStyleSheetObserver({ styleSheetRuleCb, mirror }, { win }) {
2140
2003
  if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
2141
- return function () { };
2142
- }
2143
- var insertRule = win.CSSStyleSheet.prototype.insertRule;
2144
- win.CSSStyleSheet.prototype.insertRule = function (rule, index) {
2145
- var id = mirror.getId(this.ownerNode);
2146
- if (id !== -1) {
2147
- styleSheetRuleCb({
2148
- id: id,
2149
- adds: [{ rule: rule, index: index }],
2150
- });
2151
- }
2152
- return insertRule.apply(this, arguments);
2153
- };
2154
- var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
2155
- win.CSSStyleSheet.prototype.deleteRule = function (index) {
2156
- var id = mirror.getId(this.ownerNode);
2157
- if (id !== -1) {
2158
- styleSheetRuleCb({
2159
- id: id,
2160
- removes: [{ index: index }],
2161
- });
2162
- }
2163
- return deleteRule.apply(this, arguments);
2164
- };
2165
- var supportedNestedCSSRuleTypes = {};
2166
- if (isCSSGroupingRuleSupported) {
2004
+ return () => { };
2005
+ }
2006
+ const insertRule = win.CSSStyleSheet.prototype.insertRule;
2007
+ win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
2008
+ apply: callbackWrapper((target, thisArg, argumentsList) => {
2009
+ const [rule, index] = argumentsList;
2010
+ const id = mirror.getId(thisArg.ownerNode);
2011
+ if (id !== -1) {
2012
+ styleSheetRuleCb({
2013
+ id,
2014
+ adds: [{ rule, index }],
2015
+ });
2016
+ }
2017
+ return target.apply(thisArg, argumentsList);
2018
+ }),
2019
+ });
2020
+ const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
2021
+ win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
2022
+ apply: callbackWrapper((target, thisArg, argumentsList) => {
2023
+ const [index] = argumentsList;
2024
+ const id = mirror.getId(thisArg.ownerNode);
2025
+ if (id !== -1) {
2026
+ styleSheetRuleCb({
2027
+ id,
2028
+ removes: [{ index }],
2029
+ });
2030
+ }
2031
+ return target.apply(thisArg, argumentsList);
2032
+ }),
2033
+ });
2034
+ const supportedNestedCSSRuleTypes = {};
2035
+ if (canMonkeyPatchNestedCSSRule('CSSGroupingRule')) {
2167
2036
  supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
2168
2037
  }
2169
2038
  else {
2170
- if (isCSSMediaRuleSupported) {
2039
+ if (canMonkeyPatchNestedCSSRule('CSSMediaRule')) {
2171
2040
  supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
2172
2041
  }
2173
- if (isCSSConditionRuleSupported) {
2042
+ if (canMonkeyPatchNestedCSSRule('CSSConditionRule')) {
2174
2043
  supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
2175
2044
  }
2176
- if (isCSSSupportsRuleSupported) {
2045
+ if (canMonkeyPatchNestedCSSRule('CSSSupportsRule')) {
2177
2046
  supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
2178
2047
  }
2179
2048
  }
2180
- var unmodifiedFunctions = {};
2181
- Object.entries(supportedNestedCSSRuleTypes).forEach(function (_a) {
2182
- var _b = __read(_a, 2), typeKey = _b[0], type = _b[1];
2049
+ const unmodifiedFunctions = {};
2050
+ Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
2183
2051
  unmodifiedFunctions[typeKey] = {
2184
2052
  insertRule: type.prototype.insertRule,
2185
2053
  deleteRule: type.prototype.deleteRule,
2186
2054
  };
2187
- type.prototype.insertRule = function (rule, index) {
2188
- var id = mirror.getId(this.parentStyleSheet.ownerNode);
2189
- if (id !== -1) {
2190
- styleSheetRuleCb({
2191
- id: id,
2192
- adds: [
2193
- {
2194
- rule: rule,
2195
- index: __spreadArray(__spreadArray([], __read(getNestedCSSRulePositions(this)), false), [
2196
- index || 0,
2197
- ], false),
2198
- },
2199
- ],
2200
- });
2201
- }
2202
- return unmodifiedFunctions[typeKey].insertRule.apply(this, arguments);
2203
- };
2204
- type.prototype.deleteRule = function (index) {
2205
- var id = mirror.getId(this.parentStyleSheet.ownerNode);
2206
- if (id !== -1) {
2207
- styleSheetRuleCb({
2208
- id: id,
2209
- removes: [{ index: __spreadArray(__spreadArray([], __read(getNestedCSSRulePositions(this)), false), [index], false) }],
2210
- });
2211
- }
2212
- return unmodifiedFunctions[typeKey].deleteRule.apply(this, arguments);
2213
- };
2055
+ type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
2056
+ apply: callbackWrapper((target, thisArg, argumentsList) => {
2057
+ const [rule, index] = argumentsList;
2058
+ const id = mirror.getId(thisArg.parentStyleSheet.ownerNode);
2059
+ if (id !== -1) {
2060
+ styleSheetRuleCb({
2061
+ id,
2062
+ adds: [
2063
+ {
2064
+ rule,
2065
+ index: [
2066
+ ...getNestedCSSRulePositions(thisArg),
2067
+ index || 0,
2068
+ ],
2069
+ },
2070
+ ],
2071
+ });
2072
+ }
2073
+ return target.apply(thisArg, argumentsList);
2074
+ }),
2075
+ });
2076
+ type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
2077
+ apply: callbackWrapper((target, thisArg, argumentsList) => {
2078
+ const [index] = argumentsList;
2079
+ const id = mirror.getId(thisArg.parentStyleSheet.ownerNode);
2080
+ if (id !== -1) {
2081
+ styleSheetRuleCb({
2082
+ id,
2083
+ removes: [
2084
+ { index: [...getNestedCSSRulePositions(thisArg), index] },
2085
+ ],
2086
+ });
2087
+ }
2088
+ return target.apply(thisArg, argumentsList);
2089
+ }),
2090
+ });
2214
2091
  });
2215
- return function () {
2092
+ return callbackWrapper(() => {
2216
2093
  win.CSSStyleSheet.prototype.insertRule = insertRule;
2217
2094
  win.CSSStyleSheet.prototype.deleteRule = deleteRule;
2218
- Object.entries(supportedNestedCSSRuleTypes).forEach(function (_a) {
2219
- var _b = __read(_a, 2), typeKey = _b[0], type = _b[1];
2095
+ Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
2220
2096
  type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
2221
2097
  type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
2222
2098
  });
2223
- };
2099
+ });
2224
2100
  }
2225
- function initStyleDeclarationObserver(_a, _b) {
2226
- var styleDeclarationCb = _a.styleDeclarationCb, mirror = _a.mirror;
2227
- var win = _b.win;
2228
- var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
2229
- win.CSSStyleDeclaration.prototype.setProperty = function (property, value, priority) {
2230
- var _a, _b;
2231
- var id = mirror.getId((_b = (_a = this.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet) === null || _b === void 0 ? void 0 : _b.ownerNode);
2232
- if (id !== -1) {
2233
- styleDeclarationCb({
2234
- id: id,
2235
- set: {
2236
- property: property,
2237
- value: value,
2238
- priority: priority,
2239
- },
2240
- index: getNestedCSSRulePositions(this.parentRule),
2241
- });
2242
- }
2243
- return setProperty.apply(this, arguments);
2244
- };
2245
- var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
2246
- win.CSSStyleDeclaration.prototype.removeProperty = function (property) {
2247
- var _a, _b;
2248
- var id = mirror.getId((_b = (_a = this.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet) === null || _b === void 0 ? void 0 : _b.ownerNode);
2249
- if (id !== -1) {
2250
- styleDeclarationCb({
2251
- id: id,
2252
- remove: {
2253
- property: property,
2254
- },
2255
- index: getNestedCSSRulePositions(this.parentRule),
2256
- });
2257
- }
2258
- return removeProperty.apply(this, arguments);
2259
- };
2260
- return function () {
2101
+ function initStyleDeclarationObserver({ styleDeclarationCb, mirror }, { win }) {
2102
+ const setProperty = win.CSSStyleDeclaration.prototype.setProperty;
2103
+ win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
2104
+ apply: callbackWrapper((target, thisArg, argumentsList) => {
2105
+ var _a, _b;
2106
+ const [property, value, priority] = argumentsList;
2107
+ const id = mirror.getId((_b = (_a = thisArg.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet) === null || _b === void 0 ? void 0 : _b.ownerNode);
2108
+ if (id !== -1) {
2109
+ styleDeclarationCb({
2110
+ id,
2111
+ set: {
2112
+ property,
2113
+ value,
2114
+ priority,
2115
+ },
2116
+ index: getNestedCSSRulePositions(thisArg.parentRule),
2117
+ });
2118
+ }
2119
+ return target.apply(thisArg, argumentsList);
2120
+ }),
2121
+ });
2122
+ const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
2123
+ win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
2124
+ apply: callbackWrapper((target, thisArg, argumentsList) => {
2125
+ var _a, _b;
2126
+ const [property] = argumentsList;
2127
+ const id = mirror.getId((_b = (_a = thisArg.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet) === null || _b === void 0 ? void 0 : _b.ownerNode);
2128
+ if (id !== -1) {
2129
+ styleDeclarationCb({
2130
+ id,
2131
+ remove: {
2132
+ property,
2133
+ },
2134
+ index: getNestedCSSRulePositions(thisArg.parentRule),
2135
+ });
2136
+ }
2137
+ return target.apply(thisArg, argumentsList);
2138
+ }),
2139
+ });
2140
+ return callbackWrapper(() => {
2261
2141
  win.CSSStyleDeclaration.prototype.setProperty = setProperty;
2262
2142
  win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
2263
- };
2143
+ });
2264
2144
  }
2265
- function initMediaInteractionObserver(_a) {
2266
- var mediaInteractionCb = _a.mediaInteractionCb, blockClass = _a.blockClass, mirror = _a.mirror, sampling = _a.sampling;
2267
- var handler = function (type) {
2268
- return throttle(function (event) {
2269
- var target = getEventTarget(event);
2270
- if (!target || isBlocked(target, blockClass)) {
2271
- return;
2272
- }
2273
- var _a = target, currentTime = _a.currentTime, volume = _a.volume, muted = _a.muted;
2274
- mediaInteractionCb({
2275
- type: type,
2276
- id: mirror.getId(target),
2277
- currentTime: currentTime,
2278
- volume: volume,
2279
- muted: muted,
2280
- });
2281
- }, sampling.media || 500);
2282
- };
2283
- var handlers = [
2145
+ function initMediaInteractionObserver({ mediaInteractionCb, blockClass, mirror, sampling, }) {
2146
+ const handler = (type) => throttle(callbackWrapper((event) => {
2147
+ const target = getEventTarget(event);
2148
+ if (!target || isBlocked(target, blockClass)) {
2149
+ return;
2150
+ }
2151
+ const { currentTime, volume, muted } = target;
2152
+ mediaInteractionCb({
2153
+ type,
2154
+ id: mirror.getId(target),
2155
+ currentTime,
2156
+ volume,
2157
+ muted,
2158
+ });
2159
+ }), sampling.media || 500);
2160
+ const handlers = [
2284
2161
  on('play', handler(0)),
2285
2162
  on('pause', handler(1)),
2286
2163
  on('seeked', handler(2)),
2287
2164
  on('volumechange', handler(3)),
2288
2165
  ];
2289
- return function () {
2290
- handlers.forEach(function (h) { return h(); });
2291
- };
2166
+ return callbackWrapper(() => {
2167
+ handlers.forEach((h) => h());
2168
+ });
2292
2169
  }
2293
- function initFontObserver(_a) {
2294
- var fontCb = _a.fontCb, doc = _a.doc;
2295
- var win = doc.defaultView;
2170
+ function initFontObserver({ fontCb, doc }) {
2171
+ const win = doc.defaultView;
2296
2172
  if (!win) {
2297
- return function () { };
2173
+ return () => { };
2298
2174
  }
2299
- var handlers = [];
2300
- var fontMap = new WeakMap();
2301
- var originalFontFace = win.FontFace;
2175
+ const handlers = [];
2176
+ const fontMap = new WeakMap();
2177
+ const originalFontFace = win.FontFace;
2302
2178
  win.FontFace = function FontFace(family, source, descriptors) {
2303
- var fontFace = new originalFontFace(family, source, descriptors);
2179
+ const fontFace = new originalFontFace(family, source, descriptors);
2304
2180
  fontMap.set(fontFace, {
2305
- family: family,
2181
+ family,
2306
2182
  buffer: typeof source !== 'string',
2307
- descriptors: descriptors,
2183
+ descriptors,
2308
2184
  fontSource: typeof source === 'string'
2309
2185
  ? source
2310
2186
  :
@@ -2312,10 +2188,10 @@ function initFontObserver(_a) {
2312
2188
  });
2313
2189
  return fontFace;
2314
2190
  };
2315
- var restoreHandler = patch(doc.fonts, 'add', function (original) {
2191
+ const restoreHandler = patch(doc.fonts, 'add', function (original) {
2316
2192
  return function (fontFace) {
2317
- setTimeout(function () {
2318
- var p = fontMap.get(fontFace);
2193
+ setTimeout(() => {
2194
+ const p = fontMap.get(fontFace);
2319
2195
  if (p) {
2320
2196
  fontCb(p);
2321
2197
  fontMap.delete(fontFace);
@@ -2324,163 +2200,107 @@ function initFontObserver(_a) {
2324
2200
  return original.apply(this, [fontFace]);
2325
2201
  };
2326
2202
  });
2327
- handlers.push(function () {
2203
+ handlers.push(() => {
2328
2204
  win.FontFace = originalFontFace;
2329
2205
  });
2330
2206
  handlers.push(restoreHandler);
2331
- return function () {
2332
- handlers.forEach(function (h) { return h(); });
2333
- };
2207
+ return callbackWrapper(() => {
2208
+ handlers.forEach((h) => h());
2209
+ });
2334
2210
  }
2335
2211
  function mergeHooks(o, hooks) {
2336
- var mutationCb = o.mutationCb, mousemoveCb = o.mousemoveCb, mouseInteractionCb = o.mouseInteractionCb, scrollCb = o.scrollCb, viewportResizeCb = o.viewportResizeCb, inputCb = o.inputCb, mediaInteractionCb = o.mediaInteractionCb, styleSheetRuleCb = o.styleSheetRuleCb, styleDeclarationCb = o.styleDeclarationCb, canvasMutationCb = o.canvasMutationCb, fontCb = o.fontCb;
2337
- o.mutationCb = function () {
2338
- var p = [];
2339
- for (var _i = 0; _i < arguments.length; _i++) {
2340
- p[_i] = arguments[_i];
2341
- }
2212
+ const { mutationCb, mousemoveCb, mouseInteractionCb, scrollCb, viewportResizeCb, inputCb, mediaInteractionCb, styleSheetRuleCb, styleDeclarationCb, canvasMutationCb, fontCb, } = o;
2213
+ o.mutationCb = (...p) => {
2342
2214
  if (hooks.mutation) {
2343
- hooks.mutation.apply(hooks, __spreadArray([], __read(p), false));
2215
+ hooks.mutation(...p);
2344
2216
  }
2345
- mutationCb.apply(void 0, __spreadArray([], __read(p), false));
2217
+ mutationCb(...p);
2346
2218
  };
2347
- o.mousemoveCb = function () {
2348
- var p = [];
2349
- for (var _i = 0; _i < arguments.length; _i++) {
2350
- p[_i] = arguments[_i];
2351
- }
2219
+ o.mousemoveCb = (...p) => {
2352
2220
  if (hooks.mousemove) {
2353
- hooks.mousemove.apply(hooks, __spreadArray([], __read(p), false));
2221
+ hooks.mousemove(...p);
2354
2222
  }
2355
- mousemoveCb.apply(void 0, __spreadArray([], __read(p), false));
2223
+ mousemoveCb(...p);
2356
2224
  };
2357
- o.mouseInteractionCb = function () {
2358
- var p = [];
2359
- for (var _i = 0; _i < arguments.length; _i++) {
2360
- p[_i] = arguments[_i];
2361
- }
2225
+ o.mouseInteractionCb = (...p) => {
2362
2226
  if (hooks.mouseInteraction) {
2363
- hooks.mouseInteraction.apply(hooks, __spreadArray([], __read(p), false));
2227
+ hooks.mouseInteraction(...p);
2364
2228
  }
2365
- mouseInteractionCb.apply(void 0, __spreadArray([], __read(p), false));
2229
+ mouseInteractionCb(...p);
2366
2230
  };
2367
- o.scrollCb = function () {
2368
- var p = [];
2369
- for (var _i = 0; _i < arguments.length; _i++) {
2370
- p[_i] = arguments[_i];
2371
- }
2231
+ o.scrollCb = (...p) => {
2372
2232
  if (hooks.scroll) {
2373
- hooks.scroll.apply(hooks, __spreadArray([], __read(p), false));
2233
+ hooks.scroll(...p);
2374
2234
  }
2375
- scrollCb.apply(void 0, __spreadArray([], __read(p), false));
2235
+ scrollCb(...p);
2376
2236
  };
2377
- o.viewportResizeCb = function () {
2378
- var p = [];
2379
- for (var _i = 0; _i < arguments.length; _i++) {
2380
- p[_i] = arguments[_i];
2381
- }
2237
+ o.viewportResizeCb = (...p) => {
2382
2238
  if (hooks.viewportResize) {
2383
- hooks.viewportResize.apply(hooks, __spreadArray([], __read(p), false));
2239
+ hooks.viewportResize(...p);
2384
2240
  }
2385
- viewportResizeCb.apply(void 0, __spreadArray([], __read(p), false));
2241
+ viewportResizeCb(...p);
2386
2242
  };
2387
- o.inputCb = function () {
2388
- var p = [];
2389
- for (var _i = 0; _i < arguments.length; _i++) {
2390
- p[_i] = arguments[_i];
2391
- }
2243
+ o.inputCb = (...p) => {
2392
2244
  if (hooks.input) {
2393
- hooks.input.apply(hooks, __spreadArray([], __read(p), false));
2245
+ hooks.input(...p);
2394
2246
  }
2395
- inputCb.apply(void 0, __spreadArray([], __read(p), false));
2247
+ inputCb(...p);
2396
2248
  };
2397
- o.mediaInteractionCb = function () {
2398
- var p = [];
2399
- for (var _i = 0; _i < arguments.length; _i++) {
2400
- p[_i] = arguments[_i];
2401
- }
2249
+ o.mediaInteractionCb = (...p) => {
2402
2250
  if (hooks.mediaInteaction) {
2403
- hooks.mediaInteaction.apply(hooks, __spreadArray([], __read(p), false));
2251
+ hooks.mediaInteaction(...p);
2404
2252
  }
2405
- mediaInteractionCb.apply(void 0, __spreadArray([], __read(p), false));
2253
+ mediaInteractionCb(...p);
2406
2254
  };
2407
- o.styleSheetRuleCb = function () {
2408
- var p = [];
2409
- for (var _i = 0; _i < arguments.length; _i++) {
2410
- p[_i] = arguments[_i];
2411
- }
2255
+ o.styleSheetRuleCb = (...p) => {
2412
2256
  if (hooks.styleSheetRule) {
2413
- hooks.styleSheetRule.apply(hooks, __spreadArray([], __read(p), false));
2257
+ hooks.styleSheetRule(...p);
2414
2258
  }
2415
- styleSheetRuleCb.apply(void 0, __spreadArray([], __read(p), false));
2259
+ styleSheetRuleCb(...p);
2416
2260
  };
2417
- o.styleDeclarationCb = function () {
2418
- var p = [];
2419
- for (var _i = 0; _i < arguments.length; _i++) {
2420
- p[_i] = arguments[_i];
2421
- }
2261
+ o.styleDeclarationCb = (...p) => {
2422
2262
  if (hooks.styleDeclaration) {
2423
- hooks.styleDeclaration.apply(hooks, __spreadArray([], __read(p), false));
2263
+ hooks.styleDeclaration(...p);
2424
2264
  }
2425
- styleDeclarationCb.apply(void 0, __spreadArray([], __read(p), false));
2265
+ styleDeclarationCb(...p);
2426
2266
  };
2427
- o.canvasMutationCb = function () {
2428
- var p = [];
2429
- for (var _i = 0; _i < arguments.length; _i++) {
2430
- p[_i] = arguments[_i];
2431
- }
2267
+ o.canvasMutationCb = (...p) => {
2432
2268
  if (hooks.canvasMutation) {
2433
- hooks.canvasMutation.apply(hooks, __spreadArray([], __read(p), false));
2269
+ hooks.canvasMutation(...p);
2434
2270
  }
2435
- canvasMutationCb.apply(void 0, __spreadArray([], __read(p), false));
2271
+ canvasMutationCb(...p);
2436
2272
  };
2437
- o.fontCb = function () {
2438
- var p = [];
2439
- for (var _i = 0; _i < arguments.length; _i++) {
2440
- p[_i] = arguments[_i];
2441
- }
2273
+ o.fontCb = (...p) => {
2442
2274
  if (hooks.font) {
2443
- hooks.font.apply(hooks, __spreadArray([], __read(p), false));
2275
+ hooks.font(...p);
2444
2276
  }
2445
- fontCb.apply(void 0, __spreadArray([], __read(p), false));
2277
+ fontCb(...p);
2446
2278
  };
2447
2279
  }
2448
- function initObservers(o, hooks) {
2449
- var e_1, _a;
2450
- if (hooks === void 0) { hooks = {}; }
2451
- var currentWindow = o.doc.defaultView;
2280
+ function initObservers(o, hooks = {}) {
2281
+ const currentWindow = o.doc.defaultView;
2452
2282
  if (!currentWindow) {
2453
- return function () { };
2283
+ return () => { };
2454
2284
  }
2455
2285
  mergeHooks(o, hooks);
2456
- var mutationObserver = initMutationObserver(o, o.doc);
2457
- var mousemoveHandler = initMoveObserver(o);
2458
- var mouseInteractionHandler = initMouseInteractionObserver(o);
2459
- var scrollHandler = initScrollObserver(o);
2460
- var viewportResizeHandler = initViewportResizeObserver(o);
2461
- var inputHandler = initInputObserver(o);
2462
- var mediaInteractionHandler = initMediaInteractionObserver(o);
2463
- var styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });
2464
- var styleDeclarationObserver = initStyleDeclarationObserver(o, {
2286
+ const mutationObserver = initMutationObserver(o, o.doc);
2287
+ const mousemoveHandler = initMoveObserver(o);
2288
+ const mouseInteractionHandler = initMouseInteractionObserver(o);
2289
+ const scrollHandler = initScrollObserver(o);
2290
+ const viewportResizeHandler = initViewportResizeObserver(o);
2291
+ const inputHandler = initInputObserver(o);
2292
+ const mediaInteractionHandler = initMediaInteractionObserver(o);
2293
+ const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });
2294
+ const styleDeclarationObserver = initStyleDeclarationObserver(o, {
2465
2295
  win: currentWindow,
2466
2296
  });
2467
- var fontObserver = o.collectFonts ? initFontObserver(o) : function () { };
2468
- var pluginHandlers = [];
2469
- try {
2470
- for (var _b = __values(o.plugins), _c = _b.next(); !_c.done; _c = _b.next()) {
2471
- var plugin = _c.value;
2472
- pluginHandlers.push(plugin.observer(plugin.callback, currentWindow, plugin.options));
2473
- }
2474
- }
2475
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2476
- finally {
2477
- try {
2478
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2479
- }
2480
- finally { if (e_1) throw e_1.error; }
2297
+ const fontObserver = o.collectFonts ? initFontObserver(o) : () => { };
2298
+ const pluginHandlers = [];
2299
+ for (const plugin of o.plugins) {
2300
+ pluginHandlers.push(plugin.observer(plugin.callback, currentWindow, plugin.options));
2481
2301
  }
2482
- return function () {
2483
- mutationBuffers.forEach(function (b) { return b.reset(); });
2302
+ return callbackWrapper(() => {
2303
+ mutationBuffers.forEach((b) => b.reset());
2484
2304
  mutationObserver.disconnect();
2485
2305
  mousemoveHandler();
2486
2306
  mouseInteractionHandler();
@@ -2495,22 +2315,31 @@ function initObservers(o, hooks) {
2495
2315
  catch (e) {
2496
2316
  }
2497
2317
  fontObserver();
2498
- pluginHandlers.forEach(function (h) { return h(); });
2499
- };
2318
+ pluginHandlers.forEach((h) => h());
2319
+ });
2320
+ }
2321
+ function hasNestedCSSRule(prop) {
2322
+ return typeof window[prop] !== 'undefined';
2323
+ }
2324
+ function canMonkeyPatchNestedCSSRule(prop) {
2325
+ return Boolean(typeof window[prop] !== 'undefined' &&
2326
+ window[prop].prototype &&
2327
+ 'insertRule' in window[prop].prototype &&
2328
+ 'deleteRule' in window[prop].prototype);
2500
2329
  }
2501
2330
 
2502
- var IframeManager = (function () {
2503
- function IframeManager(options) {
2331
+ class IframeManager {
2332
+ constructor(options) {
2504
2333
  this.iframes = new WeakMap();
2505
2334
  this.mutationCb = options.mutationCb;
2506
2335
  }
2507
- IframeManager.prototype.addIframe = function (iframeEl) {
2336
+ addIframe(iframeEl) {
2508
2337
  this.iframes.set(iframeEl, true);
2509
- };
2510
- IframeManager.prototype.addLoadListener = function (cb) {
2338
+ }
2339
+ addLoadListener(cb) {
2511
2340
  this.loadListener = cb;
2512
- };
2513
- IframeManager.prototype.attachIframe = function (iframeEl, childSn) {
2341
+ }
2342
+ attachIframe(iframeEl, childSn) {
2514
2343
  var _a;
2515
2344
  this.mutationCb({
2516
2345
  adds: [
@@ -2526,80 +2355,99 @@ var IframeManager = (function () {
2526
2355
  isAttachIframe: true,
2527
2356
  });
2528
2357
  (_a = this.loadListener) === null || _a === void 0 ? void 0 : _a.call(this, iframeEl);
2529
- };
2530
- return IframeManager;
2531
- }());
2358
+ }
2359
+ }
2532
2360
 
2533
- var ShadowDomManager = (function () {
2534
- function ShadowDomManager(options) {
2361
+ class ShadowDomManager {
2362
+ constructor(options) {
2535
2363
  this.restorePatches = [];
2536
2364
  this.mutationCb = options.mutationCb;
2537
2365
  this.scrollCb = options.scrollCb;
2538
2366
  this.bypassOptions = options.bypassOptions;
2539
2367
  this.mirror = options.mirror;
2540
- var manager = this;
2368
+ const manager = this;
2541
2369
  this.restorePatches.push(patch(HTMLElement.prototype, 'attachShadow', function (original) {
2542
2370
  return function () {
2543
- var shadowRoot = original.apply(this, arguments);
2371
+ const shadowRoot = original.apply(this, arguments);
2544
2372
  if (this.shadowRoot)
2545
2373
  manager.addShadowRoot(this.shadowRoot, this.ownerDocument);
2546
2374
  return shadowRoot;
2547
2375
  };
2548
2376
  }));
2549
2377
  }
2550
- ShadowDomManager.prototype.addShadowRoot = function (shadowRoot, doc) {
2551
- initMutationObserver(__assign(__assign({}, this.bypassOptions), { doc: doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
2552
- initScrollObserver(__assign(__assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: shadowRoot, mirror: this.mirror }));
2553
- };
2554
- ShadowDomManager.prototype.observeAttachShadow = function (iframeElement) {
2378
+ addShadowRoot(shadowRoot, doc) {
2379
+ initMutationObserver(Object.assign(Object.assign({}, this.bypassOptions), { doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
2380
+ initScrollObserver(Object.assign(Object.assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: shadowRoot, mirror: this.mirror }));
2381
+ }
2382
+ observeAttachShadow(iframeElement) {
2555
2383
  if (iframeElement.contentWindow) {
2556
- var manager_1 = this;
2384
+ const manager = this;
2557
2385
  this.restorePatches.push(patch(iframeElement.contentWindow.HTMLElement.prototype, 'attachShadow', function (original) {
2558
2386
  return function () {
2559
- var shadowRoot = original.apply(this, arguments);
2387
+ const shadowRoot = original.apply(this, arguments);
2560
2388
  if (this.shadowRoot)
2561
- manager_1.addShadowRoot(this.shadowRoot, iframeElement.contentDocument);
2389
+ manager.addShadowRoot(this.shadowRoot, iframeElement.contentDocument);
2562
2390
  return shadowRoot;
2563
2391
  };
2564
2392
  }));
2565
2393
  }
2566
- };
2567
- ShadowDomManager.prototype.reset = function () {
2568
- this.restorePatches.forEach(function (restorePatch) { return restorePatch(); });
2569
- };
2570
- return ShadowDomManager;
2571
- }());
2394
+ }
2395
+ reset() {
2396
+ this.restorePatches.forEach((restorePatch) => restorePatch());
2397
+ }
2398
+ }
2399
+
2400
+ /******************************************************************************
2401
+ Copyright (c) Microsoft Corporation.
2402
+
2403
+ Permission to use, copy, modify, and/or distribute this software for any
2404
+ purpose with or without fee is hereby granted.
2405
+
2406
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2407
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2408
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2409
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2410
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2411
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2412
+ PERFORMANCE OF THIS SOFTWARE.
2413
+ ***************************************************************************** */
2414
+
2415
+ function __rest(s, e) {
2416
+ var t = {};
2417
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2418
+ t[p] = s[p];
2419
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
2420
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2421
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2422
+ t[p[i]] = s[p[i]];
2423
+ }
2424
+ return t;
2425
+ }
2572
2426
 
2573
2427
  function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
2574
- var e_1, _a;
2575
- var handlers = [];
2576
- var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
2577
- var _loop_1 = function (prop) {
2428
+ const handlers = [];
2429
+ const props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
2430
+ for (const prop of props2D) {
2578
2431
  try {
2579
2432
  if (typeof win.CanvasRenderingContext2D.prototype[prop] !== 'function') {
2580
- return "continue";
2433
+ continue;
2581
2434
  }
2582
- var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function (original) {
2583
- return function () {
2584
- var _this = this;
2585
- var args = [];
2586
- for (var _i = 0; _i < arguments.length; _i++) {
2587
- args[_i] = arguments[_i];
2588
- }
2435
+ const restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function (original) {
2436
+ return function (...args) {
2589
2437
  if (!isBlocked(this.canvas, blockClass)) {
2590
- setTimeout(function () {
2591
- var recordArgs = __spreadArray([], __read(args), false);
2438
+ setTimeout(() => {
2439
+ const recordArgs = [...args];
2592
2440
  if (prop === 'drawImage') {
2593
2441
  if (recordArgs[0] &&
2594
2442
  recordArgs[0] instanceof HTMLCanvasElement) {
2595
- var canvas = recordArgs[0];
2596
- var ctx = canvas.getContext('2d');
2597
- var imgd = ctx === null || ctx === void 0 ? void 0 : ctx.getImageData(0, 0, canvas.width, canvas.height);
2598
- var pix = imgd === null || imgd === void 0 ? void 0 : imgd.data;
2443
+ const canvas = recordArgs[0];
2444
+ const ctx = canvas.getContext('2d');
2445
+ let imgd = ctx === null || ctx === void 0 ? void 0 : ctx.getImageData(0, 0, canvas.width, canvas.height);
2446
+ let pix = imgd === null || imgd === void 0 ? void 0 : imgd.data;
2599
2447
  recordArgs[0] = JSON.stringify(pix);
2600
2448
  }
2601
2449
  }
2602
- cb(_this.canvas, {
2450
+ cb(this.canvas, {
2603
2451
  type: CanvasContext['2D'],
2604
2452
  property: prop,
2605
2453
  args: recordArgs,
@@ -2611,9 +2459,9 @@ function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
2611
2459
  });
2612
2460
  handlers.push(restoreHandler);
2613
2461
  }
2614
- catch (_b) {
2615
- var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
2616
- set: function (v) {
2462
+ catch (_a) {
2463
+ const hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
2464
+ set(v) {
2617
2465
  cb(this.canvas, {
2618
2466
  type: CanvasContext['2D'],
2619
2467
  property: prop,
@@ -2624,39 +2472,22 @@ function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
2624
2472
  });
2625
2473
  handlers.push(hookHandler);
2626
2474
  }
2627
- };
2628
- try {
2629
- for (var props2D_1 = __values(props2D), props2D_1_1 = props2D_1.next(); !props2D_1_1.done; props2D_1_1 = props2D_1.next()) {
2630
- var prop = props2D_1_1.value;
2631
- _loop_1(prop);
2632
- }
2633
2475
  }
2634
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2635
- finally {
2636
- try {
2637
- if (props2D_1_1 && !props2D_1_1.done && (_a = props2D_1.return)) _a.call(props2D_1);
2638
- }
2639
- finally { if (e_1) throw e_1.error; }
2640
- }
2641
- return function () {
2642
- handlers.forEach(function (h) { return h(); });
2476
+ return () => {
2477
+ handlers.forEach((h) => h());
2643
2478
  };
2644
2479
  }
2645
2480
 
2646
2481
  function initCanvasContextObserver(win, blockClass) {
2647
- var handlers = [];
2482
+ const handlers = [];
2648
2483
  try {
2649
- var restoreHandler = patch(win.HTMLCanvasElement.prototype, 'getContext', function (original) {
2650
- return function (contextType) {
2651
- var args = [];
2652
- for (var _i = 1; _i < arguments.length; _i++) {
2653
- args[_i - 1] = arguments[_i];
2654
- }
2484
+ const restoreHandler = patch(win.HTMLCanvasElement.prototype, 'getContext', function (original) {
2485
+ return function (contextType, ...args) {
2655
2486
  if (!isBlocked(this, blockClass)) {
2656
2487
  if (!('__context' in this))
2657
2488
  this.__context = contextType;
2658
2489
  }
2659
- return original.apply(this, __spreadArray([contextType], __read(args), false));
2490
+ return original.apply(this, [contextType, ...args]);
2660
2491
  };
2661
2492
  });
2662
2493
  handlers.push(restoreHandler);
@@ -2664,14 +2495,14 @@ function initCanvasContextObserver(win, blockClass) {
2664
2495
  catch (_a) {
2665
2496
  console.error('failed to patch HTMLCanvasElement.prototype.getContext');
2666
2497
  }
2667
- return function () {
2668
- handlers.forEach(function (h) { return h(); });
2498
+ return () => {
2499
+ handlers.forEach((h) => h());
2669
2500
  };
2670
2501
  }
2671
2502
 
2672
2503
  /*
2673
- * base64-arraybuffer 1.0.1 <https://github.com/niklasvh/base64-arraybuffer>
2674
- * Copyright (c) 2021 Niklas von Hertzen <https://hertzen.com>
2504
+ * base64-arraybuffer 1.0.2 <https://github.com/niklasvh/base64-arraybuffer>
2505
+ * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
2675
2506
  * Released under MIT License
2676
2507
  */
2677
2508
  var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
@@ -2697,9 +2528,9 @@ var encode = function (arraybuffer) {
2697
2528
  return base64;
2698
2529
  };
2699
2530
 
2700
- var webGLVarMap = new Map();
2531
+ const webGLVarMap = new Map();
2701
2532
  function variableListFor(ctx, ctor) {
2702
- var contextMap = webGLVarMap.get(ctx);
2533
+ let contextMap = webGLVarMap.get(ctx);
2703
2534
  if (!contextMap) {
2704
2535
  contextMap = new Map();
2705
2536
  webGLVarMap.set(ctx, contextMap);
@@ -2709,13 +2540,13 @@ function variableListFor(ctx, ctor) {
2709
2540
  }
2710
2541
  return contextMap.get(ctor);
2711
2542
  }
2712
- var saveWebGLVar = function (value, win, ctx) {
2543
+ const saveWebGLVar = (value, win, ctx) => {
2713
2544
  if (!value ||
2714
2545
  !(isInstanceOfWebGLObject(value, win) || typeof value === 'object'))
2715
2546
  return;
2716
- var name = value.constructor.name;
2717
- var list = variableListFor(ctx, name);
2718
- var index = list.indexOf(value);
2547
+ const name = value.constructor.name;
2548
+ const list = variableListFor(ctx, name);
2549
+ let index = list.indexOf(value);
2719
2550
  if (index === -1) {
2720
2551
  index = list.length;
2721
2552
  list.push(value);
@@ -2724,7 +2555,7 @@ var saveWebGLVar = function (value, win, ctx) {
2724
2555
  };
2725
2556
  function serializeArg(value, win, ctx) {
2726
2557
  if (value instanceof Array) {
2727
- return value.map(function (arg) { return serializeArg(arg, win, ctx); });
2558
+ return value.map((arg) => serializeArg(arg, win, ctx));
2728
2559
  }
2729
2560
  else if (value === null) {
2730
2561
  return value;
@@ -2738,24 +2569,24 @@ function serializeArg(value, win, ctx) {
2738
2569
  value instanceof Int16Array ||
2739
2570
  value instanceof Int8Array ||
2740
2571
  value instanceof Uint8ClampedArray) {
2741
- var name_1 = value.constructor.name;
2572
+ const name = value.constructor.name;
2742
2573
  return {
2743
- rr_type: name_1,
2574
+ rr_type: name,
2744
2575
  args: [Object.values(value)],
2745
2576
  };
2746
2577
  }
2747
2578
  else if (value instanceof ArrayBuffer) {
2748
- var name_2 = value.constructor.name;
2749
- var base64 = encode(value);
2579
+ const name = value.constructor.name;
2580
+ const base64 = encode(value);
2750
2581
  return {
2751
- rr_type: name_2,
2752
- base64: base64,
2582
+ rr_type: name,
2583
+ base64,
2753
2584
  };
2754
2585
  }
2755
2586
  else if (value instanceof DataView) {
2756
- var name_3 = value.constructor.name;
2587
+ const name = value.constructor.name;
2757
2588
  return {
2758
- rr_type: name_3,
2589
+ rr_type: name,
2759
2590
  args: [
2760
2591
  serializeArg(value.buffer, win, ctx),
2761
2592
  value.byteOffset,
@@ -2764,35 +2595,35 @@ function serializeArg(value, win, ctx) {
2764
2595
  };
2765
2596
  }
2766
2597
  else if (value instanceof HTMLImageElement) {
2767
- var name_4 = value.constructor.name;
2768
- var src = value.src;
2598
+ const name = value.constructor.name;
2599
+ const { src } = value;
2769
2600
  return {
2770
- rr_type: name_4,
2771
- src: src,
2601
+ rr_type: name,
2602
+ src,
2772
2603
  };
2773
2604
  }
2774
2605
  else if (value instanceof ImageData) {
2775
- var name_5 = value.constructor.name;
2606
+ const name = value.constructor.name;
2776
2607
  return {
2777
- rr_type: name_5,
2608
+ rr_type: name,
2778
2609
  args: [serializeArg(value.data, win, ctx), value.width, value.height],
2779
2610
  };
2780
2611
  }
2781
2612
  else if (isInstanceOfWebGLObject(value, win) || typeof value === 'object') {
2782
- var name_6 = value.constructor.name;
2783
- var index = saveWebGLVar(value, win, ctx);
2613
+ const name = value.constructor.name;
2614
+ const index = saveWebGLVar(value, win, ctx);
2784
2615
  return {
2785
- rr_type: name_6,
2616
+ rr_type: name,
2786
2617
  index: index,
2787
2618
  };
2788
2619
  }
2789
2620
  return value;
2790
2621
  }
2791
- var serializeArgs = function (args, win, ctx) {
2792
- return __spreadArray([], __read(args), false).map(function (arg) { return serializeArg(arg, win, ctx); });
2622
+ const serializeArgs = (args, win, ctx) => {
2623
+ return [...args].map((arg) => serializeArg(arg, win, ctx));
2793
2624
  };
2794
- var isInstanceOfWebGLObject = function (value, win) {
2795
- var webGLConstructorNames = [
2625
+ const isInstanceOfWebGLObject = (value, win) => {
2626
+ const webGLConstructorNames = [
2796
2627
  'WebGLActiveInfo',
2797
2628
  'WebGLBuffer',
2798
2629
  'WebGLFramebuffer',
@@ -2805,32 +2636,27 @@ var isInstanceOfWebGLObject = function (value, win) {
2805
2636
  'WebGLVertexArrayObject',
2806
2637
  'WebGLVertexArrayObjectOES',
2807
2638
  ];
2808
- var supportedWebGLConstructorNames = webGLConstructorNames.filter(function (name) { return typeof win[name] === 'function'; });
2809
- return Boolean(supportedWebGLConstructorNames.find(function (name) { return value instanceof win[name]; }));
2639
+ const supportedWebGLConstructorNames = webGLConstructorNames.filter((name) => typeof win[name] === 'function');
2640
+ return Boolean(supportedWebGLConstructorNames.find((name) => value instanceof win[name]));
2810
2641
  };
2811
2642
 
2812
2643
  function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
2813
- var e_1, _a;
2814
- var handlers = [];
2815
- var props = Object.getOwnPropertyNames(prototype);
2816
- var _loop_1 = function (prop) {
2644
+ const handlers = [];
2645
+ const props = Object.getOwnPropertyNames(prototype);
2646
+ for (const prop of props) {
2817
2647
  try {
2818
2648
  if (typeof prototype[prop] !== 'function') {
2819
- return "continue";
2649
+ continue;
2820
2650
  }
2821
- var restoreHandler = patch(prototype, prop, function (original) {
2822
- return function () {
2823
- var args = [];
2824
- for (var _i = 0; _i < arguments.length; _i++) {
2825
- args[_i] = arguments[_i];
2826
- }
2827
- var result = original.apply(this, args);
2651
+ const restoreHandler = patch(prototype, prop, function (original) {
2652
+ return function (...args) {
2653
+ const result = original.apply(this, args);
2828
2654
  saveWebGLVar(result, win, prototype);
2829
2655
  if (!isBlocked(this.canvas, blockClass)) {
2830
- var id = mirror.getId(this.canvas);
2831
- var recordArgs = serializeArgs(__spreadArray([], __read(args), false), win, prototype);
2832
- var mutation = {
2833
- type: type,
2656
+ const id = mirror.getId(this.canvas);
2657
+ const recordArgs = serializeArgs([...args], win, prototype);
2658
+ const mutation = {
2659
+ type,
2834
2660
  property: prop,
2835
2661
  args: recordArgs,
2836
2662
  };
@@ -2841,11 +2667,11 @@ function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
2841
2667
  });
2842
2668
  handlers.push(restoreHandler);
2843
2669
  }
2844
- catch (_b) {
2845
- var hookHandler = hookSetter(prototype, prop, {
2846
- set: function (v) {
2670
+ catch (_a) {
2671
+ const hookHandler = hookSetter(prototype, prop, {
2672
+ set(v) {
2847
2673
  cb(this.canvas, {
2848
- type: type,
2674
+ type,
2849
2675
  property: prop,
2850
2676
  args: [v],
2851
2677
  setter: true,
@@ -2854,41 +2680,44 @@ function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
2854
2680
  });
2855
2681
  handlers.push(hookHandler);
2856
2682
  }
2857
- };
2858
- try {
2859
- for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
2860
- var prop = props_1_1.value;
2861
- _loop_1(prop);
2862
- }
2863
- }
2864
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2865
- finally {
2866
- try {
2867
- if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
2868
- }
2869
- finally { if (e_1) throw e_1.error; }
2870
2683
  }
2871
2684
  return handlers;
2872
2685
  }
2873
2686
  function initCanvasWebGLMutationObserver(cb, win, blockClass, mirror) {
2874
- var handlers = [];
2875
- handlers.push.apply(handlers, __spreadArray([], __read(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, mirror, win)), false));
2687
+ const handlers = [];
2688
+ handlers.push(...patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, mirror, win));
2876
2689
  if (typeof win.WebGL2RenderingContext !== 'undefined') {
2877
- handlers.push.apply(handlers, __spreadArray([], __read(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, mirror, win)), false));
2690
+ handlers.push(...patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, mirror, win));
2878
2691
  }
2879
- return function () {
2880
- handlers.forEach(function (h) { return h(); });
2692
+ return () => {
2693
+ handlers.forEach((h) => h());
2881
2694
  };
2882
2695
  }
2883
2696
 
2884
- var CanvasManager = (function () {
2885
- function CanvasManager(options) {
2697
+ class CanvasManager {
2698
+ reset() {
2699
+ this.pendingCanvasMutations.clear();
2700
+ this.resetObservers && this.resetObservers();
2701
+ }
2702
+ freeze() {
2703
+ this.frozen = true;
2704
+ }
2705
+ unfreeze() {
2706
+ this.frozen = false;
2707
+ }
2708
+ lock() {
2709
+ this.locked = true;
2710
+ }
2711
+ unlock() {
2712
+ this.locked = false;
2713
+ }
2714
+ constructor(options) {
2886
2715
  this.pendingCanvasMutations = new Map();
2887
2716
  this.rafStamps = { latestId: 0, invokeId: null };
2888
2717
  this.frozen = false;
2889
2718
  this.locked = false;
2890
2719
  this.processMutation = function (target, mutation) {
2891
- var newFrame = this.rafStamps.invokeId &&
2720
+ const newFrame = this.rafStamps.invokeId &&
2892
2721
  this.rafStamps.latestId !== this.rafStamps.invokeId;
2893
2722
  if (newFrame || !this.rafStamps.invokeId)
2894
2723
  this.rafStamps.invokeId = this.rafStamps.latestId;
@@ -2902,88 +2731,67 @@ var CanvasManager = (function () {
2902
2731
  if (options.recordCanvas === true)
2903
2732
  this.initCanvasMutationObserver(options.win, options.blockClass);
2904
2733
  }
2905
- CanvasManager.prototype.reset = function () {
2906
- this.pendingCanvasMutations.clear();
2907
- this.resetObservers && this.resetObservers();
2908
- };
2909
- CanvasManager.prototype.freeze = function () {
2910
- this.frozen = true;
2911
- };
2912
- CanvasManager.prototype.unfreeze = function () {
2913
- this.frozen = false;
2914
- };
2915
- CanvasManager.prototype.lock = function () {
2916
- this.locked = true;
2917
- };
2918
- CanvasManager.prototype.unlock = function () {
2919
- this.locked = false;
2920
- };
2921
- CanvasManager.prototype.initCanvasMutationObserver = function (win, blockClass) {
2734
+ initCanvasMutationObserver(win, blockClass) {
2922
2735
  this.startRAFTimestamping();
2923
2736
  this.startPendingCanvasMutationFlusher();
2924
- var canvasContextReset = initCanvasContextObserver(win, blockClass);
2925
- var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
2926
- var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
2927
- this.resetObservers = function () {
2737
+ const canvasContextReset = initCanvasContextObserver(win, blockClass);
2738
+ const canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
2739
+ const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
2740
+ this.resetObservers = () => {
2928
2741
  canvasContextReset();
2929
2742
  canvas2DReset();
2930
2743
  canvasWebGL1and2Reset();
2931
2744
  };
2932
- };
2933
- CanvasManager.prototype.startPendingCanvasMutationFlusher = function () {
2934
- var _this = this;
2935
- requestAnimationFrame(function () { return _this.flushPendingCanvasMutations(); });
2936
- };
2937
- CanvasManager.prototype.startRAFTimestamping = function () {
2938
- var _this = this;
2939
- var setLatestRAFTimestamp = function (timestamp) {
2940
- _this.rafStamps.latestId = timestamp;
2745
+ }
2746
+ startPendingCanvasMutationFlusher() {
2747
+ requestAnimationFrame(() => this.flushPendingCanvasMutations());
2748
+ }
2749
+ startRAFTimestamping() {
2750
+ const setLatestRAFTimestamp = (timestamp) => {
2751
+ this.rafStamps.latestId = timestamp;
2941
2752
  requestAnimationFrame(setLatestRAFTimestamp);
2942
2753
  };
2943
2754
  requestAnimationFrame(setLatestRAFTimestamp);
2944
- };
2945
- CanvasManager.prototype.flushPendingCanvasMutations = function () {
2946
- var _this = this;
2947
- this.pendingCanvasMutations.forEach(function (values, canvas) {
2948
- var id = _this.mirror.getId(canvas);
2949
- _this.flushPendingCanvasMutationFor(canvas, id);
2755
+ }
2756
+ flushPendingCanvasMutations() {
2757
+ this.pendingCanvasMutations.forEach((values, canvas) => {
2758
+ const id = this.mirror.getId(canvas);
2759
+ this.flushPendingCanvasMutationFor(canvas, id);
2950
2760
  });
2951
- requestAnimationFrame(function () { return _this.flushPendingCanvasMutations(); });
2952
- };
2953
- CanvasManager.prototype.flushPendingCanvasMutationFor = function (canvas, id) {
2761
+ requestAnimationFrame(() => this.flushPendingCanvasMutations());
2762
+ }
2763
+ flushPendingCanvasMutationFor(canvas, id) {
2954
2764
  if (this.frozen || this.locked) {
2955
2765
  return;
2956
2766
  }
2957
- var valuesWithType = this.pendingCanvasMutations.get(canvas);
2767
+ const valuesWithType = this.pendingCanvasMutations.get(canvas);
2958
2768
  if (!valuesWithType || id === -1)
2959
2769
  return;
2960
- var values = valuesWithType.map(function (value) {
2961
- value.type; var rest = __rest(value, ["type"]);
2770
+ const values = valuesWithType.map((value) => {
2771
+ const rest = __rest(value, ["type"]);
2962
2772
  return rest;
2963
2773
  });
2964
- var type = valuesWithType[0].type;
2965
- this.mutationCb({ id: id, type: type, commands: values });
2774
+ const { type } = valuesWithType[0];
2775
+ this.mutationCb({ id, type, commands: values });
2966
2776
  this.pendingCanvasMutations.delete(canvas);
2967
- };
2968
- return CanvasManager;
2969
- }());
2777
+ }
2778
+ }
2970
2779
 
2971
2780
  function wrapEvent(e) {
2972
- return __assign(__assign({}, e), { timestamp: Date.now() });
2973
- }
2974
- var wrappedEmit;
2975
- var takeFullSnapshot;
2976
- var mirror = createMirror();
2977
- function record(options) {
2978
- if (options === void 0) { options = {}; }
2979
- var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'rr-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.unblockSelector, unblockSelector = _c === void 0 ? null : _c, _d = options.ignoreClass, ignoreClass = _d === void 0 ? 'rr-ignore' : _d, _e = options.ignoreSelector, ignoreSelector = _e === void 0 ? null : _e, _f = options.maskTextClass, maskTextClass = _f === void 0 ? 'rr-mask' : _f, _g = options.maskTextSelector, maskTextSelector = _g === void 0 ? null : _g, _h = options.maskInputSelector, maskInputSelector = _h === void 0 ? null : _h, _j = options.unmaskTextSelector, unmaskTextSelector = _j === void 0 ? null : _j, _k = options.unmaskInputSelector, unmaskInputSelector = _k === void 0 ? null : _k, _l = options.inlineStylesheet, inlineStylesheet = _l === void 0 ? true : _l, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _m = options.sampling, sampling = _m === void 0 ? {} : _m, mousemoveWait = options.mousemoveWait, _o = options.recordCanvas, recordCanvas = _o === void 0 ? false : _o, _p = options.userTriggeredOnInput, userTriggeredOnInput = _p === void 0 ? false : _p, _q = options.collectFonts, collectFonts = _q === void 0 ? false : _q, _r = options.inlineImages, inlineImages = _r === void 0 ? false : _r, plugins = options.plugins, _s = options.keepIframeSrcFn, keepIframeSrcFn = _s === void 0 ? function () { return false; } : _s;
2781
+ return Object.assign(Object.assign({}, e), { timestamp: Date.now() });
2782
+ }
2783
+ let wrappedEmit;
2784
+ let takeFullSnapshot;
2785
+ const mirror = createMirror();
2786
+ function record(options = {}) {
2787
+ const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'rr-block', blockSelector = null, unblockSelector = null, ignoreClass = 'rr-ignore', ignoreSelector = null, maskTextClass = 'rr-mask', maskTextSelector = null, maskInputSelector = null, unmaskTextSelector = null, unmaskInputSelector = 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, } = options;
2980
2788
  if (!emit) {
2981
2789
  throw new Error('emit function is required');
2982
2790
  }
2983
2791
  if (mousemoveWait !== undefined && sampling.mousemove === undefined) {
2984
2792
  sampling.mousemove = mousemoveWait;
2985
2793
  }
2986
- var maskInputOptions = maskAllInputs === true
2794
+ const maskInputOptions = maskAllInputs === true
2987
2795
  ? {
2988
2796
  color: true,
2989
2797
  date: true,
@@ -3005,7 +2813,7 @@ function record(options) {
3005
2813
  : _maskInputOptions !== undefined
3006
2814
  ? _maskInputOptions
3007
2815
  : { password: true };
3008
- var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === 'all'
2816
+ const slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === 'all'
3009
2817
  ? {
3010
2818
  script: true,
3011
2819
  comment: true,
@@ -3022,37 +2830,26 @@ function record(options) {
3022
2830
  ? _slimDOMOptions
3023
2831
  : {};
3024
2832
  polyfill();
3025
- var lastFullSnapshotEvent;
3026
- var incrementalSnapshotCount = 0;
3027
- var eventProcessor = function (e) {
3028
- var e_1, _a;
3029
- try {
3030
- for (var _b = __values(plugins || []), _c = _b.next(); !_c.done; _c = _b.next()) {
3031
- var plugin = _c.value;
3032
- if (plugin.eventProcessor) {
3033
- e = plugin.eventProcessor(e);
3034
- }
2833
+ let lastFullSnapshotEvent;
2834
+ let incrementalSnapshotCount = 0;
2835
+ const eventProcessor = (e) => {
2836
+ for (const plugin of plugins || []) {
2837
+ if (plugin.eventProcessor) {
2838
+ e = plugin.eventProcessor(e);
3035
2839
  }
3036
2840
  }
3037
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3038
- finally {
3039
- try {
3040
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3041
- }
3042
- finally { if (e_1) throw e_1.error; }
3043
- }
3044
2841
  if (packFn) {
3045
2842
  e = packFn(e);
3046
2843
  }
3047
2844
  return e;
3048
2845
  };
3049
- wrappedEmit = function (e, isCheckout) {
2846
+ wrappedEmit = (e, isCheckout) => {
3050
2847
  var _a;
3051
2848
  if (((_a = mutationBuffers[0]) === null || _a === void 0 ? void 0 : _a.isFrozen()) &&
3052
2849
  e.type !== EventType.FullSnapshot &&
3053
2850
  !(e.type === EventType.IncrementalSnapshot &&
3054
2851
  e.data.source === IncrementalSource.Mutation)) {
3055
- mutationBuffers.forEach(function (buf) { return buf.unfreeze(); });
2852
+ mutationBuffers.forEach((buf) => buf.unfreeze());
3056
2853
  }
3057
2854
  emit(eventProcessor(e), isCheckout);
3058
2855
  if (e.type === EventType.FullSnapshot) {
@@ -3065,70 +2862,65 @@ function record(options) {
3065
2862
  return;
3066
2863
  }
3067
2864
  incrementalSnapshotCount++;
3068
- var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
3069
- var exceedTime = checkoutEveryNms &&
2865
+ const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
2866
+ const exceedTime = checkoutEveryNms &&
3070
2867
  e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
3071
2868
  if (exceedCount || exceedTime) {
3072
2869
  takeFullSnapshot(true);
3073
2870
  }
3074
2871
  }
3075
2872
  };
3076
- var wrappedMutationEmit = function (m) {
2873
+ const wrappedMutationEmit = (m) => {
3077
2874
  wrappedEmit(wrapEvent({
3078
2875
  type: EventType.IncrementalSnapshot,
3079
- data: __assign({ source: IncrementalSource.Mutation }, m),
3080
- }));
3081
- };
3082
- var wrappedScrollEmit = function (p) {
3083
- return wrappedEmit(wrapEvent({
3084
- type: EventType.IncrementalSnapshot,
3085
- data: __assign({ source: IncrementalSource.Scroll }, p),
2876
+ data: Object.assign({ source: IncrementalSource.Mutation }, m),
3086
2877
  }));
3087
2878
  };
3088
- var wrappedCanvasMutationEmit = function (p) {
3089
- return wrappedEmit(wrapEvent({
3090
- type: EventType.IncrementalSnapshot,
3091
- data: __assign({ source: IncrementalSource.CanvasMutation }, p),
3092
- }));
3093
- };
3094
- var iframeManager = new IframeManager({
2879
+ const wrappedScrollEmit = (p) => wrappedEmit(wrapEvent({
2880
+ type: EventType.IncrementalSnapshot,
2881
+ data: Object.assign({ source: IncrementalSource.Scroll }, p),
2882
+ }));
2883
+ const wrappedCanvasMutationEmit = (p) => wrappedEmit(wrapEvent({
2884
+ type: EventType.IncrementalSnapshot,
2885
+ data: Object.assign({ source: IncrementalSource.CanvasMutation }, p),
2886
+ }));
2887
+ const iframeManager = new IframeManager({
3095
2888
  mutationCb: wrappedMutationEmit,
3096
2889
  });
3097
- var canvasManager = new CanvasManager({
3098
- recordCanvas: recordCanvas,
2890
+ const canvasManager = new CanvasManager({
2891
+ recordCanvas,
3099
2892
  mutationCb: wrappedCanvasMutationEmit,
3100
2893
  win: window,
3101
- blockClass: blockClass,
3102
- mirror: mirror,
2894
+ blockClass,
2895
+ mirror,
3103
2896
  });
3104
- var shadowDomManager = new ShadowDomManager({
2897
+ const shadowDomManager = new ShadowDomManager({
3105
2898
  mutationCb: wrappedMutationEmit,
3106
2899
  scrollCb: wrappedScrollEmit,
3107
2900
  bypassOptions: {
3108
- blockClass: blockClass,
3109
- blockSelector: blockSelector,
3110
- unblockSelector: unblockSelector,
3111
- maskTextClass: maskTextClass,
3112
- maskTextSelector: maskTextSelector,
3113
- unmaskTextSelector: unmaskTextSelector,
3114
- maskInputSelector: maskInputSelector,
3115
- unmaskInputSelector: unmaskInputSelector,
3116
- inlineStylesheet: inlineStylesheet,
3117
- maskInputOptions: maskInputOptions,
3118
- maskTextFn: maskTextFn,
3119
- maskInputFn: maskInputFn,
3120
- recordCanvas: recordCanvas,
3121
- inlineImages: inlineImages,
3122
- sampling: sampling,
3123
- slimDOMOptions: slimDOMOptions,
3124
- iframeManager: iframeManager,
3125
- canvasManager: canvasManager,
2901
+ blockClass,
2902
+ blockSelector,
2903
+ unblockSelector,
2904
+ maskTextClass,
2905
+ maskTextSelector,
2906
+ unmaskTextSelector,
2907
+ maskInputSelector,
2908
+ unmaskInputSelector,
2909
+ inlineStylesheet,
2910
+ maskInputOptions,
2911
+ maskTextFn,
2912
+ maskInputFn,
2913
+ recordCanvas,
2914
+ inlineImages,
2915
+ sampling,
2916
+ slimDOMOptions,
2917
+ iframeManager,
2918
+ canvasManager,
3126
2919
  },
3127
- mirror: mirror,
2920
+ mirror,
3128
2921
  });
3129
- takeFullSnapshot = function (isCheckout) {
2922
+ takeFullSnapshot = (isCheckout = false) => {
3130
2923
  var _a, _b, _c, _d;
3131
- if (isCheckout === void 0) { isCheckout = false; }
3132
2924
  wrappedEmit(wrapEvent({
3133
2925
  type: EventType.Meta,
3134
2926
  data: {
@@ -3137,23 +2929,23 @@ function record(options) {
3137
2929
  height: getWindowHeight(),
3138
2930
  },
3139
2931
  }), isCheckout);
3140
- mutationBuffers.forEach(function (buf) { return buf.lock(); });
3141
- var _e = __read(snapshot(document, {
3142
- blockClass: blockClass,
3143
- blockSelector: blockSelector,
3144
- unblockSelector: unblockSelector,
3145
- maskTextClass: maskTextClass,
3146
- maskTextSelector: maskTextSelector,
3147
- unmaskTextSelector: unmaskTextSelector,
3148
- maskInputSelector: maskInputSelector,
3149
- unmaskInputSelector: unmaskInputSelector,
3150
- inlineStylesheet: inlineStylesheet,
2932
+ mutationBuffers.forEach((buf) => buf.lock());
2933
+ const [node, idNodeMap] = snapshot(document, {
2934
+ blockClass,
2935
+ blockSelector,
2936
+ unblockSelector,
2937
+ maskTextClass,
2938
+ maskTextSelector,
2939
+ unmaskTextSelector,
2940
+ maskInputSelector,
2941
+ unmaskInputSelector,
2942
+ inlineStylesheet,
3151
2943
  maskAllInputs: maskInputOptions,
3152
- maskTextFn: maskTextFn,
2944
+ maskTextFn,
3153
2945
  slimDOM: slimDOMOptions,
3154
- recordCanvas: recordCanvas,
3155
- inlineImages: inlineImages,
3156
- onSerialize: function (n) {
2946
+ recordCanvas,
2947
+ inlineImages,
2948
+ onSerialize: (n) => {
3157
2949
  if (isIframeINode(n)) {
3158
2950
  iframeManager.addIframe(n);
3159
2951
  }
@@ -3161,12 +2953,12 @@ function record(options) {
3161
2953
  shadowDomManager.addShadowRoot(n.shadowRoot, document);
3162
2954
  }
3163
2955
  },
3164
- onIframeLoad: function (iframe, childSn) {
2956
+ onIframeLoad: (iframe, childSn) => {
3165
2957
  iframeManager.attachIframe(iframe, childSn);
3166
2958
  shadowDomManager.observeAttachShadow(iframe);
3167
2959
  },
3168
- keepIframeSrcFn: keepIframeSrcFn,
3169
- }), 2), node = _e[0], idNodeMap = _e[1];
2960
+ keepIframeSrcFn,
2961
+ });
3170
2962
  if (!node) {
3171
2963
  return console.warn('Failed to snapshot the document');
3172
2964
  }
@@ -3174,7 +2966,7 @@ function record(options) {
3174
2966
  wrappedEmit(wrapEvent({
3175
2967
  type: EventType.FullSnapshot,
3176
2968
  data: {
3177
- node: node,
2969
+ node,
3178
2970
  initialOffset: {
3179
2971
  left: window.pageXOffset !== undefined
3180
2972
  ? window.pageXOffset
@@ -3191,162 +2983,144 @@ function record(options) {
3191
2983
  },
3192
2984
  },
3193
2985
  }));
3194
- mutationBuffers.forEach(function (buf) { return buf.unlock(); });
2986
+ mutationBuffers.forEach((buf) => buf.unlock());
3195
2987
  };
3196
2988
  try {
3197
- var handlers_1 = [];
3198
- handlers_1.push(on('DOMContentLoaded', function () {
2989
+ const handlers = [];
2990
+ handlers.push(on('DOMContentLoaded', () => {
3199
2991
  wrappedEmit(wrapEvent({
3200
2992
  type: EventType.DomContentLoaded,
3201
2993
  data: {},
3202
2994
  }));
3203
2995
  }));
3204
- var observe_1 = function (doc) {
2996
+ const observe = (doc) => {
3205
2997
  var _a;
3206
- return initObservers({
2998
+ return callbackWrapper(initObservers)({
3207
2999
  mutationCb: wrappedMutationEmit,
3208
- mousemoveCb: function (positions, source) {
3209
- return wrappedEmit(wrapEvent({
3210
- type: EventType.IncrementalSnapshot,
3211
- data: {
3212
- source: source,
3213
- positions: positions,
3214
- },
3215
- }));
3216
- },
3217
- mouseInteractionCb: function (d) {
3218
- return wrappedEmit(wrapEvent({
3219
- type: EventType.IncrementalSnapshot,
3220
- data: __assign({ source: IncrementalSource.MouseInteraction }, d),
3221
- }));
3222
- },
3000
+ mousemoveCb: (positions, source) => wrappedEmit(wrapEvent({
3001
+ type: EventType.IncrementalSnapshot,
3002
+ data: {
3003
+ source,
3004
+ positions,
3005
+ },
3006
+ })),
3007
+ mouseInteractionCb: (d) => wrappedEmit(wrapEvent({
3008
+ type: EventType.IncrementalSnapshot,
3009
+ data: Object.assign({ source: IncrementalSource.MouseInteraction }, d),
3010
+ })),
3223
3011
  scrollCb: wrappedScrollEmit,
3224
- viewportResizeCb: function (d) {
3225
- return wrappedEmit(wrapEvent({
3226
- type: EventType.IncrementalSnapshot,
3227
- data: __assign({ source: IncrementalSource.ViewportResize }, d),
3228
- }));
3229
- },
3230
- inputCb: function (v) {
3231
- return wrappedEmit(wrapEvent({
3232
- type: EventType.IncrementalSnapshot,
3233
- data: __assign({ source: IncrementalSource.Input }, v),
3234
- }));
3235
- },
3236
- mediaInteractionCb: function (p) {
3237
- return wrappedEmit(wrapEvent({
3238
- type: EventType.IncrementalSnapshot,
3239
- data: __assign({ source: IncrementalSource.MediaInteraction }, p),
3240
- }));
3241
- },
3242
- styleSheetRuleCb: function (r) {
3243
- return wrappedEmit(wrapEvent({
3244
- type: EventType.IncrementalSnapshot,
3245
- data: __assign({ source: IncrementalSource.StyleSheetRule }, r),
3246
- }));
3247
- },
3248
- styleDeclarationCb: function (r) {
3249
- return wrappedEmit(wrapEvent({
3250
- type: EventType.IncrementalSnapshot,
3251
- data: __assign({ source: IncrementalSource.StyleDeclaration }, r),
3252
- }));
3253
- },
3012
+ viewportResizeCb: (d) => wrappedEmit(wrapEvent({
3013
+ type: EventType.IncrementalSnapshot,
3014
+ data: Object.assign({ source: IncrementalSource.ViewportResize }, d),
3015
+ })),
3016
+ inputCb: (v) => wrappedEmit(wrapEvent({
3017
+ type: EventType.IncrementalSnapshot,
3018
+ data: Object.assign({ source: IncrementalSource.Input }, v),
3019
+ })),
3020
+ mediaInteractionCb: (p) => wrappedEmit(wrapEvent({
3021
+ type: EventType.IncrementalSnapshot,
3022
+ data: Object.assign({ source: IncrementalSource.MediaInteraction }, p),
3023
+ })),
3024
+ styleSheetRuleCb: (r) => wrappedEmit(wrapEvent({
3025
+ type: EventType.IncrementalSnapshot,
3026
+ data: Object.assign({ source: IncrementalSource.StyleSheetRule }, r),
3027
+ })),
3028
+ styleDeclarationCb: (r) => wrappedEmit(wrapEvent({
3029
+ type: EventType.IncrementalSnapshot,
3030
+ data: Object.assign({ source: IncrementalSource.StyleDeclaration }, r),
3031
+ })),
3254
3032
  canvasMutationCb: wrappedCanvasMutationEmit,
3255
- fontCb: function (p) {
3256
- return wrappedEmit(wrapEvent({
3257
- type: EventType.IncrementalSnapshot,
3258
- data: __assign({ source: IncrementalSource.Font }, p),
3259
- }));
3260
- },
3261
- blockClass: blockClass,
3262
- ignoreClass: ignoreClass,
3263
- ignoreSelector: ignoreSelector,
3264
- maskTextClass: maskTextClass,
3265
- maskTextSelector: maskTextSelector,
3266
- unmaskTextSelector: unmaskTextSelector,
3267
- maskInputSelector: maskInputSelector,
3268
- unmaskInputSelector: unmaskInputSelector,
3269
- maskInputOptions: maskInputOptions,
3270
- inlineStylesheet: inlineStylesheet,
3271
- sampling: sampling,
3272
- recordCanvas: recordCanvas,
3273
- inlineImages: inlineImages,
3274
- userTriggeredOnInput: userTriggeredOnInput,
3275
- collectFonts: collectFonts,
3276
- doc: doc,
3277
- maskInputFn: maskInputFn,
3278
- maskTextFn: maskTextFn,
3279
- blockSelector: blockSelector,
3280
- unblockSelector: unblockSelector,
3281
- slimDOMOptions: slimDOMOptions,
3282
- mirror: mirror,
3283
- iframeManager: iframeManager,
3284
- shadowDomManager: shadowDomManager,
3285
- canvasManager: canvasManager,
3286
- plugins: ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (p) { return p.observer; })) === null || _a === void 0 ? void 0 : _a.map(function (p) { return ({
3033
+ fontCb: (p) => wrappedEmit(wrapEvent({
3034
+ type: EventType.IncrementalSnapshot,
3035
+ data: Object.assign({ source: IncrementalSource.Font }, p),
3036
+ })),
3037
+ blockClass,
3038
+ ignoreClass,
3039
+ ignoreSelector,
3040
+ maskTextClass,
3041
+ maskTextSelector,
3042
+ unmaskTextSelector,
3043
+ maskInputSelector,
3044
+ unmaskInputSelector,
3045
+ maskInputOptions,
3046
+ inlineStylesheet,
3047
+ sampling,
3048
+ recordCanvas,
3049
+ inlineImages,
3050
+ userTriggeredOnInput,
3051
+ collectFonts,
3052
+ doc,
3053
+ maskInputFn,
3054
+ maskTextFn,
3055
+ blockSelector,
3056
+ unblockSelector,
3057
+ slimDOMOptions,
3058
+ mirror,
3059
+ iframeManager,
3060
+ shadowDomManager,
3061
+ canvasManager,
3062
+ plugins: ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.filter((p) => p.observer)) === null || _a === void 0 ? void 0 : _a.map((p) => ({
3287
3063
  observer: p.observer,
3288
3064
  options: p.options,
3289
- callback: function (payload) {
3290
- return wrappedEmit(wrapEvent({
3291
- type: EventType.Plugin,
3292
- data: {
3293
- plugin: p.name,
3294
- payload: payload,
3295
- },
3296
- }));
3297
- },
3298
- }); })) || [],
3065
+ callback: (payload) => wrappedEmit(wrapEvent({
3066
+ type: EventType.Plugin,
3067
+ data: {
3068
+ plugin: p.name,
3069
+ payload,
3070
+ },
3071
+ })),
3072
+ }))) || [],
3299
3073
  }, hooks);
3300
3074
  };
3301
- iframeManager.addLoadListener(function (iframeEl) {
3075
+ iframeManager.addLoadListener((iframeEl) => {
3302
3076
  try {
3303
- handlers_1.push(observe_1(iframeEl.contentDocument));
3077
+ handlers.push(observe(iframeEl.contentDocument));
3304
3078
  }
3305
3079
  catch (error) {
3306
3080
  console.warn(error);
3307
3081
  }
3308
3082
  });
3309
- var init_1 = function () {
3083
+ const init = () => {
3310
3084
  takeFullSnapshot();
3311
- handlers_1.push(observe_1(document));
3085
+ handlers.push(observe(document));
3312
3086
  };
3313
3087
  if (document.readyState === 'interactive' ||
3314
3088
  document.readyState === 'complete') {
3315
- init_1();
3089
+ init();
3316
3090
  }
3317
3091
  else {
3318
- handlers_1.push(on('load', function () {
3092
+ handlers.push(on('load', () => {
3319
3093
  wrappedEmit(wrapEvent({
3320
3094
  type: EventType.Load,
3321
3095
  data: {},
3322
3096
  }));
3323
- init_1();
3097
+ init();
3324
3098
  }, window));
3325
3099
  }
3326
- return function () {
3327
- handlers_1.forEach(function (h) { return h(); });
3100
+ return () => {
3101
+ handlers.forEach((h) => h());
3328
3102
  };
3329
3103
  }
3330
3104
  catch (error) {
3331
3105
  console.warn(error);
3332
3106
  }
3333
3107
  }
3334
- record.addCustomEvent = function (tag, payload) {
3108
+ record.addCustomEvent = (tag, payload) => {
3335
3109
  if (!wrappedEmit) {
3336
3110
  throw new Error('please add custom event after start recording');
3337
3111
  }
3338
3112
  wrappedEmit(wrapEvent({
3339
3113
  type: EventType.Custom,
3340
3114
  data: {
3341
- tag: tag,
3342
- payload: payload,
3115
+ tag,
3116
+ payload,
3343
3117
  },
3344
3118
  }));
3345
3119
  };
3346
- record.freezePage = function () {
3347
- mutationBuffers.forEach(function (buf) { return buf.freeze(); });
3120
+ record.freezePage = () => {
3121
+ mutationBuffers.forEach((buf) => buf.freeze());
3348
3122
  };
3349
- record.takeFullSnapshot = function (isCheckout) {
3123
+ record.takeFullSnapshot = (isCheckout) => {
3350
3124
  if (!takeFullSnapshot) {
3351
3125
  throw new Error('please take full snapshot after start recording');
3352
3126
  }
@@ -4040,6 +3814,12 @@ async function addEvent(
4040
3814
  } catch (error) {
4041
3815
  (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error(error);
4042
3816
  replay.stop();
3817
+
3818
+ const client = getCurrentHub().getClient();
3819
+
3820
+ if (client) {
3821
+ client.recordDroppedEvent('internal_sdk_error', 'replay');
3822
+ }
4043
3823
  }
4044
3824
  }
4045
3825
 
@@ -4244,11 +4024,16 @@ function handleFetchSpanListener(replay) {
4244
4024
  /**
4245
4025
  * Returns true if we think the given event is an error originating inside of rrweb.
4246
4026
  */
4247
- function isRrwebError(event) {
4027
+ function isRrwebError(event, hint) {
4248
4028
  if (event.type || !event.exception || !event.exception.values || !event.exception.values.length) {
4249
4029
  return false;
4250
4030
  }
4251
4031
 
4032
+ // @ts-ignore this may be set by rrweb when it finds errors
4033
+ if (hint.originalException && hint.originalException.__rrweb__) {
4034
+ return true;
4035
+ }
4036
+
4252
4037
  // Check if any exception originates from rrweb
4253
4038
  return event.exception.values.some(exception => {
4254
4039
  if (!exception.stacktrace || !exception.stacktrace.frames || !exception.stacktrace.frames.length) {
@@ -4263,7 +4048,7 @@ function isRrwebError(event) {
4263
4048
  * Returns a listener to be added to `addGlobalEventProcessor(listener)`.
4264
4049
  */
4265
4050
  function handleGlobalEventListener(replay) {
4266
- return (event) => {
4051
+ return (event, hint) => {
4267
4052
  // Do not apply replayId to the root event
4268
4053
  if (event.type === REPLAY_EVENT_NAME) {
4269
4054
  // Replays have separate set of breadcrumbs, do not include breadcrumbs
@@ -4274,7 +4059,7 @@ function handleGlobalEventListener(replay) {
4274
4059
 
4275
4060
  // Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
4276
4061
  // As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
4277
- if (isRrwebError(event) && !replay.getOptions()._experiments.captureExceptions) {
4062
+ if (isRrwebError(event, hint) && !replay.getOptions()._experiments.captureExceptions) {
4278
4063
  (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Ignoring error from rrweb internals', event);
4279
4064
  return null;
4280
4065
  }
@@ -4858,7 +4643,16 @@ async function prepareReplayEvent({
4858
4643
  }
4859
4644
 
4860
4645
  ) {
4861
- const preparedEvent = (await prepareEvent(client.getOptions(), event, { event_id }, scope)) ;
4646
+ const integrations =
4647
+ typeof client._integrations === 'object' && client._integrations !== null && !Array.isArray(client._integrations)
4648
+ ? Object.keys(client._integrations)
4649
+ : undefined;
4650
+ const preparedEvent = (await prepareEvent(
4651
+ client.getOptions(),
4652
+ event,
4653
+ { event_id, integrations },
4654
+ scope,
4655
+ )) ;
4862
4656
 
4863
4657
  // If e.g. a global event processor returned null
4864
4658
  if (!preparedEvent) {
@@ -4999,11 +4793,6 @@ async function sendReplayRequest({
4999
4793
  return response;
5000
4794
  }
5001
4795
 
5002
- const rateLimits = updateRateLimits({}, response);
5003
- if (isRateLimited(rateLimits, 'replay')) {
5004
- throw new RateLimitError(rateLimits);
5005
- }
5006
-
5007
4796
  // If the status code is invalid, we want to immediately stop & not retry
5008
4797
  if (typeof response.statusCode === 'number' && (response.statusCode < 200 || response.statusCode >= 300)) {
5009
4798
  throw new TransportStatusCodeError(response.statusCode);
@@ -5012,17 +4801,6 @@ async function sendReplayRequest({
5012
4801
  return response;
5013
4802
  }
5014
4803
 
5015
- /**
5016
- * This error indicates that we hit a rate limit API error.
5017
- */
5018
- class RateLimitError extends Error {
5019
-
5020
- constructor(rateLimits) {
5021
- super('Rate limit hit');
5022
- this.rateLimits = rateLimits;
5023
- }
5024
- }
5025
-
5026
4804
  /**
5027
4805
  * This error indicates that the transport returned an invalid status code.
5028
4806
  */
@@ -5053,7 +4831,7 @@ async function sendReplay(
5053
4831
  await sendReplayRequest(replayData);
5054
4832
  return true;
5055
4833
  } catch (err) {
5056
- if (err instanceof RateLimitError || err instanceof TransportStatusCodeError) {
4834
+ if (err instanceof TransportStatusCodeError) {
5057
4835
  throw err;
5058
4836
  }
5059
4837
 
@@ -5517,8 +5295,8 @@ class ReplayContainer {
5517
5295
  this._handleException(err);
5518
5296
  }
5519
5297
 
5520
- // _performanceObserver //
5521
- if (!('_performanceObserver' in WINDOW)) {
5298
+ // PerformanceObserver //
5299
+ if (!('PerformanceObserver' in WINDOW)) {
5522
5300
  return;
5523
5301
  }
5524
5302
 
@@ -5850,14 +5628,16 @@ class ReplayContainer {
5850
5628
  } catch (err) {
5851
5629
  this._handleException(err);
5852
5630
 
5853
- if (err instanceof RateLimitError) {
5854
- this._handleRateLimit(err.rateLimits);
5855
- return;
5856
- }
5857
-
5858
- // This means we retried 3 times, and all of them failed
5631
+ // This means we retried 3 times and all of them failed,
5632
+ // or we ran into a problem we don't want to retry, like rate limiting.
5859
5633
  // In this case, we want to completely stop the replay - otherwise, we may get inconsistent segments
5860
5634
  this.stop();
5635
+
5636
+ const client = getCurrentHub().getClient();
5637
+
5638
+ if (client) {
5639
+ client.recordDroppedEvent('send_error', 'replay');
5640
+ }
5861
5641
  }
5862
5642
  }
5863
5643
 
@@ -5914,31 +5694,6 @@ class ReplayContainer {
5914
5694
  saveSession(this.session);
5915
5695
  }
5916
5696
  }
5917
-
5918
- /**
5919
- * Pauses the replay and resumes it after the rate-limit duration is over.
5920
- */
5921
- _handleRateLimit(rateLimits) {
5922
- // in case recording is already paused, we don't need to do anything, as we might have already paused because of a
5923
- // rate limit
5924
- if (this.isPaused()) {
5925
- return;
5926
- }
5927
-
5928
- const rateLimitEnd = disabledUntil(rateLimits, 'replay');
5929
- const rateLimitDuration = rateLimitEnd - Date.now();
5930
-
5931
- if (rateLimitDuration > 0) {
5932
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.warn('[Replay]', `Rate limit hit, pausing replay for ${rateLimitDuration}ms`);
5933
- this.pause();
5934
- this._debouncedFlush.cancel();
5935
-
5936
- setTimeout(() => {
5937
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.info('[Replay]', 'Resuming replay after rate limit');
5938
- this.resume();
5939
- }, rateLimitDuration);
5940
- }
5941
- }
5942
5697
  }
5943
5698
 
5944
5699
  function getOption(
@@ -6088,6 +5843,8 @@ class Replay {
6088
5843
  // eslint-disable-next-line deprecation/deprecation
6089
5844
  blockSelector,
6090
5845
  // eslint-disable-next-line deprecation/deprecation
5846
+ maskInputOptions,
5847
+ // eslint-disable-next-line deprecation/deprecation
6091
5848
  maskTextClass,
6092
5849
  // eslint-disable-next-line deprecation/deprecation
6093
5850
  maskTextSelector,
@@ -6096,6 +5853,7 @@ class Replay {
6096
5853
  } = {}) {Replay.prototype.__init.call(this);
6097
5854
  this._recordingOptions = {
6098
5855
  maskAllInputs,
5856
+ maskInputOptions: { ...(maskInputOptions || {}), password: true },
6099
5857
  maskTextFn: maskFn,
6100
5858
  maskInputFn: maskFn,
6101
5859