@sentry/replay 7.36.0 → 7.37.1

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