@posthog/rrweb-snapshot 0.0.30 → 0.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/record.cjs +980 -0
  2. package/dist/record.cjs.map +1 -0
  3. package/dist/record.d.cts +265 -0
  4. package/dist/record.d.ts +265 -0
  5. package/dist/record.js +981 -0
  6. package/dist/record.js.map +1 -0
  7. package/dist/record.umd.cjs +1556 -0
  8. package/dist/record.umd.cjs.map +7 -0
  9. package/dist/record.umd.min.cjs +32 -0
  10. package/dist/record.umd.min.cjs.map +7 -0
  11. package/dist/replay.cjs +4356 -0
  12. package/dist/replay.cjs.map +1 -0
  13. package/dist/replay.d.cts +219 -0
  14. package/dist/replay.d.ts +219 -0
  15. package/dist/replay.js +4357 -0
  16. package/dist/replay.js.map +1 -0
  17. package/dist/replay.umd.cjs +4962 -0
  18. package/dist/replay.umd.cjs.map +7 -0
  19. package/dist/replay.umd.min.cjs +60 -0
  20. package/dist/replay.umd.min.cjs.map +7 -0
  21. package/dist/rrweb-snapshot.cjs +38 -5816
  22. package/dist/rrweb-snapshot.cjs.map +1 -1
  23. package/dist/rrweb-snapshot.js +24 -5802
  24. package/dist/rrweb-snapshot.js.map +1 -1
  25. package/dist/rrweb-snapshot.umd.cjs +5581 -5468
  26. package/dist/rrweb-snapshot.umd.cjs.map +4 -4
  27. package/dist/rrweb-snapshot.umd.min.cjs +15 -15
  28. package/dist/rrweb-snapshot.umd.min.cjs.map +4 -4
  29. package/dist/types-FDk_ocpu.js +535 -0
  30. package/dist/types-FDk_ocpu.js.map +1 -0
  31. package/dist/types-pLXhbZlp.cjs +534 -0
  32. package/dist/types-pLXhbZlp.cjs.map +1 -0
  33. package/dist/types-pLXhbZlp.umd.cjs +567 -0
  34. package/dist/types-pLXhbZlp.umd.cjs.map +7 -0
  35. package/dist/types-pLXhbZlp.umd.min.cjs +32 -0
  36. package/dist/types-pLXhbZlp.umd.min.cjs.map +7 -0
  37. package/package.json +26 -6
  38. /package/dist/{index.d.cts → rrweb-snapshot.d.cts} +0 -0
  39. /package/dist/{index.d.ts → rrweb-snapshot.d.ts} +0 -0
