@anyreplay/browser 0.1.0 → 0.1.1

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