@@ -0,0 +1,1556 @@
1
+ (function (g, f) {
2
+ if ("object" == typeof exports && "object" == typeof module) {
3
+ module.exports = f();
4
+ } else if ("function" == typeof define && define.amd) {
5
+ define("rrwebSnapshotRecord", [], f);
6
+ } else if ("object" == typeof exports) {
7
+ exports["rrwebSnapshotRecord"] = f();
8
+ } else {
9
+ g["rrwebSnapshotRecord"] = f();
10
+ }
11
+ }(this, () => {
12
+ var exports = {};
13
+ var module = { exports };
14
+ "use strict";
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __commonJS = (cb, mod) => function __require() {
17
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ };
19
+
20
+ // dist/types-pLXhbZlp.cjs
21
+ var require_types_pLXhbZlp = __commonJS({
22
+ "dist/types-pLXhbZlp.cjs"(exports2) {
23
+ "use strict";
24
+ var __defProp = Object.defineProperty;
25
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
26
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
27
+ var NodeType$1 = /* @__PURE__ */ ((NodeType2) => {
28
+ NodeType2[NodeType2["Document"] = 0] = "Document";
29
+ NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
30
+ NodeType2[NodeType2["Element"] = 2] = "Element";
31
+ NodeType2[NodeType2["Text"] = 3] = "Text";
32
+ NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
33
+ NodeType2[NodeType2["Comment"] = 5] = "Comment";
34
+ return NodeType2;
35
+ })(NodeType$1 || {});
36
+ var testableAccessors = {
37
+ Node: ["childNodes", "parentNode", "parentElement", "textContent"],
38
+ ShadowRoot: ["host", "styleSheets"],
39
+ Element: ["shadowRoot", "querySelector", "querySelectorAll"],
40
+ MutationObserver: []
41
+ };
42
+ var testableMethods = {
43
+ Node: ["contains", "getRootNode"],
44
+ ShadowRoot: ["getSelection"],
45
+ Element: [],
46
+ MutationObserver: ["constructor"]
47
+ };
48
+ var untaintedBasePrototype = {};
49
+ function angularZoneUnpatchedAlternative(key) {
50
+ var _a, _b;
51
+ const angularUnpatchedVersionSymbol = (_b = (_a = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a.__symbol__) == null ? void 0 : _b.call(_a, key);
52
+ if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
53
+ return globalThis[angularUnpatchedVersionSymbol];
54
+ } else {
55
+ return void 0;
56
+ }
57
+ }
58
+ function getUntaintedPrototype(key) {
59
+ if (untaintedBasePrototype[key])
60
+ return untaintedBasePrototype[key];
61
+ const candidate = angularZoneUnpatchedAlternative(key) || globalThis[key];
62
+ const defaultPrototype = candidate.prototype;
63
+ const accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
64
+ const isUntaintedAccessors = Boolean(
65
+ accessorNames && // @ts-expect-error 2345
66
+ accessorNames.every(
67
+ (accessor) => {
68
+ var _a, _b;
69
+ return Boolean(
70
+ (_b = (_a = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a.get) == null ? void 0 : _b.toString().includes("[native code]")
71
+ );
72
+ }
73
+ )
74
+ );
75
+ const methodNames = key in testableMethods ? testableMethods[key] : void 0;
76
+ const isUntaintedMethods = Boolean(
77
+ methodNames && methodNames.every(
78
+ // @ts-expect-error 2345
79
+ (method) => {
80
+ var _a;
81
+ return typeof defaultPrototype[method] === "function" && ((_a = defaultPrototype[method]) == null ? void 0 : _a.toString().includes("[native code]"));
82
+ }
83
+ )
84
+ );
85
+ if (isUntaintedAccessors && isUntaintedMethods) {
86
+ untaintedBasePrototype[key] = candidate.prototype;
87
+ return candidate.prototype;
88
+ }
89
+ try {
90
+ const iframeEl = document.createElement("iframe");
91
+ document.body.appendChild(iframeEl);
92
+ const win = iframeEl.contentWindow;
93
+ if (!win) return candidate.prototype;
94
+ const untaintedObject = win[key].prototype;
95
+ document.body.removeChild(iframeEl);
96
+ if (!untaintedObject) return defaultPrototype;
97
+ return untaintedBasePrototype[key] = untaintedObject;
98
+ } catch (e) {
99
+ return defaultPrototype;
100
+ }
101
+ }
102
+ var untaintedAccessorCache = {};
103
+ function getUntaintedAccessor(key, instance, accessor) {
104
+ var _a;
105
+ const cacheKey = `${key}.${String(accessor)}`;
106
+ if (untaintedAccessorCache[cacheKey])
107
+ return untaintedAccessorCache[cacheKey].call(
108
+ instance
109
+ );
110
+ const untaintedPrototype = getUntaintedPrototype(key);
111
+ const untaintedAccessor = (_a = Object.getOwnPropertyDescriptor(
112
+ untaintedPrototype,
113
+ accessor
114
+ )) == null ? void 0 : _a.get;
115
+ if (!untaintedAccessor) return instance[accessor];
116
+ untaintedAccessorCache[cacheKey] = untaintedAccessor;
117
+ return untaintedAccessor.call(instance);
118
+ }
119
+ var untaintedMethodCache = {};
120
+ function getUntaintedMethod(key, instance, method) {
121
+ const cacheKey = `${key}.${String(method)}`;
122
+ if (untaintedMethodCache[cacheKey])
123
+ return untaintedMethodCache[cacheKey].bind(
124
+ instance
125
+ );
126
+ const untaintedPrototype = getUntaintedPrototype(key);
127
+ const untaintedMethod = untaintedPrototype[method];
128
+ if (typeof untaintedMethod !== "function") return instance[method];
129
+ untaintedMethodCache[cacheKey] = untaintedMethod;
130
+ return untaintedMethod.bind(instance);
131
+ }
132
+ function childNodes(n) {
133
+ return getUntaintedAccessor("Node", n, "childNodes");
134
+ }
135
+ function parentNode(n) {
136
+ return getUntaintedAccessor("Node", n, "parentNode");
137
+ }
138
+ function parentElement(n) {
139
+ return getUntaintedAccessor("Node", n, "parentElement");
140
+ }
141
+ function textContent(n) {
142
+ return getUntaintedAccessor("Node", n, "textContent");
143
+ }
144
+ function contains(n, other) {
145
+ return getUntaintedMethod("Node", n, "contains")(other);
146
+ }
147
+ function getRootNode(n) {
148
+ return getUntaintedMethod("Node", n, "getRootNode")();
149
+ }
150
+ function host(n) {
151
+ if (!n || !("host" in n)) return null;
152
+ return getUntaintedAccessor("ShadowRoot", n, "host");
153
+ }
154
+ function styleSheets(n) {
155
+ return n.styleSheets;
156
+ }
157
+ function shadowRoot(n) {
158
+ if (!n || !("shadowRoot" in n)) return null;
159
+ return getUntaintedAccessor("Element", n, "shadowRoot");
160
+ }
161
+ function querySelector(n, selectors) {
162
+ return getUntaintedAccessor("Element", n, "querySelector")(selectors);
163
+ }
164
+ function querySelectorAll(n, selectors) {
165
+ return getUntaintedAccessor("Element", n, "querySelectorAll")(selectors);
166
+ }
167
+ function mutationObserverCtor() {
168
+ return getUntaintedPrototype("MutationObserver").constructor;
169
+ }
170
+ function patch(source, name, replacement) {
171
+ try {
172
+ if (!(name in source)) {
173
+ return () => {
174
+ };
175
+ }
176
+ const original = source[name];
177
+ const wrapped = replacement(original);
178
+ if (typeof wrapped === "function") {
179
+ wrapped.prototype = wrapped.prototype || {};
180
+ Object.defineProperties(wrapped, {
181
+ __rrweb_original__: {
182
+ enumerable: false,
183
+ value: original
184
+ }
185
+ });
186
+ }
187
+ source[name] = wrapped;
188
+ return () => {
189
+ source[name] = original;
190
+ };
191
+ } catch (e) {
192
+ return () => {
193
+ };
194
+ }
195
+ }
196
+ var index = {
197
+ childNodes,
198
+ parentNode,
199
+ parentElement,
200
+ textContent,
201
+ contains,
202
+ getRootNode,
203
+ host,
204
+ styleSheets,
205
+ shadowRoot,
206
+ querySelector,
207
+ querySelectorAll,
208
+ mutationObserver: mutationObserverCtor,
209
+ patch
210
+ };
211
+ function isElement(n) {
212
+ return n.nodeType === n.ELEMENT_NODE;
213
+ }
214
+ function isShadowRoot(n) {
215
+ const hostEl = (
216
+ // anchor and textarea elements also have a `host` property
217
+ // but only shadow roots have a `mode` property
218
+ n && "host" in n && "mode" in n && index.host(n) || null
219
+ );
220
+ return Boolean(
221
+ hostEl && "shadowRoot" in hostEl && index.shadowRoot(hostEl) === n
222
+ );
223
+ }
224
+ function isNativeShadowDom(shadowRoot2) {
225
+ return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
226
+ }
227
+ function fixBrowserCompatibilityIssuesInCSS(cssText) {
228
+ if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
229
+ cssText = cssText.replace(
230
+ /\sbackground-clip:\s*text;/g,
231
+ " -webkit-background-clip: text; background-clip: text;"
232
+ );
233
+ }
234
+ return cssText;
235
+ }
236
+ function escapeImportStatement(rule) {
237
+ const { cssText } = rule;
238
+ if (cssText.split('"').length < 3) return cssText;
239
+ const statement = ["@import", `url(${JSON.stringify(rule.href)})`];
240
+ if (rule.layerName === "") {
241
+ statement.push(`layer`);
242
+ } else if (rule.layerName) {
243
+ statement.push(`layer(${rule.layerName})`);
244
+ }
245
+ if (rule.supportsText) {
246
+ statement.push(`supports(${rule.supportsText})`);
247
+ }
248
+ if (rule.media.length) {
249
+ statement.push(rule.media.mediaText);
250
+ }
251
+ return statement.join(" ") + ";";
252
+ }
253
+ function stringifyStylesheet(s) {
254
+ try {
255
+ const rules = s.rules || s.cssRules;
256
+ if (!rules) {
257
+ return null;
258
+ }
259
+ let sheetHref = s.href;
260
+ if (!sheetHref && s.ownerNode) {
261
+ sheetHref = s.ownerNode.baseURI;
262
+ }
263
+ const stringifiedRules = Array.from(
264
+ rules,
265
+ (rule) => stringifyRule(rule, sheetHref)
266
+ ).join("");
267
+ return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
268
+ } catch (error) {
269
+ return null;
270
+ }
271
+ }
272
+ function stringifyRule(rule, sheetHref) {
273
+ var _a;
274
+ if (isCSSImportRule(rule)) {
275
+ let importStringified;
276
+ try {
277
+ importStringified = // for same-origin stylesheets,
278
+ // we can access the imported stylesheet rules directly
279
+ stringifyStylesheet(rule.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
280
+ escapeImportStatement(rule);
281
+ } catch (error) {
282
+ importStringified = rule.cssText;
283
+ }
284
+ try {
285
+ if (importStringified && ((_a = rule.styleSheet) == null ? void 0 : _a.href)) {
286
+ return absolutifyURLs(importStringified, rule.styleSheet.href);
287
+ }
288
+ } catch (e) {
289
+ }
290
+ return importStringified;
291
+ } else {
292
+ let ruleStringified = rule.cssText;
293
+ if (isCSSStyleRule(rule) && rule.selectorText.includes(":")) {
294
+ ruleStringified = fixSafariColons(ruleStringified);
295
+ }
296
+ if (sheetHref) {
297
+ return absolutifyURLs(ruleStringified, sheetHref);
298
+ }
299
+ return ruleStringified;
300
+ }
301
+ }
302
+ function fixSafariColons(cssStringified) {
303
+ const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
304
+ return cssStringified.replace(regex, "$1\\$2");
305
+ }
306
+ function isCSSImportRule(rule) {
307
+ return "styleSheet" in rule;
308
+ }
309
+ function isCSSStyleRule(rule) {
310
+ return "selectorText" in rule;
311
+ }
312
+ var Mirror = class {
313
+ constructor() {
314
+ __publicField(this, "idNodeMap", /* @__PURE__ */ new Map());
315
+ __publicField(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
316
+ }
317
+ getId(n) {
318
+ var _a;
319
+ if (!n) return -1;
320
+ const id = (_a = this.getMeta(n)) == null ? void 0 : _a.id;
321
+ return id != null ? id : -1;
322
+ }
323
+ getNode(id) {
324
+ return this.idNodeMap.get(id) || null;
325
+ }
326
+ getIds() {
327
+ return Array.from(this.idNodeMap.keys());
328
+ }
329
+ getMeta(n) {
330
+ return this.nodeMetaMap.get(n) || null;
331
+ }
332
+ // removes the node from idNodeMap
333
+ // doesn't remove the node from nodeMetaMap
334
+ removeNodeFromMap(n) {
335
+ const id = this.getId(n);
336
+ this.idNodeMap.delete(id);
337
+ if (n.childNodes) {
338
+ n.childNodes.forEach(
339
+ (childNode) => this.removeNodeFromMap(childNode)
340
+ );
341
+ }
342
+ }
343
+ has(id) {
344
+ return this.idNodeMap.has(id);
345
+ }
346
+ hasNode(node) {
347
+ return this.nodeMetaMap.has(node);
348
+ }
349
+ add(n, meta) {
350
+ const id = meta.id;
351
+ this.idNodeMap.set(id, n);
352
+ this.nodeMetaMap.set(n, meta);
353
+ }
354
+ replace(id, n) {
355
+ const oldNode = this.getNode(id);
356
+ if (oldNode) {
357
+ const meta = this.nodeMetaMap.get(oldNode);
358
+ if (meta) this.nodeMetaMap.set(n, meta);
359
+ }
360
+ this.idNodeMap.set(id, n);
361
+ }
362
+ reset() {
363
+ this.idNodeMap = /* @__PURE__ */ new Map();
364
+ this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
365
+ }
366
+ };
367
+ function createMirror() {
368
+ return new Mirror();
369
+ }
370
+ function maskInputValue({
371
+ element,
372
+ maskInputOptions,
373
+ tagName,
374
+ type,
375
+ value,
376
+ maskInputFn
377
+ }) {
378
+ let text = value || "";
379
+ const actualType = type && toLowerCase(type);
380
+ if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
381
+ if (maskInputFn) {
382
+ text = maskInputFn(text, element);
383
+ } else {
384
+ text = "*".repeat(text.length);
385
+ }
386
+ }
387
+ return text;
388
+ }
389
+ function toLowerCase(str) {
390
+ return str.toLowerCase();
391
+ }
392
+ var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
393
+ function is2DCanvasBlank(canvas) {
394
+ const ctx = canvas.getContext("2d");
395
+ if (!ctx) return true;
396
+ const chunkSize = 50;
397
+ for (let x = 0; x < canvas.width; x += chunkSize) {
398
+ for (let y = 0; y < canvas.height; y += chunkSize) {
399
+ const getImageData = ctx.getImageData;
400
+ const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
401
+ const pixelBuffer = new Uint32Array(
402
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
403
+ originalGetImageData.call(
404
+ ctx,
405
+ x,
406
+ y,
407
+ Math.min(chunkSize, canvas.width - x),
408
+ Math.min(chunkSize, canvas.height - y)
409
+ ).data.buffer
410
+ );
411
+ if (pixelBuffer.some((pixel) => pixel !== 0)) return false;
412
+ }
413
+ }
414
+ return true;
415
+ }
416
+ function isNodeMetaEqual(a, b) {
417
+ if (!a || !b || a.type !== b.type) return false;
418
+ if (a.type === NodeType$1.Document)
419
+ return a.compatMode === b.compatMode;
420
+ else if (a.type === NodeType$1.DocumentType)
421
+ return a.name === b.name && a.publicId === b.publicId && a.systemId === b.systemId;
422
+ else if (a.type === NodeType$1.Comment || a.type === NodeType$1.Text || a.type === NodeType$1.CDATA)
423
+ return a.textContent === b.textContent;
424
+ else if (a.type === NodeType$1.Element)
425
+ return a.tagName === b.tagName && JSON.stringify(a.attributes) === JSON.stringify(b.attributes) && a.isSVG === b.isSVG && a.needBlock === b.needBlock;
426
+ return false;
427
+ }
428
+ function getInputType(element) {
429
+ const type = element.type;
430
+ return element.hasAttribute("data-rr-is-password") ? "password" : type ? (
431
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
432
+ toLowerCase(type)
433
+ ) : null;
434
+ }
435
+ function extractFileExtension(path, baseURL) {
436
+ var _a;
437
+ let url;
438
+ try {
439
+ url = new URL(path, baseURL != null ? baseURL : window.location.href);
440
+ } catch (err) {
441
+ return null;
442
+ }
443
+ const regex = /\.([0-9a-z]+)(?:$)/i;
444
+ const match = url.pathname.match(regex);
445
+ return (_a = match == null ? void 0 : match[1]) != null ? _a : null;
446
+ }
447
+ function extractOrigin(url) {
448
+ let origin = "";
449
+ if (url.indexOf("//") > -1) {
450
+ origin = url.split("/").slice(0, 3).join("/");
451
+ } else {
452
+ origin = url.split("/")[0];
453
+ }
454
+ origin = origin.split("?")[0];
455
+ return origin;
456
+ }
457
+ var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
458
+ var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
459
+ var URL_WWW_MATCH = /^www\..*/i;
460
+ var DATA_URI = /^(data:)([^,]*),(.*)/i;
461
+ function absolutifyURLs(cssText, href) {
462
+ return (cssText || "").replace(
463
+ URL_IN_CSS_REF,
464
+ (origin, quote1, path1, quote2, path2, path3) => {
465
+ const filePath = path1 || path2 || path3;
466
+ const maybeQuote = quote1 || quote2 || "";
467
+ if (!filePath) {
468
+ return origin;
469
+ }
470
+ if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
471
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
472
+ }
473
+ if (DATA_URI.test(filePath)) {
474
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
475
+ }
476
+ if (filePath[0] === "/") {
477
+ return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
478
+ }
479
+ const stack = href.split("/");
480
+ const parts = filePath.split("/");
481
+ stack.pop();
482
+ for (const part of parts) {
483
+ if (part === ".") {
484
+ continue;
485
+ } else if (part === "..") {
486
+ stack.pop();
487
+ } else {
488
+ stack.push(part);
489
+ }
490
+ }
491
+ return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
492
+ }
493
+ );
494
+ }
495
+ var STRIPED_PLACEHOLDER_SVG = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxkZWZzPgogICAgPHBhdHRlcm4gaWQ9InN0cmlwZXMiIHBhdHRlcm5Vbml0cz0idXNlclNwYWNlT25Vc2UiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+CiAgICAgIDxyZWN0IHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iYmxhY2siLz4KICAgICAgPHBhdGggZD0iTTggMEgxNkwwIDE2VjhMOCAwWiIgZmlsbD0iIzJEMkQyRCIvPgogICAgICA8cGF0aCBkPSJNMTYgOFYxNkg4TDE2IDhaIiBmaWxsPSIjMkQyRDJEIi8+CiAgICA8L3BhdHRlcm4+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjc3RyaXBlcykiLz4KPC9zdmc+Cg==";
496
+ var MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION = 4096;
497
+ function recompressBase64Image(img, dataURL, type, quality) {
498
+ if (!img.complete || img.naturalWidth === 0) {
499
+ return dataURL;
500
+ }
501
+ if (img.naturalWidth > MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION || img.naturalHeight > MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION) {
502
+ return dataURL;
503
+ }
504
+ try {
505
+ const canvas = document.createElement("canvas");
506
+ canvas.width = img.naturalWidth;
507
+ canvas.height = img.naturalHeight;
508
+ const ctx = canvas.getContext("2d");
509
+ if (!ctx) {
510
+ return dataURL;
511
+ }
512
+ ctx.drawImage(img, 0, 0);
513
+ const recompressed = canvas.toDataURL(type || "image/webp", quality != null ? quality : 0.4);
514
+ return recompressed;
515
+ } catch (err) {
516
+ return dataURL;
517
+ }
518
+ }
519
+ function checkDataURLSize(dataURL, maxLength) {
520
+ if (!maxLength || dataURL.length <= maxLength) {
521
+ return dataURL;
522
+ }
523
+ return STRIPED_PLACEHOLDER_SVG;
524
+ }
525
+ var NodeType = /* @__PURE__ */ ((NodeType2) => {
526
+ NodeType2[NodeType2["Document"] = 0] = "Document";
527
+ NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
528
+ NodeType2[NodeType2["Element"] = 2] = "Element";
529
+ NodeType2[NodeType2["Text"] = 3] = "Text";
530
+ NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
531
+ NodeType2[NodeType2["Comment"] = 5] = "Comment";
532
+ return NodeType2;
533
+ })(NodeType || {});
534
+ exports2.Mirror = Mirror;
535
+ exports2.NodeType = NodeType;
536
+ exports2.NodeType$1 = NodeType$1;
537
+ exports2.absolutifyURLs = absolutifyURLs;
538
+ exports2.checkDataURLSize = checkDataURLSize;
539
+ exports2.createMirror = createMirror;
540
+ exports2.escapeImportStatement = escapeImportStatement;
541
+ exports2.extractFileExtension = extractFileExtension;
542
+ exports2.fixSafariColons = fixSafariColons;
543
+ exports2.getInputType = getInputType;
544
+ exports2.index = index;
545
+ exports2.is2DCanvasBlank = is2DCanvasBlank;
546
+ exports2.isCSSImportRule = isCSSImportRule;
547
+ exports2.isCSSStyleRule = isCSSStyleRule;
548
+ exports2.isElement = isElement;
549
+ exports2.isNativeShadowDom = isNativeShadowDom;
550
+ exports2.isNodeMetaEqual = isNodeMetaEqual;
551
+ exports2.isShadowRoot = isShadowRoot;
552
+ exports2.maskInputValue = maskInputValue;
553
+ exports2.recompressBase64Image = recompressBase64Image;
554
+ exports2.stringifyRule = stringifyRule;
555
+ exports2.stringifyStylesheet = stringifyStylesheet;
556
+ exports2.toLowerCase = toLowerCase;
557
+ }
558
+ });
559
+
560
+ // dist/record.cjs
561
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
562
+ var types = require_types_pLXhbZlp();
563
+ var _id = 1;
564
+ var tagNameRegex = new RegExp("[^a-z0-9-_:]");
565
+ var IGNORED_NODE = -2;
566
+ function genId() {
567
+ return _id++;
568
+ }
569
+ function getValidTagName(element) {
570
+ if (element instanceof HTMLFormElement) {
571
+ return "form";
572
+ }
573
+ const processedTagName = types.toLowerCase(element.tagName);
574
+ if (tagNameRegex.test(processedTagName)) {
575
+ return "div";
576
+ }
577
+ return processedTagName;
578
+ }
579
+ var canvasService;
580
+ var canvasCtx;
581
+ var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
582
+ var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
583
+ function getAbsoluteSrcsetString(doc, attributeValue) {
584
+ if (attributeValue.trim() === "") {
585
+ return attributeValue;
586
+ }
587
+ let pos = 0;
588
+ function collectCharacters(regEx) {
589
+ let chars;
590
+ const match = regEx.exec(attributeValue.substring(pos));
591
+ if (match) {
592
+ chars = match[0];
593
+ pos += chars.length;
594
+ return chars;
595
+ }
596
+ return "";
597
+ }
598
+ const output = [];
599
+ while (true) {
600
+ collectCharacters(SRCSET_COMMAS_OR_SPACES);
601
+ if (pos >= attributeValue.length) {
602
+ break;
603
+ }
604
+ let url = collectCharacters(SRCSET_NOT_SPACES);
605
+ if (url.slice(-1) === ",") {
606
+ url = absoluteToDoc(doc, url.substring(0, url.length - 1));
607
+ output.push(url);
608
+ } else {
609
+ let descriptorsStr = "";
610
+ url = absoluteToDoc(doc, url);
611
+ let inParens = false;
612
+ while (true) {
613
+ const c = attributeValue.charAt(pos);
614
+ if (c === "") {
615
+ output.push((url + descriptorsStr).trim());
616
+ break;
617
+ } else if (!inParens) {
618
+ if (c === ",") {
619
+ pos += 1;
620
+ output.push((url + descriptorsStr).trim());
621
+ break;
622
+ } else if (c === "(") {
623
+ inParens = true;
624
+ }
625
+ } else {
626
+ if (c === ")") {
627
+ inParens = false;
628
+ }
629
+ }
630
+ descriptorsStr += c;
631
+ pos += 1;
632
+ }
633
+ }
634
+ }
635
+ return output.join(", ");
636
+ }
637
+ var cachedDocument = /* @__PURE__ */ new WeakMap();
638
+ function absoluteToDoc(doc, attributeValue) {
639
+ if (!attributeValue || attributeValue.trim() === "") {
640
+ return attributeValue;
641
+ }
642
+ return getHref(doc, attributeValue);
643
+ }
644
+ function isSVGElement(el) {
645
+ return Boolean(el.tagName === "svg" || el.ownerSVGElement);
646
+ }
647
+ function getHref(doc, customHref) {
648
+ let a = cachedDocument.get(doc);
649
+ if (!a) {
650
+ a = doc.createElement("a");
651
+ cachedDocument.set(doc, a);
652
+ }
653
+ if (!customHref) {
654
+ customHref = "";
655
+ } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
656
+ return customHref;
657
+ }
658
+ a.setAttribute("href", customHref);
659
+ return a.href;
660
+ }
661
+ function transformAttribute(doc, tagName, name, value, element, dataURLOptions) {
662
+ if (!value) {
663
+ return value;
664
+ }
665
+ if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
666
+ const transformedValue = absoluteToDoc(doc, value);
667
+ if (tagName === "img" && transformedValue.startsWith("data:") && element) {
668
+ const img = element;
669
+ let processedDataURL = transformedValue;
670
+ if ((dataURLOptions == null ? void 0 : dataURLOptions.type) || (dataURLOptions == null ? void 0 : dataURLOptions.quality) !== void 0) {
671
+ processedDataURL = types.recompressBase64Image(
672
+ img,
673
+ transformedValue,
674
+ dataURLOptions.type,
675
+ dataURLOptions.quality
676
+ );
677
+ }
678
+ if (dataURLOptions == null ? void 0 : dataURLOptions.maxBase64ImageLength) {
679
+ processedDataURL = types.checkDataURLSize(
680
+ processedDataURL,
681
+ dataURLOptions.maxBase64ImageLength
682
+ );
683
+ }
684
+ return processedDataURL;
685
+ }
686
+ return transformedValue;
687
+ } else if (name === "xlink:href" && value[0] !== "#") {
688
+ return absoluteToDoc(doc, value);
689
+ } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
690
+ return absoluteToDoc(doc, value);
691
+ } else if (name === "srcset") {
692
+ return getAbsoluteSrcsetString(doc, value);
693
+ } else if (name === "style") {
694
+ return types.absolutifyURLs(value, getHref(doc));
695
+ } else if (tagName === "object" && name === "data") {
696
+ return absoluteToDoc(doc, value);
697
+ }
698
+ return value;
699
+ }
700
+ function ignoreAttribute(tagName, name, _value) {
701
+ return (tagName === "video" || tagName === "audio") && name === "autoplay";
702
+ }
703
+ function _isBlockedElement(element, blockClass, blockSelector) {
704
+ try {
705
+ if (typeof blockClass === "string") {
706
+ if (element.classList.contains(blockClass)) {
707
+ return true;
708
+ }
709
+ } else {
710
+ for (let eIndex = element.classList.length; eIndex--; ) {
711
+ const className = element.classList[eIndex];
712
+ if (blockClass.test(className)) {
713
+ return true;
714
+ }
715
+ }
716
+ }
717
+ if (blockSelector) {
718
+ return element.matches(blockSelector);
719
+ }
720
+ } catch (e) {
721
+ }
722
+ return false;
723
+ }
724
+ function classMatchesRegex(node, regex, checkAncestors) {
725
+ if (!node) return false;
726
+ if (node.nodeType !== node.ELEMENT_NODE) {
727
+ if (!checkAncestors) return false;
728
+ return classMatchesRegex(types.index.parentNode(node), regex, checkAncestors);
729
+ }
730
+ for (let eIndex = node.classList.length; eIndex--; ) {
731
+ const className = node.classList[eIndex];
732
+ if (regex.test(className)) {
733
+ return true;
734
+ }
735
+ }
736
+ if (!checkAncestors) return false;
737
+ return classMatchesRegex(types.index.parentNode(node), regex, checkAncestors);
738
+ }
739
+ function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
740
+ let el;
741
+ if (types.isElement(node)) {
742
+ el = node;
743
+ if (!types.index.childNodes(el).length) {
744
+ return false;
745
+ }
746
+ } else if (types.index.parentElement(node) === null) {
747
+ return false;
748
+ } else {
749
+ el = types.index.parentElement(node);
750
+ }
751
+ try {
752
+ if (typeof maskTextClass === "string") {
753
+ if (checkAncestors) {
754
+ if (el.closest(`.${maskTextClass}`)) return true;
755
+ } else {
756
+ if (el.classList.contains(maskTextClass)) return true;
757
+ }
758
+ } else {
759
+ if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
760
+ }
761
+ if (maskTextSelector) {
762
+ if (checkAncestors) {
763
+ if (el.closest(maskTextSelector)) return true;
764
+ } else {
765
+ if (el.matches(maskTextSelector)) return true;
766
+ }
767
+ }
768
+ } catch (e) {
769
+ }
770
+ return false;
771
+ }
772
+ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
773
+ const win = iframeEl.contentWindow;
774
+ if (!win) {
775
+ return;
776
+ }
777
+ let fired = false;
778
+ let readyState;
779
+ try {
780
+ readyState = win.document.readyState;
781
+ } catch (error) {
782
+ return;
783
+ }
784
+ if (readyState !== "complete") {
785
+ const timer = setTimeout(() => {
786
+ if (!fired) {
787
+ listener();
788
+ fired = true;
789
+ }
790
+ }, iframeLoadTimeout);
791
+ iframeEl.addEventListener("load", () => {
792
+ clearTimeout(timer);
793
+ fired = true;
794
+ listener();
795
+ });
796
+ return;
797
+ }
798
+ const blankUrl = "about:blank";
799
+ if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
800
+ setTimeout(listener, 0);
801
+ return iframeEl.addEventListener("load", listener);
802
+ }
803
+ iframeEl.addEventListener("load", listener);
804
+ }
805
+ function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
806
+ let fired = false;
807
+ let styleSheetLoaded;
808
+ try {
809
+ styleSheetLoaded = link.sheet;
810
+ } catch (error) {
811
+ return;
812
+ }
813
+ if (styleSheetLoaded) return;
814
+ const timer = setTimeout(() => {
815
+ if (!fired) {
816
+ listener();
817
+ fired = true;
818
+ }
819
+ }, styleSheetLoadTimeout);
820
+ link.addEventListener("load", () => {
821
+ clearTimeout(timer);
822
+ fired = true;
823
+ listener();
824
+ });
825
+ }
826
+ function serializeNode(n, options) {
827
+ const {
828
+ doc,
829
+ mirror,
830
+ blockClass,
831
+ blockSelector,
832
+ needsMask,
833
+ inlineStylesheet,
834
+ maskInputOptions = {},
835
+ maskTextFn,
836
+ maskInputFn,
837
+ dataURLOptions = {},
838
+ inlineImages,
839
+ recordCanvas,
840
+ keepIframeSrcFn,
841
+ newlyAddedElement = false
842
+ } = options;
843
+ const rootId = getRootId(doc, mirror);
844
+ switch (n.nodeType) {
845
+ case n.DOCUMENT_NODE:
846
+ if (n.compatMode !== "CSS1Compat") {
847
+ return {
848
+ type: types.NodeType$1.Document,
849
+ childNodes: [],
850
+ compatMode: n.compatMode
851
+ // probably "BackCompat"
852
+ };
853
+ } else {
854
+ return {
855
+ type: types.NodeType$1.Document,
856
+ childNodes: []
857
+ };
858
+ }
859
+ case n.DOCUMENT_TYPE_NODE:
860
+ return {
861
+ type: types.NodeType$1.DocumentType,
862
+ name: n.name,
863
+ publicId: n.publicId,
864
+ systemId: n.systemId,
865
+ rootId
866
+ };
867
+ case n.ELEMENT_NODE:
868
+ return serializeElementNode(n, {
869
+ doc,
870
+ blockClass,
871
+ blockSelector,
872
+ inlineStylesheet,
873
+ maskInputOptions,
874
+ maskInputFn,
875
+ dataURLOptions,
876
+ inlineImages,
877
+ recordCanvas,
878
+ keepIframeSrcFn,
879
+ newlyAddedElement,
880
+ rootId
881
+ });
882
+ case n.TEXT_NODE:
883
+ return serializeTextNode(n, {
884
+ doc,
885
+ needsMask,
886
+ maskTextFn,
887
+ rootId
888
+ });
889
+ case n.CDATA_SECTION_NODE:
890
+ return {
891
+ type: types.NodeType$1.CDATA,
892
+ textContent: "",
893
+ rootId
894
+ };
895
+ case n.COMMENT_NODE:
896
+ return {
897
+ type: types.NodeType$1.Comment,
898
+ textContent: types.index.textContent(n) || "",
899
+ rootId
900
+ };
901
+ default:
902
+ return false;
903
+ }
904
+ }
905
+ function getRootId(doc, mirror) {
906
+ if (!mirror.hasNode(doc)) return void 0;
907
+ const docId = mirror.getId(doc);
908
+ return docId === 1 ? void 0 : docId;
909
+ }
910
+ function serializeTextNode(n, options) {
911
+ var _a;
912
+ const { needsMask, maskTextFn, rootId } = options;
913
+ const parent = types.index.parentNode(n);
914
+ const parentTagName = parent && parent.tagName;
915
+ let text = types.index.textContent(n);
916
+ const isStyle = parentTagName === "STYLE" ? true : void 0;
917
+ const isScript = parentTagName === "SCRIPT" ? true : void 0;
918
+ if (isStyle && text) {
919
+ try {
920
+ if (n.nextSibling || n.previousSibling) {
921
+ } else if ((_a = parent.sheet) == null ? void 0 : _a.cssRules) {
922
+ text = types.stringifyStylesheet(parent.sheet);
923
+ }
924
+ } catch (err) {
925
+ console.warn(
926
+ `Cannot get CSS styles from text's parentNode. Error: ${err}`,
927
+ n
928
+ );
929
+ }
930
+ text = types.absolutifyURLs(text, getHref(options.doc));
931
+ }
932
+ if (isScript) {
933
+ text = "SCRIPT_PLACEHOLDER";
934
+ }
935
+ if (!isStyle && !isScript && text && needsMask) {
936
+ text = maskTextFn ? maskTextFn(text, types.index.parentElement(n)) : text.replace(/[\S]/g, "*");
937
+ }
938
+ return {
939
+ type: types.NodeType$1.Text,
940
+ textContent: text || "",
941
+ isStyle,
942
+ rootId
943
+ };
944
+ }
945
+ function findStylesheet(doc, href) {
946
+ return Array.from(doc.styleSheets).find((s) => s.href === href);
947
+ }
948
+ function hrefFrom(n) {
949
+ return n.href;
950
+ }
951
+ function serializeElementNode(n, options) {
952
+ const {
953
+ doc,
954
+ blockClass,
955
+ blockSelector,
956
+ inlineStylesheet,
957
+ maskInputOptions = {},
958
+ maskInputFn,
959
+ dataURLOptions = {},
960
+ inlineImages,
961
+ recordCanvas,
962
+ keepIframeSrcFn,
963
+ newlyAddedElement = false,
964
+ rootId
965
+ } = options;
966
+ const needBlock = _isBlockedElement(n, blockClass, blockSelector);
967
+ const tagName = getValidTagName(n);
968
+ let attributes = {};
969
+ const len = n.attributes.length;
970
+ for (let i = 0; i < len; i++) {
971
+ const attr = n.attributes[i];
972
+ if (!ignoreAttribute(tagName, attr.name, attr.value)) {
973
+ attributes[attr.name] = transformAttribute(
974
+ doc,
975
+ tagName,
976
+ types.toLowerCase(attr.name),
977
+ attr.value,
978
+ n,
979
+ dataURLOptions
980
+ );
981
+ }
982
+ }
983
+ if (tagName === "link" && inlineStylesheet) {
984
+ const href = hrefFrom(n);
985
+ if (href) {
986
+ let stylesheet = findStylesheet(doc, href);
987
+ if (!stylesheet && href.includes(".css")) {
988
+ const rootDomain = window.location.origin;
989
+ const stylesheetPath = href.replace(window.location.href, "");
990
+ const potentialStylesheetHref = rootDomain + "/" + stylesheetPath;
991
+ stylesheet = findStylesheet(doc, potentialStylesheetHref);
992
+ }
993
+ let cssText = null;
994
+ if (stylesheet) {
995
+ cssText = types.stringifyStylesheet(stylesheet);
996
+ }
997
+ if (cssText) {
998
+ delete attributes.rel;
999
+ delete attributes.href;
1000
+ attributes._cssText = cssText;
1001
+ }
1002
+ }
1003
+ }
1004
+ if (tagName === "style" && n.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
1005
+ !(n.innerText || types.index.textContent(n) || "").trim().length) {
1006
+ const cssText = types.stringifyStylesheet(
1007
+ n.sheet
1008
+ );
1009
+ if (cssText) {
1010
+ attributes._cssText = cssText;
1011
+ }
1012
+ }
1013
+ if (tagName === "input" || tagName === "textarea" || tagName === "select") {
1014
+ const value = n.value;
1015
+ const checked = n.checked;
1016
+ if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
1017
+ attributes.value = types.maskInputValue({
1018
+ element: n,
1019
+ type: types.getInputType(n),
1020
+ tagName,
1021
+ value,
1022
+ maskInputOptions,
1023
+ maskInputFn
1024
+ });
1025
+ } else if (checked) {
1026
+ attributes.checked = checked;
1027
+ }
1028
+ }
1029
+ if (tagName === "option") {
1030
+ if (n.selected && !maskInputOptions["select"]) {
1031
+ attributes.selected = true;
1032
+ } else {
1033
+ delete attributes.selected;
1034
+ }
1035
+ }
1036
+ if (tagName === "dialog" && n.open) {
1037
+ try {
1038
+ attributes.rr_open_mode = n.matches("dialog:modal") ? "modal" : "non-modal";
1039
+ } catch (e) {
1040
+ attributes.rr_open_mode = "modal";
1041
+ attributes.ph_rr_could_not_detect_modal = true;
1042
+ }
1043
+ }
1044
+ if (tagName === "canvas" && recordCanvas) {
1045
+ if (n.__context === "2d") {
1046
+ if (!types.is2DCanvasBlank(n)) {
1047
+ attributes.rr_dataURL = n.toDataURL(
1048
+ dataURLOptions.type,
1049
+ dataURLOptions.quality
1050
+ );
1051
+ }
1052
+ } else if (!("__context" in n)) {
1053
+ const canvasDataURL = n.toDataURL(
1054
+ dataURLOptions.type,
1055
+ dataURLOptions.quality
1056
+ );
1057
+ const blankCanvas = doc.createElement("canvas");
1058
+ blankCanvas.width = n.width;
1059
+ blankCanvas.height = n.height;
1060
+ const blankCanvasDataURL = blankCanvas.toDataURL(
1061
+ dataURLOptions.type,
1062
+ dataURLOptions.quality
1063
+ );
1064
+ if (canvasDataURL !== blankCanvasDataURL) {
1065
+ attributes.rr_dataURL = canvasDataURL;
1066
+ }
1067
+ }
1068
+ }
1069
+ if (tagName === "img" && inlineImages) {
1070
+ if (!canvasService) {
1071
+ canvasService = doc.createElement("canvas");
1072
+ canvasCtx = canvasService.getContext("2d");
1073
+ }
1074
+ const image = n;
1075
+ const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
1076
+ const priorCrossOrigin = image.crossOrigin;
1077
+ const recordInlineImage = () => {
1078
+ image.removeEventListener("load", recordInlineImage);
1079
+ try {
1080
+ canvasService.width = image.naturalWidth;
1081
+ canvasService.height = image.naturalHeight;
1082
+ canvasCtx.drawImage(image, 0, 0);
1083
+ attributes.rr_dataURL = canvasService.toDataURL(
1084
+ dataURLOptions.type,
1085
+ dataURLOptions.quality
1086
+ );
1087
+ } catch (err) {
1088
+ if (image.crossOrigin !== "anonymous") {
1089
+ image.crossOrigin = "anonymous";
1090
+ if (image.complete && image.naturalWidth !== 0)
1091
+ recordInlineImage();
1092
+ else image.addEventListener("load", recordInlineImage);
1093
+ return;
1094
+ } else {
1095
+ console.warn(
1096
+ `Cannot inline img src=${imageSrc}! Error: ${err}`
1097
+ );
1098
+ }
1099
+ }
1100
+ if (image.crossOrigin === "anonymous") {
1101
+ priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
1102
+ }
1103
+ };
1104
+ if (image.complete && image.naturalWidth !== 0) recordInlineImage();
1105
+ else image.addEventListener("load", recordInlineImage);
1106
+ }
1107
+ if (tagName === "audio" || tagName === "video") {
1108
+ const mediaAttributes = attributes;
1109
+ mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
1110
+ mediaAttributes.rr_mediaCurrentTime = n.currentTime;
1111
+ mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
1112
+ mediaAttributes.rr_mediaMuted = n.muted;
1113
+ mediaAttributes.rr_mediaLoop = n.loop;
1114
+ mediaAttributes.rr_mediaVolume = n.volume;
1115
+ }
1116
+ if (!newlyAddedElement) {
1117
+ if (n.scrollLeft) {
1118
+ attributes.rr_scrollLeft = n.scrollLeft;
1119
+ }
1120
+ if (n.scrollTop) {
1121
+ attributes.rr_scrollTop = n.scrollTop;
1122
+ }
1123
+ }
1124
+ if (needBlock) {
1125
+ const { width, height } = n.getBoundingClientRect();
1126
+ attributes = {
1127
+ class: attributes.class,
1128
+ rr_width: `${width}px`,
1129
+ rr_height: `${height}px`
1130
+ };
1131
+ }
1132
+ if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
1133
+ if (!n.contentDocument) {
1134
+ attributes.rr_src = attributes.src;
1135
+ }
1136
+ delete attributes.src;
1137
+ }
1138
+ let isCustomElement;
1139
+ try {
1140
+ if (customElements.get(tagName)) isCustomElement = true;
1141
+ } catch (e) {
1142
+ }
1143
+ return {
1144
+ type: types.NodeType$1.Element,
1145
+ tagName,
1146
+ attributes,
1147
+ childNodes: [],
1148
+ isSVG: isSVGElement(n) || void 0,
1149
+ needBlock,
1150
+ rootId,
1151
+ isCustom: isCustomElement
1152
+ };
1153
+ }
1154
+ function lowerIfExists(maybeAttr) {
1155
+ if (maybeAttr === void 0 || maybeAttr === null) {
1156
+ return "";
1157
+ } else {
1158
+ return maybeAttr.toLowerCase();
1159
+ }
1160
+ }
1161
+ function slimDOMExcluded(sn, slimDOMOptions) {
1162
+ if (slimDOMOptions.comment && sn.type === types.NodeType$1.Comment) {
1163
+ return true;
1164
+ } else if (sn.type === types.NodeType$1.Element) {
1165
+ if (slimDOMOptions.script && // script tag
1166
+ (sn.tagName === "script" || // (module)preload link
1167
+ sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
1168
+ sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && types.extractFileExtension(sn.attributes.href) === "js")) {
1169
+ return true;
1170
+ } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
1171
+ /^msapplication-tile(image|color)$/
1172
+ ) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
1173
+ return true;
1174
+ } else if (sn.tagName === "meta") {
1175
+ if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
1176
+ return true;
1177
+ } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
1178
+ lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
1179
+ return true;
1180
+ } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
1181
+ return true;
1182
+ } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
1183
+ return true;
1184
+ } 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:/))) {
1185
+ return true;
1186
+ } 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")) {
1187
+ return true;
1188
+ }
1189
+ }
1190
+ }
1191
+ return false;
1192
+ }
1193
+ function serializeNodeWithId(n, options) {
1194
+ const {
1195
+ doc,
1196
+ mirror,
1197
+ blockClass,
1198
+ blockSelector,
1199
+ maskTextClass,
1200
+ maskTextSelector,
1201
+ skipChild = false,
1202
+ inlineStylesheet = true,
1203
+ maskInputOptions = {},
1204
+ maskTextFn,
1205
+ maskInputFn,
1206
+ slimDOMOptions,
1207
+ dataURLOptions = {},
1208
+ inlineImages = false,
1209
+ recordCanvas = false,
1210
+ onSerialize,
1211
+ onIframeLoad,
1212
+ iframeLoadTimeout = 5e3,
1213
+ onStylesheetLoad,
1214
+ stylesheetLoadTimeout = 5e3,
1215
+ keepIframeSrcFn = () => false,
1216
+ newlyAddedElement = false
1217
+ } = options;
1218
+ let { needsMask } = options;
1219
+ let { preserveWhiteSpace = true } = options;
1220
+ if (!needsMask) {
1221
+ const checkAncestors = needsMask === void 0;
1222
+ needsMask = needMaskingText(
1223
+ n,
1224
+ maskTextClass,
1225
+ maskTextSelector,
1226
+ checkAncestors
1227
+ );
1228
+ }
1229
+ const _serializedNode = serializeNode(n, {
1230
+ doc,
1231
+ mirror,
1232
+ blockClass,
1233
+ blockSelector,
1234
+ needsMask,
1235
+ inlineStylesheet,
1236
+ maskInputOptions,
1237
+ maskTextFn,
1238
+ maskInputFn,
1239
+ dataURLOptions,
1240
+ inlineImages,
1241
+ recordCanvas,
1242
+ keepIframeSrcFn,
1243
+ newlyAddedElement
1244
+ });
1245
+ if (!_serializedNode) {
1246
+ console.warn(n, "not serialized");
1247
+ return null;
1248
+ }
1249
+ let id;
1250
+ if (mirror.hasNode(n)) {
1251
+ id = mirror.getId(n);
1252
+ } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === types.NodeType$1.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1253
+ id = IGNORED_NODE;
1254
+ } else {
1255
+ id = genId();
1256
+ }
1257
+ const serializedNode = Object.assign(_serializedNode, { id });
1258
+ mirror.add(n, serializedNode);
1259
+ if (id === IGNORED_NODE) {
1260
+ return null;
1261
+ }
1262
+ if (onSerialize) {
1263
+ onSerialize(n);
1264
+ }
1265
+ let recordChild = !skipChild;
1266
+ if (serializedNode.type === types.NodeType$1.Element) {
1267
+ recordChild = recordChild && !serializedNode.needBlock;
1268
+ delete serializedNode.needBlock;
1269
+ const shadowRootEl = types.index.shadowRoot(n);
1270
+ if (shadowRootEl && types.isNativeShadowDom(shadowRootEl))
1271
+ serializedNode.isShadowHost = true;
1272
+ }
1273
+ if ((serializedNode.type === types.NodeType$1.Document || serializedNode.type === types.NodeType$1.Element) && recordChild) {
1274
+ if (slimDOMOptions.headWhitespace && serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "head") {
1275
+ preserveWhiteSpace = false;
1276
+ }
1277
+ const bypassOptions = {
1278
+ doc,
1279
+ mirror,
1280
+ blockClass,
1281
+ blockSelector,
1282
+ needsMask,
1283
+ maskTextClass,
1284
+ maskTextSelector,
1285
+ skipChild,
1286
+ inlineStylesheet,
1287
+ maskInputOptions,
1288
+ maskTextFn,
1289
+ maskInputFn,
1290
+ slimDOMOptions,
1291
+ dataURLOptions,
1292
+ inlineImages,
1293
+ recordCanvas,
1294
+ preserveWhiteSpace,
1295
+ onSerialize,
1296
+ onIframeLoad,
1297
+ iframeLoadTimeout,
1298
+ onStylesheetLoad,
1299
+ stylesheetLoadTimeout,
1300
+ keepIframeSrcFn
1301
+ };
1302
+ if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1303
+ else {
1304
+ for (const childN of Array.from(types.index.childNodes(n))) {
1305
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1306
+ if (serializedChildNode) {
1307
+ serializedNode.childNodes.push(serializedChildNode);
1308
+ }
1309
+ }
1310
+ }
1311
+ let shadowRootEl = null;
1312
+ if (types.isElement(n) && (shadowRootEl = types.index.shadowRoot(n))) {
1313
+ for (const childN of Array.from(types.index.childNodes(shadowRootEl))) {
1314
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1315
+ if (serializedChildNode) {
1316
+ types.isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
1317
+ serializedNode.childNodes.push(serializedChildNode);
1318
+ }
1319
+ }
1320
+ }
1321
+ }
1322
+ const parent = types.index.parentNode(n);
1323
+ if (parent && types.isShadowRoot(parent) && types.isNativeShadowDom(parent)) {
1324
+ serializedNode.isShadow = true;
1325
+ }
1326
+ if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "iframe") {
1327
+ onceIframeLoaded(
1328
+ n,
1329
+ () => {
1330
+ const iframeDoc = n.contentDocument;
1331
+ if (iframeDoc && onIframeLoad) {
1332
+ const serializedIframeNode = serializeNodeWithId(iframeDoc, {
1333
+ doc: iframeDoc,
1334
+ mirror,
1335
+ blockClass,
1336
+ blockSelector,
1337
+ needsMask,
1338
+ maskTextClass,
1339
+ maskTextSelector,
1340
+ skipChild: false,
1341
+ inlineStylesheet,
1342
+ maskInputOptions,
1343
+ maskTextFn,
1344
+ maskInputFn,
1345
+ slimDOMOptions,
1346
+ dataURLOptions,
1347
+ inlineImages,
1348
+ recordCanvas,
1349
+ preserveWhiteSpace,
1350
+ onSerialize,
1351
+ onIframeLoad,
1352
+ iframeLoadTimeout,
1353
+ onStylesheetLoad,
1354
+ stylesheetLoadTimeout,
1355
+ keepIframeSrcFn
1356
+ });
1357
+ if (serializedIframeNode) {
1358
+ onIframeLoad(
1359
+ n,
1360
+ serializedIframeNode
1361
+ );
1362
+ }
1363
+ }
1364
+ },
1365
+ iframeLoadTimeout
1366
+ );
1367
+ }
1368
+ if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && types.extractFileExtension(serializedNode.attributes.href) === "css")) {
1369
+ onceStylesheetLoaded(
1370
+ n,
1371
+ () => {
1372
+ if (onStylesheetLoad) {
1373
+ const serializedLinkNode = serializeNodeWithId(n, {
1374
+ doc,
1375
+ mirror,
1376
+ blockClass,
1377
+ blockSelector,
1378
+ needsMask,
1379
+ maskTextClass,
1380
+ maskTextSelector,
1381
+ skipChild: false,
1382
+ inlineStylesheet,
1383
+ maskInputOptions,
1384
+ maskTextFn,
1385
+ maskInputFn,
1386
+ slimDOMOptions,
1387
+ dataURLOptions,
1388
+ inlineImages,
1389
+ recordCanvas,
1390
+ preserveWhiteSpace,
1391
+ onSerialize,
1392
+ onIframeLoad,
1393
+ iframeLoadTimeout,
1394
+ onStylesheetLoad,
1395
+ stylesheetLoadTimeout,
1396
+ keepIframeSrcFn
1397
+ });
1398
+ if (serializedLinkNode) {
1399
+ onStylesheetLoad(
1400
+ n,
1401
+ serializedLinkNode
1402
+ );
1403
+ }
1404
+ }
1405
+ },
1406
+ stylesheetLoadTimeout
1407
+ );
1408
+ }
1409
+ return serializedNode;
1410
+ }
1411
+ function snapshot(n, options) {
1412
+ const {
1413
+ mirror = new types.Mirror(),
1414
+ blockClass = "rr-block",
1415
+ blockSelector = null,
1416
+ maskTextClass = "rr-mask",
1417
+ maskTextSelector = null,
1418
+ inlineStylesheet = true,
1419
+ inlineImages = false,
1420
+ recordCanvas = false,
1421
+ maskAllInputs = false,
1422
+ maskTextFn,
1423
+ maskInputFn,
1424
+ slimDOM = false,
1425
+ dataURLOptions,
1426
+ preserveWhiteSpace,
1427
+ onSerialize,
1428
+ onIframeLoad,
1429
+ iframeLoadTimeout,
1430
+ onStylesheetLoad,
1431
+ stylesheetLoadTimeout,
1432
+ keepIframeSrcFn = () => false
1433
+ } = options || {};
1434
+ const maskInputOptions = maskAllInputs === true ? {
1435
+ color: true,
1436
+ date: true,
1437
+ "datetime-local": true,
1438
+ email: true,
1439
+ month: true,
1440
+ number: true,
1441
+ range: true,
1442
+ search: true,
1443
+ tel: true,
1444
+ text: true,
1445
+ time: true,
1446
+ url: true,
1447
+ week: true,
1448
+ textarea: true,
1449
+ select: true,
1450
+ password: true
1451
+ } : maskAllInputs === false ? {
1452
+ password: true
1453
+ } : maskAllInputs;
1454
+ const slimDOMOptions = slimDOM === true || slimDOM === "all" ? (
1455
+ // if true: set of sensible options that should not throw away any information
1456
+ {
1457
+ script: true,
1458
+ comment: true,
1459
+ headFavicon: true,
1460
+ headWhitespace: true,
1461
+ headMetaDescKeywords: slimDOM === "all",
1462
+ // destructive
1463
+ headMetaSocial: true,
1464
+ headMetaRobots: true,
1465
+ headMetaHttpEquiv: true,
1466
+ headMetaAuthorship: true,
1467
+ headMetaVerification: true
1468
+ }
1469
+ ) : slimDOM === false ? {} : slimDOM;
1470
+ return serializeNodeWithId(n, {
1471
+ doc: n,
1472
+ mirror,
1473
+ blockClass,
1474
+ blockSelector,
1475
+ maskTextClass,
1476
+ maskTextSelector,
1477
+ skipChild: false,
1478
+ inlineStylesheet,
1479
+ maskInputOptions,
1480
+ maskTextFn,
1481
+ maskInputFn,
1482
+ slimDOMOptions,
1483
+ dataURLOptions,
1484
+ inlineImages,
1485
+ recordCanvas,
1486
+ preserveWhiteSpace,
1487
+ onSerialize,
1488
+ onIframeLoad,
1489
+ iframeLoadTimeout,
1490
+ onStylesheetLoad,
1491
+ stylesheetLoadTimeout,
1492
+ keepIframeSrcFn,
1493
+ newlyAddedElement: false
1494
+ });
1495
+ }
1496
+ function visitSnapshot(node, onVisit) {
1497
+ function walk(current) {
1498
+ onVisit(current);
1499
+ if (current.type === types.NodeType$1.Document || current.type === types.NodeType$1.Element) {
1500
+ current.childNodes.forEach(walk);
1501
+ }
1502
+ }
1503
+ walk(node);
1504
+ }
1505
+ function cleanupSnapshot() {
1506
+ _id = 1;
1507
+ }
1508
+ exports.Mirror = types.Mirror;
1509
+ exports.NodeType = types.NodeType;
1510
+ exports.absolutifyURLs = types.absolutifyURLs;
1511
+ exports.checkDataURLSize = types.checkDataURLSize;
1512
+ exports.createMirror = types.createMirror;
1513
+ exports.escapeImportStatement = types.escapeImportStatement;
1514
+ exports.extractFileExtension = types.extractFileExtension;
1515
+ exports.fixSafariColons = types.fixSafariColons;
1516
+ exports.getInputType = types.getInputType;
1517
+ exports.is2DCanvasBlank = types.is2DCanvasBlank;
1518
+ exports.isCSSImportRule = types.isCSSImportRule;
1519
+ exports.isCSSStyleRule = types.isCSSStyleRule;
1520
+ exports.isElement = types.isElement;
1521
+ exports.isNativeShadowDom = types.isNativeShadowDom;
1522
+ exports.isNodeMetaEqual = types.isNodeMetaEqual;
1523
+ exports.isShadowRoot = types.isShadowRoot;
1524
+ exports.maskInputValue = types.maskInputValue;
1525
+ exports.recompressBase64Image = types.recompressBase64Image;
1526
+ exports.stringifyRule = types.stringifyRule;
1527
+ exports.stringifyStylesheet = types.stringifyStylesheet;
1528
+ exports.toLowerCase = types.toLowerCase;
1529
+ exports.IGNORED_NODE = IGNORED_NODE;
1530
+ exports.classMatchesRegex = classMatchesRegex;
1531
+ exports.cleanupSnapshot = cleanupSnapshot;
1532
+ exports.genId = genId;
1533
+ exports.ignoreAttribute = ignoreAttribute;
1534
+ exports.needMaskingText = needMaskingText;
1535
+ exports.serializeNodeWithId = serializeNodeWithId;
1536
+ exports.snapshot = snapshot;
1537
+ exports.transformAttribute = transformAttribute;
1538
+ exports.visitSnapshot = visitSnapshot;
1539
+ if (typeof module.exports == "object" && typeof exports == "object") {
1540
+ var __cp = (to, from, except, desc) => {
1541
+ if ((from && typeof from === "object") || typeof from === "function") {
1542
+ for (let key of Object.getOwnPropertyNames(from)) {
1543
+ if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
1544
+ Object.defineProperty(to, key, {
1545
+ get: () => from[key],
1546
+ enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
1547
+ });
1548
+ }
1549
+ }
1550
+ return to;
1551
+ };
1552
+ module.exports = __cp(module.exports, exports);
1553
+ }
1554
+ return module.exports;
1555
+ }))
1556
+ //# sourceMappingURL=record.umd.cjs.map